summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Grandin <grandinp@gmail.com>2019-06-04 10:14:17 -0600
committerPierre Grandin <grandinp@gmail.com>2019-06-04 10:14:17 -0600
commit92a5169423e470e4d1a5f4237cb2112266998d28 (patch)
treebee5f13203e0a0d99c8f6962c82deef9fe772b6e
parent5304cda121782db8e1e5e4685ae10780cce36394 (diff)
parentda3e1e0c186dfd6c6566f798811a27d001a7fb1d (diff)
downloadnavit-audio.tar.gz
Merge branch 'trunk' into audioaudio
-rw-r--r--.circleci/config.yml260
-rw-r--r--.gitchangelog.rc334
-rw-r--r--.gitchangelog.tpl42
-rw-r--r--.github/ISSUE_TEMPLATE.md2
-rw-r--r--.github/PULL_REQUEST_TEMPLATE.md6
-rw-r--r--.gitignore9
-rw-r--r--.mailmap35
-rw-r--r--.travis.yml23
-rw-r--r--AUTHORS75
-rw-r--r--CHANGELOG.md766
-rwxr-xr-xCMakeLists.txt990
-rw-r--r--CONTRIBUTING.md10
-rw-r--r--ChangeLog4
-rw-r--r--LGPL-220
-rw-r--r--README.md54
-rw-r--r--Toolchain/arm-mingw32ce.cmake8
-rw-r--r--Toolchain/i386-mingw32ce.cmake8
-rw-r--r--Toolchain/mingw.cmake34
-rw-r--r--Toolchain/mingw32.cmake21
-rw-r--r--build.gradle33
-rw-r--r--checkstyle.xml257
-rw-r--r--ci/build_android.sh34
-rw-r--r--ci/build_android_x86.sh41
-rw-r--r--ci/build_linux.sh40
-rw-r--r--ci/build_win32.sh8
-rw-r--r--ci/build_wince.sh3
-rw-r--r--ci/docker/tomtom/Dockerfile106
-rw-r--r--ci/docker/tomtom/README.md7
-rw-r--r--ci/docker/tomtom/entrypoint.sh3
-rw-r--r--ci/docker/tomtom/tomtom.cache5
-rw-r--r--ci/publish.sh17
-rw-r--r--ci/setup_common_requirements.sh1
-rw-r--r--cmake/FindDBus.cmake26
-rw-r--r--cmake/FindDBusGLib.cmake23
-rw-r--r--cmake/FindGTK2.cmake471
-rw-r--r--cmake/FindGlib.cmake39
-rw-r--r--cmake/FindGmodule.cmake28
-rw-r--r--cmake/FindProtobuf-c.cmake121
-rw-r--r--cmake/Findespeak.cmake29
-rw-r--r--cmake/LibFindMacros.cmake99
-rw-r--r--cmake/copy_files.cmake5
-rw-r--r--cmake/navit_macros.cmake6
-rwxr-xr-xcmake/version.cmake29
-rw-r--r--config.h.in (renamed from config.h.cmake)9
-rwxr-xr-xcontrib/sailfish/build_on_sailfish_sdk.sh15
-rwxr-xr-xcontrib/sailfish/build_sailfish_ci.sh22
-rwxr-xr-xcontrib/sailfish/navit-sailfish.spec50
-rw-r--r--contrib/tomtom/espeakdsp.c137
-rw-r--r--gradle/scripts/git-scm-version.gradle24
-rw-r--r--gradle/wrapper/gradle-wrapper.jarbin0 -> 53636 bytes
-rw-r--r--gradle/wrapper/gradle-wrapper.properties5
-rwxr-xr-xgradlew160
-rw-r--r--gradlew.bat90
-rw-r--r--man/CMakeLists.txt4
-rw-r--r--man/navit.12
-rw-r--r--navit/CMakeLists.txt291
-rw-r--r--navit/Doxyfile6
-rw-r--r--navit/android.c1317
-rw-r--r--navit/android.h1
-rw-r--r--navit/android/AndroidManifest.xml45
-rw-r--r--navit/android/AndroidManifest.xml.cmake18
-rw-r--r--navit/android/CMakeLists.txt184
-rw-r--r--navit/android/android_layout_default_new.xml2
-rw-r--r--navit/android/build.gradle96
-rwxr-xr-xnavit/android/change_xslt.sh27
-rw-r--r--navit/android/libs/TTS_library_stub.jarbin31633 -> 0 bytes
-rw-r--r--navit/android/libs/acra-4.8.5.jarbin154375 -> 0 bytes
-rw-r--r--navit/android/libs/android-support-v4.jarbin1364299 -> 0 bytes
-rw-r--r--navit/android/po2xml.xslt2
-rw-r--r--navit/android/res/layout/ua_com_vassiliev_filebrowser_layout.xml166
-rw-r--r--navit/android/res/values-v19/styles.xml11
-rw-r--r--navit/android/res/values-v21/styles.xml10
-rw-r--r--navit/android/res/values/strings-dont-translate.xml3
-rw-r--r--navit/android/res/values/strings.xml235
-rw-r--r--navit/android/res/values/styles.xml29
-rw-r--r--navit/android/src/org/navitproject/navit/FileBrowserActivity.java859
-rw-r--r--navit/android/src/org/navitproject/navit/Navit.java1901
-rw-r--r--navit/android/src/org/navitproject/navit/NavitActivityResult.java3
-rw-r--r--navit/android/src/org/navitproject/navit/NavitAddressSearchActivity.java771
-rwxr-xr-xnavit/android/src/org/navitproject/navit/NavitAppConfig.java165
-rw-r--r--navit/android/src/org/navitproject/navit/NavitBackupTask.java65
-rw-r--r--navit/android/src/org/navitproject/navit/NavitCamera.java32
-rw-r--r--navit/android/src/org/navitproject/navit/NavitDialogs.java384
-rw-r--r--navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java494
-rw-r--r--navit/android/src/org/navitproject/navit/NavitGraphics.java2281
-rw-r--r--navit/android/src/org/navitproject/navit/NavitMap.java60
-rw-r--r--navit/android/src/org/navitproject/navit/NavitMapDownloader.java1662
-rw-r--r--navit/android/src/org/navitproject/navit/NavitRestoreTask.java80
-rw-r--r--navit/android/src/org/navitproject/navit/NavitSensors.java50
-rw-r--r--navit/android/src/org/navitproject/navit/NavitSpeech.java53
-rw-r--r--navit/android/src/org/navitproject/navit/NavitSpeech2.java136
-rw-r--r--navit/android/src/org/navitproject/navit/NavitTextTranslations.java204
-rw-r--r--navit/android/src/org/navitproject/navit/NavitTimeout.java57
-rw-r--r--navit/android/src/org/navitproject/navit/NavitTraff.java108
-rw-r--r--navit/android/src/org/navitproject/navit/NavitVehicle.java323
-rw-r--r--navit/android/src/org/navitproject/navit/NavitWatch.java153
-rw-r--r--navit/announcement.c51
-rw-r--r--navit/atom.c36
-rw-r--r--navit/attr.c1522
-rw-r--r--navit/attr.h17
-rw-r--r--navit/attr_def.h7
-rw-r--r--navit/autoload/osso/CMakeLists.txt2
-rw-r--r--navit/autoload/osso/osso.c114
-rw-r--r--navit/binding/dbus/CMakeLists.txt8
-rw-r--r--navit/binding/dbus/binding_dbus.c3499
-rwxr-xr-xnavit/binding/dbus/eval.py12
-rw-r--r--navit/binding/dbus/navit.introspect4
-rwxr-xr-xnavit/binding/dbus/test.py12
-rw-r--r--navit/binding/python/attr.c89
-rw-r--r--navit/binding/python/binding_python.c374
-rw-r--r--navit/binding/python/config.c50
-rw-r--r--navit/binding/python/navigation.c60
-rw-r--r--navit/binding/python/navit.c158
-rw-r--r--navit/binding/python/pcoord.c77
-rw-r--r--navit/binding/python/route.c60
-rw-r--r--navit/binding/python/startup.py12
-rw-r--r--navit/binding/python/template.c83
-rw-r--r--navit/binding/win32/CMakeLists.txt6
-rw-r--r--navit/binding/win32/binding_win32.c131
-rw-r--r--navit/binding/win32/tell_navit.c263
-rw-r--r--navit/bookmarks.c1273
-rw-r--r--navit/browserplugin.c725
-rw-r--r--navit/builtin.c.in4
-rw-r--r--navit/cache.c590
-rw-r--r--navit/callback.c448
-rw-r--r--navit/command.c2870
-rw-r--r--navit/config_.c185
-rw-r--r--navit/coord.c541
-rw-r--r--navit/coord.h18
-rw-r--r--navit/country.c731
-rw-r--r--navit/data.h2
-rw-r--r--navit/data_window.c20
-rw-r--r--navit/data_window_int.h2
-rw-r--r--navit/debug.c761
-rw-r--r--navit/debug.h2
-rw-r--r--navit/endianess.h12
-rw-r--r--navit/event.c124
-rw-r--r--navit/event_glib.c222
-rwxr-xr-xnavit/fib-1.1/configure1045
-rw-r--r--navit/fib-1.1/configure.in17
-rw-r--r--navit/file.c1242
-rw-r--r--navit/file.h6
-rw-r--r--navit/font/freetype/CMakeLists.txt22
-rw-r--r--navit/font/freetype/font_freetype.c873
-rw-r--r--navit/fonts/CMakeLists.txt18
-rw-r--r--navit/fonts/License.txt8
-rw-r--r--navit/fonts/README4
-rw-r--r--navit/geom.c764
-rw-r--r--navit/graphics.c4459
-rw-r--r--navit/graphics.h2
-rw-r--r--navit/graphics/CMakeLists.txt4
-rw-r--r--navit/graphics/android/graphics_android.c1664
-rw-r--r--navit/graphics/cocoa/CMakeLists.txt4
-rw-r--r--navit/graphics/cocoa/graphics_cocoa.m68
-rw-r--r--navit/graphics/egl/CMakeLists.txt2
-rw-r--r--navit/graphics/egl/graphics_egl.c649
-rw-r--r--navit/graphics/gd/CMakeLists.txt2
-rw-r--r--navit/graphics/gd/graphics_gd.c1405
-rw-r--r--navit/graphics/gtk_drawing_area/CMakeLists.txt2
-rw-r--r--navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c1786
-rw-r--r--navit/graphics/null/graphics_null.c336
-rw-r--r--navit/graphics/opengl/CMakeLists.txt4
-rw-r--r--navit/graphics/opengl/graphics_opengl.c2441
-rw-r--r--navit/graphics/opengl/graphics_opengl_egl.c113
-rw-r--r--navit/graphics/opengl/graphics_opengl_x11.c237
-rw-r--r--navit/graphics/qt5/CMakeLists.txt12
-rw-r--r--navit/graphics/qt5/QNavitQuick.cpp108
-rw-r--r--navit/graphics/qt5/QNavitQuick.h3
-rw-r--r--navit/graphics/qt5/QNavitWidget.cpp98
-rw-r--r--navit/graphics/qt5/QNavitWidget.h8
-rw-r--r--navit/graphics/qt5/event_qt5.cpp79
-rw-r--r--navit/graphics/qt5/event_qt5.h4
-rw-r--r--navit/graphics/qt5/graphics_qt5.cpp307
-rw-r--r--navit/graphics/qt5/graphics_qt5.h4
-rw-r--r--navit/graphics/qt5/loader.qml2
-rw-r--r--navit/graphics/qt_qpainter/RenderArea.cpp336
-rw-r--r--navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp1228
-rw-r--r--navit/graphics/qt_qpainter/graphics_qt_qpainter.h8
-rw-r--r--navit/graphics/sdl/CMakeLists.txt2
-rw-r--r--navit/graphics/sdl/event.c489
-rw-r--r--navit/graphics/sdl/event_sdl.c395
-rw-r--r--navit/graphics/sdl/event_sdl.h2
-rw-r--r--navit/graphics/sdl/graphics_sdl.c1654
-rw-r--r--navit/graphics/sdl/raster.c2403
-rw-r--r--navit/graphics/sdl/raster.h3
-rw-r--r--navit/graphics/win32/graphics_win32.c986
-rw-r--r--navit/graphics/win32/xpm2bmp.c594
-rw-r--r--navit/gui.c236
-rw-r--r--navit/gui/gtk/CMakeLists.txt3
-rw-r--r--navit/gui/gtk/datawindow.c292
-rw-r--r--navit/gui/gtk/destination.c980
-rw-r--r--navit/gui/gtk/gui_gtk.h51
-rw-r--r--navit/gui/gtk/gui_gtk_action.c790
-rw-r--r--navit/gui/gtk/gui_gtk_poi.c685
-rw-r--r--navit/gui/gtk/gui_gtk_statusbar.c279
-rw-r--r--navit/gui/gtk/gui_gtk_window.c1299
-rw-r--r--navit/gui/internal/CMakeLists.txt4
-rw-r--r--navit/gui/internal/gui_internal.c5634
-rw-r--r--navit/gui/internal/gui_internal.h107
-rw-r--r--navit/gui/internal/gui_internal_bookmark.c486
-rw-r--r--navit/gui/internal/gui_internal_command.c2280
-rw-r--r--navit/gui/internal/gui_internal_gesture.c184
-rw-r--r--navit/gui/internal/gui_internal_html.c843
-rw-r--r--navit/gui/internal/gui_internal_keyboard.c1029
-rw-r--r--navit/gui/internal/gui_internal_keyboard.h30
-rw-r--r--navit/gui/internal/gui_internal_menu.c750
-rw-r--r--navit/gui/internal/gui_internal_menu.h5
-rw-r--r--navit/gui/internal/gui_internal_poi.c1260
-rw-r--r--navit/gui/internal/gui_internal_poi.h69
-rw-r--r--navit/gui/internal/gui_internal_priv.h274
-rw-r--r--navit/gui/internal/gui_internal_search.c1055
-rw-r--r--navit/gui/internal/gui_internal_widget.c2439
-rw-r--r--navit/gui/internal/gui_internal_widget.h242
-rw-r--r--navit/gui/qml/CMakeLists.txt20
-rw-r--r--navit/gui/qml/bookmarksProxy.h6
-rw-r--r--navit/gui/qml/guiProxy.h4
-rw-r--r--navit/gui/qml/gui_qml.cpp739
-rw-r--r--navit/gui/qml/navitProxy.h2
-rw-r--r--navit/gui/qml/ngqpoint.h12
-rw-r--r--navit/gui/qml/proxy.h6
-rw-r--r--navit/gui/qml/routeProxy.h6
-rw-r--r--navit/gui/qml/searchProxy.h16
-rw-r--r--navit/gui/qml/skins/navit/ButtonIcon.qml78
-rw-r--r--navit/gui/qml/skins/navit/Cellar.qml4
-rw-r--r--navit/gui/qml/skins/navit/ListSelector.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageAbout.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageBookmarks.qml12
-rw-r--r--navit/gui/qml/skins/navit/PageBookmarksAdd.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageNavigate.qml6
-rw-r--r--navit/gui/qml/skins/navit/PagePoi.qml8
-rw-r--r--navit/gui/qml/skins/navit/PagePointInfo.qml8
-rw-r--r--navit/gui/qml/skins/navit/PageRoute.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageSearch.qml16
-rw-r--r--navit/gui/qml/skins/navit/PageSearchSelector.qml14
-rw-r--r--navit/gui/qml/skins/navit/PageSettings.qml6
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsDisplay.qml10
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsLocale.qml8
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsRules.qml72
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsTools.qml8
-rw-r--r--navit/gui/qml/skins/navit/PageSettingsVehicle.qml10
-rw-r--r--navit/gui/qml/skins/navit/Slider.qml2
-rw-r--r--navit/gui/qml/skins/navit/ToggleButton.qml8
-rw-r--r--navit/gui/qml/skins/navit/ToggleSwitch.qml4
-rw-r--r--navit/gui/qml/skins/navit/command.js12
-rw-r--r--navit/gui/qml/skins/navit/main.qml8
-rw-r--r--navit/gui/qt5_qml/backend.cpp731
-rw-r--r--navit/gui/qt5_qml/editor/main.cpp3
-rw-r--r--navit/gui/qt5_qml/gui_qt5_qml.cpp68
-rw-r--r--navit/gui/qt5_qml/proxy.c11
-rw-r--r--navit/gui/qt5_qml/qml_bookmark.cpp15
-rw-r--r--navit/gui/qt5_qml/qml_map.cpp18
-rw-r--r--navit/gui/qt5_qml/qml_poi.cpp33
-rw-r--r--navit/gui/qt5_qml/qml_search.cpp21
-rw-r--r--navit/gui/qt5_qml/qml_vehicle.cpp24
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.cog.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.cogs.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.layer.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.map.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.power.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.rocket.svg2
-rw-r--r--navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg2
-rw-r--r--navit/gui/qt5_qml/skins/menu.qml2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg2
-rw-r--r--navit/gui/qt5_qml/skins/modern/main.qml2
-rw-r--r--navit/gui/qt5_qml/skins/modern/menu.qml2
-rw-r--r--navit/gui/qt5_qml/skins/pois.qml10
-rw-r--r--navit/gui/win32/CMakeLists.txt2
-rw-r--r--navit/gui/win32/ceglue.c149
-rw-r--r--navit/gui/win32/ceglue.h32
-rw-r--r--navit/gui/win32/gui_win32.c865
-rw-r--r--navit/gui/win32/win32_gui_destination.c142
-rw-r--r--navit/gui/win32/win32_gui_notify.c118
-rw-r--r--navit/icons/CMakeLists.txt217
-rw-r--r--navit/icons/car_wash.svg48
-rw-r--r--navit/icons/communication.svg59
-rw-r--r--navit/icons/concert.svg79
-rw-r--r--navit/icons/crossing.svg145
-rw-r--r--navit/icons/dam.svg342
-rw-r--r--navit/icons/danger_area.svg112
-rw-r--r--navit/icons/desktop_icons/navit.desktop.in1
-rw-r--r--navit/icons/drinking_water.svg81
-rw-r--r--navit/icons/follow.svg168
-rw-r--r--navit/icons/forbidden_area.svg118
-rw-r--r--navit/icons/government_building.svg148
-rw-r--r--navit/icons/gui_android_menu.svg174
-rw-r--r--navit/icons/gui_layers.svg64
-rw-r--r--navit/icons/gui_map.svg20
-rwxr-xr-xnavit/icons/navit_svg2png36
-rw-r--r--navit/icons/sound_off.svg114
-rw-r--r--navit/icons/sound_on.svg122
-rw-r--r--navit/icons/status_position_wait_bk.svg19
-rw-r--r--navit/icons/status_position_wait_wh.svg18
-rw-r--r--navit/icons/zoom_auto.svg147
-rw-r--r--navit/icons/zoom_in.svg142
-rw-r--r--navit/icons/zoom_manual.svg147
-rw-r--r--navit/icons/zoom_out.svg144
-rw-r--r--navit/iphone/downloader/Classes/DownloaderAppDelegate.h2
-rw-r--r--navit/iphone/downloader/Classes/DownloaderAppDelegate.m8
-rw-r--r--navit/iphone/downloader/Classes/DownloaderDetailViewController.m6
-rw-r--r--navit/iphone/downloader/Classes/RootViewController.h4
-rw-r--r--navit/iphone/downloader/Classes/RootViewController.m38
-rw-r--r--navit/iphone/downloader/main.m2
-rw-r--r--navit/item.c648
-rw-r--r--navit/item.h3
-rw-r--r--navit/keys.h2
-rw-r--r--navit/layout.c1108
-rw-r--r--navit/layout.h4
-rw-r--r--navit/linguistics.c876
-rw-r--r--navit/log.c551
-rw-r--r--navit/main.c618
-rw-r--r--navit/main.h1
-rw-r--r--navit/map.c635
-rw-r--r--navit/map.h24
-rw-r--r--navit/map/binfile/CMakeLists.txt2
-rw-r--r--navit/map/binfile/binfile.c5066
-rw-r--r--navit/map/csv/csv.c1478
-rw-r--r--navit/map/csv/csv.h4
-rw-r--r--navit/map/csv/quadtree.c959
-rw-r--r--navit/map/csv/quadtree.h2
-rw-r--r--navit/map/filter/CMakeLists.txt2
-rw-r--r--navit/map/filter/filter.c620
-rw-r--r--navit/map/garmin/CMakeLists.txt8
-rw-r--r--navit/map/garmin/gar2navit.c294
-rw-r--r--navit/map/garmin/gar2navit.h4
-rw-r--r--navit/map/garmin/garmin.c1628
-rw-r--r--navit/map/garmin/garmin.h4
-rw-r--r--navit/map/garmin/garmintypes.txt18
-rw-r--r--navit/map/garmin/gentypes.c165
-rw-r--r--navit/map/garmin_img/garmin_img.c2421
-rw-r--r--navit/map/mg/block.c460
-rw-r--r--navit/map/mg/map.c1011
-rw-r--r--navit/map/mg/poly.c427
-rw-r--r--navit/map/mg/street.c1880
-rw-r--r--navit/map/mg/town.c443
-rw-r--r--navit/map/mg/tree.c469
-rw-r--r--navit/map/shapefile/shapefile.c1185
-rw-r--r--navit/map/textfile/textfile.c593
-rw-r--r--navit/maps.c125
-rw-r--r--navit/maps/CMakeLists.txt81
-rw-r--r--navit/mapset.c436
-rw-r--r--navit/maptool/CMakeLists.txt47
-rw-r--r--navit/maptool/boundaries.c604
-rw-r--r--navit/maptool/buffer.c120
-rw-r--r--navit/maptool/ch.c822
-rw-r--r--navit/maptool/coastline.c1029
-rw-r--r--navit/maptool/fileformat.proto3
-rw-r--r--navit/maptool/generated-code/fileformat.pb-c.c248
-rw-r--r--navit/maptool/generated-code/fileformat.pb-c.h110
-rw-r--r--navit/maptool/generated-code/osmformat.pb-c.c1582
-rw-r--r--navit/maptool/generated-code/osmformat.pb-c.h523
-rw-r--r--navit/maptool/google/protobuf-c/protobuf-c-private.h72
-rw-r--r--navit/maptool/google/protobuf-c/protobuf-c.c2603
-rw-r--r--navit/maptool/google/protobuf-c/protobuf-c.h444
-rw-r--r--navit/maptool/itembin.c1243
-rw-r--r--navit/maptool/itembin_buffer.c62
-rw-r--r--navit/maptool/maptool.c1781
-rw-r--r--navit/maptool/maptool.h4
-rw-r--r--navit/maptool/misc.c701
-rw-r--r--navit/maptool/osm.c6261
-rw-r--r--navit/maptool/osm_o5m.c592
-rw-r--r--navit/maptool/osm_protobuf.c490
-rw-r--r--navit/maptool/osm_protobufdb.c1441
-rw-r--r--navit/maptool/osm_psql.c399
-rw-r--r--navit/maptool/osm_relations.c220
-rw-r--r--navit/maptool/osm_xml.c363
-rw-r--r--navit/maptool/osmformat.proto22
-rw-r--r--navit/maptool/sourcesink.c200
-rw-r--r--navit/maptool/tempfile.c64
-rw-r--r--navit/maptool/tile.c1116
-rw-r--r--navit/maptool/zip.c541
-rw-r--r--navit/maptype.c34
-rw-r--r--navit/maptype.h2
-rw-r--r--navit/menu.c33
-rw-r--r--navit/messages.c200
-rw-r--r--navit/navigation.c6936
-rw-r--r--navit/navigation.h12
-rw-r--r--navit/navit.c5737
-rw-r--r--navit/navit.dtd4
-rw-r--r--navit/navit.h5
-rw-r--r--navit/navit_layout_bike_shipped.xml1052
-rw-r--r--navit/navit_layout_car_android_shipped.xml1338
-rw-r--r--navit/navit_layout_car_dark_shipped.xml1725
-rw-r--r--navit/navit_layout_car_shipped.xml2015
-rw-r--r--navit/navit_layout_car_simple_shipped.xml122
-rw-r--r--navit/navit_layout_th_shipped.xml547
-rw-r--r--navit/navit_nls.c94
-rw-r--r--navit/navit_shipped.xml6964
-rw-r--r--navit/osd.c726
-rw-r--r--navit/osd.h4
-rw-r--r--navit/osd/core/osd_core.c6860
-rw-r--r--navit/param.c66
-rw-r--r--navit/phrase.c25
-rw-r--r--navit/plugin.c561
-rw-r--r--navit/plugin.h12
-rw-r--r--navit/plugin/j1850/j1850.c255
-rw-r--r--navit/plugin/pedestrian/pedestrian.c2197
-rw-r--r--navit/plugin_def.h1
-rw-r--r--navit/popup.c616
-rw-r--r--navit/profile.c54
-rw-r--r--navit/profile_option.c55
-rw-r--r--navit/projection.c128
-rw-r--r--navit/roadprofile.c142
-rw-r--r--navit/route.c6556
-rw-r--r--navit/route.h2
-rw-r--r--navit/route_protected.h184
-rw-r--r--navit/script.c139
-rwxr-xr-xnavit/script/cabify.sh16
-rwxr-xr-xnavit/script/check_itemdef42
-rw-r--r--navit/script/download_index.html290
-rwxr-xr-xnavit/script/gensvg8
-rwxr-xr-xnavit/script/geotag4
-rwxr-xr-xnavit/script/gps_emu6
-rwxr-xr-xnavit/script/gps_emu26
-rwxr-xr-xnavit/script/itemgra.pl92
-rw-r--r--navit/script/mapExtract.class.php160
-rw-r--r--navit/script/map_index.php6
-rw-r--r--navit/script/mapextract.php450
-rw-r--r--navit/script/osm/Geo/OSM/APIClientV4.pm46
-rw-r--r--navit/script/osm/Geo/OSM/APIClientV5.pm58
-rw-r--r--navit/script/osm/Geo/OSM/APIClientV6.pm64
-rw-r--r--navit/script/osm/Geo/OSM/EntitiesV3.pm32
-rw-r--r--navit/script/osm/Geo/OSM/EntitiesV5.pm38
-rw-r--r--navit/script/osm/Geo/OSM/EntitiesV6.pm38
-rw-r--r--navit/script/osm/Geo/OSM/MapFeatures.pm10
-rw-r--r--navit/script/osm/Geo/OSM/OsmChangeReaderV3.pm18
-rw-r--r--navit/script/osm/Geo/OSM/OsmChangeReaderV5.pm16
-rw-r--r--navit/script/osm/Geo/OSM/OsmChangeReaderV6.pm16
-rw-r--r--navit/script/osm/Geo/OSM/OsmReaderV3.pm14
-rw-r--r--navit/script/osm/Geo/OSM/OsmReaderV5.pm14
-rw-r--r--navit/script/osm/Geo/OSM/OsmReaderV6.pm14
-rw-r--r--navit/script/osm/Geo/OSM/OsmXML.pm12
-rw-r--r--navit/script/osm/Geo/OSM/Planet.pm32
-rw-r--r--navit/script/osm/Geo/OSM/SegmentList.pm42
-rw-r--r--navit/script/osm/Geo/OSM/Tracks2OSM.pm4
-rw-r--r--navit/script/osm/Geo/OSM/Upload.pm32
-rw-r--r--navit/script/osm/Geo/OSM/Write.pm16
-rwxr-xr-xnavit/script/osm/border_follower.pl6
-rwxr-xr-xnavit/script/wiki2def4
-rw-r--r--navit/search.c1784
-rw-r--r--navit/search_houseno_interpol.c345
-rw-r--r--navit/speech.c153
-rw-r--r--navit/speech/android/speech_android.c168
-rw-r--r--navit/speech/cmdline/speech_cmdline.c392
-rw-r--r--navit/speech/dbus/CMakeLists.txt2
-rw-r--r--navit/speech/dbus/speech_dbus.c62
-rw-r--r--navit/speech/espeak/speak.c632
-rw-r--r--navit/speech/iphone/speech_iphone.m12
-rw-r--r--navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp43
-rwxr-xr-xnavit/speech/qt5_espeak/qt5_espeak.cpp70
-rw-r--r--navit/speech/speech_dispatcher/speech_speech_dispatcher.c59
-rw-r--r--navit/start.c6
-rw-r--r--navit/start_apple.m6
-rw-r--r--navit/start_real.c314
-rw-r--r--navit/start_real.h4
-rwxr-xr-xnavit/startonce.sh10
-rw-r--r--navit/sunriset.c300
-rw-r--r--navit/sunriset.h2
-rw-r--r--navit/support/espeak/CMakeLists.txt9
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/compiledict.c912
-rw-r--r--navit/support/espeak/compiledict.h20
-rw-r--r--navit/support/espeak/debug.h2
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/dictionary.c2014
-rw-r--r--navit/support/espeak/dictionary.h19
-rw-r--r--navit/support/espeak/espeak-data/af_dictbin74925 -> 82372 bytes
-rw-r--r--navit/support/espeak/espeak-data/am_dictbin0 -> 3334 bytes
-rw-r--r--navit/support/espeak/espeak-data/an_dictbin0 -> 6717 bytes
-rw-r--r--navit/support/espeak/espeak-data/as_dictbin0 -> 5017 bytes
-rw-r--r--navit/support/espeak/espeak-data/az_dictbin0 -> 2135 bytes
-rw-r--r--navit/support/espeak/espeak-data/bg_dictbin0 -> 27006 bytes
-rw-r--r--navit/support/espeak/espeak-data/bn_dictbin0 -> 8087 bytes
-rw-r--r--navit/support/espeak/espeak-data/ca_dictbin4212 -> 4153 bytes
-rwxr-xr-xnavit/support/espeak/espeak-data/config9
-rw-r--r--navit/support/espeak/espeak-data/cs_dictbin7798 -> 7565 bytes
-rw-r--r--navit/support/espeak/espeak-data/cy_dictbin3541 -> 3461 bytes
-rw-r--r--navit/support/espeak/espeak-data/da_dictbin5327 -> 208489 bytes
-rw-r--r--navit/support/espeak/espeak-data/de_dictbin19322 -> 21816 bytes
-rw-r--r--navit/support/espeak/espeak-data/el_dictbin4585 -> 5351 bytes
-rw-r--r--navit/support/espeak/espeak-data/en_dictbin87069 -> 116291 bytes
-rw-r--r--navit/support/espeak/espeak-data/eo_dictbin4746 -> 4677 bytes
-rw-r--r--navit/support/espeak/espeak-data/es_dictbin5309 -> 6111 bytes
-rw-r--r--navit/support/espeak/espeak-data/et_dictbin0 -> 6767 bytes
-rw-r--r--navit/support/espeak/espeak-data/eu_dictbin0 -> 2217 bytes
-rw-r--r--navit/support/espeak/espeak-data/fa_dictbin0 -> 231857 bytes
-rw-r--r--navit/support/espeak/espeak-data/fi_dictbin4567 -> 5120 bytes
-rw-r--r--navit/support/espeak/espeak-data/fr_dictbin19363 -> 21422 bytes
-rw-r--r--navit/support/espeak/espeak-data/ga_dictbin0 -> 8917 bytes
-rw-r--r--navit/support/espeak/espeak-data/gd_dictbin0 -> 3794 bytes
-rw-r--r--navit/support/espeak/espeak-data/grc_dictbin3390 -> 3429 bytes
-rw-r--r--navit/support/espeak/espeak-data/gu_dictbin0 -> 5240 bytes
-rw-r--r--navit/support/espeak/espeak-data/hbs_dictbin7404 -> 7731 bytes
-rw-r--r--navit/support/espeak/espeak-data/hi_dictbin5696 -> 8606 bytes
-rw-r--r--navit/support/espeak/espeak-data/hu_dictbin5916 -> 113340 bytes
-rw-r--r--navit/support/espeak/espeak-data/hy_dictbin2469 -> 3400 bytes
-rw-r--r--navit/support/espeak/espeak-data/id_dictbin3083 -> 3082 bytes
-rw-r--r--navit/support/espeak/espeak-data/intonationsbin0 -> 1224 bytes
-rw-r--r--navit/support/espeak/espeak-data/is_dictbin5566 -> 5400 bytes
-rw-r--r--navit/support/espeak/espeak-data/it_dictbin48870 -> 61801 bytes
-rw-r--r--navit/support/espeak/espeak-data/jbo_dictbin2051 -> 2057 bytes
-rw-r--r--navit/support/espeak/espeak-data/ka_dictbin0 -> 3138 bytes
-rw-r--r--navit/support/espeak/espeak-data/kl_dictbin0 -> 2645 bytes
-rw-r--r--navit/support/espeak/espeak-data/kn_dictbin0 -> 5515 bytes
-rw-r--r--navit/support/espeak/espeak-data/ko_dictbin0 -> 6462 bytes
-rw-r--r--navit/support/espeak/espeak-data/ku_dictbin2277 -> 2268 bytes
-rw-r--r--navit/support/espeak/espeak-data/la_dictbin3911 -> 3817 bytes
-rw-r--r--navit/support/espeak/espeak-data/lfn_dictbin0 -> 2870 bytes
-rw-r--r--navit/support/espeak/espeak-data/lt_dictbin0 -> 5171 bytes
-rw-r--r--navit/support/espeak/espeak-data/lv_dictbin12558 -> 12293 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/af1_phtransbin1636 -> 1636 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/cr1_phtransbin2164 -> 2164 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/de2_phtransbin1444 -> 1540 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/de4_phtransbin1588 -> 1660 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/de6_phtransbin1204 -> 1276 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ee1_phtransbin0 -> 1444 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/en1_phtransbin796 -> 796 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/es_phtransbin1708 -> 1708 bytes
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/mbrola_ph/fr1_phtransbin1852 -> 1972 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/gr2_phtransbin2212 -> 2212 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/hn1_phtransbin0 -> 532 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/hu1_phtransbin1420 -> 1444 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ic1_phtransbin0 -> 1132 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/id1_phtransbin868 -> 892 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/in1_phtransbin1252 -> 1444 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ir1_phtransbin0 -> 5812 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/it3_phtransbin892 -> 892 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/lt1_phtransbin0 -> 1060 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/lt2_phtransbin0 -> 1060 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/mx1_phtransbin0 -> 1804 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/mx2_phtransbin0 -> 1828 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/nl_phtransbin1612 -> 1684 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/pl1_phtransbin1540 -> 1564 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/pt1_phtransbin2092 -> 2092 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ptbr4_phtransbin2356 -> 2356 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ptbr_phtransbin2500 -> 2500 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ro1_phtransbin2116 -> 2164 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/sv2_phtransbin1564 -> 1588 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/sv_phtransbin1564 -> 1588 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/tr1_phtransbin0 -> 364 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/us3_phtransbin1012 -> 1108 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/us_phtransbin1084 -> 1156 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/vz_phtransbin0 -> 2284 bytes
-rw-r--r--navit/support/espeak/espeak-data/mk_dictbin4948 -> 4945 bytes
-rw-r--r--navit/support/espeak/espeak-data/ml_dictbin0 -> 4159 bytes
-rw-r--r--navit/support/espeak/espeak-data/ms_dictbin0 -> 12248 bytes
-rw-r--r--navit/support/espeak/espeak-data/nci_dictbin0 -> 1534 bytes
-rw-r--r--navit/support/espeak/espeak-data/ne_dictbin0 -> 10817 bytes
-rw-r--r--navit/support/espeak/espeak-data/nl_dictbin4124 -> 27197 bytes
-rw-r--r--navit/support/espeak/espeak-data/no_dictbin3735 -> 4178 bytes
-rw-r--r--navit/support/espeak/espeak-data/or_dictbin0 -> 4765 bytes
-rw-r--r--navit/support/espeak/espeak-data/pa_dictbin0 -> 6172 bytes
-rw-r--r--navit/support/espeak/espeak-data/pap_dictbin2148 -> 2128 bytes
-rw-r--r--navit/support/espeak/espeak-data/phondatabin355256 -> 406336 bytes
-rw-r--r--navit/support/espeak/espeak-data/phondata-manifest1546
-rw-r--r--navit/support/espeak/espeak-data/phonindexbin30256 -> 25028 bytes
-rw-r--r--navit/support/espeak/espeak-data/phontabbin36460 -> 40564 bytes
-rw-r--r--navit/support/espeak/espeak-data/pl_dictbin40458 -> 34924 bytes
-rw-r--r--navit/support/espeak/espeak-data/pt_dictbin14970 -> 24985 bytes
-rw-r--r--navit/support/espeak/espeak-data/ro_dictbin24961 -> 25205 bytes
-rw-r--r--navit/support/espeak/espeak-data/ru_dictbin5519 -> 6217 bytes
-rw-r--r--navit/support/espeak/espeak-data/si_dictbin0 -> 4143 bytes
-rw-r--r--navit/support/espeak/espeak-data/sk_dictbin8898 -> 9161 bytes
-rw-r--r--navit/support/espeak/espeak-data/sl_dictbin0 -> 3965 bytes
-rw-r--r--navit/support/espeak/espeak-data/sq_dictbin3222 -> 3199 bytes
-rw-r--r--navit/support/espeak/espeak-data/sv_dictbin9508 -> 9676 bytes
-rw-r--r--navit/support/espeak/espeak-data/sw_dictbin3072 -> 3029 bytes
-rw-r--r--navit/support/espeak/espeak-data/ta_dictbin2527 -> 110757 bytes
-rw-r--r--navit/support/espeak/espeak-data/te_dictbin0 -> 3380 bytes
-rw-r--r--navit/support/espeak/espeak-data/tr_dictbin4783 -> 6052 bytes
-rw-r--r--navit/support/espeak/espeak-data/ur_dictbin0 -> 18015 bytes
-rw-r--r--navit/support/espeak/espeak-data/vi_dictbin4855 -> 7438 bytes
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/f18
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/f21
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/!v/f30
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/!v/f40
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/f523
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/fast11
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/klatt4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/klatt24
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/klatt34
-rw-r--r--navit/support/espeak/espeak-data/voices/!v/klatt44
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/m119
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/!v/m20
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/!v/m31
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/!v/m40
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/m735
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/whisperf24
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/fa3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/fa-pin6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/hi3
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/asia/hy (renamed from navit/support/espeak/espeak-data/voices/hy)0
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/asia/hy-west (renamed from navit/support/espeak/espeak-data/voices/hy-west)13
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/id (renamed from navit/support/espeak/espeak-data/voices/id)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/ka2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/kn5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/ku (renamed from navit/support/espeak/espeak-data/voices/ku)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/ml6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/ms17
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/ne5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/pa2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/ta (renamed from navit/support/espeak/espeak-data/voices/ta)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/tr (renamed from navit/support/espeak/espeak-data/voices/tr)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/vi (renamed from navit/support/espeak/espeak-data/voices/vi)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/vi-hue12
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/vi-sgn12
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/asia/zh (renamed from navit/support/espeak/espeak-data/voices/zh)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/asia/zh-yue (renamed from navit/support/espeak/espeak-data/voices/zh-yue)3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/da3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/en (renamed from navit/support/espeak/espeak-data/voices/en/en)6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/en-us (renamed from navit/support/espeak/espeak-data/voices/en/en-us)10
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/es-la7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/an3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/bg5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/bs (renamed from navit/support/espeak/espeak-data/voices/bs)0
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/europe/ca (renamed from navit/support/espeak/espeak-data/voices/ca)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/cs (renamed from navit/support/espeak/espeak-data/voices/cs)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/cy (renamed from navit/support/espeak/espeak-data/voices/cy)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/da7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/el (renamed from navit/support/espeak/espeak-data/voices/el)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/es (renamed from navit/support/espeak/espeak-data/voices/es)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/et3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/fi (renamed from navit/support/espeak/espeak-data/voices/fi)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/fr-be9
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/ga4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/hr (renamed from navit/support/espeak/espeak-data/voices/hr)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/hu (renamed from navit/support/espeak/espeak-data/voices/hu)4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/is (renamed from navit/support/espeak/espeak-data/voices/is)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/it (renamed from navit/support/espeak/espeak-data/voices/it)4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/lt5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/lv (renamed from navit/support/espeak/espeak-data/voices/lv)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/mk (renamed from navit/support/espeak/espeak-data/voices/mk)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/nl (renamed from navit/support/espeak/espeak-data/voices/nl)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/no (renamed from navit/support/espeak/espeak-data/voices/no)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/pl (renamed from navit/support/espeak/espeak-data/voices/pl)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/pt-pt (renamed from navit/support/espeak/espeak-data/voices/pt-pt)3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/ro (renamed from navit/support/espeak/espeak-data/voices/ro)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/ru (renamed from navit/support/espeak/espeak-data/voices/ru)3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/sk (renamed from navit/support/espeak/espeak-data/voices/sk)0
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/europe/sq (renamed from navit/support/espeak/espeak-data/voices/sq)0
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/europe/sr (renamed from navit/support/espeak/espeak-data/voices/sr)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/europe/sv (renamed from navit/support/espeak/espeak-data/voices/sv)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/fr6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/fr-be7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/hi9
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-br12
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/mb/mb-br33
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/mb/mb-br42
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-cr11
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de21
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de38
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de42
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de4-en2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de5-en2
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/mb/mb-de60
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/mb/mb-de6-grc0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de71
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-ee18
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-en11
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-es11
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/mb/mb-es22
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-fr12
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-fr1-en1
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-fr41
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-fr4-en1
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-gr21
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-gr2-en3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-hu11
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-hu1-en1
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-ic17
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-id11
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-ir122
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-ir222
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-it31
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-it41
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-mx110
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-mx210
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-nl22
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-nl2-en2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-pl11
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/mb/mb-pt13
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-sw12
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-sw1-en2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-sw22
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-sw2-en4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-tr17
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-tr210
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-us12
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-us23
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-us33
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-vz111
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/af (renamed from navit/support/espeak/espeak-data/voices/af)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/en-n (renamed from navit/support/espeak/espeak-data/voices/en/en-n)9
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/en-rp (renamed from navit/support/espeak/espeak-data/voices/en/en-rp)7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/en-sc (renamed from navit/support/espeak/espeak-data/voices/en/en-sc)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/en-wi (renamed from navit/support/espeak/espeak-data/voices/en/en-wi)7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/en-wm (renamed from navit/support/espeak/espeak-data/voices/en/en-wm)4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/eo (renamed from navit/support/espeak/espeak-data/voices/eo)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/grc (renamed from navit/support/espeak/espeak-data/voices/test/grc)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/jbo4
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/other/la (renamed from navit/support/espeak/espeak-data/voices/la)0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/lfn6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/other/sw (renamed from navit/support/espeak/espeak-data/voices/sw)2
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/pt3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/am3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/as4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/az3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/bn3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/eu3
-rw-r--r--navit/support/espeak/espeak-data/voices/test/gd3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/gu3
-rw-r--r--navit/support/espeak/espeak-data/voices/test/jbo3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/kl3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/ko6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/nci7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/or2
-rwxr-xr-x[-rw-r--r--]navit/support/espeak/espeak-data/voices/test/pap0
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/si4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/sl3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/te5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/ur5
-rw-r--r--navit/support/espeak/espeak-data/zh_dictbin41834 -> 41827 bytes
-rw-r--r--navit/support/espeak/espeak-data/zhy_dictbin1556 -> 1556 bytes
-rw-r--r--navit/support/espeak/espeak.c314
-rw-r--r--navit/support/espeak/espeak_command.c50
-rw-r--r--navit/support/espeak/espeak_command.h42
-rw-r--r--navit/support/espeak/event.c145
-rw-r--r--navit/support/espeak/event.h4
-rw-r--r--navit/support/espeak/fifo.c166
-rw-r--r--navit/support/espeak/fifo.h10
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/intonation.c521
-rw-r--r--navit/support/espeak/klatt.c662
-rw-r--r--navit/support/espeak/klatt.h33
-rw-r--r--navit/support/espeak/mbrolib.h205
-rw-r--r--navit/support/espeak/mbrowrap.c613
-rw-r--r--navit/support/espeak/mbrowrap.h108
-rw-r--r--navit/support/espeak/numbers.c2185
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/phoneme.h72
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/phonemelist.c677
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/portaudio.h0
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/portaudio18.h0
-rw-r--r--navit/support/espeak/readclause.c1033
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/setlengths.c660
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/sintab.h0
-rw-r--r--navit/support/espeak/sonic.c974
-rw-r--r--navit/support/espeak/sonic.h138
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/speak.c177
-rw-r--r--navit/support/espeak/speak_init.c6
-rw-r--r--navit/support/espeak/speak_lib.c362
-rw-r--r--navit/support/espeak/speak_lib.h207
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/speech.h31
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/synth_mbrola.c504
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/synthdata.c1114
-rw-r--r--navit/support/espeak/synthdata.h20
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/synthesize.c818
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/synthesize.h347
-rw-r--r--navit/support/espeak/tr_languages.c1121
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/translate.c2060
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/translate.h466
-rw-r--r--navit/support/espeak/voice.h8
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/voices.c744
-rw-r--r--navit/support/espeak/voices.h19
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/wave.c460
-rw-r--r--navit/support/espeak/wave.h15
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/wave_pulse.c141
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/wave_sada.c22
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/wavegen.c434
-rw-r--r--navit/support/espeak/wavegen.h21
-rw-r--r--navit/support/gettext_intl/dcigettext.c7
-rw-r--r--navit/support/gettext_intl/localealias.c4
-rw-r--r--navit/support/glib/CMakeLists.txt4
-rw-r--r--navit/support/glib/gutils.c4
-rw-r--r--navit/support/libc/stat.c8
-rw-r--r--navit/support/win32/X11/XF86keysym.h378
-rw-r--r--navit/support/win32/addwinsock.c16
-rw-r--r--navit/support/win32/addwinsock.h16
-rw-r--r--navit/support/win32/serial_io.c16
-rw-r--r--navit/support/wordexp/glob.c6
-rw-r--r--navit/support/xgetopt/XGetopt.c432
-rw-r--r--navit/support/xgetopt/XGetopt.h58
-rwxr-xr-xnavit/tools/asc2navit8
-rwxr-xr-xnavit/tools/cleanattr.sh8
-rw-r--r--navit/tools/gpx2navit_txt/COPYING10
-rw-r--r--navit/tools/gpx2navit_txt/INSTALL2
-rw-r--r--navit/tools/gpx2navit_txt/NEWS6
-rw-r--r--navit/tools/gpx2navit_txt/README18
-rwxr-xr-xnavit/tools/gpx2navit_txt/autogen.sh2
-rwxr-xr-xnavit/tools/gpx2navit_txt/install-sh14
-rw-r--r--navit/tools/gpx2navit_txt/man/gpx2navit_txt.164
-rw-r--r--navit/tools/gpx2navit_txt/src/elementControl.c245
-rw-r--r--navit/tools/gpx2navit_txt/src/errorcode.h2
-rw-r--r--navit/tools/gpx2navit_txt/src/geod_for.c138
-rw-r--r--navit/tools/gpx2navit_txt/src/geod_inv.c81
-rw-r--r--navit/tools/gpx2navit_txt/src/geod_set.c127
-rw-r--r--navit/tools/gpx2navit_txt/src/geodesic.h4
-rw-r--r--navit/tools/gpx2navit_txt/src/gpx2navit_txt.h8
-rw-r--r--navit/tools/gpx2navit_txt/src/main.c497
-rw-r--r--navit/tools/gpx2navit_txt/src/misc.c128
-rw-r--r--navit/tools/gpx2navit_txt/src/parser.c121
-rw-r--r--navit/tools/gpx2navit_txt/src/setmeta.c29
-rw-r--r--navit/tools/gpx2navit_txt/src/setpath.c198
-rw-r--r--navit/tools/gpx2navit_txt/src/setwpt.c37
-rw-r--r--navit/tools/gpx2navit_txt/src/utils.c135
-rw-r--r--navit/tools/latlon2bookmark/Makefile2
-rw-r--r--navit/tools/latlon2bookmark/latlon2bookmark.c270
-rw-r--r--navit/track.c1979
-rw-r--r--navit/traffic.c5319
-rw-r--r--navit/traffic.h996
-rw-r--r--navit/traffic/dummy/CMakeLists.txt1
-rw-r--r--navit/traffic/dummy/traffic_dummy.c190
-rw-r--r--navit/traffic/null/CMakeLists.txt1
-rw-r--r--navit/traffic/null/traffic_null.c101
-rw-r--r--navit/traffic/traff_android/CMakeLists.txt1
-rw-r--r--navit/traffic/traff_android/traffic_traff_android.c173
-rw-r--r--navit/transform.c2552
-rw-r--r--navit/util.c1433
-rw-r--r--navit/util.h11
-rw-r--r--navit/vehicle.c1034
-rw-r--r--navit/vehicle/android/vehicle_android.c355
-rw-r--r--navit/vehicle/demo/vehicle_demo.c483
-rw-r--r--navit/vehicle/file/vehicle_file.c1699
-rw-r--r--navit/vehicle/file/vehicle_pipe.c6
-rw-r--r--navit/vehicle/file/vehicle_serial.c6
-rw-r--r--navit/vehicle/file/vehicle_socket.c6
-rw-r--r--navit/vehicle/gpsd/CMakeLists.txt8
-rw-r--r--navit/vehicle/gpsd/vehicle_gpsd.c690
-rw-r--r--navit/vehicle/gpsd_dbus/CMakeLists.txt2
-rw-r--r--navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c363
-rw-r--r--navit/vehicle/gypsy/vehicle_gypsy.c617
-rw-r--r--navit/vehicle/iphone/corelocation.h2
-rw-r--r--navit/vehicle/iphone/corelocation.m6
-rw-r--r--navit/vehicle/iphone/vehicle_iphone.c221
-rw-r--r--navit/vehicle/maemo/CMakeLists.txt2
-rw-r--r--navit/vehicle/maemo/vehicle_maemo.c538
-rw-r--r--navit/vehicle/null/vehicle_null.c200
-rw-r--r--navit/vehicle/qt5/vehicle_qt5.cpp128
-rw-r--r--navit/vehicle/webos/bluetooth.c1079
-rw-r--r--navit/vehicle/webos/cJSON.c1069
-rw-r--r--navit/vehicle/webos/cJSON.h12
-rw-r--r--navit/vehicle/webos/vehicle_webos.c580
-rw-r--r--navit/vehicle/wince/vehicle_wince.c1649
-rw-r--r--navit/vehicleprofile.c475
-rw-r--r--navit/version.h.in2
-rw-r--r--navit/xmlconfig.c2259
-rw-r--r--navit/xmlconfig.h65
-rw-r--r--navit/xslt/android.xslt7
-rw-r--r--navit/xslt/iphone.xslt2
-rw-r--r--navit/xslt/openmoko.xslt8
-rw-r--r--navit/xslt/osd_android.xslt2
-rw-r--r--navit/xslt/osd_minimum.xslt32
-rw-r--r--navit/xslt/sailfish_osd.xslt29
-rw-r--r--navit/xslt/speech_win32.xslt6
-rw-r--r--navit/xslt/tomtom.xslt23
-rw-r--r--navit/xslt/wince.xslt20
-rw-r--r--navit/xslt/windows.xslt2
-rw-r--r--navit/zipfile.h6
-rw-r--r--po/CMakeLists.txt122
-rw-r--r--po/af.po.in938
-rw-r--r--po/ar.po.in1044
-rw-r--r--po/ast.po.in938
-rw-r--r--po/be.po.in904
-rw-r--r--po/bg.po.in998
-rw-r--r--po/bs.po.in876
-rw-r--r--po/ca.po.in949
-rw-r--r--po/ckb.po.in8
-rw-r--r--po/cs.po.in1121
-rw-r--r--po/cy.po.in8
-rw-r--r--po/da.po.in8
-rw-r--r--po/de.po.in1007
-rw-r--r--po/de_CH.po.in8
-rw-r--r--po/el.po.in8
-rw-r--r--po/en.po.in7
-rw-r--r--po/en_AU.po.in13
-rw-r--r--po/en_CA.po.in13
-rw-r--r--po/en_GB.po.in1126
-rw-r--r--po/eo.po.in8
-rw-r--r--po/es.po.in996
-rw-r--r--po/et.po.in8
-rw-r--r--po/eu.po.in8
-rw-r--r--po/fa.po.in8
-rw-r--r--po/fi.po.in8
-rw-r--r--po/fil.po.in953
-rw-r--r--po/fo.po.in8
-rw-r--r--po/fr.po.in1173
-rw-r--r--po/fr_CH.po.in8
-rw-r--r--po/fy.po.in8
-rw-r--r--po/gl.po.in8
-rw-r--r--po/he.po.in8
-rw-r--r--po/hi.po.in8
-rw-r--r--po/hr.po.in8
-rw-r--r--po/hu.po.in8
-rw-r--r--po/id.po.in8
-rw-r--r--po/it.po.in10
-rw-r--r--po/ja.po.in8
-rw-r--r--po/jv.po.in8
-rw-r--r--po/kk.po.in8
-rw-r--r--po/kn.po.in8
-rw-r--r--po/ko.po.in8
-rw-r--r--po/ku.po.in8
-rw-r--r--po/lb.po.in8
-rw-r--r--po/lt.po.in10
-rw-r--r--po/lv.po.in10
-rw-r--r--po/mk.po.in8
-rw-r--r--po/ml.po.in8
-rw-r--r--po/mn.po.in8
-rw-r--r--po/mr.po.in8
-rw-r--r--po/nb.po.in8
-rw-r--r--po/nds.po.in8
-rw-r--r--po/nl.po.in1143
-rw-r--r--po/nn.po.in8
-rw-r--r--po/pl.po.in8
-rw-r--r--po/pms.po.in8
-rw-r--r--po/pt.po.in10
-rw-r--r--po/pt_BR.po.in1148
-rw-r--r--po/ro.po.in8
-rw-r--r--po/ru.po.in8
-rw-r--r--po/sc.po.in8
-rw-r--r--po/si.po.in8
-rw-r--r--po/sk.po.in8
-rw-r--r--po/sl.po.in8
-rw-r--r--po/sq.po.in8
-rw-r--r--po/sr.po.in1064
-rw-r--r--po/sv.po.in8
-rw-r--r--po/sw.po.in8
-rw-r--r--po/ta.po.in8
-rw-r--r--po/te.po.in8
-rw-r--r--po/th.po.in8
-rw-r--r--po/tr.po.in8
-rw-r--r--po/uk.po.in8
-rw-r--r--po/ur.po.in8
-rw-r--r--po/vi.po.in8
-rw-r--r--po/zh_CN.po.in8
-rw-r--r--po/zh_HK.po.in8
-rw-r--r--po/zh_TW.po.in8
-rw-r--r--scripts/basic_upload_apks.py (renamed from ci/basic_upload_apks.py)0
-rw-r--r--scripts/build.sh (renamed from ci/build.sh)0
-rwxr-xr-xscripts/build_android.sh67
-rw-r--r--scripts/build_linux.sh55
-rw-r--r--scripts/build_tomtom_minimal.sh (renamed from ci/build_tomtom_minimal.sh)2
-rw-r--r--scripts/build_tomtom_plugin.sh (renamed from ci/build_tomtom_plugin.sh)8
-rw-r--r--scripts/build_win32.sh18
-rw-r--r--scripts/build_wince.sh29
-rwxr-xr-xscripts/ci_sanity_checks.sh66
-rw-r--r--scripts/dbus_tests.py (renamed from ci/dbus_tests.py)0
-rw-r--r--scripts/generate_contributors.sh52
-rw-r--r--scripts/import_translation.sh (renamed from ci/import_translations.sh)47
-rw-r--r--scripts/merge_i18n_update.sh (renamed from ci/merge_i18n_update.sh)5
-rw-r--r--scripts/pointer-64.png (renamed from ci/pointer-64.png)bin1733 -> 1733 bytes
-rwxr-xr-xscripts/pre-commit44
-rw-r--r--scripts/publish.sh35
-rw-r--r--scripts/run_linux_tests.sh (renamed from ci/run_linux_tests.sh)4
-rw-r--r--scripts/setup_14.04_requirements.list2
-rw-r--r--scripts/setup_android.sh (renamed from ci/setup_android.sh)7
-rw-r--r--scripts/setup_common_requirements.sh6
-rw-r--r--scripts/setup_tomtom_requirements.sh (renamed from ci/setup_tomtom_requirements.sh)12
-rw-r--r--scripts/setup_wince.sh7
-rw-r--r--scripts/update_download_center.sh106
-rw-r--r--scripts/update_doxygen.sh15
-rw-r--r--scripts/xdotools.sh (renamed from ci/xdotools.sh)8
-rw-r--r--settings.gradle1
981 files changed, 133607 insertions, 121231 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 19cb6286d..57e2f4c68 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,147 +1,277 @@
version: 2
defaults: &defaults
docker:
- - image: ubuntu:14.04
-
+ - image: ubuntu:18.04
jobs:
+ sanity_check:
+ <<: *defaults
+ steps:
+ - checkout
+ - run:
+ name: Setup requirements
+ command: bash scripts/setup_common_requirements.sh
+ - run:
+ name: run sanity check script
+ command: bash scripts/ci_sanity_checks.sh
build_linux:
<<: *defaults
steps:
- checkout
- run:
+ name: Id
+ command: cat /etc/*release
+ - run:
+ name: Setup requirements
+ command: |
+ bash scripts/setup_common_requirements.sh
+ apt-get install -y libpng-dev libfreetype6-dev libdbus-glib-1-dev libgtk2.0-dev curl
+ - run:
name: Build for Linux
+ command: bash scripts/build_linux.sh
+ - store_artifacts:
+ path: linux/_CPack_Packages
+ - run:
+ name: Update Navit-Download-Center
command: |
- bash ci/setup_common_requirements.sh
- bash ci/build_linux.sh
+ bash scripts/update_download_center.sh
run_doxygen:
<<: *defaults
steps:
- checkout
- run:
- name: Install doxygen
- command: apt-get update && apt-get -y install doxygen ca-certificates git
+ name: Install doxygen and other essentials
+ command: apt-get update && apt-get -y install doxygen ca-certificates git rsync
- run:
name: Run doxygen
command: cd navit && doxygen
- run:
name: Update results to Github
- command: |
- mkdir /root/.ssh
- chmod 0600 /root/.ssh
- echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==' >> ~/.ssh/known_hosts
- git clone -b gh-pages git@github.com:navit-gps/navit.git /root/navit-doc
- cd /root/navit-doc
- git config --global push.default simple
- git config user.name "Circle CI"
- git config user.email "circleci@navit-project.org"
- rsync -vrtza --exclude '.git' --delete /root/project/doc/html/ /root/navit-doc/
- echo "" > .nojekyll
- echo "doxygen.navit-project.org" > CNAME
- git add .
- git commit -am "update:doc:Doxygen update for commit ${CIRCLE_SHA1} [ci skip]" || true
- git push
+ command: bash scripts/update_doxygen.sh
- store_artifacts:
path: /root/project/doc
- build_android_arm:
- <<: *defaults
+ build_sailfish:
+ machine: true
steps:
- checkout
- run:
- name: Setup common requirements
- command: |
- bash ci/setup_common_requirements.sh
+ name: install docker
+ command: circleci-install docker
- run:
- name: Prepare the Android build environment
- command: |
- bash ci/setup_android.sh
+ name: make build dir
+ command: mkdir ../rpmbuild
- run:
- name: Build for Android ARM
- command: |
- bash ci/build_android.sh
+ name: run build
+ command: ls -lah ../rpmbuild && docker run -e VERSION_ID=2.2.1.18 -v `pwd`/../rpmbuild:/home/nemo/rpmbuild:rw -v `pwd`:/home/nemo/navit hoehnp/sailfishos-platform-sdk:2.2.1.18-r1 /bin/bash -x /home/nemo/navit/contrib/sailfish/build_sailfish_ci.sh
- store_artifacts:
- path: android-arm/navit
- build_android_x86:
- <<: *defaults
+ name: Store rpm
+ path: ../rpmbuild/RPMS/
+ build_android:
+ working_directory: ~/code
+ docker:
+ - image: circleci/android:api-28-ndk
+ environment:
+ JVM_OPTS: -Xmx3200m
+ GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
steps:
- checkout
- run:
- name: Setup common requirements
- command: |
- bash ci/setup_common_requirements.sh
+ name: Id
+ command: cat /etc/*release
- run:
- name: Prepare the Android build environment
+ name: Install cmake gettext libsaxonb-java librsvg2-bin pkg-config libprotobuf-c-dev protobuf-c-compiler
command: |
- bash ci/setup_android.sh
+ sudo apt-get update
+ sudo apt-get install -y cmake gettext libsaxonb-java librsvg2-bin pkg-config libprotobuf-c-dev protobuf-c-compiler
- run:
- name: Build for Android X86
+ name: Install Android SDK components
+ command: sdkmanager "cmake;3.6.4111459"
+ - run:
+ name: Build for Android
+ command: bash scripts/build_android.sh
+ - run:
+ name: Run Lint Test
command: |
- bash ci/build_android_x86.sh
+ ln -s navit/navit.dtd navit.dtd
+ mkdir /home/circleci/code/test-results
+ ./gradlew lint test
+ - run:
+ name: Run CheckStyle Test
+ command: ./gradlew checkstyleMain
+ - run:
+ name: Run Javadoc
+ command: ./gradlew generateDebugJavadoc
- store_artifacts:
- path: android-x86/navit
+ name: Store APK
+ path: navit/android/build/outputs/apk
+ destination: apk
+ - store_artifacts:
+ name: Store translations
+ path: po
+ destination: translations
+ - store_artifacts:
+ name: Store logs
+ path: navit/android/build/outputs/logs
+ destination: logs
+ - store_artifacts:
+ name: Store Javadoc
+ path: navit/android/build/outputs/docs/javadoc
+ destination: doc
+ - store_artifacts:
+ name: Store Lint reports
+ path: navit/android/build/reports
+ destination: reports
+ - store_artifacts:
+ name: Store checkstyle report
+ path: /home/circleci/code/navit/android/checkstyle
+ destination: reports
+ - store_test_results:
+ path: test-results
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash scripts/update_download_center.sh
build_win32:
- <<: *defaults
+ docker:
+ - image: ubuntu:14.04
steps:
- checkout
- run:
+ name: Prepare the Windows build environment
+ command: |
+ apt-get update && xargs -a scripts/setup_14.04_requirements.list apt-get install -y
+ apt-get install -y software-properties-common
+ add-apt-repository -y ppa:george-edison55/cmake-3.x
+ apt-get remove -y cmake
+ apt-get install -y cmake3 mingw-w64 mingw-w64-tools default-jdk nsis libsaxonb-java curl
+ - run:
name: Build for Windows
command: |
- bash ci/setup_common_requirements.sh
- bash ci/build_win32.sh
+ bash scripts/build_win32.sh
+ - store_artifacts:
+ path: win32/navit.exe
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash scripts/update_download_center.sh
build_wince:
- <<: *defaults
+ docker:
+ - image: navit/dockerfiles:wince
steps:
- checkout
- run:
+ name: Prepare the WinCE build environment
+ command: |
+ bash scripts/setup_wince.sh
+ - run:
name: Build for Windows CE
+ command: bash scripts/build_wince.sh
+ - store_artifacts:
+ path: wince/output
+ - run:
+ name: Update Navit-Download-Center
command: |
- bash ci/setup_common_requirements.sh
- bash ci/build_wince.sh
+ bash scripts/update_download_center.sh
build_tomtom_minimal:
<<: *defaults
docker:
- - image: navit/tomtom-build-image
+ - image: navit/tomtom-ng
steps:
- checkout
- run:
name: Setup common requirements
command: |
- bash ci/setup_common_requirements.sh
+ bash scripts/setup_common_requirements.sh
- run:
name: Build for Tomtom (minimal)
command: |
- bash ci/build_tomtom_minimal.sh
+ bash scripts/build_tomtom_minimal.sh
- store_artifacts:
path: /output
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash scripts/update_download_center.sh
build_tomtom_plugin:
<<: *defaults
docker:
- - image: navit/tomtom-build-image
+ - image: navit/tomtom-ng
steps:
- checkout
- run:
name: Setup common requirements
command: |
- bash ci/setup_common_requirements.sh
+ bash scripts/setup_common_requirements.sh
- run:
name: Build for Tomtom (plugin)
command: |
- bash ci/build_tomtom_plugin.sh
+ bash scripts/build_tomtom_plugin.sh
- store_artifacts:
path: /output
-
+ - run:
+ name: Update Navit-Download-Center
+ command: |
+ bash scripts/update_download_center.sh
+ merge_trunk_in_master:
+ <<: *defaults
+ steps:
+ - checkout
+ - run:
+ name: Install git
+ command: apt-get update && apt-get -y install ca-certificates git
+ - run:
+ name: configure ssh git
+ command: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
+ - add_ssh_keys:
+ fingerprints:
+ - "58:42:73:90:cc:68:f7:34:7e:37:37:fa:b3:26:1f:a5"
+ - run:
+ name: Update results to Github
+ command: export GIT_TERMINAL_PROMPT=0 && git push origin $CIRCLE_SHA1:refs/heads/master
workflows:
version: 2
- doxygen:
+ build_all:
jobs:
+ - sanity_check
+ - build_linux:
+ requires:
+ - sanity_check
+ - build_android:
+ requires:
+ - sanity_check
+ - build_sailfish:
+ requires:
+ - sanity_check
+ - build_win32:
+ requires:
+ - sanity_check
+ - build_wince:
+ requires:
+ - sanity_check
+ - build_tomtom_minimal:
+ requires:
+ - sanity_check
+ - build_tomtom_plugin:
+ requires:
+ - sanity_check
- run_doxygen:
+ requires:
+ - build_linux
+ - build_android
+ - build_win32
+ - build_wince
+ - build_tomtom_minimal
+ - build_tomtom_plugin
+ filters:
+ branches:
+ only: /^trunk$/
+ - merge_trunk_in_master:
+ requires:
+ - build_linux
+ - build_android
+ - build_win32
+ - build_wince
+ - build_tomtom_minimal
+ - build_tomtom_plugin
filters:
branches:
only: /^trunk$/
- build_all:
- jobs:
- - build_linux
- - build_android_arm
- - build_android_x86
- - build_win32
- - build_tomtom_minimal
- - build_tomtom_plugin
diff --git a/.gitchangelog.rc b/.gitchangelog.rc
new file mode 100644
index 000000000..189a99241
--- /dev/null
+++ b/.gitchangelog.rc
@@ -0,0 +1,334 @@
+# -*- coding: utf-8; mode: python -*-
+##
+## Format
+##
+## ACTION: [AUDIENCE:] COMMIT_MSG [!TAG ...]
+##
+## Description
+##
+## ACTION is one of 'chg', 'fix', 'new'
+##
+## Is WHAT the change is about.
+##
+## 'chg' is for refactor, small improvement, cosmetic changes...
+## 'fix' is for bug fixes
+## 'new' is for new features, big improvement
+##
+## AUDIENCE is optional and one of 'dev', 'usr', 'pkg', 'test', 'doc'
+##
+## Is WHO is concerned by the change.
+##
+## 'dev' is for developpers (API changes, refactors...)
+## 'usr' is for final users (UI changes)
+## 'pkg' is for packagers (packaging changes)
+## 'test' is for testers (test only related changes)
+## 'doc' is for doc guys (doc only changes)
+##
+## COMMIT_MSG is ... well ... the commit message itself.
+##
+## TAGs are additionnal adjective as 'refactor' 'minor' 'cosmetic'
+##
+## They are preceded with a '!' or a '@' (prefer the former, as the
+## latter is wrongly interpreted in github.) Commonly used tags are:
+##
+## 'refactor' is obviously for refactoring code only
+## 'minor' is for a very meaningless change (a typo, adding a comment)
+## 'cosmetic' is for cosmetic driven change (re-indentation, 80-col...)
+## 'wip' is for partial functionality but complete subfunctionality.
+##
+## Example:
+##
+## new: usr: support of bazaar implemented
+## chg: re-indentend some lines !cosmetic
+## new: dev: updated code to be compatible with last version of killer lib.
+## fix: pkg: updated year of licence coverage.
+## new: test: added a bunch of test around user usability of feature X.
+## fix: typo in spelling my name in comment. !minor
+##
+## Please note that multi-line commit message are supported, and only the
+## first line will be considered as the "summary" of the commit message. So
+## tags, and other rules only applies to the summary. The body of the commit
+## message will be displayed in the changelog without reformatting.
+
+
+##
+## ``ignore_regexps`` is a line of regexps
+##
+## Any commit having its full commit message matching any regexp listed here
+## will be ignored and won't be reported in the changelog.
+##
+ignore_regexps = [
+ r'@minor', r'!minor',
+ r'@cosmetic', r'!cosmetic',
+ r'@refactor', r'!refactor',
+ r'@wip', r'!wip',
+ r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[p|P]kg:',
+ r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*[d|D]ev:',
+ r'^(.{3,3}\s*:)?\s*[fF]irst commit.?\s*$',
+ r'^[Cc][Ii]\s*:', ## ignore Ci-related commits
+ r'^.*:\s*[Cc][Ii]\s*:', ## ignore Ci-related commits
+ r'^.*[Cc]ircle[Cc][Ii]\s*', ## ignore Ci-related commits
+ r'^.*:github:.*$',
+ r'^.*:changelog:.*$',
+ r'^Git-svn-id',
+ r'^$', ## ignore commits with empty messages
+]
+
+
+## ``section_regexps`` is a list of 2-tuples associating a string label and a
+## list of regexp
+##
+## Commit messages will be classified in sections thanks to this. Section
+## titles are the label, and a commit is classified under this section if any
+## of the regexps associated is matching.
+##
+## Please note that ``section_regexps`` will only classify commits and won't
+## make any changes to the contents. So you'll probably want to go check
+## ``subject_process`` (or ``body_process``) to do some changes to the subject,
+## whenever you are tweaking this variable.
+##
+section_regexps = [
+ ('Added', [
+ r'^[nN]ew\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ r'^[Aa]dds*\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ ]),
+ ('Changed', [
+ r'^[cC]hg\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ r'^[cC]hanges*\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ r'^[Uu]pdates*\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ r'^[Rr]ework\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ r'^[Rr]factor\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ ]),
+ ('Fixed', [
+ r'^[fF]ix\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ r'^[Cc]orrected\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ ]),
+ ('Removed', [
+ r'^[Rr]emoved\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ r'^[Cc]lean[edup]*\s*:*\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
+ ]),
+ ('Other', None ## Match all lines
+ ),
+
+]
+
+
+## ``body_process`` is a callable
+##
+## This callable will be given the original body and result will
+## be used in the changelog.
+##
+## Available constructs are:
+##
+## - any python callable that take one txt argument and return txt argument.
+##
+## - ReSub(pattern, replacement): will apply regexp substitution.
+##
+## - Indent(chars=" "): will indent the text with the prefix
+## Please remember that template engines gets also to modify the text and
+## will usually indent themselves the text if needed.
+##
+## - Wrap(regexp=r"\n\n"): re-wrap text in separate paragraph to fill 80-Columns
+##
+## - noop: do nothing
+##
+## - ucfirst: ensure the first letter is uppercase.
+## (usually used in the ``subject_process`` pipeline)
+##
+## - final_dot: ensure text finishes with a dot
+## (usually used in the ``subject_process`` pipeline)
+##
+## - strip: remove any spaces before or after the content of the string
+##
+## - SetIfEmpty(msg="No commit message."): will set the text to
+## whatever given ``msg`` if the current text is empty.
+##
+## Additionally, you can `pipe` the provided filters, for instance:
+#body_process = Wrap(regexp=r'\n(?=\w+\s*:)') | Indent(chars=" ")
+#body_process = Wrap(regexp=r'\n(?=\w+\s*:)')
+#body_process = noop
+body_process = ReSub(r'[^\\](_)', r'\\_') | ReSub(r'((^|\n)[A-Z]\w+(-\w+)*: .*(\n\s+.*)*)+$', r'') | strip
+
+
+## ``subject_process`` is a callable
+##
+## This callable will be given the original subject and result will
+## be used in the changelog.
+##
+## Available constructs are those listed in ``body_process`` doc.
+subject_process = (strip | ReSub(r'_', r'\\_') | ReSub(r'\*', r'\\*') |
+ ReSub(r'>', r'\\>') | ReSub(r'<', r'\\<') |
+ ReSub(r'^([cC]hg|[fF]ix|[nN]ew)\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n@]*)(@[a-z]+\s+)*$', r'\4') |
+ SetIfEmpty("No commit message.") | ucfirst | final_dot)
+
+
+## ``tag_filter_regexp`` is a regexp
+##
+## Tags that will be used for the changelog must match this regexp.
+##
+tag_filter_regexp = r'^v*[0-9]+\.[0-9]+(\.[0-9]+)?$'
+
+
+## ``unreleased_version_label`` is a string or a callable that outputs a string
+##
+## This label will be used as the changelog Title of the last set of changes
+## between last valid tag and HEAD if any.
+unreleased_version_label = "[Unreleased]"
+
+
+## ``output_engine`` is a callable
+##
+## This will change the output format of the generated changelog file
+##
+## Available choices are:
+##
+## - rest_py
+##
+## Legacy pure python engine, outputs ReSTructured text.
+## This is the default.
+##
+## - mustache(<template_name>)
+##
+## Template name could be any of the available templates in
+## ``templates/mustache/*.tpl``.
+## Requires python package ``pystache``.
+## Examples:
+## - mustache("markdown")
+## - mustache("restructuredtext")
+##
+## - makotemplate(<template_name>)
+##
+## Template name could be any of the available templates in
+## ``templates/mako/*.tpl``.
+## Requires python package ``mako``.
+## Examples:
+## - makotemplate("restructuredtext")
+##
+#output_engine = rest_py
+#output_engine = mustache("restructuredtext")
+#output_engine = mustache("markdown")
+#output_engine = makotemplate("restructuredtext")
+output_engine = makotemplate(".gitchangelog.tpl")
+
+
+## ``include_merge`` is a boolean
+##
+## This option tells git-log whether to include merge commits in the log.
+## The default is to include them.
+include_merge = False
+
+
+## ``log_encoding`` is a string identifier
+##
+## This option tells gitchangelog what encoding is outputed by ``git log``.
+## The default is to be clever about it: it checks ``git config`` for
+## ``i18n.logOutputEncoding``, and if not found will default to git's own
+## default: ``utf-8``.
+log_encoding = 'utf-8'
+
+
+## ``publish`` is a callable
+##
+## Sets what ``gitchangelog`` should do with the output generated by
+## the output engine. ``publish`` is a callable taking one argument
+## that is an interator on lines from the output engine.
+##
+## Some helper callable are provided:
+##
+## Available choices are:
+##
+## - stdout
+##
+## Outputs directly to standard output
+## (This is the default)
+##
+## - FileInsertAtFirstRegexMatch(file, pattern, idx=lamda m: m.start())
+##
+## Creates a callable that will parse given file for the given
+## regex pattern and will insert the output in the file.
+## ``idx`` is a callable that receive the matching object and
+## must return a integer index point where to insert the
+## the output in the file. Default is to return the position of
+## the start of the matched string.
+##
+## - FileRegexSubst(file, pattern, replace, flags)
+##
+## Apply a replace inplace in the given file. Your regex pattern must
+## take care of everything and might be more complex. Check the README
+## for a complete copy-pastable example.
+##
+# publish = FileInsertIntoFirstRegexMatch(
+# "CHANGELOG.md",
+# r'/(?P<rev>[0-9]+\.[0-9]+(\.[0-9]+)?)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n/',
+# idx=lambda m: m.start(1)
+# )
+# publish = stdout
+
+
+## ``revs`` is a list of callable or a list of string
+##
+## callable will be called to resolve as strings and allow dynamical
+## computation of these. The result will be used as revisions for
+## gitchangelog (as if directly stated on the command line). This allows
+## to filter exaclty which commits will be read by gitchangelog.
+##
+## To get a full documentation on the format of these strings, please
+## refer to the ``git rev-list`` arguments. There are many examples.
+##
+## Using callables is especially useful, for instance, if you
+## are using gitchangelog to generate incrementally your changelog.
+##
+## Some helpers are provided, you can use them::
+##
+## - FileFirstRegexMatch(file, pattern): will return a callable that will
+## return the first string match for the given pattern in the given file.
+## If you use named sub-patterns in your regex pattern, it'll output only
+## the string matching the regex pattern named "rev".
+##
+## - Caret(rev): will return the rev prefixed by a "^", which is a
+## way to remove the given revision and all its ancestor.
+##
+## Please note that if you provide a rev-list on the command line, it'll
+## replace this value (which will then be ignored).
+##
+## If empty, then ``gitchangelog`` will act as it had to generate a full
+## changelog.
+##
+## The default is to use all commits to make the changelog.
+#revs = ["^1.0.3", ]
+#revs = [
+# Caret(
+# FileFirstRegexMatch(
+# "CHANGELOG.rst",
+# r"(?P<rev>[0-9]+\.[0-9]+(\.[0-9]+)?)\s+\([0-9]+-[0-9]{2}-[0-9]{2}\)\n--+\n")),
+# "HEAD"
+#]
+# revs = []
+
+OUTPUT_FILE = "CHANGELOG.md"
+INSERT_POINT_REGEX = r'''(?isxu)
+^
+(
+ \s*\#\s+Changelog\s*(\n|\r\n|\r)
+)
+
+( ## Match all between changelog and release rev
+ (
+ (?!
+ (?<=(\n|\r)) ## look back for newline
+ \#\#\s+\[%(rev)s\]\s+-\s+[0-9]+-[0-9]{2}-[0-9]{2}(\n|\r\n|\r) ## [revision] - date
+ )
+ .
+ )*
+)
+
+(?P<tail>\#\#\s+(?P<rev>%(rev)s))
+''' % {'rev': r".*"}
+
+revs = [
+ Caret(FileFirstRegexMatch(OUTPUT_FILE, INSERT_POINT_REGEX)),
+ "HEAD"
+]
+
+publish = FileRegexSubst(OUTPUT_FILE, INSERT_POINT_REGEX, r"\1\o\n\g<tail>")
+# publish = stdout
diff --git a/.gitchangelog.tpl b/.gitchangelog.tpl
new file mode 100644
index 000000000..59bc8a299
--- /dev/null
+++ b/.gitchangelog.tpl
@@ -0,0 +1,42 @@
+% if data["title"]:
+# ${data["title"]}
+% endif
+All notable changes to this project will be documented in this file.
+
+Changes and documentation about Navit can be found in the wiki at:
+ http://wiki.navit-project.org
+A timeline of opened and closed issue tickets can be found at our trac instance:
+ http://trac.navit-project.org and on our github project:
+ https://github.com/navit-gps/navit/issues
+
+Navit follows the semantic versioning:
+* `x.y.Z` (patch): only bug fixes or refactoring, no changes in functionality
+* `x.Y.z` (minor): added or changed functionality but can be used as a drop-in
+ replacement for the previous version (all data formats and interfaces are still
+ supported); minor UI changes (such as moving individual menu items) are also
+ allowed
+* X.y.z (major): at least one of the following:
+ * Major new functionality (such as Augmented Reality, inertial navigation or
+ support for live traffic services): de-facto standard for end-user apps
+ * New user interface (such as moving from the old pulldown menu UI to the Internal
+ GUI): this is definitely the UI equivalent of a breaking API change
+ * Dropped support for a data format or interface: also a breaking change and
+ usually tends to occur along with larger changes which would warrant a new major
+ version anyway
+
+% for version in data["versions"]:
+
+<% title = "## [%s] - %s" % (version["tag"], version["date"]) if version["tag"] else "## %s" % opts["unreleased_version_label"] %>${title}
+% for section in version["sections"]:
+
+<% lbl = "## %s" % section["label"] %>${lbl}
+
+% for commit in section["commits"]:
+<%
+author = commit["author"].replace('_', '\_')
+subject = "%s [%s]" % (commit["subject"], author)
+entry = indent(subject, first=" * ").strip()
+%>${entry}
+% endfor
+% endfor
+% endfor
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 000000000..8c8bdbf2a
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,2 @@
+### Thanks for opening an issue on Navit. Before submitting a bug report, please read the documentation on what to provide here:
+https://wiki.navit-project.org/index.php/Reporting_Bugs
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 000000000..5623ec64a
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,6 @@
+Thanks for contributing to Navit!
+Before opening a pull request on navit, make sure your commit message follows our guidelines:
+https://wiki.navit-project.org/index.php/Commit_guidelines
+
+and that your code is compliant with out coding style guidelines:
+https://wiki.navit-project.org/index.php/Programming_guidelines
diff --git a/.gitignore b/.gitignore
index 8cee6228a..f24de854c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,11 @@
+/.gradle/
+/.settings/
+/build/
+/navit/android/.externalNativeBuild/
+/navit/android/build/
+/.cproject
/.gitk-tmp.*
+/.project
/CMakeLists.txt.user*
+/navit/android/cmake_plugin_settings.txt
+/nbproject/
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 000000000..1f3ba9b08
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,35 @@
+Cedric Paille <cedricpaille@gmail.com> Cedric PAILLE <cedricpaille@gmail.com>
+Charles Curley <charlescurley@users.noreply.github.com> Charles Curley <charlescurley@charlescurley.com>
+gauthier60 <gauthier60@ffa7fe5e-494d-0410-b361-a75ebd5db220> Gauthier60 <Gauthier60@ffa7fe5e-494d-0410-b361-a75ebd5db220>
+Joseph Herlant <aerostitch@users.noreply.github.com> Joseph Herlant <herlantj@gmail.com>
+Marc Capdeville <mcapdeville@users.noreply.github.com> Marc CAPDEVILLE <marc@icrea-technologies.fr>
+Marc Capdeville <mcapdeville@users.noreply.github.com> mcapdeville <m.capdeville@no-log.org>
+Patrick Höhn <hoehnp@users.noreply.github.com> Patrick Höhn <hoehnp@gmx.de>
+Pierre Grandin <pgrandin@users.noreply.github.com> Pierre GRANDIN <pgrandin@users.noreply.github.com>
+Pierre Grandin <pgrandin@users.noreply.github.com> Pierre GRANDIN <grandinp@altern.org>
+Pierre Grandin <pgrandin@users.noreply.github.com> Pierre Grandin <grandinp@altern.org>
+Pierre Grandin <pgrandin@users.noreply.github.com> Pierre Grandin <grandinp@gmail.com>
+Pierre Grandin <pgrandin@users.noreply.github.com> kazer_ <kazer_@ffa7fe5e-494d-0410-b361-a75ebd5db220>
+Sebastian Leske <sebastian.leske@sleske.name> Sebastian Leske <Sebastian.Leske@sleske.name>
+Sebastian Leske <sebastian.leske@sleske.name> sleske <sleske@ffa7fe5e-494d-0410-b361-a75ebd5db220>
+Stefan Wildemann <metalstrolch@users.noreply.github.com> Stefan Wildemann <gta04@metalstrolche.de>
+Stefan Wildemann <metalstrolch@users.noreply.github.com> Stefan Wildemann <metalstrolch@metalstrolche.de>
+Stefan Wildemann <metalstrolch@users.noreply.github.com> Stefan Wildemann <stefan.wildemann@metalstrolche.de>
+Stefan Wildemann <metalstrolch@users.noreply.github.com> Wildemann Stefan <stefan.wildemann@corpuls.com>
+Michael Dankov <mdankov@users.noreply.github.com> Michael Dankov <tryagain@navit-project.org>
+Michael Dankov <mdankov@users.noreply.github.com> mdankov <mdankov@ffa7fe5e-494d-0410-b361-a75ebd5db220>
+Michael Dankov <mdankov@users.noreply.github.com> mdankov <mdankov@users.noreply.github.com>
+youte62 <jeremylheureux@gmail.com> youte62 <jeremylheureux@gmailcom>
+Johan Fitié <jfitie@users.noreply.github.com> Johan Fitié <jfitie@gmail.com>
+jandegr <jandegr@users.noreply.github.com> jandegr <jandegr1@hotmail.com>
+jkoan <jkoan@users.noreply.github.com> jkoan <jkoan@gmx.de>
+mvglasow <mvglasow@users.noreply.github.com> mvglasow <michael -at- vonglasow.com>
+mvglasow <mvglasow@users.noreply.github.com> mvglasow <michael@vonglasow.com>
+mvglasow <mvglasow@users.noreply.github.com> mvglasow <mvglasow@ffa7fe5e-494d-0410-b361-a75ebd5db220>
+Manuel Hohmann <xenos1984@users.noreply.github.com> xenos1984 <xenos1984@ffa7fe5e-494d-0410-b361-a75ebd5db220>
+Manuel Hohmann <xenos1984@users.noreply.github.com> xenos1984 <mhohmann@physnet.uni-hamburg.de>
+Rikky <Rikky@ffa7fe5e-494d-0410-b361-a75ebd5db220> rikky <rikky@ffa7fe5e-494d-0410-b361-a75ebd5db220>
+Robert Pohlink <pohlinkzei@users.noreply.github.com> Robert Pohlink <pohlinkzei@gmx-topmail.de>
+Robert Pohlink <pohlinkzei@users.noreply.github.com> pohlinkzei <pohlinkzei@gmx-topmail.de>
+Michael Farmbauer <horwitz@users.sourceforge.net> horwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
+Martin Schaller <martin-s@users.sourceforge.net> martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000..09919cf68
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,23 @@
+sudo: required
+
+language: c
+
+services:
+ - docker
+
+before_install:
+- mkdir ../rpmbuild
+- docker pull hoehnp/sailfishos-platform-sdk:2.2.1.18-r1
+- docker run -e VERSION_ID=2.2.1.18 -v `pwd`:/home/nemo/navit hoehnp/sailfishos-platform-sdk:2.2.1.18-r1 /bin/bash -x /home/nemo/navit/contrib/sailfish/build_sailfish_ci.sh
+
+before_deploy:
+ - provider: pages
+ - skip-cleanup: true
+ - github-token: $GITHUB_TOKEN
+ - keep-history: true
+ - local-history: `pwd`/../rpmbuild/RPMS/armv7hl/
+ - local-history: `pwd`/../rpmbuild/RPMS/i586/
+before_script: skip
+script: skip
+after_success: skip
+after_script: skip
diff --git a/AUTHORS b/AUTHORS
index 426de519d..ffcabcb6b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,7 +1,70 @@
-Michael Farmbauer <horwitz@users.sourceforge.net>
-Martin Schaller <martin-s@users.sourceforge.net>
-Pierre Grandin <kazer_@users.sourceforge.net>
-Alexander Atanasov <aatanasov@gmail.com>
+# Active contributors:
+Charles Curley
+jandegr
+jkoan
+Johan Fitié
+Joseph Herlant
+KAMiKAZOW
+lains
+Marc Capdeville
+Michael Dankov
+mvglasow
+naggety
+Patrick Höhn
+Pierre Grandin
+Robert Pohlink
+Sebastian Leske
+Stefan Wildemann
+tengel
+Timo
+trldp
+youte62
-And all the Navit Team members and contributors.
-See http://wiki.navit-project.org/index.php/Navit_project_members_and_contributors for the full list!
+# Retired contributors:
+afaber
+akashihi
+anhanguera
+aurel_j
+bjasspa
+bodenseepingu
+bustersnyvel
+carcinoma
+Cedric Paille
+christeck
+eiten
+gauthier60
+geoghegan
+ghenzo
+gotwo
+greg
+hafting
+hawke666
+kelvinzhao
+klausg
+korrosa
+latouche
+Manuel Hohmann
+Martin Schaller
+mattcallow
+Michael Farmbauer
+niccolo
+norad
+OmegA_MRS
+pavel
+plum_
+Rikky
+Robotaxi
+rphlx
+sanderd17
+seralph
+singesang
+spaetz
+steven_s
+tegzed
+tinloaf
+woglinde
+worldcitizen
+zaxl
+zintor
+zoff99
+zoniq
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 000000000..d94d5b9eb
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,766 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+Changes and documentation about Navit can be found in the wiki at:
+ http://wiki.navit-project.org
+A timeline of opened and closed issue tickets can be found at our trac instance:
+ http://trac.navit-project.org and on our github project:
+ https://github.com/navit-gps/navit/issues
+
+Navit follows the semantic versioning:
+* `x.y.Z` (patch): only bug fixes or refactoring, no changes in functionality
+* `x.Y.z` (minor): added or changed functionality but can be used as a drop-in
+ replacement for the previous version (all data formats and interfaces are still
+ supported); minor UI changes (such as moving individual menu items) are also
+ allowed
+* X.y.z (major): at least one of the following:
+ * Major new functionality (such as Augmented Reality, inertial navigation or
+ support for live traffic services): de-facto standard for end-user apps
+ * New user interface (such as moving from the old pulldown menu UI to the Internal
+ GUI): this is definitely the UI equivalent of a breaking API change
+ * Dropped support for a data format or interface: also a breaking change and
+ usually tends to occur along with larger changes which would warrant a new major
+ version anyway
+
+
+## [Unreleased]
+
+To get the list of all the unreleased commits, see:
+https://github.com/navit-gps/navit/compare/v0.5.2...HEAD
+
+This changelog is generated from the list of commits on every releases.
+
+## [v0.5.3] - 2018-08-31
+
+Release 0.5.2 had issues with the version not properly updated in the `CMakeLists.txt`. This release fixes that issue.
+
+## Changed
+
+* Update Sailfish spec for release 0.5.3. [Joseph Herlant]
+* Update Patch version for release 0.5.3. [Joseph Herlant]
+
+## [v0.5.2] - 2018-08-30
+
+## Added
+
+* Add:build:Make gradlew executable. [mvglasow]
+* Add:build:Ignore gradle artifacts. [mvglasow]
+* Add:doc:add codefactor.io (#599) [jkoan]
+* Add:desktop:Add keywords to application desktop file (#610) [Joseph Herlant]
+* Add:Android:checkstyle-javadoc (#595) [jandegr]
+* Add:build:Add cmake4eclipse artifacts to .gitignore (#594) [mvglasow]
+* Add Slovakia and Belgium to the maplist. [jandegr]
+
+## Changed
+
+* Update:doc:Update AUTHORS file. [Joseph Herlant]
+* Update in-tree espeak to espeak-1.48.04 (#624) [Stefan Wildemann]
+* Update:scripts:change the sanity script to exclude fib and support. [Joseph Herlant]
+* Update:scripts:simplify the variables concatenation (#620) [Joseph Herlant]
+* Change parenthesis substitutuin as per CodeFactor request. [Stefan Wildemann]
+* Update:scripts:change the scripts that use non-POSIX functionnalities to bash v2 (#618) [Joseph Herlant]
+* Update:scripts:avoid iterating over ls output by using glob (#614) [Joseph Herlant]
+* Update:scripts:change the scripts that use non-POSIX functionnalities to bash (#613) [Joseph Herlant]
+* Update:style:optimize the usage of cat in shell scripts (#612) [Joseph Herlant]
+* Change:gui:Add underscore to internal gui keyboard. (#607) [tengel]
+* Update:i18n:Updated Čeština translation from launchpad (#602) [Pierre GRANDIN]
+* Update:i18n:Updated Dutch translation from launchpad (#601) [Pierre GRANDIN]
+* Update:i18n:Updated Serbian translation from launchpad (#600) [Pierre GRANDIN]
+* Update:doc:Remove overused space characters from README.md (#591) [KAMiKAZOW]
+* Updated header. [Pierre Grandin]
+* Update:i18n:Updated German translation from launchpad (#567) [Pierre GRANDIN]
+* Update:i18n:Updated Spanish translation from launchpad (#566) [Pierre GRANDIN]
+* Update:gtk:use user-configured units in Points of Interest (POI) window. (#557) [Charles Curley]
+* Update:xmlconfig:Use g\_strndup instead of strncpy. [Joseph Herlant]
+* Update:xmlconfig:Make sure we use g\_malloc/g\_free instead of malloc/free. [Joseph Herlant]
+* Update:doc:Update the AUTHORS file. [Joseph Herlant]
+* Update:i18n:Updated French (fr) translation from launchpad (#453) [Pierre GRANDIN]
+* Curley distance poi (#638) [Charles Curley]
+* Refactor:gui/internal: Add pointer and label when using function "view on map" (#631) [lains]
+* Refactor:core:Minor documentation amendment. [mvglasow]
+* Refactoring:graphics Improving quality of circles on platforms without native circle method (#628) [lains]
+* Refactor:core:Improve documentation of route\_value\_seg() [mvglasow]
+* Update:release:Add more keywords for gitchangelog
+
+## Fixed
+
+* Fix Android apk VersionCode (#633) [jkoan]
+* Fix latlon2bookmark (#627) [jkoan]
+* Build:Disable map/garmin on Android. [mvglasow]
+* Build:Disable vehicle/gpsd on Android. [mvglasow]
+* Scripts:WinCE build script (remove sample map, add espeak-data) (#632) [lains]
+* Scripts:replace \s with the supported use of the space class (#617) [Joseph Herlant]
+* Scripts:fix malformed shebang (#615) [Joseph Herlant]
+* Cmake:Fix the way we set the LIB\_DIR when LIBDIR is set for backward compatibility (#574) [Joseph Herlant]
+* Debug:Fix potential unterminated C--string and refactoring debug\_vprintf() (#564) [lains]
+* Maptool:coverity #262887 - leaked\_storage: Variable f going out of scope leaks the storage it points to. (#598) [Joseph Herlant]
+* Config:Fix dtd to allow real xmlint (#583) [jkoan]
+* Fixed typos. [Pierre Grandin]
+* Fixed debug statement. [Pierre Grandin]
+* Core:fix log replay. [Pierre Grandin]
+* Vehicle\_android:Doc update (#571) [jandegr]
+* Graphics:Remove missing endif from if else block. [jkoan]
+* Core:Fixing dbg() change introduced in 221f783ea1caaaab2f5ceadc6b0fb3e720aac3df (#560) [lains]
+* CI convert with librsvg2-bin xxsmal cleanup (#554) [jandegr]
+* Debug:Change line separators for dbg to work also on win\* platform (#546) [Joseph Herlant]
+* Android:Fix for the permissions dialog (#459) [jkoan]
+* Revert Fix because the docker image was fixed. [jkoan]
+* Icons:Remove links to unknown image from gui\_map.svg (#542) [Joseph Herlant]
+* Gui\_internal:use max/min instead of fmax/fmin as absent from wince. [Joseph Herlant]
+* Cleanup:android:Fix android checkstyle complains (#645) [Joseph Herlant]
+* Cleanup:scripts:Fix condefactor complaints (#646) [Joseph Herlant]
+* Cleanup:maptool: use g\_strcmp0 instead of strcmp (#434) [Joseph Herlant]
+* Cleanup:scripts:Use $(..) instead of legacy `..` to make codefactor happy (#623) [Joseph Herlant]
+* Cleanup:python:cleanup python scripts (#622) [Joseph Herlant]
+* Cleanup:global:force the re-attach the return type to the function declaration (#605) [Joseph Herlant]
+* Cleanup:android: re-attach return type to function declaration. [Joseph Herlant]
+* Cleanup:cmake:retab all CMakeLists.txt files. [Joseph Herlant]
+* Cleanup:global:Use astyle to reformat everything. [Joseph Herlant]
+* Android lint check (#586) [jandegr]
+* Android:Fix:graphics (#580) [jandegr]
+* Move the file name to the right spot. [Joseph Herlant]
+* Revert #612 for sailfish build script. [Stefan Wildemann]
+* Android translations (#589) [jandegr]
+* Refactor:Android (#572) [jandegr]
+* Rework:android:Move build system from ant to grandle (#553) [jandegr]
+* Refactor:Android (#563) [jandegr]
+* Refactoring:Android:cleanup (#458) [jandegr]
+
+## Removed
+
+* Cleanup:osd&support\_espeak:get rid of unused-variables compilation warnings (#619) [Joseph Herlant]
+* Cleanup:scripts:removes deprecated usage of egrep (#616) [Joseph Herlant]
+* Cleanup:win32:Remove unused variables (#611) [Joseph Herlant]
+* Cleanup:cmake:remove trailing spaces. [Joseph Herlant]
+* Cleanup:wince:remove unused header (#576) [Joseph Herlant]
+* Cleanup:general:Declaring war to control-M. [Joseph Herlant]
+* Cleanup:xmlconfig:Remove unreachable code. [Joseph Herlant]
+* Cleanup:global:Cleanup some unreachable code. [Joseph Herlant]
+* Android:Fix:remove unused dependency libpng (#592) [jandegr]
+
+
+## [v0.5.1] - 2018-04-19
+
+## Added
+
+* Adding question mark to icon for position pending (#423) [lains]
+* Add:icon:forbiden\_area (#331) [youte62]
+* Add:build:Add download center (#405) [jkoan]
+* Add:icon:danger\_area. [youte62]
+* Add:icon:carwash. [youte62]
+* Add:graphics-qt5:add missing watchEvent slot (#387) [Pierre GRANDIN]
+* Add drinking\_water.svg designed by me - free to use. [youte62]
+* Add governement\_building.svg designed by me - free to use. [youte62]
+* Add:icon:communication (#343) [youte62]
+* Add some Documentation to Plugins (#375) [jkoan]
+* Add:icon:concert (#342) [youte62]
+* Add:doc:added errors and usage messages to navit\_svg2png script (#369) [naggety]
+* Add:icon:fish (#330) [youte62]
+* Add:icon:update ghost\_town icon (#332) [youte62]
+* Add:icon:bridge (#339) [youte62]
+* Add:icon:emergency (#326) [youte62]
+* Add:gtk:add menu entry to toggle vehicle tracking (#362) [Charles Curley]
+* Add:icon:hotspring (#335) [youte62]
+* Add:icon:diving. [youte62]
+* Add:icon:diving (#329) [youte62]
+* Add:icon:drinking\_water (#325) [youte62]
+* Add:icon:dam (#324) [youte62]
+* Add:Icon:crossing (#323) [youte62]
+* Add:Icon:concert (#322) [youte62]
+* Add:Icon:communication (#321) [youte62]
+* Add:icon:carwash (#320) [youte62]
+* Add:Icon bridge (#319) [youte62]
+* Add:icon:bowling (#318) [youte62]
+* Add:icon:autoservice (#317) [youte62]
+* Add msissing items. [jkoan]
+* Add multicountry towns support in maptool (#305) [mdankov]
+* Add a script to get bbox out of geojson. [jkoan]
+* Added an install target for support libs. [Pierre Grandin]
+* Add some more common landuse polygons (#262) [Johan Fitié]
+* Add Zoom to route button to Route section in menu (#264) [Johan Fitié]
+* Add some more common landuse polygons. [Johan Fitié]
+* Add:maptool:Better error messages for wrong cmdline parameters. [Sebastian Leske]
+* Add:xml:Add 43 polys to Car and Car-dark layouts. [Johan Fitié]
+* Add:xpm:New SVG icon for hunting stand, to replace XPM, made by myself :-). [Sebastian Leske]
+* Add:xpm:POI Icon for playground, from openstreetmap-carto. [Sebastian Leske]
+* Add:gui\_internal:New POI filter for bus&train. [Sebastian Leske]
+* Add feature poly\_reservoir. [Johan Fitié]
+* Add grass, grassland, wetland and sand. [Johan Fitié]
+* Add poly\_basin. [Johan Fitié]
+* Add: Add speech module using espeak on QMultimedia. (#233) [Stefan Wildemann]
+* Add auto zoom toggle to gui\_internal (#237) [Johan Fitié]
+* Add Qt5 qml gui skeleton (#236) [Stefan Wildemann]
+* Add desktop icons in sizes required by Sailfish OS. (#220) [Stefan Wildemann]
+* Add 'Follow' and 'Active' to vehicle\_demo to remove the corresponding error messages (Unsupported Attribute) (#229) [Robert Pohlink]
+* Add network info menu in gui/internal for Linux (#228) [Pierre GRANDIN]
+* Add rules to build sailfish package (#221) [Stefan Wildemann]
+* Add strings for permission dialog. [jandegr]
+* Add libqt5svg5-dev to test environment. [Stefan Wildemann]
+* Add screen blanking for Sailfish OS. [Stefan Wildemann]
+* Add Qt5 based vehicle. [Stefan Wildemann]
+* Add QT5 graphics. Works on Sailfish OS. [Stefan Wildemann]
+* Add:graphics:RaspberryPI hardware accelerated graphics support (#208) [Cedric PAILLE]
+* Added automatic publishing to Playstore Beta. [Pierre Grandin]
+* Added download links for PlayStore and F-Droid in the README. [Pierre GRANDIN]
+* Added some usage images to the README.md. [Pierre GRANDIN]
+* Add CI badge. [jandegr]
+* Add gui\_layers.svg. [jandegr]
+* Add a feature to change zoom level in autozoom mode. [pohlinkzei]
+* Add set\_position to command table. [jandegr]
+* Add destination forward/backward. [jandegr]
+* Add:gui\_internal:Support mode for native virtual keyboard. [mvglasow]
+* Add:gui\_internal:Rudimentary native on-screen keyboard implementation. [mvglasow]
+* Add:graphics\_android:Use background\_color attribute for system bar tint. [mvglasow]
+* Add:port\_android:Add custom tint to system bars on API 19+ Still with hardcoded colors and minor rendering bugs. [mvglasow]
+* Add:core:Use padding for vehicle cursor if supported by graphics driver. [mvglasow]
+* Add:gui\_internal:Use padding if supported by graphics driver. [mvglasow]
+* Add:osd:Use padding if supported by graphics driver Still buggy (race condition) [mvglasow]
+* Add:graphics\_android:Implement padding for areas obstructed by system UI. [mvglasow]
+* Add:port\_android:Make system bars translucent on API 19+, transparent on API 21+ [mvglasow]
+* Add:port\_android:Apply color theme. [mvglasow]
+* Add:port\_android:Notification icon which complies with Android style guide for all densities. [mvglasow]
+* Add configurability for speed\_warner timeout. [Robert Pohlink]
+* Add:port\_android:Remove ActionBar as it is no longer needed. [mvglasow]
+* Add:port\_android:OSD button and command to show Android menu. [mvglasow]
+* Adding a androix/x86 build script. [Pierre GRANDIN]
+
+## Changed
+
+* Update NavitVehicle.java. [jandegr]
+* Update NavitVehicle.java. [jandegr]
+* Change\_android:Android no acra (#438) [jandegr]
+* Update build\_win32.sh. [jandegr]
+* Update:i18n:Updated Arabic translation from launchpad (#415) [Pierre GRANDIN]
+* Change:osd: compass appearance update (#413) [lains]
+* Change:build:Move update of doxygen to own script (#404) [jkoan]
+* Update build\_win32.sh (#402) [jandegr]
+* Update config.yml. [jandegr]
+* Update config.h.cmake. [jandegr]
+* Update osm\_psql.c. [jandegr]
+* Update CMakeLists.txt. [jandegr]
+* Update:icon:update drinking\_water icon. [youte62]
+* Update:icon:update goverment\_building icon. [youte62]
+* Update:doc:Update changelog to follow semver rules (#355) [Joseph Herlant]
+* Change:android:always build apk release (#364) [Pierre GRANDIN]
+* Update:icon:bowling (#338) [youte62]
+* Update:i18n:Updated French (fr) translation from launchpad (#353) [Pierre GRANDIN]
+* Update:i18n:Updated Spanish translation from launchpad (#352) [Pierre GRANDIN]
+* Update:i18n:Updated Čeština translation from launchpad (#351) [Pierre GRANDIN]
+* Update:doc:Build doxygen doc and push the result to a gh-pages branch (#354) [Joseph Herlant]
+* Update:icon:updated dam.svg. [youte62]
+* Update:QML2:Various updates on the QML2 UI (#316) [Pierre GRANDIN]
+* Updated shapefile driver (#295) [Pierre GRANDIN]
+* Update Android screenshot in README.md. [Johan Fitié]
+* Change default cursor in Car and Car-dark layouts (#296) [Johan Fitié]
+* Update:i18n:Updated Portuguese translation from launchpad. [Pierre Grandin]
+* Update size estimations in Android map downloader (#272) [Johan Fitié]
+* Change Android default layout from Car-Android to Car (#224) [Johan Fitié]
+* Update:i18n:Updated German translation from launchpad. [Pierre Grandin]
+* Update:Allow zipcode or town seamless search. [jandegr]
+* Updated: F-Droid download link (#199) [zintor]
+* Update:i18n:Updated German translation from launchpad. [Pierre GRANDIN]
+* Update build\_tomtom\_plugin.sh. [jandegr]
+* Update build\_tomtom\_minimal.sh. [jandegr]
+* Update build\_tomtom\_plugin.sh. [jandegr]
+* Update build\_tomtom\_minimal.sh. [jandegr]
+* Update:i18n:Updated Ukrainian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Sinhalese translation from launchpad. [CircleCI]
+* Update:i18n:Use rebase instead of a PR for translations updates. [Pierre Grandin]
+* Update:i18n:Updated Turkish (tr) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Piemontese translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Telugu translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Serbian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Polish translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Urdu translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Simplified Chinese translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Chinese (Hong Kong) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Ukrainian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Slovak translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Tamil translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Slovenian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Thai translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Albanian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Vietnamese translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Sardinian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Swahili translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Russian (ru) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Romanian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Norwegian Nynorsk translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated German, Low translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated German, Low translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Dutch translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Norwegian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Marathi translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Bosnian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Kurdish (Sorani) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Frisian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Latvian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Esperanto translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Galician translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Hebrew translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Filipino translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Japanese translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated French/Switzerland translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Hungarian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Hindi translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Croatian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Kazakh translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Italian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Indonesian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Kurdish translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Javanese translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Korean translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Kannada translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Luxembourgish translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Macedonian (mk) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Lithuanian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Mongolian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Malayalam translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Faroese translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Finnish translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Persian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Basque translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated French (fr) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Estonian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated English (United Kingdom) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated English (Canada) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated German translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Spanish translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Welsh translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Greek translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated English (Australia) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated German (Switzerland) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Catalan translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Danish translation for Navit translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Čeština translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Belarusian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Asturian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Arabic translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Afrikaans translation from launchpad. [Pierre GRANDIN]
+* Update build\_linux.sh. [jandegr]
+* Update build\_linux.sh. [jandegr]
+* Update Navit.java. [jandegr]
+* Update circle.yml. [jandegr]
+* Update build\_android\_x86.sh. [jandegr]
+* Update build\_android.sh. [jandegr]
+* Update arm-eabi.cmake. [jandegr]
+* Update build\_android.sh. [jandegr]
+* Update tomtom. [jandegr]
+* Update:i18n:Updated Norwegian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Portuguese translation from launchpad. [Pierre GRANDIN]
+* Update Makefile.am. [jandegr]
+* Update xml for heightlines. [jandegr]
+* Update doc. [jandegr]
+* Update:i18n:Updated Chinese (Traditional) translation from launchpad. [Pierre GRANDIN]
+* Update gui\_internal\_command.c. [jandegr]
+* Update:i18n:Updated German translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated French (fr) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Čeština translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Russian (ru) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Spanish translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Italian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Lithuanian translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Welsh translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Chinese (Traditional) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Chinese (Traditional) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Dutch translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Chinese (Traditional) translation from launchpad. [Pierre GRANDIN]
+* Update navit.c. [jandegr]
+* Update:i18n:Updated German, Low translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Polish translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated French (fr) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated English (United Kingdom) translation from launchpad. [Pierre GRANDIN]
+* Update link to wiki for OSD commands. [jandegr]
+* Change format\_distance to more proper values. [Robert Pohlink]
+* Update:i18n:Updated French (fr) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated English (United Kingdom) translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Danish translation for Navit translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Updated Polish translation from launchpad. [Pierre GRANDIN]
+* Update:i18n:Fixing po import script. [Pierre GRANDIN]
+* Update osd\_core.c. [Robert Pohlink]
+* Update attr.h. [jandegr]
+* Updated Hungarian translation from launchpad. [Pierre GRANDIN]
+* Updated Lithuanian translation from launchpad. [Pierre GRANDIN]
+* Updated Catalan translation from launchpad. [Pierre GRANDIN]
+* Update circle.yml. [jandegr]
+* Update circle.yml. [jandegr]
+* Update build\_android\_x86.sh. [jandegr]
+* Update i686-android.cmake. [jandegr]
+* Update build\_android\_x86.sh. [jandegr]
+* Update i686-android.cmake. [jandegr]
+* Update build\_android\_x86.sh. [jandegr]
+* Update circle.yml. [jandegr]
+* Update build\_android\_x86.sh. [jandegr]
+* Update build\_android\_x86.sh. [jandegr]
+* Update build\_android\_x86.sh. [jandegr]
+* Updated COPYRIGHT for 2016. [Pierre GRANDIN]
+
+## Fixed
+
+* Contrib:New version for sailfish 0.5.1-r5 (#444) [Stefan Wildemann]
+* OSD:Make Image and Scale osd types obey osd\_configuration setting (trac:1202) (#439) [Robert Pohlink]
+* Icons:fix typo business not bussines (#430) [Joseph Herlant]
+* Fix coverity builds (#432) [Pierre GRANDIN]
+* Typo:Fix various mispells (#421) [Joseph Herlant]
+* Maptool: prevent memory leak when fread fails (#420) [Joseph Herlant]
+* Wince:Remove useless files from the output (#412) [Pierre GRANDIN]
+* Fix:XML:Adding missing sea/ocean display in T@H layout theme. [lains]
+* Build:Fix keyscan for wince (#410) [jkoan]
+* Cmake:Fix getting the version from git to fix the wince build (#408) [jkoan]
+* Build:Fix download of Cov (#400) [jkoan]
+* Corrected files considering more comments by @pgrandin. [Patrick Höhn]
+* Fix: added changes as suggested by @pgrandin on github. [Patrick Höhn]
+* Corrected header file to change of return type of load\_buffer. [Patrick Höhn]
+* Wrong use of boolean values. [Patrick Höhn]
+* Changes in buffer.c. [Patrick Höhn]
+* Avoid NULL pointer in ch.c. [Patrick Höhn]
+* Build:fixed compiler warning in maptool module. [Patrick Höhn]
+* Navit:navigation.c:distance\_set\_last (#373) [Charles Curley]
+* Build:fixed compiler warning in vehicle module (#394) [Patrick Höhn]
+* Build:fixed compiler warning in graphics module. [Patrick Höhn]
+* Android:Use date of commit as version code instead of system time (#376) [jkoan]
+* Gtk:Initialize Follow menu entry correctly. (#390) [Charles Curley]
+* Wince:fixed the wince build (#386) [Pierre GRANDIN]
+* Cmake:Make copy of files more reliable (#377) [jkoan]
+* Cmake:Rework of xslt convert process to fix the copy issue of the navit.dtd file in android build (see process\_xslt) (#381) [jkoan]
+* Gtk:Fix imperial factors. (#380) [Charles Curley]
+* Android:reworked notification system for sdk 23 (#374) [jkoan]
+* Core:Wrong default png size with ksvgtopng (#371) [naggety]
+* Gtk:Fix imperial factors (#367) [Charles Curley]
+* Improved follow vehicle toggle doc function for GTK (#363) [Charles Curley]
+* Export more doxygen content. [Pierre Grandin]
+* Ensure that the custom domain is set for doxygen (#361) [Pierre GRANDIN]
+* Android:Fixed forced colors in layout to have android auto adaptation (#358) [jkoan]
+* Android Fix dialogs and replace \_ with T for Translate because \_ is deprecated (#350) [jkoan]
+* Core:Remove dependency on OpenSSL. [Sebastian Leske]
+* Maptool:Remove option -5 (MD5 checksum) from maptool. [Sebastian Leske]
+* Core:Remove binfile map encryption support. [Sebastian Leske]
+* Gtk:fixed missing imperial units in the GTK ui. (#359) [Charles Curley]
+* Android:Add workaround for android platform tools (#357) [jkoan]
+* Android:Ensures that we capture all build errors. [Pierre Grandin]
+* Core:Reduce POST\_SHIFT to avoid int overflow. [Sebastian Leske]
+* Build:Add -Wformat-security. [Sebastian Leske]
+* Core:Fix warnings from -Wstrict-prototypes. [Sebastian Leske]
+* Core:Fix warnings from -Wmissing-prototypes. [Sebastian Leske]
+* Core:Fix compiler warnings. [Sebastian Leske]
+* Build:Fix conditional compiler warning options. [Sebastian Leske]
+* Core:Remove unused macros min/max, which conflict with C++ standard macros. [Sebastian Leske]
+* Core:Use fprintf with string literal instead of variable. [trldp]
+* Core:Rename README.md to README, since some external builds need a README. [Sebastian Leske]
+* Fixes displaying the heightline route info (#294) [Pierre GRANDIN]
+* Maptool Accept ISO3166-1:alpha2 tag. [mdankov]
+* Xpm:Resize overlooked POI icons to 22x22. [Sebastian Leske]
+* Fixed variables name in support lib macro. [Pierre Grandin]
+* Xml:Fix XML formatting. [Johan Fitié]
+* Android cursor size (#267) [Stefan Wildemann]
+* Build:Fix typo which causes CMake warning. [Sebastian Leske]
+* Build:Regenerate navit\*.xml if XSLT files change. Fixes first part of #1333. [Sebastian Leske]
+* Xml:Remove unused XSLT files android\_\*.xslt. [Sebastian Leske]
+* Gui\_internal:Add missing types to POI filter bus&train. [Sebastian Leske]
+* Graphics\_qt5 fix layer drawing and dragging. [Stefan Wildemann]
+* Make rotating compatible to Qt 5.2 (#256) [Stefan Wildemann]
+* Maptool:Update maptool help and manpage. [Sebastian Leske]
+* Xml:Change colors for wetland in Car and Car-dark (#257) [Johan Fitié]
+* Xpm:Remove obsolete XPM icons. [Sebastian Leske]
+* Xpm:Add white outline to black SVG icons. [Sebastian Leske]
+* Xpm:Add white outline to new icon hunting\_stand. [Sebastian Leske]
+* Fix Car layout issues with wood and water (#240) [Johan Fitié]
+* Apply coding style to vehicle\_qt5. [Wildemann Stefan]
+* Apply coding style to graphics\_qt5. [Wildemann Stefan]
+* Add autozoom switch to sailfosh config. [Wildemann Stefan]
+* Fix trac981: Add Align-Attr to osd type Odometer (#230) [Robert Pohlink]
+* Don't crash if LANG environment not set (#232) [Stefan Wildemann]
+* Fix POI toggle bug with Car-dark layout (#223) [Johan Fitié]
+* Allow unusual building (#215) [Stefan Wildemann]
+* Fix #1345 crash on Android. [mdankov]
+* Gui\_internal:Rename new option to hide\_impossible\_next\_keys. [Sebastian Leske]
+* Fix apk signing and bump sdk to 25 - nougat (#209) [jandegr]
+* Remove autotools leftovers. [Wildemann Stefan]
+* Qt5: only update navit geometry if root window changed size. [Stefan Wildemann]
+* Qt5: fix resizing. Add config params w,h,fullscreen. [Stefan Wildemann]
+* Qt5: clean up things even if there i no app object. [Stefan Wildemann]
+* Qt5: allow passing Qt backend via config.xml. [Stefan Wildemann]
+* Qt5: integer to pinter cast as suggested by GLib. [Stefan Wildemann]
+* Fix overlay text functions. [Stefan Wildemann]
+* Fixed Store client\_secrets path. [Pierre Grandin]
+* Fixed keyrings path. [Pierre Grandin]
+* Port/android:Fix "invalid DT\_NEEDED" warnings on API 23+, fixes #1348. [mvglasow]
+* Tomtom:Switching to mirrored toolchain. [Pierre Grandin]
+* I18n:Ensure that we pull from trunk before rebasing. [Pierre Grandin]
+* I18n:Escape commit message when merging updates. [Pierre Grandin]
+* I18n:Rebase i18n updates against trunk, not master. [Pierre Grandin]
+* Core:Fix iPhone build broken by plugin refactoring. [Sebastian Leske]
+* Fixed pot file path when building trunk. [Pierre Grandin]
+* Maptool:Correct OSM tag is shop=chemist, not drogist. [Sebastian Leske]
+* Map\_csv:If we cannot open a CSV map file, log error and return failure. [Sebastian Leske]
+* Fixed typo in build\_android.sh. [Pierre Grandin]
+* Fixing dbus tests dependencies. [Pierre Grandin]
+* Fixed libpng version check. [Pierre Grandin]
+* Fixed typo in circle.yaml. [Pierre Grandin]
+* Fix old iOS jailbreak build. [jandegr]
+* Maptool:properly check node reference mark. [Michael Dankov]
+* Maptool:proper signedness. [Michael Dankov]
+* Core:Added link to the OSD wiki page in navit\_shipped.xml. [Pierre Grandin]
+* Core:Prevent crash on exit if csv map was used Do not attempt to free(attr-\>data) of attr\_item\_type attribute, it holds a number, not a pointer. [Michael Dankov]
+* Core:initialize value to suppress valgrind warning The warning had no actual effect, as final result of the expression was not depending on uninitialized value being tested in it. [Michael Dankov]
+* Gui\_internal:Properly switch keyboard to lower/uppercase Do the automatic switch in gui\_internal\_keypress\_do instead of gui\_internal\_search\_changed so that other text input widgets would benefit, e.g. poi search. [Michael Dankov]
+* Gui\_internal:Fix Cyrillic caps switch button. [Michael Dankov]
+* Port\_android:Hide osd buttons during map scroll Setting use\_overlay attr of \<osd type="button"\> now is supported and enabled in default config. [Michael Dankov]
+* Port\_android:No system bars tinting before KITKAT There's no way to make navigation and status bar translucent nor transparent before KITKAT, see https://developer.android.com/about/versions/android-4.4.html#UI So corresponding code realted to SystemBarTintView should be enabled since API 19, KITKAT. It actually was breaking navit on my API 17 device, drawing unrelated semitransparent bars on the top and right sides of the screen. [Michael Dankov]
+* Port\_android:Do not tint on pre-API-17 Tinting the navigation and status bars (introduced in a3e9e7) makes the whole screen tinted on my Gingerbread (API level 9) device. As the actual tint code in handleResize is anyway activated on API\>=17, there's no reason to create navigationTintView and statusTintView on API\<17. [Michael Dankov]
+* Core:Make some counters unsigned to avoid UB on overflow. [Sebastian Leske]
+* Gui\_internal:Repair "Set distance to"/"Get more" menu items. Fixes #1342. [Sebastian Leske]
+* Gui\_internal:Hide native keyboard when displaying POI search results. [mvglasow]
+* Gui\_internal:Make native keyboard compatible with changes after R6421. [mvglasow]
+* Port\_android:Restore soft keyboard when resuming activity. [mvglasow]
+* Gui\_internal:Further native keyboard refinements. [mvglasow]
+* Port\_android:Remove noisy debug code. [mvglasow]
+* Gui\_internal:Correctly handle fullscreen toggle on Android API 17+ [mvglasow]
+* Port\_android:Prevent system bar tint views from overlapping. [mvglasow]
+* I18n:Fixing translations import. [Pierre GRANDIN]
+* Fix wait\_before\_warn. [Robert Pohlink]
+* Core:Fix typo in nav\_status\_to\_text() [mvglasow]
+* Osd:Draw correct icon for navigation\_status OSD when resizing window. [mvglasow]
+* Core:Make attr\_dup\_content support attr\_item\_type. Fixes trac #1340. [Sebastian Leske]
+* Core:Exit if GUI or graphics init / connection fails. [Sebastian Leske]
+* Osd: Convert zero button size to magic indicator size -1. [Stefan Wildemann]
+* Osd: Make osd "Button" accept h and w props. [Stefan Wildemann]
+* Core:Crash in country\_search\_new Properly handle coutry search by attr\_country\_id to fix crash in internal gui when there's a gps fix and a map supporting attr\_country\_id such as Reiseplaner is active. Fixes #1337. [Michael Dankov]
+
+## Removed
+
+* Removed deprecated files and fixed a configuration example. [jkoan]
+* Cleanup old xpm icons (#292) [Johan Fitié]
+* Removed autotools lefotover (#204) [jandegr]
+* Cleanup. [jandegr]
+
+## Other
+
+* Show min/max elevation and distance in height profile. [Timo]
+* Maptool: migrate strdup to g\_strdup. [Joseph Herlant]
+* Maptool use g\_realloc instead of realloc. [Joseph Herlant]
+* Maptool: migrate free to g\_free. [Joseph Herlant]
+* Maptool: migrate malloc to g\_malloc. [Joseph Herlant]
+* Refactor:core:Refine documentation of attr.c. [mvglasow]
+* Navit/fib: cleanup unused configure\* files (#422) [Joseph Herlant]
+* Maptool: prevent issues when realloc fails (#419) [Joseph Herlant]
+* Doc: fix misspell. [Joseph Herlant]
+* Refactor:core:Some doxygen additions and corrections (#406) [mvglasow]
+* Store win32 nsis installer in artifacts. [jandegr]
+* Remove outdated tts interface (#397) [jkoan]
+* Correct header file considering earlier changes. [Patrick Höhn]
+* Further adjustments according comments. [Patrick Höhn]
+* Doc: added doxygen documentation to buffer.c. [Patrick Höhn]
+* Refactor:core:Add more documentation (#392) [mvglasow]
+* Refactor:route:Improve documentation. [mvglasow]
+* Sailfish build on newer SDKs (#388) [Stefan Wildemann]
+* Refactor:route:More documentation (#385) [mvglasow]
+* Modify icons designed by me - free to use. [youte62]
+* Modify icons designed by me - free to use. [youte62]
+* 200\*200. [youte62]
+* Modify icons designed by me - free to use. [youte62]
+* 200\*200. [youte62]
+* Refactor:core:Documentation in trasform.c. [mvglasow]
+* Refactor:route:Improve struct route documentation. [mvglasow]
+* Refine documentation (#378) [mvglasow]
+* Refactor:core:Improve documentatio. [mvglasow]
+* Refactor:core:Improve documentation. [mvglasow]
+* Core:only GGA or RMC message required, ticket #913 (#365) [naggety]
+* Refactor:route:Improve documentation (#372) [mvglasow]
+* Refactor:core:Refine documentation. [mvglasow]
+* Refactor:route:Improve documentation. [mvglasow]
+* Once more with feeling. More indentation issues. [Charles Curley]
+* Indentation fixes in my last commit. I did not re-indent the entire file. I will leave that for another time. [Charles Curley]
+* The road book now respects imperial for two more columns. The first column (Command) was good for both feet and miles. However, column 2 (Length), and the 4th column (Destination Length), were showing up only in metric. This commit fixes columns 2 and 4. This should fix bug 780. [Charles Curley]
+* Refactor:route:Add documentation. [mvglasow]
+* Refactor:route:Add documentation. [mvglasow]
+* Refactor:route:Add documentation. [mvglasow]
+* Revert "Always build 'release' package for android" [Pierre Grandin]
+* Revert "Fix:android:Ensures that we capture all build errors" [Pierre Grandin]
+* Always build 'release' package for android. [Pierre Grandin]
+* Moved Taiwan into its own map download entry. [Pierre Grandin]
+* Navit medium GUI icon size fix. [Stefan Wildemann]
+* Sailfsh version bump. [Stefan Wildemann]
+* Patch:core:More Talker IDs other than GP accepted (#314) [naggety]
+* Importing wince build script. [Pierre Grandin]
+* Revert last commit. [Pierre Grandin]
+* Coverity upgrade (#313) [Pierre GRANDIN]
+* Revert "Fix:core:Rename README.md to README..." - does not work on GitHub. [Sebastian Leske]
+* Moved xpm to icons (#307) [jkoan]
+* We always want the failed code from bash not from tee. [jkoan]
+* Little quick change to make it working fast. [jkoan]
+* Auto pitch and orientation (#306) [Johan Fitié]
+* #1352 workaround. [mdankov]
+* Smaller Android screenshot for README.md. [Johan Fitié]
+* Pitch correction (#303) [Johan Fitié]
+* [POI] Resize SVG icons to 22x22 (#304) [Johan Fitié]
+* Improve cursor in Car and Car-dark layouts (#302) [Johan Fitié]
+* [POI] Improve Bus stop icon (#301) [Johan Fitié]
+* [POI] Improve Bicycle shop, Cemetery, Bus stop, Museum, School, Fountain and Tower icons (#300) [Johan Fitié]
+* [POI] Improve Public office icon (#299) [Johan Fitié]
+* [POI] Improve Bicycle shop icon (#298) [Johan Fitié]
+* [POI] Improve Drinking water, Shopping, Sport and Tower icons (#297) [Johan Fitié]
+* Display label for heightlines (#284) [jandegr]
+* [POI] Improve Attraction, Cemetery, Heliport, Hotel, Parking and Pharmacy icons (#293) [Johan Fitié]
+* [POI] Improve Emergency, Golf, Pharmacy, Picnic and Wifi icons (#291) [Johan Fitié]
+* [POI] Improve Parking, Shop computer, Shop department, Zoo, TEC common, Unknown and Sport icons (#290) [Johan Fitié]
+* [POI] Improve Attraction, Bicycle shop, Boat ramp, Bus, Cemetery and Cinema icons (#289) [Johan Fitié]
+* [POI] Improve Car dealer, Castle, Fountain, Hospital, Parking, Peak and Pharmacy icons (#288) [Johan Fitié]
+* [POI] Improve Drinking water, Fastfood, Theater, Information, Museum, Shop grocery, Taxi, Toilets and Townhall icons (#287) [Johan Fitié]
+* [POI] Improve Bar, Beer, Bus stop, Fountain, Level crossing, Library, Memorial, Post, Repair service, Shopping and Stadium icons (#286) [Johan Fitié]
+* [POI] Improve Bank, Bench, Police, School, Tower, Trafic signals, Viewpoint, Shop apparel and Worship icons (#285) [Johan Fitié]
+* [POI] Improve Fuel icon (#283) [Johan Fitié]
+* [POI] Improve Exit and Hotel icons (#282) [Johan Fitié]
+* [POI] Improve ATM, Fire brigade and Restaurant icons. [Johan Fitié]
+* [POI] Improve tower icon more. [Johan Fitié]
+* [POI] Improve tower icon (#280) [Johan Fitié]
+* Use cached copy for libpng / tomtom (#276) [jkoan]
+* Use all available Cores on CI (#273) [jkoan]
+* Use datecode insted of Tags as Android id (#274) [jkoan]
+* [Android] Delete MapInfoFile (.tmp.info) after successful download. [Johan Fitié]
+* Sailfish config (#271) [Stefan Wildemann]
+* [Android] Enable autozoom by default (#225) [Johan Fitié]
+* Correctly implement draw\_drag on graphics\_qt5. [Stefan Wildemann]
+* Qt5 qml gui - POC update (#263) [Pierre GRANDIN]
+* Revert "Add some more common landuse polygons" [jandegr]
+* Refactor:maptool:rename variables. [Sebastian Leske]
+* QT5/qml2 UI proof of concept (#254) [Pierre GRANDIN]
+* Graphics\_qt5 QML: Add screen rotation support (#255) [Stefan Wildemann]
+* Make the speed\_warner toggle on click. [Pierre Grandin]
+* Remove Qt5 fonts dependency on Freetype (#253) [Stefan Wildemann]
+* Revert: move poly\_water\_tiled in Car layout. [Johan Fitié]
+* Trac-1246: Draw background color even if text label is empty. (#234) [Robert Pohlink]
+* Navigation\_analyze\_roundabout : central\_angle may lead to division by 0. [Marc CAPDEVILLE]
+* [Android] 'Toggle POIs' button also toggle POI labels (#226) [Johan Fitié]
+* Keep active vehicle profile when deactivating vehicle (#217) [mcapdeville]
+* Graphics Qt5 keyboard (#214) [Stefan Wildemann]
+* Qt5 Graphics: Add QML support (#213) [Stefan Wildemann]
+* Hide impossible keys at the internal keyboard instead of highlighting the possible ones (leftover from PR5) (#210) [Robert Pohlink]
+* Import android.Manifest. [jandegr]
+* Ask permissions on sdk \>= 23. [jandegr]
+* Publish arm packages only on Playstore. [Pierre Grandin]
+* Revert "Temporary: Enable Qt5 graphics in navit\_shipped.xml" [Wildemann Stefan]
+* Temporary: Enable Qt5 graphics in navit\_shipped.xml. [Wildemann Stefan]
+* Refactor: qt5: follow api changes brought with commit 60bc2797f0bd71d87a4eece306e2368afe2a8866. [Stefan Wildemann]
+* Qt5: Use default svg size if size not given. [Stefan Wildemann]
+* Qt5 image loading more robust on navit image guessing. [Stefan Wildemann]
+* Improve dash handling. Cope with impair patterns. [Stefan Wildemann]
+* Ignore old fix provided by Qt5 on startup. [Stefan Wildemann]
+* Clear surfaces if transparent. Fix dash setting. [Stefan Wildemann]
+* Sailfish needs periodic trigger for display on. [Stefan Wildemann]
+* Remove most debug messages. [Stefan Wildemann]
+* Ensure that we use jarsigner w/ jdk 1.8. [Pierre Grandin]
+* Extract android publishing credentials to current folder. [Pierre Grandin]
+* Extract publishing credentials in the right folder. [Pierre Grandin]
+* Ensures that google-api-python-client is installed for apk publishing. [Pierre Grandin]
+* Sunrise near poles simplification (#206) [jandegr]
+* Reducing code duplication in the tomtom builds (#201) [Pierre GRANDIN]
+* Jandegr patch 1 (#203) [jandegr]
+* Android patches from Jandegr (#202) [Pierre GRANDIN]
+* Improved documentation. [Pierre Grandin]
+* Bump zlib. [jandegr]
+* Bump zlib. [jandegr]
+* Removing autotools support. [Pierre GRANDIN]
+* Moving the linux bin to a more generic place to match other builds. [Pierre Grandin]
+* Android ci optimization (#195) [Pierre GRANDIN]
+* Switch badge to trunk. [jandegr]
+* Correctly escape PR message. [Pierre Grandin]
+* Better PR content for automatic i18n PR. [Pierre Grandin]
+* Process translation template update as part of the linux build. [Pierre Grandin]
+* Ensure that we build with gtk\_drawing\_area enabled. [Pierre Grandin]
+* Refactor:core:For plugins, use term 'category' instead of 'type'. [Sebastian Leske]
+* Only setup coverity when needed. [Pierre Grandin]
+* Reworking android build scripts. [Pierre Grandin]
+* Ensure that we build all targets in 4 containers. [Pierre Grandin]
+* Ensure that we build all targets in 4 containers. [Pierre Grandin]
+* Moved win32 dependencies to the build script. [Pierre Grandin]
+* Install junit-xml dbus-python in the user's env. [Pierre Grandin]
+* Install ndk only when needed. [Pierre Grandin]
+* Ensures that python-dev is installed for tests. [Pierre Grandin]
+* Ensures that libdbus-glib-1-dev is installed for tests. [Pierre Grandin]
+* Bumped libpng version to 1.6.26. [Pierre Grandin]
+* Temporarily disabled translation updates. [Pierre Grandin]
+* Enabling build parallelization. [Pierre Grandin]
+* Ensures that python-dbus is installed, needed for tests. [Pierre Grandin]
+* Reduced tomtom CI downloads verbosity. [Pierre Grandin]
+* Moving linux dependencies installation to the build script. [Pierre Grandin]
+* Sdk 23. [jandegr]
+* Install ndk. [jandegr]
+* Convert CI to trusty. [jandegr]
+* Bump libpng. [jandegr]
+* Switch to tomtom minimal build. [jandegr]
+* Missing layer. [jandegr]
+* Wrapper cleanup. [jandegr]
+* Cmake based build for tomtom. [jandegr]
+* Gui\_internal: free heightlines and diagram\_points. [jandegr]
+* Autotools. [jandegr]
+* Create gui\_heightprofile.svg. [jandegr]
+* Delete gui\_heightprofile.xpm. [jandegr]
+* Gui\_internal\_heightprofile. [jandegr]
+* Create gui\_heightprofile.xpm. [jandegr]
+* Gui\_internal: fix occasional crash of heightprofile. [jandegr]
+* Gui\_internal: layer control. [jandegr]
+* Gui internal : some more heightprofile fixes. [jandegr]
+* CI trigger. [jandegr]
+* Gui\_internal : fix heightprofile. [jandegr]
+* Refactor:maptool:Support 56 bit node IDs. [Michael Dankov]
+* Android: disable pedestrian default build. [jandegr]
+* Revert "Fix:gui\_internal:Hide native keyboard when displaying POI search results" [Michael Dankov]
+* Refactor:port\_android:Move system bars tinting code to a separate function. [Michael Dankov]
+* Remove debug message. [pohlinkzei]
+* Refactor:gui\_internal:Remove out-ifdefed code and unused widget states. [Sebastian Leske]
+* Refactor:gui\_internal:Code cleanup. [Sebastian Leske]
+* Typo. [jandegr]
+* Layoutswitcher command. [jandegr]
+* Delete android\_all\_densities.xslt. [jandegr]
+* Android: remove unused and unmaintained XSLT files. [jandegr]
+* Delete NavitGraphics2.java. [jandegr]
+* Delete NavitAndroidOverlay.java. [jandegr]
+* Android: remove unused classfiles. [jandegr]
+* Refactor:gui\_internal:Determine menu widget size based on parent size. [mvglasow]
+* Importing 241569203/pl from launchpad. [Pierre GRANDIN]
+* No-HOV. [jandegr]
+* No-HOV. [jandegr]
+* Refactor:core:Document navit\_get\_cursor\_pnt() [mvglasow]
+* Refactor:gui\_internal:Document gui\_internal\_menu.c. [mvglasow]
+* Refactor:core:Add Doxygen docs, #define IMAGE\_W\_H\_UNSET for image dimensions. [Sebastian Leske]
+* Refactor:core:Update Doxyfile to Doxygen 1.8.9.1. [Sebastian Leske]
+* Refactor:core:Fix Doxygen comments; @code only for code blocks. [Sebastian Leske]
+* Refactor:osd:Document osd\_set\_std\_graphic. [mvglasow]
+* Refactor:osd:Minor documentation improvements. [mvglasow]
+* Refactor:core:Document window.h. [mvglasow]
+* Refactor:core:Fix GCC warning about uninitialized data.dangerous\_goods. [Sebastian Leske]
+* Refactor:core:Remove out-ifdefed code. [Sebastian Leske]
+* Archive the xpms from the linux build on CI. [Pierre Grandin]
+* Archive the xpms from the linux build on CI. [Pierre Grandin]
+* Applying patch from trac-832. [Pierre GRANDIN]
+* Refactor:osd\_core:Document osd\_button\_adjust\_sizes() [mvglasow]
+* Trac-1064 render OSM shop=mall as poi\_mall. [Pierre GRANDIN]
+* Bumping the trunk to 0.5.1. [Pierre GRANDIN]
+
+## [v0.5.0] - 2015-12-31
+
+This release was done before the adoption of this changelog format. Click
+[here](https://github.com/navit-gps/navit/compare/v0.5.0-rc.2...v0.5.0)
+to view the corresponding changes.
+
+## [v0.5.0-rc2] - 2015-09-02
+
+This release was done before the adoption of this changelog format. Click
+[here](https://github.com/navit-gps/navit/compare/v0.5.0-rc.1...v0.5.0-rc.2)
+to view the corresponding changes.
+
+## [v0.5.0-rc1] - 2015-08-08
+
+This release was done before the adoption of this changelog format. Click
+[here](https://github.com/navit-gps/navit/compare/v0.5.0-beta.1...v0.5.0-rc.1)
+to view the corresponding changes.
+
+[Unreleased]: https://github.com/navit-gps/navit/compare/v0.5.3...HEAD
+[v0.5.3]: https://github.com/navit-gps/navit/compare/v0.5.2...v0.5.3
+[v0.5.2]: https://github.com/navit-gps/navit/compare/v0.5.1...v0.5.2
+[v0.5.1]: https://github.com/navit-gps/navit/compare/v0.5.0...v0.5.1
+[v0.5.0]: https://github.com/navit-gps/navit/compare/v0.5.0-rc.2...v0.5.0
+[v0.5.0-rc.2]: https://github.com/navit-gps/navit/compare/v0.5.0-rc.1...v0.5.0-rc.2
+[v0.5.0-rc.1]: https://github.com/navit-gps/navit/compare/v0.5.0-beta.1...v0.5.0-rc.1
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b48d2935f..644f43e18 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,5 @@
+cmake_minimum_required(VERSION 3.2)
+
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.navitproject.navit")
set(MACOSX_BUNDLE_BUNDLE_NAME "Navit")
message(STATUS "Building with CMake V${CMAKE_VERSION}")
@@ -5,16 +7,15 @@ project(navit C)
# Workaround for CMake issue 8345 / 9220, see http://trac.navit-project.org/ticket/1041
if(DEFINED CMAKE_CXX_COMPILER AND CMAKE_CXX_COMPILER MATCHES "^$")
- set(CMAKE_CXX_COMPILER CMAKE_CXX_COMPILER-NOTFOUND)
+ set(CMAKE_CXX_COMPILER CMAKE_CXX_COMPILER-NOTFOUND)
endif(DEFINED CMAKE_CXX_COMPILER AND CMAKE_CXX_COMPILER MATCHES "^$")
if (NOT DISABLE_CXX)
- enable_language(CXX OPTIONAL)
+ enable_language(CXX OPTIONAL)
endif(NOT DISABLE_CXX)
-cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
set(NAVIT_VERSION_MAJOR "0")
set(NAVIT_VERSION_MINOR "5")
-set(NAVIT_VERSION_PATCH "1")
+set(NAVIT_VERSION_PATCH "3")
set(PACKAGE_VERSION "${NAVIT_VERSION_MAJOR}.${NAVIT_VERSION_MINOR}.${NAVIT_VERSION_PATCH}")
set(PACKAGE_NAME "navit-git")
@@ -25,7 +26,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
include("${PROJECT_SOURCE_DIR}/cmake/navit_macros.cmake")
IF(NOT CMAKE_BUILD_TYPE)
- SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
+ SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
# binary name
@@ -43,26 +44,26 @@ set(MAN_DIR share/man/man1 CACHE PATH "Navit man path")
add_definitions ("-DMAN_DIR=\"${MAN_DIR}\"")
# LIB_DIR
IF(UNIX AND NOT ANDROID AND NOT APPLE)
- IF (NOT LIBDIR)
- MESSAGE(STATUS "LIBDIR variable is not defined. It will be autodetected now.")
- MESSAGE(STATUS "You can set it manually with -DLIBDIR=<value>")
- # check 64 bit
- IF (CMAKE_SIZEOF_VOID_P EQUAL 4)
- SET(LIB_DIR lib/navit CACHE PATH "Navit 32bit bin path")
- MESSAGE(STATUS " LIB_DIR (highest subdirectory if LIBDIR) is set to '${LIB_DIR}'")
- ELSE (CMAKE_SIZEOF_VOID_P EQUAL 4)
- SET(LIB_DIR lib64/navit CACHE PATH "Navit 64bit bin path")
- MESSAGE(STATUS " LIB_DIR (highest subdirectory if LIBDIR) is set to '${LIB_DIR}'")
- ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
- ELSE (NOT LIBDIR)
- GET_FILENAME_COMPONENT (LIB_DIR ${LIBDIR} NAME)
- MESSAGE(STATUS " LIB_DIR (highest subdirectory if LIBDIR) is set to '${LIB_DIR}'")
- ENDIF (NOT LIBDIR)
+ IF (NOT LIBDIR)
+ MESSAGE(STATUS "LIBDIR variable is not defined. It will be autodetected now.")
+ MESSAGE(STATUS "You can set it manually with -DLIBDIR=<value>")
+ # check 64 bit
+ IF (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ SET(LIB_DIR lib/${PACKAGE} CACHE PATH "Navit 32bit bin path")
+ MESSAGE(STATUS " LIB_DIR (highest subdirectory if LIBDIR) is set to '${LIB_DIR}'")
+ ELSE (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ SET(LIB_DIR lib64/${PACKAGE} CACHE PATH "Navit 64bit bin path")
+ MESSAGE(STATUS " LIB_DIR (highest subdirectory if LIBDIR) is set to '${LIB_DIR}'")
+ ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ ELSE (NOT LIBDIR)
+ SET (LIB_DIR ${LIBDIR}/${PACKAGE} CACHE PATH "Navit lib path")
+ MESSAGE(STATUS " LIB_DIR is set to '${LIB_DIR}' because LIBDIR is set to ${LIBDIR}")
+ ENDIF (NOT LIBDIR)
ELSE (UNIX AND NOT ANDROID AND NOT APPLE)
SET(LIB_DIR lib/navit CACHE PATH "Navit unix bin path")
ENDIF (UNIX AND NOT ANDROID AND NOT APPLE)
foreach(EXTRA_MODULE ${EXTRA_MODULES})
- add_module(${EXTRA_MODULE} "extra module specified" TRUE)
+ add_module(${EXTRA_MODULE} "extra module specified" TRUE)
endforeach()
add_definitions ("-DLIB_DIR=\"${LIB_DIR}\"")
@@ -71,11 +72,11 @@ if (EXTRA_LIBS)
endif(EXTRA_LIBS)
if (EXTRA_INCLUDES)
- include_directories(${EXTRA_INCLUDES})
+ include_directories(${EXTRA_INCLUDES})
endif(EXTRA_INCLUDES)
if (EXTRA_LIBDIR)
- link_directories(${EXTRA_LIBDIR})
+ link_directories(${EXTRA_LIBDIR})
endif(EXTRA_LIBDIR)
### Detect environment
@@ -132,17 +133,17 @@ set(CPACK_PACKAGE_EXECUTABLES "navit;Navit")
set(CPACK_NSIS_HELP_LINK "http://www.navit-project.org/?page=contact")
set(CPACK_NSIS_URL_INFO_ABOUT "http://www.navit-project.org")
if(WIN32)
- add_feature(USE_NSIS "makensis not found" FALSE)
- FIND_PROGRAM(NSIS_EXECUTABLE NAMES makensis makensis.exe)
- if(NSIS_EXECUTABLE)
- set_with_reason(USE_NSIS "makensis found" TRUE)
- endif(NSIS_EXECUTABLE)
-
- set(CPACK_GENERATOR ZIP)
- if(USE_NSIS)
- list(APPEND CPACK_GENERATOR NSIS)
- endif(USE_NSIS)
- set(CPACK_PACKAGE_INSTALL_DIRECTORY Navit)
+ add_feature(USE_NSIS "makensis not found" FALSE)
+ FIND_PROGRAM(NSIS_EXECUTABLE NAMES makensis makensis.exe)
+ if(NSIS_EXECUTABLE)
+ set_with_reason(USE_NSIS "makensis found" TRUE)
+ endif(NSIS_EXECUTABLE)
+
+ set(CPACK_GENERATOR ZIP)
+ if(USE_NSIS)
+ list(APPEND CPACK_GENERATOR NSIS)
+ endif(USE_NSIS)
+ set(CPACK_PACKAGE_INSTALL_DIRECTORY Navit)
endif(WIN32)
INCLUDE (CPack)
@@ -150,69 +151,99 @@ INCLUDE (CheckIncludeFiles)
INCLUDE (CheckLibraryExists)
INCLUDE (CheckFunctionExists)
INCLUDE (CheckSymbolExists)
-find_package(Glib)
-find_package(Gmodule)
+
+################################
+# pkg-config based detection #
+################################
+
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules ( GMODULE gmodule-2.0 )
+ if (GMODULE_FOUND)
+ set(HAVE_GMODULE 1)
+ include_directories(${GMODULE_INCLUDE_DIRS})
+ list(APPEND NAVIT_LIBS ${GMODULE_LIBRARIES})
+ endif(GMODULE_FOUND)
+
+ pkg_check_modules (GLIB2 glib-2.0>=2.10)
+ if (GLIB2_FOUND)
+ set(HAVE_GLIB 1)
+ include_directories(${GLIB2_INCLUDE_DIRS})
+ list(APPEND NAVIT_LIBS ${GLIB2_LIBRARIES})
+ else(GLIB2_FOUND)
+ set_with_reason(support/glib "Glib not found" TRUE ${INTL_LIBS})
+ endif(GLIB2_FOUND)
+
+ pkg_check_modules(FONTCONFIG "fontconfig >= 2.2.0")
+ pkg_check_modules(DBUS "dbus-1 >= 1.4")
+ pkg_check_modules(DBUSGLIB dbus-glib-1)
+ if(DBUSGLIB_FOUND)
+ include_directories(${DBUSGLIB_INCLUDE_DIRS})
+ set_with_reason(binding/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES})
+ set_with_reason(speech/dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES})
+ set_with_reason(vehicle/gpsd_dbus "dbus-glib-1 found" TRUE ${DBUSGLIB_LIBRARIES})
+ endif()
+
+ pkg_check_modules(LIBLOCATION liblocation)
+ pkg_check_modules(LIBOSSO libosso)
+ # Accept even old versions of libgps, because N810 uses an old version (see #1179).
+ pkg_check_modules(LIBGPS libgps)
+ pkg_check_modules(LIBGPS19 libgps>=2.90)
+ # libgpsd<V3.1 is buggy if LC_ALL is set.
+ pkg_check_modules(LIBGPS_NEW libgps>=3.1)
+ pkg_check_modules(LIBGARMIN libgarmin)
+ pkg_check_modules(IMLIB2 imlib2)
+ if(IMLIB2_FOUND)
+ set(HAVE_IMLIB2 1)
+ endif(IMLIB2_FOUND)
+endif(PKG_CONFIG_FOUND)
+
+#find_package(Iconv)
+#find_package(Gmodule)
find_package(ZLIB)
find_package(Freetype)
-find_library(SDL2MAIN SDL2)
-find_library(SDL2IMAGE SDL2_image)
-find_library(GLES2 GLESv2)
+#find_library(SDL2MAIN SDL2)
+#find_library(SDL2IMAGE SDL2_image)
find_package(SDL)
-find_package(SDL_ttf)
+#find_package(SDL_ttf)
find_package(SDL_image)
+
+find_library(GLES2 GLESv2)
find_package(OpenGL)
find_package(GLUT)
find_package(GTK2 2.6 COMPONENTS gtk)
find_package(Gettext)
find_package(PNG)
-find_package(DBusGLib)
find_package(PythonLibs)
find_package(Threads)
find_package(ALSA)
find_package(libspotify)
-libfind_pkg_check_modules(FONTCONFIG fontconfig)
#Qt detection
if (NOT DISABLE_QT)
- find_package(Qt5Widgets)
- find_package(Qt5Quick)
- find_package(Qt5Positioning)
- if (Qt5Widgets_FOUND OR Qt5Quick_FOUND OR Qt5Sensors_FOUND)
- add_feature (USE_QWIDGET "Qt5 Qt5Widget not found" FALSE)
- add_feature (USE_QML "Qt5 Qt5Quick not found" FALSE)
- if (Qt5Widgets_FOUND OR Qt5Quick_FOUND)
- find_package(Qt5Svg REQUIRED)
- find_package(Qt5DBus REQUIRED)
- find_package(Qt5Multimedia)
- find_package(espeak)
- endif (Qt5Widgets_FOUND OR Qt5Quick_FOUND)
- if (Qt5Positioning_FOUND)
- find_package(Qt5Sensors REQUIRED)
- endif (Qt5Positioning_FOUND)
- else (Qt5Widgets_FOUND OR Qt5Quick_FOUND OR Qt5Sensors_FOUND)
- # Unfortunately, CMake seems to ignore the "OPTIONAL_COMPONENTS" flag,
- # and actually requires all components to be installed. Maybe this can
- # be fixed later...
- find_package(Qt4 4.7 COMPONENTS QtCore OPTIONAL_COMPONENTS QtGui QtXml QtDeclarative QtSvg)
- endif (Qt5Widgets_FOUND OR Qt5Quick_FOUND OR Qt5Sensors_FOUND)
+ find_package(Qt5Widgets)
+ find_package(Qt5Quick)
+ find_package(Qt5Positioning)
+ if (Qt5Widgets_FOUND OR Qt5Quick_FOUND OR Qt5Sensors_FOUND)
+ add_feature (USE_QWIDGET "Qt5 Qt5Widget not found" FALSE)
+ add_feature (USE_QML "Qt5 Qt5Quick not found" FALSE)
+ if (Qt5Widgets_FOUND OR Qt5Quick_FOUND)
+ find_package(Qt5Svg REQUIRED)
+ find_package(Qt5DBus REQUIRED)
+ find_package(Qt5Multimedia)
+ find_package(espeak)
+ endif (Qt5Widgets_FOUND OR Qt5Quick_FOUND)
+ if (Qt5Positioning_FOUND)
+ find_package(Qt5Sensors REQUIRED)
+ endif (Qt5Positioning_FOUND)
+ else (Qt5Widgets_FOUND OR Qt5Quick_FOUND OR Qt5Sensors_FOUND)
+ # Unfortunately, CMake seems to ignore the "OPTIONAL_COMPONENTS" flag,
+ # and actually requires all components to be installed. Maybe this can
+ # be fixed later...
+ find_package(Qt4 4.7 COMPONENTS QtCore OPTIONAL_COMPONENTS QtGui QtXml QtDeclarative QtSvg)
+ endif (Qt5Widgets_FOUND OR Qt5Quick_FOUND OR Qt5Sensors_FOUND)
endif (NOT DISABLE_QT)
-#pkg-config based detection
-find_package(PkgConfig)
-if(PKG_CONFIG_FOUND)
- pkg_check_modules(LIBLOCATION liblocation)
- pkg_check_modules(LIBOSSO libosso)
- # Accept even old versions of libgps, because N810 uses an old version (see #1179).
- pkg_check_modules(LIBGPS libgps)
- pkg_check_modules(LIBGPS19 libgps>=2.90)
- # libgpsd<V3.1 is buggy if LC_ALL is set.
- pkg_check_modules(LIBGPS_NEW libgps>=3.1)
- pkg_check_modules(LIBGARMIN libgarmin)
- pkg_check_modules(IMLIB2 imlib2)
- if(IMLIB2_FOUND)
- set(HAVE_IMLIB2 1)
- endif(IMLIB2_FOUND)
-endif(PKG_CONFIG_FOUND)
#Simple checks
CHECK_INCLUDE_FILES(wordexp.h HAVE_WORDEXP)
CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
@@ -224,10 +255,10 @@ CHECK_INCLUDE_FILES(sys/socket.h HAVE_SOCKET)
CHECK_INCLUDE_FILES(sys/shm.h HAVE_SHMEM)
CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
if (NOT HAVE_SNPRINTF)
- CHECK_FUNCTION_EXISTS(_snprintf HAVE_DECL__SNPRINTF)
- if (HAVE_DECL__SNPRINTF)
- set(HAVE_SNPRINTF 1)
- endif(HAVE_DECL__SNPRINTF)
+ CHECK_FUNCTION_EXISTS(_snprintf HAVE_DECL__SNPRINTF)
+ if (HAVE_DECL__SNPRINTF)
+ set(HAVE_SNPRINTF 1)
+ endif(HAVE_DECL__SNPRINTF)
endif(NOT HAVE_SNPRINTF)
CHECK_INCLUDE_FILES(locale.h HAVE_LC_MESSAGES)
CHECK_INCLUDE_FILES(libintl.h HAVE_LIBINTL)
@@ -247,237 +278,220 @@ CHECK_FUNCTION_EXISTS(fsync HAVE_FSYNC)
### Configure build
#Required libraries, supplied with navit
if (NOT HAVE_LIBINTL)
- set_with_reason(support/gettext_intl "native libintl missing" TRUE)
- set(USE_LIBGNUINTL TRUE)
+ set_with_reason(support/gettext_intl "native libintl missing" TRUE)
+ set(USE_LIBGNUINTL TRUE)
else()
- CHECK_LIBRARY_EXISTS(intl libintl_fprintf "" NEEDS_LIBINTL)
- if (NEEDS_LIBINTL)
- list(APPEND NAVIT_LIBS intl)
- set(INTL_LIBS intl)
- endif(NEEDS_LIBINTL)
+ CHECK_LIBRARY_EXISTS(intl libintl_fprintf "" NEEDS_LIBINTL)
+ if (NEEDS_LIBINTL)
+ list(APPEND NAVIT_LIBS intl)
+ set(INTL_LIBS intl)
+ endif(NEEDS_LIBINTL)
endif(NOT HAVE_LIBINTL)
if (CMAKE_USE_PTHREADS_INIT)
- if (NOT ANDROID)
- list(APPEND NAVIT_LIBS pthread)
- endif(NOT ANDROID)
+ if (NOT ANDROID)
+ list(APPEND NAVIT_LIBS pthread)
+ endif(NOT ANDROID)
endif(CMAKE_USE_PTHREADS_INIT)
-if (Glib_FOUND)
- set(HAVE_GLIB 1)
- include_directories(${Glib_INCLUDE_DIRS})
- list(APPEND NAVIT_LIBS ${Glib_LIBRARIES})
-else(Glib_FOUND)
- set_with_reason(support/glib "Glib not found" TRUE ${INTL_LIBS})
-endif(Glib_FOUND)
-if (Gmodule_FOUND)
- set(HAVE_GMODULE 1)
- include_directories(${Gmodule_INCLUDE_DIRS})
- list(APPEND NAVIT_LIBS ${Gmodule_LIBRARIES})
-endif(Gmodule_FOUND)
+
if(ZLIB_FOUND)
- set(HAVE_ZLIB 1)
- include_directories(${ZLIB_INCLUDE_DIRS})
- list(APPEND NAVIT_LIBS ${ZLIB_LIBRARIES})
+ set(HAVE_ZLIB 1)
+ include_directories(${ZLIB_INCLUDE_DIRS})
+ list(APPEND NAVIT_LIBS ${ZLIB_LIBRARIES})
else(ZLIB_FOUND)
- message(STATUS "using internal zlib")
- set_with_reason(support/zlib "native zlib missing" TRUE)
+ message(STATUS "using internal zlib")
+ set_with_reason(support/zlib "native zlib missing" TRUE)
endif(ZLIB_FOUND)
if(PNG_FOUND)
- set(HAVE_PNG 1)
- include_directories(${PNG_INCLUDE_DIR})
- list(APPEND NAVIT_LIBS ${PNG_LIBRARIES})
+ set(HAVE_PNG 1)
+ include_directories(${PNG_INCLUDE_DIR})
+ list(APPEND NAVIT_LIBS ${PNG_LIBRARIES})
else(PNG_FOUND)
- message(STATUS "using internal libpng")
- set_with_reason(support/libpng "native libpng missing" TRUE)
+ message(STATUS "using internal libpng")
+ set_with_reason(support/libpng "native libpng missing" TRUE)
endif(PNG_FOUND)
if (NOT HAVE_WORDEXP)
- message(STATUS "wordexp.h not found. use internal wordexp")
- set_with_reason(support/wordexp "native wordexp missing" TRUE)
+ message(STATUS "wordexp.h not found. use internal wordexp")
+ set_with_reason(support/wordexp "native wordexp missing" TRUE)
endif()
-if (NOT Glib_FOUND)
- set_with_reason(support/ezxml "Glib not found" TRUE)
+if (NOT GLIB2_FOUND)
+ set_with_reason(support/ezxml "Glib not found" TRUE)
endif()
if(FREETYPE_FOUND)
- pkg_check_modules(FRIBIDI fribidi)
- pkg_check_modules(FRIBIDI2 fribidi>=0.19.0)
- include_directories(${FREETYPE_INCLUDE_DIRS})
- set_with_reason(font/freetype "freetype found" TRUE "${FREETYPE_LIBRARY};${FONTCONFIG_LDFLAGS};${FRIBIDI_LIBRARIES}")
+ pkg_check_modules(FRIBIDI fribidi)
+ pkg_check_modules(FRIBIDI2 fribidi>=0.19.0)
+ include_directories(${FREETYPE_INCLUDE_DIRS})
+ set_with_reason(font/freetype "freetype found" TRUE "${FREETYPE_LIBRARY};${FONTCONFIG_LDFLAGS};${FRIBIDI_LIBRARIES}")
else(FREETYPE_FOUND)
- MESSAGE("No freetype library found, graphics modules may not be available")
- set_with_reason(graphics/android "FreeType library not found" FALSE)
- set_with_reason(graphics/gd "FreeType library not found" FALSE)
- set_with_reason(graphics/gtk_drawing_area "FreeType library not found" FALSE)
- set_with_reason(graphics/opengl "FreeType library not found" FALSE)
- set_with_reason(graphics/sdl "FreeType library not found" FALSE)
- set_with_reason(graphics/egl "FreeType library not found" FALSE)
+ MESSAGE("No freetype library found, graphics modules may not be available")
+ set_with_reason(graphics/android "FreeType library not found" FALSE)
+ set_with_reason(graphics/gd "FreeType library not found" FALSE)
+ set_with_reason(graphics/gtk_drawing_area "FreeType library not found" FALSE)
+ set_with_reason(graphics/opengl "FreeType library not found" FALSE)
+ set_with_reason(graphics/sdl "FreeType library not found" FALSE)
+ set_with_reason(graphics/egl "FreeType library not found" FALSE)
endif(FREETYPE_FOUND)
if(FONTCONFIG_FOUND)
- set(HAVE_FONTCONFIG 1)
+ set(HAVE_FONTCONFIG 1)
endif(FONTCONFIG_FOUND)
if (QT_FOUND)
- if (QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND FREETYPE_FOUND)
- include(${QT_USE_FILE})
- set_with_reason(graphics/qt_qpainter "Qt libraries found" TRUE ${QT_LIBRARIES})
-
- if (QT_QTDECLARATIVE_FOUND AND QT_QTXML_FOUND)
- set_with_reason(gui/qml "Qt Declarative found" TRUE ${QT_LIBRARIES})
- endif()
-
- if (QT_QTSVG_FOUND)
- set(HAVE_QT_SVG 1)
- elseif( USE_SVG AND graphics/qt_qpainter)
- message( WARNING "QT compiled without SVG support")
- endif()
- endif()
+ if (QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND FREETYPE_FOUND)
+ include(${QT_USE_FILE})
+ set_with_reason(graphics/qt_qpainter "Qt libraries found" TRUE ${QT_LIBRARIES})
+
+ if (QT_QTDECLARATIVE_FOUND AND QT_QTXML_FOUND)
+ set_with_reason(gui/qml "Qt Declarative found" TRUE ${QT_LIBRARIES})
+ endif()
+
+ if (QT_QTSVG_FOUND)
+ set(HAVE_QT_SVG 1)
+ elseif( USE_SVG AND graphics/qt_qpainter)
+ message( WARNING "QT compiled without SVG support")
+ endif()
+ endif()
endif(QT_FOUND)
if (Qt5Widgets_FOUND OR Qt5Quick_FOUND)
- set(Qt5_ADDITIONAL_LIBRARIES "")
- if(Qt5Widgets_FOUND)
- set_with_reason(USE_QWIDGET "Qt5Widgets found" TRUE)
- if(USE_QWIDGET)
- set(Qt5_ADDITIONAL_LIBRARIES ${Qt5_ADDITIONAL_LIBRARIES} ${Qt5Widgets_LIBRARIES})
- endif()
- endif()
- if(Qt5Quick_FOUND)
- set_with_reason(USE_QML "Qt5Quick found" TRUE)
- if(USE_QML)
- set(Qt5_ADDITIONAL_LIBRARIES ${Qt5_ADDITIONAL_LIBRARIES} ${Qt5Quick_LIBRARIES})
- endif()
- set_with_reason(gui/qt5_qml "Qt5 found" TRUE
- ${Qt5Quick_LIBRARIES})
-
- endif()
- set_with_reason(graphics/qt5 "Qt5 found" TRUE
+ set(Qt5_ADDITIONAL_LIBRARIES "")
+ if(Qt5Widgets_FOUND)
+ set_with_reason(USE_QWIDGET "Qt5Widgets found" TRUE)
+ if(USE_QWIDGET)
+ set(Qt5_ADDITIONAL_LIBRARIES ${Qt5_ADDITIONAL_LIBRARIES} ${Qt5Widgets_LIBRARIES})
+ endif()
+ endif()
+ if(Qt5Quick_FOUND)
+ set_with_reason(USE_QML "Qt5Quick found" TRUE)
+ if(USE_QML)
+ set(Qt5_ADDITIONAL_LIBRARIES ${Qt5_ADDITIONAL_LIBRARIES} ${Qt5Quick_LIBRARIES})
+ endif()
+ set_with_reason(gui/qt5_qml "Qt5 found" TRUE
+ ${Qt5Quick_LIBRARIES})
+
+ endif()
+ set_with_reason(graphics/qt5 "Qt5 found" TRUE
${Qt5_ADDITIONAL_LIBRARIES}
${Qt5Svg_LIBRARIES}
${Qt5DBus_LIBRARIES})
- if (Qt5Multimedia_FOUND)
- if (espeak_FOUND)
- set_with_reason(support/espeak "native espeak found" FALSE)
- set_with_reason(speech/qt5_espeak "Qt5Multimedia and libespeak found" TRUE
- ${Qt5Multimedia_LIBRARIES}
- ${espeak_LIBRARIES})
- else()
- set_with_reason(support/espeak "native espeak missing" TRUE)
- set_with_reason(INTERNAL_ESPEAK_COMPLETE "speech_qt5_espeak requires full libespeak" TRUE)
- set_with_reason(speech/qt5_espeak "Qt5Multimedia found" TRUE
- ${Qt5Multimedia_LIBRARIES})
- endif()
- endif()
+ if (Qt5Multimedia_FOUND)
+ if (espeak_FOUND)
+ set_with_reason(support/espeak "native espeak found" FALSE)
+ set_with_reason(speech/qt5_espeak "Qt5Multimedia and libespeak found" TRUE
+ ${Qt5Multimedia_LIBRARIES}
+ ${espeak_LIBRARIES})
+ else()
+ set_with_reason(support/espeak "native espeak missing" TRUE)
+ set_with_reason(INTERNAL_ESPEAK_COMPLETE "speech_qt5_espeak requires full libespeak" TRUE)
+ set_with_reason(speech/qt5_espeak "Qt5Multimedia found" TRUE
+ ${Qt5Multimedia_LIBRARIES})
+ endif()
+ endif()
endif ()
if (Qt5Positioning_FOUND)
- set_with_reason(vehicle/qt5 "Qt5 Positioning found" TRUE
+ set_with_reason(vehicle/qt5 "Qt5 Positioning found" TRUE
${Qt5Positioning_LIBRARIES}
- ${Qt5Sensors_LIBRARIES})
+ ${Qt5Sensors_LIBRARIES})
endif ()
if(GTK2_FOUND)
- # Include gtk.h with "SYSTEM" to avoid GCC compiler warning for gtkitemfactory.h.
- include_directories(SYSTEM ${GTK2_GTK_INCLUDE_DIR})
- include_directories(${GTK2_INCLUDE_DIRS})
- set(HAVE_GTK2 1)
- set_with_reason(gui/gtk "GTK libs found" TRUE ${GTK2_LIBRARIES})
- if(FREETYPE_FOUND)
- set_with_reason(graphics/gtk_drawing_area "GTK libs found" TRUE ${GTK2_LIBRARIES})
- endif(FREETYPE_FOUND)
+ # Include gtk.h with "SYSTEM" to avoid GCC compiler warning for gtkitemfactory.h.
+ include_directories(SYSTEM ${GTK2_GTK_INCLUDE_DIR})
+ include_directories(${GTK2_INCLUDE_DIRS})
+ set(HAVE_GTK2 1)
+ set_with_reason(gui/gtk "GTK libs found" TRUE ${GTK2_LIBRARIES})
+ if(FREETYPE_FOUND)
+ set_with_reason(graphics/gtk_drawing_area "GTK libs found" TRUE ${GTK2_LIBRARIES})
+ endif(FREETYPE_FOUND)
endif(GTK2_FOUND)
CHECK_LIBRARY_EXISTS(freeimage FreeImage_Load "" HAVE_FREEIMAGE)
if (USE_OPENGLES OR USE_OPENGLES2)
- CHECK_LIBRARY_EXISTS(EGL eglInitialize "" HAVE_EGL)
+ CHECK_LIBRARY_EXISTS(EGL eglInitialize "" HAVE_EGL)
endif(USE_OPENGLES OR USE_OPENGLES2)
if (FREETYPE_FOUND)
- if (OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND AND OPENGL_INCLUDE_DIR)
- message (STATUS "opengl found: ${OPENGL_gl_LIBRARY}")
- include_directories(${OPENGL_INCLUDE_DIR})
- if (USE_OPENGLES2)
- set(USE_OPENGLES TRUE)
- set(GRAPHICS_OPENGL_LIBRARY GLESv2 EGL)
- elseif (USE_OPENGLES)
- set(GRAPHICS_OPENGL_LIBRARY GLESv1_CM EGL)
- else()
- set(GRAPHICS_OPENGL_LIBRARY ${OPENGL_gl_LIBRARY};${OPENGL_glu_LIBRARY};${GLUT_glut_LIBRARY})
- endif(USE_OPENGLES2)
- if (HAVE_FREEIMAGE)
- list(APPEND GRAPHICS_OPENGL_LIBRARY freeimage)
- endif(HAVE_FREEIMAGE)
- set_with_reason(graphics/opengl "Found OpenGL" TRUE ${GRAPHICS_OPENGL_LIBRARY})
- else()
- message (STATUS "opengl not found")
- endif()
+ if (OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND AND OPENGL_INCLUDE_DIR)
+ message (STATUS "opengl found: ${OPENGL_gl_LIBRARY}")
+ include_directories(${OPENGL_INCLUDE_DIR})
+ if (USE_OPENGLES2)
+ set(USE_OPENGLES TRUE)
+ set(GRAPHICS_OPENGL_LIBRARY GLESv2 EGL)
+ elseif (USE_OPENGLES)
+ set(GRAPHICS_OPENGL_LIBRARY GLESv1_CM EGL)
+ else()
+ set(GRAPHICS_OPENGL_LIBRARY ${OPENGL_gl_LIBRARY};${OPENGL_glu_LIBRARY};${GLUT_glut_LIBRARY})
+ endif(USE_OPENGLES2)
+ if (HAVE_FREEIMAGE)
+ list(APPEND GRAPHICS_OPENGL_LIBRARY freeimage)
+ endif(HAVE_FREEIMAGE)
+ set_with_reason(graphics/opengl "Found OpenGL" TRUE ${GRAPHICS_OPENGL_LIBRARY})
+ else()
+ message (STATUS "opengl not found")
+ endif()
else()
- message (STATUS "no Freetype found")
+ message (STATUS "no Freetype found")
endif(FREETYPE_FOUND)
if(SDL_FOUND AND SDLIMAGE_FOUND AND FREETYPE_FOUND)
- set(SDL_IMAGE 1)
- if(SDLTTF_FOUND)
- set(SDL_TTF 1)
- list(APPEND SDL_LIBRARY ${SDLTTF_LIBRARY})
- else(SDLTTF_FOUND)
- list(APPEND SDL_LIBRARY ${FREETYPE_LIBRARY})
- endif(SDLTTF_FOUND)
- set_with_reason(graphics/sdl "SDL/SDL_image libs found" TRUE ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY})
+ include_directories( ${SDL_INCLUDE_DIR} ${SDL_IMAGE_INCLUDE_DIRS})
+ set(SDL_IMAGE 1)
+ if(SDLTTF_FOUND)
+ set(SDL_TTF 1)
+ list(APPEND SDL_LIBRARY ${SDLTTF_LIBRARY})
+ else(SDLTTF_FOUND)
+ list(APPEND SDL_LIBRARY ${FREETYPE_LIBRARY})
+ endif(SDLTTF_FOUND)
+ set_with_reason(graphics/sdl "SDL/SDL_image libs found" TRUE ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY})
endif(SDL_FOUND AND SDLIMAGE_FOUND AND FREETYPE_FOUND)
if(SDL2MAIN AND SDL2IMAGE AND GLES2)
- set_with_reason(graphics/egl "SDL2/SDL2_image libs found" TRUE ${SDL2MAIN} ${SDL2IMAGE} ${GLES2})
- message(STATUS "EGL libs found : ${SDL2MAIN} ${SDL2IMAGE} ${GLES2}")
+ set_with_reason(graphics/egl "SDL2/SDL2_image libs found" TRUE ${SDL2MAIN} ${SDL2IMAGE} ${GLES2})
+ message(STATUS "EGL libs found : ${SDL2MAIN} ${SDL2IMAGE} ${GLES2}")
endif(SDL2MAIN AND SDL2IMAGE AND GLES2)
if (LIBGPS_FOUND)
- if (LIBGPS_NEW_FOUND)
- set(VEHICLE_GPSD_REASON "gpsd lib found")
- else(LIBGPS_NEW_FOUND)
- set(VEHICLE_GPSD_REASON "WARNING: old gpsd lib found, buggy if LC_ALL is set")
- endif(LIBGPS_NEW_FOUND)
- set_with_reason(vehicle/gpsd ${VEHICLE_GPSD_REASON} TRUE ${LIBGPS_LDFLAGS})
+ if (LIBGPS_NEW_FOUND)
+ set(VEHICLE_GPSD_REASON "gpsd lib found")
+ else(LIBGPS_NEW_FOUND)
+ set(VEHICLE_GPSD_REASON "WARNING: old gpsd lib found, buggy if LC_ALL is set")
+ endif(LIBGPS_NEW_FOUND)
+ set_with_reason(vehicle/gpsd ${VEHICLE_GPSD_REASON} TRUE ${LIBGPS_LDFLAGS})
endif(LIBGPS_FOUND)
if (GYPSY_FOUND)
- set_with_reason(vehicle/gypsy "gypsy lib found" TRUE)
+ set_with_reason(vehicle/gypsy "gypsy lib found" TRUE)
endif(GYPSY_FOUND)
if (LIBGARMIN_FOUND)
- include_directories(${LIBGARMIN_INCLUDE_DIRS})
- set_with_reason(map/garmin "Garmin library found" TRUE ${LIBGARMIN_LDFLAGS})
+ include_directories(${LIBGARMIN_INCLUDE_DIRS})
+ set_with_reason(map/garmin "Garmin library found" TRUE ${LIBGARMIN_LDFLAGS})
endif(LIBGARMIN_FOUND)
-if(DBusGLib_FOUND)
- include_directories(${DBusGLib_INCLUDE_DIRS})
- set_with_reason(binding/dbus "dbus-glib-1 found" TRUE ${DBusGLib_LIBRARIES})
- set_with_reason(speech/dbus "dbus-glib-1 found" TRUE ${DBusGLib_LIBRARIES})
- set_with_reason(vehicle/gpsd_dbus "dbus-glib-1 found" TRUE ${DBusGLib_LIBRARIES})
-endif()
-
if(PYTHONLIBS_FOUND)
- set_with_reason(binding/python "python libraries [${PYTHONLIBS_VERSION_STRING}] found" TRUE ${PYTHON_LIBRARIES})
+ set_with_reason(binding/python "python libraries [${PYTHONLIBS_VERSION_STRING}] found" TRUE ${PYTHON_LIBRARIES})
endif()
if (HAVE_LIBSPEECHD)
- set_with_reason(speech/speech_dispatcher "speech_dispatcher lib found" TRUE speechd)
+ set_with_reason(speech/speech_dispatcher "speech_dispatcher lib found" TRUE speechd)
endif(HAVE_LIBSPEECHD)
if (HAVE_SYSTEM)
- set_with_reason(speech/cmdline "system() call is available" TRUE)
+ set_with_reason(speech/cmdline "system() call is available" TRUE)
endif(HAVE_SYSTEM)
if (HAVE_CREATEPROCESS)
- set_with_reason(speech/cmdline "CreateProcess() call is available" TRUE)
+ set_with_reason(speech/cmdline "CreateProcess() call is available" TRUE)
endif(HAVE_CREATEPROCESS)
if (LIBLOCATION_FOUND)
- set_with_reason(vehicle/maemo "Maemo location library found" TRUE ${LIBLOCATION_LIBRARIES})
+ set_with_reason(vehicle/maemo "Maemo location library found" TRUE ${LIBLOCATION_LIBRARIES})
endif(LIBLOCATION_FOUND)
if (LIBOSSO_FOUND)
- set_with_reason(autoload/osso "Maemo osso library found" TRUE ${LIBOSSO_LIBRARIES})
+ set_with_reason(autoload/osso "Maemo osso library found" TRUE ${LIBOSSO_LIBRARIES})
endif(LIBOSSO_FOUND)
if (GETTEXT_FOUND)
- set_with_reason(USE_NATIVE_LANGUAGE_SUPPORT "Gettext found" TRUE)
+ set_with_reason(USE_NATIVE_LANGUAGE_SUPPORT "Gettext found" TRUE)
endif(GETTEXT_FOUND)
#Independent modules
@@ -490,7 +504,7 @@ add_module(gui/internal "Default" TRUE)
add_module(map/binfile "Default" TRUE)
add_module(map/filter "Default" TRUE)
if(NOT MSVC)
-add_module(map/mg "Default" TRUE)
+ add_module(map/mg "Default" TRUE)
endif(NOT MSVC)
add_module_plugin(support/shapefile "Default" TRUE)
set(map_shapefile_INCLUDES "${CMAKE_SOURCE_DIR}/navit/support/shapefile")
@@ -506,6 +520,9 @@ add_module(plugin/j1850 "Default" FALSE)
add_module(speech/android "Default" FALSE)
add_module(speech/espeak "Default" FALSE)
add_module(speech/iphone "Default" FALSE)
+add_module(traffic/dummy "Default" TRUE)
+add_module(traffic/null "Default" TRUE)
+add_module(traffic/traff_android "Default" FALSE)
add_module(vehicle/android "Default" FALSE)
add_module(vehicle/iphone "Default" FALSE)
add_module(vehicle/wince "Default" FALSE)
@@ -518,6 +535,15 @@ add_feature(USE_SVG "default" TRUE)
add_feature(SVG2PNG "default" TRUE)
add_feature(SAMPLE_MAP "default" TRUE)
add_feature(NETWORK_INFO "default" FALSE)
+add_feature(GUI_INTERNAL_VISUAL_DBG "default" FALSE)
+
+if (GUI_INTERNAL_VISUAL_DBG)
+ list(FIND ALL_MODULES gui/internal GUI_INTERNAL_ENABLED)
+ if ( ${GUI_INTERNAL_ENABLED} LESS 0 )
+ message(WARNING "GUI_INTERNAL_VISUAL_DBG enabled but gui/internal module is not included in compilation")
+ endif()
+endif(GUI_INTERNAL_VISUAL_DBG)
+
add_feature(USE_AUDIO_FRAMEWORK "default" FALSE)
find_program(MPD NAMES mpd)
@@ -546,27 +572,26 @@ if (LIBSPOTIFY_FOUND)
endif (ALSA_FOUND)
endif(LIBSPOTIFY_FOUND)
-
IF(NOT svg2png_scaling)
- IF(NOT ANDROID)
- set(svg2png_scaling 0 16 32 48 64 96)
- ELSE()
- set(svg2png_scaling -1 24 32 48 64 96 128)
- ENDIF()
+ IF(NOT ANDROID)
+ set(svg2png_scaling 0 16 32 48 64 96)
+ ELSE()
+ set(svg2png_scaling -1 24 32 48 64 96 128)
+ ENDIF()
ENDIF()
IF(NOT svg2png_scaling_flag)
- IF(NOT ANDROID)
- set(svg2png_scaling_flag 32)
- ELSE()
- set(svg2png_scaling_flag -1 24 32 64 96)
- ENDIF()
+ IF(NOT ANDROID)
+ set(svg2png_scaling_flag 32)
+ ELSE()
+ set(svg2png_scaling_flag -1 24 32 64 96)
+ ENDIF()
ENDIF()
IF(NOT svg2png_scaling_nav)
- IF(NOT ANDROID)
- set(svg2png_scaling_nav 64)
- ELSE()
- set(svg2png_scaling_nav -1 24 32 48 64 96 128)
- ENDIF()
+ IF(NOT ANDROID)
+ set(svg2png_scaling_nav 64)
+ ELSE()
+ set(svg2png_scaling_nav -1 24 32 48 64 96 128)
+ ENDIF()
ENDIF()
add_feature(DBUS_USE_SYSTEM_BUS "default" FALSE)
@@ -576,224 +601,238 @@ add_feature(XSL_PROCESSING "default" TRUE)
set(SUPPORTED_XSLT_PROCESSORS "saxonb-xslt;saxon;saxon8;saxon-xslt;xsltproc;transform.exe")
find_program(XSLT_PROCESSOR NAMES ${SUPPORTED_XSLT_PROCESSORS})
if(XSLT_PROCESSOR)
- message(STATUS "Found XSLT processor: ${XSLT_PROCESSOR}")
- execute_process(COMMAND ${XSLT_PROCESSOR} -snone ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test.xml ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test.xslt
- RESULT_VARIABLE SAXON_ERROR OUTPUT_QUIET ERROR_QUIET)
- if (NOT SAXON_ERROR)
- set (XSLT_PROCESSOR_OPTIONS -snone)
- endif()
- # additional parameter is passed to the stylesheet processor as transformation parameter
- macro(compose_xslt_transform_command CMDVAR XSLT_FILE SRC_XML DEST_XML)
- if(${XSLT_PROCESSOR} MATCHES "xsltproc")
- set(${CMDVAR} COMMAND ${XSLT_PROCESSOR} ${XSLT_PROCESSOR_OPTIONS} ${XSLT_FILE} ${SRC_XML} >${DEST_XML})
- else()
- set(${CMDVAR} COMMAND ${XSLT_PROCESSOR} ${XSLT_PROCESSOR_OPTIONS} ${SRC_XML} ${XSLT_FILE} ${ARGN} >${DEST_XML})
- endif()
- endmacro()
+ message(STATUS "Found XSLT processor: ${XSLT_PROCESSOR}")
+ execute_process(COMMAND ${XSLT_PROCESSOR} -snone ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test.xml ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test.xslt
+ RESULT_VARIABLE SAXON_ERROR OUTPUT_QUIET ERROR_QUIET)
+ if (NOT SAXON_ERROR)
+ set (XSLT_PROCESSOR_OPTIONS -snone)
+ endif()
+ # additional parameter is passed to the stylesheet processor as transformation parameter
+ macro(compose_xslt_transform_command CMDVAR XSLT_FILE SRC_XML DEST_XML)
+ if(${XSLT_PROCESSOR} MATCHES "xsltproc")
+ set(${CMDVAR} COMMAND ${XSLT_PROCESSOR} ${XSLT_PROCESSOR_OPTIONS} ${XSLT_FILE} ${SRC_XML} >${DEST_XML})
+ else()
+ set(${CMDVAR} COMMAND ${XSLT_PROCESSOR} ${XSLT_PROCESSOR_OPTIONS} ${SRC_XML} ${XSLT_FILE} ${ARGN} >${DEST_XML})
+ endif()
+ endmacro()
else()
- cfg_feature(XSL_PROCESSING "Saxon missing" FALSE)
+ cfg_feature(XSL_PROCESSING "Saxon missing" FALSE)
endif(XSLT_PROCESSOR)
if (NOT XSL_PROCESSING)
- message(WARNING "No XSLT processor available. You have to configure "
-"navit.xml yourself, or install an XSLT processor (supported: "
-"${SUPPORTED_XSLT_PROCESSORS}).")
+ message(WARNING "No XSLT processor available. You have to configure "
+ "navit.xml yourself, or install an XSLT processor (supported: "
+ "${SUPPORTED_XSLT_PROCESSORS}).")
endif()
### Platform specific settings
if(NOT CACHE_SIZE)
- SET(CACHE_SIZE 1048576)
+ SET(CACHE_SIZE 1048576)
endif(NOT CACHE_SIZE)
if(WIN32 OR WINCE)
- SET(CMAKE_EXECUTABLE_SUFFIX ".exe")
- add_module(graphics/win32 "Windows detected" TRUE)
- add_plugin(support/win32 "Windows detected" TRUE)
-
- SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -I ${CMAKE_CURRENT_SOURCE_DIR}/navit/gui/win32/resources <DEFINES> -i <SOURCE> -o <OBJECT>")
- set_with_reason(support/ezxml "Windows detected" TRUE)
- set_with_reason(speech/espeak "Windows detected" TRUE)
- #speech/espeak does use windows threads, and therefore needs only parts of
- #espeak lib. INTERNAL_ESPEAK_COMPLETE controls this.
- set_with_reason(INTERNAL_ESPEAK_COMPLETE "Windows detected" FALSE)
- set_with_reason(support/espeak "Windows detected" TRUE)
- set_with_reason(binding/win32 "Windows detected" TRUE)
-
- # vehicle_file is broken for windows. use vehicle_wince instead
- # whicle_wince isn't buildable on non-CE windows ssytems
-
- # plugins currently not supported on windows
- set_with_reason(USE_PLUGINS "win32: currently not supported" FALSE)
-
- set(HAVE_API_WIN32_BASE 1)
- set(EZXML_NOMMAP 1)
-
- # Image stuff
- if(NOT graphics/qt_qpainter)
- set_with_reason(USE_SVG "win32: SVGs currently not supported" FALSE)
- else(NOT graphics/qt_qpainter)
- MESSAGE(STATUS "win32: SVGs may not be supported by every available graphics")
- endif(NOT graphics/qt_qpainter)
-
- set(BIN_DIR bin)
- set(SHARE_DIR ./)
- set(LOCALE_DIR locale)
- set(IMAGE_DIR icons)
-
-
- if(HAVE_GTK2 AND NOT MSVC)
- #GTK requires special compile flags
- add_definitions("-mms-bitfields")
- endif(HAVE_GTK2 AND NOT MSVC)
- if(MSVC AND support/espeak)
- add_definitions(-DPLATFORM_WINDOWS)
- endif(MSVC AND support/espeak)
- CHECK_LIBRARY_EXISTS(ws2_32 WSAStartup "" HAVE_WINSOCK)
- if(HAVE_WINSOCK)
- list(APPEND NAVIT_LIBS ws2_32)
- else()
- CHECK_LIBRARY_EXISTS(ws2 WSAStartup "" HAVE_WINSOCK_2)
- if(HAVE_WINSOCK_2)
- set(HAVE_WINSOCK 1)
- list(APPEND NAVIT_LIBS ws2)
- endif()
- endif(HAVE_WINSOCK)
-
- if(MSVC)
- set(HAVE_PRAGMA_PACK 1)
- add_plugin(support/xgetopt "Windows detected" TRUE)
- endif(MSVC)
- set_with_reason(USE_NATIVE_LANGUAGE_SUPPORT "Windows detected" TRUE)
- enable_language(RC)
-
- set(XSLTS "windows;${XSLTS}" CACHE STRING "define a semicolon seperated list of XSLTs to process")
+ SET(CMAKE_EXECUTABLE_SUFFIX ".exe") #remove it when wince'll use cmake 3
+ add_module(graphics/win32 "Windows detected" TRUE)
+ add_plugin(support/win32 "Windows detected" TRUE)
+
+ SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -I ${CMAKE_CURRENT_SOURCE_DIR}/navit/gui/win32/resources <DEFINES> -i <SOURCE> -o <OBJECT>")
+ set_with_reason(binding/win32 "Windows detected" TRUE)
+
+ # vehicle_file is broken for windows. use vehicle_wince instead
+ # whicle_wince isn't buildable on non-CE windows ssytems
+
+ # plugins currently not supported on windows
+ set_with_reason(USE_PLUGINS "win32: currently not supported" FALSE)
+
+ set(HAVE_API_WIN32_BASE 1)
+ set(EZXML_NOMMAP 1)
+
+ # Image stuff
+ if(NOT graphics/qt_qpainter)
+ set_with_reason(USE_SVG "win32: SVGs currently not supported" FALSE)
+ else(NOT graphics/qt_qpainter)
+ MESSAGE(STATUS "win32: SVGs may not be supported by every available graphics")
+ endif(NOT graphics/qt_qpainter)
+
+ set(BIN_DIR bin)
+ set(SHARE_DIR ./)
+ set(LOCALE_DIR locale)
+ set(IMAGE_DIR icons)
+
+
+ if(HAVE_GTK2 AND NOT MSVC)
+ #GTK requires special compile flags
+ add_definitions("-mms-bitfields")
+ endif(HAVE_GTK2 AND NOT MSVC)
+ if(MSVC AND support/espeak)
+ add_definitions(-DPLATFORM_WINDOWS)
+ endif(MSVC AND support/espeak)
+ CHECK_LIBRARY_EXISTS(ws2_32 WSAStartup "" HAVE_WINSOCK)
+ if(HAVE_WINSOCK)
+ list(APPEND NAVIT_LIBS ws2_32)
+ else()
+ CHECK_LIBRARY_EXISTS(ws2 WSAStartup "" HAVE_WINSOCK_2)
+ if(HAVE_WINSOCK_2)
+ set(HAVE_WINSOCK 1)
+ list(APPEND NAVIT_LIBS ws2)
+ endif()
+ endif(HAVE_WINSOCK)
+
+ if(MSVC)
+ set(HAVE_PRAGMA_PACK 1)
+ add_plugin(support/xgetopt "Windows detected" TRUE)
+ endif(MSVC)
+ set_with_reason(USE_NATIVE_LANGUAGE_SUPPORT "Windows detected" TRUE)
+ enable_language(RC)
+
+ set(XSLTS "windows;${XSLTS}" CACHE STRING "define a semicolon seperated list of XSLTs to process")
endif()
if (WIN32 AND NOT WINCE)
- set(HAVE_API_WIN32 1)
- set(HAVE_STDINT_H 1)
- list(APPEND NAVIT_LIBS winmm)
+ set(HAVE_API_WIN32 1)
+ set(HAVE_STDINT_H 1)
+ list(APPEND NAVIT_LIBS winmm)
+ set_with_reason(speech/cmdline "using native tts system of windows instead of espeak" TRUE)
endif()
if(WINCE)
- add_plugin(support/libc "wince detected" TRUE)
- set(HAVE_API_WIN32_CE 1)
- set(BUILD_MAPTOOL FALSE)
- # mingw32ce since gcc 4.7.0 needs HAVE_PRAGMA_PACK as __attribute__((packed)) is broken, see gcc bug 52991
- set(HAVE_PRAGMA_PACK 1)
- set_with_reason(vehicle/file "wince: currently broken" FALSE)
- set_with_reason(vehicle/wince "wince detected" TRUE)
+ add_plugin(support/libc "wince detected" TRUE)
+ set(HAVE_API_WIN32_CE 1)
+ set(BUILD_MAPTOOL FALSE)
+ # mingw32ce since gcc 4.7.0 needs HAVE_PRAGMA_PACK as __attribute__((packed)) is broken, see gcc bug 52991
+ set(HAVE_PRAGMA_PACK 1)
+ set_with_reason(vehicle/file "wince: currently broken" FALSE)
+ set_with_reason(vehicle/wince "wince detected" TRUE)
+ set_with_reason(support/ezxml "Windows detected" TRUE)
+ set_with_reason(speech/espeak "Windows detected" TRUE)
+ #speech/espeak does use windows threads, and therefore needs only parts of
+ #espeak lib. INTERNAL_ESPEAK_COMPLETE controls this.
+ set_with_reason(INTERNAL_ESPEAK_COMPLETE "Windows detected" FALSE)
+ set_with_reason(support/espeak "Windows detected" TRUE)
endif()
if (APPLE OR USE_UIKIT)
- set_with_reason(vehicle/iphone "apple detected" TRUE)
- set_with_reason(graphics/cocoa "apple detected" TRUE)
- if (EXISTS "${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks/VoiceServices.framework")
- set_with_reason(speech/iphone "apple detected" TRUE)
- endif()
- set(BUILD_BUNDLE TRUE CACHE BOOLEAN "build an osx bundle")
+ set_with_reason(vehicle/iphone "apple detected" TRUE)
+ set_with_reason(graphics/cocoa "apple detected" TRUE)
+ if (EXISTS "${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks/VoiceServices.framework")
+ set_with_reason(speech/iphone "apple detected" TRUE)
+ endif()
+ set(BUILD_BUNDLE TRUE CACHE BOOLEAN "build an osx bundle")
endif()
if(CMAKE_SIZEOF_VOID_P LESS 8)
- set_with_reason(BUILD_MAPTOOL "maptool works only on 64 bit architectures" FALSE)
+ set_with_reason(BUILD_MAPTOOL "maptool works only on 64 bit architectures" FALSE)
endif()
set(LOCALEDIR "${LOCALE_DIR}")
find_program(BZCAT NAMES bzcat)
if (SAMPLE_MAP)
- if(CMAKE_CROSSCOMPILING)
- cfg_feature(SAMPLE_MAP "downloading binary map because of cross compiling" TRUE)
- set(DOWNLOAD_SAMPLE_MAP TRUE)
- elseif(NOT BZCAT)
- cfg_feature(SAMPLE_MAP "downloading binary map because of missing bzcat" TRUE)
- set(DOWNLOAD_SAMPLE_MAP TRUE)
- elseif(NOT BUILD_MAPTOOL)
- cfg_feature(SAMPLE_MAP "downloading binary map because maptool compilation is disabled" TRUE)
- set(DOWNLOAD_SAMPLE_MAP TRUE)
- endif(CMAKE_CROSSCOMPILING)
+ if(CMAKE_CROSSCOMPILING)
+ cfg_feature(SAMPLE_MAP "downloading binary map because of cross compiling" TRUE)
+ set(DOWNLOAD_SAMPLE_MAP TRUE)
+ elseif(NOT BZCAT)
+ cfg_feature(SAMPLE_MAP "downloading binary map because of missing bzcat" TRUE)
+ set(DOWNLOAD_SAMPLE_MAP TRUE)
+ elseif(NOT BUILD_MAPTOOL)
+ cfg_feature(SAMPLE_MAP "downloading binary map because maptool compilation is disabled" TRUE)
+ set(DOWNLOAD_SAMPLE_MAP TRUE)
+ endif(CMAKE_CROSSCOMPILING)
endif(SAMPLE_MAP)
check_symbol_exists (getifaddrs "sys/types.h;ifaddrs.h" HAS_IFADDRS)
if (HAS_IFADDRS)
- cfg_feature(NETWORK_INFO "ifaddrs.h found" TRUE)
+ cfg_feature(NETWORK_INFO "ifaddrs.h found" TRUE)
endif(HAS_IFADDRS)
if(ANDROID)
- find_program(ANDROID_LOCATION NAMES android android.bat)
- find_program(ANT_LOCATION NAMES ant)
- if (NOT ANT_LOCATION)
- message_error("Could not find ant. Please install ant and add it to the search path.")
- else()
- execute_process(COMMAND ${ANT_LOCATION} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake RESULT_VARIABLE ANT_VERSION_OK OUTPUT_QUIET ERROR_QUIET)
- if(ANT_VERSION_OK GREATER 0)
- message(WARNING "Old ant version detected. If you need crash reporter, update to at least ant 1.8")
- endif()
- endif()
- if (NOT ANDROID_LOCATION)
- message_error( "Could not find 'Android SDK and AVD Manager'. Please install the android sdk and add the <android-sdk>/tools directory to the search path.")
- endif()
- set(XSLTS "android;${XSLTS}" CACHE STRING "define a semicolon seperated list of XSLTs to process")
- list(APPEND NAVIT_LIBS log)
- set(HAVE_API_ANDROID 1)
- set_with_reason(graphics/android "Android detected, NDK:${ANDROID_NDK_API_VERSION}, API:${ANDROID_API_VERSION}" TRUE)
- set_with_reason(speech/android "Android detected, NDK:${ANDROID_NDK_API_VERSION}, API:${ANDROID_API_VERSION}" TRUE)
- set_with_reason(vehicle/android "Android detected, NDK:${ANDROID_NDK_API_VERSION}, API:${ANDROID_API_VERSION}" TRUE)
- set(SHARED_LIBNAVIT TRUE)
-
- add_feature(XPM2PNG "Android detected" TRUE)
- set(NAVIT_COMPILE_FLAGS "${NAVIT_COMPILE_FLAGS} -fPIC")
+ message(STATUS "Using generator " ${CMAKE_GENERATOR})
+ if (NOT ${CMAKE_GENERATOR} STREQUAL Ninja)
+ find_program(ANDROID_LOCATION NAMES android android.bat)
+ find_program(ANT_LOCATION NAMES ant)
+ if (NOT ANT_LOCATION)
+ message_error("Could not find ant. Please install ant and add it to the search path.")
+ else()
+ execute_process(COMMAND ${ANT_LOCATION} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake RESULT_VARIABLE ANT_VERSION_OK OUTPUT_QUIET ERROR_QUIET)
+ if(ANT_VERSION_OK GREATER 0)
+ message(WARNING "Old ant version detected. If you need crash reporter, update to at least ant 1.8")
+ endif()
+ endif()
+ if (NOT ANDROID_LOCATION)
+ message_error( "Could not find 'Android SDK and AVD Manager'. Please install the android sdk and add the <android-sdk>/tools directory to the search path.")
+ endif()
+ set(XSLTS "android;${XSLTS}" CACHE STRING "define a semicolon seperated list of XSLTs to process")
+ endif (NOT ${CMAKE_GENERATOR} STREQUAL Ninja)
+ list(APPEND NAVIT_LIBS log)
+ set(HAVE_API_ANDROID 1)
+ set_with_reason(speech/cmdline "Android detected" FALSE)
+ set_with_reason(graphics/null "Android detected" FALSE)
+ set_with_reason(graphics/android "Android detected" TRUE)
+ set_with_reason(speech/android "Android detected" TRUE)
+ set_with_reason(traffic/traff_android "Android detected" TRUE)
+ set_with_reason(vehicle/android "Android detected" TRUE)
+ set_with_reason(vehicle/file "Android detected" FALSE)
+ set_with_reason(vehicle/gpsd "Android detected" FALSE)
+ set_with_reason(map/filter "Android detected" FALSE)
+ set_with_reason(map/garmin "Android detected" FALSE)
+ set_with_reason(USE_NATIVE_LANGUAGE_SUPPORT "Android detected" TRUE)
+ # set_with_reason(plugin/pedestrian "Android detected" TRUE)
+ set_with_reason(support/libpng "Android detected" FALSE)
+ set(SHARED_LIBNAVIT TRUE)
+
+ add_feature(XPM2PNG "Android detected" TRUE)
+ set(NAVIT_COMPILE_FLAGS "${NAVIT_COMPILE_FLAGS} -fPIC")
endif(ANDROID)
if(FREETYPE_FOUND AND NOT FONTCONFIG_FOUND)
- add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/navit/fonts")
+ add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/navit/fonts")
endif()
# Image conversion
find_program(IMAGE_CONVERTER NAMES convert)
execute_process(COMMAND ${IMAGE_CONVERTER} -list format OUTPUT_VARIABLE CONVERT_FORMATS)
if(CONVERT_FORMATS MATCHES ".*XPM[ *][ ]*XPM[ ]*r[w-].*")
- set(IMAGE_CONVERTER_XPM ${IMAGE_CONVERTER})
+ set(IMAGE_CONVERTER_XPM ${IMAGE_CONVERTER})
endif()
set(CMAKE_APPBUNDLE_PATH "")
if (SVG2PNG)
- if (NOT IMAGE_CONVERTER_SVGZ)
- set (SVG_CONVERTER_PROGS rsvg-convert ksvgtopng ksvgtopng4 inkscape)
- set (CMAKE_FIND_APPBUNDLE "NEVER")
- find_program(IMAGE_CONVERTER_SVGZ NAMES ${SVG_CONVERTER_PROGS} PATHS /Applications/Inkscape.app/Contents/Resources/bin)
- if (NOT IMAGE_CONVERTER_SVGZ)
- if(CONVERT_FORMATS MATCHES ".*[ ]*SVG[ ]*r[w-].*")
- set(IMAGE_CONVERTER_SVGZ ${IMAGE_CONVERTER})
- endif()
- endif()
- endif(NOT IMAGE_CONVERTER_SVGZ)
- if (NOT IMAGE_CONVERTER_SVG)
- set(IMAGE_CONVERTER_SVG ${IMAGE_CONVERTER_SVGZ})
- endif(NOT IMAGE_CONVERTER_SVG)
-
- message(STATUS "SVG2PNG-Converter: ${IMAGE_CONVERTER_SVGZ}")
- if (NOT IMAGE_CONVERTER_SVGZ)
- message(WARNING "No SVG2PNG converter found. Please install one of the following tools: ${SVG_CONVERTER_PROGS}, or imagemagick with svg support")
- set_with_reason(SVG2PNG "no converter found" FALSE)
- endif(NOT IMAGE_CONVERTER_SVGZ)
+ if (NOT IMAGE_CONVERTER_SVGZ)
+ set (SVG_CONVERTER_PROGS rsvg-convert ksvgtopng ksvgtopng4 inkscape)
+ set (CMAKE_FIND_APPBUNDLE "NEVER")
+ find_program(IMAGE_CONVERTER_SVGZ NAMES ${SVG_CONVERTER_PROGS} PATHS /Applications/Inkscape.app/Contents/Resources/bin)
+ if (NOT IMAGE_CONVERTER_SVGZ)
+ if(CONVERT_FORMATS MATCHES ".*[ ]*SVG[ ]*r[w-].*")
+ set(IMAGE_CONVERTER_SVGZ ${IMAGE_CONVERTER})
+ endif()
+ endif()
+ endif(NOT IMAGE_CONVERTER_SVGZ)
+ if (NOT IMAGE_CONVERTER_SVG)
+ set(IMAGE_CONVERTER_SVG ${IMAGE_CONVERTER_SVGZ})
+ endif(NOT IMAGE_CONVERTER_SVG)
+
+ message(STATUS "SVG2PNG-Converter: ${IMAGE_CONVERTER_SVGZ}")
+ if (NOT IMAGE_CONVERTER_SVGZ)
+ message(WARNING "No SVG2PNG converter found. Please install one of the following tools: ${SVG_CONVERTER_PROGS}, or imagemagick with svg support")
+ set_with_reason(SVG2PNG "no converter found" FALSE)
+ endif(NOT IMAGE_CONVERTER_SVGZ)
endif(SVG2PNG)
if (XPM2PNG)
- message(STATUS "XPM2PNG-Converter: ${IMAGE_CONVERTER_XPM}")
- if (NOT IMAGE_CONVERTER_XPM)
- message(WARNING "No XPM2PNG converter found. Please install imagemagick with xpm support")
- set_with_reason(XPM2PNG "no converter found" FALSE)
- endif(NOT IMAGE_CONVERTER_XPM)
+ message(STATUS "XPM2PNG-Converter: ${IMAGE_CONVERTER_XPM}")
+ if (NOT IMAGE_CONVERTER_XPM)
+ message(WARNING "No XPM2PNG converter found. Please install imagemagick with xpm support")
+ set_with_reason(XPM2PNG "no converter found" FALSE)
+ endif(NOT IMAGE_CONVERTER_XPM)
endif(XPM2PNG)
set(XSLTS ${XSLTS} CACHE STRING "define a semicolon seperated list of XSLTs to process")
# Plugins
if(USE_PLUGINS)
- set(MODULE_BUILD_TYPE "MODULE")
- add_definitions("-fPIC")
- list(APPEND NAVIT_LIBS dl)
+ set(MODULE_BUILD_TYPE "MODULE")
+ add_definitions("-fPIC")
+ list(APPEND NAVIT_LIBS dl)
else()
- set(MODULE_BUILD_TYPE "STATIC")
+ set(MODULE_BUILD_TYPE "STATIC")
endif(USE_PLUGINS)
message(STATUS "Use plugins: ${MODULE_BUILD_TYPE}")
@@ -807,7 +846,8 @@ CHECK_FUNCTION_EXISTS (posix_memalign HAVE_POSIX_MEMALIGN)
CHECK_FUNCTION_EXISTS (popen HAVE_POPEN)
CHECK_FUNCTION_EXISTS (_atoi64 HAVE__ATOI64)
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/config.h" )
# Compile with -Wall -Wextra. We need all the help we can get from the compiler :-).
# Disabled warnings:
@@ -817,15 +857,15 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY
# -Wno-sign-compare: We currently just use int almost everywhere.
# Unclear if it's really worth correcting.
if(CMAKE_COMPILER_IS_GNUCC OR CCMAKE_COMPILER_IS_GNUCXX)
- set(COMMON_COMPILER_FLAGS "-Wall -Wundef -Wcast-align -Wpointer-arith -Wno-unused-parameter -Wno-sign-compare")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILER_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILER_FLAGS}")
- # flags not available in old GCC versions, or not for both C and C++
- add_compiler_flag_if_available("-Wno-missing-field-initializers")
- add_compiler_flag_if_available("-Wextra")
- add_compiler_flag_if_available("-Wmissing-prototypes")
- add_compiler_flag_if_available("-Wstrict-prototypes")
- add_compiler_flag_if_available("-Wformat-security")
+ set(COMMON_COMPILER_FLAGS "-Wall -Wundef -Wcast-align -Wpointer-arith -Wno-unused-parameter -Wno-sign-compare")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILER_FLAGS}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${COMMON_COMPILER_FLAGS}")
+ # flags not available in old GCC versions, or not for both C and C++
+ add_compiler_flag_if_available("-Wno-missing-field-initializers")
+ add_compiler_flag_if_available("-Wextra")
+ add_compiler_flag_if_available("-Wmissing-prototypes")
+ add_compiler_flag_if_available("-Wstrict-prototypes")
+ add_compiler_flag_if_available("-Wformat-security")
endif()
if (EXTRA_DEFINES)
@@ -833,54 +873,54 @@ if (EXTRA_DEFINES)
endif(EXTRA_DEFINES)
if (NOT NAVIT_DEPENDENCY_ERROR)
- message("\nSummary:\n")
-
- set(SUMMARY_COMPONENTS ${ALL_PLUGINS} ${ALL_MODULE_PLUGINS} ${ALL_MODULES})
- list(SORT SUMMARY_COMPONENTS)
-
- set(LAST_TYPE NONE)
- foreach ( SUMMARY_COMP ${SUMMARY_COMPONENTS})
- # split path to type and name
- string(REPLACE "/" ";" SUMMARY_COMP_LIST ${SUMMARY_COMP})
- list(GET SUMMARY_COMP_LIST 0 SUMMARY_COMP_TYPE)
- list(LENGTH SUMMARY_COMP_LIST SUMMARY_COMP_LIST_LENGTH)
- if ( SUMMARY_COMP_LIST_LENGTH GREATER 1 )
- list(GET SUMMARY_COMP_LIST 1 SUMMARY_COMP_NAME)
- else()
- set(SUMMARY_COMP_NAME ${SUMMARY_COMP})
- endif()
- if ( NOT ${LAST_TYPE} STREQUAL ${SUMMARY_COMP_TYPE})
- message("\n--->>> ${SUMMARY_COMP_TYPE}")
- set(LAST_TYPE ${SUMMARY_COMP_TYPE})
- endif()
- if (${SUMMARY_COMP})
- message("Enabled ${SUMMARY_COMP_NAME} ( ${${SUMMARY_COMP}_REASON} )")
- else()
- message("Disabled ${SUMMARY_COMP_NAME} ( ${${SUMMARY_COMP}_REASON} )")
- endif()
- endforeach()
-
- list(SORT ALL_FEATURES)
- message("\n--->>> Features")
- foreach ( FEATURE ${ALL_FEATURES})
- if ( ${FEATURE} )
- message("Enabled ${FEATURE} ( ${${FEATURE}_REASON} )")
- else()
- message("Disabled ${FEATURE} ( ${${FEATURE}_REASON} )")
- endif()
- endforeach()
-
- if (XSL_PROCESSING)
- if (XSLTS)
- message("\nProcessing XSLT files: ${XSLTS}")
- else()
- message("\nProcessing XSLT files: NONE")
- endif(XSLTS)
- message("See navit/xslt for available XSLT files, and put them into "
- "cache variable 'XSLTS' (without extension .xslt).")
- endif(XSL_PROCESSING)
-
- message("\nTo configure your build use 'cmake -L' to find changeable variables and run cmake again with 'cmake -D <var-name>=<your value> ...'.")
+ message("\nSummary:\n")
+
+ set(SUMMARY_COMPONENTS ${ALL_PLUGINS} ${ALL_MODULE_PLUGINS} ${ALL_MODULES})
+ list(SORT SUMMARY_COMPONENTS)
+
+ set(LAST_TYPE NONE)
+ foreach ( SUMMARY_COMP ${SUMMARY_COMPONENTS})
+ # split path to type and name
+ string(REPLACE "/" ";" SUMMARY_COMP_LIST ${SUMMARY_COMP})
+ list(GET SUMMARY_COMP_LIST 0 SUMMARY_COMP_TYPE)
+ list(LENGTH SUMMARY_COMP_LIST SUMMARY_COMP_LIST_LENGTH)
+ if ( SUMMARY_COMP_LIST_LENGTH GREATER 1 )
+ list(GET SUMMARY_COMP_LIST 1 SUMMARY_COMP_NAME)
+ else()
+ set(SUMMARY_COMP_NAME ${SUMMARY_COMP})
+ endif()
+ if ( NOT ${LAST_TYPE} STREQUAL ${SUMMARY_COMP_TYPE})
+ message("\n--->>> ${SUMMARY_COMP_TYPE}")
+ set(LAST_TYPE ${SUMMARY_COMP_TYPE})
+ endif()
+ if (${SUMMARY_COMP})
+ message("Enabled ${SUMMARY_COMP_NAME} ( ${${SUMMARY_COMP}_REASON} )")
+ else()
+ message("Disabled ${SUMMARY_COMP_NAME} ( ${${SUMMARY_COMP}_REASON} )")
+ endif()
+ endforeach()
+
+ list(SORT ALL_FEATURES)
+ message("\n--->>> Features")
+ foreach ( FEATURE ${ALL_FEATURES})
+ if ( ${FEATURE} )
+ message("Enabled ${FEATURE} ( ${${FEATURE}_REASON} )")
+ else()
+ message("Disabled ${FEATURE} ( ${${FEATURE}_REASON} )")
+ endif()
+ endforeach()
+
+ if (XSL_PROCESSING)
+ if (XSLTS)
+ message("\nProcessing XSLT files: ${XSLTS}")
+ else()
+ message("\nProcessing XSLT files: NONE")
+ endif(XSLTS)
+ message("See navit/xslt for available XSLT files, and put them into "
+ "cache variable 'XSLTS' (without extension .xslt).")
+ endif(XSL_PROCESSING)
+
+ message("\nTo configure your build use 'cmake -L' to find changeable variables and run cmake again with 'cmake -D <var-name>=<your value> ...'.")
endif(NOT NAVIT_DEPENDENCY_ERROR)
add_subdirectory (navit)
@@ -888,5 +928,5 @@ add_subdirectory (man)
if (USE_NATIVE_LANGUAGE_SUPPORT)
- add_subdirectory (po)
+ add_subdirectory (po)
endif(USE_NATIVE_LANGUAGE_SUPPORT)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..e116f8ccd
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,10 @@
+# Contributing
+
+Welcome to Navit! If you are interested in contributing to the [Navit code repo](README.md)
+then checkout the [Wiki](https://wiki.navit-project.org/index.php/Main_Page)
+
+When pushing a pull request, please make sure you follow our:
+* [programming guidelines](https://wiki.navit-project.org/index.php/Programming_guidelines)
+* [commit message guidelines](https://wiki.navit-project.org/index.php/Commit_guidelines)
+
+For more information on our developement process, see: https://wiki.navit-project.org/index.php/Development
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index 411115f00..000000000
--- a/ChangeLog
+++ /dev/null
@@ -1,4 +0,0 @@
-Changes and documentation about Navit can be found in the wiki at:
- http://wiki.navit-project.org
-A timeline of opened and closed issue tickets can be found at our trac instance:
- http://trac.navit-project.org
diff --git a/LGPL-2 b/LGPL-2
index 2676d08ae..995a872fe 100644
--- a/LGPL-2
+++ b/LGPL-2
@@ -51,7 +51,7 @@ library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
-
+
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
@@ -98,7 +98,7 @@ works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
-
+
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@@ -133,7 +133,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
-
+
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
@@ -145,7 +145,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
-
+
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
@@ -203,7 +203,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
-
+
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
@@ -254,7 +254,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
-
+
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
@@ -308,7 +308,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
-
+
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
@@ -349,7 +349,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
-
+
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
@@ -401,7 +401,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
-
+
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
@@ -435,7 +435,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
-
+
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
diff --git a/README.md b/README.md
index 152419378..4e7f8d577 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
[![Build Status](https://img.shields.io/circleci/project/github/navit-gps/navit/trunk.svg)](https://circleci.com/gh/navit-gps/navit)
+[![CodeFactor](https://www.codefactor.io/repository/github/navit-gps/navit/badge)](https://www.codefactor.io/repository/github/navit-gps/navit)
+
Navit on Android tablet:
@@ -14,7 +16,7 @@ Navit on Linux based Carputer:
<a href="https://f-droid.org/repository/browse/?fdfilter=navit&fdid=org.navitproject.navit"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Get_it_on_F-Droid.svg/200px-Get_it_on_F-Droid.svg.png" height="100"/></a>
</p>
-NavIT
+Navit
=====
Navit is a open source (GPL) car navigation system with routing engine.
@@ -35,56 +37,58 @@ destination, but also generates directions and even speaks to you.
Navit currently speaks over 70 languages!
-You can help translating via our web based translation page :
+You can help translating via our web based translation page:
http://translations.launchpad.net/navit/trunk/+pots/navit
-For help or more information, please refer to the wiki :
+For help or more information, please refer to the wiki:
http://wiki.navit-project.org
-If you don't know where to start, we recommend you to read the
+If you don't know where to start, we recommend you to read the
Interactive Help : http://wiki.navit-project.org/index.php/Interactive_help
-Maps:
-=====
+Maps
+====
The best navigation system is useless without maps. Those three maps
are known to work:
-- OpenStreetMaps : display, routing, but street name search isn't complete
- (see http://wiki.navit-project.org/index.php/OpenStreetMaps )
+- OpenStreetMap: display, routing, but street name search isn't complete
+ (see http://wiki.navit-project.org/index.php/OpenStreetMap)
-- Grosser Reiseplaner and compliant maps : full support
- (see http://wiki.navit-project.org/index.php/European_maps )
+- Grosser Reiseplaner and compliant maps: full support
+ (see http://wiki.navit-project.org/index.php/European_maps)
-- Garmin maps : display, routing, search is being worked on
- (see http://wiki.navit-project.org/index.php/Garmin_maps )
+- Garmin maps: display, routing, search is being worked on
+ (see http://wiki.navit-project.org/index.php/Garmin_maps)
-GPS Support:
-============
+GPS Support
+===========
-Navit read the current vehicle position :
-- directly from a file
+Navit reads the current vehicle position:
+- directly from a file or port
- from gpsd (local or remote)
+- from the location service of several mobile platforms
- from udp server (friends tracking) (experimental)
Routing algorithm
=================
-NavIt uses a Dijkstra algorithm for routing. The routing starts at the
-destination by assigning a value to each point directly connected to
-destination point. The value represents the estimated time needed to
-pass this distance.
+Navit uses LPA* (see [Lifelong_Planning_A*](https://en.wikipedia.org/wiki/Lifelong_Planning_A*)), a derivative of the Dijkstra algorithm, for
+routing. Routing starts at the destination by assigning a value to each point directly connected to the destination
+point. The value represents the estimated time needed to reach the destination from that point.
-Now the point with the lowest value is choosen using the Fibonacci
-heap and a value is assigned to connected points whos are
-unevaluated or whos current value ist greater than the new one.
+Now the point with the lowest value is chosen using the Fibonacci heap, and a value is assigned to connected points
+which are unevaluated or whose current value is greater than the new one.
The search is repeated until the origin is found.
-Once the origin is reached, all that needs to be done is to follow the
-points with the lowest values to the destination.
+Once the origin is reached, all that needs to be done is to follow the points with the lowest values to the
+destination.
+LPA* is slightly more complex, as it allows partial re-evaluation of the route graph as segment costs change. This is
+used by the (still experimental) traffic module, which can process traffic reports and tries to find a way around
+traffic problems. Refer to the Wikipedia page for a full description.
diff --git a/Toolchain/arm-mingw32ce.cmake b/Toolchain/arm-mingw32ce.cmake
deleted file mode 100644
index 4ccdd22c4..000000000
--- a/Toolchain/arm-mingw32ce.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-SET(CMAKE_SYSTEM_NAME WINCE)
-
-# specify the cross compiler
-FIND_PROGRAM(CMAKE_C_COMPILER NAMES arm-mingw32ce-gcc arm-wince-mingw32ce-gcc)
-FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES arm-mingw32ce-g++ arm-wince-mingw32ce-g++)
-FIND_PROGRAM(CMAKE_RC_COMPILER_INIT NAMES arm-mingw32ce-windres arm-wince-mingw32ce-windres)
-SET(PKG_CONFIG_EXECUTABLE "arm-mingw32ce-pkg-config")
-SET(WINCE TRUE)
diff --git a/Toolchain/i386-mingw32ce.cmake b/Toolchain/i386-mingw32ce.cmake
deleted file mode 100644
index a1cc562f6..000000000
--- a/Toolchain/i386-mingw32ce.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-SET(CMAKE_SYSTEM_NAME WINCE)
-
-# specify the cross compiler
-FIND_PROGRAM(CMAKE_C_COMPILER NAMES i386-mingw32ce-gcc )
-FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES i386-mingw32ce-g++ )
-FIND_PROGRAM(CMAKE_RC_COMPILER_INIT NAMES i386-mingw32ce-windres )
-SET(PKG_CONFIG_EXECUTABLE "i386-mingw32ce-pkg-config")
-SET(WINCE TRUE)
diff --git a/Toolchain/mingw.cmake b/Toolchain/mingw.cmake
new file mode 100644
index 000000000..c50c80f91
--- /dev/null
+++ b/Toolchain/mingw.cmake
@@ -0,0 +1,34 @@
+SET(CMAKE_C_COMPILER ${TARGET_ARCH}-gcc)
+SET(CMAKE_CXX_COMPILER ${TARGET_ARCH}-g++)
+SET(CMAKE_RC_COMPILER_INIT ${TARGET_ARCH}-windres)
+SET(PKG_CONFIG_EXECUTABLE ${TARGET_ARCH}-pkg-config)
+
+# unecessary according to https://cmake.org/cmake/help/v3.4/variable/WINCE.html
+# TODO: plateform wince change too much things for now, fix later.
+# WindowsCETest -> WindowsCE
+if (CMAKE_SYSTEM_NAME STREQUAL "WindowsCETest")
+ SET(CMAKE_EXECUTABLE_SUFFIX ".exe")
+ SET(WINCE TRUE)
+endif()
+
+if(WINCE)
+ # MINGW32CE_PATH is set in dockerfile
+ message(STATUS "Wince toolchain in $ENV{MINGW32CE_PATH}")
+
+ #SET(CMAKE_FIND_ROOT_PATH $ENV{MINGW32CE_PATH})
+ #SET(CMAKE_INSTALL_PREFIX $ENV{MINGW32CE_PATH})
+endif(WINCE)
+
+if(WIN32)
+ message(STATUS "WIN32 case")
+ #SET(CMAKE_FIND_ROOT_PATH ${MINGW_INSTALL_PREFIX})
+ #SET(QT_MOC_EXECUTABLE bin/moc)
+ #SET(QT_RCC_EXECUTABLE ${MINGW_INSTALL_PREFIX}/bin/rcc)
+ #SET(QT_UIC_EXECUTABLE ${MINGW_INSTALL_PREFIX}/bin/uic)
+ SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+ SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+ SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+ SET(CMAKE_FIND_ROOT_PATH ${MINGW_INSTALL_PREFIX})
+ SET(CMAKE_INSTALL_PREFIX ${MINGW_INSTALL_PREFIX})
+endif()
diff --git a/Toolchain/mingw32.cmake b/Toolchain/mingw32.cmake
deleted file mode 100644
index d00e7d6ab..000000000
--- a/Toolchain/mingw32.cmake
+++ /dev/null
@@ -1,21 +0,0 @@
-SET(CMAKE_SYSTEM_NAME Windows)
-
-FIND_PROGRAM(CMAKE_C_COMPILER NAMES i686-w64-mingw32-gcc i686-mingw32-gcc i586-mingw32-gcc i386-mingw32-gcc i586-mingw32msvc-gcc mingw32-gcc)
-FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES i686-w64-mingw32-g++ i686-mingw32-g++ i586-mingw32-g++ i386-mingw32-g++ i586-mingw32msvc-g++ mingw32-g++)
-
-FIND_PROGRAM(CMAKE_RC_COMPILER_INIT NAMES i686-w64-mingw32-windres i686-mingw32-windres i586-mingw32-windres i386-mingw32-windres mingw32-windres i586-mingw32msvc-windres windres.exe)
-
-FIND_PROGRAM(CMAKE_AR NAMES i686-w64-mingw32-ar i686-mingw32-ar i586-mingw32-ar i386-mingw32-ar i586-mingw32msvc-ar mingw32-ar ar.exe)
-
-IF (NOT CMAKE_FIND_ROOT_PATH)
-EXECUTE_PROCESS(
- COMMAND ${CMAKE_C_COMPILER} -print-sysroot
- OUTPUT_VARIABLE CMAKE_FIND_ROOT_PATH
-)
-ENDIF(NOT CMAKE_FIND_ROOT_PATH)
-
-set(PKG_CONFIG_EXECUTABLE "mingw32-pkg-config")
-
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 000000000..5d598ab8b
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,33 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ google()
+ jcenter()
+ maven {
+ url 'https://maven.google.com/'
+ name 'Google'
+ }
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.1.2'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+ maven {
+ url 'https://maven.google.com/'
+ name 'Google'
+ }
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/checkstyle.xml b/checkstyle.xml
new file mode 100644
index 000000000..00dfe5b3f
--- /dev/null
+++ b/checkstyle.xml
@@ -0,0 +1,257 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+ "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
+
+<!--
+
+
+ Tuned for Navit and based on :
+
+ Checkstyle configuration that checks the Google coding conventions from Google Java Style
+ that can be found at https://google.github.io/styleguide/javaguide.html.
+
+ Checkstyle is very configurable. Be sure to read the documentation at
+ http://checkstyle.sf.net (or in your downloaded distribution).
+
+ To completely disable a check, just comment it out or delete it from the file.
+
+ Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
+ -->
+
+<module name = "Checker">
+ <property name="charset" value="UTF-8"/>
+
+ <property name="severity" value="warning"/>
+
+ <property name="fileExtensions" value="java, properties, xml"/>
+ <!-- Checks for whitespace -->
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <module name="FileTabCharacter">
+ <property name="eachLine" value="true"/>
+ </module>
+
+ <module name="TreeWalker">
+ <module name="OuterTypeFilename"/>
+ <module name="IllegalTokenText">
+ <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
+ <property name="format"
+ value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
+ <property name="message"
+ value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
+ </module>
+ <module name="AvoidEscapedUnicodeCharacters">
+ <property name="allowEscapesForControlCharacters" value="true"/>
+ <property name="allowByTailComment" value="true"/>
+ <property name="allowNonPrintableEscapes" value="true"/>
+ </module>
+ <module name="LineLength">
+ <property name="max" value="120"/>
+ <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
+ </module>
+ <module name="AvoidStarImport"/>
+ <module name="OneTopLevelClass"/>
+ <module name="NoLineWrap"/>
+ <module name="EmptyBlock">
+ <property name="option" value="TEXT"/>
+ <property name="tokens"
+ value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
+ </module>
+ <module name="NeedBraces"/>
+ <module name="LeftCurly"/>
+ <module name="RightCurly">
+ <property name="id" value="RightCurlySame"/>
+ <property name="tokens"
+ value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE,
+ LITERAL_DO"/>
+ </module>
+ <module name="RightCurly">
+ <property name="id" value="RightCurlyAlone"/>
+ <property name="option" value="alone"/>
+ <property name="tokens"
+ value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
+ INSTANCE_INIT"/>
+ </module>
+ <module name="WhitespaceAround">
+ <property name="allowEmptyConstructors" value="true"/>
+ <property name="allowEmptyMethods" value="true"/>
+ <property name="allowEmptyTypes" value="true"/>
+ <property name="allowEmptyLoops" value="true"/>
+ <message key="ws.notFollowed"
+ value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
+ <message key="ws.notPreceded"
+ value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
+ </module>
+ <module name="OneStatementPerLine"/>
+ <module name="MultipleVariableDeclarations"/>
+ <module name="ArrayTypeStyle">
+ <property name="severity" value="error"/>
+ </module>
+ <module name="MissingSwitchDefault"/>
+ <module name="FallThrough"/>
+ <module name="UpperEll"/>
+ <module name="ModifierOrder"/>
+ <module name="EmptyLineSeparator">
+ <property name="allowNoEmptyLineBetweenFields" value="true"/>
+ </module>
+ <module name="SeparatorWrap">
+ <property name="id" value="SeparatorWrapDot"/>
+ <property name="tokens" value="DOT"/>
+ <property name="option" value="nl"/>
+ </module>
+ <module name="SeparatorWrap">
+ <property name="id" value="SeparatorWrapComma"/>
+ <property name="tokens" value="COMMA"/>
+ <property name="option" value="EOL"/>
+ </module>
+ <module name="SeparatorWrap">
+ <!-- ELLIPSIS is EOL until https://github.com/google/styleguide/issues/258 -->
+ <property name="id" value="SeparatorWrapEllipsis"/>
+ <property name="tokens" value="ELLIPSIS"/>
+ <property name="option" value="EOL"/>
+ </module>
+ <module name="SeparatorWrap">
+ <!-- ARRAY_DECLARATOR is EOL until https://github.com/google/styleguide/issues/259 -->
+ <property name="id" value="SeparatorWrapArrayDeclarator"/>
+ <property name="tokens" value="ARRAY_DECLARATOR"/>
+ <property name="option" value="EOL"/>
+ </module>
+ <module name="SeparatorWrap">
+ <property name="id" value="SeparatorWrapMethodRef"/>
+ <property name="tokens" value="METHOD_REF"/>
+ <property name="option" value="nl"/>
+ </module>
+ <module name="PackageName">
+ <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
+ <message key="name.invalidPattern"
+ value="Package name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="TypeName">
+ <message key="name.invalidPattern"
+ value="Type name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="MemberName">
+ <property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
+ <message key="name.invalidPattern"
+ value="Member name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="ParameterName">
+ <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
+ <message key="name.invalidPattern"
+ value="Parameter name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="CatchParameterName">
+ <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
+ <message key="name.invalidPattern"
+ value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="LocalVariableName">
+ <property name="tokens" value="VARIABLE_DEF"/>
+ <property name="format" value="^[a-z]([a-zA-Z0-9]*)?$"/>
+ <message key="name.invalidPattern"
+ value="Local variable name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="ClassTypeParameterName">
+ <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
+ <message key="name.invalidPattern"
+ value="Class type name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="MethodTypeParameterName">
+ <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
+ <message key="name.invalidPattern"
+ value="Method type name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="InterfaceTypeParameterName">
+ <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
+ <message key="name.invalidPattern"
+ value="Interface type name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="NoFinalizer"/>
+ <module name="GenericWhitespace">
+ <message key="ws.followed"
+ value="GenericWhitespace ''{0}'' is followed by whitespace."/>
+ <message key="ws.preceded"
+ value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
+ <message key="ws.illegalFollow"
+ value="GenericWhitespace ''{0}'' should followed by whitespace."/>
+ <message key="ws.notPreceded"
+ value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
+ </module>
+ <module name="Indentation">
+ <property name="basicOffset" value="4"/>
+ <property name="braceAdjustment" value="0"/>
+ <property name="caseIndent" value="4"/>
+ <property name="throwsIndent" value="4"/>
+ <property name="lineWrappingIndentation" value="8"/>
+ <property name="arrayInitIndent" value="4"/>
+ </module>
+ <module name="AbbreviationAsWordInName">
+ <property name="ignoreFinal" value="false"/>
+ <property name="allowedAbbreviationLength" value="2"/>
+ </module>
+ <module name="OverloadMethodsDeclarationOrder"/>
+ <module name="VariableDeclarationUsageDistance"/>
+ <module name="CustomImportOrder">
+ <property name="sortImportsInGroupAlphabetically" value="true"/>
+ <property name="separateLineBetweenGroups" value="true"/>
+ <property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
+ <property name="severity" value="error"/>
+ </module>
+ <module name="MethodParamPad"/>
+ <module name="NoWhitespaceBefore">
+ <property name="tokens"
+ value="COMMA, SEMI, POST_INC, POST_DEC, DOT, ELLIPSIS, METHOD_REF"/>
+ <property name="allowLineBreaks" value="true"/>
+ </module>
+ <module name="ParenPad"/>
+ <module name="OperatorWrap">
+ <property name="option" value="NL"/>
+ <property name="tokens"
+ value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR,
+ LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF "/>
+ </module>
+ <module name="AnnotationLocation">
+ <property name="id" value="AnnotationLocationMostCases"/>
+ <property name="tokens"
+ value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
+ </module>
+ <module name="AnnotationLocation">
+ <property name="id" value="AnnotationLocationVariables"/>
+ <property name="tokens" value="VARIABLE_DEF"/>
+ <property name="allowSamelineMultipleAnnotations" value="true"/>
+ </module>
+ <module name="NonEmptyAtclauseDescription"/>
+ <module name="JavadocTagContinuationIndentation"/>
+ <module name="SummaryJavadoc">
+ <property name="forbiddenSummaryFragments"
+ value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
+ </module>
+ <module name="JavadocParagraph"/>
+ <module name="AtclauseOrder">
+ <property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
+ <property name="target"
+ value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
+ </module>
+ <module name="JavadocMethod">
+ <property name="scope" value="public"/>
+ <property name="allowMissingParamTags" value="true"/>
+ <property name="allowMissingThrowsTags" value="true"/>
+ <property name="allowMissingReturnTag" value="true"/>
+ <property name="minLineCount" value="2"/>
+ <property name="allowedAnnotations" value="Override, Test"/>
+ <property name="allowThrowsTagsForSubclasses" value="true"/>
+ </module>
+ <module name="MethodName">
+ <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
+ <message key="name.invalidPattern"
+ value="Method name ''{0}'' must match pattern ''{1}''."/>
+ </module>
+ <module name="SingleLineJavadoc">
+ <property name="ignoreInlineTags" value="false"/>
+ </module>
+ <module name="EmptyCatchBlock">
+ <property name="exceptionVariableName" value="expected"/>
+ </module>
+ <module name="CommentsIndentation"/>
+ </module>
+</module>
diff --git a/ci/build_android.sh b/ci/build_android.sh
deleted file mode 100644
index bf992fd2c..000000000
--- a/ci/build_android.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-set -e
-
-apt-get update && apt-get install -y wget
-
-export ARCH="arm"
-export START_PATH=~/
-export SOURCE_PATH=$START_PATH"/"${CIRCLE_PROJECT_REPONAME}"/"
-export CMAKE_FILE=$SOURCE_PATH"/Toolchain/arm-eabi.cmake"
-export ANDROID_NDK=~/android-ndk-r11c
-export ANDROID_NDK_BIN=$ANDROID_NDK"/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin"
-export ANDROID_SDK="/usr/local/android-sdk-linux/"
-export ANDROID_SDK_PLATFORM_TOOLS=$ANDROID_SDK"/platform-tools"
-export PATH=$ANDROID_NDK_BIN:$ANDROID_SDK_PLATFORM_TOOLS:$PATH
-export BUILD_PATH=android-${ARCH}
-
-export ANDROID_SDK_HOME=/opt/android-sdk-linux
-export ANDROID_HOME=/opt/android-sdk-linux
-export PATH=${PATH}:${ANDROID_SDK_HOME}/tools:${ANDROID_SDK_HOME}/platform-tools:/opt/tools
-
-wget -nv -c http://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip
-[ -d ~/android-ndk-r11c ] || unzip -q -d ~ android-ndk-r11c-linux-x86_64.zip
-
-[ -d $BUILD_PATH ] || mkdir -p $BUILD_PATH
-pushd $BUILD_PATH
-
-android list targets
-
-cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain/arm-eabi.cmake -DCACHE_SIZE='(20*1024*1024)' -DAVOID_FLOAT=1 -DSAMPLE_MAP=n -DBUILD_MAPTOOL=n -DANDROID_API_VERSION=25 -DANDROID_NDK_API_VERSION=19 ../
-
-make -j $(nproc --all)
-
-make -j $(nproc --all) apkg-release && mv navit/android/bin/Navit-release-unsigned.apk navit/android/bin/navit-$CIRCLE_SHA1-${ARCH}-release-unsigned.apk || exit 1
-make -j $(nproc --all) apkg && mv navit/android/bin/Navit-debug.apk navit/android/bin/navit-$CIRCLE_SHA1-${ARCH}-debug.apk || exit 1
diff --git a/ci/build_android_x86.sh b/ci/build_android_x86.sh
deleted file mode 100644
index 6e84bc4e1..000000000
--- a/ci/build_android_x86.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-set -e
-
-apt-get update && apt-get install -y wget
-
-export ARCH="x86"
-export START_PATH=~/
-export SOURCE_PATH=$START_PATH"/"${CIRCLE_PROJECT_REPONAME}"/"
-export CMAKE_FILE=$SOURCE_PATH"/Toolchain/i686-android.cmake"
-export ANDROID_NDK=~/android-ndk-r11c
-export ANDROID_NDK_BIN=$ANDROID_NDK"/toolchains/x86-4.9/prebuilt/linux-x86_64/bin"
-export ANDROID_SDK="/usr/local/android-sdk-linux/"
-export ANDROID_SDK_PLATFORM_TOOLS=$ANDROID_SDK"/platform-tools"
-export PATH=$ANDROID_NDK_BIN:$ANDROID_SDK_PLATFORM_TOOLS:$PATH
-export BUILD_PATH=android-${ARCH}
-
-export ANDROID_SDK_HOME=/opt/android-sdk-linux
-export ANDROID_HOME=/opt/android-sdk-linux
-export PATH=${PATH}:${ANDROID_SDK_HOME}/tools:${ANDROID_SDK_HOME}/platform-tools:/opt/tools
-
-
-wget -nv -c http://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip
-[ -d ~/android-ndk-r11c ] || unzip -q -d ~ android-ndk-r11c-linux-x86_64.zip
-
-[ -d $BUILD_PATH ] || mkdir -p $BUILD_PATH
-pushd $BUILD_PATH
-
-android list targets
-
-cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain/i686-android.cmake -DAVOID_FLOAT=1 -DSAMPLE_MAP=n -DBUILD_MAPTOOL=n -DANDROID_API_VERSION=25 -DANDROID_NDK_API_VERSION=19 -DDISABLE_CXX=1 -DDISABLE_QT=1 ..
-make -j $(nproc --all)
-
-if [[ "${CIRCLE_BRANCH}" == "master" ]]; then
- make -j $(nproc --all) apkg-release && mv navit/android/bin/Navit-release-unsigned.apk navit/android/bin/navit-$CIRCLE_SHA1-${ARCH}-release-unsigned.apk || exit 1
-else
- make -j $(nproc --all) apkg && mv navit/android/bin/Navit-debug.apk navit/android/bin/navit-$CIRCLE_SHA1-${ARCH}-debug.apk || exit 1
-fi
-
-echo
-echo "Build leftovers :"
-find .
diff --git a/ci/build_linux.sh b/ci/build_linux.sh
deleted file mode 100644
index 14abb7597..000000000
--- a/ci/build_linux.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-set -e
-
-COVERITY_VERSION="2017.07"
-
-apt-get install -y libpng12-dev librsvg2-bin libfreetype6-dev libdbus-glib-1-dev libgtk2.0-dev curl
-
-cmake_opts="-Dgraphics/qt_qpainter:BOOL=FALSE -Dgui/qml:BOOL=FALSE -DSVG2PNG:BOOL=FALSE -DSAMPLE_MAP=n -Dgraphics/gtk_drawing_area:BOOL=TRUE"
-
-mkdir ${CIRCLE_WORKING_DIRECTORY}/linux-bin && cd ${CIRCLE_WORKING_DIRECTORY}/linux-bin
-
-if [[ "${CIRCLE_PROJECT_USERNAME}" == "navit-gps" && "${CIRCLE_BRANCH}" == "trunk" ]]; then
- # If we are building the official trunk code, push an update to coverity
- wget -nv -c -O /tmp/cov-analysis-linux64-${COVERITY_VERSION}.tar.gz http://sd-55475.dedibox.fr/cov-analysis-linux64-${COVERITY_VERSION}.tar.gz
- tar xfz /tmp/cov-analysis-linux64-${COVERITY_VERSION}.tar.gz --no-same-owner -C /usr/local/share/
- export PATH=/usr/local/share/cov-analysis-linux64-${COVERITY_VERSION}/bin:$PATH
-
- cov-build --dir cov-int cmake ${CIRCLE_WORKING_DIRECTORY}/ ${cmake_opts}
- cov-build --dir cov-int make -j $(nproc --all) || exit -1
- tar czvf navit.tgz cov-int
-
- curl --form token=$COVERITY_TOKEN \
- --form email=$COVERITY_EMAIL \
- --form file=@navit.tgz \
- --form version="${CIRCLE_BRANCH}-$CIRCLE_SHA1" \
- --form description="${CIRCLE_BRANCH}-$CIRCLE_SHA1" \
- https://scan.coverity.com/builds?project=$CIRCLE_PROJECT_USERNAME
-
- # Then update the translation template on launchpad
- sed -i '/INTEGER/d' po/navit.pot
- cp po/navit.pot $CIRCLE_ARTIFACTS/
- curl "https://translations.launchpad.net/navit/${CIRCLE_BRANCH}/+translations-upload" -H "$lp_cookie" -H "Referer: https://translations.launchpad.net/navit/${CIRCLE_BRANCH}/+translations-upload" -F file=@po/navit.pot | grep title
-
-else
- cmake ${CIRCLE_WORKING_DIRECTORY}/ ${cmake_opts} || exit -1
- make -j $(nproc --all) || exit -1
-fi
-
-if [[ "$CIRCLE_ARTIFACTS" != "" ]]; then
- cp -r navit/icons $CIRCLE_ARTIFACTS
-fi
diff --git a/ci/build_win32.sh b/ci/build_win32.sh
deleted file mode 100644
index 47b05b9d2..000000000
--- a/ci/build_win32.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-apt-get update && apt-get install -y mingw32 mingw32-binutils mingw32-runtime default-jdk nsis
-
-mkdir win32
-pushd win32
-cmake -Dbinding/python:BOOL=FALSE -DSAMPLE_MAP=n -DCMAKE_TOOLCHAIN_FILE=../Toolchain/mingw32.cmake ../ && make -j $(nproc --all) && make -j $(nproc --all) package
-popd
-
-cp win32/*.exe $CIRCLE_ARTIFACTS/
diff --git a/ci/build_wince.sh b/ci/build_wince.sh
deleted file mode 100644
index 7d0b3b471..000000000
--- a/ci/build_wince.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-mkdir wince && cd wince
-cmake ../ -DCMAKE_TOOLCHAIN_FILE=Toolchain/arm-mingw32ce.cmake -DXSLTS=windows -DCACHE_SIZE=10485760 -Dsvg2png_scaling:STRING=16,32 -Dsvg2png_scaling_nav:STRING=32 -Dsvg2png_scaling_flag=16 -DSAMPLE_MAP=n
-make
diff --git a/ci/docker/tomtom/Dockerfile b/ci/docker/tomtom/Dockerfile
deleted file mode 100644
index adddbdbf8..000000000
--- a/ci/docker/tomtom/Dockerfile
+++ /dev/null
@@ -1,106 +0,0 @@
-FROM ubuntu:14.04
-
-RUN apt-get update && apt-get install -y libglib2.0-dev git autogen autoconf libtool imagemagick zip \
- wget build-essential gettext cmake \
- && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
-RUN dpkg --add-architecture i386 && apt-get update \
- && apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386 \
- && apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
-
-ENV ARCH=arm-linux
-ENV TOMTOM_SDK_DIR=/opt/tomtom-sdk
-ENV PREFIX=$TOMTOM_SDK_DIR/gcc-3.3.4_glibc-2.3.2/$ARCH/sys-root
-ENV PATH=$TOMTOM_SDK_DIR/gcc-3.3.4_glibc-2.3.2/bin:$PREFIX/bin/:$PATH
-ENV CFLAGS="-O2 -I$PREFIX/include -I$PREFIX/usr/include"
-ENV CPPFLAGS="-I$PREFIX/include -I$PREFIX/usr/include"
-ENV LDFLAGS="-L$PREFIX/lib -L$PREFIX/usr/lib"
-ENV CC=$ARCH-gcc
-ENV CXX=$ARCH-g++
-ENV LD=$ARCH-ld
-ENV NM="$ARCH-nm -B"
-ENV AR=$ARCH-ar
-ENV RANLIB=$ARCH-ranlib
-ENV STRIP=$ARCH-strip
-ENV OBJCOPY=$ARCH-objcopy
-ENV LN_S="ln -s"
-ENV PKG_CONFIG_LIBDIR=$PREFIX/lib/pkgconfig
-RUN mkdir -p $TOMTOM_SDK_DIR
-
-RUN wget -nv -c https://github.com/navit-gps/dependencies/raw/master/tomtom/toolchain_redhat_gcc-3.3.4_glibc-2.3.2-20060131a.tar.gz -P /tmp \
- && tar xzf /tmp/toolchain_redhat_gcc-3.3.4_glibc-2.3.2-20060131a.tar.gz -C $TOMTOM_SDK_DIR \
- && rm /tmp/toolchain_redhat_gcc-3.3.4_glibc-2.3.2-20060131a.tar.gz
-
-# zlib
-RUN wget -nv -c http://zlib.net/zlib-1.2.11.tar.gz -P /tmp && cd /tmp/ \
- && tar xzf zlib-1.2.11.tar.gz && cd zlib-1.2.11 \
- && ./configure --prefix=$PREFIX && make && make install \
- && rm -rf /tmp/zlib-1.2.11 /tmp/zlib-1.2.11.tar.gz
-
-# libxml
-RUN wget -nv -c http://xmlsoft.org/sources/libxml2-2.7.8.tar.gz -P /tmp && cd /tmp/ \
- && tar xzf libxml2-2.7.8.tar.gz && cd libxml2-2.7.8/ \
- && ./configure --prefix=$PREFIX --host=$ARCH --without-python && make && make install \
- && rm -rf /tmp/libxml2-2.7.8/ /tmp/libxml2-2.7.8.tar.gz
-
-# libpng
-RUN wget -nv -c https://github.com/navit-gps/dependencies/raw/master/tomtom/libpng-1.6.29.tar.gz -P /tmp && cd /tmp/ \
- && tar xzf libpng-1.6.29.tar.gz && cd libpng-1.6.29/ \
- && ./configure --prefix=$PREFIX --host=$ARCH && make && make install \
- && rm -rf /tmp/libpng-1.6.29/ /tmp/libpng-1.6.29.tar.gz
-
-# Freetype
-RUN wget -nv -c http://download.savannah.gnu.org/releases/freetype/freetype-2.5.0.tar.gz -P /tmp && cd /tmp/ \
- && tar xzf freetype-2.5.0.tar.gz && cd freetype-2.5.0 \
- && ./configure --prefix=$PREFIX --host=$ARCH && make && make install \
- && rm -rf /tmp/freetype-2.5.0 /tmp/freetype-2.5.0.tar.gz
-
-# freetype-config --cflags
-
-# glib
-
-# chmod a-w tomtom.cache
-COPY tomtom.cache /tmp/
-
-RUN wget -nv -c http://ftp.gnome.org/pub/gnome/sources/glib/2.25/glib-2.25.17.tar.gz -P /tmp && cd /tmp / \
- && tar xzf glib-2.25.17.tar.gz && cd glib-2.25.17 \
- && mv /tmp/tomtom.cache . \
- && ./configure --prefix=$PREFIX --host=$ARCH --cache-file=tomtom.cache \
- && sed -i "s|cp xgen-gmc gmarshal.c |cp xgen-gmc gmarshal.c \&\& sed -i \"s\|g_value_get_schar\|g_value_get_char\|g\" gmarshal.c |g" gobject/Makefile \
- && make && make install \
- && rm -rf /tmp/glib-2.25.17 /tmp/glib-2.25.17.tar.gz
-
-# tslib
-RUN git clone https://github.com/playya/tslib-svn.git /tmp/tslib-svn && cd /tmp/tslib-svn/ \
- && sed -i "s|AM_CONFIG_HEADER|AC_CONFIG_HEADERS|g" configure.ac \
- && sed -i "119i\#ifdef EVIOCGRAB" plugins/input-raw.c \
- && sed -i "124i\#endif" plugins/input-raw.c \
- && sed -i "290i\#ifdef EVIOCGRAB" plugins/input-raw.c \
- && sed -i "294i\#endif" plugins/input-raw.c \
- && sed -i "s|# module_raw h3600|module_raw h3600|g" etc/ts.conf \
- && ./autogen.sh && ./configure --prefix=$PREFIX --host=$ARCH \
- && make && make install \
- && rm -rf /tmp/tslib-svn/
-
-# SDL
-RUN wget -nv -c http://www.libsdl.org/release/SDL-1.2.15.tar.gz -P /tmp && cd /tmp/ \
- && tar xzf SDL-1.2.15.tar.gz && cd SDL-1.2.15 \
- && wget -nv -c http://tracks.yaina.de/source/sdl-fbcon-notty.patch \
- && patch -p0 -i sdl-fbcon-notty.patch \
- && ./configure --prefix=$PREFIX --host=$ARCH \
- --disable-esd --disable-cdrom --disable-joystick --disable-video-x11 \
- --disable-x11-vm --disable-dga --disable-video-x11-dgamouse \
- --disable-video-x11-xv --disable-video-x11-xinerama --disable-video-directfb \
- --enable-video-fbcon --disable-audio CFLAGS="$CFLAGS -DFBCON_NOTTY" \
- && make && make install \
- && cd test && ./configure --prefix=$PREFIX --host=$ARCH \
- && make testvidinfo && cp testvidinfo $PREFIX/usr/bin/ \
- && rm -rf /tmp/SDL-1.2.15 /tmp/SDL-1.2.15.tar.gz
-
-# sdl image
-RUN wget -nv -c http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.12.tar.gz -P /tmp/ && cd /tmp/ \
- && tar xzf SDL_image-1.2.12.tar.gz && cd SDL_image-1.2.12 \
- && ./configure --prefix=$PREFIX --host=$ARCH && make && make install \
- && rm -rf /tmp/SDL_image-1.2.12 /tmp/SDL_image-1.2.12.tar.gz
-
-COPY entrypoint.sh /
-CMD bash /entrypoint.sh
diff --git a/ci/docker/tomtom/README.md b/ci/docker/tomtom/README.md
deleted file mode 100644
index badaf2707..000000000
--- a/ci/docker/tomtom/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-This is the code used to build the image available at https://hub.docker.com/r/navit/tomtom-build-image/
-
-If you want to build and use that image locally, you can do the following:
-docker build . -t navit/tomtom-build-image
-docker run -ti -v /tmp:/output navit/tomtom-build-image /bin/bash /entrypoint.sh
-
-The resulting build will be in your /tmp/ folder.
diff --git a/ci/docker/tomtom/entrypoint.sh b/ci/docker/tomtom/entrypoint.sh
deleted file mode 100644
index e70e1cb5e..000000000
--- a/ci/docker/tomtom/entrypoint.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-git clone https://github.com/navit-gps/navit.git
-cd navit
-bash ci/build_tomtom_minimal.sh
diff --git a/ci/docker/tomtom/tomtom.cache b/ci/docker/tomtom/tomtom.cache
deleted file mode 100644
index ea2cb3faf..000000000
--- a/ci/docker/tomtom/tomtom.cache
+++ /dev/null
@@ -1,5 +0,0 @@
-glib_cv_long_long_format=ll
-glib_cv_stack_grows=no
-glib_cv_uscore=no
-ac_cv_func_posix_getgrgid_r=yes
-ac_cv_func_posix_getpwuid_r=yes
diff --git a/ci/publish.sh b/ci/publish.sh
deleted file mode 100644
index a92f620b8..000000000
--- a/ci/publish.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-ARCH="arm"
-
-cd ~/
-git clone git@github.com:navit-gps/infrastructure-blackbox.git
-cd infrastructure-blackbox/keyrings/
-openssl aes-256-cbc -d -in keystore.gpg -k $KEY > ~/.keystore
-openssl aes-256-cbc -d -in client_secrets.gpg -k $KEY > ~/navit/ci/client_secrets.json
-openssl aes-256-cbc -d -in androidpublisher.gpg -k $KEY > androidpublisher.dat
-
-pip install google-api-python-client
-
-jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -storepass $SP $CIRCLE_ARTIFACTS/navit-$CIRCLE_SHA1-${ARCH}-release-unsigned.apk $key_name
-
-/usr/local/android-sdk-linux/build-tools/25.0.1/zipalign 4 $CIRCLE_ARTIFACTS/navit-$CIRCLE_SHA1-${ARCH}-release-unsigned.apk $CIRCLE_ARTIFACTS/navit-$CIRCLE_SHA1-${ARCH}-release-signed.apk
-# /usr/local/android-sdk-linux/build-tools/25.0.1/apksigner sign -v --ks-pass pass:$SP --key $key_name $CIRCLE_ARTIFACTS/navit-$CIRCLE_SHA1-${ARCH}-release-signed.apk
-/usr/local/android-sdk-linux/build-tools/25.0.1/apksigner verify -v $CIRCLE_ARTIFACTS/navit-$CIRCLE_SHA1-${ARCH}-release-signed.apk
-python ~/navit/ci/basic_upload_apks.py org.navitproject.navit $CIRCLE_ARTIFACTS/navit-$CIRCLE_SHA1-${ARCH}-release-signed.apk
diff --git a/ci/setup_common_requirements.sh b/ci/setup_common_requirements.sh
deleted file mode 100644
index f5fa73cef..000000000
--- a/ci/setup_common_requirements.sh
+++ /dev/null
@@ -1 +0,0 @@
-apt-get update && apt-get install -y wget unzip cmake build-essential gettext
diff --git a/cmake/FindDBus.cmake b/cmake/FindDBus.cmake
deleted file mode 100644
index b6bbdb53d..000000000
--- a/cmake/FindDBus.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-include(LibFindMacros)
-
-libfind_pkg_check_modules(DBUS_PKGCONFIG dbus-1)
-
-FIND_PATH(DBus_INCLUDE_DIR dbus/dbus.h
- PATHS
- ${DBUS_PKGCONFIG_INCLUDE_DIRS}
- /usr/include/dbus-1.0
-# PATH_SUFFIXES dbus
-)
-
-FIND_PATH(DBus_INCLUDE_DIR_ARCH dbus/dbus-arch-deps.h
- PATHS
- ${DBUS_PKGCONFIG_INCLUDE_DIRS}
- /usr/lib/dbus-1.0/include
-# PATH_SUFFIXES dbus
-)
-
-FIND_LIBRARY(DBus_LIBRARY
- NAMES dbus-1
- PATHS ${DBUS_PKGCONFIG_LIBRARY_DIRS}
-)
-
-set(DBus_PROCESS_INCLUDES DBus_INCLUDE_DIR DBus_INCLUDE_DIR_ARCH)
-set(DBus_PROCESS_LIBS DBus_LIBRARY)
-libfind_process(DBus)
diff --git a/cmake/FindDBusGLib.cmake b/cmake/FindDBusGLib.cmake
deleted file mode 100644
index e4e870075..000000000
--- a/cmake/FindDBusGLib.cmake
+++ /dev/null
@@ -1,23 +0,0 @@
-FIND_PACKAGE(DBus)
-
-include(LibFindMacros)
-
-libfind_pkg_check_modules(DBUS_GLIB_PKGCONFIG dbus-glib-1)
-
-FIND_PATH(DBusGLib_INCLUDE_DIR dbus/dbus-glib.h
- PATHS
- ${DBUS_GLIB_PKGCONFIG_INCLUDE_DIRS}
- /usr/include/dbus-1.0
-# PATH_SUFFIXES dbus
-)
-
-FIND_LIBRARY(DBusGLib_LIBRARY
- NAMES
- dbus-glib-1
- PATHS
- ${DBUS_GLIB_PKGCONFIG_LIBRARY_DIRS}
-)
-
-set(DBusGLib_PROCESS_INCLUDES DBusGLib_INCLUDE_DIR DBus_INCLUDE_DIRS)
-set(DBusGLib_PROCESS_LIBS DBusGLib_LIBRARY DBus_LIBRARIES)
-libfind_process(DBusGLib)
diff --git a/cmake/FindGTK2.cmake b/cmake/FindGTK2.cmake
deleted file mode 100644
index d538ca3e8..000000000
--- a/cmake/FindGTK2.cmake
+++ /dev/null
@@ -1,471 +0,0 @@
-# - Try to find GTK2
-# Once done this will define
-#
-# GTK2_FOUND - System has Boost
-# GTK2_INCLUDE_DIRS - GTK2 include directory
-# GTK2_LIBRARIES - Link these to use GTK2
-# GTK2_LIBRARY_DIRS - The path to where the GTK2 library files are.
-# GTK2_DEFINITIONS - Compiler switches required for using GTK2
-#
-# Copyright (c) 2007 Andreas Schneider <mail@cynapses.org>
-#
-# Redistribution and use is allowed according to the terms of the New
-# BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-#
-
-# Set GTK2_DEBUG to enable debug output.
-macro(GTK2_DEBUG_MESSAGE _message)
- if (GTK2_DEBUG)
- message(STATUS "(DEBUG) ${_message}")
- endif (GTK2_DEBUG)
-endmacro(GTK2_DEBUG_MESSAGE _message)
-
-if (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
- # in cache already
- set(GTK2_FOUND TRUE)
-else (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
-
- # use pkg-config to get the directories and then use these values
- # in the FIND_PATH() and FIND_LIBRARY() calls
- include(UsePkgConfig)
-
- pkgconfig(gtk+-2.0 _GTK2IncDir _GTK2LinkDir _GTK2LinkFlags _GTK2Cflags)
-
- find_path(GTK2_GTK_INCLUDE_DIR
- NAMES
- gtk/gtk.h
- PATHS
- $ENV{GTK2_HOME}
- ${_GTK2IncDir}
- ${_GTK2IncDir}/gtk-2.0
- /usr/include/gtk-2.0
- /usr/local/include/gtk-2.0
- /opt/include/gtk-2.0
- /opt/gnome/include/gtk-2.0
- /sw/include/gtk-2.0
- )
- gtk2_debug_message("GTK2_GTK_INCLUDE_DIR is ${GTK2_GTK_INCLUDE_DIR}")
-
- # Some Linux distributions (e.g. Red Hat) have glibconfig.h
- # and glib.h in different directories, so we need to look
- # for both.
- # - Atanas Georgiev <atanas@cs.columbia.edu>
- pkgconfig(glib-2.0 _GLIB2IncDir _GLIB2LinkDir _GLIB2LinkFlags _GLIB2Cflags)
- pkgconfig(gmodule-2.0 _GMODULE2IncDir _GMODULE2LinkDir _GMODULE2LinkFlags _GMODULE2Cflags)
-
- find_path(GTK2_GLIBCONFIG_INCLUDE_DIR
- NAMES
- glibconfig.h
- PATHS
- ${_GLIB2IncDir}
- ${_GMODULE2IncDir}
- ${_GMODULE2IncDir}/glib-2.0
- ${_GLIB2LinkDir}/glib-2.0/include
- /opt/gnome/lib64/glib-2.0/include
- /opt/gnome/lib/glib-2.0/include
- /opt/lib/glib-2.0/include
- /usr/lib64/glib-2.0/include
- /usr/lib/glib-2.0/include
- /sw/lib/glib-2.0/include
- )
- gtk2_debug_message("GTK2_GLIBCONFIG_INCLUDE_DIR is ${GTK2_GLIBCONFIG_INCLUDE_DIR}")
-
- find_path(GTK2_GLIB_INCLUDE_DIR
- NAMES
- glib.h
- PATHS
- ${_GLIB2IncDir}
- ${_GLIB2IncDir}/glib-2.0
- ${_GMODULE2IncDir}
- /opt/include/glib-2.0
- /opt/gnome/include/glib-2.0
- /usr/include/glib-2.0
- /sw/include/glib-2.0
- )
- gtk2_debug_message("GTK2_GLIB_INCLUDE_DIR is ${GTK2_GLIB_INCLUDE_DIR}")
-
- pkgconfig(gdk-2.0 _GDK2IncDir _GDK2LinkDir _GDK2LinkFlags _GDK2Cflags)
-
- find_path(GTK2_GDK_INCLUDE_DIR
- NAMES
- gdkconfig.h
- PATHS
- ${_GDK2IncDir}
- ${_GDK2IncDir}/gtk-2.0
- ${_GDK2LinkDir}/gtk-2.0/include
- /opt/gnome/lib/gtk-2.0/include
- /opt/gnome/lib64/gtk-2.0/include
- /opt/lib/gtk-2.0/include
- /usr/lib/gtk-2.0/include
- /usr/lib64/gtk-2.0/include
- /sw/lib/gtk-2.0/include
- )
- gtk2_debug_message("GTK2_GDK_INCLUDE_DIR is ${GTK2_GDK_INCLUDE_DIR}")
-
- find_path(GTK2_GTKGL_INCLUDE_DIR
- NAMES
- gtkgl/gtkglarea.h
- PATHS
- ${_GLIB2IncDir}
- /usr/include
- /usr/local/include
- /usr/openwin/share/include
- /opt/gnome/include
- /opt/include
- /sw/include
- )
- gtk2_debug_message("GTK2_GTKGL_INCLUDE_DIR is ${GTK2_GTKGL_INCLUDE_DIR}")
-
- pkgconfig(pango _PANGOIncDir _PANGOLinkDir _PANGOLinkFlags _PANGOCflags)
-
- find_path(GTK2_PANGO_INCLUDE_DIR
- NAMES
- pango/pango.h
- PATHS
- ${_PANGOIncDir}
- ${_PANGOIncDir}/pango-1.0/
- /usr/include/pango-1.0
- /opt/gnome/include/pango-1.0
- /opt/include/pango-1.0
- /sw/include/pango-1.0
- )
- gtk2_debug_message("GTK2_PANGO_INCLUDE_DIR is ${GTK2_PANGO_INCLUDE_DIR}")
-
- pkgconfig(cairo _CAIROIncDir _CAIROLinkDir _CAIROLinkFlags _CAIROCflags)
-
- find_path(GTK2_CAIRO_INCLUDE_DIR
- NAMES
- cairo.h
- PATHS
- ${_CAIROIncDir}
- ${_CAIROIncDir}/cairo
- /opt/gnome/include/cairo
- /usr/include
- /usr/include/cairo
- /opt/include
- /opt/include/cairo
- /sw/include
- /sw/include/cairo
- )
- gtk2_debug_message("GTK2_CAIRO_INCLUDE_DIR is ${GTK2_CAIRO_INCLUDE_DIR}")
-
- pkgconfig(gdk-pixbuf-2.0 _GDKPIXBUFIncDir _GDKPIXBUFLinkDir _GDKPIXBUFLinkFlags _GDKPIXBUFCflags)
-
- find_path(GTK2_GDKPIXBUF_INCLUDE_DIR
- NAMES
- gdk-pixbuf/gdk-pixbuf.h
- PATHS
- ${_GDKPIXBUFIncDir}
- ${_GDKPIXBUFIncDir}/gdk-pixbuf-2.0
- /opt/gnome/include/cairo
- /usr/include
- /usr/include/cairo
- /opt/include
- /opt/include/cairo
- /sw/include
- /sw/include/cairo
- /sw/include/gdk-pixbuf-2.0
- )
- gtk2_debug_message("GTK2_CAIRO_INCLUDE_DIR is ${GTK2_CAIRO_INCLUDE_DIR}")
-
- pkgconfig(atk _ATKIncDir _ATKLinkDir _ATKLinkFlags _ATKCflags)
-
- find_path(GTK2_ATK_INCLUDE_DIR
- NAMES
- atk/atk.h
- PATHS
- ${_ATKIncDir}
- ${_ATKIncDir}/atk-1.0
- /opt/gnome/include/atk-1.0
- /usr/include/atk-1.0
- /opt/include/atk-1.0
- /sw/include/atk-1.0
- )
- gtk2_debug_message("GTK2_ATK_INCLUDE_DIR is ${GTK2_ATK_INCLUDE_DIR}")
- if (UNIX)
- find_library(GTK2_GTK_LIBRARY
- NAMES
- gtk-x11-2.0
- PATHS
- ${_GTK2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_GTK_LIBRARY is ${GTK2_GTK_LIBRARY}")
-
- find_library(GTK2_GDK_LIBRARY
- NAMES
- gdk-x11-2.0
- PATHS
- ${_GDK2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_GDK_LIBRARY is ${GTK2_GDK_LIBRARY}")
- endif(UNIX)
- if (WIN32)
-
- find_library(GTK2_GTK_LIBRARY
- NAMES
- gtk-win32-2.0
- PATHS
- ${_GTK2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_GTK_LIBRARY is ${GTK2_GTK_LIBRARY}")
-
- find_library(GTK2_GDK_LIBRARY
- NAMES
- gdk-win32-2.0
- PATHS
- ${_GDK2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- endif (WIN32)
- find_library(GTK2_GDK_PIXBUF_LIBRARY
- NAMES
- gdk_pixbuf-2.0
- PATHS
- ${_GDK2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_GDK_PIXBUF_LIBRARY is ${GTK2_GDK_PIXBUF_LIBRARY}")
-
- find_library(GTK2_GMODULE_LIBRARY
- NAMES
- gmodule-2.0
- PATHS
- ${_GMODULE2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_GMODULE_LIBRARY is ${GTK2_GMODULE_LIBRARY}")
-
- find_library(GTK2_GTHREAD_LIBRARY
- NAMES
- gthread-2.0
- PATHS
- ${_GTK2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_GTHREAD_LIBRARY is ${GTK2_GTHREAD_LIBRARY}")
-
- find_library(GTK2_GOBJECT_LIBRARY
- NAMES
- gobject-2.0
- PATHS
- ${_GTK2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_GOBJECT_LIBRARY is ${GTK2_GOBJECT_LIBRARY}")
-
- find_library(GTK2_GLIB_LIBRARY
- NAMES
- glib-2.0
- PATHS
- ${_GLIB2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_GLIB_LIBRARY is ${GTK2_GLIB_LIBRARY}")
-
- find_library(GTK2_GTKGL_LIBRARY
- NAMES
- gtkgl
- PATHS
- ${_GTK2LinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_GTKGL_LIBRARY is ${GTK2_GTKGL_LIBRARY}")
-
- find_library(GTK2_PANGO_LIBRARY
- NAMES
- pango-1.0
- PATHS
- ${_PANGOLinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_PANGO_LIBRARY is ${GTK2_PANGO_LIBRARY}")
-
- find_library(GTK2_CAIRO_LIBRARY
- NAMES
- pangocairo-1.0
- PATHS
- ${_CAIROLinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_PANGO_LIBRARY is ${GTK2_CAIRO_LIBRARY}")
-
- find_library(GTK2_ATK_LIBRARY
- NAMES
- atk-1.0
- PATHS
- ${_ATKinkDir}
- /usr/lib
- /usr/local/lib
- /usr/openwin/lib
- /usr/X11R6/lib
- /opt/gnome/lib
- /opt/lib
- /sw/lib
- )
- gtk2_debug_message("GTK2_ATK_LIBRARY is ${GTK2_ATK_LIBRARY}")
-
- set(GTK2_INCLUDE_DIRS
- ${GTK2_GTK_INCLUDE_DIR}
- ${GTK2_GLIBCONFIG_INCLUDE_DIR}
- ${GTK2_GLIB_INCLUDE_DIR}
- ${GTK2_GDK_INCLUDE_DIR}
- ${GTK2_PANGO_INCLUDE_DIR}
- ${GTK2_CAIRO_INCLUDE_DIR}
- ${GTK2_ATK_INCLUDE_DIR}
- )
-
- if(GTK2_GDKPIXBUF_INCLUDE_DIR)
- set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS} ${GTK2_GDKPIXBUF_INCLUDE_DIR})
- endif(GTK2_GDKPIXBUF_INCLUDE_DIR)
-
- if (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
- if (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR)
- if (GTK2_GMODULE_LIBRARY)
- if (GTK2_GTHREAD_LIBRARY)
- if (GTK2_GOBJECT_LIBRARY)
- if (GTK2_PANGO_LIBRARY AND GTK2_PANGO_INCLUDE_DIR)
- if (GTK2_CAIRO_LIBRARY AND GTK2_CAIRO_INCLUDE_DIR)
- if (GTK2_ATK_LIBRARY AND GTK2_ATK_INCLUDE_DIR)
-
- # set GTK2 libraries
- set (GTK2_LIBRARIES
- ${GTK2_GTK_LIBRARY}
- ${GTK2_GDK_LIBRARY}
- ${GTK2_GDK_PIXBUF_LIBRARY}
- ${GTK2_GMODULE_LIBRARY}
- ${GTK2_GTHREAD_LIBRARY}
- ${GTK2_GOBJECT_LIBRARY}
- ${GTK2_PANGO_LIBRARY}
- ${GTK2_CAIRO_LIBRARY}
- ${GTK2_ATK_LIBRARY}
- )
-
- # check for gtkgl support
- if (GTK2_GTKGL_LIBRARY AND GTK2_GTKGL_INCLUDE_DIR)
- set(GTK2_GTKGL_FOUND TRUE)
-
-# set(GTK2_INCLUDE_DIRS
-# ${GTK2_INCLUDE_DIRS}
-# ${GTK2_GTKGL_INCLUDE_DIR}
-# )
-
-# set(GTK2_LIBRARIES
-# ${GTK2_LIBRARIES}
-# ${GTK2_GTKGL_LIBRARY}
-# )
- endif (GTK2_GTKGL_LIBRARY AND GTK2_GTKGL_INCLUDE_DIR)
-
- else (GTK2_ATK_LIBRARY AND GTK2_ATK_INCLUDE_DIR)
- endif (GTK2_ATK_LIBRARY AND GTK2_ATK_INCLUDE_DIR)
- else (GTK2_CAIRO_LIBRARY AND GTK2_CAIRO_INCLUDE_DIR)
- endif (GTK2_CAIRO_LIBRARY AND GTK2_CAIRO_INCLUDE_DIR)
- else (GTK2_PANGO_LIBRARY AND GTK2_PANGO_INCLUDE_DIR)
- endif (GTK2_PANGO_LIBRARY AND GTK2_PANGO_INCLUDE_DIR)
- else (GTK2_GOBJECT_LIBRARY)
- endif (GTK2_GOBJECT_LIBRARY)
- else (GTK2_GTHREAD_LIBRARY)
- endif (GTK2_GTHREAD_LIBRARY)
- else (GTK2_GMODULE_LIBRARY)
- endif (GTK2_GMODULE_LIBRARY)
- else (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR)
- endif (GTK2_GDK_LIBRARY AND GTK2_GDK_PIXBUF_LIBRARY AND GTK2_GDK_INCLUDE_DIR)
- else (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
- endif (GTK2_GTK_LIBRARY AND GTK2_GTK_INCLUDE_DIR)
-
-
- if (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES)
- set(GTK2_FOUND TRUE)
- endif (GTK2_INCLUDE_DIRS AND GTK2_LIBRARIES)
-
- if (GTK2_FOUND)
- if (NOT GTK2_FIND_QUIETLY)
- message(STATUS "Found GTK2: ${GTK2_LIBRARIES}")
- endif (NOT GTK2_FIND_QUIETLY)
- else (GTK2_FOUND)
- if (GTK2_FIND_REQUIRED)
- message(FATAL_ERROR "Could not find GTK2")
- endif (GTK2_FIND_REQUIRED)
- endif (GTK2_FOUND)
-
- # show the GTK2_INCLUDE_DIRS and GTK2_LIBRARIES variables only in the advanced view
- mark_as_advanced(GTK2_INCLUDE_DIRS GTK2_LIBRARIES)
-
-
-endif (GTK2_LIBRARIES AND GTK2_INCLUDE_DIRS)
-
diff --git a/cmake/FindGlib.cmake b/cmake/FindGlib.cmake
deleted file mode 100644
index 43414ff54..000000000
--- a/cmake/FindGlib.cmake
+++ /dev/null
@@ -1,39 +0,0 @@
-# - Try to find Glib-2.0 (with gobject)
-# Once done, this will define
-#
-# Glib_FOUND - system has Glib
-# Glib_INCLUDE_DIRS - the Glib include directories
-# Glib_LIBRARIES - link these to use Glib
-
-include(LibFindMacros)
-
-# Use pkg-config to get hints about paths
-libfind_pkg_check_modules(Glib_PKGCONF glib-2.0)
-
-# Main include dir
-find_path(Glib_INCLUDE_DIR
- NAMES glib.h
- PATHS ${Glib_PKGCONF_INCLUDE_DIRS} /sw/include
- PATH_SUFFIXES glib-2.0
-)
-
-# Glib-related libraries also use a separate config header, which is in lib dir
-find_path(GlibConfig_INCLUDE_DIR
- NAMES glibconfig.h
- PATHS ${Glib_PKGCONF_INCLUDE_DIRS} /usr /sw
- PATH_SUFFIXES lib/glib-2.0/include
-)
-
-# Finally the library itself
-find_library(Glib_LIBRARY
- NAMES glib-2.0
- PATHS ${Glib_PKGCONF_LIBRARY_DIRS} /sw/lib
-)
-
-# Set the include dir variables and the libraries and let libfind_process do the rest.
-# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
-set(Glib_PROCESS_INCLUDES Glib_INCLUDE_DIR GlibConfig_INCLUDE_DIR)
-set(Glib_PROCESS_LIBS Glib_LIBRARY)
-libfind_process(Glib)
-
-
diff --git a/cmake/FindGmodule.cmake b/cmake/FindGmodule.cmake
deleted file mode 100644
index 2d5ddd0bb..000000000
--- a/cmake/FindGmodule.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# - Try to find Glib-2.0 (with gobject)
-# Once done, this will define
-#
-# Glib_FOUND - system has Glib
-# Glib_INCLUDE_DIRS - the Glib include directories
-# Glib_LIBRARIES - link these to use Glib
-
-include(LibFindMacros)
-
-libfind_pkg_check_modules(Gmodule_PKGCONF gmodule-2.0)
-# Main include dir
-find_path(Gmodule_INCLUDE_DIR
- NAMES gmodule.h
- PATHS ${Gmodule_PKGCONF_INCLUDE_DIRS}
- PATH_SUFFIXES gmodule-2.0
-)
-
-# Finally the modulerary itself
-find_library(Gmodule_LIBRARY
- NAMES gmodule-2.0
- PATHS ${Gmodule_PKGCONF_LIBRARY_DIRS}
-)
-
-# Set the include dir variables and the libraries and let libfind_process do the rest.
-# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
-set(Gmodule_PROCESS_INCLUDES Gmodule_INCLUDE_DIR)
-set(Gmodule_PROCESS_LIBS Gmodule_LIBRARY)
-libfind_process(Gmodule)
diff --git a/cmake/FindProtobuf-c.cmake b/cmake/FindProtobuf-c.cmake
new file mode 100644
index 000000000..170c1a03d
--- /dev/null
+++ b/cmake/FindProtobuf-c.cmake
@@ -0,0 +1,121 @@
+# Locate and configure the Google Protocol Buffers library.
+# Defines the following variables:
+#
+# PROTOBUF_C_FOUND - Found the Google Protocol Buffers library
+# PROTOBUF_C_INCLUDE_DIRS - Include directories for Google Protocol Buffers
+# PROTOBUF_C_LIBRARIES - The protobuf library
+#
+# The following cache variables are also defined:
+# PROTOBUF_C_LIBRARY - The protobuf library
+# PROTOBUF_C_PROTOC_LIBRARY - The protoc library
+# PROTOBUF_C_INCLUDE_DIR - The include directory for protocol buffers
+# PROTOBUF_C_PROTOC_EXECUTABLE - The protoc compiler
+#
+# ====================================================================
+# Example:
+#
+# find_package(Protobuf-c REQUIRED)
+# include_directories(${PROTOBUF_C_INCLUDE_DIRS})
+#
+# include_directories(${CMAKE_CURRENT_BINARY_DIR})
+# PROTOBUF_C_GENERATE_C(PROTO_SRCS PROTO_HDRS foo.proto)
+# add_executable(bar bar.c ${PROTO_SRCS} ${PROTO_HDRS})
+# target_link_libraries(bar ${PROTOBUF_C_LIBRARY})
+#
+# NOTE: You may need to link against pthreads, depending
+# on the platform.
+# ====================================================================
+#
+# PROTOBUF_C_GENERATE_C (public function)
+# SRCS = Variable to define with autogenerated
+# source files
+# HDRS = Variable to define with autogenerated
+# header files
+# ARGN = proto files
+#
+# ====================================================================
+
+
+#=============================================================================
+# Copyright 2009 Kitware, Inc.
+# Copyright 2009 Philip Lowman <philip@yhbt.com>
+# Copyright 2008 Esben Mose Hansen, Ange Optimization ApS
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distributed this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+function(PROTOBUF_C_GENERATE_C SRCS HDRS)
+ if(NOT ARGN)
+ message(SEND_ERROR "Error: PROTOBUF_C_GENERATE_C() called without any proto files")
+ return()
+ endif(NOT ARGN)
+
+ set(${SRCS})
+ set(${HDRS})
+ foreach(FIL ${ARGN})
+ get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
+ get_filename_component(FIL_WE ${FIL} NAME_WE)
+
+ list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb-c.c")
+ list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb-c.h")
+
+ add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb-c.c"
+ "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb-c.h"
+ COMMAND ${PROTOBUF_C_PROTOC_EXECUTABLE}
+ ARGS --c_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL}
+ DEPENDS ${ABS_FIL}
+ COMMENT "Running C protocol buffer compiler on ${FIL}"
+ VERBATIM )
+ endforeach()
+
+ set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
+ set(${SRCS} ${${SRCS}} PARENT_SCOPE)
+ set(${HDRS} ${${HDRS}} PARENT_SCOPE)
+endfunction()
+
+
+find_path(PROTOBUF_C_INCLUDE_DIR google/protobuf-c/protobuf-c.h)
+
+# Google's provided vcproj files generate libraries with a "lib"
+# prefix on Windows
+if(WIN32)
+ set(PROTOBUF_C_ORIG_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
+ set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
+endif()
+
+find_library(PROTOBUF_C_LIBRARY NAMES protobuf-c
+ DOC "The Google Protocol Buffers Library"
+)
+find_library(PROTOBUF_C_PROTOC_LIBRARY NAMES protoc-c
+ DOC "The Google Protocol Buffers Compiler Library"
+)
+find_program(PROTOBUF_C_PROTOC_EXECUTABLE NAMES protoc-c
+ DOC "The Google Protocol Buffers Compiler"
+)
+
+mark_as_advanced(PROTOBUF_C_INCLUDE_DIR
+ PROTOBUF_C_LIBRARY
+ PROTOBUF_C_PROTOC_LIBRARY
+ PROTOBUF_C_PROTOC_EXECUTABLE)
+
+# Restore original find library prefixes
+if(WIN32)
+ set(CMAKE_FIND_LIBRARY_PREFIXES "${PROTOBUF_C_ORIG_FIND_LIBRARY_PREFIXES}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF_C DEFAULT_MSG
+ PROTOBUF_C_LIBRARY PROTOBUF_C_INCLUDE_DIR)
+
+if(PROTOBUF_C_FOUND)
+ set(PROTOBUF_C_INCLUDE_DIRS ${PROTOBUF_C_INCLUDE_DIR})
+ set(PROTOBUF_C_LIBRARIES ${PROTOBUF_C_LIBRARY})
+endif()
diff --git a/cmake/Findespeak.cmake b/cmake/Findespeak.cmake
deleted file mode 100644
index 6d390a9a8..000000000
--- a/cmake/Findespeak.cmake
+++ /dev/null
@@ -1,29 +0,0 @@
-# - Try to find espeak (with libespeak)
-# Once done, this will define
-#
-# espeak_FOUND - system has Glib
-# espeak_INCLUDE_DIRS - the Glib include directories
-# espeak_LIBRARIES - link these to use Glib
-
-include(LibFindMacros)
-
-# espeak-related libraries
-find_path(espeak_INCLUDE_DIR
- NAMES speak_lib.h
- PATHS /usr /sw/include
- PATH_SUFFIXES espeak
-)
-
-# Finally the library itself
-find_library(espeak_LIBRARY
- NAMES libespeak.so libespeak.a
- PATHS /sw/lib
-)
-
-# Set the include dir variables and the libraries and let libfind_process do the rest.
-# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
-set(espeak_PROCESS_INCLUDES espeak_INCLUDE_DIR)
-set(espeak_PROCESS_LIBS espeak_LIBRARY)
-libfind_process(espeak)
-
-
diff --git a/cmake/LibFindMacros.cmake b/cmake/LibFindMacros.cmake
deleted file mode 100644
index 69975c51b..000000000
--- a/cmake/LibFindMacros.cmake
+++ /dev/null
@@ -1,99 +0,0 @@
-# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
-# used for the current package. For this to work, the first parameter must be the
-# prefix of the current package, then the prefix of the new package etc, which are
-# passed to find_package.
-macro (libfind_package PREFIX)
- set (LIBFIND_PACKAGE_ARGS ${ARGN})
- if (${PREFIX}_FIND_QUIETLY)
- set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
- endif (${PREFIX}_FIND_QUIETLY)
- if (${PREFIX}_FIND_REQUIRED)
- set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
- endif (${PREFIX}_FIND_REQUIRED)
- find_package(${LIBFIND_PACKAGE_ARGS})
-endmacro (libfind_package)
-
-# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
-# where they added pkg_check_modules. Consequently I need to support both in my scripts
-# to avoid those deprecated warnings. Here's a helper that does just that.
-# Works identically to pkg_check_modules, except that no checks are needed prior to use.
-macro (libfind_pkg_check_modules PREFIX PKGNAME)
- if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
- include(UsePkgConfig)
- pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
- else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
- find_package(PkgConfig)
- if (PKG_CONFIG_FOUND)
- pkg_check_modules(${PREFIX} ${PKGNAME})
- endif (PKG_CONFIG_FOUND)
- endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
-endmacro (libfind_pkg_check_modules)
-
-# Do the final processing once the paths have been detected.
-# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
-# all the variables, each of which contain one include directory.
-# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
-# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
-# Also handles errors in case library detection was required, etc.
-macro (libfind_process PREFIX)
- # Skip processing if already processed during this run
- if (NOT ${PREFIX}_FOUND)
- # Start with the assumption that the library was found
- set (${PREFIX}_FOUND TRUE)
-
- # Process all includes and set _FOUND to false if any are missing
- foreach (i ${${PREFIX}_PROCESS_INCLUDES})
- if (${i})
- set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
- mark_as_advanced(${i})
- else (${i})
- set (${PREFIX}_FOUND FALSE)
- endif (${i})
- endforeach (i)
-
- # Process all libraries and set _FOUND to false if any are missing
- foreach (i ${${PREFIX}_PROCESS_LIBS})
- if (${i})
- set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
- mark_as_advanced(${i})
- else (${i})
- set (${PREFIX}_FOUND FALSE)
- endif (${i})
- endforeach (i)
-
- # Print message and/or exit on fatal error
- if (${PREFIX}_FOUND)
- if (NOT ${PREFIX}_FIND_QUIETLY)
- message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
- endif (NOT ${PREFIX}_FIND_QUIETLY)
- else (${PREFIX}_FOUND)
- if (${PREFIX}_FIND_REQUIRED)
- foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
- message("${i}=${${i}}")
- endforeach (i)
- message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
- endif (${PREFIX}_FIND_REQUIRED)
- endif (${PREFIX}_FOUND)
- endif (NOT ${PREFIX}_FOUND)
-endmacro (libfind_process)
-
-macro(libfind_library PREFIX basename)
- set(TMP "")
- if(MSVC80)
- set(TMP -vc80)
- endif(MSVC80)
- if(MSVC90)
- set(TMP -vc90)
- endif(MSVC90)
- set(${PREFIX}_LIBNAMES ${basename}${TMP})
- if(${ARGC} GREATER 2)
- set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
- string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
- set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
- endif(${ARGC} GREATER 2)
- find_library(${PREFIX}_LIBRARY
- NAMES ${${PREFIX}_LIBNAMES}
- PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
- )
-endmacro(libfind_library)
-
diff --git a/cmake/copy_files.cmake b/cmake/copy_files.cmake
index f9dca52f6..03ad8d14f 100644
--- a/cmake/copy_files.cmake
+++ b/cmake/copy_files.cmake
@@ -7,9 +7,10 @@ if ( SRC_FILES )
if ( LOWER )
get_filename_component(FILEN_NAME ${FILE} NAME)
string(TOLOWER ${FILEN_NAME} FILEN_NAME_LOWER)
- execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE} ${DST}/${FILEN_NAME_LOWER})
+ file(COPY ${FILE} DESTINATION ${DST}/)
+ file(RENAME ${DST}/${FILEN_NAME} ${DST}/${FILEN_NAME_LOWER})
else()
- execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE} ${DST}/)
+ file(COPY ${FILE} DESTINATION ${DST})
endif( LOWER )
endforeach()
endif()
diff --git a/cmake/navit_macros.cmake b/cmake/navit_macros.cmake
index eb1f3fc7c..88f2dc3cf 100644
--- a/cmake/navit_macros.cmake
+++ b/cmake/navit_macros.cmake
@@ -53,18 +53,18 @@ macro(add_module_plugin PLUGIN_PATH REASON ENABLE)
endmacro()
macro(module_add_library MODULE_NAME )
- LINK_DIRECTORIES(${${MODULE_NAME}_LIBRARY_DIRS})
+ LINK_DIRECTORIES(${${MODULE_NAME}_LIBRARY_DIRS})
add_library(${MODULE_NAME} ${MODULE_BUILD_TYPE} ${ARGN})
SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES COMPILE_DEFINITIONS "MODULE=${MODULE_NAME}")
TARGET_LINK_LIBRARIES(${MODULE_NAME} ${${MODULE_NAME}_LIBS})
SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES COMPILE_FLAGS "${NAVIT_COMPILE_FLAGS} ${${MODULE_NAME}_FLAGS}")
- INCLUDE_DIRECTORIES(${${MODULE_NAME}_INCLUDES})
+ INCLUDE_DIRECTORIES(${${MODULE_NAME}_INCLUDES})
if (USE_PLUGINS)
if (ANDROID)
TARGET_LINK_LIBRARIES(${MODULE_NAME} ${NAVIT_LIBNAME})
endif()
if (APPLE)
- set_target_properties( ${MODULE_NAME} PROPERTIES LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup")
+ set_target_properties( ${MODULE_NAME} PROPERTIES LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup")
endif()
# workaround to be compatible with old paths
set_target_properties( ${MODULE_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.libs")
diff --git a/cmake/version.cmake b/cmake/version.cmake
deleted file mode 100755
index 8f82d9f61..000000000
--- a/cmake/version.cmake
+++ /dev/null
@@ -1,29 +0,0 @@
-FIND_PROGRAM(GIT_EXECUTABLE NAMES git git.exe DOC "git command line client")
-
-get_filename_component(SOURCE_DIR ${SRC} PATH)
-
-string(TIMESTAMP VERSION "%y%m%d%H%M")
-
-string(REGEX MATCH "[0-9]+" VERSION_NUM ${VERSION} )
-if(NOT VERSION_NUM)
- message(STATUS "I can't find a release tag. This is probably not Navit's official tree")
- message(STATUS "It's OK, I will default to 0000")
- set(VERSION_NUM "0000")
-endif()
-string(REPLACE "R" "" VERSION_NUM ${VERSION_NUM} )
-if(NOT VERSION_NUM)
- set(VERSION_NUM "0000")
-endif()
-
-string(REGEX MATCH "^[a-z0-9]+" VERSION ${VERSION} )
-
-if (STRIP_M)
- set(VERSION ${VERSION_NUM})
-endif()
-
-set(NAVIT_VARIANT "-")
-
-set(${NAME} ${VERSION})
-
-message (STATUS "Git commit: ${${NAME}}")
-CONFIGURE_FILE(${SRC} ${DST} @ONLY)
diff --git a/config.h.cmake b/config.h.in
index 270835dea..5ac8b8406 100644
--- a/config.h.cmake
+++ b/config.h.in
@@ -16,10 +16,17 @@
#cmakedefine USE_LIBGNUINTL 1
#cmakedefine HAVE_BYTESWAP_H 1
/* Versions */
+#cmakedefine GIT_VERSION "@GIT_VERSION@"
+#ifndef GIT_VERSION
+#define GIT_VERSION "xdevxgitxnotxfound"
+#endif
+
+#define NAVIT_VARIANT "-"
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
#cmakedefine PACKAGE "@PACKAGE@"
#cmakedefine LOCALEDIR "@LOCALEDIR@"
+#define NAVIT_VERSION PACKAGE_VERSION "+git:" GIT_VERSION NAVIT_VARIANT
#cmakedefine HAVE_ZLIB 1
@@ -94,4 +101,6 @@
#cmakedefine HAS_IFADDRS 1
+#cmakedefine HAVE_POSTGRESQL 1
+
#cmakedefine USE_AUDIO_FRAMEWORK 1
diff --git a/contrib/sailfish/build_on_sailfish_sdk.sh b/contrib/sailfish/build_on_sailfish_sdk.sh
index 663d31b48..4198f9924 100755
--- a/contrib/sailfish/build_on_sailfish_sdk.sh
+++ b/contrib/sailfish/build_on_sailfish_sdk.sh
@@ -1,7 +1,16 @@
#! /bin/sh
-#run on the Sailfish OS sdk virtual machine. Check that rpmbuild directory exists.
+#run on the Sailfish OS sdk virtual machine. Check that rpmbuild directory exists. Remember to export VERSION_ID
+
+# please don't mess around with those lines without testing,
+# even if some fancy tool tells you to do so to save some pipes.
+# -metalstrolch-
+
+if [ -z ${VERSION_ID+x} ]; then echo "VERSION_ID not set. Forgot to export VERSION_ID?"; exit 1; fi
+
#arm devices
-sb2 -t SailfishOS-armv7hl -m sdk-build rpmbuild --define "_topdir /home/src1/rpmbuild" --define "navit_source `pwd`/../.." -bb navit-sailfish.spec
+sb2 -t SailfishOS-${VERSION_ID}-armv7hl -m sdk-install -R zypper in $(grep "^BuildRequires: " navit-sailfish.spec | sed -e "s/BuildRequires: //")
+sb2 -t SailfishOS-${VERSION_ID}-armv7hl -m sdk-build rpmbuild --define "_topdir /home/src1/rpmbuild" --define "navit_source $(pwd)/../.." -bb navit-sailfish.spec
#intel devices
-sb2 -t SailfishOS-i486 -m sdk-build rpmbuild --define "_topdir /home/src1/rpmbuild" --define "navit_source `pwd`/../.." -bb navit-sailfish.spec
+sb2 -t SailfishOS-${VERSION_ID}-i486 -m sdk-install -R zypper in $(grep "^BuildRequires: " navit-sailfish.spec | sed -e "s/BuildRequires: //")
+sb2 -t SailfishOS-${VERSION_ID}-i486 -m sdk-build rpmbuild --define "_topdir /home/src1/rpmbuild" --define "navit_source $(pwd)/../.." -bb navit-sailfish.spec
diff --git a/contrib/sailfish/build_sailfish_ci.sh b/contrib/sailfish/build_sailfish_ci.sh
new file mode 100755
index 000000000..58d1022f3
--- /dev/null
+++ b/contrib/sailfish/build_sailfish_ci.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+#run on the Sailfish OS sdk docker container. Check that rpmbuild directory exists. Remember to export VERSION_ID
+# please don't mess around with those lines without testing,
+# even if some fancy tool tells you to do so to save some pipes.
+# -hoehnp-
+
+if [ -z ${VERSION_ID+x} ]; then echo "VERSION_ID not set. Forgot to export VERSION_ID?"; exit 1; fi
+
+# First we need to cd to the directory containing this script and the spec file.
+# Makes calling it directly from docker easier.
+SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
+cd $SCRIPTPATH
+ls -lah /navit
+mkdir $HOME/rpmbuild
+
+#arm devices
+sb2 -t SailfishOS-${VERSION_ID}-armv7hl -m sdk-install -R zypper --non-interactive in $(grep "^BuildRequires: " navit-sailfish.spec | sed -e "s/BuildRequires: //")
+sb2 -t SailfishOS-${VERSION_ID}-armv7hl -m sdk-build rpmbuild --define "_topdir /home/nemo/rpmbuild" --define "navit_source ${SCRIPTPATH}/../.." -bb navit-sailfish.spec
+#intel devices
+sb2 -t SailfishOS-${VERSION_ID}-i486 -m sdk-install -R zypper --non-interactive in $(grep "^BuildRequires: " navit-sailfish.spec | sed -e "s/BuildRequires: //")
+sb2 -t SailfishOS-${VERSION_ID}-i486 -m sdk-build rpmbuild --define "_topdir /home/nemo/rpmbuild" --define "navit_source ${SCRIPTPATH}/../.." -bb navit-sailfish.spec
+
diff --git a/contrib/sailfish/navit-sailfish.spec b/contrib/sailfish/navit-sailfish.spec
index a798aa487..4f14be872 100755
--- a/contrib/sailfish/navit-sailfish.spec
+++ b/contrib/sailfish/navit-sailfish.spec
@@ -9,13 +9,15 @@
Name: harbour-navit
Summary: Open Source car navigation system
#Version: %{navit_version}_%{git_version}
-Version: 0.5.1
-Release: 4
+Version: 0.5.3
+Release: 1
License: GPL
Group: Applications/Productivity
-URL: http://navit-projet.org/
+URL: http://navit-project.org/
-BuildRequires: gcc
+#git is vor version info while building
+BuildRequires: git
+#BuildRequires: gcc
BuildRequires: cmake
BuildRequires: glib2-devel
BuildRequires: gettext-devel
@@ -73,7 +75,7 @@ mkdir navit-build
%build
%define debug_package %{nil}
%{__rm} -rf %{buildroot}
-#cmake git files directly
+#cmake git files directly
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DPACKAGE:STRING=harbour-navit \
-DNAVIT_BINARY:STRING=harbour-navit \
@@ -97,7 +99,12 @@ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
%{navit_real_source}
%{__make}
-# -DMAN_DIR:PATH=share/harbour-navit/man1
+# -DMAN_DIR:PATH=share/harbour-navit/man1
+
+%pre
+if [ -d %{_datadir}/harbour-navit/espeak-data ]; then
+ rm -rf %{_datadir}/harbour-navit/espeak-data
+fi
%install
%make_install
@@ -107,6 +114,12 @@ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
%files
%defattr(644, root, root, 755)
%{_datadir}/harbour-navit/navit.xml
+%{_datadir}/harbour-navit/navit_layout_bike.xml
+%{_datadir}/harbour-navit/navit_layout_car.xml
+%{_datadir}/harbour-navit/navit_layout_car_android.xml
+%{_datadir}/harbour-navit/navit_layout_car_dark.xml
+%{_datadir}/harbour-navit/navit_layout_car_simple.xml
+%{_datadir}/harbour-navit/navit_layout_th.xml
%{_datadir}/harbour-navit/icons/
%{_datadir}/harbour-navit/maps/osm_bbox_11.3,47.9,11.7,48.2.bin
%{_datadir}/harbour-navit/espeak-data/
@@ -123,6 +136,29 @@ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
%changelog
+*Mon Oct 01 2018 metalstrolch 0.5.3-1
+- fix rpm updating from 0.5.1 by adding %pre section
+
+*Fri Aug 31 2018 metalstrolch 0.5.3-0
+
+Release 0.5.2 was missing the version number update in the CMakefile. This release fixes this.
+
+*Fri Aug 31 2018 metalstrolch 0.5.2-0
+
+This release has seen a big work on code quality and homogeneity.
+
+If you want to know what has changed see the Changelog at: https://github.com/navit-gps/navit/blob/v0.5.2/CHANGELOG.md
+
+For the full list of commits, see: v0.5.1...v0.5.2
+
+Please report issues at http://trac.navit-project.org or https://github.com/navit-gps/navit/issues
+The documentation can be found at http://navit.readthedocs.io/
+
+To get the latest builds, see: http://download.navit-project.org/
+
+*Tue Oct 17 2017 metalstrolch 0.5.1-5
+- Update upstream
+
*Tue Oct 17 2017 metalstrolch 0.5.1-4
- Fix medium GUI icon size to cope with changed icon set on upstream
- Update upstream
@@ -139,7 +175,7 @@ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
*Mon Apr 10 2017 metalstrolch 0.5.1-1
- Almost harbour valid
-*Mon Dec 14 2015 metalstrolch 0.5.1-0
+*Mon Dec 14 2015 metalstrolch 0.5.1-0
- Initial sailfish release
- Initial package.
diff --git a/contrib/tomtom/espeakdsp.c b/contrib/tomtom/espeakdsp.c
index bd6689a1f..0078c3960 100644
--- a/contrib/tomtom/espeakdsp.c
+++ b/contrib/tomtom/espeakdsp.c
@@ -14,88 +14,79 @@
#define MAXARGC 30
-int main(int argc, char *argv[],char *envp[])
-{
- int pipefd[2];
- pid_t cpid;
- char buf;
- int co,wp,l,fh;
- short bufi[IBUFFERLEN],bufo[IBUFFERLEN*2];
- int rate=22050;
+int main(int argc, char *argv[],char *envp[]) {
+ int pipefd[2];
+ pid_t cpid;
+ char buf;
+ int co,wp,l,fh;
+ short bufi[IBUFFERLEN],bufo[IBUFFERLEN*2];
+ int rate=22050;
- char *newargv[MAXARGC+2];
+ char *newargv[MAXARGC+2];
- for(co=0;co<argc;co++)
- {
- if(co>=MAXARGC)break;
- newargv[co]=argv[co];
- }
- newargv[co++]="--stdout";
- newargv[co++]=NULL;
+ for(co=0; co<argc; co++) {
+ if(co>=MAXARGC)break;
+ newargv[co]=argv[co];
+ }
+ newargv[co++]="--stdout";
+ newargv[co++]=NULL;
- if (pipe(pipefd) == -1)
- {
- perror("pipe");
- exit(EXIT_FAILURE);
- }
+ if (pipe(pipefd) == -1) {
+ perror("pipe");
+ exit(EXIT_FAILURE);
+ }
- if(setpriority(PRIO_PROCESS,0,-10))
- perror ("setpriority");
+ if(setpriority(PRIO_PROCESS,0,-10))
+ perror ("setpriority");
- cpid = fork();
- if (cpid == -1)
- {
- perror("fork");
- exit(EXIT_FAILURE);
- }
+ cpid = fork();
+ if (cpid == -1) {
+ perror("fork");
+ exit(EXIT_FAILURE);
+ }
- if (cpid == 0)
- { /* Child writes to pipe */
+ if (cpid == 0) {
+ /* Child writes to pipe */
- close(pipefd[0]); /* Close unused read end */
- dup2(pipefd[1],1);
- execve(espeakpath,newargv,envp);
- perror(espeakpath);
- close(pipefd[1]); /* Reader will see EOF */
- wait(NULL); /* Wait for child */
- exit(EXIT_SUCCESS);
+ close(pipefd[0]); /* Close unused read end */
+ dup2(pipefd[1],1);
+ execve(espeakpath,newargv,envp);
+ perror(espeakpath);
+ close(pipefd[1]); /* Reader will see EOF */
+ wait(NULL); /* Wait for child */
+ exit(EXIT_SUCCESS);
- } else { /* Parent read from pipe */
+ } else { /* Parent read from pipe */
- close(pipefd[1]); /* Close unused write end */
+ close(pipefd[1]); /* Close unused write end */
- l=read(pipefd[0],bufi,64);
- if(memcmp(bufi,"RIFF",4))
- {
- while(l>0)
- {
- write(1,bufi,l);
- l=read(pipefd[0],bufi,IBUFFERLEN);
- }
- exit(EXIT_SUCCESS);
- }
- l=read(pipefd[0],bufi,IBUFFERLEN);
+ l=read(pipefd[0],bufi,64);
+ if(memcmp(bufi,"RIFF",4)) {
+ while(l>0) {
+ write(1,bufi,l);
+ l=read(pipefd[0],bufi,IBUFFERLEN);
+ }
+ exit(EXIT_SUCCESS);
+ }
+ l=read(pipefd[0],bufi,IBUFFERLEN);
- fh=open("/dev/dsp",O_WRONLY);
- if(fh<0)
- {
- perror("open /dev/dsp");
- exit(EXIT_FAILURE);
- }
- ioctl(fh, SNDCTL_DSP_SPEED , &rate);
- ioctl(fh, SNDCTL_DSP_SYNC, 0);
- while(l)
- {
- for(co=0,wp=0;(co<IBUFFERLEN)&&(co<l);co++)
- {
- bufo[wp++]=bufi[co]; /* mono->stereo */
- bufo[wp++]=bufi[co];
- }
- write (fh,bufo,wp);
- l=read(pipefd[0],bufi,IBUFFERLEN);
- }
- ioctl(fh, SNDCTL_DSP_SYNC, 0);
- close(pipefd[0]);
- exit(EXIT_SUCCESS);
- }
+ fh=open("/dev/dsp",O_WRONLY);
+ if(fh<0) {
+ perror("open /dev/dsp");
+ exit(EXIT_FAILURE);
+ }
+ ioctl(fh, SNDCTL_DSP_SPEED, &rate);
+ ioctl(fh, SNDCTL_DSP_SYNC, 0);
+ while(l) {
+ for(co=0,wp=0; (co<IBUFFERLEN)&&(co<l); co++) {
+ bufo[wp++]=bufi[co]; /* mono->stereo */
+ bufo[wp++]=bufi[co];
+ }
+ write (fh,bufo,wp);
+ l=read(pipefd[0],bufi,IBUFFERLEN);
+ }
+ ioctl(fh, SNDCTL_DSP_SYNC, 0);
+ close(pipefd[0]);
+ exit(EXIT_SUCCESS);
+ }
}
diff --git a/gradle/scripts/git-scm-version.gradle b/gradle/scripts/git-scm-version.gradle
new file mode 100644
index 000000000..a0d518a86
--- /dev/null
+++ b/gradle/scripts/git-scm-version.gradle
@@ -0,0 +1,24 @@
+//THX to https://proandroiddev.com/configuring-android-project-version-name-code-b168952f3323
+
+buildscript {
+ repositories {
+ jcenter()
+ }
+ dependencies {
+ classpath 'org.ajoberstar:grgit:2.3.0'
+ }
+}
+
+import org.ajoberstar.grgit.Grgit
+import java.time.format.DateTimeFormatter
+
+ext {
+ git = Grgit.open(currentDir: projectDir)
+ gitVersionName = git.describe(match: ["v[0-9.rc]*"])
+ gitVersionCode = Integer.parseInt(DateTimeFormatter.ofPattern("yyMMddhhmm").format(git.head().dateTime))
+}
+
+task printVersion() {
+ println("Version Name: $gitVersionName")
+ println("Version Code: $gitVersionCode")
+}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..13372aef5
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..73bb13d55
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 000000000..9d82f7891
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 000000000..aec99730b
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt
index 886dc1227..5c0b6c90a 100644
--- a/man/CMakeLists.txt
+++ b/man/CMakeLists.txt
@@ -1,5 +1,5 @@
INSTALL(FILES maptool.1 DESTINATION ${MAN_DIR})
if(NOT DEFINED NAVIT_BINARY)
- set(NAVIT_BINARY navit)
-endif()
+ set(NAVIT_BINARY navit)
+endif()
INSTALL(FILES navit.1 DESTINATION ${MAN_DIR} RENAME ${NAVIT_BINARY}.1)
diff --git a/man/navit.1 b/man/navit.1
index 5deed88d6..df1f0a33d 100644
--- a/man/navit.1
+++ b/man/navit.1
@@ -23,7 +23,7 @@ destination, but also generates directions and even speaks to you.
Navit is translated in more than 40 languages currently, please see https://translations.launchpad.net/navit/trunk
-For more informations, please refer to our wiki :
+For more information, please refer to our wiki :
http://wiki.navit-project.org
You can also try our mailing lists :
diff --git a/navit/CMakeLists.txt b/navit/CMakeLists.txt
index 28914f59c..a52eb09b2 100644
--- a/navit/CMakeLists.txt
+++ b/navit/CMakeLists.txt
@@ -4,52 +4,53 @@ include_directories( "${CMAKE_CURRENT_SOURCE_DIR}")
include_directories( "${CMAKE_CURRENT_BINARY_DIR}")
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/support")
-# navit cre
+# navit core
set(NAVIT_SRC announcement.c atom.c attr.c cache.c callback.c command.c config_.c coord.c country.c data_window.c debug.c
- event.c file.c geom.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c audio.c
- linguistics.c mapset.c maptype.c menu.c messages.c bookmarks.c navit.c navit_nls.c navigation.c osd.c param.c phrase.c plugin.c popup.c
- profile.c profile_option.c projection.c roadprofile.c route.c script.c search.c speech.c start_real.c sunriset.c transform.c track.c
- search_houseno_interpol.c util.c vehicle.c vehicleprofile.c xmlconfig.c )
+ event.c file.c geom.c graphics.c gui.c item.c layout.c log.c main.c
+ map.c maps.c audio.c
+ linguistics.c mapset.c maptype.c menu.c messages.c bookmarks.c navit.c navit_nls.c navigation.c osd.c param.c phrase.c plugin.c popup.c
+ profile.c profile_option.c projection.c roadprofile.c route.c script.c search.c speech.c start_real.c sunriset.c transform.c track.c
+ search_houseno_interpol.c traffic.c util.c vehicle.c vehicleprofile.c xmlconfig.c )
if(NOT USE_PLUGINS)
- list(APPEND NAVIT_SRC ${CMAKE_CURRENT_BINARY_DIR}/builtin.c)
+ list(APPEND NAVIT_SRC ${CMAKE_CURRENT_BINARY_DIR}/builtin.c)
endif(NOT USE_PLUGINS)
if (${HAVE_GLIB})
- list(APPEND NAVIT_SRC event_glib.c)
+ list(APPEND NAVIT_SRC event_glib.c)
endif()
if(ANDROID)
- list(APPEND NAVIT_SRC android.c)
- set(NAVIT_LIBNAME navit)
+ list(APPEND NAVIT_SRC android.c)
+ set(NAVIT_LIBNAME navit)
else()
- set(NAVIT_LIBNAME navit_core)
+ set(NAVIT_LIBNAME navit_core)
endif()
foreach ( PLUGIN_PATH ${ALL_PLUGINS})
- if (${PLUGIN_PATH})
- include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_PATH}")
-
- string(REPLACE "/" "_" MODULE_INC ${PLUGIN_PATH})
- list(APPEND NAVIT_SUPPORT_LIBS ${MODULE_INC})
- endif()
+ if (${PLUGIN_PATH})
+ include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_PATH}")
+
+ string(REPLACE "/" "_" MODULE_INC ${PLUGIN_PATH})
+ list(APPEND NAVIT_SUPPORT_LIBS ${MODULE_INC})
+ endif()
endforeach()
foreach ( MODULE_PATH ${ALL_MODULES})
- if ( ${MODULE_PATH} )
- include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_PATH}")
-
- string(REPLACE "/" "_" MODULE_INC ${MODULE_PATH})
- list(APPEND MODULES_PROTOTYPE "\nvoid\tmodule_${MODULE_INC}_init(void)")
- list(APPEND MODULES_FUNC "\nmodule_${MODULE_INC}_init()")
-
- if (NOT USE_PLUGINS)
- list(APPEND MODULES_NAME ${MODULE_INC})
- else()
- string(REGEX REPLACE "(^[^/]*)/.*" "\\1" ${MODULE_INC}_TYPE ${MODULE_PATH})
- endif()
- endif()
+ if ( ${MODULE_PATH} )
+ include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_PATH}")
+
+ string(REPLACE "/" "_" MODULE_INC ${MODULE_PATH})
+ list(APPEND MODULES_PROTOTYPE "\nvoid\tmodule_${MODULE_INC}_init(void)")
+ list(APPEND MODULES_FUNC "\nmodule_${MODULE_INC}_init()")
+
+ if (NOT USE_PLUGINS)
+ list(APPEND MODULES_NAME ${MODULE_INC})
+ else()
+ string(REGEX REPLACE "(^[^/]*)/.*" "\\1" ${MODULE_INC}_TYPE ${MODULE_PATH})
+ endif()
+ endif()
endforeach()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/builtin.c.in ${CMAKE_CURRENT_BINARY_DIR}/builtin.c)
@@ -58,110 +59,160 @@ include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/fib-1.1")
# Add module paths
foreach (CURRENT_MODULE ${ALL_PLUGINS} ${ALL_MODULE_PLUGINS} ${ALL_MODULES})
- if (${CURRENT_MODULE})
- add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/${CURRENT_MODULE}")
- endif()
+ if (${CURRENT_MODULE})
+ add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/${CURRENT_MODULE}")
+ endif()
endforeach()
add_subdirectory (fib-1.1)
if(NOT ANDROID)
- set(NAVIT_START_SRC start.c)
- if(WIN32 OR WINCE AND NOT WIN_OMIT_RESOURCES)
- list(APPEND NAVIT_START_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gui/win32/resources/resource.rc)
- else()
- if (APPLE)
- set(NAVIT_START_SRC start_apple.m)
- endif()
- endif()
- if (BUILD_BUNDLE)
- list(APPEND NAVIT_START_SRC resources/share resources/Icon.png resources/Default.png)
- add_custom_command(OUTPUT resources/Icon.png COMMAND convert -scale 79x79 -crop 60x60+8+19 ${CMAKE_CURRENT_SOURCE_DIR}/icons/desktop_icons/128x128/navit.png resources/Icon.png)
- add_custom_command(OUTPUT resources/Default.png COMMAND convert -scale 79x79 -crop 60x60+8+19 ${CMAKE_CURRENT_SOURCE_DIR}/icons/desktop_icons/128x128/navit.png resources/Default.png)
- endif()
- add_executable(navit ${NAVIT_START_SRC})
- target_link_libraries (navit ${NAVIT_LIBNAME})
- if(DEFINED NAVIT_BINARY)
- set_target_properties(navit PROPERTIES OUTPUT_NAME ${NAVIT_BINARY})
- endif(DEFINED NAVIT_BINARY)
- if (BUILD_BUNDLE)
- add_custom_command(OUTPUT resources/share COMMAND mkdir -p resources/share)
- set_source_files_properties(resources/share resources/Icon.png resources/Default.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
- set_target_properties(navit PROPERTIES MACOSX_BUNDLE TRUE)
- set_target_properties(navit PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
- add_dependencies(navit navit_config_xml_resource)
- add_dependencies(navit images_resource)
- add_dependencies(navit locale_resource)
- endif()
+ set(NAVIT_START_SRC start.c)
+ if(WIN32 OR WINCE AND NOT WIN_OMIT_RESOURCES)
+ list(APPEND NAVIT_START_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gui/win32/resources/resource.rc)
+ else()
+ if (APPLE)
+ set(NAVIT_START_SRC start_apple.m)
+ endif()
+ endif()
+ if (BUILD_BUNDLE)
+ list(APPEND NAVIT_START_SRC resources/share resources/Icon.png resources/Default.png)
+ add_custom_command(OUTPUT resources/Icon.png COMMAND convert -scale 79x79 -crop 60x60+8+19 ${CMAKE_CURRENT_SOURCE_DIR}/icons/desktop_icons/128x128/navit.png resources/Icon.png)
+ add_custom_command(OUTPUT resources/Default.png COMMAND convert -scale 79x79 -crop 60x60+8+19 ${CMAKE_CURRENT_SOURCE_DIR}/icons/desktop_icons/128x128/navit.png resources/Default.png)
+ endif()
+ add_executable(navit ${NAVIT_START_SRC})
+ target_link_libraries (navit ${NAVIT_LIBNAME})
+ if(DEFINED NAVIT_BINARY)
+ set_target_properties(navit PROPERTIES OUTPUT_NAME ${NAVIT_BINARY})
+ endif(DEFINED NAVIT_BINARY)
+ if (BUILD_BUNDLE)
+ add_custom_command(OUTPUT resources/share COMMAND mkdir -p resources/share)
+ set_source_files_properties(resources/share resources/Icon.png resources/Default.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
+ set_target_properties(navit PROPERTIES MACOSX_BUNDLE TRUE)
+ set_target_properties(navit PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
+ add_dependencies(navit navit_config_xml_resource)
+ add_dependencies(navit images_resource)
+ add_dependencies(navit locale_resource)
+ endif()
endif()
-if (SHARED_LIBNAVIT)
- add_library (${NAVIT_LIBNAME} SHARED ${NAVIT_SRC} )
-else(SHARED_LIBNAVIT)
- add_library (${NAVIT_LIBNAME} STATIC ${NAVIT_SRC} )
-endif(SHARED_LIBNAVIT)
+#if (SHARED_LIBNAVIT)
+# add_library (${NAVIT_LIBNAME} SHARED ${NAVIT_SRC} )
+#else(SHARED_LIBNAVIT)
+# add_library (${NAVIT_LIBNAME} STATIC ${NAVIT_SRC} )
+#endif(SHARED_LIBNAVIT)
+
+add_library (${NAVIT_LIBNAME} ${NAVIT_SRC} )
if(NOT MSVC)
- SET(NAVIT_LIBS ${NAVIT_LIBS} m)
+ SET(NAVIT_LIBS ${NAVIT_LIBS} m)
endif(NOT MSVC)
-target_link_libraries(${NAVIT_LIBNAME} ${MODULES_NAME} ${NAVIT_SUPPORT_LIBS} fib ${NAVIT_LIBS} )
+target_link_libraries(${NAVIT_LIBNAME} ${MODULES_NAME} ${NAVIT_SUPPORT_LIBS} fib ${NAVIT_LIBS} )
set_target_properties(${NAVIT_LIBNAME} PROPERTIES COMPILE_DEFINITIONS "MODULE=navit;LIBDIR=\"${CMAKE_INSTALL_PREFIX}/${LIB_DIR}\";PREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
if (DEFINED NAVIT_COMPILE_FLAGS)
- set_target_properties(${NAVIT_LIBNAME} PROPERTIES COMPILE_FLAGS "${NAVIT_COMPILE_FLAGS}")
+ set_target_properties(${NAVIT_LIBNAME} PROPERTIES COMPILE_FLAGS "${NAVIT_COMPILE_FLAGS}")
endif()
-ADD_CUSTOM_TARGET(
- git_version
- ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/version.h
- -D NAME="GIT_VERSION"
- -P ${PROJECT_SOURCE_DIR}/cmake/version.cmake
-)
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/navit.dtd"
+ COMMENT "Copy navit.dtd to ${CMAKE_CURRENT_BINARY_DIR}/navit.dtd"
+ COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/navit/navit.dtd" "${CMAKE_CURRENT_BINARY_DIR}/navit.dtd"
+ )
# additional parameter are passed to the stylesheet processor as parameter
-macro(process_xslt SRC_XML DEST_XML)
- set(XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy ${SRC_XML} ${DEST_XML}
- COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/navit/navit.dtd ${CMAKE_CURRENT_BINARY_DIR}/navit.dtd)
- if(XSL_PROCESSING AND XSLTS)
- string(REPLACE "," ";" XSLTS "${XSLTS}")
- foreach(tmp ${XSLTS})
- set(XSLT_FILE "${PROJECT_SOURCE_DIR}/navit/xslt/${tmp}.xslt")
- list(APPEND XSLT_FILES "${XSLT_FILE}")
- list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E echo Applying ${tmp}.xslt)
- compose_xslt_transform_command(CMD "${XSLT_FILE}" "${DEST_XML}" "${DEST_XML}.tmp" "${ARGN}")
- list(APPEND XSLT_COMMANDS ${CMD})
- list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E rename ${DEST_XML}.tmp ${DEST_XML})
- endforeach()
- endif()
- # Depend on all XSLT files, because the main XSLT file may pull in other files.
- # Ideally we'd parse the main XSLT file for includes, but that is tricky to do reliably.
- # Note that this list of files is only updated when (re)running CMake, so if files are
- # added/deleted, CMake must be re-run manually.
- file(GLOB ALL_XSLT_FILES "${PROJECT_SOURCE_DIR}/navit/xslt/*.xslt")
- ADD_CUSTOM_COMMAND(
- OUTPUT ${DEST_XML}
- DEPENDS ${SRC_XML} ${ALL_XSLT_FILES}
- ${XSLT_COMMANDS}
- )
+macro(process_xslt SRC_DIR SRC_XML DEST_DIR DEST_XML)
+ set(TMPFOLDER "${DEST_DIR}/${DEST_XML}")
+ # Create a unique temporary name based on the PATH and filename of the target xml file
+ string(REPLACE "/" "_" TMPFOLDER ${TMPFOLDER})
+ string(REPLACE ":" "_" TMPFOLDER ${TMPFOLDER})
+ string(REPLACE "\\" "_" TMPFOLDER ${TMPFOLDER})
+ # Create this unique temporary directory inside ${CMAKE_CURRENT_BINARY_DIR}. This is where we will store our intermediate xml file (called ${SRC_XML}.temp after each xslt pass
+ set(TMPDIR "${CMAKE_CURRENT_BINARY_DIR}/${TMPFOLDER}")
+ set(XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E make_directory "${TMPDIR}")
+ list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/navit/${SRC_XML}" "${TMPDIR}/${SRC_XML}.temp")
+ # Also copy the dtd file in the same directory as the xml file (required by the xslt processor)
+ list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/navit/navit.dtd" "${TMPDIR}/" )
+ if(XSL_PROCESSING)
+ if(NOT XSLTS STREQUAL "")
+ string(REPLACE "," ";" XSLTS "${XSLTS}")
+ foreach(tmp ${XSLTS})
+ # We will run this loop below for each xslt file provided in the XSLTS variable
+ set(XSLT_FILE "${PROJECT_SOURCE_DIR}/navit/xslt/${tmp}.xslt")
+ list(APPEND XSLT_FILES "${XSLT_FILE}")
+ list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E echo Applying ${tmp}.xslt)
+ compose_xslt_transform_command(CMD "${XSLT_FILE}" "${TMPDIR}/${SRC_XML}.temp" "${TMPDIR}/${SRC_XML}.output" "${ARGN}")
+ list(APPEND XSLT_COMMANDS ${CMD})
+ list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E rename "${TMPDIR}/${SRC_XML}.output" "${TMPDIR}/${SRC_XML}.temp")
+ endforeach()
+ endif()
+ endif(XSL_PROCESSING)
+ # Move the final resulting xml file to the target filename and directory (provided in arguments)
+ list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR})
+ list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E rename "${TMPDIR}/${SRC_XML}.temp" "${DEST_DIR}/${DEST_XML}")
+ list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E remove "${TMPDIR}/navit.dtd")
+ list(APPEND XSLT_COMMANDS COMMAND ${CMAKE_COMMAND} -E remove_directory "${TMPDIR}")
+ # Depend on all XSLT files, because the main XSLT file may pull in other files.
+ # Ideally we'd parse the main XSLT file for includes, but that is tricky to do reliably.
+ # Note that this list of files is only updated when (re)running CMake, so if files are
+ # added/deleted, CMake must be re-run manually.
+ file(GLOB ALL_XSLT_FILES "${PROJECT_SOURCE_DIR}/navit/xslt/*.xslt")
+ #message(FATAL_ERROR ${CMAKE_CURRENT_BINARY_DIR}/${DEST_XML})
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${DEST_DIR}/${DEST_XML}
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/navit/xslt/
+ DEPENDS "${SRC_DIR}/${SRC_XML}" "${CMAKE_CURRENT_BINARY_DIR}/navit.dtd" ${ALL_XSLT_FILES}
+ ${XSLT_COMMANDS}
+ )
endmacro()
+# Give instructions on how to build all navit_*.xml navit_layout_*.xml files, obtained applying relevant xslt tranformation on the source navit_shipped_*.xml files
+# The following XMLCFG_ALL_FILE_PREFIXES variable below lists all xml config files, semicolon is the delimiter
+# For example, it contains layout_navit_car, that will then be used to guess the source filename navit_layout_car_shipped.xml, installed as navit_layout_car.xml (or on android DPI-related files like navit_layout_car_xxxhdpi.xml)
+set(XMLCFG_ALL_FILE_PREFIXES "navit;navit_layout_car;navit_layout_car_dark;navit_layout_car_android;navit_layout_car_simple;navit_layout_bike;navit_layout_th")
if(ANDROID)
- process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml ${CMAKE_CURRENT_BINARY_DIR}/navitxxxhdpi.xml OSD_SIZE=5.33 ICON_SMALL=128 ICON_MEDIUM=192 ICON_BIG=256)
- process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml ${CMAKE_CURRENT_BINARY_DIR}/navitxxhdpi.xml OSD_SIZE=4 ICON_SMALL=96 ICON_MEDIUM=128 ICON_BIG=192)
- process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml ${CMAKE_CURRENT_BINARY_DIR}/navitxhdpi.xml OSD_SIZE=2.67 ICON_SMALL=64 ICON_MEDIUM=96 ICON_BIG=128)
- process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml ${CMAKE_CURRENT_BINARY_DIR}/navithdpi.xml OSD_SIZE=2 ICON_SMALL=48 ICON_MEDIUM=64 ICON_BIG=96)
- process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml ${CMAKE_CURRENT_BINARY_DIR}/navitmdpi.xml OSD_SIZE=1.33 ICON_SMALL=32 ICON_MEDIUM=48 ICON_BIG=64)
- process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml ${CMAKE_CURRENT_BINARY_DIR}/navitldpi.xml OSD_SIZE=1 ICON_SMALL=24 ICON_MEDIUM=32 ICON_BIG=48)
- add_custom_target( navit_config_xml ALL DEPENDS navitxxxhdpi.xml navitxxhdpi.xml navitxhdpi.xml navithdpi.xml navitmdpi.xml navitldpi.xml)
+ # On android, additional xlst transformations are applied to scale the OSD, icons etc... and the size is selected depending on the definition of the screen of the device (xxxhdpi, xxhdpi, ... ldpi)
+ # Files for all screen definitions are shipped inside the android package (suffixed with _xxxhdpi, _xxhdpi etc.), and it is only at runtime that the correct navit_*.xml (corresponding to the current device's resolution) is selected
+ set(XSLT_XXXHDPI_ARGS OSD_SIZE=5.33 ICON_SMALL=128 ICON_MEDIUM=192 ICON_BIG=256)
+ set(XSLT_XXHDPI_ARGS OSD_SIZE=4 ICON_SMALL=96 ICON_MEDIUM=128 ICON_BIG=192)
+ set(XSLT_XHDPI_ARGS OSD_SIZE=2.67 ICON_SMALL=64 ICON_MEDIUM=96 ICON_BIG=128)
+ set(XSLT_HDPI_ARGS OSD_SIZE=2 ICON_SMALL=48 ICON_MEDIUM=64 ICON_BIG=96)
+ set(XSLT_MDPI_ARGS OSD_SIZE=1.33 ICON_SMALL=32 ICON_MEDIUM=48 ICON_BIG=64)
+ set(XSLT_LDPI_ARGS OSD_SIZE=1 ICON_SMALL=24 ICON_MEDIUM=32 ICON_BIG=48)
+
+ set(XMLCFG_OUTPUT_LIST "") # Used to build the list of generated *xml filenames (only file basename, directory part excluded)
+ foreach(XMLCFG_FILE_PREFIX ${XMLCFG_ALL_FILE_PREFIXES})
+ set(XMLCFG_FILE_SHIPPED ${XMLCFG_FILE_PREFIX}_shipped.xml)
+ set(XMLCFG_DIR_OUTPUT_XXXHDPI ${CMAKE_CURRENT_BINARY_DIR}/config/xxxhdpi)
+ set(XMLCFG_DIR_OUTPUT_XXHDPI ${CMAKE_CURRENT_BINARY_DIR}/config/xxhdpi)
+ set(XMLCFG_DIR_OUTPUT_XHDPI ${CMAKE_CURRENT_BINARY_DIR}/config/xhdpi)
+ set(XMLCFG_DIR_OUTPUT_HDPI ${CMAKE_CURRENT_BINARY_DIR}/config/hdpi)
+ set(XMLCFG_DIR_OUTPUT_MDPI ${CMAKE_CURRENT_BINARY_DIR}/config/mdpi)
+ set(XMLCFG_DIR_OUTPUT_LDPI ${CMAKE_CURRENT_BINARY_DIR}/config/ldpi)
+ set(XMLCFG_FILE_OUTPUT ${XMLCFG_FILE_PREFIX}.xml)
+ process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_XXXHDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_XXXHDPI_ARGS})
+ process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_XXHDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_XXHDPI_ARGS})
+ process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_XHDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_XHDPI_ARGS})
+ process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_HDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_HDPI_ARGS})
+ process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_MDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_MDPI_ARGS})
+ process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${XMLCFG_DIR_OUTPUT_LDPI}/ ${XMLCFG_FILE_PREFIX}.xml ${XSLT_LDPI_ARGS})
+ set(XMLCFG_OUTPUT_LIST ${XMLCFG_OUTPUT_LIST} ${XMLCFG_DIR_OUTPUT_XXXHDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_XXHDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_XHDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_HDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_MDPI}/${XMLCFG_FILE_PREFIX}.xml ${XMLCFG_DIR_OUTPUT_LDPI}/${XMLCFG_FILE_PREFIX}.xml)
+ endforeach()
+ add_custom_target( navit_config_xml ALL DEPENDS ${XMLCFG_OUTPUT_LIST})
else()
- process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/navit_shipped.xml ${CMAKE_CURRENT_BINARY_DIR}/navit.xml "")
- add_custom_target( navit_config_xml_resource DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/navit.xml COMMAND mkdir -p resources/share/navit COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/navit.xml resources/share/navit)
- add_custom_target( locale_resource DEPENDS locales COMMAND mkdir -p resources/share COMMAND cp -a ${CMAKE_CURRENT_BINARY_DIR}/../locale resources/share/locale)
- add_custom_target( navit_config_xml ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/navit.xml)
+ set(XMLCFG_OUTPUT_LIST "") # Used to build the list of generated *xml filenames (only file basename, directory part excluded)
+ set(XMLCFG_INSTALLED_PATH_LIST "") # A list of full path to installed xml files
+ foreach(XMLCFG_FILE_PREFIX ${XMLCFG_ALL_FILE_PREFIXES})
+ set(XMLCFG_FILE_SHIPPED ${XMLCFG_FILE_PREFIX}_shipped.xml)
+ process_xslt(${CMAKE_CURRENT_SOURCE_DIR}/ ${XMLCFG_FILE_SHIPPED} ${CMAKE_CURRENT_BINARY_DIR}/ ${XMLCFG_FILE_PREFIX}.xml "")
+ set(XMLCFG_OUTPUT_LIST ${XMLCFG_OUTPUT_LIST} ${XMLCFG_FILE_PREFIX}.xml)
+ set(XMLCFG_INSTALLED_PATH_LIST ${XMLCFG_INSTALLED_PATH_LIST} ${CMAKE_CURRENT_BINARY_DIR}/${XMLCFG_FILE_PREFIX}.xml)
+ endforeach()
+ add_custom_target( navit_config_xml_resource DEPENDS ${XMLCFG_INSTALLED_PATH_LIST} COMMAND mkdir -p resources/share/navit COMMAND cp ${XMLCFG_INSTALLED_PATH_LIST} resources/share/navit)
+ add_custom_target( locale_resource DEPENDS locales COMMAND mkdir -p resources/share COMMAND cp -a ${CMAKE_CURRENT_BINARY_DIR}/../locale resources/share/locale)
+ add_custom_target( navit_config_xml ALL DEPENDS ${XMLCFG_OUTPUT_LIST})
endif()
-ADD_DEPENDENCIES(${NAVIT_LIBNAME} git_version)
if (USE_LIBGNUINTL AND NOT HAVE_GLIB)
- ADD_DEPENDENCIES(support_glib support_gettext_intl)
+ ADD_DEPENDENCIES(support_glib support_gettext_intl)
endif()
@@ -169,20 +220,26 @@ add_subdirectory (maptool)
add_subdirectory (icons)
add_subdirectory (maps)
if(ANDROID)
- add_subdirectory (android)
+ add_subdirectory (android)
endif()
install(TARGETS navit
- DESTINATION ${BIN_DIR}
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ DESTINATION ${BIN_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/navit.xml
- DESTINATION ${SHARE_DIR}
- PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+ DESTINATION ${SHARE_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+foreach(XMLCFG_INSTALLED_PATH ${XMLCFG_INSTALLED_PATH_LIST})
+ install(FILES ${XMLCFG_INSTALLED_PATH}
+ DESTINATION ${SHARE_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+endforeach()
get_directory_property(INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES)
WRITE_FILE("cmake_plugin_settings.txt"
- "set(APPLE ${APPLE} CACHE BOOL init)\n"
+ "set(APPLE ${APPLE} CACHE BOOL init)\n"
"set(ANDROID ${ANDROID} CACHE BOOL init)\n"
"set(USE_PLUGINS ${USE_PLUGINS} CACHE BOOL init)\n"
"set(MODULE_BUILD_TYPE \"${MODULE_BUILD_TYPE}\" CACHE STRING init)\n"
diff --git a/navit/Doxyfile b/navit/Doxyfile
index 0960da8b9..13f382f44 100644
--- a/navit/Doxyfile
+++ b/navit/Doxyfile
@@ -38,7 +38,7 @@ PROJECT_NAME = navit
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 0.5.1-trunk
+PROJECT_NUMBER = 0.5.3-trunk
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -809,7 +809,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*
-EXCLUDE_PATTERNS =
+EXCLUDE_PATTERNS = */support/*
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
@@ -1504,7 +1504,7 @@ MATHJAX_CODEFILE =
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
-SEARCHENGINE = NO
+SEARCHENGINE = YES
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
# implemented using a web server instead of a web client using Javascript. There
diff --git a/navit/android.c b/navit/android.c
index 6e62da1b3..dc506ffb0 100644
--- a/navit/android.c
+++ b/navit/android.c
@@ -22,755 +22,724 @@
#include "track.h"
JNIEnv *jnienv;
-jobject *android_activity;
+jobject *android_activity = NULL;
+jobject *android_application = NULL;
int android_version;
-struct android_search_priv
-{
- struct jni_object search_result_obj;
- struct event_idle *idle_ev;
- struct callback *idle_clb;
- struct search_list *search_list;
- struct attr search_attr;
- gchar **phrases;
- int current_phrase_per_level[4];
- int partial;
- int found;
+struct android_search_priv {
+ struct jni_object search_result_obj;
+ struct event_idle *idle_ev;
+ struct callback *idle_clb;
+ struct search_list *search_list;
+ struct attr search_attr;
+ gchar **phrases;
+ int current_phrase_per_level[4];
+ int partial;
+ int found;
};
-int
-android_find_class_global(char *name, jclass *ret)
-{
- *ret=(*jnienv)->FindClass(jnienv, name);
- if (! *ret) {
- dbg(lvl_error,"Failed to get Class %s\n",name);
- return 0;
- }
- *ret = (*jnienv)->NewGlobalRef(jnienv, *ret);
- return 1;
+int android_find_class_global(char *name, jclass *ret) {
+ *ret=(*jnienv)->FindClass(jnienv, name);
+ if (! *ret) {
+ dbg(lvl_error,"Failed to get Class %s",name);
+ return 0;
+ }
+ *ret = (*jnienv)->NewGlobalRef(jnienv, *ret);
+ return 1;
}
-int
-android_find_method(jclass class, char *name, char *args, jmethodID *ret)
-{
- *ret = (*jnienv)->GetMethodID(jnienv, class, name, args);
- if (*ret == NULL) {
- dbg(lvl_error,"Failed to get Method %s with signature %s\n",name,args);
- return 0;
- }
- return 1;
+int android_find_method(jclass class, char *name, char *args, jmethodID *ret) {
+ *ret = (*jnienv)->GetMethodID(jnienv, class, name, args);
+ if (*ret == NULL) {
+ dbg(lvl_error,"Failed to get Method %s with signature %s",name,args);
+ return 0;
+ }
+ return 1;
}
-int
-android_find_static_method(jclass class, char *name, char *args, jmethodID *ret)
-{
- *ret = (*jnienv)->GetStaticMethodID(jnienv, class, name, args);
- if (*ret == NULL) {
- dbg(lvl_error,"Failed to get static Method %s with signature %s\n",name,args);
- return 0;
- }
- return 1;
+int android_find_static_method(jclass class, char *name, char *args, jmethodID *ret) {
+ *ret = (*jnienv)->GetStaticMethodID(jnienv, class, name, args);
+ if (*ret == NULL) {
+ dbg(lvl_error,"Failed to get static Method %s with signature %s",name,args);
+ return 0;
+ }
+ return 1;
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_Navit_NavitMain( JNIEnv* env, jobject thiz, jobject activity, jobject lang, int version, jobject display_density_string, jobject path, jobject map_path)
-{
- const char *langstr;
- const char *displaydensitystr;
- const char *map_file_path;
- android_version=version;
- __android_log_print(ANDROID_LOG_ERROR,"test","called");
- jnienv=env;
- android_activity = (*jnienv)->NewGlobalRef(jnienv, activity);
- langstr=(*env)->GetStringUTFChars(env, lang, NULL);
- dbg(lvl_debug,"enter env=%p thiz=%p activity=%p lang=%s version=%d\n",env,thiz,android_activity,langstr,version);
- setenv("LANG",langstr,1);
- (*env)->ReleaseStringUTFChars(env, lang, langstr);
-
- displaydensitystr=(*env)->GetStringUTFChars(env, display_density_string, NULL);
- dbg(lvl_debug,"*****displaydensity=%s\n",displaydensitystr);
- setenv("ANDROID_DENSITY",displaydensitystr,1);
- (*env)->ReleaseStringUTFChars(env, display_density_string, displaydensitystr);
-
- map_file_path=(*env)->GetStringUTFChars(env, map_path, NULL);
- setenv("NAVIT_USER_DATADIR",map_file_path,1);
- (*env)->ReleaseStringUTFChars(env, display_density_string, map_file_path);
-
- const char *strings=(*env)->GetStringUTFChars(env, path, NULL);
- main_real(1, &strings);
- (*env)->ReleaseStringUTFChars(env, path, strings);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_Navit_NavitMain( JNIEnv* env, jobject thiz, jobject activity,
+ jobject application, jobject lang, int version, jobject display_density_string, jobject path, jobject map_path,
+ jboolean isLaunch) {
+ const char *langstr;
+ const char *displaydensitystr;
+ const char *map_file_path;
+ android_version=version;
+ __android_log_print(ANDROID_LOG_ERROR,"test","called");
+ jnienv=env;
+ if (android_activity)
+ (*jnienv)->DeleteGlobalRef(jnienv, android_activity);
+ android_activity = (*jnienv)->NewGlobalRef(jnienv, activity);
+ if (android_application)
+ (*jnienv)->DeleteGlobalRef(jnienv, android_application);
+ android_application = (*jnienv)->NewGlobalRef(jnienv, application);
+ langstr=(*env)->GetStringUTFChars(env, lang, NULL);
+ dbg(lvl_debug,"enter env=%p thiz=%p activity=%p lang=%s version=%d",env,thiz,android_activity,langstr,version);
+ setenv("LANG",langstr,1);
+ (*env)->ReleaseStringUTFChars(env, lang, langstr);
+
+ displaydensitystr=(*env)->GetStringUTFChars(env, display_density_string, NULL);
+ dbg(lvl_debug,"*****displaydensity=%s",displaydensitystr);
+ setenv("ANDROID_DENSITY",displaydensitystr,1);
+ (*env)->ReleaseStringUTFChars(env, display_density_string, displaydensitystr);
+
+ map_file_path=(*env)->GetStringUTFChars(env, map_path, NULL);
+ setenv("NAVIT_USER_DATADIR",map_file_path,1);
+ (*env)->ReleaseStringUTFChars(env, display_density_string, map_file_path);
+
+ if (isLaunch) {
+ const char *strings=(*env)->GetStringUTFChars(env, path, NULL);
+ main_real(1, &strings);
+ (*env)->ReleaseStringUTFChars(env, path, strings);
+ }
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_Navit_NavitDestroy( JNIEnv* env)
-{
- dbg(lvl_debug, "shutdown navit\n");
- exit(0);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_Navit_NavitDestroy( JNIEnv* env) {
+ dbg(lvl_debug, "shutdown navit");
+ exit(0);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitGraphics_SizeChangedCallback( JNIEnv* env, jobject thiz, int id, int w, int h)
-{
- dbg(lvl_debug,"enter %p %d %d\n",(struct callback *)id,w,h);
- if (id)
- callback_call_2((struct callback *)id,w,h);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitGraphics_SizeChangedCallback( JNIEnv* env, jobject thiz, int id,
+ int w, int h) {
+ dbg(lvl_debug,"enter %p %d %d",(struct callback *)id,w,h);
+ if (id)
+ callback_call_2((struct callback *)id,w,h);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitGraphics_PaddingChangedCallback(JNIEnv* env, jobject thiz, int id, int left, int top, int right, int bottom)
-{
- dbg(lvl_debug,"enter %p %d %d %d %d\n",(struct callback *)id, left, top, right, bottom);
- if (id)
- callback_call_4((struct callback *)id, left, top, right, bottom);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitGraphics_PaddingChangedCallback(JNIEnv* env, jobject thiz,
+ int id, int left, int top, int right, int bottom) {
+ dbg(lvl_debug,"enter %p %d %d %d %d",(struct callback *)id, left, top, right, bottom);
+ if (id)
+ callback_call_4((struct callback *)id, left, top, right, bottom);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitGraphics_ButtonCallback( JNIEnv* env, jobject thiz, int id, int pressed, int button, int x, int y)
-{
- dbg(lvl_debug,"enter %p %d %d\n",(struct callback *)id,pressed,button);
- if (id)
- callback_call_4((struct callback *)id,pressed,button,x,y);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitGraphics_ButtonCallback( JNIEnv* env, jobject thiz, int id,
+ int pressed, int button, int x, int y) {
+ dbg(lvl_debug,"enter %p %d %d",(struct callback *)id,pressed,button);
+ if (id)
+ callback_call_4((struct callback *)id,pressed,button,x,y);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitGraphics_MotionCallback( JNIEnv* env, jobject thiz, int id, int x, int y)
-{
- dbg(lvl_debug,"enter %p %d %d\n",(struct callback *)id,x,y);
- if (id)
- callback_call_2((struct callback *)id,x,y);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitGraphics_MotionCallback( JNIEnv* env, jobject thiz, int id,
+ int x, int y) {
+ dbg(lvl_debug,"enter %p %d %d",(struct callback *)id,x,y);
+ if (id)
+ callback_call_2((struct callback *)id,x,y);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitGraphics_KeypressCallback( JNIEnv* env, jobject thiz, int id, jobject str)
-{
- const char *s;
- dbg(lvl_debug,"enter %p %p\n",(struct callback *)id,str);
- s=(*env)->GetStringUTFChars(env, str, NULL);
- dbg(lvl_debug,"key=%d",s);
- if (id)
- callback_call_1((struct callback *)id,s);
- (*env)->ReleaseStringUTFChars(env, str, s);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitGraphics_KeypressCallback( JNIEnv* env, jobject thiz, int id,
+ jobject str) {
+ const char *s;
+ dbg(lvl_debug,"enter %p %p",(struct callback *)id,str);
+ s=(*env)->GetStringUTFChars(env, str, NULL);
+ dbg(lvl_debug,"key=%d",s);
+ if (id)
+ callback_call_1((struct callback *)id,s);
+ (*env)->ReleaseStringUTFChars(env, str, s);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitTimeout_TimeoutCallback( JNIEnv* env, jobject thiz, int id)
-{
- void (*event_handler)(void *) = *(void **)id;
- dbg(lvl_debug,"enter %p %p\n",thiz, (void *)id);
- event_handler((void*)id);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitTimeout_TimeoutCallback( JNIEnv* env, jobject thiz, int id) {
+ void (*event_handler)(void *) = *(void **)id;
+ dbg(lvl_debug,"enter %p %p",thiz, (void *)id);
+ event_handler((void*)id);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitVehicle_VehicleCallback( JNIEnv * env, jobject thiz, int id, jobject location)
-{
- callback_call_1((struct callback *)id, (void *)location);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitVehicle_VehicleCallback( JNIEnv * env, jobject thiz, int id,
+ jobject location) {
+ callback_call_1((struct callback *)id, (void *)location);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitIdle_IdleCallback( JNIEnv* env, jobject thiz, int id)
-{
- dbg(lvl_debug,"enter %p %p\n",thiz, (void *)id);
- callback_call_0((struct callback *)id);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitIdle_IdleCallback( JNIEnv* env, jobject thiz, int id) {
+ dbg(lvl_debug,"enter %p %p",thiz, (void *)id);
+ callback_call_0((struct callback *)id);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitWatch_poll( JNIEnv* env, jobject thiz, int func, int fd, int cond)
-{
- void (*pollfunc)(JNIEnv *env, int fd, int cond)=(void *)func;
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitWatch_poll( JNIEnv* env, jobject thiz, int func, int fd,
+ int cond) {
+ void (*pollfunc)(JNIEnv *env, int fd, int cond)=(void *)func;
- pollfunc(env, fd, cond);
+ pollfunc(env, fd, cond);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitWatch_WatchCallback( JNIEnv* env, jobject thiz, int id)
-{
- dbg(lvl_debug,"enter %p %p\n",thiz, (void *)id);
- callback_call_0((struct callback *)id);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitWatch_WatchCallback( JNIEnv* env, jobject thiz, int id) {
+ dbg(lvl_debug,"enter %p %p",thiz, (void *)id);
+ callback_call_0((struct callback *)id);
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitSensors_SensorCallback( JNIEnv* env, jobject thiz, int id, int sensor, float x, float y, float z)
-{
- dbg(lvl_debug,"enter %p %p %f %f %f\n",thiz, (void *)id,x,y,z);
- callback_call_4((struct callback *)id, sensor, &x, &y, &z);
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitSensors_SensorCallback( JNIEnv* env, jobject thiz, int id,
+ int sensor, float x, float y, float z) {
+ dbg(lvl_debug,"enter %p %p %f %f %f",thiz, (void *)id,x,y,z);
+ callback_call_4((struct callback *)id, sensor, &x, &y, &z);
}
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitTraff_onFeedReceived(JNIEnv * env, jobject thiz, int id,
+ jstring feed) {
+ const char *s;
+ s = (*env)->GetStringUTFChars(env, feed, NULL);
+ if (id)
+ callback_call_1((struct callback *) id, s);
+ (*env)->ReleaseStringUTFChars(env, feed, s);
+}
+
+
+
// type: 0=town, 1=street, 2=House#
-void
-android_return_search_result(struct jni_object *jni_o, int type, struct pcoord *location, const char *address)
-{
- struct coord_geo geo_location;
- struct coord c;
- jstring jaddress = NULL;
- JNIEnv* env;
- env=jni_o->env;
- jaddress = (*env)->NewStringUTF(jni_o->env,address);
-
- c.x=location->x;
- c.y=location->y;
- transform_to_geo(location->pro, &c, &geo_location);
-
- (*env)->CallVoidMethod(jni_o->env, jni_o->jo, jni_o->jm, type, geo_location.lat, geo_location.lng, jaddress);
- (*env)->DeleteLocalRef(jni_o->env, jaddress);
+void android_return_search_result(struct jni_object *jni_o, int type, struct pcoord *location, const char *address) {
+ struct coord_geo geo_location;
+ struct coord c;
+ jstring jaddress = NULL;
+ JNIEnv* env;
+ env=jni_o->env;
+ jaddress = (*env)->NewStringUTF(jni_o->env,address);
+
+ c.x=location->x;
+ c.y=location->y;
+ transform_to_geo(location->pro, &c, &geo_location);
+
+ (*env)->CallVoidMethod(jni_o->env, jni_o->jo, jni_o->jm, type, geo_location.lat, geo_location.lng, jaddress);
+ (*env)->DeleteLocalRef(jni_o->env, jaddress);
}
-JNIEXPORT jstring JNICALL
-Java_org_navitproject_navit_NavitGraphics_CallbackLocalizedString( JNIEnv* env, jobject thiz, jobject str)
-{
- const char *s;
- const char *localized_str;
+JNIEXPORT jstring JNICALL Java_org_navitproject_navit_NavitGraphics_CallbackLocalizedString( JNIEnv* env, jobject thiz,
+ jobject str) {
+ const char *s;
+ const char *localized_str;
- s=(*env)->GetStringUTFChars(env, str, NULL);
- //dbg(lvl_debug,"*****string=%s\n",s);
+ s=(*env)->GetStringUTFChars(env, str, NULL);
+ //dbg(lvl_debug,"*****string=%s",s);
- localized_str=navit_nls_gettext(s);
- //dbg(lvl_debug,"localized string=%s",localized_str);
+ localized_str=navit_nls_gettext(s);
+ //dbg(lvl_debug,"localized string=%s",localized_str);
- // jstring dataStringValue = (jstring) localized_str;
- jstring js = (*env)->NewStringUTF(env,localized_str);
+ // jstring dataStringValue = (jstring) localized_str;
+ jstring js = (*env)->NewStringUTF(env,localized_str);
- (*env)->ReleaseStringUTFChars(env, str, s);
+ (*env)->ReleaseStringUTFChars(env, str, s);
- return js;
+ return js;
}
-JNIEXPORT jint JNICALL
-Java_org_navitproject_navit_NavitGraphics_CallbackMessageChannel( JNIEnv* env, jobject thiz, int channel, jobject str)
-{
- struct attr attr;
- const char *s;
- jint ret = 0;
- dbg(lvl_debug,"enter %d %p\n",channel,str);
-
- config_get_attr(config_get(), attr_navit, &attr, NULL);
-
- switch(channel)
- {
- case 1:
- // zoom in
- navit_zoom_in_cursor(attr.u.navit, 2);
- navit_draw(attr.u.navit);
- break;
- case 2:
- // zoom out
- navit_zoom_out_cursor(attr.u.navit, 2);
- navit_draw(attr.u.navit);
- break;
- case 6: // add a map to the current mapset, return 1 on success
- {
- struct mapset *ms = navit_get_mapset(attr.u.navit);
- struct attr type, name, data, *attrs[4];
- const char *map_location=(*env)->GetStringUTFChars(env, str, NULL);
- dbg(lvl_debug,"*****string=%s\n",map_location);
- type.type=attr_type;
- type.u.str="binfile";
-
- data.type=attr_data;
- data.u.str=g_strdup(map_location);
-
- name.type=attr_name;
- name.u.str=g_strdup(map_location);
-
- attrs[0]=&type; attrs[1]=&data; attrs[2]=&name; attrs[3]=NULL;
-
- struct map * new_map = map_new(NULL, attrs);
- if (new_map) {
- struct attr map_a;
- map_a.type=attr_map;
- map_a.u.map=new_map;
- ret = mapset_add_attr(ms, &map_a);
- navit_draw(attr.u.navit);
- }
- (*env)->ReleaseStringUTFChars(env, str, map_location);
- }
- break;
- case 7: // remove a map to the current mapset, return 1 on success
- {
- struct mapset *ms = navit_get_mapset(attr.u.navit);
- struct attr map_r;
- const char *map_location=(*env)->GetStringUTFChars(env, str, NULL);
- struct map * delete_map = mapset_get_map_by_name(ms, map_location);
-
- if (delete_map)
- {
- dbg(lvl_debug,"delete map %s (%p)", map_location, delete_map);
- map_r.type=attr_map;
- map_r.u.map=delete_map;
- ret = mapset_remove_attr(ms, &map_r);
- navit_draw(attr.u.navit);
- }
- (*env)->ReleaseStringUTFChars(env, str, map_location);
- }
- break;
- case 5:
- // call a command (like in gui)
- s=(*env)->GetStringUTFChars(env, str, NULL);
- dbg(lvl_debug,"*****string=%s\n",s);
- command_evaluate(&attr,s);
- (*env)->ReleaseStringUTFChars(env, str, s);
- break;
- case 4:
- {
- // navigate to display position
- char *pstr;
- struct point p;
- struct coord c;
- struct pcoord pc;
-
- struct transformation *transform=navit_get_trans(attr.u.navit);
-
- s=(*env)->GetStringUTFChars(env, str, NULL);
- char parse_str[strlen(s) + 1];
- strcpy(parse_str, s);
- (*env)->ReleaseStringUTFChars(env, str, s);
- dbg(lvl_debug,"*****string=%s\n",parse_str);
-
- // set destination to (pixel-x#pixel-y)
- // pixel-x
- pstr = strtok (parse_str,"#");
- p.x = atoi(pstr);
- // pixel-y
- pstr = strtok (NULL, "#");
- p.y = atoi(pstr);
-
- dbg(lvl_debug,"11x=%d\n",p.x);
- dbg(lvl_debug,"11y=%d\n",p.y);
-
- transform_reverse(transform, &p, &c);
-
-
- pc.x = c.x;
- pc.y = c.y;
- pc.pro = transform_get_projection(transform);
-
- dbg(lvl_debug,"22x=%d\n",pc.x);
- dbg(lvl_debug,"22y=%d\n",pc.y);
-
- // start navigation asynchronous
- navit_set_destination(attr.u.navit, &pc, parse_str, 1);
- }
- break;
- case 3:
- {
- // navigate to geo position
- char *name;
- s=(*env)->GetStringUTFChars(env, str, NULL);
- char parse_str[strlen(s) + 1];
- strcpy(parse_str, s);
- (*env)->ReleaseStringUTFChars(env, str, s);
- dbg(lvl_debug,"*****string=%s\n",s);
-
- // set destination to (lat#lon#title)
- struct coord_geo g;
- char *p;
- char *stopstring;
-
- // lat
- p = strtok (parse_str,"#");
- g.lat = strtof(p, &stopstring);
- // lon
- p = strtok (NULL, "#");
- g.lng = strtof(p, &stopstring);
- // description
- name = strtok (NULL, "#");
-
- dbg(lvl_debug,"lat=%f\n",g.lat);
- dbg(lvl_debug,"lng=%f\n",g.lng);
- dbg(lvl_debug,"str1=%s\n",name);
-
- struct coord c;
- transform_from_geo(projection_mg, &g, &c);
-
- struct pcoord pc;
- pc.x=c.x;
- pc.y=c.y;
- pc.pro=projection_mg;
-
- // start navigation asynchronous
- navit_set_destination(attr.u.navit, &pc, name, 1);
-
- }
- break;
- default:
- dbg(lvl_error, "Unknown command: %d", channel);
- }
-
- return ret;
+JNIEXPORT jint JNICALL Java_org_navitproject_navit_NavitGraphics_CallbackMessageChannel( JNIEnv* env, jobject thiz,
+ int channel, jobject str) {
+ struct attr attr;
+ const char *s;
+ jint ret = 0;
+ dbg(lvl_debug,"enter %d %p",channel,str);
+
+ config_get_attr(config_get(), attr_navit, &attr, NULL);
+
+ switch(channel) {
+ case 1:
+ // zoom in
+ navit_zoom_in_cursor(attr.u.navit, 2);
+ navit_draw(attr.u.navit);
+ break;
+ case 2:
+ // zoom out
+ navit_zoom_out_cursor(attr.u.navit, 2);
+ navit_draw(attr.u.navit);
+ break;
+ case 6: { // add a map to the current mapset, return 1 on success
+ struct mapset *ms = navit_get_mapset(attr.u.navit);
+ struct attr type, name, data, *attrs[4];
+ const char *map_location=(*env)->GetStringUTFChars(env, str, NULL);
+ dbg(lvl_debug,"*****string=%s",map_location);
+ type.type=attr_type;
+ type.u.str="binfile";
+
+ data.type=attr_data;
+ data.u.str=g_strdup(map_location);
+
+ name.type=attr_name;
+ name.u.str=g_strdup(map_location);
+
+ attrs[0]=&type;
+ attrs[1]=&data;
+ attrs[2]=&name;
+ attrs[3]=NULL;
+
+ struct map * new_map = map_new(NULL, attrs);
+ if (new_map) {
+ struct attr map_a;
+ map_a.type=attr_map;
+ map_a.u.map=new_map;
+ ret = mapset_add_attr(ms, &map_a);
+ navit_draw(attr.u.navit);
+ }
+ (*env)->ReleaseStringUTFChars(env, str, map_location);
+ }
+ break;
+ case 7: { // remove a map to the current mapset, return 1 on success
+ struct mapset *ms = navit_get_mapset(attr.u.navit);
+ struct attr map_r;
+ const char *map_location=(*env)->GetStringUTFChars(env, str, NULL);
+ struct map * delete_map = mapset_get_map_by_name(ms, map_location);
+
+ if (delete_map) {
+ dbg(lvl_debug,"delete map %s (%p)", map_location, delete_map);
+ map_r.type=attr_map;
+ map_r.u.map=delete_map;
+ ret = mapset_remove_attr(ms, &map_r);
+ navit_draw(attr.u.navit);
+ }
+ (*env)->ReleaseStringUTFChars(env, str, map_location);
+ }
+ break;
+ case 5:
+ // call a command (like in gui)
+ s=(*env)->GetStringUTFChars(env, str, NULL);
+ dbg(lvl_debug,"*****string=%s",s);
+ command_evaluate(&attr,s);
+ (*env)->ReleaseStringUTFChars(env, str, s);
+ break;
+ case 4: {
+ // navigate to display position
+ char *pstr;
+ struct point p;
+ struct coord c;
+ struct pcoord pc;
+
+ struct transformation *transform=navit_get_trans(attr.u.navit);
+
+ s=(*env)->GetStringUTFChars(env, str, NULL);
+ char parse_str[strlen(s) + 1];
+ strcpy(parse_str, s);
+ (*env)->ReleaseStringUTFChars(env, str, s);
+ dbg(lvl_debug,"*****string=%s",parse_str);
+
+ // set destination to (pixel-x#pixel-y)
+ // pixel-x
+ pstr = strtok (parse_str,"#");
+ p.x = atoi(pstr);
+ // pixel-y
+ pstr = strtok (NULL, "#");
+ p.y = atoi(pstr);
+
+ dbg(lvl_debug,"11x=%d",p.x);
+ dbg(lvl_debug,"11y=%d",p.y);
+
+ transform_reverse(transform, &p, &c);
+
+
+ pc.x = c.x;
+ pc.y = c.y;
+ pc.pro = transform_get_projection(transform);
+
+ dbg(lvl_debug,"22x=%d",pc.x);
+ dbg(lvl_debug,"22y=%d",pc.y);
+
+ // start navigation asynchronous
+ navit_set_destination(attr.u.navit, &pc, parse_str, 1);
+ }
+ break;
+ case 3: {
+ // navigate to geo position
+ char *name;
+ s=(*env)->GetStringUTFChars(env, str, NULL);
+ char parse_str[strlen(s) + 1];
+ strcpy(parse_str, s);
+ (*env)->ReleaseStringUTFChars(env, str, s);
+ dbg(lvl_debug,"*****string=%s",s);
+
+ // set destination to (lat#lon#title)
+ struct coord_geo g;
+ char *p;
+ char *stopstring;
+
+ // lat
+ p = strtok (parse_str,"#");
+ g.lat = strtof(p, &stopstring);
+ // lon
+ p = strtok (NULL, "#");
+ g.lng = strtof(p, &stopstring);
+ // description
+ name = strtok (NULL, "#");
+
+ dbg(lvl_debug,"lat=%f",g.lat);
+ dbg(lvl_debug,"lng=%f",g.lng);
+ dbg(lvl_debug,"str1=%s",name);
+
+ struct coord c;
+ transform_from_geo(projection_mg, &g, &c);
+
+ struct pcoord pc;
+ pc.x=c.x;
+ pc.y=c.y;
+ pc.pro=projection_mg;
+
+ // start navigation asynchronous
+ navit_set_destination(attr.u.navit, &pc, name, 1);
+
+ }
+ break;
+ default:
+ dbg(lvl_error, "Unknown command: %d", channel);
+ }
+
+ return ret;
}
-JNIEXPORT jstring JNICALL
-Java_org_navitproject_navit_NavitGraphics_GetDefaultCountry( JNIEnv* env, jobject thiz, int channel, jobject str)
-{
- struct attr search_attr, country_name, country_iso2, *country_attr;
- struct tracking *tracking;
- struct search_list_result *res;
- jstring return_string = NULL;
-
- struct attr attr;
- dbg(lvl_debug,"enter %d %p\n",channel,str);
-
- config_get_attr(config_get(), attr_navit, &attr, NULL);
-
- country_attr=country_default();
- tracking=navit_get_tracking(attr.u.navit);
- if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
- country_attr=&search_attr;
- if (country_attr) {
- struct country_search *cs=country_search_new(country_attr, 0);
- struct item *item=country_search_get_item(cs);
- if (item && item_attr_get(item, attr_country_name, &country_name)) {
- struct mapset *ms=navit_get_mapset(attr.u.navit);
- struct search_list *search_list = search_list_new(ms);
- search_attr.type=attr_country_all;
- dbg(lvl_debug,"country %s\n", country_name.u.str);
- search_attr.u.str=country_name.u.str;
- search_list_search(search_list, &search_attr, 0);
- while((res=search_list_get_result(search_list)))
- {
- dbg(lvl_debug,"Get result: %s\n", res->country->iso2);
- }
- if (item_attr_get(item, attr_country_iso2, &country_iso2))
- return_string = (*env)->NewStringUTF(env,country_iso2.u.str);
- }
- country_search_destroy(cs);
- }
-
- return return_string;
+JNIEXPORT jstring JNICALL Java_org_navitproject_navit_NavitGraphics_GetDefaultCountry( JNIEnv* env, jobject thiz,
+ int channel, jobject str) {
+ struct attr search_attr, country_name, country_iso2, *country_attr;
+ struct tracking *tracking;
+ struct search_list_result *res;
+ jstring return_string = NULL;
+
+ struct attr attr;
+ dbg(lvl_debug,"enter %d %p",channel,str);
+
+ config_get_attr(config_get(), attr_navit, &attr, NULL);
+
+ country_attr=country_default();
+ tracking=navit_get_tracking(attr.u.navit);
+ if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
+ country_attr=&search_attr;
+ if (country_attr) {
+ struct country_search *cs=country_search_new(country_attr, 0);
+ struct item *item=country_search_get_item(cs);
+ if (item && item_attr_get(item, attr_country_name, &country_name)) {
+ struct mapset *ms=navit_get_mapset(attr.u.navit);
+ struct search_list *search_list = search_list_new(ms);
+ search_attr.type=attr_country_all;
+ dbg(lvl_debug,"country %s", country_name.u.str);
+ search_attr.u.str=country_name.u.str;
+ search_list_search(search_list, &search_attr, 0);
+ while((res=search_list_get_result(search_list))) {
+ dbg(lvl_debug,"Get result: %s", res->country->iso2);
+ }
+ if (item_attr_get(item, attr_country_iso2, &country_iso2))
+ return_string = (*env)->NewStringUTF(env,country_iso2.u.str);
+ }
+ country_search_destroy(cs);
+ }
+
+ return return_string;
}
-JNIEXPORT jobjectArray JNICALL
-Java_org_navitproject_navit_NavitGraphics_GetAllCountries( JNIEnv* env, jobject thiz)
-{
- struct attr search_attr;
- struct search_list_result *res;
- GList* countries = NULL;
- int country_count = 0;
- jobjectArray all_countries;
-
- struct attr attr;
- dbg(lvl_debug,"enter\n");
-
- config_get_attr(config_get(), attr_navit, &attr, NULL);
-
- struct mapset *ms=navit_get_mapset(attr.u.navit);
- struct search_list *search_list = search_list_new(ms);
- jobjectArray current_country = NULL;
- search_attr.type=attr_country_all;
- //dbg(lvl_debug,"country %s\n", country_name.u.str);
- search_attr.u.str=g_strdup("");//country_name.u.str;
- search_list_search(search_list, &search_attr, 1);
- while((res=search_list_get_result(search_list)))
- {
- dbg(lvl_debug,"Get result: %s\n", res->country->iso2);
-
- if (strlen(res->country->iso2)==2)
- {
- jstring j_iso2 = (*env)->NewStringUTF(env, res->country->iso2);
- jstring j_name = (*env)->NewStringUTF(env, navit_nls_gettext(res->country->name));
-
- current_country = (jobjectArray)(*env)->NewObjectArray(env, 2, (*env)->FindClass(env, "java/lang/String"), NULL);
-
- (*env)->SetObjectArrayElement(env, current_country, 0, j_iso2);
- (*env)->SetObjectArrayElement(env, current_country, 1, j_name);
-
- (*env)->DeleteLocalRef(env, j_iso2);
- (*env)->DeleteLocalRef(env, j_name);
-
- countries = g_list_prepend(countries, current_country);
- country_count++;
- }
- }
-
- search_list_destroy(search_list);
- all_countries = (jobjectArray)(*env)->NewObjectArray(env, country_count, (*env)->GetObjectClass(env, current_country), NULL);
-
- while(countries)
- {
- (*env)->SetObjectArrayElement(env, all_countries, --country_count, countries->data);
- countries = g_list_delete_link( countries, countries);
- }
- return all_countries;
+JNIEXPORT jobjectArray JNICALL Java_org_navitproject_navit_NavitGraphics_GetAllCountries( JNIEnv* env, jobject thiz) {
+ struct attr search_attr;
+ struct search_list_result *res;
+ GList* countries = NULL;
+ int country_count = 0;
+ jobjectArray all_countries;
+
+ struct attr attr;
+ dbg(lvl_debug,"enter");
+
+ config_get_attr(config_get(), attr_navit, &attr, NULL);
+
+ struct mapset *ms=navit_get_mapset(attr.u.navit);
+ struct search_list *search_list = search_list_new(ms);
+ jobjectArray current_country = NULL;
+ search_attr.type=attr_country_all;
+ //dbg(lvl_debug,"country %s", country_name.u.str);
+ search_attr.u.str=g_strdup("");//country_name.u.str;
+ search_list_search(search_list, &search_attr, 1);
+ while((res=search_list_get_result(search_list))) {
+ dbg(lvl_debug,"Get result: %s", res->country->iso2);
+
+ if (strlen(res->country->iso2)==2) {
+ jstring j_iso2 = (*env)->NewStringUTF(env, res->country->iso2);
+ jstring j_name = (*env)->NewStringUTF(env, navit_nls_gettext(res->country->name));
+
+ current_country = (jobjectArray)(*env)->NewObjectArray(env, 2, (*env)->FindClass(env, "java/lang/String"), NULL);
+
+ (*env)->SetObjectArrayElement(env, current_country, 0, j_iso2);
+ (*env)->SetObjectArrayElement(env, current_country, 1, j_name);
+
+ (*env)->DeleteLocalRef(env, j_iso2);
+ (*env)->DeleteLocalRef(env, j_name);
+
+ countries = g_list_prepend(countries, current_country);
+ country_count++;
+ }
+ }
+
+ search_list_destroy(search_list);
+ all_countries = (jobjectArray)(*env)->NewObjectArray(env, country_count, (*env)->GetObjectClass(env, current_country),
+ NULL);
+
+ while(countries) {
+ (*env)->SetObjectArrayElement(env, all_countries, --country_count, countries->data);
+ countries = g_list_delete_link( countries, countries);
+ }
+ return all_countries;
}
-static char *
-postal_str(struct search_list_result *res, int level)
-{
- char *ret=NULL;
- if (res->town->common.postal)
- ret=res->town->common.postal;
- if (res->town->common.postal_mask)
- ret=res->town->common.postal_mask;
- if (level == 1)
- return ret;
- if (res->street->common.postal)
- ret=res->street->common.postal;
- if (res->street->common.postal_mask)
- ret=res->street->common.postal_mask;
- if (level == 2)
- return ret;
- if (res->house_number->common.postal)
- ret=res->house_number->common.postal;
- if (res->house_number->common.postal_mask)
- ret=res->house_number->common.postal_mask;
- return ret;
+static char *postal_str(struct search_list_result *res, int level) {
+ char *ret=NULL;
+ if (res->town->common.postal)
+ ret=res->town->common.postal;
+ if (res->town->common.postal_mask)
+ ret=res->town->common.postal_mask;
+ if (level == 1)
+ return ret;
+ if (res->street->common.postal)
+ ret=res->street->common.postal;
+ if (res->street->common.postal_mask)
+ ret=res->street->common.postal_mask;
+ if (level == 2)
+ return ret;
+ if (res->house_number->common.postal)
+ ret=res->house_number->common.postal;
+ if (res->house_number->common.postal_mask)
+ ret=res->house_number->common.postal_mask;
+ return ret;
}
-static char *
-district_str(struct search_list_result *res, int level)
-{
- char *ret=NULL;
- if (res->town->common.district_name)
- ret=res->town->common.district_name;
- if (level == 1)
- return ret;
- if (res->street->common.district_name)
- ret=res->street->common.district_name;
- if (level == 2)
- return ret;
- if (res->house_number->common.district_name)
- ret=res->house_number->common.district_name;
- return ret;
+static char *district_str(struct search_list_result *res, int level) {
+ char *ret=NULL;
+ if (res->town->common.district_name)
+ ret=res->town->common.district_name;
+ if (level == 1)
+ return ret;
+ if (res->street->common.district_name)
+ ret=res->street->common.district_name;
+ if (level == 2)
+ return ret;
+ if (res->house_number->common.district_name)
+ ret=res->house_number->common.district_name;
+ return ret;
}
-static char *
-town_str(struct search_list_result *res, int level)
-{
- char *town=res->town->common.town_name;
- char *district=district_str(res, level);
- char *postal=postal_str(res, level);
- char *postal_sep=" ";
- char *district_begin=" (";
- char *district_end=")";
- char *county_sep = ", Co. ";
- char *county = res->town->common.county_name;
- if (!postal)
- postal_sep=postal="";
- if (!district)
- district_begin=district_end=district="";
- if (!county)
- county_sep=county="";
-
- return g_strdup_printf("%s%s%s%s%s%s%s%s", postal, postal_sep, town, district_begin, district, district_end, county_sep, county);
+static char *town_str(struct search_list_result *res, int level) {
+ char *town=res->town->common.town_name;
+ char *district=district_str(res, level);
+ char *postal=postal_str(res, level);
+ char *postal_sep=" ";
+ char *district_begin=" (";
+ char *district_end=")";
+ char *county_sep = ", Co. ";
+ char *county = res->town->common.county_name;
+ if (!postal)
+ postal_sep=postal="";
+ if (!district)
+ district_begin=district_end=district="";
+ if (!county)
+ county_sep=county="";
+
+ return g_strdup_printf("%s%s%s%s%s%s%s%s", postal, postal_sep, town, district_begin, district, district_end, county_sep,
+ county);
}
-static void
-android_search_end(struct android_search_priv *search_priv)
-{
- dbg(lvl_debug, "End search");
- JNIEnv* env = search_priv->search_result_obj.env;
- if (search_priv->idle_ev) {
- event_remove_idle(search_priv->idle_ev);
- search_priv->idle_ev=NULL;
- }
- if (search_priv->idle_clb) {
- callback_destroy(search_priv->idle_clb);
- search_priv->idle_clb=NULL;
- }
- jclass cls = (*env)->GetObjectClass(env,search_priv->search_result_obj.jo);
- jmethodID finish_MethodID = (*env)->GetMethodID(env, cls, "finishAddressSearch", "()V");
- if(finish_MethodID != 0) {
- (*env)->CallVoidMethod(env, search_priv->search_result_obj.jo, finish_MethodID);
- } else {
- dbg(lvl_error, "Error method finishAddressSearch not found");
- }
-
- search_list_destroy(search_priv->search_list);
- g_strfreev(search_priv->phrases);
- g_free(search_priv);
+static void android_search_end(struct android_search_priv *search_priv) {
+ dbg(lvl_debug, "End search");
+ JNIEnv* env = search_priv->search_result_obj.env;
+ if (search_priv->idle_ev) {
+ event_remove_idle(search_priv->idle_ev);
+ search_priv->idle_ev=NULL;
+ }
+ if (search_priv->idle_clb) {
+ callback_destroy(search_priv->idle_clb);
+ search_priv->idle_clb=NULL;
+ }
+ jclass cls = (*env)->GetObjectClass(env,search_priv->search_result_obj.jo);
+ jmethodID finish_MethodID = (*env)->GetMethodID(env, cls, "finishAddressSearch", "()V");
+ if(finish_MethodID != 0) {
+ (*env)->CallVoidMethod(env, search_priv->search_result_obj.jo, finish_MethodID);
+ } else {
+ dbg(lvl_error, "Error method finishAddressSearch not found");
+ }
+
+ search_list_destroy(search_priv->search_list);
+ g_strfreev(search_priv->phrases);
+ g_free(search_priv);
}
static enum attr_type android_search_level[] = {
- attr_town_or_district_name,
- attr_street_name,
- attr_house_number
+ attr_town_or_district_name,
+ attr_street_name,
+ attr_house_number
};
-static void
-android_search_idle(struct android_search_priv *search_priv)
-{
- dbg(lvl_debug, "enter android_search_idle");
-
- struct search_list_result *res = search_list_get_result(search_priv->search_list);
- if (res) {
- dbg(lvl_debug, "Town: %s, Street: %s\n",res->town ? res->town->common.town_name : "no town", res->street ? res->street->name : "no street");
- search_priv->found = 1;
- switch (search_priv->search_attr.type)
- {
- case attr_town_or_district_name:
- {
- gchar *town = town_str(res, 1);
- android_return_search_result(&search_priv->search_result_obj, 0, res->town->common.c, town);
- g_free(town);
- break;
- }
- case attr_street_name:
- {
- gchar *town = town_str(res, 2);
- gchar *address = g_strdup_printf("%.101s,%.101s, %.101s", res->country->name, town, res->street->name);
- android_return_search_result(&search_priv->search_result_obj, 1, res->street->common.c, address);
- g_free(address);
- g_free(town);
- break;
- }
- case attr_house_number:
- {
- gchar *town = town_str(res, 3);
- gchar *address = g_strdup_printf("%.101s, %.101s, %.101s %.15s", res->country->name, town, res->street->name, res->house_number->house_number);
- android_return_search_result(&search_priv->search_result_obj, 2, res->house_number->common.c, address);
- g_free(address);
- g_free(town);
- break;
- }
- default:
- dbg(lvl_error, "Unhandled search type %d", search_priv->search_attr.type);
- }
- } else {
- int level = search_list_level(search_priv->search_attr.type) - 1;
-
- if (search_priv->found) {
- search_priv->found = 0;
- if (search_priv->search_attr.type != attr_house_number) {
- level++;
- }
- }
- dbg(lvl_info, "test phrase: %d,%d, %d, level %d", search_priv->current_phrase_per_level[0], search_priv->current_phrase_per_level[1], search_priv->current_phrase_per_level[2] , level)
- do {
- while (!search_priv->phrases[++search_priv->current_phrase_per_level[level]]) {
- dbg(lvl_info, "next phrase: %d,%d, %d, level %d", search_priv->current_phrase_per_level[0], search_priv->current_phrase_per_level[1], search_priv->current_phrase_per_level[2] , level)
- if (level > 0) {
- search_priv->current_phrase_per_level[level] = -1;
- level--;
- } else {
- android_search_end(search_priv);
- return;
- }
- }
- } while (level > 0 ? search_priv->current_phrase_per_level[level] == search_priv->current_phrase_per_level[level-1] : 0);
- dbg(lvl_info, "used phrase: %d,%d, %d, level %d, '%s'", search_priv->current_phrase_per_level[0], search_priv->current_phrase_per_level[1], search_priv->current_phrase_per_level[2] , level, attr_to_name(android_search_level[level]))
- dbg(lvl_debug, "Search for '%s'", search_priv->phrases[search_priv->current_phrase_per_level[level]]);
- search_priv->search_attr.type = android_search_level[level];
- search_priv->search_attr.u.str = search_priv->phrases[search_priv->current_phrase_per_level[level]];
- struct attr test;
- test.type = android_search_level[level];
- test.u.str = search_priv->phrases[search_priv->current_phrase_per_level[level]];
- search_list_search(search_priv->search_list, &test, search_priv->partial);
- }
- dbg(lvl_info, "leave");
+static void android_search_idle(struct android_search_priv *search_priv) {
+ dbg(lvl_debug, "enter android_search_idle");
+
+ struct search_list_result *res = search_list_get_result(search_priv->search_list);
+ if (res) {
+ dbg(lvl_debug, "Town: %s, Street: %s",res->town ? res->town->common.town_name : "no town",
+ res->street ? res->street->name : "no street");
+ search_priv->found = 1;
+ switch (search_priv->search_attr.type) {
+ case attr_town_or_district_name: {
+ gchar *town = town_str(res, 1);
+ android_return_search_result(&search_priv->search_result_obj, 0, res->town->common.c, town);
+ g_free(town);
+ break;
+ }
+ case attr_street_name: {
+ gchar *town = town_str(res, 2);
+ gchar *address = g_strdup_printf("%.101s,%.101s, %.101s", res->country->name, town, res->street->name);
+ android_return_search_result(&search_priv->search_result_obj, 1, res->street->common.c, address);
+ g_free(address);
+ g_free(town);
+ break;
+ }
+ case attr_house_number: {
+ gchar *town = town_str(res, 3);
+ gchar *address = g_strdup_printf("%.101s, %.101s, %.101s %.15s", res->country->name, town, res->street->name,
+ res->house_number->house_number);
+ android_return_search_result(&search_priv->search_result_obj, 2, res->house_number->common.c, address);
+ g_free(address);
+ g_free(town);
+ break;
+ }
+ default:
+ dbg(lvl_error, "Unhandled search type %d", search_priv->search_attr.type);
+ }
+ } else {
+ int level = search_list_level(search_priv->search_attr.type) - 1;
+
+ if (search_priv->found) {
+ search_priv->found = 0;
+ if (search_priv->search_attr.type != attr_house_number) {
+ level++;
+ }
+ }
+ dbg(lvl_info, "test phrase: %d,%d, %d, level %d", search_priv->current_phrase_per_level[0],
+ search_priv->current_phrase_per_level[1], search_priv->current_phrase_per_level[2], level)
+ do {
+ while (!search_priv->phrases[++search_priv->current_phrase_per_level[level]]) {
+ dbg(lvl_info, "next phrase: %d,%d, %d, level %d", search_priv->current_phrase_per_level[0],
+ search_priv->current_phrase_per_level[1], search_priv->current_phrase_per_level[2], level)
+ if (level > 0) {
+ search_priv->current_phrase_per_level[level] = -1;
+ level--;
+ } else {
+ android_search_end(search_priv);
+ return;
+ }
+ }
+ } while (level > 0 ? search_priv->current_phrase_per_level[level] == search_priv->current_phrase_per_level[level-1] :
+ 0);
+ dbg(lvl_info, "used phrase: %d,%d, %d, level %d, '%s'", search_priv->current_phrase_per_level[0],
+ search_priv->current_phrase_per_level[1], search_priv->current_phrase_per_level[2], level,
+ attr_to_name(android_search_level[level]))
+ dbg(lvl_debug, "Search for '%s'", search_priv->phrases[search_priv->current_phrase_per_level[level]]);
+ search_priv->search_attr.type = android_search_level[level];
+ search_priv->search_attr.u.str = search_priv->phrases[search_priv->current_phrase_per_level[level]];
+ struct attr test;
+ test.type = android_search_level[level];
+ test.u.str = search_priv->phrases[search_priv->current_phrase_per_level[level]];
+ search_list_search(search_priv->search_list, &test, search_priv->partial);
+ }
+ dbg(lvl_info, "leave");
}
-static char *
-search_fix_spaces(const char *str)
-{
- int i;
- int len=strlen(str);
- char c,*s,*d,*ret=g_strdup(str);
-
- for (i = 0 ; i < len ; i++) {
- if (ret[i] == ',' || ret[i] == ',' || ret[i] == '/')
- ret[i]=' ';
- }
- s=ret;
- d=ret;
- len=0;
- do {
- c=*s++;
- if (c != ' ' || len != 0) {
- *d++=c;
- len++;
- }
- while (c == ' ' && *s == ' ')
- s++;
- if (c == ' ' && *s == '\0') {
- d--;
- len--;
- }
- } while (c);
- return ret;
+static char *search_fix_spaces(const char *str) {
+ int i;
+ int len=strlen(str);
+ char c,*s,*d,*ret=g_strdup(str);
+
+ for (i = 0 ; i < len ; i++) {
+ if (ret[i] == ',' || ret[i] == ',' || ret[i] == '/')
+ ret[i]=' ';
+ }
+ s=ret;
+ d=ret;
+ len=0;
+ do {
+ c=*s++;
+ if (c != ' ' || len != 0) {
+ *d++=c;
+ len++;
+ }
+ while (c == ' ' && *s == ' ')
+ s++;
+ if (c == ' ' && *s == '\0') {
+ d--;
+ len--;
+ }
+ } while (c);
+ return ret;
}
-static void start_search(struct android_search_priv *search_priv, const char *search_string)
-{
- dbg(lvl_debug,"enter %s\n", search_string);
- char *str=search_fix_spaces(search_string);
- search_priv->phrases = g_strsplit(str, " ", 0);
- //ret=search_address_town(ret, sl, phrases, NULL, partial, jni);
+static void start_search(struct android_search_priv *search_priv, const char *search_string) {
+ dbg(lvl_debug,"enter %s", search_string);
+ char *str=search_fix_spaces(search_string);
+ search_priv->phrases = g_strsplit(str, " ", 0);
+ //ret=search_address_town(ret, sl, phrases, NULL, partial, jni);
- dbg(lvl_debug,"First search phrase %s", search_priv->phrases[0]);
- search_priv->search_attr.u.str= search_priv->phrases[0];
- search_priv->search_attr.type=attr_town_or_district_name;
- search_list_search(search_priv->search_list, &search_priv->search_attr, search_priv->partial);
+ dbg(lvl_debug,"First search phrase %s", search_priv->phrases[0]);
+ search_priv->search_attr.u.str= search_priv->phrases[0];
+ search_priv->search_attr.type=attr_town_or_district_name;
+ search_list_search(search_priv->search_list, &search_priv->search_attr, search_priv->partial);
- search_priv->idle_clb = callback_new_1(callback_cast(android_search_idle), search_priv);
- search_priv->idle_ev = event_add_idle(50,search_priv->idle_clb);
- //callback_call_0(search_priv->idle_clb);
+ search_priv->idle_clb = callback_new_1(callback_cast(android_search_idle), search_priv);
+ search_priv->idle_ev = event_add_idle(50,search_priv->idle_clb);
+ //callback_call_0(search_priv->idle_clb);
- g_free(str);
- dbg(lvl_debug,"leave\n");
+ g_free(str);
+ dbg(lvl_debug,"leave");
}
-JNIEXPORT jlong JNICALL
-Java_org_navitproject_navit_NavitAddressSearchActivity_CallbackStartAddressSearch( JNIEnv* env, jobject thiz, int partial, jobject country, jobject str)
-{
- struct attr attr;
- const char *search_string =(*env)->GetStringUTFChars(env, str, NULL);
- dbg(lvl_debug,"search '%s'\n", search_string);
-
- config_get_attr(config_get(), attr_navit, &attr, NULL);
-
- jclass cls = (*env)->GetObjectClass(env,thiz);
- jmethodID aMethodID = (*env)->GetMethodID(env, cls, "receiveAddress", "(IFFLjava/lang/String;)V");
- struct android_search_priv *search_priv = NULL;
-
- if(aMethodID != 0)
- {
- struct mapset *ms4=navit_get_mapset(attr.u.navit);
- struct attr country_attr;
- const char *str_country=(*env)->GetStringUTFChars(env, country, NULL);
- struct search_list_result *slr;
- int count = 0;
-
- search_priv = g_new0( struct android_search_priv, 1);
- search_priv->search_list = search_list_new(ms4);
- search_priv->partial = partial;
- search_priv->current_phrase_per_level[1] = -1;
- search_priv->current_phrase_per_level[2] = -1;
-
- country_attr.type=attr_country_iso2;
- country_attr.u.str=g_strdup(str_country);
- search_list_search(search_priv->search_list, &country_attr, 0);
-
- while ((slr=search_list_get_result(search_priv->search_list)))
- {
- count++;
- }
- if (!count)
- dbg(lvl_error,"Country not found");
-
- dbg(lvl_debug,"search in country '%s'\n", str_country);
- (*env)->ReleaseStringUTFChars(env, country, str_country);
-
- search_priv->search_result_obj.env = env;
- search_priv->search_result_obj.jo = (*env)->NewGlobalRef(env, thiz);
- search_priv->search_result_obj.jm = aMethodID;
-
- start_search(search_priv, search_string);
- }
- else
- dbg(lvl_error,"**** Unable to get methodID: fillStringArray");
-
- (*env)->ReleaseStringUTFChars(env, str, search_string);
-
- return (jlong)(long)search_priv;
+JNIEXPORT jlong JNICALL Java_org_navitproject_navit_NavitAddressSearchActivity_CallbackStartAddressSearch( JNIEnv* env,
+ jobject thiz, int partial, jobject country, jobject str) {
+ struct attr attr;
+ const char *search_string =(*env)->GetStringUTFChars(env, str, NULL);
+ dbg(lvl_debug,"search '%s'", search_string);
+
+ config_get_attr(config_get(), attr_navit, &attr, NULL);
+
+ jclass cls = (*env)->GetObjectClass(env,thiz);
+ jmethodID aMethodID = (*env)->GetMethodID(env, cls, "receiveAddress", "(IFFLjava/lang/String;)V");
+ struct android_search_priv *search_priv = NULL;
+
+ if(aMethodID != 0) {
+ struct mapset *ms4=navit_get_mapset(attr.u.navit);
+ struct attr country_attr;
+ const char *str_country=(*env)->GetStringUTFChars(env, country, NULL);
+ struct search_list_result *slr;
+ int count = 0;
+
+ search_priv = g_new0( struct android_search_priv, 1);
+ search_priv->search_list = search_list_new(ms4);
+ search_priv->partial = partial;
+ search_priv->current_phrase_per_level[1] = -1;
+ search_priv->current_phrase_per_level[2] = -1;
+
+ country_attr.type=attr_country_iso2;
+ country_attr.u.str=g_strdup(str_country);
+ search_list_search(search_priv->search_list, &country_attr, 0);
+
+ while ((slr=search_list_get_result(search_priv->search_list))) {
+ count++;
+ }
+ if (!count)
+ dbg(lvl_error,"Country not found");
+
+ dbg(lvl_debug,"search in country '%s'", str_country);
+ (*env)->ReleaseStringUTFChars(env, country, str_country);
+
+ search_priv->search_result_obj.env = env;
+ search_priv->search_result_obj.jo = (*env)->NewGlobalRef(env, thiz);
+ search_priv->search_result_obj.jm = aMethodID;
+
+ start_search(search_priv, search_string);
+ } else
+ dbg(lvl_error,"**** Unable to get methodID: fillStringArray");
+
+ (*env)->ReleaseStringUTFChars(env, str, search_string);
+
+ return (jlong)(long)search_priv;
}
-JNIEXPORT void JNICALL
-Java_org_navitproject_navit_NavitAddressSearchActivity_CallbackCancelAddressSearch( JNIEnv* env, jobject thiz, jlong handle)
-{
- struct android_search_priv *priv = (void*)(long)handle;
+JNIEXPORT void JNICALL Java_org_navitproject_navit_NavitAddressSearchActivity_CallbackCancelAddressSearch( JNIEnv* env,
+ jobject thiz, jlong handle) {
+ struct android_search_priv *priv = (void*)(long)handle;
- if (priv)
- android_search_end(priv);
- else
- dbg(lvl_error, "Error: Cancel search failed");
+ if (priv)
+ android_search_end(priv);
+ else
+ dbg(lvl_error, "Error: Cancel search failed");
}
diff --git a/navit/android.h b/navit/android.h
index 24774d0e5..ee8b1b4b5 100644
--- a/navit/android.h
+++ b/navit/android.h
@@ -1,6 +1,7 @@
#include <jni.h>
extern JNIEnv *jnienv;
extern jobject *android_activity;
+extern jobject *android_application;
extern int android_version;
int android_find_class_global(char *name, jclass *ret);
int android_find_method(jclass class, char *name, char *args, jmethodID *ret);
diff --git a/navit/android/AndroidManifest.xml b/navit/android/AndroidManifest.xml
new file mode 100644
index 000000000..5080ec52b
--- /dev/null
+++ b/navit/android/AndroidManifest.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.navitproject.navit"
+ android:installLocation="auto">
+ <uses-feature android:name="android.hardware.location.network" android:required="false"/>
+ <uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
+ <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:resizeable="true" android:anyDensity="true"/>
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <application android:label="@string/app_name"
+ android:icon="@drawable/icon"
+ android:name=".NavitAppConfig"
+ android:theme="@style/NavitBaseTheme">
+ <activity android:name="Navit"
+ android:label="@string/app_name"
+ android:configChanges="locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|fontScale|screenSize"
+ android:theme="@style/NavitTheme">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="google.navigation" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".NavitAddressSearchActivity"
+ android:configChanges="orientation|screenSize|keyboardHidden">
+ </activity>
+ <activity android:name=".NavitDownloadSelectMapActivity"></activity>
+ <!-- <activity android:name=".NavitAddressResultListActivity"></activity> -->
+ <activity
+ android:name="FileBrowserActivity"
+ android:label="File browser"
+ android:configChanges="orientation|keyboardHidden">
+ <intent-filter>
+ <action android:name="ua.com.vassiliev.androidfilebrowser.SELECT_DIRECTORY_ACTION"></action>
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/navit/android/AndroidManifest.xml.cmake b/navit/android/AndroidManifest.xml.cmake
index 7aa882bb8..811a895d2 100644
--- a/navit/android/AndroidManifest.xml.cmake
+++ b/navit/android/AndroidManifest.xml.cmake
@@ -28,24 +28,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:scheme="google.navigation" />
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="google.navigation" />
</intent-filter>
</activity>
<activity android:name=".NavitAddressSearchActivity"></activity>
<activity android:name=".NavitDownloadSelectMapActivity"></activity>
<activity android:name=".NavitAddressResultListActivity"></activity>
<activity android:name=".FileBrowserActivity"></activity>
- <activity
- android:name="org.acra.dialog.CrashReportDialog"
- android:theme="@android:style/Theme.Dialog"
- android:launchMode="singleInstance"
- android:excludeFromRecents="true"
- android:finishOnTaskLaunch="true"/>
- <service
- android:name="org.acra.sender.SenderService"
- android:exported="false"
- android:process=":acra" />
</application>
-</manifest>
+</manifest>
diff --git a/navit/android/CMakeLists.txt b/navit/android/CMakeLists.txt
index 6a9b9c92f..64bd47f8e 100644
--- a/navit/android/CMakeLists.txt
+++ b/navit/android/CMakeLists.txt
@@ -1,86 +1,112 @@
-if (ANDROID)
+if (ANDROID AND NOT ${CMAKE_GENERATOR} STREQUAL Ninja)
- FILE(GLOB SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*/*/*/*")
+ FILE(GLOB SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*/*/*/*")
- foreach ( PERMISSION ${ANDROID_PERMISSIONS})
- set(ANDROID_PERMISSIONS_EXPANDED "${ANDROID_PERMISSIONS_EXPANDED}<uses-permission\tandroid:name=\\\"android.permission.${PERMISSION}\\\"/>" )
- endforeach()
+ foreach ( PERMISSION ${ANDROID_PERMISSIONS})
+ set(ANDROID_PERMISSIONS_EXPANDED "${ANDROID_PERMISSIONS_EXPANDED}<uses-permission\tandroid:name=\\\"android.permission.${PERMISSION}\\\"/>" )
+ endforeach()
- # Generate Android string resource files from gettext .po.in files.
- # Note: Android language resources should have two letter ISO 639-1 code, and, optionally, iso-3166-1-alpha-2 region code,
- # so we skip all translation files which do not conform these requirements.
- FILE(GLOB POIN_FILES1 RELATIVE ${CMAKE_SOURCE_DIR}/po "${CMAKE_SOURCE_DIR}/po/??.po.in")
- FILE(GLOB POIN_FILES2 RELATIVE ${CMAKE_SOURCE_DIR}/po "${CMAKE_SOURCE_DIR}/po/??_??.po.in")
- set(POIN_FILES ${POIN_FILES1} ${POIN_FILES2})
- foreach (POIN_FILE ${POIN_FILES})
- string(REPLACE ".po.in" "" LANG ${POIN_FILE})
- string(REPLACE "_" "-r" LANG ${LANG})
- set(LANG_RESOURCES ${LANG_RESOURCES} "${CMAKE_CURRENT_BINARY_DIR}/res/values-${LANG}/strings.xml")
- compose_xslt_transform_command(TRANS "${CMAKE_CURRENT_SOURCE_DIR}/po2xml.xslt" "${CMAKE_CURRENT_SOURCE_DIR}/res/values/strings.xml" "${CMAKE_CURRENT_BINARY_DIR}/res/values-${LANG}/strings.xml" "po_file=${CMAKE_SOURCE_DIR}/po/${POIN_FILE}")
- ADD_CUSTOM_COMMAND(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/res/values-${LANG}/strings.xml"
- DEPENDS "${CMAKE_BINARY_DIR}/po/navit.pot" "${CMAKE_SOURCE_DIR}/po/${POIN_FILE}" "${CMAKE_CURRENT_SOURCE_DIR}/po2xml.xslt" "${CMAKE_CURRENT_SOURCE_DIR}/res/values/strings.xml"
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/res/values-${LANG}
- ${TRANS}
- )
- endforeach(POIN_FILE ${POIN_FILES})
+ # Generate Android string resource files from gettext .po.in files.
+ # Note: Android language resources should have two letter ISO 639-1 code, and, optionally, iso-3166-1-alpha-2 region code,
+ # so we skip all translation files which do not conform these requirements.
+ FILE(GLOB POIN_FILES1 RELATIVE ${CMAKE_SOURCE_DIR}/po "${CMAKE_SOURCE_DIR}/po/??.po.in")
+ FILE(GLOB POIN_FILES2 RELATIVE ${CMAKE_SOURCE_DIR}/po "${CMAKE_SOURCE_DIR}/po/??_??.po.in")
+ set(POIN_FILES ${POIN_FILES1} ${POIN_FILES2})
+ foreach (POIN_FILE ${POIN_FILES})
+ string(REPLACE ".po.in" "" LANG ${POIN_FILE})
+ string(REPLACE "_" "-r" LANG ${LANG})
+ set(LANG_RESOURCES ${LANG_RESOURCES} "${CMAKE_CURRENT_BINARY_DIR}/res/values-${LANG}/strings.xml")
+ compose_xslt_transform_command(TRANS "${CMAKE_CURRENT_SOURCE_DIR}/po2xml.xslt" "${CMAKE_CURRENT_SOURCE_DIR}/res/values/strings.xml" "${CMAKE_CURRENT_BINARY_DIR}/res/values-${LANG}/strings.xml" "po_file=${CMAKE_SOURCE_DIR}/po/${POIN_FILE}")
+ ADD_CUSTOM_COMMAND(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/res/values-${LANG}/strings.xml"
+ DEPENDS "${CMAKE_BINARY_DIR}/po/navit.pot" "${CMAKE_SOURCE_DIR}/po/${POIN_FILE}" "${CMAKE_CURRENT_SOURCE_DIR}/po2xml.xslt" "${CMAKE_CURRENT_SOURCE_DIR}/res/values/strings.xml"
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/res/values-${LANG}
+ ${TRANS}
+ )
+ endforeach(POIN_FILE ${POIN_FILES})
- add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/AndroidManifest.xml
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/AndroidManifest.xml.cmake
- COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/AndroidManifest.xml.cmake
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/AndroidManifest.xml
- -D NAME=ANDROID_VERSION_INT
- -D ANDROID_VERSION_NAME=${PACKAGE_STRING}
- -D ANDROID_API_VERSION=${ANDROID_API_VERSION}
- -D ANDROID_PERMISSIONS:string="${ANDROID_PERMISSIONS_EXPANDED}"
- -D STRIP_M="1"
- -P ${PROJECT_SOURCE_DIR}/cmake/version.cmake
- )
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/AndroidManifest.xml
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/AndroidManifest.xml.cmake
+ COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/AndroidManifest.xml.cmake
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/AndroidManifest.xml
+ -D NAME=ANDROID_VERSION_INT
+ -D ANDROID_VERSION_NAME=${PACKAGE_STRING}
+ -D ANDROID_API_VERSION=${ANDROID_API_VERSION}
+ -D ANDROID_PERMISSIONS:string="${ANDROID_PERMISSIONS_EXPANDED}"
+ -D STRIP_M="1"
+ )
- add_custom_command (
- OUTPUT build.xml
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/AndroidManifest.xml ${SRC_FILES}
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
- COMMAND android update project -t android-${ANDROID_API_VERSION} -p ${CMAKE_CURRENT_BINARY_DIR}
- )
+ add_custom_command (
+ OUTPUT build.xml
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/AndroidManifest.xml ${SRC_FILES}
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND android update project -t android-${ANDROID_API_VERSION} -p ${CMAKE_CURRENT_BINARY_DIR}
+ )
- add_custom_target( android_resources
- DEPENDS build.xml ${MODULES_NAME} ${NAVIT_SUPPORT_LIBS} ${LANG_RESOURCES}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/res/raw/
- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH}
- COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/navit/libnavit.so ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH}/
- COMMAND ${CMAKE_COMMAND}
- -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/navit*.xml"
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/raw
- -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
- COMMAND ${CMAKE_COMMAND}
- -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/icons/*.png"
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/drawable-nodpi
- -D LOWER=1
- -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
- COMMAND ${CMAKE_COMMAND}
- -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/*/*/.libs/lib[b-z]*.so"
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH}
- -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
- COMMAND ${CMAKE_COMMAND}
- -D GLOB_EXP="${PROJECT_BINARY_DIR}/po/*.mo"
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/raw
- -D LOWER=1
- -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
- )
-
- add_dependencies (android_resources images locales ${NAVIT_LIBNAME})
-
- add_custom_target ( apkg
- COMMAND ant debug
- )
-
- add_custom_target ( apkg-release
- COMMAND ant release
- )
+ add_custom_target( android_resources
+ DEPENDS build.xml ${MODULES_NAME} ${NAVIT_SUPPORT_LIBS} ${LANG_RESOURCES}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/res/raw/
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/ldpi
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/mdpi
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/hdpi
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/xhdpi
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/xxhdpi
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/assets/config/xxxhdpi
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH}
+ COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/navit/libnavit.so ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH}/
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/ldpi/*.xml"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/ldpi
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/mdpi/*.xml"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/mdpi
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/hdpi/*.xml"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/hdpi
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/xhdpi/*.xml"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/xhdpi
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/xxhdpi/*.xml"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/xxhdpi
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/config/xxxhdpi/*.xml"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/assets/config/xxxhdpi
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/icons/*.png"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/drawable-nodpi
+ -D LOWER=1
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${PROJECT_BINARY_DIR}/navit/*/*/.libs/lib[b-z]*.so"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_ARCH}
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${PROJECT_BINARY_DIR}/po/*.mo"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/res/raw
+ -D LOWER=1
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ )
- add_dependencies(apkg android_resources)
- add_dependencies(apkg-release android_resources)
-
-endif(ANDROID)
+ add_dependencies (android_resources images locales ${NAVIT_LIBNAME})
+
+ add_custom_target ( apkg
+ COMMAND ant debug
+ )
+
+ add_custom_target ( apkg-release
+ COMMAND ant release
+ )
+
+ add_dependencies(apkg android_resources)
+ add_dependencies(apkg-release android_resources)
+
+endif(ANDROID AND NOT ${CMAKE_GENERATOR} STREQUAL Ninja)
diff --git a/navit/android/android_layout_default_new.xml b/navit/android/android_layout_default_new.xml
index d36659f1e..8433ad6a2 100644
--- a/navit/android/android_layout_default_new.xml
+++ b/navit/android/android_layout_default_new.xml
@@ -834,7 +834,7 @@
<icon src="danger_16_16.png"/>
</itemgra>
<itemgra item_types="poi_forbidden_area" order="13-">
- <icon src="forbiden_area.png"/>
+ <icon src="forbidden_area.png"/>
</itemgra>
<itemgra item_types="poi_tunnel" order="12-">
<icon src="tunnel.png"/>
diff --git a/navit/android/build.gradle b/navit/android/build.gradle
new file mode 100644
index 000000000..1385336bf
--- /dev/null
+++ b/navit/android/build.gradle
@@ -0,0 +1,96 @@
+apply plugin: 'com.android.application'
+apply from: "$project.rootDir/gradle/scripts/git-scm-version.gradle"
+apply plugin: 'checkstyle'
+
+android {
+ compileSdkVersion 27
+ buildToolsVersion "27.0.3"
+ defaultConfig {
+ applicationId "org.navitproject.navit"
+ minSdkVersion 9
+ targetSdkVersion 27
+ versionCode gitVersionCode
+ versionName gitVersionName
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ ndk { // need for now for 'x86_64' and , 'armeabi' and , 'arm64-v8a'
+ abiFilters 'x86', 'armeabi-v7a'
+ }
+ externalNativeBuild {
+ cmake {
+ arguments '-DUSE_PLUGINS=n', '-DBUILD_MAPTOOL=n', '-DXSL_PROCESSING=y', '-DXSLTS=android', '-DANDROID=y', '-DSAMPLE_MAP=n'
+ }
+ }
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+ lintOptions {
+ disable 'UnusedResources'
+ abortOnError true
+ }
+ sourceSets {
+ main {
+ manifest.srcFile "AndroidManifest.xml"
+ java.srcDirs = ["src"]
+ resources.srcDirs = ["src"]
+ renderscript.srcDirs = ["src"]
+ res.srcDirs = ["res"]
+ assets.srcDirs = ["assets"]
+ }
+ }
+ externalNativeBuild {
+ cmake {
+ path '../../CMakeLists.txt'
+ }
+ }
+
+ task checkstyleMain(type: Checkstyle){
+ source 'src'
+ include '**/*.java'
+ configFile = rootProject.file('checkstyle.xml')
+ ignoreFailures = false
+ showViolations = true
+ // empty classpath
+ classpath = files()
+ reports {
+ include ('**/*.java')
+ exclude ('**/FileBrowserActivity.java')
+ xml.enabled = true
+ html.enabled = true
+ xml {
+ destination "checkstyle/checkstyleMain.xml"
+ }
+ html {
+ destination "checkstyle/checkstyleMain.html"
+ }
+ }
+
+ checkstyle {
+ toolVersion = '8.10'
+ }
+ }
+ applicationVariants.all { variant ->
+ // create tasks to generate Javadocs
+ task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
+ source = variant.javaCompile.source
+ classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+ destinationDir = file("build/outputs/docs/javadoc/")
+ title = rootProject.name
+ verbose = true
+ failOnError false
+ }
+ }
+
+}
+dependencies {
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
+ androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ testImplementation 'junit:junit:4.12'
+ implementation 'ch.acra:acra:4.9.2'
+// implementation 'com.android.support:support-v4:27.1.1'
+}
diff --git a/navit/android/change_xslt.sh b/navit/android/change_xslt.sh
index 5f11f0930..c186e7314 100755
--- a/navit/android/change_xslt.sh
+++ b/navit/android/change_xslt.sh
@@ -23,36 +23,31 @@ REG3='{round(@1@-number($LAYOUT_001_ORDER_DELTA_1))}-{round(@2@-number($LAYOUT_0
REG4='{round(@1@-number($LAYOUT_001_ORDER_DELTA_1))}'
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18;do
- a=`echo "$REG0"|sed -e "s#@1@#$i#"`
- cat "$temp"|sed -e "s#order=\"0-${i}\"#order=\"${a}\"#g" > "$out"
- cp -p "$out" "$temp"
+ a=$(echo "$REG0"|sed -e "s#@1@#$i#")
+ sed -e "s#order=\"0-${i}\"#order=\"${a}\"#g" -i "$temp"
done
# dont change order="0-" values !!
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18;do
- a=`echo "$REG1"|sed -e "s#@1@#$i#"`
- cat "$temp"|sed -e "s#order=\"${i}-\"#order=\"${a}\"#g" > "$out"
- cp -p "$out" "$temp"
+ a=$(echo "$REG1"|sed -e "s#@1@#$i#")
+ sed -e "s#order=\"${i}-\"#order=\"${a}\"#g" -i "$temp"
done
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18;do
- a=`echo "$REG2"|sed -e "s#@1@#$i#"`
- cat "$temp"|sed -e "s#order=\"-${i}\"#order=\"${a}\"#g" > "$out"
- cp -p "$out" "$temp"
+ a=$(echo "$REG2"|sed -e "s#@1@#$i#")
+ sed -e "s#order=\"-${i}\"#order=\"${a}\"#g" -i "$temp"
done
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18;do
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18;do
- a=`echo "$REG3"|sed -e "s#@1@#$i#"|sed -e "s#@2@#$j#"`
- cat "$temp"|sed -e "s#order=\"${i}-${j}\"#order=\"${a}\"#g" > "$out"
- cp -p "$out" "$temp"
+ a=$(echo "$REG3"|sed -e "s#@1@#$i#"|sed -e "s#@2@#$j#")
+ sed -e "s#order=\"${i}-${j}\"#order=\"${a}\"#g" -i "$temp"
done
done
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18;do
- a=`echo "$REG4"|sed -e "s#@1@#$i#"`
- cat "$temp"|sed -e "s#order=\"${i}\"#order=\"${a}\"#g" > "$out"
- cp -p "$out" "$temp"
+ a=$(echo "$REG4"|sed -e "s#@1@#$i#")
+ sed -e "s#order=\"${i}\"#order=\"${a}\"#g" -i "$temp"
done
-
+cp -p "$temp" "$out"
diff --git a/navit/android/libs/TTS_library_stub.jar b/navit/android/libs/TTS_library_stub.jar
deleted file mode 100644
index 194b82733..000000000
--- a/navit/android/libs/TTS_library_stub.jar
+++ /dev/null
Binary files differ
diff --git a/navit/android/libs/acra-4.8.5.jar b/navit/android/libs/acra-4.8.5.jar
deleted file mode 100644
index f0044ece8..000000000
--- a/navit/android/libs/acra-4.8.5.jar
+++ /dev/null
Binary files differ
diff --git a/navit/android/libs/android-support-v4.jar b/navit/android/libs/android-support-v4.jar
deleted file mode 100644
index aa0b1a5cc..000000000
--- a/navit/android/libs/android-support-v4.jar
+++ /dev/null
Binary files differ
diff --git a/navit/android/po2xml.xslt b/navit/android/po2xml.xslt
index 1a92d2db4..17ea440f9 100644
--- a/navit/android/po2xml.xslt
+++ b/navit/android/po2xml.xslt
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:po2xml="http://example.com/namespace" exclude-result-prefixes="po2xml">
-<xsl:param name="po_file"/>
+<xsl:param name="po_file"/>
<xsl:output method="xml" indent="yes" encoding="utf-8"/>
<xsl:function name="po2xml:escape">
diff --git a/navit/android/res/layout/ua_com_vassiliev_filebrowser_layout.xml b/navit/android/res/layout/ua_com_vassiliev_filebrowser_layout.xml
index 28bedf592..6495317e8 100644
--- a/navit/android/res/layout/ua_com_vassiliev_filebrowser_layout.xml
+++ b/navit/android/res/layout/ua_com_vassiliev_filebrowser_layout.xml
@@ -1,84 +1,84 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- android:padding="3dp" >
-
- <!--
- android:layout_weight="1"
- android:layout_weight="1"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:layout_width="fill_parent"
- android:layout_gravity="top"
- android:background = "#f00"
- android:background = "#0f0"
-
- -->
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="0dp"
- android:gravity="top"
- android:orientation="horizontal"
- android:padding="0dp" >
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="0dp"
- android:layout_weight="1"
- android:gravity="top"
- android:orientation="horizontal"
- android:padding="0dp" >
-
- <Button
- android:id="@+id/upDirectoryButton"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top"
- android:layout_margin="0dp"
- android:layout_weight="1"
- android:padding="0dp"
- android:drawableLeft="@drawable/dir_up"
- android:text="Up" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_margin="0dp"
- android:layout_weight="1"
- android:gravity="top"
- android:orientation="horizontal"
- android:padding="0dp" >
-
- <Button
- android:id="@+id/selectCurrentDirectoryButton"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="top"
- android:gravity = "center|center_vertical"
- android:layout_margin="0dp"
- android:layout_weight="1"
- android:padding="0dp"
- android:text="Select" />
- </LinearLayout>
- </LinearLayout>
-
- <TextView
- android:id="@+id/currentDirectoryTextView"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="Current folder: \n/THis/is/a/long/path/to/test/if/this/will/span/multiple/lines" />
-
- <ListView
- android:id="@+id/fileListView"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_marginTop="5dp"
- android:layout_weight="1" />
-
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical"
+ android:padding="3dp" >
+
+ <!--
+ android:layout_weight="1"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:layout_width="fill_parent"
+ android:layout_gravity="top"
+ android:background = "#f00"
+ android:background = "#0f0"
+
+ -->
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="0dp"
+ android:gravity="top"
+ android:orientation="horizontal"
+ android:padding="0dp" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="0dp"
+ android:layout_weight="1"
+ android:gravity="top"
+ android:orientation="horizontal"
+ android:padding="0dp" >
+
+ <Button
+ android:id="@+id/upDirectoryButton"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:layout_margin="0dp"
+ android:layout_weight="1"
+ android:padding="0dp"
+ android:drawableLeft="@drawable/dir_up"
+ android:text="Up" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="0dp"
+ android:layout_weight="1"
+ android:gravity="top"
+ android:orientation="horizontal"
+ android:padding="0dp" >
+
+ <Button
+ android:id="@+id/selectCurrentDirectoryButton"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:gravity = "center|center_vertical"
+ android:layout_margin="0dp"
+ android:layout_weight="1"
+ android:padding="0dp"
+ android:text="Select" />
+ </LinearLayout>
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/currentDirectoryTextView"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Current folder: \n/THis/is/a/long/path/to/test/if/this/will/span/multiple/lines" />
+
+ <ListView
+ android:id="@+id/fileListView"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_marginTop="5dp"
+ android:layout_weight="1" />
+
</LinearLayout> \ No newline at end of file
diff --git a/navit/android/res/values-v19/styles.xml b/navit/android/res/values-v19/styles.xml
index b3ea5c14f..69acd3a4e 100644
--- a/navit/android/res/values-v19/styles.xml
+++ b/navit/android/res/values-v19/styles.xml
@@ -5,16 +5,7 @@
NavitBaseTheme from BOTH res/values/styles.xml and
res/values-v19/styles.xml on API 19+ devices.
-->
- <style name="NavitBaseTheme" parent="android:Theme.Holo">
-
- <!-- Main theme colors -->
- <!-- your app branding color for the app bar -->
- <item name="android:colorPrimary">@color/navitYellow500</item>
- <!-- darker variant for the status bar and contextual app bars -->
- <item name="android:colorPrimaryDark">@color/navitYellow700</item>
- <!-- theme UI controls like checkboxes and text fields -->
- <item name="android:colorAccent">@color/navitBlue500</item>
- </style>
+ <style name="NavitBaseTheme" parent="android:Theme.Holo"/>
<!--
Main Activity theme for API 19+. This theme completely replaces
diff --git a/navit/android/res/values-v21/styles.xml b/navit/android/res/values-v21/styles.xml
index a1d66bb3d..3edbb901a 100644
--- a/navit/android/res/values-v21/styles.xml
+++ b/navit/android/res/values-v21/styles.xml
@@ -24,22 +24,22 @@
<style name="NavitTheme" parent="NavitBaseTheme">
<!-- API 21 theme customizations can go here. -->
-
+
<!--
Don't use translucent system bars on API 21 as they are drawn with a semitransparent
black background which can't be changed.
-->
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowTranslucentStatus">false</item>
-
- <!--
+
+ <!--
We could set any semi-transparent color here (or change it in code), but this would not
be available on API 19/20. Simply specifying full transparency allows us to implement a
- separate mechanism that will work on all versions.
+ separate mechanism that will work on all versions.
-->
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
-
+
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
diff --git a/navit/android/res/values/strings-dont-translate.xml b/navit/android/res/values/strings-dont-translate.xml
index db794184f..f3892ef33 100644
--- a/navit/android/res/values/strings-dont-translate.xml
+++ b/navit/android/res/values/strings-dont-translate.xml
@@ -6,13 +6,14 @@
<string name="map_data_copyright">© OpenStreetMap contributors</string>
<string name="url_wiki_android">http://wiki.navit-project.org/index.php/Navit_on_Android</string>
<string name="url_wiki_main">http://wiki.navit-project.org</string>
+ <string name="osm_copyright">Map data © OpenStreetMap contributors, ODBL</string>
<!-- NOTIFICATION -->
<string name="notification_name">@string/app_name</string>
<!-- OPTIONS MENU -->
<string name="optionsmenu_address_search">@string/address_search_title</string>
-
+
<!-- Backup Restore -->
<string-array name="dialog_backup_restore_items">
<item >@string/backup</item>
diff --git a/navit/android/res/values/strings.xml b/navit/android/res/values/strings.xml
index 3a730e807..f321991e7 100644
--- a/navit/android/res/values/strings.xml
+++ b/navit/android/res/values/strings.xml
@@ -4,8 +4,10 @@
<!-- GENERIC -->
<string name="yes">Yes</string>
<string name="no">No</string>
+ <string name="cancel">Cancel</string>
<!-- NOTIFICATION -->
+ <string name="channel_name">Navit</string>
<string name="notification_ticker">Navit started</string>
<string name="notification_event_default">Navit running</string>
@@ -24,7 +26,7 @@
<string name="optionsmenu_exit_navit">Exit Navit</string>
<string name="optionsmenu_backup_restore">Backup / Restore</string>
<string name="optionsmenu_set_map_location">Set map location</string>
-
+
<!-- POSITION POP-UP -->
<string name="position_popup_title">Position</string>
<string name="position_popup_drive_here">Route to here</string>
@@ -38,8 +40,17 @@
<string name="map_download_download_error">Error downloading map.</string>
<string name="map_download_download_aborted">Map download aborted</string>
<string name="map_download_not_enough_free_space">Not enough free space</string>
+ <string name="map_download_oversize">Sorry, we currently do not support maps above 3.8G on Android, please select a smaller one.</string>
<string name="map_no_fix">No location. Reopen after location fix.</string>
<string name="maps_for_current_location">Maps containing current location</string>
+ <string name="maps_installed">Installed maps</string>
+ <string name="map_downloading">downloading</string>
+ <string name="map_download_medium_unavailable">Media selected for map storage is not available</string>
+ <string name="map_download_error_writing_map">Error writing map!</string>
+
+ <!-- STORAGE -->
+ <string name="map_location_changed">New location set to %s Restart Navit to apply the changes.</string>
+ <string name="map_location_unavailable">Current map location %s is not available Please restart Navit after you attach an SD card or select a different map location.</string>
<!-- ADDRESS SEARCH -->
<string name="address_search_title">Address search</string>
@@ -55,7 +66,7 @@
<string name="address_search_set_destination">Setting destination to:</string>
<string name="address_search_towns">Towns</string>
<string name="address_search_streets">Streets</string>
-
+
<!-- Backup Restore -->
<string name="choose_an_action">Choose an action</string>
<string name="please_insert_an_sd_card">Please insert an SD Card</string>
@@ -72,13 +83,229 @@
<string name="select_backup">Select backup</string>
<string name="backup">Backup</string>
<string name="restore">Restore</string>
-
+
<!-- TTS -->
<string name="TTS_title_data_missing">System text to speech engine data is missing</string>
<string name="TTS_qery_install_data">Navit can use any text to speech engine installed on your device. The currently selected engine reports it is unable to speak in your language. Should we ask the system to show voice download dialog?</string>
-
+
<!-- Permissions dialog-->
<string name="permissions_not_granted">Navit needs permission to access GPS and read the map.\nIf you change your mind please restart Navit and grant the permissions</string>
<string name="permissions_info_box_title">One or more ungranted permissions</string>
+
+
+ <!-- countries, continents, regions -->
+ <string name="whole_planet">Whole Planet</string>
+ <string name="africa">Africa</string>
+ <string name="angola">Angola</string>
+ <string name="burundi">Burundi</string>
+ <string name="canary_islands">Canary Islands</string>
+ <string name="congo">Congo, Democratic Republic of the</string>
+ <string name="ethiopia">Ethiopia</string>
+ <string name="guinea">Guinea</string>
+ <string name="cotedivoire">Cote d\'Ivoire</string>
+ <string name="kenya">Kenya</string>
+ <string name="lesotho">Lesotho</string>
+ <string name="liberia">Liberia</string>
+ <string name="libya">Libya</string>
+ <string name="madagascar">Madagascar</string>
+ <string name="namibia">Namibia</string>
+ <string name="botswana">Botswana</string>
+ <string name="reunion">Reunion</string>
+ <string name="rwanda">Rwanda</string>
+ <string name="south_africa">South Africa</string>
+ <string name="tanzania">Tanzania, United Republic of</string>
+ <string name="uganda">Uganda</string>
+ <string name="asia">Asia</string>
+ <string name="azerbaijan">Azerbaijan</string>
+ <string name="china">China</string>
+ <string name="cyprus">Cyprus</string>
+ <string name="india">India</string>
+ <string name="nepal">Nepal</string>
+ <string name="indonesia">Indonesia</string>
+ <string name="iran">Iran, Islamic Republic of</string>
+ <string name="iraq">Iraq</string>
+ <string name="israel">Israel</string>
+ <string name="japan">Japan</string>
+ <string name="kazakhstan">Kazakhstan</string>
+ <string name="kyrgyzsyan">Kyrgyzstan</string>
+ <string name="malaysia">Malaysia</string>
+ <string name="mongolia">Mongolia</string>
+ <string name="pakistan">Pakistan</string>
+ <string name="philippines">Philippines</string>
+ <string name="saudi_arabia">Saudi Arabia</string>
+ <string name="taiwan">Taiwan</string>
+ <string name="korea">Korea</string>
+ <string name="singapore">Singapore</string>
+ <string name="thailand">Thailand</string>
+ <string name="turkey">Turkey</string>
+ <string name="turkmenistan">Turkmenistan</string>
+ <string name="uae_other">UAE+Other</string>
+ <string name="australia">Australia</string>
+ <string name="oceania">Oceania</string>
+ <string name="tasmania">Tasmania</string>
+ <string name="victoria">Victoria</string>
+ <string name="new_south_wales">New South Wales</string>
+ <string name="new_caledonia">New Caledonia</string>
+ <string name="newzealand">New Zealand</string>
+ <string name="europe">Europe</string>
+ <string name="western_europe">Western Europe</string>
+ <string name="austria">Austria</string>
+ <string name="azores">Azores</string>
+ <string name="belgium">Belgium</string>
+ <string name="benelux">BeNeLux</string>
+ <string name="netherlands">Netherlands</string>
+ <string name="denmark">Denmark</string>
+ <string name="faroe_islands">Faroe Islands</string>
+ <string name="france">France</string>
+ <string name="alsace">Alsace</string>
+ <string name="aquitaine">Aquitaine</string>
+ <string name="auvergne">Auvergne</string>
+ <string name="centre">Centre</string>
+ <string name="bretagne">Bretagne</string>
+ <string name="bourgogne">Bourgogne</string>
+ <string name="basse_normandie">Basse-Normandie</string>
+ <string name="champagne_ardenne">Champagne-Ardenne</string>
+ <string name="corse">Corse</string>
+ <string name="franche_comte">Franche-Comte</string>
+ <string name="haute_normandie">Haute-Normandie</string>
+ <string name="ile_de_france">Ile-de-France</string>
+ <string name="languedoc_roussillon">Languedoc-Roussillon</string>
+ <string name="limousin">Limousin</string>
+ <string name="lorraine">Lorraine</string>
+ <string name="midi_pyrenees">Midi-Pyrenees</string>
+ <string name="nord_pas_de_calais">Nord-pas-de-Calais</string>
+ <string name="pays_de_la_loire">Pays-de-la-Loire</string>
+ <string name="picardie">Picardie</string>
+ <string name="poitou_charentes">Poitou-Charentes</string>
+ <string name="provence_alpes_cote_d_azur">Provence-Alpes-Cote-d-Azur</string>
+ <string name="rhone_alpes">Rhone-Alpes</string>
+ <string name="luxembourg">Luxembourg</string>
+ <string name="germany">Germany</string>
+ <string name="baden_wuerttemberg">Baden-Wuerttemberg</string>
+ <string name="bayern">Bayern</string>
+ <string name="mittelfranken">Mittelfranken</string>
+ <string name="niederbayern">Niederbayern</string>
+ <string name="oberbayern">Oberbayern</string>
+ <string name="oberfranken">Oberfranken</string>
+ <string name="oberpfalz">Oberpfalz</string>
+ <string name="schwaben">Schwaben</string>
+ <string name="unterfranken">Unterfranken</string>
+ <string name="berlin">Berlin</string>
+ <string name="brandenburg">Brandenburg</string>
+ <string name="bremen">Bremen</string>
+ <string name="hamburg">Hamburg</string>
+ <string name="hessen">Hessen</string>
+ <string name="mecklenburg_vorpommern">Mecklenburg-Vorpommern</string>
+ <string name="niedersachsen">Niedersachsen</string>
+ <string name="nordrhein_westfalen">Nordrhein-westfalen</string>
+ <string name="rheinland_pfalz">Rheinland-Pfalz</string>
+ <string name="saarland">Saarland</string>
+ <string name="sachsen_anhalt">Sachsen-Anhalt</string>
+ <string name="sachsen">Sachsen</string>
+ <string name="schleswig_holstein">Schleswig-Holstein</string>
+ <string name="thueringen">Thueringen</string>
+ <string name="iceland">Iceland</string>
+ <string name="ireland">Ireland</string>
+ <string name="italy">Italy</string>
+ <string name="portugal">Portugal</string>
+ <string name="spain">Spain</string>
+ <string name="mallorca">Mallorca</string>
+ <string name="galicia">Galicia</string>
+ <string name="scandinavia">Scandinavia</string>
+ <string name="finland">Finland</string>
+ <string name="switzerland">Switzerland</string>
+ <string name="united_kingdom">United Kingdom</string>
+ <string name="england">England</string>
+ <string name="buckinghamshire">Buckinghamshire</string>
+ <string name="cambridgeshire">Cambridgeshire</string>
+ <string name="cumbria">Cumbria</string>
+ <string name="east_yorkshire_with_hull">East yorkshire with hull</string>
+ <string name="essex">Essex</string>
+ <string name="herefordshire">Herefordshire</string>
+ <string name="kent">Kent</string>
+ <string name="lancashire">Lancashire</string>
+ <string name="leicestershire">Leicestershire</string>
+ <string name="norfolk">Norfolk</string>
+ <string name="nottinghamshire">Nottinghamshire</string>
+ <string name="oxfordshire">Oxfordshire</string>
+ <string name="shropshire">Shropshire</string>
+ <string name="somerset">Somerset</string>
+ <string name="south_yorkshire">South yorkshire</string>
+ <string name="suffolk">Suffolk</string>
+ <string name="surrey">Surrey</string>
+ <string name="wiltshire">Wiltshire</string>
+ <string name="scotland">Scotland</string>
+ <string name="wales">Wales</string>
+ <string name="albania">Albania</string>
+ <string name="belarus">Belarus</string>
+ <string name="russian_federation">Russian Federation</string>
+ <string name="bulgaria">Bulgaria</string>
+ <string name="bosnia_and_herzegovina">Bosnia and Herzegovina</string>
+ <string name="czech_republic">Czech Republic</string>
+ <string name="croatia">Croatia</string>
+ <string name="estonia">Estonia</string>
+ <string name="greece">Greece</string>
+ <string name="crete">Crete</string>
+ <string name="hungary">Hungary</string>
+ <string name="latvia">Latvia</string>
+ <string name="lithuania">Lithuania</string>
+ <string name="poland">Poland</string>
+ <string name="romania">Romania</string>
+ <string name="slovakia">Slovakia</string>
+ <string name="ukraine">Ukraine</string>
+ <string name="north_america">North America</string>
+ <string name="alaska">Alaska</string>
+ <string name="canada">Canada</string>
+ <string name="hawaii">Hawaii</string>
+ <string name="usa">USA</string>
+ <string name="except_alaska_and_hawaii">(except Alaska and Hawaii)</string>
+ <string name="midwest">Midwest</string>
+ <string name="michigan">Michigan</string>
+ <string name="ohio">Ohio</string>
+ <string name="northeast">Northeast</string>
+ <string name="massachusetts">Massachusetts</string>
+ <string name="vermont">Vermont</string>
+ <string name="pacific">Pacific</string>
+ <string name="south">South</string>
+ <string name="arkansas">Arkansas</string>
+ <string name="district_of_columbia">District of Columbia</string>
+ <string name="florida">Florida</string>
+ <string name="louisiana">Louisiana</string>
+ <string name="maryland">Maryland</string>
+ <string name="mississippi">Mississippi</string>
+ <string name="oklahoma">Oklahoma</string>
+ <string name="texas">Texas</string>
+ <string name="virginia">Virginia</string>
+ <string name="west_virginia">West Virginia</string>
+ <string name="west">West</string>
+ <string name="arizona">Arizona</string>
+ <string name="california">California</string>
+ <string name="colorado">Colorado</string>
+ <string name="idaho">Idaho</string>
+ <string name="montana">Montana</string>
+ <string name="new_mexico">New Mexico</string>
+ <string name="nevada">Nevada</string>
+ <string name="oregon">Oregon</string>
+ <string name="utah">Utah</string>
+ <string name="washington_state">Washington State</string>
+ <string name="south_middle_america">South+Middle America</string>
+ <string name="argentina">Argentina</string>
+ <string name="chile">Chile</string>
+ <string name="bolivia">Bolivia</string>
+ <string name="brazil">Brazil</string>
+ <string name="cuba">Cuba</string>
+ <string name="colombia">Colombia</string>
+ <string name="ecuador">Ecuador</string>
+ <string name="guyana">Guyana</string>
+ <string name="suriname">Suriname</string>
+ <string name="guyane_francaise">Guyane Francaise</string>
+ <string name="haiti">Haiti</string>
+ <string name="dominican_republic">Dominican Republic</string>
+ <string name="jamaica">Jamaica</string>
+ <string name="mexico">Mexico</string>
+ <string name="paraguay">Paraguay</string>
+ <string name="peru">Peru</string>
+ <string name="uruguay">Uruguay</string>
+ <string name="venezuela">Venezuela</string>
</resources>
diff --git a/navit/android/res/values/styles.xml b/navit/android/res/values/styles.xml
index 91094e222..78dadf1ce 100644
--- a/navit/android/res/values/styles.xml
+++ b/navit/android/res/values/styles.xml
@@ -1,32 +1,4 @@
<resources>
-
- <!--
- Base application theme, dependent on API level. This theme is replaced
- by NavitBaseTheme from res/values-vXX/styles.xml on newer devices.
- -->
- <style name="NavitBaseTheme" parent="android:Theme.Holo">
- <!--
- Theme customizations available in newer API levels can go in
- res/values-vXX/styles.xml, while customizations related to
- backward-compatibility can go here.
- -->
- </style>
-
- <!-- Theme for Navit's main Activity. -->
- <style name="NavitTheme" parent="NavitBaseTheme">
- <!-- All customizations that are NOT specific to a particular API-level can go here. -->
- </style>
-
- <!-- TODO complete list of shades for both colors -->
- <!--
- Primary color is derived average of icon colors (500 in Android parlance):
- 213 164 19 #d5a411 hsl 45 92 84
-
- Dark color is normally the 600 color (i.e. slightly darker than 500)
- 209 155 19 #d19b13 hsl 43 91 82
- -->
-
-
<!-- Yellow from Navit icon background (300 and 700 are the extremes of the gradient, 500 is the average, 900 is the line color) -->
<color name="navitYellow300">#e9cb14</color>
<color name="navitYellow500">#d5a411</color>
@@ -38,5 +10,4 @@
<color name="navitBlue300">#329eff</color>
<color name="navitBlue500">#1a6cb6</color>
<color name="navitBlue900">#1f3157</color>
-
</resources> \ No newline at end of file
diff --git a/navit/android/src/org/navitproject/navit/FileBrowserActivity.java b/navit/android/src/org/navitproject/navit/FileBrowserActivity.java
index f3dac4894..dc7462b76 100644
--- a/navit/android/src/org/navitproject/navit/FileBrowserActivity.java
+++ b/navit/android/src/org/navitproject/navit/FileBrowserActivity.java
@@ -1,430 +1,429 @@
-package org.navitproject.navit;
-
-//Heavily based on code from
-//https://github.com/mburman/Android-File-Explore
-// Version of Aug 13, 2011
-//Also contributed:
-// Sugan Krishnan (https://github.com/rgksugan) - Jan 2013.
-//
-
-//Project type now is Android library:
-// http://developer.android.com/guide/developing/projects/projects-eclipse.html#ReferencingLibraryProject
-
-//General Java imports
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Collections;
-
-//Android imports
-import android.app.Activity;
-import android.content.Intent;
-import android.content.res.Configuration;
-import android.graphics.Color;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.StatFs;
-import android.util.Log;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup.LayoutParams;
-import android.view.*;
-import android.widget.*;
-
-//Import of resources file for file browser
-import org.navitproject.navit.R;
-
-public class FileBrowserActivity extends Activity {
- // Intent Action Constants
- public static final String INTENT_ACTION_SELECT_DIR = "ua.com.vassiliev.androidfilebrowser.SELECT_DIRECTORY_ACTION";
- public static final String INTENT_ACTION_SELECT_FILE = "ua.com.vassiliev.androidfilebrowser.SELECT_FILE_ACTION";
-
- // Intent parameters names constants
- public static final String startDirectoryParameter = "ua.com.vassiliev.androidfilebrowser.directoryPath";
- public static final String returnDirectoryParameter = "ua.com.vassiliev.androidfilebrowser.directoryPathRet";
- public static final String returnFileParameter = "ua.com.vassiliev.androidfilebrowser.filePathRet";
- public static final String showCannotReadParameter = "ua.com.vassiliev.androidfilebrowser.showCannotRead";
- public static final String filterExtension = "ua.com.vassiliev.androidfilebrowser.filterExtension";
-
- // Stores names of traversed directories
- ArrayList<String> pathDirsList = new ArrayList<String>();
-
- // Check if the first level of the directory structure is the one showing
- // private Boolean firstLvl = true;
-
- private static final String LOGTAG = "F_PATH";
-
- private List<Item> fileList = new ArrayList<Item>();
- private File path = null;
- private String chosenFile;
- // private static final int DIALOG_LOAD_FILE = 1000;
-
- ArrayAdapter<Item> adapter;
-
- private boolean showHiddenFilesAndDirs = true;
-
- private boolean directoryShownIsEmpty = false;
-
- private String filterFileExtension = null;
-
- // Action constants
- private static int currentAction = -1;
- private static final int SELECT_DIRECTORY = 1;
- private static final int SELECT_FILE = 2;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // In case of
- // ua.com.vassiliev.androidfilebrowser.SELECT_DIRECTORY_ACTION
- // Expects com.mburman.fileexplore.directoryPath parameter to
- // point to the start folder.
- // If empty or null, will start from SDcard root.
- setContentView(R.layout.ua_com_vassiliev_filebrowser_layout);
-
- // Set action for this activity
- Intent thisInt = this.getIntent();
- currentAction = SELECT_DIRECTORY;// This would be a default action in
- // case not set by intent
- if (thisInt.getAction().equalsIgnoreCase(INTENT_ACTION_SELECT_FILE)) {
- Log.d(LOGTAG, "SELECT ACTION - SELECT FILE");
- currentAction = SELECT_FILE;
- }
-
- showHiddenFilesAndDirs = thisInt.getBooleanExtra(
- showCannotReadParameter, true);
-
- filterFileExtension = thisInt.getStringExtra(filterExtension);
-
- setInitialDirectory();
-
- parseDirectoryPath();
- loadFileList();
- this.createFileListAdapter();
- this.initializeButtons();
- this.initializeFileListView();
- updateCurrentDirectoryTextView();
- Log.d(LOGTAG, path.getAbsolutePath());
- }
-
- private void setInitialDirectory() {
- Intent thisInt = this.getIntent();
- String requestedStartDir = thisInt
- .getStringExtra(startDirectoryParameter);
-
- if (requestedStartDir != null && requestedStartDir.length() > 0) {// if(requestedStartDir!=null
- File tempFile = new File(requestedStartDir);
- if (tempFile.isDirectory())
- this.path = tempFile;
- }// if(requestedStartDir!=null
-
- if (this.path == null) {// No or invalid directory supplied in intent
- // parameter
- if (Environment.getExternalStorageDirectory().isDirectory()
- && Environment.getExternalStorageDirectory().canRead())
- path = Environment.getExternalStorageDirectory();
- else
- path = new File("/");
- }// if(this.path==null) {//No or invalid directory supplied in intent
- // parameter
- }// private void setInitialDirectory() {
-
- private void parseDirectoryPath() {
- pathDirsList.clear();
- String pathString = path.getAbsolutePath();
- String[] parts = pathString.split("/");
- int i = 0;
- while (i < parts.length) {
- pathDirsList.add(parts[i]);
- i++;
- }
- }
-
- private void initializeButtons() {
- Button upDirButton = (Button) this.findViewById(R.id.upDirectoryButton);
- upDirButton.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- Log.d(LOGTAG, "onclick for upDirButton");
- loadDirectoryUp();
- loadFileList();
- adapter.notifyDataSetChanged();
- updateCurrentDirectoryTextView();
- }
- });// upDirButton.setOnClickListener(
-
- Button selectFolderButton = (Button) this
- .findViewById(R.id.selectCurrentDirectoryButton);
- if (currentAction == SELECT_DIRECTORY) {
- selectFolderButton.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- Log.d(LOGTAG, "onclick for selectFolderButton");
- returnDirectoryFinishActivity();
- }
- });
- } else {// if(currentAction == this.SELECT_DIRECTORY) {
- selectFolderButton.setVisibility(View.GONE);
- }// } else {//if(currentAction == this.SELECT_DIRECTORY) {
- }// private void initializeButtons() {
-
- private void loadDirectoryUp() {
- // present directory removed from list
- String s = pathDirsList.remove(pathDirsList.size() - 1);
- // path modified to exclude present directory
- path = new File(path.toString().substring(0,
- path.toString().lastIndexOf(s)));
- fileList.clear();
- }
-
- private void updateCurrentDirectoryTextView() {
- int i = 0;
- String curDirString = "";
- while (i < pathDirsList.size()) {
- curDirString += pathDirsList.get(i) + "/";
- i++;
- }
- if (pathDirsList.size() == 0) {
- ((Button) this.findViewById(R.id.upDirectoryButton))
- .setEnabled(false);
- curDirString = "/";
- } else
- ((Button) this.findViewById(R.id.upDirectoryButton))
- .setEnabled(true);
- long freeSpace = getFreeSpace(curDirString);
- String formattedSpaceString = formatBytes(freeSpace);
- if (freeSpace == 0) {
- Log.d(LOGTAG, "NO FREE SPACE");
- File currentDir = new File(curDirString);
- if(!currentDir.canWrite())
- formattedSpaceString = "NON Writable";
- }
-
- ((Button) this.findViewById(R.id.selectCurrentDirectoryButton))
- .setText("Select\n[" + formattedSpaceString
- + "]");
-
- ((TextView) this.findViewById(R.id.currentDirectoryTextView))
- .setText("Current directory: " + curDirString);
- }// END private void updateCurrentDirectoryTextView() {
-
- private void showToast(String message) {
- Toast.makeText(this, message, Toast.LENGTH_LONG).show();
- }
-
- private void initializeFileListView() {
- ListView lView = (ListView) this.findViewById(R.id.fileListView);
- LinearLayout.LayoutParams lParam = new LinearLayout.LayoutParams(
- LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
- lParam.setMargins(15, 5, 15, 5);
- lView.setAdapter(this.adapter);
- lView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View view,
- int position, long id) {
- chosenFile = fileList.get(position).file;
- File sel = new File(path + "/" + chosenFile);
- Log.d(LOGTAG, "Clicked:" + chosenFile);
- if (sel.isDirectory()) {
- if (sel.canRead()) {
- // Adds chosen directory to list
- pathDirsList.add(chosenFile);
- path = new File(sel + "");
- Log.d(LOGTAG, "Just reloading the list");
- loadFileList();
- adapter.notifyDataSetChanged();
- updateCurrentDirectoryTextView();
- Log.d(LOGTAG, path.getAbsolutePath());
- } else {// if(sel.canRead()) {
- showToast("Path does not exist or cannot be read");
- }// } else {//if(sel.canRead()) {
- }// if (sel.isDirectory()) {
- // File picked or an empty directory message clicked
- else {// if (sel.isDirectory()) {
- Log.d(LOGTAG, "item clicked");
- if (!directoryShownIsEmpty) {
- Log.d(LOGTAG, "File selected:" + chosenFile);
- returnFileFinishActivity(sel.getAbsolutePath());
- }
- }// else {//if (sel.isDirectory()) {
- }// public void onClick(DialogInterface dialog, int which) {
- });// lView.setOnClickListener(
- }// private void initializeFileListView() {
-
- private void returnDirectoryFinishActivity() {
- Intent retIntent = new Intent();
- retIntent.putExtra(returnDirectoryParameter, path.getAbsolutePath());
- this.setResult(RESULT_OK, retIntent);
- this.finish();
- }// END private void returnDirectoryFinishActivity() {
-
- private void returnFileFinishActivity(String filePath) {
- Intent retIntent = new Intent();
- retIntent.putExtra(returnFileParameter, filePath);
- this.setResult(RESULT_OK, retIntent);
- this.finish();
- }// END private void returnDirectoryFinishActivity() {
-
- private void loadFileList() {
- try {
- path.mkdirs();
- } catch (SecurityException e) {
- Log.e(LOGTAG, "unable to write on the sd card ");
- }
- fileList.clear();
-
- if (path.exists() && path.canRead()) {
- FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String filename) {
- File sel = new File(dir, filename);
- boolean showReadableFile = showHiddenFilesAndDirs
- || sel.canRead();
- // Filters based on whether the file is hidden or not
- if (currentAction == SELECT_DIRECTORY) {
- return (sel.isDirectory() && showReadableFile);
- }
- if (currentAction == SELECT_FILE) {
-
- // If it is a file check the extension if provided
- if (sel.isFile() && filterFileExtension != null) {
- return (showReadableFile && sel.getName().endsWith(
- filterFileExtension));
- }
- return (showReadableFile);
- }
- return true;
- }// public boolean accept(File dir, String filename) {
- };// FilenameFilter filter = new FilenameFilter() {
-
- String[] fList = path.list(filter);
- this.directoryShownIsEmpty = false;
- for (int i = 0; i < fList.length; i++) {
- // Convert into file path
- File sel = new File(path, fList[i]);
- Log.d(LOGTAG,
- "File:" + fList[i] + " readable:"
- + (Boolean.valueOf(sel.canRead())).toString());
- int drawableID = R.drawable.file_icon;
- boolean canRead = sel.canRead();
- // Set drawables
- if (sel.isDirectory()) {
- if (canRead) {
- drawableID = R.drawable.folder_icon;
- } else {
- drawableID = R.drawable.folder_icon_light;
- }
- }
- fileList.add(i, new Item(fList[i], drawableID, canRead));
- }// for (int i = 0; i < fList.length; i++) {
- if (fileList.size() == 0) {
- // Log.d(LOGTAG, "This directory is empty");
- this.directoryShownIsEmpty = true;
- fileList.add(0, new Item("Directory is empty", -1, true));
- } else {// sort non empty list
- Collections.sort(fileList, new ItemFileNameComparator());
- }
- } else {
- Log.e(LOGTAG, "path does not exist or cannot be read");
- }
- // Log.d(TAG, "loadFileList finished");
- }// private void loadFileList() {
-
- private void createFileListAdapter() {
- adapter = new ArrayAdapter<Item>(this,
- android.R.layout.select_dialog_item, android.R.id.text1,
- fileList) {
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- // creates view
- View view = super.getView(position, convertView, parent);
- TextView textView = (TextView) view
- .findViewById(android.R.id.text1);
- // put the image on the text view
- int drawableID = 0;
- if (fileList.get(position).icon != -1) {
- // If icon == -1, then directory is empty
- drawableID = fileList.get(position).icon;
- }
- textView.setCompoundDrawablesWithIntrinsicBounds(drawableID, 0,
- 0, 0);
-
- textView.setEllipsize(null);
-
- // add margin between image and text (support various screen
- // densities)
- // int dp5 = (int) (5 *
- // getResources().getDisplayMetrics().density + 0.5f);
- int dp3 = (int) (3 * getResources().getDisplayMetrics().density + 0.5f);
- // TODO: change next line for empty directory, so text will be
- // centered
- textView.setCompoundDrawablePadding(dp3);
- return view;
- }// public View getView(int position, View convertView, ViewGroup
- };// adapter = new ArrayAdapter<Item>(this,
- }// private createFileListAdapter(){
-
- private class Item {
- public String file;
- public int icon;
- public boolean canRead;
-
- public Item(String file, Integer icon, boolean canRead) {
- this.file = file;
- this.icon = icon;
- }
-
- @Override
- public String toString() {
- return file;
- }
- }// END private class Item {
-
- private class ItemFileNameComparator implements Comparator<Item> {
- public int compare(Item lhs, Item rhs) {
- return lhs.file.toLowerCase().compareTo(rhs.file.toLowerCase());
- }
- }
-
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
- Log.d(LOGTAG, "ORIENTATION_LANDSCAPE");
- } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
- Log.d(LOGTAG, "ORIENTATION_PORTRAIT");
- }
- // Layout apparently changes itself, only have to provide good onMeasure
- // in custom components
- // TODO: check with keyboard
- // if(newConfig.keyboard == Configuration.KEYBOARDHIDDEN_YES)
- }// END public void onConfigurationChanged(Configuration newConfig) {
-
- public static long getFreeSpace(String path) {
- StatFs stat = new StatFs(path);
- long availSize = (long) stat.getAvailableBlocks()
- * (long) stat.getBlockSize();
- return availSize;
- }// END public static long getFreeSpace(String path) {
-
- public static String formatBytes(long bytes) {
- // TODO: add flag to which part is needed (e.g. GB, MB, KB or bytes)
- String retStr = "";
- // One binary gigabyte equals 1,073,741,824 bytes.
- if (bytes > 1073741824) {// Add GB
- long gbs = bytes / 1073741824;
- retStr += (new Long(gbs)).toString() + "GB ";
- bytes = bytes - (gbs * 1073741824);
- }
- // One MB - 1048576 bytes
- if (bytes > 1048576) {// Add GB
- long mbs = bytes / 1048576;
- retStr += (new Long(mbs)).toString() + "MB ";
- bytes = bytes - (mbs * 1048576);
- }
- if (bytes > 1024) {
- long kbs = bytes / 1024;
- retStr += (new Long(kbs)).toString() + "KB";
- bytes = bytes - (kbs * 1024);
- } else
- retStr += (new Long(bytes)).toString() + " bytes";
- return retStr;
- }// public static String formatBytes(long bytes){
-
-}// END public class FileBrowserActivity extends Activity {
+package org.navitproject.navit;
+
+//Heavily based on code from
+//https://github.com/mburman/Android-File-Explore
+// Version of Aug 13, 2011
+//Also contributed:
+// Sugan Krishnan (https://github.com/rgksugan) - Jan 2013.
+//
+
+//Project type now is Android library:
+// http://developer.android.com/guide/developing/projects/projects-eclipse.html#ReferencingLibraryProject
+
+//Android imports
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.StatFs;
+import android.util.Log;
+import android.view.*;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.*;
+
+//General Java imports
+import java.io.File;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+//Import of resources file for file browser
+import org.navitproject.navit.R;
+
+public class FileBrowserActivity extends Activity {
+ // Intent Action Constants
+ public static final String INTENT_ACTION_SELECT_DIR = "ua.com.vassiliev.androidfilebrowser.SELECT_DIRECTORY_ACTION";
+ public static final String INTENT_ACTION_SELECT_FILE = "ua.com.vassiliev.androidfilebrowser.SELECT_FILE_ACTION";
+
+ // Intent parameters names constants
+ public static final String startDirectoryParameter = "ua.com.vassiliev.androidfilebrowser.directoryPath";
+ public static final String returnDirectoryParameter = "ua.com.vassiliev.androidfilebrowser.directoryPathRet";
+ public static final String returnFileParameter = "ua.com.vassiliev.androidfilebrowser.filePathRet";
+ public static final String showCannotReadParameter = "ua.com.vassiliev.androidfilebrowser.showCannotRead";
+ public static final String filterExtension = "ua.com.vassiliev.androidfilebrowser.filterExtension";
+
+ // Stores names of traversed directories
+ ArrayList<String> pathDirsList = new ArrayList<String>();
+
+ // Check if the first level of the directory structure is the one showing
+ // private Boolean firstLvl = true;
+
+ private static final String LOGTAG = "F_PATH";
+
+ private List<Item> fileList = new ArrayList<Item>();
+ private File path = null;
+ private String chosenFile;
+ // private static final int DIALOG_LOAD_FILE = 1000;
+
+ ArrayAdapter<Item> adapter;
+
+ private boolean showHiddenFilesAndDirs = true;
+
+ private boolean directoryShownIsEmpty = false;
+
+ private String filterFileExtension = null;
+
+ // Action constants
+ private static int currentAction = -1;
+ private static final int SELECT_DIRECTORY = 1;
+ private static final int SELECT_FILE = 2;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // In case of
+ // ua.com.vassiliev.androidfilebrowser.SELECT_DIRECTORY_ACTION
+ // Expects com.mburman.fileexplore.directoryPath parameter to
+ // point to the start folder.
+ // If empty or null, will start from SDcard root.
+ setContentView(R.layout.ua_com_vassiliev_filebrowser_layout);
+
+ // Set action for this activity
+ Intent thisInt = this.getIntent();
+ currentAction = SELECT_DIRECTORY;// This would be a default action in
+ // case not set by intent
+ if (thisInt.getAction().equalsIgnoreCase(INTENT_ACTION_SELECT_FILE)) {
+ Log.d(LOGTAG, "SELECT ACTION - SELECT FILE");
+ currentAction = SELECT_FILE;
+ }
+
+ showHiddenFilesAndDirs = thisInt.getBooleanExtra(
+ showCannotReadParameter, true);
+
+ filterFileExtension = thisInt.getStringExtra(filterExtension);
+
+ setInitialDirectory();
+
+ parseDirectoryPath();
+ loadFileList();
+ this.createFileListAdapter();
+ this.initializeButtons();
+ this.initializeFileListView();
+ updateCurrentDirectoryTextView();
+ Log.d(LOGTAG, path.getAbsolutePath());
+ }
+
+ private void setInitialDirectory() {
+ Intent thisInt = this.getIntent();
+ String requestedStartDir = thisInt
+ .getStringExtra(startDirectoryParameter);
+
+ if (requestedStartDir != null && requestedStartDir.length() > 0) { // if(requestedStartDir!=null
+ File tempFile = new File(requestedStartDir);
+ if (tempFile.isDirectory()) {
+ this.path = tempFile;
+ }
+ } // if(requestedStartDir!=null
+
+ if (this.path == null) { // No or invalid directory supplied in intent parameter
+ if (Environment.getExternalStorageDirectory().isDirectory()
+ && Environment.getExternalStorageDirectory().canRead()) {
+ path = Environment.getExternalStorageDirectory();
+ } else {
+ path = new File("/");
+ }
+ } // if(this.path==null) {//No or invalid directory supplied in intent parameter
+ } // private void setInitialDirectory() {
+
+ private void parseDirectoryPath() {
+ pathDirsList.clear();
+ String pathString = path.getAbsolutePath();
+ String[] parts = pathString.split("/");
+ int i = 0;
+ while (i < parts.length) {
+ pathDirsList.add(parts[i]);
+ i++;
+ }
+ }
+
+ private void initializeButtons() {
+ Button upDirButton = (Button) this.findViewById(R.id.upDirectoryButton);
+ upDirButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ Log.d(LOGTAG, "onclick for upDirButton");
+ loadDirectoryUp();
+ loadFileList();
+ adapter.notifyDataSetChanged();
+ updateCurrentDirectoryTextView();
+ }
+ });// upDirButton.setOnClickListener(
+
+ Button selectFolderButton = (Button) this
+ .findViewById(R.id.selectCurrentDirectoryButton);
+ if (currentAction == SELECT_DIRECTORY) {
+ selectFolderButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ Log.d(LOGTAG, "onclick for selectFolderButton");
+ returnDirectoryFinishActivity();
+ }
+ });
+ } else { // if(currentAction == this.SELECT_DIRECTORY) {
+ selectFolderButton.setVisibility(View.GONE);
+ } // } else {//if(currentAction == this.SELECT_DIRECTORY) {
+ } // private void initializeButtons() {
+
+ private void loadDirectoryUp() {
+ // present directory removed from list
+ String s = pathDirsList.remove(pathDirsList.size() - 1);
+ // path modified to exclude present directory
+ path = new File(path.toString().substring(0,
+ path.toString().lastIndexOf(s)));
+ fileList.clear();
+ }
+
+ private void updateCurrentDirectoryTextView() {
+ int i = 0;
+ String curDirString = "";
+ while (i < pathDirsList.size()) {
+ curDirString += pathDirsList.get(i) + "/";
+ i++;
+ }
+ if (pathDirsList.size() == 0) {
+ ((Button) this.findViewById(R.id.upDirectoryButton))
+ .setEnabled(false);
+ curDirString = "/";
+ } else {
+ ((Button) this.findViewById(R.id.upDirectoryButton))
+ .setEnabled(true);
+ }
+ long freeSpace = getFreeSpace(curDirString);
+ String formattedSpaceString = formatBytes(freeSpace);
+ if (freeSpace == 0) {
+ Log.d(LOGTAG, "NO FREE SPACE");
+ File currentDir = new File(curDirString);
+ if (!currentDir.canWrite()) {
+ formattedSpaceString = "NON Writable";
+ }
+ }
+
+ ((Button) this.findViewById(R.id.selectCurrentDirectoryButton))
+ .setText("Select\n[" + formattedSpaceString + "]");
+
+ ((TextView) this.findViewById(R.id.currentDirectoryTextView))
+ .setText("Current directory: " + curDirString);
+ } // END private void updateCurrentDirectoryTextView() {
+
+ private void showToast(String message) {
+ Toast.makeText(this, message, Toast.LENGTH_LONG).show();
+ }
+
+ private void initializeFileListView() {
+ ListView lView = (ListView) this.findViewById(R.id.fileListView);
+ LinearLayout.LayoutParams lParam = new LinearLayout.LayoutParams(
+ LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
+ lParam.setMargins(15, 5, 15, 5);
+ lView.setAdapter(this.adapter);
+ lView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+ chosenFile = fileList.get(position).file;
+ File sel = new File(path + "/" + chosenFile);
+ Log.d(LOGTAG, "Clicked:" + chosenFile);
+ if (sel.isDirectory()) {
+ if (sel.canRead()) {
+ // Adds chosen directory to list
+ pathDirsList.add(chosenFile);
+ path = new File(sel + "");
+ Log.d(LOGTAG, "Just reloading the list");
+ loadFileList();
+ adapter.notifyDataSetChanged();
+ updateCurrentDirectoryTextView();
+ Log.d(LOGTAG, path.getAbsolutePath());
+ } else { // if(sel.canRead()) {
+ showToast("Path does not exist or cannot be read");
+ } // } else {//if(sel.canRead()) {
+ } else { // if (sel.isDirectory()) {
+ // File picked or an empty directory message clicked
+ Log.d(LOGTAG, "item clicked");
+ if (!directoryShownIsEmpty) {
+ Log.d(LOGTAG, "File selected:" + chosenFile);
+ returnFileFinishActivity(sel.getAbsolutePath());
+ }
+ } // else {//if (sel.isDirectory()) {
+ } // public void onClick(DialogInterface dialog, int which) {
+ }); // lView.setOnClickListener(
+ } // private void initializeFileListView() {
+
+ private void returnDirectoryFinishActivity() {
+ Intent retIntent = new Intent();
+ retIntent.putExtra(returnDirectoryParameter, path.getAbsolutePath());
+ this.setResult(RESULT_OK, retIntent);
+ this.finish();
+ } // END private void returnDirectoryFinishActivity() {
+
+ private void returnFileFinishActivity(String filePath) {
+ Intent retIntent = new Intent();
+ retIntent.putExtra(returnFileParameter, filePath);
+ this.setResult(RESULT_OK, retIntent);
+ this.finish();
+ } // END private void returnDirectoryFinishActivity() {
+
+ private void loadFileList() {
+ try {
+ path.mkdirs();
+ } catch (SecurityException e) {
+ Log.e(LOGTAG, "unable to write on the sd card ");
+ }
+ fileList.clear();
+
+ if (path.exists() && path.canRead()) {
+ FilenameFilter filter = new FilenameFilter() {
+ public boolean accept(File dir, String filename) {
+ File sel = new File(dir, filename);
+ boolean showReadableFile = showHiddenFilesAndDirs
+ || sel.canRead();
+ // Filters based on whether the file is hidden or not
+ if (currentAction == SELECT_DIRECTORY) {
+ return (sel.isDirectory() && showReadableFile);
+ }
+ if (currentAction == SELECT_FILE) {
+
+ // If it is a file check the extension if provided
+ if (sel.isFile() && filterFileExtension != null) {
+ return (showReadableFile && sel.getName().endsWith(
+ filterFileExtension));
+ }
+ return (showReadableFile);
+ }
+ return true;
+ } // public boolean accept(File dir, String filename) {
+ }; // FilenameFilter filter = new FilenameFilter() {
+
+ String[] fList = path.list(filter);
+ this.directoryShownIsEmpty = false;
+ for (int i = 0; i < fList.length; i++) {
+ // Convert into file path
+ File sel = new File(path, fList[i]);
+ Log.d(LOGTAG, "File:" + fList[i] + " readable:" + (Boolean.valueOf(sel.canRead())).toString());
+ int drawableID = R.drawable.file_icon;
+ boolean canRead = sel.canRead();
+ // Set drawables
+ if (sel.isDirectory()) {
+ if (canRead) {
+ drawableID = R.drawable.folder_icon;
+ } else {
+ drawableID = R.drawable.folder_icon_light;
+ }
+ }
+ fileList.add(i, new Item(fList[i], drawableID, canRead));
+ } // for (int i = 0; i < fList.length; i++) {
+ if (fileList.size() == 0) {
+ // Log.d(LOGTAG, "This directory is empty");
+ this.directoryShownIsEmpty = true;
+ fileList.add(0, new Item("Directory is empty", -1, true));
+ } else { // sort non empty list
+ Collections.sort(fileList, new ItemFileNameComparator());
+ }
+ } else {
+ Log.e(LOGTAG, "path does not exist or cannot be read");
+ }
+ // Log.d(TAG, "loadFileList finished");
+ } // private void loadFileList() {
+
+ private void createFileListAdapter() {
+ adapter = new ArrayAdapter<Item>(this,
+ android.R.layout.select_dialog_item, android.R.id.text1,
+ fileList) {
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ // creates view
+ View view = super.getView(position, convertView, parent);
+ TextView textView = (TextView) view
+ .findViewById(android.R.id.text1);
+ // put the image on the text view
+ int drawableID = 0;
+ if (fileList.get(position).icon != -1) {
+ // If icon == -1, then directory is empty
+ drawableID = fileList.get(position).icon;
+ }
+ textView.setCompoundDrawablesWithIntrinsicBounds(drawableID, 0,
+ 0, 0);
+
+ textView.setEllipsize(null);
+
+ // add margin between image and text (support various screen
+ // densities)
+ // int dp5 = (int) (5 *
+ // getResources().getDisplayMetrics().density + 0.5f);
+ int dp3 = (int) (3 * getResources().getDisplayMetrics().density + 0.5f);
+ // TODO: change next line for empty directory, so text will be
+ // centered
+ textView.setCompoundDrawablePadding(dp3);
+ return view;
+ } // public View getView(int position, View convertView, ViewGroup
+ }; // adapter = new ArrayAdapter<Item>(this,
+ } // private createFileListAdapter(){
+
+ private class Item {
+ public String file;
+ public int icon;
+ public boolean canRead;
+
+ public Item(String file, Integer icon, boolean canRead) {
+ this.file = file;
+ this.icon = icon;
+ }
+
+ @Override
+ public String toString() {
+ return file;
+ }
+ } // END private class Item {
+
+ private class ItemFileNameComparator implements Comparator<Item> {
+ public int compare(Item lhs, Item rhs) {
+ return lhs.file.toLowerCase().compareTo(rhs.file.toLowerCase());
+ }
+ }
+
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ Log.d(LOGTAG, "ORIENTATION_LANDSCAPE");
+ } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
+ Log.d(LOGTAG, "ORIENTATION_PORTRAIT");
+ }
+ // Layout apparently changes itself, only have to provide good onMeasure
+ // in custom components
+ // TODO: check with keyboard
+ // if(newConfig.keyboard == Configuration.KEYBOARDHIDDEN_YES)
+ } // END public void onConfigurationChanged(Configuration newConfig) {
+
+ public static long getFreeSpace(String path) {
+ StatFs stat = new StatFs(path);
+ long availSize = (long) stat.getAvailableBlocks()
+ * (long) stat.getBlockSize();
+ return availSize;
+ } // END public static long getFreeSpace(String path) {
+
+ public static String formatBytes(long bytes) {
+ // TODO: add flag to which part is needed (e.g. GB, MB, KB or bytes)
+ String retStr = "";
+ // One binary gigabyte equals 1,073,741,824 bytes.
+ if (bytes > 1073741824) { // Add GB
+ long gbs = bytes / 1073741824;
+ retStr += (new Long(gbs)).toString() + "GB ";
+ bytes = bytes - (gbs * 1073741824);
+ }
+ // One MB - 1048576 bytes
+ if (bytes > 1048576) { // Add GB
+ long mbs = bytes / 1048576;
+ retStr += (new Long(mbs)).toString() + "MB ";
+ bytes = bytes - (mbs * 1048576);
+ }
+ if (bytes > 1024) {
+ long kbs = bytes / 1024;
+ retStr += (new Long(kbs)).toString() + "KB";
+ bytes = bytes - (kbs * 1024);
+ } else {
+ retStr += (new Long(bytes)).toString() + " bytes";
+ }
+ return retStr;
+ } // public static String formatBytes(long bytes){
+
+} // END public class FileBrowserActivity extends Activity {
diff --git a/navit/android/src/org/navitproject/navit/Navit.java b/navit/android/src/org/navitproject/navit/Navit.java
index d3b970e98..bc2af1632 100644
--- a/navit/android/src/org/navitproject/navit/Navit.java
+++ b/navit/android/src/org/navitproject/navit/Navit.java
@@ -1,927 +1,974 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-package org.navitproject.navit;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.app.ActivityManager.TaskDescription;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Color;
-import android.graphics.Point;
-import android.Manifest;
-import android.media.AudioManager;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.Message;
-import android.os.PowerManager;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
-import android.text.SpannableString;
-import android.text.method.LinkMovementMethod;
-import android.text.util.Linkify;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.Display;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-
-public class Navit extends Activity
-{
-
- public NavitDialogs dialogs;
- private PowerManager.WakeLock wl;
- private NavitActivityResult ActivityResults[];
- public static InputMethodManager mgr = null;
- public static DisplayMetrics metrics = null;
- public static int status_bar_height = 0;
- public static int action_bar_default_height = 0;
- public static int navigation_bar_height = 0;
- public static int navigation_bar_height_landscape= 0;
- public static int navigation_bar_width = 0;
- public static Boolean show_soft_keyboard = false;
- public static Boolean show_soft_keyboard_now_showing = false;
- public static long last_pressed_menu_key = 0L;
- public static long time_pressed_menu_key = 0L;
- private static Intent startup_intent = null;
- private static long startup_intent_timestamp = 0L;
- public static String my_display_density = "mdpi";
- public static final int NavitDownloaderSelectMap_id = 967;
- public static final int MAP_NUM_PRIMARY = 11;
- public static final int NavitAddressSearch_id = 70;
- public static final int NavitSelectStorage_id = 43;
- public static String NavitLanguage;
- public static Resources NavitResources = null;
-
- public static final int MAP_NUM_SECONDARY = 12;
- static final String NAVIT_PACKAGE_NAME = "org.navitproject.navit";
- static final String TAG = "Navit";
- static String map_filename_path = null;
- static final String NAVIT_DATA_DIR = "/data/data/" + NAVIT_PACKAGE_NAME;
- static final String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share";
- static final String FIRST_STARTUP_FILE = NAVIT_DATA_SHARE_DIR + "/has_run_once.txt";
- public static final String NAVIT_PREFS = "NavitPrefs";
- Boolean isFullscreen = false;
- private static final int MY_PERMISSIONS_REQUEST_ALL = 101;
-
-
- /**
- * @brief A Runnable to restore soft input when the user returns to the activity.
- *
- * An instance of this class can be passed to the main message queue in the Activity's
- * {@code onRestore()} method.
- */
- private class SoftInputRestorer implements Runnable {
- public void run() {
- Navit.this.showNativeKeyboard();
- }
- }
-
-
- public void removeFileIfExists(String source) {
- File file = new File(source);
-
- if (!file.exists())
- return;
-
- file.delete();
- }
-
- public void copyFileIfExists(String source, String destination) throws IOException {
- File file = new File(source);
-
- if (!file.exists())
- return;
-
- FileInputStream is = null;
- FileOutputStream os = null;
-
- try {
- is = new FileInputStream(source);
- os = new FileOutputStream(destination);
-
- int len;
- byte buffer[] = new byte[1024];
-
- while ((len = is.read(buffer)) != -1) {
- os.write(buffer, 0, len);
- }
- } finally {
- /* Close the FileStreams to prevent Resource leaks */
- if (is != null)
- is.close();
-
- if (os != null)
- os.close();
- }
- return;
- }
-
-
- public static String T(String in)
- {
- return NavitTextTranslations.get_text(in);
- }
-
- private boolean extractRes(String resname, String result) {
- boolean needs_update = false;
- Log.e(TAG, "Res Name " + resname + ", result " + result);
- int id = NavitResources.getIdentifier(resname, "raw", NAVIT_PACKAGE_NAME);
- Log.e(TAG, "Res ID " + id);
- if (id == 0)
- return false;
-
- File resultfile = new File(result);
- if (!resultfile.exists()) {
- needs_update = true;
- File path = resultfile.getParentFile();
- if ( !path.exists() && !resultfile.getParentFile().mkdirs())
- return false;
- } else {
- PackageManager pm = getPackageManager();
- ApplicationInfo appInfo;
- long apkUpdateTime = 0;
- try {
- appInfo = pm.getApplicationInfo(NAVIT_PACKAGE_NAME, 0);
- apkUpdateTime = new File(appInfo.sourceDir).lastModified();
- } catch (NameNotFoundException e) {
- Log.e(TAG, "Could not read package infos");
- e.printStackTrace();
- }
- if (apkUpdateTime > resultfile.lastModified())
- needs_update = true;
- }
-
- if (needs_update) {
- Log.e(TAG, "Extracting resource");
-
- try {
- InputStream resourcestream = NavitResources.openRawResource(id);
- FileOutputStream resultfilestream = new FileOutputStream(resultfile);
- byte[] buf = new byte[1024];
- int i = 0;
- while ((i = resourcestream.read(buf)) != -1) {
- resultfilestream.write(buf, 0, i);
- }
- resultfilestream.close();
- } catch (Exception e) {
- Log.e(TAG, "Exception " + e.getMessage());
- return false;
- }
- }
- return true;
- }
-
- private void showInfos()
- {
- SharedPreferences settings = getSharedPreferences(NAVIT_PREFS, MODE_PRIVATE);
- boolean firstStart = settings.getBoolean("firstStart", true);
-
- if (firstStart)
- {
- AlertDialog.Builder infobox = new AlertDialog.Builder(this);
- infobox.setTitle(getString(R.string.initial_info_box_title)); // TRANS
- infobox.setCancelable(false);
-
- infobox.setMessage(R.string.initial_info_box_message);
-
- // TRANS
- infobox.setPositiveButton(getString(R.string.initial_info_box_OK), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface arg0, int arg1) {
- Log.e("Navit", "Ok, user saw the infobox");
- }
- });
-
- // TRANS
- infobox.setNeutralButton(getString(R.string.initial_info_box_more_info), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface arg0, int arg1) {
- Log.e("Navit", "user wants more info, show the website");
- String url = "http://wiki.navit-project.org/index.php/Navit_on_Android";
- Intent i = new Intent(Intent.ACTION_VIEW);
- i.setData(Uri.parse(url));
- startActivity(i);
- }
- });
- infobox.show();
- SharedPreferences.Editor edit_settings = settings.edit();
- edit_settings.putBoolean("firstStart", false);
- edit_settings.commit();
- }
- }
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
- this.requestWindowFeature(Window.FEATURE_NO_TITLE);
- else
- this.getActionBar().hide();
-
- dialogs = new NavitDialogs(this);
-
- NavitResources = getResources();
-
- // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
- Navit.startup_intent = this.getIntent();
- // hack! Remember time stamps, and only allow 4 secs. later in onResume to set target!
- Navit.startup_intent_timestamp = System.currentTimeMillis();
- Log.e("Navit", "**1**A " + startup_intent.getAction());
- Log.e("Navit", "**1**D " + startup_intent.getDataString());
-
- // init translated text
- NavitTextTranslations.init();
-
- // NOTIFICATION
- // Setup the status bar notification
- // This notification is removed in the exit() function
- NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Grab a handle to the NotificationManager
- Notification NavitNotification = new Notification(R.drawable.ic_notify, getString(R.string.notification_ticker), System.currentTimeMillis()); // Create a new notification, with the text string to show when the notification first appears
- PendingIntent appIntent = PendingIntent.getActivity(getApplicationContext(), 0, getIntent(), 0);
- //FIXME : needs a fix for sdk 23
- //NavitNotification.setLatestEventInfo(getApplicationContext(), "Navit", getString(R.string.notification_event_default), appIntent); // Set the text in the notification
- //NavitNotification.flags|=Notification.FLAG_ONGOING_EVENT; // Ensure that the notification appears in Ongoing
- nm.notify(R.string.app_name, NavitNotification); // Set the notification
-
- // Status and navigation bar sizes
- // These are platform defaults and do not change with rotation, but we have to figure out which ones apply
- // (is the navigation bar visible? on the side or at the bottom?)
- Resources resources = getResources();
- int shid = resources.getIdentifier("status_bar_height", "dimen", "android");
- int adhid = resources.getIdentifier("action_bar_default_height", "dimen", "android");
- int nhid = resources.getIdentifier("navigation_bar_height", "dimen", "android");
- int nhlid = resources.getIdentifier("navigation_bar_height_landscape", "dimen", "android");
- int nwid = resources.getIdentifier("navigation_bar_width", "dimen", "android");
- status_bar_height = (shid > 0) ? resources.getDimensionPixelSize(shid) : 0;
- action_bar_default_height = (adhid > 0) ? resources.getDimensionPixelSize(adhid) : 0;
- navigation_bar_height = (nhid > 0) ? resources.getDimensionPixelSize(nhid) : 0;
- navigation_bar_height_landscape = (nhlid > 0) ? resources.getDimensionPixelSize(nhlid) : 0;
- navigation_bar_width = (nwid > 0) ? resources.getDimensionPixelSize(nwid) : 0;
- Log.d(TAG, String.format("status_bar_height=%d, action_bar_default_height=%d, navigation_bar_height=%d, navigation_bar_height_landscape=%d, navigation_bar_width=%d",
- status_bar_height, action_bar_default_height, navigation_bar_height, navigation_bar_height_landscape, navigation_bar_width));
- if ((ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)||
- (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
- Log.d (TAG,"ask for permission(s)");
- ActivityCompat.requestPermissions(this,
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.ACCESS_FINE_LOCATION},MY_PERMISSIONS_REQUEST_ALL);
- }
- // get the local language -------------
- Locale locale = java.util.Locale.getDefault();
- String lang = locale.getLanguage();
- String langu = lang;
- String langc = lang;
- Log.e("Navit", "lang=" + lang);
- int pos = langu.indexOf('_');
- if (pos != -1)
- {
- langc = langu.substring(0, pos);
- NavitLanguage = langc + langu.substring(pos).toUpperCase(locale);
- Log.e("Navit", "substring lang " + NavitLanguage.substring(pos).toUpperCase(locale));
- // set lang. for translation
- NavitTextTranslations.main_language = langc;
- NavitTextTranslations.sub_language = NavitLanguage.substring(pos).toUpperCase(locale);
- }
- else
- {
- String country = locale.getCountry();
- Log.e("Navit", "Country1 " + country);
- Log.e("Navit", "Country2 " + country.toUpperCase(locale));
- NavitLanguage = langc + "_" + country.toUpperCase(locale);
- // set lang. for translation
- NavitTextTranslations.main_language = langc;
- NavitTextTranslations.sub_language = country.toUpperCase(locale);
- }
- Log.e("Navit", "Language " + lang);
-
- SharedPreferences prefs = getSharedPreferences(NAVIT_PREFS,MODE_PRIVATE);
- map_filename_path = prefs.getString("filenamePath", Environment.getExternalStorageDirectory().getPath() + "/navit/");
-
- // make sure the new path for the navitmap.bin file(s) exist!!
- File navit_maps_dir = new File(map_filename_path);
- navit_maps_dir.mkdirs();
-
- // make sure the share dir exists
- File navit_data_share_dir = new File(NAVIT_DATA_SHARE_DIR);
- navit_data_share_dir.mkdirs();
-
- Display display_ = getWindowManager().getDefaultDisplay();
- int width_ = display_.getWidth();
- int height_ = display_.getHeight();
- metrics = new DisplayMetrics();
- display_.getMetrics(Navit.metrics);
- int densityDpi = (int)(( Navit.metrics.density*160)-.5f);
- Log.e("Navit", "Navit -> pixels x=" + width_ + " pixels y=" + height_);
- Log.e("Navit", "Navit -> dpi=" + densityDpi);
- Log.e("Navit", "Navit -> density=" + Navit.metrics.density);
- Log.e("Navit", "Navit -> scaledDensity=" + Navit.metrics.scaledDensity);
-
- ActivityResults = new NavitActivityResult[16];
- setVolumeControlStream(AudioManager.STREAM_MUSIC);
- PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
- wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,"NavitDoNotDimScreen");
-
- if (!extractRes(langc, NAVIT_DATA_DIR + "/locale/" + langc + "/LC_MESSAGES/navit.mo"))
- {
- Log.e("Navit", "Failed to extract language resource " + langc);
- }
-
- if (densityDpi <= 120)
- {
- my_display_density = "ldpi";
- }
- else if (densityDpi <= 160)
- {
- my_display_density = "mdpi";
- }
- else if (densityDpi < 240)
- {
- my_display_density = "hdpi";
- }
- else if (densityDpi < 320)
- {
- my_display_density = "xhdpi";
- }
- else if (densityDpi < 480)
- {
- my_display_density = "xxhdpi";
- }
- else if (densityDpi < 640)
- {
- my_display_density = "xxxhdpi";
- }
- else
- {
- Log.e("Navit", "found device of very high density ("+densityDpi+")");
- Log.e("Navit", "using xxxhdpi values");
- my_display_density = "xxxhdpi";
- }
-
- if (!extractRes("navit" + my_display_density, NAVIT_DATA_DIR + "/share/navit.xml"))
- {
- Log.e("Navit", "Failed to extract navit.xml for " + my_display_density);
- }
-
- // --> dont use android.os.Build.VERSION.SDK_INT, needs API >= 4
- Log.e("Navit", "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK));
- NavitMain(this, NavitLanguage, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density, NAVIT_DATA_DIR+"/bin/navit",map_filename_path);
-
- showInfos();
-
- Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- }
-
- @Override
- public void onResume()
- {
- super.onResume();
- Log.d("Navit", "OnResume");
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
- /* Required to make system bars fully transparent */
- getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
- }
- //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- // DEBUG
- // intent_data = "google.navigation:q=Wien Burggasse 27";
- // intent_data = "google.navigation:q=48.25676,16.643";
- // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
- // intent_data = "google.navigation:ll=48.25676,16.643";
- if (startup_intent != null)
- {
- if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L)
- {
- Log.e("Navit", "**2**A " + startup_intent.getAction());
- Log.e("Navit", "**2**D " + startup_intent.getDataString());
- String navi_scheme = startup_intent.getScheme();
- if ( navi_scheme != null && navi_scheme.equals("google.navigation")) {
- parseNavigationURI(startup_intent.getData().getSchemeSpecificPart());
- }
- }
- else {
- Log.e("Navit", "timestamp for navigate_to expired! not using data");
- }
- }
- Log.d(TAG, "onResume");
- if (show_soft_keyboard_now_showing) {
- /* Calling showNativeKeyboard() directly won't work here, we need to use the message queue */
- View cf = getCurrentFocus();
- if (cf == null)
- Log.e(TAG, "no view in focus, can't get a handler");
- else
- cf.getHandler().post(new SoftInputRestorer());
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
- Log.d(TAG, "onPause");
- if (show_soft_keyboard_now_showing) {
- Log.d(TAG, "onPause:hiding soft input");
- this.hideNativeKeyboard();
- show_soft_keyboard_now_showing = true;
- }
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
- switch (requestCode) {
- case MY_PERMISSIONS_REQUEST_ALL: {
- if (grantResults.length > 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED
- && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
- // ok, we got permissions
- } else {
- AlertDialog.Builder infobox = new AlertDialog.Builder(this);
- infobox.setTitle(getString(R.string.permissions_info_box_title)); // TRANS
- infobox.setCancelable(false);
- final TextView message = new TextView(this);
- message.setFadingEdgeLength(20);
- message.setVerticalFadingEdgeEnabled(true);
- RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
- message.setLayoutParams(rlp);
- final SpannableString s = new SpannableString(getString(R.string.permissions_not_granted)); // TRANS
- message.setText(s);
- message.setMovementMethod(LinkMovementMethod.getInstance());
- infobox.setView(message);
- // TRANS
- infobox.setPositiveButton(getString(R.string.initial_info_box_OK), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface arg0, int arg1) {
- exit();
- }
- });
- infobox.show();
- }
- return;
- }
- }
- }
-
- private void parseNavigationURI(String schemeSpecificPart) {
- String naviData[]= schemeSpecificPart.split("&");
- Pattern p = Pattern.compile("(.*)=(.*)");
- Map<String,String> params = new HashMap<String,String>();
- for (int count=0; count < naviData.length; count++) {
- Matcher m = p.matcher(naviData[count]);
-
- if (m.matches()) {
- params.put(m.group(1), m.group(2));
- }
- }
-
- // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
- // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
- // c: google.navigation:ll=48.25676,16.643
- // b: google.navigation:q=48.25676,16.643
-
- Float lat;
- Float lon;
- Bundle b = new Bundle();
-
- String geoString = params.get("ll");
- if (geoString != null) {
- String address = params.get("q");
- if (address != null) b.putString("q", address);
- }
- else {
- geoString = params.get("q");
- }
-
- if ( geoString != null) {
- if (geoString.matches("^[+-]{0,1}\\d+(|\\.\\d*),[+-]{0,1}\\d+(|\\.\\d*)$")) {
- String geo[] = geoString.split(",");
- if (geo.length == 2) {
- try {
- lat = Float.valueOf(geo[0]);
- lon = Float.valueOf(geo[1]);
- b.putFloat("lat", lat);
- b.putFloat("lon", lon);
- Message msg = Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_SET_DESTINATION.ordinal());
-
- msg.setData(b);
- msg.sendToTarget();
- Log.e("Navit", "target found (b): " + geoString);
- } catch (NumberFormatException e) { } // nothing to do here
- }
- }
- else {
- start_targetsearch_from_intent(geoString);
- }
- }
- }
-
- public void setActivityResult(int requestCode, NavitActivityResult ActivityResult)
- {
- //Log.e("Navit", "setActivityResult " + requestCode);
- ActivityResults[requestCode] = ActivityResult;
- }
-
- /*
- * This is unused since we dont have the dropdown
- * TODO: recheck if this is right and remove this!
- */
- @Override
- public boolean onPrepareOptionsMenu(Menu menu)
- {
- super.onPrepareOptionsMenu(menu);
- //Log.e("Navit","onPrepareOptionsMenu");
- // this gets called every time the menu is opened!!
- // change menu items here!
- menu.clear();
-
- // group-id,item-id,sort order number
- //menu.add(1, 1, 100, getString(R.string.optionsmenu_zoom_in)); //TRANS
- //menu.add(1, 2, 200, getString(R.string.optionsmenu_zoom_out)); //TRANS
-
- menu.add(1, 3, 300, getString(R.string.optionsmenu_download_maps)); //TRANS
- menu.add(1, 5, 400, getString(R.string.optionsmenu_toggle_poi)); //TRANS
-
- menu.add(1, 6, 500, getString(R.string.optionsmenu_address_search)); //TRANS
- menu.add(1, 10, 600, getString(R.string.optionsmenu_set_map_location));
-
- menu.add(1, 99, 900, getString(R.string.optionsmenu_exit_navit)); //TRANS
-
- /* Only show the Backup to SD-Card Option if we really have one */
- if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
- menu.add(1, 7, 700, getString(R.string.optionsmenu_backup_restore)); //TRANS
-
- return true;
- }
-
- // define callback id here
- public static NavitGraphics N_NavitGraphics = null;
-
- // callback id gets set here when called from NavitGraphics
- public static void setKeypressCallback(int kp_cb_id, NavitGraphics ng)
- {
- //Log.e("Navit", "setKeypressCallback -> id1=" + kp_cb_id);
- //Log.e("Navit", "setKeypressCallback -> ng=" + String.valueOf(ng));
- //N_KeypressCallbackID = kp_cb_id;
- N_NavitGraphics = ng;
- }
-
- public static void setMotionCallback(int mo_cb_id, NavitGraphics ng)
- {
- //Log.e("Navit", "setKeypressCallback -> id2=" + mo_cb_id);
- //Log.e("Navit", "setKeypressCallback -> ng=" + String.valueOf(ng));
- //N_MotionCallbackID = mo_cb_id;
- N_NavitGraphics = ng;
- }
-
- public void start_targetsearch_from_intent(String target_address)
- {
- if (target_address == null || target_address.equals(""))
- {
- // empty search string entered
- Toast.makeText(getApplicationContext(), getString(R.string.address_search_not_found), Toast.LENGTH_LONG).show(); //TRANS
- }
- else
- {
- Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
- search_intent.putExtra("search_string", target_address);
- this.startActivityForResult(search_intent, NavitAddressSearch_id);
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- runOptionsItem(item.getItemId());
- return true;
- }
-
- public void runOptionsItem(int id)
- {
- // Handle item selection
- switch (id)
- {
- case 1 :
- // zoom in
- Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_ZOOM_IN.ordinal()).sendToTarget();
- // if we zoom, hide the bubble
- Log.e("Navit", "onOptionsItemSelected -> zoom in");
- break;
- case 2 :
- // zoom out
- Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_ZOOM_OUT.ordinal()).sendToTarget();
- // if we zoom, hide the bubble
- Log.e("Navit", "onOptionsItemSelected -> zoom out");
- break;
- case 3 :
- // map download menu
- Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class);
- startActivityForResult(map_download_list_activity, Navit.NavitDownloaderSelectMap_id);
- break;
- case 5 :
- // toggle the normal POI layers and labels (to avoid double POIs)
- Message msg = Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_CALL_CMD.ordinal());
- Bundle b = new Bundle();
- b.putString("cmd", "toggle_layer(\"POI Symbols\");");
- msg.setData(b);
- msg.sendToTarget();
-
- msg = Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_CALL_CMD.ordinal());
- b = new Bundle();
- b.putString("cmd", "toggle_layer(\"POI Labels\");");
- msg.setData(b);
- msg.sendToTarget();
-
- // toggle full POI icons on/off
- msg = Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_CALL_CMD.ordinal());
- b = new Bundle();
- b.putString("cmd", "toggle_layer(\"Android-POI-Icons-full\");");
- msg.setData(b);
- msg.sendToTarget();
-
- break;
- case 6 :
- // ok startup address search activity
- Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
- this.startActivityForResult(search_intent, NavitAddressSearch_id);
- break;
- case 7 :
- /* Backup / Restore */
- showDialog(NavitDialogs.DIALOG_BACKUP_RESTORE);
- break;
- case 10:
- setMapLocation();
- break;
- case 99 :
- // exit
- this.onStop();
- this.exit();
- break;
- }
- }
-
-
- /**
- * @brief Shows the Options menu.
- *
- * Calling this method has the same effect as pressing the hardware Menu button, where present, or touching
- * the overflow button in the Action bar.
- */
- public void showMenu() {
- openOptionsMenu();
- }
-
-
- /**
- * @brief Shows the native keyboard or other input method.
- *
- * @return {@code true} if an input method is going to be displayed, {@code false} if not
- */
- public int showNativeKeyboard() {
- /*
- * Apologies for the huge mess that this function is, but Android's soft input API is a big
- * nightmare. Its devs have mercifully given us an option to show or hide the keyboard, but
- * there is no reliable way to figure out if it is actually showing, let alone how much of the
- * screen it occupies, so our best bet is guesswork.
- */
- Configuration config = getResources().getConfiguration();
- if ((config.keyboard == Configuration.KEYBOARD_QWERTY) && (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO))
- /* physical keyboard present, exit */
- return 0;
-
- /* Use SHOW_FORCED here, else keyboard won't show in landscape mode */
- mgr.showSoftInput(getCurrentFocus(), InputMethodManager.SHOW_FORCED);
- show_soft_keyboard_now_showing = true;
-
- /*
- * Crude way to estimate the height occupied by the keyboard: for AOSP on KitKat and Lollipop it
- * is about 62-63% of available screen width (in portrait mode) but no more than slightly above
- * 46% of height (in landscape mode).
- */
- Display display_ = getWindowManager().getDefaultDisplay();
- int width_ = display_.getWidth();
- int height_ = display_.getHeight();
- int maxHeight = height_ * 47 / 100;
- int inputHeight = width_ * 63 / 100;
- if (inputHeight > (maxHeight))
- inputHeight = maxHeight;
-
- /* the receiver isn't going to fire before the UI thread becomes idle, well after this method returns */
- Log.d(TAG, "showNativeKeyboard:return (assuming true)");
- return inputHeight;
- }
-
-
- /**
- * @brief Hides the native keyboard or other input method.
- */
- public void hideNativeKeyboard() {
- mgr.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
- show_soft_keyboard_now_showing = false;
- }
-
-
- void setDestination(float latitude, float longitude, String address) {
- Toast.makeText( getApplicationContext(),getString(R.string.address_search_set_destination) + "\n" + address, Toast.LENGTH_LONG).show(); //TRANS
-
- Message msg = Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_SET_DESTINATION.ordinal());
- Bundle b = new Bundle();
- b.putFloat("lat", latitude);
- b.putFloat("lon", longitude);
- b.putString("q", address);
- msg.setData(b);
- msg.sendToTarget();
- }
-
- protected void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- switch (requestCode)
- {
- case Navit.NavitDownloaderSelectMap_id :
- if (resultCode == Activity.RESULT_OK)
- {
- Message msg = dialogs.obtainMessage(NavitDialogs.MSG_START_MAP_DOWNLOAD
- , data.getIntExtra("map_index", -1), 0);
- msg.sendToTarget();
- }
- break;
- case NavitAddressSearch_id :
- if (resultCode == Activity.RESULT_OK) {
- Bundle destination = data.getExtras();
- Toast.makeText( getApplicationContext(),getString(R.string.address_search_set_destination) + "\n" + destination.getString(("q")), Toast.LENGTH_LONG).show(); //TRANS
-
- Message msg = Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_SET_DESTINATION.ordinal());
- msg.setData(destination);
- msg.sendToTarget();
- }
- break;
- case NavitSelectStorage_id :
- if(resultCode == RESULT_OK) {
- String newDir = data.getStringExtra(FileBrowserActivity.returnDirectoryParameter);
- Log.d(TAG, "selected path= "+newDir);
- if(!newDir.contains("/navit"))
- newDir = newDir+"/navit/";
- else
- newDir = newDir+"/";
- SharedPreferences prefs = this.getSharedPreferences(NAVIT_PREFS,MODE_PRIVATE);
- SharedPreferences.Editor prefs_editor = prefs.edit();
- prefs_editor.putString("filenamePath", newDir);
- prefs_editor.commit();
- Toast.makeText(this, String.format(Navit.T("New location set to %s\nRestart Navit to apply the changes."),newDir),Toast.LENGTH_LONG).show();
- }
- else Log.w(TAG, "select path failed");
- break;
- default :
- //Log.e("Navit", "onActivityResult " + requestCode + " " + resultCode);
- ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
- break;
- }
- }
-
- @Override
- protected void onPrepareDialog(int id, Dialog dialog) {
- dialogs.prepareDialog(id, dialog);
- super.onPrepareDialog(id, dialog);
- }
-
- protected Dialog onCreateDialog(int id)
- {
- return dialogs.createDialog(id);
- }
-
- @Override
- public boolean onSearchRequested() {
- /* Launch the internal Search Activity */
- Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
- this.startActivityForResult(search_intent, NavitAddressSearch_id);
-
- return true;
- }
-
- public boolean setMapLocation()
- {
- Intent fileExploreIntent = new Intent(this,FileBrowserActivity.class);
- fileExploreIntent
- .putExtra(FileBrowserActivity.startDirectoryParameter, "/mnt")
- .setAction(FileBrowserActivity.INTENT_ACTION_SELECT_DIR);
- startActivityForResult(fileExploreIntent,NavitSelectStorage_id);
-
- return true;
- }
-
- @Override
- public void onDestroy()
- {
- super.onDestroy();
- Log.e("Navit", "OnDestroy");
- // TODO next call will kill our app the hard way. This should not be necessary, but ensures navit is
- // properly restarted and no resources are wasted with navit in background. Remove this call after
- // code review
- NavitDestroy();
- }
-
- public void fullscreen(int fullscreen) {
- int w, h;
-
- isFullscreen = (fullscreen != 0);
- if (isFullscreen) {
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
- getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
- }
- else {
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
- getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
- }
-
- Display display_ = getWindowManager().getDefaultDisplay();
- if (Build.VERSION.SDK_INT < 17) {
- w = display_.getWidth();
- h = display_.getHeight();
- } else {
- Point size = new Point();
- display_.getRealSize(size);
- w = size.x;
- h = size.y;
- }
- Log.d(TAG, String.format("Toggle fullscreen, w=%d, h=%d", w, h));
- N_NavitGraphics.handleResize(w, h);
- }
-
- public void disableSuspend()
- {
- wl.acquire();
- wl.release();
- }
-
- public void exit()
- {
-// NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
-// nm.cancel(R.string.app_name);
- NavitVehicle.removeListener();
- NavitDestroy();
- }
-
- public native void NavitMain(Navit x, String lang, int version, String display_density_string, String path, String path2);
- public native void NavitDestroy();
-
- /*
- * this is used to load the 'navit' native library on
- * application startup. The library has already been unpacked at
- * installation time by the package manager.
- */
- static
- {
- System.loadLibrary("navit");
- }
-}
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+package org.navitproject.navit;
+
+import android.Manifest;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Application;
+import android.app.Dialog;
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.AssetManager;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.graphics.Point;
+import android.media.AudioManager;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Message;
+import android.os.PowerManager;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.app.NotificationCompat;
+import android.support.v4.content.ContextCompat;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.Display;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Toast;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Navit extends Activity {
+
+ protected static NavitGraphics graphics = null;
+ private NavitDialogs dialogs;
+ private PowerManager.WakeLock wl;
+ private NavitActivityResult[] ActivityResults;
+ public static InputMethodManager mgr = null;
+ public static DisplayMetrics metrics = null;
+ public static Boolean show_soft_keyboard = false;
+ public static Boolean show_soft_keyboard_now_showing = false;
+ public static long last_pressed_menu_key = 0L;
+ public static long time_pressed_menu_key = 0L;
+ private static Intent startup_intent = null;
+ private static long startup_intent_timestamp = 0L;
+ private static String my_display_density = "mdpi";
+ private static final int NavitDownloaderSelectMap_id = 967;
+ private static final int NavitAddressSearch_id = 70;
+ private static final int NavitSelectStorage_id = 43;
+ private static String NavitLanguage;
+ private static Resources NavitResources = null;
+ private static final String CHANNEL_ID = "org.navitproject.navit";
+ private static final String NAVIT_PACKAGE_NAME = "org.navitproject.navit";
+ private static final String TAG = "Navit";
+ static String map_filename_path = null;
+ static final String NAVIT_DATA_DIR = "/data/data/" + NAVIT_PACKAGE_NAME;
+ private static final String NAVIT_DATA_SHARE_DIR = NAVIT_DATA_DIR + "/share";
+ public static final String NAVIT_PREFS = "NavitPrefs";
+ Boolean isFullscreen = false;
+ private static final int MY_PERMISSIONS_REQUEST_ALL = 101;
+ private static NotificationManager nm;
+ private static Navit navit = null;
+
+ public static Navit getInstance() {
+ return navit;
+ }
+
+
+ /**
+ * @brief A Runnable to restore soft input when the user returns to the activity.
+ *
+ * An instance of this class can be passed to the main message queue in the Activity's
+ * {@code onRestore()} method.
+ */
+ private class SoftInputRestorer implements Runnable {
+ public void run() {
+ Navit.this.showNativeKeyboard();
+ }
+ }
+
+ private void createNotificationChannel() {
+ /*
+ * Create the NotificationChannel, but only on API 26+ because
+ * the NotificationChannel class is new and not in the support library
+ */
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ CharSequence name = getString(R.string.channel_name);
+ //String description = getString(R.string.channel_description);
+ int importance = NotificationManager.IMPORTANCE_LOW;
+ NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
+ //channel.setDescription(description);
+ /*
+ * Register the channel with the system; you can't change the importance
+ * or other notification behaviors after this
+ */
+ NotificationManager notificationManager = getSystemService(NotificationManager.class);
+ notificationManager.createNotificationChannel(channel);
+ }
+ }
+
+ public void removeFileIfExists(String source) {
+ File file = new File(source);
+
+ if (!file.exists()) {
+ return;
+ }
+
+ file.delete();
+ }
+
+ public void copyFileIfExists(String source, String destination) throws IOException {
+ File file = new File(source);
+
+ if (!file.exists()) {
+ return;
+ }
+
+ FileInputStream is = null;
+ FileOutputStream os = null;
+
+ try {
+ is = new FileInputStream(source);
+ os = new FileOutputStream(destination);
+
+ int len;
+ byte[] buffer = new byte[1024];
+
+ while ((len = is.read(buffer)) != -1) {
+ os.write(buffer, 0, len);
+ }
+ } finally {
+ /* Close the FileStreams to prevent Resource leaks */
+ if (is != null) {
+ is.close();
+ }
+
+ if (os != null) {
+ os.close();
+ }
+ }
+ }
+
+ /**
+ * Translates a string from its id
+ * in R.strings
+ *
+ * @param Rid resource identifier
+ * @return translated string
+ */
+ String getTstring(int Rid) {
+ return getLocalizedString(getString(Rid));
+ }
+
+ /**
+ * Check if a specific file needs to be extracted from the apk archive
+ * This is based on whether the file already exist, and if so, whether it is older than the archive or not
+ *
+ * @param filename The full path to the file
+ * @return true if file does not exist, but it can be created at the specified location, we will also return
+ * true if the file exist but the apk archive is more recent (probably package was upgraded)
+ */
+ private boolean resourceFileNeedsUpdate(String filename) {
+ File resultfile = new File(filename);
+
+ if (!resultfile.exists()) {
+ File path = resultfile.getParentFile();
+ if (!path.exists() && !resultfile.getParentFile().mkdirs()) {
+ Log.e(TAG, "Could not create directory path for " + filename);
+ return false;
+ }
+ return true;
+ } else {
+ PackageManager pm = getPackageManager();
+ ApplicationInfo appInfo;
+ long apkUpdateTime = 0;
+ try {
+ appInfo = pm.getApplicationInfo(NAVIT_PACKAGE_NAME, 0);
+ apkUpdateTime = new File(appInfo.sourceDir).lastModified();
+ } catch (NameNotFoundException e) {
+ Log.e(TAG, "Could not read package infos");
+ e.printStackTrace();
+ }
+ if (apkUpdateTime > resultfile.lastModified()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Extract a ressource from the apk archive (res/raw) and save it to a local file
+ *
+ * @param result The full path to the local file
+ * @param resname The name of the ressource file in the archive
+ * @return true if the local file is extracted in @p result
+ */
+ private boolean extractRes(String resname, String result) {
+ Log.d(TAG, "Res Name " + resname + ", result " + result);
+ int id = NavitResources.getIdentifier(resname, "raw", NAVIT_PACKAGE_NAME);
+ Log.d(TAG, "Res ID " + id);
+ if (id == 0) {
+ return false;
+ }
+
+ if (resourceFileNeedsUpdate(result)) {
+ Log.d(TAG, "Extracting resource");
+
+ try {
+ InputStream resourcestream = NavitResources.openRawResource(id);
+ FileOutputStream resultfilestream = new FileOutputStream(new File(result));
+ byte[] buf = new byte[1024];
+ int i;
+ while ((i = resourcestream.read(buf)) != -1) {
+ resultfilestream.write(buf, 0, i);
+ }
+ resultfilestream.close();
+ } catch (Exception e) {
+ Log.e(TAG, "Exception " + e.getMessage());
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Extract an asset from the apk archive (assets) and save it to a local file
+ *
+ * @param output The full path to the output local file
+ * @param assetFileName The full path of the asset file within the archive
+ * @return true if the local file is extracted in @p output
+ */
+ private boolean extractAsset(String assetFileName, String output) {
+ AssetManager assetMgr = NavitResources.getAssets();
+ InputStream assetstream;
+ Log.d(TAG, "Asset Name " + assetFileName + ", output " + output);
+ try {
+ assetstream = assetMgr.open(assetFileName);
+ } catch (IOException e) {
+ Log.e(TAG, "Failed opening asset '" + assetFileName + "'");
+ return false;
+ }
+
+ if (resourceFileNeedsUpdate(output)) {
+ Log.d(TAG, "Extracting asset '" + assetFileName + "'");
+
+ try {
+ FileOutputStream outputFilestream = new FileOutputStream(new File(output));
+ byte[] buf = new byte[1024];
+ int i = 0;
+ while ((i = assetstream.read(buf)) != -1) {
+ outputFilestream.write(buf, 0, i);
+ }
+ outputFilestream.close();
+ } catch (Exception e) {
+ Log.e(TAG, "Exception " + e.getMessage());
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private void showInfos() {
+ SharedPreferences settings = getSharedPreferences(NAVIT_PREFS, MODE_PRIVATE);
+ boolean firstStart = settings.getBoolean("firstStart", true);
+
+ if (firstStart) {
+ AlertDialog.Builder infobox = new AlertDialog.Builder(this);
+ infobox.setTitle(getTstring(R.string.initial_info_box_title)); // TRANS
+ infobox.setCancelable(false);
+
+ infobox.setMessage(getTstring(R.string.initial_info_box_message));
+
+ infobox.setPositiveButton(getTstring(R.string.initial_info_box_OK), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ Log.d(TAG, "Ok, user saw the infobox");
+ }
+ });
+
+ infobox.setNeutralButton(getTstring(R.string.initial_info_box_more_info),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ Log.d(TAG, "user wants more info, show the website");
+ String url = "http://wiki.navit-project.org/index.php/Navit_on_Android";
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse(url));
+ startActivity(i);
+ }
+ });
+ infobox.show();
+ SharedPreferences.Editor edit_settings = settings.edit();
+ edit_settings.putBoolean("firstStart", false);
+ edit_settings.apply();
+ }
+ }
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ /* Whether this is the first launch of Navit (as opposed to the activity being recreated) */
+ boolean isLaunch = (navit == null);
+
+ super.onCreate(savedInstanceState);
+ if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
+ this.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ } else {
+ this.getActionBar().hide();
+ }
+
+ navit = this;
+ dialogs = new NavitDialogs(this);
+
+ NavitResources = getResources();
+
+ // only take arguments here, onResume gets called all the time (e.g. when screenblanks, etc.)
+ Navit.startup_intent = this.getIntent();
+ // hack! Remember time stamps, and only allow 4 secs. later in onResume to set target!
+ Navit.startup_intent_timestamp = System.currentTimeMillis();
+ Log.d(TAG, "**1**A " + startup_intent.getAction());
+ Log.d(TAG, "**1**D " + startup_intent.getDataString());
+
+ // NOTIFICATION
+ // Setup the status bar notification
+ // This notification is removed in the exit() function
+ if (isLaunch)
+ createNotificationChannel();
+ nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Grab a handle to the NotificationManager
+ PendingIntent appIntent = PendingIntent.getActivity(getApplicationContext(), 0, getIntent(), 0);
+
+ Notification NavitNotification;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ Notification.Builder builder;
+ builder = new Notification.Builder(getApplicationContext(), CHANNEL_ID);
+ builder.setContentIntent(appIntent);
+ builder.setAutoCancel(false).setOngoing(true);
+ builder.setContentTitle(getTstring(R.string.app_name));
+ builder.setContentText(getTstring(R.string.notification_event_default));
+ builder.setSmallIcon(R.drawable.ic_notify);
+ NavitNotification = builder.build();
+ } else {
+ NotificationCompat.Builder builder;
+ builder = new NotificationCompat.Builder(getApplicationContext());
+ builder.setContentIntent(appIntent);
+ builder.setAutoCancel(false).setOngoing(true);
+ builder.setContentTitle(getTstring(R.string.app_name));
+ builder.setContentText(getTstring(R.string.notification_event_default));
+ builder.setSmallIcon(R.drawable.ic_notify);
+ NavitNotification = builder.build();
+ }
+ nm.notify(R.string.app_name, NavitNotification);// Show the notification
+
+ if ((ContextCompat.checkSelfPermission(this,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
+ || (ContextCompat.checkSelfPermission(this,
+ Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
+ Log.d(TAG,"ask for permission(s)");
+ ActivityCompat.requestPermissions(this,
+ new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.ACCESS_FINE_LOCATION},
+ MY_PERMISSIONS_REQUEST_ALL);
+ }
+ // get the local language -------------
+ Locale locale = java.util.Locale.getDefault();
+ String lang = locale.getLanguage();
+ String langc = lang;
+ Log.d(TAG, "lang=" + lang);
+ int pos = lang.indexOf('_');
+ if (pos != -1) {
+ langc = lang.substring(0, pos);
+ NavitLanguage = langc + lang.substring(pos).toUpperCase(locale);
+ Log.d(TAG, "substring lang " + NavitLanguage.substring(pos).toUpperCase(locale));
+ } else {
+ String country = locale.getCountry();
+ Log.d(TAG, "Country1 " + country);
+ Log.d(TAG, "Country2 " + country.toUpperCase(locale));
+ NavitLanguage = langc + "_" + country.toUpperCase(locale);
+ }
+ Log.d(TAG, "Language " + lang);
+
+ SharedPreferences prefs = getSharedPreferences(NAVIT_PREFS,MODE_PRIVATE);
+ map_filename_path = prefs.getString("filenamePath",
+ Environment.getExternalStorageDirectory().getPath() + "/navit/");
+
+ // make sure the new path for the navitmap.bin file(s) exist!!
+ File navit_maps_dir = new File(map_filename_path);
+ navit_maps_dir.mkdirs();
+
+ // make sure the share dir exists
+ File navit_data_share_dir = new File(NAVIT_DATA_SHARE_DIR);
+ navit_data_share_dir.mkdirs();
+
+ Display display_ = getWindowManager().getDefaultDisplay();
+ int width_ = display_.getWidth();
+ int height_ = display_.getHeight();
+ metrics = new DisplayMetrics();
+ display_.getMetrics(Navit.metrics);
+ int densityDpi = (int)((Navit.metrics.density * 160) - .5f);
+ Log.d(TAG, "Navit -> pixels x=" + width_ + " pixels y=" + height_);
+ Log.d(TAG, "Navit -> dpi=" + densityDpi);
+ Log.d(TAG, "Navit -> density=" + Navit.metrics.density);
+ Log.d(TAG, "Navit -> scaledDensity=" + Navit.metrics.scaledDensity);
+
+ ActivityResults = new NavitActivityResult[16];
+ setVolumeControlStream(AudioManager.STREAM_MUSIC);
+ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,"NavitDoNotDimScreen");
+
+ if (!extractRes(langc, NAVIT_DATA_DIR + "/locale/" + langc + "/LC_MESSAGES/navit.mo")) {
+ Log.e(TAG, "Failed to extract language resource " + langc);
+ }
+
+ if (densityDpi <= 120) {
+ my_display_density = "ldpi";
+ } else if (densityDpi <= 160) {
+ my_display_density = "mdpi";
+ } else if (densityDpi < 240) {
+ my_display_density = "hdpi";
+ } else if (densityDpi < 320) {
+ my_display_density = "xhdpi";
+ } else if (densityDpi < 480) {
+ my_display_density = "xxhdpi";
+ } else if (densityDpi < 640) {
+ my_display_density = "xxxhdpi";
+ } else {
+ Log.w(TAG, "found device of very high density (" + densityDpi + ")");
+ Log.w(TAG, "using xxxhdpi values");
+ my_display_density = "xxxhdpi";
+ }
+ Log.i(TAG, "Device density detected: " + my_display_density);
+
+ try {
+ AssetManager assetMgr = NavitResources.getAssets();
+ String[] children = assetMgr.list("config/" + my_display_density);
+ for (String child : children) {
+ Log.d(TAG, "Processing config file '" + child + "' from assets");
+ if (!extractAsset("config/" + my_display_density + "/" + child, NAVIT_DATA_DIR + "/share/" + child)) {
+ Log.e(TAG, "Failed to extract asset config/" + my_display_density + "/" + child);
+ }
+ }
+ } catch (IOException e) {
+ Log.e(TAG, "Failed to access assets using AssetManager");
+ }
+
+ Log.d(TAG, "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK));
+ NavitMain(this, getApplication(), NavitLanguage, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density,
+ NAVIT_DATA_DIR + "/bin/navit", map_filename_path, isLaunch);
+ if (graphics != null)
+ graphics.setActivity(this);
+
+ showInfos();
+
+ Navit.mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ Log.d(TAG, "OnResume");
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+ /* Required to make system bars fully transparent */
+ getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ }
+ //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ // DEBUG
+ // intent_data = "google.navigation:q=Wien Burggasse 27";
+ // intent_data = "google.navigation:q=48.25676,16.643";
+ // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
+ // intent_data = "google.navigation:ll=48.25676,16.643";
+ if (startup_intent != null) {
+ if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L) {
+ Log.d(TAG, "**2**A " + startup_intent.getAction());
+ Log.d(TAG, "**2**D " + startup_intent.getDataString());
+ String navi_scheme = startup_intent.getScheme();
+ if (navi_scheme != null && navi_scheme.equals("google.navigation")) {
+ parseNavigationURI(startup_intent.getData().getSchemeSpecificPart());
+ }
+ } else {
+ Log.e(TAG, "timestamp for navigate_to expired! not using data");
+ }
+ }
+ Log.d(TAG, "onResume");
+
+ if (show_soft_keyboard_now_showing) {
+ /* Calling showNativeKeyboard() directly won't work here, we need to use the message queue */
+ View cf = getCurrentFocus();
+ if (cf == null) {
+ Log.e(TAG, "no view in focus, can't get a handler");
+ } else {
+ cf.getHandler().post(new SoftInputRestorer());
+ }
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ Log.d(TAG, "onPause");
+ if (show_soft_keyboard_now_showing) {
+ Log.d(TAG, "onPause:hiding soft input");
+ this.hideNativeKeyboard();
+ show_soft_keyboard_now_showing = true;
+ }
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
+ switch (requestCode) {
+ case MY_PERMISSIONS_REQUEST_ALL: {
+ if (grantResults.length > 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED
+ && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
+ return;
+ }
+ AlertDialog.Builder infobox = new AlertDialog.Builder(this);
+ infobox.setTitle(getTstring(R.string.permissions_info_box_title)); // TRANS
+ infobox.setCancelable(false);
+ infobox.setMessage(getTstring(R.string.permissions_not_granted));
+ // TRANS
+ infobox.setPositiveButton(getTstring(R.string.initial_info_box_OK),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ exit();
+ }
+ });
+ infobox.show();
+ }
+ }
+ }
+
+ private void parseNavigationURI(String schemeSpecificPart) {
+ String[] naviData = schemeSpecificPart.split("&");
+ Pattern p = Pattern.compile("(.*)=(.*)");
+ Map<String,String> params = new HashMap<String,String>();
+ for (int count = 0; count < naviData.length; count++) {
+ Matcher m = p.matcher(naviData[count]);
+
+ if (m.matches()) {
+ params.put(m.group(1), m.group(2));
+ }
+ }
+
+ // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
+ // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
+ // c: google.navigation:ll=48.25676,16.643
+ // b: google.navigation:q=48.25676,16.643
+
+ Float lat;
+ Float lon;
+ Bundle b = new Bundle();
+
+ String geoString = params.get("ll");
+ if (geoString != null) {
+ String address = params.get("q");
+ if (address != null) {
+ b.putString("q", address);
+ }
+ } else {
+ geoString = params.get("q");
+ }
+
+ if (geoString != null) {
+ if (geoString.matches("^[+-]{0,1}\\d+(|\\.\\d*),[+-]{0,1}\\d+(|\\.\\d*)$")) {
+ String[] geo = geoString.split(",");
+ if (geo.length == 2) {
+ try {
+ lat = Float.valueOf(geo[0]);
+ lon = Float.valueOf(geo[1]);
+ b.putFloat("lat", lat);
+ b.putFloat("lon", lon);
+ Message msg = Message.obtain(N_NavitGraphics.callback_handler,
+ NavitGraphics.msg_type.CLB_SET_DESTINATION.ordinal());
+
+ msg.setData(b);
+ msg.sendToTarget();
+ Log.e(TAG, "target found (b): " + geoString);
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
+ }
+ } else {
+ start_targetsearch_from_intent(geoString);
+ }
+ }
+ }
+
+ public void setActivityResult(int requestCode, NavitActivityResult ActivityResult) {
+ ActivityResults[requestCode] = ActivityResult;
+ }
+
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ super.onPrepareOptionsMenu(menu);
+ //Log.e("Navit","onPrepareOptionsMenu");
+ // this gets called every time the menu is opened!!
+ // change menu items here!
+ menu.clear();
+
+ // group-id,item-id,sort order number
+ //menu.add(1, 1, 100, getString(R.string.optionsmenu_zoom_in)); //TRANS
+ //menu.add(1, 2, 200, getString(R.string.optionsmenu_zoom_out)); //TRANS
+
+ menu.add(1, 3, 300, getTstring(R.string.optionsmenu_download_maps)); //TRANS
+ menu.add(1, 5, 400, getTstring(R.string.optionsmenu_toggle_poi)); //TRANS
+
+ menu.add(1, 6, 500, getTstring(R.string.optionsmenu_address_search)); //TRANS
+ menu.add(1, 10, 600, getTstring(R.string.optionsmenu_set_map_location));
+
+ menu.add(1, 99, 900, getTstring(R.string.optionsmenu_exit_navit)); //TRANS
+
+ /* Only show the Backup to SD-Card Option if we really have one */
+ if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+ menu.add(1, 7, 700, getTstring(R.string.optionsmenu_backup_restore)); //TRANS
+ }
+
+ return true;
+ }
+
+ // define callback id here
+ private NavitGraphics N_NavitGraphics = null;
+
+ // callback id gets set here when called from NavitGraphics
+ public void setKeypressCallback(int kp_cb_id, NavitGraphics ng) {
+ N_NavitGraphics = ng;
+ }
+
+ public void setMotionCallback(int mo_cb_id, NavitGraphics ng) {
+ N_NavitGraphics = ng;
+ }
+
+ public NavitGraphics getNavitGraphics() {
+ return N_NavitGraphics;
+ }
+
+
+ public void start_targetsearch_from_intent(String target_address) {
+ if (target_address == null || target_address.equals("")) {
+ // empty search string entered
+ Toast.makeText(getApplicationContext(), getTstring(R.string.address_search_not_found),
+ Toast.LENGTH_LONG).show(); //TRANS
+ } else {
+ Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
+ search_intent.putExtra("search_string", target_address);
+ this.startActivityForResult(search_intent, NavitAddressSearch_id);
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ runOptionsItem(item.getItemId());
+ return true;
+ }
+
+ public void runOptionsItem(int id) {
+ switch (id) {
+ case 1 :
+ // zoom in
+ Message.obtain(N_NavitGraphics.callback_handler,
+ NavitGraphics.msg_type.CLB_ZOOM_IN.ordinal()).sendToTarget();
+ // if we zoom, hide the bubble
+ Log.d(TAG, "onOptionsItemSelected -> zoom in");
+ break;
+ case 2 :
+ // zoom out
+ Message.obtain(N_NavitGraphics.callback_handler,
+ NavitGraphics.msg_type.CLB_ZOOM_OUT.ordinal()).sendToTarget();
+ // if we zoom, hide the bubble
+ Log.d(TAG, "onOptionsItemSelected -> zoom out");
+ break;
+ case 3 :
+ // map download menu
+ Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class);
+ startActivityForResult(map_download_list_activity, Navit.NavitDownloaderSelectMap_id);
+ break;
+ case 5 :
+ // toggle the normal POI layers and labels (to avoid double POIs)
+ Message msg = Message.obtain(N_NavitGraphics.callback_handler,
+ NavitGraphics.msg_type.CLB_CALL_CMD.ordinal());
+ Bundle b = new Bundle();
+ b.putString("cmd", "toggle_layer(\"POI Symbols\");");
+ msg.setData(b);
+ msg.sendToTarget();
+
+ msg = Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_CALL_CMD.ordinal());
+ b = new Bundle();
+ b.putString("cmd", "toggle_layer(\"POI Labels\");");
+ msg.setData(b);
+ msg.sendToTarget();
+
+ // toggle full POI icons on/off
+ msg = Message.obtain(N_NavitGraphics.callback_handler, NavitGraphics.msg_type.CLB_CALL_CMD.ordinal());
+ b = new Bundle();
+ b.putString("cmd", "toggle_layer(\"Android-POI-Icons-full\");");
+ msg.setData(b);
+ msg.sendToTarget();
+
+ break;
+ case 6 :
+ // ok startup address search activity
+ Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
+ this.startActivityForResult(search_intent, NavitAddressSearch_id);
+ break;
+ case 7 :
+ /* Backup / Restore */
+ showDialog(NavitDialogs.DIALOG_BACKUP_RESTORE);
+ break;
+ case 10:
+ setMapLocation();
+ break;
+ case 99 :
+ // exit
+ this.onStop();
+ this.exit();
+ break;
+ }
+ }
+
+
+ /**
+ * Shows the Options menu.
+ *
+ * Calling this method has the same effect as pressing the hardware Menu button, where present, or touching
+ * the overflow button in the Action bar.
+ */
+ public void showMenu() {
+ openOptionsMenu();
+ }
+
+
+ /**
+ * Shows the native keyboard or other input method.
+ */
+ public int showNativeKeyboard() {
+ /*
+ * Apologies for the huge mess that this function is, but Android's soft input API is a big
+ * nightmare. Its devs have mercifully given us an option to show or hide the keyboard, but
+ * there is no reliable way to figure out if it is actually showing, let alone how much of the
+ * screen it occupies, so our best bet is guesswork.
+ */
+ Configuration config = getResources().getConfiguration();
+ if ((config.keyboard == Configuration.KEYBOARD_QWERTY)
+ && (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)) {
+ /* physical keyboard present, exit */
+ return 0;
+ }
+
+ /* Use SHOW_FORCED here, else keyboard won't show in landscape mode */
+ mgr.showSoftInput(getCurrentFocus(), InputMethodManager.SHOW_FORCED);
+ show_soft_keyboard_now_showing = true;
+
+ /*
+ * Crude way to estimate the height occupied by the keyboard: for AOSP on KitKat and Lollipop it
+ * is about 62-63% of available screen width (in portrait mode) but no more than slightly above
+ * 46% of height (in landscape mode).
+ */
+ Display display_ = getWindowManager().getDefaultDisplay();
+ int width_ = display_.getWidth();
+ int height_ = display_.getHeight();
+ int maxHeight = height_ * 47 / 100;
+ int inputHeight = width_ * 63 / 100;
+ if (inputHeight > (maxHeight)) {
+ inputHeight = maxHeight;
+ }
+
+ /* the receiver isn't going to fire before the UI thread becomes idle, well after this method returns */
+ Log.d(TAG, "showNativeKeyboard:return (assuming true)");
+ return inputHeight;
+ }
+
+
+ /**
+ * Hides the native keyboard or other input method.
+ */
+ public void hideNativeKeyboard() {
+ mgr.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
+ show_soft_keyboard_now_showing = false;
+ }
+
+
+ void setDestination(float latitude, float longitude, String address) {
+ Toast.makeText(getApplicationContext(),getTstring(R.string.address_search_set_destination) + "\n" + address,
+ Toast.LENGTH_LONG).show(); //TRANS
+
+ Message msg = Message.obtain(N_NavitGraphics.callback_handler,
+ NavitGraphics.msg_type.CLB_SET_DESTINATION.ordinal());
+ Bundle b = new Bundle();
+ b.putFloat("lat", latitude);
+ b.putFloat("lon", longitude);
+ b.putString("q", address);
+ msg.setData(b);
+ msg.sendToTarget();
+ }
+
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ switch (requestCode) {
+ case Navit.NavitDownloaderSelectMap_id :
+ if (resultCode == Activity.RESULT_OK) {
+ Message msg = dialogs.obtainMessage(NavitDialogs.MSG_START_MAP_DOWNLOAD,
+ data.getIntExtra("map_index", -1), 0);
+ msg.sendToTarget();
+ }
+ break;
+ case NavitAddressSearch_id :
+ if (resultCode == Activity.RESULT_OK) {
+ Bundle destination = data.getExtras();
+ Toast.makeText(getApplicationContext(),
+ getTstring(R.string.address_search_set_destination) + "\n" + destination.getString(("q")),
+ Toast.LENGTH_LONG).show(); //TRANS
+
+ Message msg = Message.obtain(N_NavitGraphics.callback_handler,
+ NavitGraphics.msg_type.CLB_SET_DESTINATION.ordinal());
+ msg.setData(destination);
+ msg.sendToTarget();
+ }
+ break;
+ case NavitSelectStorage_id :
+ if (resultCode == RESULT_OK) {
+ String newDir = data.getStringExtra(FileBrowserActivity.returnDirectoryParameter);
+ Log.d(TAG, "selected path= " + newDir);
+ if (!newDir.contains("/navit")) {
+ newDir = newDir + "/navit/";
+ } else {
+ newDir = newDir + "/";
+ }
+ SharedPreferences prefs = this.getSharedPreferences(NAVIT_PREFS,MODE_PRIVATE);
+ SharedPreferences.Editor prefs_editor = prefs.edit();
+ prefs_editor.putString("filenamePath", newDir);
+ prefs_editor.apply();
+
+ Toast.makeText(this, String.format(getTstring(R.string.map_location_changed),newDir),
+ Toast.LENGTH_LONG).show();
+ } else {
+ Log.w(TAG, "select path failed");
+ }
+ break;
+ default :
+ if (ActivityResults[requestCode] != null)
+ ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
+ break;
+ }
+ }
+
+ @Override
+ protected void onPrepareDialog(int id, Dialog dialog) {
+ dialogs.prepareDialog(id);
+ super.onPrepareDialog(id, dialog);
+ }
+
+ protected Dialog onCreateDialog(int id) {
+ return dialogs.createDialog(id);
+ }
+
+ @Override
+ public boolean onSearchRequested() {
+ /* Launch the internal Search Activity */
+ Intent search_intent = new Intent(this, NavitAddressSearchActivity.class);
+ this.startActivityForResult(search_intent, NavitAddressSearch_id);
+
+ return true;
+ }
+
+ private void setMapLocation() {
+ Intent fileExploreIntent = new Intent(this,FileBrowserActivity.class);
+ fileExploreIntent
+ .putExtra(FileBrowserActivity.startDirectoryParameter, "/mnt")
+ .setAction(FileBrowserActivity.INTENT_ACTION_SELECT_DIR);
+ startActivityForResult(fileExploreIntent,NavitSelectStorage_id);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ Log.d(TAG, "OnDestroy");
+ }
+
+ public void fullscreen(int fullscreen) {
+ int w, h;
+
+ isFullscreen = (fullscreen != 0);
+ if (isFullscreen) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+ } else {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+
+ Display display_ = getWindowManager().getDefaultDisplay();
+ if (Build.VERSION.SDK_INT < 17) {
+ w = display_.getWidth();
+ h = display_.getHeight();
+ } else {
+ Point size = new Point();
+ display_.getRealSize(size);
+ w = size.x;
+ h = size.y;
+ }
+ Log.d(TAG, String.format("Toggle fullscreen, w=%d, h=%d", w, h));
+ N_NavitGraphics.handleResize(w, h);
+ }
+
+ public void disableSuspend() {
+ wl.acquire();
+ wl.release();
+ }
+
+ private void exit() {
+ nm.cancelAll();
+ NavitVehicle.removeListener();
+ NavitDestroy();
+ }
+
+ public native void NavitMain(Navit x, Application application, String lang, int version,
+ String display_density_string, String path, String path2, boolean isLaunch);
+
+ public native void NavitDestroy();
+
+
+ private String getLocalizedString(String text) {
+ return NavitGraphics.CallbackLocalizedString(text);
+ }
+
+
+ /*
+ * this is used to load the 'navit' native library on
+ * application startup. The library has already been unpacked at
+ * installation time by the package manager.
+ */
+ static {
+ System.loadLibrary("navit");
+ }
+}
diff --git a/navit/android/src/org/navitproject/navit/NavitActivityResult.java b/navit/android/src/org/navitproject/navit/NavitActivityResult.java
index 63b4e798f..7d3ef8cb4 100644
--- a/navit/android/src/org/navitproject/navit/NavitActivityResult.java
+++ b/navit/android/src/org/navitproject/navit/NavitActivityResult.java
@@ -1,6 +1,7 @@
package org.navitproject.navit;
+
import android.content.Intent;
public interface NavitActivityResult {
public void onActivityResult(int requestCode, int resultCode, Intent data);
-};
+}
diff --git a/navit/android/src/org/navitproject/navit/NavitAddressSearchActivity.java b/navit/android/src/org/navitproject/navit/NavitAddressSearchActivity.java
index 80d285fa5..5905433d6 100644
--- a/navit/android/src/org/navitproject/navit/NavitAddressSearchActivity.java
+++ b/navit/android/src/org/navitproject/navit/NavitAddressSearchActivity.java
@@ -1,385 +1,386 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-package org.navitproject.navit;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Locale;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.WindowManager;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.EditText;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.widget.RelativeLayout;
-import android.widget.Toast;
-import android.widget.RelativeLayout.LayoutParams;
-import android.widget.TextView;
-
-public class NavitAddressSearchActivity extends Activity {
- public static final class NavitAddress {
- public NavitAddress(int type, float latitude, float longitude, String address) {
- result_type = type;
- lat = latitude;
- lon = longitude;
- addr = address;
- }
-
- int result_type;
- float lat;
- float lon;
- String addr;
- }
-
- private static final String TAG = "NavitAddress";
- private static final int ADDRESS_RESULT_PROGRESS_MAX = 10;
-
- private List<NavitAddress> Addresses_found = null;
- private List<NavitAddress> addresses_shown = null;
- private String mAddressString = "";
- private boolean mPartialSearch = false;
- private String mCountry;
- private ImageButton mCountryButton;
- ProgressDialog search_results_wait = null;
- public RelativeLayout NavitAddressSearchActivity_layout;
- private int search_results_towns = 0;
- private int search_results_streets = 0;
- private int search_results_streets_hn = 0;
- private long search_handle = 0;
-
- // TODO remember settings
- private static String last_address_search_string = "";
- private static Boolean last_address_partial_match = false;
- private static String last_country = "";
-
- private int getDrawableID(String resourceName) {
- int drawableId = 0;
- try {
- Class<?> res = R.drawable.class;
- Field field = res.getField(resourceName);
- drawableId = field.getInt(null);
- } catch (Exception e) {
- Log.e("NavitAddressSearch", "Failure to get drawable id.", e);
- }
- return drawableId;
- }
-
- private void setCountryButtonImage() {
- // We have all images stored as drawable_nodpi resources which allows native code to manipulate them
- // without interference with android builtin choosing and scaling system. But that makes us to
- // reinvent the wheel here to show an image in android native interface.
- int flag_icon_sizes[]={24,32,48,64,96};
- int exact_size, nearest_size;
- exact_size=(int)(Navit.metrics.density*24.0 -.5);
- nearest_size=flag_icon_sizes[0];
- for(int size: flag_icon_sizes) {
- nearest_size=size;
- if(exact_size<=size)
- break;
- }
- mCountryButton.setImageResource(getDrawableID("country_" + mCountry+"_"+nearest_size+"_"+nearest_size));
- }
-
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- Bundle extras = getIntent().getExtras();
- if ( extras != null )
- {
- String search_string = extras.getString(("search_string"));
- if (search_string != null) {
- mPartialSearch = true;
- mAddressString = search_string;
- executeSearch();
- return;
- }
- }
-
- mPartialSearch = last_address_partial_match;
- mAddressString = last_address_search_string;
-
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
- LinearLayout panel = new LinearLayout(this);
- panel.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- panel.setOrientation(LinearLayout.VERTICAL);
-
- // address: label and text field
- SharedPreferences settings = getSharedPreferences(Navit.NAVIT_PREFS, MODE_PRIVATE);
- mCountry = settings.getString(("DefaultCountry") , null);
-
- if (mCountry == null) {
- Locale defaultLocale = Locale.getDefault();
- mCountry = defaultLocale.getCountry().toLowerCase(defaultLocale);
- SharedPreferences.Editor edit_settings = settings.edit();
- edit_settings.putString("DefaultCountry", mCountry);
- edit_settings.commit();
- }
-
- mCountryButton = new ImageButton(this);
-
- setCountryButtonImage();
-
- mCountryButton.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- requestCountryDialog();
- }
- });
-
- // address: label and text field
- TextView addr_view = new TextView(this);
- addr_view.setText(Navit.T("Enter Destination")); // TRANS
- addr_view.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20f);
- addr_view.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- addr_view.setPadding(4, 4, 4, 4);
-
- // partial match checkbox
- final CheckBox checkboxPartialMatch = new CheckBox(this);
- checkboxPartialMatch.setText(Navit.T("partial match")); // TRANS
- checkboxPartialMatch.setChecked(last_address_partial_match);
- checkboxPartialMatch.setGravity(Gravity.CENTER);
-
- final EditText address_string = new EditText(this);
- address_string.setText(last_address_search_string);
- address_string.setSelectAllOnFocus(true);
-
- // search button
- final Button btnSearch = new Button(this);
- btnSearch.setText(Navit.T("Search")); // TRANS
- btnSearch.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
- btnSearch.setGravity(Gravity.CENTER);
- btnSearch.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- mPartialSearch = checkboxPartialMatch.isChecked();
- mAddressString = address_string.getText().toString();
- last_address_partial_match = mPartialSearch;
- last_address_search_string = mAddressString;
- executeSearch();
- }
- });
-
- ListView lastAddresses = new ListView(this);
- NavitAppConfig navitConfig = (NavitAppConfig) getApplicationContext();
-
- final List<NavitAddress> addresses = navitConfig.getLastAddresses();
- int addressCount = addresses.size();
- if (addressCount > 0) {
- String[] strAddresses = new String[addressCount];
- for (int addrIndex = 0; addrIndex < addressCount; addrIndex++) {
- strAddresses[addrIndex] = addresses.get(addrIndex).addr;
- }
- ArrayAdapter<String> addressList =
- new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, strAddresses);
- lastAddresses.setAdapter(addressList);
- lastAddresses.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
- NavitAddress addressSelected = addresses.get(arg2);
- Intent resultIntent = new Intent();
-
- resultIntent.putExtra("lat", addressSelected.lat);
- resultIntent.putExtra("lon", addressSelected.lon);
- resultIntent.putExtra("q", addressSelected.addr);
-
- setResult(Activity.RESULT_OK, resultIntent);
- finish();
- }
- });
- }
-
- String title = getString(R.string.address_search_title);
-
- if (title != null && title.length() > 0)
- this.setTitle(title);
-
- LinearLayout searchSettingsLayout = new LinearLayout(this);
- searchSettingsLayout.setOrientation(LinearLayout.HORIZONTAL);
-
- searchSettingsLayout.addView(mCountryButton);
- searchSettingsLayout.addView(checkboxPartialMatch);
- panel.addView(addr_view);
- panel.addView(address_string);
- panel.addView(searchSettingsLayout);
- panel.addView(btnSearch);
- panel.addView(lastAddresses);
-
- setContentView(panel);
- }
-
- private void requestCountryDialog() {
- final String[][] all_countries = NavitGraphics.GetAllCountries();
-
- Comparator<String[]> country_comperator = new Comparator<String[]>() {
- public int compare(String[] object1, String[] object2) {
- return object1[1].compareTo(object2[1]);
- }
- };
-
- Arrays.sort(all_countries, country_comperator);
-
- AlertDialog.Builder mapModeChooser = new AlertDialog.Builder(this);
- // ToDo also show icons and country code
- String[] country_name = new String[all_countries.length];
-
- for (int country_index = 0; country_index < all_countries.length; country_index++) {
- country_name[country_index] = all_countries[country_index][1];
- }
-
- mapModeChooser.setItems(country_name, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- SharedPreferences settings = getSharedPreferences(Navit.NAVIT_PREFS, MODE_PRIVATE);
- mCountry = all_countries[item][0];
- SharedPreferences.Editor edit_settings = settings.edit();
- edit_settings.putString("DefaultCountry", mCountry);
- edit_settings.commit();
-
- setCountryButtonImage();
- }
- });
-
- AlertDialog d=mapModeChooser.create();
- d.getListView().setFastScrollEnabled(true);
- d.show();
- }
-
- /**
- * start a search on the map
- */
- public void receiveAddress(int type, float latitude, float longitude, String address) {
- Log.e(TAG, "(" + String.valueOf(latitude) + ", " + String.valueOf(longitude) + ") " + address);
-
- switch (type) {
- case 0:
- search_results_towns++;
- break;
- case 1:
- search_results_streets++;
- break;
- case 2:
- search_results_streets_hn++;
- break;
-
- }
- search_results_wait.setMessage(Navit.T("Towns") + ":" + search_results_towns + " "
- + Navit.T("Streets") + ":" + search_results_streets + "/"
- + search_results_streets_hn);
-
- search_results_wait.setProgress(Addresses_found.size() % (ADDRESS_RESULT_PROGRESS_MAX + 1));
-
- Addresses_found.add(new NavitAddress(type, latitude, longitude, address));
- }
-
- public void finishAddressSearch() {
- if (Addresses_found.isEmpty()) {
- Toast.makeText( getApplicationContext(),getString(R.string.address_search_not_found) + "\n" + mAddressString, Toast.LENGTH_LONG).show(); //TRANS
- setResult(Activity.RESULT_CANCELED);
- finish();
- }
- ListView addressesFound = new ListView(this);
- addressesFound.setFastScrollEnabled(true);
- ArrayAdapter<String> addressList =
- new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
-
- addresses_shown = new ArrayList<NavitAddress>();
-
- for (NavitAddress currentAddress : Addresses_found) {
- if (currentAddress.result_type != 0 || search_results_streets == 0) {
- addressList.add(currentAddress.addr);
- addresses_shown.add(currentAddress);
- }
- }
-
- addressesFound.setAdapter(addressList);
-
- addressesFound.setOnItemClickListener(new OnItemClickListener() {
- public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
- NavitAddress addressSelected = addresses_shown.get(arg2);
- Intent resultIntent = new Intent();
-
- resultIntent.putExtra("lat", addressSelected.lat);
- resultIntent.putExtra("lon", addressSelected.lon);
- resultIntent.putExtra("q", addressSelected.addr);
-
- setResult(Activity.RESULT_OK, resultIntent);
- finish();
- }
- });
-
- setContentView(addressesFound);
- search_results_wait.dismiss();
- }
-
- public native long CallbackStartAddressSearch(int partial_match, String country, String s);
- public native void CallbackCancelAddressSearch(long handle);
-
- @Override
- protected Dialog onCreateDialog(int id) {
- search_results_wait = new ProgressDialog(this);
- search_results_wait.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- search_results_wait.setTitle("Loading search results");
- search_results_wait.setMessage("--");
- search_results_wait.setCancelable(true);
- search_results_wait.setProgress(0);
- search_results_wait.setMax(10);
-
- Addresses_found = new ArrayList<NavitAddress>();
- search_results_towns = 0;
- search_results_streets = 0;
- search_results_streets_hn = 0;
-
- search_handle = CallbackStartAddressSearch(mPartialSearch ? 1 : 0, mCountry, mAddressString);
-
- search_results_wait.setOnCancelListener(new DialogInterface.OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- CallbackCancelAddressSearch(search_handle);
- search_handle = 0;
- search_results_wait.dismiss();
- }
- });
- return search_results_wait;
- }
-
- void executeSearch() {
- showDialog(0);
- }
-}
-
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+package org.navitproject.navit;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.WindowManager;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.RelativeLayout;
+import android.widget.RelativeLayout.LayoutParams;
+import android.widget.TextView;
+import android.widget.Toast;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+
+public class NavitAddressSearchActivity extends Activity {
+ public static final class NavitAddress {
+ public NavitAddress(int type, float latitude, float longitude, String address) {
+ result_type = type;
+ lat = latitude;
+ lon = longitude;
+ addr = address;
+ }
+
+ final int result_type;
+ final float lat;
+ final float lon;
+ final String addr;
+ }
+
+ private static final String TAG = "NavitAddress";
+ private static final int ADDRESS_RESULT_PROGRESS_MAX = 10;
+
+ private List<NavitAddress> Addresses_found = null;
+ private List<NavitAddress> addresses_shown = null;
+ private String mAddressString = "";
+ private boolean mPartialSearch = false;
+ private String mCountry;
+ private ImageButton mCountryButton;
+ private ProgressDialog search_results_wait = null;
+ public RelativeLayout NavitAddressSearchActivity_layout;
+ private int search_results_towns = 0;
+ private int search_results_streets = 0;
+ private int search_results_streets_hn = 0;
+ private long search_handle = 0;
+
+ // TODO remember settings
+ private static String last_address_search_string = "";
+ private static Boolean last_address_partial_match = false;
+ private static String last_country = "";
+
+ private int getDrawableID(String resourceName) {
+ int drawableId = 0;
+ try {
+ Class<?> res = R.drawable.class;
+ Field field = res.getField(resourceName);
+ drawableId = field.getInt(null);
+ } catch (Exception e) {
+ Log.e(TAG, "Failure to get drawable id.", e);
+ }
+ return drawableId;
+ }
+
+ private void setCountryButtonImage() {
+ // We have all images stored as drawable_nodpi resources which allows native code to manipulate them
+ // without interference with android builtin choosing and scaling system. But that makes us to
+ // reinvent the wheel here to show an image in android native interface.
+ int[] flag_icon_sizes = {24,32,48,64,96};
+ int exact_size, nearest_size;
+ exact_size = (int)(Navit.metrics.density * 24.0 - .5);
+ nearest_size = flag_icon_sizes[0];
+ for (int size: flag_icon_sizes) {
+ nearest_size = size;
+ if (exact_size <= size) {
+ break;
+ }
+ }
+ mCountryButton.setImageResource(getDrawableID("country_" + mCountry + "_" + nearest_size + "_" + nearest_size));
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Bundle extras = getIntent().getExtras();
+ if (extras != null) {
+ String search_string = extras.getString(("search_string"));
+ if (search_string != null) {
+ mPartialSearch = true;
+ mAddressString = search_string;
+ executeSearch();
+ return;
+ }
+ }
+
+ mPartialSearch = last_address_partial_match;
+ mAddressString = last_address_search_string;
+
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
+ LinearLayout panel = new LinearLayout(this);
+ panel.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+ panel.setOrientation(LinearLayout.VERTICAL);
+
+ // address: label and text field
+ SharedPreferences settings = getSharedPreferences(Navit.NAVIT_PREFS, MODE_PRIVATE);
+ mCountry = settings.getString(("DefaultCountry"), null);
+
+ if (mCountry == null) {
+ Locale defaultLocale = Locale.getDefault();
+ mCountry = defaultLocale.getCountry().toLowerCase(defaultLocale);
+ SharedPreferences.Editor edit_settings = settings.edit();
+ edit_settings.putString("DefaultCountry", mCountry);
+ edit_settings.apply();
+ }
+
+ mCountryButton = new ImageButton(this);
+
+ setCountryButtonImage();
+
+ mCountryButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ requestCountryDialog();
+ }
+ });
+
+ // address: label and text field
+ TextView addr_view = new TextView(this);
+ addr_view.setText(Navit.getInstance().getTstring(R.string.address_enter_destination)); // TRANS
+ addr_view.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20f);
+ addr_view.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+ addr_view.setPadding(4, 4, 4, 4);
+
+ // partial match checkbox
+ final CheckBox checkboxPartialMatch = new CheckBox(this);
+ checkboxPartialMatch.setText(Navit.getInstance().getTstring(R.string.address_partial_match)); // TRANS
+ checkboxPartialMatch.setChecked(last_address_partial_match);
+ checkboxPartialMatch.setGravity(Gravity.CENTER);
+
+ final EditText address_string = new EditText(this);
+ address_string.setText(last_address_search_string);
+ address_string.setSelectAllOnFocus(true);
+
+ // search button
+ final Button btnSearch = new Button(this);
+ btnSearch.setText(Navit.getInstance().getTstring(R.string.address_search_button)); // TRANS
+ btnSearch.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
+ btnSearch.setGravity(Gravity.CENTER);
+ btnSearch.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ mPartialSearch = checkboxPartialMatch.isChecked();
+ mAddressString = address_string.getText().toString();
+ last_address_partial_match = mPartialSearch;
+ last_address_search_string = mAddressString;
+ executeSearch();
+ }
+ });
+
+ ListView lastAddresses = new ListView(this);
+ NavitAppConfig navitConfig = (NavitAppConfig) getApplicationContext();
+
+ final List<NavitAddress> addresses = navitConfig.getLastAddresses();
+ int addressCount = addresses.size();
+ if (addressCount > 0) {
+ String[] strAddresses = new String[addressCount];
+ for (int addrIndex = 0; addrIndex < addressCount; addrIndex++) {
+ strAddresses[addrIndex] = addresses.get(addrIndex).addr;
+ }
+ ArrayAdapter<String> addressList =
+ new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, strAddresses);
+ lastAddresses.setAdapter(addressList);
+ lastAddresses.setOnItemClickListener(new OnItemClickListener() {
+ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+ NavitAddress addressSelected = addresses.get(arg2);
+ Intent resultIntent = new Intent();
+
+ resultIntent.putExtra("lat", addressSelected.lat);
+ resultIntent.putExtra("lon", addressSelected.lon);
+ resultIntent.putExtra("q", addressSelected.addr);
+
+ setResult(Activity.RESULT_OK, resultIntent);
+ finish();
+ }
+ });
+ }
+
+ String title = getString(R.string.address_search_title);
+ this.setTitle(title);
+
+ LinearLayout searchSettingsLayout = new LinearLayout(this);
+ searchSettingsLayout.setOrientation(LinearLayout.HORIZONTAL);
+
+ searchSettingsLayout.addView(mCountryButton);
+ searchSettingsLayout.addView(checkboxPartialMatch);
+ panel.addView(addr_view);
+ panel.addView(address_string);
+ panel.addView(searchSettingsLayout);
+ panel.addView(btnSearch);
+ panel.addView(lastAddresses);
+
+ setContentView(panel);
+ }
+
+ private void requestCountryDialog() {
+ final String[][] all_countries = NavitGraphics.GetAllCountries();
+
+ Comparator<String[]> country_comperator = new Comparator<String[]>() {
+ public int compare(String[] object1, String[] object2) {
+ return object1[1].compareTo(object2[1]);
+ }
+ };
+
+ Arrays.sort(all_countries, country_comperator);
+
+ AlertDialog.Builder mapModeChooser = new AlertDialog.Builder(this);
+ // ToDo also show icons and country code
+ String[] country_name = new String[all_countries.length];
+
+ for (int country_index = 0; country_index < all_countries.length; country_index++) {
+ country_name[country_index] = all_countries[country_index][1];
+ }
+
+ mapModeChooser.setItems(country_name, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int item) {
+ SharedPreferences settings = getSharedPreferences(Navit.NAVIT_PREFS, MODE_PRIVATE);
+ mCountry = all_countries[item][0];
+ SharedPreferences.Editor edit_settings = settings.edit();
+ edit_settings.putString("DefaultCountry", mCountry);
+ edit_settings.apply();
+
+ setCountryButtonImage();
+ }
+ });
+
+ AlertDialog d = mapModeChooser.create();
+ d.getListView().setFastScrollEnabled(true);
+ d.show();
+ }
+
+ /**
+ * start a search on the map
+ */
+ public void receiveAddress(int type, float latitude, float longitude, String address) {
+ Log.e(TAG, "(" + String.valueOf(latitude) + ", " + String.valueOf(longitude) + ") " + address);
+
+ switch (type) {
+ case 0:
+ search_results_towns++;
+ break;
+ case 1:
+ search_results_streets++;
+ break;
+ case 2:
+ search_results_streets_hn++;
+ break;
+
+ }
+ search_results_wait.setMessage(Navit.getInstance().getTstring(R.string.address_search_towns) + ":"
+ + search_results_towns + " "
+ + Navit.getInstance().getTstring(R.string.address_search_streets) + ":" + search_results_streets + "/"
+ + search_results_streets_hn);
+
+ search_results_wait.setProgress(Addresses_found.size() % (ADDRESS_RESULT_PROGRESS_MAX + 1));
+
+ Addresses_found.add(new NavitAddress(type, latitude, longitude, address));
+ }
+
+ public void finishAddressSearch() {
+ if (Addresses_found.isEmpty()) {
+ // TRANS
+ Toast.makeText(getApplicationContext(),
+ getString(R.string.address_search_not_found) + "\n" + mAddressString, Toast.LENGTH_LONG).show();
+ setResult(Activity.RESULT_CANCELED);
+ finish();
+ }
+ ListView addressesFound = new ListView(this);
+ addressesFound.setFastScrollEnabled(true);
+ ArrayAdapter<String> addressList =
+ new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
+
+ addresses_shown = new ArrayList<NavitAddress>();
+
+ for (NavitAddress currentAddress : Addresses_found) {
+ if (currentAddress.result_type != 0 || search_results_streets == 0) {
+ addressList.add(currentAddress.addr);
+ addresses_shown.add(currentAddress);
+ }
+ }
+
+ addressesFound.setAdapter(addressList);
+
+ addressesFound.setOnItemClickListener(new OnItemClickListener() {
+ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+ NavitAddress addressSelected = addresses_shown.get(arg2);
+ Intent resultIntent = new Intent();
+
+ resultIntent.putExtra("lat", addressSelected.lat);
+ resultIntent.putExtra("lon", addressSelected.lon);
+ resultIntent.putExtra("q", addressSelected.addr);
+
+ setResult(Activity.RESULT_OK, resultIntent);
+ finish();
+ }
+ });
+
+ setContentView(addressesFound);
+ search_results_wait.dismiss();
+ }
+
+ public native long CallbackStartAddressSearch(int partial_match, String country, String s);
+
+ public native void CallbackCancelAddressSearch(long handle);
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ search_results_wait = new ProgressDialog(this);
+ search_results_wait.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ search_results_wait.setTitle("Loading search results");
+ search_results_wait.setMessage("--");
+ search_results_wait.setCancelable(true);
+ search_results_wait.setProgress(0);
+ search_results_wait.setMax(10);
+
+ Addresses_found = new ArrayList<NavitAddress>();
+ search_results_towns = 0;
+ search_results_streets = 0;
+ search_results_streets_hn = 0;
+
+ search_handle = CallbackStartAddressSearch(mPartialSearch ? 1 : 0, mCountry, mAddressString);
+
+ search_results_wait.setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ CallbackCancelAddressSearch(search_handle);
+ search_handle = 0;
+ search_results_wait.dismiss();
+ }
+ });
+ return search_results_wait;
+ }
+
+ private void executeSearch() {
+ showDialog(0);
+ }
+}
+
diff --git a/navit/android/src/org/navitproject/navit/NavitAppConfig.java b/navit/android/src/org/navitproject/navit/NavitAppConfig.java
index 13ccc9bb4..22c310f70 100755
--- a/navit/android/src/org/navitproject/navit/NavitAppConfig.java
+++ b/navit/android/src/org/navitproject/navit/NavitAppConfig.java
@@ -1,90 +1,75 @@
-package org.navitproject.navit;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.navitproject.navit.NavitAddressSearchActivity.NavitAddress;
-
-import android.app.Application;
-import android.content.SharedPreferences;
-import android.util.Log;
-import org.acra.*;
-import org.acra.annotation.*;
-
-//@ReportsCrashes(formKey = "dGlrNVRIOVVKYjB0UGVoLUZPanlzWFE6MQ")
-@ReportsCrashes(mailTo = "android@navit-project.org",
- mode = ReportingInteractionMode.TOAST,
- resToastText = R.string.app_name)
-
-public class NavitAppConfig extends Application {
-
- private static final int MAX_LAST_ADDRESSES = 10;
- private static final String TAG = "Navit";
-
- private List<NavitAddress> mLastAddresses = null;
- private int mLastAddressField;
- private SharedPreferences mSettings;
-
- @Override
- public void onCreate() {
- // call ACRA.init(this) as reflection, because old ant may forgot to include it
- try {
- Class<?> acraClass = Class.forName("org.acra.ACRA");
- Class<?> partypes[] = new Class[1];
- partypes[0] = Application.class;
- java.lang.reflect.Method initMethod = acraClass.getMethod("init", partypes);
- Object arglist[] = new Object[1];
- arglist[0] = this;
- initMethod.invoke(null, arglist);
- } catch (Exception e1) {
- Log.e(TAG, "Could not init ACRA crash reporter");
- }
-
- mSettings = getSharedPreferences(Navit.NAVIT_PREFS, MODE_PRIVATE);
- super.onCreate();
- }
-
- public List<NavitAddress> getLastAddresses() {
- if (mLastAddresses == null) {
- mLastAddresses = new ArrayList<NavitAddress>();
- int mLastAddressField = mSettings.getInt("LastAddress", -1);
- if (mLastAddressField >= 0) {
- int index = mLastAddressField;
- do {
- String addr_str = mSettings.getString("LastAddress_" + String.valueOf(index), "");
-
- if (addr_str.length() > 0) {
- mLastAddresses.add(new NavitAddress(
- 1,
- mSettings.getFloat("LastAddress_Lat_" + String.valueOf(index), 0),
- mSettings.getFloat("LastAddress_Lon_" + String.valueOf(index), 0),
- addr_str));
- }
-
- if (--index < 0) index = MAX_LAST_ADDRESSES - 1;
-
- } while (index != mLastAddressField);
- }
- }
- return mLastAddresses;
- }
-
- public void addLastAddress(NavitAddress newAddress) {
- getLastAddresses();
-
- mLastAddresses.add(newAddress);
- if (mLastAddresses.size() > MAX_LAST_ADDRESSES) mLastAddresses.remove(0);
-
- mLastAddressField++;
- if (mLastAddressField >= MAX_LAST_ADDRESSES) mLastAddressField = 0;
-
- SharedPreferences.Editor editSettings = mSettings.edit();
-
- editSettings.putInt("LastAddress", mLastAddressField);
- editSettings.putString("LastAddress_" + String.valueOf(mLastAddressField), newAddress.addr);
- editSettings.putFloat("LastAddress_Lat_" + String.valueOf(mLastAddressField), newAddress.lat);
- editSettings.putFloat("LastAddress_Lon_" + String.valueOf(mLastAddressField), newAddress.lon);
-
- editSettings.commit();
- }
-}
+package org.navitproject.navit;
+
+import android.app.Application;
+import android.content.SharedPreferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.navitproject.navit.NavitAddressSearchActivity.NavitAddress;
+
+public class NavitAppConfig extends Application {
+
+ private static final int MAX_LAST_ADDRESSES = 10;
+ private static final String TAG = "Navit";
+
+ private List<NavitAddress> mLastAddresses = null;
+ private int mLastAddressField;
+ private SharedPreferences mSettings;
+
+ @Override
+ public void onCreate() {
+ mSettings = getSharedPreferences(Navit.NAVIT_PREFS, MODE_PRIVATE);
+ super.onCreate();
+ }
+
+ public List<NavitAddress> getLastAddresses() {
+ if (mLastAddresses == null) {
+ mLastAddresses = new ArrayList<NavitAddress>();
+ int mLastAddressField = mSettings.getInt("LastAddress", -1);
+ if (mLastAddressField >= 0) {
+ int index = mLastAddressField;
+ do {
+ String addr_str = mSettings.getString("LastAddress_" + String.valueOf(index), "");
+
+ if (addr_str.length() > 0) {
+ mLastAddresses.add(new NavitAddress(
+ 1,
+ mSettings.getFloat("LastAddress_Lat_" + String.valueOf(index), 0),
+ mSettings.getFloat("LastAddress_Lon_" + String.valueOf(index), 0),
+ addr_str));
+ }
+
+ if (--index < 0) {
+ index = MAX_LAST_ADDRESSES - 1;
+ }
+
+ } while (index != mLastAddressField);
+ }
+ }
+ return mLastAddresses;
+ }
+
+ public void addLastAddress(NavitAddress newAddress) {
+ getLastAddresses();
+
+ mLastAddresses.add(newAddress);
+ if (mLastAddresses.size() > MAX_LAST_ADDRESSES) {
+ mLastAddresses.remove(0);
+ }
+
+ mLastAddressField++;
+ if (mLastAddressField >= MAX_LAST_ADDRESSES) {
+ mLastAddressField = 0;
+ }
+
+ SharedPreferences.Editor editSettings = mSettings.edit();
+
+ editSettings.putInt("LastAddress", mLastAddressField);
+ editSettings.putString("LastAddress_" + String.valueOf(mLastAddressField), newAddress.addr);
+ editSettings.putFloat("LastAddress_Lat_" + String.valueOf(mLastAddressField), newAddress.lat);
+ editSettings.putFloat("LastAddress_Lon_" + String.valueOf(mLastAddressField), newAddress.lon);
+
+ editSettings.apply();
+ }
+}
diff --git a/navit/android/src/org/navitproject/navit/NavitBackupTask.java b/navit/android/src/org/navitproject/navit/NavitBackupTask.java
index ca52ee46e..c3fbe0517 100644
--- a/navit/android/src/org/navitproject/navit/NavitBackupTask.java
+++ b/navit/android/src/org/navitproject/navit/NavitBackupTask.java
@@ -1,7 +1,5 @@
-
package org.navitproject.navit;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
@@ -9,7 +7,6 @@ import android.os.Environment;
import android.text.format.Time;
import android.widget.Toast;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
@@ -31,7 +28,7 @@ public class NavitBackupTask extends AsyncTask<Void, Void, String> {
/* Create a Wait Progress Dialog to inform the User that we are working */
mDialog = new ProgressDialog(mActivity);
mDialog.setIndeterminate(true);
- mDialog.setMessage(mActivity.getString(R.string.backing_up));
+ mDialog.setMessage(mActivity.getTstring(R.string.backing_up));
mDialog.show();
}
@@ -41,60 +38,70 @@ public class NavitBackupTask extends AsyncTask<Void, Void, String> {
now.setToNow();
/* This is the Directory where all Subdirectories are stored by date */
- File mainBackupDir = new File(Environment.getExternalStorageDirectory().getPath() + "/navit/backup/");
+ File mainBackupDir = new File(
+ Environment.getExternalStorageDirectory().getPath() + "/navit/backup/");
/* Create the Main Backup Directory if it doesn't exist */
if (!mainBackupDir.isDirectory()) {
- if (!mainBackupDir.mkdirs())
- return mActivity.getString(R.string.failed_to_create_backup_directory);
+ if (!mainBackupDir.mkdirs()) {
+ return mActivity.getTstring(R.string.failed_to_create_backup_directory);
+ }
}
/* Create a Timestamp in the format YYYY-MM-DD-Index */
- String timestamp = now.year + "-" + String.format("%02d", now.month+1) + "-" + String.format("%02d", now.monthDay);
+ String timestamp = now.year + "-" + String.format("%02d", now.month + 1) + "-" + String
+ .format("%02d", now.monthDay);
/* Get the next free index */
int index = 1;
for (String s : mainBackupDir.list()) {
if (s.contains(timestamp)) {
int newIndex = Integer.parseInt(s.substring(11));
- if (newIndex >= index)
+ if (newIndex >= index) {
index = newIndex + 1;
+ }
}
}
timestamp += "-" + index;
/* This is the Directory in which the Files are copied into */
- File backupDir = new File(Environment.getExternalStorageDirectory().getPath() + "/navit/backup/" + timestamp);
+ File backupDir = new File(
+ Environment.getExternalStorageDirectory().getPath() + "/navit/backup/" + timestamp);
/* Create the Backup Directory if it doesn't exist */
if (!backupDir.isDirectory()) {
- if (!backupDir.mkdirs())
- return mActivity.getString(R.string.failed_to_create_backup_directory);
+ if (!backupDir.mkdirs()) {
+ return mActivity.getTstring(R.string.failed_to_create_backup_directory);
+ }
}
ObjectOutputStream preferencesOOs = null;
try {
/* Backup Files in home */
- mActivity.copyFileIfExists(Navit.NAVIT_DATA_DIR + "/home/bookmark.txt", backupDir.getPath() + "/bookmark.txt");
- mActivity.copyFileIfExists(Navit.NAVIT_DATA_DIR + "/home/destination.txt", backupDir.getPath() + "/destination.txt");
- mActivity.copyFileIfExists(Navit.NAVIT_DATA_DIR + "/home/gui_internal.txt", backupDir.getPath() + "/gui_internal.txt");
+ mActivity.copyFileIfExists(Navit.NAVIT_DATA_DIR + "/home/bookmark.txt",
+ backupDir.getPath() + "/bookmark.txt");
+ mActivity.copyFileIfExists(Navit.NAVIT_DATA_DIR + "/home/destination.txt",
+ backupDir.getPath() + "/destination.txt");
+ mActivity.copyFileIfExists(Navit.NAVIT_DATA_DIR + "/home/gui_internal.txt",
+ backupDir.getPath() + "/gui_internal.txt");
/* Backup Shared Preferences */
- preferencesOOs = new ObjectOutputStream(new FileOutputStream(backupDir.getPath() + "/preferences.bak"));
- preferencesOOs.writeObject(mActivity.getSharedPreferences(Navit.NAVIT_PREFS, Context.MODE_PRIVATE).getAll());
- }
- catch (IOException e) {
+ preferencesOOs = new ObjectOutputStream(
+ new FileOutputStream(backupDir.getPath() + "/preferences.bak"));
+ preferencesOOs.writeObject(
+ mActivity.getSharedPreferences(Navit.NAVIT_PREFS, Context.MODE_PRIVATE)
+ .getAll());
+ } catch (IOException e) {
e.printStackTrace();
- return mActivity.getString(R.string.backup_failed);
- }
- finally {
+ return mActivity.getTstring(R.string.backup_failed);
+ } finally {
/* Close Stream to prevent Resource Leaks */
try {
- if (preferencesOOs != null)
+ if (preferencesOOs != null) {
preferencesOOs.close();
- }
- catch (IOException e) {
+ }
+ } catch (IOException e) {
e.printStackTrace();
- return mActivity.getString(R.string.backup_failed);
+ return mActivity.getTstring(R.string.backup_failed);
}
}
@@ -114,13 +121,15 @@ public class NavitBackupTask extends AsyncTask<Void, Void, String> {
return;
}
- Toast.makeText(mActivity, mActivity.getString(R.string.backup_successful), Toast.LENGTH_LONG).show();
+ Toast.makeText(mActivity, mActivity.getTstring(R.string.backup_successful),
+ Toast.LENGTH_LONG).show();
}
@Override
protected void onCancelled() {
super.onCancelled();
- Toast.makeText(mActivity, mActivity.getString(R.string.backup_failed), Toast.LENGTH_LONG).show();
+ Toast.makeText(mActivity, mActivity.getTstring(R.string.backup_failed), Toast.LENGTH_LONG)
+ .show();
mDialog.dismiss();
}
}
diff --git a/navit/android/src/org/navitproject/navit/NavitCamera.java b/navit/android/src/org/navitproject/navit/NavitCamera.java
index bd78b36b2..709686b97 100644
--- a/navit/android/src/org/navitproject/navit/NavitCamera.java
+++ b/navit/android/src/org/navitproject/navit/NavitCamera.java
@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.navitproject.navit;
-import java.io.IOException;
+package org.navitproject.navit;
import android.content.Context;
import android.hardware.Camera;
@@ -23,39 +22,40 @@ import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import java.io.IOException;
+
public class NavitCamera extends SurfaceView implements SurfaceHolder.Callback {
- SurfaceHolder mHolder;
- Camera mCamera;
+ SurfaceHolder mHolder;
+ Camera mCamera;
- NavitCamera(Context context)
- {
- super(context);
- mHolder = getHolder();
+ NavitCamera(Context context) {
+ super(context);
+ mHolder = getHolder();
mHolder.addCallback(this);
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- Log.e("NavitCamera","Creator");
+ Log.e("NavitCamera","Creator");
+
-
- }
+ }
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, acquire the camera and tell it where
// to draw.
try {
- mCamera = Camera.open();
- mCamera.setPreviewDisplay(holder);
+ mCamera = Camera.open();
+ mCamera.setPreviewDisplay(holder);
} catch (IOException exception) {
mCamera.release();
mCamera = null;
// TODO: add more exception handling logic here
}
- Log.e("NavitCamera","surfaceCreated");
+ Log.e("NavitCamera","surfaceCreated");
}
public void surfaceDestroyed(SurfaceHolder holder) {
@@ -64,13 +64,13 @@ public class NavitCamera extends SurfaceView implements SurfaceHolder.Callback {
// important to release it when the activity is paused.
mCamera.stopPreview();
mCamera = null;
- Log.e("NavitCamera","surfaceDestroyed");
+ Log.e("NavitCamera","surfaceDestroyed");
}
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
// Now that the size is known, set up the camera parameters and begin
// the preview.
- Log.e("NavitCamera","surfaceChanged "+w+"x"+h);
+ Log.e("NavitCamera","surfaceChanged " + w + "x" + h);
mCamera.stopPreview();
Camera.Parameters parameters = mCamera.getParameters();
parameters.setPreviewSize(w, h);
diff --git a/navit/android/src/org/navitproject/navit/NavitDialogs.java b/navit/android/src/org/navitproject/navit/NavitDialogs.java
index 10f30d5b3..41cac61da 100644
--- a/navit/android/src/org/navitproject/navit/NavitDialogs.java
+++ b/navit/android/src/org/navitproject/navit/NavitDialogs.java
@@ -1,218 +1,216 @@
package org.navitproject.navit;
-
-import java.io.File;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Toast;
-import android.os.Environment;
+import java.io.File;
+
+public class NavitDialogs extends Handler {
+
+ // Dialogs
+ public static final int DIALOG_MAPDOWNLOAD = 1;
+ public static final int DIALOG_BACKUP_RESTORE = 2;
+ // dialog messages
+ static final int MSG_MAP_DOWNLOAD_FINISHED = 0;
+ static final int MSG_PROGRESS_BAR = 1;
+ static final int MSG_TOAST = 2;
+ static final int MSG_TOAST_LONG = 3;
+ static final int MSG_START_MAP_DOWNLOAD = 7;
+ private static final int DIALOG_SELECT_BACKUP = 3;
+ private static final int MSG_REMOVE_DIALOG_GENERIC = 99;
+ private static Handler mHandler;
+ private final String TAG = this.getClass().getName();
+ private ProgressDialog mapdownloader_dialog = null;
+ private NavitMapDownloader mapdownloader = null;
+ private Navit mActivity;
+
+ NavitDialogs(Navit activity) {
+ super();
+ mActivity = activity;
+ mHandler = this;
+ }
+
+ static public void sendDialogMessage(int what, String title, String text, int dialog_num,
+ int value1, int value2) {
+ Message msg = mHandler.obtainMessage(what);
+ Bundle data = new Bundle();
+ data.putString("title", title);
+ data.putString("text", text);
+ data.putInt("value1", value1);
+ data.putInt("value2", value2);
+ data.putInt("dialog_num", dialog_num);
+ msg.setData(data);
+
+ mHandler.sendMessage(msg);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_MAP_DOWNLOAD_FINISHED: {
+ // dismiss dialog, remove dialog
+ mActivity.dismissDialog(DIALOG_MAPDOWNLOAD);
+ mActivity.removeDialog(DIALOG_MAPDOWNLOAD);
+ if (msg.getData().getInt("value1") == 1) {
+ Message msg_out = Message.obtain(Navit.getInstance().getNavitGraphics().callback_handler,
+ NavitGraphics.msg_type.CLB_LOAD_MAP.ordinal());
+ msg_out.setData(msg.getData());
+ msg_out.sendToTarget();
-public class NavitDialogs extends Handler{
- // Dialogs
- public static final int DIALOG_MAPDOWNLOAD = 1;
- public static final int DIALOG_BACKUP_RESTORE = 2;
- public static final int DIALOG_SELECT_BACKUP = 3;
-
- // dialog messages
- static final int MSG_MAP_DOWNLOAD_FINISHED = 0;
- static final int MSG_PROGRESS_BAR = 1;
- static final int MSG_TOAST = 2;
- static final int MSG_TOAST_LONG = 3;
- static final int MSG_POSITION_MENU = 6;
- static final int MSG_START_MAP_DOWNLOAD = 7;
- static final int MSG_REMOVE_DIALOG_GENERIC = 99;
- static Handler mHandler;
-
- private ProgressDialog mapdownloader_dialog = null;
- private NavitMapDownloader mapdownloader = null;
-
- private Navit mActivity;
-
- public NavitDialogs(Navit activity) {
- super();
- mActivity = activity;
- mHandler = this;
- }
-
- static public void sendDialogMessage(int what, String title, String text, int dialog_num, int value1, int value2)
- {
- Message msg = mHandler.obtainMessage(what);
- Bundle data = new Bundle();
-
- data.putString("title", title);
- data.putString("text", text);
- data.putInt("value1", value1);
- data.putInt("value2", value2);
- data.putInt("dialog_num", dialog_num);
- msg.setData(data);
-
- mHandler.sendMessage(msg);
- }
-
- @Override
- public void handleMessage(Message msg)
- {
- switch (msg.what)
- {
- case MSG_MAP_DOWNLOAD_FINISHED :
- {
- // dismiss dialog, remove dialog
- mActivity.dismissDialog(DIALOG_MAPDOWNLOAD);
- mActivity.removeDialog(DIALOG_MAPDOWNLOAD);
- if (msg.getData().getInt("value1") == 1) {
- Message msg_out =
- Message.obtain(Navit.N_NavitGraphics.callback_handler,
- NavitGraphics.msg_type.CLB_LOAD_MAP.ordinal());
- msg_out.setData(msg.getData());
- msg_out.sendToTarget();
-
- msg_out = Message.obtain(Navit.N_NavitGraphics.callback_handler,
- NavitGraphics.msg_type.CLB_CALL_CMD.ordinal());
- Bundle b = new Bundle();
- int mi=msg.getData().getInt("value2");
- double lon=(Double.parseDouble(NavitMapDownloader.osm_maps[mi].lon1)+Double.parseDouble(NavitMapDownloader.osm_maps[mi].lon2))/2.0;
- double lat=(Double.parseDouble(NavitMapDownloader.osm_maps[mi].lat1)+Double.parseDouble(NavitMapDownloader.osm_maps[mi].lat2))/2.0;
- b.putString("cmd", "set_center(\""+ lon +" "+ lat + "\",1); zoom=256");
- msg_out.setData(b);
- msg_out.sendToTarget();
- }
- break;
- }
- case MSG_PROGRESS_BAR :
- // change progressbar values
- mapdownloader_dialog.setMax(msg.getData().getInt("value1"));
- mapdownloader_dialog.setProgress(msg.getData().getInt("value2"));
- mapdownloader_dialog.setTitle(msg.getData().getString(("title")));
- mapdownloader_dialog.setMessage(msg.getData().getString(("text")));
- break;
- case MSG_TOAST :
- Toast.makeText(mActivity, msg.getData().getString(("text")), Toast.LENGTH_SHORT).show();
- break;
- case MSG_TOAST_LONG :
- Toast.makeText(mActivity, msg.getData().getString(("text")), Toast.LENGTH_LONG).show();
- break;
- case MSG_START_MAP_DOWNLOAD:
- {
- int download_map_id = msg.arg1;
- Log.d("Navit", "PRI id=" + download_map_id);
- // set map id to download
-
- // show the map download progressbar, and download the map
- if (download_map_id > -1)
- {
- mapdownloader = new NavitMapDownloader(download_map_id);
- mActivity.showDialog(NavitDialogs.DIALOG_MAPDOWNLOAD);
- mapdownloader.start();
- }
- }
- break;
- case MSG_REMOVE_DIALOG_GENERIC :
- // dismiss dialog, remove dialog - generic
- mActivity.dismissDialog(msg.getData().getInt("dialog_num"));
- mActivity.removeDialog(msg.getData().getInt("dialog_num"));
- break;
- }
- }
-
- Dialog createDialog(int id)
- {
- AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
-
- switch (id)
- {
- case DIALOG_MAPDOWNLOAD :
- mapdownloader_dialog = new ProgressDialog(mActivity);
- mapdownloader_dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
- mapdownloader_dialog.setTitle("--");
- mapdownloader_dialog.setMessage("--");
- mapdownloader_dialog.setCancelable(true);
- mapdownloader_dialog.setProgress(0);
- mapdownloader_dialog.setMax(200);
- DialogInterface.OnDismissListener onDismissListener = new DialogInterface.OnDismissListener()
- {
- public void onDismiss(DialogInterface dialog)
- {
- Log.e("Navit", "onDismiss: mapdownloader_dialog");
- if(mapdownloader!=null)
- mapdownloader.stop_thread();
- }
- };
- mapdownloader_dialog.setOnDismissListener(onDismissListener);
- // show license for OSM maps
- Toast.makeText(mActivity.getApplicationContext(),
- Navit.T("Map data (c) OpenStreetMap contributors, ODBL"),
- Toast.LENGTH_LONG).show(); //TRANS
- return mapdownloader_dialog;
-
- case DIALOG_BACKUP_RESTORE :
- /* Create a Dialog that Displays Options wether to Backup or Restore */
- builder.setTitle(mActivity.getString(R.string.choose_an_action)).
- setCancelable(true).
- setItems(R.array.dialog_backup_restore_items,
- new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- /* Notify User if no SD Card present */
- if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
- Toast.makeText(mActivity,mActivity.getString(R.string.please_insert_an_sd_card), Toast.LENGTH_LONG).show();
-
- switch (which) {
- case 0:
- /* Backup */
- new NavitBackupTask(mActivity).execute();
- break;
- case 1:
- /* Restore */
- mActivity.showDialog(DIALOG_SELECT_BACKUP);
- break;
- }
- }});
- return builder.create();
-
- case DIALOG_SELECT_BACKUP :
- /* Create a Dialog with a list from which the user selects the Backup to be restored */
- File mainBackupDir = new File(Environment.getExternalStorageDirectory().getPath() + "/navit/backup/");
-
- String[] backups = null;
- if(mainBackupDir.isDirectory())
- backups = mainBackupDir.list();
-
- if(backups == null || backups.length == 0) {
- /* No Backups were found */
- builder.setTitle(mActivity.getText(R.string.no_backup_found));
- builder.setNegativeButton(mActivity.getText(android.R.string.cancel), null);
- return builder.create();
- }
-
- builder.setTitle(mActivity.getString(R.string.select_backup));
- final ArrayAdapter<String> adapter = new ArrayAdapter<String>(mActivity, android.R.layout.simple_spinner_item, backups);
- builder.setAdapter(adapter, new OnClickListener(){
+ msg_out = Message
+ .obtain(Navit.getInstance().getNavitGraphics().callback_handler,
+ NavitGraphics.msg_type.CLB_CALL_CMD.ordinal());
+ Bundle b = new Bundle();
+ int mi = msg.getData().getInt("value2");
+ double lon = (Double.parseDouble(NavitMapDownloader.osm_maps[mi].lon1) + Double
+ .parseDouble(NavitMapDownloader.osm_maps[mi].lon2)) / 2.0;
+ double lat = (Double.parseDouble(NavitMapDownloader.osm_maps[mi].lat1) + Double
+ .parseDouble(NavitMapDownloader.osm_maps[mi].lat2)) / 2.0;
+ b.putString("cmd", "set_center(\"" + lon + " " + lat + "\",1); zoom=256");
+ msg_out.setData(b);
+ msg_out.sendToTarget();
+ }
+ break;
+ }
+ case MSG_PROGRESS_BAR:
+ // change progressbar values
+ mapdownloader_dialog.setMax(msg.getData().getInt("value1"));
+ mapdownloader_dialog.setProgress(msg.getData().getInt("value2"));
+ mapdownloader_dialog.setTitle(msg.getData().getString(("title")));
+ mapdownloader_dialog.setMessage(msg.getData().getString(("text")));
+ break;
+ case MSG_TOAST:
+ Toast.makeText(mActivity, msg.getData().getString(("text")), Toast.LENGTH_SHORT).show();
+ break;
+ case MSG_TOAST_LONG:
+ Toast.makeText(mActivity, msg.getData().getString(("text")), Toast.LENGTH_LONG).show();
+ break;
+ case MSG_START_MAP_DOWNLOAD: {
+ int download_map_id = msg.arg1;
+ Log.d(TAG, "PRI id=" + download_map_id);
+ // set map id to download
+ // show the map download progressbar, and download the map
+ if (download_map_id > -1) {
+ mapdownloader = new NavitMapDownloader(download_map_id);
+ mActivity.showDialog(NavitDialogs.DIALOG_MAPDOWNLOAD);
+ mapdownloader.start();
+ }
+ }
+ break;
+ case MSG_REMOVE_DIALOG_GENERIC:
+ // dismiss dialog, remove dialog - generic
+ mActivity.dismissDialog(msg.getData().getInt("dialog_num"));
+ mActivity.removeDialog(msg.getData().getInt("dialog_num"));
+ break;
+ }
+ }
+
+ Dialog createDialog(int id) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
+
+ switch (id) {
+ case DIALOG_MAPDOWNLOAD:
+ mapdownloader_dialog = new ProgressDialog(mActivity);
+ mapdownloader_dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ mapdownloader_dialog.setTitle("--");
+ mapdownloader_dialog.setMessage("--");
+ mapdownloader_dialog.setCancelable(true);
+ mapdownloader_dialog.setProgress(0);
+ mapdownloader_dialog.setMax(200);
+ DialogInterface.OnDismissListener onDismissListener = new DialogInterface.OnDismissListener() {
+ public void onDismiss(DialogInterface dialog) {
+ Log.e(TAG, "onDismiss: mapdownloader_dialog");
+ if (mapdownloader != null) {
+ mapdownloader.stop_thread();
+ }
+ }
+ };
+ mapdownloader_dialog.setOnDismissListener(onDismissListener);
+ // show license for OSM maps
+ Toast.makeText(mActivity.getApplicationContext(),
+ Navit.getInstance().getString(R.string.osm_copyright),
+ Toast.LENGTH_LONG).show();
+ return mapdownloader_dialog;
+
+ case DIALOG_BACKUP_RESTORE:
+ /* Create a Dialog that Displays Options wether to Backup or Restore */
+ builder.setTitle(mActivity.getTstring(R.string.choose_an_action)).
+ setCancelable(true).
+ setItems(R.array.dialog_backup_restore_items,
+ new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ /* Notify User if no SD Card present */
+ if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+ Toast.makeText(mActivity, mActivity
+ .getTstring(R.string.please_insert_an_sd_card),
+ Toast.LENGTH_LONG).show();
+ }
+
+ switch (which) {
+ case 0:
+ /* Backup */
+ new NavitBackupTask(mActivity).execute();
+ break;
+ case 1:
+ /* Restore */
+ mActivity.showDialog(DIALOG_SELECT_BACKUP);
+ break;
+ }
+ }
+ });
+ return builder.create();
+
+ case DIALOG_SELECT_BACKUP:
+ /* Create a Dialog with a list from which the user selects the Backup to be restored */
+ File mainBackupDir = new File(
+ Environment.getExternalStorageDirectory().getPath() + "/navit/backup/");
+
+ String[] backups = null;
+ if (mainBackupDir.isDirectory()) {
+ backups = mainBackupDir.list();
+ }
+
+ if (backups == null || backups.length == 0) {
+ /* No Backups were found */
+ builder.setTitle(mActivity.getTstring(R.string.no_backup_found));
+ builder.setNegativeButton(mActivity.getTstring(android.R.string.cancel), null);
+ return builder.create();
+ }
+
+ builder.setTitle(mActivity.getTstring(R.string.select_backup));
+ final ArrayAdapter<String> adapter = new ArrayAdapter<String>(mActivity,
+ android.R.layout.simple_spinner_item, backups);
+ builder.setAdapter(adapter, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new NavitRestoreTask(mActivity, adapter.getItem(which)).execute();
- }});
- builder.setNegativeButton(mActivity.getString(android.R.string.cancel), null);
+ }
+ });
+ builder.setNegativeButton(mActivity.getTstring(android.R.string.cancel), null);
return builder.create();
- }
- // should never get here!!
- return null;
- }
+ }
+ // should never get here!!
+ return null;
+ }
+
+ public void prepareDialog(int id) {
- public void prepareDialog(int id, Dialog dialog) {
-
/* Remove the Dialog to force Android to rerun onCreateDialog */
- if(id == DIALOG_SELECT_BACKUP)
+ if (id == DIALOG_SELECT_BACKUP) {
mActivity.removeDialog(id);
+ }
}
}
diff --git a/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java b/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java
index 9cc056e31..bb66a8df7 100644
--- a/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java
+++ b/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java
@@ -1,238 +1,256 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-package org.navitproject.navit;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.ExpandableListActivity;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.location.Location;
-import android.location.LocationManager;
-import android.os.Bundle;
-import android.os.Message;
-import android.os.StatFs;
-import android.util.Log;
-import android.view.View;
-import android.widget.ExpandableListView;
-import android.widget.RelativeLayout;
-import android.widget.SimpleExpandableListAdapter;
-import android.widget.TextView;
-
-public class NavitDownloadSelectMapActivity extends ExpandableListActivity {
-
- private static SimpleExpandableListAdapter adapter = null;
- private static final String MAP_BULLETPOINT = " * ";
- private static ArrayList<HashMap<String, String>> downloaded_maps_childs = null;
- private static ArrayList<HashMap<String, String>> maps_current_position_childs = null;
- private static boolean currentLocationKnown = false;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- if (adapter == null) {
- adapter = createAdapter();
- }
- updateDownloadedMaps();
- updateMapsForLocation(NavitMapDownloader.osm_maps);
- setListAdapter(adapter);
- try {
- setTitle(String.valueOf(getFreeSpace() / 1024 / 1024) + "MB available");
- } catch (Exception e) {
- Log.e("Navit","Exception "+e.getClass().getName()+" during getFreeSpace, reporting 'no sdcard present'");
- NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST_LONG, null,
- String.format(Navit.T("Current map location %s is not available\nPlease restart Navit after you attach an SD card or select a different map location."),Navit.map_filename_path),
- -1, 0, 0);
- finish();
- }
- }
-
- protected long getFreeSpace()
- {
- StatFs fsInfo = new StatFs(Navit.map_filename_path);
- return (long)fsInfo.getAvailableBlocks() * fsInfo.getBlockSize();
- }
-
- private void updateDownloadedMaps() {
- downloaded_maps_childs.clear();
- for (NavitMap map : NavitMapDownloader.getAvailableMaps()) {
- HashMap<String, String> child = new HashMap<String, String>();
- child.put("map_name", map.mapName + " " + (map.size() / 1024 / 1024) + "MB");
- child.put("map_location", map.getLocation());
- downloaded_maps_childs.add(child);
- }
- }
-
- private void updateMapsForLocation(NavitMapDownloader.osm_map_values osm_maps[]) {
- Location currentLocation = NavitVehicle.lastLocation;
- if (maps_current_position_childs.size() == 0 || (currentLocation != null && !currentLocationKnown)) {
- if (currentLocation == null) {
- LocationManager mapLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
- List<String> providers = mapLocationManager.getProviders(true);
- long lastUpdate = 0;
- long bestUpdateTime = -1;
- for (String provider : providers) {
- Location lastKnownLocation = mapLocationManager.getLastKnownLocation(provider);
- if (lastKnownLocation != null) {
- lastUpdate = lastKnownLocation.getTime();
- if (lastUpdate > bestUpdateTime) {
- currentLocation = lastKnownLocation;
- bestUpdateTime = lastUpdate;
- }
- }
- }
- } else currentLocationKnown = true;
-
- if (currentLocation != null) {
- // if this map contains data to our current position, add it to
- // the
- // MapsOfCurrentLocation-list
- for (int currentMapIndex = 0; currentMapIndex < osm_maps.length; currentMapIndex++) {
- if (osm_maps[currentMapIndex].isInMap(currentLocation)) {
- HashMap<String, String> currentPositionMapChild = new HashMap<String, String>();
- currentPositionMapChild.put("map_name", osm_maps[currentMapIndex].map_name + " "
- + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024) + "MB");
- currentPositionMapChild.put("map_index", String.valueOf(currentMapIndex));
-
- maps_current_position_childs.add(currentPositionMapChild);
- }
- }
- }
- }
- }
-
- private SimpleExpandableListAdapter createAdapter() {
-
- NavitMapDownloader.osm_map_values osm_maps[] = NavitMapDownloader.osm_maps;
-
- ArrayList<HashMap<String, String>> resultGroups = new ArrayList<HashMap<String, String>>();
- ArrayList<ArrayList<HashMap<String, String>>> resultChilds =
- new ArrayList<ArrayList<HashMap<String, String>>>();
-
- // add already downloaded maps (group and empty child list
- HashMap<String, String> downloaded_maps_hash = new HashMap<String, String>();
- downloaded_maps_hash.put("category_name", Navit.T("Downloaded maps"));
- resultGroups.add(downloaded_maps_hash);
- downloaded_maps_childs = new ArrayList<HashMap<String, String>>();
- resultChilds.add(downloaded_maps_childs);
-
- ArrayList<HashMap<String, String>> secList = new ArrayList<HashMap<String, String>>();
- maps_current_position_childs = new ArrayList<HashMap<String, String>>();
- // maps containing the current location
- HashMap<String, String> matching_maps = new HashMap<String, String>();
- matching_maps.put("category_name", Navit.NavitResources.getString(R.string.maps_for_current_location));
- resultGroups.add(matching_maps);
- resultChilds.add(maps_current_position_childs);
-
- // add all maps
- for (int currentMapIndex = 0; currentMapIndex < osm_maps.length; currentMapIndex++) {
- if (osm_maps[currentMapIndex].level == 0) {
- if (secList != null && secList.size() > 0) {
- resultChilds.add(secList);
- }
- secList = new ArrayList<HashMap<String, String>>();
- HashMap<String, String> map_info_hash = new HashMap<String, String>();
- map_info_hash.put("category_name", osm_maps[currentMapIndex].map_name);
- resultGroups.add(map_info_hash);
- }
-
- HashMap<String, String> child = new HashMap<String, String>();
- child.put("map_name", (osm_maps[currentMapIndex].level > 1 ? MAP_BULLETPOINT : "")
- + osm_maps[currentMapIndex].map_name + " "
- + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024) + "MB");
- child.put("map_index", String.valueOf(currentMapIndex));
-
- secList.add(child);
- }
- resultChilds.add(secList);
-
- return new SimpleExpandableListAdapter(this, resultGroups, android.R.layout.simple_expandable_list_item_1,
- new String[] { "category_name" }, new int[] { android.R.id.text1 }, resultChilds,
- android.R.layout.simple_expandable_list_item_1, new String[] { "map_name" },
- new int[] { android.R.id.text1 });
- }
-
- @Override
- public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
- super.onChildClick(parent, v, groupPosition, childPosition, id);
- Log.d("Navit", "p:" + groupPosition + ", child_pos:" + childPosition);
-
- @SuppressWarnings("unchecked")
- HashMap<String, String> child = (HashMap<String, String>) adapter.getChild(groupPosition, childPosition);
-
- String map_index = child.get("map_index");
- if (map_index != null) {
- int mi=Integer.parseInt(map_index);
- if(NavitMapDownloader.osm_maps[mi].est_size_bytes/1024/1024/950>=4) {
- NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST_LONG, null,
- Navit.T("Sorry, we currently do not support maps above 3.8G on Android, please select a smaller one."),
- -1, 0, 0);
- return true;
- }
- Intent resultIntent = new Intent();
- resultIntent.putExtra("map_index", mi);
- setResult(Activity.RESULT_OK, resultIntent);
- finish();
- } else {
- // ask user if to delete this map
- askForMapDeletion(child.get("map_location"));
- }
- return true;
- }
-
- private void askForMapDeletion(final String map_location) {
- AlertDialog.Builder deleteMapBox = new AlertDialog.Builder(this);
- deleteMapBox.setTitle(R.string.map_delete); // Android also takes recource id
- deleteMapBox.setCancelable(true);
-
- NavitMap maptoDelete = new NavitMap(map_location);
- deleteMapBox.setMessage(maptoDelete.mapName + " " + String.valueOf(maptoDelete.size() / 1024 / 1024) + "MB");
-
-
- // TRANS
- deleteMapBox.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface arg0, int arg1) {
- Log.e("Navit", "Delete Map");
- Message msg =
- Message.obtain(Navit.N_NavitGraphics.callback_handler,
- NavitGraphics.msg_type.CLB_DELETE_MAP.ordinal());
- Bundle b = new Bundle();
- b.putString("title", map_location);
- msg.setData(b);
- msg.sendToTarget();
- finish();
- }
- });
-
- // TRANS
- deleteMapBox.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface arg0, int arg1) {
- Log.e("Navit", "don't delete map");
- }
- });
- deleteMapBox.show();
- }
-}
+/**
+ * Navit, a modular navigation system. Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+package org.navitproject.navit;
+
+import android.Manifest;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ExpandableListActivity;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.location.Location;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.os.Message;
+import android.os.StatFs;
+import android.support.v4.app.ActivityCompat;
+import android.util.Log;
+import android.view.View;
+import android.widget.ExpandableListView;
+import android.widget.SimpleExpandableListAdapter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class NavitDownloadSelectMapActivity extends ExpandableListActivity {
+
+ private static final String MAP_BULLETPOINT = " * ";
+ private static SimpleExpandableListAdapter adapter = null;
+ private static ArrayList<HashMap<String, String>> downloaded_maps_childs = null;
+ private static ArrayList<HashMap<String, String>> maps_current_position_childs = null;
+ private static boolean currentLocationKnown = false;
+ private final String TAG = this.getClass().getName();
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (adapter == null) {
+ adapter = createAdapter();
+ }
+ updateDownloadedMaps();
+ updateMapsForLocation(NavitMapDownloader.osm_maps);
+ setListAdapter(adapter);
+ try {
+ setTitle(String.valueOf(getFreeSpace() / 1024 / 1024) + "MB available");
+ } catch (Exception e) {
+ Log.e(TAG, "Exception " + e.getClass().getName()
+ + " during getFreeSpace, reporting 'no sdcard present'");
+ NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST_LONG, null,
+ String.format(
+ (Navit.getInstance().getTstring(R.string.map_location_unavailable)),
+ Navit.map_filename_path),
+ -1, 0, 0);
+ finish();
+ }
+ }
+
+ private long getFreeSpace() {
+ StatFs fsInfo = new StatFs(Navit.map_filename_path);
+ return (long) fsInfo.getAvailableBlocks() * fsInfo.getBlockSize();
+ }
+
+ private void updateDownloadedMaps() {
+ downloaded_maps_childs.clear();
+ for (NavitMap map : NavitMapDownloader.getAvailableMaps()) {
+ HashMap<String, String> child = new HashMap<String, String>();
+ child.put("map_name", map.mapName + " " + (map.size() / 1024 / 1024) + "MB");
+ child.put("map_location", map.getLocation());
+ downloaded_maps_childs.add(child);
+ }
+ }
+
+ private void updateMapsForLocation(NavitMapDownloader.osm_map_values[] osm_maps) {
+ Location currentLocation = NavitVehicle.lastLocation;
+ if (maps_current_position_childs.size() == 0 || (currentLocation != null
+ && !currentLocationKnown)) {
+ if (currentLocation == null) {
+ LocationManager mapLocationManager = (LocationManager) getSystemService(
+ Context.LOCATION_SERVICE);
+ List<String> providers = mapLocationManager.getProviders(true);
+ long lastUpdate;
+ long bestUpdateTime = -1;
+ for (String provider : providers) {
+ if (ActivityCompat
+ .checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED
+ && ActivityCompat
+ .checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED) {
+ return;
+ }
+ Location lastKnownLocation = mapLocationManager.getLastKnownLocation(provider);
+ if (lastKnownLocation != null) {
+ lastUpdate = lastKnownLocation.getTime();
+ if (lastUpdate > bestUpdateTime) {
+ currentLocation = lastKnownLocation;
+ bestUpdateTime = lastUpdate;
+ }
+ }
+ }
+ } else {
+ currentLocationKnown = true;
+ }
+
+ if (currentLocation != null) {
+ // if this map contains data to our current position, add it to
+ // the MapsOfCurrentLocation-list
+ for (int currentMapIndex = 0; currentMapIndex < osm_maps.length;
+ currentMapIndex++) {
+ if (osm_maps[currentMapIndex].isInMap(currentLocation)) {
+ HashMap<String, String> currentPositionMapChild = new HashMap<String, String>();
+ currentPositionMapChild.put("map_name", osm_maps[currentMapIndex].map_name + " "
+ + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024)
+ + "MB");
+ currentPositionMapChild.put("map_index", String.valueOf(currentMapIndex));
+
+ maps_current_position_childs.add(currentPositionMapChild);
+ }
+ }
+ }
+ }
+ }
+
+ private SimpleExpandableListAdapter createAdapter() {
+
+ NavitMapDownloader.osm_map_values[] osm_maps = NavitMapDownloader.osm_maps;
+
+ ArrayList<HashMap<String, String>> resultGroups = new ArrayList<HashMap<String, String>>();
+ ArrayList<ArrayList<HashMap<String, String>>> resultChilds =
+ new ArrayList<ArrayList<HashMap<String, String>>>();
+
+ // add already downloaded maps (group and empty child list
+ HashMap<String, String> downloaded_maps_hash = new HashMap<String, String>();
+ downloaded_maps_hash
+ .put("category_name", Navit.getInstance().getTstring(R.string.maps_installed));
+ resultGroups.add(downloaded_maps_hash);
+ downloaded_maps_childs = new ArrayList<HashMap<String, String>>();
+ resultChilds.add(downloaded_maps_childs);
+
+ ArrayList<HashMap<String, String>> secList = new ArrayList<HashMap<String, String>>();
+ maps_current_position_childs = new ArrayList<HashMap<String, String>>();
+ // maps containing the current location
+ HashMap<String, String> matching_maps = new HashMap<String, String>();
+ matching_maps.put("category_name",
+ Navit.getInstance().getTstring(R.string.maps_for_current_location));
+ resultGroups.add(matching_maps);
+ resultChilds.add(maps_current_position_childs);
+
+ // add all maps
+ for (int currentMapIndex = 0; currentMapIndex < osm_maps.length; currentMapIndex++) {
+ if (osm_maps[currentMapIndex].level == 0) {
+ if (secList.size() > 0) {
+ resultChilds.add(secList);
+ }
+ secList = new ArrayList<HashMap<String, String>>();
+ HashMap<String, String> map_info_hash = new HashMap<String, String>();
+ map_info_hash.put("category_name", osm_maps[currentMapIndex].map_name);
+ resultGroups.add(map_info_hash);
+ }
+
+ HashMap<String, String> child = new HashMap<String, String>();
+ child.put("map_name", (osm_maps[currentMapIndex].level > 1 ? MAP_BULLETPOINT : "")
+ + osm_maps[currentMapIndex].map_name + " "
+ + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024) + "MB");
+ child.put("map_index", String.valueOf(currentMapIndex));
+
+ secList.add(child);
+ }
+ resultChilds.add(secList);
+
+ return new SimpleExpandableListAdapter(this, resultGroups,
+ android.R.layout.simple_expandable_list_item_1,
+ new String[] {"category_name"}, new int[] {android.R.id.text1}, resultChilds,
+ android.R.layout.simple_expandable_list_item_1, new String[] {"map_name"},
+ new int[] {android.R.id.text1});
+ }
+
+ @Override
+ public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
+ int childPosition, long id) {
+ super.onChildClick(parent, v, groupPosition, childPosition, id);
+ Log.d(TAG, "p:" + groupPosition + ", child_pos:" + childPosition);
+
+ @SuppressWarnings("unchecked")
+ HashMap<String, String> child = (HashMap<String, String>) adapter.getChild(groupPosition, childPosition);
+
+ String map_index = child.get("map_index");
+ if (map_index != null) {
+ int mi = Integer.parseInt(map_index);
+ if (NavitMapDownloader.osm_maps[mi].est_size_bytes / 1024 / 1024 / 950 >= 4) {
+ NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST_LONG, null,
+ Navit.getInstance().getTstring(R.string.map_download_oversize),
+ -1, 0, 0);
+ return true;
+ }
+ Intent resultIntent = new Intent();
+ resultIntent.putExtra("map_index", mi);
+ setResult(Activity.RESULT_OK, resultIntent);
+ finish();
+ } else {
+ // ask user if to delete this map
+ askForMapDeletion(child.get("map_location"));
+ }
+ return true;
+ }
+
+ private void askForMapDeletion(final String map_location) {
+ AlertDialog.Builder deleteMapBox = new AlertDialog.Builder(this);
+ deleteMapBox.setTitle(Navit.getInstance().getTstring(R.string.map_delete));
+ deleteMapBox.setCancelable(true);
+
+ NavitMap maptoDelete = new NavitMap(map_location);
+ deleteMapBox.setMessage(
+ maptoDelete.mapName + " " + String.valueOf(maptoDelete.size() / 1024 / 1024)
+ + "MB");
+
+ // TRANS
+ deleteMapBox.setPositiveButton(Navit.getInstance().getTstring(R.string.yes),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ Log.d(TAG, "Delete Map");
+ Message msg = Message.obtain(Navit.getInstance().getNavitGraphics().callback_handler,
+ NavitGraphics.msg_type.CLB_DELETE_MAP.ordinal());
+ Bundle b = new Bundle();
+ b.putString("title", map_location);
+ msg.setData(b);
+ msg.sendToTarget();
+ finish();
+ }
+ });
+
+ // TRANS
+ deleteMapBox.setNegativeButton((Navit.getInstance().getTstring(R.string.no)),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ Log.d(TAG, "don't delete map");
+ }
+ });
+ deleteMapBox.show();
+ }
+}
diff --git a/navit/android/src/org/navitproject/navit/NavitGraphics.java b/navit/android/src/org/navitproject/navit/NavitGraphics.java
index a2d8e405f..4e7929f88 100644
--- a/navit/android/src/org/navitproject/navit/NavitGraphics.java
+++ b/navit/android/src/org/navitproject/navit/NavitGraphics.java
@@ -19,17 +19,14 @@
package org.navitproject.navit;
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-
+import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
@@ -38,7 +35,7 @@ import android.graphics.Rect;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
-import android.util.FloatMath;
+import android.support.v4.view.ViewConfigurationCompat;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Gravity;
@@ -48,1163 +45,1127 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup.LayoutParams;
+import android.view.WindowInsets;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
-public class NavitGraphics
-{
- private NavitGraphics parent_graphics;
- private ArrayList<NavitGraphics> overlays = new ArrayList<NavitGraphics>();
- int bitmap_w;
- int bitmap_h;
- int pos_x;
- int pos_y;
- int pos_wraparound;
- int overlay_disabled;
- int bgcolor;
- float trackball_x, trackball_y;
- View view;
- SystemBarTintView navigationTintView;
- SystemBarTintView statusTintView;
- FrameLayout frameLayout;
- RelativeLayout relativelayout;
- NavitCamera camera;
- Activity activity;
-
- public static Boolean in_map = false;
-
- // for menu key
- private static long time_for_long_press = 300L;
- private static long interval_for_long_press = 200L;
-
- private Handler timer_handler = new Handler();
-
- public void setBackgroundColor(int bgcolor) {
- this.bgcolor = bgcolor;
- if (navigationTintView != null)
- navigationTintView.setBackgroundColor(bgcolor);
- if (statusTintView != null)
- statusTintView.setBackgroundColor(bgcolor);
- }
-
- public void SetCamera(int use_camera)
- {
- if (use_camera != 0 && camera == null)
- {
- // activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
- camera = new NavitCamera(activity);
- relativelayout.addView(camera);
- relativelayout.bringChildToFront(view);
- }
- }
-
- protected Rect get_rect()
- {
- Rect ret=new Rect();
- ret.left=pos_x;
- ret.top=pos_y;
- if (pos_wraparound != 0) {
- if (ret.left < 0) {
- ret.left+=parent_graphics.bitmap_w;
- }
- if (ret.top < 0) {
- ret.top+=parent_graphics.bitmap_h;
- }
- }
- ret.right=ret.left+bitmap_w;
- ret.bottom=ret.top+bitmap_h;
- if (pos_wraparound != 0) {
- if (bitmap_w < 0) {
- ret.right=ret.left+bitmap_w+parent_graphics.bitmap_w;
- }
- if (bitmap_h < 0) {
- ret.bottom=ret.top+bitmap_h+parent_graphics.bitmap_h;
- }
- }
- return ret;
- }
-
- private class NavitView extends View implements Runnable, MenuItem.OnMenuItemClickListener{
- int touch_mode = NONE;
- float oldDist = 0;
- static final int NONE = 0;
- static final int DRAG = 1;
- static final int ZOOM = 2;
- static final int PRESSED = 3;
-
- Method eventGetX = null;
- Method eventGetY = null;
-
- public PointF mPressedPosition = null;
-
- public NavitView(Context context) {
- super(context);
- try
- {
- eventGetX = android.view.MotionEvent.class.getMethod("getX", int.class);
- eventGetY = android.view.MotionEvent.class.getMethod("getY", int.class);
- }
- catch (Exception e)
- {
- Log.e("NavitGraphics", "Multitouch zoom not supported");
- }
- }
-
- @Override
- protected void onCreateContextMenu(ContextMenu menu) {
- super.onCreateContextMenu(menu);
-
- menu.setHeaderTitle(Navit.T("Position")+"..");
- menu.add(1, 1, NONE, Navit.T("Route to here")).setOnMenuItemClickListener(this);
- menu.add(1, 2, NONE, Navit.T("Cancel")).setOnMenuItemClickListener(this);
- }
-
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- switch(item.getItemId()) {
- case 1:
- Message msg = Message.obtain(callback_handler, msg_type.CLB_SET_DISPLAY_DESTINATION.ordinal()
- , (int)mPressedPosition.x, (int)mPressedPosition.y);
- msg.sendToTarget();
- break;
- }
- return false;
- }
-
-
- @Override
- protected void onDraw(Canvas canvas)
- {
- super.onDraw(canvas);
- canvas.drawBitmap(draw_bitmap, pos_x, pos_y, null);
- if (overlay_disabled == 0)
- {
- // assume we ARE in map view mode!
- in_map = true;
- for (NavitGraphics overlay : overlays)
- {
- if (overlay.overlay_disabled == 0)
- {
- Rect r=overlay.get_rect();
- canvas.drawBitmap(overlay.draw_bitmap, r.left, r.top, null);
- }
- }
- }
- else
- {
- if (Navit.show_soft_keyboard)
- {
- if (Navit.mgr != null)
- {
- //Log.e("NavitGraphics", "view -> SHOW SoftInput");
- //Log.e("NavitGraphics", "view mgr=" + String.valueOf(Navit.mgr));
- Navit.mgr.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
- Navit.show_soft_keyboard_now_showing = true;
- // clear the variable now, keyboard will stay on screen until backbutton pressed
- Navit.show_soft_keyboard = false;
- }
- }
- }
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh)
- {
- Log.e("Navit", "NavitGraphics -> onSizeChanged pixels x=" + w + " pixels y=" + h);
- Log.e("Navit", "NavitGraphics -> onSizeChanged density=" + Navit.metrics.density);
- Log.e("Navit", "NavitGraphics -> onSizeChanged scaledDensity="
- + Navit.metrics.scaledDensity);
- super.onSizeChanged(w, h, oldw, oldh);
-
- handleResize(w, h);
- }
-
- public void do_longpress_action()
- {
- Log.e("NavitGraphics", "do_longpress_action enter");
-
- activity.openContextMenu(this);
- }
-
- private int getActionField(String fieldname, Object obj)
- {
- int ret_value = -999;
- try
- {
- java.lang.reflect.Field field = android.view.MotionEvent.class.getField(fieldname);
- try
- {
- ret_value = field.getInt(obj);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- catch (NoSuchFieldException ex) {}
-
- return ret_value;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event)
- {
- //Log.e("NavitGraphics", "onTouchEvent");
- super.onTouchEvent(event);
- int x = (int) event.getX();
- int y = (int) event.getY();
-
- int _ACTION_POINTER_UP_ = getActionField("ACTION_POINTER_UP", event);
- int _ACTION_POINTER_DOWN_ = getActionField("ACTION_POINTER_DOWN", event);
- int _ACTION_MASK_ = getActionField("ACTION_MASK", event);
-
- int switch_value = event.getAction();
- if (_ACTION_MASK_ != -999)
- {
- switch_value = (event.getAction() & _ACTION_MASK_);
- }
-
- if (switch_value == MotionEvent.ACTION_DOWN)
- {
- touch_mode = PRESSED;
- if (!in_map) ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
- mPressedPosition = new PointF(x, y);
- postDelayed(this, time_for_long_press);
- }
- else if ((switch_value == MotionEvent.ACTION_UP) || (switch_value == _ACTION_POINTER_UP_))
- {
- Log.e("NavitGraphics", "ACTION_UP");
-
- if ( touch_mode == DRAG )
- {
- Log.e("NavitGraphics", "onTouch move");
-
- MotionCallback(MotionCallbackID, x, y);
- ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
- }
- else if (touch_mode == ZOOM)
- {
- //Log.e("NavitGraphics", "onTouch zoom");
-
- float newDist = spacing(getFloatValue(event, 0), getFloatValue(event, 1));
- float scale = 0;
- if (newDist > 10f)
- {
- scale = newDist / oldDist;
- }
-
- if (scale > 1.3)
- {
- // zoom in
- CallbackMessageChannel(1, null);
- //Log.e("NavitGraphics", "onTouch zoom in");
- }
- else if (scale < 0.8)
- {
- // zoom out
- CallbackMessageChannel(2, null);
- //Log.e("NavitGraphics", "onTouch zoom out");
- }
- }
- else if (touch_mode == PRESSED)
- {
- if (in_map) ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
- ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
- }
- touch_mode = NONE;
- }
- else if (switch_value == MotionEvent.ACTION_MOVE)
- {
- //Log.e("NavitGraphics", "ACTION_MOVE");
-
- if (touch_mode == DRAG)
- {
- MotionCallback(MotionCallbackID, x, y);
- }
- else if (touch_mode == ZOOM)
- {
- float newDist = spacing(getFloatValue(event, 0), getFloatValue(event, 1));
- float scale = newDist / oldDist;
- Log.e("NavitGraphics", "New scale = " + scale);
- if (scale > 1.2)
- {
- // zoom in
- CallbackMessageChannel(1, "");
- oldDist = newDist;
- //Log.e("NavitGraphics", "onTouch zoom in");
- }
- else if (scale < 0.8)
- {
- oldDist = newDist;
- // zoom out
- CallbackMessageChannel(2, "");
- //Log.e("NavitGraphics", "onTouch zoom out");
- }
- }
- else if (touch_mode == PRESSED)
- {
- Log.e("NavitGraphics", "Start drag mode");
- if ( spacing(mPressedPosition, new PointF(event.getX(), event.getY())) > 20f) {
- ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
- touch_mode = DRAG;
- }
- }
- }
- else if (switch_value == _ACTION_POINTER_DOWN_)
- {
- //Log.e("NavitGraphics", "ACTION_POINTER_DOWN");
- oldDist = spacing(getFloatValue(event, 0), getFloatValue(event, 1));
- if (oldDist > 2f)
- {
- touch_mode = ZOOM;
- //Log.e("NavitGraphics", "--> zoom");
- }
- }
- return true;
- }
-
- private float spacing(PointF a, PointF b)
- {
- float x = a.x - b.x;
- float y = a.y - b.y;
- return (float)Math.sqrt(x * x + y * y);
- }
-
- private PointF getFloatValue(Object instance, Object argument)
- {
- PointF pos = new PointF(0,0);
-
- if (eventGetX != null && eventGetY != null)
- {
- try
- {
- Float x = (java.lang.Float) eventGetX.invoke(instance, argument);
- Float y = (java.lang.Float) eventGetY.invoke(instance, argument);
- pos.set(x.floatValue(), y.floatValue());
-
- }
- catch (Exception e){}
- }
- return pos;
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- int i;
- String s = null;
- boolean handled = true;
- i = event.getUnicodeChar();
- //Log.e("NavitGraphics", "onKeyDown " + keyCode + " " + i);
- // Log.e("NavitGraphics","Unicode "+event.getUnicodeChar());
- if (i == 0)
- {
- if (keyCode == android.view.KeyEvent.KEYCODE_DEL)
- {
- s = java.lang.String.valueOf((char) 8);
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_MENU)
- {
- if (!in_map)
- {
- // if last menukeypress is less than 0.2 seconds away then count longpress
- if ((System.currentTimeMillis() - Navit.last_pressed_menu_key) < interval_for_long_press)
- {
- Navit.time_pressed_menu_key = Navit.time_pressed_menu_key
- + (System.currentTimeMillis() - Navit.last_pressed_menu_key);
- //Log.e("NavitGraphics", "press time=" + Navit.time_pressed_menu_key);
-
- // on long press let softkeyboard popup
- if (Navit.time_pressed_menu_key > time_for_long_press)
- {
- //Log.e("NavitGraphics", "long press menu key!!");
- Navit.show_soft_keyboard = true;
- Navit.time_pressed_menu_key = 0L;
- // need to draw to get the keyboard showing
- this.postInvalidate();
- }
- }
- else
- {
- Navit.time_pressed_menu_key = 0L;
- }
- Navit.last_pressed_menu_key = System.currentTimeMillis();
- // if in menu view:
- // use as OK (Enter) key
- s = java.lang.String.valueOf((char) 13);
- handled = true;
- // dont use menu key here (use it in onKeyUp)
- return handled;
- }
- else
- {
- // if on map view:
- // volume UP
- //s = java.lang.String.valueOf((char) 1);
- handled = false;
- return handled;
- }
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_SEARCH)
- {
- /* Handle event in Main Activity if map is shown */
- if(in_map)
- return false;
-
- s = java.lang.String.valueOf((char) 19);
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_BACK)
- {
- //Log.e("NavitGraphics", "KEYCODE_BACK down");
- s = java.lang.String.valueOf((char) 27);
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_CALL)
- {
- s = java.lang.String.valueOf((char) 3);
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_VOLUME_UP)
- {
- if (!in_map)
- {
- // if in menu view:
- // use as UP key
- s = java.lang.String.valueOf((char) 16);
- handled = true;
- }
- else
- {
- // if on map view:
- // volume UP
- //s = java.lang.String.valueOf((char) 21);
- handled = false;
- return handled;
- }
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_VOLUME_DOWN)
- {
- if (!in_map)
- {
- // if in menu view:
- // use as DOWN key
- s = java.lang.String.valueOf((char) 14);
- handled = true;
- }
- else
- {
- // if on map view:
- // volume DOWN
- //s = java.lang.String.valueOf((char) 4);
- handled = false;
- return handled;
- }
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_CENTER)
- {
- s = java.lang.String.valueOf((char) 13);
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_DOWN)
- {
- s = java.lang.String.valueOf((char) 14);
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_LEFT)
- {
- s = java.lang.String.valueOf((char) 2);
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_RIGHT)
- {
- s = java.lang.String.valueOf((char) 6);
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_UP)
- {
- s = java.lang.String.valueOf((char) 16);
- }
- }
- else if (i == 10)
- {
- s = java.lang.String.valueOf((char) 13);
- }
-
- if (s != null)
- {
- KeypressCallback(KeypressCallbackID, s);
- }
- return handled;
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event)
- {
- //Log.e("NavitGraphics", "onKeyUp " + keyCode);
-
- int i;
- String s = null;
- boolean handled = true;
- i = event.getUnicodeChar();
-
- if (i == 0)
- {
- if (keyCode == android.view.KeyEvent.KEYCODE_VOLUME_UP)
- {
- if (!in_map)
- {
- //s = java.lang.String.valueOf((char) 16);
- handled = true;
- return handled;
- }
- else
- {
- //s = java.lang.String.valueOf((char) 21);
- handled = false;
- return handled;
- }
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_VOLUME_DOWN)
- {
- if (!in_map)
- {
- //s = java.lang.String.valueOf((char) 14);
- handled = true;
- return handled;
- }
- else
- {
- //s = java.lang.String.valueOf((char) 4);
- handled = false;
- return handled;
- }
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_SEARCH) {
- /* Handle event in Main Activity if map is shown */
- if(in_map)
- return false;
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_BACK)
- {
- if (Navit.show_soft_keyboard_now_showing)
- {
- Navit.show_soft_keyboard_now_showing = false;
- }
- //Log.e("NavitGraphics", "KEYCODE_BACK up");
- //s = java.lang.String.valueOf((char) 27);
- handled = true;
- return handled;
- }
- else if (keyCode == android.view.KeyEvent.KEYCODE_MENU)
- {
- if (!in_map)
- {
- if (Navit.show_soft_keyboard_now_showing)
- {
- // if soft keyboard showing on screen, dont use menu button as select key
- }
- else
- {
- // if in menu view:
- // use as OK (Enter) key
- s = java.lang.String.valueOf((char) 13);
- handled = true;
- }
- }
- else
- {
- // if on map view:
- // volume UP
- //s = java.lang.String.valueOf((char) 1);
- handled = false;
- return handled;
- }
- }
- }
- else if(i!=10)
- {
- s = java.lang.String.valueOf((char) i);
- }
-
- if (s != null)
- {
- KeypressCallback(KeypressCallbackID, s);
- }
- return handled;
-
- }
-
- @Override
- public boolean onKeyMultiple (int keyCode, int count, KeyEvent event)
- {
- String s = null;
- if(keyCode == KeyEvent.KEYCODE_UNKNOWN) {
- s=event.getCharacters();
- KeypressCallback(KeypressCallbackID, s);
- return true;
- }
- return super.onKeyMultiple(keyCode, count, event);
- }
-
- @Override
- public boolean onTrackballEvent(MotionEvent event)
- {
- //Log.e("NavitGraphics", "onTrackball " + event.getAction() + " " + event.getX() + " "
- // + event.getY());
- String s = null;
- if (event.getAction() == android.view.MotionEvent.ACTION_DOWN)
- {
- s = java.lang.String.valueOf((char) 13);
- }
- if (event.getAction() == android.view.MotionEvent.ACTION_MOVE)
- {
- trackball_x += event.getX();
- trackball_y += event.getY();
- //Log.e("NavitGraphics", "trackball " + trackball_x + " " + trackball_y);
- if (trackball_x <= -1)
- {
- s = java.lang.String.valueOf((char) 2);
- trackball_x += 1;
- }
- if (trackball_x >= 1)
- {
- s = java.lang.String.valueOf((char) 6);
- trackball_x -= 1;
- }
- if (trackball_y <= -1)
- {
- s = java.lang.String.valueOf((char) 16);
- trackball_y += 1;
- }
- if (trackball_y >= 1)
- {
- s = java.lang.String.valueOf((char) 14);
- trackball_y -= 1;
- }
- }
- if (s != null)
- {
- KeypressCallback(KeypressCallbackID, s);
- }
- return true;
- }
- @Override
- protected void onFocusChanged(boolean gainFocus, int direction,
- Rect previouslyFocusedRect)
- {
- super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
- //Log.e("NavitGraphics", "FocusChange " + gainFocus);
- }
-
- public void run() {
- if (in_map && touch_mode == PRESSED)
- {
- do_longpress_action();
- touch_mode = NONE;
- }
- }
-
- }
-
- private class SystemBarTintView extends View {
-
- public SystemBarTintView(Context context) {
- super(context);
- this.setBackgroundColor(bgcolor);
- }
-
- }
-
- public NavitGraphics(final Activity activity, NavitGraphics parent, int x, int y, int w, int h,
- int wraparound, int use_camera)
- {
- if (parent == null)
- {
- this.activity = activity;
- view = new NavitView(activity);
- //activity.registerForContextMenu(view);
- view.setClickable(false);
- view.setFocusable(true);
- view.setFocusableInTouchMode(true);
- view.setKeepScreenOn(true);
- relativelayout = new RelativeLayout(activity);
- if (use_camera != 0)
- {
- SetCamera(use_camera);
- }
- relativelayout.addView(view);
-
- /* The navigational and status bar tinting code is meaningful only on API19+ */
- if(Build.VERSION.SDK_INT >= 19)
- {
- frameLayout = new FrameLayout(activity);
- frameLayout.addView(relativelayout);
- navigationTintView = new SystemBarTintView(activity);
- statusTintView = new SystemBarTintView(activity);
- frameLayout.addView(navigationTintView);
- frameLayout.addView(statusTintView);
- activity.setContentView(frameLayout);
- }
- else
- {
- activity.setContentView(relativelayout);
- }
-
- view.requestFocus();
- }
- else
- {
- draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- bitmap_w = w;
- bitmap_h = h;
- pos_x = x;
- pos_y = y;
- pos_wraparound = wraparound;
- draw_canvas = new Canvas(draw_bitmap);
- parent.overlays.add(this);
- }
- parent_graphics = parent;
- }
-
- static public enum msg_type {
- CLB_ZOOM_IN, CLB_ZOOM_OUT, CLB_REDRAW, CLB_MOVE, CLB_BUTTON_UP, CLB_BUTTON_DOWN, CLB_SET_DESTINATION
- , CLB_SET_DISPLAY_DESTINATION, CLB_CALL_CMD, CLB_COUNTRY_CHOOSER, CLB_LOAD_MAP, CLB_UNLOAD_MAP, CLB_DELETE_MAP
- };
-
- static public msg_type[] msg_values = msg_type.values();
-
- public Handler callback_handler = new Handler()
- {
- public void handleMessage(Message msg)
- {
- switch (msg_values[msg.what])
- {
- case CLB_ZOOM_IN:
- CallbackMessageChannel(1, "");
- break;
- case CLB_ZOOM_OUT:
- CallbackMessageChannel(2, "");
- break;
- case CLB_MOVE:
- MotionCallback(MotionCallbackID, msg.getData().getInt("x"), msg.getData().getInt("y"));
- break;
- case CLB_SET_DESTINATION:
- String lat = Float.toString(msg.getData().getFloat("lat"));
- String lon = Float.toString(msg.getData().getFloat("lon"));
- String q = msg.getData().getString(("q"));
- CallbackMessageChannel(3, lat + "#" + lon + "#" + q);
- break;
- case CLB_SET_DISPLAY_DESTINATION:
- int x = msg.arg1;
- int y = msg.arg2;
- CallbackMessageChannel(4, "" + x + "#" + y);
- break;
- case CLB_CALL_CMD:
- String cmd = msg.getData().getString(("cmd"));
- CallbackMessageChannel(5, cmd);
- break;
- case CLB_BUTTON_UP:
- ButtonCallback(ButtonCallbackID, 0, 1, msg.getData().getInt("x"), msg.getData().getInt("y")); // up
- break;
- case CLB_BUTTON_DOWN:
- ButtonCallback(ButtonCallbackID, 1, 1, msg.getData().getInt("x"), msg.getData().getInt("y")); // down
- break;
- case CLB_COUNTRY_CHOOSER:
- break;
- case CLB_LOAD_MAP:
- CallbackMessageChannel(6, msg.getData().getString(("title")));
- break;
- case CLB_DELETE_MAP:
- File toDelete = new File( msg.getData().getString(("title")));
- toDelete.delete();
- //fallthrough
- case CLB_UNLOAD_MAP:
- CallbackMessageChannel(7, msg.getData().getString(("title")));
- break;
- }
- }
- };
-
- public native void SizeChangedCallback(int id, int x, int y);
- public native void PaddingChangedCallback(int id, int left, int right, int top, int bottom);
- public native void KeypressCallback(int id, String s);
- public native int CallbackMessageChannel(int i, String s);
- public native void ButtonCallback(int id, int pressed, int button, int x, int y);
- public native void MotionCallback(int id, int x, int y);
- public native String GetDefaultCountry(int id, String s);
- public static native String[][] GetAllCountries();
- private Canvas draw_canvas;
- private Bitmap draw_bitmap;
- private int SizeChangedCallbackID, PaddingChangedCallbackID, ButtonCallbackID, MotionCallbackID, KeypressCallbackID;
- // private int count;
-
- /**
- * @brief Adjust views used to tint navigation and status bars.
- *
- * This method is called from handleResize.
- *
- * It (re-)evaluates if and where the navigation bar is going to be shown, and calculates the
- * padding for objects which should not be obstructed.
- *
- */
- private void adjustSystemBarsTintingViews() {
-
- /* frameLayout is only created on platforms supporting navigation and status bar tinting */
- if (frameLayout == null)
- return;
-
- if (!(activity instanceof Navit)) {
- Log.e("NavitGraphics", "Main Activity is not a Navit instance, cannot update padding");
- return;
- }
-
- Navit navit = (Navit) activity;
-
- /*
- * Determine visibility of status bar.
- * The status bar is always visible unless we are in fullscreen mode.
- */
- final Boolean isStatusShowing = !navit.isFullscreen;
-
- /*
- * Determine visibility of navigation bar.
- * This logic is based on the presence of a hardware menu button and is known to work on
- * devices which allow switching between hw and sw buttons (OnePlus One running CyanogenMod).
- */
- final Boolean isNavShowing = !ViewConfiguration.get(navit.getApplication()).hasPermanentMenuKey();
- Log.d("NavitGraphics", String.format("isStatusShowing=%b isNavShowing=%b", isStatusShowing, isNavShowing));
-
- /*
- * Determine where the navigation bar would be displayed.
- * Logic is taken from AOSP RenderSessionImpl.findNavigationBar()
- * (platform/frameworks/base/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java)
- */
- final Boolean isLandscape = (navit.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
- final Boolean isNavAtBottom = (!isLandscape) || (navit.getResources().getConfiguration().smallestScreenWidthDp >= 600);
- Log.d("NavitGraphics", String.format("isNavAtBottom=%b (Configuration.smallestScreenWidthDp=%d, isLandscape=%b)",
- isNavAtBottom, navit.getResources().getConfiguration().smallestScreenWidthDp, isLandscape));
-
- int left = 0;
- int top = isStatusShowing ? Navit.status_bar_height : 0;
- int right = (isNavShowing && !isNavAtBottom) ? Navit.navigation_bar_width : 0;
- final int bottom = (!(isNavShowing && isNavAtBottom)) ? 0 : isLandscape ? Navit.navigation_bar_height_landscape : Navit.navigation_bar_height;
-
- /* hide tint bars during update to prevent ugly effects */
- statusTintView.setVisibility(View.GONE);
- navigationTintView.setVisibility(View.GONE);
-
- frameLayout.post(new Runnable() {
- @Override
- public void run() {
- statusTintView.setVisibility(isStatusShowing ? View.VISIBLE : View.GONE);
- FrameLayout.LayoutParams statusLayoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, Navit.status_bar_height, Gravity.TOP);
-
- /* Prevent tint views from overlapping when navigation is on the right */
- statusLayoutParams.setMargins(0, 0, (isNavShowing && !isNavAtBottom) ? Navit.navigation_bar_width : 0, 0);
- statusTintView.setLayoutParams(statusLayoutParams);
- Log.d("NavitGraphics", String.format("statusTintView: width=%d height=%d",
- statusTintView.getWidth(), statusTintView.getHeight()));
- navigationTintView.setVisibility(isNavShowing ? View.VISIBLE : View.GONE);
- LayoutParams navigationLayoutParams = new FrameLayout.LayoutParams(
- isNavAtBottom ? LayoutParams.MATCH_PARENT : Navit.navigation_bar_width, // X
- isNavAtBottom ? bottom : LayoutParams.MATCH_PARENT, // Y
- Gravity.BOTTOM | Gravity.RIGHT);
- navigationTintView.setLayoutParams(navigationLayoutParams);
- Log.d("NavitGraphics", String.format("navigationTintView: width=%d height=%d",
- navigationTintView.getWidth(), navigationTintView.getHeight()));
- }
- });
-
- Log.d("NavitGraphics", String.format("Padding left=%d top=%d right=%d bottom=%d", left, top, right, bottom));
-
- PaddingChangedCallback(PaddingChangedCallbackID, left, top, right, bottom);
- }
-
- /**
- * @brief Handles resize events.
- *
- * This method is called whenever the main View is resized in any way. This is the case when its
- * {@code onSizeChanged()} event handler fires or when toggling Fullscreen mode.
- *
- */
- public void handleResize(int w, int h) {
- if (this.parent_graphics != null)
- this.parent_graphics.handleResize(w, h);
- else {
- Log.d("NavitGraphics", String.format("handleResize w=%d h=%d", w, h));
-
- adjustSystemBarsTintingViews();
-
- draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- draw_canvas = new Canvas(draw_bitmap);
- bitmap_w = w;
- bitmap_h = h;
- SizeChangedCallback(SizeChangedCallbackID, w, h);
- }
- }
-
- /**
- * @brief Returns whether the device has a hardware menu button.
- *
- * Only Android versions starting with ICS (API version 14) support the API call to detect the presence of a
- * Menu button. On earlier Android versions, the following assumptions will be made: On API levels up to 10,
- * this method will always return {@code true}, as these Android versions relied on devices having a physical
- * Menu button. On API levels 11 through 13 (Honeycomb releases), this method will always return
- * {@code false}, as Honeycomb was a tablet-only release and did not require devices to have a Menu button.
- *
- * Note that this method is not aware of non-standard mechanisms on some customized builds of Android. For
- * example, CyanogenMod has an option to add a menu button to the navigation bar. Even with that option,
- * this method will still return `false`.
- */
- public boolean hasMenuButton() {
- if (Build.VERSION.SDK_INT <= 10)
- return true;
- else if (Build.VERSION.SDK_INT <= 13)
- return false;
- else
- return ViewConfiguration.get(activity.getApplication()).hasPermanentMenuKey();
- }
-
- public void setSizeChangedCallback(int id)
- {
- SizeChangedCallbackID = id;
- }
- public void setPaddingChangedCallback(int id)
- {
- PaddingChangedCallbackID = id;
- }
- public void setButtonCallback(int id)
- {
- ButtonCallbackID = id;
- }
- public void setMotionCallback(int id)
- {
- MotionCallbackID = id;
- Navit.setMotionCallback(id, this);
- }
-
- public void setKeypressCallback(int id)
- {
- KeypressCallbackID = id;
- // set callback id also in main intent (for menus)
- Navit.setKeypressCallback(id, this);
- }
-
-
- protected void draw_polyline(Paint paint, int c[])
- {
- int i, ndashes;
- float [] intervals;
- // Log.e("NavitGraphics","draw_polyline");
- paint.setStrokeWidth(c[0]);
- paint.setARGB(c[1],c[2],c[3],c[4]);
- paint.setStyle(Paint.Style.STROKE);
- //paint.setAntiAlias(true);
- //paint.setStrokeWidth(0);
- ndashes=c[5];
- intervals=new float[ndashes+(ndashes%2)];
- for (i = 0; i < ndashes; i++)
- intervals[i]=c[6+i];
-
- if((ndashes%2)==1)
- intervals[ndashes]=intervals[ndashes-1];
-
- if(ndashes>0)
- paint.setPathEffect(new android.graphics.DashPathEffect(intervals,0.0f));
-
- Path path = new Path();
- path.moveTo(c[6+ndashes], c[7+ndashes]);
- for (i = 8+ndashes; i < c.length; i += 2)
- {
- path.lineTo(c[i], c[i + 1]);
- }
- //global_path.close();
- draw_canvas.drawPath(path, paint);
- paint.setPathEffect(null);
- }
-
- protected void draw_polygon(Paint paint, int c[])
- {
- //Log.e("NavitGraphics","draw_polygon");
- paint.setStrokeWidth(c[0]);
- paint.setARGB(c[1],c[2],c[3],c[4]);
- paint.setStyle(Paint.Style.FILL);
- //paint.setAntiAlias(true);
- //paint.setStrokeWidth(0);
- Path path = new Path();
- path.moveTo(c[5], c[6]);
- for (int i = 7; i < c.length; i += 2)
- {
- path.lineTo(c[i], c[i + 1]);
- }
- //global_path.close();
- draw_canvas.drawPath(path, paint);
- }
- protected void draw_rectangle(Paint paint, int x, int y, int w, int h)
- {
- //Log.e("NavitGraphics","draw_rectangle");
- Rect r = new Rect(x, y, x + w, y + h);
- paint.setStyle(Paint.Style.FILL);
- paint.setAntiAlias(true);
- //paint.setStrokeWidth(0);
- draw_canvas.drawRect(r, paint);
- }
- protected void draw_circle(Paint paint, int x, int y, int r)
- {
- //Log.e("NavitGraphics","draw_circle");
- // float fx = x;
- // float fy = y;
- // float fr = r / 2;
- paint.setStyle(Paint.Style.STROKE);
- draw_canvas.drawCircle(x, y, r / 2, paint);
- }
- protected void draw_text(Paint paint, int x, int y, String text, int size, int dx, int dy, int bgcolor)
- {
- int oldcolor=paint.getColor();
- Path path=null;
-
- paint.setTextSize(size / 15);
- paint.setStyle(Paint.Style.FILL);
-
- if (dx != 0x10000 || dy != 0) {
- path = new Path();
- path.moveTo(x, y);
- path.rLineTo(dx, dy);
- paint.setTextAlign(android.graphics.Paint.Align.LEFT);
- }
-
- if(bgcolor!=0) {
- paint.setStrokeWidth(3);
- paint.setColor(bgcolor);
- paint.setStyle(Paint.Style.STROKE);
- if(path==null) {
- draw_canvas.drawText(text, x, y, paint);
- } else {
- draw_canvas.drawTextOnPath(text, path, 0, 0, paint);
- }
- paint.setStyle(Paint.Style.FILL);
- paint.setColor(oldcolor);
- }
-
- if(path==null) {
- draw_canvas.drawText(text, x, y, paint);
- } else {
- draw_canvas.drawTextOnPath(text, path, 0, 0, paint);
- }
- paint.clearShadowLayer();
- }
- protected void draw_image(Paint paint, int x, int y, Bitmap bitmap)
- {
- //Log.e("NavitGraphics","draw_image");
- // float fx = x;
- // float fy = y;
- draw_canvas.drawBitmap(bitmap, x, y, null);
- }
-
- /* takes an image and draws it on the screen as a prerendered maptile
- *
- *
- *
- * @param paint Paint object used to draw the image
- * @param count the number of points specified
- * @param p0x and p0y specifying the top left point
- * @param p1x and p1y specifying the top right point
- * @param p2x and p2y specifying the bottom left point, not yet used but kept
- * for compatibility with the linux port
- * @param bitmap Bitmap object holding the image to draw
- *
- * TODO make it work with 4 points specified to make it work for 3D mapview, so it can be used
- * for small but very detailed maps as well as for large maps with very little detail but large
- * coverage.
- * TODO make it work with rectangular tiles as well ?
- */
- protected void draw_image_warp(Paint paint, int count, int p0x, int p0y, int p1x, int p1y, int p2x, int p2y, Bitmap bitmap)
- {
-
- float width;
- float scale;
- float deltaY;
- float deltaX;
- float angle;
- Matrix matrix;
-
- if (count == 3)
- {
- matrix = new Matrix();
- deltaX = p1x - p0x;
- deltaY = p1y - p0y;
- width = (float) (Math.sqrt((deltaX * deltaX) + (deltaY * deltaY)));
- angle = (float) (Math.atan2(deltaY, deltaX) * 180d / Math.PI);
- scale = width / bitmap.getWidth();
- matrix.preScale(scale, scale);
- matrix.postTranslate(p0x, p0y);
- matrix.postRotate(angle, p0x, p0y);
- draw_canvas.drawBitmap(bitmap, matrix, paint);
- }
- }
-
- /* These constants must be synchronized with enum draw_mode_num in graphics.h. */
- public static final int draw_mode_begin = 0;
- public static final int draw_mode_end = 1;
-
- protected void draw_mode(int mode)
- {
- //Log.e("NavitGraphics", "draw_mode mode=" + mode + " parent_graphics="
- // + String.valueOf(parent_graphics));
-
- if (mode == draw_mode_end) {
- if (parent_graphics == null) {
- view.invalidate();
- } else {
- parent_graphics.view.invalidate(get_rect());
- }
- }
- if (mode == draw_mode_begin && parent_graphics != null) {
- draw_bitmap.eraseColor(0);
- }
-
- }
- protected void draw_drag(int x, int y)
- {
- //Log.e("NavitGraphics","draw_drag");
- pos_x = x;
- pos_y = y;
- }
- protected void overlay_disable(int disable)
- {
- Log.e("NavitGraphics","overlay_disable: " + disable + "Parent: " + (parent_graphics != null));
- // assume we are NOT in map view mode!
- if (parent_graphics == null)
- in_map = (disable==0);
- if (overlay_disabled != disable) {
- overlay_disabled = disable;
- if (parent_graphics != null) {
- parent_graphics.view.invalidate(get_rect());
- }
- }
- }
-
- protected void overlay_resize(int x, int y, int w, int h, int wraparound)
- {
- //Log.e("NavitGraphics","overlay_resize");
- draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- bitmap_w = w;
- bitmap_h = h;
- pos_x = x;
- pos_y = y;
- pos_wraparound = wraparound;
- draw_canvas.setBitmap(draw_bitmap);
- }
-
- public static String getLocalizedString(String text)
- {
- String ret = CallbackLocalizedString(text);
- //Log.e("NavitGraphics", "callback_handler -> lozalized string=" + ret);
- return ret;
- }
-
-
-
-
- /**
- * get localized string
- */
- public static native String CallbackLocalizedString(String s);
-
+public class NavitGraphics {
+ private static final String TAG = "NavitGraphics";
+ private final NavitGraphics parent_graphics;
+ private final ArrayList<NavitGraphics> overlays = new ArrayList<NavitGraphics>();
+ private int bitmap_w;
+ private int bitmap_h;
+ private int pos_x;
+ private int pos_y;
+ private int pos_wraparound;
+ private int overlay_disabled;
+ private int bgcolor;
+ private float trackball_x;
+ private float trackball_y;
+ private int padding_left = 0;
+ private int padding_right = 0;
+ private int padding_top = 0;
+ private int padding_bottom = 0;
+ private View view;
+ private SystemBarTintView leftTintView;
+ private SystemBarTintView rightTintView;
+ private SystemBarTintView topTintView;
+ private SystemBarTintView bottomTintView;
+ private FrameLayout frameLayout;
+ private RelativeLayout relativelayout;
+ private NavitCamera camera = null;
+ private Navit activity;
+ private static Boolean in_map = false;
+ // for menu key
+ private static final long time_for_long_press = 300L;
+
+
+ private Handler timer_handler = new Handler();
+
+ public void setBackgroundColor(int bgcolor) {
+ this.bgcolor = bgcolor;
+ if (leftTintView != null) {
+ leftTintView.setBackgroundColor(bgcolor);
+ }
+ if (rightTintView != null) {
+ rightTintView.setBackgroundColor(bgcolor);
+ }
+ if (topTintView != null) {
+ topTintView.setBackgroundColor(bgcolor);
+ }
+ if (bottomTintView != null) {
+ bottomTintView.setBackgroundColor(bgcolor);
+ }
+ }
+
+ private void SetCamera(int use_camera) {
+ if (use_camera != 0 && camera == null) {
+ // activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ addCamera();
+ addCameraView();
+ }
+ }
+
+ /**
+ * @brief Adds a camera.
+ *
+ * This method does not create the view for the camera. This must be done separately by calling
+ * {@link #addCameraView()}.
+ */
+ private void addCamera() {
+ camera = new NavitCamera(activity);
+ }
+
+ /**
+ * @brief Adds a view for the camera.
+ *
+ * If {@link #camera} is null, this method is a no-op.
+ */
+ private void addCameraView() {
+ if (camera != null) {
+ relativelayout.addView(camera);
+ relativelayout.bringChildToFront(view);
+ }
+ }
+
+ private Rect get_rect() {
+ Rect ret = new Rect();
+ ret.left = pos_x;
+ ret.top = pos_y;
+ if (pos_wraparound != 0) {
+ if (ret.left < 0) {
+ ret.left += parent_graphics.bitmap_w;
+ }
+ if (ret.top < 0) {
+ ret.top += parent_graphics.bitmap_h;
+ }
+ }
+ ret.right = ret.left + bitmap_w;
+ ret.bottom = ret.top + bitmap_h;
+ if (pos_wraparound != 0) {
+ if (bitmap_w < 0) {
+ ret.right = ret.left + bitmap_w + parent_graphics.bitmap_w;
+ }
+ if (bitmap_h < 0) {
+ ret.bottom = ret.top + bitmap_h + parent_graphics.bitmap_h;
+ }
+ }
+ return ret;
+ }
+
+ private class NavitView extends View implements Runnable, MenuItem.OnMenuItemClickListener {
+ int touch_mode = NONE;
+ float oldDist = 0;
+ static final int NONE = 0;
+ static final int DRAG = 1;
+ static final int ZOOM = 2;
+ static final int PRESSED = 3;
+
+ Method eventGetX = null;
+ Method eventGetY = null;
+
+ PointF mPressedPosition = null;
+
+ public NavitView(Context context) {
+ super(context);
+ try {
+ eventGetX = android.view.MotionEvent.class.getMethod("getX", int.class);
+ eventGetY = android.view.MotionEvent.class.getMethod("getY", int.class);
+ } catch (Exception e) {
+ Log.e(TAG, "Multitouch zoom not supported");
+ }
+ }
+
+ @Override
+ @TargetApi(20)
+ public WindowInsets onApplyWindowInsets (WindowInsets insets) {
+ /*
+ * We're skipping the top inset here because it appears to have a bug on most Android versions tested,
+ * causing it to report between 24 and 64 dip more than what is actually occupied by the system UI.
+ * The top inset is retrieved in handleResize(), with logic depending on the platform version.
+ */
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT_WATCH) {
+ padding_left = insets.getSystemWindowInsetLeft();
+ padding_right = insets.getSystemWindowInsetRight();
+ padding_bottom = insets.getSystemWindowInsetBottom();
+ }
+ return super.onApplyWindowInsets(insets);
+ }
+
+ @Override
+ protected void onCreateContextMenu(ContextMenu menu) {
+ super.onCreateContextMenu(menu);
+
+ menu.setHeaderTitle(activity.getTstring(R.string.position_popup_title) + "..");
+ menu.add(1, 1, NONE, activity.getTstring(R.string.position_popup_drive_here))
+ .setOnMenuItemClickListener(this);
+ menu.add(1, 2, NONE, activity.getTstring(R.string.cancel)).setOnMenuItemClickListener(this);
+ }
+
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ switch (item.getItemId()) {
+ case 1:
+ Message msg = Message.obtain(callback_handler, msg_type.CLB_SET_DISPLAY_DESTINATION.ordinal(),
+ (int)mPressedPosition.x, (int)mPressedPosition.y);
+ msg.sendToTarget();
+ break;
+ }
+ return false;
+ }
+
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ canvas.drawBitmap(draw_bitmap, pos_x, pos_y, null);
+ if (overlay_disabled == 0) {
+ // assume we ARE in map view mode!
+ in_map = true;
+ for (NavitGraphics overlay : overlays) {
+ if (overlay.overlay_disabled == 0) {
+ Rect r = overlay.get_rect();
+ canvas.drawBitmap(overlay.draw_bitmap, r.left, r.top, null);
+ }
+ }
+ } else {
+ if (Navit.show_soft_keyboard) {
+ if (Navit.mgr != null) {
+ Navit.mgr.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
+ Navit.show_soft_keyboard_now_showing = true;
+ // clear the variable now, keyboard will stay on screen until backbutton pressed
+ Navit.show_soft_keyboard = false;
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ Log.d(TAG, "onSizeChanged pixels x=" + w + " pixels y=" + h);
+ Log.d(TAG, "onSizeChanged density=" + Navit.metrics.density);
+ Log.d(TAG, "onSizeChanged scaledDensity=" + Navit.metrics.scaledDensity);
+ super.onSizeChanged(w, h, oldw, oldh);
+
+ handleResize(w, h);
+ }
+
+ void do_longpress_action() {
+ Log.d(TAG, "do_longpress_action enter");
+
+ activity.openContextMenu(this);
+ }
+
+ private int getActionField(String fieldname, Object obj) {
+ int ret_value = -999;
+ try {
+ java.lang.reflect.Field field = android.view.MotionEvent.class.getField(fieldname);
+ try {
+ ret_value = field.getInt(obj);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } catch (NoSuchFieldException ex) {
+ ex.printStackTrace();
+ }
+ return ret_value;
+ }
+
+ @SuppressLint("ClickableViewAccessibility")
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ super.onTouchEvent(event);
+ int x = (int) event.getX();
+ int y = (int) event.getY();
+
+ int _ACTION_POINTER_UP_ = getActionField("ACTION_POINTER_UP", event);
+ int _ACTION_POINTER_DOWN_ = getActionField("ACTION_POINTER_DOWN", event);
+ int _ACTION_MASK_ = getActionField("ACTION_MASK", event);
+
+ int switch_value = event.getAction();
+ if (_ACTION_MASK_ != -999) {
+ switch_value = (event.getAction() & _ACTION_MASK_);
+ }
+
+ if (switch_value == MotionEvent.ACTION_DOWN) {
+ touch_mode = PRESSED;
+ if (!in_map) {
+ ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
+ }
+ mPressedPosition = new PointF(x, y);
+ postDelayed(this, time_for_long_press);
+ } else if ((switch_value == MotionEvent.ACTION_UP) || (switch_value == _ACTION_POINTER_UP_)) {
+ Log.d(TAG, "ACTION_UP");
+
+ switch (touch_mode) {
+ case DRAG:
+ Log.d(TAG, "onTouch move");
+
+ MotionCallback(MotionCallbackID, x, y);
+ ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
+
+ break;
+ case ZOOM:
+ float newDist = spacing(getFloatValue(event, 0), getFloatValue(event, 1));
+ float scale = 0;
+ if (newDist > 10f) {
+ scale = newDist / oldDist;
+ }
+
+ if (scale > 1.3) {
+ // zoom in
+ CallbackMessageChannel(1, null);
+ } else if (scale < 0.8) {
+ // zoom out
+ CallbackMessageChannel(2, null);
+ }
+ break;
+ case PRESSED:
+ if (in_map) {
+ ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
+ }
+ ButtonCallback(ButtonCallbackID, 0, 1, x, y); // up
+
+ break;
+ }
+ touch_mode = NONE;
+ } else if (switch_value == MotionEvent.ACTION_MOVE) {
+ switch (touch_mode) {
+ case DRAG:
+ MotionCallback(MotionCallbackID, x, y);
+ break;
+ case ZOOM:
+ float newDist = spacing(getFloatValue(event, 0), getFloatValue(event, 1));
+ float scale = newDist / oldDist;
+ Log.d(TAG, "New scale = " + scale);
+ if (scale > 1.2) {
+ // zoom in
+ CallbackMessageChannel(1, "");
+ oldDist = newDist;
+ } else if (scale < 0.8) {
+ oldDist = newDist;
+ // zoom out
+ CallbackMessageChannel(2, "");
+ }
+ break;
+ case PRESSED:
+ Log.d(TAG, "Start drag mode");
+ if (spacing(mPressedPosition, new PointF(event.getX(), event.getY())) > 20f) {
+ ButtonCallback(ButtonCallbackID, 1, 1, x, y); // down
+ touch_mode = DRAG;
+ }
+ break;
+ }
+ } else if (switch_value == _ACTION_POINTER_DOWN_) {
+ oldDist = spacing(getFloatValue(event, 0), getFloatValue(event, 1));
+ if (oldDist > 2f) {
+ touch_mode = ZOOM;
+ }
+ }
+ return true;
+ }
+
+ private float spacing(PointF a, PointF b) {
+ float x = a.x - b.x;
+ float y = a.y - b.y;
+ return (float)Math.sqrt(x * x + y * y);
+ }
+
+ private PointF getFloatValue(Object instance, Object argument) {
+ PointF pos = new PointF(0,0);
+
+ if (eventGetX != null && eventGetY != null) {
+ try {
+ Float x = (java.lang.Float) eventGetX.invoke(instance, argument);
+ Float y = (java.lang.Float) eventGetY.invoke(instance, argument);
+ pos.set(x, y);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return pos;
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ int i;
+ String s = null;
+ long interval_for_long_press = 200L;
+ i = event.getUnicodeChar();
+ if (i == 0) {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_DEL:
+ s = String.valueOf((char) 8);
+ break;
+ case KeyEvent.KEYCODE_MENU:
+ if (!in_map) {
+ // if last menukeypress is less than 0.2 seconds away then count longpress
+ if ((System.currentTimeMillis() - Navit.last_pressed_menu_key) < interval_for_long_press) {
+ Navit.time_pressed_menu_key = Navit.time_pressed_menu_key
+ + (System.currentTimeMillis() - Navit.last_pressed_menu_key);
+ // on long press let softkeyboard popup
+ if (Navit.time_pressed_menu_key > time_for_long_press) {
+ Navit.show_soft_keyboard = true;
+ Navit.time_pressed_menu_key = 0L;
+ // need to draw to get the keyboard showing
+ this.postInvalidate();
+ }
+ } else {
+ Navit.time_pressed_menu_key = 0L;
+ }
+ Navit.last_pressed_menu_key = System.currentTimeMillis();
+ // if in menu view:
+ // use as OK (Enter) key
+ // dont use menu key here (use it in onKeyUp)
+ return true;
+ } else {
+ // if on map view:
+ // volume UP
+ //s = java.lang.String.valueOf((char) 1);
+ return true;
+ }
+ case KeyEvent.KEYCODE_SEARCH:
+ /* Handle event in Main Activity if map is shown */
+ if (in_map) {
+ return false;
+ }
+
+ s = String.valueOf((char) 19);
+ break;
+ case KeyEvent.KEYCODE_BACK:
+ s = String.valueOf((char) 27);
+ break;
+ case KeyEvent.KEYCODE_CALL:
+ s = String.valueOf((char) 3);
+ break;
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ if (!in_map) {
+ // if in menu view:
+ // use as UP key
+ s = String.valueOf((char) 16);
+ } else {
+ // if on map view:
+ // volume UP
+ //s = java.lang.String.valueOf((char) 21);
+ return false;
+ }
+ break;
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ if (!in_map) {
+ // if in menu view:
+ // use as DOWN key
+ s = String.valueOf((char) 14);
+ } else {
+ // if on map view:
+ // volume DOWN
+ //s = java.lang.String.valueOf((char) 4);
+ return false;
+ }
+ break;
+ case KeyEvent.KEYCODE_DPAD_CENTER:
+ s = String.valueOf((char) 13);
+ break;
+ case KeyEvent.KEYCODE_DPAD_DOWN:
+ s = String.valueOf((char) 14);
+ break;
+ case KeyEvent.KEYCODE_DPAD_LEFT:
+ s = String.valueOf((char) 2);
+ break;
+ case KeyEvent.KEYCODE_DPAD_RIGHT:
+ s = String.valueOf((char) 6);
+ break;
+ case KeyEvent.KEYCODE_DPAD_UP:
+ s = String.valueOf((char) 16);
+ break;
+ }
+ } else if (i == 10) {
+ s = java.lang.String.valueOf((char) 13);
+ }
+
+ if (s != null) {
+ KeypressCallback(KeypressCallbackID, s);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ int i;
+ String s = null;
+ i = event.getUnicodeChar();
+
+ if (i == 0) {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ return (!in_map);
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ return (!in_map);
+ case KeyEvent.KEYCODE_SEARCH:
+ /* Handle event in Main Activity if map is shown */
+ if (in_map) {
+ return false;
+ }
+ break;
+ case KeyEvent.KEYCODE_BACK:
+ if (Navit.show_soft_keyboard_now_showing) {
+ Navit.show_soft_keyboard_now_showing = false;
+ }
+ //s = java.lang.String.valueOf((char) 27);
+ return true;
+ case KeyEvent.KEYCODE_MENU:
+ if (!in_map) {
+ if (Navit.show_soft_keyboard_now_showing) {
+ // if soft keyboard showing on screen, dont use menu button as select key
+ } else {
+ // if in menu view:
+ // use as OK (Enter) key
+ s = String.valueOf((char) 13);
+ }
+ } else {
+ // if on map view:
+ // volume UP
+ //s = java.lang.String.valueOf((char) 1);
+ return false;
+ }
+ break;
+ }
+ } else if (i != 10) {
+ s = java.lang.String.valueOf((char) i);
+ }
+
+ if (s != null) {
+ KeypressCallback(KeypressCallbackID, s);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onKeyMultiple(int keyCode, int count, KeyEvent event) {
+ String s;
+ if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
+ s = event.getCharacters();
+ KeypressCallback(KeypressCallbackID, s);
+ return true;
+ }
+ return super.onKeyMultiple(keyCode, count, event);
+ }
+
+ @Override
+ public boolean onTrackballEvent(MotionEvent event) {
+ String s = null;
+ if (event.getAction() == android.view.MotionEvent.ACTION_DOWN) {
+ s = java.lang.String.valueOf((char) 13);
+ }
+ if (event.getAction() == android.view.MotionEvent.ACTION_MOVE) {
+ trackball_x += event.getX();
+ trackball_y += event.getY();
+ if (trackball_x <= -1) {
+ s = java.lang.String.valueOf((char) 2);
+ trackball_x += 1;
+ }
+ if (trackball_x >= 1) {
+ s = java.lang.String.valueOf((char) 6);
+ trackball_x -= 1;
+ }
+ if (trackball_y <= -1) {
+ s = java.lang.String.valueOf((char) 16);
+ trackball_y += 1;
+ }
+ if (trackball_y >= 1) {
+ s = java.lang.String.valueOf((char) 14);
+ trackball_y -= 1;
+ }
+ }
+ if (s != null) {
+ KeypressCallback(KeypressCallbackID, s);
+ }
+ return true;
+ }
+
+ public void run() {
+ if (in_map && touch_mode == PRESSED) {
+ do_longpress_action();
+ touch_mode = NONE;
+ }
+ }
+
+ }
+
+ private class SystemBarTintView extends View {
+
+ public SystemBarTintView(Context context) {
+ super(context);
+ this.setBackgroundColor(bgcolor);
+ }
+
+ }
+
+ public NavitGraphics(final Activity activity, NavitGraphics parent, int x, int y, int w, int h,
+ int wraparound, int use_camera) {
+ if (parent == null) {
+ if (use_camera != 0) {
+ addCamera();
+ }
+ setActivity(activity);
+ } else {
+ draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ bitmap_w = w;
+ bitmap_h = h;
+ pos_x = x;
+ pos_y = y;
+ pos_wraparound = wraparound;
+ draw_canvas = new Canvas(draw_bitmap);
+ parent.overlays.add(this);
+ }
+ parent_graphics = parent;
+ }
+
+ /**
+ * @brief Sets up the main activity.
+ *
+ * @param activity The main activity.
+ */
+ protected void setActivity(final Activity activity) {
+ if (Navit.graphics == null)
+ Navit.graphics = this;
+ this.activity = (Navit) activity;
+ view = new NavitView(activity);
+ view.setClickable(false);
+ view.setFocusable(true);
+ view.setFocusableInTouchMode(true);
+ view.setKeepScreenOn(true);
+ relativelayout = new RelativeLayout(activity);
+ addCameraView();
+ relativelayout.addView(view);
+
+ /* The navigational and status bar tinting code is meaningful only on API19+ */
+ if (Build.VERSION.SDK_INT >= 19) {
+ frameLayout = new FrameLayout(activity);
+ frameLayout.addView(relativelayout);
+ leftTintView = new SystemBarTintView(activity);
+ rightTintView = new SystemBarTintView(activity);
+ topTintView = new SystemBarTintView(activity);
+ bottomTintView = new SystemBarTintView(activity);
+ frameLayout.addView(leftTintView);
+ frameLayout.addView(rightTintView);
+ frameLayout.addView(topTintView);
+ frameLayout.addView(bottomTintView);
+ activity.setContentView(frameLayout);
+ } else {
+ activity.setContentView(relativelayout);
+ }
+
+ view.requestFocus();
+ }
+
+ public enum msg_type {
+ CLB_ZOOM_IN, CLB_ZOOM_OUT, CLB_REDRAW, CLB_MOVE, CLB_BUTTON_UP, CLB_BUTTON_DOWN, CLB_SET_DESTINATION,
+ CLB_SET_DISPLAY_DESTINATION, CLB_CALL_CMD, CLB_COUNTRY_CHOOSER, CLB_LOAD_MAP, CLB_UNLOAD_MAP, CLB_DELETE_MAP
+ }
+
+ static private final msg_type[] msg_values = msg_type.values();
+
+ public final Handler callback_handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg_values[msg.what]) {
+ case CLB_ZOOM_IN:
+ CallbackMessageChannel(1, "");
+ break;
+ case CLB_ZOOM_OUT:
+ CallbackMessageChannel(2, "");
+ break;
+ case CLB_MOVE:
+ MotionCallback(MotionCallbackID, msg.getData().getInt("x"), msg.getData().getInt("y"));
+ break;
+ case CLB_SET_DESTINATION:
+ String lat = Float.toString(msg.getData().getFloat("lat"));
+ String lon = Float.toString(msg.getData().getFloat("lon"));
+ String q = msg.getData().getString(("q"));
+ CallbackMessageChannel(3, lat + "#" + lon + "#" + q);
+ break;
+ case CLB_SET_DISPLAY_DESTINATION:
+ int x = msg.arg1;
+ int y = msg.arg2;
+ CallbackMessageChannel(4, "" + x + "#" + y);
+ break;
+ case CLB_CALL_CMD:
+ String cmd = msg.getData().getString(("cmd"));
+ CallbackMessageChannel(5, cmd);
+ break;
+ case CLB_BUTTON_UP:
+ ButtonCallback(ButtonCallbackID, 0, 1, msg.getData().getInt("x"), msg.getData().getInt("y")); // up
+ break;
+ case CLB_BUTTON_DOWN:
+ // down
+ ButtonCallback(ButtonCallbackID, 1, 1, msg.getData().getInt("x"), msg.getData().getInt("y"));
+ break;
+ case CLB_COUNTRY_CHOOSER:
+ break;
+ case CLB_LOAD_MAP:
+ CallbackMessageChannel(6, msg.getData().getString(("title")));
+ break;
+ case CLB_DELETE_MAP:
+ File toDelete = new File(msg.getData().getString(("title")));
+ toDelete.delete();
+ //fallthrough
+ case CLB_UNLOAD_MAP:
+ CallbackMessageChannel(7, msg.getData().getString(("title")));
+ break;
+ }
+ }
+ };
+
+ public native void SizeChangedCallback(int id, int x, int y);
+
+ public native void PaddingChangedCallback(int id, int left, int right, int top, int bottom);
+
+ public native void KeypressCallback(int id, String s);
+
+ public native int CallbackMessageChannel(int i, String s);
+
+ public native void ButtonCallback(int id, int pressed, int button, int x, int y);
+
+ public native void MotionCallback(int id, int x, int y);
+
+ public native String GetDefaultCountry(int id, String s);
+
+ public static native String[][] GetAllCountries();
+
+ private Canvas draw_canvas;
+ private Bitmap draw_bitmap;
+ private int SizeChangedCallbackID;
+ private int PaddingChangedCallbackID;
+ private int ButtonCallbackID;
+ private int MotionCallbackID;
+ private int KeypressCallbackID;
+
+ /**
+ * @brief Adjust views used to tint navigation and status bars.
+ *
+ * This method is called from handleResize.
+ *
+ * It (re-)evaluates if and where the navigation bar is going to be shown, and calculates the
+ * padding for objects which should not be obstructed.
+ *
+ */
+ private void adjustSystemBarsTintingViews() {
+ /* hide tint bars during update to prevent ugly effects */
+ leftTintView.setVisibility(View.GONE);
+ rightTintView.setVisibility(View.GONE);
+ topTintView.setVisibility(View.GONE);
+ bottomTintView.setVisibility(View.GONE);
+
+ frameLayout.post(new Runnable() {
+ @Override
+ public void run() {
+ FrameLayout.LayoutParams leftLayoutParams = new FrameLayout.LayoutParams(padding_left,
+ LayoutParams.MATCH_PARENT, Gravity.BOTTOM | Gravity.LEFT);
+ leftTintView.setLayoutParams(leftLayoutParams);
+
+ FrameLayout.LayoutParams rightLayoutParams = new FrameLayout.LayoutParams(padding_right,
+ LayoutParams.MATCH_PARENT, Gravity.BOTTOM | Gravity.RIGHT);
+ rightTintView.setLayoutParams(rightLayoutParams);
+
+ FrameLayout.LayoutParams topLayoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+ padding_top, Gravity.TOP);
+ /* Prevent horizontal and vertical tint views from overlapping */
+ topLayoutParams.setMargins(padding_left, 0, padding_right, 0);
+ topTintView.setLayoutParams(topLayoutParams);
+
+ FrameLayout.LayoutParams bottomLayoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+ padding_bottom, Gravity.BOTTOM);
+ /* Prevent horizontal and vertical tint views from overlapping */
+ bottomLayoutParams.setMargins(padding_left, 0, padding_right, 0);
+ bottomTintView.setLayoutParams(bottomLayoutParams);
+
+ /* show tint bars again */
+ leftTintView.setVisibility(View.VISIBLE);
+ rightTintView.setVisibility(View.VISIBLE);
+ topTintView.setVisibility(View.VISIBLE);
+ bottomTintView.setVisibility(View.VISIBLE);
+ }
+ });
+
+ PaddingChangedCallback(PaddingChangedCallbackID, padding_left, padding_top, padding_right, padding_bottom);
+ }
+
+ /**
+ * @brief Handles resize events.
+ *
+ * This method is called whenever the main View is resized in any way. This is the case when its
+ * {@code onSizeChanged()} event handler fires or when toggling Fullscreen mode.
+ *
+ */
+ @TargetApi(23)
+ public void handleResize(int w, int h) {
+ if (this.parent_graphics != null) {
+ this.parent_graphics.handleResize(w, h);
+ } else {
+ Log.d(TAG, String.format("handleResize w=%d h=%d", w, h));
+
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
+ /*
+ * On API 23+ we can query window insets to determine the area which is obscured by the system bars.
+ * This appears to have a bug, though, causing an inset to be reported for the navigation bar even
+ * when it is not obstructing the window. Therefore, we are relying on the values previously obtained
+ * by NavitView#onApplyWindowInsets(), though this is affected by a different bug. Luckily, the two
+ * bugs appear to be complementary, allowing us to mix and match results.
+ */
+ if (view == null) {
+ Log.w(TAG, "view is null, cannot update padding");
+ } else {
+ Log.d(TAG, String.format("view w=%d h=%d x=%.0f y=%.0f",
+ view.getWidth(), view.getHeight(), view.getX(), view.getY()));
+ if (view.getRootWindowInsets() == null)
+ Log.w(TAG, "No root window insets, cannot update padding");
+ else {
+ Log.d(TAG, String.format("RootWindowInsets left=%d right=%d top=%d bottom=%d",
+ view.getRootWindowInsets().getSystemWindowInsetLeft(),
+ view.getRootWindowInsets().getSystemWindowInsetRight(),
+ view.getRootWindowInsets().getSystemWindowInsetTop(),
+ view.getRootWindowInsets().getSystemWindowInsetBottom()));
+ padding_top = view.getRootWindowInsets().getSystemWindowInsetTop();
+ }
+ }
+ } else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT_WATCH) {
+ /*
+ * API 20-22 do not support root window insets, forcing us to make an educated guess about the
+ * navigation bar height:
+ *
+ * The size is a platform default and does not change with rotation, but we have to figure out if it
+ * applies, i.e. if the status bar is visible.
+ *
+ * The status bar is always visible unless we are in fullscreen mode. (Fortunately, none of the
+ * versions affected by this support split screen mode, which would have further complicated things.)
+ */
+ if (activity.isFullscreen)
+ padding_top = 0;
+ else {
+ Resources resources = view.getResources();
+ int shid = resources.getIdentifier("status_bar_height", "dimen", "android");
+ padding_top = (shid > 0) ? resources.getDimensionPixelSize(shid) : 0;
+ }
+ } else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
+ /*
+ * API 19 does not support window insets at all, forcing us to do even more guessing than on API 20-22:
+ *
+ * All system bar sizes are platform defaults and do not change with rotation, but we have
+ * to figure out which ones apply.
+ *
+ * Status bar visibility is as on API 20-22.
+ *
+ * The navigation bar is shown on devices that report they have no physical menu button. This seems to
+ * work even on devices that allow disabling the physical buttons (and use the navigation bar, in which
+ * case they report no physical menu button is available; tested with a OnePlus One running CyanogenMod).
+ *
+ * If shown, the navigation bar may appear on the side or at the bottom. The logic to determine this is
+ * taken from AOSP RenderSessionImpl.findNavigationBar()
+ * platform/frameworks/base/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+ */
+ Resources resources = view.getResources();
+ int shid = resources.getIdentifier("status_bar_height", "dimen", "android");
+ int adhid = resources.getIdentifier("action_bar_default_height", "dimen", "android");
+ int nhid = resources.getIdentifier("navigation_bar_height", "dimen", "android");
+ int nhlid = resources.getIdentifier("navigation_bar_height_landscape", "dimen", "android");
+ int nwid = resources.getIdentifier("navigation_bar_width", "dimen", "android");
+ int status_bar_height = (shid > 0) ? resources.getDimensionPixelSize(shid) : 0;
+ int action_bar_default_height = (adhid > 0) ? resources.getDimensionPixelSize(adhid) : 0;
+ int navigation_bar_height = (nhid > 0) ? resources.getDimensionPixelSize(nhid) : 0;
+ int navigation_bar_height_landscape = (nhlid > 0) ? resources.getDimensionPixelSize(nhlid) : 0;
+ int navigation_bar_width = (nwid > 0) ? resources.getDimensionPixelSize(nwid) : 0;
+ Log.d(TAG, String.format(
+ "status_bar_height=%d, action_bar_default_height=%d, navigation_bar_height=%d, "
+ + "navigation_bar_height_landscape=%d, navigation_bar_width=%d",
+ status_bar_height, action_bar_default_height, navigation_bar_height,
+ navigation_bar_height_landscape, navigation_bar_width));
+
+ if (activity == null) {
+ Log.w(TAG, "Main Activity is not a Navit instance, cannot update padding");
+ } else if (frameLayout != null) {
+ /* frameLayout is only created on platforms supporting navigation and status bar tinting */
+
+ Navit navit = activity;
+ boolean isStatusShowing = !navit.isFullscreen;
+ boolean isNavShowing = !ViewConfigurationCompat.hasPermanentMenuKey(ViewConfiguration.get(navit));
+ Log.d(TAG, String.format("isStatusShowing=%b isNavShowing=%b", isStatusShowing, isNavShowing));
+
+ boolean isLandscape = (navit.getResources().getConfiguration().orientation
+ == Configuration.ORIENTATION_LANDSCAPE);
+ boolean isNavAtBottom = (!isLandscape)
+ || (navit.getResources().getConfiguration().smallestScreenWidthDp >= 600);
+ Log.d(TAG, String.format("isNavAtBottom=%b (Configuration.smallestScreenWidthDp=%d, isLandscape=%b)",
+ isNavAtBottom, navit.getResources().getConfiguration().smallestScreenWidthDp, isLandscape));
+
+ padding_left = 0;
+ padding_top = isStatusShowing ? status_bar_height : 0;
+ padding_right = (isNavShowing && !isNavAtBottom) ? navigation_bar_width : 0;
+ padding_bottom = (!(isNavShowing && isNavAtBottom)) ? 0 : (
+ isLandscape ? navigation_bar_height_landscape : navigation_bar_height);
+ }
+ } else {
+ /* API 18 and below does not support drawing under the system bars, padding is 0 all around */
+ padding_left = 0;
+ padding_right = 0;
+ padding_top = 0;
+ padding_bottom = 0;
+ }
+
+ Log.d(TAG, String.format("Padding left=%d top=%d right=%d bottom=%d",
+ padding_left, padding_top, padding_right, padding_bottom));
+
+ adjustSystemBarsTintingViews();
+
+ draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ draw_canvas = new Canvas(draw_bitmap);
+ bitmap_w = w;
+ bitmap_h = h;
+ SizeChangedCallback(SizeChangedCallbackID, w, h);
+ }
+ }
+
+ /**
+ * @brief Returns whether the device has a hardware menu button.
+ *
+ * Only Android versions starting with ICS (API version 14) support the API call to detect the presence of a
+ * Menu button. On earlier Android versions, the following assumptions will be made: On API levels up to 10,
+ * this method will always return {@code true}, as these Android versions relied on devices having a physical
+ * Menu button. On API levels 11 through 13 (Honeycomb releases), this method will always return
+ * {@code false}, as Honeycomb was a tablet-only release and did not require devices to have a Menu button.
+ *
+ * Note that this method is not aware of non-standard mechanisms on some customized builds of Android. For
+ * example, CyanogenMod has an option to add a menu button to the navigation bar. Even with that option,
+ * this method will still return `false`.
+ */
+ public boolean hasMenuButton() {
+ if (Build.VERSION.SDK_INT <= 10) {
+ return true;
+ } else {
+ if (Build.VERSION.SDK_INT <= 13) {
+ return false;
+ } else {
+ return ViewConfiguration.get(activity.getApplication()).hasPermanentMenuKey();
+ }
+ }
+ }
+
+ public void setSizeChangedCallback(int id) {
+ SizeChangedCallbackID = id;
+ }
+
+ public void setPaddingChangedCallback(int id) {
+ PaddingChangedCallbackID = id;
+ }
+
+ public void setButtonCallback(int id) {
+ ButtonCallbackID = id;
+ }
+
+ public void setMotionCallback(int id) {
+ MotionCallbackID = id;
+ if (activity != null) {
+ activity.setMotionCallback(id, this);
+ }
+ }
+
+ public void setKeypressCallback(int id) {
+ KeypressCallbackID = id;
+ // set callback id also in main intent (for menus)
+ if (activity != null) {
+ activity.setKeypressCallback(id, this);
+ }
+ }
+
+
+ protected void draw_polyline(Paint paint, int[] c) {
+ paint.setStrokeWidth(c[0]);
+ paint.setARGB(c[1],c[2],c[3],c[4]);
+ paint.setStyle(Paint.Style.STROKE);
+ //paint.setAntiAlias(true);
+ //paint.setStrokeWidth(0);
+ int ndashes = c[5];
+ float[] intervals = new float[ndashes + (ndashes % 2)];
+ for (int i = 0; i < ndashes; i++) {
+ intervals[i] = c[6 + i];
+ }
+
+ if ((ndashes % 2) == 1) {
+ intervals[ndashes] = intervals[ndashes - 1];
+ }
+
+ if (ndashes > 0) {
+ paint.setPathEffect(new android.graphics.DashPathEffect(intervals,0.0f));
+ }
+
+ Path path = new Path();
+ path.moveTo(c[6 + ndashes], c[7 + ndashes]);
+ for (int i = 8 + ndashes; i < c.length; i += 2) {
+ path.lineTo(c[i], c[i + 1]);
+ }
+ //global_path.close();
+ draw_canvas.drawPath(path, paint);
+ paint.setPathEffect(null);
+ }
+
+ protected void draw_polygon(Paint paint, int[] c) {
+ paint.setStrokeWidth(c[0]);
+ paint.setARGB(c[1],c[2],c[3],c[4]);
+ paint.setStyle(Paint.Style.FILL);
+ //paint.setAntiAlias(true);
+ //paint.setStrokeWidth(0);
+ Path path = new Path();
+ path.moveTo(c[5], c[6]);
+ for (int i = 7; i < c.length; i += 2) {
+ path.lineTo(c[i], c[i + 1]);
+ }
+ //global_path.close();
+ draw_canvas.drawPath(path, paint);
+ }
+
+ protected void draw_rectangle(Paint paint, int x, int y, int w, int h) {
+ Rect r = new Rect(x, y, x + w, y + h);
+ paint.setStyle(Paint.Style.FILL);
+ paint.setAntiAlias(true);
+ //paint.setStrokeWidth(0);
+ draw_canvas.drawRect(r, paint);
+ }
+
+ protected void draw_circle(Paint paint, int x, int y, int r) {
+ paint.setStyle(Paint.Style.STROKE);
+ draw_canvas.drawCircle(x, y, r / 2, paint);
+ }
+
+ protected void draw_text(Paint paint, int x, int y, String text, int size, int dx, int dy, int bgcolor) {
+ int oldcolor = paint.getColor();
+ Path path = null;
+
+ paint.setTextSize(size / 15);
+ paint.setStyle(Paint.Style.FILL);
+
+ if (dx != 0x10000 || dy != 0) {
+ path = new Path();
+ path.moveTo(x, y);
+ path.rLineTo(dx, dy);
+ paint.setTextAlign(android.graphics.Paint.Align.LEFT);
+ }
+
+ if (bgcolor != 0) {
+ paint.setStrokeWidth(3);
+ paint.setColor(bgcolor);
+ paint.setStyle(Paint.Style.STROKE);
+ if (path == null) {
+ draw_canvas.drawText(text, x, y, paint);
+ } else {
+ draw_canvas.drawTextOnPath(text, path, 0, 0, paint);
+ }
+ paint.setStyle(Paint.Style.FILL);
+ paint.setColor(oldcolor);
+ }
+
+ if (path == null) {
+ draw_canvas.drawText(text, x, y, paint);
+ } else {
+ draw_canvas.drawTextOnPath(text, path, 0, 0, paint);
+ }
+ paint.clearShadowLayer();
+ }
+
+ protected void draw_image(Paint paint, int x, int y, Bitmap bitmap) {
+ draw_canvas.drawBitmap(bitmap, x, y, null);
+ }
+
+ /* takes an image and draws it on the screen as a prerendered maptile
+ *
+ *
+ *
+ * @param paint Paint object used to draw the image
+ * @param count the number of points specified
+ * @param p0x and p0y specifying the top left point
+ * @param p1x and p1y specifying the top right point
+ * @param p2x and p2y specifying the bottom left point, not yet used but kept
+ * for compatibility with the linux port
+ * @param bitmap Bitmap object holding the image to draw
+ *
+ * TODO make it work with 4 points specified to make it work for 3D mapview, so it can be used
+ * for small but very detailed maps as well as for large maps with very little detail but large
+ * coverage.
+ * TODO make it work with rectangular tiles as well ?
+ */
+ protected void draw_image_warp(Paint paint, int count, int p0x, int p0y, int p1x, int p1y, int p2x, int p2y,
+ Bitmap bitmap) {
+
+ float width;
+ float scale;
+ float deltaY;
+ float deltaX;
+ float angle;
+ Matrix matrix;
+
+ if (count == 3) {
+ matrix = new Matrix();
+ deltaX = p1x - p0x;
+ deltaY = p1y - p0y;
+ width = (float) (Math.sqrt((deltaX * deltaX) + (deltaY * deltaY)));
+ angle = (float) (Math.atan2(deltaY, deltaX) * 180d / Math.PI);
+ scale = width / bitmap.getWidth();
+ matrix.preScale(scale, scale);
+ matrix.postTranslate(p0x, p0y);
+ matrix.postRotate(angle, p0x, p0y);
+ draw_canvas.drawBitmap(bitmap, matrix, paint);
+ }
+ }
+
+ /* These constants must be synchronized with enum draw_mode_num in graphics.h. */
+ private static final int draw_mode_begin = 0;
+ private static final int draw_mode_end = 1;
+
+ protected void draw_mode(int mode) {
+ if (mode == draw_mode_end) {
+ if (parent_graphics == null) {
+ view.invalidate();
+ } else {
+ parent_graphics.view.invalidate(get_rect());
+ }
+ }
+ if (mode == draw_mode_begin && parent_graphics != null) {
+ draw_bitmap.eraseColor(0);
+ }
+
+ }
+
+ protected void draw_drag(int x, int y) {
+ pos_x = x;
+ pos_y = y;
+ }
+
+ protected void overlay_disable(int disable) {
+ Log.d(TAG,"overlay_disable: " + disable + "Parent: " + (parent_graphics != null));
+ // assume we are NOT in map view mode!
+ if (parent_graphics == null) {
+ in_map = (disable == 0);
+ }
+ if (overlay_disabled != disable) {
+ overlay_disabled = disable;
+ if (parent_graphics != null) {
+ parent_graphics.view.invalidate(get_rect());
+ }
+ }
+ }
+
+ protected void overlay_resize(int x, int y, int w, int h, int wraparound) {
+ draw_bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ bitmap_w = w;
+ bitmap_h = h;
+ pos_x = x;
+ pos_y = y;
+ pos_wraparound = wraparound;
+ draw_canvas.setBitmap(draw_bitmap);
+ }
+
+ public static native String CallbackLocalizedString(String s);
}
diff --git a/navit/android/src/org/navitproject/navit/NavitMap.java b/navit/android/src/org/navitproject/navit/NavitMap.java
index b7bd265a4..ee0f11bb7 100644
--- a/navit/android/src/org/navitproject/navit/NavitMap.java
+++ b/navit/android/src/org/navitproject/navit/NavitMap.java
@@ -3,38 +3,38 @@ package org.navitproject.navit;
import java.io.File;
public class NavitMap {
- String fileName;
- String mapName;
- String mapPath;
+ private String fileName;
+ String mapName;
+ private String mapPath;
- public NavitMap(String path, String map_file_name) {
- mapPath = path;
- fileName = map_file_name;
- if (map_file_name.endsWith(".bin")) {
- mapName = map_file_name.substring(0, map_file_name.length() - 4);
- } else {
- mapName = map_file_name;
- }
- }
+ NavitMap(String path, String map_file_name) {
+ mapPath = path;
+ fileName = map_file_name;
+ if (map_file_name.endsWith(".bin")) {
+ mapName = map_file_name.substring(0, map_file_name.length() - 4);
+ } else {
+ mapName = map_file_name;
+ }
+ }
- public NavitMap(String map_location) {
- File mapFile = new File(map_location);
-
- mapPath = mapFile.getParent() + "/";
- fileName = mapFile.getName();
- if (fileName.endsWith(".bin")) {
- mapName = fileName.substring(0, fileName.length() - 4);
- } else {
- mapName = fileName;
- }
- }
+ NavitMap(String map_location) {
+ File mapFile = new File(map_location);
- public long size() {
- File map_file = new File(mapPath + fileName);
- return map_file.length();
- }
+ mapPath = mapFile.getParent() + "/";
+ fileName = mapFile.getName();
+ if (fileName.endsWith(".bin")) {
+ mapName = fileName.substring(0, fileName.length() - 4);
+ } else {
+ mapName = fileName;
+ }
+ }
- public String getLocation() {
- return mapPath + fileName;
- }
+ public long size() {
+ File map_file = new File(mapPath + fileName);
+ return map_file.length();
+ }
+
+ public String getLocation() {
+ return mapPath + fileName;
+ }
}
diff --git a/navit/android/src/org/navitproject/navit/NavitMapDownloader.java b/navit/android/src/org/navitproject/navit/NavitMapDownloader.java
index feda451b8..c2c40fe2e 100644
--- a/navit/android/src/org/navitproject/navit/NavitMapDownloader.java
+++ b/navit/android/src/org/navitproject/navit/NavitMapDownloader.java
@@ -1,711 +1,951 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-package org.navitproject.navit;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import android.location.Location;
-import android.os.Bundle;
-import android.os.Message;
-import android.os.StatFs;
-import android.util.Log;
-
-/**
- * @author rikky
- *
- */
-public class NavitMapDownloader extends Thread
-{
- public static class osm_map_values
- {
- String lon1;
- String lat1;
- String lon2;
- String lat2;
- String map_name = "";
- long est_size_bytes = 0;
- int level = 0;
-
-
- public osm_map_values(String mapname, String lon_1, String lat_1, String lon_2, String lat_2,
- long bytes_est, int level)
- {
- this.map_name = mapname;
- this.lon1 = lon_1;
- this.lat1 = lat_1;
- this.lon2 = lon_2;
- this.lat2 = lat_2;
- this.est_size_bytes = bytes_est;
- this.level = level;
- }
-
- public boolean isInMap(Location location) {
- double longitude_1 = Double.valueOf(this.lon1);
- double latitude_1 = Double.valueOf(this.lat1);
- double longitude_2 = Double.valueOf(this.lon2);
- double latitude_2 = Double.valueOf(this.lat2);
-
- if (location.getLongitude() < longitude_1)
- return false;
- if (location.getLongitude() > longitude_2)
- return false;
- if (location.getLatitude() < latitude_1)
- return false;
- if (location.getLatitude() > latitude_2)
- return false;
-
- return true;
- }
- }
-
- //
- // define the maps here
- // size estimations updated 2017-06-22
- //
- public static final osm_map_values[] osm_maps = {
- new osm_map_values(Navit.T("Whole Planet"), "-180", "-90", "180", "90", 23992258630L, 0),
- new osm_map_values(Navit.T("Africa"), "-30.89", "-36.17", "61.68", "38.40", 2070076339L, 0),
- new osm_map_values(Navit.T("Angola"), "11.4", "-18.1", "24.2", "-5.3", 127557789L, 1),
- new osm_map_values(Navit.T("Burundi"), "28.9", "-4.5", "30.9", "-2.2", 124049667L, 1),
- new osm_map_values(Navit.T("Canary Islands"), "-18.69", "26.52", "-12.79", "29.99", 133565815L, 1),
- new osm_map_values(Navit.T("Congo, Democratic Republic of the"), "11.7", "-13.6", "31.5", "5.7", 244228485L, 1),
- new osm_map_values(Navit.T("Ethiopia"), "32.89", "3.33", "48.07", "14.97", 153067406L, 1),
- new osm_map_values(Navit.T("Guinea"), "-15.47", "7.12", "-7.58", "12.74", 188047126L, 1),
- new osm_map_values(Navit.T("Cote d'Ivoire"), "-8.72", "4.09", "-2.43", "10.80", 132187496L, 1),
- new osm_map_values(Navit.T("Kenya"), "33.8", "-5.2", "42.4", "4.9", 190073089L, 1),
- new osm_map_values(Navit.T("Lesotho"), "26.9", "-30.7", "29.6", "-28.4", 196189429L, 1),
- new osm_map_values(Navit.T("Liberia"), "-15.00", "-0.73", "-7.20", "8.65", 156257253L, 1),
- new osm_map_values(Navit.T("Libya"), "9.32", "19.40", "25.54", "33.63", 126046917L, 1),
- new osm_map_values(Navit.T("Madagascar"), "42.25", "-26.63", "51.20", "-11.31", 145210721L, 1),
- new osm_map_values(Navit.T("Namibia")+"+"+Navit.T("Botswana"), "11.4", "-29.1", "29.5", "-16.9", 248970987L, 1),
- new osm_map_values(Navit.T("Reunion"), "55.2", "-21.4", "55.9", "-20.9", 126008774L, 1),
- new osm_map_values(Navit.T("Rwanda"), "28.8", "-2.9", "30.9", "-1.0", 128267595L, 1),
- new osm_map_values(Navit.T("South Africa")+"+"+Navit.T("Lesotho"), "15.93", "-36.36", "33.65", "-22.08", 307280006L, 1),
- new osm_map_values(Navit.T("Tanzania, United Republic of"), "29.19", "-11.87", "40.74", "-0.88", 253621029L, 1),
- new osm_map_values(Navit.T("Uganda"), "29.3", "-1.6", "35.1", "4.3", 179134521L, 1),
- new osm_map_values(Navit.T("Asia"), "23.8", "0.1", "195.0", "82.4", 5113673780L, 0),
- new osm_map_values(Navit.T("Azerbaijan"), "44.74", "38.34", "51.69", "42.37", 138346406L, 1),
- new osm_map_values(Navit.T("China"), "67.3", "5.3", "135.0", "54.5", 1718108758L, 1),
- new osm_map_values(Navit.T("Cyprus"), "32.0", "34.5", "34.9", "35.8", 118472448L, 1),
- new osm_map_values(Navit.T("India")+"+"+Navit.T("Nepal"), "67.9", "5.5", "89.6", "36.0", 601877877L, 1),
- new osm_map_values(Navit.T("Indonesia"), "93.7", "-17.3", "155.5", "7.6", 420741405L, 1),
- new osm_map_values(Navit.T("Iran, Islamic Republic of"), "43.5", "24.4", "63.6", "40.4", 242016066L, 1),
- new osm_map_values(Navit.T("Iraq"), "38.7", "28.5", "49.2", "37.4", 160751805L, 1),
- new osm_map_values(Navit.T("Israel"), "33.99", "29.8", "35.95", "33.4", 155685778L, 1),
- new osm_map_values(Navit.T("Japan")+"+"+Navit.T("Korea"), "123.6", "25.2", "151.3", "47.1", 1029080156L, 1),
- new osm_map_values(Navit.T("Kazakhstan"), "46.44", "40.89", "87.36", "55.45", 407633007L, 1),
- new osm_map_values(Navit.T("Kyrgyzstan"), "69.23", "39.13", "80.33", "43.29", 147997835L, 1),
- new osm_map_values(Navit.T("Malaysia")+"+"+Navit.T("Singapore"), "94.3", "-5.9", "108.6", "6.8", 168816435L, 1),
- new osm_map_values(Navit.T("Mongolia"), "87.5", "41.4", "120.3", "52.7", 153534851L, 1),
- new osm_map_values(Navit.T("Pakistan"), "60.83", "23.28", "77.89", "37.15", 217644321L, 1),
- new osm_map_values(Navit.T("Philippines"), "115.58", "4.47", "127.85", "21.60", 281428307L, 1),
- new osm_map_values(Navit.T("Saudi Arabia"), "33.2", "16.1", "55.9", "33.5", 242648303L, 1),
- new osm_map_values(Navit.T("Taiwan"), "119.1", "21.5", "122.5", "25.2", 1029080156L, 1),
- new osm_map_values(Navit.T("Thailand"), "97.5", "5.7", "105.2", "19.7", 185135492L, 1),
- new osm_map_values(Navit.T("Turkey"), "25.1", "35.8", "46.4", "42.8", 331087441L, 1),
- new osm_map_values(Navit.T("Turkmenistan"), "51.78", "35.07", "66.76", "42.91", 131045087L, 1),
- new osm_map_values(Navit.T("UAE+Other"), "51.5", "22.6", "56.7", "26.5", 128934674L, 1),
- new osm_map_values(Navit.T("Australia")+"+"+Navit.T("Oceania"), "89.84", "-57.39", "179.79", "7.26", 782722650L, 0),
- new osm_map_values(Navit.T("Australia"), "110.5", "-44.2", "154.9", "-9.2", 348652900L, 0),
- new osm_map_values(Navit.T("Tasmania"), "144.0", "-45.1", "155.3", "-24.8", 253231890L, 1),
- new osm_map_values(Navit.T("Victoria")+"+"+Navit.T("New South Wales"), "140.7", "-39.4", "153.7", "-26.9", 241500829L, 1),
- new osm_map_values(Navit.T("New Caledonia"), "157.85", "-25.05", "174.15", "-16.85", 115512336L, 1),
- new osm_map_values(Navit.T("New Zealand"), "165.2", "-47.6", "179.1", "-33.7", 239264192L, 1),
- new osm_map_values(Navit.T("Europe"), "-12.97", "33.59", "34.15", "72.10", 11984126789L, 0),
- new osm_map_values(Navit.T("Western Europe"), "-17.6", "34.5", "42.9", "70.9", 12648810717L, 1),
- new osm_map_values(Navit.T("Austria"), "9.4", "46.32", "17.21", "49.1", 898273634L, 1),
- new osm_map_values(Navit.T("Azores"), "-31.62", "36.63", "-24.67", "40.13", 112687225L, 1),
- new osm_map_values(Navit.T("BeNeLux"), "2.08", "48.87", "7.78", "54.52", 1771971595L, 1),
- new osm_map_values(Navit.T("Netherlands"), "3.07", "50.75", "7.23", "53.73", 1191828033L, 1),
- new osm_map_values(Navit.T("Denmark"), "7.65", "54.32", "15.58", "58.07", 365606979L, 1),
- new osm_map_values(Navit.T("Faroe Islands"), "-7.8", "61.3", "-6.1", "62.5", 109377568L, 1),
- new osm_map_values(Navit.T("France"), "-5.45", "42.00", "8.44", "51.68", 3907969744L, 1),
- new osm_map_values(Navit.T("Alsace"), "6.79", "47.27", "8.48", "49.17", 354249349L, 2),
- new osm_map_values(Navit.T("Aquitaine"), "-2.27", "42.44", "1.50", "45.76", 443715019L, 2),
- new osm_map_values(Navit.T("Auvergne"), "2.01", "44.57", "4.54", "46.85", 287663213L, 2),
- new osm_map_values(Navit.T("Basse-Normandie"), "-2.09", "48.13", "1.03", "49.98", 262352354L, 2),
- new osm_map_values(Navit.T("Bourgogne"), "2.80", "46.11", "5.58", "48.45", 298868796L, 2),
- new osm_map_values(Navit.T("Bretagne"), "-5.58", "46.95", "-0.96", "48.99", 382770794L, 2),
- new osm_map_values(Navit.T("Centre"), "0.01", "46.29", "3.18", "48.99", 474224721L, 2),
- new osm_map_values(Navit.T("Champagne-Ardenne"), "3.34", "47.53", "5.94", "50.28", 269947824L, 2),
- new osm_map_values(Navit.T("Corse"), "8.12", "41.32", "9.95", "43.28", 129902146L, 2),
- new osm_map_values(Navit.T("Franche-Comte"), "5.20", "46.21", "7.83", "48.07", 324476070L, 2),
- new osm_map_values(Navit.T("Haute-Normandie"), "-0.15", "48.62", "1.85", "50.18", 202782876L, 2),
- new osm_map_values(Navit.T("Ile-de-France"), "1.40", "48.07", "3.61", "49.29", 311052699L, 2),
- new osm_map_values(Navit.T("Languedoc-Roussillon"), "1.53", "42.25", "4.89", "45.02", 380145667L, 2),
- new osm_map_values(Navit.T("Limousin"), "0.58", "44.87", "2.66", "46.50", 206696539L, 2),
- new osm_map_values(Navit.T("Lorraine"), "4.84", "47.77", "7.72", "49.73", 330777318L, 2),
- new osm_map_values(Navit.T("Midi-Pyrenees"), "-0.37", "42.18", "3.50", "45.10", 462618363L, 2),
- new osm_map_values(Navit.T("Nord-pas-de-Calais"), "1.42", "49.92", "4.49", "51.31", 368467511L, 2),
- new osm_map_values(Navit.T("Pays-de-la-Loire"), "-2.88", "46.20", "0.97", "48.62", 499471143L, 2),
- new osm_map_values(Navit.T("Picardie"), "1.25", "48.79", "4.31", "50.43", 374308041L, 2),
- new osm_map_values(Navit.T("Poitou-Charentes"), "-1.69", "45.04", "1.26", "47.23", 342125526L, 2),
- new osm_map_values(Navit.T("Provence-Alpes-Cote-d-Azur"), "4.21", "42.91", "7.99", "45.18", 390306134L, 2),
- new osm_map_values(Navit.T("Rhone-Alpes"), "3.65", "44.07", "7.88", "46.64", 510797942L, 2),
- new osm_map_values(Navit.T("Germany"), "5.18", "46.84", "15.47", "55.64", 3521359466L, 1),
- new osm_map_values(Navit.T("Baden-Wuerttemberg"), "7.32", "47.14", "10.57", "49.85", 674361124L, 2),
- new osm_map_values(Navit.T("Bayern"), "8.92", "47.22", "13.90", "50.62", 860161150L, 2),
- new osm_map_values(Navit.T("Mittelfranken"), "9.86", "48.78", "11.65", "49.84", 203055195L, 2),
- new osm_map_values(Navit.T("Niederbayern"), "11.55", "47.75", "14.12", "49.42", 312924770L, 2),
- new osm_map_values(Navit.T("Oberbayern"), "10.67", "47.05", "13.57", "49.14", 382734883L, 2),
- new osm_map_values(Navit.T("Oberfranken"), "10.31", "49.54", "12.49", "50.95", 235258691L, 2),
- new osm_map_values(Navit.T("Oberpfalz"), "11.14", "48.71", "13.47", "50.43", 264536012L, 2),
- new osm_map_values(Navit.T("Schwaben"), "9.27", "47.10", "11.36", "49.09", 321141607L, 2),
- new osm_map_values(Navit.T("Unterfranken"), "8.59", "49.16", "10.93", "50.67", 303720890L, 2),
- new osm_map_values(Navit.T("Berlin"), "13.03", "52.28", "13.81", "52.73", 169019946L, 2),
- new osm_map_values(Navit.T("Brandenburg"), "11.17", "51.30", "14.83", "53.63", 323497599L, 2),
- new osm_map_values(Navit.T("Bremen"), "8.43", "52.96", "9.04", "53.66", 150963608L, 2),
- new osm_map_values(Navit.T("Hamburg"), "9.56", "53.34", "10.39", "53.80", 156284421L, 2),
- new osm_map_values(Navit.T("Hessen"), "7.72", "49.34", "10.29", "51.71", 432279328L, 2),
- new osm_map_values(Navit.T("Mecklenburg-Vorpommern"), "10.54", "53.05", "14.48", "55.05", 213183908L, 2),
- new osm_map_values(Navit.T("Niedersachsen"), "6.40", "51.24", "11.69", "54.22", 819766939L, 2),
- new osm_map_values(Navit.T("Nordrhein-westfalen"), "5.46", "50.26", "9.52", "52.59", 967053517L, 2),
- new osm_map_values(Navit.T("Rheinland-Pfalz"), "6.06", "48.91", "8.56", "51.00", 442868899L, 2),
- new osm_map_values(Navit.T("Saarland"), "6.30", "49.06", "7.46", "49.69", 157721162L, 2),
- new osm_map_values(Navit.T("Sachsen-Anhalt"), "10.50", "50.88", "13.26", "53.11", 287785088L, 2),
- new osm_map_values(Navit.T("Sachsen"), "11.82", "50.11", "15.10", "51.73", 342620834L, 2),
- new osm_map_values(Navit.T("Schleswig-Holstein"), "7.41", "53.30", "11.98", "55.20", 280293910L, 2),
- new osm_map_values(Navit.T("Thueringen"), "9.81", "50.15", "12.72", "51.70", 269428239L, 2),
- new osm_map_values(Navit.T("Germany")+"+"+Navit.T("Austria")+"+"+Navit.T("Switzerland"), "3.4", "44.5", "18.6", "55.1", 5746126429L, 1),
- new osm_map_values(Navit.T("Iceland"), "-25.3", "62.8", "-11.4", "67.5", 124837162L, 1),
- new osm_map_values(Navit.T("Ireland"), "-11.17", "51.25", "-5.23", "55.9", 234750271L, 1),
- new osm_map_values(Navit.T("Italy"), "6.52", "36.38", "18.96", "47.19", 1610171395L, 1),
- new osm_map_values(Navit.T("Spain")+"+"+Navit.T("Portugal"), "-11.04", "34.87", "4.62", "44.41", 1039624918L, 1),
- new osm_map_values(Navit.T("Mallorca"), "2.2", "38.8", "4.7", "40.2", 137200636L, 2),
- new osm_map_values(Navit.T("Galicia"), "-10.0", "41.7", "-6.3", "44.1", 174549553L, 2),
- new osm_map_values(Navit.T("Scandinavia"), "4.0", "54.4", "32.1", "71.5", 1398661090L, 1),
- new osm_map_values(Navit.T("Finland"), "18.6", "59.2", "32.3", "70.3", 460997178L, 1),
- new osm_map_values(Navit.T("Denmark"), "7.49", "54.33", "13.05", "57.88", 321870414L, 1),
- new osm_map_values(Navit.T("Switzerland"), "5.79", "45.74", "10.59", "47.84", 552565332L, 1),
- new osm_map_values(Navit.T("United Kingdom"), "-9.7", "49.6", "2.2", "61.2", 901724648L, 1),
- new osm_map_values(Navit.T("England"), "-7.80", "48.93", "2.41", "56.14", 937728414L, 1),
- new osm_map_values(Navit.T("Buckinghamshire"), "-1.19", "51.44", "-0.43", "52.25", 142256978L, 2),
- new osm_map_values(Navit.T("Cambridgeshire"), "-0.55", "51.96", "0.56", "52.79", 142334001L, 2),
- new osm_map_values(Navit.T("Cumbria"), "-3.96", "53.85", "-2.11", "55.24", 144422460L, 2),
- new osm_map_values(Navit.T("East yorkshire with hull"), "-1.16", "53.50", "0.54", "54.26", 141518744L, 2),
- new osm_map_values(Navit.T("Essex"), "-0.07", "51.40", "1.36", "52.14", 162542730L, 2),
- new osm_map_values(Navit.T("Herefordshire"), "-3.19", "51.78", "-2.29", "52.45", 129368660L, 2),
- new osm_map_values(Navit.T("Kent"), "-0.02", "50.81", "1.65", "51.53", 145482562L, 2),
- new osm_map_values(Navit.T("Lancashire"), "-3.20", "53.43", "-2.00", "54.29", 148964975L, 2),
- new osm_map_values(Navit.T("Leicestershire"), "-1.65", "52.34", "-0.61", "53.03", 154199956L, 2),
- new osm_map_values(Navit.T("Norfolk"), "0.10", "52.30", "2.04", "53.41", 146017009L, 2),
- new osm_map_values(Navit.T("Nottinghamshire"), "-1.39", "52.73", "-0.62", "53.55", 147986548L, 2),
- new osm_map_values(Navit.T("Oxfordshire"), "-1.77", "51.41", "-0.82", "52.22", 142240992L, 2),
- new osm_map_values(Navit.T("Shropshire"), "-3.29", "52.26", "-2.18", "53.05", 136909363L, 2),
- new osm_map_values(Navit.T("Somerset"), "-3.89", "50.77", "-2.20", "51.40", 145186096L, 2),
- new osm_map_values(Navit.T("South yorkshire"), "-1.88", "53.25", "-0.80", "53.71", 145902650L, 2),
- new osm_map_values(Navit.T("Suffolk"), "0.29", "51.88", "1.81", "52.60", 143799697L, 2),
- new osm_map_values(Navit.T("Surrey"), "-0.90", "51.02", "0.10", "51.52", 157987139L, 2),
- new osm_map_values(Navit.T("Wiltshire"), "-2.41", "50.90", "-1.44", "51.76", 138652346L, 2),
- new osm_map_values(Navit.T("Scotland"), "-8.13", "54.49", "-0.15", "61.40", 258853845L, 2),
- new osm_map_values(Navit.T("Wales"), "-5.56", "51.28", "-2.60", "53.60", 193593409L, 2),
- new osm_map_values(Navit.T("Albania"), "19.09", "39.55", "21.12", "42.72", 146199817L, 1),
- new osm_map_values(Navit.T("Belarus"), "23.12", "51.21", "32.87", "56.23", 324470696L, 1),
- new osm_map_values(Navit.T("Russian Federation"), "27.9", "41.5", "190.4", "77.6", 2148314279L, 1),
- new osm_map_values(Navit.T("Bulgaria"), "24.7", "42.1", "24.8", "42.1", 109869373L, 1),
- new osm_map_values(Navit.T("Bosnia and Herzegovina"), "15.69", "42.52", "19.67", "45.32", 187122485L, 1),
- new osm_map_values(Navit.T("Czech Republic"), "11.91", "48.48", "19.02", "51.17", 904838442L, 1),
- new osm_map_values(Navit.T("Croatia"), "13.4", "42.1", "19.4", "46.9", 460854751L, 1),
- new osm_map_values(Navit.T("Estonia"), "21.5", "57.5", "28.2", "59.6", 173378927L, 1),
- new osm_map_values(Navit.T("Greece"), "28.9", "37.8", "29.0", "37.8", 109435051L, 1),
- new osm_map_values(Navit.T("Crete"), "23.3", "34.5", "26.8", "36.0", 115985063L, 1),
- new osm_map_values(Navit.T("Hungary"), "16.08", "45.57", "23.03", "48.39", 350318541L, 1),
- new osm_map_values(Navit.T("Latvia"), "20.7", "55.6", "28.3", "58.1", 188188140L, 1),
- new osm_map_values(Navit.T("Lithuania"), "20.9", "53.8", "26.9", "56.5", 217852597L, 1),
- new osm_map_values(Navit.T("Poland"), "13.6", "48.8", "24.5", "55.0", 1464968657L, 1),
- new osm_map_values(Navit.T("Romania"), "20.3", "43.5", "29.9", "48.4", 347931565L, 1),
- new osm_map_values(Navit.T("Ukraine"), "22.0", "44.3", "40.4", "52.4", 793611912L, 1),
- new osm_map_values(Navit.T("North America"), "-178.1", "6.5", "-10.4", "84.0", 5601866516L, 0),
- new osm_map_values(Navit.T("Alaska"), "-179.5", "49.5", "-129", "71.6", 207746039L, 1),
- new osm_map_values(Navit.T("Canada"), "-141.3", "41.5", "-52.2", "70.2", 2635719651L, 1),
- new osm_map_values(Navit.T("Hawaii"), "-161.07", "18.49", "-154.45", "22.85", 115016656L, 1),
- new osm_map_values(Navit.T("USA")+Navit.T(" (except Alaska and Hawaii)"), "-125.4", "24.3", "-66.5", "49.3", 4060487198L, 1),
- new osm_map_values(Navit.T("Midwest"), "-104.11", "35.92", "-80.46", "49.46", 1145596450L, 2),
- new osm_map_values(Navit.T("Michigan"), "-90.47", "41.64", "-79.00", "49.37", 538247019L, 2),
- new osm_map_values(Navit.T("Ohio"), "-84.87", "38.05", "-79.85", "43.53", 277022336L, 2),
- new osm_map_values(Navit.T("Northeast"), "-80.58", "38.72", "-66.83", "47.53", 1017160709L, 2),
- new osm_map_values(Navit.T("Massachusetts"), "-73.56", "40.78", "-68.67", "42.94", 340055487L, 2),
- new osm_map_values(Navit.T("Vermont"), "-73.49", "42.68", "-71.41", "45.07", 139626067L, 2),
- new osm_map_values(Navit.T("Pacific"), "-180.05", "15.87", "-129.75", "73.04", 207090640L, 2),
- new osm_map_values(Navit.T("South"), "-106.70", "23.98", "-71.46", "40.70", 1747935356L, 2),
- new osm_map_values(Navit.T("Arkansas"), "-94.67", "32.95", "-89.59", "36.60", 155658661L, 2),
- new osm_map_values(Navit.T("District of Columbia"), "-77.17", "38.74", "-76.86", "39.05", 129235755L, 2),
- new osm_map_values(Navit.T("Florida"), "-88.75", "23.63", "-77.67", "31.05", 224022108L, 2),
- new osm_map_values(Navit.T("Louisiana"), "-94.09", "28.09", "-88.62", "33.07", 210120605L, 2),
- new osm_map_values(Navit.T("Maryland"), "-79.54", "37.83", "-74.99", "40.22", 276462622L, 2),
- new osm_map_values(Navit.T("Mississippi"), "-91.71", "29.99", "-88.04", "35.05", 177858031L, 2),
- new osm_map_values(Navit.T("Oklahoma"), "-103.41", "33.56", "-94.38", "37.38", 200061473L, 2),
- new osm_map_values(Navit.T("Texas"), "-106.96", "25.62", "-92.97", "36.58", 430089141L, 2),
- new osm_map_values(Navit.T("Virginia"), "-83.73", "36.49", "-74.25", "39.52", 384187569L, 2),
- new osm_map_values(Navit.T("West Virginia"), "-82.70", "37.15", "-77.66", "40.97", 220552071L, 2),
- new osm_map_values(Navit.T("West"), "-133.11", "31.28", "-101.99", "49.51", 1152909162L, 2),
- new osm_map_values(Navit.T("Arizona"), "-114.88", "30.01", "-108.99", "37.06", 182826833L, 2),
- new osm_map_values(Navit.T("California"), "-125.94", "32.43", "-114.08", "42.07", 586923326L, 2),
- new osm_map_values(Navit.T("Colorado"), "-109.11", "36.52", "-100.41", "41.05", 228623724L, 2),
- new osm_map_values(Navit.T("Idaho"), "-117.30", "41.93", "-110.99", "49.18", 170684507L, 2),
- new osm_map_values(Navit.T("Montana"), "-116.10", "44.31", "-102.64", "49.74", 176229800L, 2),
- new osm_map_values(Navit.T("New Mexico"), "-109.10", "26.98", "-96.07", "37.05", 361793070L, 2),
- new osm_map_values(Navit.T("Nevada"), "-120.2", "35.0", "-113.8", "42.1", 200614482L, 2),
- new osm_map_values(Navit.T("Oregon"), "-124.8", "41.8", "-116.3", "46.3", 211462685L, 2),
- new osm_map_values(Navit.T("Utah"), "-114.11", "36.95", "-108.99", "42.05", 151590197L, 2),
- new osm_map_values(Navit.T("Washington State"), "-125.0", "45.5", "-116.9", "49.0", 222553768L, 2),
- new osm_map_values(Navit.T("South+Middle America"), "-83.5", "-56.3", "-30.8", "13.7", 958895383L, 0),
- new osm_map_values(Navit.T("Argentina"), "-73.9", "-57.3", "-51.6", "-21.0", 376857648L, 1),
- new osm_map_values(Navit.T("Argentina")+"+"+Navit.T("Chile"), "-77.2", "-56.3", "-52.7", "-16.1", 420275812L, 1),
- new osm_map_values(Navit.T("Bolivia"), "-70.5", "-23.1", "-57.3", "-9.3", 175937824L, 1),
- new osm_map_values(Navit.T("Brazil"), "-71.4", "-34.7", "-32.8", "5.4", 664872975L, 1),
- new osm_map_values(Navit.T("Chile"), "-81.77", "-58.50", "-65.46", "-17.41", 241657330L, 1),
- new osm_map_values(Navit.T("Cuba"), "-85.3", "19.6", "-74.0", "23.6", 129043575L, 1),
- new osm_map_values(Navit.T("Colombia"), "-79.1", "-4.0", "-66.7", "12.6", 212016580L, 1),
- new osm_map_values(Navit.T("Ecuador"), "-82.6", "-5.4", "-74.4", "2.3", 158857591L, 1),
- new osm_map_values(Navit.T("Guyana")+"+"+Navit.T("Suriname")+"+"+Navit.T("Guyane Francaise"), "-62.0", "1.0", "-51.2", "8.9", 123000072L, 1),
- new osm_map_values(Navit.T("Haiti")+"+"+Navit.T("Dominican Republic"), "-74.8", "17.3", "-68.2", "20.1", 149925689L, 1),
- new osm_map_values(Navit.T("Jamaica"), "-78.6", "17.4", "-75.9", "18.9", 113961998L, 1),
- new osm_map_values(Navit.T("Mexico"), "-117.6", "14.1", "-86.4", "32.8", 551307973L, 1),
- new osm_map_values(Navit.T("Paraguay"), "-63.8", "-28.1", "-53.6", "-18.8", 159498397L, 1),
- new osm_map_values(Navit.T("Peru"), "-82.4", "-18.1", "-67.5", "0.4", 212490557L, 1),
- new osm_map_values(Navit.T("Uruguay"), "-59.2", "-36.5", "-51.7", "-29.7", 157482719L, 1),
- new osm_map_values(Navit.T("Venezuela"), "-73.6", "0.4", "-59.7", "12.8", 167295729L, 1)
- };
-
- private String map_filename_path;
-
- public static NavitMap[] getAvailableMaps() {
- class filterMaps implements FilenameFilter {
- public boolean accept(File dir, String filename) {
- if (filename.endsWith(".bin"))
- return true;
- return false;
- }
- }
- NavitMap maps[] = new NavitMap[0];
- File map_dir = new File(Navit.map_filename_path);
- String map_file_names[] = map_dir.list(new filterMaps());
- if (map_file_names != null) {
- maps = new NavitMap[map_file_names.length];
- for (int map_file_index = 0; map_file_index < map_file_names.length; map_file_index++) {
- maps[map_file_index] = new NavitMap(Navit.map_filename_path, map_file_names[map_file_index]);
- }
- }
- return maps;
- }
- private Boolean stop_me = false;
- private osm_map_values map_values;
- private int map_id;
- private long uiLastUpdated = -1;
-
- private Boolean retryDownload = false; //Download failed, but
- //we should try to resume
- private static final int SOCKET_CONNECT_TIMEOUT = 60000; // 60 secs.
- private static final int SOCKET_READ_TIMEOUT = 120000; // 120 secs.
- private static final int MAP_WRITE_FILE_BUFFER = 1024 * 64;
- private static final int MAP_WRITE_MEM_BUFFER = 1024 * 64;
- private static final int MAP_READ_FILE_BUFFER = 1024 * 64;
- private static final int UPDATE_PROGRESS_TIME_NS = 1000 * 1000000; // 1ns=1E-9s
- private static final int MAX_RETRIES = 5;
- private static final String TAG = "NavitMapDownloader";
-
- protected int retry_counter = 0;
-
- public NavitMapDownloader(int map_id) {
- this.map_values = osm_maps[map_id];
- this.map_id=map_id;
- this.map_filename_path=Navit.map_filename_path;
- }
-
- public void run() {
- stop_me = false;
- retry_counter = 0;
-
- Log.v(TAG, "start download " + map_values.map_name);
- updateProgress(0, map_values.est_size_bytes, Navit.T("downloading") + ": " + map_values.map_name);
-
- boolean success;
- do {
- try {
- Thread.sleep(10 + retry_counter * 1000);
- } catch (InterruptedException e1) {}
- retryDownload = false;
- success = download_osm_map();
- } while ( !success
- && retryDownload
- && retry_counter < MAX_RETRIES
- && !stop_me);
-
- if (success) {
- toast(map_values.map_name + " " + Navit.T("ready"));
- getMapInfoFile().delete();
- Log.d(TAG, "success");
- }
-
- if (success || stop_me ) {
- NavitDialogs.sendDialogMessage( NavitDialogs.MSG_MAP_DOWNLOAD_FINISHED
- , map_filename_path + map_values.map_name + ".bin", null, -1, success ? 1 : 0 , map_id );
- }
- }
-
- public void stop_thread() {
- stop_me = true;
- Log.d(TAG, "stop_me -> true");
- }
-
- protected boolean checkFreeSpace(long needed_bytes) {
- long free_space = getFreeSpace();
-
- if ( needed_bytes <= 0 )
- needed_bytes = MAP_WRITE_FILE_BUFFER;
-
- if (free_space < needed_bytes ) {
- String msg;
- Log.e(TAG, "Not enough free space or media not available. Please free at least " + needed_bytes / 1024 /1024 + "Mb.");
- if(free_space<0)
- msg=Navit.T("Media selected for map storage is not available");
- else
- msg=Navit.T("Not enough free space");
- updateProgress(free_space, needed_bytes, Navit.T("Error downloading map!") + "\n" + msg);
- return false;
- }
- return true;
- }
-
- protected boolean deleteMap() {
- File finalOutputFile = getMapFile();
-
- if (finalOutputFile.exists()) {
- Message msg =
- Message.obtain(Navit.N_NavitGraphics.callback_handler,
- NavitGraphics.msg_type.CLB_DELETE_MAP.ordinal());
- Bundle b = new Bundle();
- b.putString("title", finalOutputFile.getAbsolutePath());
- msg.setData(b);
- msg.sendToTarget();
- return true;
- }
- return false;
- }
-
- /**
- * @param map_values
- * @return
- */
- protected boolean download_osm_map() {
- long already_read = 0;
- long real_size_bytes = 0;
- boolean resume = true;
-
- File outputFile = getDestinationFile();
- long old_download_size = outputFile.length();
-
- URL url = null;
- if (old_download_size > 0) {
- url = readFileInfo();
- }
-
- if (url == null) {
- resume = false;
- url = getDownloadURL();
- }
-
- // URL url = new URL("http://192.168.2.101:8080/zweibruecken.bin");
- URLConnection c = initConnection(url);
- if (c != null) {
-
- if (resume) {
- c.setRequestProperty("Range", "bytes=" + old_download_size + "-");
- already_read = old_download_size;
- }
- try {
- real_size_bytes=Long.parseLong(c.getHeaderField("Content-Length")) + already_read;
- } catch(Exception e) {
- real_size_bytes=-1;
- }
-
- long fileTime = c.getLastModified();
-
- if (!resume) {
- outputFile.delete();
- writeFileInfo(c, real_size_bytes);
- }
-
- if (real_size_bytes <= 0)
- real_size_bytes = map_values.est_size_bytes;
-
- Log.d(TAG, "size: " + real_size_bytes + ", read: " + already_read + ", timestamp: " + fileTime
- + ", Connection ref: " + c.getURL());
-
- if (checkFreeSpace(real_size_bytes - already_read)
- && downloadData(c, already_read, real_size_bytes, resume, outputFile)) {
-
- File finalOutputFile = getMapFile();
- // delete an already existing file first
- finalOutputFile.delete();
- // rename file to its final name
- outputFile.renameTo(finalOutputFile);
- return true;
- }
- }
- return false;
- }
-
- protected File getDestinationFile() {
- File outputFile = new File(map_filename_path, map_values.map_name + ".tmp");
- outputFile.getParentFile().mkdir();
- return outputFile;
- }
-
- protected boolean downloadData(URLConnection c, long already_read, long real_size_bytes
- , boolean resume,File outputFile) {
- boolean success = false;
- BufferedOutputStream buf = getOutputStream(outputFile, resume);
- BufferedInputStream bif = getInputStream(c);
-
- if (buf != null && bif != null) {
- success = readData(buf, bif, already_read, real_size_bytes);
- // always cleanup, as we might get errors when trying to resume
- try {
- buf.flush();
- buf.close();
-
- bif.close();
- } catch (IOException e) {
- }
- }
- return success;
- }
-
- protected URL getDownloadURL() {
- URL url = null;
- try {
- url =
- new URL("http://maps.navit-project.org/api/map/?bbox=" + map_values.lon1 + "," + map_values.lat1
- + "," + map_values.lon2 + "," + map_values.lat2);
- } catch (MalformedURLException e) {
- Log.e(TAG, "We failed to create a URL to " + map_values.map_name);
- e.printStackTrace();
- return null;
- }
- Log.v(TAG, "connect to " + url.toString());
- return url;
- }
-
- protected long getFreeSpace() {
- try {
- StatFs fsInfo = new StatFs(map_filename_path);
- return (long)fsInfo.getAvailableBlocks() * fsInfo.getBlockSize();
- } catch(Exception e) {
- return -1;
- }
- }
-
- protected BufferedInputStream getInputStream(URLConnection c) {
- BufferedInputStream bif = null;
- try {
- bif = new BufferedInputStream(c.getInputStream(), MAP_READ_FILE_BUFFER);
- } catch (FileNotFoundException e) {
- Log.e(TAG, "File not found on server: " + e);
- if (retry_counter > 0) {
- getMapInfoFile().delete();
- }
- enableRetry();
- bif = null;
- } catch (IOException e) {
- Log.e(TAG, "Error reading from server: " + e);
- enableRetry();
- bif = null;
- }
- return bif;
- }
-
- protected File getMapFile() {
- return new File(map_filename_path, map_values.map_name + ".bin");
- }
-
- protected File getMapInfoFile() {
- return new File(map_filename_path, map_values.map_name + ".tmp.info");
- }
-
- protected BufferedOutputStream getOutputStream(File outputFile, boolean resume) {
- BufferedOutputStream buf = null;
- try {
- buf = new BufferedOutputStream(new FileOutputStream(outputFile, resume), MAP_WRITE_FILE_BUFFER);
- } catch (FileNotFoundException e) {
- Log.e(TAG, "Could not open output file for writing: " + e);
- buf = null;
- }
- return buf;
- }
-
- protected URLConnection initConnection(URL url) {
- HttpURLConnection c = null;
- try {
- c = (HttpURLConnection) url.openConnection();
- c.setRequestMethod("GET");
- } catch (Exception e) {
- Log.e(TAG, "Failed connecting server: " + e);
- enableRetry();
- return null;
- }
-
- c.setReadTimeout(SOCKET_READ_TIMEOUT);
- c.setConnectTimeout(SOCKET_CONNECT_TIMEOUT);
- return c;
- }
-
- protected boolean readData(OutputStream buf, InputStream bif, long already_read, long real_size_bytes) {
- long start_timestamp = System.nanoTime();
- byte[] buffer = new byte[MAP_WRITE_MEM_BUFFER];
- int len1 = 0;
- long mapFileSize = real_size_bytes;
- long startOffset = already_read;
- boolean success = false;
-
- try {
- while (!stop_me && (len1 = bif.read(buffer)) != -1) {
- already_read += len1;
- updateProgress(start_timestamp, startOffset, already_read, mapFileSize);
-
- try {
- buf.write(buffer, 0, len1);
- } catch (IOException e) {
- Log.d(TAG, "Error: " + e);
- if ( !checkFreeSpace(real_size_bytes - already_read + MAP_WRITE_FILE_BUFFER)) {
- if (deleteMap()) {
- enableRetry();
- } else {
- updateProgress(already_read, real_size_bytes, Navit.T("Error downloading map!") + "\n"
- + Navit.T("Not enough free space"));
- }
- } else {
- updateProgress(already_read, real_size_bytes, Navit.T("Error writing map!"));
- }
-
- return false;
- }
- }
-
- if (stop_me) {
- toast(Navit.T("Map download aborted!"));
- } else if ( already_read < real_size_bytes ) {
- Log.d(TAG, "Server send only " + already_read + " bytes of " + real_size_bytes);
- enableRetry();
- } else {
- success = true;
- }
- } catch (IOException e) {
- Log.d(TAG, "Error: " + e);
-
- enableRetry();
- updateProgress(already_read, real_size_bytes, Navit.T("Error downloading map!"));
- }
-
- return success;
- }
-
- protected URL readFileInfo() {
- URL url = null;
- try {
- ObjectInputStream infoStream = new ObjectInputStream(new FileInputStream(getMapInfoFile()));
- String resume_proto = infoStream.readUTF();
- infoStream.readUTF(); // read the host name (unused for now)
- String resume_file = infoStream.readUTF();
- infoStream.close();
- // looks like the same file, try to resume
- Log.v(TAG, "Try to resume download");
- url = new URL(resume_proto + "://" + "maps.navit-project.org" + resume_file);
- } catch (Exception e) {
- getMapInfoFile().delete();
- }
- return url;
- }
-
- protected void toast(String message) {
- NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST, null, message, -1, 0, 0);
- }
-
- protected void updateProgress(long startTime, long offsetBytes, long readBytes, long maxBytes) {
- long currentTime = System.nanoTime();
-
- if ((currentTime > uiLastUpdated + UPDATE_PROGRESS_TIME_NS) && startTime!=currentTime) {
- float per_second_overall = (readBytes - offsetBytes) / ((currentTime - startTime) / 1000000000f);
- long bytes_remaining = maxBytes - readBytes;
- int eta_seconds = (int) (bytes_remaining / per_second_overall);
-
- String eta_string;
- if (eta_seconds > 60) {
- eta_string = (int) (eta_seconds / 60f) + " m";
- } else {
- eta_string = eta_seconds + " s";
- }
- String info =
- String.format("%s: %s\n %dMb / %dMb\n %.1f kb/s %s: %s", Navit.T("downloading")
- , map_values.map_name, readBytes / 1024 / 1024, maxBytes / 1024 / 1024,
- per_second_overall / 1024f, Navit.T("ETA"), eta_string);
-
- if (retry_counter > 0) {
- info += "\n Retry " + retry_counter + "/" + MAX_RETRIES;
- }
- Log.e(TAG, "info: " + info);
-
- updateProgress(readBytes, maxBytes, info);
- uiLastUpdated = currentTime;
- }
- }
-
- protected void updateProgress(long positionBytes, long maximumBytes, String infoText) {
- NavitDialogs.sendDialogMessage(NavitDialogs.MSG_PROGRESS_BAR, Navit.T("Map download"), infoText
- , NavitDialogs.DIALOG_MAPDOWNLOAD, (int) (maximumBytes / 1024),
- (int) (positionBytes / 1024));
- }
-
- protected void writeFileInfo(URLConnection c, long sizeInBytes) {
- ObjectOutputStream infoStream;
- try {
- infoStream = new ObjectOutputStream(new FileOutputStream(getMapInfoFile()));
- infoStream.writeUTF(c.getURL().getProtocol());
- infoStream.writeUTF(c.getURL().getHost());
- infoStream.writeUTF(c.getURL().getFile());
- infoStream.writeLong(sizeInBytes);
- infoStream.close();
- } catch (Exception e) {
- Log.e(TAG, "Could not write info file for map download. Resuming will not be possible. (" + e.getMessage() + ")");
- }
- }
-
- void enableRetry() {
- retryDownload = true;
- retry_counter++;
- }
- // dialog send helper methods
-}
+/**
+ * Navit, a modular navigation system. Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+package org.navitproject.navit;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Message;
+import android.os.StatFs;
+import android.util.Log;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * @author rikky
+ *
+ */
+public class NavitMapDownloader extends Thread {
+
+ //
+ // define the maps here
+ // size estimations updated 2017-06-22
+ //
+ public static final osm_map_values[] osm_maps = {
+ new osm_map_values(Navit.getInstance().getTstring(R.string.whole_planet), "-180", "-90", "180", "90",
+ 23992258630L, 0),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.africa), "-30.89", "-36.17", "61.68",
+ "38.40", 2070076339L, 0),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.angola), "11.4", "-18.1", "24.2", "-5.3",
+ 127557789L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.burundi), "28.9", "-4.5", "30.9", "-2.2",
+ 124049667L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.canary_islands), "-18.69", "26.52", "-12.79",
+ "29.99", 133565815L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.congo), "11.7",
+ "-13.6", "31.5", "5.7", 244228485L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.ethiopia), "32.89", "3.33", "48.07", "14.97",
+ 153067406L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.guinea), "-15.47", "7.12", "-7.58", "12.74",
+ 188047126L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.cotedivoire), "-8.72", "4.09", "-2.43",
+ "10.80", 132187496L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.kenya), "33.8", "-5.2", "42.4", "4.9",
+ 190073089L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.lesotho), "26.9", "-30.7", "29.6", "-28.4",
+ 196189429L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.liberia), "-15.00", "-0.73", "-7.20", "8.65",
+ 156257253L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.libya), "9.32", "19.40", "25.54", "33.63",
+ 126046917L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.madagascar), "42.25", "-26.63", "51.20",
+ "-11.31", 145210721L, 1),
+ new osm_map_values(
+ Navit.getInstance().getTstring(R.string.namibia) + "+"
+ + Navit.getInstance().getTstring(R.string.botswana),
+ "11.4", "-29.1", "29.5", "-16.9", 248970987L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.reunion), "55.2", "-21.4", "55.9", "-20.9",
+ 126008774L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.rwanda), "28.8", "-2.9", "30.9", "-1.0",
+ 128267595L, 1),
+ new osm_map_values(
+ Navit.getInstance().getTstring(R.string.south_africa) + "+"
+ + Navit.getInstance().getTstring(R.string.lesotho),
+ "15.93", "-36.36", "33.65", "-22.08", 307280006L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.tanzania), "29.19",
+ "-11.87", "40.74", "-0.88", 253621029L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.uganda), "29.3", "-1.6", "35.1", "4.3",
+ 179134521L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.asia), "23.8", "0.1", "195.0", "82.4",
+ 5113673780L, 0),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.azerbaijan), "44.74", "38.34", "51.69",
+ "42.37", 138346406L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.china), "67.3", "5.3", "135.0", "54.5",
+ 1718108758L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.cyprus), "32.0", "34.5", "34.9", "35.8",
+ 118472448L, 1),
+ new osm_map_values(
+ Navit.getInstance().getTstring(R.string.india) + "+"
+ + Navit.getInstance().getTstring(R.string.nepal), "67.9",
+ "5.5", "89.6", "36.0", 601877877L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.indonesia), "93.7", "-17.3", "155.5", "7.6",
+ 420741405L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.iran), "43.5", "24.4",
+ "63.6", "40.4", 242016066L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.iraq), "38.7", "28.5", "49.2", "37.4",
+ 160751805L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.israel), "33.99", "29.8", "35.95", "33.4",
+ 155685778L, 1),
+ new osm_map_values(
+ Navit.getInstance().getTstring(R.string.japan) + "+"
+ + Navit.getInstance().getTstring(R.string.korea), "123.6",
+ "25.2", "151.3", "47.1", 1029080156L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.kazakhstan), "46.44", "40.89", "87.36",
+ "55.45", 407633007L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.kyrgyzsyan), "69.23", "39.13", "80.33",
+ "43.29", 147997835L, 1),
+ new osm_map_values(
+ Navit.getInstance().getTstring(R.string.malaysia) + "+"
+ + Navit.getInstance().getTstring(R.string.singapore),
+ "94.3", "-5.9", "108.6", "6.8", 168816435L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.mongolia), "87.5", "41.4", "120.3", "52.7",
+ 153534851L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.pakistan), "60.83", "23.28", "77.89",
+ "37.15", 217644321L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.philippines), "115.58", "4.47", "127.85",
+ "21.60", 281428307L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.saudi_arabia), "33.2", "16.1", "55.9",
+ "33.5", 242648303L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.taiwan), "119.1", "21.5", "122.5", "25.2",
+ 1029080156L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.thailand), "97.5", "5.7", "105.2", "19.7",
+ 185135492L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.turkey), "25.1", "35.8", "46.4", "42.8",
+ 331087441L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.turkmenistan), "51.78", "35.07", "66.76",
+ "42.91", 131045087L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.uae_other), "51.5", "22.6", "56.7", "26.5",
+ 128934674L, 1),
+ new osm_map_values(
+ Navit.getInstance().getTstring(R.string.australia) + "+"
+ + Navit.getInstance().getTstring(R.string.oceania),
+ "89.84", "-57.39", "179.79", "7.26", 782722650L, 0),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.australia), "110.5", "-44.2", "154.9",
+ "-9.2", 348652900L, 0),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.tasmania), "144.0", "-45.1", "155.3",
+ "-24.8", 253231890L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.victoria) + " + " + Navit.getInstance()
+ .getTstring(R.string.new_south_wales), "140.7", "-39.4", "153.7", "-26.9", 241500829L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.new_caledonia), "157.85", "-25.05", "174.15",
+ "-16.85", 115512336L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.newzealand), "165.2", "-47.6", "179.1",
+ "-33.7", 239264192L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.europe), "-12.97", "33.59", "34.15", "72.10",
+ 11984126789L, 0),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.western_europe), "-17.6", "34.5", "42.9",
+ "70.9", 12648810717L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.austria), "9.4", "46.32", "17.21", "49.1",
+ 898273634L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.azores), "-31.62", "36.63", "-24.67",
+ "40.13", 112687225L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.belgium), "2.3", "49.5", "6.5", "51.6",
+ 733035524L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.benelux), "2.08", "48.87", "7.78", "54.52",
+ 1771971595L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.netherlands), "3.07", "50.75", "7.23",
+ "53.73", 1191828033L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.denmark), "7.65", "54.32", "15.58", "58.07",
+ 365606979L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.faroe_islands), "-7.8", "61.3", "-6.1",
+ "62.5", 109377568L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.france), "-5.45", "42.00", "8.44", "51.68",
+ 3907969744L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.alsace), "6.79", "47.27", "8.48", "49.17",
+ 354249349L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.aquitaine), "-2.27", "42.44", "1.50",
+ "45.76", 443715019L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.auvergne), "2.01", "44.57", "4.54", "46.85",
+ 287663213L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.basse_normandie), "-2.09", "48.13", "1.03",
+ "49.98", 262352354L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.bourgogne), "2.80", "46.11", "5.58", "48.45",
+ 298868796L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.bretagne), "-5.58", "46.95", "-0.96",
+ "48.99", 382770794L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.centre), "0.01", "46.29", "3.18", "48.99",
+ 474224721L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.champagne_ardenne), "3.34", "47.53", "5.94",
+ "50.28", 269947824L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.corse), "8.12", "41.32", "9.95", "43.28",
+ 129902146L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.franche_comte), "5.20", "46.21", "7.83",
+ "48.07", 324476070L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.haute_normandie), "-0.15", "48.62", "1.85",
+ "50.18", 202782876L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.ile_de_france), "1.40", "48.07", "3.61",
+ "49.29", 311052699L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.languedoc_roussillon), "1.53", "42.25",
+ "4.89", "45.02", 380145667L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.limousin), "0.58", "44.87", "2.66", "46.50",
+ 206696539L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.lorraine), "4.84", "47.77", "7.72", "49.73",
+ 330777318L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.midi_pyrenees), "-0.37", "42.18", "3.50",
+ "45.10", 462618363L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.nord_pas_de_calais), "1.42", "49.92", "4.49",
+ "51.31", 368467511L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.pays_de_la_loire), "-2.88", "46.20", "0.97",
+ "48.62", 499471143L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.picardie), "1.25", "48.79", "4.31", "50.43",
+ 374308041L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.poitou_charentes), "-1.69", "45.04", "1.26",
+ "47.23", 342125526L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.provence_alpes_cote_d_azur), "4.21", "42.91",
+ "7.99", "45.18", 390306134L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.rhone_alpes), "3.65", "44.07", "7.88",
+ "46.64", 510797942L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.luxembourg), "5.7", "49.4", "6.5", "50.2",
+ 1771971595L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.germany), "5.18", "46.84", "15.47", "55.64",
+ 3521359466L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.baden_wuerttemberg), "7.32", "47.14",
+ "10.57", "49.85", 674361124L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.bayern), "8.92", "47.22", "13.90", "50.62",
+ 860161150L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.mittelfranken), "9.86", "48.78", "11.65",
+ "49.84", 203055195L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.niederbayern), "11.55", "47.75", "14.12",
+ "49.42", 312924770L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.oberbayern), "10.67", "47.05", "13.57",
+ "49.14", 382734883L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.oberfranken), "10.31", "49.54", "12.49",
+ "50.95", 235258691L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.oberpfalz), "11.14", "48.71", "13.47",
+ "50.43", 264536012L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.schwaben), "9.27", "47.10", "11.36", "49.09",
+ 321141607L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.unterfranken), "8.59", "49.16", "10.93",
+ "50.67", 303720890L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.berlin), "13.03", "52.28", "13.81", "52.73",
+ 169019946L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.brandenburg), "11.17", "51.30", "14.83",
+ "53.63", 323497599L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.bremen), "8.43", "52.96", "9.04", "53.66",
+ 150963608L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.hamburg), "9.56", "53.34", "10.39", "53.80",
+ 156284421L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.hessen), "7.72", "49.34", "10.29", "51.71",
+ 432279328L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.mecklenburg_vorpommern), "10.54", "53.05",
+ "14.48", "55.05", 213183908L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.niedersachsen), "6.40", "51.24", "11.69",
+ "54.22", 819766939L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.nordrhein_westfalen), "5.46", "50.26",
+ "9.52", "52.59", 967053517L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.rheinland_pfalz), "6.06", "48.91", "8.56",
+ "51.00", 442868899L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.saarland), "6.30", "49.06", "7.46", "49.69",
+ 157721162L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.sachsen_anhalt), "10.50", "50.88", "13.26",
+ "53.11", 287785088L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.sachsen), "11.82", "50.11", "15.10", "51.73",
+ 342620834L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.schleswig_holstein), "7.41", "53.30",
+ "11.98", "55.20", 280293910L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.thueringen), "9.81", "50.15", "12.72",
+ "51.70", 269428239L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.iceland), "-25.3", "62.8", "-11.4", "67.5",
+ 124837162L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.ireland), "-11.17", "51.25", "-5.23", "55.9",
+ 234750271L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.italy), "6.52", "36.38", "18.96", "47.19",
+ 1610171395L, 1),
+ new osm_map_values(
+ Navit.getInstance().getTstring(R.string.spain) + "+"
+ + Navit.getInstance().getTstring(R.string.portugal),
+ "-11.04", "34.87", "4.62", "44.41", 1039624918L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.mallorca), "2.2", "38.8", "4.7", "40.2",
+ 137200636L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.galicia), "-10.0", "41.7", "-6.3", "44.1",
+ 174549553L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.scandinavia), "4.0", "54.4", "32.1", "71.5",
+ 1398661090L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.finland), "18.6", "59.2", "32.3", "70.3",
+ 460997178L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.denmark), "7.49", "54.33", "13.05", "57.88",
+ 321870414L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.switzerland), "5.79", "45.74", "10.59",
+ "47.84", 552565332L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.united_kingdom), "-9.7", "49.6", "2.2",
+ "61.2", 901724648L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.england), "-7.80", "48.93", "2.41", "56.14",
+ 937728414L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.buckinghamshire), "-1.19", "51.44", "-0.43",
+ "52.25", 142256978L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.cambridgeshire), "-0.55", "51.96", "0.56",
+ "52.79", 142334001L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.cumbria), "-3.96", "53.85", "-2.11", "55.24",
+ 144422460L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.east_yorkshire_with_hull), "-1.16", "53.50",
+ "0.54", "54.26", 141518744L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.essex), "-0.07", "51.40", "1.36", "52.14",
+ 162542730L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.herefordshire), "-3.19", "51.78", "-2.29",
+ "52.45", 129368660L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.kent), "-0.02", "50.81", "1.65", "51.53",
+ 145482562L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.lancashire), "-3.20", "53.43", "-2.00",
+ "54.29", 148964975L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.leicestershire), "-1.65", "52.34", "-0.61",
+ "53.03", 154199956L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.norfolk), "0.10", "52.30", "2.04", "53.41",
+ 146017009L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.nottinghamshire), "-1.39", "52.73", "-0.62",
+ "53.55", 147986548L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.oxfordshire), "-1.77", "51.41", "-0.82",
+ "52.22", 142240992L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.shropshire), "-3.29", "52.26", "-2.18",
+ "53.05", 136909363L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.somerset), "-3.89", "50.77", "-2.20",
+ "51.40", 145186096L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.south_yorkshire), "-1.88", "53.25", "-0.80",
+ "53.71", 145902650L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.suffolk), "0.29", "51.88", "1.81", "52.60",
+ 143799697L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.surrey), "-0.90", "51.02", "0.10", "51.52",
+ 157987139L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.wiltshire), "-2.41", "50.90", "-1.44",
+ "51.76", 138652346L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.scotland), "-8.13", "54.49", "-0.15",
+ "61.40", 258853845L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.wales), "-5.56", "51.28", "-2.60", "53.60",
+ 193593409L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.albania), "19.09", "39.55", "21.12", "42.72",
+ 146199817L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.belarus), "23.12", "51.21", "32.87", "56.23",
+ 324470696L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.russian_federation), "27.9", "41.5", "190.4",
+ "77.6", 2148314279L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.bulgaria), "24.7", "42.1", "24.8", "42.1",
+ 109869373L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.bosnia_and_herzegovina), "15.69", "42.52",
+ "19.67", "45.32", 187122485L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.czech_republic), "11.91", "48.48", "19.02",
+ "51.17", 904838442L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.croatia), "13.4", "42.1", "19.4", "46.9",
+ 460854751L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.estonia), "21.5", "57.5", "28.2", "59.6",
+ 173378927L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.greece), "28.9", "37.8", "29.0", "37.8",
+ 109435051L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.crete), "23.3", "34.5", "26.8", "36.0",
+ 115985063L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.hungary), "16.08", "45.57", "23.03", "48.39",
+ 350318541L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.latvia), "20.7", "55.6", "28.3", "58.1",
+ 188188140L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.lithuania), "20.9", "53.8", "26.9", "56.5",
+ 217852597L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.poland), "13.6", "48.8", "24.5", "55.0",
+ 1464968657L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.romania), "20.3", "43.5", "29.9", "48.4",
+ 347931565L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.slovakia), "16.8", "47.7", "22.6", "49.7",
+ 420533039L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.ukraine), "22.0", "44.3", "40.4", "52.4",
+ 793611912L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.north_america), "-178.1", "6.5", "-10.4",
+ "84.0", 5601866516L, 0),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.alaska), "-179.5", "49.5", "-129", "71.6",
+ 207746039L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.canada), "-141.3", "41.5", "-52.2", "70.2",
+ 2635719651L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.hawaii), "-161.07", "18.49", "-154.45",
+ "22.85", 115016656L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.usa) + Navit.getInstance()
+ .getTstring(R.string.except_alaska_and_hawaii), "-125.4", "24.3", "-66.5", "49.3",
+ 4060487198L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.midwest), "-104.11", "35.92", "-80.46",
+ "49.46", 1145596450L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.michigan), "-90.47", "41.64", "-79.00",
+ "49.37", 538247019L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.ohio), "-84.87", "38.05", "-79.85", "43.53",
+ 277022336L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.northeast), "-80.58", "38.72", "-66.83",
+ "47.53", 1017160709L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.massachusetts), "-73.56", "40.78", "-68.67",
+ "42.94", 340055487L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.vermont), "-73.49", "42.68", "-71.41",
+ "45.07", 139626067L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.pacific), "-180.05", "15.87", "-129.75",
+ "73.04", 207090640L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.south), "-106.70", "23.98", "-71.46",
+ "40.70", 1747935356L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.arkansas), "-94.67", "32.95", "-89.59",
+ "36.60", 155658661L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.district_of_columbia), "-77.17", "38.74",
+ "-76.86", "39.05", 129235755L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.florida), "-88.75", "23.63", "-77.67",
+ "31.05", 224022108L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.louisiana), "-94.09", "28.09", "-88.62",
+ "33.07", 210120605L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.maryland), "-79.54", "37.83", "-74.99",
+ "40.22", 276462622L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.mississippi), "-91.71", "29.99", "-88.04",
+ "35.05", 177858031L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.oklahoma), "-103.41", "33.56", "-94.38",
+ "37.38", 200061473L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.texas), "-106.96", "25.62", "-92.97",
+ "36.58", 430089141L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.virginia), "-83.73", "36.49", "-74.25",
+ "39.52", 384187569L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.west_virginia), "-82.70", "37.15", "-77.66",
+ "40.97", 220552071L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.west), "-133.11", "31.28", "-101.99",
+ "49.51", 1152909162L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.arizona), "-114.88", "30.01", "-108.99",
+ "37.06", 182826833L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.california), "-125.94", "32.43", "-114.08",
+ "42.07", 586923326L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.colorado), "-109.11", "36.52", "-100.41",
+ "41.05", 228623724L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.idaho), "-117.30", "41.93", "-110.99",
+ "49.18", 170684507L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.montana), "-116.10", "44.31", "-102.64",
+ "49.74", 176229800L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.new_mexico), "-109.10", "26.98", "-96.07",
+ "37.05", 361793070L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.nevada), "-120.2", "35.0", "-113.8", "42.1",
+ 200614482L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.oregon), "-124.8", "41.8", "-116.3", "46.3",
+ 211462685L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.utah), "-114.11", "36.95", "-108.99",
+ "42.05", 151590197L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.washington_state), "-125.0", "45.5",
+ "-116.9", "49.0", 222553768L, 2),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.south_middle_america), "-83.5", "-56.3",
+ "-30.8", "13.7", 958895383L, 0),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.argentina), "-73.9", "-57.3", "-51.6",
+ "-21.0", 376857648L, 1),
+ new osm_map_values(
+ Navit.getInstance().getTstring(R.string.argentina) + "+"
+ + Navit.getInstance().getTstring(R.string.chile),
+ "-77.2", "-56.3", "-52.7", "-16.1", 420275812L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.bolivia), "-70.5", "-23.1", "-57.3", "-9.3",
+ 175937824L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.brazil), "-71.4", "-34.7", "-32.8", "5.4",
+ 664872975L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.chile), "-81.77", "-58.50", "-65.46",
+ "-17.41", 241657330L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.cuba), "-85.3", "19.6", "-74.0", "23.6",
+ 129043575L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.colombia), "-79.1", "-4.0", "-66.7", "12.6",
+ 212016580L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.ecuador), "-82.6", "-5.4", "-74.4", "2.3",
+ 158857591L, 1),
+ new osm_map_values(
+ Navit.getInstance().getTstring(R.string.guyana) + "+"
+ + Navit.getInstance().getTstring(R.string.suriname) + "+"
+ + Navit.getInstance().getTstring(R.string.guyane_francaise), "-62.0", "1.0", "-51.2",
+ "8.9", 123000072L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.haiti) + "+"
+ + Navit.getInstance().getTstring(R.string.dominican_republic), "-74.8", "17.3", "-68.2", "20.1",
+ 149925689L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.jamaica), "-78.6", "17.4", "-75.9", "18.9",
+ 113961998L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.mexico), "-117.6", "14.1", "-86.4", "32.8",
+ 551307973L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.paraguay), "-63.8", "-28.1", "-53.6",
+ "-18.8", 159498397L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.peru), "-82.4", "-18.1", "-67.5", "0.4",
+ 212490557L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.uruguay), "-59.2", "-36.5", "-51.7", "-29.7",
+ 157482719L, 1),
+ new osm_map_values(Navit.getInstance().getTstring(R.string.venezuela), "-73.6", "0.4", "-59.7", "12.8",
+ 167295729L, 1)
+ };
+ //we should try to resume
+ private static final int SOCKET_CONNECT_TIMEOUT = 60000; // 60 secs.
+ private static final int SOCKET_READ_TIMEOUT = 120000; // 120 secs.
+ private static final int MAP_WRITE_FILE_BUFFER = 1024 * 64;
+ private static final int MAP_WRITE_MEM_BUFFER = 1024 * 64;
+ private static final int MAP_READ_FILE_BUFFER = 1024 * 64;
+ private static final int UPDATE_PROGRESS_TIME_NS = 1000 * 1000000; // 1ns=1E-9s
+ private static final int MAX_RETRIES = 5;
+ private final String TAG = this.getClass().getName();
+ private final String map_filename_path;
+ private final osm_map_values map_values;
+ private final int map_id;
+ private Boolean stop_me = false;
+ private long uiLastUpdated = -1;
+ private Boolean retryDownload = false; //Download failed, but
+ private int retry_counter = 0;
+
+ NavitMapDownloader(int map_id) {
+ this.map_values = osm_maps[map_id];
+ this.map_id = map_id;
+ this.map_filename_path = Navit.map_filename_path;
+ }
+
+ public static NavitMap[] getAvailableMaps() {
+ class filterMaps implements FilenameFilter {
+
+ public boolean accept(File dir, String filename) {
+ return (filename.endsWith(".bin"));
+ }
+ }
+
+ NavitMap[] maps = new NavitMap[0];
+ File map_dir = new File(Navit.map_filename_path);
+ String[] map_file_names = map_dir.list(new filterMaps());
+ if (map_file_names != null) {
+ maps = new NavitMap[map_file_names.length];
+ for (int map_file_index = 0; map_file_index < map_file_names.length; map_file_index++) {
+ maps[map_file_index] = new NavitMap(Navit.map_filename_path,
+ map_file_names[map_file_index]);
+ }
+ }
+ return maps;
+ }
+
+ public void run() {
+ stop_me = false;
+ retry_counter = 0;
+
+ Log.v(TAG, "start download " + map_values.map_name);
+ updateProgress(0, map_values.est_size_bytes,
+ Navit.getInstance().getTstring(R.string.map_downloading) + ": " + map_values.map_name);
+
+ boolean success;
+ do {
+ try {
+ Thread.sleep(10 + retry_counter * 1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ retryDownload = false;
+ success = download_osm_map();
+ } while (!success
+ && retryDownload
+ && retry_counter < MAX_RETRIES
+ && !stop_me);
+
+ if (success) {
+ toast(map_values.map_name + " " + Navit.getInstance().getTstring(R.string.map_download_ready));
+ getMapInfoFile().delete();
+ Log.d(TAG, "success");
+ }
+
+ if (success || stop_me) {
+ NavitDialogs.sendDialogMessage(NavitDialogs.MSG_MAP_DOWNLOAD_FINISHED,
+ map_filename_path + map_values.map_name + ".bin", null, -1, success ? 1 : 0, map_id);
+ }
+ }
+
+ public void stop_thread() {
+ stop_me = true;
+ Log.d(TAG, "stop_me -> true");
+ }
+
+ private boolean checkFreeSpace(long needed_bytes) {
+ long free_space = getFreeSpace();
+
+ if (needed_bytes <= 0) {
+ needed_bytes = MAP_WRITE_FILE_BUFFER;
+ }
+
+ if (free_space < needed_bytes) {
+ String msg;
+ Log.e(TAG, "Not enough free space or media not available. Please free at least "
+ + needed_bytes / 1024 / 1024 + "Mb.");
+ if (free_space < 0) {
+ msg = Navit.getInstance().getTstring(R.string.map_download_medium_unavailable);
+ } else {
+ msg = Navit.getInstance().getTstring(R.string.map_download_not_enough_free_space);
+ }
+ updateProgress(free_space, needed_bytes,
+ Navit.getInstance().getTstring(R.string.map_download_download_error) + "\n" + msg);
+ return false;
+ }
+ return true;
+ }
+
+ private boolean deleteMap() {
+ File finalOutputFile = getMapFile();
+
+ if (finalOutputFile.exists()) {
+ Message msg = Message.obtain(Navit.getInstance().getNavitGraphics().callback_handler,
+ NavitGraphics.msg_type.CLB_DELETE_MAP.ordinal());
+ Bundle b = new Bundle();
+ b.putString("title", finalOutputFile.getAbsolutePath());
+ msg.setData(b);
+ msg.sendToTarget();
+ return true;
+ }
+ return false;
+ }
+
+
+ private boolean download_osm_map() {
+ long already_read = 0;
+ long real_size_bytes;
+ boolean resume = true;
+
+ File outputFile = getDestinationFile();
+ long old_download_size = outputFile.length();
+
+ URL url = null;
+ if (old_download_size > 0) {
+ url = readFileInfo();
+ }
+
+ if (url == null) {
+ resume = false;
+ url = getDownloadURL();
+ }
+
+ // URL url = new URL("http://192.168.2.101:8080/zweibruecken.bin");
+ URLConnection c = initConnection(url);
+ if (c != null) {
+
+ if (resume) {
+ c.setRequestProperty("Range", "bytes=" + old_download_size + "-");
+ already_read = old_download_size;
+ }
+ try {
+ real_size_bytes = Long.parseLong(c.getHeaderField("Content-Length")) + already_read;
+ } catch (Exception e) {
+ real_size_bytes = -1;
+ }
+
+ long fileTime = c.getLastModified();
+
+ if (!resume) {
+ outputFile.delete();
+ writeFileInfo(c, real_size_bytes);
+ }
+
+ if (real_size_bytes <= 0) {
+ real_size_bytes = map_values.est_size_bytes;
+ }
+
+ Log.d(TAG, "size: " + real_size_bytes + ", read: " + already_read + ", timestamp: "
+ + fileTime
+ + ", Connection ref: " + c.getURL());
+
+ if (checkFreeSpace(real_size_bytes - already_read)
+ && downloadData(c, already_read, real_size_bytes, resume, outputFile)) {
+
+ File finalOutputFile = getMapFile();
+ // delete an already existing file first
+ finalOutputFile.delete();
+ // rename file to its final name
+ outputFile.renameTo(finalOutputFile);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private File getDestinationFile() {
+ File outputFile = new File(map_filename_path, map_values.map_name + ".tmp");
+ outputFile.getParentFile().mkdir();
+ return outputFile;
+ }
+
+ private boolean downloadData(URLConnection c, long already_read, long real_size_bytes, boolean resume,
+ File outputFile) {
+ boolean success = false;
+ BufferedOutputStream buf = getOutputStream(outputFile, resume);
+ BufferedInputStream bif = getInputStream(c);
+
+ if (buf != null && bif != null) {
+ success = readData(buf, bif, already_read, real_size_bytes);
+ // always cleanup, as we might get errors when trying to resume
+ try {
+ buf.flush();
+ buf.close();
+
+ bif.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return success;
+ }
+
+ private URL getDownloadURL() {
+ URL url;
+ try {
+ url =
+ new URL("http://maps.navit-project.org/api/map/?bbox=" + map_values.lon1 + ","
+ + map_values.lat1
+ + "," + map_values.lon2 + "," + map_values.lat2);
+ } catch (MalformedURLException e) {
+ Log.e(TAG, "We failed to create a URL to " + map_values.map_name);
+ e.printStackTrace();
+ return null;
+ }
+ Log.v(TAG, "connect to " + url.toString());
+ return url;
+ }
+
+ private long getFreeSpace() {
+ try {
+ StatFs fsInfo = new StatFs(map_filename_path);
+ return (long) fsInfo.getAvailableBlocks() * fsInfo.getBlockSize();
+ } catch (Exception e) {
+ return -1;
+ }
+ }
+
+ private BufferedInputStream getInputStream(URLConnection c) {
+ BufferedInputStream bif;
+ try {
+ bif = new BufferedInputStream(c.getInputStream(), MAP_READ_FILE_BUFFER);
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "File not found on server: " + e);
+ if (retry_counter > 0) {
+ getMapInfoFile().delete();
+ }
+ enableRetry();
+ bif = null;
+ } catch (IOException e) {
+ Log.e(TAG, "Error reading from server: " + e);
+ enableRetry();
+ bif = null;
+ }
+ return bif;
+ }
+
+ private File getMapFile() {
+ return new File(map_filename_path, map_values.map_name + ".bin");
+ }
+
+ private File getMapInfoFile() {
+ return new File(map_filename_path, map_values.map_name + ".tmp.info");
+ }
+
+ private BufferedOutputStream getOutputStream(File outputFile, boolean resume) {
+ BufferedOutputStream buf;
+ try {
+ buf = new BufferedOutputStream(new FileOutputStream(outputFile, resume),
+ MAP_WRITE_FILE_BUFFER);
+ } catch (FileNotFoundException e) {
+ Log.e(TAG, "Could not open output file for writing: " + e);
+ buf = null;
+ }
+ return buf;
+ }
+
+ private URLConnection initConnection(URL url) {
+ HttpURLConnection c;
+ try {
+ c = (HttpURLConnection) url.openConnection();
+ c.setRequestMethod("GET");
+ } catch (Exception e) {
+ Log.e(TAG, "Failed connecting server: " + e);
+ enableRetry();
+ return null;
+ }
+
+ c.setReadTimeout(SOCKET_READ_TIMEOUT);
+ c.setConnectTimeout(SOCKET_CONNECT_TIMEOUT);
+ return c;
+ }
+
+ private boolean readData(OutputStream buf, InputStream bif, long already_read,
+ long real_size_bytes) {
+ long start_timestamp = System.nanoTime();
+ byte[] buffer = new byte[MAP_WRITE_MEM_BUFFER];
+ int len1;
+ long startOffset = already_read;
+ boolean success = false;
+
+ try {
+ while (!stop_me && (len1 = bif.read(buffer)) != -1) {
+ already_read += len1;
+ updateProgress(start_timestamp, startOffset, already_read, real_size_bytes);
+
+ try {
+ buf.write(buffer, 0, len1);
+ } catch (IOException e) {
+ Log.d(TAG, "Error: " + e);
+ if (!checkFreeSpace(real_size_bytes - already_read + MAP_WRITE_FILE_BUFFER)) {
+ if (deleteMap()) {
+ enableRetry();
+ } else {
+ updateProgress(already_read, real_size_bytes,
+ Navit.getInstance().getTstring(R.string.map_download_download_error) + "\n"
+ + Navit.getInstance().getTstring(R.string.map_download_not_enough_free_space));
+ }
+ } else {
+ updateProgress(already_read, real_size_bytes,
+ Navit.getInstance().getTstring(R.string.map_download_error_writing_map));
+ }
+
+ return false;
+ }
+ }
+
+ if (stop_me) {
+ toast(Navit.getInstance().getTstring(R.string.map_download_download_aborted));
+ } else if (already_read < real_size_bytes) {
+ Log.d(TAG, "Server send only " + already_read + " bytes of " + real_size_bytes);
+ enableRetry();
+ } else {
+ success = true;
+ }
+ } catch (IOException e) {
+ Log.d(TAG, "Error: " + e);
+
+ enableRetry();
+ updateProgress(already_read, real_size_bytes,
+ Navit.getInstance().getTstring(R.string.map_download_download_error));
+ }
+
+ return success;
+ }
+
+ private URL readFileInfo() {
+ URL url = null;
+ try {
+ ObjectInputStream infoStream = new ObjectInputStream(
+ new FileInputStream(getMapInfoFile()));
+ String resume_proto = infoStream.readUTF();
+ infoStream.readUTF(); // read the host name (unused for now)
+ String resume_file = infoStream.readUTF();
+ infoStream.close();
+ // looks like the same file, try to resume
+ Log.v(TAG, "Try to resume download");
+ url = new URL(resume_proto + "://" + "maps.navit-project.org" + resume_file);
+ } catch (Exception e) {
+ getMapInfoFile().delete();
+ }
+ return url;
+ }
+
+ private void toast(String message) {
+ NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST, null, message, -1, 0, 0);
+ }
+
+ private void updateProgress(long startTime, long offsetBytes, long readBytes, long maxBytes) {
+ long currentTime = System.nanoTime();
+
+ if ((currentTime > uiLastUpdated + UPDATE_PROGRESS_TIME_NS) && startTime != currentTime) {
+ float per_second_overall = (readBytes - offsetBytes) / ((currentTime - startTime) / 1000000000f);
+ long bytes_remaining = maxBytes - readBytes;
+ int eta_seconds = (int) (bytes_remaining / per_second_overall);
+
+ String eta_string;
+ if (eta_seconds > 60) {
+ eta_string = (int) (eta_seconds / 60f) + " m";
+ } else {
+ eta_string = eta_seconds + " s";
+ }
+ String info = String.format("%s: %s\n %dMb / %dMb\n %.1f kb/s %s: %s",
+ Navit.getInstance().getTstring(R.string.map_downloading),
+ map_values.map_name, readBytes / 1024 / 1024, maxBytes / 1024 / 1024,
+ per_second_overall / 1024f, Navit.getInstance().getTstring(R.string.map_download_eta),
+ eta_string);
+
+ if (retry_counter > 0) {
+ info += "\n Retry " + retry_counter + "/" + MAX_RETRIES;
+ }
+ Log.d(TAG, "info: " + info);
+
+ updateProgress(readBytes, maxBytes, info);
+ uiLastUpdated = currentTime;
+ }
+ }
+
+ private void updateProgress(long positionBytes, long maximumBytes, String infoText) {
+ NavitDialogs.sendDialogMessage(NavitDialogs.MSG_PROGRESS_BAR,
+ Navit.getInstance().getTstring(R.string.map_download_title), infoText,
+ NavitDialogs.DIALOG_MAPDOWNLOAD, (int) (maximumBytes / 1024),
+ (int) (positionBytes / 1024));
+ }
+
+ private void writeFileInfo(URLConnection c, long sizeInBytes) {
+ ObjectOutputStream infoStream;
+ try {
+ infoStream = new ObjectOutputStream(new FileOutputStream(getMapInfoFile()));
+ infoStream.writeUTF(c.getURL().getProtocol());
+ infoStream.writeUTF(c.getURL().getHost());
+ infoStream.writeUTF(c.getURL().getFile());
+ infoStream.writeLong(sizeInBytes);
+ infoStream.close();
+ } catch (Exception e) {
+ Log.e(TAG,
+ "Could not write info file for map download. Resuming will not be possible. ("
+ + e.getMessage() + ")");
+ }
+ }
+
+ private void enableRetry() {
+ retryDownload = true;
+ retry_counter++;
+ }
+
+ public static class osm_map_values {
+
+ final String lon1;
+ final String lat1;
+ final String lon2;
+ final String lat2;
+ final String map_name;
+ final long est_size_bytes;
+ final int level;
+
+
+ private osm_map_values(String mapname, String lon_1, String lat_1, String lon_2,
+ String lat_2,
+ long bytes_est, int level) {
+ this.map_name = mapname;
+ this.lon1 = lon_1;
+ this.lat1 = lat_1;
+ this.lon2 = lon_2;
+ this.lat2 = lat_2;
+ this.est_size_bytes = bytes_est;
+ this.level = level;
+ }
+
+ public boolean isInMap(Location location) {
+ double longitude_1 = Double.valueOf(this.lon1);
+ double latitude_1 = Double.valueOf(this.lat1);
+ double longitude_2 = Double.valueOf(this.lon2);
+ double latitude_2 = Double.valueOf(this.lat2);
+
+ if (location.getLongitude() < longitude_1) {
+ return false;
+ }
+ if (location.getLongitude() > longitude_2) {
+ return false;
+ }
+ if (location.getLatitude() < latitude_1) {
+ return false;
+ }
+ if (location.getLatitude() > latitude_2) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/navit/android/src/org/navitproject/navit/NavitRestoreTask.java b/navit/android/src/org/navitproject/navit/NavitRestoreTask.java
index aaffcb002..e4c774fb9 100644
--- a/navit/android/src/org/navitproject/navit/NavitRestoreTask.java
+++ b/navit/android/src/org/navitproject/navit/NavitRestoreTask.java
@@ -1,7 +1,5 @@
-
package org.navitproject.navit;
-import android.app.Activity;
import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.content.Context;
@@ -9,10 +7,8 @@ import android.content.SharedPreferences.Editor;
import android.os.AsyncTask;
import android.os.Environment;
import android.widget.Toast;
-
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Map;
@@ -38,7 +34,7 @@ public class NavitRestoreTask extends AsyncTask<Void, Void, String> {
/* Create a Wait Progress Dialog to inform the User that we are working */
mDialog = new ProgressDialog(mActivity);
mDialog.setIndeterminate(true);
- mDialog.setMessage(mActivity.getString(R.string.restoring));
+ mDialog.setMessage(mActivity.getTstring(R.string.restoring));
mDialog.show();
}
@@ -47,28 +43,35 @@ public class NavitRestoreTask extends AsyncTask<Void, Void, String> {
protected String doInBackground(Void... v) {
/* This is the Directory where all Subdirectories are stored by date */
- File backupDir = new File(Environment.getExternalStorageDirectory().getPath() + "/navit/backup/" + mTimestamp);
-
+ File backupDir = new File(
+ Environment.getExternalStorageDirectory().getPath() + "/navit/backup/"
+ + mTimestamp);
+
/* Check if there is a Backup Directory */
- if (!backupDir.isDirectory())
- return mActivity.getString(R.string.backup_not_found);
+ if (!backupDir.isDirectory()) {
+ return mActivity.getTstring(R.string.backup_not_found);
+ }
- ObjectInputStream preferenceOIS = null;
+ ObjectInputStream preferenceOis = null;
try {
/* Delete all old Files in Home */
mActivity.removeFileIfExists(Navit.NAVIT_DATA_DIR + "/home/bookmark.txt");
mActivity.removeFileIfExists(Navit.NAVIT_DATA_DIR + "/home/destination.txt");
mActivity.removeFileIfExists(Navit.NAVIT_DATA_DIR + "/home/gui_internal.txt");
-
+
/* Restore Files in home */
- mActivity.copyFileIfExists(backupDir.getPath() + "/bookmark.txt", Navit.NAVIT_DATA_DIR + "/home/bookmark.txt");
- mActivity.copyFileIfExists(backupDir.getPath() + "/destination.txt", Navit.NAVIT_DATA_DIR + "/home/destination.txt");
- mActivity.copyFileIfExists(backupDir.getPath() + "/gui_internal.txt", Navit.NAVIT_DATA_DIR + "/home/gui_internal.txt");
+ mActivity.copyFileIfExists(backupDir.getPath() + "/bookmark.txt",
+ Navit.NAVIT_DATA_DIR + "/home/bookmark.txt");
+ mActivity.copyFileIfExists(backupDir.getPath() + "/destination.txt",
+ Navit.NAVIT_DATA_DIR + "/home/destination.txt");
+ mActivity.copyFileIfExists(backupDir.getPath() + "/gui_internal.txt",
+ Navit.NAVIT_DATA_DIR + "/home/gui_internal.txt");
/* Restore Shared Preferences */
- preferenceOIS = new ObjectInputStream(new FileInputStream(backupDir.getPath() + "/preferences.bak"));
- Map<String, ?> entries = (Map<String, ?>) preferenceOIS.readObject();
+ preferenceOis = new ObjectInputStream(
+ new FileInputStream(backupDir.getPath() + "/preferences.bak"));
+ Map<String, ?> entries = (Map<String, ?>) preferenceOis.readObject();
Editor prefEditor = mActivity.getSharedPreferences(Navit.NAVIT_PREFS, Context.MODE_PRIVATE).edit();
@@ -80,37 +83,37 @@ public class NavitRestoreTask extends AsyncTask<Void, Void, String> {
Object value = entry.getValue();
String key = entry.getKey();
- if (value instanceof Boolean)
+ if (value instanceof Boolean) {
prefEditor.putBoolean(key, ((Boolean) value).booleanValue());
- else if (value instanceof Float)
+ } else if (value instanceof Float) {
prefEditor.putFloat(key, ((Float) value).floatValue());
- else if (value instanceof Integer)
+ } else if (value instanceof Integer) {
prefEditor.putInt(key, ((Integer) value).intValue());
- else if (value instanceof Long)
+ } else if (value instanceof Long) {
prefEditor.putLong(key, ((Long) value).longValue());
- else if (value instanceof String)
+ } else if (value instanceof String) {
prefEditor.putString(key, (String) value);
+ }
}
- if (!prefEditor.commit())
- return mActivity.getString(R.string.failed_to_restore);
+ if (!prefEditor.commit()) {
+ return mActivity.getTstring(R.string.failed_to_restore);
+ }
- }
- catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
- return mActivity.getString(R.string.failed_to_restore);
- }
- finally {
+ return mActivity.getTstring(R.string.failed_to_restore);
+ } finally {
try {
/* Close Stream to prevent Resource leak */
- if (preferenceOIS != null)
- preferenceOIS.close();
- }
- catch (IOException e) {
-
+ if (preferenceOis != null) {
+ preferenceOis.close();
+ }
+ } catch (IOException e) {
+ // Catching but ignoring that exception when closing the stream
+ return null;
}
}
-
return null;
}
@@ -128,7 +131,9 @@ public class NavitRestoreTask extends AsyncTask<Void, Void, String> {
}
/* Navit needs to be restarted. Currently the User has to restart it by himself */
- Toast.makeText(mActivity, mActivity.getString(R.string.restore_successful_please_restart_navit), Toast.LENGTH_LONG).show();
+ Toast.makeText(mActivity,
+ mActivity.getTstring(R.string.restore_successful_please_restart_navit),
+ Toast.LENGTH_LONG).show();
NotificationManager nm = (NotificationManager) mActivity.getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(R.string.app_name);
NavitVehicle.removeListener();
@@ -138,7 +143,8 @@ public class NavitRestoreTask extends AsyncTask<Void, Void, String> {
@Override
protected void onCancelled() {
super.onCancelled();
- Toast.makeText(mActivity, mActivity.getString(R.string.restore_failed), Toast.LENGTH_LONG).show();
+ Toast.makeText(mActivity, mActivity.getTstring(R.string.restore_failed), Toast.LENGTH_LONG)
+ .show();
mDialog.dismiss();
- }
+ }
}
diff --git a/navit/android/src/org/navitproject/navit/NavitSensors.java b/navit/android/src/org/navitproject/navit/NavitSensors.java
index b263ed082..ad94bdfbe 100644
--- a/navit/android/src/org/navitproject/navit/NavitSensors.java
+++ b/navit/android/src/org/navitproject/navit/NavitSensors.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.navitproject.navit;
import android.content.Context;
@@ -24,29 +25,30 @@ import android.hardware.SensorManager;
public class NavitSensors implements SensorEventListener {
- private SensorManager mSensorManager;
- private int callbackid;
- public native void SensorCallback(int id, int sensor, float x, float y, float z);
-
-
- NavitSensors(Context context, int cbid)
- {
- mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
- mSensorManager.registerListener((SensorEventListener)this, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
- mSensorManager.registerListener((SensorEventListener)this, mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_NORMAL);
- callbackid=cbid;
- }
-
- public void
- onAccuracyChanged(Sensor sensor, int accuracy)
- {
- }
-
- public void
- onSensorChanged(SensorEvent sev)
- {
- // Log.e("NavitSensor","Type:" + sev.sensor.getType() + " X:" + sev.values[0] + " Y:"+sev.values[1]+" Z:"+sev.values[2]);
- SensorCallback(callbackid, sev.sensor.getType(), sev.values[0], sev.values[1], sev.values[2]);
- }
+ private SensorManager mSensorManager;
+ private int callbackid;
+
+ public native void SensorCallback(int id, int sensor, float x, float y, float z);
+
+
+ NavitSensors(Context context, int cbid) {
+ mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
+ mSensorManager.registerListener((SensorEventListener)this,
+ mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
+ SensorManager.SENSOR_DELAY_NORMAL);
+ mSensorManager.registerListener((SensorEventListener)this,
+ mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
+ SensorManager.SENSOR_DELAY_NORMAL);
+ callbackid = cbid;
+ }
+
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+ }
+
+ public void onSensorChanged(SensorEvent sev) {
+ // Log.e("NavitSensor","Type:" + sev.sensor.getType() + " X:" + sev.values[0] + " Y:"+sev.values[1]+" Z:"
+ // +sev.values[2]);
+ SensorCallback(callbackid, sev.sensor.getType(), sev.values[0], sev.values[1], sev.values[2]);
+ }
}
diff --git a/navit/android/src/org/navitproject/navit/NavitSpeech.java b/navit/android/src/org/navitproject/navit/NavitSpeech.java
deleted file mode 100644
index ac6b5de4c..000000000
--- a/navit/android/src/org/navitproject/navit/NavitSpeech.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-package org.navitproject.navit;
-
-import android.util.Log;
-
-import com.google.tts.TTS;
-
-
-public class NavitSpeech implements Runnable {
- private TTS tts;
- private TTS.InitListener ttsInitListener;
- private String what;
- private Thread thread;
-
- NavitSpeech(Navit navit)
- {
- ttsInitListener = new TTS.InitListener() {
- public void onInit(int version) {
- }
- };
- tts=new TTS(navit, ttsInitListener, true);
- }
- public void run()
- {
- Log.e("NavitSpeech","In "+what);
- tts.speak(what, 0, null);
- }
- public void say(String what)
- {
- this.what=what;
- thread = new Thread(this, "speech thread");
- thread.start();
- }
-}
-
diff --git a/navit/android/src/org/navitproject/navit/NavitSpeech2.java b/navit/android/src/org/navitproject/navit/NavitSpeech2.java
index b4ec85d4e..c86fdd1c8 100644
--- a/navit/android/src/org/navitproject/navit/NavitSpeech2.java
+++ b/navit/android/src/org/navitproject/navit/NavitSpeech2.java
@@ -1,90 +1,88 @@
/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
+ * Navit, a modular navigation system. Copyright (C) 2005-2008 Navit Team
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License version 2 as published by the Free Software Foundation.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
*/
package org.navitproject.navit;
-import android.content.Intent;
-import android.content.Context;
+import android.app.AlertDialog;
import android.content.DialogInterface;
+import android.content.Intent;
import android.content.pm.PackageManager;
-import android.app.AlertDialog;
import android.speech.tts.TextToSpeech;
import android.util.Log;
+@SuppressWarnings("unused")
public class NavitSpeech2 implements TextToSpeech.OnInitListener, NavitActivityResult {
- private TextToSpeech mTts;
- private Navit navit;
- int MY_DATA_CHECK_CODE=1;
+ private final Navit navit;
+ private final int MY_DATA_CHECK_CODE = 1;
+ private final String TAG = this.getClass().getName();
+ private TextToSpeech mTts;
+
+
+ NavitSpeech2(Navit navit) {
+ this.navit = navit;
+ navit.setActivityResult(1, this);
+ Log.d(TAG, "Create");
+ Intent checkIntent = new Intent();
+ checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
+ if (navit.getPackageManager()
+ .resolveActivity(checkIntent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
+ Log.d(TAG, "ACTION_CHECK_TTS_DATA available");
+ navit.startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
+ } else {
+ Log.e(TAG, "ACTION_CHECK_TTS_DATA not available, assume tts is working");
+ mTts = new TextToSpeech(navit.getApplication(), this);
+ }
+ }
- public void onInit(int status)
- {
- Log.e("NavitSpeech2","Status "+status);
- }
+ public void onInit(int status) {
+ Log.d(TAG, "Status " + status);
+ }
- public void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- Log.e("NavitSpeech2","onActivityResult "+requestCode+" "+resultCode);
- if (requestCode == MY_DATA_CHECK_CODE) {
- if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
- // success, create the TTS instance
- mTts = new TextToSpeech(navit, this);
- } else {
- // missing data, ask to install it
- AlertDialog.Builder builder = new AlertDialog.Builder(navit);
- builder
- .setTitle(R.string.TTS_title_data_missing)
- .setMessage(R.string.TTS_qery_install_data)
- .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- Intent installIntent = new Intent();
- installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
- navit.startActivity(installIntent);
- }
- })
- .setNegativeButton(R.string.no, null)
- .show();
- }
- }
- }
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ Log.d(TAG, "onActivityResult " + requestCode + " " + resultCode);
+ if (requestCode == MY_DATA_CHECK_CODE) {
+ if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
+ // success, create the TTS instance
+ mTts = new TextToSpeech(navit.getApplication(), this);
+ } else {
+ // missing data, ask to install it
+ AlertDialog.Builder builder = new AlertDialog.Builder(navit);
+ builder
+ .setTitle(navit.getTstring(R.string.TTS_title_data_missing))
+ .setMessage(navit.getTstring(R.string.TTS_qery_install_data))
+ .setPositiveButton(navit.getTstring(R.string.yes),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent installIntent = new Intent();
+ installIntent.setAction(
+ TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
+ navit.startActivity(installIntent);
+ }
+ })
+ .setNegativeButton(navit.getTstring(R.string.no), null)
+ .show();
+ }
+ }
+ }
- NavitSpeech2(Navit navit)
- {
- this.navit=navit;
- navit.setActivityResult(1, this);
- Log.e("NavitSpeech2","Create");
- Intent checkIntent = new Intent();
- checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
- if (navit.getPackageManager().resolveActivity(checkIntent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
- Log.e("NavitSpeech2","ACTION_CHECK_TTS_DATA available");
- navit.startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
- } else {
- Log.e("NavitSpeech2","ACTION_CHECK_TTS_DATA not available, assume tts is working");
- mTts = new TextToSpeech(navit, this);
- }
- }
- public void say(String what)
- {
- if (mTts != null) {
- mTts.speak(what, TextToSpeech.QUEUE_FLUSH, null);
- }
- }
+ public void say(String what) {
+ if (mTts != null) {
+ mTts.speak(what, TextToSpeech.QUEUE_FLUSH, null);
+ }
+ }
}
diff --git a/navit/android/src/org/navitproject/navit/NavitTextTranslations.java b/navit/android/src/org/navitproject/navit/NavitTextTranslations.java
deleted file mode 100644
index 93aa5fe76..000000000
--- a/navit/android/src/org/navitproject/navit/NavitTextTranslations.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-package org.navitproject.navit;
-
-import java.util.HashMap;
-
-import android.util.Log;
-
-public class NavitTextTranslations
-{
- static String main_language = "en";
- static String sub_language = "EN";
- static String fallback_language = "en";
- static String fallback_sub_language = "EN";
- private static HashMap<String, HashMap<String, String>> Navit_text_lookup = new HashMap<String, HashMap<String, String>>();
-
- public static void init()
- {
- Log.e("NavitTextTranslations", "initializing translated text ...");
- String k = null;
- String[] v = null;
-/*
- k = "exit navit";
- v = new String[]{"en", "Exit Navit", "de", "Navit beenden", "nl", "Navit afsluiten", "fr","Quittez Navit"};
- p(k, v);
-
- k = "zoom in";
- v = new String[]{"en", "Zoom in", "fr", "Zoom-avant"};
- p(k, v);
-
- k = "zoom out";
- v = new String[]{"en", "Zoom out", "fr", "Zoom-arrière", "nl", "Zoom uit"};
- p(k, v);
-
- k = "address search";
- v = new String[]{"en", "Address search", "de", "Adresse suchen", "nl", "Zoek adres", "fr","Cherchez adresse"};
- p(k, v);
-
- k = "Mapdownload";
- v = new String[]{"en", "Mapdownload", "de", "Kartendownload"};
- p(k, v);
-
- k = "downloading";
- v = new String[]{"en", "downloading"};
- p(k, v);
-
- k = "Downloaded maps";
- v = new String[]{"en", "Downloaded maps", "de", "Heruntergeladene Karten", "nl", "Gedownloade kaarten", "fr","Cartes téléchargées" };
- p(k, v);
-
- k = "ETA";
- v = new String[]{"en", "ETA", "de", "fertig in"};
- p(k, v);
-
- k = "Error downloading map";
- v = new String[]{"en", "Error downloading map!", "de", "Fehler beim Kartendownload"};
- p(k, v);
-
- k = "ready";
- v = new String[]{"en", "ready", "de", "fertig"};
- p(k, v);
-
- k = "Ok";
- v = new String[]{"en", "OK"};
- p(k, v);
-
- k = "No address found";
- v = new String[]{"en", "No address found", "de", "Keine Adresse gefunden"};
- p(k, v);
-
- k = "Enter: City and Street";
- v = new String[]{"en", "Enter: City, Street", "de", "Stadt und Straße:"};
- p(k, v);
-
- k = "No search string entered";
- v = new String[]{"en", "No text entered", "de", "Keine Eingabe"};
- p(k, v);
-
- k = "setting destination to";
- v = new String[]{"en", "Setting destination to:", "de", "neues Fahrziel"};
- p(k, v);
-
- k = "getting search results";
- v = new String[]{"en", "getting search results", "de", "lade Suchergebnisse"};
- p(k, v);
-
- k = "searching ...";
- v = new String[]{"en", "searching ...", "de", "Suche läuft ..."};
- p(k, v);
-
- k = "No Results found!";
- v = new String[]{"en", "No Results found!", "de", "Suche liefert kein Ergebnis!"};
- p(k, v);
-
- k = "Map data (c) OpenStreetMap contributors, CC-BY-SA";
- v = new String[]{"en", "Map data (c) OpenStreetMap contributors, CC-BY-SA"};
- p(k, v);
-
- k = "partial match";
- v = new String[]{"en", "partial match", "de", "ungefähr"};
- p(k, v);
-
- k = "Search";
- v = new String[]{"en", "Search", "de", "suchen"};
- p(k, v);
-
- k = "drive here";
- v = new String[]{"en", "Route to here", "de", "Ziel setzen"};
- p(k, v);
-
- k = "loading search results";
- v = new String[]{"en", "Loading search results", "de", "lade Suchergebnisse"};
- p(k, v);
-
- k = "towns";
- v = new String[]{"en", "Towns", "de", "Städte"};
- p(k, v);
-*/
- Log.e("NavitTextTranslations", "... ready");
- }
-
- private static void p(String key, String[] values)
- {
- HashMap<String, String> t = new HashMap<String, String>();
- //Log.e("NavitTextTranslations", "trying: " + key);
- try
- {
- for (int i = 0; i < (int) (values.length / 2); i++)
- {
- t.put(values[i * 2], values[(i * 2) + 1]);
- }
- Navit_text_lookup.put(key, t);
- }
- catch (Exception e)
- {
- Log.e("NavitTextTranslations", "!!Error in translationkey: " + key);
- }
- }
-
- public static String get_text(String in)
- {
- String out = null;
- //Log.e("NavitTextTranslations", "lookup L:" + main_language + " T:" + in);
- try
- {
- out = Navit_text_lookup.get(in).get(main_language);
- }
- catch (Exception e)
- {
- // most likely there is not translation yet
- //Log.e("NavitTextTranslations", "lookup: exception");
- out = null;
- }
-
- if (out == null)
- {
- // always return a string for output (use fallback language)
- //Log.e("NavitTextTranslations", "using default language");
- try
- {
- out = Navit_text_lookup.get(in).get(fallback_language);
- }
- catch (Exception e)
- {
- //Log.e("NavitTextTranslations", "using default language: exception");
- // most likely there is not translation yet
- out = null;
- }
- }
-
- if (out == null)
- {
- // if we still dont have any text, use the ".mo" file and call the c-function gettext(in)
- out = NavitGraphics.getLocalizedString(in);
- if (out != null)
- {
- HashMap<String, String> langmap = new HashMap<String, String>();
- langmap.put(main_language, out);
- Navit_text_lookup.put(in, langmap);
- }
-
- //Log.e("NavitTextTranslations", "return the value from gettext() = " + out);
- }
- return out;
- }
-
-}
diff --git a/navit/android/src/org/navitproject/navit/NavitTimeout.java b/navit/android/src/org/navitproject/navit/NavitTimeout.java
index b70d8a1ad..81451ab47 100644
--- a/navit/android/src/org/navitproject/navit/NavitTimeout.java
+++ b/navit/android/src/org/navitproject/navit/NavitTimeout.java
@@ -26,33 +26,34 @@ import android.util.Log;
public class NavitTimeout implements Runnable {
- private static Handler handler =new Handler() {
- public void handleMessage(Message m) {
- Log.e("Navit","Handler received message");
- }
- };
- private boolean event_multi;
- private int event_callbackid;
- private int event_timeout;
- public native void TimeoutCallback(int id);
-
- NavitTimeout(int timeout, boolean multi, int callbackid)
- {
- event_timeout=timeout;
- event_multi=multi;
- event_callbackid=callbackid;
- handler.postDelayed(this, event_timeout);
- }
- public void run() {
- // Log.e("Navit","Handle Event");
- if (event_multi) {
- handler.postDelayed(this, event_timeout);
- }
- TimeoutCallback(event_callbackid);
- }
- public void remove()
- {
- handler.removeCallbacks(this);
- }
+ private static Handler handler = new Handler() {
+ public void handleMessage(Message m) {
+ Log.e("Navit","Handler received message");
+ }
+ };
+ private boolean event_multi;
+ private int event_callbackid;
+ private int event_timeout;
+
+ public native void TimeoutCallback(int id);
+
+ NavitTimeout(int timeout, boolean multi, int callbackid) {
+ event_timeout = timeout;
+ event_multi = multi;
+ event_callbackid = callbackid;
+ handler.postDelayed(this, event_timeout);
+ }
+
+ public void run() {
+ // Log.e("Navit","Handle Event");
+ if (event_multi) {
+ handler.postDelayed(this, event_timeout);
+ }
+ TimeoutCallback(event_callbackid);
+ }
+
+ public void remove() {
+ handler.removeCallbacks(this);
+ }
}
diff --git a/navit/android/src/org/navitproject/navit/NavitTraff.java b/navit/android/src/org/navitproject/navit/NavitTraff.java
new file mode 100644
index 000000000..a98b91948
--- /dev/null
+++ b/navit/android/src/org/navitproject/navit/NavitTraff.java
@@ -0,0 +1,108 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2018 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+package org.navitproject.navit;
+
+import android.Manifest;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.util.Log;
+
+import java.util.List;
+
+/**
+ * @brief The TraFF receiver implementation.
+ *
+ * This class registers the broadcast receiver for TraFF feeds, polls all registered sources once on creation, receives
+ * TraFF feeds and forwards them to the traffic module for processing.
+ */
+public class NavitTraff extends BroadcastReceiver {
+ public static String ACTION_TRAFF_FEED = "org.traffxml.traff.FEED";
+
+ public static String ACTION_TRAFF_POLL = "org.traffxml.traff.POLL";
+
+ public static String EXTRA_FEED = "feed";
+
+ /** Identifier for the callback function. */
+ private int cbid;
+
+ private Context context = null;
+
+ /** An intent filter for TraFF events. */
+ private IntentFilter traffFilter = new IntentFilter();
+
+ /**
+ * @brief Forwards a newly received TraFF feed to the traffic module for processing.
+ *
+ * This is called when a TraFF feed is received.
+ *
+ * @param id The identifier for the native callback implementation
+ * @param feed The TraFF feed
+ */
+ public native void onFeedReceived(int id, String feed);
+
+ /**
+ * @brief Creates a new {@code NavitTraff} instance.
+ *
+ * Creating a new {@code NavitTraff} instance registers a broadcast receiver for TraFF broadcasts and polls all
+ * registered sources once to ensure we have messages which were received by these sources before we started up.
+ *
+ * @param context The context
+ * @param cbid The callback identifier for the native method to call upon receiving a feed
+ */
+ NavitTraff(Context context, int cbid) {
+ this.context = context;
+ this.cbid = cbid;
+
+ traffFilter.addAction(ACTION_TRAFF_FEED);
+ traffFilter.addAction(ACTION_TRAFF_POLL);
+
+ context.registerReceiver(this, traffFilter);
+ /* TODO unregister receiver on exit */
+
+ /* Broadcast a poll intent */
+ Intent outIntent = new Intent(ACTION_TRAFF_POLL);
+ PackageManager pm = context.getPackageManager();
+ List<ResolveInfo> receivers = pm.queryBroadcastReceivers(outIntent, 0);
+ if (receivers != null)
+ for (ResolveInfo receiver : receivers) {
+ ComponentName cn = new ComponentName(receiver.activityInfo.applicationInfo.packageName,
+ receiver.activityInfo.name);
+ outIntent = new Intent(ACTION_TRAFF_POLL);
+ outIntent.setComponent(cn);
+ context.sendBroadcast(outIntent, Manifest.permission.ACCESS_COARSE_LOCATION);
+ }
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if ((intent != null) && (intent.getAction().equals(ACTION_TRAFF_FEED))) {
+ String feed = intent.getStringExtra(EXTRA_FEED);
+ if (feed == null)
+ Log.w(this.getClass().getSimpleName(), "empty feed, ignoring");
+ else
+ onFeedReceived(cbid, feed);
+ }
+ }
+}
diff --git a/navit/android/src/org/navitproject/navit/NavitVehicle.java b/navit/android/src/org/navitproject/navit/NavitVehicle.java
index 313502b96..200fc3eec 100644
--- a/navit/android/src/org/navitproject/navit/NavitVehicle.java
+++ b/navit/android/src/org/navitproject/navit/NavitVehicle.java
@@ -19,12 +19,11 @@
package org.navitproject.navit;
-import java.util.List;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.GpsSatellite;
import android.location.GpsStatus;
@@ -32,154 +31,180 @@ import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
+import android.support.v4.content.ContextCompat;
import android.util.Log;
+import java.util.List;
+
+
+
public class NavitVehicle {
-
- public static final String GPS_FIX_CHANGE = "android.location.GPS_FIX_CHANGE";
-
- public static Location lastLocation = null;
-
- private static LocationManager sLocationManager = null;
- private static Context context = null;
- private int vehicle_pcbid;
- private int vehicle_scbid;
- private int vehicle_fcbid;
- private String preciseProvider;
- private String fastProvider;
-
- private static NavitLocationListener preciseLocationListener = null;
- private static NavitLocationListener fastLocationListener = null;
-
- public native void VehicleCallback(int id, Location location);
- public native void VehicleCallback(int id, int satsInView, int satsUsed);
- public native void VehicleCallback(int id, int enabled);
-
- private class NavitLocationListener extends BroadcastReceiver implements GpsStatus.Listener, LocationListener {
- public boolean precise = false;
- public void onLocationChanged(Location location) {
- lastLocation = location;
- // Disable the fast provider if still active
- if (precise && fastProvider != null) {
- sLocationManager.removeUpdates(fastLocationListener);
- fastProvider = null;
- }
-
- VehicleCallback(vehicle_pcbid, location);
- VehicleCallback(vehicle_fcbid, 1);
- }
- public void onProviderDisabled(String provider){}
- public void onProviderEnabled(String provider) {}
- public void onStatusChanged(String provider, int status, Bundle extras) {}
-
- /**
- * Called when the status of the GPS changes.
- */
- public void onGpsStatusChanged (int event) {
- GpsStatus status = sLocationManager.getGpsStatus(null);
- int satsInView = 0;
- int satsUsed = 0;
- Iterable<GpsSatellite> sats = status.getSatellites();
- for (GpsSatellite sat : sats) {
- satsInView++;
- if (sat.usedInFix()) {
- satsUsed++;
- }
- }
- VehicleCallback(vehicle_scbid, satsInView, satsUsed);
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(GPS_FIX_CHANGE)) {
- if (intent.getBooleanExtra("enabled", false))
- VehicleCallback(vehicle_fcbid, 1);
- else if (!intent.getBooleanExtra("enabled", true))
- VehicleCallback(vehicle_fcbid, 0);
- }
- }
- }
-
- /**
- * @brief Creates a new {@code NavitVehicle}
- *
- * @param context
- * @param pcbid The address of the position callback function which will be called when a location update is received
- * @param scbid The address of the status callback function which will be called when a status update is received
- * @param fcbid The address of the fix callback function which will be called when a
- * {@code android.location.GPS_FIX_CHANGE} is received, indicating a change in GPS fix status
- */
- NavitVehicle (Context context, int pcbid, int scbid, int fcbid) {
- this.context = context;
- sLocationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
- preciseLocationListener = new NavitLocationListener();
- preciseLocationListener.precise = true;
- fastLocationListener = new NavitLocationListener();
-
- /* Use 2 LocationProviders, one precise (usually GPS), and one
- not so precise, but possible faster. The fast provider is
- disabled when the precise provider gets its first fix. */
-
- // Selection criteria for the precise provider
- Criteria highCriteria = new Criteria();
- highCriteria.setAccuracy(Criteria.ACCURACY_FINE);
- highCriteria.setAltitudeRequired(true);
- highCriteria.setBearingRequired(true);
- highCriteria.setCostAllowed(true);
- highCriteria.setPowerRequirement(Criteria.POWER_HIGH);
-
- // Selection criteria for the fast provider
- Criteria lowCriteria = new Criteria();
- lowCriteria.setAccuracy(Criteria.ACCURACY_COARSE);
- lowCriteria.setAltitudeRequired(false);
- lowCriteria.setBearingRequired(false);
- lowCriteria.setCostAllowed(true);
- lowCriteria.setPowerRequirement(Criteria.POWER_HIGH);
-
- Log.e("NavitVehicle", "Providers " + sLocationManager.getAllProviders());
-
- preciseProvider = sLocationManager.getBestProvider(highCriteria, false);
- Log.e("NavitVehicle", "Precise Provider " + preciseProvider);
- fastProvider = sLocationManager.getBestProvider(lowCriteria, false);
- Log.e("NavitVehicle", "Fast Provider " + fastProvider);
- vehicle_pcbid = pcbid;
- vehicle_scbid = scbid;
- vehicle_fcbid = fcbid;
-
- context.registerReceiver(preciseLocationListener, new IntentFilter(GPS_FIX_CHANGE));
- sLocationManager.requestLocationUpdates(preciseProvider, 0, 0, preciseLocationListener);
- sLocationManager.addGpsStatusListener(preciseLocationListener);
-
- /*
- * Since Android criteria have no way to specify "fast fix", lowCriteria may return the same
- * provider as highCriteria, even if others are available. In this case, do not register two
- * listeners for the same provider but pick the fast provider manually. (Usually there will
- * only be two providers in total, which makes the choice easy.)
- */
- if (fastProvider == null || preciseProvider.compareTo(fastProvider) == 0) {
- List<String> fastProviderList = sLocationManager.getProviders(lowCriteria, false);
- fastProvider = null;
- for (String fastCandidate: fastProviderList) {
- if (preciseProvider.compareTo(fastCandidate) != 0) {
- fastProvider = fastCandidate;
- break;
- }
- }
- }
- if (fastProvider != null) {
- sLocationManager.requestLocationUpdates(fastProvider, 0, 0, fastLocationListener);
- }
- }
-
- public static void removeListener() {
- if (sLocationManager != null) {
- if (preciseLocationListener != null) {
- sLocationManager.removeUpdates(preciseLocationListener);
- sLocationManager.removeGpsStatusListener(preciseLocationListener);
- context.unregisterReceiver(preciseLocationListener);
- }
- if (fastLocationListener != null) sLocationManager.removeUpdates(fastLocationListener);
- }
-
- }
+
+ private static final String GPS_FIX_CHANGE = "android.location.GPS_FIX_CHANGE";
+
+ public static Location lastLocation = null;
+
+ private static LocationManager sLocationManager = null;
+ private static Context context = null;
+ private int vehicle_pcbid;
+ private int vehicle_scbid;
+ private int vehicle_fcbid;
+ private String preciseProvider;
+ private String fastProvider;
+
+ private static NavitLocationListener preciseLocationListener = null;
+ private static NavitLocationListener fastLocationListener = null;
+
+ public native void VehicleCallback(int id, Location location);
+
+ public native void VehicleCallback(int id, int satsInView, int satsUsed);
+
+ public native void VehicleCallback(int id, int enabled);
+
+ private class NavitLocationListener extends BroadcastReceiver implements GpsStatus.Listener, LocationListener {
+ public boolean precise = false;
+
+ public void onLocationChanged(Location location) {
+ lastLocation = location;
+ // Disable the fast provider if still active
+ if (precise && fastProvider != null) {
+ sLocationManager.removeUpdates(fastLocationListener);
+ fastProvider = null;
+ }
+
+ VehicleCallback(vehicle_pcbid, location);
+ VehicleCallback(vehicle_fcbid, 1);
+ }
+
+ public void onProviderDisabled(String provider) {}
+
+ public void onProviderEnabled(String provider) {}
+
+ public void onStatusChanged(String provider, int status, Bundle extras) {}
+
+ /**
+ * Called when the status of the GPS changes.
+ */
+ public void onGpsStatusChanged(int event) {
+ if (ContextCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED) {
+ // Permission is not granted
+ return;
+ }
+ GpsStatus status = sLocationManager.getGpsStatus(null);
+ int satsInView = 0;
+ int satsUsed = 0;
+ Iterable<GpsSatellite> sats = status.getSatellites();
+ for (GpsSatellite sat : sats) {
+ satsInView++;
+ if (sat.usedInFix()) {
+ satsUsed++;
+ }
+ }
+ VehicleCallback(vehicle_scbid, satsInView, satsUsed);
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(GPS_FIX_CHANGE)) {
+ if (intent.getBooleanExtra("enabled", false)) {
+ VehicleCallback(vehicle_fcbid, 1);
+ } else {
+ if (!intent.getBooleanExtra("enabled", true)) {
+ VehicleCallback(vehicle_fcbid, 0);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @brief Creates a new {@code NavitVehicle}
+ *
+ * @param context
+ * @param pcbid The address of the position callback function called when a location update is received
+ * @param scbid The address of the status callback function called when a status update is received
+ * @param fcbid The address of the fix callback function called when a
+ * {@code android.location.GPS_FIX_CHANGE} is received, indicating a change in GPS fix status
+ */
+ NavitVehicle(Context context, int pcbid, int scbid, int fcbid) {
+ if (ContextCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED) {
+ // Permission is not granted
+ return;
+ }
+ this.context = context;
+ sLocationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
+ preciseLocationListener = new NavitLocationListener();
+ preciseLocationListener.precise = true;
+ fastLocationListener = new NavitLocationListener();
+
+ /* Use 2 LocationProviders, one precise (usually GPS), and one
+ not so precise, but possible faster. The fast provider is
+ disabled when the precise provider gets its first fix. */
+
+ // Selection criteria for the precise provider
+ Criteria highCriteria = new Criteria();
+ highCriteria.setAccuracy(Criteria.ACCURACY_FINE);
+ highCriteria.setAltitudeRequired(true);
+ highCriteria.setBearingRequired(true);
+ highCriteria.setCostAllowed(true);
+ highCriteria.setPowerRequirement(Criteria.POWER_HIGH);
+
+ // Selection criteria for the fast provider
+ Criteria lowCriteria = new Criteria();
+ lowCriteria.setAccuracy(Criteria.ACCURACY_COARSE);
+ lowCriteria.setAltitudeRequired(false);
+ lowCriteria.setBearingRequired(false);
+ lowCriteria.setCostAllowed(true);
+ lowCriteria.setPowerRequirement(Criteria.POWER_HIGH);
+
+ Log.e("NavitVehicle", "Providers " + sLocationManager.getAllProviders());
+
+ preciseProvider = sLocationManager.getBestProvider(highCriteria, false);
+ Log.e("NavitVehicle", "Precise Provider " + preciseProvider);
+ fastProvider = sLocationManager.getBestProvider(lowCriteria, false);
+ Log.e("NavitVehicle", "Fast Provider " + fastProvider);
+ vehicle_pcbid = pcbid;
+ vehicle_scbid = scbid;
+ vehicle_fcbid = fcbid;
+
+ context.registerReceiver(preciseLocationListener, new IntentFilter(GPS_FIX_CHANGE));
+ sLocationManager.requestLocationUpdates(preciseProvider, 0, 0, preciseLocationListener);
+ sLocationManager.addGpsStatusListener(preciseLocationListener);
+
+ /*
+ * Since Android criteria have no way to specify "fast fix", lowCriteria may return the same
+ * provider as highCriteria, even if others are available. In this case, do not register two
+ * listeners for the same provider but pick the fast provider manually. (Usually there will
+ * only be two providers in total, which makes the choice easy.)
+ */
+ if (fastProvider == null || preciseProvider.compareTo(fastProvider) == 0) {
+ List<String> fastProviderList = sLocationManager.getProviders(lowCriteria, false);
+ fastProvider = null;
+ for (String fastCandidate: fastProviderList) {
+ if (preciseProvider.compareTo(fastCandidate) != 0) {
+ fastProvider = fastCandidate;
+ break;
+ }
+ }
+ }
+ if (fastProvider != null) {
+ sLocationManager.requestLocationUpdates(fastProvider, 0, 0, fastLocationListener);
+ }
+ }
+
+ public static void removeListener() {
+ if (sLocationManager != null) {
+ if (preciseLocationListener != null) {
+ sLocationManager.removeUpdates(preciseLocationListener);
+ sLocationManager.removeGpsStatusListener(preciseLocationListener);
+ context.unregisterReceiver(preciseLocationListener);
+ }
+ if (fastLocationListener != null) {
+ sLocationManager.removeUpdates(fastLocationListener);
+ }
+ }
+
+ }
}
diff --git a/navit/android/src/org/navitproject/navit/NavitWatch.java b/navit/android/src/org/navitproject/navit/NavitWatch.java
index ebe5c8727..5f13c83a3 100644
--- a/navit/android/src/org/navitproject/navit/NavitWatch.java
+++ b/navit/android/src/org/navitproject/navit/NavitWatch.java
@@ -19,84 +19,91 @@
package org.navitproject.navit;
-import java.lang.Thread;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
+import java.lang.Thread;
+
public class NavitWatch implements Runnable {
- private Thread thread;
- private static Handler handler =new Handler() {
- public void handleMessage(Message m) {
- Log.e("NavitWatch","Handler received message");
- }
- };
- private boolean removed;
- private int watch_func;
- private int watch_fd;
- private int watch_cond;
- private int watch_callbackid;
- private boolean callback_pending;
- private Runnable callback_runnable;
- public native void poll(int func, int fd, int cond);
- public native void WatchCallback(int id);
+ private Thread thread;
+ private static Handler handler = new Handler() {
+ public void handleMessage(Message m) {
+ Log.e("NavitWatch","Handler received message");
+ }
+ };
+ private boolean removed;
+ private int watch_func;
+ private int watch_fd;
+ private int watch_cond;
+ private int watch_callbackid;
+ private boolean callback_pending;
+ private Runnable callback_runnable;
+
+ public native void poll(int func, int fd, int cond);
+
+ public native void WatchCallback(int id);
+
+ NavitWatch(int func, int fd, int cond, int callbackid) {
+ // Log.e("NavitWatch","Creating new thread for "+fd+" "+cond+" from current thread "
+ // + java.lang.Thread.currentThread().getName());
+ watch_func = func;
+ watch_fd = fd;
+ watch_cond = cond;
+ watch_callbackid = callbackid;
+ final NavitWatch navitwatch = this;
+ callback_runnable = new Runnable() {
+ public void run() {
+ navitwatch.callback();
+ }
+ };
+ thread = new Thread(this, "poll thread");
+ thread.start();
+ }
+
+ public void run() {
+ for (;;) {
+ // Log.e("NavitWatch","Polling "+watch_fd+" "+watch_cond + " from "
+ // + java.lang.Thread.currentThread().getName());
+ poll(watch_func, watch_fd, watch_cond);
+ // Log.e("NavitWatch","poll returned");
+ if (removed) {
+ break;
+ }
+ callback_pending = true;
+ handler.post(callback_runnable);
+ try {
+ // Log.e("NavitWatch","wait");
+ synchronized (this) {
+ if (callback_pending) {
+ this.wait();
+ }
+ }
+ // Log.e("NavitWatch","wait returned");
+ } catch (Exception e) {
+ Log.e("NavitWatch","Exception " + e.getMessage());
+ }
+ if (removed) {
+ break;
+ }
+ }
+ }
+
+ public void callback() {
+ // Log.e("NavitWatch","Calling Callback");
+ if (!removed) {
+ WatchCallback(watch_callbackid);
+ }
+ synchronized (this) {
+ callback_pending = false;
+ // Log.e("NavitWatch","Waking up");
+ this.notify();
+ }
+ }
- NavitWatch(int func, int fd, int cond, int callbackid)
- {
- // Log.e("NavitWatch","Creating new thread for "+fd+" "+cond+" from current thread " + java.lang.Thread.currentThread().getName());
- watch_func=func;
- watch_fd=fd;
- watch_cond=cond;
- watch_callbackid=callbackid;
- final NavitWatch navitwatch=this;
- callback_runnable = new Runnable() {
- public void run()
- {
- navitwatch.callback();
- }
- };
- thread = new Thread(this, "poll thread");
- thread.start();
- }
- public void run()
- {
- for (;;) {
- // Log.e("NavitWatch","Polling "+watch_fd+" "+watch_cond + " from " + java.lang.Thread.currentThread().getName());
- poll(watch_func, watch_fd, watch_cond);
- // Log.e("NavitWatch","poll returned");
- if (removed)
- break;
- callback_pending=true;
- handler.post(callback_runnable);
- try {
- // Log.e("NavitWatch","wait");
- synchronized(this) {
- if (callback_pending)
- this.wait();
- }
- // Log.e("NavitWatch","wait returned");
- } catch (Exception e) {
- Log.e("NavitWatch","Exception "+e.getMessage());
- }
- if (removed)
- break;
- }
- }
- public void callback()
- {
- // Log.e("NavitWatch","Calling Callback");
- if (!removed)
- WatchCallback(watch_callbackid);
- synchronized(this) {
- callback_pending=false;
- // Log.e("NavitWatch","Waking up");
- this.notify();
- }
- }
- public void remove()
- {
- removed=true;
- thread.interrupt();
- }
+ public void remove() {
+ removed = true;
+ thread.interrupt();
+ }
}
diff --git a/navit/announcement.c b/navit/announcement.c
index 9ea367afe..c823fe1e1 100644
--- a/navit/announcement.c
+++ b/navit/announcement.c
@@ -23,46 +23,37 @@
#include "announcement.h"
struct announcement {
- struct attr **attrs;
+ struct attr **attrs;
};
struct announcement *
-announcement_new(struct attr *parent, struct attr **attrs)
-{
- struct announcement *this_;
- struct attr *type_attr;
- if (! (type_attr=attr_search(attrs, NULL, attr_name))) {
- return NULL;
- }
- this_=g_new0(struct announcement, 1);
- this_->attrs=attr_list_dup(attrs);
- return this_;
+announcement_new(struct attr *parent, struct attr **attrs) {
+ struct announcement *this_;
+ struct attr *type_attr;
+ if (! (type_attr=attr_search(attrs, NULL, attr_name))) {
+ return NULL;
+ }
+ this_=g_new0(struct announcement, 1);
+ this_->attrs=attr_list_dup(attrs);
+ return this_;
}
-int
-announcement_get_attr(struct announcement *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+int announcement_get_attr(struct announcement *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
}
-int
-announcement_set_attr(struct announcement *this_, struct attr *attr)
-{
- this_->attrs=attr_generic_set_attr(this_->attrs, attr);
- return 1;
+int announcement_set_attr(struct announcement *this_, struct attr *attr) {
+ this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+ return 1;
}
-int
-announcement_add_attr(struct announcement *this_, struct attr *attr)
-{
- this_->attrs=attr_generic_add_attr(this_->attrs, attr);
- return 1;
+int announcement_add_attr(struct announcement *this_, struct attr *attr) {
+ this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+ return 1;
}
-int
-announcement_remove_attr(struct announcement *this_, struct attr *attr)
-{
- this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
- return 1;
+int announcement_remove_attr(struct announcement *this_, struct attr *attr) {
+ this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
+ return 1;
}
diff --git a/navit/atom.c b/navit/atom.c
index de11ce8bc..087729972 100644
--- a/navit/atom.c
+++ b/navit/atom.c
@@ -3,29 +3,23 @@
static GHashTable *atom_hash;
-char *
-atom_lookup(char *name)
-{
- if (!atom_hash)
- return NULL;
- return g_hash_table_lookup(atom_hash,name);
+char *atom_lookup(char *name) {
+ if (!atom_hash)
+ return NULL;
+ return g_hash_table_lookup(atom_hash,name);
}
-char *
-atom(char *name)
-{
- char *id=atom_lookup(name);
- if (id)
- return id;
- if (!atom_hash)
- return NULL;
- id=g_strdup(name);
- g_hash_table_insert(atom_hash, id, id);
- return id;
+char *atom(char *name) {
+ char *id=atom_lookup(name);
+ if (id)
+ return id;
+ if (!atom_hash)
+ return NULL;
+ id=g_strdup(name);
+ g_hash_table_insert(atom_hash, id, id);
+ return id;
}
-void
-atom_init(void)
-{
- atom_hash=g_hash_table_new(g_str_hash, g_str_equal);
+void atom_init(void) {
+ atom_hash=g_hash_table_new(g_str_hash, g_str_equal);
}
diff --git a/navit/attr.c b/navit/attr.c
index 24b6cbe6a..f7e5d1fac 100644
--- a/navit/attr.c
+++ b/navit/attr.c
@@ -16,10 +16,10 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-
+
/** @file attr.c
* @brief Attribute handling code
- *
+ *
* Structures and functions for working with attributes.
*
* @author Navit Team
@@ -45,13 +45,13 @@
#include "xmlconfig.h"
struct attr_name {
- enum attr_type attr;
- char *name;
+ enum attr_type attr;
+ char *name;
};
/** List of attr_types with their names as strings. */
-static struct attr_name attr_names[]={
+static struct attr_name attr_names[]= {
#define ATTR2(x,y) ATTR(y)
#define ATTR(x) { attr_##x, #x },
@@ -67,24 +67,20 @@ static struct attr_name attr_names[]={
static GHashTable *attr_hash;
-void
-attr_create_hash(void)
-{
- int i;
- attr_hash=g_hash_table_new(g_str_hash, g_str_equal);
- for (i=0 ; i < sizeof(attr_names)/sizeof(struct attr_name) ; i++) {
- g_hash_table_insert(attr_hash, attr_names[i].name, GINT_TO_POINTER(attr_names[i].attr));
- }
+void attr_create_hash(void) {
+ int i;
+ attr_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ for (i=0 ; i < sizeof(attr_names)/sizeof(struct attr_name) ; i++) {
+ g_hash_table_insert(attr_hash, attr_names[i].name, GINT_TO_POINTER(attr_names[i].attr));
+ }
}
-void
-attr_destroy_hash(void)
-{
- g_hash_table_destroy(attr_hash);
- attr_hash=NULL;
+void attr_destroy_hash(void) {
+ g_hash_table_destroy(attr_hash);
+ attr_hash=NULL;
}
-/**
+/**
* @brief Converts a string to an attr_type
*
* This function reads a string and returns the corresponding attr_type.
@@ -92,18 +88,16 @@ attr_destroy_hash(void)
* @param name The attribute name
* @return The corresponding {@code attr_type}, or {@code attr_none} if the string specifies a nonexistent or invalid attribute type.
*/
-enum attr_type
-attr_from_name(const char *name)
-{
- int i;
+enum attr_type attr_from_name(const char *name) {
+ int i;
- if (attr_hash)
- return GPOINTER_TO_INT(g_hash_table_lookup(attr_hash, name));
- for (i=0 ; i < sizeof(attr_names)/sizeof(struct attr_name) ; i++) {
- if (! strcmp(attr_names[i].name, name))
- return attr_names[i].attr;
- }
- return attr_none;
+ if (attr_hash)
+ return GPOINTER_TO_INT(g_hash_table_lookup(attr_hash, name));
+ for (i=0 ; i < sizeof(attr_names)/sizeof(struct attr_name) ; i++) {
+ if (! strcmp(attr_names[i].name, name))
+ return attr_names[i].attr;
+ }
+ return attr_none;
}
@@ -111,7 +105,7 @@ static int attr_match(enum attr_type search, enum attr_type found);
-/**
+/**
* @brief Converts an attr_type to a string
*
* @param attr The attribute type to be converted.
@@ -119,19 +113,17 @@ static int attr_match(enum attr_type search, enum attr_type found);
* The calling function should create a copy of the string if it needs to alter it or relies on the
* string being available permanently.
*/
-char *
-attr_to_name(enum attr_type attr)
-{
- int i;
+char *attr_to_name(enum attr_type attr) {
+ int i;
- for (i=0 ; i < sizeof(attr_names)/sizeof(struct attr_name) ; i++) {
- if (attr_names[i].attr == attr)
- return attr_names[i].name;
- }
- return NULL;
+ for (i=0 ; i < sizeof(attr_names)/sizeof(struct attr_name) ; i++) {
+ if (attr_names[i].attr == attr)
+ return attr_names[i].name;
+ }
+ return NULL;
}
-/**
+/**
* @brief Creates an attribute from text information
*
* This function creates an attribute from two strings specifying the name and
@@ -142,219 +134,216 @@ attr_to_name(enum attr_type attr)
* @return The new attribute
*/
struct attr *
-attr_new_from_text(const char *name, const char *value)
-{
- enum attr_type attr;
- struct attr *ret;
- struct coord_geo *g;
- struct coord c;
- enum item_type item_type;
- char *pos,*type_str,*str,*tok;
- int min,max,count;
-
- ret=g_new0(struct attr, 1);
- dbg(lvl_debug,"enter name='%s' value='%s'\n", name, value);
- attr=attr_from_name(name);
- ret->type=attr;
- switch (attr) {
- case attr_item_type:
- ret->u.item_type=item_from_name(value);
- break;
- case attr_item_types:
- count=0;
- type_str=g_strdup(value);
- str=type_str;
- while ((tok=strtok(str, ","))) {
- ret->u.item_types=g_realloc(ret->u.item_types, (count+2)*sizeof(enum item_type));
- item_type=item_from_name(tok);
- if (item_type!=type_none) {
- ret->u.item_types[count++]=item_type;
- ret->u.item_types[count]=type_none;
- } else {
- dbg(lvl_error,"Unknown item type '%s' ignored.\n",tok);
- }
- str=NULL;
- }
- g_free(type_str);
- break;
- case attr_attr_types:
- count=0;
- type_str=g_strdup(value);
- str=type_str;
- while ((tok=strtok(str, ","))) {
- ret->u.attr_types=g_realloc(ret->u.attr_types, (count+2)*sizeof(enum attr_type));
- ret->u.attr_types[count++]=attr_from_name(tok);
- ret->u.attr_types[count]=attr_none;
- str=NULL;
- }
- g_free(type_str);
- break;
- case attr_dash:
- count=0;
- type_str=g_strdup(value);
- str=type_str;
- while ((tok=strtok(str, ","))) {
- ret->u.dash=g_realloc(ret->u.dash, (count+2)*sizeof(int));
- ret->u.dash[count++]=g_ascii_strtoull(tok,NULL,0);
- ret->u.dash[count]=0;
- str=NULL;
- }
- g_free(type_str);
- break;
- case attr_order:
- case attr_sequence_range:
- case attr_angle_range:
- case attr_speed_range:
- pos=strchr(value, '-');
- min=0;
- max=32767;
- if (! pos) {
- sscanf(value,"%d",&min);
- max=min;
- } else if (pos == value)
- sscanf(value,"-%d",&max);
- else
- sscanf(value,"%d-%d",&min, &max);
- ret->u.range.min=min;
- ret->u.range.max=max;
- break;
- default:
- if (attr >= attr_type_string_begin && attr <= attr_type_string_end) {
- ret->u.str=g_strdup(value);
- break;
- }
- if (attr >= attr_type_int_begin && attr < attr_type_rel_abs_begin) {
- char *tail;
- if (value[0] == '0' && value[1] == 'x')
- ret->u.num=strtoul(value, &tail, 0);
- else
- ret->u.num=strtol(value, &tail, 0);
- if (*tail) {
- dbg(lvl_error, "Incorrect value '%s' for attribute '%s'; expected a number. "
- "Defaulting to 0.\n", value, name);
- ret->u.num=0;
- }
- break;
- }
- if (attr >= attr_type_rel_abs_begin && attr < attr_type_boolean_begin) {
- char *tail;
- int value_is_relative=0;
- ret->u.num=strtol(value, &tail, 0);
- if (*tail) {
- if (!strcmp(tail, "%")) {
- value_is_relative=1;
- } else {
- dbg(lvl_error, "Incorrect value '%s' for attribute '%s'; expected a number or a relative value in percent. "
- "Defaulting to 0.\n", value, name);
- ret->u.num=0;
- }
- }
- if (value_is_relative) {
- if ((ret->u.num > ATTR_REL_MAXREL) || (ret->u.num < ATTR_REL_MINREL)) {
- dbg(lvl_error, "Relative possibly-relative attribute with value out of range: %li\n", ret->u.num);
- }
-
- ret->u.num += ATTR_REL_RELSHIFT;
- } else {
- if ((ret->u.num > ATTR_REL_MAXABS) || (ret->u.num < ATTR_REL_MINABS)) {
- dbg(lvl_error, "Non-relative possibly-relative attribute with value out of range: %li\n", ret->u.num);
- }
- }
- break;
- }
- if (attr >= attr_type_boolean_begin && attr <= attr_type_int_end) {
- if (!(g_ascii_strcasecmp(value,"no") && g_ascii_strcasecmp(value,"0") && g_ascii_strcasecmp(value,"false")))
- ret->u.num=0;
- else if (!(g_ascii_strcasecmp(value,"yes") && g_ascii_strcasecmp(value,"1") && g_ascii_strcasecmp(value,"true")))
- ret->u.num=1;
- else {
- dbg(lvl_error, "Incorrect value '%s' for attribute '%s'; expected a boolean (no/0/false or yes/1/true). "
- "Defaulting to 'true'.\n", value, name);
- ret->u.num=1;
- }
- break;
- }
- if (attr >= attr_type_color_begin && attr <= attr_type_color_end) {
- struct color *color=g_new0(struct color, 1);
- int r,g,b,a;
- ret->u.color=color;
- if(strlen(value)==7){
- sscanf(value,"#%02x%02x%02x", &r, &g, &b);
- color->r = (r << 8) | r;
- color->g = (g << 8) | g;
- color->b = (b << 8) | b;
- color->a = (65535);
- } else if(strlen(value)==9){
- sscanf(value,"#%02x%02x%02x%02x", &r, &g, &b, &a);
- color->r = (r << 8) | r;
- color->g = (g << 8) | g;
- color->b = (b << 8) | b;
- color->a = (a << 8) | a;
- } else {
- dbg(lvl_error,"color %s has unknown format\n",value);
- }
- break;
- }
- if (attr >= attr_type_coord_geo_begin && attr <= attr_type_coord_geo_end) {
- g=g_new(struct coord_geo, 1);
- ret->u.coord_geo=g;
- coord_parse(value, projection_mg, &c);
- transform_to_geo(projection_mg, &c, g);
- break;
- }
- dbg(lvl_debug,"unknown attribute\n");
- g_free(ret);
- ret=NULL;
- }
- return ret;
+attr_new_from_text(const char *name, const char *value) {
+ enum attr_type attr;
+ struct attr *ret;
+ struct coord_geo *g;
+ struct coord c;
+ enum item_type item_type;
+ char *pos,*type_str,*str,*tok;
+ int min,max,count;
+
+ ret=g_new0(struct attr, 1);
+ dbg(lvl_debug,"enter name='%s' value='%s'", name, value);
+ attr=attr_from_name(name);
+ ret->type=attr;
+ switch (attr) {
+ case attr_item_type:
+ ret->u.item_type=item_from_name(value);
+ break;
+ case attr_item_types:
+ count=0;
+ type_str=g_strdup(value);
+ str=type_str;
+ while ((tok=strtok(str, ","))) {
+ ret->u.item_types=g_realloc(ret->u.item_types, (count+2)*sizeof(enum item_type));
+ item_type=item_from_name(tok);
+ if (item_type!=type_none) {
+ ret->u.item_types[count++]=item_type;
+ ret->u.item_types[count]=type_none;
+ } else {
+ dbg(lvl_error,"Unknown item type '%s' ignored.",tok);
+ }
+ str=NULL;
+ }
+ g_free(type_str);
+ break;
+ case attr_attr_types:
+ count=0;
+ type_str=g_strdup(value);
+ str=type_str;
+ while ((tok=strtok(str, ","))) {
+ ret->u.attr_types=g_realloc(ret->u.attr_types, (count+2)*sizeof(enum attr_type));
+ ret->u.attr_types[count++]=attr_from_name(tok);
+ ret->u.attr_types[count]=attr_none;
+ str=NULL;
+ }
+ g_free(type_str);
+ break;
+ case attr_dash:
+ count=0;
+ type_str=g_strdup(value);
+ str=type_str;
+ while ((tok=strtok(str, ","))) {
+ ret->u.dash=g_realloc(ret->u.dash, (count+2)*sizeof(int));
+ ret->u.dash[count++]=g_ascii_strtoull(tok,NULL,0);
+ ret->u.dash[count]=0;
+ str=NULL;
+ }
+ g_free(type_str);
+ break;
+ case attr_order:
+ case attr_sequence_range:
+ case attr_angle_range:
+ case attr_speed_range:
+ pos=strchr(value, '-');
+ min=0;
+ max=32767;
+ if (! pos) {
+ sscanf(value,"%d",&min);
+ max=min;
+ } else if (pos == value)
+ sscanf(value,"-%d",&max);
+ else
+ sscanf(value,"%d-%d",&min, &max);
+ ret->u.range.min=min;
+ ret->u.range.max=max;
+ break;
+ default:
+ if (attr >= attr_type_string_begin && attr <= attr_type_string_end) {
+ ret->u.str=g_strdup(value);
+ break;
+ }
+ if (attr >= attr_type_int_begin && attr < attr_type_rel_abs_begin) {
+ char *tail;
+ if (value[0] == '0' && value[1] == 'x')
+ ret->u.num=strtoul(value, &tail, 0);
+ else
+ ret->u.num=strtol(value, &tail, 0);
+ if (*tail) {
+ dbg(lvl_error, "Incorrect value '%s' for attribute '%s'; expected a number. "
+ "Defaulting to 0.\n", value, name);
+ ret->u.num=0;
+ }
+ break;
+ }
+ if (attr >= attr_type_rel_abs_begin && attr < attr_type_boolean_begin) {
+ char *tail;
+ int value_is_relative=0;
+ ret->u.num=strtol(value, &tail, 0);
+ if (*tail) {
+ if (!strcmp(tail, "%")) {
+ value_is_relative=1;
+ } else {
+ dbg(lvl_error, "Incorrect value '%s' for attribute '%s'; expected a number or a relative value in percent. "
+ "Defaulting to 0.\n", value, name);
+ ret->u.num=0;
+ }
+ }
+ if (value_is_relative) {
+ if ((ret->u.num > ATTR_REL_MAXREL) || (ret->u.num < ATTR_REL_MINREL)) {
+ dbg(lvl_error, "Relative possibly-relative attribute with value out of range: %li", ret->u.num);
+ }
+
+ ret->u.num += ATTR_REL_RELSHIFT;
+ } else {
+ if ((ret->u.num > ATTR_REL_MAXABS) || (ret->u.num < ATTR_REL_MINABS)) {
+ dbg(lvl_error, "Non-relative possibly-relative attribute with value out of range: %li", ret->u.num);
+ }
+ }
+ break;
+ }
+ if (attr >= attr_type_boolean_begin && attr <= attr_type_int_end) {
+ if (!(g_ascii_strcasecmp(value,"no") && g_ascii_strcasecmp(value,"0") && g_ascii_strcasecmp(value,"false")))
+ ret->u.num=0;
+ else if (!(g_ascii_strcasecmp(value,"yes") && g_ascii_strcasecmp(value,"1") && g_ascii_strcasecmp(value,"true")))
+ ret->u.num=1;
+ else {
+ dbg(lvl_error, "Incorrect value '%s' for attribute '%s'; expected a boolean (no/0/false or yes/1/true). "
+ "Defaulting to 'true'.\n", value, name);
+ ret->u.num=1;
+ }
+ break;
+ }
+ if (attr >= attr_type_color_begin && attr <= attr_type_color_end) {
+ struct color *color=g_new0(struct color, 1);
+ int r,g,b,a;
+ ret->u.color=color;
+ if(strlen(value)==7) {
+ sscanf(value,"#%02x%02x%02x", &r, &g, &b);
+ color->r = (r << 8) | r;
+ color->g = (g << 8) | g;
+ color->b = (b << 8) | b;
+ color->a = (65535);
+ } else if(strlen(value)==9) {
+ sscanf(value,"#%02x%02x%02x%02x", &r, &g, &b, &a);
+ color->r = (r << 8) | r;
+ color->g = (g << 8) | g;
+ color->b = (b << 8) | b;
+ color->a = (a << 8) | a;
+ } else {
+ dbg(lvl_error,"color %s has unknown format",value);
+ }
+ break;
+ }
+ if (attr >= attr_type_coord_geo_begin && attr <= attr_type_coord_geo_end) {
+ g=g_new(struct coord_geo, 1);
+ ret->u.coord_geo=g;
+ coord_parse(value, projection_mg, &c);
+ transform_to_geo(projection_mg, &c, g);
+ break;
+ }
+ dbg(lvl_debug,"unknown attribute");
+ g_free(ret);
+ ret=NULL;
+ }
+ return ret;
}
-/**
+/**
* @brief Converts access flags to a human-readable string.
*
* @param flags The flags as a number
* @return The flags in human-readable form
*/
-static char *
-flags_to_text(int flags)
-{
- char *ret=g_strdup_printf("0x%x:",flags);
- if (flags & AF_ONEWAY) ret=g_strconcat_printf(ret,"%sAF_ONEWAY",ret?"|":"");
- if (flags & AF_ONEWAYREV) ret=g_strconcat_printf(ret,"%sAF_ONEWAYREV",ret?"|":"");
- if (flags & AF_SEGMENTED) ret=g_strconcat_printf(ret,"%sAF_SEGMENTED",ret?"|":"");
- if (flags & AF_ROUNDABOUT) ret=g_strconcat_printf(ret,"%sAF_ROUNDABOUT",ret?"|":"");
- if (flags & AF_ROUNDABOUT_VALID) ret=g_strconcat_printf(ret,"%sAF_ROUNDABOUT_VALID",ret?"|":"");
- if (flags & AF_ONEWAY_EXCEPTION) ret=g_strconcat_printf(ret,"%sAF_ONEWAY_EXCEPTION",ret?"|":"");
- if (flags & AF_SPEED_LIMIT) ret=g_strconcat_printf(ret,"%sAF_SPEED_LIMIT",ret?"|":"");
- if (flags & AF_RESERVED1) ret=g_strconcat_printf(ret,"%sAF_RESERVED1",ret?"|":"");
- if (flags & AF_SIZE_OR_WEIGHT_LIMIT) ret=g_strconcat_printf(ret,"%sAF_SIZE_OR_WEIGHT_LIMIT",ret?"|":"");
- if (flags & AF_THROUGH_TRAFFIC_LIMIT) ret=g_strconcat_printf(ret,"%sAF_THROUGH_TRAFFIC_LIMIT",ret?"|":"");
- if (flags & AF_TOLL) ret=g_strconcat_printf(ret,"%sAF_TOLL",ret?"|":"");
- if (flags & AF_SEASONAL) ret=g_strconcat_printf(ret,"%sAF_SEASONAL",ret?"|":"");
- if (flags & AF_UNPAVED) ret=g_strconcat_printf(ret,"%sAF_UNPAVED",ret?"|":"");
- if (flags & AF_FORD) ret=g_strconcat_printf(ret,"%sAF_FORD",ret?"|":"");
- if (flags & AF_UNDERGROUND) ret=g_strconcat_printf(ret,"%sAF_UNDERGROUND",ret?"|":"");
- if (flags & AF_DANGEROUS_GOODS) ret=g_strconcat_printf(ret,"%sAF_DANGEROUS_GOODS",ret?"|":"");
- if ((flags & AF_ALL) == AF_ALL)
- return g_strconcat_printf(ret,"%sAF_ALL",ret?"|":"");
- if ((flags & AF_ALL) == AF_MOTORIZED_FAST)
- return g_strconcat_printf(ret,"%sAF_MOTORIZED_FAST",ret?"|":"");
- if (flags & AF_EMERGENCY_VEHICLES) ret=g_strconcat_printf(ret,"%sAF_EMERGENCY_VEHICLES",ret?"|":"");
- if (flags & AF_TRANSPORT_TRUCK) ret=g_strconcat_printf(ret,"%sAF_TRANSPORT_TRUCK",ret?"|":"");
- if (flags & AF_DELIVERY_TRUCK) ret=g_strconcat_printf(ret,"%sAF_DELIVERY_TRUCK",ret?"|":"");
- if (flags & AF_PUBLIC_BUS) ret=g_strconcat_printf(ret,"%sAF_PUBLIC_BUS",ret?"|":"");
- if (flags & AF_TAXI) ret=g_strconcat_printf(ret,"%sAF_TAXI",ret?"|":"");
- if (flags & AF_HIGH_OCCUPANCY_CAR) ret=g_strconcat_printf(ret,"%sAF_HIGH_OCCUPANCY_CAR",ret?"|":"");
- if (flags & AF_CAR) ret=g_strconcat_printf(ret,"%sAF_CAR",ret?"|":"");
- if (flags & AF_MOTORCYCLE) ret=g_strconcat_printf(ret,"%sAF_MOTORCYCLE",ret?"|":"");
- if (flags & AF_MOPED) ret=g_strconcat_printf(ret,"%sAF_MOPED",ret?"|":"");
- if (flags & AF_HORSE) ret=g_strconcat_printf(ret,"%sAF_HORSE",ret?"|":"");
- if (flags & AF_BIKE) ret=g_strconcat_printf(ret,"%sAF_BIKE",ret?"|":"");
- if (flags & AF_PEDESTRIAN) ret=g_strconcat_printf(ret,"%sAF_PEDESTRIAN",ret?"|":"");
- return ret;
+static char *flags_to_text(int flags) {
+ char *ret=g_strdup_printf("0x%x:",flags);
+ if (flags & AF_ONEWAY) ret=g_strconcat_printf(ret,"%sAF_ONEWAY",ret?"|":"");
+ if (flags & AF_ONEWAYREV) ret=g_strconcat_printf(ret,"%sAF_ONEWAYREV",ret?"|":"");
+ if (flags & AF_SEGMENTED) ret=g_strconcat_printf(ret,"%sAF_SEGMENTED",ret?"|":"");
+ if (flags & AF_ROUNDABOUT) ret=g_strconcat_printf(ret,"%sAF_ROUNDABOUT",ret?"|":"");
+ if (flags & AF_ROUNDABOUT_VALID) ret=g_strconcat_printf(ret,"%sAF_ROUNDABOUT_VALID",ret?"|":"");
+ if (flags & AF_ONEWAY_EXCEPTION) ret=g_strconcat_printf(ret,"%sAF_ONEWAY_EXCEPTION",ret?"|":"");
+ if (flags & AF_SPEED_LIMIT) ret=g_strconcat_printf(ret,"%sAF_SPEED_LIMIT",ret?"|":"");
+ if (flags & AF_RESERVED1) ret=g_strconcat_printf(ret,"%sAF_RESERVED1",ret?"|":"");
+ if (flags & AF_SIZE_OR_WEIGHT_LIMIT) ret=g_strconcat_printf(ret,"%sAF_SIZE_OR_WEIGHT_LIMIT",ret?"|":"");
+ if (flags & AF_THROUGH_TRAFFIC_LIMIT) ret=g_strconcat_printf(ret,"%sAF_THROUGH_TRAFFIC_LIMIT",ret?"|":"");
+ if (flags & AF_TOLL) ret=g_strconcat_printf(ret,"%sAF_TOLL",ret?"|":"");
+ if (flags & AF_SEASONAL) ret=g_strconcat_printf(ret,"%sAF_SEASONAL",ret?"|":"");
+ if (flags & AF_UNPAVED) ret=g_strconcat_printf(ret,"%sAF_UNPAVED",ret?"|":"");
+ if (flags & AF_FORD) ret=g_strconcat_printf(ret,"%sAF_FORD",ret?"|":"");
+ if (flags & AF_UNDERGROUND) ret=g_strconcat_printf(ret,"%sAF_UNDERGROUND",ret?"|":"");
+ if (flags & AF_DANGEROUS_GOODS) ret=g_strconcat_printf(ret,"%sAF_DANGEROUS_GOODS",ret?"|":"");
+ if ((flags & AF_ALL) == AF_ALL)
+ return g_strconcat_printf(ret,"%sAF_ALL",ret?"|":"");
+ if ((flags & AF_ALL) == AF_MOTORIZED_FAST)
+ return g_strconcat_printf(ret,"%sAF_MOTORIZED_FAST",ret?"|":"");
+ if (flags & AF_EMERGENCY_VEHICLES) ret=g_strconcat_printf(ret,"%sAF_EMERGENCY_VEHICLES",ret?"|":"");
+ if (flags & AF_TRANSPORT_TRUCK) ret=g_strconcat_printf(ret,"%sAF_TRANSPORT_TRUCK",ret?"|":"");
+ if (flags & AF_DELIVERY_TRUCK) ret=g_strconcat_printf(ret,"%sAF_DELIVERY_TRUCK",ret?"|":"");
+ if (flags & AF_PUBLIC_BUS) ret=g_strconcat_printf(ret,"%sAF_PUBLIC_BUS",ret?"|":"");
+ if (flags & AF_TAXI) ret=g_strconcat_printf(ret,"%sAF_TAXI",ret?"|":"");
+ if (flags & AF_HIGH_OCCUPANCY_CAR) ret=g_strconcat_printf(ret,"%sAF_HIGH_OCCUPANCY_CAR",ret?"|":"");
+ if (flags & AF_CAR) ret=g_strconcat_printf(ret,"%sAF_CAR",ret?"|":"");
+ if (flags & AF_MOTORCYCLE) ret=g_strconcat_printf(ret,"%sAF_MOTORCYCLE",ret?"|":"");
+ if (flags & AF_MOPED) ret=g_strconcat_printf(ret,"%sAF_MOPED",ret?"|":"");
+ if (flags & AF_HORSE) ret=g_strconcat_printf(ret,"%sAF_HORSE",ret?"|":"");
+ if (flags & AF_BIKE) ret=g_strconcat_printf(ret,"%sAF_BIKE",ret?"|":"");
+ if (flags & AF_PEDESTRIAN) ret=g_strconcat_printf(ret,"%sAF_PEDESTRIAN",ret?"|":"");
+ return ret;
}
-/**
+/**
* @brief Converts attribute data to human-readable text
*
* @param attr The attribute to be formatted
@@ -370,119 +359,119 @@ flags_to_text(int flags)
* @return The attribute data in human-readable form. The caller is responsible for calling {@code g_free()} on
* the result when it is no longer needed.
*/
-char *
-attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map)
-{
- char *ret;
- enum attr_type type=attr->type;
-
- if (!sep)
- sep="";
-
- if (type >= attr_type_item_begin && type <= attr_type_item_end) {
- struct item *item=attr->u.item;
- struct attr type, data;
- if (! item)
- return g_strdup("(nil)");
- if (! item->map || !map_get_attr(item->map, attr_type, &type, NULL))
- type.u.str="";
- if (! item->map || !map_get_attr(item->map, attr_data, &data, NULL))
- data.u.str="";
- return g_strdup_printf("type=0x%x id=0x%x,0x%x map=%p (%s:%s)", item->type, item->id_hi, item->id_lo, item->map, type.u.str, data.u.str);
- }
- if (type >= attr_type_string_begin && type <= attr_type_string_end) {
- if (map) {
- char *mstr;
- if (attr->u.str) {
- mstr=map_convert_string(map, attr->u.str);
- ret=g_strdup(mstr);
- map_convert_free(mstr);
- } else
- ret=g_strdup("(null)");
-
- } else
- ret=g_strdup(attr->u.str);
- return ret;
- }
- if (type == attr_flags || type == attr_through_traffic_flags)
- return flags_to_text(attr->u.num);
- if (type == attr_destination_length) {
- if (fmt == attr_format_with_units) {
- double distance=attr->u.num;
- if (distance > 10000)
- return g_strdup_printf("%.0f%skm",distance/1000,sep);
- return g_strdup_printf("%.1f%skm",distance/1000,sep);
- }
- }
- if (type == attr_destination_time) {
- if (fmt == attr_format_with_units) {
- int seconds=(attr->u.num+5)/10;
- int minutes=seconds/60;
- int hours=minutes/60;
- int days=hours/24;
- hours%=24;
- minutes%=60;
- seconds%=60;
- if (days)
- return g_strdup_printf("%d:%02d:%02d:%02d",days,hours,minutes,seconds);
- if (hours)
- return g_strdup_printf("%02d:%02d:%02d",hours,minutes,seconds);
- return g_strdup_printf("%02d:%02d",minutes,seconds);
- }
- }
- if (type >= attr_type_int_begin && type <= attr_type_int_end)
- return g_strdup_printf("%ld", attr->u.num);
- if (type >= attr_type_int64_begin && type <= attr_type_int64_end)
- return g_strdup_printf(LONGLONG_FMT, *attr->u.num64);
- if (type >= attr_type_double_begin && type <= attr_type_double_end)
- return g_strdup_printf("%f", *attr->u.numd);
- if (type >= attr_type_object_begin && type <= attr_type_object_end)
- return g_strdup_printf("(object[%s])", attr_to_name(type));
- if (type >= attr_type_color_begin && type <= attr_type_color_end) {
- if (attr->u.color->a != 65535)
- return g_strdup_printf("#%02x%02x%02x%02x", attr->u.color->r>>8,attr->u.color->g>>8,attr->u.color->b>>8, attr->u.color->a>>8);
- else
- return g_strdup_printf("#%02x%02x%02x", attr->u.color->r>>8,attr->u.color->g>>8,attr->u.color->b>>8);
- }
- if (type >= attr_type_coord_geo_begin && type <= attr_type_coord_geo_end)
- return g_strdup_printf("%f %f",attr->u.coord_geo->lng,attr->u.coord_geo->lat);
- if (type == attr_zipfile_ref_block) {
- int *data=attr->u.data;
- return g_strdup_printf("0x%x,0x%x,0x%x",data[0],data[1],data[2]);
- }
- if (type == attr_item_id) {
- int *data=attr->u.data;
- return g_strdup_printf("0x%x,0x%x",data[0],data[1]);
- }
- if (type == attr_item_types) {
- enum item_type *item_types=attr->u.item_types;
- char *sep="",*ret=NULL;
- while (item_types && *item_types) {
- ret=g_strconcat_printf(ret,"%s%s",sep,item_to_name(*item_types++));
- sep=",";
- }
- return ret;
- }
- if (type >= attr_type_group_begin && type <= attr_type_group_end) {
- int i=0;
- char *ret=g_strdup("");
- char *sep="";
- while (attr->u.attrs[i].type) {
- char *val=attr_to_text_ext(&attr->u.attrs[i], sep, fmt, def_fmt, map);
- ret=g_strconcat_printf(ret,"%s%s=%s",sep,attr_to_name(attr->u.attrs[i].type),val);
- g_free(val);
- sep=" ";
- i++;
- }
- return ret;
- }
- if (type >= attr_type_item_type_begin && type <= attr_type_item_type_end) {
- return g_strdup_printf("0x%ld[%s]",attr->u.num,item_to_name(attr->u.num));
- }
- if (type == attr_nav_status) {
- return nav_status_to_text(attr->u.num);
- }
- return g_strdup_printf("(no text[%s])", attr_to_name(type));
+char *attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_format def_fmt, struct map *map) {
+ char *ret;
+ enum attr_type type=attr->type;
+
+ if (!sep)
+ sep="";
+
+ if (type >= attr_type_item_begin && type <= attr_type_item_end) {
+ struct item *item=attr->u.item;
+ struct attr type, data;
+ if (! item)
+ return g_strdup("(nil)");
+ if (! item->map || !map_get_attr(item->map, attr_type, &type, NULL))
+ type.u.str="";
+ if (! item->map || !map_get_attr(item->map, attr_data, &data, NULL))
+ data.u.str="";
+ return g_strdup_printf("type=0x%x id=0x%x,0x%x map=%p (%s:%s)", item->type, item->id_hi, item->id_lo, item->map,
+ type.u.str, data.u.str);
+ }
+ if (type >= attr_type_string_begin && type <= attr_type_string_end) {
+ if (map) {
+ char *mstr;
+ if (attr->u.str) {
+ mstr=map_convert_string(map, attr->u.str);
+ ret=g_strdup(mstr);
+ map_convert_free(mstr);
+ } else
+ ret=g_strdup("(null)");
+
+ } else
+ ret=g_strdup(attr->u.str);
+ return ret;
+ }
+ if (type == attr_flags || type == attr_through_traffic_flags)
+ return flags_to_text(attr->u.num);
+ if (type == attr_destination_length) {
+ if (fmt == attr_format_with_units) {
+ double distance=attr->u.num;
+ if (distance > 10000)
+ return g_strdup_printf("%.0f%skm",distance/1000,sep);
+ return g_strdup_printf("%.1f%skm",distance/1000,sep);
+ }
+ }
+ if (type == attr_destination_time) {
+ if (fmt == attr_format_with_units) {
+ int seconds=(attr->u.num+5)/10;
+ int minutes=seconds/60;
+ int hours=minutes/60;
+ int days=hours/24;
+ hours%=24;
+ minutes%=60;
+ seconds%=60;
+ if (days)
+ return g_strdup_printf("%d:%02d:%02d:%02d",days,hours,minutes,seconds);
+ if (hours)
+ return g_strdup_printf("%02d:%02d:%02d",hours,minutes,seconds);
+ return g_strdup_printf("%02d:%02d",minutes,seconds);
+ }
+ }
+ if (type >= attr_type_int_begin && type <= attr_type_int_end)
+ return g_strdup_printf("%ld", attr->u.num);
+ if (type >= attr_type_int64_begin && type <= attr_type_int64_end)
+ return g_strdup_printf(LONGLONG_FMT, *attr->u.num64);
+ if (type >= attr_type_double_begin && type <= attr_type_double_end)
+ return g_strdup_printf("%f", *attr->u.numd);
+ if (type >= attr_type_object_begin && type <= attr_type_object_end)
+ return g_strdup_printf("(object[%s])", attr_to_name(type));
+ if (type >= attr_type_color_begin && type <= attr_type_color_end) {
+ if (attr->u.color->a != 65535)
+ return g_strdup_printf("#%02x%02x%02x%02x", attr->u.color->r>>8,attr->u.color->g>>8,attr->u.color->b>>8,
+ attr->u.color->a>>8);
+ else
+ return g_strdup_printf("#%02x%02x%02x", attr->u.color->r>>8,attr->u.color->g>>8,attr->u.color->b>>8);
+ }
+ if (type >= attr_type_coord_geo_begin && type <= attr_type_coord_geo_end)
+ return g_strdup_printf("%f %f",attr->u.coord_geo->lng,attr->u.coord_geo->lat);
+ if (type == attr_zipfile_ref_block) {
+ int *data=attr->u.data;
+ return g_strdup_printf("0x%x,0x%x,0x%x",data[0],data[1],data[2]);
+ }
+ if (type == attr_item_id) {
+ int *data=attr->u.data;
+ return g_strdup_printf("0x%x,0x%x",data[0],data[1]);
+ }
+ if (type == attr_item_types) {
+ enum item_type *item_types=attr->u.item_types;
+ char *sep="",*ret=NULL;
+ while (item_types && *item_types) {
+ ret=g_strconcat_printf(ret,"%s%s",sep,item_to_name(*item_types++));
+ sep=",";
+ }
+ return ret;
+ }
+ if (type >= attr_type_group_begin && type <= attr_type_group_end) {
+ int i=0;
+ char *ret=g_strdup("");
+ char *sep="";
+ while (attr->u.attrs[i].type) {
+ char *val=attr_to_text_ext(&attr->u.attrs[i], sep, fmt, def_fmt, map);
+ ret=g_strconcat_printf(ret,"%s%s=%s",sep,attr_to_name(attr->u.attrs[i].type),val);
+ g_free(val);
+ sep=" ";
+ i++;
+ }
+ return ret;
+ }
+ if (type >= attr_type_item_type_begin && type <= attr_type_item_type_end) {
+ return g_strdup_printf("0x%ld[%s]",attr->u.num,item_to_name(attr->u.num));
+ }
+ if (type == attr_nav_status) {
+ return nav_status_to_text(attr->u.num);
+ }
+ return g_strdup_printf("(no text[%s])", attr_to_name(type));
}
/**
@@ -494,13 +483,11 @@ attr_to_text_ext(struct attr *attr, char *sep, enum attr_format fmt, enum attr_f
* @param map The translation map, see {@code attr_to_text_ext()}
* @param pretty Not used
*/
-char *
-attr_to_text(struct attr *attr, struct map *map, int pretty)
-{
- return attr_to_text_ext(attr, NULL, attr_format_default, attr_format_default, map);
+char *attr_to_text(struct attr *attr, struct map *map, int pretty) {
+ return attr_to_text_ext(attr, NULL, attr_format_default, attr_format_default, map);
}
-/**
+/**
* @brief Searches for an attribute of a given type
*
* This function searches an array of pointers to attributes for a given
@@ -513,35 +500,32 @@ attr_to_text(struct attr *attr, struct map *map, int pretty)
* @return Pointer to the first matching attribute, or NULL if no match was found.
*/
struct attr *
-attr_search(struct attr **attrs, struct attr *last, enum attr_type attr)
-{
- dbg(lvl_info, "enter attrs=%p\n", attrs);
- while (*attrs) {
- dbg(lvl_debug,"*attrs=%p\n", *attrs);
- if ((*attrs)->type == attr) {
- return *attrs;
- }
- attrs++;
- }
- return NULL;
-}
-
-static int
-attr_match(enum attr_type search, enum attr_type found)
-{
- switch (search) {
- case attr_any:
- return 1;
- case attr_any_xml:
- switch (found) {
- case attr_callback:
- return 0;
- default:
- return 1;
- }
- default:
- return search == found;
- }
+attr_search(struct attr **attrs, struct attr *last, enum attr_type attr) {
+ dbg(lvl_info, "enter attrs=%p", attrs);
+ while (*attrs) {
+ dbg(lvl_debug,"*attrs=%p", *attrs);
+ if ((*attrs)->type == attr) {
+ return *attrs;
+ }
+ attrs++;
+ }
+ return NULL;
+}
+
+static int attr_match(enum attr_type search, enum attr_type found) {
+ switch (search) {
+ case attr_any:
+ return 1;
+ case attr_any_xml:
+ switch (found) {
+ case attr_callback:
+ return 0;
+ default:
+ return 1;
+ }
+ default:
+ return search == found;
+ }
}
/**
@@ -570,31 +554,30 @@ attr_match(enum attr_type search, enum attr_type found)
* @param iter An iterator. This parameter may be NULL.
* @return True if a matching attribute was found, false if not.
*/
-int
-attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- while (attrs && *attrs) {
- if (attr_match(type,(*attrs)->type)) {
- *attr=**attrs;
- if (!iter)
- return 1;
- if (*((void **)iter) < (void *)attrs) {
- *((void **)iter)=(void *)attrs;
- return 1;
- }
- }
- attrs++;
- }
- if (type == attr_any || type == attr_any_xml)
- return 0;
- while (def_attrs && *def_attrs) {
- if ((*def_attrs)->type == type) {
- *attr=**def_attrs;
- return 1;
- }
- def_attrs++;
- }
- return 0;
+int attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_type type, struct attr *attr,
+ struct attr_iter *iter) {
+ while (attrs && *attrs) {
+ if (attr_match(type,(*attrs)->type)) {
+ *attr=**attrs;
+ if (!iter)
+ return 1;
+ if (*((void **)iter) < (void *)attrs) {
+ *((void **)iter)=(void *)attrs;
+ return 1;
+ }
+ }
+ attrs++;
+ }
+ if (type == attr_any || type == attr_any_xml)
+ return 0;
+ while (def_attrs && *def_attrs) {
+ if ((*def_attrs)->type == type) {
+ *attr=**def_attrs;
+ return 1;
+ }
+ def_attrs++;
+ }
+ return 0;
}
/**
@@ -605,32 +588,32 @@ attr_generic_get_attr(struct attr **attrs, struct attr **def_attrs, enum attr_ty
* contain an attribute whose type matches that of the new one, the new
* attribute is inserted into the list.
*
- * @param attrs Points to the array of attribute pointers to be updated
+ * @param attrs Points to the array of attribute pointers to be updated (if NULL, this function will
+ * create a new list containing only the new attribute)
* @param attr The new attribute.
* @return Pointer to the updated attribute list
*/
struct attr **
-attr_generic_set_attr(struct attr **attrs, struct attr *attr)
-{
- struct attr **curr=attrs;
- int i,count=0;
- dbg(lvl_debug, "enter, attrs=%p, attr=%p (%s)\n", attrs, attr, attr_to_name(attr->type));
- while (curr && *curr) {
- if ((*curr)->type == attr->type) {
- attr_free(*curr);
- *curr=attr_dup(attr);
- return attrs;
- }
- curr++;
- count++;
- }
- curr=g_new0(struct attr *, count+2);
- for (i = 0 ; i < count ; i++)
- curr[i]=attrs[i];
- curr[count]=attr_dup(attr);
- curr[count+1]=NULL;
- g_free(attrs);
- return curr;
+attr_generic_set_attr(struct attr **attrs, struct attr *attr) {
+ struct attr **curr=attrs;
+ int i,count=0;
+ dbg(lvl_debug, "enter, attrs=%p, attr=%p (%s)", attrs, attr, attr_to_name(attr->type));
+ while (curr && *curr) {
+ if ((*curr)->type == attr->type) {
+ attr_free(*curr);
+ *curr=attr_dup(attr);
+ return attrs;
+ }
+ curr++;
+ count++;
+ }
+ curr=g_new0(struct attr *, count+2);
+ for (i = 0 ; i < count ; i++)
+ curr[i]=attrs[i];
+ curr[count]=attr_dup(attr);
+ curr[count+1]=NULL;
+ g_free(attrs);
+ return curr;
}
/**
@@ -643,331 +626,335 @@ attr_generic_set_attr(struct attr **attrs, struct attr *attr)
* @return Pointer to the updated attribute list
*/
struct attr **
-attr_generic_add_attr(struct attr **attrs, struct attr *attr)
-{
- struct attr **curr=attrs;
- int i,count=0;
- dbg(lvl_debug, "enter, attrs=%p, attr=%p (%s)\n", attrs, attr, attr_to_name(attr->type));
- while (curr && *curr) {
- curr++;
- count++;
- }
- curr=g_new0(struct attr *, count+2);
- for (i = 0 ; i < count ; i++)
- curr[i]=attrs[i];
- curr[count]=attr_dup(attr);
- curr[count+1]=NULL;
- g_free(attrs);
- return curr;
+attr_generic_add_attr(struct attr **attrs, struct attr *attr) {
+ struct attr **curr=attrs;
+ int i,count=0;
+ dbg(lvl_debug, "enter, attrs=%p, attr=%p (%s)", attrs, attr, attr_to_name(attr->type));
+ while (curr && *curr) {
+ curr++;
+ count++;
+ }
+ curr=g_new0(struct attr *, count+2);
+ for (i = 0 ; i < count ; i++)
+ curr[i]=attrs[i];
+ curr[count]=attr_dup(attr);
+ curr[count+1]=NULL;
+ g_free(attrs);
+ return curr;
}
struct attr **
-attr_generic_add_attr_list(struct attr **attrs, struct attr **add)
-{
- while (add && *add) {
- attrs=attr_generic_add_attr(attrs, *add);
- add++;
- }
- return attrs;
+attr_generic_add_attr_list(struct attr **attrs, struct attr **add) {
+ while (add && *add) {
+ attrs=attr_generic_add_attr(attrs, *add);
+ add++;
+ }
+ return attrs;
}
struct attr **
-attr_generic_prepend_attr(struct attr **attrs, struct attr *attr)
-{
- struct attr **curr=attrs;
- int i,count=0;
- while (curr && *curr) {
- curr++;
- count++;
- }
- curr=g_new0(struct attr *, count+2);
- for (i = 0 ; i < count ; i++)
- curr[i+1]=attrs[i];
- curr[0]=attr_dup(attr);
- curr[count+1]=NULL;
- g_free(attrs);
- return curr;
+attr_generic_prepend_attr(struct attr **attrs, struct attr *attr) {
+ struct attr **curr=attrs;
+ int i,count=0;
+ while (curr && *curr) {
+ curr++;
+ count++;
+ }
+ curr=g_new0(struct attr *, count+2);
+ for (i = 0 ; i < count ; i++)
+ curr[i+1]=attrs[i];
+ curr[0]=attr_dup(attr);
+ curr[count+1]=NULL;
+ g_free(attrs);
+ return curr;
}
+/**
+ * @brief Removes an attribute from an attribute list.
+ *
+ * If `attrs` contains `attr`, a new attribute list is created (which contains all attributes, except
+ * for `attr`) and both `attrs` (the original attribute list) and `attr` are freed.
+ *
+ * If `attrs` does not contain `attr`, this function is a no-op.
+ *
+ * @param attrs The attribute list
+ * @param attr The attribute to remove from the list
+ *
+ * @return The new attribute list
+ */
struct attr **
-attr_generic_remove_attr(struct attr **attrs, struct attr *attr)
-{
- struct attr **curr=attrs;
- int i,j,count=0,found=0;
- while (curr && *curr) {
- if ((*curr)->type == attr->type && (*curr)->u.data == attr->u.data)
- found=1;
- curr++;
- count++;
- }
- if (!found)
- return attrs;
- curr=g_new0(struct attr *, count);
- j=0;
- for (i = 0 ; i < count ; i++) {
- if (attrs[i]->type != attr->type || attrs[i]->u.data != attr->u.data)
- curr[j++]=attrs[i];
- else
- attr_free(attrs[i]);
- }
- curr[j]=NULL;
- g_free(attrs);
- return curr;
-}
-
-enum attr_type
-attr_type_begin(enum attr_type type)
-{
- if (type < attr_type_item_begin)
- return attr_none;
- if (type < attr_type_int_begin)
- return attr_type_item_begin;
- if (type < attr_type_string_begin)
- return attr_type_int_begin;
- if (type < attr_type_special_begin)
- return attr_type_string_begin;
- if (type < attr_type_double_begin)
- return attr_type_special_begin;
- if (type < attr_type_coord_geo_begin)
- return attr_type_double_begin;
- if (type < attr_type_color_begin)
- return attr_type_coord_geo_begin;
- if (type < attr_type_object_begin)
- return attr_type_color_begin;
- if (type < attr_type_coord_begin)
- return attr_type_object_begin;
- if (type < attr_type_pcoord_begin)
- return attr_type_coord_begin;
- if (type < attr_type_callback_begin)
- return attr_type_pcoord_begin;
- if (type < attr_type_int64_begin)
- return attr_type_callback_begin;
- if (type <= attr_type_int64_end)
- return attr_type_int64_begin;
- return attr_none;
-}
-
-int
-attr_data_size(struct attr *attr)
-{
- if (attr->type == attr_none)
- return 0;
- if (attr->type >= attr_type_string_begin && attr->type <= attr_type_string_end)
- return attr->u.str?strlen(attr->u.str)+1:0;
- if (attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end)
- return sizeof(attr->u.num);
- if (attr->type >= attr_type_coord_geo_begin && attr->type <= attr_type_coord_geo_end)
- return sizeof(*attr->u.coord_geo);
- if (attr->type >= attr_type_color_begin && attr->type <= attr_type_color_end)
- return sizeof(*attr->u.color);
- if (attr->type >= attr_type_object_begin && attr->type <= attr_type_object_end)
- return sizeof(void *);
- if (attr->type >= attr_type_item_begin && attr->type <= attr_type_item_end)
- return sizeof(struct item);
- if (attr->type >= attr_type_int64_begin && attr->type <= attr_type_int64_end)
- return sizeof(*attr->u.num64);
- if (attr->type == attr_order)
- return sizeof(attr->u.range);
- if (attr->type >= attr_type_double_begin && attr->type <= attr_type_double_end)
- return sizeof(*attr->u.numd);
- if (attr->type == attr_item_types) {
- int i=0;
- while (attr->u.item_types[i++] != type_none);
- return i*sizeof(enum item_type);
- }
- if (attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end)
- return sizeof(enum item_type);
- if (attr->type == attr_attr_types) {
- int i=0;
- while (attr->u.attr_types[i++] != attr_none);
- return i*sizeof(enum attr_type);
- }
- dbg(lvl_error,"size for %s unknown\n", attr_to_name(attr->type));
- return 0;
-}
-
-void *
-attr_data_get(struct attr *attr)
-{
- if ((attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) ||
- (attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end))
- return &attr->u.num;
- if (attr->type == attr_order)
- return &attr->u.range;
- return attr->u.data;
-}
-
-void
-attr_data_set(struct attr *attr, void *data)
-{
- if ((attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) ||
- (attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end))
- attr->u.num=*((int *)data);
- else
- attr->u.data=data;
-}
-
-void
-attr_data_set_le(struct attr * attr, void * data)
-{
- if ((attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) ||
- (attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end))
- attr->u.num=le32_to_cpu(*((int *)data));
- else if (attr->type == attr_order) {
- attr->u.num=le32_to_cpu(*((int *)data));
- attr->u.range.min=le16_to_cpu(attr->u.range.min);
- attr->u.range.max=le16_to_cpu(attr->u.range.max);
- }
- else
-/* Fixme: Handle long long */
- attr->u.data=data;
-
-}
-
-static void
-attr_free_content_do(struct attr *attr)
-{
- if (!attr)
- return;
- if (HAS_OBJECT_FUNC(attr->type)) {
- struct navit_object *obj=attr->u.data;
- if (obj && obj->func && obj->func->unref)
- obj->func->unref(obj);
- }
- if (!(attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) &&
- !(attr->type >= attr_type_object_begin && attr->type <= attr_type_object_end) &&
- attr->type != attr_item_type)
- g_free(attr->u.data);
-}
-
-void
-attr_free_content(struct attr *attr)
-{
- attr_free_content_do(attr);
- memset(attr,0,sizeof(*attr));
-}
-
-void
-attr_free(struct attr *attr)
-{
- attr_free_content_do(attr);
- g_free(attr);
-}
-
-void
-attr_dup_content(struct attr *src, struct attr *dst)
-{
- int size;
- dst->type=src->type;
- if (src->type >= attr_type_int_begin && src->type <= attr_type_int_end)
- dst->u.num=src->u.num;
- else if (src->type == attr_item_type)
- dst->u.item_type=src->u.item_type;
- else if (src->type >= attr_type_object_begin && src->type <= attr_type_object_end) {
- if (HAS_OBJECT_FUNC(src->type)) {
- struct navit_object *obj=src->u.data;
- if (obj && obj->func && obj->func->ref) {
- dst->u.data=obj->func->ref(obj);
- } else
- dst->u.data=obj;
- } else
- dst->u.data=src->u.data;
- } else {
- size=attr_data_size(src);
- if (size) {
- dst->u.data=g_malloc(size);
- memcpy(dst->u.data, src->u.data, size);
- }
- }
+attr_generic_remove_attr(struct attr **attrs, struct attr *attr) {
+ struct attr **curr=attrs;
+ int i,j,count=0,found=0;
+ while (curr && *curr) {
+ if ((*curr)->type == attr->type && (*curr)->u.data == attr->u.data)
+ found=1;
+ curr++;
+ count++;
+ }
+ if (!found)
+ return attrs;
+ curr=g_new0(struct attr *, count);
+ j=0;
+ for (i = 0 ; i < count ; i++) {
+ if (attrs[i]->type != attr->type || attrs[i]->u.data != attr->u.data)
+ curr[j++]=attrs[i];
+ else
+ attr_free(attrs[i]);
+ }
+ curr[j]=NULL;
+ g_free(attrs);
+ return curr;
+}
+
+enum attr_type attr_type_begin(enum attr_type type) {
+ if (type < attr_type_item_begin)
+ return attr_none;
+ if (type < attr_type_int_begin)
+ return attr_type_item_begin;
+ if (type < attr_type_string_begin)
+ return attr_type_int_begin;
+ if (type < attr_type_special_begin)
+ return attr_type_string_begin;
+ if (type < attr_type_double_begin)
+ return attr_type_special_begin;
+ if (type < attr_type_coord_geo_begin)
+ return attr_type_double_begin;
+ if (type < attr_type_color_begin)
+ return attr_type_coord_geo_begin;
+ if (type < attr_type_object_begin)
+ return attr_type_color_begin;
+ if (type < attr_type_coord_begin)
+ return attr_type_object_begin;
+ if (type < attr_type_pcoord_begin)
+ return attr_type_coord_begin;
+ if (type < attr_type_callback_begin)
+ return attr_type_pcoord_begin;
+ if (type < attr_type_int64_begin)
+ return attr_type_callback_begin;
+ if (type <= attr_type_int64_end)
+ return attr_type_int64_begin;
+ return attr_none;
+}
+
+int attr_data_size(struct attr *attr) {
+ if (attr->type == attr_none)
+ return 0;
+ if (attr->type >= attr_type_string_begin && attr->type <= attr_type_string_end)
+ return attr->u.str?strlen(attr->u.str)+1:0;
+ if (attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end)
+ return sizeof(attr->u.num);
+ if (attr->type >= attr_type_coord_geo_begin && attr->type <= attr_type_coord_geo_end)
+ return sizeof(*attr->u.coord_geo);
+ if (attr->type >= attr_type_color_begin && attr->type <= attr_type_color_end)
+ return sizeof(*attr->u.color);
+ if (attr->type >= attr_type_object_begin && attr->type <= attr_type_object_end)
+ return sizeof(void *);
+ if (attr->type >= attr_type_item_begin && attr->type <= attr_type_item_end)
+ return sizeof(struct item);
+ if (attr->type >= attr_type_int64_begin && attr->type <= attr_type_int64_end)
+ return sizeof(*attr->u.num64);
+ if (attr->type == attr_order)
+ return sizeof(attr->u.range);
+ if (attr->type >= attr_type_double_begin && attr->type <= attr_type_double_end)
+ return sizeof(*attr->u.numd);
+ if (attr->type == attr_item_types) {
+ int i=0;
+ while (attr->u.item_types[i++] != type_none);
+ return i*sizeof(enum item_type);
+ }
+ if (attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end)
+ return sizeof(enum item_type);
+ if (attr->type == attr_attr_types) {
+ int i=0;
+ while (attr->u.attr_types[i++] != attr_none);
+ return i*sizeof(enum attr_type);
+ }
+ dbg(lvl_error,"size for %s unknown", attr_to_name(attr->type));
+ return 0;
+}
+
+void *attr_data_get(struct attr *attr) {
+ if ((attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) ||
+ (attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end))
+ return &attr->u.num;
+ if (attr->type == attr_order)
+ return &attr->u.range;
+ return attr->u.data;
+}
+
+void attr_data_set(struct attr *attr, void *data) {
+ if ((attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) ||
+ (attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end))
+ attr->u.num=*((int *)data);
+ else
+ attr->u.data=data;
+}
+
+void attr_data_set_le(struct attr * attr, void * data) {
+ if ((attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) ||
+ (attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end))
+ attr->u.num=le32_to_cpu(*((int *)data));
+ else if (attr->type == attr_order) {
+ attr->u.num=le32_to_cpu(*((int *)data));
+ attr->u.range.min=le16_to_cpu(attr->u.range.min);
+ attr->u.range.max=le16_to_cpu(attr->u.range.max);
+ } else
+ /* Fixme: Handle long long */
+ attr->u.data=data;
+
+}
+
+static void attr_free_content_do(struct attr *attr) {
+ if (!attr)
+ return;
+ if (HAS_OBJECT_FUNC(attr->type)) {
+ struct navit_object *obj=attr->u.data;
+ if (obj && obj->func && obj->func->unref)
+ obj->func->unref(obj);
+ }
+ if (!(attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end) &&
+ !(attr->type >= attr_type_object_begin && attr->type <= attr_type_object_end) &&
+ attr->type != attr_item_type)
+ g_free(attr->u.data);
+}
+
+void attr_free_content(struct attr *attr) {
+ attr_free_content_do(attr);
+ memset(attr,0,sizeof(*attr));
+}
+
+void attr_free(struct attr *attr) {
+ attr_free_content_do(attr);
+ g_free(attr);
+}
+
+void attr_dup_content(struct attr *src, struct attr *dst) {
+ int size;
+ dst->type=src->type;
+ if (src->type >= attr_type_int_begin && src->type <= attr_type_int_end)
+ dst->u.num=src->u.num;
+ else if (src->type == attr_item_type)
+ dst->u.item_type=src->u.item_type;
+ else if (src->type >= attr_type_object_begin && src->type <= attr_type_object_end) {
+ if (HAS_OBJECT_FUNC(src->type)) {
+ struct navit_object *obj=src->u.data;
+ if (obj && obj->func && obj->func->ref) {
+ dst->u.data=obj->func->ref(obj);
+ } else
+ dst->u.data=obj;
+ } else
+ dst->u.data=src->u.data;
+ } else {
+ size=attr_data_size(src);
+ if (size) {
+ dst->u.data=g_malloc(size);
+ memcpy(dst->u.data, src->u.data, size);
+ }
+ }
}
struct attr *
-attr_dup(struct attr *attr)
-{
- struct attr *ret=g_new0(struct attr, 1);
- attr_dup_content(attr, ret);
- return ret;
+attr_dup(struct attr *attr) {
+ struct attr *ret=g_new0(struct attr, 1);
+ attr_dup_content(attr, ret);
+ return ret;
}
-void
-attr_list_free(struct attr **attrs)
-{
- int count=0;
- while (attrs && attrs[count]) {
- attr_free(attrs[count++]);
- }
- g_free(attrs);
+/**
+ * @brief Frees a list of attributes.
+ *
+ * This frees the pointer array as well as the attributes referenced by the pointers.
+ *
+ * It is safe to call this function with a NULL argument; doing so is a no-op.
+ *
+ * @param attrs The attribute list to free
+ */
+void attr_list_free(struct attr **attrs) {
+ int count=0;
+ while (attrs && attrs[count]) {
+ attr_free(attrs[count++]);
+ }
+ g_free(attrs);
}
+/**
+ * @brief Duplicates a list of attributes.
+ *
+ * This creates a deep copy, i.e. the attributes in the list are copied as well.
+ *
+ * It is safe to call this function with a NULL argument; in this case, NULL will be returned.
+ *
+ * @param attrs The attribute list to copy
+ *
+ * @return The copy of the attribute list
+ */
struct attr **
-attr_list_dup(struct attr **attrs)
-{
- struct attr **ret;
- int i,count=0;
-
- if (!attrs)
- return NULL;
-
- while (attrs[count])
- count++;
- ret=g_new0(struct attr *, count+1);
- for (i = 0 ; i < count ; i++)
- ret[i]=attr_dup(attrs[i]);
- return ret;
-}
-
-int
-attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret)
-{
- int len=0,quoted;
- char *p,*e,*n;
-
- dbg(lvl_debug,"get_tag %s from %s\n", name, line);
- if (name)
- len=strlen(name);
- if (pos)
- p=line+*pos;
- else
- p=line;
- for(;;) {
- while (*p == ' ') {
- p++;
- }
- if (! *p)
- return 0;
- n=p;
- e=strchr(p,'=');
- if (! e)
- return 0;
- p=e+1;
- quoted=0;
- while (*p) {
- if (*p == ' ' && !quoted)
- break;
- if (*p == '"')
- quoted=1-quoted;
- p++;
- }
- if (name == NULL || (e-n == len && !strncmp(n, name, len))) {
- if (name_ret) {
- len=e-n;
- strncpy(name_ret, n, len);
- name_ret[len]='\0';
- }
- e++;
- len=p-e;
- if (e[0] == '"') {
- e++;
- len-=2;
- }
- strncpy(val_ret, e, len);
- val_ret[len]='\0';
- if (pos)
- *pos=p-line;
- return 1;
- }
- }
- return 0;
+attr_list_dup(struct attr **attrs) {
+ struct attr **ret;
+ int i,count=0;
+
+ if (!attrs)
+ return NULL;
+
+ while (attrs[count])
+ count++;
+ ret=g_new0(struct attr *, count+1);
+ for (i = 0 ; i < count ; i++)
+ ret[i]=attr_dup(attrs[i]);
+ return ret;
+}
+
+int attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret) {
+ int len=0,quoted;
+ char *p,*e,*n;
+
+ dbg(lvl_debug,"get_tag %s from %s", name, line);
+ if (name)
+ len=strlen(name);
+ if (pos)
+ p=line+*pos;
+ else
+ p=line;
+ for(;;) {
+ while (*p == ' ') {
+ p++;
+ }
+ if (! *p)
+ return 0;
+ n=p;
+ e=strchr(p,'=');
+ if (! e)
+ return 0;
+ p=e+1;
+ quoted=0;
+ while (*p) {
+ if (*p == ' ' && !quoted)
+ break;
+ if (*p == '"')
+ quoted=1-quoted;
+ p++;
+ }
+ if (name == NULL || (e-n == len && !strncmp(n, name, len))) {
+ if (name_ret) {
+ len=e-n;
+ strncpy(name_ret, n, len);
+ name_ret[len]='\0';
+ }
+ e++;
+ len=p-e;
+ if (e[0] == '"') {
+ e++;
+ len-=2;
+ }
+ strncpy(val_ret, e, len);
+ val_ret[len]='\0';
+ if (pos)
+ *pos=p-line;
+ return 1;
+ }
+ }
+ return 0;
}
/**
@@ -978,15 +965,13 @@ attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret)
*
* @return True if the attribute type was found, false if it was not found or if {@code types} is empty
*/
-int
-attr_types_contains(enum attr_type *types, enum attr_type type)
-{
- while (types && *types != attr_none) {
- if (*types == type)
- return 1;
- types++;
- }
- return 0;
+int attr_types_contains(enum attr_type *types, enum attr_type type) {
+ while (types && *types != attr_none) {
+ if (*types == type)
+ return 1;
+ types++;
+ }
+ return 0;
}
/**
@@ -1001,13 +986,11 @@ attr_types_contains(enum attr_type *types, enum attr_type type)
*
* @return True if the attribute type was found, false if it was not found, {@code deflt} if types is empty.
*/
-int
-attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt)
-{
- if (!types) {
- return deflt;
- }
- return attr_types_contains(types, type);
+int attr_types_contains_default(enum attr_type *types, enum attr_type type, int deflt) {
+ if (!types) {
+ return deflt;
+ }
+ return attr_types_contains(types, type);
}
/**
@@ -1019,12 +1002,11 @@ attr_types_contains_default(enum attr_type *types, enum attr_type type, int defl
*
* @return Absolute value corresponding to given relative value.
*/
-int attr_rel2real(int attrval, int whole, int treat_neg_as_rel)
-{
- if (attrval > ATTR_REL_MAXABS)
- return whole * (attrval - ATTR_REL_RELSHIFT)/100;
- if(treat_neg_as_rel && attrval<0 )
- return whole+attrval;
- return attrval;
+int attr_rel2real(int attrval, int whole, int treat_neg_as_rel) {
+ if (attrval > ATTR_REL_MAXABS)
+ return whole * (attrval - ATTR_REL_RELSHIFT)/100;
+ if(treat_neg_as_rel && attrval<0 )
+ return whole+attrval;
+ return attrval;
}
diff --git a/navit/attr.h b/navit/attr.h
index 22ea624a5..a315400b7 100644
--- a/navit/attr.h
+++ b/navit/attr.h
@@ -79,18 +79,19 @@ enum attr_format {
#define AF_TRANSPORT_TRUCK (1<<21)
#define AF_DELIVERY_TRUCK (1<<22)
#define AF_PUBLIC_BUS (1<<23)
-#define AF_TAXI (1<<24)
-#define AF_HIGH_OCCUPANCY_CAR (1<<25)
-#define AF_CAR (1<<26)
-#define AF_MOTORCYCLE (1<<27)
-#define AF_MOPED (1<<28)
-#define AF_HORSE (1<<29)
-#define AF_BIKE (1<<30)
-#define AF_PEDESTRIAN (1<<31)
+#define AF_TAXI (1<<24)
+#define AF_HIGH_OCCUPANCY_CAR (1<<25)
+#define AF_CAR (1<<26)
+#define AF_MOTORCYCLE (1<<27)
+#define AF_MOPED (1<<28)
+#define AF_HORSE (1<<29)
+#define AF_BIKE (1<<30)
+#define AF_PEDESTRIAN (1<<31)
#define AF_PBH (AF_PEDESTRIAN|AF_BIKE|AF_HORSE)
#define AF_MOTORIZED_FAST (AF_MOTORCYCLE|AF_CAR|AF_HIGH_OCCUPANCY_CAR|AF_TAXI|AF_PUBLIC_BUS|AF_DELIVERY_TRUCK|AF_TRANSPORT_TRUCK|AF_EMERGENCY_VEHICLES)
#define AF_ALL (AF_PBH|AF_MOPED|AF_MOTORIZED_FAST)
+#define AF_DISTORTIONMASK (AF_ALL|AF_ONEWAYMASK)
#define AF_DG_ANY (1<<0)
diff --git a/navit/attr_def.h b/navit/attr_def.h
index e21df52f3..1f1ce88a7 100644
--- a/navit/attr_def.h
+++ b/navit/attr_def.h
@@ -19,7 +19,7 @@
/** @file attr_def.h
* @brief Attribute definitions.
- *
+ *
* Any attribute used by a Navit object must be defined in this file.
*
* @author Navit Team
@@ -347,7 +347,7 @@ ATTR(daylayout)
ATTR(nightlayout)
ATTR(xml_text)
ATTR(layout_name)
-ATTR_UNUSED
+ATTR(default_layout)
ATTR_UNUSED
ATTR(status_text)
ATTR(log_gpx_desc)
@@ -443,6 +443,8 @@ ATTR(text_color)
ATTR(idle_color)
ATTR(background_color2)
ATTR(text_background)
+ATTR(destination_dir_color)
+ATTR(north_color)
ATTR2(0x0007ffff,type_color_end)
ATTR2(0x00080000,type_object_begin)
ATTR(navit)
@@ -486,6 +488,7 @@ ATTR(maps)
ATTR(layout)
ATTR(profile_option)
ATTR(script)
+ATTR(traffic)
ATTR(audio)
ATTR2(0x0008ffff,type_object_end)
ATTR2(0x00090000,type_coord_begin)
diff --git a/navit/autoload/osso/CMakeLists.txt b/navit/autoload/osso/CMakeLists.txt
index 905afb01b..2a6f9b631 100644
--- a/navit/autoload/osso/CMakeLists.txt
+++ b/navit/autoload/osso/CMakeLists.txt
@@ -1,2 +1,2 @@
-module_add_library(autoload_osso osso.c)
+module_add_library(autoload_osso osso.c)
diff --git a/navit/autoload/osso/osso.c b/navit/autoload/osso/osso.c
index f6672090c..b94657569 100644
--- a/navit/autoload/osso/osso.c
+++ b/navit/autoload/osso/osso.c
@@ -12,89 +12,75 @@
static osso_context_t *osso_context;
static struct attr callback = { attr_callback };
-extern char *version;
-
struct cb_hw_state_trail {
- struct navit* nav;
- osso_hw_state_t *state;
+ struct navit* nav;
+ osso_hw_state_t *state;
};
-static void
-osso_display_on(struct navit *this_)
-{
- osso_return_t err;
- err = osso_display_blanking_pause(osso_context);
- dbg(lvl_warning, "Unblank result: ",
- err == OSSO_OK ? "Ok" : (err ==
- OSSO_ERROR ? "Error" :
- "Invalid context"));
+static void osso_display_on(struct navit *this_) {
+ osso_return_t err;
+ err = osso_display_blanking_pause(osso_context);
+ dbg(lvl_warning, "Unblank result: ",
+ err == OSSO_OK ? "Ok" : (err ==
+ OSSO_ERROR ? "Error" :
+ "Invalid context"));
}
-static gboolean
-osso_cb_hw_state_idle(struct cb_hw_state_trail * params)
-{
- dbg(lvl_debug, "(inact=%d, save=%d, shut=%d, memlow=%d, state=%d)\n",
- params->state->system_inactivity_ind,
- params->state->save_unsaved_data_ind, params->state->shutdown_ind,
- params->state->memory_low_ind, params->state->sig_device_mode_ind);
+static gboolean osso_cb_hw_state_idle(struct cb_hw_state_trail * params) {
+ dbg(lvl_debug, "(inact=%d, save=%d, shut=%d, memlow=%d, state=%d)",
+ params->state->system_inactivity_ind,
+ params->state->save_unsaved_data_ind, params->state->shutdown_ind,
+ params->state->memory_low_ind, params->state->sig_device_mode_ind);
- if (params->state->shutdown_ind) {
- /* we are going down, down, down */
- navit_destroy(params->nav);
- }
+ if (params->state->shutdown_ind) {
+ /* we are going down, down, down */
+ navit_destroy(params->nav);
+ }
- g_free(params->state);
- g_free(params);
+ g_free(params->state);
+ g_free(params);
- return FALSE;
+ return FALSE;
}
/**
- * * Handle osso events
- * * @param state Osso hardware state
- * * @param data ptr to private data
- * * @returns nothing
+ * * Handle osso events
+ * * @param state Osso hardware state
+ * * @param data ptr to private data
+ * * @returns nothing
**/
-static void
-osso_cb_hw_state(osso_hw_state_t * state, gpointer data)
-{
- struct navit *nav = (struct navit*)data;
- struct cb_hw_state_trail *params = g_new(struct cb_hw_state_trail,1);
- params->nav=nav;
- params->state = g_new(osso_hw_state_t, 1);
- memcpy(params->state, state, sizeof(osso_hw_state_t));
- g_idle_add((GSourceFunc) osso_cb_hw_state_idle, params);
+static void osso_cb_hw_state(osso_hw_state_t * state, gpointer data) {
+ struct navit *nav = (struct navit*)data;
+ struct cb_hw_state_trail *params = g_new(struct cb_hw_state_trail,1);
+ params->nav=nav;
+ params->state = g_new(osso_hw_state_t, 1);
+ memcpy(params->state, state, sizeof(osso_hw_state_t));
+ g_idle_add((GSourceFunc) osso_cb_hw_state_idle, params);
}
-static void
-osso_navit(struct navit *nav, int add)
-{
- dbg(lvl_debug, "Installing osso context for org.navit_project.navit\n");
- osso_context = osso_initialize("org.navit_project.navit", version, TRUE, NULL);
- if (osso_context == NULL) {
- dbg(lvl_error, "error initiating osso context\n");
- }
- osso_hw_set_event_cb(osso_context, NULL, osso_cb_hw_state, nav);
+static void osso_navit(struct navit *nav, int add) {
+ dbg(lvl_debug, "Installing osso context for org.navit_project.navit");
+ osso_context = osso_initialize("org.navit_project.navit", NAVIT_VERSION, TRUE, NULL);
+ if (osso_context == NULL) {
+ dbg(lvl_error, "error initiating osso context");
+ }
+ osso_hw_set_event_cb(osso_context, NULL, osso_cb_hw_state, nav);
- if (add > 0) {
- /* add callback to unblank screen */
- navit_add_callback(nav, callback_new_attr_0(callback_cast (osso_display_on), attr_unsuspend));
- }
+ if (add > 0) {
+ /* add callback to unblank screen */
+ navit_add_callback(nav, callback_new_attr_0(callback_cast (osso_display_on), attr_unsuspend));
+ }
}
-void
-plugin_init(void)
-{
- //struct callback *cb;
+void plugin_init(void) {
+ //struct callback *cb;
- dbg(lvl_info, "enter\n");
+ dbg(lvl_info, "enter");
- callback.u.callback = callback_new_attr_0(callback_cast(osso_navit), attr_navit);
- config_add_attr(config, &callback);
+ callback.u.callback = callback_new_attr_0(callback_cast(osso_navit), attr_navit);
+ config_add_attr(config, &callback);
}
-void
-plugin_deinit(void)
-{
- osso_deinitialize(osso_context);
+void plugin_deinit(void) {
+ osso_deinitialize(osso_context);
}
diff --git a/navit/binding/dbus/CMakeLists.txt b/navit/binding/dbus/CMakeLists.txt
index 6f081ab09..b6378da14 100644
--- a/navit/binding/dbus/CMakeLists.txt
+++ b/navit/binding/dbus/CMakeLists.txt
@@ -1,10 +1,10 @@
-module_add_library(binding_dbus binding_dbus.c)
+module_add_library(binding_dbus binding_dbus.c)
set(bindir ${CMAKE_INSTALL_PREFIX}/${BIN_DIR})
configure_file (
- "${CMAKE_CURRENT_SOURCE_DIR}/org.navit_project.navit.service.in"
- "${CMAKE_CURRENT_BINARY_DIR}/org.navit_project.navit.service"
-)
+ "${CMAKE_CURRENT_SOURCE_DIR}/org.navit_project.navit.service.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/org.navit_project.navit.service"
+ )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.navit_project.navit.service DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dbus-1/services/)
diff --git a/navit/binding/dbus/binding_dbus.c b/navit/binding/dbus/binding_dbus.c
index 97b48f9c4..aa776db10 100644
--- a/navit/binding/dbus/binding_dbus.c
+++ b/navit/binding/dbus/binding_dbus.c
@@ -52,6 +52,7 @@
#include "util.h"
#include "transform.h"
#include "event.h"
+#include "traffic.h"
static DBusConnection *connection;
static dbus_uint32_t dbus_serial;
@@ -76,367 +77,334 @@ GHashTable *object_hash_rev;
GHashTable *object_count;
struct dbus_callback {
- struct callback *callback;
- char *signal;
+ struct callback *callback;
+ char *signal;
};
-static char *
-object_new(char *type, void *object)
-{
- int id;
- char *ret;
- dbg(lvl_debug,"enter %s\n", type);
- if ((ret=g_hash_table_lookup(object_hash_rev, object)))
- return ret;
- id=GPOINTER_TO_INT(g_hash_table_lookup(object_count, type));
- g_hash_table_insert(object_count, type, GINT_TO_POINTER((id+1)));
- ret=g_strdup_printf("%s/%s/%d", object_path, type, id);
- g_hash_table_insert(object_hash, ret, object);
- g_hash_table_insert(object_hash_rev, object, ret);
- dbg(lvl_debug,"return %s\n", ret);
- return (ret);
-}
-
-static void *
-object_get(const char *path)
-{
- return g_hash_table_lookup(object_hash, path);
-}
-
-static void
-object_destroy(const char *path, void *object)
-{
- if (!path && !object)
- return;
- if (!object)
- object=g_hash_table_lookup(object_hash, path);
- if (!path)
- path=g_hash_table_lookup(object_hash_rev, object);
- g_hash_table_remove(object_hash, path);
- g_hash_table_remove(object_hash_rev, object);
-}
-
-static void *
-resolve_object(const char *opath, char *type)
-{
- char *prefix;
- const char *oprefix;
- void *ret=NULL;
- char *def_navit="/default_navit";
- char *def_gui="/default_gui";
- char *def_graphics="/default_graphics";
- char *def_vehicle="/default_vehicle";
- char *def_vehicleprofile="/default_vehicleprofile";
- char *def_mapset="/default_mapset";
- char *def_map="/default_map";
- char *def_navigation="/default_navigation";
- char *def_route="/default_route";
- char *def_tracking="/default_tracking";
- struct attr attr;
-
- if (strncmp(opath, object_path, strlen(object_path))) {
- dbg(lvl_error,"wrong object path %s\n",opath);
- return NULL;
- }
- prefix=g_strdup_printf("%s/%s/", object_path, type);
- if (!strncmp(prefix, opath, strlen(prefix))) {
- ret=object_get(opath);
- g_free(prefix);
- return ret;
- }
- g_free(prefix);
- oprefix=opath+strlen(object_path);
- if (!strncmp(oprefix,def_navit,strlen(def_navit))) {
- oprefix+=strlen(def_navit);
- struct attr navit;
- if (!config_get_attr(config, attr_navit, &navit, NULL))
- return NULL;
- if (!oprefix[0]) {
- dbg(lvl_debug,"default_navit\n");
- return navit.u.navit;
- }
- if (!strncmp(oprefix,def_graphics,strlen(def_graphics))) {
- if (navit_get_attr(navit.u.navit, attr_graphics, &attr, NULL)) {
- return attr.u.graphics;
- }
- return NULL;
- }
- if (!strncmp(oprefix,def_gui,strlen(def_gui))) {
- if (navit_get_attr(navit.u.navit, attr_gui, &attr, NULL)) {
- return attr.u.gui;
- }
- return NULL;
- }
- if (!strncmp(oprefix,def_vehicleprofile,strlen(def_vehicleprofile))) {
- if (navit_get_attr(navit.u.navit, attr_vehicleprofile, &attr, NULL)) {
- return attr.u.vehicleprofile;
- }
- return NULL;
- }
- if (!strncmp(oprefix,def_vehicle,strlen(def_vehicle))) {
- if (navit_get_attr(navit.u.navit, attr_vehicle, &attr, NULL)) {
- return attr.u.vehicle;
- }
- return NULL;
- }
- if (!strncmp(oprefix,def_mapset,strlen(def_mapset))) {
- oprefix+=strlen(def_mapset);
- if (navit_get_attr(navit.u.navit, attr_mapset, &attr, NULL)) {
- if (!oprefix[0]) {
- return attr.u.mapset;
- }
- if (!strncmp(oprefix,def_map,strlen(def_map))) {
- if (mapset_get_attr(attr.u.mapset, attr_map, &attr, NULL)) {
- return attr.u.map;
- }
- return NULL;
- }
- }
- return NULL;
- }
- if (!strncmp(oprefix,def_navigation,strlen(def_navigation))) {
- if (navit_get_attr(navit.u.navit, attr_navigation, &attr, NULL)) {
- return attr.u.navigation;
- }
- return NULL;
- }
- if (!strncmp(oprefix,def_route,strlen(def_route))) {
- oprefix+=strlen(def_route);
- if (navit_get_attr(navit.u.navit, attr_route, &attr, NULL)) {
- return attr.u.route;
- }
- return NULL;
- }
- if (!strncmp(oprefix,def_tracking,strlen(def_tracking))) {
- if (navit_get_attr(navit.u.navit, attr_trackingo, &attr, NULL)) {
- return attr.u.tracking;
- }
- return NULL;
- }
- }
- return NULL;
-}
-
-static void *
-object_get_from_message_arg(DBusMessageIter *iter, char *type)
-{
- char *opath;
-
- if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_OBJECT_PATH)
- return NULL;
- dbus_message_iter_get_basic(iter, &opath);
- dbus_message_iter_next(iter);
- return resolve_object(opath, type);
-}
-
-static void *
-object_get_from_message(DBusMessage *message, char *type)
-{
- return resolve_object(dbus_message_get_path(message), type);
-}
-
-static enum attr_type
-attr_type_get_from_message(DBusMessageIter *iter)
-{
- char *attr_type;
-
- if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
- return attr_none;
- dbus_message_iter_get_basic(iter, &attr_type);
- dbus_message_iter_next(iter);
- return attr_from_name(attr_type);
-}
-
-static void
-encode_variant_string(DBusMessageIter *iter, char *str)
-{
- DBusMessageIter variant;
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &variant);
- dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &str);
- dbus_message_iter_close_container(iter, &variant);
-}
-
-static void
-encode_dict_string_variant_string(DBusMessageIter *iter, char *key, char *value)
-{
- DBusMessageIter dict;
- dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, NULL, &dict);
- dbus_message_iter_append_basic(&dict, DBUS_TYPE_STRING, &key);
- encode_variant_string(&dict, value);
- dbus_message_iter_close_container(iter, &dict);
-}
-
-static int
-encode_attr(DBusMessageIter *iter1, struct attr *attr)
-{
- char *name=attr_to_name(attr->type);
- DBusMessageIter iter2,iter3;
- dbus_message_iter_append_basic(iter1, DBUS_TYPE_STRING, &name);
- if (attr->type >= attr_type_int_begin && attr->type < attr_type_boolean_begin) {
- dbus_message_iter_open_container(iter1, DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &iter2);
- dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &attr->u.num);
- dbus_message_iter_close_container(iter1, &iter2);
- }
- if (attr->type >= attr_type_boolean_begin && attr->type <= attr_type_int_end) {
- dbus_message_iter_open_container(iter1, DBUS_TYPE_VARIANT, DBUS_TYPE_BOOLEAN_AS_STRING, &iter2);
- dbus_message_iter_append_basic(&iter2, DBUS_TYPE_BOOLEAN, &attr->u.num);
- dbus_message_iter_close_container(iter1, &iter2);
- }
- if (attr->type >= attr_type_string_begin && attr->type <= attr_type_string_end) {
- encode_variant_string(iter1, attr->u.str);
- }
- if ((attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end) || attr->type == attr_item_type) {
- encode_variant_string(iter1, item_to_name(attr->u.item_type));
- }
- if (attr->type >= attr_type_pcoord_begin && attr->type <= attr_type_pcoord_end) {
- dbus_message_iter_open_container(iter1, DBUS_TYPE_VARIANT, "ai", &iter2);
- dbus_message_iter_open_container(&iter2, DBUS_TYPE_ARRAY, "i", &iter3);
- if (attr->u.pcoord) {
- dbus_message_iter_append_basic(&iter3, DBUS_TYPE_INT32, &attr->u.pcoord->pro);
- dbus_message_iter_append_basic(&iter3, DBUS_TYPE_INT32, &attr->u.pcoord->x);
- dbus_message_iter_append_basic(&iter3, DBUS_TYPE_INT32, &attr->u.pcoord->y);
- }
- dbus_message_iter_close_container(&iter2, &iter3);
- dbus_message_iter_close_container(iter1, &iter2);
- }
- if (attr->type >= attr_type_object_begin && attr->type <= attr_type_object_end) {
- char *object=object_new(attr_to_name(attr->type), attr->u.data);
- dbus_message_iter_open_container(iter1, DBUS_TYPE_VARIANT, DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter2);
- dbus_message_iter_append_basic(&iter2, DBUS_TYPE_OBJECT_PATH, &object);
- dbus_message_iter_close_container(iter1, &iter2);
- }
- if (attr->type == attr_item_types) {
- char *str=attr_to_text(attr,NULL,0);
- encode_variant_string(iter1, str);
- g_free(str);
- }
- return 1;
-}
-
-
-static DBusHandlerResult
-empty_reply(DBusConnection *connection, DBusMessage *message)
-{
- DBusMessage *reply;
-
- reply = dbus_message_new_method_return(message);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-
-static DBusHandlerResult
-dbus_error(DBusConnection *connection, DBusMessage *message, char *error, char *msg)
-{
- DBusMessage *reply;
-
- reply = dbus_message_new_error(message, error, msg);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static DBusHandlerResult
-dbus_error_invalid_attr_type(DBusConnection *connection, DBusMessage *message)
-{
- return dbus_error(connection, message, DBUS_ERROR_INVALID_ARGS, "attribute type invalid");
-}
-
-static DBusHandlerResult
-dbus_error_invalid_parameter(DBusConnection *connection, DBusMessage *message)
-{
- return dbus_error(connection, message, DBUS_ERROR_INVALID_ARGS, "parameter invalid");
-}
-
-static DBusHandlerResult
-dbus_error_invalid_object_path(DBusConnection *connection, DBusMessage *message)
-{
- return dbus_error(connection, message, DBUS_ERROR_BAD_ADDRESS, "object path invalid");
-}
-
-static DBusHandlerResult
-dbus_error_invalid_object_path_parameter(DBusConnection *connection, DBusMessage *message)
-{
- return dbus_error(connection, message, DBUS_ERROR_BAD_ADDRESS, "object path parameter invalid");
-}
-
-static DBusHandlerResult
-dbus_error_navigation_not_configured(DBusConnection *connection, DBusMessage *message)
-{
- return dbus_error(connection, message, DBUS_ERROR_FAILED, "navigation is not configured (no <navigation> element in config file?)");
-}
-
-static DBusHandlerResult
-dbus_error_no_data_available(DBusConnection *connection, DBusMessage *message)
-{
+static char *object_new(char *type, void *object) {
+ int id;
+ char *ret;
+ dbg(lvl_debug,"enter %s", type);
+ if ((ret=g_hash_table_lookup(object_hash_rev, object)))
+ return ret;
+ id=GPOINTER_TO_INT(g_hash_table_lookup(object_count, type));
+ g_hash_table_insert(object_count, type, GINT_TO_POINTER((id+1)));
+ ret=g_strdup_printf("%s/%s/%d", object_path, type, id);
+ g_hash_table_insert(object_hash, ret, object);
+ g_hash_table_insert(object_hash_rev, object, ret);
+ dbg(lvl_debug,"return %s", ret);
+ return (ret);
+}
+
+static void *object_get(const char *path) {
+ return g_hash_table_lookup(object_hash, path);
+}
+
+static void object_destroy(const char *path, void *object) {
+ if (!path && !object)
+ return;
+ if (!object)
+ object=g_hash_table_lookup(object_hash, path);
+ if (!path)
+ path=g_hash_table_lookup(object_hash_rev, object);
+ g_hash_table_remove(object_hash, path);
+ g_hash_table_remove(object_hash_rev, object);
+}
+
+static void *resolve_object(const char *opath, char *type) {
+ char *prefix;
+ const char *oprefix;
+ void *ret=NULL;
+ char *def_navit="/default_navit";
+ char *def_gui="/default_gui";
+ char *def_graphics="/default_graphics";
+ char *def_vehicle="/default_vehicle";
+ char *def_vehicleprofile="/default_vehicleprofile";
+ char *def_mapset="/default_mapset";
+ char *def_map="/default_map";
+ char *def_navigation="/default_navigation";
+ char *def_route="/default_route";
+ char *def_tracking="/default_tracking";
+ struct attr attr;
+
+ if (strncmp(opath, object_path, strlen(object_path))) {
+ dbg(lvl_error,"wrong object path %s",opath);
+ return NULL;
+ }
+ prefix=g_strdup_printf("%s/%s/", object_path, type);
+ if (!strncmp(prefix, opath, strlen(prefix))) {
+ ret=object_get(opath);
+ g_free(prefix);
+ return ret;
+ }
+ g_free(prefix);
+ oprefix=opath+strlen(object_path);
+ if (!strncmp(oprefix,def_navit,strlen(def_navit))) {
+ oprefix+=strlen(def_navit);
+ struct attr navit;
+ if (!config_get_attr(config, attr_navit, &navit, NULL))
+ return NULL;
+ if (!oprefix[0]) {
+ dbg(lvl_debug,"default_navit");
+ return navit.u.navit;
+ }
+ if (!strncmp(oprefix,def_graphics,strlen(def_graphics))) {
+ if (navit_get_attr(navit.u.navit, attr_graphics, &attr, NULL)) {
+ return attr.u.graphics;
+ }
+ return NULL;
+ }
+ if (!strncmp(oprefix,def_gui,strlen(def_gui))) {
+ if (navit_get_attr(navit.u.navit, attr_gui, &attr, NULL)) {
+ return attr.u.gui;
+ }
+ return NULL;
+ }
+ if (!strncmp(oprefix,def_vehicleprofile,strlen(def_vehicleprofile))) {
+ if (navit_get_attr(navit.u.navit, attr_vehicleprofile, &attr, NULL)) {
+ return attr.u.vehicleprofile;
+ }
+ return NULL;
+ }
+ if (!strncmp(oprefix,def_vehicle,strlen(def_vehicle))) {
+ if (navit_get_attr(navit.u.navit, attr_vehicle, &attr, NULL)) {
+ return attr.u.vehicle;
+ }
+ return NULL;
+ }
+ if (!strncmp(oprefix,def_mapset,strlen(def_mapset))) {
+ oprefix+=strlen(def_mapset);
+ if (navit_get_attr(navit.u.navit, attr_mapset, &attr, NULL)) {
+ if (!oprefix[0]) {
+ return attr.u.mapset;
+ }
+ if (!strncmp(oprefix,def_map,strlen(def_map))) {
+ if (mapset_get_attr(attr.u.mapset, attr_map, &attr, NULL)) {
+ return attr.u.map;
+ }
+ return NULL;
+ }
+ }
+ return NULL;
+ }
+ if (!strncmp(oprefix,def_navigation,strlen(def_navigation))) {
+ if (navit_get_attr(navit.u.navit, attr_navigation, &attr, NULL)) {
+ return attr.u.navigation;
+ }
+ return NULL;
+ }
+ if (!strncmp(oprefix,def_route,strlen(def_route))) {
+ oprefix+=strlen(def_route);
+ if (navit_get_attr(navit.u.navit, attr_route, &attr, NULL)) {
+ return attr.u.route;
+ }
+ return NULL;
+ }
+ if (!strncmp(oprefix,def_tracking,strlen(def_tracking))) {
+ if (navit_get_attr(navit.u.navit, attr_trackingo, &attr, NULL)) {
+ return attr.u.tracking;
+ }
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+static void *object_get_from_message_arg(DBusMessageIter *iter, char *type) {
+ char *opath;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_OBJECT_PATH)
+ return NULL;
+ dbus_message_iter_get_basic(iter, &opath);
+ dbus_message_iter_next(iter);
+ return resolve_object(opath, type);
+}
+
+static void *object_get_from_message(DBusMessage *message, char *type) {
+ return resolve_object(dbus_message_get_path(message), type);
+}
+
+static enum attr_type attr_type_get_from_message(DBusMessageIter *iter) {
+ char *attr_type;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+ return attr_none;
+ dbus_message_iter_get_basic(iter, &attr_type);
+ dbus_message_iter_next(iter);
+ return attr_from_name(attr_type);
+}
+
+static void encode_variant_string(DBusMessageIter *iter, char *str) {
+ DBusMessageIter variant;
+ dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &variant);
+ dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &str);
+ dbus_message_iter_close_container(iter, &variant);
+}
+
+static void encode_dict_string_variant_string(DBusMessageIter *iter, char *key, char *value) {
+ DBusMessageIter dict;
+ dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY, NULL, &dict);
+ dbus_message_iter_append_basic(&dict, DBUS_TYPE_STRING, &key);
+ encode_variant_string(&dict, value);
+ dbus_message_iter_close_container(iter, &dict);
+}
+
+static int encode_attr(DBusMessageIter *iter1, struct attr *attr) {
+ char *name=attr_to_name(attr->type);
+ DBusMessageIter iter2,iter3;
+ dbus_message_iter_append_basic(iter1, DBUS_TYPE_STRING, &name);
+ if (attr->type >= attr_type_int_begin && attr->type < attr_type_boolean_begin) {
+ dbus_message_iter_open_container(iter1, DBUS_TYPE_VARIANT, DBUS_TYPE_INT32_AS_STRING, &iter2);
+ dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &attr->u.num);
+ dbus_message_iter_close_container(iter1, &iter2);
+ }
+ if (attr->type >= attr_type_boolean_begin && attr->type <= attr_type_int_end) {
+ dbus_message_iter_open_container(iter1, DBUS_TYPE_VARIANT, DBUS_TYPE_BOOLEAN_AS_STRING, &iter2);
+ dbus_message_iter_append_basic(&iter2, DBUS_TYPE_BOOLEAN, &attr->u.num);
+ dbus_message_iter_close_container(iter1, &iter2);
+ }
+ if (attr->type >= attr_type_string_begin && attr->type <= attr_type_string_end) {
+ encode_variant_string(iter1, attr->u.str);
+ }
+ if ((attr->type >= attr_type_item_type_begin && attr->type <= attr_type_item_type_end)
+ || attr->type == attr_item_type) {
+ encode_variant_string(iter1, item_to_name(attr->u.item_type));
+ }
+ if (attr->type >= attr_type_pcoord_begin && attr->type <= attr_type_pcoord_end) {
+ dbus_message_iter_open_container(iter1, DBUS_TYPE_VARIANT, "ai", &iter2);
+ dbus_message_iter_open_container(&iter2, DBUS_TYPE_ARRAY, "i", &iter3);
+ if (attr->u.pcoord) {
+ dbus_message_iter_append_basic(&iter3, DBUS_TYPE_INT32, &attr->u.pcoord->pro);
+ dbus_message_iter_append_basic(&iter3, DBUS_TYPE_INT32, &attr->u.pcoord->x);
+ dbus_message_iter_append_basic(&iter3, DBUS_TYPE_INT32, &attr->u.pcoord->y);
+ }
+ dbus_message_iter_close_container(&iter2, &iter3);
+ dbus_message_iter_close_container(iter1, &iter2);
+ }
+ if (attr->type >= attr_type_object_begin && attr->type <= attr_type_object_end) {
+ char *object=object_new(attr_to_name(attr->type), attr->u.data);
+ dbus_message_iter_open_container(iter1, DBUS_TYPE_VARIANT, DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter2);
+ dbus_message_iter_append_basic(&iter2, DBUS_TYPE_OBJECT_PATH, &object);
+ dbus_message_iter_close_container(iter1, &iter2);
+ }
+ if (attr->type == attr_item_types) {
+ char *str=attr_to_text(attr,NULL,0);
+ encode_variant_string(iter1, str);
+ g_free(str);
+ }
+ return 1;
+}
+
+
+static DBusHandlerResult empty_reply(DBusConnection *connection, DBusMessage *message) {
+ DBusMessage *reply;
+
+ reply = dbus_message_new_method_return(message);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+
+static DBusHandlerResult dbus_error(DBusConnection *connection, DBusMessage *message, char *error, char *msg) {
+ DBusMessage *reply;
+
+ reply = dbus_message_new_error(message, error, msg);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static DBusHandlerResult dbus_error_invalid_attr_type(DBusConnection *connection, DBusMessage *message) {
+ return dbus_error(connection, message, DBUS_ERROR_INVALID_ARGS, "attribute type invalid");
+}
+
+static DBusHandlerResult dbus_error_invalid_parameter(DBusConnection *connection, DBusMessage *message) {
+ return dbus_error(connection, message, DBUS_ERROR_INVALID_ARGS, "parameter invalid");
+}
+
+static DBusHandlerResult dbus_error_invalid_object_path(DBusConnection *connection, DBusMessage *message) {
+ return dbus_error(connection, message, DBUS_ERROR_BAD_ADDRESS, "object path invalid");
+}
+
+static DBusHandlerResult dbus_error_invalid_object_path_parameter(DBusConnection *connection, DBusMessage *message) {
+ return dbus_error(connection, message, DBUS_ERROR_BAD_ADDRESS, "object path parameter invalid");
+}
+
+static DBusHandlerResult dbus_error_navigation_not_configured(DBusConnection *connection, DBusMessage *message) {
+ return dbus_error(connection, message, DBUS_ERROR_FAILED,
+ "navigation is not configured (no <navigation> element in config file?)");
+}
+
+static DBusHandlerResult dbus_error_traffic_not_configured(DBusConnection *connection, DBusMessage *message) {
+ return dbus_error(connection, message, DBUS_ERROR_FAILED,
+ "traffic is not configured (no <traffic> element in config file?)");
+}
+
+static DBusHandlerResult dbus_error_no_data_available(DBusConnection *connection, DBusMessage *message) {
#if 1
- return dbus_error(connection, message, DBUS_ERROR_FILE_NOT_FOUND, "no data available");
+ return dbus_error(connection, message, DBUS_ERROR_FILE_NOT_FOUND, "no data available");
#else
- return empty_reply(connection, message);
+ return empty_reply(connection, message);
#endif
}
#if 0
-static void
-dbus_dump_iter(char *prefix, DBusMessageIter *iter)
-{
- char *prefixr,*vals;
- int arg,vali;
- DBusMessageIter iterr;
- while ((arg=dbus_message_iter_get_arg_type(iter)) != DBUS_TYPE_INVALID) {
- switch (arg) {
- case DBUS_TYPE_INT32:
- dbus_message_iter_get_basic(iter, &vali);
- dbg(lvl_debug,"%sDBUS_TYPE_INT32: %d\n",prefix,vali);
- break;
- case DBUS_TYPE_STRING:
- dbus_message_iter_get_basic(iter, &vals);
- dbg(lvl_debug,"%sDBUS_TYPE_STRING: %s\n",prefix,vals);
- break;
- case DBUS_TYPE_STRUCT:
- dbg(lvl_debug,"%sDBUS_TYPE_STRUCT:\n",prefix);
- prefixr=g_strdup_printf("%s ",prefix);
- dbus_message_iter_recurse(iter, &iterr);
- dbus_dump_iter(prefixr, &iterr);
- g_free(prefixr);
- break;
- case DBUS_TYPE_VARIANT:
- dbg(lvl_debug,"%sDBUS_TYPE_VARIANT:\n",prefix);
- prefixr=g_strdup_printf("%s ",prefix);
- dbus_message_iter_recurse(iter, &iterr);
- dbus_dump_iter(prefixr, &iterr);
- g_free(prefixr);
- break;
- case DBUS_TYPE_DICT_ENTRY:
- dbg(lvl_debug,"%sDBUS_TYPE_DICT_ENTRY:\n",prefix);
- prefixr=g_strdup_printf("%s ",prefix);
- dbus_message_iter_recurse(iter, &iterr);
- dbus_dump_iter(prefixr, &iterr);
- g_free(prefixr);
- break;
- case DBUS_TYPE_ARRAY:
- dbg(lvl_debug,"%sDBUS_TYPE_ARRAY:\n",prefix);
- prefixr=g_strdup_printf("%s ",prefix);
- dbus_message_iter_recurse(iter, &iterr);
- dbus_dump_iter(prefixr, &iterr);
- g_free(prefixr);
- break;
- default:
- dbg(lvl_debug,"%c\n",arg);
- }
- dbus_message_iter_next(iter);
- }
-}
-
-static void
-dbus_dump(DBusMessage *message)
-{
- DBusMessageIter iter;
-
- dbus_message_iter_init(message, &iter);
- dbus_dump_iter("",&iter);
+static void dbus_dump_iter(char *prefix, DBusMessageIter *iter) {
+ char *prefixr,*vals;
+ int arg,vali;
+ DBusMessageIter iterr;
+ while ((arg=dbus_message_iter_get_arg_type(iter)) != DBUS_TYPE_INVALID) {
+ switch (arg) {
+ case DBUS_TYPE_INT32:
+ dbus_message_iter_get_basic(iter, &vali);
+ dbg(lvl_debug,"%sDBUS_TYPE_INT32: %d",prefix,vali);
+ break;
+ case DBUS_TYPE_STRING:
+ dbus_message_iter_get_basic(iter, &vals);
+ dbg(lvl_debug,"%sDBUS_TYPE_STRING: %s",prefix,vals);
+ break;
+ case DBUS_TYPE_STRUCT:
+ dbg(lvl_debug,"%sDBUS_TYPE_STRUCT:",prefix);
+ prefixr=g_strdup_printf("%s ",prefix);
+ dbus_message_iter_recurse(iter, &iterr);
+ dbus_dump_iter(prefixr, &iterr);
+ g_free(prefixr);
+ break;
+ case DBUS_TYPE_VARIANT:
+ dbg(lvl_debug,"%sDBUS_TYPE_VARIANT:",prefix);
+ prefixr=g_strdup_printf("%s ",prefix);
+ dbus_message_iter_recurse(iter, &iterr);
+ dbus_dump_iter(prefixr, &iterr);
+ g_free(prefixr);
+ break;
+ case DBUS_TYPE_DICT_ENTRY:
+ dbg(lvl_debug,"%sDBUS_TYPE_DICT_ENTRY:",prefix);
+ prefixr=g_strdup_printf("%s ",prefix);
+ dbus_message_iter_recurse(iter, &iterr);
+ dbus_dump_iter(prefixr, &iterr);
+ g_free(prefixr);
+ break;
+ case DBUS_TYPE_ARRAY:
+ dbg(lvl_debug,"%sDBUS_TYPE_ARRAY:",prefix);
+ prefixr=g_strdup_printf("%s ",prefix);
+ dbus_message_iter_recurse(iter, &iterr);
+ dbus_dump_iter(prefixr, &iterr);
+ g_free(prefixr);
+ break;
+ default:
+ dbg(lvl_debug,"%c",arg);
+ }
+ dbus_message_iter_next(iter);
+ }
+}
+
+static void dbus_dump(DBusMessage *message) {
+ DBusMessageIter iter;
+
+ dbus_message_iter_init(message, &iter);
+ dbus_dump_iter("",&iter);
}
#endif
@@ -449,9 +417,7 @@ dbus_dump(DBusMessage *message)
* @param pc Pointer where the data should get stored
* @returns Returns 1 when everything went right, otherwise 0
*/
-static int
-pcoord_get_from_message(DBusMessage *message, DBusMessageIter *iter, struct pcoord *pc)
-{
+static int pcoord_get_from_message(DBusMessage *message, DBusMessageIter *iter, struct pcoord *pc) {
if(!strcmp(dbus_message_iter_get_signature(iter), "s")) {
char *coordstring;
@@ -495,652 +461,583 @@ pcoord_get_from_message(DBusMessage *message, DBusMessageIter *iter, struct pcoo
}
-static void
-pcoord_encode(DBusMessageIter *iter, struct pcoord *pc)
-{
- DBusMessageIter iter2;
- dbus_message_iter_open_container(iter,DBUS_TYPE_STRUCT,NULL,&iter2);
- if (pc) {
- dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &pc->pro);
- dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &pc->x);
- dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &pc->y);
- } else {
- int n=0;
- dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &n);
- dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &n);
- dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &n);
- }
- dbus_message_iter_close_container(iter, &iter2);
-}
-
-static enum attr_type
-decode_attr_type_from_iter(DBusMessageIter *iter)
-{
- char *attr_type;
- enum attr_type ret;
-
- if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
- return attr_none;
- dbus_message_iter_get_basic(iter, &attr_type);
- dbus_message_iter_next(iter);
- ret=attr_from_name(attr_type);
- dbg(lvl_debug, "attr value: 0x%x string: %s\n", ret, attr_type);
- return ret;
-}
-
-static int
-decode_attr_from_iter(DBusMessageIter *iter, struct attr *attr)
-{
- DBusMessageIter iterattr, iterstruct;
- int ret=1;
- double d;
-
- attr->type=decode_attr_type_from_iter(iter);
- if (attr->type == attr_none)
- return 0;
-
- dbus_message_iter_recurse(iter, &iterattr);
- dbus_message_iter_next(iter);
- dbg(lvl_debug, "seems valid. signature: %s\n", dbus_message_iter_get_signature(&iterattr));
-
- if (attr->type >= attr_type_item_begin && attr->type <= attr_type_item_end)
- return 0;
-
- if (attr->type >= attr_type_int_begin && attr->type <= attr_type_boolean_begin) {
- if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_INT32) {
- int val;
- dbus_message_iter_get_basic(&iterattr, &val);
- attr->u.num=val;
- return 1;
- }
- return 0;
- }
- if(attr->type >= attr_type_boolean_begin && attr->type <= attr_type_int_end) {
- if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_BOOLEAN) {
- int val;
- dbus_message_iter_get_basic(&iterattr, &val);
- attr->u.num=val;
- return 1;
- }
- return 0;
+static void pcoord_encode(DBusMessageIter *iter, struct pcoord *pc) {
+ DBusMessageIter iter2;
+ dbus_message_iter_open_container(iter,DBUS_TYPE_STRUCT,NULL,&iter2);
+ if (pc) {
+ dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &pc->pro);
+ dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &pc->x);
+ dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &pc->y);
+ } else {
+ int n=0;
+ dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &n);
+ dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &n);
+ dbus_message_iter_append_basic(&iter2, DBUS_TYPE_INT32, &n);
+ }
+ dbus_message_iter_close_container(iter, &iter2);
+}
+
+static enum attr_type decode_attr_type_from_iter(DBusMessageIter *iter) {
+ char *attr_type;
+ enum attr_type ret;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+ return attr_none;
+ dbus_message_iter_get_basic(iter, &attr_type);
+ dbus_message_iter_next(iter);
+ ret=attr_from_name(attr_type);
+ dbg(lvl_debug, "attr value: 0x%x string: %s", ret, attr_type);
+ return ret;
+}
+
+static int decode_attr_from_iter(DBusMessageIter *iter, struct attr *attr) {
+ DBusMessageIter iterattr, iterstruct;
+ int ret=1;
+ double d;
+
+ attr->type=decode_attr_type_from_iter(iter);
+ if (attr->type == attr_none)
+ return 0;
+
+ dbus_message_iter_recurse(iter, &iterattr);
+ dbus_message_iter_next(iter);
+ dbg(lvl_debug, "seems valid. signature: %s", dbus_message_iter_get_signature(&iterattr));
+
+ if (attr->type >= attr_type_item_begin && attr->type <= attr_type_item_end)
+ return 0;
+
+ if (attr->type >= attr_type_int_begin && attr->type <= attr_type_boolean_begin) {
+ if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_INT32) {
+ int val;
+ dbus_message_iter_get_basic(&iterattr, &val);
+ attr->u.num=val;
+ return 1;
+ }
+ return 0;
+ }
+ if(attr->type >= attr_type_boolean_begin && attr->type <= attr_type_int_end) {
+ if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_BOOLEAN) {
+ int val;
+ dbus_message_iter_get_basic(&iterattr, &val);
+ attr->u.num=val;
+ return 1;
+ }
+ return 0;
+ }
+ if(attr->type >= attr_type_string_begin && attr->type <= attr_type_string_end) {
+ if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&iterattr, &attr->u.str);
+ return 1;
+ }
+ return 0;
+ }
+ if(attr->type >= attr_type_double_begin && attr->type <= attr_type_double_end) {
+ if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_DOUBLE) {
+ attr->u.numd=g_new(typeof(*attr->u.numd),1);
+ dbus_message_iter_get_basic(&iterattr, attr->u.numd);
+ return 1;
}
- if(attr->type >= attr_type_string_begin && attr->type <= attr_type_string_end) {
- if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_STRING) {
- dbus_message_iter_get_basic(&iterattr, &attr->u.str);
- return 1;
- }
- return 0;
+ }
+ if(attr->type >= attr_type_object_begin && attr->type <= attr_type_object_end) {
+ if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_OBJECT_PATH) {
+ char *obj;
+ dbus_message_iter_get_basic(&iterattr, &obj);
+ attr->u.data=object_get(obj);
+ if (attr->u.data) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+ if(attr->type >= attr_type_coord_geo_begin && attr->type <= attr_type_coord_geo_end) {
+ if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_STRUCT) {
+ attr->u.coord_geo=g_new(typeof(*attr->u.coord_geo),1);
+ dbus_message_iter_recurse(&iterattr, &iterstruct);
+ if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_DOUBLE) {
+ dbus_message_iter_get_basic(&iterstruct, &d);
+ dbus_message_iter_next(&iterstruct);
+ attr->u.coord_geo->lng=d;
+ } else
+ ret=0;
+ if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_DOUBLE) {
+ dbus_message_iter_get_basic(&iterstruct, &d);
+ attr->u.coord_geo->lat=d;
+ } else
+ ret=0;
+ if (!ret) {
+ g_free(attr->u.coord_geo);
+ attr->u.coord_geo=NULL;
+ }
+ return ret;
+ }
+ }
+ if(attr->type >= attr_type_pcoord_begin && attr->type <= attr_type_pcoord_end) {
+ int i;
+ if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_STRUCT) {
+ attr->u.pcoord=g_new(typeof(*attr->u.pcoord),1);
+ dbus_message_iter_recurse(&iterattr, &iterstruct);
+ if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_INT32) {
+ dbus_message_iter_get_basic(&iterstruct, &i);
+ dbus_message_iter_next(&iterstruct);
+ attr->u.pcoord->pro=i;
+ } else
+ ret=0;
+ if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_INT32) {
+ dbus_message_iter_get_basic(&iterstruct, &i);
+ dbus_message_iter_next(&iterstruct);
+ attr->u.pcoord->x=i;
+ } else
+ ret=0;
+ if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_INT32) {
+ dbus_message_iter_get_basic(&iterstruct, &i);
+ attr->u.pcoord->y=i;
+ } else
+ ret=0;
+ if (!ret) {
+ g_free(attr->u.pcoord);
+ attr->u.pcoord=NULL;
+ }
+ return ret;
}
- if(attr->type >= attr_type_double_begin && attr->type <= attr_type_double_end) {
- if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_DOUBLE) {
- attr->u.numd=g_new(typeof(*attr->u.numd),1);
- dbus_message_iter_get_basic(&iterattr, attr->u.numd);
- return 1;
- }
- }
- if(attr->type >= attr_type_object_begin && attr->type <= attr_type_object_end) {
- if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_OBJECT_PATH) {
- char *obj;
- dbus_message_iter_get_basic(&iterattr, &obj);
- attr->u.data=object_get(obj);
- if (attr->u.data) {
- return 1;
- }
- }
- return 0;
- }
- if(attr->type >= attr_type_coord_geo_begin && attr->type <= attr_type_coord_geo_end) {
- if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_STRUCT) {
- attr->u.coord_geo=g_new(typeof(*attr->u.coord_geo),1);
- dbus_message_iter_recurse(&iterattr, &iterstruct);
- if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_DOUBLE) {
- dbus_message_iter_get_basic(&iterstruct, &d);
- dbus_message_iter_next(&iterstruct);
- attr->u.coord_geo->lng=d;
- } else
- ret=0;
- if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_DOUBLE) {
- dbus_message_iter_get_basic(&iterstruct, &d);
- attr->u.coord_geo->lat=d;
- } else
- ret=0;
- if (!ret) {
- g_free(attr->u.coord_geo);
- attr->u.coord_geo=NULL;
- }
- return ret;
- }
- }
- if(attr->type >= attr_type_pcoord_begin && attr->type <= attr_type_pcoord_end) {
- int i;
- if (dbus_message_iter_get_arg_type(&iterattr) == DBUS_TYPE_STRUCT) {
- attr->u.pcoord=g_new(typeof(*attr->u.pcoord),1);
- dbus_message_iter_recurse(&iterattr, &iterstruct);
- if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_INT32) {
- dbus_message_iter_get_basic(&iterstruct, &i);
- dbus_message_iter_next(&iterstruct);
- attr->u.pcoord->pro=i;
- } else
- ret=0;
- if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_INT32) {
- dbus_message_iter_get_basic(&iterstruct, &i);
- dbus_message_iter_next(&iterstruct);
- attr->u.pcoord->x=i;
- } else
- ret=0;
- if (dbus_message_iter_get_arg_type(&iterstruct) == DBUS_TYPE_INT32) {
- dbus_message_iter_get_basic(&iterstruct, &i);
- attr->u.pcoord->y=i;
- } else
- ret=0;
- if (!ret) {
- g_free(attr->u.pcoord);
- attr->u.pcoord=NULL;
- }
- return ret;
- }
- }
- if (attr->type == attr_callback) {
- struct dbus_callback *callback=object_get_from_message_arg(&iterattr, "callback");
- if (callback) {
- attr->u.callback=callback->callback;
- return 1;
- }
- }
- return 0;
-}
-
-static int
-decode_attr(DBusMessage *message, struct attr *attr)
-{
- DBusMessageIter iter;
-
- dbus_message_iter_init(message, &iter);
- return decode_attr_from_iter(&iter, attr);
-}
-
-static void
-destroy_attr(struct attr *attr)
-{
- if(attr->type > attr_type_double_begin && attr->type < attr_type_double_end) {
- g_free(attr->u.numd);
- }
-}
-
-static char *
-get_iter_name(char *type)
-{
- return g_strdup_printf("%s_attr_iter",type);
-}
-
-static DBusHandlerResult
-request_attr_iter(DBusConnection *connection, DBusMessage *message, char *type, struct attr_iter *(*func)(void))
-{
- DBusMessage *reply;
- char *iter_name;
- char *opath;
- struct attr_iter *attr_iter;
-
- attr_iter=(*func)();
- iter_name=get_iter_name(type);
- opath=object_new(iter_name,attr_iter);
- g_free(iter_name);
- reply = dbus_message_new_method_return(message);
- dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static DBusHandlerResult
-request_attr_iter_destroy(DBusConnection *connection, DBusMessage *message, char *type, void (*func)(struct attr_iter *))
-{
- struct attr_iter *attr_iter;
- DBusMessageIter iter;
- char *iter_name;
-
- dbus_message_iter_init(message, &iter);
- iter_name=get_iter_name(type);
- attr_iter=object_get_from_message_arg(&iter, iter_name);
- g_free(iter_name);
- if (! attr_iter)
- return dbus_error_invalid_object_path_parameter(connection, message);
- object_destroy(NULL, attr_iter);
- func(attr_iter);
-
- return empty_reply(connection, message);
-}
-
-static DBusHandlerResult
-request_destroy(DBusConnection *connection, DBusMessage *message, char *type, void *data, void (*func)(void *))
-{
- if (!data)
- data=object_get_from_message(message, type);
- if (!data)
- return dbus_error_invalid_object_path(connection, message);
- object_destroy(NULL, data);
- func(data);
-
- return empty_reply(connection, message);
-}
-
-
-static DBusHandlerResult
-request_dup(DBusConnection *connection, DBusMessage *message, char *type, void *data, void *(*func)(void *))
-{
- DBusMessage *reply;
- char *opath;
- void *obj;
- if (!data)
- data=object_get_from_message(message, type);
- if (!data)
- return dbus_error_invalid_object_path(connection, message);
- obj=func(data);
- opath=object_new(type,obj);
- reply = dbus_message_new_method_return(message);
- dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-
-static DBusHandlerResult
-request_get_attr(DBusConnection *connection, DBusMessage *message, char *type, void *data, int (*func)(void *data, enum attr_type type, struct attr *attr, struct attr_iter *iter))
-{
- DBusMessage *reply;
- DBusMessageIter iter;
- struct attr attr;
- enum attr_type attr_type;
- struct attr_iter *attr_iter;
- char *iter_name;
-
- if (! data)
- data = object_get_from_message(message, type);
- if (! data)
- return dbus_error_invalid_object_path(connection, message);
-
- dbus_message_iter_init(message, &iter);
- attr_type=attr_type_get_from_message(&iter);
- if (attr_type == attr_none)
- return dbus_error_invalid_attr_type(connection, message);
- iter_name=get_iter_name(type);
- attr_iter=object_get_from_message_arg(&iter, iter_name);
- g_free(iter_name);
- if (func(data, attr_type, &attr, attr_iter)) {
- DBusMessageIter iter1;
- reply = dbus_message_new_method_return(message);
- dbus_message_iter_init_append(reply, &iter1);
- encode_attr(&iter1, &attr);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- return dbus_error_no_data_available(connection, message);
-
-}
-
-static DBusHandlerResult
-request_command(DBusConnection *connection, DBusMessage *message, char *type, void *data, int (*func)(void *data, enum attr_type type, struct attr *attr, struct attr_iter *iter))
-{
- DBusMessageIter iter;
- struct attr attr;
- char *command;
-
- if (! data)
- data = object_get_from_message(message, type);
- if (! data)
- return dbus_error_invalid_object_path(connection, message);
-
- dbus_message_iter_init(message, &iter);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
- return dbus_error_invalid_parameter(connection, message);
- dbus_message_iter_get_basic(&iter, &command);
- dbus_message_iter_next(&iter);
- if (func(data, attr_callback_list, &attr, NULL)) {
- int valid=0;
- callback_list_call_attr_4(attr.u.callback_list, attr_command, command, NULL, NULL, &valid);
- }
- return empty_reply(connection, message);
-
-}
-
-static DBusHandlerResult
-request_set_add_remove_attr(DBusConnection *connection, DBusMessage *message, char *type, void *data, int (*func)(void *data, struct attr *attr))
-{
- struct attr attr;
- int ret;
-
- if (! data)
- data = object_get_from_message(message, type);
- if (! data)
- return dbus_error_invalid_object_path(connection, message);
-
- if (decode_attr(message, &attr)) {
- ret=(*func)(data, &attr);
- destroy_attr(&attr);
- if (ret)
- return empty_reply(connection, message);
- dbg(lvl_error,"failed to set/add/remove attr\n");
- } else {
- dbg(lvl_error,"failed to decode attr\n");
- }
- return dbus_error_invalid_parameter(connection, message);
+ }
+ if (attr->type == attr_callback) {
+ struct dbus_callback *callback=object_get_from_message_arg(&iterattr, "callback");
+ if (callback) {
+ attr->u.callback=callback->callback;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int decode_attr(DBusMessage *message, struct attr *attr) {
+ DBusMessageIter iter;
+
+ dbus_message_iter_init(message, &iter);
+ return decode_attr_from_iter(&iter, attr);
+}
+
+static void destroy_attr(struct attr *attr) {
+ if(attr->type > attr_type_double_begin && attr->type < attr_type_double_end) {
+ g_free(attr->u.numd);
+ }
+}
+
+static char *get_iter_name(char *type) {
+ return g_strdup_printf("%s_attr_iter",type);
+}
+
+static DBusHandlerResult request_attr_iter(DBusConnection *connection, DBusMessage *message, char *type,
+ struct attr_iter *(*func)(void)) {
+ DBusMessage *reply;
+ char *iter_name;
+ char *opath;
+ struct attr_iter *attr_iter;
+
+ attr_iter=(*func)();
+ iter_name=get_iter_name(type);
+ opath=object_new(iter_name,attr_iter);
+ g_free(iter_name);
+ reply = dbus_message_new_method_return(message);
+ dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static DBusHandlerResult request_attr_iter_destroy(DBusConnection *connection, DBusMessage *message, char *type,
+ void (*func)(struct attr_iter *)) {
+ struct attr_iter *attr_iter;
+ DBusMessageIter iter;
+ char *iter_name;
+
+ dbus_message_iter_init(message, &iter);
+ iter_name=get_iter_name(type);
+ attr_iter=object_get_from_message_arg(&iter, iter_name);
+ g_free(iter_name);
+ if (! attr_iter)
+ return dbus_error_invalid_object_path_parameter(connection, message);
+ object_destroy(NULL, attr_iter);
+ func(attr_iter);
+
+ return empty_reply(connection, message);
+}
+
+static DBusHandlerResult request_destroy(DBusConnection *connection, DBusMessage *message, char *type, void *data,
+ void (*func)(void *)) {
+ if (!data)
+ data=object_get_from_message(message, type);
+ if (!data)
+ return dbus_error_invalid_object_path(connection, message);
+ object_destroy(NULL, data);
+ func(data);
+
+ return empty_reply(connection, message);
+}
+
+
+static DBusHandlerResult request_dup(DBusConnection *connection, DBusMessage *message, char *type, void *data,
+ void *(*func)(void *)) {
+ DBusMessage *reply;
+ char *opath;
+ void *obj;
+ if (!data)
+ data=object_get_from_message(message, type);
+ if (!data)
+ return dbus_error_invalid_object_path(connection, message);
+ obj=func(data);
+ opath=object_new(type,obj);
+ reply = dbus_message_new_method_return(message);
+ dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+
+static DBusHandlerResult request_get_attr(DBusConnection *connection, DBusMessage *message, char *type, void *data,
+ int (*func)(void *data, enum attr_type type, struct attr *attr, struct attr_iter *iter)) {
+ DBusMessage *reply;
+ DBusMessageIter iter;
+ struct attr attr;
+ enum attr_type attr_type;
+ struct attr_iter *attr_iter;
+ char *iter_name;
+
+ if (! data)
+ data = object_get_from_message(message, type);
+ if (! data)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+ attr_type=attr_type_get_from_message(&iter);
+ if (attr_type == attr_none)
+ return dbus_error_invalid_attr_type(connection, message);
+ iter_name=get_iter_name(type);
+ attr_iter=object_get_from_message_arg(&iter, iter_name);
+ g_free(iter_name);
+ if (func(data, attr_type, &attr, attr_iter)) {
+ DBusMessageIter iter1;
+ reply = dbus_message_new_method_return(message);
+ dbus_message_iter_init_append(reply, &iter1);
+ encode_attr(&iter1, &attr);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ return dbus_error_no_data_available(connection, message);
+
+}
+
+static DBusHandlerResult request_command(DBusConnection *connection, DBusMessage *message, char *type, void *data,
+ int (*func)(void *data, enum attr_type type, struct attr *attr, struct attr_iter *iter)) {
+ DBusMessageIter iter;
+ struct attr attr;
+ char *command;
+
+ if (! data)
+ data = object_get_from_message(message, type);
+ if (! data)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+ return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_get_basic(&iter, &command);
+ dbus_message_iter_next(&iter);
+ if (func(data, attr_callback_list, &attr, NULL)) {
+ int valid=0;
+ callback_list_call_attr_4(attr.u.callback_list, attr_command, command, NULL, NULL, &valid);
+ }
+ return empty_reply(connection, message);
+
+}
+
+static DBusHandlerResult request_set_add_remove_attr(DBusConnection *connection, DBusMessage *message, char *type,
+ void *data, int (*func)(void *data, struct attr *attr)) {
+ struct attr attr;
+ int ret;
+
+ if (! data)
+ data = object_get_from_message(message, type);
+ if (! data)
+ return dbus_error_invalid_object_path(connection, message);
+
+ if (decode_attr(message, &attr)) {
+ ret=(*func)(data, &attr);
+ destroy_attr(&attr);
+ if (ret)
+ return empty_reply(connection, message);
+ dbg(lvl_error,"failed to set/add/remove attr");
+ } else {
+ dbg(lvl_error,"failed to decode attr");
+ }
+ return dbus_error_invalid_parameter(connection, message);
}
/* callback */
-static void
-dbus_callback_emit_signal(struct dbus_callback *dbus_callback)
-{
- DBusMessage* msg;
- msg = dbus_message_new_signal(object_path, service_name, dbus_callback->signal);
- if (msg) {
- dbus_connection_send(connection, msg, &dbus_serial);
- dbus_connection_flush(connection);
- dbus_message_unref(msg);
- }
-}
-
-static void
-request_callback_destroy_do(struct dbus_callback *data)
-{
- callback_destroy(data->callback);
- g_free(data->signal);
- g_free(data);
-}
-
-static DBusHandlerResult
-request_callback_destroy(DBusConnection *connection, DBusMessage *message)
-{
- return request_destroy(connection, message, "callback", NULL, (void (*)(void *)) request_callback_destroy_do);
-}
-
-static DBusHandlerResult
-request_callback_new(DBusConnection *connection, DBusMessage *message)
-{
- DBusMessageIter iter;
- DBusMessage *reply;
- struct dbus_callback *callback;
- char *signal,*opath;
- enum attr_type type;
-
- dbus_message_iter_init(message, &iter);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
- return dbus_error_invalid_parameter(connection, message);
- dbus_message_iter_get_basic(&iter, &signal);
- dbus_message_iter_next(&iter);
- callback=g_new0(struct dbus_callback, 1);
- callback->signal=g_strdup(signal);
-
- if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING) {
- type=attr_type_get_from_message(&iter);
- callback->callback=callback_new_attr_1(callback_cast(dbus_callback_emit_signal), type, callback);
- } else
- callback->callback=callback_new_1(callback_cast(dbus_callback_emit_signal), callback);
- opath=object_new("callback", callback);
- reply = dbus_message_new_method_return(message);
- dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
+static void dbus_callback_emit_signal(struct dbus_callback *dbus_callback) {
+ DBusMessage* msg;
+ msg = dbus_message_new_signal(object_path, service_name, dbus_callback->signal);
+ if (msg) {
+ dbus_connection_send(connection, msg, &dbus_serial);
+ dbus_connection_flush(connection);
+ dbus_message_unref(msg);
+ }
+}
+
+static void request_callback_destroy_do(struct dbus_callback *data) {
+ callback_destroy(data->callback);
+ g_free(data->signal);
+ g_free(data);
+}
+
+static DBusHandlerResult request_callback_destroy(DBusConnection *connection, DBusMessage *message) {
+ return request_destroy(connection, message, "callback", NULL, (void (*)(void *)) request_callback_destroy_do);
+}
+
+static DBusHandlerResult request_callback_new(DBusConnection *connection, DBusMessage *message) {
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ struct dbus_callback *callback;
+ char *signal,*opath;
+ enum attr_type type;
+
+ dbus_message_iter_init(message, &iter);
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+ return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_get_basic(&iter, &signal);
+ dbus_message_iter_next(&iter);
+ callback=g_new0(struct dbus_callback, 1);
+ callback->signal=g_strdup(signal);
+
+ if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING) {
+ type=attr_type_get_from_message(&iter);
+ callback->callback=callback_new_attr_1(callback_cast(dbus_callback_emit_signal), type, callback);
+ } else
+ callback->callback=callback_new_1(callback_cast(dbus_callback_emit_signal), callback);
+ opath=object_new("callback", callback);
+ reply = dbus_message_new_method_return(message);
+ dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+ return DBUS_HANDLER_RESULT_HANDLED;
}
/* config */
-static DBusHandlerResult
-request_config_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "config", config, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))config_get_attr);
+static DBusHandlerResult request_config_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "config", config, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))config_get_attr);
}
-static DBusHandlerResult
-request_config_attr_iter(DBusConnection *connection, DBusMessage *message)
-{
- return request_attr_iter(connection, message, "config", (struct attr_iter * (*)(void))config_attr_iter_new);
+static DBusHandlerResult request_config_attr_iter(DBusConnection *connection, DBusMessage *message) {
+ return request_attr_iter(connection, message, "config", (struct attr_iter * (*)(void))config_attr_iter_new);
}
-static DBusHandlerResult
-request_config_attr_iter_destroy(DBusConnection *connection, DBusMessage *message)
-{
- return request_attr_iter_destroy(connection, message, "config", (void (*)(struct attr_iter *))config_attr_iter_destroy);
+static DBusHandlerResult request_config_attr_iter_destroy(DBusConnection *connection, DBusMessage *message) {
+ return request_attr_iter_destroy(connection, message, "config", (void (*)(struct attr_iter *))config_attr_iter_destroy);
}
/* graphics */
-static DBusHandlerResult
-request_graphics_get_data(DBusConnection *connection, DBusMessage *message)
-{
- struct graphics *graphics;
- char *data;
- struct graphics_data_image *image;
- DBusMessage *reply;
-
- graphics = object_get_from_message(message, "graphics");
- if (! graphics)
- return dbus_error_invalid_object_path(connection, message);
-
- if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &data, DBUS_TYPE_INVALID))
- return dbus_error_invalid_parameter(connection, message);
- image=graphics_get_data(graphics, data);
- if (image) {
- DBusMessageIter iter1,iter2;
- reply = dbus_message_new_method_return(message);
+static DBusHandlerResult request_graphics_get_data(DBusConnection *connection, DBusMessage *message) {
+ struct graphics *graphics;
+ char *data;
+ struct graphics_data_image *image;
+ DBusMessage *reply;
+
+ graphics = object_get_from_message(message, "graphics");
+ if (! graphics)
+ return dbus_error_invalid_object_path(connection, message);
+
+ if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &data, DBUS_TYPE_INVALID))
+ return dbus_error_invalid_parameter(connection, message);
+ image=graphics_get_data(graphics, data);
+ if (image) {
+ DBusMessageIter iter1,iter2;
+ reply = dbus_message_new_method_return(message);
#if 0
- dbus_message_append_args(reply, DBUS_TYPE_STRING, &result, DBUS_TYPE_INVALID);
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &result, DBUS_TYPE_INVALID);
#endif
- dbus_message_iter_init_append(reply, &iter1);
- dbus_message_iter_open_container(&iter1, DBUS_TYPE_ARRAY, "y", &iter2);
- if (image->data && image->size)
- dbus_message_iter_append_fixed_array(&iter2, DBUS_TYPE_BYTE, &image->data, image->size);
- dbus_message_iter_close_container(&iter1, &iter2);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- return dbus_error_no_data_available(connection, message);
+ dbus_message_iter_init_append(reply, &iter1);
+ dbus_message_iter_open_container(&iter1, DBUS_TYPE_ARRAY, "y", &iter2);
+ if (image->data && image->size)
+ dbus_message_iter_append_fixed_array(&iter2, DBUS_TYPE_BYTE, &image->data, image->size);
+ dbus_message_iter_close_container(&iter1, &iter2);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ return dbus_error_no_data_available(connection, message);
}
/* gui */
-static DBusHandlerResult
-request_gui_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "gui", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))gui_get_attr);
+static DBusHandlerResult request_gui_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "gui", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))gui_get_attr);
}
-static DBusHandlerResult
-request_gui_command(DBusConnection *connection, DBusMessage *message)
-{
- return request_command(connection, message, "gui", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))gui_get_attr);
+static DBusHandlerResult request_gui_command(DBusConnection *connection, DBusMessage *message) {
+ return request_command(connection, message, "gui", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))gui_get_attr);
}
-static DBusHandlerResult
-request_graphics_set_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "graphics", NULL, (int (*)(void *, struct attr *))graphics_set_attr);
+static DBusHandlerResult request_graphics_set_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "graphics", NULL, (int (*)(void *,
+ struct attr *))graphics_set_attr);
}
/* layout */
-static DBusHandlerResult
-request_layout_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "layout", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))layout_get_attr);
+static DBusHandlerResult request_layout_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "layout", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))layout_get_attr);
}
/* map */
-static DBusHandlerResult
-request_map_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "map", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))map_get_attr);
+static DBusHandlerResult request_map_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "map", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))map_get_attr);
}
-static DBusHandlerResult
-request_map_set_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "map", NULL, (int (*)(void *, struct attr *))map_set_attr);
+static DBusHandlerResult request_map_set_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "map", NULL, (int (*)(void *, struct attr *))map_set_attr);
}
-static DBusHandlerResult
-request_map_dump(DBusConnection *connection, DBusMessage *message)
-{
- DBusMessageIter iter;
- struct map *map;
-
- map=object_get_from_message(message, "map");
- if (! map)
- return dbus_error_invalid_object_path(connection, message);
-
- dbus_message_iter_init(message, &iter);
- if(!strcmp(dbus_message_iter_get_signature(&iter), "s")) {
- char *file;
- FILE *f;
- dbus_message_iter_get_basic(&iter, &file);
- /* dbg(0,"File '%s'\n",file); */
- f=fopen(file,"w");
- map_dump_filedesc(map,f);
- fclose(f);
- return empty_reply(connection, message);
- }
- return dbus_error_invalid_parameter(connection, message);
+static DBusHandlerResult request_map_dump(DBusConnection *connection, DBusMessage *message) {
+ DBusMessageIter iter;
+ struct map *map;
+
+ map=object_get_from_message(message, "map");
+ if (! map)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+ if(!strcmp(dbus_message_iter_get_signature(&iter), "s")) {
+ char *file;
+ FILE *f;
+ dbus_message_iter_get_basic(&iter, &file);
+ /* dbg(0,"File '%s'",file); */
+ f=fopen(file,"w");
+ map_dump_filedesc(map,f);
+ fclose(f);
+ return empty_reply(connection, message);
+ }
+ return dbus_error_invalid_parameter(connection, message);
}
/* mapset */
-static DBusHandlerResult
-request_mapset_attr_iter(DBusConnection *connection, DBusMessage *message)
-{
- return request_attr_iter(connection, message, "mapset", (struct attr_iter * (*)(void))mapset_attr_iter_new);
+static DBusHandlerResult request_mapset_attr_iter(DBusConnection *connection, DBusMessage *message) {
+ return request_attr_iter(connection, message, "mapset", (struct attr_iter * (*)(void))mapset_attr_iter_new);
}
-static DBusHandlerResult
-request_mapset_attr_iter_destroy(DBusConnection *connection, DBusMessage *message)
-{
- return request_attr_iter_destroy(connection, message, "mapset", (void (*)(struct attr_iter *))mapset_attr_iter_destroy);
+static DBusHandlerResult request_mapset_attr_iter_destroy(DBusConnection *connection, DBusMessage *message) {
+ return request_attr_iter_destroy(connection, message, "mapset", (void (*)(struct attr_iter *))mapset_attr_iter_destroy);
}
-static DBusHandlerResult
-request_mapset_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "mapset", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))mapset_get_attr);
+static DBusHandlerResult request_mapset_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "mapset", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))mapset_get_attr);
}
/* navigation */
-static DBusHandlerResult
-request_navigation_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "navigation", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))navigation_get_attr);
+static DBusHandlerResult request_navigation_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "navigation", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))navigation_get_attr);
}
/* osd */
-static DBusHandlerResult
-request_osd_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "osd", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))osd_get_attr);
+static DBusHandlerResult request_osd_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "osd", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))osd_get_attr);
}
-static DBusHandlerResult
-request_osd_set_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "osd", NULL, (int (*)(void *, struct attr *))osd_set_attr);
+static DBusHandlerResult request_osd_set_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "osd", NULL, (int (*)(void *, struct attr *))osd_set_attr);
}
/* roadprofile */
-static DBusHandlerResult
-request_roadprofile_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "roadprofile", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))roadprofile_get_attr);
+static DBusHandlerResult request_roadprofile_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "roadprofile", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))roadprofile_get_attr);
}
-static DBusHandlerResult
-request_roadprofile_set_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "roadprofile", NULL, (int (*)(void *, struct attr *))roadprofile_set_attr);
+static DBusHandlerResult request_roadprofile_set_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "roadprofile", NULL, (int (*)(void *,
+ struct attr *))roadprofile_set_attr);
}
-static DBusHandlerResult
-request_roadprofile_attr_iter(DBusConnection *connection, DBusMessage *message)
-{
- return request_attr_iter(connection, message, "roadprofile", (struct attr_iter * (*)(void))roadprofile_attr_iter_new);
+static DBusHandlerResult request_roadprofile_attr_iter(DBusConnection *connection, DBusMessage *message) {
+ return request_attr_iter(connection, message, "roadprofile", (struct attr_iter * (*)(void))roadprofile_attr_iter_new);
}
-static DBusHandlerResult
-request_roadprofile_attr_iter_destroy(DBusConnection *connection, DBusMessage *message)
-{
- return request_attr_iter_destroy(connection, message, "roadprofile", (void (*)(struct attr_iter *))roadprofile_attr_iter_destroy);
+static DBusHandlerResult request_roadprofile_attr_iter_destroy(DBusConnection *connection, DBusMessage *message) {
+ return request_attr_iter_destroy(connection, message, "roadprofile",
+ (void (*)(struct attr_iter *))roadprofile_attr_iter_destroy);
}
/* route */
-static DBusHandlerResult
-request_route_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "route", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))route_get_attr);
+static DBusHandlerResult request_route_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "route", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))route_get_attr);
}
-static DBusHandlerResult
-request_route_set_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "route", NULL, (int (*)(void *, struct attr *))route_set_attr);
+static DBusHandlerResult request_route_set_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "route", NULL, (int (*)(void *, struct attr *))route_set_attr);
}
-static DBusHandlerResult
-request_route_add_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "route", NULL, (int (*)(void *, struct attr *))route_add_attr);
+static DBusHandlerResult request_route_add_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "route", NULL, (int (*)(void *, struct attr *))route_add_attr);
}
-static DBusHandlerResult
-request_route_remove_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "route", NULL, (int (*)(void *, struct attr *))route_remove_attr);
+static DBusHandlerResult request_route_remove_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "route", NULL, (int (*)(void *,
+ struct attr *))route_remove_attr);
}
-static DBusHandlerResult
-request_route_destroy(DBusConnection *connection, DBusMessage *message)
-{
- return request_destroy(connection, message, "route", NULL, (void (*)(void *)) route_destroy);
+static DBusHandlerResult request_route_destroy(DBusConnection *connection, DBusMessage *message) {
+ return request_destroy(connection, message, "route", NULL, (void (*)(void *)) route_destroy);
}
-static DBusHandlerResult
-request_route_dup(DBusConnection *connection, DBusMessage *message)
-{
- return request_dup(connection, message, "route", NULL, (void *(*)(void *)) route_dup);
+static DBusHandlerResult request_route_dup(DBusConnection *connection, DBusMessage *message) {
+ return request_dup(connection, message, "route", NULL, (void *(*)(void *)) route_dup);
}
/* navit */
-static DBusHandlerResult
-request_navit_draw(DBusConnection *connection, DBusMessage *message)
-{
- struct navit *navit;
+static DBusHandlerResult request_navit_draw(DBusConnection *connection, DBusMessage *message) {
+ struct navit *navit;
- navit=object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ navit=object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
- navit_draw(navit);
+ navit_draw(navit);
- return empty_reply(connection, message);
+ return empty_reply(connection, message);
}
@@ -1152,33 +1049,31 @@ request_navit_draw(DBusConnection *connection, DBusMessage *message)
* @param p Pointer where the data should get stored
* @returns Returns 1 when everything went right, otherwise 0
*/
-static int
-point_get_from_message(DBusMessage *message, DBusMessageIter *iter, struct point *p)
-{
- DBusMessageIter iter2;
+static int point_get_from_message(DBusMessage *message, DBusMessageIter *iter, struct point *p) {
+ DBusMessageIter iter2;
- dbg(lvl_debug,"%s\n", dbus_message_iter_get_signature(iter));
+ dbg(lvl_debug,"%s", dbus_message_iter_get_signature(iter));
- dbus_message_iter_recurse(iter, &iter2);
+ dbus_message_iter_recurse(iter, &iter2);
- if (dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INT32)
- return 0;
- dbus_message_iter_get_basic(&iter2, &p->x);
+ if (dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INT32)
+ return 0;
+ dbus_message_iter_get_basic(&iter2, &p->x);
- dbus_message_iter_next(&iter2);
+ dbus_message_iter_next(&iter2);
- if (dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INT32)
- return 0;
- dbus_message_iter_get_basic(&iter2, &p->y);
+ if (dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INT32)
+ return 0;
+ dbus_message_iter_get_basic(&iter2, &p->y);
- dbg(lvl_debug, " x -> %x y -> %x\n", p->x, p->y);
+ dbg(lvl_debug, " x -> %x y -> %x", p->x, p->y);
- dbus_message_iter_next(&iter2);
+ dbus_message_iter_next(&iter2);
- if (dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INVALID)
- return 0;
+ if (dbus_message_iter_get_arg_type(&iter2) != DBUS_TYPE_INVALID)
+ return 0;
- return 1;
+ return 1;
}
/**
@@ -1188,20 +1083,18 @@ point_get_from_message(DBusMessage *message, DBusMessageIter *iter, struct point
* @returns An empty reply if everything went right, otherwise DBUS_HANDLER_RESULT_NOT_YET_HANDLED
*/
-static DBusHandlerResult
-request_navit_add_message(DBusConnection *connection, DBusMessage *message)
-{
- struct navit *navit;
- char *usermessage;
+static DBusHandlerResult request_navit_add_message(DBusConnection *connection, DBusMessage *message) {
+ struct navit *navit;
+ char *usermessage;
DBusMessageIter iter;
- navit=object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ navit=object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
- dbus_message_iter_init(message, &iter);
- dbus_message_iter_get_basic(&iter, &usermessage);
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_get_basic(&iter, &usermessage);
navit_add_message(navit, usermessage);
@@ -1216,24 +1109,22 @@ request_navit_add_message(DBusConnection *connection, DBusMessage *message)
* @returns An empty reply if everything went right, otherwise DBUS_HANDLER_RESULT_NOT_YET_HANDLED
*/
-static DBusHandlerResult
-request_navit_set_center(DBusConnection *connection, DBusMessage *message)
-{
- struct pcoord pc;
- struct navit *navit;
- DBusMessageIter iter;
+static DBusHandlerResult request_navit_set_center(DBusConnection *connection, DBusMessage *message) {
+ struct pcoord pc;
+ struct navit *navit;
+ DBusMessageIter iter;
- navit=object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ navit=object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
- dbus_message_iter_init(message, &iter);
+ dbus_message_iter_init(message, &iter);
- if (!pcoord_get_from_message(message, &iter, &pc))
- return dbus_error_invalid_parameter(connection, message);
+ if (!pcoord_get_from_message(message, &iter, &pc))
+ return dbus_error_invalid_parameter(connection, message);
- navit_set_center(navit, &pc, 0);
- return empty_reply(connection, message);
+ navit_set_center(navit, &pc, 0);
+ return empty_reply(connection, message);
}
/**
@@ -1242,23 +1133,21 @@ request_navit_set_center(DBusConnection *connection, DBusMessage *message)
* @param message The DBusMessage containing the x and y value
* @returns An empty reply if everything went right, otherwise DBUS_HANDLER_RESULT_NOT_YET_HANDLED
*/
-static DBusHandlerResult
-request_navit_set_center_screen(DBusConnection *connection, DBusMessage *message)
-{
- struct point p;
- struct navit *navit;
- DBusMessageIter iter;
+static DBusHandlerResult request_navit_set_center_screen(DBusConnection *connection, DBusMessage *message) {
+ struct point p;
+ struct navit *navit;
+ DBusMessageIter iter;
- navit=object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ navit=object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
- dbus_message_iter_init(message, &iter);
+ dbus_message_iter_init(message, &iter);
- if (!point_get_from_message(message, &iter, &p))
- return dbus_error_invalid_parameter(connection, message);
- navit_set_center_screen(navit, &p, 0);
- return empty_reply(connection, message);
+ if (!point_get_from_message(message, &iter, &p))
+ return dbus_error_invalid_parameter(connection, message);
+ navit_set_center_screen(navit, &p, 0);
+ return empty_reply(connection, message);
}
/**
@@ -1267,28 +1156,26 @@ request_navit_set_center_screen(DBusConnection *connection, DBusMessage *message
* @param message The DBusMessage containing the name of the layout
* @returns An empty reply if everything went right, otherwise DBUS_HANDLER_RESULT_NOT_YET_HANDLED
*/
-static DBusHandlerResult
-request_navit_set_layout(DBusConnection *connection, DBusMessage *message)
-{
- char *new_layout_name;
- struct navit *navit;
- struct attr attr;
- struct attr_iter *iter;
-
- navit=object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
-
- if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &new_layout_name, DBUS_TYPE_INVALID))
- return dbus_error_invalid_parameter(connection, message);
-
- iter=navit_attr_iter_new();
- while(navit_get_attr(navit, attr_layout, &attr, iter)) {
- if (strcmp(attr.u.layout->name, new_layout_name) == 0) {
- navit_set_attr(navit, &attr);
- }
- }
- return empty_reply(connection, message);
+static DBusHandlerResult request_navit_set_layout(DBusConnection *connection, DBusMessage *message) {
+ char *new_layout_name;
+ struct navit *navit;
+ struct attr attr;
+ struct attr_iter *iter;
+
+ navit=object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
+
+ if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &new_layout_name, DBUS_TYPE_INVALID))
+ return dbus_error_invalid_parameter(connection, message);
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(navit, attr_layout, &attr, iter)) {
+ if (strcmp(attr.u.layout->name, new_layout_name) == 0) {
+ navit_set_attr(navit, &attr);
+ }
+ }
+ return empty_reply(connection, message);
}
/**
@@ -1297,142 +1184,322 @@ request_navit_set_layout(DBusConnection *connection, DBusMessage *message)
* @param message The DBusMessage
* @returns An empty reply if everything went right, otherwise DBUS_HANDLER_RESULT_NOT_YET_HANDLED
*/
-static DBusHandlerResult
-request_navit_quit(DBusConnection *connection, DBusMessage *message)
-{
- dbg(lvl_debug,"Got a quit request from DBUS\n");
- struct attr navit;
- navit.type=attr_navit;
- struct navit *nav;
- nav = object_get_from_message(message, "navit");
- if (! nav)
- return dbus_error_invalid_object_path(connection, message);
- navit.u.navit=nav;
- config_remove_attr(config, &navit);
-
- struct callback *callback;
- callback=callback_new_1(callback_cast(event_main_loop_quit), NULL);
- event_add_timeout(1000, 1, callback);
- return empty_reply(connection, message);
+static DBusHandlerResult request_navit_quit(DBusConnection *connection, DBusMessage *message) {
+ dbg(lvl_debug,"Got a quit request from DBUS");
+ struct attr navit;
+ navit.type=attr_navit;
+ struct navit *nav;
+ nav = object_get_from_message(message, "navit");
+ if (! nav)
+ return dbus_error_invalid_object_path(connection, message);
+ navit.u.navit=nav;
+ config_remove_attr(config, &navit);
+
+ struct callback *callback;
+ callback=callback_new_1(callback_cast(event_main_loop_quit), NULL);
+ event_add_timeout(1000, 1, callback);
+ return empty_reply(connection, message);
}
-static DBusHandlerResult
-request_navit_zoom(DBusConnection *connection, DBusMessage *message)
-{
- int factor;
- struct point p, *pp=NULL;
- struct navit *navit;
- DBusMessageIter iter;
-
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+/**
+ * @brief Exports currently active traffic distortions as a GPX file.
+ *
+ * @param connection The DBusConnection object through which a message arrived
+ * @param message The DBusMessage including the `filename` parameter
+ * @returns An empty reply if everything went right, otherwise `DBUS_HANDLER_RESULT_NOT_YET_HANDLED`
+ */
+static DBusHandlerResult request_navit_traffic_export_gpx(DBusConnection *connection, DBusMessage *message) {
+ char * filename;
+ struct navit * navit;
+ DBusMessageIter iter;
+ struct attr attr;
+ struct attr_iter * a_iter;
+ struct traffic * traffic = NULL;
+ FILE *fp;
+ struct traffic_message ** messages;
+ struct traffic_message ** curr_msg;
+ char * wpt_types[] = {"from", "at", "via", "not_via", "to"};
+ struct traffic_point * wpts[5];
+ int i;
+ struct item ** items;
+ struct item ** curr_itm;
+ int dir, lastdir = 0;
+ struct coord c, c_last;
+ struct coord_geo g;
+
+ char *header = "<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<gpx version='1.1' creator='Navit http://navit.sourceforge.net'\n"
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"
+ " xmlns:navit='http://www.navit-project.org/schema/navit'\n"
+ " xmlns='http://www.topografix.com/GPX/1/1'\n"
+ " xsi:schemaLocation='http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'>\n";
+ char *trailer = "</gpx>\n";
+
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+
+ dbus_message_iter_get_basic(&iter, &filename);
+
+ a_iter = navit_attr_iter_new();
+ if (navit_get_attr(navit, attr_traffic, &attr, a_iter))
+ traffic = (struct traffic *) attr.u.navit_object;
+ navit_attr_iter_destroy(a_iter);
+
+ if (!traffic)
+ return dbus_error_traffic_not_configured(connection, message);
+
+ dbg(lvl_debug,"Dumping traffic distortions from dbus to %s", filename);
+
+ fp = fopen(filename, "w");
+ if (!fp) {
+ return dbus_error(connection, message, DBUS_ERROR_FAILED,
+ "could not open file for writing");
+ }
- dbus_message_iter_init(message, &iter);
- dbg(lvl_debug,"%s\n", dbus_message_iter_get_signature(&iter));
+ fprintf(fp, "%s", header);
+
+ messages = traffic_get_stored_messages(traffic);
+
+ for (curr_msg = messages; *curr_msg; curr_msg++) {
+ if (!(*curr_msg)->location)
+ continue;
+ wpts[0] = (*curr_msg)->location->from;
+ wpts[1] = (*curr_msg)->location->at;
+ wpts[2] = (*curr_msg)->location->via;
+ wpts[3] = (*curr_msg)->location->not_via;
+ wpts[4] = (*curr_msg)->location->to;
+ for (i = 0; i <= 4; i++) {
+ if (!wpts[i])
+ continue;
+ fprintf(fp, "<wpt lon='%4.16f' lat='%4.16f'><type>%s</type><name>%s</name></wpt>\n",
+ wpts[i]->coord.lng, wpts[i]->coord.lat, wpt_types[i], (*curr_msg)->id);
+ }
+ }
- dbus_message_iter_get_basic(&iter, &factor);
+ for (curr_msg = messages; *curr_msg; curr_msg++) {
+ items = traffic_message_get_items(*curr_msg);
+ for (curr_itm = items; *curr_itm; curr_itm++) {
+ /*
+ * Don’t blindly copy this code unless you know what you are doing.
+ * It is based on various assumptions which hold true for traffic map items, but not necessarily for items
+ * obtained from other maps.
+ */
+ item_coord_rewind(*curr_itm);
+ item_coord_get(*curr_itm, &c, 1);
+ item_attr_rewind(*curr_itm);
+ if (item_attr_get(*curr_itm, attr_flags, &attr)) {
+ if (attr.u.num & AF_ONEWAY)
+ dir = 1;
+ else if (attr.u.num & AF_ONEWAYREV)
+ dir = -1;
+ else
+ dir = 0;
+ } else
+ dir = 0;
+ if ((curr_itm == items) || (c.x != c_last.x) || (c.y != c_last.y) || lastdir != dir) {
+ /*
+ * Start a new route for the first item, or if the last point of the previous item does not coincide
+ * with the first point of the current one. This includes closing the previous route (if any) and
+ * adding the first point.
+ */
+ if (curr_itm != items)
+ fprintf(fp, "</rte>\n");
+ fprintf(fp, "<rte><type>%s</type><name>%s</name>\n",
+ dir ? (dir > 0 ? "forward" : "backward") : "bidirectional", (*curr_msg)->id);
+ transform_to_geo(projection_mg, &c, &g);
+ fprintf(fp,"<rtept lon='%4.16f' lat='%4.16f'></rtept>\n", g.lng, g.lat);
+ }
+ while (item_coord_get(*curr_itm, &c, 1)) {
+ transform_to_geo(projection_mg, &c, &g);
+ fprintf(fp,"<rtept lon='%4.16f' lat='%4.16f'></rtept>\n", g.lng, g.lat);
+ }
+ c_last.x = c.x;
+ c_last.y = c.y;
+ lastdir = dir;
+ }
+ if (curr_itm != items)
+ fprintf(fp, "</rte>\n");
+ g_free(items);
+ }
- if (dbus_message_iter_has_next(&iter))
- {
- dbus_message_iter_next(&iter);
- if (!point_get_from_message(message, &iter, &p))
- return dbus_error_invalid_parameter(connection, message);
- pp=&p;
- }
+ fprintf(fp,"%s",trailer);
- if (factor > 1)
- navit_zoom_in(navit, factor, pp);
- else if (factor < -1)
- navit_zoom_out(navit, 0-factor, pp);
+ fclose(fp);
- return empty_reply(connection, message);
+ g_free(messages);
+ return empty_reply(connection, message);
}
/**
- * @brief Exports the current route as a GPX file
+ * @brief Injects a traffic feed.
+ *
* @param connection The DBusConnection object through which a message arrived
- * @param message The DBusMessage including the 'filename' parameter
- * @returns An empty reply if everything went right, otherwise DBUS_HANDLER_RESULT_NOT_YET_HANDLED
+ * @param message The DBusMessage including the `filename` parameter
+ * @returns An empty reply if everything went right, otherwise `DBUS_HANDLER_RESULT_NOT_YET_HANDLED`
*/
-static DBusHandlerResult
-request_navit_zoom_to_route(DBusConnection *connection, DBusMessage *message)
-{
- struct navit *navit;
- DBusMessageIter iter;
+static DBusHandlerResult request_navit_traffic_inject(DBusConnection *connection, DBusMessage *message) {
+ char * filename;
+ struct navit *navit;
+ DBusMessageIter iter;
+ struct attr * attr;
+ struct attr_iter * a_iter;
+ struct traffic * traffic = NULL;
+ struct traffic_message ** messages;
+
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ dbus_message_iter_get_basic(&iter, &filename);
- dbus_message_iter_init(message, &iter);
- dbg(lvl_debug,"%s\n", dbus_message_iter_get_signature(&iter));
+ attr = g_new0(struct attr, 1);
+ a_iter = navit_attr_iter_new();
+ if (navit_get_attr(navit, attr_traffic, attr, a_iter))
+ traffic = (struct traffic *) attr->u.navit_object;
+ navit_attr_iter_destroy(a_iter);
+ g_free(attr);
- navit_zoom_to_route(navit,0);
+ if (!traffic)
+ return dbus_error_traffic_not_configured(connection, message);
- return empty_reply(connection, message);
+ dbg(lvl_debug, "Processing traffic feed from file %s", filename);
+ messages = traffic_get_messages_from_xml_file(traffic, filename);
+ if (messages) {
+ dbg(lvl_debug, "got messages from file %s, processing", filename);
+ traffic_process_messages(traffic, messages);
+ g_free(messages);
+ }
+
+ return empty_reply(connection, message);
}
-static DBusHandlerResult
-request_navit_route_export_gpx(DBusConnection *connection, DBusMessage *message)
-{
- char * filename;
- struct navit *navit;
- DBusMessageIter iter;
+static DBusHandlerResult request_navit_zoom(DBusConnection *connection, DBusMessage *message) {
+ int factor;
+ struct point p, *pp=NULL;
+ struct navit *navit;
+ DBusMessageIter iter;
+
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+ dbg(lvl_debug,"%s", dbus_message_iter_get_signature(&iter));
+
+ dbus_message_iter_get_basic(&iter, &factor);
+
+ if (dbus_message_iter_has_next(&iter)) {
+ dbus_message_iter_next(&iter);
+ if (!point_get_from_message(message, &iter, &p))
+ return dbus_error_invalid_parameter(connection, message);
+ pp=&p;
+ }
+
+ if (factor > 1)
+ navit_zoom_in(navit, factor, pp);
+ else if (factor < -1)
+ navit_zoom_out(navit, 0-factor, pp);
+
+ return empty_reply(connection, message);
+
+}
+
+static DBusHandlerResult request_navit_zoom_to_route(DBusConnection *connection, DBusMessage *message) {
+ struct navit *navit;
+ DBusMessageIter iter;
+
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+ dbg(lvl_debug,"%s", dbus_message_iter_get_signature(&iter));
+
+ navit_zoom_to_route(navit,0);
+
+ return empty_reply(connection, message);
+
+}
+
+/**
+ * @brief Exports the current route as a GPX file.
+ *
+ * @param connection The DBusConnection object through which a message arrived
+ * @param message The DBusMessage including the `filename` parameter
+ * @returns An empty reply if everything went right, otherwise `DBUS_HANDLER_RESULT_NOT_YET_HANDLED`
+ */
+static DBusHandlerResult request_navit_route_export_gpx(DBusConnection *connection, DBusMessage *message) {
+ char * filename;
+ struct navit *navit;
+ DBusMessageIter iter;
+
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ dbus_message_iter_init(message, &iter);
- dbus_message_iter_init(message, &iter);
+ dbus_message_iter_get_basic(&iter, &filename);
- dbus_message_iter_get_basic(&iter, &filename);
+ struct navigation *nav = navit_get_navigation(navit);
+ if(!nav) {
+ return dbus_error_navigation_not_configured(connection, message);
+ }
- struct navigation *nav = navit_get_navigation(navit);
- if(!nav) {
- return dbus_error_navigation_not_configured(connection, message);
+ dbg(lvl_debug,"Dumping route from dbus to %s", filename);
+
+ struct map * map=NULL;
+ struct map_rect * mr=NULL;
+ struct item *item = NULL;
+ struct attr attr;
+ struct coord c;
+ struct coord_geo g;
+
+ char *header = "<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<gpx version='1.1' creator='Navit http://navit.sourceforge.net'\n"
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"
+ " xmlns:navit='http://www.navit-project.org/schema/navit'\n"
+ " xmlns='http://www.topografix.com/GPX/1/1'\n"
+ " xsi:schemaLocation='http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'>\n"
+ "<rte>\n";
+ char *trailer = "</rte>\n</gpx>\n";
+
+ map = navigation_get_map(nav);
+ if(map)
+ mr = map_rect_new(map,NULL);
+
+ FILE *fp;
+ fp = fopen(filename,"w");
+ if (!fp) {
+ map_rect_destroy(mr);
+ return dbus_error(connection, message, DBUS_ERROR_FAILED,
+ "could not open file for writing");
+ }
+
+ fprintf(fp, "%s", header);
+
+ while((item = map_rect_get_item(mr))) {
+ if(item_attr_get(item,attr_navigation_long,&attr)) {
+ item_coord_get(item, &c, 1);
+ transform_to_geo (projection_mg, &c, &g);
+ fprintf(fp,"<rtept lon='%4.16f' lat='%4.16f'><type>%s</type><name>%s</name></rtept>\n",g.lng, g.lat,
+ item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str));
}
+ }
+ fprintf(fp,"%s",trailer);
- dbg(lvl_debug,"Dumping route from dbus to %s\n", filename);
-
- struct map * map=NULL;
- struct map_rect * mr=NULL;
- struct item *item = NULL;
- struct attr attr;
- struct coord c;
- struct coord_geo g;
-
- char *header = "<?xml version='1.0' encoding='UTF-8'?>\n"
- "<gpx version='1.1' creator='Navit http://navit.sourceforge.net'\n"
- " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"
- " xmlns:navit='http://www.navit-project.org/schema/navit'\n"
- " xmlns='http://www.topografix.com/GPX/1/1'\n"
- " xsi:schemaLocation='http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'>\n"
- "<rte>\n";
- char *trailer = "</rte>\n</gpx>\n";
-
- map = navigation_get_map(nav);
- if(map)
- mr = map_rect_new(map,NULL);
-
- FILE *fp;
- fp = fopen(filename,"w");
- fprintf(fp, "%s", header);
-
- while((item = map_rect_get_item(mr))) {
- if(item_attr_get(item,attr_navigation_long,&attr)) {
- item_coord_get(item, &c, 1);
- transform_to_geo (projection_mg, &c, &g);
- fprintf(fp,"<rtept lon='%4.16f' lat='%4.16f'><type>%s</type><name>%s</name></rtept>\n",g.lng, g.lat, item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str));
- }
- }
- fprintf(fp,"%s",trailer);
-
- fclose(fp);
-
- return empty_reply(connection, message);
+ fclose(fp);
+
+ map_rect_destroy(mr);
+
+ return empty_reply(connection, message);
}
/**
@@ -1441,627 +1508,589 @@ request_navit_route_export_gpx(DBusConnection *connection, DBusMessage *message)
* @param message The DBusMessage including the 'filename' parameter
* @returns An empty reply if everything went right, otherwise DBUS_HANDLER_RESULT_NOT_YET_HANDLED
*/
-static DBusHandlerResult
-request_navit_route_export_geojson(DBusConnection *connection, DBusMessage *message)
-{
- char * filename;
- struct point p;
- struct navit *navit;
- DBusMessageIter iter;
-
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
-
- dbus_message_iter_init(message, &iter);
-
- dbus_message_iter_get_basic(&iter, &filename);
-
- if (dbus_message_iter_has_next(&iter))
- {
- dbus_message_iter_next(&iter);
- if (!point_get_from_message(message, &iter, &p))
- return dbus_error_invalid_parameter(connection, message);
- }
+static DBusHandlerResult request_navit_route_export_geojson(DBusConnection *connection, DBusMessage *message) {
+ char * filename;
+ struct point p;
+ struct navit *navit;
+ DBusMessageIter iter;
- dbg(lvl_debug,"Dumping route from dbus to %s\n", filename);
-
- struct map * map=NULL;
- struct navigation * nav = NULL;
- struct map_rect * mr=NULL;
- struct item *item = NULL;
- struct attr attr;
- struct coord c;
- struct coord_geo g;
-
- char *header = "{\n"
-" \"type\": \"FeatureCollection\",\n"
-" \"features\": [\n"
-" {\n"
-" \"type\": \"Feature\",\n"
-" \"properties\": {\n"
-" \"name\": \"Navit route export\",\n"
-" \"stroke\": \"red\",\n"
-" \"stroke-width\": \"5px\"\n"
-" },\n"
-" \"geometry\": {\n"
-" \"type\": \"LineString\",\n"
-" \"coordinates\": [\n";
-
- nav = navit_get_navigation(navit);
- if(!nav) {
- return dbus_error_navigation_not_configured(connection, message);
- }
- map = navigation_get_map(nav);
- if(map)
- mr = map_rect_new(map,NULL);
-
- FILE *fp;
- fp = fopen(filename,"w");
- fprintf(fp, "%s", header);
- int is_first=1;
- char * instructions;
- instructions=g_strdup("");
- while((item = map_rect_get_item(mr))) {
- if(item_attr_get(item,attr_navigation_long,&attr)) {
- item_coord_get(item, &c, 1);
- transform_to_geo (projection_mg, &c, &g);
- if(!is_first){
- fprintf(fp,",\n");
- instructions=g_strconcat_printf(instructions,",\n");
- }
- fprintf(fp,"[ %4.16f, %4.16f ]",g.lng, g.lat);
- instructions=g_strconcat_printf(instructions, g_strdup_printf(" { \"type\": \"Feature\", \"properties\": { \"Instruction\": \"%s\", \"name\": \"\" }, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ %4.16f, %4.16f ] } }", map_convert_string_tmp(item->map,attr.u.str), g.lng, g.lat));
- /* fprintf(fp,"<rtept lon='%4.16f' lat='%4.16f'><type>%s</type><name>%s</name></rtept>\n",g.lng, g.lat, item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str)); */
- is_first=0;
- }
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+
+ dbus_message_iter_get_basic(&iter, &filename);
+
+ if (dbus_message_iter_has_next(&iter)) {
+ dbus_message_iter_next(&iter);
+ if (!point_get_from_message(message, &iter, &p))
+ return dbus_error_invalid_parameter(connection, message);
+ }
+
+ dbg(lvl_debug,"Dumping route from dbus to %s", filename);
+
+ struct map * map=NULL;
+ struct navigation * nav = NULL;
+ struct map_rect * mr=NULL;
+ struct item *item = NULL;
+ struct attr attr;
+ struct coord c;
+ struct coord_geo g;
+
+ char *header = "{\n"
+ " \"type\": \"FeatureCollection\",\n"
+ " \"features\": [\n"
+ " {\n"
+ " \"type\": \"Feature\",\n"
+ " \"properties\": {\n"
+ " \"name\": \"Navit route export\",\n"
+ " \"stroke\": \"red\",\n"
+ " \"stroke-width\": \"5px\"\n"
+ " },\n"
+ " \"geometry\": {\n"
+ " \"type\": \"LineString\",\n"
+ " \"coordinates\": [\n";
+
+ nav = navit_get_navigation(navit);
+ if(!nav) {
+ return dbus_error_navigation_not_configured(connection, message);
+ }
+ map = navigation_get_map(nav);
+ if(map)
+ mr = map_rect_new(map,NULL);
+
+ FILE *fp;
+ fp = fopen(filename,"w");
+ if (!fp) {
+ return dbus_error(connection, message, DBUS_ERROR_FAILED,
+ "could not open file for writing");
+ }
+
+ fprintf(fp, "%s", header);
+ int is_first=1;
+ char * instructions;
+ instructions=g_strdup("");
+ while((item = map_rect_get_item(mr))) {
+ if(item_attr_get(item,attr_navigation_long,&attr)) {
+ item_coord_get(item, &c, 1);
+ transform_to_geo (projection_mg, &c, &g);
+ if(!is_first) {
+ fprintf(fp,",\n");
+ instructions=g_strconcat_printf(instructions,",\n");
+ }
+ fprintf(fp,"[ %4.16f, %4.16f ]",g.lng, g.lat);
+ instructions=g_strconcat_printf(instructions,
+ g_strdup_printf(" { \"type\": \"Feature\", \"properties\": { \"Instruction\": \"%s\", \"name\": \"\" }, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ %4.16f, %4.16f ] } }",
+ map_convert_string_tmp(item->map,attr.u.str), g.lng, g.lat));
+ /* fprintf(fp,"<rtept lon='%4.16f' lat='%4.16f'><type>%s</type><name>%s</name></rtept>\n",g.lng, g.lat, item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str)); */
+ is_first=0;
}
+ }
- fprintf(fp," ]}\n },\n%s ]\n }\n",instructions);
+ fprintf(fp," ]}\n },\n%s ]\n }\n",instructions);
- fclose(fp);
+ fclose(fp);
- return empty_reply(connection, message);
+ return empty_reply(connection, message);
}
-static DBusHandlerResult
-request_navit_block(DBusConnection *connection, DBusMessage *message)
-{
- int mode;
- struct navit *navit;
- DBusMessageIter iter;
+static DBusHandlerResult request_navit_block(DBusConnection *connection, DBusMessage *message) {
+ int mode;
+ struct navit *navit;
+ DBusMessageIter iter;
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
- dbus_message_iter_init(message, &iter);
+ dbus_message_iter_init(message, &iter);
- dbus_message_iter_get_basic(&iter, &mode);
+ dbus_message_iter_get_basic(&iter, &mode);
- navit_block(navit, mode);
- return empty_reply(connection, message);
+ navit_block(navit, mode);
+ return empty_reply(connection, message);
}
-static DBusHandlerResult
-request_navit_resize(DBusConnection *connection, DBusMessage *message)
-{
- struct navit *navit;
- int w, h;
- DBusMessageIter iter;
+static DBusHandlerResult request_navit_resize(DBusConnection *connection, DBusMessage *message) {
+ struct navit *navit;
+ int w, h;
+ DBusMessageIter iter;
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
- dbus_message_iter_init(message, &iter);
- dbg(lvl_debug,"%s\n", dbus_message_iter_get_signature(&iter));
+ dbus_message_iter_init(message, &iter);
+ dbg(lvl_debug,"%s", dbus_message_iter_get_signature(&iter));
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
- return dbus_error_invalid_parameter(connection, message);
- dbus_message_iter_get_basic(&iter, &w);
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
+ return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_get_basic(&iter, &w);
- dbus_message_iter_next(&iter);
+ dbus_message_iter_next(&iter);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
- return dbus_error_invalid_parameter(connection, message);
- dbus_message_iter_get_basic(&iter, &h);
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
+ return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_get_basic(&iter, &h);
- dbg(lvl_debug, " w -> %i h -> %i\n", w, h);
+ dbg(lvl_debug, " w -> %i h -> %i", w, h);
- navit_handle_resize(navit, w, h);
+ navit_handle_resize(navit, w, h);
- return empty_reply(connection, message);
+ return empty_reply(connection, message);
}
-static DBusHandlerResult
-request_navit_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "navit", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))navit_get_attr);
+static DBusHandlerResult request_navit_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "navit", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))navit_get_attr);
}
-static DBusHandlerResult
-request_navit_attr_iter(DBusConnection *connection, DBusMessage *message)
-{
- DBusMessage *reply;
- struct attr_iter *attr_iter=navit_attr_iter_new();
- char *opath=object_new("navit_attr_iter",attr_iter);
- reply = dbus_message_new_method_return(message);
- dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
+static DBusHandlerResult request_navit_attr_iter(DBusConnection *connection, DBusMessage *message) {
+ DBusMessage *reply;
+ struct attr_iter *attr_iter=navit_attr_iter_new();
+ char *opath=object_new("navit_attr_iter",attr_iter);
+ reply = dbus_message_new_method_return(message);
+ dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
+ return DBUS_HANDLER_RESULT_HANDLED;
}
-static DBusHandlerResult
-request_navit_attr_iter_destroy(DBusConnection *connection, DBusMessage *message)
-{
- struct attr_iter *attr_iter;
- DBusMessageIter iter;
+static DBusHandlerResult request_navit_attr_iter_destroy(DBusConnection *connection, DBusMessage *message) {
+ struct attr_iter *attr_iter;
+ DBusMessageIter iter;
- dbus_message_iter_init(message, &iter);
- attr_iter=object_get_from_message_arg(&iter, "navit_attr_iter");
- if (! attr_iter)
- return dbus_error_invalid_object_path_parameter(connection, message);
- navit_attr_iter_destroy(attr_iter);
+ dbus_message_iter_init(message, &iter);
+ attr_iter=object_get_from_message_arg(&iter, "navit_attr_iter");
+ if (! attr_iter)
+ return dbus_error_invalid_object_path_parameter(connection, message);
+ navit_attr_iter_destroy(attr_iter);
- return empty_reply(connection, message);
+ return empty_reply(connection, message);
}
-static DBusHandlerResult
-request_navit_set_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "navit", NULL, (int (*)(void *, struct attr *))navit_set_attr);
+static DBusHandlerResult request_navit_set_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "navit", NULL, (int (*)(void *, struct attr *))navit_set_attr);
}
-static DBusHandlerResult
-request_navit_add_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "navit", NULL, (int (*)(void *, struct attr *))navit_add_attr);
+static DBusHandlerResult request_navit_add_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "navit", NULL, (int (*)(void *, struct attr *))navit_add_attr);
}
-static DBusHandlerResult
-request_navit_remove_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "navit", NULL, (int (*)(void *, struct attr *))navit_remove_attr);
+static DBusHandlerResult request_navit_remove_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "navit", NULL, (int (*)(void *,
+ struct attr *))navit_remove_attr);
}
-static DBusHandlerResult
-request_navit_set_position(DBusConnection *connection, DBusMessage *message)
-{
- struct pcoord pc;
- struct navit *navit;
- DBusMessageIter iter;
+static DBusHandlerResult request_navit_set_position(DBusConnection *connection, DBusMessage *message) {
+ struct pcoord pc;
+ struct navit *navit;
+ DBusMessageIter iter;
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
- dbus_message_iter_init(message, &iter);
- if (!pcoord_get_from_message(message, &iter, &pc))
- return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_init(message, &iter);
+ if (!pcoord_get_from_message(message, &iter, &pc))
+ return dbus_error_invalid_parameter(connection, message);
- navit_set_position(navit, &pc);
- return empty_reply(connection, message);
+ navit_set_position(navit, &pc);
+ return empty_reply(connection, message);
}
-static DBusHandlerResult
-request_navit_set_destination(DBusConnection *connection, DBusMessage *message)
-{
- struct pcoord pc;
- struct navit *navit;
- DBusMessageIter iter;
- char *description;
+static DBusHandlerResult request_navit_set_destination(DBusConnection *connection, DBusMessage *message) {
+ struct pcoord pc;
+ struct navit *navit;
+ DBusMessageIter iter;
+ char *description;
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
- dbus_message_iter_init(message, &iter);
- if (!pcoord_get_from_message(message, &iter, &pc))
- return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_init(message, &iter);
+ if (!pcoord_get_from_message(message, &iter, &pc))
+ return dbus_error_invalid_parameter(connection, message);
- dbus_message_iter_next(&iter);
- dbus_message_iter_get_basic(&iter, &description);
- dbg(lvl_debug, " destination -> %s\n", description);
+ dbus_message_iter_next(&iter);
+ dbus_message_iter_get_basic(&iter, &description);
+ dbg(lvl_debug, " destination -> %s", description);
- navit_set_destination(navit, &pc, description, 1);
- return empty_reply(connection, message);
+ navit_set_destination(navit, &pc, description, 1);
+ return empty_reply(connection, message);
}
-static DBusHandlerResult
-request_navit_clear_destination(DBusConnection *connection, DBusMessage *message)
-{
- struct navit *navit;
+static DBusHandlerResult request_navit_clear_destination(DBusConnection *connection, DBusMessage *message) {
+ struct navit *navit;
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
- navit_set_destination(navit, NULL, NULL, 0);
- return empty_reply(connection, message);
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
+ navit_set_destination(navit, NULL, NULL, 0);
+ return empty_reply(connection, message);
}
-static DBusHandlerResult
-request_navit_evaluate(DBusConnection *connection, DBusMessage *message)
-{
- struct navit *navit;
- char *command;
- char *result;
- struct attr attr;
- DBusMessage *reply;
- int error;
+static DBusHandlerResult request_navit_evaluate(DBusConnection *connection, DBusMessage *message) {
+ struct navit *navit;
+ char *command;
+ char *result;
+ struct attr attr;
+ DBusMessage *reply;
+ int error;
+
+ navit = object_get_from_message(message, "navit");
+ if (! navit)
+ return dbus_error_invalid_object_path(connection, message);
+
+ attr.type=attr_navit;
+ attr.u.navit=navit;
+ if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &command, DBUS_TYPE_INVALID))
+ return dbus_error_invalid_parameter(connection, message);
+ result=command_evaluate_to_string(&attr, command, &error);
+ reply = dbus_message_new_method_return(message);
+ if (error)
+ dbus_message_append_args(reply, DBUS_TYPE_INT32, &error, DBUS_TYPE_INVALID);
+ else if (result)
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &result, DBUS_TYPE_INVALID);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
- navit = object_get_from_message(message, "navit");
- if (! navit)
- return dbus_error_invalid_object_path(connection, message);
+/* search_list */
- attr.type=attr_navit;
- attr.u.navit=navit;
- if (!dbus_message_get_args(message, NULL, DBUS_TYPE_STRING, &command, DBUS_TYPE_INVALID))
- return dbus_error_invalid_parameter(connection, message);
- result=command_evaluate_to_string(&attr, command, &error);
- reply = dbus_message_new_method_return(message);
- if (error)
- dbus_message_append_args(reply, DBUS_TYPE_INT32, &error, DBUS_TYPE_INVALID);
- else if (result)
- dbus_message_append_args(reply, DBUS_TYPE_STRING, &result, DBUS_TYPE_INVALID);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
+static DBusHandlerResult request_search_list_destroy(DBusConnection *connection, DBusMessage *message) {
+ return request_destroy(connection, message, "search_list", NULL, (void (*)(void *)) search_list_destroy);
+}
+
+static void request_search_list_common(struct search_list_common *slc, DBusMessageIter *iter4) {
+ if (slc->postal)
+ encode_dict_string_variant_string(iter4, "postal", slc->postal);
+ if (slc->postal_mask)
+ encode_dict_string_variant_string(iter4, "postal_mask", slc->postal_mask);
+}
+
+static DBusHandlerResult request_search_list_get_result(DBusConnection *connection, DBusMessage *message) {
+ struct search_list *search_list;
+ struct search_list_result *result;
+ DBusMessage *reply;
+ DBusMessageIter iter,iter2,iter3,iter4;
+ char *country="country";
+ char *town="town";
+ char *street="street";
+ char *house_number="housenumber";
+
+ search_list = object_get_from_message(message, "search_list");
+ if (! search_list)
+ return dbus_error_invalid_object_path(connection, message);
+ result=search_list_get_result(search_list);
+ if (!result)
+ return dbus_error_no_data_available(connection, message);
+ reply = dbus_message_new_method_return(message);
+ dbus_message_iter_init_append(reply, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &result->id);
+ pcoord_encode(&iter, result->c);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sa{sv}}", &iter2);
+ if (result->country && (result->country->car || result->country->iso2 || result->country->iso3
+ || result->country->name)) {
+ dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
+ dbus_message_iter_append_basic(&iter3, DBUS_TYPE_STRING, &country);
+ dbus_message_iter_open_container(&iter3, DBUS_TYPE_ARRAY, "{sv}", &iter4);
+ if (result->country->car)
+ encode_dict_string_variant_string(&iter4, "car", result->country->car);
+ if (result->country->iso2)
+ encode_dict_string_variant_string(&iter4, "iso2", result->country->iso2);
+ if (result->country->iso3)
+ encode_dict_string_variant_string(&iter4, "iso3", result->country->iso3);
+ if (result->country->name)
+ encode_dict_string_variant_string(&iter4, "name", result->country->name);
+ dbus_message_iter_close_container(&iter3, &iter4);
+ dbus_message_iter_close_container(&iter2, &iter3);
+ }
+ if (result->town && (result->town->common.district_name || result->town->common.town_name)) {
+ dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
+ dbus_message_iter_append_basic(&iter3, DBUS_TYPE_STRING, &town);
+ dbus_message_iter_open_container(&iter3, DBUS_TYPE_ARRAY, "{sv}", &iter4);
+ request_search_list_common(&result->town->common,&iter4);
+ if (result->town->common.district_name)
+ encode_dict_string_variant_string(&iter4, "district", result->town->common.district_name);
+ if (result->town->common.town_name)
+ encode_dict_string_variant_string(&iter4, "name", result->town->common.town_name);
+ dbus_message_iter_close_container(&iter3, &iter4);
+ dbus_message_iter_close_container(&iter2, &iter3);
+ }
+ if (result->street && result->street->name) {
+ dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
+ dbus_message_iter_append_basic(&iter3, DBUS_TYPE_STRING, &street);
+ dbus_message_iter_open_container(&iter3, DBUS_TYPE_ARRAY, "{sv}", &iter4);
+ request_search_list_common(&result->street->common,&iter4);
+ if (result->street->name)
+ encode_dict_string_variant_string(&iter4, "name", result->street->name);
+ dbus_message_iter_close_container(&iter3, &iter4);
+ dbus_message_iter_close_container(&iter2, &iter3);
+ }
+ if (result->house_number && result->house_number->house_number) {
+ dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
+ dbus_message_iter_append_basic(&iter3, DBUS_TYPE_STRING, &house_number);
+ dbus_message_iter_open_container(&iter3, DBUS_TYPE_ARRAY, "{sv}", &iter4);
+ request_search_list_common(&result->house_number->common,&iter4);
+ encode_dict_string_variant_string(&iter4, "name", result->house_number->house_number);
+ dbus_message_iter_close_container(&iter3, &iter4);
+ dbus_message_iter_close_container(&iter2, &iter3);
+ }
+ dbus_message_iter_close_container(&iter, &iter2);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+ return DBUS_HANDLER_RESULT_HANDLED;
}
-/* search_list */
+static DBusHandlerResult request_search_list_new(DBusConnection *connection, DBusMessage *message) {
+ DBusMessageIter iter;
+ DBusMessage *reply;
+ struct mapset *mapset;
+ struct search_list *search_list;
+ char *opath;
+
+ dbus_message_iter_init(message, &iter);
+ mapset=object_get_from_message_arg(&iter, "mapset");
+ if (! mapset)
+ return dbus_error_invalid_object_path_parameter(connection, message);
+ search_list=search_list_new(mapset);
+ opath=object_new("search_list", search_list);
+ reply = dbus_message_new_method_return(message);
+ dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static DBusHandlerResult request_search_list_search(DBusConnection *connection, DBusMessage *message) {
+ DBusMessageIter iter;
+ struct search_list *search_list;
+ struct attr attr;
+ int partial;
+
+ search_list = object_get_from_message(message, "search_list");
+ if (! search_list)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+ if (!decode_attr_from_iter(&iter, &attr))
+ return dbus_error_invalid_parameter(connection, message);
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
+ return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_get_basic(&iter, &partial);
+ search_list_search(search_list, &attr, partial);
+ return empty_reply(connection, message);
+}
-static DBusHandlerResult
-request_search_list_destroy(DBusConnection *connection, DBusMessage *message)
-{
- return request_destroy(connection, message, "search_list", NULL, (void (*)(void *)) search_list_destroy);
-}
-
-static void
-request_search_list_common(struct search_list_common *slc, DBusMessageIter *iter4)
-{
- if (slc->postal)
- encode_dict_string_variant_string(iter4, "postal", slc->postal);
- if (slc->postal_mask)
- encode_dict_string_variant_string(iter4, "postal_mask", slc->postal_mask);
-}
-
-static DBusHandlerResult
-request_search_list_get_result(DBusConnection *connection, DBusMessage *message)
-{
- struct search_list *search_list;
- struct search_list_result *result;
- DBusMessage *reply;
- DBusMessageIter iter,iter2,iter3,iter4;
- char *country="country";
- char *town="town";
- char *street="street";
- char *house_number="housenumber";
-
- search_list = object_get_from_message(message, "search_list");
- if (! search_list)
- return dbus_error_invalid_object_path(connection, message);
- result=search_list_get_result(search_list);
- if (!result)
- return dbus_error_no_data_available(connection, message);
- reply = dbus_message_new_method_return(message);
- dbus_message_iter_init_append(reply, &iter);
- dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &result->id);
- pcoord_encode(&iter, result->c);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sa{sv}}", &iter2);
- if (result->country && (result->country->car || result->country->iso2 || result->country->iso3 || result->country->name)) {
- dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
- dbus_message_iter_append_basic(&iter3, DBUS_TYPE_STRING, &country);
- dbus_message_iter_open_container(&iter3, DBUS_TYPE_ARRAY, "{sv}", &iter4);
- if (result->country->car)
- encode_dict_string_variant_string(&iter4, "car", result->country->car);
- if (result->country->iso2)
- encode_dict_string_variant_string(&iter4, "iso2", result->country->iso2);
- if (result->country->iso3)
- encode_dict_string_variant_string(&iter4, "iso3", result->country->iso3);
- if (result->country->name)
- encode_dict_string_variant_string(&iter4, "name", result->country->name);
- dbus_message_iter_close_container(&iter3, &iter4);
- dbus_message_iter_close_container(&iter2, &iter3);
- }
- if (result->town && (result->town->common.district_name || result->town->common.town_name)) {
- dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
- dbus_message_iter_append_basic(&iter3, DBUS_TYPE_STRING, &town);
- dbus_message_iter_open_container(&iter3, DBUS_TYPE_ARRAY, "{sv}", &iter4);
- request_search_list_common(&result->town->common,&iter4);
- if (result->town->common.district_name)
- encode_dict_string_variant_string(&iter4, "district", result->town->common.district_name);
- if (result->town->common.town_name)
- encode_dict_string_variant_string(&iter4, "name", result->town->common.town_name);
- dbus_message_iter_close_container(&iter3, &iter4);
- dbus_message_iter_close_container(&iter2, &iter3);
- }
- if (result->street && result->street->name) {
- dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
- dbus_message_iter_append_basic(&iter3, DBUS_TYPE_STRING, &street);
- dbus_message_iter_open_container(&iter3, DBUS_TYPE_ARRAY, "{sv}", &iter4);
- request_search_list_common(&result->street->common,&iter4);
- if (result->street->name)
- encode_dict_string_variant_string(&iter4, "name", result->street->name);
- dbus_message_iter_close_container(&iter3, &iter4);
- dbus_message_iter_close_container(&iter2, &iter3);
- }
- if (result->house_number && result->house_number->house_number) {
- dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
- dbus_message_iter_append_basic(&iter3, DBUS_TYPE_STRING, &house_number);
- dbus_message_iter_open_container(&iter3, DBUS_TYPE_ARRAY, "{sv}", &iter4);
- request_search_list_common(&result->house_number->common,&iter4);
- encode_dict_string_variant_string(&iter4, "name", result->house_number->house_number);
- dbus_message_iter_close_container(&iter3, &iter4);
- dbus_message_iter_close_container(&iter2, &iter3);
- }
- dbus_message_iter_close_container(&iter, &iter2);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static DBusHandlerResult
-request_search_list_new(DBusConnection *connection, DBusMessage *message)
-{
- DBusMessageIter iter;
- DBusMessage *reply;
- struct mapset *mapset;
- struct search_list *search_list;
- char *opath;
-
- dbus_message_iter_init(message, &iter);
- mapset=object_get_from_message_arg(&iter, "mapset");
- if (! mapset)
- return dbus_error_invalid_object_path_parameter(connection, message);
- search_list=search_list_new(mapset);
- opath=object_new("search_list", search_list);
- reply = dbus_message_new_method_return(message);
- dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-static DBusHandlerResult
-request_search_list_search(DBusConnection *connection, DBusMessage *message)
-{
- DBusMessageIter iter;
- struct search_list *search_list;
- struct attr attr;
- int partial;
-
- search_list = object_get_from_message(message, "search_list");
- if (! search_list)
- return dbus_error_invalid_object_path(connection, message);
-
- dbus_message_iter_init(message, &iter);
- if (!decode_attr_from_iter(&iter, &attr))
- return dbus_error_invalid_parameter(connection, message);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
- return dbus_error_invalid_parameter(connection, message);
- dbus_message_iter_get_basic(&iter, &partial);
- search_list_search(search_list, &attr, partial);
- return empty_reply(connection, message);
-}
-
-static DBusHandlerResult
-request_search_list_select(DBusConnection *connection, DBusMessage *message)
-{
- DBusMessageIter iter;
- struct search_list *search_list;
- int id, mode;
- enum attr_type attr_type;
-
- search_list = object_get_from_message(message, "search_list");
- if (! search_list)
- return dbus_error_invalid_object_path(connection, message);
-
- dbus_message_iter_init(message, &iter);
- attr_type=decode_attr_type_from_iter(&iter);
- if (attr_type == attr_none)
- return dbus_error_invalid_parameter(connection, message);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
- return dbus_error_invalid_parameter(connection, message);
- dbus_message_iter_get_basic(&iter, &id);
- if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
- return dbus_error_invalid_parameter(connection, message);
- dbus_message_iter_get_basic(&iter, &mode);
- search_list_select(search_list, attr_type, id, mode);
- return empty_reply(connection, message);
+static DBusHandlerResult request_search_list_select(DBusConnection *connection, DBusMessage *message) {
+ DBusMessageIter iter;
+ struct search_list *search_list;
+ int id, mode;
+ enum attr_type attr_type;
+
+ search_list = object_get_from_message(message, "search_list");
+ if (! search_list)
+ return dbus_error_invalid_object_path(connection, message);
+
+ dbus_message_iter_init(message, &iter);
+ attr_type=decode_attr_type_from_iter(&iter);
+ if (attr_type == attr_none)
+ return dbus_error_invalid_parameter(connection, message);
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
+ return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_get_basic(&iter, &id);
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_INT32)
+ return dbus_error_invalid_parameter(connection, message);
+ dbus_message_iter_get_basic(&iter, &mode);
+ search_list_select(search_list, attr_type, id, mode);
+ return empty_reply(connection, message);
}
/* tracking */
-static DBusHandlerResult
-request_tracking_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "tracking", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))tracking_get_attr);
+static DBusHandlerResult request_tracking_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "tracking", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))tracking_get_attr);
}
/* vehicle */
-static DBusHandlerResult
-request_vehicle_set_attr(DBusConnection *connection, DBusMessage *message)
-{
- struct vehicle *vehicle;
- struct attr attr;
- int ret;
-
- vehicle = object_get_from_message(message, "vehicle");
- if (! vehicle)
- return dbus_error_invalid_object_path(connection, message);
- if (decode_attr(message, &attr)) {
- ret=vehicle_set_attr(vehicle, &attr);
- destroy_attr(&attr);
- if (ret)
- return empty_reply(connection, message);
- }
- return dbus_error_invalid_parameter(connection, message);
+static DBusHandlerResult request_vehicle_set_attr(DBusConnection *connection, DBusMessage *message) {
+ struct vehicle *vehicle;
+ struct attr attr;
+ int ret;
+
+ vehicle = object_get_from_message(message, "vehicle");
+ if (! vehicle)
+ return dbus_error_invalid_object_path(connection, message);
+ if (decode_attr(message, &attr)) {
+ ret=vehicle_set_attr(vehicle, &attr);
+ destroy_attr(&attr);
+ if (ret)
+ return empty_reply(connection, message);
+ }
+ return dbus_error_invalid_parameter(connection, message);
}
/* vehicleprofile */
-static DBusHandlerResult
-request_vehicleprofile_get_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_get_attr(connection, message, "vehicleprofile", NULL, (int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))vehicleprofile_get_attr);
+static DBusHandlerResult request_vehicleprofile_get_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_get_attr(connection, message, "vehicleprofile", NULL, (int (*)(void *, enum attr_type, struct attr *,
+ struct attr_iter *))vehicleprofile_get_attr);
}
-static DBusHandlerResult
-request_vehicleprofile_set_attr(DBusConnection *connection, DBusMessage *message)
-{
- return request_set_add_remove_attr(connection, message, "vehicleprofile", NULL, (int (*)(void *, struct attr *))vehicleprofile_set_attr);
+static DBusHandlerResult request_vehicleprofile_set_attr(DBusConnection *connection, DBusMessage *message) {
+ return request_set_add_remove_attr(connection, message, "vehicleprofile", NULL, (int (*)(void *,
+ struct attr *))vehicleprofile_set_attr);
}
-static DBusHandlerResult
-request_vehicleprofile_attr_iter(DBusConnection *connection, DBusMessage *message)
-{
- return request_attr_iter(connection, message, "vehicleprofile", (struct attr_iter * (*)(void))vehicleprofile_attr_iter_new);
+static DBusHandlerResult request_vehicleprofile_attr_iter(DBusConnection *connection, DBusMessage *message) {
+ return request_attr_iter(connection, message, "vehicleprofile",
+ (struct attr_iter * (*)(void))vehicleprofile_attr_iter_new);
}
-static DBusHandlerResult
-request_vehicleprofile_attr_iter_destroy(DBusConnection *connection, DBusMessage *message)
-{
- return request_attr_iter_destroy(connection, message, "vehicleprofile", (void (*)(struct attr_iter *))vehicleprofile_attr_iter_destroy);
+static DBusHandlerResult request_vehicleprofile_attr_iter_destroy(DBusConnection *connection, DBusMessage *message) {
+ return request_attr_iter_destroy(connection, message, "vehicleprofile",
+ (void (*)(struct attr_iter *))vehicleprofile_attr_iter_destroy);
}
struct dbus_method {
- char *path;
- char *method;
- char *signature;
+ char *path;
+ char *method;
+ char *signature;
char *signature_name;
char *response;
char *response_name;
- DBusHandlerResult(*func)(DBusConnection *connection, DBusMessage *message);
+ DBusHandlerResult(*func)(DBusConnection *connection, DBusMessage *message);
} dbus_methods[] = {
- {"", "attr_iter", "", "", "o", "attr_iter", request_config_attr_iter},
- {"", "attr_iter_destroy", "o", "attr_iter", "", "", request_config_attr_iter_destroy},
- {"", "get_attr", "s", "attrname", "sv", "attrname,value",request_config_get_attr},
- {"", "get_attr_wi", "so", "attrname,attr_iter", "sv", "attrname,value",request_config_get_attr},
- {"", "callback_new", "s", "signalname", "o", "callback",request_callback_new},
- {"", "callback_attr_new", "ss", "signalname,attribute", "o", "callback",request_callback_new},
- {"", "search_list_new", "o", "mapset", "o", "search",request_search_list_new},
- {".callback","destroy", "", "", "", "", request_callback_destroy},
- {".graphics","get_data", "s", "type", "ay", "data", request_graphics_get_data},
- {".graphics","set_attr", "sv", "attribute,value", "", "", request_graphics_set_attr},
- {".gui", "get_attr", "s", "attribute", "sv", "attrname,value", request_gui_get_attr},
- {".gui", "command_parameter", "sa{sa{sv}}","command,parameter", "a{sa{sv}}", "return", request_gui_command},
- {".gui", "command", "s", "command", "a{sa{sv}}", "return", request_gui_command},
- {".navit", "draw", "", "", "", "", request_navit_draw},
- {".navit", "add_message", "s", "message", "", "", request_navit_add_message},
- {".navit", "set_center_by_string","s", "(coordinates)", "", "", request_navit_set_center},
- {".navit", "set_center", "(is)", "(projection,coordinates)", "", "", request_navit_set_center},
- {".navit", "set_center", "(iii)", "(projection,longitude,latitude)", "", "", request_navit_set_center},
- {".navit", "set_center_screen", "(ii)", "(pixel_x,pixel_y)", "", "", request_navit_set_center_screen},
- {".navit", "set_layout", "s", "layoutname", "", "", request_navit_set_layout},
- {".navit", "zoom", "i(ii)", "factor(pixel_x,pixel_y)", "", "", request_navit_zoom},
- {".navit", "zoom", "i", "factor", "", "", request_navit_zoom},
- {".navit", "zoom_to_route", "", "", "", "", request_navit_zoom_to_route},
- {".navit", "quit", "", "", "", "", request_navit_quit},
- {".navit", "export_as_gpx", "s", "filename", "", "", request_navit_route_export_gpx},
- {".navit", "export_as_geojson", "s", "filename", "", "", request_navit_route_export_geojson},
- {".navit", "block", "i", "mode", "", "", request_navit_block},
- {".navit", "resize", "ii", "upperleft,lowerright", "", "", request_navit_resize},
- {".navit", "attr_iter", "", "", "o", "attr_iter", request_navit_attr_iter},
- {".navit", "attr_iter_destroy", "o", "attr_iter", "", "", request_navit_attr_iter_destroy},
- {".navit", "get_attr", "s", "attribute", "sv", "attrname,value", request_navit_get_attr},
- {".navit", "get_attr_wi", "so", "attribute,attr_iter", "sv", "attrname,value", request_navit_get_attr},
- {".navit", "set_attr", "sv", "attribute,value", "", "", request_navit_set_attr},
- {".navit", "add_attr", "sv", "attribute,value", "", "", request_navit_add_attr},
- {".navit", "remove_attr", "sv", "attribute,value", "", "", request_navit_remove_attr},
- {".navit", "set_position", "s", "(coordinates)", "", "", request_navit_set_position},
- {".navit", "set_position", "(is)", "(projection,coordinated)", "", "", request_navit_set_position},
- {".navit", "set_position", "(iii)", "(projection,longitude,latitude)", "", "", request_navit_set_position},
- {".navit", "set_destination", "ss", "coordinates,comment", "", "", request_navit_set_destination},
- {".navit", "set_destination", "(is)s", "(projection,coordinates)comment", "", "", request_navit_set_destination},
- {".navit", "set_destination", "(iii)s", "(projection,longitude,latitude)comment", "", "", request_navit_set_destination},
- {".navit", "clear_destination", "", "", "", "", request_navit_clear_destination},
- {".navit", "evaluate", "s", "command", "s", "", request_navit_evaluate},
- {".layout", "get_attr", "s", "attribute", "sv", "attrname,value", request_layout_get_attr},
- {".map", "get_attr", "s", "attribute", "sv", "attrname,value", request_map_get_attr},
- {".map", "set_attr", "sv", "attribute,value", "", "", request_map_set_attr},
- {".map", "dump", "s", "file", "", "", request_map_dump},
- {".mapset", "attr_iter", "", "", "o", "attr_iter", request_mapset_attr_iter},
- {".mapset", "attr_iter_destroy", "o", "attr_iter", "", "", request_mapset_attr_iter_destroy},
- {".mapset", "get_attr", "s", "attribute", "sv", "attrname,value", request_mapset_get_attr},
- {".mapset", "get_attr_wi", "so", "attribute,attr_iter", "sv", "attrname,value", request_mapset_get_attr},
- {".navigation","get_attr", "s", "attribute", "", "", request_navigation_get_attr},
- {".osd", "get_attr", "s", "attribute", "sv", "attrname,value", request_osd_get_attr},
- {".osd", "set_attr", "sv", "attribute,value", "", "", request_osd_set_attr},
- {".roadprofile", "get_attr", "s", "attribute", "sv", "attrname,value", request_roadprofile_get_attr},
- {".roadprofile", "get_attr_wi", "so", "attribute,attr_iter", "", "", request_roadprofile_get_attr},
- {".roadprofile", "set_attr", "sv", "attribute,value", "", "", request_roadprofile_set_attr},
- {".roadprofile", "attr_iter", "", "", "o", "attr_iter", request_roadprofile_attr_iter},
- {".roadprofile", "attr_iter_destroy","o", "attr_iter", "", "", request_roadprofile_attr_iter_destroy},
- {".route", "get_attr", "s", "attribute", "sv", "attrname,value", request_route_get_attr},
- {".route", "set_attr", "sv", "attribute,value", "", "", request_route_set_attr},
- {".route", "add_attr", "sv", "attribute,value", "", "", request_route_add_attr},
- {".route", "remove_attr", "sv", "attribute,value", "", "", request_route_remove_attr},
- {".route", "destroy", "", "", "", "", request_route_destroy},
- {".route", "dup", "", "", "", "", request_route_dup},
- {".search_list","destroy", "", "", "", "", request_search_list_destroy},
- {".search_list","destroy", "", "", "", "", request_search_list_destroy},
- {".search_list","destroy", "", "", "", "", request_search_list_destroy},
- {".search_list","get_result", "", "", "i(iii)a{sa{sv}}", "id,coord,dict", request_search_list_get_result},
- {".search_list","search", "svi", "attribute,value,partial", "", "", request_search_list_search},
- {".search_list","select", "sii", "attribute_type,id,mode", "", "", request_search_list_select},
- {".tracking","get_attr", "s", "attribute", "", "", request_tracking_get_attr},
- {".vehicle","set_attr", "sv", "attribute,value", "", "", request_vehicle_set_attr},
- {".vehicleprofile","get_attr", "s", "attribute", "", "", request_vehicleprofile_get_attr},
- {".vehicleprofile","get_attr_wi", "so", "attribute,attr_iter", "", "", request_vehicleprofile_get_attr},
- {".vehicleprofile","set_attr", "sv", "attribute,value", "", "", request_vehicleprofile_set_attr},
- {".vehicleprofile","attr_iter", "", "", "o", "attr_iter", request_vehicleprofile_attr_iter},
- {".vehicleprofile","attr_iter_destroy","o", "attr_iter", "", "", request_vehicleprofile_attr_iter_destroy},
+ {"", "attr_iter", "", "", "o", "attr_iter", request_config_attr_iter},
+ {"", "attr_iter_destroy", "o", "attr_iter", "", "", request_config_attr_iter_destroy},
+ {"", "get_attr", "s", "attrname", "sv", "attrname,value",request_config_get_attr},
+ {"", "get_attr_wi", "so", "attrname,attr_iter", "sv", "attrname,value",request_config_get_attr},
+ {"", "callback_new", "s", "signalname", "o", "callback",request_callback_new},
+ {"", "callback_attr_new", "ss", "signalname,attribute", "o", "callback",request_callback_new},
+ {"", "search_list_new", "o", "mapset", "o", "search",request_search_list_new},
+ {".callback","destroy", "", "", "", "", request_callback_destroy},
+ {".graphics","get_data", "s", "type", "ay", "data", request_graphics_get_data},
+ {".graphics","set_attr", "sv", "attribute,value", "", "", request_graphics_set_attr},
+ {".gui", "get_attr", "s", "attribute", "sv", "attrname,value", request_gui_get_attr},
+ {".gui", "command_parameter", "sa{sa{sv}}","command,parameter", "a{sa{sv}}", "return", request_gui_command},
+ {".gui", "command", "s", "command", "a{sa{sv}}", "return", request_gui_command},
+ {".navit", "draw", "", "", "", "", request_navit_draw},
+ {".navit", "add_message", "s", "message", "", "", request_navit_add_message},
+ {".navit", "set_center_by_string","s", "(coordinates)", "", "", request_navit_set_center},
+ {".navit", "set_center", "(is)", "(projection,coordinates)", "", "", request_navit_set_center},
+ {".navit", "set_center", "(iii)", "(projection,longitude,latitude)", "", "", request_navit_set_center},
+ {".navit", "set_center_screen", "(ii)", "(pixel_x,pixel_y)", "", "", request_navit_set_center_screen},
+ {".navit", "set_layout", "s", "layoutname", "", "", request_navit_set_layout},
+ {".navit", "traffic_export", "s", "filename", "", "", request_navit_traffic_export_gpx},
+ {".navit", "traffic_inject", "s", "filename", "", "", request_navit_traffic_inject},
+ {".navit", "zoom", "i(ii)", "factor(pixel_x,pixel_y)", "", "", request_navit_zoom},
+ {".navit", "zoom", "i", "factor", "", "", request_navit_zoom},
+ {".navit", "zoom_to_route", "", "", "", "", request_navit_zoom_to_route},
+ {".navit", "quit", "", "", "", "", request_navit_quit},
+ {".navit", "export_as_gpx", "s", "filename", "", "", request_navit_route_export_gpx},
+ {".navit", "export_as_geojson", "s", "filename", "", "", request_navit_route_export_geojson},
+ {".navit", "block", "i", "mode", "", "", request_navit_block},
+ {".navit", "resize", "ii", "upperleft,lowerright", "", "", request_navit_resize},
+ {".navit", "attr_iter", "", "", "o", "attr_iter", request_navit_attr_iter},
+ {".navit", "attr_iter_destroy", "o", "attr_iter", "", "", request_navit_attr_iter_destroy},
+ {".navit", "get_attr", "s", "attribute", "sv", "attrname,value", request_navit_get_attr},
+ {".navit", "get_attr_wi", "so", "attribute,attr_iter", "sv", "attrname,value", request_navit_get_attr},
+ {".navit", "set_attr", "sv", "attribute,value", "", "", request_navit_set_attr},
+ {".navit", "add_attr", "sv", "attribute,value", "", "", request_navit_add_attr},
+ {".navit", "remove_attr", "sv", "attribute,value", "", "", request_navit_remove_attr},
+ {".navit", "set_position", "s", "(coordinates)", "", "", request_navit_set_position},
+ {".navit", "set_position", "(is)", "(projection,coordinated)", "", "", request_navit_set_position},
+ {".navit", "set_position", "(iii)", "(projection,longitude,latitude)", "", "", request_navit_set_position},
+ {".navit", "set_destination", "ss", "coordinates,comment", "", "", request_navit_set_destination},
+ {".navit", "set_destination", "(is)s", "(projection,coordinates)comment", "", "", request_navit_set_destination},
+ {".navit", "set_destination", "(iii)s", "(projection,longitude,latitude)comment", "", "", request_navit_set_destination},
+ {".navit", "clear_destination", "", "", "", "", request_navit_clear_destination},
+ {".navit", "evaluate", "s", "command", "s", "", request_navit_evaluate},
+ {".layout", "get_attr", "s", "attribute", "sv", "attrname,value", request_layout_get_attr},
+ {".map", "get_attr", "s", "attribute", "sv", "attrname,value", request_map_get_attr},
+ {".map", "set_attr", "sv", "attribute,value", "", "", request_map_set_attr},
+ {".map", "dump", "s", "file", "", "", request_map_dump},
+ {".mapset", "attr_iter", "", "", "o", "attr_iter", request_mapset_attr_iter},
+ {".mapset", "attr_iter_destroy", "o", "attr_iter", "", "", request_mapset_attr_iter_destroy},
+ {".mapset", "get_attr", "s", "attribute", "sv", "attrname,value", request_mapset_get_attr},
+ {".mapset", "get_attr_wi", "so", "attribute,attr_iter", "sv", "attrname,value", request_mapset_get_attr},
+ {".navigation","get_attr", "s", "attribute", "", "", request_navigation_get_attr},
+ {".osd", "get_attr", "s", "attribute", "sv", "attrname,value", request_osd_get_attr},
+ {".osd", "set_attr", "sv", "attribute,value", "", "", request_osd_set_attr},
+ {".roadprofile", "get_attr", "s", "attribute", "sv", "attrname,value", request_roadprofile_get_attr},
+ {".roadprofile", "get_attr_wi", "so", "attribute,attr_iter", "", "", request_roadprofile_get_attr},
+ {".roadprofile", "set_attr", "sv", "attribute,value", "", "", request_roadprofile_set_attr},
+ {".roadprofile", "attr_iter", "", "", "o", "attr_iter", request_roadprofile_attr_iter},
+ {".roadprofile", "attr_iter_destroy","o", "attr_iter", "", "", request_roadprofile_attr_iter_destroy},
+ {".route", "get_attr", "s", "attribute", "sv", "attrname,value", request_route_get_attr},
+ {".route", "set_attr", "sv", "attribute,value", "", "", request_route_set_attr},
+ {".route", "add_attr", "sv", "attribute,value", "", "", request_route_add_attr},
+ {".route", "remove_attr", "sv", "attribute,value", "", "", request_route_remove_attr},
+ {".route", "destroy", "", "", "", "", request_route_destroy},
+ {".route", "dup", "", "", "", "", request_route_dup},
+ {".search_list","destroy", "", "", "", "", request_search_list_destroy},
+ {".search_list","destroy", "", "", "", "", request_search_list_destroy},
+ {".search_list","destroy", "", "", "", "", request_search_list_destroy},
+ {".search_list","get_result", "", "", "i(iii)a{sa{sv}}", "id,coord,dict", request_search_list_get_result},
+ {".search_list","search", "svi", "attribute,value,partial", "", "", request_search_list_search},
+ {".search_list","select", "sii", "attribute_type,id,mode", "", "", request_search_list_select},
+ {".tracking","get_attr", "s", "attribute", "", "", request_tracking_get_attr},
+ {".vehicle","set_attr", "sv", "attribute,value", "", "", request_vehicle_set_attr},
+ {".vehicleprofile","get_attr", "s", "attribute", "", "", request_vehicleprofile_get_attr},
+ {".vehicleprofile","get_attr_wi", "so", "attribute,attr_iter", "", "", request_vehicleprofile_get_attr},
+ {".vehicleprofile","set_attr", "sv", "attribute,value", "", "", request_vehicleprofile_set_attr},
+ {".vehicleprofile","attr_iter", "", "", "o", "attr_iter", request_vehicleprofile_attr_iter},
+ {".vehicleprofile","attr_iter_destroy","o", "attr_iter", "", "", request_vehicleprofile_attr_iter_destroy},
};
-static char *
-introspect_path(const char *object)
-{
- char *ret;
- int i;
- char *def=".default_";
- int def_len=strlen(def);
- if (strncmp(object, object_path, strlen(object_path)))
- return NULL;
- ret=g_strdup(object+strlen(object_path));
- dbg(lvl_debug,"path=%s\n",ret);
- for (i = strlen(ret)-1 ; i >= 0 ; i--) {
- if (ret[i] == '/' || (ret[i] >= '0' && ret[i] <= '9'))
- ret[i]='\0';
- else
- break;
- }
- for (i = 0 ; i < strlen(ret); i++)
- if (ret[i] == '/')
- ret[i]='.';
-
- for (i = strlen(ret)-1 ; i >= 0 ; i--) {
- if (!strncmp(ret+i, def, def_len)) {
- memmove(ret+1,ret+i+def_len,strlen(ret+i+def_len)+1);
- break;
- }
- }
- return ret;
-}
-
-static char *
-generate_navitintrospectxml(const char *object)
-{
+static char *introspect_path(const char *object) {
+ char *ret;
+ int i;
+ char *def=".default_";
+ int def_len=strlen(def);
+ if (strncmp(object, object_path, strlen(object_path)))
+ return NULL;
+ ret=g_strdup(object+strlen(object_path));
+ dbg(lvl_debug,"path=%s",ret);
+ for (i = strlen(ret)-1 ; i >= 0 ; i--) {
+ if (ret[i] == '/' || (ret[i] >= '0' && ret[i] <= '9'))
+ ret[i]='\0';
+ else
+ break;
+ }
+ for (i = 0 ; i < strlen(ret); i++)
+ if (ret[i] == '/')
+ ret[i]='.';
+
+ for (i = strlen(ret)-1 ; i >= 0 ; i--) {
+ if (!strncmp(ret+i, def, def_len)) {
+ memmove(ret+1,ret+i+def_len,strlen(ret+i+def_len)+1);
+ break;
+ }
+ }
+ return ret;
+}
+
+static char *generate_navitintrospectxml(const char *object) {
int i,methods_size,n=0;
char *navitintrospectxml;
char *path=introspect_path(object);
if (!path)
- return NULL;
- dbg(lvl_debug,"path=%s\n",path);
+ return NULL;
+ dbg(lvl_debug,"path=%s",path);
// write header and make navit introspectable
navitintrospectxml = g_strdup_printf("%s%s%s\n", navitintrospectxml_head1, object, navitintrospectxml_head2);
@@ -2069,22 +2098,25 @@ generate_navitintrospectxml(const char *object)
methods_size=sizeof(dbus_methods)/sizeof(struct dbus_method);
for (i = 0 ; i < methods_size ; i++) {
// start new interface if it's the first method or it changed
- if (strcmp(dbus_methods[i].path, path))
- continue;
+ if (strcmp(dbus_methods[i].path, path))
+ continue;
if ((n == 0) || strcmp(dbus_methods[i-1].path, dbus_methods[i].path))
- navitintrospectxml = g_strconcat_printf(navitintrospectxml, " <interface name=\"%s%s\">\n", service_name, dbus_methods[i].path);
- n++;
+ navitintrospectxml = g_strconcat_printf(navitintrospectxml, " <interface name=\"%s%s\">\n", service_name,
+ dbus_methods[i].path);
+ n++;
// start the new method
navitintrospectxml = g_strconcat_printf(navitintrospectxml, " <method name=\"%s\">\n", dbus_methods[i].method);
// set input signature if existent
if (strcmp(dbus_methods[i].signature, ""))
- navitintrospectxml = g_strconcat_printf(navitintrospectxml, " <arg direction=\"in\" name=\"%s\" type=\"%s\" />\n", dbus_methods[i].signature_name, dbus_methods[i].signature);
+ navitintrospectxml = g_strconcat_printf(navitintrospectxml, " <arg direction=\"in\" name=\"%s\" type=\"%s\" />\n",
+ dbus_methods[i].signature_name, dbus_methods[i].signature);
// set response signature if existent
if (strcmp(dbus_methods[i].response, ""))
- navitintrospectxml = g_strconcat_printf(navitintrospectxml, " <arg direction=\"out\" name=\"%s\" type=\"%s\" />\n", dbus_methods[i].response_name, dbus_methods[i].response);
+ navitintrospectxml = g_strconcat_printf(navitintrospectxml, " <arg direction=\"out\" name=\"%s\" type=\"%s\" />\n",
+ dbus_methods[i].response_name, dbus_methods[i].response);
// close the method
navitintrospectxml = g_strconcat_printf(navitintrospectxml, " </method>\n");
@@ -2099,141 +2131,136 @@ generate_navitintrospectxml(const char *object)
return navitintrospectxml;
}
-static DBusHandlerResult
-navit_handler_func(DBusConnection *connection, DBusMessage *message, void *user_data)
-{
- int i;
- char *path;
- dbg(lvl_debug,"type=%s interface=%s path=%s member=%s signature=%s\n", dbus_message_type_to_string(dbus_message_get_type(message)), dbus_message_get_interface(message), dbus_message_get_path(message), dbus_message_get_member(message), dbus_message_get_signature(message));
- if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
- DBusMessage *reply;
- char *navitintrospectxml = generate_navitintrospectxml(dbus_message_get_path(message));
- dbg(lvl_debug,"Introspect %s:Result:%s\n",dbus_message_get_path(message), navitintrospectxml);
- if (navitintrospectxml) {
- reply = dbus_message_new_method_return(message);
- dbus_message_append_args(reply, DBUS_TYPE_STRING, &navitintrospectxml, DBUS_TYPE_INVALID);
- dbus_connection_send (connection, reply, NULL);
- dbus_message_unref (reply);
- g_free(navitintrospectxml);
- return DBUS_HANDLER_RESULT_HANDLED;
- }
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
+static DBusHandlerResult navit_handler_func(DBusConnection *connection, DBusMessage *message, void *user_data) {
+ int i;
+ char *path;
+ dbg(lvl_debug,"type=%s interface=%s path=%s member=%s signature=%s",
+ dbus_message_type_to_string(dbus_message_get_type(message)), dbus_message_get_interface(message),
+ dbus_message_get_path(message), dbus_message_get_member(message), dbus_message_get_signature(message));
+ if (dbus_message_is_method_call (message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+ DBusMessage *reply;
+ char *navitintrospectxml = generate_navitintrospectxml(dbus_message_get_path(message));
+ dbg(lvl_debug,"Introspect %s:Result:%s",dbus_message_get_path(message), navitintrospectxml);
+ if (navitintrospectxml) {
+ reply = dbus_message_new_method_return(message);
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &navitintrospectxml, DBUS_TYPE_INVALID);
+ dbus_connection_send (connection, reply, NULL);
+ dbus_message_unref (reply);
+ g_free(navitintrospectxml);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
for (i = 0 ; i < sizeof(dbus_methods)/sizeof(struct dbus_method) ; i++) {
- path=g_strdup_printf("%s%s", service_name, dbus_methods[i].path);
- if (dbus_message_is_method_call(message, path, dbus_methods[i].method) &&
- dbus_message_has_signature(message, dbus_methods[i].signature)) {
- g_free(path);
- return dbus_methods[i].func(connection, message);
- }
- g_free(path);
- }
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ path=g_strdup_printf("%s%s", service_name, dbus_methods[i].path);
+ if (dbus_message_is_method_call(message, path, dbus_methods[i].method) &&
+ dbus_message_has_signature(message, dbus_methods[i].signature)) {
+ g_free(path);
+ return dbus_methods[i].func(connection, message);
+ }
+ g_free(path);
+ }
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
static DBusObjectPathVTable dbus_navit_vtable = {
- NULL,
- navit_handler_func,
- NULL
+ NULL,
+ navit_handler_func,
+ NULL
};
#if 0
-DBusHandlerResult
-filter(DBusConnection *connection, DBusMessage *message, void *user_data)
-{
- dbg(lvl_debug,"type=%s interface=%s path=%s member=%s signature=%s\n", dbus_message_type_to_string(dbus_message_get_type(message)), dbus_message_get_interface(message), dbus_message_get_path(message), dbus_message_get_member(message), dbus_message_get_signature(message));
- if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
- }
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+DBusHandlerResult filter(DBusConnection *connection, DBusMessage *message, void *user_data) {
+ dbg(lvl_debug,"type=%s interface=%s path=%s member=%s signature=%s",
+ dbus_message_type_to_string(dbus_message_get_type(message)), dbus_message_get_interface(message),
+ dbus_message_get_path(message), dbus_message_get_member(message), dbus_message_get_signature(message));
+ if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
+ }
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
#endif
-static int
-dbus_cmd_send_signal(struct navit *navit, char *command, struct attr **in, struct attr ***out)
-{
- DBusMessage* msg;
- char *opath=object_new("navit",navit);
- char *interface=g_strdup_printf("%s%s", service_name, ".navit");
- dbg(lvl_debug,"enter %s %s %s\n",opath,command,interface);
- msg = dbus_message_new_signal(opath, interface, "signal");
- if (msg) {
- DBusMessageIter iter1,iter2,iter3;
- dbus_message_iter_init_append(msg, &iter1);
- dbus_message_iter_open_container(&iter1, DBUS_TYPE_ARRAY, "{sv}", &iter2);
- if (in) {
- while (*in) {
- dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
- encode_attr(&iter3, *in);
- dbus_message_iter_close_container(&iter2, &iter3);
- in++;
- }
- }
- dbus_message_iter_close_container(&iter1, &iter2);
- dbus_connection_send(connection, msg, &dbus_serial);
- dbus_connection_flush(connection);
- dbus_message_unref(msg);
- }
- g_free(interface);
- return 0;
+static int dbus_cmd_send_signal(struct navit *navit, char *command, struct attr **in, struct attr ***out) {
+ DBusMessage* msg;
+ char *opath=object_new("navit",navit);
+ char *interface=g_strdup_printf("%s%s", service_name, ".navit");
+ dbg(lvl_debug,"enter %s %s %s",opath,command,interface);
+ msg = dbus_message_new_signal(opath, interface, "signal");
+ if (msg) {
+ DBusMessageIter iter1,iter2,iter3;
+ dbus_message_iter_init_append(msg, &iter1);
+ dbus_message_iter_open_container(&iter1, DBUS_TYPE_ARRAY, "{sv}", &iter2);
+ if (in) {
+ while (*in) {
+ dbus_message_iter_open_container(&iter2, DBUS_TYPE_DICT_ENTRY, NULL, &iter3);
+ encode_attr(&iter3, *in);
+ dbus_message_iter_close_container(&iter2, &iter3);
+ in++;
+ }
+ }
+ dbus_message_iter_close_container(&iter1, &iter2);
+ dbus_connection_send(connection, msg, &dbus_serial);
+ dbus_connection_flush(connection);
+ dbus_message_unref(msg);
+ }
+ g_free(interface);
+ return 0;
}
static struct command_table commands[] = {
- {"dbus_send_signal",command_cast(dbus_cmd_send_signal)},
+ {"dbus_send_signal",command_cast(dbus_cmd_send_signal)},
};
-static void
-dbus_main_navit(struct navit *navit, int added)
-{
- struct attr attr;
- if (added==1) {
- DBusMessage* msg;
- char *opath=object_new("navit",navit);
- char *interface=g_strdup_printf("%s%s", service_name, ".navit");
- command_add_table_attr(commands, sizeof(commands)/sizeof(struct command_table), navit, &attr);
- navit_add_attr(navit, &attr);
- msg = dbus_message_new_signal(opath, interface, "startup");
- dbus_connection_send(connection, msg, &dbus_serial);
- dbus_connection_flush(connection);
- dbus_message_unref(msg);
- g_free(interface);
- }
-}
-
-void plugin_init(void)
-{
- DBusError error;
-
- struct attr callback;
- object_hash=g_hash_table_new(g_str_hash, g_str_equal);
- object_hash_rev=g_hash_table_new(NULL, NULL);
- object_count=g_hash_table_new(g_str_hash, g_str_equal);
- dbg(lvl_debug,"enter\n");
- dbus_error_init(&error);
+static void dbus_main_navit(struct navit *navit, int added) {
+ struct attr attr;
+ if (added==1) {
+ DBusMessage* msg;
+ char *opath=object_new("navit",navit);
+ char *interface=g_strdup_printf("%s%s", service_name, ".navit");
+ command_add_table_attr(commands, sizeof(commands)/sizeof(struct command_table), navit, &attr);
+ navit_add_attr(navit, &attr);
+ msg = dbus_message_new_signal(opath, interface, "startup");
+ dbus_connection_send(connection, msg, &dbus_serial);
+ dbus_connection_flush(connection);
+ dbus_message_unref(msg);
+ g_free(interface);
+ }
+}
+
+void plugin_init(void) {
+ DBusError error;
+
+ struct attr callback;
+ object_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ object_hash_rev=g_hash_table_new(NULL, NULL);
+ object_count=g_hash_table_new(g_str_hash, g_str_equal);
+ dbg(lvl_debug,"enter");
+ dbus_error_init(&error);
#ifdef DBUS_USE_SYSTEM_BUS
- connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
#else
- connection = dbus_bus_get(DBUS_BUS_SESSION, &error);
+ connection = dbus_bus_get(DBUS_BUS_SESSION, &error);
#endif
- if (!connection) {
- dbg(lvl_error,"Failed to open connection to session message bus: %s\n", error.message);
- dbus_error_free(&error);
- return;
- }
- dbus_connection_setup_with_g_main(connection, NULL);
+ if (!connection) {
+ dbg(lvl_error,"Failed to open connection to session message bus: %s", error.message);
+ dbus_error_free(&error);
+ return;
+ }
+ dbus_connection_setup_with_g_main(connection, NULL);
#if 0
- dbus_connection_add_filter(connection, filter, NULL, NULL);
- dbus_bus_add_match(connection, "type='signal',""interface='" DBUS_INTERFACE_DBUS "'", &error);
+ dbus_connection_add_filter(connection, filter, NULL, NULL);
+ dbus_bus_add_match(connection, "type='signal',""interface='" DBUS_INTERFACE_DBUS "'", &error);
#endif
- dbus_connection_register_fallback(connection, object_path, &dbus_navit_vtable, NULL);
- dbus_bus_request_name(connection, service_name, 0, &error);
- if (dbus_error_is_set(&error)) {
- dbg(lvl_error,"Failed to request name: %s", error.message);
- dbus_error_free (&error);
- }
- callback.type=attr_callback;
- callback.u.callback=callback_new_attr_0(callback_cast(dbus_main_navit),attr_navit);
- config_add_attr(config, &callback);
+ dbus_connection_register_fallback(connection, object_path, &dbus_navit_vtable, NULL);
+ dbus_bus_request_name(connection, service_name, 0, &error);
+ if (dbus_error_is_set(&error)) {
+ dbg(lvl_error,"Failed to request name: %s", error.message);
+ dbus_error_free (&error);
+ }
+ callback.type=attr_callback;
+ callback.u.callback=callback_new_attr_0(callback_cast(dbus_main_navit),attr_navit);
+ config_add_attr(config, &callback);
}
diff --git a/navit/binding/dbus/eval.py b/navit/binding/dbus/eval.py
index a2e1926fd..ecb1d9583 100755
--- a/navit/binding/dbus/eval.py
+++ b/navit/binding/dbus/eval.py
@@ -4,9 +4,9 @@ import sys
bus = dbus.SessionBus()
conn = bus.get_object('org.navit_project.navit',
'/org/navit_project/navit')
-iface = dbus.Interface(conn, dbus_interface='org.navit_project.navit');
-iter=iface.attr_iter();
-navit=bus.get_object('org.navit_project.navit', conn.get_attr_wi('navit',iter)[1]);
-iface.attr_iter_destroy(iter);
-navit_iface = dbus.Interface(navit, dbus_interface='org.navit_project.navit.navit');
-print navit_iface.evaluate(sys.argv[1]);
+iface = dbus.Interface(conn, dbus_interface='org.navit_project.navit')
+_iter=iface.attr_iter()
+navit=bus.get_object('org.navit_project.navit', conn.get_attr_wi('navit',_iter)[1])
+iface.attr_iter_destroy(_iter)
+navit_iface = dbus.Interface(navit, dbus_interface='org.navit_project.navit.navit')
+print navit_iface.evaluate(sys.argv[1])
diff --git a/navit/binding/dbus/navit.introspect b/navit/binding/dbus/navit.introspect
index 9366c0cb3..9530a7b27 100644
--- a/navit/binding/dbus/navit.introspect
+++ b/navit/binding/dbus/navit.introspect
@@ -6,7 +6,7 @@
<arg direction="out" type="s" />
</method>
</interface>
-
+
<interface name="org.navit_project.navit">
<method name="get_navit">
<arg name="iter" type="o" direction="in"/>
@@ -19,7 +19,7 @@
<arg name="iter" type="o" direction="in"/>
</method>
</interface>
-
+
<interface name="org.navit_project.navit.navit">
<method name="zoom">
<arg type="i" direction="in" />
diff --git a/navit/binding/dbus/test.py b/navit/binding/dbus/test.py
index 740f000e6..98a04b5a6 100755
--- a/navit/binding/dbus/test.py
+++ b/navit/binding/dbus/test.py
@@ -3,9 +3,9 @@ import dbus
bus = dbus.SessionBus()
conn = bus.get_object('org.navit_project.navit',
'/org/navit_project/navit')
-iface = dbus.Interface(conn, dbus_interface='org.navit_project.navit');
-iter=iface.attr_iter();
-navit=bus.get_object('org.navit_project.navit', conn.get_attr_wi("navit",iter)[1]);
-iface.attr_iter_destroy(iter);
-navit_iface = dbus.Interface(navit, dbus_interface='org.navit_project.navit.navit');
-navit_iface.set_center((1,0x138a4a,0x5d773f));
+iface = dbus.Interface(conn, dbus_interface='org.navit_project.navit')
+_iter=iface.attr_iter()
+navit=bus.get_object('org.navit_project.navit', conn.get_attr_wi("navit",_iter)[1])
+iface.attr_iter_destroy(_iter)
+navit_iface = dbus.Interface(navit, dbus_interface='org.navit_project.navit.navit')
+navit_iface.set_center((1,0x138a4a,0x5d773f))
diff --git a/navit/binding/python/attr.c b/navit/binding/python/attr.c
index 2d5ed92b6..f9ba18d47 100644
--- a/navit/binding/python/attr.c
+++ b/navit/binding/python/attr.c
@@ -22,78 +22,67 @@
#include "attr.h"
typedef struct {
- PyObject_HEAD
- int ref;
- struct attr *attr;
+ PyObject_HEAD
+ int ref;
+ struct attr *attr;
} attrObject;
-static PyObject *
-attr_func(attrObject *self, PyObject *args)
-{
- const char *file;
- int ret;
- if (!PyArg_ParseTuple(args, "s", &file))
- return NULL;
- ret=0;
- return Py_BuildValue("i",ret);
+static PyObject *attr_func(attrObject *self, PyObject *args) {
+ const char *file;
+ int ret;
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return NULL;
+ ret=0;
+ return Py_BuildValue("i",ret);
}
static PyMethodDef attr_methods[] = {
- {"func", (PyCFunction) attr_func, METH_VARARGS },
- {NULL, NULL },
+ {"func", (PyCFunction) attr_func, METH_VARARGS },
+ {NULL, NULL },
};
-static PyObject *
-attr_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(attr_methods, self, name);
+static PyObject *attr_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(attr_methods, self, name);
}
-static void
-attr_destroy_py(attrObject *self)
-{
- if (! self->ref)
- attr_free(self->attr);
+static void attr_destroy_py(attrObject *self) {
+ if (! self->ref)
+ attr_free(self->attr);
}
PyTypeObject attr_Type = {
- Obj_HEAD
- .tp_name="attr",
- .tp_basicsize=sizeof(attrObject),
- .tp_dealloc=(destructor)attr_destroy_py,
- .tp_getattr=attr_getattr_py,
+ Obj_HEAD
+ .tp_name="attr",
+ .tp_basicsize=sizeof(attrObject),
+ .tp_dealloc=(destructor)attr_destroy_py,
+ .tp_getattr=attr_getattr_py,
};
struct attr *
-attr_py_get(PyObject *self)
-{
- return ((attrObject *)self)->attr;
+attr_py_get(PyObject *self) {
+ return ((attrObject *)self)->attr;
}
-PyObject *
-attr_new_py(PyObject *self, PyObject *args)
-{
- attrObject *ret;
- const char *name,*value;
- if (!PyArg_ParseTuple(args, "ss", &name, &value))
- return NULL;
- ret=PyObject_NEW(attrObject, &attr_Type);
- ret->attr=attr_new_from_text(name, value);
- ret->ref=0;
- return (PyObject *)ret;
+PyObject *attr_new_py(PyObject *self, PyObject *args) {
+ attrObject *ret;
+ const char *name,*value;
+ if (!PyArg_ParseTuple(args, "ss", &name, &value))
+ return NULL;
+ ret=PyObject_NEW(attrObject, &attr_Type);
+ ret->attr=attr_new_from_text(name, value);
+ ret->ref=0;
+ return (PyObject *)ret;
}
-PyObject *
-attr_new_py_ref(struct attr *attr)
-{
- attrObject *ret;
+PyObject *attr_new_py_ref(struct attr *attr) {
+ attrObject *ret;
- ret=PyObject_NEW(attrObject, &attr_Type);
- ret->ref=1;
- ret->attr=attr;
- return (PyObject *)ret;
+ ret=PyObject_NEW(attrObject, &attr_Type);
+ ret->ref=1;
+ ret->attr=attr;
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/binding_python.c b/navit/binding/python/binding_python.c
index 51d84fe10..6a3fe5197 100644
--- a/navit/binding/python/binding_python.c
+++ b/navit/binding/python/binding_python.c
@@ -42,66 +42,62 @@
/* *** coord *** */
typedef struct {
- PyObject_HEAD
- struct coord *c;
+ PyObject_HEAD
+ struct coord *c;
} coordObject;
static void coord_destroy_py(coordObject *self);
PyTypeObject coord_Type = {
- Obj_HEAD
- .tp_name="coord",
- .tp_basicsize=sizeof(coordObject),
- .tp_dealloc=(destructor)coord_destroy_py,
+ Obj_HEAD
+ .tp_name="coord",
+ .tp_basicsize=sizeof(coordObject),
+ .tp_dealloc=(destructor)coord_destroy_py,
};
/* *** map *** */
typedef struct {
- PyObject_HEAD
- int ref;
- struct map *m;
+ PyObject_HEAD
+ int ref;
+ struct map *m;
} mapObject;
static void map_destroy_py(mapObject *self);
static PyObject *map_getattr_py(PyObject *self, char *name);
PyTypeObject map_Type = {
- Obj_HEAD
- .tp_name="map",
- .tp_basicsize=sizeof(mapObject),
- .tp_dealloc=(destructor)map_destroy_py,
- .tp_getattr=map_getattr_py,
+ Obj_HEAD
+ .tp_name="map",
+ .tp_basicsize=sizeof(mapObject),
+ .tp_dealloc=(destructor)map_destroy_py,
+ .tp_getattr=map_getattr_py,
};
/* *** IMPLEMENTATIONS *** */
/* *** coord *** */
-static PyObject *
-coord_new_py(PyObject *self, PyObject *args)
-{
- coordObject *ret;
- int x,y;
- if (!PyArg_ParseTuple(args, "ii:navit.coord",&x,&y))
- return NULL;
- ret=PyObject_NEW(coordObject, &coord_Type);
- ret->c=coord_new(x,y);
- return (PyObject *)ret;
+static PyObject *coord_new_py(PyObject *self, PyObject *args) {
+ coordObject *ret;
+ int x,y;
+ if (!PyArg_ParseTuple(args, "ii:navit.coord",&x,&y))
+ return NULL;
+ ret=PyObject_NEW(coordObject, &coord_Type);
+ ret->c=coord_new(x,y);
+ return (PyObject *)ret;
}
-static void
-coord_destroy_py(coordObject *self)
-{
- coord_destroy(self->c);
+static void coord_destroy_py(coordObject *self) {
+ coord_destroy(self->c);
}
/* *** coord_rect *** */
typedef struct {
- PyObject_HEAD
- struct coord_rect *r;
+ PyObject_HEAD
+ struct coord_rect *r;
} coord_rectObject;
@@ -109,38 +105,34 @@ static void coord_rect_destroy_py(coord_rectObject *self);
PyTypeObject coord_rect_Type = {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
- PyObject_HEAD_INIT(NULL);
+ PyObject_HEAD_INIT(NULL);
#else
- PyObject_HEAD_INIT(&PyType_Type)
+ PyObject_HEAD_INIT(&PyType_Type)
#endif
- .tp_name="coord_rect",
- .tp_basicsize=sizeof(coord_rectObject),
- .tp_dealloc=(destructor)coord_rect_destroy_py,
+ .tp_name="coord_rect",
+ .tp_basicsize=sizeof(coord_rectObject),
+ .tp_dealloc=(destructor)coord_rect_destroy_py,
};
-static PyObject *
-coord_rect_new_py(PyObject *self, PyObject *args)
-{
- coord_rectObject *ret;
- coordObject *lu,*rd;
- if (!PyArg_ParseTuple(args, "O!O!:navit.coord_rect_rect",&coord_Type,&lu,&coord_Type,&rd))
- return NULL;
- ret=PyObject_NEW(coord_rectObject, &coord_rect_Type);
- ret->r=coord_rect_new(lu->c,rd->c);
- return (PyObject *)ret;
+static PyObject *coord_rect_new_py(PyObject *self, PyObject *args) {
+ coord_rectObject *ret;
+ coordObject *lu,*rd;
+ if (!PyArg_ParseTuple(args, "O!O!:navit.coord_rect_rect",&coord_Type,&lu,&coord_Type,&rd))
+ return NULL;
+ ret=PyObject_NEW(coord_rectObject, &coord_rect_Type);
+ ret->r=coord_rect_new(lu->c,rd->c);
+ return (PyObject *)ret;
}
-static void
-coord_rect_destroy_py(coord_rectObject *self)
-{
- coord_rect_destroy(self->r);
+static void coord_rect_destroy_py(coord_rectObject *self) {
+ coord_rect_destroy(self->r);
}
/* *** map_rect *** */
typedef struct {
- PyObject_HEAD
- struct map_rect *mr;
+ PyObject_HEAD
+ struct map_rect *mr;
} map_rectObject;
@@ -148,110 +140,94 @@ static void map_rect_destroy_py(map_rectObject *self);
PyTypeObject map_rect_Type = {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
- PyObject_HEAD_INIT(NULL);
+ PyObject_HEAD_INIT(NULL);
#else
- PyObject_HEAD_INIT(&PyType_Type)
+ PyObject_HEAD_INIT(&PyType_Type)
#endif
- .tp_name="map_rect",
- .tp_basicsize=sizeof(map_rectObject),
- .tp_dealloc=(destructor)map_rect_destroy_py,
+ .tp_name="map_rect",
+ .tp_basicsize=sizeof(map_rectObject),
+ .tp_dealloc=(destructor)map_rect_destroy_py,
};
-static PyObject *
-map_rect_new_py(mapObject *self, PyObject *args)
-{
- map_rectObject *ret;
- coord_rectObject *r;
- if (!PyArg_ParseTuple(args, "O!:navit.map_rect_rect",&coord_rect_Type,&r))
- return NULL;
- ret=PyObject_NEW(map_rectObject, &map_rect_Type);
- ret->mr=map_rect_new(self->m, NULL);
- return (PyObject *)ret;
+static PyObject *map_rect_new_py(mapObject *self, PyObject *args) {
+ map_rectObject *ret;
+ coord_rectObject *r;
+ if (!PyArg_ParseTuple(args, "O!:navit.map_rect_rect",&coord_rect_Type,&r))
+ return NULL;
+ ret=PyObject_NEW(map_rectObject, &map_rect_Type);
+ ret->mr=map_rect_new(self->m, NULL);
+ return (PyObject *)ret;
}
-static void
-map_rect_destroy_py(map_rectObject *self)
-{
- map_rect_destroy(self->mr);
+static void map_rect_destroy_py(map_rectObject *self) {
+ map_rect_destroy(self->mr);
}
/* *** map *** */
-static PyObject *
-map_dump_file_py(mapObject *self, PyObject *args)
-{
- const char *s;
- if (!PyArg_ParseTuple(args, "s",&s))
- return NULL;
- map_dump_file(self->m, s);
- Py_RETURN_NONE;
+static PyObject *map_dump_file_py(mapObject *self, PyObject *args) {
+ const char *s;
+ if (!PyArg_ParseTuple(args, "s",&s))
+ return NULL;
+ map_dump_file(self->m, s);
+ Py_RETURN_NONE;
}
-static PyObject *
-map_set_attr_py(mapObject *self, PyObject *args)
-{
- PyObject *attr;
- if (!PyArg_ParseTuple(args, "O!", &attr_Type, &attr))
- return NULL;
- map_set_attr(self->m, attr_py_get(attr));
- Py_RETURN_NONE;
+static PyObject *map_set_attr_py(mapObject *self, PyObject *args) {
+ PyObject *attr;
+ if (!PyArg_ParseTuple(args, "O!", &attr_Type, &attr))
+ return NULL;
+ map_set_attr(self->m, attr_py_get(attr));
+ Py_RETURN_NONE;
}
static PyMethodDef map_methods[] = {
- {"dump_file", (PyCFunction) map_dump_file_py, METH_VARARGS },
- {"map_rect_new", (PyCFunction) map_rect_new_py, METH_VARARGS },
- {"set_attr", (PyCFunction) map_set_attr_py, METH_VARARGS },
- {NULL, NULL },
+ {"dump_file", (PyCFunction) map_dump_file_py, METH_VARARGS },
+ {"map_rect_new", (PyCFunction) map_rect_new_py, METH_VARARGS },
+ {"set_attr", (PyCFunction) map_set_attr_py, METH_VARARGS },
+ {NULL, NULL },
};
-static PyObject *
-map_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(map_methods, self, name);
+static PyObject *map_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(map_methods, self, name);
}
-static PyObject *
-map_new_py(PyObject *self, PyObject *args)
-{
- mapObject *ret;
- char *type, *filename;
-
- if (!PyArg_ParseTuple(args, "ss:navit.map", &type, &filename))
- return NULL;
- ret=PyObject_NEW(mapObject, &map_Type);
- ret->m=map_new(NULL,NULL);
- ret->ref=0;
- return (PyObject *)ret;
+static PyObject *map_new_py(PyObject *self, PyObject *args) {
+ mapObject *ret;
+ char *type, *filename;
+
+ if (!PyArg_ParseTuple(args, "ss:navit.map", &type, &filename))
+ return NULL;
+ ret=PyObject_NEW(mapObject, &map_Type);
+ ret->m=map_new(NULL,NULL);
+ ret->ref=0;
+ return (PyObject *)ret;
}
-PyObject *
-map_py_ref(struct map *map)
-{
- mapObject *ret;
- ret=PyObject_NEW(mapObject, &map_Type);
- ret->m=map;
- ret->ref=1;
- return (PyObject *)ret;
+PyObject *map_py_ref(struct map *map) {
+ mapObject *ret;
+ ret=PyObject_NEW(mapObject, &map_Type);
+ ret->m=map;
+ ret->ref=1;
+ return (PyObject *)ret;
}
-static void
-map_destroy_py(mapObject *self)
-{
- if (!self->ref)
- map_destroy(self->m);
+static void map_destroy_py(mapObject *self) {
+ if (!self->ref)
+ map_destroy(self->m);
}
/* *** mapset *** */
typedef struct {
- PyObject_HEAD
- struct mapset *ms;
+ PyObject_HEAD
+ struct mapset *ms;
} mapsetObject;
@@ -260,111 +236,99 @@ static PyObject *mapset_getattr_py(PyObject *self, char *name);
PyTypeObject mapset_Type = {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
- PyObject_HEAD_INIT(NULL);
+ PyObject_HEAD_INIT(NULL);
#else
- PyObject_HEAD_INIT(&PyType_Type)
+ PyObject_HEAD_INIT(&PyType_Type)
#endif
- .tp_name="mapset",
- .tp_basicsize=sizeof(mapsetObject),
- .tp_dealloc=(destructor)mapset_destroy_py,
- .tp_getattr=mapset_getattr_py,
+ .tp_name="mapset",
+ .tp_basicsize=sizeof(mapsetObject),
+ .tp_dealloc=(destructor)mapset_destroy_py,
+ .tp_getattr=mapset_getattr_py,
};
-static PyObject *
-mapset_add_py(mapsetObject *self, PyObject *args)
-{
- mapObject *map;
- if (!PyArg_ParseTuple(args, "O:navit.mapset", &map))
- return NULL;
- Py_INCREF(map);
- mapset_add_attr(self->ms, &(struct attr){attr_map,.u.map=map->m});
- return Py_BuildValue("");
+static PyObject *mapset_add_py(mapsetObject *self, PyObject *args) {
+ mapObject *map;
+ if (!PyArg_ParseTuple(args, "O:navit.mapset", &map))
+ return NULL;
+ Py_INCREF(map);
+ mapset_add_attr(self->ms, &(struct attr) {
+ attr_map,.u.map=map->m
+ });
+ return Py_BuildValue("");
}
static PyMethodDef mapset_methods[] = {
- {"add", (PyCFunction) mapset_add_py, METH_VARARGS },
- {NULL, NULL },
+ {"add", (PyCFunction) mapset_add_py, METH_VARARGS },
+ {NULL, NULL },
};
-static PyObject *
-mapset_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(mapset_methods, self, name);
+static PyObject *mapset_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(mapset_methods, self, name);
}
-static PyObject *
-mapset_new_py(PyObject *self, PyObject *args)
-{
- mapsetObject *ret;
- if (!PyArg_ParseTuple(args, ":navit.mapset"))
- return NULL;
- ret=PyObject_NEW(mapsetObject, &mapset_Type);
- ret->ms=mapset_new(NULL,NULL);
- return (PyObject *)ret;
+static PyObject *mapset_new_py(PyObject *self, PyObject *args) {
+ mapsetObject *ret;
+ if (!PyArg_ParseTuple(args, ":navit.mapset"))
+ return NULL;
+ ret=PyObject_NEW(mapsetObject, &mapset_Type);
+ ret->ms=mapset_new(NULL,NULL);
+ return (PyObject *)ret;
}
-static void
-mapset_destroy_py(mapsetObject *self)
-{
- mapset_destroy(self->ms);
+static void mapset_destroy_py(mapsetObject *self) {
+ mapset_destroy(self->ms);
}
-static PyObject *
-config_load_py(PyObject *self, PyObject *args)
-{
- const char *file;
- int ret;
- xmlerror *error;
- if (!PyArg_ParseTuple(args, "s", &file))
- return NULL;
- ret=config_load(file, &error);
- return Py_BuildValue("i",ret);
+static PyObject *config_load_py(PyObject *self, PyObject *args) {
+ const char *file;
+ int ret;
+ xmlerror *error;
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return NULL;
+ ret=config_load(file, &error);
+ return Py_BuildValue("i",ret);
}
-static PyMethodDef navitMethods[]={
- {"attr", attr_new_py, METH_VARARGS},
- {"coord", coord_new_py, METH_VARARGS, "Create a new coordinate point."},
- {"coord_rect", coord_rect_new_py, METH_VARARGS, "Create a new coordinate rectangle."},
- {"map", map_new_py, METH_VARARGS, "Create a new map."},
- {"mapset", mapset_new_py, METH_VARARGS, "Create a new mapset."},
- {"config_load", config_load_py, METH_VARARGS, "Load a config"},
- {"config", config_py, METH_VARARGS, "Get Config Object"},
- {"pcoord", pcoord_py, METH_VARARGS},
- {NULL, NULL, 0, NULL}
+static PyMethodDef navitMethods[]= {
+ {"attr", attr_new_py, METH_VARARGS},
+ {"coord", coord_new_py, METH_VARARGS, "Create a new coordinate point."},
+ {"coord_rect", coord_rect_new_py, METH_VARARGS, "Create a new coordinate rectangle."},
+ {"map", map_new_py, METH_VARARGS, "Create a new map."},
+ {"mapset", mapset_new_py, METH_VARARGS, "Create a new mapset."},
+ {"config_load", config_load_py, METH_VARARGS, "Load a config"},
+ {"config", config_py, METH_VARARGS, "Get Config Object"},
+ {"pcoord", pcoord_py, METH_VARARGS},
+ {NULL, NULL, 0, NULL}
};
-PyObject *
-python_object_from_attr(struct attr *attr)
-{
- switch (attr->type) {
- case attr_navigation:
- return navigation_py_ref(attr->u.navigation);
- case attr_route:
- return route_py_ref(attr->u.route);
- default:
- return NULL;
- }
- return NULL;
+PyObject *python_object_from_attr(struct attr *attr) {
+ switch (attr->type) {
+ case attr_navigation:
+ return navigation_py_ref(attr->u.navigation);
+ case attr_route:
+ return route_py_ref(attr->u.route);
+ default:
+ return NULL;
+ }
+ return NULL;
}
-void
-plugin_init(void)
-{
- int fd,size;
- char buffer[65536];
-
- Py_Initialize();
- Py_InitModule("navit", navitMethods);
- fd=open("startup.py",O_RDONLY);
- if (fd >= 0) {
- size=read(fd, buffer, 65535);
- if (size > 0) {
- buffer[size]='\0';
- PyRun_SimpleString(buffer);
- }
- }
-
- Py_Finalize();
+void plugin_init(void) {
+ int fd,size;
+ char buffer[65536];
+
+ Py_Initialize();
+ Py_InitModule("navit", navitMethods);
+ fd=open("startup.py",O_RDONLY);
+ if (fd >= 0) {
+ size=read(fd, buffer, 65535);
+ if (size > 0) {
+ buffer[size]='\0';
+ PyRun_SimpleString(buffer);
+ }
+ }
+
+ Py_Finalize();
}
diff --git a/navit/binding/python/config.c b/navit/binding/python/config.c
index c3f04c4df..5115844a8 100644
--- a/navit/binding/python/config.c
+++ b/navit/binding/python/config.c
@@ -22,52 +22,44 @@
#include "config_.h"
typedef struct {
- PyObject_HEAD
+ PyObject_HEAD
} configObject;
-static PyObject *
-config_navit(PyObject *self, PyObject *args)
-{
- struct attr navit;
- if (config_get_attr(config, attr_navit, &navit, NULL))
- return navit_py_ref(navit.u.navit);
- return NULL;
+static PyObject *config_navit(PyObject *self, PyObject *args) {
+ struct attr navit;
+ if (config_get_attr(config, attr_navit, &navit, NULL))
+ return navit_py_ref(navit.u.navit);
+ return NULL;
}
static PyMethodDef config_methods[] = {
- {"navit", (PyCFunction) config_navit, METH_VARARGS },
- {NULL, NULL },
+ {"navit", (PyCFunction) config_navit, METH_VARARGS },
+ {NULL, NULL },
};
-static PyObject *
-config_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(config_methods, self, name);
+static PyObject *config_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(config_methods, self, name);
}
-static void
-config_destroy_py(configObject *self)
-{
+static void config_destroy_py(configObject *self) {
}
PyTypeObject config_Type = {
- Obj_HEAD
- .tp_name="config",
- .tp_basicsize=sizeof(configObject),
- .tp_dealloc=(destructor)config_destroy_py,
- .tp_getattr=config_getattr_py,
+ Obj_HEAD
+ .tp_name="config",
+ .tp_basicsize=sizeof(configObject),
+ .tp_dealloc=(destructor)config_destroy_py,
+ .tp_getattr=config_getattr_py,
};
-PyObject *
-config_py(PyObject *self, PyObject *args)
-{
- configObject *ret;
+PyObject *config_py(PyObject *self, PyObject *args) {
+ configObject *ret;
- dbg(lvl_debug,"enter\n");
- ret=PyObject_NEW(configObject, &config_Type);
- return (PyObject *)ret;
+ dbg(lvl_debug,"enter");
+ ret=PyObject_NEW(configObject, &config_Type);
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/navigation.c b/navit/binding/python/navigation.c
index 75a421d52..b5030b731 100644
--- a/navit/binding/python/navigation.c
+++ b/navit/binding/python/navigation.c
@@ -21,62 +21,52 @@
#include "navigation.h"
typedef struct {
- PyObject_HEAD
- struct navigation *navigation;
+ PyObject_HEAD
+ struct navigation *navigation;
} navigationObject;
-static PyObject *
-navigation_get_map_py(navigationObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
- return map_py_ref(navigation_get_map(self->navigation));
+static PyObject *navigation_get_map_py(navigationObject *self, PyObject *args) {
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ return map_py_ref(navigation_get_map(self->navigation));
}
static PyMethodDef navigation_methods[] = {
- {"get_map", (PyCFunction) navigation_get_map_py, METH_VARARGS },
- {NULL, NULL },
+ {"get_map", (PyCFunction) navigation_get_map_py, METH_VARARGS },
+ {NULL, NULL },
};
-static PyObject *
-navigation_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(navigation_methods, self, name);
+static PyObject *navigation_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(navigation_methods, self, name);
}
-static void
-navigation_destroy_py(navigationObject *self)
-{
+static void navigation_destroy_py(navigationObject *self) {
}
PyTypeObject navigation_Type = {
- Obj_HEAD
- .tp_name="navigation",
- .tp_basicsize=sizeof(navigationObject),
- .tp_dealloc=(destructor)navigation_destroy_py,
- .tp_getattr=navigation_getattr_py,
+ Obj_HEAD
+ .tp_name="navigation",
+ .tp_basicsize=sizeof(navigationObject),
+ .tp_dealloc=(destructor)navigation_destroy_py,
+ .tp_getattr=navigation_getattr_py,
};
-PyObject *
-navigation_py(PyObject *self, PyObject *args)
-{
- navigationObject *ret;
+PyObject *navigation_py(PyObject *self, PyObject *args) {
+ navigationObject *ret;
- ret=PyObject_NEW(navigationObject, &navigation_Type);
- return (PyObject *)ret;
+ ret=PyObject_NEW(navigationObject, &navigation_Type);
+ return (PyObject *)ret;
}
-PyObject *
-navigation_py_ref(struct navigation *navigation)
-{
- navigationObject *ret;
+PyObject *navigation_py_ref(struct navigation *navigation) {
+ navigationObject *ret;
- ret=PyObject_NEW(navigationObject, &navigation_Type);
- ret->navigation=navigation;
- return (PyObject *)ret;
+ ret=PyObject_NEW(navigationObject, &navigation_Type);
+ ret->navigation=navigation;
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/navit.c b/navit/binding/python/navit.c
index 2fde44cbe..38248b74b 100644
--- a/navit/binding/python/navit.c
+++ b/navit/binding/python/navit.c
@@ -22,125 +22,105 @@
#include "navit.h"
typedef struct {
- PyObject_HEAD
- struct navit *navit;
+ PyObject_HEAD
+ struct navit *navit;
} navitObject;
-static PyObject *
-navit_set_attr_py(navitObject *self, PyObject *args)
-{
- PyObject *attr;
- if (!PyArg_ParseTuple(args, "O!", &attr_Type, &attr))
- return NULL;
- navit_set_attr(self->navit, attr_py_get(attr));
- Py_RETURN_NONE;
+static PyObject *navit_set_attr_py(navitObject *self, PyObject *args) {
+ PyObject *attr;
+ if (!PyArg_ParseTuple(args, "O!", &attr_Type, &attr))
+ return NULL;
+ navit_set_attr(self->navit, attr_py_get(attr));
+ Py_RETURN_NONE;
}
-static PyObject *
-navit_get_attr_py(navitObject *self, PyObject *args)
-{
- char *name;
- struct attr attr;
- if (!PyArg_ParseTuple(args, "s", &name))
- return NULL;
- if (!navit_get_attr(self->navit, attr_from_name(name), &attr, NULL)) {
- dbg(lvl_error,"get_attr not ok\n");
- Py_RETURN_NONE;
- }
- dbg(lvl_debug,"get_attr ok\n");
- return python_object_from_attr(&attr);
+static PyObject *navit_get_attr_py(navitObject *self, PyObject *args) {
+ char *name;
+ struct attr attr;
+ if (!PyArg_ParseTuple(args, "s", &name))
+ return NULL;
+ if (!navit_get_attr(self->navit, attr_from_name(name), &attr, NULL)) {
+ dbg(lvl_error,"get_attr not ok");
+ Py_RETURN_NONE;
+ }
+ dbg(lvl_debug,"get_attr ok");
+ return python_object_from_attr(&attr);
}
-static PyObject *
-navit_set_center_py(navitObject *self, PyObject *args)
-{
- PyObject *pcoord;
- if (!PyArg_ParseTuple(args, "O!", &pcoord_Type, &pcoord))
- return NULL;
- navit_set_center(self->navit, pcoord_py_get(pcoord), 0);
- Py_RETURN_NONE;
+static PyObject *navit_set_center_py(navitObject *self, PyObject *args) {
+ PyObject *pcoord;
+ if (!PyArg_ParseTuple(args, "O!", &pcoord_Type, &pcoord))
+ return NULL;
+ navit_set_center(self->navit, pcoord_py_get(pcoord), 0);
+ Py_RETURN_NONE;
}
-static PyObject *
-navit_set_destination_py(navitObject *self, PyObject *args)
-{
- PyObject *pcoord;
- const char *description;
- int async;
- if (!PyArg_ParseTuple(args, "O!si", &pcoord_Type, &pcoord, &description, &async))
- return NULL;
- navit_set_destination(self->navit, pcoord_py_get(pcoord), description, async);
- Py_RETURN_NONE;
+static PyObject *navit_set_destination_py(navitObject *self, PyObject *args) {
+ PyObject *pcoord;
+ const char *description;
+ int async;
+ if (!PyArg_ParseTuple(args, "O!si", &pcoord_Type, &pcoord, &description, &async))
+ return NULL;
+ navit_set_destination(self->navit, pcoord_py_get(pcoord), description, async);
+ Py_RETURN_NONE;
}
-static PyObject *
-navit_set_position_py(navitObject *self, PyObject *args)
-{
- PyObject *pcoord;
- if (!PyArg_ParseTuple(args, "O!", &pcoord_Type, &pcoord))
- return NULL;
- navit_set_position(self->navit, pcoord_py_get(pcoord));
- Py_RETURN_NONE;
+static PyObject *navit_set_position_py(navitObject *self, PyObject *args) {
+ PyObject *pcoord;
+ if (!PyArg_ParseTuple(args, "O!", &pcoord_Type, &pcoord))
+ return NULL;
+ navit_set_position(self->navit, pcoord_py_get(pcoord));
+ Py_RETURN_NONE;
}
-static PyObject *
-navit_zoom_to_route_py(navitObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
- navit_zoom_to_route(self->navit,0);
- Py_RETURN_NONE;
+static PyObject *navit_zoom_to_route_py(navitObject *self, PyObject *args) {
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ navit_zoom_to_route(self->navit,0);
+ Py_RETURN_NONE;
}
static PyMethodDef navit_methods[] = {
- {"set_attr", (PyCFunction) navit_set_attr_py, METH_VARARGS },
- {"get_attr", (PyCFunction) navit_get_attr_py, METH_VARARGS },
- {"set_center", (PyCFunction) navit_set_center_py, METH_VARARGS },
- {"set_destination", (PyCFunction) navit_set_destination_py, METH_VARARGS },
- {"set_position", (PyCFunction) navit_set_position_py, METH_VARARGS },
- {"zoom_to_route", (PyCFunction) navit_zoom_to_route_py, METH_VARARGS },
- {NULL, NULL },
+ {"set_attr", (PyCFunction) navit_set_attr_py, METH_VARARGS },
+ {"get_attr", (PyCFunction) navit_get_attr_py, METH_VARARGS },
+ {"set_center", (PyCFunction) navit_set_center_py, METH_VARARGS },
+ {"set_destination", (PyCFunction) navit_set_destination_py, METH_VARARGS },
+ {"set_position", (PyCFunction) navit_set_position_py, METH_VARARGS },
+ {"zoom_to_route", (PyCFunction) navit_zoom_to_route_py, METH_VARARGS },
+ {NULL, NULL },
};
-static PyObject *
-navit_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(navit_methods, self, name);
+static PyObject *navit_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(navit_methods, self, name);
}
-static void
-navit_destroy_py(navitObject *self)
-{
+static void navit_destroy_py(navitObject *self) {
}
PyTypeObject navit_Type = {
- Obj_HEAD
- .tp_name="navit",
- .tp_basicsize=sizeof(navitObject),
- .tp_dealloc=(destructor)navit_destroy_py,
- .tp_getattr=navit_getattr_py,
+ Obj_HEAD
+ .tp_name="navit",
+ .tp_basicsize=sizeof(navitObject),
+ .tp_dealloc=(destructor)navit_destroy_py,
+ .tp_getattr=navit_getattr_py,
};
-PyObject *
-navit_py(PyObject *self, PyObject *args)
-{
- navitObject *ret;
+PyObject *navit_py(PyObject *self, PyObject *args) {
+ navitObject *ret;
- dbg(lvl_debug,"enter\n");
- ret=PyObject_NEW(navitObject, &navit_Type);
- return (PyObject *)ret;
+ dbg(lvl_debug,"enter");
+ ret=PyObject_NEW(navitObject, &navit_Type);
+ return (PyObject *)ret;
}
-PyObject *
-navit_py_ref(struct navit *navit)
-{
- dbg(lvl_debug,"navit=%p\n", navit);
- navitObject *ret=PyObject_NEW(navitObject, &navit_Type);
- ret->navit=navit;
- return (PyObject *)ret;
+PyObject *navit_py_ref(struct navit *navit) {
+ dbg(lvl_debug,"navit=%p", navit);
+ navitObject *ret=PyObject_NEW(navitObject, &navit_Type);
+ ret->navit=navit;
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/pcoord.c b/navit/binding/python/pcoord.c
index 4fe734a70..0c8d959fe 100644
--- a/navit/binding/python/pcoord.c
+++ b/navit/binding/python/pcoord.c
@@ -21,68 +21,59 @@
#include "coord.h"
typedef struct {
- PyObject_HEAD
- struct pcoord pc;
+ PyObject_HEAD
+ struct pcoord pc;
} pcoordObject;
-static PyObject *
-pcoord_func(pcoordObject *self, PyObject *args)
-{
- const char *file;
- int ret=0;
- if (!PyArg_ParseTuple(args, "s", &file))
- return NULL;
- return Py_BuildValue("i",ret);
+static PyObject *pcoord_func(pcoordObject *self, PyObject *args) {
+ const char *file;
+ int ret=0;
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return NULL;
+ return Py_BuildValue("i",ret);
}
static PyMethodDef pcoord_methods[] = {
- {"func", (PyCFunction) pcoord_func, METH_VARARGS },
- {NULL, NULL },
+ {"func", (PyCFunction) pcoord_func, METH_VARARGS },
+ {NULL, NULL },
};
-static PyObject *
-pcoord_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(pcoord_methods, self, name);
+static PyObject *pcoord_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(pcoord_methods, self, name);
}
-static void
-pcoord_destroy_py(pcoordObject *self)
-{
+static void pcoord_destroy_py(pcoordObject *self) {
}
PyTypeObject pcoord_Type = {
- Obj_HEAD
- .tp_name="pcoord",
- .tp_basicsize=sizeof(pcoordObject),
- .tp_dealloc=(destructor)pcoord_destroy_py,
- .tp_getattr=pcoord_getattr_py,
+ Obj_HEAD
+ .tp_name="pcoord",
+ .tp_basicsize=sizeof(pcoordObject),
+ .tp_dealloc=(destructor)pcoord_destroy_py,
+ .tp_getattr=pcoord_getattr_py,
};
-PyObject *
-pcoord_py(PyObject *self, PyObject *args)
-{
- pcoordObject *ret;
- const char *str;
- enum projection pro;
- struct coord c;
- if (!PyArg_ParseTuple(args, "si", &str, &pro))
- return NULL;
- ret=PyObject_NEW(pcoordObject, &pcoord_Type);
- coord_parse(str, pro, &c);
- ret->pc.pro=pro;
- ret->pc.x=c.x;
- ret->pc.y=c.y;
- dbg(lvl_debug,"0x%x,0x%x\n", c.x, c.y);
- return (PyObject *)ret;
+PyObject *pcoord_py(PyObject *self, PyObject *args) {
+ pcoordObject *ret;
+ const char *str;
+ enum projection pro;
+ struct coord c;
+ if (!PyArg_ParseTuple(args, "si", &str, &pro))
+ return NULL;
+ ret=PyObject_NEW(pcoordObject, &pcoord_Type);
+ coord_parse(str, pro, &c);
+ ret->pc.pro=pro;
+ ret->pc.x=c.x;
+ ret->pc.y=c.y;
+ dbg(lvl_debug,"0x%x,0x%x", c.x, c.y);
+ return (PyObject *)ret;
}
struct pcoord *
-pcoord_py_get(PyObject *self)
-{
- return &((pcoordObject *)self)->pc;
+pcoord_py_get(PyObject *self) {
+ return &((pcoordObject *)self)->pc;
}
diff --git a/navit/binding/python/route.c b/navit/binding/python/route.c
index dfbd08cf9..3aaff8157 100644
--- a/navit/binding/python/route.c
+++ b/navit/binding/python/route.c
@@ -23,62 +23,52 @@
#include "route.h"
typedef struct {
- PyObject_HEAD
- struct route *route;
+ PyObject_HEAD
+ struct route *route;
} routeObject;
-static PyObject *
-route_get_map_py(routeObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ""))
- return NULL;
- return map_py_ref(route_get_map(self->route));
+static PyObject *route_get_map_py(routeObject *self, PyObject *args) {
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+ return map_py_ref(route_get_map(self->route));
}
static PyMethodDef route_methods[] = {
- {"get_map", (PyCFunction) route_get_map_py, METH_VARARGS },
- {NULL, NULL },
+ {"get_map", (PyCFunction) route_get_map_py, METH_VARARGS },
+ {NULL, NULL },
};
-static PyObject *
-route_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(route_methods, self, name);
+static PyObject *route_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(route_methods, self, name);
}
-static void
-route_destroy_py(routeObject *self)
-{
+static void route_destroy_py(routeObject *self) {
}
PyTypeObject route_Type = {
- Obj_HEAD
- .tp_name="route",
- .tp_basicsize=sizeof(routeObject),
- .tp_dealloc=(destructor)route_destroy_py,
- .tp_getattr=route_getattr_py,
+ Obj_HEAD
+ .tp_name="route",
+ .tp_basicsize=sizeof(routeObject),
+ .tp_dealloc=(destructor)route_destroy_py,
+ .tp_getattr=route_getattr_py,
};
-PyObject *
-route_py(PyObject *self, PyObject *args)
-{
- routeObject *ret;
+PyObject *route_py(PyObject *self, PyObject *args) {
+ routeObject *ret;
- ret=PyObject_NEW(routeObject, &route_Type);
- return (PyObject *)ret;
+ ret=PyObject_NEW(routeObject, &route_Type);
+ return (PyObject *)ret;
}
-PyObject *
-route_py_ref(struct route *route)
-{
- routeObject *ret;
+PyObject *route_py_ref(struct route *route) {
+ routeObject *ret;
- ret=PyObject_NEW(routeObject, &route_Type);
- ret->route=route;
- return (PyObject *)ret;
+ ret=PyObject_NEW(routeObject, &route_Type);
+ ret->route=route;
+ return (PyObject *)ret;
}
diff --git a/navit/binding/python/startup.py b/navit/binding/python/startup.py
index f8e801551..272a78a2f 100644
--- a/navit/binding/python/startup.py
+++ b/navit/binding/python/startup.py
@@ -1,8 +1,8 @@
import navit
navit.config_load("navit.xml.local")
-pos=navit.pcoord("5023.7493 N 00730.2898 E",1);
-dest=navit.pcoord("5023.6604 N 00729.8500 E",1);
-inst=navit.config().navit();
-inst.set_position(pos);
-inst.set_destination(dest,"Test");
-inst.set_center(pos);
+pos=navit.pcoord("5023.7493 N 00730.2898 E",1)
+dest=navit.pcoord("5023.6604 N 00729.8500 E",1)
+inst=navit.config().navit()
+inst.set_position(pos)
+inst.set_destination(dest,"Test")
+inst.set_center(pos)
diff --git a/navit/binding/python/template.c b/navit/binding/python/template.c
index 088cb5ee3..69a3e7265 100644
--- a/navit/binding/python/template.c
+++ b/navit/binding/python/template.c
@@ -21,76 +21,65 @@
#include "template.h"
typedef struct {
- PyObject_HEAD
- int ref;
- struct template *template;
+ PyObject_HEAD
+ int ref;
+ struct template *template;
} templateObject;
-static PyObject *
-template_func(templateObject *self, PyObject *args)
-{
- const char *file;
- int ret;
- if (!PyArg_ParseTuple(args, "s", &file))
- return NULL;
- ret=0;
- return Py_BuildValue("i",ret);
+static PyObject *template_func(templateObject *self, PyObject *args) {
+ const char *file;
+ int ret;
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return NULL;
+ ret=0;
+ return Py_BuildValue("i",ret);
}
static PyMethodDef template_methods[] = {
- {"func", (PyCFunction) template_func, METH_VARARGS },
- {NULL, NULL },
+ {"func", (PyCFunction) template_func, METH_VARARGS },
+ {NULL, NULL },
};
-static PyObject *
-template_getattr_py(PyObject *self, char *name)
-{
- return Py_FindMethod(template_methods, self, name);
+static PyObject *template_getattr_py(PyObject *self, char *name) {
+ return Py_FindMethod(template_methods, self, name);
}
-static void
-template_destroy_py(templateObject *self)
-{
- if (! self->ref)
- template_destroy(self->template);
+static void template_destroy_py(templateObject *self) {
+ if (! self->ref)
+ template_destroy(self->template);
}
PyTypeObject template_Type = {
- Obj_HEAD
- .tp_name="template",
- .tp_basicsize=sizeof(templateObject),
- .tp_dealloc=(destructor)template_destroy_py,
- .tp_getattr=template_getattr_py,
+ Obj_HEAD
+ .tp_name="template",
+ .tp_basicsize=sizeof(templateObject),
+ .tp_dealloc=(destructor)template_destroy_py,
+ .tp_getattr=template_getattr_py,
};
struct template *
-template_py_get(PyObject *self)
-{
- return ((templateObject *)self)->template;
+template_py_get(PyObject *self) {
+ return ((templateObject *)self)->template;
}
-PyObject *
-template_new_py(PyObject *self, PyObject *args)
-{
- templateObject *ret;
+PyObject *template_new_py(PyObject *self, PyObject *args) {
+ templateObject *ret;
- ret=PyObject_NEW(templateObject, &template_Type);
- ret->template=template_new();
- ret->ref=0;
- return (PyObject *)ret;
+ ret=PyObject_NEW(templateObject, &template_Type);
+ ret->template=template_new();
+ ret->ref=0;
+ return (PyObject *)ret;
}
-PyObject *
-template_new_py_ref(struct template *template)
-{
- templateObject *ret;
+PyObject *template_new_py_ref(struct template *template) {
+ templateObject *ret;
- ret=PyObject_NEW(templateObject, &template_Type);
- ret->ref=1;
- ret->template=template;
- return (PyObject *)ret;
+ ret=PyObject_NEW(templateObject, &template_Type);
+ ret->ref=1;
+ ret->template=template;
+ return (PyObject *)ret;
}
diff --git a/navit/binding/win32/CMakeLists.txt b/navit/binding/win32/CMakeLists.txt
index 792a8ff43..37f81aec7 100644
--- a/navit/binding/win32/CMakeLists.txt
+++ b/navit/binding/win32/CMakeLists.txt
@@ -1,9 +1,9 @@
if (USE_LIBGNUINTL AND NOT HAVE_GLIB)
- ADD_DEPENDENCIES(support_glib intl_cmake)
+ ADD_DEPENDENCIES(support_glib support_gettext_intl)
endif()
-module_add_library(binding_win32 binding_win32.c)
+module_add_library(binding_win32 binding_win32.c)
add_executable(tell_navit tell_navit.c)
-target_link_libraries(tell_navit ${MODULES_NAME} ${NAVIT_SUPPORT_LIBS} fib ${NAVIT_LIBS} )
+target_link_libraries(tell_navit ${MODULES_NAME} ${NAVIT_SUPPORT_LIBS} fib ${NAVIT_LIBS} )
install(TARGETS tell_navit DESTINATION ${BIN_DIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
diff --git a/navit/binding/win32/binding_win32.c b/navit/binding/win32/binding_win32.c
index c6d3295cc..6ff0af9c0 100644
--- a/navit/binding/win32/binding_win32.c
+++ b/navit/binding/win32/binding_win32.c
@@ -49,97 +49,90 @@
#include "binding_win32.h"
struct win32_binding_private {
- struct navit* navit;
+ struct navit* navit;
};
/* TODO: do something meaningful here
- *
+ *
*/
-static int
-win32_cmd_send_signal(struct navit *navit, char *command, struct attr **in, struct attr ***out)
-{
- dbg(lvl_error,"this function is a stub\n");
- if (in) {
- while (*in) {
- dbg(lvl_debug,"another attribute to be sent\n");
- in++;
- }
- }
- return 0;
+static int win32_cmd_send_signal(struct navit *navit, char *command, struct attr **in, struct attr ***out) {
+ dbg(lvl_error,"this function is a stub");
+ if (in) {
+ while (*in) {
+ dbg(lvl_debug,"another attribute to be sent");
+ in++;
+ }
+ }
+ return 0;
}
static struct command_table commands[] = {
- {"win32_send",command_cast(win32_cmd_send_signal)},
+ {"win32_send",command_cast(win32_cmd_send_signal)},
};
-static void
-win32_wm_copydata(struct win32_binding_private *this, int *hwndSender, COPYDATASTRUCT *cpd)
-{
- struct attr navit;
- struct navit_binding_w32_msg *msg;
- navit.type=attr_navit;
- navit.u.navit=this->navit;
- if(cpd->dwData!=NAVIT_BINDING_W32_DWDATA) {
- dbg(lvl_error,"COPYDATA message came with wrong DWDATA value, expected %d, got %d.\n",NAVIT_BINDING_W32_DWDATA,cpd->dwData);
- return;
- }
- if(cpd->cbData<sizeof(*msg)) {
- dbg(lvl_error,"COPYDATA message too short, expected >=%d, got %d.\n",sizeof(*msg),cpd->cbData);
- return;
- }
- msg=cpd->lpData;
- if(cpd->dwData!=NAVIT_BINDING_W32_VERSION) {
- dbg(lvl_error,"Got request with wrong version number, expected %d, got %d.\n",NAVIT_BINDING_W32_VERSION,msg->version);
- return;
- }
- if(strcmp(NAVIT_BINDING_W32_MAGIC,msg->magic)) {
- dbg(lvl_error,"Got request with wrong MAGIC, expected %s, got %*s.\n",NAVIT_BINDING_W32_MAGIC, msg->magic,sizeof(msg->magic));
- return;
- }
- dbg(lvl_debug,"Running command %s\n", msg->text);
- command_evaluate(&navit, msg->text);
+static void win32_wm_copydata(struct win32_binding_private *this, int *hwndSender, COPYDATASTRUCT *cpd) {
+ struct attr navit;
+ struct navit_binding_w32_msg *msg;
+ navit.type=attr_navit;
+ navit.u.navit=this->navit;
+ if(cpd->dwData!=NAVIT_BINDING_W32_DWDATA) {
+ dbg(lvl_error,"COPYDATA message came with wrong DWDATA value, expected %d, got %d.",NAVIT_BINDING_W32_DWDATA,
+ cpd->dwData);
+ return;
+ }
+ if(cpd->cbData<sizeof(*msg)) {
+ dbg(lvl_error,"COPYDATA message too short, expected >=%d, got %d.",sizeof(*msg),cpd->cbData);
+ return;
+ }
+ msg=cpd->lpData;
+ if(cpd->dwData!=NAVIT_BINDING_W32_VERSION) {
+ dbg(lvl_error,"Got request with wrong version number, expected %d, got %d.",NAVIT_BINDING_W32_VERSION,msg->version);
+ return;
+ }
+ if(strcmp(NAVIT_BINDING_W32_MAGIC,msg->magic)) {
+ dbg(lvl_error,"Got request with wrong MAGIC, expected %s, got %*s.",NAVIT_BINDING_W32_MAGIC, msg->magic,
+ sizeof(msg->magic));
+ return;
+ }
+ dbg(lvl_debug,"Running command %s", msg->text);
+ command_evaluate(&navit, msg->text);
}
-static void
-win32_cb_graphics_ready(struct win32_binding_private *this, struct navit *navit)
-{
- struct graphics *gra;
- struct callback *gcb;
+static void win32_cb_graphics_ready(struct win32_binding_private *this, struct navit *navit) {
+ struct graphics *gra;
+ struct callback *gcb;
- gcb=callback_new_attr_1(callback_cast(win32_wm_copydata),attr_wm_copydata, this);
- gra=navit_get_graphics(navit);
- dbg_assert(gra);
- graphics_add_callback(gra, gcb);
+ gcb=callback_new_attr_1(callback_cast(win32_wm_copydata),attr_wm_copydata, this);
+ gra=navit_get_graphics(navit);
+ dbg_assert(gra);
+ graphics_add_callback(gra, gcb);
}
-static void
-win32_main_navit(struct win32_binding_private *this, struct navit *navit, int added)
-{
- struct attr attr;
- dbg(lvl_debug,"enter\n");
- if (added==1) {
- dbg(lvl_debug,"enter2\n");
- this->navit=navit;
- command_add_table_attr(commands, sizeof(commands)/sizeof(struct command_table), navit, &attr);
- navit_add_attr(navit, &attr);
- navit_add_callback(navit,callback_new_attr_1(callback_cast(win32_cb_graphics_ready),attr_graphics_ready, this));
- }
+static void win32_main_navit(struct win32_binding_private *this, struct navit *navit, int added) {
+ struct attr attr;
+ dbg(lvl_debug,"enter");
+ if (added==1) {
+ dbg(lvl_debug,"enter2");
+ this->navit=navit;
+ command_add_table_attr(commands, sizeof(commands)/sizeof(struct command_table), navit, &attr);
+ navit_add_attr(navit, &attr);
+ navit_add_callback(navit,callback_new_attr_1(callback_cast(win32_cb_graphics_ready),attr_graphics_ready, this));
+ }
}
-void plugin_init(void)
-{
- struct attr callback;
- struct win32_binding_private *this=g_new0(struct win32_binding_private,1);
- dbg(lvl_debug,"enter\n");
- callback.type=attr_callback;
- callback.u.callback=callback_new_attr_1(callback_cast(win32_main_navit),attr_navit,this);
- config_add_attr(config, &callback);
+void plugin_init(void) {
+ struct attr callback;
+ struct win32_binding_private *this=g_new0(struct win32_binding_private,1);
+ dbg(lvl_debug,"enter");
+ callback.type=attr_callback;
+ callback.u.callback=callback_new_attr_1(callback_cast(win32_main_navit),attr_navit,this);
+ config_add_attr(config, &callback);
}
diff --git a/navit/binding/win32/tell_navit.c b/navit/binding/win32/tell_navit.c
index e06f73258..f99319f92 100644
--- a/navit/binding/win32/tell_navit.c
+++ b/navit/binding/win32/tell_navit.c
@@ -29,151 +29,146 @@
#include <glib.h>
#include "binding_win32.h"
-static LRESULT CALLBACK message_handler( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
-{
- switch(uMsg) {
- case WM_CREATE:
- return 0;
- }
- return TRUE;
+static LRESULT CALLBACK message_handler( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
+ switch(uMsg) {
+ case WM_CREATE:
+ return 0;
+ }
+ return TRUE;
}
int errormode=1;
-void err(char *fmt, ...)
-{
- va_list ap;
- char buf[1024];
+void err(char *fmt, ...) {
+ va_list ap;
+ char buf[1024];
#if defined HAVE_API_WIN32_CE
#define vsnprintf _vsnprintf
#endif
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- switch(errormode) {
- case 0: /* be silent */
- break;
- case 1:
- MessageBox(NULL, buf, "tell_navit", MB_ICONERROR|MB_OK);
- break;
- case 2:
- fprintf(stderr,"%s",buf);
- break;
- }
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ switch(errormode) {
+ case 0: /* be silent */
+ break;
+ case 1:
+ MessageBox(NULL, buf, "tell_navit", MB_ICONERROR|MB_OK);
+ break;
+ case 2:
+ fprintf(stderr,"%s",buf);
+ break;
+ }
}
-void print_usage(void)
-{
- err(
- "tell_navit usage:\n"
- "tell_navit [options] navit_command\n"
- "\t-h this help\n"
- "\t-e <way>: set way to report error messages:\n"
- "\t\t0 - suppress messages\n"
- "\t\t1 - use messagebox (default)\n"
- "\t\t2 - print to stderr\n"
- );
+void print_usage(void) {
+ err(
+ "tell_navit usage:\n"
+ "tell_navit [options] navit_command\n"
+ "\t-h this help\n"
+ "\t-e <way>: set way to report error messages:\n"
+ "\t\t0 - suppress messages\n"
+ "\t\t1 - use messagebox (default)\n"
+ "\t\t2 - print to stderr\n"
+ );
}
-int main(int argc, char **argv)
-{
- HWND navitWindow;
- COPYDATASTRUCT cd;
- char opt;
-
- TCHAR *g_szClassName = TEXT("TellNavitWND");
- WNDCLASS wc;
- HWND hwnd;
- HWND hWndParent=NULL;
-
-
- if(argc>0) {
- while((opt = getopt(argc, argv, ":hvc:d:e:s:")) != -1) {
- switch(opt){
- case 'h':
- print_usage();
- exit(0);
- break;
- case 'e':
- errormode=atoi(optarg);
- break;
- default:
- err("Unknown option %c\n", opt);
- exit(1);
- break;
- }
- }
- } else {
- print_usage();
- exit(1);
- }
- if(optind==argc) {
- err("Navit command to execute is needed.");
- exit(1);
- }
-
-
- memset(&wc, 0 , sizeof(WNDCLASS));
- wc.lpfnWndProc = message_handler;
- wc.hInstance = GetModuleHandle(NULL);
- wc.lpszClassName = g_szClassName;
-
- if (!RegisterClass(&wc))
- {
- err(TEXT("Window class registration failed\n"));
- return 1;
- } else {
- hwnd = CreateWindow(
- g_szClassName,
- TEXT("Tell Navit"),
- 0,
- 0,
- 0,
- 0,
- 0,
- hWndParent,
- NULL,
- GetModuleHandle(NULL),
- NULL);
- if(!hwnd) {
- err(TEXT("Can't create hidden window\n"));
- UnregisterClass(g_szClassName,NULL);
- return 1;
- }
- }
-
- navitWindow=FindWindow( TEXT("NAVGRA"), NULL );
- if(!navitWindow) {
- err(TEXT("Navit window not found\n"));
- DestroyWindow(hwnd);
- UnregisterClass(g_szClassName,NULL);
- return 1;
- } else {
- int rv;
- char *command=g_strjoinv(" ",argv+optind);
- struct navit_binding_w32_msg *msg;
- int sz=sizeof(*msg)+strlen(command);
-
- cd.dwData=NAVIT_BINDING_W32_DWDATA;
- msg=g_malloc0(sz);
- msg->version=NAVIT_BINDING_W32_VERSION;
- g_strlcpy(msg->magic,NAVIT_BINDING_W32_MAGIC,sizeof(msg->magic));
- g_strlcpy(msg->text,command,sz-sizeof(*msg)+1);
- cd.cbData=sz;
- cd.lpData=msg;
- rv=SendMessage( navitWindow, WM_COPYDATA, (WPARAM)hwnd, (LPARAM) (LPVOID) &cd );
- g_free(command);
- g_free(msg);
- if(rv!=0) {
- err(TEXT("Error %d sending message, SendMessage return value is %d\n"), GetLastError(), rv);
- DestroyWindow(hwnd);
- UnregisterClass(g_szClassName,NULL);
- return 1;
- }
- }
- DestroyWindow(hwnd);
- UnregisterClass(g_szClassName,NULL);
- return 0;
+int main(int argc, char **argv) {
+ HWND navitWindow;
+ COPYDATASTRUCT cd;
+ char opt;
+
+ TCHAR *g_szClassName = TEXT("TellNavitWND");
+ WNDCLASS wc;
+ HWND hwnd;
+ HWND hWndParent=NULL;
+
+
+ if(argc>0) {
+ while((opt = getopt(argc, argv, ":hvc:d:e:s:")) != -1) {
+ switch(opt) {
+ case 'h':
+ print_usage();
+ exit(0);
+ break;
+ case 'e':
+ errormode=atoi(optarg);
+ break;
+ default:
+ err("Unknown option %c\n", opt);
+ exit(1);
+ break;
+ }
+ }
+ } else {
+ print_usage();
+ exit(1);
+ }
+ if(optind==argc) {
+ err("Navit command to execute is needed.");
+ exit(1);
+ }
+
+
+ memset(&wc, 0, sizeof(WNDCLASS));
+ wc.lpfnWndProc = message_handler;
+ wc.hInstance = GetModuleHandle(NULL);
+ wc.lpszClassName = g_szClassName;
+
+ if (!RegisterClass(&wc)) {
+ err(TEXT("Window class registration failed\n"));
+ return 1;
+ } else {
+ hwnd = CreateWindow(
+ g_szClassName,
+ TEXT("Tell Navit"),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ hWndParent,
+ NULL,
+ GetModuleHandle(NULL),
+ NULL);
+ if(!hwnd) {
+ err(TEXT("Can't create hidden window\n"));
+ UnregisterClass(g_szClassName,NULL);
+ return 1;
+ }
+ }
+
+ navitWindow=FindWindow( TEXT("NAVGRA"), NULL );
+ if(!navitWindow) {
+ err(TEXT("Navit window not found\n"));
+ DestroyWindow(hwnd);
+ UnregisterClass(g_szClassName,NULL);
+ return 1;
+ } else {
+ int rv;
+ char *command=g_strjoinv(" ",argv+optind);
+ struct navit_binding_w32_msg *msg;
+ int sz=sizeof(*msg)+strlen(command);
+
+ cd.dwData=NAVIT_BINDING_W32_DWDATA;
+ msg=g_malloc0(sz);
+ msg->version=NAVIT_BINDING_W32_VERSION;
+ g_strlcpy(msg->magic,NAVIT_BINDING_W32_MAGIC,sizeof(msg->magic));
+ g_strlcpy(msg->text,command,sz-sizeof(*msg)+1);
+ cd.cbData=sz;
+ cd.lpData=msg;
+ rv=SendMessage( navitWindow, WM_COPYDATA, (WPARAM)hwnd, (LPARAM) (LPVOID) &cd );
+ g_free(command);
+ g_free(msg);
+ if(rv!=0) {
+ err(TEXT("Error %d sending message, SendMessage return value is %d\n"), GetLastError(), rv);
+ DestroyWindow(hwnd);
+ UnregisterClass(g_szClassName,NULL);
+ return 1;
+ }
+ }
+ DestroyWindow(hwnd);
+ UnregisterClass(g_szClassName,NULL);
+ return 0;
}
diff --git a/navit/bookmarks.c b/navit/bookmarks.c
index aa180e947..a3e5c482d 100644
--- a/navit/bookmarks.c
+++ b/navit/bookmarks.c
@@ -41,334 +41,328 @@
/* FIXME: Move this to support directory */
#ifdef _MSC_VER
#include <windows.h>
-static int ftruncate(int fd, __int64 length)
-{
- HANDLE fh = (HANDLE)_get_osfhandle(fd);
- if (!fh || _lseeki64(fd, length, SEEK_SET)) {
- return -1;
- }
- return SetEndOfFile(fh) ? 0 : -1;
+static int ftruncate(int fd, __int64 length) {
+ HANDLE fh = (HANDLE)_get_osfhandle(fd);
+ if (!fh || _lseeki64(fd, length, SEEK_SET)) {
+ return -1;
+ }
+ return SetEndOfFile(fh) ? 0 : -1;
}
#endif /* _MSC_VER */
struct bookmarks {
- //data storage
- struct map *bookmark;
- struct map_rect *mr;
- GHashTable *bookmarks_hash;
- GList *bookmarks_list;
- char* bookmark_file;
- char *working_file;
- struct bookmark_item_priv* clipboard;
- struct bookmark_item_priv* root;
- struct bookmark_item_priv* current;
-
- //Refs to other objects
- struct transformation *trans;
- struct attr **attrs;
- struct callback_list *attr_cbl;
- struct attr *parent;
+ //data storage
+ struct map *bookmark;
+ struct map_rect *mr;
+ GHashTable *bookmarks_hash;
+ GList *bookmarks_list;
+ char* bookmark_file;
+ char *working_file;
+ struct bookmark_item_priv* clipboard;
+ struct bookmark_item_priv* root;
+ struct bookmark_item_priv* current;
+
+ //Refs to other objects
+ struct transformation *trans;
+ struct attr **attrs;
+ struct callback_list *attr_cbl;
+ struct attr *parent;
};
struct bookmark_item_priv {
- char *label;
- enum item_type type;
- struct pcoord c;
- GList *children;
- GList *iter;
- struct bookmark_item_priv *parent;
- struct item item;
+ char *label;
+ enum item_type type;
+ struct pcoord c;
+ GList *children;
+ GList *iter;
+ struct bookmark_item_priv *parent;
+ struct item item;
};
void bookmarks_move_root(struct bookmarks *this_) {
- this_->current=this_->root;
- this_->current->iter=g_list_first(this_->current->children);
- dbg(lvl_info,"Root list have %u entries\n",g_list_length(this_->current->children));
- return;
+ this_->current=this_->root;
+ this_->current->iter=g_list_first(this_->current->children);
+ dbg(lvl_info,"Root list have %u entries",g_list_length(this_->current->children));
+ return;
}
void bookmarks_move_up(struct bookmarks *this_) {
- if (this_->current->parent) {
- this_->current=this_->current->parent;
- this_->current->iter=this_->current->children;
- }
- return;
+ if (this_->current->parent) {
+ this_->current=this_->current->parent;
+ this_->current->iter=this_->current->children;
+ }
+ return;
}
int bookmarks_move_down(struct bookmarks *this_,const char* name) {
- bookmarks_item_rewind(this_);
- if (this_->current->children==NULL) {
- return 0;
- }
- while (this_->current->iter!=NULL) {
- struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
- if (!strcmp(data->label,name)) {
- this_->current=(struct bookmark_item_priv*)this_->current->iter->data;
- this_->current->iter=g_list_first(this_->current->children);
- dbg(lvl_info,"%s list have %u entries\n",this_->current->label,g_list_length(this_->current->children));
- return 1;
- }
- this_->current->iter=g_list_next(this_->current->iter);
- }
- return 0;
+ bookmarks_item_rewind(this_);
+ if (this_->current->children==NULL) {
+ return 0;
+ }
+ while (this_->current->iter!=NULL) {
+ struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
+ if (!strcmp(data->label,name)) {
+ this_->current=(struct bookmark_item_priv*)this_->current->iter->data;
+ this_->current->iter=g_list_first(this_->current->children);
+ dbg(lvl_info,"%s list have %u entries",this_->current->label,g_list_length(this_->current->children));
+ return 1;
+ }
+ this_->current->iter=g_list_next(this_->current->iter);
+ }
+ return 0;
}
void bookmarks_item_rewind(struct bookmarks* this_) {
- this_->current->children=g_list_first(this_->current->children);
- this_->current->iter=this_->current->children;
- this_->current->iter=this_->current->children;
+ this_->current->children=g_list_first(this_->current->children);
+ this_->current->iter=this_->current->children;
+ this_->current->iter=this_->current->children;
}
struct item* bookmarks_get_item(struct bookmarks* this_) {
- struct item item,*ret;
+ struct item item,*ret;
if (this_->current->iter==NULL) {
- return NULL;
- }
+ return NULL;
+ }
- item=((struct bookmark_item_priv*)this_->current->iter->data)->item;
- this_->current->iter=g_list_next(this_->current->iter);
+ item=((struct bookmark_item_priv*)this_->current->iter->data)->item;
+ this_->current->iter=g_list_next(this_->current->iter);
- ret = map_rect_get_item_byid(this_->mr, item.id_hi, item.id_lo);
+ ret = map_rect_get_item_byid(this_->mr, item.id_hi, item.id_lo);
- return ret;
+ return ret;
}
int bookmarks_get_bookmark_count(struct bookmarks* this_) {
- int ret=0;
- bookmarks_item_rewind(this_);
- while (this_->current->iter!=NULL) {
- struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
- if (data->type == type_bookmark) {
- ret++;
- }
- this_->current->iter=g_list_next(this_->current->iter);
- }
- return ret;
+ int ret=0;
+ bookmarks_item_rewind(this_);
+ while (this_->current->iter!=NULL) {
+ struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
+ if (data->type == type_bookmark) {
+ ret++;
+ }
+ this_->current->iter=g_list_next(this_->current->iter);
+ }
+ return ret;
}
const char* bookmarks_item_cwd(struct bookmarks* this_) {
- return this_->current->label;
+ return this_->current->label;
}
static void bookmarks_clear_item(struct bookmark_item_priv *b_item) {
- b_item->children=g_list_first(b_item->children);
- while(b_item->children) {
- bookmarks_clear_item((struct bookmark_item_priv*)b_item->children->data);
- b_item->children=g_list_next(b_item->children);
- }
- g_free(b_item->label);
- g_free(b_item);
-}
-
-static void
-bookmarks_clear_hash(struct bookmarks *this_) {
- if (this_->mr) {
- map_rect_destroy(this_->mr);
- }
- bookmarks_clear_item(this_->root);
- g_hash_table_destroy(this_->bookmarks_hash);
- g_list_free(this_->bookmarks_list);
-}
-
-static void
-bookmarks_load_hash(struct bookmarks *this_) {
- struct bookmark_item_priv *b_item;
- struct item *item;
- struct attr attr;
- struct coord c;
- char *pos,*finder;
- char *copy_helper;
-
- if (this_->mr) {
- map_rect_destroy(this_->mr);
- }
- this_->mr=map_rect_new(this_->bookmark, NULL);
-
- this_->bookmarks_hash=g_hash_table_new(g_str_hash, g_str_equal);
- this_->root=g_new0(struct bookmark_item_priv,1);
- this_->root->type=type_none;
- this_->root->parent=NULL;
- this_->root->children=NULL;
- bookmarks_move_root(this_);
-
- while ((item=map_rect_get_item(this_->mr))) {
- if (item->type != type_bookmark && item->type != type_bookmark_folder ) continue;
- if (!item_attr_get(item, attr_path, &attr)) {
- item_attr_get(item, attr_label, &attr);
- }
- item_coord_get(item, &c, 1);
-
- b_item=g_new0(struct bookmark_item_priv,1);
- b_item->c.x=c.x;
- b_item->c.y=c.y;
- b_item->label=g_strdup(attr.u.str);
- b_item->type=item->type;
- b_item->item=*item;
-
- //Prepare position
- bookmarks_move_root(this_);
- finder=b_item->label;
- while ((pos=strchr(finder,'/'))) {
- *pos=0x00;
- dbg(lvl_debug,"Found path entry: %s\n",finder);
- if (!bookmarks_move_down(this_,finder)) {
- struct bookmark_item_priv *path_item=g_new0(struct bookmark_item_priv,1);
- path_item->type=type_bookmark_folder;
- path_item->parent=this_->current;
- path_item->children=NULL;
- path_item->label=g_strdup(finder);
-
- this_->current->children=g_list_append(this_->current->children,path_item);
- this_->current=path_item;
- g_hash_table_insert(this_->bookmarks_hash,b_item->label,path_item);
- this_->bookmarks_list=g_list_append(this_->bookmarks_list,path_item);
- }
- finder+=strlen(finder)+1;
- }
- copy_helper=g_strdup(finder);
- free(b_item->label);
- b_item->label=copy_helper;
- b_item->parent=this_->current;
-
- g_hash_table_insert(this_->bookmarks_hash,b_item->label,b_item);
- this_->bookmarks_list=g_list_append(this_->bookmarks_list,b_item);
- this_->current->children=g_list_append(this_->current->children,b_item);
- this_->current->children=g_list_first(this_->current->children);
- dbg(lvl_debug,"Added %s to %s and current list now %u long\n",b_item->label,this_->current->label,g_list_length(this_->current->children));
- }
- bookmarks_move_root(this_);
+ b_item->children=g_list_first(b_item->children);
+ while(b_item->children) {
+ bookmarks_clear_item((struct bookmark_item_priv*)b_item->children->data);
+ b_item->children=g_list_next(b_item->children);
+ }
+ g_free(b_item->label);
+ g_free(b_item);
}
-struct bookmarks *
-bookmarks_new(struct attr *parent, struct attr **attrs, struct transformation *trans) {
- struct bookmarks *this_;
+static void bookmarks_clear_hash(struct bookmarks *this_) {
+ if (this_->mr) {
+ map_rect_destroy(this_->mr);
+ }
+ bookmarks_clear_item(this_->root);
+ g_hash_table_destroy(this_->bookmarks_hash);
+ g_list_free(this_->bookmarks_list);
+}
- if (parent->type!=attr_navit) {
- return NULL;
- }
+static void bookmarks_load_hash(struct bookmarks *this_) {
+ struct bookmark_item_priv *b_item;
+ struct item *item;
+ struct attr attr;
+ struct coord c;
+ char *pos,*finder;
+ char *copy_helper;
- this_ = g_new0(struct bookmarks,1);
- this_->attr_cbl=callback_list_new();
- this_->parent=parent;
- //this_->attrs=attr_list_dup(attrs);
- this_->trans=trans;
+ if (this_->mr) {
+ map_rect_destroy(this_->mr);
+ }
+ this_->mr=map_rect_new(this_->bookmark, NULL);
+
+ this_->bookmarks_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ this_->root=g_new0(struct bookmark_item_priv,1);
+ this_->root->type=type_none;
+ this_->root->parent=NULL;
+ this_->root->children=NULL;
+ bookmarks_move_root(this_);
+
+ while ((item=map_rect_get_item(this_->mr))) {
+ if (item->type != type_bookmark && item->type != type_bookmark_folder ) continue;
+ if (!item_attr_get(item, attr_path, &attr)) {
+ item_attr_get(item, attr_label, &attr);
+ }
+ item_coord_get(item, &c, 1);
+
+ b_item=g_new0(struct bookmark_item_priv,1);
+ b_item->c.x=c.x;
+ b_item->c.y=c.y;
+ b_item->label=g_strdup(attr.u.str);
+ b_item->type=item->type;
+ b_item->item=*item;
+
+ //Prepare position
+ bookmarks_move_root(this_);
+ finder=b_item->label;
+ while ((pos=strchr(finder,'/'))) {
+ *pos=0x00;
+ dbg(lvl_debug,"Found path entry: %s",finder);
+ if (!bookmarks_move_down(this_,finder)) {
+ struct bookmark_item_priv *path_item=g_new0(struct bookmark_item_priv,1);
+ path_item->type=type_bookmark_folder;
+ path_item->parent=this_->current;
+ path_item->children=NULL;
+ path_item->label=g_strdup(finder);
+
+ this_->current->children=g_list_append(this_->current->children,path_item);
+ this_->current=path_item;
+ g_hash_table_insert(this_->bookmarks_hash,b_item->label,path_item);
+ this_->bookmarks_list=g_list_append(this_->bookmarks_list,path_item);
+ }
+ finder+=strlen(finder)+1;
+ }
+ copy_helper=g_strdup(finder);
+ free(b_item->label);
+ b_item->label=copy_helper;
+ b_item->parent=this_->current;
+
+ g_hash_table_insert(this_->bookmarks_hash,b_item->label,b_item);
+ this_->bookmarks_list=g_list_append(this_->bookmarks_list,b_item);
+ this_->current->children=g_list_append(this_->current->children,b_item);
+ this_->current->children=g_list_first(this_->current->children);
+ dbg(lvl_debug,"Added %s to %s and current list now %u long",b_item->label,this_->current->label,
+ g_list_length(this_->current->children));
+ }
+ bookmarks_move_root(this_);
+}
- this_->bookmark_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt", NULL);
- this_->working_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt.tmp", NULL);
+struct bookmarks *
+bookmarks_new(struct attr *parent, struct attr **attrs, struct transformation *trans) {
+ struct bookmarks *this_;
- this_->clipboard=g_new0(struct bookmark_item_priv,1);
+ if (parent->type!=attr_navit) {
+ return NULL;
+ }
- {
- //Load map now
- struct attr type={attr_type, {"textfile"}},
- data={attr_data, {this_->bookmark_file}},
- no_warn={attr_no_warning_if_map_file_missing, {(void *)1}};
- struct attr *attrs[]={&type, &data, &no_warn, NULL};
- this_->bookmark=map_new(this_->parent, attrs);
- if (!this_->bookmark)
- return NULL;
- bookmarks_load_hash(this_);
- }
+ this_ = g_new0(struct bookmarks,1);
+ this_->attr_cbl=callback_list_new();
+ this_->parent=parent;
+ //this_->attrs=attr_list_dup(attrs);
+ this_->trans=trans;
+
+ this_->bookmark_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt", NULL);
+ this_->working_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt.tmp", NULL);
+
+ this_->clipboard=g_new0(struct bookmark_item_priv,1);
+
+ {
+ //Load map now
+ struct attr type= {attr_type, {"textfile"}},
+ data= {attr_data, {this_->bookmark_file}},
+ no_warn= {attr_no_warning_if_map_file_missing, {(void *)1}};
+ struct attr *attrs[]= {&type, &data, &no_warn, NULL};
+ this_->bookmark=map_new(this_->parent, attrs);
+ if (!this_->bookmark)
+ return NULL;
+ bookmarks_load_hash(this_);
+ }
- return this_;
+ return this_;
}
-void
-bookmarks_destroy(struct bookmarks *this_) {
+void bookmarks_destroy(struct bookmarks *this_) {
- bookmarks_clear_hash(this_);
+ bookmarks_clear_hash(this_);
- map_destroy(this_->bookmark);
- callback_list_destroy(this_->attr_cbl);
+ map_destroy(this_->bookmark);
+ callback_list_destroy(this_->attr_cbl);
- g_free(this_->bookmark_file);
- g_free(this_->working_file);
+ g_free(this_->bookmark_file);
+ g_free(this_->working_file);
- g_free(this_->clipboard);
- g_free(this_);
+ g_free(this_->clipboard);
+ g_free(this_);
}
struct map*
bookmarks_get_map(struct bookmarks *this_) {
- return this_->bookmark;
-}
-
-enum projection bookmarks_get_projection(struct bookmarks *this_){
- return map_projection(this_->bookmark);
-}
-void
-bookmarks_add_callback(struct bookmarks *this_, struct callback *cb)
-{
- callback_list_add(this_->attr_cbl, cb);
-}
-
-static int
-bookmarks_store_bookmarks_to_file(struct bookmarks *this_, int limit,int replace) {
- FILE *f;
- struct bookmark_item_priv *item,*parent_item;
- char *fullname;
- const char *prostr;
- int result;
- GHashTable *dedup=g_hash_table_new_full(g_str_hash,g_str_equal,g_free,NULL);
-
- f=fopen(this_->working_file, replace ? "w+" : "a+");
- if (f==NULL) {
- navit_add_message(this_->parent->u.navit,_("Failed to write bookmarks file"));
- return FALSE;
- }
-
- this_->bookmarks_list=g_list_first(this_->bookmarks_list);
- while (this_->bookmarks_list) {
- item=(struct bookmark_item_priv*)this_->bookmarks_list->data;
-
- parent_item=item;
- fullname=g_strdup(item->label);
- while ((parent_item=parent_item->parent)) {
- char *pathHelper;
- if (parent_item->label) {
- pathHelper=g_strconcat(parent_item->label,"/",fullname,NULL);
- g_free(fullname);
- fullname=g_strdup(pathHelper);
- g_free(pathHelper);
- dbg(lvl_debug,"full name: %s\n",fullname);
- }
- }
-
- if (!g_hash_table_lookup(dedup,fullname)) {
- g_hash_table_insert(dedup,fullname,fullname);
- if (item->type == type_bookmark) {
- prostr = projection_to_name(projection_mg);
- if (fprintf(f,"%s%s%s0x%x %s0x%x type=%s label=\"%s\" path=\"%s\"\n",
- prostr, *prostr ? ":" : "",
- item->c.x >= 0 ? "":"-", item->c.x >= 0 ? item->c.x : -item->c.x,
- item->c.y >= 0 ? "":"-", item->c.y >= 0 ? item->c.y : -item->c.y,
- "bookmark", item->label,fullname)<1) {
- g_free(fullname);
- break;
- }
- }
- if (item->type == type_bookmark_folder) {
- prostr = projection_to_name(projection_mg);
- if (fprintf(f,"%s%s%s0x%x %s0x%x type=%s label=\"%s\" path=\"%s\"\n",
- prostr, *prostr ? ":" : "",
- "", 0,
- "", 0,
- "bookmark_folder", item->label,fullname)<1) {
- g_free(fullname);
- break;
- }
- }
- }
-
- /* Limit could be zero, so we start decrementing it from zero and never reach 1
- or it was bigger and we decreased it earlier. So when this counter becomes 1, we know
- that we have enough entries in bookmarks file */
- if (limit==1) {
- break;
- }
- limit--;
-
- this_->bookmarks_list=g_list_next(this_->bookmarks_list);
- }
-
- fclose(f);
+ return this_->bookmark;
+}
+
+enum projection bookmarks_get_projection(struct bookmarks *this_) {
+ return map_projection(this_->bookmark);
+}
+void bookmarks_add_callback(struct bookmarks *this_, struct callback *cb) {
+ callback_list_add(this_->attr_cbl, cb);
+}
+
+static int bookmarks_store_bookmarks_to_file(struct bookmarks *this_, int limit,int replace) {
+ FILE *f;
+ struct bookmark_item_priv *item,*parent_item;
+ char *fullname;
+ const char *prostr;
+ int result;
+ GHashTable *dedup=g_hash_table_new_full(g_str_hash,g_str_equal,g_free,NULL);
+
+ f=fopen(this_->working_file, replace ? "w+" : "a+");
+ if (f==NULL) {
+ navit_add_message(this_->parent->u.navit,_("Failed to write bookmarks file"));
+ return FALSE;
+ }
+
+ this_->bookmarks_list=g_list_first(this_->bookmarks_list);
+ while (this_->bookmarks_list) {
+ item=(struct bookmark_item_priv*)this_->bookmarks_list->data;
+
+ parent_item=item;
+ fullname=g_strdup(item->label);
+ while ((parent_item=parent_item->parent)) {
+ char *pathHelper;
+ if (parent_item->label) {
+ pathHelper=g_strconcat(parent_item->label,"/",fullname,NULL);
+ g_free(fullname);
+ fullname=g_strdup(pathHelper);
+ g_free(pathHelper);
+ dbg(lvl_debug,"full name: %s",fullname);
+ }
+ }
+
+ if (!g_hash_table_lookup(dedup,fullname)) {
+ g_hash_table_insert(dedup,fullname,fullname);
+ if (item->type == type_bookmark) {
+ prostr = projection_to_name(projection_mg);
+ if (fprintf(f,"%s%s%s0x%x %s0x%x type=%s label=\"%s\" path=\"%s\"\n",
+ prostr, *prostr ? ":" : "",
+ item->c.x >= 0 ? "":"-", item->c.x >= 0 ? item->c.x : -item->c.x,
+ item->c.y >= 0 ? "":"-", item->c.y >= 0 ? item->c.y : -item->c.y,
+ "bookmark", item->label,fullname)<1) {
+ g_free(fullname);
+ break;
+ }
+ }
+ if (item->type == type_bookmark_folder) {
+ prostr = projection_to_name(projection_mg);
+ if (fprintf(f,"%s%s%s0x%x %s0x%x type=%s label=\"%s\" path=\"%s\"\n",
+ prostr, *prostr ? ":" : "",
+ "", 0,
+ "", 0,
+ "bookmark_folder", item->label,fullname)<1) {
+ g_free(fullname);
+ break;
+ }
+ }
+ }
+
+ /* Limit could be zero, so we start decrementing it from zero and never reach 1
+ or it was bigger and we decreased it earlier. So when this counter becomes 1, we know
+ that we have enough entries in bookmarks file */
+ if (limit==1) {
+ break;
+ }
+ limit--;
+
+ this_->bookmarks_list=g_list_next(this_->bookmarks_list);
+ }
+
+ fclose(f);
g_hash_table_destroy(dedup);
@@ -378,12 +372,11 @@ bookmarks_store_bookmarks_to_file(struct bookmarks *this_, int limit,int replac
}
unlink(this_->bookmark_file);
- result=(rename(this_->working_file,this_->bookmark_file)==0);
- if (!result)
- {
- navit_add_message(this_->parent->u.navit,_("Failed to write bookmarks file"));
- }
- return result;
+ result=(rename(this_->working_file,this_->bookmark_file)==0);
+ if (!result) {
+ navit_add_message(this_->parent->u.navit,_("Failed to write bookmarks file"));
+ }
+ return result;
}
/**
@@ -393,10 +386,8 @@ bookmarks_store_bookmarks_to_file(struct bookmarks *this_, int limit,int replac
* full path. Should be freed using g_free.
*
*/
-char*
-bookmarks_get_destination_file(gboolean create)
-{
- return g_strjoin(NULL, navit_get_user_data_directory(create), "/destination.txt", NULL);
+char* bookmarks_get_destination_file(gboolean create) {
+ return g_strjoin(NULL, navit_get_user_data_directory(create), "/destination.txt", NULL);
}
/*
@@ -408,75 +399,67 @@ bookmarks_get_destination_file(gboolean create)
* arg: gboolean create: create the directory where the file is stored
* if it does not exist
*/
-char*
-bookmarks_get_center_file(gboolean create)
-{
- return g_strjoin(NULL, navit_get_user_data_directory(create), "/center.txt", NULL);
-}
-
-void
-bookmarks_set_center_from_file(struct bookmarks *this_, char *file)
-{
- FILE *f;
- char *line = NULL;
-
- size_t line_size = 0;
- enum projection pro;
- struct coord *center;
-
- f = fopen(file, "r");
- if (! f)
- return;
- getline(&line, &line_size, f);
- fclose(f);
- if (line) {
- center = transform_center(this_->trans);
- pro = transform_get_projection(this_->trans);
- coord_parse(g_strchomp(line), pro, center);
- free(line);
- }
- return;
-}
-
-void
-bookmarks_write_center_to_file(struct bookmarks *this_, char *file)
-{
- FILE *f;
- enum projection pro;
- struct coord *center;
-
- f = fopen(file, "w+");
- if (f) {
- center = transform_center(this_->trans);
- pro = transform_get_projection(this_->trans);
- coord_print(pro, center, f);
- fclose(f);
- } else {
- perror(file);
- }
- return;
-}
-
-static void
-bookmarks_emit_dbus_signal(struct bookmarks *this_, struct pcoord *c, const char *description,int create)
-{
+char* bookmarks_get_center_file(gboolean create) {
+ return g_strjoin(NULL, navit_get_user_data_directory(create), "/center.txt", NULL);
+}
+
+void bookmarks_set_center_from_file(struct bookmarks *this_, char *file) {
+ FILE *f;
+ char *line = NULL;
+
+ size_t line_size = 0;
+ enum projection pro;
+ struct coord *center;
+
+ f = fopen(file, "r");
+ if (! f)
+ return;
+ getline(&line, &line_size, f);
+ fclose(f);
+ if (line) {
+ center = transform_center(this_->trans);
+ pro = transform_get_projection(this_->trans);
+ coord_parse(g_strchomp(line), pro, center);
+ free(line);
+ }
+ return;
+}
+
+void bookmarks_write_center_to_file(struct bookmarks *this_, char *file) {
+ FILE *f;
+ enum projection pro;
+ struct coord *center;
+
+ f = fopen(file, "w+");
+ if (f) {
+ center = transform_center(this_->trans);
+ pro = transform_get_projection(this_->trans);
+ coord_print(pro, center, f);
+ fclose(f);
+ } else {
+ perror(file);
+ }
+ return;
+}
+
+static void bookmarks_emit_dbus_signal(struct bookmarks *this_, struct pcoord *c, const char *description,int create) {
struct attr attr1,attr2,attr3,attr4,cb,*attr_list[5];
- int valid=0;
- attr1.type=attr_type;
- attr1.u.str="bookmark";
+ int valid=0;
+ attr1.type=attr_type;
+ attr1.u.str="bookmark";
attr2.type=attr_data;
attr2.u.str=create ? "create" : "delete";
- attr3.type=attr_data;
- attr3.u.str=(char *)description;
+ attr3.type=attr_data;
+ attr3.u.str=(char *)description;
attr4.type=attr_coord;
attr4.u.pcoord=c;
- attr_list[0]=&attr1;
- attr_list[1]=&attr2;
+ attr_list[0]=&attr1;
+ attr_list[1]=&attr2;
attr_list[2]=&attr3;
attr_list[3]=&attr4;
- attr_list[4]=NULL;
- if (navit_get_attr(this_->parent->u.navit, attr_callback_list, &cb, NULL))
- callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
+ attr_list[4]=NULL;
+ if (navit_get_attr(this_->parent->u.navit, attr_callback_list, &cb, NULL))
+ callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
}
/**
@@ -487,335 +470,323 @@ bookmarks_emit_dbus_signal(struct bookmarks *this_, struct pcoord *c, const char
* @param description A label which allows the user to later identify this bookmark
* @returns nothing
*/
-int
-bookmarks_add_bookmark(struct bookmarks *this_, struct pcoord *pc, const char *description)
-{
- struct bookmark_item_priv *b_item=g_new0(struct bookmark_item_priv,1);
- int result;
-
- if (pc) {
- b_item->c.x=pc->x;
- b_item->c.y=pc->y;
- b_item->type=type_bookmark;
- } else {
- b_item->type=type_bookmark_folder;
- }
- b_item->label=g_strdup(description);
- b_item->parent=this_->current;
- b_item->children=NULL;
-
- this_->current->children=g_list_first(this_->current->children);
- this_->current->children=g_list_append(this_->current->children,b_item);
- this_->bookmarks_list=g_list_first(this_->bookmarks_list);
- this_->bookmarks_list=g_list_append(this_->bookmarks_list,b_item);
-
- result=bookmarks_store_bookmarks_to_file(this_,0,0);
-
- callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
- bookmarks_clear_hash(this_);
- bookmarks_load_hash(this_);
+int bookmarks_add_bookmark(struct bookmarks *this_, struct pcoord *pc, const char *description) {
+ struct bookmark_item_priv *b_item=g_new0(struct bookmark_item_priv,1);
+ int result;
+
+ if (pc) {
+ b_item->c.x=pc->x;
+ b_item->c.y=pc->y;
+ b_item->type=type_bookmark;
+ } else {
+ b_item->type=type_bookmark_folder;
+ }
+ b_item->label=g_strdup(description);
+ b_item->parent=this_->current;
+ b_item->children=NULL;
+
+ this_->current->children=g_list_first(this_->current->children);
+ this_->current->children=g_list_append(this_->current->children,b_item);
+ this_->bookmarks_list=g_list_first(this_->bookmarks_list);
+ this_->bookmarks_list=g_list_append(this_->bookmarks_list,b_item);
+
+ result=bookmarks_store_bookmarks_to_file(this_,0,0);
+
+ callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
+ bookmarks_clear_hash(this_);
+ bookmarks_load_hash(this_);
bookmarks_emit_dbus_signal(this_,&(b_item->c),description,TRUE);
- return result;
+ return result;
}
-
-int
-bookmarks_cut_bookmark(struct bookmarks *this_, const char *label) {
- if (bookmarks_copy_bookmark(this_,label)) {
- return bookmarks_delete_bookmark(this_,label);
- }
-
- return FALSE;
-}
-int
-bookmarks_copy_bookmark(struct bookmarks *this_, const char *label) {
- bookmarks_item_rewind(this_);
- if (this_->current->children==NULL) {
- return 0;
- }
- while (this_->current->iter!=NULL) {
- struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
- if (!strcmp(data->label,label)) {
- this_->clipboard->c=data->c;
- this_->clipboard->type=data->type;
- this_->clipboard->item=data->item;
- this_->clipboard->children=data->children;
- if (!this_->clipboard->label) {
- g_free(this_->clipboard->label);
- }
- this_->clipboard->label=g_strdup(data->label);
- return TRUE;
- }
- this_->current->iter=g_list_next(this_->current->iter);
- }
- return FALSE;
-}
-int
-bookmarks_paste_bookmark(struct bookmarks *this_) {
- int result;
- struct bookmark_item_priv* b_item;
-
- if (!this_->clipboard->label) {
- return FALSE;
- }
-
- b_item=g_new0(struct bookmark_item_priv,1);
- b_item->c.x=this_->clipboard->c.x;
- b_item->c.y=this_->clipboard->c.y;
- b_item->label=g_strdup(this_->clipboard->label);
- b_item->type=this_->clipboard->type;
- b_item->item=this_->clipboard->item;
- b_item->parent=this_->current;
- b_item->children=this_->clipboard->children;
-
- g_hash_table_insert(this_->bookmarks_hash,b_item->label,b_item);
- this_->bookmarks_list=g_list_append(this_->bookmarks_list,b_item);
- this_->current->children=g_list_append(this_->current->children,b_item);
- this_->current->children=g_list_first(this_->current->children);
-
- result=bookmarks_store_bookmarks_to_file(this_,0,0);
-
- callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
- bookmarks_clear_hash(this_);
- bookmarks_load_hash(this_);
-
- return result;
-}
-
-
-int
-bookmarks_delete_bookmark(struct bookmarks *this_, const char *label) {
- int result;
-
- bookmarks_item_rewind(this_);
- if (this_->current->children==NULL) {
- return 0;
- }
- while (this_->current->iter!=NULL) {
- struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
- if (!strcmp(data->label,label)) {
- this_->bookmarks_list=g_list_first(this_->bookmarks_list);
- this_->bookmarks_list=g_list_remove(this_->bookmarks_list,data);
-
- result=bookmarks_store_bookmarks_to_file(this_,0,0);
-
- callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
- bookmarks_clear_hash(this_);
- bookmarks_load_hash(this_);
-
- bookmarks_emit_dbus_signal(this_,&(data->c),label,FALSE);
-
- return result;
- }
- this_->current->iter=g_list_next(this_->current->iter);
- }
-
- return FALSE;
-}
-
-int
-bookmarks_rename_bookmark(struct bookmarks *this_, const char *oldName, const char* newName) {
- int result;
-
- bookmarks_item_rewind(this_);
- if (this_->current->children==NULL) {
- return 0;
- }
- while (this_->current->iter!=NULL) {
- struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
- if (!strcmp(data->label,oldName)) {
- g_free(data->label);
- data->label=g_strdup(newName);
-
- result=bookmarks_store_bookmarks_to_file(this_,0,0);
-
- callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
- bookmarks_clear_hash(this_);
- bookmarks_load_hash(this_);
-
- return result;
- }
- this_->current->iter=g_list_next(this_->current->iter);
- }
-
- return FALSE;
+
+int bookmarks_cut_bookmark(struct bookmarks *this_, const char *label) {
+ if (bookmarks_copy_bookmark(this_,label)) {
+ return bookmarks_delete_bookmark(this_,label);
+ }
+
+ return FALSE;
+}
+int bookmarks_copy_bookmark(struct bookmarks *this_, const char *label) {
+ bookmarks_item_rewind(this_);
+ if (this_->current->children==NULL) {
+ return 0;
+ }
+ while (this_->current->iter!=NULL) {
+ struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
+ if (!strcmp(data->label,label)) {
+ this_->clipboard->c=data->c;
+ this_->clipboard->type=data->type;
+ this_->clipboard->item=data->item;
+ this_->clipboard->children=data->children;
+ if (!this_->clipboard->label) {
+ g_free(this_->clipboard->label);
+ }
+ this_->clipboard->label=g_strdup(data->label);
+ return TRUE;
+ }
+ this_->current->iter=g_list_next(this_->current->iter);
+ }
+ return FALSE;
+}
+int bookmarks_paste_bookmark(struct bookmarks *this_) {
+ int result;
+ struct bookmark_item_priv* b_item;
+
+ if (!this_->clipboard->label) {
+ return FALSE;
+ }
+
+ b_item=g_new0(struct bookmark_item_priv,1);
+ b_item->c.x=this_->clipboard->c.x;
+ b_item->c.y=this_->clipboard->c.y;
+ b_item->label=g_strdup(this_->clipboard->label);
+ b_item->type=this_->clipboard->type;
+ b_item->item=this_->clipboard->item;
+ b_item->parent=this_->current;
+ b_item->children=this_->clipboard->children;
+
+ g_hash_table_insert(this_->bookmarks_hash,b_item->label,b_item);
+ this_->bookmarks_list=g_list_append(this_->bookmarks_list,b_item);
+ this_->current->children=g_list_append(this_->current->children,b_item);
+ this_->current->children=g_list_first(this_->current->children);
+
+ result=bookmarks_store_bookmarks_to_file(this_,0,0);
+
+ callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
+ bookmarks_clear_hash(this_);
+ bookmarks_load_hash(this_);
+
+ return result;
}
-struct former_destination{
- enum item_type type;
- char* description;
- GList* c;
+
+int bookmarks_delete_bookmark(struct bookmarks *this_, const char *label) {
+ int result;
+
+ bookmarks_item_rewind(this_);
+ if (this_->current->children==NULL) {
+ return 0;
+ }
+ while (this_->current->iter!=NULL) {
+ struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
+ if (!strcmp(data->label,label)) {
+ this_->bookmarks_list=g_list_first(this_->bookmarks_list);
+ this_->bookmarks_list=g_list_remove(this_->bookmarks_list,data);
+
+ result=bookmarks_store_bookmarks_to_file(this_,0,0);
+
+ callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
+ bookmarks_clear_hash(this_);
+ bookmarks_load_hash(this_);
+
+ bookmarks_emit_dbus_signal(this_,&(data->c),label,FALSE);
+
+ return result;
+ }
+ this_->current->iter=g_list_next(this_->current->iter);
+ }
+
+ return FALSE;
+}
+
+int bookmarks_rename_bookmark(struct bookmarks *this_, const char *oldName, const char* newName) {
+ int result;
+
+ bookmarks_item_rewind(this_);
+ if (this_->current->children==NULL) {
+ return 0;
+ }
+ while (this_->current->iter!=NULL) {
+ struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data;
+ if (!strcmp(data->label,oldName)) {
+ g_free(data->label);
+ data->label=g_strdup(newName);
+
+ result=bookmarks_store_bookmarks_to_file(this_,0,0);
+
+ callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
+ bookmarks_clear_hash(this_);
+ bookmarks_load_hash(this_);
+
+ return result;
+ }
+ this_->current->iter=g_list_next(this_->current->iter);
+ }
+
+ return FALSE;
+}
+
+struct former_destination {
+ enum item_type type;
+ char* description;
+ GList* c;
};
-static void free_former_destination(struct former_destination* former_destination){
- g_free(former_destination->description);
- g_list_foreach(former_destination->c, (GFunc)g_free, NULL);
- g_list_free(former_destination->c);
- g_free(former_destination);
+static void free_former_destination(struct former_destination* former_destination) {
+ g_free(former_destination->description);
+ g_list_foreach(former_destination->c, (GFunc)g_free, NULL);
+ g_list_free(former_destination->c);
+ g_free(former_destination);
}
/*
* Doesn't read any items besides former_destination. So active waypoints items of type former_itinerary and former_itinerary_part are skipped.
*/
-static GList* read_former_destination_map_as_list(struct map *map){
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- struct former_destination *dest;
- struct coord c;
- int more;
- GList* list = NULL;
- if (map && (mr=map_rect_new(map, NULL))) {
- while ((item=map_rect_get_item(mr))) {
- if (item->type != type_former_destination) continue;
- dest = g_new0(struct former_destination, 1);
- dest->type=item->type;
- item_attr_get(item, attr_label, &attr);
- dest->description = g_strdup(attr.u.str);
- more = item_coord_get(item, &c, 1);
- while (more) {
- dest->c = g_list_append(dest->c, g_new(struct coord, 1));
- *(struct coord *)g_list_last(dest->c)->data = c;
- more = item_coord_get(item, &c, 1);
- }
- list = g_list_prepend(list, dest);
- }
- map_rect_destroy(mr);
- }
- return g_list_reverse(list);
-}
-
-static int
-destination_equal(struct former_destination* dest1, struct former_destination* dest2, int ignore_descriptions)
-{
- if ((dest1->type == dest2->type) &&
- (ignore_descriptions || !strcmp(dest1->description, dest2->description)) &&
- (coord_equal((struct coord *)g_list_last(dest1->c)->data, (struct coord *)g_list_last(dest2->c)->data))){
- return TRUE;
- }
- return FALSE;
+static GList* read_former_destination_map_as_list(struct map *map) {
+ struct map_rect *mr;
+ struct item *item;
+ struct attr attr;
+ struct former_destination *dest;
+ struct coord c;
+ int more;
+ GList* list = NULL;
+ if (map && (mr=map_rect_new(map, NULL))) {
+ while ((item=map_rect_get_item(mr))) {
+ if (item->type != type_former_destination) continue;
+ dest = g_new0(struct former_destination, 1);
+ dest->type=item->type;
+ item_attr_get(item, attr_label, &attr);
+ dest->description = g_strdup(attr.u.str);
+ more = item_coord_get(item, &c, 1);
+ while (more) {
+ dest->c = g_list_append(dest->c, g_new(struct coord, 1));
+ *(struct coord *)g_list_last(dest->c)->data = c;
+ more = item_coord_get(item, &c, 1);
+ }
+ list = g_list_prepend(list, dest);
+ }
+ map_rect_destroy(mr);
+ }
+ return g_list_reverse(list);
+}
+
+static int destination_equal(struct former_destination* dest1, struct former_destination* dest2,
+ int ignore_descriptions) {
+ if ((dest1->type == dest2->type) &&
+ (ignore_descriptions || !strcmp(dest1->description, dest2->description)) &&
+ (coord_equal((struct coord *)g_list_last(dest1->c)->data, (struct coord *)g_list_last(dest2->c)->data))) {
+ return TRUE;
+ }
+ return FALSE;
}
/*
- * Find destination in given GList. If remove_found is non-zero, any matching items are removed and new beginning of the list is returned.
+ * Find destination in given GList. If remove_found is non-zero, any matching items are removed and new beginning of the list is returned.
* If remove_found is zero, last matching item is returned. In the latter case, description is ignored and can be NULL.
*/
-static GList*
-find_destination_in_list(struct former_destination* dest_to_remove, GList* former_destinations, int remove_found)
-{
- GList* curr_el = former_destinations;
- GList* prev_el = NULL;
- GList* found_el = NULL;
- struct former_destination* curr_dest;
- while(curr_el){
- curr_dest = curr_el->data;
- if (destination_equal(dest_to_remove, curr_dest, remove_found?0:1)) {
- if(remove_found) {
- free_former_destination(curr_dest);
- curr_el = g_list_remove(curr_el, curr_dest);
- continue;
- } else {
- found_el=curr_el;
- }
- }
- prev_el = curr_el;
- curr_el = g_list_next(curr_el);
-
- }
- if(remove_found)
- return g_list_first(prev_el);
- else
- return found_el;
-
-}
-
-
-static void
-write_former_destinations(GList* former_destinations, char *former_destination_file, enum projection proj)
-{
- FILE *f;
- GList* currdest = NULL;
- GList* c_list = NULL;
- struct coord *c;
- struct former_destination *dest;
- const char* prostr = projection_to_name(proj);
- f=fopen(former_destination_file, "w");
- if (f) {
- for(currdest = former_destinations; currdest; currdest = g_list_next(currdest)){
- dest = currdest->data;
- if (dest->description)
- fprintf(f,"type=%s label=\"%s\"\n", item_to_name(dest->type), dest->description);
- else
- fprintf(f,"type=%s\n", item_to_name(dest->type));
- c_list = dest->c;
- do {
- c = (struct coord *)c_list->data;
- fprintf(f,"%s%s%s0x%x %s0x%x\n",
- prostr, *prostr ? ":" : "",
- c->x >= 0 ? "":"-", c->x >= 0 ? c->x : -c->x,
- c->y >= 0 ? "":"-", c->y >= 0 ? c->y : -c->y);
- c_list = g_list_next(c_list);
- } while (c_list);
- }
- fclose(f);
- } else {
- dbg(lvl_error, "Error updating destinations file %s: %s\n", former_destination_file, strerror(errno));
- }
+static GList* find_destination_in_list(struct former_destination* dest_to_remove, GList* former_destinations,
+ int remove_found) {
+ GList* curr_el = former_destinations;
+ GList* prev_el = NULL;
+ GList* found_el = NULL;
+ struct former_destination* curr_dest;
+ while(curr_el) {
+ curr_dest = curr_el->data;
+ if (destination_equal(dest_to_remove, curr_dest, remove_found?0:1)) {
+ if(remove_found) {
+ free_former_destination(curr_dest);
+ curr_el = g_list_remove(curr_el, curr_dest);
+ continue;
+ } else {
+ found_el=curr_el;
+ }
+ }
+ prev_el = curr_el;
+ curr_el = g_list_next(curr_el);
+
+ }
+ if(remove_found)
+ return g_list_first(prev_el);
+ else
+ return found_el;
+
+}
+
+
+static void write_former_destinations(GList* former_destinations, char *former_destination_file, enum projection proj) {
+ FILE *f;
+ GList* currdest = NULL;
+ GList* c_list = NULL;
+ struct coord *c;
+ struct former_destination *dest;
+ const char* prostr = projection_to_name(proj);
+ f=fopen(former_destination_file, "w");
+ if (f) {
+ for(currdest = former_destinations; currdest; currdest = g_list_next(currdest)) {
+ dest = currdest->data;
+ if (dest->description)
+ fprintf(f,"type=%s label=\"%s\"\n", item_to_name(dest->type), dest->description);
+ else
+ fprintf(f,"type=%s\n", item_to_name(dest->type));
+ c_list = dest->c;
+ do {
+ c = (struct coord *)c_list->data;
+ fprintf(f,"%s%s%s0x%x %s0x%x\n",
+ prostr, *prostr ? ":" : "",
+ c->x >= 0 ? "":"-", c->x >= 0 ? c->x : -c->x,
+ c->y >= 0 ? "":"-", c->y >= 0 ? c->y : -c->y);
+ c_list = g_list_next(c_list);
+ } while (c_list);
+ }
+ fclose(f);
+ } else {
+ dbg(lvl_error, "Error updating destinations file %s: %s", former_destination_file, strerror(errno));
+ }
}
/**
* Append recent destination(s) item to the former destionations map.
* @param former_destination_map
* @param former_destination_file
- * @param c coordinates of item point(s). Can be set to NULL when navigation is stopped to remove type_former_itinerary and
+ * @param c coordinates of item point(s). Can be set to NULL when navigation is stopped to remove type_former_itinerary and
* type_former_itinerary_part items from the file.
* @param count number of points in this item. Set to 0 when navigation is stopped.
* @param type type_former_destination, type_former_itinerary and type_former_itinerary_part are meaningful here
- * @param description character string used to identify this destination. If NULL, most recent waypoint at these coordinates will be used
+ * @param description character string used to identify this destination. If NULL, most recent waypoint at these coordinates will be used
* to get description.
* @param limit Limits the number of entries in the "backlog". Set to 0 for "infinite"
*/
-void
-bookmarks_append_destinations(struct map *former_destination_map, char *former_destination_file,
- struct pcoord *c, int count, enum item_type type, const char *description, int limit)
-{
- struct former_destination *new_dest=NULL;
- GList* former_destinations = NULL;
- GList* former_destinations_shortened = NULL;
- struct coord* c_dup;
- int no_of_former_destinations;
- int i;
-
- former_destinations = read_former_destination_map_as_list(former_destination_map);
-
- if(c && count>0) {
- GList *older;
- struct coord ctmp;
- new_dest = g_new0(struct former_destination, 1);
- new_dest->type = type;
- for (i=0; i<count; i++) {
- ctmp.x=c[i].x;
- ctmp.y=c[i].y;
- c_dup = g_new(struct coord, 1);
- transform_from_to(&ctmp,c[i].pro, c_dup, map_projection(former_destination_map));
- new_dest->c = g_list_append(new_dest->c, c_dup);
- }
- older=find_destination_in_list(new_dest, former_destinations,0);
- if(!description && older)
- description=((struct former_destination *)older->data)->description;
- new_dest->description = g_strdup(description?description:_("Map Point"));
-
- former_destinations = find_destination_in_list(new_dest, former_destinations, 1);
- former_destinations = g_list_append(former_destinations, new_dest);
- }
- no_of_former_destinations = g_list_length(former_destinations);
- if (limit > 0 && no_of_former_destinations > limit)
- former_destinations_shortened = g_list_nth(former_destinations, no_of_former_destinations - limit);
- else
- former_destinations_shortened = former_destinations;
-
- write_former_destinations(former_destinations_shortened, former_destination_file, map_projection(former_destination_map));
- g_list_foreach(former_destinations, (GFunc) free_former_destination, NULL);
- g_list_free(former_destinations);
+void bookmarks_append_destinations(struct map *former_destination_map, char *former_destination_file, struct pcoord *c,
+ int count, enum item_type type, const char *description, int limit) {
+ struct former_destination *new_dest=NULL;
+ GList* former_destinations = NULL;
+ GList* former_destinations_shortened = NULL;
+ struct coord* c_dup;
+ int no_of_former_destinations;
+ int i;
+
+ former_destinations = read_former_destination_map_as_list(former_destination_map);
+
+ if(c && count>0) {
+ GList *older;
+ struct coord ctmp;
+ new_dest = g_new0(struct former_destination, 1);
+ new_dest->type = type;
+ for (i=0; i<count; i++) {
+ ctmp.x=c[i].x;
+ ctmp.y=c[i].y;
+ c_dup = g_new(struct coord, 1);
+ transform_from_to(&ctmp,c[i].pro, c_dup, map_projection(former_destination_map));
+ new_dest->c = g_list_append(new_dest->c, c_dup);
+ }
+ older=find_destination_in_list(new_dest, former_destinations,0);
+ if(!description && older)
+ description=((struct former_destination *)older->data)->description;
+ new_dest->description = g_strdup(description?description:_("Map Point"));
+
+ former_destinations = find_destination_in_list(new_dest, former_destinations, 1);
+ former_destinations = g_list_append(former_destinations, new_dest);
+ }
+ no_of_former_destinations = g_list_length(former_destinations);
+ if (limit > 0 && no_of_former_destinations > limit)
+ former_destinations_shortened = g_list_nth(former_destinations, no_of_former_destinations - limit);
+ else
+ former_destinations_shortened = former_destinations;
+
+ write_former_destinations(former_destinations_shortened, former_destination_file,
+ map_projection(former_destination_map));
+ g_list_foreach(former_destinations, (GFunc) free_former_destination, NULL);
+ g_list_free(former_destinations);
}
diff --git a/navit/browserplugin.c b/navit/browserplugin.c
index e5fbc5517..84f0002ed 100644
--- a/navit/browserplugin.c
+++ b/navit/browserplugin.c
@@ -54,443 +54,390 @@ static NPNetscapeFuncs *sBrowserFuncs = NULL;
extern struct NPClass navitclass,navitclass2;
typedef struct InstanceData {
- NPP npp;
- NPWindow window;
+ NPP npp;
+ NPWindow window;
} InstanceData;
-static void
-fillPluginFunctionTable(NPPluginFuncs * pFuncs)
-{
- pFuncs->version = 11;
- pFuncs->size = sizeof(*pFuncs);
- pFuncs->newp = NPP_New;
- pFuncs->destroy = NPP_Destroy;
- pFuncs->setwindow = NPP_SetWindow;
- pFuncs->newstream = NPP_NewStream;
- pFuncs->destroystream = NPP_DestroyStream;
- pFuncs->asfile = NPP_StreamAsFile;
- pFuncs->writeready = NPP_WriteReady;
- pFuncs->write = NPP_Write;
- pFuncs->print = NPP_Print;
- pFuncs->event = NPP_HandleEvent;
- pFuncs->urlnotify = NPP_URLNotify;
- pFuncs->getvalue = NPP_GetValue;
- pFuncs->setvalue = NPP_SetValue;
+static void fillPluginFunctionTable(NPPluginFuncs * pFuncs) {
+ pFuncs->version = 11;
+ pFuncs->size = sizeof(*pFuncs);
+ pFuncs->newp = NPP_New;
+ pFuncs->destroy = NPP_Destroy;
+ pFuncs->setwindow = NPP_SetWindow;
+ pFuncs->newstream = NPP_NewStream;
+ pFuncs->destroystream = NPP_DestroyStream;
+ pFuncs->asfile = NPP_StreamAsFile;
+ pFuncs->writeready = NPP_WriteReady;
+ pFuncs->write = NPP_Write;
+ pFuncs->print = NPP_Print;
+ pFuncs->event = NPP_HandleEvent;
+ pFuncs->urlnotify = NPP_URLNotify;
+ pFuncs->getvalue = NPP_GetValue;
+ pFuncs->setvalue = NPP_SetValue;
}
NP_EXPORT(NPError)
-NP_Initialize(NPNetscapeFuncs * bFuncs, NPPluginFuncs * pFuncs)
-{
- NPError err = NPERR_NO_ERROR;
- NPBool supportsXEmbed = false;
- NPNToolkitType toolkit = 0;
-
- sBrowserFuncs = bFuncs;
-
- fillPluginFunctionTable(pFuncs);
- err =
- sBrowserFuncs->getvalue(NULL, NPNVSupportsXEmbedBool,
- (void *) &supportsXEmbed);
- if (err != NPERR_NO_ERROR || supportsXEmbed != true)
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
- err =
- sBrowserFuncs->getvalue(NULL, NPNVToolkit, (void *) &toolkit);
-
- if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2)
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
-
- return NPERR_NO_ERROR;
+NP_Initialize(NPNetscapeFuncs * bFuncs, NPPluginFuncs * pFuncs) {
+ NPError err = NPERR_NO_ERROR;
+ NPBool supportsXEmbed = false;
+ NPNToolkitType toolkit = 0;
+
+ sBrowserFuncs = bFuncs;
+
+ fillPluginFunctionTable(pFuncs);
+ err =
+ sBrowserFuncs->getvalue(NULL, NPNVSupportsXEmbedBool,
+ (void *) &supportsXEmbed);
+ if (err != NPERR_NO_ERROR || supportsXEmbed != true)
+ return NPERR_INCOMPATIBLE_VERSION_ERROR;
+ err =
+ sBrowserFuncs->getvalue(NULL, NPNVToolkit, (void *) &toolkit);
+
+ if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2)
+ return NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+ return NPERR_NO_ERROR;
}
NP_EXPORT(char *)
-NP_GetPluginVersion()
-{
- return PLUGIN_VERSION;
+NP_GetPluginVersion() {
+ return PLUGIN_VERSION;
}
NP_EXPORT(char *)
-NP_GetMIMEDescription()
-{
- return "application/navit-plugin:nsc:Navit plugin";
+NP_GetMIMEDescription() {
+ return "application/navit-plugin:nsc:Navit plugin";
}
NP_EXPORT(NPError)
-NP_GetValue(void *future, NPPVariable aVariable, void *aValue)
-{
- fprintf(stderr, "NP_GetValue %d\n", aVariable);
- switch (aVariable) {
- case NPPVpluginNameString:
- *((char **) aValue) = PLUGIN_NAME;
- break;
- case NPPVpluginDescriptionString:
- *((char **) aValue) = PLUGIN_DESCRIPTION;
- break;
- default:
- return NPERR_INVALID_PARAM;
- break;
- }
- return NPERR_NO_ERROR;
+NP_GetValue(void *future, NPPVariable aVariable, void *aValue) {
+ fprintf(stderr, "NP_GetValue %d\n", aVariable);
+ switch (aVariable) {
+ case NPPVpluginNameString:
+ *((char **) aValue) = PLUGIN_NAME;
+ break;
+ case NPPVpluginDescriptionString:
+ *((char **) aValue) = PLUGIN_DESCRIPTION;
+ break;
+ default:
+ return NPERR_INVALID_PARAM;
+ break;
+ }
+ return NPERR_NO_ERROR;
}
NP_EXPORT(NPError)
-NP_Shutdown()
-{
- return NPERR_NO_ERROR;
+NP_Shutdown() {
+ return NPERR_NO_ERROR;
}
-NPError
-NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc,
- char *argn[], char *argv[], NPSavedData * saved)
-{
- char *args[]={"/usr/bin/navit",NULL};
- // Make sure we can render this plugin
- NPBool browserSupportsWindowless = false;
- sBrowserFuncs->getvalue(instance, NPNVSupportsWindowless,
- &browserSupportsWindowless);
- if (!browserSupportsWindowless) {
- printf("Windowless mode not supported by the browser\n");
- return NPERR_GENERIC_ERROR;
- }
+NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData * saved) {
+ char *args[]= {"/usr/bin/navit",NULL};
+ // Make sure we can render this plugin
+ NPBool browserSupportsWindowless = false;
+ sBrowserFuncs->getvalue(instance, NPNVSupportsWindowless,
+ &browserSupportsWindowless);
+ if (!browserSupportsWindowless) {
+ printf("Windowless mode not supported by the browser\n");
+ return NPERR_GENERIC_ERROR;
+ }
#if 0
- sBrowserFuncs->setvalue(instance, NPPVpluginWindowBool,
- (void *) true);
+ sBrowserFuncs->setvalue(instance, NPPVpluginWindowBool,
+ (void *) true);
#endif
- // set up our our instance data
- InstanceData *instanceData =
- (InstanceData *) malloc(sizeof(InstanceData));
- if (!instanceData)
- return NPERR_OUT_OF_MEMORY_ERROR;
- memset(instanceData, 0, sizeof(InstanceData));
- instanceData->npp = instance;
- instance->pdata = instanceData;
- fprintf(stderr, "npp=%p\n", instance);
-
- main_real(1, args);
- return NPERR_NO_ERROR;
+ // set up our our instance data
+ InstanceData *instanceData =
+ (InstanceData *) malloc(sizeof(InstanceData));
+ if (!instanceData)
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ memset(instanceData, 0, sizeof(InstanceData));
+ instanceData->npp = instance;
+ instance->pdata = instanceData;
+ fprintf(stderr, "npp=%p\n", instance);
+
+ main_real(1, args);
+ return NPERR_NO_ERROR;
}
-NPError
-NPP_Destroy(NPP instance, NPSavedData ** save)
-{
- InstanceData *instanceData = (InstanceData *) (instance->pdata);
- free(instanceData);
- return NPERR_NO_ERROR;
+NPError NPP_Destroy(NPP instance, NPSavedData ** save) {
+ InstanceData *instanceData = (InstanceData *) (instance->pdata);
+ free(instanceData);
+ return NPERR_NO_ERROR;
}
-NPError
-NPP_SetWindow(NPP instance, NPWindow * window)
-{
- struct attr navit,graphics,windowid;
- InstanceData *instanceData = (InstanceData *) (instance->pdata);
- if (window->window == instanceData->window.window)
- return;
- instanceData->window = *window;
- fprintf(stderr, "Window 0x%x\n", window->window);
- if (!config_get_attr(config, attr_navit, &navit, NULL)) {
- fprintf(stderr,"No navit\n");
- return NPERR_GENERIC_ERROR;
- }
- if (!navit_get_attr(navit.u.navit, attr_graphics, &graphics, NULL)) {
- fprintf(stderr,"No Graphics\n");
- return NPERR_GENERIC_ERROR;
- }
- windowid.type=attr_windowid;
- windowid.u.num=window->window;
- if (!graphics_set_attr(graphics.u.graphics, &windowid)) {
- fprintf(stderr,"Failed to set window\n");
- return NPERR_GENERIC_ERROR;
- }
-
- return NPERR_NO_ERROR;
+NPError NPP_SetWindow(NPP instance, NPWindow * window) {
+ struct attr navit,graphics,windowid;
+ InstanceData *instanceData = (InstanceData *) (instance->pdata);
+ if (window->window == instanceData->window.window)
+ return;
+ instanceData->window = *window;
+ fprintf(stderr, "Window 0x%x\n", window->window);
+ if (!config_get_attr(config, attr_navit, &navit, NULL)) {
+ fprintf(stderr,"No navit\n");
+ return NPERR_GENERIC_ERROR;
+ }
+ if (!navit_get_attr(navit.u.navit, attr_graphics, &graphics, NULL)) {
+ fprintf(stderr,"No Graphics\n");
+ return NPERR_GENERIC_ERROR;
+ }
+ windowid.type=attr_windowid;
+ windowid.u.num=window->window;
+ if (!graphics_set_attr(graphics.u.graphics, &windowid)) {
+ fprintf(stderr,"Failed to set window\n");
+ return NPERR_GENERIC_ERROR;
+ }
+
+ return NPERR_NO_ERROR;
}
-NPError
-NPP_NewStream(NPP instance, NPMIMEType type, NPStream * stream,
- NPBool seekable, uint16_t * stype)
-{
- return NPERR_GENERIC_ERROR;
+NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream * stream, NPBool seekable, uint16_t * stype) {
+ return NPERR_GENERIC_ERROR;
}
-NPError
-NPP_DestroyStream(NPP instance, NPStream * stream, NPReason reason)
-{
- return NPERR_GENERIC_ERROR;
+NPError NPP_DestroyStream(NPP instance, NPStream * stream, NPReason reason) {
+ return NPERR_GENERIC_ERROR;
}
-int32_t
-NPP_WriteReady(NPP instance, NPStream * stream)
-{
- return 0;
+int32_t NPP_WriteReady(NPP instance, NPStream * stream) {
+ return 0;
}
-int32_t
-NPP_Write(NPP instance, NPStream * stream, int32_t offset, int32_t len,
- void *buffer)
-{
- return 0;
+int32_t NPP_Write(NPP instance, NPStream * stream, int32_t offset, int32_t len,
+ void *buffer) {
+ return 0;
}
-void
-NPP_StreamAsFile(NPP instance, NPStream * stream, const char *fname)
-{
+void NPP_StreamAsFile(NPP instance, NPStream * stream, const char *fname) {
}
-void
-NPP_Print(NPP instance, NPPrint * platformPrint)
-{
+void NPP_Print(NPP instance, NPPrint * platformPrint) {
}
-int16_t
-NPP_HandleEvent(NPP instance, void *event)
-{
+int16_t NPP_HandleEvent(NPP instance, void *event) {
- return 0;
+ return 0;
#if 0
- InstanceData *instanceData = (InstanceData *) (instance->pdata);
- XEvent *nativeEvent = (XEvent *) event;
+ InstanceData *instanceData = (InstanceData *) (instance->pdata);
+ XEvent *nativeEvent = (XEvent *) event;
- if (nativeEvent->type != GraphicsExpose)
- return 0;
+ if (nativeEvent->type != GraphicsExpose)
+ return 0;
- XGraphicsExposeEvent *expose = &nativeEvent->xgraphicsexpose;
- instanceData->window.window = (void *) (expose->drawable);
+ XGraphicsExposeEvent *expose = &nativeEvent->xgraphicsexpose;
+ instanceData->window.window = (void *) (expose->drawable);
- GdkNativeWindow nativeWinId = (XID) (instanceData->window.window);
- GdkDrawable *gdkWindow =
- GDK_DRAWABLE(gdk_window_foreign_new(nativeWinId));
- drawWindow(instanceData, gdkWindow);
- g_object_unref(gdkWindow);
+ GdkNativeWindow nativeWinId = (XID) (instanceData->window.window);
+ GdkDrawable *gdkWindow =
+ GDK_DRAWABLE(gdk_window_foreign_new(nativeWinId));
+ drawWindow(instanceData, gdkWindow);
+ g_object_unref(gdkWindow);
#endif
- return 1;
+ return 1;
}
-void
-NPP_URLNotify(NPP instance, const char *URL, NPReason reason,
- void *notifyData)
-{
+void NPP_URLNotify(NPP instance, const char *URL, NPReason reason, void *notifyData) {
}
struct NavitObject {
- NPClass *class;
- uint32_t referenceCount;
- InstanceData *instanceData;
- int is_attr;
- struct attr attr;
+ NPClass *class;
+ uint32_t referenceCount;
+ InstanceData *instanceData;
+ int is_attr;
+ struct attr attr;
};
-void
-printIdentifier(NPIdentifier name)
-{
- NPUTF8 *str;
- str = sBrowserFuncs->utf8fromidentifier(name);
- fprintf(stderr, "%s\n", str);
- sBrowserFuncs->memfree(str);
+void printIdentifier(NPIdentifier name) {
+ NPUTF8 *str;
+ str = sBrowserFuncs->utf8fromidentifier(name);
+ fprintf(stderr, "%s\n", str);
+ sBrowserFuncs->memfree(str);
}
-NPObject *
-allocate(NPP npp, NPClass * aClass)
-{
- struct NavitObject *ret = calloc(sizeof(struct NavitObject), 1);
- if (ret) {
- ret->class = aClass;
- ret->instanceData = npp->pdata;
- fprintf(stderr, "instanceData for %p is %p\n", ret,
- ret->instanceData);
- }
- return (NPObject *) ret;
+NPObject *allocate(NPP npp, NPClass * aClass) {
+ struct NavitObject *ret = calloc(sizeof(struct NavitObject), 1);
+ if (ret) {
+ ret->class = aClass;
+ ret->instanceData = npp->pdata;
+ fprintf(stderr, "instanceData for %p is %p\n", ret,
+ ret->instanceData);
+ }
+ return (NPObject *) ret;
}
-void
-invalidate(NPObject * npobj)
-{
- fprintf(stderr, "invalidate\n");
+void invalidate(NPObject * npobj) {
+ fprintf(stderr, "invalidate\n");
}
-bool
-hasMethod(NPObject * npobj, NPIdentifier name)
-{
- fprintf(stderr, "hasMethod\n");
- printIdentifier(name);
- if (name == sBrowserFuncs->getstringidentifier("command"))
- return true;
- if (name == sBrowserFuncs->getstringidentifier("get_attr"))
- return true;
- if (name == sBrowserFuncs->getstringidentifier("toString"))
- return true;
- if (name == sBrowserFuncs->getstringidentifier("nativeMethod"))
- return true;
- if (name ==
- sBrowserFuncs->getstringidentifier("anotherNativeMethod"))
- return true;
-
- return false;
+bool hasMethod(NPObject * npobj, NPIdentifier name) {
+ fprintf(stderr, "hasMethod\n");
+ printIdentifier(name);
+ if (name == sBrowserFuncs->getstringidentifier("command"))
+ return true;
+ if (name == sBrowserFuncs->getstringidentifier("get_attr"))
+ return true;
+ if (name == sBrowserFuncs->getstringidentifier("toString"))
+ return true;
+ if (name == sBrowserFuncs->getstringidentifier("nativeMethod"))
+ return true;
+ if (name ==
+ sBrowserFuncs->getstringidentifier("anotherNativeMethod"))
+ return true;
+
+ return false;
}
-enum attr_type
-variant_to_attr_type(const NPVariant *variant)
-{
- if (NPVARIANT_IS_STRING(*variant))
- return attr_from_name(NPVARIANT_TO_STRING(*variant).utf8characters);
- return attr_none;
+enum attr_type variant_to_attr_type(const NPVariant *variant) {
+ if (NPVARIANT_IS_STRING(*variant))
+ return attr_from_name(NPVARIANT_TO_STRING(*variant).utf8characters);
+ return attr_none;
}
-bool
-invoke(NPObject * npobj, NPIdentifier name, const NPVariant * args,
- uint32_t argCount, NPVariant * result)
-{
- struct NavitObject *obj = (struct NavitObject *) npobj;
- fprintf(stderr, "invoke\n");
- printIdentifier(name);
- if (name == sBrowserFuncs->getstringidentifier("get_attr")) {
- enum attr_type attr_type;
- struct attr attr;
- if (!argCount)
- return false;
- attr_type=variant_to_attr_type(&args[0]);
- if (attr_type == attr_none)
- return false;
- if (config_get_attr(config, attr_type, &attr, NULL)) {
- struct NavitObject *obj2 = (struct NavitObject *)sBrowserFuncs->createobject(obj->instanceData->npp, &navitclass);
- obj2->is_attr=1;
- obj2->attr=attr;
- OBJECT_TO_NPVARIANT((NPObject *)obj2, *result);
- return true;
- } else {
- VOID_TO_NPVARIANT(*result);
- return true;
- }
- }
- if (name == sBrowserFuncs->getstringidentifier("command")) {
- enum attr_type attr_type;
- struct attr attr;
- NPObject *window;
- NPError err;
- NPVariant value;
- if (!argCount || !NPVARIANT_IS_STRING(args[0]))
- return false;
- if (navit_get_attr(obj->attr.u.navit, attr_callback_list, &attr, NULL)) {
- int valid=0;
- callback_list_call_attr_4(attr.u.callback_list, attr_command, NPVARIANT_TO_STRING(args[0]), NULL, NULL, &valid);
- }
- err=sBrowserFuncs->getvalue(obj->instanceData->npp, NPNVWindowNPObject, (void *) &window);
- fprintf(stderr,"error1:%d\n",err);
- //OBJECT_TO_NPVARIANT(window, *result);
- err=sBrowserFuncs->invoke(obj->instanceData->npp, window, sBrowserFuncs->getstringidentifier("Array"), window, 0, result);
- fprintf(stderr,"error2:%d\n",err);
- INT32_TO_NPVARIANT(23, value);
- err=sBrowserFuncs->setproperty(obj->instanceData->npp, NPVARIANT_TO_OBJECT(*result), sBrowserFuncs->getintidentifier(0), &value);
- INT32_TO_NPVARIANT(42, value);
- err=sBrowserFuncs->setproperty(obj->instanceData->npp, NPVARIANT_TO_OBJECT(*result), sBrowserFuncs->getintidentifier(1), &value);
- fprintf(stderr,"error3:%d\n",err);
-
-
- //VOID_TO_NPVARIANT(*result);
- return true;
- }
- if (name == sBrowserFuncs->getstringidentifier("toString")) {
- char *s;
- if (obj->is_attr) {
- s="[NavitObject attribute]";
- STRINGZ_TO_NPVARIANT(strdup(s), *result);
- return true;
- }
- s=g_strdup_printf("[NavitObject %s]",attr_to_name(obj->attr.type));
- STRINGZ_TO_NPVARIANT(strdup(s), *result);
- g_free(s);
- return true;
- }
- if (name == sBrowserFuncs->getstringidentifier("nativeMethod")) {
- result->type = NPVariantType_Int32;
- result->value.intValue = 23;
- return true;
- }
- if (name ==
- sBrowserFuncs->getstringidentifier("anotherNativeMethod")) {
- result->type = NPVariantType_Int32;
- result->value.intValue = 42;
- return true;
- }
- return false;
+bool invoke(NPObject * npobj, NPIdentifier name, const NPVariant * args, uint32_t argCount, NPVariant * result) {
+ struct NavitObject *obj = (struct NavitObject *) npobj;
+ fprintf(stderr, "invoke\n");
+ printIdentifier(name);
+ if (name == sBrowserFuncs->getstringidentifier("get_attr")) {
+ enum attr_type attr_type;
+ struct attr attr;
+ if (!argCount)
+ return false;
+ attr_type=variant_to_attr_type(&args[0]);
+ if (attr_type == attr_none)
+ return false;
+ if (config_get_attr(config, attr_type, &attr, NULL)) {
+ struct NavitObject *obj2 = (struct NavitObject *)sBrowserFuncs->createobject(obj->instanceData->npp, &navitclass);
+ obj2->is_attr=1;
+ obj2->attr=attr;
+ OBJECT_TO_NPVARIANT((NPObject *)obj2, *result);
+ return true;
+ } else {
+ VOID_TO_NPVARIANT(*result);
+ return true;
+ }
+ }
+ if (name == sBrowserFuncs->getstringidentifier("command")) {
+ enum attr_type attr_type;
+ struct attr attr;
+ NPObject *window;
+ NPError err;
+ NPVariant value;
+ if (!argCount || !NPVARIANT_IS_STRING(args[0]))
+ return false;
+ if (navit_get_attr(obj->attr.u.navit, attr_callback_list, &attr, NULL)) {
+ int valid=0;
+ callback_list_call_attr_4(attr.u.callback_list, attr_command, NPVARIANT_TO_STRING(args[0]), NULL, NULL, &valid);
+ }
+ err=sBrowserFuncs->getvalue(obj->instanceData->npp, NPNVWindowNPObject, (void *) &window);
+ fprintf(stderr,"error1:%d\n",err);
+ //OBJECT_TO_NPVARIANT(window, *result);
+ err=sBrowserFuncs->invoke(obj->instanceData->npp, window, sBrowserFuncs->getstringidentifier("Array"), window, 0,
+ result);
+ fprintf(stderr,"error2:%d\n",err);
+ INT32_TO_NPVARIANT(23, value);
+ err=sBrowserFuncs->setproperty(obj->instanceData->npp, NPVARIANT_TO_OBJECT(*result), sBrowserFuncs->getintidentifier(0),
+ &value);
+ INT32_TO_NPVARIANT(42, value);
+ err=sBrowserFuncs->setproperty(obj->instanceData->npp, NPVARIANT_TO_OBJECT(*result), sBrowserFuncs->getintidentifier(1),
+ &value);
+ fprintf(stderr,"error3:%d\n",err);
+
+
+ //VOID_TO_NPVARIANT(*result);
+ return true;
+ }
+ if (name == sBrowserFuncs->getstringidentifier("toString")) {
+ char *s;
+ if (obj->is_attr) {
+ s="[NavitObject attribute]";
+ STRINGZ_TO_NPVARIANT(strdup(s), *result);
+ return true;
+ }
+ s=g_strdup_printf("[NavitObject %s]",attr_to_name(obj->attr.type));
+ STRINGZ_TO_NPVARIANT(strdup(s), *result);
+ g_free(s);
+ return true;
+ }
+ if (name == sBrowserFuncs->getstringidentifier("nativeMethod")) {
+ result->type = NPVariantType_Int32;
+ result->value.intValue = 23;
+ return true;
+ }
+ if (name ==
+ sBrowserFuncs->getstringidentifier("anotherNativeMethod")) {
+ result->type = NPVariantType_Int32;
+ result->value.intValue = 42;
+ return true;
+ }
+ return false;
}
-bool
-invokeDefault(NPObject * npobj, const NPVariant * args, uint32_t argCount,
- NPVariant * result)
-{
- fprintf(stderr, "invokeDefault\n");
- return false;
+bool invokeDefault(NPObject * npobj, const NPVariant * args, uint32_t argCount, NPVariant * result) {
+ fprintf(stderr, "invokeDefault\n");
+ return false;
}
-bool
-hasProperty(NPObject * npobj, NPIdentifier name)
-{
- struct NavitObject *obj = (struct NavitObject *) npobj;
- fprintf(stderr, "hasProperty\n");
- printIdentifier(name);
- if (obj->is_attr && name == sBrowserFuncs->getstringidentifier("type"))
- return true;
- if (obj->is_attr && name == sBrowserFuncs->getstringidentifier("val"))
- return true;
- if (name == sBrowserFuncs->getstringidentifier("nativeProperty")) {
- return true;
- }
- return false;
+bool hasProperty(NPObject * npobj, NPIdentifier name) {
+ struct NavitObject *obj = (struct NavitObject *) npobj;
+ fprintf(stderr, "hasProperty\n");
+ printIdentifier(name);
+ if (obj->is_attr && name == sBrowserFuncs->getstringidentifier("type"))
+ return true;
+ if (obj->is_attr && name == sBrowserFuncs->getstringidentifier("val"))
+ return true;
+ if (name == sBrowserFuncs->getstringidentifier("nativeProperty")) {
+ return true;
+ }
+ return false;
}
-bool
-getProperty(NPObject * npobj, NPIdentifier name, NPVariant * result)
-{
- struct NavitObject *obj = (struct NavitObject *) npobj;
- fprintf(stderr, "getProperty %p\n", obj);
- fprintf(stderr, "instanceData %p\n", obj->instanceData);
- if (obj->is_attr && name == sBrowserFuncs->getstringidentifier("type")) {
- STRINGZ_TO_NPVARIANT(strdup(attr_to_name(obj->attr.type)), *result);
- return true;
- }
- if (obj->is_attr && name == sBrowserFuncs->getstringidentifier("val")) {
- struct NavitObject *obj2 = (struct NavitObject *)sBrowserFuncs->createobject(obj->instanceData->npp, &navitclass);
- obj2->attr=obj->attr;
- OBJECT_TO_NPVARIANT((NPObject *)obj2, *result);
- return true;
- }
- if (name == sBrowserFuncs->getstringidentifier("nativeProperty")) {
- result->type = NPVariantType_Object;
- fprintf(stderr, "npp=%p\n", obj->instanceData->npp);
- result->value.objectValue = sBrowserFuncs->createobject(obj->instanceData->npp, &navitclass2);
- return true;
- }
- return false;
+bool getProperty(NPObject * npobj, NPIdentifier name, NPVariant * result) {
+ struct NavitObject *obj = (struct NavitObject *) npobj;
+ fprintf(stderr, "getProperty %p\n", obj);
+ fprintf(stderr, "instanceData %p\n", obj->instanceData);
+ if (obj->is_attr && name == sBrowserFuncs->getstringidentifier("type")) {
+ STRINGZ_TO_NPVARIANT(strdup(attr_to_name(obj->attr.type)), *result);
+ return true;
+ }
+ if (obj->is_attr && name == sBrowserFuncs->getstringidentifier("val")) {
+ struct NavitObject *obj2 = (struct NavitObject *)sBrowserFuncs->createobject(obj->instanceData->npp, &navitclass);
+ obj2->attr=obj->attr;
+ OBJECT_TO_NPVARIANT((NPObject *)obj2, *result);
+ return true;
+ }
+ if (name == sBrowserFuncs->getstringidentifier("nativeProperty")) {
+ result->type = NPVariantType_Object;
+ fprintf(stderr, "npp=%p\n", obj->instanceData->npp);
+ result->value.objectValue = sBrowserFuncs->createobject(obj->instanceData->npp, &navitclass2);
+ return true;
+ }
+ return false;
}
-bool
-setProperty(NPObject * npobj, NPIdentifier name, const NPVariant * value)
-{
- fprintf(stderr, "setProperty\n");
- return false;
+bool setProperty(NPObject * npobj, NPIdentifier name, const NPVariant * value) {
+ fprintf(stderr, "setProperty\n");
+ return false;
}
-bool
-removeProperty(NPObject * npobj, NPIdentifier name)
-{
- fprintf(stderr, "removeProperty\n");
- return false;
+bool removeProperty(NPObject * npobj, NPIdentifier name) {
+ fprintf(stderr, "removeProperty\n");
+ return false;
}
@@ -498,55 +445,51 @@ removeProperty(NPObject * npobj, NPIdentifier name)
struct NPClass navitclass = {
- 1,
- allocate,
- NULL, /* deallocate */
- invalidate,
- hasMethod,
- invoke,
- invokeDefault,
- hasProperty,
- getProperty,
- setProperty,
- removeProperty,
+ 1,
+ allocate,
+ NULL, /* deallocate */
+ invalidate,
+ hasMethod,
+ invoke,
+ invokeDefault,
+ hasProperty,
+ getProperty,
+ setProperty,
+ removeProperty,
};
struct NPClass navitclass2 = {
- 1,
- allocate, /* allocate */
- NULL, /* deallocate */
- invalidate,
- hasMethod,
- invoke,
- invokeDefault,
- hasProperty,
- getProperty,
- setProperty,
- removeProperty,
+ 1,
+ allocate, /* allocate */
+ NULL, /* deallocate */
+ invalidate,
+ hasMethod,
+ invoke,
+ invokeDefault,
+ hasProperty,
+ getProperty,
+ setProperty,
+ removeProperty,
};
-NPError
-NPP_GetValue(NPP instance, NPPVariable variable, void *value)
-{
- fprintf(stderr, "NPP_GetValue %d %d\n", variable,
- NPPVpluginScriptableNPObject);
- if (variable == NPPVpluginNeedsXEmbed) {
- *((NPBool *) value) = true;
- fprintf(stderr, "Xembedd\n");
- return NPERR_NO_ERROR;
- }
-
- if (variable == NPPVpluginScriptableNPObject) {
- *(NPObject **) value =
- sBrowserFuncs->createobject(instance, &navitclass);
- return NPERR_NO_ERROR;
- }
- return NPERR_GENERIC_ERROR;
+NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
+ fprintf(stderr, "NPP_GetValue %d %d\n", variable,
+ NPPVpluginScriptableNPObject);
+ if (variable == NPPVpluginNeedsXEmbed) {
+ *((NPBool *) value) = true;
+ fprintf(stderr, "Xembedd\n");
+ return NPERR_NO_ERROR;
+ }
+
+ if (variable == NPPVpluginScriptableNPObject) {
+ *(NPObject **) value =
+ sBrowserFuncs->createobject(instance, &navitclass);
+ return NPERR_NO_ERROR;
+ }
+ return NPERR_GENERIC_ERROR;
}
-NPError
-NPP_SetValue(NPP instance, NPNVariable variable, void *value)
-{
- return NPERR_GENERIC_ERROR;
+NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) {
+ return NPERR_GENERIC_ERROR;
}
diff --git a/navit/builtin.c.in b/navit/builtin.c.in
index d340d174b..464845929 100644
--- a/navit/builtin.c.in
+++ b/navit/builtin.c.in
@@ -1,5 +1,5 @@
${MODULES_PROTOTYPE};
-extern void builtin_init(void);
-void builtin_init(void) {
+extern void builtin_init(void);
+void builtin_init(void) {
${MODULES_FUNC};
}
diff --git a/navit/cache.c b/navit/cache.c
index 180b165c0..b94953840 100644
--- a/navit/cache.c
+++ b/navit/cache.c
@@ -7,395 +7,345 @@
#include "cache.h"
struct cache_entry {
- int usage;
- unsigned int size;
- struct cache_entry_list *where;
- struct cache_entry *next;
- struct cache_entry *prev;
- int id[0];
+ int usage;
+ unsigned int size;
+ struct cache_entry_list *where;
+ struct cache_entry *next;
+ struct cache_entry *prev;
+ int id[0];
};
struct cache_entry_list {
- struct cache_entry *first, *last;
- int size;
+ struct cache_entry *first, *last;
+ int size;
};
struct cache {
- struct cache_entry_list t1,b1,t2,b2,*insert;
- int size,id_size,entry_size;
- int t1_target;
- unsigned int misses;
- unsigned int hits;
- GHashTable *hash;
+ struct cache_entry_list t1,b1,t2,b2,*insert;
+ int size,id_size,entry_size;
+ int t1_target;
+ unsigned int misses;
+ unsigned int hits;
+ GHashTable *hash;
};
-static void
-cache_entry_dump(struct cache *cache, struct cache_entry *entry)
-{
- int i,size;
- dbg(lvl_debug,"Usage: %d size %d\n",entry->usage, entry->size);
- if (cache)
- size=cache->id_size;
- else
- size=5;
- for (i = 0 ; i < size ; i++) {
- dbg(lvl_debug,"0x%x\n", entry->id[i]);
- }
+static void cache_entry_dump(struct cache *cache, struct cache_entry *entry) {
+ int i,size;
+ dbg(lvl_debug,"Usage: %d size %d",entry->usage, entry->size);
+ if (cache)
+ size=cache->id_size;
+ else
+ size=5;
+ for (i = 0 ; i < size ; i++) {
+ dbg(lvl_debug,"0x%x", entry->id[i]);
+ }
}
-static void
-cache_list_dump(char *str, struct cache *cache, struct cache_entry_list *list)
-{
- struct cache_entry *first=list->first;
- dbg(lvl_debug,"dump %s %d\n",str, list->size);
- while (first) {
- cache_entry_dump(cache, first);
- first=first->next;
- }
+static void cache_list_dump(char *str, struct cache *cache, struct cache_entry_list *list) {
+ struct cache_entry *first=list->first;
+ dbg(lvl_debug,"dump %s %d",str, list->size);
+ while (first) {
+ cache_entry_dump(cache, first);
+ first=first->next;
+ }
}
-static guint
-cache_hash4(gconstpointer key)
-{
- int *id=(int *)key;
- return id[0];
+static guint cache_hash4(gconstpointer key) {
+ int *id=(int *)key;
+ return id[0];
}
-static guint
-cache_hash20(gconstpointer key)
-{
- int *id=(int *)key;
- return id[0]^id[1]^id[2]^id[3]^id[4];
+static guint cache_hash20(gconstpointer key) {
+ int *id=(int *)key;
+ return id[0]^id[1]^id[2]^id[3]^id[4];
}
-static gboolean
-cache_equal4(gconstpointer a, gconstpointer b)
-{
- int *ida=(int *)a;
- int *idb=(int *)b;
+static gboolean cache_equal4(gconstpointer a, gconstpointer b) {
+ int *ida=(int *)a;
+ int *idb=(int *)b;
- return ida[0] == idb[0];
+ return ida[0] == idb[0];
}
-static gboolean
-cache_equal20(gconstpointer a, gconstpointer b)
-{
- int *ida=(int *)a;
- int *idb=(int *)b;
-
- return(ida[0] == idb[0] &&
- ida[1] == idb[1] &&
- ida[2] == idb[2] &&
- ida[3] == idb[3] &&
- ida[4] == idb[4]);
+static gboolean cache_equal20(gconstpointer a, gconstpointer b) {
+ int *ida=(int *)a;
+ int *idb=(int *)b;
+
+ return(ida[0] == idb[0] &&
+ ida[1] == idb[1] &&
+ ida[2] == idb[2] &&
+ ida[3] == idb[3] &&
+ ida[4] == idb[4]);
}
struct cache *
-cache_new(int id_size, int size)
-{
- struct cache *cache=g_new0(struct cache, 1);
-
- cache->id_size=id_size/4;
- cache->entry_size=cache->id_size*sizeof(int)+sizeof(struct cache_entry);
- cache->size=size;
- switch (id_size) {
- case 4:
- cache->hash=g_hash_table_new(cache_hash4, cache_equal4);
- break;
- case 20:
- cache->hash=g_hash_table_new(cache_hash20, cache_equal20);
- break;
- default:
- dbg(lvl_error,"cache with id_size of %d not supported\n", id_size);
- g_free(cache);
- cache=NULL;
- }
- return cache;
+cache_new(int id_size, int size) {
+ struct cache *cache=g_new0(struct cache, 1);
+
+ cache->id_size=id_size/4;
+ cache->entry_size=cache->id_size*sizeof(int)+sizeof(struct cache_entry);
+ cache->size=size;
+ switch (id_size) {
+ case 4:
+ cache->hash=g_hash_table_new(cache_hash4, cache_equal4);
+ break;
+ case 20:
+ cache->hash=g_hash_table_new(cache_hash20, cache_equal20);
+ break;
+ default:
+ dbg(lvl_error,"cache with id_size of %d not supported", id_size);
+ g_free(cache);
+ cache=NULL;
+ }
+ return cache;
}
-void
-cache_resize(struct cache *cache, int size)
-{
- cache->size=size;
+void cache_resize(struct cache *cache, int size) {
+ cache->size=size;
}
-static void
-cache_insert_mru(struct cache *cache, struct cache_entry_list *list, struct cache_entry *entry)
-{
- entry->prev=NULL;
- entry->next=list->first;
- entry->where=list;
- if (entry->next)
- entry->next->prev=entry;
- list->first=entry;
- if (! list->last)
- list->last=entry;
- list->size+=entry->size;
- if (cache)
- g_hash_table_insert(cache->hash, (gpointer)entry->id, entry);
+static void cache_insert_mru(struct cache *cache, struct cache_entry_list *list, struct cache_entry *entry) {
+ entry->prev=NULL;
+ entry->next=list->first;
+ entry->where=list;
+ if (entry->next)
+ entry->next->prev=entry;
+ list->first=entry;
+ if (! list->last)
+ list->last=entry;
+ list->size+=entry->size;
+ if (cache)
+ g_hash_table_insert(cache->hash, (gpointer)entry->id, entry);
}
-static void
-cache_remove_from_list(struct cache_entry_list *list, struct cache_entry *entry)
-{
- if (entry->prev)
- entry->prev->next=entry->next;
- else
- list->first=entry->next;
- if (entry->next)
- entry->next->prev=entry->prev;
- else
- list->last=entry->prev;
- list->size-=entry->size;
+static void cache_remove_from_list(struct cache_entry_list *list, struct cache_entry *entry) {
+ if (entry->prev)
+ entry->prev->next=entry->next;
+ else
+ list->first=entry->next;
+ if (entry->next)
+ entry->next->prev=entry->prev;
+ else
+ list->last=entry->prev;
+ list->size-=entry->size;
}
-static void
-cache_remove(struct cache *cache, struct cache_entry *entry)
-{
- dbg(lvl_debug,"remove 0x%x 0x%x 0x%x 0x%x 0x%x\n", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
- g_hash_table_remove(cache->hash, (gpointer)(entry->id));
- g_slice_free1(entry->size, entry);
+static void cache_remove(struct cache *cache, struct cache_entry *entry) {
+ dbg(lvl_debug,"remove 0x%x 0x%x 0x%x 0x%x 0x%x", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
+ g_hash_table_remove(cache->hash, (gpointer)(entry->id));
+ g_slice_free1(entry->size, entry);
}
-static struct cache_entry *
-cache_remove_lru_helper(struct cache_entry_list *list)
-{
- struct cache_entry *last=list->last;
- if (! last)
- return NULL;
- list->last=last->prev;
- if (last->prev)
- last->prev->next=NULL;
- else
- list->first=NULL;
- list->size-=last->size;
- return last;
+static struct cache_entry *cache_remove_lru_helper(struct cache_entry_list *list) {
+ struct cache_entry *last=list->last;
+ if (! last)
+ return NULL;
+ list->last=last->prev;
+ if (last->prev)
+ last->prev->next=NULL;
+ else
+ list->first=NULL;
+ list->size-=last->size;
+ return last;
}
-static struct cache_entry *
-cache_remove_lru(struct cache *cache, struct cache_entry_list *list)
-{
- struct cache_entry *last;
- int seen=0;
- while (list->last && list->last->usage && seen < list->size) {
- last=cache_remove_lru_helper(list);
- cache_insert_mru(NULL, list, last);
- seen+=last->size;
- }
- last=list->last;
- if (! last || last->usage || seen >= list->size)
- return NULL;
- dbg(lvl_debug,"removing %d\n", last->id[0]);
- cache_remove_lru_helper(list);
- if (cache) {
- cache_remove(cache, last);
- return NULL;
- }
- return last;
+static struct cache_entry *cache_remove_lru(struct cache *cache, struct cache_entry_list *list) {
+ struct cache_entry *last;
+ int seen=0;
+ while (list->last && list->last->usage && seen < list->size) {
+ last=cache_remove_lru_helper(list);
+ cache_insert_mru(NULL, list, last);
+ seen+=last->size;
+ }
+ last=list->last;
+ if (! last || last->usage || seen >= list->size)
+ return NULL;
+ dbg(lvl_debug,"removing %d", last->id[0]);
+ cache_remove_lru_helper(list);
+ if (cache) {
+ cache_remove(cache, last);
+ return NULL;
+ }
+ return last;
}
-void *
-cache_entry_new(struct cache *cache, void *id, int size)
-{
- struct cache_entry *ret;
- size+=cache->entry_size;
- cache->misses+=size;
- ret=(struct cache_entry *)g_slice_alloc0(size);
- ret->size=size;
- ret->usage=1;
- memcpy(ret->id, id, cache->id_size*sizeof(int));
- return &ret->id[cache->id_size];
+void *cache_entry_new(struct cache *cache, void *id, int size) {
+ struct cache_entry *ret;
+ size+=cache->entry_size;
+ cache->misses+=size;
+ ret=(struct cache_entry *)g_slice_alloc0(size);
+ ret->size=size;
+ ret->usage=1;
+ memcpy(ret->id, id, cache->id_size*sizeof(int));
+ return &ret->id[cache->id_size];
}
-void
-cache_entry_destroy(struct cache *cache, void *data)
-{
- struct cache_entry *entry=(struct cache_entry *)((char *)data-cache->entry_size);
- dbg(lvl_debug,"destroy 0x%x 0x%x 0x%x 0x%x 0x%x\n", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
- entry->usage--;
+void cache_entry_destroy(struct cache *cache, void *data) {
+ struct cache_entry *entry=(struct cache_entry *)((char *)data-cache->entry_size);
+ dbg(lvl_debug,"destroy 0x%x 0x%x 0x%x 0x%x 0x%x", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
+ entry->usage--;
}
-static struct cache_entry *
-cache_trim(struct cache *cache, struct cache_entry *entry)
-{
- struct cache_entry *new_entry;
- dbg(lvl_debug,"trim 0x%x 0x%x 0x%x 0x%x 0x%x\n", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
- dbg(lvl_debug,"Trim %x from %d -> %d\n", entry->id[0], entry->size, cache->size);
- if ( cache->entry_size < entry->size )
- {
- g_hash_table_remove(cache->hash, (gpointer)(entry->id));
-
- new_entry = g_slice_alloc0(cache->entry_size);
- memcpy(new_entry, entry, cache->entry_size);
- g_slice_free1( entry->size, entry);
- new_entry->size = cache->entry_size;
-
- g_hash_table_insert(cache->hash, (gpointer)new_entry->id, new_entry);
- }
- else
- {
- new_entry = entry;
- }
-
- return new_entry;
+static struct cache_entry *cache_trim(struct cache *cache, struct cache_entry *entry) {
+ struct cache_entry *new_entry;
+ dbg(lvl_debug,"trim 0x%x 0x%x 0x%x 0x%x 0x%x", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
+ dbg(lvl_debug,"Trim %x from %d -> %d", entry->id[0], entry->size, cache->size);
+ if ( cache->entry_size < entry->size ) {
+ g_hash_table_remove(cache->hash, (gpointer)(entry->id));
+
+ new_entry = g_slice_alloc0(cache->entry_size);
+ memcpy(new_entry, entry, cache->entry_size);
+ g_slice_free1( entry->size, entry);
+ new_entry->size = cache->entry_size;
+
+ g_hash_table_insert(cache->hash, (gpointer)new_entry->id, new_entry);
+ } else {
+ new_entry = entry;
+ }
+
+ return new_entry;
}
-static struct cache_entry *
-cache_move(struct cache *cache, struct cache_entry_list *old, struct cache_entry_list *new)
-{
- struct cache_entry *entry;
- entry=cache_remove_lru(NULL, old);
- if (! entry)
- return NULL;
- entry=cache_trim(cache, entry);
- cache_insert_mru(NULL, new, entry);
- return entry;
+static struct cache_entry *cache_move(struct cache *cache, struct cache_entry_list *old, struct cache_entry_list *new) {
+ struct cache_entry *entry;
+ entry=cache_remove_lru(NULL, old);
+ if (! entry)
+ return NULL;
+ entry=cache_trim(cache, entry);
+ cache_insert_mru(NULL, new, entry);
+ return entry;
}
-static int
-cache_replace(struct cache *cache)
-{
- if (cache->t1.size >= MAX(1,cache->t1_target)) {
- dbg(lvl_debug,"replace 12\n");
- if (!cache_move(cache, &cache->t1, &cache->b1))
- cache_move(cache, &cache->t2, &cache->b2);
- } else {
- dbg(lvl_debug,"replace t2\n");
- if (!cache_move(cache, &cache->t2, &cache->b2))
- cache_move(cache, &cache->t1, &cache->b1);
- }
+static int cache_replace(struct cache *cache) {
+ if (cache->t1.size >= MAX(1,cache->t1_target)) {
+ dbg(lvl_debug,"replace 12");
+ if (!cache_move(cache, &cache->t1, &cache->b1))
+ cache_move(cache, &cache->t2, &cache->b2);
+ } else {
+ dbg(lvl_debug,"replace t2");
+ if (!cache_move(cache, &cache->t2, &cache->b2))
+ cache_move(cache, &cache->t1, &cache->b1);
+ }
#if 0
- if (! entry) {
- cache_dump(cache);
- exit(0);
- }
+ if (! entry) {
+ cache_dump(cache);
+ exit(0);
+ }
#endif
- return 1;
+ return 1;
}
-void
-cache_flush(struct cache *cache, void *id)
-{
- struct cache_entry *entry=g_hash_table_lookup(cache->hash, id);
- if (entry) {
- cache_remove_from_list(entry->where, entry);
- cache_remove(cache, entry);
- }
+void cache_flush(struct cache *cache, void *id) {
+ struct cache_entry *entry=g_hash_table_lookup(cache->hash, id);
+ if (entry) {
+ cache_remove_from_list(entry->where, entry);
+ cache_remove(cache, entry);
+ }
}
-void
-cache_flush_data(struct cache *cache, void *data)
-{
- struct cache_entry *entry=(struct cache_entry *)((char *)data-cache->entry_size);
- if (entry) {
- cache_remove_from_list(entry->where, entry);
- cache_remove(cache, entry);
- }
+void cache_flush_data(struct cache *cache, void *data) {
+ struct cache_entry *entry=(struct cache_entry *)((char *)data-cache->entry_size);
+ if (entry) {
+ cache_remove_from_list(entry->where, entry);
+ cache_remove(cache, entry);
+ }
}
-void *
-cache_lookup(struct cache *cache, void *id) {
- struct cache_entry *entry;
+void *cache_lookup(struct cache *cache, void *id) {
+ struct cache_entry *entry;
- dbg(lvl_debug,"get %d\n", ((int *)id)[0]);
- entry=g_hash_table_lookup(cache->hash, id);
- if (entry == NULL) {
- cache->insert=&cache->t1;
+ dbg(lvl_debug,"get %d", ((int *)id)[0]);
+ entry=g_hash_table_lookup(cache->hash, id);
+ if (entry == NULL) {
+ cache->insert=&cache->t1;
#ifdef DEBUG_CACHE
- fprintf(stderr,"-");
+ fprintf(stderr,"-");
#endif
- dbg(lvl_debug,"not in cache\n");
- return NULL;
- }
- dbg(lvl_debug,"found 0x%x 0x%x 0x%x 0x%x 0x%x\n", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
- if (entry->where == &cache->t1 || entry->where == &cache->t2) {
- cache->hits+=entry->size;
+ dbg(lvl_debug,"not in cache");
+ return NULL;
+ }
+ dbg(lvl_debug,"found 0x%x 0x%x 0x%x 0x%x 0x%x", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
+ if (entry->where == &cache->t1 || entry->where == &cache->t2) {
+ cache->hits+=entry->size;
#ifdef DEBUG_CACHE
- if (entry->where == &cache->t1)
- fprintf(stderr,"h");
- else
- fprintf(stderr,"H");
+ if (entry->where == &cache->t1)
+ fprintf(stderr,"h");
+ else
+ fprintf(stderr,"H");
#endif
- dbg(lvl_debug,"in cache %s\n", entry->where == &cache->t1 ? "T1" : "T2");
- cache_remove_from_list(entry->where, entry);
- cache_insert_mru(NULL, &cache->t2, entry);
- entry->usage++;
- return &entry->id[cache->id_size];
- } else {
- if (entry->where == &cache->b1) {
+ dbg(lvl_debug,"in cache %s", entry->where == &cache->t1 ? "T1" : "T2");
+ cache_remove_from_list(entry->where, entry);
+ cache_insert_mru(NULL, &cache->t2, entry);
+ entry->usage++;
+ return &entry->id[cache->id_size];
+ } else {
+ if (entry->where == &cache->b1) {
#ifdef DEBUG_CACHE
- fprintf(stderr,"m");
+ fprintf(stderr,"m");
#endif
- dbg(lvl_debug,"in phantom cache B1\n");
- cache->t1_target=MIN(cache->t1_target+MAX(cache->b2.size/cache->b1.size, 1),cache->size);
- cache_remove_from_list(&cache->b1, entry);
- } else if (entry->where == &cache->b2) {
+ dbg(lvl_debug,"in phantom cache B1");
+ cache->t1_target=MIN(cache->t1_target+MAX(cache->b2.size/cache->b1.size, 1),cache->size);
+ cache_remove_from_list(&cache->b1, entry);
+ } else if (entry->where == &cache->b2) {
#ifdef DEBUG_CACHE
- fprintf(stderr,"M");
+ fprintf(stderr,"M");
#endif
- dbg(lvl_debug,"in phantom cache B2\n");
- cache->t1_target=MAX(cache->t1_target-MAX(cache->b1.size/cache->b2.size, 1),0);
- cache_remove_from_list(&cache->b2, entry);
- } else {
- dbg(lvl_error,"**ERROR** invalid where\n");
- }
- cache_replace(cache);
- cache_remove(cache, entry);
- cache->insert=&cache->t2;
- return NULL;
- }
+ dbg(lvl_debug,"in phantom cache B2");
+ cache->t1_target=MAX(cache->t1_target-MAX(cache->b1.size/cache->b2.size, 1),0);
+ cache_remove_from_list(&cache->b2, entry);
+ } else {
+ dbg(lvl_error,"**ERROR** invalid where");
+ }
+ cache_replace(cache);
+ cache_remove(cache, entry);
+ cache->insert=&cache->t2;
+ return NULL;
+ }
}
-void
-cache_insert(struct cache *cache, void *data)
-{
- struct cache_entry *entry=(struct cache_entry *)((char *)data-cache->entry_size);
- dbg(lvl_debug,"insert 0x%x 0x%x 0x%x 0x%x 0x%x\n", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
- if (cache->insert == &cache->t1) {
- if (cache->t1.size + cache->b1.size >= cache->size) {
- if (cache->t1.size < cache->size) {
- cache_remove_lru(cache, &cache->b1);
- cache_replace(cache);
- } else {
- cache_remove_lru(cache, &cache->t1);
- }
- } else {
- if (cache->t1.size + cache->t2.size + cache->b1.size + cache->b2.size >= cache->size) {
- if (cache->t1.size + cache->t2.size + cache->b1.size + cache->b2.size >= 2*cache->size)
- cache_remove_lru(cache, &cache->b2);
- cache_replace(cache);
- }
- }
- }
- cache_insert_mru(cache, cache->insert, entry);
+void cache_insert(struct cache *cache, void *data) {
+ struct cache_entry *entry=(struct cache_entry *)((char *)data-cache->entry_size);
+ dbg(lvl_debug,"insert 0x%x 0x%x 0x%x 0x%x 0x%x", entry->id[0], entry->id[1], entry->id[2], entry->id[3], entry->id[4]);
+ if (cache->insert == &cache->t1) {
+ if (cache->t1.size + cache->b1.size >= cache->size) {
+ if (cache->t1.size < cache->size) {
+ cache_remove_lru(cache, &cache->b1);
+ cache_replace(cache);
+ } else {
+ cache_remove_lru(cache, &cache->t1);
+ }
+ } else {
+ if (cache->t1.size + cache->t2.size + cache->b1.size + cache->b2.size >= cache->size) {
+ if (cache->t1.size + cache->t2.size + cache->b1.size + cache->b2.size >= 2*cache->size)
+ cache_remove_lru(cache, &cache->b2);
+ cache_replace(cache);
+ }
+ }
+ }
+ cache_insert_mru(cache, cache->insert, entry);
}
-void *
-cache_insert_new(struct cache *cache, void *id, int size)
-{
- void *data=cache_entry_new(cache, id, size);
- cache_insert(cache, data);
- return data;
+void *cache_insert_new(struct cache *cache, void *id, int size) {
+ void *data=cache_entry_new(cache, id, size);
+ cache_insert(cache, data);
+ return data;
}
-static void
-cache_stats(struct cache *cache)
-{
- dbg(lvl_debug,"hits %d misses %d hitratio %d size %d entry_size %d id_size %d T1 target %d\n", cache->hits, cache->misses, cache->hits*100/(cache->hits+cache->misses), cache->size, cache->entry_size, cache->id_size, cache->t1_target);
- dbg(lvl_debug,"T1:%d B1:%d T2:%d B2:%d\n", cache->t1.size, cache->b1.size, cache->t2.size, cache->b2.size);
- cache->hits=0;
- cache->misses=0;
+static void cache_stats(struct cache *cache) {
+ dbg(lvl_debug,"hits %d misses %d hitratio %d size %d entry_size %d id_size %d T1 target %d", cache->hits, cache->misses,
+ cache->hits*100/(cache->hits+cache->misses), cache->size, cache->entry_size, cache->id_size, cache->t1_target);
+ dbg(lvl_debug,"T1:%d B1:%d T2:%d B2:%d", cache->t1.size, cache->b1.size, cache->t2.size, cache->b2.size);
+ cache->hits=0;
+ cache->misses=0;
}
-void
-cache_dump(struct cache *cache)
-{
- cache_stats(cache);
- cache_list_dump("T1", cache, &cache->t1);
- cache_list_dump("B1", cache, &cache->b1);
- cache_list_dump("T2", cache, &cache->t2);
- cache_list_dump("B2", cache, &cache->b2);
- dbg(lvl_debug,"dump end\n");
+void cache_dump(struct cache *cache) {
+ cache_stats(cache);
+ cache_list_dump("T1", cache, &cache->t1);
+ cache_list_dump("B1", cache, &cache->b1);
+ cache_list_dump("T2", cache, &cache->t2);
+ cache_list_dump("B2", cache, &cache->b2);
+ dbg(lvl_debug,"dump end");
}
diff --git a/navit/callback.c b/navit/callback.c
index 293fab0af..c9ce5adea 100644
--- a/navit/callback.c
+++ b/navit/callback.c
@@ -24,255 +24,219 @@
#include "callback.h"
struct callback {
- /* func has variable number of arguments, not (void),
- * but we must declare something... */
- void (*func)(void);
- int pcount;
- enum attr_type type;
- void *p[0];
-
+ /* func has variable number of arguments, not (void),
+ * but we must declare something... */
+ void (*func)(void);
+ int pcount;
+ enum attr_type type;
+ void *p[0];
+
};
struct callback_list {
- GList *list;
+ GList *list;
};
-struct callback_list *
-callback_list_new(void)
-{
- struct callback_list *ret=g_new0(struct callback_list, 1);
-
- return ret;
-}
-
-struct callback *
-callback_new_attr(void (*func)(void), enum attr_type type, int pcount, void **p)
-{
- struct callback *ret;
- int i;
-
- ret=g_malloc0(sizeof(struct callback)+pcount*sizeof(void *));
- ret->func=func;
- ret->pcount=pcount;
- ret->type=type;
- for (i = 0 ; i < pcount ; i++) {
- ret->p[i]=p[i];
- }
- return ret;
-}
-
-struct callback *
-callback_new_attr_args(void (*func)(void), enum attr_type type, int count, ...)
-{
- int i;
- void **p=g_alloca(sizeof(void*)*count);
- va_list ap;
- va_start(ap, count);
- for (i = 0 ; i < count ; i++)
- p[i]=va_arg(ap, void *);
- va_end(ap);
- return callback_new_attr(func, type, count, p);
-}
-
-struct callback *
-callback_new(void (*func)(void), int pcount, void **p)
-{
- return callback_new_attr(func, attr_none, pcount, p);
-}
-
-struct callback *
-callback_new_args(void (*func)(void), int count, ...)
-{
- int i;
- void **p=g_alloca(sizeof(void*)*count);
- va_list ap;
- va_start(ap, count);
- for (i = 0 ; i < count ; i++)
- p[i]=va_arg(ap, void *);
- va_end(ap);
- return callback_new(func, count, p);
-}
-
-void
-callback_destroy(struct callback *cb)
-{
- g_free(cb);
-}
-
-void
-callback_set_arg(struct callback *cb, int arg, void *p)
-{
- if (arg < 0 || arg > cb->pcount)
- return;
- cb->p[arg]=p;
-}
-
-void
-callback_list_add(struct callback_list *l, struct callback *cb)
-{
- l->list=g_list_prepend(l->list, cb);
-}
-
+struct callback_list * callback_list_new(void) {
+ struct callback_list *ret=g_new0(struct callback_list, 1);
-struct callback *
-callback_list_add_new(struct callback_list *l, void (*func)(void), int pcount, void **p)
-{
- struct callback *ret;
-
- ret=callback_new(func, pcount, p);
- callback_list_add(l, ret);
- return ret;
+ return ret;
}
-void
-callback_list_remove(struct callback_list *l, struct callback *cb)
-{
- l->list=g_list_remove(l->list, cb);
-}
-
-void
-callback_list_remove_destroy(struct callback_list *l, struct callback *cb)
-{
- callback_list_remove(l, cb);
- g_free(cb);
-}
-
-void
-callback_call(struct callback *cb, int pcount, void **p)
-{
- int i;
- void *pf[8];
- if (! cb)
- return;
- if (cb->pcount + pcount <= 8) {
- dbg(lvl_debug,"cb->pcount=%d\n", cb->pcount);
- if (cb->pcount && cb->p)
- dbg(lvl_debug,"cb->p[0]=%p\n", cb->p[0]);
- dbg(lvl_debug,"pcount=%d\n", pcount);
- if (pcount) {
- dbg_assert(p!=NULL);
- dbg(lvl_debug,"p[0]=%p\n", p[0]);
- }
- for (i = 0 ; i < cb->pcount ; i++)
- pf[i]=cb->p[i];
- for (i = 0 ; i < pcount ; i++)
- pf[i+cb->pcount]=p[i];
- switch (cb->pcount+pcount) {
- case 8:
- ((int (*)(void*,void*,void*,void*,void*,void*,void*,void*))cb->func)(
- pf[0],pf[1],pf[2],pf[3],pf[4],pf[5],pf[6],pf[7]);
- break;
- case 7:
- ((int (*)(void*,void*,void*,void*,void*,void*,void*))cb->func)(
- pf[0],pf[1],pf[2],pf[3],pf[4],pf[5],pf[6]);
- break;
- case 6:
- ((int (*)(void*,void*,void*,void*,void*,void*))cb->func)(
- pf[0],pf[1],pf[2],pf[3],pf[4],pf[5]);
- break;
- case 5:
- ((int (*)(void*,void*,void*,void*,void*))cb->func)(
- pf[0],pf[1],pf[2],pf[3],pf[4]);
- break;
- case 4:
- ((int (*)(void*,void*,void*,void*))cb->func)(
- pf[0],pf[1],pf[2],pf[3]);
- break;
- case 3:
- ((int (*)(void*,void*,void*))cb->func)(
- pf[0],pf[1],pf[2]);
- break;
- case 2:
- ((int (*)(void*,void*))cb->func)(
- pf[0],pf[1]);
- break;
- case 1:
- ((int (*)(void*))cb->func)(
- pf[0]);
- break;
- case 0:
- cb->func();
- break;
- }
- } else {
- dbg(lvl_error,"too many parameters for callback (%d+%d)\n", cb->pcount, pcount);
- }
-}
-
-void
-callback_call_args(struct callback *cb, int count, ...)
-{
- int i;
- void **p=g_alloca(sizeof(void*)*count);
- va_list ap;
- va_start(ap, count);
- for (i = 0 ; i < count ; i++)
- p[i]=va_arg(ap, void *);
- va_end(ap);
- callback_call(cb, count, p);
-}
-
-void
-callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount, void **p)
-{
- GList *cbi;
- struct callback *cb;
-
- if (!l) {
- return;
- }
-
- cbi=l->list;
- while (cbi) {
- cb=cbi->data;
- if (type == attr_any || cb->type == attr_any || cb->type == type)
- callback_call(cb, pcount, p);
- cbi=g_list_next(cbi);
- }
-
-}
-
-void
-callback_list_call_attr_args(struct callback_list *cbl, enum attr_type type, int count, ...)
-{
- int i;
- void **p=g_alloca(sizeof(void*)*count);
- va_list ap;
- va_start(ap, count);
- for (i = 0 ; i < count ; i++)
- p[i]=va_arg(ap, void *);
- va_end(ap);
- callback_list_call_attr(cbl, type, count, p);
-}
-
-void
-callback_list_call(struct callback_list *l, int pcount, void **p)
-{
- callback_list_call_attr(l, attr_any, pcount, p);
-}
-
-void
-callback_list_call_args(struct callback_list *cbl, int count, ...)
-{
- int i;
- void **p=g_alloca(sizeof(void*)*count);
- va_list ap;
- va_start(ap, count);
- for (i = 0 ; i < count ; i++)
- p[i]=va_arg(ap, void *);
- va_end(ap);
- callback_list_call(cbl, count, p);
-}
+struct callback * callback_new_attr(void (*func)(void), enum attr_type type, int pcount, void **p) {
+ struct callback *ret;
+ int i;
-void
-callback_list_destroy(struct callback_list *l)
-{
- GList *cbi;
- cbi=l->list;
- while (cbi) {
- g_free(cbi->data);
- cbi=g_list_next(cbi);
- }
- g_list_free(l->list);
- g_free(l);
+ ret=g_malloc0(sizeof(struct callback)+pcount*sizeof(void *));
+ ret->func=func;
+ ret->pcount=pcount;
+ ret->type=type;
+ for (i = 0 ; i < pcount ; i++) {
+ ret->p[i]=p[i];
+ }
+ return ret;
+}
+
+struct callback * callback_new_attr_args(void (*func)(void), enum attr_type type, int count, ...) {
+ int i;
+ void **p=g_alloca(sizeof(void*)*count);
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ return callback_new_attr(func, type, count, p);
+}
+
+struct callback * callback_new(void (*func)(void), int pcount, void **p) {
+ return callback_new_attr(func, attr_none, pcount, p);
+}
+
+struct callback * callback_new_args(void (*func)(void), int count, ...) {
+ int i;
+ void **p=g_alloca(sizeof(void*)*count);
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ return callback_new(func, count, p);
+}
+
+void callback_destroy(struct callback *cb) {
+ g_free(cb);
+}
+
+void callback_set_arg(struct callback *cb, int arg, void *p) {
+ if (arg < 0 || arg > cb->pcount)
+ return;
+ cb->p[arg]=p;
+}
+
+void callback_list_add(struct callback_list *l, struct callback *cb) {
+ l->list=g_list_prepend(l->list, cb);
+}
+
+
+struct callback * callback_list_add_new(struct callback_list *l, void (*func)(void), int pcount, void **p) {
+ struct callback *ret;
+
+ ret=callback_new(func, pcount, p);
+ callback_list_add(l, ret);
+ return ret;
+}
+
+void callback_list_remove(struct callback_list *l, struct callback *cb) {
+ l->list=g_list_remove(l->list, cb);
+}
+
+void callback_list_remove_destroy(struct callback_list *l, struct callback *cb) {
+ callback_list_remove(l, cb);
+ g_free(cb);
+}
+
+void callback_call(struct callback *cb, int pcount, void **p) {
+ int i;
+ void *pf[8];
+ if (! cb)
+ return;
+ if (cb->pcount + pcount <= 8) {
+ dbg(lvl_debug,"cb->pcount=%d", cb->pcount);
+ if (cb->pcount && cb->p)
+ dbg(lvl_debug,"cb->p[0]=%p", cb->p[0]);
+ dbg(lvl_debug,"pcount=%d", pcount);
+ if (pcount) {
+ dbg_assert(p!=NULL);
+ dbg(lvl_debug,"p[0]=%p", p[0]);
+ }
+ for (i = 0 ; i < cb->pcount ; i++)
+ pf[i]=cb->p[i];
+ for (i = 0 ; i < pcount ; i++)
+ pf[i+cb->pcount]=p[i];
+ switch (cb->pcount+pcount) {
+ case 8:
+ ((int (*)(void*,void*,void*,void*,void*,void*,void*,void*))cb->func)(
+ pf[0],pf[1],pf[2],pf[3],pf[4],pf[5],pf[6],pf[7]);
+ break;
+ case 7:
+ ((int (*)(void*,void*,void*,void*,void*,void*,void*))cb->func)(
+ pf[0],pf[1],pf[2],pf[3],pf[4],pf[5],pf[6]);
+ break;
+ case 6:
+ ((int (*)(void*,void*,void*,void*,void*,void*))cb->func)(
+ pf[0],pf[1],pf[2],pf[3],pf[4],pf[5]);
+ break;
+ case 5:
+ ((int (*)(void*,void*,void*,void*,void*))cb->func)(
+ pf[0],pf[1],pf[2],pf[3],pf[4]);
+ break;
+ case 4:
+ ((int (*)(void*,void*,void*,void*))cb->func)(
+ pf[0],pf[1],pf[2],pf[3]);
+ break;
+ case 3:
+ ((int (*)(void*,void*,void*))cb->func)(
+ pf[0],pf[1],pf[2]);
+ break;
+ case 2:
+ ((int (*)(void*,void*))cb->func)(
+ pf[0],pf[1]);
+ break;
+ case 1:
+ ((int (*)(void*))cb->func)(
+ pf[0]);
+ break;
+ case 0:
+ cb->func();
+ break;
+ }
+ } else {
+ dbg(lvl_error,"too many parameters for callback (%d+%d)", cb->pcount, pcount);
+ }
+}
+
+void callback_call_args(struct callback *cb, int count, ...) {
+ int i;
+ void **p=g_alloca(sizeof(void*)*count);
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ callback_call(cb, count, p);
+}
+
+void callback_list_call_attr(struct callback_list *l, enum attr_type type, int pcount, void **p) {
+ GList *cbi;
+ struct callback *cb;
+
+ if (!l) {
+ return;
+ }
+
+ cbi=l->list;
+ while (cbi) {
+ cb=cbi->data;
+ if (type == attr_any || cb->type == attr_any || cb->type == type)
+ callback_call(cb, pcount, p);
+ cbi=g_list_next(cbi);
+ }
+
+}
+
+void callback_list_call_attr_args(struct callback_list *cbl, enum attr_type type, int count, ...) {
+ int i;
+ void **p=g_alloca(sizeof(void*)*count);
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ callback_list_call_attr(cbl, type, count, p);
+}
+
+void callback_list_call(struct callback_list *l, int pcount, void **p) {
+ callback_list_call_attr(l, attr_any, pcount, p);
+}
+
+void callback_list_call_args(struct callback_list *cbl, int count, ...) {
+ int i;
+ void **p=g_alloca(sizeof(void*)*count);
+ va_list ap;
+ va_start(ap, count);
+ for (i = 0 ; i < count ; i++)
+ p[i]=va_arg(ap, void *);
+ va_end(ap);
+ callback_list_call(cbl, count, p);
+}
+
+void callback_list_destroy(struct callback_list *l) {
+ GList *cbi;
+ cbi=l->list;
+ while (cbi) {
+ g_free(cbi->data);
+ cbi=g_list_next(cbi);
+ }
+ g_list_free(l->list);
+ g_free(l);
}
diff --git a/navit/command.c b/navit/command.c
index 4208c575c..032e0f887 100644
--- a/navit/command.c
+++ b/navit/command.c
@@ -19,8 +19,8 @@
/*
gui.fullscreen=!gui.fullscreen
gui.menu()
-gui.get_data()
-zoom_in()
+gui.get_data()
+zoom_in()
zoom_out()
speech.active=!speech.active
osd_configuration=1
@@ -32,75 +32,75 @@ osd[@type=="xxx"].active=0;osd[@type=="yyy"].active=0
* The result, or interim result, of evaluating a saved command.
*/
struct result {
- struct attr attr; /**< The attribute. If {@code allocated} is true, it stores an object that was
+ struct attr attr; /**< The attribute. If {@code allocated} is true, it stores an object that was
* successfully retrieved. Else it is either a placeholder or a constant value.
*/
- double val;
- const char *var; /**< If {@code allocated} is false, the name of the object to be resolved.
+ double val;
+ const char *var; /**< If {@code allocated} is false, the name of the object to be resolved.
* Else, it is the name of the object successfully retrieved and stored in
* {@code attr}, or {@code NULL} if retrieval failed.
* Only the first {@code varlen} characters are significant.
*/
- int varlen; /**< Number of significant characters in {@code var} */
- const char *attrn; /**< The name of an object that has been resolved but not yet retrieved,
+ int varlen; /**< Number of significant characters in {@code var} */
+ const char *attrn; /**< The name of an object that has been resolved but not yet retrieved,
* {@code NULL} otherwise. Only the first {@code attrnlen} characters are
* significant.
*/
- int attrnlen; /**< Number of significant characters in {@code attrn} */
- int allocated; /**< Whether the result has been calculated */
+ int attrnlen; /**< Number of significant characters in {@code attrn} */
+ int allocated; /**< Whether the result has been calculated */
};
struct result_list {
- struct attr **attrs;
+ struct attr **attrs;
};
struct context {
- struct attr *attr;
- int error;
- int skip;
- const char *expr;
- struct result res;
+ struct attr *attr;
+ int error;
+ int skip;
+ const char *expr;
+ struct result res;
};
/**
* Information about a callback function for a saved command.
*/
struct command_saved_cb {
- struct callback *cb; /**< The callback function */
- struct attr attr;
+ struct callback *cb; /**< The callback function */
+ struct attr attr;
};
/**
* A saved command.
*/
struct command_saved {
- struct context ctx;
- struct result res;
- char *command; /**< The command string itself **/
- struct event_idle *idle_ev; /**< Event to update this command **/
- struct callback *idle_cb;
- struct callback *register_cb; /**< Callback to register all the callbacks **/
- struct event_idle *register_ev; /**< Idle event to register all the callbacks **/
- struct attr context_attr; /**< The root of the object hierarchy, which will be assumed as
+ struct context ctx;
+ struct result res;
+ char *command; /**< The command string itself **/
+ struct event_idle *idle_ev; /**< Event to update this command **/
+ struct callback *idle_cb;
+ struct callback *register_cb; /**< Callback to register all the callbacks **/
+ struct event_idle *register_ev; /**< Idle event to register all the callbacks **/
+ struct attr context_attr; /**< The root of the object hierarchy, which will be assumed as
* the parent of all unqualified or partially qualified object
* references. **/
- int num_cbs; /**< Number of entries in {@code cbs} **/
- struct command_saved_cb *cbs; /**< List of callbacks for this saved command **/
- struct callback *cb; /**< Callback that should be called when we re-evaluate **/
- int error;
- int async;
+ int num_cbs; /**< Number of entries in {@code cbs} **/
+ struct command_saved_cb *cbs; /**< List of callbacks for this saved command **/
+ struct callback *cb; /**< Callback that should be called when we re-evaluate **/
+ int error;
+ int async;
};
enum error {
- no_error=0, missing_double_quote, missing_opening_parenthesis, missing_closing_parenthesis, missing_closing_brace, missing_colon, missing_semicolon, wrong_type, illegal_number_format, illegal_character, missing_closing_bracket, invalid_type, not_ready, internal, eof_reached
+ no_error=0, missing_double_quote, missing_opening_parenthesis, missing_closing_parenthesis, missing_closing_brace, missing_colon, missing_semicolon, wrong_type, illegal_number_format, illegal_character, missing_closing_bracket, invalid_type, not_ready, internal, eof_reached
};
enum op_type {
- op_type_binary, op_type_prefix, op_type_suffix
+ op_type_binary, op_type_prefix, op_type_suffix
};
enum set_type {
- set_type_symbol, set_type_string, set_type_integer, set_type_float
+ set_type_symbol, set_type_string, set_type_integer, set_type_float
};
@@ -117,80 +117,76 @@ static struct attr ** eval_list(struct context *ctx);
* calling {@code g_free()} when it is no longer needed.
*/
char *command_error_to_text(int err) {
- switch (err) {
- case no_error:
- return g_strdup("no_error");
- case missing_double_quote:
- return g_strdup("missing_double_quote");
- case missing_opening_parenthesis:
- return g_strdup("missing_opening_parenthesis");
- case missing_closing_parenthesis:
- return g_strdup("missing_closing_parenthesis");
- case missing_closing_brace:
- return g_strdup("missing_closing_brace");
- case missing_colon:
- return g_strdup("missing_colon");
- case missing_semicolon:
- return g_strdup("missing_semicolon");
- case wrong_type:
- return g_strdup("wrong_type");
- case illegal_number_format:
- return g_strdup("illegal_number_format");
- case illegal_character:
- return g_strdup("illegal_character");
- case missing_closing_bracket:
- return g_strdup("missing_closing_bracket");
- case invalid_type:
- return g_strdup("invalid_type");
- case not_ready:
- return g_strdup("not_ready");
- case internal:
- return g_strdup("internal");
- case eof_reached:
- return g_strdup("eof_reached");
- default:
- return g_strdup("unknown");
- }
-}
-
-static void
-result_free(struct result *res)
-{
- if(res->allocated) {
- attr_free_content(&res->attr);
- res->allocated=0;
- } else {
- res->attr.type=type_none;
- res->attr.u.data=NULL;
- }
+ switch (err) {
+ case no_error:
+ return g_strdup("no_error");
+ case missing_double_quote:
+ return g_strdup("missing_double_quote");
+ case missing_opening_parenthesis:
+ return g_strdup("missing_opening_parenthesis");
+ case missing_closing_parenthesis:
+ return g_strdup("missing_closing_parenthesis");
+ case missing_closing_brace:
+ return g_strdup("missing_closing_brace");
+ case missing_colon:
+ return g_strdup("missing_colon");
+ case missing_semicolon:
+ return g_strdup("missing_semicolon");
+ case wrong_type:
+ return g_strdup("wrong_type");
+ case illegal_number_format:
+ return g_strdup("illegal_number_format");
+ case illegal_character:
+ return g_strdup("illegal_character");
+ case missing_closing_bracket:
+ return g_strdup("missing_closing_bracket");
+ case invalid_type:
+ return g_strdup("invalid_type");
+ case not_ready:
+ return g_strdup("not_ready");
+ case internal:
+ return g_strdup("internal");
+ case eof_reached:
+ return g_strdup("eof_reached");
+ default:
+ return g_strdup("unknown");
+ }
+}
+
+static void result_free(struct result *res) {
+ if(res->allocated) {
+ attr_free_content(&res->attr);
+ res->allocated=0;
+ } else {
+ res->attr.type=type_none;
+ res->attr.u.data=NULL;
+ }
}
static int command_register_callbacks(struct command_saved *cs);
-static const char *
-get_op(struct context *ctx, int test, ...)
-{
- char *op;
- const char *ret=NULL;
- va_list ap;
-
- while (*ctx->expr && g_ascii_isspace(*ctx->expr)) {
- ctx->expr++;
- }
-
- va_start(ap, test);
- while ((op = va_arg(ap, char *))) {
- if (!strncmp(ctx->expr, op, strlen(op))) {
- ret=op;
- if (! test)
- ctx->expr+=strlen(op);
- break;
- }
- }
- va_end(ap);
- return ret;
+static const char *get_op(struct context *ctx, int test, ...) {
+ char *op;
+ const char *ret=NULL;
+ va_list ap;
+
+ while (*ctx->expr && g_ascii_isspace(*ctx->expr)) {
+ ctx->expr++;
+ }
+
+ va_start(ap, test);
+ while ((op = va_arg(ap, char *))) {
+ if (!strncmp(ctx->expr, op, strlen(op))) {
+ ret=op;
+ if (! test)
+ ctx->expr+=strlen(op);
+ break;
+ }
+ }
+ va_end(ap);
+ return ret;
}
/*static int
@@ -199,37 +195,31 @@ is_int(struct result *res)
return 1;
}*/
-static int
-is_double(struct result *res)
-{
- return 0;
+static int is_double(struct result *res) {
+ return 0;
}
-static void
-dump(struct result *res)
-{
+static void dump(struct result *res) {
#if 0
- char object[res->varlen+1];
- char attribute[res->attrnlen+1];
- if (res->var)
- strncpy(object, res->var, res->varlen);
- object[res->varlen]='\0';
- if (res->attrn)
- strncpy(attribute, res->attrn, res->attrnlen);
- attribute[res->attrnlen]='\0';
- dbg(lvl_debug,"type:%s\n", attr_to_name(res->attr.type));
- dbg(lvl_debug,"attribute '%s' from '%s'\n", attribute, object);
+ char object[res->varlen+1];
+ char attribute[res->attrnlen+1];
+ if (res->var)
+ strncpy(object, res->var, res->varlen);
+ object[res->varlen]='\0';
+ if (res->attrn)
+ strncpy(attribute, res->attrn, res->attrnlen);
+ attribute[res->attrnlen]='\0';
+ dbg(lvl_debug,"type:%s", attr_to_name(res->attr.type));
+ dbg(lvl_debug,"attribute '%s' from '%s'", attribute, object);
#endif
}
-static enum attr_type
-command_attr_type(struct result *res)
-{
- char *attrn=g_alloca(sizeof(char)*(res->attrnlen+1));
+static enum attr_type command_attr_type(struct result *res) {
+ char *attrn=g_alloca(sizeof(char)*(res->attrnlen+1));
- strncpy(attrn, res->attrn, res->attrnlen);
- attrn[res->attrnlen]='\0';
- return attr_from_name(attrn);
+ strncpy(attrn, res->attrn, res->attrnlen);
+ attrn[res->attrnlen]='\0';
+ return attr_from_name(attrn);
}
/**
@@ -247,40 +237,35 @@ command_attr_type(struct result *res)
* @return True if a matching attribute was found, false if no matching attribute was found or an error
* occurred
*/
-static int
-command_object_get_attr(struct context *ctx, struct attr *object, enum attr_type attr_type, struct attr *ret)
-{
- int r;
- struct attr dup;
- struct object_func *func=object_func_lookup(object->type);
- if (!object->u.data || !func || !func->get_attr) {
- dbg(lvl_warning, "cannot retrieve attributes from %s (%p), func=%p\n", attr_to_name(object->type), object->u.data, func)
- return 0;
- }
- r=func->get_attr(object->u.data, attr_type, &dup, NULL);
- if(r)
- attr_dup_content(&dup,ret);
- else
- dbg(lvl_warning, "%s (%p) has no attribute %s\n", attr_to_name(object->type), object->u.data, attr_to_name(attr_type))
- return r;
-}
-
-static int
-command_object_add_attr(struct context *ctx, struct attr *object, struct attr *attr)
-{
- struct object_func *func=object_func_lookup(object->type);
- if (!object->u.data || !func || !func->add_attr)
- return 0;
- return func->add_attr(object->u.data, attr);
-}
-
-static int
-command_object_remove_attr(struct context *ctx, struct attr *object, struct attr *attr)
-{
- struct object_func *func=object_func_lookup(object->type);
- if (!object->u.data || !func || !func->remove_attr)
- return 0;
- return func->remove_attr(object->u.data, attr);
+static int command_object_get_attr(struct context *ctx, struct attr *object, enum attr_type attr_type,
+ struct attr *ret) {
+ int r;
+ struct attr dup;
+ struct object_func *func=object_func_lookup(object->type);
+ if (!object->u.data || !func || !func->get_attr) {
+ dbg(lvl_warning, "cannot retrieve attributes from %s (%p), func=%p", attr_to_name(object->type), object->u.data, func)
+ return 0;
+ }
+ r=func->get_attr(object->u.data, attr_type, &dup, NULL);
+ if(r)
+ attr_dup_content(&dup,ret);
+ else
+ dbg(lvl_warning, "%s (%p) has no attribute %s", attr_to_name(object->type), object->u.data, attr_to_name(attr_type))
+ return r;
+}
+
+static int command_object_add_attr(struct context *ctx, struct attr *object, struct attr *attr) {
+ struct object_func *func=object_func_lookup(object->type);
+ if (!object->u.data || !func || !func->add_attr)
+ return 0;
+ return func->add_attr(object->u.data, attr);
+}
+
+static int command_object_remove_attr(struct context *ctx, struct attr *object, struct attr *attr) {
+ struct object_func *func=object_func_lookup(object->type);
+ if (!object->u.data || !func || !func->remove_attr)
+ return 0;
+ return func->remove_attr(object->u.data, attr);
}
@@ -305,58 +290,54 @@ command_object_remove_attr(struct context *ctx, struct attr *object, struct attr
* @param ctx The context
* @param res The result
*/
-static void
-command_get_attr(struct context *ctx, struct result *res)
-{
- int result;
- struct result tmp={{0,},};
- enum attr_type attr_type=command_attr_type(res);
- enum attr_type parent_type = res->attr.type; /* for debugging only */
- if (ctx->skip)
- return;
- result=command_object_get_attr(ctx, &res->attr, attr_type, &tmp.attr);
- result_free(res);
- *res=tmp;
- res->allocated=1;
- if (result) {
- dbg(lvl_debug, "successfully retrieved '%s' from '%s'\n", attr_to_name(attr_type), attr_to_name(parent_type));
- res->var=res->attrn;
- res->varlen=res->attrnlen;
- } else {
- dbg(lvl_warning, "could not retrieve '%s' from '%s'\n", attr_to_name(attr_type), attr_to_name(parent_type));
- result_free(res);
- res->attr.type=attr_none;
- res->var=NULL;
- res->varlen=0;
- }
- res->attrn=NULL;
- res->attrnlen=0;
- dump(res);
-}
-
-static void
-command_set_attr(struct context *ctx, struct result *res, struct result *newres)
-{
- enum attr_type attr_type=command_attr_type(res);
- struct object_func *func=object_func_lookup(res->attr.type);
- if (ctx->skip)
- return;
- if (!res->attr.u.data || !func || !func->set_attr)
- return;
- if (attr_type == attr_attr_types) {
- char *attrn=g_alloca(sizeof(char)*(res->attrnlen+1));
- struct attr *tmp;
- strncpy(attrn, res->attrn, res->attrnlen);
- attrn[res->attrnlen]='\0';
- tmp=attr_new_from_text(attrn, newres->attr.u.str);
- newres->attr.u.data=tmp->u.data;
- newres->allocated=1;
- g_free(tmp);
- }
- newres->attr.type=attr_type;
- func->set_attr(res->attr.u.data, &newres->attr);
- result_free(res);
- *res=*newres;
+static void command_get_attr(struct context *ctx, struct result *res) {
+ int result;
+ struct result tmp= {{0,},};
+ enum attr_type attr_type=command_attr_type(res);
+ enum attr_type parent_type = res->attr.type; /* for debugging only */
+ if (ctx->skip)
+ return;
+ result=command_object_get_attr(ctx, &res->attr, attr_type, &tmp.attr);
+ result_free(res);
+ *res=tmp;
+ res->allocated=1;
+ if (result) {
+ dbg(lvl_debug, "successfully retrieved '%s' from '%s'", attr_to_name(attr_type), attr_to_name(parent_type));
+ res->var=res->attrn;
+ res->varlen=res->attrnlen;
+ } else {
+ dbg(lvl_warning, "could not retrieve '%s' from '%s'", attr_to_name(attr_type), attr_to_name(parent_type));
+ result_free(res);
+ res->attr.type=attr_none;
+ res->var=NULL;
+ res->varlen=0;
+ }
+ res->attrn=NULL;
+ res->attrnlen=0;
+ dump(res);
+}
+
+static void command_set_attr(struct context *ctx, struct result *res, struct result *newres) {
+ enum attr_type attr_type=command_attr_type(res);
+ struct object_func *func=object_func_lookup(res->attr.type);
+ if (ctx->skip)
+ return;
+ if (!res->attr.u.data || !func || !func->set_attr)
+ return;
+ if (attr_type == attr_attr_types) {
+ char *attrn=g_alloca(sizeof(char)*(res->attrnlen+1));
+ struct attr *tmp;
+ strncpy(attrn, res->attrn, res->attrnlen);
+ attrn[res->attrnlen]='\0';
+ tmp=attr_new_from_text(attrn, newres->attr.u.str);
+ newres->attr.u.data=tmp->u.data;
+ newres->allocated=1;
+ g_free(tmp);
+ }
+ newres->attr.type=attr_type;
+ func->set_attr(res->attr.u.data, &newres->attr);
+ result_free(res);
+ *res=*newres;
}
/**
@@ -373,16 +354,14 @@ command_set_attr(struct context *ctx, struct result *res, struct result *newres)
* @param ctx The context
* @param res The result
*/
-static void
-resolve_object(struct context *ctx, struct result *res)
-{
- if (res->attr.type == attr_none && res->varlen) {
- res->attr=*ctx->attr;
- res->attrn=res->var;
- res->attrnlen=res->varlen;
- res->var=NULL;
- res->varlen=0;
- }
+static void resolve_object(struct context *ctx, struct result *res) {
+ if (res->attr.type == attr_none && res->varlen) {
+ res->attr=*ctx->attr;
+ res->attrn=res->var;
+ res->attrnlen=res->varlen;
+ res->var=NULL;
+ res->varlen=0;
+ }
}
/**
@@ -403,19 +382,15 @@ resolve_object(struct context *ctx, struct result *res)
* @param ctx The context
* @param res The result
*/
-static void
-resolve(struct context *ctx, struct result *res)
-{
- resolve_object(ctx, res);
- if (res->attrn)
- command_get_attr(ctx, res);
+static void resolve(struct context *ctx, struct result *res) {
+ resolve_object(ctx, res);
+ if (res->attrn)
+ command_get_attr(ctx, res);
}
-static double
-get_double(struct context *ctx, struct result *res)
-{
- resolve(ctx, res);
- return res->val;
+static double get_double(struct context *ctx, struct result *res) {
+ resolve(ctx, res);
+ return res->val;
}
@@ -439,25 +414,23 @@ get_double(struct context *ctx, struct result *res)
*
* @return The result of the expression, see description.
*/
-static int
-get_int_bool(struct context *ctx, int is_bool, struct result *res)
-{
- resolve(ctx, res);
- if (res->attr.type == attr_none)
- return 0;
- if (res->attr.type >= attr_type_int_begin && res->attr.type <= attr_type_int_end) {
- return res->attr.u.num;
- }
- if (res->attr.type >= attr_type_double_begin && res->attr.type <= attr_type_double_end) {
- return (int) (*res->attr.u.numd);
- }
- if (is_bool && ATTR_IS_OBJECT(res->attr.type))
- return res->attr.u.data != NULL;
- if (is_bool && ATTR_IS_STRING(res->attr.type))
- return res->attr.u.data != NULL;
- dbg(lvl_debug,"bool %d %s\n",is_bool,attr_to_name(res->attr.type));
- ctx->error=wrong_type;
- return 0;
+static int get_int_bool(struct context *ctx, int is_bool, struct result *res) {
+ resolve(ctx, res);
+ if (res->attr.type == attr_none)
+ return 0;
+ if (res->attr.type >= attr_type_int_begin && res->attr.type <= attr_type_int_end) {
+ return res->attr.u.num;
+ }
+ if (res->attr.type >= attr_type_double_begin && res->attr.type <= attr_type_double_end) {
+ return (int) (*res->attr.u.numd);
+ }
+ if (is_bool && ATTR_IS_OBJECT(res->attr.type))
+ return res->attr.u.data != NULL;
+ if (is_bool && ATTR_IS_STRING(res->attr.type))
+ return res->attr.u.data != NULL;
+ dbg(lvl_debug,"bool %d %s",is_bool,attr_to_name(res->attr.type));
+ ctx->error=wrong_type;
+ return 0;
}
/**
@@ -466,10 +439,8 @@ get_int_bool(struct context *ctx, int is_bool, struct result *res)
* This function is a wrapper around {@code get_int_bool()}. It is equivalent to
* {@code get_int_bool(ctx, 0, res)}. See {@code get_int_bool()} for a description.
*/
-static int
-get_int(struct context *ctx, struct result *res)
-{
- return get_int_bool(ctx, 0, res);
+static int get_int(struct context *ctx, struct result *res) {
+ return get_int_bool(ctx, 0, res);
}
/**
@@ -478,188 +449,177 @@ get_int(struct context *ctx, struct result *res)
* This function is a wrapper around {@code get_int_bool()}. It is equivalent to
* {@code get_int_bool(ctx, 1, res)}. See {@code get_int_bool()} for a description.
*/
-static int
-get_bool(struct context *ctx, struct result *res)
-{
- return !!get_int_bool(ctx, 1, res);
-}
-
-
-static char *
-get_string(struct context *ctx, struct result *res)
-{
- resolve(ctx, res);
- return attr_to_text(&res->attr, NULL, 0);
-}
-
-static void
-set_double(struct result *res, double val)
-{
- result_free(res);
- res->attr.type=attr_type_double_begin;
- res->attr.u.numd=&res->val;
- res->val=val;
-}
-
-static void
-set_int(struct result *res, int val)
-{
- result_free(res);
- res->attr.type=attr_type_int_begin;
- res->attr.u.num=val;
-}
-
-static void
-result_op(struct context *ctx, enum op_type op_type, const char *op, struct result *inout, struct result *in)
-{
- if (ctx->skip)
- return;
- switch (op_type) {
- case op_type_prefix:
- switch ((op[0] << 8) | op[1]) {
- case ('!' << 8):
- set_int(inout, !get_bool(ctx, inout));
- return;
- case ('~' << 8):
- set_int(inout, ~get_int(ctx, inout));
- return;
- }
- break;
- case op_type_binary:
- resolve(ctx, inout);
- resolve(ctx, in);
- switch ((op[0] << 8) | op[1]) {
- case ('=' << 8)|'=':
- if (inout->attr.type == attr_none || in->attr.type == attr_none) {
- set_int(inout, 0);
- } else if (ATTR_IS_STRING(inout->attr.type) && ATTR_IS_STRING(in->attr.type)) {
- char *s1=get_string(ctx, inout),*s2=get_string(ctx, in);
- set_int(inout, (!strcmp(s1,s2)));
- g_free(s1);
- g_free(s2);
- } else if (ATTR_IS_OBJECT(inout->attr.type) && ATTR_IS_OBJECT(in->attr.type)) {
- set_int(inout, inout->attr.u.data == in->attr.u.data);
- } else
- set_int(inout, (get_int(ctx, inout) == get_int(ctx, in)));
- return;
- case ('!' << 8)|'=':
- if (inout->attr.type == attr_none || in->attr.type == attr_none) {
- set_int(inout, 1);
- } else if (ATTR_IS_STRING(inout->attr.type) && ATTR_IS_STRING(in->attr.type)) {
- char *s1=get_string(ctx, inout),*s2=get_string(ctx, in);
- set_int(inout, (!!strcmp(s1,s2)));
- g_free(s1);
- g_free(s2);
- } else if (ATTR_IS_OBJECT(inout->attr.type) && ATTR_IS_OBJECT(in->attr.type)) {
- set_int(inout, inout->attr.u.data != in->attr.u.data);
- } else
- set_int(inout, (get_int(ctx, inout) != get_int(ctx, in)));
- return;
- case ('<' << 8):
- set_int(inout, (get_int(ctx, inout) < get_int(ctx, in)));
- return;
- case ('<' << 8)|'=':
- set_int(inout, (get_int(ctx, inout) <= get_int(ctx, in)));
- return;
- case ('>' << 8):
- set_int(inout, (get_int(ctx, inout) > get_int(ctx, in)));
- return;
- case ('>' << 8)|'=':
- set_int(inout, (get_int(ctx, inout) >= get_int(ctx, in)));
- return;
- case ('*' << 8):
- if (is_double(inout) || is_double(in))
- set_double(inout, get_double(ctx, inout) * get_double(ctx, in));
- else
- set_int(inout, get_int(ctx, inout) * get_int(ctx, in));
- return;
- case ('/' << 8):
- if (is_double(inout) || is_double(in))
- set_double(inout, get_double(ctx, inout) * get_double(ctx, in));
- else
- set_int(inout, get_int(ctx, inout) * get_int(ctx, in));
- return;
- case ('%' << 8):
- set_int(inout, get_int(ctx, inout) % get_int(ctx, in));
- return;
- case ('+' << 8):
- if (is_double(inout) || is_double(in))
- set_double(inout, get_double(ctx, inout) + get_double(ctx, in));
- else if (ATTR_IS_STRING(inout->attr.type) && ATTR_IS_STRING(in->attr.type)) {
- char *str=g_strdup_printf("%s%s",inout->attr.u.str,in->attr.u.str);
- result_free(inout);
- inout->attr.type=attr_type_string_begin;
- inout->attr.u.str=str;
- inout->allocated=1;
- } else
- set_int(inout, get_int(ctx, inout) + get_int(ctx, in));
- return;
- case ('-' << 8):
- if (is_double(inout) || is_double(in))
- set_int(inout, get_int(ctx, inout) - get_int(ctx, in));
- else
- set_double(inout, get_double(ctx, inout) - get_double(ctx, in));
- return;
- case ('&' << 8):
- set_int(inout, get_int(ctx, inout) & get_int(ctx, in));
- return;
- case ('^' << 8):
- set_int(inout, get_int(ctx, inout) ^ get_int(ctx, in));
- return;
- case ('|' << 8):
- set_int(inout, get_int(ctx, inout) | get_int(ctx, in));
- return;
- case (('&' << 8) | '&'):
- set_int(inout, get_int(ctx, inout) && get_int(ctx, in));
- return;
- case (('|' << 8) | '|'):
- set_int(inout, get_int(ctx, inout) || get_int(ctx, in));
- return;
- default:
- break;
- }
- default:
- break;
- }
- dbg(lvl_error,"Unkown op %d %s\n",op_type,op);
- ctx->error=internal;
-}
-
-static void
-result_set(struct context *ctx, enum set_type set_type, const char *op, int len, struct result *out)
-{
- if (ctx->skip)
- return;
- switch (set_type) {
- case set_type_symbol:
- out->attr.type=attr_none;
- out->var=op;
- out->varlen=len;
- return;
- case set_type_integer:
- out->attr.type=attr_type_int_begin;
- out->attr.u.num=atoi(ctx->expr);
- return;
- case set_type_float:
- out->val = strtod(ctx->expr, NULL);
- out->attr.type=attr_type_double_begin;
- out->attr.u.numd=&out->val;
- return;
- case set_type_string:
- if (len >= 2) {
- out->attr.type=attr_type_string_begin;
- out->attr.u.str=g_malloc(len-1);
- strncpy(out->attr.u.str, op+1, len-2);
- out->attr.u.str[len-2]='\0';
- out->allocated=1;
- return;
- }
- break;
- default:
- break;
- }
- dbg(lvl_error,"unknown set type %d %s\n",set_type,op);
- ctx->error=internal;
+static int get_bool(struct context *ctx, struct result *res) {
+ return !!get_int_bool(ctx, 1, res);
+}
+
+
+static char *get_string(struct context *ctx, struct result *res) {
+ resolve(ctx, res);
+ return attr_to_text(&res->attr, NULL, 0);
+}
+
+static void set_double(struct result *res, double val) {
+ result_free(res);
+ res->attr.type=attr_type_double_begin;
+ res->attr.u.numd=&res->val;
+ res->val=val;
+}
+
+static void set_int(struct result *res, int val) {
+ result_free(res);
+ res->attr.type=attr_type_int_begin;
+ res->attr.u.num=val;
+}
+
+static void result_op(struct context *ctx, enum op_type op_type, const char *op, struct result *inout,
+ struct result *in) {
+ if (ctx->skip)
+ return;
+ switch (op_type) {
+ case op_type_prefix:
+ switch ((op[0] << 8) | op[1]) {
+ case ('!' << 8):
+ set_int(inout, !get_bool(ctx, inout));
+ return;
+ case ('~' << 8):
+ set_int(inout, ~get_int(ctx, inout));
+ return;
+ }
+ break;
+ case op_type_binary:
+ resolve(ctx, inout);
+ resolve(ctx, in);
+ switch ((op[0] << 8) | op[1]) {
+ case ('=' << 8)|'=':
+ if (inout->attr.type == attr_none || in->attr.type == attr_none) {
+ set_int(inout, 0);
+ } else if (ATTR_IS_STRING(inout->attr.type) && ATTR_IS_STRING(in->attr.type)) {
+ char *s1=get_string(ctx, inout),*s2=get_string(ctx, in);
+ set_int(inout, (!strcmp(s1,s2)));
+ g_free(s1);
+ g_free(s2);
+ } else if (ATTR_IS_OBJECT(inout->attr.type) && ATTR_IS_OBJECT(in->attr.type)) {
+ set_int(inout, inout->attr.u.data == in->attr.u.data);
+ } else
+ set_int(inout, (get_int(ctx, inout) == get_int(ctx, in)));
+ return;
+ case ('!' << 8)|'=':
+ if (inout->attr.type == attr_none || in->attr.type == attr_none) {
+ set_int(inout, 1);
+ } else if (ATTR_IS_STRING(inout->attr.type) && ATTR_IS_STRING(in->attr.type)) {
+ char *s1=get_string(ctx, inout),*s2=get_string(ctx, in);
+ set_int(inout, (!!strcmp(s1,s2)));
+ g_free(s1);
+ g_free(s2);
+ } else if (ATTR_IS_OBJECT(inout->attr.type) && ATTR_IS_OBJECT(in->attr.type)) {
+ set_int(inout, inout->attr.u.data != in->attr.u.data);
+ } else
+ set_int(inout, (get_int(ctx, inout) != get_int(ctx, in)));
+ return;
+ case ('<' << 8):
+ set_int(inout, (get_int(ctx, inout) < get_int(ctx, in)));
+ return;
+ case ('<' << 8)|'=':
+ set_int(inout, (get_int(ctx, inout) <= get_int(ctx, in)));
+ return;
+ case ('>' << 8):
+ set_int(inout, (get_int(ctx, inout) > get_int(ctx, in)));
+ return;
+ case ('>' << 8)|'=':
+ set_int(inout, (get_int(ctx, inout) >= get_int(ctx, in)));
+ return;
+ case ('*' << 8):
+ if (is_double(inout) || is_double(in))
+ set_double(inout, get_double(ctx, inout) * get_double(ctx, in));
+ else
+ set_int(inout, get_int(ctx, inout) * get_int(ctx, in));
+ return;
+ case ('/' << 8):
+ if (is_double(inout) || is_double(in))
+ set_double(inout, get_double(ctx, inout) * get_double(ctx, in));
+ else
+ set_int(inout, get_int(ctx, inout) * get_int(ctx, in));
+ return;
+ case ('%' << 8):
+ set_int(inout, get_int(ctx, inout) % get_int(ctx, in));
+ return;
+ case ('+' << 8):
+ if (is_double(inout) || is_double(in))
+ set_double(inout, get_double(ctx, inout) + get_double(ctx, in));
+ else if (ATTR_IS_STRING(inout->attr.type) && ATTR_IS_STRING(in->attr.type)) {
+ char *str=g_strdup_printf("%s%s",inout->attr.u.str,in->attr.u.str);
+ result_free(inout);
+ inout->attr.type=attr_type_string_begin;
+ inout->attr.u.str=str;
+ inout->allocated=1;
+ } else
+ set_int(inout, get_int(ctx, inout) + get_int(ctx, in));
+ return;
+ case ('-' << 8):
+ if (is_double(inout) || is_double(in))
+ set_int(inout, get_int(ctx, inout) - get_int(ctx, in));
+ else
+ set_double(inout, get_double(ctx, inout) - get_double(ctx, in));
+ return;
+ case ('&' << 8):
+ set_int(inout, get_int(ctx, inout) & get_int(ctx, in));
+ return;
+ case ('^' << 8):
+ set_int(inout, get_int(ctx, inout) ^ get_int(ctx, in));
+ return;
+ case ('|' << 8):
+ set_int(inout, get_int(ctx, inout) | get_int(ctx, in));
+ return;
+ case (('&' << 8) | '&'):
+ set_int(inout, get_int(ctx, inout) && get_int(ctx, in));
+ return;
+ case (('|' << 8) | '|'):
+ set_int(inout, get_int(ctx, inout) || get_int(ctx, in));
+ return;
+ default:
+ break;
+ }
+ default:
+ break;
+ }
+ dbg(lvl_error,"Unknown op %d %s",op_type,op);
+ ctx->error=internal;
+}
+
+static void result_set(struct context *ctx, enum set_type set_type, const char *op, int len, struct result *out) {
+ if (ctx->skip)
+ return;
+ switch (set_type) {
+ case set_type_symbol:
+ out->attr.type=attr_none;
+ out->var=op;
+ out->varlen=len;
+ return;
+ case set_type_integer:
+ out->attr.type=attr_type_int_begin;
+ out->attr.u.num=atoi(ctx->expr);
+ return;
+ case set_type_float:
+ out->val = strtod(ctx->expr, NULL);
+ out->attr.type=attr_type_double_begin;
+ out->attr.u.numd=&out->val;
+ return;
+ case set_type_string:
+ if (len >= 2) {
+ out->attr.type=attr_type_string_begin;
+ out->attr.u.str=g_malloc(len-1);
+ strncpy(out->attr.u.str, op+1, len-2);
+ out->attr.u.str[len-2]='\0';
+ out->allocated=1;
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ dbg(lvl_error,"unknown set type %d %s",set_type,op);
+ ctx->error=internal;
}
/**
@@ -693,96 +653,96 @@ result_set(struct context *ctx, enum set_type set_type, const char *op, int len,
* @param ctx The context to evaluate
* @param res Points to a {@code struct res} in which the result will be stored
*/
-static void
-eval_value(struct context *ctx, struct result *res) {
- const char *op;
- int dots=0;
-
- result_free(res);
-
- res->varlen=0;
- res->var=NULL;
- res->attrnlen=0;
- res->attrn=NULL;
-
- while (g_ascii_isspace(*(ctx->expr))) {
- ctx->expr++;
- }
- op = ctx->expr;
-
- if ((op[0] >= 'a' && op[0] <= 'z') || (op[0] >= 'A' && op[0] <= 'Z') || op[0] == '_') {
- const char *s=op;
- for (;;) {
- while ((op[0] >= 'a' && op[0] <= 'z') || (op[0] >= 'A' && op[0] <= 'Z') || (op[0] >= '0' && op[0] <= '9') || op[0] == '_') {
- op++;
- }
- if (op-s == 3 && !strncmp(s,"new",3) && op[0] == ' ') {
- op++;
- } else
- break;
- }
- result_set(ctx, set_type_symbol, ctx->expr, op-ctx->expr, res);
- ctx->expr=op;
- return;
- }
- if ((op[0] >= '0' && op[0] <= '9') ||
- (op[0] == '.' && op[1] >= '0' && op[1] <= '9') ||
- (op[0] == '-' && op[1] >= '0' && op[1] <= '9') ||
- (op[0] == '-' && op[1] == '.' && op[2] >= '0' && op[2] <= '9')) {
- while ((op[0] >= '0' && op[0] <= '9') || op[0] == '.' || (res->varlen == 0 && op[0] == '-')) {
- if (op[0] == '.')
- dots++;
- if (dots > 1) {
- ctx->error=illegal_number_format;
- return;
- }
- op++;
- }
- result_set(ctx, dots?set_type_float:set_type_integer, ctx->expr, op-ctx->expr, res);
- ctx->expr=op;
- return;
- }
- if (op[0] == '"') {
- int escaped=0;
- do {
- if (op[0] == '\\') {
- escaped=1;
- if (op[1] == '"')
- op++;
- }
- op++;
- } while (op[0] && op[0] != '"');
- if(!*op) {
- ctx->error=missing_double_quote;
- return;
- }
- op++;
- if (escaped) {
- char *tmpstr=g_malloc(op-ctx->expr+1),*s=tmpstr;
- op=ctx->expr;
- do {
- if (op[0] == '\\')
- op++;
- *s++=*op++;
- } while (op[0] != '"');
- *s++=*op++;
- result_set(ctx, set_type_string, tmpstr, s-tmpstr, res);
- g_free(tmpstr);
- } else
- result_set(ctx, set_type_string, ctx->expr, op-ctx->expr, res);
- ctx->expr=op;
- return;
- }
- if (!*op)
- ctx->error=eof_reached;
- else {
- /*
- * If we get here, ctx->expr does not begin with a variable or a literal value. This is not an
- * error if this function is being called to test if an expression begins with a value.
- */
- dbg(lvl_debug, "character 0x%x is illegal in a value\n",*op);
- ctx->error=illegal_character;
- }
+static void eval_value(struct context *ctx, struct result *res) {
+ const char *op;
+ int dots=0;
+
+ result_free(res);
+
+ res->varlen=0;
+ res->var=NULL;
+ res->attrnlen=0;
+ res->attrn=NULL;
+
+ while (g_ascii_isspace(*(ctx->expr))) {
+ ctx->expr++;
+ }
+ op = ctx->expr;
+
+ if ((op[0] >= 'a' && op[0] <= 'z') || (op[0] >= 'A' && op[0] <= 'Z') || op[0] == '_') {
+ const char *s=op;
+ for (;;) {
+ while ((op[0] >= 'a' && op[0] <= 'z') || (op[0] >= 'A' && op[0] <= 'Z') || (op[0] >= '0' && op[0] <= '9')
+ || op[0] == '_') {
+ op++;
+ }
+ if (op-s == 3 && !strncmp(s,"new",3) && op[0] == ' ') {
+ op++;
+ } else
+ break;
+ }
+ result_set(ctx, set_type_symbol, ctx->expr, op-ctx->expr, res);
+ ctx->expr=op;
+ return;
+ }
+ if ((op[0] >= '0' && op[0] <= '9') ||
+ (op[0] == '.' && op[1] >= '0' && op[1] <= '9') ||
+ (op[0] == '-' && op[1] >= '0' && op[1] <= '9') ||
+ (op[0] == '-' && op[1] == '.' && op[2] >= '0' && op[2] <= '9')) {
+ while ((op[0] >= '0' && op[0] <= '9') || op[0] == '.' || (res->varlen == 0 && op[0] == '-')) {
+ if (op[0] == '.')
+ dots++;
+ if (dots > 1) {
+ ctx->error=illegal_number_format;
+ return;
+ }
+ op++;
+ }
+ result_set(ctx, dots?set_type_float:set_type_integer, ctx->expr, op-ctx->expr, res);
+ ctx->expr=op;
+ return;
+ }
+ if (op[0] == '"') {
+ int escaped=0;
+ do {
+ if (op[0] == '\\') {
+ escaped=1;
+ if (op[1] == '"')
+ op++;
+ }
+ op++;
+ } while (op[0] && op[0] != '"');
+ if(!*op) {
+ ctx->error=missing_double_quote;
+ return;
+ }
+ op++;
+ if (escaped) {
+ char *tmpstr=g_malloc(op-ctx->expr+1),*s=tmpstr;
+ op=ctx->expr;
+ do {
+ if (op[0] == '\\')
+ op++;
+ *s++=*op++;
+ } while (op[0] != '"');
+ *s++=*op++;
+ result_set(ctx, set_type_string, tmpstr, s-tmpstr, res);
+ g_free(tmpstr);
+ } else
+ result_set(ctx, set_type_string, ctx->expr, op-ctx->expr, res);
+ ctx->expr=op;
+ return;
+ }
+ if (!*op)
+ ctx->error=eof_reached;
+ else {
+ /*
+ * If we get here, ctx->expr does not begin with a variable or a literal value. This is not an
+ * error if this function is being called to test if an expression begins with a value.
+ */
+ dbg(lvl_debug, "character 0x%x is illegal in a value",*op);
+ ctx->error=illegal_character;
+ }
}
/**
@@ -807,826 +767,765 @@ eval_value(struct context *ctx, struct result *res) {
* has been retrieved (e.g. {@code vehicle} from {@code vehicle.position_speed}), the return value is 2.
* If no object references were found, the return value is 0.
*/
-static int
-get_next_object(struct context *ctx, struct result *res) {
-
- while (*ctx->expr) {
- res->varlen = 0;
- ctx->error = 0;
-
- eval_value(ctx,res);
-
- if ((res->attr.type == attr_none) && (res->varlen > 0)) {
- if (ctx->expr[0] != '.') {
- return 1; // 1 means "this is the final object name"
- } else {
- return 2; // 2 means "there are more object names following" (e.g. we just hit 'vehicle' in 'vehicle.position_speed'
- }
- }
-
- if (ctx->error) {
- // Probably hit an operator
- ctx->expr++;
- }
- }
-
- return 0;
-}
-
-static void
-eval_brace(struct context *ctx, struct result *res)
-{
- if (get_op(ctx,0,"(",NULL)) {
- eval_comma(ctx, res);
- if (ctx->error) return;
- if (!get_op(ctx,0,")",NULL))
- ctx->error=missing_closing_parenthesis;
- return;
- }
- eval_value(ctx, res);
-}
-
-static void
-command_call_function(struct context *ctx, struct result *res)
-{
- struct attr cbl,**list=NULL;
- char *function=g_alloca(sizeof(char)*(res->attrnlen+1));
- if (res->attrn)
- strncpy(function, res->attrn, res->attrnlen);
- function[res->attrnlen]='\0';
- dbg(lvl_debug,"function=%s\n", function);
- if (ctx->expr[0] != ')') {
- list=eval_list(ctx);
- if (ctx->error) {
- attr_list_free(list);
- return;
- }
- }
- if (!get_op(ctx,0,")",NULL)) {
- attr_list_free(list);
- ctx->error=missing_closing_parenthesis;
- return;
- }
- if (!ctx->skip) {
- if (!strcmp(function,"_") && list && list[0] && list[0]->type >= attr_type_string_begin && list[0]->type <= attr_type_string_end) {
- result_free(res);
- res->attr.type=list[0]->type;
- res->attr.u.str=g_strdup(navit_nls_gettext(list[0]->u.str));
- res->allocated=1;
-
- } else if (!strncmp(function,"new ",4)) {
- enum attr_type attr_type=attr_from_name(function+4);
- result_free(res);
- if (ATTR_IS_INT(attr_type)) {
- if (list && list[0] && ATTR_IS_INT(list[0]->type)) {
- res->attr.type=attr_type;
- res->attr.u.num=list[0]->u.num;
- res->allocated=0;
- } else {
- dbg(lvl_error,"don't know how to create int of args\n");
- }
- } else if (ATTR_IS_STRING(attr_type)) {
- if (list && list[0] && ATTR_IS_STRING(list[0]->type)) {
- res->attr.type=attr_type;
- res->attr.u.str=g_strdup(list[0]->u.str);
- res->allocated=1;
- } else {
- dbg(lvl_error,"don't know how to create string of args\n");
- }
- } else if (ATTR_IS_OBJECT(attr_type)) {
- struct object_func *func=object_func_lookup(attr_type);
- if (func && func->create) {
- res->attr.type=attr_type;
- res->attr.u.data=func->create(list[0], list+1);
- /* Setting allocated to 1 here will make object to be destroyed when last reference is destroyed.
- So created persistent objects should be stored with set_attr_var command. */
- res->allocated=1;
- }
- } else {
- dbg(lvl_error,"don't know how to create %s (%s)\n",attr_to_name(attr_type),function+4);
- }
- } else if (!strcmp(function,"add_attr")) {
- command_object_add_attr(ctx, &res->attr, list[0]);
- } else if (!strcmp(function,"remove_attr")) {
- command_object_remove_attr(ctx, &res->attr, list[0]);
- } else {
- if (command_object_get_attr(ctx, &res->attr, attr_callback_list, &cbl)) {
- int valid =0;
- struct attr **out=NULL;
- dbg(lvl_debug,"function call %s from %s\n",function, attr_to_name(res->attr.type));
- callback_list_call_attr_4(cbl.u.callback_list, attr_command, function, list, &out, &valid);
- if (valid!=1){
- dbg(lvl_error, "invalid command ignored: \"%s\"; see http://wiki.navit-project.org/index.php/"
- "OSD#Navit_commands for valid commands.\n", function);
- }
- if (out && out[0]) {
- result_free(res);
- attr_dup_content(out[0], &res->attr);
- res->allocated=1;
- attr_list_free(out);
- } else
- result_free(res);
- } else
- result_free(res);
- }
- }
- attr_list_free(list);
- res->var=NULL;
- res->varlen=0;
- res->attrn=NULL;
- res->attrnlen=0;
-}
-
-static void
-eval_postfix(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
- const char *op;
-
- eval_brace(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (!(op=get_op(ctx,0,"[","(",".",NULL)))
- return;
- if (op[0] == '.') {
- eval_brace(ctx, &tmp);
- if (ctx->error) return;
- resolve(ctx, res);
- if (ctx->error) return;
- res->attrn=tmp.var;
- res->attrnlen=tmp.varlen;
- dump(res);
- } else if (op[0] == '[') {
- resolve_object(ctx, res);
- if (ctx->error) return;
- if (get_op(ctx,0,"@",NULL)) {
- if (!ctx->skip) {
- struct object_func *obj_func=object_func_lookup(res->attr.type);
- struct attr_iter *iter;
- struct attr attr;
- enum attr_type attr_type=command_attr_type(res);
- void *obj=res->attr.u.data;
- if (!obj) {
- dbg(lvl_error,"no object\n");
- return;
- }
- if (!obj_func) {
- dbg(lvl_error,"no object func\n");
- return;
- }
- if (!obj_func->iter_new || !obj_func->iter_destroy) {
- dbg(lvl_error,"no iter func\n");
- return;
- }
- iter = obj_func->iter_new(NULL);
- result_free(res);
- res->varlen=0;
- res->attrn=NULL;
- while (obj_func->get_attr(obj, attr_type, &attr, iter)) {
- if (command_evaluate_to_boolean(&attr, ctx->expr, &ctx->error)) {
- result_free(res);
- res->attr=attr;
- }
- }
- obj_func->iter_destroy(iter);
- }
- if (ctx->error) return;
- ctx->expr+=command_evaluate_to_length(ctx->expr, &ctx->error);
- }
- if (!get_op(ctx,0,"]",NULL)) {
- ctx->error=missing_closing_bracket;
- return;
- }
- } else if (op[0] == '(') {
- dbg(lvl_debug,"function call\n");
- resolve_object(ctx, res);
- command_call_function(ctx, res);
- }
- }
-}
-
-static void
-eval_unary(struct context *ctx, struct result *res)
-{
- const char *op;
- op=get_op(ctx,0,"~","!",NULL);
- if (op) {
- eval_unary(ctx, res);
- if (ctx->error) return;
- result_op(ctx, op_type_prefix, op, res, NULL);
- } else
- eval_postfix(ctx, res);
-}
-
-static void
-eval_multiplicative(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
- const char *op;
-
- eval_unary(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (!(op=get_op(ctx,0,"*","/","%",NULL))) return;
- eval_unary(ctx, &tmp);
- if (!ctx->error)
- result_op(ctx, op_type_binary, op, res, &tmp);
- result_free(&tmp);
- if (ctx->error) return;
- }
-}
-
-static void
-eval_additive(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
- const char *op;
-
- eval_multiplicative(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (!(op=get_op(ctx,0,"-","+",NULL))) return;
- eval_multiplicative(ctx, &tmp);
- if (!ctx->error)
- result_op(ctx, op_type_binary, op, res, &tmp);
- result_free(&tmp);
- if (ctx->error) return;
- }
-}
-
-static void
-eval_equality(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
- const char *op;
-
- eval_additive(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (!(op=get_op(ctx,0,"==","!=","<=",">=","<",">",NULL))) return;
- eval_additive(ctx, &tmp);
- if (!ctx->error)
- result_op(ctx, op_type_binary, op, res, &tmp);
- result_free(&tmp);
- if (ctx->error) return;
- }
-}
-
-
-static void
-eval_bitwise_and(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
-
- eval_equality(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (get_op(ctx,1,"&&",NULL)) return;
- if (!get_op(ctx,0,"&",NULL)) return;
- eval_equality(ctx, &tmp);
- if (!ctx->error)
- result_op(ctx, op_type_binary, "&", res, &tmp);
- result_free(&tmp);
- if (ctx->error) return;
- }
-}
-
-static void
-eval_bitwise_xor(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
-
- eval_bitwise_and(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (!get_op(ctx,0,"^",NULL)) return;
- eval_bitwise_and(ctx, &tmp);
- if (!ctx->error)
- result_op(ctx, op_type_binary, "^", res, &tmp);
- result_free(&tmp);
- if (ctx->error) return;
- }
-}
-
-static void
-eval_bitwise_or(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
-
- eval_bitwise_xor(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (get_op(ctx,1,"||",NULL)) return;
- if (!get_op(ctx,0,"|",NULL)) return;
- eval_bitwise_xor(ctx, &tmp);
- if (!ctx->error)
- result_op(ctx, op_type_binary, "|", res, &tmp);
- result_free(&tmp);
- if (ctx->error) return;
- }
-}
-
-static void
-eval_logical_and(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
-
- eval_bitwise_or(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (!get_op(ctx,0,"&&",NULL)) return;
- eval_bitwise_or(ctx, &tmp);
- if (!ctx->error)
- result_op(ctx, op_type_binary, "&&", res, &tmp);
- result_free(&tmp);
- if (ctx->error) return;
- }
-}
-
-static void
-eval_logical_or(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
-
- eval_logical_and(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (!get_op(ctx,0,"||",NULL)) return;
- eval_logical_and(ctx, &tmp);
- if (!ctx->error)
- result_op(ctx, op_type_binary, "||", res, &tmp);
- result_free(&tmp);
- if (ctx->error) return;
- }
-}
-
-static void
-eval_conditional(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
- int cond=0;
- int skip;
-
- eval_logical_or(ctx, res);
- if (ctx->error) return;
- if (!get_op(ctx,0,"?",NULL)) return;
- skip=ctx->skip;
- cond=get_bool(ctx, res);
- result_free(res);
- if (ctx->error) return;
- ctx->skip=!cond || skip;
- eval_logical_or(ctx, &tmp);
- ctx->skip=skip;
- if (ctx->error) {
- result_free(&tmp);
- return;
- }
-
- *res=tmp;
- memset(&tmp,0,sizeof(tmp));
-
- if (!get_op(ctx,0,":",NULL)) {
- dbg(lvl_debug,"ctxerr\n");
- ctx->error=missing_colon;
- return;
- }
- ctx->skip=cond || skip;
- eval_logical_or(ctx, &tmp);
- ctx->skip=skip;
- if (ctx->error) {
- result_free(&tmp);
- return;
- }
- if (!cond) {
- result_free(res);
- *res=tmp;
- } else
- result_free(&tmp);
+static int get_next_object(struct context *ctx, struct result *res) {
+
+ while (*ctx->expr) {
+ res->varlen = 0;
+ ctx->error = 0;
+
+ eval_value(ctx,res);
+
+ if ((res->attr.type == attr_none) && (res->varlen > 0)) {
+ if (ctx->expr[0] != '.') {
+ return 1; // 1 means "this is the final object name"
+ } else {
+ return 2; // 2 means "there are more object names following" (e.g. we just hit 'vehicle' in 'vehicle.position_speed'
+ }
+ }
+
+ if (ctx->error) {
+ // Probably hit an operator
+ ctx->expr++;
+ }
+ }
+
+ return 0;
+}
+
+static void eval_brace(struct context *ctx, struct result *res) {
+ if (get_op(ctx,0,"(",NULL)) {
+ eval_comma(ctx, res);
+ if (ctx->error) return;
+ if (!get_op(ctx,0,")",NULL))
+ ctx->error=missing_closing_parenthesis;
+ return;
+ }
+ eval_value(ctx, res);
+}
+
+static void command_call_function(struct context *ctx, struct result *res) {
+ struct attr cbl,**list=NULL;
+ char *function=g_alloca(sizeof(char)*(res->attrnlen+1));
+ if (res->attrn)
+ strncpy(function, res->attrn, res->attrnlen);
+ function[res->attrnlen]='\0';
+ dbg(lvl_debug,"function=%s", function);
+ if (ctx->expr[0] != ')') {
+ list=eval_list(ctx);
+ if (ctx->error) {
+ attr_list_free(list);
+ return;
+ }
+ }
+ if (!get_op(ctx,0,")",NULL)) {
+ attr_list_free(list);
+ ctx->error=missing_closing_parenthesis;
+ return;
+ }
+ if (!ctx->skip) {
+ if (!strcmp(function,"_") && list && list[0] && list[0]->type >= attr_type_string_begin
+ && list[0]->type <= attr_type_string_end) {
+ result_free(res);
+ res->attr.type=list[0]->type;
+ res->attr.u.str=g_strdup(navit_nls_gettext(list[0]->u.str));
+ res->allocated=1;
+
+ } else if (!strncmp(function,"new ",4)) {
+ enum attr_type attr_type=attr_from_name(function+4);
+ result_free(res);
+ if (ATTR_IS_INT(attr_type)) {
+ if (list && list[0] && ATTR_IS_INT(list[0]->type)) {
+ res->attr.type=attr_type;
+ res->attr.u.num=list[0]->u.num;
+ res->allocated=0;
+ } else {
+ dbg(lvl_error,"don't know how to create int of args");
+ }
+ } else if (ATTR_IS_STRING(attr_type)) {
+ if (list && list[0] && ATTR_IS_STRING(list[0]->type)) {
+ res->attr.type=attr_type;
+ res->attr.u.str=g_strdup(list[0]->u.str);
+ res->allocated=1;
+ } else {
+ dbg(lvl_error,"don't know how to create string of args");
+ }
+ } else if (ATTR_IS_OBJECT(attr_type)) {
+ struct object_func *func=object_func_lookup(attr_type);
+ if (func && func->create) {
+ res->attr.type=attr_type;
+ res->attr.u.data=func->create(list[0], list+1);
+ /* Setting allocated to 1 here will make object to be destroyed when last reference is destroyed.
+ So created persistent objects should be stored with set_attr_var command. */
+ res->allocated=1;
+ }
+ } else {
+ dbg(lvl_error,"don't know how to create %s (%s)",attr_to_name(attr_type),function+4);
+ }
+ } else if (!strcmp(function,"add_attr")) {
+ command_object_add_attr(ctx, &res->attr, list[0]);
+ } else if (!strcmp(function,"remove_attr")) {
+ command_object_remove_attr(ctx, &res->attr, list[0]);
+ } else {
+ if (command_object_get_attr(ctx, &res->attr, attr_callback_list, &cbl)) {
+ int valid =0;
+ struct attr **out=NULL;
+ dbg(lvl_debug,"function call %s from %s",function, attr_to_name(res->attr.type));
+ callback_list_call_attr_4(cbl.u.callback_list, attr_command, function, list, &out, &valid);
+ if (valid!=1) {
+ dbg(lvl_error, "invalid command ignored: \"%s\"; see http://wiki.navit-project.org/index.php/"
+ "OSD#Navit_commands for valid commands.", function);
+ }
+ if (out && out[0]) {
+ result_free(res);
+ attr_dup_content(out[0], &res->attr);
+ res->allocated=1;
+ attr_list_free(out);
+ } else
+ result_free(res);
+ } else
+ result_free(res);
+ }
+ }
+ attr_list_free(list);
+ res->var=NULL;
+ res->varlen=0;
+ res->attrn=NULL;
+ res->attrnlen=0;
+}
+
+static void eval_postfix(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+ const char *op;
+
+ eval_brace(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (!(op=get_op(ctx,0,"[","(",".",NULL)))
+ return;
+ if (op[0] == '.') {
+ eval_brace(ctx, &tmp);
+ if (ctx->error) return;
+ resolve(ctx, res);
+ if (ctx->error) return;
+ res->attrn=tmp.var;
+ res->attrnlen=tmp.varlen;
+ dump(res);
+ } else if (op[0] == '[') {
+ resolve_object(ctx, res);
+ if (ctx->error) return;
+ if (get_op(ctx,0,"@",NULL)) {
+ if (!ctx->skip) {
+ struct object_func *obj_func=object_func_lookup(res->attr.type);
+ struct attr_iter *iter;
+ struct attr attr;
+ enum attr_type attr_type=command_attr_type(res);
+ void *obj=res->attr.u.data;
+ if (!obj) {
+ dbg(lvl_error,"no object");
+ return;
+ }
+ if (!obj_func) {
+ dbg(lvl_error,"no object func");
+ return;
+ }
+ if (!obj_func->iter_new || !obj_func->iter_destroy) {
+ dbg(lvl_error,"no iter func");
+ return;
+ }
+ iter = obj_func->iter_new(NULL);
+ result_free(res);
+ res->varlen=0;
+ res->attrn=NULL;
+ while (obj_func->get_attr(obj, attr_type, &attr, iter)) {
+ if (command_evaluate_to_boolean(&attr, ctx->expr, &ctx->error)) {
+ result_free(res);
+ res->attr=attr;
+ }
+ }
+ obj_func->iter_destroy(iter);
+ }
+ if (ctx->error) return;
+ ctx->expr+=command_evaluate_to_length(ctx->expr, &ctx->error);
+ }
+ if (!get_op(ctx,0,"]",NULL)) {
+ ctx->error=missing_closing_bracket;
+ return;
+ }
+ } else if (op[0] == '(') {
+ dbg(lvl_debug,"function call");
+ resolve_object(ctx, res);
+ command_call_function(ctx, res);
+ }
+ }
+}
+
+static void eval_unary(struct context *ctx, struct result *res) {
+ const char *op;
+ op=get_op(ctx,0,"~","!",NULL);
+ if (op) {
+ eval_unary(ctx, res);
+ if (ctx->error) return;
+ result_op(ctx, op_type_prefix, op, res, NULL);
+ } else
+ eval_postfix(ctx, res);
+}
+
+static void eval_multiplicative(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+ const char *op;
+
+ eval_unary(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (!(op=get_op(ctx,0,"*","/","%",NULL))) return;
+ eval_unary(ctx, &tmp);
+ if (!ctx->error)
+ result_op(ctx, op_type_binary, op, res, &tmp);
+ result_free(&tmp);
+ if (ctx->error) return;
+ }
+}
+
+static void eval_additive(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+ const char *op;
+
+ eval_multiplicative(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (!(op=get_op(ctx,0,"-","+",NULL))) return;
+ eval_multiplicative(ctx, &tmp);
+ if (!ctx->error)
+ result_op(ctx, op_type_binary, op, res, &tmp);
+ result_free(&tmp);
+ if (ctx->error) return;
+ }
+}
+
+static void eval_equality(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+ const char *op;
+
+ eval_additive(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (!(op=get_op(ctx,0,"==","!=","<=",">=","<",">",NULL))) return;
+ eval_additive(ctx, &tmp);
+ if (!ctx->error)
+ result_op(ctx, op_type_binary, op, res, &tmp);
+ result_free(&tmp);
+ if (ctx->error) return;
+ }
+}
+
+
+static void eval_bitwise_and(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+
+ eval_equality(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (get_op(ctx,1,"&&",NULL)) return;
+ if (!get_op(ctx,0,"&",NULL)) return;
+ eval_equality(ctx, &tmp);
+ if (!ctx->error)
+ result_op(ctx, op_type_binary, "&", res, &tmp);
+ result_free(&tmp);
+ if (ctx->error) return;
+ }
+}
+
+static void eval_bitwise_xor(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+
+ eval_bitwise_and(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (!get_op(ctx,0,"^",NULL)) return;
+ eval_bitwise_and(ctx, &tmp);
+ if (!ctx->error)
+ result_op(ctx, op_type_binary, "^", res, &tmp);
+ result_free(&tmp);
+ if (ctx->error) return;
+ }
+}
+
+static void eval_bitwise_or(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+
+ eval_bitwise_xor(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (get_op(ctx,1,"||",NULL)) return;
+ if (!get_op(ctx,0,"|",NULL)) return;
+ eval_bitwise_xor(ctx, &tmp);
+ if (!ctx->error)
+ result_op(ctx, op_type_binary, "|", res, &tmp);
+ result_free(&tmp);
+ if (ctx->error) return;
+ }
+}
+
+static void eval_logical_and(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+
+ eval_bitwise_or(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (!get_op(ctx,0,"&&",NULL)) return;
+ eval_bitwise_or(ctx, &tmp);
+ if (!ctx->error)
+ result_op(ctx, op_type_binary, "&&", res, &tmp);
+ result_free(&tmp);
+ if (ctx->error) return;
+ }
+}
+
+static void eval_logical_or(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+
+ eval_logical_and(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (!get_op(ctx,0,"||",NULL)) return;
+ eval_logical_and(ctx, &tmp);
+ if (!ctx->error)
+ result_op(ctx, op_type_binary, "||", res, &tmp);
+ result_free(&tmp);
+ if (ctx->error) return;
+ }
+}
+
+static void eval_conditional(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+ int cond=0;
+ int skip;
+
+ eval_logical_or(ctx, res);
+ if (ctx->error) return;
+ if (!get_op(ctx,0,"?",NULL)) return;
+ skip=ctx->skip;
+ cond=get_bool(ctx, res);
+ result_free(res);
+ if (ctx->error) return;
+ ctx->skip=!cond || skip;
+ eval_logical_or(ctx, &tmp);
+ ctx->skip=skip;
+ if (ctx->error) {
+ result_free(&tmp);
+ return;
+ }
+
+ *res=tmp;
+ memset(&tmp,0,sizeof(tmp));
+
+ if (!get_op(ctx,0,":",NULL)) {
+ dbg(lvl_debug,"ctxerr");
+ ctx->error=missing_colon;
+ return;
+ }
+ ctx->skip=cond || skip;
+ eval_logical_or(ctx, &tmp);
+ ctx->skip=skip;
+ if (ctx->error) {
+ result_free(&tmp);
+ return;
+ }
+ if (!cond) {
+ result_free(res);
+ *res=tmp;
+ } else
+ result_free(&tmp);
}
/* = *= /= %= += -= >>= <<= &= ^= |= */
-static void
-eval_assignment(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
- eval_conditional(ctx, res);
- if (ctx->error) return;
- if (!get_op(ctx,0,"=",NULL)) return;
- eval_conditional(ctx, &tmp);
- if (ctx->error) {
- result_free(&tmp);
- return;
- }
- resolve(ctx, &tmp);
- if (ctx->error) {
- result_free(&tmp);
- return;
- }
- resolve_object(ctx, res);
- command_set_attr(ctx, res, &tmp);
+static void eval_assignment(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+ eval_conditional(ctx, res);
+ if (ctx->error) return;
+ if (!get_op(ctx,0,"=",NULL)) return;
+ eval_conditional(ctx, &tmp);
+ if (ctx->error) {
+ result_free(&tmp);
+ return;
+ }
+ resolve(ctx, &tmp);
+ if (ctx->error) {
+ result_free(&tmp);
+ return;
+ }
+ resolve_object(ctx, res);
+ command_set_attr(ctx, res, &tmp);
}
/* , */
-static void
-eval_comma(struct context *ctx, struct result *res)
-{
- struct result tmp={{0,},};
-
- eval_assignment(ctx, res);
- if (ctx->error) return;
- for (;;) {
- if (!get_op(ctx,0,",",NULL)) return;
- eval_assignment(ctx, &tmp);
- if (ctx->error) return;
- result_free(res);
- *res=tmp;
- }
-}
-
-static struct attr **
-eval_list(struct context *ctx)
-{
- struct result tmp={{0,},};
-
- struct attr **ret=NULL;
- for (;;) {
- eval_assignment(ctx, &tmp);
- if (ctx->error) {
- result_free(&tmp);
- attr_list_free(ret);
- return NULL;
- }
- resolve(ctx, &tmp);
- ret=attr_generic_add_attr(ret, &tmp.attr);
- result_free(&tmp);
- if (!get_op(ctx,0,",",NULL)) return ret;
- }
+static void eval_comma(struct context *ctx, struct result *res) {
+ struct result tmp= {{0,},};
+
+ eval_assignment(ctx, res);
+ if (ctx->error) return;
+ for (;;) {
+ if (!get_op(ctx,0,",",NULL)) return;
+ eval_assignment(ctx, &tmp);
+ if (ctx->error) return;
+ result_free(res);
+ *res=tmp;
+ }
+}
+
+static struct attr ** eval_list(struct context *ctx) {
+ struct result tmp= {{0,},};
+
+ struct attr **ret=NULL;
+ for (;;) {
+ eval_assignment(ctx, &tmp);
+ if (ctx->error) {
+ result_free(&tmp);
+ attr_list_free(ret);
+ return NULL;
+ }
+ resolve(ctx, &tmp);
+ ret=attr_generic_add_attr(ret, &tmp.attr);
+ result_free(&tmp);
+ if (!get_op(ctx,0,",",NULL)) return ret;
+ }
}
#if 0
-void command(struct attr *attr, char *expr)
-{
- struct result res;
- struct context ctx;
- memset(&res, 0, sizeof(res));
- memset(&ctx, 0, sizeof(ctx));
- ctx.attr=attr;
- ctx.error=0;
- ctx.expr=expr;
- printf("command='%s'\n", expr);
- eval_comma(&ctx,&res);
- printf("err=%d %s\n", ctx.error, ctx.expr);
- dump(&res);
- printf("***\n");
- resolve(&ctx, &res);
- dump(&res);
- printf("%s\n", get_string(&ctx, &res));
+void command(struct attr *attr, char *expr) {
+ struct result res;
+ struct context ctx;
+ memset(&res, 0, sizeof(res));
+ memset(&ctx, 0, sizeof(ctx));
+ ctx.attr=attr;
+ ctx.error=0;
+ ctx.expr=expr;
+ printf("command='%s'\n", expr);
+ eval_comma(&ctx,&res);
+ printf("err=%d %s\n", ctx.error, ctx.expr);
+ dump(&res);
+ printf("***\n");
+ resolve(&ctx, &res);
+ dump(&res);
+ printf("%s\n", get_string(&ctx, &res));
}
#endif
-static void
-command_evaluate_to(struct attr *attr, const char *expr, struct context *ctx, struct result *res)
-{
- result_free(res);
- memset(res, 0, sizeof(*res));
- memset(ctx, 0, sizeof(*ctx));
- ctx->attr=attr;
- ctx->expr=expr;
- eval_comma(ctx,res);
-}
-
-enum attr_type
-command_evaluate_to_attr(struct attr *attr, char *expr, int *error, struct attr *ret)
-{
- struct result res={{0,},};
- struct context ctx;
- command_evaluate_to(attr, expr, &ctx, &res);
- if (ctx.error)
- return attr_none;
- resolve_object(&ctx, &res);
- *ret=res.attr;
- dbg(lvl_debug,"type %s\n",attr_to_name(command_attr_type(&res)));
- return command_attr_type(&res);
-}
-
-void
-command_evaluate_to_void(struct attr *attr, char *expr, int *error)
-{
- struct result res={{0,},};
- struct context ctx;
- command_evaluate_to(attr, expr, &ctx, &res);
- if (!ctx.error)
- resolve(&ctx, &res);
- if (error)
- *error=ctx.error;
- result_free(&res);
-
-}
-
-char *
-command_evaluate_to_string(struct attr *attr, char *expr, int *error)
-{
- struct result res={{0,},};
- struct context ctx;
- char *ret=NULL;
-
- command_evaluate_to(attr, expr, &ctx, &res);
- if (!ctx.error)
- resolve(&ctx, &res);
- if (!ctx.error)
- ret=get_string(&ctx, &res);
- if (error)
- *error=ctx.error;
-
- result_free(&res);
-
- if (ctx.error)
- return NULL;
- else
- return ret;
-}
-
-int
-command_evaluate_to_int(struct attr *attr, char *expr, int *error)
-{
- struct result res={{0,},};
- struct context ctx;
- int ret=0;
-
- command_evaluate_to(attr, expr, &ctx, &res);
- if (!ctx.error)
- resolve(&ctx, &res);
- if (!ctx.error)
- ret=get_int(&ctx, &res);
- if (error)
- *error=ctx.error;
-
- result_free(&res);
-
- if (ctx.error)
- return 0;
- else
- return ret;
-}
-
-int
-command_evaluate_to_boolean(struct attr *attr, const char *expr, int *error)
-{
- struct result res={{0,},};
- struct context ctx;
- int ret=0;
-
- command_evaluate_to(attr, expr, &ctx, &res);
- if (!ctx.error)
- resolve(&ctx, &res);
- if (!ctx.error) {
- if (res.attr.type == attr_none)
- ret=0;
- else if ((res.attr.type >= attr_type_int_begin && res.attr.type <= attr_type_int_end) ||
- (res.attr.type >= attr_type_double_begin && res.attr.type <= attr_type_double_end))
- ret=get_int(&ctx, &res);
- else
- ret=res.attr.u.data != NULL;
- }
-
- result_free(&res);
-
- if (error)
- *error=ctx.error;
- if (ctx.error)
- return 0;
- else
- return ret;
-}
-
-int
-command_evaluate_to_length(const char *expr, int *error)
-{
- struct attr attr;
- struct result res={{0,},};
- struct context ctx;
-
- attr.type=attr_none;
- attr.u.data=NULL;
- command_evaluate_to(&attr, expr, &ctx, &res);
-
- result_free(&res);
-
- if (!ctx.error)
- return ctx.expr-expr;
- return 0;
-}
-
-static int
-command_evaluate_single(struct context *ctx)
-{
- struct result res={{0,},},tmp={{0,},};
- const char *op,*a,*f,*end;
- enum attr_type attr_type;
- void *obj;
- struct object_func *obj_func;
- struct attr_iter *iter;
- struct attr attr;
- int cond=0;
- int skip=ctx->skip;
- if (!(op=get_op(ctx,0,"foreach","if","{",NULL))) {
- eval_comma(ctx,&res);
- if (ctx->error)
- return 0;
- resolve(ctx, &res);
- result_free(&res);
- if (ctx->error)
- return 0;
- return get_op(ctx,0,";",NULL) != NULL;
- }
- switch (op[0]) {
- case 'f':
- if (!get_op(ctx,0,"(",NULL)) {
- ctx->error=missing_opening_parenthesis;
- return 0;
- }
- ctx->skip=1;
- a=ctx->expr;
- eval_conditional(ctx, &res);
- resolve_object(ctx, &res);
- ctx->skip=skip;
- if (!get_op(ctx,0,";",NULL)) {
- ctx->error=missing_semicolon;
- return 0;
- }
- eval_comma(ctx,&res);
- attr_type=command_attr_type(&res);
- obj=res.attr.u.data;
- obj_func=object_func_lookup(res.attr.type);
- if (!get_op(ctx,0,")",NULL)) {
- ctx->error=missing_closing_parenthesis;
- return 0;
- }
- f=ctx->expr;
- ctx->skip=1;
- if (!command_evaluate_single(ctx)) {
- ctx->skip=skip;
- return 0;
- }
- ctx->skip=skip;
- if (ctx->skip) {
- result_free(&res);
- return 1;
- }
- end=ctx->expr;
- if (!obj) {
- dbg(lvl_error,"no object\n");
- return 0;
- }
- if (!obj_func) {
- dbg(lvl_error,"no object func\n");
- return 0;
- }
- if (!obj_func->iter_new || !obj_func->iter_destroy) {
- dbg(lvl_error,"no iter func\n");
- return 0;
- }
- iter = obj_func->iter_new(NULL);
- while (obj_func->get_attr(obj, attr_type, &attr, iter)) {
- ctx->expr=a;
- eval_conditional(ctx, &res);
- resolve_object(ctx, &res);
- tmp.attr=attr;
- resolve(ctx, &tmp);
- if (ctx->error) {
- result_free(&tmp);
- return 0;
- }
- command_set_attr(ctx, &res, &tmp);
- result_free(&tmp);
- ctx->expr=f;
- if (!command_evaluate_single(ctx)) {
- obj_func->iter_destroy(iter);
- return 0;
- }
- }
- obj_func->iter_destroy(iter);
- ctx->expr=end;
- return 1;
- case 'i':
- if (!get_op(ctx,0,"(",NULL)) {
- ctx->error=missing_opening_parenthesis;
- return 0;
- }
- eval_comma(ctx,&res);
- if (!skip && !ctx->error)
- cond=get_bool(ctx, &res);
- result_free(&res);
- if (ctx->error)
- return 0;
- if (!get_op(ctx,0,")",NULL)) {
- ctx->error=missing_closing_parenthesis;
- return 0;
- }
- ctx->skip=!cond || skip;
- command_evaluate_single(ctx);
- ctx->skip=skip;
- if (ctx->error)
- return 0;
- if (get_op(ctx,0,"else",NULL)) {
- ctx->skip=cond || skip;
- command_evaluate_single(ctx);
- ctx->skip=skip;
- if (ctx->error)
- return 0;
- }
- return 1;
- case '{':
- while (!get_op(ctx,0,"}",NULL)) {
- if (!command_evaluate_single(ctx))
- return 0;
- }
- return 1;
- default:
- return 0;
- }
-}
-
-void
-command_evaluate(struct attr *attr, const char *expr)
-{
- /* Once the eval has started we can't rely anymore on the content of
- * expr which may be freed when the calling widget is destroyed by a
- * subsequent command call. Hence the g_strdup. */
-
- char *expr_dup;
- char *err = NULL; /* Error description */
- struct context ctx={0,};
- ctx.attr=attr;
- ctx.error=0;
- ctx.expr=expr_dup=g_strdup(expr);
- for (;;) {
- if (!command_evaluate_single(&ctx))
- break;
- }
- if (ctx.error && ctx.error != eof_reached) {
- char expr[32];
- strncpy(expr, ctx.expr, 32);
- expr[31]='\0';
- err = command_error_to_text(ctx.error);
- dbg(lvl_error, "error %s starting at %s\n", err, expr);
- g_free(err);
- }
- g_free(expr_dup);
+static void command_evaluate_to(struct attr *attr, const char *expr, struct context *ctx, struct result *res) {
+ result_free(res);
+ memset(res, 0, sizeof(*res));
+ memset(ctx, 0, sizeof(*ctx));
+ ctx->attr=attr;
+ ctx->expr=expr;
+ eval_comma(ctx,res);
+}
+
+enum attr_type command_evaluate_to_attr(struct attr *attr, char *expr, int *error, struct attr *ret) {
+ struct result res={{0,},};
+ struct context ctx;
+ command_evaluate_to(attr, expr, &ctx, &res);
+ if (ctx.error)
+ return attr_none;
+ resolve_object(&ctx, &res);
+ *ret=res.attr;
+ dbg(lvl_debug,"type %s",attr_to_name(command_attr_type(&res)));
+ return command_attr_type(&res);
+}
+
+void command_evaluate_to_void(struct attr *attr, char *expr, int *error) {
+ struct result res= {{0,},};
+ struct context ctx;
+ command_evaluate_to(attr, expr, &ctx, &res);
+ if (!ctx.error)
+ resolve(&ctx, &res);
+ if (error)
+ *error=ctx.error;
+ result_free(&res);
+
+}
+
+char *command_evaluate_to_string(struct attr *attr, char *expr, int *error) {
+ struct result res= {{0,},};
+ struct context ctx;
+ char *ret=NULL;
+
+ command_evaluate_to(attr, expr, &ctx, &res);
+ if (!ctx.error)
+ resolve(&ctx, &res);
+ if (!ctx.error)
+ ret=get_string(&ctx, &res);
+ if (error)
+ *error=ctx.error;
+
+ result_free(&res);
+
+ if (ctx.error)
+ return NULL;
+ else
+ return ret;
+}
+
+int command_evaluate_to_int(struct attr *attr, char *expr, int *error) {
+ struct result res= {{0,},};
+ struct context ctx;
+ int ret=0;
+
+ command_evaluate_to(attr, expr, &ctx, &res);
+ if (!ctx.error)
+ resolve(&ctx, &res);
+ if (!ctx.error)
+ ret=get_int(&ctx, &res);
+ if (error)
+ *error=ctx.error;
+
+ result_free(&res);
+
+ if (ctx.error)
+ return 0;
+ else
+ return ret;
+}
+
+int command_evaluate_to_boolean(struct attr *attr, const char *expr, int *error) {
+ struct result res= {{0,},};
+ struct context ctx;
+ int ret=0;
+
+ command_evaluate_to(attr, expr, &ctx, &res);
+ if (!ctx.error)
+ resolve(&ctx, &res);
+ if (!ctx.error) {
+ if (res.attr.type == attr_none)
+ ret=0;
+ else if ((res.attr.type >= attr_type_int_begin && res.attr.type <= attr_type_int_end) ||
+ (res.attr.type >= attr_type_double_begin && res.attr.type <= attr_type_double_end))
+ ret=get_int(&ctx, &res);
+ else
+ ret=res.attr.u.data != NULL;
+ }
+
+ result_free(&res);
+
+ if (error)
+ *error=ctx.error;
+ if (ctx.error)
+ return 0;
+ else
+ return ret;
+}
+
+int command_evaluate_to_length(const char *expr, int *error) {
+ struct attr attr;
+ struct result res= {{0,},};
+ struct context ctx;
+
+ attr.type=attr_none;
+ attr.u.data=NULL;
+ command_evaluate_to(&attr, expr, &ctx, &res);
+
+ result_free(&res);
+
+ if (!ctx.error)
+ return ctx.expr-expr;
+ return 0;
+}
+
+static int command_evaluate_single(struct context *ctx) {
+ struct result res= {{0,},},tmp= {{0,},};
+ const char *op,*a,*f,*end;
+ enum attr_type attr_type;
+ void *obj;
+ struct object_func *obj_func;
+ struct attr_iter *iter;
+ struct attr attr;
+ int cond=0;
+ int skip=ctx->skip;
+ if (!(op=get_op(ctx,0,"foreach","if","{",NULL))) {
+ eval_comma(ctx,&res);
+ if (ctx->error)
+ return 0;
+ resolve(ctx, &res);
+ result_free(&res);
+ if (ctx->error)
+ return 0;
+ return get_op(ctx,0,";",NULL) != NULL;
+ }
+ switch (op[0]) {
+ case 'f':
+ if (!get_op(ctx,0,"(",NULL)) {
+ ctx->error=missing_opening_parenthesis;
+ return 0;
+ }
+ ctx->skip=1;
+ a=ctx->expr;
+ eval_conditional(ctx, &res);
+ resolve_object(ctx, &res);
+ ctx->skip=skip;
+ if (!get_op(ctx,0,";",NULL)) {
+ ctx->error=missing_semicolon;
+ return 0;
+ }
+ eval_comma(ctx,&res);
+ attr_type=command_attr_type(&res);
+ obj=res.attr.u.data;
+ obj_func=object_func_lookup(res.attr.type);
+ if (!get_op(ctx,0,")",NULL)) {
+ ctx->error=missing_closing_parenthesis;
+ return 0;
+ }
+ f=ctx->expr;
+ ctx->skip=1;
+ if (!command_evaluate_single(ctx)) {
+ ctx->skip=skip;
+ return 0;
+ }
+ ctx->skip=skip;
+ if (ctx->skip) {
+ result_free(&res);
+ return 1;
+ }
+ end=ctx->expr;
+ if (!obj) {
+ dbg(lvl_error,"no object");
+ return 0;
+ }
+ if (!obj_func) {
+ dbg(lvl_error,"no object func");
+ return 0;
+ }
+ if (!obj_func->iter_new || !obj_func->iter_destroy) {
+ dbg(lvl_error,"no iter func");
+ return 0;
+ }
+ iter = obj_func->iter_new(NULL);
+ while (obj_func->get_attr(obj, attr_type, &attr, iter)) {
+ ctx->expr=a;
+ eval_conditional(ctx, &res);
+ resolve_object(ctx, &res);
+ tmp.attr=attr;
+ resolve(ctx, &tmp);
+ if (ctx->error) {
+ result_free(&tmp);
+ return 0;
+ }
+ command_set_attr(ctx, &res, &tmp);
+ result_free(&tmp);
+ ctx->expr=f;
+ if (!command_evaluate_single(ctx)) {
+ obj_func->iter_destroy(iter);
+ return 0;
+ }
+ }
+ obj_func->iter_destroy(iter);
+ ctx->expr=end;
+ return 1;
+ case 'i':
+ if (!get_op(ctx,0,"(",NULL)) {
+ ctx->error=missing_opening_parenthesis;
+ return 0;
+ }
+ eval_comma(ctx,&res);
+ if (!skip && !ctx->error)
+ cond=get_bool(ctx, &res);
+ result_free(&res);
+ if (ctx->error)
+ return 0;
+ if (!get_op(ctx,0,")",NULL)) {
+ ctx->error=missing_closing_parenthesis;
+ return 0;
+ }
+ ctx->skip=!cond || skip;
+ command_evaluate_single(ctx);
+ ctx->skip=skip;
+ if (ctx->error)
+ return 0;
+ if (get_op(ctx,0,"else",NULL)) {
+ ctx->skip=cond || skip;
+ command_evaluate_single(ctx);
+ ctx->skip=skip;
+ if (ctx->error)
+ return 0;
+ }
+ return 1;
+ case '{':
+ while (!get_op(ctx,0,"}",NULL)) {
+ if (!command_evaluate_single(ctx))
+ return 0;
+ }
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+void command_evaluate(struct attr *attr, const char *expr) {
+ /* Once the eval has started we can't rely anymore on the content of
+ * expr which may be freed when the calling widget is destroyed by a
+ * subsequent command call. Hence the g_strdup. */
+
+ char *expr_dup;
+ char *err = NULL; /* Error description */
+ struct context ctx= {0,};
+ ctx.attr=attr;
+ ctx.error=0;
+ ctx.expr=expr_dup=g_strdup(expr);
+ for (;;) {
+ if (!command_evaluate_single(&ctx))
+ break;
+ }
+ if (ctx.error && ctx.error != eof_reached) {
+ char expr[32];
+ strncpy(expr, ctx.expr, 32);
+ expr[31]='\0';
+ err = command_error_to_text(ctx.error);
+ dbg(lvl_error, "error %s starting at %s", err, expr);
+ g_free(err);
+ }
+ g_free(expr_dup);
}
#if 0
-void
-command_interpreter(struct attr *attr)
-{
- char buffer[4096];
- int size;
- for (;;) {
- size=read(0, buffer, 4095);
- buffer[size]='\0';
- if (size) {
- buffer[size-1]='\0';
- }
- command(attr, buffer);
- }
+void command_interpreter(struct attr *attr) {
+ char buffer[4096];
+ int size;
+ for (;;) {
+ size=read(0, buffer, 4095);
+ buffer[size]='\0';
+ if (size) {
+ buffer[size-1]='\0';
+ }
+ command(attr, buffer);
+ }
}
#endif
-static void
-command_table_call(struct command_table *table, int count, void *data, char *command, struct attr **in, struct attr ***out, int *valid)
-{
- int i;
- for (i = 0 ; i < count ; i++) {
- if (!strcmp(command,table->command)) {
- if (valid)
- *valid=1;
- table->func(data, command, in, out);
- }
- table++;
- }
-}
-
-void
-command_add_table_attr(struct command_table *table, int count, void *data, struct attr *attr)
-{
- attr->type=attr_callback;
- attr->u.callback=callback_new_attr_3(callback_cast(command_table_call),attr_command, table, count, data);
+static void command_table_call(struct command_table *table, int count, void *data, char *command, struct attr **in, struct attr ***out, int *valid) {
+ int i;
+ for (i = 0 ; i < count ; i++) {
+ if (!strcmp(command,table->command)) {
+ if (valid)
+ *valid=1;
+ table->func(data, command, in, out);
+ }
+ table++;
+ }
}
-void
-command_add_table(struct callback_list *cbl, struct command_table *table, int count, void *data)
-{
- struct attr attr;
- command_add_table_attr(table, count, data, &attr);
- callback_list_add(cbl, attr.u.callback);
+void command_add_table_attr(struct command_table *table, int count, void *data, struct attr *attr) {
+ attr->type=attr_callback;
+ attr->u.callback=callback_new_attr_3(callback_cast(command_table_call),attr_command, table, count, data);
}
-void
-command_saved_set_cb (struct command_saved *cs, struct callback *cb)
-{
- cs->cb = cb;
+void command_add_table(struct callback_list *cbl, struct command_table *table, int count, void *data) {
+ struct attr attr;
+ command_add_table_attr(table, count, data, &attr);
+ callback_list_add(cbl, attr.u.callback);
+}
+
+void command_saved_set_cb (struct command_saved *cs, struct callback *cb) {
+ cs->cb = cb;
}
/**
@@ -1635,16 +1534,12 @@ command_saved_set_cb (struct command_saved *cs, struct callback *cb)
* This function is a wrapper around {@code get_int()}. It is equivalent to
* {@code get_int(&cs->ctx, &cs->res)}. See {@code get_int()} for a description.
*/
-int
-command_saved_get_int (struct command_saved *cs)
-{
- return get_int(&cs->ctx, &cs->res);
+int command_saved_get_int (struct command_saved *cs) {
+ return get_int(&cs->ctx, &cs->res);
}
-int
-command_saved_error (struct command_saved *cs)
-{
- return cs->error;
+int command_saved_error (struct command_saved *cs) {
+ return cs->error;
}
/**
@@ -1657,27 +1552,25 @@ command_saved_error (struct command_saved *cs)
*
* @param cs The command to evaluate
*/
-static void
-command_saved_evaluate_idle (struct command_saved *cs)
-{
- dbg(lvl_debug, "enter: cs=%p, cs->command=%s\n", cs, cs->command);
- // Only run once at a time
- if (cs->idle_ev) {
- event_remove_idle(cs->idle_ev);
- cs->idle_ev = NULL;
- }
+static void command_saved_evaluate_idle (struct command_saved *cs) {
+ dbg(lvl_debug, "enter: cs=%p, cs->command=%s", cs, cs->command);
+ // Only run once at a time
+ if (cs->idle_ev) {
+ event_remove_idle(cs->idle_ev);
+ cs->idle_ev = NULL;
+ }
- command_evaluate_to(&cs->context_attr, cs->command, &cs->ctx, &cs->res);
+ command_evaluate_to(&cs->context_attr, cs->command, &cs->ctx, &cs->res);
- if (!cs->ctx.error) {
- cs->error = 0;
+ if (!cs->ctx.error) {
+ cs->error = 0;
- if (cs->cb) {
- callback_call_1(cs->cb, cs);
- }
- } else {
- cs->error = cs->ctx.error;
- }
+ if (cs->cb) {
+ callback_call_1(cs->cb, cs);
+ }
+ } else {
+ cs->error = cs->ctx.error;
+ }
}
/**
@@ -1691,24 +1584,22 @@ command_saved_evaluate_idle (struct command_saved *cs)
*
* @param cs The command to evaluate
*/
-static void
-command_saved_evaluate(struct command_saved *cs)
-{
- dbg(lvl_debug, "enter: cs=%p, cs->async=%d, cs->command=%s\n", cs, cs->async, cs->command);
- if (!cs->async) {
- command_saved_evaluate_idle(cs);
- return;
- }
- if (cs->idle_ev) {
- // We're already scheduled for reevaluation
- return;
- }
-
- if (!cs->idle_cb) {
- cs->idle_cb = callback_new_1(callback_cast(command_saved_evaluate_idle), cs);
- }
-
- cs->idle_ev = event_add_idle(100, cs->idle_cb);
+static void command_saved_evaluate(struct command_saved *cs) {
+ dbg(lvl_debug, "enter: cs=%p, cs->async=%d, cs->command=%s", cs, cs->async, cs->command);
+ if (!cs->async) {
+ command_saved_evaluate_idle(cs);
+ return;
+ }
+ if (cs->idle_ev) {
+ // We're already scheduled for reevaluation
+ return;
+ }
+
+ if (!cs->idle_cb) {
+ cs->idle_cb = callback_new_1(callback_cast(command_saved_evaluate_idle), cs);
+ }
+
+ cs->idle_ev = event_add_idle(100, cs->idle_cb);
}
/**
@@ -1716,43 +1607,42 @@ command_saved_evaluate(struct command_saved *cs)
*
* @param cs The saved command
*/
-static void
-command_saved_callbacks_changed(struct command_saved *cs)
-{
- // For now, we delete each and every callback and then re-create them
- int i;
- struct object_func *func;
- struct attr attr;
+static void command_saved_callbacks_changed(struct command_saved *cs) {
+ // For now, we delete each and every callback and then re-create them
+ int i;
+ struct object_func *func;
+ struct attr attr;
- dbg(lvl_debug, "enter: cs=%p, cs->async=%d, cs->command=%s\n", cs, cs->async, cs->command);
+ dbg(lvl_debug, "enter: cs=%p, cs->async=%d, cs->command=%s", cs, cs->async, cs->command);
- if (cs->register_ev) {
- event_remove_idle(cs->register_ev);
- cs->register_ev = NULL;
- }
+ if (cs->register_ev) {
+ event_remove_idle(cs->register_ev);
+ cs->register_ev = NULL;
+ }
- attr.type = attr_callback;
+ attr.type = attr_callback;
- for (i = 0; i < cs->num_cbs; i++) {
- func = object_func_lookup(cs->cbs[i].attr.type);
-
- if (!func->remove_attr) {
- dbg(lvl_error, "Could not remove command-evaluation callback because remove_attr is missing for type %i!\n", cs->cbs[i].attr.type);
- continue;
- }
+ for (i = 0; i < cs->num_cbs; i++) {
+ func = object_func_lookup(cs->cbs[i].attr.type);
- attr.u.callback = cs->cbs[i].cb;
+ if (!func->remove_attr) {
+ dbg(lvl_error, "Could not remove command-evaluation callback because remove_attr is missing for type %i!",
+ cs->cbs[i].attr.type);
+ continue;
+ }
- func->remove_attr(cs->cbs[i].attr.u.data, &attr);
- callback_destroy(cs->cbs[i].cb);
- }
+ attr.u.callback = cs->cbs[i].cb;
- g_free(cs->cbs);
- cs->cbs = NULL;
- cs->num_cbs = 0;
+ func->remove_attr(cs->cbs[i].attr.u.data, &attr);
+ callback_destroy(cs->cbs[i].cb);
+ }
- // Now, re-create all the callbacks
- command_register_callbacks(cs);
+ g_free(cs->cbs);
+ cs->cbs = NULL;
+ cs->num_cbs = 0;
+
+ // Now, re-create all the callbacks
+ command_register_callbacks(cs);
}
/**
@@ -1772,77 +1662,79 @@ command_saved_callbacks_changed(struct command_saved *cs)
*
* @return True if all callbacks were successfully registered, false if the function failed
*/
-static int
-command_register_callbacks(struct command_saved *cs)
-{
- struct attr prev; /* The parent of the next object which will be retrieved. */
- struct attr cb_attr;
- int status;
- struct object_func *func;
- struct callback *cb;
- int tmpoffset; /* For debugging. Because we work with pointers into the same string instance.
+static int command_register_callbacks(struct command_saved *cs) {
+ struct attr prev; /* The parent of the next object which will be retrieved. */
+ struct attr cb_attr;
+ int status;
+ struct object_func *func;
+ struct callback *cb;
+ int tmpoffset; /* For debugging. Because we work with pointers into the same string instance.
* we can figure out offsets by using simple pointer arithmetics.
*/
-
- dbg(lvl_debug, "enter: cs=%p, cs->async=%d, cs->command=%s\n", cs, cs->async, cs->command);
- cs->ctx.expr = cs->command;
- prev = cs->context_attr;
-
- while ((status = get_next_object(&cs->ctx, &cs->res)) != 0) {
- tmpoffset = cs->res.var - cs->command;
- cs->ctx.attr = &prev;
- resolve(&cs->ctx, &cs->res);
-
- if (cs->ctx.error) {
- /* An error occurred while parsing the command */
- tmpoffset = cs->ctx.expr - cs->command;
- dbg(lvl_error, "parsing error: cs=%p, cs->ctx.error=%d\n\t%s\n\t%*s\n", cs, cs->ctx.error, cs->command, tmpoffset + 1, "^");
- return 0;
- } else if (cs->res.attr.type == attr_none) {
- /* We could not resolve an object, perhaps because it has not been created */
- dbg(lvl_error, "could not resolve object in cs=%p:\n\t%s\n\t%*s\n", cs, cs->command, tmpoffset + 1, "^");
- return 0;
- }
-
- if (prev.type != attr_none) {
- func = object_func_lookup(prev.type);
-
- if (func->add_attr) {
- if (status == 2) { // This is not the final attribute name
- cb = callback_new_attr_1(callback_cast(command_saved_callbacks_changed), cs->res.attr.type, (void*)cs);
- } else if (status == 1) { // This is the final attribute name
- cb = callback_new_attr_1(callback_cast(command_saved_evaluate), cs->res.attr.type, (void*)cs);
- cs->ctx.attr = &cs->context_attr;
- } else {
- dbg(lvl_error, "Error: Strange status returned from get_next_object()\n");
- }
-
- cs->num_cbs++;
- cs->cbs = g_realloc(cs->cbs, (sizeof(struct command_saved_cb) * cs->num_cbs));
- cs->cbs[cs->num_cbs-1].cb = cb;
- cs->cbs[cs->num_cbs-1].attr = prev;
-
- cb_attr.u.callback = cb;
- cb_attr.type = attr_callback;
-
- func->add_attr(prev.u.data, &cb_attr);
-
- } else {
- dbg(lvl_error, "Could not add callback because add_attr is missing for type %i\n", prev.type);
- }
- }
-
- if (status == 2) {
- prev = cs->res.attr;
- } else {
- prev = cs->context_attr;
- }
- }
-
- command_saved_evaluate_idle(cs);
-
- dbg(lvl_debug, "done: cs=%p, cs->command=%s\n", cs, cs->command);
- return 1;
+
+ dbg(lvl_debug, "enter: cs=%p, cs->async=%d, cs->command=%s", cs, cs->async, cs->command);
+ cs->ctx.expr = cs->command;
+ prev = cs->context_attr;
+
+ while ((status = get_next_object(&cs->ctx, &cs->res)) != 0) {
+ tmpoffset = cs->res.var - cs->command;
+ cs->ctx.attr = &prev;
+ resolve(&cs->ctx, &cs->res);
+
+ if (cs->ctx.error) {
+ /* An error occurred while parsing the command */
+ tmpoffset = cs->ctx.expr - cs->command;
+ dbg(lvl_error, "parsing error: cs=%p, cs->ctx.error=%d", cs, cs->ctx.error);
+ dbg(lvl_error, "\t%s", cs->command);
+ dbg(lvl_error, "\t%*s", tmpoffset + 1, "^");
+ return 0;
+ } else if (cs->res.attr.type == attr_none) {
+ /* We could not resolve an object, perhaps because it has not been created */
+ dbg(lvl_error, "could not resolve object in cs=%p:", cs);
+ dbg(lvl_error, "\t%s", cs->command);
+ dbg(lvl_error, "\t%*s", tmpoffset + 1, "^");
+ return 0;
+ }
+
+ if (prev.type != attr_none) {
+ func = object_func_lookup(prev.type);
+
+ if (func->add_attr) {
+ if (status == 2) { // This is not the final attribute name
+ cb = callback_new_attr_1(callback_cast(command_saved_callbacks_changed), cs->res.attr.type, (void*)cs);
+ } else if (status == 1) { // This is the final attribute name
+ cb = callback_new_attr_1(callback_cast(command_saved_evaluate), cs->res.attr.type, (void*)cs);
+ cs->ctx.attr = &cs->context_attr;
+ } else {
+ dbg(lvl_error, "Error: Strange status returned from get_next_object()");
+ }
+
+ cs->num_cbs++;
+ cs->cbs = g_realloc(cs->cbs, (sizeof(struct command_saved_cb) * cs->num_cbs));
+ cs->cbs[cs->num_cbs-1].cb = cb;
+ cs->cbs[cs->num_cbs-1].attr = prev;
+
+ cb_attr.u.callback = cb;
+ cb_attr.type = attr_callback;
+
+ func->add_attr(prev.u.data, &cb_attr);
+
+ } else {
+ dbg(lvl_error, "Could not add callback because add_attr is missing for type %i", prev.type);
+ }
+ }
+
+ if (status == 2) {
+ prev = cs->res.attr;
+ } else {
+ prev = cs->context_attr;
+ }
+ }
+
+ command_saved_evaluate_idle(cs);
+
+ dbg(lvl_debug, "done: cs=%p, cs->command=%s", cs, cs->command);
+ return 1;
}
/**
@@ -1855,38 +1747,34 @@ command_register_callbacks(struct command_saved *cs)
* in an idle callback
*/
struct command_saved *
-command_saved_attr_new(char *command, struct attr *attr, struct callback *cb, int async)
-{
- struct command_saved *ret;
+command_saved_attr_new(char *command, struct attr *attr, struct callback *cb, int async) {
+ struct command_saved *ret;
- ret = g_new0(struct command_saved, 1);
- dbg(lvl_debug, "enter, ret=%p, command=%s\n", ret, command);
- ret->command = g_strdup(command);
- ret->context_attr = *attr;
- ret->cb = cb;
- ret->error = not_ready;
- ret->async = async;
+ ret = g_new0(struct command_saved, 1);
+ dbg(lvl_debug, "enter, ret=%p, command=%s", ret, command);
+ ret->command = g_strdup(command);
+ ret->context_attr = *attr;
+ ret->cb = cb;
+ ret->error = not_ready;
+ ret->async = async;
- if (!command_register_callbacks(ret)) {
- // We try this as an idle call again
- dbg(lvl_debug, "could not register callbacks, will retry as an idle call\n");
- ret->register_cb = callback_new_1(callback_cast(command_saved_callbacks_changed), ret);
- ret->register_ev = event_add_idle(300, ret->register_cb);
- }
+ if (!command_register_callbacks(ret)) {
+ // We try this as an idle call again
+ dbg(lvl_debug, "could not register callbacks, will retry as an idle call");
+ ret->register_cb = callback_new_1(callback_cast(command_saved_callbacks_changed), ret);
+ ret->register_ev = event_add_idle(300, ret->register_cb);
+ }
- return ret;
+ return ret;
}
struct command_saved *
-command_saved_new(char *command, struct navit *navit, struct callback *cb, int async)
-{
- struct attr attr=ATTR_OBJECT(navit, navit);
- return command_saved_attr_new(command, &attr, cb, async);
+command_saved_new(char *command, struct navit *navit, struct callback *cb, int async) {
+ struct attr attr=ATTR_OBJECT(navit, navit);
+ return command_saved_attr_new(command, &attr, cb, async);
}
-void
-command_saved_destroy(struct command_saved *cs)
-{
- g_free(cs->command);
- g_free(cs);
+void command_saved_destroy(struct command_saved *cs) {
+ g_free(cs->command);
+ g_free(cs);
}
diff --git a/navit/config_.c b/navit/config_.c
index 9f4bd5860..644b66d70 100644
--- a/navit/config_.c
+++ b/navit/config_.c
@@ -32,13 +32,12 @@
#endif
struct config {
- NAVIT_OBJECT
+ NAVIT_OBJECT
} *config;
struct config *
-config_get(void)
-{
- return config;
+config_get(void) {
+ return config;
}
int config_empty_ok;
@@ -46,139 +45,119 @@ int config_empty_ok;
int configured;
struct attr_iter {
- void *iter;
+ void *iter;
};
-void
-config_destroy(struct config *this_)
-{
- attr_list_free(this_->attrs);
- g_free(config);
- exit(0);
+void config_destroy(struct config *this_) {
+ attr_list_free(this_->attrs);
+ g_free(config);
+ exit(0);
}
-static void
-config_terminate(int sig)
-{
- dbg(lvl_debug,"terminating\n");
- config_destroy(config);
+static void config_terminate(int sig) {
+ dbg(lvl_debug,"terminating");
+ config_destroy(config);
}
-static void
-config_new_int(void)
-{
- config=g_new0(struct config, 1);
+static void config_new_int(void) {
+ config=g_new0(struct config, 1);
#ifndef HAVE_API_WIN32_CE
- signal(SIGTERM, config_terminate);
+ signal(SIGTERM, config_terminate);
#ifndef HAVE_API_WIN32
#ifndef _MSC_VER
#ifndef __MINGW32__
- signal(SIGPIPE, SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
#endif /* __MINGW32__ */
#endif
#endif
#endif
}
-int
-config_get_attr(struct config *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+int config_get_attr(struct config *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
}
-static int
-config_set_attr_int(struct config *this_, struct attr *attr)
-{
- switch (attr->type) {
- case attr_language:
- setenv("LANG",attr->u.str,1);
- return 1;
- case attr_cache_size:
- return file_set_cache_size(attr->u.num);
- default:
- return 0;
- }
+static int config_set_attr_int(struct config *this_, struct attr *attr) {
+ switch (attr->type) {
+ case attr_language:
+ setenv("LANG",attr->u.str,1);
+ return 1;
+ case attr_cache_size:
+ return file_set_cache_size(attr->u.num);
+ default:
+ return 0;
+ }
}
-int
-config_set_attr(struct config *this_, struct attr *attr)
-{
- if (config_set_attr_int(this_, attr))
- return navit_object_set_attr((struct navit_object *)this_, attr);
- else
- return 0;
+int config_set_attr(struct config *this_, struct attr *attr) {
+ if (config_set_attr_int(this_, attr))
+ return navit_object_set_attr((struct navit_object *)this_, attr);
+ else
+ return 0;
}
-int
-config_add_attr(struct config *this_, struct attr *attr)
-{
- if (!config) {
- config_new_int();
- this_=config;
- }
- return navit_object_add_attr((struct navit_object *)this_, attr);
+int config_add_attr(struct config *this_, struct attr *attr) {
+ if (!config) {
+ config_new_int();
+ this_=config;
+ }
+ return navit_object_add_attr((struct navit_object *)this_, attr);
}
-int
-config_remove_attr(struct config *this_, struct attr *attr)
-{
- return navit_object_remove_attr((struct navit_object *)this_, attr);
+int config_remove_attr(struct config *this_, struct attr *attr) {
+ return navit_object_remove_attr((struct navit_object *)this_, attr);
}
struct attr_iter *
-config_attr_iter_new()
-{
- return navit_object_attr_iter_new();
+config_attr_iter_new() {
+ return navit_object_attr_iter_new();
}
-void
-config_attr_iter_destroy(struct attr_iter *iter)
-{
- navit_object_attr_iter_destroy(iter);
+void config_attr_iter_destroy(struct attr_iter *iter) {
+ navit_object_attr_iter_destroy(iter);
}
struct config *
-config_new(struct attr *parent, struct attr **attrs)
-{
- if (configured) {
- dbg(lvl_error,"only one config allowed\n");
- return config;
- }
- if (parent) {
- dbg(lvl_error,"no parent in config allowed\n");
- return NULL;
- }
- if (!config)
- config_new_int();
- config->func=&config_func;
- navit_object_ref((struct navit_object *)config);
- config->attrs=attr_generic_add_attr_list(config->attrs, attrs);
- while (*attrs) {
- if (!config_set_attr_int(config,*attrs)) {
- dbg(lvl_error,"failed to set attribute '%s'\n",attr_to_name((*attrs)->type));
- config_destroy(config);
- config=NULL;
- break;
- }
- attrs++;
- }
- configured=1;
- return config;
+config_new(struct attr *parent, struct attr **attrs) {
+ if (configured) {
+ dbg(lvl_error,"only one config allowed");
+ return config;
+ }
+ if (parent) {
+ dbg(lvl_error,"no parent in config allowed");
+ return NULL;
+ }
+ if (!config)
+ config_new_int();
+ config->func=&config_func;
+ navit_object_ref((struct navit_object *)config);
+ config->attrs=attr_generic_add_attr_list(config->attrs, attrs);
+ while (*attrs) {
+ if (!config_set_attr_int(config,*attrs)) {
+ dbg(lvl_error,"failed to set attribute '%s'",attr_to_name((*attrs)->type));
+ config_destroy(config);
+ config=NULL;
+ break;
+ }
+ attrs++;
+ }
+ configured=1;
+ return config;
}
struct object_func config_func = {
- attr_config,
- (object_func_new)config_new,
- (object_func_get_attr)navit_object_get_attr,
- (object_func_iter_new)navit_object_attr_iter_new,
- (object_func_iter_destroy)navit_object_attr_iter_destroy,
- (object_func_set_attr)config_set_attr,
- (object_func_add_attr)config_add_attr,
- (object_func_remove_attr)navit_object_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)NULL,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_config,
+ (object_func_new)config_new,
+ (object_func_get_attr)navit_object_get_attr,
+ (object_func_iter_new)navit_object_attr_iter_new,
+ (object_func_iter_destroy)navit_object_attr_iter_destroy,
+ (object_func_set_attr)config_set_attr,
+ (object_func_add_attr)config_add_attr,
+ (object_func_remove_attr)navit_object_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)NULL,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/coord.c b/navit/coord.c
index 2bc169d46..bb16978c8 100644
--- a/navit/coord.c
+++ b/navit/coord.c
@@ -39,110 +39,93 @@
* @returns the coordinate
*/
-struct coord *
-coord_get(unsigned char **p)
-{
- struct coord *ret=(struct coord *)(*p);
- *p += sizeof(*ret);
- return ret;
+struct coord * coord_get(unsigned char **p) {
+ struct coord *ret=(struct coord *)(*p);
+ *p += sizeof(*ret);
+ return ret;
}
-struct coord *
-coord_new(int x, int y)
-{
- struct coord *c=g_new(struct coord, 1);
+struct coord * coord_new(int x, int y) {
+ struct coord *c=g_new(struct coord, 1);
- c->x=x;
- c->y=y;
+ c->x=x;
+ c->y=y;
- return c;
+ return c;
}
-struct coord *
-coord_new_from_attrs(struct attr *parent, struct attr **attrs)
-{
- struct attr *x,*y;
- x=attr_search(attrs, NULL, attr_x);
- y=attr_search(attrs, NULL, attr_y);
- if (!x || !y)
- return NULL;
- return coord_new(x->u.num, y->u.num);
+struct coord * coord_new_from_attrs(struct attr *parent, struct attr **attrs) {
+ struct attr *x,*y;
+ x=attr_search(attrs, NULL, attr_x);
+ y=attr_search(attrs, NULL, attr_y);
+ if (!x || !y)
+ return NULL;
+ return coord_new(x->u.num, y->u.num);
}
-void
-coord_destroy(struct coord *c)
-{
- g_free(c);
+void coord_destroy(struct coord *c) {
+ g_free(c);
}
-struct coord_rect *
-coord_rect_new(struct coord *lu, struct coord *rl)
-{
- struct coord_rect *r=g_new(struct coord_rect, 1);
+struct coord_rect * coord_rect_new(struct coord *lu, struct coord *rl) {
+ struct coord_rect *r=g_new(struct coord_rect, 1);
+
+ dbg_assert(lu->x <= rl->x);
+ dbg_assert(lu->y >= rl->y);
- dbg_assert(lu->x <= rl->x);
- dbg_assert(lu->y >= rl->y);
+ r->lu=*lu;
+ r->rl=*rl;
- r->lu=*lu;
- r->rl=*rl;
+ return r;
- return r;
-
}
-void
-coord_rect_destroy(struct coord_rect *r)
-{
- g_free(r);
+void coord_rect_destroy(struct coord_rect *r) {
+ g_free(r);
}
-int
-coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2)
-{
- dbg_assert(r1->lu.x <= r1->rl.x);
- dbg_assert(r1->lu.y >= r1->rl.y);
- dbg_assert(r2->lu.x <= r2->rl.x);
- dbg_assert(r2->lu.y >= r2->rl.y);
- dbg(lvl_debug,"0x%x,0x%x - 0x%x,0x%x vs 0x%x,0x%x - 0x%x,0x%x\n", r1->lu.x, r1->lu.y, r1->rl.x, r1->rl.y, r2->lu.x, r2->lu.y, r2->rl.x, r2->rl.y);
- if (r1->lu.x > r2->rl.x)
- return 0;
- if (r1->rl.x < r2->lu.x)
- return 0;
- if (r1->lu.y < r2->rl.y)
- return 0;
- if (r1->rl.y > r2->lu.y)
- return 0;
- return 1;
+int coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2) {
+ dbg_assert(r1->lu.x <= r1->rl.x);
+ dbg_assert(r1->lu.y >= r1->rl.y);
+ dbg_assert(r2->lu.x <= r2->rl.x);
+ dbg_assert(r2->lu.y >= r2->rl.y);
+ dbg(lvl_debug,"0x%x,0x%x - 0x%x,0x%x vs 0x%x,0x%x - 0x%x,0x%x", r1->lu.x, r1->lu.y, r1->rl.x, r1->rl.y, r2->lu.x,
+ r2->lu.y, r2->rl.x, r2->rl.y);
+ if (r1->lu.x > r2->rl.x)
+ return 0;
+ if (r1->rl.x < r2->lu.x)
+ return 0;
+ if (r1->lu.y < r2->rl.y)
+ return 0;
+ if (r1->rl.y > r2->lu.y)
+ return 0;
+ return 1;
}
-int
-coord_rect_contains(struct coord_rect *r, struct coord *c)
-{
- dbg_assert(r->lu.x <= r->rl.x);
- dbg_assert(r->lu.y >= r->rl.y);
- if (c->x < r->lu.x)
- return 0;
- if (c->x > r->rl.x)
- return 0;
- if (c->y < r->rl.y)
- return 0;
- if (c->y > r->lu.y)
- return 0;
- return 1;
+int coord_rect_contains(struct coord_rect *r, struct coord *c) {
+ dbg_assert(r->lu.x <= r->rl.x);
+ dbg_assert(r->lu.y >= r->rl.y);
+ if (c->x < r->lu.x)
+ return 0;
+ if (c->x > r->rl.x)
+ return 0;
+ if (c->y < r->rl.y)
+ return 0;
+ if (c->y > r->lu.y)
+ return 0;
+ return 1;
}
-void
-coord_rect_extend(struct coord_rect *r, struct coord *c)
-{
- if (c->x < r->lu.x)
- r->lu.x=c->x;
- if (c->x > r->rl.x)
- r->rl.x=c->x;
- if (c->y < r->rl.y)
- r->rl.y=c->y;
- if (c->y > r->lu.y)
- r->lu.y=c->y;
+void coord_rect_extend(struct coord_rect *r, struct coord *c) {
+ if (c->x < r->lu.x)
+ r->lu.x=c->x;
+ if (c->x > r->rl.x)
+ r->rl.x=c->x;
+ if (c->y < r->rl.y)
+ r->rl.y=c->y;
+ if (c->y > r->lu.y)
+ r->lu.y=c->y;
}
/**
@@ -161,112 +144,109 @@ coord_rect_extend(struct coord_rect *r, struct coord *c)
* @returns The lenght of the parsed string
*/
-int
-coord_parse(const char *coord_input, enum projection output_projection, struct coord *result)
-{
- char *proj=NULL,*s,*co;
- const char *str=coord_input;
- int args,ret = 0;
- struct coord_geo g;
- struct coord c,offset;
- enum projection str_pro=projection_none;
-
- dbg(lvl_debug,"enter('%s',%d,%p)\n", coord_input, output_projection, result);
- s=strchr(str,' ');
- co=strchr(str,':');
- if (co && co < s) {
- proj=malloc(co-str+1);
- strncpy(proj, str, co-str);
- proj[co-str]='\0';
- dbg(lvl_debug,"projection=%s\n", proj);
- str=co+1;
- s=strchr(str,' ');
- if (!strcmp(proj, "geo"))
- str_pro = projection_none;
- else {
- str_pro = projection_from_name(proj,&offset);
- if (str_pro == projection_none) {
- dbg(lvl_error, "Unknown projection: %s\n", proj);
- goto out;
- }
- }
- }
- if (! s) {
- ret=0;
- goto out;
- }
- while (*s == ' ') {
- s++;
- }
- if (!strncmp(s, "0x", 2) || !strncmp(s, "-0x", 3)) {
- args=sscanf(str, "%i %i%n",&c.x, &c.y, &ret);
- if (args < 2)
- goto out;
- dbg(lvl_debug,"str='%s' x=0x%x y=0x%x c=%d\n", str, c.x, c.y, ret);
- dbg(lvl_debug,"rest='%s'\n", str+ret);
-
- if (str_pro == projection_none)
- str_pro=projection_mg;
- if (str_pro != output_projection) {
- transform_to_geo(str_pro, &c, &g);
- transform_from_geo(output_projection, &g, &c);
- }
- *result=c;
- } else if (*s == 'N' || *s == 'n' || *s == 'S' || *s == 's') {
- double lng, lat;
- char ns, ew;
- dbg(lvl_debug,"str='%s'\n", str);
- args=sscanf(str, "%lf %c %lf %c%n", &lat, &ns, &lng, &ew, &ret);
- dbg(lvl_debug,"args=%d\n", args);
- dbg(lvl_debug,"lat=%f %c lon=%f %c\n", lat, ns, lng, ew);
- if (args < 4)
- goto out;
- dbg(lvl_debug,"projection=%d str_pro=%d projection_none=%d\n", output_projection, str_pro, projection_none);
- if (str_pro == projection_none) {
- g.lat=floor(lat/100);
- lat-=g.lat*100;
- g.lat+=lat/60;
- g.lng=floor(lng/100);
- lng-=g.lng*100;
- g.lng+=lng/60;
- if (ns == 's' || ns == 'S')
- g.lat=-g.lat;
- if (ew == 'w' || ew == 'W')
- g.lng=-g.lng;
- dbg(lvl_debug,"transform_from_geo(%f,%f)",g.lat,g.lng);
- transform_from_geo(output_projection, &g, result);
- dbg(lvl_debug,"result 0x%x,0x%x\n", result->x,result->y);
- }
- dbg(lvl_debug,"str='%s' x=%f ns=%c y=%f ew=%c c=%d\n", str, lng, ns, lat, ew, ret);
- dbg(lvl_debug,"rest='%s'\n", str+ret);
- } else if (str_pro == projection_utm) {
- double x,y;
- args=sscanf(str, "%lf %lf%n", &x, &y, &ret);
- if (args < 2)
- goto out;
- c.x=x+offset.x;
- c.y=y+offset.y;
- if (str_pro != output_projection) {
- transform_to_geo(str_pro, &c, &g);
- transform_from_geo(output_projection, &g, &c);
- }
- *result=c;
- } else {
- double lng, lat;
- args=sscanf(str, "%lf %lf%n", &lng, &lat, &ret);
- if (args < 2)
- goto out;
- dbg(lvl_debug,"str='%s' x=%f y=%f c=%d\n", str, lng, lat, ret);
- dbg(lvl_debug,"rest='%s'\n", str+ret);
- g.lng=lng;
- g.lat=lat;
- transform_from_geo(output_projection, &g, result);
- }
- ret+=str-coord_input;
- dbg(lvl_info, "ret=%d delta=%d ret_str='%s'\n", ret, GPOINTER_TO_INT(str-coord_input), coord_input+ret);
+int coord_parse(const char *coord_input, enum projection output_projection, struct coord *result) {
+ char *proj=NULL,*s,*co;
+ const char *str=coord_input;
+ int args,ret = 0;
+ struct coord_geo g;
+ struct coord c,offset;
+ enum projection str_pro=projection_none;
+
+ dbg(lvl_debug,"enter('%s',%d,%p)", coord_input, output_projection, result);
+ s=strchr(str,' ');
+ co=strchr(str,':');
+ if (co && co < s) {
+ proj=g_malloc(co-str+1);
+ g_strlcpy(proj, str, 1+co-str);
+ dbg(lvl_debug,"projection=%s", proj);
+ str=co+1;
+ s=strchr(str,' ');
+ if (!strcmp(proj, "geo"))
+ str_pro = projection_none;
+ else {
+ str_pro = projection_from_name(proj,&offset);
+ if (str_pro == projection_none) {
+ dbg(lvl_error, "Unknown projection: %s", proj);
+ goto out;
+ }
+ }
+ }
+ if (! s) {
+ ret=0;
+ goto out;
+ }
+ while (*s == ' ') {
+ s++;
+ }
+ if (!strncmp(s, "0x", 2) || !strncmp(s, "-0x", 3)) {
+ args=sscanf(str, "%i %i%n",&c.x, &c.y, &ret);
+ if (args < 2)
+ goto out;
+ dbg(lvl_debug,"str='%s' x=0x%x y=0x%x c=%d", str, c.x, c.y, ret);
+ dbg(lvl_debug,"rest='%s'", str+ret);
+
+ if (str_pro == projection_none)
+ str_pro=projection_mg;
+ if (str_pro != output_projection) {
+ transform_to_geo(str_pro, &c, &g);
+ transform_from_geo(output_projection, &g, &c);
+ }
+ *result=c;
+ } else if (*s == 'N' || *s == 'n' || *s == 'S' || *s == 's') {
+ double lng, lat;
+ char ns, ew;
+ dbg(lvl_debug,"str='%s'", str);
+ args=sscanf(str, "%lf %c %lf %c%n", &lat, &ns, &lng, &ew, &ret);
+ dbg(lvl_debug,"args=%d", args);
+ dbg(lvl_debug,"lat=%f %c lon=%f %c", lat, ns, lng, ew);
+ if (args < 4)
+ goto out;
+ dbg(lvl_debug,"projection=%d str_pro=%d projection_none=%d", output_projection, str_pro, projection_none);
+ if (str_pro == projection_none) {
+ g.lat=floor(lat/100);
+ lat-=g.lat*100;
+ g.lat+=lat/60;
+ g.lng=floor(lng/100);
+ lng-=g.lng*100;
+ g.lng+=lng/60;
+ if (ns == 's' || ns == 'S')
+ g.lat=-g.lat;
+ if (ew == 'w' || ew == 'W')
+ g.lng=-g.lng;
+ dbg(lvl_debug,"transform_from_geo(%f,%f)",g.lat,g.lng);
+ transform_from_geo(output_projection, &g, result);
+ dbg(lvl_debug,"result 0x%x,0x%x", result->x,result->y);
+ }
+ dbg(lvl_debug,"str='%s' x=%f ns=%c y=%f ew=%c c=%d", str, lng, ns, lat, ew, ret);
+ dbg(lvl_debug,"rest='%s'", str+ret);
+ } else if (str_pro == projection_utm) {
+ double x,y;
+ args=sscanf(str, "%lf %lf%n", &x, &y, &ret);
+ if (args < 2)
+ goto out;
+ c.x=x+offset.x;
+ c.y=y+offset.y;
+ if (str_pro != output_projection) {
+ transform_to_geo(str_pro, &c, &g);
+ transform_from_geo(output_projection, &g, &c);
+ }
+ *result=c;
+ } else {
+ double lng, lat;
+ args=sscanf(str, "%lf %lf%n", &lng, &lat, &ret);
+ if (args < 2)
+ goto out;
+ dbg(lvl_debug,"str='%s' x=%f y=%f c=%d", str, lng, lat, ret);
+ dbg(lvl_debug,"rest='%s'", str+ret);
+ g.lng=lng;
+ g.lat=lat;
+ transform_from_geo(output_projection, &g, result);
+ }
+ ret+=str-coord_input;
+ dbg(lvl_info, "ret=%d delta=%d ret_str='%s'", ret, GPOINTER_TO_INT(str-coord_input), coord_input+ret);
out:
- free(proj);
- return ret;
+ g_free(proj);
+ return ret;
}
/**
@@ -274,9 +254,7 @@ out:
* For parameters see coord_parse.
*/
-int
-pcoord_parse(const char *c_str, enum projection pro, struct pcoord *pc_ret)
-{
+int pcoord_parse(const char *c_str, enum projection pro, struct pcoord *pc_ret) {
struct coord c;
int ret;
ret = coord_parse(c_str, pro, &c);
@@ -286,116 +264,111 @@ pcoord_parse(const char *c_str, enum projection pro, struct pcoord *pc_ret)
return ret;
}
-void
-coord_print(enum projection pro, struct coord *c, FILE *out) {
- unsigned int x;
- unsigned int y;
- char *sign_x = "";
- char *sign_y = "";
-
- if ( c->x < 0 ) {
- x = -c->x;
- sign_x = "-";
- } else {
- x = c->x;
- }
- if ( c->y < 0 ) {
- y = -c->y;
- sign_y = "-";
- } else {
- y = c->y;
- }
- fprintf( out, "%s: %s0x%x %s0x%x\n",
- projection_to_name( pro ),
- sign_x, x,
- sign_y, y );
- return;
+void coord_print(enum projection pro, struct coord *c, FILE *out) {
+ unsigned int x;
+ unsigned int y;
+ char *sign_x = "";
+ char *sign_y = "";
+
+ if ( c->x < 0 ) {
+ x = -c->x;
+ sign_x = "-";
+ } else {
+ x = c->x;
+ }
+ if ( c->y < 0 ) {
+ y = -c->y;
+ sign_y = "-";
+ } else {
+ y = c->y;
+ }
+ fprintf( out, "%s: %s0x%x %s0x%x\n",
+ projection_to_name( pro ),
+ sign_x, x,
+ sign_y, y );
+ return;
}
/**
* @brief Converts a lat/lon into a text formatted text string.
* @param lat The latitude (if lat is 360 or greater, the latitude will be omitted)
* @param lng The longitude (if lng is 360 or greater, the longitude will be omitted)
- * @param fmt The format to use.
+ * @param fmt The format to use.
* @li DEGREES_DECIMAL=>Degrees with decimal places, i.e. 20.5000°N 110.5000°E
* @li DEGREES_MINUTES=>Degrees and minutes, i.e. 20°30.00'N 110°30.00'E
* @li DEGREES_MINUTES_SECONDS=>Degrees, minutes and seconds, i.e. 20°30'30.00"N 110°30'30"E
- *
- *
+ *
+ *
* @param buffer A buffer large enough to hold the output + a terminating NULL (up to 31 bytes)
* @param size The size of the buffer
*
*/
-void coord_format(float lat,float lng, enum coord_format fmt, char * buffer, int size)
-{
-
- char lat_c='N';
- char lng_c='E';
- float lat_deg,lat_min,lat_sec;
- float lng_deg,lng_min,lng_sec;
- int size_used=0;
-
- if (lng < 0) {
- lng=-lng;
- lng_c='W';
- }
- if (lat < 0) {
- lat=-lat;
- lat_c='S';
- }
- lat_deg=lat;
- lat_min=(lat-floor(lat_deg))*60;
- lat_sec=fmod(lat*3600,60);
- lng_deg=lng;
- lng_min=(lng-floor(lng_deg))*60;
- lng_sec=fmod(lng*3600,60);
- switch(fmt)
- {
-
- case DEGREES_DECIMAL:
- if (lat<360)
- size_used+=g_snprintf(buffer+size_used,size-size_used,"%02.6f°%c",lat,lat_c);
- if ((lat<360)&&(lng<360))
- size_used+=g_snprintf(buffer+size_used,size-size_used," ");
- if (lng<360)
- size_used+=g_snprintf(buffer+size_used,size-size_used,"%03.7f°%c",lng,lng_c);
- break;
- case DEGREES_MINUTES:
- if (lat<360)
- size_used+=g_snprintf(buffer+size_used,size-size_used,"%02.0f°%07.4f' %c",floor(lat_deg),lat_min,lat_c);
- if ((lat<360)&&(lng<360))
- size_used+=g_snprintf(buffer+size_used,size-size_used," ");
- if (lng<360)
- size_used+=g_snprintf(buffer+size_used,size-size_used,"%03.0f°%07.4f' %c",floor(lng_deg),lng_min,lng_c);
- break;
- case DEGREES_MINUTES_SECONDS:
- if (lat<360)
- size_used+=g_snprintf(buffer+size_used,size-size_used,"%02.0f°%02.0f'%05.2f\" %c",floor(lat_deg),floor(lat_min),lat_sec,lat_c);
- if ((lat<360)&&(lng<360))
- size_used+=g_snprintf(buffer+size_used,size-size_used," ");
- if (lng<360)
- size_used+=g_snprintf(buffer+size_used,size-size_used,"%03.0f°%02.0f'%05.2f\" %c",floor(lng_deg),floor(lng_min),lng_sec,lng_c);
- break;
-
-
- }
-
+void coord_format(float lat,float lng, enum coord_format fmt, char * buffer, int size) {
+
+ char lat_c='N';
+ char lng_c='E';
+ float lat_deg,lat_min,lat_sec;
+ float lng_deg,lng_min,lng_sec;
+ int size_used=0;
+
+ if (lng < 0) {
+ lng=-lng;
+ lng_c='W';
+ }
+ if (lat < 0) {
+ lat=-lat;
+ lat_c='S';
+ }
+ lat_deg=lat;
+ lat_min=(lat-floor(lat_deg))*60;
+ lat_sec=fmod(lat*3600,60);
+ lng_deg=lng;
+ lng_min=(lng-floor(lng_deg))*60;
+ lng_sec=fmod(lng*3600,60);
+ switch(fmt) {
+
+ case DEGREES_DECIMAL:
+ if (lat<360)
+ size_used+=g_snprintf(buffer+size_used,size-size_used,"%02.6f°%c",lat,lat_c);
+ if ((lat<360)&&(lng<360))
+ size_used+=g_snprintf(buffer+size_used,size-size_used," ");
+ if (lng<360)
+ size_used+=g_snprintf(buffer+size_used,size-size_used,"%03.7f°%c",lng,lng_c);
+ break;
+ case DEGREES_MINUTES:
+ if (lat<360)
+ size_used+=g_snprintf(buffer+size_used,size-size_used,"%02.0f°%07.4f' %c",floor(lat_deg),lat_min,lat_c);
+ if ((lat<360)&&(lng<360))
+ size_used+=g_snprintf(buffer+size_used,size-size_used," ");
+ if (lng<360)
+ size_used+=g_snprintf(buffer+size_used,size-size_used,"%03.0f°%07.4f' %c",floor(lng_deg),lng_min,lng_c);
+ break;
+ case DEGREES_MINUTES_SECONDS:
+ if (lat<360)
+ size_used+=g_snprintf(buffer+size_used,size-size_used,"%02.0f°%02.0f'%05.2f\" %c",floor(lat_deg),floor(lat_min),
+ lat_sec,lat_c);
+ if ((lat<360)&&(lng<360))
+ size_used+=g_snprintf(buffer+size_used,size-size_used," ");
+ if (lng<360)
+ size_used+=g_snprintf(buffer+size_used,size-size_used,"%03.0f°%02.0f'%05.2f\" %c",floor(lng_deg),floor(lng_min),
+ lng_sec,lng_c);
+ break;
+
+
+ }
+
}
-unsigned int
-coord_hash(const void *key)
-{
- const struct coord *c=key;
- return c->x^c->y;
+unsigned int coord_hash(const void *key) {
+ const struct coord *c=key;
+ return c->x^c->y;
}
-int
-coord_equal(const void *a, const void *b)
-{
- const struct coord *c_a=a;
- const struct coord *c_b=b;
- if (c_a->x == c_b->x && c_a->y == c_b->y)
- return TRUE;
- return FALSE;
+int coord_equal(const void *a, const void *b) {
+ const struct coord *c_a=a;
+ const struct coord *c_b=b;
+ if (c_a->x == c_b->x && c_a->y == c_b->y)
+ return TRUE;
+ return FALSE;
}
/** @} */
diff --git a/navit/coord.h b/navit/coord.h
index 8d08c0353..8387462a2 100644
--- a/navit/coord.h
+++ b/navit/coord.h
@@ -36,6 +36,18 @@ struct coord {
int y; /*!< Y-Value */
};
+/**
+ * @brief An integer mercator coordinate packed with a text label
+ *
+ * This structure holds information about an item (coordinates & label) on a map. This can be
+ * used in a list as group of points to display as search results on a map.
+ * It is used to structure input data for function navit_populate_search_results_map()
+ */
+struct lcoord {
+ struct coord c; /*!< The coordinates for this item */
+ char *label; /*!< A label to associate to this item */
+};
+
/*! A integer mercator coordinate carrying its projection */
struct pcoord {
enum projection pro;
@@ -87,7 +99,7 @@ struct coord_geo {
navit_float lat; /*!< Latitude */
};
-//! A cartesian coordinate
+//! A cartesian coordinate
struct coord_geo_cart {
navit_float x; /*!< X-Value */
navit_float y; /*!< Y-Value */
@@ -98,7 +110,7 @@ struct coord_geo_cart {
* An enumeration of formats for printing geographic coordinates in.
*
*/
-enum coord_format
+enum coord_format
{
/**
* Degrees with decimal places.
@@ -115,7 +127,7 @@ enum coord_format
* Degrees, minutes and seconds.
* ie 20 30 30.00 N 110 30 30 E
*/
- DEGREES_MINUTES_SECONDS
+ DEGREES_MINUTES_SECONDS
};
enum projection;
diff --git a/navit/country.c b/navit/country.c
index 7d13e69e7..23af61f81 100644
--- a/navit/country.c
+++ b/navit/country.c
@@ -29,410 +29,401 @@
#include "navit_nls.h"
struct country {
- int id;
- const char *car;
- const char *iso2;
- const char *iso3;
- const char *name;
+ int id;
+ const char *car;
+ const char *iso2;
+ const char *iso3;
+ const char *name;
};
-/* List of all known countries and their codes.
+/* List of all known countries and their codes.
* If you update this list, look at country_table array in maptool/osm.c also. */
static struct country country[]= {
- { 20, "AND", "AD", "AND", /* 020 */ _n("Andorra")},
- {784, "UAE", "AE", "ARE", /* 784 */ _n("United Arab Emirates")},
- { 4, "AFG", "AF", "AFG", /* 004 */ _n("Afghanistan")},
- { 28, "AG", "AG", "ATG", /* 028 */ _n("Antigua and Barbuda")},
- {660, NULL, "AI", "AIA", /* 660 */ _n("Anguilla")},
- { 8, "AL", "AL", "ALB", /* 008 */ _n("Albania")},
- { 51, "ARM", "AM", "ARM", /* 051 */ _n("Armenia")},
- {530, "NA", "AN", "ANT", /* 530 */ _n("Netherlands Antilles")},
- { 24, "ANG", "AO", "AGO", /* 024 */ _n("Angola")},
- { 10, NULL, "AQ", "ATA", /* 010 */ _n("Antarctica")},
- { 32, "RA", "AR", "ARG", /* 032 */ _n("Argentina")},
- { 16, NULL, "AS", "ASM", /* 016 */ _n("American Samoa")},
- { 40, "A", "AT", "AUT", /* 040 */ _n("Austria")},
- { 36, "AUS", "AU", "AUS", /* 036 */ _n("Australia")},
- {533, "ARU", "AW", "ABW", /* 533 */ _n("Aruba")},
- {248, "AX", "AX", "ALA", /* 248 */ _n("Aland Islands")},
- { 31, "AZ", "AZ", "AZE", /* 031 */ _n("Azerbaijan")},
- { 70, "BiH", "BA", "BIH", /* 070 */ _n("Bosnia and Herzegovina")},
- { 52, "BDS", "BB", "BRB", /* 052 */ _n("Barbados")},
- { 50, "BD", "BD", "BGD", /* 050 */ _n("Bangladesh")},
- { 56, "B", "BE", "BEL", /* 056 */ _n("Belgium")},
- {854, "BF", "BF", "BFA", /* 854 */ _n("Burkina Faso")},
- {100, "BG", "BG", "BGR", /* 100 */ _n("Bulgaria")},
- { 48, "BRN", "BH", "BHR", /* 048 */ _n("Bahrain")},
- {108, "RU", "BI", "BDI", /* 108 */ _n("Burundi")},
- {204, "BJ", "BJ", "BEN", /* 204 */ _n("Benin")},
- {652, NULL, "BL", "BLM", /* 652 */ _n("Saint Barthelemy")},
- { 60, NULL, "BM", "BMU", /* 060 */ _n("Bermuda")},
- { 96, "BRU", "BN", "BRN", /* 096 */ _n("Brunei Darussalam")},
- { 68, "BOL", "BO", "BOL", /* 068 */ _n("Bolivia")},
- {535, NULL, "BQ", "BES", /* 535 */ _n("Bonaire, Sint Eustatius and Saba")},
- { 76, "BR", "BR", "BRA", /* 076 */ _n("Brazil")},
- { 44, "BS", "BS", "BHS", /* 044 */ _n("Bahamas")},
- { 64, "BHT", "BT", "BTN", /* 064 */ _n("Bhutan")},
- { 74, NULL, "BV", "BVT", /* 074 */ _n("Bouvet Island")},
- { 72, "RB", "BW", "BWA", /* 072 */ _n("Botswana")},
- {112, "BY", "BY", "BLR", /* 112 */ _n("Belarus")},
- { 84, "BZ", "BZ", "BLZ", /* 084 */ _n("Belize")},
- {124, "CDN", "CA", "CAN", /* 124 */ _n("Canada")},
- {166, NULL, "CC", "CCK", /* 166 */ _n("Cocos (Keeling) Islands")},
- {180, "CGO", "CD", "COD", /* 180 */ _n("Congo, Democratic Republic of the")},
- {140, "RCA", "CF", "CAF", /* 140 */ _n("Central African Republic")},
- {178, NULL, "CG", "COG", /* 178 */ _n("Congo")},
- {756, "CH", "CH", "CHE", /* 756 */ _n("Switzerland")},
- {384, "CI", "CI", "CIV", /* 384 */ _n("Cote d'Ivoire")},
- {184, NULL, "CK", "COK", /* 184 */ _n("Cook Islands")},
- {152, "RCH", "CL", "CHL", /* 152 */ _n("Chile")},
- {120, "CAM", "CM", "CMR", /* 120 */ _n("Cameroon")},
- {156, "RC", "CN", "CHN", /* 156 */ _n("China")},
- {170, "CO", "CO", "COL", /* 170 */ _n("Colombia")},
- {188, "CR", "CR", "CRI", /* 188 */ _n("Costa Rica")},
- {192, "C", "CU", "CUB", /* 192 */ _n("Cuba")},
- {132, "CV", "CV", "CPV", /* 132 */ _n("Cape Verde")},
- {531, NULL, "CW", "CUW", /* 531 */ _n("Curacao")},
- {162, NULL, "CX", "CXR", /* 162 */ _n("Christmas Island")},
- {196, "CY", "CY", "CYP", /* 196 */ _n("Cyprus")},
- {203, "CZ", "CZ", "CZE", /* 203 */ _n("Czech Republic")},
- {276, "D", "DE", "DEU", /* 276 */ _n("Germany")},
- {262, "DJI", "DJ", "DJI", /* 262 */ _n("Djibouti")},
- {208, "DK", "DK", "DNK", /* 208 */ _n("Denmark")},
- {212, "WD", "DM", "DMA", /* 212 */ _n("Dominica")},
- {214, "DOM", "DO", "DOM", /* 214 */ _n("Dominican Republic")},
- { 12, "DZ", "DZ", "DZA", /* 012 */ _n("Algeria")},
- {218, "EC", "EC", "ECU", /* 218 */ _n("Ecuador")},
- {233, "EST", "EE", "EST", /* 233 */ _n("Estonia")},
- {818, "ET", "EG", "EGY", /* 818 */ _n("Egypt")},
- {732, "WSA", "EH", "ESH", /* 732 */ _n("Western Sahara")},
- {232, "ER", "ER", "ERI", /* 232 */ _n("Eritrea")},
- {724, "E", "ES", "ESP", /* 724 */ _n("Spain")},
- {231, "ETH", "ET", "ETH", /* 231 */ _n("Ethiopia")},
- {246, "FIN", "FI", "FIN", /* 246 */ _n("Finland")},
- {242, "FJI", "FJ", "FJI", /* 242 */ _n("Fiji")},
- {238, NULL, "FK", "FLK", /* 238 */ _n("Falkland Islands (Malvinas)")},
- {583, "FSM", "FM", "FSM", /* 583 */ _n("Micronesia, Federated States of")},
- {234, "FO", "FO", "FRO", /* 234 */ _n("Faroe Islands")},
- {250, "F", "FR", "FRA", /* 250 */ _n("France")},
- {266, "G", "GA", "GAB", /* 266 */ _n("Gabon")},
- {826, "GB", "GB", "GBR", /* 826 */ _n("United Kingdom")},
- {308, "WG", "GD", "GRD", /* 308 */ _n("Grenada")},
- {268, "GE", "GE", "GEO", /* 268 */ _n("Georgia")},
- {254, NULL, "GF", "GUF", /* 254 */ _n("French Guiana")},
- {831, NULL, "GG", "GGY", /* 831 */ _n("Guernsey")},
- {288, "GH", "GH", "GHA", /* 288 */ _n("Ghana")},
- {292, "GBZ", "GI", "GIB", /* 292 */ _n("Gibraltar")},
- {304, "KN", "GL", "GRL", /* 304 */ _n("Greenland")},
- {270, "WAG", "GM", "GMB", /* 270 */ _n("Gambia")},
- {324, "RG", "GN", "GIN", /* 324 */ _n("Guinea")},
- {312, NULL, "GP", "GLP", /* 312 */ _n("Guadeloupe")},
- {226, "GQ", "GQ", "GNQ", /* 226 */ _n("Equatorial Guinea")},
- {300, "GR", "GR", "GRC", /* 300 */ _n("Greece")},
- {239, NULL, "GS", "SGS", /* 239 */ _n("South Georgia and the South Sandwich Islands")},
- {320, "GCA", "GT", "GTM", /* 320 */ _n("Guatemala")},
- {316, NULL, "GU", "GUM", /* 316 */ _n("Guam")},
- {624, "GUB", "GW", "GNB", /* 624 */ _n("Guinea-Bissau")},
- {328, "GUY", "GY", "GUY", /* 328 */ _n("Guyana")},
- {344, "HK", "HK", "HKG", /* 344 */ _n("Hong Kong")},
- {334, NULL, "HM", "HMD", /* 334 */ _n("Heard Island and McDonald Islands")},
- {340, "HN", "HN", "HND", /* 340 */ _n("Honduras")},
- {191, "HR", "HR", "HRV", /* 191 */ _n("Croatia")},
- {332, "RH", "HT", "HTI", /* 332 */ _n("Haiti")},
- {348, "H", "HU", "HUN", /* 348 */ _n("Hungary")},
- {360, "RI", "ID", "IDN", /* 360 */ _n("Indonesia")},
- {372, "IRL", "IE", "IRL", /* 372 */ _n("Ireland")},
- {376, "IL", "IL", "ISR", /* 376 */ _n("Israel")},
- {833, NULL, "IM", "IMN", /* 833 */ _n("Isle of Man")},
- {356, "IND", "IN", "IND", /* 356 */ _n("India")},
- { 86, NULL, "IO", "IOT", /* 086 */ _n("British Indian Ocean Territory")},
- {368, "IRQ", "IQ", "IRQ", /* 368 */ _n("Iraq")},
- {364, "IR", "IR", "IRN", /* 364 */ _n("Iran, Islamic Republic of")},
- {352, "IS", "IS", "ISL", /* 352 */ _n("Iceland")},
- {380, "I", "IT", "ITA", /* 380 */ _n("Italy")},
- {832, NULL, "JE", "JEY", /* 832 */ _n("Jersey")},
- {388, "JA", "JM", "JAM", /* 388 */ _n("Jamaica")},
- {400, "JOR", "JO", "JOR", /* 400 */ _n("Jordan")},
- {392, "J", "JP", "JPN", /* 392 */ _n("Japan")},
- {404, "EAK", "KE", "KEN", /* 404 */ _n("Kenya")},
- {417, "KS", "KG", "KGZ", /* 417 */ _n("Kyrgyzstan")},
- {116, "K", "KH", "KHM", /* 116 */ _n("Cambodia")},
- {296, "KIR", "KI", "KIR", /* 296 */ _n("Kiribati")},
- {174, "COM", "KM", "COM", /* 174 */ _n("Comoros")},
- {659, "KAN", "KN", "KNA", /* 659 */ _n("Saint Kitts and Nevis")},
- {408, "KP", "KP", "PRK", /* 408 */ _n("Korea, Democratic People's Republic of")},
- {410, "ROK", "KR", "KOR", /* 410 */ _n("Korea, Republic of")},
- {414, "KWT", "KW", "KWT", /* 414 */ _n("Kuwait")},
- {136, NULL, "KY", "CYM", /* 136 */ _n("Cayman Islands")},
- {398, "KZ", "KZ", "KAZ", /* 398 */ _n("Kazakhstan")},
- {418, "LAO", "LA", "LAO", /* 418 */ _n("Lao People's Democratic Republic")},
- {422, "RL", "LB", "LBN", /* 422 */ _n("Lebanon")},
- {662, "WL", "LC", "LCA", /* 662 */ _n("Saint Lucia")},
- {438, "FL", "LI", "LIE", /* 438 */ _n("Liechtenstein")},
- {144, "CL", "LK", "LKA", /* 144 */ _n("Sri Lanka")},
- {430, "LB", "LR", "LBR", /* 430 */ _n("Liberia")},
- {426, "LS", "LS", "LSO", /* 426 */ _n("Lesotho")},
- {440, "LT", "LT", "LTU", /* 440 */ _n("Lithuania")},
- {442, "L", "LU", "LUX", /* 442 */ _n("Luxembourg")},
- {428, "LV", "LV", "LVA", /* 428 */ _n("Latvia")},
- {434, "LAR", "LY", "LBY", /* 434 */ _n("Libya")},
- {504, "MA", "MA", "MAR", /* 504 */ _n("Morocco")},
- {492, "MC", "MC", "MCO", /* 492 */ _n("Monaco")},
- {498, "MD", "MD", "MDA", /* 498 */ _n("Moldova, Republic of")},
- {499, "MNE", "ME", "MNE", /* 499 */ _n("Montenegro")},
- {663, NULL, "MF", "MAF", /* 663 */ _n("Saint Martin (French part)")},
- {450, "RM", "MG", "MDG", /* 450 */ _n("Madagascar")},
- {584, "MH", "MH", "MHL", /* 584 */ _n("Marshall Islands")},
- {807, "MK", "MK", "MKD", /* 807 */ _n("Macedonia, the former Yugoslav Republic of")},
- {466, "RMM", "ML", "MLI", /* 466 */ _n("Mali")},
- {104, "MYA", "MM", "MMR", /* 104 */ _n("Myanmar")},
- {496, "MGL", "MN", "MNG", /* 496 */ _n("Mongolia")},
- {446, NULL, "MO", "MAC", /* 446 */ _n("Macao")},
- {580, NULL, "MP", "MNP", /* 580 */ _n("Northern Mariana Islands")},
- {474, NULL, "MQ", "MTQ", /* 474 */ _n("Martinique")},
- {478, "RIM", "MR", "MRT", /* 478 */ _n("Mauritania")},
- {500, NULL, "MS", "MSR", /* 500 */ _n("Montserrat")},
- {470, "M", "MT", "MLT", /* 470 */ _n("Malta")},
- {480, "MS", "MU", "MUS", /* 480 */ _n("Mauritius")},
- {462, "MV", "MV", "MDV", /* 462 */ _n("Maldives")},
- {454, "MW", "MW", "MWI", /* 454 */ _n("Malawi")},
- {484, "MEX", "MX", "MEX", /* 484 */ _n("Mexico")},
- {458, "MAL", "MY", "MYS", /* 458 */ _n("Malaysia")},
- {508, "MOC", "MZ", "MOZ", /* 508 */ _n("Mozambique")},
- {516, "NAM", "NA", "NAM", /* 516 */ _n("Namibia")},
- {540, "NCL", "NC", "NCL", /* 540 */ _n("New Caledonia")},
- {562, "RN", "NE", "NER", /* 562 */ _n("Niger")},
- {574, NULL, "NF", "NFK", /* 574 */ _n("Norfolk Island")},
- {566, "NGR", "NG", "NGA", /* 566 */ _n("Nigeria")},
- {558, "NIC", "NI", "NIC", /* 558 */ _n("Nicaragua")},
- {528, "NL", "NL", "NLD", /* 528 */ _n("Netherlands")},
- {578, "N", "NO", "NOR", /* 578 */ _n("Norway")},
- {524, "NEP", "NP", "NPL", /* 524 */ _n("Nepal")},
- {520, "NAU", "NR", "NRU", /* 520 */ _n("Nauru")},
- {570, NULL, "NU", "NIU", /* 570 */ _n("Niue")},
- {554, "NZ", "NZ", "NZL", /* 554 */ _n("New Zealand")},
- {512, "OM", "OM", "OMN", /* 512 */ _n("Oman")},
- {591, "PA", "PA", "PAN", /* 591 */ _n("Panama")},
- {604, "PE", "PE", "PER", /* 604 */ _n("Peru")},
- {258, NULL, "PF", "PYF", /* 258 */ _n("French Polynesia")},
- {598, "PNG", "PG", "PNG", /* 598 */ _n("Papua New Guinea")},
- {608, "RP", "PH", "PHL", /* 608 */ _n("Philippines")},
- {586, "PK", "PK", "PAK", /* 586 */ _n("Pakistan")},
- {616, "PL", "PL", "POL", /* 616 */ _n("Poland")},
- {666, NULL, "PM", "SPM", /* 666 */ _n("Saint Pierre and Miquelon")},
- {612, NULL, "PN", "PCN", /* 612 */ _n("Pitcairn")},
- {630, "PRI", "PR", "PRI", /* 630 */ _n("Puerto Rico")},
- {275, "AUT", "PS", "PSE", /* 275 */ _n("Palestinian Territory, Occupied")},
- {620, "P", "PT", "PRT", /* 620 */ _n("Portugal")},
- {585, "PAL", "PW", "PLW", /* 585 */ _n("Palau")},
- {600, "PY", "PY", "PRY", /* 600 */ _n("Paraguay")},
- {634, "Q", "QA", "QAT", /* 634 */ _n("Qatar")},
- {638, NULL, "RE", "REU", /* 638 */ _n("Reunion")},
- {642, "RO", "RO", "ROU", /* 642 */ _n("Romania")},
- {688, "SRB", "RS", "SRB", /* 688 */ _n("Serbia")},
- {643, "RUS", "RU", "RUS", /* 643 */ _n("Russian Federation")},
- {646, "RWA", "RW", "RWA", /* 646 */ _n("Rwanda")},
- {682, "KSA", "SA", "SAU", /* 682 */ _n("Saudi Arabia")},
- { 90, "SOL", "SB", "SLB", /* 090 */ _n("Solomon Islands")},
- {690, "SY", "SC", "SYC", /* 690 */ _n("Seychelles")},
- {736, "SUD", "SD", "SDN", /* 736 */ _n("Sudan")},
- {752, "S", "SE", "SWE", /* 752 */ _n("Sweden")},
- {702, "SGP", "SG", "SGP", /* 702 */ _n("Singapore")},
- {654, NULL, "SH", "SHN", /* 654 */ _n("Saint Helena")},
- {705, "SLO", "SI", "SVN", /* 705 */ _n("Slovenia")},
- {744, NULL, "SJ", "SJM", /* 744 */ _n("Svalbard and Jan Mayen")},
- {703, "SK", "SK", "SVK", /* 703 */ _n("Slovakia")},
- {694, "WAL", "SL", "SLE", /* 694 */ _n("Sierra Leone")},
- {674, "RSM", "SM", "SMR", /* 674 */ _n("San Marino")},
- {686, "SN", "SN", "SEN", /* 686 */ _n("Senegal")},
- {706, "SO", "SO", "SOM", /* 706 */ _n("Somalia")},
- {740, "SME", "SR", "SUR", /* 740 */ _n("Suriname")},
- {728, NULL, "SS", "SSD", /* 728 */ _n("South Sudan")},
- {678, "STP", "ST", "STP", /* 678 */ _n("Sao Tome and Principe")},
- {222, "ES", "SV", "SLV", /* 222 */ _n("El Salvador")},
- {534, NULL, "SX", "SXM", /* 534 */ _n("Sint Maarten (Dutch part)")},
- {760, "SYR", "SY", "SYR", /* 760 */ _n("Syrian Arab Republic")},
- {748, "SD", "SZ", "SWZ", /* 748 */ _n("Swaziland")},
- {796, NULL, "TC", "TCA", /* 796 */ _n("Turks and Caicos Islands")},
- {148, "TD", "TD", "TCD", /* 148 */ _n("Chad")},
- {260, "ARK", "TF", "ATF", /* 260 */ _n("French Southern Territories")},
- {768, "RT", "TG", "TGO", /* 768 */ _n("Togo")},
- {764, "T", "TH", "THA", /* 764 */ _n("Thailand")},
- {762, "TJ", "TJ", "TJK", /* 762 */ _n("Tajikistan")},
- {772, NULL, "TK", "TKL", /* 772 */ _n("Tokelau")},
- {626, "TL", "TL", "TLS", /* 626 */ _n("Timor-Leste")},
- {795, "TM", "TM", "TKM", /* 795 */ _n("Turkmenistan")},
- {788, "TN", "TN", "TUN", /* 788 */ _n("Tunisia")},
- {776, "TON", "TO", "TON", /* 776 */ _n("Tonga")},
- {792, "TR", "TR", "TUR", /* 792 */ _n("Turkey")},
- {780, "TT", "TT", "TTO", /* 780 */ _n("Trinidad and Tobago")},
- {798, "TUV", "TV", "TUV", /* 798 */ _n("Tuvalu")},
- {158, NULL, "TW", "TWN", /* 158 */ _n("Taiwan, Province of China")},
- {834, "EAT", "TZ", "TZA", /* 834 */ _n("Tanzania, United Republic of")},
- {804, "UA", "UA", "UKR", /* 804 */ _n("Ukraine")},
- {800, "EAU", "UG", "UGA", /* 800 */ _n("Uganda")},
- {581, NULL, "UM", "UMI", /* 581 */ _n("United States Minor Outlying Islands")},
- {840, "USA", "US", "USA", /* 840 */ _n("United States")},
- {858, "ROU", "UY", "URY", /* 858 */ _n("Uruguay")},
- {860, "UZ", "UZ", "UZB", /* 860 */ _n("Uzbekistan")},
- {336, "SCV", "VA", "VAT", /* 336 */ _n("Holy See (Vatican City State)")},
- {670, "WV", "VC", "VCT", /* 670 */ _n("Saint Vincent and the Grenadines")},
- {862, "YV", "VE", "VEN", /* 862 */ _n("Venezuela")},
- { 92, NULL, "VG", "VGB", /* 092 */ _n("Virgin Islands, British")},
- {850, NULL, "VI", "VIR", /* 850 */ _n("Virgin Islands, U.S.")},
- {704, "VN", "VN", "VNM", /* 704 */ _n("Viet Nam")},
- {548, "VAN", "VU", "VUT", /* 548 */ _n("Vanuatu")},
- {876, NULL, "WF", "WLF", /* 876 */ _n("Wallis and Futuna")},
- {882, "WS", "WS", "WSM", /* 882 */ _n("Samoa")},
- {887, "YAR", "YE", "YEM", /* 887 */ _n("Yemen")},
- {175, NULL, "YT", "MYT", /* 175 */ _n("Mayotte")},
- {710, "ZA", "ZA", "ZAF", /* 710 */ _n("South Africa") },
- {894, "Z", "ZM", "ZMB", /* 894 */ _n("Zambia")},
- {716, "ZW", "ZW", "ZWE", /* 716 */ _n("Zimbabwe")},
- {999, "*", "*", "*", _n("* Unknown, add is_in tags to those cities")},
+ { 20, "AND", "AD", "AND", /* 020 */ _n("Andorra")},
+ {784, "UAE", "AE", "ARE", /* 784 */ _n("United Arab Emirates")},
+ { 4, "AFG", "AF", "AFG", /* 004 */ _n("Afghanistan")},
+ { 28, "AG", "AG", "ATG", /* 028 */ _n("Antigua and Barbuda")},
+ {660, NULL, "AI", "AIA", /* 660 */ _n("Anguilla")},
+ { 8, "AL", "AL", "ALB", /* 008 */ _n("Albania")},
+ { 51, "ARM", "AM", "ARM", /* 051 */ _n("Armenia")},
+ {530, "NA", "AN", "ANT", /* 530 */ _n("Netherlands Antilles")},
+ { 24, "ANG", "AO", "AGO", /* 024 */ _n("Angola")},
+ { 10, NULL, "AQ", "ATA", /* 010 */ _n("Antarctica")},
+ { 32, "RA", "AR", "ARG", /* 032 */ _n("Argentina")},
+ { 16, NULL, "AS", "ASM", /* 016 */ _n("American Samoa")},
+ { 40, "A", "AT", "AUT", /* 040 */ _n("Austria")},
+ { 36, "AUS", "AU", "AUS", /* 036 */ _n("Australia")},
+ {533, "ARU", "AW", "ABW", /* 533 */ _n("Aruba")},
+ {248, "AX", "AX", "ALA", /* 248 */ _n("Aland Islands")},
+ { 31, "AZ", "AZ", "AZE", /* 031 */ _n("Azerbaijan")},
+ { 70, "BiH", "BA", "BIH", /* 070 */ _n("Bosnia and Herzegovina")},
+ { 52, "BDS", "BB", "BRB", /* 052 */ _n("Barbados")},
+ { 50, "BD", "BD", "BGD", /* 050 */ _n("Bangladesh")},
+ { 56, "B", "BE", "BEL", /* 056 */ _n("Belgium")},
+ {854, "BF", "BF", "BFA", /* 854 */ _n("Burkina Faso")},
+ {100, "BG", "BG", "BGR", /* 100 */ _n("Bulgaria")},
+ { 48, "BRN", "BH", "BHR", /* 048 */ _n("Bahrain")},
+ {108, "RU", "BI", "BDI", /* 108 */ _n("Burundi")},
+ {204, "BJ", "BJ", "BEN", /* 204 */ _n("Benin")},
+ {652, NULL, "BL", "BLM", /* 652 */ _n("Saint Barthelemy")},
+ { 60, NULL, "BM", "BMU", /* 060 */ _n("Bermuda")},
+ { 96, "BRU", "BN", "BRN", /* 096 */ _n("Brunei Darussalam")},
+ { 68, "BOL", "BO", "BOL", /* 068 */ _n("Bolivia")},
+ {535, NULL, "BQ", "BES", /* 535 */ _n("Bonaire, Sint Eustatius and Saba")},
+ { 76, "BR", "BR", "BRA", /* 076 */ _n("Brazil")},
+ { 44, "BS", "BS", "BHS", /* 044 */ _n("Bahamas")},
+ { 64, "BHT", "BT", "BTN", /* 064 */ _n("Bhutan")},
+ { 74, NULL, "BV", "BVT", /* 074 */ _n("Bouvet Island")},
+ { 72, "RB", "BW", "BWA", /* 072 */ _n("Botswana")},
+ {112, "BY", "BY", "BLR", /* 112 */ _n("Belarus")},
+ { 84, "BZ", "BZ", "BLZ", /* 084 */ _n("Belize")},
+ {124, "CDN", "CA", "CAN", /* 124 */ _n("Canada")},
+ {166, NULL, "CC", "CCK", /* 166 */ _n("Cocos (Keeling) Islands")},
+ {180, "CGO", "CD", "COD", /* 180 */ _n("Congo, Democratic Republic of the")},
+ {140, "RCA", "CF", "CAF", /* 140 */ _n("Central African Republic")},
+ {178, NULL, "CG", "COG", /* 178 */ _n("Congo")},
+ {756, "CH", "CH", "CHE", /* 756 */ _n("Switzerland")},
+ {384, "CI", "CI", "CIV", /* 384 */ _n("Cote d'Ivoire")},
+ {184, NULL, "CK", "COK", /* 184 */ _n("Cook Islands")},
+ {152, "RCH", "CL", "CHL", /* 152 */ _n("Chile")},
+ {120, "CAM", "CM", "CMR", /* 120 */ _n("Cameroon")},
+ {156, "RC", "CN", "CHN", /* 156 */ _n("China")},
+ {170, "CO", "CO", "COL", /* 170 */ _n("Colombia")},
+ {188, "CR", "CR", "CRI", /* 188 */ _n("Costa Rica")},
+ {192, "C", "CU", "CUB", /* 192 */ _n("Cuba")},
+ {132, "CV", "CV", "CPV", /* 132 */ _n("Cape Verde")},
+ {531, NULL, "CW", "CUW", /* 531 */ _n("Curacao")},
+ {162, NULL, "CX", "CXR", /* 162 */ _n("Christmas Island")},
+ {196, "CY", "CY", "CYP", /* 196 */ _n("Cyprus")},
+ {203, "CZ", "CZ", "CZE", /* 203 */ _n("Czech Republic")},
+ {276, "D", "DE", "DEU", /* 276 */ _n("Germany")},
+ {262, "DJI", "DJ", "DJI", /* 262 */ _n("Djibouti")},
+ {208, "DK", "DK", "DNK", /* 208 */ _n("Denmark")},
+ {212, "WD", "DM", "DMA", /* 212 */ _n("Dominica")},
+ {214, "DOM", "DO", "DOM", /* 214 */ _n("Dominican Republic")},
+ { 12, "DZ", "DZ", "DZA", /* 012 */ _n("Algeria")},
+ {218, "EC", "EC", "ECU", /* 218 */ _n("Ecuador")},
+ {233, "EST", "EE", "EST", /* 233 */ _n("Estonia")},
+ {818, "ET", "EG", "EGY", /* 818 */ _n("Egypt")},
+ {732, "WSA", "EH", "ESH", /* 732 */ _n("Western Sahara")},
+ {232, "ER", "ER", "ERI", /* 232 */ _n("Eritrea")},
+ {724, "E", "ES", "ESP", /* 724 */ _n("Spain")},
+ {231, "ETH", "ET", "ETH", /* 231 */ _n("Ethiopia")},
+ {246, "FIN", "FI", "FIN", /* 246 */ _n("Finland")},
+ {242, "FJI", "FJ", "FJI", /* 242 */ _n("Fiji")},
+ {238, NULL, "FK", "FLK", /* 238 */ _n("Falkland Islands (Malvinas)")},
+ {583, "FSM", "FM", "FSM", /* 583 */ _n("Micronesia, Federated States of")},
+ {234, "FO", "FO", "FRO", /* 234 */ _n("Faroe Islands")},
+ {250, "F", "FR", "FRA", /* 250 */ _n("France")},
+ {266, "G", "GA", "GAB", /* 266 */ _n("Gabon")},
+ {826, "GB", "GB", "GBR", /* 826 */ _n("United Kingdom")},
+ {308, "WG", "GD", "GRD", /* 308 */ _n("Grenada")},
+ {268, "GE", "GE", "GEO", /* 268 */ _n("Georgia")},
+ {254, NULL, "GF", "GUF", /* 254 */ _n("French Guiana")},
+ {831, NULL, "GG", "GGY", /* 831 */ _n("Guernsey")},
+ {288, "GH", "GH", "GHA", /* 288 */ _n("Ghana")},
+ {292, "GBZ", "GI", "GIB", /* 292 */ _n("Gibraltar")},
+ {304, "KN", "GL", "GRL", /* 304 */ _n("Greenland")},
+ {270, "WAG", "GM", "GMB", /* 270 */ _n("Gambia")},
+ {324, "RG", "GN", "GIN", /* 324 */ _n("Guinea")},
+ {312, NULL, "GP", "GLP", /* 312 */ _n("Guadeloupe")},
+ {226, "GQ", "GQ", "GNQ", /* 226 */ _n("Equatorial Guinea")},
+ {300, "GR", "GR", "GRC", /* 300 */ _n("Greece")},
+ {239, NULL, "GS", "SGS", /* 239 */ _n("South Georgia and the South Sandwich Islands")},
+ {320, "GCA", "GT", "GTM", /* 320 */ _n("Guatemala")},
+ {316, NULL, "GU", "GUM", /* 316 */ _n("Guam")},
+ {624, "GUB", "GW", "GNB", /* 624 */ _n("Guinea-Bissau")},
+ {328, "GUY", "GY", "GUY", /* 328 */ _n("Guyana")},
+ {344, "HK", "HK", "HKG", /* 344 */ _n("Hong Kong")},
+ {334, NULL, "HM", "HMD", /* 334 */ _n("Heard Island and McDonald Islands")},
+ {340, "HN", "HN", "HND", /* 340 */ _n("Honduras")},
+ {191, "HR", "HR", "HRV", /* 191 */ _n("Croatia")},
+ {332, "RH", "HT", "HTI", /* 332 */ _n("Haiti")},
+ {348, "H", "HU", "HUN", /* 348 */ _n("Hungary")},
+ {360, "RI", "ID", "IDN", /* 360 */ _n("Indonesia")},
+ {372, "IRL", "IE", "IRL", /* 372 */ _n("Ireland")},
+ {376, "IL", "IL", "ISR", /* 376 */ _n("Israel")},
+ {833, NULL, "IM", "IMN", /* 833 */ _n("Isle of Man")},
+ {356, "IND", "IN", "IND", /* 356 */ _n("India")},
+ { 86, NULL, "IO", "IOT", /* 086 */ _n("British Indian Ocean Territory")},
+ {368, "IRQ", "IQ", "IRQ", /* 368 */ _n("Iraq")},
+ {364, "IR", "IR", "IRN", /* 364 */ _n("Iran, Islamic Republic of")},
+ {352, "IS", "IS", "ISL", /* 352 */ _n("Iceland")},
+ {380, "I", "IT", "ITA", /* 380 */ _n("Italy")},
+ {832, NULL, "JE", "JEY", /* 832 */ _n("Jersey")},
+ {388, "JA", "JM", "JAM", /* 388 */ _n("Jamaica")},
+ {400, "JOR", "JO", "JOR", /* 400 */ _n("Jordan")},
+ {392, "J", "JP", "JPN", /* 392 */ _n("Japan")},
+ {404, "EAK", "KE", "KEN", /* 404 */ _n("Kenya")},
+ {417, "KS", "KG", "KGZ", /* 417 */ _n("Kyrgyzstan")},
+ {116, "K", "KH", "KHM", /* 116 */ _n("Cambodia")},
+ {296, "KIR", "KI", "KIR", /* 296 */ _n("Kiribati")},
+ {174, "COM", "KM", "COM", /* 174 */ _n("Comoros")},
+ {659, "KAN", "KN", "KNA", /* 659 */ _n("Saint Kitts and Nevis")},
+ {408, "KP", "KP", "PRK", /* 408 */ _n("Korea, Democratic People's Republic of")},
+ {410, "ROK", "KR", "KOR", /* 410 */ _n("Korea, Republic of")},
+ {414, "KWT", "KW", "KWT", /* 414 */ _n("Kuwait")},
+ {136, NULL, "KY", "CYM", /* 136 */ _n("Cayman Islands")},
+ {398, "KZ", "KZ", "KAZ", /* 398 */ _n("Kazakhstan")},
+ {418, "LAO", "LA", "LAO", /* 418 */ _n("Lao People's Democratic Republic")},
+ {422, "RL", "LB", "LBN", /* 422 */ _n("Lebanon")},
+ {662, "WL", "LC", "LCA", /* 662 */ _n("Saint Lucia")},
+ {438, "FL", "LI", "LIE", /* 438 */ _n("Liechtenstein")},
+ {144, "CL", "LK", "LKA", /* 144 */ _n("Sri Lanka")},
+ {430, "LB", "LR", "LBR", /* 430 */ _n("Liberia")},
+ {426, "LS", "LS", "LSO", /* 426 */ _n("Lesotho")},
+ {440, "LT", "LT", "LTU", /* 440 */ _n("Lithuania")},
+ {442, "L", "LU", "LUX", /* 442 */ _n("Luxembourg")},
+ {428, "LV", "LV", "LVA", /* 428 */ _n("Latvia")},
+ {434, "LAR", "LY", "LBY", /* 434 */ _n("Libya")},
+ {504, "MA", "MA", "MAR", /* 504 */ _n("Morocco")},
+ {492, "MC", "MC", "MCO", /* 492 */ _n("Monaco")},
+ {498, "MD", "MD", "MDA", /* 498 */ _n("Moldova, Republic of")},
+ {499, "MNE", "ME", "MNE", /* 499 */ _n("Montenegro")},
+ {663, NULL, "MF", "MAF", /* 663 */ _n("Saint Martin (French part)")},
+ {450, "RM", "MG", "MDG", /* 450 */ _n("Madagascar")},
+ {584, "MH", "MH", "MHL", /* 584 */ _n("Marshall Islands")},
+ {807, "MK", "MK", "MKD", /* 807 */ _n("Macedonia, the former Yugoslav Republic of")},
+ {466, "RMM", "ML", "MLI", /* 466 */ _n("Mali")},
+ {104, "MYA", "MM", "MMR", /* 104 */ _n("Myanmar")},
+ {496, "MGL", "MN", "MNG", /* 496 */ _n("Mongolia")},
+ {446, NULL, "MO", "MAC", /* 446 */ _n("Macao")},
+ {580, NULL, "MP", "MNP", /* 580 */ _n("Northern Mariana Islands")},
+ {474, NULL, "MQ", "MTQ", /* 474 */ _n("Martinique")},
+ {478, "RIM", "MR", "MRT", /* 478 */ _n("Mauritania")},
+ {500, NULL, "MS", "MSR", /* 500 */ _n("Montserrat")},
+ {470, "M", "MT", "MLT", /* 470 */ _n("Malta")},
+ {480, "MS", "MU", "MUS", /* 480 */ _n("Mauritius")},
+ {462, "MV", "MV", "MDV", /* 462 */ _n("Maldives")},
+ {454, "MW", "MW", "MWI", /* 454 */ _n("Malawi")},
+ {484, "MEX", "MX", "MEX", /* 484 */ _n("Mexico")},
+ {458, "MAL", "MY", "MYS", /* 458 */ _n("Malaysia")},
+ {508, "MOC", "MZ", "MOZ", /* 508 */ _n("Mozambique")},
+ {516, "NAM", "NA", "NAM", /* 516 */ _n("Namibia")},
+ {540, "NCL", "NC", "NCL", /* 540 */ _n("New Caledonia")},
+ {562, "RN", "NE", "NER", /* 562 */ _n("Niger")},
+ {574, NULL, "NF", "NFK", /* 574 */ _n("Norfolk Island")},
+ {566, "NGR", "NG", "NGA", /* 566 */ _n("Nigeria")},
+ {558, "NIC", "NI", "NIC", /* 558 */ _n("Nicaragua")},
+ {528, "NL", "NL", "NLD", /* 528 */ _n("Netherlands")},
+ {578, "N", "NO", "NOR", /* 578 */ _n("Norway")},
+ {524, "NEP", "NP", "NPL", /* 524 */ _n("Nepal")},
+ {520, "NAU", "NR", "NRU", /* 520 */ _n("Nauru")},
+ {570, NULL, "NU", "NIU", /* 570 */ _n("Niue")},
+ {554, "NZ", "NZ", "NZL", /* 554 */ _n("New Zealand")},
+ {512, "OM", "OM", "OMN", /* 512 */ _n("Oman")},
+ {591, "PA", "PA", "PAN", /* 591 */ _n("Panama")},
+ {604, "PE", "PE", "PER", /* 604 */ _n("Peru")},
+ {258, NULL, "PF", "PYF", /* 258 */ _n("French Polynesia")},
+ {598, "PNG", "PG", "PNG", /* 598 */ _n("Papua New Guinea")},
+ {608, "RP", "PH", "PHL", /* 608 */ _n("Philippines")},
+ {586, "PK", "PK", "PAK", /* 586 */ _n("Pakistan")},
+ {616, "PL", "PL", "POL", /* 616 */ _n("Poland")},
+ {666, NULL, "PM", "SPM", /* 666 */ _n("Saint Pierre and Miquelon")},
+ {612, NULL, "PN", "PCN", /* 612 */ _n("Pitcairn")},
+ {630, "PRI", "PR", "PRI", /* 630 */ _n("Puerto Rico")},
+ {275, "AUT", "PS", "PSE", /* 275 */ _n("Palestinian Territory, Occupied")},
+ {620, "P", "PT", "PRT", /* 620 */ _n("Portugal")},
+ {585, "PAL", "PW", "PLW", /* 585 */ _n("Palau")},
+ {600, "PY", "PY", "PRY", /* 600 */ _n("Paraguay")},
+ {634, "Q", "QA", "QAT", /* 634 */ _n("Qatar")},
+ {638, NULL, "RE", "REU", /* 638 */ _n("Reunion")},
+ {642, "RO", "RO", "ROU", /* 642 */ _n("Romania")},
+ {688, "SRB", "RS", "SRB", /* 688 */ _n("Serbia")},
+ {643, "RUS", "RU", "RUS", /* 643 */ _n("Russian Federation")},
+ {646, "RWA", "RW", "RWA", /* 646 */ _n("Rwanda")},
+ {682, "KSA", "SA", "SAU", /* 682 */ _n("Saudi Arabia")},
+ { 90, "SOL", "SB", "SLB", /* 090 */ _n("Solomon Islands")},
+ {690, "SY", "SC", "SYC", /* 690 */ _n("Seychelles")},
+ {736, "SUD", "SD", "SDN", /* 736 */ _n("Sudan")},
+ {752, "S", "SE", "SWE", /* 752 */ _n("Sweden")},
+ {702, "SGP", "SG", "SGP", /* 702 */ _n("Singapore")},
+ {654, NULL, "SH", "SHN", /* 654 */ _n("Saint Helena")},
+ {705, "SLO", "SI", "SVN", /* 705 */ _n("Slovenia")},
+ {744, NULL, "SJ", "SJM", /* 744 */ _n("Svalbard and Jan Mayen")},
+ {703, "SK", "SK", "SVK", /* 703 */ _n("Slovakia")},
+ {694, "WAL", "SL", "SLE", /* 694 */ _n("Sierra Leone")},
+ {674, "RSM", "SM", "SMR", /* 674 */ _n("San Marino")},
+ {686, "SN", "SN", "SEN", /* 686 */ _n("Senegal")},
+ {706, "SO", "SO", "SOM", /* 706 */ _n("Somalia")},
+ {740, "SME", "SR", "SUR", /* 740 */ _n("Suriname")},
+ {728, NULL, "SS", "SSD", /* 728 */ _n("South Sudan")},
+ {678, "STP", "ST", "STP", /* 678 */ _n("Sao Tome and Principe")},
+ {222, "ES", "SV", "SLV", /* 222 */ _n("El Salvador")},
+ {534, NULL, "SX", "SXM", /* 534 */ _n("Sint Maarten (Dutch part)")},
+ {760, "SYR", "SY", "SYR", /* 760 */ _n("Syrian Arab Republic")},
+ {748, "SD", "SZ", "SWZ", /* 748 */ _n("Swaziland")},
+ {796, NULL, "TC", "TCA", /* 796 */ _n("Turks and Caicos Islands")},
+ {148, "TD", "TD", "TCD", /* 148 */ _n("Chad")},
+ {260, "ARK", "TF", "ATF", /* 260 */ _n("French Southern Territories")},
+ {768, "RT", "TG", "TGO", /* 768 */ _n("Togo")},
+ {764, "T", "TH", "THA", /* 764 */ _n("Thailand")},
+ {762, "TJ", "TJ", "TJK", /* 762 */ _n("Tajikistan")},
+ {772, NULL, "TK", "TKL", /* 772 */ _n("Tokelau")},
+ {626, "TL", "TL", "TLS", /* 626 */ _n("Timor-Leste")},
+ {795, "TM", "TM", "TKM", /* 795 */ _n("Turkmenistan")},
+ {788, "TN", "TN", "TUN", /* 788 */ _n("Tunisia")},
+ {776, "TON", "TO", "TON", /* 776 */ _n("Tonga")},
+ {792, "TR", "TR", "TUR", /* 792 */ _n("Turkey")},
+ {780, "TT", "TT", "TTO", /* 780 */ _n("Trinidad and Tobago")},
+ {798, "TUV", "TV", "TUV", /* 798 */ _n("Tuvalu")},
+ {158, NULL, "TW", "TWN", /* 158 */ _n("Taiwan, Province of China")},
+ {834, "EAT", "TZ", "TZA", /* 834 */ _n("Tanzania, United Republic of")},
+ {804, "UA", "UA", "UKR", /* 804 */ _n("Ukraine")},
+ {800, "EAU", "UG", "UGA", /* 800 */ _n("Uganda")},
+ {581, NULL, "UM", "UMI", /* 581 */ _n("United States Minor Outlying Islands")},
+ {840, "USA", "US", "USA", /* 840 */ _n("United States")},
+ {858, "ROU", "UY", "URY", /* 858 */ _n("Uruguay")},
+ {860, "UZ", "UZ", "UZB", /* 860 */ _n("Uzbekistan")},
+ {336, "SCV", "VA", "VAT", /* 336 */ _n("Holy See (Vatican City State)")},
+ {670, "WV", "VC", "VCT", /* 670 */ _n("Saint Vincent and the Grenadines")},
+ {862, "YV", "VE", "VEN", /* 862 */ _n("Venezuela")},
+ { 92, NULL, "VG", "VGB", /* 092 */ _n("Virgin Islands, British")},
+ {850, NULL, "VI", "VIR", /* 850 */ _n("Virgin Islands, U.S.")},
+ {704, "VN", "VN", "VNM", /* 704 */ _n("Viet Nam")},
+ {548, "VAN", "VU", "VUT", /* 548 */ _n("Vanuatu")},
+ {876, NULL, "WF", "WLF", /* 876 */ _n("Wallis and Futuna")},
+ {882, "WS", "WS", "WSM", /* 882 */ _n("Samoa")},
+ {887, "YAR", "YE", "YEM", /* 887 */ _n("Yemen")},
+ {175, NULL, "YT", "MYT", /* 175 */ _n("Mayotte")},
+ {710, "ZA", "ZA", "ZAF", /* 710 */ _n("South Africa") },
+ {894, "Z", "ZM", "ZMB", /* 894 */ _n("Zambia")},
+ {716, "ZW", "ZW", "ZWE", /* 716 */ _n("Zimbabwe")},
+ {999, "*", "*", "*", _n("* Unknown, add is_in tags to those cities")},
};
struct country_search {
- struct attr search;
- int len;
- int partial;
- struct item item;
- int count;
- struct country *country;
- enum attr_type attr_next;
+ struct attr search;
+ int len;
+ int partial;
+ struct item item;
+ int count;
+ struct country *country;
+ enum attr_type attr_next;
};
-static int
-country_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct country_search *this_=priv_data;
- struct country *country=this_->country;
+static int country_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct country_search *this_=priv_data;
+ struct country *country=this_->country;
- attr->type=attr_type;
- switch (attr_type) {
- case attr_any:
- while (this_->attr_next != attr_none) {
- if (country_attr_get(this_, this_->attr_next, attr))
- return 1;
- }
- return 0;
- // Cast to char* necessary but safe, because our callers know
- // not to modify attr->u.str (hopefully).
- case attr_label:
- attr->u.str=(char*)navit_nls_gettext(country->name);
- this_->attr_next=attr_country_id;
- return 1;
- case attr_country_id:
- attr->u.num=country->id;
- this_->attr_next=country->car ? attr_country_car : attr_country_iso2;
- return 1;
- case attr_country_car:
- attr->u.str=(char*)country->car;
- this_->attr_next=attr_country_iso2;
- return attr->u.str ? 1 : 0;
- case attr_country_iso2:
- attr->u.str=(char*)country->iso2;
- this_->attr_next=attr_country_iso3;
- return 1;
- case attr_country_iso3:
- attr->u.str=(char*)country->iso3;
- this_->attr_next=attr_country_name;
- return 1;
- case attr_country_name:
- attr->u.str=(char*)navit_nls_gettext(country->name);
- this_->attr_next=attr_none;
- return 1;
- default:
- return 0;
- }
+ attr->type=attr_type;
+ switch (attr_type) {
+ case attr_any:
+ while (this_->attr_next != attr_none) {
+ if (country_attr_get(this_, this_->attr_next, attr))
+ return 1;
+ }
+ return 0;
+ // Cast to char* necessary but safe, because our callers know
+ // not to modify attr->u.str (hopefully).
+ case attr_label:
+ attr->u.str=(char*)navit_nls_gettext(country->name);
+ this_->attr_next=attr_country_id;
+ return 1;
+ case attr_country_id:
+ attr->u.num=country->id;
+ this_->attr_next=country->car ? attr_country_car : attr_country_iso2;
+ return 1;
+ case attr_country_car:
+ attr->u.str=(char*)country->car;
+ this_->attr_next=attr_country_iso2;
+ return attr->u.str ? 1 : 0;
+ case attr_country_iso2:
+ attr->u.str=(char*)country->iso2;
+ this_->attr_next=attr_country_iso3;
+ return 1;
+ case attr_country_iso3:
+ attr->u.str=(char*)country->iso3;
+ this_->attr_next=attr_country_name;
+ return 1;
+ case attr_country_name:
+ attr->u.str=(char*)navit_nls_gettext(country->name);
+ this_->attr_next=attr_none;
+ return 1;
+ default:
+ return 0;
+ }
}
struct item_methods country_meth = {
- NULL, /* coord_rewind */
- NULL, /* coord_get */
- NULL, /* attr_rewind */
- country_attr_get, /* attr_get */
+ NULL, /* coord_rewind */
+ NULL, /* coord_get */
+ NULL, /* attr_rewind */
+ country_attr_get, /* attr_get */
};
struct country_search *
-country_search_new(struct attr *search, int partial)
-{
- struct country_search *ret=g_new(struct country_search, 1);
- ret->search=*search;
- if (search->type != attr_country_id) {
- ret->search.u.str=linguistics_casefold(ret->search.u.str);
- ret->len=strlen(ret->search.u.str);
- }
- else
- ret->len=0;
- ret->partial=partial;
- ret->count=0;
+country_search_new(struct attr *search, int partial) {
+ struct country_search *ret=g_new(struct country_search, 1);
+ ret->search=*search;
+ if (search->type != attr_country_id) {
+ ret->search.u.str=linguistics_casefold(ret->search.u.str);
+ ret->len=strlen(ret->search.u.str);
+ } else
+ ret->len=0;
+ ret->partial=partial;
+ ret->count=0;
- ret->item.type=type_country_label;
- ret->item.id_hi=0;
- ret->item.map=NULL;
- ret->item.meth=&country_meth;
- ret->item.priv_data=ret;
+ ret->item.type=type_country_label;
+ ret->item.id_hi=0;
+ ret->item.map=NULL;
+ ret->item.meth=&country_meth;
+ ret->item.priv_data=ret;
- return ret;
+ return ret;
}
-static int
-match(struct country_search *this_, enum attr_type type, const char *name)
-{
- int ret;
- if (!name)
- return 0;
- if (this_->search.type != type && this_->search.type != attr_country_all)
- return 0;
- ret=linguistics_compare(name, this_->search.u.str, linguistics_cmp_expand | (this_->partial?linguistics_cmp_partial:0) | linguistics_cmp_words)==0;
- return ret;
+static int match(struct country_search *this_, enum attr_type type, const char *name) {
+ int ret;
+ if (!name)
+ return 0;
+ if (this_->search.type != type && this_->search.type != attr_country_all)
+ return 0;
+ ret=linguistics_compare(name, this_->search.u.str,
+ linguistics_cmp_expand | (this_->partial?linguistics_cmp_partial:0) | linguistics_cmp_words)==0;
+ return ret;
}
struct item *
-country_search_get_item(struct country_search *this_)
-{
- for (;;) {
- if (this_->count >= sizeof(country)/sizeof(struct country))
- return NULL;
- this_->country=&country[this_->count++];
- if ((this_->search.type == attr_country_id && this_->search.u.num == this_->country->id) ||
- match(this_, attr_country_iso3, this_->country->iso3) ||
- match(this_, attr_country_iso2, this_->country->iso2) ||
- match(this_, attr_country_car, this_->country->car) ||
- match(this_, attr_country_name, navit_nls_gettext(this_->country->name))) {
- this_->item.id_lo=this_->country->id;
- return &this_->item;
- }
- }
+country_search_get_item(struct country_search *this_) {
+ for (;;) {
+ if (this_->count >= sizeof(country)/sizeof(struct country))
+ return NULL;
+ this_->country=&country[this_->count++];
+ if ((this_->search.type == attr_country_id && this_->search.u.num == this_->country->id) ||
+ match(this_, attr_country_iso3, this_->country->iso3) ||
+ match(this_, attr_country_iso2, this_->country->iso2) ||
+ match(this_, attr_country_car, this_->country->car) ||
+ match(this_, attr_country_name, navit_nls_gettext(this_->country->name))) {
+ this_->item.id_lo=this_->country->id;
+ return &this_->item;
+ }
+ }
}
static struct attr country_default_attr;
static char iso2[3];
struct attr *
-country_default(void)
-{
- char *lang;
- if (country_default_attr.u.str)
- return &country_default_attr;
- lang=getenv("LANG");
- if (!lang || strlen(lang) < 5)
- return NULL;
- strncpy(iso2, lang+3, 2);
- country_default_attr.type=attr_country_iso2;
- country_default_attr.u.str=iso2;
- return &country_default_attr;
+country_default(void) {
+ char *lang;
+ if (country_default_attr.u.str)
+ return &country_default_attr;
+ lang=getenv("LANG");
+ if (!lang || strlen(lang) < 5)
+ return NULL;
+ strncpy(iso2, lang+3, 2);
+ country_default_attr.type=attr_country_iso2;
+ country_default_attr.u.str=iso2;
+ return &country_default_attr;
}
-void
-country_search_destroy(struct country_search *this_)
-{
- g_free(this_->search.u.str);
- g_free(this_);
+void country_search_destroy(struct country_search *this_) {
+ g_free(this_->search.u.str);
+ g_free(this_);
}
diff --git a/navit/data.h b/navit/data.h
index 19928a391..c060739b0 100644
--- a/navit/data.h
+++ b/navit/data.h
@@ -100,7 +100,7 @@ get_string(unsigned char **p)
while (**p) (*p)++;
(*p)++;
return ret;
-}
+}
#define L(x) ({ unsigned char *t=(unsigned char *)&(x); t[0] | (t[1] << 8) | (t[2] << 16) | (t[3] << 24); })
diff --git a/navit/data_window.c b/navit/data_window.c
index 8db7d5d54..2c9310a01 100644
--- a/navit/data_window.c
+++ b/navit/data_window.c
@@ -20,22 +20,16 @@
#include <glib.h>
#include "data_window.h"
-void
-datawindow_mode(struct datawindow *win, int start)
-{
- win->meth.mode(win->priv, start);
+void datawindow_mode(struct datawindow *win, int start) {
+ win->meth.mode(win->priv, start);
}
-void
-datawindow_add(struct datawindow *win, struct param_list *param, int count)
-{
- win->meth.add(win->priv, param, count);
+void datawindow_add(struct datawindow *win, struct param_list *param, int count) {
+ win->meth.add(win->priv, param, count);
}
-void
-datawindow_destroy(struct datawindow *win)
-{
- win->meth.destroy(win->priv);
- g_free(win);
+void datawindow_destroy(struct datawindow *win) {
+ win->meth.destroy(win->priv);
+ g_free(win);
}
diff --git a/navit/data_window_int.h b/navit/data_window_int.h
index 6d3ead94e..a9b712759 100644
--- a/navit/data_window_int.h
+++ b/navit/data_window_int.h
@@ -22,7 +22,7 @@
struct data_window {
GtkWidget *window;
- GtkWidget *scrolled_window;
+ GtkWidget *scrolled_window;
GtkWidget *treeview;
void(*callback)(struct data_window *, char **cols);
};
diff --git a/navit/debug.c b/navit/debug.c
index 6d1bd4c95..ef485ad8a 100644
--- a/navit/debug.c
+++ b/navit/debug.c
@@ -67,459 +67,512 @@ static FILE *debug_fp;
#if defined(_WIN32) || defined(__CEGCC__)
-static void sigsegv(int sig)
-{
+static void sigsegv(int sig) {
}
#else
#include <unistd.h>
-static void sigsegv(int sig)
-{
- char buffer[256];
- if (segv_level > 1)
- sprintf(buffer, "gdb -ex bt %s %d", gdb_program, getpid());
- else
- sprintf(buffer, "gdb -ex bt -ex detach -ex quit %s %d", gdb_program, getpid());
- system(buffer);
- exit(1);
+static void sigsegv(int sig) {
+ char buffer[256];
+ if (segv_level > 1)
+ sprintf(buffer, "gdb -ex bt %s %d", gdb_program, getpid());
+ else
+ sprintf(buffer, "gdb -ex bt -ex detach -ex quit %s %d", gdb_program, getpid());
+ system(buffer);
+ exit(1);
}
#endif
-void
-debug_init(const char *program_name)
-{
+void debug_init(const char *program_name) {
#ifndef HAVE_API_ANDROID
- gdb_program=g_strdup(program_name);
- signal(SIGSEGV, sigsegv);
+ gdb_program=g_strdup(program_name);
+ signal(SIGSEGV, sigsegv);
#endif
- debug_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ debug_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
- debug_fp = stdout;
+ debug_fp = stdout;
#else
- debug_fp = stderr;
+ debug_fp = stderr;
#endif
}
-static void
-debug_update_level(gpointer key, gpointer value, gpointer user_data)
-{
- if (max_debug_level < GPOINTER_TO_INT(value))
- max_debug_level = GPOINTER_TO_INT(value);
+static void debug_update_level(gpointer key, gpointer value, gpointer user_data) {
+ if (max_debug_level < GPOINTER_TO_INT(value))
+ max_debug_level = GPOINTER_TO_INT(value);
}
-void
-debug_set_global_level(dbg_level level, int override_old_value ) {
- if (global_debug_level == GLOBAL_DEBUG_LEVEL_UNSET || override_old_value) {
- global_debug_level=level;
- if (max_debug_level < global_debug_level){
- max_debug_level = global_debug_level;
- }
- }
+void debug_set_global_level(dbg_level level, int override_old_value ) {
+ if (global_debug_level == GLOBAL_DEBUG_LEVEL_UNSET || override_old_value) {
+ global_debug_level=level;
+ if (max_debug_level < global_debug_level) {
+ max_debug_level = global_debug_level;
+ }
+ }
}
-void
-debug_level_set(const char *name, dbg_level level)
-{
- if (!strcmp(name, "segv")) {
+void debug_level_set(const char *name, dbg_level level) {
+ if (!strcmp(name, "segv")) {
#ifndef HAVE_API_ANDROID
- segv_level=level;
- if (segv_level)
- signal(SIGSEGV, sigsegv);
- else
- signal(SIGSEGV, NULL);
+ segv_level=level;
+ if (segv_level)
+ signal(SIGSEGV, sigsegv);
+ else
+ signal(SIGSEGV, NULL);
#endif
- } else if (!strcmp(name, "timestamps")) {
- timestamp_prefix=level;
- } else if (!strcmp(name, DEBUG_MODULE_GLOBAL)) {
- debug_set_global_level(level, 0);
- } else {
- g_hash_table_insert(debug_hash, g_strdup(name), GINT_TO_POINTER(level));
- g_hash_table_foreach(debug_hash, debug_update_level, NULL);
- }
+ } else if (!strcmp(name, "timestamps")) {
+ timestamp_prefix=level;
+ } else if (!strcmp(name, DEBUG_MODULE_GLOBAL)) {
+ debug_set_global_level(level, 0);
+ } else {
+ g_hash_table_insert(debug_hash, g_strdup(name), GINT_TO_POINTER(level));
+ g_hash_table_foreach(debug_hash, debug_update_level, NULL);
+ }
}
-static dbg_level
-parse_dbg_level(struct attr *dbg_level_attr, struct attr *level_attr)
-{
- if (dbg_level_attr) {
- if(!strcmp(dbg_level_attr->u.str,"error")){
- return lvl_error;
- }
- if(!strcmp(dbg_level_attr->u.str,"warning")){
- return lvl_warning;
- }
- if(!strcmp(dbg_level_attr->u.str,"info")){
- return lvl_info;
- }
- if(!strcmp(dbg_level_attr->u.str,"debug")){
- return lvl_debug;
- }
- dbg(lvl_error, "Invalid debug level in config: '%s'\n", dbg_level_attr->u.str);
- } else if (level_attr) {
- if (level_attr->u.num>= lvl_error &&
- level_attr->u.num<= lvl_debug)
- return level_attr->u.num;
- dbg(lvl_error, "Invalid debug level in config: %ld\n", level_attr->u.num);
- }
- return lvl_unset;
+static dbg_level parse_dbg_level(struct attr *dbg_level_attr, struct attr *level_attr) {
+ if (dbg_level_attr) {
+ if(!strcmp(dbg_level_attr->u.str,"error")) {
+ return lvl_error;
+ }
+ if(!strcmp(dbg_level_attr->u.str,"warning")) {
+ return lvl_warning;
+ }
+ if(!strcmp(dbg_level_attr->u.str,"info")) {
+ return lvl_info;
+ }
+ if(!strcmp(dbg_level_attr->u.str,"debug")) {
+ return lvl_debug;
+ }
+ dbg(lvl_error, "Invalid debug level in config: '%s'", dbg_level_attr->u.str);
+ } else if (level_attr) {
+ if (level_attr->u.num>= lvl_error &&
+ level_attr->u.num<= lvl_debug)
+ return level_attr->u.num;
+ dbg(lvl_error, "Invalid debug level in config: %ld", level_attr->u.num);
+ }
+ return lvl_unset;
}
struct debug *
-debug_new(struct attr *parent, struct attr **attrs)
-{
- struct attr *name,*dbg_level_attr,*level_attr;
- dbg_level level;
- name=attr_search(attrs, NULL, attr_name);
- dbg_level_attr=attr_search(attrs, NULL, attr_dbg_level);
- level_attr=attr_search(attrs, NULL, attr_level);
- level = parse_dbg_level(dbg_level_attr,level_attr);
+debug_new(struct attr *parent, struct attr **attrs) {
+ struct attr *name,*dbg_level_attr,*level_attr;
+ dbg_level level;
+ name=attr_search(attrs, NULL, attr_name);
+ dbg_level_attr=attr_search(attrs, NULL, attr_dbg_level);
+ level_attr=attr_search(attrs, NULL, attr_level);
+ level = parse_dbg_level(dbg_level_attr,level_attr);
#ifdef HAVE_SOCKET
- if (!name && level==lvl_unset) {
- struct attr *socket_attr=attr_search(attrs, NULL, attr_socket);
- char *p,*s;
- if (!socket_attr)
- return NULL;
- s=g_strdup(socket_attr->u.str);
- p=strchr(s,':');
- if (!p) {
- g_free(s);
- return NULL;
- }
- *p++='\0';
- debug_sin.sin_family=AF_INET;
- if (!inet_aton(s, &debug_sin.sin_addr)) {
- g_free(s);
- return NULL;
- }
- debug_sin.sin_port=ntohs(atoi(p));
- if (debug_socket == -1)
- debug_socket=socket(PF_INET, SOCK_DGRAM, 0);
- g_free(s);
- return (struct debug *)&dummy;
- }
+ if (!name && level==lvl_unset) {
+ struct attr *socket_attr=attr_search(attrs, NULL, attr_socket);
+ char *p,*s;
+ if (!socket_attr)
+ return NULL;
+ s=g_strdup(socket_attr->u.str);
+ p=strchr(s,':');
+ if (!p) {
+ g_free(s);
+ return NULL;
+ }
+ *p++='\0';
+ debug_sin.sin_family=AF_INET;
+ if (!inet_aton(s, &debug_sin.sin_addr)) {
+ g_free(s);
+ return NULL;
+ }
+ debug_sin.sin_port=ntohs(atoi(p));
+ if (debug_socket == -1)
+ debug_socket=socket(PF_INET, SOCK_DGRAM, 0);
+ g_free(s);
+ return (struct debug *)&dummy;
+ }
#endif
- if (!name || level==lvl_unset)
- return NULL;
- debug_level_set(name->u.str, level);
- return (struct debug *)&dummy;
+ if (!name || level==lvl_unset)
+ return NULL;
+ debug_level_set(name->u.str, level);
+ return (struct debug *)&dummy;
}
-dbg_level
-debug_level_get(const char *message_category)
-{
- if (!debug_hash)
- return DEFAULT_DEBUG_LEVEL;
- gpointer level = g_hash_table_lookup(debug_hash, message_category);
- if (!level) {
- return DEFAULT_DEBUG_LEVEL;
- }
- return GPOINTER_TO_INT(level);
+dbg_level debug_level_get(const char *message_category) {
+ if (!debug_hash)
+ return DEFAULT_DEBUG_LEVEL;
+ gpointer level = g_hash_table_lookup(debug_hash, message_category);
+ if (!level) {
+ return DEFAULT_DEBUG_LEVEL;
+ }
+ return GPOINTER_TO_INT(level);
}
-static void debug_timestamp(char *buffer)
-{
+/**
+ * @brief Write a timestamp to a string buffer
+ *
+ * Timestamp has the format "HH:MM:SS:mmm|" (with mmm=milliseconds), or under Windows "SSSSS:uuuuuu|" (with uuuuuu=microseconds)
+ *
+ * @param[out] buffer The buffer to write to
+ *
+ * @warning Buffer overflow may occur on @p buffer, if it is less than 14-bytes long (13 chars will be stored at max)
+ */
+static void debug_timestamp(char *buffer) {
#if defined HAVE_API_WIN32_CE || defined _MSC_VER
- LARGE_INTEGER counter, frequency;
- double val;
- QueryPerformanceCounter(&counter);
- QueryPerformanceFrequency(&frequency);
- val=counter.HighPart * 4294967296.0 + counter.LowPart;
- val/=frequency.HighPart * 4294967296.0 + frequency.LowPart;
- sprintf(buffer,"%.6f|",val);
-
+ LARGE_INTEGER counter, frequency;
+ double val;
+ unsigned int intpart;
+ QueryPerformanceCounter(&counter);
+ QueryPerformanceFrequency(&frequency);
+ val=counter.HighPart * 4294967296.0 + counter.LowPart;
+ val/=frequency.HighPart * 4294967296.0 + frequency.LowPart;
+ intpart=((unsigned int)val)/100000; /* Extract all digits above 5 lower from integer part */
+ val = val - (intpart * 100000); /* Limit val integer part to 5 digits */
+ sprintf(buffer,"%.6f|",val);
#else
- struct timeval tv;
-
- if (gettimeofday(&tv, NULL) == -1)
- return;
- /* Timestamps are UTC */
- sprintf(buffer,
- "%02d:%02d:%02d.%03d|",
- (int)(tv.tv_sec/3600)%24,
- (int)(tv.tv_sec/60)%60,
- (int)tv.tv_sec % 60,
- (int)tv.tv_usec/1000);
+ struct timeval tv;
+
+ if (gettimeofday(&tv, NULL) == -1)
+ return;
+ /* Timestamps are UTC */
+ sprintf(buffer,
+ "%02d:%02d:%02d.%03d|",
+ (int)(tv.tv_sec/3600)%24,
+ (int)(tv.tv_sec/60)%60,
+ (int)tv.tv_sec % 60,
+ (int)tv.tv_usec/1000);
#endif
}
-static char* dbg_level_to_string(dbg_level level)
-{
- switch(level) {
- case lvl_unset:
- return "-unset-";
- case lvl_error:
- return "error";
- case lvl_warning:
- return "warning";
- case lvl_info:
- return "info";
- case lvl_debug:
- return "debug";
- }
- return "-invalid level-";
+static char* dbg_level_to_string(dbg_level level) {
+ switch(level) {
+ case lvl_unset:
+ return "-unset-";
+ case lvl_error:
+ return "error";
+ case lvl_warning:
+ return "warning";
+ case lvl_info:
+ return "info";
+ case lvl_debug:
+ return "debug";
+ }
+ return "-invalid level-";
}
#ifdef HAVE_API_ANDROID
-static android_LogPriority
-dbg_level_to_android(dbg_level level)
-{
- switch(level) {
- case lvl_unset:
- return ANDROID_LOG_UNKNOWN;
- case lvl_error:
- return ANDROID_LOG_ERROR;
- case lvl_warning:
- return ANDROID_LOG_WARN;
- case lvl_info:
- return ANDROID_LOG_INFO;
- case lvl_debug:
- return ANDROID_LOG_DEBUG;
- }
- return ANDROID_LOG_UNKNOWN;
+static android_LogPriority dbg_level_to_android(dbg_level level) {
+ switch(level) {
+ case lvl_unset:
+ return ANDROID_LOG_UNKNOWN;
+ case lvl_error:
+ return ANDROID_LOG_ERROR;
+ case lvl_warning:
+ return ANDROID_LOG_WARN;
+ case lvl_info:
+ return ANDROID_LOG_INFO;
+ case lvl_debug:
+ return ANDROID_LOG_DEBUG;
+ }
+ return ANDROID_LOG_UNKNOWN;
}
#endif
-void
-debug_vprintf(dbg_level level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, va_list ap)
-{
+/**
+ * @brief Write a log message
+ *
+ * @param level The level of the message. The message will only be written if \p level is higher than the minimum (global, per module or per function)
+ * @param module The name of the module that is initiating the log message
+ * @param mlen The length of string \p module
+ * @param function The name of the function that is initiating the log message
+ * @param flen The length of string \p function
+ * @param prefix Force prepending the message with context information (a timestamp, if timestamp_prefix is set), and the module and function name
+ * @param fmt The format string that specifies how subsequent arguments are output
+ * @param ap A list of arguments to use for substitution in the format string
+ */
+void debug_vprintf(dbg_level level, const char *module, const int mlen, const char *function, const int flen,
+ int prefix, const char *fmt, va_list ap) {
+ char *end; /* Pointer to the NUL terminating byte of debug_message */
+ char debug_message[4096];
+ char *message_origin = debug_message + sizeof(debug_message)
+ -1; /* message_origin is actually stored at the very end of debug_message buffer */
+ size_t len; /* Length of the currently processed C-string */
+
+ /* Here we store a description of the source of the debugging message (message_origin)
+ * For this, we use the last bytes of the debug_message[] buffer.
+ * For example, if message_origin is "gui_internal:gui_internal_set_attr", debug_message[] will contain:
+ * "gui_internal:gui_internal_set_attr\0" with '\0' being the last byte (stored in debug_message[sizeof(debug_message) -1])
+ */
+
+ *message_origin = '\0'; /* Force string termination of message_origin (last byte of debug_message) */
+
+#if defined HAVE_API_WIN32_CE || defined _MSC_VER
+ len = strlen(function);
+#else
+ len = flen;
+#endif
+ message_origin -= len;
+ dbg_assert(message_origin >= debug_message);
+ memmove(message_origin, function, len);
+ message_origin--;
+ dbg_assert(message_origin >= debug_message);
+ *message_origin = ':';
#if defined HAVE_API_WIN32_CE || defined _MSC_VER
- char message_origin[4096];
+ len = strlen(module);
#else
- char message_origin[mlen+flen+3];
+ len = mlen;
#endif
+ message_origin -= len;
+ dbg_assert(message_origin >= debug_message);
+ memmove(message_origin, module, len);
- sprintf(message_origin, "%s:%s", module, function);
- if (global_debug_level >= level || debug_level_get(module) >= level || debug_level_get(message_origin) >= level) {
+ /* The source of the debug message has been created, is terminated with '\0' and stored at the very end of the debug_message buffer. */
+
+ if (global_debug_level >= level || debug_level_get(module) >= level || debug_level_get(message_origin) >= level) {
+ /* Do we output a debug message, based on the current debug level set */
#if defined(DEBUG_WIN32_CE_MESSAGEBOX)
- wchar_t muni[4096];
+ wchar_t muni[4096];
#endif
- char debug_message[4096];
- debug_message[0]='\0';
- if (prefix) {
- if (timestamp_prefix)
- debug_timestamp(debug_message);
- strcpy(debug_message+strlen(debug_message),dbg_level_to_string(level));
- strcpy(debug_message+strlen(debug_message),":");
- strcpy(debug_message+strlen(debug_message),message_origin);
- strcpy(debug_message+strlen(debug_message),":");
- }
+ debug_message[0]='\0';
+ end = debug_message;
+ if (prefix) {
+ if (timestamp_prefix) {
+ /* Do we prepend with a timestamp? */
+ dbg_assert(sizeof(debug_message)>=14);
+ debug_timestamp(debug_message);
+ len = strlen(debug_message);
+ end = debug_message+len;
+ }
+ /* When we reach this part of the code, end is a pointer to the beginning of the debug message (inside the buffer debug_message) */
+ g_strlcpy(end, dbg_level_to_string(level),
+ sizeof(debug_message) - (end - debug_message)); /* Add the debug level for the current debug message level */
+ len = strlen(debug_message);
+ end = debug_message+len; /* Have len points to the end of the constructed string */
+ dbg_assert(end < debug_message+sizeof(debug_message)); /* Make sure we don't get any overflow */
+ *end++ = ':';
+ /* In the code below, we add the message_origin to the debug message */
+ len=strlen(message_origin);
+ dbg_assert(end+len < debug_message+sizeof(debug_message)); /* Make sure we don't get any overflow */
+ memmove(end,message_origin,len); /* We use memmove here as both message_origin and destination may overlap */
+ message_origin =
+ NULL; /* Warning: from this point, we must not use the pointer message_origin as the content of the debug_message may be overwritten at any time. */
+ end+=len;
+ dbg_assert(end+1 < debug_message+sizeof(
+ debug_message)); /* Make sure we don't get any overflow for both ':' and terminating '\0' */
+ *end++ = ':';
+ *end = '\0'; /* Force termination of the string */
+ /* When we get here, debug_message contains:
+ * "ttttttttttttt|error:gui_internal:gui_internal_set_attr:\0" (if timestamps are enabled) or
+ * "error:gui_internal:gui_internal_set_attr:\0" otherwise.
+ * end points to the terminating '\0'
+ */
+ }
#if defined HAVE_API_WIN32_CE
#define vsnprintf _vsnprintf
#endif
- vsnprintf(debug_message+strlen(debug_message),4095-strlen(debug_message),fmt,ap);
+ len = strlen(debug_message);
+ vsnprintf(end,sizeof(debug_message) - len,fmt,
+ ap); /* Concatenate the debug log message itself to the prefix constructed above */
+ len = strlen(debug_message); /* Adjust len to store the length of the current string */
+ end = debug_message+len; /* Adjust end to point to the terminating '\0' of the current string */
+
+ /* In the code below, we prepend the end-of-line sequence to the current string pointed by debug_message ("\r\n" for Windows, "\r" otherwise */
+#ifdef HAVE_API_WIN32_BASE
+ if (len + 1 < sizeof(debug_message) - 1) {
+ /* For Windows platforms, add \r at the end of the buffer (if any room), make sure that we have room for one more character */
+ *end++ = '\r';
+ len++;
+ *end = '\0';
+ }
+#endif
+ if (len + 1 < sizeof(debug_message)) { /* Add \n at the end of the buffer (if any room) */
+ *end++ = '\n';
+ len++;
+ *end = '\0';
+ }
#ifdef DEBUG_WIN32_CE_MESSAGEBOX
- mbstowcs(muni, debug_message, strlen(debug_message)+1);
- MessageBoxW(NULL, muni, TEXT("Navit - Error"), MB_APPLMODAL|MB_OK|MB_ICONERROR);
+ mbstowcs(muni, debug_message, len+1);
+ MessageBoxW(NULL, muni, TEXT("Navit - Error"), MB_APPLMODAL|MB_OK|MB_ICONERROR);
#else
#ifdef HAVE_API_ANDROID
- __android_log_print(dbg_level_to_android(level), "navit", "%s", debug_message);
+ __android_log_print(dbg_level_to_android(level), "navit", "%s", debug_message);
#else
#ifdef HAVE_SOCKET
- if (debug_socket != -1) {
- sendto(debug_socket, debug_message, strlen(debug_message), 0, (struct sockaddr *)&debug_sin, sizeof(debug_sin));
- return;
- }
+ if (debug_socket != -1) {
+ sendto(debug_socket, debug_message, len, 0, (struct sockaddr *)&debug_sin, sizeof(debug_sin));
+ return;
+ }
#endif
- FILE *fp=debug_fp;
- if (! fp)
- fp = stderr;
- fprintf(fp,"%s",debug_message);
- fflush(fp);
+ FILE *fp=debug_fp;
+ if (! fp)
+ fp = stderr;
+ fprintf(fp,"%s",debug_message);
+ fflush(fp);
#endif
#endif
- }
+ }
}
-void
-debug_printf(dbg_level level, const char *module, const int mlen,const char *function, const int flen, int prefix, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- debug_vprintf(level, module, mlen, function, flen, prefix, fmt, ap);
- va_end(ap);
+void debug_printf(dbg_level level, const char *module, const int mlen,const char *function, const int flen,
+ int prefix, const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ debug_vprintf(level, module, mlen, function, flen, prefix, fmt, ap);
+ va_end(ap);
}
-void
-debug_assert_fail(const char *module, const int mlen,const char *function, const int flen, const char *file, int line, const char *expr)
-{
- debug_printf(lvl_error,module,mlen,function,flen,1,"%s:%d assertion failed:%s\n", file, line, expr);
- abort();
+void debug_assert_fail(const char *module, const int mlen,const char *function, const int flen, const char *file,
+ int line, const char *expr) {
+ debug_printf(lvl_error,module,mlen,function,flen,1,"%s:%d assertion failed:%s\n", file, line, expr);
+ abort();
}
-void
-debug_destroy(void)
-{
- if (!debug_fp)
- return;
- if (debug_fp == stderr || debug_fp == stdout)
- return;
- fclose(debug_fp);
- debug_fp = NULL;
+void debug_destroy(void) {
+ if (!debug_fp)
+ return;
+ if (debug_fp == stderr || debug_fp == stdout)
+ return;
+ fclose(debug_fp);
+ debug_fp = NULL;
}
-void debug_set_logfile(const char *path)
-{
- FILE *fp;
- fp = fopen(path, "a");
- if (fp) {
- debug_destroy();
- debug_fp = fp;
- fprintf(debug_fp, "Navit log started\n");
- fflush(debug_fp);
- }
+void debug_set_logfile(const char *path) {
+ FILE *fp;
+ fp = fopen(path, "a");
+ if (fp) {
+ debug_destroy();
+ debug_fp = fp;
+ fprintf(debug_fp, "Navit log started\n");
+ fflush(debug_fp);
+ }
}
struct malloc_head {
- int magic;
- int size;
- char *where;
- void *return_address[8];
- struct malloc_head *prev;
- struct malloc_head *next;
+ int magic;
+ int size;
+ char *where;
+ void *return_address[8];
+ struct malloc_head *prev;
+ struct malloc_head *next;
} *malloc_heads;
struct malloc_tail {
- int magic;
+ int magic;
};
int mallocs,debug_malloc_size,debug_malloc_size_m;
-void
-debug_dump_mallocs(void)
-{
- struct malloc_head *head=malloc_heads;
- int i;
- dbg(lvl_debug,"mallocs %d\n",mallocs);
- while (head) {
- fprintf(stderr,"unfreed malloc from %s of size %d\n",head->where,head->size);
- for (i = 0 ; i < 8 ; i++)
- fprintf(stderr,"\tlist *%p\n",head->return_address[i]);
-#if 0
- fprintf(stderr,"%s\n",head+1);
-#endif
- head=head->next;
- }
+void debug_dump_mallocs(void) {
+ struct malloc_head *head=malloc_heads;
+ int i;
+ dbg(lvl_debug,"mallocs %d",mallocs);
+ while (head) {
+ fprintf(stderr,"unfreed malloc from %s of size %d\n",head->where,head->size);
+ for (i = 0 ; i < 8 ; i++)
+ fprintf(stderr,"\tlist *%p\n",head->return_address[i]);
+ head=head->next;
+ }
}
-void *
-debug_malloc(const char *where, int line, const char *func, int size)
-{
- struct malloc_head *head;
- struct malloc_tail *tail;
- if (!size)
- return NULL;
- mallocs++;
- debug_malloc_size+=size;
- if (debug_malloc_size/(1024*1024) != debug_malloc_size_m) {
- debug_malloc_size_m=debug_malloc_size/(1024*1024);
- dbg(lvl_debug,"malloced %d kb\n",debug_malloc_size/1024);
- }
- head=malloc(size+sizeof(*head)+sizeof(*tail));
- head->magic=0xdeadbeef;
- head->size=size;
- head->prev=NULL;
- head->next=malloc_heads;
- malloc_heads=head;
- if (head->next)
- head->next->prev=head;
- head->where=g_strdup_printf("%s:%d %s",where,line,func);
+void *debug_malloc(const char *where, int line, const char *func, int size) {
+ struct malloc_head *head;
+ struct malloc_tail *tail;
+ if (!size)
+ return NULL;
+ mallocs++;
+ debug_malloc_size+=size;
+ if (debug_malloc_size/(1024*1024) != debug_malloc_size_m) {
+ debug_malloc_size_m=debug_malloc_size/(1024*1024);
+ dbg(lvl_debug,"malloced %d kb",debug_malloc_size/1024);
+ }
+ head=malloc(size+sizeof(*head)+sizeof(*tail));
+ head->magic=0xdeadbeef;
+ head->size=size;
+ head->prev=NULL;
+ head->next=malloc_heads;
+ malloc_heads=head;
+ if (head->next)
+ head->next->prev=head;
+ head->where=g_strdup_printf("%s:%d %s",where,line,func);
#if !defined (__GNUC__)
#define __builtin_return_address(x) NULL
#endif
- head->return_address[0]=__builtin_return_address(0);
- head->return_address[1]=__builtin_return_address(1);
- head->return_address[2]=__builtin_return_address(2);
- head->return_address[3]=__builtin_return_address(3);
- head->return_address[4]=__builtin_return_address(4);
- head->return_address[5]=__builtin_return_address(5);
- head->return_address[6]=__builtin_return_address(6);
- head->return_address[7]=__builtin_return_address(7);
- head++;
- tail=(struct malloc_tail *)((unsigned char *)head+size);
- tail->magic=0xdeadbef0;
- return head;
+ head->return_address[0]=__builtin_return_address(0);
+ head->return_address[1]=__builtin_return_address(1);
+ head->return_address[2]=__builtin_return_address(2);
+ head->return_address[3]=__builtin_return_address(3);
+ head->return_address[4]=__builtin_return_address(4);
+ head->return_address[5]=__builtin_return_address(5);
+ head->return_address[6]=__builtin_return_address(6);
+ head->return_address[7]=__builtin_return_address(7);
+ head++;
+ tail=(struct malloc_tail *)((unsigned char *)head+size);
+ tail->magic=0xdeadbef0;
+ return head;
}
-void *
-debug_malloc0(const char *where, int line, const char *func, int size)
-{
- void *ret=debug_malloc(where, line, func, size);
- if (ret)
- memset(ret, 0, size);
- return ret;
+void *debug_malloc0(const char *where, int line, const char *func, int size) {
+ void *ret=debug_malloc(where, line, func, size);
+ if (ret)
+ memset(ret, 0, size);
+ return ret;
}
-void *
-debug_realloc(const char *where, int line, const char *func, void *ptr, int size)
-{
- void *ret=debug_malloc(where, line, func, size);
- if (ret && ptr)
- memcpy(ret, ptr, size);
- debug_free(where, line, func, ptr);
- return ret;
+void *debug_realloc(const char *where, int line, const char *func, void *ptr, int size) {
+ void *ret=debug_malloc(where, line, func, size);
+ if (ret && ptr)
+ memcpy(ret, ptr, size);
+ debug_free(where, line, func, ptr);
+ return ret;
}
-char *
-debug_strdup(const char *where, int line, const char *func, const char *ptr)
-{
- int size;
- char *ret;
-
- if (!ptr)
- return NULL;
- size=strlen(ptr)+1;
- ret=debug_malloc(where, line, func, size);
- memcpy(ret, ptr, size);
- return ret;
+char *debug_strdup(const char *where, int line, const char *func, const char *ptr) {
+ int size;
+ char *ret;
+
+ if (!ptr)
+ return NULL;
+ size=strlen(ptr)+1;
+ ret=debug_malloc(where, line, func, size);
+ memcpy(ret, ptr, size);
+ return ret;
}
-char *
-debug_guard(const char *where, int line, const char *func, char *str)
-{
- char *ret=debug_strdup(where, line, func, str);
- g_free(str);
- return ret;
+char *debug_guard(const char *where, int line, const char *func, char *str) {
+ char *ret=debug_strdup(where, line, func, str);
+ g_free(str);
+ return ret;
}
-void
-debug_free(const char *where, int line, const char *func, void *ptr)
-{
- struct malloc_head *head;
- struct malloc_tail *tail;
- if (!ptr)
- return;
- mallocs--;
- head=(struct malloc_head *)((unsigned char *)ptr-sizeof(*head));
- tail=(struct malloc_tail *)((unsigned char *)ptr+head->size);
- debug_malloc_size-=head->size;
- if (head->magic != 0xdeadbeef || tail->magic != 0xdeadbef0) {
- fprintf(stderr,"Invalid free from %s:%d %s\n",where,line,func);
- }
- head->magic=0;
- tail->magic=0;
- if (head->prev)
- head->prev->next=head->next;
- else
- malloc_heads=head->next;
- if (head->next)
- head->next->prev=head->prev;
- free(head->where);
- free(head);
+void debug_free(const char *where, int line, const char *func, void *ptr) {
+ struct malloc_head *head;
+ struct malloc_tail *tail;
+ if (!ptr)
+ return;
+ mallocs--;
+ head=(struct malloc_head *)((unsigned char *)ptr-sizeof(*head));
+ tail=(struct malloc_tail *)((unsigned char *)ptr+head->size);
+ debug_malloc_size-=head->size;
+ if (head->magic != 0xdeadbeef || tail->magic != 0xdeadbef0) {
+ fprintf(stderr,"Invalid free from %s:%d %s\n",where,line,func);
+ }
+ head->magic=0;
+ tail->magic=0;
+ if (head->prev)
+ head->prev->next=head->next;
+ else
+ malloc_heads=head->next;
+ if (head->next)
+ head->next->prev=head->prev;
+ free(head->where);
+ free(head);
}
-void
-debug_free_func(void *ptr)
-{
- debug_free("unknown",0,"unknown",ptr);
+void debug_free_func(void *ptr) {
+ debug_free("unknown",0,"unknown",ptr);
}
void debug_finished(void) {
- debug_dump_mallocs();
- g_free(gdb_program);
- g_hash_table_destroy(debug_hash);
- debug_destroy();
+ debug_dump_mallocs();
+ g_free(gdb_program);
+ g_hash_table_destroy(debug_hash);
+ debug_destroy();
}
diff --git a/navit/debug.h b/navit/debug.h
index 49f19566f..4d12ec169 100644
--- a/navit/debug.h
+++ b/navit/debug.h
@@ -30,7 +30,7 @@ extern "C" {
#ifdef _MSC_VER
#define __PRETTY_FUNCTION__ __FUNCTION__
-/* Uncomment the following define to enable MSVC's memory debugging support */
+/* Uncomment the following define to enable MSVC's memory debugging support */
/*#define _CRTDBG_MAP_ALLOC*/
#ifdef _CRTDBG_MAP_ALLOC
#include <stdlib.h>
diff --git a/navit/endianess.h b/navit/endianess.h
index 2b4047093..9e00dfb85 100644
--- a/navit/endianess.h
+++ b/navit/endianess.h
@@ -18,9 +18,9 @@
*/
#ifndef __ENDIANESS_HANDLER__
- /* The following is based on xorg/xserver/GL/glx/glxbyteorder.h
+ /* The following is based on xorg/xserver/GL/glx/glxbyteorder.h
* which is (c) IBM Corp. 2006,2007 and originally licensed under the following
- * BSD-license. All modifications in navit are licensed under the GNU GPL as
+ * BSD-license. All modifications in navit are licensed under the GNU GPL as
* described in file "COPYRIGHT".
*
* Portions also from GNU C Library include/bits/byteswap.h Also licsend
@@ -33,11 +33,11 @@
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
@@ -92,14 +92,14 @@
#endif
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
#define le16_to_cpu(x) __bswap_16 (x)
#define le32_to_cpu(x) __bswap_32 (x)
#define le64_to_cpu(x) __bswap_64 (x)
#define cpu_to_le16(x) __bswap_16 (x)
#define cpu_to_le32(x) __bswap_32 (x)
#define cpu_to_le64(x) __bswap_64 (x)
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
#define le16_to_cpu(x) (x)
#define le32_to_cpu(x) (x)
#define cpu_to_le16(x) (x)
diff --git a/navit/event.c b/navit/event.c
index 5aee40689..ecb21ee94 100644
--- a/navit/event.c
+++ b/navit/event.c
@@ -31,7 +31,7 @@ static int has_quit;
#define require_method_helper(m)\
if(!event_methods.m) {\
- dbg(lvl_error, "Can't find event system method %s. Event system is %s%s\n",\
+ dbg(lvl_error, "Can't find event system method %s. Event system is %s%s",\
#m ,e_system?"set to ":"not set.", e_system?e_system:"");\
#define require_method(m)\
@@ -44,37 +44,30 @@ static int has_quit;
return r;\
}
-void event_main_loop_run(void)
-{
- require_method(main_loop_run);
- event_methods.main_loop_run();
+void event_main_loop_run(void) {
+ require_method(main_loop_run);
+ event_methods.main_loop_run();
}
-void event_main_loop_quit(void)
-{
- if (event_methods.main_loop_quit)
- event_methods.main_loop_quit();
- has_quit=1;
+void event_main_loop_quit(void) {
+ if (event_methods.main_loop_quit)
+ event_methods.main_loop_quit();
+ has_quit=1;
}
-int
-event_main_loop_has_quit(void)
-{
- return has_quit;
+int event_main_loop_has_quit(void) {
+ return has_quit;
}
struct event_watch *
-event_add_watch(int fd, enum event_watch_cond cond, struct callback *cb)
-{
- require_method2(add_watch, NULL);
- return event_methods.add_watch(fd, cond, cb);
+event_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) {
+ require_method2(add_watch, NULL);
+ return event_methods.add_watch(fd, cond, cb);
}
-void
-event_remove_watch(struct event_watch *ev)
-{
- require_method(remove_watch);
- event_methods.remove_watch(ev);
+void event_remove_watch(struct event_watch *ev) {
+ require_method(remove_watch);
+ event_methods.remove_watch(ev);
}
/**
@@ -87,67 +80,56 @@ event_remove_watch(struct event_watch *ev)
* @returns the result of the event_methods.add_timeout() call
*/
struct event_timeout *
-event_add_timeout(int timeout, int multi, struct callback *cb)
-{
- require_method2(add_timeout, NULL);
- return event_methods.add_timeout(timeout, multi, cb);
+event_add_timeout(int timeout, int multi, struct callback *cb) {
+ require_method2(add_timeout, NULL);
+ return event_methods.add_timeout(timeout, multi, cb);
}
-void
-event_remove_timeout(struct event_timeout *ev)
-{
- require_method(remove_timeout);
- event_methods.remove_timeout(ev);
+void event_remove_timeout(struct event_timeout *ev) {
+ require_method(remove_timeout);
+ event_methods.remove_timeout(ev);
}
struct event_idle *
-event_add_idle(int priority, struct callback *cb)
-{
- require_method2(add_idle, NULL);
- return event_methods.add_idle(priority,cb);
+event_add_idle(int priority, struct callback *cb) {
+ require_method2(add_idle, NULL);
+ return event_methods.add_idle(priority,cb);
}
-void
-event_remove_idle(struct event_idle *ev)
-{
- require_method(remove_idle);
- event_methods.remove_idle(ev);
+void event_remove_idle(struct event_idle *ev) {
+ require_method(remove_idle);
+ event_methods.remove_idle(ev);
}
-void
-event_call_callback(struct callback_list *cb)
-{
- require_method(call_callback);
- event_methods.call_callback(cb);
+void event_call_callback(struct callback_list *cb) {
+ require_method(call_callback);
+ event_methods.call_callback(cb);
}
-char const *
-event_system(void)
-{
- return e_system;
+char const *event_system(void) {
+ return e_system;
}
-int
-event_request_system(const char *system, const char *requestor)
-{
- void (*event_type_new)(struct event_methods *meth);
- if (e_system) {
- if (strcmp(e_system, system)) {
- dbg(lvl_error,"system '%s' already requested by '%s', can't set to '%s' as requested from '%s'\n", e_system, e_requestor, system, requestor);
- return 0;
- }
- return 1;
- }
- event_type_new=plugin_get_category_event(system);
- if (! event_type_new) {
- dbg(lvl_error,"unsupported event system '%s' requested from '%s'\n", system, requestor);
- return 0;
- }
- event_type_new(&event_methods);
- e_system=system;
- e_requestor=requestor;
-
- return 1;
+int event_request_system(const char *system, const char *requestor) {
+ void (*event_type_new)(struct event_methods *meth);
+ if (e_system) {
+ if (strcmp(e_system, system)) {
+ dbg(lvl_error,"system '%s' already requested by '%s', can't set to '%s' as requested from '%s'", e_system, e_requestor,
+ system, requestor);
+ return 0;
+ }
+ return 1;
+ }
+ event_type_new=plugin_get_category_event(system);
+ if (! event_type_new) {
+ dbg(lvl_error,"unsupported event system '%s' requested from '%s'", system, requestor);
+ return 0;
+ }
+ event_type_new(&event_methods);
+ e_system=system;
+ e_requestor=requestor;
+
+ return 1;
}
diff --git a/navit/event_glib.c b/navit/event_glib.c
index e9bad6c40..0048071b0 100644
--- a/navit/event_glib.c
+++ b/navit/event_glib.c
@@ -26,175 +26,147 @@
static GMainLoop *loop;
-static void event_glib_main_loop_run(void)
-{
- loop = g_main_loop_new (NULL, TRUE);
- if (g_main_loop_is_running (loop))
- {
- g_main_loop_run (loop);
- }
+static void event_glib_main_loop_run(void) {
+ loop = g_main_loop_new (NULL, TRUE);
+ if (g_main_loop_is_running (loop)) {
+ g_main_loop_run (loop);
+ }
}
-static void event_glib_main_loop_quit(void)
-{
- if (loop) {
- g_main_loop_quit(loop);
- g_main_loop_unref(loop);
- }
+static void event_glib_main_loop_quit(void) {
+ if (loop) {
+ g_main_loop_quit(loop);
+ g_main_loop_unref(loop);
+ }
}
struct event_watch {
- GIOChannel *iochan;
- guint source;
+ GIOChannel *iochan;
+ guint source;
};
-static gboolean
-event_glib_call_watch(GIOChannel * iochan, GIOCondition condition, gpointer t)
-{
- struct callback *cb=t;
- callback_call_0(cb);
- return TRUE;
+static gboolean event_glib_call_watch(GIOChannel * iochan, GIOCondition condition, gpointer t) {
+ struct callback *cb=t;
+ callback_call_0(cb);
+ return TRUE;
}
-static struct event_watch *
-event_glib_add_watch(int fd, enum event_watch_cond cond, struct callback *cb)
-{
- struct event_watch *ret=g_new0(struct event_watch, 1);
- int flags=0;
- ret->iochan = g_io_channel_unix_new(fd);
- switch (cond) {
- case event_watch_cond_read:
- flags=G_IO_IN;
- break;
- case event_watch_cond_write:
- flags=G_IO_OUT;
- break;
- case event_watch_cond_except:
- flags=G_IO_ERR|G_IO_HUP;
- break;
- }
- ret->source = g_io_add_watch(ret->iochan, flags, event_glib_call_watch, (gpointer)cb);
- return ret;
+static struct event_watch *event_glib_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) {
+ struct event_watch *ret=g_new0(struct event_watch, 1);
+ int flags=0;
+ ret->iochan = g_io_channel_unix_new(fd);
+ switch (cond) {
+ case event_watch_cond_read:
+ flags=G_IO_IN;
+ break;
+ case event_watch_cond_write:
+ flags=G_IO_OUT;
+ break;
+ case event_watch_cond_except:
+ flags=G_IO_ERR|G_IO_HUP;
+ break;
+ }
+ ret->source = g_io_add_watch(ret->iochan, flags, event_glib_call_watch, (gpointer)cb);
+ return ret;
}
-static void
-event_glib_remove_watch(struct event_watch *ev)
-{
- if (! ev)
- return;
- g_source_remove(ev->source);
- g_io_channel_unref(ev->iochan);
- g_free(ev);
+static void event_glib_remove_watch(struct event_watch *ev) {
+ if (! ev)
+ return;
+ g_source_remove(ev->source);
+ g_io_channel_unref(ev->iochan);
+ g_free(ev);
}
struct event_timeout {
- guint source;
- struct callback *cb;
+ guint source;
+ struct callback *cb;
};
-static gboolean
-event_glib_call_timeout_single(struct event_timeout *ev)
-{
- callback_call_0(ev->cb);
- g_free(ev);
- return FALSE;
+static gboolean event_glib_call_timeout_single(struct event_timeout *ev) {
+ callback_call_0(ev->cb);
+ g_free(ev);
+ return FALSE;
}
-static gboolean
-event_glib_call_timeout_multi(struct event_timeout *ev)
-{
- callback_call_0(ev->cb);
- return TRUE;
+static gboolean event_glib_call_timeout_multi(struct event_timeout *ev) {
+ callback_call_0(ev->cb);
+ return TRUE;
}
-static struct event_timeout *
-event_glib_add_timeout(int timeout, int multi, struct callback *cb)
-{
- struct event_timeout *ret=g_new0(struct event_timeout, 1);
- ret->cb=cb;
- ret->source = g_timeout_add(timeout, multi ? (GSourceFunc)event_glib_call_timeout_multi : (GSourceFunc)event_glib_call_timeout_single, (gpointer)ret);
+static struct event_timeout *event_glib_add_timeout(int timeout, int multi, struct callback *cb) {
+ struct event_timeout *ret=g_new0(struct event_timeout, 1);
+ ret->cb=cb;
+ ret->source = g_timeout_add(timeout,
+ multi ? (GSourceFunc)event_glib_call_timeout_multi : (GSourceFunc)event_glib_call_timeout_single, (gpointer)ret);
- return ret;
+ return ret;
}
-static void
-event_glib_remove_timeout(struct event_timeout *ev)
-{
- if (! ev)
- return;
- g_source_remove(ev->source);
- g_free(ev);
+static void event_glib_remove_timeout(struct event_timeout *ev) {
+ if (! ev)
+ return;
+ g_source_remove(ev->source);
+ g_free(ev);
}
struct event_idle {
- guint source;
- struct callback *cb;
+ guint source;
+ struct callback *cb;
};
-static gboolean
-event_glib_call_idle(struct event_idle *ev)
-{
- callback_call_0(ev->cb);
- return TRUE;
+static gboolean event_glib_call_idle(struct event_idle *ev) {
+ callback_call_0(ev->cb);
+ return TRUE;
}
-static struct event_idle *
-event_glib_add_idle(int priority, struct callback *cb)
-{
- struct event_idle *ret=g_new0(struct event_idle, 1);
- ret->cb=cb;
- ret->source = g_idle_add_full(G_PRIORITY_HIGH_IDLE+priority, (GSourceFunc)event_glib_call_idle, (gpointer)ret, NULL);
- return ret;
+static struct event_idle *event_glib_add_idle(int priority, struct callback *cb) {
+ struct event_idle *ret=g_new0(struct event_idle, 1);
+ ret->cb=cb;
+ ret->source = g_idle_add_full(G_PRIORITY_HIGH_IDLE+priority, (GSourceFunc)event_glib_call_idle, (gpointer)ret, NULL);
+ return ret;
}
-static void
-event_glib_remove_idle(struct event_idle *ev)
-{
- if (! ev)
- return;
- g_source_remove(ev->source);
- g_free(ev);
+static void event_glib_remove_idle(struct event_idle *ev) {
+ if (! ev)
+ return;
+ g_source_remove(ev->source);
+ g_free(ev);
}
-static void
-event_glib_call_callback(struct callback_list *cb)
-{
-/*
- Idea for implementation:
- Create a pipe then use add_watch
- add callback to a queue
- from here write to the pipe to wakeup the pool
- then from the gui thread process the callback queue
-*/
+static void event_glib_call_callback(struct callback_list *cb) {
+ /*
+ Idea for implementation:
+ Create a pipe then use add_watch
+ add callback to a queue
+ from here write to the pipe to wakeup the pool
+ then from the gui thread process the callback queue
+ */
}
static struct event_methods event_glib_methods = {
- event_glib_main_loop_run,
- event_glib_main_loop_quit,
- event_glib_add_watch,
- event_glib_remove_watch,
- event_glib_add_timeout,
- event_glib_remove_timeout,
- event_glib_add_idle,
- event_glib_remove_idle,
- event_glib_call_callback,
+ event_glib_main_loop_run,
+ event_glib_main_loop_quit,
+ event_glib_add_watch,
+ event_glib_remove_watch,
+ event_glib_add_timeout,
+ event_glib_remove_timeout,
+ event_glib_add_idle,
+ event_glib_remove_idle,
+ event_glib_call_callback,
};
struct event_priv {
- int data;
+ int data;
};
-static struct event_priv*
-event_glib_new(struct event_methods *meth)
-{
- *meth=event_glib_methods;
- return (struct event_priv *)event_glib_new;
+static struct event_priv* event_glib_new(struct event_methods *meth) {
+ *meth=event_glib_methods;
+ return (struct event_priv *)event_glib_new;
}
-void
-event_glib_init(void)
-{
- plugin_register_category_event("glib", event_glib_new);
+void event_glib_init(void) {
+ plugin_register_category_event("glib", event_glib_new);
}
diff --git a/navit/fib-1.1/configure b/navit/fib-1.1/configure
deleted file mode 100755
index 62eaa3d01..000000000
--- a/navit/fib-1.1/configure
+++ /dev/null
@@ -1,1045 +0,0 @@
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
-
-ac_prev=
-for ac_option
-do
-
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$ac_optarg" ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file="$ac_optarg" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix="$ac_optarg" ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he)
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$ac_optarg" ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir="$ac_optarg" ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir="$ac_optarg" ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir="$ac_optarg" ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir="$ac_optarg" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir="$ac_optarg" ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir="$ac_optarg" ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir="$ac_optarg" ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix="$ac_optarg" ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix="$ac_optarg" ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix="$ac_optarg" ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name="$ac_optarg" ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir="$ac_optarg" ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir="$ac_optarg" ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site="$ac_optarg" ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir="$ac_optarg" ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir="$ac_optarg" ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.13"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes="$ac_optarg" ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries="$ac_optarg" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set these to C if already set. These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=fib.c
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-ac_exeext=
-ac_objext=o
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-
-
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:529: checking how to run the C preprocessor" >&5
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 544 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:550: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 561 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:567: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -nologo -E"
- cat > conftest.$ac_ext <<EOF
-#line 578 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:584: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:609: checking for ANSI C header files" >&5
-if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 614 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:622: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- ac_cv_header_stdc=yes
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 639 "configure"
-#include "confdefs.h"
-#include <string.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "memchr" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 657 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "free" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-if test "$cross_compiling" = yes; then
- :
-else
- cat > conftest.$ac_ext <<EOF
-#line 678 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int main () { int i; for (i = 0; i < 256; i++)
-if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
-exit (0); }
-
-EOF
-if { (eval echo configure:689: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- :
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_header_stdc=no
-fi
-rm -fr conftest*
-fi
-
-fi
-fi
-
-echo "$ac_t""$ac_cv_header_stdc" 1>&6
-if test $ac_cv_header_stdc = yes; then
- cat >> confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-for ac_hdr in limits.h
-do
-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:716: checking for $ac_hdr" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 721 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:726: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-
-echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:754: checking for inline" >&5
-if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_cv_c_inline=no
-for ac_kw in inline __inline__ __inline; do
- cat > conftest.$ac_ext <<EOF
-#line 761 "configure"
-#include "confdefs.h"
-
-int main() {
-} $ac_kw foo() {
-; return 0; }
-EOF
-if { (eval echo configure:768: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_c_inline=$ac_kw; break
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
-fi
-rm -f conftest*
-done
-
-fi
-
-echo "$ac_t""$ac_cv_c_inline" 1>&6
-case "$ac_cv_c_inline" in
- inline | yes) ;;
- no) cat >> confdefs.h <<\EOF
-#define inline
-EOF
- ;;
- *) cat >> confdefs.h <<EOF
-#define inline $ac_cv_c_inline
-EOF
- ;;
-esac
-
-
-
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote substitution
- # turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- -e "s/'/'\\\\''/g" \
- -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
- ;;
- esac >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-cat > conftest.defs <<\EOF
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
-s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
-s%\[%\\&%g
-s%\]%\\&%g
-s%\$%$$%g
-EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
-rm -f conftest.defs
-
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.13"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-
-trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@SHELL@%$SHELL%g
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@FFLAGS@%$FFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@CPP@%$CPP%g
-
-CEOF
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
- else
- sed "${ac_end}q" conftest.subs > conftest.s$ac_file
- fi
- if test ! -s conftest.s$ac_file; then
- ac_more_lines=false
- rm -f conftest.s$ac_file
- else
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f conftest.s$ac_file"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
- fi
- ac_file=`expr $ac_file + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_cmds`
- fi
-done
-if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
-fi
-EOF
-
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
-
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
-
- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
-
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
diff --git a/navit/fib-1.1/configure.in b/navit/fib-1.1/configure.in
deleted file mode 100644
index 827015270..000000000
--- a/navit/fib-1.1/configure.in
+++ /dev/null
@@ -1,17 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT(fib.c)
-
-dnl Checks for programs.
-
-dnl Checks for libraries.
-
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS(limits.h)
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_INLINE
-
-dnl Checks for library functions.
-
-AC_OUTPUT(Makefile)
diff --git a/navit/file.c b/navit/file.c
index 8363b6a8b..8d0365499 100644
--- a/navit/file.c
+++ b/navit/file.c
@@ -44,8 +44,6 @@
#include <netdb.h>
#endif
-extern char *version;
-
#ifdef CACHE_SIZE
static GHashTable *file_name_hash;
#endif
@@ -58,10 +56,10 @@ static struct cache *file_cache;
#endif
struct file_cache_id {
- long long offset;
- int size;
- int file_name_id;
- int method;
+ long long offset;
+ int size;
+ int file_name_id;
+ int method;
} ATTRIBUTE_PACKED;
#ifdef HAVE_PRAGMA_PACK
@@ -69,171 +67,159 @@ struct file_cache_id {
#endif
#ifdef HAVE_SOCKET
-static int
-file_socket_connect(char *host, char *service)
-{
- struct addrinfo hints;
- struct addrinfo *result, *rp;
- int fd=-1,s;
-
- memset(&hints, 0, sizeof(struct addrinfo));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = 0;
- hints.ai_protocol = 0;
- s = getaddrinfo(host, service, &hints, &result);
- if (s != 0) {
- dbg(lvl_error,"getaddrinfo error %s\n",gai_strerror(s));
- return -1;
- }
- for (rp = result; rp != NULL; rp = rp->ai_next) {
- fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
- if (fd != -1) {
- if (connect(fd, rp->ai_addr, rp->ai_addrlen) != -1)
- break;
- close(fd);
- fd=-1;
- }
- }
- freeaddrinfo(result);
- return fd;
-}
-
-static void
-file_http_request(struct file *file, char *method, char *host, char *path, char *header, int persistent)
-{
- char *request=g_strdup_printf("%s %s HTTP/1.0\r\nUser-Agent: navit %s\r\nHost: %s\r\n%s%s%s\r\n",method,path,version,host,persistent?"Connection: Keep-Alive\r\n":"",header?header:"",header?"\r\n":"");
- write(file->fd, request, strlen(request));
- dbg(lvl_debug,"%s\n",request);
- file->requests++;
-}
-
-static int
-file_request_do(struct file *file, struct attr **options, int connect)
-{
- struct attr *attr;
- char *name;
-
- if (!options)
- return 0;
- attr=attr_search(options, NULL, attr_url);
- if (!attr)
- return 0;
- name=attr->u.str;
- if (!name)
- return 0;
- g_free(file->name);
- file->name = g_strdup(name);
- if (!strncmp(name,"http://",7)) {
- char *host=g_strdup(name+7);
- char *port=strchr(host,':');
- char *path=strchr(name+7,'/');
- char *method="GET";
- char *header=NULL;
- int persistent=0;
- if ((attr=attr_search(options, NULL, attr_http_method)) && attr->u.str)
- method=attr->u.str;
- if ((attr=attr_search(options, NULL, attr_http_header)) && attr->u.str)
- header=attr->u.str;
- if ((attr=attr_search(options, NULL, attr_persistent)))
- persistent=attr->u.num;
- if (path)
- host[path-name-7]='\0';
- if (port)
- *port++='\0';
- dbg(lvl_debug,"host=%s path=%s\n",host,path);
- if (connect)
- file->fd=file_socket_connect(host,port?port:"80");
- file_http_request(file,method,host,path,header,persistent);
- file->special=1;
- g_free(host);
- }
- return 1;
+static int file_socket_connect(char *host, char *service) {
+ struct addrinfo hints;
+ struct addrinfo *result, *rp;
+ int fd=-1,s;
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = 0;
+ hints.ai_protocol = 0;
+ s = getaddrinfo(host, service, &hints, &result);
+ if (s != 0) {
+ dbg(lvl_error,"getaddrinfo error %s",gai_strerror(s));
+ return -1;
+ }
+ for (rp = result; rp != NULL; rp = rp->ai_next) {
+ fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
+ if (fd != -1) {
+ if (connect(fd, rp->ai_addr, rp->ai_addrlen) != -1)
+ break;
+ close(fd);
+ fd=-1;
+ }
+ }
+ freeaddrinfo(result);
+ return fd;
+}
+
+static void file_http_request(struct file *file, char *method, char *host, char *path, char *header, int persistent) {
+ char *request=g_strdup_printf("%s %s HTTP/1.0\r\nUser-Agent: navit %s\r\nHost: %s\r\n%s%s%s\r\n",method,path,
+ NAVIT_VERSION,
+ host,persistent?"Connection: Keep-Alive\r\n":"",header?header:"",header?"\r\n":"");
+ write(file->fd, request, strlen(request));
+ dbg(lvl_debug,"%s",request);
+ file->requests++;
+}
+
+static int file_request_do(struct file *file, struct attr **options, int connect) {
+ struct attr *attr;
+ char *name;
+
+ if (!options)
+ return 0;
+ attr=attr_search(options, NULL, attr_url);
+ if (!attr)
+ return 0;
+ name=attr->u.str;
+ if (!name)
+ return 0;
+ g_free(file->name);
+ file->name = g_strdup(name);
+ if (!strncmp(name,"http://",7)) {
+ char *host=g_strdup(name+7);
+ char *port=strchr(host,':');
+ char *path=strchr(name+7,'/');
+ char *method="GET";
+ char *header=NULL;
+ int persistent=0;
+ if ((attr=attr_search(options, NULL, attr_http_method)) && attr->u.str)
+ method=attr->u.str;
+ if ((attr=attr_search(options, NULL, attr_http_header)) && attr->u.str)
+ header=attr->u.str;
+ if ((attr=attr_search(options, NULL, attr_persistent)))
+ persistent=attr->u.num;
+ if (path)
+ host[path-name-7]='\0';
+ if (port)
+ *port++='\0';
+ dbg(lvl_debug,"host=%s path=%s",host,path);
+ if (connect)
+ file->fd=file_socket_connect(host,port?port:"80");
+ file_http_request(file,method,host,path,header,persistent);
+ file->special=1;
+ g_free(host);
+ }
+ return 1;
}
#endif
-static unsigned char *
-file_http_header_end(unsigned char *str, int len)
-{
- int i;
- for (i=0; i+1<len; i+=2) {
- if (str[i+1]=='\n') {
- if (str[i]=='\n')
- return str+i+2;
- else if (str[i]=='\r' && i+3<len && str[i+2]=='\r' && str[i+3]=='\n')
- return str+i+4;
- --i;
- } else if (str[i+1]=='\r') {
- if (i+4<len && str[i+2]=='\n' && str[i+3]=='\r' && str[i+4]=='\n')
- return str+i+5;
- --i;
- }
- }
- return NULL;
-}
-
-int
-file_request(struct file *f, struct attr **options)
-{
+static unsigned char *file_http_header_end(unsigned char *str, int len) {
+ int i;
+ for (i=0; i+1<len; i+=2) {
+ if (str[i+1]=='\n') {
+ if (str[i]=='\n')
+ return str+i+2;
+ else if (str[i]=='\r' && i+3<len && str[i+2]=='\r' && str[i+3]=='\n')
+ return str+i+4;
+ --i;
+ } else if (str[i+1]=='\r') {
+ if (i+4<len && str[i+2]=='\n' && str[i+3]=='\r' && str[i+4]=='\n')
+ return str+i+5;
+ --i;
+ }
+ }
+ return NULL;
+}
+
+int file_request(struct file *f, struct attr **options) {
#ifdef HAVE_SOCKET
- return file_request_do(f, options, 0);
+ return file_request_do(f, options, 0);
#else
- return 0;
+ return 0;
#endif
}
-char *
-file_http_header(struct file *f, char *header)
-{
- if (!f->headers)
- return NULL;
- return g_hash_table_lookup(f->headers, header);
+char *file_http_header(struct file *f, char *header) {
+ if (!f->headers)
+ return NULL;
+ return g_hash_table_lookup(f->headers, header);
}
struct file *
-file_create(char *name, struct attr **options)
-{
- struct file *file= g_new0(struct file,1);
- struct attr *attr;
- int open_flags=O_LARGEFILE|O_BINARY;
+file_create(char *name, struct attr **options) {
+ struct file *file= g_new0(struct file,1);
+ struct attr *attr;
+ int open_flags=O_LARGEFILE|O_BINARY;
- if (options && (attr=attr_search(options, NULL, attr_url))) {
+ if (options && (attr=attr_search(options, NULL, attr_url))) {
#ifdef HAVE_SOCKET
- file_request_do(file, options, 1);
+ file_request_do(file, options, 1);
#endif
- } else {
- if (options && (attr=attr_search(options, NULL, attr_readwrite)) && attr->u.num) {
- open_flags |= O_RDWR;
- if ((attr=attr_search(options, NULL, attr_create)) && attr->u.num)
- open_flags |= O_CREAT|O_TRUNC;
- } else
- open_flags |= O_RDONLY;
- file->name = g_strdup(name);
- file->fd=open(name, open_flags, 0666);
- if (file->fd == -1) {
- g_free(file->name);
- g_free(file);
- return NULL;
- }
- dbg(lvl_debug,"fd=%d\n", file->fd);
- file->size=lseek(file->fd, 0, SEEK_END);
- if (file->size < 0)
- file->size=0;
- dbg(lvl_debug,"size="LONGLONG_FMT"\n", file->size);
- file->name_id = (long)atom(name);
- }
+ } else {
+ if (options && (attr=attr_search(options, NULL, attr_readwrite)) && attr->u.num) {
+ open_flags |= O_RDWR;
+ if ((attr=attr_search(options, NULL, attr_create)) && attr->u.num)
+ open_flags |= O_CREAT|O_TRUNC;
+ } else
+ open_flags |= O_RDONLY;
+ file->name = g_strdup(name);
+ file->fd=open(name, open_flags, 0666);
+ if (file->fd == -1) {
+ g_free(file->name);
+ g_free(file);
+ return NULL;
+ }
+ dbg(lvl_debug,"fd=%d", file->fd);
+ file->size=lseek(file->fd, 0, SEEK_END);
+ if (file->size < 0)
+ file->size=0;
+ dbg(lvl_debug,"size="LONGLONG_FMT"", file->size);
+ file->name_id = (long)atom(name);
+ }
#ifdef CACHE_SIZE
- if (!options || !(attr=attr_search(options, NULL, attr_cache)) || attr->u.num)
- file->cache=1;
+ if (!options || !(attr=attr_search(options, NULL, attr_cache)) || attr->u.num)
+ file->cache=1;
#endif
- dbg_assert(file != NULL);
- return file;
+ dbg_assert(file != NULL);
+ return file;
}
#if 0
struct file *
-file_create_url(char *url)
-{
+file_create_url(char *url) {
}
#endif
@@ -244,599 +230,541 @@ file_create_url(char *url)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
-int file_is_dir(char *name)
-{
- struct stat buf;
- if (! stat(name, &buf)) {
- return S_ISDIR(buf.st_mode);
- }
- return 0;
+/**
+ * @brief Check if a given path corresponds to a directory
+ *
+ * @param name The path to the filesystem element
+ * @return !=0 (true) if @p name is a directory
+ */
+int file_is_dir(const char *name) {
+ struct stat buf;
+ if (! stat(name, &buf)) {
+ return S_ISDIR(buf.st_mode);
+ }
+ return 0;
}
-int file_is_reg(char *name)
-{
- struct stat buf;
- if (! stat(name, &buf)) {
- return S_ISREG(buf.st_mode);
- }
- return 0;
+/**
+ * @brief Check if a given path corresponds to a regular file
+ *
+ * @param name The path to the filesystem element
+ * @return !=0 (true) if @p name is a regular file
+ */
+int file_is_reg(const char *name) {
+ struct stat buf;
+ if (! stat(name, &buf)) {
+ return S_ISREG(buf.st_mode);
+ }
+ return 0;
}
-long long
-file_size(struct file *file)
-{
- return file->size;
+long long file_size(struct file *file) {
+ return file->size;
}
-int file_mkdir(char *name, int pflag)
-{
- char *buffer=g_alloca(sizeof(char)*(strlen(name)+1));
- int ret;
- char *next;
- dbg(lvl_debug,"enter %s %d\n",name,pflag);
- if (!pflag) {
- if (file_is_dir(name))
- return 0;
+int file_mkdir(char *name, int pflag) {
+ char *buffer=g_alloca(sizeof(char)*(strlen(name)+1));
+ int ret;
+ char *next;
+ dbg(lvl_debug,"enter %s %d",name,pflag);
+ if (!pflag) {
+ if (file_is_dir(name))
+ return 0;
#if defined HAVE_API_WIN32_BASE || defined _MSC_VER
- return mkdir(name);
+ return mkdir(name);
#else
- return mkdir(name, 0777);
+ return mkdir(name, 0777);
#endif
- }
- strcpy(buffer, name);
- next=buffer;
- while ((next=strchr(next, '/'))) {
- *next='\0';
- if (*buffer) {
- ret=file_mkdir(buffer, 0);
- if (ret)
- return ret;
- }
- *next++='/';
- }
- if (pflag == 2)
- return 0;
- return file_mkdir(buffer, 0);
-}
-
-int
-file_mmap(struct file *file)
-{
+ }
+ strcpy(buffer, name);
+ next=buffer;
+ while ((next=strchr(next, '/'))) {
+ *next='\0';
+ if (*buffer) {
+ ret=file_mkdir(buffer, 0);
+ if (ret)
+ return ret;
+ }
+ *next++='/';
+ }
+ if (pflag == 2)
+ return 0;
+ return file_mkdir(buffer, 0);
+}
+
+int file_mmap(struct file *file) {
#if 0
- int mmap_size=file->size+1024*1024;
+ int mmap_size=file->size+1024*1024;
#else
- int mmap_size=file->size;
+ int mmap_size=file->size;
#endif
#ifdef HAVE_API_WIN32_BASE
- file->begin = (unsigned char*)mmap_readonly_win32( file->name, &file->map_handle, &file->map_file );
+ file->begin = (unsigned char*)mmap_readonly_win32( file->name, &file->map_handle, &file->map_file );
#else
- file->begin=mmap(NULL, mmap_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, file->fd, 0);
- dbg_assert(file->begin != NULL);
- if (file->begin == (void *)0xffffffff) {
- perror("mmap");
- return 0;
- }
+ file->begin=mmap(NULL, mmap_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, file->fd, 0);
+ dbg_assert(file->begin != NULL);
+ if (file->begin == (void *)0xffffffff) {
+ perror("mmap");
+ return 0;
+ }
#endif
- dbg_assert(file->begin != (void *)0xffffffff);
- file->mmap_end=file->begin+mmap_size;
- file->end=file->begin+file->size;
-
- return 1;
-}
-
-unsigned char *
-file_data_read(struct file *file, long long offset, int size)
-{
- void *ret;
- if (file->special)
- return NULL;
- if (file->begin)
- return file->begin+offset;
- if (file->cache) {
- struct file_cache_id id={offset,size,file->name_id,0};
- ret=cache_lookup(file_cache,&id);
- if (ret)
- return ret;
- ret=cache_insert_new(file_cache,&id,size);
- } else
- ret=g_malloc(size);
- lseek(file->fd, offset, SEEK_SET);
- if (read(file->fd, ret, size) != size) {
- file_data_free(file, ret);
- ret=NULL;
- }
- return ret;
-
-}
-
-static void
-file_process_headers(struct file *file, unsigned char *headers)
-{
- char *tok;
- char *cl;
- if (file->headers)
- g_hash_table_destroy(file->headers);
- file->headers=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
- while ((tok=strtok((char*)headers, "\r\n"))) {
- char *sep;
- tok=g_strdup(tok);
- sep=strchr(tok,':');
- if (!sep)
- sep=strchr(tok,'/');
- if (!sep) {
- g_free(tok);
- continue;
- }
- *sep++='\0';
- if (*sep == ' ')
- sep++;
- strtolower(tok, tok);
- dbg(lvl_debug,"header '%s'='%s'\n",tok,sep);
- g_hash_table_insert(file->headers, tok, sep);
- headers=NULL;
- }
- cl=g_hash_table_lookup(file->headers, "content-length");
- if (cl)
+ dbg_assert(file->begin != (void *)0xffffffff);
+ file->mmap_end=file->begin+mmap_size;
+ file->end=file->begin+file->size;
+
+ return 1;
+}
+
+unsigned char *file_data_read(struct file *file, long long offset, int size) {
+ void *ret;
+ if (file->special)
+ return NULL;
+ if (file->begin)
+ return file->begin+offset;
+ if (file->cache) {
+ struct file_cache_id id= {offset,size,file->name_id,0};
+ ret=cache_lookup(file_cache,&id);
+ if (ret)
+ return ret;
+ ret=cache_insert_new(file_cache,&id,size);
+ } else
+ ret=g_malloc(size);
+ lseek(file->fd, offset, SEEK_SET);
+ if (read(file->fd, ret, size) != size) {
+ file_data_free(file, ret);
+ ret=NULL;
+ }
+ return ret;
+
+}
+
+static void file_process_headers(struct file *file, unsigned char *headers) {
+ char *tok;
+ char *cl;
+ if (file->headers)
+ g_hash_table_destroy(file->headers);
+ file->headers=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ while ((tok=strtok((char*)headers, "\r\n"))) {
+ char *sep;
+ tok=g_strdup(tok);
+ sep=strchr(tok,':');
+ if (!sep)
+ sep=strchr(tok,'/');
+ if (!sep) {
+ g_free(tok);
+ continue;
+ }
+ *sep++='\0';
+ if (*sep == ' ')
+ sep++;
+ strtolower(tok, tok);
+ dbg(lvl_debug,"header '%s'='%s'",tok,sep);
+ g_hash_table_insert(file->headers, tok, sep);
+ headers=NULL;
+ }
+ cl=g_hash_table_lookup(file->headers, "content-length");
+ if (cl)
#ifdef HAVE__ATOI64
- file->size=_atoi64(cl);
+ file->size=_atoi64(cl);
#else
- file->size=atoll(cl);
+ file->size=atoll(cl);
#endif
}
-static void
-file_shift_buffer(struct file *file, int amount)
-{
- memmove(file->buffer, file->buffer+amount, file->buffer_len-amount);
- file->buffer_len-=amount;
-}
-
-unsigned char *
-file_data_read_special(struct file *file, int size, int *size_ret)
-{
- unsigned char *ret,*hdr;
- int rets=0,rd;
- int buffer_size=8192;
- int eof=0;
- if (!file->special)
- return NULL;
- if (!file->buffer)
- file->buffer=g_malloc(buffer_size);
- ret=g_malloc(size);
- while ((size > 0 || file->requests) && (!eof || file->buffer_len)) {
- int toread=buffer_size-file->buffer_len;
- if (toread >= 4096 && !eof) {
- if (!file->requests && toread > size)
- toread=size;
- rd=read(file->fd, file->buffer+file->buffer_len, toread);
- if (rd > 0) {
- file->buffer_len+=rd;
- } else
- eof=1;
- }
- if (file->requests) {
- dbg(lvl_debug,"checking header\n");
- if ((hdr=file_http_header_end(file->buffer, file->buffer_len))) {
- hdr[-1]='\0';
- dbg(lvl_debug,"found %s\n",file->buffer);
- file_process_headers(file, file->buffer);
- file_shift_buffer(file, hdr-file->buffer);
- file->requests--;
- if (file_http_header(file, "location"))
- break;
- }
- }
- if (!file->requests) {
- rd=file->buffer_len;
- if (rd > size)
- rd=size;
- memcpy(ret+rets, file->buffer, rd);
- file_shift_buffer(file, rd);
- rets+=rd;
- size-=rd;
- }
- }
- *size_ret=rets;
- return ret;
-}
-
-unsigned char *
-file_data_read_all(struct file *file)
-{
- return file_data_read(file, 0, file->size);
-}
-
-void
-file_data_flush(struct file *file, long long offset, int size)
-{
- if (file->cache) {
- struct file_cache_id id={offset,size,file->name_id,0};
- cache_flush(file_cache,&id);
- dbg(lvl_debug,"Flushing "LONGLONG_FMT" %d bytes\n",offset,size);
- }
-}
-
-int
-file_data_write(struct file *file, long long offset, int size, const void *data)
-{
- file_data_flush(file, offset, size);
- lseek(file->fd, offset, SEEK_SET);
- if (write(file->fd, data, size) != size)
- return 0;
- if (file->size < offset+size)
- file->size=offset+size;
- return 1;
-}
-
-int
-file_get_contents(char *name, unsigned char **buffer, int *size)
-{
- struct file *file;
- file=file_create(name, 0);
- if (!file)
- return 0;
- file->cache=0;
- *size=file_size(file);
- *buffer=file_data_read_all(file);
- file_destroy(file);
- return 1;
-}
-
-
-static int
-uncompress_int(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
-
- err = inflateInit2(&stream, -MAX_WBITS);
- if (err != Z_OK) return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = stream.total_out;
-
- err = inflateEnd(&stream);
- return err;
-}
-
-unsigned char *
-file_data_read_compressed(struct file *file, long long offset, int size, int size_uncomp)
-{
- void *ret;
- char *buffer = 0;
- uLongf destLen=size_uncomp;
-
- if (file->cache) {
- struct file_cache_id id={offset,size,file->name_id,1};
- ret=cache_lookup(file_cache,&id);
- if (ret)
- return ret;
- ret=cache_insert_new(file_cache,&id,size_uncomp);
- } else
- ret=g_malloc(size_uncomp);
- lseek(file->fd, offset, SEEK_SET);
-
- buffer = (char *)g_malloc(size);
- if (read(file->fd, buffer, size) != size) {
- g_free(ret);
- ret=NULL;
- } else {
- if (uncompress_int(ret, &destLen, (Bytef *)buffer, size) != Z_OK) {
- dbg(lvl_error,"uncompress failed\n");
- g_free(ret);
- ret=NULL;
- }
- }
- g_free(buffer);
-
- return ret;
-}
-
-void
-file_data_free(struct file *file, unsigned char *data)
-{
- if (file->begin) {
- if (data == file->begin)
- return;
- if (data >= file->begin && data < file->end)
- return;
- }
- if (file->cache && data) {
- cache_entry_destroy(file_cache, data);
- } else
- g_free(data);
-}
-
-void
-file_data_remove(struct file *file, unsigned char *data)
-{
- if (file->begin) {
- if (data == file->begin)
- return;
- if (data >= file->begin && data < file->end)
- return;
- }
- if (file->cache && data) {
- cache_flush_data(file_cache, data);
- } else
- g_free(data);
-}
-
-int
-file_exists(char const *name)
-{
- struct stat buf;
- if (! stat(name, &buf))
- return 1;
- return 0;
-}
-
-void
-file_remap_readonly(struct file *f)
-{
+static void file_shift_buffer(struct file *file, int amount) {
+ memmove(file->buffer, file->buffer+amount, file->buffer_len-amount);
+ file->buffer_len-=amount;
+}
+
+unsigned char *file_data_read_special(struct file *file, int size, int *size_ret) {
+ unsigned char *ret,*hdr;
+ int rets=0,rd;
+ int buffer_size=8192;
+ int eof=0;
+ if (!file->special)
+ return NULL;
+ if (!file->buffer)
+ file->buffer=g_malloc(buffer_size);
+ ret=g_malloc(size);
+ while ((size > 0 || file->requests) && (!eof || file->buffer_len)) {
+ int toread=buffer_size-file->buffer_len;
+ if (toread >= 4096 && !eof) {
+ if (!file->requests && toread > size)
+ toread=size;
+ rd=read(file->fd, file->buffer+file->buffer_len, toread);
+ if (rd > 0) {
+ file->buffer_len+=rd;
+ } else
+ eof=1;
+ }
+ if (file->requests) {
+ dbg(lvl_debug,"checking header");
+ if ((hdr=file_http_header_end(file->buffer, file->buffer_len))) {
+ hdr[-1]='\0';
+ dbg(lvl_debug,"found %s",file->buffer);
+ file_process_headers(file, file->buffer);
+ file_shift_buffer(file, hdr-file->buffer);
+ file->requests--;
+ if (file_http_header(file, "location"))
+ break;
+ }
+ }
+ if (!file->requests) {
+ rd=file->buffer_len;
+ if (rd > size)
+ rd=size;
+ memcpy(ret+rets, file->buffer, rd);
+ file_shift_buffer(file, rd);
+ rets+=rd;
+ size-=rd;
+ }
+ }
+ *size_ret=rets;
+ return ret;
+}
+
+unsigned char *file_data_read_all(struct file *file) {
+ return file_data_read(file, 0, file->size);
+}
+
+void file_data_flush(struct file *file, long long offset, int size) {
+ if (file->cache) {
+ struct file_cache_id id= {offset,size,file->name_id,0};
+ cache_flush(file_cache,&id);
+ dbg(lvl_debug,"Flushing "LONGLONG_FMT" %d bytes",offset,size);
+ }
+}
+
+int file_data_write(struct file *file, long long offset, int size, const void *data) {
+ file_data_flush(file, offset, size);
+ lseek(file->fd, offset, SEEK_SET);
+ if (write(file->fd, data, size) != size)
+ return 0;
+ if (file->size < offset+size)
+ file->size=offset+size;
+ return 1;
+}
+
+int file_get_contents(char *name, unsigned char **buffer, int *size) {
+ struct file *file;
+ file=file_create(name, 0);
+ if (!file)
+ return 0;
+ file->cache=0;
+ *size=file_size(file);
+ *buffer=file_data_read_all(file);
+ file_destroy(file);
+ return 1;
+}
+
+
+static int uncompress_int(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) {
+ z_stream stream;
+ int err;
+
+ stream.next_in = (Bytef*)source;
+ stream.avail_in = (uInt)sourceLen;
+ stream.next_out = dest;
+ stream.avail_out = (uInt)*destLen;
+
+ stream.zalloc = (alloc_func)0;
+ stream.zfree = (free_func)0;
+
+ err = inflateInit2(&stream, -MAX_WBITS);
+ if (err != Z_OK) return err;
+
+ err = inflate(&stream, Z_FINISH);
+ if (err != Z_STREAM_END) {
+ inflateEnd(&stream);
+ if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
+ return Z_DATA_ERROR;
+ return err;
+ }
+ *destLen = stream.total_out;
+
+ err = inflateEnd(&stream);
+ return err;
+}
+
+unsigned char *file_data_read_compressed(struct file *file, long long offset, int size, int size_uncomp) {
+ void *ret;
+ char *buffer = 0;
+ uLongf destLen=size_uncomp;
+
+ if (file->cache) {
+ struct file_cache_id id= {offset,size,file->name_id,1};
+ ret=cache_lookup(file_cache,&id);
+ if (ret)
+ return ret;
+ ret=cache_insert_new(file_cache,&id,size_uncomp);
+ } else
+ ret=g_malloc(size_uncomp);
+ lseek(file->fd, offset, SEEK_SET);
+
+ buffer = (char *)g_malloc(size);
+ if (read(file->fd, buffer, size) != size) {
+ g_free(ret);
+ ret=NULL;
+ } else {
+ if (uncompress_int(ret, &destLen, (Bytef *)buffer, size) != Z_OK) {
+ dbg(lvl_error,"uncompress failed");
+ g_free(ret);
+ ret=NULL;
+ }
+ }
+ g_free(buffer);
+
+ return ret;
+}
+
+void file_data_free(struct file *file, unsigned char *data) {
+ if (file->begin) {
+ if (data == file->begin)
+ return;
+ if (data >= file->begin && data < file->end)
+ return;
+ }
+ if (file->cache && data) {
+ cache_entry_destroy(file_cache, data);
+ } else
+ g_free(data);
+}
+
+void file_data_remove(struct file *file, unsigned char *data) {
+ if (file->begin) {
+ if (data == file->begin)
+ return;
+ if (data >= file->begin && data < file->end)
+ return;
+ }
+ if (file->cache && data) {
+ cache_flush_data(file_cache, data);
+ } else
+ g_free(data);
+}
+
+int file_exists(char const *name) {
+ struct stat buf;
+ if (! stat(name, &buf))
+ return 1;
+ return 0;
+}
+
+void file_remap_readonly(struct file *f) {
#if defined(_WIN32) || defined(__CEGCC__)
#else
- void *begin;
- munmap(f->begin, f->size);
- begin=mmap(f->begin, f->size, PROT_READ, MAP_PRIVATE, f->fd, 0);
- if (f->begin != begin)
- printf("remap failed\n");
+ void *begin;
+ munmap(f->begin, f->size);
+ begin=mmap(f->begin, f->size, PROT_READ, MAP_PRIVATE, f->fd, 0);
+ if (f->begin != begin)
+ printf("remap failed\n");
#endif
}
-void
-file_unmap(struct file *f)
-{
+void file_unmap(struct file *f) {
#if defined(_WIN32) || defined(__CEGCC__)
- mmap_unmap_win32( f->begin, f->map_handle , f->map_file );
+ mmap_unmap_win32( f->begin, f->map_handle, f->map_file );
#else
- munmap(f->begin, f->size);
+ munmap(f->begin, f->size);
#endif
}
#ifndef _MSC_VER
-void *
-file_opendir(char *dir)
-{
- return opendir(dir);
-}
-#else
-void *
-file_opendir(char *dir)
-{
- WIN32_FIND_DATAA FindFileData;
- HANDLE hFind = INVALID_HANDLE_VALUE;
+void *file_opendir(char *dir) {
+ return opendir(dir);
+}
+#else
+void *file_opendir(char *dir) {
+ WIN32_FIND_DATAA FindFileData;
+ HANDLE hFind = INVALID_HANDLE_VALUE;
#undef UNICODE // we need FindFirstFileA() which takes an 8-bit c-string
- char* fname=g_alloca(sizeof(char)*(strlen(dir)+4));
- sprintf(fname,"%s\\*",dir);
- hFind = FindFirstFileA(fname, &FindFileData);
- return hFind;
+ char* fname=g_alloca(sizeof(char)*(strlen(dir)+4));
+ sprintf(fname,"%s\\*",dir);
+ hFind = FindFirstFileA(fname, &FindFileData);
+ return hFind;
}
#endif
#ifndef _MSC_VER
-char *
-file_readdir(void *hnd)
-{
- struct dirent *ent;
+char *file_readdir(void *hnd) {
+ struct dirent *ent;
- ent=readdir(hnd);
- if (! ent)
- return NULL;
- return ent->d_name;
+ ent=readdir(hnd);
+ if (! ent)
+ return NULL;
+ return ent->d_name;
}
#else
-char *
-file_readdir(void *hnd)
-{
- WIN32_FIND_DATA FindFileData;
+char *file_readdir(void *hnd) {
+ WIN32_FIND_DATA FindFileData;
- if (FindNextFile(hnd, &FindFileData) ) {
- return FindFileData.cFileName;
- } else {
- return NULL;
- }
+ if (FindNextFile(hnd, &FindFileData) ) {
+ return FindFileData.cFileName;
+ } else {
+ return NULL;
+ }
}
#endif /* _MSC_VER */
#ifndef _MSC_VER
-void
-file_closedir(void *hnd)
-{
- closedir(hnd);
+void file_closedir(void *hnd) {
+ closedir(hnd);
}
#else
-void
-file_closedir(void *hnd)
-{
- FindClose(hnd);
+void file_closedir(void *hnd) {
+ FindClose(hnd);
}
#endif /* _MSC_VER */
struct file *
-file_create_caseinsensitive(char *name, struct attr **options)
-{
- char *dirname=g_alloca(sizeof(char)*(strlen(name)+1));
- char *filename;
- char *p;
- void *d;
- struct file *ret;
-
- ret=file_create(name, options);
- if (ret)
- return ret;
-
- strcpy(dirname, name);
- p=dirname+strlen(name);
- while (p > dirname) {
- if (*p == '/')
- break;
- p--;
- }
- *p=0;
- d=file_opendir(dirname);
- if (d) {
- *p++='/';
- while ((filename=file_readdir(d))) {
- if (!g_ascii_strcasecmp(filename, p)) {
- strcpy(p, filename);
- ret=file_create(dirname, options);
- if (ret)
- break;
- }
- }
- file_closedir(d);
- }
- return ret;
-}
-
-void
-file_fsync(struct file *f)
-{
+file_create_caseinsensitive(char *name, struct attr **options) {
+ char *dirname=g_alloca(sizeof(char)*(strlen(name)+1));
+ char *filename;
+ char *p;
+ void *d;
+ struct file *ret;
+
+ ret=file_create(name, options);
+ if (ret)
+ return ret;
+
+ strcpy(dirname, name);
+ p=dirname+strlen(name);
+ while (p > dirname) {
+ if (*p == '/')
+ break;
+ p--;
+ }
+ *p=0;
+ d=file_opendir(dirname);
+ if (d) {
+ *p++='/';
+ while ((filename=file_readdir(d))) {
+ if (!g_ascii_strcasecmp(filename, p)) {
+ strcpy(p, filename);
+ ret=file_create(dirname, options);
+ if (ret)
+ break;
+ }
+ }
+ file_closedir(d);
+ }
+ return ret;
+}
+
+void file_fsync(struct file *f) {
#ifdef HAVE_FSYNC
- fsync(f->fd);
+ fsync(f->fd);
#endif
}
-void
-file_destroy(struct file *f)
-{
- if (f->headers)
- g_hash_table_destroy(f->headers);
- switch (f->special) {
- case 0:
- case 1:
- close(f->fd);
- break;
- }
-
- if ( f->begin != NULL )
- {
+void file_destroy(struct file *f) {
+ if (f->headers)
+ g_hash_table_destroy(f->headers);
+ switch (f->special) {
+ case 0:
+ case 1:
+ close(f->fd);
+ break;
+ }
+
+ if ( f->begin != NULL ) {
file_unmap( f );
}
- g_free(f->buffer);
- g_free(f->name);
- g_free(f);
+ g_free(f->buffer);
+ g_free(f->name);
+ g_free(f);
}
struct file_wordexp {
- int err;
- char *pattern;
- wordexp_t we;
+ int err;
+ char *pattern;
+ wordexp_t we;
};
struct file_wordexp *
-file_wordexp_new(const char *pattern)
-{
- struct file_wordexp *ret=g_new0(struct file_wordexp, 1);
+file_wordexp_new(const char *pattern) {
+ struct file_wordexp *ret=g_new0(struct file_wordexp, 1);
- ret->pattern=g_strdup(pattern);
- ret->err=wordexp(pattern, &ret->we, 0);
- if (ret->err)
- dbg(lvl_debug,"wordexp('%s') returned %d\n", pattern, ret->err);
- return ret;
+ ret->pattern=g_strdup(pattern);
+ ret->err=wordexp(pattern, &ret->we, 0);
+ if (ret->err)
+ dbg(lvl_debug,"wordexp('%s') returned %d", pattern, ret->err);
+ return ret;
}
-int
-file_wordexp_get_count(struct file_wordexp *wexp)
-{
- if (wexp->err)
- return 1;
- return wexp->we.we_wordc;
+int file_wordexp_get_count(struct file_wordexp *wexp) {
+ if (wexp->err)
+ return 1;
+ return wexp->we.we_wordc;
}
-char **
-file_wordexp_get_array(struct file_wordexp *wexp)
-{
- if (wexp->err)
- return &wexp->pattern;
- return wexp->we.we_wordv;
+char ** file_wordexp_get_array(struct file_wordexp *wexp) {
+ if (wexp->err)
+ return &wexp->pattern;
+ return wexp->we.we_wordv;
}
-void
-file_wordexp_destroy(struct file_wordexp *wexp)
-{
- if (! wexp->err)
- wordfree(&wexp->we);
- g_free(wexp->pattern);
- g_free(wexp);
+void file_wordexp_destroy(struct file_wordexp *wexp) {
+ if (! wexp->err)
+ wordfree(&wexp->we);
+ g_free(wexp->pattern);
+ g_free(wexp);
}
-int
-file_version(struct file *file, int mode)
-{
+int file_version(struct file *file, int mode) {
#ifndef HAVE_API_WIN32_BASE
- struct stat st;
- int error;
- if (mode == 3) {
- long long size=lseek(file->fd, 0, SEEK_END);
- if (file->begin && file->begin+size > file->mmap_end) {
- file->version++;
- } else {
- file->size=size;
- if (file->begin)
- file->end=file->begin+file->size;
- }
- } else {
- if (mode == 2)
- error=stat(file->name, &st);
- else
- error=fstat(file->fd, &st);
- if (error || !file->version || file->mtime != st.st_mtime || file->ctime != st.st_ctime) {
- file->mtime=st.st_mtime;
- file->ctime=st.st_ctime;
- file->version++;
- dbg(lvl_debug,"%s now version %d\n", file->name, file->version);
- }
- }
- return file->version;
+ struct stat st;
+ int error;
+ if (mode == 3) {
+ long long size=lseek(file->fd, 0, SEEK_END);
+ if (file->begin && file->begin+size > file->mmap_end) {
+ file->version++;
+ } else {
+ file->size=size;
+ if (file->begin)
+ file->end=file->begin+file->size;
+ }
+ } else {
+ if (mode == 2)
+ error=stat(file->name, &st);
+ else
+ error=fstat(file->fd, &st);
+ if (error || !file->version || file->mtime != st.st_mtime || file->ctime != st.st_ctime) {
+ file->mtime=st.st_mtime;
+ file->ctime=st.st_ctime;
+ file->version++;
+ dbg(lvl_debug,"%s now version %d", file->name, file->version);
+ }
+ }
+ return file->version;
#else
- return 0;
+ return 0;
#endif
}
-void *
-file_get_os_handle(struct file *file)
-{
- return GINT_TO_POINTER(file->fd);
+void *file_get_os_handle(struct file *file) {
+ return GINT_TO_POINTER(file->fd);
}
-int
-file_set_cache_size(int cache_size)
-{
+int file_set_cache_size(int cache_size) {
#ifdef CACHE_SIZE
- cache_resize(file_cache, cache_size);
- return 1;
+ cache_resize(file_cache, cache_size);
+ return 1;
#else
- return 0;
+ return 0;
#endif
}
-void
-file_init(void)
-{
+void file_init(void) {
#ifdef CACHE_SIZE
- file_name_hash=g_hash_table_new(g_str_hash, g_str_equal);
- file_cache=cache_new(sizeof(struct file_cache_id), CACHE_SIZE);
+ file_name_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ file_cache=cache_new(sizeof(struct file_cache_id), CACHE_SIZE);
#endif
- if(sizeof(off_t)<8)
- dbg(lvl_error,"Maps larger than 2GB are not supported by this binary, sizeof(off_t)=%zu\n",sizeof(off_t));
+ if(sizeof(off_t)<8)
+ dbg(lvl_error,"Maps larger than 2GB are not supported by this binary, sizeof(off_t)=%zu",sizeof(off_t));
}
diff --git a/navit/file.h b/navit/file.h
index 46dbc4c99..8105302ba 100644
--- a/navit/file.h
+++ b/navit/file.h
@@ -44,7 +44,7 @@ struct file {
#ifndef __CEGCC__
time_t mtime;
time_t ctime;
- int version;
+ int version;
#endif
#if defined(_WIN32) || defined(__CEGCC__)
long map_handle;
@@ -65,7 +65,8 @@ struct attr;
int file_request(struct file *f, struct attr **options);
char *file_http_header(struct file *f, char *header);
struct file *file_create(char *name, struct attr **options);
-int file_is_dir(char *name);
+int file_is_dir(const char *name);
+int file_is_reg(const char *name);
long long file_size(struct file *file);
int file_mkdir(char *name, int pflag);
int file_mmap(struct file *file);
@@ -95,7 +96,6 @@ int file_version(struct file *file, int byname);
void *file_get_os_handle(struct file *file);
int file_set_cache_size(int cache_size);
void file_init(void);
-int file_is_reg(char *name);
void file_data_remove(struct file *file, unsigned char *data);
/* end of prototypes */
diff --git a/navit/font/freetype/CMakeLists.txt b/navit/font/freetype/CMakeLists.txt
index 88470e8ff..c8c945e68 100644
--- a/navit/font/freetype/CMakeLists.txt
+++ b/navit/font/freetype/CMakeLists.txt
@@ -1,15 +1,15 @@
module_add_library(font_freetype font_freetype.c)
if (FRIBIDI_FOUND)
- include_directories(${FRIBIDI_INCLUDE_DIRS})
- set_property(
- TARGET font_freetype
- APPEND PROPERTY COMPILE_DEFINITIONS USE_FRIBIDI=1
- )
- if (NOT FRIBIDI2_FOUND)
- set_property(
- TARGET font_freetype
- APPEND PROPERTY COMPILE_DEFINITIONS FRIBIDIOLD=1
- )
- endif (NOT FRIBIDI2_FOUND)
+ include_directories(${FRIBIDI_INCLUDE_DIRS})
+ set_property(
+ TARGET font_freetype
+ APPEND PROPERTY COMPILE_DEFINITIONS USE_FRIBIDI=1
+ )
+ if (NOT FRIBIDI2_FOUND)
+ set_property(
+ TARGET font_freetype
+ APPEND PROPERTY COMPILE_DEFINITIONS FRIBIDIOLD=1
+ )
+ endif (NOT FRIBIDI2_FOUND)
endif (FRIBIDI_FOUND)
diff --git a/navit/font/freetype/font_freetype.c b/navit/font/freetype/font_freetype.c
index 0508c5870..bb3a88d21 100644
--- a/navit/font/freetype/font_freetype.c
+++ b/navit/font/freetype/font_freetype.c
@@ -57,21 +57,21 @@
#define COL_SHIFT (COLOR_BITDEPTH-COLOR_BITDEPTH_OUTPUT)
struct font_freetype_font {
- int size;
+ int size;
#if USE_CACHING
#if HAVE_LOOKUP_SCALER
- FTC_ScalerRec scaler;
+ FTC_ScalerRec scaler;
#else
- FTC_ImageTypeRec scaler;
+ FTC_ImageTypeRec scaler;
#endif
- int charmap_index;
+ int charmap_index;
#else
- FT_Face face;
+ FT_Face face;
#endif
};
struct font_priv {
- int data;
+ int data;
};
static struct font_priv dummy;
@@ -86,140 +86,132 @@ static int library_init = 0;
static int library_deinit = 0;
-static void
-font_freetype_get_text_bbox(struct graphics_priv *gr,
- struct font_freetype_font *font, char *text,
- int dx, int dy, struct point *ret,
- int estimate)
-{
- char *p = text;
- FT_BBox bbox;
- FT_UInt glyph_index;
- FT_Glyph glyph;
- FT_Matrix matrix;
- FT_Vector pen;
- int i;
- struct point pt;
- int n, len, x = 0, y = 0;
- pen.x = 0 * 64;
- pen.y = 0 * 64;
+static void font_freetype_get_text_bbox(struct graphics_priv *gr, struct font_freetype_font *font, char *text, int dx, int dy, struct point *ret, int estimate) {
+ char *p = text;
+ FT_BBox bbox;
+ FT_UInt glyph_index;
+ FT_Glyph glyph;
+ FT_Matrix matrix;
+ FT_Vector pen;
+ int i;
+ struct point pt;
+ int n, len, x = 0, y = 0;
+ pen.x = 0 * 64;
+ pen.y = 0 * 64;
#if 0
- matrix.xx = dx;
- matrix.xy = dy;
- matrix.yx = -dy;
- matrix.yy = dx;
+ matrix.xx = dx;
+ matrix.xy = dy;
+ matrix.yx = -dy;
+ matrix.yy = dx;
#else
- matrix.xx = 0x10000;
- matrix.xy = 0;
- matrix.yx = 0;
- matrix.yy = 0x10000;
+ matrix.xx = 0x10000;
+ matrix.xy = 0;
+ matrix.yx = 0;
+ matrix.yy = 0x10000;
#endif
- len = g_utf8_strlen(text, -1);
- if (estimate) {
- bbox.xMin = 0;
- bbox.yMin = 0;
- bbox.yMax = 13*font->size/256;
- bbox.xMax = 9*font->size*len/256;
- } else {
- bbox.xMin = bbox.yMin = 32000;
- bbox.xMax = bbox.yMax = -32000;
+ len = g_utf8_strlen(text, -1);
+ if (estimate) {
+ bbox.xMin = 0;
+ bbox.yMin = 0;
+ bbox.yMax = 13*font->size/256;
+ bbox.xMax = 9*font->size*len/256;
+ } else {
+ bbox.xMin = bbox.yMin = 32000;
+ bbox.xMax = bbox.yMax = -32000;
#if !USE_CACHING
- FT_Set_Transform(font->face, &matrix, &pen);
+ FT_Set_Transform(font->face, &matrix, &pen);
#endif
- for (n = 0; n < len; n++) {
- FT_BBox glyph_bbox;
+ for (n = 0; n < len; n++) {
+ FT_BBox glyph_bbox;
#if USE_CACHING
- FTC_Node anode = NULL;
- FT_Glyph cached_glyph;
- glyph_index = FTC_CMapCache_Lookup(charmap_cache, font->scaler.face_id, font->charmap_index, g_utf8_get_char(p));
+ FTC_Node anode = NULL;
+ FT_Glyph cached_glyph;
+ glyph_index = FTC_CMapCache_Lookup(charmap_cache, font->scaler.face_id, font->charmap_index, g_utf8_get_char(p));
#if HAVE_LOOKUP_SCALER
- FTC_ImageCache_LookupScaler(image_cache, &font->scaler, FT_LOAD_DEFAULT, glyph_index, &cached_glyph, &anode);
+ FTC_ImageCache_LookupScaler(image_cache, &font->scaler, FT_LOAD_DEFAULT, glyph_index, &cached_glyph, &anode);
#else
- FTC_ImageCache_Lookup(image_cache, &font->scaler, glyph_index, &cached_glyph, &anode);
+ FTC_ImageCache_Lookup(image_cache, &font->scaler, glyph_index, &cached_glyph, &anode);
#endif /* HAVE_LOOKUP_SCALER */
- FT_Glyph_Copy(cached_glyph, &glyph);
- FT_Glyph_Transform(glyph, &matrix, &pen);
+ FT_Glyph_Copy(cached_glyph, &glyph);
+ FT_Glyph_Transform(glyph, &matrix, &pen);
#else
- glyph_index = FT_Get_Char_Index(font->face, g_utf8_get_char(p));
- FT_Load_Glyph(font->face, glyph_index, FT_LOAD_DEFAULT);
- FT_Get_Glyph(font->face->glyph, &glyph);
+ glyph_index = FT_Get_Char_Index(font->face, g_utf8_get_char(p));
+ FT_Load_Glyph(font->face, glyph_index, FT_LOAD_DEFAULT);
+ FT_Get_Glyph(font->face->glyph, &glyph);
#endif /* USE_CACHING */
- FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox);
-
- glyph_bbox.xMin += x >> 6;
- glyph_bbox.xMax += x >> 6;
- glyph_bbox.yMin += y >> 6;
- glyph_bbox.yMax += y >> 6;
- x += glyph->advance.x >> 10;
- y -= glyph->advance.y >> 10;
- if (glyph_bbox.xMin < bbox.xMin)
- bbox.xMin = glyph_bbox.xMin;
- if (glyph_bbox.yMin < bbox.yMin)
- bbox.yMin = glyph_bbox.yMin;
- if (glyph_bbox.xMax > bbox.xMax)
- bbox.xMax = glyph_bbox.xMax;
- if (glyph_bbox.yMax > bbox.yMax)
- bbox.yMax = glyph_bbox.yMax;
- p = g_utf8_next_char(p);
-
- FT_Done_Glyph(glyph);
+ FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_pixels, &glyph_bbox);
+
+ glyph_bbox.xMin += x >> 6;
+ glyph_bbox.xMax += x >> 6;
+ glyph_bbox.yMin += y >> 6;
+ glyph_bbox.yMax += y >> 6;
+ x += glyph->advance.x >> 10;
+ y -= glyph->advance.y >> 10;
+ if (glyph_bbox.xMin < bbox.xMin)
+ bbox.xMin = glyph_bbox.xMin;
+ if (glyph_bbox.yMin < bbox.yMin)
+ bbox.yMin = glyph_bbox.yMin;
+ if (glyph_bbox.xMax > bbox.xMax)
+ bbox.xMax = glyph_bbox.xMax;
+ if (glyph_bbox.yMax > bbox.yMax)
+ bbox.yMax = glyph_bbox.yMax;
+ p = g_utf8_next_char(p);
+
+ FT_Done_Glyph(glyph);
#if USE_CACHING
- FTC_Node_Unref(anode, manager);
+ FTC_Node_Unref(anode, manager);
#endif
- }
- if (bbox.xMin > bbox.xMax) {
- bbox.xMin = 0;
- bbox.yMin = 0;
- bbox.xMax = 0;
- bbox.yMax = 0;
- }
- }
- ret[0].x = bbox.xMin;
- ret[0].y = -bbox.yMin;
- ret[1].x = bbox.xMin;
- ret[1].y = -bbox.yMax;
- ret[2].x = bbox.xMax;
- ret[2].y = -bbox.yMax;
- ret[3].x = bbox.xMax;
- ret[3].y = -bbox.yMin;
- if (dy != 0 || dx != 0x10000) {
- for (i = 0 ; i < 4 ; i++) {
- pt=ret[i];
- ret[i].x=(pt.x*dx-pt.y*dy)/0x10000;
- ret[i].y=(pt.y*dx+pt.x*dy)/0x10000;
- }
- }
+ }
+ if (bbox.xMin > bbox.xMax) {
+ bbox.xMin = 0;
+ bbox.yMin = 0;
+ bbox.xMax = 0;
+ bbox.yMax = 0;
+ }
+ }
+ ret[0].x = bbox.xMin;
+ ret[0].y = -bbox.yMin;
+ ret[1].x = bbox.xMin;
+ ret[1].y = -bbox.yMax;
+ ret[2].x = bbox.xMax;
+ ret[2].y = -bbox.yMax;
+ ret[3].x = bbox.xMax;
+ ret[3].y = -bbox.yMin;
+ if (dy != 0 || dx != 0x10000) {
+ for (i = 0 ; i < 4 ; i++) {
+ pt=ret[i];
+ ret[i].x=(pt.x*dx-pt.y*dy)/0x10000;
+ ret[i].y=(pt.y*dx+pt.x*dy)/0x10000;
+ }
+ }
}
-static struct font_freetype_text *
-font_freetype_text_new(char *text, struct font_freetype_font *font, int dx,
- int dy)
-{
- FT_Matrix matrix;
- FT_Vector pen;
- FT_UInt glyph_index;
- int y, n, len, w, h, pixmap_len;
- struct font_freetype_text *ret;
- struct font_freetype_glyph *curr;
- char *p = text;
- unsigned char *gl, *pm;
- FT_BitmapGlyph glyph_bitmap;
- FT_Glyph glyph;
-
- len = g_utf8_strlen(text, -1);
- ret = g_malloc(sizeof(*ret) + len * sizeof(struct text_glyph *));
- ret->glyph_count = len;
-
- matrix.xx = dx;
- matrix.xy = dy;
- matrix.yx = -dy;
- matrix.yy = dx;
-
- pen.x = 0 * 64;
- pen.y = 0 * 64;
+static struct font_freetype_text *font_freetype_text_new(char *text, struct font_freetype_font *font, int dx, int dy) {
+ FT_Matrix matrix;
+ FT_Vector pen;
+ FT_UInt glyph_index;
+ int y, n, len, w, h, pixmap_len;
+ struct font_freetype_text *ret;
+ struct font_freetype_glyph *curr;
+ char *p = text;
+ unsigned char *gl, *pm;
+ FT_BitmapGlyph glyph_bitmap;
+ FT_Glyph glyph;
+
+ len = g_utf8_strlen(text, -1);
+ ret = g_malloc(sizeof(*ret) + len * sizeof(struct text_glyph *));
+ ret->glyph_count = len;
+
+ matrix.xx = dx;
+ matrix.xy = dy;
+ matrix.yx = -dy;
+ matrix.yy = dx;
+
+ pen.x = 0 * 64;
+ pen.y = 0 * 64;
#if !USE_CACHING
- FT_Set_Transform(font->face, &matrix, &pen);
+ FT_Set_Transform(font->face, &matrix, &pen);
#endif
#ifdef USE_FRIBIDI
@@ -237,9 +229,9 @@ font_freetype_text_new(char *text, struct font_freetype_font *font, int dx,
FriBidiStrIndex unicode_len =
#ifdef FRIBIDIOLD
- fribidi_utf8_to_unicode(text, textlen, unicode_text);
+ fribidi_utf8_to_unicode(text, textlen, unicode_text);
#else
- fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, text, textlen, unicode_text);
+ fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, text, textlen, unicode_text);
#endif
fribidi_log2vis(unicode_text, unicode_len, &base, visual_unicode_text, NULL, NULL, NULL);
// TODO: check return value
@@ -252,414 +244,381 @@ font_freetype_text_new(char *text, struct font_freetype_font *font, int dx,
}
#endif /* USE_FRIBIDI */
- for (n = 0; n < len; n++) {
+ for (n = 0; n < len; n++) {
#if USE_CACHING
- FTC_Node anode=NULL;
- FT_Glyph cached_glyph;
- glyph_index = FTC_CMapCache_Lookup(charmap_cache, font->scaler.face_id, font->charmap_index, g_utf8_get_char(p));
+ FTC_Node anode=NULL;
+ FT_Glyph cached_glyph;
+ glyph_index = FTC_CMapCache_Lookup(charmap_cache, font->scaler.face_id, font->charmap_index, g_utf8_get_char(p));
#if HAVE_LOOKUP_SCALER
- FTC_ImageCache_LookupScaler(image_cache, &font->scaler, FT_LOAD_DEFAULT, glyph_index, &cached_glyph, &anode);
+ FTC_ImageCache_LookupScaler(image_cache, &font->scaler, FT_LOAD_DEFAULT, glyph_index, &cached_glyph, &anode);
#else
- FTC_ImageCache_Lookup(image_cache, &font->scaler, glyph_index, &cached_glyph, &anode);
+ FTC_ImageCache_Lookup(image_cache, &font->scaler, glyph_index, &cached_glyph, &anode);
#endif
- FT_Glyph_Copy(cached_glyph, &glyph);
- FT_Glyph_Transform(glyph, &matrix, &pen);
- FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, NULL, TRUE);
+ FT_Glyph_Copy(cached_glyph, &glyph);
+ FT_Glyph_Transform(glyph, &matrix, &pen);
+ FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, NULL, TRUE);
#else
- glyph_index = FT_Get_Char_Index(font->face, g_utf8_get_char(p));
- FT_Load_Glyph(font->face, glyph_index, FT_LOAD_DEFAULT);
- FT_Get_Glyph(font->face->glyph, &glyph);
+ glyph_index = FT_Get_Char_Index(font->face, g_utf8_get_char(p));
+ FT_Load_Glyph(font->face, glyph_index, FT_LOAD_DEFAULT);
+ FT_Get_Glyph(font->face->glyph, &glyph);
#endif
- FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, NULL, TRUE);
- glyph_bitmap = (FT_BitmapGlyph)glyph;
-
- w = glyph_bitmap->bitmap.width;
- h = glyph_bitmap->bitmap.rows;
- if (w && h)
- pixmap_len = (w + 2) * (h + 2);
- else
- pixmap_len = 0;
- curr = g_malloc0(sizeof(*curr) + pixmap_len);
- if (pixmap_len) {
- curr->w = w;
- curr->h = h;
- }
- curr->pixmap = (unsigned char *) (curr + 1);
- ret->glyph[n] = curr;
-
- curr->x = glyph_bitmap->left << 6;
- curr->y = -glyph_bitmap->top << 6;
- for (y = 0; y < h; y++) {
- gl = glyph_bitmap->bitmap.buffer + y * glyph_bitmap->bitmap.pitch;
- pm = curr->pixmap + y * w;
- memcpy(pm, gl, w);
- }
-
- curr->dx = glyph->advance.x >> 10;
- curr->dy = -glyph->advance.y >> 10;
- FT_Done_Glyph(glyph);
+ FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, NULL, TRUE);
+ glyph_bitmap = (FT_BitmapGlyph)glyph;
+
+ w = glyph_bitmap->bitmap.width;
+ h = glyph_bitmap->bitmap.rows;
+ if (w && h)
+ pixmap_len = (w + 2) * (h + 2);
+ else
+ pixmap_len = 0;
+ curr = g_malloc0(sizeof(*curr) + pixmap_len);
+ if (pixmap_len) {
+ curr->w = w;
+ curr->h = h;
+ }
+ curr->pixmap = (unsigned char *) (curr + 1);
+ ret->glyph[n] = curr;
+
+ curr->x = glyph_bitmap->left << 6;
+ curr->y = -glyph_bitmap->top << 6;
+ for (y = 0; y < h; y++) {
+ gl = glyph_bitmap->bitmap.buffer + y * glyph_bitmap->bitmap.pitch;
+ pm = curr->pixmap + y * w;
+ memcpy(pm, gl, w);
+ }
+
+ curr->dx = glyph->advance.x >> 10;
+ curr->dy = -glyph->advance.y >> 10;
+ FT_Done_Glyph(glyph);
#if USE_CACHING
- FTC_Node_Unref(anode, manager);
+ FTC_Node_Unref(anode, manager);
#endif
- p = g_utf8_next_char(p);
- }
- ret->glyph_count = len;
- return ret;
+ p = g_utf8_next_char(p);
+ }
+ ret->glyph_count = len;
+ return ret;
}
/**
* List of font families to use, in order of preference
*/
static char *fontfamilies[] = {
- "Liberation Sans",
- "Arial",
- "NcrBI4nh",
- "luximbi",
- "FreeSans",
- "DejaVu Sans",
- NULL,
+ "Liberation Sans",
+ "Arial",
+ "NcrBI4nh",
+ "luximbi",
+ "FreeSans",
+ "DejaVu Sans",
+ NULL,
};
-static void
-font_destroy(struct graphics_font_priv *font)
-{
- g_free(font);
- /* TODO: free font->face */
+static void font_destroy(struct graphics_font_priv *font) {
+ g_free(font);
+ /* TODO: free font->face */
}
static struct graphics_font_methods font_methods = {
- font_destroy
+ font_destroy
};
-static void
-font_freetype_text_destroy(struct font_freetype_text *text)
-{
- int i;
- struct font_freetype_glyph **gp;
+static void font_freetype_text_destroy(struct font_freetype_text *text) {
+ int i;
+ struct font_freetype_glyph **gp;
- gp = text->glyph;
- i = text->glyph_count;
- while (i-- > 0)
- g_free(*gp++);
- g_free(text);
+ gp = text->glyph;
+ i = text->glyph_count;
+ while (i-- > 0)
+ g_free(*gp++);
+ g_free(text);
}
#if USE_CACHING
-static FT_Error face_requester( FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face* aface )
-{
- FT_Error ret;
- char *fontfile,*fontindex;
- if (! face_id)
- return FT_Err_Invalid_Handle;
- fontfile=g_strdup((char *)face_id);
- dbg(lvl_debug,"fontfile=%s\n", fontfile);
- fontindex=strrchr(fontfile,'/');
- if (! fontindex) {
- g_free(fontfile);
- return FT_Err_Invalid_Handle;
- }
- *fontindex++='\0';
- dbg(lvl_debug,"new face %s %d\n", fontfile, atoi(fontindex));
- ret = FT_New_Face( library, fontfile, atoi(fontindex), aface );
- if(ret) {
- dbg(lvl_error,"Error while creating freetype face: %d\n", ret);
- return ret;
- }
- if((ret = FT_Select_Charmap(*aface, FT_ENCODING_UNICODE))) {
- dbg(lvl_error,"Error while creating freetype face: %d\n", ret);
- }
- return 0;
+static FT_Error face_requester( FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face* aface ) {
+ FT_Error ret;
+ char *fontfile,*fontindex;
+ if (! face_id)
+ return FT_Err_Invalid_Handle;
+ fontfile=g_strdup((char *)face_id);
+ dbg(lvl_debug,"fontfile=%s", fontfile);
+ fontindex=strrchr(fontfile,'/');
+ if (! fontindex) {
+ g_free(fontfile);
+ return FT_Err_Invalid_Handle;
+ }
+ *fontindex++='\0';
+ dbg(lvl_debug,"new face %s %d", fontfile, atoi(fontindex));
+ ret = FT_New_Face( library, fontfile, atoi(fontindex), aface );
+ if(ret) {
+ dbg(lvl_error,"Error while creating freetype face: %d", ret);
+ return ret;
+ }
+ if((ret = FT_Select_Charmap(*aface, FT_ENCODING_UNICODE))) {
+ dbg(lvl_error,"Error while creating freetype face: %d", ret);
+ }
+ return 0;
}
#endif
/** Implementation of font_freetype_methods.font_new */
-static struct font_freetype_font *
-font_freetype_font_new(struct graphics_priv *gr,
- struct graphics_font_methods *meth,
- char *fontfamily, int size, int flags)
-{
- struct font_freetype_font *font =
- g_new(struct font_freetype_font, 1);
- int exact, found=0;
- char **family, **family_sav;
+static struct font_freetype_font *font_freetype_font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size, int flags) {
+ struct font_freetype_font *font =
+ g_new(struct font_freetype_font, 1);
+ int exact, found=0;
+ char **family, **family_sav;
#if USE_CACHING
- char *idstr;
- FT_Face face;
+ char *idstr;
+ FT_Face face;
#endif
#ifndef HAVE_FONTCONFIG
- char *name;
+ char *name;
#endif
- *meth = font_methods;
+ *meth = font_methods;
- if (!library_init) {
- FT_Init_FreeType(&library);
+ if (!library_init) {
+ FT_Init_FreeType(&library);
#if USE_CACHING
- FTC_Manager_New( library, 0, 0, 0, &face_requester, NULL, &manager);
- FTC_ImageCache_New( manager, &image_cache);
- FTC_CMapCache_New( manager, &charmap_cache);
- FTC_SBitCache_New( manager, &sbit_cache);
+ FTC_Manager_New( library, 0, 0, 0, &face_requester, NULL, &manager);
+ FTC_ImageCache_New( manager, &image_cache);
+ FTC_CMapCache_New( manager, &charmap_cache);
+ FTC_SBitCache_New( manager, &sbit_cache);
#endif
- library_init = 1;
- }
- font->size=size;
+ library_init = 1;
+ }
+ font->size=size;
#ifdef HAVE_FONTCONFIG
- dbg(lvl_info, " about to search for fonts, preferred = %s\n", fontfamily);
- family = g_malloc(sizeof(fontfamilies) + sizeof(fontfamily));
- if (fontfamily) {
- memcpy(family, &fontfamily, sizeof(fontfamily));
- memcpy(family + 1, fontfamilies, sizeof(fontfamilies));
- } else {
- memcpy(family, fontfamilies, sizeof(fontfamilies));
- }
- family_sav=family;
- for (exact = 1; !found && exact >= 0; exact--) {
- family=family_sav;
-
-
- while (*family && !found) {
- dbg(lvl_info, "Looking for font family %s. exact=%d\n",
- *family, exact);
- FcPattern *required =
- FcPatternBuild(NULL, FC_FAMILY, FcTypeString,
- *family, NULL);
- if (flags)
- FcPatternAddInteger(required, FC_WEIGHT,
- FC_WEIGHT_BOLD);
- FcConfigSubstitute(FcConfigGetCurrent(), required,
- FcMatchFont);
- FcDefaultSubstitute(required);
- FcResult result;
- FcPattern *matched =
- FcFontMatch(FcConfigGetCurrent(), required,
- &result);
- if (matched) {
- FcValue v1, v2;
- FcChar8 *fontfile;
- int fontindex;
- FcPatternGet(required, FC_FAMILY, 0, &v1);
- FcPatternGet(matched, FC_FAMILY, 0, &v2);
- FcResult r1 =
- FcPatternGetString(matched, FC_FILE, 0,
- &fontfile);
- FcResult r2 =
- FcPatternGetInteger(matched, FC_INDEX,
- 0, &fontindex);
- if ((r1 == FcResultMatch)
- && (r2 == FcResultMatch)
- && (FcValueEqual(v1, v2) || !exact)) {
- dbg(lvl_info,
- "About to load font from file %s index %d\n",
- fontfile, fontindex);
+ dbg(lvl_info, " about to search for fonts, preferred = %s", fontfamily);
+ family = g_malloc(sizeof(fontfamilies) + sizeof(fontfamily));
+ if (fontfamily) {
+ memcpy(family, &fontfamily, sizeof(fontfamily));
+ memcpy(family + 1, fontfamilies, sizeof(fontfamilies));
+ } else {
+ memcpy(family, fontfamilies, sizeof(fontfamilies));
+ }
+ family_sav=family;
+ for (exact = 1; !found && exact >= 0; exact--) {
+ family=family_sav;
+
+
+ while (*family && !found) {
+ dbg(lvl_info, "Looking for font family %s. exact=%d", *family, exact);
+ FcPattern *required = FcPatternBuild(NULL, FC_FAMILY, FcTypeString, *family, NULL);
+ if (flags)
+ FcPatternAddInteger(required, FC_WEIGHT, FC_WEIGHT_BOLD);
+ FcConfigSubstitute(FcConfigGetCurrent(), required, FcMatchFont);
+ FcDefaultSubstitute(required);
+ FcResult result;
+ FcPattern *matched =
+ FcFontMatch(FcConfigGetCurrent(), required, &result);
+ if (matched) {
+ FcValue v1, v2;
+ FcChar8 *fontfile;
+ int fontindex;
+ FcPatternGet(required, FC_FAMILY, 0, &v1);
+ FcPatternGet(matched, FC_FAMILY, 0, &v2);
+ FcResult r1 =
+ FcPatternGetString(matched, FC_FILE, 0, &fontfile);
+ FcResult r2 =
+ FcPatternGetInteger(matched, FC_INDEX, 0, &fontindex);
+ if ((r1 == FcResultMatch)
+ && (r2 == FcResultMatch)
+ && (FcValueEqual(v1, v2) || !exact)) {
+ dbg(lvl_info, "About to load font from file %s index %d", fontfile, fontindex);
#if USE_CACHING
- idstr=g_strdup_printf("%s/%d", fontfile, fontindex);
- font->scaler.face_id=(FTC_FaceID)atom(idstr);
- g_free(idstr);
+ idstr=g_strdup_printf("%s/%d", fontfile, fontindex);
+ font->scaler.face_id=(FTC_FaceID)atom(idstr);
+ g_free(idstr);
#if HAVE_LOOKUP_SCALER
- font->scaler.width=0;
- font->scaler.height=size;
- font->scaler.pixel=0;
- font->scaler.x_res=300;
- font->scaler.y_res=300;
+ font->scaler.width=0;
+ font->scaler.height=size;
+ font->scaler.pixel=0;
+ font->scaler.x_res=300;
+ font->scaler.y_res=300;
#else
- font->scaler.width=size/15;
- font->scaler.height=size/15;
- font->scaler.flags=FT_LOAD_DEFAULT;
+ font->scaler.width=size/15;
+ font->scaler.height=size/15;
+ font->scaler.flags=FT_LOAD_DEFAULT;
#endif
- FTC_Manager_LookupFace(manager, font->scaler.face_id, &face);
- font->charmap_index=face->charmap ? FT_Get_Charmap_Index(face->charmap) : 0;
+ FTC_Manager_LookupFace(manager, font->scaler.face_id, &face);
+ font->charmap_index=face->charmap ? FT_Get_Charmap_Index(face->charmap) : 0;
#else /* USE_CACHING */
- FT_New_Face(library,
- (char *) fontfile,
- fontindex,
- &font->face);
+ FT_New_Face(library, (char *) fontfile, fontindex, &font->face);
#endif /* USE_CACHING */
- found = 1;
- }
- FcPatternDestroy(matched);
- }
- FcPatternDestroy(required);
- family++;
- }
- }
- g_free(family_sav);
+ found = 1;
+ }
+ FcPatternDestroy(matched);
+ }
+ FcPatternDestroy(required);
+ family++;
+ }
+ }
+ g_free(family_sav);
#else /* HAVE_FONTCONFIG */
#ifdef FREETYPE_FONTS
- {
- char *fonts[]={FREETYPE_FONTS};
- name=g_strdup(fonts[flags ? 1:0]);
- }
+ {
+ char *fonts[]= {FREETYPE_FONTS};
+ name=g_strdup(fonts[flags ? 1:0]);
+ }
#else
- name=g_strdup_printf("%s/fonts/%s-%s.ttf",getenv("NAVIT_SHAREDIR"),"LiberationSans",flags ? "Bold":"Regular");
+ name=g_strdup_printf("%s/fonts/%s-%s.ttf",getenv("NAVIT_SHAREDIR"),"LiberationSans",flags ? "Bold":"Regular");
#endif
#if USE_CACHING
- idstr=g_strdup_printf("%s/%d", name, 0);
- font->scaler.face_id=(FTC_FaceID)atom(idstr);
- g_free(idstr);
- FTC_Manager_LookupFace(manager, font->scaler.face_id, &face);
- font->charmap_index=face->charmap ? FT_Get_Charmap_Index(face->charmap) : 0;
+ idstr=g_strdup_printf("%s/%d", name, 0);
+ font->scaler.face_id=(FTC_FaceID)atom(idstr);
+ g_free(idstr);
+ FTC_Manager_LookupFace(manager, font->scaler.face_id, &face);
+ font->charmap_index=face->charmap ? FT_Get_Charmap_Index(face->charmap) : 0;
#if HAVE_LOOKUP_SCALER
- font->scaler.width=0;
- font->scaler.height=size;
- font->scaler.pixel=0;
- font->scaler.x_res=300;
- font->scaler.y_res=300;
+ font->scaler.width=0;
+ font->scaler.height=size;
+ font->scaler.pixel=0;
+ font->scaler.x_res=300;
+ font->scaler.y_res=300;
#else
- font->scaler.width=size/15;
- font->scaler.height=size/15;
- font->scaler.flags=FT_LOAD_DEFAULT;
+ font->scaler.width=size/15;
+ font->scaler.height=size/15;
+ font->scaler.flags=FT_LOAD_DEFAULT;
#endif
- found=1;
- FTC_Manager_LookupFace(manager, font->scaler.face_id, &face);
- font->charmap_index=face->charmap ? FT_Get_Charmap_Index(face->charmap) : 0;
+ found=1;
+ FTC_Manager_LookupFace(manager, font->scaler.face_id, &face);
+ font->charmap_index=face->charmap ? FT_Get_Charmap_Index(face->charmap) : 0;
#else /* USE_CACHING */
- if (!FT_New_Face(library, name, 0, &font->face))
- found=1;
+ if (!FT_New_Face(library, name, 0, &font->face))
+ found=1;
#endif /* USE_CACHING */
- g_free(name);
+ g_free(name);
#endif /* HAVE_FONTCONFIG */
- if (!found) {
- dbg(lvl_error,"Failed to load font, no labelling\n");
- g_free(font);
- return NULL;
- }
+ if (!found) {
+ dbg(lvl_error,"Failed to load font, no labelling");
+ g_free(font);
+ return NULL;
+ }
#if !USE_CACHING
- FT_Set_Char_Size(font->face, 0, size, 300, 300);
- FT_Select_Charmap(font->face, FT_ENCODING_UNICODE);
+ FT_Set_Char_Size(font->face, 0, size, 300, 300);
+ FT_Select_Charmap(font->face, FT_ENCODING_UNICODE);
#endif
- return font;
+ return font;
}
/** Implementation of font_freetype_methods.get_shadow. */
-static int
-font_freetype_glyph_get_shadow(struct font_freetype_glyph *g,
- unsigned char *data, int stride, struct color *foreground, struct color *background)
-{
- int x, y, w = g->w, h = g->h;
- unsigned int bg, fg;
- unsigned char *pm, *psp,*ps,*psn;
- fg=((foreground->a>>COL_SHIFT)<<24)|
- ((foreground->r>>COL_SHIFT)<<16)|
- ((foreground->g>>COL_SHIFT)<<8)|
- ((foreground->b>>COL_SHIFT)<<0);
- bg=((background->a>>COL_SHIFT)<<24)|
- ((background->r>>COL_SHIFT)<<16)|
- ((background->g>>COL_SHIFT)<<8)|
- ((background->b>>COL_SHIFT)<<0);
- for (y = 0; y < h+2; y++) {
- if (stride) {
- ps = data + stride * y;
- } else {
- unsigned char **dataptr=(unsigned char **)data;
- ps = dataptr[y];
- }
- for (x = 0 ; x < w+2 ; x++)
- ((unsigned int *)ps)[x]=bg;
- }
- for (y = 0; y < h; y++) {
- pm = g->pixmap + y * w;
- if (stride) {
- psp = data + stride * y;
- ps = psp + stride;
- psn = ps + stride;
- } else {
- unsigned char **dataptr=(unsigned char **)data;
- psp = dataptr[y];
- ps = dataptr[y+1];
- psn = dataptr[y+2];
- }
- for (x = 0; x < w; x++) {
- if (*pm) {
- ((unsigned int *)psp)[1]=fg;
- ((unsigned int *)ps)[0]=fg;
- ((unsigned int *)ps)[1]=fg;
- ((unsigned int *)ps)[2]=fg;
- ((unsigned int *)psn)[1]=fg;
- }
- psp+=4;
- ps+=4;
- psn+=4;
- pm++;
- }
- }
- return 1;
+static int font_freetype_glyph_get_shadow(struct font_freetype_glyph *g, unsigned char *data, int stride, struct color *foreground, struct color *background) {
+ int x, y, w = g->w, h = g->h;
+ unsigned int bg, fg;
+ unsigned char *pm, *psp,*ps,*psn;
+ fg=((foreground->a>>COL_SHIFT)<<24)|
+ ((foreground->r>>COL_SHIFT)<<16)|
+ ((foreground->g>>COL_SHIFT)<<8)|
+ ((foreground->b>>COL_SHIFT)<<0);
+ bg=((background->a>>COL_SHIFT)<<24)|
+ ((background->r>>COL_SHIFT)<<16)|
+ ((background->g>>COL_SHIFT)<<8)|
+ ((background->b>>COL_SHIFT)<<0);
+ for (y = 0; y < h+2; y++) {
+ if (stride) {
+ ps = data + stride * y;
+ } else {
+ unsigned char **dataptr=(unsigned char **)data;
+ ps = dataptr[y];
+ }
+ for (x = 0 ; x < w+2 ; x++)
+ ((unsigned int *)ps)[x]=bg;
+ }
+ for (y = 0; y < h; y++) {
+ pm = g->pixmap + y * w;
+ if (stride) {
+ psp = data + stride * y;
+ ps = psp + stride;
+ psn = ps + stride;
+ } else {
+ unsigned char **dataptr=(unsigned char **)data;
+ psp = dataptr[y];
+ ps = dataptr[y+1];
+ psn = dataptr[y+2];
+ }
+ for (x = 0; x < w; x++) {
+ if (*pm) {
+ ((unsigned int *)psp)[1]=fg;
+ ((unsigned int *)ps)[0]=fg;
+ ((unsigned int *)ps)[1]=fg;
+ ((unsigned int *)ps)[2]=fg;
+ ((unsigned int *)psn)[1]=fg;
+ }
+ psp+=4;
+ ps+=4;
+ psn+=4;
+ pm++;
+ }
+ }
+ return 1;
}
/** Implementation of font_freetype_methods.get_glyph. */
-static int
-font_freetype_glyph_get_glyph(struct font_freetype_glyph *g,
- unsigned char *data, int stride, struct color *fg, struct color *bg, struct color *transparent)
-{
- int x, y, w = g->w, h = g->h;
- unsigned int tr;
- unsigned char v,vi,*pm, *ps;
- tr=((transparent->a>>COL_SHIFT)<<24)|
- ((transparent->r>>COL_SHIFT)<<16)|
- ((transparent->g>>COL_SHIFT)<<8)|
- ((transparent->b>>COL_SHIFT)<<0);
- for (y = 0; y < h; y++) {
- pm = g->pixmap + y * w;
- if (stride) {
- ps = data + stride*y;
- } else {
- unsigned char **dataptr=(unsigned char **)data;
- ps = dataptr[y];
- }
- for (x = 0; x < w; x++) {
- v=*pm;
- if (v) {
- vi=255-v;
- ((unsigned int *)ps)[0]=
- ((((fg->a*v+bg->a*vi)/255)>>COL_SHIFT)<<24)|
- ((((fg->r*v+bg->r*vi)/255)>>COL_SHIFT)<<16)|
- ((((fg->g*v+bg->g*vi)/255)>>COL_SHIFT)<<8)|
- ((((fg->b*v+bg->b*vi)/255)>>COL_SHIFT)<<0);
- } else
- ((unsigned int *)ps)[0]=tr;
- ps+=4;
- pm++;
- }
- }
- return 1;
+static int font_freetype_glyph_get_glyph(struct font_freetype_glyph *g, unsigned char *data, int stride, struct color *fg, struct color *bg, struct color *transparent) {
+ int x, y, w = g->w, h = g->h;
+ unsigned int tr;
+ unsigned char v,vi,*pm, *ps;
+ tr=((transparent->a>>COL_SHIFT)<<24)|
+ ((transparent->r>>COL_SHIFT)<<16)|
+ ((transparent->g>>COL_SHIFT)<<8)|
+ ((transparent->b>>COL_SHIFT)<<0);
+ for (y = 0; y < h; y++) {
+ pm = g->pixmap + y * w;
+ if (stride) {
+ ps = data + stride*y;
+ } else {
+ unsigned char **dataptr=(unsigned char **)data;
+ ps = dataptr[y];
+ }
+ for (x = 0; x < w; x++) {
+ v=*pm;
+ if (v) {
+ vi=255-v;
+ ((unsigned int *)ps)[0]=
+ ((((fg->a*v+bg->a*vi)/255)>>COL_SHIFT)<<24)|
+ ((((fg->r*v+bg->r*vi)/255)>>COL_SHIFT)<<16)|
+ ((((fg->g*v+bg->g*vi)/255)>>COL_SHIFT)<<8)|
+ ((((fg->b*v+bg->b*vi)/255)>>COL_SHIFT)<<0);
+ } else
+ ((unsigned int *)ps)[0]=tr;
+ ps+=4;
+ pm++;
+ }
+ }
+ return 1;
}
-static void
-font_freetype_destroy(void) {
- // Do not call FcFini here: GdkPixbuf also (indirectly) uses fontconfig (for SVGs with
- // text), but does not properly deallocate all objects, so FcFini assert()s.
- if (!library_deinit) {
+static void font_freetype_destroy(void) {
+ // Do not call FcFini here: GdkPixbuf also (indirectly) uses fontconfig (for SVGs with
+ // text), but does not properly deallocate all objects, so FcFini assert()s.
+ if (!library_deinit) {
#if USE_CACHING
- FTC_Manager_Done(manager);
+ FTC_Manager_Done(manager);
#endif
- FT_Done_FreeType(library);
- }
- library_deinit = 1;
+ FT_Done_FreeType(library);
+ }
+ library_deinit = 1;
}
static struct font_freetype_methods methods = {
- font_freetype_destroy,
- font_freetype_font_new,
- font_freetype_get_text_bbox,
- font_freetype_text_new,
- font_freetype_text_destroy,
- font_freetype_glyph_get_shadow,
- font_freetype_glyph_get_glyph,
+ font_freetype_destroy,
+ font_freetype_font_new,
+ font_freetype_get_text_bbox,
+ font_freetype_text_new,
+ font_freetype_text_destroy,
+ font_freetype_glyph_get_shadow,
+ font_freetype_glyph_get_glyph,
};
-static struct font_priv *
-font_freetype_new(void *meth)
-{
- *((struct font_freetype_methods *) meth) = methods;
- return &dummy;
+static struct font_priv *font_freetype_new(void *meth) {
+ *((struct font_freetype_methods *) meth) = methods;
+ return &dummy;
}
-void
-plugin_init(void)
-{
- plugin_register_category_font("freetype", font_freetype_new);
+void plugin_init(void) {
+ plugin_register_category_font("freetype", font_freetype_new);
#ifdef HAVE_FONTCONFIG
- FcInit();
+ FcInit();
#endif
}
diff --git a/navit/fonts/CMakeLists.txt b/navit/fonts/CMakeLists.txt
index 2c2f22531..69fb716f3 100644
--- a/navit/fonts/CMakeLists.txt
+++ b/navit/fonts/CMakeLists.txt
@@ -1,13 +1,13 @@
add_custom_target( fonts ALL DEPENDS ${NAVIT_FONTS}
- COMMAND ${CMAKE_COMMAND}
- -D GLOB_EXP="${CMAKE_CURRENT_SOURCE_DIR}/*.ttf" #${NAVIT_FONTS}"
- -D DST=${CMAKE_CURRENT_BINARY_DIR}
- -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
-)
+ COMMAND ${CMAKE_COMMAND}
+ -D GLOB_EXP="${CMAKE_CURRENT_SOURCE_DIR}/*.ttf" #${NAVIT_FONTS}"
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}
+ -P ${PROJECT_SOURCE_DIR}/cmake/copy_files.cmake
+ )
FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.ttf")
install(
- FILES ${files}
- DESTINATION ${SHARE_DIR}/fonts
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
-)
+ FILES ${files}
+ DESTINATION ${SHARE_DIR}/fonts
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ )
diff --git a/navit/fonts/License.txt b/navit/fonts/License.txt
index f1787287c..b0e1f3edc 100644
--- a/navit/fonts/License.txt
+++ b/navit/fonts/License.txt
@@ -3,17 +3,17 @@ LIBERATION FONT SOFTWARE
This agreement governs the use of the Software and any updates to the Software, regardless of the delivery mechanism. Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to the user ("Client") a license to this work pursuant to the GNU General Public License v.2 with the exceptions set forth below and such other terms as are set forth in this End User License Agreement.
- 1. The Software and License Exception. LIBERATION font software (the "Software") consists of TrueType-OpenType formatted font software for rendering LIBERATION typefaces in sans-serif, serif, and monospaced character styles. You are licensed to use, modify, copy, and distribute the Software pursuant to the GNU General Public License v.2 with the following exceptions:
+ 1. The Software and License Exception. LIBERATION font software (the "Software") consists of TrueType-OpenType formatted font software for rendering LIBERATION typefaces in sans-serif, serif, and monospaced character styles. You are licensed to use, modify, copy, and distribute the Software pursuant to the GNU General Public License v.2 with the following exceptions:
(a) As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
(b) As a further exception, any distribution of the object code of the Software in a physical product must provide you the right to access and modify the source code for the Software and to reinstall that modified version of the Software in object code form on the same physical product on which you received it.
- 2. Intellectual Property Rights. The Software and each of its components, including the source code, documentation, appearance, structure and organization are owned by Red Hat and others and are protected under copyright and other laws. Title to the Software and any component, or to any copy, modification, or merged portion shall remain with the aforementioned, subject to the applicable license. The "LIBERATION" trademark is a trademark of Red Hat, Inc. in the U.S. and other countries. This agreement does not permit Client to distribute modified versions of the Software using Red Hat's trademarks. If Client makes a redistribution of a modified version of the Software, then Client must modify the files names to remove any reference to the Red Hat trademarks and must not use the Red Hat trademarks in any way to reference or promote the modified Software.
+ 2. Intellectual Property Rights. The Software and each of its components, including the source code, documentation, appearance, structure and organization are owned by Red Hat and others and are protected under copyright and other laws. Title to the Software and any component, or to any copy, modification, or merged portion shall remain with the aforementioned, subject to the applicable license. The "LIBERATION" trademark is a trademark of Red Hat, Inc. in the U.S. and other countries. This agreement does not permit Client to distribute modified versions of the Software using Red Hat's trademarks. If Client makes a redistribution of a modified version of the Software, then Client must modify the files names to remove any reference to the Red Hat trademarks and must not use the Red Hat trademarks in any way to reference or promote the modified Software.
- 3. Limited Warranty. To the maximum extent permitted under applicable law, the Software is provided and licensed "as is" without warranty of any kind, expressed or implied, including the implied warranties of merchantability, non-infringement or fitness for a particular purpose. Red Hat does not warrant that the functions contained in the Software will meet Client's requirements or that the operation of the Software will be entirely error free or appear precisely as described in the accompanying documentation.
+ 3. Limited Warranty. To the maximum extent permitted under applicable law, the Software is provided and licensed "as is" without warranty of any kind, expressed or implied, including the implied warranties of merchantability, non-infringement or fitness for a particular purpose. Red Hat does not warrant that the functions contained in the Software will meet Client's requirements or that the operation of the Software will be entirely error free or appear precisely as described in the accompanying documentation.
- 4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential damages, including lost profits or lost savings arising out of the use or inability to use the Software, even if Red Hat or such dealer has been advised of the possibility of such damages.
+ 4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential damages, including lost profits or lost savings arising out of the use or inability to use the Software, even if Red Hat or such dealer has been advised of the possibility of such damages.
5. General. If any provision of this agreement is held to be unenforceable, that shall not affect the enforceability of the remaining provisions. This agreement shall be governed by the laws of the State of North Carolina and of the United States, without regard to any conflict of laws provisions, except that the United Nations Convention on the International Sale of Goods shall not apply.
Copyright © 2007 Red Hat, Inc. All rights reserved. LIBERATION is a trademark of Red Hat, Inc.
diff --git a/navit/fonts/README b/navit/fonts/README
index 51a5329cd..e57b91222 100644
--- a/navit/fonts/README
+++ b/navit/fonts/README
@@ -24,7 +24,7 @@ Courier New.
3.2 Build from the source
- Change into directory liberation-fonts-[VERSION]/ and build from sources by
+ Change into directory liberation-fonts-[VERSION]/ and build from sources by
following commands:
$ cd liberation-fonts-[VERSION]
@@ -42,7 +42,7 @@ Courier New.
4. Usage
========
-The fonts should be installed and detected by the system after installation.
+The fonts should be installed and detected by the system after installation.
5. License
diff --git a/navit/geom.c b/navit/geom.c
index 65ea4986b..e4b28fbd3 100644
--- a/navit/geom.c
+++ b/navit/geom.c
@@ -20,17 +20,15 @@
#include <math.h>
#include "geom.h"
-void
-geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse)
-{
- int i;
- if (!reverse) {
- memcpy(to, from, count*sizeof(struct coord));
- return;
- }
- from+=count;
- for (i = 0 ; i < count ; i++)
- *to++=*--from;
+void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse) {
+ int i;
+ if (!reverse) {
+ memcpy(to, from, count*sizeof(struct coord));
+ return;
+ }
+ from+=count;
+ for (i = 0 ; i < count ; i++)
+ *to++=*--from;
}
/**
@@ -40,74 +38,59 @@ geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse)
* @param out *c coordinates of middle point
* @returns number of first vertex of segment containing middle point
*/
-int
-geom_line_middle(struct coord *p, int count, struct coord *c)
-{
- double length=0,half=0,len=0;
- int i;
+int geom_line_middle(struct coord *p, int count, struct coord *c) {
+ double length=0,half=0,len=0;
+ int i;
- if(count==1) {
- *c=*p;
- return 0;
- }
-
- for (i=0; i<count-1; i++) {
- length+=sqrt(sq(p[i].x-p[i+1].x)+sq(p[i].y-p[i+1].y));
- }
+ if(count==1) {
+ *c=*p;
+ return 0;
+ }
- length/=2;
- for (i=0; (i<count-1) && (half<length); i++) {
- len=sqrt(sq(p[i].x-p[i+1].x)+sq(p[i].y-p[i+1].y));
- half+=len;
- }
- if (i > 0) {
- i--;
- half-=length;
- if (len) {
- c->x=(p[i].x*half+p[i+1].x*(len-half))/len;
- c->y=(p[i].y*half+p[i+1].y*(len-half))/len;
- } else
- *c=p[i];
- } else
- *c=p[0];
- return i;
+ for (i=0; i<count-1; i++) {
+ length+=sqrt(sq(p[i].x-p[i+1].x)+sq(p[i].y-p[i+1].y));
+ }
+
+ length/=2;
+ for (i=0; (i<count-1) && (half<length); i++) {
+ len=sqrt(sq(p[i].x-p[i+1].x)+sq(p[i].y-p[i+1].y));
+ half+=len;
+ }
+ if (i > 0) {
+ i--;
+ half-=length;
+ if (len) {
+ c->x=(p[i].x*half+p[i+1].x*(len-half))/len;
+ c->y=(p[i].y*half+p[i+1].y*(len-half))/len;
+ } else
+ *c=p[i];
+ } else
+ *c=p[0];
+ return i;
}
-void
-geom_coord_revert(struct coord *c, int count)
-{
- struct coord tmp;
- int i;
+void geom_coord_revert(struct coord *c, int count) {
+ struct coord tmp;
+ int i;
- for (i = 0 ; i < count/2 ; i++) {
- tmp=c[i];
- c[i]=c[count-1-i];
- c[count-1-i]=tmp;
- }
+ for (i = 0 ; i < count/2 ; i++) {
+ tmp=c[i];
+ c[i]=c[count-1-i];
+ c[count-1-i]=tmp;
+ }
}
-long long
-geom_poly_area(struct coord *c, int count)
-{
- long long area=0;
- int i,j=0;
-#if 0
- fprintf(stderr,"count=%d\n",count);
-#endif
- for (i=0; i<count; i++) {
- if (++j == count)
- j=0;
-#if 0
- fprintf(stderr,"(%d+%d)*(%d-%d)=%d*%d="LONGLONG_FMT"\n",c[i].x,c[j].x,c[i].y,c[j].y,c[i].x+c[j].x,c[i].y-c[j].y,(long long)(c[i].x+c[j].x)*(c[i].y-c[j].y));
-#endif
- area+=(long long)(c[i].x+c[j].x)*(c[i].y-c[j].y);
-#if 0
- fprintf(stderr,"area="LONGLONG_FMT"\n",area);
-#endif
- }
- return area/2;
+long long geom_poly_area(struct coord *c, int count) {
+ long long area=0;
+ int i,j=0;
+ for (i=0; i<count; i++) {
+ if (++j == count)
+ j=0;
+ area+=(long long)(c[i].x+c[j].x)*(c[i].y-c[j].y);
+ }
+ return area/2;
}
/**
@@ -117,399 +100,338 @@ geom_poly_area(struct coord *c, int count)
* @param out *c coordinates of poly centroid
* @returns 1 on success, 0 if poly area is 0
*/
-int
-geom_poly_centroid(struct coord *p, int count, struct coord *c)
-{
- long long area=0;
- long long sx=0,sy=0,tmp;
- int i,j;
- long long x0=p[0].x, y0=p[0].y, xi, yi, xj, yj;
-
- /*fprintf(stderr,"area="LONGLONG_FMT"\n", area );*/
- for (i=0,j=0; i<count; i++) {
- if (++j == count)
- j=0;
- xi=p[i].x-x0;
- yi=p[i].y-y0;
- xj=p[j].x-x0;
- yj=p[j].y-y0;
- tmp=(xi*yj-xj*yi);
- sx+=(xi+xj)*tmp;
- sy+=(yi+yj)*tmp;
- area+=xi*yj-xj*yi;
- }
- if(area!=0) {
- c->x=x0+sx/3/area;
- c->y=y0+sy/3/area;
- return 1;
- }
- return 0;
+int geom_poly_centroid(struct coord *p, int count, struct coord *c) {
+ long long area=0;
+ long long sx=0,sy=0,tmp;
+ int i,j;
+ long long x0=p[0].x, y0=p[0].y, xi, yi, xj, yj;
+
+ /*fprintf(stderr,"area="LONGLONG_FMT"\n", area );*/
+ for (i=0,j=0; i<count; i++) {
+ if (++j == count)
+ j=0;
+ xi=p[i].x-x0;
+ yi=p[i].y-y0;
+ xj=p[j].x-x0;
+ yj=p[j].y-y0;
+ tmp=(xi*yj-xj*yi);
+ sx+=(xi+xj)*tmp;
+ sy+=(yi+yj)*tmp;
+ area+=xi*yj-xj*yi;
+ }
+ if(area!=0) {
+ c->x=x0+sx/3/area;
+ c->y=y0+sy/3/area;
+ return 1;
+ }
+ return 0;
}
/**
* Get coordinates of polyline point c most close to given point p.
* @param in *pl array of polyline vertex coordinates
* @param in count count of polyline vertexes
- * @param in *p point coordinates
+ * @param in *p point coordinates
* @param out *c coordinates of polyline point most close to given point.
* @returns first vertex number of polyline segment to which c belongs
*/
-int
-geom_poly_closest_point(struct coord *pl, int count, struct coord *p, struct coord *c)
-{
- int i,vertex=0;
- long long x, y, xi, xj, yi, yj, u, d, dmin=0;
- if(count<2) {
- c->x=pl->x;
- c->y=pl->y;
- return 0;
- }
- for(i=0;i<count-1;i++) {
- xi=pl[i].x;
- yi=pl[i].y;
- xj=pl[i+1].x;
- yj=pl[i+1].y;
- u=(xj-xi)*(xj-xi)+(yj-yi)*(yj-yi);
- if(u!=0) {
- u=((p->x-xi)*(xj-xi)+(p->y-yi)*(yj-yi))*1000/u;
- }
- if(u<0)
- u=0;
- else if (u>1000)
- u=1000;
- x=xi+u*(xj-xi)/1000;
- y=yi+u*(yj-yi)/1000;
- d=(p->x-x)*(p->x-x)+(p->y-y)*(p->y-y);
- if(i==0 || d<dmin) {
- dmin=d;
- c->x=x;
- c->y=y;
- vertex=i;
- }
- }
- return vertex;
+int geom_poly_closest_point(struct coord *pl, int count, struct coord *p, struct coord *c) {
+ int i,vertex=0;
+ long long x, y, xi, xj, yi, yj, u, d, dmin=0;
+ if(count<2) {
+ c->x=pl->x;
+ c->y=pl->y;
+ return 0;
+ }
+ for(i=0; i<count-1; i++) {
+ xi=pl[i].x;
+ yi=pl[i].y;
+ xj=pl[i+1].x;
+ yj=pl[i+1].y;
+ u=(xj-xi)*(xj-xi)+(yj-yi)*(yj-yi);
+ if(u!=0) {
+ u=((p->x-xi)*(xj-xi)+(p->y-yi)*(yj-yi))*1000/u;
+ }
+ if(u<0)
+ u=0;
+ else if (u>1000)
+ u=1000;
+ x=xi+u*(xj-xi)/1000;
+ y=yi+u*(yj-yi)/1000;
+ d=(p->x-x)*(p->x-x)+(p->y-y)*(p->y-y);
+ if(i==0 || d<dmin) {
+ dmin=d;
+ c->x=x;
+ c->y=y;
+ vertex=i;
+ }
+ }
+ return vertex;
}
/**
* Check if point is inside polgone.
* @param in *cp array of polygon vertex coordinates
* @param in count count of polygon vertexes
- * @param in *c point coordinates
+ * @param in *c point coordinates
* @returns 1 - inside, 0 - outside
*/
-int
-geom_poly_point_inside(struct coord *cp, int count, struct coord *c)
-{
- int ret=0;
- struct coord *last=cp+count-1;
- while (cp < last) {
- if ((cp[0].y > c->y) != (cp[1].y > c->y) &&
- c->x < ((long long)cp[1].x-cp[0].x)*(c->y-cp[0].y)/(cp[1].y-cp[0].y)+cp[0].x) {
-#if 0
- fprintf(stderr," cross 0x%x,0x%x-0x%x,0x%x %dx%d",cp,cp[0].x,cp[0].y,cp[1].x,cp[1].y,cp[1].x-cp[0].x,c->y-cp[0].y);
- printf("type=selected_line\n");
- coord_print(projection_mg, &cp[0], stdout);
- coord_print(projection_mg, &cp[1], stdout);
-#endif
- ret=!ret;
- }
- cp++;
- }
- return ret;
+int geom_poly_point_inside(struct coord *cp, int count, struct coord *c) {
+ int ret=0;
+ struct coord *last=cp+count-1;
+ while (cp < last) {
+ if ((cp[0].y > c->y) != (cp[1].y > c->y) &&
+ c->x < ((long long)cp[1].x-cp[0].x)*(c->y-cp[0].y)/(cp[1].y-cp[0].y)+cp[0].x) {
+ ret=!ret;
+ }
+ cp++;
+ }
+ return ret;
}
-GList *
-geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third)
-{
- int count;
- struct geom_poly_segment *ret;
- struct coord *pos;
+GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third) {
+ int count;
+ struct geom_poly_segment *ret;
+ struct coord *pos;
- if (!second)
- return NULL;
- ret=g_new(struct geom_poly_segment, 1);
- ret->type=second->type;
- count=(second->last-second->first)+1;
- if (first)
- count+=(first->last-first->first);
- if (third)
- count+=(third->last-third->first);
-#if 0
- fprintf(stderr,"count=%d first=%p second=%p third=%p\n",count,first,second,third);
- if (first)
- fprintf(stderr,"first:0x%x,0x%x-0x%x,0x%x (%d)\n",first->first->x,first->first->y,first->last->x,first->last->y, first->last-first->first+1);
- if (second)
- fprintf(stderr,"second:0x%x,0x%x-0x%x,0x%x (%d)\n",second->first->x,second->first->y,second->last->x,second->last->y, second->last-second->first+1);
- if (third)
- fprintf(stderr,"third:0x%x,0x%x-0x%x,0x%x (%d)\n",third->first->x,third->first->y,third->last->x,third->last->y, third->last-third->first+1);
-#endif
- ret->first=g_new(struct coord, count);
- pos=ret->first;
- if (first) {
- count=(first->last-first->first)+1;
- geom_coord_copy(first->first, pos, count, coord_is_equal(*first->first, *second->first));
- pos+=count-1;
- }
- count=(second->last-second->first)+1;
- geom_coord_copy(second->first, pos, count, 0);
- pos+=count;
- if (third) {
- pos--;
- count=(third->last-third->first)+1;
- geom_coord_copy(third->first, pos, count, coord_is_equal(*third->last, *second->last));
- pos+=count;
- }
- ret->last=pos-1;
-#if 0
- fprintf(stderr,"result:0x%x,0x%x-0x%x,0x%x (%d)\n",ret->first->x,ret->first->y,ret->last->x,ret->last->y, ret->last-ret->first+1);
-#endif
- list=g_list_prepend(list, ret);
-#if 0
- fprintf(stderr,"List=%p\n",list);
-#endif
- return list;
+ if (!second)
+ return NULL;
+ ret=g_new(struct geom_poly_segment, 1);
+ ret->type=second->type;
+ count=(second->last-second->first)+1;
+ if (first)
+ count+=(first->last-first->first);
+ if (third)
+ count+=(third->last-third->first);
+ ret->first=g_new(struct coord, count);
+ pos=ret->first;
+ if (first) {
+ count=(first->last-first->first)+1;
+ geom_coord_copy(first->first, pos, count, coord_is_equal(*first->first, *second->first));
+ pos+=count-1;
+ }
+ count=(second->last-second->first)+1;
+ geom_coord_copy(second->first, pos, count, 0);
+ pos+=count;
+ if (third) {
+ pos--;
+ count=(third->last-third->first)+1;
+ geom_coord_copy(third->first, pos, count, coord_is_equal(*third->last, *second->last));
+ pos+=count;
+ }
+ ret->last=pos-1;
+ list=g_list_prepend(list, ret);
+ return list;
}
-void
-geom_poly_segment_destroy(struct geom_poly_segment *seg)
-{
- g_free(seg->first);
- g_free(seg);
+void geom_poly_segment_destroy(struct geom_poly_segment *seg) {
+ g_free(seg->first);
+ g_free(seg);
}
-GList *
-geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg)
-{
- if (seg) {
- list=g_list_remove(list, seg);
- geom_poly_segment_destroy(seg);
- }
- return list;
+GList *geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg) {
+ if (seg) {
+ list=g_list_remove(list, seg);
+ geom_poly_segment_destroy(seg);
+ }
+ return list;
}
-int
-geom_poly_segment_compatible(struct geom_poly_segment *s1, struct geom_poly_segment *s2, int dir)
-{
- int same=0,opposite=0;
- if (s1->type == geom_poly_segment_type_none || s2->type == geom_poly_segment_type_none)
- return 0;
- if (s1->type == s2->type) {
- same=1;
- if (s1->type == geom_poly_segment_type_way_inner || s1->type == geom_poly_segment_type_way_outer) {
- opposite=1;
- }
- }
- if (s1->type == geom_poly_segment_type_way_left_side && s2->type == geom_poly_segment_type_way_right_side)
- opposite=1;
- if (s1->type == geom_poly_segment_type_way_right_side && s2->type == geom_poly_segment_type_way_left_side)
- opposite=1;
- if (s1->type == geom_poly_segment_type_way_unknown || s2->type == geom_poly_segment_type_way_unknown) {
- same=1;
- opposite=1;
- }
- if (dir < 0) {
- if ((opposite && coord_is_equal(*s1->first, *s2->first)) || (same && coord_is_equal(*s1->first, *s2->last)))
- return 1;
- } else {
- if ((opposite && coord_is_equal(*s1->last, *s2->last)) || (same && coord_is_equal(*s1->last, *s2->first)))
- return 1;
- }
- return 0;
+int geom_poly_segment_compatible(struct geom_poly_segment *s1, struct geom_poly_segment *s2, int dir) {
+ int same=0,opposite=0;
+ if (s1->type == geom_poly_segment_type_none || s2->type == geom_poly_segment_type_none)
+ return 0;
+ if (s1->type == s2->type) {
+ same=1;
+ if (s1->type == geom_poly_segment_type_way_inner || s1->type == geom_poly_segment_type_way_outer) {
+ opposite=1;
+ }
+ }
+ if (s1->type == geom_poly_segment_type_way_left_side && s2->type == geom_poly_segment_type_way_right_side)
+ opposite=1;
+ if (s1->type == geom_poly_segment_type_way_right_side && s2->type == geom_poly_segment_type_way_left_side)
+ opposite=1;
+ if (s1->type == geom_poly_segment_type_way_unknown || s2->type == geom_poly_segment_type_way_unknown) {
+ same=1;
+ opposite=1;
+ }
+ if (dir < 0) {
+ if ((opposite && coord_is_equal(*s1->first, *s2->first)) || (same && coord_is_equal(*s1->first, *s2->last)))
+ return 1;
+ } else {
+ if ((opposite && coord_is_equal(*s1->last, *s2->last)) || (same && coord_is_equal(*s1->last, *s2->first)))
+ return 1;
+ }
+ return 0;
}
-GList *
-geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type)
-{
- GList *ret=NULL;
- while (in) {
- struct geom_poly_segment *seg=in->data;
- GList *tmp=ret;
- struct geom_poly_segment *merge_first=NULL,*merge_last=NULL;
- while (tmp) {
- struct geom_poly_segment *cseg=tmp->data;
- if (geom_poly_segment_compatible(seg, cseg, -1))
- merge_first=cseg;
- if (geom_poly_segment_compatible(seg, cseg, 1))
- merge_last=cseg;
- tmp=g_list_next(tmp);
- }
- if (merge_first == merge_last)
- merge_last=NULL;
- ret=geom_poly_segments_insert(ret, merge_first, seg, merge_last);
- ret=geom_poly_segments_remove(ret, merge_first);
- ret=geom_poly_segments_remove(ret, merge_last);
- in=g_list_next(in);
- }
- in=ret;
- while (in) {
- struct geom_poly_segment *seg=in->data;
- if (coord_is_equal(*seg->first, *seg->last)) {
- long long area=geom_poly_area(seg->first,seg->last-seg->first+1);
- if (type == geom_poly_segment_type_way_right_side && seg->type == geom_poly_segment_type_way_right_side) {
- seg->type=area > 0 ? geom_poly_segment_type_way_outer : geom_poly_segment_type_way_inner;
- }
- }
- in=g_list_next(in);
- }
- return ret;
+GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type) {
+ GList *ret=NULL;
+ while (in) {
+ struct geom_poly_segment *seg=in->data;
+ GList *tmp=ret;
+ struct geom_poly_segment *merge_first=NULL,*merge_last=NULL;
+ while (tmp) {
+ struct geom_poly_segment *cseg=tmp->data;
+ if (geom_poly_segment_compatible(seg, cseg, -1))
+ merge_first=cseg;
+ if (geom_poly_segment_compatible(seg, cseg, 1))
+ merge_last=cseg;
+ tmp=g_list_next(tmp);
+ }
+ if (merge_first == merge_last)
+ merge_last=NULL;
+ ret=geom_poly_segments_insert(ret, merge_first, seg, merge_last);
+ ret=geom_poly_segments_remove(ret, merge_first);
+ ret=geom_poly_segments_remove(ret, merge_last);
+ in=g_list_next(in);
+ }
+ in=ret;
+ while (in) {
+ struct geom_poly_segment *seg=in->data;
+ if (coord_is_equal(*seg->first, *seg->last)) {
+ long long area=geom_poly_area(seg->first,seg->last-seg->first+1);
+ if (type == geom_poly_segment_type_way_right_side && seg->type == geom_poly_segment_type_way_right_side) {
+ seg->type=area > 0 ? geom_poly_segment_type_way_outer : geom_poly_segment_type_way_inner;
+ }
+ }
+ in=g_list_next(in);
+ }
+ return ret;
}
-int
-geom_poly_segments_point_inside(GList *in, struct coord *c)
-{
- int open_matches=0,closed_matches=0;
-#if 0
- fprintf(stderr,"try 0x%x,0x%x:",c->x,c->y);
-#endif
- while (in) {
- struct geom_poly_segment *seg=in->data;
- if (geom_poly_point_inside(seg->first, seg->last-seg->first+1, c)) {
-#if 0
- fprintf(stderr," inside");
-#endif
- if (coord_is_equal(*seg->first,*seg->last))
- closed_matches++;
- else
- open_matches++;
- } else {
-#if 0
- fprintf(stderr," outside");
-#endif
- }
- in=g_list_next(in);
- }
-#if 0
- fprintf(stderr,"\n");
- fprintf(stderr,"open_matches %d closed_matches %d\n",open_matches,closed_matches);
-#endif
- if (closed_matches) {
- if (closed_matches & 1)
- return 1;
- else
- return 0;
- }
- if (open_matches) {
- if (open_matches & 1)
- return -1;
- else
- return 0;
- }
- return 0;
+int geom_poly_segments_point_inside(GList *in, struct coord *c) {
+ int open_matches=0,closed_matches=0;
+ while (in) {
+ struct geom_poly_segment *seg=in->data;
+ if (geom_poly_point_inside(seg->first, seg->last-seg->first+1, c)) {
+ if (coord_is_equal(*seg->first,*seg->last))
+ closed_matches++;
+ else
+ open_matches++;
+ } else {
+ }
+ in=g_list_next(in);
+ }
+ if (closed_matches) {
+ if (closed_matches & 1)
+ return 1;
+ else
+ return 0;
+ }
+ if (open_matches) {
+ if (open_matches & 1)
+ return -1;
+ else
+ return 0;
+ }
+ return 0;
}
-static int
-clipcode(struct coord *p, struct rect *r)
-{
- int code=0;
- if (p->x < r->l.x)
- code=1;
- if (p->x > r->h.x)
- code=2;
- if (p->y < r->l.y)
- code |=4;
- if (p->y > r->h.y)
- code |=8;
- return code;
+static int clipcode(struct coord *p, struct rect *r) {
+ int code=0;
+ if (p->x < r->l.x)
+ code=1;
+ if (p->x > r->h.x)
+ code=2;
+ if (p->y < r->l.y)
+ code |=4;
+ if (p->y > r->h.y)
+ code |=8;
+ return code;
}
-int
-geom_clip_line_code(struct coord *p1, struct coord *p2, struct rect *r)
-{
- int code1,code2,ret=1;
- long long dx,dy;
- code1=clipcode(p1, r);
- if (code1)
- ret |= 2;
- code2=clipcode(p2, r);
- if (code2)
- ret |= 4;
- dx=p2->x-p1->x;
- dy=p2->y-p1->y;
- while (code1 || code2) {
- if (code1 & code2)
- return 0;
- if (code1 & 1) {
- p1->y+=(r->l.x-p1->x)*dy/dx;
- p1->x=r->l.x;
- } else if (code1 & 2) {
- p1->y+=(r->h.x-p1->x)*dy/dx;
- p1->x=r->h.x;
- } else if (code1 & 4) {
- p1->x+=(r->l.y-p1->y)*dx/dy;
- p1->y=r->l.y;
- } else if (code1 & 8) {
- p1->x+=(r->h.y-p1->y)*dx/dy;
- p1->y=r->h.y;
- }
- code1=clipcode(p1, r);
- if (code1 & code2)
- return 0;
- if (code2 & 1) {
- p2->y+=(r->l.x-p2->x)*dy/dx;
- p2->x=r->l.x;
- } else if (code2 & 2) {
- p2->y+=(r->h.x-p2->x)*dy/dx;
- p2->x=r->h.x;
- } else if (code2 & 4) {
- p2->x+=(r->l.y-p2->y)*dx/dy;
- p2->y=r->l.y;
- } else if (code2 & 8) {
- p2->x+=(r->h.y-p2->y)*dx/dy;
- p2->y=r->h.y;
- }
- code2=clipcode(p2, r);
- }
- if (p1->x == p2->x && p1->y == p2->y)
- ret=0;
- return ret;
+int geom_clip_line_code(struct coord *p1, struct coord *p2, struct rect *r) {
+ int code1,code2,ret=1;
+ long long dx,dy;
+ code1=clipcode(p1, r);
+ if (code1)
+ ret |= 2;
+ code2=clipcode(p2, r);
+ if (code2)
+ ret |= 4;
+ dx=p2->x-p1->x;
+ dy=p2->y-p1->y;
+ while (code1 || code2) {
+ if (code1 & code2)
+ return 0;
+ if (code1 & 1) {
+ p1->y+=(r->l.x-p1->x)*dy/dx;
+ p1->x=r->l.x;
+ } else if (code1 & 2) {
+ p1->y+=(r->h.x-p1->x)*dy/dx;
+ p1->x=r->h.x;
+ } else if (code1 & 4) {
+ p1->x+=(r->l.y-p1->y)*dx/dy;
+ p1->y=r->l.y;
+ } else if (code1 & 8) {
+ p1->x+=(r->h.y-p1->y)*dx/dy;
+ p1->y=r->h.y;
+ }
+ code1=clipcode(p1, r);
+ if (code1 & code2)
+ return 0;
+ if (code2 & 1) {
+ p2->y+=(r->l.x-p2->x)*dy/dx;
+ p2->x=r->l.x;
+ } else if (code2 & 2) {
+ p2->y+=(r->h.x-p2->x)*dy/dx;
+ p2->x=r->h.x;
+ } else if (code2 & 4) {
+ p2->x+=(r->l.y-p2->y)*dx/dy;
+ p2->y=r->l.y;
+ } else if (code2 & 8) {
+ p2->x+=(r->h.y-p2->y)*dx/dy;
+ p2->y=r->h.y;
+ }
+ code2=clipcode(p2, r);
+ }
+ if (p1->x == p2->x && p1->y == p2->y)
+ ret=0;
+ return ret;
}
-int
-geom_is_inside(struct coord *p, struct rect *r, int edge)
-{
- switch(edge) {
- case 0:
- return p->x >= r->l.x;
- case 1:
- return p->x <= r->h.x;
- case 2:
- return p->y >= r->l.y;
- case 3:
- return p->y <= r->h.y;
- default:
- return 0;
- }
+int geom_is_inside(struct coord *p, struct rect *r, int edge) {
+ switch(edge) {
+ case 0:
+ return p->x >= r->l.x;
+ case 1:
+ return p->x <= r->h.x;
+ case 2:
+ return p->y >= r->l.y;
+ case 3:
+ return p->y <= r->h.y;
+ default:
+ return 0;
+ }
}
-void
-geom_poly_intersection(struct coord *p1, struct coord *p2, struct rect *r, int edge, struct coord *ret)
-{
- int dx=p2->x-p1->x;
- int dy=p2->y-p1->y;
- switch(edge) {
- case 0:
- ret->y=p1->y+(r->l.x-p1->x)*dy/dx;
- ret->x=r->l.x;
- break;
- case 1:
- ret->y=p1->y+(r->h.x-p1->x)*dy/dx;
- ret->x=r->h.x;
- break;
- case 2:
- ret->x=p1->x+(r->l.y-p1->y)*dx/dy;
- ret->y=r->l.y;
- break;
- case 3:
- ret->x=p1->x+(r->h.y-p1->y)*dx/dy;
- ret->y=r->h.y;
- break;
- }
+void geom_poly_intersection(struct coord *p1, struct coord *p2, struct rect *r, int edge, struct coord *ret) {
+ int dx=p2->x-p1->x;
+ int dy=p2->y-p1->y;
+ switch(edge) {
+ case 0:
+ ret->y=p1->y+(r->l.x-p1->x)*dy/dx;
+ ret->x=r->l.x;
+ break;
+ case 1:
+ ret->y=p1->y+(r->h.x-p1->x)*dy/dx;
+ ret->x=r->h.x;
+ break;
+ case 2:
+ ret->x=p1->x+(r->l.y-p1->y)*dx/dy;
+ ret->y=r->l.y;
+ break;
+ case 3:
+ ret->x=p1->x+(r->h.y-p1->y)*dx/dy;
+ ret->y=r->h.y;
+ break;
+ }
}
-void geom_init()
-{
+void geom_init() {
}
diff --git a/navit/graphics.c b/navit/graphics.c
index f89a4f89d..1bb7dbd3c 100644
--- a/navit/graphics.c
+++ b/navit/graphics.c
@@ -67,122 +67,114 @@
* @see graphics_overlay_new()
* @see struct graphics_gc
*/
-struct graphics
-{
- struct graphics* parent;
- struct graphics_priv *priv;
- struct graphics_methods meth;
- char *default_font;
- int font_len;
- struct graphics_font **font;
- struct graphics_gc *gc[3];
- struct attr **attrs;
- struct callback_list *cbl;
- struct point_rect r;
- int gamma,brightness,contrast;
- int colormgmt;
- int font_size;
- GList *selection;
- int disabled;
- /*
- * Counter for z_order of displayitems;
- */
- int current_z_order;
- GHashTable *image_cache_hash;
+struct graphics {
+ struct graphics* parent;
+ struct graphics_priv *priv;
+ struct graphics_methods meth;
+ char *default_font;
+ int font_len;
+ struct graphics_font **font;
+ struct graphics_gc *gc[3];
+ struct attr **attrs;
+ struct callback_list *cbl;
+ struct point_rect r;
+ int gamma,brightness,contrast;
+ int colormgmt;
+ int font_size;
+ GList *selection;
+ int disabled;
+ /*
+ * Counter for z_order of displayitems;
+ */
+ int current_z_order;
+ GHashTable *image_cache_hash;
};
-struct display_context
-{
- struct graphics *gra;
- struct element *e;
- struct graphics_gc *gc;
- struct graphics_gc *gc_background;
- struct graphics_image *img;
- enum projection pro;
- int mindist;
- struct transformation *trans;
- enum item_type type;
- int maxlen;
+struct display_context {
+ struct graphics *gra;
+ struct element *e;
+ struct graphics_gc *gc;
+ struct graphics_gc *gc_background;
+ struct graphics_image *img;
+ enum projection pro;
+ int mindist;
+ struct transformation *trans;
+ enum item_type type;
+ int maxlen;
};
#define HASH_SIZE 1024
-struct hash_entry
-{
- enum item_type type;
- struct displayitem *di;
+struct hash_entry {
+ enum item_type type;
+ struct displayitem *di;
};
struct displaylist {
- int busy;
- int workload;
- struct callback *cb;
- struct layout *layout, *layout_hashed;
- struct display_context dc;
- int order, order_hashed, max_offset;
- struct mapset *ms;
- struct mapset_handle *msh;
- struct map *m;
- int conv;
- struct map_selection *sel;
- struct map_rect *mr;
- struct callback *idle_cb;
- struct event_idle *idle_ev;
- unsigned int seq;
- struct hash_entry hash_entries[HASH_SIZE];
+ int busy;
+ int workload;
+ struct callback *cb;
+ struct layout *layout, *layout_hashed;
+ struct display_context dc;
+ int order, order_hashed, max_offset;
+ struct mapset *ms;
+ struct mapset_handle *msh;
+ struct map *m;
+ int conv;
+ struct map_selection *sel;
+ struct map_rect *mr;
+ struct callback *idle_cb;
+ struct event_idle *idle_ev;
+ unsigned int seq;
+ struct hash_entry hash_entries[HASH_SIZE];
};
struct displaylist_icon_cache {
- unsigned int seq;
+ unsigned int seq;
};
-static void draw_circle(struct point *pnt, int diameter, int scale, int start, int len, struct point *res, int *pos, int dir);
+static void circle_to_points(const struct point *center, int diameter, int scale, int start, int len, struct point *res,
+ int *pos, int dir);
static void graphics_process_selection(struct graphics *gra, struct displaylist *dl);
static void graphics_gc_init(struct graphics *this_);
-static void
-clear_hash(struct displaylist *dl)
-{
- int i;
- for (i = 0 ; i < HASH_SIZE ; i++)
- dl->hash_entries[i].type=type_none;
-}
-
-static struct hash_entry *
-get_hash_entry(struct displaylist *dl, enum item_type type)
-{
- int hashidx=(type*2654435761UL) & (HASH_SIZE-1);
- int offset=dl->max_offset;
- do {
- if (!dl->hash_entries[hashidx].type)
- return NULL;
- if (dl->hash_entries[hashidx].type == type)
- return &dl->hash_entries[hashidx];
- hashidx=(hashidx+1)&(HASH_SIZE-1);
- } while (offset-- > 0);
- return NULL;
-}
-
-static struct hash_entry *
-set_hash_entry(struct displaylist *dl, enum item_type type)
-{
- int hashidx=(type*2654435761UL) & (HASH_SIZE-1);
- int offset=0;
- for (;;) {
- if (!dl->hash_entries[hashidx].type) {
- dl->hash_entries[hashidx].type=type;
- if (dl->max_offset < offset)
- dl->max_offset=offset;
- return &dl->hash_entries[hashidx];
- }
- if (dl->hash_entries[hashidx].type == type)
- return &dl->hash_entries[hashidx];
- hashidx=(hashidx+1)&(HASH_SIZE-1);
- offset++;
- }
- return NULL;
+static void clear_hash(struct displaylist *dl) {
+ int i;
+ for (i = 0 ; i < HASH_SIZE ; i++)
+ dl->hash_entries[i].type=type_none;
+}
+
+static struct hash_entry *get_hash_entry(struct displaylist *dl, enum item_type type) {
+ int hashidx=(type*2654435761UL) & (HASH_SIZE-1);
+ int offset=dl->max_offset;
+ do {
+ if (!dl->hash_entries[hashidx].type)
+ return NULL;
+ if (dl->hash_entries[hashidx].type == type)
+ return &dl->hash_entries[hashidx];
+ hashidx=(hashidx+1)&(HASH_SIZE-1);
+ } while (offset-- > 0);
+ return NULL;
+}
+
+static struct hash_entry *set_hash_entry(struct displaylist *dl, enum item_type type) {
+ int hashidx=(type*2654435761UL) & (HASH_SIZE-1);
+ int offset=0;
+ for (;;) {
+ if (!dl->hash_entries[hashidx].type) {
+ dl->hash_entries[hashidx].type=type;
+ if (dl->max_offset < offset)
+ dl->max_offset=offset;
+ return &dl->hash_entries[hashidx];
+ }
+ if (dl->hash_entries[hashidx].type == type)
+ return &dl->hash_entries[hashidx];
+ hashidx=(hashidx+1)&(HASH_SIZE-1);
+ offset++;
+ }
+ return NULL;
}
/**
@@ -199,28 +191,26 @@ set_hash_entry(struct displaylist *dl, enum item_type type)
*
* @return True if the attribute was set, false if not
*/
-static int
-graphics_set_attr_do(struct graphics *gra, struct attr *attr)
-{
- switch (attr->type) {
- case attr_gamma:
- gra->gamma=attr->u.num;
- break;
- case attr_brightness:
- gra->brightness=attr->u.num;
- break;
- case attr_contrast:
- gra->contrast=attr->u.num;
- break;
- case attr_font_size:
- gra->font_size=attr->u.num;
- return 1;
- default:
- return 0;
- }
- gra->colormgmt=(gra->gamma != 65536 || gra->brightness != 0 || gra->contrast != 65536);
- graphics_gc_init(gra);
- return 1;
+static int graphics_set_attr_do(struct graphics *gra, struct attr *attr) {
+ switch (attr->type) {
+ case attr_gamma:
+ gra->gamma=attr->u.num;
+ break;
+ case attr_brightness:
+ gra->brightness=attr->u.num;
+ break;
+ case attr_contrast:
+ gra->contrast=attr->u.num;
+ break;
+ case attr_font_size:
+ gra->font_size=attr->u.num;
+ return 1;
+ default:
+ return 0;
+ }
+ gra->colormgmt=(gra->gamma != 65536 || gra->brightness != 0 || gra->contrast != 65536);
+ graphics_gc_init(gra);
+ return 1;
}
/**
@@ -237,23 +227,19 @@ graphics_set_attr_do(struct graphics *gra, struct attr *attr)
*
* @return True if the attribute was successfully set, false otherwise.
*/
-int
-graphics_set_attr(struct graphics *gra, struct attr *attr)
-{
- int ret=1;
- /* FIXME if gra->meth doesn't have a setter, we don't even try the generic attrs - is that what we want? */
- dbg(lvl_debug,"enter\n");
- if (gra->meth.set_attr)
- ret=gra->meth.set_attr(gra->priv, attr);
- if (!ret)
- ret=graphics_set_attr_do(gra, attr);
- return ret != 0;
+int graphics_set_attr(struct graphics *gra, struct attr *attr) {
+ int ret=1;
+ /* FIXME if gra->meth doesn't have a setter, we don't even try the generic attrs - is that what we want? */
+ dbg(lvl_debug,"enter");
+ if (gra->meth.set_attr)
+ ret=gra->meth.set_attr(gra->priv, attr);
+ if (!ret)
+ ret=graphics_set_attr_do(gra, attr);
+ return ret != 0;
}
-void
-graphics_set_rect(struct graphics *gra, struct point_rect *pr)
-{
- gra->r=*pr;
+void graphics_set_rect(struct graphics *gra, struct point_rect *pr) {
+ gra->r=*pr;
}
/**
@@ -263,39 +249,39 @@ graphics_set_rect(struct graphics *gra, struct point_rect *pr)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-struct graphics * graphics_new(struct attr *parent, struct attr **attrs)
-{
- struct graphics *this_;
- struct attr *type_attr, cbl_attr;
- struct graphics_priv * (*graphicstype_new)(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl);
-
- if (! (type_attr=attr_search(attrs, NULL, attr_type))) {
- dbg(lvl_error,"Graphics plugin type is not set.\n");
- return NULL;
- }
-
- graphicstype_new=plugin_get_category_graphics(type_attr->u.str);
- if (! graphicstype_new) {
- dbg(lvl_error,"Failed to load graphics plugin %s.\n", type_attr->u.str);
- return NULL;
- }
- this_=g_new0(struct graphics, 1);
- this_->attrs=attr_list_dup(attrs);
- this_->cbl=callback_list_new();
- cbl_attr.type=attr_callback_list;
- cbl_attr.u.callback_list=this_->cbl;
- this_->attrs=attr_generic_add_attr(this_->attrs, &cbl_attr);
- this_->priv=(*graphicstype_new)(parent->u.navit, &this_->meth, this_->attrs, this_->cbl);
- this_->brightness=0;
- this_->contrast=65536;
- this_->gamma=65536;
- this_->font_size=20;
- this_->image_cache_hash = g_hash_table_new_full(g_str_hash, g_str_equal,g_free,g_free);
- while (*attrs) {
- graphics_set_attr_do(this_,*attrs);
- attrs++;
- }
- return this_;
+struct graphics * graphics_new(struct attr *parent, struct attr **attrs) {
+ struct graphics *this_;
+ struct attr *type_attr, cbl_attr;
+ struct graphics_priv * (*graphicstype_new)(struct navit *nav, struct graphics_methods *meth, struct attr **attrs,
+ struct callback_list *cbl);
+
+ if (! (type_attr=attr_search(attrs, NULL, attr_type))) {
+ dbg(lvl_error,"Graphics plugin type is not set.");
+ return NULL;
+ }
+
+ graphicstype_new=plugin_get_category_graphics(type_attr->u.str);
+ if (! graphicstype_new) {
+ dbg(lvl_error,"Failed to load graphics plugin %s.", type_attr->u.str);
+ return NULL;
+ }
+ this_=g_new0(struct graphics, 1);
+ this_->attrs=attr_list_dup(attrs);
+ this_->cbl=callback_list_new();
+ cbl_attr.type=attr_callback_list;
+ cbl_attr.u.callback_list=this_->cbl;
+ this_->attrs=attr_generic_add_attr(this_->attrs, &cbl_attr);
+ this_->priv=(*graphicstype_new)(parent->u.navit, &this_->meth, this_->attrs, this_->cbl);
+ this_->brightness=0;
+ this_->contrast=65536;
+ this_->gamma=65536;
+ this_->font_size=20;
+ this_->image_cache_hash = g_hash_table_new_full(g_str_hash, g_str_equal,g_free,g_free);
+ while (*attrs) {
+ graphics_set_attr_do(this_,*attrs);
+ attrs++;
+ }
+ return this_;
}
/**
@@ -324,9 +310,8 @@ struct graphics * graphics_new(struct attr *parent, struct attr **attrs)
*
* @author Martin Schaller (04/2008)
*/
-int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
}
/**
@@ -347,27 +332,26 @@ int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *
* @returns new overlay
* @author Martin Schaller (04/2008)
*/
-struct graphics * graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h, int wraparound)
-{
- struct graphics *this_;
- struct point_rect pr;
- if (!parent->meth.overlay_new)
- return NULL;
- this_=g_new0(struct graphics, 1);
- this_->priv=parent->meth.overlay_new(parent->priv, &this_->meth, p, w, h, wraparound);
- this_->image_cache_hash = parent->image_cache_hash;
- this_->parent = parent;
- pr.lu.x=0;
- pr.lu.y=0;
- pr.rl.x=w;
- pr.rl.y=h;
- this_->font_size=20;
- graphics_set_rect(this_, &pr);
- if (!this_->priv) {
- g_free(this_);
- this_=NULL;
- }
- return this_;
+struct graphics * graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h, int wraparound) {
+ struct graphics *this_;
+ struct point_rect pr;
+ if (!parent->meth.overlay_new)
+ return NULL;
+ this_=g_new0(struct graphics, 1);
+ this_->priv=parent->meth.overlay_new(parent->priv, &this_->meth, p, w, h, wraparound);
+ this_->image_cache_hash = parent->image_cache_hash;
+ this_->parent = parent;
+ pr.lu.x=0;
+ pr.lu.y=0;
+ pr.rl.x=w;
+ pr.rl.y=h;
+ this_->font_size=20;
+ graphics_set_rect(this_, &pr);
+ if (!this_->priv) {
+ g_free(this_);
+ this_=NULL;
+ }
+ return this_;
}
/**
@@ -379,30 +363,26 @@ struct graphics * graphics_overlay_new(struct graphics *parent, struct point *p,
* @param h The new height of the overlay
* @param wraparound The new wraparound of the overlay
*/
-void
-graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int wraparound)
-{
- if (! this_->meth.overlay_resize) {
- return;
- }
+void graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int wraparound) {
+ if (! this_->meth.overlay_resize) {
+ return;
+ }
- this_->meth.overlay_resize(this_->priv, p, w, h, wraparound);
+ this_->meth.overlay_resize(this_->priv, p, w, h, wraparound);
}
-static void
-graphics_gc_init(struct graphics *this_)
-{
- struct color background={ COLOR_BACKGROUND_ };
- struct color black={ COLOR_BLACK_ };
- struct color white={ COLOR_WHITE_ };
- if (!this_->gc[0] || !this_->gc[1] || !this_->gc[2])
- return;
- graphics_gc_set_background(this_->gc[0], &background );
- graphics_gc_set_foreground(this_->gc[0], &background );
- graphics_gc_set_background(this_->gc[1], &black );
- graphics_gc_set_foreground(this_->gc[1], &white );
- graphics_gc_set_background(this_->gc[2], &white );
- graphics_gc_set_foreground(this_->gc[2], &black );
+static void graphics_gc_init(struct graphics *this_) {
+ struct color background= { COLOR_BACKGROUND_ };
+ struct color black= { COLOR_BLACK_ };
+ struct color white= { COLOR_WHITE_ };
+ if (!this_->gc[0] || !this_->gc[1] || !this_->gc[2])
+ return;
+ graphics_gc_set_background(this_->gc[0], &background );
+ graphics_gc_set_foreground(this_->gc[0], &background );
+ graphics_gc_set_background(this_->gc[1], &black );
+ graphics_gc_set_foreground(this_->gc[1], &white );
+ graphics_gc_set_background(this_->gc[2], &white );
+ graphics_gc_set_foreground(this_->gc[2], &black );
}
@@ -413,15 +393,14 @@ graphics_gc_init(struct graphics *this_)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_init(struct graphics *this_)
-{
- if (this_->gc[0])
- return;
- this_->gc[0]=graphics_gc_new(this_);
- this_->gc[1]=graphics_gc_new(this_);
- this_->gc[2]=graphics_gc_new(this_);
- graphics_gc_init(this_);
- graphics_background_gc(this_, this_->gc[0]);
+void graphics_init(struct graphics *this_) {
+ if (this_->gc[0])
+ return;
+ this_->gc[0]=graphics_gc_new(this_);
+ this_->gc[1]=graphics_gc_new(this_);
+ this_->gc[2]=graphics_gc_new(this_);
+ graphics_gc_init(this_);
+ graphics_background_gc(this_, this_->gc[0]);
}
/**
@@ -430,19 +409,16 @@ void graphics_init(struct graphics *this_)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void * graphics_get_data(struct graphics *this_, const char *type)
-{
- return (this_->meth.get_data(this_->priv, type));
+void * graphics_get_data(struct graphics *this_, const char *type) {
+ return (this_->meth.get_data(this_->priv, type));
}
-void graphics_add_callback(struct graphics *this_, struct callback *cb)
-{
- callback_list_add(this_->cbl, cb);
+void graphics_add_callback(struct graphics *this_, struct callback *cb) {
+ callback_list_add(this_->cbl, cb);
}
-void graphics_remove_callback(struct graphics *this_, struct callback *cb)
-{
- callback_list_remove(this_->cbl, cb);
+void graphics_remove_callback(struct graphics *this_, struct callback *cb) {
+ callback_list_remove(this_->cbl, cb);
}
/**
@@ -451,29 +427,27 @@ void graphics_remove_callback(struct graphics *this_, struct callback *cb)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-struct graphics_font * graphics_font_new(struct graphics *gra, int size, int flags)
-{
- struct graphics_font *this_;
+struct graphics_font * graphics_font_new(struct graphics *gra, int size, int flags) {
+ struct graphics_font *this_;
- this_=g_new0(struct graphics_font,1);
- this_->priv=gra->meth.font_new(gra->priv, &this_->meth, gra->default_font, size, flags);
- return this_;
+ this_=g_new0(struct graphics_font,1);
+ this_->priv=gra->meth.font_new(gra->priv, &this_->meth, gra->default_font, size, flags);
+ return this_;
}
-struct graphics_font * graphics_named_font_new(struct graphics *gra, char *font, int size, int flags)
-{
- struct graphics_font *this_;
+struct graphics_font * graphics_named_font_new(struct graphics *gra, char *font, int size, int flags) {
+ struct graphics_font *this_;
- this_=g_new0(struct graphics_font,1);
- this_->priv=gra->meth.font_new(gra->priv, &this_->meth, font, size, flags);
- return this_;
+ this_=g_new0(struct graphics_font,1);
+ this_->priv=gra->meth.font_new(gra->priv, &this_->meth, font, size, flags);
+ return this_;
}
void graphics_font_destroy(struct graphics_font *gra_font) {
- if(!gra_font)
- return;
- gra_font->meth.font_destroy(gra_font->priv);
- g_free(gra_font);
+ if(!gra_font)
+ return;
+ gra_font->meth.font_destroy(gra_font->priv);
+ g_free(gra_font);
}
/**
@@ -483,38 +457,37 @@ void graphics_font_destroy(struct graphics_font *gra_font) {
* @returns nothing
* @author David Tegze (02/2011)
*/
-void graphics_free(struct graphics *gra)
-{
- if (!gra)
- return;
-
- /* If it's not an overlay, free the image cache. */
- if(!gra->parent) {
- struct graphics_image *img;
- GList *ll, *l;
-
- /* We can't specify context (pointer to struct graphics) for g_hash_table_new to have it passed to free function
- so we have to free img->priv manually, the rest would be freed by g_hash_table_destroy. GHashTableIter isn't used because it
- broke n800 build at r5107.
- */
- for(ll=l=g_hash_to_list(gra->image_cache_hash);l;l=g_list_next(l)) {
- img=l->data;
- if (img && gra->meth.image_free)
- gra->meth.image_free(gra->priv, img->priv);
- }
- g_list_free(ll);
- g_hash_table_destroy(gra->image_cache_hash);
- }
-
- attr_list_free(gra->attrs);
- graphics_gc_destroy(gra->gc[0]);
- graphics_gc_destroy(gra->gc[1]);
- graphics_gc_destroy(gra->gc[2]);
- g_free(gra->default_font);
- graphics_font_destroy_all(gra);
- g_free(gra->font);
- gra->meth.graphics_destroy(gra->priv);
- g_free(gra);
+void graphics_free(struct graphics *gra) {
+ if (!gra)
+ return;
+
+ /* If it's not an overlay, free the image cache. */
+ if(!gra->parent) {
+ struct graphics_image *img;
+ GList *ll, *l;
+
+ /* We can't specify context (pointer to struct graphics) for g_hash_table_new to have it passed to free function
+ so we have to free img->priv manually, the rest would be freed by g_hash_table_destroy. GHashTableIter isn't used because it
+ broke n800 build at r5107.
+ */
+ for(ll=l=g_hash_to_list(gra->image_cache_hash); l; l=g_list_next(l)) {
+ img=l->data;
+ if (img && gra->meth.image_free)
+ gra->meth.image_free(gra->priv, img->priv);
+ }
+ g_list_free(ll);
+ g_hash_table_destroy(gra->image_cache_hash);
+ }
+
+ attr_list_free(gra->attrs);
+ graphics_gc_destroy(gra->gc[0]);
+ graphics_gc_destroy(gra->gc[1]);
+ graphics_gc_destroy(gra->gc[2]);
+ g_free(gra->default_font);
+ graphics_font_destroy_all(gra);
+ g_free(gra->font);
+ gra->meth.graphics_destroy(gra->priv);
+ g_free(gra);
}
/**
@@ -524,15 +497,14 @@ void graphics_free(struct graphics *gra)
* @returns nothing
* @author Sarah Nordstrom (05/2008)
*/
-void graphics_font_destroy_all(struct graphics *gra)
-{
- int i;
- for(i = 0 ; i < gra->font_len; i++) {
- if(!gra->font[i]) continue;
- gra->font[i]->meth.font_destroy(gra->font[i]->priv);
- g_free(gra->font[i]);
- gra->font[i] = NULL;
- }
+void graphics_font_destroy_all(struct graphics *gra) {
+ int i;
+ for(i = 0 ; i < gra->font_len; i++) {
+ if(!gra->font[i]) continue;
+ gra->font[i]->meth.font_destroy(gra->font[i]->priv);
+ g_free(gra->font[i]);
+ gra->font[i] = NULL;
+ }
}
/**
@@ -541,14 +513,13 @@ void graphics_font_destroy_all(struct graphics *gra)
* @returns new graphics context
* @author Martin Schaller (04/2008)
*/
-struct graphics_gc * graphics_gc_new(struct graphics *gra)
-{
- struct graphics_gc *this_;
+struct graphics_gc * graphics_gc_new(struct graphics *gra) {
+ struct graphics_gc *this_;
- this_=g_new0(struct graphics_gc,1);
- this_->priv=gra->meth.gc_new(gra->priv, &this_->meth);
- this_->gra=gra;
- return this_;
+ this_=g_new0(struct graphics_gc,1);
+ this_->priv=gra->meth.gc_new(gra->priv, &this_->meth);
+ this_->gra=gra;
+ return this_;
}
/**
@@ -556,45 +527,42 @@ struct graphics_gc * graphics_gc_new(struct graphics *gra)
* @param gc context to destroy
* @author Martin Schaller (04/2008)
*/
-void graphics_gc_destroy(struct graphics_gc *gc)
-{
- if (!gc)
- return;
- gc->meth.gc_destroy(gc->priv);
- g_free(gc);
-}
-
-static void
-graphics_convert_color(struct graphics *gra, struct color *in, struct color *out)
-{
- *out=*in;
- if (gra->brightness) {
- out->r+=gra->brightness;
- out->g+=gra->brightness;
- out->b+=gra->brightness;
- }
- if (gra->contrast != 65536) {
- out->r=out->r*gra->contrast/65536;
- out->g=out->g*gra->contrast/65536;
- out->b=out->b*gra->contrast/65536;
- }
- if (out->r < 0)
- out->r=0;
- if (out->r > 65535)
- out->r=65535;
- if (out->g < 0)
- out->g=0;
- if (out->g > 65535)
- out->g=65535;
- if (out->b < 0)
- out->b=0;
- if (out->b > 65535)
- out->b=65535;
- if (gra->gamma != 65536) {
- out->r=pow(out->r/65535.0,gra->gamma/65536.0)*65535.0;
- out->g=pow(out->g/65535.0,gra->gamma/65536.0)*65535.0;
- out->b=pow(out->b/65535.0,gra->gamma/65536.0)*65535.0;
- }
+void graphics_gc_destroy(struct graphics_gc *gc) {
+ if (!gc)
+ return;
+ gc->meth.gc_destroy(gc->priv);
+ g_free(gc);
+}
+
+static void graphics_convert_color(struct graphics *gra, struct color *in, struct color *out) {
+ *out=*in;
+ if (gra->brightness) {
+ out->r+=gra->brightness;
+ out->g+=gra->brightness;
+ out->b+=gra->brightness;
+ }
+ if (gra->contrast != 65536) {
+ out->r=out->r*gra->contrast/65536;
+ out->g=out->g*gra->contrast/65536;
+ out->b=out->b*gra->contrast/65536;
+ }
+ if (out->r < 0)
+ out->r=0;
+ if (out->r > 65535)
+ out->r=65535;
+ if (out->g < 0)
+ out->g=0;
+ if (out->g > 65535)
+ out->g=65535;
+ if (out->b < 0)
+ out->b=0;
+ if (out->b > 65535)
+ out->b=65535;
+ if (gra->gamma != 65536) {
+ out->r=pow(out->r/65535.0,gra->gamma/65536.0)*65535.0;
+ out->g=pow(out->g/65535.0,gra->gamma/65536.0)*65535.0;
+ out->b=pow(out->b/65535.0,gra->gamma/65536.0)*65535.0;
+ }
}
/**
@@ -603,14 +571,13 @@ graphics_convert_color(struct graphics *gra, struct color *in, struct color *out
* @param c color to set
* @author Martin Schaller (04/2008)
*/
-void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c)
-{
- struct color cn;
- if (gc->gra->colormgmt) {
- graphics_convert_color(gc->gra, c, &cn);
- c=&cn;
- }
- gc->meth.gc_set_foreground(gc->priv, c);
+void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c) {
+ struct color cn;
+ if (gc->gra->colormgmt) {
+ graphics_convert_color(gc->gra, c, &cn);
+ c=&cn;
+ }
+ gc->meth.gc_set_foreground(gc->priv, c);
}
/**
@@ -619,14 +586,13 @@ void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_gc_set_background(struct graphics_gc *gc, struct color *c)
-{
- struct color cn;
- if (gc->gra->colormgmt) {
- graphics_convert_color(gc->gra, c, &cn);
- c=&cn;
- }
- gc->meth.gc_set_background(gc->priv, c);
+void graphics_gc_set_background(struct graphics_gc *gc, struct color *c) {
+ struct color cn;
+ if (gc->gra->colormgmt) {
+ graphics_convert_color(gc->gra, c, &cn);
+ c=&cn;
+ }
+ gc->meth.gc_set_background(gc->priv, c);
}
@@ -636,9 +602,8 @@ void graphics_gc_set_background(struct graphics_gc *gc, struct color *c)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_gc_set_linewidth(struct graphics_gc *gc, int width)
-{
- gc->meth.gc_set_linewidth(gc->priv, width);
+void graphics_gc_set_linewidth(struct graphics_gc *gc, int width) {
+ gc->meth.gc_set_linewidth(gc->priv, width);
}
/**
@@ -647,10 +612,9 @@ void graphics_gc_set_linewidth(struct graphics_gc *gc, int width)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n)
-{
- if (gc->meth.gc_set_dashes)
- gc->meth.gc_set_dashes(gc->priv, width, offset, dash_list, n);
+void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n) {
+ if (gc->meth.gc_set_dashes)
+ gc->meth.gc_set_dashes(gc->priv, width, offset, dash_list, n);
}
/**
@@ -663,123 +627,122 @@ void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsig
* @returns <>
* @author Martin Schaller (04/2008)
*/
-struct graphics_image * graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h)
-{
- return graphics_image_new_scaled_rotated(gra, path, w, h, 0);
-}
-
-static void
-image_new_helper(struct graphics *gra, struct graphics_image *this_, char *path, char *name, int width, int height, int rotate, int zip)
-{
- int i=0;
- int stdsizes[]={8,12,16,22,24,32,36,48,64,72,96,128,192,256};
- const int numstdsizes=sizeof(stdsizes)/sizeof(int);
- int sz;
- int mode=1;
- int bmstd=0;
- sz=width>0?width:height;
- while (mode<=8) {
- char *new_name=NULL;
- int n;
- switch (mode) {
- case 1:
- /* The best variant both for cpu usage and quality would be prescaled png of a needed size */
- mode++;
- if (width != IMAGE_W_H_UNSET && height != IMAGE_W_H_UNSET) {
- new_name=g_strdup_printf("%s_%d_%d.png", name, width, height);
- }
- break;
- case 2:
- mode++;
- /* Try to load image by the exact name given by user. For example, if she wants to
- scale some prescaled png variant to a new size given as function params, or have
- default png image to be displayed unscaled. */
- new_name=g_strdup(path);
- break;
- case 3:
- mode++;
- /* Next, try uncompressed and compressed svgs as they should give best quality but
- rendering might take more cpu resources when the image is displayed for the first time */
- new_name=g_strdup_printf("%s.svg", name);
- break;
- case 4:
- mode++;
- new_name=g_strdup_printf("%s.svgz", name);
- break;
- case 5:
- mode++;
- i=0;
- /* If we have no size specifiers, try the default png now */
- if(sz<=0) {
- new_name=g_strdup_printf("%s.png", name);
- break;
- }
- /* Find best matching size from standard row */
- for(bmstd=0;bmstd<numstdsizes;bmstd++)
- if(stdsizes[bmstd]>sz)
- break;
- i=1;
- /* Fall through */
- case 6:
- /* Select best matching image from standard row */
- if(sz>0) {
- /* If size were specified, start with bmstd and then try standard sizes in row
- * bmstd, bmstd+1, bmstd+2, .. numstdsizes-1, bmstd-1, bmstd-2, .., 0 */
- n=bmstd+i;
- if((bmstd+i)>=numstdsizes)
- n=numstdsizes-i-1;
-
- if(++i==numstdsizes)
- mode++;
- } else {
- /* If no size were specified, start with the smallest standard size and then try following ones */
- n=i++;
- if(i==numstdsizes)
- mode+=2;
- }
- if(n<0||n>=numstdsizes)
- break;
- new_name=g_strdup_printf("%s_%d_%d.png", name, stdsizes[n],stdsizes[n]);
- break;
-
- case 7:
- /* Scaling the default prescaled png of unknown size to the needed size will give random quality loss */
- mode++;
- new_name=g_strdup_printf("%s.png", name);
- break;
- case 8:
- /* xpm format is used as a last resort, because its not widely supported and we are moving to svg and png formats */
- mode++;
- new_name=g_strdup_printf("%s.xpm", name);
- break;
- }
- if (! new_name)
- continue;
-
- this_->width=width;
- this_->height=height;
- dbg(lvl_debug,"Trying to load image '%s' for '%s' at %dx%d\n", new_name, path, width, height);
- if (zip) {
- unsigned char *start;
- int len;
- if (file_get_contents(new_name, &start, &len)) {
- struct graphics_image_buffer buffer={"buffer:",graphics_image_type_unknown};
- buffer.start=start;
- buffer.len=len;
- this_->priv=gra->meth.image_new(gra->priv, &this_->meth, (char *)&buffer, &this_->width, &this_->height, &this_->hot, rotate);
- g_free(start);
- }
- } else {
- if (strcmp(new_name,"buffer:"))
- this_->priv=gra->meth.image_new(gra->priv, &this_->meth, new_name, &this_->width, &this_->height, &this_->hot, rotate);
- }
- if (this_->priv) {
- dbg(lvl_info,"Using image '%s' for '%s' at %dx%d\n", new_name, path, width, height);
- g_free(new_name);
- break;
- }
- g_free(new_name);
- }
+struct graphics_image * graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h) {
+ return graphics_image_new_scaled_rotated(gra, path, w, h, 0);
+}
+
+static void image_new_helper(struct graphics *gra, struct graphics_image *this_, char *path, char *name, int width,
+ int height, int rotate, int zip) {
+ int i=0;
+ int stdsizes[]= {8,12,16,22,24,32,36,48,64,72,96,128,192,256};
+ const int numstdsizes=sizeof(stdsizes)/sizeof(int);
+ int sz;
+ int mode=1;
+ int bmstd=0;
+ sz=width>0?width:height;
+ while (mode<=8) {
+ char *new_name=NULL;
+ int n;
+ switch (mode) {
+ case 1:
+ /* The best variant both for cpu usage and quality would be prescaled png of a needed size */
+ mode++;
+ if (width != IMAGE_W_H_UNSET && height != IMAGE_W_H_UNSET) {
+ new_name=g_strdup_printf("%s_%d_%d.png", name, width, height);
+ }
+ break;
+ case 2:
+ mode++;
+ /* Try to load image by the exact name given by user. For example, if she wants to
+ scale some prescaled png variant to a new size given as function params, or have
+ default png image to be displayed unscaled. */
+ new_name=g_strdup(path);
+ break;
+ case 3:
+ mode++;
+ /* Next, try uncompressed and compressed svgs as they should give best quality but
+ rendering might take more cpu resources when the image is displayed for the first time */
+ new_name=g_strdup_printf("%s.svg", name);
+ break;
+ case 4:
+ mode++;
+ new_name=g_strdup_printf("%s.svgz", name);
+ break;
+ case 5:
+ mode++;
+ i=0;
+ /* If we have no size specifiers, try the default png now */
+ if(sz<=0) {
+ new_name=g_strdup_printf("%s.png", name);
+ break;
+ }
+ /* Find best matching size from standard row */
+ for(bmstd=0; bmstd<numstdsizes; bmstd++)
+ if(stdsizes[bmstd]>sz)
+ break;
+ i=1;
+ /* Fall through */
+ case 6:
+ /* Select best matching image from standard row */
+ if(sz>0) {
+ /* If size were specified, start with bmstd and then try standard sizes in row
+ * bmstd, bmstd+1, bmstd+2, .. numstdsizes-1, bmstd-1, bmstd-2, .., 0 */
+ n=bmstd+i;
+ if((bmstd+i)>=numstdsizes)
+ n=numstdsizes-i-1;
+
+ if(++i==numstdsizes)
+ mode++;
+ } else {
+ /* If no size were specified, start with the smallest standard size and then try following ones */
+ n=i++;
+ if(i==numstdsizes)
+ mode+=2;
+ }
+ if(n<0||n>=numstdsizes)
+ break;
+ new_name=g_strdup_printf("%s_%d_%d.png", name, stdsizes[n],stdsizes[n]);
+ break;
+
+ case 7:
+ /* Scaling the default prescaled png of unknown size to the needed size will give random quality loss */
+ mode++;
+ new_name=g_strdup_printf("%s.png", name);
+ break;
+ case 8:
+ /* xpm format is used as a last resort, because its not widely supported and we are moving to svg and png formats */
+ mode++;
+ new_name=g_strdup_printf("%s.xpm", name);
+ break;
+ }
+ if (! new_name)
+ continue;
+
+ this_->width=width;
+ this_->height=height;
+ dbg(lvl_debug,"Trying to load image '%s' for '%s' at %dx%d", new_name, path, width, height);
+ if (zip) {
+ unsigned char *start;
+ int len;
+ if (file_get_contents(new_name, &start, &len)) {
+ struct graphics_image_buffer buffer= {"buffer:",graphics_image_type_unknown};
+ buffer.start=start;
+ buffer.len=len;
+ this_->priv=gra->meth.image_new(gra->priv, &this_->meth, (char *)&buffer, &this_->width, &this_->height, &this_->hot,
+ rotate);
+ g_free(start);
+ }
+ } else {
+ if (strcmp(new_name,"buffer:"))
+ this_->priv=gra->meth.image_new(gra->priv, &this_->meth, new_name, &this_->width, &this_->height, &this_->hot, rotate);
+ }
+ if (this_->priv) {
+ dbg(lvl_info,"Using image '%s' for '%s' at %dx%d", new_name, path, width, height);
+ g_free(new_name);
+ break;
+ }
+ g_free(new_name);
+ }
}
/**
@@ -793,103 +756,102 @@ image_new_helper(struct graphics *gra, struct graphics_image *this_, char *path,
* @returns <>
* @author Martin Schaller (04/2008)
*/
-struct graphics_image * graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate)
-{
- struct graphics_image *this_;
- char* hash_key = g_strdup_printf("%s*%d*%d*%d",path,w,h,rotate);
- struct file_wordexp *we;
- int i;
- char **paths;
-
- if ( g_hash_table_lookup_extended( gra->image_cache_hash, hash_key, NULL, (gpointer)&this_) ) {
- g_free(hash_key);
- dbg(lvl_debug,"Found cached image%sfor '%s'\n",this_?" ":" miss ",path);
- return this_;
- }
-
- this_=g_new0(struct graphics_image,1);
- this_->height=h;
- this_->width=w;
-
- we=file_wordexp_new(path);
- paths=file_wordexp_get_array(we);
-
- for(i=0;i<file_wordexp_get_count(we) && !this_->priv;i++) {
- char *ext;
- char *s, *name;
- char *pathi=paths[i];
- int len=strlen(pathi);
- int i,k;
- int newwidth=IMAGE_W_H_UNSET, newheight=IMAGE_W_H_UNSET;
-
- ext=g_utf8_strrchr(pathi,-1,'.');
- i=pathi-ext+len;
-
- /* Dont allow too long or too short file name extensions*/
- if(ext && ((i>5) || (i<1)))
- ext=NULL;
-
- /* Search for _w_h name part, begin from char before extension if it exists */
- if(ext)
- s=ext-1;
- else
- s=pathi+len;
-
- k=1;
- while(s>pathi && g_ascii_isdigit(*s)) {
- if(newheight<0)
- newheight=0;
- newheight+=(*s-'0')*k;
- k*=10;
- s--;
- }
-
- if(k>1 && s>pathi && *s=='_') {
- k=1;
- s--;
- while(s>pathi && g_ascii_isdigit(*s)) {
- if(newwidth<0)
- newwidth=0;
- newwidth+=(*s-'0')*k;;
- k*=10;
- s--;
- }
- }
-
- if(k==1 || s<=pathi || *s!='_') {
- newwidth=IMAGE_W_H_UNSET;
- newheight=IMAGE_W_H_UNSET;
- if(ext)
- s=ext;
- else
- s=pathi+len;
-
- }
-
- /* If exact h and w values were given as function parameters, they take precedence over values guessed from the image name */
- if(w!=IMAGE_W_H_UNSET)
- newwidth=w;
- if(h!=IMAGE_W_H_UNSET)
- newheight=h;
-
- name=g_strndup(pathi,s-pathi);
- image_new_helper(gra, this_, pathi, name, newwidth, newheight, rotate, 0);
- if (!this_->priv && strstr(pathi, ".zip/"))
- image_new_helper(gra, this_, pathi, name, newwidth, newheight, rotate, 1);
- g_free(name);
- }
-
- file_wordexp_destroy(we);
-
- if (! this_->priv) {
- dbg(lvl_error,"No image for '%s'\n", path);
- g_free(this_);
- this_=NULL;
- }
-
- g_hash_table_insert(gra->image_cache_hash, hash_key, (gpointer)this_ );
-
- return this_;
+struct graphics_image * graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate) {
+ struct graphics_image *this_;
+ char* hash_key = g_strdup_printf("%s*%d*%d*%d",path,w,h,rotate);
+ struct file_wordexp *we;
+ int i;
+ char **paths;
+
+ if ( g_hash_table_lookup_extended( gra->image_cache_hash, hash_key, NULL, (gpointer)&this_) ) {
+ g_free(hash_key);
+ dbg(lvl_debug,"Found cached image%sfor '%s'",this_?" ":" miss ",path);
+ return this_;
+ }
+
+ this_=g_new0(struct graphics_image,1);
+ this_->height=h;
+ this_->width=w;
+
+ we=file_wordexp_new(path);
+ paths=file_wordexp_get_array(we);
+
+ for(i=0; i<file_wordexp_get_count(we) && !this_->priv; i++) {
+ char *ext;
+ char *s, *name;
+ char *pathi=paths[i];
+ int len=strlen(pathi);
+ int i,k;
+ int newwidth=IMAGE_W_H_UNSET, newheight=IMAGE_W_H_UNSET;
+
+ ext=g_utf8_strrchr(pathi,-1,'.');
+ i=pathi-ext+len;
+
+ /* Dont allow too long or too short file name extensions*/
+ if(ext && ((i>5) || (i<1)))
+ ext=NULL;
+
+ /* Search for _w_h name part, begin from char before extension if it exists */
+ if(ext)
+ s=ext-1;
+ else
+ s=pathi+len;
+
+ k=1;
+ while(s>pathi && g_ascii_isdigit(*s)) {
+ if(newheight<0)
+ newheight=0;
+ newheight+=(*s-'0')*k;
+ k*=10;
+ s--;
+ }
+
+ if(k>1 && s>pathi && *s=='_') {
+ k=1;
+ s--;
+ while(s>pathi && g_ascii_isdigit(*s)) {
+ if(newwidth<0)
+ newwidth=0;
+ newwidth+=(*s-'0')*k;;
+ k*=10;
+ s--;
+ }
+ }
+
+ if(k==1 || s<=pathi || *s!='_') {
+ newwidth=IMAGE_W_H_UNSET;
+ newheight=IMAGE_W_H_UNSET;
+ if(ext)
+ s=ext;
+ else
+ s=pathi+len;
+
+ }
+
+ /* If exact h and w values were given as function parameters, they take precedence over values guessed from the image name */
+ if(w!=IMAGE_W_H_UNSET)
+ newwidth=w;
+ if(h!=IMAGE_W_H_UNSET)
+ newheight=h;
+
+ name=g_strndup(pathi,s-pathi);
+ image_new_helper(gra, this_, pathi, name, newwidth, newheight, rotate, 0);
+ if (!this_->priv && strstr(pathi, ".zip/"))
+ image_new_helper(gra, this_, pathi, name, newwidth, newheight, rotate, 1);
+ g_free(name);
+ }
+
+ file_wordexp_destroy(we);
+
+ if (! this_->priv) {
+ dbg(lvl_error,"No image for '%s'", path);
+ g_free(this_);
+ this_=NULL;
+ }
+
+ g_hash_table_insert(gra->image_cache_hash, hash_key, (gpointer)this_ );
+
+ return this_;
}
/**
@@ -899,9 +861,8 @@ struct graphics_image * graphics_image_new_scaled_rotated(struct graphics *gra,
* @returns <>
* @author Martin Schaller (04/2008)
*/
-struct graphics_image * graphics_image_new(struct graphics *gra, char *path)
-{
- return graphics_image_new_scaled_rotated(gra, path, IMAGE_W_H_UNSET, IMAGE_W_H_UNSET, 0);
+struct graphics_image * graphics_image_new(struct graphics *gra, char *path) {
+ return graphics_image_new_scaled_rotated(gra, path, IMAGE_W_H_UNSET, IMAGE_W_H_UNSET, 0);
}
/**
@@ -910,9 +871,8 @@ struct graphics_image * graphics_image_new(struct graphics *gra, char *path)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_image_free(struct graphics *gra, struct graphics_image *img)
-{
- /* Image is cached inside gra->image_cache_hash. So it would be freed only when graphics is destroyed => Do nothing here. */
+void graphics_image_free(struct graphics *gra, struct graphics_image *img) {
+ /* Image is cached inside gra->image_cache_hash. So it would be freed only when graphics is destroyed => Do nothing here. */
}
/**
@@ -926,9 +886,8 @@ void graphics_image_free(struct graphics *gra, struct graphics_image *img)
* @param mode specify beginning or end of drawing
* @author Martin Schaller (04/2008)
*/
-void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode)
-{
- this_->meth.draw_mode(this_->priv, mode);
+void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode) {
+ this_->meth.draw_mode(this_->priv, mode);
}
/**
@@ -937,31 +896,31 @@ void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count)
-{
- this_->meth.draw_lines(this_->priv, gc->priv, p, count);
+void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count) {
+ this_->meth.draw_lines(this_->priv, gc->priv, p, count);
}
/**
- * FIXME
- * @param <>
- * @returns <>
+ * @brief Draw a circle
+ * @param this_ The graphics instance on which to draw
+ * @param gc The graphics context
+ * @param p The coordinates of the center of the circle
+ * @param r The radius of the circle
+ *
* @author Martin Schaller (04/2008)
*/
-void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r)
-{
- struct point *pnt=g_alloca(sizeof(struct point)*(r*4+64));
- int i=0;
+void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r) {
+ struct point *pnt=g_alloca(sizeof(struct point)*(r*4+64));
+ int i=0;
- if(this_->meth.draw_circle)
- this_->meth.draw_circle(this_->priv, gc->priv, p, r);
- else
- {
- draw_circle(p, r, 0, -1, 1026, pnt, &i, 1);
- pnt[i] = pnt[0];
- i++;
- this_->meth.draw_lines(this_->priv, gc->priv, pnt, i);
- }
+ if(this_->meth.draw_circle)
+ this_->meth.draw_circle(this_->priv, gc->priv, p, r);
+ else {
+ circle_to_points(p, r, 0, -1, 1026, pnt, &i, 1);
+ pnt[i] = pnt[0];
+ i++;
+ this_->meth.draw_lines(this_->priv, gc->priv, pnt, i);
+ }
}
/**
@@ -970,30 +929,29 @@ void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h)
-{
- this_->meth.draw_rectangle(this_->priv, gc->priv, p, w, h);
+void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h) {
+ this_->meth.draw_rectangle(this_->priv, gc->priv, p, w, h);
}
-void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill)
-{
- struct point *p=g_alloca(sizeof(struct point)*(r*4+32));
- struct point pi0={plu->x+r,plu->y+r};
- struct point pi1={plu->x+w-r,plu->y+r};
- struct point pi2={plu->x+w-r,plu->y+h-r};
- struct point pi3={plu->x+r,plu->y+h-r};
- int i=0;
+void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h,
+ int r, int fill) {
+ struct point *p=g_alloca(sizeof(struct point)*(r*4+32));
+ struct point pi0= {plu->x+r,plu->y+r};
+ struct point pi1= {plu->x+w-r,plu->y+r};
+ struct point pi2= {plu->x+w-r,plu->y+h-r};
+ struct point pi3= {plu->x+r,plu->y+h-r};
+ int i=0;
- draw_circle(&pi2, r*2, 0, -1, 258, p, &i, 1);
- draw_circle(&pi1, r*2, 0, 255, 258, p, &i, 1);
- draw_circle(&pi0, r*2, 0, 511, 258, p, &i, 1);
- draw_circle(&pi3, r*2, 0, 767, 258, p, &i, 1);
- p[i]=p[0];
- i++;
- if (fill)
- this_->meth.draw_polygon(this_->priv, gc->priv, p, i);
- else
- this_->meth.draw_lines(this_->priv, gc->priv, p, i);
+ circle_to_points(&pi2, r*2, 0, -1, 258, p, &i, 1);
+ circle_to_points(&pi1, r*2, 0, 255, 258, p, &i, 1);
+ circle_to_points(&pi0, r*2, 0, 511, 258, p, &i, 1);
+ circle_to_points(&pi3, r*2, 0, 767, 258, p, &i, 1);
+ p[i]=p[0];
+ i++;
+ if (fill)
+ this_->meth.draw_polygon(this_->priv, gc->priv, p, i);
+ else
+ this_->meth.draw_lines(this_->priv, gc->priv, p, i);
}
@@ -1003,9 +961,9 @@ void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2, struct graphics_font *font, char *text, struct point *p, int dx, int dy)
-{
- this_->meth.draw_text(this_->priv, gc1->priv, gc2 ? gc2->priv : NULL, font->priv, text, p, dx, dy);
+void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2,
+ struct graphics_font *font, char *text, struct point *p, int dx, int dy) {
+ this_->meth.draw_text(this_->priv, gc1->priv, gc2 ? gc2->priv : NULL, font->priv, text, p, dx, dy);
}
@@ -1015,9 +973,9 @@ void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate)
-{
- this_->meth.get_text_bbox(this_->priv, font->priv, text, dx, dy, ret, estimate);
+void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy,
+ struct point *ret, int estimate) {
+ this_->meth.get_text_bbox(this_->priv, font->priv, text, dx, dy, ret, estimate);
}
/**
@@ -1026,16 +984,14 @@ void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font,
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_overlay_disable(struct graphics *this_, int disable)
-{
- this_->disabled = disable;
- if (this_->meth.overlay_disable)
- this_->meth.overlay_disable(this_->priv, disable);
+void graphics_overlay_disable(struct graphics *this_, int disable) {
+ this_->disabled = disable;
+ if (this_->meth.overlay_disable)
+ this_->meth.overlay_disable(this_->priv, disable);
}
-int graphics_is_disabled(struct graphics *this_)
-{
- return this_->disabled || (this_->parent && this_->parent->disabled);
+int graphics_is_disabled(struct graphics *this_) {
+ return this_->disabled || (this_->parent && this_->parent->disabled);
}
/**
@@ -1044,9 +1000,8 @@ int graphics_is_disabled(struct graphics *this_)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img)
-{
- this_->meth.draw_image(this_->priv, gc->priv, p, img->priv);
+void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img) {
+ this_->meth.draw_image(this_->priv, gc->priv, p, img->priv);
}
@@ -1055,19 +1010,15 @@ void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-int
-graphics_draw_drag(struct graphics *this_, struct point *p)
-{
- if (!this_->meth.draw_drag)
- return 0;
- this_->meth.draw_drag(this_->priv, p);
- return 1;
+int graphics_draw_drag(struct graphics *this_, struct point *p) {
+ if (!this_->meth.draw_drag)
+ return 0;
+ this_->meth.draw_drag(this_->priv, p);
+ return 1;
}
-void
-graphics_background_gc(struct graphics *this_, struct graphics_gc *gc)
-{
- this_->meth.background_gc(this_->priv, gc ? gc->priv : NULL);
+void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc) {
+ this_->meth.background_gc(this_->priv, gc ? gc->priv : NULL);
}
@@ -1112,13 +1063,13 @@ graphics_background_gc(struct graphics *this_, struct graphics_gc *gc)
* supported by the plugin
*/
int graphics_show_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd) {
- int ret;
- if (!this_->meth.show_native_keyboard)
- ret = -1;
- else
- ret = this_->meth.show_native_keyboard(kbd);
- dbg(lvl_debug, "return %d\n", ret);
- return ret;
+ int ret;
+ if (!this_->meth.show_native_keyboard)
+ ret = -1;
+ else
+ ret = this_->meth.show_native_keyboard(kbd);
+ dbg(lvl_debug, "return %d", ret);
+ return ret;
}
@@ -1149,10 +1100,10 @@ int graphics_show_native_keyboard (struct graphics *this_, struct graphics_keybo
* by the plugin
*/
int graphics_hide_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd) {
- if (!this_->meth.hide_native_keyboard)
- return 0;
- this_->meth.hide_native_keyboard(kbd);
- return 1;
+ if (!this_->meth.hide_native_keyboard)
+ return 0;
+ this_->meth.hide_native_keyboard(kbd);
+ return 1;
}
#include "attr.h"
@@ -1166,12 +1117,12 @@ int graphics_hide_native_keyboard (struct graphics *this_, struct graphics_keybo
* @author Martin Schaller (04/2008)
*/
struct displayitem {
- struct displayitem *next;
- struct item item;
- char *label;
- int z_order;
- int count;
- struct coord c[0];
+ struct displayitem *next;
+ struct item item;
+ char *label;
+ int z_order;
+ int count;
+ struct coord c[0];
};
/**
@@ -1180,18 +1131,17 @@ struct displayitem {
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static void xdisplay_free(struct displaylist *dl)
-{
- int i;
- for (i = 0 ; i < HASH_SIZE ; i++) {
- struct displayitem *di=dl->hash_entries[i].di;
- while (di) {
- struct displayitem *next=di->next;
- g_free(di);
- di=next;
- }
- dl->hash_entries[i].di=NULL;
- }
+static void xdisplay_free(struct displaylist *dl) {
+ int i;
+ for (i = 0 ; i < HASH_SIZE ; i++) {
+ struct displayitem *di=dl->hash_entries[i].di;
+ while (di) {
+ struct displayitem *next=di->next;
+ g_free(di);
+ di=next;
+ }
+ dl->hash_entries[i].di=NULL;
+ }
}
/**
@@ -1200,42 +1150,42 @@ static void xdisplay_free(struct displaylist *dl)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static void display_add(struct hash_entry *entry, struct item *item, int count, struct coord *c, char **label, int label_count)
-{
- struct displayitem *di;
- int len,i;
- char *p;
-
- len=sizeof(*di)+count*sizeof(*c);
- if (label && label_count) {
- for (i = 0 ; i < label_count ; i++) {
- if (label[i])
- len+=strlen(label[i])+1;
- else
- len++;
- }
- }
- p=g_malloc(len);
-
- di=(struct displayitem *)p;
- p+=sizeof(*di)+count*sizeof(*c);
- di->item=*item;
- di->z_order=0;
- if (label && label_count) {
- di->label=p;
- for (i = 0 ; i < label_count ; i++) {
- if (label[i]) {
- strcpy(p, label[i]);
- p+=strlen(label[i])+1;
- } else
- *p++='\0';
- }
- } else
- di->label=NULL;
- di->count=count;
- memcpy(di->c, c, count*sizeof(*c));
- di->next=entry->di;
- entry->di=di;
+static void display_add(struct hash_entry *entry, struct item *item, int count, struct coord *c, char **label,
+ int label_count) {
+ struct displayitem *di;
+ int len,i;
+ char *p;
+
+ len=sizeof(*di)+count*sizeof(*c);
+ if (label && label_count) {
+ for (i = 0 ; i < label_count ; i++) {
+ if (label[i])
+ len+=strlen(label[i])+1;
+ else
+ len++;
+ }
+ }
+ p=g_malloc(len);
+
+ di=(struct displayitem *)p;
+ p+=sizeof(*di)+count*sizeof(*c);
+ di->item=*item;
+ di->z_order=0;
+ if (label && label_count) {
+ di->label=p;
+ for (i = 0 ; i < label_count ; i++) {
+ if (label[i]) {
+ strcpy(p, label[i]);
+ p+=strlen(label[i])+1;
+ } else
+ *p++='\0';
+ }
+ } else
+ di->label=NULL;
+ di->count=count;
+ memcpy(di->c, c, count*sizeof(*c));
+ di->next=entry->di;
+ entry->di=di;
}
@@ -1245,1002 +1195,992 @@ static void display_add(struct hash_entry *entry, struct item *item, int count,
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static void label_line(struct graphics *gra, struct graphics_gc *fg, struct graphics_gc *bg, struct graphics_font *font, struct point *p, int count, char *label)
-{
- int i,x,y,tl,tlm,th,thm,tlsq,l;
- float lsq;
- double dx,dy;
- struct point p_t;
- struct point pb[5];
-
- if (gra->meth.get_text_bbox) {
- gra->meth.get_text_bbox(gra->priv, font->priv, label, 0x10000, 0x0, pb, 1);
- tl=(pb[2].x-pb[0].x);
- th=(pb[0].y-pb[1].y);
- } else {
- tl=strlen(label)*4;
- th=8;
- }
- tlm=tl*32;
- thm=th*36;
- tlsq = tlm*tlm;
- for (i = 0 ; i < count-1 ; i++) {
- dx=p[i+1].x-p[i].x;
- dx*=32;
- dy=p[i+1].y-p[i].y;
- dy*=32;
- lsq = dx*dx+dy*dy;
- if (lsq > tlsq) {
- l=(int)sqrtf(lsq);
- x=p[i].x;
- y=p[i].y;
- if (dx < 0) {
- dx=-dx;
- dy=-dy;
- x=p[i+1].x;
- y=p[i+1].y;
- }
- x+=(l-tlm)*dx/l/64;
- y+=(l-tlm)*dy/l/64;
- x-=dy*thm/l/64;
- y+=dx*thm/l/64;
- p_t.x=x;
- p_t.y=y;
- if (x < gra->r.rl.x && x + tl > gra->r.lu.x && y + tl > gra->r.lu.y && y - tl < gra->r.rl.y)
- gra->meth.draw_text(gra->priv, fg->priv, bg?bg->priv:NULL, font->priv, label, &p_t, dx*0x10000/l, dy*0x10000/l);
- }
- }
-}
-
-static void display_draw_arrow(struct point *p, int dx, int dy, int l, struct graphics_gc *gc, struct graphics *gra)
-{
- struct point pnt[3];
- pnt[0]=pnt[1]=pnt[2]=*p;
- pnt[0].x+=-dx*l/65536+dy*l/65536;
- pnt[0].y+=-dy*l/65536-dx*l/65536;
- pnt[2].x+=-dx*l/65536-dy*l/65536;
- pnt[2].y+=-dy*l/65536+dx*l/65536;
- gra->meth.draw_lines(gra->priv, gc->priv, pnt, 3);
-}
-
-static void display_draw_arrows(struct graphics *gra, struct graphics_gc *gc, struct point *pnt, int count)
-{
- int i,dx,dy,l;
- struct point p;
- for (i = 0 ; i < count-1 ; i++) {
- dx=pnt[i+1].x-pnt[i].x;
- dy=pnt[i+1].y-pnt[i].y;
- l=sqrt(dx*dx+dy*dy);
- if (l) {
- dx=dx*65536/l;
- dy=dy*65536/l;
- p=pnt[i];
- p.x+=dx*15/65536;
- p.y+=dy*15/65536;
- display_draw_arrow(&p, dx, dy, 10, gc, gra);
- p=pnt[i+1];
- p.x-=dx*15/65536;
- p.y-=dy*15/65536;
- display_draw_arrow(&p, dx, dy, 10, gc, gra);
- }
- }
-}
-
-static int
-intersection(struct point * a1, int adx, int ady, struct point * b1, int bdx, int bdy,
- struct point * res)
-{
- int n, a, b;
- dbg(lvl_debug,"%d,%d - %d,%d x %d,%d-%d,%d\n",a1->x,a1->y,a1->x+adx,a1->y+ady,b1->x,b1->y,b1->x+bdx,b1->y+bdy);
- n = bdy * adx - bdx * ady;
- a = bdx * (a1->y - b1->y) - bdy * (a1->x - b1->x);
- b = adx * (a1->y - b1->y) - ady * (a1->x - b1->x);
- dbg(lvl_debug,"a %d b %d n %d\n",a,b,n);
- if (n < 0) {
- n = -n;
- a = -a;
- b = -b;
- }
- if (n == 0)
- return 0;
- res->x = a1->x + a * adx / n;
- res->y = a1->y + a * ady / n;
- dbg(lvl_debug,"%d,%d\n",res->x,res->y);
- return 1;
+static void label_line(struct graphics *gra, struct graphics_gc *fg, struct graphics_gc *bg, struct graphics_font *font,
+ struct point *p, int count, char *label) {
+ int i,x,y,tl,tlm,th,thm,tlsq,l;
+ float lsq;
+ double dx,dy;
+ struct point p_t;
+ struct point pb[5];
+
+ if (gra->meth.get_text_bbox) {
+ gra->meth.get_text_bbox(gra->priv, font->priv, label, 0x10000, 0x0, pb, 1);
+ tl=(pb[2].x-pb[0].x);
+ th=(pb[0].y-pb[1].y);
+ } else {
+ tl=strlen(label)*4;
+ th=8;
+ }
+ tlm=tl*32;
+ thm=th*36;
+ tlsq = tlm*tlm;
+ for (i = 0 ; i < count-1 ; i++) {
+ dx=p[i+1].x-p[i].x;
+ dx*=32;
+ dy=p[i+1].y-p[i].y;
+ dy*=32;
+ lsq = dx*dx+dy*dy;
+ if (lsq > tlsq) {
+ l=(int)sqrtf(lsq);
+ x=p[i].x;
+ y=p[i].y;
+ if (dx < 0) {
+ dx=-dx;
+ dy=-dy;
+ x=p[i+1].x;
+ y=p[i+1].y;
+ }
+ x+=(l-tlm)*dx/l/64;
+ y+=(l-tlm)*dy/l/64;
+ x-=dy*thm/l/64;
+ y+=dx*thm/l/64;
+ p_t.x=x;
+ p_t.y=y;
+ if (x < gra->r.rl.x && x + tl > gra->r.lu.x && y + tl > gra->r.lu.y && y - tl < gra->r.rl.y)
+ gra->meth.draw_text(gra->priv, fg->priv, bg?bg->priv:NULL, font->priv, label, &p_t, dx*0x10000/l, dy*0x10000/l);
+ }
+ }
+}
+
+static void display_draw_arrow(struct point *p, int dx, int dy, int l, struct graphics_gc *gc, struct graphics *gra) {
+ struct point pnt[3];
+ pnt[0]=pnt[1]=pnt[2]=*p;
+ pnt[0].x+=-dx*l/65536+dy*l/65536;
+ pnt[0].y+=-dy*l/65536-dx*l/65536;
+ pnt[2].x+=-dx*l/65536-dy*l/65536;
+ pnt[2].y+=-dy*l/65536+dx*l/65536;
+ gra->meth.draw_lines(gra->priv, gc->priv, pnt, 3);
+}
+
+static void display_draw_arrows(struct graphics *gra, struct graphics_gc *gc, struct point *pnt, int count) {
+ int i,dx,dy,l;
+ struct point p;
+ for (i = 0 ; i < count-1 ; i++) {
+ dx=pnt[i+1].x-pnt[i].x;
+ dy=pnt[i+1].y-pnt[i].y;
+ l=sqrt(dx*dx+dy*dy);
+ if (l) {
+ dx=dx*65536/l;
+ dy=dy*65536/l;
+ p=pnt[i];
+ p.x+=dx*15/65536;
+ p.y+=dy*15/65536;
+ display_draw_arrow(&p, dx, dy, 10, gc, gra);
+ p=pnt[i+1];
+ p.x-=dx*15/65536;
+ p.y-=dy*15/65536;
+ display_draw_arrow(&p, dx, dy, 10, gc, gra);
+ }
+ }
+}
+
+static int intersection(struct point * a1, int adx, int ady, struct point * b1, int bdx, int bdy, struct point * res) {
+ int n, a, b;
+ dbg(lvl_debug,"%d,%d - %d,%d x %d,%d-%d,%d",a1->x,a1->y,a1->x+adx,a1->y+ady,b1->x,b1->y,b1->x+bdx,b1->y+bdy);
+ n = bdy * adx - bdx * ady;
+ a = bdx * (a1->y - b1->y) - bdy * (a1->x - b1->x);
+ b = adx * (a1->y - b1->y) - ady * (a1->x - b1->x);
+ dbg(lvl_debug,"a %d b %d n %d",a,b,n);
+ if (n < 0) {
+ n = -n;
+ a = -a;
+ b = -b;
+ }
+ if (n == 0)
+ return 0;
+ res->x = a1->x + a * adx / n;
+ res->y = a1->y + a * ady / n;
+ dbg(lvl_debug,"%d,%d",res->x,res->y);
+ return 1;
}
struct circle {
- short x,y,fowler;
-} circle64[]={
-{0,128,0},
-{13,127,13},
-{25,126,25},
-{37,122,38},
-{49,118,53},
-{60,113,67},
-{71,106,85},
-{81,99,104},
-{91,91,128},
-{99,81,152},
-{106,71,171},
-{113,60,189},
-{118,49,203},
-{122,37,218},
-{126,25,231},
-{127,13,243},
-{128,0,256},
-{127,-13,269},
-{126,-25,281},
-{122,-37,294},
-{118,-49,309},
-{113,-60,323},
-{106,-71,341},
-{99,-81,360},
-{91,-91,384},
-{81,-99,408},
-{71,-106,427},
-{60,-113,445},
-{49,-118,459},
-{37,-122,474},
-{25,-126,487},
-{13,-127,499},
-{0,-128,512},
-{-13,-127,525},
-{-25,-126,537},
-{-37,-122,550},
-{-49,-118,565},
-{-60,-113,579},
-{-71,-106,597},
-{-81,-99,616},
-{-91,-91,640},
-{-99,-81,664},
-{-106,-71,683},
-{-113,-60,701},
-{-118,-49,715},
-{-122,-37,730},
-{-126,-25,743},
-{-127,-13,755},
-{-128,0,768},
-{-127,13,781},
-{-126,25,793},
-{-122,37,806},
-{-118,49,821},
-{-113,60,835},
-{-106,71,853},
-{-99,81,872},
-{-91,91,896},
-{-81,99,920},
-{-71,106,939},
-{-60,113,957},
-{-49,118,971},
-{-37,122,986},
-{-25,126,999},
-{-13,127,1011},
+ short x,y,fowler;
+} circle64[]= {
+ {0,128,0},
+ {13,127,13},
+ {25,126,25},
+ {37,122,38},
+ {49,118,53},
+ {60,113,67},
+ {71,106,85},
+ {81,99,104},
+ {91,91,128},
+ {99,81,152},
+ {106,71,171},
+ {113,60,189},
+ {118,49,203},
+ {122,37,218},
+ {126,25,231},
+ {127,13,243},
+ {128,0,256},
+ {127,-13,269},
+ {126,-25,281},
+ {122,-37,294},
+ {118,-49,309},
+ {113,-60,323},
+ {106,-71,341},
+ {99,-81,360},
+ {91,-91,384},
+ {81,-99,408},
+ {71,-106,427},
+ {60,-113,445},
+ {49,-118,459},
+ {37,-122,474},
+ {25,-126,487},
+ {13,-127,499},
+ {0,-128,512},
+ {-13,-127,525},
+ {-25,-126,537},
+ {-37,-122,550},
+ {-49,-118,565},
+ {-60,-113,579},
+ {-71,-106,597},
+ {-81,-99,616},
+ {-91,-91,640},
+ {-99,-81,664},
+ {-106,-71,683},
+ {-113,-60,701},
+ {-118,-49,715},
+ {-122,-37,730},
+ {-126,-25,743},
+ {-127,-13,755},
+ {-128,0,768},
+ {-127,13,781},
+ {-126,25,793},
+ {-122,37,806},
+ {-118,49,821},
+ {-113,60,835},
+ {-106,71,853},
+ {-99,81,872},
+ {-91,91,896},
+ {-81,99,920},
+ {-71,106,939},
+ {-60,113,957},
+ {-49,118,971},
+ {-37,122,986},
+ {-25,126,999},
+ {-13,127,1011},
};
-static void
-draw_circle(struct point *pnt, int diameter, int scale, int start, int len, struct point *res, int *pos, int dir)
-{
- struct circle *c;
- int count=64;
- int end=start+len;
- int i,step;
- c=circle64;
- if (diameter > 128)
- step=1;
- else if (diameter > 64)
- step=2;
- else if (diameter > 24)
- step=4;
- else if (diameter > 8)
- step=8;
- else
- step=16;
- if (len > 0) {
- while (start < 0) {
- start+=1024;
- end+=1024;
- }
- while (end > 0) {
- i=0;
- while (i < count && c[i].fowler <= start)
- i+=step;
- while (i < count && c[i].fowler < end) {
- if (1< *pos || 0<dir) {
- res[*pos].x=pnt->x+((c[i].x*diameter+128)>>8);
- res[*pos].y=pnt->y+((c[i].y*diameter+128)>>8);
- (*pos)+=dir;
- }
- i+=step;
- }
- end-=1024;
- start-=1024;
- }
- } else {
- while (start > 1024) {
- start-=1024;
- end-=1024;
- }
- while (end < 1024) {
- i=count-1;
- while (i >= 0 && c[i].fowler >= start)
- i-=step;
- while (i >= 0 && c[i].fowler > end) {
- if (1< *pos || 0<dir) {
- res[*pos].x=pnt->x+((c[i].x*diameter+128)>>8);
- res[*pos].y=pnt->y+((c[i].y*diameter+128)>>8);
- (*pos)+=dir;
- }
- i-=step;
- }
- start+=1024;
- end+=1024;
- }
- }
-}
-
-
-static int
-fowler(int dy, int dx)
-{
- int adx, ady; /* Absolute Values of Dx and Dy */
- int code; /* Angular Region Classification Code */
-
- adx = (dx < 0) ? -dx : dx; /* Compute the absolute values. */
- ady = (dy < 0) ? -dy : dy;
-
- code = (adx < ady) ? 1 : 0;
- if (dx < 0)
- code += 2;
- if (dy < 0)
- code += 4;
-
- switch (code) {
- case 0:
- return (dx == 0) ? 0 : 128*ady / adx; /* [ 0, 45] */
- case 1:
- return (256 - (128*adx / ady)); /* ( 45, 90] */
- case 3:
- return (256 + (128*adx / ady)); /* ( 90,135) */
- case 2:
- return (512 - (128*ady / adx)); /* [135,180] */
- case 6:
- return (512 + (128*ady / adx)); /* (180,225] */
- case 7:
- return (768 - (128*adx / ady)); /* (225,270) */
- case 5:
- return (768 + (128*adx / ady)); /* [270,315) */
- case 4:
- return (1024 - (128*ady / adx));/* [315,360) */
- }
- return 0;
-}
-static int
-int_sqrt(unsigned int n)
-{
- unsigned int h, p= 0, q= 1, r= n;
-
- /* avoid q rollover */
- if(n >= (1<<(sizeof(n)*8-2))) {
- q = 1<<(sizeof(n)*8-2);
- } else {
- while ( q <= n ) {
- q <<= 2;
- }
- q >>= 2;
- }
-
- while ( q != 0 ) {
- h = p + q;
- p >>= 1;
- if ( r >= h ) {
- p += q;
- r -= h;
- }
- q >>= 2;
- }
- return p;
+/**
+ * @brief Create a set of points on a circle or on a circular arc
+ *
+ * @param center Center point of the circle
+ * @param diameter Diameter of the circle
+ * @param scale Unused
+ * @param start Position of the first point on the circle (in 1/1024th of the circle), -1 being the bottom of the circle, 511 being the top of the circle
+ * @param len Length of the arc on the circle, relative to start (in 1/1024th of the circle), 514 is half a circle, 1028 is a full circle (or 1027 if first and last points are connected with a line)
+ * @param[out] res Returned an array of points that will form the resulting circle
+ * @param[out] pos Index of the last point filled inside array @p res
+ * @param dir Direction of the circle (valid values are 1 (counter-clockwise) or -1 (clockwise), other values may lead to unknown result)
+ */
+static void circle_to_points(const struct point *center, int diameter, int scale, int start, int len, struct point *res,
+ int *pos, int dir) {
+ struct circle *c;
+ int count=64;
+ int end=start+len;
+ int i,step;
+ c=circle64;
+ if (diameter > 128)
+ step=1;
+ else if (diameter > 64)
+ step=2;
+ else if (diameter > 16)
+ step=4;
+ else if (diameter > 4)
+ step=8;
+ else
+ step=16;
+ if (len > 0) {
+ while (start < 0) {
+ start+=1024;
+ end+=1024;
+ }
+ while (end > 0) {
+ i=0;
+ while (i < count && c[i].fowler <= start)
+ i+=step;
+ while (i < count && c[i].fowler < end) {
+ if (1< *pos || 0<dir) {
+ res[*pos].x=center->x+((c[i].x*diameter+128)>>8);
+ res[*pos].y=center->y+((c[i].y*diameter+128)>>8);
+ (*pos)+=dir;
+ }
+ i+=step;
+ }
+ end-=1024;
+ start-=1024;
+ }
+ } else {
+ while (start > 1024) {
+ start-=1024;
+ end-=1024;
+ }
+ while (end < 1024) {
+ i=count-1;
+ while (i >= 0 && c[i].fowler >= start)
+ i-=step;
+ while (i >= 0 && c[i].fowler > end) {
+ if (1< *pos || 0<dir) {
+ res[*pos].x=center->x+((c[i].x*diameter+128)>>8);
+ res[*pos].y=center->y+((c[i].y*diameter+128)>>8);
+ (*pos)+=dir;
+ }
+ i-=step;
+ }
+ start+=1024;
+ end+=1024;
+ }
+ }
+}
+
+
+static int fowler(int dy, int dx) {
+ int adx, ady; /* Absolute Values of Dx and Dy */
+ int code; /* Angular Region Classification Code */
+
+ adx = (dx < 0) ? -dx : dx; /* Compute the absolute values. */
+ ady = (dy < 0) ? -dy : dy;
+
+ code = (adx < ady) ? 1 : 0;
+ if (dx < 0)
+ code += 2;
+ if (dy < 0)
+ code += 4;
+
+ switch (code) {
+ case 0:
+ return (dx == 0) ? 0 : 128*ady / adx; /* [ 0, 45] */
+ case 1:
+ return (256 - (128*adx / ady)); /* ( 45, 90] */
+ case 3:
+ return (256 + (128*adx / ady)); /* ( 90,135) */
+ case 2:
+ return (512 - (128*ady / adx)); /* [135,180] */
+ case 6:
+ return (512 + (128*ady / adx)); /* (180,225] */
+ case 7:
+ return (768 - (128*adx / ady)); /* (225,270) */
+ case 5:
+ return (768 + (128*adx / ady)); /* [270,315) */
+ case 4:
+ return (1024 - (128*ady / adx));/* [315,360) */
+ }
+ return 0;
}
struct draw_polyline_shape {
- int wi;
- int step;
- int fow;
- int dx,dy;
- int dxw,dyw;
- int l,lscale;
+ int wi;
+ int step;
+ int fow;
+ int dx,dy;
+ int dxw,dyw;
+ int l,lscale;
};
struct draw_polyline_context {
- int prec;
- int ppos,npos;
- struct point *res;
- struct draw_polyline_shape shape;
- struct draw_polyline_shape prev_shape;
+ int prec;
+ int ppos,npos;
+ struct point *res;
+ struct draw_polyline_shape shape;
+ struct draw_polyline_shape prev_shape;
};
-static void
-draw_shape_update(struct draw_polyline_shape *shape)
-{
- shape->dxw = -(shape->dx * shape->wi * shape->lscale) / shape->l;
- shape->dyw = (shape->dy * shape->wi * shape->lscale) / shape->l;
-}
-
-static void
-draw_shape(struct draw_polyline_context *ctx, struct point *pnt, int wi)
-{
- int dxs,dys,lscales;
- int lscale=16;
- int l;
- struct draw_polyline_shape *shape=&ctx->shape;
- struct draw_polyline_shape *prev=&ctx->prev_shape;
-
-#if 0
- dbg(lvl_debug,"enter %d,%d - %d,%d %d\n",pnt[0].x,pnt[0].y,pnt[1].x,pnt[1].y,wi);
-#endif
-
- *prev=*shape;
- if (prev->wi != wi && prev->l) {
- prev->wi=wi;
- draw_shape_update(prev);
- }
- shape->wi=wi;
- shape->dx = (pnt[1].x - pnt[0].x);
- shape->dy = (pnt[1].y - pnt[0].y);
- if (wi > 16)
- shape->step=4;
- else if (wi > 8)
- shape->step=8;
- else
- shape->step=16;
-#if 0
- l = int_sqrt(dx * dx * lscale * lscale + dy * dy * lscale * lscale);
-#else
- dxs=shape->dx*shape->dx;
- dys=shape->dy*shape->dy;
- lscales=lscale*lscale;
- if (dxs + dys > lscales)
- l = int_sqrt(dxs+dys)*lscale;
- else
- l = int_sqrt((dxs+dys)*lscales);
-#endif
- shape->fow=fowler(-shape->dy, shape->dx);
- dbg(lvl_debug,"fow=%d\n",shape->fow);
- if (! l)
- l=1;
- if (wi*lscale > 10000)
- lscale=10000/wi;
- dbg_assert(wi*lscale <= 10000);
- shape->l=l;
- shape->lscale=lscale;
- shape->wi=wi;
- draw_shape_update(shape);
-}
-
-static void
-draw_point(struct draw_polyline_shape *shape, struct point *src, struct point *dst, int pos)
-{
- if (pos) {
- dst->x=(src->x*2-shape->dyw)/2;
- dst->y=(src->y*2-shape->dxw)/2;
- } else {
- dst->x=(src->x*2+shape->dyw)/2;
- dst->y=(src->y*2+shape->dxw)/2;
- }
-}
-
-static void
-draw_begin(struct draw_polyline_context *ctx, struct point *p)
-{
- struct draw_polyline_shape *shape=&ctx->shape;
- int i;
- for (i = 0 ; i <= 32 ; i+=shape->step) {
- ctx->res[ctx->ppos].x=(p->x*256+(shape->dyw*circle64[i].y)+(shape->dxw*circle64[i].x))/256;
- ctx->res[ctx->ppos].y=(p->y*256+(shape->dxw*circle64[i].y)-(shape->dyw*circle64[i].x))/256;
- ctx->ppos++;
- }
-}
-
-static int
-draw_middle(struct draw_polyline_context *ctx, struct point *p)
-{
- int delta=ctx->prev_shape.fow-ctx->shape.fow;
- if (delta > 512)
- delta-=1024;
- if (delta < -512)
- delta+=1024;
- if (delta < 16 && delta > -16) {
- draw_point(&ctx->shape, p, &ctx->res[ctx->npos--], 0);
- draw_point(&ctx->shape, p, &ctx->res[ctx->ppos++], 1);
- return 1;
- }
- dbg(lvl_debug,"delta %d\n",delta);
- if (delta > 0) {
- struct point pos,poso;
- draw_point(&ctx->shape, p, &pos, 1);
- draw_point(&ctx->prev_shape, p, &poso, 1);
- if (delta >= 256)
- return 0;
- if (intersection(&pos, ctx->shape.dx, ctx->shape.dy, &poso, ctx->prev_shape.dx, ctx->prev_shape.dy, &ctx->res[ctx->ppos])) {
- ctx->ppos++;
- draw_point(&ctx->prev_shape, p, &ctx->res[ctx->npos--], 0);
- draw_point(&ctx->shape, p, &ctx->res[ctx->npos--], 0);
- return 1;
- }
- } else {
- struct point neg,nego;
- draw_point(&ctx->shape, p, &neg, 0);
- draw_point(&ctx->prev_shape, p, &nego, 0);
- if (delta <= -256)
- return 0;
- if (intersection(&neg, ctx->shape.dx, ctx->shape.dy, &nego, ctx->prev_shape.dx, ctx->prev_shape.dy, &ctx->res[ctx->npos])) {
- ctx->npos--;
- draw_point(&ctx->prev_shape, p, &ctx->res[ctx->ppos++], 1);
- draw_point(&ctx->shape, p, &ctx->res[ctx->ppos++], 1);
- return 1;
- }
- }
- return 0;
-}
-
-static void
-draw_end(struct draw_polyline_context *ctx, struct point *p)
-{
- int i;
- struct draw_polyline_shape *shape=&ctx->prev_shape;
- for (i = 0 ; i <= 32 ; i+=shape->step) {
- ctx->res[ctx->npos].x=(p->x*256+(shape->dyw*circle64[i].y)-(shape->dxw*circle64[i].x))/256;
- ctx->res[ctx->npos].y=(p->y*256+(shape->dxw*circle64[i].y)+(shape->dyw*circle64[i].x))/256;
- ctx->npos--;
- }
-}
-
-static void
-draw_init_ctx(struct draw_polyline_context *ctx, int maxpoints)
-{
- ctx->prec=1;
- ctx->ppos=maxpoints/2;
- ctx->npos=maxpoints/2-1;
-}
-
-
-static void
-graphics_draw_polyline_as_polygon(struct graphics_priv *gra_priv, struct graphics_gc_priv *gc_priv, struct point *pnt, int count, int *width, void (*draw)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count))
-{
- int maxpoints=200;
- struct draw_polyline_context ctx;
- int i=0;
- int max_circle_points=20;
- if (count < 2)
- return;
-#if 0
- dbg(lvl_debug,"count=%d\n",count);
- for (i = 0 ; i < count ; i++)
- dbg(lvl_debug,"%d,%d width %d\n",pnt[i].x,pnt[i].y,width[i]);
-#endif
- ctx.shape.l=0;
- ctx.shape.wi=0;
- ctx.res=g_alloca(sizeof(struct point)*maxpoints);
- i=0;
- draw_init_ctx(&ctx, maxpoints);
- draw_shape(&ctx, pnt, *width++);
- draw_begin(&ctx,&pnt[0]);
- for (i = 1 ; i < count -1 ; i++) {
- draw_shape(&ctx, pnt+i, *width++);
- if (ctx.npos < max_circle_points || ctx.ppos >= maxpoints-max_circle_points || !draw_middle(&ctx,&pnt[i])) {
- draw_end(&ctx,&pnt[i]);
- ctx.res[ctx.npos]=ctx.res[ctx.ppos-1];
- draw(gra_priv, gc_priv, ctx.res+ctx.npos, ctx.ppos-ctx.npos);
- draw_init_ctx(&ctx, maxpoints);
- draw_begin(&ctx,&pnt[i]);
- }
- }
- draw_shape(&ctx, &pnt[count-2], *width++);
- ctx.prev_shape=ctx.shape;
- draw_end(&ctx,&pnt[count-1]);
- ctx.res[ctx.npos]=ctx.res[ctx.ppos-1];
- draw(gra_priv, gc_priv, ctx.res+ctx.npos, ctx.ppos-ctx.npos);
+static void draw_shape_update(struct draw_polyline_shape *shape) {
+ shape->dxw = -(shape->dx * shape->wi * shape->lscale) / shape->l;
+ shape->dyw = (shape->dy * shape->wi * shape->lscale) / shape->l;
+}
+
+static void draw_shape(struct draw_polyline_context *ctx, struct point *pnt, int wi) {
+ int dxs,dys,lscales;
+ int lscale=16;
+ int l;
+ struct draw_polyline_shape *shape=&ctx->shape;
+ struct draw_polyline_shape *prev=&ctx->prev_shape;
+
+ *prev=*shape;
+ if (prev->wi != wi && prev->l) {
+ prev->wi=wi;
+ draw_shape_update(prev);
+ }
+ shape->wi=wi;
+ shape->dx = (pnt[1].x - pnt[0].x);
+ shape->dy = (pnt[1].y - pnt[0].y);
+ if (wi > 16)
+ shape->step=4;
+ else if (wi > 8)
+ shape->step=8;
+ else
+ shape->step=16;
+ dxs=shape->dx*shape->dx;
+ dys=shape->dy*shape->dy;
+ lscales=lscale*lscale;
+ if (dxs + dys > lscales)
+ l = uint_sqrt(dxs+dys)*lscale;
+ else
+ l = uint_sqrt((dxs+dys)*lscales);
+
+ shape->fow=fowler(-shape->dy, shape->dx);
+ dbg(lvl_debug,"fow=%d",shape->fow);
+ if (! l)
+ l=1;
+ if (wi*lscale > 10000)
+ lscale=10000/wi;
+ dbg_assert(wi*lscale <= 10000);
+ shape->l=l;
+ shape->lscale=lscale;
+ shape->wi=wi;
+ draw_shape_update(shape);
+}
+
+static void draw_point(struct draw_polyline_shape *shape, struct point *src, struct point *dst, int pos) {
+ if (pos) {
+ dst->x=(src->x*2-shape->dyw)/2;
+ dst->y=(src->y*2-shape->dxw)/2;
+ } else {
+ dst->x=(src->x*2+shape->dyw)/2;
+ dst->y=(src->y*2+shape->dxw)/2;
+ }
+}
+
+static void draw_begin(struct draw_polyline_context *ctx, struct point *p) {
+ struct draw_polyline_shape *shape=&ctx->shape;
+ int i;
+ for (i = 0 ; i <= 32 ; i+=shape->step) {
+ ctx->res[ctx->ppos].x=(p->x*256+(shape->dyw*circle64[i].y)+(shape->dxw*circle64[i].x))/256;
+ ctx->res[ctx->ppos].y=(p->y*256+(shape->dxw*circle64[i].y)-(shape->dyw*circle64[i].x))/256;
+ ctx->ppos++;
+ }
+}
+
+static int draw_middle(struct draw_polyline_context *ctx, struct point *p) {
+ int delta=ctx->prev_shape.fow-ctx->shape.fow;
+ if (delta > 512)
+ delta-=1024;
+ if (delta < -512)
+ delta+=1024;
+ if (delta < 16 && delta > -16) {
+ draw_point(&ctx->shape, p, &ctx->res[ctx->npos--], 0);
+ draw_point(&ctx->shape, p, &ctx->res[ctx->ppos++], 1);
+ return 1;
+ }
+ dbg(lvl_debug,"delta %d",delta);
+ if (delta > 0) {
+ struct point pos,poso;
+ draw_point(&ctx->shape, p, &pos, 1);
+ draw_point(&ctx->prev_shape, p, &poso, 1);
+ if (delta >= 256)
+ return 0;
+ if (intersection(&pos, ctx->shape.dx, ctx->shape.dy, &poso, ctx->prev_shape.dx, ctx->prev_shape.dy,
+ &ctx->res[ctx->ppos])) {
+ ctx->ppos++;
+ draw_point(&ctx->prev_shape, p, &ctx->res[ctx->npos--], 0);
+ draw_point(&ctx->shape, p, &ctx->res[ctx->npos--], 0);
+ return 1;
+ }
+ } else {
+ struct point neg,nego;
+ draw_point(&ctx->shape, p, &neg, 0);
+ draw_point(&ctx->prev_shape, p, &nego, 0);
+ if (delta <= -256)
+ return 0;
+ if (intersection(&neg, ctx->shape.dx, ctx->shape.dy, &nego, ctx->prev_shape.dx, ctx->prev_shape.dy,
+ &ctx->res[ctx->npos])) {
+ ctx->npos--;
+ draw_point(&ctx->prev_shape, p, &ctx->res[ctx->ppos++], 1);
+ draw_point(&ctx->shape, p, &ctx->res[ctx->ppos++], 1);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void draw_end(struct draw_polyline_context *ctx, struct point *p) {
+ int i;
+ struct draw_polyline_shape *shape=&ctx->prev_shape;
+ for (i = 0 ; i <= 32 ; i+=shape->step) {
+ ctx->res[ctx->npos].x=(p->x*256+(shape->dyw*circle64[i].y)-(shape->dxw*circle64[i].x))/256;
+ ctx->res[ctx->npos].y=(p->y*256+(shape->dxw*circle64[i].y)+(shape->dyw*circle64[i].x))/256;
+ ctx->npos--;
+ }
+}
+
+static void draw_init_ctx(struct draw_polyline_context *ctx, int maxpoints) {
+ ctx->prec=1;
+ ctx->ppos=maxpoints/2;
+ ctx->npos=maxpoints/2-1;
+}
+
+
+static void graphics_draw_polyline_as_polygon(struct graphics_priv *gra_priv, struct graphics_gc_priv *gc_priv,
+ struct point *pnt, int count, int *width, void (*draw)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
+ struct point *p, int count)) {
+ int maxpoints=200;
+ struct draw_polyline_context ctx;
+ int i=0;
+ int max_circle_points=20;
+ if (count < 2)
+ return;
+ ctx.shape.l=0;
+ ctx.shape.wi=0;
+ ctx.res=g_alloca(sizeof(struct point)*maxpoints);
+ i=0;
+ draw_init_ctx(&ctx, maxpoints);
+ draw_shape(&ctx, pnt, *width++);
+ draw_begin(&ctx,&pnt[0]);
+ for (i = 1 ; i < count -1 ; i++) {
+ draw_shape(&ctx, pnt+i, *width++);
+ if (ctx.npos < max_circle_points || ctx.ppos >= maxpoints-max_circle_points || !draw_middle(&ctx,&pnt[i])) {
+ draw_end(&ctx,&pnt[i]);
+ ctx.res[ctx.npos]=ctx.res[ctx.ppos-1];
+ draw(gra_priv, gc_priv, ctx.res+ctx.npos, ctx.ppos-ctx.npos);
+ draw_init_ctx(&ctx, maxpoints);
+ draw_begin(&ctx,&pnt[i]);
+ }
+ }
+ draw_shape(&ctx, &pnt[count-2], *width++);
+ ctx.prev_shape=ctx.shape;
+ draw_end(&ctx,&pnt[count-1]);
+ ctx.res[ctx.npos]=ctx.res[ctx.ppos-1];
+ draw(gra_priv, gc_priv, ctx.res+ctx.npos, ctx.ppos-ctx.npos);
}
struct wpoint {
- int x,y,w;
+ int x,y,w;
};
enum relative_pos {
- INSIDE = 0,
- LEFT_OF = 1,
- RIGHT_OF = 2,
- ABOVE = 4,
- BELOW = 8
+ INSIDE = 0,
+ LEFT_OF = 1,
+ RIGHT_OF = 2,
+ ABOVE = 4,
+ BELOW = 8
};
-static int
-relative_pos(struct wpoint *p, struct point_rect *r)
-{
- int relative_pos=INSIDE;
- if (p->x < r->lu.x)
- relative_pos=LEFT_OF;
- else if (p->x > r->rl.x)
- relative_pos=RIGHT_OF;
- if (p->y < r->lu.y)
- relative_pos |=ABOVE;
- else if (p->y > r->rl.y)
- relative_pos |=BELOW;
- return relative_pos;
-}
-
-static void
-clip_line_endoint_to_rect_edge(struct wpoint *p, int rel_pos, int dx, int dy, int dw, struct point_rect *clip_rect)
-{
- // We must cast to float to avoid integer
- // overflow (i.e. undefined behaviour) at high
- // zoom levels.
- if (rel_pos & LEFT_OF) {
- p->y+=(((float)clip_rect->lu.x)-p->x)*dy/dx;
- p->w+=(((float)clip_rect->lu.x)-p->x)*dw/dx;
- p->x=clip_rect->lu.x;
- } else if (rel_pos & RIGHT_OF) {
- p->y+=(((float)clip_rect->rl.x)-p->x)*dy/dx;
- p->w+=(((float)clip_rect->rl.x)-p->x)*dw/dx;
- p->x=clip_rect->rl.x;
- } else if (rel_pos & ABOVE) {
- p->x+=(((float)clip_rect->lu.y)-p->y)*dx/dy;
- p->w+=(((float)clip_rect->lu.y)-p->y)*dw/dy;
- p->y=clip_rect->lu.y;
- } else if (rel_pos & BELOW) {
- p->x+=(((float)clip_rect->rl.y)-p->y)*dx/dy;
- p->w+=(((float)clip_rect->rl.y)-p->y)*dw/dy;
- p->y=clip_rect->rl.y;
- }
+static int relative_pos(struct wpoint *p, struct point_rect *r) {
+ int relative_pos=INSIDE;
+ if (p->x < r->lu.x)
+ relative_pos=LEFT_OF;
+ else if (p->x > r->rl.x)
+ relative_pos=RIGHT_OF;
+ if (p->y < r->lu.y)
+ relative_pos |=ABOVE;
+ else if (p->y > r->rl.y)
+ relative_pos |=BELOW;
+ return relative_pos;
+}
+
+static void clip_line_endoint_to_rect_edge(struct wpoint *p, int rel_pos, int dx, int dy, int dw,
+ struct point_rect *clip_rect) {
+ // We must cast to float to avoid integer
+ // overflow (i.e. undefined behaviour) at high
+ // zoom levels.
+ if (rel_pos & LEFT_OF) {
+ p->y+=(((float)clip_rect->lu.x)-p->x)*dy/dx;
+ p->w+=(((float)clip_rect->lu.x)-p->x)*dw/dx;
+ p->x=clip_rect->lu.x;
+ } else if (rel_pos & RIGHT_OF) {
+ p->y+=(((float)clip_rect->rl.x)-p->x)*dy/dx;
+ p->w+=(((float)clip_rect->rl.x)-p->x)*dw/dx;
+ p->x=clip_rect->rl.x;
+ } else if (rel_pos & ABOVE) {
+ p->x+=(((float)clip_rect->lu.y)-p->y)*dx/dy;
+ p->w+=(((float)clip_rect->lu.y)-p->y)*dw/dy;
+ p->y=clip_rect->lu.y;
+ } else if (rel_pos & BELOW) {
+ p->x+=(((float)clip_rect->rl.y)-p->y)*dx/dy;
+ p->w+=(((float)clip_rect->rl.y)-p->y)*dw/dy;
+ p->y=clip_rect->rl.y;
+ }
}
enum clip_result {
- CLIPRES_INVISIBLE = 0,
- CLIPRES_VISIBLE = 1,
- CLIPRES_START_CLIPPED = 2,
- CLIPRES_END_CLIPPED = 4,
+ CLIPRES_INVISIBLE = 0,
+ CLIPRES_VISIBLE = 1,
+ CLIPRES_START_CLIPPED = 2,
+ CLIPRES_END_CLIPPED = 4,
};
-static int
-clip_line(struct wpoint *p1, struct wpoint *p2, struct point_rect *clip_rect)
-{
- int rel_pos1,rel_pos2;
- int ret = CLIPRES_VISIBLE;
- int dx,dy,dw;
- rel_pos1=relative_pos(p1, clip_rect);
- if (rel_pos1!=INSIDE)
- ret |= CLIPRES_START_CLIPPED;
- rel_pos2=relative_pos(p2, clip_rect);
- if (rel_pos2!=INSIDE)
- ret |= CLIPRES_END_CLIPPED;
- dx=p2->x-p1->x;
- dy=p2->y-p1->y;
- dw=p2->w-p1->w;
- while ((rel_pos1!=INSIDE) || (rel_pos2!=INSIDE)) {
- if (rel_pos1 & rel_pos2)
- return CLIPRES_INVISIBLE;
- clip_line_endoint_to_rect_edge(p1, rel_pos1, dx, dy, dw, clip_rect);
- rel_pos1=relative_pos(p1, clip_rect);
- if (rel_pos1 & rel_pos2)
- return CLIPRES_INVISIBLE;
- clip_line_endoint_to_rect_edge(p2, rel_pos2, dx, dy, dw, clip_rect);
- rel_pos2=relative_pos(p2, clip_rect);
- }
- return ret;
-}
-
-static void
-graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int poly)
-{
- struct point *points_to_draw=g_alloca(sizeof(struct point)*(count+1));
- int *w=g_alloca(sizeof(int)*(count+1));
- struct wpoint segment_start,segment_end;
- int i,points_to_draw_cnt=0;
- int clip_result;
- int r_width, r_height;
- struct point_rect r=gra->r;
-
- r_width=r.rl.x-r.lu.x;
- r_height=r.rl.y-r.lu.y;
-
- // Expand clipping rect by 1/3 so wide, slanted lines do not
- // partially end before screen border.
- // Ideally we would expand by the line width here, but in 3D
- // mode the width is variable and needs clipping itself, so that
- // would get complicated. Anyway, 1/3 of screen size should be
- // enough...
- r.lu.x-=r_width/3;
- r.lu.y-=r_height/3;
- r.rl.x+=r_width/3;
- r.rl.y+=r_height/3;
- // Iterate over line segments, push them into points_to_draw
- // until we reach a completely invisible segment...
- for (i = 0 ; i < count ; i++) {
- if (i) {
- segment_start.x=pa[i-1].x;
- segment_start.y=pa[i-1].y;
- segment_start.w=width[(i-1)];
- segment_end.x=pa[i].x;
- segment_end.y=pa[i].y;
- segment_end.w=width[i];
- dbg(lvl_debug, "Segment: [%d, %d] - [%d, %d]...\n", segment_start.x, segment_start.y, segment_end.x, segment_end.y);
- clip_result=clip_line(&segment_start, &segment_end, &r);
- if (clip_result != CLIPRES_INVISIBLE) {
- dbg(lvl_debug, "....clipped to [%d, %d] - [%d, %d]\n", segment_start.x, segment_start.y, segment_end.x, segment_end.y);
- if ((i == 1) || (clip_result & CLIPRES_START_CLIPPED)) {
- points_to_draw[points_to_draw_cnt].x=segment_start.x;
- points_to_draw[points_to_draw_cnt].y=segment_start.y;
- w[points_to_draw_cnt]=segment_start.w;
- points_to_draw_cnt++;
- }
- points_to_draw[points_to_draw_cnt].x=segment_end.x;
- points_to_draw[points_to_draw_cnt].y=segment_end.y;
- w[points_to_draw_cnt]=segment_end.w;
- points_to_draw_cnt++;
- }
- if ((i == count-1) || (clip_result & CLIPRES_END_CLIPPED)) {
- // ... then draw the resulting polyline
- if (points_to_draw_cnt > 1) {
- if (poly) {
- graphics_draw_polyline_as_polygon(gra->priv, gc->priv, points_to_draw, points_to_draw_cnt, w, gra->meth.draw_polygon);
-#if 0
- gra->meth.draw_lines(gra->priv, gc->priv, points_to_draw, points_to_draw_cnt);
-#endif
- } else
- gra->meth.draw_lines(gra->priv, gc->priv, points_to_draw, points_to_draw_cnt);
- points_to_draw_cnt=0;
- }
- }
- }
- }
-}
-
-static int
-is_inside(struct point *p, struct point_rect *r, int edge)
-{
- switch(edge) {
- case 0:
- return p->x >= r->lu.x;
- case 1:
- return p->x <= r->rl.x;
- case 2:
- return p->y >= r->lu.y;
- case 3:
- return p->y <= r->rl.y;
- default:
- return 0;
- }
-}
-
-static void
-poly_intersection(struct point *p1, struct point *p2, struct point_rect *r, int edge, struct point *ret)
-{
- int dx=p2->x-p1->x;
- int dy=p2->y-p1->y;
- switch(edge) {
- case 0:
- ret->y=p1->y+((float)r->lu.x-p1->x)*dy/dx;
- ret->x=r->lu.x;
- break;
- case 1:
- ret->y=p1->y+((float)r->rl.x-p1->x)*dy/dx;
- ret->x=r->rl.x;
- break;
- case 2:
- ret->x=p1->x+((float)r->lu.y-p1->y)*dx/dy;
- ret->y=r->lu.y;
- break;
- case 3:
- ret->x=p1->x+((float)r->rl.y-p1->y)*dx/dy;
- ret->y=r->rl.y;
- break;
- }
-}
-
-static void
-graphics_draw_polygon_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pin, int count_in)
-{
- struct point_rect r=gra->r;
- struct point *pout,*p,*s,pi,*p1,*p2;
- int limit=10000;
- struct point *pa1=g_alloca(sizeof(struct point) * (count_in < limit ? count_in*8+1:0));
- struct point *pa2=g_alloca(sizeof(struct point) * (count_in < limit ? count_in*8+1:0));
- int count_out,edge=3;
- int i;
-#if 0
- r.lu.x+=20;
- r.lu.y+=20;
- r.rl.x-=20;
- r.rl.y-=20;
-#endif
- if (count_in < limit) {
- p1=pa1;
- p2=pa2;
- } else {
- p1=g_new(struct point, count_in*8+1);
- p2=g_new(struct point, count_in*8+1);
- }
-
- pout=p1;
- for (edge = 0 ; edge < 4 ; edge++) {
- p=pin;
- s=pin+count_in-1;
- count_out=0;
- for (i = 0 ; i < count_in ; i++) {
- if (is_inside(p, &r, edge)) {
- if (! is_inside(s, &r, edge)) {
- poly_intersection(s,p,&r,edge,&pi);
- pout[count_out++]=pi;
- }
- pout[count_out++]=*p;
- } else {
- if (is_inside(s, &r, edge)) {
- poly_intersection(p,s,&r,edge,&pi);
- pout[count_out++]=pi;
- }
- }
- s=p;
- p++;
- }
- count_in=count_out;
- if (pin == p1) {
- pin=p2;
- pout=p1;
- } else {
- pin=p1;
- pout=p2;
- }
- }
- gra->meth.draw_polygon(gra->priv, gc->priv, pin, count_in);
- if (count_in >= limit) {
- g_free(p1);
- g_free(p2);
- }
-}
-
-
-static void
-display_context_free(struct display_context *dc)
-{
- if (dc->gc)
- graphics_gc_destroy(dc->gc);
- if (dc->gc_background)
- graphics_gc_destroy(dc->gc_background);
- if (dc->img)
- graphics_image_free(dc->gra, dc->img);
- dc->gc=NULL;
- dc->gc_background=NULL;
- dc->img=NULL;
-}
-
-static struct graphics_font *
-get_font(struct graphics *gra, int size)
-{
- if (size > 64)
- size=64;
- if (size >= gra->font_len) {
- gra->font=g_renew(struct graphics_font *, gra->font, size+1);
- while (gra->font_len <= size)
- gra->font[gra->font_len++]=NULL;
- }
- if (! gra->font[size])
- gra->font[size]=graphics_font_new(gra, size*gra->font_size, 0);
- return gra->font[size];
-}
-
-void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p)
-{
- struct graphics_font *font=get_font(this_, text_size);
- struct point bbox[4];
- int i;
-
- graphics_get_text_bbox(this_, font, text, 0x10000, 0, bbox, 0);
- for (i = 0 ; i < 4 ; i++) {
- bbox[i].x+=p->x;
- bbox[i].y+=p->y;
- }
- graphics_draw_rectangle(this_, this_->gc[2], &bbox[1], bbox[2].x-bbox[0].x, bbox[0].y-bbox[1].y+5);
- graphics_draw_text(this_, this_->gc[1], this_->gc[2], font, text, p, 0x10000, 0);
-}
-
-char *
-graphics_icon_path(const char *icon)
-{
- static char *navit_sharedir;
- char *ret=NULL;
- struct file_wordexp *wordexp=NULL;
- dbg(lvl_debug,"enter %s\n",icon);
- if (strchr(icon, '$')) {
- wordexp=file_wordexp_new(icon);
- if (file_wordexp_get_count(wordexp))
- icon=file_wordexp_get_array(wordexp)[0];
- }
- if (strchr(icon,'/'))
- ret=g_strdup(icon);
- else {
+static int clip_line(struct wpoint *p1, struct wpoint *p2, struct point_rect *clip_rect) {
+ int rel_pos1,rel_pos2;
+ int ret = CLIPRES_VISIBLE;
+ int dx,dy,dw;
+ rel_pos1=relative_pos(p1, clip_rect);
+ if (rel_pos1!=INSIDE)
+ ret |= CLIPRES_START_CLIPPED;
+ rel_pos2=relative_pos(p2, clip_rect);
+ if (rel_pos2!=INSIDE)
+ ret |= CLIPRES_END_CLIPPED;
+ dx=p2->x-p1->x;
+ dy=p2->y-p1->y;
+ dw=p2->w-p1->w;
+ while ((rel_pos1!=INSIDE) || (rel_pos2!=INSIDE)) {
+ if (rel_pos1 & rel_pos2)
+ return CLIPRES_INVISIBLE;
+ clip_line_endoint_to_rect_edge(p1, rel_pos1, dx, dy, dw, clip_rect);
+ rel_pos1=relative_pos(p1, clip_rect);
+ if (rel_pos1 & rel_pos2)
+ return CLIPRES_INVISIBLE;
+ clip_line_endoint_to_rect_edge(p2, rel_pos2, dx, dy, dw, clip_rect);
+ rel_pos2=relative_pos(p2, clip_rect);
+ }
+ return ret;
+}
+
+/**
+ * @brief Draw polyline on the display
+ *
+ * Polylines are a serie of lines connected to each other.
+ *
+ * @param gra The graphics instance on which to draw
+ * @param gc The graphics context
+ * @param[in] pin An array of points forming the polygon
+ * @param count_in The number of elements inside @p pin
+ * @param[in] width An array of width matching the line starting from the corresponding @p pa (if all equal, all lines will have the same width)
+ * @param poly A boolean indicating whether the polyline should be closed to form a polygon (only the contour of this polygon will be drawn)
+ */
+void graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count,
+ int *width, int poly) {
+ struct point *points_to_draw=g_alloca(sizeof(struct point)*(count+1));
+ int *w=g_alloca(sizeof(int)*(count+1));
+ struct wpoint segment_start,segment_end;
+ int i,points_to_draw_cnt=0;
+ int clip_result;
+ int r_width, r_height;
+ struct point_rect r=gra->r;
+
+ r_width=r.rl.x-r.lu.x;
+ r_height=r.rl.y-r.lu.y;
+
+ // Expand clipping rect by 1/3 so wide, slanted lines do not
+ // partially end before screen border.
+ // Ideally we would expand by the line width here, but in 3D
+ // mode the width is variable and needs clipping itself, so that
+ // would get complicated. Anyway, 1/3 of screen size should be
+ // enough...
+ r.lu.x-=r_width/3;
+ r.lu.y-=r_height/3;
+ r.rl.x+=r_width/3;
+ r.rl.y+=r_height/3;
+ // Iterate over line segments, push them into points_to_draw
+ // until we reach a completely invisible segment...
+ for (i = 0 ; i < count ; i++) {
+ if (i) {
+ segment_start.x=pa[i-1].x;
+ segment_start.y=pa[i-1].y;
+ segment_start.w=width[(i-1)];
+ segment_end.x=pa[i].x;
+ segment_end.y=pa[i].y;
+ segment_end.w=width[i];
+ dbg(lvl_debug, "Segment: [%d, %d] - [%d, %d]...", segment_start.x, segment_start.y, segment_end.x, segment_end.y);
+ clip_result=clip_line(&segment_start, &segment_end, &r);
+ if (clip_result != CLIPRES_INVISIBLE) {
+ dbg(lvl_debug, "....clipped to [%d, %d] - [%d, %d]", segment_start.x, segment_start.y, segment_end.x, segment_end.y);
+ if ((i == 1) || (clip_result & CLIPRES_START_CLIPPED)) {
+ points_to_draw[points_to_draw_cnt].x=segment_start.x;
+ points_to_draw[points_to_draw_cnt].y=segment_start.y;
+ w[points_to_draw_cnt]=segment_start.w;
+ points_to_draw_cnt++;
+ }
+ points_to_draw[points_to_draw_cnt].x=segment_end.x;
+ points_to_draw[points_to_draw_cnt].y=segment_end.y;
+ w[points_to_draw_cnt]=segment_end.w;
+ points_to_draw_cnt++;
+ }
+ if ((i == count-1) || (clip_result & CLIPRES_END_CLIPPED)) {
+ // ... then draw the resulting polyline
+ if (points_to_draw_cnt > 1) {
+ if (poly) {
+ graphics_draw_polyline_as_polygon(gra->priv, gc->priv, points_to_draw, points_to_draw_cnt, w, gra->meth.draw_polygon);
+ } else
+ gra->meth.draw_lines(gra->priv, gc->priv, points_to_draw, points_to_draw_cnt);
+ points_to_draw_cnt=0;
+ }
+ }
+ }
+ }
+}
+
+static int is_inside(struct point *p, struct point_rect *r, int edge) {
+ switch(edge) {
+ case 0:
+ return p->x >= r->lu.x;
+ case 1:
+ return p->x <= r->rl.x;
+ case 2:
+ return p->y >= r->lu.y;
+ case 3:
+ return p->y <= r->rl.y;
+ default:
+ return 0;
+ }
+}
+
+static void poly_intersection(struct point *p1, struct point *p2, struct point_rect *r, int edge, struct point *ret) {
+ int dx=p2->x-p1->x;
+ int dy=p2->y-p1->y;
+ switch(edge) {
+ case 0:
+ ret->y=p1->y+((float)r->lu.x-p1->x)*dy/dx;
+ ret->x=r->lu.x;
+ break;
+ case 1:
+ ret->y=p1->y+((float)r->rl.x-p1->x)*dy/dx;
+ ret->x=r->rl.x;
+ break;
+ case 2:
+ ret->x=p1->x+((float)r->lu.y-p1->y)*dx/dy;
+ ret->y=r->lu.y;
+ break;
+ case 3:
+ ret->x=p1->x+((float)r->rl.y-p1->y)*dx/dy;
+ ret->y=r->rl.y;
+ break;
+ }
+}
+
+/**
+ * @brief Draw a plain polygon on the display
+ *
+ * @param gra The graphics instance on which to draw
+ * @param gc The graphics context
+ * @param[in] pin An array of points forming the polygon
+ * @param count_in The number of elements inside @p pin
+ */
+void graphics_draw_polygon_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pin, int count_in) {
+ struct point_rect r=gra->r;
+ struct point *pout,*p,*s,pi,*p1,*p2;
+ int limit=10000;
+ struct point *pa1=g_alloca(sizeof(struct point) * (count_in < limit ? count_in*8+1:0));
+ struct point *pa2=g_alloca(sizeof(struct point) * (count_in < limit ? count_in*8+1:0));
+ int count_out,edge=3;
+ int i;
+ if (count_in < limit) {
+ p1=pa1;
+ p2=pa2;
+ } else {
+ p1=g_new(struct point, count_in*8+1);
+ p2=g_new(struct point, count_in*8+1);
+ }
+
+ pout=p1;
+ for (edge = 0 ; edge < 4 ; edge++) {
+ p=pin;
+ s=pin+count_in-1;
+ count_out=0;
+ for (i = 0 ; i < count_in ; i++) {
+ if (is_inside(p, &r, edge)) {
+ if (! is_inside(s, &r, edge)) {
+ poly_intersection(s,p,&r,edge,&pi);
+ pout[count_out++]=pi;
+ }
+ pout[count_out++]=*p;
+ } else {
+ if (is_inside(s, &r, edge)) {
+ poly_intersection(p,s,&r,edge,&pi);
+ pout[count_out++]=pi;
+ }
+ }
+ s=p;
+ p++;
+ }
+ count_in=count_out;
+ if (pin == p1) {
+ pin=p2;
+ pout=p1;
+ } else {
+ pin=p1;
+ pout=p2;
+ }
+ }
+ gra->meth.draw_polygon(gra->priv, gc->priv, pin, count_in);
+ if (count_in >= limit) {
+ g_free(p1);
+ g_free(p2);
+ }
+}
+
+
+static void display_context_free(struct display_context *dc) {
+ if (dc->gc)
+ graphics_gc_destroy(dc->gc);
+ if (dc->gc_background)
+ graphics_gc_destroy(dc->gc_background);
+ if (dc->img)
+ graphics_image_free(dc->gra, dc->img);
+ dc->gc=NULL;
+ dc->gc_background=NULL;
+ dc->img=NULL;
+}
+
+static struct graphics_font *get_font(struct graphics *gra, int size) {
+ if (size > 64)
+ size=64;
+ if (size >= gra->font_len) {
+ gra->font=g_renew(struct graphics_font *, gra->font, size+1);
+ while (gra->font_len <= size)
+ gra->font[gra->font_len++]=NULL;
+ }
+ if (! gra->font[size])
+ gra->font[size]=graphics_font_new(gra, size*gra->font_size, 0);
+ return gra->font[size];
+}
+
+void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p) {
+ struct graphics_font *font=get_font(this_, text_size);
+ struct point bbox[4];
+ int i;
+
+ graphics_get_text_bbox(this_, font, text, 0x10000, 0, bbox, 0);
+ for (i = 0 ; i < 4 ; i++) {
+ bbox[i].x+=p->x;
+ bbox[i].y+=p->y;
+ }
+ graphics_draw_rectangle(this_, this_->gc[2], &bbox[1], bbox[2].x-bbox[0].x, bbox[0].y-bbox[1].y+5);
+ graphics_draw_text(this_, this_->gc[1], this_->gc[2], font, text, p, 0x10000, 0);
+}
+
+char *graphics_icon_path(const char *icon) {
+ static char *navit_sharedir;
+ char *ret=NULL;
+ struct file_wordexp *wordexp=NULL;
+ dbg(lvl_debug,"enter %s",icon);
+ if (strchr(icon, '$')) {
+ wordexp=file_wordexp_new(icon);
+ if (file_wordexp_get_count(wordexp))
+ icon=file_wordexp_get_array(wordexp)[0];
+ }
+ if (strchr(icon,'/'))
+ ret=g_strdup(icon);
+ else {
#ifdef HAVE_API_ANDROID
- // get resources for the correct screen density
- //
- // this part not needed, android unpacks only the correct version into res/drawable dir!
- // dbg(lvl_debug,"android icon_path %s\n",icon);
- // static char *android_density;
- // android_density = getenv("ANDROID_DENSITY");
- // ret=g_strdup_printf("res/drawable-%s/%s",android_density ,icon);
- ret=g_strdup_printf("res/drawable/%s" ,icon);
+ // get resources for the correct screen density
+ //
+ // this part not needed, android unpacks only the correct version into res/drawable dir!
+ // dbg(lvl_debug,"android icon_path %s",icon);
+ // static char *android_density;
+ // android_density = getenv("ANDROID_DENSITY");
+ // ret=g_strdup_printf("res/drawable-%s/%s",android_density ,icon);
+ ret=g_strdup_printf("res/drawable/%s",icon);
#else
- if (! navit_sharedir)
- navit_sharedir = getenv("NAVIT_SHAREDIR");
- ret=g_strdup_printf("%s/icons/%s", navit_sharedir, icon);
-#endif
- }
- if (wordexp)
- file_wordexp_destroy(wordexp);
- return ret;
-}
-
-static int
-limit_count(struct coord *c, int count)
-{
- int i;
- for (i = 1 ; i < count ; i++) {
- if (c[i].x == c[0].x && c[i].y == c[0].y)
- return i+1;
- }
- return count;
-}
-
-
-static void
-displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc)
-{
- int *width=g_alloca(sizeof(int)*dc->maxlen);
- struct point *pa=g_alloca(sizeof(struct point)*dc->maxlen);
- struct graphics *gra=dc->gra;
- struct graphics_gc *gc=dc->gc;
- struct element *e=dc->e;
- struct graphics_image *img=dc->img;
- struct point p;
- char *path;
-
- while (di) {
- int i,count=di->count,mindist=dc->mindist;
-
- di->z_order=++(gra->current_z_order);
-
- if (! gc) {
- gc=graphics_gc_new(gra);
- graphics_gc_set_foreground(gc, &e->color);
- dc->gc=gc;
- }
- if (item_type_is_area(dc->type) && (dc->e->type == element_polyline || dc->e->type == element_text))
- count=limit_count(di->c, count);
- if (dc->type == type_poly_water_tiled)
- mindist=0;
-#if 0
- if (dc->e->type == element_polygon) {
- int max=1000;
- int offset=5600;
- c+=offset;
- count-=offset;
- if (count < 0)
- count=0;
- if (count > max)
- count=max;
- }
+ if (! navit_sharedir)
+ navit_sharedir = getenv("NAVIT_SHAREDIR");
+ ret=g_strdup_printf("%s/icons/%s", navit_sharedir, icon);
#endif
- if (dc->e->type == element_polyline)
- count=transform(dc->trans, dc->pro, di->c, pa, count, mindist, e->u.polyline.width, width);
- else
- count=transform(dc->trans, dc->pro, di->c, pa, count, mindist, 0, NULL);
- switch (e->type) {
- case element_polygon:
- graphics_draw_polygon_clipped(gra, gc, pa, count);
- break;
- case element_polyline:
- {
- gc->meth.gc_set_linewidth(gc->priv, 1);
- if (e->u.polyline.width > 0 && e->u.polyline.dash_num > 0)
- graphics_gc_set_dashes(gc, e->u.polyline.width,
- e->u.polyline.offset,
- e->u.polyline.dash_table,
- e->u.polyline.dash_num);
- for (i = 0 ; i < count ; i++) {
- if (width[i] < 2)
- width[i]=2;
- }
- graphics_draw_polyline_clipped(gra, gc, pa, count, width, e->u.polyline.width > 1);
- }
- break;
- case element_circle:
- if (count) {
- if (e->u.circle.width > 1)
- gc->meth.gc_set_linewidth(gc->priv, e->u.polyline.width);
- graphics_draw_circle(gra, gc, pa, e->u.circle.radius);
- if (di->label && e->text_size) {
- struct graphics_font *font=get_font(gra, e->text_size);
- struct graphics_gc *gc_background=dc->gc_background;
- if (! gc_background && e->u.circle.background_color.a) {
- gc_background=graphics_gc_new(gra);
- graphics_gc_set_foreground(gc_background, &e->u.circle.background_color);
- dc->gc_background=gc_background;
- }
- p.x=pa[0].x+3;
- p.y=pa[0].y+10;
- if (font)
- gra->meth.draw_text(gra->priv, gc->priv, gc_background?gc_background->priv:NULL, font->priv, di->label, &p, 0x10000, 0);
- else
- dbg(lvl_error,"Failed to get font with size %d\n",e->text_size);
- }
- }
- break;
- case element_text:
- if (count && di->label) {
- struct graphics_font *font=get_font(gra, e->text_size);
- struct graphics_gc *gc_background=dc->gc_background;
- if (! gc_background && e->u.text.background_color.a) {
- gc_background=graphics_gc_new(gra);
- graphics_gc_set_foreground(gc_background, &e->u.text.background_color);
- dc->gc_background=gc_background;
- }
- if (font)
- label_line(gra, gc, gc_background, font, pa, count, di->label);
- else
- dbg(lvl_error,"Failed to get font with size %d\n",e->text_size);
- }
- break;
- case element_icon:
- if (count) {
- if (!img || item_is_custom_poi(di->item)) {
- if (item_is_custom_poi(di->item)) {
- char *icon;
- char *src;
- if (img)
- graphics_image_free(dc->gra, img);
- src=e->u.icon.src;
- if (!src || !src[0])
- src="%s";
- icon=g_strdup_printf(src,di->label+strlen(di->label)+1);
- path=graphics_icon_path(icon);
- g_free(icon);
- } else
- path=graphics_icon_path(e->u.icon.src);
- img=graphics_image_new_scaled_rotated(gra, path, e->u.icon.width, e->u.icon.height, e->u.icon.rotation);
- if (img)
- dc->img=img;
- else
- dbg(lvl_debug,"failed to load icon '%s'\n", path);
- g_free(path);
- }
- if (img) {
- if (e->u.icon.x != -1 || e->u.icon.y != -1) {
- p.x=pa[0].x - e->u.icon.x;
- p.y=pa[0].y - e->u.icon.y;
- } else {
- p.x=pa[0].x - img->hot.x;
- p.y=pa[0].y - img->hot.y;
- }
- gra->meth.draw_image(gra->priv, gra->gc[0]->priv, &p, img->priv);
- }
- }
- break;
- case element_image:
- dbg(lvl_debug,"image: '%s'\n", di->label);
- if (gra->meth.draw_image_warp) {
- img=graphics_image_new_scaled_rotated(gra, di->label, IMAGE_W_H_UNSET, IMAGE_W_H_UNSET, 0);
- if (img)
- gra->meth.draw_image_warp(gra->priv, gra->gc[0]->priv, pa, count, img->priv);
- } else
- dbg(lvl_error,"draw_image_warp not supported by graphics driver drawing '%s'\n", di->label);
- break;
- case element_arrows:
- display_draw_arrows(gra,gc,pa,count);
- break;
- default:
- dbg(lvl_error, "Unhandled element type %d\n", e->type);
-
- }
- di=di->next;
- }
+ }
+ if (wordexp)
+ file_wordexp_destroy(wordexp);
+ return ret;
+}
+
+static int limit_count(struct coord *c, int count) {
+ int i;
+ for (i = 1 ; i < count ; i++) {
+ if (c[i].x == c[0].x && c[i].y == c[0].y)
+ return i+1;
+ }
+ return count;
+}
+
+/**
+ * @brief Draw a multi-line text next to a specified point @p pref
+ *
+ * @param gra The graphics instance on which to draw
+ * @param fg The graphics color to use to draw the text
+ * @param bg The graphics background color to use to draw the text
+ * @param font The font to use to draw the text
+ * @param pref The position to draw the text (draw at the right and vertically aligned relatively to this point)
+ * @param label The text to draw (may contain '\n' for multiline text, if so lines will be stacked vertically)
+ * @param line_spacing The delta between each line (set its value at to least the font text size, to be readable)
+ */
+static void multiline_label_draw(struct graphics *gra, struct graphics_gc *fg, struct graphics_gc *bg,
+ struct graphics_font *font, struct point pref, const char *label, int line_spacing) {
+
+ char *input_label=g_strdup(label);
+ char *label_lines[10]; /* Max 10 lines of text */
+ int label_nblines=0;
+ int label_linepos=0;
+ char *startline=input_label;
+ char *endline=startline;
+ while (endline && *endline!='\0') {
+ while (*endline!='\0' && *endline!='\n') { /* Search for new line */
+ endline=g_utf8_next_char(endline);
+ }
+ if (*endline=='\0')
+ endline=NULL; /* This means we reached the end of string */
+ if (endline) /* Test if we got a new line character ('\n') */
+ *endline='\0'; /* Terminate string at line ('\n') and print this line */
+ label_lines[label_nblines++]=startline;
+ if (endline==NULL) /* endline is NULL, this was the last line of the multi-line string */
+ break;
+ endline++; /* No need for g_utf8_next_char() here, as we know '\n' is a single byte UTF-8 char */
+ startline=endline; /* Start processing next line, by setting startline to its first character */
+ }
+ if (label_nblines>(sizeof(label_lines)/sizeof(char
+ *))) { /* Does label_nblines overflows the number of entries in array label_lines? */
+ dbg(lvl_warning,"Too many lines (%d) in label \"%s\", truncating to %lu", label_nblines, label,
+ sizeof(label_lines)/sizeof(char *));
+ label_nblines=sizeof(label_lines)/sizeof(char *);
+ }
+ /* Horizontally, we position the label next to the specified point (on the right handside) */
+ pref.x+=1;
+ /* Vertically, we center the text with respect to specified point */
+ pref.y-=(label_nblines*line_spacing)/2;
+
+ /* Parse all stored lines, and display them */
+ for (label_linepos=0; label_linepos<label_nblines; label_linepos++) {
+ gra->meth.draw_text(gra->priv, fg->priv, bg?bg->priv:NULL, font->priv, label_lines[label_linepos],
+ &pref, 0x10000, 0);
+ pref.y+=line_spacing;
+ }
+ g_free(input_label);
+}
+
+
+/**
+ * @brief Draw a displayitem element
+ *
+ * This function will invoke the appropriate draw primitive depending on the type of the element to draw
+ *
+ * @brief di The displayitem to draw
+ * @brief dummy Unused
+ * @brief dc The display_context to use to draw items
+ */
+static void displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc) {
+ int *width=g_alloca(sizeof(int)*dc->maxlen);
+ struct point *pa=g_alloca(sizeof(struct point)*dc->maxlen);
+ struct graphics *gra=dc->gra;
+ struct graphics_gc *gc=dc->gc;
+ struct element *e=dc->e;
+ struct graphics_image *img=dc->img;
+ struct point p;
+ char *path;
+
+ while (di) {
+ int i,count=di->count,mindist=dc->mindist;
+
+ di->z_order=++(gra->current_z_order);
+
+ if (! gc) {
+ gc=graphics_gc_new(gra);
+ graphics_gc_set_foreground(gc, &e->color);
+ dc->gc=gc;
+ }
+ if (item_type_is_area(dc->type) && (dc->e->type == element_polyline || dc->e->type == element_text))
+ count=limit_count(di->c, count);
+ if (dc->type == type_poly_water_tiled)
+ mindist=0;
+ if (dc->e->type == element_polyline)
+ count=transform(dc->trans, dc->pro, di->c, pa, count, mindist, e->u.polyline.width, width);
+ else
+ count=transform(dc->trans, dc->pro, di->c, pa, count, mindist, 0, NULL);
+ switch (e->type) {
+ case element_polygon:
+ graphics_draw_polygon_clipped(gra, gc, pa, count);
+ break;
+ case element_polyline: {
+ gc->meth.gc_set_linewidth(gc->priv, 1);
+ if (e->u.polyline.width > 0 && e->u.polyline.dash_num > 0)
+ graphics_gc_set_dashes(gc, e->u.polyline.width, e->u.polyline.offset, e->u.polyline.dash_table, e->u.polyline.dash_num);
+ for (i = 0 ; i < count ; i++) {
+ if (width[i] < 2)
+ width[i]=2;
+ }
+ graphics_draw_polyline_clipped(gra, gc, pa, count, width, e->u.polyline.width > 1);
+ }
+ break;
+ case element_circle:
+ if (count) {
+ if (e->u.circle.width > 1)
+ gc->meth.gc_set_linewidth(gc->priv, e->u.polyline.width);
+ graphics_draw_circle(gra, gc, pa, e->u.circle.radius);
+ if (di->label && e->text_size) {
+ struct graphics_font *font=get_font(gra, e->text_size);
+ struct graphics_gc *gc_background=dc->gc_background;
+ if (! gc_background && e->u.circle.background_color.a) {
+ gc_background=graphics_gc_new(gra);
+ graphics_gc_set_foreground(gc_background, &e->u.circle.background_color);
+ dc->gc_background=gc_background;
+ }
+ if (font) {
+ /* Set p to the center of the circle */
+ p.x=pa[0].x+(e->u.circle.radius/2);
+ p.y=pa[0].y+(e->u.circle.radius/2);
+ multiline_label_draw(gra, gc, gc_background, font, p, di->label, e->text_size+1);
+ } else
+ dbg(lvl_error,"Failed to get font with size %d",e->text_size);
+ }
+ }
+ break;
+ case element_text:
+ if (count && di->label) {
+ struct graphics_font *font=get_font(gra, e->text_size);
+ struct graphics_gc *gc_background=dc->gc_background;
+ if (! gc_background && e->u.text.background_color.a) {
+ gc_background=graphics_gc_new(gra);
+ graphics_gc_set_foreground(gc_background, &e->u.text.background_color);
+ dc->gc_background=gc_background;
+ }
+ if (font)
+ label_line(gra, gc, gc_background, font, pa, count, di->label);
+ else
+ dbg(lvl_error,"Failed to get font with size %d",e->text_size);
+ }
+ break;
+ case element_icon:
+ if (count) {
+ if (!img || item_is_custom_poi(di->item)) {
+ if (item_is_custom_poi(di->item)) {
+ char *icon;
+ char *src;
+ if (img)
+ graphics_image_free(dc->gra, img);
+ src=e->u.icon.src;
+ if (!src || !src[0])
+ src="%s";
+ icon=g_strdup_printf(src,di->label+strlen(di->label)+1);
+ path=graphics_icon_path(icon);
+ g_free(icon);
+ } else
+ path=graphics_icon_path(e->u.icon.src);
+ img=graphics_image_new_scaled_rotated(gra, path, e->u.icon.width, e->u.icon.height, e->u.icon.rotation);
+ if (img)
+ dc->img=img;
+ else
+ dbg(lvl_debug,"failed to load icon '%s'", path);
+ g_free(path);
+ }
+ if (img) {
+ if (e->u.icon.x != -1 || e->u.icon.y != -1) {
+ p.x=pa[0].x - e->u.icon.x;
+ p.y=pa[0].y - e->u.icon.y;
+ } else {
+ p.x=pa[0].x - img->hot.x;
+ p.y=pa[0].y - img->hot.y;
+ }
+ gra->meth.draw_image(gra->priv, gra->gc[0]->priv, &p, img->priv);
+ }
+ }
+ break;
+ case element_image:
+ dbg(lvl_debug,"image: '%s'", di->label);
+ if (gra->meth.draw_image_warp) {
+ img=graphics_image_new_scaled_rotated(gra, di->label, IMAGE_W_H_UNSET, IMAGE_W_H_UNSET, 0);
+ if (img)
+ gra->meth.draw_image_warp(gra->priv, gra->gc[0]->priv, pa, count, img->priv);
+ } else
+ dbg(lvl_error,"draw_image_warp not supported by graphics driver drawing '%s'", di->label);
+ break;
+ case element_arrows:
+ display_draw_arrows(gra,gc,pa,count);
+ break;
+ default:
+ dbg(lvl_error, "Unhandled element type %d", e->type);
+
+ }
+ di=di->next;
+ }
}
/**
* FIXME
@@ -2248,75 +2188,72 @@ displayitem_draw(struct displayitem *di, void *dummy, struct display_context *dc
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static void xdisplay_draw_elements(struct graphics *gra, struct displaylist *display_list, struct itemgra *itm)
-{
- struct element *e;
- GList *es,*types;
- struct display_context *dc=&display_list->dc;
- struct hash_entry *entry;
-
- es=itm->elements;
- while (es) {
- e=es->data;
- dc->e=e;
- types=itm->type;
- while (types) {
- dc->type=GPOINTER_TO_INT(types->data);
- entry=get_hash_entry(display_list, dc->type);
- if (entry && entry->di) {
- displayitem_draw(entry->di, NULL, dc);
- display_context_free(dc);
- }
- types=g_list_next(types);
- }
- es=g_list_next(es);
- }
-}
-
-void
-graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label)
-{
- GList *es;
- struct display_context dc;
- int max_coord=32;
- char *buffer=g_alloca(sizeof(struct displayitem)+max_coord*sizeof(struct coord));
- struct displayitem *di=(struct displayitem *)buffer;
- es=itm->elements;
- di->item.type=type_none;
- di->item.id_hi=0;
- di->item.id_lo=0;
- di->item.map=NULL;
- di->z_order=0;
- di->label=label;
- dc.gra=gra;
- dc.gc=NULL;
- dc.gc_background=NULL;
- dc.img=NULL;
- dc.pro=projection_screen;
- dc.mindist=0;
- dc.trans=t;
- dc.type=type_none;
- dc.maxlen=max_coord;
- while (es) {
- struct element *e=es->data;
- if (e->coord_count) {
- if (e->coord_count > max_coord) {
- dbg(lvl_error,"maximum number of coords reached: %d > %d\n",e->coord_count,max_coord);
- di->count=max_coord;
- } else
- di->count=e->coord_count;
- memcpy(di->c, e->coord, di->count*sizeof(struct coord));
- } else {
- di->c[0].x=0;
- di->c[0].y=0;
- di->count=1;
- }
- dc.e=e;
- di->next=NULL;
- displayitem_draw(di, NULL, &dc);
- display_context_free(&dc);
- es=g_list_next(es);
- }
+static void xdisplay_draw_elements(struct graphics *gra, struct displaylist *display_list, struct itemgra *itm) {
+ struct element *e;
+ GList *es,*types;
+ struct display_context *dc=&display_list->dc;
+ struct hash_entry *entry;
+
+ es=itm->elements;
+ while (es) {
+ e=es->data;
+ dc->e=e;
+ types=itm->type;
+ while (types) {
+ dc->type=GPOINTER_TO_INT(types->data);
+ entry=get_hash_entry(display_list, dc->type);
+ if (entry && entry->di) {
+ displayitem_draw(entry->di, NULL, dc);
+ display_context_free(dc);
+ }
+ types=g_list_next(types);
+ }
+ es=g_list_next(es);
+ }
+}
+
+void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label) {
+ GList *es;
+ struct display_context dc;
+ int max_coord=32;
+ char *buffer=g_alloca(sizeof(struct displayitem)+max_coord*sizeof(struct coord));
+ struct displayitem *di=(struct displayitem *)buffer;
+ es=itm->elements;
+ di->item.type=type_none;
+ di->item.id_hi=0;
+ di->item.id_lo=0;
+ di->item.map=NULL;
+ di->z_order=0;
+ di->label=label;
+ dc.gra=gra;
+ dc.gc=NULL;
+ dc.gc_background=NULL;
+ dc.img=NULL;
+ dc.pro=projection_screen;
+ dc.mindist=0;
+ dc.trans=t;
+ dc.type=type_none;
+ dc.maxlen=max_coord;
+ while (es) {
+ struct element *e=es->data;
+ if (e->coord_count) {
+ if (e->coord_count > max_coord) {
+ dbg(lvl_error,"maximum number of coords reached: %d > %d",e->coord_count,max_coord);
+ di->count=max_coord;
+ } else
+ di->count=e->coord_count;
+ memcpy(di->c, e->coord, di->count*sizeof(struct coord));
+ } else {
+ di->c[0].x=0;
+ di->c[0].y=0;
+ di->count=1;
+ }
+ dc.e=e;
+ di->next=NULL;
+ displayitem_draw(di, NULL, &dc);
+ display_context_free(&dc);
+ es=g_list_next(es);
+ }
}
/**
@@ -2325,18 +2262,17 @@ graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transfor
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static void xdisplay_draw_layer(struct displaylist *display_list, struct graphics *gra, struct layer *lay, int order)
-{
- GList *itms;
- struct itemgra *itm;
+static void xdisplay_draw_layer(struct displaylist *display_list, struct graphics *gra, struct layer *lay, int order) {
+ GList *itms;
+ struct itemgra *itm;
- itms=lay->itemgras;
- while (itms) {
- itm=itms->data;
- if (order >= itm->order.min && order <= itm->order.max)
- xdisplay_draw_elements(gra, display_list, itm);
- itms=g_list_next(itms);
- }
+ itms=lay->itemgras;
+ while (itms) {
+ itm=itms->data;
+ if (order >= itm->order.min && order <= itm->order.max)
+ xdisplay_draw_elements(gra, display_list, itm);
+ itms=g_list_next(itms);
+ }
}
@@ -2346,22 +2282,21 @@ static void xdisplay_draw_layer(struct displaylist *display_list, struct graphic
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static void xdisplay_draw(struct displaylist *display_list, struct graphics *gra, struct layout *l, int order)
-{
- GList *lays;
- struct layer *lay;
-
- gra->current_z_order=0;
- lays=l->layers;
- while (lays) {
- lay=lays->data;
- if (lay->active) {
- if (lay->ref)
- lay=lay->ref;
- xdisplay_draw_layer(display_list, gra, lay, order);
- }
- lays=g_list_next(lays);
- }
+static void xdisplay_draw(struct displaylist *display_list, struct graphics *gra, struct layout *l, int order) {
+ GList *lays;
+ struct layer *lay;
+
+ gra->current_z_order=0;
+ lays=l->layers;
+ while (lays) {
+ lay=lays->data;
+ if (lay->active) {
+ if (lay->ref)
+ lay=lay->ref;
+ xdisplay_draw_layer(display_list, gra, lay, order);
+ }
+ lays=g_list_next(lays);
+ }
}
/**
@@ -2372,208 +2307,196 @@ static void xdisplay_draw(struct displaylist *display_list, struct graphics *gra
*/
extern void *route_selection;
-static void
-displaylist_update_layers(struct displaylist *displaylist, GList *layers, int order)
-{
- while (layers) {
- struct layer *layer=layers->data;
- GList *itemgras;
- if (layer->ref)
- layer=layer->ref;
- itemgras=layer->itemgras;
- while (itemgras) {
- struct itemgra *itemgra=itemgras->data;
- GList *types=itemgra->type;
- if (itemgra->order.min <= order && itemgra->order.max >= order) {
- while (types) {
- enum item_type type=(enum item_type) types->data;
- set_hash_entry(displaylist, type);
- types=g_list_next(types);
- }
- }
- itemgras=g_list_next(itemgras);
- }
- layers=g_list_next(layers);
- }
-}
-
-static void
-displaylist_update_hash(struct displaylist *displaylist)
-{
- displaylist->max_offset=0;
- clear_hash(displaylist);
- displaylist_update_layers(displaylist, displaylist->layout->layers, displaylist->order);
- dbg(lvl_debug,"max offset %d\n",displaylist->max_offset);
+static void displaylist_update_layers(struct displaylist *displaylist, GList *layers, int order) {
+ while (layers) {
+ struct layer *layer=layers->data;
+ GList *itemgras;
+ if (layer->ref)
+ layer=layer->ref;
+ itemgras=layer->itemgras;
+ while (itemgras) {
+ struct itemgra *itemgra=itemgras->data;
+ GList *types=itemgra->type;
+ if (itemgra->order.min <= order && itemgra->order.max >= order) {
+ while (types) {
+ enum item_type type=(enum item_type) types->data;
+ set_hash_entry(displaylist, type);
+ types=g_list_next(types);
+ }
+ }
+ itemgras=g_list_next(itemgras);
+ }
+ layers=g_list_next(layers);
+ }
+}
+
+static void displaylist_update_hash(struct displaylist *displaylist) {
+ displaylist->max_offset=0;
+ clear_hash(displaylist);
+ displaylist_update_layers(displaylist, displaylist->layout->layers, displaylist->order);
+ dbg(lvl_debug,"max offset %d",displaylist->max_offset);
}
/**
* @brief Returns selection structure based on displaylist transform, projection and order.
* Use this function to get map selection if you are going to fetch complete item data from the map based on displayitem reference.
- * @param displaylist
+ * @param displaylist
* @returns Pointer to selection structure
*/
-struct map_selection *displaylist_get_selection(struct displaylist *displaylist)
-{
- return transform_get_selection(displaylist->dc.trans, displaylist->dc.pro, displaylist->order);
+struct map_selection *displaylist_get_selection(struct displaylist *displaylist) {
+ return transform_get_selection(displaylist->dc.trans, displaylist->dc.pro, displaylist->order);
}
/**
- * @brief Compare displayitems based on their zorder values.
+ * @brief Compare displayitems based on their zorder values.
* Use with g_list_insert_sorted to sort less shaded items to be before more shaded ones in the result list.
*/
-static int displaylist_cmp_zorder(const struct displayitem *a, const struct displayitem *b)
-{
- if(a->z_order>b->z_order)
- return -1;
- if(a->z_order<b->z_order)
- return 1;
- return 0;
+static int displaylist_cmp_zorder(const struct displayitem *a, const struct displayitem *b) {
+ if(a->z_order>b->z_order)
+ return -1;
+ if(a->z_order<b->z_order)
+ return 1;
+ return 0;
}
/**
* @brief Returns list of displayitems clicked at given coordinates. The deeper item is in current layout, the deeper it will be in the list.
- * @param displaylist
+ * @param displaylist
* @param p clicked point
- * @param radius radius of clicked area
+ * @param radius radius of clicked area
* @returns GList of displayitems
*/
-GList *displaylist_get_clicked_list(struct displaylist *displaylist, struct point *p, int radius)
-{
- GList *l=NULL;
- struct displayitem *di;
- struct displaylist_handle *dlh=graphics_displaylist_open(displaylist);
-
- while ((di=graphics_displaylist_next(dlh))) {
- if (di->z_order>0 && graphics_displayitem_within_dist(displaylist, di, p,radius))
- l=g_list_insert_sorted(l,(gpointer) di, (GCompareFunc) displaylist_cmp_zorder);
- }
-
- graphics_displaylist_close(dlh);
-
- return l;
-}
-
-
-
-static void
-do_draw(struct displaylist *displaylist, int cancel, int flags)
-{
- struct item *item;
- int count,max=displaylist->dc.maxlen,workload=0;
- struct coord *ca=g_alloca(sizeof(struct coord)*max);
- struct attr attr,attr2;
- enum projection pro;
-
- if (displaylist->order != displaylist->order_hashed || displaylist->layout != displaylist->layout_hashed) {
- displaylist_update_hash(displaylist);
- displaylist->order_hashed=displaylist->order;
- displaylist->layout_hashed=displaylist->layout;
- }
- profile(0,NULL);
- pro=transform_get_projection(displaylist->dc.trans);
- while (!cancel) {
- if (!displaylist->msh)
- displaylist->msh=mapset_open(displaylist->ms);
- if (!displaylist->m) {
- displaylist->m=mapset_next(displaylist->msh, 1);
- if (!displaylist->m) {
- mapset_close(displaylist->msh);
- displaylist->msh=NULL;
- break;
- }
- displaylist->dc.pro=map_projection(displaylist->m);
- displaylist->conv=map_requires_conversion(displaylist->m);
- if (route_selection)
- displaylist->sel=route_selection;
- else
- displaylist->sel=displaylist_get_selection(displaylist);
- displaylist->mr=map_rect_new(displaylist->m, displaylist->sel);
- }
- if (displaylist->mr) {
- while ((item=map_rect_get_item(displaylist->mr))) {
- int label_count=0;
- char *labels[2];
- struct hash_entry *entry;
- if (item == &busy_item) {
- if (displaylist->workload)
- return;
- else
- continue;
- }
- entry=get_hash_entry(displaylist, item->type);
- if (!entry)
- continue;
- count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, displaylist->sel);
- if (! count)
- continue;
-#if 0
- dbg(lvl_debug,"%s 0x%x 0x%x\n",item_to_name(item->type), item->id_hi, item->id_lo);
-#endif
- if (displaylist->dc.pro != pro)
- transform_from_to_count(ca, displaylist->dc.pro, ca, pro, count);
- if (count == max) {
- dbg(lvl_error,"point count overflow %d for %s "ITEM_ID_FMT"\n", count,item_to_name(item->type),ITEM_ID_ARGS(*item));
- displaylist->dc.maxlen=max*2;
- }
- if (item_is_custom_poi(*item)) {
- if (item_attr_get(item, attr_icon_src, &attr2))
- labels[1]=map_convert_string(displaylist->m, attr2.u.str);
- else
- labels[1]=NULL;
- label_count=2;
- } else {
- labels[1]=NULL;
- label_count=0;
- }
- if (item_attr_get(item, attr_label, &attr)) {
- labels[0]=attr.u.str;
- if (!label_count)
- label_count=2;
- } else
- labels[0]=NULL;
- if (displaylist->conv && label_count) {
- labels[0]=map_convert_string(displaylist->m, labels[0]);
- display_add(entry, item, count, ca, labels, label_count);
- map_convert_free(labels[0]);
- } else
- display_add(entry, item, count, ca, labels, label_count);
- if (labels[1])
- map_convert_free(labels[1]);
- workload++;
- if (workload == displaylist->workload)
- return;
- }
- map_rect_destroy(displaylist->mr);
- }
- if (!route_selection)
- map_selection_destroy(displaylist->sel);
- displaylist->mr=NULL;
- displaylist->sel=NULL;
- displaylist->m=NULL;
- }
- profile(1,"process_selection\n");
- if (displaylist->idle_ev)
- event_remove_idle(displaylist->idle_ev);
- displaylist->idle_ev=NULL;
- callback_destroy(displaylist->idle_cb);
- displaylist->idle_cb=NULL;
- displaylist->busy=0;
- graphics_process_selection(displaylist->dc.gra, displaylist);
- profile(1,"draw\n");
- if (! cancel)
- graphics_displaylist_draw(displaylist->dc.gra, displaylist, displaylist->dc.trans, displaylist->layout, flags);
- map_rect_destroy(displaylist->mr);
- if (!route_selection)
- map_selection_destroy(displaylist->sel);
- mapset_close(displaylist->msh);
- displaylist->mr=NULL;
- displaylist->sel=NULL;
- displaylist->m=NULL;
- displaylist->msh=NULL;
- profile(1,"callback\n");
- callback_call_1(displaylist->cb, cancel);
- profile(0,"end\n");
+GList *displaylist_get_clicked_list(struct displaylist *displaylist, struct point *p, int radius) {
+ GList *l=NULL;
+ struct displayitem *di;
+ struct displaylist_handle *dlh=graphics_displaylist_open(displaylist);
+
+ while ((di=graphics_displaylist_next(dlh))) {
+ if (di->z_order>0 && graphics_displayitem_within_dist(displaylist, di, p,radius))
+ l=g_list_insert_sorted(l,(gpointer) di, (GCompareFunc) displaylist_cmp_zorder);
+ }
+
+ graphics_displaylist_close(dlh);
+
+ return l;
+}
+
+
+
+static void do_draw(struct displaylist *displaylist, int cancel, int flags) {
+ struct item *item;
+ int count,max=displaylist->dc.maxlen,workload=0;
+ struct coord *ca=g_alloca(sizeof(struct coord)*max);
+ struct attr attr,attr2;
+ enum projection pro;
+
+ if (displaylist->order != displaylist->order_hashed || displaylist->layout != displaylist->layout_hashed) {
+ displaylist_update_hash(displaylist);
+ displaylist->order_hashed=displaylist->order;
+ displaylist->layout_hashed=displaylist->layout;
+ }
+ profile(0,NULL);
+ pro=transform_get_projection(displaylist->dc.trans);
+ while (!cancel) {
+ if (!displaylist->msh)
+ displaylist->msh=mapset_open(displaylist->ms);
+ if (!displaylist->m) {
+ displaylist->m=mapset_next(displaylist->msh, 1);
+ if (!displaylist->m) {
+ mapset_close(displaylist->msh);
+ displaylist->msh=NULL;
+ break;
+ }
+ displaylist->dc.pro=map_projection(displaylist->m);
+ displaylist->conv=map_requires_conversion(displaylist->m);
+ if (route_selection)
+ displaylist->sel=route_selection;
+ else
+ displaylist->sel=displaylist_get_selection(displaylist);
+ displaylist->mr=map_rect_new(displaylist->m, displaylist->sel);
+ }
+ if (displaylist->mr) {
+ while ((item=map_rect_get_item(displaylist->mr))) {
+ int label_count=0;
+ char *labels[2];
+ struct hash_entry *entry;
+ if (item == &busy_item) {
+ if (displaylist->workload)
+ return;
+ else
+ continue;
+ }
+ entry=get_hash_entry(displaylist, item->type);
+ if (!entry)
+ continue;
+ count=item_coord_get_within_selection(item, ca, item->type < type_line ? 1: max, displaylist->sel);
+ if (! count)
+ continue;
+ if (displaylist->dc.pro != pro)
+ transform_from_to_count(ca, displaylist->dc.pro, ca, pro, count);
+ if (count == max) {
+ dbg(lvl_error,"point count overflow %d for %s "ITEM_ID_FMT"", count,item_to_name(item->type),ITEM_ID_ARGS(*item));
+ displaylist->dc.maxlen=max*2;
+ }
+ if (item_is_custom_poi(*item)) {
+ if (item_attr_get(item, attr_icon_src, &attr2))
+ labels[1]=map_convert_string(displaylist->m, attr2.u.str);
+ else
+ labels[1]=NULL;
+ label_count=2;
+ } else {
+ labels[1]=NULL;
+ label_count=0;
+ }
+ if (item_attr_get(item, attr_label, &attr)) {
+ labels[0]=attr.u.str;
+ if (!label_count)
+ label_count=2;
+ } else
+ labels[0]=NULL;
+ if (displaylist->conv && label_count) {
+ labels[0]=map_convert_string(displaylist->m, labels[0]);
+ display_add(entry, item, count, ca, labels, label_count);
+ map_convert_free(labels[0]);
+ } else
+ display_add(entry, item, count, ca, labels, label_count);
+ if (labels[1])
+ map_convert_free(labels[1]);
+ workload++;
+ if (workload == displaylist->workload)
+ return;
+ }
+ map_rect_destroy(displaylist->mr);
+ }
+ if (!route_selection)
+ map_selection_destroy(displaylist->sel);
+ displaylist->mr=NULL;
+ displaylist->sel=NULL;
+ displaylist->m=NULL;
+ }
+ profile(1,"process_selection\n");
+ if (displaylist->idle_ev)
+ event_remove_idle(displaylist->idle_ev);
+ displaylist->idle_ev=NULL;
+ callback_destroy(displaylist->idle_cb);
+ displaylist->idle_cb=NULL;
+ displaylist->busy=0;
+ graphics_process_selection(displaylist->dc.gra, displaylist);
+ profile(1,"draw\n");
+ if (! cancel)
+ graphics_displaylist_draw(displaylist->dc.gra, displaylist, displaylist->dc.trans, displaylist->layout, flags);
+ map_rect_destroy(displaylist->mr);
+ if (!route_selection)
+ map_selection_destroy(displaylist->sel);
+ mapset_close(displaylist->msh);
+ displaylist->mr=NULL;
+ displaylist->sel=NULL;
+ displaylist->m=NULL;
+ displaylist->msh=NULL;
+ profile(1,"callback\n");
+ callback_call_1(displaylist->cb, cancel);
+ profile(0,"end\n");
}
/**
@@ -2582,71 +2505,71 @@ do_draw(struct displaylist *displaylist, int cancel, int flags)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags)
-{
- int order=transform_get_order(trans);
- if(displaylist->dc.trans && displaylist->dc.trans!=trans)
- transform_destroy(displaylist->dc.trans);
- if(displaylist->dc.trans!=trans)
- displaylist->dc.trans=transform_dup(trans);
- displaylist->dc.gra=gra;
- displaylist->dc.mindist=flags&512?15:2;
- // FIXME find a better place to set the background color
- if (l) {
- graphics_gc_set_background(gra->gc[0], &l->color);
- graphics_gc_set_foreground(gra->gc[0], &l->color);
- g_free(gra->default_font);
- gra->default_font = g_strdup(l->font);
- }
- graphics_background_gc(gra, gra->gc[0]);
- if (flags & 1)
- callback_list_call_attr_0(gra->cbl, attr_predraw);
- gra->meth.draw_mode(gra->priv, draw_mode_begin);
- if (!(flags & 2))
- gra->meth.draw_rectangle(gra->priv, gra->gc[0]->priv, &gra->r.lu, gra->r.rl.x-gra->r.lu.x, gra->r.rl.y-gra->r.lu.y);
- if (l) {
- order+=l->order_delta;
- xdisplay_draw(displaylist, gra, l, order>0?order:0);
- }
- if (flags & 1)
- callback_list_call_attr_0(gra->cbl, attr_postdraw);
- if (!(flags & 4))
- gra->meth.draw_mode(gra->priv, draw_mode_end);
-}
-
-static void graphics_load_mapset(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags)
-{
- int order=transform_get_order(trans);
-
- dbg(lvl_debug,"enter");
- if (displaylist->busy) {
- if (async == 1)
- return;
- do_draw(displaylist, 1, flags);
- }
- xdisplay_free(displaylist);
- dbg(lvl_debug,"order=%d\n", order);
-
- displaylist->dc.gra=gra;
- displaylist->ms=mapset;
- if(displaylist->dc.trans && displaylist->dc.trans!=trans)
- transform_destroy(displaylist->dc.trans);
- if(displaylist->dc.trans!=trans)
- displaylist->dc.trans=transform_dup(trans);
- displaylist->workload=async ? 100 : 0;
- displaylist->cb=cb;
- displaylist->seq++;
- if (l)
- order+=l->order_delta;
- displaylist->order=order>0?order:0;
- displaylist->busy=1;
- displaylist->layout=l;
- if (async) {
- if (! displaylist->idle_cb)
- displaylist->idle_cb=callback_new_3(callback_cast(do_draw), displaylist, 0, flags);
- displaylist->idle_ev=event_add_idle(50, displaylist->idle_cb);
- } else
- do_draw(displaylist, 0, flags);
+void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans,
+ struct layout *l, int flags) {
+ int order=transform_get_order(trans);
+ if(displaylist->dc.trans && displaylist->dc.trans!=trans)
+ transform_destroy(displaylist->dc.trans);
+ if(displaylist->dc.trans!=trans)
+ displaylist->dc.trans=transform_dup(trans);
+ displaylist->dc.gra=gra;
+ displaylist->dc.mindist=flags&512?15:2;
+ // FIXME find a better place to set the background color
+ if (l) {
+ graphics_gc_set_background(gra->gc[0], &l->color);
+ graphics_gc_set_foreground(gra->gc[0], &l->color);
+ g_free(gra->default_font);
+ gra->default_font = g_strdup(l->font);
+ }
+ graphics_background_gc(gra, gra->gc[0]);
+ if (flags & 1)
+ callback_list_call_attr_0(gra->cbl, attr_predraw);
+ gra->meth.draw_mode(gra->priv, draw_mode_begin);
+ if (!(flags & 2))
+ gra->meth.draw_rectangle(gra->priv, gra->gc[0]->priv, &gra->r.lu, gra->r.rl.x-gra->r.lu.x, gra->r.rl.y-gra->r.lu.y);
+ if (l) {
+ order+=l->order_delta;
+ xdisplay_draw(displaylist, gra, l, order>0?order:0);
+ }
+ if (flags & 1)
+ callback_list_call_attr_0(gra->cbl, attr_postdraw);
+ if (!(flags & 4))
+ gra->meth.draw_mode(gra->priv, draw_mode_end);
+}
+
+static void graphics_load_mapset(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset,
+ struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags) {
+ int order=transform_get_order(trans);
+
+ dbg(lvl_debug,"enter");
+ if (displaylist->busy) {
+ if (async == 1)
+ return;
+ do_draw(displaylist, 1, flags);
+ }
+ xdisplay_free(displaylist);
+ dbg(lvl_debug,"order=%d", order);
+
+ displaylist->dc.gra=gra;
+ displaylist->ms=mapset;
+ if(displaylist->dc.trans && displaylist->dc.trans!=trans)
+ transform_destroy(displaylist->dc.trans);
+ if(displaylist->dc.trans!=trans)
+ displaylist->dc.trans=transform_dup(trans);
+ displaylist->workload=async ? 100 : 0;
+ displaylist->cb=cb;
+ displaylist->seq++;
+ if (l)
+ order+=l->order_delta;
+ displaylist->order=order>0?order:0;
+ displaylist->busy=1;
+ displaylist->layout=l;
+ if (async) {
+ if (! displaylist->idle_cb)
+ displaylist->idle_cb=callback_new_3(callback_cast(do_draw), displaylist, 0, flags);
+ displaylist->idle_ev=event_add_idle(50, displaylist->idle_cb);
+ } else
+ do_draw(displaylist, 0, flags);
}
/**
* FIXME
@@ -2654,18 +2577,16 @@ static void graphics_load_mapset(struct graphics *gra, struct displaylist *displ
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags)
-{
- graphics_load_mapset(gra, displaylist, mapset, trans, l, async, cb, flags);
+void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset,
+ struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags) {
+ graphics_load_mapset(gra, displaylist, mapset, trans, l, async, cb, flags);
}
-int
-graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist)
-{
- if (!displaylist->busy)
- return 0;
- do_draw(displaylist, 1, 0);
- return 1;
+int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist) {
+ if (!displaylist->busy)
+ return 0;
+ do_draw(displaylist, 1, 0);
+ return 1;
}
/**
@@ -2675,9 +2596,9 @@ graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist)
* @author Martin Schaller (04/2008)
*/
struct displaylist_handle {
- struct displaylist *dl;
- struct displayitem *di;
- int hashidx;
+ struct displaylist *dl;
+ struct displayitem *di;
+ int hashidx;
};
/**
@@ -2686,14 +2607,13 @@ struct displaylist_handle {
* @returns <>
* @author Martin Schaller (04/2008)
*/
-struct displaylist_handle * graphics_displaylist_open(struct displaylist *displaylist)
-{
- struct displaylist_handle *ret;
+struct displaylist_handle * graphics_displaylist_open(struct displaylist *displaylist) {
+ struct displaylist_handle *ret;
- ret=g_new0(struct displaylist_handle, 1);
- ret->dl=displaylist;
+ ret=g_new0(struct displaylist_handle, 1);
+ ret->dl=displaylist;
- return ret;
+ return ret;
}
/**
@@ -2702,26 +2622,25 @@ struct displaylist_handle * graphics_displaylist_open(struct displaylist *displa
* @returns <>
* @author Martin Schaller (04/2008)
*/
-struct displayitem * graphics_displaylist_next(struct displaylist_handle *dlh)
-{
- struct displayitem *ret;
- if (!dlh)
- return NULL;
- for (;;) {
- if (dlh->di) {
- ret=dlh->di;
- dlh->di=ret->next;
- break;
- }
- if (dlh->hashidx == HASH_SIZE) {
- ret=NULL;
- break;
- }
- if (dlh->dl->hash_entries[dlh->hashidx].type)
- dlh->di=dlh->dl->hash_entries[dlh->hashidx].di;
- dlh->hashidx++;
- }
- return ret;
+struct displayitem * graphics_displaylist_next(struct displaylist_handle *dlh) {
+ struct displayitem *ret;
+ if (!dlh)
+ return NULL;
+ for (;;) {
+ if (dlh->di) {
+ ret=dlh->di;
+ dlh->di=ret->next;
+ break;
+ }
+ if (dlh->hashidx == HASH_SIZE) {
+ ret=NULL;
+ break;
+ }
+ if (dlh->dl->hash_entries[dlh->hashidx].type)
+ dlh->di=dlh->dl->hash_entries[dlh->hashidx].di;
+ dlh->hashidx++;
+ }
+ return ret;
}
/**
@@ -2730,9 +2649,8 @@ struct displayitem * graphics_displaylist_next(struct displaylist_handle *dlh)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-void graphics_displaylist_close(struct displaylist_handle *dlh)
-{
- g_free(dlh);
+void graphics_displaylist_close(struct displaylist_handle *dlh) {
+ g_free(dlh);
}
/**
@@ -2741,21 +2659,19 @@ void graphics_displaylist_close(struct displaylist_handle *dlh)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-struct displaylist * graphics_displaylist_new(void)
-{
- struct displaylist *ret=g_new0(struct displaylist, 1);
+struct displaylist * graphics_displaylist_new(void) {
+ struct displaylist *ret=g_new0(struct displaylist, 1);
- ret->dc.maxlen=16384;
+ ret->dc.maxlen=16384;
- return ret;
+ return ret;
}
-void graphics_displaylist_destroy(struct displaylist *displaylist)
-{
- if(displaylist->dc.trans)
- transform_destroy(displaylist->dc.trans);
- g_free(displaylist);
-
+void graphics_displaylist_destroy(struct displaylist *displaylist) {
+ if(displaylist->dc.trans)
+ transform_destroy(displaylist->dc.trans);
+ g_free(displaylist);
+
}
@@ -2766,28 +2682,24 @@ void graphics_displaylist_destroy(struct displaylist *displaylist)
* @returns Pointer to struct item
* @author Martin Schaller (04/2008)
*/
-struct item * graphics_displayitem_get_item(struct displayitem *di)
-{
- return &di->item;
+struct item * graphics_displayitem_get_item(struct displayitem *di) {
+ return &di->item;
}
/**
- * Get the number of this item as it was last displayed on the screen, dependent of current layout. Items with lower numbers
- * are shaded by items with higher ones when they overlap. Zero means item was not displayed at all. If the item is displayed twice, its topmost
+ * Get the number of this item as it was last displayed on the screen, dependent of current layout. Items with lower numbers
+ * are shaded by items with higher ones when they overlap. Zero means item was not displayed at all. If the item is displayed twice, its topmost
* occurence is used.
* @param di pointer to displayitem structure
- * @returns z-order of current item.
+ * @returns z-order of current item.
*/
-int graphics_displayitem_get_z_order(struct displayitem *di)
-{
- return di->z_order;
+int graphics_displayitem_get_z_order(struct displayitem *di) {
+ return di->z_order;
}
-int
-graphics_displayitem_get_coord_count(struct displayitem *di)
-{
- return di->count;
+int graphics_displayitem_get_coord_count(struct displayitem *di) {
+ return di->count;
}
/**
@@ -2796,15 +2708,12 @@ graphics_displayitem_get_coord_count(struct displayitem *di)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-char * graphics_displayitem_get_label(struct displayitem *di)
-{
- return di->label;
+char * graphics_displayitem_get_label(struct displayitem *di) {
+ return di->label;
}
-int
-graphics_displayitem_get_displayed(struct displayitem *di)
-{
- return 1;
+int graphics_displayitem_get_displayed(struct displayitem *di) {
+ return 1;
}
/**
@@ -2813,16 +2722,15 @@ graphics_displayitem_get_displayed(struct displayitem *di)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static int within_dist_point(struct point *p0, struct point *p1, int dist)
-{
- if (p0->x == 32767 || p0->y == 32767 || p1->x == 32767 || p1->y == 32767)
- return 0;
- if (p0->x == -32768 || p0->y == -32768 || p1->x == -32768 || p1->y == -32768)
- return 0;
- if ((p0->x-p1->x)*(p0->x-p1->x) + (p0->y-p1->y)*(p0->y-p1->y) <= dist*dist) {
- return 1;
- }
+static int within_dist_point(struct point *p0, struct point *p1, int dist) {
+ if (p0->x == 32767 || p0->y == 32767 || p1->x == 32767 || p1->y == 32767)
return 0;
+ if (p0->x == -32768 || p0->y == -32768 || p1->x == -32768 || p1->y == -32768)
+ return 0;
+ if ((p0->x-p1->x)*(p0->x-p1->x) + (p0->y-p1->y)*(p0->y-p1->y) <= dist*dist) {
+ return 1;
+ }
+ return 0;
}
/**
@@ -2831,50 +2739,49 @@ static int within_dist_point(struct point *p0, struct point *p1, int dist)
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static int within_dist_line(struct point *p, struct point *line_p0, struct point *line_p1, int dist)
-{
- int vx,vy,wx,wy;
- int c1,c2;
- struct point line_p;
-
- if (line_p0->x < line_p1->x) {
- if (p->x < line_p0->x - dist)
- return 0;
- if (p->x > line_p1->x + dist)
- return 0;
- } else {
- if (p->x < line_p1->x - dist)
- return 0;
- if (p->x > line_p0->x + dist)
- return 0;
- }
- if (line_p0->y < line_p1->y) {
- if (p->y < line_p0->y - dist)
- return 0;
- if (p->y > line_p1->y + dist)
- return 0;
- } else {
- if (p->y < line_p1->y - dist)
- return 0;
- if (p->y > line_p0->y + dist)
- return 0;
- }
-
- vx=line_p1->x-line_p0->x;
- vy=line_p1->y-line_p0->y;
- wx=p->x-line_p0->x;
- wy=p->y-line_p0->y;
-
- c1=vx*wx+vy*wy;
- if ( c1 <= 0 )
- return within_dist_point(p, line_p0, dist);
- c2=vx*vx+vy*vy;
- if ( c2 <= c1 )
- return within_dist_point(p, line_p1, dist);
-
- line_p.x=line_p0->x+vx*c1/c2;
- line_p.y=line_p0->y+vy*c1/c2;
- return within_dist_point(p, &line_p, dist);
+static int within_dist_line(struct point *p, struct point *line_p0, struct point *line_p1, int dist) {
+ int vx,vy,wx,wy;
+ int c1,c2;
+ struct point line_p;
+
+ if (line_p0->x < line_p1->x) {
+ if (p->x < line_p0->x - dist)
+ return 0;
+ if (p->x > line_p1->x + dist)
+ return 0;
+ } else {
+ if (p->x < line_p1->x - dist)
+ return 0;
+ if (p->x > line_p0->x + dist)
+ return 0;
+ }
+ if (line_p0->y < line_p1->y) {
+ if (p->y < line_p0->y - dist)
+ return 0;
+ if (p->y > line_p1->y + dist)
+ return 0;
+ } else {
+ if (p->y < line_p1->y - dist)
+ return 0;
+ if (p->y > line_p0->y + dist)
+ return 0;
+ }
+
+ vx=line_p1->x-line_p0->x;
+ vy=line_p1->y-line_p0->y;
+ wx=p->x-line_p0->x;
+ wy=p->y-line_p0->y;
+
+ c1=vx*wx+vy*wy;
+ if ( c1 <= 0 )
+ return within_dist_point(p, line_p0, dist);
+ c2=vx*vx+vy*vy;
+ if ( c2 <= c1 )
+ return within_dist_point(p, line_p1, dist);
+
+ line_p.x=line_p0->x+vx*c1/c2;
+ line_p.y=line_p0->y+vy*c1/c2;
+ return within_dist_point(p, &line_p, dist);
}
/**
@@ -2883,17 +2790,16 @@ static int within_dist_line(struct point *p, struct point *line_p0, struct point
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static int within_dist_polyline(struct point *p, struct point *line_pnt, int count, int dist, int close)
-{
- int i;
- for (i = 0 ; i < count-1 ; i++) {
- if (within_dist_line(p,line_pnt+i,line_pnt+i+1,dist)) {
- return 1;
- }
- }
- if (close)
- return (within_dist_line(p,line_pnt,line_pnt+count-1,dist));
- return 0;
+static int within_dist_polyline(struct point *p, struct point *line_pnt, int count, int dist, int close) {
+ int i;
+ for (i = 0 ; i < count-1 ; i++) {
+ if (within_dist_line(p,line_pnt+i,line_pnt+i+1,dist)) {
+ return 1;
+ }
+ }
+ if (close)
+ return (within_dist_line(p,line_pnt,line_pnt+count-1,dist));
+ return 0;
}
/**
@@ -2902,18 +2808,17 @@ static int within_dist_polyline(struct point *p, struct point *line_pnt, int cou
* @returns <>
* @author Martin Schaller (04/2008)
*/
-static int within_dist_polygon(struct point *p, struct point *poly_pnt, int count, int dist)
-{
- int i, j, c = 0;
- for (i = 0, j = count-1; i < count; j = i++) {
- if ((((poly_pnt[i].y <= p->y) && ( p->y < poly_pnt[j].y )) ||
- ((poly_pnt[j].y <= p->y) && ( p->y < poly_pnt[i].y))) &&
- (p->x < (poly_pnt[j].x - poly_pnt[i].x) * (p->y - poly_pnt[i].y) / (poly_pnt[j].y - poly_pnt[i].y) + poly_pnt[i].x))
- c = !c;
- }
- if (! c)
- return within_dist_polyline(p, poly_pnt, count, dist, 1);
- return c;
+static int within_dist_polygon(struct point *p, struct point *poly_pnt, int count, int dist) {
+ int i, j, c = 0;
+ for (i = 0, j = count-1; i < count; j = i++) {
+ if ((((poly_pnt[i].y <= p->y) && ( p->y < poly_pnt[j].y )) ||
+ ((poly_pnt[j].y <= p->y) && ( p->y < poly_pnt[i].y))) &&
+ (p->x < (poly_pnt[j].x - poly_pnt[i].x) * (p->y - poly_pnt[i].y) / (poly_pnt[j].y - poly_pnt[i].y) + poly_pnt[i].x))
+ c = !c;
+ }
+ if (! c)
+ return within_dist_polyline(p, poly_pnt, count, dist, 1);
+ return c;
}
/**
@@ -2922,127 +2827,117 @@ static int within_dist_polygon(struct point *p, struct point *poly_pnt, int coun
* @returns <>
* @author Martin Schaller (04/2008)
*/
-int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist)
-{
- struct point *pa=g_alloca(sizeof(struct point)*displaylist->dc.maxlen);
- int count;
+int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p,
+ int dist) {
+ struct point *pa=g_alloca(sizeof(struct point)*displaylist->dc.maxlen);
+ int count;
- count=transform(displaylist->dc.trans, displaylist->dc.pro, di->c, pa, di->count, 0, 0, NULL);
+ count=transform(displaylist->dc.trans, displaylist->dc.pro, di->c, pa, di->count, 0, 0, NULL);
- if (di->item.type < type_line) {
- return within_dist_point(p, &pa[0], dist);
- }
- if (di->item.type < type_area) {
- return within_dist_polyline(p, pa, count, dist, 0);
- }
- return within_dist_polygon(p, pa, count, dist);
+ if (di->item.type < type_line) {
+ return within_dist_point(p, &pa[0], dist);
+ }
+ if (di->item.type < type_area) {
+ return within_dist_polyline(p, pa, count, dist, 0);
+ }
+ return within_dist_polygon(p, pa, count, dist);
}
-static void
-graphics_process_selection_item(struct displaylist *dl, struct item *item)
-{
+static void graphics_process_selection_item(struct displaylist *dl, struct item *item) {
#if 0 /* FIXME */
- struct displayitem di,*di_res;
- GHashTable *h;
- int count,max=dl->dc.maxlen;
- struct coord ca[max];
- struct attr attr;
- struct map_rect *mr;
-
- di.item=*item;
- di.label=NULL;
- di.count=0;
- h=g_hash_table_lookup(dl->dl, GINT_TO_POINTER(di.item.type));
- if (h) {
- di_res=g_hash_table_lookup(h, &di);
- if (di_res) {
- di.item.type=(enum item_type)item->priv_data;
- display_add(dl, &di.item, di_res->count, di_res->c, NULL, 0);
- return;
- }
- }
- mr=map_rect_new(item->map, NULL);
- item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- count=item_coord_get(item, ca, item->type < type_line ? 1: max);
- if (!item_attr_get(item, attr_label, &attr))
- attr.u.str=NULL;
- if (dl->conv && attr.u.str && attr.u.str[0]) {
- char *str=map_convert_string(item->map, attr.u.str);
- display_add(dl, item, count, ca, &str, 1);
- map_convert_free(str);
- } else
- display_add(dl, item, count, ca, &attr.u.str, 1);
- map_rect_destroy(mr);
+ struct displayitem di,*di_res;
+ GHashTable *h;
+ int count,max=dl->dc.maxlen;
+ struct coord ca[max];
+ struct attr attr;
+ struct map_rect *mr;
+
+ di.item=*item;
+ di.label=NULL;
+ di.count=0;
+ h=g_hash_table_lookup(dl->dl, GINT_TO_POINTER(di.item.type));
+ if (h) {
+ di_res=g_hash_table_lookup(h, &di);
+ if (di_res) {
+ di.item.type=(enum item_type)item->priv_data;
+ display_add(dl, &di.item, di_res->count, di_res->c, NULL, 0);
+ return;
+ }
+ }
+ mr=map_rect_new(item->map, NULL);
+ item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ count=item_coord_get(item, ca, item->type < type_line ? 1: max);
+ if (!item_attr_get(item, attr_label, &attr))
+ attr.u.str=NULL;
+ if (dl->conv && attr.u.str && attr.u.str[0]) {
+ char *str=map_convert_string(item->map, attr.u.str);
+ display_add(dl, item, count, ca, &str, 1);
+ map_convert_free(str);
+ } else
+ display_add(dl, item, count, ca, &attr.u.str, 1);
+ map_rect_destroy(mr);
#endif
}
-void
-graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl)
-{
- struct item *item_dup=g_new(struct item, 1);
- *item_dup=*item;
- item_dup->priv_data=(void *)type;
- gra->selection=g_list_append(gra->selection, item_dup);
- if (dl)
- graphics_process_selection_item(dl, item_dup);
-}
-
-void
-graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl)
-{
- GList *curr;
- int found;
-
- for (;;) {
- curr=gra->selection;
- found=0;
- while (curr) {
- struct item *sitem=curr->data;
- if (item_is_equal(*item,*sitem)) {
+void graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl) {
+ struct item *item_dup=g_new(struct item, 1);
+ *item_dup=*item;
+ item_dup->priv_data=(void *)type;
+ gra->selection=g_list_append(gra->selection, item_dup);
+ if (dl)
+ graphics_process_selection_item(dl, item_dup);
+}
+
+void graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl) {
+ GList *curr;
+ int found;
+
+ for (;;) {
+ curr=gra->selection;
+ found=0;
+ while (curr) {
+ struct item *sitem=curr->data;
+ if (item_is_equal(*item,*sitem)) {
#if 0 /* FIXME */
- if (dl) {
- struct displayitem di;
- GHashTable *h;
- di.item=*sitem;
- di.label=NULL;
- di.count=0;
- di.item.type=type;
- h=g_hash_table_lookup(dl->dl, GINT_TO_POINTER(di.item.type));
- if (h)
- g_hash_table_remove(h, &di);
- }
+ if (dl) {
+ struct displayitem di;
+ GHashTable *h;
+ di.item=*sitem;
+ di.label=NULL;
+ di.count=0;
+ di.item.type=type;
+ h=g_hash_table_lookup(dl->dl, GINT_TO_POINTER(di.item.type));
+ if (h)
+ g_hash_table_remove(h, &di);
+ }
#endif
- g_free(sitem);
- gra->selection=g_list_remove(gra->selection, curr->data);
- found=1;
- break;
- }
- }
- if (!found)
- return;
- }
-}
-
-void
-graphics_clear_selection(struct graphics *gra, struct displaylist *dl)
-{
- while (gra->selection) {
- struct item *item=(struct item *)gra->selection->data;
- graphics_remove_selection(gra, item, (enum item_type)item->priv_data,dl);
- }
-}
-
-static void
-graphics_process_selection(struct graphics *gra, struct displaylist *dl)
-{
- GList *curr;
-
- curr=gra->selection;
- while (curr) {
- struct item *item=curr->data;
- graphics_process_selection_item(dl, item);
- curr=g_list_next(curr);
- }
+ g_free(sitem);
+ gra->selection=g_list_remove(gra->selection, curr->data);
+ found=1;
+ break;
+ }
+ }
+ if (!found)
+ return;
+ }
+}
+
+void graphics_clear_selection(struct graphics *gra, struct displaylist *dl) {
+ while (gra->selection) {
+ struct item *item=(struct item *)gra->selection->data;
+ graphics_remove_selection(gra, item, (enum item_type)item->priv_data,dl);
+ }
+}
+
+static void graphics_process_selection(struct graphics *gra, struct displaylist *dl) {
+ GList *curr;
+
+ curr=gra->selection;
+ while (curr) {
+ struct item *item=curr->data;
+ graphics_process_selection_item(dl, item);
+ curr=g_list_next(curr);
+ }
}
diff --git a/navit/graphics.h b/navit/graphics.h
index 2ffbd9ab0..befeb8e2b 100644
--- a/navit/graphics.h
+++ b/navit/graphics.h
@@ -282,6 +282,8 @@ void graphics_remove_selection(struct graphics *gra, struct item *item, enum ite
void graphics_clear_selection(struct graphics *gra, struct displaylist *dl);
int graphics_show_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd);
int graphics_hide_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd);
+void graphics_draw_polygon_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pin, int count_in);
+void graphics_draw_polyline_clipped(struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int poly);
/* end of prototypes */
#ifdef __cplusplus
diff --git a/navit/graphics/CMakeLists.txt b/navit/graphics/CMakeLists.txt
index 004accfc8..9e77d361d 100644
--- a/navit/graphics/CMakeLists.txt
+++ b/navit/graphics/CMakeLists.txt
@@ -4,8 +4,8 @@
add_subdirectory (ezxml)
if (HAVE_API_WIN32_BASE)
-add_subdirectory (glib)
-add_subdirectory (win32)
+ add_subdirectory (glib)
+ add_subdirectory (win32)
endif (HAVE_API_WIN32_BASE)
add_subdirectory (zlib)
diff --git a/navit/graphics/android/graphics_android.c b/navit/graphics/android/graphics_android.c
index 0d6aa30d2..68cf1874d 100644
--- a/navit/graphics/android/graphics_android.c
+++ b/navit/graphics/android/graphics_android.c
@@ -35,454 +35,414 @@
#include "command.h"
struct graphics_priv {
- jclass NavitGraphicsClass;
- jmethodID NavitGraphics_draw_polyline, NavitGraphics_draw_polygon, NavitGraphics_draw_rectangle,
- NavitGraphics_draw_circle, NavitGraphics_draw_text, NavitGraphics_draw_image,
- NavitGraphics_draw_image_warp, NavitGraphics_draw_mode, NavitGraphics_draw_drag,
- NavitGraphics_overlay_disable, NavitGraphics_overlay_resize, NavitGraphics_SetCamera,
- NavitGraphics_setBackgroundColor;
-
- jclass PaintClass;
- jmethodID Paint_init,Paint_setStrokeWidth,Paint_setARGB;
-
- jobject NavitGraphics;
- jobject Paint;
-
- jclass BitmapFactoryClass;
- jmethodID BitmapFactory_decodeFile, BitmapFactory_decodeResource;
-
- jclass BitmapClass;
- jmethodID Bitmap_getHeight, Bitmap_getWidth, Bitmap_createScaledBitmap;
-
- jclass ContextClass;
- jmethodID Context_getResources;
-
- jclass ResourcesClass;
- jobject Resources;
- jmethodID Resources_getIdentifier;
-
- jobject packageName;
-
- struct callback_list *cbl;
- struct window win;
- struct padding *padding;
- jint bgcolor;
+ jclass NavitGraphicsClass;
+ jmethodID NavitGraphics_draw_polyline, NavitGraphics_draw_polygon, NavitGraphics_draw_rectangle,
+ NavitGraphics_draw_circle, NavitGraphics_draw_text, NavitGraphics_draw_image,
+ NavitGraphics_draw_image_warp, NavitGraphics_draw_mode, NavitGraphics_draw_drag,
+ NavitGraphics_overlay_disable, NavitGraphics_overlay_resize, NavitGraphics_SetCamera,
+ NavitGraphics_setBackgroundColor;
+
+ jclass PaintClass;
+ jmethodID Paint_init,Paint_setStrokeWidth,Paint_setARGB;
+
+ jobject NavitGraphics;
+ jobject Paint;
+
+ jclass BitmapFactoryClass;
+ jmethodID BitmapFactory_decodeFile, BitmapFactory_decodeResource;
+
+ jclass BitmapClass;
+ jmethodID Bitmap_getHeight, Bitmap_getWidth, Bitmap_createScaledBitmap;
+
+ jclass ContextClass;
+ jmethodID Context_getResources;
+
+ jclass ResourcesClass;
+ jobject Resources;
+ jmethodID Resources_getIdentifier;
+
+ jobject packageName;
+
+ struct callback_list *cbl;
+ struct window win;
+ struct padding *padding;
+ jint bgcolor;
};
struct graphics_font_priv {
- int size;
+ int size;
};
struct graphics_gc_priv {
- struct graphics_priv *gra;
- int linewidth;
- enum draw_mode_num mode;
- int a,r,g,b;
- unsigned char *dashes;
- int ndashes;
+ struct graphics_priv *gra;
+ int linewidth;
+ enum draw_mode_num mode;
+ int a,r,g,b;
+ unsigned char *dashes;
+ int ndashes;
};
struct graphics_image_priv {
- jobject Bitmap;
- int width;
- int height;
- struct point hot;
+ jobject Bitmap;
+ int width;
+ int height;
+ struct point hot;
};
static GHashTable *image_cache_hash = NULL;
-static int
-find_class_global(char *name, jclass *ret)
-{
- *ret=(*jnienv)->FindClass(jnienv, name);
- if (! *ret) {
- dbg(lvl_error,"Failed to get Class %s\n",name);
- return 0;
- }
- *ret = (*jnienv)->NewGlobalRef(jnienv, *ret);
- return 1;
+static int find_class_global(char *name, jclass *ret) {
+ *ret=(*jnienv)->FindClass(jnienv, name);
+ if (! *ret) {
+ dbg(lvl_error,"Failed to get Class %s",name);
+ return 0;
+ }
+ *ret = (*jnienv)->NewGlobalRef(jnienv, *ret);
+ return 1;
}
-static int
-find_method(jclass class, char *name, char *args, jmethodID *ret)
-{
- *ret = (*jnienv)->GetMethodID(jnienv, class, name, args);
- if (*ret == NULL) {
- dbg(lvl_error,"Failed to get Method %s with signature %s\n",name,args);
- return 0;
- }
- return 1;
+static int find_method(jclass class, char *name, char *args, jmethodID *ret) {
+ *ret = (*jnienv)->GetMethodID(jnienv, class, name, args);
+ if (*ret == NULL) {
+ dbg(lvl_error,"Failed to get Method %s with signature %s",name,args);
+ return 0;
+ }
+ return 1;
}
-static int
-find_static_method(jclass class, char *name, char *args, jmethodID *ret)
-{
- *ret = (*jnienv)->GetStaticMethodID(jnienv, class, name, args);
- if (*ret == NULL) {
- dbg(lvl_error,"Failed to get static Method %s with signature %s\n",name,args);
- return 0;
- }
- return 1;
+static int find_static_method(jclass class, char *name, char *args, jmethodID *ret) {
+ *ret = (*jnienv)->GetStaticMethodID(jnienv, class, name, args);
+ if (*ret == NULL) {
+ dbg(lvl_error,"Failed to get static Method %s with signature %s",name,args);
+ return 0;
+ }
+ return 1;
}
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
+static void graphics_destroy(struct graphics_priv *gr) {
}
-static void font_destroy(struct graphics_font_priv *font)
-{
- g_free(font);
+static void font_destroy(struct graphics_font_priv *font) {
+ g_free(font);
}
static struct graphics_font_methods font_methods = {
- font_destroy
+ font_destroy
};
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags)
-{
- struct graphics_font_priv *ret=g_new0(struct graphics_font_priv, 1);
- *meth=font_methods;
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font,
+ int size, int flags) {
+ struct graphics_font_priv *ret=g_new0(struct graphics_font_priv, 1);
+ *meth=font_methods;
- ret->size=size;
- return ret;
+ ret->size=size;
+ return ret;
}
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
- g_free(gc->dashes);
- g_free(gc);
+static void gc_destroy(struct graphics_gc_priv *gc) {
+ g_free(gc->dashes);
+ g_free(gc);
}
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
+static void gc_set_linewidth(struct graphics_gc_priv *gc, int w) {
gc->linewidth = w;
}
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
-{
- g_free(gc->dashes);
- gc->ndashes=n;
- if(n) {
- gc->dashes=g_malloc(n);
- memcpy(gc->dashes, dash_list, n);
- } else {
- gc->dashes=NULL;
- }
+static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n) {
+ g_free(gc->dashes);
+ gc->ndashes=n;
+ if(n) {
+ gc->dashes=g_malloc(n);
+ memcpy(gc->dashes, dash_list, n);
+ } else {
+ gc->dashes=NULL;
+ }
}
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c) {
gc->r = c->r >> 8;
gc->g = c->g >> 8;
gc->b = c->b >> 8;
gc->a = c->a >> 8;
}
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_background(struct graphics_gc_priv *gc, struct color *c) {
}
static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
+ gc_destroy,
+ gc_set_linewidth,
+ gc_set_dashes,
+ gc_set_foreground,
+ gc_set_background
};
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- struct graphics_gc_priv *ret=g_new0(struct graphics_gc_priv, 1);
- *meth=gc_methods;
+static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) {
+ struct graphics_gc_priv *ret=g_new0(struct graphics_gc_priv, 1);
+ *meth=gc_methods;
- ret->gra = gr;
- ret->a = ret->r = ret->g = ret->b = 255;
- ret->linewidth=1;
- return ret;
+ ret->gra = gr;
+ ret->a = ret->r = ret->g = ret->b = 255;
+ ret->linewidth=1;
+ return ret;
}
-static void image_destroy(struct graphics_image_priv *img)
-{
+static void image_destroy(struct graphics_image_priv *img) {
// unused?
}
static struct graphics_image_methods image_methods = {
- image_destroy
+ image_destroy
};
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gra, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation)
-{
- struct graphics_image_priv* ret = NULL;
-
- ret=g_new0(struct graphics_image_priv, 1);
- jstring string;
- jclass localBitmap = NULL;
- int id;
-
- dbg(lvl_debug,"enter %s\n",path);
- if (!strncmp(path,"res/drawable/",13)) {
- jstring a=(*jnienv)->NewStringUTF(jnienv, "drawable");
- char *path_noext=g_strdup(path+13);
- char *pos=strrchr(path_noext, '.');
- if (pos)
- *pos='\0';
- dbg(lvl_debug,"path_noext=%s\n",path_noext);
- string = (*jnienv)->NewStringUTF(jnienv, path_noext);
- g_free(path_noext);
- id=(*jnienv)->CallIntMethod(jnienv, gra->Resources, gra->Resources_getIdentifier, string, a, gra->packageName);
- dbg(lvl_debug,"id=%d\n",id);
- if (id)
- localBitmap=(*jnienv)->CallStaticObjectMethod(jnienv, gra->BitmapFactoryClass, gra->BitmapFactory_decodeResource, gra->Resources, id);
- (*jnienv)->DeleteLocalRef(jnienv, a);
- } else {
- string = (*jnienv)->NewStringUTF(jnienv, path);
- localBitmap=(*jnienv)->CallStaticObjectMethod(jnienv, gra->BitmapFactoryClass, gra->BitmapFactory_decodeFile, string);
- }
- if (localBitmap) {
- ret->width=(*jnienv)->CallIntMethod(jnienv, localBitmap, gra->Bitmap_getWidth);
- ret->height=(*jnienv)->CallIntMethod(jnienv, localBitmap, gra->Bitmap_getHeight);
- if((*w!=IMAGE_W_H_UNSET && *w!=ret->width) || (*h!=IMAGE_W_H_UNSET && *w!=ret->height)) {
- jclass scaledBitmap=(*jnienv)->CallStaticObjectMethod(jnienv, gra->BitmapClass,
- gra->Bitmap_createScaledBitmap, localBitmap, (*w==IMAGE_W_H_UNSET)?ret->width:*w, (*h==IMAGE_W_H_UNSET)?ret->height:*h, JNI_TRUE);
- if(!scaledBitmap) {
- dbg(lvl_error,"Bitmap scaling to %dx%d failed for %s",*w,*h,path);
- } else {
- (*jnienv)->DeleteLocalRef(jnienv, localBitmap);
- localBitmap=scaledBitmap;
- ret->width=(*jnienv)->CallIntMethod(jnienv, localBitmap, gra->Bitmap_getWidth);
- ret->height=(*jnienv)->CallIntMethod(jnienv, localBitmap, gra->Bitmap_getHeight);
- }
- }
- ret->Bitmap = (*jnienv)->NewGlobalRef(jnienv, localBitmap);
- (*jnienv)->DeleteLocalRef(jnienv, localBitmap);
-
- dbg(lvl_debug,"w=%d h=%d for %s\n",ret->width,ret->height,path);
- ret->hot.x=ret->width/2;
- ret->hot.y=ret->height/2;
- } else {
- g_free(ret);
- ret=NULL;
- dbg(lvl_warning,"Failed to open %s\n",path);
- }
- (*jnienv)->DeleteLocalRef(jnienv, string);
- if (ret) {
- *w=ret->width;
- *h=ret->height;
- if (hot)
- *hot=ret->hot;
- }
-
- return ret;
+static struct graphics_image_priv *image_new(struct graphics_priv *gra, struct graphics_image_methods *meth, char *path,
+ int *w, int *h, struct point *hot, int rotation) {
+ struct graphics_image_priv* ret = NULL;
+
+ ret=g_new0(struct graphics_image_priv, 1);
+ jstring string;
+ jclass localBitmap = NULL;
+ int id;
+
+ dbg(lvl_debug,"enter %s",path);
+ if (!strncmp(path,"res/drawable/",13)) {
+ jstring a=(*jnienv)->NewStringUTF(jnienv, "drawable");
+ char *path_noext=g_strdup(path+13);
+ char *pos=strrchr(path_noext, '.');
+ if (pos)
+ *pos='\0';
+ dbg(lvl_debug,"path_noext=%s",path_noext);
+ string = (*jnienv)->NewStringUTF(jnienv, path_noext);
+ g_free(path_noext);
+ id=(*jnienv)->CallIntMethod(jnienv, gra->Resources, gra->Resources_getIdentifier, string, a, gra->packageName);
+ dbg(lvl_debug,"id=%d",id);
+ if (id)
+ localBitmap=(*jnienv)->CallStaticObjectMethod(jnienv, gra->BitmapFactoryClass, gra->BitmapFactory_decodeResource,
+ gra->Resources, id);
+ (*jnienv)->DeleteLocalRef(jnienv, a);
+ } else {
+ string = (*jnienv)->NewStringUTF(jnienv, path);
+ localBitmap=(*jnienv)->CallStaticObjectMethod(jnienv, gra->BitmapFactoryClass, gra->BitmapFactory_decodeFile, string);
+ }
+ if (localBitmap) {
+ ret->width=(*jnienv)->CallIntMethod(jnienv, localBitmap, gra->Bitmap_getWidth);
+ ret->height=(*jnienv)->CallIntMethod(jnienv, localBitmap, gra->Bitmap_getHeight);
+ if((*w!=IMAGE_W_H_UNSET && *w!=ret->width) || (*h!=IMAGE_W_H_UNSET && *w!=ret->height)) {
+ jclass scaledBitmap=(*jnienv)->CallStaticObjectMethod(jnienv, gra->BitmapClass,
+ gra->Bitmap_createScaledBitmap, localBitmap, (*w==IMAGE_W_H_UNSET)?ret->width:*w, (*h==IMAGE_W_H_UNSET)?ret->height:*h,
+ JNI_TRUE);
+ if(!scaledBitmap) {
+ dbg(lvl_error,"Bitmap scaling to %dx%d failed for %s",*w,*h,path);
+ } else {
+ (*jnienv)->DeleteLocalRef(jnienv, localBitmap);
+ localBitmap=scaledBitmap;
+ ret->width=(*jnienv)->CallIntMethod(jnienv, localBitmap, gra->Bitmap_getWidth);
+ ret->height=(*jnienv)->CallIntMethod(jnienv, localBitmap, gra->Bitmap_getHeight);
+ }
+ }
+ ret->Bitmap = (*jnienv)->NewGlobalRef(jnienv, localBitmap);
+ (*jnienv)->DeleteLocalRef(jnienv, localBitmap);
+
+ dbg(lvl_debug,"w=%d h=%d for %s",ret->width,ret->height,path);
+ ret->hot.x=ret->width/2;
+ ret->hot.y=ret->height/2;
+ } else {
+ g_free(ret);
+ ret=NULL;
+ dbg(lvl_warning,"Failed to open %s",path);
+ }
+ (*jnienv)->DeleteLocalRef(jnienv, string);
+ if (ret) {
+ *w=ret->width;
+ *h=ret->height;
+ if (hot)
+ *hot=ret->hot;
+ }
+
+ return ret;
}
-static void initPaint(struct graphics_priv *gra, struct graphics_gc_priv *gc)
-{
+static void initPaint(struct graphics_priv *gra, struct graphics_gc_priv *gc) {
float wf = gc->linewidth;
(*jnienv)->CallVoidMethod(jnienv, gc->gra->Paint, gra->Paint_setStrokeWidth, wf);
(*jnienv)->CallVoidMethod(jnienv, gc->gra->Paint, gra->Paint_setARGB, gc->a, gc->r, gc->g, gc->b);
}
-static void
-draw_lines(struct graphics_priv *gra, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int arrsize=1+4+1+gc->ndashes+count*2;
- jint pc[arrsize];
- int i;
- jintArray points;
- if (count <= 0)
- return;
- points = (*jnienv)->NewIntArray(jnienv,arrsize);
- pc[0]=gc->linewidth;
- pc[1]=gc->a;
- pc[2]=gc->r;
- pc[3]=gc->g;
- pc[4]=gc->b;
- pc[5]=gc->ndashes;
- for (i = 0 ; i < gc->ndashes ; i++) {
- pc[6+i] = gc->dashes[i];
- }
- for (i = 0 ; i < count ; i++) {
- pc[6+gc->ndashes+i*2]=p[i].x;
- pc[6+gc->ndashes+i*2+1]=p[i].y;
- }
- (*jnienv)->SetIntArrayRegion(jnienv, points, 0, arrsize, pc);
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_polyline, gc->gra->Paint, points);
- (*jnienv)->DeleteLocalRef(jnienv, points);
+static void draw_lines(struct graphics_priv *gra, struct graphics_gc_priv *gc, struct point *p, int count) {
+ int arrsize=1+4+1+gc->ndashes+count*2;
+ jint pc[arrsize];
+ int i;
+ jintArray points;
+ if (count <= 0)
+ return;
+ points = (*jnienv)->NewIntArray(jnienv,arrsize);
+ pc[0]=gc->linewidth;
+ pc[1]=gc->a;
+ pc[2]=gc->r;
+ pc[3]=gc->g;
+ pc[4]=gc->b;
+ pc[5]=gc->ndashes;
+ for (i = 0 ; i < gc->ndashes ; i++) {
+ pc[6+i] = gc->dashes[i];
+ }
+ for (i = 0 ; i < count ; i++) {
+ pc[6+gc->ndashes+i*2]=p[i].x;
+ pc[6+gc->ndashes+i*2+1]=p[i].y;
+ }
+ (*jnienv)->SetIntArrayRegion(jnienv, points, 0, arrsize, pc);
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_polyline, gc->gra->Paint, points);
+ (*jnienv)->DeleteLocalRef(jnienv, points);
}
-static void
-draw_polygon(struct graphics_priv *gra, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int arrsize=1+4+count*2;
- jint pc[arrsize];
- int i;
- jintArray points;
- if (count <= 0)
- return;
- points = (*jnienv)->NewIntArray(jnienv,arrsize);
- for (i = 0 ; i < count ; i++) {
- pc[5+i*2]=p[i].x;
- pc[5+i*2+1]=p[i].y;
- }
- pc[0]=gc->linewidth;
- pc[1]=gc->a;
- pc[2]=gc->r;
- pc[3]=gc->g;
- pc[4]=gc->b;
- (*jnienv)->SetIntArrayRegion(jnienv, points, 0, arrsize, pc);
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_polygon, gc->gra->Paint, points);
- (*jnienv)->DeleteLocalRef(jnienv, points);
+static void draw_polygon(struct graphics_priv *gra, struct graphics_gc_priv *gc, struct point *p, int count) {
+ int arrsize=1+4+count*2;
+ jint pc[arrsize];
+ int i;
+ jintArray points;
+ if (count <= 0)
+ return;
+ points = (*jnienv)->NewIntArray(jnienv,arrsize);
+ for (i = 0 ; i < count ; i++) {
+ pc[5+i*2]=p[i].x;
+ pc[5+i*2+1]=p[i].y;
+ }
+ pc[0]=gc->linewidth;
+ pc[1]=gc->a;
+ pc[2]=gc->r;
+ pc[3]=gc->g;
+ pc[4]=gc->b;
+ (*jnienv)->SetIntArrayRegion(jnienv, points, 0, arrsize, pc);
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_polygon, gc->gra->Paint, points);
+ (*jnienv)->DeleteLocalRef(jnienv, points);
}
-static void
-draw_rectangle(struct graphics_priv *gra, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
- initPaint(gra, gc);
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_rectangle, gc->gra->Paint, p->x, p->y, w, h);
+static void draw_rectangle(struct graphics_priv *gra, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
+ initPaint(gra, gc);
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_rectangle, gc->gra->Paint, p->x, p->y, w,
+ h);
}
-static void
-draw_circle(struct graphics_priv *gra, struct graphics_gc_priv *gc, struct point *p, int r)
-{
- initPaint(gra, gc);
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_circle, gc->gra->Paint, p->x, p->y, r);
+static void draw_circle(struct graphics_priv *gra, struct graphics_gc_priv *gc, struct point *p, int r) {
+ initPaint(gra, gc);
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_circle, gc->gra->Paint, p->x, p->y, r);
}
-static void
-draw_text(struct graphics_priv *gra, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
- int bgcolor=0;
- dbg(lvl_debug,"enter %s\n", text);
- initPaint(gra, fg);
- if(bg)
- bgcolor=(bg->a<<24)| (bg->r<<16) | (bg->g<<8) | bg->b;
- jstring string = (*jnienv)->NewStringUTF(jnienv, text);
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_text, fg->gra->Paint, p->x, p->y, string, font->size, dx, dy, bgcolor);
- (*jnienv)->DeleteLocalRef(jnienv, string);
+static void draw_text(struct graphics_priv *gra, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg,
+ struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
+ int bgcolor=0;
+ dbg(lvl_debug,"enter %s", text);
+ initPaint(gra, fg);
+ if(bg)
+ bgcolor=(bg->a<<24)| (bg->r<<16) | (bg->g<<8) | bg->b;
+ jstring string = (*jnienv)->NewStringUTF(jnienv, text);
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_text, fg->gra->Paint, p->x, p->y, string,
+ font->size, dx, dy, bgcolor);
+ (*jnienv)->DeleteLocalRef(jnienv, string);
}
-static void
-draw_image(struct graphics_priv *gra, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
- dbg(lvl_debug,"enter %p\n",img);
- initPaint(gra, fg);
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_image, fg->gra->Paint, p->x, p->y, img->Bitmap);
-
+static void draw_image(struct graphics_priv *gra, struct graphics_gc_priv *fg, struct point *p,
+ struct graphics_image_priv *img) {
+ dbg(lvl_debug,"enter %p",img);
+ initPaint(gra, fg);
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_image, fg->gra->Paint, p->x, p->y,
+ img->Bitmap);
+
}
-static void
-draw_image_warp (struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, struct graphics_image_priv *img)
-{
-
- /*
- *
- *
- * if coord count==3 then top.left top.right bottom.left
- *
- */
-
- if (count==3)
- {
- initPaint(gr, fg);
- (*jnienv)->CallVoidMethod(jnienv, gr->NavitGraphics, gr->NavitGraphics_draw_image_warp, fg->gra->Paint,
- count, p[0].x, p[0].y,p[1].x, p[1].y, p[2].x, p[2].y, img->Bitmap);
- } else
- dbg(lvl_debug,"draw_image_warp is called with unsupported count parameter value %d\n", count);
+static void draw_image_warp (struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count,
+ struct graphics_image_priv *img) {
+
+ /*
+ *
+ *
+ * if coord count==3 then top.left top.right bottom.left
+ *
+ */
+
+ if (count==3) {
+ initPaint(gr, fg);
+ (*jnienv)->CallVoidMethod(jnienv, gr->NavitGraphics, gr->NavitGraphics_draw_image_warp, fg->gra->Paint, count,
+ p[0].x, p[0].y,p[1].x, p[1].y, p[2].x, p[2].y, img->Bitmap);
+ } else
+ dbg(lvl_debug,"draw_image_warp is called with unsupported count parameter value %d", count);
}
-static void draw_drag(struct graphics_priv *gra, struct point *p)
-{
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_drag, p ? p->x : 0, p ? p->y : 0);
+static void draw_drag(struct graphics_priv *gra, struct point *p) {
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_drag, p ? p->x : 0, p ? p->y : 0);
}
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
+static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
}
-static void
-draw_mode(struct graphics_priv *gra, enum draw_mode_num mode)
-{
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_mode, (int)mode);
+static void draw_mode(struct graphics_priv *gra, enum draw_mode_num mode) {
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_draw_mode, (int)mode);
}
-static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound);
+static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p,
+ int w, int h, int wraparound);
-static void *
-get_data(struct graphics_priv *this, const char *type)
-{
- if (!strcmp(type,"padding"))
- return this->padding;
- if (!strcmp(type,"window"))
- return &this->win;
- return NULL;
+static void *get_data(struct graphics_priv *this, const char *type) {
+ if (!strcmp(type,"padding"))
+ return this->padding;
+ if (!strcmp(type,"window"))
+ return &this->win;
+ return NULL;
}
-static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
-{
+static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv) {
}
-static void get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate)
-{
- int len = g_utf8_strlen(text, -1);
- int xMin = 0;
- int yMin = 0;
- int yMax = 13*font->size/256;
- int xMax = 9*font->size*len/256;
-
- ret[0].x = xMin;
- ret[0].y = -yMin;
- ret[1].x = xMin;
- ret[1].y = -yMax;
- ret[2].x = xMax;
- ret[2].y = -yMax;
- ret[3].x = xMax;
- ret[3].y = -yMin;
+static void get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy,
+ struct point *ret, int estimate) {
+ int len = g_utf8_strlen(text, -1);
+ int xMin = 0;
+ int yMin = 0;
+ int yMax = 13*font->size/256;
+ int xMax = 9*font->size*len/256;
+
+ ret[0].x = xMin;
+ ret[0].y = -yMin;
+ ret[1].x = xMin;
+ ret[1].y = -yMax;
+ ret[2].x = xMax;
+ ret[2].y = -yMax;
+ ret[3].x = xMax;
+ ret[3].y = -yMin;
}
-static void overlay_disable(struct graphics_priv *gra, int disable)
-{
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_overlay_disable, disable);
+static void overlay_disable(struct graphics_priv *gra, int disable) {
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_overlay_disable, disable);
}
-static void overlay_resize(struct graphics_priv *gra, struct point *pnt, int w, int h, int wraparound)
-{
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_overlay_resize, pnt ? pnt->x:0 , pnt ? pnt->y:0, w, h, wraparound);
+static void overlay_resize(struct graphics_priv *gra, struct point *pnt, int w, int h, int wraparound) {
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_overlay_resize, pnt ? pnt->x:0, pnt ? pnt->y:0,
+ w, h, wraparound);
}
-static int
-set_attr(struct graphics_priv *gra, struct attr *attr)
-{
- switch (attr->type) {
- case attr_use_camera:
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_SetCamera, attr->u.num);
- return 1;
- case attr_background_color:
- gra->bgcolor = (attr->u.color->a / 0x101) << 24
- | (attr->u.color->r / 0x101) << 16
- | (attr->u.color->g / 0x101) << 8
- | (attr->u.color->b / 0x101);
- dbg(lvl_debug, "set attr_background_color %04x %04x %04x %04x (%08x)\n",
- attr->u.color->r, attr->u.color->g, attr->u.color->b, attr->u.color->a, gra->bgcolor);
- if (gra->NavitGraphics_setBackgroundColor != NULL)
- (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_setBackgroundColor, gra->bgcolor);
- else
- dbg(lvl_error, "NavitGraphics.setBackgroundColor not found, cannot set background color\n");
- return 1;
- default:
- return 0;
- }
+static int set_attr(struct graphics_priv *gra, struct attr *attr) {
+ switch (attr->type) {
+ case attr_use_camera:
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_SetCamera, attr->u.num);
+ return 1;
+ case attr_background_color:
+ gra->bgcolor = (attr->u.color->a / 0x101) << 24
+ | (attr->u.color->r / 0x101) << 16
+ | (attr->u.color->g / 0x101) << 8
+ | (attr->u.color->b / 0x101);
+ dbg(lvl_debug, "set attr_background_color %04x %04x %04x %04x (%08x)",
+ attr->u.color->r, attr->u.color->g, attr->u.color->b, attr->u.color->a, gra->bgcolor);
+ if (gra->NavitGraphics_setBackgroundColor != NULL)
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_setBackgroundColor, gra->bgcolor);
+ else
+ dbg(lvl_error, "NavitGraphics.setBackgroundColor not found, cannot set background color");
+ return 1;
+ default:
+ return 0;
+ }
}
@@ -492,97 +452,85 @@ void hide_native_keyboard (struct graphics_keyboard *kbd);
static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
- draw_image_warp,
- draw_drag,
- font_new,
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- image_free,
- get_text_bbox,
- overlay_disable,
- overlay_resize,
- set_attr,
- show_native_keyboard,
- hide_native_keyboard,
+ graphics_destroy,
+ draw_mode,
+ draw_lines,
+ draw_polygon,
+ draw_rectangle,
+ draw_circle,
+ draw_text,
+ draw_image,
+ draw_image_warp,
+ draw_drag,
+ font_new,
+ gc_new,
+ background_gc,
+ overlay_new,
+ image_new,
+ get_data,
+ image_free,
+ get_text_bbox,
+ overlay_disable,
+ overlay_resize,
+ set_attr,
+ show_native_keyboard,
+ hide_native_keyboard,
};
-static void
-resize_callback(struct graphics_priv *gra, int w, int h)
-{
- dbg(lvl_debug,"w=%d h=%d ok\n",w,h);
- dbg(lvl_debug,"gra=%p, %d callbacks in list\n", gra, g_list_length(gra->cbl));
- callback_list_call_attr_2(gra->cbl, attr_resize, (void *)w, (void *)h);
+static void resize_callback(struct graphics_priv *gra, int w, int h) {
+ dbg(lvl_debug,"w=%d h=%d ok",w,h);
+ dbg(lvl_debug,"gra=%p, %d callbacks in list", gra, g_list_length(gra->cbl));
+ callback_list_call_attr_2(gra->cbl, attr_resize, (void *)w, (void *)h);
}
-static void
-padding_callback(struct graphics_priv *gra, int left, int top, int right, int bottom)
-{
- dbg(lvl_debug, "win.padding left=%d top=%d right=%d bottom=%d ok\n", left, top, right, bottom);
- gra->padding->left = left;
- gra->padding->top = top;
- gra->padding->right = right;
- gra->padding->bottom = bottom;
+static void padding_callback(struct graphics_priv *gra, int left, int top, int right, int bottom) {
+ dbg(lvl_debug, "win.padding left=%d top=%d right=%d bottom=%d ok", left, top, right, bottom);
+ gra->padding->left = left;
+ gra->padding->top = top;
+ gra->padding->right = right;
+ gra->padding->bottom = bottom;
}
-static void
-motion_callback(struct graphics_priv *gra, int x, int y)
-{
- struct point p;
- p.x=x;
- p.y=y;
- callback_list_call_attr_1(gra->cbl, attr_motion, (void *)&p);
+static void motion_callback(struct graphics_priv *gra, int x, int y) {
+ struct point p;
+ p.x=x;
+ p.y=y;
+ callback_list_call_attr_1(gra->cbl, attr_motion, (void *)&p);
}
-static void
-keypress_callback(struct graphics_priv *gra, char *s)
-{
- dbg(lvl_debug,"enter %s\n",s);
- callback_list_call_attr_1(gra->cbl, attr_keypress, s);
+static void keypress_callback(struct graphics_priv *gra, char *s) {
+ dbg(lvl_debug,"enter %s",s);
+ callback_list_call_attr_1(gra->cbl, attr_keypress, s);
}
-static void
-button_callback(struct graphics_priv *gra, int pressed, int button, int x, int y)
-{
- struct point p;
- p.x=x;
- p.y=y;
- callback_list_call_attr_3(gra->cbl, attr_button, (void *)pressed, (void *)button, (void *)&p);
+static void button_callback(struct graphics_priv *gra, int pressed, int button, int x, int y) {
+ struct point p;
+ p.x=x;
+ p.y=y;
+ callback_list_call_attr_3(gra->cbl, attr_button, (void *)pressed, (void *)button, (void *)&p);
}
-static int
-set_activity(jobject graphics)
-{
- jclass ActivityClass;
- jmethodID cid;
-
- ActivityClass = (*jnienv)->GetObjectClass(jnienv, android_activity);
- dbg(lvl_debug,"at 5\n");
- if (ActivityClass == NULL) {
- dbg(lvl_debug,"no activity class found\n");
- return 0;
- }
- dbg(lvl_debug,"at 6\n");
- cid = (*jnienv)->GetMethodID(jnienv, ActivityClass, "setContentView", "(Landroid/view/View;)V");
- if (cid == NULL) {
- dbg(lvl_error,"no setContentView method found\n");
- return 0;
- }
- dbg(lvl_debug,"at 7\n");
- (*jnienv)->CallVoidMethod(jnienv, android_activity, cid, graphics);
- dbg(lvl_debug,"at 8\n");
- return 1;
+static int set_activity(jobject graphics) {
+ jclass ActivityClass;
+ jmethodID cid;
+
+ ActivityClass = (*jnienv)->GetObjectClass(jnienv, android_activity);
+ dbg(lvl_debug,"at 5");
+ if (ActivityClass == NULL) {
+ dbg(lvl_debug,"no activity class found");
+ return 0;
+ }
+ dbg(lvl_debug,"at 6");
+ cid = (*jnienv)->GetMethodID(jnienv, ActivityClass, "setContentView", "(Landroid/view/View;)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no setContentView method found");
+ return 0;
+ }
+ dbg(lvl_debug,"at 7");
+ (*jnienv)->CallVoidMethod(jnienv, android_activity, cid, graphics);
+ dbg(lvl_debug,"at 8");
+ return 1;
}
/**
@@ -598,167 +546,176 @@ set_activity(jobject graphics)
* @param wraparound (0 for the main view)
* @param use_camera Whether to use the camera (0 for overlays)
*/
-static int
-graphics_android_init(struct graphics_priv *ret, struct graphics_priv *parent, struct point *pnt, int w, int h, int wraparound, int use_camera)
-{
- struct callback *cb;
- jmethodID cid, Context_getPackageName;
-
- dbg(lvl_debug,"at 2 jnienv=%p\n",jnienv);
- if (parent)
- ret->padding = parent->padding;
- if (!find_class_global("android/graphics/Paint", &ret->PaintClass))
- return 0;
- if (!find_method(ret->PaintClass, "<init>", "(I)V", &ret->Paint_init))
- return 0;
- if (!find_method(ret->PaintClass, "setARGB", "(IIII)V", &ret->Paint_setARGB))
- return 0;
- if (!find_method(ret->PaintClass, "setStrokeWidth", "(F)V", &ret->Paint_setStrokeWidth))
- return 0;
-
- if (!find_class_global("android/graphics/BitmapFactory", &ret->BitmapFactoryClass))
- return 0;
- if (!find_static_method(ret->BitmapFactoryClass, "decodeFile", "(Ljava/lang/String;)Landroid/graphics/Bitmap;", &ret->BitmapFactory_decodeFile))
- return 0;
- if (!find_static_method(ret->BitmapFactoryClass, "decodeResource", "(Landroid/content/res/Resources;I)Landroid/graphics/Bitmap;", &ret->BitmapFactory_decodeResource))
- return 0;
-
- if (!find_class_global("android/graphics/Bitmap", &ret->BitmapClass))
- return 0;
- if (!find_method(ret->BitmapClass, "getHeight", "()I", &ret->Bitmap_getHeight))
- return 0;
- if (!find_method(ret->BitmapClass, "getWidth", "()I", &ret->Bitmap_getWidth))
- return 0;
- if (!find_static_method(ret->BitmapClass, "createScaledBitmap", "(Landroid/graphics/Bitmap;IIZ)Landroid/graphics/Bitmap;", &ret->Bitmap_createScaledBitmap))
- return 0;
-
- if (!find_class_global("android/content/Context", &ret->ContextClass))
- return 0;
- if (!find_method(ret->ContextClass, "getResources", "()Landroid/content/res/Resources;", &ret->Context_getResources))
- return 0;
-
-
- ret->Resources=(*jnienv)->CallObjectMethod(jnienv, android_activity, ret->Context_getResources);
- if (ret->Resources)
- ret->Resources = (*jnienv)->NewGlobalRef(jnienv, ret->Resources);
- if (!find_class_global("android/content/res/Resources", &ret->ResourcesClass))
- return 0;
- if (!find_method(ret->ResourcesClass, "getIdentifier", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", &ret->Resources_getIdentifier))
- return 0;
-
- if (!find_method(ret->ContextClass, "getPackageName", "()Ljava/lang/String;", &Context_getPackageName))
- return 0;
- ret->packageName=(*jnienv)->CallObjectMethod(jnienv, android_activity, Context_getPackageName);
- ret->packageName=(*jnienv)->NewGlobalRef(jnienv, ret->packageName);
-
- if (!find_class_global("org/navitproject/navit/NavitGraphics", &ret->NavitGraphicsClass))
- return 0;
- dbg(lvl_debug,"at 3\n");
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "<init>", "(Landroid/app/Activity;Lorg/navitproject/navit/NavitGraphics;IIIIII)V");
- if (cid == NULL) {
- dbg(lvl_error,"no method found\n");
- return 0; /* exception thrown */
- }
- dbg(lvl_debug,"at 4 android_activity=%p\n",android_activity);
- ret->NavitGraphics=(*jnienv)->NewObject(jnienv, ret->NavitGraphicsClass, cid, android_activity, parent ? parent->NavitGraphics : NULL, pnt ? pnt->x:0 , pnt ? pnt->y:0, w, h, wraparound, use_camera);
- dbg(lvl_debug,"result=%p\n",ret->NavitGraphics);
- if (ret->NavitGraphics)
- ret->NavitGraphics = (*jnienv)->NewGlobalRef(jnienv, ret->NavitGraphics);
-
- /* Create a single global Paint, otherwise android will quickly run out
- * of global refs.*/
- /* 0x101 = text kerning (default), antialiasing */
- ret->Paint=(*jnienv)->NewObject(jnienv, ret->PaintClass, ret->Paint_init, 0x101);
-
- dbg(lvl_debug,"result=%p\n",ret->Paint);
- if (ret->Paint)
- ret->Paint = (*jnienv)->NewGlobalRef(jnienv, ret->Paint);
-
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setSizeChangedCallback", "(I)V");
- if (cid == NULL) {
- dbg(lvl_error,"no SetResizeCallback method found\n");
- return 0; /* exception thrown */
- }
- cb=callback_new_1(callback_cast(resize_callback), ret);
- (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
-
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setPaddingChangedCallback", "(I)V");
- if (cid == NULL) {
- dbg(lvl_error,"no SetPaddingCallback method found\n");
- return 0; /* exception thrown */
- }
- cb=callback_new_1(callback_cast(padding_callback), ret);
- (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
-
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setButtonCallback", "(I)V");
- if (cid == NULL) {
- dbg(lvl_error,"no SetButtonCallback method found\n");
- return 0; /* exception thrown */
- }
- cb=callback_new_1(callback_cast(button_callback), ret);
- (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
-
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setMotionCallback", "(I)V");
- if (cid == NULL) {
- dbg(lvl_error,"no SetMotionCallback method found\n");
- return 0; /* exception thrown */
- }
- cb=callback_new_1(callback_cast(motion_callback), ret);
- (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
-
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setKeypressCallback", "(I)V");
- if (cid == NULL) {
- dbg(lvl_error,"no SetKeypressCallback method found\n");
- return 0; /* exception thrown */
- }
- cb=callback_new_1(callback_cast(keypress_callback), ret);
- (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
-
- if (!find_method(ret->NavitGraphicsClass, "draw_polyline", "(Landroid/graphics/Paint;[I)V", &ret->NavitGraphics_draw_polyline))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "draw_polygon", "(Landroid/graphics/Paint;[I)V", &ret->NavitGraphics_draw_polygon))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "draw_rectangle", "(Landroid/graphics/Paint;IIII)V", &ret->NavitGraphics_draw_rectangle))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "draw_circle", "(Landroid/graphics/Paint;III)V", &ret->NavitGraphics_draw_circle))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "draw_text", "(Landroid/graphics/Paint;IILjava/lang/String;IIII)V", &ret->NavitGraphics_draw_text))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "draw_image", "(Landroid/graphics/Paint;IILandroid/graphics/Bitmap;)V", &ret->NavitGraphics_draw_image))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "draw_image_warp", "(Landroid/graphics/Paint;IIIIIIILandroid/graphics/Bitmap;)V", &ret->NavitGraphics_draw_image_warp))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "draw_mode", "(I)V", &ret->NavitGraphics_draw_mode))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "draw_drag", "(II)V", &ret->NavitGraphics_draw_drag))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "overlay_disable", "(I)V", &ret->NavitGraphics_overlay_disable))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "overlay_resize", "(IIIII)V", &ret->NavitGraphics_overlay_resize))
- return 0;
- if (!find_method(ret->NavitGraphicsClass, "SetCamera", "(I)V", &ret->NavitGraphics_SetCamera))
- return 0;
+static int graphics_android_init(struct graphics_priv *ret, struct graphics_priv *parent, struct point *pnt, int w,
+ int h, int wraparound, int use_camera) {
+ struct callback *cb;
+ jmethodID cid, Context_getPackageName;
+
+ dbg(lvl_debug,"at 2 jnienv=%p",jnienv);
+ if (parent)
+ ret->padding = parent->padding;
+ if (!find_class_global("android/graphics/Paint", &ret->PaintClass))
+ return 0;
+ if (!find_method(ret->PaintClass, "<init>", "(I)V", &ret->Paint_init))
+ return 0;
+ if (!find_method(ret->PaintClass, "setARGB", "(IIII)V", &ret->Paint_setARGB))
+ return 0;
+ if (!find_method(ret->PaintClass, "setStrokeWidth", "(F)V", &ret->Paint_setStrokeWidth))
+ return 0;
+
+ if (!find_class_global("android/graphics/BitmapFactory", &ret->BitmapFactoryClass))
+ return 0;
+ if (!find_static_method(ret->BitmapFactoryClass, "decodeFile", "(Ljava/lang/String;)Landroid/graphics/Bitmap;",
+ &ret->BitmapFactory_decodeFile))
+ return 0;
+ if (!find_static_method(ret->BitmapFactoryClass, "decodeResource",
+ "(Landroid/content/res/Resources;I)Landroid/graphics/Bitmap;", &ret->BitmapFactory_decodeResource))
+ return 0;
+
+ if (!find_class_global("android/graphics/Bitmap", &ret->BitmapClass))
+ return 0;
+ if (!find_method(ret->BitmapClass, "getHeight", "()I", &ret->Bitmap_getHeight))
+ return 0;
+ if (!find_method(ret->BitmapClass, "getWidth", "()I", &ret->Bitmap_getWidth))
+ return 0;
+ if (!find_static_method(ret->BitmapClass, "createScaledBitmap",
+ "(Landroid/graphics/Bitmap;IIZ)Landroid/graphics/Bitmap;", &ret->Bitmap_createScaledBitmap))
+ return 0;
+
+ if (!find_class_global("android/content/Context", &ret->ContextClass))
+ return 0;
+ if (!find_method(ret->ContextClass, "getResources", "()Landroid/content/res/Resources;", &ret->Context_getResources))
+ return 0;
+
+
+ ret->Resources=(*jnienv)->CallObjectMethod(jnienv, android_activity, ret->Context_getResources);
+ if (ret->Resources)
+ ret->Resources = (*jnienv)->NewGlobalRef(jnienv, ret->Resources);
+ if (!find_class_global("android/content/res/Resources", &ret->ResourcesClass))
+ return 0;
+ if (!find_method(ret->ResourcesClass, "getIdentifier", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
+ &ret->Resources_getIdentifier))
+ return 0;
+
+ if (!find_method(ret->ContextClass, "getPackageName", "()Ljava/lang/String;", &Context_getPackageName))
+ return 0;
+ ret->packageName=(*jnienv)->CallObjectMethod(jnienv, android_activity, Context_getPackageName);
+ ret->packageName=(*jnienv)->NewGlobalRef(jnienv, ret->packageName);
+
+ if (!find_class_global("org/navitproject/navit/NavitGraphics", &ret->NavitGraphicsClass))
+ return 0;
+ dbg(lvl_debug,"at 3");
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "<init>",
+ "(Landroid/app/Activity;Lorg/navitproject/navit/NavitGraphics;IIIIII)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no method found");
+ return 0; /* exception thrown */
+ }
+ dbg(lvl_debug,"at 4 android_activity=%p",android_activity);
+ ret->NavitGraphics=(*jnienv)->NewObject(jnienv, ret->NavitGraphicsClass, cid, android_activity,
+ parent ? parent->NavitGraphics : NULL, pnt ? pnt->x:0, pnt ? pnt->y:0, w, h, wraparound, use_camera);
+ dbg(lvl_debug,"result=%p",ret->NavitGraphics);
+ if (ret->NavitGraphics)
+ ret->NavitGraphics = (*jnienv)->NewGlobalRef(jnienv, ret->NavitGraphics);
+
+ /* Create a single global Paint, otherwise android will quickly run out
+ * of global refs.*/
+ /* 0x101 = text kerning (default), antialiasing */
+ ret->Paint=(*jnienv)->NewObject(jnienv, ret->PaintClass, ret->Paint_init, 0x101);
+
+ dbg(lvl_debug,"result=%p",ret->Paint);
+ if (ret->Paint)
+ ret->Paint = (*jnienv)->NewGlobalRef(jnienv, ret->Paint);
+
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setSizeChangedCallback", "(I)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no SetResizeCallback method found");
+ return 0; /* exception thrown */
+ }
+ cb=callback_new_1(callback_cast(resize_callback), ret);
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
+
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setPaddingChangedCallback", "(I)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no SetPaddingCallback method found");
+ return 0; /* exception thrown */
+ }
+ cb=callback_new_1(callback_cast(padding_callback), ret);
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
+
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setButtonCallback", "(I)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no SetButtonCallback method found");
+ return 0; /* exception thrown */
+ }
+ cb=callback_new_1(callback_cast(button_callback), ret);
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
+
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setMotionCallback", "(I)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no SetMotionCallback method found");
+ return 0; /* exception thrown */
+ }
+ cb=callback_new_1(callback_cast(motion_callback), ret);
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
+
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setKeypressCallback", "(I)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no SetKeypressCallback method found");
+ return 0; /* exception thrown */
+ }
+ cb=callback_new_1(callback_cast(keypress_callback), ret);
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, cid, (int)cb);
+
+ if (!find_method(ret->NavitGraphicsClass, "draw_polyline", "(Landroid/graphics/Paint;[I)V",
+ &ret->NavitGraphics_draw_polyline))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "draw_polygon", "(Landroid/graphics/Paint;[I)V",
+ &ret->NavitGraphics_draw_polygon))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "draw_rectangle", "(Landroid/graphics/Paint;IIII)V",
+ &ret->NavitGraphics_draw_rectangle))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "draw_circle", "(Landroid/graphics/Paint;III)V",
+ &ret->NavitGraphics_draw_circle))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "draw_text", "(Landroid/graphics/Paint;IILjava/lang/String;IIII)V",
+ &ret->NavitGraphics_draw_text))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "draw_image", "(Landroid/graphics/Paint;IILandroid/graphics/Bitmap;)V",
+ &ret->NavitGraphics_draw_image))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "draw_image_warp",
+ "(Landroid/graphics/Paint;IIIIIIILandroid/graphics/Bitmap;)V", &ret->NavitGraphics_draw_image_warp))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "draw_mode", "(I)V", &ret->NavitGraphics_draw_mode))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "draw_drag", "(II)V", &ret->NavitGraphics_draw_drag))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "overlay_disable", "(I)V", &ret->NavitGraphics_overlay_disable))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "overlay_resize", "(IIIII)V", &ret->NavitGraphics_overlay_resize))
+ return 0;
+ if (!find_method(ret->NavitGraphicsClass, "SetCamera", "(I)V", &ret->NavitGraphics_SetCamera))
+ return 0;
#if 0
- set_activity(ret->NavitGraphics);
+ set_activity(ret->NavitGraphics);
#endif
- return 1;
+ return 1;
}
static jclass NavitClass;
-static jmethodID Navit_disableSuspend, Navit_exit, Navit_fullscreen, Navit_runOptionsItem, Navit_showMenu, Navit_showNativeKeyboard, Navit_hideNativeKeyboard;
+static jmethodID Navit_disableSuspend, Navit_exit, Navit_fullscreen, Navit_runOptionsItem, Navit_showMenu,
+ Navit_showNativeKeyboard, Navit_hideNativeKeyboard;
-static int
-graphics_android_fullscreen(struct window *win, int on)
-{
- (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_fullscreen, on);
- return 1;
+static int graphics_android_fullscreen(struct window *win, int on) {
+ (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_fullscreen, on);
+ return 1;
}
-static void
-graphics_android_disable_suspend(struct window *win)
-{
- dbg(lvl_debug,"enter\n");
- (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_disableSuspend);
+static void graphics_android_disable_suspend(struct window *win) {
+ dbg(lvl_debug,"enter");
+ (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_disableSuspend);
}
/**
@@ -772,19 +729,18 @@ graphics_android_disable_suspend(struct window *win)
* @param out Points to a buffer which will receive a pointer to the output of the command
* @param valid
*/
-static void
-graphics_android_cmd_runMenuItem(struct graphics_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- int ncmd=0;
- dbg(0,"Running %s\n",function);
- if(!strcmp(function,"map_download_dialog")) {
- ncmd=3;
- } else if(!strcmp(function,"backup_restore_dialog")) {
- ncmd=7;
- } else if(!strcmp(function,"set_map_location")) {
- ncmd=10;
- }
- (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_runOptionsItem, ncmd);
+static void graphics_android_cmd_runMenuItem(struct graphics_priv *this, char *function, struct attr **in,
+ struct attr ***out, int *valid) {
+ int ncmd=0;
+ dbg(0,"Running %s",function);
+ if(!strcmp(function,"map_download_dialog")) {
+ ncmd=3;
+ } else if(!strcmp(function,"backup_restore_dialog")) {
+ ncmd=7;
+ } else if(!strcmp(function,"set_map_location")) {
+ ncmd=10;
+ }
+ (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_runOptionsItem, ncmd);
}
/**
@@ -798,11 +754,10 @@ graphics_android_cmd_runMenuItem(struct graphics_priv *this, char *function, str
* @param out Points to a buffer which will receive a pointer to the output of the command
* @param valid
*/
-static void
-graphics_android_cmd_menu(struct graphics_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- dbg(lvl_debug, "enter\n");
- (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_showMenu);
+static void graphics_android_cmd_menu(struct graphics_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ dbg(lvl_debug, "enter");
+ (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_showMenu);
}
/**
@@ -810,10 +765,10 @@ graphics_android_cmd_menu(struct graphics_priv *this, char *function, struct att
* this command.
*/
static struct command_table commands[] = {
- {"map_download_dialog",command_cast(graphics_android_cmd_runMenuItem)},
- {"set_map_location",command_cast(graphics_android_cmd_runMenuItem)},
- {"backup_restore_dialog",command_cast(graphics_android_cmd_runMenuItem)},
- {"menu", command_cast(graphics_android_cmd_menu)},
+ {"map_download_dialog",command_cast(graphics_android_cmd_runMenuItem)},
+ {"set_map_location",command_cast(graphics_android_cmd_runMenuItem)},
+ {"backup_restore_dialog",command_cast(graphics_android_cmd_runMenuItem)},
+ {"menu", command_cast(graphics_android_cmd_menu)},
};
/**
@@ -829,76 +784,76 @@ static struct command_table commands[] = {
*
* @return The new graphics instance
*/
-static struct graphics_priv *
-graphics_android_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct graphics_priv *ret;
- struct attr *attr;
- int use_camera=0;
- jmethodID cid;
- jint android_bgcolor;
-
- dbg(lvl_debug, "enter\n");
- if (!event_request_system("android","graphics_android"))
- return NULL;
- ret=g_new0(struct graphics_priv, 1);
-
- ret->cbl=cbl;
- *meth=graphics_methods;
- ret->win.priv=ret;
- ret->win.fullscreen=graphics_android_fullscreen;
- ret->win.disable_suspend=graphics_android_disable_suspend;
- ret->padding = g_new0(struct padding, 1);
- ret->padding->left = 0;
- ret->padding->top = 0;
- ret->padding->right = 0;
- ret->padding->bottom = 0;
- /* attr_background_color is the background color for system bars (API 17+ only) */
- if ((attr=attr_search(attrs, NULL, attr_background_color))) {
- ret->bgcolor = (attr->u.color->a / 0x101) << 24
- | (attr->u.color->r / 0x101) << 16
- | (attr->u.color->g / 0x101) << 8
- | (attr->u.color->b / 0x101);
- dbg(lvl_debug, "attr_background_color %04x %04x %04x %04x (%08x)\n",
- attr->u.color->r, attr->u.color->g, attr->u.color->b, attr->u.color->a, ret->bgcolor);
- } else {
- /* default is the same as for OSD */
- ret->bgcolor = 0x60000000;
- }
- if ((attr=attr_search(attrs, NULL, attr_use_camera))) {
- use_camera=attr->u.num;
- }
- if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
- command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), ret);
+static struct graphics_priv *graphics_android_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs,
+ struct callback_list *cbl) {
+ struct graphics_priv *ret;
+ struct attr *attr;
+ int use_camera=0;
+ jmethodID cid;
+ jint android_bgcolor;
+
+ dbg(lvl_debug, "enter");
+ if (!event_request_system("android","graphics_android"))
+ return NULL;
+ ret=g_new0(struct graphics_priv, 1);
+
+ ret->cbl=cbl;
+ *meth=graphics_methods;
+ ret->win.priv=ret;
+ ret->win.fullscreen=graphics_android_fullscreen;
+ ret->win.disable_suspend=graphics_android_disable_suspend;
+ ret->padding = g_new0(struct padding, 1);
+ ret->padding->left = 0;
+ ret->padding->top = 0;
+ ret->padding->right = 0;
+ ret->padding->bottom = 0;
+ /* attr_background_color is the background color for system bars (API 17+ only) */
+ if ((attr=attr_search(attrs, NULL, attr_background_color))) {
+ ret->bgcolor = (attr->u.color->a / 0x101) << 24
+ | (attr->u.color->r / 0x101) << 16
+ | (attr->u.color->g / 0x101) << 8
+ | (attr->u.color->b / 0x101);
+ dbg(lvl_debug, "attr_background_color %04x %04x %04x %04x (%08x)",
+ attr->u.color->r, attr->u.color->g, attr->u.color->b, attr->u.color->a, ret->bgcolor);
+ } else {
+ /* default is the same as for OSD */
+ ret->bgcolor = 0xa0000000;
+ }
+ if ((attr=attr_search(attrs, NULL, attr_use_camera))) {
+ use_camera=attr->u.num;
+ }
+ if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
+ command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), ret);
+ }
+ image_cache_hash = g_hash_table_new(g_str_hash, g_str_equal);
+ if (graphics_android_init(ret, NULL, NULL, 0, 0, 0, use_camera)) {
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "hasMenuButton", "()Z");
+ if (cid != NULL) {
+ attr = g_new0(struct attr, 1);
+ attr->type = attr_has_menu_button;
+ attr->u.num = (*jnienv)->CallBooleanMethod(jnienv, ret->NavitGraphics, cid);
+
+ /*
+ * Although the attribute refers to information obtained by the graphics plugin, we are storing it
+ * with the navit object: the object is easier to access from anywhere in the program, and ultimately
+ * it refers to a configuration value affecting all of Navit, thus users are likely to look for it in
+ * the navit object (as the fact that graphics also handles input devices is not immedately obvious).
+ */
+ navit_object_set_attr((struct navit_object *) nav, attr);
+ dbg(lvl_debug, "attr_has_menu_button=%d", attr->u.num);
+ g_free(attr);
+ }
+ ret->NavitGraphics_setBackgroundColor = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setBackgroundColor",
+ "(I)V");
+ if (ret->NavitGraphics_setBackgroundColor != NULL) {
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, ret->NavitGraphics_setBackgroundColor, ret->bgcolor);
}
- image_cache_hash = g_hash_table_new(g_str_hash, g_str_equal);
- if (graphics_android_init(ret, NULL, NULL, 0, 0, 0, use_camera)) {
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "hasMenuButton", "()Z");
- if (cid != NULL) {
- attr = g_new0(struct attr, 1);
- attr->type = attr_has_menu_button;
- attr->u.num = (*jnienv)->CallBooleanMethod(jnienv, ret->NavitGraphics, cid);
-
- /*
- * Although the attribute refers to information obtained by the graphics plugin, we are storing it
- * with the navit object: the object is easier to access from anywhere in the program, and ultimately
- * it refers to a configuration value affecting all of Navit, thus users are likely to look for it in
- * the navit object (as the fact that graphics also handles input devices is not immedately obvious).
- */
- navit_object_set_attr((struct navit_object *) nav, attr);
- dbg(lvl_debug, "attr_has_menu_button=%d\n", attr->u.num);
- g_free(attr);
- }
- ret->NavitGraphics_setBackgroundColor = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setBackgroundColor", "(I)V");
- if (ret->NavitGraphics_setBackgroundColor != NULL) {
- (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, ret->NavitGraphics_setBackgroundColor, ret->bgcolor);
- }
- dbg(lvl_debug,"returning %p\n",ret);
- return ret;
- } else {
- g_free(ret);
- return NULL;
- }
+ dbg(lvl_debug,"returning %p",ret);
+ return ret;
+ } else {
+ g_free(ret);
+ return NULL;
+ }
}
/**
@@ -916,31 +871,27 @@ graphics_android_new(struct navit *nav, struct graphics_methods *meth, struct at
*
* @return The graphics instance for the new overlay
*/
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
-{
- struct graphics_priv *ret=g_new0(struct graphics_priv, 1);
- *meth=graphics_methods;
- if (graphics_android_init(ret, gr, p, w, h, wraparound, 0)) {
- dbg(lvl_debug,"returning %p\n",ret);
- return ret;
- } else {
- g_free(ret);
- return NULL;
- }
+static struct graphics_priv *overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p,
+ int w, int h, int wraparound) {
+ struct graphics_priv *ret=g_new0(struct graphics_priv, 1);
+ *meth=graphics_methods;
+ if (graphics_android_init(ret, gr, p, w, h, wraparound, 0)) {
+ dbg(lvl_debug,"returning %p",ret);
+ return ret;
+ } else {
+ g_free(ret);
+ return NULL;
+ }
}
-static void
-event_android_main_loop_run(void)
-{
- dbg(lvl_debug,"enter\n");
+static void event_android_main_loop_run(void) {
+ dbg(lvl_debug,"enter");
}
-static void event_android_main_loop_quit(void)
-{
- dbg(lvl_debug,"enter\n");
- (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_exit);
+static void event_android_main_loop_quit(void) {
+ dbg(lvl_debug,"enter");
+ (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_exit);
}
@@ -957,191 +908,172 @@ static jmethodID NavitWatch_init;
static jmethodID NavitWatch_remove;
-static void do_poll(JNIEnv *env, int fd, int cond)
-{
- struct pollfd pfd;
- pfd.fd=fd;
- dbg(lvl_debug,"%p poll called for %d %d\n", fd, cond);
- switch ((enum event_watch_cond)cond) {
- case event_watch_cond_read:
- pfd.events=POLLIN;
- break;
- case event_watch_cond_write:
- pfd.events=POLLOUT;
- break;
- case event_watch_cond_except:
- pfd.events=POLLERR;
- break;
- default:
- pfd.events=0;
- }
- pfd.revents=0;
- poll(&pfd, 1, -1);
+static void do_poll(JNIEnv *env, int fd, int cond) {
+ struct pollfd pfd;
+ pfd.fd=fd;
+ dbg(lvl_debug,"%p poll called for %d %d", fd, cond);
+ switch ((enum event_watch_cond)cond) {
+ case event_watch_cond_read:
+ pfd.events=POLLIN;
+ break;
+ case event_watch_cond_write:
+ pfd.events=POLLOUT;
+ break;
+ case event_watch_cond_except:
+ pfd.events=POLLERR;
+ break;
+ default:
+ pfd.events=0;
+ }
+ pfd.revents=0;
+ poll(&pfd, 1, -1);
}
-static struct event_watch *
-event_android_add_watch(int h, enum event_watch_cond cond, struct callback *cb)
-{
- jobject ret;
- ret=(*jnienv)->NewObject(jnienv, NavitWatchClass, NavitWatch_init, (int)do_poll, h, (int) cond, (int)cb);
- dbg(lvl_debug,"result for %d,%d,%p=%p\n",h,cond,cb,ret);
- if (ret)
- ret = (*jnienv)->NewGlobalRef(jnienv, ret);
- return (struct event_watch *)ret;
+static struct event_watch *event_android_add_watch(int h, enum event_watch_cond cond, struct callback *cb) {
+ jobject ret;
+ ret=(*jnienv)->NewObject(jnienv, NavitWatchClass, NavitWatch_init, (int)do_poll, h, (int) cond, (int)cb);
+ dbg(lvl_debug,"result for %d,%d,%p=%p",h,cond,cb,ret);
+ if (ret)
+ ret = (*jnienv)->NewGlobalRef(jnienv, ret);
+ return (struct event_watch *)ret;
}
-static void
-event_android_remove_watch(struct event_watch *ev)
-{
- dbg(lvl_debug,"enter %p\n",ev);
- if (ev) {
- jobject obj=(jobject )ev;
- (*jnienv)->CallVoidMethod(jnienv, obj, NavitWatch_remove);
- (*jnienv)->DeleteGlobalRef(jnienv, obj);
- }
+static void event_android_remove_watch(struct event_watch *ev) {
+ dbg(lvl_debug,"enter %p",ev);
+ if (ev) {
+ jobject obj=(jobject )ev;
+ (*jnienv)->CallVoidMethod(jnienv, obj, NavitWatch_remove);
+ (*jnienv)->DeleteGlobalRef(jnienv, obj);
+ }
}
-struct event_timeout
-{
- void (*handle_timeout)(struct event_timeout *priv);
- jobject jni_timeout;
- int multi;
- struct callback *cb;
+struct event_timeout {
+ void (*handle_timeout)(struct event_timeout *priv);
+ jobject jni_timeout;
+ int multi;
+ struct callback *cb;
};
-static void
-event_android_remove_timeout(struct event_timeout *priv)
-{
- if (priv && priv->jni_timeout) {
- (*jnienv)->CallVoidMethod(jnienv, priv->jni_timeout, NavitTimeout_remove);
- (*jnienv)->DeleteGlobalRef(jnienv, priv->jni_timeout);
- priv->jni_timeout = NULL;
- }
+static void event_android_remove_timeout(struct event_timeout *priv) {
+ if (priv && priv->jni_timeout) {
+ (*jnienv)->CallVoidMethod(jnienv, priv->jni_timeout, NavitTimeout_remove);
+ (*jnienv)->DeleteGlobalRef(jnienv, priv->jni_timeout);
+ priv->jni_timeout = NULL;
+ }
}
-static void event_android_handle_timeout(struct event_timeout *priv)
-{
- callback_call_0(priv->cb);
- if (!priv->multi)
- event_android_remove_timeout(priv);
+static void event_android_handle_timeout(struct event_timeout *priv) {
+ callback_call_0(priv->cb);
+ if (!priv->multi)
+ event_android_remove_timeout(priv);
}
-static struct event_timeout *
-event_android_add_timeout(int timeout, int multi, struct callback *cb)
-{
- struct event_timeout *ret = g_new0(struct event_timeout, 1);
- ret->cb = cb;
- ret->multi = multi;
- ret->handle_timeout = event_android_handle_timeout;
- ret->jni_timeout = (*jnienv)->NewObject(jnienv, NavitTimeoutClass, NavitTimeout_init, timeout, multi, (int)ret);
- if (ret->jni_timeout)
- ret->jni_timeout = (*jnienv)->NewGlobalRef(jnienv, ret->jni_timeout);
- return ret;
+static struct event_timeout *event_android_add_timeout(int timeout, int multi, struct callback *cb) {
+ struct event_timeout *ret = g_new0(struct event_timeout, 1);
+ ret->cb = cb;
+ ret->multi = multi;
+ ret->handle_timeout = event_android_handle_timeout;
+ ret->jni_timeout = (*jnienv)->NewObject(jnienv, NavitTimeoutClass, NavitTimeout_init, timeout, multi, (int)ret);
+ if (ret->jni_timeout)
+ ret->jni_timeout = (*jnienv)->NewGlobalRef(jnienv, ret->jni_timeout);
+ return ret;
}
-static struct event_idle *
-event_android_add_idle(int priority, struct callback *cb)
-{
+static struct event_idle *event_android_add_idle(int priority, struct callback *cb) {
#if 0
- jobject ret;
- dbg(lvl_debug,"enter\n");
- ret=(*jnienv)->NewObject(jnienv, NavitIdleClass, NavitIdle_init, (int)cb);
- dbg(lvl_debug,"result for %p=%p\n",cb,ret);
- if (ret)
- ret = (*jnienv)->NewGlobalRef(jnienv, ret);
- return (struct event_idle *)ret;
+ jobject ret;
+ dbg(lvl_debug,"enter");
+ ret=(*jnienv)->NewObject(jnienv, NavitIdleClass, NavitIdle_init, (int)cb);
+ dbg(lvl_debug,"result for %p=%p",cb,ret);
+ if (ret)
+ ret = (*jnienv)->NewGlobalRef(jnienv, ret);
+ return (struct event_idle *)ret;
#endif
- return (struct event_idle *)event_android_add_timeout(1, 1, cb);
+ return (struct event_idle *)event_android_add_timeout(1, 1, cb);
}
-static void
-event_android_remove_idle(struct event_idle *ev)
-{
+static void event_android_remove_idle(struct event_idle *ev) {
#if 0
- dbg(lvl_debug,"enter %p\n",ev);
- if (ev) {
- jobject obj=(jobject )ev;
- (*jnienv)->CallVoidMethod(jnienv, obj, NavitIdle_remove);
- (*jnienv)->DeleteGlobalRef(jnienv, obj);
- }
+ dbg(lvl_debug,"enter %p",ev);
+ if (ev) {
+ jobject obj=(jobject )ev;
+ (*jnienv)->CallVoidMethod(jnienv, obj, NavitIdle_remove);
+ (*jnienv)->DeleteGlobalRef(jnienv, obj);
+ }
#endif
- event_android_remove_timeout((struct event_timeout *)ev);
+ event_android_remove_timeout((struct event_timeout *)ev);
}
-static void
-event_android_call_callback(struct callback_list *cb)
-{
- dbg(lvl_debug,"enter\n");
+static void event_android_call_callback(struct callback_list *cb) {
+ dbg(lvl_debug,"enter");
}
static struct event_methods event_android_methods = {
- event_android_main_loop_run,
- event_android_main_loop_quit,
- event_android_add_watch,
- event_android_remove_watch,
- event_android_add_timeout,
- event_android_remove_timeout,
- event_android_add_idle,
- event_android_remove_idle,
- event_android_call_callback,
+ event_android_main_loop_run,
+ event_android_main_loop_quit,
+ event_android_add_watch,
+ event_android_remove_watch,
+ event_android_add_timeout,
+ event_android_remove_timeout,
+ event_android_add_idle,
+ event_android_remove_idle,
+ event_android_call_callback,
};
-static struct event_priv *
-event_android_new(struct event_methods *meth)
-{
- dbg(lvl_debug,"enter\n");
- if (!find_class_global("org/navitproject/navit/NavitTimeout", &NavitTimeoutClass))
- return NULL;
- NavitTimeout_init = (*jnienv)->GetMethodID(jnienv, NavitTimeoutClass, "<init>", "(IZI)V");
- if (NavitTimeout_init == NULL)
- return NULL;
- NavitTimeout_remove = (*jnienv)->GetMethodID(jnienv, NavitTimeoutClass, "remove", "()V");
- if (NavitTimeout_remove == NULL)
- return NULL;
+static struct event_priv *event_android_new(struct event_methods *meth) {
+ dbg(lvl_debug,"enter");
+ if (!find_class_global("org/navitproject/navit/NavitTimeout", &NavitTimeoutClass))
+ return NULL;
+ NavitTimeout_init = (*jnienv)->GetMethodID(jnienv, NavitTimeoutClass, "<init>", "(IZI)V");
+ if (NavitTimeout_init == NULL)
+ return NULL;
+ NavitTimeout_remove = (*jnienv)->GetMethodID(jnienv, NavitTimeoutClass, "remove", "()V");
+ if (NavitTimeout_remove == NULL)
+ return NULL;
#if 0
- if (!find_class_global("org/navitproject/navit/NavitIdle", &NavitIdleClass))
- return NULL;
- NavitIdle_init = (*jnienv)->GetMethodID(jnienv, NavitIdleClass, "<init>", "(I)V");
- if (NavitIdle_init == NULL)
- return NULL;
- NavitIdle_remove = (*jnienv)->GetMethodID(jnienv, NavitIdleClass, "remove", "()V");
- if (NavitIdle_remove == NULL)
- return NULL;
+ if (!find_class_global("org/navitproject/navit/NavitIdle", &NavitIdleClass))
+ return NULL;
+ NavitIdle_init = (*jnienv)->GetMethodID(jnienv, NavitIdleClass, "<init>", "(I)V");
+ if (NavitIdle_init == NULL)
+ return NULL;
+ NavitIdle_remove = (*jnienv)->GetMethodID(jnienv, NavitIdleClass, "remove", "()V");
+ if (NavitIdle_remove == NULL)
+ return NULL;
#endif
- if (!find_class_global("org/navitproject/navit/NavitWatch", &NavitWatchClass))
- return NULL;
- NavitWatch_init = (*jnienv)->GetMethodID(jnienv, NavitWatchClass, "<init>", "(IIII)V");
- if (NavitWatch_init == NULL)
- return NULL;
- NavitWatch_remove = (*jnienv)->GetMethodID(jnienv, NavitWatchClass, "remove", "()V");
- if (NavitWatch_remove == NULL)
- return NULL;
-
- if (!find_class_global("org/navitproject/navit/Navit", &NavitClass))
- return NULL;
- Navit_disableSuspend = (*jnienv)->GetMethodID(jnienv, NavitClass, "disableSuspend", "()V");
- if (Navit_disableSuspend == NULL)
- return NULL;
- Navit_exit = (*jnienv)->GetMethodID(jnienv, NavitClass, "exit", "()V");
- if (Navit_exit == NULL)
- return NULL;
- Navit_fullscreen = (*jnienv)->GetMethodID(jnienv, NavitClass, "fullscreen", "(I)V");
- if (Navit_fullscreen == NULL)
- return NULL;
- Navit_runOptionsItem = (*jnienv)->GetMethodID(jnienv, NavitClass, "runOptionsItem", "(I)V");
- if (Navit_runOptionsItem == NULL)
- return NULL;
- Navit_showMenu = (*jnienv)->GetMethodID(jnienv, NavitClass, "showMenu", "()V");
- if (Navit_showMenu == NULL)
- return NULL;
- Navit_showNativeKeyboard = (*jnienv)->GetMethodID(jnienv, NavitClass, "showNativeKeyboard", "()I");
- Navit_hideNativeKeyboard = (*jnienv)->GetMethodID(jnienv, NavitClass, "hideNativeKeyboard", "()V");
-
- dbg(lvl_debug,"ok\n");
- *meth=event_android_methods;
+ if (!find_class_global("org/navitproject/navit/NavitWatch", &NavitWatchClass))
+ return NULL;
+ NavitWatch_init = (*jnienv)->GetMethodID(jnienv, NavitWatchClass, "<init>", "(IIII)V");
+ if (NavitWatch_init == NULL)
return NULL;
+ NavitWatch_remove = (*jnienv)->GetMethodID(jnienv, NavitWatchClass, "remove", "()V");
+ if (NavitWatch_remove == NULL)
+ return NULL;
+
+ if (!find_class_global("org/navitproject/navit/Navit", &NavitClass))
+ return NULL;
+ Navit_disableSuspend = (*jnienv)->GetMethodID(jnienv, NavitClass, "disableSuspend", "()V");
+ if (Navit_disableSuspend == NULL)
+ return NULL;
+ Navit_exit = (*jnienv)->GetMethodID(jnienv, NavitClass, "exit", "()V");
+ if (Navit_exit == NULL)
+ return NULL;
+ Navit_fullscreen = (*jnienv)->GetMethodID(jnienv, NavitClass, "fullscreen", "(I)V");
+ if (Navit_fullscreen == NULL)
+ return NULL;
+ Navit_runOptionsItem = (*jnienv)->GetMethodID(jnienv, NavitClass, "runOptionsItem", "(I)V");
+ if (Navit_runOptionsItem == NULL)
+ return NULL;
+ Navit_showMenu = (*jnienv)->GetMethodID(jnienv, NavitClass, "showMenu", "()V");
+ if (Navit_showMenu == NULL)
+ return NULL;
+ Navit_showNativeKeyboard = (*jnienv)->GetMethodID(jnienv, NavitClass, "showNativeKeyboard", "()I");
+ Navit_hideNativeKeyboard = (*jnienv)->GetMethodID(jnienv, NavitClass, "hideNativeKeyboard", "()V");
+
+ dbg(lvl_debug,"ok");
+ *meth=event_android_methods;
+ return NULL;
}
@@ -1164,16 +1096,16 @@ event_android_new(struct event_methods *meth)
* @return True if the input method is going to be displayed, false if not.
*/
int show_native_keyboard (struct graphics_keyboard *kbd) {
- kbd->w = -1;
- if (Navit_showNativeKeyboard == NULL) {
- dbg(lvl_error, "method Navit.showNativeKeyboard() not found, cannot display keyboard\n");
- return 0;
- }
- kbd->h = (*jnienv)->CallIntMethod(jnienv, android_activity, Navit_showNativeKeyboard);
- dbg(lvl_error, "keyboard size is %d x %d px\n", kbd->w, kbd->h);
- dbg(lvl_error, "return\n");
- /* zero height means we're not showing a keyboard, therefore normalize height to boolean */
- return !!(kbd->h);
+ kbd->w = -1;
+ if (Navit_showNativeKeyboard == NULL) {
+ dbg(lvl_error, "method Navit.showNativeKeyboard() not found, cannot display keyboard");
+ return 0;
+ }
+ kbd->h = (*jnienv)->CallIntMethod(jnienv, android_activity, Navit_showNativeKeyboard);
+ dbg(lvl_error, "keyboard size is %d x %d px", kbd->w, kbd->h);
+ dbg(lvl_error, "return");
+ /* zero height means we're not showing a keyboard, therefore normalize height to boolean */
+ return !!(kbd->h);
}
@@ -1185,19 +1117,17 @@ int show_native_keyboard (struct graphics_keyboard *kbd) {
* will be freed by this function.
*/
void hide_native_keyboard (struct graphics_keyboard *kbd) {
- if (Navit_hideNativeKeyboard == NULL) {
- dbg(lvl_error, "method Navit.hideNativeKeyboard() not found, cannot dismiss keyboard\n");
- return;
- }
- (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_hideNativeKeyboard);
- g_free(kbd->gra_priv);
+ if (Navit_hideNativeKeyboard == NULL) {
+ dbg(lvl_error, "method Navit.hideNativeKeyboard() not found, cannot dismiss keyboard");
+ return;
+ }
+ (*jnienv)->CallVoidMethod(jnienv, android_activity, Navit_hideNativeKeyboard);
+ g_free(kbd->gra_priv);
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug,"enter\n");
- plugin_register_category_graphics("android", graphics_android_new);
- plugin_register_category_event("android", event_android_new);
+void plugin_init(void) {
+ dbg(lvl_debug,"enter");
+ plugin_register_category_graphics("android", graphics_android_new);
+ plugin_register_category_event("android", event_android_new);
}
diff --git a/navit/graphics/cocoa/CMakeLists.txt b/navit/graphics/cocoa/CMakeLists.txt
index a4cd31d84..6e7d21e4a 100644
--- a/navit/graphics/cocoa/CMakeLists.txt
+++ b/navit/graphics/cocoa/CMakeLists.txt
@@ -1,6 +1,6 @@
if (USE_UIKIT)
-set(graphics_cocoa_LIBS "-framework Foundation" "-framework UIKit" "-framework CoreGraphics" "-liconv")
+ set(graphics_cocoa_LIBS "-framework Foundation" "-framework UIKit" "-framework CoreGraphics" "-liconv")
else()
-set(graphics_cocoa_LIBS "-framework Cocoa" "-liconv")
+ set(graphics_cocoa_LIBS "-framework Cocoa" "-liconv")
endif()
module_add_library(graphics_cocoa graphics_cocoa.m)
diff --git a/navit/graphics/cocoa/graphics_cocoa.m b/navit/graphics/cocoa/graphics_cocoa.m
index 16c879bd7..6f5bcedc5 100644
--- a/navit/graphics/cocoa/graphics_cocoa.m
+++ b/navit/graphics/cocoa/graphics_cocoa.m
@@ -112,7 +112,7 @@ struct graphics_font_priv {
#if REVERSE_Y
pc.y=graphics->h-pc.y-gr->h;
#endif
- dbg(1,"draw %dx%d at %f,%f\n",gr->w,gr->h,pc.x,pc.y);
+ dbg(1,"draw %dx%d at %f,%f",gr->w,gr->h,pc.x,pc.y);
CGContextDrawLayerAtPoint(X, pc, gr->layer);
}
gr=gr->next;
@@ -128,7 +128,7 @@ struct graphics_font_priv {
struct point p;
p.x=pc.x;
p.y=pc.y;
- dbg(1,"Enter count=%d %d %d\n",touches.count,p.x,p.y);
+ dbg(1,"Enter count=%d %d %d",touches.count,p.x,p.y);
callback_list_call_attr_3(graphics->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(1), (void *)&p);
}
@@ -141,7 +141,7 @@ struct graphics_font_priv {
struct point p;
p.x=pc.x;
p.y=pc.y;
- dbg(1,"Enter count=%d %d %d\n",touches.count,p.x,p.y);
+ dbg(1,"Enter count=%d %d %d",touches.count,p.x,p.y);
callback_list_call_attr_3(graphics->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(1), (void *)&p);
}
@@ -153,7 +153,7 @@ struct graphics_font_priv {
struct point p;
p.x=pc.x;
p.y=pc.y;
- dbg(1,"Enter count=%d %d %d\n",touches.count,p.x,p.y);
+ dbg(1,"Enter count=%d %d %d",touches.count,p.x,p.y);
callback_list_call_attr_3(graphics->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(1), (void *)&p);
}
@@ -165,7 +165,7 @@ struct graphics_font_priv {
struct point p;
p.x=pc.x;
p.y=pc.y;
- dbg(1,"Enter count=%d %d %d\n",touches.count,p.x,p.y);
+ dbg(1,"Enter count=%d %d %d",touches.count,p.x,p.y);
callback_list_call_attr_1(graphics->cbl, attr_motion, (void *)&p);
}
@@ -175,8 +175,8 @@ struct graphics_font_priv {
struct point p;
p.x=theEvent.locationInWindow.x;
p.y=graphics->h-theEvent.locationInWindow.y;
-
- dbg(1,"Enter %d %d\n",p.x,p.y);
+
+ dbg(1,"Enter %d %d",p.x,p.y);
callback_list_call_attr_3(graphics->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(1), (void *)&p);
}
@@ -185,8 +185,8 @@ struct graphics_font_priv {
struct point p;
p.x=theEvent.locationInWindow.x;
p.y=graphics->h-theEvent.locationInWindow.y;
-
- dbg(1,"Enter %d %d\n",p.x,p.y);
+
+ dbg(1,"Enter %d %d",p.x,p.y);
callback_list_call_attr_3(graphics->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(1), (void *)&p);
}
@@ -195,8 +195,8 @@ struct graphics_font_priv {
struct point p;
p.x=theEvent.locationInWindow.x;
p.y=graphics->h-theEvent.locationInWindow.y;
-
- dbg(1,"Enter %d %d\n",p.x,p.y);
+
+ dbg(1,"Enter %d %d",p.x,p.y);
callback_list_call_attr_1(graphics->cbl, attr_motion, (void *)&p);
}
#endif
@@ -233,7 +233,7 @@ struct graphics_font_priv {
return [self init];
}
-static
+static
void free_graphics(struct graphics_priv *gr)
{
if (gr->layer) {
@@ -280,7 +280,7 @@ setup_graphics(struct graphics_priv *gr)
}
- (void)didReceiveMemoryWarning {
- dbg(0,"enter\n");
+ dbg(0,"enter");
}
- (void)viewDidUnload {
@@ -355,7 +355,7 @@ applicationDidFinishLaunching:(NSNotification *)aNotification
if (global_graphics_cocoa) {
callback_list_call_attr_2(global_graphics_cocoa->cbl, attr_resize, (int)appFrame.size.width, (int)appFrame.size.height);
-
+
}
#if USE_UIKIT
@@ -378,7 +378,7 @@ static void
draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
{
if (mode == draw_mode_end) {
- dbg(1,"end %p\n",gr);
+ dbg(1,"end %p",gr);
if (!gr->parent) {
#if USE_UIKIT
[gr->view setNeedsDisplay];
@@ -404,7 +404,7 @@ draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *
CGContextBeginPath(gr->layer_context);
CGContextAddLines(gr->layer_context, points, count);
CGContextStrokePath(gr->layer_context);
-
+
}
static void
@@ -427,7 +427,7 @@ draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct poi
{
CGRect lr=CGRectMake(p->x, p->y, w, h);
if (p->x <= 0 && p->y <= 0 && p->x+w+1 >= gr->w && p->y+h+1 >= gr->h) {
- dbg(1,"clear %p %dx%d\n",gr,w,h);
+ dbg(1,"clear %p %dx%d",gr,w,h);
free_graphics(gr);
setup_graphics(gr);
}
@@ -533,8 +533,8 @@ gc_set_background(struct graphics_gc_priv *gc, struct color *c)
}
static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
+ gc_destroy,
+ gc_set_linewidth,
gc_set_dashes,
gc_set_foreground,
gc_set_background,
@@ -571,7 +571,7 @@ image_new(struct graphics_priv *gra, struct graphics_image_methods *meth, char *
CGImageRef image = CGImageCreateWithPNGDataProvider(imgDataProvider, NULL, true, kCGRenderingIntentDefault);
CGDataProviderRelease(imgDataProvider);
- dbg(1,"size %dx%d\n",CGImageGetWidth(image),CGImageGetHeight(image));
+ dbg(1,"size %dx%d",CGImageGetWidth(image),CGImageGetHeight(image));
if (w)
*w=CGImageGetWidth(image);
if (h)
@@ -586,7 +586,7 @@ image_new(struct graphics_priv *gra, struct graphics_image_methods *meth, char *
static void *
get_data(struct graphics_priv *this, const char *type)
{
- dbg(0,"enter\n");
+ dbg(0,"enter");
if (strcmp(type,"window"))
return NULL;
return &this->win;
@@ -630,14 +630,14 @@ static struct graphics_methods graphics_methods = {
draw_polygon,
draw_rectangle,
NULL, /* draw_circle, */
- draw_text,
+ draw_text,
draw_image,
NULL, /* draw_image_warp, */
draw_drag,
font_new,
gc_new,
background_gc,
- overlay_new,
+ overlay_new,
image_new,
get_data,
image_free,
@@ -670,7 +670,7 @@ graphics_cocoa_new(struct navit *nav, struct graphics_methods *meth, struct attr
{
struct graphics_priv *ret;
*meth=graphics_methods;
- dbg(0,"enter\n");
+ dbg(0,"enter");
if(!event_request_system("cocoa","graphics_cocoa"))
return NULL;
ret=g_new0(struct graphics_priv, 1);
@@ -683,7 +683,7 @@ static void
event_cocoa_main_loop_run(void)
{
- dbg(0,"enter\n");
+ dbg(0,"enter");
#if 0
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
@@ -693,9 +693,9 @@ event_cocoa_main_loop_run(void)
#endif
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
#if USE_UIKIT
- dbg(0,"calling main\n");
+ dbg(0,"calling main");
int retval = UIApplicationMain(main_argc, main_argv, nil, @"NavitAppDelegate");
- dbg(0,"retval=%d\n",retval);
+ dbg(0,"retval=%d",retval);
#else
NavitAppDelegate * delegate = [[NavitAppDelegate alloc] init];
NSApplication * application = [NSApplication sharedApplication];
@@ -739,7 +739,7 @@ event_cocoa_add_timeout(int timeout, int multi, struct callback *cb)
NavitTimer *ret=[[NavitTimer alloc]init];
ret->cb=cb;
ret->timer=[NSTimer scheduledTimerWithTimeInterval:(timeout/1000.0) target:ret selector:@selector(onTimer:) userInfo:nil repeats:multi?YES:NO];
- dbg(1,"timer=%p\n",ret->timer);
+ dbg(1,"timer=%p",ret->timer);
return (struct event_timeout *)ret;
}
@@ -748,7 +748,7 @@ static void
event_cocoa_remove_timeout(struct event_timeout *ev)
{
NavitTimer *t=(NavitTimer *)ev;
-
+
[t->timer invalidate];
[t release];
}
@@ -761,7 +761,7 @@ event_cocoa_add_idle(int priority, struct callback *cb)
ret->cb=cb;
ret->timer=[NSTimer scheduledTimerWithTimeInterval:(0.0) target:ret selector:@selector(onTimer:) userInfo:nil repeats:YES];
- dbg(1,"timer=%p\n",ret->timer);
+ dbg(1,"timer=%p",ret->timer);
return (struct event_idle *)ret;
}
@@ -769,7 +769,7 @@ static void
event_cocoa_remove_idle(struct event_idle *ev)
{
NavitTimer *t=(NavitTimer *)ev;
-
+
[t->timer invalidate];
[t release];
}
@@ -782,7 +782,7 @@ static struct event_methods event_cocoa_methods = {
event_cocoa_add_timeout,
event_cocoa_remove_timeout,
event_cocoa_add_idle,
- event_cocoa_remove_idle,
+ event_cocoa_remove_idle,
NULL, /* event_cocoa_call_callback, */
};
@@ -790,7 +790,7 @@ static struct event_methods event_cocoa_methods = {
static struct event_priv *
event_cocoa_new(struct event_methods *meth)
{
- dbg(0,"enter\n");
+ dbg(0,"enter");
*meth=event_cocoa_methods;
return NULL;
}
@@ -799,7 +799,7 @@ event_cocoa_new(struct event_methods *meth)
void
plugin_init(void)
{
- dbg(0,"enter\n");
+ dbg(0,"enter");
plugin_register_category_graphics("cocoa", graphics_cocoa_new);
plugin_register_category_event("cocoa", event_cocoa_new);
}
diff --git a/navit/graphics/egl/CMakeLists.txt b/navit/graphics/egl/CMakeLists.txt
index 1943f2bc0..a0e4e27dd 100644
--- a/navit/graphics/egl/CMakeLists.txt
+++ b/navit/graphics/egl/CMakeLists.txt
@@ -1,2 +1,2 @@
-module_add_library(graphics_egl graphics_egl.c)
+module_add_library(graphics_egl graphics_egl.c)
diff --git a/navit/graphics/egl/graphics_egl.c b/navit/graphics/egl/graphics_egl.c
index 4d7780ff4..2da56047c 100644
--- a/navit/graphics/egl/graphics_egl.c
+++ b/navit/graphics/egl/graphics_egl.c
@@ -38,7 +38,7 @@
#include "window.h"
#include "navit/font/freetype/font_freetype.h"
-#include <SDL2/SDL_image.h>
+#include "SDL_image.h"
#include <GLES2/gl2.h>
#include <EGL/egl.h>
@@ -88,7 +88,8 @@ struct graphics_priv {
struct graphics_gc_priv *background_gc;
enum draw_mode_num mode;
GLuint program;
- GLint mvp_location, position_location, color_location, texture_position_location, use_texture_location, texture_location;
+ GLint mvp_location, position_location, color_location, texture_position_location, use_texture_location,
+ texture_location;
struct callback_list *cbl;
struct font_freetype_methods freetype_methods;
struct navit *nav;
@@ -114,25 +115,24 @@ struct graphics_opengl_platform {
EGLConfig config[1];
};
-struct contour
-{
- struct point *p;
- unsigned int count;
+struct contour {
+ struct point *p;
+ unsigned int count;
};
static GHashTable *hImageData;
static int USERWANTSTOQUIT = 0;
static struct graphics_priv *graphics_priv_root;
static struct graphics_priv *graphics_opengl_new_helper(struct
- graphics_methods
- *meth);
+ graphics_methods
+ *meth);
/*
* GLES 2 Compatible vertex and fragment shaders
* Taken from opengl driver
*/
const char vertex_src [] =
-" \
+ " \
attribute vec2 position; \
attribute vec2 texture_position; \
uniform mat4 mvp; \
@@ -146,7 +146,7 @@ const char vertex_src [] =
";
const char fragment_src [] =
-" \
+ " \
uniform lowp vec4 avcolor; \
uniform sampler2D texture; \
uniform bool use_texture; \
@@ -166,140 +166,139 @@ const char fragment_src [] =
* Found at http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml
* Adapted and debugged for this use
*/
-float area(const struct contour* contour)
-{
- int p, q;
- int n = contour->count - 1;
- float A = 0.f;
-
- for (p=n-1, q=0; q < n; p=q++)
- {
- A += contour->p[p].x * contour->p[q].y - contour->p[q].x * contour->p[p].y;
- }
- return A * .5f;
+float area(const struct contour* contour) {
+ int p, q;
+ int n = contour->count - 1;
+ float A = 0.f;
+
+ for (p=n-1, q=0; q < n; p=q++) {
+ A += contour->p[p].x * contour->p[q].y - contour->p[q].x * contour->p[p].y;
+ }
+ return A * .5f;
}
-int
-inside_triangle(float Ax, float Ay,
- float Bx, float By,
- float Cx, float Cy,
- float Px, float Py)
-{
- float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
- float cCROSSap, bCROSScp, aCROSSbp;
-
- ax = Cx - Bx; ay = Cy - By;
- bx = Ax - Cx; by = Ay - Cy;
- cx = Bx - Ax; cy = By - Ay;
- apx= Px - Ax; apy= Py - Ay;
- bpx= Px - Bx; bpy= Py - By;
- cpx= Px - Cx; cpy= Py - Cy;
-
- aCROSSbp = ax*bpy - ay*bpx;
- cCROSSap = cx*apy - cy*apx;
- bCROSScp = bx*cpy - by*cpx;
-
- return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
+int inside_triangle(float Ax, float Ay,
+ float Bx, float By,
+ float Cx, float Cy,
+ float Px, float Py) {
+ float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
+ float cCROSSap, bCROSScp, aCROSSbp;
+
+ ax = Cx - Bx;
+ ay = Cy - By;
+ bx = Ax - Cx;
+ by = Ay - Cy;
+ cx = Bx - Ax;
+ cy = By - Ay;
+ apx= Px - Ax;
+ apy= Py - Ay;
+ bpx= Px - Bx;
+ bpy= Py - By;
+ cpx= Px - Cx;
+ cpy= Py - Cy;
+
+ aCROSSbp = ax*bpy - ay*bpx;
+ cCROSSap = cx*apy - cy*apx;
+ bCROSScp = bx*cpy - by*cpx;
+
+ return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
}
-int
-snip(const struct point* pnt,int u,int v,int w,int n,int *V)
-{
- int p;
- float Ax, Ay, Bx, By, Cx, Cy, Px, Py;
+int snip(const struct point* pnt,int u,int v,int w,int n,int *V) {
+ int p;
+ float Ax, Ay, Bx, By, Cx, Cy, Px, Py;
- Ax = pnt[V[u]].x;
- Ay = pnt[V[u]].y;
+ Ax = pnt[V[u]].x;
+ Ay = pnt[V[u]].y;
- Bx = pnt[V[v]].x;
- By = pnt[V[v]].y;
+ Bx = pnt[V[v]].x;
+ By = pnt[V[v]].y;
- Cx = pnt[V[w]].x;
- Cy = pnt[V[w]].y;
+ Cx = pnt[V[w]].x;
+ Cy = pnt[V[w]].y;
- if ( (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax))) < 0.f )
- return 0;
+ if ( (((Bx-Ax)*(Cy-Ay)) - ((By-Ay)*(Cx-Ax))) < 0.f )
+ return 0;
- for (p=0;p<n;p++)
- {
- if( (p == u) || (p == v) || (p == w) )
- continue;
- Px = pnt[V[p]].x;
- Py = pnt[V[p]].y;
- if (inside_triangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py))
- return 0;
- }
+ for (p=0; p<n; p++) {
+ if( (p == u) || (p == v) || (p == w) )
+ continue;
+ Px = pnt[V[p]].x;
+ Py = pnt[V[p]].y;
+ if (inside_triangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py))
+ return 0;
+ }
- return 1;
+ return 1;
}
-int
-process_triangles(const struct contour* contour, struct contour* result)
-{
- int v;
- int contour_size = contour->count - 1;
- int polygon_temp_size = contour_size * 80;
- int final_count = 0;
- result->p = malloc(sizeof(struct point) * polygon_temp_size);
-
- int n = contour_size;
- if ( n < 3 ) return 0;
-
- int *V = alloca(sizeof(int)*n);
-
- if ( 0.0f < area(contour) )
- for (v=0; v<n; v++) V[v] = v;
- else
- for(v=0; v<n; v++) V[v] = (n-1)-v;
-
- int nv = n;
-
- int count = 2*nv;
-
- for(v=nv-1; nv>2; )
- {
- /* if we loop, it is probably a non-simple polygon */
- if (0 >= (count--))
- {
- //** Triangulate: ERROR - probable bad polygon!
- break;
- }
-
- /* three consecutive vertices in current polygon, <u,v,w> */
- int u = v ; if (nv <= u) u = 0; /* previous */
- v = u+1; if (nv <= v) v = 0; /* new v */
- int w = v+1; if (nv <= w) w = 0; /* next */
-
- if ( snip(contour->p,u,v,w,nv,V) )
- {
- int a,b,c,s,t;
-
- /* true names of the vertices */
- a = V[u]; b = V[v]; c = V[w];
-
- /* output Triangle */
- result->p[final_count++] = contour->p[a];
- result->p[final_count++] = contour->p[b];
- result->p[final_count++] = contour->p[c];
-
- if (final_count >= polygon_temp_size){
- free(result->p);
- return 0;
- }
-
- /* remove v from remaining polygon */
- for(s=v,t=v+1;t<nv;s++,t++)
- V[s] = V[t];
- nv--;
-
- /* resest error detection counter */
- count = 2*nv;
- }
- }
-
- result->count = final_count;
-
- return 1;
+int process_triangles(const struct contour* contour, struct contour* result) {
+ int v;
+ int contour_size = contour->count - 1;
+ int polygon_temp_size = contour_size * 80;
+ int final_count = 0;
+ result->p = malloc(sizeof(struct point) * polygon_temp_size);
+
+ int n = contour_size;
+ if ( n < 3 ) return 0;
+
+ int *V = alloca(sizeof(int)*n);
+
+ if ( 0.0f < area(contour) )
+ for (v=0; v<n; v++) V[v] = v;
+ else
+ for(v=0; v<n; v++) V[v] = (n-1)-v;
+
+ int nv = n;
+
+ int count = 2*nv;
+
+ for(v=nv-1; nv>2; ) {
+ /* if we loop, it is probably a non-simple polygon */
+ if (0 >= (count--)) {
+ //** Triangulate: ERROR - probable bad polygon!
+ break;
+ }
+
+ /* three consecutive vertices in current polygon, <u,v,w> */
+ int u = v ;
+ if (nv <= u) u = 0; /* previous */
+ v = u+1;
+ if (nv <= v) v = 0; /* new v */
+ int w = v+1;
+ if (nv <= w) w = 0; /* next */
+
+ if ( snip(contour->p,u,v,w,nv,V) ) {
+ int a,b,c,s,t;
+
+ /* true names of the vertices */
+ a = V[u];
+ b = V[v];
+ c = V[w];
+
+ /* output Triangle */
+ result->p[final_count++] = contour->p[a];
+ result->p[final_count++] = contour->p[b];
+ result->p[final_count++] = contour->p[c];
+
+ if (final_count >= polygon_temp_size) {
+ free(result->p);
+ return 0;
+ }
+
+ /* remove v from remaining polygon */
+ for(s=v,t=v+1; t<nv; s++,t++)
+ V[s] = V[t];
+ nv--;
+
+ /* resest error detection counter */
+ count = 2*nv;
+ }
+ }
+
+ result->count = final_count;
+
+ return 1;
}
// ** Efficient Polygon Triangulation **
@@ -307,10 +306,8 @@ process_triangles(const struct contour* contour, struct contour* result)
/*
* Destroys SDL/EGL context
*/
-static void
-sdl_egl_destroy(struct graphics_opengl_platform *egl)
-{
- if (egl->eglwindow){
+static void sdl_egl_destroy(struct graphics_opengl_platform *egl) {
+ if (egl->eglwindow) {
SDL_GL_DeleteContext(egl->eglcontext);
SDL_DestroyWindow(egl->eglwindow);
}
@@ -321,18 +318,14 @@ sdl_egl_destroy(struct graphics_opengl_platform *egl)
/*
* Swap EGL buffer
*/
-static void
-sdl_egl_swap_buffers(struct graphics_opengl_platform *egl)
-{
+static void sdl_egl_swap_buffers(struct graphics_opengl_platform *egl) {
SDL_GL_SwapWindow(egl->eglwindow);
}
/*
* Main graphic destroy
*/
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
+static void graphics_destroy(struct graphics_priv *gr) {
/*FIXME graphics_destroy is never called */
gr->freetype_methods.destroy();
g_free(gr);
@@ -341,23 +334,16 @@ graphics_destroy(struct graphics_priv *gr)
SDL_Quit();
}
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
+static void gc_destroy(struct graphics_gc_priv *gc) {
g_free(gc);
gc = NULL;
}
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
+static void gc_set_linewidth(struct graphics_gc_priv *gc, int w) {
gc->linewidth = w;
}
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset,
- unsigned char *dash_list, int n)
-{
+static void gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset, unsigned char *dash_list, int n) {
int i;
const int cOpenglMaskBits = 16;
gc->dash_count = n;
@@ -388,7 +374,7 @@ gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset,
++dash_list[i];
++num_error[i % 2];
} else if (0 < num_error[i % 2]
- && 2 < dash_list[i]) {
+ && 2 < dash_list[i]) {
++dash_list[i];
--num_error[i % 2];
}
@@ -412,18 +398,14 @@ gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset,
}
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c) {
gc->fr = c->r / 65535.0;
gc->fg = c->g / 65535.0;
gc->fb = c->b / 65535.0;
gc->fa = c->a / 65535.0;
}
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_background(struct graphics_gc_priv *gc, struct color *c) {
gc->br = c->r / 65535.0;
gc->bg = c->g / 65535.0;
gc->bb = c->b / 65535.0;
@@ -438,9 +420,7 @@ static struct graphics_gc_methods gc_methods = {
gc_set_background
};
-static struct graphics_gc_priv *
-gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
+static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) {
struct graphics_gc_priv *gc = g_new0(struct graphics_gc_priv, 1);
*meth = gc_methods;
@@ -451,16 +431,14 @@ gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
static struct graphics_image_priv image_error;
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h,
- struct point *hot, int rotation)
-{
+static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name,
+ int *w, int *h, struct point *hot, int rotation) {
struct graphics_image_priv *gi;
/* FIXME: meth is not used yet.. so gi leaks. at least xpm is small */
struct graphics_image_priv *curr_elem =
- g_hash_table_lookup(hImageData, name);
+ g_hash_table_lookup(hImageData, name);
if (curr_elem == &image_error) {
//found but couldn't be loaded
@@ -475,29 +453,23 @@ image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *n
}
if (strlen(name) < 4) {
- g_hash_table_insert(hImageData, g_strdup(name),
- &image_error);
+ g_hash_table_insert(hImageData, g_strdup(name), &image_error);
return NULL;
}
gi = g_new0(struct graphics_image_priv, 1);
gi->img = IMG_Load(name);
- if(gi->img)
- {
+ if(gi->img) {
*w=gi->img->w;
*h=gi->img->h;
hot->x=*w/2;
hot->y=*h/2;
- }
- else
- {
+ } else {
/* TODO: debug "colour parse errors" on xpm */
- dbg(lvl_error,"image_new on '%s' failed: %s\n", name, IMG_GetError());
+ dbg(lvl_error,"image_new on '%s' failed: %s", name, IMG_GetError());
g_free(gi);
gi = NULL;
- g_hash_table_insert(hImageData,
- g_strdup(name),
- &image_error);
+ g_hash_table_insert(hImageData, g_strdup(name), &image_error);
return gi;
}
@@ -505,16 +477,12 @@ image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *n
return gi;
}
-static void
-image_free(struct graphics_priv *gr, struct graphics_image_priv * gi)
-{
+static void image_free(struct graphics_priv *gr, struct graphics_image_priv * gi) {
// SDL_FreeSurface(gi->img);
// g_free(gi);
}
-static void
-set_color(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
+static void set_color(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
GLfloat col[4];
col[0]=gc->fr;
col[1]=gc->fg;
@@ -523,9 +491,7 @@ set_color(struct graphics_priv *gr, struct graphics_gc_priv *gc)
glUniform4fv(gr->color_location, 1, col);
}
-static void
-draw_array(struct graphics_priv *gr, struct point *p, int count, GLenum mode)
-{
+static void draw_array(struct graphics_priv *gr, struct point *p, int count, GLenum mode) {
int i;
GLf *x;//[count*2];
x = alloca(sizeof(GLf)*count*2);
@@ -538,9 +504,7 @@ draw_array(struct graphics_priv *gr, struct point *p, int count, GLenum mode)
glDrawArrays(mode, 0, count);
}
-static void
-draw_rectangle_do(struct graphics_priv *gr, struct point *p, int w, int h)
-{
+static void draw_rectangle_do(struct graphics_priv *gr, struct point *p, int w, int h) {
struct point pa[4];
pa[0]=pa[1]=pa[2]=pa[3]=*p;
pa[0].x+=w;
@@ -551,9 +515,7 @@ draw_rectangle_do(struct graphics_priv *gr, struct point *p, int w, int h)
}
-static void
-draw_image_es(struct graphics_priv *gr, struct point *p, int w, int h, unsigned char *data)
-{
+static void draw_image_es(struct graphics_priv *gr, struct point *p, int w, int h, unsigned char *data) {
GLf x[8];
GLuint texture;
memset(x, 0, sizeof(x));
@@ -587,9 +549,7 @@ draw_image_es(struct graphics_priv *gr, struct point *p, int w, int h, unsigned
glDeleteTextures(1, &texture);
}
-inline void
-get_overlay_pos(struct graphics_priv *gr, struct point *point_out)
-{
+inline void get_overlay_pos(struct graphics_priv *gr, struct point *point_out) {
if (gr->parent == NULL) {
point_out->x = 0;
point_out->y = 0;
@@ -606,9 +566,7 @@ get_overlay_pos(struct graphics_priv *gr, struct point *point_out)
}
}
-inline void
-draw_overlay(struct graphics_priv *gr)
-{
+inline void draw_overlay(struct graphics_priv *gr) {
struct point p_eff;
GLf x[8];
@@ -636,13 +594,10 @@ draw_overlay(struct graphics_priv *gr)
glDisable(GL_BLEND);
}
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc,
- struct point *p, int count)
-{
+static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
return;
}
@@ -655,14 +610,11 @@ draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc,
}
-static void
-draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc,
- struct point *p, int count)
-{
+static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
int ok;
if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
return;
}
set_color(gr, gc);
@@ -671,7 +623,7 @@ draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc,
contour.count = count;
contour.p = p;
ok = process_triangles(&contour, &result);
- if (ok && gr->fill_poly){
+ if (ok && gr->fill_poly) {
draw_array(gr, result.p, result.count, GL_TRIANGLES);
free(result.p);
} else {
@@ -679,13 +631,10 @@ draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc,
}
}
-static void
-draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc,
- struct point *p, int w, int h)
-{
+static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
return;
}
set_color(gr, gc);
@@ -693,18 +642,16 @@ draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc,
graphics_priv_root->dirty = 1;
}
-static void
-display_text_draw(struct font_freetype_text *text,
- struct graphics_priv *gr, struct graphics_gc_priv *fg,
- struct graphics_gc_priv *bg, int color, struct point *p)
-{
+static void display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, struct graphics_gc_priv *fg,
+ struct graphics_gc_priv *bg, int color, struct point *p) {
int i, x, y, stride;
struct font_freetype_glyph *g, **gp;
unsigned char *shadow, *glyph;
struct color transparent = { 0x0000, 0x0000, 0x0000, 0x0000 };
- struct color black =
- { fg->fr * 65535, fg->fg * 65535, fg->fb * 65535,
- fg->fa * 65535 };
+ struct color black = {
+ fg->fr * 65535, fg->fg * 65535, fg->fb * 65535,
+ fg->fa * 65535
+ };
struct color white = { 0xffff, 0xffff, 0xffff, 0xffff };
if (bg) {
@@ -751,10 +698,7 @@ display_text_draw(struct font_freetype_text *text,
stride = (g->w + 2) * 4;
if (color) {
shadow = g_malloc(stride * (g->h + 2));
- gr->freetype_methods.get_shadow(g, shadow,
- stride,
- &white,
- &transparent);
+ gr->freetype_methods.get_shadow(g, shadow, stride, &white, &transparent);
struct point p;
p.x=((x + g->x) >> 6)-1;
@@ -780,13 +724,7 @@ display_text_draw(struct font_freetype_text *text,
if (bg) {
glyph =
g_malloc(stride * g->h * 4);
- gr->freetype_methods.get_glyph(g,
- glyph,
- stride
- * 4,
- &black,
- &white,
- &transparent);
+ gr->freetype_methods.get_glyph(g, glyph, stride * 4, &black, &white, &transparent);
struct point p;
p.x=(x + g->x) >> 6;
p.y=(y + g->y) >> 6;
@@ -796,11 +734,7 @@ display_text_draw(struct font_freetype_text *text,
}
stride *= 4;
glyph = g_malloc(stride * g->h);
- gr->freetype_methods.get_glyph(g, glyph,
- stride,
- &black,
- &white,
- &transparent);
+ gr->freetype_methods.get_glyph(g, glyph, stride, &black, &white, &transparent);
struct point p;
p.x=(x + g->x) >> 6;
p.y=(y + g->y) >> 6;
@@ -814,14 +748,11 @@ display_text_draw(struct font_freetype_text *text,
}
}
-static void
-draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg,
- struct graphics_gc_priv *bg, struct graphics_font_priv *font,
- char *text, struct point *p, int dx, int dy)
-{
+static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg,
+ struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
return;
}
@@ -829,14 +760,12 @@ draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg,
int color = 1;
if (!font) {
- dbg(lvl_error, "no font, returning\n");
+ dbg(lvl_error, "no font, returning");
return;
}
graphics_priv_root->dirty = 1;
- t = gr->freetype_methods.text_new(text,
- (struct font_freetype_font *)
- font, dx, dy);
+ t = gr->freetype_methods.text_new(text, (struct font_freetype_font *) font, dx, dy);
struct point p_eff;
p_eff.x = p->x;
@@ -847,34 +776,26 @@ draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg,
}
-static void
-draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg,
- struct point *p, struct graphics_image_priv *img)
-{
+static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p,
+ struct graphics_image_priv *img) {
draw_image_es(gr, p, img->img->w, img->img->h, img->img->pixels);
}
-static void
-draw_drag(struct graphics_priv *gr, struct point *p)
-{
+static void draw_drag(struct graphics_priv *gr, struct point *p) {
if (p) {
gr->p.x = p->x;
gr->p.y = p->y;
}
}
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
+static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
gr->background_gc = gc;
}
/*
* Draws map in background
*/
-static void
-draw_background(struct graphics_priv *gr)
-{
+static void draw_background(struct graphics_priv *gr) {
struct point p_eff;
GLf x[8];
@@ -908,25 +829,23 @@ draw_background(struct graphics_priv *gr)
Map and overlays are rendered in an offscreen buffer (See render to texture)
and are recomposed altogether at draw_mode_end request for root
*/
-static void
-draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
+static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode) {
GLfloat matrix[16];
struct graphics_priv *overlay = NULL;
int i;
- if (mode == draw_mode_begin){
+ if (mode == draw_mode_begin) {
// Should not be necessary...
// SDL_GL_MakeCurrent(gr->platform->eglwindow, gr->platform->eglcontext);
- if (gr->parent == NULL){
+ if (gr->parent == NULL) {
// Full redraw, reset drag position
gr->p.x = 0;
gr->p.y = 0;
}
// Need to setup appropriate projection matrix
- for (i = 0; i < 16 ; i++){
+ for (i = 0; i < 16 ; i++) {
matrix[i] = 0.0;
}
@@ -948,7 +867,7 @@ draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
if (mode == draw_mode_end && gr->parent == NULL) {
overlay = gr->overlays;
draw_background(gr);
- while(overlay){
+ while(overlay) {
if (gr->overlay_enabled)
draw_overlay(overlay);
overlay = overlay->next;
@@ -959,22 +878,16 @@ draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
gr->mode = mode;
}
-static int
-graphics_opengl_fullscreen(struct window *w, int on)
-{
+static int graphics_opengl_fullscreen(struct window *w, int on) {
return 1;
}
-static void
-graphics_opengl_disable_suspend(struct window *w)
-{
+static void graphics_opengl_disable_suspend(struct window *w) {
// No op
}
-static GLuint
-load_shader(const char *shader_source, GLenum type)
-{
+static GLuint load_shader(const char *shader_source, GLenum type) {
GLuint shader = glCreateShader(type);
glShaderSource(shader, 1, &shader_source, NULL);
@@ -983,28 +896,25 @@ load_shader(const char *shader_source, GLenum type)
return shader;
}
-static void *
-get_data(struct graphics_priv *this, const char *type)
-{
+static void *get_data(struct graphics_priv *this, const char *type) {
GLuint vertexShader;
GLuint fragmentShader;
struct window* win;
int i;
if (!strcmp(type, "gtk_widget")) {
- fprintf(stderr,
- "Currently GTK gui is not yet supported with EGL graphics driver\n");
+ fprintf(stderr, "Currently GTK gui is not yet supported with EGL graphics driver\n");
return NULL;
}
if(strcmp(type, "window") == 0) {
SDL_GL_MakeCurrent(this->platform->eglwindow, this->platform->eglcontext);
- glClearColor ( 0 , 0 , 0 , 1);
+ glClearColor ( 0, 0, 0, 1);
glClear ( GL_COLOR_BUFFER_BIT );
- callback_list_call_attr_2(graphics_priv_root->cbl, attr_resize,
- GINT_TO_POINTER(this->width), GINT_TO_POINTER(this->height));
+ callback_list_call_attr_2(graphics_priv_root->cbl, attr_resize, GINT_TO_POINTER(this->width),
+ GINT_TO_POINTER(this->height));
this->program = glCreateProgram();
vertexShader = load_shader(vertex_src, GL_VERTEX_SHADER);
@@ -1038,19 +948,14 @@ get_data(struct graphics_priv *this, const char *type)
}
-static void
-overlay_disable(struct graphics_priv *gr, int disable)
-{
+static void overlay_disable(struct graphics_priv *gr, int disable) {
gr->overlay_enabled = !disable;
gr->force_redraw = 1;
draw_mode(gr, draw_mode_end);
}
// Need more testing
-static void
-overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h,
- int wraparound)
-{
+static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound) {
int changed = 0;
int w2, h2;
@@ -1094,17 +999,15 @@ overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h,
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gr->overlay_texture, 0);
}
- callback_list_call_attr_2(gr->cbl, attr_resize,
- GINT_TO_POINTER(gr->width),
- GINT_TO_POINTER(gr->height));
+ callback_list_call_attr_2(gr->cbl, attr_resize, GINT_TO_POINTER(gr->width), GINT_TO_POINTER(gr->height));
}
}
static struct graphics_priv *overlay_new(struct graphics_priv *gr,
- struct graphics_methods *meth,
- struct point *p, int w, int h,
- int wraparound);
+ struct graphics_methods *meth,
+ struct point *p, int w, int h,
+ int wraparound);
static struct graphics_methods graphics_methods = {
graphics_destroy,
@@ -1132,9 +1035,7 @@ static struct graphics_methods graphics_methods = {
NULL, /* hide_native_keyboard */
};
-static struct graphics_priv *
-graphics_opengl_new_helper(struct graphics_methods *meth)
-{
+static struct graphics_priv *graphics_opengl_new_helper(struct graphics_methods *meth) {
struct font_priv *(*font_freetype_new) (void *meth);
font_freetype_new = plugin_get_category_font("freetype");
@@ -1150,16 +1051,14 @@ graphics_opengl_new_helper(struct graphics_methods *meth)
meth->font_new =
(struct graphics_font_priv *
(*)(struct graphics_priv *, struct graphics_font_methods *,
- char *, int, int)) this->freetype_methods.font_new;
+ char *, int, int)) this->freetype_methods.font_new;
meth->get_text_bbox =
(void (*) (struct graphics_priv *, struct graphics_font_priv *,
- char *, int, int, struct point*, int)) this->freetype_methods.get_text_bbox;
+ char *, int, int, struct point*, int)) this->freetype_methods.get_text_bbox;
return this;
}
-static void
-create_framebuffer_texture(struct graphics_priv *gr)
-{
+static void create_framebuffer_texture(struct graphics_priv *gr) {
GLenum status;
// Prepare a new framebuffer object
glGenFramebuffers(1, &gr->framebuffer_name);
@@ -1180,10 +1079,8 @@ create_framebuffer_texture(struct graphics_priv *gr)
}
}
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth,
- struct point *p, int w, int h, int wraparound)
-{
+static struct graphics_priv *overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p,
+ int w, int h, int wraparound) {
struct graphics_priv *this = graphics_opengl_new_helper(meth);
this->p.x = p->x;
@@ -1219,8 +1116,7 @@ overlay_new(struct graphics_priv *gr, struct graphics_methods *meth,
}
-static gboolean graphics_sdl_idle(void *data)
-{
+static gboolean graphics_sdl_idle(void *data) {
struct graphics_priv *gr = (struct graphics_priv *)data;
struct point p;
SDL_Event ev;
@@ -1230,17 +1126,14 @@ static gboolean graphics_sdl_idle(void *data)
char keycode;
// Process SDL events (KEYS + MOUSE)
- while(1)
- {
- ret = SDL_PollEvent(&ev);
+ while(1) {
+ ret = SDL_PollEvent(&ev);
- if(!ret)
- break;
+ if(!ret)
+ break;
- switch(ev.type)
- {
- case SDL_MOUSEMOTION:
- {
+ switch(ev.type) {
+ case SDL_MOUSEMOTION: {
p.x = ev.motion.x;
p.y = ev.motion.y;
//gr->force_redraw = 1;
@@ -1248,82 +1141,68 @@ static gboolean graphics_sdl_idle(void *data)
break;
}
- case SDL_KEYDOWN:
- {
+ case SDL_KEYDOWN: {
memset(keybuf, 0, sizeof(keybuf));
- switch(ev.key.keysym.sym)
- {
+ switch(ev.key.keysym.sym) {
case SDLK_F1:
graphics_priv_root->fill_poly = !graphics_priv_root->fill_poly;
break;
case SDLK_F2:
graphics_priv_root->show_overlays = !graphics_priv_root->show_overlays;
break;
- case SDLK_LEFT:
- {
+ case SDLK_LEFT: {
keybuf[0] = NAVIT_KEY_LEFT;
break;
- }
- case SDLK_RIGHT:
- {
+ }
+ case SDLK_RIGHT: {
keybuf[0] = NAVIT_KEY_RIGHT;
break;
- }
- case SDLK_BACKSPACE:
- {
+ }
+ case SDLK_BACKSPACE: {
keybuf[0] = NAVIT_KEY_BACKSPACE;
break;
- }
- case SDLK_RETURN:
- {
+ }
+ case SDLK_RETURN: {
keybuf[0] = NAVIT_KEY_RETURN;
break;
- }
- case SDLK_DOWN:
- {
+ }
+ case SDLK_DOWN: {
keybuf[0] = NAVIT_KEY_DOWN;
break;
- }
- case SDLK_PAGEUP:
- {
+ }
+ case SDLK_PAGEUP: {
keybuf[0] = NAVIT_KEY_ZOOM_OUT;
break;
- }
- case SDLK_UP:
- {
+ }
+ case SDLK_UP: {
keybuf[0] = NAVIT_KEY_UP;
break;
- }
- case SDLK_PAGEDOWN:
- {
+ }
+ case SDLK_PAGEDOWN: {
keybuf[0] = NAVIT_KEY_ZOOM_IN;
break;
- }
- case SDLK_ESCAPE:
- {
+ }
+ case SDLK_ESCAPE: {
USERWANTSTOQUIT = 1;
break;
- }
- default:
- {
+ }
+ default: {
/* return unicode chars when they can be converted to ascii */
// Need more work...
keycode = ev.key.keysym.sym;
keybuf[0] = keycode <= 127 ? keycode : 0;
break;
- }
+ }
}
if (keybuf[0]) {
callback_list_call_attr_1(gr->cbl, attr_keypress, (void *)keybuf);
}
break;
}
- case SDL_KEYUP:
- {
+ case SDL_KEYUP: {
break;
}
- case SDL_MOUSEBUTTONDOWN:
- {
+ case SDL_MOUSEBUTTONDOWN: {
p.x = ev.button.x;
p.y = ev.button.y;
graphics_priv_root->force_redraw = 1;
@@ -1331,26 +1210,23 @@ static gboolean graphics_sdl_idle(void *data)
break;
}
- case SDL_MOUSEBUTTONUP:
- {
+ case SDL_MOUSEBUTTONUP: {
p.x = ev.button.x;
p.y = ev.button.y;
callback_list_call_attr_3(gr->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER((int)ev.button.button), (void *)&p);
break;
}
- case SDL_QUIT:
- {
+ case SDL_QUIT: {
break;
}
- default:
- {
+ default: {
break;
}
- }
+ }
}
- if (USERWANTSTOQUIT){
+ if (USERWANTSTOQUIT) {
SDL_Quit();
exit(0);
}
@@ -1359,10 +1235,8 @@ static gboolean graphics_sdl_idle(void *data)
}
-static struct graphics_priv *
-graphics_opengl_new(struct navit *nav, struct graphics_methods *meth,
- struct attr **attrs, struct callback_list *cbl)
-{
+static struct graphics_priv *graphics_opengl_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs,
+ struct callback_list *cbl) {
struct attr *attr;
if (!event_request_system("glib", "graphics_opengl_new"))
return NULL;
@@ -1404,7 +1278,7 @@ graphics_opengl_new(struct navit *nav, struct graphics_methods *meth,
// SDL Init
int sdl_status = SDL_Init(SDL_INIT_VIDEO|SDL_INIT_EVENTS);
- if (sdl_status != 0){
+ if (sdl_status != 0) {
fprintf(stderr, "\nUnable to initialize SDL: %i %s\n", sdl_status, SDL_GetError() );
exit(1);
}
@@ -1421,13 +1295,13 @@ graphics_opengl_new(struct navit *nav, struct graphics_methods *meth,
SDL_GL_SetSwapInterval(0);
ret->eglwindow = SDL_CreateWindow(
- "Navit EGL", // window title
- SDL_WINDOWPOS_UNDEFINED, // initial x position
- SDL_WINDOWPOS_UNDEFINED, // initial y position
- this->width, // width, in pixels
- this->height, // height, in pixels
- flags
- );
+ "Navit EGL", // window title
+ SDL_WINDOWPOS_UNDEFINED, // initial x position
+ SDL_WINDOWPOS_UNDEFINED, // initial y position
+ this->width, // width, in pixels
+ this->height, // height, in pixels
+ flags
+ );
if (ret->eglwindow == NULL) {
fprintf(stderr, "\nUnable to initialize SDL window: %s\n", SDL_GetError() );
@@ -1435,7 +1309,7 @@ graphics_opengl_new(struct navit *nav, struct graphics_methods *meth,
}
ret->eglcontext = SDL_GL_CreateContext(ret->eglwindow);
- if (ret->eglcontext == NULL){
+ if (ret->eglcontext == NULL) {
printf("EGL context creation failed\n");
goto error;
}
@@ -1450,9 +1324,6 @@ error:
return NULL;
}
-void
-plugin_init(void)
-{
+void plugin_init(void) {
plugin_register_category_graphics("egl", graphics_opengl_new);
}
-
diff --git a/navit/graphics/gd/CMakeLists.txt b/navit/graphics/gd/CMakeLists.txt
index 5f8f6ec7a..cf411b9ae 100644
--- a/navit/graphics/gd/CMakeLists.txt
+++ b/navit/graphics/gd/CMakeLists.txt
@@ -1,3 +1,3 @@
include_directories(${GD_INCLUDE_DIR})
-module_add_library(graphics_gd graphics_gd.c)
+module_add_library(graphics_gd graphics_gd.c)
target_link_libraries(graphics_gd ${GD_LIBS})
diff --git a/navit/graphics/gd/graphics_gd.c b/navit/graphics/gd/graphics_gd.c
index 3ef6c520b..7c8a45693 100644
--- a/navit/graphics/gd/graphics_gd.c
+++ b/navit/graphics/gd/graphics_gd.c
@@ -48,8 +48,8 @@
#endif
struct shmem_header {
- int flag;
- int w,h,bpp;
+ int flag;
+ int w,h,bpp;
};
#ifdef HAVE_XPM
@@ -65,821 +65,752 @@ static void add_overlays(struct graphics_priv *overlay, gdImagePtr im);
#include <X11/xpm.h>
-BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm (char *filename)
-{
- XpmInfo info;
- XpmImage image;
- int i, j, k, number;
- char buf[5];
- gdImagePtr im = 0;
- int *pointer;
- int red = 0, green = 0, blue = 0, alpha = 0;
- int *colors;
- int ret;
- ret = XpmReadFileToXpmImage (filename, &image, &info);
- if (ret != XpmSuccess)
- return 0;
-
- if (!(im = gdImageCreate (image.width, image.height)))
- return 0;
-
- number = image.ncolors;
- if (overflow2(sizeof (int), number)) {
- return 0;
- }
- colors = (int *) gdMalloc (sizeof (int) * number);
- if (colors == NULL)
- return (0);
- for (i = 0; i < number; i++)
- {
- alpha = 0;
- switch (strlen (image.colorTable[i].c_color))
- {
- case 4:
- if (!strcasecmp(image.colorTable[i].c_color,"none")) {
- red = 0;
- green = 0;
- blue = 0;
- alpha = 127;
- } else {
- buf[1] = '\0';
- buf[0] = image.colorTable[i].c_color[1];
- red = strtol (buf, NULL, 16);
-
- buf[0] = image.colorTable[i].c_color[3];
- green = strtol (buf, NULL, 16);
-
- buf[0] = image.colorTable[i].c_color[5];
- blue = strtol (buf, NULL, 16);
- }
- break;
- case 7:
- buf[2] = '\0';
- buf[0] = image.colorTable[i].c_color[1];
- buf[1] = image.colorTable[i].c_color[2];
- red = strtol (buf, NULL, 16);
-
- buf[0] = image.colorTable[i].c_color[3];
- buf[1] = image.colorTable[i].c_color[4];
- green = strtol (buf, NULL, 16);
-
- buf[0] = image.colorTable[i].c_color[5];
- buf[1] = image.colorTable[i].c_color[6];
- blue = strtol (buf, NULL, 16);
- break;
- case 10:
- buf[3] = '\0';
- buf[0] = image.colorTable[i].c_color[1];
- buf[1] = image.colorTable[i].c_color[2];
- buf[2] = image.colorTable[i].c_color[3];
- red = strtol (buf, NULL, 16);
- red /= 64;
-
- buf[0] = image.colorTable[i].c_color[4];
- buf[1] = image.colorTable[i].c_color[5];
- buf[2] = image.colorTable[i].c_color[6];
- green = strtol (buf, NULL, 16);
- green /= 64;
-
- buf[0] = image.colorTable[i].c_color[7];
- buf[1] = image.colorTable[i].c_color[8];
- buf[2] = image.colorTable[i].c_color[9];
- blue = strtol (buf, NULL, 16);
- blue /= 64;
- break;
- case 13:
- buf[4] = '\0';
- buf[0] = image.colorTable[i].c_color[1];
- buf[1] = image.colorTable[i].c_color[2];
- buf[2] = image.colorTable[i].c_color[3];
- buf[3] = image.colorTable[i].c_color[4];
- red = strtol (buf, NULL, 16);
- red /= 256;
-
- buf[0] = image.colorTable[i].c_color[5];
- buf[1] = image.colorTable[i].c_color[6];
- buf[2] = image.colorTable[i].c_color[7];
- buf[3] = image.colorTable[i].c_color[8];
- green = strtol (buf, NULL, 16);
- green /= 256;
-
- buf[0] = image.colorTable[i].c_color[9];
- buf[1] = image.colorTable[i].c_color[10];
- buf[2] = image.colorTable[i].c_color[11];
- buf[3] = image.colorTable[i].c_color[12];
- blue = strtol (buf, NULL, 16);
- blue /= 256;
- break;
- }
-
-
- colors[i] = gdImageColorResolveAlpha(im, red, green, blue, alpha);
- if (colors[i] == -1)
- fprintf (stderr, "ARRRGH\n");
+BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm (char *filename) {
+ XpmInfo info;
+ XpmImage image;
+ int i, j, k, number;
+ char buf[5];
+ gdImagePtr im = 0;
+ int *pointer;
+ int red = 0, green = 0, blue = 0, alpha = 0;
+ int *colors;
+ int ret;
+ ret = XpmReadFileToXpmImage (filename, &image, &info);
+ if (ret != XpmSuccess)
+ return 0;
+
+ if (!(im = gdImageCreate (image.width, image.height)))
+ return 0;
+
+ number = image.ncolors;
+ if (overflow2(sizeof (int), number)) {
+ return 0;
+ }
+ colors = (int *) gdMalloc (sizeof (int) * number);
+ if (colors == NULL)
+ return (0);
+ for (i = 0; i < number; i++) {
+ alpha = 0;
+ switch (strlen (image.colorTable[i].c_color)) {
+ case 4:
+ if (!strcasecmp(image.colorTable[i].c_color,"none")) {
+ red = 0;
+ green = 0;
+ blue = 0;
+ alpha = 127;
+ } else {
+ buf[1] = '\0';
+ buf[0] = image.colorTable[i].c_color[1];
+ red = strtol (buf, NULL, 16);
+
+ buf[0] = image.colorTable[i].c_color[3];
+ green = strtol (buf, NULL, 16);
+
+ buf[0] = image.colorTable[i].c_color[5];
+ blue = strtol (buf, NULL, 16);
+ }
+ break;
+ case 7:
+ buf[2] = '\0';
+ buf[0] = image.colorTable[i].c_color[1];
+ buf[1] = image.colorTable[i].c_color[2];
+ red = strtol (buf, NULL, 16);
+
+ buf[0] = image.colorTable[i].c_color[3];
+ buf[1] = image.colorTable[i].c_color[4];
+ green = strtol (buf, NULL, 16);
+
+ buf[0] = image.colorTable[i].c_color[5];
+ buf[1] = image.colorTable[i].c_color[6];
+ blue = strtol (buf, NULL, 16);
+ break;
+ case 10:
+ buf[3] = '\0';
+ buf[0] = image.colorTable[i].c_color[1];
+ buf[1] = image.colorTable[i].c_color[2];
+ buf[2] = image.colorTable[i].c_color[3];
+ red = strtol (buf, NULL, 16);
+ red /= 64;
+
+ buf[0] = image.colorTable[i].c_color[4];
+ buf[1] = image.colorTable[i].c_color[5];
+ buf[2] = image.colorTable[i].c_color[6];
+ green = strtol (buf, NULL, 16);
+ green /= 64;
+
+ buf[0] = image.colorTable[i].c_color[7];
+ buf[1] = image.colorTable[i].c_color[8];
+ buf[2] = image.colorTable[i].c_color[9];
+ blue = strtol (buf, NULL, 16);
+ blue /= 64;
+ break;
+ case 13:
+ buf[4] = '\0';
+ buf[0] = image.colorTable[i].c_color[1];
+ buf[1] = image.colorTable[i].c_color[2];
+ buf[2] = image.colorTable[i].c_color[3];
+ buf[3] = image.colorTable[i].c_color[4];
+ red = strtol (buf, NULL, 16);
+ red /= 256;
+
+ buf[0] = image.colorTable[i].c_color[5];
+ buf[1] = image.colorTable[i].c_color[6];
+ buf[2] = image.colorTable[i].c_color[7];
+ buf[3] = image.colorTable[i].c_color[8];
+ green = strtol (buf, NULL, 16);
+ green /= 256;
+
+ buf[0] = image.colorTable[i].c_color[9];
+ buf[1] = image.colorTable[i].c_color[10];
+ buf[2] = image.colorTable[i].c_color[11];
+ buf[3] = image.colorTable[i].c_color[12];
+ blue = strtol (buf, NULL, 16);
+ blue /= 256;
+ break;
+ }
+
+
+ colors[i] = gdImageColorResolveAlpha(im, red, green, blue, alpha);
+ if (colors[i] == -1)
+ fprintf (stderr, "ARRRGH\n");
}
- pointer = (int *) image.data;
- for (i = 0; i < image.height; i++)
- {
- for (j = 0; j < image.width; j++)
- {
- k = *pointer++;
- gdImageSetPixel (im, j, i, colors[k]);
- }
+ pointer = (int *) image.data;
+ for (i = 0; i < image.height; i++) {
+ for (j = 0; j < image.width; j++) {
+ k = *pointer++;
+ gdImageSetPixel (im, j, i, colors[k]);
+ }
}
- gdFree (colors);
- return (im);
+ gdFree (colors);
+ return (im);
}
#endif
struct graphics_priv {
- gdImagePtr im;
- int w,h,flags,overlay,shmkey,shmsize,shmoffset;
- void *shm;
- struct shmem_header *shm_header;
- struct point p;
- struct callback *cb;
- struct callback_list *cbl;
- struct navit *nav;
- struct graphics_gc_priv *background;
- struct font_freetype_methods freetype_methods;
- struct window window;
- struct graphics_data_image image;
- struct graphics_priv *next,*overlays;
- GList *sockets;
+ gdImagePtr im;
+ int w,h,flags,overlay,shmkey,shmsize,shmoffset;
+ void *shm;
+ struct shmem_header *shm_header;
+ struct point p;
+ struct callback *cb;
+ struct callback_list *cbl;
+ struct navit *nav;
+ struct graphics_gc_priv *background;
+ struct font_freetype_methods freetype_methods;
+ struct window window;
+ struct graphics_data_image image;
+ struct graphics_priv *next,*overlays;
+ GList *sockets;
};
struct graphics_gc_priv {
- struct graphics_priv *gr;
- int color;
- int bgcolor;
- int width;
- struct color color2;
- unsigned char *dash_list;
- int dash_count;
- int dash_list_len;
+ struct graphics_priv *gr;
+ int color;
+ int bgcolor;
+ int width;
+ struct color color2;
+ unsigned char *dash_list;
+ int dash_count;
+ int dash_list_len;
};
struct graphics_image_priv {
- gdImagePtr im;
+ gdImagePtr im;
};
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
- gr->freetype_methods.destroy();
- g_free(gr);
+static void graphics_destroy(struct graphics_priv *gr) {
+ gr->freetype_methods.destroy();
+ g_free(gr);
}
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
- if (gc->color != -1)
- gdImageColorDeallocate(gc->gr->im, gc->color);
- if (gc->bgcolor != -1)
- gdImageColorDeallocate(gc->gr->im, gc->bgcolor);
- g_free(gc->dash_list);
- g_free(gc);
+static void gc_destroy(struct graphics_gc_priv *gc) {
+ if (gc->color != -1)
+ gdImageColorDeallocate(gc->gr->im, gc->color);
+ if (gc->bgcolor != -1)
+ gdImageColorDeallocate(gc->gr->im, gc->bgcolor);
+ g_free(gc->dash_list);
+ g_free(gc);
}
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
- gc->width=w;
+static void gc_set_linewidth(struct graphics_gc_priv *gc, int w) {
+ gc->width=w;
}
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
-{
- int i,count=0;
- g_free(gc->dash_list);
- gc->dash_list=g_new(unsigned char, n);
- for (i = 0 ; i < n ; i++) {
- gc->dash_list[i]=dash_list[i];
- count+=dash_list[i];
- }
- gc->dash_list_len=n;
- gc->dash_count=count;
+static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n) {
+ int i,count=0;
+ g_free(gc->dash_list);
+ gc->dash_list=g_new(unsigned char, n);
+ for (i = 0 ; i < n ; i++) {
+ gc->dash_list[i]=dash_list[i];
+ count+=dash_list[i];
+ }
+ gc->dash_list_len=n;
+ gc->dash_count=count;
}
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
- gc->color2=*c;
- gc->color=gdImageColorAllocate(gc->gr->im, c->r>>8, c->g>>8, c->b>>8);
+static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c) {
+ gc->color2=*c;
+ gc->color=gdImageColorAllocate(gc->gr->im, c->r>>8, c->g>>8, c->b>>8);
}
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
- gc->bgcolor=gdImageColorAllocate(gc->gr->im, c->r>>8, c->g>>8, c->b>>8);
+static void gc_set_background(struct graphics_gc_priv *gc, struct color *c) {
+ gc->bgcolor=gdImageColorAllocate(gc->gr->im, c->r>>8, c->g>>8, c->b>>8);
}
static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
+ gc_destroy,
+ gc_set_linewidth,
+ gc_set_dashes,
+ gc_set_foreground,
+ gc_set_background
};
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- struct graphics_gc_priv *ret=g_new0(struct graphics_gc_priv, 1);
- ret->gr=gr;
- ret->width=1;
- ret->color=-1;
- ret->bgcolor=-1;
- *meth=gc_methods;
- return ret;
-}
-
-
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot, int rotation)
-{
- FILE *file;
- struct graphics_image_priv *ret=NULL;
- gdImagePtr im=NULL;
- int len;
-
- if (! name)
- return NULL;
- len=strlen(name);
- if (len < 4)
- return NULL;
- file=fopen(name,"r");
- if (file) {
- if (!strcmp(name+len-4,".png"))
+static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) {
+ struct graphics_gc_priv *ret=g_new0(struct graphics_gc_priv, 1);
+ ret->gr=gr;
+ ret->width=1;
+ ret->color=-1;
+ ret->bgcolor=-1;
+ *meth=gc_methods;
+ return ret;
+}
+
+
+static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot, int rotation) {
+ FILE *file;
+ struct graphics_image_priv *ret=NULL;
+ gdImagePtr im=NULL;
+ int len;
+
+ if (! name)
+ return NULL;
+ len=strlen(name);
+ if (len < 4)
+ return NULL;
+ file=fopen(name,"r");
+ if (file) {
+ if (!strcmp(name+len-4,".png"))
#ifdef HAVE_GRAPHICS_GD_PNG
- im=gdImageCreateFromPng(file);
+ im=gdImageCreateFromPng(file);
#else
- im=NULL;
+ im=NULL;
#endif
- else if (!strcmp(name+len-4,".xpm"))
- im=gdImageCreateFromXpm(name);
- else if (!strcmp(name+len-4,".gif")) {
- im=gdImageCreateFromGif(file);
- }
- fclose(file);
- }
- if (im) {
- ret=g_new0(struct graphics_image_priv, 1);
- ret->im=im;
- *w=im->sx;
- *h=im->sy;
- hot->x=im->sx/2;
- hot->y=im->sy/2;
- }
- return ret;
-}
-
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int color[gc->dash_count],cc;
- int i,j,k=0;
-
- if (gc->dash_count) {
- cc=gc->color;
- for (i = 0 ; i < gc->dash_list_len ; i++) {
- for (j = 0 ; j < gc->dash_list[i] ; j++) {
- color[k++]=cc;
- }
- if (cc == gdTransparent)
- cc=gc->color;
- else
- cc=gdTransparent;
- }
- gdImageSetStyle(gr->im, color, gc->dash_count);
- }
- gdImageSetThickness(gr->im, gc->width);
- cc=gc->color;
- if (gr->flags & 8) {
- gdImageSetAntiAliased(gr->im, cc);
- cc=gdAntiAliased;
- }
+ else if (!strcmp(name+len-4,".xpm"))
+ im=gdImageCreateFromXpm(name);
+ else if (!strcmp(name+len-4,".gif")) {
+ im=gdImageCreateFromGif(file);
+ }
+ fclose(file);
+ }
+ if (im) {
+ ret=g_new0(struct graphics_image_priv, 1);
+ ret->im=im;
+ *w=im->sx;
+ *h=im->sy;
+ hot->x=im->sx/2;
+ hot->y=im->sy/2;
+ }
+ return ret;
+}
+
+static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ int color[gc->dash_count],cc;
+ int i,j,k=0;
+
+ if (gc->dash_count) {
+ cc=gc->color;
+ for (i = 0 ; i < gc->dash_list_len ; i++) {
+ for (j = 0 ; j < gc->dash_list[i] ; j++) {
+ color[k++]=cc;
+ }
+ if (cc == gdTransparent)
+ cc=gc->color;
+ else
+ cc=gdTransparent;
+ }
+ gdImageSetStyle(gr->im, color, gc->dash_count);
+ }
+ gdImageSetThickness(gr->im, gc->width);
+ cc=gc->color;
+ if (gr->flags & 8) {
+ gdImageSetAntiAliased(gr->im, cc);
+ cc=gdAntiAliased;
+ }
#ifdef GD_NO_IMAGE_OPEN_POLYGON
- for (i = 0 ; i < count-1 ; i++)
- gdImageLine(gr->im, p[i].x, p[i].y, p[i+1].x, p[i+1].y, gc->dash_count ? gdStyled : cc);
+ for (i = 0 ; i < count-1 ; i++)
+ gdImageLine(gr->im, p[i].x, p[i].y, p[i+1].x, p[i+1].y, gc->dash_count ? gdStyled : cc);
#else
- gdImageOpenPolygon(gr->im, (gdPointPtr) p, count, gc->dash_count ? gdStyled : cc);
+ gdImageOpenPolygon(gr->im, (gdPointPtr) p, count, gc->dash_count ? gdStyled : cc);
#endif
}
-static void
-draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int cc=gc->color;
- if (gr->flags & 8) {
- gdImageSetAntiAliased(gr->im, cc);
- cc=gdAntiAliased;
- }
- gdImageFilledPolygon(gr->im, (gdPointPtr) p, count, cc);
-}
-
-static void
-draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
- int cc=gc->color;
- if (gr->flags & 8) {
- gdImageSetAntiAliased(gr->im, cc);
- cc=gdAntiAliased;
- }
- gdImageFilledRectangle(gr->im, p->x, p->y, p->x+w, p->y+h, cc);
-}
-
-static void
-draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
- int cc=gc->color;
- if (gr->flags & 8) {
- gdImageSetAntiAliased(gr->im, cc);
- cc=gdAntiAliased;
- }
- gdImageSetThickness(gr->im, gc->width);
- gdImageArc(gr->im, p->x, p->y, r, r, 0, 360, cc);
-}
-
-
-static void
-draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
- struct font_freetype_text *t;
- struct font_freetype_glyph *g, **gp;
- gdImagePtr im;
- int i,x,y,w,h;
- t=gr->freetype_methods.text_new(text, (struct font_freetype_font *)font, dx, dy);
- struct color fgc,bgc,transparent = {0x0, 0x0, 0x0, 0x7f7f};
- fgc=fg->color2;
- fgc.a=0;
-
- if (bg) {
- bgc=bg->color2;
- bgc.a=0;
- x=p->x << 6;
- y=p->y << 6;
- gp=t->glyph;
- i=t->glyph_count;
- while (i-- > 0)
- {
- g=*gp++;
- w=g->w;
- h=g->h;
- if (w && h) {
- im=gdImageCreateTrueColor(w+2, h+2);
- gr->freetype_methods.get_shadow(g,(unsigned char *)(im->tpixels),0,&bgc,&transparent);
- gdImageCopy(gr->im, im, ((x+g->x)>>6)-1, ((y+g->y)>>6)-1, 0, 0, w+2, h+2);
- gdImageDestroy(im);
- }
- x+=g->dx;
- y+=g->dy;
- }
- } else
- bgc=transparent;
- x=p->x << 6;
- y=p->y << 6;
- gp=t->glyph;
- i=t->glyph_count;
- while (i-- > 0)
- {
- g=*gp++;
- w=g->w;
- h=g->h;
- if (w && h) {
- im=gdImageCreateTrueColor(w, h);
- gr->freetype_methods.get_glyph(g,(unsigned char *)(im->tpixels),0,&fgc,&bgc,&transparent);
- gdImageCopy(gr->im, im, (x+g->x)>>6, (y+g->y)>>6, 0, 0, w, h);
- gdImageDestroy(im);
- }
- x+=g->dx;
- y+=g->dy;
- }
- gr->freetype_methods.text_destroy(t);
-}
-
-static void
-draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
- gdImageCopy(gr->im, img->im, p->x, p->y, 0, 0, img->im->sx, img->im->sy);
-}
-
-static void
-draw_drag(struct graphics_priv *gr, struct point *p)
-{
- if (p)
- gr->p=*p;
- else {
- gr->p.x=0;
- gr->p.y=0;
- }
-}
-
-
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
- gr->background=gc;
-}
-
-static void
-draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
- FILE *pngout;
+static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ int cc=gc->color;
+ if (gr->flags & 8) {
+ gdImageSetAntiAliased(gr->im, cc);
+ cc=gdAntiAliased;
+ }
+ gdImageFilledPolygon(gr->im, (gdPointPtr) p, count, cc);
+}
+
+static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
+ int cc=gc->color;
+ if (gr->flags & 8) {
+ gdImageSetAntiAliased(gr->im, cc);
+ cc=gdAntiAliased;
+ }
+ gdImageFilledRectangle(gr->im, p->x, p->y, p->x+w, p->y+h, cc);
+}
+
+static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r) {
+ int cc=gc->color;
+ if (gr->flags & 8) {
+ gdImageSetAntiAliased(gr->im, cc);
+ cc=gdAntiAliased;
+ }
+ gdImageSetThickness(gr->im, gc->width);
+ gdImageArc(gr->im, p->x, p->y, r, r, 0, 360, cc);
+}
+
+
+static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
+ struct font_freetype_text *t;
+ struct font_freetype_glyph *g, **gp;
+ gdImagePtr im;
+ int i,x,y,w,h;
+ t=gr->freetype_methods.text_new(text, (struct font_freetype_font *)font, dx, dy);
+ struct color fgc,bgc,transparent = {0x0, 0x0, 0x0, 0x7f7f};
+ fgc=fg->color2;
+ fgc.a=0;
+
+ if (bg) {
+ bgc=bg->color2;
+ bgc.a=0;
+ x=p->x << 6;
+ y=p->y << 6;
+ gp=t->glyph;
+ i=t->glyph_count;
+ while (i-- > 0) {
+ g=*gp++;
+ w=g->w;
+ h=g->h;
+ if (w && h) {
+ im=gdImageCreateTrueColor(w+2, h+2);
+ gr->freetype_methods.get_shadow(g,(unsigned char *)(im->tpixels),0,&bgc,&transparent);
+ gdImageCopy(gr->im, im, ((x+g->x)>>6)-1, ((y+g->y)>>6)-1, 0, 0, w+2, h+2);
+ gdImageDestroy(im);
+ }
+ x+=g->dx;
+ y+=g->dy;
+ }
+ } else
+ bgc=transparent;
+ x=p->x << 6;
+ y=p->y << 6;
+ gp=t->glyph;
+ i=t->glyph_count;
+ while (i-- > 0) {
+ g=*gp++;
+ w=g->w;
+ h=g->h;
+ if (w && h) {
+ im=gdImageCreateTrueColor(w, h);
+ gr->freetype_methods.get_glyph(g,(unsigned char *)(im->tpixels),0,&fgc,&bgc,&transparent);
+ gdImageCopy(gr->im, im, (x+g->x)>>6, (y+g->y)>>6, 0, 0, w, h);
+ gdImageDestroy(im);
+ }
+ x+=g->dx;
+ y+=g->dy;
+ }
+ gr->freetype_methods.text_destroy(t);
+}
+
+static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img) {
+ gdImageCopy(gr->im, img->im, p->x, p->y, 0, 0, img->im->sx, img->im->sy);
+}
+
+static void draw_drag(struct graphics_priv *gr, struct point *p) {
+ if (p)
+ gr->p=*p;
+ else {
+ gr->p.x=0;
+ gr->p.y=0;
+ }
+}
+
+
+static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
+ gr->background=gc;
+}
+
+static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode) {
+ FILE *pngout;
#if 0
- if (mode == draw_mode_begin && gr->background) {
- gdImageFilledRectangle(gr->im, 0, 0, gr->w, gr->h, gr->background->color);
- }
+ if (mode == draw_mode_begin && gr->background) {
+ gdImageFilledRectangle(gr->im, 0, 0, gr->w, gr->h, gr->background->color);
+ }
#endif
- if (mode == draw_mode_end && !gr->overlay) {
- add_overlays(gr->overlays, gr->im);
- if (!(gr->flags & 1)) {
+ if (mode == draw_mode_end && !gr->overlay) {
+ add_overlays(gr->overlays, gr->im);
+ if (!(gr->flags & 1)) {
#ifdef HAVE_GRAPHICS_GD_PNG
- rename("test.png","test.png.old");
- pngout=fopen("test.png", "wb");
- gdImagePng(gr->im, pngout);
- fclose(pngout);
+ rename("test.png","test.png.old");
+ pngout=fopen("test.png", "wb");
+ gdImagePng(gr->im, pngout);
+ fclose(pngout);
#else
- rename("test.gd","test.gd.old");
- pngout=fopen("test.gd", "wb");
- gdImageGd(gr->im, pngout);
- fclose(pngout);
+ rename("test.gd","test.gd.old");
+ pngout=fopen("test.gd", "wb");
+ gdImageGd(gr->im, pngout);
+ fclose(pngout);
#endif
- }
- if (gr->flags & 2) {
- struct shmem_header *next=shm_next(gr);
- gr->shm_header->flag=1;
- dbg(lvl_debug,"next flag is %d\n",next->flag);
- if (!next->flag) {
- gr->shm_header=next;
- image_setup(gr);
- }
- }
+ }
+ if (gr->flags & 2) {
+ struct shmem_header *next=shm_next(gr);
+ gr->shm_header->flag=1;
+ dbg(lvl_debug,"next flag is %d",next->flag);
+ if (!next->flag) {
+ gr->shm_header=next;
+ image_setup(gr);
+ }
+ }
#ifdef HAVE_GRAPHICS_GD_PNG
#ifdef HAVE_SOCKET
- if (gr->flags & 4) {
- int size, size_written;
- void *data=gdImagePngPtr(gr->im, &size);
- GList *sockets=gr->sockets;
- while (sockets) {
- int fd=socket(PF_INET, SOCK_STREAM, 0);
- if (fd < 0) {
- dbg(lvl_error,"socket failed\n");
- } else {
- if (connect(fd, (struct sockaddr *)sockets->data, sizeof(struct sockaddr_in)) < 0) {
- dbg(lvl_error,"connect failed\n");
- } else {
- size_written=write(fd, data, size);
- dbg(lvl_debug,"size %d vs %d\n",size, size_written);
- if (shutdown(fd, SHUT_RDWR) < 0)
- dbg(lvl_error,"shutdown failed\n");
- }
- close(fd);
- }
- sockets=g_list_next(sockets);
- }
- gdFree(data);
- }
+ if (gr->flags & 4) {
+ int size, size_written;
+ void *data=gdImagePngPtr(gr->im, &size);
+ GList *sockets=gr->sockets;
+ while (sockets) {
+ int fd=socket(PF_INET, SOCK_STREAM, 0);
+ if (fd < 0) {
+ dbg(lvl_error,"socket failed");
+ } else {
+ if (connect(fd, (struct sockaddr *)sockets->data, sizeof(struct sockaddr_in)) < 0) {
+ dbg(lvl_error,"connect failed");
+ } else {
+ size_written=write(fd, data, size);
+ dbg(lvl_debug,"size %d vs %d",size, size_written);
+ if (shutdown(fd, SHUT_RDWR) < 0)
+ dbg(lvl_error,"shutdown failed");
+ }
+ close(fd);
+ }
+ sockets=g_list_next(sockets);
+ }
+ gdFree(data);
+ }
#endif
#endif
- }
+ }
}
static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound);
-static void
-add_overlays(struct graphics_priv *overlay, gdImagePtr im)
-{
- while (overlay) {
- if (overlay->background) {
- gdImagePtr res,src;
- int y,x;
- int bgcol=overlay->background->color;
- res=gdImageCreateTrueColor(overlay->w,overlay->h);
- src=gdImageCreateTrueColor(overlay->w,overlay->h);
- gdImageCopy(src, im, 0, 0, overlay->p.x, overlay->p.y, overlay->w, overlay->h);
- for (y = 0 ; y < overlay->h ; y++) {
- unsigned int *res_line=res->tpixels[y];
- unsigned int *src_line=src->tpixels[y];
- unsigned int *overlay_line=overlay->im->tpixels[y];
- for (x = 0 ; x < overlay->w ; x++) {
- if (overlay_line[x] != bgcol)
- res_line[x]=overlay_line[x];
- else
- res_line[x]=src_line[x];
- }
- }
- gdImageCopy(im, res, overlay->p.x, overlay->p.y, 0, 0, overlay->w, overlay->h);
- gdImageDestroy(res);
- gdImageDestroy(src);
- } else
- gdImageCopy(im, overlay->im, overlay->p.x, overlay->p.y, 0, 0, overlay->w, overlay->h);
- overlay=overlay->next;
- }
-}
-
-static void *
-get_data(struct graphics_priv *this, char *type)
-{
- int b;
- struct point p;
- gdImagePtr im = this->im;
- dbg(lvl_debug,"type=%s\n",type);
- if (!strcmp(type,"window"))
- return &this->window;
- if (!strcmp(type,"image_png")) {
- if (this->overlays) {
- struct graphics_priv *overlay=this->overlays;
- im=gdImageCreateTrueColor(this->w,this->h);
- gdImageCopy(im, this->im, 0, 0, 0, 0, this->w, this->h);
- add_overlays(overlay, im);
- }
- if (this->image.data)
- gdFree(this->image.data);
+static void add_overlays(struct graphics_priv *overlay, gdImagePtr im) {
+ while (overlay) {
+ if (overlay->background) {
+ gdImagePtr res,src;
+ int y,x;
+ int bgcol=overlay->background->color;
+ res=gdImageCreateTrueColor(overlay->w,overlay->h);
+ src=gdImageCreateTrueColor(overlay->w,overlay->h);
+ gdImageCopy(src, im, 0, 0, overlay->p.x, overlay->p.y, overlay->w, overlay->h);
+ for (y = 0 ; y < overlay->h ; y++) {
+ unsigned int *res_line=res->tpixels[y];
+ unsigned int *src_line=src->tpixels[y];
+ unsigned int *overlay_line=overlay->im->tpixels[y];
+ for (x = 0 ; x < overlay->w ; x++) {
+ if (overlay_line[x] != bgcol)
+ res_line[x]=overlay_line[x];
+ else
+ res_line[x]=src_line[x];
+ }
+ }
+ gdImageCopy(im, res, overlay->p.x, overlay->p.y, 0, 0, overlay->w, overlay->h);
+ gdImageDestroy(res);
+ gdImageDestroy(src);
+ } else
+ gdImageCopy(im, overlay->im, overlay->p.x, overlay->p.y, 0, 0, overlay->w, overlay->h);
+ overlay=overlay->next;
+ }
+}
+
+static void *get_data(struct graphics_priv *this, char *type) {
+ int b;
+ struct point p;
+ gdImagePtr im = this->im;
+ dbg(lvl_debug,"type=%s",type);
+ if (!strcmp(type,"window"))
+ return &this->window;
+ if (!strcmp(type,"image_png")) {
+ if (this->overlays) {
+ struct graphics_priv *overlay=this->overlays;
+ im=gdImageCreateTrueColor(this->w,this->h);
+ gdImageCopy(im, this->im, 0, 0, 0, 0, this->w, this->h);
+ add_overlays(overlay, im);
+ }
+ if (this->image.data)
+ gdFree(this->image.data);
#ifdef HAVE_GRAPHICS_GD_PNG
- this->image.data=gdImagePngPtr(im, &this->image.size);
+ this->image.data=gdImagePngPtr(im, &this->image.size);
#else
- this->image.data=NULL;
+ this->image.data=NULL;
#endif
- if (this->overlays)
- gdImageDestroy(im);
- return &this->image;
- }
- if (sscanf(type,"click_%d_%d_%d",&p.x,&p.y,&b) == 3) {
- dbg(lvl_debug,"click %d %d %d\n",p.x,p.y,b);
- callback_list_call_attr_3(this->cbl, attr_button, (void *)b, (void *)1, (void *)&p);
- }
- if (sscanf(type,"move_%d_%d",&p.x,&p.y) == 2) {
- dbg(lvl_debug,"move %d %d\n",p.x,p.y);
- callback_list_call_attr_1(this->cbl, attr_motion, (void *)&p);
- }
- return NULL;
+ if (this->overlays)
+ gdImageDestroy(im);
+ return &this->image;
+ }
+ if (sscanf(type,"click_%d_%d_%d",&p.x,&p.y,&b) == 3) {
+ dbg(lvl_debug,"click %d %d %d",p.x,p.y,b);
+ callback_list_call_attr_3(this->cbl, attr_button, (void *)b, (void *)1, (void *)&p);
+ }
+ if (sscanf(type,"move_%d_%d",&p.x,&p.y) == 2) {
+ dbg(lvl_debug,"move %d %d",p.x,p.y);
+ callback_list_call_attr_1(this->cbl, attr_motion, (void *)&p);
+ }
+ return NULL;
}
-static void
-image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
-{
- gdImageDestroy(priv->im);
- g_free(priv);
+static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv) {
+ gdImageDestroy(priv->im);
+ g_free(priv);
}
-static void
-overlay_disable(struct graphics_priv *gr, int disable)
-{
- dbg(lvl_debug,"enter\n");
+static void overlay_disable(struct graphics_priv *gr, int disable) {
+ dbg(lvl_debug,"enter");
}
-static void
-overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
-{
- dbg(lvl_debug,"enter\n");
+static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound) {
+ dbg(lvl_debug,"enter");
}
struct shmem_header *
-shm_next(struct graphics_priv *gr)
-{
- char *next=(char *)gr->shm_header+gr->shmoffset;
- if (next+gr->shmoffset > (char *)gr->shm+gr->shmsize) {
- dbg(lvl_debug,"wraparound\n");
- return gr->shm;
- }
- dbg(lvl_debug,"next 0x%x (offset 0x%x)\n",next-(char *)gr->shm,gr->shmoffset);
- return (struct shmem_header *)next;
-
-}
-static void
-image_setup(struct graphics_priv *gr)
-{
- int i,*shm=(int *)(gr->shm_header+1);
- if (!gr->shmkey)
- return;
- for (i = 0 ; i < gr->h ; i++)
- gr->im->tpixels[i]=shm+gr->w*i;
- gr->shm_header->w=gr->w;
- gr->shm_header->h=gr->h;
- gr->shm_header->bpp=32;
- gr->shm_header->flag=0;
-}
-
-static void
-image_create(struct graphics_priv *gr)
-{
- dbg(lvl_debug,"shmkey %d\n",gr->shmkey);
+shm_next(struct graphics_priv *gr) {
+ char *next=(char *)gr->shm_header+gr->shmoffset;
+ if (next+gr->shmoffset > (char *)gr->shm+gr->shmsize) {
+ dbg(lvl_debug,"wraparound");
+ return gr->shm;
+ }
+ dbg(lvl_debug,"next 0x%x (offset 0x%x)",next-(char *)gr->shm,gr->shmoffset);
+ return (struct shmem_header *)next;
+
+}
+static void image_setup(struct graphics_priv *gr) {
+ int i,*shm=(int *)(gr->shm_header+1);
+ if (!gr->shmkey)
+ return;
+ for (i = 0 ; i < gr->h ; i++)
+ gr->im->tpixels[i]=shm+gr->w*i;
+ gr->shm_header->w=gr->w;
+ gr->shm_header->h=gr->h;
+ gr->shm_header->bpp=32;
+ gr->shm_header->flag=0;
+}
+
+static void image_create(struct graphics_priv *gr) {
+ dbg(lvl_debug,"shmkey %d",gr->shmkey);
#ifdef HAVE_SHMEM
- if (gr->shmkey) {
- int size=gr->h*gr->w*sizeof(int);
- int shmid=shmget(gr->shmkey, size, 0666);
- dbg(lvl_debug,"shmid for key 0x%x is 0x%x\n",gr->shmkey, shmid);
- if (shmid < 0)
- dbg(lvl_debug,"shmget\n");
- gr->shm=shmat(shmid, NULL, 0);
- if (!gr->shm)
- dbg(lvl_debug,"shmat\n");
- gr->shm_header=gr->shm;
- gr->im=g_new0(gdImage,1);
- gr->im->tpixels=g_new(int *,gr->h);
- gr->im->sx=gr->w;
- gr->im->sy=gr->h;
- gr->im->transparent=-1;
- gr->im->trueColor=1;
- gr->im->alphaBlendingFlag=1;
- gr->im->thick=1;
- gr->im->cx2=gr->im->sx-1;
- gr->im->cy2=gr->im->sy-1;
- image_setup(gr);
- } else
+ if (gr->shmkey) {
+ int size=gr->h*gr->w*sizeof(int);
+ int shmid=shmget(gr->shmkey, size, 0666);
+ dbg(lvl_debug,"shmid for key 0x%x is 0x%x",gr->shmkey, shmid);
+ if (shmid < 0)
+ dbg(lvl_debug,"shmget");
+ gr->shm=shmat(shmid, NULL, 0);
+ if (!gr->shm)
+ dbg(lvl_debug,"shmat");
+ gr->shm_header=gr->shm;
+ gr->im=g_new0(gdImage,1);
+ gr->im->tpixels=g_new(int *,gr->h);
+ gr->im->sx=gr->w;
+ gr->im->sy=gr->h;
+ gr->im->transparent=-1;
+ gr->im->trueColor=1;
+ gr->im->alphaBlendingFlag=1;
+ gr->im->thick=1;
+ gr->im->cx2=gr->im->sx-1;
+ gr->im->cy2=gr->im->sy-1;
+ image_setup(gr);
+ } else
#endif
- gr->im=gdImageCreateTrueColor(gr->w,gr->h);
+ gr->im=gdImageCreateTrueColor(gr->w,gr->h);
}
-static void
-image_destroy(struct graphics_priv *gr)
-{
+static void image_destroy(struct graphics_priv *gr) {
#ifdef HAVE_SHMEM
- if (gr->shmkey) {
- shmdt(gr->shm);
- g_free(gr->im->tpixels);
- g_free(gr->im);
- } else
+ if (gr->shmkey) {
+ shmdt(gr->shm);
+ g_free(gr->im->tpixels);
+ g_free(gr->im);
+ } else
#endif
- gdImageDestroy(gr->im);
- gr->im=NULL;
-}
-
-static int
-set_attr_do(struct graphics_priv *gr, struct attr *attr, int init)
-{
- char *s,*c,*n,*p;
- switch (attr->type) {
- case attr_w:
- if (gr->w != attr->u.num) {
- gr->w=attr->u.num;
- if (!init) {
- if (gr->im)
- image_destroy(gr);
- image_create(gr);
- emit_callback(gr);
- }
- }
- break;
- case attr_h:
- if (gr->h != attr->u.num) {
- gr->h=attr->u.num;
- if (!init) {
- if (gr->im)
- image_destroy(gr);
- image_create(gr);
- emit_callback(gr);
- }
- }
- break;
- case attr_flags:
- gr->flags=attr->u.num;
- break;
- case attr_shmkey:
- gr->shmkey=attr->u.num;
- break;
- case attr_shmsize:
- gr->shmsize=attr->u.num;
- break;
- case attr_shmoffset:
- gr->shmoffset=attr->u.num;
- break;
+ gdImageDestroy(gr->im);
+ gr->im=NULL;
+}
+
+static int set_attr_do(struct graphics_priv *gr, struct attr *attr, int init) {
+ char *s,*c,*n,*p;
+ switch (attr->type) {
+ case attr_w:
+ if (gr->w != attr->u.num) {
+ gr->w=attr->u.num;
+ if (!init) {
+ if (gr->im)
+ image_destroy(gr);
+ image_create(gr);
+ emit_callback(gr);
+ }
+ }
+ break;
+ case attr_h:
+ if (gr->h != attr->u.num) {
+ gr->h=attr->u.num;
+ if (!init) {
+ if (gr->im)
+ image_destroy(gr);
+ image_create(gr);
+ emit_callback(gr);
+ }
+ }
+ break;
+ case attr_flags:
+ gr->flags=attr->u.num;
+ break;
+ case attr_shmkey:
+ gr->shmkey=attr->u.num;
+ break;
+ case attr_shmsize:
+ gr->shmsize=attr->u.num;
+ break;
+ case attr_shmoffset:
+ gr->shmoffset=attr->u.num;
+ break;
#ifdef HAVE_SOCKET
- case attr_socket:
- g_list_foreach(gr->sockets, (GFunc)g_free, NULL);
- g_list_free(gr->sockets);
- gr->sockets=NULL;
- c=s=g_strdup(attr->u.str);
- dbg(lvl_debug,"s=%s\n",s);
- while (c) {
- n=strchr(c,',');
- if (n)
- *n++='\0';
- p=strchr(c,':');
- if (p) {
- *p++='\0';
- struct sockaddr_in *sin=g_new(struct sockaddr_in, 1);
- sin->sin_family=AF_INET;
- sin->sin_port=ntohs(atoi(p));
- if (inet_aton(c, &sin->sin_addr)) {
- gr->sockets=g_list_append(gr->sockets, sin);
- } else {
- dbg(lvl_error,"error in %s\n",c);
- g_free(sin);
- }
- dbg(lvl_debug,"host=%s port=%s\n",c,p);
- } else
- dbg(lvl_error,"error in format: %s\n",p);
- c=n;
- }
- g_free(s);
+ case attr_socket:
+ g_list_foreach(gr->sockets, (GFunc)g_free, NULL);
+ g_list_free(gr->sockets);
+ gr->sockets=NULL;
+ c=s=g_strdup(attr->u.str);
+ dbg(lvl_debug,"s=%s",s);
+ while (c) {
+ n=strchr(c,',');
+ if (n)
+ *n++='\0';
+ p=strchr(c,':');
+ if (p) {
+ *p++='\0';
+ struct sockaddr_in *sin=g_new(struct sockaddr_in, 1);
+ sin->sin_family=AF_INET;
+ sin->sin_port=ntohs(atoi(p));
+ if (inet_aton(c, &sin->sin_addr)) {
+ gr->sockets=g_list_append(gr->sockets, sin);
+ } else {
+ dbg(lvl_error,"error in %s",c);
+ g_free(sin);
+ }
+ dbg(lvl_debug,"host=%s port=%s",c,p);
+ } else
+ dbg(lvl_error,"error in format: %s",p);
+ c=n;
+ }
+ g_free(s);
#endif
- default:
- return 0;
- }
- return 1;
+ default:
+ return 0;
+ }
+ return 1;
}
-static int
-set_attr(struct graphics_priv *gr, struct attr *attr)
-{
- return set_attr_do(gr, attr, 0);
+static int set_attr(struct graphics_priv *gr, struct attr *attr) {
+ return set_attr_do(gr, attr, 0);
}
static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
- NULL,
- draw_drag,
- NULL,
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- image_free,
- NULL,
- overlay_disable,
- overlay_resize,
- set_attr,
- NULL, /* show_native_keyboard */
- NULL, /* hide_native_keyboard */
+ graphics_destroy,
+ draw_mode,
+ draw_lines,
+ draw_polygon,
+ draw_rectangle,
+ draw_circle,
+ draw_text,
+ draw_image,
+ NULL,
+ draw_drag,
+ NULL,
+ gc_new,
+ background_gc,
+ overlay_new,
+ image_new,
+ get_data,
+ image_free,
+ NULL,
+ overlay_disable,
+ overlay_resize,
+ set_attr,
+ NULL, /* show_native_keyboard */
+ NULL, /* hide_native_keyboard */
};
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
-{
- struct font_priv * (*font_freetype_new)(void *meth);
- struct graphics_priv *ret;
-
- dbg(lvl_debug,"enter\n");
- ret=g_new0(struct graphics_priv, 1);
- *meth=graphics_methods;
- font_freetype_new=plugin_get_category_font("freetype");
- if (!font_freetype_new)
- return NULL;
- font_freetype_new(&ret->freetype_methods);
- ret->p=*p;
- ret->w=w;
- ret->h=h;
- ret->overlay=1;
- ret->flags=1;
- ret->im=gdImageCreateTrueColor(ret->w,ret->h);
- ret->next=gr->overlays;
- gr->overlays=ret;
-
- return ret;
-}
-
-static void
-emit_callback(struct graphics_priv *priv)
-{
- callback_list_call_attr_2(priv->cbl, attr_resize, (void *)priv->w, (void *)priv->h);
-}
-
-
-static struct graphics_priv *
-graphics_gd_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct font_priv * (*font_freetype_new)(void *meth);
- struct graphics_priv *ret;
- event_request_system("glib","graphics_gd_new");
- font_freetype_new=plugin_get_category_font("freetype");
- if (!font_freetype_new)
- return NULL;
- *meth=graphics_methods;
- ret=g_new0(struct graphics_priv, 1);
- font_freetype_new(&ret->freetype_methods);
- meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int, int))ret->freetype_methods.font_new;
- meth->get_text_bbox=ret->freetype_methods.get_text_bbox;
- ret->cb=callback_new_attr_1(callback_cast(emit_callback), attr_navit, ret);
- navit_add_callback(nav, ret->cb);
- ret->cbl=cbl;
- ret->nav=nav;
- ret->w=800;
- ret->h=600;
- while (*attrs) {
- set_attr_do(ret, *attrs, 1);
- attrs++;
- }
- if (!ret->im)
- image_create(ret);
- return ret;
-}
-
-void
-plugin_init(void)
-{
- plugin_register_category_graphics("gd", graphics_gd_new);
+static struct graphics_priv *overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound) {
+ struct font_priv * (*font_freetype_new)(void *meth);
+ struct graphics_priv *ret;
+
+ dbg(lvl_debug,"enter");
+ ret=g_new0(struct graphics_priv, 1);
+ *meth=graphics_methods;
+ font_freetype_new=plugin_get_category_font("freetype");
+ if (!font_freetype_new)
+ return NULL;
+ font_freetype_new(&ret->freetype_methods);
+ ret->p=*p;
+ ret->w=w;
+ ret->h=h;
+ ret->overlay=1;
+ ret->flags=1;
+ ret->im=gdImageCreateTrueColor(ret->w,ret->h);
+ ret->next=gr->overlays;
+ gr->overlays=ret;
+
+ return ret;
+}
+
+static void emit_callback(struct graphics_priv *priv) {
+ callback_list_call_attr_2(priv->cbl, attr_resize, (void *)priv->w, (void *)priv->h);
+}
+
+
+static struct graphics_priv *graphics_gd_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct font_priv * (*font_freetype_new)(void *meth);
+ struct graphics_priv *ret;
+ event_request_system("glib","graphics_gd_new");
+ font_freetype_new=plugin_get_category_font("freetype");
+ if (!font_freetype_new)
+ return NULL;
+ *meth=graphics_methods;
+ ret=g_new0(struct graphics_priv, 1);
+ font_freetype_new(&ret->freetype_methods);
+ meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int, int))ret->freetype_methods.font_new;
+ meth->get_text_bbox=ret->freetype_methods.get_text_bbox;
+ ret->cb=callback_new_attr_1(callback_cast(emit_callback), attr_navit, ret);
+ navit_add_callback(nav, ret->cb);
+ ret->cbl=cbl;
+ ret->nav=nav;
+ ret->w=800;
+ ret->h=600;
+ while (*attrs) {
+ set_attr_do(ret, *attrs, 1);
+ attrs++;
+ }
+ if (!ret->im)
+ image_create(ret);
+ return ret;
+}
+
+void plugin_init(void) {
+ plugin_register_category_graphics("gd", graphics_gd_new);
}
diff --git a/navit/graphics/gtk_drawing_area/CMakeLists.txt b/navit/graphics/gtk_drawing_area/CMakeLists.txt
index 19e442616..b5b55f4f6 100644
--- a/navit/graphics/gtk_drawing_area/CMakeLists.txt
+++ b/navit/graphics/gtk_drawing_area/CMakeLists.txt
@@ -1,3 +1,3 @@
set(graphics_gtk_drawing_area_LIBS ${IMLIB2_LDFLAGS} ${GTK2_LIBRARIES})
-module_add_library(graphics_gtk_drawing_area graphics_gtk_drawing_area.c)
+module_add_library(graphics_gtk_drawing_area graphics_gtk_drawing_area.c)
diff --git a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c b/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
index 387003c40..b61ac2403 100644
--- a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
+++ b/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
@@ -49,6 +49,7 @@
#include "plugin.h"
#include "navit/font/freetype/font_freetype.h"
#include "navit.h"
+#include <errno.h>
#ifndef GDK_Book
#define GDK_Book XF86XK_Book
@@ -59,683 +60,616 @@
struct graphics_priv {
- GdkEventButton button_event;
- int button_timeout;
- GtkWidget *widget;
- GtkWidget *win;
- struct window window;
- cairo_t *cairo;
- struct point p;
- int width;
- int height;
- int win_w;
- int win_h;
- int visible;
- int overlay_disabled;
- int overlay_autodisabled;
- int wraparound;
- struct graphics_priv *parent;
- struct graphics_priv *overlays;
- struct graphics_priv *next;
- struct graphics_gc_priv *background_gc;
- struct callback_list *cbl;
- struct font_freetype_methods freetype_methods;
- struct navit *nav;
- int pid;
- struct timeval button_press[8];
- struct timeval button_release[8];
- int timeout;
- int delay;
- char *window_title;
+ GdkEventButton button_event;
+ int button_timeout;
+ GtkWidget *widget;
+ GtkWidget *win;
+ struct window window;
+ cairo_t *cairo;
+ struct point p;
+ int width;
+ int height;
+ int win_w;
+ int win_h;
+ int visible;
+ int overlay_disabled;
+ int overlay_autodisabled;
+ int wraparound;
+ struct graphics_priv *parent;
+ struct graphics_priv *overlays;
+ struct graphics_priv *next;
+ struct graphics_gc_priv *background_gc;
+ struct callback_list *cbl;
+ struct font_freetype_methods freetype_methods;
+ struct navit *nav;
+ int pid;
+ struct timeval button_press[8];
+ struct timeval button_release[8];
+ int timeout;
+ int delay;
+ char *window_title;
};
struct graphics_gc_priv {
- struct graphics_priv *gr;
- struct color c;
- double linewidth;
- double *dashes;
- int ndashes;
- double offset;
+ struct graphics_priv *gr;
+ struct color c;
+ double linewidth;
+ double *dashes;
+ int ndashes;
+ double offset;
};
struct graphics_image_priv {
- GdkPixbuf *pixbuf;
- int w;
- int h;
+ GdkPixbuf *pixbuf;
+ int w;
+ int h;
#ifdef HAVE_IMLIB2
- void *image;
+ void *image;
#endif
};
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
- dbg(lvl_debug,"enter parent %p\n",gr->parent);
- gr->freetype_methods.destroy();
- if (!gr->parent) {
- dbg(lvl_debug,"enter win %p\n",gr->win);
- if (gr->win)
- gtk_widget_destroy(gr->win);
- dbg(lvl_debug,"widget %p\n",gr->widget);
- if (gr->widget)
- gtk_widget_destroy(gr->widget);
- g_free(gr->window_title);
- }
- g_free(gr);
+static void graphics_destroy(struct graphics_priv *gr) {
+ dbg(lvl_debug,"enter parent %p",gr->parent);
+ gr->freetype_methods.destroy();
+ if (!gr->parent) {
+ dbg(lvl_debug,"enter win %p",gr->win);
+ if (gr->win)
+ gtk_widget_destroy(gr->win);
+ dbg(lvl_debug,"widget %p",gr->widget);
+ if (gr->widget)
+ gtk_widget_destroy(gr->widget);
+ g_free(gr->window_title);
+ }
+ g_free(gr);
}
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
- g_free(gc);
+static void gc_destroy(struct graphics_gc_priv *gc) {
+ g_free(gc);
}
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
- gc->linewidth = w;
+static void gc_set_linewidth(struct graphics_gc_priv *gc, int w) {
+ gc->linewidth = w;
}
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
-{
- int i;
- g_free(gc->dashes);
- gc->ndashes=n;
- gc->offset=offset;
- if(n) {
- gc->dashes=g_malloc_n(n, sizeof(double));
- for (i=0; i<n; i++) {
- gc->dashes[i]=dash_list[i];
- }
- } else {
- gc->dashes=NULL;
- }
+static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n) {
+ int i;
+ g_free(gc->dashes);
+ gc->ndashes=n;
+ gc->offset=offset;
+ if(n) {
+ gc->dashes=g_malloc_n(n, sizeof(double));
+ for (i=0; i<n; i++) {
+ gc->dashes[i]=dash_list[i];
+ }
+ } else {
+ gc->dashes=NULL;
+ }
}
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
- gc->c=*c;
+static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c) {
+ gc->c=*c;
}
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_background(struct graphics_gc_priv *gc, struct color *c) {
}
static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background,
+ gc_destroy,
+ gc_set_linewidth,
+ gc_set_dashes,
+ gc_set_foreground,
+ gc_set_background,
};
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- struct graphics_gc_priv *gc=g_new(struct graphics_gc_priv, 1);
+static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) {
+ struct graphics_gc_priv *gc=g_new(struct graphics_gc_priv, 1);
- *meth=gc_methods;
- gc->gr=gr;
+ *meth=gc_methods;
+ gc->gr=gr;
- gc->linewidth=1;
- gc->c.r=0;
- gc->c.g=0;
- gc->c.b=0;
- gc->c.a=0;
- gc->dashes=NULL;
- gc->ndashes=0;
- gc->offset=0;
+ gc->linewidth=1;
+ gc->c.r=0;
+ gc->c.g=0;
+ gc->c.b=0;
+ gc->c.a=0;
+ gc->dashes=NULL;
+ gc->ndashes=0;
+ gc->offset=0;
- return gc;
+ return gc;
}
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot, int rotation)
-{
- GdkPixbuf *pixbuf;
- struct graphics_image_priv *ret;
- const char *option;
-
- if (!strcmp(name,"buffer:")) {
- struct graphics_image_buffer *buffer=(struct graphics_image_buffer *)name;
- GdkPixbufLoader *loader=gdk_pixbuf_loader_new();
- if (!loader)
- return NULL;
- if (*w != IMAGE_W_H_UNSET || *h != IMAGE_W_H_UNSET)
- gdk_pixbuf_loader_set_size(loader, *w, *h);
- gdk_pixbuf_loader_write(loader, buffer->start, buffer->len, NULL);
- gdk_pixbuf_loader_close(loader, NULL);
- pixbuf=gdk_pixbuf_loader_get_pixbuf(loader);
- g_object_ref(pixbuf);
- g_object_unref(loader);
- } else {
- if (*w == IMAGE_W_H_UNSET && *h == IMAGE_W_H_UNSET)
- pixbuf=gdk_pixbuf_new_from_file(name, NULL);
- else
- pixbuf=gdk_pixbuf_new_from_file_at_size(name, *w, *h, NULL);
- }
-
- if (!pixbuf)
- return NULL;
-
- if (rotation) {
- GdkPixbuf *tmp;
- switch (rotation) {
- case 90:
- rotation=270;
- break;
- case 180:
- break;
- case 270:
- rotation=90;
- break;
- default:
- return NULL;
- }
-
- tmp=gdk_pixbuf_rotate_simple(pixbuf, rotation);
-
- if (!tmp) {
- g_object_unref(pixbuf);
- return NULL;
- }
-
- g_object_unref(pixbuf);
- pixbuf=tmp;
- }
-
- ret=g_new0(struct graphics_image_priv, 1);
- ret->pixbuf=pixbuf;
- ret->w=gdk_pixbuf_get_width(pixbuf);
- ret->h=gdk_pixbuf_get_height(pixbuf);
- *w=ret->w;
- *h=ret->h;
- if (hot) {
- option=gdk_pixbuf_get_option(pixbuf, "x_hot");
- if (option)
- hot->x=atoi(option);
- else
- hot->x=ret->w/2-1;
- option=gdk_pixbuf_get_option(pixbuf, "y_hot");
- if (option)
- hot->y=atoi(option);
- else
- hot->y=ret->h/2-1;
- }
- return ret;
+static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot, int rotation) {
+ GdkPixbuf *pixbuf;
+ struct graphics_image_priv *ret;
+ const char *option;
+
+ if (!strcmp(name,"buffer:")) {
+ struct graphics_image_buffer *buffer=(struct graphics_image_buffer *)name;
+ GdkPixbufLoader *loader=gdk_pixbuf_loader_new();
+ if (!loader)
+ return NULL;
+ if (*w != IMAGE_W_H_UNSET || *h != IMAGE_W_H_UNSET)
+ gdk_pixbuf_loader_set_size(loader, *w, *h);
+ gdk_pixbuf_loader_write(loader, buffer->start, buffer->len, NULL);
+ gdk_pixbuf_loader_close(loader, NULL);
+ pixbuf=gdk_pixbuf_loader_get_pixbuf(loader);
+ g_object_ref(pixbuf);
+ g_object_unref(loader);
+ } else {
+ if (*w == IMAGE_W_H_UNSET && *h == IMAGE_W_H_UNSET)
+ pixbuf=gdk_pixbuf_new_from_file(name, NULL);
+ else
+ pixbuf=gdk_pixbuf_new_from_file_at_size(name, *w, *h, NULL);
+ }
+
+ if (!pixbuf)
+ return NULL;
+
+ if (rotation) {
+ GdkPixbuf *tmp;
+ switch (rotation) {
+ case 90:
+ rotation=270;
+ break;
+ case 180:
+ break;
+ case 270:
+ rotation=90;
+ break;
+ default:
+ return NULL;
+ }
+
+ tmp=gdk_pixbuf_rotate_simple(pixbuf, rotation);
+
+ if (!tmp) {
+ g_object_unref(pixbuf);
+ return NULL;
+ }
+
+ g_object_unref(pixbuf);
+ pixbuf=tmp;
+ }
+
+ ret=g_new0(struct graphics_image_priv, 1);
+ ret->pixbuf=pixbuf;
+ ret->w=gdk_pixbuf_get_width(pixbuf);
+ ret->h=gdk_pixbuf_get_height(pixbuf);
+ *w=ret->w;
+ *h=ret->h;
+ if (hot) {
+ option=gdk_pixbuf_get_option(pixbuf, "x_hot");
+ if (option)
+ hot->x=atoi(option);
+ else
+ hot->x=ret->w/2-1;
+ option=gdk_pixbuf_get_option(pixbuf, "y_hot");
+ if (option)
+ hot->y=atoi(option);
+ else
+ hot->y=ret->h/2-1;
+ }
+ return ret;
}
-static void
-image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
-{
- g_object_unref(priv->pixbuf);
- g_free(priv);
+static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv) {
+ g_object_unref(priv->pixbuf);
+ g_free(priv);
}
-static void
-set_drawing_color(cairo_t *cairo, struct color c)
-{
- double col_max = 1<<COLOR_BITDEPTH;
- cairo_set_source_rgba(cairo, c.r/col_max, c.g/col_max, c.b/col_max, c.a/col_max);
+static void set_drawing_color(cairo_t *cairo, struct color c) {
+ double col_max = 1<<COLOR_BITDEPTH;
+ cairo_set_source_rgba(cairo, c.r/col_max, c.g/col_max, c.b/col_max, c.a/col_max);
}
-static void
-set_stroke_params_from_gc(cairo_t *cairo, struct graphics_gc_priv *gc)
-{
- set_drawing_color(cairo, gc->c);
- cairo_set_dash(cairo, gc->dashes, gc->ndashes, gc->offset);
- cairo_set_line_width(cairo, gc->linewidth);
+static void set_stroke_params_from_gc(cairo_t *cairo, struct graphics_gc_priv *gc) {
+ set_drawing_color(cairo, gc->c);
+ cairo_set_dash(cairo, gc->dashes, gc->ndashes, gc->offset);
+ cairo_set_line_width(cairo, gc->linewidth);
}
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int i;
- if (!count)
- return;
- cairo_move_to(gr->cairo, p[0].x, p[0].y);
- for (i=1; i<count; i++) {
- cairo_line_to(gr->cairo, p[i].x, p[i].y);
- }
- set_stroke_params_from_gc(gr->cairo, gc);
- cairo_stroke(gr->cairo);
+static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ int i;
+ if (!count)
+ return;
+ cairo_move_to(gr->cairo, p[0].x, p[0].y);
+ for (i=1; i<count; i++) {
+ cairo_line_to(gr->cairo, p[i].x, p[i].y);
+ }
+ set_stroke_params_from_gc(gr->cairo, gc);
+ cairo_stroke(gr->cairo);
}
-static void
-draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int i;
- set_drawing_color(gr->cairo, gc->c);
- cairo_move_to(gr->cairo, p[0].x, p[0].y);
- for (i=1; i<count; i++) {
- cairo_line_to(gr->cairo, p[i].x, p[i].y);
- }
- cairo_fill(gr->cairo);
+static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ int i;
+ set_drawing_color(gr->cairo, gc->c);
+ cairo_move_to(gr->cairo, p[0].x, p[0].y);
+ for (i=1; i<count; i++) {
+ cairo_line_to(gr->cairo, p[i].x, p[i].y);
+ }
+ cairo_fill(gr->cairo);
}
-static void
-draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
- cairo_save(gr->cairo);
- // Use OPERATOR_SOURCE to overwrite old contents even when drawing with transparency.
- // Necessary for OSD drawing.
- cairo_set_operator(gr->cairo, CAIRO_OPERATOR_SOURCE);
- cairo_rectangle(gr->cairo, p->x, p->y, w, h);
- set_drawing_color(gr->cairo, gc->c);
- cairo_fill(gr->cairo);
- cairo_restore(gr->cairo);
+static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
+ cairo_save(gr->cairo);
+ // Use OPERATOR_SOURCE to overwrite old contents even when drawing with transparency.
+ // Necessary for OSD drawing.
+ cairo_set_operator(gr->cairo, CAIRO_OPERATOR_SOURCE);
+ cairo_rectangle(gr->cairo, p->x, p->y, w, h);
+ set_drawing_color(gr->cairo, gc->c);
+ cairo_fill(gr->cairo);
+ cairo_restore(gr->cairo);
}
-static void
-draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
- cairo_arc (gr->cairo, p->x, p->y, r/2, 0.0, 2*M_PI);
- set_stroke_params_from_gc(gr->cairo, gc);
- cairo_stroke(gr->cairo);
+static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r) {
+ cairo_arc (gr->cairo, p->x, p->y, r/2, 0.0, 2*M_PI);
+ set_stroke_params_from_gc(gr->cairo, gc);
+ cairo_stroke(gr->cairo);
}
-static void
-draw_rgb_image_buffer(cairo_t *cairo, int buffer_width, int buffer_height, int draw_pos_x, int draw_pos_y, int stride, unsigned char *buffer)
-{
- cairo_surface_t *buffer_surface = cairo_image_surface_create_for_data(
- buffer, CAIRO_FORMAT_ARGB32, buffer_width, buffer_height, stride);
- cairo_set_source_surface(cairo, buffer_surface, draw_pos_x, draw_pos_y);
- cairo_paint(cairo);
- cairo_surface_destroy(buffer_surface);
+static void draw_rgb_image_buffer(cairo_t *cairo, int buffer_width, int buffer_height, int draw_pos_x, int draw_pos_y, int stride, unsigned char *buffer) {
+ cairo_surface_t *buffer_surface = cairo_image_surface_create_for_data(
+ buffer, CAIRO_FORMAT_ARGB32, buffer_width, buffer_height, stride);
+ cairo_set_source_surface(cairo, buffer_surface, draw_pos_x, draw_pos_y);
+ cairo_paint(cairo);
+ cairo_surface_destroy(buffer_surface);
}
-static void
-display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct point *p)
-{
- int i,x,y,stride;
- struct font_freetype_glyph *g, **gp;
- struct color transparent={0x0,0x0,0x0,0x0};
-
- gp=text->glyph;
- i=text->glyph_count;
- x=p->x << 6;
- y=p->y << 6;
- while (i-- > 0)
- {
- g=*gp++;
- if (g->w && g->h && bg ) {
- unsigned char *shadow;
- stride=cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, g->w+2);
- shadow=g_malloc(stride*(g->h+2));
- gr->freetype_methods.get_shadow(g, shadow, stride, &bg->c, &transparent);
- draw_rgb_image_buffer(gr->cairo, g->w+2, g->h+2, ((x+g->x)>>6)-1, ((y+g->y)>>6)-1, stride, shadow);
- g_free(shadow);
- }
- x+=g->dx;
- y+=g->dy;
- }
- x=p->x << 6;
- y=p->y << 6;
- gp=text->glyph;
- i=text->glyph_count;
- while (i-- > 0)
- {
- g=*gp++;
- if (g->w && g->h) {
- unsigned char *glyph;
- stride=cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, g->w);
- glyph=g_malloc(stride*g->h);
- gr->freetype_methods.get_glyph(g, glyph, stride, &fg->c, bg?&bg->c:&transparent, &transparent);
- draw_rgb_image_buffer(gr->cairo, g->w, g->h, (x+g->x)>>6, (y+g->y)>>6, stride, glyph);
- g_free(glyph);
- }
- x+=g->dx;
- y+=g->dy;
- }
+static void display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct point *p) {
+ int i,x,y,stride;
+ struct font_freetype_glyph *g, **gp;
+ struct color transparent= {0x0,0x0,0x0,0x0};
+
+ gp=text->glyph;
+ i=text->glyph_count;
+ x=p->x << 6;
+ y=p->y << 6;
+ while (i-- > 0) {
+ g=*gp++;
+ if (g->w && g->h && bg ) {
+ unsigned char *shadow;
+ stride=cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, g->w+2);
+ shadow=g_malloc(stride*(g->h+2));
+ gr->freetype_methods.get_shadow(g, shadow, stride, &bg->c, &transparent);
+ draw_rgb_image_buffer(gr->cairo, g->w+2, g->h+2, ((x+g->x)>>6)-1, ((y+g->y)>>6)-1, stride, shadow);
+ g_free(shadow);
+ }
+ x+=g->dx;
+ y+=g->dy;
+ }
+ x=p->x << 6;
+ y=p->y << 6;
+ gp=text->glyph;
+ i=text->glyph_count;
+ while (i-- > 0) {
+ g=*gp++;
+ if (g->w && g->h) {
+ unsigned char *glyph;
+ stride=cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, g->w);
+ glyph=g_malloc(stride*g->h);
+ gr->freetype_methods.get_glyph(g, glyph, stride, &fg->c, bg?&bg->c:&transparent, &transparent);
+ draw_rgb_image_buffer(gr->cairo, g->w, g->h, (x+g->x)>>6, (y+g->y)>>6, stride, glyph);
+ g_free(glyph);
+ }
+ x+=g->dx;
+ y+=g->dy;
+ }
}
-static void
-draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
- struct font_freetype_text *t;
+static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
+ struct font_freetype_text *t;
- if (! font)
- {
- dbg(lvl_error,"no font, returning\n");
- return;
- }
+ if (! font) {
+ dbg(lvl_error,"no font, returning");
+ return;
+ }
#if 0 /* Temporarily disabled because it destroys text rendering of overlays and in gui internal in some places */
- /*
- This needs an improvement, no one checks if the strings are visible
- */
- if (p->x > gr->width-50 || p->y > gr->height-50) {
- return;
- }
- if (p->x < -50 || p->y < -50) {
- return;
- }
+ /*
+ This needs an improvement, no one checks if the strings are visible
+ */
+ if (p->x > gr->width-50 || p->y > gr->height-50) {
+ return;
+ }
+ if (p->x < -50 || p->y < -50) {
+ return;
+ }
#endif
- if (bg && !bg->c.a)
- bg=NULL;
- t=gr->freetype_methods.text_new(text, (struct font_freetype_font *)font, dx, dy);
- display_text_draw(t, gr, fg, bg, p);
- gr->freetype_methods.text_destroy(t);
+ if (bg && !bg->c.a)
+ bg=NULL;
+ t=gr->freetype_methods.text_new(text, (struct font_freetype_font *)font, dx, dy);
+ display_text_draw(t, gr, fg, bg, p);
+ gr->freetype_methods.text_destroy(t);
}
-static void
-draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
- gdk_cairo_set_source_pixbuf(gr->cairo, img->pixbuf, p->x, p->y);
- cairo_paint(gr->cairo);
+static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img) {
+ gdk_cairo_set_source_pixbuf(gr->cairo, img->pixbuf, p->x, p->y);
+ cairo_paint(gr->cairo);
}
-static unsigned char*
-create_buffer_with_stride_if_required(unsigned char *input_buffer, int w, int h, size_t bytes_per_pixel, size_t output_stride)
-{
- int line;
- size_t input_offset, output_offset;
- unsigned char *out_buf;
- size_t input_stride = w*bytes_per_pixel;
- if (input_stride == output_stride) {
- return NULL;
- }
-
- out_buf = g_malloc(h*output_stride);
- for (line = 0; line < h; line++) {
- input_offset = line*input_stride;
- output_offset = line*output_stride;
- memcpy(out_buf+output_offset, input_buffer+input_offset, input_stride);
- }
- return out_buf;
+#ifdef HAVE_IMLIB2
+static unsigned char* create_buffer_with_stride_if_required(unsigned char *input_buffer, int w, int h, size_t bytes_per_pixel, size_t output_stride) {
+ int line;
+ size_t input_offset, output_offset;
+ unsigned char *out_buf;
+ size_t input_stride = w*bytes_per_pixel;
+ if (input_stride == output_stride) {
+ return NULL;
+ }
+
+ out_buf = g_malloc(h*output_stride);
+ for (line = 0; line < h; line++) {
+ input_offset = line*input_stride;
+ output_offset = line*output_stride;
+ memcpy(out_buf+output_offset, input_buffer+input_offset, input_stride);
+ }
+ return out_buf;
}
-#ifdef HAVE_IMLIB2
-static void
-draw_image_warp(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, struct graphics_image_priv *img)
-{
- int w,h;
- DATA32 *intermediate_buffer;
- unsigned char* intermediate_buffer_aligned;
- Imlib_Image intermediate_image;
- size_t stride;
- dbg(lvl_debug,"draw_image_warp data=%p\n", img);
- w = img->w;
- h = img->h;
- if (!img->image) {
- int x,y;
- img->image=imlib_create_image(w, h);
- imlib_context_set_image(img->image);
- if (gdk_pixbuf_get_colorspace(img->pixbuf) != GDK_COLORSPACE_RGB || gdk_pixbuf_get_bits_per_sample(img->pixbuf) != 8) {
- dbg(lvl_error,"implement me\n");
- } else if (gdk_pixbuf_get_has_alpha(img->pixbuf) && gdk_pixbuf_get_n_channels(img->pixbuf) == 4) {
- for (y=0 ; y < h ; y++) {
- unsigned int *dst=imlib_image_get_data()+y*w;
- unsigned char *src=gdk_pixbuf_get_pixels(img->pixbuf)+y*gdk_pixbuf_get_rowstride(img->pixbuf);
- for (x=0 ; x < w ; x++) {
- *dst++=0xff000000|(src[0] << 16)|(src[1] << 8)|src[2];
- src+=4;
- }
- }
- } else if (!gdk_pixbuf_get_has_alpha(img->pixbuf) && gdk_pixbuf_get_n_channels(img->pixbuf) == 3) {
- for (y=0 ; y < h ; y++) {
- unsigned int *dst=imlib_image_get_data()+y*w;
- unsigned char *src=gdk_pixbuf_get_pixels(img->pixbuf)+y*gdk_pixbuf_get_rowstride(img->pixbuf);
- for (x=0 ; x < w ; x++) {
- *dst++=0xff000000|(src[0] << 16)|(src[1] << 8)|src[2];
- src+=3;
- }
- }
- } else {
- dbg(lvl_error,"implement me\n");
- }
-
- }
-
- intermediate_buffer = g_malloc0(gr->width*gr->height*4);
- intermediate_image = imlib_create_image_using_data(gr->width, gr->height, intermediate_buffer);
- imlib_context_set_image(intermediate_image);
- imlib_image_set_has_alpha(1);
-
- if (count == 3) {
- /* 0 1
+static void draw_image_warp(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, struct graphics_image_priv *img) {
+ int w,h;
+ DATA32 *intermediate_buffer;
+ unsigned char* intermediate_buffer_aligned;
+ Imlib_Image intermediate_image;
+ size_t stride;
+ dbg(lvl_debug,"draw_image_warp data=%p", img);
+ w = img->w;
+ h = img->h;
+ if (!img->image) {
+ int x,y;
+ img->image=imlib_create_image(w, h);
+ imlib_context_set_image(img->image);
+ if (gdk_pixbuf_get_colorspace(img->pixbuf) != GDK_COLORSPACE_RGB || gdk_pixbuf_get_bits_per_sample(img->pixbuf) != 8) {
+ dbg(lvl_error,"implement me");
+ } else if (gdk_pixbuf_get_has_alpha(img->pixbuf) && gdk_pixbuf_get_n_channels(img->pixbuf) == 4) {
+ for (y=0 ; y < h ; y++) {
+ unsigned int *dst=imlib_image_get_data()+y*w;
+ unsigned char *src=gdk_pixbuf_get_pixels(img->pixbuf)+y*gdk_pixbuf_get_rowstride(img->pixbuf);
+ for (x=0 ; x < w ; x++) {
+ *dst++=0xff000000|(src[0] << 16)|(src[1] << 8)|src[2];
+ src+=4;
+ }
+ }
+ } else if (!gdk_pixbuf_get_has_alpha(img->pixbuf) && gdk_pixbuf_get_n_channels(img->pixbuf) == 3) {
+ for (y=0 ; y < h ; y++) {
+ unsigned int *dst=imlib_image_get_data()+y*w;
+ unsigned char *src=gdk_pixbuf_get_pixels(img->pixbuf)+y*gdk_pixbuf_get_rowstride(img->pixbuf);
+ for (x=0 ; x < w ; x++) {
+ *dst++=0xff000000|(src[0] << 16)|(src[1] << 8)|src[2];
+ src+=3;
+ }
+ }
+ } else {
+ dbg(lvl_error,"implement me");
+ }
+
+ }
+
+ intermediate_buffer = g_malloc0(gr->width*gr->height*4);
+ intermediate_image = imlib_create_image_using_data(gr->width, gr->height, intermediate_buffer);
+ imlib_context_set_image(intermediate_image);
+ imlib_image_set_has_alpha(1);
+
+ if (count == 3) {
+ /* 0 1
2 */
- imlib_blend_image_onto_image_skewed(img->image, 1, 0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, p[1].y-p[0].y, p[2].x-p[0].x, p[2].y-p[0].y);
- }
- if (count == 2) {
- /* 0
+ imlib_blend_image_onto_image_skewed(img->image, 1, 0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, p[1].y-p[0].y,
+ p[2].x-p[0].x, p[2].y-p[0].y);
+ }
+ if (count == 2) {
+ /* 0
1 */
- imlib_blend_image_onto_image_skewed(img->image, 1, 0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, 0, 0, p[1].y-p[0].y);
- }
- if (count == 1) {
- /*
+ imlib_blend_image_onto_image_skewed(img->image, 1, 0, 0, w, h, p[0].x, p[0].y, p[1].x-p[0].x, 0, 0, p[1].y-p[0].y);
+ }
+ if (count == 1) {
+ /*
0
*/
- imlib_blend_image_onto_image_skewed(img->image, 1, 0, 0, w, h, p[0].x-w/2, p[0].y-h/2, w, 0, 0, h);
- }
-
- stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, gr->width);
- intermediate_buffer_aligned = create_buffer_with_stride_if_required(
- (unsigned char* )intermediate_buffer, gr->width, gr->height, sizeof(DATA32), stride);
- cairo_surface_t *buffer_surface = cairo_image_surface_create_for_data(
- intermediate_buffer_aligned ? intermediate_buffer_aligned : (unsigned char*)intermediate_buffer,
- CAIRO_FORMAT_ARGB32, gr->width, gr->height, stride);
- cairo_set_source_surface(gr->cairo, buffer_surface, 0, 0);
- cairo_paint(gr->cairo);
-
- cairo_surface_destroy(buffer_surface);
- imlib_free_image();
- g_free(intermediate_buffer);
- g_free(intermediate_buffer_aligned);
+ imlib_blend_image_onto_image_skewed(img->image, 1, 0, 0, w, h, p[0].x-w/2, p[0].y-h/2, w, 0, 0, h);
+ }
+
+ stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, gr->width);
+ intermediate_buffer_aligned = create_buffer_with_stride_if_required(
+ (unsigned char* )intermediate_buffer, gr->width, gr->height, sizeof(DATA32), stride);
+ cairo_surface_t *buffer_surface = cairo_image_surface_create_for_data(
+ intermediate_buffer_aligned ? intermediate_buffer_aligned : (unsigned char*)intermediate_buffer,
+ CAIRO_FORMAT_ARGB32, gr->width, gr->height, stride);
+ cairo_set_source_surface(gr->cairo, buffer_surface, 0, 0);
+ cairo_paint(gr->cairo);
+
+ cairo_surface_destroy(buffer_surface);
+ imlib_free_image();
+ g_free(intermediate_buffer);
+ g_free(intermediate_buffer_aligned);
}
#endif
-static void
-overlay_rect(struct graphics_priv *parent, struct graphics_priv *overlay, GdkRectangle *r)
-{
- r->x=overlay->p.x;
- r->y=overlay->p.y;
- r->width=overlay->width;
- r->height=overlay->height;
- if (!overlay->wraparound)
- return;
- if (r->x < 0)
- r->x += parent->width;
- if (r->y < 0)
- r->y += parent->height;
- if (r->width < 0)
- r->width += parent->width;
- if (r->height < 0)
- r->height += parent->height;
+static void overlay_rect(struct graphics_priv *parent, struct graphics_priv *overlay, GdkRectangle *r) {
+ r->x=overlay->p.x;
+ r->y=overlay->p.y;
+ r->width=overlay->width;
+ r->height=overlay->height;
+ if (!overlay->wraparound)
+ return;
+ if (r->x < 0)
+ r->x += parent->width;
+ if (r->y < 0)
+ r->y += parent->height;
+ if (r->width < 0)
+ r->width += parent->width;
+ if (r->height < 0)
+ r->height += parent->height;
}
-static void
-overlay_draw(struct graphics_priv *parent, struct graphics_priv *overlay, GdkRectangle *re, cairo_t *cairo)
-{
- GdkRectangle or, ir;
- if (parent->overlay_disabled || overlay->overlay_disabled || overlay->overlay_autodisabled)
- return;
- overlay_rect(parent, overlay, &or);
- if (! gdk_rectangle_intersect(re, &or, &ir))
- return;
- or.x-=re->x;
- or.y-=re->y;
- cairo_surface_t *overlay_surface = cairo_get_target(overlay->cairo);
- cairo_set_source_surface(cairo, overlay_surface, or.x, or.y);
- cairo_paint(cairo);
+static void overlay_draw(struct graphics_priv *parent, struct graphics_priv *overlay, GdkRectangle *re, cairo_t *cairo) {
+ GdkRectangle or, ir;
+ if (parent->overlay_disabled || overlay->overlay_disabled || overlay->overlay_autodisabled)
+ return;
+ overlay_rect(parent, overlay, &or);
+ if (! gdk_rectangle_intersect(re, &or, &ir))
+ return;
+ or.x-=re->x;
+ or.y-=re->y;
+ cairo_surface_t *overlay_surface = cairo_get_target(overlay->cairo);
+ cairo_set_source_surface(cairo, overlay_surface, or.x, or.y);
+ cairo_paint(cairo);
}
-static void
-draw_drag(struct graphics_priv *gr, struct point *p)
-{
- if (p)
- gr->p=*p;
- else {
- gr->p.x=0;
- gr->p.y=0;
- }
+static void draw_drag(struct graphics_priv *gr, struct point *p) {
+ if (p)
+ gr->p=*p;
+ else {
+ gr->p.x=0;
+ gr->p.y=0;
+ }
}
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
- gr->background_gc=gc;
+static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
+ gr->background_gc=gc;
}
-static void
-draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
- if (mode == draw_mode_end) {
- // Just invalidate the whole window. We could only the invalidate the area of
- // graphics_priv, but that is probably not significantly faster.
- gdk_window_invalidate_rect(gr->widget->window, NULL, TRUE);
- }
+static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode) {
+ if (mode == draw_mode_end) {
+ // Just invalidate the whole window. We could only the invalidate the area of
+ // graphics_priv, but that is probably not significantly faster.
+ gdk_window_invalidate_rect(gr->widget->window, NULL, TRUE);
+ }
}
/* Events */
-static gint
-configure(GtkWidget * widget, GdkEventConfigure * event, gpointer user_data)
-{
- struct graphics_priv *gra=user_data;
- if (! gra->visible)
- return TRUE;
+static gint configure(GtkWidget * widget, GdkEventConfigure * event, gpointer user_data) {
+ struct graphics_priv *gra=user_data;
+ if (! gra->visible)
+ return TRUE;
#ifndef _WIN32
- dbg(lvl_debug,"window=%lu\n", GDK_WINDOW_XID(widget->window));
+ dbg(lvl_debug,"window=%lu", GDK_WINDOW_XID(widget->window));
#endif
- gra->width=widget->allocation.width;
- gra->height=widget->allocation.height;
- cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, gra->width, gra->height);
- if (gra->cairo)
- cairo_destroy(gra->cairo);
- gra->cairo = cairo_create(surface);
- cairo_surface_destroy(surface);
- cairo_set_antialias (gra->cairo, CAIRO_ANTIALIAS_GOOD);
- callback_list_call_attr_2(gra->cbl, attr_resize, GINT_TO_POINTER(gra->width), GINT_TO_POINTER(gra->height));
- return TRUE;
+ gra->width=widget->allocation.width;
+ gra->height=widget->allocation.height;
+ cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, gra->width, gra->height);
+ if (gra->cairo)
+ cairo_destroy(gra->cairo);
+ gra->cairo = cairo_create(surface);
+ cairo_surface_destroy(surface);
+ cairo_set_antialias (gra->cairo, CAIRO_ANTIALIAS_GOOD);
+ callback_list_call_attr_2(gra->cbl, attr_resize, GINT_TO_POINTER(gra->width), GINT_TO_POINTER(gra->height));
+ return TRUE;
}
-static gint
-expose(GtkWidget * widget, GdkEventExpose * event, gpointer user_data)
-{
- struct graphics_priv *gra=user_data;
- struct graphics_gc_priv *background_gc=gra->background_gc;
- struct graphics_priv *overlay;
-
- gra->visible=1;
- if (! gra->cairo)
- configure(widget, NULL, user_data);
-
- cairo_t *cairo=gdk_cairo_create(widget->window);
- if (gra->p.x || gra->p.y) {
- set_drawing_color(cairo, background_gc->c);
- cairo_paint(cairo);
- }
- cairo_set_source_surface(cairo, cairo_get_target(gra->cairo), gra->p.x, gra->p.y);
- cairo_paint(cairo);
-
- overlay = gra->overlays;
- while (overlay) {
- overlay_draw(gra,overlay,&event->area,cairo);
- overlay=overlay->next;
- }
-
- cairo_destroy(cairo);
- return FALSE;
+static gint expose(GtkWidget * widget, GdkEventExpose * event, gpointer user_data) {
+ struct graphics_priv *gra=user_data;
+ struct graphics_gc_priv *background_gc=gra->background_gc;
+ struct graphics_priv *overlay;
+
+ gra->visible=1;
+ if (! gra->cairo)
+ configure(widget, NULL, user_data);
+
+ cairo_t *cairo=gdk_cairo_create(widget->window);
+ if (gra->p.x || gra->p.y) {
+ set_drawing_color(cairo, background_gc->c);
+ cairo_paint(cairo);
+ }
+ cairo_set_source_surface(cairo, cairo_get_target(gra->cairo), gra->p.x, gra->p.y);
+ cairo_paint(cairo);
+
+ overlay = gra->overlays;
+ while (overlay) {
+ overlay_draw(gra,overlay,&event->area,cairo);
+ overlay=overlay->next;
+ }
+
+ cairo_destroy(cairo);
+ return FALSE;
}
-static int
-tv_delta(struct timeval *old, struct timeval *new)
-{
- if (new->tv_sec-old->tv_sec >= INT_MAX/1000)
- return INT_MAX;
- return (new->tv_sec-old->tv_sec)*1000+(new->tv_usec-old->tv_usec)/1000;
+static int tv_delta(struct timeval *old, struct timeval *new) {
+ if (new->tv_sec-old->tv_sec >= INT_MAX/1000)
+ return INT_MAX;
+ return (new->tv_sec-old->tv_sec)*1000+(new->tv_usec-old->tv_usec)/1000;
}
-static gint
-button_press(GtkWidget * widget, GdkEventButton * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday(&tv, &tz);
-
- if (event->button < 8) {
- if (tv_delta(&this->button_press[event->button], &tv) < this->timeout)
- return FALSE;
- this->button_press[event->button]= tv;
- this->button_release[event->button].tv_sec=0;
- this->button_release[event->button].tv_usec=0;
- }
- p.x=event->x;
- p.y=event->y;
- callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(event->button), (void *)&p);
- return FALSE;
+static gint button_press(GtkWidget * widget, GdkEventButton * event, gpointer user_data) {
+ struct graphics_priv *this=user_data;
+ struct point p;
+ struct timeval tv;
+ struct timezone tz;
+
+ gettimeofday(&tv, &tz);
+
+ if (event->button < 8) {
+ if (tv_delta(&this->button_press[event->button], &tv) < this->timeout)
+ return FALSE;
+ this->button_press[event->button]= tv;
+ this->button_release[event->button].tv_sec=0;
+ this->button_release[event->button].tv_usec=0;
+ }
+ p.x=event->x;
+ p.y=event->y;
+ callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(event->button), (void *)&p);
+ return FALSE;
}
-static gint
-button_release(GtkWidget * widget, GdkEventButton * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday(&tv, &tz);
-
- if (event->button < 8) {
- if (tv_delta(&this->button_release[event->button], &tv) < this->timeout)
- return FALSE;
- this->button_release[event->button]= tv;
- this->button_press[event->button].tv_sec=0;
- this->button_press[event->button].tv_usec=0;
- }
- p.x=event->x;
- p.y=event->y;
- callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(event->button), (void *)&p);
- return FALSE;
+static gint button_release(GtkWidget * widget, GdkEventButton * event, gpointer user_data) {
+ struct graphics_priv *this=user_data;
+ struct point p;
+ struct timeval tv;
+ struct timezone tz;
+
+ gettimeofday(&tv, &tz);
+
+ if (event->button < 8) {
+ if (tv_delta(&this->button_release[event->button], &tv) < this->timeout)
+ return FALSE;
+ this->button_release[event->button]= tv;
+ this->button_press[event->button].tv_sec=0;
+ this->button_press[event->button].tv_usec=0;
+ }
+ p.x=event->x;
+ p.y=event->y;
+ callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(event->button), (void *)&p);
+ return FALSE;
}
-static gint
-scroll(GtkWidget * widget, GdkEventScroll * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
- int button;
-
- p.x=event->x;
- p.y=event->y;
- switch (event->direction) {
- case GDK_SCROLL_UP:
- button=4;
- break;
- case GDK_SCROLL_DOWN:
- button=5;
- break;
- default:
- button=-1;
- break;
- }
- if (button != -1) {
- callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button), (void *)&p);
- callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button), (void *)&p);
- }
- return FALSE;
+static gint scroll(GtkWidget * widget, GdkEventScroll * event, gpointer user_data) {
+ struct graphics_priv *this=user_data;
+ struct point p;
+ int button;
+
+ p.x=event->x;
+ p.y=event->y;
+ switch (event->direction) {
+ case GDK_SCROLL_UP:
+ button=4;
+ break;
+ case GDK_SCROLL_DOWN:
+ button=5;
+ break;
+ default:
+ button=-1;
+ break;
+ }
+ if (button != -1) {
+ callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button), (void *)&p);
+ callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button), (void *)&p);
+ }
+ return FALSE;
}
-static gint
-motion_notify(GtkWidget * widget, GdkEventMotion * event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- struct point p;
+static gint motion_notify(GtkWidget * widget, GdkEventMotion * event, gpointer user_data) {
+ struct graphics_priv *this=user_data;
+ struct point p;
- p.x=event->x;
- p.y=event->y;
- callback_list_call_attr_1(this->cbl, attr_motion, (void *)&p);
- return FALSE;
+ p.x=event->x;
+ p.y=event->y;
+ callback_list_call_attr_1(this->cbl, attr_motion, (void *)&p);
+ return FALSE;
}
/* *
@@ -745,410 +679,390 @@ motion_notify(GtkWidget * widget, GdkEventMotion * event, gpointer user_data)
* * @param user_data Pointer to private data structure
* * @returns TRUE
* */
-static gint
-delete(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- dbg(lvl_debug,"enter this->win=%p\n",this->win);
- if (this->delay & 2) {
- if (this->win)
- this->win=NULL;
- } else {
- callback_list_call_attr_0(this->cbl, attr_window_closed);
- }
- return TRUE;
+static gint delete(GtkWidget *widget, GdkEventKey *event, gpointer user_data) {
+ struct graphics_priv *this=user_data;
+ dbg(lvl_debug,"enter this->win=%p",this->win);
+ if (this->delay & 2) {
+ if (this->win)
+ this->win=NULL;
+ } else {
+ callback_list_call_attr_0(this->cbl, attr_window_closed);
+ }
+ return TRUE;
}
-static gint
-keypress(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
-{
- struct graphics_priv *this=user_data;
- int len,ucode;
- char key[8];
- ucode=gdk_keyval_to_unicode(event->keyval);
- len=g_unichar_to_utf8(ucode, key);
- key[len]='\0';
-
- switch (event->keyval) {
- case GDK_Up:
- key[0]=NAVIT_KEY_UP;
- key[1]='\0';
- break;
- case GDK_Down:
- key[0]=NAVIT_KEY_DOWN;
- key[1]='\0';
- break;
- case GDK_Left:
- key[0]=NAVIT_KEY_LEFT;
- key[1]='\0';
- break;
- case GDK_Right:
- key[0]=NAVIT_KEY_RIGHT;
- key[1]='\0';
- break;
- case GDK_BackSpace:
- key[0]=NAVIT_KEY_BACKSPACE;
- key[1]='\0';
- break;
- case GDK_Tab:
- key[0]='\t';
- key[1]='\0';
- break;
- case GDK_Delete:
- key[0]=NAVIT_KEY_DELETE;
- key[1]='\0';
- break;
- case GDK_Escape:
- key[0]=NAVIT_KEY_BACK;
- key[1]='\0';
- break;
- case GDK_Return:
- case GDK_KP_Enter:
- key[0]=NAVIT_KEY_RETURN;
- key[1]='\0';
- break;
- case GDK_Book:
+static gint keypress(GtkWidget *widget, GdkEventKey *event, gpointer user_data) {
+ struct graphics_priv *this=user_data;
+ int len,ucode;
+ char key[8];
+ ucode=gdk_keyval_to_unicode(event->keyval);
+ len=g_unichar_to_utf8(ucode, key);
+ key[len]='\0';
+
+ switch (event->keyval) {
+ case GDK_Up:
+ key[0]=NAVIT_KEY_UP;
+ key[1]='\0';
+ break;
+ case GDK_Down:
+ key[0]=NAVIT_KEY_DOWN;
+ key[1]='\0';
+ break;
+ case GDK_Left:
+ key[0]=NAVIT_KEY_LEFT;
+ key[1]='\0';
+ break;
+ case GDK_Right:
+ key[0]=NAVIT_KEY_RIGHT;
+ key[1]='\0';
+ break;
+ case GDK_BackSpace:
+ key[0]=NAVIT_KEY_BACKSPACE;
+ key[1]='\0';
+ break;
+ case GDK_Tab:
+ key[0]='\t';
+ key[1]='\0';
+ break;
+ case GDK_Delete:
+ key[0]=NAVIT_KEY_DELETE;
+ key[1]='\0';
+ break;
+ case GDK_Escape:
+ key[0]=NAVIT_KEY_BACK;
+ key[1]='\0';
+ break;
+ case GDK_Return:
+ case GDK_KP_Enter:
+ key[0]=NAVIT_KEY_RETURN;
+ key[1]='\0';
+ break;
+ case GDK_Book:
#ifdef USE_HILDON
- case GDK_F7:
+ case GDK_F7:
#endif
- key[0]=NAVIT_KEY_ZOOM_IN;
- key[1]='\0';
- break;
- case GDK_Calendar:
+ key[0]=NAVIT_KEY_ZOOM_IN;
+ key[1]='\0';
+ break;
+ case GDK_Calendar:
#ifdef USE_HILDON
- case GDK_F8:
+ case GDK_F8:
#endif
- key[0]=NAVIT_KEY_ZOOM_OUT;
- key[1]='\0';
- break;
- case GDK_Page_Up:
- key[0]=NAVIT_KEY_PAGE_UP;
- key[1]='\0';
- break;
- case GDK_Page_Down:
- key[0]=NAVIT_KEY_PAGE_DOWN;
- key[1]='\0';
- break;
- }
- if (key[0])
- callback_list_call_attr_1(this->cbl, attr_keypress, (void *)key);
- else
- dbg(lvl_debug,"keyval 0x%x\n", event->keyval);
-
- return FALSE;
+ key[0]=NAVIT_KEY_ZOOM_OUT;
+ key[1]='\0';
+ break;
+ case GDK_Page_Up:
+ key[0]=NAVIT_KEY_PAGE_UP;
+ key[1]='\0';
+ break;
+ case GDK_Page_Down:
+ key[0]=NAVIT_KEY_PAGE_DOWN;
+ key[1]='\0';
+ break;
+ }
+ if (key[0])
+ callback_list_call_attr_1(this->cbl, attr_keypress, (void *)key);
+ else
+ dbg(lvl_debug,"keyval 0x%x", event->keyval);
+
+ return FALSE;
}
static struct graphics_priv *graphics_gtk_drawing_area_new_helper(struct graphics_methods *meth);
-static void
-overlay_disable(struct graphics_priv *gr, int disabled)
-{
- if (!gr->overlay_disabled != !disabled) {
- gr->overlay_disabled=disabled;
- if (gr->parent) {
- GdkRectangle r;
- overlay_rect(gr->parent, gr, &r);
- gdk_window_invalidate_rect(gr->parent->widget->window, &r, TRUE);
- }
- }
+static void overlay_disable(struct graphics_priv *gr, int disabled) {
+ if (!gr->overlay_disabled != !disabled) {
+ gr->overlay_disabled=disabled;
+ if (gr->parent) {
+ GdkRectangle r;
+ overlay_rect(gr->parent, gr, &r);
+ gdk_window_invalidate_rect(gr->parent->widget->window, &r, TRUE);
+ }
+ }
}
-static void
-overlay_resize(struct graphics_priv *this, struct point *p, int w, int h, int wraparound)
-{
- //do not dereference parent for non overlay osds
- if(!this->parent) {
- return;
- }
-
- int changed = 0;
- int w2,h2;
-
- if (w == 0) {
- w2 = 1;
- } else {
- w2 = w;
- }
-
- if (h == 0) {
- h2 = 1;
- } else {
- h2 = h;
- }
-
- this->p = *p;
- if (this->width != w2) {
- this->width = w2;
- changed = 1;
- }
-
- if (this->height != h2) {
- this->height = h2;
- changed = 1;
- }
-
- this->wraparound = wraparound;
-
- if (changed) {
- cairo_destroy(this->cairo);
- cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w2, h2);
- this->cairo=cairo_create(surface);
- cairo_surface_destroy(surface);
-
- if ((w == 0) || (h == 0)) {
- this->overlay_autodisabled = 1;
- } else {
- this->overlay_autodisabled = 0;
- }
-
- callback_list_call_attr_2(this->cbl, attr_resize, GINT_TO_POINTER(this->width), GINT_TO_POINTER(this->height));
- }
+static void overlay_resize(struct graphics_priv *this, struct point *p, int w, int h, int wraparound) {
+ //do not dereference parent for non overlay osds
+ if(!this->parent) {
+ return;
+ }
+
+ int changed = 0;
+ int w2,h2;
+
+ if (w == 0) {
+ w2 = 1;
+ } else {
+ w2 = w;
+ }
+
+ if (h == 0) {
+ h2 = 1;
+ } else {
+ h2 = h;
+ }
+
+ this->p = *p;
+ if (this->width != w2) {
+ this->width = w2;
+ changed = 1;
+ }
+
+ if (this->height != h2) {
+ this->height = h2;
+ changed = 1;
+ }
+
+ this->wraparound = wraparound;
+
+ if (changed) {
+ cairo_destroy(this->cairo);
+ cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w2, h2);
+ this->cairo=cairo_create(surface);
+ cairo_surface_destroy(surface);
+
+ if ((w == 0) || (h == 0)) {
+ this->overlay_autodisabled = 1;
+ } else {
+ this->overlay_autodisabled = 0;
+ }
+
+ callback_list_call_attr_2(this->cbl, attr_resize, GINT_TO_POINTER(this->width), GINT_TO_POINTER(this->height));
+ }
}
-static void
-get_data_window(struct graphics_priv *this, unsigned int xid)
-{
- if (!xid)
- this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- else
- this->win = gtk_plug_new(xid);
- if (!gtk_widget_get_parent(this->widget))
- gtk_widget_ref(this->widget);
- gtk_window_set_default_size(GTK_WINDOW(this->win), this->win_w, this->win_h);
- dbg(lvl_debug,"h= %i, w= %i\n",this->win_h, this->win_w);
- gtk_window_set_title(GTK_WINDOW(this->win), this->window_title);
- gtk_window_set_wmclass (GTK_WINDOW (this->win), "navit", this->window_title);
- gtk_widget_realize(this->win);
- if (gtk_widget_get_parent(this->widget))
- gtk_widget_reparent(this->widget, this->win);
- else
- gtk_container_add(GTK_CONTAINER(this->win), this->widget);
- gtk_widget_show_all(this->win);
- GTK_WIDGET_SET_FLAGS (this->widget, GTK_CAN_FOCUS);
- gtk_widget_set_sensitive(this->widget, TRUE);
- gtk_widget_grab_focus(this->widget);
- g_signal_connect(G_OBJECT(this->widget), "key-press-event", G_CALLBACK(keypress), this);
- g_signal_connect(G_OBJECT(this->win), "delete_event", G_CALLBACK(delete), this);
+static void get_data_window(struct graphics_priv *this, unsigned int xid) {
+ if (!xid)
+ this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ else
+ this->win = gtk_plug_new(xid);
+ if (!gtk_widget_get_parent(this->widget))
+ gtk_widget_ref(this->widget);
+ gtk_window_set_default_size(GTK_WINDOW(this->win), this->win_w, this->win_h);
+ dbg(lvl_debug,"h= %i, w= %i",this->win_h, this->win_w);
+ gtk_window_set_title(GTK_WINDOW(this->win), this->window_title);
+ gtk_window_set_wmclass (GTK_WINDOW (this->win), "navit", this->window_title);
+ gtk_widget_realize(this->win);
+ if (gtk_widget_get_parent(this->widget))
+ gtk_widget_reparent(this->widget, this->win);
+ else
+ gtk_container_add(GTK_CONTAINER(this->win), this->widget);
+ gtk_widget_show_all(this->win);
+ GTK_WIDGET_SET_FLAGS (this->widget, GTK_CAN_FOCUS);
+ gtk_widget_set_sensitive(this->widget, TRUE);
+ gtk_widget_grab_focus(this->widget);
+ g_signal_connect(G_OBJECT(this->widget), "key-press-event", G_CALLBACK(keypress), this);
+ g_signal_connect(G_OBJECT(this->win), "delete_event", G_CALLBACK(delete), this);
}
-static int
-set_attr(struct graphics_priv *gr, struct attr *attr)
-{
- dbg(lvl_debug,"enter\n");
- switch (attr->type) {
- case attr_windowid:
- get_data_window(gr, attr->u.num);
- return 1;
- default:
- return 0;
- }
+static int set_attr(struct graphics_priv *gr, struct attr *attr) {
+ dbg(lvl_debug,"enter");
+ switch (attr->type) {
+ case attr_windowid:
+ get_data_window(gr, attr->u.num);
+ return 1;
+ default:
+ return 0;
+ }
}
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
-{
- int w2,h2;
- struct graphics_priv *this=graphics_gtk_drawing_area_new_helper(meth);
- this->widget=gr->widget;
- this->p=*p;
- this->width=w;
- this->height=h;
- this->parent=gr;
-
- /* If either height or width is 0, we set it to 1 to avoid warnings, and
- * disable the overlay. */
- if (h == 0) {
- h2 = 1;
- } else {
- h2 = h;
- }
-
- if (w == 0) {
- w2 = 1;
- } else {
- w2 = w;
- }
-
- cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w2, h2);
- this->cairo=cairo_create(surface);
- cairo_surface_destroy(surface);
-
- if ((w == 0) || (h == 0)) {
- this->overlay_autodisabled = 1;
- } else {
- this->overlay_autodisabled = 0;
- }
-
- this->next=gr->overlays;
- this->wraparound=wraparound;
- gr->overlays=this;
- return this;
+static struct graphics_priv *overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound) {
+ int w2,h2;
+ struct graphics_priv *this=graphics_gtk_drawing_area_new_helper(meth);
+ this->widget=gr->widget;
+ this->p=*p;
+ this->width=w;
+ this->height=h;
+ this->parent=gr;
+
+ /* If either height or width is 0, we set it to 1 to avoid warnings, and
+ * disable the overlay. */
+ if (h == 0) {
+ h2 = 1;
+ } else {
+ h2 = h;
+ }
+
+ if (w == 0) {
+ w2 = 1;
+ } else {
+ w2 = w;
+ }
+
+ cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w2, h2);
+ this->cairo=cairo_create(surface);
+ cairo_surface_destroy(surface);
+
+ if ((w == 0) || (h == 0)) {
+ this->overlay_autodisabled = 1;
+ } else {
+ this->overlay_autodisabled = 0;
+ }
+
+ this->next=gr->overlays;
+ this->wraparound=wraparound;
+ gr->overlays=this;
+ return this;
}
static int gtk_argc;
-static char **gtk_argv={NULL};
+static char **gtk_argv= {NULL};
-static int
-graphics_gtk_drawing_area_fullscreen(struct window *w, int on)
-{
- struct graphics_priv *gr=w->priv;
- if (on)
- gtk_window_fullscreen(GTK_WINDOW(gr->win));
- else
- gtk_window_unfullscreen(GTK_WINDOW(gr->win));
- return 1;
-}
+static int graphics_gtk_drawing_area_fullscreen(struct window *w, int on) {
+ struct graphics_priv *gr=w->priv;
+ if (on)
+ gtk_window_fullscreen(GTK_WINDOW(gr->win));
+ else
+ gtk_window_unfullscreen(GTK_WINDOW(gr->win));
+ return 1;
+}
-static void
-graphics_gtk_drawing_area_disable_suspend(struct window *w)
-{
- struct graphics_priv *gr=w->priv;
+static void graphics_gtk_drawing_area_disable_suspend(struct window *w) {
+ struct graphics_priv *gr=w->priv;
#ifndef _WIN32
- if (gr->pid)
- kill(gr->pid, SIGWINCH);
+ if (gr->pid)
+ kill(gr->pid, SIGWINCH);
#else
- dbg(lvl_warning, "failed to kill() under Windows\n");
+ dbg(lvl_warning, "failed to kill() under Windows");
#endif
}
-static void *
-get_data(struct graphics_priv *this, char const *type)
-{
- FILE *f;
- if (!strcmp(type,"gtk_widget"))
- return this->widget;
+static void *get_data(struct graphics_priv *this, char const *type) {
+ FILE *f;
+ if (!strcmp(type,"gtk_widget"))
+ return this->widget;
#ifndef _WIN32
- if (!strcmp(type,"xwindow_id"))
- return (void *)GDK_WINDOW_XID(this->win ? this->win->window : this->widget->window);
+ if (!strcmp(type,"xwindow_id"))
+ return (void *)GDK_WINDOW_XID(this->win ? this->win->window : this->widget->window);
#endif
- if (!strcmp(type,"window")) {
- char *cp = getenv("NAVIT_XID");
- unsigned xid = 0;
- if (cp)
- xid = strtol(cp, NULL, 0);
- if (!(this->delay & 1))
- get_data_window(this, xid);
- this->window.fullscreen=graphics_gtk_drawing_area_fullscreen;
- this->window.disable_suspend=graphics_gtk_drawing_area_disable_suspend;
- this->window.priv=this;
+ if (!strcmp(type,"window")) {
+ char *cp = getenv("NAVIT_XID");
+ unsigned xid = 0;
+ if (cp)
+ xid = strtol(cp, NULL, 0);
+ if (!(this->delay & 1))
+ get_data_window(this, xid);
+ this->window.fullscreen=graphics_gtk_drawing_area_fullscreen;
+ this->window.disable_suspend=graphics_gtk_drawing_area_disable_suspend;
+ this->window.priv=this;
#if !defined(_WIN32) && !defined(__CEGCC__)
- f=popen("pidof /usr/bin/ipaq-sleep","r");
- if (f) {
- fscanf(f,"%d",&this->pid);
- dbg(lvl_debug,"ipaq_sleep pid=%d\n", this->pid);
- pclose(f);
- }
+ f=popen("pidof /usr/bin/ipaq-sleep","r");
+ if (f) {
+ int fscanf_result;
+ fscanf_result = fscanf(f,"%d",&this->pid);
+ if ((fscanf_result == EOF) || (fscanf_result == 0)) {
+ dbg(lvl_warning, "Failed to open iPaq sleep file. Error-Code: %d", errno);
+ }
+ dbg(lvl_debug,"ipaq_sleep pid=%d", this->pid);
+ pclose(f);
+ }
#endif
- return &this->window;
- }
- return NULL;
+ return &this->window;
+ }
+ return NULL;
}
static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
+ graphics_destroy,
+ draw_mode,
+ draw_lines,
+ draw_polygon,
+ draw_rectangle,
+ draw_circle,
+ draw_text,
+ draw_image,
#ifdef HAVE_IMLIB2
- draw_image_warp,
+ draw_image_warp,
#else
- NULL,
+ NULL,
#endif
- draw_drag,
- NULL, /* font_new */
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- image_free,
- NULL, /* get_text_bbox */
- overlay_disable,
- overlay_resize,
- set_attr,
- NULL, /* show_native_keyboard */
- NULL, /* hide_native_keyboard */
+ draw_drag,
+ NULL, /* font_new */
+ gc_new,
+ background_gc,
+ overlay_new,
+ image_new,
+ get_data,
+ image_free,
+ NULL, /* get_text_bbox */
+ overlay_disable,
+ overlay_resize,
+ set_attr,
+ NULL, /* show_native_keyboard */
+ NULL, /* hide_native_keyboard */
};
-static struct graphics_priv *
-graphics_gtk_drawing_area_new_helper(struct graphics_methods *meth)
-{
- struct font_priv * (*font_freetype_new)(void *meth);
- font_freetype_new=plugin_get_category_font("freetype");
- if (!font_freetype_new)
- return NULL;
- struct graphics_priv *this=g_new0(struct graphics_priv,1);
- font_freetype_new(&this->freetype_methods);
- *meth=graphics_methods;
- meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int, int))this->freetype_methods.font_new;
- meth->get_text_bbox=(void(*)(struct graphics_priv*, struct graphics_font_priv *, char *, int, int, struct point *, int))this->freetype_methods.get_text_bbox;
- return this;
+static struct graphics_priv *graphics_gtk_drawing_area_new_helper(struct graphics_methods *meth) {
+ struct font_priv * (*font_freetype_new)(void *meth);
+ font_freetype_new=plugin_get_category_font("freetype");
+ if (!font_freetype_new)
+ return NULL;
+ struct graphics_priv *this=g_new0(struct graphics_priv,1);
+ font_freetype_new(&this->freetype_methods);
+ *meth=graphics_methods;
+ meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int,
+ int))this->freetype_methods.font_new;
+ meth->get_text_bbox=(void(*)(struct graphics_priv*, struct graphics_font_priv *, char *, int, int, struct point *,
+ int))this->freetype_methods.get_text_bbox;
+ return this;
}
-static struct graphics_priv *
-graphics_gtk_drawing_area_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- int i;
- GtkWidget *draw;
- struct attr *attr;
-
- if (! event_request_system("glib","graphics_gtk_drawing_area_new"))
- return NULL;
-
- draw=gtk_drawing_area_new();
- struct graphics_priv *this=graphics_gtk_drawing_area_new_helper(meth);
- this->nav = nav;
- this->widget=draw;
- this->win_w=792;
- if ((attr=attr_search(attrs, NULL, attr_w)))
- this->win_w=attr->u.num;
- this->win_h=547;
- if ((attr=attr_search(attrs, NULL, attr_h)))
- this->win_h=attr->u.num;
- this->timeout=100;
- if ((attr=attr_search(attrs, NULL, attr_timeout)))
- this->timeout=attr->u.num;
- this->delay=0;
- if ((attr=attr_search(attrs, NULL, attr_delay)))
- this->delay=attr->u.num;
- if ((attr=attr_search(attrs, NULL, attr_window_title)))
- this->window_title=g_strdup(attr->u.str);
- else
- this->window_title=g_strdup("Navit");
- this->cbl=cbl;
- gtk_widget_set_events(draw, GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_KEY_PRESS_MASK);
- g_signal_connect(G_OBJECT(draw), "expose_event", G_CALLBACK(expose), this);
- g_signal_connect(G_OBJECT(draw), "configure_event", G_CALLBACK(configure), this);
- g_signal_connect(G_OBJECT(draw), "button_press_event", G_CALLBACK(button_press), this);
- g_signal_connect(G_OBJECT(draw), "button_release_event", G_CALLBACK(button_release), this);
- g_signal_connect(G_OBJECT(draw), "scroll_event", G_CALLBACK(scroll), this);
- g_signal_connect(G_OBJECT(draw), "motion_notify_event", G_CALLBACK(motion_notify), this);
- g_signal_connect(G_OBJECT(draw), "delete_event", G_CALLBACK(delete), nav);
-
- for (i = 0; i < 8; i++) {
- this->button_press[i].tv_sec = 0;
- this->button_press[i].tv_usec = 0;
- this->button_release[i].tv_sec = 0;
- this->button_release[i].tv_usec = 0;
- }
-
- return this;
+static struct graphics_priv *graphics_gtk_drawing_area_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ int i;
+ GtkWidget *draw;
+ struct attr *attr;
+
+ if (! event_request_system("glib","graphics_gtk_drawing_area_new"))
+ return NULL;
+
+ draw=gtk_drawing_area_new();
+ struct graphics_priv *this=graphics_gtk_drawing_area_new_helper(meth);
+ this->nav = nav;
+ this->widget=draw;
+ this->win_w=792;
+ if ((attr=attr_search(attrs, NULL, attr_w)))
+ this->win_w=attr->u.num;
+ this->win_h=547;
+ if ((attr=attr_search(attrs, NULL, attr_h)))
+ this->win_h=attr->u.num;
+ this->timeout=100;
+ if ((attr=attr_search(attrs, NULL, attr_timeout)))
+ this->timeout=attr->u.num;
+ this->delay=0;
+ if ((attr=attr_search(attrs, NULL, attr_delay)))
+ this->delay=attr->u.num;
+ if ((attr=attr_search(attrs, NULL, attr_window_title)))
+ this->window_title=g_strdup(attr->u.str);
+ else
+ this->window_title=g_strdup("Navit");
+ this->cbl=cbl;
+ gtk_widget_set_events(draw, GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_KEY_PRESS_MASK);
+ g_signal_connect(G_OBJECT(draw), "expose_event", G_CALLBACK(expose), this);
+ g_signal_connect(G_OBJECT(draw), "configure_event", G_CALLBACK(configure), this);
+ g_signal_connect(G_OBJECT(draw), "button_press_event", G_CALLBACK(button_press), this);
+ g_signal_connect(G_OBJECT(draw), "button_release_event", G_CALLBACK(button_release), this);
+ g_signal_connect(G_OBJECT(draw), "scroll_event", G_CALLBACK(scroll), this);
+ g_signal_connect(G_OBJECT(draw), "motion_notify_event", G_CALLBACK(motion_notify), this);
+ g_signal_connect(G_OBJECT(draw), "delete_event", G_CALLBACK(delete), nav);
+
+ for (i = 0; i < 8; i++) {
+ this->button_press[i].tv_sec = 0;
+ this->button_press[i].tv_usec = 0;
+ this->button_release[i].tv_sec = 0;
+ this->button_release[i].tv_usec = 0;
+ }
+
+ return this;
}
-void
-plugin_init(void)
-{
- gtk_init(&gtk_argc, &gtk_argv);
- gtk_set_locale();
+void plugin_init(void) {
+ gtk_init(&gtk_argc, &gtk_argv);
+ gtk_set_locale();
#ifdef HAVE_API_WIN32
- setlocale(LC_NUMERIC, "C"); /* WIN32 gtk resets LC_NUMERIC */
+ setlocale(LC_NUMERIC, "C"); /* WIN32 gtk resets LC_NUMERIC */
#endif
- plugin_register_category_graphics("gtk_drawing_area", graphics_gtk_drawing_area_new);
+ plugin_register_category_graphics("gtk_drawing_area", graphics_gtk_drawing_area_new);
}
diff --git a/navit/graphics/null/graphics_null.c b/navit/graphics/null/graphics_null.c
index ecac7d528..c3a21185b 100644
--- a/navit/graphics/null/graphics_null.c
+++ b/navit/graphics/null/graphics_null.c
@@ -39,321 +39,249 @@
static struct callback_list* callbacks;
static struct graphics_priv {
- int dummy;
+ int dummy;
} graphics_priv;
static struct graphics_font_priv {
- int dummy;
+ int dummy;
} graphics_font_priv;
static struct graphics_gc_priv {
- int dummy;
+ int dummy;
} graphics_gc_priv;
static struct graphics_image_priv {
- int dummy;
+ int dummy;
} graphics_image_priv;
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
+static void graphics_destroy(struct graphics_priv *gr) {
}
-static void font_destroy(struct graphics_font_priv *font)
-{
+static void font_destroy(struct graphics_font_priv *font) {
}
static struct graphics_font_methods font_methods = {
- font_destroy
+ font_destroy
};
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags)
-{
- *meth=font_methods;
- return &graphics_font_priv;
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags) {
+ *meth=font_methods;
+ return &graphics_font_priv;
}
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
+static void gc_destroy(struct graphics_gc_priv *gc) {
}
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
+static void gc_set_linewidth(struct graphics_gc_priv *gc, int w) {
}
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
-{
+static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n) {
}
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c) {
}
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_background(struct graphics_gc_priv *gc, struct color *c) {
}
static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
+ gc_destroy,
+ gc_set_linewidth,
+ gc_set_dashes,
+ gc_set_foreground,
+ gc_set_background
};
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- *meth=gc_methods;
- return &graphics_gc_priv;
+static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) {
+ *meth=gc_methods;
+ return &graphics_gc_priv;
}
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation)
-{
- return &graphics_image_priv;
+static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation) {
+ return &graphics_image_priv;
}
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
+static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
}
-static void
-draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
+static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
}
-static void
-draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
+static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
}
-static void
-draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
+static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r) {
}
-static void
-draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
+static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
}
-static void
-draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
+static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img) {
}
-static void draw_drag(struct graphics_priv *gr, struct point *p)
-{
+static void draw_drag(struct graphics_priv *gr, struct point *p) {
}
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
+static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
}
-static void
-draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
+static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode) {
}
static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound);
-static void
-resize_callback(int w, int h)
-{
- callback_list_call_attr_2(callbacks, attr_resize,
- GINT_TO_POINTER(1), GINT_TO_POINTER(1));
+static void resize_callback(int w, int h) {
+ callback_list_call_attr_2(callbacks, attr_resize, GINT_TO_POINTER(1), GINT_TO_POINTER(1));
}
-static int
-graphics_null_fullscreen(struct window *w, int on)
-{
- return 1;
+static int graphics_null_fullscreen(struct window *w, int on) {
+ return 1;
}
-static void
-graphics_null_disable_suspend(struct window *w)
-{
+static void graphics_null_disable_suspend(struct window *w) {
}
-static void *
-get_data(struct graphics_priv *this, char const *type)
-{
- if (strcmp(type, "window") == 0) {
- struct window *win;
- win = g_new0(struct window, 1);
- win->priv = this;
- win->fullscreen = graphics_null_fullscreen;
- win->disable_suspend = graphics_null_disable_suspend;
- resize_callback(1,1);
- return win;
- }
- return NULL;
+static void *get_data(struct graphics_priv *this, char const *type) {
+ if (strcmp(type, "window") == 0) {
+ struct window *win;
+ win = g_new0(struct window, 1);
+ win->priv = this;
+ win->fullscreen = graphics_null_fullscreen;
+ win->disable_suspend = graphics_null_disable_suspend;
+ resize_callback(1,1);
+ return win;
+ }
+ return NULL;
}
-static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
-{
+static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv) {
}
-static void get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate)
-{
+static void get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate) {
}
-static void overlay_disable(struct graphics_priv *gr, int disable)
-{
+static void overlay_disable(struct graphics_priv *gr, int disable) {
}
-static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
-{
+static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound) {
}
static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
- NULL,
- draw_drag,
- font_new,
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- image_free,
- get_text_bbox,
- overlay_disable,
- overlay_resize,
- NULL, /* show_native_keyboard */
- NULL, /* hide_native_keyboard */
+ graphics_destroy,
+ draw_mode,
+ draw_lines,
+ draw_polygon,
+ draw_rectangle,
+ draw_circle,
+ draw_text,
+ draw_image,
+ NULL,
+ draw_drag,
+ font_new,
+ gc_new,
+ background_gc,
+ overlay_new,
+ image_new,
+ get_data,
+ image_free,
+ get_text_bbox,
+ overlay_disable,
+ overlay_resize,
+ NULL, /* show_native_keyboard */
+ NULL, /* hide_native_keyboard */
};
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
-{
- *meth=graphics_methods;
- return &graphics_priv;
+static struct graphics_priv *overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound) {
+ *meth=graphics_methods;
+ return &graphics_priv;
}
-static struct graphics_priv *
-graphics_null_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct attr *event_loop_system = NULL;
- *meth=graphics_methods;
+static struct graphics_priv *graphics_null_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct attr *event_loop_system = NULL;
+ *meth=graphics_methods;
- event_loop_system = attr_search(attrs, NULL, attr_event_loop_system);
+ event_loop_system = attr_search(attrs, NULL, attr_event_loop_system);
- if (event_loop_system && event_loop_system->u.str) {
- dbg(lvl_debug, "event_system is %s\n", event_loop_system->u.str);
- if (!event_request_system(event_loop_system->u.str, "graphics_null"))
- return NULL;
- } else {
- if (!event_request_system("null", "graphics_null"))
- return NULL;
- }
- callbacks = cbl;
- resize_callback(1,1);
- return &graphics_priv;
+ if (event_loop_system && event_loop_system->u.str) {
+ dbg(lvl_debug, "event_system is %s", event_loop_system->u.str);
+ if (!event_request_system(event_loop_system->u.str, "graphics_null"))
+ return NULL;
+ } else {
+ if (!event_request_system("null", "graphics_null"))
+ return NULL;
+ }
+ callbacks = cbl;
+ resize_callback(1,1);
+ return &graphics_priv;
}
-static void
-event_null_main_loop_run(void)
-{
+static void event_null_main_loop_run(void) {
- dbg(lvl_debug,"enter\n");
- for (;;)
- sleep(1);
+ dbg(lvl_debug,"enter");
+ for (;;)
+ sleep(1);
}
-static void event_null_main_loop_quit(void)
-{
- dbg(lvl_debug,"enter\n");
+static void event_null_main_loop_quit(void) {
+ dbg(lvl_debug,"enter");
}
-static struct event_watch *
-event_null_add_watch(int h, enum event_watch_cond cond, struct callback *cb)
-{
- dbg(lvl_debug,"enter\n");
- return NULL;
+static struct event_watch *event_null_add_watch(int h, enum event_watch_cond cond, struct callback *cb) {
+ dbg(lvl_debug,"enter");
+ return NULL;
}
-static void
-event_null_remove_watch(struct event_watch *ev)
-{
- dbg(lvl_debug,"enter\n");
+static void event_null_remove_watch(struct event_watch *ev) {
+ dbg(lvl_debug,"enter");
}
-static struct event_timeout *
-event_null_add_timeout(int timeout, int multi, struct callback *cb)
-{
- dbg(lvl_debug,"enter\n");
- return NULL;
+static struct event_timeout *event_null_add_timeout(int timeout, int multi, struct callback *cb) {
+ dbg(lvl_debug,"enter");
+ return NULL;
}
-static void
-event_null_remove_timeout(struct event_timeout *to)
-{
- dbg(lvl_debug,"enter\n");
+static void event_null_remove_timeout(struct event_timeout *to) {
+ dbg(lvl_debug,"enter");
}
-static struct event_idle *
-event_null_add_idle(int priority, struct callback *cb)
-{
- dbg(lvl_debug,"enter\n");
- return NULL;
+static struct event_idle *event_null_add_idle(int priority, struct callback *cb) {
+ dbg(lvl_debug,"enter");
+ return NULL;
}
-static void
-event_null_remove_idle(struct event_idle *ev)
-{
- dbg(lvl_debug,"enter\n");
+static void event_null_remove_idle(struct event_idle *ev) {
+ dbg(lvl_debug,"enter");
}
-static void
-event_null_call_callback(struct callback_list *cb)
-{
- dbg(lvl_debug,"enter\n");
+static void event_null_call_callback(struct callback_list *cb) {
+ dbg(lvl_debug,"enter");
}
static struct event_methods event_null_methods = {
- event_null_main_loop_run,
- event_null_main_loop_quit,
- event_null_add_watch,
- event_null_remove_watch,
- event_null_add_timeout,
- event_null_remove_timeout,
- event_null_add_idle,
- event_null_remove_idle,
- event_null_call_callback,
+ event_null_main_loop_run,
+ event_null_main_loop_quit,
+ event_null_add_watch,
+ event_null_remove_watch,
+ event_null_add_timeout,
+ event_null_remove_timeout,
+ event_null_add_idle,
+ event_null_remove_idle,
+ event_null_call_callback,
};
-static struct event_priv *
-event_null_new(struct event_methods *meth)
-{
- *meth=event_null_methods;
- return NULL;
+static struct event_priv *event_null_new(struct event_methods *meth) {
+ *meth=event_null_methods;
+ return NULL;
}
-void
-plugin_init(void)
-{
- plugin_register_category_graphics("null", graphics_null_new);
- plugin_register_category_event("null", event_null_new);
+void plugin_init(void) {
+ plugin_register_category_graphics("null", graphics_null_new);
+ plugin_register_category_event("null", event_null_new);
}
diff --git a/navit/graphics/opengl/CMakeLists.txt b/navit/graphics/opengl/CMakeLists.txt
index 6596344d1..382be14c7 100644
--- a/navit/graphics/opengl/CMakeLists.txt
+++ b/navit/graphics/opengl/CMakeLists.txt
@@ -1,6 +1,6 @@
set(graphics_opengl_SOURCES graphics_opengl.c)
if (USE_OPENGLES)
- LIST(APPEND graphics_opengl_SOURCES graphics_opengl_x11.c graphics_opengl_egl.c)
+ LIST(APPEND graphics_opengl_SOURCES graphics_opengl_x11.c graphics_opengl_egl.c)
endif (USE_OPENGLES)
-module_add_library(graphics_opengl ${graphics_opengl_SOURCES})
+module_add_library(graphics_opengl ${graphics_opengl_SOURCES})
diff --git a/navit/graphics/opengl/graphics_opengl.c b/navit/graphics/opengl/graphics_opengl.c
index 98230f0dc..2789061f1 100644
--- a/navit/graphics/opengl/graphics_opengl.c
+++ b/navit/graphics/opengl/graphics_opengl.c
@@ -50,7 +50,7 @@
#define PIXEL_FORMAT GL_BGRA
#endif
-#if HAVE_FREEIMAGE
+#ifdef HAVE_FREEIMAGE
#include <FreeImage.h>
#endif
@@ -114,73 +114,73 @@ typedef GLfixed GLf;
//#define MIRRORED_VIEW 1
struct graphics_gc_priv {
- struct graphics_priv *gr;
- float fr, fg, fb, fa;
- float br, bg, bb, ba;
- int linewidth;
- unsigned char *dash_list;
- int dash_count;
- int dash_mask;
+ struct graphics_priv *gr;
+ float fr, fg, fb, fa;
+ float br, bg, bb, ba;
+ int linewidth;
+ unsigned char *dash_list;
+ int dash_count;
+ int dash_mask;
} graphics_gc_priv;
struct graphics_priv {
- int button_timeout;
- struct point p;
- int width;
- int height;
- int library_init;
- int visible;
- int overlay_enabled;
- int overlay_autodisabled;
- int wraparound;
- struct graphics_priv *parent;
- struct graphics_priv *overlays;
- struct graphics_priv *next;
- struct graphics_gc_priv *background_gc;
- enum draw_mode_num mode;
- void (*resize_callback) (void *data, int w, int h);
- void *resize_callback_data;
- void (*motion_callback) (void *data, struct point * p);
- void *motion_callback_data;
- void (*button_callback) (void *data, int press, int button,
- struct point * p);
- void *button_callback_data;
+ int button_timeout;
+ struct point p;
+ int width;
+ int height;
+ int library_init;
+ int visible;
+ int overlay_enabled;
+ int overlay_autodisabled;
+ int wraparound;
+ struct graphics_priv *parent;
+ struct graphics_priv *overlays;
+ struct graphics_priv *next;
+ struct graphics_gc_priv *background_gc;
+ enum draw_mode_num mode;
+ void (*resize_callback) (void *data, int w, int h);
+ void *resize_callback_data;
+ void (*motion_callback) (void *data, struct point * p);
+ void *motion_callback_data;
+ void (*button_callback) (void *data, int press, int button, struct point * p);
+ void *button_callback_data;
#ifdef USE_OPENGLES
- GLuint program;
- GLint mvp_location, position_location, color_location, texture_position_location, use_texture_location, texture_location;
+ GLuint program;
+ GLint mvp_location, position_location, color_location, texture_position_location, use_texture_location,
+ texture_location;
#else
- GLuint DLid;
+ GLuint DLid;
#endif
- struct callback_list *cbl;
- struct font_freetype_methods freetype_methods;
- struct navit *nav;
- int timeout;
- int delay;
- struct window window;
- int dirty; //display needs to be redrawn (draw on root graphics or overlay is done)
- int force_redraw; //display needs to be redrawn (draw on root graphics or overlay is done)
- time_t last_refresh_time; //last display refresh time
- struct graphics_opengl_window_system *window_system;
- struct graphics_opengl_window_system_methods *window_system_methods;
- struct graphics_opengl_platform *platform;
- struct graphics_opengl_platform_methods *platform_methods;
+ struct callback_list *cbl;
+ struct font_freetype_methods freetype_methods;
+ struct navit *nav;
+ int timeout;
+ int delay;
+ struct window window;
+ int dirty; //display needs to be redrawn (draw on root graphics or overlay is done)
+ int force_redraw; //display needs to be redrawn (draw on root graphics or overlay is done)
+ time_t last_refresh_time; //last display refresh time
+ struct graphics_opengl_window_system *window_system;
+ struct graphics_opengl_window_system_methods *window_system_methods;
+ struct graphics_opengl_platform *platform;
+ struct graphics_opengl_platform_methods *platform_methods;
};
static struct graphics_priv *graphics_priv_root;
struct graphics_image_priv {
- int w;
- int h;
- int hot_x;
- int hot_y;
- unsigned char *data;
- char *path;
+ int w;
+ int h;
+ int hot_x;
+ int hot_y;
+ unsigned char *data;
+ char *path;
} graphics_image_priv;
struct mouse_event_queue_element {
- int button;
- int state;
- int x;
- int y;
+ int button;
+ int state;
+ int x;
+ int y;
};
static const int mouse_event_queue_size = 100;
@@ -204,8 +204,8 @@ const char *getPrimitiveType(GLenum type);
#endif
static struct graphics_priv *graphics_opengl_new_helper(struct
- graphics_methods
- *meth);
+ graphics_methods
+ *meth);
static void display(void);
static void resize_callback(int w, int h);
#ifdef USE_OPENGLES
@@ -217,7 +217,7 @@ static void glut_close(void);
#ifdef USE_OPENGLES2
const char vertex_src [] =
-" \
+ " \
attribute vec2 position; \
attribute vec2 texture_position; \
uniform mat4 mvp; \
@@ -231,7 +231,7 @@ const char vertex_src [] =
";
const char fragment_src [] =
-" \
+ " \
uniform lowp vec4 avcolor; \
uniform sampler2D texture; \
uniform bool use_texture; \
@@ -247,456 +247,407 @@ const char fragment_src [] =
";
#endif
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
- /*FIXME graphics_destroy is never called */
- /*TODO add destroy code for image cache(delete entries in hImageData) */
- gr->freetype_methods.destroy();
- g_free(gr);
- gr = NULL;
+static void graphics_destroy(struct graphics_priv *gr) {
+ /*FIXME graphics_destroy is never called */
+ /*TODO add destroy code for image cache(delete entries in hImageData) */
+ gr->freetype_methods.destroy();
+ g_free(gr);
+ gr = NULL;
}
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
- g_free(gc);
- gc = NULL;
+static void gc_destroy(struct graphics_gc_priv *gc) {
+ g_free(gc);
+ gc = NULL;
}
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
- gc->linewidth = w;
+static void gc_set_linewidth(struct graphics_gc_priv *gc, int w) {
+ gc->linewidth = w;
}
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset,
- unsigned char *dash_list, int n)
-{
- int i;
- const int cOpenglMaskBits = 16;
- gc->dash_count = n;
- if (1 == n) {
- gc->dash_mask = 0;
- for (i = 0; i < cOpenglMaskBits; ++i) {
- gc->dash_mask <<= 1;
- gc->dash_mask |= (i / n) % 2;
- }
- } else if (1 < n) {
- unsigned char *curr = dash_list;
- int cnt = 0; //dot counter
- int dcnt = 0; //dash element counter
- int sum_dash = 0;
- gc->dash_mask = 0;
-
- for (i = 0; i < n; ++i) {
- sum_dash += dash_list[i];
- }
-
- //scale dashlist elements to max size
- if (sum_dash > cOpenglMaskBits) {
- int num_error[2] = { 0, 0 }; //count elements rounded to 0 for odd(drawn) and even(masked) for compensation
- double factor = (1.0 * cOpenglMaskBits) / sum_dash;
- for (i = 0; i < n; ++i) { //calculate dashlist max and largest common denomiator for scaling
- dash_list[i] *= factor;
- if (dash_list[i] == 0) {
- ++dash_list[i];
- ++num_error[i % 2];
- } else if (0 < num_error[i % 2]
- && 2 < dash_list[i]) {
- ++dash_list[i];
- --num_error[i % 2];
- }
- }
- }
- //calculate mask
- for (i = 0; i < cOpenglMaskBits; ++i) {
- gc->dash_mask <<= 1;
- gc->dash_mask |= 1 - dcnt % 2;
- ++cnt;
- if (cnt == *curr) {
- cnt = 0;
- ++curr;
- ++dcnt;
- if (dcnt == n) {
- curr = dash_list;
- }
- }
- }
- }
+static void gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset, unsigned char *dash_list, int n) {
+ int i;
+ const int cOpenglMaskBits = 16;
+ gc->dash_count = n;
+ if (1 == n) {
+ gc->dash_mask = 0;
+ for (i = 0; i < cOpenglMaskBits; ++i) {
+ gc->dash_mask <<= 1;
+ gc->dash_mask |= (i / n) % 2;
+ }
+ } else if (1 < n) {
+ unsigned char *curr = dash_list;
+ int cnt = 0; //dot counter
+ int dcnt = 0; //dash element counter
+ int sum_dash = 0;
+ gc->dash_mask = 0;
+
+ for (i = 0; i < n; ++i) {
+ sum_dash += dash_list[i];
+ }
+
+ //scale dashlist elements to max size
+ if (sum_dash > cOpenglMaskBits) {
+ int num_error[2] = { 0, 0 }; //count elements rounded to 0 for odd(drawn) and even(masked) for compensation
+ double factor = (1.0 * cOpenglMaskBits) / sum_dash;
+ for (i = 0; i < n; ++i) { //calculate dashlist max and largest common denomiator for scaling
+ dash_list[i] *= factor;
+ if (dash_list[i] == 0) {
+ ++dash_list[i];
+ ++num_error[i % 2];
+ } else if (0 < num_error[i % 2]
+ && 2 < dash_list[i]) {
+ ++dash_list[i];
+ --num_error[i % 2];
+ }
+ }
+ }
+ //calculate mask
+ for (i = 0; i < cOpenglMaskBits; ++i) {
+ gc->dash_mask <<= 1;
+ gc->dash_mask |= 1 - dcnt % 2;
+ ++cnt;
+ if (cnt == *curr) {
+ cnt = 0;
+ ++curr;
+ ++dcnt;
+ if (dcnt == n) {
+ curr = dash_list;
+ }
+ }
+ }
+ }
}
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
- gc->fr = c->r / 65535.0;
- gc->fg = c->g / 65535.0;
- gc->fb = c->b / 65535.0;
- gc->fa = c->a / 65535.0;
+static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c) {
+ gc->fr = c->r / 65535.0;
+ gc->fg = c->g / 65535.0;
+ gc->fb = c->b / 65535.0;
+ gc->fa = c->a / 65535.0;
}
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
- gc->br = c->r / 65535.0;
- gc->bg = c->g / 65535.0;
- gc->bb = c->b / 65535.0;
- gc->ba = c->a / 65535.0;
+static void gc_set_background(struct graphics_gc_priv *gc, struct color *c) {
+ gc->br = c->r / 65535.0;
+ gc->bg = c->g / 65535.0;
+ gc->bb = c->b / 65535.0;
+ gc->ba = c->a / 65535.0;
}
static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
+ gc_destroy,
+ gc_set_linewidth,
+ gc_set_dashes,
+ gc_set_foreground,
+ gc_set_background
};
-static struct graphics_gc_priv *
-gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- struct graphics_gc_priv *gc = g_new0(struct graphics_gc_priv, 1);
+static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) {
+ struct graphics_gc_priv *gc = g_new0(struct graphics_gc_priv, 1);
- *meth = gc_methods;
- gc->gr = gr;
- gc->linewidth = 1;
- return gc;
+ *meth = gc_methods;
+ gc->gr = gr;
+ gc->linewidth = 1;
+ return gc;
}
static struct graphics_image_priv image_error;
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gr, struct graphics_image_methods *meth,
- char *path, int *w, int *h, struct point *hot, int rotation)
-{
-#if HAVE_FREEIMAGE
- FIBITMAP *image;
- RGBQUAD aPixel;
- unsigned char *data;
- int width, height, i, j;
- struct graphics_image_priv *gi;
- //check if image already exists in hashmap
- struct graphics_image_priv *curr_elem =
- g_hash_table_lookup(hImageData, path);
- if (curr_elem == &image_error) {
- //found but couldn't be loaded
- return NULL;
- } else if (curr_elem) {
- //found and OK -> use hastable entry
- *w = curr_elem->w;
- *h = curr_elem->h;
- hot->x = curr_elem->w / 2 - 1;
- hot->y = curr_elem->h / 2 - 1;
- return curr_elem;
- } else {
- if (strlen(path) < 4) {
- g_hash_table_insert(hImageData, g_strdup(path),
- &image_error);
- return NULL;
- }
- char *ext_str = path + strlen(path) - 3;
- if (strstr(ext_str, "png") || strstr(path, "PNG")) {
- if ((image =
- FreeImage_Load(FIF_PNG, path, 0)) == NULL) {
- g_hash_table_insert(hImageData,
- g_strdup(path),
- &image_error);
- return NULL;
- }
- } else if (strstr(ext_str, "xpm") || strstr(path, "XPM")) {
- if ((image =
- FreeImage_Load(FIF_XPM, path, 0)) == NULL) {
- g_hash_table_insert(hImageData,
- g_strdup(path),
- &image_error);
- return NULL;
- }
- } else if (strstr(ext_str, "svg") || strstr(path, "SVG")) {
- char path_new[256];
- snprintf(path_new, strlen(path) - 3, "%s", path);
- strcat(path_new, "_48_48.png");
-
- if ((image =
- FreeImage_Load(FIF_PNG, path_new,
- 0)) == NULL) {
- g_hash_table_insert(hImageData,
- g_strdup(path),
- &image_error);
- return NULL;
- }
- } else {
- g_hash_table_insert(hImageData, g_strdup(path),
- &image_error);
- return NULL;
- }
-
- if (FreeImage_GetBPP(image) == 64) {
- FIBITMAP *image2;
- image2 = FreeImage_ConvertTo32Bits(image);
- FreeImage_Unload(image);
- image = image2;
- }
+static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation) {
+#ifdef HAVE_FREEIMAGE
+ FIBITMAP *image;
+ RGBQUAD aPixel;
+ unsigned char *data;
+ int width, height, i, j;
+ struct graphics_image_priv *gi;
+ //check if image already exists in hashmap
+ struct graphics_image_priv *curr_elem =
+ g_hash_table_lookup(hImageData, path);
+ if (curr_elem == &image_error) {
+ //found but couldn't be loaded
+ return NULL;
+ } else if (curr_elem) {
+ //found and OK -> use hastable entry
+ *w = curr_elem->w;
+ *h = curr_elem->h;
+ hot->x = curr_elem->w / 2 - 1;
+ hot->y = curr_elem->h / 2 - 1;
+ return curr_elem;
+ } else {
+ if (strlen(path) < 4) {
+ g_hash_table_insert(hImageData, g_strdup(path), &image_error);
+ return NULL;
+ }
+ char *ext_str = path + strlen(path) - 3;
+ if (strstr(ext_str, "png") || strstr(path, "PNG")) {
+ if ((image =
+ FreeImage_Load(FIF_PNG, path, 0)) == NULL) {
+ g_hash_table_insert(hImageData, g_strdup(path), &image_error);
+ return NULL;
+ }
+ } else if (strstr(ext_str, "xpm") || strstr(path, "XPM")) {
+ if ((image =
+ FreeImage_Load(FIF_XPM, path, 0)) == NULL) {
+ g_hash_table_insert(hImageData, g_strdup(path), &image_error);
+ return NULL;
+ }
+ } else if (strstr(ext_str, "svg") || strstr(path, "SVG")) {
+ char path_new[256];
+ snprintf(path_new, strlen(path) - 3, "%s", path);
+ strcat(path_new, "_48_48.png");
+
+ if ((image = FreeImage_Load(FIF_PNG, path_new, 0)) == NULL) {
+ g_hash_table_insert(hImageData, g_strdup(path), &image_error);
+ return NULL;
+ }
+ } else {
+ g_hash_table_insert(hImageData, g_strdup(path), &image_error);
+ return NULL;
+ }
+
+ if (FreeImage_GetBPP(image) == 64) {
+ FIBITMAP *image2;
+ image2 = FreeImage_ConvertTo32Bits(image);
+ FreeImage_Unload(image);
+ image = image2;
+ }
#if FREEIMAGE_MAJOR_VERSION*100+FREEIMAGE_MINOR_VERSION >= 313
- if (rotation) {
- FIBITMAP *image2;
- image2 = FreeImage_Rotate(image, rotation, NULL);
- image = image2;
- }
+ if (rotation) {
+ FIBITMAP *image2;
+ image2 = FreeImage_Rotate(image, rotation, NULL);
+ image = image2;
+ }
#endif
- gi = g_new0(struct graphics_image_priv, 1);
-
- width = FreeImage_GetWidth(image);
- height = FreeImage_GetHeight(image);
-
- if ((*w != width || *h != height) && *w != IMAGE_W_H_UNSET && *h != IMAGE_W_H_UNSET) {
- FIBITMAP *image2;
- image2 = FreeImage_Rescale(image, *w, *h, FILTER_BOX);
- FreeImage_Unload(image);
- image = image2;
- width = *w;
- height = *h;
- }
-
- data = (unsigned char *) malloc(width * height * 4);
-
- RGBQUAD *palette = NULL;
- if (FreeImage_GetBPP(image) == 8) {
- palette = FreeImage_GetPalette(image);
- }
-
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- unsigned char idx;
- if (FreeImage_GetBPP(image) == 8) {
- FreeImage_GetPixelIndex(image, j,
- height -
- i - 1,
- &idx);
- data[4 * width * i + 4 * j + 0] =
- palette[idx].rgbRed;
- data[4 * width * i + 4 * j + 1] =
- palette[idx].rgbGreen;
- data[4 * width * i + 4 * j + 2] =
- palette[idx].rgbBlue;
- data[4 * width * i + 4 * j + 3] =
- 255;
- } else if (FreeImage_GetBPP(image) == 16
- || FreeImage_GetBPP(image) == 24
- || FreeImage_GetBPP(image) ==
- 32) {
- FreeImage_GetPixelColor(image, j,
- height -
- i - 1,
- &aPixel);
- int transparent =
- (aPixel.rgbRed == 0
- && aPixel.rgbBlue == 0
- && aPixel.rgbGreen == 0);
- data[4 * width * i + 4 * j + 0] =
- transparent ? 0 : (aPixel.
- rgbRed);
- data[4 * width * i + 4 * j + 1] =
- (aPixel.rgbGreen);
- data[4 * width * i + 4 * j + 2] =
- transparent ? 0 : (aPixel.
- rgbBlue);
- data[4 * width * i + 4 * j + 3] =
- transparent ? 0 : 255;
-
- }
- }
- }
-
- FreeImage_Unload(image);
-
- *w = width;
- *h = height;
- gi->w = width;
- gi->h = height;
- gi->hot_x = width / 2 - 1;
- gi->hot_y = height / 2 - 1;
- hot->x = width / 2 - 1;
- hot->y = height / 2 - 1;
- gi->data = data;
- gi->path = path;
- //add to hashtable
- g_hash_table_insert(hImageData, g_strdup(path), gi);
- return gi;
- }
+ gi = g_new0(struct graphics_image_priv, 1);
+
+ width = FreeImage_GetWidth(image);
+ height = FreeImage_GetHeight(image);
+
+ if ((*w != width || *h != height) && *w != IMAGE_W_H_UNSET && *h != IMAGE_W_H_UNSET) {
+ FIBITMAP *image2;
+ image2 = FreeImage_Rescale(image, *w, *h, FILTER_BOX);
+ FreeImage_Unload(image);
+ image = image2;
+ width = *w;
+ height = *h;
+ }
+
+ data = (unsigned char *) malloc(width * height * 4);
+
+ RGBQUAD *palette = NULL;
+ if (FreeImage_GetBPP(image) == 8) {
+ palette = FreeImage_GetPalette(image);
+ }
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ unsigned char idx;
+ if (FreeImage_GetBPP(image) == 8) {
+ FreeImage_GetPixelIndex(image, j, height - i - 1, &idx);
+ data[4 * width * i + 4 * j + 0] =
+ palette[idx].rgbRed;
+ data[4 * width * i + 4 * j + 1] =
+ palette[idx].rgbGreen;
+ data[4 * width * i + 4 * j + 2] =
+ palette[idx].rgbBlue;
+ data[4 * width * i + 4 * j + 3] =
+ 255;
+ } else if (FreeImage_GetBPP(image) == 16
+ || FreeImage_GetBPP(image) == 24
+ || FreeImage_GetBPP(image) == 32) {
+ FreeImage_GetPixelColor(image, j, height - i - 1, &aPixel);
+ int transparent =
+ (aPixel.rgbRed == 0
+ && aPixel.rgbBlue == 0
+ && aPixel.rgbGreen == 0);
+ data[4 * width * i + 4 * j + 0] =
+ transparent ? 0 : (aPixel.
+ rgbRed);
+ data[4 * width * i + 4 * j + 1] =
+ (aPixel.rgbGreen);
+ data[4 * width * i + 4 * j + 2] =
+ transparent ? 0 : (aPixel.
+ rgbBlue);
+ data[4 * width * i + 4 * j + 3] =
+ transparent ? 0 : 255;
+
+ }
+ }
+ }
+
+ FreeImage_Unload(image);
+
+ *w = width;
+ *h = height;
+ gi->w = width;
+ gi->h = height;
+ gi->hot_x = width / 2 - 1;
+ gi->hot_y = height / 2 - 1;
+ hot->x = width / 2 - 1;
+ hot->y = height / 2 - 1;
+ gi->data = data;
+ gi->path = path;
+ //add to hashtable
+ g_hash_table_insert(hImageData, g_strdup(path), gi);
+ return gi;
+ }
#else
- dbg(lvl_error,"FreeImage not available - cannot load any images.\n", path);
- return NULL;
+ dbg(lvl_error,"FreeImage not available - cannot load any images.");
+ return NULL;
#endif
}
-static void
-set_color(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
+static void set_color(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
#ifdef USE_OPENGLES2
- GLfloat col[4];
- col[0]=gc->fr;
- col[1]=gc->fg;
- col[2]=gc->fb;
- col[3]=1.0;
- glUniform4fv(gr->color_location, 1, col);
+ GLfloat col[4];
+ col[0]=gc->fr;
+ col[1]=gc->fg;
+ col[2]=gc->fb;
+ col[3]=1.0;
+ glUniform4fv(gr->color_location, 1, col);
#else
- glColor4f(glF(gc->fr), glF(gc->fg), glF(gc->fb), glF(gc->fa));
+ glColor4f(glF(gc->fr), glF(gc->fg), glF(gc->fb), glF(gc->fa));
#endif
}
-static void
-draw_array(struct graphics_priv *gr, struct point *p, int count, GLenum mode)
-{
- int i;
+static void draw_array(struct graphics_priv *gr, struct point *p, int count, GLenum mode) {
+ int i;
#ifdef USE_OPENGLES
- GLf x[count*2];
+ GLf x[count*2];
#else
- glBegin(mode);
+ glBegin(mode);
#endif
- for (i = 0 ; i < count ; i++) {
+ for (i = 0 ; i < count ; i++) {
#ifdef USE_OPENGLES
- x[i*2]=glF(p[i].x);
- x[i*2+1]=glF(p[i].y);
+ x[i*2]=glF(p[i].x);
+ x[i*2+1]=glF(p[i].y);
#else
- glVertex2f(p[i].x, p[i].y);
+ glVertex2f(p[i].x, p[i].y);
#endif
- }
+ }
#ifdef USE_OPENGLES
#ifdef USE_OPENGLES2
- glVertexAttribPointer (gr->position_location, 2, GL_FLOAT, 0, 0, x );
+ glVertexAttribPointer (gr->position_location, 2, GL_FLOAT, 0, 0, x );
#else
- glVertexPointer(2, GL_F, 0, x);
+ glVertexPointer(2, GL_F, 0, x);
#endif
- glDrawArrays(mode, 0, count);
+ glDrawArrays(mode, 0, count);
#else
- glEnd();
+ glEnd();
#endif
}
-static void
-draw_rectangle_do(struct graphics_priv *gr, struct point *p, int w, int h)
-{
- struct point pa[4];
- pa[0]=pa[1]=pa[2]=pa[3]=*p;
- pa[0].x+=w;
- pa[1].x+=w;
- pa[1].y+=h;
- pa[3].y+=h;
- draw_array(gr, pa, 4, GL_TRIANGLE_STRIP);
+static void draw_rectangle_do(struct graphics_priv *gr, struct point *p, int w, int h) {
+ struct point pa[4];
+ pa[0]=pa[1]=pa[2]=pa[3]=*p;
+ pa[0].x+=w;
+ pa[1].x+=w;
+ pa[1].y+=h;
+ pa[3].y+=h;
+ draw_array(gr, pa, 4, GL_TRIANGLE_STRIP);
}
#ifdef USE_OPENGLES
-static int next_power2(int x)
-{
- int r=1;
- while (r < x)
- r*=2;
- return r;
+static int next_power2(int x) {
+ int r=1;
+ while (r < x)
+ r*=2;
+ return r;
}
-static void
-draw_image_es(struct graphics_priv *gr, struct point *p, int w, int h, unsigned char *data)
-{
- GLf x[8];
+static void draw_image_es(struct graphics_priv *gr, struct point *p, int w, int h, unsigned char *data) {
+ GLf x[8];
- memset(x, 0, sizeof(x));
+ memset(x, 0, sizeof(x));
#if REQUIRES_POWER_OF_2
- int w2=next_power2(w);
- int h2=next_power2(h);
- int y;
- if (w2 != w || h2 != h) {
- char *newpix=g_malloc0(w2*h2*4);
- for (y=0 ; y < h ; y++)
- memcpy(newpix+y*w2*4, data+y*w*4, w*4);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w2, h2, 0, GL_RGBA, GL_UNSIGNED_BYTE, newpix);
- g_free(newpix);
- w=w2;
- h=h2;
- } else
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ int w2=next_power2(w);
+ int h2=next_power2(h);
+ int y;
+ if (w2 != w || h2 != h) {
+ char *newpix=g_malloc0(w2*h2*4);
+ for (y=0 ; y < h ; y++)
+ memcpy(newpix+y*w2*4, data+y*w*4, w*4);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w2, h2, 0, GL_RGBA, GL_UNSIGNED_BYTE, newpix);
+ g_free(newpix);
+ w=w2;
+ h=h2;
+ } else
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
#else
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
#endif
- x[0]+=glF(1);
- x[2]+=glF(1);
- x[3]+=glF(1);
- x[7]+=glF(1);
+ x[0]+=glF(1);
+ x[2]+=glF(1);
+ x[3]+=glF(1);
+ x[7]+=glF(1);
#ifdef USE_OPENGLES2
- glUniform1i(gr->use_texture_location, 1);
- glEnableVertexAttribArray(gr->texture_position_location);
- glVertexAttribPointer (gr->texture_position_location, 2, GL_FLOAT, 0, 0, x );
+ glUniform1i(gr->use_texture_location, 1);
+ glEnableVertexAttribArray(gr->texture_position_location);
+ glVertexAttribPointer (gr->texture_position_location, 2, GL_FLOAT, 0, 0, x );
#else
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glEnable(GL_TEXTURE_2D);
- glTexCoordPointer(2, GL_F, 0, x);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnable(GL_TEXTURE_2D);
+ glTexCoordPointer(2, GL_F, 0, x);
#endif
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- draw_rectangle_do(gr, p, w, h);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ draw_rectangle_do(gr, p, w, h);
#ifdef USE_OPENGLES2
- glUniform1i(gr->use_texture_location, 0);
- glDisableVertexAttribArray(gr->texture_position_location);
+ glUniform1i(gr->use_texture_location, 0);
+ glDisableVertexAttribArray(gr->texture_position_location);
#else
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisable(GL_TEXTURE_2D);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisable(GL_TEXTURE_2D);
#endif
- glDisable(GL_BLEND);
+ glDisable(GL_BLEND);
}
#endif
-static void
-get_overlay_pos(struct graphics_priv *gr, struct point *point_out)
-{
- if (gr->parent == NULL) {
- point_out->x = 0;
- point_out->y = 0;
- return;
- }
- point_out->x = gr->p.x;
- if (point_out->x < 0) {
- point_out->x += gr->parent->width;
- }
-
- point_out->y = gr->p.y;
- if (point_out->y < 0) {
- point_out->y += gr->parent->height;
- }
+static void get_overlay_pos(struct graphics_priv *gr, struct point *point_out) {
+ if (gr->parent == NULL) {
+ point_out->x = 0;
+ point_out->y = 0;
+ return;
+ }
+ point_out->x = gr->p.x;
+ if (point_out->x < 0) {
+ point_out->x += gr->parent->width;
+ }
+
+ point_out->y = gr->p.y;
+ if (point_out->y < 0) {
+ point_out->y += gr->parent->height;
+ }
}
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc,
- struct point *p, int count)
-{
- if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
- return;
- }
+static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ if ((gr->parent && !gr->parent->overlay_enabled)
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
+ return;
+ }
#if !defined(USE_OPENGLES) || defined(USE_OPENGLES2)
- glLineWidth(gc->linewidth);
+ glLineWidth(gc->linewidth);
#endif
- set_color(gr, gc);
- graphics_priv_root->dirty = 1;
+ set_color(gr, gc);
+ graphics_priv_root->dirty = 1;
#ifndef USE_OPENGLES
- if (!gr->parent && 0 < gc->dash_count) {
- glLineStipple(1, gc->dash_mask);
- glEnable(GL_LINE_STIPPLE);
- }
+ if (!gr->parent && 0 < gc->dash_count) {
+ glLineStipple(1, gc->dash_mask);
+ glEnable(GL_LINE_STIPPLE);
+ }
#endif
- draw_array(gr, p, count, GL_LINE_STRIP);
+ draw_array(gr, p, count, GL_LINE_STRIP);
#ifndef USE_OPENGLES
- if (!gr->parent && 0 < gc->dash_count) {
- glDisable(GL_LINE_STIPPLE);
- }
+ if (!gr->parent && 0 < gc->dash_count) {
+ glDisable(GL_LINE_STIPPLE);
+ }
#endif
}
@@ -705,1118 +656,972 @@ static int tess_count;
static struct point tess_array[512];
static GLenum tess_type;
-const char *
-getPrimitiveType(GLenum type)
-{
- char *ret = "";
-
- switch (type) {
- case 0x0000:
- ret = "GL_POINTS";
- break;
- case 0x0001:
- ret = "GL_LINES";
- break;
- case 0x0002:
- ret = "GL_LINE_LOOP";
- break;
- case 0x0003:
- ret = "GL_LINE_STRIP";
- break;
- case 0x0004:
- ret = "GL_TRIANGLES";
- break;
- case 0x0005:
- ret = "GL_TRIANGLE_STRIP";
- break;
- case 0x0006:
- ret = "GL_TRIANGLE_FAN";
- break;
- case 0x0007:
- ret = "GL_QUADS";
- break;
- case 0x0008:
- ret = "GL_QUAD_STRIP";
- break;
- case 0x0009:
- ret = "GL_POLYGON";
- break;
- }
- return ret;
+const char *getPrimitiveType(GLenum type) {
+ char *ret = "";
+
+ switch (type) {
+ case 0x0000:
+ ret = "GL_POINTS";
+ break;
+ case 0x0001:
+ ret = "GL_LINES";
+ break;
+ case 0x0002:
+ ret = "GL_LINE_LOOP";
+ break;
+ case 0x0003:
+ ret = "GL_LINE_STRIP";
+ break;
+ case 0x0004:
+ ret = "GL_TRIANGLES";
+ break;
+ case 0x0005:
+ ret = "GL_TRIANGLE_STRIP";
+ break;
+ case 0x0006:
+ ret = "GL_TRIANGLE_FAN";
+ break;
+ case 0x0007:
+ ret = "GL_QUADS";
+ break;
+ case 0x0008:
+ ret = "GL_QUAD_STRIP";
+ break;
+ case 0x0009:
+ ret = "GL_POLYGON";
+ break;
+ }
+ return ret;
}
-void APIENTRY
-tessBeginCB(GLenum which)
-{
- dbg(lvl_debug, "glBegin( %s );\n", getPrimitiveType(which));
- tess_type=which;
- tess_count=0;
+void APIENTRY tessBeginCB(GLenum which) {
+ dbg(lvl_debug, "glBegin( %s );", getPrimitiveType(which));
+ tess_type=which;
+ tess_count=0;
}
-void APIENTRY
-tessEndCB(void)
-{
- dbg(lvl_debug, "glEnd();\n");
- draw_array(graphics_priv_root, tess_array, tess_count, tess_type);
+void APIENTRY tessEndCB(void) {
+ dbg(lvl_debug, "glEnd();");
+ draw_array(graphics_priv_root, tess_array, tess_count, tess_type);
}
-void APIENTRY
-tessVertexCB(const GLvoid * data)
-{
- // cast back to double type
- const GLdouble *ptr = (const GLdouble *) data;
- dbg(lvl_debug, " glVertex3d();\n");
+void APIENTRY tessVertexCB(const GLvoid * data) {
+ // cast back to double type
+ const GLdouble *ptr = (const GLdouble *) data;
+ dbg(lvl_debug, " glVertex3d();");
- tess_array[tess_count].x=ptr[0];
- tess_array[tess_count].y=ptr[1];
- if (tess_count < 511)
- tess_count++;
- else
- dbg(lvl_error,"overflow\n");
+ tess_array[tess_count].x=ptr[0];
+ tess_array[tess_count].y=ptr[1];
+ if (tess_count < 511)
+ tess_count++;
+ else
+ dbg(lvl_error,"overflow");
}
-void APIENTRY
-tessCombineCB(GLdouble c[3], void *d[4], GLfloat w[4], void **out)
-{
- GLdouble *nv = (GLdouble *) malloc(sizeof(GLdouble) * 3);
- nv[0] = c[0];
- nv[1] = c[1];
- nv[2] = c[2];
- *out = nv;
+void APIENTRY tessCombineCB(GLdouble c[3], void *d[4], GLfloat w[4], void **out) {
+ GLdouble *nv = (GLdouble *) malloc(sizeof(GLdouble) * 3);
+ nv[0] = c[0];
+ nv[1] = c[1];
+ nv[2] = c[2];
+ *out = nv;
}
#endif
-static void
-draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc,
- struct point *p, int count)
-{
- if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
- return;
- }
- set_color(gr, gc);
- graphics_priv_root->dirty = 1;
+static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ if ((gr->parent && !gr->parent->overlay_enabled)
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
+ return;
+ }
+ set_color(gr, gc);
+ graphics_priv_root->dirty = 1;
#if defined(USE_OPENGLES) && !defined(USE_GLUT_FOR_OPENGLES)
- draw_array(gr, p, count, GL_LINE_STRIP);
+ draw_array(gr, p, count, GL_LINE_STRIP);
#else
- GLUtesselator *tess = gluNewTess(); // create a tessellator
- if (!tess)
- return; // failed to create tessellation object, return 0
-
- GLdouble quad1[count][3];
- int i;
- for (i = 0; i < count; i++) {
- quad1[i][0] = (GLdouble) (p[i].x);
- quad1[i][1] = (GLdouble) (p[i].y);
- quad1[i][2] = 0;
- }
-
-
- // register callback functions
- gluTessCallback(tess, GLU_TESS_BEGIN, (void (APIENTRY *)(void)) tessBeginCB);
- gluTessCallback(tess, GLU_TESS_END, (void (APIENTRY *)(void)) tessEndCB);
- // gluTessCallback(tess, GLU_TESS_ERROR, (void (*)(void))tessErrorCB);
- gluTessCallback(tess, GLU_TESS_VERTEX, (void (APIENTRY *)(void)) tessVertexCB);
- gluTessCallback(tess, GLU_TESS_COMBINE, (void (APIENTRY *)(void)) tessCombineCB);
-
- // tessellate and compile a concave quad into display list
- // gluTessVertex() takes 3 params: tess object, pointer to vertex coords,
- // and pointer to vertex data to be passed to vertex callback.
- // The second param is used only to perform tessellation, and the third
- // param is the actual vertex data to draw. It is usually same as the second
- // param, but It can be more than vertex coord, for example, color, normal
- // and UV coords which are needed for actual drawing.
- // Here, we are looking at only vertex coods, so the 2nd and 3rd params are
- // pointing same address.
- gluTessBeginPolygon(tess, 0); // with NULL data
- gluTessBeginContour(tess);
- for (i = 0; i < count; i++) {
- gluTessVertex(tess, quad1[i], quad1[i]);
- }
- gluTessEndContour(tess);
- gluTessEndPolygon(tess);
-
- gluDeleteTess(tess); // delete after tessellation
+ GLUtesselator *tess = gluNewTess(); // create a tessellator
+ if (!tess)
+ return; // failed to create tessellation object, return 0
+
+ GLdouble quad1[count][3];
+ int i;
+ for (i = 0; i < count; i++) {
+ quad1[i][0] = (GLdouble) (p[i].x);
+ quad1[i][1] = (GLdouble) (p[i].y);
+ quad1[i][2] = 0;
+ }
+
+
+ // register callback functions
+ gluTessCallback(tess, GLU_TESS_BEGIN, (void (APIENTRY *)(void)) tessBeginCB);
+ gluTessCallback(tess, GLU_TESS_END, (void (APIENTRY *)(void)) tessEndCB);
+ // gluTessCallback(tess, GLU_TESS_ERROR, (void (*)(void))tessErrorCB);
+ gluTessCallback(tess, GLU_TESS_VERTEX, (void (APIENTRY *)(void)) tessVertexCB);
+ gluTessCallback(tess, GLU_TESS_COMBINE, (void (APIENTRY *)(void)) tessCombineCB);
+
+ // tessellate and compile a concave quad into display list
+ // gluTessVertex() takes 3 params: tess object, pointer to vertex coords,
+ // and pointer to vertex data to be passed to vertex callback.
+ // The second param is used only to perform tessellation, and the third
+ // param is the actual vertex data to draw. It is usually same as the second
+ // param, but It can be more than vertex coord, for example, color, normal
+ // and UV coords which are needed for actual drawing.
+ // Here, we are looking at only vertex coods, so the 2nd and 3rd params are
+ // pointing same address.
+ gluTessBeginPolygon(tess, 0); // with NULL data
+ gluTessBeginContour(tess);
+ for (i = 0; i < count; i++) {
+ gluTessVertex(tess, quad1[i], quad1[i]);
+ }
+ gluTessEndContour(tess);
+ gluTessEndPolygon(tess);
+
+ gluDeleteTess(tess); // delete after tessellation
#endif
}
-static void
-draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc,
- struct point *p, int w, int h)
-{
- if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
- return;
- }
- set_color(gr, gc);
- draw_rectangle_do(gr, p, w, h);
- graphics_priv_root->dirty = 1;
+static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
+ if ((gr->parent && !gr->parent->overlay_enabled)
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
+ return;
+ }
+ set_color(gr, gc);
+ draw_rectangle_do(gr, p, w, h);
+ graphics_priv_root->dirty = 1;
}
-static void
-display_text_draw(struct font_freetype_text *text,
- struct graphics_priv *gr, struct graphics_gc_priv *fg,
- struct graphics_gc_priv *bg, int color, struct point *p)
-{
- int i, x, y, stride;
- struct font_freetype_glyph *g, **gp;
- unsigned char *shadow, *glyph;
- struct color transparent = { 0x0000, 0x0000, 0x0000, 0x0000 };
- struct color black =
- { fg->fr * 65535, fg->fg * 65535, fg->fb * 65535,
- fg->fa * 65535 };
- struct color white = { 0xffff, 0xffff, 0xffff, 0xffff };
-
- if (bg) {
- if (COLOR_IS_WHITE(black) && COLOR_IS_BLACK(white)) {
- black.r = 65535;
- black.g = 65535;
- black.b = 65535;
- black.a = 65535;
-
- white.r = 0;
- white.g = 0;
- white.b = 0;
- white.a = 65535;
- } else if (COLOR_IS_BLACK(black) && COLOR_IS_WHITE(white)) {
- white.r = 65535;
- white.g = 65535;
- white.b = 65535;
- white.a = 65535;
-
- black.r = 0;
- black.g = 0;
- black.b = 0;
- black.a = 65535;
- } else {
- white.r = bg->fr;
- white.g = bg->fg;
- white.b = bg->fb;
- white.a = bg->fa;
- }
- } else {
- white.r = 0;
- white.g = 0;
- white.b = 0;
- white.a = 0;
- }
-
- gp = text->glyph;
- i = text->glyph_count;
- x = p->x << 6;
- y = p->y << 6;
- while (i-- > 0) {
- g = *gp++;
- if (g->w && g->h && bg) {
- stride = (g->w + 2) * 4;
- if (color) {
- shadow = g_malloc(stride * (g->h + 2));
- gr->freetype_methods.get_shadow(g, shadow,
- stride,
- &white,
- &transparent);
+static void display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, int color, struct point *p) {
+ int i, x, y, stride;
+ struct font_freetype_glyph *g, **gp;
+ unsigned char *shadow, *glyph;
+ struct color transparent = { 0x0000, 0x0000, 0x0000, 0x0000 };
+ struct color black = {
+ fg->fr * 65535, fg->fg * 65535, fg->fb * 65535, fg->fa * 65535
+ };
+ struct color white = { 0xffff, 0xffff, 0xffff, 0xffff };
+
+ if (bg) {
+ if (COLOR_IS_WHITE(black) && COLOR_IS_BLACK(white)) {
+ black.r = 65535;
+ black.g = 65535;
+ black.b = 65535;
+ black.a = 65535;
+
+ white.r = 0;
+ white.g = 0;
+ white.b = 0;
+ white.a = 65535;
+ } else if (COLOR_IS_BLACK(black) && COLOR_IS_WHITE(white)) {
+ white.r = 65535;
+ white.g = 65535;
+ white.b = 65535;
+ white.a = 65535;
+
+ black.r = 0;
+ black.g = 0;
+ black.b = 0;
+ black.a = 65535;
+ } else {
+ white.r = bg->fr;
+ white.g = bg->fg;
+ white.b = bg->fb;
+ white.a = bg->fa;
+ }
+ } else {
+ white.r = 0;
+ white.g = 0;
+ white.b = 0;
+ white.a = 0;
+ }
+
+ gp = text->glyph;
+ i = text->glyph_count;
+ x = p->x << 6;
+ y = p->y << 6;
+ while (i-- > 0) {
+ g = *gp++;
+ if (g->w && g->h && bg) {
+ stride = (g->w + 2) * 4;
+ if (color) {
+ shadow = g_malloc(stride * (g->h + 2));
+ gr->freetype_methods.get_shadow(g, shadow, stride, &white, &transparent);
#ifdef USE_OPENGLES
- struct point p;
- p.x=((x + g->x) >> 6)-1;
- p.y=((y + g->y) >> 6)-1;
- draw_image_es(gr, &p, g->w+2, g->h+2, shadow);
+ struct point p;
+ p.x=((x + g->x) >> 6)-1;
+ p.y=((y + g->y) >> 6)-1;
+ draw_image_es(gr, &p, g->w+2, g->h+2, shadow);
#else
#ifdef MIRRORED_VIEW
- glPixelZoom(-1.0, -1.0); //mirrored mode
+ glPixelZoom(-1.0, -1.0); //mirrored mode
#else
- glPixelZoom(1.0, -1.0);
+ glPixelZoom(1.0, -1.0);
#endif
- glRasterPos2d((x + g->x) >> 6,
- (y + g->y) >> 6);
- glDrawPixels(g->w + 2, g->h + 2, PIXEL_FORMAT,
- GL_UNSIGNED_BYTE, shadow);
+ glRasterPos2d((x + g->x) >> 6, (y + g->y) >> 6);
+ glDrawPixels(g->w + 2, g->h + 2, PIXEL_FORMAT, GL_UNSIGNED_BYTE, shadow);
#endif
- g_free(shadow);
- }
- }
- x += g->dx;
- y += g->dy;
- }
-
- x = p->x << 6;
- y = p->y << 6;
- gp = text->glyph;
- i = text->glyph_count;
- while (i-- > 0) {
- g = *gp++;
- if (g->w && g->h) {
- if (color) {
- stride = g->w;
- if (bg) {
- glyph =
- g_malloc(stride * g->h * 4);
- gr->freetype_methods.get_glyph(g,
- glyph,
- stride
- * 4,
- &black,
- &white,
- &transparent);
+ g_free(shadow);
+ }
+ }
+ x += g->dx;
+ y += g->dy;
+ }
+
+ x = p->x << 6;
+ y = p->y << 6;
+ gp = text->glyph;
+ i = text->glyph_count;
+ while (i-- > 0) {
+ g = *gp++;
+ if (g->w && g->h) {
+ if (color) {
+ stride = g->w;
+ if (bg) {
+ glyph =
+ g_malloc(stride * g->h * 4);
+ gr->freetype_methods.get_glyph(g, glyph, stride * 4, &black, &white, &transparent);
#ifdef USE_OPENGLES
- struct point p;
- p.x=(x + g->x) >> 6;
- p.y=(y + g->y) >> 6;
- draw_image_es(gr, &p, g->w, g->h, glyph);
+ struct point p;
+ p.x=(x + g->x) >> 6;
+ p.y=(y + g->y) >> 6;
+ draw_image_es(gr, &p, g->w, g->h, glyph);
#else
#ifdef MIRRORED_VIEW
- glPixelZoom(-1.0, -1.0); //mirrored mode
+ glPixelZoom(-1.0, -1.0); //mirrored mode
#else
- glPixelZoom(1.0, -1.0);
+ glPixelZoom(1.0, -1.0);
#endif
- glRasterPos2d((x + g->x) >> 6,
- (y + g->y) >> 6);
- glDrawPixels(g->w, g->h, PIXEL_FORMAT,
- GL_UNSIGNED_BYTE,
- glyph);
+ glRasterPos2d((x + g->x) >> 6, (y + g->y) >> 6);
+ glDrawPixels(g->w, g->h, PIXEL_FORMAT, GL_UNSIGNED_BYTE, glyph);
#endif
- g_free(glyph);
- }
- stride *= 4;
- glyph = g_malloc(stride * g->h);
- gr->freetype_methods.get_glyph(g, glyph,
- stride,
- &black,
- &white,
- &transparent);
+ g_free(glyph);
+ }
+ stride *= 4;
+ glyph = g_malloc(stride * g->h);
+ gr->freetype_methods.get_glyph(g, glyph, stride, &black, &white, &transparent);
#ifdef USE_OPENGLES
- struct point p;
- p.x=(x + g->x) >> 6;
- p.y=(y + g->y) >> 6;
- draw_image_es(gr, &p, g->w, g->h, glyph);
+ struct point p;
+ p.x=(x + g->x) >> 6;
+ p.y=(y + g->y) >> 6;
+ draw_image_es(gr, &p, g->w, g->h, glyph);
#else
#ifdef MIRRORED_VIEW
- glPixelZoom(-1.0, -1.0); //mirrored mode
+ glPixelZoom(-1.0, -1.0); //mirrored mode
#else
- glPixelZoom(1.0, -1.0);
+ glPixelZoom(1.0, -1.0);
#endif
- glRasterPos2d((x + g->x) >> 6,
- (y + g->y) >> 6);
- glDrawPixels(g->w, g->h, PIXEL_FORMAT,
- GL_UNSIGNED_BYTE, glyph);
+ glRasterPos2d((x + g->x) >> 6, (y + g->y) >> 6);
+ glDrawPixels(g->w, g->h, PIXEL_FORMAT, GL_UNSIGNED_BYTE, glyph);
#endif
- g_free(glyph);
- }
- }
- x += g->dx;
- y += g->dy;
- }
+ g_free(glyph);
+ }
+ }
+ x += g->dx;
+ y += g->dy;
+ }
}
-static void
-draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg,
- struct graphics_gc_priv *bg, struct graphics_font_priv *font,
- char *text, struct point *p, int dx, int dy)
-{
- if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
- return;
- }
-
- struct font_freetype_text *t;
- int color = 1;
-
- if (!font) {
- dbg(lvl_error, "no font, returning\n");
- return;
- }
-
- graphics_priv_root->dirty = 1;
-
- t = gr->freetype_methods.text_new(text,
- (struct font_freetype_font *)
- font, dx, dy);
-
- struct point p_eff;
- p_eff.x = p->x;
- p_eff.y = p->y;
-
- display_text_draw(t, gr, fg, bg, color, &p_eff);
- gr->freetype_methods.text_destroy(t);
+static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
+ if ((gr->parent && !gr->parent->overlay_enabled)
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
+ return;
+ }
+
+ struct font_freetype_text *t;
+ int color = 1;
+
+ if (!font) {
+ dbg(lvl_error, "no font, returning");
+ return;
+ }
+
+ graphics_priv_root->dirty = 1;
+
+ t = gr->freetype_methods.text_new(text, (struct font_freetype_font *) font, dx, dy);
+
+ struct point p_eff;
+ p_eff.x = p->x;
+ p_eff.y = p->y;
+
+ display_text_draw(t, gr, fg, bg, color, &p_eff);
+ gr->freetype_methods.text_destroy(t);
}
-static void
-draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg,
- struct point *p, struct graphics_image_priv *img)
-{
+static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img) {
#ifdef USE_OPENGLES
- draw_image_es(gr, p, img->w, img->h, img->data);
+ draw_image_es(gr, p, img->w, img->h, img->data);
#else
- if ((gr->parent && !gr->parent->overlay_enabled)
- || (gr->parent && gr->parent->overlay_enabled
- && !gr->overlay_enabled)) {
- return;
- }
+ if ((gr->parent && !gr->parent->overlay_enabled)
+ || (gr->parent && gr->parent->overlay_enabled
+ && !gr->overlay_enabled)) {
+ return;
+ }
- if (!img || !img->data) {
- return;
- }
+ if (!img || !img->data) {
+ return;
+ }
- graphics_priv_root->dirty = 1;
+ graphics_priv_root->dirty = 1;
- struct point p_eff;
- p_eff.x = p->x + img->hot_x;
- p_eff.y = p->y + img->hot_y;
+ struct point p_eff;
+ p_eff.x = p->x + img->hot_x;
+ p_eff.y = p->y + img->hot_y;
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glRasterPos2d(p_eff.x - img->hot_x, p_eff.y - img->hot_y);
- glDrawPixels(img->w, img->h, GL_RGBA, GL_UNSIGNED_BYTE, img->data);
+ glRasterPos2d(p_eff.x - img->hot_x, p_eff.y - img->hot_y);
+ glDrawPixels(img->w, img->h, GL_RGBA, GL_UNSIGNED_BYTE, img->data);
#endif
}
-static void
-draw_drag(struct graphics_priv *gr, struct point *p)
-{
+static void draw_drag(struct graphics_priv *gr, struct point *p) {
- if (p) {
- gr->p.x = p->x;
- gr->p.y = p->y;
- }
+ if (p) {
+ gr->p.x = p->x;
+ gr->p.y = p->y;
+ }
}
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
- gr->background_gc = gc;
+static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
+ gr->background_gc = gc;
}
-static void
-handle_mouse_queue(void)
-{
+static void handle_mouse_queue(void) {
#ifdef USE_OPENGLES
#else
- static int locked = 0;
- if (!locked) {
- locked = 1;
- } else {
- return;
- }
-
- if (mouse_event_queue_begin_idx < mouse_event_queue_end_idx) {
- if (mouse_queue[mouse_event_queue_begin_idx].button ==
- GLUT_LEFT_BUTTON
- && mouse_queue[mouse_event_queue_begin_idx].state ==
- GLUT_UP) {
- struct point p;
- p.x =
- mouse_queue[mouse_event_queue_begin_idx %
- mouse_event_queue_size].x;
- p.y =
- mouse_queue[mouse_event_queue_begin_idx %
- mouse_event_queue_size].y;
- graphics_priv_root->force_redraw = 1;
- callback_list_call_attr_3(graphics_priv_root->cbl,
- attr_button, (void *) 0,
- 1, (void *) &p);
- } else if (mouse_queue[mouse_event_queue_begin_idx].
- button == GLUT_LEFT_BUTTON
- && mouse_queue[mouse_event_queue_begin_idx].
- state == GLUT_DOWN) {
- struct point p;
- p.x =
- mouse_queue[mouse_event_queue_begin_idx %
- mouse_event_queue_size].x;
- p.y =
- mouse_queue[mouse_event_queue_begin_idx %
- mouse_event_queue_size].y;
- graphics_priv_root->force_redraw = 1;
- callback_list_call_attr_3(graphics_priv_root->cbl,
- attr_button, (void *) 1,
- 1, (void *) &p);
- }
- ++mouse_event_queue_begin_idx;
- }
- locked = 0;
+ static int locked = 0;
+ if (!locked) {
+ locked = 1;
+ } else {
+ return;
+ }
+
+ if (mouse_event_queue_begin_idx < mouse_event_queue_end_idx) {
+ if (mouse_queue[mouse_event_queue_begin_idx].button ==
+ GLUT_LEFT_BUTTON
+ && mouse_queue[mouse_event_queue_begin_idx].state ==
+ GLUT_UP) {
+ struct point p;
+ p.x =
+ mouse_queue[mouse_event_queue_begin_idx %
+ mouse_event_queue_size].x;
+ p.y =
+ mouse_queue[mouse_event_queue_begin_idx %
+ mouse_event_queue_size].y;
+ graphics_priv_root->force_redraw = 1;
+ callback_list_call_attr_3(graphics_priv_root->cbl, attr_button, (void *) 0, 1, (void *) &p);
+ } else if (mouse_queue[mouse_event_queue_begin_idx].
+ button == GLUT_LEFT_BUTTON
+ && mouse_queue[mouse_event_queue_begin_idx].
+ state == GLUT_DOWN) {
+ struct point p;
+ p.x =
+ mouse_queue[mouse_event_queue_begin_idx %
+ mouse_event_queue_size].x;
+ p.y =
+ mouse_queue[mouse_event_queue_begin_idx %
+ mouse_event_queue_size].y;
+ graphics_priv_root->force_redraw = 1;
+ callback_list_call_attr_3(graphics_priv_root->cbl, attr_button, (void *) 1, 1, (void *) &p);
+ }
+ ++mouse_event_queue_begin_idx;
+ }
+ locked = 0;
#endif
}
/*draws root graphics and its overlays*/
-static int
-redraw_screen(struct graphics_priv *gr)
-{
+static int redraw_screen(struct graphics_priv *gr) {
#ifdef USE_OPENGLES
#else
- graphics_priv_root->dirty = 0;
-
- glCallList(gr->DLid);
- //display overlays display list
- struct graphics_priv *overlay;
- overlay = gr->overlays;
- while (gr->overlay_enabled && overlay) {
- if (overlay->overlay_enabled) {
- glPushMatrix();
- struct point p_eff;
- get_overlay_pos(overlay, &p_eff);
- glTranslatef(p_eff.x, p_eff.y, 1);
- glCallList(overlay->DLid);
- glPopMatrix();
- }
- overlay = overlay->next;
- }
- glutSwapBuffers();
+ graphics_priv_root->dirty = 0;
+
+ glCallList(gr->DLid);
+ //display overlays display list
+ struct graphics_priv *overlay;
+ overlay = gr->overlays;
+ while (gr->overlay_enabled && overlay) {
+ if (overlay->overlay_enabled) {
+ glPushMatrix();
+ struct point p_eff;
+ get_overlay_pos(overlay, &p_eff);
+ glTranslatef(p_eff.x, p_eff.y, 1);
+ glCallList(overlay->DLid);
+ glPopMatrix();
+ }
+ overlay = overlay->next;
+ }
+ glutSwapBuffers();
#endif
- return TRUE;
+ return TRUE;
}
#ifndef USE_OPENGLES
/*filters call to redraw in overlay enabled(map) mode*/
-static gboolean
-redraw_filter(gpointer data)
-{
- struct graphics_priv *gr = (struct graphics_priv*) data;
- if (gr->overlay_enabled && gr->dirty) {
- redraw_screen(gr);
- }
- return 0;
+static gboolean redraw_filter(gpointer data) {
+ struct graphics_priv *gr = (struct graphics_priv*) data;
+ if (gr->overlay_enabled && gr->dirty) {
+ redraw_screen(gr);
+ }
+ return 0;
}
#endif
-static void
-draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
- if (gr->parent) { //overlay
+static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode) {
+ if (gr->parent) { //overlay
#ifdef USE_OPENGLES
#else
- if (mode == draw_mode_begin) {
- glNewList(gr->DLid, GL_COMPILE);
- }
+ if (mode == draw_mode_begin) {
+ glNewList(gr->DLid, GL_COMPILE);
+ }
- if (mode == draw_mode_end) {
- glEndList();
- }
+ if (mode == draw_mode_end) {
+ glEndList();
+ }
#endif
- } else { //root graphics
- if (mode == draw_mode_begin) {
+ } else { //root graphics
+ if (mode == draw_mode_begin) {
#ifdef USE_OPENGLES
#else
- glNewList(gr->DLid, GL_COMPILE);
+ glNewList(gr->DLid, GL_COMPILE);
#endif
- }
+ }
- if (mode == draw_mode_end) {
+ if (mode == draw_mode_end) {
#ifdef USE_OPENGLES
- gr->platform_methods->swap_buffers(gr->platform);
+ gr->platform_methods->swap_buffers(gr->platform);
#else
- glEndList();
- gr->force_redraw = 1;
- if (!gr->overlay_enabled || gr->force_redraw) {
- redraw_screen(gr);
- }
+ glEndList();
+ gr->force_redraw = 1;
+ if (!gr->overlay_enabled || gr->force_redraw) {
+ redraw_screen(gr);
+ }
#endif
- }
- }
- gr->mode = mode;
+ }
+ }
+ gr->mode = mode;
}
static struct graphics_priv *overlay_new(struct graphics_priv *gr,
- struct graphics_methods *meth,
- struct point *p, int w, int h,
- int wraparound);
-
-static int
-graphics_opengl_fullscreen(struct window *w, int on)
-{
- return 1;
+ struct graphics_methods *meth,
+ struct point *p, int w, int h,
+ int wraparound);
+
+static int graphics_opengl_fullscreen(struct window *w, int on) {
+ return 1;
}
-static void
-graphics_opengl_disable_suspend(struct window *w)
-{
+static void graphics_opengl_disable_suspend(struct window *w) {
}
#ifdef USE_OPENGLES2
-static GLuint
-load_shader(const char *shader_source, GLenum type)
-{
- GLuint shader = glCreateShader(type);
+static GLuint load_shader(const char *shader_source, GLenum type) {
+ GLuint shader = glCreateShader(type);
- glShaderSource(shader, 1, &shader_source, NULL);
- glCompileShader(shader);
+ glShaderSource(shader, 1, &shader_source, NULL);
+ glCompileShader(shader);
- return shader;
+ return shader;
}
#endif
-static void *
-get_data(struct graphics_priv *this, const char *type)
-{
- /*TODO initialize gtkglext context when type=="gtk_widget" */
- if (!strcmp(type, "gtk_widget")) {
- fprintf(stderr,
- "Currently GTK gui is not yet supported with opengl graphics driver\n");
- return NULL;
- }
- if (strcmp(type, "window") == 0) {
- struct window *win;
+static void *get_data(struct graphics_priv *this, const char *type) {
+ /*TODO initialize gtkglext context when type=="gtk_widget" */
+ if (!strcmp(type, "gtk_widget")) {
+ fprintf(stderr, "Currently GTK gui is not yet supported with opengl graphics driver\n");
+ return NULL;
+ }
+ if (strcmp(type, "window") == 0) {
+ struct window *win;
#ifdef USE_OPENGLES
- GLuint vertexShader;
- GLuint fragmentShader;
- GLuint textures;
- GLfloat matrix[16];
- int i;
-
- this->window_system=graphics_opengl_x11_new(NULL, this->width, this->height, 32, &this->window_system_methods);
- this->platform=graphics_opengl_egl_new(this->window_system_methods->get_display(this->window_system),
- this->window_system_methods->get_window(this->window_system),
- &this->platform_methods);
- this->window_system_methods->set_callbacks(this->window_system, this, resize_callback_do, click_notify_do, motion_notify_do, NULL);
- resize_callback(this->width,this->height);
+ GLuint vertexShader;
+ GLuint fragmentShader;
+ GLuint textures;
+ GLfloat matrix[16];
+ int i;
+
+ this->window_system=graphics_opengl_x11_new(NULL, this->width, this->height, 32, &this->window_system_methods);
+ this->platform=graphics_opengl_egl_new(this->window_system_methods->get_display(this->window_system),
+ this->window_system_methods->get_window(this->window_system),
+ &this->platform_methods);
+ this->window_system_methods->set_callbacks(this->window_system, this, resize_callback_do, click_notify_do, motion_notify_do, NULL);
+ resize_callback(this->width,this->height);
#if 0
- glClearColor ( 0.4 , 0.4 , 0.4 , 1);
+ glClearColor ( 0.4, 0.4, 0.4, 1);
#endif
- glClear ( GL_COLOR_BUFFER_BIT );
+ glClear ( GL_COLOR_BUFFER_BIT );
#ifdef USE_OPENGLES2
- this->program=glCreateProgram();
- vertexShader = load_shader(vertex_src, GL_VERTEX_SHADER);
- fragmentShader = load_shader(fragment_src, GL_FRAGMENT_SHADER);
- glAttachShader(this->program, vertexShader);
- glAttachShader(this->program, fragmentShader);
- glLinkProgram(this->program);
- glUseProgram(this->program);
- this->mvp_location=glGetUniformLocation(this->program, "mvp");
- this->position_location=glGetAttribLocation(this->program, "position");
- glEnableVertexAttribArray(this->position_location);
- this->texture_position_location=glGetAttribLocation(this->program, "texture_position");
- this->color_location=glGetUniformLocation(this->program, "avcolor");
- this->texture_location=glGetUniformLocation(this->program, "texture");
- this->use_texture_location=glGetUniformLocation(this->program, "use_texture");
- glUniform1i(this->use_texture_location, 0);
- glUniform1i(this->texture_location, 0);
-
- for (i = 0 ; i < 16 ; i++)
- matrix[i]=0.0;
- matrix[0]=2.0/this->width;
- matrix[5]=-2.0/this->height;
- matrix[10]=1;
- matrix[12]=-1;
- matrix[13]=1;
- matrix[15]=1;
- glUniformMatrix4fv(this->mvp_location, 1, GL_FALSE, matrix);
+ this->program=glCreateProgram();
+ vertexShader = load_shader(vertex_src, GL_VERTEX_SHADER);
+ fragmentShader = load_shader(fragment_src, GL_FRAGMENT_SHADER);
+ glAttachShader(this->program, vertexShader);
+ glAttachShader(this->program, fragmentShader);
+ glLinkProgram(this->program);
+ glUseProgram(this->program);
+ this->mvp_location=glGetUniformLocation(this->program, "mvp");
+ this->position_location=glGetAttribLocation(this->program, "position");
+ glEnableVertexAttribArray(this->position_location);
+ this->texture_position_location=glGetAttribLocation(this->program, "texture_position");
+ this->color_location=glGetUniformLocation(this->program, "avcolor");
+ this->texture_location=glGetUniformLocation(this->program, "texture");
+ this->use_texture_location=glGetUniformLocation(this->program, "use_texture");
+ glUniform1i(this->use_texture_location, 0);
+ glUniform1i(this->texture_location, 0);
+
+ for (i = 0 ; i < 16 ; i++)
+ matrix[i]=0.0;
+ matrix[0]=2.0/this->width;
+ matrix[5]=-2.0/this->height;
+ matrix[10]=1;
+ matrix[12]=-1;
+ matrix[13]=1;
+ matrix[15]=1;
+ glUniformMatrix4fv(this->mvp_location, 1, GL_FALSE, matrix);
#else
- glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_VERTEX_ARRAY);
#endif
- glGenTextures(1, &textures);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, textures);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glGenTextures(1, &textures);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, textures);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
#ifndef USE_OPENGLES2
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
#endif
#endif
- win = g_new0(struct window, 1);
- win->priv = this;
- win->fullscreen = graphics_opengl_fullscreen;
- win->disable_suspend = graphics_opengl_disable_suspend;
- return win;
- } else {
+ win = g_new0(struct window, 1);
+ win->priv = this;
+ win->fullscreen = graphics_opengl_fullscreen;
+ win->disable_suspend = graphics_opengl_disable_suspend;
+ return win;
+ } else {
#ifdef USE_OPENGLES
- return NULL;
+ return NULL;
#else
- return &this->DLid;
+ return &this->DLid;
#endif
- }
+ }
}
-static void
-image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
-{
+static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv) {
//TODO free image data in hashtable when graphics is destroyed
//currently graphics destroy is not called !!!
-/*
- g_free(priv->data);
- priv->data = NULL;
- g_free(priv);
- priv = NULL;
-*/
+ /*
+ g_free(priv->data);
+ priv->data = NULL;
+ g_free(priv);
+ priv = NULL;
+ */
}
-static void
-overlay_disable(struct graphics_priv *gr, int disable)
-{
- gr->overlay_enabled = !disable;
- gr->force_redraw = 1;
- draw_mode(gr, draw_mode_end);
+static void overlay_disable(struct graphics_priv *gr, int disable) {
+ gr->overlay_enabled = !disable;
+ gr->force_redraw = 1;
+ draw_mode(gr, draw_mode_end);
}
-static void
-overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h,
- int wraparound)
-{
- int changed = 0;
- int w2, h2;
-
- if (w == 0) {
- w2 = 1;
- } else {
- w2 = w;
- }
-
- if (h == 0) {
- h2 = 1;
- } else {
- h2 = h;
- }
-
- gr->p = *p;
- if (gr->width != w2) {
- gr->width = w2;
- changed = 1;
- }
-
- if (gr->height != h2) {
- gr->height = h2;
- changed = 1;
- }
-
- gr->wraparound = wraparound;
-
- if (changed) {
- if ((w == 0) || (h == 0)) {
- gr->overlay_autodisabled = 1;
- } else {
- gr->overlay_autodisabled = 0;
- }
-
- callback_list_call_attr_2(gr->cbl, attr_resize,
- GINT_TO_POINTER(gr->width),
- GINT_TO_POINTER(gr->height));
- }
+static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound) {
+ int changed = 0;
+ int w2, h2;
+
+ if (w == 0) {
+ w2 = 1;
+ } else {
+ w2 = w;
+ }
+
+ if (h == 0) {
+ h2 = 1;
+ } else {
+ h2 = h;
+ }
+
+ gr->p = *p;
+ if (gr->width != w2) {
+ gr->width = w2;
+ changed = 1;
+ }
+
+ if (gr->height != h2) {
+ gr->height = h2;
+ changed = 1;
+ }
+
+ gr->wraparound = wraparound;
+
+ if (changed) {
+ if ((w == 0) || (h == 0)) {
+ gr->overlay_autodisabled = 1;
+ } else {
+ gr->overlay_autodisabled = 0;
+ }
+
+ callback_list_call_attr_2(gr->cbl, attr_resize, GINT_TO_POINTER(gr->width), GINT_TO_POINTER(gr->height));
+ }
}
static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- NULL,
- draw_text,
- draw_image,
- NULL,
- draw_drag,
- NULL,
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- image_free,
- NULL,
- overlay_disable,
- overlay_resize,
- NULL, /* show_native_keyboard */
- NULL, /* hide_native_keyboard */
+ graphics_destroy,
+ draw_mode,
+ draw_lines,
+ draw_polygon,
+ draw_rectangle,
+ NULL,
+ draw_text,
+ draw_image,
+ NULL,
+ draw_drag,
+ NULL,
+ gc_new,
+ background_gc,
+ overlay_new,
+ image_new,
+ get_data,
+ image_free,
+ NULL,
+ overlay_disable,
+ overlay_resize,
+ NULL, /* show_native_keyboard */
+ NULL, /* hide_native_keyboard */
};
-static struct graphics_priv *
-graphics_opengl_new_helper(struct graphics_methods *meth)
-{
- struct font_priv *(*font_freetype_new) (void *meth);
- font_freetype_new = plugin_get_category_font("freetype");
-
- if (!font_freetype_new) {
- return NULL;
- }
-
- struct graphics_priv *this = g_new0(struct graphics_priv, 1);
-
- font_freetype_new(&this->freetype_methods);
- *meth = graphics_methods;
-
- meth->font_new =
- (struct graphics_font_priv *
- (*)(struct graphics_priv *, struct graphics_font_methods *,
- char *, int, int)) this->freetype_methods.font_new;
- meth->get_text_bbox =
- (void (*) (struct graphics_priv *, struct graphics_font_priv *,
- char *, int, int, struct point*, int)) this->freetype_methods.get_text_bbox;
- return this;
+static struct graphics_priv *graphics_opengl_new_helper(struct graphics_methods *meth) {
+ struct font_priv *(*font_freetype_new) (void *meth);
+ font_freetype_new = plugin_get_category_font("freetype");
+
+ if (!font_freetype_new) {
+ return NULL;
+ }
+
+ struct graphics_priv *this = g_new0(struct graphics_priv, 1);
+
+ font_freetype_new(&this->freetype_methods);
+ *meth = graphics_methods;
+
+ meth->font_new =
+ (struct graphics_font_priv *
+ (*)(struct graphics_priv *, struct graphics_font_methods *,
+ char *, int, int)) this->freetype_methods.font_new;
+ meth->get_text_bbox =
+ (void (*) (struct graphics_priv *, struct graphics_font_priv *,
+ char *, int, int, struct point*, int)) this->freetype_methods.get_text_bbox;
+ return this;
}
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth,
- struct point *p, int w, int h, int wraparound)
-{
- struct graphics_priv *this = graphics_opengl_new_helper(meth);
- this->p = *p;
- this->width = w;
- this->height = h;
- this->parent = gr;
-
- if ((w == 0) || (h == 0)) {
- this->overlay_autodisabled = 1;
- } else {
- this->overlay_autodisabled = 0;
- }
- this->overlay_enabled = 1;
- this->overlay_autodisabled = 0;
-
- this->next = gr->overlays;
- gr->overlays = this;
+static struct graphics_priv *overlay_new(struct graphics_priv *gr, struct graphics_methods *meth,
+ struct point *p, int w, int h, int wraparound) {
+ struct graphics_priv *this = graphics_opengl_new_helper(meth);
+ this->p = *p;
+ this->width = w;
+ this->height = h;
+ this->parent = gr;
+
+ if ((w == 0) || (h == 0)) {
+ this->overlay_autodisabled = 1;
+ } else {
+ this->overlay_autodisabled = 0;
+ }
+ this->overlay_enabled = 1;
+ this->overlay_autodisabled = 0;
+
+ this->next = gr->overlays;
+ gr->overlays = this;
#ifdef USE_OPENGLES
#else
- this->DLid = glGenLists(1);
+ this->DLid = glGenLists(1);
#endif
- return this;
+ return this;
}
#ifdef USE_OPENGLES
-static void
-click_notify_do(struct graphics_priv *priv, int button, int state, int x, int y)
-{
- struct point p={x,y};
- dbg(lvl_debug,"enter state %d button %d\n",state,button);
- callback_list_call_attr_3(priv->cbl, attr_button, (void *) state, (void *)button, (void *) &p);
+static void click_notify_do(struct graphics_priv *priv, int button, int state, int x, int y) {
+ struct point p= {x,y};
+ dbg(lvl_debug,"enter state %d button %d",state,button);
+ callback_list_call_attr_3(priv->cbl, attr_button, (void *) state, (void *)button, (void *) &p);
}
#endif
-static void
-click_notify(int button, int state, int x, int y)
-{
- mouse_queue[mouse_event_queue_end_idx %
- mouse_event_queue_size].button = button;
- mouse_queue[mouse_event_queue_end_idx %
- mouse_event_queue_size].state = state;
+static void click_notify(int button, int state, int x, int y) {
+ mouse_queue[mouse_event_queue_end_idx %
+ mouse_event_queue_size].button = button;
+ mouse_queue[mouse_event_queue_end_idx %
+ mouse_event_queue_size].state = state;
#ifdef MIRRORED_VIEW
- mouse_queue[mouse_event_queue_end_idx % mouse_event_queue_size].x =
- graphics_priv_root->width - x;
+ mouse_queue[mouse_event_queue_end_idx % mouse_event_queue_size].x =
+ graphics_priv_root->width - x;
#else
- mouse_queue[mouse_event_queue_end_idx % mouse_event_queue_size].x =
- x;
+ mouse_queue[mouse_event_queue_end_idx % mouse_event_queue_size].x =
+ x;
#endif
- mouse_queue[mouse_event_queue_end_idx % mouse_event_queue_size].y =
- y;
- ++mouse_event_queue_end_idx;
+ mouse_queue[mouse_event_queue_end_idx % mouse_event_queue_size].y =
+ y;
+ ++mouse_event_queue_end_idx;
}
-static void
-motion_notify_do(struct graphics_priv *priv, int x, int y)
-{
- struct point p;
+static void motion_notify_do(struct graphics_priv *priv, int x, int y) {
+ struct point p;
#ifdef MIRRORED_VIEW
- p.x = priv->width - x;
+ p.x = priv->width - x;
#else
- p.x = x;
+ p.x = x;
#endif
- p.y = y;
- callback_list_call_attr_1(priv->cbl, attr_motion,
- (void *) &p);
- return;
+ p.y = y;
+ callback_list_call_attr_1(priv->cbl, attr_motion, (void *) &p);
+ return;
}
-static void
-motion_notify(int x, int y)
-{
- motion_notify_do(graphics_priv_root, x, y);
+static void motion_notify(int x, int y) {
+ motion_notify_do(graphics_priv_root, x, y);
}
#ifndef USE_OPENGLES
-static gboolean
-graphics_opengl_idle(void *data)
-{
- static int opengl_init_ok = 0;
- if (!opengl_init_ok) {
- callback_list_call_attr_2(graphics_priv_root->cbl,
- attr_resize,
- GINT_TO_POINTER
- (graphics_priv_root->width),
- GINT_TO_POINTER
- (graphics_priv_root->height));
- opengl_init_ok = 1;
- } else {
-
+static gboolean graphics_opengl_idle(void *data) {
+ static int opengl_init_ok = 0;
+ if (!opengl_init_ok) {
+ callback_list_call_attr_2(graphics_priv_root->cbl, attr_resize, GINT_TO_POINTER (graphics_priv_root->width), GINT_TO_POINTER (graphics_priv_root->height));
+ opengl_init_ok = 1;
+ } else {
+
#ifdef FREEGLUT
- glutMainLoopEvent();
+ glutMainLoopEvent();
#endif
- handle_mouse_queue();
- }
- return TRUE;
+ handle_mouse_queue();
+ }
+ return TRUE;
}
#endif
-static void
-ProcessNormalKeys(unsigned char key_in, int x, int y)
-{
- int key = 0;
- char keybuf[2];
-
- switch (key_in) {
- case 13:
- key = NAVIT_KEY_RETURN;
- break;
- default:
- key = key_in;
- break;
- }
- keybuf[0] = key;
- keybuf[1] = '\0';
- graphics_priv_root->force_redraw = 1;
- callback_list_call_attr_1(graphics_priv_root->cbl, attr_keypress,
- (void *) keybuf);
+static void ProcessNormalKeys(unsigned char key_in, int x, int y) {
+ int key = 0;
+ char keybuf[2];
+
+ switch (key_in) {
+ case 13:
+ key = NAVIT_KEY_RETURN;
+ break;
+ default:
+ key = key_in;
+ break;
+ }
+ keybuf[0] = key;
+ keybuf[1] = '\0';
+ graphics_priv_root->force_redraw = 1;
+ callback_list_call_attr_1(graphics_priv_root->cbl, attr_keypress, (void *) keybuf);
}
-static void
-ProcessSpecialKeys(int key_in, int x, int y)
-{
- int key = 0;
- char keybuf[2];
-
- switch (key_in) {
- case 102:
- key = NAVIT_KEY_RIGHT;
- break;
- case 100:
- key = NAVIT_KEY_LEFT;
- break;
- case 103:
- key = NAVIT_KEY_DOWN;
- break;
- case 101:
- key = NAVIT_KEY_UP;
- break;
- case 104:
- key = NAVIT_KEY_ZOOM_OUT;
- break;
- case 105:
- key = NAVIT_KEY_ZOOM_IN;
- break;
- default:
- break;
- } //switch
-
- graphics_priv_root->force_redraw = 1;
- keybuf[0] = key;
- keybuf[1] = '\0';
- callback_list_call_attr_1(graphics_priv_root->cbl, attr_keypress,
- (void *) keybuf);
+static void ProcessSpecialKeys(int key_in, int x, int y) {
+ int key = 0;
+ char keybuf[2];
+
+ switch (key_in) {
+ case 102:
+ key = NAVIT_KEY_RIGHT;
+ break;
+ case 100:
+ key = NAVIT_KEY_LEFT;
+ break;
+ case 103:
+ key = NAVIT_KEY_DOWN;
+ break;
+ case 101:
+ key = NAVIT_KEY_UP;
+ break;
+ case 104:
+ key = NAVIT_KEY_ZOOM_OUT;
+ break;
+ case 105:
+ key = NAVIT_KEY_ZOOM_IN;
+ break;
+ default:
+ break;
+ } //switch
+
+ graphics_priv_root->force_redraw = 1;
+ keybuf[0] = key;
+ keybuf[1] = '\0';
+ callback_list_call_attr_1(graphics_priv_root->cbl, attr_keypress, (void *) keybuf);
}
-static void
-resize_callback_do(struct graphics_priv *priv, int w, int h)
-{
- glViewport(0, 0, w, h);
+static void resize_callback_do(struct graphics_priv *priv, int w, int h) {
+ glViewport(0, 0, w, h);
#ifndef USE_OPENGLES2
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
#ifdef MIRRORED_VIEW
- glOrthof(glF(w), glF(0), glF(h), glF(0), glF(1), glF(-1));
+ glOrthof(glF(w), glF(0), glF(h), glF(0), glF(1), glF(-1));
#else
- glOrthof(glF(0), glF(w), glF(h), glF(0), glF(1), glF(-1));
+ glOrthof(glF(0), glF(w), glF(h), glF(0), glF(1), glF(-1));
#endif
#endif
- priv->width = w;
- priv->height = h;
+ priv->width = w;
+ priv->height = h;
- callback_list_call_attr_2(priv->cbl, attr_resize,
- GINT_TO_POINTER(w), GINT_TO_POINTER(h));
+ callback_list_call_attr_2(priv->cbl, attr_resize, GINT_TO_POINTER(w), GINT_TO_POINTER(h));
}
-static void
-resize_callback(int w, int h)
-{
- resize_callback_do(graphics_priv_root, w, h);
+static void resize_callback(int w, int h) {
+ resize_callback_do(graphics_priv_root, w, h);
}
-static void
-display(void)
-{
- graphics_priv_root->force_redraw = 1;
- redraw_screen(graphics_priv_root);
- resize_callback(graphics_priv_root->width,
- graphics_priv_root->height);
+static void display(void) {
+ graphics_priv_root->force_redraw = 1;
+ redraw_screen(graphics_priv_root);
+ resize_callback(graphics_priv_root->width, graphics_priv_root->height);
}
-static void
-glut_close(void)
-{
- callback_list_call_attr_0(graphics_priv_root->cbl,
- attr_window_closed);
+static void glut_close(void) {
+ callback_list_call_attr_0(graphics_priv_root->cbl, attr_window_closed);
}
-static struct graphics_priv *
-graphics_opengl_new(struct navit *nav, struct graphics_methods *meth,
- struct attr **attrs, struct callback_list *cbl)
-{
- struct attr *attr;
-
- if (!event_request_system("glib", "graphics_opengl_new"))
- return NULL;
-
- struct graphics_priv *this = graphics_opengl_new_helper(meth);
- graphics_priv_root = this;
-
- this->nav = nav;
- this->parent = NULL;
- this->overlay_enabled = 1;
-
- this->width = SCREEN_WIDTH;
- if ((attr = attr_search(attrs, NULL, attr_w)))
- this->width = attr->u.num;
- this->height = SCREEN_HEIGHT;
- if ((attr = attr_search(attrs, NULL, attr_h)))
- this->height = attr->u.num;
- this->timeout = 100;
- if ((attr = attr_search(attrs, NULL, attr_timeout)))
- this->timeout = attr->u.num;
- this->delay = 0;
- if ((attr = attr_search(attrs, NULL, attr_delay)))
- this->delay = attr->u.num;
- this->cbl = cbl;
-
- char *cmdline = "";
- int argc = 0;
+static struct graphics_priv *graphics_opengl_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct attr *attr;
+
+ if (!event_request_system("glib", "graphics_opengl_new"))
+ return NULL;
+
+ struct graphics_priv *this = graphics_opengl_new_helper(meth);
+ graphics_priv_root = this;
+
+ this->nav = nav;
+ this->parent = NULL;
+ this->overlay_enabled = 1;
+
+ this->width = SCREEN_WIDTH;
+ if ((attr = attr_search(attrs, NULL, attr_w)))
+ this->width = attr->u.num;
+ this->height = SCREEN_HEIGHT;
+ if ((attr = attr_search(attrs, NULL, attr_h)))
+ this->height = attr->u.num;
+ this->timeout = 100;
+ if ((attr = attr_search(attrs, NULL, attr_timeout)))
+ this->timeout = attr->u.num;
+ this->delay = 0;
+ if ((attr = attr_search(attrs, NULL, attr_delay)))
+ this->delay = attr->u.num;
+ this->cbl = cbl;
+
+ char *cmdline = "";
+ int argc = 0;
#ifndef USE_OPENGLES
- glutInit(&argc, &cmdline);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
+ glutInit(&argc, &cmdline);
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
- glutInitWindowSize(this->width, this->height);
- glutInitWindowPosition(0, 0);
- glutCreateWindow("Navit opengl window");
+ glutInitWindowSize(this->width, this->height);
+ glutInitWindowPosition(0, 0);
+ glutCreateWindow("Navit opengl window");
- glutDisplayFunc(display);
- glutReshapeFunc(resize_callback);
- resize_callback(this->width, this->height);
+ glutDisplayFunc(display);
+ glutReshapeFunc(resize_callback);
+ resize_callback(this->width, this->height);
#endif
- graphics_priv_root->cbl = cbl;
- graphics_priv_root->width = this->width;
- graphics_priv_root->height = this->height;
+ graphics_priv_root->cbl = cbl;
+ graphics_priv_root->width = this->width;
+ graphics_priv_root->height = this->height;
#ifndef USE_OPENGLES
- glutMotionFunc(motion_notify);
- glutPassiveMotionFunc(motion_notify);
- glutMouseFunc(click_notify);
- glutKeyboardFunc(ProcessNormalKeys);
- glutSpecialFunc(ProcessSpecialKeys);
+ glutMotionFunc(motion_notify);
+ glutPassiveMotionFunc(motion_notify);
+ glutMouseFunc(click_notify);
+ glutKeyboardFunc(ProcessNormalKeys);
+ glutSpecialFunc(ProcessSpecialKeys);
#ifdef FREEGLUT
- glutCloseFunc(glut_close);
+ glutCloseFunc(glut_close);
#endif
- this->DLid = glGenLists(1);
+ this->DLid = glGenLists(1);
- g_timeout_add(G_PRIORITY_DEFAULT + 10, graphics_opengl_idle, NULL);
+ g_timeout_add(G_PRIORITY_DEFAULT + 10, graphics_opengl_idle, NULL);
- /*this will only refresh screen in map(overlay enabled) mode */
- g_timeout_add(G_PRIORITY_DEFAULT + 1000, redraw_filter, this);
+ /*this will only refresh screen in map(overlay enabled) mode */
+ g_timeout_add(G_PRIORITY_DEFAULT + 1000, redraw_filter, this);
#endif
- //create hash table for uncompressed image data
- hImageData = g_hash_table_new(g_str_hash, g_str_equal);
- return this;
+ //create hash table for uncompressed image data
+ hImageData = g_hash_table_new(g_str_hash, g_str_equal);
+ return this;
}
-static void
-event_opengl_main_loop_run(void)
-{
- dbg(lvl_info, "enter\n");
+static void event_opengl_main_loop_run(void) {
+ dbg(lvl_info, "enter");
}
-static void
-event_opengl_main_loop_quit(void)
-{
- dbg(lvl_debug, "enter\n");
+static void event_opengl_main_loop_quit(void) {
+ dbg(lvl_debug, "enter");
}
-static struct event_watch *
-event_opengl_add_watch(int fd, enum event_watch_cond cond,
- struct callback *cb)
-{
- dbg(lvl_debug, "enter\n");
- return NULL;
+static struct event_watch *event_opengl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) {
+ dbg(lvl_debug, "enter");
+ return NULL;
}
-static void
-event_opengl_remove_watch(struct event_watch *ev)
-{
- dbg(lvl_debug, "enter\n");
+static void event_opengl_remove_watch(struct event_watch *ev) {
+ dbg(lvl_debug, "enter");
}
-static struct event_timeout *
-event_opengl_add_timeout(int timeout, int multi, struct callback *cb)
-{
- dbg(lvl_debug, "enter\n");
- return NULL;
+static struct event_timeout *event_opengl_add_timeout(int timeout, int multi, struct callback *cb) {
+ dbg(lvl_debug, "enter");
+ return NULL;
}
-static void
-event_opengl_remove_timeout(struct event_timeout *to)
-{
- dbg(lvl_debug, "enter\n");
+static void event_opengl_remove_timeout(struct event_timeout *to) {
+ dbg(lvl_debug, "enter");
}
-static struct event_idle *
-event_opengl_add_idle(int priority, struct callback *cb)
-{
- dbg(lvl_debug, "enter\n");
- return NULL;
+static struct event_idle *event_opengl_add_idle(int priority, struct callback *cb) {
+ dbg(lvl_debug, "enter");
+ return NULL;
}
-static void
-event_opengl_remove_idle(struct event_idle *ev)
-{
- dbg(lvl_debug, "enter\n");
+static void event_opengl_remove_idle(struct event_idle *ev) {
+ dbg(lvl_debug, "enter");
}
-static void
-event_opengl_call_callback(struct callback_list *cb)
-{
- dbg(lvl_debug, "enter\n");
+static void event_opengl_call_callback(struct callback_list *cb) {
+ dbg(lvl_debug, "enter");
}
static struct event_methods event_opengl_methods = {
- event_opengl_main_loop_run,
- event_opengl_main_loop_quit,
- event_opengl_add_watch,
- event_opengl_remove_watch,
- event_opengl_add_timeout,
- event_opengl_remove_timeout,
- event_opengl_add_idle,
- event_opengl_remove_idle,
- event_opengl_call_callback,
+ event_opengl_main_loop_run,
+ event_opengl_main_loop_quit,
+ event_opengl_add_watch,
+ event_opengl_remove_watch,
+ event_opengl_add_timeout,
+ event_opengl_remove_timeout,
+ event_opengl_add_idle,
+ event_opengl_remove_idle,
+ event_opengl_call_callback,
};
-static struct event_priv *
-event_opengl_new(struct event_methods *meth)
-{
- *meth = event_opengl_methods;
- return NULL;
+static struct event_priv *event_opengl_new(struct event_methods *meth) {
+ *meth = event_opengl_methods;
+ return NULL;
}
-void
-plugin_init(void)
-{
- plugin_register_category_graphics("opengl", graphics_opengl_new);
- plugin_register_category_event("opengl", event_opengl_new);
+void plugin_init(void) {
+ plugin_register_category_graphics("opengl", graphics_opengl_new);
+ plugin_register_category_event("opengl", event_opengl_new);
}
diff --git a/navit/graphics/opengl/graphics_opengl_egl.c b/navit/graphics/opengl/graphics_opengl_egl.c
index cb91ac88e..032169f7b 100644
--- a/navit/graphics/opengl/graphics_opengl_egl.c
+++ b/navit/graphics/opengl/graphics_opengl_egl.c
@@ -11,87 +11,82 @@
#include "debug.h"
struct graphics_opengl_platform {
- EGLSurface eglwindow;
- EGLDisplay egldisplay;
- EGLConfig config[1];
- EGLContext context;
+ EGLSurface eglwindow;
+ EGLDisplay egldisplay;
+ EGLConfig config[1];
+ EGLContext context;
};
static EGLint attributeList[] = {
- EGL_RED_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_RED_SIZE, 8,
+ EGL_ALPHA_SIZE, 8,
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
#ifdef USE_OPENGLES2
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
#endif
- EGL_NONE
+ EGL_NONE
};
EGLint aEGLContextAttributes[] = {
#ifdef USE_OPENGLES2
- EGL_CONTEXT_CLIENT_VERSION, 2,
+ EGL_CONTEXT_CLIENT_VERSION, 2,
#endif
- EGL_NONE
+ EGL_NONE
};
-static void
-graphics_opengl_egl_destroy(struct graphics_opengl_platform *egl)
-{
- g_free(egl);
+static void graphics_opengl_egl_destroy(struct graphics_opengl_platform *egl) {
+ g_free(egl);
}
-static void
-graphics_opengl_egl_swap_buffers(struct graphics_opengl_platform *egl)
-{
- eglSwapBuffers(egl->egldisplay, egl->eglwindow);
+static void graphics_opengl_egl_swap_buffers(struct graphics_opengl_platform *egl) {
+ eglSwapBuffers(egl->egldisplay, egl->eglwindow);
}
struct graphics_opengl_platform_methods graphics_opengl_egl_methods = {
- graphics_opengl_egl_destroy,
- graphics_opengl_egl_swap_buffers,
+ graphics_opengl_egl_destroy,
+ graphics_opengl_egl_swap_buffers,
};
struct graphics_opengl_platform *
-graphics_opengl_egl_new(void *display, void *window, struct graphics_opengl_platform_methods **methods)
-{
- struct graphics_opengl_platform *ret=g_new0(struct graphics_opengl_platform,1);
- EGLint major,minor,nconfig;
+graphics_opengl_egl_new(void *display, void *window, struct graphics_opengl_platform_methods **methods) {
+ struct graphics_opengl_platform *ret=g_new0(struct graphics_opengl_platform,1);
+ EGLint major,minor,nconfig;
- *methods=&graphics_opengl_egl_methods;
- ret->egldisplay = eglGetDisplay((EGLNativeDisplayType)display);
- if (!ret->egldisplay) {
- dbg(lvl_error, "can't get display\n");
- goto error;
- }
- if (!eglInitialize(ret->egldisplay, &major, &minor)) {
- dbg(lvl_error, "eglInitialize failed\n");
- goto error;
- }
- dbg(lvl_debug,"eglInitialize ok with version %d.%d\n",major,minor);
- eglBindAPI(EGL_OPENGL_ES_API);
- if (!eglChooseConfig(ret->egldisplay, attributeList, ret->config, sizeof(ret->config)/sizeof(EGLConfig), &nconfig)) {
- dbg(lvl_error, "eglChooseConfig failed\n");
- goto error;
- }
- if (nconfig != 1) {
- dbg(lvl_error, "unexpected number of configs %d\n",nconfig);
- goto error;
- }
- ret->eglwindow = eglCreateWindowSurface(ret->egldisplay, ret->config[0], (NativeWindowType) window, NULL);
- if (ret->eglwindow == EGL_NO_SURFACE) {
- dbg(lvl_error, "eglCreateWindowSurface failed");
- goto error;
- }
- ret->context = eglCreateContext(ret->egldisplay, ret->config[0], EGL_NO_CONTEXT, aEGLContextAttributes);
- if (ret->context == EGL_NO_CONTEXT) {
- dbg(lvl_error, "eglCreateContext failed");
- goto error;
- }
- eglMakeCurrent(ret->egldisplay, ret->eglwindow, ret->eglwindow, ret->context);
- return ret;
+ *methods=&graphics_opengl_egl_methods;
+ ret->egldisplay = eglGetDisplay((EGLNativeDisplayType)display);
+ if (!ret->egldisplay) {
+ dbg(lvl_error, "can't get display");
+ goto error;
+ }
+ if (!eglInitialize(ret->egldisplay, &major, &minor)) {
+ dbg(lvl_error, "eglInitialize failed");
+ goto error;
+ }
+ dbg(lvl_debug,"eglInitialize ok with version %d.%d",major,minor);
+ eglBindAPI(EGL_OPENGL_ES_API);
+ if (!eglChooseConfig(ret->egldisplay, attributeList, ret->config, sizeof(ret->config)/sizeof(EGLConfig), &nconfig)) {
+ dbg(lvl_error, "eglChooseConfig failed");
+ goto error;
+ }
+ if (nconfig != 1) {
+ dbg(lvl_error, "unexpected number of configs %d",nconfig);
+ goto error;
+ }
+ ret->eglwindow = eglCreateWindowSurface(ret->egldisplay, ret->config[0], (NativeWindowType) window, NULL);
+ if (ret->eglwindow == EGL_NO_SURFACE) {
+ dbg(lvl_error, "eglCreateWindowSurface failed");
+ goto error;
+ }
+ ret->context = eglCreateContext(ret->egldisplay, ret->config[0], EGL_NO_CONTEXT, aEGLContextAttributes);
+ if (ret->context == EGL_NO_CONTEXT) {
+ dbg(lvl_error, "eglCreateContext failed");
+ goto error;
+ }
+ eglMakeCurrent(ret->egldisplay, ret->eglwindow, ret->eglwindow, ret->context);
+ return ret;
error:
- graphics_opengl_egl_destroy(ret);
- return NULL;
+ graphics_opengl_egl_destroy(ret);
+ return NULL;
}
diff --git a/navit/graphics/opengl/graphics_opengl_x11.c b/navit/graphics/opengl/graphics_opengl_x11.c
index 8f4b02eaf..f56b2b9d5 100644
--- a/navit/graphics/opengl/graphics_opengl_x11.c
+++ b/navit/graphics/opengl/graphics_opengl_x11.c
@@ -7,147 +7,138 @@
#include "graphics_opengl.h"
struct graphics_opengl_window_system {
- Display *display;
- int screen;
- Window window,root_window;
- XVisualInfo visual;
- Colormap colormap;
- struct callback *cb;
- struct event_watch *watch;
- void *data;
- void (*resize)(void *data, int w, int h);
- void (*button)(void *data, int button, int state, int x, int y);
- void (*motion)(void *data, int x, int y);
- void *keypress;
+ Display *display;
+ int screen;
+ Window window,root_window;
+ XVisualInfo visual;
+ Colormap colormap;
+ struct callback *cb;
+ struct event_watch *watch;
+ void *data;
+ void (*resize)(void *data, int w, int h);
+ void (*button)(void *data, int button, int state, int x, int y);
+ void (*motion)(void *data, int x, int y);
+ void *keypress;
};
-static void
-graphics_opengl_x11_destroy(struct graphics_opengl_window_system *x11)
-{
- if (x11->watch)
- event_remove_watch(x11->watch);
- if (x11->cb)
- callback_destroy(x11->cb);
- if (x11->display) {
- if (x11->window)
- XDestroyWindow(x11->display, x11->window);
- if (x11->colormap)
- XFreeColormap(x11->display, x11->colormap);
- XCloseDisplay(x11->display);
- }
- g_free(x11);
+static void graphics_opengl_x11_destroy(struct graphics_opengl_window_system *x11) {
+ if (x11->watch)
+ event_remove_watch(x11->watch);
+ if (x11->cb)
+ callback_destroy(x11->cb);
+ if (x11->display) {
+ if (x11->window)
+ XDestroyWindow(x11->display, x11->window);
+ if (x11->colormap)
+ XFreeColormap(x11->display, x11->colormap);
+ XCloseDisplay(x11->display);
+ }
+ g_free(x11);
}
-static void *
-graphics_opengl_get_display(struct graphics_opengl_window_system *x11)
-{
- return x11->display;
+static void *graphics_opengl_get_display(struct graphics_opengl_window_system *x11) {
+ return x11->display;
}
-static void *
-graphics_opengl_get_window(struct graphics_opengl_window_system *x11)
-{
- return (void *)x11->window;
+static void *graphics_opengl_get_window(struct graphics_opengl_window_system *x11) {
+ return (void *)x11->window;
}
-static void
-graphics_opengl_set_callbacks(struct graphics_opengl_window_system *x11, void *data, void *resize, void *button, void *motion, void *keypress)
-{
- x11->data=data;
- x11->resize=resize;
- x11->button=button;
- x11->motion=motion;
- x11->keypress=keypress;
+static void graphics_opengl_set_callbacks(struct graphics_opengl_window_system *x11, void *data, void *resize, void *button, void *motion, void *keypress) {
+ x11->data=data;
+ x11->resize=resize;
+ x11->button=button;
+ x11->motion=motion;
+ x11->keypress=keypress;
}
struct graphics_opengl_window_system_methods graphics_opengl_x11_methods = {
- graphics_opengl_x11_destroy,
- graphics_opengl_get_display,
- graphics_opengl_get_window,
- graphics_opengl_set_callbacks,
+ graphics_opengl_x11_destroy,
+ graphics_opengl_get_display,
+ graphics_opengl_get_window,
+ graphics_opengl_set_callbacks,
};
-static void
-graphics_opengl_x11_watch(struct graphics_opengl_window_system *x11)
-{
- XEvent event;
- while (XPending(x11->display)) {
- XNextEvent(x11->display, &event);
- switch(event.type) {
- case ButtonPress:
- if (x11->button)
- x11->button(x11->data,event.xbutton.button,1,event.xbutton.x,event.xbutton.y);
- break;
- case ButtonRelease:
- if (x11->button)
- x11->button(x11->data,event.xbutton.button,0,event.xbutton.x,event.xbutton.y);
- break;
- case ConfigureNotify:
- dbg(lvl_debug,"ConfigureNotify\n");
- break;
- case Expose:
- dbg(lvl_debug,"Expose\n");
- break;
- case KeyPress:
- dbg(lvl_debug,"KeyPress\n");
- break;
- case KeyRelease:
- dbg(lvl_debug,"KeyRelease\n");
- break;
- case MapNotify:
- dbg(lvl_debug,"MapNotify\n");
- break;
- case MotionNotify:
- if (x11->motion)
- x11->motion(x11->data,event.xmotion.x,event.xmotion.y);
- break;
- case ReparentNotify:
- dbg(lvl_debug,"ReparentNotify\n");
- break;
- default:
- dbg(lvl_debug,"type %d\n",event.type);
- }
- }
+static void graphics_opengl_x11_watch(struct graphics_opengl_window_system *x11) {
+ XEvent event;
+ while (XPending(x11->display)) {
+ XNextEvent(x11->display, &event);
+ switch(event.type) {
+ case ButtonPress:
+ if (x11->button)
+ x11->button(x11->data,event.xbutton.button,1,event.xbutton.x,event.xbutton.y);
+ break;
+ case ButtonRelease:
+ if (x11->button)
+ x11->button(x11->data,event.xbutton.button,0,event.xbutton.x,event.xbutton.y);
+ break;
+ case ConfigureNotify:
+ dbg(lvl_debug,"ConfigureNotify");
+ break;
+ case Expose:
+ dbg(lvl_debug,"Expose");
+ break;
+ case KeyPress:
+ dbg(lvl_debug,"KeyPress");
+ break;
+ case KeyRelease:
+ dbg(lvl_debug,"KeyRelease");
+ break;
+ case MapNotify:
+ dbg(lvl_debug,"MapNotify");
+ break;
+ case MotionNotify:
+ if (x11->motion)
+ x11->motion(x11->data,event.xmotion.x,event.xmotion.y);
+ break;
+ case ReparentNotify:
+ dbg(lvl_debug,"ReparentNotify");
+ break;
+ default:
+ dbg(lvl_debug,"type %d",event.type);
+ }
+ }
}
-
+
struct graphics_opengl_window_system *
-graphics_opengl_x11_new(void *displayname, int w, int h, int depth, struct graphics_opengl_window_system_methods **methods)
-{
- struct graphics_opengl_window_system *ret=g_new0(struct graphics_opengl_window_system, 1);
- XSetWindowAttributes attributes;
- unsigned long valuemask;
+graphics_opengl_x11_new(void *displayname, int w, int h, int depth, struct graphics_opengl_window_system_methods **methods) {
+ struct graphics_opengl_window_system *ret=g_new0(struct graphics_opengl_window_system, 1);
+ XSetWindowAttributes attributes;
+ unsigned long valuemask;
- ret->cb=callback_new_1(callback_cast(graphics_opengl_x11_watch), ret);
- if (!event_request_system("glib", "graphics_opengl_x11_new"))
- goto error;
- *methods=&graphics_opengl_x11_methods;
- ret->display=XOpenDisplay(displayname);
- if (!ret->display) {
- dbg(lvl_error,"failed to open display\n");
- goto error;
- }
- ret->watch=event_add_watch(ConnectionNumber(ret->display), event_watch_cond_read, ret->cb);
- ret->screen=XDefaultScreen(ret->display);
- ret->root_window=RootWindow(ret->display, ret->screen);
- if (!XMatchVisualInfo(ret->display, ret->screen, depth, TrueColor, &ret->visual)) {
- dbg(lvl_error,"failed to find visual\n");
- goto error;
- }
- ret->colormap=XCreateColormap(ret->display, ret->root_window, ret->visual.visual, AllocNone);
- valuemask = /* CWBackPixel | */ CWBorderPixel | CWEventMask | CWColormap ; // | CWBackingStore;
- attributes.colormap = ret->colormap;
- attributes.border_pixel = 0;
- attributes.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonMotionMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask;
- attributes.backing_store = Always;
- ret->window=XCreateWindow(ret->display, RootWindow(ret->display, ret->screen), 0, 0, w, h, 0, ret->visual.depth, InputOutput, ret->visual.visual, valuemask, &attributes);
- XMapWindow(ret->display, ret->window);
- XFlush(ret->display);
- graphics_opengl_x11_watch(ret);
- return ret;
+ ret->cb=callback_new_1(callback_cast(graphics_opengl_x11_watch), ret);
+ if (!event_request_system("glib", "graphics_opengl_x11_new"))
+ goto error;
+ *methods=&graphics_opengl_x11_methods;
+ ret->display=XOpenDisplay(displayname);
+ if (!ret->display) {
+ dbg(lvl_error,"failed to open display");
+ goto error;
+ }
+ ret->watch=event_add_watch(ConnectionNumber(ret->display), event_watch_cond_read, ret->cb);
+ ret->screen=XDefaultScreen(ret->display);
+ ret->root_window=RootWindow(ret->display, ret->screen);
+ if (!XMatchVisualInfo(ret->display, ret->screen, depth, TrueColor, &ret->visual)) {
+ dbg(lvl_error,"failed to find visual");
+ goto error;
+ }
+ ret->colormap=XCreateColormap(ret->display, ret->root_window, ret->visual.visual, AllocNone);
+ valuemask = /* CWBackPixel | */ CWBorderPixel | CWEventMask | CWColormap ; // | CWBackingStore;
+ attributes.colormap = ret->colormap;
+ attributes.border_pixel = 0;
+ attributes.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonMotionMask | ButtonReleaseMask |
+ KeyPressMask | KeyReleaseMask;
+ attributes.backing_store = Always;
+ ret->window=XCreateWindow(ret->display, RootWindow(ret->display, ret->screen), 0, 0, w, h, 0, ret->visual.depth,
+ InputOutput, ret->visual.visual, valuemask, &attributes);
+ XMapWindow(ret->display, ret->window);
+ XFlush(ret->display);
+ graphics_opengl_x11_watch(ret);
+ return ret;
error:
- graphics_opengl_x11_destroy(ret);
- return NULL;
+ graphics_opengl_x11_destroy(ret);
+ return NULL;
}
diff --git a/navit/graphics/qt5/CMakeLists.txt b/navit/graphics/qt5/CMakeLists.txt
index ff359e88f..0ba6dbc62 100644
--- a/navit/graphics/qt5/CMakeLists.txt
+++ b/navit/graphics/qt5/CMakeLists.txt
@@ -15,20 +15,20 @@ set(HAVE_FREETYPE 0)
# check if we have FREETYPE
if(font/freetype)
- set(HAVE_FREETYPE 1)
+ set(HAVE_FREETYPE 1)
endif()
# check if we have QML
if(USE_QML)
- set(QML 1)
- qt5_add_resources(QT5_QRC "graphics_qt5.qrc")
- set(GRAPHICS_QT5_ADDITIONAL ${GRAPHICS_QT5_ADDITIONAL} "QNavitQuick.cpp" ${QT5_QRC})
+ set(QML 1)
+ qt5_add_resources(QT5_QRC "graphics_qt5.qrc")
+ set(GRAPHICS_QT5_ADDITIONAL ${GRAPHICS_QT5_ADDITIONAL} "QNavitQuick.cpp" ${QT5_QRC})
endif ()
#check if we have QWIDGET
if(USE_QWIDGET)
- set(QWIDGET 1)
- set(GRAPHICS_QT5_ADDITIONAL ${GRAPHICS_QT5_ADDITIONAL} "QNavitWidget.cpp")
+ set(QWIDGET 1)
+ set(GRAPHICS_QT5_ADDITIONAL ${GRAPHICS_QT5_ADDITIONAL} "QNavitWidget.cpp")
endif ()
module_add_library(graphics_qt5 graphics_qt5.cpp event_qt5.cpp ${GRAPHICS_QT5_ADDITIONAL})
diff --git a/navit/graphics/qt5/QNavitQuick.cpp b/navit/graphics/qt5/QNavitQuick.cpp
index 7df3e0073..dcd0d2aa5 100644
--- a/navit/graphics/qt5/QNavitQuick.cpp
+++ b/navit/graphics/qt5/QNavitQuick.cpp
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-//Style with: clang-format -style=WebKit -i
#include <glib.h>
#ifdef HAVE_UNISTD_H
@@ -46,21 +45,18 @@ extern "C" {
#include <QPainter>
QNavitQuick::QNavitQuick(QQuickItem* parent)
- : QQuickPaintedItem(parent)
-{
+ : QQuickPaintedItem(parent) {
setAcceptedMouseButtons(Qt::AllButtons);
graphics_priv = NULL;
}
-void QNavitQuick::setGraphicContext(GraphicsPriv* gp)
-{
- dbg(lvl_debug, "enter\n");
+void QNavitQuick::setGraphicContext(GraphicsPriv* gp) {
+ dbg(lvl_debug, "enter");
graphics_priv = gp->gp;
QObject::connect(gp, SIGNAL(update()), this, SLOT(update()));
}
-static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEvent* event)
-{
+static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEvent* event) {
GHashTableIter iter;
struct graphics_priv *key, *value;
g_hash_table_iter_init(&iter, gp->overlays);
@@ -68,7 +64,8 @@ static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEve
if (!value->disable) {
QRect rr(value->x, value->y, value->pixmap->width(), value->pixmap->height());
if (event->rect().intersects(rr)) {
- dbg(lvl_debug, "draw overlay (%d, %d, %d, %d)\n", value->x + value->scroll_x, value->y + value->scroll_y, value->pixmap->width(), value->pixmap->height());
+ dbg(lvl_debug, "draw overlay (%d, %d, %d, %d)", value->x + value->scroll_x, value->y + value->scroll_y,
+ value->pixmap->width(), value->pixmap->height());
painter->drawPixmap(value->x, value->y, *value->pixmap);
/* draw overlays of overlay if any by recursive calling */
paintOverlays(painter, value, event);
@@ -77,11 +74,12 @@ static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEve
}
}
-void QNavitQuick::paint(QPainter* painter)
-{
- QPaintEvent event = QPaintEvent(QRect(boundingRect().x(), boundingRect().y(), boundingRect().width(), boundingRect().height()));
+void QNavitQuick::paint(QPainter* painter) {
+ QPaintEvent event = QPaintEvent(QRect(boundingRect().x(), boundingRect().y(), boundingRect().width(),
+ boundingRect().height()));
- dbg(lvl_debug, "enter (%f, %f, %f, %f)\n", boundingRect().x(), boundingRect().y(), boundingRect().width(), boundingRect().height());
+ dbg(lvl_debug, "enter (%f, %f, %f, %f)", boundingRect().x(), boundingRect().y(), boundingRect().width(),
+ boundingRect().height());
/* color background if any */
if (graphics_priv->background_graphics_gc_priv != NULL) {
@@ -90,14 +88,16 @@ void QNavitQuick::paint(QPainter* painter)
}
/* draw base */
painter->drawPixmap(graphics_priv->scroll_x, graphics_priv->scroll_y, *graphics_priv->pixmap,
- boundingRect().x(), boundingRect().y(),
- boundingRect().width(), boundingRect().height());
- paintOverlays(painter, graphics_priv, &event);
+ boundingRect().x(), boundingRect().y(),
+ boundingRect().width(), boundingRect().height());
+ /* disable on root pane disables ALL overlays (for drag of background) */
+ if(!(graphics_priv->disable)) {
+ paintOverlays(painter, graphics_priv, &event);
+ }
}
-void QNavitQuick::keyPressEvent(QKeyEvent* event)
-{
- dbg(lvl_debug, "enter\n");
+void QNavitQuick::keyPressEvent(QKeyEvent* event) {
+ dbg(lvl_debug, "enter");
char key[2];
int keycode;
char* text = NULL;
@@ -157,89 +157,89 @@ void QNavitQuick::keyPressEvent(QKeyEvent* event)
else if (key[0])
callback_list_call_attr_1(graphics_priv->callbacks, attr_keypress, (void*)key);
else
- dbg(lvl_debug, "keyval 0x%x\n", keycode);
+ dbg(lvl_debug, "keyval 0x%x", keycode);
}
-void QNavitQuick::keyReleaseEvent(QKeyEvent* event)
-{
- dbg(lvl_debug, "enter\n");
+void QNavitQuick::keyReleaseEvent(QKeyEvent* event) {
+ dbg(lvl_debug, "enter");
}
-void QNavitQuick::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
-{
- dbg(lvl_debug, "enter\n");
+void QNavitQuick::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) {
+ dbg(lvl_debug, "enter");
QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry);
QPainter* painter = NULL;
if (graphics_priv == NULL) {
- dbg(lvl_debug, "Context not set, aborting\n");
+ dbg(lvl_debug, "Context not set, aborting");
return;
}
if (graphics_priv->pixmap != NULL) {
- delete graphics_priv->pixmap;
- graphics_priv->pixmap = NULL;
+ if((width() != graphics_priv->pixmap->width()) || (height() != graphics_priv->pixmap->height())) {
+ delete graphics_priv->pixmap;
+ graphics_priv->pixmap = NULL;
+ }
+ }
+ if (graphics_priv->pixmap == NULL) {
+ graphics_priv->pixmap = new QPixmap(width(), height());
}
-
- graphics_priv->pixmap = new QPixmap(width(), height());
painter = new QPainter(graphics_priv->pixmap);
if (painter != NULL) {
QBrush brush;
painter->fillRect(0, 0, width(), height(), brush);
delete painter;
}
- dbg(lvl_debug, "size %fx%f\n", width(), height());
- dbg(lvl_debug, "pixmap %p %dx%d\n", graphics_priv->pixmap, graphics_priv->pixmap->width(), graphics_priv->pixmap->height());
+ dbg(lvl_debug, "size %fx%f", width(), height());
+ dbg(lvl_debug, "pixmap %p %dx%d", graphics_priv->pixmap, graphics_priv->pixmap->width(),
+ graphics_priv->pixmap->height());
/* if the root window got resized, tell navit about it */
if (graphics_priv->root)
resize_callback(graphics_priv, width(), height());
}
-void QNavitQuick::mouseEvent(int pressed, QMouseEvent* event)
-{
+void QNavitQuick::mouseEvent(int pressed, QMouseEvent* event) {
struct point p;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
p.x = event->x();
p.y = event->y();
switch (event->button()) {
case Qt::LeftButton:
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(1), GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(1),
+ GINT_TO_POINTER(&p));
break;
case Qt::MidButton:
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(2), GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(2),
+ GINT_TO_POINTER(&p));
break;
case Qt::RightButton:
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(3), GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(3),
+ GINT_TO_POINTER(&p));
break;
default:
break;
}
}
-void QNavitQuick::mousePressEvent(QMouseEvent* event)
-{
- dbg(lvl_debug, "enter\n");
+void QNavitQuick::mousePressEvent(QMouseEvent* event) {
+ dbg(lvl_debug, "enter");
mouseEvent(1, event);
}
-void QNavitQuick::mouseReleaseEvent(QMouseEvent* event)
-{
- dbg(lvl_debug, "enter\n");
+void QNavitQuick::mouseReleaseEvent(QMouseEvent* event) {
+ dbg(lvl_debug, "enter");
mouseEvent(0, event);
}
-void QNavitQuick::mouseMoveEvent(QMouseEvent* event)
-{
- dbg(lvl_debug, "enter\n");
+void QNavitQuick::mouseMoveEvent(QMouseEvent* event) {
+ dbg(lvl_debug, "enter");
struct point p;
p.x = event->x();
p.y = event->y();
callback_list_call_attr_1(graphics_priv->callbacks, attr_motion, (void*)&p);
}
-void QNavitQuick::wheelEvent(QWheelEvent* event)
-{
+void QNavitQuick::wheelEvent(QWheelEvent* event) {
struct point p;
int button;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
p.x = event->x(); // xy-coordinates of the mouse pointer
p.y = event->y();
@@ -251,8 +251,10 @@ void QNavitQuick::wheelEvent(QWheelEvent* event)
button = -1;
if (button != -1) {
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button), GINT_TO_POINTER(&p));
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button), GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button),
+ GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button),
+ GINT_TO_POINTER(&p));
}
event->accept();
diff --git a/navit/graphics/qt5/QNavitQuick.h b/navit/graphics/qt5/QNavitQuick.h
index 3679e8127..40c6639ae 100644
--- a/navit/graphics/qt5/QNavitQuick.h
+++ b/navit/graphics/qt5/QNavitQuick.h
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#ifndef QNAVITQUICK_H
#define QNAVITQUICK_H
@@ -29,9 +28,9 @@ class QNavitQuick;
class QNavitQuick : public QQuickPaintedItem {
Q_OBJECT
public:
+ void paint(QPainter* painter);
QNavitQuick(QQuickItem* parent = 0);
- void paint(QPainter* painter);
Q_INVOKABLE void setGraphicContext(GraphicsPriv* gp);
diff --git a/navit/graphics/qt5/QNavitWidget.cpp b/navit/graphics/qt5/QNavitWidget.cpp
index 5a5bd303b..355187b49 100644
--- a/navit/graphics/qt5/QNavitWidget.cpp
+++ b/navit/graphics/qt5/QNavitWidget.cpp
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#include <glib.h>
#ifdef HAVE_UNISTD_H
@@ -46,23 +45,20 @@ extern "C" {
#include "graphics_qt5.h"
QNavitWidget::QNavitWidget(struct graphics_priv* my_graphics_priv,
- QWidget* parent,
- Qt::WindowFlags flags)
- : QWidget(parent, flags)
-{
+ QWidget* parent,
+ Qt::WindowFlags flags)
+ : QWidget(parent, flags) {
graphics_priv = my_graphics_priv;
}
-bool QNavitWidget::event(QEvent* event)
-{
+bool QNavitWidget::event(QEvent* event) {
if (event->type() == QEvent::Gesture)
dbg(lvl_debug, "Gesture event caught");
//return gestureEvent(static_cast<QGestureEvent*>(event));
return QWidget::event(event);
}
-static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEvent* event)
-{
+static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEvent* event) {
GHashTableIter iter;
struct graphics_priv *key, *value;
g_hash_table_iter_init(&iter, gp->overlays);
@@ -70,7 +66,8 @@ static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEve
if (!value->disable) {
QRect rr(value->x, value->y, value->pixmap->width(), value->pixmap->height());
if (event->rect().intersects(rr)) {
- dbg(lvl_debug, "draw overlay (%d, %d, %d, %d)\n", value->x + value->scroll_x, value->y + value->scroll_y, value->pixmap->width(), value->pixmap->height());
+ dbg(lvl_debug, "draw overlay (%d, %d, %d, %d)", value->x + value->scroll_x, value->y + value->scroll_y,
+ value->pixmap->width(), value->pixmap->height());
painter->drawPixmap(value->x + value->scroll_x, value->y + value->scroll_y, *value->pixmap);
/* draw overlays of overlay if any by recursive calling */
paintOverlays(painter, value, event);
@@ -79,9 +76,9 @@ static void paintOverlays(QPainter* painter, struct graphics_priv* gp, QPaintEve
}
}
-void QNavitWidget::paintEvent(QPaintEvent* event)
-{
- dbg(lvl_debug, "enter (%d, %d, %d, %d)\n", event->rect().x(), event->rect().y(), event->rect().width(), event->rect().height());
+void QNavitWidget::paintEvent(QPaintEvent* event) {
+ dbg(lvl_debug, "enter (%d, %d, %d, %d)", event->rect().x(), event->rect().y(), event->rect().width(),
+ event->rect().height());
QPainter painter(this);
/* color background if any */
if (graphics_priv->background_graphics_gc_priv != NULL) {
@@ -89,57 +86,64 @@ void QNavitWidget::paintEvent(QPaintEvent* event)
painter.fillRect(event->rect(), *graphics_priv->background_graphics_gc_priv->brush);
}
painter.drawPixmap(event->rect().x(), event->rect().y(), *graphics_priv->pixmap,
- event->rect().x() - graphics_priv->scroll_x, event->rect().y() - graphics_priv->scroll_y,
- event->rect().width(), event->rect().height());
- paintOverlays(&painter, graphics_priv, event);
+ event->rect().x() - graphics_priv->scroll_x, event->rect().y() - graphics_priv->scroll_y,
+ event->rect().width(), event->rect().height());
+ /* disable on root pane disables ALL overlays (for drag of background) */
+ if(!(graphics_priv->disable)) {
+ paintOverlays(&painter, graphics_priv, event);
+ };
}
-void QNavitWidget::resizeEvent(QResizeEvent* event)
-{
+void QNavitWidget::resizeEvent(QResizeEvent* event) {
QPainter* painter = NULL;
if (graphics_priv->pixmap != NULL) {
- delete graphics_priv->pixmap;
- graphics_priv->pixmap = NULL;
+ if((width() != graphics_priv->pixmap->width()) || (height() != graphics_priv->pixmap->height())) {
+ delete graphics_priv->pixmap;
+ graphics_priv->pixmap = NULL;
+ }
+ }
+ if (graphics_priv->pixmap == NULL) {
+ graphics_priv->pixmap = new QPixmap(size());
}
-
- graphics_priv->pixmap = new QPixmap(size());
painter = new QPainter(graphics_priv->pixmap);
if (painter != NULL) {
QBrush brush;
painter->fillRect(0, 0, width(), height(), brush);
delete painter;
}
- dbg(lvl_debug, "size %dx%d\n", width(), height());
- dbg(lvl_debug, "pixmap %p %dx%d\n", graphics_priv->pixmap, graphics_priv->pixmap->width(), graphics_priv->pixmap->height());
+ dbg(lvl_debug, "size %dx%d", width(), height());
+ dbg(lvl_debug, "pixmap %p %dx%d", graphics_priv->pixmap, graphics_priv->pixmap->width(),
+ graphics_priv->pixmap->height());
/* if the root window got resized, tell navit about it */
if (graphics_priv->root)
resize_callback(graphics_priv, width(), height());
}
-void QNavitWidget::mouseEvent(int pressed, QMouseEvent* event)
-{
+void QNavitWidget::mouseEvent(int pressed, QMouseEvent* event) {
struct point p;
- // dbg(lvl_debug,"enter\n");
+ // dbg(lvl_debug,"enter");
p.x = event->x();
p.y = event->y();
switch (event->button()) {
case Qt::LeftButton:
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(1), GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(1),
+ GINT_TO_POINTER(&p));
break;
case Qt::MidButton:
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(2), GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(2),
+ GINT_TO_POINTER(&p));
break;
case Qt::RightButton:
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(3), GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(3),
+ GINT_TO_POINTER(&p));
break;
default:
break;
}
}
-void QNavitWidget::keyPressEvent(QKeyEvent* event)
-{
- dbg(lvl_debug, "enter\n");
+void QNavitWidget::keyPressEvent(QKeyEvent* event) {
+ dbg(lvl_debug, "enter");
char key[2];
int keycode;
char* text = NULL;
@@ -199,35 +203,31 @@ void QNavitWidget::keyPressEvent(QKeyEvent* event)
else if (key[0])
callback_list_call_attr_1(graphics_priv->callbacks, attr_keypress, (void*)key);
else
- dbg(lvl_debug, "keyval 0x%x\n", keycode);
+ dbg(lvl_debug, "keyval 0x%x", keycode);
}
-void QNavitWidget::mousePressEvent(QMouseEvent* event)
-{
- // dbg(lvl_debug,"enter\n");
+void QNavitWidget::mousePressEvent(QMouseEvent* event) {
+ // dbg(lvl_debug,"enter");
mouseEvent(1, event);
}
-void QNavitWidget::mouseReleaseEvent(QMouseEvent* event)
-{
- // dbg(lvl_debug,"enter\n");
+void QNavitWidget::mouseReleaseEvent(QMouseEvent* event) {
+ // dbg(lvl_debug,"enter");
mouseEvent(0, event);
}
-void QNavitWidget::mouseMoveEvent(QMouseEvent* event)
-{
+void QNavitWidget::mouseMoveEvent(QMouseEvent* event) {
struct point p;
- // dbg(lvl_debug,"enter\n");
+ // dbg(lvl_debug,"enter");
p.x = event->x();
p.y = event->y();
callback_list_call_attr_1(graphics_priv->callbacks, attr_motion, (void*)&p);
}
-void QNavitWidget::wheelEvent(QWheelEvent* event)
-{
+void QNavitWidget::wheelEvent(QWheelEvent* event) {
struct point p;
int button;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
p.x = event->x(); // xy-coordinates of the mouse pointer
p.y = event->y();
@@ -239,8 +239,10 @@ void QNavitWidget::wheelEvent(QWheelEvent* event)
button = -1;
if (button != -1) {
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button), GINT_TO_POINTER(&p));
- callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button), GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button),
+ GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(graphics_priv->callbacks, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button),
+ GINT_TO_POINTER(&p));
}
event->accept();
diff --git a/navit/graphics/qt5/QNavitWidget.h b/navit/graphics/qt5/QNavitWidget.h
index 674b69390..40fb88b19 100644
--- a/navit/graphics/qt5/QNavitWidget.h
+++ b/navit/graphics/qt5/QNavitWidget.h
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#ifndef __QNavitWidget_h
#define __QNavitWidget_h
@@ -30,10 +29,9 @@ class QNavitWidget;
class QNavitWidget : public QWidget {
Q_OBJECT
-public:
- QNavitWidget(struct graphics_priv* my_graphics_priv,
- QWidget* parent,
- Qt::WindowFlags flags);
+public: QNavitWidget(struct graphics_priv* my_graphics_priv,
+ QWidget* parent,
+ Qt::WindowFlags flags);
protected:
virtual bool event(QEvent* event);
diff --git a/navit/graphics/qt5/event_qt5.cpp b/navit/graphics/qt5/event_qt5.cpp
index 08fb6e525..70870ece7 100644
--- a/navit/graphics/qt5/event_qt5.cpp
+++ b/navit/graphics/qt5/event_qt5.cpp
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#include <glib.h>
#include <stdio.h>
@@ -58,12 +57,20 @@ struct event_watch {
static void event_qt5_remove_timeout(struct event_timeout* to);
qt5_navit_timer::qt5_navit_timer(QObject* parent)
- : QObject(parent)
-{
+ : QObject(parent) {
timer_type = g_hash_table_new(NULL, NULL);
timer_callback = g_hash_table_new(NULL, NULL);
watches = g_hash_table_new(NULL, NULL);
- dbg(lvl_debug, "qt5_navit_timer object created\n");
+ dbg(lvl_debug, "qt5_navit_timer object created");
+}
+
+void qt5_navit_timer::watchEvent(int id) {
+ struct event_watch* ret = g_new0(struct event_watch, 1);
+ ret = (struct event_watch*)g_hash_table_lookup(watches, (void*)(long)id);
+ if (ret) {
+ dbg(lvl_debug, "callback found, calling it");
+ callback_call_0(ret->cb);
+ }
}
void qt5_navit_timer::watchEvent(int id)
@@ -80,7 +87,7 @@ void qt5_navit_timer::timerEvent(QTimerEvent* event)
{
int id = event->timerId();
void* multi = NULL;
- // dbg(lvl_debug, "TimerEvent (%d)\n", id);
+ // dbg(lvl_debug, "TimerEvent (%d)", id);
struct callback* cb = (struct callback*)g_hash_table_lookup(timer_callback, (void*)(long)id);
if (cb)
callback_call_0(cb);
@@ -90,30 +97,25 @@ void qt5_navit_timer::timerEvent(QTimerEvent* event)
if (((int)(long)multi) == 0)
event_qt5_remove_timeout((struct event_timeout*)(long)id);
}
- // dbg(lvl_debug, "TimerEvent (%d) leave\n", id);
+ // dbg(lvl_debug, "TimerEvent (%d) leave", id);
}
qt5_navit_timer* qt5_timer = NULL;
-static void
-event_qt5_main_loop_run(void)
-{
+static void event_qt5_main_loop_run(void) {
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
if (navit_app != NULL)
navit_app->exec();
}
-static void event_qt5_main_loop_quit(void)
-{
- dbg(lvl_debug, "enter\n");
+static void event_qt5_main_loop_quit(void) {
+ dbg(lvl_debug, "enter");
exit(0);
}
-static struct event_watch*
-event_qt5_add_watch(int fd, enum event_watch_cond cond, struct callback* cb)
-{
- dbg(lvl_debug, "enter fd=%d\n", (int)(long)fd);
+static struct event_watch* event_qt5_add_watch(int fd, enum event_watch_cond cond, struct callback* cb) {
+ dbg(lvl_debug, "enter fd=%d", (int)(long)fd);
struct event_watch* ret = g_new0(struct event_watch, 1);
ret->fd = fd;
ret->cb = cb;
@@ -123,54 +125,42 @@ event_qt5_add_watch(int fd, enum event_watch_cond cond, struct callback* cb)
return ret;
}
-static void
-event_qt5_remove_watch(struct event_watch* ev)
-{
- dbg(lvl_debug, "enter\n");
+static void event_qt5_remove_watch(struct event_watch* ev) {
+ dbg(lvl_debug, "enter");
g_hash_table_remove(qt5_timer->watches, GINT_TO_POINTER(ev->fd));
delete (ev->sn);
g_free(ev);
}
-static struct event_timeout*
-event_qt5_add_timeout(int timeout, int multi, struct callback* cb)
-{
+static struct event_timeout* event_qt5_add_timeout(int timeout, int multi, struct callback* cb) {
int id;
dbg(lvl_debug, "add timeout %d, mul %d, %p ==", timeout, multi, cb);
id = qt5_timer->startTimer(timeout);
- dbg(lvl_debug, "%d\n", id);
+ dbg(lvl_debug, "%d", id);
g_hash_table_insert(qt5_timer->timer_callback, (void*)(long)id, cb);
g_hash_table_insert(qt5_timer->timer_type, (void*)(long)id, (void*)(long)!!multi);
return (struct event_timeout*)(long)id;
}
-static void
-event_qt5_remove_timeout(struct event_timeout* to)
-{
- dbg(lvl_debug, "remove timeout (%d)\n", (int)(long)to);
+static void event_qt5_remove_timeout(struct event_timeout* to) {
+ dbg(lvl_debug, "remove timeout (%d)", (int)(long)to);
qt5_timer->killTimer((int)(long)to);
g_hash_table_remove(qt5_timer->timer_callback, to);
g_hash_table_remove(qt5_timer->timer_type, to);
}
-static struct event_idle*
-event_qt5_add_idle(int priority, struct callback* cb)
-{
- dbg(lvl_debug, "add idle event\n");
+static struct event_idle* event_qt5_add_idle(int priority, struct callback* cb) {
+ dbg(lvl_debug, "add idle event");
return (struct event_idle*)event_qt5_add_timeout(0, 1, cb);
}
-static void
-event_qt5_remove_idle(struct event_idle* ev)
-{
- dbg(lvl_debug, "Remove idle timeout\n");
+static void event_qt5_remove_idle(struct event_idle* ev) {
+ dbg(lvl_debug, "Remove idle timeout");
event_qt5_remove_timeout((struct event_timeout*)ev);
}
-static void
-event_qt5_call_callback(struct callback_list* cb)
-{
- dbg(lvl_debug, "enter\n");
+static void event_qt5_call_callback(struct callback_list* cb) {
+ dbg(lvl_debug, "enter");
}
static struct event_methods event_qt5_methods = {
@@ -185,15 +175,12 @@ static struct event_methods event_qt5_methods = {
event_qt5_call_callback,
};
-static struct event_priv*
-event_qt5_new(struct event_methods* meth)
-{
+static struct event_priv* event_qt5_new(struct event_methods* meth) {
*meth = event_qt5_methods;
qt5_timer = new qt5_navit_timer(NULL);
return NULL;
}
-void qt5_event_init(void)
-{
+void qt5_event_init(void) {
plugin_register_category_event("qt5", event_qt5_new);
}
diff --git a/navit/graphics/qt5/event_qt5.h b/navit/graphics/qt5/event_qt5.h
index 892e8fca8..7fe184cd1 100644
--- a/navit/graphics/qt5/event_qt5.h
+++ b/navit/graphics/qt5/event_qt5.h
@@ -16,15 +16,13 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#include <QObject>
#include <glib.h>
class qt5_navit_timer : public QObject {
Q_OBJECT
-public:
- qt5_navit_timer(QObject* parent = 0);
+public: qt5_navit_timer(QObject* parent = 0);
GHashTable* timer_type;
GHashTable* timer_callback;
GHashTable* watches;
diff --git a/navit/graphics/qt5/graphics_qt5.cpp b/navit/graphics/qt5/graphics_qt5.cpp
index f7ac15f43..e7b31c605 100644
--- a/navit/graphics/qt5/graphics_qt5.cpp
+++ b/navit/graphics/qt5/graphics_qt5.cpp
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#include <glib.h>
#ifdef HAVE_UNISTD_H
@@ -64,17 +63,14 @@ extern "C" {
#endif
#if USE_QML
-GraphicsPriv::GraphicsPriv(struct graphics_priv* gp)
-{
+GraphicsPriv::GraphicsPriv(struct graphics_priv* gp) {
this->gp = gp;
}
-GraphicsPriv::~GraphicsPriv()
-{
+GraphicsPriv::~GraphicsPriv() {
}
-void GraphicsPriv::emit_update()
-{
+void GraphicsPriv::emit_update() {
emit update();
}
#endif
@@ -89,10 +85,8 @@ struct graphics_image_priv {
QPixmap* pixmap;
};
-static void
-graphics_destroy(struct graphics_priv* gr)
-{
-// dbg(lvl_debug,"enter\n");
+static void graphics_destroy(struct graphics_priv* gr) {
+// dbg(lvl_debug,"enter");
#if HAVE_FREETYPE
gr->freetype_methods.destroy();
#endif
@@ -144,9 +138,8 @@ graphics_destroy(struct graphics_priv* gr)
g_free(gr);
}
-static void font_destroy(struct graphics_font_priv* font)
-{
- // dbg(lvl_debug,"enter\n");
+static void font_destroy(struct graphics_font_priv* font) {
+ // dbg(lvl_debug,"enter");
if (font->font != NULL)
delete (font->font);
g_free(font);
@@ -186,11 +179,11 @@ static const char* fontfamilies[] = {
*
* Allocates a font handle and returnes filled interface stucture
*/
-static struct graphics_font_priv* font_new(struct graphics_priv* gr, struct graphics_font_methods* meth, char* font, int size, int flags)
-{
+static struct graphics_font_priv* font_new(struct graphics_priv* gr, struct graphics_font_methods* meth, char* font,
+ int size, int flags) {
int a = 0;
struct graphics_font_priv* font_priv;
- dbg(lvl_debug, "enter (font %s, %d, 0x%x)\n", font, size, flags);
+ dbg(lvl_debug, "enter (font %s, %d, 0x%x)", font, size, flags);
font_priv = g_new0(struct graphics_font_priv, 1);
font_priv->font = new QFont(fontfamilies[0]);
if (font != NULL)
@@ -201,7 +194,7 @@ static struct graphics_font_priv* font_new(struct graphics_priv* gr, struct grap
a++;
}
if (font_priv->font->exactMatch()) {
- dbg(lvl_debug, "Exactly matching font: %s\n", font_priv->font->family().toUtf8().data());
+ dbg(lvl_debug, "Exactly matching font: %s", font_priv->font->family().toUtf8().data());
} else {
/* set any font*/
if (font != NULL) {
@@ -209,7 +202,7 @@ static struct graphics_font_priv* font_new(struct graphics_priv* gr, struct grap
} else {
font_priv->font->setFamily(fontfamilies[0]);
}
- dbg(lvl_debug, "No matching font. Resort to: %s\n", font_priv->font->family().toUtf8().data());
+ dbg(lvl_debug, "No matching font. Resort to: %s", font_priv->font->family().toUtf8().data());
}
/* No clue why factor 20. Found this by comparing to Freetype rendering. */
@@ -224,25 +217,19 @@ static struct graphics_font_priv* font_new(struct graphics_priv* gr, struct grap
return font_priv;
}
-static void
-gc_destroy(struct graphics_gc_priv* gc)
-{
- // dbg(lvl_debug,"enter gc=%p\n", gc);
+static void gc_destroy(struct graphics_gc_priv* gc) {
+ // dbg(lvl_debug,"enter gc=%p", gc);
delete (gc->pen);
delete (gc->brush);
g_free(gc);
}
-static void
-gc_set_linewidth(struct graphics_gc_priv* gc, int w)
-{
- // dbg(lvl_debug,"enter gc=%p, %d\n", gc, w);
+static void gc_set_linewidth(struct graphics_gc_priv* gc, int w) {
+ // dbg(lvl_debug,"enter gc=%p, %d", gc, w);
gc->pen->setWidth(w);
}
-static void
-gc_set_dashes(struct graphics_gc_priv* gc, int w, int offset, unsigned char* dash_list, int n)
-{
+static void gc_set_dashes(struct graphics_gc_priv* gc, int w, int offset, unsigned char* dash_list, int n) {
if (n <= 0) {
dbg(lvl_error, "Refuse to set dashes without dash pattern");
}
@@ -262,21 +249,17 @@ gc_set_dashes(struct graphics_gc_priv* gc, int w, int offset, unsigned char* das
gc->pen->setDashPattern(dashes);
}
-static void
-gc_set_foreground(struct graphics_gc_priv* gc, struct color* c)
-{
+static void gc_set_foreground(struct graphics_gc_priv* gc, struct color* c) {
QColor col(c->r >> 8, c->g >> 8, c->b >> 8, c->a >> 8);
- // dbg(lvl_debug,"context %p: color %02x%02x%02x\n",gc, c->r >> 8, c->g >> 8, c->b >> 8);
+ // dbg(lvl_debug,"context %p: color %02x%02x%02x",gc, c->r >> 8, c->g >> 8, c->b >> 8);
gc->pen->setColor(col);
gc->brush->setColor(col);
//gc->c=*c;
}
-static void
-gc_set_background(struct graphics_gc_priv* gc, struct color* c)
-{
+static void gc_set_background(struct graphics_gc_priv* gc, struct color* c) {
QColor col(c->r >> 8, c->g >> 8, c->b >> 8, c->a >> 8);
- // dbg(lvl_debug,"context %p: color %02x%02x%02x\n",gc, c->r >> 8, c->g >> 8, c->b >> 8);
+ // dbg(lvl_debug,"context %p: color %02x%02x%02x",gc, c->r >> 8, c->g >> 8, c->b >> 8);
//gc->pen->setColor(col);
//gc->brush->setColor(col);
}
@@ -289,10 +272,9 @@ static struct graphics_gc_methods gc_methods = {
gc_set_background
};
-static struct graphics_gc_priv* gc_new(struct graphics_priv* gr, struct graphics_gc_methods* meth)
-{
+static struct graphics_gc_priv* gc_new(struct graphics_priv* gr, struct graphics_gc_methods* meth) {
struct graphics_gc_priv* graphics_gc_priv = NULL;
- // dbg(lvl_debug,"enter gr==%p\n", gr);
+ // dbg(lvl_debug,"enter gr==%p", gr);
graphics_gc_priv = g_new0(struct graphics_gc_priv, 1);
graphics_gc_priv->graphics_priv = gr;
graphics_gc_priv->pen = new QPen();
@@ -302,9 +284,8 @@ static struct graphics_gc_priv* gc_new(struct graphics_priv* gr, struct graphics
return graphics_gc_priv;
}
-static void image_destroy(struct graphics_image_priv* img)
-{
- // dbg(lvl_debug, "enter\n");
+static void image_destroy(struct graphics_image_priv* img) {
+ // dbg(lvl_debug, "enter");
if (img->pixmap != NULL)
delete (img->pixmap);
g_free(img);
@@ -314,18 +295,21 @@ struct graphics_image_methods image_methods = {
image_destroy
};
-static struct graphics_image_priv*
-image_new(struct graphics_priv* gr, struct graphics_image_methods* meth, char* path, int* w, int* h, struct point* hot, int rotation)
-{
+static struct graphics_image_priv* image_new(struct graphics_priv* gr, struct graphics_image_methods* meth, char* path,
+ int* w, int* h, struct point* hot, int rotation) {
struct graphics_image_priv* image_priv;
- // dbg(lvl_debug,"enter %s, %d %d\n", path, *w, *h);
+ // dbg(lvl_debug,"enter %s, %d %d", path, *w, *h);
if (path[0] == 0) {
- dbg(lvl_debug, "Refuse to load image without path\n");
+ dbg(lvl_debug, "Refuse to load image without path");
return NULL;
}
QString key(path);
QString renderer_key(key);
- QString extension = key.right(key.lastIndexOf("."));
+ int index = key.lastIndexOf(".");
+ QString extension;
+ if(index > 0) {
+ extension = key.right(index);
+ }
QFile imagefile(key);
if (!imagefile.exists()) {
/* file doesn't exit. Either navit wants us to guess file name by
@@ -333,11 +317,11 @@ image_new(struct graphics_priv* gr, struct graphics_image_methods* meth, char* p
*/
if (extension != "") {
/*file doesn't exist. give up */
- dbg(lvl_debug, "File %s does not exist\n", path);
+ dbg(lvl_debug, "File %s does not exist", path);
return NULL;
} else {
/* add ".svg" for renderer to try .svg file first in renderer */
- dbg(lvl_debug, "Guess extension on %s\n", path);
+ dbg(lvl_debug, "Guess extension on %s", path);
renderer_key += ".svg";
}
}
@@ -348,7 +332,7 @@ image_new(struct graphics_priv* gr, struct graphics_image_methods* meth, char* p
if (renderer_key.endsWith("svg")) {
QSvgRenderer renderer(renderer_key);
if (renderer.isValid()) {
- dbg(lvl_debug, "render %s\n", path);
+ dbg(lvl_debug, "render %s", path);
/* try to render this */
/* assume "standard" size if size is not given */
if (*w <= 0)
@@ -364,19 +348,20 @@ image_new(struct graphics_priv* gr, struct graphics_image_methods* meth, char* p
if (image_priv->pixmap == NULL) {
/*cannot be rendered. try to load it */
- dbg(lvl_debug, "cannot render %s\n", path);
+ dbg(lvl_debug, "cannot render %s", path);
image_priv->pixmap = new QPixmap(key);
}
/* check if we got image */
- if (image_priv->pixmap->isNull()) {
+ if ((image_priv->pixmap == NULL) || (image_priv->pixmap->isNull())) {
g_free(image_priv);
return NULL;
} else {
/* check if we need to scale this */
if ((*w > 0) && (*h > 0)) {
if ((image_priv->pixmap->width() != *w) || (image_priv->pixmap->height() != *h)) {
- dbg(lvl_debug, "scale pixmap %s, %d->%d,%d->%d\n", path, image_priv->pixmap->width(), *w, image_priv->pixmap->height(), *h);
+ dbg(lvl_debug, "scale pixmap %s, %d->%d,%d->%d", path, image_priv->pixmap->width(), *w, image_priv->pixmap->height(),
+ *h);
QPixmap* scaled = new QPixmap(image_priv->pixmap->scaled(*w, *h, Qt::IgnoreAspectRatio, Qt::FastTransformation));
delete (image_priv->pixmap);
image_priv->pixmap = scaled;
@@ -386,7 +371,7 @@ image_new(struct graphics_priv* gr, struct graphics_image_methods* meth, char* p
*w = image_priv->pixmap->width();
*h = image_priv->pixmap->height();
- // dbg(lvl_debug, "Got (%d,%d)\n", *w,*h);
+ // dbg(lvl_debug, "Got (%d,%d)", *w,*h);
if (hot) {
hot->x = *w / 2;
hot->y = *h / 2;
@@ -395,12 +380,10 @@ image_new(struct graphics_priv* gr, struct graphics_image_methods* meth, char* p
return image_priv;
}
-static void
-draw_lines(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point* p, int count)
-{
+static void draw_lines(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point* p, int count) {
int i;
QPolygon polygon;
- // dbg(lvl_debug,"enter gr=%p, gc=%p, (%d, %d)\n", gr, gc, p->x, p->y);
+ // dbg(lvl_debug,"enter gr=%p, gc=%p, (%d, %d)", gr, gc, p->x, p->y);
if (gr->painter == NULL)
return;
@@ -410,12 +393,10 @@ draw_lines(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point*
gr->painter->drawPolyline(polygon);
}
-static void
-draw_polygon(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point* p, int count)
-{
+static void draw_polygon(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point* p, int count) {
int i;
QPolygon polygon;
- // dbg(lvl_debug,"enter gr=%p, gc=%p, (%d, %d)\n", gr, gc, p->x, p->y);
+ // dbg(lvl_debug,"enter gr=%p, gc=%p, (%d, %d)", gr, gc, p->x, p->y);
if (gr->painter == NULL)
return;
@@ -433,10 +414,8 @@ draw_polygon(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point
gr->painter->drawPolygon(polygon);
}
-static void
-draw_rectangle(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point* p, int w, int h)
-{
- // dbg(lvl_debug,"gr=%p gc=%p %d,%d,%d,%d\n", gr, gc, p->x, p->y, w, h);
+static void draw_rectangle(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point* p, int w, int h) {
+ // dbg(lvl_debug,"gr=%p gc=%p %d,%d,%d,%d", gr, gc, p->x, p->y, w, h);
if (gr->painter == NULL)
return;
/* if the rectangle is transparent, we need to clear it first */
@@ -449,10 +428,8 @@ draw_rectangle(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct poi
gr->painter->fillRect(p->x, p->y, w, h, *gc->brush);
}
-static void
-draw_circle(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point* p, int r)
-{
- // dbg(lvl_debug,"enter gr=%p, gc=%p, (%d,%d) r=%d\n", gr, gc, p->x, p->y, r);
+static void draw_circle(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point* p, int r) {
+ // dbg(lvl_debug,"enter gr=%p, gc=%p, (%d,%d) r=%d", gr, gc, p->x, p->y, r);
if (gr->painter == NULL)
return;
gr->painter->setPen(*gc->pen);
@@ -472,10 +449,9 @@ draw_circle(struct graphics_priv* gr, struct graphics_gc_priv* gc, struct point*
*
* Renders given text on gr surface. Draws nice contrast outline around text.
*/
-static void
-draw_text(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct graphics_gc_priv* bg, struct graphics_font_priv* font, char* text, struct point* p, int dx, int dy)
-{
- dbg(lvl_debug, "enter gc=%p, fg=%p, bg=%p pos(%d,%d) d(%d, %d) %s\n", gr, fg, bg, p->x, p->y, dx, dy, text);
+static void draw_text(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct graphics_gc_priv* bg,
+ struct graphics_font_priv* font, char* text, struct point* p, int dx, int dy) {
+ dbg(lvl_debug, "enter gc=%p, fg=%p, bg=%p pos(%d,%d) d(%d, %d) %s", gr, fg, bg, p->x, p->y, dx, dy, text);
QPainter* painter = gr->painter;
if (painter == NULL)
return;
@@ -565,14 +541,13 @@ draw_text(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct graphics
#endif
}
-static void
-draw_image(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct point* p, struct graphics_image_priv* img)
-{
- // dbg(lvl_debug,"enter\n");
+static void draw_image(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct point* p,
+ struct graphics_image_priv* img) {
+ // dbg(lvl_debug,"enter");
if (gr->painter != NULL)
gr->painter->drawPixmap(p->x, p->y, *img->pixmap);
else
- dbg(lvl_debug, "Try to draw image, but no painter\n");
+ dbg(lvl_debug, "Try to draw image, but no painter");
}
/**
@@ -584,15 +559,14 @@ draw_image(struct graphics_priv* gr, struct graphics_gc_priv* fg, struct point*
* called for root layer. There the content of the root layer is to be moved
* by given vector. On root layer, NULL indicates the end of a drag.
*/
-static void draw_drag(struct graphics_priv* gr, struct point* p)
-{
+static void draw_drag(struct graphics_priv* gr, struct point* p) {
struct point vector;
if (p != NULL) {
- dbg(lvl_debug, "enter %p (%d,%d)\n", gr, p->x, p->y);
+ dbg(lvl_debug, "enter %p (%d,%d)", gr, p->x, p->y);
vector = *p;
} else {
- dbg(lvl_debug, "enter %p (NULL)\n", gr);
+ dbg(lvl_debug, "enter %p (NULL)", gr);
vector.x = 0;
vector.y = 0;
}
@@ -621,38 +595,34 @@ static void draw_drag(struct graphics_priv* gr, struct point* p)
}
}
-static void
-background_gc(struct graphics_priv* gr, struct graphics_gc_priv* gc)
-{
- // dbg(lvl_debug,"register context %p on %p\n", gc, gr);
+static void background_gc(struct graphics_priv* gr, struct graphics_gc_priv* gc) {
+ // dbg(lvl_debug,"register context %p on %p", gc, gr);
gr->background_graphics_gc_priv = gc;
}
-static void
-draw_mode(struct graphics_priv* gr, enum draw_mode_num mode)
-{
+static void draw_mode(struct graphics_priv* gr, enum draw_mode_num mode) {
switch (mode) {
case draw_mode_begin:
- dbg(lvl_debug, "Begin drawing on context %p (use == %d)\n", gr, gr->use_count);
+ dbg(lvl_debug, "Begin drawing on context %p (use == %d)", gr, gr->use_count);
gr->use_count++;
if (gr->painter == NULL)
gr->painter = new QPainter(gr->pixmap);
else
- dbg(lvl_debug, "drawing on %p already active\n", gr);
+ dbg(lvl_debug, "drawing on %p already active", gr);
break;
case draw_mode_end:
- dbg(lvl_debug, "End drawing on context %p (use == %d)\n", gr, gr->use_count);
+ dbg(lvl_debug, "End drawing on context %p (use == %d)", gr, gr->use_count);
gr->use_count--;
if (gr->use_count < 0)
gr->use_count = 0;
if (gr->use_count > 0) {
- dbg(lvl_debug, "drawing on %p still in use\n", gr);
+ dbg(lvl_debug, "drawing on %p still in use", gr);
} else if (gr->painter != NULL) {
gr->painter->end();
delete (gr->painter);
gr->painter = NULL;
} else {
- dbg(lvl_debug, "Context %p not active!\n", gr)
+ dbg(lvl_debug, "Context %p not active!", gr)
}
#if USE_QWIDGET
/* call repaint on widget */
@@ -667,25 +637,22 @@ draw_mode(struct graphics_priv* gr, enum draw_mode_num mode)
break;
default:
- dbg(lvl_debug, "Unknown drawing %d on context %p\n", mode, gr);
+ dbg(lvl_debug, "Unknown drawing %d on context %p", mode, gr);
break;
}
}
-static struct graphics_priv* overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct point* p, int w, int h, int wraparound);
+static struct graphics_priv* overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct point* p,
+ int w, int h, int wraparound);
-void resize_callback(struct graphics_priv* gr, int w, int h)
-{
- // dbg(lvl_debug,"enter (%d, %d)\n", w, h);
- callback_list_call_attr_2(gr->callbacks, attr_resize,
- GINT_TO_POINTER(w), GINT_TO_POINTER(h));
+void resize_callback(struct graphics_priv* gr, int w, int h) {
+ // dbg(lvl_debug,"enter (%d, %d)", w, h);
+ callback_list_call_attr_2(gr->callbacks, attr_resize, GINT_TO_POINTER(w), GINT_TO_POINTER(h));
}
-static int
-graphics_qt5_fullscreen(struct window* w, int on)
-{
+static int graphics_qt5_fullscreen(struct window* w, int on) {
struct graphics_priv* gr;
- // dbg(lvl_debug,"enter\n");
+ // dbg(lvl_debug,"enter");
gr = (struct graphics_priv*)w->priv;
#if USE_QML
if (gr->window != NULL) {
@@ -707,10 +674,8 @@ graphics_qt5_fullscreen(struct window* w, int on)
}
#ifdef SAILFISH_OS
-static void
-keep_display_on(struct graphics_priv* priv)
-{
- // dbg(lvl_debug,"enter\n");
+static void keep_display_on(struct graphics_priv* priv) {
+ // dbg(lvl_debug,"enter");
QDBusConnection system = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "system");
QDBusInterface interface("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", system);
@@ -718,10 +683,8 @@ keep_display_on(struct graphics_priv* priv)
}
#endif
-static void
-graphics_qt5_disable_suspend(struct window* w)
-{
-// dbg(lvl_debug,"enter\n");
+static void graphics_qt5_disable_suspend(struct window* w) {
+// dbg(lvl_debug,"enter");
#ifdef SAILFISH_OS
struct graphics_priv* gr;
gr = (struct graphics_priv*)w->priv;
@@ -733,13 +696,11 @@ graphics_qt5_disable_suspend(struct window* w)
#endif
}
-static void*
-get_data(struct graphics_priv* this_priv, char const* type)
-{
- // dbg(lvl_debug,"enter: %s\n", type);
+static void* get_data(struct graphics_priv* this_priv, char const* type) {
+ // dbg(lvl_debug,"enter: %s", type);
if (strcmp(type, "window") == 0) {
struct window* win;
- // dbg(lvl_debug,"window detected\n");
+ // dbg(lvl_debug,"window detected");
win = g_new0(struct window, 1);
win->priv = this_priv;
win->fullscreen = graphics_qt5_fullscreen;
@@ -748,15 +709,14 @@ get_data(struct graphics_priv* this_priv, char const* type)
return win;
}
if (strcmp(type, "engine") == 0) {
- dbg(lvl_debug, "Hand over QQmlApplicationEngine\n");
+ dbg(lvl_debug, "Hand over QQmlApplicationEngine");
return (this_priv->engine);
}
return NULL;
}
-static void image_free(struct graphics_priv* gr, struct graphics_image_priv* priv)
-{
- // dbg(lvl_debug,"enter\n");
+static void image_free(struct graphics_priv* gr, struct graphics_image_priv* priv) {
+ // dbg(lvl_debug,"enter");
delete (priv->pixmap);
g_free(priv);
}
@@ -773,13 +733,13 @@ static void image_free(struct graphics_priv* gr, struct graphics_image_priv* pri
*
* Calculates the bounding box around the given text.
*/
-static void get_text_bbox(struct graphics_priv* gr, struct graphics_font_priv* font, char* text, int dx, int dy, struct point* ret, int estimate)
-{
+static void get_text_bbox(struct graphics_priv* gr, struct graphics_font_priv* font, char* text, int dx, int dy,
+ struct point* ret, int estimate) {
int i;
struct point pt;
QString tmp = QString::fromUtf8(text);
QRect r;
- // dbg(lvl_debug,"enter %s %d %d\n", text, dx, dy);
+ // dbg(lvl_debug,"enter %s %d %d", text, dx, dy);
/* use QFontMetrix for bbox calculation as we do not always have a painter */
QFontMetrics fm(*font->font);
@@ -807,32 +767,46 @@ static void get_text_bbox(struct graphics_priv* gr, struct graphics_font_priv* f
}
}
-static void overlay_disable(struct graphics_priv* gr, int disable)
-{
- GHashTableIter iter;
- struct graphics_priv *key, *value;
- // dbg(lvl_debug,"enter gr=%p, %d\n", gr, disable);
+static void overlay_disable(struct graphics_priv* gr, int disable) {
+ //dbg(lvl_error,"enter gr=%p, %d", gr, disable);
+ gr->disable = disable;
+#if USE_QWIDGET
+ /* call repaint on widget */
+ if (gr->widget != NULL)
+ gr->widget->repaint(gr->x, gr->y, gr->pixmap->width(), gr->pixmap->height());
+#endif
+#if USE_QML
+ if (gr->GPriv != NULL)
+ gr->GPriv->emit_update();
- g_hash_table_iter_init(&iter, gr->overlays);
- while (g_hash_table_iter_next(&iter, (void**)&key, (void**)&value)) {
- /* disable or enable all overlays of this pane */
- value->disable = disable;
- }
+#endif
}
-static void overlay_resize(struct graphics_priv* gr, struct point* p, int w, int h, int wraparound)
-{
- // dbg(lvl_debug,"enter\n");
+static void overlay_resize(struct graphics_priv* gr, struct point* p, int w, int h, int wraparound) {
+ // dbg(lvl_debug,"enter %d %d %d %d %d", p->x, p->y, w, h, wraparound);
gr->x = p->x;
gr->y = p->y;
if (gr->painter != NULL) {
delete (gr->painter);
}
- delete (gr->pixmap);
- gr->pixmap = new QPixmap(w, h);
- gr->pixmap->fill(Qt::transparent);
+ /* replacing the pixmap clears the content. Only neccesary if size actually changes */
+ if((gr->pixmap->height() != h) || (gr->pixmap->width() != w)) {
+ delete (gr->pixmap);
+ gr->pixmap = new QPixmap(w, h);
+ gr->pixmap->fill(Qt::transparent);
+ }
if (gr->painter != NULL)
gr->painter = new QPainter(gr->pixmap);
+#if USE_QWIDGET
+ /* call repaint on widget */
+ if (gr->widget != NULL)
+ gr->widget->repaint(gr->x, gr->y, gr->pixmap->width(), gr->pixmap->height());
+#endif
+#if USE_QML
+ if (gr->GPriv != NULL)
+ gr->GPriv->emit_update();
+
+#endif
}
static struct graphics_methods graphics_methods = {
@@ -859,9 +833,8 @@ static struct graphics_methods graphics_methods = {
};
/* create new graphics context on given context */
-static struct graphics_priv*
-overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct point* p, int w, int h, int wraparound)
-{
+static struct graphics_priv* overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct point* p,
+ int w, int h, int wraparound) {
struct graphics_priv* graphics_priv = NULL;
graphics_priv = g_new0(struct graphics_priv, 1);
*meth = graphics_methods;
@@ -869,8 +842,10 @@ overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct poin
if (gr->font_freetype_new) {
graphics_priv->font_freetype_new = gr->font_freetype_new;
gr->font_freetype_new(&graphics_priv->freetype_methods);
- meth->font_new = (struct graphics_font_priv * (*)(struct graphics_priv*, struct graphics_font_methods*, char*, int, int))graphics_priv->freetype_methods.font_new;
- meth->get_text_bbox = (void (*)(struct graphics_priv*, struct graphics_font_priv*, char*, int, int, struct point*, int))graphics_priv->freetype_methods.get_text_bbox;
+ meth->font_new = (struct graphics_font_priv * (*)(struct graphics_priv*, struct graphics_font_methods*, char*, int,
+ int))graphics_priv->freetype_methods.font_new;
+ meth->get_text_bbox = (void (*)(struct graphics_priv*, struct graphics_font_priv*, char*, int, int, struct point*,
+ int))graphics_priv->freetype_methods.get_text_bbox;
}
#endif
#if USE_QML
@@ -897,15 +872,14 @@ overlay_new(struct graphics_priv* gr, struct graphics_methods* meth, struct poin
graphics_priv->argv[0] = NULL;
/* register on parent */
g_hash_table_insert(gr->overlays, graphics_priv, graphics_priv);
- // dbg(lvl_debug,"New overlay: %p\n", graphics_priv);
+ // dbg(lvl_debug,"New overlay: %p", graphics_priv);
return graphics_priv;
}
/* create application and initial graphics context */
-static struct graphics_priv*
-graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr** attrs, struct callback_list* cbl)
-{
+static struct graphics_priv* graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr** attrs,
+ struct callback_list* cbl) {
struct graphics_priv* graphics_priv = NULL;
struct attr* event_loop_system = NULL;
struct attr* platform = NULL;
@@ -914,7 +888,7 @@ graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr**
bool use_qml = USE_QML;
bool use_qwidget = USE_QWIDGET;
- //dbg(lvl_debug,"enter\n");
+ //dbg(lvl_debug,"enter");
/* get qt widget attr */
if ((attr_widget = attr_search(attrs, NULL, attr_qt5_widget))) {
@@ -938,7 +912,7 @@ graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr**
/* get event loop from config and request event loop*/
event_loop_system = attr_search(attrs, NULL, attr_event_loop_system);
if (event_loop_system && event_loop_system->u.str) {
- //dbg(lvl_debug, "event_system is %s\n", event_loop_system->u.str);
+ //dbg(lvl_debug, "event_system is %s", event_loop_system->u.str);
if (!event_request_system(event_loop_system->u.str, "graphics_qt5"))
return NULL;
} else {
@@ -952,7 +926,7 @@ graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr**
/* get font plugin if present */
font_freetype_new = (struct font_priv * (*)(void*))plugin_get_category_font("freetype");
if (!font_freetype_new) {
- dbg(lvl_error, "no freetype\n");
+ dbg(lvl_error, "no freetype");
return NULL;
}
#endif
@@ -971,7 +945,7 @@ graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr**
graphics_priv->argv[graphics_priv->argc] = g_strdup(platform->u.str);
graphics_priv->argc++;
}
-/* create surrounding application */
+ /* create surrounding application */
#if USE_QWIDGET
QApplication* internal_app = new QApplication(graphics_priv->argc, graphics_priv->argv);
navit_app = internal_app;
@@ -982,8 +956,10 @@ graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr**
#if HAVE_FREETYPE
graphics_priv->font_freetype_new = font_freetype_new;
font_freetype_new(&graphics_priv->freetype_methods);
- meth->font_new = (struct graphics_font_priv * (*)(struct graphics_priv*, struct graphics_font_methods*, char*, int, int))graphics_priv->freetype_methods.font_new;
- meth->get_text_bbox = (void (*)(struct graphics_priv*, struct graphics_font_priv*, char*, int, int, struct point*, int))graphics_priv->freetype_methods.get_text_bbox;
+ meth->font_new = (struct graphics_font_priv * (*)(struct graphics_priv*, struct graphics_font_methods*, char*, int,
+ int))graphics_priv->freetype_methods.font_new;
+ meth->get_text_bbox = (void (*)(struct graphics_priv*, struct graphics_font_priv*, char*, int, int, struct point*,
+ int))graphics_priv->freetype_methods.get_text_bbox;
#endif
graphics_priv->callbacks = cbl;
graphics_priv->pixmap = NULL;
@@ -1004,7 +980,7 @@ graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr**
/* register our QtQuick widget to allow it's usage within QML */
qmlRegisterType<QNavitQuick>("com.navit.graphics_qt5", 1, 0, "QNavitQuick");
/* get our qml application from embedded resources. May be replaced by the
- * QtQuick gui component if enabled */
+ * QtQuick gui component if enabled */
graphics_priv->engine = new QQmlApplicationEngine();
if (graphics_priv->engine != NULL) {
graphics_priv->GPriv = new GraphicsPriv(graphics_priv);
@@ -1024,7 +1000,7 @@ graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr**
}
#endif
if ((fullscreen = attr_search(attrs, NULL, attr_fullscreen)) && (fullscreen->u.num)) {
-/* show this maximized */
+ /* show this maximized */
#if USE_QML
if (graphics_priv->window != NULL)
graphics_priv->window->setWindowState(Qt::WindowFullScreen);
@@ -1083,7 +1059,7 @@ graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr**
/* tell Navit our geometry */
resize_callback(graphics_priv, graphics_priv->pixmap->width(), graphics_priv->pixmap->height());
-/* show our window */
+ /* show our window */
#if USE_QML
if (graphics_priv->window != NULL)
graphics_priv->window->show();
@@ -1096,12 +1072,11 @@ graphics_qt5_new(struct navit* nav, struct graphics_methods* meth, struct attr**
return graphics_priv;
}
-void plugin_init(void)
-{
+void plugin_init(void) {
#if USE_QML
Q_INIT_RESOURCE(graphics_qt5);
#endif
- // dbg(lvl_debug,"enter\n");
+ // dbg(lvl_debug,"enter");
plugin_register_category_graphics("qt5", graphics_qt5_new);
qt5_event_init();
}
diff --git a/navit/graphics/qt5/graphics_qt5.h b/navit/graphics/qt5/graphics_qt5.h
index f9d19616b..0eed89510 100644
--- a/navit/graphics/qt5/graphics_qt5.h
+++ b/navit/graphics/qt5/graphics_qt5.h
@@ -16,7 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-// style with: clang-format -style=WebKit -i *
#ifndef __graphics_qt_h
#define __graphics_qt_h
@@ -62,8 +61,7 @@ struct graphics_priv;
#if USE_QML
class GraphicsPriv : public QObject {
Q_OBJECT
-public:
- GraphicsPriv(struct graphics_priv* gp);
+public: GraphicsPriv(struct graphics_priv* gp);
~GraphicsPriv();
void emit_update();
diff --git a/navit/graphics/qt5/loader.qml b/navit/graphics/qt5/loader.qml
index 9882cb23a..29dcb7832 100644
--- a/navit/graphics/qt5/loader.qml
+++ b/navit/graphics/qt5/loader.qml
@@ -4,7 +4,7 @@ import QtQuick.Window 2.0
Window {
width: 200; height: 200
-
+
Item {
id: root
anchors.fill: parent
diff --git a/navit/graphics/qt_qpainter/RenderArea.cpp b/navit/graphics/qt_qpainter/RenderArea.cpp
index 1159082ed..76f8f198f 100644
--- a/navit/graphics/qt_qpainter/RenderArea.cpp
+++ b/navit/graphics/qt_qpainter/RenderArea.cpp
@@ -22,19 +22,18 @@
#include "RenderArea.moc"
#ifdef QT_QPAINTER_USE_EMBEDDING
-EmbeddedWidget::EmbeddedWidget(struct graphics_priv *priv, QWidget* child, QWidget *parent)
-: QX11EmbedWidget(parent) {
+EmbeddedWidget::EmbeddedWidget(struct graphics_priv *priv, QWidget* child, QWidget *parent)
+ : QX11EmbedWidget(parent) {
this->gra=priv;
- this->setWindowTitle(priv->window_title);
- QStackedLayout* _outerLayout = new QStackedLayout(this);
- this->setLayout(_outerLayout);
- _outerLayout->addWidget(child);
- _outerLayout->setCurrentWidget(child);
+ this->setWindowTitle(priv->window_title);
+ QStackedLayout* _outerLayout = new QStackedLayout(this);
+ this->setLayout(_outerLayout);
+ _outerLayout->addWidget(child);
+ _outerLayout->setCurrentWidget(child);
}
-void EmbeddedWidget::closeEvent(QCloseEvent* event)
-{
- gra->widget->processClose();
+void EmbeddedWidget::closeEvent(QCloseEvent* event) {
+ gra->widget->processClose();
}
#endif /* QT_QPAINTER_USE_EMBEDDING */
@@ -44,27 +43,26 @@ void EmbeddedWidget::closeEvent(QCloseEvent* event)
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
RenderArea::RenderArea(struct graphics_priv *priv, QT_QPAINTER_RENDERAREA_PARENT *parent, int w, int h, int overlay)
- : QT_QPAINTER_RENDERAREA_PARENT(parent)
-{
- pixmap = new QPixmap(w, h);
+ : QT_QPAINTER_RENDERAREA_PARENT(parent) {
+ pixmap = new QPixmap(w, h);
#ifndef QT_QPAINTER_NO_WIDGET
- if (!overlay) {
-#if QT_VERSION >= 0x040700
- grabGesture(Qt::PinchGesture);
- grabGesture(Qt::SwipeGesture);
- grabGesture(Qt::PanGesture);
+ if (!overlay) {
+#if QT_VERSION >= 0x040700
+ grabGesture(Qt::PinchGesture);
+ grabGesture(Qt::SwipeGesture);
+ grabGesture(Qt::PanGesture);
#endif
- setWindowTitle(priv->window_title);
- }
+ setWindowTitle(priv->window_title);
+ }
#endif
- is_overlay=overlay;
- gra=priv;
+ is_overlay=overlay;
+ gra=priv;
#ifdef QT_QPAINTER_USE_EVENT_QT
- timer_type=g_hash_table_new(NULL, NULL);
- timer_callback=g_hash_table_new(NULL, NULL);
- watches=g_hash_table_new(NULL, NULL);
+ timer_type=g_hash_table_new(NULL, NULL);
+ timer_callback=g_hash_table_new(NULL, NULL);
+ watches=g_hash_table_new(NULL, NULL);
#ifndef QT_QPAINTER_NO_WIDGET
- setAttribute(Qt::WA_OpaquePaintEvent, true);
+ setAttribute(Qt::WA_OpaquePaintEvent, true);
#endif
#endif
}
@@ -73,33 +71,29 @@ RenderArea::RenderArea(struct graphics_priv *priv, QT_QPAINTER_RENDERAREA_PARENT
//# Description: QWidget:closeEvent
//# Comment: Deletes navit object and stops event loop on graphics shutdown
//##############################################################################################################
-void RenderArea::processClose()
-{
- callback_list_call_attr_0(this->cbl, attr_window_closed);
+void RenderArea::processClose() {
+ callback_list_call_attr_0(this->cbl, attr_window_closed);
}
-void RenderArea::closeEvent(QCloseEvent* event)
-{
- this->processClose();
+void RenderArea::closeEvent(QCloseEvent* event) {
+ this->processClose();
}
-bool RenderArea::event(QEvent *event)
-{
-#if QT_VERSION >= 0x040700
- if (event->type() == QEvent::Gesture) {
- dbg(lvl_debug,"gesture\n");
- return true;
- }
+bool RenderArea::event(QEvent *event) {
+#if QT_VERSION >= 0x040700
+ if (event->type() == QEvent::Gesture) {
+ dbg(lvl_debug,"gesture");
+ return true;
+ }
#endif
- return QWidget::event(event);
+ return QWidget::event(event);
}
//##############################################################################################################
//# Description: QWidget:sizeHint
//# Comment: This property holds the recommended size for the widget
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-QSize RenderArea::sizeHint() const
-{
- return QSize(gra->w, gra->h);
+QSize RenderArea::sizeHint() const {
+ return QSize(gra->w, gra->h);
}
//##############################################################################################################
@@ -107,25 +101,23 @@ QSize RenderArea::sizeHint() const
//# Comment: A paint event is a request to repaint all or part of the widget.
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void RenderArea::paintEvent(QPaintEvent * event)
-{
- qt_qpainter_draw(gra, &event->rect(), 1);
+void RenderArea::paintEvent(QPaintEvent * event) {
+ qt_qpainter_draw(gra, &event->rect(), 1);
}
-void RenderArea::do_resize(QSize size)
-{
+void RenderArea::do_resize(QSize size) {
if (pixmap->paintingActive()) {
pixmap->paintEngine()->painter()->end();
}
- delete pixmap;
- pixmap=new QPixmap(size);
- pixmap->fill();
+ delete pixmap;
+ pixmap=new QPixmap(size);
+ pixmap->fill();
QPainter painter(pixmap);
QBrush brush;
- painter.fillRect(0, 0, size.width(), size.height(), brush);
- dbg(lvl_debug,"size %dx%d\n", size.width(), size.height());
- dbg(lvl_debug,"pixmap %p %dx%d\n", pixmap, pixmap->width(), pixmap->height());
- callback_list_call_attr_2(this->cbl, attr_resize, GINT_TO_POINTER(size.width()), GINT_TO_POINTER(size.height()));
+ painter.fillRect(0, 0, size.width(), size.height(), brush);
+ dbg(lvl_debug,"size %dx%d", size.width(), size.height());
+ dbg(lvl_debug,"pixmap %p %dx%d", pixmap, pixmap->width(), pixmap->height());
+ callback_list_call_attr_2(this->cbl, attr_resize, GINT_TO_POINTER(size.width()), GINT_TO_POINTER(size.height()));
}
//##############################################################################################################
@@ -133,11 +125,10 @@ void RenderArea::do_resize(QSize size)
//# Comment: When resizeEvent() is called, the widget already has its new geometry.
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void RenderArea::resizeEvent(QResizeEvent * event)
-{
- if (!this->is_overlay) {
- RenderArea::do_resize(event->size());
- }
+void RenderArea::resizeEvent(QResizeEvent * event) {
+ if (!this->is_overlay) {
+ RenderArea::do_resize(event->size());
+ }
}
//##############################################################################################################
@@ -145,34 +136,31 @@ void RenderArea::resizeEvent(QResizeEvent * event)
//# Comment: Delegate of QWidget::mousePressEvent and QWidget::mouseReleaseEvent (see below)
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void RenderArea::mouseEvent(int pressed, QMouseEvent *event)
-{
- struct point p;
- p.x=event->x();
- p.y=event->y();
- switch (event->button()) {
- case Qt::LeftButton:
- callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(1), GINT_TO_POINTER(&p));
- break;
- case Qt::MidButton:
- callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(2), GINT_TO_POINTER(&p));
- break;
- case Qt::RightButton:
- callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(3), GINT_TO_POINTER(&p));
- break;
- default:
- break;
- }
+void RenderArea::mouseEvent(int pressed, QMouseEvent *event) {
+ struct point p;
+ p.x=event->x();
+ p.y=event->y();
+ switch (event->button()) {
+ case Qt::LeftButton:
+ callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(1), GINT_TO_POINTER(&p));
+ break;
+ case Qt::MidButton:
+ callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(2), GINT_TO_POINTER(&p));
+ break;
+ case Qt::RightButton:
+ callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(pressed), GINT_TO_POINTER(3), GINT_TO_POINTER(&p));
+ break;
+ default:
+ break;
+ }
}
-void RenderArea::mousePressEvent(QMouseEvent *event)
-{
- mouseEvent(1, event);
+void RenderArea::mousePressEvent(QMouseEvent *event) {
+ mouseEvent(1, event);
}
-void RenderArea::mouseReleaseEvent(QMouseEvent *event)
-{
- mouseEvent(0, event);
+void RenderArea::mouseReleaseEvent(QMouseEvent *event) {
+ mouseEvent(0, event);
}
//##############################################################################################################
@@ -180,12 +168,11 @@ void RenderArea::mouseReleaseEvent(QMouseEvent *event)
//# Comment: If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void RenderArea::mouseMoveEvent(QMouseEvent *event)
-{
- struct point p;
- p.x=event->x();
- p.y=event->y();
- callback_list_call_attr_1(this->cbl, attr_motion, (void *)&p);
+void RenderArea::mouseMoveEvent(QMouseEvent *event) {
+ struct point p;
+ p.x=event->x();
+ p.y=event->y();
+ callback_list_call_attr_1(this->cbl, attr_motion, (void *)&p);
}
@@ -194,114 +181,109 @@ void RenderArea::mouseMoveEvent(QMouseEvent *event)
//# Comment:
//# Authors: Stefan Klumpp (04/2008)
//##############################################################################################################
-void RenderArea::wheelEvent(QWheelEvent *event)
-{
- struct point p;
- int button;
-
- p.x=event->x(); // xy-coordinates of the mouse pointer
- p.y=event->y();
-
- if (event->delta() > 0) // wheel movement away from the person
- button=4;
- else if (event->delta() < 0) // wheel movement towards the person
- button=5;
- else
- button=-1;
-
- if (button != -1) {
- callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button), GINT_TO_POINTER(&p));
- callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button), GINT_TO_POINTER(&p));
- }
-
- event->accept();
+void RenderArea::wheelEvent(QWheelEvent *event) {
+ struct point p;
+ int button;
+
+ p.x=event->x(); // xy-coordinates of the mouse pointer
+ p.y=event->y();
+
+ if (event->delta() > 0) // wheel movement away from the person
+ button=4;
+ else if (event->delta() < 0) // wheel movement towards the person
+ button=5;
+ else
+ button=-1;
+
+ if (button != -1) {
+ callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER(button), GINT_TO_POINTER(&p));
+ callback_list_call_attr_3(this->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(button), GINT_TO_POINTER(&p));
+ }
+
+ event->accept();
}
#define CASE(x) case x:
-void RenderArea::keyPressEvent(QKeyEvent *event)
-{
- QString str=event->text();
- const char *text=str.toUtf8().constData();
- dbg(lvl_debug,"enter text='%s' 0x%x (%zu) key=%d\n", text, text[0], strlen(text), event->key());
- if (!text || !text[0] || text[0] == 0x7f) {
- dbg(lvl_debug,"special key\n");
- switch (event->key()) {
- case 4099:
- {
- char text_backspace[] = {NAVIT_KEY_BACKSPACE,'\0'};
- text=text_backspace;
- }
- break;
- case 4101:
+void RenderArea::keyPressEvent(QKeyEvent *event) {
+ QString str=event->text();
+ const char *text=str.toUtf8().constData();
+ dbg(lvl_debug,"enter text='%s' 0x%x (%zu) key=%d", text, text[0], strlen(text), event->key());
+ if (!text || !text[0] || text[0] == 0x7f) {
+ dbg(lvl_debug,"special key");
+ switch (event->key()) {
+ case 4099: {
+ char text_backspace[] = {NAVIT_KEY_BACKSPACE,'\0'};
+ text=text_backspace;
+ }
+ break;
+ case 4101:
#ifdef QT_QPAINTER_CUSTOM_RETURN
- QT_QPAINTER_CUSTOM_RETURN
+ QT_QPAINTER_CUSTOM_RETURN
#endif
- {
- char text_return[] = {NAVIT_KEY_RETURN,'\0'};
- text=text_return;
- }
- break;
- case 4114:
+ {
+ char text_return[] = {NAVIT_KEY_RETURN,'\0'};
+ text=text_return;
+ }
+ break;
+ case 4114:
#ifdef QT_QPAINTER_CUSTOM_LEFT
- QT_QPAINTER_CUSTOM_LEFT
+ QT_QPAINTER_CUSTOM_LEFT
#endif
- {
- char text_left[] = {NAVIT_KEY_LEFT,'\0'};
- text=text_left;
- }
- break;
- case 4115:
+ {
+ char text_left[] = {NAVIT_KEY_LEFT,'\0'};
+ text=text_left;
+ }
+ break;
+ case 4115:
#ifdef QT_QPAINTER_CUSTOM_UP
- QT_QPAINTER_CUSTOM_UP
+ QT_QPAINTER_CUSTOM_UP
#endif
- {
- char text_up[] = {NAVIT_KEY_UP,'\0'};
- text=text_up;
- }
- break;
- case 4116:
+ {
+ char text_up[] = {NAVIT_KEY_UP,'\0'};
+ text=text_up;
+ }
+ break;
+ case 4116:
#ifdef QT_QPAINTER_CUSTOM_RIGHT
- QT_QPAINTER_CUSTOM_RIGHT
+ QT_QPAINTER_CUSTOM_RIGHT
#endif
- {
- char text_right[] = {NAVIT_KEY_RIGHT,'\0'};
- text=text_right;
- }
- break;
- case 4117:
+ {
+ char text_right[] = {NAVIT_KEY_RIGHT,'\0'};
+ text=text_right;
+ }
+ break;
+ case 4117:
#ifdef QT_QPAINTER_CUSTOM_DOWN
- QT_QPAINTER_CUSTOM_DOWN
+ QT_QPAINTER_CUSTOM_DOWN
#endif
- {
- char text_down[] = {NAVIT_KEY_DOWN,'\0'};
- text=text_down;
- }
- break;
- }
- }
- callback_list_call_attr_1(this->cbl, attr_keypress, (void *)text);
- event->accept();
+ {
+ char text_down[] = {NAVIT_KEY_DOWN,'\0'};
+ text=text_down;
+ }
+ break;
+ }
+ }
+ callback_list_call_attr_1(this->cbl, attr_keypress, (void *)text);
+ event->accept();
}
-void RenderArea::watchEvent(int fd)
-{
+void RenderArea::watchEvent(int fd) {
#ifdef QT_QPAINTER_USE_EVENT_QT
- struct event_watch *ev=(struct event_watch *)g_hash_table_lookup(watches, (void *)fd);
- dbg(lvl_debug,"fd=%d ev=%p cb=%p\n", fd, ev, ev->cb);
- callback_call_0(ev->cb);
+ struct event_watch *ev=(struct event_watch *)g_hash_table_lookup(watches, (void *)fd);
+ dbg(lvl_debug,"fd=%d ev=%p cb=%p", fd, ev, ev->cb);
+ callback_call_0(ev->cb);
#endif
}
#ifdef QT_QPAINTER_USE_EVENT_QT
-void RenderArea::timerEvent(QTimerEvent *event)
-{
- int id=event->timerId();
- struct callback *cb=(struct callback *)g_hash_table_lookup(timer_callback, (void *)id);
- if (cb)
- callback_call_0(cb);
- if (!g_hash_table_lookup(timer_type, (void *)id))
- event_qt_remove_timeout((struct event_timeout *)id);
+void RenderArea::timerEvent(QTimerEvent *event) {
+ int id=event->timerId();
+ struct callback *cb=(struct callback *)g_hash_table_lookup(timer_callback, (void *)id);
+ if (cb)
+ callback_call_0(cb);
+ if (!g_hash_table_lookup(timer_type, (void *)id))
+ event_qt_remove_timeout((struct event_timeout *)id);
}
#endif /* QT_QPAINTER_USE_EVENT_QT */
diff --git a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp b/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
index 65163ea9d..423f3d5fb 100644
--- a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
+++ b/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
@@ -21,7 +21,7 @@
//#
//# File: graphics_qt_qpainter.cpp
//# Description: Graphics interface for internal GUI using Qt (Trolltech.com)
-//# Comment:
+//# Comment:
//# Authors: Martin Schaller (04/2008), Stefan Klumpp (04/2008)
//#
//##############################################################################################################
@@ -31,84 +31,80 @@
#include "RenderArea.h"
//##############################################################################################################
-//# Description: RenderArea (QWidget) class for the main window (map, menu, ...)
-//# Comment:
+//# Description: RenderArea (QWidget) class for the main window (map, menu, ...)
+//# Comment:
//# Authors: Martin Schaller (04/2008), Stefan Klumpp (04/2008)
//##############################################################################################################
-static void
-overlay_rect(struct graphics_priv *parent, struct graphics_priv *overlay, int clean, QRect *r)
-{
- struct point p;
- int w,h;
- if (clean) {
- p=overlay->pclean;
- } else {
- p=overlay->p;;
- }
- w=overlay->widget->pixmap->width();
- h=overlay->widget->pixmap->height();
- if (overlay->wraparound) {
- if (p.x < 0)
- p.x+=parent->widget->pixmap->width();
- if (p.y < 0)
- p.y+=parent->widget->pixmap->height();
- if (w < 0)
- w += parent->widget->pixmap->width();
- if (h < 0)
- h += parent->widget->pixmap->height();
- }
- r->setRect(p.x, p.y, w, h);
-}
-
-void
-qt_qpainter_draw(struct graphics_priv *gr, const QRect *r, int paintev)
-{
- if (!paintev) {
+static void overlay_rect(struct graphics_priv *parent, struct graphics_priv *overlay, int clean, QRect *r) {
+ struct point p;
+ int w,h;
+ if (clean) {
+ p=overlay->pclean;
+ } else {
+ p=overlay->p;;
+ }
+ w=overlay->widget->pixmap->width();
+ h=overlay->widget->pixmap->height();
+ if (overlay->wraparound) {
+ if (p.x < 0)
+ p.x+=parent->widget->pixmap->width();
+ if (p.y < 0)
+ p.y+=parent->widget->pixmap->height();
+ if (w < 0)
+ w += parent->widget->pixmap->width();
+ if (h < 0)
+ h += parent->widget->pixmap->height();
+ }
+ r->setRect(p.x, p.y, w, h);
+}
+
+void qt_qpainter_draw(struct graphics_priv *gr, const QRect *r, int paintev) {
+ if (!paintev) {
#ifndef QT_QPAINTER_NO_WIDGET
- dbg(lvl_debug,"update %d,%d %d x %d\n", r->x(), r->y(), r->width(), r->height());
- if (r->x() <= -r->width())
- return;
- if (r->y() <= -r->height())
- return;
- if (r->x() > gr->widget->pixmap->width())
- return;
- if (r->y() > gr->widget->pixmap->height())
- return;
- dbg(lvl_debug,"update valid %d,%d %dx%d\n", r->x(), r->y(), r->width(), r->height());
- gr->widget->update(*r);
+ dbg(lvl_debug,"update %d,%d %d x %d", r->x(), r->y(), r->width(), r->height());
+ if (r->x() <= -r->width())
+ return;
+ if (r->y() <= -r->height())
+ return;
+ if (r->x() > gr->widget->pixmap->width())
+ return;
+ if (r->y() > gr->widget->pixmap->height())
+ return;
+ dbg(lvl_debug,"update valid %d,%d %dx%d", r->x(), r->y(), r->width(), r->height());
+ gr->widget->update(*r);
#endif
- return;
- }
- QPixmap pixmap(r->width(),r->height());
- QPainter painter(&pixmap);
- struct graphics_priv *overlay=NULL;
- if (! gr->overlay_disable)
- overlay=gr->overlays;
- if ((gr->p.x || gr->p.y) && gr->background_gc) {
- painter.setPen(*gr->background_gc->pen);
- painter.fillRect(0, 0, gr->widget->pixmap->width(), gr->widget->pixmap->height(), *gr->background_gc->brush);
- }
- painter.drawPixmap(QPoint(gr->p.x,gr->p.y), *gr->widget->pixmap, *r);
- while (overlay) {
- QRect ovr;
- overlay_rect(gr, overlay, 0, &ovr);
- if (!overlay->overlay_disable && r->intersects(ovr)) {
- unsigned char *data;
- int i,size=ovr.width()*ovr.height();
- QImage img=overlay->widget->pixmap->toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
- data=img.bits();
- for (i = 0 ; i < size ; i++) {
- if (data[0] == overlay->rgba[0] && data[1] == overlay->rgba[1] && data[2] == overlay->rgba[2])
- data[3]=overlay->rgba[3];
- data+=4;
- }
- painter.drawImage(QPoint(ovr.x()-r->x(),ovr.y()-r->y()), img);
- }
- overlay=overlay->next;
- }
+ return;
+ }
+ QPixmap pixmap(r->width(),r->height());
+ QPainter painter(&pixmap);
+ struct graphics_priv *overlay=NULL;
+ if (! gr->overlay_disable)
+ overlay=gr->overlays;
+ if ((gr->p.x || gr->p.y) && gr->background_gc) {
+ painter.setPen(*gr->background_gc->pen);
+ painter.fillRect(0, 0, gr->widget->pixmap->width(), gr->widget->pixmap->height(), *gr->background_gc->brush);
+ }
+ painter.drawPixmap(QPoint(gr->p.x,gr->p.y), *gr->widget->pixmap, *r);
+ while (overlay) {
+ QRect ovr;
+ overlay_rect(gr, overlay, 0, &ovr);
+ if (!overlay->overlay_disable && r->intersects(ovr)) {
+ unsigned char *data;
+ int i,size=ovr.width()*ovr.height();
+ QImage img=overlay->widget->pixmap->toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ data=img.bits();
+ for (i = 0 ; i < size ; i++) {
+ if (data[0] == overlay->rgba[0] && data[1] == overlay->rgba[1] && data[2] == overlay->rgba[2])
+ data[3]=overlay->rgba[3];
+ data+=4;
+ }
+ painter.drawImage(QPoint(ovr.x()-r->x(),ovr.y()-r->y()), img);
+ }
+ overlay=overlay->next;
+ }
#ifndef QT_QPAINTER_NO_WIDGET
- QPainter painterw(gr->widget);
- painterw.drawPixmap(r->x(), r->y(), pixmap);
+ QPainter painterw(gr->widget);
+ painterw.drawPixmap(r->x(), r->y(), pixmap);
#endif
}
@@ -120,614 +116,586 @@ qt_qpainter_draw(struct graphics_priv *gr, const QRect *r, int paintev)
//##############################################################################################################
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
struct graphics_font_priv {
- QFont *font;
+ QFont *font;
};
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
struct graphics_image_priv {
- QPixmap *pixmap;
+ QPixmap *pixmap;
};
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void graphics_destroy(struct graphics_priv *gr)
-{
+static void graphics_destroy(struct graphics_priv *gr) {
#ifdef QT_QPAINTER_USE_FREETYPE
- gr->freetype_methods.destroy();
+ gr->freetype_methods.destroy();
#endif
- g_free(gr->window_title);
- g_free(gr);
+ g_free(gr->window_title);
+ g_free(gr);
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void font_destroy(struct graphics_font_priv *font)
-{
+static void font_destroy(struct graphics_font_priv *font) {
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
static struct graphics_font_methods font_methods = {
- font_destroy
+ font_destroy
};
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size, int flags)
-{
- struct graphics_font_priv *ret=g_new0(struct graphics_font_priv, 1);
- ret->font=new QFont("Arial",size/20);
- *meth=font_methods;
- return ret;
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size, int flags) {
+ struct graphics_font_priv *ret=g_new0(struct graphics_font_priv, 1);
+ ret->font=new QFont("Arial",size/20);
+ *meth=font_methods;
+ return ret;
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gc_destroy(struct graphics_gc_priv *gc)
-{
- delete gc->pen;
- delete gc->brush;
- g_free(gc);
+static void gc_destroy(struct graphics_gc_priv *gc) {
+ delete gc->pen;
+ delete gc->brush;
+ g_free(gc);
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
- gc->pen->setWidth(w);
+static void gc_set_linewidth(struct graphics_gc_priv *gc, int w) {
+ gc->pen->setWidth(w);
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
-{
+static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n) {
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
- QColor col(c->r >> 8, c->g >> 8, c->b >> 8 /* , c->a >> 8 */);
- gc->pen->setColor(col);
- gc->brush->setColor(col);
- gc->c=*c;
+static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c) {
+ QColor col(c->r >> 8, c->g >> 8, c->b >> 8 /* , c->a >> 8 */);
+ gc->pen->setColor(col);
+ gc->brush->setColor(col);
+ gc->c=*c;
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_background(struct graphics_gc_priv *gc, struct color *c) {
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
static struct graphics_gc_methods gc_methods = {
- gc_destroy,
- gc_set_linewidth,
- gc_set_dashes,
- gc_set_foreground,
- gc_set_background
+ gc_destroy,
+ gc_set_linewidth,
+ gc_set_dashes,
+ gc_set_foreground,
+ gc_set_background
};
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
- *meth=gc_methods;
- struct graphics_gc_priv *ret=g_new0(struct graphics_gc_priv, 1);
- ret->pen=new QPen();
- ret->brush=new QBrush(Qt::SolidPattern);
- return ret;
+static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) {
+ *meth=gc_methods;
+ struct graphics_gc_priv *ret=g_new0(struct graphics_gc_priv, 1);
+ ret->pen=new QPen();
+ ret->brush=new QBrush(Qt::SolidPattern);
+ return ret;
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static struct graphics_image_priv * image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation)
-{
- struct graphics_image_priv *ret;
- QPixmap *cachedPixmap;
- QString key(path);
+static struct graphics_image_priv * image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation) {
+ struct graphics_image_priv *ret;
+ QPixmap *cachedPixmap;
+ QString key(path);
- ret=g_new0(struct graphics_image_priv, 1);
+ ret=g_new0(struct graphics_image_priv, 1);
- cachedPixmap=QPixmapCache::find(key);
- if (!cachedPixmap) {
+ cachedPixmap=QPixmapCache::find(key);
+ if (!cachedPixmap) {
#ifdef HAVE_QT_SVG
- if(key.endsWith(".svg", Qt::CaseInsensitive)) {
- QSvgRenderer renderer(key);
- if (!renderer.isValid()) {
- g_free(ret);
- return NULL;
- }
- ret->pixmap=new QPixmap(renderer.defaultSize());
- ret->pixmap->fill(Qt::transparent);
- QPainter painter(ret->pixmap);
- renderer.render(&painter);
-
- } else {
-
- ret->pixmap=new QPixmap(path);
-
- }
-#else
- ret->pixmap=new QPixmap(path);
+ if(key.endsWith(".svg", Qt::CaseInsensitive)) {
+ QSvgRenderer renderer(key);
+ if (!renderer.isValid()) {
+ g_free(ret);
+ return NULL;
+ }
+ ret->pixmap=new QPixmap(renderer.defaultSize());
+ ret->pixmap->fill(Qt::transparent);
+ QPainter painter(ret->pixmap);
+ renderer.render(&painter);
+
+ } else {
+
+ ret->pixmap=new QPixmap(path);
+
+ }
+#else
+ ret->pixmap=new QPixmap(path);
#endif /* QT__VERSION */
- if (ret->pixmap->isNull()) {
- g_free(ret);
- return NULL;
- }
-
- QPixmapCache::insert(key,QPixmap(*ret->pixmap));
- } else {
- ret->pixmap=new QPixmap(*cachedPixmap);
- }
+ if (ret->pixmap->isNull()) {
+ g_free(ret);
+ return NULL;
+ }
+
+ QPixmapCache::insert(key,QPixmap(*ret->pixmap));
+ } else {
+ ret->pixmap=new QPixmap(*cachedPixmap);
+ }
- *w=ret->pixmap->width();
- *h=ret->pixmap->height();
- if (hot) {
- hot->x=*w/2;
- hot->y=*h/2;
- }
+ *w=ret->pixmap->width();
+ *h=ret->pixmap->height();
+ if (hot) {
+ hot->x=*w/2;
+ hot->y=*h/2;
+ }
- return ret;
+ return ret;
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int i;
- QPolygon polygon;
+static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ int i;
+ QPolygon polygon;
- for (i = 0 ; i < count ; i++)
- polygon.putPoints(i, 1, p[i].x, p[i].y);
- gr->painter->setPen(*gc->pen);
- gr->painter->drawPolyline(polygon);
+ for (i = 0 ; i < count ; i++)
+ polygon.putPoints(i, 1, p[i].x, p[i].y);
+ gr->painter->setPen(*gc->pen);
+ gr->painter->drawPolyline(polygon);
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- int i;
- QPolygon polygon;
+static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ int i;
+ QPolygon polygon;
- for (i = 0 ; i < count ; i++)
- polygon.putPoints(i, 1, p[i].x, p[i].y);
- gr->painter->setPen(*gc->pen);
- gr->painter->setBrush(*gc->brush);
- gr->painter->drawPolygon(polygon);
+ for (i = 0 ; i < count ; i++)
+ polygon.putPoints(i, 1, p[i].x, p[i].y);
+ gr->painter->setPen(*gc->pen);
+ gr->painter->setBrush(*gc->brush);
+ gr->painter->drawPolygon(polygon);
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
- dbg(lvl_debug,"gr=%p gc=%p %d,%d,%d,%d\n", gr, gc, p->x, p->y, w, h);
- gr->painter->fillRect(p->x,p->y, w, h, *gc->brush);
+static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
+ dbg(lvl_debug,"gr=%p gc=%p %d,%d,%d,%d", gr, gc, p->x, p->y, w, h);
+ gr->painter->fillRect(p->x,p->y, w, h, *gc->brush);
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
- gr->painter->setPen(*gc->pen);
- gr->painter->drawArc(p->x-r/2, p->y-r/2, r, r, 0, 360*16);
-
+static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r) {
+ gr->painter->setPen(*gc->pen);
+ gr->painter->drawArc(p->x-r/2, p->y-r/2, r, r, 0, 360*16);
+
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
- QPainter *painter=gr->painter;
+static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
+ QPainter *painter=gr->painter;
#ifndef QT_QPAINTER_USE_FREETYPE
- QString tmp=QString::fromUtf8(text);
+ QString tmp=QString::fromUtf8(text);
#ifndef QT_NO_TRANSFORMATIONS
- QMatrix sav=gr->painter->worldMatrix();
- QMatrix m(dx/65535.0,dy/65535.0,-dy/65535.0,dx/65535.0,p->x,p->y);
- painter->setWorldMatrix(m,TRUE);
- painter->setPen(*fg->pen);
- painter->setFont(*font->font);
- painter->drawText(0, 0, tmp);
- painter->setWorldMatrix(sav);
+ QMatrix sav=gr->painter->worldMatrix();
+ QMatrix m(dx/65535.0,dy/65535.0,-dy/65535.0,dx/65535.0,p->x,p->y);
+ painter->setWorldMatrix(m,TRUE);
+ painter->setPen(*fg->pen);
+ painter->setFont(*font->font);
+ painter->drawText(0, 0, tmp);
+ painter->setWorldMatrix(sav);
#else
- painter->setPen(*fg->pen);
- painter->setFont(*font->font);
- painter->drawText(p->x, p->y, tmp);
+ painter->setPen(*fg->pen);
+ painter->setFont(*font->font);
+ painter->drawText(p->x, p->y, tmp);
#endif
#else
- struct font_freetype_text *t;
- struct font_freetype_glyph *g, **gp;
- struct color transparent = {0x0000, 0x0000, 0x0000, 0x0000};
- struct color *fgc=&fg->c, *bgc=&bg->c;
-
- int i,x,y;
-
- if (! font)
- return;
- t=gr->freetype_methods.text_new(text, (struct font_freetype_font *)font, dx, dy);
- x=p->x << 6;
- y=p->y << 6;
- gp=t->glyph;
- i=t->glyph_count;
- if (bg) {
- while (i-- > 0) {
- g=*gp++;
- if (g->w && g->h) {
- unsigned char *data;
- QImage img(g->w+2, g->h+2, QImage::Format_ARGB32_Premultiplied);
- data=img.bits();
- gr->freetype_methods.get_shadow(g,(unsigned char *)data,img.bytesPerLine(),bgc,&transparent);
-
- painter->drawImage(((x+g->x)>>6)-1, ((y+g->y)>>6)-1, img);
- }
- x+=g->dx;
- y+=g->dy;
- }
- } else
- bgc=&transparent;
- x=p->x << 6;
- y=p->y << 6;
- gp=t->glyph;
- i=t->glyph_count;
- while (i-- > 0) {
- g=*gp++;
- if (g->w && g->h) {
- unsigned char *data;
- QImage img(g->w, g->h, QImage::Format_ARGB32_Premultiplied);
- data=img.bits();
- gr->freetype_methods.get_glyph(g,(unsigned char *)data,img.bytesPerLine(),fgc,bgc,&transparent);
- painter->drawImage((x+g->x)>>6, (y+g->y)>>6, img);
- }
- x+=g->dx;
- y+=g->dy;
- }
- gr->freetype_methods.text_destroy(t);
+ struct font_freetype_text *t;
+ struct font_freetype_glyph *g, **gp;
+ struct color transparent = {0x0000, 0x0000, 0x0000, 0x0000};
+ struct color *fgc=&fg->c, *bgc=&bg->c;
+
+ int i,x,y;
+
+ if (! font)
+ return;
+ t=gr->freetype_methods.text_new(text, (struct font_freetype_font *)font, dx, dy);
+ x=p->x << 6;
+ y=p->y << 6;
+ gp=t->glyph;
+ i=t->glyph_count;
+ if (bg) {
+ while (i-- > 0) {
+ g=*gp++;
+ if (g->w && g->h) {
+ unsigned char *data;
+ QImage img(g->w+2, g->h+2, QImage::Format_ARGB32_Premultiplied);
+ data=img.bits();
+ gr->freetype_methods.get_shadow(g,(unsigned char *)data,img.bytesPerLine(),bgc,&transparent);
+
+ painter->drawImage(((x+g->x)>>6)-1, ((y+g->y)>>6)-1, img);
+ }
+ x+=g->dx;
+ y+=g->dy;
+ }
+ } else
+ bgc=&transparent;
+ x=p->x << 6;
+ y=p->y << 6;
+ gp=t->glyph;
+ i=t->glyph_count;
+ while (i-- > 0) {
+ g=*gp++;
+ if (g->w && g->h) {
+ unsigned char *data;
+ QImage img(g->w, g->h, QImage::Format_ARGB32_Premultiplied);
+ data=img.bits();
+ gr->freetype_methods.get_glyph(g,(unsigned char *)data,img.bytesPerLine(),fgc,bgc,&transparent);
+ painter->drawImage((x+g->x)>>6, (y+g->y)>>6, img);
+ }
+ x+=g->dx;
+ y+=g->dy;
+ }
+ gr->freetype_methods.text_destroy(t);
#endif
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
- gr->painter->drawPixmap(p->x, p->y, *img->pixmap);
+static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img) {
+ gr->painter->drawPixmap(p->x, p->y, *img->pixmap);
}
-static void
-draw_drag(struct graphics_priv *gr, struct point *p)
-{
- if (!gr->cleanup) {
- gr->pclean=gr->p;
- gr->cleanup=1;
- }
- if (p)
- gr->p=*p;
- else {
- gr->p.x=0;
- gr->p.y=0;
- }
+static void draw_drag(struct graphics_priv *gr, struct point *p) {
+ if (!gr->cleanup) {
+ gr->pclean=gr->p;
+ gr->cleanup=1;
+ }
+ if (p)
+ gr->p=*p;
+ else {
+ gr->p.x=0;
+ gr->p.y=0;
+ }
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
- gr->background_gc=gc;
- gr->rgba[2]=gc->c.r >> 8;
- gr->rgba[1]=gc->c.g >> 8;
- gr->rgba[0]=gc->c.b >> 8;
- gr->rgba[3]=gc->c.a >> 8;
+static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
+ gr->background_gc=gc;
+ gr->rgba[2]=gc->c.r >> 8;
+ gr->rgba[1]=gc->c.g >> 8;
+ gr->rgba[0]=gc->c.b >> 8;
+ gr->rgba[3]=gc->c.a >> 8;
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
- dbg(lvl_debug,"mode for %p %d\n", gr, mode);
- QRect r;
- if (mode == draw_mode_begin) {
- if (gr->widget->pixmap->paintingActive()) {
- gr->widget->pixmap->paintEngine()->painter()->end();
- }
- gr->painter->begin(gr->widget->pixmap);
- }
- if (mode == draw_mode_end) {
- gr->painter->end();
- if (gr->parent) {
- if (gr->cleanup) {
- overlay_rect(gr->parent, gr, 1, &r);
- qt_qpainter_draw(gr->parent, &r, 0);
- gr->cleanup=0;
- }
- overlay_rect(gr->parent, gr, 0, &r);
- qt_qpainter_draw(gr->parent, &r, 0);
- } else {
- r.setRect(0, 0, gr->widget->pixmap->width(), gr->widget->pixmap->height());
- qt_qpainter_draw(gr, &r, 0);
- }
- if (!gr->parent)
- QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers|QEventLoop::DeferredDeletion|QEventLoop::X11ExcludeTimers);
- }
- gr->mode=mode;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
+static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode) {
+ dbg(lvl_debug,"mode for %p %d", gr, mode);
+ QRect r;
+ if (mode == draw_mode_begin) {
+ if (gr->widget->pixmap->paintingActive()) {
+ gr->widget->pixmap->paintEngine()->painter()->end();
+ }
+ gr->painter->begin(gr->widget->pixmap);
+ }
+ if (mode == draw_mode_end) {
+ gr->painter->end();
+ if (gr->parent) {
+ if (gr->cleanup) {
+ overlay_rect(gr->parent, gr, 1, &r);
+ qt_qpainter_draw(gr->parent, &r, 0);
+ gr->cleanup=0;
+ }
+ overlay_rect(gr->parent, gr, 0, &r);
+ qt_qpainter_draw(gr->parent, &r, 0);
+ } else {
+ r.setRect(0, 0, gr->widget->pixmap->width(), gr->widget->pixmap->height());
+ qt_qpainter_draw(gr, &r, 0);
+ }
+ if (!gr->parent)
+ QCoreApplication::processEvents(
+ QEventLoop::ExcludeUserInputEvents|QEventLoop::ExcludeSocketNotifiers|QEventLoop::DeferredDeletion|QEventLoop::X11ExcludeTimers);
+ }
+ gr->mode=mode;
+}
+
+//##############################################################################################################
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h,int wraparound);
+static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p,
+ int w, int h,int wraparound);
static int argc=1;
-static char *argv[]={NULL,NULL,NULL};
+static char *argv[]= {NULL,NULL,NULL};
-static int
-fullscreen(struct window *win, int on)
-{
+static int fullscreen(struct window *win, int on) {
#ifndef QT_QPAINTER_NO_WIDGET
- struct graphics_priv *this_=(struct graphics_priv *)win->priv;
- QWidget* _outerWidget;
+ struct graphics_priv *this_=(struct graphics_priv *)win->priv;
+ QWidget* _outerWidget;
#ifdef QT_QPAINTER_USE_EMBEDDING
- _outerWidget=(QWidget*)this_->widget->parent();
+ _outerWidget=(QWidget*)this_->widget->parent();
#else
- _outerWidget=this_->widget;
+ _outerWidget=this_->widget;
#endif /* QT_QPAINTER_USE_EMBEDDING */
- if (on)
- _outerWidget->showFullScreen();
- else
- _outerWidget->showMaximized();
+ if (on)
+ _outerWidget->showFullScreen();
+ else
+ _outerWidget->showMaximized();
#endif
- return 1;
+ return 1;
}
-static void
-disable_suspend(struct window *win)
-{
+static void disable_suspend(struct window *win) {
#ifdef HAVE_QPE
- struct graphics_priv *this_=(struct graphics_priv *)win->priv;
- this_->app->setTempScreenSaverMode(QPEApplication::DisableLightOff);
+ struct graphics_priv *this_=(struct graphics_priv *)win->priv;
+ this_->app->setTempScreenSaverMode(QPEApplication::DisableLightOff);
#endif
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void * get_data(struct graphics_priv *this_, const char *type)
-{
- struct window *win;
- QString xid;
- bool ok;
-
- if (!strcmp(type, "resize")) {
- dbg(lvl_debug,"resize %d %d\n",this_->w,this_->h);
- QSize size(this_->w,this_->h);
- this_->widget->do_resize(size);
- }
- if (!strcmp(type, "qt_widget"))
- return this_->widget;
- if (!strcmp(type, "qt_pixmap"))
- return this_->widget->pixmap;
- if (!strcmp(type, "window")) {
- win=g_new(struct window, 1);
+static void * get_data(struct graphics_priv *this_, const char *type) {
+ struct window *win;
+ QString xid;
+ bool ok;
+
+ if (!strcmp(type, "resize")) {
+ dbg(lvl_debug,"resize %d %d",this_->w,this_->h);
+ QSize size(this_->w,this_->h);
+ this_->widget->do_resize(size);
+ }
+ if (!strcmp(type, "qt_widget"))
+ return this_->widget;
+ if (!strcmp(type, "qt_pixmap"))
+ return this_->widget->pixmap;
+ if (!strcmp(type, "window")) {
+ win=g_new(struct window, 1);
#ifndef QT_QPAINTER_NO_WIDGET
#ifdef QT_QPAINTER_USE_EMBEDDING
- EmbeddedWidget* _outerWidget=new EmbeddedWidget(this_,this_->widget,NULL);
- xid=getenv("NAVIT_XID");
- if (xid.length()>0) {
- _outerWidget->embedInto(xid.toULong(&ok,0));
- }
- _outerWidget->show();
+ EmbeddedWidget* _outerWidget=new EmbeddedWidget(this_,this_->widget,NULL);
+ xid=getenv("NAVIT_XID");
+ if (xid.length()>0) {
+ _outerWidget->embedInto(xid.toULong(&ok,0));
+ }
+ _outerWidget->show();
#endif /* QT_QPAINTER_USE_EMBEDDING */
- if (this_->w && this_->h)
- this_->widget->show();
- else
- this_->widget->showMaximized();
+ if (this_->w && this_->h)
+ this_->widget->show();
+ else
+ this_->widget->showMaximized();
#endif /* QT_QPAINTER_NO_WIDGET */
- win->priv=this_;
- win->fullscreen=fullscreen;
- win->disable_suspend=disable_suspend;
- return win;
- }
- return NULL;
-}
-
-static void
-image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
-{
- delete priv->pixmap;
- g_free(priv);
-}
-
-static void
-get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate)
-{
- QPainter *painter=gr->painter;
- QString tmp=QString::fromUtf8(text);
- painter->setFont(*font->font);
- QRect r=painter->boundingRect(0,0,gr->w,gr->h,0,tmp);
- ret[0].x=0;
- ret[0].y=-r.height();
- ret[1].x=0;
- ret[1].y=0;
- ret[2].x=r.width();
- ret[2].y=0;
- ret[3].x=r.width();
- ret[3].y=-r.height();
-}
-
-
-//##############################################################################################################
-//# Description:
-//# Comment:
+ win->priv=this_;
+ win->fullscreen=fullscreen;
+ win->disable_suspend=disable_suspend;
+ return win;
+ }
+ return NULL;
+}
+
+static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv) {
+ delete priv->pixmap;
+ g_free(priv);
+}
+
+static void get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate) {
+ QPainter *painter=gr->painter;
+ QString tmp=QString::fromUtf8(text);
+ painter->setFont(*font->font);
+ QRect r=painter->boundingRect(0,0,gr->w,gr->h,0,tmp);
+ ret[0].x=0;
+ ret[0].y=-r.height();
+ ret[1].x=0;
+ ret[1].y=0;
+ ret[2].x=r.width();
+ ret[2].y=0;
+ ret[3].x=r.width();
+ ret[3].y=-r.height();
+}
+
+
+//##############################################################################################################
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void overlay_disable(struct graphics_priv *gr, int disable)
-{
- gr->overlay_disable=disable;
+static void overlay_disable(struct graphics_priv *gr, int disable) {
+ gr->overlay_disable=disable;
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static int set_attr(struct graphics_priv *gr, struct attr *attr)
-{
- switch (attr->type) {
- case attr_w:
- gr->w=attr->u.num;
- if (gr->w != 0 && gr->h != 0) {
- QSize size(gr->w,gr->h);
- gr->widget->do_resize(size);
- }
- break;
- case attr_h:
- gr->h=attr->u.num;
- if (gr->w != 0 && gr->h != 0) {
- QSize size(gr->w,gr->h);
- gr->widget->do_resize(size);
- }
- break;
- default:
- return 0;
- }
- return 1;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
+static int set_attr(struct graphics_priv *gr, struct attr *attr) {
+ switch (attr->type) {
+ case attr_w:
+ gr->w=attr->u.num;
+ if (gr->w != 0 && gr->h != 0) {
+ QSize size(gr->w,gr->h);
+ gr->widget->do_resize(size);
+ }
+ break;
+ case attr_h:
+ gr->h=attr->u.num;
+ if (gr->w != 0 && gr->h != 0) {
+ QSize size(gr->w,gr->h);
+ gr->widget->do_resize(size);
+ }
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+//##############################################################################################################
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
static struct graphics_methods graphics_methods = {
- graphics_destroy,
- draw_mode,
- draw_lines,
- draw_polygon,
- draw_rectangle,
- draw_circle,
- draw_text,
- draw_image,
- NULL,
- draw_drag,
- font_new,
- gc_new,
- background_gc,
- overlay_new,
- image_new,
- get_data,
- image_free,
- get_text_bbox,
- overlay_disable,
- NULL,
- set_attr,
- NULL, /* show_native_keyboard */
- NULL, /* hide_native_keyboard */
+ graphics_destroy,
+ draw_mode,
+ draw_lines,
+ draw_polygon,
+ draw_rectangle,
+ draw_circle,
+ draw_text,
+ draw_image,
+ NULL,
+ draw_drag,
+ font_new,
+ gc_new,
+ background_gc,
+ overlay_new,
+ image_new,
+ get_data,
+ image_free,
+ get_text_bbox,
+ overlay_disable,
+ NULL,
+ set_attr,
+ NULL, /* show_native_keyboard */
+ NULL, /* hide_native_keyboard */
};
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h,int wraparound)
-{
- *meth=graphics_methods;
- struct graphics_priv *ret=g_new0(struct graphics_priv, 1);
+static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h,int wraparound) {
+ *meth=graphics_methods;
+ struct graphics_priv *ret=g_new0(struct graphics_priv, 1);
#ifdef QT_QPAINTER_USE_FREETYPE
- if (gr->font_freetype_new) {
- ret->font_freetype_new=gr->font_freetype_new;
- gr->font_freetype_new(&ret->freetype_methods);
- meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int, int))ret->freetype_methods.font_new;
- meth->get_text_bbox=(void (*)(struct graphics_priv*, struct graphics_font_priv*, char*, int, int, struct point*, int))ret->freetype_methods.get_text_bbox;
- }
+ if (gr->font_freetype_new) {
+ ret->font_freetype_new=gr->font_freetype_new;
+ gr->font_freetype_new(&ret->freetype_methods);
+ meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int,
+ int))ret->freetype_methods.font_new;
+ meth->get_text_bbox=(void (*)(struct graphics_priv*, struct graphics_font_priv*, char*, int, int, struct point*,
+ int))ret->freetype_methods.get_text_bbox;
+ }
#endif
- ret->widget= new RenderArea(ret,gr->widget,w,h,1);
- ret->wraparound=wraparound;
- ret->painter=new QPainter;
- ret->p=*p;
- ret->parent=gr;
- ret->next=gr->overlays;
- gr->overlays=ret;
+ ret->widget= new RenderArea(ret,gr->widget,w,h,1);
+ ret->wraparound=wraparound;
+ ret->painter=new QPainter;
+ ret->p=*p;
+ ret->parent=gr;
+ ret->next=gr->overlays;
+ gr->overlays=ret;
#ifndef QT_QPAINTER_NO_WIDGET
- ret->widget->hide();
+ ret->widget->hide();
#endif
- return ret;
+ return ret;
}
#ifdef QT_QPAINTER_USE_EVENT_QT
@@ -735,199 +703,181 @@ static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graph
static struct graphics_priv *event_gr;
-static void
-event_qt_main_loop_run(void)
-{
- event_gr->app->exec();
+static void event_qt_main_loop_run(void) {
+ event_gr->app->exec();
}
-static void event_qt_main_loop_quit(void)
-{
- dbg(lvl_debug,"enter\n");
- exit(0);
+static void event_qt_main_loop_quit(void) {
+ dbg(lvl_debug,"enter");
+ exit(0);
}
-static struct event_watch *
-event_qt_add_watch(int fd, enum event_watch_cond cond, struct callback *cb)
-{
- dbg(lvl_debug,"enter fd=%d\n",(int)(long)fd);
- struct event_watch *ret=g_new0(struct event_watch, 1);
- ret->fd=fd;
- ret->cb=cb;
- g_hash_table_insert(event_gr->widget->watches, GINT_TO_POINTER(fd), ret);
- ret->sn=new QSocketNotifier(fd, QSocketNotifier::Read, event_gr->widget);
- QObject::connect(ret->sn, SIGNAL(activated(int)), event_gr->widget, SLOT(watchEvent(int)));
- return ret;
+static struct event_watch *event_qt_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) {
+ dbg(lvl_debug,"enter fd=%d",(int)(long)fd);
+ struct event_watch *ret=g_new0(struct event_watch, 1);
+ ret->fd=fd;
+ ret->cb=cb;
+ g_hash_table_insert(event_gr->widget->watches, GINT_TO_POINTER(fd), ret);
+ ret->sn=new QSocketNotifier(fd, QSocketNotifier::Read, event_gr->widget);
+ QObject::connect(ret->sn, SIGNAL(activated(int)), event_gr->widget, SLOT(watchEvent(int)));
+ return ret;
}
-static void
-event_qt_remove_watch(struct event_watch *ev)
-{
- g_hash_table_remove(event_gr->widget->watches, GINT_TO_POINTER(ev->fd));
- delete(ev->sn);
- g_free(ev);
+static void event_qt_remove_watch(struct event_watch *ev) {
+ g_hash_table_remove(event_gr->widget->watches, GINT_TO_POINTER(ev->fd));
+ delete(ev->sn);
+ g_free(ev);
}
-static struct event_timeout *
-event_qt_add_timeout(int timeout, int multi, struct callback *cb)
-{
- int id;
- id=event_gr->widget->startTimer(timeout);
- g_hash_table_insert(event_gr->widget->timer_callback, (void *)id, cb);
- g_hash_table_insert(event_gr->widget->timer_type, (void *)id, (void *)!!multi);
- return (struct event_timeout *)id;
+static struct event_timeout *event_qt_add_timeout(int timeout, int multi, struct callback *cb) {
+ int id;
+ id=event_gr->widget->startTimer(timeout);
+ g_hash_table_insert(event_gr->widget->timer_callback, (void *)id, cb);
+ g_hash_table_insert(event_gr->widget->timer_type, (void *)id, (void *)!!multi);
+ return (struct event_timeout *)id;
}
-void
-event_qt_remove_timeout(struct event_timeout *ev)
-{
- event_gr->widget->killTimer((int)(long)ev);
- g_hash_table_remove(event_gr->widget->timer_callback, ev);
- g_hash_table_remove(event_gr->widget->timer_type, ev);
+void event_qt_remove_timeout(struct event_timeout *ev) {
+ event_gr->widget->killTimer((int)(long)ev);
+ g_hash_table_remove(event_gr->widget->timer_callback, ev);
+ g_hash_table_remove(event_gr->widget->timer_type, ev);
}
-static struct event_idle *
-event_qt_add_idle(int priority, struct callback *cb)
-{
- dbg(lvl_debug,"enter\n");
- return (struct event_idle *)event_qt_add_timeout(0, 1, cb);
+static struct event_idle *event_qt_add_idle(int priority, struct callback *cb) {
+ dbg(lvl_debug,"enter");
+ return (struct event_idle *)event_qt_add_timeout(0, 1, cb);
}
-static void
-event_qt_remove_idle(struct event_idle *ev)
-{
- dbg(lvl_debug,"enter\n");
- event_qt_remove_timeout((struct event_timeout *) ev);
+static void event_qt_remove_idle(struct event_idle *ev) {
+ dbg(lvl_debug,"enter");
+ event_qt_remove_timeout((struct event_timeout *) ev);
}
-static void
-event_qt_call_callback(struct callback_list *cb)
-{
- dbg(lvl_debug,"enter\n");
+static void event_qt_call_callback(struct callback_list *cb) {
+ dbg(lvl_debug,"enter");
}
static struct event_methods event_qt_methods = {
- event_qt_main_loop_run,
- event_qt_main_loop_quit,
- event_qt_add_watch,
- event_qt_remove_watch,
- event_qt_add_timeout,
- event_qt_remove_timeout,
- event_qt_add_idle,
- event_qt_remove_idle,
- event_qt_call_callback,
+ event_qt_main_loop_run,
+ event_qt_main_loop_quit,
+ event_qt_add_watch,
+ event_qt_remove_watch,
+ event_qt_add_timeout,
+ event_qt_remove_timeout,
+ event_qt_add_idle,
+ event_qt_remove_idle,
+ event_qt_call_callback,
};
struct event_priv {
};
struct event_priv *
-event_qt_new(struct event_methods *meth)
-{
- dbg(lvl_debug,"enter\n");
- *meth=event_qt_methods;
- return NULL;
+event_qt_new(struct event_methods *meth) {
+ dbg(lvl_debug,"enter");
+ *meth=event_qt_methods;
+ return NULL;
}
#endif
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static struct graphics_priv * graphics_qt_qpainter_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct graphics_priv *ret;
- struct font_priv * (*font_freetype_new)(void *meth);
- struct attr *attr;
+static struct graphics_priv * graphics_qt_qpainter_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct graphics_priv *ret;
+ struct font_priv * (*font_freetype_new)(void *meth);
+ struct attr *attr;
- dbg(lvl_debug,"enter\n");
+ dbg(lvl_debug,"enter");
#ifdef QT_QPAINTER_USE_EVENT_QT
- if (event_gr)
- return NULL;
- if (! event_request_system("qt","graphics_qt_qpainter_new"))
- return NULL;
+ if (event_gr)
+ return NULL;
+ if (! event_request_system("qt","graphics_qt_qpainter_new"))
+ return NULL;
#endif
#ifdef QT_QPAINTER_USE_EVENT_GLIB
- if (! event_request_system("glib","graphics_qt_qpainter_new"))
- return NULL;
+ if (! event_request_system("glib","graphics_qt_qpainter_new"))
+ return NULL;
#endif
#ifdef QT_QPAINTER_USE_FREETYPE
- font_freetype_new=(struct font_priv *(*)(void *))plugin_get_category_font("freetype");
- if (!font_freetype_new) {
- dbg(lvl_error,"no freetype\n");
- return NULL;
- }
+ font_freetype_new=(struct font_priv *(*)(void *))plugin_get_category_font("freetype");
+ if (!font_freetype_new) {
+ dbg(lvl_error,"no freetype");
+ return NULL;
+ }
#endif
- ret=g_new0(struct graphics_priv, 1);
- *meth=graphics_methods;
- ret->nav=nav;
+ ret=g_new0(struct graphics_priv, 1);
+ *meth=graphics_methods;
+ ret->nav=nav;
#ifdef QT_QPAINTER_USE_FREETYPE
- ret->font_freetype_new=font_freetype_new;
- font_freetype_new(&ret->freetype_methods);
- meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int, int))ret->freetype_methods.font_new;
- meth->get_text_bbox=(void (*)(struct graphics_priv*, struct graphics_font_priv*, char*, int, int, struct point*, int))ret->freetype_methods.get_text_bbox;
+ ret->font_freetype_new=font_freetype_new;
+ font_freetype_new(&ret->freetype_methods);
+ meth->font_new=(struct graphics_font_priv *(*)(struct graphics_priv *, struct graphics_font_methods *, char *, int,
+ int))ret->freetype_methods.font_new;
+ meth->get_text_bbox=(void (*)(struct graphics_priv*, struct graphics_font_priv*, char*, int, int, struct point*,
+ int))ret->freetype_methods.get_text_bbox;
#endif
#if defined QT_QPAINTER_USE_EMBEDDING && QT_VERSION >= 0x040500
- if ((attr=attr_search(attrs, NULL, attr_gc_type)))
- QApplication::setGraphicsSystem(attr->u.str);
- else
- QApplication::setGraphicsSystem("raster");
+ if ((attr=attr_search(attrs, NULL, attr_gc_type)))
+ QApplication::setGraphicsSystem(attr->u.str);
+ else
+ QApplication::setGraphicsSystem("raster");
#endif
- argv[0]=(char*)malloc(255);
- strcpy(argv[0], "navit");
- if ((attr=attr_search(attrs, NULL, attr_flags)))
- ret->flags=attr->u.num;
- if (ret->flags & 1) {
- argv[1]=(char*)malloc(255);
- strcpy(argv[1], "-qws");
- argc++;
- }
+ argv[0]=(char*)malloc(255);
+ strcpy(argv[0], "navit");
+ if ((attr=attr_search(attrs, NULL, attr_flags)))
+ ret->flags=attr->u.num;
+ if (ret->flags & 1) {
+ argv[1]=(char*)malloc(255);
+ strcpy(argv[1], "-qws");
+ argc++;
+ }
#ifndef QT_QPAINTER_NO_APP
#ifdef HAVE_QPE
- ret->app = new QPEApplication(argc, argv);
+ ret->app = new QPEApplication(argc, argv);
#else
- ret->app = new QApplication(argc, argv);
+ ret->app = new QApplication(argc, argv);
#endif
#endif
- ret->widget= new RenderArea(ret);
- ret->widget->cbl=cbl;
- ret->painter = new QPainter;
+ ret->widget= new RenderArea(ret);
+ ret->widget->cbl=cbl;
+ ret->painter = new QPainter;
#ifdef QT_QPAINTER_USE_EVENT_QT
- event_gr=ret;
+ event_gr=ret;
#endif
- ret->w=800;
- ret->h=600;
- if ((attr=attr_search(attrs, NULL, attr_w)))
- ret->w=attr->u.num;
- if ((attr=attr_search(attrs, NULL, attr_h)))
- ret->h=attr->u.num;
- if ((attr=attr_search(attrs, NULL, attr_window_title)))
- ret->window_title=g_strdup(attr->u.str);
- else
- ret->window_title=g_strdup("Navit");
+ ret->w=800;
+ ret->h=600;
+ if ((attr=attr_search(attrs, NULL, attr_w)))
+ ret->w=attr->u.num;
+ if ((attr=attr_search(attrs, NULL, attr_h)))
+ ret->h=attr->u.num;
+ if ((attr=attr_search(attrs, NULL, attr_window_title)))
+ ret->window_title=g_strdup(attr->u.str);
+ else
+ ret->window_title=g_strdup("Navit");
- dbg(lvl_debug,"return\n");
- return ret;
+ dbg(lvl_debug,"return");
+ return ret;
}
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void plugin_init(void)
-{
- plugin_register_category_graphics("qt_qpainter", graphics_qt_qpainter_new);
+void plugin_init(void) {
+ plugin_register_category_graphics("qt_qpainter", graphics_qt_qpainter_new);
#ifdef QT_QPAINTER_USE_EVENT_QT
- plugin_register_category_event("qt", event_qt_new);
+ plugin_register_category_event("qt", event_qt_new);
#endif
}
-// *** EOF ***
+// *** EOF ***
diff --git a/navit/graphics/qt_qpainter/graphics_qt_qpainter.h b/navit/graphics/qt_qpainter/graphics_qt_qpainter.h
index 9678b0dc0..3b90689f0 100644
--- a/navit/graphics/qt_qpainter/graphics_qt_qpainter.h
+++ b/navit/graphics/qt_qpainter/graphics_qt_qpainter.h
@@ -87,8 +87,8 @@
class RenderArea;
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
struct graphics_gc_priv {
@@ -98,8 +98,8 @@ struct graphics_gc_priv {
};
//##############################################################################################################
-//# Description:
-//# Comment:
+//# Description:
+//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
struct graphics_priv {
diff --git a/navit/graphics/sdl/CMakeLists.txt b/navit/graphics/sdl/CMakeLists.txt
index b8cad6025..c367a1762 100644
--- a/navit/graphics/sdl/CMakeLists.txt
+++ b/navit/graphics/sdl/CMakeLists.txt
@@ -1,2 +1,2 @@
-module_add_library(graphics_sdl graphics_sdl.c raster.c)
+module_add_library(graphics_sdl graphics_sdl.c raster.c)
diff --git a/navit/graphics/sdl/event.c b/navit/graphics/sdl/event.c
index f96b079b3..e94f1431b 100644
--- a/navit/graphics/sdl/event.c
+++ b/navit/graphics/sdl/event.c
@@ -8,26 +8,26 @@
#include "webos/webos.h"
struct event_timeout {
- SDL_TimerID id;
- int multi;
- struct callback *cb;
+ SDL_TimerID id;
+ int multi;
+ struct callback *cb;
};
struct idle_task {
- int priority;
- struct callback *cb;
+ int priority;
+ struct callback *cb;
};
struct event_watch {
- struct pollfd *pfd;
- struct callback *cb;
+ struct pollfd *pfd;
+ struct callback *cb;
};
static void event_sdl_watch_thread(GPtrArray *);
static void event_sdl_watch_startthread(GPtrArray *watch_list);
static void event_sdl_watch_stopthread(void);
static struct event_watch *event_sdl_add_watch(int, enum event_watch_cond,
- struct callback *);
+ struct callback *);
static void event_sdl_remove_watch(struct event_watch *);
static struct event_timeout *event_sdl_add_timeout(int, int, struct callback *);
static void event_sdl_remove_timeout(struct event_timeout *);
@@ -42,340 +42,337 @@ static SDL_Joystick *accelerometer = NULL;
static unsigned int orientation = WEBOS_ORIENTATION_PORTRAIT;
static void sdl_accelerometer_handler(void* param) {
- struct graphics_priv *gr = (struct graphics_priv *) param;
- int xAxis = SDL_JoystickGetAxis(accelerometer, 0);
- int yAxis = SDL_JoystickGetAxis(accelerometer, 1);
- int zAxis = SDL_JoystickGetAxis(accelerometer, 2);
- unsigned char new_orientation;
-
- dbg(lvl_info, "x(%d) y(%d) z(%d) c(%d)\n", xAxis, yAxis, zAxis,
- sdl_orientation_count);
-
- if (zAxis > -30000) {
- if (xAxis < -15000 && yAxis > -5000 && yAxis < 5000)
- new_orientation = WEBOS_ORIENTATION_LANDSCAPE;
- else if (yAxis > 15000 && xAxis > -5000 && xAxis < 5000)
- new_orientation = WEBOS_ORIENTATION_PORTRAIT;
- else
- return;
- } else
- return;
-
- if (new_orientation == sdl_next_orientation) {
- if (sdl_orientation_count < 3)
- sdl_orientation_count++;
- } else {
- sdl_orientation_count = 0;
- sdl_next_orientation = new_orientation;
- return;
- }
-
- if (sdl_orientation_count == 3) {
- sdl_orientation_count++;
-
- if (new_orientation != orientation) {
- dbg(lvl_debug, "x(%d) y(%d) z(%d) o(%d)\n", xAxis, yAxis, zAxis,
- new_orientation);
- orientation = new_orientation;
-
- SDL_Event event;
- SDL_UserEvent userevent;
-
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_ROTATE;
- userevent.data1 = NULL;
- userevent.data2 = NULL;
-
- event.type = SDL_USEREVENT;
- event.user = userevent;
-
- SDL_PushEvent(&event);
- }
- }
+ struct graphics_priv *gr = (struct graphics_priv *) param;
+ int xAxis = SDL_JoystickGetAxis(accelerometer, 0);
+ int yAxis = SDL_JoystickGetAxis(accelerometer, 1);
+ int zAxis = SDL_JoystickGetAxis(accelerometer, 2);
+ unsigned char new_orientation;
+
+ dbg(lvl_info, "x(%d) y(%d) z(%d) c(%d)", xAxis, yAxis, zAxis,
+ sdl_orientation_count);
+
+ if (zAxis > -30000) {
+ if (xAxis < -15000 && yAxis > -5000 && yAxis < 5000)
+ new_orientation = WEBOS_ORIENTATION_LANDSCAPE;
+ else if (yAxis > 15000 && xAxis > -5000 && xAxis < 5000)
+ new_orientation = WEBOS_ORIENTATION_PORTRAIT;
+ else
+ return;
+ } else
+ return;
+
+ if (new_orientation == sdl_next_orientation) {
+ if (sdl_orientation_count < 3)
+ sdl_orientation_count++;
+ } else {
+ sdl_orientation_count = 0;
+ sdl_next_orientation = new_orientation;
+ return;
+ }
+
+ if (sdl_orientation_count == 3) {
+ sdl_orientation_count++;
+
+ if (new_orientation != orientation) {
+ dbg(lvl_debug, "x(%d) y(%d) z(%d) o(%d)", xAxis, yAxis, zAxis,
+ new_orientation);
+ orientation = new_orientation;
+
+ SDL_Event event;
+ SDL_UserEvent userevent;
+
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_ROTATE;
+ userevent.data1 = NULL;
+ userevent.data2 = NULL;
+
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
+
+ SDL_PushEvent(&event);
+ }
+ }
}
#endif
/* ---------- SDL Eventhandling ---------- */
static Uint32 sdl_timer_callback(Uint32 interval, void* param) {
- struct event_timeout *timeout = (struct event_timeout*) param;
+ struct event_timeout *timeout = (struct event_timeout*) param;
- dbg(lvl_debug, "timer(%p) multi(%d) interval(%d) fired\n", param, timeout->multi,
- interval);
+ dbg(lvl_debug, "timer(%p) multi(%d) interval(%d) fired", param, timeout->multi,
+ interval);
- SDL_Event event;
- SDL_UserEvent userevent;
+ SDL_Event event;
+ SDL_UserEvent userevent;
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_TIMER;
- userevent.data1 = timeout->cb;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_TIMER;
+ userevent.data1 = timeout->cb;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent(&event);
+ SDL_PushEvent(&event);
- if (timeout->multi == 0) {
- g_free(timeout);
- timeout = NULL;
- return 0; // cancel timer
- }
- return interval; // reactivate timer
+ if (timeout->multi == 0) {
+ g_free(timeout);
+ timeout = NULL;
+ return 0; // cancel timer
+ }
+ return interval; // reactivate timer
}
/* SDL Mainloop */
static void event_sdl_main_loop_run(void) {
#ifdef USE_WEBOS_ACCELEROMETER
- struct callback* accel_cb = NULL;
- struct event_timeout* accel_to = NULL;
- if (PDL_GetPDKVersion() > 100) {
- accel_cb = callback_new_1(callback_cast(sdl_accelerometer_handler), gr);
- accel_to = event_add_timeout(200, 1, accel_cb);
- }
+ struct callback* accel_cb = NULL;
+ struct event_timeout* accel_to = NULL;
+ if (PDL_GetPDKVersion() > 100) {
+ accel_cb = callback_new_1(callback_cast(sdl_accelerometer_handler), gr);
+ accel_to = event_add_timeout(200, 1, accel_cb);
+ }
#endif
- graphics_sdl_idle(NULL);
+ graphics_sdl_idle(NULL);
- event_sdl_watch_stopthread();
+ event_sdl_watch_stopthread();
#ifdef USE_WEBOS_ACCELEROMETER
- SDL_JoystickClose(accelerometer);
- if (PDL_GetPDKVersion() > 100) {
- event_remove_timeout(accel_to);
- callback_destroy(accel_cb);
- }
+ SDL_JoystickClose(accelerometer);
+ if (PDL_GetPDKVersion() > 100) {
+ event_remove_timeout(accel_to);
+ callback_destroy(accel_cb);
+ }
#endif
}
static void event_sdl_main_loop_quit(void) {
- quit_event_loop = 1;
+ quit_event_loop = 1;
}
/* Watch */
static void event_sdl_watch_thread(GPtrArray *watch_list) {
- struct pollfd *pfds = g_new0 (struct pollfd, watch_list->len);
- struct event_watch *ew;
- int ret;
- int idx;
-
- for (idx = 0; idx < watch_list->len; idx++) {
- ew = g_ptr_array_index(watch_list, idx);
- g_memmove(&pfds[idx], ew->pfd, sizeof(struct pollfd));
- }
-
- while ((ret = ppoll(pfds, watch_list->len, NULL, NULL)) > 0) {
- for (idx = 0; idx < watch_list->len; idx++) {
- if (pfds[idx].revents == pfds[idx].events) { /* The requested event happened, notify mainloop! */
- ew = g_ptr_array_index(watch_list, idx);
- dbg(lvl_debug, "watch(%p) event(%d) encountered\n", ew,
- pfds[idx].revents);
-
- SDL_Event event;
- SDL_UserEvent userevent;
-
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_WATCH;
- userevent.data1 = ew->cb;
- userevent.data2 = NULL;
-
- event.type = SDL_USEREVENT;
- event.user = userevent;
-
- SDL_PushEvent(&event);
- }
- }
- }
-
- g_free(pfds);
-
- pthread_exit(0);
+ struct pollfd *pfds = g_new0 (struct pollfd, watch_list->len);
+ struct event_watch *ew;
+ int ret;
+ int idx;
+
+ for (idx = 0; idx < watch_list->len; idx++) {
+ ew = g_ptr_array_index(watch_list, idx);
+ g_memmove(&pfds[idx], ew->pfd, sizeof(struct pollfd));
+ }
+
+ while ((ret = ppoll(pfds, watch_list->len, NULL, NULL)) > 0) {
+ for (idx = 0; idx < watch_list->len; idx++) {
+ if (pfds[idx].revents == pfds[idx].events) { /* The requested event happened, notify mainloop! */
+ ew = g_ptr_array_index(watch_list, idx);
+ dbg(lvl_debug, "watch(%p) event(%d) encountered", ew,
+ pfds[idx].revents);
+
+ SDL_Event event;
+ SDL_UserEvent userevent;
+
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_WATCH;
+ userevent.data1 = ew->cb;
+ userevent.data2 = NULL;
+
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
+
+ SDL_PushEvent(&event);
+ }
+ }
+ }
+
+ g_free(pfds);
+
+ pthread_exit(0);
}
static void event_sdl_watch_startthread(GPtrArray *watch_list) {
- dbg(lvl_debug, "enter\n");
- if (sdl_watch_thread)
- event_sdl_watch_stopthread();
+ dbg(lvl_debug, "enter");
+ if (sdl_watch_thread)
+ event_sdl_watch_stopthread();
- int ret;
- ret = pthread_create(&sdl_watch_thread, NULL,
- (void *) event_sdl_watch_thread, (void *) watch_list);
+ int ret;
+ ret = pthread_create(&sdl_watch_thread, NULL,
+ (void *) event_sdl_watch_thread, (void *) watch_list);
- dbg_assert(ret == 0);
+ dbg_assert(ret == 0);
}
static void event_sdl_watch_stopthread() {
- dbg(lvl_debug, "enter\n");
- if (sdl_watch_thread) {
- /* Notify the watch thread that the list of FDs will change */
- pthread_kill(sdl_watch_thread, SIGUSR1);
- pthread_join(sdl_watch_thread, NULL);
- sdl_watch_thread = 0;
- }
+ dbg(lvl_debug, "enter");
+ if (sdl_watch_thread) {
+ /* Notify the watch thread that the list of FDs will change */
+ pthread_kill(sdl_watch_thread, SIGUSR1);
+ pthread_join(sdl_watch_thread, NULL);
+ sdl_watch_thread = 0;
+ }
}
-static struct event_watch *
-event_sdl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) {
- dbg(lvl_debug, "fd(%d) cond(%x) cb(%x)\n", fd, cond, cb);
+static struct event_watch *event_sdl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) {
+ dbg(lvl_debug, "fd(%d) cond(%x) cb(%x)", fd, cond, cb);
- event_sdl_watch_stopthread();
+ event_sdl_watch_stopthread();
- if (!sdl_watch_list)
- sdl_watch_list = g_ptr_array_new();
+ if (!sdl_watch_list)
+ sdl_watch_list = g_ptr_array_new();
- struct event_watch *new_ew = g_new0 (struct event_watch, 1);
- struct pollfd *pfd = g_new0 (struct pollfd, 1);
+ struct event_watch *new_ew = g_new0 (struct event_watch, 1);
+ struct pollfd *pfd = g_new0 (struct pollfd, 1);
- pfd->fd = fd;
+ pfd->fd = fd;
- /* Modify watchlist here */
- switch (cond) {
- case event_watch_cond_read:
- pfd->events = POLLIN;
- break;
- case event_watch_cond_write:
- pfd->events = POLLOUT;
- break;
- case event_watch_cond_except:
- pfd->events = POLLERR | POLLHUP;
- break;
- }
+ /* Modify watchlist here */
+ switch (cond) {
+ case event_watch_cond_read:
+ pfd->events = POLLIN;
+ break;
+ case event_watch_cond_write:
+ pfd->events = POLLOUT;
+ break;
+ case event_watch_cond_except:
+ pfd->events = POLLERR | POLLHUP;
+ break;
+ }
- new_ew->pfd = (struct pollfd*) pfd;
- new_ew->cb = cb;
+ new_ew->pfd = (struct pollfd*) pfd;
+ new_ew->cb = cb;
- g_ptr_array_add(sdl_watch_list, (gpointer) new_ew);
+ g_ptr_array_add(sdl_watch_list, (gpointer) new_ew);
- event_sdl_watch_startthread(sdl_watch_list);
+ event_sdl_watch_startthread(sdl_watch_list);
- return new_ew;
+ return new_ew;
}
static void event_sdl_remove_watch(struct event_watch *ew) {
- dbg(lvl_debug, "enter %p\n", ew);
+ dbg(lvl_debug, "enter %p", ew);
- event_sdl_watch_stopthread();
+ event_sdl_watch_stopthread();
- g_ptr_array_remove(sdl_watch_list, ew);
- g_free(ew->pfd);
- g_free(ew);
+ g_ptr_array_remove(sdl_watch_list, ew);
+ g_free(ew->pfd);
+ g_free(ew);
- if (sdl_watch_list->len > 0)
- event_sdl_watch_startthread(sdl_watch_list);
+ if (sdl_watch_list->len > 0)
+ event_sdl_watch_startthread(sdl_watch_list);
}
/* Timeout */
-static struct event_timeout *
-event_sdl_add_timeout(int timeout, int multi, struct callback *cb) {
- struct event_timeout * ret = g_new0(struct event_timeout, 1);
- if (!ret)
- return ret;
- dbg(lvl_debug, "timer(%p) multi(%d) interval(%d) cb(%p) added\n", ret, multi,
- timeout, cb);
- ret->multi = multi;
- ret->cb = cb;
- ret->id = SDL_AddTimer(timeout, sdl_timer_callback, ret);
-
- return ret;
+static struct event_timeout *event_sdl_add_timeout(int timeout, int multi, struct callback *cb) {
+ struct event_timeout * ret = g_new0(struct event_timeout, 1);
+ if (!ret)
+ return ret;
+ dbg(lvl_debug, "timer(%p) multi(%d) interval(%d) cb(%p) added", ret, multi,
+ timeout, cb);
+ ret->multi = multi;
+ ret->cb = cb;
+ ret->id = SDL_AddTimer(timeout, sdl_timer_callback, ret);
+
+ return ret;
}
static void event_sdl_remove_timeout(struct event_timeout *to) {
- dbg(lvl_info, "enter %p\n", to);
- if (to != NULL) {
- int ret = to->id ? SDL_RemoveTimer(to->id) : SDL_TRUE;
- if (ret == SDL_FALSE) {
- dbg(lvl_debug, "SDL_RemoveTimer (%p) failed\n", to->id);
- } else {
- g_free(to);
- dbg(lvl_debug, "timer(%p) removed\n", to);
- }
- }
+ dbg(lvl_info, "enter %p", to);
+ if (to != NULL) {
+ int ret = to->id ? SDL_RemoveTimer(to->id) : SDL_TRUE;
+ if (ret == SDL_FALSE) {
+ dbg(lvl_debug, "SDL_RemoveTimer (%p) failed", to->id);
+ } else {
+ g_free(to);
+ dbg(lvl_debug, "timer(%p) removed", to);
+ }
+ }
}
/* Idle */
/* sort ptr_array by priority, increasing order */
static gint sdl_sort_idle_tasks(gconstpointer parama, gconstpointer paramb) {
- struct idle_task *a = (struct idle_task *) parama;
- struct idle_task *b = (struct idle_task *) paramb;
- if (a->priority < b->priority)
- return -1;
- if (a->priority > b->priority)
- return 1;
- return 0;
+ struct idle_task *a = (struct idle_task *) parama;
+ struct idle_task *b = (struct idle_task *) paramb;
+ if (a->priority < b->priority)
+ return -1;
+ if (a->priority > b->priority)
+ return 1;
+ return 0;
}
-static struct event_idle *
-event_sdl_add_idle(int priority, struct callback *cb) {
- dbg(lvl_debug, "add idle priority(%d) cb(%p)\n", priority, cb);
+static struct event_idle *event_sdl_add_idle(int priority, struct callback *cb) {
+ dbg(lvl_debug, "add idle priority(%d) cb(%p)", priority, cb);
- struct idle_task *task = g_new0(struct idle_task, 1);
- task->priority = priority;
- task->cb = cb;
+ struct idle_task *task = g_new0(struct idle_task, 1);
+ task->priority = priority;
+ task->cb = cb;
- g_ptr_array_add(idle_tasks, (gpointer) task);
+ g_ptr_array_add(idle_tasks, (gpointer) task);
- if (idle_tasks->len < 2) {
- SDL_Event event;
- SDL_UserEvent userevent;
+ if (idle_tasks->len < 2) {
+ SDL_Event event;
+ SDL_UserEvent userevent;
- dbg(lvl_debug, "poking eventloop because of new idle_events\n");
+ dbg(lvl_debug, "poking eventloop because of new idle_events");
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_IDLE_EVENT;
- userevent.data1 = NULL;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_IDLE_EVENT;
+ userevent.data1 = NULL;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent(&event);
- } else
- // more than one entry => sort the list
- g_ptr_array_sort(idle_tasks, sdl_sort_idle_tasks);
+ SDL_PushEvent(&event);
+ } else
+ // more than one entry => sort the list
+ g_ptr_array_sort(idle_tasks, sdl_sort_idle_tasks);
- return (struct event_idle *) task;
+ return (struct event_idle *) task;
}
static void event_sdl_remove_idle(struct event_idle *task) {
- dbg(lvl_debug, "remove task(%p)\n", task);
- g_ptr_array_remove(idle_tasks, (gpointer) task);
+ dbg(lvl_debug, "remove task(%p)", task);
+ g_ptr_array_remove(idle_tasks, (gpointer) task);
}
/* callback */
static void event_sdl_call_callback(struct callback_list *cbl) {
- dbg(lvl_debug, "call_callback cbl(%p)\n", cbl);
- SDL_Event event;
- SDL_UserEvent userevent;
+ dbg(lvl_debug, "call_callback cbl(%p)", cbl);
+ SDL_Event event;
+ SDL_UserEvent userevent;
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_CALL_CALLBACK;
- userevent.data1 = cbl;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_CALL_CALLBACK;
+ userevent.data1 = cbl;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent(&event);
+ SDL_PushEvent(&event);
}
static struct event_methods event_sdl_methods = { event_sdl_main_loop_run,
- event_sdl_main_loop_quit, event_sdl_add_watch, event_sdl_remove_watch,
- event_sdl_add_timeout, event_sdl_remove_timeout, event_sdl_add_idle,
- event_sdl_remove_idle, event_sdl_call_callback, };
-
-static struct event_priv *
-event_sdl_new(struct event_methods* methods) {
- idle_tasks = g_ptr_array_new();
- *methods = event_sdl_methods;
- return NULL;
+ event_sdl_main_loop_quit, event_sdl_add_watch, event_sdl_remove_watch,
+ event_sdl_add_timeout, event_sdl_remove_timeout, event_sdl_add_idle,
+ event_sdl_remove_idle, event_sdl_call_callback,
+};
+
+static struct event_priv *event_sdl_new(struct event_methods* methods) {
+ idle_tasks = g_ptr_array_new();
+ *methods = event_sdl_methods;
+ return NULL;
}
/* ---------- SDL Eventhandling ---------- */
void sdl_event_init(void) {
- plugin_register_category_event("sdl", event_sdl_new);
+ plugin_register_category_event("sdl", event_sdl_new);
}
diff --git a/navit/graphics/sdl/event_sdl.c b/navit/graphics/sdl/event_sdl.c
index 28fe4fafb..454e9eb06 100644
--- a/navit/graphics/sdl/event_sdl.c
+++ b/navit/graphics/sdl/event_sdl.c
@@ -19,7 +19,7 @@
#include <glib.h>
#include <poll.h>
-#include <SDL/SDL.h>
+#include "SDL.h"
#include <pthread.h>
#include <signal.h>
#include "config.h"
@@ -43,301 +43,266 @@ static struct event_idle *event_sdl_add_idle(int, struct callback *);
static void event_sdl_remove_idle(struct event_idle *);
static void event_sdl_call_callback(struct callback_list *);
-static Uint32
-sdl_timer_callback(Uint32 interval, void* param)
-{
- struct event_timeout *timeout=(struct event_timeout*)param;
+static Uint32 sdl_timer_callback(Uint32 interval, void* param) {
+ struct event_timeout *timeout=(struct event_timeout*)param;
- dbg(lvl_debug,"timer(%p) multi(%d) interval(%d) fired\n", param, timeout->multi, interval);
+ dbg(lvl_debug,"timer(%p) multi(%d) interval(%d) fired", param, timeout->multi, interval);
- SDL_Event event;
- SDL_UserEvent userevent;
+ SDL_Event event;
+ SDL_UserEvent userevent;
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_TIMER;
- userevent.data1 = timeout->cb;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_TIMER;
+ userevent.data1 = timeout->cb;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent (&event);
+ SDL_PushEvent (&event);
- if (timeout->multi == 0) {
- timeout->id = 0;
- return 0; // cancel timer
- }
- return interval; // reactivate timer
+ if (timeout->multi == 0) {
+ timeout->id = 0;
+ return 0; // cancel timer
+ }
+ return interval; // reactivate timer
}
/* SDL Mainloop */
-static void
-event_sdl_main_loop_run(void)
-{
- graphics_sdl_idle(NULL);
- event_sdl_watch_stopthread();
+static void event_sdl_main_loop_run(void) {
+ graphics_sdl_idle(NULL);
+ event_sdl_watch_stopthread();
}
-static void
-event_sdl_main_loop_quit(void)
-{
- quit_event_loop = 1;
+static void event_sdl_main_loop_quit(void) {
+ quit_event_loop = 1;
}
/* Watch */
-void
-event_sdl_watch_thread (GPtrArray *watch_list)
-{
- struct pollfd *pfds = g_new0 (struct pollfd, watch_list->len);
- struct event_watch *ew;
- int ret;
- int idx;
+void event_sdl_watch_thread (GPtrArray *watch_list) {
+ struct pollfd *pfds = g_new0 (struct pollfd, watch_list->len);
+ struct event_watch *ew;
+ int ret;
+ int idx;
- for (idx = 0; idx < watch_list->len; idx++ ) {
- ew = g_ptr_array_index (watch_list, idx);
- g_memmove (&pfds[idx], ew->pfd, sizeof(struct pollfd));
- }
+ for (idx = 0; idx < watch_list->len; idx++ ) {
+ ew = g_ptr_array_index (watch_list, idx);
+ g_memmove (&pfds[idx], ew->pfd, sizeof(struct pollfd));
+ }
- while ((ret = ppoll(pfds, watch_list->len, NULL, NULL)) > 0) {
- for (idx = 0; idx < watch_list->len; idx++ ) {
- if (pfds[idx].revents == pfds[idx].events) { /* The requested event happened, notify mainloop! */
- ew = g_ptr_array_index (watch_list, idx);
- dbg(lvl_debug,"watch(%p) event(%d) encountered\n", ew, pfds[idx].revents);
+ while ((ret = ppoll(pfds, watch_list->len, NULL, NULL)) > 0) {
+ for (idx = 0; idx < watch_list->len; idx++ ) {
+ if (pfds[idx].revents == pfds[idx].events) { /* The requested event happened, notify mainloop! */
+ ew = g_ptr_array_index (watch_list, idx);
+ dbg(lvl_debug,"watch(%p) event(%d) encountered", ew, pfds[idx].revents);
- SDL_Event event;
- SDL_UserEvent userevent;
+ SDL_Event event;
+ SDL_UserEvent userevent;
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_WATCH;
- userevent.data1 = ew->cb;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_WATCH;
+ userevent.data1 = ew->cb;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent (&event);
- }
- }
- }
+ SDL_PushEvent (&event);
+ }
+ }
+ }
- g_free(pfds);
+ g_free(pfds);
- pthread_exit(0);
+ pthread_exit(0);
}
-static void
-event_sdl_watch_startthread(GPtrArray *watch_list)
-{
- dbg(lvl_debug,"enter\n");
- if (sdl_watch_thread)
- event_sdl_watch_stopthread();
+static void event_sdl_watch_startthread(GPtrArray *watch_list) {
+ dbg(lvl_debug,"enter");
+ if (sdl_watch_thread)
+ event_sdl_watch_stopthread();
- int ret;
- ret = pthread_create (&sdl_watch_thread, NULL, (void *)event_sdl_watch_thread, (void *)watch_list);
+ int ret;
+ ret = pthread_create (&sdl_watch_thread, NULL, (void *)event_sdl_watch_thread, (void *)watch_list);
- dbg_assert (ret == 0);
+ dbg_assert (ret == 0);
}
-static void
-event_sdl_watch_stopthread()
-{
- dbg(lvl_debug,"enter\n");
- if (sdl_watch_thread) {
- /* Notify the watch thread that the list of FDs will change */
- pthread_kill(sdl_watch_thread, SIGUSR1);
- pthread_join(sdl_watch_thread, NULL);
- sdl_watch_thread = 0;
- }
+static void event_sdl_watch_stopthread() {
+ dbg(lvl_debug,"enter");
+ if (sdl_watch_thread) {
+ /* Notify the watch thread that the list of FDs will change */
+ pthread_kill(sdl_watch_thread, SIGUSR1);
+ pthread_join(sdl_watch_thread, NULL);
+ sdl_watch_thread = 0;
+ }
}
-static struct event_watch *
-event_sdl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb)
-{
- dbg(lvl_debug,"fd(%d) cond(%x) cb(%x)\n", fd, cond, cb);
+static struct event_watch *event_sdl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) {
+ dbg(lvl_debug,"fd(%d) cond(%x) cb(%x)", fd, cond, cb);
- event_sdl_watch_stopthread();
+ event_sdl_watch_stopthread();
- if (!sdl_watch_list)
- sdl_watch_list = g_ptr_array_new();
+ if (!sdl_watch_list)
+ sdl_watch_list = g_ptr_array_new();
- struct event_watch *new_ew = g_new0 (struct event_watch, 1);
- struct pollfd *pfd = g_new0 (struct pollfd, 1);
+ struct event_watch *new_ew = g_new0 (struct event_watch, 1);
+ struct pollfd *pfd = g_new0 (struct pollfd, 1);
- pfd->fd = fd;
+ pfd->fd = fd;
- /* Modify watchlist here */
- switch (cond) {
- case event_watch_cond_read:
- pfd->events = POLLIN;
- break;
- case event_watch_cond_write:
- pfd->events = POLLOUT;
- break;
- case event_watch_cond_except:
- pfd->events = POLLERR|POLLHUP;
- break;
- }
+ /* Modify watchlist here */
+ switch (cond) {
+ case event_watch_cond_read:
+ pfd->events = POLLIN;
+ break;
+ case event_watch_cond_write:
+ pfd->events = POLLOUT;
+ break;
+ case event_watch_cond_except:
+ pfd->events = POLLERR|POLLHUP;
+ break;
+ }
- new_ew->pfd = (struct pollfd*) pfd;
- new_ew->cb = cb;
+ new_ew->pfd = (struct pollfd*) pfd;
+ new_ew->cb = cb;
- g_ptr_array_add (sdl_watch_list, (gpointer)new_ew);
+ g_ptr_array_add (sdl_watch_list, (gpointer)new_ew);
- event_sdl_watch_startthread(sdl_watch_list);
+ event_sdl_watch_startthread(sdl_watch_list);
- return new_ew;
+ return new_ew;
}
-static void
-event_sdl_remove_watch(struct event_watch *ew)
-{
- dbg(lvl_debug,"enter %p\n",ew);
+static void event_sdl_remove_watch(struct event_watch *ew) {
+ dbg(lvl_debug,"enter %p",ew);
- event_sdl_watch_stopthread();
+ event_sdl_watch_stopthread();
- g_ptr_array_remove (sdl_watch_list, ew);
- g_free (ew->pfd);
- g_free (ew);
+ g_ptr_array_remove (sdl_watch_list, ew);
+ g_free (ew->pfd);
+ g_free (ew);
- if (sdl_watch_list->len > 0)
- event_sdl_watch_startthread(sdl_watch_list);
+ if (sdl_watch_list->len > 0)
+ event_sdl_watch_startthread(sdl_watch_list);
}
/* Timeout */
-static struct event_timeout *
-event_sdl_add_timeout(int timeout, int multi, struct callback *cb)
-{
- struct event_timeout * ret = g_new0(struct event_timeout, 1);
- if(!ret) {
- dbg(lvl_error,"g_new0 failed\n");
- return ret;
- }
- dbg(lvl_debug,"timer(%p) multi(%d) interval(%d) cb(%p) added\n",ret, multi, timeout, cb);
- ret->multi = multi;
- ret->cb = cb;
- ret->id = SDL_AddTimer(timeout, sdl_timer_callback, ret);
-
- return ret;
+static struct event_timeout *event_sdl_add_timeout(int timeout, int multi, struct callback *cb) {
+ struct event_timeout * ret = g_new0(struct event_timeout, 1);
+ if(!ret) {
+ dbg(lvl_error,"g_new0 failed");
+ return ret;
+ }
+ dbg(lvl_debug,"timer(%p) multi(%d) interval(%d) cb(%p) added",ret, multi, timeout, cb);
+ ret->multi = multi;
+ ret->cb = cb;
+ ret->id = SDL_AddTimer(timeout, sdl_timer_callback, ret);
+
+ return ret;
}
-static void
-event_sdl_remove_timeout(struct event_timeout *to)
-{
- dbg(lvl_info,"enter %p\n", to);
- if(to)
- {
- /* do not SDL_RemoveTimer if oneshot timer has already fired */
- int ret = to->id == 0 ? SDL_TRUE : SDL_RemoveTimer(to->id);
-
- if (ret == SDL_FALSE)
- dbg(lvl_error,"SDL_RemoveTimer (%p) failed\n", to->id);
-
- g_free(to);
- dbg(lvl_debug,"timer(%p) removed\n", to);
- }
+static void event_sdl_remove_timeout(struct event_timeout *to) {
+ dbg(lvl_info,"enter %p", to);
+ if(to) {
+ /* do not SDL_RemoveTimer if oneshot timer has already fired */
+ int ret = to->id == 0 ? SDL_TRUE : SDL_RemoveTimer(to->id);
+
+ if (ret == SDL_FALSE)
+ dbg(lvl_error,"SDL_RemoveTimer (%p) failed", to->id);
+
+ g_free(to);
+ dbg(lvl_debug,"timer(%p) removed", to);
+ }
}
/* Idle */
/* sort ptr_array by priority, increasing order */
-static gint
-sdl_sort_idle_tasks(gconstpointer parama, gconstpointer paramb)
-{
- struct idle_task *a = (struct idle_task *)parama;
- struct idle_task *b = (struct idle_task *)paramb;
- if (a->priority < b->priority)
- return -1;
- if (a->priority > b->priority)
- return 1;
- return 0;
+static gint sdl_sort_idle_tasks(gconstpointer parama, gconstpointer paramb) {
+ struct idle_task *a = (struct idle_task *)parama;
+ struct idle_task *b = (struct idle_task *)paramb;
+ if (a->priority < b->priority)
+ return -1;
+ if (a->priority > b->priority)
+ return 1;
+ return 0;
}
-static struct event_idle *
-event_sdl_add_idle(int priority, struct callback *cb)
-{
- dbg(lvl_debug,"add idle priority(%d) cb(%p)\n", priority, cb);
+static struct event_idle *event_sdl_add_idle(int priority, struct callback *cb) {
+ dbg(lvl_debug,"add idle priority(%d) cb(%p)", priority, cb);
- struct idle_task *task = g_new0(struct idle_task, 1);
- task->priority = priority;
- task->cb = cb;
+ struct idle_task *task = g_new0(struct idle_task, 1);
+ task->priority = priority;
+ task->cb = cb;
- g_ptr_array_add(idle_tasks, (gpointer)task);
+ g_ptr_array_add(idle_tasks, (gpointer)task);
- if (idle_tasks->len < 2)
- {
- SDL_Event event;
- SDL_UserEvent userevent;
+ if (idle_tasks->len < 2) {
+ SDL_Event event;
+ SDL_UserEvent userevent;
- dbg(lvl_debug,"poking eventloop because of new idle_events\n");
+ dbg(lvl_debug,"poking eventloop because of new idle_events");
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_IDLE_EVENT;
- userevent.data1 = NULL;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_IDLE_EVENT;
+ userevent.data1 = NULL;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent (&event);
- }
- else // more than one entry => sort the list
- g_ptr_array_sort(idle_tasks, sdl_sort_idle_tasks);
+ SDL_PushEvent (&event);
+ } else // more than one entry => sort the list
+ g_ptr_array_sort(idle_tasks, sdl_sort_idle_tasks);
- return (struct event_idle *)task;
+ return (struct event_idle *)task;
}
-static void
-event_sdl_remove_idle(struct event_idle *task)
-{
- dbg(lvl_debug,"remove task(%p)\n", task);
- g_ptr_array_remove(idle_tasks, (gpointer)task);
+static void event_sdl_remove_idle(struct event_idle *task) {
+ dbg(lvl_debug,"remove task(%p)", task);
+ g_ptr_array_remove(idle_tasks, (gpointer)task);
}
/* callback */
-static void
-event_sdl_call_callback(struct callback_list *cbl)
-{
- dbg(lvl_debug,"call_callback cbl(%p)\n",cbl);
- SDL_Event event;
- SDL_UserEvent userevent;
+static void event_sdl_call_callback(struct callback_list *cbl) {
+ dbg(lvl_debug,"call_callback cbl(%p)",cbl);
+ SDL_Event event;
+ SDL_UserEvent userevent;
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_CALL_CALLBACK;
- userevent.data1 = cbl;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_CALL_CALLBACK;
+ userevent.data1 = cbl;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent (&event);
+ SDL_PushEvent (&event);
}
static struct event_methods event_sdl_methods = {
- event_sdl_main_loop_run,
- event_sdl_main_loop_quit,
- event_sdl_add_watch,
- event_sdl_remove_watch,
- event_sdl_add_timeout,
- event_sdl_remove_timeout,
- event_sdl_add_idle,
- event_sdl_remove_idle,
- event_sdl_call_callback,
+ event_sdl_main_loop_run,
+ event_sdl_main_loop_quit,
+ event_sdl_add_watch,
+ event_sdl_remove_watch,
+ event_sdl_add_timeout,
+ event_sdl_remove_timeout,
+ event_sdl_add_idle,
+ event_sdl_remove_idle,
+ event_sdl_call_callback,
};
-static struct event_priv *
-event_sdl_new(struct event_methods* methods)
-{
- idle_tasks = g_ptr_array_new();
- *methods = event_sdl_methods;
- return NULL;
+static struct event_priv *event_sdl_new(struct event_methods* methods) {
+ idle_tasks = g_ptr_array_new();
+ *methods = event_sdl_methods;
+ return NULL;
}
-void
-event_sdl_register(void)
-{
- plugin_register_category_event("sdl", event_sdl_new);
+void event_sdl_register(void) {
+ plugin_register_category_event("sdl", event_sdl_new);
}
diff --git a/navit/graphics/sdl/event_sdl.h b/navit/graphics/sdl/event_sdl.h
index 7dceedec5..ee47f60d9 100644
--- a/navit/graphics/sdl/event_sdl.h
+++ b/navit/graphics/sdl/event_sdl.h
@@ -2,7 +2,7 @@
#ifndef __EVENT_SDL_H
#define __EVENT_SDL_H
-#include <SDL/SDL.h>
+#include "SDL.h"
#include "config.h"
#include "callback.h"
#include "event.h"
diff --git a/navit/graphics/sdl/graphics_sdl.c b/navit/graphics/sdl/graphics_sdl.c
index b1a9c17b9..4187d4ed6 100644
--- a/navit/graphics/sdl/graphics_sdl.c
+++ b/navit/graphics/sdl/graphics_sdl.c
@@ -34,7 +34,7 @@
#include "callback.h"
#include "font/freetype/font_freetype.h"
-#include <SDL/SDL.h>
+#include "SDL.h"
#include <math.h>
#ifdef USE_WEBOS
@@ -56,7 +56,7 @@
#include "raster.h"
#include <event.h>
-#include <SDL/SDL_image.h>
+#include "SDL_image.h"
#include <alloca.h>
/* TODO: union overlay + non-overlay to reduce size */
@@ -182,23 +182,18 @@ struct graphics_image_priv {
};
-static void
-graphics_destroy(struct graphics_priv *gr)
-{
- dbg(lvl_debug, "graphics_destroy %p %u\n", gr, gr->overlay_mode);
+static void graphics_destroy(struct graphics_priv *gr) {
+ dbg(lvl_debug, "graphics_destroy %p %u", gr, gr->overlay_mode);
- if(gr->overlay_mode)
- {
+ if(gr->overlay_mode) {
SDL_FreeSurface(gr->screen);
gr->overlay_parent->overlay_array[gr->overlay_idx] = NULL;
- }
- else
- {
- g_free (ft_buffer);
- gr->freetype_methods.destroy();
+ } else {
+ g_free (ft_buffer);
+ gr->freetype_methods.destroy();
#ifdef USE_WEBOS_ACCELEROMETER
- SDL_JoystickClose(gr->accelerometer);
+ SDL_JoystickClose(gr->accelerometer);
#endif
#ifdef USE_WEBOS
PDL_Quit();
@@ -211,39 +206,29 @@ graphics_destroy(struct graphics_priv *gr)
/* graphics_gc */
-static void
-gc_destroy(struct graphics_gc_priv *gc)
-{
+static void gc_destroy(struct graphics_gc_priv *gc) {
g_free(gc);
}
-static void
-gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
- dbg(lvl_debug, "gc_set_linewidth %p %d\n", gc, w);
+static void gc_set_linewidth(struct graphics_gc_priv *gc, int w) {
+ dbg(lvl_debug, "gc_set_linewidth %p %d", gc, w);
gc->linewidth = w;
}
-static void
-gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
-{
+static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n) {
/* TODO */
}
-static void
-gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
- dbg(lvl_debug, "gc_set_foreground: %p %d %d %d %d\n", gc, c->a, c->r, c->g, c->b);
+static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c) {
+ dbg(lvl_debug, "gc_set_foreground: %p %d %d %d %d", gc, c->a, c->r, c->g, c->b);
gc->fore_r = c->r/256;
gc->fore_g = c->g/256;
gc->fore_b = c->b/256;
gc->fore_a = c->a/256;
}
-static void
-gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
- dbg(lvl_debug, "gc_set_background: %p %d %d %d %d\n", gc, c->a, c->r, c->g, c->b);
+static void gc_set_background(struct graphics_gc_priv *gc, struct color *c) {
+ dbg(lvl_debug, "gc_set_background: %p %d %d %d %d", gc, c->a, c->r, c->g, c->b);
gc->back_r = c->r/256;
gc->back_g = c->g/256;
gc->back_b = c->b/256;
@@ -258,8 +243,7 @@ static struct graphics_gc_methods gc_methods = {
gc_set_background
};
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
+static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) {
struct graphics_gc_priv *gc=g_new0(struct graphics_gc_priv, 1);
*meth=gc_methods;
gc->gr=gr;
@@ -268,18 +252,15 @@ static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics
}
-static struct graphics_image_priv *
-image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h,
- struct point *hot, int rotation)
-{
+static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name,
+ int *w, int *h, struct point *hot, int rotation) {
struct graphics_image_priv *gi;
/* FIXME: meth is not used yet.. so gi leaks. at least xpm is small */
gi = g_new0(struct graphics_image_priv, 1);
gi->img = IMG_Load(name);
- if(gi->img)
- {
+ if(gi->img) {
/* TBD: improves blit performance? */
#if !SDL_VERSION_ATLEAST(1,3,0)
SDL_SetColorKey(gi->img, SDL_RLEACCEL, gi->img->format->colorkey);
@@ -288,11 +269,9 @@ image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *n
*h=gi->img->h;
hot->x=*w/2;
hot->y=*h/2;
- }
- else
- {
+ } else {
/* TODO: debug "colour parse errors" on xpm */
- dbg(lvl_error,"image_new on '%s' failed: %s\n", name, IMG_GetError());
+ dbg(lvl_error,"image_new on '%s' failed: %s", name, IMG_GetError());
g_free(gi);
gi = NULL;
}
@@ -300,19 +279,15 @@ image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *n
return gi;
}
-static void
-image_free(struct graphics_priv *gr, struct graphics_image_priv * gi)
-{
+static void image_free(struct graphics_priv *gr, struct graphics_image_priv * gi) {
SDL_FreeSurface(gi->img);
g_free(gi);
}
-static void
-draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent && gr->overlay_parent->overlay_enable && !gr->overlay_enable) )
- {
- return;
+static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent
+ && gr->overlay_parent->overlay_enable && !gr->overlay_enable) ) {
+ return;
}
Sint16 *vx, *vy;
@@ -322,106 +297,90 @@ draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point
vx = alloca(count * sizeof(Sint16));
vy = alloca(count * sizeof(Sint16));
- for(i = 0; i < count; i++)
- {
+ for(i = 0; i < count; i++) {
x = (Sint16)p[i].x;
y = (Sint16)p[i].y;
vx[i] = x;
vy[i] = y;
- dbg(lvl_debug, "draw_polygon: %p %i %d,%d\n", gc, i, p[i].x, p[i].y);
+ dbg(lvl_debug, "draw_polygon: %p %i %d,%d", gc, i, p[i].x, p[i].y);
}
- if(gr->aa)
- {
+ if(gr->aa) {
raster_aapolygon(gr->screen, count, vx, vy,
- SDL_MapRGBA(gr->screen->format,
- gc->fore_r,
- gc->fore_g,
- gc->fore_b,
- gc->fore_a));
- }
- else
- {
+ SDL_MapRGBA(gr->screen->format,
+ gc->fore_r,
+ gc->fore_g,
+ gc->fore_b,
+ gc->fore_a));
+ } else {
raster_polygon(gr->screen, count, vx, vy,
- SDL_MapRGBA(gr->screen->format,
- gc->fore_r,
- gc->fore_g,
- gc->fore_b,
- gc->fore_a));
+ SDL_MapRGBA(gr->screen->format,
+ gc->fore_r,
+ gc->fore_g,
+ gc->fore_b,
+ gc->fore_a));
}
}
-static void
-draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
- if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent && gr->overlay_parent->overlay_enable && !gr->overlay_enable) )
- {
- return;
+static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
+ if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent
+ && gr->overlay_parent->overlay_enable && !gr->overlay_enable) ) {
+ return;
}
- dbg(lvl_debug, "draw_rectangle: %d %d %d %d r=%d g=%d b=%d a=%d\n", p->x, p->y, w, h,
- gc->fore_r, gc->fore_g, gc->fore_b, gc->fore_a);
- if(w > gr->screen->w)
- {
+ dbg(lvl_debug, "draw_rectangle: %d %d %d %d r=%d g=%d b=%d a=%d", p->x, p->y, w, h,
+ gc->fore_r, gc->fore_g, gc->fore_b, gc->fore_a);
+ if(w > gr->screen->w) {
w = gr->screen->w;
}
- if(h > gr->screen->h)
- {
+ if(h > gr->screen->h) {
h = gr->screen->h;
}
raster_rect(gr->screen, p->x, p->y, w, h,
- SDL_MapRGBA(gr->screen->format,
- gc->fore_r,
- gc->fore_g,
- gc->fore_b,
- gc->fore_a));
+ SDL_MapRGBA(gr->screen->format,
+ gc->fore_r,
+ gc->fore_g,
+ gc->fore_b,
+ gc->fore_a));
}
-static void
-draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
- if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent && gr->overlay_parent->overlay_enable && !gr->overlay_enable) )
- {
- return;
+static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r) {
+ if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent
+ && gr->overlay_parent->overlay_enable && !gr->overlay_enable) ) {
+ return;
}
/* FIXME: does not quite match gtk */
/* hack for osd compass.. why is this needed!? */
- if(gr->overlay_mode)
- {
+ if(gr->overlay_mode) {
r = r / 2;
}
- if(gr->aa)
- {
+ if(gr->aa) {
raster_aacircle(gr->screen, p->x, p->y, r,
- SDL_MapRGBA(gr->screen->format,
- gc->fore_r,
- gc->fore_g,
- gc->fore_b,
- gc->fore_a));
- }
- else
- {
+ SDL_MapRGBA(gr->screen->format,
+ gc->fore_r,
+ gc->fore_g,
+ gc->fore_b,
+ gc->fore_a));
+ } else {
raster_circle(gr->screen, p->x, p->y, r,
- SDL_MapRGBA(gr->screen->format,
- gc->fore_r,
- gc->fore_g,
- gc->fore_b,
- gc->fore_a));
+ SDL_MapRGBA(gr->screen->format,
+ gc->fore_r,
+ gc->fore_g,
+ gc->fore_b,
+ gc->fore_a));
}
}
-static void
-draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
- if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent && gr->overlay_parent->overlay_enable && !gr->overlay_enable) )
- {
- return;
+static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
+ if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent
+ && gr->overlay_parent->overlay_enable && !gr->overlay_enable) ) {
+ return;
}
/* you might expect lines to be simpler than the other shapes.
@@ -439,73 +398,58 @@ draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *
//int lw = 1;
int i;
- for(i = 0; i < count-1; i++)
- {
- float dx=p[i+1].x-p[i].x;
- float dy=p[i+1].y-p[i].y;
+ for(i = 0; i < count-1; i++) {
+ float dx=p[i+1].x-p[i].x;
+ float dy=p[i+1].y-p[i].y;
float angle;
int x_lw_adj, y_lw_adj;
- if(lw == 1)
- {
- if(gr->aa)
- {
+ if(lw == 1) {
+ if(gr->aa) {
raster_aaline(gr->screen, p[i].x, p[i].y, p[i+1].x, p[i+1].y,
- SDL_MapRGBA(gr->screen->format,
- gc->fore_r,
- gc->fore_g,
- gc->fore_b,
- gc->fore_a));
- }
- else
- {
+ SDL_MapRGBA(gr->screen->format,
+ gc->fore_r,
+ gc->fore_g,
+ gc->fore_b,
+ gc->fore_a));
+ } else {
raster_line(gr->screen, p[i].x, p[i].y, p[i+1].x, p[i+1].y,
- SDL_MapRGBA(gr->screen->format,
- gc->fore_r,
- gc->fore_g,
- gc->fore_b,
- gc->fore_a));
+ SDL_MapRGBA(gr->screen->format,
+ gc->fore_r,
+ gc->fore_g,
+ gc->fore_b,
+ gc->fore_a));
}
- }
- else
- {
+ } else {
/* there is probably a much simpler way but this works ok */
/* FIXME: float + double mixture */
/* FIXME: lrint(round())? */
- if(dy == 0.0)
- {
+ if(dy == 0.0) {
angle = 0.0;
x_lw_adj = 0;
y_lw_adj = round((float)lw/2.0);
- }
- else if(dx == 0.0)
- {
+ } else if(dx == 0.0) {
angle = 0.0;
x_lw_adj = round((float)lw/2.0);
y_lw_adj = 0;
- }
- else
- {
+ } else {
angle = (M_PI/2.0) - atan(abs(dx)/abs(dy));
x_lw_adj = round(sin(angle)*(float)lw/2.0);
y_lw_adj = round(cos(angle)*(float)lw/2.0);
- if((x_lw_adj < 0) || (y_lw_adj < 0))
- {
- dbg(lvl_debug, "i=%d\n", i);
- dbg(lvl_debug, " %d,%d->%d,%d\n", p[i].x, p[i].y, p[i+1].x, p[i+1].y);
- dbg(lvl_debug, " lw=%d angle=%f\n", lw, 180.0 * angle / M_PI);
- dbg(lvl_debug, " x_lw_adj=%d y_lw_adj=%d\n", x_lw_adj, y_lw_adj);
+ if((x_lw_adj < 0) || (y_lw_adj < 0)) {
+ dbg(lvl_debug, "i=%d", i);
+ dbg(lvl_debug, " %d,%d->%d,%d", p[i].x, p[i].y, p[i+1].x, p[i+1].y);
+ dbg(lvl_debug, " lw=%d angle=%f", lw, 180.0 * angle / M_PI);
+ dbg(lvl_debug, " x_lw_adj=%d y_lw_adj=%d", x_lw_adj, y_lw_adj);
}
}
- if(p[i+1].x > p[i].x)
- {
+ if(p[i+1].x > p[i].x) {
x_lw_adj = -x_lw_adj;
}
- if(p[i+1].y > p[i].y)
- {
+ if(p[i+1].y > p[i].y) {
y_lw_adj = -y_lw_adj;
}
@@ -530,10 +474,8 @@ draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *
/* FIXME: should just draw a half circle */
/* now some circular endcaps, if the width is over 2 */
- if(lw > 2)
- {
- if(i == 0)
- {
+ if(lw > 2) {
+ if(i == 0) {
draw_circle(gr, gc, &p[i], lw/2);
}
/* we truncate on the divide on purpose, so we don't go outside the line */
@@ -544,11 +486,9 @@ draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *
}
-static void
-set_pixel(SDL_Surface *surface, int x, int y, Uint8 r2, Uint8 g2, Uint8 b2, Uint8 a2)
-{
+static void set_pixel(SDL_Surface *surface, int x, int y, Uint8 r2, Uint8 g2, Uint8 b2, Uint8 a2) {
if(x<0 || y<0 || x>=surface->w || y>=surface->h) {
- return;
+ return;
}
void *target_pixel = ((Uint8*)surface->pixels + y * surface->pitch + x * surface->format->BytesPerPixel);
@@ -556,85 +496,79 @@ set_pixel(SDL_Surface *surface, int x, int y, Uint8 r2, Uint8 g2, Uint8 b2, Uint
Uint8 r1,g1,b1,a1;
switch(surface->format->BytesPerPixel) {
- case 2:
- {
- SDL_GetRGBA(*(Uint16 *)target_pixel, surface->format, &r1, &g1, &b1, &a1);
- *(Uint16 *)target_pixel = SDL_MapRGBA(surface->format,
- (r1*(0xff-a2)/0xff) + (r2*a2/0xff),
- (g1*(0xff-a2)/0xff) + (g2*a2/0xff),
- (b1*(0xff-a2)/0xff) + (b2*a2/0xff),
- a2 + a1*(0xff-a2)/0xff );
- break;
- }
- case 4:
- {
- SDL_GetRGBA(*(Uint32 *)target_pixel, surface->format, &r1, &g1, &b1, &a1);
- *(Uint32 *)target_pixel = SDL_MapRGBA(surface->format,
- (r1*(0xff-a2)/0xff) + (r2*a2/0xff),
- (g1*(0xff-a2)/0xff) + (g2*a2/0xff),
- (b1*(0xff-a2)/0xff) + (b2*a2/0xff),
- a2 + a1*(0xff-a2)/0xff );
- break;
- }
+ case 2: {
+ SDL_GetRGBA(*(Uint16 *)target_pixel, surface->format, &r1, &g1, &b1, &a1);
+ *(Uint16 *)target_pixel = SDL_MapRGBA(surface->format,
+ (r1*(0xff-a2)/0xff) + (r2*a2/0xff),
+ (g1*(0xff-a2)/0xff) + (g2*a2/0xff),
+ (b1*(0xff-a2)/0xff) + (b2*a2/0xff),
+ a2 + a1*(0xff-a2)/0xff );
+ break;
+ }
+ case 4: {
+ SDL_GetRGBA(*(Uint32 *)target_pixel, surface->format, &r1, &g1, &b1, &a1);
+ *(Uint32 *)target_pixel = SDL_MapRGBA(surface->format,
+ (r1*(0xff-a2)/0xff) + (r2*a2/0xff),
+ (g1*(0xff-a2)/0xff) + (g2*a2/0xff),
+ (b1*(0xff-a2)/0xff) + (b2*a2/0xff),
+ a2 + a1*(0xff-a2)/0xff );
+ break;
+ }
}
}
-static void
-resize_ft_buffer (unsigned int new_size)
-{
+static void resize_ft_buffer (unsigned int new_size) {
if (new_size > ft_buffer_size) {
- g_free (ft_buffer);
- ft_buffer = g_malloc (new_size);
- dbg(lvl_debug, "old_size(%u) new_size(%u) ft_buffer(%p)\n", ft_buffer_size, new_size, ft_buffer);
- ft_buffer_size = new_size;
+ g_free (ft_buffer);
+ ft_buffer = g_malloc (new_size);
+ dbg(lvl_debug, "old_size(%u) new_size(%u) ft_buffer(%p)", ft_buffer_size, new_size, ft_buffer);
+ ft_buffer_size = new_size;
}
}
-static void
-display_text_draw(struct font_freetype_text *text,
- struct graphics_priv *gr, struct graphics_gc_priv *fg,
- struct graphics_gc_priv *bg, int color, struct point *p)
-{
+static void display_text_draw(struct font_freetype_text *text, struct graphics_priv *gr, struct graphics_gc_priv *fg,
+ struct graphics_gc_priv *bg, int color, struct point *p) {
int i, x, y, stride;
struct font_freetype_glyph *g, **gp;
struct color transparent = { 0x0000, 0x0000, 0x0000, 0x0000 };
struct color black = { fg->fore_r * 255, fg->fore_g * 255,
- fg->fore_b * 255, fg->fore_a * 255 };
+ fg->fore_b * 255, fg->fore_a * 255
+ };
struct color white = { 0xffff, 0xffff, 0xffff, 0xffff };
if (bg) {
- if (COLOR_IS_WHITE(black) && COLOR_IS_BLACK(white)) {
- black.r = 65535;
- black.g = 65535;
- black.b = 65535;
- black.a = 65535;
-
- white.r = 0;
- white.g = 0;
- white.b = 0;
- white.a = 65535;
- } else if (COLOR_IS_BLACK(black) && COLOR_IS_WHITE(white)) {
- white.r = 65535;
- white.g = 65535;
- white.b = 65535;
- white.a = 65535;
-
- black.r = 0;
- black.g = 0;
- black.b = 0;
- black.a = 65535;
- } else {
- white.r = bg->fore_r * 255;
- white.g = bg->fore_g * 255;
- white.b = bg->fore_b * 255;
- white.a = bg->fore_a * 255;
- }
+ if (COLOR_IS_WHITE(black) && COLOR_IS_BLACK(white)) {
+ black.r = 65535;
+ black.g = 65535;
+ black.b = 65535;
+ black.a = 65535;
+
+ white.r = 0;
+ white.g = 0;
+ white.b = 0;
+ white.a = 65535;
+ } else if (COLOR_IS_BLACK(black) && COLOR_IS_WHITE(white)) {
+ white.r = 65535;
+ white.g = 65535;
+ white.b = 65535;
+ white.a = 65535;
+
+ black.r = 0;
+ black.g = 0;
+ black.b = 0;
+ black.a = 65535;
+ } else {
+ white.r = bg->fore_r * 255;
+ white.g = bg->fore_g * 255;
+ white.b = bg->fore_b * 255;
+ white.a = bg->fore_a * 255;
+ }
} else {
- white.r = 0;
- white.g = 0;
- white.b = 0;
- white.a = 0;
+ white.r = 0;
+ white.g = 0;
+ white.b = 0;
+ white.a = 0;
}
@@ -643,32 +577,32 @@ display_text_draw(struct font_freetype_text *text,
x = p->x << 6;
y = p->y << 6;
while (i-- > 0) {
- g = *gp++;
- if (g->w && g->h && bg) {
- stride = (g->w + 2) * 4;
- if (color) {
- resize_ft_buffer(stride * (g->h + 2));
- gr->freetype_methods.get_shadow(g, ft_buffer, stride, &white, &transparent);
-
- SDL_Surface *glyph_surface =
- SDL_CreateRGBSurfaceFrom(ft_buffer, g->w + 2, g->h + 2,
- 32,
- stride,
- 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
- if (glyph_surface) {
- SDL_Rect r;
- r.x = (x + g->x) >> 6;
- r.y = (y + g->y) >> 6;
- r.w = g->w + 2;
- r.h = g->h + 2;
-
- SDL_BlitSurface(glyph_surface, NULL, gr->screen, &r);
- SDL_FreeSurface(glyph_surface);
- }
- }
- }
- x += g->dx;
- y += g->dy;
+ g = *gp++;
+ if (g->w && g->h && bg) {
+ stride = (g->w + 2) * 4;
+ if (color) {
+ resize_ft_buffer(stride * (g->h + 2));
+ gr->freetype_methods.get_shadow(g, ft_buffer, stride, &white, &transparent);
+
+ SDL_Surface *glyph_surface =
+ SDL_CreateRGBSurfaceFrom(ft_buffer, g->w + 2, g->h + 2,
+ 32,
+ stride,
+ 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
+ if (glyph_surface) {
+ SDL_Rect r;
+ r.x = (x + g->x) >> 6;
+ r.y = (y + g->y) >> 6;
+ r.w = g->w + 2;
+ r.h = g->h + 2;
+
+ SDL_BlitSurface(glyph_surface, NULL, gr->screen, &r);
+ SDL_FreeSurface(glyph_surface);
+ }
+ }
+ }
+ x += g->dx;
+ y += g->dy;
}
gp = text->glyph;
@@ -676,80 +610,75 @@ display_text_draw(struct font_freetype_text *text,
x = p->x << 6;
y = p->y << 6;
while (i-- > 0) {
- g = *gp++;
- if (g->w && g->h) {
- if (color) {
- stride = g->w;
- if (bg) {
- resize_ft_buffer(stride * g->h * 4);
- gr->freetype_methods.get_glyph(g, ft_buffer,
- stride * 4, &black,
- &white, &transparent);
- SDL_Surface *glyph_surface =
- SDL_CreateRGBSurfaceFrom(ft_buffer, g->w, g->h, 32,
- stride * 4,
- 0x000000ff,0x0000ff00, 0x00ff0000,0xff000000);
- if (glyph_surface) {
- SDL_Rect r;
- r.x = (x + g->x) >> 6;
- r.y = (y + g->y) >> 6;
- r.w = g->w;
- r.h = g->h;
-
- SDL_BlitSurface(glyph_surface, NULL, gr->screen,&r);
- SDL_FreeSurface(glyph_surface);
- }
- }
- stride *= 4;
- resize_ft_buffer(stride * g->h);
- gr->freetype_methods.get_glyph(g, ft_buffer, stride,
- &black, &white,
- &transparent);
- int ii, jj;
- unsigned char* pGlyph = ft_buffer;
- for (jj = 0; jj < g->h; ++jj) {
- for (ii = 0; ii < g->w; ++ii) {
- if(*(pGlyph+3) > 0) {
+ g = *gp++;
+ if (g->w && g->h) {
+ if (color) {
+ stride = g->w;
+ if (bg) {
+ resize_ft_buffer(stride * g->h * 4);
+ gr->freetype_methods.get_glyph(g, ft_buffer,
+ stride * 4, &black,
+ &white, &transparent);
+ SDL_Surface *glyph_surface =
+ SDL_CreateRGBSurfaceFrom(ft_buffer, g->w, g->h, 32,
+ stride * 4,
+ 0x000000ff,0x0000ff00, 0x00ff0000,0xff000000);
+ if (glyph_surface) {
+ SDL_Rect r;
+ r.x = (x + g->x) >> 6;
+ r.y = (y + g->y) >> 6;
+ r.w = g->w;
+ r.h = g->h;
+
+ SDL_BlitSurface(glyph_surface, NULL, gr->screen,&r);
+ SDL_FreeSurface(glyph_surface);
+ }
+ }
+ stride *= 4;
+ resize_ft_buffer(stride * g->h);
+ gr->freetype_methods.get_glyph(g, ft_buffer, stride,
+ &black, &white,
+ &transparent);
+ int ii, jj;
+ unsigned char* pGlyph = ft_buffer;
+ for (jj = 0; jj < g->h; ++jj) {
+ for (ii = 0; ii < g->w; ++ii) {
+ if(*(pGlyph+3) > 0) {
set_pixel(gr->screen,
- ii+((x + g->x) >> 6),
- jj+((y + g->y) >> 6),
- *(pGlyph+2), // Pixels are in BGRA format
- *(pGlyph+1),
- *(pGlyph+0),
- *(pGlyph+3)
- );
+ ii+((x + g->x) >> 6),
+ jj+((y + g->y) >> 6),
+ *(pGlyph+2), // Pixels are in BGRA format
+ *(pGlyph+1),
+ *(pGlyph+0),
+ *(pGlyph+3)
+ );
}
pGlyph += 4;
- }
- }
- }
- }
- x += g->dx;
- y += g->dy;
+ }
+ }
+ }
+ }
+ x += g->dx;
+ y += g->dy;
}
}
-static void
-draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg,
- struct graphics_gc_priv *bg, struct graphics_font_priv *font,
- char *text, struct point *p, int dx, int dy)
-{
+static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg,
+ struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable)
- || (gr->overlay_parent && gr->overlay_parent->overlay_enable
- && !gr->overlay_enable)) {
- return;
+ || (gr->overlay_parent && gr->overlay_parent->overlay_enable
+ && !gr->overlay_enable)) {
+ return;
}
struct font_freetype_text *t;
int color = 1;
if (!font) {
- dbg(lvl_error, "no font, returning\n");
- return;
+ dbg(lvl_error, "no font, returning");
+ return;
}
- t = gr->freetype_methods.text_new(text,
- (struct font_freetype_font *) font,
- dx, dy);
+ t = gr->freetype_methods.text_new(text, (struct font_freetype_font *) font, dx, dy);
struct point p_eff;
p_eff.x = p->x;
@@ -759,12 +688,11 @@ draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg,
gr->freetype_methods.text_destroy(t);
}
-static void
-draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
- if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent && gr->overlay_parent->overlay_enable && !gr->overlay_enable) )
- {
- return;
+static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p,
+ struct graphics_image_priv *img) {
+ if ((gr->overlay_parent && !gr->overlay_parent->overlay_enable) || (gr->overlay_parent
+ && gr->overlay_parent->overlay_enable && !gr->overlay_enable) ) {
+ return;
}
SDL_Rect r;
@@ -777,45 +705,33 @@ draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *
SDL_BlitSurface(img->img, NULL, gr->screen, &r);
}
-static void
-background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
- dbg(lvl_debug, "background_gc\n");
+static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
+ dbg(lvl_debug, "background_gc");
}
-static void
-draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
+static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode) {
struct graphics_priv *ov;
SDL_Rect rect;
int i;
- if(gr->overlay_mode)
- {
+ if(gr->overlay_mode) {
/* will be drawn below */
- }
- else
- {
- dbg(lvl_debug, "draw_mode: %d\n", mode);
-
- if(mode == draw_mode_end)
- {
- if((gr->draw_mode == draw_mode_begin) && gr->overlay_enable)
- {
- for(i = 0; i < OVERLAY_MAX; i++)
- {
+ } else {
+ dbg(lvl_debug, "draw_mode: %d", mode);
+
+ if(mode == draw_mode_end) {
+ if((gr->draw_mode == draw_mode_begin) && gr->overlay_enable) {
+ for(i = 0; i < OVERLAY_MAX; i++) {
ov = gr->overlay_array[i];
- if(ov && ov->overlay_enable)
- {
+ if(ov && ov->overlay_enable) {
rect.x = ov->overlay_x;
if(rect.x<0) rect.x += gr->screen->w;
rect.y = ov->overlay_y;
if(rect.y<0) rect.y += gr->screen->h;
rect.w = ov->screen->w;
rect.h = ov->screen->h;
- SDL_BlitSurface(ov->screen, NULL,
- gr->screen, &rect);
+ SDL_BlitSurface(ov->screen, NULL, gr->screen, &rect);
}
}
}
@@ -827,61 +743,55 @@ draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
}
}
-static void overlay_disable(struct graphics_priv *gr, int disable)
-{
+static void overlay_disable(struct graphics_priv *gr, int disable) {
gr->overlay_enable = !disable;
struct graphics_priv *curr_gr = gr;
if(gr->overlay_parent) {
- curr_gr = gr->overlay_parent;
+ curr_gr = gr->overlay_parent;
}
draw_mode(curr_gr,draw_mode_end);
}
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound);
+static struct graphics_priv *overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p,
+ int w, int h, int wraparound);
-static int window_fullscreen(struct window *win, int on)
-{
+static int window_fullscreen(struct window *win, int on) {
struct graphics_priv *gr=(struct graphics_priv *)win->priv;
/* Update video flags */
if(on) {
- gr->video_flags |= SDL_FULLSCREEN;
+ gr->video_flags |= SDL_FULLSCREEN;
} else {
- gr->video_flags &= ~SDL_FULLSCREEN;
+ gr->video_flags &= ~SDL_FULLSCREEN;
}
/* Update video mode */
gr->screen = SDL_SetVideoMode(gr->screen->w, gr->screen->h, gr->video_bpp, gr->video_flags);
if(gr->screen == NULL) {
- navit_destroy(gr->nav);
- }
- else {
- callback_list_call_attr_2(gr->cbl, attr_resize, GINT_TO_POINTER(gr->screen->w), GINT_TO_POINTER(gr->screen->h));
+ navit_destroy(gr->nav);
+ } else {
+ callback_list_call_attr_2(gr->cbl, attr_resize, GINT_TO_POINTER(gr->screen->w), GINT_TO_POINTER(gr->screen->h));
}
return 1;
}
-static void *
-get_data(struct graphics_priv *this, char const *type)
-{
+static void *get_data(struct graphics_priv *this, char const *type) {
if(strcmp(type, "window") == 0) {
- struct window *win;
- win=g_new(struct window, 1);
- win->priv=this;
- win->fullscreen=window_fullscreen;
- win->disable_suspend=NULL;
- return win;
+ struct window *win;
+ win=g_new(struct window, 1);
+ win->priv=this;
+ win->fullscreen=window_fullscreen;
+ win->disable_suspend=NULL;
+ return win;
} else {
- return NULL;
+ return NULL;
}
}
-static void draw_drag(struct graphics_priv *gr, struct point *p)
-{
+static void draw_drag(struct graphics_priv *gr, struct point *p) {
if(p) {
- gr->overlay_x = p->x;
- gr->overlay_y = p->y;
+ gr->overlay_x = p->x;
+ gr->overlay_y = p->y;
}
}
@@ -907,74 +817,70 @@ static struct graphics_methods graphics_methods = {
overlay_disable,
NULL, /* overlay_resize */
NULL, /* set_attr */
- NULL, /* show_native_keyboard */
- NULL, /* hide_native_keyboard */
+ NULL, /* show_native_keyboard */
+ NULL, /* hide_native_keyboard */
};
-static struct graphics_priv *
-overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h,int wraparound)
-{
+static struct graphics_priv *overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p,
+ int w, int h,int wraparound) {
struct graphics_priv *ov;
Uint32 rmask, gmask, bmask, amask;
int i;
- for(i = 0; i < OVERLAY_MAX; i++)
- {
- if(gr->overlay_array[i] == NULL)
- {
- break;
- }
+ for(i = 0; i < OVERLAY_MAX; i++) {
+ if(gr->overlay_array[i] == NULL) {
+ break;
+ }
}
- if(i == OVERLAY_MAX)
- {
- dbg(lvl_error, "too many overlays! increase OVERLAY_MAX\n");
- return NULL;
+ if(i == OVERLAY_MAX) {
+ dbg(lvl_error, "too many overlays! increase OVERLAY_MAX");
+ return NULL;
}
- dbg(lvl_debug, "overlay_new %d %d %d %u %u (%x, %x, %x ,%x, %d)\n", i,
- p->x,
- p->y,
- w,
- h,
- gr->screen->format->Rmask,
- gr->screen->format->Gmask,
- gr->screen->format->Bmask,
- gr->screen->format->Amask,
- gr->screen->format->BitsPerPixel
+ dbg(lvl_debug, "overlay_new %d %d %d %u %u (%x, %x, %x ,%x, %d)", i,
+ p->x,
+ p->y,
+ w,
+ h,
+ gr->screen->format->Rmask,
+ gr->screen->format->Gmask,
+ gr->screen->format->Bmask,
+ gr->screen->format->Amask,
+ gr->screen->format->BitsPerPixel
);
ov = g_new0(struct graphics_priv, 1);
switch(gr->screen->format->BitsPerPixel) {
- case 8:
- rmask = 0xc0;
- gmask = 0x30;
- bmask = 0x0c;
- amask = 0x03;
- break;
- case 16:
- rmask = 0xf000;
- gmask = 0x0f00;
- bmask = 0x00f0;
- amask = 0x000f;
- break;
- case 32:
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
- break;
- default:
- rmask = gr->screen->format->Rmask;
- gmask = gr->screen->format->Gmask;
- bmask = gr->screen->format->Bmask;
- amask = gr->screen->format->Amask;
+ case 8:
+ rmask = 0xc0;
+ gmask = 0x30;
+ bmask = 0x0c;
+ amask = 0x03;
+ break;
+ case 16:
+ rmask = 0xf000;
+ gmask = 0x0f00;
+ bmask = 0x00f0;
+ amask = 0x000f;
+ break;
+ case 32:
+ rmask = 0xff000000;
+ gmask = 0x00ff0000;
+ bmask = 0x0000ff00;
+ amask = 0x000000ff;
+ break;
+ default:
+ rmask = gr->screen->format->Rmask;
+ gmask = gr->screen->format->Gmask;
+ bmask = gr->screen->format->Bmask;
+ amask = gr->screen->format->Amask;
}
ov->screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
- w, h,
- gr->screen->format->BitsPerPixel,
- rmask, gmask, bmask, amask);
+ w, h,
+ gr->screen->format->BitsPerPixel,
+ rmask, gmask, bmask, amask);
ov->overlay_mode = 1;
ov->overlay_enable = 1;
@@ -988,9 +894,8 @@ overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct poin
struct font_priv *(*font_freetype_new) (void *meth);
font_freetype_new = plugin_get_category_font ("freetype");
- if (!font_freetype_new)
- {
- return NULL;
+ if (!font_freetype_new) {
+ return NULL;
}
@@ -999,9 +904,9 @@ overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct poin
*meth=graphics_methods;
meth->font_new =
- (struct graphics_font_priv *
- (*)(struct graphics_priv *, struct graphics_font_methods *, char *, int,
- int)) ov->freetype_methods.font_new;
+ (struct graphics_font_priv *
+ (*)(struct graphics_priv *, struct graphics_font_methods *, char *, int,
+ int)) ov->freetype_methods.font_new;
meth->get_text_bbox = (void *)ov->freetype_methods.get_text_bbox;
@@ -1010,8 +915,7 @@ overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct poin
return ov;
}
-static gboolean graphics_sdl_idle(void *data)
-{
+static gboolean graphics_sdl_idle(void *data) {
struct graphics_priv *gr = (struct graphics_priv *)data;
struct point p;
SDL_Event ev;
@@ -1021,13 +925,12 @@ static gboolean graphics_sdl_idle(void *data)
#ifdef USE_WEBOS
if(data==NULL) {
- if(the_graphics!=NULL) {
- gr = the_graphics;
- }
- else {
- dbg(lvl_error,"graphics_idle: graphics not set!\n");
- return FALSE;
- }
+ if(the_graphics!=NULL) {
+ gr = the_graphics;
+ } else {
+ dbg(lvl_error,"graphics_idle: graphics not set!");
+ return FALSE;
+ }
}
#endif
@@ -1037,9 +940,8 @@ static gboolean graphics_sdl_idle(void *data)
graphics_gtk does it during Configure, but SDL does not have
an equivalent event, so we use our own flag
*/
- if(gr->resize_callback_initial != 0)
- {
- callback_list_call_attr_2(gr->cbl, attr_resize, GINT_TO_POINTER(gr->screen->w), GINT_TO_POINTER(gr->screen->h));
+ if(gr->resize_callback_initial != 0) {
+ callback_list_call_attr_2(gr->cbl, attr_resize, GINT_TO_POINTER(gr->screen->w), GINT_TO_POINTER(gr->screen->h));
gr->resize_callback_initial = 0;
}
@@ -1047,8 +949,8 @@ static gboolean graphics_sdl_idle(void *data)
struct callback* accel_cb = NULL;
struct event_timeout* accel_to = NULL;
if (PDL_GetPDKVersion() > 100) {
- accel_cb = callback_new_1(callback_cast(sdl_accelerometer_handler), gr);
- accel_to = event_add_timeout(200, 1, accel_cb);
+ accel_cb = callback_new_1(callback_cast(sdl_accelerometer_handler), gr);
+ accel_to = event_add_timeout(200, 1, accel_cb);
}
#endif
#ifdef USE_WEBOS
@@ -1062,321 +964,307 @@ static gboolean graphics_sdl_idle(void *data)
#endif
{
#ifdef USE_WEBOS
- ret = 0;
- if(idle_tasks->len > 0)
- {
- while (!(ret = SDL_PollEvent(&ev)) && idle_tasks->len > 0)
- {
- if (idle_tasks_idx >= idle_tasks->len)
- idle_tasks_idx = 0;
-
- dbg(lvl_debug,"idle_tasks_idx(%d)\n",idle_tasks_idx);
- task = (struct idle_task *)g_ptr_array_index(idle_tasks,idle_tasks_idx);
-
- if (idle_tasks_idx == 0) // only execute tasks with lowest priority value
- idle_tasks_cur_priority = task->priority;
- if (task->priority > idle_tasks_cur_priority)
- idle_tasks_idx = 0;
- else
- {
- callback_call_0(task->cb);
- idle_tasks_idx++;
- }
- }
- }
- if (!ret) // If we get here there are no idle_tasks and we have no events pending
- ret = SDL_WaitEvent(&ev);
+ ret = 0;
+ if(idle_tasks->len > 0) {
+ while (!(ret = SDL_PollEvent(&ev)) && idle_tasks->len > 0) {
+ if (idle_tasks_idx >= idle_tasks->len)
+ idle_tasks_idx = 0;
+
+ dbg(lvl_debug,"idle_tasks_idx(%d)",idle_tasks_idx);
+ task = (struct idle_task *)g_ptr_array_index(idle_tasks,idle_tasks_idx);
+
+ if (idle_tasks_idx == 0) // only execute tasks with lowest priority value
+ idle_tasks_cur_priority = task->priority;
+ if (task->priority > idle_tasks_cur_priority)
+ idle_tasks_idx = 0;
+ else {
+ callback_call_0(task->cb);
+ idle_tasks_idx++;
+ }
+ }
+ }
+ if (!ret) // If we get here there are no idle_tasks and we have no events pending
+ ret = SDL_WaitEvent(&ev);
#else
- ret = SDL_PollEvent(&ev);
+ ret = SDL_PollEvent(&ev);
#endif
- if(ret == 0)
- {
- break;
- }
+ if(ret == 0) {
+ break;
+ }
#ifdef USE_WEBOS
- dbg(lvl_debug,"SDL_Event %d\n", ev.type);
+ dbg(lvl_debug,"SDL_Event %d", ev.type);
#endif
- switch(ev.type)
- {
- case SDL_MOUSEMOTION:
- {
- p.x = ev.motion.x;
- p.y = ev.motion.y;
- callback_list_call_attr_1(gr->cbl, attr_motion, (void *)&p);
- break;
- }
-
- case SDL_KEYDOWN:
- {
- memset(keybuf, 0, sizeof(keybuf));
- switch(ev.key.keysym.sym)
- {
- case SDLK_LEFT:
- {
- keybuf[0] = NAVIT_KEY_LEFT;
- break;
- }
- case SDLK_RIGHT:
- {
- keybuf[0] = NAVIT_KEY_RIGHT;
- break;
- }
- case SDLK_BACKSPACE:
- {
- keybuf[0] = NAVIT_KEY_BACKSPACE;
- break;
- }
- case SDLK_RETURN:
- {
- keybuf[0] = NAVIT_KEY_RETURN;
- break;
- }
- case SDLK_DOWN:
- {
- keybuf[0] = NAVIT_KEY_DOWN;
- break;
- }
- case SDLK_PAGEUP:
- {
- keybuf[0] = NAVIT_KEY_ZOOM_OUT;
- break;
- }
- case SDLK_UP:
- {
- keybuf[0] = NAVIT_KEY_UP;
- break;
- }
- case SDLK_PAGEDOWN:
- {
- keybuf[0] = NAVIT_KEY_ZOOM_IN;
- break;
- }
+ switch(ev.type) {
+ case SDL_MOUSEMOTION: {
+ p.x = ev.motion.x;
+ p.y = ev.motion.y;
+ callback_list_call_attr_1(gr->cbl, attr_motion, (void *)&p);
+ break;
+ }
+
+ case SDL_KEYDOWN: {
+ memset(keybuf, 0, sizeof(keybuf));
+ switch(ev.key.keysym.sym) {
+ case SDLK_LEFT: {
+ keybuf[0] = NAVIT_KEY_LEFT;
+ break;
+ }
+ case SDLK_RIGHT: {
+ keybuf[0] = NAVIT_KEY_RIGHT;
+ break;
+ }
+ case SDLK_BACKSPACE: {
+ keybuf[0] = NAVIT_KEY_BACKSPACE;
+ break;
+ }
+ case SDLK_RETURN: {
+ keybuf[0] = NAVIT_KEY_RETURN;
+ break;
+ }
+ case SDLK_DOWN: {
+ keybuf[0] = NAVIT_KEY_DOWN;
+ break;
+ }
+ case SDLK_PAGEUP: {
+ keybuf[0] = NAVIT_KEY_ZOOM_OUT;
+ break;
+ }
+ case SDLK_UP: {
+ keybuf[0] = NAVIT_KEY_UP;
+ break;
+ }
+ case SDLK_PAGEDOWN: {
+ keybuf[0] = NAVIT_KEY_ZOOM_IN;
+ break;
+ }
#ifdef USE_WEBOS
- case WEBOS_KEY_SHIFT:
- {
- if ((key_mod & WEBOS_KEY_MOD_SHIFT_STICKY) == WEBOS_KEY_MOD_SHIFT_STICKY)
- key_mod &= ~(WEBOS_KEY_MOD_SHIFT_STICKY);
- else if ((key_mod & WEBOS_KEY_MOD_SHIFT) == WEBOS_KEY_MOD_SHIFT)
- key_mod |= WEBOS_KEY_MOD_SHIFT_STICKY;
- else
- key_mod |= WEBOS_KEY_MOD_SHIFT;
- break;
- }
- case WEBOS_KEY_ORANGE:
- {
- if ((key_mod & WEBOS_KEY_MOD_ORANGE_STICKY) == WEBOS_KEY_MOD_ORANGE_STICKY)
- key_mod &= ~(WEBOS_KEY_MOD_ORANGE_STICKY);
- else if ((key_mod & WEBOS_KEY_MOD_ORANGE) == WEBOS_KEY_MOD_ORANGE)
- key_mod |= WEBOS_KEY_MOD_ORANGE_STICKY;
- else
- key_mod |= WEBOS_KEY_MOD_ORANGE;
- break;
- }
- case WEBOS_KEY_SYM:
- {
- /* Toggle the on-screen keyboard */
- //callback_list_call_attr_1(gr->cbl, attr_keyboard_toggle); // Not implemented yet
- break;
- }
- case PDLK_GESTURE_BACK:
- {
- keybuf[0] = NAVIT_KEY_BACK;
- break;
- }
- case PDLK_GESTURE_FORWARD:
- case PDLK_GESTURE_AREA:
- {
- break;
- }
+ case WEBOS_KEY_SHIFT: {
+ if ((key_mod & WEBOS_KEY_MOD_SHIFT_STICKY) == WEBOS_KEY_MOD_SHIFT_STICKY)
+ key_mod &= ~(WEBOS_KEY_MOD_SHIFT_STICKY);
+ else if ((key_mod & WEBOS_KEY_MOD_SHIFT) == WEBOS_KEY_MOD_SHIFT)
+ key_mod |= WEBOS_KEY_MOD_SHIFT_STICKY;
+ else
+ key_mod |= WEBOS_KEY_MOD_SHIFT;
+ break;
+ }
+ case WEBOS_KEY_ORANGE: {
+ if ((key_mod & WEBOS_KEY_MOD_ORANGE_STICKY) == WEBOS_KEY_MOD_ORANGE_STICKY)
+ key_mod &= ~(WEBOS_KEY_MOD_ORANGE_STICKY);
+ else if ((key_mod & WEBOS_KEY_MOD_ORANGE) == WEBOS_KEY_MOD_ORANGE)
+ key_mod |= WEBOS_KEY_MOD_ORANGE_STICKY;
+ else
+ key_mod |= WEBOS_KEY_MOD_ORANGE;
+ break;
+ }
+ case WEBOS_KEY_SYM: {
+ /* Toggle the on-screen keyboard */
+ //callback_list_call_attr_1(gr->cbl, attr_keyboard_toggle); // Not implemented yet
+ break;
+ }
+ case PDLK_GESTURE_BACK: {
+ keybuf[0] = NAVIT_KEY_BACK;
+ break;
+ }
+ case PDLK_GESTURE_FORWARD:
+ case PDLK_GESTURE_AREA: {
+ break;
+ }
#endif
- default:
- {
+ default: {
#ifdef USE_WEBOS
- if (ev.key.keysym.unicode < 0x80 && ev.key.keysym.unicode > 0) {
- keybuf[0] = (char)ev.key.keysym.unicode;
- if ((key_mod & WEBOS_KEY_MOD_ORANGE) == WEBOS_KEY_MOD_ORANGE) {
- switch(keybuf[0]) {
- case 'e': keybuf[0] = '1'; break;
- case 'r': keybuf[0] = '2'; break;
- case 't': keybuf[0] = '3'; break;
- case 'd': keybuf[0] = '4'; break;
- case 'f': keybuf[0] = '5'; break;
- case 'g': keybuf[0] = '6'; break;
- case 'x': keybuf[0] = '7'; break;
- case 'c': keybuf[0] = '8'; break;
- case 'v': keybuf[0] = '9'; break;
- case '@': keybuf[0] = '0'; break;
- case ',': keybuf[0] = '-'; break;
- case 'u': strncpy(keybuf, "ü", sizeof(keybuf)); break;
- case 'a': strncpy(keybuf, "ä", sizeof(keybuf)); break;
- case 'o': strncpy(keybuf, "ö", sizeof(keybuf)); break;
- case 's': strncpy(keybuf, "ß", sizeof(keybuf)); break;
- }
-}
- if ((key_mod & WEBOS_KEY_MOD_SHIFT_STICKY) != WEBOS_KEY_MOD_SHIFT_STICKY)
- key_mod &= ~(WEBOS_KEY_MOD_SHIFT_STICKY);
- if ((key_mod & WEBOS_KEY_MOD_ORANGE_STICKY) != WEBOS_KEY_MOD_ORANGE_STICKY)
- key_mod &= ~(WEBOS_KEY_MOD_ORANGE_STICKY);
- }
- else {
- dbg(lvl_error,"Unknown key sym: %x\n", ev.key.keysym.sym);
- }
+ if (ev.key.keysym.unicode < 0x80 && ev.key.keysym.unicode > 0) {
+ keybuf[0] = (char)ev.key.keysym.unicode;
+ if ((key_mod & WEBOS_KEY_MOD_ORANGE) == WEBOS_KEY_MOD_ORANGE) {
+ switch(keybuf[0]) {
+ case 'e':
+ keybuf[0] = '1';
+ break;
+ case 'r':
+ keybuf[0] = '2';
+ break;
+ case 't':
+ keybuf[0] = '3';
+ break;
+ case 'd':
+ keybuf[0] = '4';
+ break;
+ case 'f':
+ keybuf[0] = '5';
+ break;
+ case 'g':
+ keybuf[0] = '6';
+ break;
+ case 'x':
+ keybuf[0] = '7';
+ break;
+ case 'c':
+ keybuf[0] = '8';
+ break;
+ case 'v':
+ keybuf[0] = '9';
+ break;
+ case '@':
+ keybuf[0] = '0';
+ break;
+ case ',':
+ keybuf[0] = '-';
+ break;
+ case 'u':
+ strncpy(keybuf, "ü", sizeof(keybuf));
+ break;
+ case 'a':
+ strncpy(keybuf, "ä", sizeof(keybuf));
+ break;
+ case 'o':
+ strncpy(keybuf, "ö", sizeof(keybuf));
+ break;
+ case 's':
+ strncpy(keybuf, "ß", sizeof(keybuf));
+ break;
+ }
+ }
+ if ((key_mod & WEBOS_KEY_MOD_SHIFT_STICKY) != WEBOS_KEY_MOD_SHIFT_STICKY)
+ key_mod &= ~(WEBOS_KEY_MOD_SHIFT_STICKY);
+ if ((key_mod & WEBOS_KEY_MOD_ORANGE_STICKY) != WEBOS_KEY_MOD_ORANGE_STICKY)
+ key_mod &= ~(WEBOS_KEY_MOD_ORANGE_STICKY);
+ } else {
+ dbg(lvl_error,"Unknown key sym: %x", ev.key.keysym.sym);
+ }
#else
- /* return unicode chars when they can be converted to ascii */
- keybuf[0] = ev.key.keysym.unicode<=127 ? ev.key.keysym.unicode : 0;
+ /* return unicode chars when they can be converted to ascii */
+ keybuf[0] = ev.key.keysym.unicode<=127 ? ev.key.keysym.unicode : 0;
#endif
- break;
- }
- }
-
- dbg(lvl_info,"key mod: 0x%x\n", key_mod);
-
- if (keybuf[0]) {
- callback_list_call_attr_1(gr->cbl, attr_keypress, (void *)keybuf);
- }
- break;
- }
-
- case SDL_KEYUP:
- {
- break;
- }
-
- case SDL_MOUSEBUTTONDOWN:
- {
- dbg(lvl_debug, "SDL_MOUSEBUTTONDOWN %d %d %d %d %d\n",
- ev.button.which,
- ev.button.button,
- ev.button.state,
- ev.button.x,
- ev.button.y);
-
- p.x = ev.button.x;
- p.y = ev.button.y;
- callback_list_call_attr_3(gr->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER((int)ev.button.button), (void *)&p);
- break;
- }
-
- case SDL_MOUSEBUTTONUP:
- {
- dbg(lvl_debug, "SDL_MOUSEBUTTONUP %d %d %d %d %d\n",
- ev.button.which,
- ev.button.button,
- ev.button.state,
- ev.button.x,
- ev.button.y);
-
- p.x = ev.button.x;
- p.y = ev.button.y;
- callback_list_call_attr_3(gr->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER((int)ev.button.button), (void *)&p);
- break;
- }
-
- case SDL_QUIT:
- {
+ break;
+ }
+ }
+
+ dbg(lvl_info,"key mod: 0x%x", key_mod);
+
+ if (keybuf[0]) {
+ callback_list_call_attr_1(gr->cbl, attr_keypress, (void *)keybuf);
+ }
+ break;
+ }
+
+ case SDL_KEYUP: {
+ break;
+ }
+
+ case SDL_MOUSEBUTTONDOWN: {
+ dbg(lvl_debug, "SDL_MOUSEBUTTONDOWN %d %d %d %d %d",
+ ev.button.which,
+ ev.button.button,
+ ev.button.state,
+ ev.button.x,
+ ev.button.y);
+
+ p.x = ev.button.x;
+ p.y = ev.button.y;
+ callback_list_call_attr_3(gr->cbl, attr_button, GINT_TO_POINTER(1), GINT_TO_POINTER((int)ev.button.button), (void *)&p);
+ break;
+ }
+
+ case SDL_MOUSEBUTTONUP: {
+ dbg(lvl_debug, "SDL_MOUSEBUTTONUP %d %d %d %d %d",
+ ev.button.which,
+ ev.button.button,
+ ev.button.state,
+ ev.button.x,
+ ev.button.y);
+
+ p.x = ev.button.x;
+ p.y = ev.button.y;
+ callback_list_call_attr_3(gr->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER((int)ev.button.button), (void *)&p);
+ break;
+ }
+
+ case SDL_QUIT: {
#ifdef USE_WEBOS
- quit_event_loop = 1;
- navit_destroy(gr->nav);
+ quit_event_loop = 1;
+ navit_destroy(gr->nav);
+#else
+ callback_list_call_attr_0(gr->cbl, attr_window_closed);
#endif
- break;
- }
+ break;
+ }
- case SDL_VIDEORESIZE:
- {
+ case SDL_VIDEORESIZE: {
- gr->screen = SDL_SetVideoMode(ev.resize.w, ev.resize.h, gr->video_bpp, gr->video_flags);
- if(gr->screen == NULL)
- {
- navit_destroy(gr->nav);
- }
- else
- {
- callback_list_call_attr_2(gr->cbl, attr_resize, GINT_TO_POINTER(gr->screen->w), GINT_TO_POINTER(gr->screen->h));
- }
+ gr->screen = SDL_SetVideoMode(ev.resize.w, ev.resize.h, gr->video_bpp, gr->video_flags);
+ if(gr->screen == NULL) {
+ navit_destroy(gr->nav);
+ } else {
+ callback_list_call_attr_2(gr->cbl, attr_resize, GINT_TO_POINTER(gr->screen->w), GINT_TO_POINTER(gr->screen->h));
+ }
- break;
- }
+ break;
+ }
#ifdef USE_WEBOS
- case SDL_USEREVENT:
- {
- SDL_UserEvent userevent = ev.user;
- dbg(lvl_info,"received SDL_USEREVENT type(%x) code(%x)\n",userevent.type,userevent.code);
- if (userevent.type != SDL_USEREVENT)
- break;
-
- if (userevent.code == PDL_GPS_UPDATE)
- {
- struct attr vehicle_attr;
- struct vehicle *v;
- navit_get_attr(gr->nav, attr_vehicle, &vehicle_attr, NULL);
- v = vehicle_attr.u.vehicle;
- if (v) {
- struct attr attr;
- attr.type = attr_pdl_gps_update;
- attr.u.data = userevent.data1;
- vehicle_set_attr(v, &attr);
- }
- }
- else if(userevent.code == SDL_USEREVENT_CODE_TIMER)
- {
- struct callback *cb = (struct callback *)userevent.data1;
- dbg(lvl_debug, "SDL_USEREVENT timer received cb(%p)\n", cb);
- callback_call_0(cb);
- }
- else if(userevent.code == SDL_USEREVENT_CODE_WATCH)
- {
- struct callback *cb = (struct callback *)userevent.data1;
- dbg(lvl_debug, "SDL_USEREVENT watch received cb(%p)\n", cb);
- callback_call_0(cb);
- }
- else if(userevent.code == SDL_USEREVENT_CODE_CALL_CALLBACK)
- {
- struct callback_list *cbl = (struct callback_list *)userevent.data1;
- dbg(lvl_debug, "SDL_USEREVENT call_callback received cbl(%p)\n", cbl);
- callback_list_call_0(cbl);
- }
- else if(userevent.code == SDL_USEREVENT_CODE_IDLE_EVENT) {
- dbg(lvl_debug, "SDL_USEREVENT idle_event received\n");
- }
+ case SDL_USEREVENT: {
+ SDL_UserEvent userevent = ev.user;
+ dbg(lvl_info,"received SDL_USEREVENT type(%x) code(%x)",userevent.type,userevent.code);
+ if (userevent.type != SDL_USEREVENT)
+ break;
+
+ if (userevent.code == PDL_GPS_UPDATE) {
+ struct attr vehicle_attr;
+ struct vehicle *v;
+ navit_get_attr(gr->nav, attr_vehicle, &vehicle_attr, NULL);
+ v = vehicle_attr.u.vehicle;
+ if (v) {
+ struct attr attr;
+ attr.type = attr_pdl_gps_update;
+ attr.u.data = userevent.data1;
+ vehicle_set_attr(v, &attr);
+ }
+ } else if(userevent.code == SDL_USEREVENT_CODE_TIMER) {
+ struct callback *cb = (struct callback *)userevent.data1;
+ dbg(lvl_debug, "SDL_USEREVENT timer received cb(%p)", cb);
+ callback_call_0(cb);
+ } else if(userevent.code == SDL_USEREVENT_CODE_WATCH) {
+ struct callback *cb = (struct callback *)userevent.data1;
+ dbg(lvl_debug, "SDL_USEREVENT watch received cb(%p)", cb);
+ callback_call_0(cb);
+ } else if(userevent.code == SDL_USEREVENT_CODE_CALL_CALLBACK) {
+ struct callback_list *cbl = (struct callback_list *)userevent.data1;
+ dbg(lvl_debug, "SDL_USEREVENT call_callback received cbl(%p)", cbl);
+ callback_list_call_0(cbl);
+ } else if(userevent.code == SDL_USEREVENT_CODE_IDLE_EVENT) {
+ dbg(lvl_debug, "SDL_USEREVENT idle_event received");
+ }
#ifdef USE_WEBOS_ACCELEROMETER
- else if(userevent.code == SDL_USEREVENT_CODE_ROTATE)
- {
- dbg(lvl_debug, "SDL_USEREVENT rotate received\n");
- switch(gr->orientation)
- {
- case WEBOS_ORIENTATION_PORTRAIT:
- gr->screen = SDL_SetVideoMode(gr->real_w, gr->real_h, gr->video_bpp, gr->video_flags);
- PDL_SetOrientation(PDL_ORIENTATION_0);
- break;
- case WEBOS_ORIENTATION_LANDSCAPE:
- gr->screen = SDL_SetVideoMode(gr->real_h, gr->real_w, gr->video_bpp, gr->video_flags);
- PDL_SetOrientation(PDL_ORIENTATION_270);
- break;
- }
- if(gr->screen == NULL)
- {
- navit_destroy(gr->nav);
- }
- else
- {
- callback_list_call_attr_2(gr->cbl, attr_resize, (void *)gr->screen->w, (void *)gr->screen->h);
- }
- }
+ else if(userevent.code == SDL_USEREVENT_CODE_ROTATE) {
+ dbg(lvl_debug, "SDL_USEREVENT rotate received");
+ switch(gr->orientation) {
+ case WEBOS_ORIENTATION_PORTRAIT:
+ gr->screen = SDL_SetVideoMode(gr->real_w, gr->real_h, gr->video_bpp, gr->video_flags);
+ PDL_SetOrientation(PDL_ORIENTATION_0);
+ break;
+ case WEBOS_ORIENTATION_LANDSCAPE:
+ gr->screen = SDL_SetVideoMode(gr->real_h, gr->real_w, gr->video_bpp, gr->video_flags);
+ PDL_SetOrientation(PDL_ORIENTATION_270);
+ break;
+ }
+ if(gr->screen == NULL) {
+ navit_destroy(gr->nav);
+ } else {
+ callback_list_call_attr_2(gr->cbl, attr_resize, (void *)gr->screen->w, (void *)gr->screen->h);
+ }
+ }
#endif
- else
- dbg(lvl_warning, "unknown SDL_USEREVENT\n");
+ else
+ dbg(lvl_warning, "unknown SDL_USEREVENT");
- break;
- }
+ break;
+ }
#endif
- default:
- {
- dbg(lvl_debug, "SDL_Event %d\n", ev.type);
- break;
- }
- }
+ default: {
+ dbg(lvl_debug, "SDL_Event %d", ev.type);
+ break;
+ }
+ }
}
#ifdef USE_WEBOS
@@ -1385,8 +1273,8 @@ static gboolean graphics_sdl_idle(void *data)
#ifdef USE_WEBOS_ACCELEROMETER
if (PDL_GetPDKVersion() > 100) {
- event_remove_timeout(accel_to);
- callback_destroy(accel_cb);
+ event_remove_timeout(accel_to);
+ callback_destroy(accel_cb);
}
#endif
@@ -1394,9 +1282,8 @@ static gboolean graphics_sdl_idle(void *data)
}
-static struct graphics_priv *
-graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
+static struct graphics_priv *graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs,
+ struct callback_list *cbl) {
struct graphics_priv *this=g_new0(struct graphics_priv, 1);
struct font_priv *(*font_freetype_new) (void *meth);
struct attr *attr;
@@ -1409,21 +1296,21 @@ graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr *
/* initialize fonts */
font_freetype_new = plugin_get_category_font("freetype");
- if (!font_freetype_new) {
- g_free(this);
- return NULL;
- }
+ if (!font_freetype_new) {
+ g_free(this);
+ return NULL;
+ }
- font_freetype_new(&this->freetype_methods);
+ font_freetype_new(&this->freetype_methods);
- *meth = graphics_methods;
+ *meth = graphics_methods;
- meth->font_new = (struct graphics_font_priv *
- (*)(struct graphics_priv *, struct graphics_font_methods *, char *, int,
- int)) this->freetype_methods.font_new;
- meth->get_text_bbox = (void*) this->freetype_methods.get_text_bbox;
+ meth->font_new = (struct graphics_font_priv *
+ (*)(struct graphics_priv *, struct graphics_font_methods *, char *, int,
+ int)) this->freetype_methods.font_new;
+ meth->get_text_bbox = (void*) this->freetype_methods.get_text_bbox;
- dbg(lvl_debug,"Calling SDL_Init\n");
+ dbg(lvl_debug,"Calling SDL_Init");
#ifdef USE_WEBOS
# ifdef USE_WEBOS_ACCELEROMETER
ret = SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_JOYSTICK);
@@ -1433,21 +1320,19 @@ graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr *
#else
ret = SDL_Init(SDL_INIT_VIDEO);
#endif
- if(ret < 0)
- {
- dbg(lvl_error,"SDL_Init failed %d\n", ret);
- this->freetype_methods.destroy();
+ if(ret < 0) {
+ dbg(lvl_error,"SDL_Init failed %d", ret);
+ this->freetype_methods.destroy();
g_free(this);
return NULL;
}
#ifdef USE_WEBOS
- dbg(lvl_debug,"Calling PDL_Init(0)\n");
+ dbg(lvl_debug,"Calling PDL_Init(0)");
ret = PDL_Init(0);
- if(ret < 0)
- {
- dbg(lvl_error,"PDL_Init failed %d\n", ret);
- this->freetype_methods.destroy();
+ if(ret < 0) {
+ dbg(lvl_error,"PDL_Init failed %d", ret);
+ this->freetype_methods.destroy();
g_free(this);
return NULL;
}
@@ -1456,9 +1341,9 @@ graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr *
#else
if (! event_request_system("glib","graphics_sdl_new")) {
#endif
- dbg(lvl_error,"event_request_system failed");
- this->freetype_methods.destroy();
- g_free(this);
+ dbg(lvl_error,"event_request_system failed");
+ this->freetype_methods.destroy();
+ g_free(this);
return NULL;
}
@@ -1477,8 +1362,8 @@ graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr *
if ((attr=attr_search(attrs, NULL, attr_bpp)))
this->video_bpp=attr->u.num;
if ((attr=attr_search(attrs, NULL, attr_flags))) {
- if (attr->u.num & 1)
- this->video_flags = SDL_SWSURFACE;
+ if (attr->u.num & 1)
+ this->video_flags = SDL_SWSURFACE;
}
if ((attr=attr_search(attrs, NULL, attr_frame))) {
if(!attr->u.num)
@@ -1487,10 +1372,9 @@ graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr *
this->screen = SDL_SetVideoMode(w, h, this->video_bpp, this->video_flags);
- if(this->screen == NULL)
- {
- dbg(lvl_error,"SDL_SetVideoMode failed\n");
- this->freetype_methods.destroy();
+ if(this->screen == NULL) {
+ dbg(lvl_error,"SDL_SetVideoMode failed");
+ this->freetype_methods.destroy();
g_free(this);
#ifdef USE_WEBOS
PDL_Quit();
@@ -1503,19 +1387,18 @@ graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr *
w = this->screen->w;
h = this->screen->h;
- dbg(lvl_debug, "using screen %ix%i@%i\n",
- this->screen->w, this->screen->h,
- this->screen->format->BytesPerPixel * 8);
+ dbg(lvl_debug, "using screen %ix%i@%i",
+ this->screen->w, this->screen->h,
+ this->screen->format->BytesPerPixel * 8);
#ifdef USE_WEBOS_ACCELEROMETER
if ( w > h ) {
- this->orientation = WEBOS_ORIENTATION_LANDSCAPE;
- this->real_w = h;
- this->real_h = w;
- }
- else {
- this->orientation = WEBOS_ORIENTATION_PORTRAIT;
- this->real_w = w;
- this->real_h = h;
+ this->orientation = WEBOS_ORIENTATION_LANDSCAPE;
+ this->real_w = h;
+ this->real_h = w;
+ } else {
+ this->orientation = WEBOS_ORIENTATION_PORTRAIT;
+ this->real_w = w;
+ this->real_h = h;
}
this->accelerometer = SDL_JoystickOpen(0);
#endif
@@ -1530,7 +1413,7 @@ graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr *
#ifdef USE_WEBOS
if(the_graphics!=NULL) {
- dbg(lvl_debug,"graphics_sdl_new: graphics struct already set: %d!\n", the_graphics_count);
+ dbg(lvl_debug,"graphics_sdl_new: graphics struct already set: %d!", the_graphics_count);
}
the_graphics = this;
the_graphics_count++;
@@ -1551,12 +1434,10 @@ graphics_sdl_new(struct navit *nav, struct graphics_methods *meth, struct attr *
#ifdef USE_WEBOS
/* ---------- SDL Eventhandling ---------- */
-static Uint32
-sdl_timer_callback(Uint32 interval, void* param)
-{
+static Uint32 sdl_timer_callback(Uint32 interval, void* param) {
struct event_timeout *timeout=(struct event_timeout*)param;
- dbg(lvl_debug,"timer(%p) multi(%d) interval(%d) fired\n", param, timeout->multi, interval);
+ dbg(lvl_debug,"timer(%p) multi(%d) interval(%d) fired", param, timeout->multi, interval);
SDL_Event event;
SDL_UserEvent userevent;
@@ -1572,63 +1453,57 @@ sdl_timer_callback(Uint32 interval, void* param)
SDL_PushEvent (&event);
if (timeout->multi == 0) {
- timeout->id = 0;
- return 0; // cancel timer
+ timeout->id = 0;
+ return 0; // cancel timer
}
return interval; // reactivate timer
}
/* SDL Mainloop */
-static void
-event_sdl_main_loop_run(void)
-{
+static void event_sdl_main_loop_run(void) {
PDL_ScreenTimeoutEnable(PDL_FALSE);
graphics_sdl_idle(NULL);
PDL_ScreenTimeoutEnable(PDL_TRUE);
}
-static void
-event_sdl_main_loop_quit(void)
-{
+static void event_sdl_main_loop_quit(void) {
quit_event_loop = 1;
}
/* Watch */
-static void
-event_sdl_watch_thread (GPtrArray *watch_list)
-{
+static void event_sdl_watch_thread (GPtrArray *watch_list) {
struct pollfd *pfds = g_new0 (struct pollfd, watch_list->len);
struct event_watch *ew;
int ret;
int idx;
for (idx = 0; idx < watch_list->len; idx++ ) {
- ew = g_ptr_array_index (watch_list, idx);
- g_memmove (&pfds[idx], ew->pfd, sizeof(struct pollfd));
+ ew = g_ptr_array_index (watch_list, idx);
+ g_memmove (&pfds[idx], ew->pfd, sizeof(struct pollfd));
}
while ((ret = ppoll(pfds, watch_list->len, NULL, NULL)) > 0) {
- for (idx = 0; idx < watch_list->len; idx++ ) {
- if (pfds[idx].revents == pfds[idx].events) { /* The requested event happened, notify mainloop! */
- ew = g_ptr_array_index (watch_list, idx);
- dbg(lvl_debug,"watch(%p) event(%d) encountered\n", ew, pfds[idx].revents);
+ for (idx = 0; idx < watch_list->len; idx++ ) {
+ if (pfds[idx].revents == pfds[idx].events) { /* The requested event happened, notify mainloop! */
+ ew = g_ptr_array_index (watch_list, idx);
+ dbg(lvl_debug,"watch(%p) event(%d) encountered", ew, pfds[idx].revents);
- SDL_Event event;
- SDL_UserEvent userevent;
+ SDL_Event event;
+ SDL_UserEvent userevent;
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_WATCH;
- userevent.data1 = ew->cb;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_WATCH;
+ userevent.data1 = ew->cb;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent (&event);
- }
- }
+ SDL_PushEvent (&event);
+ }
+ }
}
g_free(pfds);
@@ -1636,12 +1511,10 @@ event_sdl_watch_thread (GPtrArray *watch_list)
pthread_exit(0);
}
-static void
-event_sdl_watch_startthread(GPtrArray *watch_list)
-{
- dbg(lvl_debug,"enter\n");
+static void event_sdl_watch_startthread(GPtrArray *watch_list) {
+ dbg(lvl_debug,"enter");
if (sdl_watch_thread)
- event_sdl_watch_stopthread();
+ event_sdl_watch_stopthread();
int ret;
ret = pthread_create (&sdl_watch_thread, NULL, (void *)event_sdl_watch_thread, (void *)watch_list);
@@ -1649,27 +1522,23 @@ event_sdl_watch_startthread(GPtrArray *watch_list)
dbg_assert (ret == 0);
}
-static void
-event_sdl_watch_stopthread()
-{
- dbg(lvl_debug,"enter\n");
+static void event_sdl_watch_stopthread() {
+ dbg(lvl_debug,"enter");
if (sdl_watch_thread) {
- /* Notify the watch thread that the list of FDs will change */
- pthread_kill(sdl_watch_thread, SIGUSR1);
- pthread_join(sdl_watch_thread, NULL);
- sdl_watch_thread = 0;
+ /* Notify the watch thread that the list of FDs will change */
+ pthread_kill(sdl_watch_thread, SIGUSR1);
+ pthread_join(sdl_watch_thread, NULL);
+ sdl_watch_thread = 0;
}
}
-static struct event_watch *
-event_sdl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb)
-{
- dbg(lvl_debug,"fd(%d) cond(%x) cb(%x)\n", fd, cond, cb);
+static struct event_watch *event_sdl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) {
+ dbg(lvl_debug,"fd(%d) cond(%x) cb(%x)", fd, cond, cb);
event_sdl_watch_stopthread();
if (!sdl_watch_list)
- sdl_watch_list = g_ptr_array_new();
+ sdl_watch_list = g_ptr_array_new();
struct event_watch *new_ew = g_new0 (struct event_watch, 1);
struct pollfd *pfd = g_new0 (struct pollfd, 1);
@@ -1678,15 +1547,15 @@ event_sdl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb)
/* Modify watchlist here */
switch (cond) {
- case event_watch_cond_read:
- pfd->events = POLLIN;
- break;
- case event_watch_cond_write:
- pfd->events = POLLOUT;
- break;
- case event_watch_cond_except:
- pfd->events = POLLERR|POLLHUP;
- break;
+ case event_watch_cond_read:
+ pfd->events = POLLIN;
+ break;
+ case event_watch_cond_write:
+ pfd->events = POLLOUT;
+ break;
+ case event_watch_cond_except:
+ pfd->events = POLLERR|POLLHUP;
+ break;
}
new_ew->pfd = (struct pollfd*) pfd;
@@ -1699,10 +1568,8 @@ event_sdl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb)
return new_ew;
}
-static void
-event_sdl_remove_watch(struct event_watch *ew)
-{
- dbg(lvl_debug,"enter %p\n",ew);
+static void event_sdl_remove_watch(struct event_watch *ew) {
+ dbg(lvl_debug,"enter %p",ew);
event_sdl_watch_stopthread();
@@ -1711,20 +1578,18 @@ event_sdl_remove_watch(struct event_watch *ew)
g_free (ew);
if (sdl_watch_list->len > 0)
- event_sdl_watch_startthread(sdl_watch_list);
+ event_sdl_watch_startthread(sdl_watch_list);
}
/* Timeout */
-static struct event_timeout *
-event_sdl_add_timeout(int timeout, int multi, struct callback *cb)
-{
+static struct event_timeout *event_sdl_add_timeout(int timeout, int multi, struct callback *cb) {
struct event_timeout * ret = g_new0(struct event_timeout, 1);
if(!ret) {
- dbg(lvl_error,"g_new0 failed\n");
- return ret;
+ dbg(lvl_error,"g_new0 failed");
+ return ret;
}
- dbg(lvl_debug,"timer(%p) multi(%d) interval(%d) cb(%p) added\n",ret, multi, timeout, cb);
+ dbg(lvl_debug,"timer(%p) multi(%d) interval(%d) cb(%p) added",ret, multi, timeout, cb);
ret->multi = multi;
ret->cb = cb;
ret->id = SDL_AddTimer(timeout, sdl_timer_callback, ret);
@@ -1732,42 +1597,35 @@ event_sdl_add_timeout(int timeout, int multi, struct callback *cb)
return ret;
}
-static void
-event_sdl_remove_timeout(struct event_timeout *to)
-{
- dbg(lvl_info,"enter %p\n", to);
- if(to)
- {
- /* do not SDL_RemoveTimer if oneshot timer has already fired */
- int ret = to->id == 0 ? SDL_TRUE : SDL_RemoveTimer(to->id);
+static void event_sdl_remove_timeout(struct event_timeout *to) {
+ dbg(lvl_info,"enter %p", to);
+ if(to) {
+ /* do not SDL_RemoveTimer if oneshot timer has already fired */
+ int ret = to->id == 0 ? SDL_TRUE : SDL_RemoveTimer(to->id);
if (ret == SDL_FALSE)
- dbg(lvl_error,"SDL_RemoveTimer (%p) failed\n", to->id);
+ dbg(lvl_error,"SDL_RemoveTimer (%p) failed", to->id);
- g_free(to);
- dbg(lvl_debug,"timer(%p) removed\n", to);
+ g_free(to);
+ dbg(lvl_debug,"timer(%p) removed", to);
}
}
/* Idle */
/* sort ptr_array by priority, increasing order */
-static gint
-sdl_sort_idle_tasks(gconstpointer parama, gconstpointer paramb)
-{
+static gint sdl_sort_idle_tasks(gconstpointer parama, gconstpointer paramb) {
struct idle_task *a = (struct idle_task *)parama;
struct idle_task *b = (struct idle_task *)paramb;
if (a->priority < b->priority)
- return -1;
+ return -1;
if (a->priority > b->priority)
- return 1;
+ return 1;
return 0;
}
-static struct event_idle *
-event_sdl_add_idle(int priority, struct callback *cb)
-{
- dbg(lvl_debug,"add idle priority(%d) cb(%p)\n", priority, cb);
+static struct event_idle *event_sdl_add_idle(int priority, struct callback *cb) {
+ dbg(lvl_debug,"add idle priority(%d) cb(%p)", priority, cb);
struct idle_task *task = g_new0(struct idle_task, 1);
task->priority = priority;
@@ -1775,42 +1633,36 @@ event_sdl_add_idle(int priority, struct callback *cb)
g_ptr_array_add(idle_tasks, (gpointer)task);
- if (idle_tasks->len < 2)
- {
- SDL_Event event;
- SDL_UserEvent userevent;
+ if (idle_tasks->len < 2) {
+ SDL_Event event;
+ SDL_UserEvent userevent;
- dbg(lvl_debug,"poking eventloop because of new idle_events\n");
+ dbg(lvl_debug,"poking eventloop because of new idle_events");
- userevent.type = SDL_USEREVENT;
- userevent.code = SDL_USEREVENT_CODE_IDLE_EVENT;
- userevent.data1 = NULL;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = SDL_USEREVENT_CODE_IDLE_EVENT;
+ userevent.data1 = NULL;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent (&event);
- }
- else // more than one entry => sort the list
- g_ptr_array_sort(idle_tasks, sdl_sort_idle_tasks);
+ SDL_PushEvent (&event);
+ } else // more than one entry => sort the list
+ g_ptr_array_sort(idle_tasks, sdl_sort_idle_tasks);
return (struct event_idle *)task;
}
-static void
-event_sdl_remove_idle(struct event_idle *task)
-{
- dbg(lvl_debug,"remove task(%p)\n", task);
+static void event_sdl_remove_idle(struct event_idle *task) {
+ dbg(lvl_debug,"remove task(%p)", task);
g_ptr_array_remove(idle_tasks, (gpointer)task);
}
/* callback */
-static void
-event_sdl_call_callback(struct callback_list *cbl)
-{
- dbg(lvl_debug,"call_callback cbl(%p)\n",cbl);
+static void event_sdl_call_callback(struct callback_list *cbl) {
+ dbg(lvl_debug,"call_callback cbl(%p)",cbl);
SDL_Event event;
SDL_UserEvent userevent;
@@ -1837,9 +1689,7 @@ static struct event_methods event_sdl_methods = {
event_sdl_call_callback,
};
-static struct event_priv *
-event_sdl_new(struct event_methods* methods)
-{
+static struct event_priv *event_sdl_new(struct event_methods* methods) {
idle_tasks = g_ptr_array_new();
*methods = event_sdl_methods;
return NULL;
@@ -1848,9 +1698,7 @@ event_sdl_new(struct event_methods* methods)
/* ---------- SDL Eventhandling ---------- */
#endif
-void
-plugin_init(void)
-{
+void plugin_init(void) {
#ifdef USE_WEBOS
plugin_register_category_event("sdl", event_sdl_new);
#endif
diff --git a/navit/graphics/sdl/raster.c b/navit/graphics/sdl/raster.c
index 82c79212c..6c713844b 100644
--- a/navit/graphics/sdl/raster.c
+++ b/navit/graphics/sdl/raster.c
@@ -25,49 +25,37 @@
/* raster_rect */
-static inline void raster_rect_inline(SDL_Surface *dst, int16_t x1, int16_t y1, int16_t w, int16_t h, uint32_t color)
-{
+static inline void raster_rect_inline(SDL_Surface *dst, int16_t x1, int16_t y1, int16_t w, int16_t h, uint32_t color) {
/* sge */
SDL_Rect rect;
#if 1
- if((w <= 0) || (h <= 0))
- {
+ if((w <= 0) || (h <= 0)) {
return;
}
#if 0
- if(x1 < 0)
- {
- if((x1 + w) < 0)
- {
+ if(x1 < 0) {
+ if((x1 + w) < 0) {
return;
- }
- else
- {
+ } else {
w = w + x1;
x1 = 0;
}
}
- if(y1 < 0)
- {
- if((y1 + h) < 0)
- {
+ if(y1 < 0) {
+ if((y1 + h) < 0) {
return;
- }
- else
- {
+ } else {
h = h + y1;
y1 = 0;
}
}
- if(x1 + w >= dst->w)
- {
+ if(x1 + w >= dst->w) {
w = dst->w - x1;
}
- if(y1 + h >= dst->h)
- {
+ if(y1 + h >= dst->h) {
h = dst->h - y1;
}
#endif
@@ -87,172 +75,171 @@ static inline void raster_rect_inline(SDL_Surface *dst, int16_t x1, int16_t y1,
/*
* Order coordinates to ensure that
- * x1<=x2 and y1<=y2
+ * x1<=x2 and y1<=y2
*/
if (x1 > x2) {
- tmp = x1;
- x1 = x2;
- x2 = tmp;
+ tmp = x1;
+ x1 = x2;
+ x2 = tmp;
}
if (y1 > y2) {
- tmp = y1;
- y1 = y2;
- y2 = tmp;
+ tmp = y1;
+ y1 = y2;
+ y2 = tmp;
}
- /*
- * Get clipping boundary and
- * check visibility
+ /*
+ * Get clipping boundary and
+ * check visibility
*/
left = dst->clip_rect.x;
if (x2<left) {
- return(0);
+ return(0);
}
right = dst->clip_rect.x + dst->clip_rect.w - 1;
if (x1>right) {
- return(0);
+ return(0);
}
top = dst->clip_rect.y;
if (y2<top) {
- return(0);
+ return(0);
}
bottom = dst->clip_rect.y + dst->clip_rect.h - 1;
if (y1>bottom) {
- return(0);
+ return(0);
}
-
+
/* Clip all points */
- if (x1<left) {
- x1=left;
+ if (x1<left) {
+ x1=left;
} else if (x1>right) {
- x1=right;
+ x1=right;
}
- if (x2<left) {
- x2=left;
+ if (x2<left) {
+ x2=left;
} else if (x2>right) {
- x2=right;
+ x2=right;
}
- if (y1<top) {
- y1=top;
+ if (y1<top) {
+ y1=top;
} else if (y1>bottom) {
- y1=bottom;
+ y1=bottom;
}
- if (y2<top) {
- y2=top;
+ if (y2<top) {
+ y2=top;
} else if (y2>bottom) {
- y2=bottom;
+ y2=bottom;
}
#if 0
/*
- * Test for special cases of straight line or single point
+ * Test for special cases of straight line or single point
*/
if (x1 == x2) {
- if (y1 == y2) {
- return (pixelColor(dst, x1, y1, color));
- } else {
- return (vlineColor(dst, x1, y1, y2, color));
- }
+ if (y1 == y2) {
+ return (pixelColor(dst, x1, y1, color));
+ } else {
+ return (vlineColor(dst, x1, y1, y2, color));
+ }
}
if (y1 == y2) {
- return (hlineColor(dst, x1, x2, y1, color));
+ return (hlineColor(dst, x1, x2, y1, color));
}
#endif
/*
- * Calculate width&height
+ * Calculate width&height
*/
w = x2 - x1;
h = y2 - y1;
- /*
- * No alpha-blending required
- */
+ /*
+ * No alpha-blending required
+ */
#if 0
- /*
- * Setup color
- */
- colorptr = (Uint8 *) & color;
- if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
- color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]);
- } else {
- color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]);
- }
+ /*
+ * Setup color
+ */
+ colorptr = (Uint8 *) & color;
+ if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
+ color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]);
+ } else {
+ color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]);
+ }
#endif
- /*
- * Lock surface
- */
- SDL_LockSurface(dst);
-
- /*
- * More variable setup
- */
- dx = w;
- dy = h;
- pixx = dst->format->BytesPerPixel;
- pixy = dst->pitch;
- pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y1;
- pixellast = pixel + pixx * dx + pixy * dy;
- dx++;
-
- /*
- * Draw
- */
- switch (dst->format->BytesPerPixel) {
- case 1:
- for (; pixel <= pixellast; pixel += pixy) {
- memset(pixel, (Uint8) color, dx);
- }
- break;
- case 2:
- pixy -= (pixx * dx);
- for (; pixel <= pixellast; pixel += pixy) {
- for (x = 0; x < dx; x++) {
- *(Uint16*) pixel = color;
- pixel += pixx;
- }
- }
- break;
- case 3:
- pixy -= (pixx * dx);
- for (; pixel <= pixellast; pixel += pixy) {
- for (x = 0; x < dx; x++) {
- if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
- pixel[0] = (color >> 16) & 0xff;
- pixel[1] = (color >> 8) & 0xff;
- pixel[2] = color & 0xff;
- } else {
- pixel[0] = color & 0xff;
- pixel[1] = (color >> 8) & 0xff;
- pixel[2] = (color >> 16) & 0xff;
- }
- pixel += pixx;
- }
- }
- break;
- default: /* case 4 */
- pixy -= (pixx * dx);
- for (; pixel <= pixellast; pixel += pixy) {
- for (x = 0; x < dx; x++) {
- *(Uint32 *) pixel = color;
- pixel += pixx;
- }
- }
- break;
- }
-
- /*
- * Unlock surface
- */
- SDL_UnlockSurface(dst);
+ /*
+ * Lock surface
+ */
+ SDL_LockSurface(dst);
+
+ /*
+ * More variable setup
+ */
+ dx = w;
+ dy = h;
+ pixx = dst->format->BytesPerPixel;
+ pixy = dst->pitch;
+ pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y1;
+ pixellast = pixel + pixx * dx + pixy * dy;
+ dx++;
+
+ /*
+ * Draw
+ */
+ switch (dst->format->BytesPerPixel) {
+ case 1:
+ for (; pixel <= pixellast; pixel += pixy) {
+ memset(pixel, (Uint8) color, dx);
+ }
+ break;
+ case 2:
+ pixy -= (pixx * dx);
+ for (; pixel <= pixellast; pixel += pixy) {
+ for (x = 0; x < dx; x++) {
+ *(Uint16*) pixel = color;
+ pixel += pixx;
+ }
+ }
+ break;
+ case 3:
+ pixy -= (pixx * dx);
+ for (; pixel <= pixellast; pixel += pixy) {
+ for (x = 0; x < dx; x++) {
+ if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
+ pixel[0] = (color >> 16) & 0xff;
+ pixel[1] = (color >> 8) & 0xff;
+ pixel[2] = color & 0xff;
+ } else {
+ pixel[0] = color & 0xff;
+ pixel[1] = (color >> 8) & 0xff;
+ pixel[2] = (color >> 16) & 0xff;
+ }
+ pixel += pixx;
+ }
+ }
+ break;
+ default: /* case 4 */
+ pixy -= (pixx * dx);
+ for (; pixel <= pixellast; pixel += pixy) {
+ for (x = 0; x < dx; x++) {
+ *(Uint32 *) pixel = color;
+ pixel += pixx;
+ }
+ }
+ break;
+ }
+
+ /*
+ * Unlock surface
+ */
+ SDL_UnlockSurface(dst);
#endif
}
-void raster_rect(SDL_Surface *s, int16_t x, int16_t y, int16_t w, int16_t h, uint32_t col)
-{
+void raster_rect(SDL_Surface *s, int16_t x, int16_t y, int16_t w, int16_t h, uint32_t col) {
raster_rect_inline(s, x, y, w, h, col);
}
@@ -270,222 +257,219 @@ void raster_rect(SDL_Surface *s, int16_t x, int16_t y, int16_t w, int16_t h, uin
#define clip_ymax(surface) surface->clip_rect.y+surface->clip_rect.h-1
-static void raster_PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
-{
- if(x>=clip_xmin(surface) && x<=clip_xmax(surface) && y>=clip_ymin(surface) && y<=clip_ymax(surface)){
- switch (surface->format->BytesPerPixel) {
- case 1: { /* Assuming 8-bpp */
- *((Uint8 *)surface->pixels + y*surface->pitch + x) = color;
- }
- break;
-
- case 2: { /* Probably 15-bpp or 16-bpp */
- *((Uint16 *)surface->pixels + y*surface->pitch/2 + x) = color;
- }
- break;
-
- case 3: { /* Slow 24-bpp mode, usually not used */
- Uint8 *pix = (Uint8 *)surface->pixels + y * surface->pitch + x*3;
-
- /* Gack - slow, but endian correct */
- *(pix+surface->format->Rshift/8) = color>>surface->format->Rshift;
- *(pix+surface->format->Gshift/8) = color>>surface->format->Gshift;
- *(pix+surface->format->Bshift/8) = color>>surface->format->Bshift;
- *(pix+surface->format->Ashift/8) = color>>surface->format->Ashift;
- }
- break;
-
- case 4: { /* Probably 32-bpp */
- *((Uint32 *)surface->pixels + y*surface->pitch/4 + x) = color;
- }
- break;
- }
- }
+static void raster_PutPixel(SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color) {
+ if(x>=clip_xmin(surface) && x<=clip_xmax(surface) && y>=clip_ymin(surface) && y<=clip_ymax(surface)) {
+ switch (surface->format->BytesPerPixel) {
+ case 1: { /* Assuming 8-bpp */
+ *((Uint8 *)surface->pixels + y*surface->pitch + x) = color;
+ }
+ break;
+
+ case 2: { /* Probably 15-bpp or 16-bpp */
+ *((Uint16 *)surface->pixels + y*surface->pitch/2 + x) = color;
+ }
+ break;
+
+ case 3: { /* Slow 24-bpp mode, usually not used */
+ Uint8 *pix = (Uint8 *)surface->pixels + y * surface->pitch + x*3;
+
+ /* Gack - slow, but endian correct */
+ *(pix+surface->format->Rshift/8) = color>>surface->format->Rshift;
+ *(pix+surface->format->Gshift/8) = color>>surface->format->Gshift;
+ *(pix+surface->format->Bshift/8) = color>>surface->format->Bshift;
+ *(pix+surface->format->Ashift/8) = color>>surface->format->Ashift;
+ }
+ break;
+
+ case 4: { /* Probably 32-bpp */
+ *((Uint32 *)surface->pixels + y*surface->pitch/4 + x) = color;
+ }
+ break;
+ }
+ }
}
/* PutPixel routine with alpha blending, input color in destination format */
/* New, faster routine - default blending pixel */
-static void raster_PutPixelAlpha(SDL_Surface * surface, Sint16 x, Sint16 y, Uint32 color, Uint8 alpha)
-{
+static void raster_PutPixelAlpha(SDL_Surface * surface, Sint16 x, Sint16 y, Uint32 color, Uint8 alpha) {
/* sdl-gfx */
Uint32 Rmask = surface->format->Rmask, Gmask =
- surface->format->Gmask, Bmask = surface->format->Bmask, Amask = surface->format->Amask;
+ surface->format->Gmask, Bmask = surface->format->Bmask, Amask = surface->format->Amask;
Uint32 R = 0, G = 0, B = 0, A = 0;
if (x >= clip_xmin(surface) && x <= clip_xmax(surface)
- && y >= clip_ymin(surface) && y <= clip_ymax(surface)) {
-
- switch (surface->format->BytesPerPixel) {
- case 1:{ /* Assuming 8-bpp */
- if (alpha == 255) {
- *((Uint8 *) surface->pixels + y * surface->pitch + x) = color;
- } else {
- Uint8 *pixel = (Uint8 *) surface->pixels + y * surface->pitch + x;
-
- Uint8 dR = surface->format->palette->colors[*pixel].r;
- Uint8 dG = surface->format->palette->colors[*pixel].g;
- Uint8 dB = surface->format->palette->colors[*pixel].b;
- Uint8 sR = surface->format->palette->colors[color].r;
- Uint8 sG = surface->format->palette->colors[color].g;
- Uint8 sB = surface->format->palette->colors[color].b;
-
- dR = dR + ((sR - dR) * alpha >> 8);
- dG = dG + ((sG - dG) * alpha >> 8);
- dB = dB + ((sB - dB) * alpha >> 8);
-
- *pixel = SDL_MapRGB(surface->format, dR, dG, dB);
- }
- }
- break;
-
- case 2:{ /* Probably 15-bpp or 16-bpp */
- if (alpha == 255) {
- *((Uint16 *) surface->pixels + y * surface->pitch / 2 + x) = color;
- } else {
- Uint16 *pixel = (Uint16 *) surface->pixels + y * surface->pitch / 2 + x;
- Uint32 dc = *pixel;
-
- R = ((dc & Rmask) + (((color & Rmask) - (dc & Rmask)) * alpha >> 8)) & Rmask;
- G = ((dc & Gmask) + (((color & Gmask) - (dc & Gmask)) * alpha >> 8)) & Gmask;
- B = ((dc & Bmask) + (((color & Bmask) - (dc & Bmask)) * alpha >> 8)) & Bmask;
- if (Amask)
- A = ((dc & Amask) + (((color & Amask) - (dc & Amask)) * alpha >> 8)) & Amask;
-
- *pixel = R | G | B | A;
- }
- }
- break;
-
- case 3:{ /* Slow 24-bpp mode, usually not used */
- Uint8 *pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3;
- Uint8 rshift8 = surface->format->Rshift / 8;
- Uint8 gshift8 = surface->format->Gshift / 8;
- Uint8 bshift8 = surface->format->Bshift / 8;
- Uint8 ashift8 = surface->format->Ashift / 8;
-
-
- if (alpha == 255) {
- *(pix + rshift8) = color >> surface->format->Rshift;
- *(pix + gshift8) = color >> surface->format->Gshift;
- *(pix + bshift8) = color >> surface->format->Bshift;
- *(pix + ashift8) = color >> surface->format->Ashift;
- } else {
- Uint8 dR, dG, dB, dA = 0;
- Uint8 sR, sG, sB, sA = 0;
-
- pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3;
-
- dR = *((pix) + rshift8);
- dG = *((pix) + gshift8);
- dB = *((pix) + bshift8);
- dA = *((pix) + ashift8);
-
- sR = (color >> surface->format->Rshift) & 0xff;
- sG = (color >> surface->format->Gshift) & 0xff;
- sB = (color >> surface->format->Bshift) & 0xff;
- sA = (color >> surface->format->Ashift) & 0xff;
-
- dR = dR + ((sR - dR) * alpha >> 8);
- dG = dG + ((sG - dG) * alpha >> 8);
- dB = dB + ((sB - dB) * alpha >> 8);
- dA = dA + ((sA - dA) * alpha >> 8);
-
- *((pix) + rshift8) = dR;
- *((pix) + gshift8) = dG;
- *((pix) + bshift8) = dB;
- *((pix) + ashift8) = dA;
- }
- }
- break;
+ && y >= clip_ymin(surface) && y <= clip_ymax(surface)) {
+
+ switch (surface->format->BytesPerPixel) {
+ case 1: { /* Assuming 8-bpp */
+ if (alpha == 255) {
+ *((Uint8 *) surface->pixels + y * surface->pitch + x) = color;
+ } else {
+ Uint8 *pixel = (Uint8 *) surface->pixels + y * surface->pitch + x;
+
+ Uint8 dR = surface->format->palette->colors[*pixel].r;
+ Uint8 dG = surface->format->palette->colors[*pixel].g;
+ Uint8 dB = surface->format->palette->colors[*pixel].b;
+ Uint8 sR = surface->format->palette->colors[color].r;
+ Uint8 sG = surface->format->palette->colors[color].g;
+ Uint8 sB = surface->format->palette->colors[color].b;
+
+ dR = dR + ((sR - dR) * alpha >> 8);
+ dG = dG + ((sG - dG) * alpha >> 8);
+ dB = dB + ((sB - dB) * alpha >> 8);
+
+ *pixel = SDL_MapRGB(surface->format, dR, dG, dB);
+ }
+ }
+ break;
+
+ case 2: { /* Probably 15-bpp or 16-bpp */
+ if (alpha == 255) {
+ *((Uint16 *) surface->pixels + y * surface->pitch / 2 + x) = color;
+ } else {
+ Uint16 *pixel = (Uint16 *) surface->pixels + y * surface->pitch / 2 + x;
+ Uint32 dc = *pixel;
+
+ R = ((dc & Rmask) + (((color & Rmask) - (dc & Rmask)) * alpha >> 8)) & Rmask;
+ G = ((dc & Gmask) + (((color & Gmask) - (dc & Gmask)) * alpha >> 8)) & Gmask;
+ B = ((dc & Bmask) + (((color & Bmask) - (dc & Bmask)) * alpha >> 8)) & Bmask;
+ if (Amask)
+ A = ((dc & Amask) + (((color & Amask) - (dc & Amask)) * alpha >> 8)) & Amask;
+
+ *pixel = R | G | B | A;
+ }
+ }
+ break;
+
+ case 3: { /* Slow 24-bpp mode, usually not used */
+ Uint8 *pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3;
+ Uint8 rshift8 = surface->format->Rshift / 8;
+ Uint8 gshift8 = surface->format->Gshift / 8;
+ Uint8 bshift8 = surface->format->Bshift / 8;
+ Uint8 ashift8 = surface->format->Ashift / 8;
+
+
+ if (alpha == 255) {
+ *(pix + rshift8) = color >> surface->format->Rshift;
+ *(pix + gshift8) = color >> surface->format->Gshift;
+ *(pix + bshift8) = color >> surface->format->Bshift;
+ *(pix + ashift8) = color >> surface->format->Ashift;
+ } else {
+ Uint8 dR, dG, dB, dA = 0;
+ Uint8 sR, sG, sB, sA = 0;
+
+ pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3;
+
+ dR = *((pix) + rshift8);
+ dG = *((pix) + gshift8);
+ dB = *((pix) + bshift8);
+ dA = *((pix) + ashift8);
+
+ sR = (color >> surface->format->Rshift) & 0xff;
+ sG = (color >> surface->format->Gshift) & 0xff;
+ sB = (color >> surface->format->Bshift) & 0xff;
+ sA = (color >> surface->format->Ashift) & 0xff;
+
+ dR = dR + ((sR - dR) * alpha >> 8);
+ dG = dG + ((sG - dG) * alpha >> 8);
+ dB = dB + ((sB - dB) * alpha >> 8);
+ dA = dA + ((sA - dA) * alpha >> 8);
+
+ *((pix) + rshift8) = dR;
+ *((pix) + gshift8) = dG;
+ *((pix) + bshift8) = dB;
+ *((pix) + ashift8) = dA;
+ }
+ }
+ break;
#ifdef ORIGINAL_ALPHA_PIXEL_ROUTINE
- case 4:{ /* Probably :-) 32-bpp */
- if (alpha == 255) {
- *((Uint32 *) surface->pixels + y * surface->pitch / 4 + x) = color;
- } else {
- Uint32 Rshift, Gshift, Bshift, Ashift;
- Uint32 *pixel = (Uint32 *) surface->pixels + y * surface->pitch / 4 + x;
- Uint32 dc = *pixel;
-
- Rshift = surface->format->Rshift;
- Gshift = surface->format->Gshift;
- Bshift = surface->format->Bshift;
- Ashift = surface->format->Ashift;
-
- R = ((dc & Rmask) + (((((color & Rmask) - (dc & Rmask)) >> Rshift) * alpha >> 8) << Rshift)) & Rmask;
- G = ((dc & Gmask) + (((((color & Gmask) - (dc & Gmask)) >> Gshift) * alpha >> 8) << Gshift)) & Gmask;
- B = ((dc & Bmask) + (((((color & Bmask) - (dc & Bmask)) >> Bshift) * alpha >> 8) << Bshift)) & Bmask;
- if (Amask)
- A = ((dc & Amask) + (((((color & Amask) - (dc & Amask)) >> Ashift) * alpha >> 8) << Ashift)) & Amask;
-
- *pixel = R | G | B | A;
- }
- }
- break;
+ case 4: { /* Probably :-) 32-bpp */
+ if (alpha == 255) {
+ *((Uint32 *) surface->pixels + y * surface->pitch / 4 + x) = color;
+ } else {
+ Uint32 Rshift, Gshift, Bshift, Ashift;
+ Uint32 *pixel = (Uint32 *) surface->pixels + y * surface->pitch / 4 + x;
+ Uint32 dc = *pixel;
+
+ Rshift = surface->format->Rshift;
+ Gshift = surface->format->Gshift;
+ Bshift = surface->format->Bshift;
+ Ashift = surface->format->Ashift;
+
+ R = ((dc & Rmask) + (((((color & Rmask) - (dc & Rmask)) >> Rshift) * alpha >> 8) << Rshift)) & Rmask;
+ G = ((dc & Gmask) + (((((color & Gmask) - (dc & Gmask)) >> Gshift) * alpha >> 8) << Gshift)) & Gmask;
+ B = ((dc & Bmask) + (((((color & Bmask) - (dc & Bmask)) >> Bshift) * alpha >> 8) << Bshift)) & Bmask;
+ if (Amask)
+ A = ((dc & Amask) + (((((color & Amask) - (dc & Amask)) >> Ashift) * alpha >> 8) << Ashift)) & Amask;
+
+ *pixel = R | G | B | A;
+ }
+ }
+ break;
#endif
#ifdef MODIFIED_ALPHA_PIXEL_ROUTINE
- case 4:{ /* Probably :-) 32-bpp */
- if (alpha == 255) {
- *((Uint32 *) surface->pixels + y * surface->pitch / 4 + x) = color;
- } else {
- Uint32 Rshift, Gshift, Bshift, Ashift;
- Uint32 *pixel = (Uint32 *) surface->pixels + y * surface->pitch / 4 + x;
- Uint32 dc = *pixel;
- Uint32 dR = (color & Rmask), dG = (color & Gmask), dB = (color & Bmask);
- Uint32 surfaceAlpha, preMultR, preMultG, preMultB;
- Uint32 aTmp;
-
- Rshift = surface->format->Rshift;
- Gshift = surface->format->Gshift;
- Bshift = surface->format->Bshift;
- Ashift = surface->format->Ashift;
-
- preMultR = (alpha * (dR>>Rshift));
- preMultG = (alpha * (dG>>Gshift));
- preMultB = (alpha * (dB>>Bshift));
-
- surfaceAlpha = ((dc & Amask) >> Ashift);
- aTmp = (255 - alpha);
- if ((A = 255 - ((aTmp * (255 - surfaceAlpha)) >> 8 ))) {
- aTmp *= surfaceAlpha;
- R = (preMultR + ((aTmp * ((dc & Rmask) >> Rshift)) >> 8)) / A << Rshift & Rmask;
- G = (preMultG + ((aTmp * ((dc & Gmask) >> Gshift)) >> 8)) / A << Gshift & Gmask;
- B = (preMultB + ((aTmp * ((dc & Bmask) >> Bshift)) >> 8)) / A << Bshift & Bmask;
- }
- *pixel = R | G | B | (A << Ashift & Amask);
-
- }
- }
- break;
+ case 4: { /* Probably :-) 32-bpp */
+ if (alpha == 255) {
+ *((Uint32 *) surface->pixels + y * surface->pitch / 4 + x) = color;
+ } else {
+ Uint32 Rshift, Gshift, Bshift, Ashift;
+ Uint32 *pixel = (Uint32 *) surface->pixels + y * surface->pitch / 4 + x;
+ Uint32 dc = *pixel;
+ Uint32 dR = (color & Rmask), dG = (color & Gmask), dB = (color & Bmask);
+ Uint32 surfaceAlpha, preMultR, preMultG, preMultB;
+ Uint32 aTmp;
+
+ Rshift = surface->format->Rshift;
+ Gshift = surface->format->Gshift;
+ Bshift = surface->format->Bshift;
+ Ashift = surface->format->Ashift;
+
+ preMultR = (alpha * (dR>>Rshift));
+ preMultG = (alpha * (dG>>Gshift));
+ preMultB = (alpha * (dB>>Bshift));
+
+ surfaceAlpha = ((dc & Amask) >> Ashift);
+ aTmp = (255 - alpha);
+ if ((A = 255 - ((aTmp * (255 - surfaceAlpha)) >> 8 ))) {
+ aTmp *= surfaceAlpha;
+ R = (preMultR + ((aTmp * ((dc & Rmask) >> Rshift)) >> 8)) / A << Rshift & Rmask;
+ G = (preMultG + ((aTmp * ((dc & Gmask) >> Gshift)) >> 8)) / A << Gshift & Gmask;
+ B = (preMultB + ((aTmp * ((dc & Bmask) >> Bshift)) >> 8)) / A << Bshift & Bmask;
+ }
+ *pixel = R | G | B | (A << Ashift & Amask);
+
+ }
+ }
+ break;
#endif
- }
+ }
}
}
/* FIXME: eliminate these 2 functions */
-static int raster_pixelColorNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color)
-{
+static int raster_pixelColorNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) {
int result = 0;
#if 0
/*
- * Setup color
+ * Setup color
*/
alpha = color & 0x000000ff;
mcolor =
- SDL_MapRGBA(dst->format, (color & 0xff000000) >> 24,
- (color & 0x00ff0000) >> 16, (color & 0x0000ff00) >> 8, alpha);
+ SDL_MapRGBA(dst->format, (color & 0xff000000) >> 24,
+ (color & 0x00ff0000) >> 16, (color & 0x0000ff00) >> 8, alpha);
#endif
/*
- * Draw
+ * Draw
*/
raster_PutPixel(dst, x, y, color);
@@ -495,18 +479,17 @@ static int raster_pixelColorNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32
/* Pixel - using alpha weight on color for AA-drawing - no locking */
-static int raster_pixelColorWeightNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color, Uint32 weight)
-{
+static int raster_pixelColorWeightNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color, Uint32 weight) {
#if 0
Uint32 a;
/*
- * Get alpha
+ * Get alpha
*/
a = (color & (Uint32) 0x000000ff);
/*
- * Modify Alpha by weight
+ * Modify Alpha by weight
*/
a = ((a * weight) >> 8);
#endif
@@ -521,17 +504,23 @@ static int raster_pixelColorWeightNolock(SDL_Surface * dst, Sint16 x, Sint16 y,
-static inline void raster_hline(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color)
-{
+static inline void raster_hline(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) {
#if 1
- SDL_Rect l;
+ SDL_Rect l;
/* sge */
- if(x1>x2){Sint16 tmp=x1; x1=x2; x2=tmp;}
-
- l.x=x1; l.y=y; l.w=x2-x1+1; l.h=1;
-
- SDL_FillRect(dst, &l, color);
+ if(x1>x2) {
+ Sint16 tmp=x1;
+ x1=x2;
+ x2=tmp;
+ }
+
+ l.x=x1;
+ l.y=y;
+ l.w=x2-x1+1;
+ l.h=1;
+
+ SDL_FillRect(dst, &l, color);
#else
/* sdl_gfx */
@@ -544,14 +533,12 @@ static inline void raster_hline(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16
int result = -1;
#if 0
int i;
- union
- {
+ union {
double d;
uint16_t col[4];
} doub;
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
doub.col[i] = color;
}
#endif
@@ -560,48 +547,48 @@ static inline void raster_hline(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16
* Check visibility of clipping rectangle
*/
if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) {
- return(0);
+ return(0);
}
-
+
/*
* Swap x1, x2 if required to ensure x1<=x2
*/
if (x1 > x2) {
- xtmp = x1;
- x1 = x2;
- x2 = xtmp;
+ xtmp = x1;
+ x1 = x2;
+ x2 = xtmp;
}
/*
* Get clipping boundary and
- * check visibility of hline
+ * check visibility of hline
*/
left = dst->clip_rect.x;
if (x2<left) {
- return(0);
+ return(0);
}
right = dst->clip_rect.x + dst->clip_rect.w - 1;
if (x1>right) {
- return(0);
+ return(0);
}
top = dst->clip_rect.y;
bottom = dst->clip_rect.y + dst->clip_rect.h - 1;
if ((y<top) || (y>bottom)) {
- return (0);
+ return (0);
}
/*
- * Clip x
+ * Clip x
*/
if (x1 < left) {
- x1 = left;
+ x1 = left;
}
if (x2 > right) {
- x2 = right;
+ x2 = right;
}
/*
- * Calculate width
+ * Calculate width
*/
w = x2 - x1;
@@ -609,88 +596,93 @@ static inline void raster_hline(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16
printf("raster_hline %d %d %d %d\n", x1, x2, y, w);
#endif
- /*
- * Lock surface
- */
+ /*
+ * Lock surface
+ */
if (SDL_MUSTLOCK(dst)) {
- SDL_LockSurface(dst);
- }
-
- /*
- * More variable setup
- */
- dx = w;
- pixx = dst->format->BytesPerPixel;
- pixy = dst->pitch;
- pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y;
-
- /*
- * Draw
- */
- switch (dst->format->BytesPerPixel) {
- case 1:
- memset(pixel, color, dx);
- break;
- case 2:
- pixellast = pixel + dx + dx;
+ SDL_LockSurface(dst);
+ }
+
+ /*
+ * More variable setup
+ */
+ dx = w;
+ pixx = dst->format->BytesPerPixel;
+ pixy = dst->pitch;
+ pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y;
+
+ /*
+ * Draw
+ */
+ switch (dst->format->BytesPerPixel) {
+ case 1:
+ memset(pixel, color, dx);
+ break;
+ case 2:
+ pixellast = pixel + dx + dx;
#if 0
- for (; (pixel+3) <= pixellast; pixel += 4*pixx)
- {
- *(double *)pixel = doub.d;
+ for (; (pixel+3) <= pixellast; pixel += 4*pixx) {
+ *(double *)pixel = doub.d;
}
#endif
- for (; pixel <= pixellast; pixel += pixx) {
- *(Uint16 *) pixel = color;
- }
- break;
- case 3:
- pixellast = pixel + dx + dx + dx;
- for (; pixel <= pixellast; pixel += pixx) {
- if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
- pixel[0] = (color >> 16) & 0xff;
- pixel[1] = (color >> 8) & 0xff;
- pixel[2] = color & 0xff;
- } else {
- pixel[0] = color & 0xff;
- pixel[1] = (color >> 8) & 0xff;
- pixel[2] = (color >> 16) & 0xff;
- }
- }
- break;
- default: /* case 4 */
- dx = dx + dx;
- pixellast = pixel + dx + dx;
- for (; pixel <= pixellast; pixel += pixx) {
- *(Uint32 *) pixel = color;
- }
- break;
- }
-
- /*
- * Unlock surface
- */
+ for (; pixel <= pixellast; pixel += pixx) {
+ *(Uint16 *) pixel = color;
+ }
+ break;
+ case 3:
+ pixellast = pixel + dx + dx + dx;
+ for (; pixel <= pixellast; pixel += pixx) {
+ if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
+ pixel[0] = (color >> 16) & 0xff;
+ pixel[1] = (color >> 8) & 0xff;
+ pixel[2] = color & 0xff;
+ } else {
+ pixel[0] = color & 0xff;
+ pixel[1] = (color >> 8) & 0xff;
+ pixel[2] = (color >> 16) & 0xff;
+ }
+ }
+ break;
+ default: /* case 4 */
+ dx = dx + dx;
+ pixellast = pixel + dx + dx;
+ for (; pixel <= pixellast; pixel += pixx) {
+ *(Uint32 *) pixel = color;
+ }
+ break;
+ }
+
+ /*
+ * Unlock surface
+ */
if (SDL_MUSTLOCK(dst)) {
- SDL_UnlockSurface(dst);
+ SDL_UnlockSurface(dst);
}
- /*
- * Set result code
- */
- result = 0;
+ /*
+ * Set result code
+ */
+ result = 0;
return (result);
#endif
}
-static void raster_vline(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color)
-{
- SDL_Rect l;
+static void raster_vline(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color) {
+ SDL_Rect l;
+
+ if(y1>y2) {
+ Sint16 tmp=y1;
+ y1=y2;
+ y2=tmp;
+ }
+
+ l.x=x;
+ l.y=y1;
+ l.w=1;
+ l.h=y2-y1+1;
- if(y1>y2){Sint16 tmp=y1; y1=y2; y2=tmp;}
-
- l.x=x; l.y=y1; l.w=1; l.h=y2-y1+1;
-
- SDL_FillRect(dst, &l, color);
+ SDL_FillRect(dst, &l, color);
}
@@ -704,25 +696,23 @@ static void raster_vline(SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint3
#define CLIP_REJECT(a,b) (a&b)
#define CLIP_ACCEPT(a,b) (!(a|b))
-static int clipEncode(Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom)
-{
+static int clipEncode(Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom) {
int code = 0;
if (x < left) {
- code |= CLIP_LEFT_EDGE;
+ code |= CLIP_LEFT_EDGE;
} else if (x > right) {
- code |= CLIP_RIGHT_EDGE;
+ code |= CLIP_RIGHT_EDGE;
}
if (y < top) {
- code |= CLIP_TOP_EDGE;
+ code |= CLIP_TOP_EDGE;
} else if (y > bottom) {
- code |= CLIP_BOTTOM_EDGE;
+ code |= CLIP_BOTTOM_EDGE;
}
return code;
}
-static int clipLine(SDL_Surface * dst, Sint16 * x1, Sint16 * y1, Sint16 * x2, Sint16 * y2)
-{
+static int clipLine(SDL_Surface * dst, Sint16 * x1, Sint16 * y1, Sint16 * x2, Sint16 * y2) {
Sint16 left, right, top, bottom;
int code1, code2;
int draw = 0;
@@ -730,7 +720,7 @@ static int clipLine(SDL_Surface * dst, Sint16 * x1, Sint16 * y1, Sint16 * x2, Si
float m;
/*
- * Get clipping boundary
+ * Get clipping boundary
*/
left = dst->clip_rect.x;
right = dst->clip_rect.x + dst->clip_rect.w - 1;
@@ -738,56 +728,55 @@ static int clipLine(SDL_Surface * dst, Sint16 * x1, Sint16 * y1, Sint16 * x2, Si
bottom = dst->clip_rect.y + dst->clip_rect.h - 1;
while (1) {
- code1 = clipEncode(*x1, *y1, left, top, right, bottom);
- code2 = clipEncode(*x2, *y2, left, top, right, bottom);
- if (CLIP_ACCEPT(code1, code2)) {
- draw = 1;
- break;
- } else if (CLIP_REJECT(code1, code2))
- break;
- else {
- if (CLIP_INSIDE(code1)) {
- swaptmp = *x2;
- *x2 = *x1;
- *x1 = swaptmp;
- swaptmp = *y2;
- *y2 = *y1;
- *y1 = swaptmp;
- swaptmp = code2;
- code2 = code1;
- code1 = swaptmp;
- }
- if (*x2 != *x1) {
- m = (*y2 - *y1) / (float) (*x2 - *x1);
- } else {
- m = 1.0f;
- }
- if (code1 & CLIP_LEFT_EDGE) {
- *y1 += (Sint16) ((left - *x1) * m);
- *x1 = left;
- } else if (code1 & CLIP_RIGHT_EDGE) {
- *y1 += (Sint16) ((right - *x1) * m);
- *x1 = right;
- } else if (code1 & CLIP_BOTTOM_EDGE) {
- if (*x2 != *x1) {
- *x1 += (Sint16) ((bottom - *y1) / m);
- }
- *y1 = bottom;
- } else if (code1 & CLIP_TOP_EDGE) {
- if (*x2 != *x1) {
- *x1 += (Sint16) ((top - *y1) / m);
- }
- *y1 = top;
- }
- }
+ code1 = clipEncode(*x1, *y1, left, top, right, bottom);
+ code2 = clipEncode(*x2, *y2, left, top, right, bottom);
+ if (CLIP_ACCEPT(code1, code2)) {
+ draw = 1;
+ break;
+ } else if (CLIP_REJECT(code1, code2))
+ break;
+ else {
+ if (CLIP_INSIDE(code1)) {
+ swaptmp = *x2;
+ *x2 = *x1;
+ *x1 = swaptmp;
+ swaptmp = *y2;
+ *y2 = *y1;
+ *y1 = swaptmp;
+ swaptmp = code2;
+ code2 = code1;
+ code1 = swaptmp;
+ }
+ if (*x2 != *x1) {
+ m = (*y2 - *y1) / (float) (*x2 - *x1);
+ } else {
+ m = 1.0f;
+ }
+ if (code1 & CLIP_LEFT_EDGE) {
+ *y1 += (Sint16) ((left - *x1) * m);
+ *x1 = left;
+ } else if (code1 & CLIP_RIGHT_EDGE) {
+ *y1 += (Sint16) ((right - *x1) * m);
+ *x1 = right;
+ } else if (code1 & CLIP_BOTTOM_EDGE) {
+ if (*x2 != *x1) {
+ *x1 += (Sint16) ((bottom - *y1) / m);
+ }
+ *y1 = bottom;
+ } else if (code1 & CLIP_TOP_EDGE) {
+ if (*x2 != *x1) {
+ *x1 += (Sint16) ((top - *y1) / m);
+ }
+ *y1 = top;
+ }
+ }
}
return draw;
}
-void raster_line(SDL_Surface *dst, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t color)
-{
+void raster_line(SDL_Surface *dst, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t color) {
/* sdl-gfx */
int pixx, pixy;
int x, y;
@@ -797,40 +786,40 @@ void raster_line(SDL_Surface *dst, int16_t x1, int16_t y1, int16_t x2, int16_t y
void *pixel;
/*
- * Clip line and test if we have to draw
+ * Clip line and test if we have to draw
*/
if (!(clipLine(dst, &x1, &y1, &x2, &y2))) {
- return;
+ return;
}
/*
- * Test for special cases of straight lines or single point
+ * Test for special cases of straight lines or single point
*/
if (x1 == x2) {
- if (y1 < y2) {
- raster_vline(dst, x1, y1, y2, color);
- return;
- } else if (y1 > y2) {
- raster_vline(dst, x1, y2, y1, color);
- return;
- } else {
- raster_PutPixel(dst, x1, y1, color);
- return;
- }
+ if (y1 < y2) {
+ raster_vline(dst, x1, y1, y2, color);
+ return;
+ } else if (y1 > y2) {
+ raster_vline(dst, x1, y2, y1, color);
+ return;
+ } else {
+ raster_PutPixel(dst, x1, y1, color);
+ return;
+ }
}
if (y1 == y2) {
- if (x1 < x2) {
- raster_hline(dst, x1, x2, y1, color);
- return;
- } else if (x1 > x2) {
- raster_hline(dst, x2, x1, y1, color);
- return;
- }
+ if (x1 < x2) {
+ raster_hline(dst, x1, x2, y1, color);
+ return;
+ } else if (x1 > x2) {
+ raster_hline(dst, x2, x1, y1, color);
+ return;
+ }
}
/*
- * Variable setup
+ * Variable setup
*/
dx = x2 - x1;
dy = y2 - y1;
@@ -839,105 +828,105 @@ void raster_line(SDL_Surface *dst, int16_t x1, int16_t y1, int16_t x2, int16_t y
/* Lock surface */
if (SDL_MUSTLOCK(dst)) {
- if (SDL_LockSurface(dst) < 0) {
- return;
- }
+ if (SDL_LockSurface(dst) < 0) {
+ return;
+ }
}
- /*
- * No alpha blending - use fast pixel routines
- */
+ /*
+ * No alpha blending - use fast pixel routines
+ */
#if 0
- /*
- * Setup color
- */
- colorptr = (Uint8 *) & color;
- if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
- color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]);
- } else {
- color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]);
- }
+ /*
+ * Setup color
+ */
+ colorptr = (Uint8 *) & color;
+ if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
+ color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]);
+ } else {
+ color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]);
+ }
#endif
- /*
- * More variable setup
- */
- dx = sx * dx + 1;
- dy = sy * dy + 1;
- pixx = dst->format->BytesPerPixel;
- pixy = dst->pitch;
- pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y1;
- pixx *= sx;
- pixy *= sy;
- if (dx < dy) {
- swaptmp = dx;
- dx = dy;
- dy = swaptmp;
- swaptmp = pixx;
- pixx = pixy;
- pixy = swaptmp;
- }
-
- /*
- * Draw
- */
- x = 0;
- y = 0;
- switch (dst->format->BytesPerPixel) {
- case 1:
- for (; x < dx; x++, pixel=(Uint8 *)pixel+pixx) {
- *(Uint8 *)pixel = color;
- y += dy;
- if (y >= dx) {
- y -= dx;
- pixel = (Uint8 *)pixel + pixy;
- }
- }
- break;
- case 2:
- for (; x < dx; x++, pixel=(Uint8 *)pixel+pixx) {
- *(Uint16 *) pixel = color;
- y += dy;
- if (y >= dx) {
- y -= dx;
- pixel = (Uint8 *)pixel + pixy;
- }
- }
- break;
- case 3:
- for (; x < dx; x++, pixel=(Uint8 *)pixel+pixx) {
- if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
- *(Uint8 *)pixel = (color >> 16) & 0xff;
- *((Uint8 *)pixel+1) = (color >> 8) & 0xff;
- *((Uint8 *)pixel+2) = color & 0xff;
- } else {
- *(Uint8 *)pixel = color & 0xff;
- *((Uint8 *)pixel+1) = (color >> 8) & 0xff;
- *((Uint8 *)pixel+2) = (color >> 16) & 0xff;
- }
- y += dy;
- if (y >= dx) {
- y -= dx;
- pixel = (Uint8 *)pixel + pixy;
- }
- }
- break;
- default: /* case 4 */
- for (; x < dx; x++, pixel=(Uint8 *)pixel+pixx) {
- *(Uint32 *) pixel = color;
- y += dy;
- if (y >= dx) {
- y -= dx;
- pixel = (Uint8 *)pixel + pixy;
- }
- }
- break;
- }
+ /*
+ * More variable setup
+ */
+ dx = sx * dx + 1;
+ dy = sy * dy + 1;
+ pixx = dst->format->BytesPerPixel;
+ pixy = dst->pitch;
+ pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y1;
+ pixx *= sx;
+ pixy *= sy;
+ if (dx < dy) {
+ swaptmp = dx;
+ dx = dy;
+ dy = swaptmp;
+ swaptmp = pixx;
+ pixx = pixy;
+ pixy = swaptmp;
+ }
+
+ /*
+ * Draw
+ */
+ x = 0;
+ y = 0;
+ switch (dst->format->BytesPerPixel) {
+ case 1:
+ for (; x < dx; x++, pixel=(Uint8 *)pixel+pixx) {
+ *(Uint8 *)pixel = color;
+ y += dy;
+ if (y >= dx) {
+ y -= dx;
+ pixel = (Uint8 *)pixel + pixy;
+ }
+ }
+ break;
+ case 2:
+ for (; x < dx; x++, pixel=(Uint8 *)pixel+pixx) {
+ *(Uint16 *) pixel = color;
+ y += dy;
+ if (y >= dx) {
+ y -= dx;
+ pixel = (Uint8 *)pixel + pixy;
+ }
+ }
+ break;
+ case 3:
+ for (; x < dx; x++, pixel=(Uint8 *)pixel+pixx) {
+ if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {
+ *(Uint8 *)pixel = (color >> 16) & 0xff;
+ *((Uint8 *)pixel+1) = (color >> 8) & 0xff;
+ *((Uint8 *)pixel+2) = color & 0xff;
+ } else {
+ *(Uint8 *)pixel = color & 0xff;
+ *((Uint8 *)pixel+1) = (color >> 8) & 0xff;
+ *((Uint8 *)pixel+2) = (color >> 16) & 0xff;
+ }
+ y += dy;
+ if (y >= dx) {
+ y -= dx;
+ pixel = (Uint8 *)pixel + pixy;
+ }
+ }
+ break;
+ default: /* case 4 */
+ for (; x < dx; x++, pixel=(Uint8 *)pixel+pixx) {
+ *(Uint32 *) pixel = color;
+ y += dy;
+ if (y >= dx) {
+ y -= dx;
+ pixel = (Uint8 *)pixel + pixy;
+ }
+ }
+ break;
+ }
/* Unlock surface */
if (SDL_MUSTLOCK(dst)) {
- SDL_UnlockSurface(dst);
+ SDL_UnlockSurface(dst);
}
return;
@@ -947,8 +936,8 @@ void raster_line(SDL_Surface *dst, int16_t x1, int16_t y1, int16_t x2, int16_t y
#define AAlevels 256
#define AAbits 8
-static void raster_aalineColorInt(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color, int draw_endpoint)
-{
+static void raster_aalineColorInt(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color,
+ int draw_endpoint) {
Sint32 xx0, yy0, xx1, yy1;
Uint32 intshift, erracc, erradj;
Uint32 erracctmp, wgt;
@@ -958,18 +947,18 @@ static void raster_aalineColorInt(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint1
* Check visibility of clipping rectangle
*/
if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) {
- return;
+ return;
}
/*
- * Clip line and test if we have to draw
+ * Clip line and test if we have to draw
*/
if (!(clipLine(dst, &x1, &y1, &x2, &y2))) {
- return;
+ return;
}
/*
- * Keep on working with 32bit numbers
+ * Keep on working with 32bit numbers
*/
xx0 = x1;
yy0 = y1;
@@ -977,177 +966,176 @@ static void raster_aalineColorInt(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint1
yy1 = y2;
/*
- * Reorder points if required
+ * Reorder points if required
*/
if (yy0 > yy1) {
- tmp = yy0;
- yy0 = yy1;
- yy1 = tmp;
- tmp = xx0;
- xx0 = xx1;
- xx1 = tmp;
+ tmp = yy0;
+ yy0 = yy1;
+ yy1 = tmp;
+ tmp = xx0;
+ xx0 = xx1;
+ xx1 = tmp;
}
/*
- * Calculate distance
+ * Calculate distance
*/
dx = xx1 - xx0;
dy = yy1 - yy0;
/*
- * Adjust for negative dx and set xdir
+ * Adjust for negative dx and set xdir
*/
if (dx >= 0) {
- xdir = 1;
+ xdir = 1;
} else {
- xdir = -1;
- dx = (-dx);
+ xdir = -1;
+ dx = (-dx);
}
/*
- * Check for special cases
+ * Check for special cases
*/
if (dx == 0) {
- /*
- * Vertical line
- */
- raster_vline(dst, x1, y1, y2, color);
- return;
+ /*
+ * Vertical line
+ */
+ raster_vline(dst, x1, y1, y2, color);
+ return;
} else if (dy == 0) {
- /*
- * Horizontal line
- */
- raster_hline(dst, x1, x2, y1, color);
- return;
+ /*
+ * Horizontal line
+ */
+ raster_hline(dst, x1, x2, y1, color);
+ return;
} else if (dx == dy) {
- /*
- * Diagonal line
- */
- raster_line(dst, x1, y1, x2, y2, color);
- return;
+ /*
+ * Diagonal line
+ */
+ raster_line(dst, x1, y1, x2, y2, color);
+ return;
}
/*
- * Zero accumulator
+ * Zero accumulator
*/
erracc = 0;
/*
- * # of bits by which to shift erracc to get intensity level
+ * # of bits by which to shift erracc to get intensity level
*/
intshift = 32 - AAbits;
/* Lock surface */
if (SDL_MUSTLOCK(dst)) {
- if (SDL_LockSurface(dst) < 0) {
- return;
- }
+ if (SDL_LockSurface(dst) < 0) {
+ return;
+ }
}
/*
- * Draw the initial pixel in the foreground color
+ * Draw the initial pixel in the foreground color
*/
raster_pixelColorNolock(dst, x1, y1, color);
/*
- * x-major or y-major?
+ * x-major or y-major?
*/
if (dy > dx) {
- /*
- * y-major. Calculate 16-bit fixed point fractional part of a pixel that
- * X advances every time Y advances 1 pixel, truncating the result so that
- * we won't overrun the endpoint along the X axis
- */
- /*
- * Not-so-portable version: erradj = ((Uint64)dx << 32) / (Uint64)dy;
- */
- erradj = ((dx << 16) / dy) << 16;
-
- /*
- * draw all pixels other than the first and last
- */
- x0pxdir = xx0 + xdir;
- while (--dy) {
- erracctmp = erracc;
- erracc += erradj;
- if (erracc <= erracctmp) {
- /*
- * rollover in error accumulator, x coord advances
- */
- xx0 = x0pxdir;
- x0pxdir += xdir;
- }
- yy0++; /* y-major so always advance Y */
-
- /*
- * the AAbits most significant bits of erracc give us the intensity
- * weighting for this pixel, and the complement of the weighting for
- * the paired pixel.
- */
- wgt = (erracc >> intshift) & 255;
- raster_pixelColorWeightNolock (dst, xx0, yy0, color, 255 - wgt);
- raster_pixelColorWeightNolock (dst, x0pxdir, yy0, color, wgt);
- }
+ /*
+ * y-major. Calculate 16-bit fixed point fractional part of a pixel that
+ * X advances every time Y advances 1 pixel, truncating the result so that
+ * we won't overrun the endpoint along the X axis
+ */
+ /*
+ * Not-so-portable version: erradj = ((Uint64)dx << 32) / (Uint64)dy;
+ */
+ erradj = ((dx << 16) / dy) << 16;
+
+ /*
+ * draw all pixels other than the first and last
+ */
+ x0pxdir = xx0 + xdir;
+ while (--dy) {
+ erracctmp = erracc;
+ erracc += erradj;
+ if (erracc <= erracctmp) {
+ /*
+ * rollover in error accumulator, x coord advances
+ */
+ xx0 = x0pxdir;
+ x0pxdir += xdir;
+ }
+ yy0++; /* y-major so always advance Y */
+
+ /*
+ * the AAbits most significant bits of erracc give us the intensity
+ * weighting for this pixel, and the complement of the weighting for
+ * the paired pixel.
+ */
+ wgt = (erracc >> intshift) & 255;
+ raster_pixelColorWeightNolock (dst, xx0, yy0, color, 255 - wgt);
+ raster_pixelColorWeightNolock (dst, x0pxdir, yy0, color, wgt);
+ }
} else {
- /*
- * x-major line. Calculate 16-bit fixed-point fractional part of a pixel
- * that Y advances each time X advances 1 pixel, truncating the result so
- * that we won't overrun the endpoint along the X axis.
- */
- /*
- * Not-so-portable version: erradj = ((Uint64)dy << 32) / (Uint64)dx;
- */
- erradj = ((dy << 16) / dx) << 16;
-
- /*
- * draw all pixels other than the first and last
- */
- y0p1 = yy0 + 1;
- while (--dx) {
-
- erracctmp = erracc;
- erracc += erradj;
- if (erracc <= erracctmp) {
- /*
- * Accumulator turned over, advance y
- */
- yy0 = y0p1;
- y0p1++;
- }
- xx0 += xdir; /* x-major so always advance X */
- /*
- * the AAbits most significant bits of erracc give us the intensity
- * weighting for this pixel, and the complement of the weighting for
- * the paired pixel.
- */
- wgt = (erracc >> intshift) & 255;
- raster_pixelColorWeightNolock (dst, xx0, yy0, color, 255 - wgt);
- raster_pixelColorWeightNolock (dst, xx0, y0p1, color, wgt);
- }
- }
-
- /*
- * Do we have to draw the endpoint
+ /*
+ * x-major line. Calculate 16-bit fixed-point fractional part of a pixel
+ * that Y advances each time X advances 1 pixel, truncating the result so
+ * that we won't overrun the endpoint along the X axis.
+ */
+ /*
+ * Not-so-portable version: erradj = ((Uint64)dy << 32) / (Uint64)dx;
+ */
+ erradj = ((dy << 16) / dx) << 16;
+
+ /*
+ * draw all pixels other than the first and last
+ */
+ y0p1 = yy0 + 1;
+ while (--dx) {
+
+ erracctmp = erracc;
+ erracc += erradj;
+ if (erracc <= erracctmp) {
+ /*
+ * Accumulator turned over, advance y
+ */
+ yy0 = y0p1;
+ y0p1++;
+ }
+ xx0 += xdir; /* x-major so always advance X */
+ /*
+ * the AAbits most significant bits of erracc give us the intensity
+ * weighting for this pixel, and the complement of the weighting for
+ * the paired pixel.
+ */
+ wgt = (erracc >> intshift) & 255;
+ raster_pixelColorWeightNolock (dst, xx0, yy0, color, 255 - wgt);
+ raster_pixelColorWeightNolock (dst, xx0, y0p1, color, wgt);
+ }
+ }
+
+ /*
+ * Do we have to draw the endpoint
*/
if (draw_endpoint) {
- /*
- * Draw final pixel, always exactly intersected by the line and doesn't
- * need to be weighted.
- */
- raster_pixelColorNolock (dst, x2, y2, color);
+ /*
+ * Draw final pixel, always exactly intersected by the line and doesn't
+ * need to be weighted.
+ */
+ raster_pixelColorNolock (dst, x2, y2, color);
}
/* Unlock surface */
if (SDL_MUSTLOCK(dst)) {
- SDL_UnlockSurface(dst);
+ SDL_UnlockSurface(dst);
}
}
-void raster_aaline(SDL_Surface *s, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t col)
-{
+void raster_aaline(SDL_Surface *s, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t col) {
raster_aalineColorInt(s, x1, y1, x2, y2, col, 1);
}
@@ -1155,8 +1143,7 @@ void raster_aaline(SDL_Surface *s, int16_t x1, int16_t y1, int16_t x2, int16_t y
/* raster :: circle */
-void raster_circle(SDL_Surface *dst, int16_t x, int16_t y, int16_t r, uint32_t color)
-{
+void raster_circle(SDL_Surface *dst, int16_t x, int16_t y, int16_t r, uint32_t color) {
/* sdl-gfx */
Sint16 left, right, top, bottom;
Sint16 x1, y1, x2, y2;
@@ -1174,297 +1161,284 @@ void raster_circle(SDL_Surface *dst, int16_t x, int16_t y, int16_t r, uint32_t c
* Check visibility of clipping rectangle
*/
if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) {
- return;
+ return;
}
/*
- * Sanity check radius
+ * Sanity check radius
*/
if (r < 0) {
- return;
+ return;
}
/*
- * Special case for r=0 - draw a point
+ * Special case for r=0 - draw a point
*/
if (r == 0) {
- return (raster_PutPixel(dst, x, y, color));
+ return (raster_PutPixel(dst, x, y, color));
}
/*
- * Get circle and clipping boundary and
- * test if bounding box of circle is visible
+ * Get circle and clipping boundary and
+ * test if bounding box of circle is visible
*/
x2 = x + r;
left = dst->clip_rect.x;
if (x2<left) {
- return;
- }
+ return;
+ }
x1 = x - r;
right = dst->clip_rect.x + dst->clip_rect.w - 1;
if (x1>right) {
- return;
- }
+ return;
+ }
y2 = y + r;
top = dst->clip_rect.y;
if (y2<top) {
- return;
- }
+ return;
+ }
y1 = y - r;
bottom = dst->clip_rect.y + dst->clip_rect.h - 1;
if (y1>bottom) {
- return;
- }
+ return;
+ }
/*
- * Draw
+ * Draw
*/
do {
- xpcx = x + cx;
- xmcx = x - cx;
- xpcy = x + cy;
- xmcy = x - cy;
- if (ocy != cy) {
- if (cy > 0) {
- ypcy = y + cy;
- ymcy = y - cy;
- raster_hline(dst, xmcx, xpcx, ypcy, color);
- raster_hline(dst, xmcx, xpcx, ymcy, color);
+ xpcx = x + cx;
+ xmcx = x - cx;
+ xpcy = x + cy;
+ xmcy = x - cy;
+ if (ocy != cy) {
+ if (cy > 0) {
+ ypcy = y + cy;
+ ymcy = y - cy;
+ raster_hline(dst, xmcx, xpcx, ypcy, color);
+ raster_hline(dst, xmcx, xpcx, ymcy, color);
// raster_rect_inline(dst, xmcx, ypcy, 2*cx, 1, color);
// raster_rect_inline(dst, xmcx, ymcy, 2*cx, 1, color);
- } else {
- raster_hline(dst, xmcx, xpcx, y, color);
+ } else {
+ raster_hline(dst, xmcx, xpcx, y, color);
// raster_rect_inline(dst, xmcx, y, 2*cx, 1, color);
- }
- ocy = cy;
- }
- if (ocx != cx) {
- if (cx != cy) {
- if (cx > 0) {
- ypcx = y + cx;
- ymcx = y - cx;
- raster_hline(dst, xmcy, xpcy, ymcx, color);
- raster_hline(dst, xmcy, xpcy, ypcx, color);
- //raster_rect_inline(dst, xmcy, ymcx, 2*cy, 1, color);
- //raster_rect_inline(dst, xmcy, ypcx, 2*cy, 1, color);
- } else {
- raster_hline(dst, xmcy, xpcy, y, color);
- //raster_rect_inline(dst, xmcy, y, 2*cy, 1, color);
- }
- }
- ocx = cx;
- }
- /*
- * Update
- */
- if (df < 0) {
- df += d_e;
- d_e += 2;
- d_se += 2;
- } else {
- df += d_se;
- d_e += 2;
- d_se += 4;
- cy--;
- }
- cx++;
+ }
+ ocy = cy;
+ }
+ if (ocx != cx) {
+ if (cx != cy) {
+ if (cx > 0) {
+ ypcx = y + cx;
+ ymcx = y - cx;
+ raster_hline(dst, xmcy, xpcy, ymcx, color);
+ raster_hline(dst, xmcy, xpcy, ypcx, color);
+ //raster_rect_inline(dst, xmcy, ymcx, 2*cy, 1, color);
+ //raster_rect_inline(dst, xmcy, ypcx, 2*cy, 1, color);
+ } else {
+ raster_hline(dst, xmcy, xpcy, y, color);
+ //raster_rect_inline(dst, xmcy, y, 2*cy, 1, color);
+ }
+ }
+ ocx = cx;
+ }
+ /*
+ * Update
+ */
+ if (df < 0) {
+ df += d_e;
+ d_e += 2;
+ d_se += 2;
+ } else {
+ df += d_se;
+ d_e += 2;
+ d_se += 4;
+ cy--;
+ }
+ cx++;
} while (cx <= cy);
}
/* FIXME: convert to fixed pt */
-static void raster_AAFilledEllipse(SDL_Surface *surface, Sint16 xc, Sint16 yc, Sint16 rx, Sint16 ry, Uint32 color)
-{
+static void raster_AAFilledEllipse(SDL_Surface *surface, Sint16 xc, Sint16 yc, Sint16 rx, Sint16 ry, Uint32 color) {
/* sge */
- /* Sanity check */
- if (rx < 1)
- rx = 1;
- if (ry < 1)
- ry = 1;
-
- int a2 = rx * rx;
- int b2 = ry * ry;
-
- int ds = 2 * a2;
- int dt = 2 * b2;
-
- int dxt = (int)(a2 / sqrt(a2 + b2));
-
- int t = 0;
- int s = -2 * a2 * ry;
- int d = 0;
-
- Sint16 x = xc;
- Sint16 y = yc - ry;
-
- Sint16 xs, ys, dyt;
- float cp, is, ip, imax = 1.0;
-
- /* Lock surface */
- if ( SDL_MUSTLOCK(surface) )
- if ( SDL_LockSurface(surface) < 0 )
- return;
-
- /* "End points" */
- raster_PutPixel(surface, x, y, color);
- raster_PutPixel(surface, 2*xc-x, y, color);
-
- raster_PutPixel(surface, x, 2*yc-y, color);
- raster_PutPixel(surface, 2*xc-x, 2*yc-y, color);
-
- /* unlock surface */
- if (SDL_MUSTLOCK(surface) )
- SDL_UnlockSurface(surface);
-
- raster_vline(surface, x, y+1, 2*yc-y-1, color);
-
- int i;
-
- for (i = 1; i <= dxt; i++)
- {
- x--;
- d += t - b2;
-
- if (d >= 0)
- ys = y - 1;
- else if ((d - s - a2) > 0)
- {
- if ((2 * d - s - a2) >= 0)
- ys = y + 1;
- else
- {
- ys = y;
- y++;
- d -= s + a2;
- s += ds;
- }
- }
- else
- {
- y++;
- ys = y + 1;
- d -= s + a2;
- s += ds;
- }
-
- t -= dt;
-
- /* Calculate alpha */
- cp = (float) abs(d) / abs(s);
- is = cp * imax;
- ip = imax - is;
-
-
- /* Lock surface */
- if ( SDL_MUSTLOCK(surface) )
- if ( SDL_LockSurface(surface) < 0 )
- return;
-
- /* Upper half */
- raster_PutPixelAlpha(surface, x, y, color, (Uint8)(ip*255));
- raster_PutPixelAlpha(surface, 2*xc-x, y, color, (Uint8)(ip*255));
-
- raster_PutPixelAlpha(surface, x, ys, color, (Uint8)(is*255));
- raster_PutPixelAlpha(surface, 2*xc-x, ys, color, (Uint8)(is*255));
-
-
- /* Lower half */
- raster_PutPixelAlpha(surface, x, 2*yc-y, color, (Uint8)(ip*255));
- raster_PutPixelAlpha(surface, 2*xc-x, 2*yc-y, color, (Uint8)(ip*255));
-
- raster_PutPixelAlpha(surface, x, 2*yc-ys, color, (Uint8)(is*255));
- raster_PutPixelAlpha(surface, 2*xc-x, 2*yc-ys, color, (Uint8)(is*255));
-
- /* unlock surface */
- if (SDL_MUSTLOCK(surface) )
- SDL_UnlockSurface(surface);
-
-
- /* Fill */
- raster_vline(surface, x, y+1, 2*yc-y-1, color);
- raster_vline(surface, 2*xc-x, y+1, 2*yc-y-1, color);
- raster_vline(surface, x, ys+1, 2*yc-ys-1, color);
- raster_vline(surface, 2*xc-x, ys+1, 2*yc-ys-1, color);
- }
-
- dyt = abs(y - yc);
-
- for (i = 1; i <= dyt; i++)
- {
- y++;
- d -= s + a2;
-
- if (d <= 0)
- xs = x + 1;
- else if ((d + t - b2) < 0)
- {
- if ((2 * d + t - b2) <= 0)
- xs = x - 1;
- else
- {
- xs = x;
- x--;
- d += t - b2;
- t -= dt;
- }
- }
- else
- {
- x--;
- xs = x - 1;
- d += t - b2;
- t -= dt;
- }
-
- s += ds;
-
- /* Calculate alpha */
- cp = (float) abs(d) / abs(t);
- is = cp * imax;
- ip = imax - is;
-
-
- /* Lock surface */
- if ( SDL_MUSTLOCK(surface) )
- if ( SDL_LockSurface(surface) < 0 )
- return;
-
- /* Upper half */
- raster_PutPixelAlpha(surface, x, y, color, (Uint8)(ip*255));
- raster_PutPixelAlpha(surface, 2*xc-x, y, color, (Uint8)(ip*255));
-
- raster_PutPixelAlpha(surface, xs, y, color, (Uint8)(is*255));
- raster_PutPixelAlpha(surface, 2*xc-xs, y, color, (Uint8)(is*255));
-
-
- /* Lower half*/
- raster_PutPixelAlpha(surface, x, 2*yc-y, color, (Uint8)(ip*255));
- raster_PutPixelAlpha(surface, 2*xc-x, 2*yc-y, color, (Uint8)(ip*255));
-
- raster_PutPixelAlpha(surface, xs, 2*yc-y, color, (Uint8)(is*255));
- raster_PutPixelAlpha(surface, 2*xc-xs, 2*yc-y, color, (Uint8)(is*255));
-
- /* unlock surface */
- if (SDL_MUSTLOCK(surface) )
- SDL_UnlockSurface(surface);
-
- /* Fill */
- raster_hline(surface, x+1, 2*xc-x-1, y, color);
- raster_hline(surface, xs+1, 2*xc-xs-1, y, color);
- raster_hline(surface, x+1, 2*xc-x-1, 2*yc-y, color);
- raster_hline(surface, xs+1, 2*xc-xs-1, 2*yc-y, color);
- }
+ /* Sanity check */
+ if (rx < 1)
+ rx = 1;
+ if (ry < 1)
+ ry = 1;
+
+ int a2 = rx * rx;
+ int b2 = ry * ry;
+
+ int ds = 2 * a2;
+ int dt = 2 * b2;
+
+ int dxt = (int)(a2 / sqrt(a2 + b2));
+
+ int t = 0;
+ int s = -2 * a2 * ry;
+ int d = 0;
+
+ Sint16 x = xc;
+ Sint16 y = yc - ry;
+
+ Sint16 xs, ys, dyt;
+ float cp, is, ip, imax = 1.0;
+
+ /* Lock surface */
+ if ( SDL_MUSTLOCK(surface) )
+ if ( SDL_LockSurface(surface) < 0 )
+ return;
+
+ /* "End points" */
+ raster_PutPixel(surface, x, y, color);
+ raster_PutPixel(surface, 2*xc-x, y, color);
+
+ raster_PutPixel(surface, x, 2*yc-y, color);
+ raster_PutPixel(surface, 2*xc-x, 2*yc-y, color);
+
+ /* unlock surface */
+ if (SDL_MUSTLOCK(surface) )
+ SDL_UnlockSurface(surface);
+
+ raster_vline(surface, x, y+1, 2*yc-y-1, color);
+
+ int i;
+
+ for (i = 1; i <= dxt; i++) {
+ x--;
+ d += t - b2;
+
+ if (d >= 0)
+ ys = y - 1;
+ else if ((d - s - a2) > 0) {
+ if ((2 * d - s - a2) >= 0)
+ ys = y + 1;
+ else {
+ ys = y;
+ y++;
+ d -= s + a2;
+ s += ds;
+ }
+ } else {
+ y++;
+ ys = y + 1;
+ d -= s + a2;
+ s += ds;
+ }
+
+ t -= dt;
+
+ /* Calculate alpha */
+ cp = (float) abs(d) / abs(s);
+ is = cp * imax;
+ ip = imax - is;
+
+
+ /* Lock surface */
+ if ( SDL_MUSTLOCK(surface) )
+ if ( SDL_LockSurface(surface) < 0 )
+ return;
+
+ /* Upper half */
+ raster_PutPixelAlpha(surface, x, y, color, (Uint8)(ip*255));
+ raster_PutPixelAlpha(surface, 2*xc-x, y, color, (Uint8)(ip*255));
+
+ raster_PutPixelAlpha(surface, x, ys, color, (Uint8)(is*255));
+ raster_PutPixelAlpha(surface, 2*xc-x, ys, color, (Uint8)(is*255));
+
+
+ /* Lower half */
+ raster_PutPixelAlpha(surface, x, 2*yc-y, color, (Uint8)(ip*255));
+ raster_PutPixelAlpha(surface, 2*xc-x, 2*yc-y, color, (Uint8)(ip*255));
+
+ raster_PutPixelAlpha(surface, x, 2*yc-ys, color, (Uint8)(is*255));
+ raster_PutPixelAlpha(surface, 2*xc-x, 2*yc-ys, color, (Uint8)(is*255));
+
+ /* unlock surface */
+ if (SDL_MUSTLOCK(surface) )
+ SDL_UnlockSurface(surface);
+
+
+ /* Fill */
+ raster_vline(surface, x, y+1, 2*yc-y-1, color);
+ raster_vline(surface, 2*xc-x, y+1, 2*yc-y-1, color);
+ raster_vline(surface, x, ys+1, 2*yc-ys-1, color);
+ raster_vline(surface, 2*xc-x, ys+1, 2*yc-ys-1, color);
+ }
+
+ dyt = abs(y - yc);
+
+ for (i = 1; i <= dyt; i++) {
+ y++;
+ d -= s + a2;
+
+ if (d <= 0)
+ xs = x + 1;
+ else if ((d + t - b2) < 0) {
+ if ((2 * d + t - b2) <= 0)
+ xs = x - 1;
+ else {
+ xs = x;
+ x--;
+ d += t - b2;
+ t -= dt;
+ }
+ } else {
+ x--;
+ xs = x - 1;
+ d += t - b2;
+ t -= dt;
+ }
+
+ s += ds;
+
+ /* Calculate alpha */
+ cp = (float) abs(d) / abs(t);
+ is = cp * imax;
+ ip = imax - is;
+
+
+ /* Lock surface */
+ if ( SDL_MUSTLOCK(surface) )
+ if ( SDL_LockSurface(surface) < 0 )
+ return;
+
+ /* Upper half */
+ raster_PutPixelAlpha(surface, x, y, color, (Uint8)(ip*255));
+ raster_PutPixelAlpha(surface, 2*xc-x, y, color, (Uint8)(ip*255));
+
+ raster_PutPixelAlpha(surface, xs, y, color, (Uint8)(is*255));
+ raster_PutPixelAlpha(surface, 2*xc-xs, y, color, (Uint8)(is*255));
+
+
+ /* Lower half*/
+ raster_PutPixelAlpha(surface, x, 2*yc-y, color, (Uint8)(ip*255));
+ raster_PutPixelAlpha(surface, 2*xc-x, 2*yc-y, color, (Uint8)(ip*255));
+
+ raster_PutPixelAlpha(surface, xs, 2*yc-y, color, (Uint8)(is*255));
+ raster_PutPixelAlpha(surface, 2*xc-xs, 2*yc-y, color, (Uint8)(is*255));
+
+ /* unlock surface */
+ if (SDL_MUSTLOCK(surface) )
+ SDL_UnlockSurface(surface);
+
+ /* Fill */
+ raster_hline(surface, x+1, 2*xc-x-1, y, color);
+ raster_hline(surface, xs+1, 2*xc-xs-1, y, color);
+ raster_hline(surface, x+1, 2*xc-x-1, 2*yc-y, color);
+ raster_hline(surface, xs+1, 2*xc-xs-1, 2*yc-y, color);
+ }
}
-void raster_aacircle(SDL_Surface *s, int16_t x, int16_t y, int16_t r, uint32_t col)
-{
+void raster_aacircle(SDL_Surface *s, int16_t x, int16_t y, int16_t r, uint32_t col) {
raster_AAFilledEllipse(s, x, y, r, r, col);
}
#if 0
-void raster_aacircle(SDL_Surface *s, int16_t x, int16_t y, int16_t r, uint32_t col)
-{
+void raster_aacircle(SDL_Surface *s, int16_t x, int16_t y, int16_t r, uint32_t col) {
/* sdl-gfx */
Sint16 left, right, top, bottom;
int result;
@@ -1483,159 +1457,150 @@ void raster_aacircle(SDL_Surface *s, int16_t x, int16_t y, int16_t r, uint32_t c
* Check visibility of clipping rectangle
*/
if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) {
- return;
+ return;
}
/*
- * Sanity check radius
+ * Sanity check radius
*/
if (r < 0) {
- return;
+ return;
}
#if 0
/*
- * Special case for r=0 - draw a point
+ * Special case for r=0 - draw a point
*/
if (r == 0) {
- return (pixelColor(dst, x, y, color));
+ return (pixelColor(dst, x, y, color));
}
#endif
/*
- * Get circle and clipping boundary and
- * test if bounding box of circle is visible
+ * Get circle and clipping boundary and
+ * test if bounding box of circle is visible
*/
x2 = x + r;
left = dst->clip_rect.x;
if (x2<left) {
- return;
- }
+ return;
+ }
x1 = x - r;
right = dst->clip_rect.x + dst->clip_rect.w - 1;
if (x1>right) {
- return;
- }
+ return;
+ }
y2 = y + r;
top = dst->clip_rect.y;
if (y2<top) {
- return;
- }
+ return;
+ }
y1 = y - r;
bottom = dst->clip_rect.y + dst->clip_rect.h - 1;
if (y1>bottom) {
- return;
- }
+ return;
+ }
/*
- * Draw
+ * Draw
*/
result = 0;
do {
- xpcx = x + cx;
- xmcx = x - cx;
- xpcy = x + cy;
- xmcy = x - cy;
- if (ocy != cy) {
- if (cy > 0) {
- ypcy = y + cy;
- ymcy = y - cy;
- raster_hlineColor(dst, xmcx, xpcx, ypcy, color);
- raster_hlineColor(dst, xmcx, xpcx, ymcy, color);
+ xpcx = x + cx;
+ xmcx = x - cx;
+ xpcy = x + cy;
+ xmcy = x - cy;
+ if (ocy != cy) {
+ if (cy > 0) {
+ ypcy = y + cy;
+ ymcy = y - cy;
+ raster_hlineColor(dst, xmcx, xpcx, ypcy, color);
+ raster_hlineColor(dst, xmcx, xpcx, ymcy, color);
// raster_rect_inline(dst, xmcx, ypcy, 2*cx, 1, color);
// raster_rect_inline(dst, xmcx, ymcy, 2*cx, 1, color);
- } else {
- raster_hlineColor(dst, xmcx, xpcx, y, color);
+ } else {
+ raster_hlineColor(dst, xmcx, xpcx, y, color);
// raster_rect_inline(dst, xmcx, y, 2*cx, 1, color);
- }
- ocy = cy;
- }
- if (ocx != cx) {
- if (cx != cy) {
- if (cx > 0) {
- ypcx = y + cx;
- ymcx = y - cx;
- raster_hlineColor(dst, xmcy, xpcy, ymcx, color);
- raster_hlineColor(dst, xmcy, xpcy, ypcx, color);
- //raster_rect_inline(dst, xmcy, ymcx, 2*cy, 1, color);
- //raster_rect_inline(dst, xmcy, ypcx, 2*cy, 1, color);
- } else {
- raster_hlineColor(dst, xmcy, xpcy, y, color);
- //raster_rect_inline(dst, xmcy, y, 2*cy, 1, color);
- }
- }
- ocx = cx;
- }
- /*
- * Update
- */
- if (df < 0) {
- df += d_e;
- d_e += 2;
- d_se += 2;
- } else {
- df += d_se;
- d_e += 2;
- d_se += 4;
- cy--;
- }
- cx++;
+ }
+ ocy = cy;
+ }
+ if (ocx != cx) {
+ if (cx != cy) {
+ if (cx > 0) {
+ ypcx = y + cx;
+ ymcx = y - cx;
+ raster_hlineColor(dst, xmcy, xpcy, ymcx, color);
+ raster_hlineColor(dst, xmcy, xpcy, ypcx, color);
+ //raster_rect_inline(dst, xmcy, ymcx, 2*cy, 1, color);
+ //raster_rect_inline(dst, xmcy, ypcx, 2*cy, 1, color);
+ } else {
+ raster_hlineColor(dst, xmcy, xpcy, y, color);
+ //raster_rect_inline(dst, xmcy, y, 2*cy, 1, color);
+ }
+ }
+ ocx = cx;
+ }
+ /*
+ * Update
+ */
+ if (df < 0) {
+ df += d_e;
+ d_e += 2;
+ d_se += 2;
+ } else {
+ df += d_se;
+ d_e += 2;
+ d_se += 4;
+ cy--;
+ }
+ cx++;
} while (cx <= cy);
#if 0
/* sge */
- Sint16 cx = 0;
- Sint16 cy = r;
- int draw=1;
- Sint16 df = 1 - r;
- Sint16 d_e = 3;
- Sint16 d_se = -2 * r + 5;
+ Sint16 cx = 0;
+ Sint16 cy = r;
+ int draw=1;
+ Sint16 df = 1 - r;
+ Sint16 d_e = 3;
+ Sint16 d_se = -2 * r + 5;
#ifdef DEBUG
printf("raster_circle %d %d %d\n", x, y, r);
#endif
- if(r < 0)
- {
+ if(r < 0) {
return;
}
- do {
- if(draw)
- {
- raster_rect_inline(s, x-cx, y+cy, 2*cx, 1, col);
- raster_rect_inline(s, x-cx, y-cy, 2*cx, 1, col);
- draw=0;
- }
- if(cx!=cy)
- {
- if(cx)
- {
+ do {
+ if(draw) {
+ raster_rect_inline(s, x-cx, y+cy, 2*cx, 1, col);
+ raster_rect_inline(s, x-cx, y-cy, 2*cx, 1, col);
+ draw=0;
+ }
+ if(cx!=cy) {
+ if(cx) {
raster_rect_inline(s, x-cy, y-cx, 2*cy, 1, col);
raster_rect_inline(s, x-cy, y+cx, 2*cy, 1, col);
- }
- else
- {
+ } else {
raster_rect_inline(s, x-cy, y, 2*cy, 1, col);
}
- }
-
- if (df < 0)
- {
- df += d_e;
- d_e += 2;
- d_se += 2;
- }
- else
- {
- df += d_se;
- d_e += 2;
- d_se += 4;
- cy--;
- draw=1;
- }
- cx++;
- } while(cx <= cy);
+ }
+
+ if (df < 0) {
+ df += d_e;
+ d_e += 2;
+ d_se += 2;
+ } else {
+ df += d_se;
+ d_e += 2;
+ d_se += 4;
+ cy--;
+ draw=1;
+ }
+ cx++;
+ } while(cx <= cy);
#endif
}
#endif
@@ -1649,8 +1614,7 @@ void raster_aacircle(SDL_Surface *s, int16_t x, int16_t y, int16_t r, uint32_t c
/* Helper qsort callback for polygon drawing */
-static int gfxPrimitivesCompareInt(const void *a, const void *b)
-{
+static int gfxPrimitivesCompareInt(const void *a, const void *b) {
return (*(const int *) a) - (*(const int *) b);
}
@@ -1659,10 +1623,10 @@ static int gfxPrimitivesCompareInt(const void *a, const void *b)
static int *gfxPrimitivesPolyIntsGlobal = NULL;
static int gfxPrimitivesPolyAllocatedGlobal = 0;
-/* (Note: The last two parameters are optional; but required for multithreaded operation.) */
+/* (Note: The last two parameters are optional; but required for multithreaded operation.) */
-static inline int raster_filledPolygonColorMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color, int **polyInts, int *polyAllocated)
-{
+static inline int raster_filledPolygonColorMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n,
+ Uint32 color, int **polyInts, int *polyAllocated) {
/* sdl-gfx */
int result;
int i;
@@ -1679,135 +1643,133 @@ static inline int raster_filledPolygonColorMT(SDL_Surface * dst, const Sint16 *
* Check visibility of clipping rectangle
*/
if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) {
- return(0);
+ return(0);
}
/*
* Sanity check number of edges
*/
if (n < 3) {
- return -1;
+ return -1;
}
-
+
/*
- * Map polygon cache
+ * Map polygon cache
*/
if ((polyInts==NULL) || (polyAllocated==NULL)) {
- /* Use global cache */
- gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
- gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
+ /* Use global cache */
+ gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
+ gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
} else {
- /* Use local cache */
- gfxPrimitivesPolyInts = *polyInts;
- gfxPrimitivesPolyAllocated = *polyAllocated;
+ /* Use local cache */
+ gfxPrimitivesPolyInts = *polyInts;
+ gfxPrimitivesPolyAllocated = *polyAllocated;
}
/*
- * Allocate temp array, only grow array
+ * Allocate temp array, only grow array
*/
if (!gfxPrimitivesPolyAllocated) {
- gfxPrimitivesPolyInts = (int *) malloc(sizeof(int) * n);
- gfxPrimitivesPolyAllocated = n;
+ gfxPrimitivesPolyInts = (int *) malloc(sizeof(int) * n);
+ gfxPrimitivesPolyAllocated = n;
} else {
- if (gfxPrimitivesPolyAllocated < n) {
- gfxPrimitivesPolyInts = (int *) realloc(gfxPrimitivesPolyInts, sizeof(int) * n);
- gfxPrimitivesPolyAllocated = n;
- }
+ if (gfxPrimitivesPolyAllocated < n) {
+ gfxPrimitivesPolyInts = (int *) realloc(gfxPrimitivesPolyInts, sizeof(int) * n);
+ gfxPrimitivesPolyAllocated = n;
+ }
}
/*
* Check temp array
*/
- if (gfxPrimitivesPolyInts==NULL) {
- gfxPrimitivesPolyAllocated = 0;
+ if (gfxPrimitivesPolyInts==NULL) {
+ gfxPrimitivesPolyAllocated = 0;
}
/*
* Update cache variables
*/
- if ((polyInts==NULL) || (polyAllocated==NULL)) {
- gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
- gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
+ if ((polyInts==NULL) || (polyAllocated==NULL)) {
+ gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
+ gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
} else {
- *polyInts = gfxPrimitivesPolyInts;
- *polyAllocated = gfxPrimitivesPolyAllocated;
+ *polyInts = gfxPrimitivesPolyInts;
+ *polyAllocated = gfxPrimitivesPolyAllocated;
}
/*
* Check temp array again
*/
- if (gfxPrimitivesPolyInts==NULL) {
- return(-1);
+ if (gfxPrimitivesPolyInts==NULL) {
+ return(-1);
}
/*
- * Determine Y maxima
+ * Determine Y maxima
*/
miny = vy[0];
maxy = vy[0];
for (i = 1; (i < n); i++) {
- if (vy[i] < miny) {
- miny = vy[i];
- } else if (vy[i] > maxy) {
- maxy = vy[i];
- }
+ if (vy[i] < miny) {
+ miny = vy[i];
+ } else if (vy[i] > maxy) {
+ maxy = vy[i];
+ }
}
/*
- * Draw, scanning y
+ * Draw, scanning y
*/
result = 0;
for (y = miny; (y <= maxy); y++) {
- ints = 0;
- for (i = 0; (i < n); i++) {
- if (!i) {
- ind1 = n - 1;
- ind2 = 0;
- } else {
- ind1 = i - 1;
- ind2 = i;
- }
- y1 = vy[ind1];
- y2 = vy[ind2];
- if (y1 < y2) {
- x1 = vx[ind1];
- x2 = vx[ind2];
- } else if (y1 > y2) {
- y2 = vy[ind1];
- y1 = vy[ind2];
- x2 = vx[ind1];
- x1 = vx[ind2];
- } else {
- continue;
- }
- if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
- gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
- }
- }
-
- qsort(gfxPrimitivesPolyInts, ints, sizeof(int), gfxPrimitivesCompareInt);
-
- for (i = 0; (i < ints); i += 2) {
- xa = gfxPrimitivesPolyInts[i] + 1;
- xa = (xa >> 16) + ((xa & 32768) >> 15);
- xb = gfxPrimitivesPolyInts[i+1] - 1;
- xb = (xb >> 16) + ((xb & 32768) >> 15);
- raster_hline(dst, xa, xb, y, color);
+ ints = 0;
+ for (i = 0; (i < n); i++) {
+ if (!i) {
+ ind1 = n - 1;
+ ind2 = 0;
+ } else {
+ ind1 = i - 1;
+ ind2 = i;
+ }
+ y1 = vy[ind1];
+ y2 = vy[ind2];
+ if (y1 < y2) {
+ x1 = vx[ind1];
+ x2 = vx[ind2];
+ } else if (y1 > y2) {
+ y2 = vy[ind1];
+ y1 = vy[ind2];
+ x2 = vx[ind1];
+ x1 = vx[ind2];
+ } else {
+ continue;
+ }
+ if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
+ gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
+ }
+ }
+
+ qsort(gfxPrimitivesPolyInts, ints, sizeof(int), gfxPrimitivesCompareInt);
+
+ for (i = 0; (i < ints); i += 2) {
+ xa = gfxPrimitivesPolyInts[i] + 1;
+ xa = (xa >> 16) + ((xa & 32768) >> 15);
+ xb = gfxPrimitivesPolyInts[i+1] - 1;
+ xb = (xb >> 16) + ((xb & 32768) >> 15);
+ raster_hline(dst, xa, xb, y, color);
// raster_rect_inline(dst, xa, y, xb - xa, 1, color);
- }
+ }
}
return (result);
}
-void raster_polygon(SDL_Surface *s, int16_t n, int16_t *vx, int16_t *vy, uint32_t col)
-{
+void raster_polygon(SDL_Surface *s, int16_t n, int16_t *vx, int16_t *vy, uint32_t col) {
raster_filledPolygonColorMT(s, vx, vy, n, col, NULL, NULL);
}
-void raster_aapolygon(SDL_Surface *dst, int16_t n, int16_t *vx, int16_t *vy, uint32_t color)
-{
+void raster_aapolygon(SDL_Surface *dst, int16_t n, int16_t *vx, int16_t *vy, uint32_t color) {
/* sdl-gfx + sge w/ rphlx changes: basically, draw aaline border,
then fill.
@@ -1833,19 +1795,19 @@ void raster_aapolygon(SDL_Surface *dst, int16_t n, int16_t *vx, int16_t *vy, uin
* Check visibility of clipping rectangle
*/
if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) {
- return;
+ return;
}
/*
* Sanity check number of edges
*/
if (n < 3) {
- return;
+ return;
}
/*
- * Pointer setup
+ * Pointer setup
*/
px1 = px2 = vx;
py1 = py2 = vy;
@@ -1853,155 +1815,150 @@ void raster_aapolygon(SDL_Surface *dst, int16_t n, int16_t *vx, int16_t *vy, uin
py2++;
/*
- * Draw
+ * Draw
*/
for (i = 1; i < n; i++) {
- raster_aalineColorInt(dst, *px1, *py1, *px2, *py2, color, 0);
- px1 = px2;
- py1 = py2;
- px2++;
- py2++;
+ raster_aalineColorInt(dst, *px1, *py1, *px2, *py2, color, 0);
+ px1 = px2;
+ py1 = py2;
+ px2++;
+ py2++;
}
raster_aalineColorInt(dst, *px1, *py1, *vx, *vy, color, 0);
/*
- * Map polygon cache
+ * Map polygon cache
*/
if ((polyInts==NULL) || (polyAllocated==NULL)) {
- /* Use global cache */
- gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
- gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
+ /* Use global cache */
+ gfxPrimitivesPolyInts = gfxPrimitivesPolyIntsGlobal;
+ gfxPrimitivesPolyAllocated = gfxPrimitivesPolyAllocatedGlobal;
} else {
- /* Use local cache */
- gfxPrimitivesPolyInts = *polyInts;
- gfxPrimitivesPolyAllocated = *polyAllocated;
+ /* Use local cache */
+ gfxPrimitivesPolyInts = *polyInts;
+ gfxPrimitivesPolyAllocated = *polyAllocated;
}
/*
- * Allocate temp array, only grow array
+ * Allocate temp array, only grow array
*/
if (!gfxPrimitivesPolyAllocated) {
- gfxPrimitivesPolyInts = (int *) malloc(sizeof(int) * n);
- gfxPrimitivesPolyAllocated = n;
+ gfxPrimitivesPolyInts = (int *) malloc(sizeof(int) * n);
+ gfxPrimitivesPolyAllocated = n;
} else {
- if (gfxPrimitivesPolyAllocated < n) {
- gfxPrimitivesPolyInts = (int *) realloc(gfxPrimitivesPolyInts, sizeof(int) * n);
- gfxPrimitivesPolyAllocated = n;
- }
+ if (gfxPrimitivesPolyAllocated < n) {
+ gfxPrimitivesPolyInts = (int *) realloc(gfxPrimitivesPolyInts, sizeof(int) * n);
+ gfxPrimitivesPolyAllocated = n;
+ }
}
/*
* Check temp array
*/
- if (gfxPrimitivesPolyInts==NULL) {
- gfxPrimitivesPolyAllocated = 0;
+ if (gfxPrimitivesPolyInts==NULL) {
+ gfxPrimitivesPolyAllocated = 0;
}
/*
* Update cache variables
*/
- if ((polyInts==NULL) || (polyAllocated==NULL)) {
- gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
- gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
+ if ((polyInts==NULL) || (polyAllocated==NULL)) {
+ gfxPrimitivesPolyIntsGlobal = gfxPrimitivesPolyInts;
+ gfxPrimitivesPolyAllocatedGlobal = gfxPrimitivesPolyAllocated;
} else {
- *polyInts = gfxPrimitivesPolyInts;
- *polyAllocated = gfxPrimitivesPolyAllocated;
+ *polyInts = gfxPrimitivesPolyInts;
+ *polyAllocated = gfxPrimitivesPolyAllocated;
}
/*
* Check temp array again
*/
- if (gfxPrimitivesPolyInts==NULL) {
- return;
+ if (gfxPrimitivesPolyInts==NULL) {
+ return;
}
/*
- * Determine Y maxima
+ * Determine Y maxima
*/
miny = vy[0];
maxy = vy[0];
for (i = 1; (i < n); i++) {
- if (vy[i] < miny) {
- miny = vy[i];
- } else if (vy[i] > maxy) {
- maxy = vy[i];
- }
+ if (vy[i] < miny) {
+ miny = vy[i];
+ } else if (vy[i] > maxy) {
+ maxy = vy[i];
+ }
}
/*
- * Draw, scanning y
+ * Draw, scanning y
*/
for (y = miny; (y <= maxy); y++) {
- ints = 0;
- for (i = 0; (i < n); i++) {
- if (!i) {
- ind1 = n - 1;
- ind2 = 0;
- } else {
- ind1 = i - 1;
- ind2 = i;
- }
- y1 = vy[ind1];
- y2 = vy[ind2];
- if (y1 < y2) {
- x1 = vx[ind1];
- x2 = vx[ind2];
- } else if (y1 > y2) {
- y2 = vy[ind1];
- y1 = vy[ind2];
- x2 = vx[ind1];
- x1 = vx[ind2];
- } else {
- continue;
- }
- if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
- gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
- }
- }
-
- qsort(gfxPrimitivesPolyInts, ints, sizeof(int), gfxPrimitivesCompareInt);
+ ints = 0;
+ for (i = 0; (i < n); i++) {
+ if (!i) {
+ ind1 = n - 1;
+ ind2 = 0;
+ } else {
+ ind1 = i - 1;
+ ind2 = i;
+ }
+ y1 = vy[ind1];
+ y2 = vy[ind2];
+ if (y1 < y2) {
+ x1 = vx[ind1];
+ x2 = vx[ind2];
+ } else if (y1 > y2) {
+ y2 = vy[ind1];
+ y1 = vy[ind2];
+ x2 = vx[ind1];
+ x1 = vx[ind2];
+ } else {
+ continue;
+ }
+ if ( ((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2)) ) {
+ gfxPrimitivesPolyInts[ints++] = ((65536 * (y - y1)) / (y2 - y1)) * (x2 - x1) + (65536 * x1);
+ }
+ }
+
+ qsort(gfxPrimitivesPolyInts, ints, sizeof(int), gfxPrimitivesCompareInt);
// o = p = -1;
- for (i = 0; (i < ints); i +=2) {
+ for (i = 0; (i < ints); i +=2) {
#if 0
- xa = gfxPrimitivesPolyInts[i] + 1;
- xa = (xa >> 16) + ((xa & 32768) >> 15);
- xb = gfxPrimitivesPolyInts[i+1] - 1;
- xb = (xb >> 16) + ((xb & 32768) >> 15);
+ xa = gfxPrimitivesPolyInts[i] + 1;
+ xa = (xa >> 16) + ((xa & 32768) >> 15);
+ xb = gfxPrimitivesPolyInts[i+1] - 1;
+ xb = (xb >> 16) + ((xb & 32768) >> 15);
#else
- xa = (gfxPrimitivesPolyInts[i] >> 16);
- xb = (gfxPrimitivesPolyInts[i+1] >> 16);
+ xa = (gfxPrimitivesPolyInts[i] >> 16);
+ xb = (gfxPrimitivesPolyInts[i+1] >> 16);
#endif
#if 0
- if(o < 0)
- {
- o = xa+1;
- }
- else if(p < 0)
- {
- p = xa;
- }
-
- if( (o >= 0) && (p >= 0))
- {
- if(p-o < 0)
- {
- o = p = -1;
- continue;
+ if(o < 0) {
+ o = xa+1;
+ } else if(p < 0) {
+ p = xa;
}
- raster_hlineColor(dst, o, p, y, color);
+ if( (o >= 0) && (p >= 0)) {
+ if(p-o < 0) {
+ o = p = -1;
+ continue;
+ }
- o = p = -1;
- }
+ raster_hlineColor(dst, o, p, y, color);
+
+ o = p = -1;
+ }
#else
- raster_hline(dst, xa+1, xb, y, color);
+ raster_hline(dst, xa+1, xb, y, color);
#endif
// raster_rect_inline(dst, xa, y, xb - xa, 1, color);
- }
+ }
}
}
diff --git a/navit/graphics/sdl/raster.h b/navit/graphics/sdl/raster.h
index 8f50b2715..2e68ea05f 100644
--- a/navit/graphics/sdl/raster.h
+++ b/navit/graphics/sdl/raster.h
@@ -9,7 +9,7 @@
#define __RASTER_H
#include <stdint.h>
-#include <SDL/SDL.h>
+#include "SDL.h"
void raster_rect(SDL_Surface *s, int16_t x, int16_t y, int16_t w, int16_t h, uint32_t col);
@@ -22,4 +22,3 @@ void raster_aacircle(SDL_Surface *s, int16_t x, int16_t y, int16_t r, uint32_t c
void raster_aapolygon(SDL_Surface *s, int16_t n, int16_t *vx, int16_t *vy, uint32_t col);
#endif /* __RASTER_H */
-
diff --git a/navit/graphics/win32/graphics_win32.c b/navit/graphics/win32/graphics_win32.c
index 3d8fa351d..1c8172c7c 100644
--- a/navit/graphics/win32/graphics_win32.c
+++ b/navit/graphics/win32/graphics_win32.c
@@ -29,10 +29,10 @@
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x500 && !defined(__MINGW32CE__)
typedef struct {
- int BlendOp;
- int BlendFlags;
- int SourceConstantAlpha;
- int AlphaFormat;
+ int BlendOp;
+ int BlendFlags;
+ int SourceConstantAlpha;
+ int AlphaFormat;
} BLENDFUNCTION;
#define AC_SRC_OVER 1
@@ -58,8 +58,7 @@ typedef BOOL (WINAPI *FP_AlphaBlend) ( HDC hdcDest,
typedef int (WINAPI *FP_SetStretchBltMode) (HDC dc,int mode);
-struct graphics_priv
-{
+struct graphics_priv {
struct navit *nav;
struct window window;
struct point p;
@@ -95,8 +94,7 @@ struct graphics_priv
GHashTable *image_cache_hash;
};
-struct window_priv
-{
+struct window_priv {
HANDLE hBackLight;
};
@@ -121,8 +119,7 @@ HFONT EzCreateFont (HDC hdc, TCHAR * szFaceName, int iDeciPtHeight,
#define EZ_ATTR_STRIKEOUT 8
HFONT EzCreateFont (HDC hdc, TCHAR * szFaceName, int iDeciPtHeight,
- int iDeciPtWidth, int iAttributes, BOOL fLogRes)
-{
+ int iDeciPtWidth, int iAttributes, BOOL fLogRes) {
FLOAT cxDpi, cyDpi ;
HFONT hFont ;
LOGFONT lf ;
@@ -140,13 +137,10 @@ HFONT EzCreateFont (HDC hdc, TCHAR * szFaceName, int iDeciPtHeight,
SetWindowOrgEx (hdc, 0, 0, NULL) ;
#endif
- if (fLogRes)
- {
+ if (fLogRes) {
cxDpi = (FLOAT) GetDeviceCaps (hdc, LOGPIXELSX) ;
cyDpi = (FLOAT) GetDeviceCaps (hdc, LOGPIXELSY) ;
- }
- else
- {
+ } else {
cxDpi = (FLOAT) (25.4 * GetDeviceCaps (hdc, HORZRES) /
GetDeviceCaps (hdc, HORZSIZE)) ;
@@ -178,8 +172,7 @@ HFONT EzCreateFont (HDC hdc, TCHAR * szFaceName, int iDeciPtHeight,
hFont = CreateFontIndirect (&lf) ;
- if (iDeciPtWidth != 0)
- {
+ if (iDeciPtWidth != 0) {
hFont = (HFONT) SelectObject (hdc, hFont) ;
GetTextMetrics (hdc, &tm) ;
@@ -196,21 +189,19 @@ HFONT EzCreateFont (HDC hdc, TCHAR * szFaceName, int iDeciPtHeight,
return hFont ;
}
-struct graphics_image_priv
-{
+struct graphics_image_priv {
PXPM2BMP pxpm;
- int width,height,row_bytes,channels;
+ int width,height,row_bytes,channels;
unsigned char *png_pixels;
HBITMAP hBitmap;
struct point hot;
};
-static void ErrorExit(LPTSTR lpszFunction)
-{
+static void ErrorExit(LPTSTR lpszFunction) {
// Retrieve the system error message for the last-error code
- LPVOID lpMsgBuf;
+ LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();
@@ -238,8 +229,7 @@ static void ErrorExit(LPTSTR lpszFunction)
-struct graphics_gc_priv
-{
+struct graphics_gc_priv {
HWND hwnd;
int line_width;
COLORREF fg_color;
@@ -253,13 +243,11 @@ struct graphics_gc_priv
};
-static void create_memory_dc(struct graphics_priv *gr)
-{
+static void create_memory_dc(struct graphics_priv *gr) {
HDC hdc;
BITMAPINFO bOverlayInfo;
- if (gr->hMemDC)
- {
+ if (gr->hMemDC) {
(void)SelectBitmap(gr->hMemDC, gr->hOldBitmap);
DeleteBitmap(gr->hBitmap);
DeleteDC(gr->hMemDC);
@@ -274,7 +262,7 @@ static void create_memory_dc(struct graphics_priv *gr)
hdc = GetDC( gr->wnd_handle );
// Creates memory DC
gr->hMemDC = CreateCompatibleDC(hdc);
- dbg(lvl_debug, "resize memDC to: %d %d \n", gr->width, gr->height );
+ dbg(lvl_debug, "resize memDC to: %d %d ", gr->width, gr->height );
#ifndef FAST_TRANSPARENCY
@@ -287,80 +275,72 @@ static void create_memory_dc(struct graphics_priv *gr)
bOverlayInfo.bmiHeader.biCompression = BI_RGB;
bOverlayInfo.bmiHeader.biPlanes = 1;
gr->hPrebuildDC = CreateCompatibleDC(NULL);
- gr->hPrebuildBitmap = CreateDIBSection(gr->hMemDC, &bOverlayInfo, DIB_RGB_COLORS , (void **)&gr->pPixelData, NULL, 0);
+ gr->hPrebuildBitmap = CreateDIBSection(gr->hMemDC, &bOverlayInfo, DIB_RGB_COLORS, (void **)&gr->pPixelData, NULL, 0);
gr->hOldPrebuildBitmap = SelectBitmap(gr->hPrebuildDC, gr->hPrebuildBitmap);
#endif
gr->hBitmap = CreateCompatibleBitmap(hdc, gr->width, gr->height );
- if ( gr->hBitmap )
- {
+ if ( gr->hBitmap ) {
gr->hOldBitmap = SelectBitmap( gr->hMemDC, gr->hBitmap);
}
ReleaseDC( gr->wnd_handle, hdc );
}
-static void HandleButtonClick( struct graphics_priv *gra_priv, int updown, int button, long lParam )
-{
+static void HandleButtonClick( struct graphics_priv *gra_priv, int updown, int button, long lParam ) {
struct point pt = { LOWORD(lParam), HIWORD(lParam) };
callback_list_call_attr_3(gra_priv->cbl, attr_button, (void *)updown, (void *)button, (void *)&pt);
}
-static void HandleKeyChar(struct graphics_priv *gra_priv, WPARAM wParam)
-{
+static void HandleKeyChar(struct graphics_priv *gra_priv, WPARAM wParam) {
TCHAR key = (TCHAR) wParam;
char *s=NULL;
- char k[]={0,0};
- dbg(lvl_debug,"HandleKey %d\n",key);
- switch (key) {
+ char k[]= {0,0};
+ dbg(lvl_debug,"HandleKey %d",key);
+ switch (key) {
default:
- k[0]=key;
- s=k;
+ k[0]=key;
+ s=k;
break;
}
- if (s)
+ if (s)
callback_list_call_attr_1(gra_priv->cbl, attr_keypress, (void *)s);
}
-static void HandleKeyDown(struct graphics_priv *gra_priv, WPARAM wParam)
-{
+static void HandleKeyDown(struct graphics_priv *gra_priv, WPARAM wParam) {
int key = (int) wParam;
- char up[]={NAVIT_KEY_UP,0};
- char down[]={NAVIT_KEY_DOWN,0};
- char left[]={NAVIT_KEY_LEFT,0};
- char right[]={NAVIT_KEY_RIGHT,0};
+ char up[]= {NAVIT_KEY_UP,0};
+ char down[]= {NAVIT_KEY_DOWN,0};
+ char left[]= {NAVIT_KEY_LEFT,0};
+ char right[]= {NAVIT_KEY_RIGHT,0};
char *s=NULL;
- dbg(lvl_debug,"HandleKey %d\n",key);
- switch (key) {
+ dbg(lvl_debug,"HandleKey %d",key);
+ switch (key) {
case 37:
- s=left;
+ s=left;
break;
case 38:
- s=up;
+ s=up;
break;
case 39:
- s=right;
+ s=right;
break;
case 40:
- s=down;
+ s=down;
break;
}
- if (s)
+ if (s)
callback_list_call_attr_1(gra_priv->cbl, attr_keypress, (void *)s);
}
-static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
-{
+static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
- struct graphics_priv* gra_priv = (struct graphics_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
+ struct graphics_priv* gra_priv = (struct graphics_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
- switch (Message)
- {
- case WM_CREATE:
- {
- if ( gra_priv )
- {
+ switch (Message) {
+ case WM_CREATE: {
+ if ( gra_priv ) {
RECT rc ;
GetClientRect( hwnd, &rc );
@@ -371,8 +351,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
}
break;
case WM_COMMAND:
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case WM_USER + 1:
break;
}
@@ -381,8 +360,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
DestroyWindow(hwnd);
break;
case WM_USER+1:
- if ( gra_priv )
- {
+ if ( gra_priv ) {
RECT rc ;
GetClientRect( hwnd, &rc );
@@ -393,8 +371,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
callback_list_call_attr_2(gra_priv->cbl, attr_resize, (void *)gra_priv->width, (void *)gra_priv->height);
}
break;
- case WM_USER+2:
- {
+ case WM_USER+2: {
struct callback_list *cbl = (struct callback_list*)wParam;
#ifdef HAVE_API_WIN32_CE
/* FIXME: Reset the idle timer need a better place */
@@ -405,22 +382,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
break;
case WM_SIZE:
- if ( gra_priv )
- {
+ if ( gra_priv ) {
gra_priv->width = LOWORD( lParam );
gra_priv->height = HIWORD( lParam );
create_memory_dc(gra_priv);
- dbg(lvl_debug, "resize gfx to: %d %d \n", gra_priv->width, gra_priv->height );
+ dbg(lvl_debug, "resize gfx to: %d %d ", gra_priv->width, gra_priv->height );
callback_list_call_attr_2(gra_priv->cbl, attr_resize, (void *)gra_priv->width, (void *)gra_priv->height);
}
break;
case WM_DESTROY:
#ifdef HAVE_API_WIN32_CE
- if ( gra_priv && gra_priv->window.priv )
- {
+ if ( gra_priv && gra_priv->window.priv ) {
struct window_priv *win_priv = gra_priv->window.priv;
- if (win_priv->hBackLight)
- {
+ if (win_priv->hBackLight) {
ReleasePowerRequirement(win_priv->hBackLight);
}
}
@@ -428,94 +402,88 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
PostQuitMessage(0);
break;
case WM_PAINT:
- if ( gra_priv && gra_priv->hMemDC)
- {
- struct graphics_priv* overlay;
+ if ( gra_priv && gra_priv->hMemDC) {
+ struct graphics_priv* overlay;
PAINTSTRUCT ps = { 0 };
HDC hdc;
profile(0, NULL);
- dbg(lvl_debug, "WM_PAINT\n");
+ dbg(lvl_debug, "WM_PAINT");
overlay = gra_priv->overlays;
#ifndef FAST_TRANSPARENCY
- BitBlt( gra_priv->hPrebuildDC, 0, 0, gra_priv->width , gra_priv->height, gra_priv->hMemDC, 0, 0, SRCCOPY);
+ BitBlt( gra_priv->hPrebuildDC, 0, 0, gra_priv->width, gra_priv->height, gra_priv->hMemDC, 0, 0, SRCCOPY);
#endif
- while ( !gra_priv->disabled && overlay)
- {
- if ( !overlay->disabled && overlay->p.x >= 0 &&
- overlay->p.y >= 0 &&
- overlay->p.x < gra_priv->width &&
- overlay->p.y < gra_priv->height )
- {
- int x,y;
- int destPixel, srcPixel;
+ while ( !gra_priv->disabled && overlay) {
+ if ( !overlay->disabled && overlay->p.x >= 0 &&
+ overlay->p.y >= 0 &&
+ overlay->p.x < gra_priv->width &&
+ overlay->p.y < gra_priv->height ) {
+ int x,y;
+ int destPixel, srcPixel;
int h,w;
#ifdef FAST_TRANSPARENCY
- if ( !overlay->hPrebuildDC )
- {
- overlay->hPrebuildBitmap = CreateBitmap(overlay->width,overlay->height,1,1,NULL);
- overlay->hPrebuildDC = CreateCompatibleDC(NULL);
- overlay->hOldPrebuildBitmap = SelectBitmap( overlay->hPrebuildDC, overlay->hPrebuildBitmap);
- SetBkColor(overlay->hMemDC,RGB(overlay->transparent_color.r >> 8,overlay->transparent_color.g >> 8,overlay->transparent_color.b >> 8));
- BitBlt(overlay->hPrebuildDC,0,0,overlay->width,overlay->height,overlay->hMemDC,0,0,SRCCOPY);
- BitBlt(overlay->hMemDC,0,0,overlay->width,overlay->height,overlay->hPrebuildDC,0,0,SRCINVERT);
- }
+ if ( !overlay->hPrebuildDC ) {
+ overlay->hPrebuildBitmap = CreateBitmap(overlay->width,overlay->height,1,1,NULL);
+ overlay->hPrebuildDC = CreateCompatibleDC(NULL);
+ overlay->hOldPrebuildBitmap = SelectBitmap( overlay->hPrebuildDC, overlay->hPrebuildBitmap);
+ SetBkColor(overlay->hMemDC,RGB(overlay->transparent_color.r >> 8,overlay->transparent_color.g >> 8,
+ overlay->transparent_color.b >> 8));
+ BitBlt(overlay->hPrebuildDC,0,0,overlay->width,overlay->height,overlay->hMemDC,0,0,SRCCOPY);
+ BitBlt(overlay->hMemDC,0,0,overlay->width,overlay->height,overlay->hPrebuildDC,0,0,SRCINVERT);
+ }
#else
- const COLORREF transparent_color = RGB(overlay->transparent_color.r >> 8,overlay->transparent_color.g >> 8,overlay->transparent_color.b >> 8);
-
- BitBlt( overlay->hPrebuildDC, 0, 0, overlay->width , overlay->height, overlay->hMemDC, 0, 0, SRCCOPY);
-
- h=overlay->height;
- w=overlay->width;
- if (w > gra_priv->width-overlay->p.x)
- w=gra_priv->width-overlay->p.x;
- if (h > gra_priv->height-overlay->p.y)
- h=gra_priv->height-overlay->p.y;
- for ( y = 0; y < h ;y++ )
- {
- for ( x = 0; x < w; x++ )
- {
- srcPixel = y*overlay->width+x;
- destPixel = ((overlay->p.y + y) * gra_priv->width) + (overlay->p.x + x);
- if ( overlay->pPixelData[srcPixel] == transparent_color )
- {
- destPixel = ((overlay->p.y + y) * gra_priv->width) + (overlay->p.x + x);
-
- gra_priv->pPixelData[destPixel] = RGB ( ((65535 - overlay->transparent_color.a) * GetRValue(gra_priv->pPixelData[destPixel]) + overlay->transparent_color.a * GetRValue(overlay->pPixelData[srcPixel])) / 65535,
- ((65535 - overlay->transparent_color.a) * GetGValue(gra_priv->pPixelData[destPixel]) + overlay->transparent_color.a * GetGValue(overlay->pPixelData[srcPixel])) / 65535,
- ((65535 - overlay->transparent_color.a) * GetBValue(gra_priv->pPixelData[destPixel]) + overlay->transparent_color.a * GetBValue(overlay->pPixelData[srcPixel])) / 65535);
-
- }
- else
- {
- gra_priv->pPixelData[destPixel] = overlay->pPixelData[srcPixel];
- }
- }
-
- }
+ const COLORREF transparent_color = RGB(overlay->transparent_color.r >> 8,overlay->transparent_color.g >> 8,
+ overlay->transparent_color.b >> 8);
+
+ BitBlt( overlay->hPrebuildDC, 0, 0, overlay->width, overlay->height, overlay->hMemDC, 0, 0, SRCCOPY);
+
+ h=overlay->height;
+ w=overlay->width;
+ if (w > gra_priv->width-overlay->p.x)
+ w=gra_priv->width-overlay->p.x;
+ if (h > gra_priv->height-overlay->p.y)
+ h=gra_priv->height-overlay->p.y;
+ for ( y = 0; y < h ; y++ ) {
+ for ( x = 0; x < w; x++ ) {
+ srcPixel = y*overlay->width+x;
+ destPixel = ((overlay->p.y + y) * gra_priv->width) + (overlay->p.x + x);
+ if ( overlay->pPixelData[srcPixel] == transparent_color ) {
+ destPixel = ((overlay->p.y + y) * gra_priv->width) + (overlay->p.x + x);
+
+ gra_priv->pPixelData[destPixel] = RGB ( ((65535 - overlay->transparent_color.a) * GetRValue(
+ gra_priv->pPixelData[destPixel]) + overlay->transparent_color.a * GetRValue(overlay->pPixelData[srcPixel])) / 65535,
+ ((65535 - overlay->transparent_color.a) * GetGValue(gra_priv->pPixelData[destPixel]) + overlay->transparent_color.a *
+ GetGValue(overlay->pPixelData[srcPixel])) / 65535,
+ ((65535 - overlay->transparent_color.a) * GetBValue(gra_priv->pPixelData[destPixel]) + overlay->transparent_color.a *
+ GetBValue(overlay->pPixelData[srcPixel])) / 65535);
+
+ } else {
+ gra_priv->pPixelData[destPixel] = overlay->pPixelData[srcPixel];
+ }
+ }
+
+ }
#endif
- }
- overlay = overlay->next;
- }
+ }
+ overlay = overlay->next;
+ }
#ifndef FAST_TRANSPARENCY
hdc = BeginPaint(hwnd, &ps);
- BitBlt( hdc, 0, 0, gra_priv->width , gra_priv->height, gra_priv->hPrebuildDC, 0, 0, SRCCOPY );
+ BitBlt( hdc, 0, 0, gra_priv->width, gra_priv->height, gra_priv->hPrebuildDC, 0, 0, SRCCOPY );
#else
HDC hdc = BeginPaint(hwnd, &ps);
- BitBlt( hdc, 0, 0, gra_priv->width , gra_priv->height, gra_priv->hMemDC, 0, 0, SRCCOPY );
+ BitBlt( hdc, 0, 0, gra_priv->width, gra_priv->height, gra_priv->hMemDC, 0, 0, SRCCOPY );
overlay = gra_priv->overlays;
- while ( !gra_priv->disabled && overlay && !overlay->disabled )
- {
+ while ( !gra_priv->disabled && overlay && !overlay->disabled ) {
if ( overlay->p.x > 0 &&
overlay->p.y > 0 &&
overlay->p.x + overlay->width < gra_priv->width &&
- overlay->p.y + overlay->height < gra_priv->height )
- {
+ overlay->p.y + overlay->height < gra_priv->height ) {
BitBlt(hdc,overlay->p.x,overlay->p.y,overlay->width,overlay->height,overlay->hPrebuildDC,0,0,SRCAND);
BitBlt(hdc,overlay->p.x,overlay->p.y,overlay->width,overlay->height,overlay->hMemDC,0,0,SRCPAINT);
}
@@ -526,22 +494,19 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
profile(0, "WM_PAINT\n");
}
break;
- case WM_MOUSEMOVE:
- {
+ case WM_MOUSEMOVE: {
struct point pt = { LOWORD(lParam), HIWORD(lParam) };
callback_list_call_attr_1(gra_priv->cbl, attr_motion, (void *)&pt);
}
break;
- case WM_LBUTTONDOWN:
- {
- dbg(lvl_debug, "LBUTTONDOWN\n");
+ case WM_LBUTTONDOWN: {
+ dbg(lvl_debug, "LBUTTONDOWN");
HandleButtonClick( gra_priv, 1, 1, lParam);
}
break;
- case WM_LBUTTONUP:
- {
- dbg(lvl_debug, "LBUTTONUP\n");
+ case WM_LBUTTONUP: {
+ dbg(lvl_debug, "LBUTTONUP");
HandleButtonClick( gra_priv, 0, 1, lParam);
}
break;
@@ -552,7 +517,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
HandleButtonClick( gra_priv, 0, 3,lParam );
break;
case WM_LBUTTONDBLCLK:
- dbg(lvl_debug, "LBUTTONDBLCLK\n");
+ dbg(lvl_debug, "LBUTTONDBLCLK");
HandleButtonClick( gra_priv, 1, 6,lParam );
break;
case WM_CHAR:
@@ -561,23 +526,23 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
case WM_KEYDOWN:
HandleKeyDown( gra_priv, wParam);
break;
- case WM_COPYDATA:
- dbg(lvl_debug,"got WM_COPYDATA\n");
+ case WM_COPYDATA:
+ dbg(lvl_debug,"got WM_COPYDATA");
callback_list_call_attr_2(gra_priv->cbl, attr_wm_copydata, (void *)wParam, (void*)lParam);
break;
#ifdef HAVE_API_WIN32_CE
case WM_SETFOCUS:
if (fullscr) {
- HWND hwndSip = FindWindow(L"MS_SIPBUTTON", NULL);
- // deactivate the SIP button
- ShowWindow(hwndSip, SW_HIDE);
+ HWND hwndSip = FindWindow(L"MS_SIPBUTTON", NULL);
+ // deactivate the SIP button
+ ShowWindow(hwndSip, SW_HIDE);
}
break;
- case WM_KILLFOCUS:
+ case WM_KILLFOCUS:
if (fullscr != 1) {
- HWND hwndSip = FindWindow(L"MS_SIPBUTTON", NULL);
- // active the SIP button
- ShowWindow(hwndSip, SW_SHOW);
+ HWND hwndSip = FindWindow(L"MS_SIPBUTTON", NULL);
+ // active the SIP button
+ ShowWindow(hwndSip, SW_SHOW);
}
break;
#endif
@@ -587,34 +552,34 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
return 0;
}
-static int fullscreen(struct window *win, int on)
-{
+static int fullscreen(struct window *win, int on) {
#ifdef HAVE_API_WIN32_CE
HWND hwndTaskbar = FindWindow(L"HHTaskBar", NULL);
HWND hwndSip = FindWindow(L"MS_SIPBUTTON", NULL);
RECT taskbar_rect;
fullscr = on;
- if (on) {
+ if (on) {
ShowWindow(hwndTaskbar, SW_HIDE);
MoveWindow(g_hwnd, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), FALSE);
-
- // deactivate the SIP button
- ShowWindow(hwndSip, SW_HIDE);
-
- } else {
+
+ // deactivate the SIP button
+ ShowWindow(hwndSip, SW_HIDE);
+
+ } else {
ShowWindow(hwndTaskbar, SW_SHOW);
GetWindowRect( hwndTaskbar, &taskbar_rect);
- MoveWindow(g_hwnd, 0, taskbar_rect.bottom, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) - taskbar_rect.bottom, FALSE);
-
- // activate the SIP button
- ShowWindow(hwndSip, SW_SHOW);
+ MoveWindow(g_hwnd, 0, taskbar_rect.bottom, GetSystemMetrics(SM_CXSCREEN),
+ GetSystemMetrics(SM_CYSCREEN) - taskbar_rect.bottom, FALSE);
+
+ // activate the SIP button
+ ShowWindow(hwndSip, SW_SHOW);
}
#else
- if (on) {
+ if (on) {
ShowWindow(g_hwnd, SW_MAXIMIZE);
- } else {
+ } else {
ShowWindow(g_hwnd, SW_RESTORE);
}
@@ -624,15 +589,12 @@ static int fullscreen(struct window *win, int on)
}
extern void WINAPI SystemIdleTimerReset(void);
-static struct event_timeout *
- event_win32_add_timeout(int timeout, int multi, struct callback *cb);
+static struct event_timeout *event_win32_add_timeout(int timeout, int multi, struct callback *cb);
-static void disable_suspend(struct window *win)
-{
+static void disable_suspend(struct window *win) {
#ifdef HAVE_API_WIN32_CE
struct window_priv *win_priv = win->priv;
- if ( win_priv && !win_priv->hBackLight )
- {
+ if ( win_priv && !win_priv->hBackLight ) {
win_priv->hBackLight = SetPowerRequirement(TEXT("BKL1:"), 0, 0x01, NULL, 0);
event_win32_add_timeout(29000, 1, callback_new(SystemIdleTimerReset, 0, NULL));
}
@@ -643,8 +605,7 @@ static void disable_suspend(struct window *win)
static const TCHAR g_szClassName[] = {'N','A','V','G','R','A','\0'};
-static HANDLE CreateGraphicsWindows( struct graphics_priv* gr, HMENU hMenu )
-{
+static HANDLE CreateGraphicsWindows( struct graphics_priv* gr, HMENU hMenu ) {
int wStyle = WS_VISIBLE;
HWND hwnd;
#ifdef HAVE_API_WIN32_CE
@@ -689,20 +650,18 @@ static HANDLE CreateGraphicsWindows( struct graphics_priv* gr, HMENU hMenu )
if (!RegisterClassEx(&wc))
#endif
{
- dbg(lvl_error, "Window registration failed\n");
+ dbg(lvl_error, "Window registration failed");
return NULL;
}
- if(gr->frame)
- {
- if ( hMenu )
- {
+ if(gr->frame) {
+ if ( hMenu ) {
wStyle = WS_CHILD;
} else {
wStyle = WS_OVERLAPPED|WS_VISIBLE;
}
} else {
- wStyle = WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
+ wStyle = WS_VISIBLE | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
}
#ifdef HAVE_API_WIN32_CE
@@ -730,25 +689,24 @@ static HANDLE CreateGraphicsWindows( struct graphics_priv* gr, HMENU hMenu )
GetModuleHandle(NULL),
NULL);
#endif
- if (hwnd == NULL)
- {
- dbg(lvl_error, "Window creation failed: %d\n", GetLastError());
+ if (hwnd == NULL) {
+ dbg(lvl_error, "Window creation failed: %d", GetLastError());
return NULL;
}
/* For Vista, we need here ChangeWindowMessageFilter(WM_COPYDATA,MSGFLT_ADD); since Win7 we need above one or ChangeWindowMessageFilterEx (MSDN), both are
not avail for earlier Win and not present in my mingw :(. ChangeWindowMessageFilter may not be present in later Win versions. Welcome late binding!
*/
if(gr->ChangeWindowMessageFilter)
- gr->ChangeWindowMessageFilter(WM_COPYDATA,1 /*MSGFLT_ADD*/);
- else if(gr->ChangeWindowMessageFilterEx)
- gr->ChangeWindowMessageFilterEx(hwnd,WM_COPYDATA,1 /*MSGFLT_ALLOW*/,NULL);
+ gr->ChangeWindowMessageFilter(WM_COPYDATA,1 /*MSGFLT_ADD*/);
+ else if(gr->ChangeWindowMessageFilterEx)
+ gr->ChangeWindowMessageFilterEx(hwnd,WM_COPYDATA,1 /*MSGFLT_ALLOW*/,NULL);
gr->wnd_handle = hwnd;
callback_list_call_attr_2(gr->cbl, attr_resize, (void *)gr->width, (void *)gr->height);
create_memory_dc(gr);
- SetWindowLongPtr( hwnd , DWLP_USER, (LONG_PTR)gr );
+ SetWindowLongPtr( hwnd, DWLP_USER, (LONG_PTR)gr );
ShowWindow( hwnd, SW_SHOW );
UpdateWindow( hwnd );
@@ -760,38 +718,33 @@ static HANDLE CreateGraphicsWindows( struct graphics_priv* gr, HMENU hMenu )
-static void graphics_destroy(struct graphics_priv *gr)
-{
+static void graphics_destroy(struct graphics_priv *gr) {
g_free( gr );
}
-static void gc_destroy(struct graphics_gc_priv *gc)
-{
+static void gc_destroy(struct graphics_gc_priv *gc) {
DeleteObject( gc->hpen );
DeleteObject( gc->hbrush );
g_free( gc );
}
-static void gc_set_linewidth(struct graphics_gc_priv *gc, int w)
-{
+static void gc_set_linewidth(struct graphics_gc_priv *gc, int w) {
DeleteObject (gc->hpen);
gc->line_width = w;
gc->hpen = CreatePen(gc->dashed?PS_DASH:PS_SOLID, gc->line_width, gc->fg_color );
}
-static void gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n)
-{
- gc->dashed=n>0;
- DeleteObject (gc->hpen);
- gc->hpen = CreatePen(gc->dashed?PS_DASH:PS_SOLID, gc->line_width, gc->fg_color );
+static void gc_set_dashes(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n) {
+ gc->dashed=n>0;
+ DeleteObject (gc->hpen);
+ gc->hpen = CreatePen(gc->dashed?PS_DASH:PS_SOLID, gc->line_width, gc->fg_color );
// gdk_gc_set_dashes(gc->gc, 0, (gint8 *)dash_list, n);
// gdk_gc_set_line_attributes(gc->gc, 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_ROUND, GDK_JOIN_ROUND);
}
-static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c) {
gc->fg_color = RGB( c->r >> 8, c->g >> 8, c->b >> 8);
gc->fg_alpha = c->a;
@@ -799,15 +752,13 @@ static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
DeleteObject (gc->hbrush);
gc->hpen = CreatePen(gc->dashed?PS_DASH:PS_SOLID, gc->line_width, gc->fg_color );
gc->hbrush = CreateSolidBrush( gc->fg_color );
- if ( gc->gr && c->a < 0xFFFF )
- {
- gc->gr->transparent_color = *c;
+ if ( gc->gr && c->a < 0xFFFF ) {
+ gc->gr->transparent_color = *c;
}
}
-static void gc_set_background(struct graphics_gc_priv *gc, struct color *c)
-{
+static void gc_set_background(struct graphics_gc_priv *gc, struct color *c) {
gc->bg_color = RGB( c->r >> 8, c->g >> 8, c->b >> 8);
gc->bg_alpha = c->a;
if ( gc->gr && gc->gr->hMemDC )
@@ -815,8 +766,7 @@ static void gc_set_background(struct graphics_gc_priv *gc, struct color *c)
}
-static struct graphics_gc_methods gc_methods =
-{
+static struct graphics_gc_methods gc_methods = {
gc_destroy,
gc_set_linewidth,
gc_set_dashes,
@@ -824,8 +774,7 @@ static struct graphics_gc_methods gc_methods =
gc_set_background,
};
-static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
-{
+static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth) {
struct graphics_gc_priv *gc=g_new(struct graphics_gc_priv, 1);
*meth=gc_methods;
gc->hwnd = gr->wnd_handle;
@@ -842,23 +791,18 @@ static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics
}
-static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
+static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
int i;
HPEN hpenold = SelectObject( gr->hMemDC, gc->hpen );
int oldbkmode=SetBkMode( gr->hMemDC, TRANSPARENT);
int first = 1;
- for ( i = 0; i< count; i++ )
- {
- if ( first )
- {
+ for ( i = 0; i< count; i++ ) {
+ if ( first ) {
first = 0;
MoveToEx( gr->hMemDC, p[0].x, p[0].y, NULL );
- }
- else
- {
+ } else {
LineTo( gr->hMemDC, p[i].x, p[i].y );
}
}
@@ -866,28 +810,25 @@ static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, st
SelectObject( gr->hMemDC, hpenold);
}
-static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
-{
+static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count) {
HPEN holdpen = SelectObject( gr->hMemDC, gc->hpen );
HBRUSH holdbrush = SelectObject( gr->hMemDC, gc->hbrush );
if (sizeof(POINT) != sizeof(struct point)) {
- int i;
- POINT* points=g_alloca(sizeof(POINT)*count);
- for ( i=0;i< count; i++ )
- {
- points[i].x = p[i].x;
- points[i].y = p[i].y;
- }
- Polygon( gr->hMemDC, points,count );
+ int i;
+ POINT* points=g_alloca(sizeof(POINT)*count);
+ for ( i=0; i< count; i++ ) {
+ points[i].x = p[i].x;
+ points[i].y = p[i].y;
+ }
+ Polygon( gr->hMemDC, points,count );
} else
- Polygon( gr->hMemDC, (POINT *)p, count);
+ Polygon( gr->hMemDC, (POINT *)p, count);
SelectObject( gr->hMemDC, holdbrush);
SelectObject( gr->hMemDC, holdpen);
}
-static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
-{
+static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
HPEN holdpen = SelectObject( gr->hMemDC, gc->hpen );
HBRUSH holdbrush = SelectObject( gr->hMemDC, gc->hbrush );
@@ -897,8 +838,7 @@ static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc
SelectObject( gr->hMemDC, holdpen);
}
-static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
-{
+static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r) {
HPEN holdpen = SelectObject( gr->hMemDC, gc->hpen );
HBRUSH holdbrush = SelectObject( gr->hMemDC, GetStockObject(NULL_BRUSH));
@@ -911,43 +851,32 @@ static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, s
}
-static void draw_drag(struct graphics_priv *gr, struct point *p)
-{
- if ( p )
- {
+static void draw_drag(struct graphics_priv *gr, struct point *p) {
+ if ( p ) {
gr->p.x = p->x;
gr->p.y = p->y;
if ( p->x < 0 || p->y < 0 ||
- ( gr->parent && ((p->x + gr->width > gr->parent->width) || (p->y + gr->height > gr->parent->height) )))
- {
+ ( gr->parent && ((p->x + gr->width > gr->parent->width) || (p->y + gr->height > gr->parent->height) ))) {
gr->disabled = TRUE;
- }
- else
- {
+ } else {
gr->disabled = FALSE;
}
}
}
-static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
-{
- dbg(lvl_debug, "set draw_mode to %x, %d\n", gr, (int)mode );
+static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode) {
+ dbg(lvl_debug, "set draw_mode to %x, %d", gr, (int)mode );
- if ( mode == draw_mode_begin )
- {
- if ( gr->wnd_handle == NULL )
- {
+ if ( mode == draw_mode_begin ) {
+ if ( gr->wnd_handle == NULL ) {
CreateGraphicsWindows( gr, (HMENU)ID_CHILD_GFX );
}
- if ( gr->mode != draw_mode_begin )
- {
- if ( gr->hMemDC )
- {
- dbg(lvl_debug, "Erase dc: %x, w: %d, h: %d, bg_color: %x\n", gr, gr->width, gr->height, gr->bg_color);
+ if ( gr->mode != draw_mode_begin ) {
+ if ( gr->hMemDC ) {
+ dbg(lvl_debug, "Erase dc: %x, w: %d, h: %d, bg_color: %x", gr, gr->width, gr->height, gr->bg_color);
#ifdef FAST_TRANSPARENCY
- if ( gr->hPrebuildDC )
- {
+ if ( gr->hPrebuildDC ) {
(void)SelectBitmap(gr->hPrebuildDC, gr->hOldPrebuildBitmap );
DeleteBitmap(gr->hPrebuildBitmap);
DeleteDC(gr->hPrebuildDC);
@@ -957,8 +886,7 @@ static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
}
}
#ifdef FAST_TRANSPARENCY
- else if ( gr->hPrebuildDC )
- {
+ else if ( gr->hPrebuildDC ) {
(void)SelectBitmap(gr->hPrebuildDC, gr->hOldPrebuildBitmap );
DeleteBitmap(gr->hPrebuildBitmap);
DeleteDC(gr->hPrebuildDC);
@@ -968,8 +896,7 @@ static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
}
// force paint
- if (mode == draw_mode_end && gr->mode == draw_mode_begin)
- {
+ if (mode == draw_mode_end && gr->mode == draw_mode_begin) {
InvalidateRect( gr->wnd_handle, NULL, FALSE );
}
@@ -977,20 +904,16 @@ static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
}
-static void * get_data(struct graphics_priv *this_, const char *type)
-{
- if ( strcmp( "wnd_parent_handle_ptr", type ) == 0 )
- {
+static void * get_data(struct graphics_priv *this_, const char *type) {
+ if ( strcmp( "wnd_parent_handle_ptr", type ) == 0 ) {
return &( this_->wnd_parent_handle );
}
- if ( strcmp( "START_CLIENT", type ) == 0 )
- {
+ if ( strcmp( "START_CLIENT", type ) == 0 ) {
CreateGraphicsWindows( this_, (HMENU)ID_CHILD_GFX );
return NULL;
}
- if (!strcmp(type, "window"))
- {
- CreateGraphicsWindows( this_ , NULL);
+ if (!strcmp(type, "window")) {
+ CreateGraphicsWindows( this_, NULL);
this_->window.fullscreen = fullscreen;
this_->window.disable_suspend = disable_suspend;
@@ -1003,8 +926,7 @@ static void * get_data(struct graphics_priv *this_, const char *type)
}
-static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
-{
+static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc) {
RECT rcClient = { 0, 0, gr->width, gr->height };
HBRUSH bgBrush;
@@ -1015,15 +937,14 @@ static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
DeleteObject( bgBrush );
}
-struct graphics_font_priv
-{
+struct graphics_font_priv {
LOGFONT lf;
HFONT hfont;
int size;
};
-static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
-{
+static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg,
+ struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy) {
RECT rcClient;
int prevBkMode;
HFONT hOldFont;
@@ -1033,8 +954,7 @@ static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, str
prevBkMode = SetBkMode( gr->hMemDC, TRANSPARENT );
- if ( NULL == font->hfont )
- {
+ if ( NULL == font->hfont ) {
#ifdef WIN_USE_SYSFONT
font->hfont = (HFONT) GetStockObject (SYSTEM_FONT);
GetObject (font->hfont, sizeof (LOGFONT), &font->lf);
@@ -1064,22 +984,21 @@ static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, str
SetBkMode (gr->hMemDC, TRANSPARENT);
if (ConvertUTF8toUTF16(&utf8, utf8+strlen(text),
&utf16p, utf16p+sizeof(utf16),
- lenientConversion) == conversionOK)
- {
- if(bg && bg->fg_alpha) {
- SetTextColor(gr->hMemDC, bg->fg_color);
- ExtTextOutW(gr->hMemDC, -1, -1, 0, NULL,
- utf16, (wchar_t*) utf16p - utf16, NULL);
- ExtTextOutW(gr->hMemDC, 1, 1, 0, NULL,
- utf16, (wchar_t*) utf16p - utf16, NULL);
- ExtTextOutW(gr->hMemDC, -1, 1, 0, NULL,
- utf16, (wchar_t*) utf16p - utf16, NULL);
- ExtTextOutW(gr->hMemDC, 1, -1, 0, NULL,
- utf16, (wchar_t*) utf16p - utf16, NULL);
+ lenientConversion) == conversionOK) {
+ if(bg && bg->fg_alpha) {
+ SetTextColor(gr->hMemDC, bg->fg_color);
+ ExtTextOutW(gr->hMemDC, -1, -1, 0, NULL,
+ utf16, (wchar_t*) utf16p - utf16, NULL);
+ ExtTextOutW(gr->hMemDC, 1, 1, 0, NULL,
+ utf16, (wchar_t*) utf16p - utf16, NULL);
+ ExtTextOutW(gr->hMemDC, -1, 1, 0, NULL,
+ utf16, (wchar_t*) utf16p - utf16, NULL);
+ ExtTextOutW(gr->hMemDC, 1, -1, 0, NULL,
+ utf16, (wchar_t*) utf16p - utf16, NULL);
}
- SetTextColor(gr->hMemDC, fg->fg_color);
+ SetTextColor(gr->hMemDC, fg->fg_color);
ExtTextOutW(gr->hMemDC, 0, 0, 0, NULL,
- utf16, (wchar_t*) utf16p - utf16, NULL);
+ utf16, (wchar_t*) utf16p - utf16, NULL);
}
}
@@ -1092,22 +1011,19 @@ static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, str
SetViewportOrgEx (gr->hMemDC, 0, 0, NULL) ;
}
-static void font_destroy(struct graphics_font_priv *font)
-{
- if ( font->hfont )
- {
+static void font_destroy(struct graphics_font_priv *font) {
+ if ( font->hfont ) {
DeleteObject(font->hfont);
}
g_free(font);
}
-static struct graphics_font_methods font_methods =
-{
+static struct graphics_font_methods font_methods = {
font_destroy
};
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *name, int size, int flags)
-{
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *name,
+ int size, int flags) {
struct graphics_font_priv *font=g_new(struct graphics_font_priv, 1);
*meth = font_methods;
@@ -1119,9 +1035,7 @@ static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct grap
#include "png.h"
-static int
-pngdecode(struct graphics_priv *gr, char *name, struct graphics_image_priv *img)
-{
+static int pngdecode(struct graphics_priv *gr, char *name, struct graphics_image_priv *img) {
png_struct *png_ptr = NULL;
png_info *info_ptr = NULL;
png_byte buf[8];
@@ -1129,33 +1043,29 @@ pngdecode(struct graphics_priv *gr, char *name, struct graphics_image_priv *img)
int bit_depth;
int color_type;
- int alpha_present;
int ret;
int i;
FILE *png_file;
BITMAPINFO pnginfo;
HDC dc;
- dbg(lvl_debug,"enter %s\n",name);
+ dbg(lvl_debug,"enter %s",name);
png_file=fopen(name, "rb");
- if (!png_file)
- {
- dbg(lvl_warning,"failed to open %s\n",name);
+ if (!png_file) {
+ dbg(lvl_warning,"failed to open %s",name);
return FALSE;
}
/* read and check signature in PNG file */
ret = fread (buf, 1, 8, png_file);
- if (ret != 8)
- {
+ if (ret != 8) {
fclose(png_file);
return FALSE;
}
ret = png_check_sig (buf, 8);
- if (!ret)
- {
+ if (!ret) {
fclose(png_file);
return FALSE;
}
@@ -1164,22 +1074,19 @@ pngdecode(struct graphics_priv *gr, char *name, struct graphics_image_priv *img)
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
- if (!png_ptr)
- {
+ if (!png_ptr) {
fclose(png_file);
return FALSE; /* out of memory */
}
info_ptr = png_create_info_struct (png_ptr);
- if (!info_ptr)
- {
+ if (!info_ptr) {
fclose(png_file);
png_destroy_read_struct (&png_ptr, NULL, NULL);
return FALSE; /* out of memory */
}
- if (setjmp (png_jmpbuf(png_ptr)))
- {
+ if (setjmp (png_jmpbuf(png_ptr))) {
fclose(png_file);
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return FALSE;
@@ -1204,20 +1111,20 @@ pngdecode(struct graphics_priv *gr, char *name, struct graphics_image_priv *img)
png_set_palette_to_rgb(png_ptr);
/* expand images to bit-depth 8 (only applicable for grayscale images) */
- if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA && bit_depth < 8)
- png_set_gray_1_2_4_to_8(png_ptr);
+ if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA && bit_depth < 8)
+ png_set_gray_1_2_4_to_8(png_ptr);
/* Expand grayscale to rgb */
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- png_set_gray_to_rgb(png_ptr);
+ png_set_gray_to_rgb(png_ptr);
/* expand colored images to bit-depth 8 */
if (color_type == PNG_COLOR_TYPE_RGB && bit_depth < 8)
png_set_packing(png_ptr);
/* transform transparency maps into full alpha-channel */
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
- png_set_tRNS_to_alpha(png_ptr);
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ png_set_tRNS_to_alpha(png_ptr);
/* Add opaque alpha channel if no alpha channel exist */
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_PALETTE)
@@ -1235,8 +1142,7 @@ pngdecode(struct graphics_priv *gr, char *name, struct graphics_image_priv *img)
png_read_update_info (png_ptr, info_ptr);
img->channels = 4;
- alpha_present = 1;
-
+
/* row_bytes is the width x number of channels x (bit-depth / 8) */
img->row_bytes = png_get_rowbytes (png_ptr, info_ptr);
@@ -1248,11 +1154,10 @@ pngdecode(struct graphics_priv *gr, char *name, struct graphics_image_priv *img)
pnginfo.bmiHeader.biCompression = BI_RGB;
pnginfo.bmiHeader.biPlanes = 1;
dc = CreateCompatibleDC(NULL);
- img->hBitmap = CreateDIBSection(dc, &pnginfo, DIB_RGB_COLORS , (void **)&img->png_pixels, NULL, 0);
+ img->hBitmap = CreateDIBSection(dc, &pnginfo, DIB_RGB_COLORS, (void **)&img->png_pixels, NULL, 0);
DeleteDC(dc);
- if ((row_pointers = (png_byte **) g_malloc (img->height * sizeof (png_bytep))) == NULL)
- {
+ if ((row_pointers = (png_byte **) g_malloc (img->height * sizeof (png_bytep))) == NULL) {
fclose(png_file);
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
g_free (img->png_pixels);
@@ -1278,128 +1183,114 @@ pngdecode(struct graphics_priv *gr, char *name, struct graphics_image_priv *img)
g_free (row_pointers);
img->hot.x=img->width/2-1;
img->hot.y=img->height/2-1;
- dbg(lvl_debug,"ok\n");
+ dbg(lvl_debug,"ok");
fclose(png_file);
return TRUE;
} /* end of source */
-static void pngscale(struct graphics_image_priv *img, struct graphics_priv *gr, int width, int height)
-{
- HBITMAP origBmp;
+static void pngscale(struct graphics_image_priv *img, struct graphics_priv *gr, int width, int height) {
+ HBITMAP origBmp;
+ BITMAPINFO pnginfo;
+ HDC dc1, dc2;
+
+ origBmp=img->hBitmap;
+
+ memset(&pnginfo, 0, sizeof(pnginfo));
+ pnginfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ pnginfo.bmiHeader.biWidth = width;
+ pnginfo.bmiHeader.biHeight = -height;
+ pnginfo.bmiHeader.biBitCount = 32;
+ pnginfo.bmiHeader.biCompression = BI_RGB;
+ pnginfo.bmiHeader.biPlanes = 1;
+ dc1 = CreateCompatibleDC(NULL);
+ dc2 = CreateCompatibleDC(NULL);
+ img->hBitmap = CreateDIBSection(dc1, &pnginfo, DIB_RGB_COLORS, (void **)&(img->png_pixels), NULL, 0);
+
+ if(gr->SetStretchBltMode) {
+ gr->SetStretchBltMode(dc1,STRETCH_HALFTONE);
+ SetBrushOrgEx(dc1,0,0,NULL);
+ }
+
+ SelectBitmap(dc1,img->hBitmap);
+ SelectBitmap(dc2,origBmp);
+
+ StretchBlt(dc1,0,0,width, height, dc2, 0,0, img->width, img->height,SRCCOPY);
+ img->width=width;
+ img->height=height;
+ img->hot.x=width/2-1;
+ img->hot.y=height/2-1;
+
+ DeleteDC(dc1);
+ DeleteDC(dc2);
+ DeleteObject(origBmp);
+}
+
+
+static void pngrender(struct graphics_image_priv *img, struct graphics_priv *gr, int x0, int y0) {
+ if (gr->AlphaBlend && img->hBitmap) {
+ HDC hdc;
+ HBITMAP oldBitmap;
+ BLENDFUNCTION blendFunction ;
+ blendFunction.BlendOp = AC_SRC_OVER;
+ blendFunction.BlendFlags = 0;
+ blendFunction.SourceConstantAlpha = 255;
+ blendFunction.AlphaFormat = AC_SRC_ALPHA;
+ hdc = CreateCompatibleDC(NULL);
+ oldBitmap = SelectBitmap(hdc, img->hBitmap);
+ gr->AlphaBlend(gr->hMemDC, x0, y0, img->width, img->height, hdc, 0, 0, img->width, img->height, blendFunction);
+ (void)SelectBitmap(hdc, oldBitmap);
+ DeleteDC(hdc);
+ } else {
+ int x, y;
+ HDC hdc=gr->hMemDC;
+ png_byte *pix_ptr = img->png_pixels;
+ COLORREF *pixeldata;
+ HDC dc;
+ HBITMAP bitmap;
+ HBITMAP oldBitmap;
+
BITMAPINFO pnginfo;
- HDC dc1, dc2;
- png_byte *origPixels;
-
- origBmp=img->hBitmap;
- origPixels=img->png_pixels;
memset(&pnginfo, 0, sizeof(pnginfo));
pnginfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- pnginfo.bmiHeader.biWidth = width;
- pnginfo.bmiHeader.biHeight = -height;
+ pnginfo.bmiHeader.biWidth = img->width;
+ pnginfo.bmiHeader.biHeight = -img->height;
pnginfo.bmiHeader.biBitCount = 32;
pnginfo.bmiHeader.biCompression = BI_RGB;
pnginfo.bmiHeader.biPlanes = 1;
- dc1 = CreateCompatibleDC(NULL);
- dc2 = CreateCompatibleDC(NULL);
- img->hBitmap = CreateDIBSection(dc1, &pnginfo, DIB_RGB_COLORS , (void **)&(img->png_pixels), NULL, 0);
-
- if(gr->SetStretchBltMode) {
- gr->SetStretchBltMode(dc1,STRETCH_HALFTONE);
- SetBrushOrgEx(dc1,0,0,NULL);
- }
-
- SelectBitmap(dc1,img->hBitmap);
- SelectBitmap(dc2,origBmp);
-
- StretchBlt(dc1,0,0,width, height, dc2, 0,0, img->width, img->height,SRCCOPY);
- img->width=width;
- img->height=height;
- img->hot.x=width/2-1;
- img->hot.y=height/2-1;
-
- DeleteDC(dc1);
- DeleteDC(dc2);
- DeleteObject(origBmp);
-}
-
+ dc = CreateCompatibleDC(NULL);
+ bitmap = CreateDIBSection(hdc, &pnginfo, DIB_RGB_COLORS, (void **)&pixeldata, NULL, 0);
+ oldBitmap = SelectBitmap(dc, bitmap);
+ BitBlt(dc, 0, 0, img->width, img->height, hdc, x0, y0, SRCCOPY);
+ for (y=0 ; y < img->width ; y++) {
+ for (x=0 ; x < img->height ; x++) {
+ int b = pix_ptr[0];
+ int g = pix_ptr[1];
+ int r = pix_ptr[2];
+ int a = pix_ptr[3];
+ if (a != 0xff) {
+ int p = *pixeldata;
+ int ai = 0xff - a;
+ r = (r * a + ((p >> 16) & 0xff) * ai) / 255;
+ g = (g * a + ((p >> 8) & 0xff) * ai) / 255;
+ b = (b * a + ((p >> 0) & 0xff) * ai) / 255;
+ }
+ *pixeldata++ = (r << 16) | (g << 8) | b;
+ pix_ptr+=img->channels;
+ }
+ }
-static void
-pngrender(struct graphics_image_priv *img, struct graphics_priv *gr, int x0, int y0)
-{
- if (gr->AlphaBlend && img->hBitmap)
- {
- HDC hdc;
- HBITMAP oldBitmap;
- BLENDFUNCTION blendFunction ;
- blendFunction.BlendOp = AC_SRC_OVER;
- blendFunction.BlendFlags = 0;
- blendFunction.SourceConstantAlpha = 255;
- blendFunction.AlphaFormat = AC_SRC_ALPHA;
- hdc = CreateCompatibleDC(NULL);
- oldBitmap = SelectBitmap(hdc, img->hBitmap);
- gr->AlphaBlend(gr->hMemDC, x0, y0, img->width, img->height, hdc, 0, 0, img->width, img->height, blendFunction);
- (void)SelectBitmap(hdc, oldBitmap);
- DeleteDC(hdc);
- }
- else
- {
- int x, y;
- HDC hdc=gr->hMemDC;
- png_byte *pix_ptr = img->png_pixels;
- COLORREF *pixeldata;
- HDC dc;
- HBITMAP bitmap;
- HBITMAP oldBitmap;
-
- BITMAPINFO pnginfo;
-
- memset(&pnginfo, 0, sizeof(pnginfo));
- pnginfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- pnginfo.bmiHeader.biWidth = img->width;
- pnginfo.bmiHeader.biHeight = -img->height;
- pnginfo.bmiHeader.biBitCount = 32;
- pnginfo.bmiHeader.biCompression = BI_RGB;
- pnginfo.bmiHeader.biPlanes = 1;
- dc = CreateCompatibleDC(NULL);
- bitmap = CreateDIBSection(hdc, &pnginfo, DIB_RGB_COLORS, (void **)&pixeldata, NULL, 0);
- oldBitmap = SelectBitmap(dc, bitmap);
- BitBlt(dc, 0, 0, img->width, img->height, hdc, x0, y0, SRCCOPY);
- for (y=0 ; y < img->width ; y++)
- {
- for (x=0 ; x < img->height ; x++)
- {
- int b = pix_ptr[0];
- int g = pix_ptr[1];
- int r = pix_ptr[2];
- int a = pix_ptr[3];
- if (a != 0xff)
- {
- int p = *pixeldata;
- int ai = 0xff - a;
- r = (r * a + ((p >> 16) & 0xff) * ai) / 255;
- g = (g * a + ((p >> 8) & 0xff) * ai) / 255;
- b = (b * a + ((p >> 0) & 0xff) * ai) / 255;
- }
- *pixeldata++ = (r << 16) | (g << 8) | b;
- pix_ptr+=img->channels;
- }
- }
-
- BitBlt(hdc, x0, y0, img->width, img->height, dc, 0, 0, SRCCOPY);
- (void)SelectBitmap(dc, oldBitmap);
- DeleteBitmap(bitmap);
- DeleteDC(dc);
- }
+ BitBlt(hdc, x0, y0, img->width, img->height, dc, 0, 0, SRCCOPY);
+ (void)SelectBitmap(dc, oldBitmap);
+ DeleteBitmap(bitmap);
+ DeleteDC(dc);
+ }
}
-static int
-xpmdecode(char *name, struct graphics_image_priv *img)
-{
+static int xpmdecode(char *name, struct graphics_image_priv *img) {
img->pxpm = Xpm2bmp_new();
- if (Xpm2bmp_load( img->pxpm, name ) != 0)
- {
+ if (Xpm2bmp_load( img->pxpm, name ) != 0) {
g_free(img->pxpm);
return FALSE;
}
@@ -1412,21 +1303,19 @@ xpmdecode(char *name, struct graphics_image_priv *img)
-static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot, int rotation)
-{
+static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name,
+ int *w, int *h, struct point *hot, int rotation) {
struct graphics_image_priv* ret;
-
+
char* hash_key = g_strdup_printf("%s_%d_%d_%d",name,*w,*h,rotation);
-
- if ( !g_hash_table_lookup_extended( gr->image_cache_hash, hash_key, NULL, (gpointer)&ret) )
- {
+
+ if ( !g_hash_table_lookup_extended( gr->image_cache_hash, hash_key, NULL, (gpointer)&ret) ) {
int len=strlen(name);
int rc=0;
- if (len >= 4)
- {
+ if (len >= 4) {
char *ext;
- dbg(lvl_info, "loading image '%s'\n", name );
+ dbg(lvl_info, "loading image '%s'", name );
ret = g_new0( struct graphics_image_priv, 1 );
ext = name+len-4;
if (!strcmp(ext,".xpm")) {
@@ -1436,7 +1325,7 @@ static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct gr
}
}
if (!rc) {
- dbg(lvl_warning, "failed loading '%s'\n", name );
+ dbg(lvl_warning, "failed loading '%s'", name );
g_free(ret);
ret=NULL;
}
@@ -1453,11 +1342,11 @@ static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct gr
if(ret->png_pixels && ret->hBitmap)
pngscale(ret, gr, *w, *h);
}
- }
+ }
}
if (ret) {
- *w=ret->width;
- *h=ret->height;
+ *w=ret->width;
+ *h=ret->height;
if (hot)
*hot=ret->hot;
}
@@ -1466,23 +1355,20 @@ static struct graphics_image_priv *image_new(struct graphics_priv *gr, struct gr
}
-static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
-{
+static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p,
+ struct graphics_image_priv *img) {
if (img->pxpm)
- Xpm2bmp_paint( img->pxpm , gr->hMemDC, p->x, p->y );
+ Xpm2bmp_paint( img->pxpm, gr->hMemDC, p->x, p->y );
if (img->png_pixels)
pngrender(img, gr, p->x, p->y);
}
-static struct graphics_priv *
- graphics_win32_new_helper(struct graphics_methods *meth);
+static struct graphics_priv *graphics_win32_new_helper(struct graphics_methods *meth);
-static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
-{
- dbg(lvl_debug, "resize overlay: %x, x: %d, y: %d, w: %d, h: %d, wraparound: %d\n", gr, p->x, p->y, w, h, wraparound);
+static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound) {
+ dbg(lvl_debug, "resize overlay: %x, x: %d, y: %d, w: %d, h: %d, wraparound: %d", gr, p->x, p->y, w, h, wraparound);
- if ( gr->width != w || gr->height != h )
- {
+ if ( gr->width != w || gr->height != h ) {
gr->width = w;
gr->height = h;
create_memory_dc(gr);
@@ -1493,11 +1379,10 @@ static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int
}
-static struct graphics_priv *
- overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
-{
+static struct graphics_priv *overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p,
+ int w, int h, int wraparound) {
struct graphics_priv *this=graphics_win32_new_helper(meth);
- dbg(lvl_debug, "overlay: %x, x: %d, y: %d, w: %d, h: %d, wraparound: %d\n", this, p->x, p->y, w, h, wraparound);
+ dbg(lvl_debug, "overlay: %x, x: %d, y: %d, w: %d, h: %d, wraparound: %d", this, p->x, p->y, w, h, wraparound);
this->width = w;
this->height = h;
this->parent = gr;
@@ -1507,20 +1392,17 @@ static struct graphics_priv *
this->hPrebuildDC = 0;
this->AlphaBlend = gr->AlphaBlend;
this->image_cache_hash = gr->image_cache_hash;
-
+
this->next = gr->overlays;
gr->overlays = this;
this->wnd_handle = gr->wnd_handle;
- if (wraparound)
- {
- if ( p->x < 0 )
- {
+ if (wraparound) {
+ if ( p->x < 0 ) {
this->p.x += gr->width;
}
- if ( p->y < 0 )
- {
+ if ( p->y < 0 ) {
this->p.y += gr->height;
}
}
@@ -1529,21 +1411,20 @@ static struct graphics_priv *
return this;
}
-static void overlay_disable(struct graphics_priv *gr, int disable)
-{
- dbg(lvl_debug, "overlay: %x, disable: %d\n", gr, disable);
+static void overlay_disable(struct graphics_priv *gr, int disable) {
+ dbg(lvl_debug, "overlay: %x, disable: %d", gr, disable);
gr->disabled = disable;
}
-static void get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate)
-{
+static void get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy,
+ struct point *ret, int estimate) {
int len = g_utf8_strlen(text, -1);
int xMin = 0;
int yMin = 0;
int yMax = 13*font->size/256;
int xMax = 9*font->size*len/256;
- dbg(lvl_info, "Get bbox for %s\n", text);
+ dbg(lvl_info, "Get bbox for %s", text);
ret[0].x = xMin;
ret[0].y = -yMin;
@@ -1556,8 +1437,7 @@ static void get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *f
}
-static struct graphics_methods graphics_methods =
-{
+static struct graphics_methods graphics_methods = {
graphics_destroy,
draw_mode,
draw_lines,
@@ -1582,22 +1462,19 @@ static struct graphics_methods graphics_methods =
get_text_bbox,
overlay_disable,
overlay_resize,
- NULL, /* show_native_keyboard */
- NULL, /* hide_native_keyboard */
+ NULL, /* show_native_keyboard */
+ NULL, /* hide_native_keyboard */
};
-static struct graphics_priv *
- graphics_win32_new_helper(struct graphics_methods *meth)
-{
+static struct graphics_priv *graphics_win32_new_helper(struct graphics_methods *meth) {
struct graphics_priv *this_=g_new0(struct graphics_priv,1);
*meth=graphics_methods;
this_->mode = -1;
return this_;
}
-static void bind_late(struct graphics_priv* gra_priv)
-{
+static void bind_late(struct graphics_priv* gra_priv) {
#if HAVE_API_WIN32_CE
gra_priv->hCoreDll = LoadLibrary(TEXT("coredll.dll"));
#else
@@ -1605,43 +1482,36 @@ static void bind_late(struct graphics_priv* gra_priv)
gra_priv->hGdi32Dll = LoadLibrary(TEXT("gdi32.dll"));
gra_priv->hUser32Dll = GetModuleHandle("user32.dll");
#endif
- if ( gra_priv->hCoreDll )
- {
+ if ( gra_priv->hCoreDll ) {
gra_priv->AlphaBlend = (FP_AlphaBlend)GetProcAddress(gra_priv->hCoreDll, TEXT("AlphaBlend") );
- if (!gra_priv->AlphaBlend)
- {
- dbg(lvl_warning, "AlphaBlend not supported\n");
+ if (!gra_priv->AlphaBlend) {
+ dbg(lvl_warning, "AlphaBlend not supported");
}
#if HAVE_API_WIN32_CE
gra_priv->SetStretchBltMode= (FP_SetStretchBltMode)GetProcAddress(gra_priv->hCoreDll, TEXT("SetStretchBltMode") );
#else
gra_priv->SetStretchBltMode= (FP_SetStretchBltMode)GetProcAddress(gra_priv->hGdi32Dll, TEXT("SetStretchBltMode") );
#endif
- if (!gra_priv->SetStretchBltMode)
- {
- dbg(lvl_warning, "SetStretchBltMode not supported\n");
+ if (!gra_priv->SetStretchBltMode) {
+ dbg(lvl_warning, "SetStretchBltMode not supported");
}
+ } else {
+ dbg(lvl_error, "Error loading coredll");
}
- else
- {
- dbg(lvl_error, "Error loading coredll\n");
- }
-
+
if(gra_priv->hUser32Dll) {
- gra_priv->ChangeWindowMessageFilterEx=GetProcAddress(gra_priv->hUser32Dll,"ChangeWindowMessageFilterEx");
- gra_priv->ChangeWindowMessageFilter=GetProcAddress(gra_priv->hUser32Dll,"ChangeWindowMessageFilter");
+ gra_priv->ChangeWindowMessageFilterEx=GetProcAddress(gra_priv->hUser32Dll,"ChangeWindowMessageFilterEx");
+ gra_priv->ChangeWindowMessageFilter=GetProcAddress(gra_priv->hUser32Dll,"ChangeWindowMessageFilter");
}
}
-static struct graphics_priv*
- graphics_win32_new( struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
+static struct graphics_priv* graphics_win32_new( struct navit *nav, struct graphics_methods *meth, struct attr **attrs,
+ struct callback_list *cbl) {
struct attr *attr;
struct graphics_priv* this_;
- HMODULE user32;
if (!event_request_system("win32","graphics_win32"))
return NULL;
this_=graphics_win32_new_helper(meth);
@@ -1673,28 +1543,24 @@ static struct graphics_priv*
}
-static void
-event_win32_main_loop_run(void)
-{
+static void event_win32_main_loop_run(void) {
MSG msg;
- dbg(lvl_debug,"enter\n");
- while (GetMessage(&msg, 0, 0, 0))
- {
+ dbg(lvl_debug,"enter");
+ while (GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg); /* Keyboard input. */
DispatchMessage(&msg);
}
}
-static void event_win32_main_loop_quit(void)
-{
+static void event_win32_main_loop_quit(void) {
#ifdef HAVE_API_WIN32_CE
HWND hwndTaskbar;
HWND hwndSip;
#endif
- dbg(lvl_debug,"enter\n");
+ dbg(lvl_debug,"enter");
#ifdef HAVE_API_WIN32_CE
hwndTaskbar = FindWindow(L"HHTaskBar", NULL);
@@ -1707,42 +1573,33 @@ static void event_win32_main_loop_quit(void)
DestroyWindow(g_hwnd);
}
-static struct event_watch *
- event_win32_add_watch(int h, enum event_watch_cond cond, struct callback *cb)
-{
- dbg(lvl_debug,"enter\n");
+static struct event_watch *event_win32_add_watch(int h, enum event_watch_cond cond, struct callback *cb) {
+ dbg(lvl_debug,"enter");
return NULL;
}
-static void
-event_win32_remove_watch(struct event_watch *ev)
-{
- dbg(lvl_debug,"enter\n");
+static void event_win32_remove_watch(struct event_watch *ev) {
+ dbg(lvl_debug,"enter");
}
static GList *timers;
-struct event_timeout
-{
+struct event_timeout {
UINT_PTR timer_id;
int multi;
struct callback *cb;
struct event_timeout *next;
};
-static void run_timer(UINT_PTR idEvent)
-{
+static void run_timer(UINT_PTR idEvent) {
GList *l;
struct event_timeout *t;
l = timers;
- while (l)
- {
+ while (l) {
t = l->data;
- if (t->timer_id == idEvent)
- {
+ if (t->timer_id == idEvent) {
struct callback *cb = t->cb;
- dbg(lvl_info, "Timer %d (multi: %d)\n", t->timer_id, t->multi);
- if (!t->multi)
- {
+ dbg(lvl_info, "Timer %d (multi: %d)", t->timer_id, t->multi);
+ if (!t->multi) {
KillTimer(NULL, t->timer_id);
timers = g_list_remove(timers, t);
g_free(t);
@@ -1752,19 +1609,16 @@ static void run_timer(UINT_PTR idEvent)
}
l = g_list_next(l);
}
- dbg(lvl_error, "timer %d not found\n", idEvent);
+ dbg(lvl_error, "timer %d not found", idEvent);
}
static VOID CALLBACK win32_timer_cb(HWND hwnd, UINT uMsg,
UINT_PTR idEvent,
- DWORD dwTime)
-{
+ DWORD dwTime) {
run_timer(idEvent);
}
-static struct event_timeout *
- event_win32_add_timeout(int timeout, int multi, struct callback *cb)
-{
+static struct event_timeout *event_win32_add_timeout(int timeout, int multi, struct callback *cb) {
struct event_timeout *t;
t = g_new0(struct event_timeout, 1);
if (!t)
@@ -1773,25 +1627,20 @@ static struct event_timeout *
timers = g_list_prepend(timers, t);
t->cb = cb;
t->timer_id = SetTimer(NULL, 0, timeout, win32_timer_cb);
- dbg(lvl_debug, "Started timer %d for %d (multi: %d)\n", t->timer_id, timeout, multi);
+ dbg(lvl_debug, "Started timer %d for %d (multi: %d)", t->timer_id, timeout, multi);
return t;
}
-static void
-event_win32_remove_timeout(struct event_timeout *to)
-{
- if (to)
- {
+static void event_win32_remove_timeout(struct event_timeout *to) {
+ if (to) {
GList *l;
struct event_timeout *t=NULL;
- dbg(lvl_debug, "Try stopping timer %d\n", to->timer_id);
+ dbg(lvl_debug, "Try stopping timer %d", to->timer_id);
l = timers;
- while (l)
- {
+ while (l) {
t = l->data;
/* Use the pointer not the ID, IDs are reused */
- if (t == to)
- {
+ if (t == to) {
KillTimer(NULL, t->timer_id);
timers = g_list_remove(timers, t);
g_free(t);
@@ -1799,31 +1648,24 @@ event_win32_remove_timeout(struct event_timeout *to)
}
l = g_list_next(l);
}
- dbg(lvl_error, "Timer %d not found\n", to->timer_id);
+ dbg(lvl_error, "Timer %d not found", to->timer_id);
g_free(to);
}
}
-static struct event_idle *
- event_win32_add_idle(int priority, struct callback *cb)
-{
- return (struct event_idle *)event_win32_add_timeout(1, 1, cb);
+static struct event_idle *event_win32_add_idle(int priority, struct callback *cb) {
+ return (struct event_idle *)event_win32_add_timeout(1, 1, cb);
}
-static void
-event_win32_remove_idle(struct event_idle *ev)
-{
+static void event_win32_remove_idle(struct event_idle *ev) {
event_win32_remove_timeout((struct event_timeout *)ev);
}
-static void
-event_win32_call_callback(struct callback_list *cb)
-{
- PostMessage(g_hwnd, WM_USER+2, (WPARAM)cb , (LPARAM)0);
+static void event_win32_call_callback(struct callback_list *cb) {
+ PostMessage(g_hwnd, WM_USER+2, (WPARAM)cb, (LPARAM)0);
}
-static struct event_methods event_win32_methods =
-{
+static struct event_methods event_win32_methods = {
event_win32_main_loop_run,
event_win32_main_loop_quit,
event_win32_add_watch,
@@ -1835,16 +1677,12 @@ static struct event_methods event_win32_methods =
event_win32_call_callback,
};
-static struct event_priv *
- event_win32_new(struct event_methods *meth)
-{
+static struct event_priv *event_win32_new(struct event_methods *meth) {
*meth=event_win32_methods;
return NULL;
}
-void
-plugin_init(void)
-{
+void plugin_init(void) {
plugin_register_category_graphics("win32", graphics_win32_new);
plugin_register_category_event("win32", event_win32_new);
}
diff --git a/navit/graphics/win32/xpm2bmp.c b/navit/graphics/win32/xpm2bmp.c
index 455d69941..3885a5107 100644
--- a/navit/graphics/win32/xpm2bmp.c
+++ b/navit/graphics/win32/xpm2bmp.c
@@ -11,8 +11,7 @@
static int CreateBitmapFromXpm( const char* filename, PXPM2BMP pXpm2bmp );
// typedefs
-static XPMCOLORENTRY theRGBRecords[] =
-{
+static XPMCOLORENTRY theRGBRecords[] = {
{"ALICEBLUE", 240, 248, 255},
{"ANTIQUEWHITE", 250, 235, 215},
{"AQUAMARINE", 50, 191, 193},
@@ -250,348 +249,321 @@ static XPMCOLORENTRY theRGBRecords[] =
};
-PXPM2BMP Xpm2bmp_new(void)
-{
- PXPM2BMP preturn = g_malloc0( sizeof(XPM2BMP) );
- return preturn;
+PXPM2BMP Xpm2bmp_new(void) {
+ PXPM2BMP preturn = g_malloc0( sizeof(XPM2BMP) );
+ return preturn;
}
-int Xpm2bmp_load( PXPM2BMP pXpm2bmp, const char* filename )
-{
- return CreateBitmapFromXpm( filename, pXpm2bmp );
+int Xpm2bmp_load( PXPM2BMP pXpm2bmp, const char* filename ) {
+ return CreateBitmapFromXpm( filename, pXpm2bmp );
}
-int Xpm2bmp_paint( PXPM2BMP pXpm2bmp, HDC hdc, int x1,int y1 )
-{
- StretchDIBits(hdc,
- x1, y1, pXpm2bmp->size_x, pXpm2bmp->size_y,
- 0, 0, pXpm2bmp->size_x, pXpm2bmp->size_y,
- pXpm2bmp->wimage_data_trans,
- (BITMAPINFO *)pXpm2bmp->bmih_trans,
- DIB_RGB_COLORS,
- SRCAND );
-
- StretchDIBits(hdc,
- x1, y1, pXpm2bmp->size_x, pXpm2bmp->size_y,
- 0, 0, pXpm2bmp->size_x, pXpm2bmp->size_y,
- pXpm2bmp->wimage_data,
- (BITMAPINFO *)pXpm2bmp->bmih,
- DIB_RGB_COLORS,
- SRCPAINT );
-
- return 0;
+int Xpm2bmp_paint( PXPM2BMP pXpm2bmp, HDC hdc, int x1,int y1 ) {
+ StretchDIBits(hdc,
+ x1, y1, pXpm2bmp->size_x, pXpm2bmp->size_y,
+ 0, 0, pXpm2bmp->size_x, pXpm2bmp->size_y,
+ pXpm2bmp->wimage_data_trans,
+ (BITMAPINFO *)pXpm2bmp->bmih_trans,
+ DIB_RGB_COLORS,
+ SRCAND );
+
+ StretchDIBits(hdc,
+ x1, y1, pXpm2bmp->size_x, pXpm2bmp->size_y,
+ 0, 0, pXpm2bmp->size_x, pXpm2bmp->size_y,
+ pXpm2bmp->wimage_data,
+ (BITMAPINFO *)pXpm2bmp->bmih,
+ DIB_RGB_COLORS,
+ SRCPAINT );
+
+ return 0;
}
-static int parse_line_values( const char* line, PXPM2BMP pXpm2bmp )
-{
- int return_value = 0;
- char* parse_line = (char*)line;
- char* tok;
- int value_pos = 0;
-
- parse_line = strchr( parse_line, '"' );
- parse_line++;
-
- tok = strtok( parse_line, " \t\n" );
-
- while ( tok != 0 )
- {
- int val = atoi( tok );
- switch ( value_pos )
- {
- case 0: pXpm2bmp->size_x = val; break;
- case 1: pXpm2bmp->size_y = val; break;
- case 2: pXpm2bmp->colors = val; break;
- case 3: pXpm2bmp->chars_per_pixel = val; break;
- case 4: pXpm2bmp->hotspot_x = val; break;
- case 5: pXpm2bmp->hotspot_y = val; break;
- }
- tok = strtok( NULL, " \t" );
- value_pos ++;
-
- }
-
- return return_value;
+static int parse_line_values( const char* line, PXPM2BMP pXpm2bmp ) {
+ int return_value = 0;
+ char* parse_line = (char*)line;
+ char* tok;
+ int value_pos = 0;
+
+ parse_line = strchr( parse_line, '"' );
+ parse_line++;
+
+ tok = strtok( parse_line, " \t\n" );
+
+ while ( tok != 0 ) {
+ int val = atoi( tok );
+ switch ( value_pos ) {
+ case 0:
+ pXpm2bmp->size_x = val;
+ break;
+ case 1:
+ pXpm2bmp->size_y = val;
+ break;
+ case 2:
+ pXpm2bmp->colors = val;
+ break;
+ case 3:
+ pXpm2bmp->chars_per_pixel = val;
+ break;
+ case 4:
+ pXpm2bmp->hotspot_x = val;
+ break;
+ case 5:
+ pXpm2bmp->hotspot_y = val;
+ break;
+ }
+ tok = strtok( NULL, " \t" );
+ value_pos ++;
+
+ }
+
+ return return_value;
}
-static int hex2int( char c )
-{
- if ((c >= '0') && (c <='9' )) return c - '0';
- if ((c >= 'A') && (c <= 'F')) return c - 'A' + 10;
- if ((c >= 'a') && (c <= 'f')) return c - 'a' + 10;
- return -1;
+static int hex2int( char c ) {
+ if ((c >= '0') && (c <='9' )) return c - '0';
+ if ((c >= 'A') && (c <= 'F')) return c - 'A' + 10;
+ if ((c >= 'a') && (c <= 'f')) return c - 'a' + 10;
+ return -1;
}
-static DWORD string2hex16( const char* str )
-{
- int i1 = hex2int( str[0] );
- int i2 = hex2int( str[1] );
- if ( ( i1 >= 0 ) && ( i2 >= 0 ) )
- return i1*16+i2;
- return -1;
+static DWORD string2hex16( const char* str ) {
+ int i1 = hex2int( str[0] );
+ int i2 = hex2int( str[1] );
+ if ( ( i1 >= 0 ) && ( i2 >= 0 ) )
+ return i1*16+i2;
+ return -1;
}
-static int parse_color_values( const char* line, PXPM2BMP pXpm2bmp )
-{
- int return_value = 0;
- char* cq = strchr( line, '"' );
- char* cchar = strchr( cq+pXpm2bmp->chars_per_pixel+1, 'c' );
- char* chash = strchr( cq+pXpm2bmp->chars_per_pixel+1, '#' );
- char* qe = strchr( cq+pXpm2bmp->chars_per_pixel+1, '"' );
+static int parse_color_values( const char* line, PXPM2BMP pXpm2bmp ) {
+ int return_value = 0;
+ char* cq = strchr( line, '"' );
+ char* cchar = strchr( cq+pXpm2bmp->chars_per_pixel+1, 'c' );
+ char* chash = strchr( cq+pXpm2bmp->chars_per_pixel+1, '#' );
+ char* qe = strchr( cq+pXpm2bmp->chars_per_pixel+1, '"' );
- cq++;
+ cq++;
- if ( cq )
- {
- memcpy( pXpm2bmp->color_entires[ pXpm2bmp-> color_entires_size].color_str, cq, pXpm2bmp->chars_per_pixel + 1 );
- pXpm2bmp->color_entires[ pXpm2bmp-> color_entires_size].color_str[ pXpm2bmp->chars_per_pixel ] = '\0';
+ if ( cq ) {
+ memcpy( pXpm2bmp->color_entires[ pXpm2bmp-> color_entires_size].color_str, cq, pXpm2bmp->chars_per_pixel + 1 );
+ pXpm2bmp->color_entires[ pXpm2bmp-> color_entires_size].color_str[ pXpm2bmp->chars_per_pixel ] = '\0';
- if ( cchar && chash && qe)
- {
- int len;
- chash++;
- *qe = 0;
- len = strlen( chash );
+ if ( cchar && chash && qe) {
+ int len;
+ chash++;
+ *qe = 0;
+ len = strlen( chash );
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r = string2hex16( &chash[0] );
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g = string2hex16( &chash[len / 3] );
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b = string2hex16( &chash[len * 2 / 3] );
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r = string2hex16( &chash[0] );
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g = string2hex16( &chash[len / 3] );
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b = string2hex16( &chash[len * 2 / 3] );
#ifdef _DBG
-printf( "adding color %s => %d RGB %x %x %x to index %d\n",
- line,
- pXpm2bmp->color_entires_size,
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r,
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g,
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b,
- pXpm2bmp->color_entires_size );
+ printf( "adding color %s => %d RGB %x %x %x to index %d\n",
+ line,
+ pXpm2bmp->color_entires_size,
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r,
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g,
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b,
+ pXpm2bmp->color_entires_size );
#endif
- }
- else
- {
- int q;
- char *start = cchar + 1;
- char *end = start;
-
- while ( *start != 0 )
- {
- if ( ( *start != '\t' ) && ( *start != ' ' ) )
- {
- break;
- }
- start++;
- }
-
- end = start;
- while ( *end != 0 )
- {
- if ( ( *end == '\t' ) || ( *end == ' ' ) || ( *end == '"' ))
- {
- *end = 0;
- }
- end++;
- }
-
- start = _strupr( start );
-
- for ( q=0; q < sizeof( theRGBRecords ) / sizeof( theRGBRecords[0] ); q++ )
- {
-
- if ( 0 == strcmp( start, theRGBRecords[q].color_str ) )
- {
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r = theRGBRecords[q].r;
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g = theRGBRecords[q].g;
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b = theRGBRecords[q].b;
- }
- }
- if ( 0 == strcmp( start, "NONE" ) )
- {
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r = 255;
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g = 0;
- pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b = 255;
- }
- }
- }
- pXpm2bmp->color_entires_size++;
-
- return return_value;
+ } else {
+ int q;
+ char *start = cchar + 1;
+ char *end = start;
+
+ while ( *start != 0 ) {
+ if ( ( *start != '\t' ) && ( *start != ' ' ) ) {
+ break;
+ }
+ start++;
+ }
+
+ end = start;
+ while ( *end != 0 ) {
+ if ( ( *end == '\t' ) || ( *end == ' ' ) || ( *end == '"' )) {
+ *end = 0;
+ }
+ end++;
+ }
+
+ start = _strupr( start );
+
+ for ( q=0; q < sizeof( theRGBRecords ) / sizeof( theRGBRecords[0] ); q++ ) {
+
+ if ( 0 == strcmp( start, theRGBRecords[q].color_str ) ) {
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r = theRGBRecords[q].r;
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g = theRGBRecords[q].g;
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b = theRGBRecords[q].b;
+ }
+ }
+ if ( 0 == strcmp( start, "NONE" ) ) {
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].r = 255;
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].g = 0;
+ pXpm2bmp->color_entires[ pXpm2bmp->color_entires_size].b = 255;
+ }
+ }
+ }
+ pXpm2bmp->color_entires_size++;
+
+ return return_value;
}
static int vv = 0;
-static int parse_pixel_line_values( const char* line, PXPM2BMP pXpm2bmp, unsigned char* pixel_data, unsigned char* pixel_data_trans )
-{
- int return_value = 0;
- int i,j;
-
-
- char* cq = strchr( line, '"' );
- int pix_idx = 0;
- int size_x = pXpm2bmp->size_x;
- int len = strlen( cq );
-
- cq++;
-
- if ( len > pXpm2bmp->chars_per_pixel * size_x )
- {
- for ( i=0; i< size_x; i++ )
- {
- int found = 0;
- char* cmp = &cq[ i * pXpm2bmp->chars_per_pixel];
-
- for ( j=0; j< pXpm2bmp-> color_entires_size; j++ )
- {
- if ( strncmp( cmp, pXpm2bmp->color_entires[ j ].color_str, pXpm2bmp->chars_per_pixel ) == 0 )
- {
- int r = pXpm2bmp->color_entires[ j ].r;
- int g = pXpm2bmp->color_entires[ j ].g;
- int b = pXpm2bmp->color_entires[ j ].b;
-
- if ( ( r == 255 ) && ( g == 0 ) && ( r == 255 ) )
- {
- r=g=b=0;
- pixel_data_trans[ pix_idx ] = 255;
- pixel_data_trans[ pix_idx+1 ] = 255;
- pixel_data_trans[ pix_idx+2 ] = 255;
- }
- else
- {
- pixel_data_trans[ pix_idx ] = 0;
- pixel_data_trans[ pix_idx+1 ] = 0;
- pixel_data_trans[ pix_idx+2 ] = 0;
- }
-
- // pixel_data[ pix_idx++ ] = pXpm2bmp->color_entires[ j ].r;
- // pixel_data[ pix_idx++ ] = pXpm2bmp->color_entires[ j ].g;
- // pixel_data[ pix_idx++ ] = pXpm2bmp->color_entires[ j ].b;
- pixel_data[ pix_idx++ ] = b;
- pixel_data[ pix_idx++ ] = g;
- pixel_data[ pix_idx++ ] = r;
- found = 1;
- vv++;
- break;
- }
- }
- if ( !found )
- {
- fprintf( stderr, "XPMLIB: error color not found\n" );
- }
-
- }
- }
- else
- {
- return_value = -1;
- fprintf( stderr, "XPMLIB: invalid line length\n" );
- }
- return return_value;
+static int parse_pixel_line_values( const char* line, PXPM2BMP pXpm2bmp, unsigned char* pixel_data,
+ unsigned char* pixel_data_trans ) {
+ int return_value = 0;
+ int i,j;
+
+
+ char* cq = strchr( line, '"' );
+ int pix_idx = 0;
+ int size_x = pXpm2bmp->size_x;
+ int len = strlen( cq );
+
+ cq++;
+
+ if ( len > pXpm2bmp->chars_per_pixel * size_x ) {
+ for ( i=0; i< size_x; i++ ) {
+ int found = 0;
+ char* cmp = &cq[ i * pXpm2bmp->chars_per_pixel];
+
+ for ( j=0; j< pXpm2bmp-> color_entires_size; j++ ) {
+ if ( strncmp( cmp, pXpm2bmp->color_entires[ j ].color_str, pXpm2bmp->chars_per_pixel ) == 0 ) {
+ int r = pXpm2bmp->color_entires[ j ].r;
+ int g = pXpm2bmp->color_entires[ j ].g;
+ int b = pXpm2bmp->color_entires[ j ].b;
+
+ if ( ( r == 255 ) && ( g == 0 ) && ( r == 255 ) ) {
+ r=g=b=0;
+ pixel_data_trans[ pix_idx ] = 255;
+ pixel_data_trans[ pix_idx+1 ] = 255;
+ pixel_data_trans[ pix_idx+2 ] = 255;
+ } else {
+ pixel_data_trans[ pix_idx ] = 0;
+ pixel_data_trans[ pix_idx+1 ] = 0;
+ pixel_data_trans[ pix_idx+2 ] = 0;
+ }
+
+ // pixel_data[ pix_idx++ ] = pXpm2bmp->color_entires[ j ].r;
+ // pixel_data[ pix_idx++ ] = pXpm2bmp->color_entires[ j ].g;
+ // pixel_data[ pix_idx++ ] = pXpm2bmp->color_entires[ j ].b;
+ pixel_data[ pix_idx++ ] = b;
+ pixel_data[ pix_idx++ ] = g;
+ pixel_data[ pix_idx++ ] = r;
+ found = 1;
+ vv++;
+ break;
+ }
+ }
+ if ( !found ) {
+ fprintf( stderr, "XPMLIB: error color not found\n" );
+ }
+
+ }
+ } else {
+ return_value = -1;
+ fprintf( stderr, "XPMLIB: invalid line length\n" );
+ }
+ return return_value;
}
-static int CreateBitmapFromXpm( const char* filename, PXPM2BMP pXpm2bmp )
-{
- int return_val = 0;
+static int CreateBitmapFromXpm( const char* filename, PXPM2BMP pXpm2bmp ) {
+ int return_val = 0;
unsigned char i, row;
- char line[ 1024 ];
- int nbytes ;
- int padding, rowsize = 0;
- FILE* file_xpm = fopen( filename, "r" );
-
- int phase = 0;
- row = 0;
-
- if ( file_xpm )
- {
- while ( fgets(line, sizeof( line ), file_xpm ) )
- {
+ char line[ 1024 ];
+ int nbytes ;
+ int padding, rowsize = 0;
+ FILE* file_xpm = fopen( filename, "r" );
+
+ int phase = 0;
+ row = 0;
+
+ if ( file_xpm ) {
+ while ( fgets(line, sizeof( line ), file_xpm ) ) {
#ifdef _DBG
- printf( "PARSING: %s\n", line );
+ printf( "PARSING: %s\n", line );
#endif
- if ( line[ 0 ] != '"' )
- continue;
+ if ( line[ 0 ] != '"' )
+ continue;
- switch ( phase )
- {
- case 0:
- parse_line_values( line, pXpm2bmp );
+ switch ( phase ) {
+ case 0:
+ parse_line_values( line, pXpm2bmp );
#ifdef _DBG
- printf( "size_x %d\n", pXpm2bmp->size_x );
- printf( "size_y %d\n", pXpm2bmp->size_y );
+ printf( "size_x %d\n", pXpm2bmp->size_x );
+ printf( "size_y %d\n", pXpm2bmp->size_y );
#endif
- phase = 1;
-
- pXpm2bmp->color_entires_size = 0;
- nbytes = ( pXpm2bmp->chars_per_pixel + 1 ) * pXpm2bmp->colors;
-
- pXpm2bmp->color_entires = g_malloc0( sizeof(XPMCOLORENTRY) * (pXpm2bmp->colors + 100) );
- pXpm2bmp->color_entires[0].color_str = g_malloc0( nbytes * pXpm2bmp->colors );
- for ( i = 1; i< pXpm2bmp->colors; i++ )
- {
- pXpm2bmp->color_entires[i].color_str = pXpm2bmp->color_entires[0].color_str + ( pXpm2bmp->chars_per_pixel + 1 ) * i;
- }
-
- rowsize=pXpm2bmp->size_x * 3;
- padding=4-(rowsize%4);
- if(padding<4)
- rowsize+=padding;
-
-
- if (!(pXpm2bmp->dib = (unsigned char *)g_malloc(sizeof(BITMAPINFOHEADER) + rowsize * pXpm2bmp->size_y )))
- {
- return 4;
- }
- if (!(pXpm2bmp->dib_trans = (unsigned char *)g_malloc0(sizeof(BITMAPINFOHEADER) + rowsize * pXpm2bmp->size_y )))
- {
- return 4;
- }
-
- memset(pXpm2bmp->dib, 0, sizeof(BITMAPINFOHEADER));
- pXpm2bmp->bmih = (BITMAPINFOHEADER *)pXpm2bmp->dib;
- pXpm2bmp->bmih->biSize = sizeof(BITMAPINFOHEADER);
- pXpm2bmp->bmih->biWidth = pXpm2bmp->size_x;
- pXpm2bmp->bmih->biHeight = -((long)pXpm2bmp->size_y);
- pXpm2bmp->bmih->biPlanes = 1;
- pXpm2bmp->bmih->biBitCount = 24;
- pXpm2bmp->bmih->biCompression = 0;
- pXpm2bmp->wimage_data = pXpm2bmp->dib + sizeof(BITMAPINFOHEADER);
-
-
- pXpm2bmp->bmih_trans = (BITMAPINFOHEADER *)pXpm2bmp->dib_trans;
- pXpm2bmp->bmih_trans->biSize = sizeof(BITMAPINFOHEADER);
- pXpm2bmp->bmih_trans->biWidth = pXpm2bmp->size_x;
- pXpm2bmp->bmih_trans->biHeight = -((long)pXpm2bmp->size_y);
- pXpm2bmp->bmih_trans->biPlanes = 1;
- pXpm2bmp->bmih_trans->biBitCount = 24;
- pXpm2bmp->bmih_trans->biCompression = 0;
- pXpm2bmp->wimage_data_trans = pXpm2bmp->dib_trans + sizeof(BITMAPINFOHEADER);
+ phase = 1;
+
+ pXpm2bmp->color_entires_size = 0;
+ nbytes = ( pXpm2bmp->chars_per_pixel + 1 ) * pXpm2bmp->colors;
+
+ pXpm2bmp->color_entires = g_malloc0( sizeof(XPMCOLORENTRY) * (pXpm2bmp->colors + 100) );
+ pXpm2bmp->color_entires[0].color_str = g_malloc0( nbytes * pXpm2bmp->colors );
+ for ( i = 1; i< pXpm2bmp->colors; i++ ) {
+ pXpm2bmp->color_entires[i].color_str = pXpm2bmp->color_entires[0].color_str + ( pXpm2bmp->chars_per_pixel + 1 ) * i;
+ }
+
+ rowsize=pXpm2bmp->size_x * 3;
+ padding=4-(rowsize%4);
+ if(padding<4)
+ rowsize+=padding;
+
+
+ if (!(pXpm2bmp->dib = (unsigned char *)g_malloc(sizeof(BITMAPINFOHEADER) + rowsize * pXpm2bmp->size_y ))) {
+ return 4;
+ }
+ if (!(pXpm2bmp->dib_trans = (unsigned char *)g_malloc0(sizeof(BITMAPINFOHEADER) + rowsize * pXpm2bmp->size_y ))) {
+ return 4;
+ }
+
+ memset(pXpm2bmp->dib, 0, sizeof(BITMAPINFOHEADER));
+ pXpm2bmp->bmih = (BITMAPINFOHEADER *)pXpm2bmp->dib;
+ pXpm2bmp->bmih->biSize = sizeof(BITMAPINFOHEADER);
+ pXpm2bmp->bmih->biWidth = pXpm2bmp->size_x;
+ pXpm2bmp->bmih->biHeight = -((long)pXpm2bmp->size_y);
+ pXpm2bmp->bmih->biPlanes = 1;
+ pXpm2bmp->bmih->biBitCount = 24;
+ pXpm2bmp->bmih->biCompression = 0;
+ pXpm2bmp->wimage_data = pXpm2bmp->dib + sizeof(BITMAPINFOHEADER);
+
+
+ pXpm2bmp->bmih_trans = (BITMAPINFOHEADER *)pXpm2bmp->dib_trans;
+ pXpm2bmp->bmih_trans->biSize = sizeof(BITMAPINFOHEADER);
+ pXpm2bmp->bmih_trans->biWidth = pXpm2bmp->size_x;
+ pXpm2bmp->bmih_trans->biHeight = -((long)pXpm2bmp->size_y);
+ pXpm2bmp->bmih_trans->biPlanes = 1;
+ pXpm2bmp->bmih_trans->biBitCount = 24;
+ pXpm2bmp->bmih_trans->biCompression = 0;
+ pXpm2bmp->wimage_data_trans = pXpm2bmp->dib_trans + sizeof(BITMAPINFOHEADER);
// memset( pXpm2bmp->wimage_data_trans, 255, 5* 22 * 3 );
- break;
- case 1:
- parse_color_values( line, pXpm2bmp );
- if ( pXpm2bmp->color_entires_size >= pXpm2bmp->colors )
- {
- phase = 2;
- }
-
- break;
- case 2:
- parse_pixel_line_values( line, pXpm2bmp,
- pXpm2bmp->wimage_data + row * rowsize,
- pXpm2bmp->wimage_data_trans + row * rowsize );
-
- row++;
- if ( row >= pXpm2bmp->size_y )
- {
- phase = 3;
- }
- break;
- }
-
- }
-
- fclose( file_xpm );
- }
- return return_val;
+ break;
+ case 1:
+ parse_color_values( line, pXpm2bmp );
+ if ( pXpm2bmp->color_entires_size >= pXpm2bmp->colors ) {
+ phase = 2;
+ }
+
+ break;
+ case 2:
+ parse_pixel_line_values( line, pXpm2bmp,
+ pXpm2bmp->wimage_data + row * rowsize,
+ pXpm2bmp->wimage_data_trans + row * rowsize );
+
+ row++;
+ if ( row >= pXpm2bmp->size_y ) {
+ phase = 3;
+ }
+ break;
+ }
+
+ }
+
+ fclose( file_xpm );
+ }
+ return return_val;
}
diff --git a/navit/gui.c b/navit/gui.c
index 9b2ba4971..f9de8496d 100644
--- a/navit/gui.c
+++ b/navit/gui.c
@@ -28,162 +28,142 @@
#include "plugin.h"
struct gui {
- struct gui_methods meth;
- struct gui_priv *priv;
- struct attr **attrs;
- struct attr parent;
+ struct gui_methods meth;
+ struct gui_priv *priv;
+ struct attr **attrs;
+ struct attr parent;
};
struct gui *
-gui_new(struct attr *parent, struct attr **attrs)
-{
- struct gui *this_;
- struct attr *type_attr;
- struct gui_priv *(*guitype_new)(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui);
- struct attr cbl;
- if (! (type_attr=attr_search(attrs, NULL, attr_type))) {
- return NULL;
- }
-
- guitype_new=plugin_get_category_gui(type_attr->u.str);
- if (! guitype_new)
- return NULL;
-
- this_=g_new0(struct gui, 1);
- this_->attrs=attr_list_dup(attrs);
- cbl.type=attr_callback_list;
- cbl.u.callback_list=callback_list_new();
- this_->attrs=attr_generic_add_attr(this_->attrs, &cbl);
- this_->priv=guitype_new(parent->u.navit, &this_->meth, this_->attrs, this_);
- this_->parent=*parent;
- return this_;
+gui_new(struct attr *parent, struct attr **attrs) {
+ struct gui *this_;
+ struct attr *type_attr;
+ struct gui_priv *(*guitype_new)(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui);
+ struct attr cbl;
+ if (! (type_attr=attr_search(attrs, NULL, attr_type))) {
+ return NULL;
+ }
+
+ guitype_new=plugin_get_category_gui(type_attr->u.str);
+ if (! guitype_new)
+ return NULL;
+
+ this_=g_new0(struct gui, 1);
+ this_->attrs=attr_list_dup(attrs);
+ cbl.type=attr_callback_list;
+ cbl.u.callback_list=callback_list_new();
+ this_->attrs=attr_generic_add_attr(this_->attrs, &cbl);
+ this_->priv=guitype_new(parent->u.navit, &this_->meth, this_->attrs, this_);
+ this_->parent=*parent;
+ return this_;
}
-int
-gui_get_attr(struct gui *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- int ret;
- if (this_->meth.get_attr) {
- ret=this_->meth.get_attr(this_->priv, type, attr);
- if (ret)
- return ret;
- }
- if (type == this_->parent.type) {
- *attr=this_->parent;
- return 1;
- }
- return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+int gui_get_attr(struct gui *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ int ret;
+ if (this_->meth.get_attr) {
+ ret=this_->meth.get_attr(this_->priv, type, attr);
+ if (ret)
+ return ret;
+ }
+ if (type == this_->parent.type) {
+ *attr=this_->parent;
+ return 1;
+ }
+ return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
}
-int
-gui_set_attr(struct gui *this_, struct attr *attr)
-{
- int ret=1;
- if (this_->meth.set_attr)
- ret=this_->meth.set_attr(this_->priv, attr);
- if (ret == 1)
- this_->attrs=attr_generic_set_attr(this_->attrs, attr);
- return ret != 0;
+int gui_set_attr(struct gui *this_, struct attr *attr) {
+ int ret=1;
+ if (this_->meth.set_attr)
+ ret=this_->meth.set_attr(this_->priv, attr);
+ if (ret == 1)
+ this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+ return ret != 0;
}
-int
-gui_add_attr(struct gui *this_, struct attr *attr)
-{
- int ret=0;
- if (this_->meth.add_attr)
- ret=this_->meth.add_attr(this_->priv, attr);
- return ret;
+int gui_add_attr(struct gui *this_, struct attr *attr) {
+ int ret=0;
+ if (this_->meth.add_attr)
+ ret=this_->meth.add_attr(this_->priv, attr);
+ return ret;
}
struct menu *
-gui_menubar_new(struct gui *gui)
-{
- struct menu *this_;
- if (! gui->meth.menubar_new)
- return NULL;
- this_=g_new0(struct menu, 1);
- this_->priv=gui->meth.menubar_new(gui->priv, &this_->meth);
- if (! this_->priv) {
- g_free(this_);
- return NULL;
- }
- return this_;
+gui_menubar_new(struct gui *gui) {
+ struct menu *this_;
+ if (! gui->meth.menubar_new)
+ return NULL;
+ this_=g_new0(struct menu, 1);
+ this_->priv=gui->meth.menubar_new(gui->priv, &this_->meth);
+ if (! this_->priv) {
+ g_free(this_);
+ return NULL;
+ }
+ return this_;
}
struct menu *
-gui_popup_new(struct gui *gui)
-{
- struct menu *this_;
- if (!gui || ! gui->meth.popup_new)
- return NULL;
- this_=g_new0(struct menu, 1);
- this_->priv=gui->meth.popup_new(gui->priv, &this_->meth);
- if (! this_->priv) {
- g_free(this_);
- return NULL;
- }
- return this_;
+gui_popup_new(struct gui *gui) {
+ struct menu *this_;
+ if (!gui || ! gui->meth.popup_new)
+ return NULL;
+ this_=g_new0(struct menu, 1);
+ this_->priv=gui->meth.popup_new(gui->priv, &this_->meth);
+ if (! this_->priv) {
+ g_free(this_);
+ return NULL;
+ }
+ return this_;
}
struct datawindow *
-gui_datawindow_new(struct gui *gui, const char *name, struct callback *click, struct callback *close)
-{
- struct datawindow *this_;
- if (! gui->meth.datawindow_new)
- return NULL;
- this_=g_new0(struct datawindow, 1);
- this_->priv=gui->meth.datawindow_new(gui->priv, name, click, close, &this_->meth);
- if (! this_->priv) {
- g_free(this_);
- return NULL;
- }
- return this_;
+gui_datawindow_new(struct gui *gui, const char *name, struct callback *click, struct callback *close) {
+ struct datawindow *this_;
+ if (! gui->meth.datawindow_new)
+ return NULL;
+ this_=g_new0(struct datawindow, 1);
+ this_->priv=gui->meth.datawindow_new(gui->priv, name, click, close, &this_->meth);
+ if (! this_->priv) {
+ g_free(this_);
+ return NULL;
+ }
+ return this_;
}
-int
-gui_add_bookmark(struct gui *gui, struct pcoord *c, char *description)
-{
- int ret;
- dbg(lvl_info,"enter\n");
- if (! gui->meth.add_bookmark)
- return 0;
- ret=gui->meth.add_bookmark(gui->priv, c, description);
-
- dbg(lvl_info,"ret=%d\n", ret);
- return ret;
+int gui_add_bookmark(struct gui *gui, struct pcoord *c, char *description) {
+ int ret;
+ dbg(lvl_info,"enter");
+ if (! gui->meth.add_bookmark)
+ return 0;
+ ret=gui->meth.add_bookmark(gui->priv, c, description);
+
+ dbg(lvl_info,"ret=%d", ret);
+ return ret;
}
-int
-gui_set_graphics(struct gui *this_, struct graphics *gra)
-{
- if (! this_->meth.set_graphics) {
- dbg(lvl_error, "cannot set graphics, method 'set_graphics' not available\n");
- return 1;
- }
- return this_->meth.set_graphics(this_->priv, gra);
+int gui_set_graphics(struct gui *this_, struct graphics *gra) {
+ if (! this_->meth.set_graphics) {
+ dbg(lvl_error, "cannot set graphics, method 'set_graphics' not available");
+ return 1;
+ }
+ return this_->meth.set_graphics(this_->priv, gra);
}
-void
-gui_disable_suspend(struct gui *this_)
-{
- if (this_->meth.disable_suspend)
- this_->meth.disable_suspend(this_->priv);
+void gui_disable_suspend(struct gui *this_) {
+ if (this_->meth.disable_suspend)
+ this_->meth.disable_suspend(this_->priv);
}
-int
-gui_has_main_loop(struct gui *this_)
-{
- if (! this_->meth.run_main_loop)
- return 0;
- return 1;
+int gui_has_main_loop(struct gui *this_) {
+ if (! this_->meth.run_main_loop)
+ return 0;
+ return 1;
}
-int
-gui_run_main_loop(struct gui *this_)
-{
- if (! gui_has_main_loop(this_))
- return 1;
- return this_->meth.run_main_loop(this_->priv);
+int gui_run_main_loop(struct gui *this_) {
+ if (! gui_has_main_loop(this_))
+ return 1;
+ return this_->meth.run_main_loop(this_->priv);
}
diff --git a/navit/gui/gtk/CMakeLists.txt b/navit/gui/gtk/CMakeLists.txt
index a1dfa173c..1a1ec2a7a 100644
--- a/navit/gui/gtk/CMakeLists.txt
+++ b/navit/gui/gtk/CMakeLists.txt
@@ -1,2 +1,3 @@
-module_add_library(gui_gtk datawindow.c destination.c gui_gtk_statusbar.c gui_gtk_action.c gui_gtk_window.c gui_gtk_poi.c)
+module_add_library(gui_gtk datawindow.c destination.c gui_gtk_statusbar.c gui_gtk_action.c gui_gtk_window.c
+ gui_gtk_poi.c)
diff --git a/navit/gui/gtk/datawindow.c b/navit/gui/gtk/datawindow.c
index dd71ce999..afe977dbc 100644
--- a/navit/gui/gtk/datawindow.c
+++ b/navit/gui/gtk/datawindow.c
@@ -29,186 +29,172 @@
#include "gui_gtk.h"
struct datawindow_priv {
- GtkWidget *window;
- GtkWidget *scrolled_window;
- GtkWidget *treeview;
- GtkWidget *button;
- GtkListStore *liststore;
- GtkTreeModel *sortmodel;
- struct callback *click, *close;
- struct gui_priv *gui;
+ GtkWidget *window;
+ GtkWidget *scrolled_window;
+ GtkWidget *treeview;
+ GtkWidget *button;
+ GtkListStore *liststore;
+ GtkTreeModel *sortmodel;
+ struct callback *click, *close;
+ struct gui_priv *gui;
};
static GValue value;
-static void
-select_row(GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, struct datawindow_priv *win)
-{
- char *cols[20];
- GtkTreeIter iter;
- GtkTreeModel *model;
- int i;
-
- dbg(lvl_debug,"win=%p\n", win);
-
- model=gtk_tree_view_get_model(tree);
- gtk_tree_model_get_iter(model, &iter, path);
-
- for (i=0;i<gtk_tree_model_get_n_columns(model);i++) {
- gtk_tree_model_get_value(model, &iter, i, &value);
- cols[i]=g_strdup_value_contents(&value)+1;
- cols[i][strlen(cols[i])-1]='\0';
- g_value_unset(&value);
- }
- callback_call_1(win->click, cols);
+static void select_row(GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, struct datawindow_priv *win) {
+ char *cols[20];
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ int i;
+
+ dbg(lvl_debug,"win=%p", win);
+
+ model=gtk_tree_view_get_model(tree);
+ gtk_tree_model_get_iter(model, &iter, path);
+
+ for (i=0; i<gtk_tree_model_get_n_columns(model); i++) {
+ gtk_tree_model_get_value(model, &iter, i, &value);
+ cols[i]=g_strdup_value_contents(&value)+1;
+ cols[i][strlen(cols[i])-1]='\0';
+ g_value_unset(&value);
+ }
+ callback_call_1(win->click, cols);
}
-static void
-gui_gtk_datawindow_add(struct datawindow_priv *win, struct param_list *param, int count)
-{
- int i;
- GtkCellRenderer *cell;
- GtkTreeIter iter;
- GType types[count];
-
- if (! win->treeview) {
- win->treeview=gtk_tree_view_new();
- gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), NULL);
- gtk_container_add(GTK_CONTAINER(win->scrolled_window), win->treeview);
- gtk_widget_show_all(GTK_WIDGET(win->window));
- gtk_widget_grab_focus(GTK_WIDGET(win->treeview));
-
- /* add column names to treeview */
- for(i=0;i<count;i++) {
- if (param[i].name) {
- cell=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (win->treeview),-1,param[i].name,
- cell,"text",i, NULL);
- }
- }
+static void gui_gtk_datawindow_add(struct datawindow_priv *win, struct param_list *param, int count) {
+ int i;
+ GtkCellRenderer *cell;
+ GtkTreeIter iter;
+ GType types[count];
+
+ if (! win->treeview) {
+ win->treeview=gtk_tree_view_new();
+ gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), NULL);
+ gtk_container_add(GTK_CONTAINER(win->scrolled_window), win->treeview);
+ gtk_widget_show_all(GTK_WIDGET(win->window));
+ gtk_widget_grab_focus(GTK_WIDGET(win->treeview));
+
+ /* add column names to treeview */
+ for(i=0; i<count; i++) {
+ if (param[i].name) {
+ cell=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (win->treeview),-1,param[i].name,
+ cell,"text",i, NULL);
+ }
+ }
#if 0
- g_signal_connect(G_OBJECT(win->treeview), "click-column", G_CALLBACK(click_column), NULL);
+ g_signal_connect(G_OBJECT(win->treeview), "click-column", G_CALLBACK(click_column), NULL);
#endif
- g_signal_connect(G_OBJECT(win->treeview), "row-activated", G_CALLBACK(select_row), win);
- }
-
- /* find data storage and create a new one if none is there */
- if (gtk_tree_view_get_model(GTK_TREE_VIEW (win->treeview)) == NULL) {
- for(i=0;i<count;i++) {
- if (param[i].name && !strcmp(param[i].name, "Distance"))
- types[i]=G_TYPE_INT;
- else
- types[i]=G_TYPE_STRING;
- }
- win->liststore=gtk_list_store_newv(count,types);
- if (! strcmp(param[0].name, "Distance")) {
- win->sortmodel=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(win->liststore));
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (win->sortmodel), 0, GTK_SORT_ASCENDING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), GTK_TREE_MODEL(win->sortmodel));
- } else
- gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), GTK_TREE_MODEL(win->liststore));
- }
-
- gtk_list_store_append(win->liststore,&iter);
-
- /* add data to data storage */
- for(i=0;i<count;i++) {
- if (param[i].name && !strcmp(param[i].name, "Distance")) {
- gtk_list_store_set(win->liststore,&iter,i,atoi(param[i].value),-1);
- } else {
- gtk_list_store_set(win->liststore,&iter,i,param[i].value,-1);
- }
- }
+ g_signal_connect(G_OBJECT(win->treeview), "row-activated", G_CALLBACK(select_row), win);
+ }
+
+ /* find data storage and create a new one if none is there */
+ if (gtk_tree_view_get_model(GTK_TREE_VIEW (win->treeview)) == NULL) {
+ for(i=0; i<count; i++) {
+ if (param[i].name && !strcmp(param[i].name, "Distance"))
+ types[i]=G_TYPE_INT;
+ else
+ types[i]=G_TYPE_STRING;
+ }
+ win->liststore=gtk_list_store_newv(count,types);
+ if (! strcmp(param[0].name, "Distance")) {
+ win->sortmodel=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(win->liststore));
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (win->sortmodel), 0, GTK_SORT_ASCENDING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), GTK_TREE_MODEL(win->sortmodel));
+ } else
+ gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), GTK_TREE_MODEL(win->liststore));
+ }
+
+ gtk_list_store_append(win->liststore,&iter);
+
+ /* add data to data storage */
+ for(i=0; i<count; i++) {
+ if (param[i].name && !strcmp(param[i].name, "Distance")) {
+ gtk_list_store_set(win->liststore,&iter,i,atoi(param[i].value),-1);
+ } else {
+ gtk_list_store_set(win->liststore,&iter,i,param[i].value,-1);
+ }
+ }
}
-static void
-gui_gtk_datawindow_mode(struct datawindow_priv *win, int start)
-{
- if (start) {
- if (win && win->treeview) {
- gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), NULL);
- }
- }
+static void gui_gtk_datawindow_mode(struct datawindow_priv *win, int start) {
+ if (start) {
+ if (win && win->treeview) {
+ gtk_tree_view_set_model (GTK_TREE_VIEW (win->treeview), NULL);
+ }
+ }
}
-static gboolean
-gui_gtk_datawindow_delete(GtkWidget *widget, GdkEvent *event, struct datawindow_priv *win)
-{
- callback_call_0(win->close);
+static gboolean gui_gtk_datawindow_delete(GtkWidget *widget, GdkEvent *event, struct datawindow_priv *win) {
+ callback_call_0(win->close);
- if (win->button) {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(win->button), FALSE);
- }
+ if (win->button) {
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION(win->button), FALSE);
+ }
- return FALSE;
+ return FALSE;
}
-void
-gui_gtk_datawindow_destroy(struct datawindow_priv *win)
-{
- if ((!win->gui) || (!win->gui->datawindow)) {
- return;
- }
+void gui_gtk_datawindow_destroy(struct datawindow_priv *win) {
+ if ((!win->gui) || (!win->gui->datawindow)) {
+ return;
+ }
- gui_gtk_datawindow_delete(NULL, NULL, win);
- gtk_widget_destroy(win->window);
- win->gui->datawindow = NULL;
+ gui_gtk_datawindow_delete(NULL, NULL, win);
+ gtk_widget_destroy(win->window);
+ win->gui->datawindow = NULL;
- return;
+ return;
}
-void
-gui_gtk_datawindow_set_button(struct datawindow_priv *this_, GtkWidget *btn)
-{
- this_->button = btn;
+void gui_gtk_datawindow_set_button(struct datawindow_priv *this_, GtkWidget *btn) {
+ this_->button = btn;
}
-static gboolean
-keypress(GtkWidget *widget, GdkEventKey *event, struct datawindow_priv *win)
-{
- if (event->type != GDK_KEY_PRESS)
- return FALSE;
- if (event->keyval == GDK_Cancel) {
- gui_gtk_datawindow_delete(widget, (GdkEvent *)event, win);
- gtk_widget_destroy(win->window);
- }
- return FALSE;
+static gboolean keypress(GtkWidget *widget, GdkEventKey *event, struct datawindow_priv *win) {
+ if (event->type != GDK_KEY_PRESS)
+ return FALSE;
+ if (event->keyval == GDK_Cancel) {
+ gui_gtk_datawindow_delete(widget, (GdkEvent *)event, win);
+ gtk_widget_destroy(win->window);
+ }
+ return FALSE;
}
static struct datawindow_methods gui_gtk_datawindow_meth = {
- gui_gtk_datawindow_destroy,
- gui_gtk_datawindow_add,
- gui_gtk_datawindow_mode,
+ gui_gtk_datawindow_destroy,
+ gui_gtk_datawindow_add,
+ gui_gtk_datawindow_mode,
};
struct datawindow_priv *
-gui_gtk_datawindow_new(struct gui_priv *gui, const char *name, struct callback *click, struct callback *close, struct datawindow_methods *meth)
-{
- struct datawindow_priv *win;
-
- if (!gui)
- return NULL;
- *meth=gui_gtk_datawindow_meth;
- win=g_new0(struct datawindow_priv, 1);
- win->window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_default_size(GTK_WINDOW(win->window), 320, 200);
- gtk_window_set_title(GTK_WINDOW(win->window), name);
- gtk_window_set_wmclass (GTK_WINDOW (win->window), "navit", "Navit");
-
- win->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (win->scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(win->window), win->scrolled_window);
- g_signal_connect(G_OBJECT(win->window), "key-press-event", G_CALLBACK(keypress), win);
- win->treeview=NULL;
- win->click=click;
- win->close=close;
- gtk_window_set_transient_for(GTK_WINDOW((GtkWidget *)(win->window)), GTK_WINDOW(gui->win));
- g_signal_connect(G_OBJECT(win->window), "delete-event", G_CALLBACK(gui_gtk_datawindow_delete), win);
- gtk_widget_show_all(win->window);
-
- win->gui = gui;
- gui->datawindow = win;
- return win;
+gui_gtk_datawindow_new(struct gui_priv *gui, const char *name, struct callback *click, struct callback *close,
+ struct datawindow_methods *meth) {
+ struct datawindow_priv *win;
+
+ if (!gui)
+ return NULL;
+ *meth=gui_gtk_datawindow_meth;
+ win=g_new0(struct datawindow_priv, 1);
+ win->window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size(GTK_WINDOW(win->window), 320, 200);
+ gtk_window_set_title(GTK_WINDOW(win->window), name);
+ gtk_window_set_wmclass (GTK_WINDOW (win->window), "navit", "Navit");
+
+ win->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (win->scrolled_window),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add(GTK_CONTAINER(win->window), win->scrolled_window);
+ g_signal_connect(G_OBJECT(win->window), "key-press-event", G_CALLBACK(keypress), win);
+ win->treeview=NULL;
+ win->click=click;
+ win->close=close;
+ gtk_window_set_transient_for(GTK_WINDOW((GtkWidget *)(win->window)), GTK_WINDOW(gui->win));
+ g_signal_connect(G_OBJECT(win->window), "delete-event", G_CALLBACK(gui_gtk_datawindow_delete), win);
+ gtk_widget_show_all(win->window);
+
+ win->gui = gui;
+ gui->datawindow = win;
+ return win;
}
diff --git a/navit/gui/gtk/destination.c b/navit/gui/gtk/destination.c
index 18fc58b75..6a0fbb5b7 100644
--- a/navit/gui/gtk/destination.c
+++ b/navit/gui/gtk/destination.c
@@ -37,293 +37,295 @@
#define COL_COUNT 8
static struct search_param {
- struct navit *nav;
- struct mapset *ms;
- struct search_list *sl;
- struct attr attr;
- int partial;
- GtkWidget *entry_country, *entry_postal, *entry_city, *entry_district;
- GtkWidget *entry_street, *entry_number;
- GtkWidget *listbox;
- GtkWidget *treeview;
- GtkListStore *liststore;
- GtkTreeModel *liststore2;
+ struct navit *nav;
+ struct mapset *ms;
+ struct search_list *sl;
+ struct attr attr;
+ int partial;
+ GtkWidget *entry_country, *entry_postal, *entry_city, *entry_district;
+ GtkWidget *entry_street, *entry_number;
+ GtkWidget *listbox;
+ GtkWidget *treeview;
+ GtkListStore *liststore;
+ GtkTreeModel *liststore2;
} search_param;
-static void button_map(GtkWidget *widget, struct search_param *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- struct pcoord *c=NULL;
- GtkTreeIter iter;
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &focus_column);
- if(!path)
- return;
- if(!gtk_tree_model_get_iter(search->liststore2, &iter, path))
- return;
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
- if (c) {
- navit_set_center(search->nav, c, 1);
- }
-}
-static char *description(struct search_param *search, GtkTreeIter *iter)
-{
- char *desc,*car,*postal,*town,*street;
- char empty='\0';
-
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 0, &car, -1);
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 1, &postal, -1);
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 2, &town, -1);
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 4, &street, -1);
-
- /* protect against nulls */
+static char *description(struct search_param *search, GtkTreeIter *iter) {
+ char *desc,*car,*postal,*town,*street;
+ char empty='\0';
+
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 0, &car, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 1, &postal, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 2, &town, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), iter, 4, &street, -1);
+
+ /* protect against nulls */
if (car==0) car=&empty;
- if (postal==0) postal=&empty;
+ if (postal==0) postal=&empty;
if (town==0) town=&empty;
if (street==0) street=&empty;
-
- if (search->attr.type == attr_town_name)
- desc=g_strdup_printf("%s-%s %s", car, postal, town);
- else
- desc=g_strdup_printf("%s-%s %s, %s", car, postal, town, street);
- return desc;
+
+ if (search->attr.type == attr_town_name)
+ desc=g_strdup_printf("%s-%s %s", car, postal, town);
+ else
+ desc=g_strdup_printf("%s-%s %s, %s", car, postal, town, street);
+ return desc;
}
-static void button_destination(GtkWidget *widget, struct search_param *search)
-{
- struct pcoord *c=NULL;
- GtkTreeIter iter;
- char *desc;
-
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (search->liststore2), &iter))
- return;
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
- if (c) {
- desc=description(search, &iter);
- navit_set_destination(search->nav, c, desc, 1);
- g_free(desc);
- }
+static void button_map(GtkWidget *widget, struct search_param *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ struct pcoord *point=NULL; /* A pointer on the geographical position of the selected map point */
+ GtkTreeIter iter;
+ char *label;
+ GList* p;
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &focus_column);
+ if(!path)
+ return;
+ if(!gtk_tree_model_get_iter(search->liststore2, &iter, path))
+ return;
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &point, -1);
+ if (point) {
+ GList* list = NULL;
+ struct lcoord *result = g_new0(struct lcoord, 1);
+ result->c.x=point->x;
+ result->c.y=point->y;
+ result->label=description(search, &iter); /* Allocated here, freed by invoking g_free() below when parsing the GList */
+ list = g_list_prepend(list, result);
+ navit_populate_search_results_map(search->nav, list, NULL);
+ /* Parse the GList starting at list and free all payloads before freeing the list itself */
+ for(p=list; p; p=g_list_next(p)) {
+ if (((struct lcoord *)(p->data))->label)
+ g_free(((struct lcoord *)(p->data))->label);
+ }
+ g_list_free(list);
+
+ navit_set_center(search->nav, point, 1);
+ }
}
-static void button_bookmark(GtkWidget *widget, struct search_param *search)
-{
- struct pcoord *c=NULL;
- GtkTreeIter iter;
- char *desc;
- struct attr attr;
-
- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (search->liststore2), &iter))
- return;
- gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
- if (c) {
- navit_get_attr(search->nav, attr_bookmarks, &attr, NULL);
- desc=description(search, &iter);
- bookmarks_add_bookmark(attr.u.bookmarks, c, desc);
- g_free(desc);
- }
+static void button_destination(GtkWidget *widget, struct search_param *search) {
+ struct pcoord *c=NULL;
+ GtkTreeIter iter;
+ char *desc;
+
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (search->liststore2), &iter))
+ return;
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
+ if (c) {
+ desc=description(search, &iter);
+ navit_populate_search_results_map(search->nav, NULL, NULL); /* Remove any highlighted point on the map */
+ navit_set_destination(search->nav, c, desc, 1);
+ g_free(desc);
+ }
+}
+
+static void button_bookmark(GtkWidget *widget, struct search_param *search) {
+ struct pcoord *c=NULL;
+ GtkTreeIter iter;
+ char *desc;
+ struct attr attr;
+
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (search->liststore2), &iter))
+ return;
+ gtk_tree_model_get (GTK_TREE_MODEL (search->liststore2), &iter, COL_COUNT, &c, -1);
+ if (c) {
+ navit_get_attr(search->nav, attr_bookmarks, &attr, NULL);
+ desc=description(search, &iter);
+ bookmarks_add_bookmark(attr.u.bookmarks, c, desc);
+ g_free(desc);
+ }
}
char **columns_text[] = {
- (char *[]){_n("Car"),_n("Iso2"),_n("Iso3"),_n("Country"),NULL},
- (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),NULL},
- (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),_n("Street"),NULL},
- (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),_n("Street"),_n("Number"),NULL},
+ (char *[]){_n("Car"),_n("Iso2"),_n("Iso3"),_n("Country"),NULL},
+ (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),NULL},
+ (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),_n("Street"),NULL},
+ (char *[]){_n("Car"),_n("Postal"),_n("Town"),_n("District"),_n("Street"),_n("Number"),NULL},
};
-static void set_columns(struct search_param *param, int mode)
-{
- GList *columns_list,*columns;
- char **column_text=columns_text[mode];
- int i=0;
-
- columns_list=gtk_tree_view_get_columns(GTK_TREE_VIEW(param->treeview));
- columns=columns_list;
- while (columns) {
- gtk_tree_view_remove_column(GTK_TREE_VIEW(param->treeview), columns->data);
- columns=g_list_next(columns);
- }
- g_list_free(columns_list);
- while (*column_text) {
- GtkCellRenderer *cell=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (param->treeview),-1, navit_nls_gettext(*column_text), cell, "text", i, NULL);
- i++;
- column_text++;
- }
+static void set_columns(struct search_param *param, int mode) {
+ GList *columns_list,*columns;
+ char **column_text=columns_text[mode];
+ int i=0;
+
+ columns_list=gtk_tree_view_get_columns(GTK_TREE_VIEW(param->treeview));
+ columns=columns_list;
+ while (columns) {
+ gtk_tree_view_remove_column(GTK_TREE_VIEW(param->treeview), columns->data);
+ columns=g_list_next(columns);
+ }
+ g_list_free(columns_list);
+ while (*column_text) {
+ GtkCellRenderer *cell=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (param->treeview),-1, navit_nls_gettext(*column_text), cell,
+ "text", i, NULL);
+ i++;
+ column_text++;
+ }
}
-static void row_activated(GtkWidget *widget, GtkTreePath *p1, GtkTreeViewColumn *c, struct search_param *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
- GtkWidget *entry_widget;
- char *str;
- int column;
-
- dbg(lvl_debug,"enter\n");
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &focus_column);
- if(!path)
- return;
- if(!gtk_tree_model_get_iter(search->liststore2, &iter, path))
- return;
- switch(search->attr.type) {
- case attr_country_all:
- entry_widget=search->entry_country;
- column=3;
- break;
- case attr_town_name:
- entry_widget=search->entry_city;
- column=2;
- break;
- case attr_street_name:
- entry_widget=search->entry_street;
- column=4;
- break;
- default:
- dbg(lvl_debug,"Unknown mode\n");
- return;
- }
- gtk_tree_model_get(search->liststore2, &iter, column, &str, -1);
- dbg(lvl_debug,"str=%s\n", str);
- search->partial=0;
- gtk_entry_set_text(GTK_ENTRY(entry_widget), str);
+static void row_activated(GtkWidget *widget, GtkTreePath *p1, GtkTreeViewColumn *c, struct search_param *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+ GtkWidget *entry_widget;
+ char *str;
+ int column;
+
+ dbg(lvl_debug,"enter");
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &focus_column);
+ if(!path)
+ return;
+ if(!gtk_tree_model_get_iter(search->liststore2, &iter, path))
+ return;
+ switch(search->attr.type) {
+ case attr_country_all:
+ entry_widget=search->entry_country;
+ column=3;
+ break;
+ case attr_town_name:
+ entry_widget=search->entry_city;
+ column=2;
+ break;
+ case attr_street_name:
+ entry_widget=search->entry_street;
+ column=4;
+ break;
+ default:
+ dbg(lvl_debug,"Unknown mode");
+ return;
+ }
+ gtk_tree_model_get(search->liststore2, &iter, column, &str, -1);
+ dbg(lvl_debug,"str=%s", str);
+ search->partial=0;
+ gtk_entry_set_text(GTK_ENTRY(entry_widget), str);
}
-static void tree_view_button_release(GtkWidget *widget, GdkEventButton *event, struct search_param *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *column;
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &column);
- gtk_tree_view_row_activated(GTK_TREE_VIEW(search->treeview), path, column);
-
+static void tree_view_button_release(GtkWidget *widget, GdkEventButton *event, struct search_param *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview), &path, &column);
+ gtk_tree_view_row_activated(GTK_TREE_VIEW(search->treeview), path, column);
+
}
-static void
-next_focus(struct search_param *search, GtkWidget *widget)
-{
- if (widget == search->entry_country)
- gtk_widget_grab_focus(search->entry_city);
- if (widget == search->entry_city)
- gtk_widget_grab_focus(search->entry_street);
- if (widget == search->entry_street)
- gtk_widget_grab_focus(search->entry_number);
-
+static void next_focus(struct search_param *search, GtkWidget *widget) {
+ if (widget == search->entry_country)
+ gtk_widget_grab_focus(search->entry_city);
+ if (widget == search->entry_city)
+ gtk_widget_grab_focus(search->entry_street);
+ if (widget == search->entry_street)
+ gtk_widget_grab_focus(search->entry_number);
+
}
-static void changed(GtkWidget *widget, struct search_param *search)
-{
- struct search_list_result *res;
- GtkTreeIter iter;
-
- search->attr.u.str=(char *)gtk_entry_get_text(GTK_ENTRY(widget));
- printf("changed %s partial %d\n", search->attr.u.str, search->partial);
- if (widget == search->entry_country) {
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING);
- dbg(lvl_debug,"country\n");
- search->attr.type=attr_country_all;
- set_columns(search, 0);
- }
- if (widget == search->entry_postal) {
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 1, GTK_SORT_ASCENDING);
- dbg(lvl_debug,"postal\n");
- search->attr.type=attr_town_postal;
- if (strlen(search->attr.u.str) < 2)
- return;
- set_columns(search, 1);
- }
- if (widget == search->entry_city) {
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 2, GTK_SORT_ASCENDING);
- dbg(lvl_debug,"town\n");
- search->attr.type=attr_town_name;
- if (strlen(search->attr.u.str) < 3)
- return;
- set_columns(search, 1);
- }
- if (widget == search->entry_street) {
- dbg(lvl_debug,"street\n");
- search->attr.type=attr_street_name;
- // Searching for a street by just its first letter generates too many hits to be useful,
- // plus it causes the GUI to become unresponsive because the search is single-threaded.
- // So we only start searching once we have two letters.
- if (strlen(search->attr.u.str) < 2)
- return;
- set_columns(search, 2);
- }
-
- search_list_search(search->sl, &search->attr, search->partial);
- gtk_list_store_clear(search->liststore);
- while((res=search_list_get_result(search->sl))) {
- gtk_list_store_append(search->liststore,&iter);
- gtk_list_store_set(search->liststore,&iter,COL_COUNT,res->c,-1);
- if (widget == search->entry_country) {
- if (res->country) {
- gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1);
- gtk_list_store_set(search->liststore,&iter,1,res->country->iso3,-1);
- gtk_list_store_set(search->liststore,&iter,2,res->country->iso2,-1);
- gtk_list_store_set(search->liststore,&iter,3,res->country->name,-1);
- }
- } else {
- if (res->country)
- gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1);
- else
- gtk_list_store_set(search->liststore,&iter,0,"",-1);
- if (res->town) {
- gtk_list_store_set(search->liststore,&iter,1,res->town->common.postal,-1);
- gtk_list_store_set(search->liststore,&iter,2,res->town->common.town_name,-1);
- gtk_list_store_set(search->liststore,&iter,3,res->town->common.district_name,-1);
- } else {
- gtk_list_store_set(search->liststore,&iter,1,"",-1);
- gtk_list_store_set(search->liststore,&iter,2,"",-1);
- gtk_list_store_set(search->liststore,&iter,3,"",-1);
- }
- if (res->street)
- gtk_list_store_set(search->liststore,&iter,4,res->street->name,-1);
- else
- gtk_list_store_set(search->liststore,&iter,4,"",-1);
-
- }
- }
-
- if(! search->partial)
- {
- if( widget == search->entry_country )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
- }
- if( widget == search->entry_city )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE);
- }
- if( widget == search->entry_street )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), TRUE);
- }
- } else {
- if( widget == search->entry_country )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
- }
- if( widget == search->entry_city )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
- }
- if( widget == search->entry_street )
- {
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
- }
- }
- if (! search->partial)
- next_focus(search, widget);
- search->partial=1;
+static void changed(GtkWidget *widget, struct search_param *search) {
+ struct search_list_result *res;
+ GtkTreeIter iter;
+
+ search->attr.u.str=(char *)gtk_entry_get_text(GTK_ENTRY(widget));
+ printf("changed %s partial %d\n", search->attr.u.str, search->partial);
+ if (widget == search->entry_country) {
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING);
+ dbg(lvl_debug,"country");
+ search->attr.type=attr_country_all;
+ set_columns(search, 0);
+ }
+ if (widget == search->entry_postal) {
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 1, GTK_SORT_ASCENDING);
+ dbg(lvl_debug,"postal");
+ search->attr.type=attr_town_postal;
+ if (strlen(search->attr.u.str) < 2)
+ return;
+ set_columns(search, 1);
+ }
+ if (widget == search->entry_city) {
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 2, GTK_SORT_ASCENDING);
+ dbg(lvl_debug,"town");
+ search->attr.type=attr_town_name;
+ if (strlen(search->attr.u.str) < 3)
+ return;
+ set_columns(search, 1);
+ }
+ if (widget == search->entry_street) {
+ dbg(lvl_debug,"street");
+ search->attr.type=attr_street_name;
+ // Searching for a street by just its first letter generates too many hits to be useful,
+ // plus it causes the GUI to become unresponsive because the search is single-threaded.
+ // So we only start searching once we have two letters.
+ if (strlen(search->attr.u.str) < 2)
+ return;
+ set_columns(search, 2);
+ }
+
+ search_list_search(search->sl, &search->attr, search->partial);
+ gtk_list_store_clear(search->liststore);
+ while((res=search_list_get_result(search->sl))) {
+ gtk_list_store_append(search->liststore,&iter);
+ gtk_list_store_set(search->liststore,&iter,COL_COUNT,res->c,-1);
+ if (widget == search->entry_country) {
+ if (res->country) {
+ gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1);
+ gtk_list_store_set(search->liststore,&iter,1,res->country->iso3,-1);
+ gtk_list_store_set(search->liststore,&iter,2,res->country->iso2,-1);
+ gtk_list_store_set(search->liststore,&iter,3,res->country->name,-1);
+ }
+ } else {
+ if (res->country)
+ gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1);
+ else
+ gtk_list_store_set(search->liststore,&iter,0,"",-1);
+ if (res->town) {
+ gtk_list_store_set(search->liststore,&iter,1,res->town->common.postal,-1);
+ gtk_list_store_set(search->liststore,&iter,2,res->town->common.town_name,-1);
+ gtk_list_store_set(search->liststore,&iter,3,res->town->common.district_name,-1);
+ } else {
+ gtk_list_store_set(search->liststore,&iter,1,"",-1);
+ gtk_list_store_set(search->liststore,&iter,2,"",-1);
+ gtk_list_store_set(search->liststore,&iter,3,"",-1);
+ }
+ if (res->street)
+ gtk_list_store_set(search->liststore,&iter,4,res->street->name,-1);
+ else
+ gtk_list_store_set(search->liststore,&iter,4,"",-1);
+
+ }
+ }
+
+ if(! search->partial) {
+ if( widget == search->entry_country ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
+ }
+ if( widget == search->entry_city ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE);
+ }
+ if( widget == search->entry_street ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), TRUE);
+ }
+ } else {
+ if( widget == search->entry_country ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
+ }
+ if( widget == search->entry_city ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
+ }
+ if( widget == search->entry_street ) {
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
+ }
+ }
+ if (! search->partial)
+ next_focus(search, widget);
+ search->partial=1;
}
/* borrowed from gpe-login */
@@ -331,252 +333,238 @@ static void changed(GtkWidget *widget, struct search_param *search)
#define MAX_ARGS 8
-static void
-parse_xkbd_args (const char *cmd, char **argv)
-{
- const char *p = cmd;
- char buf[strlen (cmd) + 1], *bufp = buf;
- int nargs = 0;
- int escape = 0, squote = 0, dquote = 0;
-
- while (*p)
- {
- if (escape)
- {
- *bufp++ = *p;
- escape = 0;
- }
- else
- {
- switch (*p)
- {
- case '\\':
- escape = 1;
- break;
- case '"':
- if (squote)
- *bufp++ = *p;
- else
- dquote = !dquote;
- break;
- case '\'':
- if (dquote)
- *bufp++ = *p;
- else
- squote = !squote;
- break;
- case ' ':
- if (!squote && !dquote)
- {
- *bufp = 0;
- if (nargs < MAX_ARGS)
- argv[nargs++] = strdup (buf);
- bufp = buf;
- break;
- }
- default:
- *bufp++ = *p;
- break;
- }
- }
- p++;
- }
-
- if (bufp != buf)
- {
- *bufp = 0;
- if (nargs < MAX_ARGS)
- argv[nargs++] = strdup (buf);
- }
- argv[nargs] = NULL;
+static void parse_xkbd_args (const char *cmd, char **argv) {
+ const char *p = cmd;
+ char buf[strlen (cmd) + 1], *bufp = buf;
+ int nargs = 0;
+ int escape = 0, squote = 0, dquote = 0;
+
+ while (*p) {
+ if (escape) {
+ *bufp++ = *p;
+ escape = 0;
+ } else {
+ switch (*p) {
+ case '\\':
+ escape = 1;
+ break;
+ case '"':
+ if (squote)
+ *bufp++ = *p;
+ else
+ dquote = !dquote;
+ break;
+ case '\'':
+ if (dquote)
+ *bufp++ = *p;
+ else
+ squote = !squote;
+ break;
+ case ' ':
+ if (!squote && !dquote) {
+ *bufp = 0;
+ if (nargs < MAX_ARGS)
+ argv[nargs++] = strdup (buf);
+ bufp = buf;
+ break;
+ }
+ default:
+ *bufp++ = *p;
+ break;
+ }
+ }
+ p++;
+ }
+
+ if (bufp != buf) {
+ *bufp = 0;
+ if (nargs < MAX_ARGS)
+ argv[nargs++] = strdup (buf);
+ }
+ argv[nargs] = NULL;
}
int kbd_pid;
-static int
-spawn_xkbd (char *xkbd_path, char *xkbd_str)
-{
+static int spawn_xkbd (char *xkbd_path, char *xkbd_str) {
#ifdef _WIN32 // AF FIXME for WIN32
- #ifndef F_SETFD
- #define F_SETFD 2
- #endif
+#ifndef F_SETFD
+#define F_SETFD 2
+#endif
#else
- char *xkbd_args[MAX_ARGS + 1];
- int fd[2];
- char buf[256];
- char c;
- int a = 0;
- size_t n;
-
- pipe (fd);
- kbd_pid = fork ();
- if (kbd_pid == 0)
- {
- close (fd[0]);
- if (dup2 (fd[1], 1) < 0)
- perror ("dup2");
- close (fd[1]);
- if (fcntl (1, F_SETFD, 0))
- perror ("fcntl");
- xkbd_args[0] = (char *)xkbd_path;
- xkbd_args[1] = "-xid";
- if (xkbd_str)
- parse_xkbd_args (xkbd_str, xkbd_args + 2);
- else
- xkbd_args[2] = NULL;
- execvp (xkbd_path, xkbd_args);
- perror (xkbd_path);
- _exit (1);
- }
- close (fd[1]);
- do {
- n = read (fd[0], &c, 1);
- if (n)
- {
- buf[a++] = c;
- }
- } while (n && (c != 10) && (a < (sizeof (buf) - 1)));
-
- if (a)
- {
- buf[a] = 0;
- return atoi (buf);
- }
+ char *xkbd_args[MAX_ARGS + 1];
+ int fd[2];
+ char buf[256];
+ char c;
+ int a = 0;
+ size_t n;
+
+ pipe (fd);
+ kbd_pid = fork ();
+ if (kbd_pid == 0) {
+ close (fd[0]);
+ if (dup2 (fd[1], 1) < 0)
+ perror ("dup2");
+ close (fd[1]);
+ if (fcntl (1, F_SETFD, 0))
+ perror ("fcntl");
+ xkbd_args[0] = (char *)xkbd_path;
+ xkbd_args[1] = "-xid";
+ if (xkbd_str)
+ parse_xkbd_args (xkbd_str, xkbd_args + 2);
+ else
+ xkbd_args[2] = NULL;
+ execvp (xkbd_path, xkbd_args);
+ perror (xkbd_path);
+ _exit (1);
+ }
+ close (fd[1]);
+ do {
+ n = read (fd[0], &c, 1);
+ if (n) {
+ buf[a++] = c;
+ }
+ } while (n && (c != 10) && (a < (sizeof (buf) - 1)));
+
+ if (a) {
+ buf[a] = 0;
+ return atoi (buf);
+ }
#endif
- return 0;
+ return 0;
}
-int destination_address(struct navit *nav)
-{
-
- GtkWidget *window2, *keyboard, *vbox, *table;
- GtkWidget *label_country;
- GtkWidget *label_postal, *label_city, *label_district;
- GtkWidget *label_street, *label_number;
- GtkWidget *button1,*button2,*button3;
- int i;
- struct search_param *search=&search_param;
- struct attr search_attr, country_name, *country_attr;
- struct tracking *tracking;
- struct country_search *cs;
- struct item *item;
-
-
- search->nav=nav;
- search->ms=navit_get_mapset(nav);
- search->sl=search_list_new(search->ms);
-
- window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window2),_("Enter Destination"));
- gtk_window_set_wmclass (GTK_WINDOW (window2), "navit", "Navit");
- gtk_window_set_default_size (GTK_WINDOW (window2),0,300);
- vbox = gtk_vbox_new(FALSE, 0);
- table = gtk_table_new(3, 8, FALSE);
-
- search->entry_country = gtk_entry_new();
- label_country = gtk_label_new(_("Country"));
- search->entry_postal = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_postal), FALSE);
- label_postal = gtk_label_new(_("Zip Code"));
- search->entry_city = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), FALSE);
- label_city = gtk_label_new(_("City"));
- search->entry_district = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_district), FALSE);
- label_district = gtk_label_new(_("District/Township"));
- search->entry_street = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
- label_street = gtk_label_new(_("Street"));
- search->entry_number = gtk_entry_new();
- gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
- label_number = gtk_label_new(_("Number"));
- search->treeview=gtk_tree_view_new();
- search->listbox = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (search->listbox),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), NULL);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(search->listbox),search->treeview);
- {
- GType types[COL_COUNT+1];
- for(i=0;i<COL_COUNT;i++)
- types[i]=G_TYPE_STRING;
- types[i]=G_TYPE_POINTER;
- search->liststore=gtk_list_store_newv(COL_COUNT+1,types);
- search->liststore2=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->liststore));
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), GTK_TREE_MODEL(search->liststore2));
- }
-
-
-
-
- button1 = gtk_button_new_with_label(_("Map"));
- button2 = gtk_button_new_with_label(_("Bookmark"));
- button3 = gtk_button_new_with_label(_("Destination"));
-
- gtk_table_attach(GTK_TABLE(table), label_country, 0, 1, 0, 1, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_postal, 1, 2, 0, 1, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_city, 2, 3, 0, 1, 0, GTK_FILL, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), search->entry_country, 0, 1, 1, 2, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_postal, 1, 2, 1, 2, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_city, 2, 3, 1, 2, 0, GTK_FILL, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), label_district, 0, 1, 2, 3, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_street, 1, 2, 2, 3, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_number, 2, 3, 2, 3, 0, GTK_FILL, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), search->entry_district, 0, 1, 3, 4, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_street, 1, 2, 3, 4, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_number, 2, 3, 3, 4, 0, GTK_FILL, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), search->listbox, 0, 3, 4, 5, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
-
- gtk_table_attach(GTK_TABLE(table), button1, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), button2, 1, 2, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), button3, 2, 3, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
-
- g_signal_connect(G_OBJECT(search->entry_country), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_postal), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_city), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_district), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_street), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(search->entry_number), "changed", G_CALLBACK(changed), search);
- g_signal_connect(G_OBJECT(button1), "clicked", G_CALLBACK(button_map), search);
- g_signal_connect(G_OBJECT(button2), "clicked", G_CALLBACK(button_bookmark), search);
- g_signal_connect(G_OBJECT(button3), "clicked", G_CALLBACK(button_destination), search);
- g_signal_connect(G_OBJECT(search->treeview), "button-release-event", G_CALLBACK(tree_view_button_release), search);
- g_signal_connect(G_OBJECT(search->treeview), "row_activated", G_CALLBACK(row_activated), search);
-
- gtk_widget_grab_focus(search->entry_city);
-
- gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
- keyboard=gtk_socket_new();
- gtk_box_pack_end(GTK_BOX(vbox), keyboard, FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(window2), vbox);
+int destination_address(struct navit *nav) {
+
+ GtkWidget *window2, *keyboard, *vbox, *table;
+ GtkWidget *label_country;
+ GtkWidget *label_postal, *label_city, *label_district;
+ GtkWidget *label_street, *label_number;
+ GtkWidget *button1,*button2,*button3;
+ int i;
+ struct search_param *search=&search_param;
+ struct attr search_attr, country_name, *country_attr;
+ struct tracking *tracking;
+ struct country_search *cs;
+ struct item *item;
+
+
+ search->nav=nav;
+ search->ms=navit_get_mapset(nav);
+ search->sl=search_list_new(search->ms);
+
+ window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window2),_("Enter Destination"));
+ gtk_window_set_wmclass (GTK_WINDOW (window2), "navit", "Navit");
+ gtk_window_set_default_size (GTK_WINDOW (window2),0,300);
+ vbox = gtk_vbox_new(FALSE, 0);
+ table = gtk_table_new(3, 8, FALSE);
+
+ search->entry_country = gtk_entry_new();
+ label_country = gtk_label_new(_("Country"));
+ search->entry_postal = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_postal), FALSE);
+ label_postal = gtk_label_new(_("Zip Code"));
+ search->entry_city = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), FALSE);
+ label_city = gtk_label_new(_("City"));
+ search->entry_district = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_district), FALSE);
+ label_district = gtk_label_new(_("District/Township"));
+ search->entry_street = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE);
+ label_street = gtk_label_new(_("Street"));
+ search->entry_number = gtk_entry_new();
+ gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE);
+ label_number = gtk_label_new(_("Number"));
+ search->treeview=gtk_tree_view_new();
+ search->listbox = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (search->listbox),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), NULL);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(search->listbox),search->treeview);
+ {
+ GType types[COL_COUNT+1];
+ for(i=0; i<COL_COUNT; i++)
+ types[i]=G_TYPE_STRING;
+ types[i]=G_TYPE_POINTER;
+ search->liststore=gtk_list_store_newv(COL_COUNT+1,types);
+ search->liststore2=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->liststore));
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview), GTK_TREE_MODEL(search->liststore2));
+ }
+
+
+
+
+ button1 = gtk_button_new_with_label(_("Map"));
+ button2 = gtk_button_new_with_label(_("Bookmark"));
+ button3 = gtk_button_new_with_label(_("Destination"));
+
+ gtk_table_attach(GTK_TABLE(table), label_country, 0, 1, 0, 1, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_postal, 1, 2, 0, 1, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_city, 2, 3, 0, 1, 0, GTK_FILL, 0, 0);
+
+ gtk_table_attach(GTK_TABLE(table), search->entry_country, 0, 1, 1, 2, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_postal, 1, 2, 1, 2, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_city, 2, 3, 1, 2, 0, GTK_FILL, 0, 0);
+
+ gtk_table_attach(GTK_TABLE(table), label_district, 0, 1, 2, 3, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_street, 1, 2, 2, 3, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_number, 2, 3, 2, 3, 0, GTK_FILL, 0, 0);
+
+ gtk_table_attach(GTK_TABLE(table), search->entry_district, 0, 1, 3, 4, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_street, 1, 2, 3, 4, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_number, 2, 3, 3, 4, 0, GTK_FILL, 0, 0);
+
+ gtk_table_attach(GTK_TABLE(table), search->listbox, 0, 3, 4, 5, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0,
+ 0);
+
+ gtk_table_attach(GTK_TABLE(table), button1, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), button2, 1, 2, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), button3, 2, 3, 5, 6, GTK_FILL, GTK_FILL, 0, 0);
+
+ g_signal_connect(G_OBJECT(search->entry_country), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_postal), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_city), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_district), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_street), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(search->entry_number), "changed", G_CALLBACK(changed), search);
+ g_signal_connect(G_OBJECT(button1), "clicked", G_CALLBACK(button_map), search);
+ g_signal_connect(G_OBJECT(button2), "clicked", G_CALLBACK(button_bookmark), search);
+ g_signal_connect(G_OBJECT(button3), "clicked", G_CALLBACK(button_destination), search);
+ g_signal_connect(G_OBJECT(search->treeview), "button-release-event", G_CALLBACK(tree_view_button_release), search);
+ g_signal_connect(G_OBJECT(search->treeview), "row_activated", G_CALLBACK(row_activated), search);
+
+ gtk_widget_grab_focus(search->entry_city);
+
+ gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+ keyboard=gtk_socket_new();
+ gtk_box_pack_end(GTK_BOX(vbox), keyboard, FALSE, FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(window2), vbox);
#if 0
- g_signal_connect(G_OBJECT(listbox), "select-row", G_CALLBACK(select_row), NULL);
+ g_signal_connect(G_OBJECT(listbox), "select-row", G_CALLBACK(select_row), NULL);
#endif
- gtk_widget_show_all(window2);
+ gtk_widget_show_all(window2);
#ifndef _WIN32
- gtk_socket_steal(GTK_SOCKET(keyboard), spawn_xkbd("xkbd","-geometry 200x100"));
+ gtk_socket_steal(GTK_SOCKET(keyboard), spawn_xkbd("xkbd","-geometry 200x100"));
#endif
- country_attr=country_default();
- tracking=navit_get_tracking(nav);
- if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
- country_attr=&search_attr;
- if (country_attr) {
- cs=country_search_new(country_attr, 0);
- item=country_search_get_item(cs);
- if (item && item_attr_get(item, attr_country_name, &country_name))
- gtk_entry_set_text(GTK_ENTRY(search->entry_country), country_name.u.str);
- country_search_destroy(cs);
- } else {
- dbg(lvl_error,"warning: no default country found\n");
- }
- search->partial=1;
- return 0;
+ country_attr=country_default();
+ tracking=navit_get_tracking(nav);
+ if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
+ country_attr=&search_attr;
+ if (country_attr) {
+ cs=country_search_new(country_attr, 0);
+ item=country_search_get_item(cs);
+ if (item && item_attr_get(item, attr_country_name, &country_name))
+ gtk_entry_set_text(GTK_ENTRY(search->entry_country), country_name.u.str);
+ country_search_destroy(cs);
+ } else {
+ dbg(lvl_error,"warning: no default country found");
+ }
+ search->partial=1;
+ return 0;
}
diff --git a/navit/gui/gtk/gui_gtk.h b/navit/gui/gtk/gui_gtk.h
index 10051beaf..c8c3ca1ec 100644
--- a/navit/gui/gtk/gui_gtk.h
+++ b/navit/gui/gtk/gui_gtk.h
@@ -26,37 +26,38 @@ struct callback;
struct statusbar_priv;
struct gui_priv {
- struct navit *nav;
- GtkWidget *win;
- GtkWidget *dialog_win;
- GtkWidget *dialog_entry;
- struct pcoord dialog_coord;
- GtkWidget *vbox;
- GtkWidget *menubar;
- GtkActionGroup *base_group;
- GtkActionGroup *debug_group;
- GtkActionGroup *dyn_group;
- GtkUIManager *ui_manager;
- GSList *layout_group;
- GSList *projection_group;
- GSList *vehicle_group;
- GList *dest_menuitems;
- GList *bookmarks_menuitems;
- GList *vehicle_menuitems;
- GtkUIManager *menu_manager; // old
- struct statusbar_priv *statusbar;
- int menubar_enable;
- int toolbar_enable;
- int statusbar_enable;
- int dyn_counter;
- struct datawindow_priv *datawindow;
+ struct navit *nav;
+ GtkWidget *win;
+ GtkWidget *dialog_win;
+ GtkWidget *dialog_entry;
+ struct pcoord dialog_coord;
+ GtkWidget *vbox;
+ GtkWidget *menubar;
+ GtkActionGroup *base_group;
+ GtkActionGroup *debug_group;
+ GtkActionGroup *dyn_group;
+ GtkUIManager *ui_manager;
+ GSList *layout_group;
+ GSList *projection_group;
+ GSList *vehicle_group;
+ GList *dest_menuitems;
+ GList *bookmarks_menuitems;
+ GList *vehicle_menuitems;
+ GtkUIManager *menu_manager; // old
+ struct statusbar_priv *statusbar;
+ int menubar_enable;
+ int toolbar_enable;
+ int statusbar_enable;
+ int dyn_counter;
+ struct datawindow_priv *datawindow;
};
void gui_gtk_ui_init(struct gui_priv *this);
struct menu_priv *gui_gtk_menubar_new(struct gui_priv *gui, struct menu_methods *meth);
struct statusbar_priv *gui_gtk_statusbar_new(struct gui_priv *gui);
struct menu_priv *gui_gtk_popup_new(struct gui_priv *gui, struct menu_methods *meth);
-struct datawindow_priv *gui_gtk_datawindow_new(struct gui_priv *gui, const char *name, struct callback *click, struct callback *close, struct datawindow_methods *meth);
+struct datawindow_priv *gui_gtk_datawindow_new(struct gui_priv *gui, const char *name, struct callback *click,
+ struct callback *close, struct datawindow_methods *meth);
void gui_gtk_datawindow_destroy(struct datawindow_priv *win);
void gui_gtk_datawindow_set_button(struct datawindow_priv *this_, GtkWidget *btn);
diff --git a/navit/gui/gtk/gui_gtk_action.c b/navit/gui/gtk/gui_gtk_action.c
index 0d6acee48..ca5ff9427 100644
--- a/navit/gui/gtk/gui_gtk_action.c
+++ b/navit/gui/gtk/gui_gtk_action.c
@@ -36,94 +36,80 @@
#include "gui_gtk_poi.h"
struct menu_priv {
- char *path;
- GtkAction *action;
- struct gui_priv *gui;
- enum menu_type type;
- struct callback *cb;
- struct menu_priv *child;
- struct menu_priv *sibling;
- gulong handler_id;
- guint merge_id;
- GtkWidget *widget;
+ char *path;
+ GtkAction *action;
+ struct gui_priv *gui;
+ enum menu_type type;
+ struct callback *cb;
+ struct menu_priv *child;
+ struct menu_priv *sibling;
+ gulong handler_id;
+ guint merge_id;
+ GtkWidget *widget;
};
/* Create callbacks that implement our Actions */
-static void
-zoom_in_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_zoom_in(gui->nav, 2, NULL);
+static void zoom_in_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_zoom_in(gui->nav, 2, NULL);
}
-static void
-zoom_out_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_zoom_out(gui->nav, 2, NULL);
+static void zoom_out_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_zoom_out(gui->nav, 2, NULL);
}
-static void
-refresh_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_draw(gui->nav);
+static void refresh_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_draw(gui->nav);
}
-// Forward declarations, these should not be visible outside the GUI, so
+// Forward declarations, these should not be visible outside the GUI, so
// they are not in the header files, but here
void gui_gtk_datawindow_set_button(struct datawindow_priv *this_, GtkWidget *btn);
void gui_gtk_datawindow_destroy(struct datawindow_priv *win);
-static void
-roadbook_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
-
- if (! gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w))) {
- gui_gtk_datawindow_destroy(gui->datawindow);
- } else {
- navit_window_roadbook_new(gui->nav);
- if (gui->datawindow) {
- gui_gtk_datawindow_set_button(gui->datawindow, w);
- }
- }
+static void roadbook_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+
+ if (! gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w))) {
+ gui_gtk_datawindow_destroy(gui->datawindow);
+ } else {
+ navit_window_roadbook_new(gui->nav);
+ if (gui->datawindow) {
+ gui_gtk_datawindow_set_button(gui->datawindow, w);
+ }
+ }
}
-static void
-autozoom_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr autozoom_attr;
-
- autozoom_attr.type = attr_autozoom_active;
- if (! gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w))) {
- autozoom_attr.u.num = 0;
- } else {
- autozoom_attr.u.num = 1;
- }
-
- navit_set_attr(gui->nav, &autozoom_attr);
+static void autozoom_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr autozoom_attr;
+
+ autozoom_attr.type = attr_autozoom_active;
+ if (! gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w))) {
+ autozoom_attr.u.num = 0;
+ } else {
+ autozoom_attr.u.num = 1;
+ }
+
+ navit_set_attr(gui->nav, &autozoom_attr);
}
-static void
-cursor_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr attr;
+static void cursor_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr attr;
- attr.type=attr_cursor;
- attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_cursor\n");
- }
+ attr.type=attr_cursor;
+ attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_cursor");
+ }
}
-static void
-tracking_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr attr;
+static void tracking_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr attr;
- attr.type=attr_tracking;
- attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_tracking\n");
- }
+ attr.type=attr_tracking;
+ attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_tracking");
+ }
}
/** @brief Toggles the ability to follow the vehicle at the
@@ -135,270 +121,251 @@ tracking_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
* @return void
*/
-static void
-follow_vehicle_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr attr;
+static void follow_vehicle_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr attr;
- attr.type=attr_follow_cursor;
- attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_follow_gps\n");
- }
+ attr.type=attr_follow_cursor;
+ attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_follow_gps");
+ }
}
-static void
-orient_north_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- struct attr attr;
+static void orient_north_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ struct attr attr;
- attr.type=attr_orientation;
- attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)) ? 0:-1;
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_orientation\n");
- }
+ attr.type=attr_orientation;
+ attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)) ? 0:-1;
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_orientation");
+ }
}
-static void
-window_fullscreen_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- if(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)))
- gtk_window_fullscreen(GTK_WINDOW(gui->win));
- else
- gtk_window_unfullscreen(GTK_WINDOW(gui->win));
+static void window_fullscreen_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ if(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w)))
+ gtk_window_fullscreen(GTK_WINDOW(gui->win));
+ else
+ gtk_window_unfullscreen(GTK_WINDOW(gui->win));
}
#include <stdlib.h>
#include "point.h"
#include "transform.h"
-static void
-info_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- char buffer[512];
- int mw,mh;
- struct coord lt, rb;
- struct point p;
- struct transformation *t;
-
- t=navit_get_trans(gui->nav);
- transform_get_size(t, &mw, &mh);
- p.x=0;
- p.y=0;
- transform_reverse(t, &p, &lt);
- p.x=mw;
- p.y=mh;
- transform_reverse(t, &p, &rb);
-
- sprintf(buffer,"./info.sh %d,%d 0x%x,0x%x 0x%x,0x%x", mw, mh, lt.x, lt.y, rb.x, rb.y);
- system(buffer);
+static void info_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ char buffer[512];
+ int mw,mh;
+ struct coord lt, rb;
+ struct point p;
+ struct transformation *t;
+
+ t=navit_get_trans(gui->nav);
+ transform_get_size(t, &mw, &mh);
+ p.x=0;
+ p.y=0;
+ transform_reverse(t, &p, &lt);
+ p.x=mw;
+ p.y=mh;
+ transform_reverse(t, &p, &rb);
+
+ sprintf(buffer,"./info.sh %d,%d 0x%x,0x%x 0x%x,0x%x", mw, mh, lt.x, lt.y, rb.x, rb.y);
+ system(buffer);
}
-static void
-route_clear_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_set_destination(gui->nav, NULL, NULL, 0);
+static void route_clear_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_set_destination(gui->nav, NULL, NULL, 0);
}
-static void
-poi_search_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- gtk_gui_poi(gui->nav);
+static void poi_search_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ gtk_gui_poi(gui->nav);
}
-static void
-destination_action(GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- destination_address(gui->nav);
+static void destination_action(GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ destination_address(gui->nav);
}
-static void
-quit_action (GtkWidget *w, struct gui_priv *gui, void *dummy)
-{
- navit_destroy(gui->nav);
- exit(0);
+static void quit_action (GtkWidget *w, struct gui_priv *gui, void *dummy) {
+ navit_destroy(gui->nav);
+ exit(0);
}
-static GtkActionEntry entries[] =
-{
- /* TRANSLATORS: These texts are for menu items in GTK GUI. The _ indicates the mnemonic key (=underlined character) for this menu item. Please place the _ before a suitable character in the translation (or omit it if no mnemonic key is desired). */
- { "DisplayMenuAction", NULL, _n("_Display") },
- { "RouteMenuAction", NULL, _n("_Route") },
- { "FormerDestinationMenuAction", NULL, _n("_Former Destinations") },
- { "BookmarkMenuAction", NULL, _n("_Bookmarks") },
- { "MapMenuAction", NULL, _n("_Map") },
- { "LayoutMenuAction", NULL, _n("_Layout") },
- { "ProjectionMenuAction", NULL, _n("_Projection") },
- { "VehicleMenuAction", NULL, _n("_Vehicle") },
- { "ZoomOutAction", GTK_STOCK_ZOOM_OUT, _n("Zoom_Out"), "<control>minus", _n("Decrease zoom level"), G_CALLBACK(zoom_out_action) },
- { "ZoomInAction", GTK_STOCK_ZOOM_IN, _n("Zoom_In"), "<control>plus", _n("Increase zoom level"), G_CALLBACK(zoom_in_action) },
- { "RefreshAction", GTK_STOCK_REFRESH, _n("_Recalculate"), "<control>R", _n("Redraw map"), G_CALLBACK(refresh_action) },
+static GtkActionEntry entries[] = {
+ /* TRANSLATORS: These texts are for menu items in GTK GUI. The _ indicates the mnemonic key (=underlined character) for this menu item. Please place the _ before a suitable character in the translation (or omit it if no mnemonic key is desired). */
+ { "DisplayMenuAction", NULL, _n("_Display") },
+ { "RouteMenuAction", NULL, _n("_Route") },
+ { "FormerDestinationMenuAction", NULL, _n("_Former Destinations") },
+ { "BookmarkMenuAction", NULL, _n("_Bookmarks") },
+ { "MapMenuAction", NULL, _n("_Map") },
+ { "LayoutMenuAction", NULL, _n("_Layout") },
+ { "ProjectionMenuAction", NULL, _n("_Projection") },
+ { "VehicleMenuAction", NULL, _n("_Vehicle") },
+ { "ZoomOutAction", GTK_STOCK_ZOOM_OUT, _n("Zoom_Out"), "<control>minus", _n("Decrease zoom level"), G_CALLBACK(zoom_out_action) },
+ { "ZoomInAction", GTK_STOCK_ZOOM_IN, _n("Zoom_In"), "<control>plus", _n("Increase zoom level"), G_CALLBACK(zoom_in_action) },
+ { "RefreshAction", GTK_STOCK_REFRESH, _n("_Recalculate"), "<control>R", _n("Redraw map"), G_CALLBACK(refresh_action) },
#ifdef GTK_STOCK_INFO
- { "InfoAction", GTK_STOCK_INFO, _n("_Info"), NULL, NULL, G_CALLBACK(info_action) },
+ { "InfoAction", GTK_STOCK_INFO, _n("_Info"), NULL, NULL, G_CALLBACK(info_action) },
#else
- { "InfoAction", NULL, _n("_Info"), NULL, NULL, G_CALLBACK(info_action) },
+ { "InfoAction", NULL, _n("_Info"), NULL, NULL, G_CALLBACK(info_action) },
#endif /*GTK_STOCK_INFO*/
- { "DestinationAction", "flag_icon", _n("Set _destination"), "<control>D", _n("Opens address search dialog"), G_CALLBACK(destination_action) },
- { "POIAction", "flag_icon", _n("_POI search"), "<control>P", _n("Opens POI search dialog"), G_CALLBACK(poi_search_action) },
- { "RouteClearAction", NULL, _n("_Stop Navigation"), "<control>S", NULL, G_CALLBACK(route_clear_action) },
- { "Test", NULL, _n("Test"), NULL, NULL, G_CALLBACK(destination_action) },
- { "QuitAction", GTK_STOCK_QUIT, _n("_Quit"), "<control>Q",_n("Quit the application"), G_CALLBACK (quit_action) }
+ { "DestinationAction", "flag_icon", _n("Set _destination"), "<control>D", _n("Opens address search dialog"), G_CALLBACK(destination_action) },
+ { "POIAction", "flag_icon", _n("_POI search"), "<control>P", _n("Opens POI search dialog"), G_CALLBACK(poi_search_action) },
+ { "RouteClearAction", NULL, _n("_Stop Navigation"), "<control>S", NULL, G_CALLBACK(route_clear_action) },
+ { "Test", NULL, _n("Test"), NULL, NULL, G_CALLBACK(destination_action) },
+ { "QuitAction", GTK_STOCK_QUIT, _n("_Quit"), "<control>Q",_n("Quit the application"), G_CALLBACK (quit_action) }
};
static guint n_entries = G_N_ELEMENTS (entries);
-static GtkToggleActionEntry toggleentries[] =
-{
- { "CursorAction", "cursor_icon",_n("Show position _cursor"), NULL, NULL, G_CALLBACK(cursor_action),TRUE },
- { "TrackingAction", NULL ,_n("_Lock on Road"), NULL, NULL, G_CALLBACK(tracking_action),TRUE },
- { "FollowVehicleAction", NULL ,_n("_Follow Vehicle"), NULL, NULL, G_CALLBACK(follow_vehicle_action),TRUE },
- { "OrientationAction", "orientation_icon", _n("_Keep orientation to the North"), NULL, _n("Switches map orientation to the north or the vehicle"), G_CALLBACK(orient_north_action),FALSE },
- { "RoadbookAction", GTK_STOCK_JUSTIFY_FILL, _n("_Roadbook"), "<control>B", _n("Show/hide route description"), G_CALLBACK(roadbook_action), FALSE },
- { "AutozoomAction", GTK_STOCK_ZOOM_FIT, _n("_Autozoom"), "<control>A", _n("Enable/disable automatic zoom level changing"), G_CALLBACK(autozoom_action), FALSE },
+static GtkToggleActionEntry toggleentries[] = {
+ { "CursorAction", "cursor_icon",_n("Show position _cursor"), NULL, NULL, G_CALLBACK(cursor_action),TRUE },
+ { "TrackingAction", NULL,_n("_Lock on Road"), NULL, NULL, G_CALLBACK(tracking_action),TRUE },
+ { "FollowVehicleAction", NULL,_n("_Follow Vehicle"), NULL, NULL, G_CALLBACK(follow_vehicle_action),TRUE },
+ { "OrientationAction", "orientation_icon", _n("_Keep orientation to the North"), NULL, _n("Switches map orientation to the north or the vehicle"), G_CALLBACK(orient_north_action),FALSE },
+ { "RoadbookAction", GTK_STOCK_JUSTIFY_FILL, _n("_Roadbook"), "<control>B", _n("Show/hide route description"), G_CALLBACK(roadbook_action), FALSE },
+ { "AutozoomAction", GTK_STOCK_ZOOM_FIT, _n("_Autozoom"), "<control>A", _n("Enable/disable automatic zoom level changing"), G_CALLBACK(autozoom_action), FALSE },
#ifdef GTK_STOCK_FULLSCREEN
- { "FullscreenAction",GTK_STOCK_FULLSCREEN, _n("_Fullscreen"), "<control>F", NULL, G_CALLBACK(window_fullscreen_action), FALSE }
+ { "FullscreenAction",GTK_STOCK_FULLSCREEN, _n("_Fullscreen"), "<control>F", NULL, G_CALLBACK(window_fullscreen_action), FALSE }
#else
- { "FullscreenAction", NULL, _n("_Fullscreen"), "<control>F", NULL, G_CALLBACK(window_fullscreen_action), FALSE }
+ { "FullscreenAction", NULL, _n("_Fullscreen"), "<control>F", NULL, G_CALLBACK(window_fullscreen_action), FALSE }
#endif /*GTK_STOCK_FULLSCREEN*/
};
static guint n_toggleentries = G_N_ELEMENTS (toggleentries);
-static GtkActionEntry debug_entries[] =
-{
- { "DataMenuAction", NULL, _n("Data") },
+static GtkActionEntry debug_entries[] = {
+ { "DataMenuAction", NULL, _n("Data") },
};
static guint n_debug_entries = G_N_ELEMENTS (debug_entries);
static const char * cursor_xpm[] = {
-"22 22 2 1",
-" c None",
-". c #0000FF",
-" ",
-" ",
-" ",
-" .. ",
-" .. .. ",
-" .. .. ",
-" . . ",
-" . . ",
-" . ... . ",
-" . ... . . ",
-" . ... . . ",
-" . .. . . ",
-" . . . ",
-" . . . ",
-" . . . ",
-" . . . ",
-" .. .. ",
-" .. .. ",
-" .. ",
-" ",
-" ",
-" "};
+ "22 22 2 1",
+ " c None",
+ ". c #0000FF",
+ " ",
+ " ",
+ " ",
+ " .. ",
+ " .. .. ",
+ " .. .. ",
+ " . . ",
+ " . . ",
+ " . ... . ",
+ " . ... . . ",
+ " . ... . . ",
+ " . .. . . ",
+ " . . . ",
+ " . . . ",
+ " . . . ",
+ " . . . ",
+ " .. .. ",
+ " .. .. ",
+ " .. ",
+ " ",
+ " ",
+ " "
+};
static const char * north_xpm[] = {
-"22 22 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" . ",
-" ... ",
-" . . . ",
-" . . . ",
-" . ",
-" .... . .... ",
-" .... . .... ",
-" .... . .. ",
-" .. .. .. ",
-" .. .. .. ",
-" .. .. .. ",
-" .. .. .. ",
-" .. . .... ",
-" .... . .... ",
-" .... . .... ",
-" . ",
-" . ",
-" . ",
-" ",
-" "};
+ "22 22 2 1",
+ " c None",
+ ". c #000000",
+ " ",
+ " ",
+ " . ",
+ " ... ",
+ " . . . ",
+ " . . . ",
+ " . ",
+ " .... . .... ",
+ " .... . .... ",
+ " .... . .. ",
+ " .. .. .. ",
+ " .. .. .. ",
+ " .. .. .. ",
+ " .. .. .. ",
+ " .. . .... ",
+ " .... . .... ",
+ " .... . .... ",
+ " . ",
+ " . ",
+ " . ",
+ " ",
+ " "
+};
static const char * flag_xpm[] = {
-"22 22 2 1",
-" c None",
-"+ c #000000",
-"+++++++ ",
-"+ +++++++++ ",
-"+ +++ +++++++++ ",
-"+ +++ +++ +++ ",
-"++++ +++ +++ ",
-"++++ +++ +++ ",
-"++++ +++ +++ + ",
-"+ ++++++ +++ + ",
-"+ +++ ++++++ + ",
-"+ +++ +++ +++ ",
-"++++ +++ +++ ",
-"++++ +++ +++ ",
-"++++++++++ +++ + ",
-"+ +++++++++ + ",
-"+ ++++++ ",
-"+ ",
-"+ ",
-"+ ",
-"+ ",
-"+ ",
-"+ ",
-"+ "};
+ "22 22 2 1",
+ " c None",
+ "+ c #000000",
+ "+++++++ ",
+ "+ +++++++++ ",
+ "+ +++ +++++++++ ",
+ "+ +++ +++ +++ ",
+ "++++ +++ +++ ",
+ "++++ +++ +++ ",
+ "++++ +++ +++ + ",
+ "+ ++++++ +++ + ",
+ "+ +++ ++++++ + ",
+ "+ +++ +++ +++ ",
+ "++++ +++ +++ ",
+ "++++ +++ +++ ",
+ "++++++++++ +++ + ",
+ "+ +++++++++ + ",
+ "+ ++++++ ",
+ "+ ",
+ "+ ",
+ "+ ",
+ "+ ",
+ "+ ",
+ "+ ",
+ "+ "
+};
static struct {
- gchar *stockid;
- const char **icon_xpm;
+ gchar *stockid;
+ const char **icon_xpm;
} stock_icons[] = {
- {"cursor_icon", cursor_xpm },
- {"orientation_icon", north_xpm },
- {"flag_icon", flag_xpm }
+ {"cursor_icon", cursor_xpm },
+ {"orientation_icon", north_xpm },
+ {"flag_icon", flag_xpm }
};
static gint n_stock_icons = G_N_ELEMENTS (stock_icons);
-static void
-register_my_stock_icons (void)
-{
- GtkIconFactory *icon_factory;
- GtkIconSet *icon_set;
- GdkPixbuf *pixbuf;
- gint i;
+static void register_my_stock_icons (void) {
+ GtkIconFactory *icon_factory;
+ GtkIconSet *icon_set;
+ GdkPixbuf *pixbuf;
+ gint i;
- icon_factory = gtk_icon_factory_new ();
+ icon_factory = gtk_icon_factory_new ();
- for (i = 0; i < n_stock_icons; i++)
- {
- pixbuf = gdk_pixbuf_new_from_xpm_data(stock_icons[i].icon_xpm);
- icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
- g_object_unref(pixbuf);
- gtk_icon_factory_add (icon_factory, stock_icons[i].stockid, icon_set);
- gtk_icon_set_unref (icon_set);
- }
+ for (i = 0; i < n_stock_icons; i++) {
+ pixbuf = gdk_pixbuf_new_from_xpm_data(stock_icons[i].icon_xpm);
+ icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
+ g_object_unref(pixbuf);
+ gtk_icon_factory_add (icon_factory, stock_icons[i].stockid, icon_set);
+ gtk_icon_set_unref (icon_set);
+ }
- gtk_icon_factory_add_default(icon_factory);
+ gtk_icon_factory_add_default(icon_factory);
- g_object_unref(icon_factory);
+ g_object_unref(icon_factory);
}
static char layout[] =
- "<ui>\
+ "<ui>\
<menubar name=\"MenuBar\">\
<menu name=\"Display\" action=\"DisplayMenuAction\">\
<menuitem name=\"Zoom in\" action=\"ZoomInAction\" />\
@@ -464,200 +431,187 @@ static char layout[] =
</ui>";
-static void
-activate(void *dummy, struct menu_priv *menu)
-{
- if (menu->cb)
- callback_call_0(menu->cb);
+static void activate(void *dummy, struct menu_priv *menu) {
+ if (menu->cb)
+ callback_call_0(menu->cb);
}
static struct menu_methods menu_methods;
-static struct menu_priv *
-add_menu(struct menu_priv *menu, struct menu_methods *meth, char *name, enum menu_type type, struct callback *cb)
-{
- struct menu_priv *ret;
- char *dynname;
-
- ret=g_new0(struct menu_priv, 1);
- *meth=menu_methods;
- if (! strcmp(menu->path, "/ui/MenuBar") && !strcmp(name,"Route")) {
- dynname=g_strdup("Route");
- } else if (! strcmp(menu->path, "/ui/MenuBar") && !strcmp(name,"Data")) {
- dynname=g_strdup("Data");
- } else {
- dynname=g_strdup_printf("%d", menu->gui->dyn_counter++);
- if (type == menu_type_toggle)
- ret->action=GTK_ACTION(gtk_toggle_action_new(dynname, name, NULL, NULL));
- else
- ret->action=gtk_action_new(dynname, name, NULL, NULL);
- if (cb)
- ret->handler_id=g_signal_connect(ret->action, "activate", G_CALLBACK(activate), ret);
- gtk_action_group_add_action(menu->gui->dyn_group, ret->action);
- ret->merge_id=gtk_ui_manager_new_merge_id(menu->gui->ui_manager);
- gtk_ui_manager_add_ui( menu->gui->ui_manager, ret->merge_id, menu->path, dynname, dynname, type == menu_type_submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
- }
- ret->gui=menu->gui;
- ret->path=g_strdup_printf("%s/%s", menu->path, dynname);
- ret->type=type;
- ret->cb=cb;
- ret->sibling=menu->child;
- menu->child=ret;
- g_free(dynname);
- return ret;
+static struct menu_priv *add_menu(struct menu_priv *menu, struct menu_methods *meth, char *name, enum menu_type type,
+ struct callback *cb) {
+ struct menu_priv *ret;
+ char *dynname;
+
+ ret=g_new0(struct menu_priv, 1);
+ *meth=menu_methods;
+ if (! strcmp(menu->path, "/ui/MenuBar") && !strcmp(name,"Route")) {
+ dynname=g_strdup("Route");
+ } else if (! strcmp(menu->path, "/ui/MenuBar") && !strcmp(name,"Data")) {
+ dynname=g_strdup("Data");
+ } else {
+ dynname=g_strdup_printf("%d", menu->gui->dyn_counter++);
+ if (type == menu_type_toggle)
+ ret->action=GTK_ACTION(gtk_toggle_action_new(dynname, name, NULL, NULL));
+ else
+ ret->action=gtk_action_new(dynname, name, NULL, NULL);
+ if (cb)
+ ret->handler_id=g_signal_connect(ret->action, "activate", G_CALLBACK(activate), ret);
+ gtk_action_group_add_action(menu->gui->dyn_group, ret->action);
+ ret->merge_id=gtk_ui_manager_new_merge_id(menu->gui->ui_manager);
+ gtk_ui_manager_add_ui( menu->gui->ui_manager, ret->merge_id, menu->path, dynname, dynname,
+ type == menu_type_submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
+ }
+ ret->gui=menu->gui;
+ ret->path=g_strdup_printf("%s/%s", menu->path, dynname);
+ ret->type=type;
+ ret->cb=cb;
+ ret->sibling=menu->child;
+ menu->child=ret;
+ g_free(dynname);
+ return ret;
}
-static void
-remove_menu(struct menu_priv *item, int recursive)
-{
-
- if (recursive) {
- struct menu_priv *next,*child=item->child;
- while (child) {
- next=child->sibling;
- remove_menu(child, recursive);
- child=next;
- }
- }
- if (item->action) {
- gtk_ui_manager_remove_ui(item->gui->ui_manager, item->merge_id);
- gtk_action_group_remove_action(item->gui->dyn_group, item->action);
+static void remove_menu(struct menu_priv *item, int recursive) {
+
+ if (recursive) {
+ struct menu_priv *next,*child=item->child;
+ while (child) {
+ next=child->sibling;
+ remove_menu(child, recursive);
+ child=next;
+ }
+ }
+ if (item->action) {
+ gtk_ui_manager_remove_ui(item->gui->ui_manager, item->merge_id);
+ gtk_action_group_remove_action(item->gui->dyn_group, item->action);
#if 0
- if (item->callback)
- g_signal_handler_disconnect(item->action, item->handler_id);
+ if (item->callback)
+ g_signal_handler_disconnect(item->action, item->handler_id);
#endif
- g_object_unref(item->action);
- }
- g_free(item->path);
- g_free(item);
+ g_object_unref(item->action);
+ }
+ g_free(item->path);
+ g_free(item);
}
-static void
-set_toggle(struct menu_priv *menu, int active)
-{
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
+static void set_toggle(struct menu_priv *menu, int active) {
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
}
-static int
-get_toggle(struct menu_priv *menu)
-{
- return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
+static int get_toggle(struct menu_priv *menu) {
+ return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
}
static struct menu_methods menu_methods = {
#if 1
- add_menu,
- set_toggle,
- get_toggle,
+ add_menu,
+ set_toggle,
+ get_toggle,
#else
- NULL,
- NULL,
- NULL
+ NULL,
+ NULL,
+ NULL
#endif
};
-static void
-popup_deactivate(GtkWidget *widget, struct menu_priv *menu)
-{
- g_signal_handler_disconnect(widget, menu->handler_id);
- remove_menu(menu, 1);
+static void popup_deactivate(GtkWidget *widget, struct menu_priv *menu) {
+ g_signal_handler_disconnect(widget, menu->handler_id);
+ remove_menu(menu, 1);
}
-static void
-popup_activate(struct menu_priv *menu)
-{
+static void popup_activate(struct menu_priv *menu) {
#ifdef _WIN32
- menu->widget=gtk_ui_manager_get_widget(menu->gui->ui_manager, menu->path );
+ menu->widget=gtk_ui_manager_get_widget(menu->gui->ui_manager, menu->path );
#endif
- gtk_menu_popup(GTK_MENU(menu->widget), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
- menu->handler_id=g_signal_connect(menu->widget, "selection-done", G_CALLBACK(popup_deactivate), menu);
+ gtk_menu_popup(GTK_MENU(menu->widget), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
+ menu->handler_id=g_signal_connect(menu->widget, "selection-done", G_CALLBACK(popup_deactivate), menu);
}
-void
-gui_gtk_ui_init(struct gui_priv *this)
-{
- GError *error = NULL;
- struct attr attr;
- GtkToggleAction *toggle_action;
-
- this->base_group = gtk_action_group_new ("BaseActions");
- this->debug_group = gtk_action_group_new ("DebugActions");
- this->dyn_group = gtk_action_group_new ("DynamicActions");
- register_my_stock_icons();
- this->ui_manager = gtk_ui_manager_new ();
- gtk_action_group_set_translation_domain(this->base_group,"navit");
- gtk_action_group_set_translation_domain(this->debug_group,"navit");
- gtk_action_group_set_translation_domain(this->dyn_group,"navit");
- gtk_action_group_add_actions (this->base_group, entries, n_entries, this);
- gtk_action_group_add_toggle_actions (this->base_group, toggleentries, n_toggleentries, this);
- gtk_ui_manager_insert_action_group (this->ui_manager, this->base_group, 0);
- gtk_action_group_add_actions (this->debug_group, debug_entries, n_debug_entries, this);
- gtk_ui_manager_insert_action_group (this->ui_manager, this->debug_group, 0);
- gtk_ui_manager_add_ui_from_string (this->ui_manager, layout, strlen(layout), &error);
- gtk_ui_manager_insert_action_group (this->ui_manager, this->dyn_group, 0);
- if (error) {
- g_message ("building menus failed: %s", error->message);
- g_error_free (error);
- }
- if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- }
- if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num != -1);
- }
- if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- }
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "RoadbookAction"));
- gtk_toggle_action_set_active(toggle_action, 0);
-
- if (navit_get_attr(this->nav, attr_autozoom_active, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "AutozoomAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- }
+void gui_gtk_ui_init(struct gui_priv *this) {
+ GError *error = NULL;
+ struct attr attr;
+ GtkToggleAction *toggle_action;
+
+ this->base_group = gtk_action_group_new ("BaseActions");
+ this->debug_group = gtk_action_group_new ("DebugActions");
+ this->dyn_group = gtk_action_group_new ("DynamicActions");
+ register_my_stock_icons();
+ this->ui_manager = gtk_ui_manager_new ();
+ gtk_action_group_set_translation_domain(this->base_group,"navit");
+ gtk_action_group_set_translation_domain(this->debug_group,"navit");
+ gtk_action_group_set_translation_domain(this->dyn_group,"navit");
+ gtk_action_group_add_actions (this->base_group, entries, n_entries, this);
+ gtk_action_group_add_toggle_actions (this->base_group, toggleentries, n_toggleentries, this);
+ gtk_ui_manager_insert_action_group (this->ui_manager, this->base_group, 0);
+ gtk_action_group_add_actions (this->debug_group, debug_entries, n_debug_entries, this);
+ gtk_ui_manager_insert_action_group (this->ui_manager, this->debug_group, 0);
+ gtk_ui_manager_add_ui_from_string (this->ui_manager, layout, strlen(layout), &error);
+ gtk_ui_manager_insert_action_group (this->ui_manager, this->dyn_group, 0);
+ if (error) {
+ g_message ("building menus failed: %s", error->message);
+ g_error_free (error);
+ }
+ if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
+ if (navit_get_attr(this->nav, attr_follow_cursor, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "FollowVehicleAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
+ if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num != -1);
+ }
+ if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "RoadbookAction"));
+ gtk_toggle_action_set_active(toggle_action, 0);
+
+ if (navit_get_attr(this->nav, attr_autozoom_active, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "AutozoomAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ }
}
-static struct menu_priv *
-gui_gtk_ui_new (struct gui_priv *this, struct menu_methods *meth, char *path, int popup, GtkWidget **widget_ret)
-{
- struct menu_priv *ret;
- GtkWidget *widget;
-
- *meth=menu_methods;
- ret=g_new0(struct menu_priv, 1);
- ret->path=g_strdup(path);
- ret->gui=this;
-
- widget=gtk_ui_manager_get_widget(this->ui_manager, path);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
- if (widget_ret)
- *widget_ret=widget;
- if (! popup) {
- gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
- } else {
- ret->widget=widget;
- meth->popup=popup_activate;
- }
- return ret;
+static struct menu_priv *gui_gtk_ui_new (struct gui_priv *this, struct menu_methods *meth, char *path, int popup,
+ GtkWidget **widget_ret) {
+ struct menu_priv *ret;
+ GtkWidget *widget;
+
+ *meth=menu_methods;
+ ret=g_new0(struct menu_priv, 1);
+ ret->path=g_strdup(path);
+ ret->gui=this;
+
+ widget=gtk_ui_manager_get_widget(this->ui_manager, path);
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ if (widget_ret)
+ *widget_ret=widget;
+ if (! popup) {
+ gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ } else {
+ ret->widget=widget;
+ meth->popup=popup_activate;
+ }
+ return ret;
}
#if 0
struct menu_priv *
-gui_gtk_menubar_new(struct gui_priv *this, struct menu_methods *meth)
-{
- return gui_gtk_ui_new(this, meth, "/ui/MenuBar", 0, &this->menubar);
+gui_gtk_menubar_new(struct gui_priv *this, struct menu_methods *meth) {
+ return gui_gtk_ui_new(this, meth, "/ui/MenuBar", 0, &this->menubar);
}
#endif
struct menu_priv *
-gui_gtk_popup_new(struct gui_priv *this, struct menu_methods *meth)
-{
- return gui_gtk_ui_new(this, meth, "/ui/PopUp", 1, NULL);
+gui_gtk_popup_new(struct gui_priv *this, struct menu_methods *meth) {
+ return gui_gtk_ui_new(this, meth, "/ui/PopUp", 1, NULL);
}
diff --git a/navit/gui/gtk/gui_gtk_poi.c b/navit/gui/gtk/gui_gtk_poi.c
index a3578243b..265f1f28e 100644
--- a/navit/gui/gtk/gui_gtk_poi.c
+++ b/navit/gui/gtk/gui_gtk_poi.c
@@ -35,328 +35,413 @@
#include "attr.h"
#include "util.h"
-static struct gtk_poi_search{
- GtkWidget *entry_distance;
- GtkWidget *label_distance;
- GtkWidget *treeview_cat;
- GtkWidget *treeview_poi;
- GtkWidget *button_visit, *button_destination, *button_map;
- GtkListStore *store_poi;
- GtkListStore *store_cat;
- GtkTreeModel *store_poi_sorted;
- GtkTreeModel *store_cat_sorted;
- char *selected_cat;
- struct navit *nav;
+#include "navigation.h" /* for FEET_PER_METER and other conversion factors. */
+
+/**
+ * @brief Context passed around POI search function
+ */
+static struct gtk_poi_search {
+ GtkWidget *entry_distance;
+ GtkWidget *label_distance;
+ GtkWidget *treeview_cat;
+ GtkWidget *treeview_poi;
+ GtkWidget *button_visit, *button_destination, *button_map;
+ GtkListStore *store_poi;
+ GtkListStore *store_cat;
+ GtkTreeModel *store_poi_sorted;
+ GtkTreeModel *store_cat_sorted;
+ char *selected_cat;
+ struct navit *nav;
} gtk_poi_search;
-static GdkPixbuf *
-geticon(const char *name){
- GdkPixbuf *icon=NULL;
- GError *error=NULL;
- icon=gdk_pixbuf_new_from_file(graphics_icon_path(name),&error);
- if (error) {
- dbg(lvl_error, "failed to load icon '%s': %s\n", name, error->message);
- }
- return icon;
+/**
+ * @brief Get a pixbuf representing an icon for the catalog
+ *
+ * @param name The name of the icon to use (eg: "pharmacy.png"
+ * @return A pixbuf containing this icon of NULL if the icon could not be loaded
+ */
+static GdkPixbuf *geticon(const char *name) {
+ GdkPixbuf *icon=NULL;
+ GError *error=NULL;
+ icon=gdk_pixbuf_new_from_file(graphics_icon_path(name),&error);
+ if (error) {
+ dbg(lvl_error, "failed to load icon '%s': %s", name, error->message);
+ }
+ return icon;
}
/** Build the category list model with icons. */
-static GtkTreeModel *
-category_list_model(struct gtk_poi_search *search)
-{
- GtkTreeIter iter;
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter, 0,geticon("pharmacy.png"), 1, _("Pharmacy"), 2, "poi_pharmacy", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter, 0, geticon("restaurant.png"), 1, _("Restaurant"), 2, "poi_restaurant", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("restaurant.png"), 1, _("Restaurant. Fast food"), 2, "poi_fastfood", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("hotel.png"), 1, _("Hotel"), 2, "poi_hotel", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("parking.png"), 1, _("Car parking"), 2, "poi_car_parking", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("fuel.png"), 1, _("Fuel station"), 2, "poi_fuel", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("bank.png"), 1, _("Bank"), 2, "poi_bank", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("hospital.png"), 1, _("Hospital"), 2, "poi_hospital", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("cinema.png"), 1, _("Cinema"), 2, "poi_cinema", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("rail_station.png"), 1, _("Train station"), 2, "poi_rail_station", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("school.png"), 1, _("School"), 2, "poi_school", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("police.png"), 1, _("Police"), 2, "poi_police", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("justice.png"), 1, _("Justice"), 2, "poi_justice", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("taxi.png"), 1, _("Taxi"), 2, "poi_taxi", -1);
- gtk_list_store_append(search->store_cat, &iter);
- gtk_list_store_set(search->store_cat, &iter,0, geticon("shopping.png"), 1, _("Shopping"), 2, "poi_shopping", -1);
- return GTK_TREE_MODEL (search->store_cat_sorted);
+static GtkTreeModel *category_list_model(struct gtk_poi_search *search) {
+ GtkTreeIter iter;
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter, 0,geticon("pharmacy.png"), 1, _("Pharmacy"), 2, "poi_pharmacy", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter, 0, geticon("restaurant.png"), 1, _("Restaurant"), 2, "poi_restaurant", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("restaurant.png"), 1, _("Restaurant. Fast food"), 2,
+ "poi_fastfood", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("hotel.png"), 1, _("Hotel"), 2, "poi_hotel", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("parking.png"), 1, _("Car parking"), 2, "poi_car_parking", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("fuel.png"), 1, _("Fuel station"), 2, "poi_fuel", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("bank.png"), 1, _("Bank"), 2, "poi_bank", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("hospital.png"), 1, _("Hospital"), 2, "poi_hospital", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("cinema.png"), 1, _("Cinema"), 2, "poi_cinema", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("rail_station.png"), 1, _("Train station"), 2,
+ "poi_rail_station", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("school.png"), 1, _("School"), 2, "poi_school", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("police.png"), 1, _("Police"), 2, "poi_police", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("justice.png"), 1, _("Justice"), 2, "poi_justice", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("taxi.png"), 1, _("Taxi"), 2, "poi_taxi", -1);
+ gtk_list_store_append(search->store_cat, &iter);
+ gtk_list_store_set(search->store_cat, &iter,0, geticon("shopping.png"), 1, _("Shopping"), 2, "poi_shopping", -1);
+ return GTK_TREE_MODEL (search->store_cat_sorted);
}
/** Construct model of POIs from map information. */
-static GtkTreeModel *
-model_poi (struct gtk_poi_search *search)
-{
- GtkTreeIter iter;
- struct map_selection *sel,*selm;
- struct coord coord_item,center;
- struct pcoord pc;
- struct mapset_handle *h;
- int search_distance_meters,idist;
- struct map *m;
- struct map_rect *mr;
- struct item *item;
- struct point cursor_position;
- enum item_type selected;
-
- search_distance_meters=1000*atoi((char *) gtk_entry_get_text(GTK_ENTRY(search->entry_distance)));
-
- cursor_position.x=navit_get_width(search->nav)/2;
- cursor_position.y=navit_get_height(search->nav)/2;
- gtk_label_set_text(GTK_LABEL(search->label_distance),_("Distance from screen center (km)"));
-
- transform_reverse(navit_get_trans(search->nav), &cursor_position, &center);
- pc.pro = transform_get_projection(navit_get_trans(search->nav));
- pc.x = center.x;
- pc.y = center.y;
-
- //Search in the map, for pois
- sel=map_selection_rect_new(&pc ,search_distance_meters*transform_scale(abs(center.y)+search_distance_meters*1.5),18);
- gtk_list_store_clear(search->store_poi);
-
- h=mapset_open(navit_get_mapset(search->nav));
-
- selected=item_from_name(search->selected_cat);
- while ((m=mapset_next(h, 1))) {
- selm=map_selection_dup_pro(sel, projection_mg, map_projection(m));
- mr=map_rect_new(m, selm);
- if (mr) {
- while ((item=map_rect_get_item(mr))) {
- struct attr label_attr;
- item_attr_get(item,attr_label,&label_attr);
- item_coord_get(item,&coord_item,1);
- idist=transform_distance(1,&center,&coord_item);
- if (item->type==selected && idist<=search_distance_meters){
- char direction[5];
- gtk_list_store_append(search->store_poi, &iter);
- get_compass_direction(direction,transform_get_angle_delta(&center,&coord_item,0),1);
- gtk_list_store_set(search->store_poi, &iter, 0,direction, 1,idist,
- 2,g_strdup(label_attr.u.str), 3,coord_item.x, 4,coord_item.y ,-1);
- }
- }
- map_rect_destroy(mr);
- }
- map_selection_destroy(selm);
- }
- map_selection_destroy(sel);
- mapset_close(h);
-
- return GTK_TREE_MODEL (search->store_poi_sorted);
+static GtkTreeModel *model_poi (struct gtk_poi_search *search) {
+ GtkTreeIter iter;
+ struct map_selection *sel,*selm;
+ struct coord coord_item,center;
+ struct pcoord pc;
+ struct mapset_handle *h;
+ int search_distance_meters; /* distance to search the POI database, in meters, from the center of the screen. */
+ int idist; /* idist appears to be the distance in meters from the center of the screen to a POI. */
+ struct map *m;
+ struct map_rect *mr;
+ struct item *item;
+ struct point cursor_position;
+ enum item_type selected;
+
+ /* Respect the Imperial attribute as we enlighten the user. */
+ struct attr attr;
+ int imperial = FALSE; /* default to using metric measures. */
+ if (navit_get_attr(gtk_poi_search.nav, attr_imperial, &attr, NULL))
+ imperial=attr.u.num;
+
+ if (imperial == FALSE) {
+ /* Input is in kilometers */
+ search_distance_meters=1000*atoi((char *) gtk_entry_get_text(GTK_ENTRY(search->entry_distance)));
+ gtk_label_set_text(GTK_LABEL(search->label_distance),_("Select a search radius from screen center in km"));
+ } else {
+ /* Input is in miles. */
+ search_distance_meters=atoi((char *) gtk_entry_get_text(GTK_ENTRY(search->entry_distance)))/METERS_TO_MILES;
+ gtk_label_set_text(GTK_LABEL(search->label_distance),_("Select a search radius from screen center in miles"));
+ }
+
+ cursor_position.x=navit_get_width(search->nav)/2;
+ cursor_position.y=navit_get_height(search->nav)/2;
+
+ transform_reverse(navit_get_trans(search->nav), &cursor_position, &center);
+ pc.pro = transform_get_projection(navit_get_trans(search->nav));
+ pc.x = center.x;
+ pc.y = center.y;
+
+ //Search in the map, for pois
+ sel=map_selection_rect_new(&pc,search_distance_meters*transform_scale(abs(center.y)+search_distance_meters*1.5),18);
+ gtk_list_store_clear(search->store_poi);
+
+ h=mapset_open(navit_get_mapset(search->nav));
+
+ selected=item_from_name(search->selected_cat);
+ while ((m=mapset_next(h, 1))) {
+ selm=map_selection_dup_pro(sel, projection_mg, map_projection(m));
+ mr=map_rect_new(m, selm);
+ if (mr) {
+ while ((item=map_rect_get_item(mr))) {
+ struct attr label_attr;
+ item_attr_get(item,attr_label,&label_attr);
+ item_coord_get(item,&coord_item,1);
+ idist=transform_distance(1,&center,&coord_item);
+ if (item->type==selected && idist<=search_distance_meters) {
+ char direction[5];
+ gtk_list_store_append(search->store_poi, &iter);
+ get_compass_direction(direction,transform_get_angle_delta(&center,&coord_item,0),1);
+
+ /**
+ * If the user has selected imperial, translate idist from meters to
+ * feet. We convert to feet only, and not miles, because the code
+ * sorts on the numeric value of the distance, so it doesn't like two
+ * different units. Currently, the distance is an int. Can it be made
+ * a float? Possible future enhancement?
+ */
+ if (imperial != FALSE) {
+ idist = idist * (FEET_PER_METER); /* convert meters to feet. */
+ }
+
+ gtk_list_store_set(search->store_poi, &iter, 0,direction, 1,idist,
+ 2,g_strdup(label_attr.u.str), 3,coord_item.x, 4,coord_item.y,-1);
+ }
+ }
+ map_rect_destroy(mr);
+ }
+ map_selection_destroy(selm);
+ }
+ map_selection_destroy(sel);
+ mapset_close(h);
+
+ return GTK_TREE_MODEL (search->store_poi_sorted);
}
/** Enable button if there is a selected row. */
-static void
-treeview_poi_changed(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
-
- gtk_widget_set_sensitive(search->button_visit,TRUE);
- gtk_widget_set_sensitive(search->button_map,TRUE);
- gtk_widget_set_sensitive(search->button_destination,TRUE);
+static void treeview_poi_changed(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
+
+ gtk_widget_set_sensitive(search->button_visit,TRUE);
+ gtk_widget_set_sensitive(search->button_map,TRUE);
+ gtk_widget_set_sensitive(search->button_destination,TRUE);
}
/** Reload the POI list and disable buttons. */
-static void
-treeview_poi_reload(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
-
- gtk_widget_set_sensitive(search->button_visit,FALSE);
- gtk_widget_set_sensitive(search->button_map,FALSE);
- gtk_widget_set_sensitive(search->button_destination,FALSE);
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_cat_sorted), &iter, 2, &search->selected_cat, -1);
- gtk_tree_view_set_model(GTK_TREE_VIEW (search->treeview_poi), model_poi(search));
+static void treeview_poi_reload(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+
+ gtk_widget_set_sensitive(search->button_visit,FALSE);
+ gtk_widget_set_sensitive(search->button_map,FALSE);
+ gtk_widget_set_sensitive(search->button_destination,FALSE);
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_cat_sorted), &iter, 2, &search->selected_cat, -1);
+ gtk_tree_view_set_model(GTK_TREE_VIEW (search->treeview_poi), model_poi(search));
}
-/** Set the selected POI as destination. */
-static void
-button_destination_clicked(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
- long int lat, lon;
- char *label;
- char *category;
- char buffer[2000];
-
- //Get category
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_cat_sorted), &iter, 1, &category, -1);
-
- //Get label, lat, lon
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 2, &label, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
- sprintf(buffer, _("POI %s. %s"), category, label);
-
- struct pcoord dest;
- dest.x=lat;
- dest.y=lon;
- dest.pro=1;
- navit_set_destination(search->nav, &dest, buffer, 1);
- dbg(lvl_debug,_("Set destination to %ld, %ld \n"),lat,lon);
+/**
+ * @brief Callback invoked when 'Destination' is clicked in a POI contextual window
+ *
+ * Set the selected POI as destination
+ *
+ * @param widget The widget that has been clicked
+ * @param search A pointer to private data containing the POI search context
+ */
+static void button_destination_clicked(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+ long int lat, lon;
+ char *label;
+ char *category;
+ char buffer[2000];
+
+ //Get category
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_cat), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_cat_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_cat_sorted), &iter, 1, &category, -1);
+
+ //Get label, lat, lon
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 2, &label, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
+ sprintf(buffer, _("POI %s. %s"), category, label);
+ navit_populate_search_results_map(search->nav, NULL, NULL); /* Remove any highlighted point on the map */
+
+ struct pcoord dest;
+ dest.x=lat;
+ dest.y=lon;
+ dest.pro=1;
+ navit_set_destination(search->nav, &dest, buffer, 1);
+ dbg(lvl_debug,_("Set destination to %ld, %ld "),lat,lon);
}
-/* Show the POI's position in the map. */
-static void
-button_map_clicked(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
- long int lat,lon;
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
-
- struct pcoord dest;
- dest.x=lat;
- dest.y=lon;
- dest.pro=1;
- navit_set_center(search->nav, &dest,1);
- dbg(lvl_debug,_("Set map to %ld, %ld \n"),lat,lon);
+/**
+ * @brief Callback invoked when 'Map' is clicked in a POI contextual window
+ *
+ * Show the POI's position in the map
+ *
+ * @param widget The widget that has been clicked
+ * @param search A pointer to private data containing the POI search context
+ */
+static void button_map_clicked(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+ long int lat,lon;
+ char *label;
+ GList* p;
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 2, &label, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
+
+ struct pcoord point; /* The geographical position of the selected POI point */
+ point.x=lat;
+ point.y=lon;
+ point.pro=1;
+ GList* list = NULL;
+ struct lcoord *result = g_new0(struct lcoord, 1);
+ result->c.x=lat;
+ result->c.y=lon;
+ result->label=g_strdup(label);
+ list = g_list_prepend(list, result);
+ navit_populate_search_results_map(search->nav, list, NULL);
+ /* Parse the GList starting at list and free all payloads before freeing the list itself */
+ for(p=list; p; p=g_list_next(p)) {
+ if (((struct lcoord *)(p->data))->label)
+ g_free(((struct lcoord *)(p->data))->label);
+ }
+ g_list_free(list);
+ navit_set_center(search->nav, &point,1);
+ dbg(lvl_debug,_("Set map to %ld, %ld "),lat,lon);
}
-/** Set POI as the first "visit before". */
-static void
-button_visit_clicked(GtkWidget *widget, struct gtk_poi_search *search)
-{
- GtkTreePath *path;
- GtkTreeViewColumn *focus_column;
- GtkTreeIter iter;
- long int lat,lon;
-
- gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
- if(!path) return;
- if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
- gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
- dbg(lvl_debug,_("Set next visit to %ld, %ld \n"),lat,lon);
-
- struct pcoord dest;
- dest.x=lat;
- dest.y=lon;
- dest.pro=1;
- popup_set_visitbefore(search->nav,&dest,0);
+/**
+ * @brief Callback invoked when 'Visit before' is clicked in a POI contextual window
+ *
+ * Set POI as a waypoint to visit before an existing destination
+ *
+ * @param widget The widget that has been clicked
+ * @param search A pointer to private data containing the POI search context
+ */
+static void button_visit_clicked(GtkWidget *widget, struct gtk_poi_search *search) {
+ GtkTreePath *path;
+ GtkTreeViewColumn *focus_column;
+ GtkTreeIter iter;
+ long int lat,lon;
+
+ gtk_tree_view_get_cursor(GTK_TREE_VIEW(search->treeview_poi), &path, &focus_column);
+ if(!path) return;
+ if(!gtk_tree_model_get_iter(GTK_TREE_MODEL(search->store_poi_sorted), &iter, path)) return;
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 3, &lat, -1);
+ gtk_tree_model_get(GTK_TREE_MODEL(search->store_poi_sorted), &iter, 4, &lon, -1);
+ dbg(lvl_debug,_("Set next visit to %ld, %ld "),lat,lon);
+ navit_populate_search_results_map(search->nav, NULL, NULL); /* Remove any highlighted point on the map */
+
+ struct pcoord dest;
+ dest.x=lat;
+ dest.y=lon;
+ dest.pro=1;
+ popup_set_visitbefore(search->nav,&dest,0);
}
-/** Create UI and connect objects to functions. */
-void gtk_gui_poi(struct navit *nav)
-{
- GtkWidget *window2,*vbox, *keyboard, *table;
- GtkWidget *label_category, *label_poi;
- GtkWidget *listbox_cat, *listbox_poi;
- GtkCellRenderer *renderer;
-
- struct gtk_poi_search *search=&gtk_poi_search;
- search->nav=nav;
-
- window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window2),_("POI search"));
- gtk_window_set_wmclass (GTK_WINDOW (window2), "navit", "Navit");
- gtk_window_set_default_size (GTK_WINDOW (window2),700,550);
- vbox = gtk_vbox_new(FALSE, 0);
- table = gtk_table_new(4, 4, FALSE);
-
- label_category = gtk_label_new(_("Select a category"));
- search->label_distance = gtk_label_new(_("Select a distance to look for (km)"));
- label_poi=gtk_label_new(_("Select a POI"));
-
- search->entry_distance=gtk_entry_new_with_max_length(2);
- gtk_entry_set_text(GTK_ENTRY(search->entry_distance),"10");
-
- search->treeview_cat=gtk_tree_view_new();
- listbox_cat = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (listbox_cat), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(listbox_cat),search->treeview_cat);
- search->store_cat = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
- renderer=gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_cat),-1, _(" "), renderer, "pixbuf", 0, NULL);
- renderer=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_cat),-1, _("Category"), renderer, "text", 1, NULL);
- search->store_cat_sorted=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->store_cat));
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(search->store_cat_sorted),1,GTK_SORT_ASCENDING);
- gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview_cat), category_list_model(search));
-
- search->treeview_poi=gtk_tree_view_new();
- listbox_poi = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (listbox_poi), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(listbox_poi),search->treeview_poi);
- search->store_poi = gtk_list_store_new (5, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG);
- renderer=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Direction"), renderer, "text",0,NULL);
- renderer=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Distance(m)"), renderer, "text", 1, NULL);
- renderer=gtk_cell_renderer_text_new();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Name"), renderer, "text", 2, NULL);
- search->store_poi_sorted=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->store_poi));
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(search->store_poi_sorted),1,GTK_SORT_ASCENDING);
-
- search->button_visit = gtk_button_new_with_label(_("Visit Before"));
- search->button_destination = gtk_button_new_with_label(_("Destination"));
- search->button_map = gtk_button_new_with_label(_("Map"));
- gtk_widget_set_sensitive(search->button_visit,FALSE);
- gtk_widget_set_sensitive(search->button_map,FALSE);
- gtk_widget_set_sensitive(search->button_destination,FALSE);
-
- gtk_table_attach(GTK_TABLE(table), search->label_distance, 0, 1, 0, 1, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->entry_distance, 1, 2, 0, 1, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_category, 0, 1, 2, 3, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), listbox_cat, 0, 1, 3, 4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
- gtk_table_attach(GTK_TABLE(table), label_poi, 1, 4, 2, 3, 0, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), listbox_poi, 1, 4, 3, 4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->button_map, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->button_visit, 1, 2, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(table), search->button_destination, 2, 3, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
- gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
-
- g_signal_connect(G_OBJECT(search->entry_distance), "changed", G_CALLBACK(treeview_poi_reload), search);
- g_signal_connect(G_OBJECT(search->button_visit), "clicked", G_CALLBACK(button_visit_clicked), search);
- g_signal_connect(G_OBJECT(search->button_map), "clicked", G_CALLBACK(button_map_clicked), search);
- g_signal_connect(G_OBJECT(search->button_destination), "clicked", G_CALLBACK(button_destination_clicked), search);
- g_signal_connect(G_OBJECT(search->treeview_cat), "cursor_changed", G_CALLBACK(treeview_poi_reload), search);
- g_signal_connect(G_OBJECT(search->treeview_poi), "cursor_changed", G_CALLBACK(treeview_poi_changed), search);
-
- keyboard=gtk_socket_new();
- gtk_box_pack_end(GTK_BOX(vbox), keyboard, FALSE, FALSE, 0);
- gtk_container_add(GTK_CONTAINER(window2), vbox);
- gtk_widget_show_all(window2);
+/**
+ * @brief Create the POI search UI window and connect objects to functions
+ *
+ * @param nav The navit instance
+ */
+void gtk_gui_poi(struct navit *nav) {
+ GtkWidget *window2,*vbox, *keyboard, *table;
+ GtkWidget *label_category, *label_poi;
+ GtkWidget *listbox_cat, *listbox_poi;
+ GtkCellRenderer *renderer;
+
+ struct gtk_poi_search *search=&gtk_poi_search;
+ search->nav=nav;
+
+ navit_populate_search_results_map(search->nav, NULL, NULL); /* Remove any highlighted point on the map */
+ window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window2),_("POI search"));
+ gtk_window_set_wmclass (GTK_WINDOW (window2), "navit", "Navit");
+ gtk_window_set_default_size (GTK_WINDOW (window2),700,550);
+ vbox = gtk_vbox_new(FALSE, 0);
+ table = gtk_table_new(4, 4, FALSE);
+
+ label_category = gtk_label_new(_("Select a category"));
+ label_poi=gtk_label_new(_("Select a POI"));
+
+ /* Respect the Imperial attribute as we enlighten the user. */
+ struct attr attr;
+ int imperial = FALSE; /* default to using metric measures. */
+ if (navit_get_attr(gtk_poi_search.nav, attr_imperial, &attr, NULL))
+ imperial=attr.u.num;
+
+ if (imperial == FALSE) {
+ /* Input is in kilometers */
+ search->label_distance = gtk_label_new(_("Select a search radius from screen center in km"));
+ } else {
+ /* Input is in miles. */
+ search->label_distance = gtk_label_new(_("Select a search radius from screen center in miles"));
+ }
+
+ search->entry_distance=gtk_entry_new_with_max_length(2);
+ gtk_entry_set_text(GTK_ENTRY(search->entry_distance),"10");
+
+ search->treeview_cat=gtk_tree_view_new();
+ listbox_cat = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (listbox_cat), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(listbox_cat),search->treeview_cat);
+ search->store_cat = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
+ renderer=gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_cat),-1, _(" "), renderer, "pixbuf", 0,
+ NULL);
+ renderer=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_cat),-1, _("Category"), renderer, "text",
+ 1, NULL);
+ search->store_cat_sorted=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->store_cat));
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(search->store_cat_sorted),1,GTK_SORT_ASCENDING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (search->treeview_cat), category_list_model(search));
+
+ search->treeview_poi=gtk_tree_view_new();
+ listbox_poi = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (listbox_poi), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(listbox_poi),search->treeview_poi);
+ search->store_poi = gtk_list_store_new (5, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG);
+ renderer=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Direction"), renderer, "text",
+ 0,NULL);
+ renderer=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Distance"), renderer, "text",
+ 1, NULL);
+ renderer=gtk_cell_renderer_text_new();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (search->treeview_poi),-1, _("Name"), renderer, "text", 2,
+ NULL);
+ search->store_poi_sorted=gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(search->store_poi));
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(search->store_poi_sorted),1,GTK_SORT_ASCENDING);
+
+ search->button_visit = gtk_button_new_with_label(_("Visit Before"));
+ search->button_destination = gtk_button_new_with_label(_("Destination"));
+ search->button_map = gtk_button_new_with_label(_("Map"));
+ gtk_widget_set_sensitive(search->button_visit,FALSE);
+ gtk_widget_set_sensitive(search->button_map,FALSE);
+ gtk_widget_set_sensitive(search->button_destination,FALSE);
+
+ gtk_table_attach(GTK_TABLE(table), search->label_distance, 0, 1, 0, 1, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->entry_distance, 1, 2, 0, 1, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_category, 0, 1, 2, 3, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), listbox_cat, 0, 1, 3, 4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), label_poi, 1, 4, 2, 3, 0, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), listbox_poi, 1, 4, 3, 4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->button_map, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->button_visit, 1, 2, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), search->button_destination, 2, 3, 4, 5, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+
+ g_signal_connect(G_OBJECT(search->entry_distance), "changed", G_CALLBACK(treeview_poi_reload), search);
+ g_signal_connect(G_OBJECT(search->button_visit), "clicked", G_CALLBACK(button_visit_clicked), search);
+ g_signal_connect(G_OBJECT(search->button_map), "clicked", G_CALLBACK(button_map_clicked), search);
+ g_signal_connect(G_OBJECT(search->button_destination), "clicked", G_CALLBACK(button_destination_clicked), search);
+ g_signal_connect(G_OBJECT(search->treeview_cat), "cursor_changed", G_CALLBACK(treeview_poi_reload), search);
+ g_signal_connect(G_OBJECT(search->treeview_poi), "cursor_changed", G_CALLBACK(treeview_poi_changed), search);
+
+ keyboard=gtk_socket_new();
+ gtk_box_pack_end(GTK_BOX(vbox), keyboard, FALSE, FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(window2), vbox);
+ gtk_widget_show_all(window2);
}
diff --git a/navit/gui/gtk/gui_gtk_statusbar.c b/navit/gui/gtk/gui_gtk_statusbar.c
index aa70c6332..f245312d1 100644
--- a/navit/gui/gtk/gui_gtk_statusbar.c
+++ b/navit/gui/gtk/gui_gtk_statusbar.c
@@ -36,161 +36,158 @@
#include "navit_nls.h"
struct statusbar_priv {
- struct gui_priv *gui;
- GtkWidget *hbox;
- char gps_text[128];
- GtkWidget *gps;
- char route_text[128];
- GtkWidget *route;
- struct callback *vehicle_cb;
+ struct gui_priv *gui;
+ GtkWidget *hbox;
+ char gps_text[128];
+ GtkWidget *gps;
+ char route_text[128];
+ GtkWidget *route;
+ struct callback *vehicle_cb;
};
#if 0
-static void
-statusbar_destroy(struct statusbar_priv *this)
-{
- g_free(this);
+static void statusbar_destroy(struct statusbar_priv *this) {
+ g_free(this);
}
-static void
-statusbar_gps_update(struct statusbar_priv *this, int sats, int qual, double lng, double lat, double height, double direction, double speed)
-{
- char *dirs[]={_("N"),_("NE"),_("E"),_("SE"),_("S"),_("SW"),_("W"),_("NW"),_("N")};
- char *dir;
- int dir_idx;
- char pos_text[36];
+static void statusbar_gps_update(struct statusbar_priv *this, int sats, int qual, double lng, double lat, double height,
+ double direction, double speed) {
+ char *dirs[]= {_("N"),_("NE"),_("E"),_("SE"),_("S"),_("SW"),_("W"),_("NW"),_("N")};
+ char *dir;
+ int dir_idx;
+ char pos_text[36];
- coord_format(lat,lng,DEGREES_MINUTES_SECONDS,pos_text,sizeof(pos_text));
- dir=dirs[dir_idx];
- sprintf(this->gps_text, "GPS %02d/%02d %s %4.0fm %3.0f°%-2s %3.0fkm/h", sats, qual, pos_text, height, direction, dir, speed);
- gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
+ coord_format(lat,lng,DEGREES_MINUTES_SECONDS,pos_text,sizeof(pos_text));
+ dir=dirs[dir_idx];
+ sprintf(this->gps_text, "GPS %02d/%02d %s %4.0fm %3.0f°%-2s %3.0fkm/h", sats, qual, pos_text, height, direction, dir,
+ speed);
+ gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
}
#endif
-static const char *status_fix2str(int type)
-{
- switch(type) {
- case 0: return _("No");
- case 1: return _("2D");
- case 3: return _("3D");
- default:
- return _("OT");
- }
+static const char *status_fix2str(int type) {
+ switch(type) {
+ case 0:
+ return _("No");
+ case 1:
+ return _("2D");
+ case 3:
+ return _("3D");
+ default:
+ return _("OT");
+ }
}
-static void
-statusbar_route_update(struct statusbar_priv *this, struct navit *navit, struct vehicle *v)
-{
- struct navigation *nav=NULL;
- struct map *map=NULL;
- struct map_rect *mr=NULL;
- struct item *item=NULL;
- struct attr attr;
- double route_len=0;
- time_t eta;
- struct tm *eta_tm=NULL;
- char buffer[128];
- double lng, lat, direction=0, height=0, speed=0, hdop=0;
- int sats=0, qual=0;
- int status=0;
- const char *dirs[]={_("N"),_("NE"),_("E"),_("SE"),_("S"),_("SW"),_("W"),_("NW"),_("N")};
- const char *dir;
- int dir_idx;
-
- /* Respect the Imperial attribute as we enlighten the user. */
- int imperial = FALSE; /* default to using metric measures. */
- if (navit_get_attr(navit, attr_imperial, &attr, NULL))
- imperial=attr.u.num;
-
- if (navit)
- nav=navit_get_navigation(navit);
- if (nav)
- map=navigation_get_map(nav);
- if (map)
- mr=map_rect_new(map, NULL);
- if (mr)
- item=map_rect_get_item(mr);
- if (item) {
- if (item_attr_get(item, attr_destination_length, &attr))
- route_len=attr.u.num;
- if (item_attr_get(item, attr_destination_time, &attr)) {
- eta=time(NULL)+attr.u.num/10;
- eta_tm=localtime(&eta);
- }
- }
- if (mr)
- map_rect_destroy(mr);
-
- sprintf(buffer,_("Route %4.1f%s %02d:%02d ETA" ),
- imperial == TRUE ? route_len / METERS_PER_MILE : route_len/1000,
- imperial == TRUE ? "mi" : "km",
- eta_tm ? eta_tm->tm_hour : 0 ,
- eta_tm ? eta_tm->tm_min : 0);
-
- if (strcmp(buffer, this->route_text)) {
- strcpy(this->route_text, buffer);
- gtk_label_set_text(GTK_LABEL(this->route), this->route_text);
- }
- if (!vehicle_get_attr(v, attr_position_coord_geo, &attr, NULL))
- return;
- lng=attr.u.coord_geo->lng;
- lat=attr.u.coord_geo->lat;
- if (vehicle_get_attr(v, attr_position_fix_type, &attr, NULL))
- status=attr.u.num;
- if (vehicle_get_attr(v, attr_position_direction, &attr, NULL))
- direction=*(attr.u.numd);
- direction=fmod(direction,360);
- if (direction < 0)
- direction+=360;
- dir_idx=(direction+22.5)/45;
- dir=dirs[dir_idx];
- if (vehicle_get_attr(v, attr_position_height, &attr, NULL))
- height=*(attr.u.numd);
- if (vehicle_get_attr(v, attr_position_hdop, &attr, NULL))
- hdop=*(attr.u.numd);
- if (vehicle_get_attr(v, attr_position_speed, &attr, NULL))
- speed=*(attr.u.numd);
- if (vehicle_get_attr(v, attr_position_sats_used, &attr, NULL))
- sats=attr.u.num;
- if (vehicle_get_attr(v, attr_position_qual, &attr, NULL))
- qual=attr.u.num;
- coord_format(lat,lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
-
- sprintf(this->gps_text,"GPS:%s %02d/%02d HD:%02.2f %s %4.0f%s %3.0f°%-2s %3.1f%s",
- status_fix2str(status),
- sats, qual, hdop, buffer,
- imperial ? height * FEET_PER_METER : height,
- imperial == TRUE ? "\'" : "m",
- direction, dir,
- imperial == TRUE ? speed / (METERS_PER_MILE / 1000) : speed, /* hard-coded. Ugly */
- imperial == TRUE ? " mph" : "km/h"
- );
-
- gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
+static void statusbar_route_update(struct statusbar_priv *this, struct navit *navit, struct vehicle *v) {
+ struct navigation *nav=NULL;
+ struct map *map=NULL;
+ struct map_rect *mr=NULL;
+ struct item *item=NULL;
+ struct attr attr;
+ double route_len=0; /* Distance to destination. We get it in kilometers. */
+ time_t eta;
+ struct tm *eta_tm=NULL;
+ char buffer[128];
+ double lng, lat, direction=0, height=0, speed=0, hdop=0;
+ int sats=0, qual=0;
+ int status=0;
+ const char *dirs[]= {_("N"),_("NE"),_("E"),_("SE"),_("S"),_("SW"),_("W"),_("NW"),_("N")};
+ const char *dir;
+ int dir_idx;
+
+ /* Respect the Imperial attribute as we enlighten the user. */
+ int imperial = FALSE; /* default to using metric measures. */
+ if (navit_get_attr(navit, attr_imperial, &attr, NULL))
+ imperial=attr.u.num;
+
+ if (navit)
+ nav=navit_get_navigation(navit);
+ if (nav)
+ map=navigation_get_map(nav);
+ if (map)
+ mr=map_rect_new(map, NULL);
+ if (mr)
+ item=map_rect_get_item(mr);
+ if (item) {
+ if (item_attr_get(item, attr_destination_length, &attr))
+ route_len=attr.u.num;
+ if (item_attr_get(item, attr_destination_time, &attr)) {
+ eta=time(NULL)+attr.u.num/10;
+ eta_tm=localtime(&eta);
+ }
+ }
+ if (mr)
+ map_rect_destroy(mr);
+
+ sprintf(buffer,_("Route %4.1f%s %02d:%02d ETA" ),
+ imperial == TRUE ? route_len * (KILOMETERS_TO_MILES/1000.00) : route_len/1000,
+ imperial == TRUE ? "mi" : "km",
+ eta_tm ? eta_tm->tm_hour : 0,
+ eta_tm ? eta_tm->tm_min : 0);
+
+ if (strcmp(buffer, this->route_text)) {
+ strcpy(this->route_text, buffer);
+ gtk_label_set_text(GTK_LABEL(this->route), this->route_text);
+ }
+ if (!vehicle_get_attr(v, attr_position_coord_geo, &attr, NULL))
+ return;
+ lng=attr.u.coord_geo->lng;
+ lat=attr.u.coord_geo->lat;
+ if (vehicle_get_attr(v, attr_position_fix_type, &attr, NULL))
+ status=attr.u.num;
+ if (vehicle_get_attr(v, attr_position_direction, &attr, NULL))
+ direction=*(attr.u.numd);
+ direction=fmod(direction,360);
+ if (direction < 0)
+ direction+=360;
+ dir_idx=(direction+22.5)/45;
+ dir=dirs[dir_idx];
+ if (vehicle_get_attr(v, attr_position_height, &attr, NULL))
+ height=*(attr.u.numd);
+ if (vehicle_get_attr(v, attr_position_hdop, &attr, NULL))
+ hdop=*(attr.u.numd);
+ if (vehicle_get_attr(v, attr_position_speed, &attr, NULL))
+ speed=*(attr.u.numd);
+ if (vehicle_get_attr(v, attr_position_sats_used, &attr, NULL))
+ sats=attr.u.num;
+ if (vehicle_get_attr(v, attr_position_qual, &attr, NULL))
+ qual=attr.u.num;
+ coord_format(lat,lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
+
+ sprintf(this->gps_text,"GPS:%s %02d/%02d HD:%02.2f %s %4.0f%s %3.0f°%-2s %3.1f%s",
+ status_fix2str(status),
+ sats, qual, hdop, buffer,
+ imperial ? height * FEET_PER_METER : height,
+ imperial == TRUE ? "\'" : "m",
+ direction, dir,
+ imperial == TRUE ? speed * KILOMETERS_TO_MILES : speed,
+ imperial == TRUE ? " mph" : "km/h"
+ );
+
+ gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
}
struct statusbar_priv *
-gui_gtk_statusbar_new(struct gui_priv *gui)
-{
- struct statusbar_priv *this=g_new0(struct statusbar_priv, 1);
-
- this->gui=gui;
- this->hbox=gtk_hbox_new(FALSE, 1);
- this->gps=gtk_label_new( "GPS 00/0 0000.0000N 00000.0000E 0000m 000°NO 000km/h" );
- gtk_label_set_justify(GTK_LABEL(this->gps), GTK_JUSTIFY_LEFT);
- this->route=gtk_label_new( _( "Route 0000km 0+00:00 ETA" ) );
- gtk_label_set_justify(GTK_LABEL(this->route), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(GTK_BOX(this->hbox), this->gps, TRUE, TRUE, 2);
- gtk_box_pack_start(GTK_BOX(this->hbox), gtk_vseparator_new(), TRUE, TRUE, 2);
- gtk_box_pack_start(GTK_BOX(this->hbox), this->route, TRUE, TRUE, 2);
- GTK_WIDGET_UNSET_FLAGS (this->hbox, GTK_CAN_FOCUS);
-
- gtk_box_pack_end(GTK_BOX(gui->vbox), this->hbox, FALSE, FALSE, 0);
- gtk_widget_show_all(this->hbox);
- /* add a callback for position updates */
- this->vehicle_cb=callback_new_attr_1(callback_cast(statusbar_route_update), attr_position_coord_geo, this);
- navit_add_callback(gui->nav, this->vehicle_cb);
- return this;
+gui_gtk_statusbar_new(struct gui_priv *gui) {
+ struct statusbar_priv *this=g_new0(struct statusbar_priv, 1);
+
+ this->gui=gui;
+ this->hbox=gtk_hbox_new(FALSE, 1);
+ this->gps=gtk_label_new( "GPS 00/0 0000.0000N 00000.0000E 0000m 000°NO 000km/h" );
+ gtk_label_set_justify(GTK_LABEL(this->gps), GTK_JUSTIFY_LEFT);
+ this->route=gtk_label_new( _( "Route 0000km 0+00:00 ETA" ) );
+ gtk_label_set_justify(GTK_LABEL(this->route), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start(GTK_BOX(this->hbox), this->gps, TRUE, TRUE, 2);
+ gtk_box_pack_start(GTK_BOX(this->hbox), gtk_vseparator_new(), TRUE, TRUE, 2);
+ gtk_box_pack_start(GTK_BOX(this->hbox), this->route, TRUE, TRUE, 2);
+ GTK_WIDGET_UNSET_FLAGS (this->hbox, GTK_CAN_FOCUS);
+
+ gtk_box_pack_end(GTK_BOX(gui->vbox), this->hbox, FALSE, FALSE, 0);
+ gtk_widget_show_all(this->hbox);
+ /* add a callback for position updates */
+ this->vehicle_cb=callback_new_attr_1(callback_cast(statusbar_route_update), attr_position_coord_geo, this);
+ navit_add_callback(gui->nav, this->vehicle_cb);
+ return this;
}
diff --git a/navit/gui/gtk/gui_gtk_window.c b/navit/gui/gtk/gui_gtk_window.c
index 1741a54a0..1e57004d0 100644
--- a/navit/gui/gtk/gui_gtk_window.c
+++ b/navit/gui/gtk/gui_gtk_window.c
@@ -66,747 +66,706 @@
#define GDK_Calendar XF86XK_Calendar
#endif
#define KEY_ZOOM_IN GDK_Book
-#define KEY_ZOOM_OUT GDK_Calendar
+#define KEY_ZOOM_OUT GDK_Calendar
#define KEY_UP GDK_Up
#define KEY_DOWN GDK_Down
#define KEY_LEFT GDK_Left
#define KEY_RIGHT GDK_Right
#endif
-static gboolean
-keypress(GtkWidget *widget, GdkEventKey *event, struct gui_priv *this)
-{
- int w,h;
- struct transformation *t;
- #ifdef USE_HILDON
- GtkToggleAction *action;
- gboolean *fullscreen;
- #endif /*HILDON*/
- struct point p;
- if (event->type != GDK_KEY_PRESS)
- return FALSE;
- dbg(lvl_debug,"keypress 0x%x\n", event->keyval);
- transform_get_size(navit_get_trans(this->nav), &w, &h);
- switch (event->keyval) {
- case GDK_KP_Enter:
- gtk_menu_shell_select_first(GTK_MENU_SHELL(this->menubar), TRUE);
- break;
- case KEY_UP:
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case KEY_DOWN:
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case KEY_LEFT:
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case KEY_RIGHT:
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case KEY_ZOOM_IN:
- navit_zoom_in(this->nav, 2, NULL);
- break;
- case KEY_ZOOM_OUT:
- navit_zoom_out(this->nav, 2, NULL);
- break;
- case 'a':
- t=navit_get_trans(this->nav);
- transform_set_yaw(t, (transform_get_yaw(t)+15)%360);
- navit_draw(this->nav);
- break;
- case 'd':
- t=navit_get_trans(this->nav);
- transform_set_yaw(t, (transform_get_yaw(t)-15)%360);
- navit_draw(this->nav);
- break;
- case 'w':
- t=navit_get_trans(this->nav);
- transform_set_pitch(t, (transform_get_pitch(t)+5)%360);
- navit_draw(this->nav);
- break;
- case 'x':
- t=navit_get_trans(this->nav);
- transform_set_pitch(t, (transform_get_pitch(t)-5)%360);
- navit_draw(this->nav);
- break;
- case 'r':
- t=navit_get_trans(this->nav);
- transform_set_distance(t, (transform_get_distance(t)-5));
- navit_draw(this->nav);
- break;
- case 'f':
- t=navit_get_trans(this->nav);
- transform_set_distance(t, (transform_get_distance(t)+5));
- navit_draw(this->nav);
- break;
- case 'z':
- t=navit_get_trans(this->nav);
- transform_set_hog(t, (transform_get_hog(t)+1));
- navit_draw(this->nav);
- break;
- case 'h':
- t=navit_get_trans(this->nav);
- transform_set_hog(t, (transform_get_hog(t)-1));
- navit_draw(this->nav);
- break;
- case 't':
- {
- struct coord *p;
- struct pcoord pc;
- t=navit_get_trans(this->nav);
- p=transform_center(t);
- pc.pro=projection_mg;
- p->y+=50*cos(transform_get_yaw(t)*M_PI/180);
- p->x+=50*sin(transform_get_yaw(t)*M_PI/180);
- pc.x=p->x;
- pc.y=p->y;
- navit_set_center(this->nav, &pc, 1);
- }
- break;
- case 'g':
- {
- struct coord *p;
- struct pcoord pc;
- t=navit_get_trans(this->nav);
- p=transform_center(t);
- pc.pro=projection_mg;
- p->y-=50*cos(transform_get_yaw(t)*M_PI/180);
- p->x-=50*sin(transform_get_yaw(t)*M_PI/180);
- pc.x=p->x;
- pc.y=p->y;
- navit_set_center(this->nav, &pc, 1);
- }
- break;
- #ifdef USE_HILDON
- case HILDON_HARDKEY_FULLSCREEN:
- action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (this->base_group, "FullscreenAction"));
-
- if ( gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))
- {
- fullscreen = 0;
- } else {
- fullscreen = 1;
- }
- gtk_toggle_action_set_active (action, fullscreen);
- break;
- #endif /*HILDON*/
- default:
- return FALSE;
- }
- return TRUE;
+static gboolean keypress(GtkWidget *widget, GdkEventKey *event, struct gui_priv *this) {
+ int w,h;
+ struct transformation *t;
+#ifdef USE_HILDON
+ GtkToggleAction *action;
+ gboolean *fullscreen;
+#endif /*HILDON*/
+ struct point p;
+ if (event->type != GDK_KEY_PRESS)
+ return FALSE;
+ dbg(lvl_debug,"keypress 0x%x", event->keyval);
+ transform_get_size(navit_get_trans(this->nav), &w, &h);
+ switch (event->keyval) {
+ case GDK_KP_Enter:
+ gtk_menu_shell_select_first(GTK_MENU_SHELL(this->menubar), TRUE);
+ break;
+ case KEY_UP:
+ p.x=w/2;
+ p.y=0;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case KEY_DOWN:
+ p.x=w/2;
+ p.y=h;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case KEY_LEFT:
+ p.x=0;
+ p.y=h/2;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case KEY_RIGHT:
+ p.x=w;
+ p.y=h/2;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case KEY_ZOOM_IN:
+ navit_zoom_in(this->nav, 2, NULL);
+ break;
+ case KEY_ZOOM_OUT:
+ navit_zoom_out(this->nav, 2, NULL);
+ break;
+ case 'a':
+ t=navit_get_trans(this->nav);
+ transform_set_yaw(t, (transform_get_yaw(t)+15)%360);
+ navit_draw(this->nav);
+ break;
+ case 'd':
+ t=navit_get_trans(this->nav);
+ transform_set_yaw(t, (transform_get_yaw(t)-15)%360);
+ navit_draw(this->nav);
+ break;
+ case 'w':
+ t=navit_get_trans(this->nav);
+ transform_set_pitch(t, (transform_get_pitch(t)+5)%360);
+ navit_draw(this->nav);
+ break;
+ case 'x':
+ t=navit_get_trans(this->nav);
+ transform_set_pitch(t, (transform_get_pitch(t)-5)%360);
+ navit_draw(this->nav);
+ break;
+ case 'r':
+ t=navit_get_trans(this->nav);
+ transform_set_distance(t, (transform_get_distance(t)-5));
+ navit_draw(this->nav);
+ break;
+ case 'f':
+ t=navit_get_trans(this->nav);
+ transform_set_distance(t, (transform_get_distance(t)+5));
+ navit_draw(this->nav);
+ break;
+ case 'z':
+ t=navit_get_trans(this->nav);
+ transform_set_hog(t, (transform_get_hog(t)+1));
+ navit_draw(this->nav);
+ break;
+ case 'h':
+ t=navit_get_trans(this->nav);
+ transform_set_hog(t, (transform_get_hog(t)-1));
+ navit_draw(this->nav);
+ break;
+ case 't': {
+ struct coord *p;
+ struct pcoord pc;
+ t=navit_get_trans(this->nav);
+ p=transform_center(t);
+ pc.pro=projection_mg;
+ p->y+=50*cos(transform_get_yaw(t)*M_PI/180);
+ p->x+=50*sin(transform_get_yaw(t)*M_PI/180);
+ pc.x=p->x;
+ pc.y=p->y;
+ navit_set_center(this->nav, &pc, 1);
+ }
+ break;
+ case 'g': {
+ struct coord *p;
+ struct pcoord pc;
+ t=navit_get_trans(this->nav);
+ p=transform_center(t);
+ pc.pro=projection_mg;
+ p->y-=50*cos(transform_get_yaw(t)*M_PI/180);
+ p->x-=50*sin(transform_get_yaw(t)*M_PI/180);
+ pc.x=p->x;
+ pc.y=p->y;
+ navit_set_center(this->nav, &pc, 1);
+ }
+ break;
+#ifdef USE_HILDON
+ case HILDON_HARDKEY_FULLSCREEN:
+ action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (this->base_group, "FullscreenAction"));
+
+ if ( gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) {
+ fullscreen = 0;
+ } else {
+ fullscreen = 1;
+ }
+ gtk_toggle_action_set_active (action, fullscreen);
+ break;
+#endif /*HILDON*/
+ default:
+ return FALSE;
+ }
+ return TRUE;
}
-static int
-gui_gtk_set_graphics(struct gui_priv *this, struct graphics *gra)
-{
- GtkWidget *graphics;
-
- graphics=graphics_get_data(gra, "gtk_widget");
- if (! graphics)
- return 1;
- GTK_WIDGET_SET_FLAGS (graphics, GTK_CAN_FOCUS);
- gtk_widget_set_sensitive(graphics, TRUE);
- g_signal_connect(G_OBJECT(graphics), "key-press-event", G_CALLBACK(keypress), this);
- gtk_box_pack_end(GTK_BOX(this->vbox), graphics, TRUE, TRUE, 0);
- gtk_widget_show_all(graphics);
- gtk_widget_grab_focus(graphics);
-
- return 0;
+static int gui_gtk_set_graphics(struct gui_priv *this, struct graphics *gra) {
+ GtkWidget *graphics;
+
+ graphics=graphics_get_data(gra, "gtk_widget");
+ if (! graphics)
+ return 1;
+ GTK_WIDGET_SET_FLAGS (graphics, GTK_CAN_FOCUS);
+ gtk_widget_set_sensitive(graphics, TRUE);
+ g_signal_connect(G_OBJECT(graphics), "key-press-event", G_CALLBACK(keypress), this);
+ gtk_box_pack_end(GTK_BOX(this->vbox), graphics, TRUE, TRUE, 0);
+ gtk_widget_show_all(graphics);
+ gtk_widget_grab_focus(graphics);
+
+ return 0;
}
-static void
-gui_gtk_route_callback(struct gui_priv *gui) {
- struct attr route_attr;
- GtkAction *roadbookAction=gtk_ui_manager_get_action (gui->ui_manager,"/ui/ToolBar/ToolItems/Roadbook");
- if (roadbookAction) {
- if (navit_get_attr(gui->nav,attr_route,&route_attr,NULL)) {
- struct attr route_status_attr;
- if (route_get_attr(route_attr.u.route, attr_route_status,&route_status_attr,NULL) ) {
- if (route_status_attr.u.num>2) {
- gtk_action_set_sensitive(roadbookAction,1);
- } else {
- gtk_action_set_sensitive(roadbookAction,0);
- }
- }
- }
- }
+static void gui_gtk_route_callback(struct gui_priv *gui) {
+ struct attr route_attr;
+ GtkAction *roadbookAction=gtk_ui_manager_get_action (gui->ui_manager,"/ui/ToolBar/ToolItems/Roadbook");
+ if (roadbookAction) {
+ if (navit_get_attr(gui->nav,attr_route,&route_attr,NULL)) {
+ struct attr route_status_attr;
+ if (route_get_attr(route_attr.u.route, attr_route_status,&route_status_attr,NULL) ) {
+ if (route_status_attr.u.num>2) {
+ gtk_action_set_sensitive(roadbookAction,1);
+ } else {
+ gtk_action_set_sensitive(roadbookAction,0);
+ }
+ }
+ }
+ }
}
-static void
-gui_gtk_add_bookmark_do(struct gui_priv *gui)
-{
- struct attr attr;
- navit_get_attr(gui->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, &gui->dialog_coord, gtk_entry_get_text(GTK_ENTRY(gui->dialog_entry)));
- gtk_widget_destroy(gui->dialog_win);
+static void gui_gtk_add_bookmark_do(struct gui_priv *gui) {
+ struct attr attr;
+ navit_get_attr(gui->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_bookmark(attr.u.bookmarks, &gui->dialog_coord, gtk_entry_get_text(GTK_ENTRY(gui->dialog_entry)));
+ gtk_widget_destroy(gui->dialog_win);
}
-static int
-gui_gtk_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description)
-{
- GtkWidget *button_ok,*button_cancel,*label,*vbox,*hbox;
-
- gui->dialog_coord=*c;
- gui->dialog_win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- vbox=gtk_vbox_new(FALSE, 0);
- gtk_container_add (GTK_CONTAINER (gui->dialog_win), vbox);
- gtk_window_set_title(GTK_WINDOW(gui->dialog_win),_("Add Bookmark"));
- gtk_window_set_wmclass (GTK_WINDOW (gui->dialog_win), "navit", "Navit");
- gtk_window_set_transient_for(GTK_WINDOW(gui->dialog_win), GTK_WINDOW(gui->win));
- gtk_window_set_modal(GTK_WINDOW(gui->dialog_win), TRUE);
- label=gtk_label_new(_("Name"));
- gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
- gui->dialog_entry=gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(gui->dialog_entry), description);
- gtk_box_pack_start(GTK_BOX(vbox), gui->dialog_entry, TRUE, TRUE, 0);
- hbox=gtk_hbox_new(FALSE, 0);
- button_ok = gtk_button_new_from_stock (GTK_STOCK_OK);
- gtk_box_pack_start(GTK_BOX(hbox), button_ok, TRUE, TRUE, 10);
- button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- gtk_box_pack_start(GTK_BOX(hbox), button_cancel, TRUE, TRUE, 10);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 10);
- gtk_widget_show_all(gui->dialog_win);
- GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT);
- gtk_widget_grab_default(button_ok);
- g_signal_connect_swapped (G_OBJECT (button_cancel), "clicked", G_CALLBACK (gtk_widget_destroy), G_OBJECT (gui->dialog_win));
- g_signal_connect_swapped (G_OBJECT (gui->dialog_entry), "activate", G_CALLBACK (gui_gtk_add_bookmark_do), gui);
-
- g_signal_connect_swapped(G_OBJECT (button_ok), "clicked", G_CALLBACK (gui_gtk_add_bookmark_do), gui);
-
- return 1;
+static int gui_gtk_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description) {
+ GtkWidget *button_ok,*button_cancel,*label,*vbox,*hbox;
+
+ gui->dialog_coord=*c;
+ gui->dialog_win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ vbox=gtk_vbox_new(FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (gui->dialog_win), vbox);
+ gtk_window_set_title(GTK_WINDOW(gui->dialog_win),_("Add Bookmark"));
+ gtk_window_set_wmclass (GTK_WINDOW (gui->dialog_win), "navit", "Navit");
+ gtk_window_set_transient_for(GTK_WINDOW(gui->dialog_win), GTK_WINDOW(gui->win));
+ gtk_window_set_modal(GTK_WINDOW(gui->dialog_win), TRUE);
+ label=gtk_label_new(_("Name"));
+ gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
+ gui->dialog_entry=gtk_entry_new();
+ gtk_entry_set_text(GTK_ENTRY(gui->dialog_entry), description);
+ gtk_box_pack_start(GTK_BOX(vbox), gui->dialog_entry, TRUE, TRUE, 0);
+ hbox=gtk_hbox_new(FALSE, 0);
+ button_ok = gtk_button_new_from_stock (GTK_STOCK_OK);
+ gtk_box_pack_start(GTK_BOX(hbox), button_ok, TRUE, TRUE, 10);
+ button_cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+ gtk_box_pack_start(GTK_BOX(hbox), button_cancel, TRUE, TRUE, 10);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 10);
+ gtk_widget_show_all(gui->dialog_win);
+ GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT);
+ gtk_widget_grab_default(button_ok);
+ g_signal_connect_swapped (G_OBJECT (button_cancel), "clicked", G_CALLBACK (gtk_widget_destroy),
+ G_OBJECT (gui->dialog_win));
+ g_signal_connect_swapped (G_OBJECT (gui->dialog_entry), "activate", G_CALLBACK (gui_gtk_add_bookmark_do), gui);
+
+ g_signal_connect_swapped(G_OBJECT (button_ok), "clicked", G_CALLBACK (gui_gtk_add_bookmark_do), gui);
+
+ return 1;
}
struct gui_methods gui_gtk_methods = {
- NULL,
- gui_gtk_popup_new,
- gui_gtk_set_graphics,
- NULL,
- gui_gtk_datawindow_new,
- gui_gtk_add_bookmark,
+ NULL,
+ gui_gtk_popup_new,
+ gui_gtk_set_graphics,
+ NULL,
+ gui_gtk_datawindow_new,
+ gui_gtk_add_bookmark,
};
-static gboolean
-gui_gtk_delete(GtkWidget *widget, GdkEvent *event, struct navit *nav)
-{
- /* FIXME remove attr_navit callback */
- navit_destroy(nav);
- exit(0);
+static gboolean gui_gtk_delete(GtkWidget *widget, GdkEvent *event, struct navit *nav) {
+ /* FIXME remove attr_navit callback */
+ navit_destroy(nav);
+ exit(0);
- return TRUE;
+ return TRUE;
}
-static void
-gui_gtk_toggle_init(struct gui_priv *this)
-{
- struct attr attr;
- GtkToggleAction *toggle_action;
-
- if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- } else {
- dbg(lvl_warning, "Unable to locate CursorAction\n");
- }
- if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num != -1);
- } else {
- dbg(lvl_error, "Unable to locate OrientationAction\n");
- }
- if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
- toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
- gtk_toggle_action_set_active(toggle_action, attr.u.num);
- } else {
- dbg(lvl_error, "Unable to locate TrackingAction\n");
- }
+static void gui_gtk_toggle_init(struct gui_priv *this) {
+ struct attr attr;
+ GtkToggleAction *toggle_action;
+
+ if (navit_get_attr(this->nav, attr_cursor, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "CursorAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ } else {
+ dbg(lvl_warning, "Unable to locate CursorAction");
+ }
+ if (navit_get_attr(this->nav, attr_orientation, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "OrientationAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num != -1);
+ } else {
+ dbg(lvl_error, "Unable to locate OrientationAction");
+ }
+ if (navit_get_attr(this->nav, attr_tracking, &attr, NULL)) {
+ toggle_action = GTK_TOGGLE_ACTION(gtk_action_group_get_action(this->base_group, "TrackingAction"));
+ gtk_toggle_action_set_active(toggle_action, attr.u.num);
+ } else {
+ dbg(lvl_error, "Unable to locate TrackingAction");
+ }
}
struct action_cb_data {
- struct gui_priv *gui;
- struct attr attr;
+ struct gui_priv *gui;
+ struct attr attr;
};
-static void
-gui_gtk_action_activate(GtkAction *action, struct action_cb_data *data)
-{
- if(data->attr.type == attr_destination) {
- char * label;
- g_object_get(G_OBJECT(action), "label", &label,NULL);
- navit_set_destination(data->gui->nav, data->attr.u.pcoord, label, 1);
- g_free(label);
- }
+static void gui_gtk_action_activate(GtkAction *action, struct action_cb_data *data) {
+ if(data->attr.type == attr_destination) {
+ char * label;
+ g_object_get(G_OBJECT(action), "label", &label,NULL);
+ navit_populate_search_results_map(data->gui->nav, NULL, NULL); /* Remove any highlighted point on the map */
+ navit_set_destination(data->gui->nav, data->attr.u.pcoord, label, 1);
+ g_free(label);
+ }
}
struct gui_menu_info {
- guint merge_id;
- GtkAction *action;
+ guint merge_id;
+ GtkAction *action;
};
-static void
-gui_gtk_del_menu(struct gui_priv *this, struct gui_menu_info *meninfo)
-{
- gtk_action_group_remove_action(this->dyn_group, meninfo->action);
- gtk_ui_manager_remove_ui(this->ui_manager, meninfo->merge_id);
+static void gui_gtk_del_menu(struct gui_priv *this, struct gui_menu_info *meninfo) {
+ gtk_action_group_remove_action(this->dyn_group, meninfo->action);
+ gtk_ui_manager_remove_ui(this->ui_manager, meninfo->merge_id);
}
-static struct gui_menu_info
-gui_gtk_add_menu(struct gui_priv *this, char *name, char *label, char *path, int submenu, struct action_cb_data *data)
-{
- struct gui_menu_info meninfo;
- GtkAction *action;
- guint merge_id;
-
- action=gtk_action_new(name, label, NULL, NULL);
- meninfo.action = action;
- if (data)
- g_signal_connect(action, "activate", G_CALLBACK(gui_gtk_action_activate), data);
- gtk_action_group_add_action(this->dyn_group, action);
- merge_id =gtk_ui_manager_new_merge_id(this->ui_manager);
- meninfo.merge_id = merge_id;
- gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
-
- return meninfo;
+static struct gui_menu_info gui_gtk_add_menu(struct gui_priv *this, char *name, char *label, char *path, int submenu,
+ struct action_cb_data *data) {
+ struct gui_menu_info meninfo;
+ GtkAction *action;
+ guint merge_id;
+
+ action=gtk_action_new(name, label, NULL, NULL);
+ meninfo.action = action;
+ if (data)
+ g_signal_connect(action, "activate", G_CALLBACK(gui_gtk_action_activate), data);
+ gtk_action_group_add_action(this->dyn_group, action);
+ merge_id =gtk_ui_manager_new_merge_id(this->ui_manager);
+ meninfo.merge_id = merge_id;
+ gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name,
+ submenu ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM, FALSE);
+
+ return meninfo;
}
-static void
-gui_gtk_action_toggled(GtkToggleAction *action, struct action_cb_data *data)
-{
- struct attr active;
- active.type=attr_active;
- active.u.num=gtk_toggle_action_get_active(action);
- map_set_attr(data->attr.u.map, &active);
- navit_draw(data->gui->nav);
+static void gui_gtk_action_toggled(GtkToggleAction *action, struct action_cb_data *data) {
+ struct attr active;
+ active.type=attr_active;
+ active.u.num=gtk_toggle_action_get_active(action);
+ map_set_attr(data->attr.u.map, &active);
+ navit_draw(data->gui->nav);
}
-static void
-gui_gtk_add_toggle_menu(struct gui_priv *this, char *name, char *label, char *path, struct action_cb_data *data, gboolean active)
-{
- GtkToggleAction *toggle_action;
- guint merge_id;
-
- toggle_action=gtk_toggle_action_new(name, label, NULL, NULL);
- gtk_toggle_action_set_active(toggle_action, active);
- g_signal_connect(GTK_ACTION(toggle_action), "toggled", G_CALLBACK(gui_gtk_action_toggled), data);
- gtk_action_group_add_action(this->dyn_group, GTK_ACTION(toggle_action));
- merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
- gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
+static void gui_gtk_add_toggle_menu(struct gui_priv *this, char *name, char *label, char *path,
+ struct action_cb_data *data, gboolean active) {
+ GtkToggleAction *toggle_action;
+ guint merge_id;
+
+ toggle_action=gtk_toggle_action_new(name, label, NULL, NULL);
+ gtk_toggle_action_set_active(toggle_action, active);
+ g_signal_connect(GTK_ACTION(toggle_action), "toggled", G_CALLBACK(gui_gtk_action_toggled), data);
+ gtk_action_group_add_action(this->dyn_group, GTK_ACTION(toggle_action));
+ merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
+ gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
}
-static void
-gui_gtk_action_changed(GtkRadioAction *action, GtkRadioAction *current, struct action_cb_data *data)
-{
- if (action == current) {
- navit_set_attr(data->gui->nav, &data->attr);
- }
+static void gui_gtk_action_changed(GtkRadioAction *action, GtkRadioAction *current, struct action_cb_data *data) {
+ if (action == current) {
+ navit_set_attr(data->gui->nav, &data->attr);
+ }
}
-static struct gui_menu_info
-gui_gtk_add_radio_menu(struct gui_priv *this, char *name, char *label, char *path, struct action_cb_data *data, GSList **g)
-{
- struct gui_menu_info meninfo;
- GtkRadioAction *radio_action;
- guint merge_id;
-
- radio_action=gtk_radio_action_new(name, label, NULL, NULL, 0);
- meninfo.action = (GtkAction *)radio_action;
- gtk_radio_action_set_group(radio_action, *g);
- *g=gtk_radio_action_get_group(radio_action);
- g_signal_connect(GTK_ACTION(radio_action), "changed", G_CALLBACK(gui_gtk_action_changed), data);
- gtk_action_group_add_action(this->dyn_group, GTK_ACTION(radio_action));
- merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
- meninfo.merge_id = merge_id;
- gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
-
- return meninfo;
+static struct gui_menu_info gui_gtk_add_radio_menu(struct gui_priv *this, char *name, char *label, char *path,
+ struct action_cb_data *data, GSList **g) {
+ struct gui_menu_info meninfo;
+ GtkRadioAction *radio_action;
+ guint merge_id;
+
+ radio_action=gtk_radio_action_new(name, label, NULL, NULL, 0);
+ meninfo.action = (GtkAction *)radio_action;
+ gtk_radio_action_set_group(radio_action, *g);
+ *g=gtk_radio_action_get_group(radio_action);
+ g_signal_connect(GTK_ACTION(radio_action), "changed", G_CALLBACK(gui_gtk_action_changed), data);
+ gtk_action_group_add_action(this->dyn_group, GTK_ACTION(radio_action));
+ merge_id=gtk_ui_manager_new_merge_id(this->ui_manager);
+ meninfo.merge_id = merge_id;
+ gtk_ui_manager_add_ui(this->ui_manager, merge_id, path, name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
+
+ return meninfo;
}
-static void
-gui_gtk_layouts_init(struct gui_priv *this)
-{
- struct attr_iter *iter;
- struct attr attr;
- struct action_cb_data *data;
- int count=0;
- char *name;
-
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
- name=g_strdup_printf("Layout %d", count++);
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_layout;
- data->attr.u.layout=attr.u.layout;
- gui_gtk_add_radio_menu(this, name, attr.u.layout->name, "/ui/MenuBar/Map/Layout/LayoutMenuAdditions", data, &this->layout_group);
- g_free(name);
- }
- navit_attr_iter_destroy(iter);
+static void gui_gtk_layouts_init(struct gui_priv *this) {
+ struct attr_iter *iter;
+ struct attr attr;
+ struct action_cb_data *data;
+ int count=0;
+ char *name;
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
+ name=g_strdup_printf("Layout %d", count++);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_layout;
+ data->attr.u.layout=attr.u.layout;
+ gui_gtk_add_radio_menu(this, name, attr.u.layout->name, "/ui/MenuBar/Map/Layout/LayoutMenuAdditions", data,
+ &this->layout_group);
+ g_free(name);
+ }
+ navit_attr_iter_destroy(iter);
}
-static void
-gui_gtk_projections_init(struct gui_priv *this)
-{
- struct action_cb_data *data;
-
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_projection;
- data->attr.u.projection=projection_mg;
- gui_gtk_add_radio_menu(this, "Projection mg", "Map & Guide", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data, &this->projection_group);
-
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_projection;
- data->attr.u.projection=projection_garmin;
- gui_gtk_add_radio_menu(this, "Projection garmin", "Garmin", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data, &this->projection_group);
+static void gui_gtk_projections_init(struct gui_priv *this) {
+ struct action_cb_data *data;
+
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_projection;
+ data->attr.u.projection=projection_mg;
+ gui_gtk_add_radio_menu(this, "Projection mg", "Map & Guide", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data,
+ &this->projection_group);
+
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_projection;
+ data->attr.u.projection=projection_garmin;
+ gui_gtk_add_radio_menu(this, "Projection garmin", "Garmin", "/ui/MenuBar/Map/Projection/ProjectionMenuAdditions", data,
+ &this->projection_group);
}
-static void
-gui_gtk_vehicles_update(struct gui_priv *this)
-{
- struct attr_iter *iter;
- struct attr attr,vattr;
- struct action_cb_data *data;
- int count=0;
- char *name;
- GList *curr;
- struct gui_menu_info *meninfo;
- dbg(lvl_debug,"enter\n");
-
- curr = g_list_first(this->vehicle_menuitems);
-
- while (curr) {
- gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
- g_free((struct gui_menu_info *)curr->data);
- curr = g_list_next(curr);
- };
-
- g_list_free(this->vehicle_menuitems);
- this->vehicle_menuitems = NULL;
-
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- name=g_strdup_printf("Vehicle %d", count++);
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_vehicle;
- data->attr.u.vehicle=attr.u.vehicle;
- meninfo = g_new(struct gui_menu_info, 1);
- *meninfo = gui_gtk_add_radio_menu(this, name, vattr.u.str, "/ui/MenuBar/Map/Vehicle/VehicleMenuAdditions", data, &this->vehicle_group);
- this->vehicle_menuitems = g_list_prepend(this->vehicle_menuitems, meninfo);
- g_free(name);
- }
- navit_attr_iter_destroy(iter);
+static void gui_gtk_vehicles_update(struct gui_priv *this) {
+ struct attr_iter *iter;
+ struct attr attr,vattr;
+ struct action_cb_data *data;
+ int count=0;
+ char *name;
+ GList *curr;
+ struct gui_menu_info *meninfo;
+ dbg(lvl_debug,"enter");
+
+ curr = g_list_first(this->vehicle_menuitems);
+
+ while (curr) {
+ gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
+ g_free((struct gui_menu_info *)curr->data);
+ curr = g_list_next(curr);
+ };
+
+ g_list_free(this->vehicle_menuitems);
+ this->vehicle_menuitems = NULL;
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
+ name=g_strdup_printf("Vehicle %d", count++);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_vehicle;
+ data->attr.u.vehicle=attr.u.vehicle;
+ meninfo = g_new(struct gui_menu_info, 1);
+ *meninfo = gui_gtk_add_radio_menu(this, name, vattr.u.str, "/ui/MenuBar/Map/Vehicle/VehicleMenuAdditions", data,
+ &this->vehicle_group);
+ this->vehicle_menuitems = g_list_prepend(this->vehicle_menuitems, meninfo);
+ g_free(name);
+ }
+ navit_attr_iter_destroy(iter);
}
-static void
-gui_gtk_vehicles_init(struct gui_priv *this)
-{
- navit_add_callback(this->nav, callback_new_attr_1(callback_cast(gui_gtk_vehicles_update), attr_vehicle, this));
- gui_gtk_vehicles_update(this);
+static void gui_gtk_vehicles_init(struct gui_priv *this) {
+ navit_add_callback(this->nav, callback_new_attr_1(callback_cast(gui_gtk_vehicles_update), attr_vehicle, this));
+ gui_gtk_vehicles_update(this);
}
-static void
-gui_gtk_maps_init(struct gui_priv *this)
-{
- struct attr_iter *iter;
- struct attr attr,active,type,data;
- struct action_cb_data *cb_data;
- int count=0;
- char *name, *label;
-
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
- name=g_strdup_printf("Map %d", count++);
- if (! map_get_attr(attr.u.map, attr_type, &type, NULL))
- type.u.str="";
- if (! map_get_attr(attr.u.map, attr_data, &data, NULL))
- data.u.str="";
- label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
- cb_data=g_new(struct action_cb_data, 1);
- cb_data->gui=this;
- cb_data->attr.type=attr_map;
- cb_data->attr.u.map=attr.u.map;
- if (! map_get_attr(attr.u.map, attr_active, &active, NULL))
- active.u.num=1;
- gui_gtk_add_toggle_menu(this, name, label, "/ui/MenuBar/Map/MapMenuAdditions", cb_data, active.u.num);
- g_free(name);
- g_free(label);
- }
- navit_attr_iter_destroy(iter);
+static void gui_gtk_maps_init(struct gui_priv *this) {
+ struct attr_iter *iter;
+ struct attr attr,active,type,data;
+ struct action_cb_data *cb_data;
+ int count=0;
+ char *name, *label;
+
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
+ name=g_strdup_printf("Map %d", count++);
+ if (! map_get_attr(attr.u.map, attr_type, &type, NULL))
+ type.u.str="";
+ if (! map_get_attr(attr.u.map, attr_data, &data, NULL))
+ data.u.str="";
+ label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
+ cb_data=g_new(struct action_cb_data, 1);
+ cb_data->gui=this;
+ cb_data->attr.type=attr_map;
+ cb_data->attr.u.map=attr.u.map;
+ if (! map_get_attr(attr.u.map, attr_active, &active, NULL))
+ active.u.num=1;
+ gui_gtk_add_toggle_menu(this, name, label, "/ui/MenuBar/Map/MapMenuAdditions", cb_data, active.u.num);
+ g_free(name);
+ g_free(label);
+ }
+ navit_attr_iter_destroy(iter);
}
-static void
-gui_gtk_destinations_update(struct gui_priv *this)
-{
- GList *curr;
- struct attr attr;
- struct action_cb_data *data;
- struct map_rect *mr=NULL;
- struct item *item;
- struct gui_menu_info *meninfo;
- struct coord c;
- int count=0;
- char *name, *label;
-
- curr = g_list_first(this->dest_menuitems);
-
- while (curr) {
- gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
- g_free((struct gui_menu_info *)curr->data);
- curr = g_list_next(curr);
- };
-
- g_list_free(this->dest_menuitems);
- this->dest_menuitems = NULL;
-
- if(navit_get_attr(this->nav, attr_former_destination_map, &attr, NULL) && attr.u.map && (mr=map_rect_new(attr.u.map, NULL))) {
- while ((item=map_rect_get_item(mr))) {
- if (item->type != type_former_destination) continue;
- name=g_strdup_printf("Destination %d", count++);
- item_attr_get(item, attr_label, &attr);
- label=attr.u.str;
- item_coord_get(item, &c, 1);
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_destination;
- data->attr.u.pcoord=g_new(struct pcoord, 1);
- data->attr.u.pcoord->pro=projection_mg;
- data->attr.u.pcoord->x=c.x;
- data->attr.u.pcoord->y=c.y;
-
- meninfo = g_new(struct gui_menu_info, 1);
- *meninfo = gui_gtk_add_menu(this, name, label, "/ui/MenuBar/Route/FormerDestinations/FormerDestinationMenuAdditions",0,data);
- this->dest_menuitems = g_list_prepend(this->dest_menuitems, meninfo);
- g_free(name);
- }
- map_rect_destroy(mr);
- }
+static void gui_gtk_destinations_update(struct gui_priv *this) {
+ GList *curr;
+ struct attr attr;
+ struct action_cb_data *data;
+ struct map_rect *mr=NULL;
+ struct item *item;
+ struct gui_menu_info *meninfo;
+ struct coord c;
+ int count=0;
+ char *name, *label;
+
+ curr = g_list_first(this->dest_menuitems);
+
+ while (curr) {
+ gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
+ g_free((struct gui_menu_info *)curr->data);
+ curr = g_list_next(curr);
+ };
+
+ g_list_free(this->dest_menuitems);
+ this->dest_menuitems = NULL;
+
+ if(navit_get_attr(this->nav, attr_former_destination_map, &attr, NULL) && attr.u.map
+ && (mr=map_rect_new(attr.u.map, NULL))) {
+ while ((item=map_rect_get_item(mr))) {
+ if (item->type != type_former_destination) continue;
+ name=g_strdup_printf("Destination %d", count++);
+ item_attr_get(item, attr_label, &attr);
+ label=attr.u.str;
+ item_coord_get(item, &c, 1);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_destination;
+ data->attr.u.pcoord=g_new(struct pcoord, 1);
+ data->attr.u.pcoord->pro=projection_mg;
+ data->attr.u.pcoord->x=c.x;
+ data->attr.u.pcoord->y=c.y;
+
+ meninfo = g_new(struct gui_menu_info, 1);
+ *meninfo = gui_gtk_add_menu(this, name, label, "/ui/MenuBar/Route/FormerDestinations/FormerDestinationMenuAdditions",0,
+ data);
+ this->dest_menuitems = g_list_prepend(this->dest_menuitems, meninfo);
+ g_free(name);
+ }
+ map_rect_destroy(mr);
+ }
}
-static void
-gui_gtk_destinations_init(struct gui_priv *this)
-{
- navit_add_callback(this->nav, callback_new_attr_1(callback_cast(gui_gtk_destinations_update), attr_destination, this));
- gui_gtk_destinations_update(this);
+static void gui_gtk_destinations_init(struct gui_priv *this) {
+ navit_add_callback(this->nav, callback_new_attr_1(callback_cast(gui_gtk_destinations_update), attr_destination, this));
+ gui_gtk_destinations_update(this);
}
-static void
-gui_gtk_bookmarks_update(struct gui_priv *this)
-{
- GList *curr;
- struct attr attr;
- struct action_cb_data *data;
- struct map_rect *mr=NULL;
- struct gui_menu_info *meninfo;
- struct item *item;
- struct coord c;
- int count=0;
- char *parent, *name, *label, *label_full, *menu_label, *tmp_parent, *s;
- GHashTable *hash;
-
- curr = g_list_first(this->bookmarks_menuitems);
-
- while (curr) {
- gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
- g_free((struct gui_menu_info *)curr->data);
- curr = g_list_next(curr);
- };
-
- g_list_free(this->bookmarks_menuitems);
- this->bookmarks_menuitems = NULL;
-
- if(navit_get_attr(this->nav, attr_bookmark_map, &attr, NULL) && attr.u.map && (mr=map_rect_new(attr.u.map, NULL))) {
- hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
- while ((item=map_rect_get_item(mr))) {
- if (item->type != type_bookmark) continue;
- item_attr_get(item, attr_label, &attr);
- label_full=attr.u.str;
- item_coord_get(item, &c, 1);
- menu_label=g_malloc(strlen(label_full)+1);
- label=label_full;
- parent=g_strdup("/ui/MenuBar/Route/Bookmarks/BookmarkMenuAdditions");
- while ((s=strchr(label, '/'))) {
- strcpy(menu_label, label_full);
- menu_label[s-label_full]='\0';
- if ((tmp_parent=g_hash_table_lookup(hash, menu_label))) {
- tmp_parent=g_strdup(tmp_parent);
- } else {
- name=g_strdup_printf("Bookmark %d", count++);
- meninfo = g_new(struct gui_menu_info, 1);
- *meninfo = gui_gtk_add_menu(this, name, menu_label+(label-label_full),parent,1,NULL);
- this->bookmarks_menuitems = g_list_prepend(this->bookmarks_menuitems, meninfo);
- tmp_parent=g_strdup_printf("%s/%s", parent, name);
- g_hash_table_insert(hash, g_strdup(menu_label), g_strdup(tmp_parent));
- g_free(name);
- }
- g_free(parent);
- parent=tmp_parent;
- label=s+1;
- }
- g_free(menu_label);
- data=g_new(struct action_cb_data, 1);
- data->gui=this;
- data->attr.type=attr_destination;
- data->attr.u.pcoord=g_new(struct pcoord, 1);
- data->attr.u.pcoord->pro=projection_mg;
- data->attr.u.pcoord->x=c.x;
- data->attr.u.pcoord->y=c.y;
- name=g_strdup_printf("Bookmark %d", count++);
- meninfo = g_new(struct gui_menu_info, 1);
- *meninfo = gui_gtk_add_menu(this, name, label, parent,0,data);
- this->bookmarks_menuitems = g_list_prepend(this->bookmarks_menuitems, meninfo);
- g_free(name);
- g_free(parent);
- }
- g_hash_table_destroy(hash);
- }
+static void gui_gtk_bookmarks_update(struct gui_priv *this) {
+ GList *curr;
+ struct attr attr;
+ struct action_cb_data *data;
+ struct map_rect *mr=NULL;
+ struct gui_menu_info *meninfo;
+ struct item *item;
+ struct coord c;
+ int count=0;
+ char *parent, *name, *label, *label_full, *menu_label, *tmp_parent, *s;
+ GHashTable *hash;
+
+ curr = g_list_first(this->bookmarks_menuitems);
+
+ while (curr) {
+ gui_gtk_del_menu(this, (struct gui_menu_info *)curr->data);
+ g_free((struct gui_menu_info *)curr->data);
+ curr = g_list_next(curr);
+ };
+
+ g_list_free(this->bookmarks_menuitems);
+ this->bookmarks_menuitems = NULL;
+
+ if(navit_get_attr(this->nav, attr_bookmark_map, &attr, NULL) && attr.u.map && (mr=map_rect_new(attr.u.map, NULL))) {
+ hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ while ((item=map_rect_get_item(mr))) {
+ if (item->type != type_bookmark) continue;
+ item_attr_get(item, attr_label, &attr);
+ label_full=attr.u.str;
+ item_coord_get(item, &c, 1);
+ menu_label=g_malloc(strlen(label_full)+1);
+ label=label_full;
+ parent=g_strdup("/ui/MenuBar/Route/Bookmarks/BookmarkMenuAdditions");
+ while ((s=strchr(label, '/'))) {
+ strcpy(menu_label, label_full);
+ menu_label[s-label_full]='\0';
+ if ((tmp_parent=g_hash_table_lookup(hash, menu_label))) {
+ tmp_parent=g_strdup(tmp_parent);
+ } else {
+ name=g_strdup_printf("Bookmark %d", count++);
+ meninfo = g_new(struct gui_menu_info, 1);
+ *meninfo = gui_gtk_add_menu(this, name, menu_label+(label-label_full),parent,1,NULL);
+ this->bookmarks_menuitems = g_list_prepend(this->bookmarks_menuitems, meninfo);
+ tmp_parent=g_strdup_printf("%s/%s", parent, name);
+ g_hash_table_insert(hash, g_strdup(menu_label), g_strdup(tmp_parent));
+ g_free(name);
+ }
+ g_free(parent);
+ parent=tmp_parent;
+ label=s+1;
+ }
+ g_free(menu_label);
+ data=g_new(struct action_cb_data, 1);
+ data->gui=this;
+ data->attr.type=attr_destination;
+ data->attr.u.pcoord=g_new(struct pcoord, 1);
+ data->attr.u.pcoord->pro=projection_mg;
+ data->attr.u.pcoord->x=c.x;
+ data->attr.u.pcoord->y=c.y;
+ name=g_strdup_printf("Bookmark %d", count++);
+ meninfo = g_new(struct gui_menu_info, 1);
+ *meninfo = gui_gtk_add_menu(this, name, label, parent,0,data);
+ this->bookmarks_menuitems = g_list_prepend(this->bookmarks_menuitems, meninfo);
+ g_free(name);
+ g_free(parent);
+ }
+ g_hash_table_destroy(hash);
+ }
}
-static void
-gui_gtk_bookmarks_init(struct gui_priv *this)
-{
- struct attr attr;
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_callback(attr.u.bookmarks, callback_new_attr_1(callback_cast(gui_gtk_bookmarks_update), attr_bookmark_map, this));
- gui_gtk_bookmarks_update(this);
+static void gui_gtk_bookmarks_init(struct gui_priv *this) {
+ struct attr attr;
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_callback(attr.u.bookmarks, callback_new_attr_1(callback_cast(gui_gtk_bookmarks_update), attr_bookmark_map,
+ this));
+ gui_gtk_bookmarks_update(this);
}
-static void
-gui_gtk_init(struct gui_priv *this, struct navit *nav)
-{
-
- struct attr route_attr;
-
- gui_gtk_toggle_init(this);
- gui_gtk_layouts_init(this);
- gui_gtk_projections_init(this);
- gui_gtk_vehicles_init(this);
- gui_gtk_maps_init(this);
- gui_gtk_destinations_init(this);
- gui_gtk_bookmarks_init(this);
-
- if (navit_get_attr(nav,attr_route,&route_attr,NULL)) {
- struct attr callback;
- callback.type=attr_callback;
- callback.u.callback=callback_new_attr_1(callback_cast(gui_gtk_route_callback), attr_route_status, this);
- route_add_attr(route_attr.u.route, &callback);
- }
- gui_gtk_route_callback(this); //Set initial state
+static void gui_gtk_init(struct gui_priv *this, struct navit *nav) {
+
+ struct attr route_attr;
+
+ gui_gtk_toggle_init(this);
+ gui_gtk_layouts_init(this);
+ gui_gtk_projections_init(this);
+ gui_gtk_vehicles_init(this);
+ gui_gtk_maps_init(this);
+ gui_gtk_destinations_init(this);
+ gui_gtk_bookmarks_init(this);
+
+ if (navit_get_attr(nav,attr_route,&route_attr,NULL)) {
+ struct attr callback;
+ callback.type=attr_callback;
+ callback.u.callback=callback_new_attr_1(callback_cast(gui_gtk_route_callback), attr_route_status, this);
+ route_add_attr(route_attr.u.route, &callback);
+ }
+ gui_gtk_route_callback(this); //Set initial state
}
-static struct gui_priv *
-gui_gtk_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui)
-{
- struct gui_priv *this;
- int w=792, h=547;
- char *cp = getenv("NAVIT_XID");
- unsigned xid = 0;
- struct attr *attr;
- GtkWidget *widget;
- int fullscreen = 0;
-
- if (! event_request_system("glib","gui_gtk_new"))
- return NULL;
-
- if (cp) {
- xid = strtol(cp, NULL, 0);
- }
-
- this=g_new0(struct gui_priv, 1);
- this->nav=nav;
-
- attr = attr_search(attrs, NULL, attr_menubar);
- if (attr) {
- this->menubar_enable=attr->u.num;
- } else {
- this->menubar_enable=1;
- }
- attr=attr_search(attrs, NULL, attr_toolbar);
- if (attr) {
- this->toolbar_enable=attr->u.num;
- } else {
- this->toolbar_enable=1;
- }
- attr=attr_search(attrs, NULL, attr_statusbar);
- if (attr) {
- this->statusbar_enable=attr->u.num;
- } else {
- this->statusbar_enable=1;
- }
-
- *meth=gui_gtk_methods;
-
- if (!xid)
- this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- else
- this->win = gtk_plug_new(xid);
-
-
- g_signal_connect(G_OBJECT(this->win), "delete-event", G_CALLBACK(gui_gtk_delete), nav);
- this->vbox = gtk_vbox_new(FALSE, 0);
- gtk_window_set_default_size(GTK_WINDOW(this->win), w, h);
- gtk_window_set_title(GTK_WINDOW(this->win), "Navit");
- gtk_window_set_wmclass (GTK_WINDOW (this->win), "navit", "Navit");
- gtk_widget_realize(this->win);
- gui_gtk_ui_init(this);
- if (this->menubar_enable) {
- widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/MenuBar");
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
- gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
- this->menubar=widget;
- }
- if (this->toolbar_enable) {
- widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/ToolBar");
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
- gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
- gtk_widget_show (widget);
- }
- if (this->statusbar_enable) {
- this->statusbar=gui_gtk_statusbar_new(this);
- }
- gtk_window_add_accel_group (GTK_WINDOW (this->win),
- gtk_ui_manager_get_accel_group(this->ui_manager));
- gtk_container_add(GTK_CONTAINER(this->win), this->vbox);
- gtk_widget_show_all(this->win);
-
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(gui_gtk_init), attr_navit, this));
-
- if ((attr=attr_search(attrs, NULL, attr_fullscreen)))
- fullscreen=attr->u.num;
-
- if (fullscreen) {
- GtkToggleAction *action;
- action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (this->base_group, "FullscreenAction"));
- gtk_toggle_action_set_active (action, fullscreen);
- }
-
- return this;
+static struct gui_priv *gui_gtk_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui) {
+ struct gui_priv *this;
+ int w=792, h=547;
+ char *cp = getenv("NAVIT_XID");
+ unsigned xid = 0;
+ struct attr *attr;
+ GtkWidget *widget;
+ int fullscreen = 0;
+
+ if (! event_request_system("glib","gui_gtk_new"))
+ return NULL;
+
+ if (cp) {
+ xid = strtol(cp, NULL, 0);
+ }
+
+ this=g_new0(struct gui_priv, 1);
+ this->nav=nav;
+
+ attr = attr_search(attrs, NULL, attr_menubar);
+ if (attr) {
+ this->menubar_enable=attr->u.num;
+ } else {
+ this->menubar_enable=1;
+ }
+ attr=attr_search(attrs, NULL, attr_toolbar);
+ if (attr) {
+ this->toolbar_enable=attr->u.num;
+ } else {
+ this->toolbar_enable=1;
+ }
+ attr=attr_search(attrs, NULL, attr_statusbar);
+ if (attr) {
+ this->statusbar_enable=attr->u.num;
+ } else {
+ this->statusbar_enable=1;
+ }
+
+ *meth=gui_gtk_methods;
+
+ if (!xid)
+ this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ else
+ this->win = gtk_plug_new(xid);
+
+
+ g_signal_connect(G_OBJECT(this->win), "delete-event", G_CALLBACK(gui_gtk_delete), nav);
+ this->vbox = gtk_vbox_new(FALSE, 0);
+ gtk_window_set_default_size(GTK_WINDOW(this->win), w, h);
+ gtk_window_set_title(GTK_WINDOW(this->win), "Navit");
+ gtk_window_set_wmclass (GTK_WINDOW (this->win), "navit", "Navit");
+ gtk_widget_realize(this->win);
+ gui_gtk_ui_init(this);
+ if (this->menubar_enable) {
+ widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/MenuBar");
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ this->menubar=widget;
+ }
+ if (this->toolbar_enable) {
+ widget=gtk_ui_manager_get_widget(this->ui_manager, "/ui/ToolBar");
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_box_pack_start (GTK_BOX(this->vbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+ }
+ if (this->statusbar_enable) {
+ this->statusbar=gui_gtk_statusbar_new(this);
+ }
+ gtk_window_add_accel_group (GTK_WINDOW (this->win),
+ gtk_ui_manager_get_accel_group(this->ui_manager));
+ gtk_container_add(GTK_CONTAINER(this->win), this->vbox);
+ gtk_widget_show_all(this->win);
+
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(gui_gtk_init), attr_navit, this));
+
+ if ((attr=attr_search(attrs, NULL, attr_fullscreen)))
+ fullscreen=attr->u.num;
+
+ if (fullscreen) {
+ GtkToggleAction *action;
+ action = GTK_TOGGLE_ACTION (gtk_action_group_get_action (this->base_group, "FullscreenAction"));
+ gtk_toggle_action_set_active (action, fullscreen);
+ }
+
+ return this;
}
static int gtk_argc;
-static char **gtk_argv={NULL};
+static char **gtk_argv= {NULL};
-void
-plugin_init(void)
-{
- gtk_init(&gtk_argc, &gtk_argv);
- gtk_set_locale();
+void plugin_init(void) {
+ gtk_init(&gtk_argc, &gtk_argv);
+ gtk_set_locale();
#ifdef HAVE_API_WIN32
- setlocale(LC_NUMERIC,"C");
+ setlocale(LC_NUMERIC,"C");
#endif
- plugin_register_category_gui("gtk", gui_gtk_new);
+ plugin_register_category_gui("gtk", gui_gtk_new);
}
diff --git a/navit/gui/internal/CMakeLists.txt b/navit/gui/internal/CMakeLists.txt
index 4c853f526..bda2068da 100644
--- a/navit/gui/internal/CMakeLists.txt
+++ b/navit/gui/internal/CMakeLists.txt
@@ -1,3 +1,7 @@
+if (GUI_INTERNAL_VISUAL_DBG)
+ add_definitions ("-DGUI_INTERNAL_VISUAL_DBG")
+endif(GUI_INTERNAL_VISUAL_DBG)
+
if(USE_AUDIO_FRAMEWORK)
set(audio_sources gui_internal_media.c )
endif(USE_AUDIO_FRAMEWORK)
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c
index 0a62ae010..726a03d17 100644
--- a/navit/gui/internal/gui_internal.c
+++ b/navit/gui/internal/gui_internal.c
@@ -105,13 +105,14 @@ const int SMALL_PROFILE=2;
* [1] => MEDIUM PROFILE (screens larger than 320 in one dimension
* [2] => Small profile (default)
*/
-static struct gui_config_settings config_profiles[]={
- {545,32,48,96,10}
+static struct gui_config_settings config_profiles[]= {
+ {545,32,48,96,10}
, {300,32,48,64,3}
- ,{200,16,32,48,2}
+ ,{200,16,32,48,2}
};
static void gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data);
+static void gui_internal_prepare_search_results_map(struct gui_priv *this, struct widget *table, struct coord_rect *r);
static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle *vehicle);
@@ -127,29 +128,25 @@ static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle
*
* @return image_struct Ptr to scaled image struct or NULL if not scaled or found
*/
-static struct graphics_image *
-image_new_scaled(struct gui_priv *this, const char *name, int w, int h)
-{
- struct graphics_image *ret=NULL;
- char *full_path=NULL;
- full_path=graphics_icon_path(name);
- ret=graphics_image_new_scaled(this->gra, full_path, w, h);
- dbg(lvl_debug,"Trying to load image '%s' (w=%d, h=%d): %s\n", name, w, h, ret ? "OK" : "NOT FOUND");
- g_free(full_path);
- if (!ret) {
- dbg(lvl_error,"Failed to load image for '%s' (w=%d, h=%d)\n", name, w, h);
- full_path=graphics_icon_path("unknown");
- ret=graphics_image_new_scaled(this->gra, full_path, w, h);
- g_free(full_path);
- }
- return ret;
+static struct graphics_image *image_new_scaled(struct gui_priv *this, const char *name, int w, int h) {
+ struct graphics_image *ret=NULL;
+ char *full_path=NULL;
+ full_path=graphics_icon_path(name);
+ ret=graphics_image_new_scaled(this->gra, full_path, w, h);
+ dbg(lvl_debug,"Trying to load image '%s' (w=%d, h=%d): %s", name, w, h, ret ? "OK" : "NOT FOUND");
+ g_free(full_path);
+ if (!ret) {
+ dbg(lvl_error,"Failed to load image for '%s' (w=%d, h=%d)", name, w, h);
+ full_path=graphics_icon_path("unknown");
+ ret=graphics_image_new_scaled(this->gra, full_path, w, h);
+ g_free(full_path);
+ }
+ return ret;
}
#if 0
-static struct graphics_image *
-image_new_o(struct gui_priv *this, char *name)
-{
- return image_new_scaled(this, name, -1, -1);
+static struct graphics_image *image_new_o(struct gui_priv *this, char *name) {
+ return image_new_scaled(this, name, -1, -1);
}
#endif
@@ -164,9 +161,8 @@ image_new_o(struct gui_priv *this, char *name)
* @return image_struct Ptr to scaled image struct or NULL if not scaled or found
*/
struct graphics_image *
-image_new_xs(struct gui_priv *this, const char *name)
-{
- return image_new_scaled(this, name, this->icon_xs, this->icon_xs);
+image_new_xs(struct gui_priv *this, const char *name) {
+ return image_new_scaled(this, name, this->icon_xs, this->icon_xs);
}
/**
@@ -178,9 +174,8 @@ image_new_xs(struct gui_priv *this, const char *name)
* @return image_struct Ptr to scaled image struct or NULL if not scaled or found
*/
struct graphics_image *
-image_new_s(struct gui_priv *this, const char *name)
-{
- return image_new_scaled(this, name, this->icon_s, this->icon_s);
+image_new_s(struct gui_priv *this, const char *name) {
+ return image_new_scaled(this, name, this->icon_s, this->icon_s);
}
/**
@@ -191,108 +186,101 @@ image_new_s(struct gui_priv *this, const char *name)
* @return image_struct Ptr to scaled image struct or NULL if not scaled or found
*/
struct graphics_image *
-image_new_l(struct gui_priv *this, const char *name)
-{
- return image_new_scaled(this, name, this->icon_l, this->icon_l);
-}
-
-
-
-static int
-gui_internal_button_attr_update(struct gui_priv *this, struct widget *w)
-{
- struct widget *wi;
- int is_on=0;
- struct attr curr;
- GList *l;
-
- if (w->get_attr(w->instance, w->on.type, &curr, NULL))
- is_on=curr.u.data == w->on.u.data;
- else
- is_on=w->deflt;
- if (is_on != w->is_on) {
- if (w->redraw)
- this->redraw=1;
- w->is_on=is_on;
- l=g_list_first(w->children);
- if (l) {
- wi=l->data;
- if (wi->img)
- graphics_image_free(this->gra, wi->img);
- wi->img=image_new_xs(this, is_on ? "gui_active" : "gui_inactive");
- }
- if (w->is_on && w->off.type == attr_none)
- w->state &= ~STATE_SENSITIVE;
- else
- w->state |= STATE_SENSITIVE;
- return 1;
- }
- return 0;
-}
-
-static void
-gui_internal_button_attr_callback(struct gui_priv *this, struct widget *w)
-{
- if (gui_internal_button_attr_update(this, w))
- gui_internal_widget_render(this, w);
-}
-static void
-gui_internal_button_attr_pressed(struct gui_priv *this, struct widget *w, void *data)
-{
- if (w->is_on)
- w->set_attr(w->instance, &w->off);
- else
- w->set_attr(w->instance, &w->on);
- gui_internal_button_attr_update(this, w);
+image_new_l(struct gui_priv *this, const char *name) {
+ return image_new_scaled(this, name, this->icon_l, this->icon_l);
+}
+
+
+
+static int gui_internal_button_attr_update(struct gui_priv *this, struct widget *w) {
+ struct widget *wi;
+ int is_on=0;
+ struct attr curr;
+ GList *l;
+
+ if (w->get_attr(w->instance, w->on.type, &curr, NULL))
+ is_on=curr.u.data == w->on.u.data;
+ else
+ is_on=w->deflt;
+ if (is_on != w->is_on) {
+ if (w->redraw)
+ this->redraw=1;
+ w->is_on=is_on;
+ l=g_list_first(w->children);
+ if (l) {
+ wi=l->data;
+ if (wi->img)
+ graphics_image_free(this->gra, wi->img);
+ wi->img=image_new_xs(this, is_on ? "gui_active" : "gui_inactive");
+ }
+ if (w->is_on && w->off.type == attr_none)
+ w->state &= ~STATE_SENSITIVE;
+ else
+ w->state |= STATE_SENSITIVE;
+ return 1;
+ }
+ return 0;
+}
+
+static void gui_internal_button_attr_callback(struct gui_priv *this, struct widget *w) {
+ if (gui_internal_button_attr_update(this, w))
+ gui_internal_widget_render(this, w);
+}
+static void gui_internal_button_attr_pressed(struct gui_priv *this, struct widget *w, void *data) {
+ if (w->is_on)
+ w->set_attr(w->instance, &w->off);
+ else
+ w->set_attr(w->instance, &w->on);
+ gui_internal_button_attr_update(this, w);
}
struct widget *
-gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct attr *on, struct attr *off)
-{
- struct graphics_image *image=NULL;
- struct widget *ret;
- if (!on && !off)
- return NULL;
- image=image_new_xs(this, "gui_inactive");
- ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
- if (on)
- ret->on=*on;
- if (off)
- ret->off=*off;
- ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))navit_get_attr;
- ret->set_attr=(int (*)(void *, struct attr *))navit_set_attr;
- ret->remove_cb=(void (*)(void *, struct callback *))navit_remove_callback;
- ret->instance=this->nav;
- ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
- navit_add_callback(this->nav, ret->cb);
- gui_internal_button_attr_update(this, ret);
- return ret;
+gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct attr *on,
+ struct attr *off) {
+ struct graphics_image *image=NULL;
+ struct widget *ret;
+ if (!on && !off)
+ return NULL;
+ image=image_new_xs(this, "gui_inactive");
+ ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
+ if (on)
+ ret->on=*on;
+ if (off)
+ ret->off=*off;
+ ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))navit_get_attr;
+ ret->set_attr=(int (*)(void *, struct attr *))navit_set_attr;
+ ret->remove_cb=(void (*)(void *, struct callback *))navit_remove_callback;
+ ret->instance=this->nav;
+ ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
+ navit_add_callback(this->nav, ret->cb);
+ gui_internal_button_attr_update(this, ret);
+ return ret;
}
struct widget *
-gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct map *map, struct attr *on, struct attr *off, int deflt)
-{
- struct graphics_image *image=NULL;
- struct widget *ret;
- image=image_new_xs(this, "gui_inactive");
- if (!on && !off)
- return NULL;
- ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
- if (on)
- ret->on=*on;
- if (off)
- ret->off=*off;
- ret->deflt=deflt;
- ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))map_get_attr;
- ret->set_attr=(int (*)(void *, struct attr *))map_set_attr;
- ret->remove_cb=(void (*)(void *, struct callback *))map_remove_callback;
- ret->instance=map;
- ret->redraw=1;
- ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
- map_add_callback(map, ret->cb);
- gui_internal_button_attr_update(this, ret);
- return ret;
+gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct map *map,
+ struct attr *on, struct attr *off, int deflt) {
+ struct graphics_image *image=NULL;
+ struct widget *ret;
+ image=image_new_xs(this, "gui_inactive");
+ if (!on && !off)
+ return NULL;
+ ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
+ if (on)
+ ret->on=*on;
+ if (off)
+ ret->off=*off;
+ ret->deflt=deflt;
+ ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))map_get_attr;
+ ret->set_attr=(int (*)(void *, struct attr *))map_set_attr;
+ ret->remove_cb=(void (*)(void *, struct callback *))map_remove_callback;
+ ret->instance=map;
+ ret->redraw=1;
+ ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
+ map_add_callback(map, ret->cb);
+ gui_internal_button_attr_update(this, ret);
+ return ret;
}
@@ -312,89 +300,90 @@ gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum f
/* FIXME where is the implementation? */
-static void gui_internal_motion_cb(struct gui_priv *this)
-{
- this->motion_timeout_event=NULL;
- gui_internal_gesture_ring_add(this, &(this->current));
-
- /* Check for scrollable table below the highligted item if there's a movement with the button pressed */
- if (this->pressed && this->highlighted) {
- struct widget *wt=NULL;
- struct widget *wr=NULL;
- int dx,dy;
-
- /* Guard against accidental scrolling when user is likely going to swipe */
- gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
- if(abs(dx)>abs(dy) || abs(dy)<this->icon_s)
- return;
-
- if(this->highlighted)
- for(wr=this->highlighted;wr && wr->type!=widget_table_row;wr=wr->parent);
- if(wr)
- wt=wr->parent;
-
- if(wt && wt->type==widget_table && (wt->state & STATE_SCROLLABLE)) {
- struct table_data *td=wt->data;
- GList *top=NULL;
- GList *btm=NULL;
- GList *ttop, *tbtm;
-
-
-
- if(!wr || !wr->h)
- return;
-
- if(this->current.y < wr->p.y && wr!=td->top_row->data ) {
- int n=(wr->p.y-this->current.y)/wr->h+1;
-
- btm=td->bottom_row;
- top=td->top_row;
-
- while(n-->0 && (tbtm=gui_internal_widget_table_next_row(btm))!=NULL && (ttop=gui_internal_widget_table_next_row(top))!=NULL) {
- top=ttop;
- btm=tbtm;
- if(top->data==wr)
- break;
- }
- this->pressed=2;
- } else if (this->current.y > wr->p.y + wr->h ) {
- int y=wt->p.y+wt->h-wr->h;
- int n;
-
- if(td->scroll_buttons.button_box && td->scroll_buttons.button_box->p.y!=0)
- y=td->scroll_buttons.button_box->p.y - td->scroll_buttons.button_box->h;
-
- if(y>this->current.y)
- y=this->current.y;
-
- n=(y - wr->p.y )/wr->h;
-
- btm=td->bottom_row;
- top=td->top_row;
-
- while(n-->0 && (ttop=gui_internal_widget_table_prev_row(top))!=NULL && (tbtm=gui_internal_widget_table_prev_row(btm))!=NULL) {
- btm=tbtm;
- top=ttop;
- if(btm->data==wr)
- break;
- }
- this->pressed=2;
- }
- if( top && btm && (td->top_row!=top || td->bottom_row!=btm) ) {
- gui_internal_table_hide_rows(wt->data);
- td->top_row=top;
- td->bottom_row=btm;
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_widget_render(this,wt);
- graphics_draw_mode(this->gra, draw_mode_end);
- }
-
- return;
- }
- }
-
- /* Else, just move highlight after pointer if there's nothing to scroll */
- gui_internal_highlight(this);
+static void gui_internal_motion_cb(struct gui_priv *this) {
+ this->motion_timeout_event=NULL;
+ gui_internal_gesture_ring_add(this, &(this->current));
+
+ /* Check for scrollable table below the highligted item if there's a movement with the button pressed */
+ if (this->pressed && this->highlighted) {
+ struct widget *wt=NULL;
+ struct widget *wr=NULL;
+ int dx,dy;
+
+ /* Guard against accidental scrolling when user is likely going to swipe */
+ gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
+ if(abs(dx)>abs(dy) || abs(dy)<this->icon_s)
+ return;
+
+ if(this->highlighted)
+ for(wr=this->highlighted; wr && wr->type!=widget_table_row; wr=wr->parent);
+ if(wr)
+ wt=wr->parent;
+
+ if(wt && wt->type==widget_table && (wt->state & STATE_SCROLLABLE)) {
+ struct table_data *td=wt->data;
+ GList *top=NULL;
+ GList *btm=NULL;
+ GList *ttop, *tbtm;
+
+
+
+ if(!wr || !wr->h)
+ return;
+
+ if(this->current.y < wr->p.y && wr!=td->top_row->data ) {
+ int n=(wr->p.y-this->current.y)/wr->h+1;
+
+ btm=td->bottom_row;
+ top=td->top_row;
+
+ while(n-->0 && (tbtm=gui_internal_widget_table_next_row(btm))!=NULL
+ && (ttop=gui_internal_widget_table_next_row(top))!=NULL) {
+ top=ttop;
+ btm=tbtm;
+ if(top->data==wr)
+ break;
+ }
+ this->pressed=2;
+ } else if (this->current.y > wr->p.y + wr->h ) {
+ int y=wt->p.y+wt->h-wr->h;
+ int n;
+
+ if(td->scroll_buttons.button_box && td->scroll_buttons.button_box->p.y!=0)
+ y=td->scroll_buttons.button_box->p.y - td->scroll_buttons.button_box->h;
+
+ if(y>this->current.y)
+ y=this->current.y;
+
+ n=(y - wr->p.y )/wr->h;
+
+ btm=td->bottom_row;
+ top=td->top_row;
+
+ while(n-->0 && (ttop=gui_internal_widget_table_prev_row(top))!=NULL
+ && (tbtm=gui_internal_widget_table_prev_row(btm))!=NULL) {
+ btm=tbtm;
+ top=ttop;
+ if(btm->data==wr)
+ break;
+ }
+ this->pressed=2;
+ }
+ if( top && btm && (td->top_row!=top || td->bottom_row!=btm) ) {
+ gui_internal_table_hide_rows(wt->data);
+ td->top_row=top;
+ td->bottom_row=btm;
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_widget_render(this,wt);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ }
+
+ return;
+ }
+ }
+
+ /* Else, just move highlight after pointer if there's nothing to scroll */
+ gui_internal_highlight(this);
}
//##############################################################################################################
@@ -402,229 +391,196 @@ static void gui_internal_motion_cb(struct gui_priv *this)
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gui_internal_call_highlighted(struct gui_priv *this)
-{
- if (! this->highlighted || ! this->highlighted->func)
- return;
- this->highlighted->reason=gui_internal_reason_click;
- this->highlighted->func(this, this->highlighted, this->highlighted->data);
-}
-
-void
-gui_internal_say(struct gui_priv *this, struct widget *w, int questionmark)
-{
- char *text=w->speech;
- if (! this->speech)
- return;
- if (!text)
- text=w->text;
- if (!text)
- text=w->name;
- if (text) {
- text=g_strdup_printf("%s%c", text, questionmark ? '?':'\0');
- navit_say(this->nav, text);
- g_free(text);
- }
+static void gui_internal_call_highlighted(struct gui_priv *this) {
+ if (! this->highlighted || ! this->highlighted->func)
+ return;
+ this->highlighted->reason=gui_internal_reason_click;
+ this->highlighted->func(this, this->highlighted, this->highlighted->data);
+}
+
+void gui_internal_say(struct gui_priv *this, struct widget *w, int questionmark) {
+ char *text=w->speech;
+ if (! this->speech)
+ return;
+ if (!text)
+ text=w->text;
+ if (!text)
+ text=w->name;
+ if (text) {
+ text=g_strdup_printf("%s%c", text, questionmark ? '?':'\0');
+ navit_say(this->nav, text);
+ g_free(text);
+ }
}
-void
-gui_internal_back(struct gui_priv *this, struct widget *w, void *data)
-{
- gui_internal_prune_menu_count(this, 1, 1);
+void gui_internal_back(struct gui_priv *this, struct widget *w, void *data) {
+ gui_internal_prune_menu_count(this, 1, 1);
}
-void
-gui_internal_cmd_return(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_prune_menu(this, wm->data);
+void gui_internal_cmd_return(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_prune_menu(this, wm->data);
}
-void
-gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w=this->root.children->data;
- if (w && w->menu_data && w->menu_data->href && !strcmp(w->menu_data->href,"#Main Menu"))
- gui_internal_prune_menu(this, w);
- else
- gui_internal_html_main_menu(this);
+void gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w=this->root.children->data;
+ if (w && w->menu_data && w->menu_data->href && !strcmp(w->menu_data->href,"#Main Menu"))
+ gui_internal_prune_menu(this, w);
+ else
+ gui_internal_html_main_menu(this);
}
struct widget *
-gui_internal_time_help(struct gui_priv *this)
-{
- struct widget *w,*wc,*wcn;
- char timestr[64];
- struct tm *tm;
- time_t timep;
-
- w=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
- w->bl=this->spacing;
- w->spx=this->spacing;
- w->spx=10;
- w->bl=10;
- w->br=10;
- w->bt=6;
- w->bb=6;
- if (this->flags & 64) {
- wc=gui_internal_box_new(this, gravity_right_top|orientation_vertical|flags_fill);
- wc->bl=10;
- wc->br=20;
- wc->bt=6;
- wc->bb=6;
- timep=time(NULL);
- tm=localtime(&timep);
- strftime(timestr, 64, "%H:%M %d.%m.%Y", tm);
- wcn=gui_internal_label_new(this, timestr);
- gui_internal_widget_append(wc, wcn);
- gui_internal_widget_append(w, wc);
- }
- if (this->flags & 128) {
- wcn=gui_internal_button_new_with_callback(this, _("Help"), image_new_l(this, "gui_help"), gravity_center|orientation_vertical|flags_fill, NULL, NULL);
- gui_internal_widget_append(w, wcn);
- }
- return w;
+gui_internal_time_help(struct gui_priv *this) {
+ struct widget *w,*wc,*wcn;
+ char timestr[64];
+ struct tm *tm;
+ time_t timep;
+
+ w=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
+ w->bl=this->spacing;
+ w->spx=this->spacing;
+ w->spx=10;
+ w->bl=10;
+ w->br=10;
+ w->bt=6;
+ w->bb=6;
+ if (this->flags & 64) {
+ wc=gui_internal_box_new(this, gravity_right_top|orientation_vertical|flags_fill);
+ wc->bl=10;
+ wc->br=20;
+ wc->bt=6;
+ wc->bb=6;
+ timep=time(NULL);
+ tm=localtime(&timep);
+ strftime(timestr, 64, "%H:%M %d.%m.%Y", tm);
+ wcn=gui_internal_label_new(this, timestr);
+ gui_internal_widget_append(wc, wcn);
+ gui_internal_widget_append(w, wc);
+ }
+ if (this->flags & 128) {
+ wcn=gui_internal_button_new_with_callback(this, _("Help"), image_new_l(this, "gui_help"),
+ gravity_center|orientation_vertical|flags_fill, NULL, NULL);
+ gui_internal_widget_append(w, wcn);
+ }
+ return w;
}
/**
* Applies the configuration values to this based on the settings
* specified in the configuration file (this->config) and
- * the most approriate default profile based on screen resolution.
+ * the most appropriate default profile based on screen resolution.
*
* This function should be run after this->root is setup and could
* be rerun after the window is resized.
*
* @author Steve Singer <ssinger_pg@sympatico.ca> (09/2008)
*/
-void
-gui_internal_apply_config(struct gui_priv *this)
-{
- struct gui_config_settings * current_config=0;
-
- dbg(lvl_debug,"w=%d h=%d\n", this->root.w, this->root.h);
- /*
- * Select default values from profile based on the screen.
- */
- if((this->root.w > 320 || this->root.h > 320) && this->root.w > 240 && this->root.h > 240)
- {
- if((this->root.w > 640 || this->root.h > 640) && this->root.w > 480 && this->root.h > 480 )
- {
- current_config = &config_profiles[LARGE_PROFILE];
+void gui_internal_apply_config(struct gui_priv *this) {
+ struct gui_config_settings * current_config=0;
+
+ dbg(lvl_debug,"w=%d h=%d", this->root.w, this->root.h);
+ /*
+ * Select default values from profile based on the screen.
+ */
+ if((this->root.w > 320 || this->root.h > 320) && this->root.w > 240 && this->root.h > 240) {
+ if((this->root.w > 640 || this->root.h > 640) && this->root.w > 480 && this->root.h > 480 ) {
+ current_config = &config_profiles[LARGE_PROFILE];
+ } else {
+ current_config = &config_profiles[MEDIUM_PROFILE];
+ }
+ } else {
+ current_config = &config_profiles[SMALL_PROFILE];
}
- else
- {
- current_config = &config_profiles[MEDIUM_PROFILE];
- }
- }
- else
- {
- current_config = &config_profiles[SMALL_PROFILE];
- }
-
- /*
- * Apply override values from config file
- */
- if(this->config.font_size == -1 )
- {
- this->font_size = current_config->font_size;
- }
- else
- {
- this->font_size = this->config.font_size;
- }
-
- if(this->config.icon_xs == -1 )
- {
- this->icon_xs = current_config->icon_xs;
- }
- else
- {
- this->icon_xs = this->config.icon_xs;
- }
-
- if(this->config.icon_s == -1 )
- {
- this->icon_s = current_config->icon_s;
- }
- else
- {
- this->icon_s = this->config.icon_s;
- }
- if(this->config.icon_l == -1 )
- {
- this->icon_l = current_config->icon_l;
- }
- else
- {
- this->icon_l = this->config.icon_l;
- }
- if(this->config.spacing == -1 )
- {
- this->spacing = current_config->spacing;
- }
- else
- {
- this->spacing = current_config->spacing;
- }
- if (!this->fonts[0]) {
- int i,sizes[]={100,66,50};
- for (i = 0 ; i < 3 ; i++) {
- if (this->font_name)
- this->fonts[i]=graphics_named_font_new(this->gra,this->font_name,this->font_size*sizes[i]/100,1);
- else
- this->fonts[i]=graphics_font_new(this->gra,this->font_size*sizes[i]/100,1);
- }
- }
-
-}
-
-
-
-
-
-static void
-gui_internal_cmd_set_destination(struct gui_priv *this, struct widget *wm, void *data)
-{
- char *name=data;
- dbg(lvl_info,"c=%d:0x%x,0x%x\n", wm->c.pro, wm->c.x, wm->c.y);
- navit_set_destination(this->nav, &wm->c, name, 1);
- if (this->flags & 512) {
- struct attr follow;
- follow.type=attr_follow;
- follow.u.num=180;
- navit_set_attr(this->nav, &this->osd_configuration);
- navit_set_attr(this->nav, &follow);
- navit_zoom_to_route(this->nav, 0);
- }
- gui_internal_prune_menu(this, NULL);
-}
-
-static void
-gui_internal_cmd_insert_destination_do(struct gui_priv *this, struct widget *wm, void *data) {
- char *name=data;
- int dstcount=navit_get_destination_count(this->nav)+1;
- int pos,i;
- struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
- dstcount=navit_get_destinations(this->nav,dst,dstcount);
-
- pos=dstcount-wm->datai;
- if(pos<0)
- pos=0;
-
- for(i=dstcount;i>pos;i--)
- dst[i]=dst[i-1];
-
- dst[pos]=wm->c;
- navit_add_destination_description(this->nav,&wm->c,(char*)data);
- navit_set_destinations(this->nav,dst,dstcount+1,name,1);
- gui_internal_prune_menu(this, NULL);
+
+ /*
+ * Apply override values from config file
+ */
+ if(this->config.font_size == -1 ) {
+ this->font_size = current_config->font_size;
+ } else {
+ this->font_size = this->config.font_size;
+ }
+
+ if(this->config.icon_xs == -1 ) {
+ this->icon_xs = current_config->icon_xs;
+ } else {
+ this->icon_xs = this->config.icon_xs;
+ }
+
+ if(this->config.icon_s == -1 ) {
+ this->icon_s = current_config->icon_s;
+ } else {
+ this->icon_s = this->config.icon_s;
+ }
+ if(this->config.icon_l == -1 ) {
+ this->icon_l = current_config->icon_l;
+ } else {
+ this->icon_l = this->config.icon_l;
+ }
+ if(this->config.spacing == -1 ) {
+ this->spacing = current_config->spacing;
+ } else {
+ this->spacing = this->config.spacing;
+ dbg(lvl_info, "Overriding default spacing %d with value %d provided in config file", current_config->spacing,
+ this->config.spacing);
+ }
+ if (!this->fonts[0]) {
+ int i,sizes[]= {100,66,50};
+ for (i = 0 ; i < 3 ; i++) {
+ if (this->font_name)
+ this->fonts[i]=graphics_named_font_new(this->gra,this->font_name,this->font_size*sizes[i]/100,1);
+ else
+ this->fonts[i]=graphics_font_new(this->gra,this->font_size*sizes[i]/100,1);
+ }
+ }
+
+}
+
+
+
+
+
+static void gui_internal_cmd_set_destination(struct gui_priv *this, struct widget *wm, void *data) {
+ char *name=data;
+ dbg(lvl_info,"c=%d:0x%x,0x%x", wm->c.pro, wm->c.x, wm->c.y);
+ navit_set_destination(this->nav, &wm->c, name, 1);
+ if (this->flags & 512) {
+ struct attr follow;
+ follow.type=attr_follow;
+ follow.u.num=180;
+ navit_set_attr(this->nav, &this->osd_configuration);
+ navit_set_attr(this->nav, &follow);
+ navit_zoom_to_route(this->nav, 0);
+ }
+ gui_internal_prune_menu(this, NULL);
+}
+
+static void gui_internal_cmd_insert_destination_do(struct gui_priv *this, struct widget *wm, void *data) {
+ char *name=data;
+ int dstcount=navit_get_destination_count(this->nav)+1;
+ int pos,i;
+ struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
+ dstcount=navit_get_destinations(this->nav,dst,dstcount);
+
+ pos=dstcount-wm->datai;
+ if(pos<0)
+ pos=0;
+
+ for(i=dstcount; i>pos; i--)
+ dst[i]=dst[i-1];
+
+ dst[pos]=wm->c;
+ navit_add_destination_description(this->nav,&wm->c,(char*)data);
+ navit_set_destinations(this->nav,dst,dstcount+1,name,1);
+ gui_internal_prune_menu(this, NULL);
}
/*
@@ -634,7 +590,7 @@ gui_internal_cmd_insert_destination_do(struct gui_priv *this, struct widget *wm,
* function passed as {@code cmd} will be called.
*
* Widget passed as wm parameter of the called cmd function will have item set to user chosen waypoint item. Its data will be set
- * to zero-based choosen waypoint number, counting from the route end. Coordinates to wm->c will be copied from wm_->c if wm_ is not null. Otherwise,
+ * to zero-based chosen waypoint number, counting from the route end. Coordinates to wm->c will be copied from wm_->c if wm_ is not null. Otherwise,
* waypoint coordinates will be copied to wm->c.
*
* @param this gui context
@@ -644,82 +600,79 @@ gui_internal_cmd_insert_destination_do(struct gui_priv *this, struct widget *wm,
* @param cmd Callback function which will be called on item selection
* @param data data argument to be passed to the callback function
*/
-void
-gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_, void(*cmd)(struct gui_priv *priv, struct widget *widget, void *data),void *data)
-{
- struct widget *wb,*w,*wtable,*row,*wc;
- struct map *map;
- struct map_rect *mr;
- struct item *item;
- char *text;
- int i;
- int dstcount=navit_get_destination_count(this->nav)+1;
-
- map=route_get_map(navit_get_route(this->nav));
- if(!map)
- return;
- mr = map_rect_new(map, NULL);
- if(!mr)
- return;
-
- wb=gui_internal_menu(this, title);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- if(hint)
- gui_internal_widget_append(w, gui_internal_label_new(this, hint));
- wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(w,wtable);
-
- i=0;
- while((item = map_rect_get_item(mr))!=NULL) {
- struct attr attr;
- if(item->type!=type_waypoint && item->type!=type_route_end)
- continue;
- if (item_attr_get(item, attr_label, &attr)) {
- text=g_strdup_printf(_("Waypoint %s"), map_convert_string_tmp(item->map, attr.u.str));
- } else
- continue;
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row, wc=gui_internal_button_new_with_callback(this, text,
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- cmd, data));
- wc->item=*item;
- if(wm_)
- wc->c=wm_->c;
- else {
- struct coord c;
- item_coord_get(item,&c,1);
- wc->c.x=c.x;
- wc->c.y=c.y;
- wc->c.pro=map_projection(item->map);
- }
- i++;
- wc->datai=dstcount-i;
- g_free(text);
- }
- map_rect_destroy(mr);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_insert_destination(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_select_waypoint(this, data, _("Select waypoint to insert the new one before"), wm, gui_internal_cmd_insert_destination_do, data);
-}
-
-
-
-static void
-gui_internal_cmd_set_position(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr v;
- if(data) {
- v.type=attr_vehicle;
- v.u.vehicle=NULL;
- navit_set_attr(this->nav, &v);
- }
- navit_set_position(this->nav, &wm->c);
- gui_internal_prune_menu(this, NULL);
+void gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_,
+ void(*cmd)(struct gui_priv *priv, struct widget *widget, void *data),void *data) {
+ struct widget *wb,*w,*wtable,*row,*wc;
+ struct map *map;
+ struct map_rect *mr;
+ struct item *item;
+ char *text;
+ int i;
+ int dstcount=navit_get_destination_count(this->nav)+1;
+
+ map=route_get_map(navit_get_route(this->nav));
+ if(!map)
+ return;
+ mr = map_rect_new(map, NULL);
+ if(!mr)
+ return;
+
+ wb=gui_internal_menu(this, title);
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ if(hint)
+ gui_internal_widget_append(w, gui_internal_label_new(this, hint));
+ wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ gui_internal_widget_append(w,wtable);
+
+ i=0;
+ while((item = map_rect_get_item(mr))!=NULL) {
+ struct attr attr;
+ if(item->type!=type_waypoint && item->type!=type_route_end)
+ continue;
+ if (item_attr_get(item, attr_label, &attr)) {
+ text=g_strdup_printf(_("Waypoint %s"), map_convert_string_tmp(item->map, attr.u.str));
+ } else
+ continue;
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row, wc=gui_internal_button_new_with_callback(this, text,
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ cmd, data));
+ wc->item=*item;
+ if(wm_)
+ wc->c=wm_->c;
+ else {
+ struct coord c;
+ item_coord_get(item,&c,1);
+ wc->c.x=c.x;
+ wc->c.y=c.y;
+ wc->c.pro=map_projection(item->map);
+ }
+ i++;
+ wc->datai=dstcount-i;
+ g_free(text);
+ }
+ map_rect_destroy(mr);
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_insert_destination(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_select_waypoint(this, data, _("Select waypoint to insert the new one before"), wm,
+ gui_internal_cmd_insert_destination_do, data);
+}
+
+
+
+static void gui_internal_cmd_set_position(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr v;
+ if(data) {
+ v.type=attr_vehicle;
+ v.u.vehicle=NULL;
+ navit_set_attr(this->nav, &v);
+ }
+ navit_set_position(this->nav, &wm->c);
+ gui_internal_prune_menu(this, NULL);
}
@@ -731,14 +684,12 @@ gui_internal_cmd_set_position(struct gui_priv *this, struct widget *wm, void *da
* @brief Generic notification function for Editable widgets to call Another widget notification function when Enter is pressed in editable field.
* The Editable widget should have data member pointing to the Another widget.
*/
-void
-gui_internal_call_linked_on_finish(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (wm->reason==gui_internal_reason_keypress_finish && data) {
- struct widget *w=data;
- if(w->func)
- w->func(this, w, w->data);
- }
+void gui_internal_call_linked_on_finish(struct gui_priv *this, struct widget *wm, void *data) {
+ if (wm->reason==gui_internal_reason_keypress_finish && data) {
+ struct widget *w=data;
+ if(w->func)
+ w->func(this, w, w->data);
+ }
}
struct widget * gui_internal_keyboard(struct gui_priv *this, int mode);
@@ -747,345 +698,313 @@ struct widget * gui_internal_keyboard(struct gui_priv *this, int mode);
struct widget * gui_internal_keyboard_show_native(struct gui_priv *this, struct widget *w, int mode, char *lang);
-static void
-gui_internal_cmd_delete_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_delete_bookmark(mattr.u.bookmarks,wm->text);
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
+static void gui_internal_cmd_delete_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_delete_bookmark(mattr.u.bookmarks,wm->text);
+ l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
+ gui_internal_prune_menu(this, l->data);
}
/**
- * Get a utf-8 string, return the same prepared for case insensitive search. Result should be g_free()d after use.
+ * @brief Remove the case in a string
+ *
+ * @warning Result should be g_free()d after use.
+ *
+ * @param s The input utf-8 string
+ * @return An equivalent string prepared for case insensitive search
+ */
+char *removecase(char *s) {
+ char *r;
+ r=linguistics_casefold(s);
+ return r;
+}
+
+/**
+ * @brief Apply the command "View on Map", centers the map on the selected point and highlight this point using
+ * type_found_item style
+ *
+ * @param this The GUI context
+ * @param wm The widget that points to this function as a callback
+ * @param data Private data provided during callback (unused)
*/
-char *
-removecase(char *s)
-{
- char *r;
- r=linguistics_casefold(s);
- return r;
-}
-
-static void
-gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (wm->item.type != type_none) {
- enum item_type type;
- if (wm->item.type < type_line)
- type=type_selected_point;
- else if (wm->item.type < type_area)
- type=type_selected_point;
- else
- type=type_selected_area;
- graphics_clear_selection(this->gra, NULL);
- graphics_add_selection(this->gra, &wm->item, type, NULL);
- }
- navit_set_center(this->nav, &wm->c, 1);
- gui_internal_prune_menu(this, NULL);
-}
-
-
-static void
-gui_internal_cmd_view_attribute_details(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb;
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- char *text,*url;
- int i;
-
- text=g_strdup_printf("Attribute %s",wm->name);
- wb=gui_internal_menu(this, text);
- g_free(text);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- for (i = 0 ; i < wm->datai ; i++) {
- item_attr_get(item, attr_any, &attr);
- }
- if (item_attr_get(item, attr_any, &attr)) {
- url=NULL;
- switch (attr.type) {
- case attr_osm_nodeid:
- url=g_strdup_printf("http://www.openstreetmap.org/browse/node/"LONGLONG_FMT"\n",*attr.u.num64);
- break;
- case attr_osm_wayid:
- url=g_strdup_printf("http://www.openstreetmap.org/browse/way/"LONGLONG_FMT"\n",*attr.u.num64);
- break;
- case attr_osm_relationid:
- url=g_strdup_printf("http://www.openstreetmap.org/browse/relation/"LONGLONG_FMT"\n",*attr.u.num64);
- break;
- default:
- break;
- }
- if (url) {
- gui_internal_widget_append(w,
- wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_in_browser, NULL));
- wb->name=url;
- }
- }
- map_rect_destroy(mr);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_view_attributes(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb;
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- char *text;
- int count=0;
-
- dbg(lvl_info,"item=%p 0x%x 0x%x\n", wm->item.map,wm->item.id_hi, wm->item.id_lo);
- wb=gui_internal_menu(this, "Attributes");
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- dbg(lvl_info,"item=%p\n", item);
- if (item) {
- text=g_strdup_printf("%s:%s", _("Item type"), item_to_name(item->type));
- gui_internal_widget_append(w,
- wb=gui_internal_button_new(this, text,
- NULL, gravity_left_center|orientation_horizontal|flags_fill));
- wb->name=g_strdup(text);
- wb->item=wm->item;
- g_free(text);
- while(item_attr_get(item, attr_any, &attr)) {
- char *attrtxt;
- text=g_strdup_printf("%s:%s", attr_to_name(attr.type), attrtxt=attr_to_text(&attr, wm->item.map, 1));
- g_free(attrtxt);
- gui_internal_widget_append(w,
- wb=gui_internal_button_new_with_callback(this, text,
- NULL, gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_attribute_details, NULL));
- wb->name=g_strdup(text);
- wb->item=wm->item;
- wb->datai=count++;
- g_free(text);
- }
- text=g_strdup_printf("%s:0x%x,0x%x", "ID", item->id_hi, item->id_lo);
- gui_internal_widget_append(w,
- wb=gui_internal_button_new(this, text,
- NULL, gravity_left_center|orientation_horizontal|flags_fill));
- wb->name=text;
- wb->item=wm->item;
- }
- map_rect_destroy(mr);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- char *cmd=NULL;
-
- if (!wm->name) {
- dbg(lvl_info,"item=%p 0x%x 0x%x\n", wm->item.map,wm->item.id_hi, wm->item.id_lo);
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- dbg(lvl_info,"item=%p\n", item);
- if (item) {
- while(item_attr_get(item, attr_url_local, &attr)) {
- if (! cmd)
- cmd=g_strdup_printf("navit-browser.sh '%s' &",map_convert_string_tmp(item->map,attr.u.str));
- }
- }
- map_rect_destroy(mr);
- } else {
- cmd=g_strdup_printf("navit-browser.sh '%s' &",wm->name);
- }
- if (cmd) {
+static void gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *wm, void *data) {
+
+ struct widget *w;
+ struct widget *wr;
+ struct widget *wi;
+ char *label;
+
+ if (wm->item.type != type_none) {
+ enum item_type type;
+ if (wm->item.type < type_line)
+ type=type_selected_point;
+ else if (wm->item.type < type_area)
+ type=type_selected_point;
+ else
+ type=type_selected_area;
+ graphics_clear_selection(this->gra, NULL);
+ graphics_add_selection(this->gra, &wm->item, type, NULL);
+ } else {
+ if (wm->item.priv_data)
+ label = wm->item.priv_data; /* Use the label of the point to view on map */
+ else
+ label = g_strdup("");
+ w = gui_internal_widget_table_new(this, 0, 0); /* Create a basic table */
+ gui_internal_widget_append(w,wr=gui_internal_widget_table_row_new(this,0)); /* In this table, add one row */
+ gui_internal_widget_append(wr,wi=gui_internal_box_new_with_label(this,0,
+ label)); /* That row contains a widget of type widget_box */
+ wi->name = label; /* Use the label of the point to view on map */
+ wi->c.x=wm->c.x; /* Use the coordinates of the point to place it on the map */
+ wi->c.y=wm->c.y;
+ gui_internal_prepare_search_results_map(this, w, NULL);
+ g_free(label);
+ wi->name = NULL;
+ gui_internal_widget_destroy(this, w);
+ }
+ navit_set_center(this->nav, &wm->c, 1);
+ gui_internal_prune_menu(this, NULL);
+}
+
+
+static void gui_internal_cmd_view_attribute_details(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb;
+ struct map_rect *mr;
+ struct item *item;
+ struct attr attr;
+ char *text,*url;
+ int i;
+
+ text=g_strdup_printf("Attribute %s",wm->name);
+ wb=gui_internal_menu(this, text);
+ g_free(text);
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ mr=map_rect_new(wm->item.map, NULL);
+ item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
+ for (i = 0 ; i < wm->datai ; i++) {
+ item_attr_get(item, attr_any, &attr);
+ }
+ if (item_attr_get(item, attr_any, &attr)) {
+ url=NULL;
+ switch (attr.type) {
+ case attr_osm_nodeid:
+ url=g_strdup_printf("http://www.openstreetmap.org/browse/node/"LONGLONG_FMT"\n",*attr.u.num64);
+ break;
+ case attr_osm_wayid:
+ url=g_strdup_printf("http://www.openstreetmap.org/browse/way/"LONGLONG_FMT"\n",*attr.u.num64);
+ break;
+ case attr_osm_relationid:
+ url=g_strdup_printf("http://www.openstreetmap.org/browse/relation/"LONGLONG_FMT"\n",*attr.u.num64);
+ break;
+ default:
+ break;
+ }
+ if (url) {
+ gui_internal_widget_append(w,
+ wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_in_browser, NULL));
+ wb->name=url;
+ }
+ }
+ map_rect_destroy(mr);
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_view_attributes(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb;
+ struct map_rect *mr;
+ struct item *item;
+ struct attr attr;
+ char *text;
+ int count=0;
+
+ dbg(lvl_info,"item=%p 0x%x 0x%x", wm->item.map,wm->item.id_hi, wm->item.id_lo);
+ wb=gui_internal_menu(this, "Attributes");
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ mr=map_rect_new(wm->item.map, NULL);
+ item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
+ dbg(lvl_info,"item=%p", item);
+ if (item) {
+ text=g_strdup_printf("%s:%s", _("Item type"), item_to_name(item->type));
+ gui_internal_widget_append(w,
+ wb=gui_internal_button_new(this, text,
+ NULL, gravity_left_center|orientation_horizontal|flags_fill));
+ wb->name=g_strdup(text);
+ wb->item=wm->item;
+ g_free(text);
+ while(item_attr_get(item, attr_any, &attr)) {
+ char *attrtxt;
+ text=g_strdup_printf("%s:%s", attr_to_name(attr.type), attrtxt=attr_to_text(&attr, wm->item.map, 1));
+ g_free(attrtxt);
+ gui_internal_widget_append(w,
+ wb=gui_internal_button_new_with_callback(this, text,
+ NULL, gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_attribute_details, NULL));
+ wb->name=g_strdup(text);
+ wb->item=wm->item;
+ wb->datai=count++;
+ g_free(text);
+ }
+ text=g_strdup_printf("%s:0x%x,0x%x", "ID", item->id_hi, item->id_lo);
+ gui_internal_widget_append(w,
+ wb=gui_internal_button_new(this, text,
+ NULL, gravity_left_center|orientation_horizontal|flags_fill));
+ wb->name=text;
+ wb->item=wm->item;
+ }
+ map_rect_destroy(mr);
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data) {
+ struct map_rect *mr;
+ struct item *item;
+ struct attr attr;
+ char *cmd=NULL;
+
+ if (!wm->name) {
+ dbg(lvl_info,"item=%p 0x%x 0x%x", wm->item.map,wm->item.id_hi, wm->item.id_lo);
+ mr=map_rect_new(wm->item.map, NULL);
+ item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
+ dbg(lvl_info,"item=%p", item);
+ if (item) {
+ while(item_attr_get(item, attr_url_local, &attr)) {
+ if (! cmd)
+ cmd=g_strdup_printf("navit-browser.sh '%s' &",map_convert_string_tmp(item->map,attr.u.str));
+ }
+ }
+ map_rect_destroy(mr);
+ } else {
+ cmd=g_strdup_printf("navit-browser.sh '%s' &",wm->name);
+ }
+ if (cmd) {
#ifdef HAVE_SYSTEM
- system(cmd);
+ system(cmd);
#else
- dbg(lvl_error,"Error: External commands were disabled during compilation, cannot call '%s'.\n",cmd);
+ dbg(lvl_error,"Error: External commands were disabled during compilation, cannot call '%s'.",cmd);
#endif
- g_free(cmd);
- }
+ g_free(cmd);
+ }
}
+/**
+ * @brief Create a map rect highlighting one of multiple points provided in argument @data and displayed using
+ * the style type_found_item (name for each point will also be displayed aside)
+ *
+ * @param this The GUI context
+ * @param table A table widget or any of its descendants. The table contain results to place on the map.
+ * Providing NULL here will remove all previous results from the map.
+ * @param[out] r The minimum rect focused to contain all results placed on the map (or unchanged if r==NULL)
+ */
+static void gui_internal_prepare_search_results_map(struct gui_priv *this, struct widget *table, struct coord_rect *r) {
+ struct widget *w;
+ GList *l; /* Cursor in the list of widgets */
+ GList* list = NULL; /* List we will create to store the points to add to the result map */
+ struct attr a;
+ GList* p;
+
+ this->results_map_population=0;
+
+ /* Find the table to populate the map */
+ for(w=table; w && w->type!=widget_table; w=w->parent);
+
+ if(!w) {
+ dbg(lvl_warning,"Can't find the results table - only map clean up is done.");
+ } else {
+ /* Create a GList containing all search results */
+ for(l=w->children; l; l=g_list_next(l)) {
+ struct widget *wr=l->data;
+ if(wr->type==widget_table_row) {
+ struct widget *wi=wr->children->data;
+ if(wi->name==NULL)
+ continue;
+ struct lcoord *result = g_new0(struct lcoord, 1);
+ result->c.x=wi->c.x;
+ result->c.y=wi->c.y;
+ result->label=g_strdup(wi->name);
+ list = g_list_prepend(list, result);
+ }
+ }
+ }
+ this->results_map_population=navit_populate_search_results_map(this->nav, list, r);
+ /* Parse the GList starting at list and free all payloads before freeing the list itself */
+ if (list) {
+ for(p=list; p; p=g_list_next(p)) {
+ if (((struct lcoord *)(p->data))->label)
+ g_free(((struct lcoord *)(p->data))->label);
+ }
+ }
+ g_list_free(list);
+ if(!this->results_map_population)
+ return;
+ a.type=attr_orientation;
+ a.u.num=0;
+ navit_set_attr(this->nav,&a); /* Set orientation to North */
+ if (r) {
+ navit_zoom_to_rect(this->nav,r);
+ gui_internal_prune_menu(this, NULL);
+ }
+}
-/*
- * @brief Transfers search results to a map.
+/**
+ * @brief Apply the command "Show results on the map", highlighting one of multiple points using
+ * type_found_item style (with their respective name placed aside)
*
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data (pointer to the table widget containing results, or NULL to clean the result map without adding any new data).
+ * @param this The GUI context
+ * @param wm The widget that called us
+ * @param data Private data provided during callback (should be a pointer to the table widget containing results,
+ * or NULL to remove all previous results from the map).
*/
-static void
-gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w;
- struct mapset *ms;
- struct map *map;
- struct map_rect *mr;
- struct item *item;
- GList *l;
- struct coord_rect r;
- struct attr a;
- int count;
-
- ms=navit_get_mapset(this->nav);
-
- if(!ms)
- return;
-
- map=mapset_get_map_by_name(ms, "search_results");
- if(!map) {
- struct attr *attrs[10], attrmap;
- enum attr_type types[]={attr_position_longitude,attr_position_latitude,attr_label,attr_none};
- int i;
-
- attrs[0]=g_new0(struct attr,1);
- attrs[0]->type=attr_type;
- attrs[0]->u.str="csv";
-
- attrs[1]=g_new0(struct attr,1);
- attrs[1]->type=attr_name;
- attrs[1]->u.str="search_results";
-
- attrs[2]=g_new0(struct attr,1);
- attrs[2]->type=attr_charset;
- attrs[2]->u.str="utf-8";
-
- attrs[3]=g_new0(struct attr,1);
- attrs[3]->type=attr_item_type;
- attrs[3]->u.num=type_found_item;
-
- attrs[4]=g_new0(struct attr,1);
- attrs[4]->type=attr_attr_types;
- attrs[4]->u.attr_types=types;
- attrs[5]=NULL;
-
- attrmap.type=attr_map;
- map=attrmap.u.map=map_new(NULL,attrs);
- if(map)
- mapset_add_attr(ms,&attrmap);
-
- for(i=0;attrs[i];i++)
- g_free(attrs[i]);
-
- }
-
- if(!map)
- return;
-
-
- mr = map_rect_new(map, NULL);
-
- if(!mr)
- return;
-
- /* Clean the map */
- while((item = map_rect_get_item(mr))!=NULL) {
- item_type_set(item,type_none);
- }
-
- this->results_map_population=0;
-
- /* Find the table to pupulate the map */
- for(w=data; w && w->type!=widget_table;w=w->parent);
-
- if(!w) {
- map_rect_destroy(mr);
- dbg(lvl_warning,"Can't find the results table - only map clean up is done.\n");
- return;
- }
-
- /* Populate the map with search results*/
- for(l=w->children, count=0;l;l=g_list_next(l)) {
- struct widget *wr=l->data;
- if(wr->type==widget_table_row) {
- struct widget *wi=wr->children->data;
- struct item* it;
- if(wi->name==NULL)
- continue;
- dbg(lvl_info,"%s\n",wi->name);
- it=map_rect_create_item(mr,type_found_item);
- if(it) {
- struct coord c;
- struct attr a;
- c.x=wi->c.x;
- c.y=wi->c.y;
- item_coord_set(it, &c, 1, change_mode_modify);
- a.type=attr_label;
- a.u.str=wi->name;
- item_attr_set(it, &a, change_mode_modify);
- if(!count++)
- r.lu=r.rl=c;
- else
- coord_rect_extend(&r,&c);
- }
- }
- }
- map_rect_destroy(mr);
- if(!count)
- return;
- a.type=attr_orientation;
- a.u.num=0;
- navit_set_attr(this->nav,&a);
- navit_zoom_to_rect(this->nav,&r);
- gui_internal_prune_menu(this, NULL);
- this->results_map_population=count;
+static void gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget *wm, void *data) {
+ struct coord_rect r;
+
+ gui_internal_prepare_search_results_map(this, (struct widget *)data, &r);
}
/*
- * @brief Removes search results from a map.
+ * @brief Removes all existing search results from a map.
*
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data
+ * @param this The GUI context
+ * @param wm The widget that called us
+ * @param data Private data (unused).
*/
-static void
-gui_internal_cmd_results_map_clean(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_cmd_results_to_map(this,wm,NULL);
- gui_internal_prune_menu(this, NULL);
- navit_draw(this->nav);
-}
-
-static void
-gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widget *wm, void *data)
-{
- int dstcount=navit_get_destination_count(this->nav);
- int i;
- struct map_rect *mr;
- struct item *item;
- struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
- dstcount=navit_get_destinations(this->nav,dst,dstcount);
- mr=map_rect_new(wm->item.map, NULL);
- i=0;
- while((item=map_rect_get_item(mr))!=NULL) {
- struct coord c;
- if(item->type!=type_waypoint && item->type!=type_route_end)
- continue;
- if(item_is_equal_id(*item,wm->item))
- continue;
- item_coord_get_pro(item,&c,1,projection_mg);
- dst[i].x=c.x;
- dst[i].y=c.y;
- dst[i].pro=projection_mg;
- i++;
- }
- map_rect_destroy(mr);
- navit_set_destinations(this->nav,dst,i,NULL,1);
- gui_internal_prune_menu(this, NULL);
+static void gui_internal_cmd_results_map_clean(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_cmd_results_to_map(this,wm,NULL);
+ gui_internal_prune_menu(this, NULL);
+ navit_draw(this->nav);
+}
+
+static void gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widget *wm, void *data) {
+ int dstcount=navit_get_destination_count(this->nav);
+ int i;
+ struct map_rect *mr;
+ struct item *item;
+ struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
+ dstcount=navit_get_destinations(this->nav,dst,dstcount);
+ mr=map_rect_new(wm->item.map, NULL);
+ i=0;
+ while((item=map_rect_get_item(mr))!=NULL) {
+ struct coord c;
+ if(item->type!=type_waypoint && item->type!=type_route_end)
+ continue;
+ if(item_is_equal_id(*item,wm->item))
+ continue;
+ item_coord_get_pro(item,&c,1,projection_mg);
+ dst[i].x=c.x;
+ dst[i].y=c.y;
+ dst[i].pro=projection_mg;
+ i++;
+ }
+ map_rect_destroy(mr);
+ navit_set_destinations(this->nav,dst,i,NULL,1);
+ gui_internal_prune_menu(this, NULL);
}
@@ -1097,10 +1016,10 @@ gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widget *wm, void
* argument or in WGS84 coordinates (i.e. latitude and longitude in degrees) via the {@code g_in}
* argument. One of these must be supplied, the other should be {@code NULL}.
*
- * @param this The internal GUI instance
+ * @param this The GUI context
* @param pc_in Projected coordinates of the position
* @param g_in WGS84 coordinates of the position
- * @param wm
+ * @param wm The widget that points to this function as a callback
* @param name The display name for the position
* @param flags Flags specifying the operations available from the GUI
*/
@@ -1119,275 +1038,296 @@ gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widget *wm, void
* 2048: "Show search results on the map"
* TODO define constants for these values
*/
-void
-gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in, struct widget *wm, const char *name, int flags)
-{
- struct widget *wb,*w,*wtable,*row,*wc,*wbc,*wclosest=NULL;
- struct coord_geo g;
- struct pcoord pc;
- struct coord c;
- char *coord;
-
- if (pc_in) {
- pc=*pc_in;
- c.x=pc.x;
- c.y=pc.y;
- dbg(lvl_info,"x=0x%x y=0x%x\n", c.x, c.y);
- transform_to_geo(pc.pro, &c, &g);
- } else if (g_in) {
- struct attr attr;
- if (!navit_get_attr(this->nav, attr_projection, &attr, NULL))
- return;
- g=*g_in;
- pc.pro=attr.u.projection;
- transform_from_geo(pc.pro, &g, &c);
- pc.x=c.x;
- pc.y=c.y;
- } else
- return;
-
- wb=gui_internal_menu(this, name);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- coord=gui_internal_coordinates(&pc, ' ');
- gui_internal_widget_append(w, gui_internal_label_new(this, coord));
- g_free(coord);
- wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(w,wtable);
-
- if ((flags & 1) && wm) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wc=gui_internal_button_new_with_callback(this, _("Streets"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_search_street_in_town, wm));
- wc->item=wm->item;
- wc->selection_id=wm->selection_id;
- }
- if ((flags & 2) && wm) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wc=gui_internal_button_new_with_callback(this, _("House numbers"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_search_house_number_in_street, wm));
- wc->item=wm->item;
- wc->selection_id=wm->selection_id;
- }
- if ((flags & 4) && wm) {
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- if (item) {
- if (item_attr_get(item, attr_description, &attr))
- gui_internal_widget_append(w, gui_internal_label_new(this, map_convert_string_tmp(item->map,attr.u.str)));
- if (item_attr_get(item, attr_url_local, &attr)) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_in_browser, NULL));
- wb->item=wm->item;
- }
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wb=gui_internal_button_new_with_callback(this, _("View Attributes"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_attributes, NULL));
- wb->item=wm->item;
- }
- map_rect_destroy(mr);
- }
- if (flags & 8) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Set as destination"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_destination, g_strdup(name)));
- wbc->data_free=g_free_func;
- wbc->c=pc;
- if(navit_get_destination_count(this->nav)>=1) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Visit before..."),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_insert_destination, g_strdup(name)));
- wbc->data_free=g_free_func;
- wbc->c=pc;
- }
- }
- if (flags & 16) {
- const char *text;
- struct attr vehicle, source;
- int deactivate=0;
- if (navit_get_attr(this->nav, attr_vehicle, &vehicle, NULL) && vehicle.u.vehicle &&
- !(vehicle_get_attr(vehicle.u.vehicle, attr_source, &source, NULL) && source.u.str && !strcmp("demo://",source.u.str)))
- deactivate=1;
-
- text=deactivate? _("Set as position (and deactivate vehicle)") : _("Set as position");
-
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, text,
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_position, (void*)(long)deactivate));
- wbc->c=pc;
- }
- if (flags & 32) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Add as bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_add_bookmark2, g_strdup(name)));
- wbc->data_free=g_free_func;
- wbc->c=pc;
- }
+void gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in,
+ struct widget *wm, const char *name, int flags) {
+ struct widget *wb,*w,*wtable,*row,*wc,*wbc,*wclosest=NULL;
+ struct coord_geo g;
+ struct pcoord pc;
+ struct coord c;
+ char *coord;
+
+ if (pc_in) {
+ pc=*pc_in;
+ c.x=pc.x;
+ c.y=pc.y;
+ dbg(lvl_info,"x=0x%x y=0x%x", c.x, c.y);
+ transform_to_geo(pc.pro, &c, &g);
+ } else if (g_in) {
+ struct attr attr;
+ if (!navit_get_attr(this->nav, attr_projection, &attr, NULL))
+ return;
+ g=*g_in;
+ pc.pro=attr.u.projection;
+ transform_from_geo(pc.pro, &g, &c);
+ pc.x=c.x;
+ pc.y=c.y;
+ } else
+ return;
+
+ wb=gui_internal_menu(this, name);
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ coord=gui_internal_coordinates(&pc, ' ');
+ gui_internal_widget_append(w, gui_internal_label_new(this, coord));
+ g_free(coord);
+ wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ gui_internal_widget_append(w,wtable);
+
+ if ((flags & 1) && wm) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wc=gui_internal_button_new_with_callback(this, _("Streets"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_search_street_in_town, wm));
+ wc->item=wm->item;
+ wc->selection_id=wm->selection_id;
+ }
+ if ((flags & 2) && wm) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wc=gui_internal_button_new_with_callback(this, _("House numbers"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_search_house_number_in_street, wm));
+ wc->item=wm->item;
+ wc->selection_id=wm->selection_id;
+ }
+ if ((flags & 4) && wm) {
+ struct map_rect *mr;
+ struct item *item;
+ struct attr attr;
+ mr=map_rect_new(wm->item.map, NULL);
+ item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
+ if (item) {
+ if (item_attr_get(item, attr_description, &attr))
+ gui_internal_widget_append(w, gui_internal_label_new(this, map_convert_string_tmp(item->map,attr.u.str)));
+ if (item_attr_get(item, attr_url_local, &attr)) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_in_browser, NULL));
+ wb->item=wm->item;
+ }
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wb=gui_internal_button_new_with_callback(this, _("View Attributes"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_attributes, NULL));
+ wb->item=wm->item;
+ }
+ map_rect_destroy(mr);
+ }
+ if (flags & 8) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Set as destination"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_set_destination, g_strdup(name)));
+ wbc->data_free=g_free_func;
+ wbc->c=pc;
+ if(navit_get_destination_count(this->nav)>=1) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Visit before..."),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_insert_destination, g_strdup(name)));
+ wbc->data_free=g_free_func;
+ wbc->c=pc;
+ }
+ }
+ if (flags & 16) {
+ const char *text;
+ struct attr vehicle, source;
+ int deactivate=0;
+ if (navit_get_attr(this->nav, attr_vehicle, &vehicle, NULL) && vehicle.u.vehicle &&
+ !(vehicle_get_attr(vehicle.u.vehicle, attr_source, &source, NULL) && source.u.str && !strcmp("demo://",source.u.str)))
+ deactivate=1;
+
+ text=deactivate? _("Set as position (and deactivate vehicle)") : _("Set as position");
+
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, text,
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_set_position, (void*)(long)deactivate));
+ wbc->c=pc;
+ }
+ if (flags & 32) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Add as bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_add_bookmark2, g_strdup(name)));
+ wbc->data_free=g_free_func;
+ wbc->c=pc;
+ }
#ifndef _MSC_VER
//POIs are not operational under MSVC yet
- if (flags & 64) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("POIs"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_pois, NULL));
- wbc->c=pc;
- }
+ if (flags & 64) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("POIs"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_pois, NULL));
+ wbc->c=pc;
+ }
#endif /* _MSC_VER */
#if 0
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new(this, "Add to tour",
- image_new_o(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ gui_internal_button_new(this, "Add to tour",
+ image_new_o(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill));
#endif
- if (flags & 128) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("View on map"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_on_map, NULL));
- wbc->c=pc;
- if ((flags & 4) && wm)
- wbc->item=wm->item;
- else
- wbc->item.type=type_none;
- }
- if(flags & 256 && this->results_map_population) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Remove search results from the map"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_results_map_clean, NULL));
- wbc->data=wm;
- }
- if(flags & 2048) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Show results on the map"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_results_to_map, NULL));
- wbc->data=wm;
- }
- if ((flags & 256) || (flags & 1024)) {
- struct displaylist_handle *dlh;
- struct displaylist *display;
- struct attr attr;
- struct point p;
- struct transformation *trans;
-
- char *text;
- struct map_selection *sel;
- GList *l, *ll;
-
- c.x=pc.x;
- c.y=pc.y;
-
- trans=navit_get_trans(this->nav);
- transform(trans,pc.pro,&c,&p,1,0,0,0);
- display=navit_get_displaylist(this->nav);
- dlh=graphics_displaylist_open(display);
- sel=displaylist_get_selection(display);
- l=displaylist_get_clicked_list(display, &p, this->radius);
- for(ll=l;ll;ll=g_list_next(ll)) {
- struct displayitem *di;
- struct item *item;
- struct map_rect *mr;
- struct item *itemo;
-
- di=(struct displayitem*)ll->data;
- item=graphics_displayitem_get_item(di);
-
- mr=map_rect_new(item->map, sel);
- itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- if(!itemo) {
- map_rect_destroy(mr);
- continue;
- }
- if (item_attr_get(itemo, attr_label, &attr)) {
- text=g_strdup(map_convert_string_tmp(itemo->map, attr.u.str));
- } else
- text=g_strdup(item_to_name(item->type));
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row, wc=gui_internal_cmd_pois_item(this, NULL, itemo, NULL, NULL, -1, text));
- wc->c=pc;
- g_free(wc->name);
- wc->name=g_strdup(text);
- wc->item=*itemo;
- g_free(text);
- map_rect_destroy(mr);
- if(!wclosest)
- wclosest=wc;
-
- }
- g_list_free(l);
- map_selection_destroy(sel);
- graphics_displaylist_close(dlh);
- }
- if (flags & 512) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Cut Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_cut_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Copy Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_copy_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Rename Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_rename_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Paste Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_paste_bookmark, NULL));
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Delete Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_delete_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- }
-
- if (wm && (wm->item.type==type_waypoint || wm->item.type==type_route_end)) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Delete waypoint"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_delete_waypoint, NULL));
- wbc->item=wm->item;
- }
-
- gui_internal_menu_render(this);
-
- if((flags & 1024) && wclosest)
- gui_internal_cmd_view_attributes(this,wclosest,wclosest->data);
+ if (flags & 128) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("View on map"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_view_on_map, NULL));
+ wbc->c=pc;
+ if ((flags & 4) && wm) {
+ wbc->item=wm->item;
+ } else {
+ wbc->item.type=type_none;
+ wbc->item.priv_data = g_strdup(name); /* Will be freed up by gui_internal_cmd_view_on_map() */
+ }
+ }
+ if(flags & 256 && this->results_map_population) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Remove search results from the map"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_results_map_clean, NULL));
+ wbc->data=wm;
+ }
+ if(flags & 2048) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Show results on the map"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_results_to_map, NULL));
+ wbc->data=wm;
+ }
+ if ((flags & 256) || (flags & 1024)) {
+ struct displaylist_handle *dlh;
+ struct displaylist *display;
+ struct attr attr;
+ struct point p;
+ struct transformation *trans;
+
+ char *text;
+ struct map_selection *sel;
+ GList *l, *ll;
+
+ c.x=pc.x;
+ c.y=pc.y;
+
+ trans=navit_get_trans(this->nav);
+ transform(trans,pc.pro,&c,&p,1,0,0,0);
+ display=navit_get_displaylist(this->nav);
+ dlh=graphics_displaylist_open(display);
+ sel=displaylist_get_selection(display);
+ l=displaylist_get_clicked_list(display, &p, this->radius);
+ for(ll=l; ll; ll=g_list_next(ll)) {
+ struct displayitem *di;
+ struct item *item;
+ struct map_rect *mr;
+ struct item *itemo;
+
+ di=(struct displayitem*)ll->data;
+ item=graphics_displayitem_get_item(di);
+
+ mr=map_rect_new(item->map, sel);
+ itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ if(!itemo) {
+ map_rect_destroy(mr);
+ continue;
+ }
+ if (item_attr_get(itemo, attr_label, &attr)) {
+ text=g_strdup(map_convert_string_tmp(itemo->map, attr.u.str));
+ } else
+ text=g_strdup(item_to_name(item->type));
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row, wc=gui_internal_cmd_pois_item(this, NULL, itemo, NULL, NULL, -1, text));
+ wc->c=pc;
+ g_free(wc->name);
+ wc->name=g_strdup(text);
+ wc->item=*itemo;
+ g_free(text);
+ map_rect_destroy(mr);
+ if(!wclosest)
+ wclosest=wc;
+
+ }
+ g_list_free(l);
+ map_selection_destroy(sel);
+ graphics_displaylist_close(dlh);
+ }
+ if (flags & 512) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Cut Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_cut_bookmark, NULL));
+ wbc->text=g_strdup(wm->text);
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Copy Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_copy_bookmark, NULL));
+ wbc->text=g_strdup(wm->text);
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Rename Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_rename_bookmark, NULL));
+ wbc->text=g_strdup(wm->text);
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Paste Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_paste_bookmark, NULL));
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Delete Bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_delete_bookmark, NULL));
+ wbc->text=g_strdup(wm->text);
+ }
+
+ if (wm && (wm->item.type==type_waypoint || wm->item.type==type_route_end)) {
+ gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ wbc=gui_internal_button_new_with_callback(this, _("Delete waypoint"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_delete_waypoint, NULL));
+ wbc->item=wm->item;
+ }
+
+ gui_internal_menu_render(this);
+
+ if((flags & 1024) && wclosest)
+ gui_internal_cmd_view_attributes(this,wclosest,wclosest->data);
}
@@ -1403,60 +1343,58 @@ gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct
9 Item from the POI list
*/
-void
-gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data)
-{
- int flags;
-
- if(!data)
- data=wm->data;
-
- switch ((long) data) {
- case 0:
- flags=8|16|32|64|128|256;
- break;
- case 1:
- flags=8|16|32|64|256;
- break;
- case 2:
- flags=4|8|16|32|64|128;
- break;
- case 3:
- flags=1|4|8|16|32|64|128|2048;
- flags &= this->flags_town;
- break;
- case 4:
- gui_internal_search_town_in_country(this, wm);
- return;
- case 5:
- flags=2|8|16|32|64|128|2048;
- flags &= this->flags_street;
- break;
- case 6:
- flags=8|16|32|64|128|2048;
- flags &= this->flags_house_number;
- break;
- case 7:
- flags=8|16|64|128|512;
- break;
- case 8:
- flags=8|16|32|64|128;
- break;
- case 9:
- flags=4|8|16|32|64|128|2048;
- break;
- default:
- return;
- }
- switch (flags) {
- case 2:
- gui_internal_search_house_number_in_street(this, wm, NULL);
- return;
- case 8:
- gui_internal_cmd_set_destination(this, wm, NULL);
- return;
- }
- gui_internal_cmd_position_do(this, &wm->c, NULL, wm, wm->name ? wm->name : wm->text, flags);
+void gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data) {
+ int flags;
+
+ if(!data)
+ data=wm->data;
+
+ switch ((long) data) {
+ case 0:
+ flags=8|16|32|64|128|256;
+ break;
+ case 1:
+ flags=8|16|32|64|256;
+ break;
+ case 2:
+ flags=4|8|16|32|64|128;
+ break;
+ case 3:
+ flags=1|4|8|16|32|64|128|2048;
+ flags &= this->flags_town;
+ break;
+ case 4:
+ gui_internal_search_town_in_country(this, wm);
+ return;
+ case 5:
+ flags=2|8|16|32|64|128|2048;
+ flags &= this->flags_street;
+ break;
+ case 6:
+ flags=8|16|32|64|128|2048;
+ flags &= this->flags_house_number;
+ break;
+ case 7:
+ flags=8|16|64|128|512;
+ break;
+ case 8:
+ flags=8|16|32|64|128;
+ break;
+ case 9:
+ flags=4|8|16|32|64|128|2048;
+ break;
+ default:
+ return;
+ }
+ switch (flags) {
+ case 2:
+ gui_internal_search_house_number_in_street(this, wm, NULL);
+ return;
+ case 8:
+ gui_internal_cmd_set_destination(this, wm, NULL);
+ return;
+ }
+ gui_internal_cmd_position_do(this, &wm->c, NULL, wm, wm->name ? wm->name : wm->text, flags);
}
@@ -1465,515 +1403,490 @@ gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data)
/**
* The "Bookmarks" section of the OSD
- *
+ *
*/
-void
-gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr attr,mattr;
- struct item *item;
- char *label_full,*prefix=0;
- int plen=0,hassub,found=0;
- struct widget *wb,*w,*wbm;
- struct coord c;
- struct widget *tbl, *row;
-
- if (data)
- prefix=g_strdup(data);
- else {
- if (wm && wm->prefix)
- prefix=g_strdup(wm->prefix);
- }
- if ( prefix )
- plen=strlen(prefix);
-
- gui_internal_prune_menu_count(this, 1, 0);
- wb=gui_internal_menu(this, _("Bookmarks"));
- wb->background=this->background;
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- //w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
-
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- if (!plen) {
- bookmarks_move_root(mattr.u.bookmarks);
- } else {
- if (!strcmp(prefix,"..")) {
- bookmarks_move_up(mattr.u.bookmarks);
- g_free(prefix);
- prefix=g_strdup(bookmarks_item_cwd(mattr.u.bookmarks));
- if (prefix) {
- plen=strlen(prefix);
- } else {
- plen=0;
- }
- } else {
- bookmarks_move_down(mattr.u.bookmarks,prefix);
- }
-
- // "Back" button, when inside a bookmark folder
-
- if (plen) {
- wbm=gui_internal_button_new_with_callback(this, "..",
- image_new_xs(this, "gui_inactive"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_bookmarks, NULL);
- wbm->prefix=g_strdup("..");
- gui_internal_widget_append(w, wbm);
-
- // load bookmark folder as Waypoints, if any
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks) > 0){
- wbm=gui_internal_button_new_with_callback(this, _("Bookmarks as waypoints"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_load_bookmarks_as_waypoints, NULL);
- wbm->prefix=g_strdup(prefix);
- gui_internal_widget_append(w, wbm);
- }
-
- // save Waypoints in bookmark folder, if route exists
- if (navit_get_destination_count(this->nav) > 0){
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0){
- wbm=gui_internal_button_new_with_callback(this, _("Save waypoints"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
- }else{
- wbm=gui_internal_button_new_with_callback(this, _("Replace with waypoints"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
- }
- wbm->prefix=g_strdup(prefix);
- gui_internal_widget_append(w, wbm);
- }
-
- // delete empty folder
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0){
- gui_internal_widget_append(w,
- wbm=gui_internal_button_new_with_callback(this, _("Delete Folder"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_delete_bookmark_folder, NULL));
- wbm->prefix=g_strdup(prefix);
- }
-
- }
- }
-
- // Adds the Bookmark folders
- wbm=gui_internal_button_new_with_callback(this, _("Add Bookmark folder"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_add_bookmark_folder2, NULL);
- gui_internal_widget_append(w, wbm);
-
- // Pastes the Bookmark
- wbm=gui_internal_button_new_with_callback(this, _("Paste bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_paste_bookmark, NULL);
- gui_internal_widget_append(w, wbm);
-
- bookmarks_item_rewind(mattr.u.bookmarks);
-
- tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(w,tbl);
-
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr)) continue;
- label_full=map_convert_string_tmp(item->map,attr.u.str);
- dbg(lvl_info,"full_labled: %s\n",label_full);
-
- // hassub == 1 if the item type is a sub-folder
- if (item->type == type_bookmark_folder) {
- hassub=1;
- } else {
- hassub=0;
- }
-
- row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_horizontal);
- gui_internal_widget_append(tbl, row);
- wbm=gui_internal_button_new_with_callback(this, label_full,
- image_new_xs(this, hassub ? "gui_inactive" : "gui_active" ), gravity_left_center|orientation_horizontal|flags_fill,
- hassub ? gui_internal_cmd_bookmarks : gui_internal_cmd_position, NULL);
-
- gui_internal_widget_append(row,wbm);
- if (item_coord_get(item, &c, 1)) {
- wbm->c.x=c.x;
- wbm->c.y=c.y;
- wbm->c.pro=bookmarks_get_projection(mattr.u.bookmarks);
- wbm->name=g_strdup_printf(_("Bookmark %s"),label_full);
- wbm->text=g_strdup(label_full);
- if (!hassub) {
- wbm->data=(void*)7;//Mark us as a bookmark
- }
- wbm->prefix=g_strdup(label_full);
- } else {
- gui_internal_widget_destroy(this, row);
- }
- }
- }
-
- g_free(prefix);
-
- if (found)
- gui_internal_check_exit(this);
- else
- gui_internal_menu_render(this);
-}
-
-
-
-
-static void
-gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary);
-
-static int
-gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result);
-
-static int
-gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result);
-
-static struct widget*
-gui_internal_keynav_find_next_sensitive_child(struct widget *wi);
-
-void
-gui_internal_keypress_do(struct gui_priv *this, char *key)
-{
- struct widget *wi,*menu,*search_list;
- int len=0;
- char *text=NULL;
-
- menu=g_list_last(this->root.children)->data;
- wi=gui_internal_find_widget(menu, NULL, STATE_EDIT);
- if (wi) {
- /* select first item of the searchlist */
- if (*key == NAVIT_KEY_RETURN) {
- search_list=gui_internal_menu_data(this)->search_list;
- if(search_list) {
- GList *l=gui_internal_widget_table_top_row(this, search_list);
- if (l && l->data) {
- struct widget *w=l->data;
- this->current.x=w->p.x+w->w/2;
- this->current.y=w->p.y+w->h/2;
- gui_internal_highlight(this);
- }
- } else {
- wi->reason=gui_internal_reason_keypress_finish;
- wi->func(this, wi, wi->data);
- }
- return;
- } else if (*key == NAVIT_KEY_BACKSPACE) {
- dbg(lvl_debug,"backspace\n");
- if (wi->text && wi->text[0]) {
- len=g_utf8_prev_char(wi->text+strlen(wi->text))-wi->text;
- wi->text[len]='\0';
- text=g_strdup(wi->text);
- }
- } else {
- if (wi->state & STATE_CLEAR) {
- dbg(lvl_info,"wi->state=0x%x\n", wi->state);
- g_free(wi->text);
- wi->text=NULL;
- wi->state &= ~STATE_CLEAR;
- dbg(lvl_info,"wi->state=0x%x\n", wi->state);
- }
- text=g_strdup_printf("%s%s", wi->text ? wi->text : "", key);
-
- gui_internal_keyboard_to_lower_case(this);
- }
- g_free(wi->text);
- wi->text=text;
-
- if(!wi->text || !*wi->text)
- gui_internal_keyboard_to_upper_case(this);
-
- if (wi->func) {
- wi->reason=gui_internal_reason_keypress;
- wi->func(this, wi, wi->data);
- }
- gui_internal_widget_render(this, wi);
- }
-}
-
-
-
-
-char *
-gui_internal_cmd_match_expand(char *pattern, struct attr **in)
-{
- char p,*ret=g_strdup(pattern),*r=ret,*a;
- int len;
- while ((p=*pattern++)) {
- switch (p) {
- case '*':
- *r='\0';
- a=attr_to_text(*in++,NULL,0);
- len=strlen(ret)+strlen(a)+strlen(pattern)+1;
- r=g_malloc(len);
- strcpy(r, ret);
- strcat(r, a);
- g_free(ret);
- g_free(a);
- ret=r;
- r=ret+strlen(ret);
- break;
- case '\\':
- p=*pattern++;
- default:
- *r++=p;
- }
- }
- *r++='\0';
- return ret;
-}
-
-static int
-gui_internal_match(const char *pattern, const char *string)
-{
- char p,s;
- while ((p=*pattern++)) {
- switch (p) {
- case '*':
- while ((s=*string)) {
- if (gui_internal_match(pattern,string))
- return 1;
- string++;
- }
- break;
- case '\\':
- p=*pattern++;
- default:
- if (*string++ != p)
- return 0;
- }
- }
- return 1;
-}
-
-int
-gui_internal_set(char *remove, char *add)
-{
- char *gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
- char *gui_file_new=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal_new.txt", NULL);
- FILE *fo=fopen(gui_file_new,"w");
- FILE *fi=fopen(gui_file,"r");
- char *line=NULL;
- int ret;
- size_t size=0;
- if (fi != NULL){
- while (getline(&line,&size,fi) > 0) {
- int len=strlen(line);
- if (len > 0 && line[len-1] == '\n')
- line[len-1]='\0';
- dbg(lvl_debug,"line=%s\n",line);
- if (!gui_internal_match(remove, line))
- fprintf(fo,"%s\n",line);
- }
- if (line)
- free(line);
- fclose(fi);
- }
- if (add)
- fprintf(fo,"%s;\n",add);
- fclose(fo);
- unlink(gui_file);
- ret=(rename(gui_file_new, gui_file)==0);
- g_free(gui_file_new);
- g_free(gui_file);
-
- return ret;
-}
-
-
-
-static void
-gui_internal_window_closed(struct gui_priv *this)
-{
- gui_internal_cmd2_quit(this, NULL, NULL, NULL, NULL);
-}
-
-
-static void
-gui_internal_cmd_map_download_do(struct gui_priv *this, struct widget *wm, void *data)
-{
- char *text=g_strdup_printf(_("Download %s"),wm->name);
- struct widget *w, *wb;
- struct map *map=data;
- double bllon,bllat,trlon,trlat;
-
- wb=gui_internal_menu(this, text);
- g_free(text);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- if (sscanf(wm->prefix,"%lf,%lf,%lf,%lf",&bllon,&bllat,&trlon,&trlat) == 4) {
- struct coord_geo g;
- struct map_selection sel;
- struct map_rect *mr;
- struct item *item;
-
- sel.next=NULL;
- sel.order=255;
- g.lng=bllon;
- g.lat=trlat;
- transform_from_geo(projection_mg, &g, &sel.u.c_rect.lu);
- g.lng=trlon;
- g.lat=bllat;
- transform_from_geo(projection_mg, &g, &sel.u.c_rect.rl);
- sel.range.min=type_none;
- sel.range.max=type_last;
- mr=map_rect_new(map, &sel);
- while ((item=map_rect_get_item(mr))) {
- dbg(lvl_info,"item\n");
- }
- map_rect_destroy(mr);
- }
-
- dbg(lvl_info,"bbox=%s\n",wm->prefix);
- gui_internal_menu_render(this);
-}
-
-void
-gui_internal_cmd_map_download(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr on, off, download_enabled, download_disabled;
- struct widget *w,*wb,*wma;
- struct map *map=data;
- FILE *f;
- char *search,buffer[256];
- int found,sp_match=0;
-
- dbg(lvl_debug,"wm=%p prefix=%s\n",wm,wm->prefix);
-
- search=wm->prefix;
- if (search) {
- found=0;
- while(search[sp_match] == ' ')
- sp_match++;
- sp_match++;
- } else {
- found=1;
- }
- on.type=off.type=attr_active;
- on.u.num=1;
- off.u.num=0;
- wb=gui_internal_menu(this, wm->name?wm->name:_("Map Download"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- if (!search) {
- wma=gui_internal_button_map_attr_new(this, _("Active"), gravity_left_center|orientation_horizontal|flags_fill, map, &on, &off, 1);
- gui_internal_widget_append(w, wma);
- }
-
- download_enabled.type=download_disabled.type=attr_update;
- download_enabled.u.num=1;
- download_disabled.u.num=0;
- wma=gui_internal_button_map_attr_new(this
- , _("Download Enabled")
- , gravity_left_center|orientation_horizontal|flags_fill
- , map
- , &download_enabled
- , &download_disabled
- , 0);
- gui_internal_widget_append(w, wma);
-
-
- f=fopen("maps/areas.tsv","r");
- while (f && fgets(buffer, sizeof(buffer), f)) {
- char *nl,*description,*description_size,*bbox,*size=NULL;
- int sp=0;
- if ((nl=strchr(buffer,'\n')))
- *nl='\0';
- if ((nl=strchr(buffer,'\r')))
- *nl='\0';
- while(buffer[sp] == ' ')
- sp++;
- if ((bbox=strchr(buffer,'\t')))
- *bbox++='\0';
- if (bbox && (size=strchr(bbox,'\t')))
- *size++='\0';
- if (search && !strcmp(buffer, search)) {
- wma=gui_internal_button_new_with_callback(this, _("Download completely"), NULL,
- gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download_do, map);
- wma->name=g_strdup(buffer+sp);
- wma->prefix=g_strdup(bbox);
- gui_internal_widget_append(w, wma);
- found=1;
- } else if (sp < sp_match)
- found=0;
- if (sp == sp_match && found && buffer[sp]) {
- description=g_strdup(buffer+sp);
- if (size)
- description_size=g_strdup_printf("%s (%s)",description,size);
- else
- description_size=g_strdup(description);
- wma=gui_internal_button_new_with_callback(this, description_size, NULL,
- gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download, map);
- g_free(description_size);
- wma->prefix=g_strdup(buffer);
- wma->name=description;
- gui_internal_widget_append(w, wma);
- }
- }
-
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_set_active_vehicle(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr vehicle = {attr_vehicle,{wm->data}};
- navit_set_attr(this->nav, &vehicle);
-}
-
-static void
-gui_internal_cmd_show_satellite_status(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*row;
- struct attr attr,sat_attr;
- struct vehicle *v=wm->data;
- char *str;
- int i;
- enum attr_type types[]={attr_sat_prn, attr_sat_elevation, attr_sat_azimuth, attr_sat_snr};
-
- wb=gui_internal_menu(this, _("Show Satellite Status"));
- gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_satellite_status;
- gui_internal_menu_data(this)->redisplay_widget=wm;
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- w = gui_internal_widget_table_new(this,gravity_center | orientation_vertical | flags_expand | flags_fill, 0);
- row = gui_internal_widget_table_row_new(this,gravity_left_top);
- gui_internal_widget_append(row, gui_internal_label_new(this, " PRN "));
- gui_internal_widget_append(row, gui_internal_label_new(this, _(" Elevation ")));
- gui_internal_widget_append(row, gui_internal_label_new(this, _(" Azimuth ")));
- gui_internal_widget_append(row, gui_internal_label_new(this, " SNR "));
- gui_internal_widget_append(w,row);
- while (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
- row = gui_internal_widget_table_row_new(this,gravity_left_top);
- for (i = 0 ; i < sizeof(types)/sizeof(enum attr_type) ; i++) {
- if (item_attr_get(attr.u.item, types[i], &sat_attr))
- str=g_strdup_printf("%ld", sat_attr.u.num);
- else
- str=g_strdup("");
- gui_internal_widget_append(row, gui_internal_label_new(this, str));
- g_free(str);
- }
- gui_internal_widget_append(w,row);
- }
- gui_internal_widget_append(wb, w);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_show_nmea_data(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb;
- struct attr attr;
- struct vehicle *v=wm->data;
- wb=gui_internal_menu(this, _("Show NMEA Data"));
- gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_nmea_data;
- gui_internal_menu_data(this)->redisplay_widget=wm;
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL))
- gui_internal_widget_append(w, gui_internal_text_new(this, attr.u.str, gravity_left_center|orientation_vertical));
- gui_internal_menu_render(this);
+void gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr attr,mattr;
+ struct item *item;
+ char *label_full,*prefix=0;
+ int plen=0,hassub,found=0;
+ struct widget *wb,*w,*wbm;
+ struct coord c;
+ struct widget *tbl, *row;
+
+ if (data)
+ prefix=g_strdup(data);
+ else {
+ if (wm && wm->prefix)
+ prefix=g_strdup(wm->prefix);
+ }
+ if ( prefix )
+ plen=strlen(prefix);
+
+ gui_internal_prune_menu_count(this, 1, 0);
+ wb=gui_internal_menu(this, _("Bookmarks"));
+ wb->background=this->background;
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ //w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+
+ if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
+ if (!plen) {
+ bookmarks_move_root(mattr.u.bookmarks);
+ } else {
+ if (!strcmp(prefix,"..")) {
+ bookmarks_move_up(mattr.u.bookmarks);
+ g_free(prefix);
+ prefix=g_strdup(bookmarks_item_cwd(mattr.u.bookmarks));
+ if (prefix) {
+ plen=strlen(prefix);
+ } else {
+ plen=0;
+ }
+ } else {
+ bookmarks_move_down(mattr.u.bookmarks,prefix);
+ }
+
+ // "Back" button, when inside a bookmark folder
+
+ if (plen) {
+ wbm=gui_internal_button_new_with_callback(this, "..",
+ image_new_xs(this, "gui_inactive"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_bookmarks, NULL);
+ wbm->prefix=g_strdup("..");
+ gui_internal_widget_append(w, wbm);
+
+ // load bookmark folder as Waypoints, if any
+ if (bookmarks_get_bookmark_count(mattr.u.bookmarks) > 0) {
+ wbm=gui_internal_button_new_with_callback(this, _("Bookmarks as waypoints"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_load_bookmarks_as_waypoints, NULL);
+ wbm->prefix=g_strdup(prefix);
+ gui_internal_widget_append(w, wbm);
+ }
+
+ // save Waypoints in bookmark folder, if route exists
+ if (navit_get_destination_count(this->nav) > 0) {
+ if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0) {
+ wbm=gui_internal_button_new_with_callback(this, _("Save waypoints"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
+ } else {
+ wbm=gui_internal_button_new_with_callback(this, _("Replace with waypoints"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
+ }
+ wbm->prefix=g_strdup(prefix);
+ gui_internal_widget_append(w, wbm);
+ }
+
+ // delete empty folder
+ if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0) {
+ gui_internal_widget_append(w,
+ wbm=gui_internal_button_new_with_callback(this, _("Delete Folder"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_delete_bookmark_folder, NULL));
+ wbm->prefix=g_strdup(prefix);
+ }
+
+ }
+ }
+
+ // Adds the Bookmark folders
+ wbm=gui_internal_button_new_with_callback(this, _("Add Bookmark folder"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_add_bookmark_folder2, NULL);
+ gui_internal_widget_append(w, wbm);
+
+ // Pastes the Bookmark
+ wbm=gui_internal_button_new_with_callback(this, _("Paste bookmark"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_paste_bookmark, NULL);
+ gui_internal_widget_append(w, wbm);
+
+ bookmarks_item_rewind(mattr.u.bookmarks);
+
+ tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ gui_internal_widget_append(w,tbl);
+
+ while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
+ if (!item_attr_get(item, attr_label, &attr)) continue;
+ label_full=map_convert_string_tmp(item->map,attr.u.str);
+ dbg(lvl_info,"full_labled: %s",label_full);
+
+ // hassub == 1 if the item type is a sub-folder
+ if (item->type == type_bookmark_folder) {
+ hassub=1;
+ } else {
+ hassub=0;
+ }
+
+ row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_horizontal);
+ gui_internal_widget_append(tbl, row);
+ wbm=gui_internal_button_new_with_callback(this, label_full,
+ image_new_xs(this, hassub ? "gui_inactive" : "gui_active" ), gravity_left_center|orientation_horizontal|flags_fill,
+ hassub ? gui_internal_cmd_bookmarks : gui_internal_cmd_position, NULL);
+
+ gui_internal_widget_append(row,wbm);
+ if (item_coord_get(item, &c, 1)) {
+ wbm->c.x=c.x;
+ wbm->c.y=c.y;
+ wbm->c.pro=bookmarks_get_projection(mattr.u.bookmarks);
+ wbm->name=g_strdup_printf(_("Bookmark %s"),label_full);
+ wbm->text=g_strdup(label_full);
+ if (!hassub) {
+ wbm->data=(void*)7;//Mark us as a bookmark
+ }
+ wbm->prefix=g_strdup(label_full);
+ } else {
+ gui_internal_widget_destroy(this, row);
+ }
+ }
+ }
+
+ g_free(prefix);
+
+ if (found)
+ gui_internal_check_exit(this);
+ else
+ gui_internal_menu_render(this);
+}
+
+
+
+
+static void gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary);
+
+static int gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result);
+
+static int gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result);
+
+static struct widget* gui_internal_keynav_find_next_sensitive_child(struct widget *wi);
+
+void gui_internal_keypress_do(struct gui_priv *this, char *key) {
+ struct widget *wi,*menu,*search_list;
+ int len=0;
+ char *text=NULL;
+
+ menu=g_list_last(this->root.children)->data;
+ wi=gui_internal_find_widget(menu, NULL, STATE_EDIT);
+ if (wi) {
+ /* select first item of the searchlist */
+ if (*key == NAVIT_KEY_RETURN) {
+ search_list=gui_internal_menu_data(this)->search_list;
+ if(search_list) {
+ GList *l=gui_internal_widget_table_top_row(this, search_list);
+ if (l && l->data) {
+ struct widget *w=l->data;
+ this->current.x=w->p.x+w->w/2;
+ this->current.y=w->p.y+w->h/2;
+ gui_internal_highlight(this);
+ }
+ } else {
+ wi->reason=gui_internal_reason_keypress_finish;
+ wi->func(this, wi, wi->data);
+ }
+ return;
+ } else if (*key == NAVIT_KEY_BACKSPACE) {
+ dbg(lvl_debug,"backspace");
+ if (wi->text && wi->text[0]) {
+ len=g_utf8_prev_char(wi->text+strlen(wi->text))-wi->text;
+ wi->text[len]='\0';
+ text=g_strdup(wi->text);
+ }
+ } else {
+ if (wi->state & STATE_CLEAR) {
+ dbg(lvl_info,"wi->state=0x%x", wi->state);
+ g_free(wi->text);
+ wi->text=NULL;
+ wi->state &= ~STATE_CLEAR;
+ dbg(lvl_info,"wi->state=0x%x", wi->state);
+ }
+ text=g_strdup_printf("%s%s", wi->text ? wi->text : "", key);
+
+ gui_internal_keyboard_to_lower_case(this);
+ }
+ g_free(wi->text);
+ wi->text=text;
+
+ if(!wi->text || !*wi->text)
+ gui_internal_keyboard_to_upper_case(this);
+
+ if (wi->func) {
+ wi->reason=gui_internal_reason_keypress;
+ wi->func(this, wi, wi->data);
+ }
+ gui_internal_widget_render(this, wi);
+ }
+}
+
+
+
+
+char *gui_internal_cmd_match_expand(char *pattern, struct attr **in) {
+ char p,*ret=g_strdup(pattern),*r=ret,*a;
+ int len;
+ while ((p=*pattern++)) {
+ switch (p) {
+ case '*':
+ *r='\0';
+ a=attr_to_text(*in++,NULL,0);
+ len=strlen(ret)+strlen(a)+strlen(pattern)+1;
+ r=g_malloc(len);
+ strcpy(r, ret);
+ strcat(r, a);
+ g_free(ret);
+ g_free(a);
+ ret=r;
+ r=ret+strlen(ret);
+ break;
+ case '\\':
+ p=*pattern++;
+ default:
+ *r++=p;
+ }
+ }
+ *r++='\0';
+ return ret;
+}
+
+static int gui_internal_match(const char *pattern, const char *string) {
+ char p,s;
+ while ((p=*pattern++)) {
+ switch (p) {
+ case '*':
+ while ((s=*string)) {
+ if (gui_internal_match(pattern,string))
+ return 1;
+ string++;
+ }
+ break;
+ case '\\':
+ p=*pattern++;
+ default:
+ if (*string++ != p)
+ return 0;
+ }
+ }
+ return 1;
+}
+
+int gui_internal_set(char *remove, char *add) {
+ char *gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
+ char *gui_file_new=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal_new.txt", NULL);
+ FILE *fo=fopen(gui_file_new,"w");
+ FILE *fi=fopen(gui_file,"r");
+ char *line=NULL;
+ int ret;
+ size_t size=0;
+ if (fi != NULL) {
+ while (getline(&line,&size,fi) > 0) {
+ int len=strlen(line);
+ if (len > 0 && line[len-1] == '\n')
+ line[len-1]='\0';
+ dbg(lvl_debug,"line=%s",line);
+ if (!gui_internal_match(remove, line))
+ fprintf(fo,"%s\n",line);
+ }
+ if (line)
+ free(line);
+ fclose(fi);
+ }
+ if (add)
+ fprintf(fo,"%s;\n",add);
+ fclose(fo);
+ unlink(gui_file);
+ ret=(rename(gui_file_new, gui_file)==0);
+ g_free(gui_file_new);
+ g_free(gui_file);
+
+ return ret;
+}
+
+
+
+static void gui_internal_window_closed(struct gui_priv *this) {
+ gui_internal_cmd2_quit(this, NULL, NULL, NULL, NULL);
+}
+
+
+static void gui_internal_cmd_map_download_do(struct gui_priv *this, struct widget *wm, void *data) {
+ char *text=g_strdup_printf(_("Download %s"),wm->name);
+ struct widget *w, *wb;
+ struct map *map=data;
+ double bllon,bllat,trlon,trlat;
+
+ wb=gui_internal_menu(this, text);
+ g_free(text);
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+ if (sscanf(wm->prefix,"%lf,%lf,%lf,%lf",&bllon,&bllat,&trlon,&trlat) == 4) {
+ struct coord_geo g;
+ struct map_selection sel;
+ struct map_rect *mr;
+ struct item *item;
+
+ sel.next=NULL;
+ sel.order=255;
+ g.lng=bllon;
+ g.lat=trlat;
+ transform_from_geo(projection_mg, &g, &sel.u.c_rect.lu);
+ g.lng=trlon;
+ g.lat=bllat;
+ transform_from_geo(projection_mg, &g, &sel.u.c_rect.rl);
+ sel.range.min=type_none;
+ sel.range.max=type_last;
+ mr=map_rect_new(map, &sel);
+ while ((item=map_rect_get_item(mr))) {
+ dbg(lvl_info,"item");
+ }
+ map_rect_destroy(mr);
+ }
+
+ dbg(lvl_info,"bbox=%s",wm->prefix);
+ gui_internal_menu_render(this);
+}
+
+void gui_internal_cmd_map_download(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr on, off, download_enabled, download_disabled;
+ struct widget *w,*wb,*wma;
+ struct map *map=data;
+ FILE *f;
+ char *search,buffer[256];
+ int found,sp_match=0;
+
+ dbg(lvl_debug,"wm=%p prefix=%s",wm,wm->prefix);
+
+ search=wm->prefix;
+ if (search) {
+ found=0;
+ while(search[sp_match] == ' ')
+ sp_match++;
+ sp_match++;
+ } else {
+ found=1;
+ }
+ on.type=off.type=attr_active;
+ on.u.num=1;
+ off.u.num=0;
+ wb=gui_internal_menu(this, wm->name?wm->name:_("Map Download"));
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+ if (!search) {
+ wma=gui_internal_button_map_attr_new(this, _("Active"), gravity_left_center|orientation_horizontal|flags_fill, map, &on,
+ &off, 1);
+ gui_internal_widget_append(w, wma);
+ }
+
+ download_enabled.type=download_disabled.type=attr_update;
+ download_enabled.u.num=1;
+ download_disabled.u.num=0;
+ wma=gui_internal_button_map_attr_new(this
+ , _("Download Enabled")
+ , gravity_left_center|orientation_horizontal|flags_fill
+ , map
+ , &download_enabled
+ , &download_disabled
+ , 0);
+ gui_internal_widget_append(w, wma);
+
+
+ f=fopen("maps/areas.tsv","r");
+ while (f && fgets(buffer, sizeof(buffer), f)) {
+ char *nl,*description,*description_size,*bbox,*size=NULL;
+ int sp=0;
+ if ((nl=strchr(buffer,'\n')))
+ *nl='\0';
+ if ((nl=strchr(buffer,'\r')))
+ *nl='\0';
+ while(buffer[sp] == ' ')
+ sp++;
+ if ((bbox=strchr(buffer,'\t')))
+ *bbox++='\0';
+ if (bbox && (size=strchr(bbox,'\t')))
+ *size++='\0';
+ if (search && !strcmp(buffer, search)) {
+ wma=gui_internal_button_new_with_callback(this, _("Download completely"), NULL,
+ gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download_do, map);
+ wma->name=g_strdup(buffer+sp);
+ wma->prefix=g_strdup(bbox);
+ gui_internal_widget_append(w, wma);
+ found=1;
+ } else if (sp < sp_match)
+ found=0;
+ if (sp == sp_match && found && buffer[sp]) {
+ description=g_strdup(buffer+sp);
+ if (size)
+ description_size=g_strdup_printf("%s (%s)",description,size);
+ else
+ description_size=g_strdup(description);
+ wma=gui_internal_button_new_with_callback(this, description_size, NULL,
+ gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download, map);
+ g_free(description_size);
+ wma->prefix=g_strdup(buffer);
+ wma->name=description;
+ gui_internal_widget_append(w, wma);
+ }
+ }
+
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_set_active_vehicle(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr vehicle = {attr_vehicle,{wm->data}};
+ navit_set_attr(this->nav, &vehicle);
+}
+
+static void gui_internal_cmd_show_satellite_status(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb,*row;
+ struct attr attr,sat_attr;
+ struct vehicle *v=wm->data;
+ char *str;
+ int i;
+ enum attr_type types[]= {attr_sat_prn, attr_sat_elevation, attr_sat_azimuth, attr_sat_snr};
+
+ wb=gui_internal_menu(this, _("Show Satellite Status"));
+ gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_satellite_status;
+ gui_internal_menu_data(this)->redisplay_widget=wm;
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ w = gui_internal_widget_table_new(this,gravity_center | orientation_vertical | flags_expand | flags_fill, 0);
+ row = gui_internal_widget_table_row_new(this,gravity_left_top);
+ gui_internal_widget_append(row, gui_internal_label_new(this, " PRN "));
+ gui_internal_widget_append(row, gui_internal_label_new(this, _(" Elevation ")));
+ gui_internal_widget_append(row, gui_internal_label_new(this, _(" Azimuth ")));
+ gui_internal_widget_append(row, gui_internal_label_new(this, " SNR "));
+ gui_internal_widget_append(w,row);
+ while (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
+ row = gui_internal_widget_table_row_new(this,gravity_left_top);
+ for (i = 0 ; i < sizeof(types)/sizeof(enum attr_type) ; i++) {
+ if (item_attr_get(attr.u.item, types[i], &sat_attr))
+ str=g_strdup_printf("%ld", sat_attr.u.num);
+ else
+ str=g_strdup("");
+ gui_internal_widget_append(row, gui_internal_label_new(this, str));
+ g_free(str);
+ }
+ gui_internal_widget_append(w,row);
+ }
+ gui_internal_widget_append(wb, w);
+ gui_internal_menu_render(this);
+}
+
+static void gui_internal_cmd_show_nmea_data(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb;
+ struct attr attr;
+ struct vehicle *v=wm->data;
+ wb=gui_internal_menu(this, _("Show NMEA Data"));
+ gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_nmea_data;
+ gui_internal_menu_data(this)->redisplay_widget=wm;
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL))
+ gui_internal_widget_append(w, gui_internal_text_new(this, attr.u.str, gravity_left_center|orientation_vertical));
+ gui_internal_menu_render(this);
}
/**
@@ -1981,8 +1894,8 @@ gui_internal_cmd_show_nmea_data(struct gui_priv *this, struct widget *wm, void *
* one data item.
*/
struct vehicle_and_profilename {
- struct vehicle *vehicle;
- char *profilename;
+ struct vehicle *vehicle;
+ char *profilename;
};
/**
@@ -1990,40 +1903,36 @@ struct vehicle_and_profilename {
*
* @return true if the vehicle is active, false otherwise.
*/
-static int
-gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle
- *vehicle)
-{
- struct attr active_vehicle;
+static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle
+ *vehicle) {
+ struct attr active_vehicle;
- if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
+ if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
active_vehicle.u.vehicle=NULL;
- return active_vehicle.u.vehicle == vehicle;
-}
-
-static void
-save_vehicle_xml(struct vehicle *v)
-{
- struct attr attr;
- struct attr_iter *iter=vehicle_attr_iter_new();
- int childs=0;
- printf("<vehicle");
- while (vehicle_get_attr(v, attr_any_xml, &attr, iter)) {
- if (ATTR_IS_OBJECT(attr.type))
- childs=1;
- else {
- char *attrtxt;
- printf(" %s=\"%s\"",attr_to_name(attr.type),attrtxt=attr_to_text(&attr, NULL, 1));
- g_free(attrtxt);
- }
- }
- if (childs) {
- printf(">\n");
- printf("</vehicle>\n");
- } else
- printf(" />\n");
- vehicle_attr_iter_destroy(iter);
+ return active_vehicle.u.vehicle == vehicle;
+}
+
+static void save_vehicle_xml(struct vehicle *v) {
+ struct attr attr;
+ struct attr_iter *iter=vehicle_attr_iter_new();
+ int childs=0;
+ printf("<vehicle");
+ while (vehicle_get_attr(v, attr_any_xml, &attr, iter)) {
+ if (ATTR_IS_OBJECT(attr.type))
+ childs=1;
+ else {
+ char *attrtxt;
+ printf(" %s=\"%s\"",attr_to_name(attr.type),attrtxt=attr_to_text(&attr, NULL, 1));
+ g_free(attrtxt);
+ }
+ }
+ if (childs) {
+ printf(">\n");
+ printf("</vehicle>\n");
+ } else
+ printf(" />\n");
+ vehicle_attr_iter_destroy(iter);
}
@@ -2032,169 +1941,162 @@ save_vehicle_xml(struct vehicle *v)
*
* @see gui_internal_add_vehicle_profile
*/
-static void
-gui_internal_cmd_set_active_profile(struct gui_priv *this, struct
- widget *wm, void *data)
-{
- struct vehicle_and_profilename *vapn = data;
- struct vehicle *v = vapn->vehicle;
- char *profilename = vapn->profilename;
- struct attr vehicle_name_attr;
- char *vehicle_name = NULL;
- struct attr profilename_attr;
- struct attr vehicle;
-
- // Get the vehicle name
- vehicle_get_attr(v, attr_name, &vehicle_name_attr, NULL);
- vehicle_name = vehicle_name_attr.u.str;
-
- dbg(lvl_debug, "Changing vehicle %s to profile %s\n", vehicle_name,
- profilename);
-
- // Change the profile name
- profilename_attr.type = attr_profilename;
- profilename_attr.u.str = profilename;
- if(!vehicle_set_attr(v, &profilename_attr)) {
- dbg(lvl_error, "Unable to set the vehicle's profile name\n");
- }
-
- navit_set_vehicleprofile_name(this->nav,profilename);
-
- save_vehicle_xml(v);
+static void gui_internal_cmd_set_active_profile(struct gui_priv *this, struct
+ widget *wm, void *data) {
+ struct vehicle_and_profilename *vapn = data;
+ struct vehicle *v = vapn->vehicle;
+ char *profilename = vapn->profilename;
+ struct attr vehicle_name_attr;
+ char *vehicle_name = NULL;
+ struct attr profilename_attr;
+ struct attr vehicle;
+
+ // Get the vehicle name
+ vehicle_get_attr(v, attr_name, &vehicle_name_attr, NULL);
+ vehicle_name = vehicle_name_attr.u.str;
+
+ dbg(lvl_debug, "Changing vehicle %s to profile %s", vehicle_name, profilename);
+
+ // Change the profile name
+ profilename_attr.type = attr_profilename;
+ profilename_attr.u.str = profilename;
+ if(!vehicle_set_attr(v, &profilename_attr)) {
+ dbg(lvl_error, "Unable to set the vehicle's profile name");
+ }
+
+ navit_set_vehicleprofile_name(this->nav,profilename);
+
+ save_vehicle_xml(v);
// Notify Navit that the routing should be re-done if this is the
// active vehicle.
- if (gui_internal_is_active_vehicle(this, v)) {
- vehicle.u.vehicle=v;
- }
- else {
+ if (gui_internal_is_active_vehicle(this, v)) {
+ vehicle.u.vehicle=v;
+ } else {
+
+ vehicle.u.vehicle=NULL;
+ }
- vehicle.u.vehicle=NULL;
- }
-
- vehicle.type=attr_vehicle;
- navit_set_attr(this->nav, &vehicle);
+ vehicle.type=attr_vehicle;
+ navit_set_attr(this->nav, &vehicle);
-
- gui_internal_prune_menu_count(this, 1, 0);
- gui_internal_menu_vehicle_settings(this, v, vehicle_name);
+
+ gui_internal_prune_menu_count(this, 1, 0);
+ gui_internal_menu_vehicle_settings(this, v, vehicle_name);
}
/**
* Adds the vehicle profile to the GUI, allowing the user to pick a
* profile for the currently selected vehicle.
*/
-static void
-gui_internal_add_vehicle_profile(struct gui_priv *this, struct widget
- *parent, struct vehicle *v, struct vehicleprofile *profile)
-{
- // Just here to show up in the translation file, nice and close to
- // where the translations are actually used.
- struct attr profile_attr;
- struct attr *attr = NULL;
- char *name = NULL;
- char *active_profile = NULL;
- char *label = NULL;
- int active;
- struct vehicle_and_profilename *context = NULL;
+static void gui_internal_add_vehicle_profile(struct gui_priv *this, struct widget
+ *parent, struct vehicle *v, struct vehicleprofile *profile) {
+ // Just here to show up in the translation file, nice and close to
+ // where the translations are actually used.
+ struct attr profile_attr;
+ struct attr *attr = NULL;
+ char *name = NULL;
+ char *active_profile = NULL;
+ char *label = NULL;
+ int active;
+ struct vehicle_and_profilename *context = NULL;
#ifdef ONLY_FOR_TRANSLATION
- char *translations[] = {_n("car"), _n("bike"), _n("pedestrian")};
+ char *translations[] = {_n("car"), _n("bike"), _n("pedestrian")};
#endif
- // Figure out the profile name
- attr = attr_search(profile->attrs, NULL, attr_name);
- if (!attr) {
- dbg(lvl_error, "Adding vehicle profile failed. attr==NULL");
- return;
- }
- name = attr->u.str;
-
- // Determine whether the profile is the active one
- if (vehicle_get_attr(v, attr_profilename, &profile_attr, NULL))
- active_profile = profile_attr.u.str;
- active = active_profile != NULL && !strcmp(name, active_profile);
-
- dbg(lvl_debug, "Adding vehicle profile %s, active=%s/%i\n", name,
- active_profile, active);
-
- // Build a translatable label.
- if(active) {
- label = g_strdup_printf(_("Current profile: %s"), _(name));
- } else {
- label = g_strdup_printf(_("Change profile to: %s"), _(name));
- }
-
- // Create the context object (the vehicle and the desired profile)
- context = g_new0(struct vehicle_and_profilename, 1);
- context->vehicle = v;
- context->profilename = name;
-
- // Add the button
- gui_internal_widget_append(parent,
- gui_internal_button_new_with_callback(
- this, label,
- image_new_xs(this, active ? "gui_active" : "gui_inactive"),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_active_profile, context));
-
- free(label);
-}
-
-void
-gui_internal_menu_vehicle_settings(struct gui_priv *this, struct vehicle *v, char *name)
-{
- struct widget *w,*wb,*row;
- struct attr attr;
+ // Figure out the profile name
+ attr = attr_search(profile->attrs, NULL, attr_name);
+ if (!attr) {
+ dbg(lvl_error, "Adding vehicle profile failed. attr==NULL");
+ return;
+ }
+ name = attr->u.str;
+
+ // Determine whether the profile is the active one
+ if (vehicle_get_attr(v, attr_profilename, &profile_attr, NULL))
+ active_profile = profile_attr.u.str;
+ active = active_profile != NULL && !strcmp(name, active_profile);
+
+ dbg(lvl_debug, "Adding vehicle profile %s, active=%s/%i", name, active_profile, active);
+
+ // Build a translatable label.
+ if(active) {
+ label = g_strdup_printf(_("Current profile: %s"), _(name));
+ } else {
+ label = g_strdup_printf(_("Change profile to: %s"), _(name));
+ }
+
+ // Create the context object (the vehicle and the desired profile)
+ context = g_new0(struct vehicle_and_profilename, 1);
+ context->vehicle = v;
+ context->profilename = name;
+
+ // Add the button
+ gui_internal_widget_append(parent,
+ gui_internal_button_new_with_callback(
+ this, label,
+ image_new_xs(this, active ? "gui_active" : "gui_inactive"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_set_active_profile, context));
+
+ free(label);
+}
+
+void gui_internal_menu_vehicle_settings(struct gui_priv *this, struct vehicle *v, char *name) {
+ struct widget *w,*wb,*row;
+ struct attr attr;
struct vehicleprofile *profile = NULL;
- GList *profiles;
+ GList *profiles;
- wb=gui_internal_menu(this, name);
- w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
- gui_internal_widget_append(wb, w);
+ wb=gui_internal_menu(this, name);
+ w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
+ gui_internal_widget_append(wb, w);
// Add the "Set as active" button if this isn't the active
// vehicle.
- if (!gui_internal_is_active_vehicle(this, v)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new_with_callback(this, _("Set as active"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_active_vehicle, v));
- }
-
- if (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new_with_callback(this, _("Show Satellite status"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_show_satellite_status, v));
- }
- if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new_with_callback(this, _("Show NMEA data"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_show_nmea_data, v));
- }
+ if (!gui_internal_is_active_vehicle(this, v)) {
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ gui_internal_button_new_with_callback(this, _("Set as active"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_set_active_vehicle, v));
+ }
+
+ if (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ gui_internal_button_new_with_callback(this, _("Show Satellite status"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_show_satellite_status, v));
+ }
+ if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL)) {
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row,
+ gui_internal_button_new_with_callback(this, _("Show NMEA data"),
+ image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_show_nmea_data, v));
+ }
// Add all the possible vehicle profiles to the menu
- profiles = navit_get_vehicleprofiles(this->nav);
+ profiles = navit_get_vehicleprofiles(this->nav);
while(profiles) {
profile = (struct vehicleprofile *)profiles->data;
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
gui_internal_add_vehicle_profile(this, row, v, profile);
- profiles = g_list_next(profiles);
+ profiles = g_list_next(profiles);
}
- callback_list_call_attr_2(this->cbl, attr_vehicle, w, v);
- gui_internal_menu_render(this);
+ callback_list_call_attr_2(this->cbl, attr_vehicle, w, v);
+ gui_internal_menu_render(this);
}
-void
-gui_internal_cmd_vehicle_settings(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_menu_vehicle_settings(this, wm->data, wm->text);
+void gui_internal_cmd_vehicle_settings(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_menu_vehicle_settings(this, wm->data, wm->text);
}
@@ -2205,255 +2107,227 @@ gui_internal_cmd_vehicle_settings(struct gui_priv *this, struct widget *wm, void
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gui_internal_motion(void *data, struct point *p)
-{
-
- struct gui_priv *this=data;
- if (!this->root.children) {
- navit_handle_motion(this->nav, p);
- return;
- }
- if (!this->pressed)
- return;
- this->current=*p;
- if(!this->motion_timeout_callback)
- this->motion_timeout_callback=callback_new_1(callback_cast(gui_internal_motion_cb), this);
- if(!this->motion_timeout_event)
- this->motion_timeout_event=event_add_timeout(30,0, this->motion_timeout_callback);
-}
-
-void
-gui_internal_evaluate(struct gui_priv *this, const char *command)
-{
- if (command)
- command_evaluate(&this->self, command);
-}
-
-
-void
-gui_internal_enter(struct gui_priv *this, int ignore)
-{
- struct graphics *gra=this->gra;
- if (ignore != -1)
- this->ignore_button=ignore;
-
- navit_block(this->nav, 1);
- graphics_overlay_disable(gra, 1);
- this->root.p.x=0;
- this->root.p.y=0;
- this->root.background=this->background;
-}
-
-void
-gui_internal_leave(struct gui_priv *this)
-{
- graphics_draw_mode(this->gra, draw_mode_end);
-}
-
-void
-gui_internal_set_click_coord(struct gui_priv *this, struct point *p)
-{
- struct coord c;
- struct coord_geo g;
- struct attr attr;
- struct transformation *trans;
- attr_free(this->click_coord_geo);
- this->click_coord_geo=NULL;
- if (p) {
- trans=navit_get_trans(this->nav);
- transform_reverse(trans, p, &c);
- dbg(lvl_debug,"x=0x%x y=0x%x\n", c.x, c.y);
- this->clickp.pro=transform_get_projection(trans);
- this->clickp.x=c.x;
- this->clickp.y=c.y;
- transform_to_geo(this->clickp.pro, &c, &g);
- attr.u.coord_geo=&g;
- attr.type=attr_click_coord_geo;
- this->click_coord_geo=attr_dup(&attr);
- }
-}
-
-static void
-gui_internal_set_position_coord(struct gui_priv *this)
-{
- struct transformation *trans;
- struct attr attr,attrp;
- struct coord c;
-
- attr_free(this->position_coord_geo);
- this->position_coord_geo=NULL;
- if (navit_get_attr(this->nav, attr_vehicle, &attr, NULL) && attr.u.vehicle
- && vehicle_get_attr(attr.u.vehicle, attr_position_coord_geo, &attrp, NULL)) {
- trans=navit_get_trans(this->nav);
- this->position_coord_geo=attr_dup(&attrp);
- this->vehiclep.pro=transform_get_projection(trans);
- transform_from_geo(this->vehiclep.pro, attrp.u.coord_geo, &c);
- this->vehiclep.x=c.x;
- this->vehiclep.y=c.y;
- }
-}
-
-void
-gui_internal_enter_setup(struct gui_priv *this)
-{
- if (!this->mouse_button_clicked_on_map)
- gui_internal_set_position_coord(this);
-}
-
-void
-gui_internal_cmd_menu(struct gui_priv *this, int ignore, char *href)
-{
- dbg(lvl_debug,"enter\n");
- gui_internal_enter(this, ignore);
- gui_internal_enter_setup(this);
- // draw menu
- if (href)
- gui_internal_html_load_href(this, href, 0);
- else
- gui_internal_html_main_menu(this);
-}
-
-
-
-static void
-gui_internal_cmd_log_do(struct gui_priv *this, struct widget *widget)
-{
- if (widget->text && strlen(widget->text)) {
- if (this->position_coord_geo)
- navit_textfile_debug_log_at(this->nav, &this->vehiclep, "type=log_entry label=\"%s\"",widget->text);
- else
- navit_textfile_debug_log(this->nav, "type=log_entry label=\"%s\"",widget->text);
- }
- g_free(widget->text);
- widget->text=NULL;
- gui_internal_prune_menu(this, NULL);
- gui_internal_check_exit(this);
-}
-
-void
-gui_internal_cmd_log_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_cmd_log_do(this, widget->data);
-}
-
-
-void
-gui_internal_check_exit(struct gui_priv *this)
-{
- struct graphics *gra=this->gra;
- if (! this->root.children) {
- gui_internal_search_idle_end(this);
- gui_internal_search_list_destroy(this);
- graphics_overlay_disable(gra, 0);
- if (!navit_block(this->nav, 0)) {
- if (this->redraw)
- navit_draw(this->nav);
- else
- navit_draw_displaylist(this->nav);
- }
- }
-}
-
-static int
-gui_internal_get_attr(struct gui_priv *this, enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_active:
- attr->u.num=this->root.children != NULL;
- break;
- case attr_click_coord_geo:
- if (!this->click_coord_geo)
- return 0;
- *attr=*this->click_coord_geo;
- break;
- case attr_position_coord_geo:
- if (!this->position_coord_geo)
- return 0;
- *attr=*this->position_coord_geo;
- break;
- case attr_pitch:
- attr->u.num=this->pitch;
- break;
- case attr_button:
- attr->u.num=this->mouse_button_clicked_on_map;
- break;
- case attr_navit:
- attr->u.navit=this->nav;
- break;
- case attr_fullscreen:
- attr->u.num=(this->fullscreen > 0);
- break;
- default:
- return 0;
- }
- attr->type=type;
- return 1;
-}
-
-static int
-gui_internal_add_attr(struct gui_priv *this, struct attr *attr)
-{
- switch (attr->type) {
- case attr_xml_text:
- g_free(this->html_text);
- this->html_text=g_strdup(attr->u.str);
- return 1;
- default:
- return 0;
- }
-}
-
-static int
-gui_internal_set_attr(struct gui_priv *this, struct attr *attr)
-{
- switch (attr->type) {
- case attr_fullscreen:
- if ((this->fullscreen > 0) != (attr->u.num > 0)) {
- graphics_draw_mode(this->gra, draw_mode_end);
- this->win->fullscreen(this->win, attr->u.num > 0);
- graphics_draw_mode(this->gra, draw_mode_begin);
- }
- this->fullscreen=attr->u.num;
- return 1;
- case attr_menu_on_map_click:
- this->menu_on_map_click=attr->u.num;
- return 1;
- case attr_on_map_click:
- g_free(this->on_map_click);
- this->on_map_click=g_strdup(attr->u.str);
- return 1;
- default:
- dbg(lvl_error,"Unknown attribute: %s\n",attr_to_name(attr->type));
- return 1;
- }
-}
-
-static void gui_internal_dbus_signal(struct gui_priv *this, struct point *p)
-{
- struct displaylist_handle *dlh;
- struct displaylist *display;
- struct displayitem *di;
- struct attr cb,**attr_list=NULL;
- int valid=0;
-
- display=navit_get_displaylist(this->nav);
- dlh=graphics_displaylist_open(display);
- while ((di=graphics_displaylist_next(dlh))) {
- struct item *item=graphics_displayitem_get_item(di);
- if (item_is_point(*item) && graphics_displayitem_get_displayed(di) &&
- graphics_displayitem_within_dist(display, di, p, this->radius)) {
- struct map_rect *mr=map_rect_new(item->map, NULL);
- struct item *itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- struct attr attr;
- if (itemo && item_attr_get(itemo, attr_data, &attr))
- attr_list=attr_generic_add_attr(attr_list, &attr);
- map_rect_destroy(mr);
- }
- }
- graphics_displaylist_close(dlh);
- if (attr_list && navit_get_attr(this->nav, attr_callback_list, &cb, NULL))
- callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
- attr_list_free(attr_list);
+static void gui_internal_motion(void *data, struct point *p) {
+
+ struct gui_priv *this=data;
+ if (!this->root.children) {
+ navit_handle_motion(this->nav, p);
+ return;
+ }
+ if (!this->pressed)
+ return;
+ this->current=*p;
+ if(!this->motion_timeout_callback)
+ this->motion_timeout_callback=callback_new_1(callback_cast(gui_internal_motion_cb), this);
+ if(!this->motion_timeout_event)
+ this->motion_timeout_event=event_add_timeout(30,0, this->motion_timeout_callback);
+}
+
+void gui_internal_evaluate(struct gui_priv *this, const char *command) {
+ if (command)
+ command_evaluate(&this->self, command);
+}
+
+
+void gui_internal_enter(struct gui_priv *this, int ignore) {
+ struct graphics *gra=this->gra;
+ if (ignore != -1)
+ this->ignore_button=ignore;
+
+ navit_block(this->nav, 1);
+ graphics_overlay_disable(gra, 1);
+ this->root.p.x=0;
+ this->root.p.y=0;
+ this->root.background=this->background;
+}
+
+void gui_internal_leave(struct gui_priv *this) {
+ graphics_draw_mode(this->gra, draw_mode_end);
+}
+
+void gui_internal_set_click_coord(struct gui_priv *this, struct point *p) {
+ struct coord c;
+ struct coord_geo g;
+ struct attr attr;
+ struct transformation *trans;
+ attr_free(this->click_coord_geo);
+ this->click_coord_geo=NULL;
+ if (p) {
+ trans=navit_get_trans(this->nav);
+ transform_reverse(trans, p, &c);
+ dbg(lvl_debug,"x=0x%x y=0x%x", c.x, c.y);
+ this->clickp.pro=transform_get_projection(trans);
+ this->clickp.x=c.x;
+ this->clickp.y=c.y;
+ transform_to_geo(this->clickp.pro, &c, &g);
+ attr.u.coord_geo=&g;
+ attr.type=attr_click_coord_geo;
+ this->click_coord_geo=attr_dup(&attr);
+ }
+}
+
+static void gui_internal_set_position_coord(struct gui_priv *this) {
+ struct transformation *trans;
+ struct attr attr,attrp;
+ struct coord c;
+
+ attr_free(this->position_coord_geo);
+ this->position_coord_geo=NULL;
+ if (navit_get_attr(this->nav, attr_vehicle, &attr, NULL) && attr.u.vehicle
+ && vehicle_get_attr(attr.u.vehicle, attr_position_coord_geo, &attrp, NULL)) {
+ trans=navit_get_trans(this->nav);
+ this->position_coord_geo=attr_dup(&attrp);
+ this->vehiclep.pro=transform_get_projection(trans);
+ transform_from_geo(this->vehiclep.pro, attrp.u.coord_geo, &c);
+ this->vehiclep.x=c.x;
+ this->vehiclep.y=c.y;
+ }
+}
+
+void gui_internal_enter_setup(struct gui_priv *this) {
+ if (!this->mouse_button_clicked_on_map)
+ gui_internal_set_position_coord(this);
+}
+
+void gui_internal_cmd_menu(struct gui_priv *this, int ignore, char *href) {
+ dbg(lvl_debug,"enter");
+ gui_internal_enter(this, ignore);
+ gui_internal_enter_setup(this);
+ // draw menu
+ if (href)
+ gui_internal_html_load_href(this, href, 0);
+ else
+ gui_internal_html_main_menu(this);
+}
+
+
+
+static void gui_internal_cmd_log_do(struct gui_priv *this, struct widget *widget) {
+ if (widget->text && strlen(widget->text)) {
+ if (this->position_coord_geo)
+ navit_textfile_debug_log_at(this->nav, &this->vehiclep, "type=log_entry label=\"%s\"",widget->text);
+ else
+ navit_textfile_debug_log(this->nav, "type=log_entry label=\"%s\"",widget->text);
+ }
+ g_free(widget->text);
+ widget->text=NULL;
+ gui_internal_prune_menu(this, NULL);
+ gui_internal_check_exit(this);
+}
+
+void gui_internal_cmd_log_clicked(struct gui_priv *this, struct widget *widget, void *data) {
+ gui_internal_cmd_log_do(this, widget->data);
+}
+
+
+void gui_internal_check_exit(struct gui_priv *this) {
+ struct graphics *gra=this->gra;
+ if (! this->root.children) {
+ gui_internal_search_idle_end(this);
+ gui_internal_search_list_destroy(this);
+ graphics_overlay_disable(gra, 0);
+ if (!navit_block(this->nav, 0)) {
+ if (this->redraw)
+ navit_draw(this->nav);
+ else
+ navit_draw_displaylist(this->nav);
+ }
+ }
+}
+
+static int gui_internal_get_attr(struct gui_priv *this, enum attr_type type, struct attr *attr) {
+ switch (type) {
+ case attr_active:
+ attr->u.num=this->root.children != NULL;
+ break;
+ case attr_click_coord_geo:
+ if (!this->click_coord_geo)
+ return 0;
+ *attr=*this->click_coord_geo;
+ break;
+ case attr_position_coord_geo:
+ if (!this->position_coord_geo)
+ return 0;
+ *attr=*this->position_coord_geo;
+ break;
+ case attr_pitch:
+ attr->u.num=this->pitch;
+ break;
+ case attr_button:
+ attr->u.num=this->mouse_button_clicked_on_map;
+ break;
+ case attr_navit:
+ attr->u.navit=this->nav;
+ break;
+ case attr_fullscreen:
+ attr->u.num=(this->fullscreen > 0);
+ break;
+ default:
+ return 0;
+ }
+ attr->type=type;
+ return 1;
+}
+
+static int gui_internal_add_attr(struct gui_priv *this, struct attr *attr) {
+ switch (attr->type) {
+ case attr_xml_text:
+ g_free(this->html_text);
+ this->html_text=g_strdup(attr->u.str);
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static int gui_internal_set_attr(struct gui_priv *this, struct attr *attr) {
+ switch (attr->type) {
+ case attr_fullscreen:
+ if ((this->fullscreen > 0) != (attr->u.num > 0)) {
+ graphics_draw_mode(this->gra, draw_mode_end);
+ this->win->fullscreen(this->win, attr->u.num > 0);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ }
+ this->fullscreen=attr->u.num;
+ return 1;
+ case attr_menu_on_map_click:
+ this->menu_on_map_click=attr->u.num;
+ return 1;
+ case attr_on_map_click:
+ g_free(this->on_map_click);
+ this->on_map_click=g_strdup(attr->u.str);
+ return 1;
+ default:
+ dbg(lvl_error,"Unknown attribute: %s",attr_to_name(attr->type));
+ return 1;
+ }
+}
+
+static void gui_internal_dbus_signal(struct gui_priv *this, struct point *p) {
+ struct displaylist_handle *dlh;
+ struct displaylist *display;
+ struct displayitem *di;
+ struct attr cb,**attr_list=NULL;
+ int valid=0;
+
+ display=navit_get_displaylist(this->nav);
+ dlh=graphics_displaylist_open(display);
+ while ((di=graphics_displaylist_next(dlh))) {
+ struct item *item=graphics_displayitem_get_item(di);
+ if (item_is_point(*item) && graphics_displayitem_get_displayed(di) &&
+ graphics_displayitem_within_dist(display, di, p, this->radius)) {
+ struct map_rect *mr=map_rect_new(item->map, NULL);
+ struct item *itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ struct attr attr;
+ if (itemo && item_attr_get(itemo, attr_data, &attr))
+ attr_list=attr_generic_add_attr(attr_list, &attr);
+ map_rect_destroy(mr);
+ }
+ }
+ graphics_displaylist_close(dlh);
+ if (attr_list && navit_get_attr(this->nav, attr_callback_list, &cb, NULL))
+ callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
+ attr_list_free(attr_list);
}
/**
@@ -2461,55 +2335,53 @@ static void gui_internal_dbus_signal(struct gui_priv *this, struct point *p)
*
* @author Martin Bruns (05/2012), mdankov
*/
-static int
-gui_internal_coordinate_parse(char *s, char plus, char minus, double *x)
-{
- int sign=0;
- char *degree, *minute, *second;
- double tmp;
-
- if(!s)
- return 0;
-
- if (strchr(s, minus)!=NULL)
- sign=-1;
- else if (strchr(s, plus)!=NULL)
- sign=1;
-
- if(!sign)
- return 0;
-
-
- /* Can't just use strtok here because ° is multibyte sequence in utf8 */
- degree=s;
- minute=strstr(s,"°");
- if(minute) {
- *minute=0;
- minute+=strlen("°");
- }
-
- sscanf(degree, "%lf", x);
-
- if(strchr(degree, plus) || strchr(degree, minus)) {
- dbg(lvl_debug,"degree %c/%c found\n",plus,minus);
- } else {/* DEGREES_MINUTES */
- if(!minute)
- return 0;
- minute = strtok(minute,"'");
- sscanf(minute, "%lf", &tmp);
- *x+=tmp/60;
- if(strchr(minute, plus) || strchr(minute, minus)) {
- dbg(lvl_debug,"minute %c/%c found\n",plus,minus);
- } else { /* DEGREES_MINUTES_SECONDS */
- second=strtok(NULL,"");
- if(!second)
- return 0;
- sscanf(second, "%lf", &tmp);
- *x+=tmp/3600;
- }
- }
- *x *= sign;
- return 1;
+static int gui_internal_coordinate_parse(char *s, char plus, char minus, double *x) {
+ int sign=0;
+ char *degree, *minute, *second;
+ double tmp;
+
+ if(!s)
+ return 0;
+
+ if (strchr(s, minus)!=NULL)
+ sign=-1;
+ else if (strchr(s, plus)!=NULL)
+ sign=1;
+
+ if(!sign)
+ return 0;
+
+
+ /* Can't just use strtok here because ° is multibyte sequence in utf8 */
+ degree=s;
+ minute=strstr(s,"°");
+ if(minute) {
+ *minute=0;
+ minute+=strlen("°");
+ }
+
+ sscanf(degree, "%lf", x);
+
+ if(strchr(degree, plus) || strchr(degree, minus)) {
+ dbg(lvl_debug,"degree %c/%c found",plus,minus);
+ } else {/* DEGREES_MINUTES */
+ if(!minute)
+ return 0;
+ minute = strtok(minute,"'");
+ sscanf(minute, "%lf", &tmp);
+ *x+=tmp/60;
+ if(strchr(minute, plus) || strchr(minute, minus)) {
+ dbg(lvl_debug,"minute %c/%c found",plus,minus);
+ } else { /* DEGREES_MINUTES_SECONDS */
+ second=strtok(NULL,"");
+ if(!second)
+ return 0;
+ sscanf(second, "%lf", &tmp);
+ *x+=tmp/3600;
+ }
+ }
+ *x *= sign;
+ return 1;
}
//##############################################################################################################
@@ -2517,35 +2389,34 @@ gui_internal_coordinate_parse(char *s, char plus, char minus, double *x)
//# Comment:
//# Authors: Martin Bruns (05/2012)
//##############################################################################################################
-static void
-gui_internal_cmd_enter_coord_do(struct gui_priv *this, struct widget *widget)
-{
- char *lat, *lng;
- char *widgettext;
- double latitude, longitude;
- dbg(lvl_debug,"text entered:%s\n", widget->text);
-
- /* possible entry can be identical to coord_format output but only space between lat and lng is allowed */
- widgettext=g_ascii_strup(widget->text,-1);
-
- lat=strtok(widgettext," ");
- lng=strtok(NULL,"");
-
- if(!lat || !lng){
- g_free(widgettext);
- return;
- }
- if( gui_internal_coordinate_parse(lat, 'N', 'S', &latitude) && gui_internal_coordinate_parse(lng, 'E', 'W', &longitude) ) {
- g_free(widgettext);
- widgettext=g_strdup_printf("%lf %lf", longitude, latitude);
- pcoord_parse(widgettext, projection_mg, &widget->c );
- } else if(!pcoord_parse(widget->text, projection_mg, &widget->c )) {
- g_free(widgettext);
- return;
- }
- g_free(widgettext);
-
- gui_internal_cmd_position(this, widget, (void*)8);
+static void gui_internal_cmd_enter_coord_do(struct gui_priv *this, struct widget *widget) {
+ char *lat, *lng;
+ char *widgettext;
+ double latitude, longitude;
+ dbg(lvl_debug,"text entered:%s", widget->text);
+
+ /* possible entry can be identical to coord_format output but only space between lat and lng is allowed */
+ widgettext=g_ascii_strup(widget->text,-1);
+
+ lat=strtok(widgettext," ");
+ lng=strtok(NULL,"");
+
+ if(!lat || !lng) {
+ g_free(widgettext);
+ return;
+ }
+ if( gui_internal_coordinate_parse(lat, 'N', 'S', &latitude)
+ && gui_internal_coordinate_parse(lng, 'E', 'W', &longitude) ) {
+ g_free(widgettext);
+ widgettext=g_strdup_printf("%lf %lf", longitude, latitude);
+ pcoord_parse(widgettext, projection_mg, &widget->c );
+ } else if(!pcoord_parse(widget->text, projection_mg, &widget->c )) {
+ g_free(widgettext);
+ return;
+ }
+ g_free(widgettext);
+
+ gui_internal_cmd_position(this, widget, (void*)8);
}
//##############################################################################################################
@@ -2553,11 +2424,9 @@ gui_internal_cmd_enter_coord_do(struct gui_priv *this, struct widget *widget)
//# Comment:
//# Authors: Martin Bruns (05/2012)
//##############################################################################################################
-void
-gui_internal_cmd_enter_coord_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- dbg(lvl_debug,"entered\n");
- gui_internal_cmd_enter_coord_do(this, widget->data);
+void gui_internal_cmd_enter_coord_clicked(struct gui_priv *this, struct widget *widget, void *data) {
+ dbg(lvl_debug,"entered");
+ gui_internal_cmd_enter_coord_do(this, widget->data);
}
/**
@@ -2565,263 +2434,271 @@ gui_internal_cmd_enter_coord_clicked(struct gui_priv *this, struct widget *widge
*
* @author Martin Schaller (04/2008), Stefan Klumpp (04/2008)
*/
-static void gui_internal_button(void *data, int pressed, int button, struct point *p)
-{
- struct gui_priv *this=data;
- struct graphics *gra=this->gra;
-
- dbg(lvl_debug,"enter %d %d\n", pressed, button);
- // if still on the map (not in the menu, yet):
- dbg(lvl_debug,"children=%p ignore_button=%d\n",this->root.children,this->ignore_button);
- if (!this->root.children || this->ignore_button) {
-
- this->ignore_button=0;
- // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
- if (!navit_handle_button(this->nav, pressed, button, p, NULL)) {
- dbg(lvl_debug,"navit has handled button\n");
- return;
- }
- dbg(lvl_debug,"menu_on_map_click=%d\n",this->menu_on_map_click);
- if (button != 1)
- return;
- if (this->on_map_click || this->menu_on_map_click) {
- this->mouse_button_clicked_on_map=1;
- gui_internal_set_click_coord(this, p);
- gui_internal_set_position_coord(this);
- if (this->on_map_click)
- command_evaluate(&this->self, this->on_map_click);
- else
- gui_internal_cmd_menu(this, 0, NULL);
- this->mouse_button_clicked_on_map=0;
- } else if (this->signal_on_map_click) {
- gui_internal_dbus_signal(this, p);
- return;
- }
- return;
- }
-
-
- /*
- * If already in the menu:
- */
-
- if (pressed) {
- this->pressed=1;
- this->current=*p;
- gui_internal_gesture_ring_clear(this);
- gui_internal_gesture_ring_add(this, p);
- gui_internal_highlight(this);
- } else {
- int dx,dy;
- gui_internal_gesture_ring_add(this, p);
- gui_internal_gesture_get_vector(this, 300, NULL, &dx, &dy);
- this->current.x=-1;
- this->current.y=-1;
- graphics_draw_mode(gra, draw_mode_begin);
- if(!gui_internal_gesture_do(this) && this->pressed!=2 && abs(dx)<this->icon_s && abs(dy)<this->icon_s)
- gui_internal_call_highlighted(this);
- this->pressed=0;
- if (!event_main_loop_has_quit()) {
- gui_internal_highlight(this);
- graphics_draw_mode(gra, draw_mode_end);
- gui_internal_check_exit(this);
- }
- }
-}
-
-static void
-gui_internal_setup(struct gui_priv *this)
-{
- struct color cbh={0x9fff,0x9fff,0x9fff,0xffff};
- struct color cf={0xbfff,0xbfff,0xbfff,0xffff};
- struct graphics *gra=this->gra;
- unsigned char *buffer;
- char *gui_file;
- int size;
-
- if (this->background)
- return;
- this->background=graphics_gc_new(gra);
- this->background2=graphics_gc_new(gra);
- this->highlight_background=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->highlight_background, &cbh);
- this->foreground=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->foreground, &cf);
- this->text_background=graphics_gc_new(gra);
- this->text_foreground=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->background, &this->background_color);
- graphics_gc_set_foreground(this->background2, &this->background2_color);
- graphics_gc_set_foreground(this->text_background, &this->text_background_color);
- graphics_gc_set_foreground(this->text_foreground, &this->text_foreground_color);
- gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
- if (file_get_contents(gui_file,&buffer,&size)) {
- char *command=g_malloc(size+1);
- strncpy(command,(const char *)buffer,size);
- command[size]=0;
- command_evaluate(&this->self, command);
- g_free(command);
- g_free(buffer);
- }
- g_free(gui_file);
+static void gui_internal_button(void *data, int pressed, int button, struct point *p) {
+ struct gui_priv *this=data;
+ struct graphics *gra=this->gra;
+
+ dbg(lvl_debug,"enter %d %d", pressed, button);
+ // if still on the map (not in the menu, yet):
+ dbg(lvl_debug,"children=%p ignore_button=%d",this->root.children,this->ignore_button);
+ if (!this->root.children || this->ignore_button) {
+
+ this->ignore_button=0;
+ // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
+ if (!navit_handle_button(this->nav, pressed, button, p, NULL)) {
+ dbg(lvl_debug,"navit has handled button");
+ return;
+ }
+ dbg(lvl_debug,"menu_on_map_click=%d",this->menu_on_map_click);
+ if (button != 1)
+ return;
+ if (this->on_map_click || this->menu_on_map_click) {
+ this->mouse_button_clicked_on_map=1;
+ gui_internal_set_click_coord(this, p);
+ gui_internal_set_position_coord(this);
+ if (this->on_map_click)
+ command_evaluate(&this->self, this->on_map_click);
+ else
+ gui_internal_cmd_menu(this, 0, NULL);
+ this->mouse_button_clicked_on_map=0;
+ } else if (this->signal_on_map_click) {
+ gui_internal_dbus_signal(this, p);
+ return;
+ }
+ return;
+ }
+
+
+ /*
+ * If already in the menu:
+ */
+
+ if (pressed) {
+ this->pressed=1;
+ this->current=*p;
+ gui_internal_gesture_ring_clear(this);
+ gui_internal_gesture_ring_add(this, p);
+ gui_internal_highlight(this);
+ } else {
+ int dx,dy;
+ gui_internal_gesture_ring_add(this, p);
+ gui_internal_gesture_get_vector(this, 300, NULL, &dx, &dy);
+ this->current.x=-1;
+ this->current.y=-1;
+ graphics_draw_mode(gra, draw_mode_begin);
+ if(!gui_internal_gesture_do(this) && this->pressed!=2 && abs(dx)<this->icon_s && abs(dy)<this->icon_s)
+ gui_internal_call_highlighted(this);
+ this->pressed=0;
+ if (!event_main_loop_has_quit()) {
+ gui_internal_highlight(this);
+ graphics_draw_mode(gra, draw_mode_end);
+ gui_internal_check_exit(this);
+ }
+ }
+}
+
+static void gui_internal_setup(struct gui_priv *this) {
+ struct color cbh= {0x9fff,0x9fff,0x9fff,0xffff};
+ struct color cf= {0xbfff,0xbfff,0xbfff,0xffff};
+ struct graphics *gra=this->gra;
+ unsigned char *buffer;
+ char *gui_file;
+ int size;
+
+ if (this->background)
+ return;
+ this->background=graphics_gc_new(gra);
+ this->background2=graphics_gc_new(gra);
+ this->highlight_background=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->highlight_background, &cbh);
+ this->foreground=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->foreground, &cf);
+ this->text_background=graphics_gc_new(gra);
+ this->text_foreground=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->background, &this->background_color);
+ graphics_gc_set_foreground(this->background2, &this->background2_color);
+ graphics_gc_set_foreground(this->text_background, &this->text_background_color);
+ graphics_gc_set_foreground(this->text_foreground, &this->text_foreground_color);
+ gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
+ if (file_get_contents(gui_file,&buffer,&size)) {
+ char *command=g_malloc(size+1);
+ strncpy(command,(const char *)buffer,size);
+ command[size]=0;
+ command_evaluate(&this->self, command);
+ g_free(command);
+ g_free(buffer);
+ }
+ g_free(gui_file);
+}
+
+/**
+ * @brief Callback function invoked when display area is resized
+ *
+ * @param data A generic argument structure pointer, here we use it to store the the internal GUI context (this)
+ * @param wnew The new width of the display area
+ * @param hnew The new height of the display area
+ *
+ * @author Martin Schaller
+ * @date 2008/04
+ */
+static void gui_internal_resize(void *data, int wnew, int hnew) {
+ GList *l;
+ struct widget *w;
+
+ struct gui_priv *this=data;
+ int changed=0;
+
+ gui_internal_setup(this);
+
+ changed=gui_internal_menu_needs_resizing(this, &(this->root), wnew, hnew);
+
+ /*
+ * If we're drawing behind system bars on Android, watching for actual size changes will not catch
+ * fullscreen toggle events. As a workaround, always assume a size change if padding is supplied.
+ */
+ if (!changed && this->gra && graphics_get_data(this->gra, "padding"))
+ changed = 1;
+ navit_handle_resize(this->nav, wnew, hnew);
+ if (this->root.children) {
+ if (changed) {
+ l = g_list_last(this->root.children);
+ if (l) {
+ w=l->data;
+ if (!gui_internal_widget_reload_href(this,
+ w)) { /* If the foremost widget is a HTML menu, reload & redraw it from its href */
+ /* If not, resize the foremost widget */
+ dbg(lvl_debug, "Current GUI displayed is not a menu");
+ dbg(lvl_debug, "Will call resize with w=%d, h=%d", wnew, hnew)
+ gui_internal_menu_resize(this, wnew, hnew);
+ gui_internal_menu_render(this);
+ } else {
+ dbg(lvl_debug,"Current GUI displayed is a menu");
+ }
+ }
+ } else {
+ gui_internal_menu_render(this);
+ }
+ }
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gui_internal_resize(void *data, int w, int h)
-{
- struct gui_priv *this=data;
- int changed=0;
-
- gui_internal_setup(this);
-
- if (this->root.w != w || this->root.h != h) {
- this->root.w=w;
- this->root.h=h;
- changed=1;
- }
- /*
- * If we're drawing behind system bars on Android, watching for actual size changes will not catch
- * fullscreen toggle events. As a workaround, always assume a size change if padding is supplied.
- */
- if (!changed && this->gra && graphics_get_data(this->gra, "padding"))
- changed = 1;
- dbg(lvl_debug,"w=%d h=%d children=%p\n", w, h, this->root.children);
- navit_handle_resize(this->nav, w, h);
- if (this->root.children) {
- if (changed) {
- gui_internal_html_main_menu(this);
- } else {
- gui_internal_menu_render(this);
- }
- }
-}
-
-static void
-gui_internal_keynav_point(struct widget *w, int dx, int dy, struct point *p)
-{
- p->x=w->p.x+w->w/2;
- p->y=w->p.y+w->h/2;
- if (dx < 0)
- p->x=w->p.x;
- if (dx > 0)
- p->x=w->p.x+w->w;
- if (dy < 0)
- p->y=w->p.y;
- if (dy > 0)
- p->y=w->p.y+w->h;
-}
-
-static struct widget*
-gui_internal_keynav_find_next_sensitive_child(struct widget *wi) {
- GList *l=wi->children;
- if (wi->state & STATE_OFFSCREEN)
- return NULL;
- if (wi->state & STATE_SENSITIVE)
- return wi;
- while (l) {
- struct widget* tmp = gui_internal_keynav_find_next_sensitive_child(l->data);
- if (tmp)
- return tmp;
- l=g_list_next(l);
- }
- return NULL;
-}
-
-static int
-gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result) {
- GList *l=wi->children;
- if (wi == current_highlight)
- return 1;
- while (l) {
- struct widget *child=l->data;
- l=g_list_next(l);
- if (gui_internal_keynav_find_next(child, current_highlight, result)) {
- while (l) {
- struct widget *new = gui_internal_keynav_find_next_sensitive_child(l->data);
- if (new) {
- *result = new;
- /* Found one! */
- return 0;
- }
- l=g_list_next(l);
- }
- /* Try parent */
- return 1;
- }
- }
- return 0;
+static void gui_internal_keynav_point(struct widget *w, int dx, int dy, struct point *p) {
+ p->x=w->p.x+w->w/2;
+ p->y=w->p.y+w->h/2;
+ if (dx < 0)
+ p->x=w->p.x;
+ if (dx > 0)
+ p->x=w->p.x+w->w;
+ if (dy < 0)
+ p->y=w->p.y;
+ if (dy > 0)
+ p->y=w->p.y+w->h;
+}
+
+static struct widget* gui_internal_keynav_find_next_sensitive_child(struct widget *wi) {
+ GList *l=wi->children;
+ if (wi->state & STATE_OFFSCREEN)
+ return NULL;
+ if (wi->state & STATE_SENSITIVE)
+ return wi;
+ while (l) {
+ struct widget* tmp = gui_internal_keynav_find_next_sensitive_child(l->data);
+ if (tmp)
+ return tmp;
+ l=g_list_next(l);
+ }
+ return NULL;
+}
+
+static int gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result) {
+ GList *l=wi->children;
+ if (wi == current_highlight)
+ return 1;
+ while (l) {
+ struct widget *child=l->data;
+ l=g_list_next(l);
+ if (gui_internal_keynav_find_next(child, current_highlight, result)) {
+ while (l) {
+ struct widget *new = gui_internal_keynav_find_next_sensitive_child(l->data);
+ if (new) {
+ *result = new;
+ /* Found one! */
+ return 0;
+ }
+ l=g_list_next(l);
+ }
+ /* Try parent */
+ return 1;
+ }
+ }
+ return 0;
}
#define RESULT_FOUND 1
#define NO_RESULT_YET 0
-static int
-gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result) {
- if (wi == current_highlight && *result) {
- // Reached current widget; last widget found is the result.
- return RESULT_FOUND;
- }
- // If widget is off-screen, do not recurse into it.
- if (wi->state & STATE_OFFSCREEN)
- return NO_RESULT_YET;
- if (wi->state & STATE_SENSITIVE)
- *result= wi;
- GList *l=wi->children;
- while (l) {
- struct widget *child=l->data;
- if (gui_internal_keynav_find_prev(child, current_highlight, result) == RESULT_FOUND) {
- return RESULT_FOUND;
- }
- l=g_list_next(l);
- }
- // If no sensitive widget is found before "current_highlight", return the last sensitive widget when
- // recursion terminates.
- return NO_RESULT_YET;
-}
-
-static void
-gui_internal_keynav_find_closest(struct widget *wi, struct point *p, int dx, int dy, int *distance, struct widget **result)
-{
- GList *l=wi->children;
- // Skip hidden elements
- if (wi->p.x==0 && wi->p.y==0 && wi->w==0 && wi->h==0)
- return;
- if ((wi->state & STATE_SENSITIVE) ) {
- int dist1,dist2;
- struct point wp;
- gui_internal_keynav_point(wi, -dx, -dy, &wp);
- if (dx) {
- dist1=(wp.x-p->x)*dx;
- dist2=wp.y-p->y;
- } else if (dy) {
- dist1=(wp.y-p->y)*dy;
- dist2=wp.x-p->x;
- } else {
- dist2=wp.x-p->x;
- dist1=wp.y-p->y;
- if (dist1 < 0)
- dist1=-dist1;
- }
- dbg(lvl_debug,"checking %d,%d %d %d against %d,%d-%d,%d result %d,%d\n", p->x, p->y, dx, dy, wi->p.x, wi->p.y, wi->p.x+wi->w, wi->p.y+wi->h, dist1, dist2);
- if (dist1 >= 0) {
- if (dist2 < 0)
- dist1-=dist2;
- else
- dist1+=dist2;
- if (dist1 < *distance) {
- *result=wi;
- *distance=dist1;
- }
- }
- }
- while (l) {
- struct widget *child=l->data;
- gui_internal_keynav_find_closest(child, p, dx, dy, distance, result);
- l=g_list_next(l);
- }
+static int gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result) {
+ if (wi == current_highlight && *result) {
+ // Reached current widget; last widget found is the result.
+ return RESULT_FOUND;
+ }
+ // If widget is off-screen, do not recurse into it.
+ if (wi->state & STATE_OFFSCREEN)
+ return NO_RESULT_YET;
+ if (wi->state & STATE_SENSITIVE)
+ *result= wi;
+ GList *l=wi->children;
+ while (l) {
+ struct widget *child=l->data;
+ if (gui_internal_keynav_find_prev(child, current_highlight, result) == RESULT_FOUND) {
+ return RESULT_FOUND;
+ }
+ l=g_list_next(l);
+ }
+ // If no sensitive widget is found before "current_highlight", return the last sensitive widget when
+ // recursion terminates.
+ return NO_RESULT_YET;
+}
+
+static void gui_internal_keynav_find_closest(struct widget *wi, struct point *p, int dx, int dy, int *distance,
+ struct widget **result) {
+ GList *l=wi->children;
+ // Skip hidden elements
+ if (wi->p.x==0 && wi->p.y==0 && wi->w==0 && wi->h==0)
+ return;
+ if ((wi->state & STATE_SENSITIVE) ) {
+ int dist1,dist2;
+ struct point wp;
+ gui_internal_keynav_point(wi, -dx, -dy, &wp);
+ if (dx) {
+ dist1=(wp.x-p->x)*dx;
+ dist2=wp.y-p->y;
+ } else if (dy) {
+ dist1=(wp.y-p->y)*dy;
+ dist2=wp.x-p->x;
+ } else {
+ dist2=wp.x-p->x;
+ dist1=wp.y-p->y;
+ if (dist1 < 0)
+ dist1=-dist1;
+ }
+ dbg(lvl_debug,"checking %d,%d %d %d against %d,%d-%d,%d result %d,%d", p->x, p->y, dx, dy, wi->p.x, wi->p.y,
+ wi->p.x+wi->w, wi->p.y+wi->h, dist1, dist2);
+ if (dist1 >= 0) {
+ if (dist2 < 0)
+ dist1-=dist2;
+ else
+ dist1+=dist2;
+ if (dist1 < *distance) {
+ *result=wi;
+ *distance=dist1;
+ }
+ }
+ }
+ while (l) {
+ struct widget *child=l->data;
+ gui_internal_keynav_find_closest(child, p, dx, dy, distance, result);
+ l=g_list_next(l);
+ }
}
/**
@@ -2836,59 +2713,56 @@ gui_internal_keynav_find_closest(struct widget *wi, struct point *p, int dx, int
* @param rotary (0/1) input from rotary encoder - dx indicates forwards/backwards movement
* through all widgets
*/
-static void
-gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary)
-{
- struct widget *result,*menu=g_list_last(this->root.children)->data;
- struct widget *current_highlight = NULL;
- struct point p;
- int distance;
- if (this->highlighted && this->highlighted_menu == menu) {
- gui_internal_keynav_point(this->highlighted, dx, dy, &p);
- current_highlight = this->highlighted;
- }
- else {
- p.x=0;
- p.y=0;
- distance=INT_MAX;
- result=NULL;
- gui_internal_keynav_find_closest(menu, &p, 0, 0, &distance, &result);
- if (result) {
- gui_internal_keynav_point(result, dx, dy, &p);
- dbg(lvl_debug,"result origin=%p p=%d,%d\n", result, p.x, p.y);
- current_highlight = result;
- }
- }
- result=NULL;
- distance=INT_MAX;
- if (rotary && dx > 0)
- gui_internal_keynav_find_next(menu, current_highlight, &result);
- else if (rotary && dx < 0)
- gui_internal_keynav_find_prev(menu, current_highlight, &result);
- else
- gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
- dbg(lvl_debug,"result=%p\n", result);
- if (! result) {
- if (dx < 0) {
- p.x=this->root.w;
- if (rotary) p.y = this->root.h;
- }
- if (dx > 0) {
- p.x=0;
- if (rotary) p.y = 0;
- }
- if (dy < 0)
- p.y=this->root.h;
- if (dy > 0)
- p.y=0;
- result=NULL;
- distance=INT_MAX;
- gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
- dbg(lvl_debug,"wraparound result=%p\n", result);
- }
- gui_internal_highlight_do(this, result);
- if (result)
- gui_internal_say(this, result, 1);
+static void gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary) {
+ struct widget *result,*menu=g_list_last(this->root.children)->data;
+ struct widget *current_highlight = NULL;
+ struct point p;
+ int distance;
+ if (this->highlighted && this->highlighted_menu == menu) {
+ gui_internal_keynav_point(this->highlighted, dx, dy, &p);
+ current_highlight = this->highlighted;
+ } else {
+ p.x=0;
+ p.y=0;
+ distance=INT_MAX;
+ result=NULL;
+ gui_internal_keynav_find_closest(menu, &p, 0, 0, &distance, &result);
+ if (result) {
+ gui_internal_keynav_point(result, dx, dy, &p);
+ dbg(lvl_debug,"result origin=%p p=%d,%d", result, p.x, p.y);
+ current_highlight = result;
+ }
+ }
+ result=NULL;
+ distance=INT_MAX;
+ if (rotary && dx > 0)
+ gui_internal_keynav_find_next(menu, current_highlight, &result);
+ else if (rotary && dx < 0)
+ gui_internal_keynav_find_prev(menu, current_highlight, &result);
+ else
+ gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
+ dbg(lvl_debug,"result=%p", result);
+ if (! result) {
+ if (dx < 0) {
+ p.x=this->root.w;
+ if (rotary) p.y = this->root.h;
+ }
+ if (dx > 0) {
+ p.x=0;
+ if (rotary) p.y = 0;
+ }
+ if (dy < 0)
+ p.y=this->root.h;
+ if (dy > 0)
+ p.y=0;
+ result=NULL;
+ distance=INT_MAX;
+ gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
+ dbg(lvl_debug,"wraparound result=%p", result);
+ }
+ gui_internal_highlight_do(this, result);
+ if (result)
+ gui_internal_say(this, result, 1);
}
//##############################################################################################################
@@ -2896,87 +2770,86 @@ gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int ro
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static void gui_internal_keypress(void *data, char *key)
-{
- struct gui_priv *this=data;
- int w,h;
- struct point p;
- if (!this->root.children) {
- transform_get_size(navit_get_trans(this->nav), &w, &h);
- switch (*key) {
- case NAVIT_KEY_UP:
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_DOWN:
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_LEFT:
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_RIGHT:
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_ZOOM_IN:
- navit_zoom_in(this->nav, 2, NULL);
- break;
- case NAVIT_KEY_ZOOM_OUT:
- navit_zoom_out(this->nav, 2, NULL);
- break;
- case NAVIT_KEY_RETURN:
- case NAVIT_KEY_MENU:
- gui_internal_set_click_coord(this, NULL);
- gui_internal_cmd_menu(this, 0, NULL);
- break;
- }
- return;
- }
- graphics_draw_mode(this->gra, draw_mode_begin);
- switch (*key) {
- case NAVIT_KEY_PAGE_DOWN:
- gui_internal_keynav_highlight_next(this,1,0,1);
- break;
- case NAVIT_KEY_PAGE_UP:
- gui_internal_keynav_highlight_next(this,-1,0,1);
- break;
- case NAVIT_KEY_LEFT:
- gui_internal_keynav_highlight_next(this,-1,0,0);
- break;
- case NAVIT_KEY_RIGHT:
- gui_internal_keynav_highlight_next(this,1,0,0);
- break;
- case NAVIT_KEY_UP:
- gui_internal_keynav_highlight_next(this,0,-1,0);
- break;
- case NAVIT_KEY_DOWN:
- gui_internal_keynav_highlight_next(this,0,1,0);
- break;
- case NAVIT_KEY_BACK:
- if (g_list_length(this->root.children) > 1)
- gui_internal_back(this, NULL, NULL);
- else
- gui_internal_prune_menu(this, NULL);
- break;
- case NAVIT_KEY_RETURN:
- if (this->highlighted && this->highlighted_menu == g_list_last(this->root.children)->data)
- gui_internal_call_highlighted(this);
- else
- gui_internal_keypress_do(this, key);
- break;
- default:
- gui_internal_keypress_do(this, key);
- }
- if (!event_main_loop_has_quit()) {
- graphics_draw_mode(this->gra, draw_mode_end);
- gui_internal_check_exit(this);
- }
+static void gui_internal_keypress(void *data, char *key) {
+ struct gui_priv *this=data;
+ int w,h;
+ struct point p;
+ if (!this->root.children) {
+ transform_get_size(navit_get_trans(this->nav), &w, &h);
+ switch (*key) {
+ case NAVIT_KEY_UP:
+ p.x=w/2;
+ p.y=0;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case NAVIT_KEY_DOWN:
+ p.x=w/2;
+ p.y=h;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case NAVIT_KEY_LEFT:
+ p.x=0;
+ p.y=h/2;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case NAVIT_KEY_RIGHT:
+ p.x=w;
+ p.y=h/2;
+ navit_set_center_screen(this->nav, &p, 1);
+ break;
+ case NAVIT_KEY_ZOOM_IN:
+ navit_zoom_in(this->nav, 2, NULL);
+ break;
+ case NAVIT_KEY_ZOOM_OUT:
+ navit_zoom_out(this->nav, 2, NULL);
+ break;
+ case NAVIT_KEY_RETURN:
+ case NAVIT_KEY_MENU:
+ gui_internal_set_click_coord(this, NULL);
+ gui_internal_cmd_menu(this, 0, NULL);
+ break;
+ }
+ return;
+ }
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ switch (*key) {
+ case NAVIT_KEY_PAGE_DOWN:
+ gui_internal_keynav_highlight_next(this,1,0,1);
+ break;
+ case NAVIT_KEY_PAGE_UP:
+ gui_internal_keynav_highlight_next(this,-1,0,1);
+ break;
+ case NAVIT_KEY_LEFT:
+ gui_internal_keynav_highlight_next(this,-1,0,0);
+ break;
+ case NAVIT_KEY_RIGHT:
+ gui_internal_keynav_highlight_next(this,1,0,0);
+ break;
+ case NAVIT_KEY_UP:
+ gui_internal_keynav_highlight_next(this,0,-1,0);
+ break;
+ case NAVIT_KEY_DOWN:
+ gui_internal_keynav_highlight_next(this,0,1,0);
+ break;
+ case NAVIT_KEY_BACK:
+ if (g_list_length(this->root.children) > 1)
+ gui_internal_back(this, NULL, NULL);
+ else
+ gui_internal_prune_menu(this, NULL);
+ break;
+ case NAVIT_KEY_RETURN:
+ if (this->highlighted && this->highlighted_menu == g_list_last(this->root.children)->data)
+ gui_internal_call_highlighted(this);
+ else
+ gui_internal_keypress_do(this, key);
+ break;
+ default:
+ gui_internal_keypress_do(this, key);
+ }
+ if (!event_main_loop_has_quit()) {
+ graphics_draw_mode(this->gra, draw_mode_end);
+ gui_internal_check_exit(this);
+ }
}
@@ -2985,45 +2858,43 @@ static void gui_internal_keypress(void *data, char *key)
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static int gui_internal_set_graphics(struct gui_priv *this, struct graphics *gra)
-{
- struct window *win;
- struct transformation *trans=navit_get_trans(this->nav);
-
- win=graphics_get_data(gra, "window");
- if (! win) {
- dbg(lvl_error, "failed to obtain window from graphics plugin, cannot set graphics\n");
- return 1;
- }
- navit_ignore_graphics_events(this->nav, 1);
- this->gra=gra;
- this->win=win;
- navit_ignore_graphics_events(this->nav, 1);
- transform_get_size(trans, &this->root.w, &this->root.h);
- this->resize_cb=callback_new_attr_1(callback_cast(gui_internal_resize), attr_resize, this);
- graphics_add_callback(gra, this->resize_cb);
- this->button_cb=callback_new_attr_1(callback_cast(gui_internal_button), attr_button, this);
- graphics_add_callback(gra, this->button_cb);
- this->motion_cb=callback_new_attr_1(callback_cast(gui_internal_motion), attr_motion, this);
- graphics_add_callback(gra, this->motion_cb);
- this->keypress_cb=callback_new_attr_1(callback_cast(gui_internal_keypress), attr_keypress, this);
- graphics_add_callback(gra, this->keypress_cb);
- this->window_closed_cb=callback_new_attr_1(callback_cast(gui_internal_window_closed), attr_window_closed, this);
- graphics_add_callback(gra, this->window_closed_cb);
-
- // set fullscreen if needed
- if (this->fullscreen)
- this->win->fullscreen(this->win, this->fullscreen != 0);
- /* Was resize callback already issued? */
- if (navit_get_ready(this->nav) & 2)
- gui_internal_setup(this);
- return 0;
-}
-
-static void gui_internal_disable_suspend(struct gui_priv *this)
-{
- if (this->win->disable_suspend)
- this->win->disable_suspend(this->win);
+static int gui_internal_set_graphics(struct gui_priv *this, struct graphics *gra) {
+ struct window *win;
+ struct transformation *trans=navit_get_trans(this->nav);
+
+ win=graphics_get_data(gra, "window");
+ if (! win) {
+ dbg(lvl_error, "failed to obtain window from graphics plugin, cannot set graphics");
+ return 1;
+ }
+ navit_ignore_graphics_events(this->nav, 1);
+ this->gra=gra;
+ this->win=win;
+ navit_ignore_graphics_events(this->nav, 1);
+ transform_get_size(trans, &this->root.w, &this->root.h);
+ this->resize_cb=callback_new_attr_1(callback_cast(gui_internal_resize), attr_resize, this);
+ graphics_add_callback(gra, this->resize_cb);
+ this->button_cb=callback_new_attr_1(callback_cast(gui_internal_button), attr_button, this);
+ graphics_add_callback(gra, this->button_cb);
+ this->motion_cb=callback_new_attr_1(callback_cast(gui_internal_motion), attr_motion, this);
+ graphics_add_callback(gra, this->motion_cb);
+ this->keypress_cb=callback_new_attr_1(callback_cast(gui_internal_keypress), attr_keypress, this);
+ graphics_add_callback(gra, this->keypress_cb);
+ this->window_closed_cb=callback_new_attr_1(callback_cast(gui_internal_window_closed), attr_window_closed, this);
+ graphics_add_callback(gra, this->window_closed_cb);
+
+ // set fullscreen if needed
+ if (this->fullscreen)
+ this->win->fullscreen(this->win, this->fullscreen != 0);
+ /* Was resize callback already issued? */
+ if (navit_get_ready(this->nav) & 2)
+ gui_internal_setup(this);
+ return 0;
+}
+
+static void gui_internal_disable_suspend(struct gui_priv *this) {
+ if (this->win->disable_suspend)
+ this->win->disable_suspend(this->win);
}
//##############################################################################################################
@@ -3032,181 +2903,159 @@ static void gui_internal_disable_suspend(struct gui_priv *this)
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
struct gui_methods gui_internal_methods = {
- NULL,
- NULL,
- gui_internal_set_graphics,
- NULL,
- NULL,
- NULL,
- gui_internal_disable_suspend,
- gui_internal_get_attr,
- gui_internal_add_attr,
- gui_internal_set_attr,
+ NULL,
+ NULL,
+ gui_internal_set_graphics,
+ NULL,
+ NULL,
+ NULL,
+ gui_internal_disable_suspend,
+ gui_internal_get_attr,
+ gui_internal_add_attr,
+ gui_internal_set_attr,
};
-static void
-gui_internal_add_callback(struct gui_priv *priv, struct callback *cb)
-{
- callback_list_add(priv->cbl, cb);
+static void gui_internal_add_callback(struct gui_priv *priv, struct callback *cb) {
+ callback_list_add(priv->cbl, cb);
}
-static void
-gui_internal_remove_callback(struct gui_priv *priv, struct callback *cb)
-{
- callback_list_remove(priv->cbl, cb);
+static void gui_internal_remove_callback(struct gui_priv *priv, struct callback *cb) {
+ callback_list_remove(priv->cbl, cb);
}
static struct gui_internal_methods gui_internal_methods_ext = {
- gui_internal_add_callback,
- gui_internal_remove_callback,
- gui_internal_menu_render,
- image_new_xs,
- image_new_l,
+ gui_internal_add_callback,
+ gui_internal_remove_callback,
+ gui_internal_menu_render,
+ image_new_xs,
+ image_new_l,
};
-static enum flags
-gui_internal_get_flags(struct widget *widget)
-{
- return widget->flags;
+static enum flags gui_internal_get_flags(struct widget *widget) {
+ return widget->flags;
}
-static void
-gui_internal_set_flags(struct widget *widget, enum flags flags)
-{
- widget->flags=flags;
+static void gui_internal_set_flags(struct widget *widget, enum flags flags) {
+ widget->flags=flags;
}
-static int
-gui_internal_get_state(struct widget *widget)
-{
- return widget->state;
+static int gui_internal_get_state(struct widget *widget) {
+ return widget->state;
}
-static void
-gui_internal_set_state(struct widget *widget, int state)
-{
- widget->state=state;
+static void gui_internal_set_state(struct widget *widget, int state) {
+ widget->state=state;
}
-static void
-gui_internal_set_func(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget, void *data))
-{
- widget->func=func;
+static void gui_internal_set_func(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget,
+ void *data)) {
+ widget->func=func;
}
-static void
-gui_internal_set_data(struct widget *widget, void *data)
-{
- widget->data=data;
+static void gui_internal_set_data(struct widget *widget, void *data) {
+ widget->data=data;
}
-static void
-gui_internal_set_default_background(struct gui_priv *this, struct widget *widget)
-{
- widget->background=this->background;
+static void gui_internal_set_default_background(struct gui_priv *this, struct widget *widget) {
+ widget->background=this->background;
}
static struct gui_internal_widget_methods gui_internal_widget_methods = {
- gui_internal_widget_append,
- gui_internal_button_new,
- gui_internal_button_new_with_callback,
- gui_internal_box_new,
- gui_internal_label_new,
- gui_internal_image_new,
- gui_internal_keyboard,
- gui_internal_menu,
- gui_internal_get_flags,
- gui_internal_set_flags,
- gui_internal_get_state,
- gui_internal_set_state,
- gui_internal_set_func,
- gui_internal_set_data,
- gui_internal_set_default_background,
+ gui_internal_widget_append,
+ gui_internal_button_new,
+ gui_internal_button_new_with_callback,
+ gui_internal_box_new,
+ gui_internal_label_new,
+ gui_internal_image_new,
+ gui_internal_keyboard,
+ gui_internal_menu,
+ gui_internal_get_flags,
+ gui_internal_set_flags,
+ gui_internal_get_state,
+ gui_internal_set_state,
+ gui_internal_set_func,
+ gui_internal_set_data,
+ gui_internal_set_default_background,
};
/**
* @brief finds the intersection point of 2 lines
*
- * @param coord a1, a2, b1, b2 : coords of the start and
+ * @param coord a1, a2, b1, b2 : coords of the start and
* end of the first and the second line
* @param coord res, will become the coords of the intersection if found
* @return : TRUE if intersection found, otherwise FALSE
*/
-int
-line_intersection(struct coord* a1, struct coord *a2, struct coord * b1, struct coord *b2, struct coord *res)
-{
- int n, a, b;
- int adx=a2->x-a1->x;
- int ady=a2->y-a1->y;
- int bdx=b2->x-b1->x;
- int bdy=b2->y-b1->y;
- n = bdy * adx - bdx * ady;
- a = bdx * (a1->y - b1->y) - bdy * (a1->x - b1->x);
- b = adx * (a1->y - b1->y) - ady * (a1->x - b1->x);
- if (n < 0) {
- n = -n;
- a = -a;
- b = -b;
- }
- if (a < 0 || b < 0)
- return FALSE;
- if (a > n || b > n)
- return FALSE;
- if (n == 0) {
- dbg(lvl_info,"a=%d b=%d n=%d\n", a, b, n);
- dbg(lvl_info,"a1=0x%x,0x%x ad %d,%d\n", a1->x, a1->y, adx, ady);
- dbg(lvl_info,"b1=0x%x,0x%x bd %d,%d\n", b1->x, b1->y, bdx, bdy);
- dbg(lvl_info,"No intersection found, lines assumed parallel ?\n");
- return FALSE;
- }
- res->x = a1->x + a * adx / n;
- res->y = a1->y + a * ady / n;
- return TRUE;
+int line_intersection(struct coord* a1, struct coord *a2, struct coord * b1, struct coord *b2, struct coord *res) {
+ int n, a, b;
+ int adx=a2->x-a1->x;
+ int ady=a2->y-a1->y;
+ int bdx=b2->x-b1->x;
+ int bdy=b2->y-b1->y;
+ n = bdy * adx - bdx * ady;
+ a = bdx * (a1->y - b1->y) - bdy * (a1->x - b1->x);
+ b = adx * (a1->y - b1->y) - ady * (a1->x - b1->x);
+ if (n < 0) {
+ n = -n;
+ a = -a;
+ b = -b;
+ }
+ if (a < 0 || b < 0)
+ return FALSE;
+ if (a > n || b > n)
+ return FALSE;
+ if (n == 0) {
+ dbg(lvl_info,"a=%d b=%d n=%d", a, b, n);
+ dbg(lvl_info,"a1=0x%x,0x%x ad %d,%d", a1->x, a1->y, adx, ady);
+ dbg(lvl_info,"b1=0x%x,0x%x bd %d,%d", b1->x, b1->y, bdx, bdy);
+ dbg(lvl_info,"No intersection found, lines assumed parallel ?");
+ return FALSE;
+ }
+ res->x = a1->x + a * adx / n;
+ res->y = a1->y + a * ady / n;
+ return TRUE;
}
struct heightline *
-item_get_heightline(struct item *item)
-{
- struct heightline *ret=NULL;
- struct street_data *sd;
- struct attr attr;
- int i,height;
-
- if (item_attr_get(item, attr_label, &attr)) {
- height=atoi(attr.u.str);
- sd=street_get_data(item);
- if (sd && sd->count > 1) {
- ret=g_malloc(sizeof(struct heightline)+sd->count*sizeof(struct coord));
- ret->bbox.lu=sd->c[0];
- ret->bbox.rl=sd->c[0];
- ret->count=sd->count;
- ret->height=height;
- for (i = 0 ; i < sd->count ; i++) {
- ret->c[i]=sd->c[i];
- coord_rect_extend(&ret->bbox, sd->c+i);
- }
- }
- street_data_free(sd);
- }
- return ret;
+item_get_heightline(struct item *item) {
+ struct heightline *ret=NULL;
+ struct street_data *sd;
+ struct attr attr;
+ int i,height;
+
+ if (item_attr_get(item, attr_label, &attr)) {
+ height=atoi(attr.u.str);
+ sd=street_get_data(item);
+ if (sd && sd->count > 1) {
+ ret=g_malloc(sizeof(struct heightline)+sd->count*sizeof(struct coord));
+ ret->bbox.lu=sd->c[0];
+ ret->bbox.rl=sd->c[0];
+ ret->count=sd->count;
+ ret->height=height;
+ for (i = 0 ; i < sd->count ; i++) {
+ ret->c[i]=sd->c[i];
+ coord_rect_extend(&ret->bbox, sd->c+i);
+ }
+ }
+ street_data_free(sd);
+ }
+ return ret;
}
/**
* @brief Called when the route is updated.
*/
-void
-gui_internal_route_update(struct gui_priv * this, struct navit * navit, struct vehicle *v)
-{
+void gui_internal_route_update(struct gui_priv * this, struct navit * navit, struct vehicle *v) {
- if(this->route_data.route_showing) {
- gui_internal_populate_route_table(this,navit);
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
- }
+ if(this->route_data.route_showing) {
+ gui_internal_populate_route_table(this,navit);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ }
}
@@ -3218,14 +3067,12 @@ gui_internal_route_update(struct gui_priv * this, struct navit * navit, struct v
* The main purpose of this function is to remove the widgets from
* references route_data because those widgets are about to be freed.
*/
-void
-gui_internal_route_screen_free(struct gui_priv * this_,struct widget * w)
-{
- if(this_) {
- this_->route_data.route_showing=0;
- this_->route_data.route_table=NULL;
- g_free(w);
- }
+void gui_internal_route_screen_free(struct gui_priv * this_,struct widget * w) {
+ if(this_) {
+ this_->route_data.route_showing=0;
+ this_->route_data.route_table=NULL;
+ g_free(w);
+ }
}
@@ -3235,85 +3082,83 @@ gui_internal_route_screen_free(struct gui_priv * this_,struct widget * w)
* @param this The gui context
* @param navit The navit object
*/
-void
-gui_internal_populate_route_table(struct gui_priv * this, struct navit * navit)
-{
- struct map * map=NULL;
- struct map_rect * mr=NULL;
- struct navigation * nav = NULL;
- struct item * item =NULL;
- struct attr attr,route;
- struct widget * label = NULL;
- struct widget * row = NULL;
- struct coord c;
- nav = navit_get_navigation(navit);
- if(!nav) {
- return;
- }
- map = navigation_get_map(nav);
- if(map)
- mr = map_rect_new(map,NULL);
- if(mr) {
- GList *toprow;
- struct item topitem={0};
- toprow=gui_internal_widget_table_top_row(this, this->route_data.route_table);
- if(toprow && toprow->data)
- topitem=((struct widget*)toprow->data)->item;
- gui_internal_widget_table_clear(this,this->route_data.route_table);
- if (navit_get_attr(navit, attr_route, &route, NULL)) {
- struct attr destination_length, destination_time;
- char *length=NULL,*time=NULL,*length_time;
- if (route_get_attr(route.u.route, attr_destination_length, &destination_length, NULL))
- length=attr_to_text_ext(&destination_length, NULL, attr_format_with_units, attr_format_default, NULL);
- if (route_get_attr(route.u.route, attr_destination_time, &destination_time, NULL))
- time=attr_to_text_ext(&destination_time, NULL, attr_format_with_units, attr_format_default, NULL);
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- gui_internal_widget_append(this->route_data.route_table,row);
- length_time=g_strdup_printf("%s %s",length,time);
- label = gui_internal_label_new(this,length_time);
- g_free(length_time);
- g_free(length);
- g_free(time);
- gui_internal_widget_append(row,label);
- }
- while((item = map_rect_get_item(mr))) {
- if(item_attr_get(item,attr_navigation_long,&attr)) {
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- gui_internal_widget_append(this->route_data.route_table,row);
-
- label = gui_internal_label_new(this,map_convert_string_tmp(item->map,attr.u.str));
- gui_internal_widget_append(row,label);
-
- label->item=*item;
- row->item=*item;
- item_coord_get(item, &c, 1);
- label->c.x=c.x;
- label->c.y=c.y;
- label->c.pro=map_projection(map);
- label->func=gui_internal_cmd_position;
- label->state|=STATE_SENSITIVE;
- label->data=(void*)2;
- if(toprow && item->id_hi==topitem.id_hi && item->id_lo==topitem.id_lo && item->map==topitem.map)
- gui_internal_widget_table_set_top_row(this, this->route_data.route_table, row);
- }
-
- }
- map_rect_destroy(mr);
- }
+void gui_internal_populate_route_table(struct gui_priv * this, struct navit * navit) {
+ struct map * map=NULL;
+ struct map_rect * mr=NULL;
+ struct navigation * nav = NULL;
+ struct item * item =NULL;
+ struct attr attr,route;
+ struct widget * label = NULL;
+ struct widget * row = NULL;
+ struct coord c;
+ nav = navit_get_navigation(navit);
+ if(!nav) {
+ return;
+ }
+ map = navigation_get_map(nav);
+ if(map)
+ mr = map_rect_new(map,NULL);
+ if(mr) {
+ GList *toprow;
+ struct item topitem= {0};
+ toprow=gui_internal_widget_table_top_row(this, this->route_data.route_table);
+ if(toprow && toprow->data)
+ topitem=((struct widget*)toprow->data)->item;
+ gui_internal_widget_table_clear(this,this->route_data.route_table);
+ if (navit_get_attr(navit, attr_route, &route, NULL)) {
+ struct attr destination_length, destination_time;
+ char *length=NULL,*time=NULL,*length_time;
+ if (route_get_attr(route.u.route, attr_destination_length, &destination_length, NULL))
+ length=attr_to_text_ext(&destination_length, NULL, attr_format_with_units, attr_format_default, NULL);
+ if (route_get_attr(route.u.route, attr_destination_time, &destination_time, NULL))
+ time=attr_to_text_ext(&destination_time, NULL, attr_format_with_units, attr_format_default, NULL);
+ row = gui_internal_widget_table_row_new(this,
+ gravity_left
+ | flags_fill
+ | orientation_horizontal);
+ gui_internal_widget_append(this->route_data.route_table,row);
+ length_time=g_strdup_printf("%s %s",length,time);
+ label = gui_internal_label_new(this,length_time);
+ g_free(length_time);
+ g_free(length);
+ g_free(time);
+ gui_internal_widget_append(row,label);
+ }
+ while((item = map_rect_get_item(mr))) {
+ if(item_attr_get(item,attr_navigation_long,&attr)) {
+ row = gui_internal_widget_table_row_new(this,
+ gravity_left
+ | flags_fill
+ | orientation_horizontal);
+ gui_internal_widget_append(this->route_data.route_table,row);
+
+ label = gui_internal_label_new(this,map_convert_string_tmp(item->map,attr.u.str));
+ gui_internal_widget_append(row,label);
+
+ label->item=*item;
+ row->item=*item;
+ item_coord_get(item, &c, 1);
+ label->c.x=c.x;
+ label->c.y=c.y;
+ label->c.pro=map_projection(map);
+ label->func=gui_internal_cmd_position;
+ label->state|=STATE_SENSITIVE;
+ label->data=(void*)2;
+ if(toprow && item->id_hi==topitem.id_hi && item->id_lo==topitem.id_lo && item->map==topitem.map)
+ gui_internal_widget_table_set_top_row(this, this->route_data.route_table, row);
+ }
+
+ }
+ map_rect_destroy(mr);
+ }
}
/*
- * Command interface wrapper for commands which can be used both from gui html and to enter internal gui (for example, from osd or dbus).
+ * Command interface wrapper for commands which can be used both from gui html and to enter internal gui (for example, from osd or dbus).
* Set first command argument to integer 1, if this command was called by mouse click from oustside of gui (default). Set it to 0
* if command is called by some other means (dbus signal, for example). If first argument is non integer, it's passed on
* to actual handler.
- *
+ *
*/
@@ -3322,142 +3167,126 @@ gui_internal_populate_route_table(struct gui_priv * this, struct navit * navit)
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui)
-{
- struct color color_white={0xffff,0xffff,0xffff,0xffff};
- struct color color_black={0x0,0x0,0x0,0xffff};
- struct color back2_color={0x4141,0x4141,0x4141,0xffff};
-
- struct gui_priv *this;
- struct attr *attr;
- *meth=gui_internal_methods;
- this=g_new0(struct gui_priv, 1);
- this->nav=nav;
-
- this->self.type=attr_gui;
- this->self.u.gui=gui;
-
- if ((attr=attr_search(attrs, NULL, attr_menu_on_map_click)))
- this->menu_on_map_click=attr->u.num;
- else
- this->menu_on_map_click=1;
-
- if ((attr=attr_search(attrs, NULL, attr_on_map_click)))
- this->on_map_click=g_strdup(attr->u.str);
-
- if ((attr=attr_search(attrs, NULL, attr_signal_on_map_click)))
- this->signal_on_map_click=attr->u.num;
- gui_internal_command_init(this, attrs);
-
- if( (attr=attr_search(attrs,NULL,attr_font_size)))
- {
- this->config.font_size=attr->u.num;
- }
- else
- {
- this->config.font_size=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_icon_xs)))
- {
- this->config.icon_xs=attr->u.num;
- }
- else
- {
- this->config.icon_xs=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_icon_l)))
- {
- this->config.icon_l=attr->u.num;
- }
- else
- {
- this->config.icon_l=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_icon_s)))
- {
- this->config.icon_s=attr->u.num;
- }
- else
- {
- this->config.icon_s=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_spacing)))
- {
- this->config.spacing=attr->u.num;
- }
- else
- {
- this->config.spacing=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_gui_speech)))
- {
- this->speech=attr->u.num;
- }
- if( (attr=attr_search(attrs,NULL,attr_keyboard)))
- this->keyboard=attr->u.num;
- else
- this->keyboard=1;
+static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs,
+ struct gui *gui) {
+ struct color color_white= {0xffff,0xffff,0xffff,0xffff};
+ struct color color_black= {0x0,0x0,0x0,0xffff};
+ struct color back2_color= {0x4141,0x4141,0x4141,0xffff};
+
+ struct gui_priv *this;
+ struct attr *attr;
+ *meth=gui_internal_methods;
+ this=g_new0(struct gui_priv, 1);
+ this->nav=nav;
+
+ this->self.type=attr_gui;
+ this->self.u.gui=gui;
+
+ if ((attr=attr_search(attrs, NULL, attr_menu_on_map_click)))
+ this->menu_on_map_click=attr->u.num;
+ else
+ this->menu_on_map_click=1;
+
+ if ((attr=attr_search(attrs, NULL, attr_on_map_click)))
+ this->on_map_click=g_strdup(attr->u.str);
+
+ if ((attr=attr_search(attrs, NULL, attr_signal_on_map_click)))
+ this->signal_on_map_click=attr->u.num;
+ gui_internal_command_init(this, attrs);
+
+ if( (attr=attr_search(attrs,NULL,attr_font_size))) {
+ this->config.font_size=attr->u.num;
+ } else {
+ this->config.font_size=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_icon_xs))) {
+ this->config.icon_xs=attr->u.num;
+ } else {
+ this->config.icon_xs=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_icon_l))) {
+ this->config.icon_l=attr->u.num;
+ } else {
+ this->config.icon_l=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_icon_s))) {
+ this->config.icon_s=attr->u.num;
+ } else {
+ this->config.icon_s=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_spacing))) {
+ this->config.spacing=attr->u.num;
+ } else {
+ this->config.spacing=-1;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_gui_speech))) {
+ this->speech=attr->u.num;
+ }
+ if( (attr=attr_search(attrs,NULL,attr_keyboard)))
+ this->keyboard=attr->u.num;
+ else
+ this->keyboard=1;
if( (attr=attr_search(attrs,NULL,attr_fullscreen)))
- this->fullscreen=attr->u.num;
-
- if( (attr=attr_search(attrs,NULL,attr_flags)))
- this->flags=attr->u.num;
- if( (attr=attr_search(attrs,NULL,attr_background_color)))
- this->background_color=*attr->u.color;
- else
- this->background_color=color_black;
- if( (attr=attr_search(attrs,NULL,attr_background_color2)))
- this->background2_color=*attr->u.color;
- else
- this->background2_color=back2_color;
- if( (attr=attr_search(attrs,NULL,attr_text_color)))
- this->text_foreground_color=*attr->u.color;
- else
- this->text_foreground_color=color_white;
- if( (attr=attr_search(attrs,NULL,attr_text_background)))
- this->text_background_color=*attr->u.color;
- else
- this->text_background_color=color_black;
- if( (attr=attr_search(attrs,NULL,attr_columns)))
- this->cols=attr->u.num;
- if( (attr=attr_search(attrs,NULL,attr_osd_configuration)))
- this->osd_configuration=*attr;
-
- if( (attr=attr_search(attrs,NULL,attr_pitch)))
- this->pitch=attr->u.num;
- else
- this->pitch=20;
- if( (attr=attr_search(attrs,NULL,attr_flags_town)))
- this->flags_town=attr->u.num;
- else
- this->flags_town=-1;
- if( (attr=attr_search(attrs,NULL,attr_flags_street)))
- this->flags_street=attr->u.num;
- else
- this->flags_street=-1;
- if( (attr=attr_search(attrs,NULL,attr_flags_house_number)))
- this->flags_house_number=attr->u.num;
- else
- this->flags_house_number=-1;
- if( (attr=attr_search(attrs,NULL,attr_radius)))
- this->radius=attr->u.num;
- else
- this->radius=10;
- if( (attr=attr_search(attrs,NULL,attr_font)))
- this->font_name=g_strdup(attr->u.str);
-
- if((attr=attr_search(attrs, NULL, attr_hide_impossible_next_keys)))
- this->hide_keys = attr->u.num;
- else
- this->hide_keys = 0;
-
- this->data.priv=this;
- this->data.gui=&gui_internal_methods_ext;
- this->data.widget=&gui_internal_widget_methods;
- this->cbl=callback_list_new();
-
- return this;
+ this->fullscreen=attr->u.num;
+
+ if( (attr=attr_search(attrs,NULL,attr_flags)))
+ this->flags=attr->u.num;
+ if( (attr=attr_search(attrs,NULL,attr_background_color)))
+ this->background_color=*attr->u.color;
+ else
+ this->background_color=color_black;
+ if( (attr=attr_search(attrs,NULL,attr_background_color2)))
+ this->background2_color=*attr->u.color;
+ else
+ this->background2_color=back2_color;
+ if( (attr=attr_search(attrs,NULL,attr_text_color)))
+ this->text_foreground_color=*attr->u.color;
+ else
+ this->text_foreground_color=color_white;
+ if( (attr=attr_search(attrs,NULL,attr_text_background)))
+ this->text_background_color=*attr->u.color;
+ else
+ this->text_background_color=color_black;
+ if( (attr=attr_search(attrs,NULL,attr_columns)))
+ this->cols=attr->u.num;
+ if( (attr=attr_search(attrs,NULL,attr_osd_configuration)))
+ this->osd_configuration=*attr;
+
+ if( (attr=attr_search(attrs,NULL,attr_pitch)))
+ this->pitch=attr->u.num;
+ else
+ this->pitch=20;
+ if( (attr=attr_search(attrs,NULL,attr_flags_town)))
+ this->flags_town=attr->u.num;
+ else
+ this->flags_town=-1;
+ if( (attr=attr_search(attrs,NULL,attr_flags_street)))
+ this->flags_street=attr->u.num;
+ else
+ this->flags_street=-1;
+ if( (attr=attr_search(attrs,NULL,attr_flags_house_number)))
+ this->flags_house_number=attr->u.num;
+ else
+ this->flags_house_number=-1;
+ if( (attr=attr_search(attrs,NULL,attr_radius)))
+ this->radius=attr->u.num;
+ else
+ this->radius=10;
+ if( (attr=attr_search(attrs,NULL,attr_font)))
+ this->font_name=g_strdup(attr->u.str);
+
+ if((attr=attr_search(attrs, NULL, attr_hide_impossible_next_keys)))
+ this->hide_keys = attr->u.num;
+ else
+ this->hide_keys = 0;
+
+ this->data.priv=this;
+ this->data.gui=&gui_internal_methods_ext;
+ this->data.widget=&gui_internal_widget_methods;
+ this->cbl=callback_list_new();
+
+ return this;
}
//##############################################################################################################
@@ -3465,7 +3294,6 @@ static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void plugin_init(void)
-{
- plugin_register_category_gui("internal", gui_internal_new);
+void plugin_init(void) {
+ plugin_register_category_gui("internal", gui_internal_new);
}
diff --git a/navit/gui/internal/gui_internal.h b/navit/gui/internal/gui_internal.h
index 1a5cd13d3..734d31d38 100644
--- a/navit/gui/internal/gui_internal.h
+++ b/navit/gui/internal/gui_internal.h
@@ -15,71 +15,72 @@ struct gui_priv;
#define GESTURE_RINGSIZE 100
enum widget_type {
- widget_box=1,
- widget_button,
- widget_label,
- widget_image,
- widget_table,
- widget_table_row
+ widget_box=1,
+ widget_button,
+ widget_label,
+ widget_image,
+ widget_table,
+ widget_table_row
};
enum flags {
- gravity_none=0x00,
- gravity_left=1,
- gravity_xcenter=2,
- gravity_right=4,
- gravity_top=8,
- gravity_ycenter=16,
- gravity_bottom=32,
- gravity_left_top=gravity_left|gravity_top,
- gravity_top_center=gravity_xcenter|gravity_top,
- gravity_right_top=gravity_right|gravity_top,
- gravity_left_center=gravity_left|gravity_ycenter,
- gravity_center=gravity_xcenter|gravity_ycenter,
- gravity_right_center=gravity_right|gravity_ycenter,
- gravity_left_bottom=gravity_left|gravity_bottom,
- gravity_bottom_center=gravity_xcenter|gravity_bottom,
- gravity_right_bottom=gravity_right|gravity_bottom,
- flags_expand=0x100,
- flags_fill=0x200,
- flags_swap=0x400,
- flags_scrollx=0x800,
- flags_scrolly=0x1000,
- orientation_horizontal=0x10000,
- orientation_vertical=0x20000,
- orientation_horizontal_vertical=0x40000,
+ gravity_none=0x00,
+ gravity_left=1,
+ gravity_xcenter=2,
+ gravity_right=4,
+ gravity_top=8,
+ gravity_ycenter=16,
+ gravity_bottom=32,
+ gravity_left_top=gravity_left|gravity_top,
+ gravity_top_center=gravity_xcenter|gravity_top,
+ gravity_right_top=gravity_right|gravity_top,
+ gravity_left_center=gravity_left|gravity_ycenter,
+ gravity_center=gravity_xcenter|gravity_ycenter,
+ gravity_right_center=gravity_right|gravity_ycenter,
+ gravity_left_bottom=gravity_left|gravity_bottom,
+ gravity_bottom_center=gravity_xcenter|gravity_bottom,
+ gravity_right_bottom=gravity_right|gravity_bottom,
+ flags_expand=0x100,
+ flags_fill=0x200,
+ flags_swap=0x400,
+ flags_scrollx=0x800,
+ flags_scrolly=0x1000,
+ orientation_horizontal=0x10000,
+ orientation_vertical=0x20000,
+ orientation_horizontal_vertical=0x40000,
};
struct gui_internal_methods {
- void (*add_callback)(struct gui_priv *priv, struct callback *cb);
- void (*remove_callback)(struct gui_priv *priv, struct callback *cb);
- void (*menu_render)(struct gui_priv *this);
- struct graphics_image * (*image_new_xs)(struct gui_priv *this, const char *name);
- struct graphics_image * (*image_new_l)(struct gui_priv *this, const char *name);
+ void (*add_callback)(struct gui_priv *priv, struct callback *cb);
+ void (*remove_callback)(struct gui_priv *priv, struct callback *cb);
+ void (*menu_render)(struct gui_priv *this);
+ struct graphics_image * (*image_new_xs)(struct gui_priv *this, const char *name);
+ struct graphics_image * (*image_new_l)(struct gui_priv *this, const char *name);
};
struct gui_internal_widget_methods {
- void (*append)(struct widget *parent, struct widget *child);
- struct widget * (*button_new)(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags);
- struct widget * (*button_new_with_callback)(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
- struct widget * (*box_new)(struct gui_priv *this, enum flags flags);
- struct widget * (*label_new)(struct gui_priv *this, const char *text);
- struct widget * (*image_new)(struct gui_priv *this, struct graphics_image *image);
- struct widget * (*keyboard)(struct gui_priv *this, int mode);
- struct widget * (*menu)(struct gui_priv *this, const char *label);
- enum flags (*get_flags)(struct widget *widget);
- void (*set_flags)(struct widget *widget, enum flags flags);
- int (*get_state)(struct widget *widget);
- void (*set_state)(struct widget *widget, int state);
- void (*set_func)(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget, void *data));
- void (*set_data)(struct widget *widget, void *data);
- void (*set_default_background)(struct gui_priv *this, struct widget *widget);
+ void (*append)(struct widget *parent, struct widget *child);
+ struct widget * (*button_new)(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags);
+ struct widget * (*button_new_with_callback)(struct gui_priv *this, const char *text, struct graphics_image *image,
+ enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
+ struct widget * (*box_new)(struct gui_priv *this, enum flags flags);
+ struct widget * (*label_new)(struct gui_priv *this, const char *text);
+ struct widget * (*image_new)(struct gui_priv *this, struct graphics_image *image);
+ struct widget * (*keyboard)(struct gui_priv *this, int mode);
+ struct widget * (*menu)(struct gui_priv *this, const char *label);
+ enum flags (*get_flags)(struct widget *widget);
+ void (*set_flags)(struct widget *widget, enum flags flags);
+ int (*get_state)(struct widget *widget);
+ void (*set_state)(struct widget *widget, int state);
+ void (*set_func)(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget, void *data));
+ void (*set_data)(struct widget *widget, void *data);
+ void (*set_default_background)(struct gui_priv *this, struct widget *widget);
};
struct gui_internal_data {
- struct gui_priv *priv;
- struct gui_internal_methods *gui;
- struct gui_internal_widget_methods *widget;
+ struct gui_priv *priv;
+ struct gui_internal_methods *gui;
+ struct gui_internal_widget_methods *widget;
};
diff --git a/navit/gui/internal/gui_internal_bookmark.c b/navit/gui/internal/gui_internal_bookmark.c
index eed0de123..bedad9173 100644
--- a/navit/gui/internal/gui_internal_bookmark.c
+++ b/navit/gui/internal/gui_internal_bookmark.c
@@ -16,298 +16,276 @@
#include "gui_internal_keyboard.h"
#include "gui_internal_bookmark.h"
-static void
-gui_internal_cmd_add_bookmark_do(struct gui_priv *this, struct widget *widget)
-{
- GList *l;
- struct attr attr;
- dbg(lvl_debug,"text='%s'\n", widget->text);
- if (widget->text && strlen(widget->text)){
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, &widget->c, widget->text);
- }
- g_free(widget->text);
- widget->text=NULL;
- l=g_list_previous(g_list_last(this->root.children));
- gui_internal_prune_menu(this, l->data);
+static void gui_internal_cmd_add_bookmark_do(struct gui_priv *this, struct widget *widget) {
+ GList *l;
+ struct attr attr;
+ dbg(lvl_debug,"text='%s'", widget->text);
+ if (widget->text && strlen(widget->text)) {
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_bookmark(attr.u.bookmarks, &widget->c, widget->text);
+ }
+ g_free(widget->text);
+ widget->text=NULL;
+ l=g_list_previous(g_list_last(this->root.children));
+ gui_internal_prune_menu(this, l->data);
}
-static void
-gui_internal_cmd_add_bookmark_folder_do(struct gui_priv *this, struct widget *widget)
-{
- GList *l;
- struct attr attr;
- dbg(lvl_debug,"text='%s'\n", widget->text);
- if (widget->text && strlen(widget->text)){
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, NULL, widget->text);
- }
- g_free(widget->text);
- widget->text=NULL;
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
+static void gui_internal_cmd_add_bookmark_folder_do(struct gui_priv *this, struct widget *widget) {
+ GList *l;
+ struct attr attr;
+ dbg(lvl_debug,"text='%s'", widget->text);
+ if (widget->text && strlen(widget->text)) {
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_bookmark(attr.u.bookmarks, NULL, widget->text);
+ }
+ g_free(widget->text);
+ widget->text=NULL;
+ l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
+ gui_internal_prune_menu(this, l->data);
}
-static void
-gui_internal_cmd_add_bookmark_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_cmd_add_bookmark_do(this, widget->data);
+static void gui_internal_cmd_add_bookmark_clicked(struct gui_priv *this, struct widget *widget, void *data) {
+ gui_internal_cmd_add_bookmark_do(this, widget->data);
}
-static void
-gui_internal_cmd_add_bookmark_folder_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_cmd_add_bookmark_folder_do(this, widget->data);
+static void gui_internal_cmd_add_bookmark_folder_clicked(struct gui_priv *this, struct widget *widget, void *data) {
+ gui_internal_cmd_add_bookmark_folder_do(this, widget->data);
}
-static void
-gui_internal_cmd_rename_bookmark_clicked(struct gui_priv *this, struct widget *widget,void *data)
-{
- struct widget *w=(struct widget*)widget->data;
- GList *l;
- struct attr attr;
- dbg(lvl_debug,"text='%s'\n", w->text);
- if (w->text && strlen(w->text)){
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_rename_bookmark(attr.u.bookmarks, w->name, w->text);
- }
- g_free(w->text);
- g_free(w->name);
- w->text=NULL;
- w->name=NULL;
- l=g_list_previous(g_list_previous(g_list_previous(g_list_last(this->root.children))));
- gui_internal_prune_menu(this, l->data);
+static void gui_internal_cmd_rename_bookmark_clicked(struct gui_priv *this, struct widget *widget,void *data) {
+ struct widget *w=(struct widget*)widget->data;
+ GList *l;
+ struct attr attr;
+ dbg(lvl_debug,"text='%s'", w->text);
+ if (w->text && strlen(w->text)) {
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_rename_bookmark(attr.u.bookmarks, w->name, w->text);
+ }
+ g_free(w->text);
+ g_free(w->name);
+ w->text=NULL;
+ w->name=NULL;
+ l=g_list_previous(g_list_previous(g_list_previous(g_list_last(this->root.children))));
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_add_bookmark2(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- char *name=data;
- wb=gui_internal_menu(this,_("Add Bookmark"));
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- wk->c=wm->c;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_add_bookmark_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
+void gui_internal_cmd_add_bookmark2(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb,*wk,*wl,*we,*wnext;
+ char *name=data;
+ wb=gui_internal_menu(this,_("Add Bookmark"));
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ wk->c=wm->c;
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_add_bookmark_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wl);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")),
+ getenv("LANG"));
+ gui_internal_menu_render(this);
}
-void
-gui_internal_cmd_add_bookmark_folder2(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- char *name=data;
- wb=gui_internal_menu(this,_("Add Bookmark folder"));
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- wk->c=wm->c;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_add_bookmark_folder_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
+void gui_internal_cmd_add_bookmark_folder2(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb,*wk,*wl,*we,*wnext;
+ char *name=data;
+ wb=gui_internal_menu(this,_("Add Bookmark folder"));
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ wk->c=wm->c;
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_add_bookmark_folder_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wl);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")),
+ getenv("LANG"));
+ gui_internal_menu_render(this);
}
-void
-gui_internal_cmd_rename_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- char *name=wm->text;
- wb=gui_internal_menu(this,_("Rename"));
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- wk->c=wm->c;
- wk->name=g_strdup(name);
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_rename_bookmark_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
+void gui_internal_cmd_rename_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w,*wb,*wk,*wl,*we,*wnext;
+ char *name=wm->text;
+ wb=gui_internal_menu(this,_("Rename"));
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ wk->c=wm->c;
+ wk->name=g_strdup(name);
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_rename_bookmark_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wl);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")),
+ getenv("LANG"));
+ gui_internal_menu_render(this);
}
-void
-gui_internal_cmd_cut_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_cut_bookmark(mattr.u.bookmarks,wm->text);
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
+void gui_internal_cmd_cut_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_cut_bookmark(mattr.u.bookmarks,wm->text);
+ l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_copy_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_copy_bookmark(mattr.u.bookmarks,wm->text);
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
+void gui_internal_cmd_copy_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_copy_bookmark(mattr.u.bookmarks,wm->text);
+ l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_paste_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_paste_bookmark(mattr.u.bookmarks);
- l=g_list_previous(g_list_last(this->root.children));
- if(l)
- gui_internal_prune_menu(this, l->data);
+void gui_internal_cmd_paste_bookmark(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_paste_bookmark(mattr.u.bookmarks);
+ l=g_list_previous(g_list_last(this->root.children));
+ if(l)
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_delete_bookmark_folder(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_move_up(mattr.u.bookmarks);
- bookmarks_delete_bookmark(mattr.u.bookmarks,wm->prefix);
- l=g_list_first(this->root.children);
- gui_internal_prune_menu(this, l->data);
+void gui_internal_cmd_delete_bookmark_folder(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
+ GList *l;
+ navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
+ bookmarks_move_up(mattr.u.bookmarks);
+ bookmarks_delete_bookmark(mattr.u.bookmarks,wm->prefix);
+ l=g_list_first(this->root.children);
+ gui_internal_prune_menu(this, l->data);
}
-void
-gui_internal_cmd_load_bookmarks_as_waypoints(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
+void gui_internal_cmd_load_bookmarks_as_waypoints(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- struct attr attr;
- struct item *item;
- struct coord c;
- struct pcoord *pc;
- enum projection pro=bookmarks_get_projection(mattr.u.bookmarks);
- int i, bm_count;
+ if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
+ struct attr attr;
+ struct item *item;
+ struct coord c;
+ struct pcoord *pc;
+ enum projection pro=bookmarks_get_projection(mattr.u.bookmarks);
+ int i, bm_count;
- navit_set_destination(this->nav, NULL, NULL, 0);
+ navit_set_destination(this->nav, NULL, NULL, 0);
- bm_count=bookmarks_get_bookmark_count(mattr.u.bookmarks);
- pc=g_alloca(bm_count*sizeof(struct pcoord));
- bookmarks_item_rewind(mattr.u.bookmarks);
- i=0;
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr))
- continue;
- if (item->type == type_bookmark) {
- if (item_coord_get(item, &c, 1)) {
- pc[i].x=c.x;
- pc[i].y=c.y;
- pc[i].pro=pro;
- navit_add_destination_description(this->nav,&pc[i],attr.u.str);
- i++;
- }
- }
- }
- bm_count=i;
+ bm_count=bookmarks_get_bookmark_count(mattr.u.bookmarks);
+ pc=g_alloca(bm_count*sizeof(struct pcoord));
+ bookmarks_item_rewind(mattr.u.bookmarks);
+ i=0;
+ while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
+ if (!item_attr_get(item, attr_label, &attr))
+ continue;
+ if (item->type == type_bookmark) {
+ if (item_coord_get(item, &c, 1)) {
+ pc[i].x=c.x;
+ pc[i].y=c.y;
+ pc[i].pro=pro;
+ navit_add_destination_description(this->nav,&pc[i],attr.u.str);
+ i++;
+ }
+ }
+ }
+ bm_count=i;
- if (bm_count>0){
- navit_set_destinations(this->nav, pc, bm_count, wm->prefix, 1);
- if (this->flags & 512) {
- struct attr follow;
- follow.type=attr_follow;
- follow.u.num=180;
- navit_set_attr(this->nav, &this->osd_configuration);
- navit_set_attr(this->nav, &follow);
- navit_zoom_to_route(this->nav, 0);
- }
- }
- }
+ if (bm_count>0) {
+ navit_set_destinations(this->nav, pc, bm_count, wm->prefix, 1);
+ if (this->flags & 512) {
+ struct attr follow;
+ follow.type=attr_follow;
+ follow.u.num=180;
+ navit_set_attr(this->nav, &this->osd_configuration);
+ navit_set_attr(this->nav, &follow);
+ navit_zoom_to_route(this->nav, 0);
+ }
+ }
+ }
- gui_internal_prune_menu(this, NULL);
+ gui_internal_prune_menu(this, NULL);
}
-void
-gui_internal_cmd_replace_bookmarks_from_waypoints(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
+void gui_internal_cmd_replace_bookmarks_from_waypoints(struct gui_priv *this, struct widget *wm, void *data) {
+ struct attr mattr;
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- struct attr attr;
- char *desc=NULL;
- struct pcoord *pc;
- int i, bm_count;
+ if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
+ struct attr attr;
+ char *desc=NULL;
+ struct pcoord *pc;
+ int i, bm_count;
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks)>0){
- struct item *item;
- bookmarks_item_rewind(mattr.u.bookmarks);
+ if (bookmarks_get_bookmark_count(mattr.u.bookmarks)>0) {
+ struct item *item;
+ bookmarks_item_rewind(mattr.u.bookmarks);
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
+ while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr))
- continue;
+ if (!item_attr_get(item, attr_label, &attr))
+ continue;
- if (item->type == type_bookmark)
- bookmarks_delete_bookmark(mattr.u.bookmarks, attr.u.str);
+ if (item->type == type_bookmark)
+ bookmarks_delete_bookmark(mattr.u.bookmarks, attr.u.str);
- bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
- }
- }
- bookmarks_item_rewind(mattr.u.bookmarks);
+ bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
+ }
+ }
+ bookmarks_item_rewind(mattr.u.bookmarks);
- bm_count=navit_get_destination_count(this->nav);
- pc=g_alloca(bm_count*sizeof(struct pcoord));
- navit_get_destinations(this->nav, pc, bm_count);
+ bm_count=navit_get_destination_count(this->nav);
+ pc=g_alloca(bm_count*sizeof(struct pcoord));
+ navit_get_destinations(this->nav, pc, bm_count);
- for (i=0; i<bm_count; i++){
- char *tmp=navit_get_destination_description(this->nav, i);
- desc=g_strdup_printf("%s WP%d", tmp, i+1);
- g_free(tmp);
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, &pc[i], desc);
- bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
- g_free(desc);
- }
- }
+ for (i=0; i<bm_count; i++) {
+ char *tmp=navit_get_destination_description(this->nav, i);
+ desc=g_strdup_printf("%s WP%d", tmp, i+1);
+ g_free(tmp);
+ navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
+ bookmarks_add_bookmark(attr.u.bookmarks, &pc[i], desc);
+ bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
+ g_free(desc);
+ }
+ }
- gui_internal_prune_menu(this, NULL);
+ gui_internal_prune_menu(this, NULL);
}
diff --git a/navit/gui/internal/gui_internal_command.c b/navit/gui/internal/gui_internal_command.c
index 6249b3047..fce70e7db 100644
--- a/navit/gui/internal/gui_internal_command.c
+++ b/navit/gui/internal/gui_internal_command.c
@@ -44,8 +44,6 @@
#include <arpa/inet.h>
#endif
-extern char *version;
-
/**
* @brief Converts a WGS84 coordinate pair to its string representation.
*
@@ -57,30 +55,28 @@ extern char *version;
*
* @return The coordinates as a formatted string
*/
-static char *
-coordinates_geo(const struct coord_geo *gc, char sep)
-{
- char latc='N',lngc='E';
- int lat_deg,lat_min,lat_sec;
- int lng_deg,lng_min,lng_sec;
- struct coord_geo g=*gc;
-
- if (g.lat < 0) {
- g.lat=-g.lat;
- latc='S';
- }
- if (g.lng < 0) {
- g.lng=-g.lng;
- lngc='W';
- }
- lat_sec=fmod(g.lat*3600+0.5,60);
- lat_min=fmod(g.lat*60-lat_sec/60.0+0.5,60);
- lat_deg=g.lat-lat_min/60.0-lat_sec/3600.0+0.5;
- lng_sec=fmod(g.lng*3600+0.5,60);
- lng_min=fmod(g.lng*60-lng_sec/60.0+0.5,60);
- lng_deg=g.lng-lng_min/60.0-lng_sec/3600.0+0.5;;
-
- return g_strdup_printf("%d°%d'%d\" %c%c%d°%d'%d\" %c",lat_deg,lat_min,lat_sec,latc,sep,lng_deg,lng_min,lng_sec,lngc);
+static char *coordinates_geo(const struct coord_geo *gc, char sep) {
+ char latc='N',lngc='E';
+ int lat_deg,lat_min,lat_sec;
+ int lng_deg,lng_min,lng_sec;
+ struct coord_geo g=*gc;
+
+ if (g.lat < 0) {
+ g.lat=-g.lat;
+ latc='S';
+ }
+ if (g.lng < 0) {
+ g.lng=-g.lng;
+ lngc='W';
+ }
+ lat_sec=fmod(g.lat*3600+0.5,60);
+ lat_min=fmod(g.lat*60-lat_sec/60.0+0.5,60);
+ lat_deg=g.lat-lat_min/60.0-lat_sec/3600.0+0.5;
+ lng_sec=fmod(g.lng*3600+0.5,60);
+ lng_min=fmod(g.lng*60-lng_sec/60.0+0.5,60);
+ lng_deg=g.lng-lng_min/60.0-lng_sec/3600.0+0.5;;
+
+ return g_strdup_printf("%d°%d'%d\" %c%c%d°%d'%d\" %c",lat_deg,lat_min,lat_sec,latc,sep,lng_deg,lng_min,lng_sec,lngc);
}
/**
@@ -94,693 +90,702 @@ coordinates_geo(const struct coord_geo *gc, char sep)
*
* @return The coordinates as a formatted string
*/
-char *
-gui_internal_coordinates(struct pcoord *pc, char sep)
-{
- struct coord_geo g;
- struct coord c;
- c.x=pc->x;
- c.y=pc->y;
- transform_to_geo(pc->pro, &c, &g);
- return coordinates_geo(&g, sep);
+char *gui_internal_coordinates(struct pcoord *pc, char sep) {
+ struct coord_geo g;
+ struct coord c;
+ c.x=pc->x;
+ c.y=pc->y;
+ transform_to_geo(pc->pro, &c, &g);
+ return coordinates_geo(&g, sep);
}
enum escape_mode {
- escape_mode_none=0,
- escape_mode_string=1,
- escape_mode_quote=2,
- escape_mode_html=4,
- escape_mode_html_quote=8,
- escape_mode_html_apos=16,
+ escape_mode_none=0,
+ escape_mode_string=1,
+ escape_mode_quote=2,
+ escape_mode_html=4,
+ escape_mode_html_quote=8,
+ escape_mode_html_apos=16,
};
/* todo &=&amp;, < = &lt; */
-static char *
-gui_internal_escape(enum escape_mode mode, char *in)
-{
- int len=mode & escape_mode_string ? 3:1;
- char *dst,*out,*src=in;
- char *quot="&quot;";
- char *apos="&apos;";
- while (*src) {
- if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
- len++;
- if (*src == '"' && mode == escape_mode_html_quote)
- len+=strlen(quot);
- else if (*src == '\'' && mode == escape_mode_html_apos)
- len+=strlen(apos);
- else
- len++;
- src++;
- }
- src=in;
- out=dst=g_malloc(len);
- if (mode & escape_mode_string)
- *dst++='"';
- while (*src) {
- if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
- *dst++='\\';
- if (*src == '"' && mode == escape_mode_html_quote) {
- strcpy(dst,quot);
- src++;
- dst+=strlen(quot);
- } else if (*src == '\'' && mode == escape_mode_html_apos) {
- strcpy(dst,apos);
- src++;
- dst+=strlen(apos);
- } else
- *dst++=*src++;
- }
- if (mode & escape_mode_string)
- *dst++='"';
- *dst++='\0';
- return out;
+static char *gui_internal_escape(enum escape_mode mode, char *in) {
+ int len=mode & escape_mode_string ? 3:1;
+ char *dst,*out,*src=in;
+ char *quot="&quot;";
+ char *apos="&apos;";
+ while (*src) {
+ if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
+ len++;
+ if (*src == '"' && mode == escape_mode_html_quote)
+ len+=strlen(quot);
+ else if (*src == '\'' && mode == escape_mode_html_apos)
+ len+=strlen(apos);
+ else
+ len++;
+ src++;
+ }
+ src=in;
+ out=dst=g_malloc(len);
+ if (mode & escape_mode_string)
+ *dst++='"';
+ while (*src) {
+ if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
+ *dst++='\\';
+ if (*src == '"' && mode == escape_mode_html_quote) {
+ strcpy(dst,quot);
+ src++;
+ dst+=strlen(quot);
+ } else if (*src == '\'' && mode == escape_mode_html_apos) {
+ strcpy(dst,apos);
+ src++;
+ dst+=strlen(apos);
+ } else
+ *dst++=*src++;
+ }
+ if (mode & escape_mode_string)
+ *dst++='"';
+ *dst++='\0';
+ return out;
}
-static void
-gui_internal_cmd_escape(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr escaped;
- if (!in || !in[0]) {
- dbg(lvl_error,"first parameter missing or wrong type\n");
- return;
- }
- if (!out) {
- dbg(lvl_error,"output missing\n");
- return;
- }
- if (ATTR_IS_STRING(in[0]->type)) {
- escaped.type=in[0]->type;
- escaped.u.str=gui_internal_escape(escape_mode_string,in[0]->u.str);
- } else if (ATTR_IS_INT(in[0]->type)) {
- escaped.type=attr_type_string_begin;
- escaped.u.str=g_strdup_printf("%ld",in[0]->u.num);
- } else {
- dbg(lvl_error,"first parameter wrong type\n");
- return;
- }
- dbg(lvl_debug,"in %s result %s\n",in[0]->u.str,escaped.u.str);
- *out=attr_generic_add_attr(*out, attr_dup(&escaped));
- g_free(escaped.u.str);
+static void gui_internal_cmd_escape(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct attr escaped;
+ if (!in || !in[0]) {
+ dbg(lvl_error,"first parameter missing or wrong type");
+ return;
+ }
+ if (!out) {
+ dbg(lvl_error,"output missing");
+ return;
+ }
+ if (ATTR_IS_STRING(in[0]->type)) {
+ escaped.type=in[0]->type;
+ escaped.u.str=gui_internal_escape(escape_mode_string,in[0]->u.str);
+ } else if (ATTR_IS_INT(in[0]->type)) {
+ escaped.type=attr_type_string_begin;
+ escaped.u.str=g_strdup_printf("%ld",in[0]->u.num);
+ } else {
+ dbg(lvl_error,"first parameter wrong type");
+ return;
+ }
+ dbg(lvl_debug,"in %s result %s",in[0]->u.str,escaped.u.str);
+ *out=attr_generic_add_attr(*out, attr_dup(&escaped));
+ g_free(escaped.u.str);
}
-static void
-gui_internal_cmd2_about(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *menu,*wb,*w;
- char *text;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- menu=gui_internal_menu(this, _("About Navit"));
- menu->spx=this->spacing*10;
- wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand);
- gui_internal_widget_append(menu, wb);
-
- //Icon
- gui_internal_widget_append(wb, w=gui_internal_image_new(this, image_new_xs(this, "navit")));
- w->flags=gravity_top_center|orientation_horizontal|flags_fill;
-
- //app name
- text=g_strdup_printf("%s",PACKAGE_NAME);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_top_center|orientation_horizontal|flags_expand;
- g_free(text);
-
- //Version
- text=g_strdup_printf("%s",version);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_top_center|orientation_horizontal|flags_expand;
- g_free(text);
-
- //Site
- text=g_strdup_printf("http://www.navit-project.org/");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_top_center|orientation_horizontal|flags_expand;
- g_free(text);
-
- //Authors
- text=g_strdup_printf("%s:",_("By"));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Martin Schaller");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Michael Farmbauer");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Alexander Atanasov");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Pierre Grandin");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
-
- //Contributors
- text=g_strdup_printf("%s",_("And all the Navit Team"));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("%s",_("members and contributors."));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
-
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
+static void gui_internal_cmd2_about(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *menu,*wb,*w;
+ char *text;
+
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ menu=gui_internal_menu(this, _("About Navit"));
+ menu->spx=this->spacing*10;
+ wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand);
+ gui_internal_widget_append(menu, wb);
+
+ //Icon
+ gui_internal_widget_append(wb, w=gui_internal_image_new(this, image_new_xs(this, "navit")));
+ w->flags=gravity_top_center|orientation_horizontal|flags_fill;
+
+ //app name
+ text=g_strdup_printf("%s",PACKAGE_NAME);
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_top_center|orientation_horizontal|flags_expand;
+ g_free(text);
+
+ //Version
+ text=g_strdup_printf("%s",NAVIT_VERSION);
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_top_center|orientation_horizontal|flags_expand;
+ g_free(text);
+
+ //Site
+ text=g_strdup_printf("http://www.navit-project.org/");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_top_center|orientation_horizontal|flags_expand;
+ g_free(text);
+
+ //Authors
+ text=g_strdup_printf("%s:",_("By"));
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("Martin Schaller");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("Michael Farmbauer");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("Alexander Atanasov");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("Pierre Grandin");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+
+ //Contributors
+ text=g_strdup_printf("%s",_("And all the Navit Team"));
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ text=g_strdup_printf("%s",_("members and contributors."));
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
}
-static void
-gui_internal_cmd2_waypoints(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- gui_internal_select_waypoint(this, _("Waypoints"), NULL, NULL, gui_internal_cmd_position, (void*)2);
+static void gui_internal_cmd2_waypoints(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ gui_internal_select_waypoint(this, _("Waypoints"), NULL, NULL, gui_internal_cmd_position, (void*)2);
}
-static void
-gui_internal_cmd_enter_coord(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *w, *wb, *wk, *wr, *we, *wnext, *row;
- wb=gui_internal_menu(this, _("Enter Coordinates"));
- w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wr);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, we);
-
-/*
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
-
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);*/
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Latitude Longitude")));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_enter_coord_clicked;
- wnext->data=wk;
- wk->data=wnext;
- row=gui_internal_text_new(this, _("Enter coordinates, for example:"), gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
- row=gui_internal_text_new(this, "52.5219N 19.4127E", gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
- row=gui_internal_text_new(this, "52°31.3167N 19°24.7667E", gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
- row=gui_internal_text_new(this, "52°31'19N 19°24'46E", gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
-
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_DEGREE));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_DEGREE, NULL);
- gui_internal_menu_render(this);
+static void gui_internal_cmd_enter_coord(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *w, *wb, *wk, *wr, *we, *wnext, *row;
+ wb=gui_internal_menu(this, _("Enter Coordinates"));
+ w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wr);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(wr, we);
+
+ /*
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);*/
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Latitude Longitude")));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_enter_coord_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ row=gui_internal_text_new(this, _("Enter coordinates, for example:"),
+ gravity_top_center|flags_fill|orientation_vertical);
+ gui_internal_widget_append(wr,row);
+ row=gui_internal_text_new(this, "52.5219N 19.4127E", gravity_top_center|flags_fill|orientation_vertical);
+ gui_internal_widget_append(wr,row);
+ row=gui_internal_text_new(this, "52°31.3167N 19°24.7667E", gravity_top_center|flags_fill|orientation_vertical);
+ gui_internal_widget_append(wr,row);
+ row=gui_internal_text_new(this, "52°31'19N 19°24'46E", gravity_top_center|flags_fill|orientation_vertical);
+ gui_internal_widget_append(wr,row);
+
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_DEGREE));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_DEGREE, NULL);
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_town(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- if (this->sl)
- search_list_select(this->sl, attr_country_all, 0, 0);
- gui_internal_search(this,_("Town"),"Town",1);
+static void gui_internal_cmd2_town(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ if (this->sl)
+ search_list_select(this->sl, attr_country_all, 0, 0);
+ gui_internal_search(this,_("Town"),"Town",1);
}
-static void
-gui_internal_cmd2_setting_vehicle(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr,attr2,vattr;
- struct widget *w,*wb,*wl;
- struct attr_iter *iter;
- struct attr active_vehicle;
-
- iter=navit_attr_iter_new();
- if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- navit_attr_iter_destroy(iter);
- gui_internal_menu_vehicle_settings(this, attr.u.vehicle, vattr.u.str);
- return;
- }
- navit_attr_iter_destroy(iter);
-
- wb=gui_internal_menu(this, _("Vehicle"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
- active_vehicle.u.vehicle=NULL;
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- wl=gui_internal_button_new_with_callback(this, vattr.u.str,
- image_new_xs(this, attr.u.vehicle == active_vehicle.u.vehicle ? "gui_active" : "gui_inactive"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_vehicle_settings, attr.u.vehicle);
- wl->text=g_strdup(vattr.u.str);
- gui_internal_widget_append(w, wl);
- }
- navit_attr_iter_destroy(iter);
- gui_internal_menu_render(this);
+static void gui_internal_cmd2_setting_vehicle(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ struct attr attr,attr2,vattr;
+ struct widget *w,*wb,*wl;
+ struct attr_iter *iter;
+ struct attr active_vehicle;
+
+ iter=navit_attr_iter_new();
+ if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
+ navit_attr_iter_destroy(iter);
+ gui_internal_menu_vehicle_settings(this, attr.u.vehicle, vattr.u.str);
+ return;
+ }
+ navit_attr_iter_destroy(iter);
+
+ wb=gui_internal_menu(this, _("Vehicle"));
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+ if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
+ active_vehicle.u.vehicle=NULL;
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
+ wl=gui_internal_button_new_with_callback(this, vattr.u.str,
+ image_new_xs(this, attr.u.vehicle == active_vehicle.u.vehicle ? "gui_active" : "gui_inactive"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_vehicle_settings, attr.u.vehicle);
+ wl->text=g_strdup(vattr.u.str);
+ gui_internal_widget_append(w, wl);
+ }
+ navit_attr_iter_destroy(iter);
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_setting_rules(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *wb,*w;
- struct attr on,off;
- wb=gui_internal_menu(this, _("Rules"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- on.u.num=1;
- off.u.num=0;
- on.type=off.type=attr_tracking;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Lock on road"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- on.u.num=0;
- off.u.num=-1;
- on.type=off.type=attr_orientation;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Northing"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- on.u.num=1;
- off.u.num=0;
- on.type=off.type=attr_follow_cursor;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Map follows Vehicle"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- on.u.num=1;
- off.u.num=0;
- on.type=off.type=attr_waypoints_flag;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Plan with Waypoints"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- gui_internal_menu_render(this);
+static void gui_internal_cmd2_setting_rules(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *wb,*w;
+ struct attr on,off;
+ wb=gui_internal_menu(this, _("Rules"));
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*3;
+ gui_internal_widget_append(wb, w);
+ on.u.num=1;
+ off.u.num=0;
+ on.type=off.type=attr_tracking;
+ gui_internal_widget_append(w,
+ gui_internal_button_navit_attr_new(this, _("Lock on road"), gravity_left_center|orientation_horizontal|flags_fill,
+ &on, &off));
+ on.u.num=0;
+ off.u.num=-1;
+ on.type=off.type=attr_orientation;
+ gui_internal_widget_append(w,
+ gui_internal_button_navit_attr_new(this, _("Northing"), gravity_left_center|orientation_horizontal|flags_fill,
+ &on, &off));
+ on.u.num=1;
+ off.u.num=0;
+ on.type=off.type=attr_follow_cursor;
+ gui_internal_widget_append(w,
+ gui_internal_button_navit_attr_new(this, _("Map follows Vehicle"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ &on, &off));
+ on.u.num=1;
+ off.u.num=0;
+ on.type=off.type=attr_waypoints_flag;
+ gui_internal_widget_append(w,
+ gui_internal_button_navit_attr_new(this, _("Plan with Waypoints"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ &on, &off));
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_setting_maps(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr, on, off, description, type, data, url, active;
- struct widget *w,*wb,*row,*wma;
- char *label;
- struct attr_iter *iter;
-
- wb=gui_internal_menu(this, _("Maps"));
- //w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- //w->spy=this->spacing*3;
- w = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(wb, w);
- iter=navit_attr_iter_new();
- on.type=off.type=attr_active;
- on.u.num=1;
- off.u.num=0;
- while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
- if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
- label=g_strdup(description.u.str);
- } else {
- if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
- type.u.str="";
- if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
- data.u.str="";
- label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
- }
- if (map_get_attr(attr.u.map, attr_url, &url, NULL)) {
- if (!map_get_attr(attr.u.map, attr_active, &active, NULL))
- active.u.num=1;
- wma=gui_internal_button_new_with_callback(this, label, image_new_xs(this, active.u.num ? "gui_active" : "gui_inactive"),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_map_download, attr.u.map);
- } else {
- wma=gui_internal_button_map_attr_new(this, label, gravity_left_center|orientation_horizontal|flags_fill,
- attr.u.map, &on, &off, 1);
- }
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row, wma);
- g_free(label);
- }
- navit_attr_iter_destroy(iter);
- gui_internal_menu_render(this);
+static void gui_internal_cmd2_setting_maps(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct attr attr, on, off, description, type, data, url, active;
+ struct widget *w,*wb,*row,*wma;
+ char *label;
+ struct attr_iter *iter;
+
+ wb=gui_internal_menu(this, _("Maps"));
+ //w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ //w->spy=this->spacing*3;
+ w = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ gui_internal_widget_append(wb, w);
+ iter=navit_attr_iter_new();
+ on.type=off.type=attr_active;
+ on.u.num=1;
+ off.u.num=0;
+ while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
+ if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
+ label=g_strdup(description.u.str);
+ } else {
+ if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
+ type.u.str="";
+ if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
+ data.u.str="";
+ label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
+ }
+ if (map_get_attr(attr.u.map, attr_url, &url, NULL)) {
+ if (!map_get_attr(attr.u.map, attr_active, &active, NULL))
+ active.u.num=1;
+ wma=gui_internal_button_new_with_callback(this, label, image_new_xs(this, active.u.num ? "gui_active" : "gui_inactive"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_map_download, attr.u.map);
+ } else {
+ wma=gui_internal_button_map_attr_new(this, label, gravity_left_center|orientation_horizontal|flags_fill,
+ attr.u.map, &on, &off, 1);
+ }
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ gui_internal_widget_append(row, wma);
+ g_free(label);
+ }
+ navit_attr_iter_destroy(iter);
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_setting_layout(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr;
- struct widget *w,*wb,*wl,*row;
- struct attr_iter *iter;
-
-
- wb=gui_internal_menu(this, _("Layout"));
- w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
- gui_internal_widget_append(wb, w);
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- wl=gui_internal_button_navit_attr_new(this, attr.u.layout->name, gravity_left_center|orientation_horizontal|flags_fill,
- &attr, NULL);
- gui_internal_widget_append(row, wl);
- }
- navit_attr_iter_destroy(iter);
- gui_internal_menu_render(this);
+static void gui_internal_cmd2_setting_layout(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ struct attr attr;
+ struct widget *w,*wb,*wl,*row;
+ struct attr_iter *iter;
+
+
+ wb=gui_internal_menu(this, _("Layout"));
+ w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
+ gui_internal_widget_append(wb, w);
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
+ gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
+ gravity_left|orientation_horizontal|flags_fill));
+ wl=gui_internal_button_navit_attr_new(this, attr.u.layout->name, gravity_left_center|orientation_horizontal|flags_fill,
+ &attr, NULL);
+ gui_internal_widget_append(row, wl);
+ }
+ navit_attr_iter_destroy(iter);
+ gui_internal_menu_render(this);
}
/*
* @brief Displays Route Height Profile
*
- * displays a heightprofile if a route is active and
+ * displays a heightprofile if a route is active and
* some heightinfo is provided by means of a map
*
* the name of the file providing the heightlines must
* comply with *.heightlines.bin
- *
+ *
*/
-static void
-gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget * menu, *box;
- struct map * map=NULL;
- struct map_rect * mr=NULL;
- struct route * route;
- struct item * item =NULL;
- struct mapset *ms;
- struct mapset_handle *msh;
- int x,i,first=1,dist=0;
- int diagram_points_count = 0;
- struct coord c,last,res;
- struct coord_rect rbbox,dbbox;
- struct map_selection sel;
- struct heightline *heightline,*heightlines=NULL;
- struct diagram_point *min,*diagram_point,*diagram_points=NULL;
- struct point p[2];
- sel.next=NULL;
- sel.order=18;
- sel.range.min=type_height_line_1;
- sel.range.max=type_height_line_3;
-
- menu=gui_internal_menu(this,_("Height Profile"));
- box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
- gui_internal_widget_append(menu, box);
- route = navit_get_route(this->nav);
- if (route)
- map = route_get_map(route);
- if(map)
- mr = map_rect_new(map,NULL);
- if(mr) {
- while((item = map_rect_get_item(mr))) {
- while (item_coord_get(item, &c, 1)) {
- if (first) {
- first=0;
- sel.u.c_rect.lu=c;
- sel.u.c_rect.rl=c;
- } else
- coord_rect_extend(&sel.u.c_rect, &c);
- }
- }
- map_rect_destroy(mr);
- mr = NULL;
- ms=navit_get_mapset(this->nav);
- if (!first && ms) {
- int heightmap_installed = FALSE;
- msh=mapset_open(ms);
- while ((map=mapset_next(msh, 1))) {
- struct attr data_attr;
- if (map_get_attr(map, attr_data, &data_attr, NULL)){
- dbg(lvl_debug,"map name = %s\n",data_attr.u.str);
- if (strstr(data_attr.u.str,".heightlines.bin")){
- dbg(lvl_info,"reading heightlines from map %s\n",data_attr.u.str);
- mr=map_rect_new(map, &sel);
- heightmap_installed = TRUE;
- }
- else {
- dbg(lvl_debug,"ignoring map %s\n",data_attr.u.str);
- }
- }
- if (mr) {
- while((item = map_rect_get_item(mr))) {
- if (item->type >= sel.range.min && item->type <= sel.range.max) {
- heightline=item_get_heightline(item);
- if (heightline) {
- heightline->next=heightlines;
- heightlines=heightline;
- }
- }
- }
- map_rect_destroy(mr);
- mr = NULL;
- }
- }
- mapset_close(msh);
- if (!heightmap_installed){
- char *text;
- struct widget *w;
- text=g_strdup_printf("%s",_("please install a map *.heightlines.bin to provide elevationdata"));
- gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- gui_internal_menu_render(this);
- return;
- }
- }
- }
- map=NULL;
- mr=NULL;
- if (route)
- map = route_get_map(route);
- if(map)
- mr = map_rect_new(map,NULL);
- if(mr && heightlines) {
- while((item = map_rect_get_item(mr))) {
- first=1;
- while (item_coord_get(item, &c, 1)) {
- if (first)
- first=0;
- else {
- heightline=heightlines;
- rbbox.lu=last;
- rbbox.rl=last;
- coord_rect_extend(&rbbox, &c);
- while (heightline) {
- if (coord_rect_overlap(&rbbox, &heightline->bbox)) {
- for (i = 0 ; i < heightline->count - 1; i++) {
- if (heightline->c[i].x != heightline->c[i+1].x || heightline->c[i].y != heightline->c[i+1].y) {
- if (line_intersection(heightline->c+i, heightline->c+i+1, &last, &c, &res)) {
- diagram_point=g_new(struct diagram_point, 1);
- diagram_point->c.x=dist+transform_distance(projection_mg, &last, &res);
- diagram_point->c.y=heightline->height;
- diagram_point->next=diagram_points;
- diagram_points=diagram_point;
- diagram_points_count ++;
- dbg(lvl_debug,"%d %d\n", diagram_point->c.x, diagram_point->c.y);
- }
- }
- }
- }
- heightline=heightline->next;
- }
- dist+=transform_distance(projection_mg, &last, &c);
- }
- last=c;
- }
- }
- }
- while (heightlines){
- heightline=heightlines;
- heightlines=heightlines->next;
- g_free(heightline);
- }
- if(mr)
- map_rect_destroy(mr);
-
- if(diagram_points_count < 2){
- char *text;
- struct widget *w;
- text=g_strdup_printf("%s",_("The route must cross at least 2 heightlines"));
- gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- gui_internal_menu_render(this);
- if(diagram_points)
- g_free(diagram_points);
- return;
- }
-
- gui_internal_menu_render(this);
- first=1;
- diagram_point=diagram_points;
- while (diagram_point) {
- if (first) {
- dbbox.lu=diagram_point->c;
- dbbox.rl=diagram_point->c;
- first=0;
- } else
- coord_rect_extend(&dbbox, &diagram_point->c);
- diagram_point=diagram_point->next;
- }
- dbg(lvl_debug,"%d %d %d %d\n", dbbox.lu.x, dbbox.lu.y, dbbox.rl.x, dbbox.rl.y);
- if (dbbox.rl.x > dbbox.lu.x && dbbox.lu.x*100/(dbbox.rl.x-dbbox.lu.x) <= 25)
- dbbox.lu.x=0;
- if (dbbox.lu.y > dbbox.rl.y && dbbox.rl.y*100/(dbbox.lu.y-dbbox.rl.y) <= 25)
- dbbox.rl.y=0;
- dbg(lvl_debug,"%d,%d %dx%d\n", box->p.x, box->p.y, box->w, box->h);
- x=dbbox.lu.x;
- first=1;
- if (diagram_points_count > 1 && dbbox.rl.x != dbbox.lu.x && dbbox.lu.y != dbbox.rl.y){
- for (;;) {
- min=NULL;
- diagram_point=diagram_points;
- while (diagram_point) {
- if (diagram_point->c.x >= x && (!min || min->c.x > diagram_point->c.x))
- min=diagram_point;
- diagram_point=diagram_point->next;
- }
- if (! min)
- break;
- p[1].x=(min->c.x-dbbox.lu.x)*(box->w-10)/(dbbox.rl.x-dbbox.lu.x)+box->p.x+5;
- p[1].y=(box->h)-5-(min->c.y-dbbox.rl.y)*(box->h-10)/(dbbox.lu.y-dbbox.rl.y)+box->p.y;
- dbg(lvl_debug,"%d,%d=%d,%d\n",min->c.x, min->c.y, p[1].x,p[1].y);
- graphics_draw_circle(this->gra, this->foreground, &p[1], 2);
- if (first)
- first=0;
- else
- graphics_draw_lines(this->gra, this->foreground, p, 2);
- p[0]=p[1];
- x=min->c.x+1;
- }
- }
- while (diagram_points){
- diagram_point=diagram_points;
- diagram_points=diagram_points->next;
- g_free(diagram_point);
- }
+static void gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ struct widget * menu, *box;
+ struct map * map=NULL;
+ struct map_rect * mr=NULL;
+ struct route * route;
+ struct item * item =NULL;
+ struct mapset *ms;
+ struct mapset_handle *msh;
+ int x,i,first=1,dist=0;
+ int diagram_points_count = 0;
+ struct coord c,last,res;
+ struct coord_rect rbbox,dbbox;
+ struct map_selection sel;
+ struct heightline *heightline,*heightlines=NULL;
+ struct diagram_point *min,*diagram_point,*diagram_points=NULL;
+ struct point p[2];
+ int min_ele=INT_MAX;
+ int max_ele=INT_MIN;
+ int distance=0;
+ sel.next=NULL;
+ sel.order=18;
+ sel.range.min=type_height_line_1;
+ sel.range.max=type_height_line_3;
+
+ menu=gui_internal_menu(this,_("Height Profile"));
+ box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
+ gui_internal_widget_append(menu, box);
+ route = navit_get_route(this->nav);
+ if (route)
+ map = route_get_map(route);
+ if(map)
+ mr = map_rect_new(map,NULL);
+ if(mr) {
+ while((item = map_rect_get_item(mr))) {
+ while (item_coord_get(item, &c, 1)) {
+ if (first) {
+ first=0;
+ sel.u.c_rect.lu=c;
+ sel.u.c_rect.rl=c;
+ } else
+ coord_rect_extend(&sel.u.c_rect, &c);
+ }
+ }
+ map_rect_destroy(mr);
+ mr = NULL;
+ ms=navit_get_mapset(this->nav);
+ if (!first && ms) {
+ int heightmap_installed = FALSE;
+ msh=mapset_open(ms);
+ while ((map=mapset_next(msh, 1))) {
+ struct attr data_attr;
+ if (map_get_attr(map, attr_data, &data_attr, NULL)) {
+ dbg(lvl_debug,"map name = %s",data_attr.u.str);
+ if (strstr(data_attr.u.str,".heightlines.bin")) {
+ dbg(lvl_info,"reading heightlines from map %s",data_attr.u.str);
+ mr=map_rect_new(map, &sel);
+ heightmap_installed = TRUE;
+ } else {
+ dbg(lvl_debug,"ignoring map %s",data_attr.u.str);
+ }
+ }
+ if (mr) {
+ while((item = map_rect_get_item(mr))) {
+ if (item->type >= sel.range.min && item->type <= sel.range.max) {
+ heightline=item_get_heightline(item);
+ if (heightline) {
+ heightline->next=heightlines;
+ heightlines=heightline;
+ }
+ }
+ }
+ map_rect_destroy(mr);
+ mr = NULL;
+ }
+ }
+ mapset_close(msh);
+ if (!heightmap_installed) {
+ char *text;
+ struct widget *w;
+ text=g_strdup_printf("%s",_("please install a map *.heightlines.bin to provide elevationdata"));
+ gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ gui_internal_menu_render(this);
+ return;
+ }
+ }
+ }
+ map=NULL;
+ mr=NULL;
+ if (route)
+ map = route_get_map(route);
+ if(map)
+ mr = map_rect_new(map,NULL);
+ if(mr && heightlines) {
+ while((item = map_rect_get_item(mr))) {
+ first=1;
+ while (item_coord_get(item, &c, 1)) {
+ if (first)
+ first=0;
+ else {
+ heightline=heightlines;
+ rbbox.lu=last;
+ rbbox.rl=last;
+ coord_rect_extend(&rbbox, &c);
+ while (heightline) {
+ if (coord_rect_overlap(&rbbox, &heightline->bbox)) {
+ for (i = 0 ; i < heightline->count - 1; i++) {
+ if (heightline->c[i].x != heightline->c[i+1].x || heightline->c[i].y != heightline->c[i+1].y) {
+ if (line_intersection(heightline->c+i, heightline->c+i+1, &last, &c, &res)) {
+ diagram_point=g_new(struct diagram_point, 1);
+ diagram_point->c.x=dist+transform_distance(projection_mg, &last, &res);
+ diagram_point->c.y=heightline->height;
+ diagram_point->next=diagram_points;
+ diagram_points=diagram_point;
+ diagram_points_count ++;
+ dbg(lvl_debug,"%d %d", diagram_point->c.x, diagram_point->c.y);
+ max_ele=MAX(max_ele, diagram_point->c.y);
+ min_ele=MIN(min_ele, diagram_point->c.y);
+ distance=diagram_point->c.x;
+ }
+ }
+ }
+ }
+ heightline=heightline->next;
+ }
+ dist+=transform_distance(projection_mg, &last, &c);
+ }
+ last=c;
+ }
+ }
+ }
+ while (heightlines) {
+ heightline=heightlines;
+ heightlines=heightlines->next;
+ g_free(heightline);
+ }
+ if(mr)
+ map_rect_destroy(mr);
+
+ if(diagram_points_count < 2) {
+ char *text;
+ struct widget *w;
+ text=g_strdup_printf("%s",_("The route must cross at least 2 heightlines"));
+ gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ gui_internal_menu_render(this);
+ if(diagram_points)
+ g_free(diagram_points);
+ return;
+ }
+
+ gui_internal_menu_render(this);
+ first=1;
+ diagram_point=diagram_points;
+ while (diagram_point) {
+ if (first) {
+ dbbox.lu=diagram_point->c;
+ dbbox.rl=diagram_point->c;
+ first=0;
+ } else
+ coord_rect_extend(&dbbox, &diagram_point->c);
+ diagram_point=diagram_point->next;
+ }
+ dbg(lvl_debug,"%d %d %d %d", dbbox.lu.x, dbbox.lu.y, dbbox.rl.x, dbbox.rl.y);
+ if (dbbox.rl.x > dbbox.lu.x && dbbox.lu.x*100/(dbbox.rl.x-dbbox.lu.x) <= 25)
+ dbbox.lu.x=0;
+ if (dbbox.lu.y > dbbox.rl.y && dbbox.rl.y*100/(dbbox.lu.y-dbbox.rl.y) <= 25)
+ dbbox.rl.y=0;
+ dbg(lvl_debug,"%d,%d %dx%d", box->p.x, box->p.y, box->w, box->h);
+ x=dbbox.lu.x;
+ first=1;
+ if (diagram_points_count > 1 && dbbox.rl.x != dbbox.lu.x && dbbox.lu.y != dbbox.rl.y) {
+ for (;;) {
+ min=NULL;
+ diagram_point=diagram_points;
+ while (diagram_point) {
+ if (diagram_point->c.x >= x && (!min || min->c.x > diagram_point->c.x))
+ min=diagram_point;
+ diagram_point=diagram_point->next;
+ }
+ if (! min)
+ break;
+ p[1].x=(min->c.x-dbbox.lu.x)*(box->w-10)/(dbbox.rl.x-dbbox.lu.x)+box->p.x+5;
+ p[1].y=(box->h)-5-(min->c.y-dbbox.rl.y)*(box->h-10)/(dbbox.lu.y-dbbox.rl.y)+box->p.y;
+ dbg(lvl_debug,"%d,%d=%d,%d",min->c.x, min->c.y, p[1].x,p[1].y);
+ graphics_draw_circle(this->gra, this->foreground, &p[1], 2);
+ if (first)
+ first=0;
+ else
+ graphics_draw_lines(this->gra, this->foreground, p, 2);
+ p[0]=p[1];
+ x=min->c.x+1;
+ }
+ }
+
+ struct point pTopLeft= {0, box->p.y + 10};
+ struct point pBottomLeft= {0, box->h + box->p.y - 2};
+ struct point pBottomRight= {box->w - 100, box->h + box->p.y - 2};
+ char* minele_text=g_strdup_printf("%d m", min_ele);
+ char* maxele_text=g_strdup_printf("%d m", max_ele);
+ char* distance_text=g_strdup_printf("%.3f km", distance/1000.0);
+ graphics_draw_text_std(this->gra, 10, maxele_text, &pTopLeft);
+ graphics_draw_text_std(this->gra, 10, minele_text, &pBottomLeft);
+ graphics_draw_text_std(this->gra, 10, distance_text, &pBottomRight);
+
+ while (diagram_points) {
+ diagram_point=diagram_points;
+ diagram_points=diagram_points->next;
+ g_free(diagram_point);
+ }
}
-static void
-gui_internal_cmd2_route_description(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
+static void gui_internal_cmd2_route_description(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
- struct widget * menu;
- struct widget * box;
+ struct widget * menu;
+ struct widget * box;
- if(! this->vehicle_cb)
- {
- /**
- * Register the callback on vehicle updates.
- */
- this->vehicle_cb = callback_new_attr_1(callback_cast(gui_internal_route_update),
- attr_position_coord_geo,this);
- navit_add_callback(this->nav,this->vehicle_cb);
- }
+ if(! this->vehicle_cb) {
+ /**
+ * Register the callback on vehicle updates.
+ */
+ this->vehicle_cb = callback_new_attr_1(callback_cast(gui_internal_route_update),
+ attr_position_coord_geo,this);
+ navit_add_callback(this->nav,this->vehicle_cb);
+ }
- this->route_data.route_table = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ this->route_data.route_table = gui_internal_widget_table_new(this,
+ gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- menu=gui_internal_menu(this,_("Route Description"));
+ menu=gui_internal_menu(this,_("Route Description"));
- menu->wfree=gui_internal_route_screen_free;
- this->route_data.route_showing=1;
- this->route_data.route_table->spx = this->spacing;
+ menu->wfree=gui_internal_route_screen_free;
+ this->route_data.route_showing=1;
+ this->route_data.route_table->spx = this->spacing;
- box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
+ box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
- gui_internal_widget_append(box,this->route_data.route_table);
- box->w=menu->w;
- box->spx = this->spacing;
- this->route_data.route_table->w=box->w;
- gui_internal_widget_append(menu,box);
- gui_internal_populate_route_table(this,this->nav);
- gui_internal_menu_render(this);
+ gui_internal_widget_append(box,this->route_data.route_table);
+ box->w=menu->w;
+ box->spx = this->spacing;
+ this->route_data.route_table->w=box->w;
+ gui_internal_widget_append(menu,box);
+ gui_internal_populate_route_table(this,this->nav);
+ gui_internal_menu_render(this);
}
-static void
-gui_internal_cmd2_pois(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *w;
- struct poi_param *param;
- struct attr pro;
- struct coord c;
-
- dbg(lvl_debug,"enter\n");
- if (!in || !in[0])
- return;
- if (!ATTR_IS_COORD_GEO(in[0]->type))
- return;
- if (!navit_get_attr(this->nav, attr_projection, &pro, NULL))
- return;
- w=g_new0(struct widget,1);
- param=g_new0(struct poi_param,1);
- if (in[1] && ATTR_IS_STRING(in[1]->type)) {
- gui_internal_poi_param_set_filter(param, in[1]->u.str);
- if (in[2] && ATTR_IS_INT(in[2]->type))
- param->AddressFilterType=in[2]->u.num;
- }
-
- transform_from_geo(pro.u.projection,in[0]->u.coord_geo,&c);
- w->c.x=c.x;
- w->c.y=c.y;
- w->c.pro=pro.u.projection;
- gui_internal_cmd_pois(this, w, param);
- g_free(w);
- gui_internal_poi_param_free(param);
+static void gui_internal_cmd2_pois(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *w;
+ struct poi_param *param;
+ struct attr pro;
+ struct coord c;
+
+ dbg(lvl_debug,"enter");
+ if (!in || !in[0])
+ return;
+ if (!ATTR_IS_COORD_GEO(in[0]->type))
+ return;
+ if (!navit_get_attr(this->nav, attr_projection, &pro, NULL))
+ return;
+ w=g_new0(struct widget,1);
+ param=g_new0(struct poi_param,1);
+ if (in[1] && ATTR_IS_STRING(in[1]->type)) {
+ gui_internal_poi_param_set_filter(param, in[1]->u.str);
+ if (in[2] && ATTR_IS_INT(in[2]->type))
+ param->AddressFilterType=in[2]->u.num;
+ }
+
+ transform_from_geo(pro.u.projection,in[0]->u.coord_geo,&c);
+ w->c.x=c.x;
+ w->c.y=c.y;
+ w->c.pro=pro.u.projection;
+ gui_internal_cmd_pois(this, w, param);
+ g_free(w);
+ gui_internal_poi_param_free(param);
}
-static void
-gui_internal_cmd2_locale(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *menu,*wb,*w;
- char *text;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- menu=gui_internal_menu(this, _("Show Locale"));
- menu->spx=this->spacing*10;
- wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(menu, wb);
- text=g_strdup_printf("LANG=%1$s (1=%3$s 2=%2$s)",getenv("LANG"),"2","1");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_left_center|orientation_horizontal|flags_fill;
- g_free(text);
+static void gui_internal_cmd2_locale(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *menu,*wb,*w;
+ char *text;
+
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ menu=gui_internal_menu(this, _("Show Locale"));
+ menu->spx=this->spacing*10;
+ wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(menu, wb);
+ text=g_strdup_printf("LANG=%1$s (1=%3$s 2=%2$s)",getenv("LANG"),"2","1");
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_left_center|orientation_horizontal|flags_fill;
+ g_free(text);
#ifdef HAVE_API_WIN32_BASE
- {
- char country[32],lang[32];
+ {
+ char country[32],lang[32];
#ifdef HAVE_API_WIN32_CE
- wchar_t wcountry[32],wlang[32];
+ wchar_t wcountry[32],wlang[32];
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, wlang, sizeof(wlang));
- WideCharToMultiByte(CP_ACP,0,wlang,-1,lang,sizeof(lang),NULL,NULL);
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, wlang, sizeof(wlang));
+ WideCharToMultiByte(CP_ACP,0,wlang,-1,lang,sizeof(lang),NULL,NULL);
#else
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, lang, sizeof(lang));
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, lang, sizeof(lang));
#endif
- text=g_strdup_printf("LOCALE_SABBREVLANGNAME=%s",lang);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_left_center|orientation_horizontal|flags_fill;
- g_free(text);
+ text=g_strdup_printf("LOCALE_SABBREVLANGNAME=%s",lang);
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_left_center|orientation_horizontal|flags_fill;
+ g_free(text);
#ifdef HAVE_API_WIN32_CE
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, wcountry, sizeof(wcountry));
- WideCharToMultiByte(CP_ACP,0,wcountry,-1,country,sizeof(country),NULL,NULL);
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, wcountry, sizeof(wcountry));
+ WideCharToMultiByte(CP_ACP,0,wcountry,-1,country,sizeof(country),NULL,NULL);
#else
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, country, sizeof(country));
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, country, sizeof(country));
#endif
- text=g_strdup_printf("LOCALE_SABBREVCTRYNAME=%s",country);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_left_center|orientation_horizontal|flags_fill;
- g_free(text);
- }
+ text=g_strdup_printf("LOCALE_SABBREVCTRYNAME=%s",country);
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_left_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ }
#endif
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
}
/**
@@ -793,553 +798,528 @@ gui_internal_cmd2_locale(struct gui_priv *this, char *function, struct attr **in
* Currently only works on non Windows systems.
*
*/
-static void
-gui_internal_cmd2_network_info(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
+static void gui_internal_cmd2_network_info(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
#if HAS_IFADDRS
- struct widget *menu,*wb,*w;
- char *text;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- menu=gui_internal_menu(this, _("Network info"));
- menu->spx=this->spacing*10;
- wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(menu, wb);
-
- struct ifaddrs *addrs, *tmp;
- getifaddrs(&addrs);
- tmp = addrs;
-
- while (tmp)
- {
- if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET)
- {
- struct sockaddr_in *pAddr = (struct sockaddr_in *)tmp->ifa_addr;
- if(g_ascii_strncasecmp(tmp->ifa_name,"lo",2 ) ) {
- text=g_strdup_printf("%s: %s", tmp->ifa_name, inet_ntoa(pAddr->sin_addr));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- }
- }
- tmp = tmp->ifa_next;
- }
- freeifaddrs(addrs);
-
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
+ struct widget *menu,*wb,*w;
+ char *text;
+
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ menu=gui_internal_menu(this, _("Network info"));
+ menu->spx=this->spacing*10;
+ wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(menu, wb);
+
+ struct ifaddrs *addrs, *tmp;
+ getifaddrs(&addrs);
+ tmp = addrs;
+
+ while (tmp) {
+ if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET) {
+ struct sockaddr_in *pAddr = (struct sockaddr_in *)tmp->ifa_addr;
+ if(g_ascii_strncasecmp(tmp->ifa_name,"lo",2 ) ) {
+ text=g_strdup_printf("%s: %s", tmp->ifa_name, inet_ntoa(pAddr->sin_addr));
+ gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ }
+ }
+ tmp = tmp->ifa_next;
+ }
+ freeifaddrs(addrs);
+
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
#else
- dbg(lvl_error, "Cannot show network info: ifaddr.h not found\n");
+ dbg(lvl_error, "Cannot show network info: ifaddr.h not found");
#endif
}
-static void
-gui_internal_cmd_formerdests(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *wb,*w,*wbm,*tbl=NULL;
- struct map *formerdests;
- struct map_rect *mr_formerdests;
- struct item *item;
- struct attr attr;
- char *label_full;
- enum projection projection;
-
- if(!navit_get_attr(this->nav, attr_former_destination_map, &attr, NULL))
- return;
-
- formerdests=attr.u.map;
- if(!formerdests)
- return;
-
- mr_formerdests=map_rect_new(formerdests, NULL);
- if(!mr_formerdests)
- return;
-
- projection = map_projection(formerdests);
-
- gui_internal_prune_menu_count(this, 1, 0);
- wb=gui_internal_menu(this, _("Former Destinations"));
- wb->background=this->background;
-
- w=gui_internal_box_new(this,
- gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*2;
- gui_internal_widget_append(wb, w);
- while ((item=map_rect_get_item(mr_formerdests))) {
- struct coord c;
- struct widget *row;
- if (item->type!=type_former_destination) continue;
- if (!item_attr_get(item, attr_label, &attr)) continue;
- if(!tbl) {
- tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand | orientation_vertical,1);
- gui_internal_widget_append(w,tbl);
- }
- row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_vertical);
- gui_internal_widget_prepend(tbl, row);
- label_full=attr.u.str;
- wbm=gui_internal_button_new_with_callback(this, label_full,
- image_new_xs(this, "gui_active"),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_position, NULL);
- gui_internal_widget_append(row,wbm);
- if (item_coord_get(item, &c, 1)) {
- wbm->c.x=c.x;
- wbm->c.y=c.y;
- wbm->c.pro=projection;
- wbm->name=g_strdup(label_full);
- wbm->text=g_strdup(label_full);
- wbm->data=(void*)8; //Mark us as a former destination
- wbm->prefix=g_strdup(label_full);
- }
- }
- if (!tbl){
- wbm=gui_internal_text_new(this, _("- No former destinations available -"),
- gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, wbm);
- }
- gui_internal_menu_render(this);
- map_rect_destroy(mr_formerdests);
+static void gui_internal_cmd_formerdests(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct widget *wb,*w,*wbm,*tbl=NULL;
+ struct map *formerdests;
+ struct map_rect *mr_formerdests;
+ struct item *item;
+ struct attr attr;
+ char *label_full;
+ enum projection projection;
+
+ if(!navit_get_attr(this->nav, attr_former_destination_map, &attr, NULL))
+ return;
+
+ formerdests=attr.u.map;
+ if(!formerdests)
+ return;
+
+ mr_formerdests=map_rect_new(formerdests, NULL);
+ if(!mr_formerdests)
+ return;
+
+ projection = map_projection(formerdests);
+
+ gui_internal_prune_menu_count(this, 1, 0);
+ wb=gui_internal_menu(this, _("Former Destinations"));
+ wb->background=this->background;
+
+ w=gui_internal_box_new(this,
+ gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ w->spy=this->spacing*2;
+ gui_internal_widget_append(wb, w);
+ while ((item=map_rect_get_item(mr_formerdests))) {
+ struct coord c;
+ struct widget *row;
+ if (item->type!=type_former_destination) continue;
+ if (!item_attr_get(item, attr_label, &attr)) continue;
+ if(!tbl) {
+ tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand | orientation_vertical,1);
+ gui_internal_widget_append(w,tbl);
+ }
+ row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_vertical);
+ gui_internal_widget_prepend(tbl, row);
+ label_full=attr.u.str;
+ wbm=gui_internal_button_new_with_callback(this, label_full,
+ image_new_xs(this, "gui_active"),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_position, NULL);
+ gui_internal_widget_append(row,wbm);
+ if (item_coord_get(item, &c, 1)) {
+ wbm->c.x=c.x;
+ wbm->c.y=c.y;
+ wbm->c.pro=projection;
+ wbm->name=g_strdup(label_full);
+ wbm->text=g_strdup(label_full);
+ wbm->data=(void*)8; //Mark us as a former destination
+ wbm->prefix=g_strdup(label_full);
+ }
+ }
+ if (!tbl) {
+ wbm=gui_internal_text_new(this, _("- No former destinations available -"),
+ gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, wbm);
+ }
+ gui_internal_menu_render(this);
+ map_rect_destroy(mr_formerdests);
}
-static void
-gui_internal_cmd2_bookmarks(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str=NULL;
- if (in && in[0] && ATTR_IS_STRING(in[0]->type)) {
- str=in[0]->u.str;
- }
+static void gui_internal_cmd2_bookmarks(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *str=NULL;
+ if (in && in[0] && ATTR_IS_STRING(in[0]->type)) {
+ str=in[0]->u.str;
+ }
- gui_internal_cmd_bookmarks(this, NULL, str);
+ gui_internal_cmd_bookmarks(this, NULL, str);
}
-static void
-gui_internal_cmd2_abort_navigation(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- navit_set_destination(this->nav, NULL, NULL, 0);
+static void gui_internal_cmd2_abort_navigation(struct gui_priv *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ navit_set_destination(this->nav, NULL, NULL, 0);
}
-static void
-gui_internal_cmd2_back(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_back(this, NULL, NULL);
- graphics_draw_mode(this->gra, draw_mode_end);
- gui_internal_check_exit(this);
+static void gui_internal_cmd2_back(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_back(this, NULL, NULL);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ gui_internal_check_exit(this);
}
-static void
-gui_internal_cmd2_back_to_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- gui_internal_prune_menu(this, NULL);
- gui_internal_check_exit(this);
+static void gui_internal_cmd2_back_to_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ gui_internal_prune_menu(this, NULL);
+ gui_internal_check_exit(this);
}
-static void
-gui_internal_get_data(struct gui_priv *priv, char *command, struct attr **in, struct attr ***out)
-{
- struct attr private_data = { attr_private_data, {(void *)&priv->data}};
- if (out)
- *out=attr_generic_add_attr(*out, &private_data);
+static void gui_internal_get_data(struct gui_priv *priv, char *command, struct attr **in, struct attr ***out) {
+ struct attr private_data = { attr_private_data, {(void *)&priv->data}};
+ if (out)
+ *out=attr_generic_add_attr(*out, &private_data);
}
-static void
-gui_internal_cmd_log(struct gui_priv *this)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- gui_internal_enter(this, 1);
- gui_internal_set_click_coord(this, NULL);
- gui_internal_enter_setup(this);
- wb=gui_internal_menu(this, "Log Message");
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Message")));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_log_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
- gui_internal_leave(this);
+static void gui_internal_cmd_log(struct gui_priv *this) {
+ struct widget *w,*wb,*wk,*wl,*we,*wnext;
+ gui_internal_enter(this, 1);
+ gui_internal_set_click_coord(this, NULL);
+ gui_internal_enter_setup(this);
+ wb=gui_internal_menu(this, "Log Message");
+ w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(w, we);
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Message")));
+ wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_call_linked_on_finish;
+ gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wnext->state |= STATE_SENSITIVE;
+ wnext->func = gui_internal_cmd_log_clicked;
+ wnext->data=wk;
+ wk->data=wnext;
+ wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wl);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")),
+ getenv("LANG"));
+ gui_internal_menu_render(this);
+ gui_internal_leave(this);
}
-static void
-gui_internal_cmd_menu2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *href=NULL;
- int i=0, ignore=0, replace=0;
-
- if (in && in[i] && ATTR_IS_INT(in[i]->type))
- ignore=in[i++]->u.num;
-
- if (in && in[i] && ATTR_IS_STRING(in[i]->type)) {
- href=in[i++]->u.str;
- if (in[i] && ATTR_IS_INT(in[i]->type))
- replace=in[i++]->u.num;
- }
-
- if (this->root.children) {
- if (!href)
- return;
- gui_internal_html_load_href(this, href, replace);
- return;
- }
- gui_internal_cmd_menu(this, ignore, href);
+static void gui_internal_cmd_menu2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *href=NULL;
+ int i=0, ignore=0, replace=0;
+
+ if (in && in[i] && ATTR_IS_INT(in[i]->type))
+ ignore=in[i++]->u.num;
+
+ if (in && in[i] && ATTR_IS_STRING(in[i]->type)) {
+ href=in[i++]->u.str;
+ if (in[i] && ATTR_IS_INT(in[i]->type))
+ replace=in[i++]->u.num;
+ }
+
+ if (this->root.children) {
+ if (!href)
+ return;
+ gui_internal_html_load_href(this, href, replace);
+ return;
+ }
+ gui_internal_cmd_menu(this, ignore, href);
}
-static void
-gui_internal_cmd2_position(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- const char *name=_("Position");
- int flags=-1;
-
- dbg(lvl_debug,"enter\n");
- if (!in || !in[0])
- return;
- if (!ATTR_IS_COORD_GEO(in[0]->type))
- return;
- if (in[1] && ATTR_IS_STRING(in[1]->type)) {
- name=in[1]->u.str;
- if (in[2] && ATTR_IS_INT(in[2]->type))
- flags=in[2]->u.num;
- }
- dbg(lvl_debug,"flags=0x%x\n",flags);
- gui_internal_cmd_position_do(this, NULL, in[0]->u.coord_geo, NULL, name, flags);
+static void gui_internal_cmd2_position(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ const char *name=_("Position");
+ int flags=-1;
+
+ dbg(lvl_debug,"enter");
+ if (!in || !in[0])
+ return;
+ if (!ATTR_IS_COORD_GEO(in[0]->type))
+ return;
+ if (in[1] && ATTR_IS_STRING(in[1]->type)) {
+ name=in[1]->u.str;
+ if (in[2] && ATTR_IS_INT(in[2]->type))
+ flags=in[2]->u.num;
+ }
+ dbg(lvl_debug,"flags=0x%x",flags);
+ gui_internal_cmd_position_do(this, NULL, in[0]->u.coord_geo, NULL, name, flags);
}
-static void
-gui_internal_cmd_redraw_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- this->redraw=1;
+static void gui_internal_cmd_redraw_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ this->redraw=1;
}
-static void
-gui_internal_cmd2_refresh(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *href=g_strdup(this->href);
- gui_internal_html_load_href(this, href, 1);
- g_free(href);
+static void gui_internal_cmd2_refresh(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *href=g_strdup(this->href);
+ gui_internal_html_load_href(this, href, 1);
+ g_free(href);
}
-static void
-gui_internal_cmd2_set(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *pattern,*command=NULL;
- if (!in || !in[0] || !ATTR_IS_STRING(in[0]->type)) {
- dbg(lvl_error,"first parameter missing or wrong type\n");
- return;
- }
- pattern=in[0]->u.str;
- dbg(lvl_debug,"pattern %s\n",pattern);
- if (in[1]) {
- command=gui_internal_cmd_match_expand(pattern, in+1);
- dbg(lvl_debug,"expand %s\n",command);
- gui_internal_set(pattern, command);
- command_evaluate(&this->self, command);
- g_free(command);
- } else {
- gui_internal_set(pattern, NULL);
- }
+static void gui_internal_cmd2_set(struct gui_priv *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *pattern,*command=NULL;
+ if (!in || !in[0] || !ATTR_IS_STRING(in[0]->type)) {
+ dbg(lvl_error,"first parameter missing or wrong type");
+ return;
+ }
+ pattern=in[0]->u.str;
+ dbg(lvl_debug,"pattern %s",pattern);
+ if (in[1]) {
+ command=gui_internal_cmd_match_expand(pattern, in+1);
+ dbg(lvl_debug,"expand %s",command);
+ gui_internal_set(pattern, command);
+ command_evaluate(&this->self, command);
+ g_free(command);
+ } else {
+ gui_internal_set(pattern, NULL);
+ }
}
-void
-gui_internal_cmd2_quit(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr navit;
- gui_internal_prune_menu(this, NULL);
- navit.type=attr_navit;
- navit.u.navit=this->nav;
- config_remove_attr(config, &navit);
- event_main_loop_quit();
+void gui_internal_cmd2_quit(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ struct attr navit;
+ gui_internal_prune_menu(this, NULL);
+ navit.type=attr_navit;
+ navit.u.navit=this->nav;
+ config_remove_attr(config, &navit);
+ event_main_loop_quit();
}
-static char *
-gui_internal_append_attr(char *str, enum escape_mode mode, char *pre, struct attr *attr, char *post)
-{
- char *astr=NULL;
- if (ATTR_IS_STRING(attr->type))
- astr=gui_internal_escape(mode, attr->u.str);
- else if (ATTR_IS_COORD_GEO(attr->type)) {
- char *str2=coordinates_geo(attr->u.coord_geo, '\n');
- astr=gui_internal_escape(mode, str2);
- g_free(str2);
- } else if (ATTR_IS_INT(attr->type))
- astr=g_strdup_printf("%ld",attr->u.num);
- else
- astr=g_strdup_printf("Unsupported type %s",attr_to_name(attr->type));
- str=g_strconcat_printf(str,"%s%s%s",pre,astr,post);
- g_free(astr);
- return str;
+static char *gui_internal_append_attr(char *str, enum escape_mode mode, char *pre, struct attr *attr, char *post) {
+ char *astr=NULL;
+ if (ATTR_IS_STRING(attr->type))
+ astr=gui_internal_escape(mode, attr->u.str);
+ else if (ATTR_IS_COORD_GEO(attr->type)) {
+ char *str2=coordinates_geo(attr->u.coord_geo, '\n');
+ astr=gui_internal_escape(mode, str2);
+ g_free(str2);
+ } else if (ATTR_IS_INT(attr->type))
+ astr=g_strdup_printf("%ld",attr->u.num);
+ else
+ astr=g_strdup_printf("Unsupported type %s",attr_to_name(attr->type));
+ str=g_strconcat_printf(str,"%s%s%s",pre,astr,post);
+ g_free(astr);
+ return str;
}
-static void
-gui_internal_cmd_write(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str=NULL;
- dbg(lvl_debug,"enter %s %p %p %p\n",function,in,out,valid);
- if (!in)
- return;
- while (*in) {
- str=gui_internal_append_attr(str, escape_mode_none, "", *in, "");
- in++;
- }
- if (str) {
- str=g_strdup_printf("<html>%s</html>\n",str);
+static void gui_internal_cmd_write(struct gui_priv * this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *str=NULL;
+ dbg(lvl_debug,"enter %s %p %p %p",function,in,out,valid);
+ if (!in)
+ return;
+ while (*in) {
+ str=gui_internal_append_attr(str, escape_mode_none, "", *in, "");
+ in++;
+ }
+ if (str) {
+ str=g_strdup_printf("<html>%s</html>\n",str);
#if 0
- dbg(lvl_debug,"%s\n",str);
+ dbg(lvl_debug,"%s",str);
#endif
- gui_internal_html_parse_text(this, str);
- }
- g_free(str);
+ gui_internal_html_parse_text(this, str);
+ }
+ g_free(str);
}
-static void
-gui_internal_onclick(struct attr ***in, char **onclick, char *set)
-{
- struct attr **i=*in;
- char *c,*str=NULL,*args=NULL,*sep="";
-
- if (!*i || !ATTR_IS_STRING((*i)->type) || !(*i)->u.str)
- goto error;
- str=g_strdup((*i)->u.str);
- i++;
- c=str;
- while (*c) {
- if (c[0] == '%' && c[1] == '{') {
- char format[4],*end=strchr(c+2,'}'),*replacement=NULL,*new_str;
- int is_arg;
- if (!end) {
- dbg(lvl_error,"Missing closing brace in format string %s\n",c);
- goto error;
- }
- if (end-c > sizeof(format)) {
- dbg(lvl_error,"Invalid format string %s\n",c);
- goto error;
- }
- strncpy(format, c+2, end-c-2);
- format[end-c-2]='\0';
- is_arg=end[1] == '*';
- c[0]='\0';
- if (!strcmp(format,"d")) {
- replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
- if (is_arg) {
- args=g_strconcat_printf(args, "%s%s", args ? "," : "", replacement);
- g_free(replacement);
- replacement=g_strdup("");
- }
-
- }
- if (!strcmp(format,"se")) {
- replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
- if (is_arg) {
- char *arg=gui_internal_escape(escape_mode_string, replacement);
- args=g_strconcat_printf(args, "%s%s", args ? "," : "", arg);
- g_free(replacement);
- g_free(arg);
- replacement=g_strdup("");
- }
- }
- if (!replacement) {
- dbg(lvl_error,"Unsupported format string %s\n",format);
- goto error;
- }
- new_str=g_strconcat(str, replacement, end+1, NULL);
- c=new_str+strlen(str)+strlen(replacement);
- g_free(str);
- g_free(replacement);
- str=new_str;
- }
- c++;
- }
- *in=i;
- if (*onclick && strlen(*onclick))
- sep=";";
- if (str && strlen(str)) {
- char *old=*onclick;
- if (set) {
- char *setstr=gui_internal_escape(escape_mode_string,str);
- char *argssep="";
- if (args && strlen(args))
- argssep=",";
- *onclick=g_strconcat(old,sep,set,"(",setstr,argssep,args,")",NULL);
- } else {
- *onclick=g_strconcat(old,sep,str,NULL);
- }
- g_free(old);
- }
+static void gui_internal_onclick(struct attr ***in, char **onclick, char *set) {
+ struct attr **i=*in;
+ char *c,*str=NULL,*args=NULL,*sep="";
+
+ if (!*i || !ATTR_IS_STRING((*i)->type) || !(*i)->u.str)
+ goto error;
+ str=g_strdup((*i)->u.str);
+ i++;
+ c=str;
+ while (*c) {
+ if (c[0] == '%' && c[1] == '{') {
+ char format[4],*end=strchr(c+2,'}'),*replacement=NULL,*new_str;
+ int is_arg;
+ if (!end) {
+ dbg(lvl_error,"Missing closing brace in format string %s",c);
+ goto error;
+ }
+ if (end-c > sizeof(format)) {
+ dbg(lvl_error,"Invalid format string %s",c);
+ goto error;
+ }
+ strncpy(format, c+2, end-c-2);
+ format[end-c-2]='\0';
+ is_arg=end[1] == '*';
+ c[0]='\0';
+ if (!strcmp(format,"d")) {
+ replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
+ if (is_arg) {
+ args=g_strconcat_printf(args, "%s%s", args ? "," : "", replacement);
+ g_free(replacement);
+ replacement=g_strdup("");
+ }
+
+ }
+ if (!strcmp(format,"se")) {
+ replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
+ if (is_arg) {
+ char *arg=gui_internal_escape(escape_mode_string, replacement);
+ args=g_strconcat_printf(args, "%s%s", args ? "," : "", arg);
+ g_free(replacement);
+ g_free(arg);
+ replacement=g_strdup("");
+ }
+ }
+ if (!replacement) {
+ dbg(lvl_error,"Unsupported format string %s",format);
+ goto error;
+ }
+ new_str=g_strconcat(str, replacement, end+1, NULL);
+ c=new_str+strlen(str)+strlen(replacement);
+ g_free(str);
+ g_free(replacement);
+ str=new_str;
+ }
+ c++;
+ }
+ *in=i;
+ if (*onclick && strlen(*onclick))
+ sep=";";
+ if (str && strlen(str)) {
+ char *old=*onclick;
+ if (set) {
+ char *setstr=gui_internal_escape(escape_mode_string,str);
+ char *argssep="";
+ if (args && strlen(args))
+ argssep=",";
+ *onclick=g_strconcat(old,sep,set,"(",setstr,argssep,args,")",NULL);
+ } else {
+ *onclick=g_strconcat(old,sep,str,NULL);
+ }
+ g_free(old);
+ }
error:
- g_free(str);
- g_free(args);
- return;
+ g_free(str);
+ g_free(args);
+ return;
}
-static void
-gui_internal_cmd_img(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str=g_strdup("<img"),*suffix=NULL,*onclick=g_strdup(""),*html;
-
- if (ATTR_IS_STRING((*in)->type)) {
- if ((*in)->u.str && strlen((*in)->u.str))
- str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " class=", *in, "");
- in++;
- } else {
- dbg(lvl_error,"argument error: class argument not string\n");
- goto error;
- }
- if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
- if ((*in)->u.str && strlen((*in)->u.str)) {
- str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " src=", *in, "");
- }
- in++;
- } else {
- dbg(lvl_error,"argument error: image argument not string\n");
- goto error;
- }
- if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
- if ((*in)->u.str && strlen((*in)->u.str)) {
- suffix=gui_internal_append_attr(NULL, escape_mode_html, ">", *in, "</img>");
- } else {
- suffix=g_strdup("/>");
- }
- in++;
- } else {
- dbg(lvl_error,"argument error: text argument not string\n");
- goto error;
- }
- gui_internal_onclick(&in,&onclick,NULL);
- gui_internal_onclick(&in,&onclick,"set");
- gui_internal_onclick(&in,&onclick,NULL);
- if (strlen(onclick)) {
- char *tmp=gui_internal_escape(escape_mode_html_apos, onclick);
- str=g_strconcat_printf(str," onclick='%s'",tmp);
- g_free(tmp);
- }
- g_free(onclick);
- html=g_strdup_printf("<html>%s%s</html>\n",str,suffix);
- dbg(lvl_debug,"return %s",html);
- gui_internal_html_parse_text(this, html);
- g_free(html);
+static void gui_internal_cmd_img(struct gui_priv * this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *str=g_strdup("<img"),*suffix=NULL,*onclick=g_strdup(""),*html;
+
+ if (ATTR_IS_STRING((*in)->type)) {
+ if ((*in)->u.str && strlen((*in)->u.str))
+ str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " class=", *in, "");
+ in++;
+ } else {
+ dbg(lvl_error,"argument error: class argument not string");
+ goto error;
+ }
+ if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
+ if ((*in)->u.str && strlen((*in)->u.str)) {
+ str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " src=", *in, "");
+ }
+ in++;
+ } else {
+ dbg(lvl_error,"argument error: image argument not string");
+ goto error;
+ }
+ if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
+ if ((*in)->u.str && strlen((*in)->u.str)) {
+ suffix=gui_internal_append_attr(NULL, escape_mode_html, ">", *in, "</img>");
+ } else {
+ suffix=g_strdup("/>");
+ }
+ in++;
+ } else {
+ dbg(lvl_error,"argument error: text argument not string");
+ goto error;
+ }
+ gui_internal_onclick(&in,&onclick,NULL);
+ gui_internal_onclick(&in,&onclick,"set");
+ gui_internal_onclick(&in,&onclick,NULL);
+ if (strlen(onclick)) {
+ char *tmp=gui_internal_escape(escape_mode_html_apos, onclick);
+ str=g_strconcat_printf(str," onclick='%s'",tmp);
+ g_free(tmp);
+ }
+ g_free(onclick);
+ html=g_strdup_printf("<html>%s%s</html>\n",str,suffix);
+ dbg(lvl_debug,"return %s",html);
+ gui_internal_html_parse_text(this, html);
+ g_free(html);
error:
- g_free(suffix);
- g_free(str);
- return;
+ g_free(suffix);
+ g_free(str);
+ return;
}
-static void
-gui_internal_cmd_debug(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str;
- dbg(lvl_debug,"begin\n");
- if (in) {
- while (*in) {
- str=attr_to_text(*in, NULL, 0);
- dbg(lvl_debug,"%s:%s\n",attr_to_name((*in)->type),str);
- in++;
- g_free(str);
- }
- }
- dbg(lvl_debug,"done\n");
+static void gui_internal_cmd_debug(struct gui_priv * this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char *str;
+ dbg(lvl_debug,"begin");
+ if (in) {
+ while (*in) {
+ str=attr_to_text(*in, NULL, 0);
+ dbg(lvl_debug,"%s:%s",attr_to_name((*in)->type),str);
+ in++;
+ g_free(str);
+ }
+ }
+ dbg(lvl_debug,"done");
}
-static void
-gui_internal_cmd2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- int entering=0;
- int ignore=1;
- if (in && in[0] && ATTR_IS_INT(in[0]->type)) {
- ignore=in[0]->u.num;
- in++;
- }
-
- if(!this->root.children) {
- entering=1;
- gui_internal_apply_config(this);
- gui_internal_enter(this, ignore);
- gui_internal_enter_setup(this);
- }
-
- if(!strcmp(function, "bookmarks"))
- gui_internal_cmd2_bookmarks(this, function, in, out, valid);
- else if(!strcmp(function, "formerdests"))
- gui_internal_cmd_formerdests(this, function, in, out, valid);
- else if(!strcmp(function, "locale"))
- gui_internal_cmd2_locale(this, function, in, out, valid);
- else if(!strcmp(function, "network_info"))
- gui_internal_cmd2_network_info(this, function, in, out, valid);
- else if(!strcmp(function, "position"))
- gui_internal_cmd2_position(this, function, in, out, valid);
- else if(!strcmp(function, "pois"))
- gui_internal_cmd2_pois(this, function, in, out, valid);
- else if(!strcmp(function, "route_description"))
- gui_internal_cmd2_route_description(this, function, in, out, valid);
- else if(!strcmp(function, "route_height_profile"))
- gui_internal_cmd2_route_height_profile(this, function, in, out, valid);
- else if(!strcmp(function, "setting_layout"))
- gui_internal_cmd2_setting_layout(this, function, in, out, valid);
- else if(!strcmp(function, "setting_maps"))
- gui_internal_cmd2_setting_maps(this, function, in, out, valid);
- else if(!strcmp(function, "setting_rules"))
- gui_internal_cmd2_setting_rules(this, function, in, out, valid);
- else if(!strcmp(function, "setting_vehicle"))
- gui_internal_cmd2_setting_vehicle(this, function, in, out, valid);
- else if(!strcmp(function, "town"))
- gui_internal_cmd2_town(this, function, in, out, valid);
- else if(!strcmp(function, "enter_coord"))
- gui_internal_cmd_enter_coord(this, function, in, out, valid);
- else if(!strcmp(function, "waypoints"))
- gui_internal_cmd2_waypoints(this, function, in, out, valid);
- else if(!strcmp(function, "about"))
- gui_internal_cmd2_about(this, function, in, out, valid);
-
- if(entering)
- graphics_draw_mode(this->gra, draw_mode_end);
+static void gui_internal_cmd2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ int entering=0;
+ int ignore=1;
+ if (in && in[0] && ATTR_IS_INT(in[0]->type)) {
+ ignore=in[0]->u.num;
+ in++;
+ }
+
+ if(!this->root.children) {
+ entering=1;
+ gui_internal_apply_config(this);
+ gui_internal_enter(this, ignore);
+ gui_internal_enter_setup(this);
+ }
+
+ if(!strcmp(function, "bookmarks"))
+ gui_internal_cmd2_bookmarks(this, function, in, out, valid);
+ else if(!strcmp(function, "formerdests"))
+ gui_internal_cmd_formerdests(this, function, in, out, valid);
+ else if(!strcmp(function, "locale"))
+ gui_internal_cmd2_locale(this, function, in, out, valid);
+ else if(!strcmp(function, "network_info"))
+ gui_internal_cmd2_network_info(this, function, in, out, valid);
+ else if(!strcmp(function, "position"))
+ gui_internal_cmd2_position(this, function, in, out, valid);
+ else if(!strcmp(function, "pois"))
+ gui_internal_cmd2_pois(this, function, in, out, valid);
+ else if(!strcmp(function, "route_description"))
+ gui_internal_cmd2_route_description(this, function, in, out, valid);
+ else if(!strcmp(function, "route_height_profile"))
+ gui_internal_cmd2_route_height_profile(this, function, in, out, valid);
+ else if(!strcmp(function, "setting_layout"))
+ gui_internal_cmd2_setting_layout(this, function, in, out, valid);
+ else if(!strcmp(function, "setting_maps"))
+ gui_internal_cmd2_setting_maps(this, function, in, out, valid);
+ else if(!strcmp(function, "setting_rules"))
+ gui_internal_cmd2_setting_rules(this, function, in, out, valid);
+ else if(!strcmp(function, "setting_vehicle"))
+ gui_internal_cmd2_setting_vehicle(this, function, in, out, valid);
+ else if(!strcmp(function, "town"))
+ gui_internal_cmd2_town(this, function, in, out, valid);
+ else if(!strcmp(function, "enter_coord"))
+ gui_internal_cmd_enter_coord(this, function, in, out, valid);
+ else if(!strcmp(function, "waypoints"))
+ gui_internal_cmd2_waypoints(this, function, in, out, valid);
+ else if(!strcmp(function, "about"))
+ gui_internal_cmd2_about(this, function, in, out, valid);
+
+ if(entering)
+ graphics_draw_mode(this->gra, draw_mode_end);
}
static struct command_table commands[] = {
- {"E",command_cast(gui_internal_cmd_escape)},
- {"abort_navigation",command_cast(gui_internal_cmd2_abort_navigation)},
- {"back",command_cast(gui_internal_cmd2_back)},
- {"back_to_map",command_cast(gui_internal_cmd2_back_to_map)},
- {"bookmarks",command_cast(gui_internal_cmd2)},
- {"debug",command_cast(gui_internal_cmd_debug)},
- {"formerdests",command_cast(gui_internal_cmd2)},
- {"get_data",command_cast(gui_internal_get_data)},
- {"img",command_cast(gui_internal_cmd_img)},
- {"locale",command_cast(gui_internal_cmd2)},
- {"log",command_cast(gui_internal_cmd_log)},
- {"menu",command_cast(gui_internal_cmd_menu2)},
- {"position",command_cast(gui_internal_cmd2_position)},
- {"pois",command_cast(gui_internal_cmd2)},
- {"redraw_map",command_cast(gui_internal_cmd_redraw_map)},
- {"refresh",command_cast(gui_internal_cmd2_refresh)},
- {"route_description",command_cast(gui_internal_cmd2)},
- {"route_height_profile",command_cast(gui_internal_cmd2)},
- {"set",command_cast(gui_internal_cmd2_set)},
- {"setting_layout",command_cast(gui_internal_cmd2)},
- {"setting_maps",command_cast(gui_internal_cmd2)},
- {"setting_rules",command_cast(gui_internal_cmd2)},
- {"setting_vehicle",command_cast(gui_internal_cmd2)},
- {"town",command_cast(gui_internal_cmd2)},
- {"enter_coord",command_cast(gui_internal_cmd2)},
- {"quit",command_cast(gui_internal_cmd2_quit)},
- {"waypoints",command_cast(gui_internal_cmd2)},
- {"write",command_cast(gui_internal_cmd_write)},
- {"about",command_cast(gui_internal_cmd2)},
+ {"E",command_cast(gui_internal_cmd_escape)},
+ {"abort_navigation",command_cast(gui_internal_cmd2_abort_navigation)},
+ {"back",command_cast(gui_internal_cmd2_back)},
+ {"back_to_map",command_cast(gui_internal_cmd2_back_to_map)},
+ {"bookmarks",command_cast(gui_internal_cmd2)},
+ {"debug",command_cast(gui_internal_cmd_debug)},
+ {"formerdests",command_cast(gui_internal_cmd2)},
+ {"get_data",command_cast(gui_internal_get_data)},
+ {"img",command_cast(gui_internal_cmd_img)},
+ {"locale",command_cast(gui_internal_cmd2)},
+ {"log",command_cast(gui_internal_cmd_log)},
+ {"menu",command_cast(gui_internal_cmd_menu2)},
+ {"position",command_cast(gui_internal_cmd2_position)},
+ {"pois",command_cast(gui_internal_cmd2)},
+ {"redraw_map",command_cast(gui_internal_cmd_redraw_map)},
+ {"refresh",command_cast(gui_internal_cmd2_refresh)},
+ {"route_description",command_cast(gui_internal_cmd2)},
+ {"route_height_profile",command_cast(gui_internal_cmd2)},
+ {"set",command_cast(gui_internal_cmd2_set)},
+ {"setting_layout",command_cast(gui_internal_cmd2)},
+ {"setting_maps",command_cast(gui_internal_cmd2)},
+ {"setting_rules",command_cast(gui_internal_cmd2)},
+ {"setting_vehicle",command_cast(gui_internal_cmd2)},
+ {"town",command_cast(gui_internal_cmd2)},
+ {"enter_coord",command_cast(gui_internal_cmd2)},
+ {"quit",command_cast(gui_internal_cmd2_quit)},
+ {"waypoints",command_cast(gui_internal_cmd2)},
+ {"write",command_cast(gui_internal_cmd_write)},
+ {"about",command_cast(gui_internal_cmd2)},
#if HAS_IFADDRS
- {"network_info",command_cast(gui_internal_cmd2)},
+ {"network_info",command_cast(gui_internal_cmd2)},
#endif
#ifdef USE_AUDIO_FRAMEWORK
{"media_show_playlist", command_cast (gui_internal_media_show_playlist)},
@@ -1347,13 +1327,11 @@ static struct command_table commands[] = {
};
-void
-gui_internal_command_init(struct gui_priv *this, struct attr **attrs)
-{
- struct attr *attr;
- if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
- command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this);
- }
+void gui_internal_command_init(struct gui_priv *this, struct attr **attrs) {
+ struct attr *attr;
+ if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
+ command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this);
+ }
}
diff --git a/navit/gui/internal/gui_internal_gesture.c b/navit/gui/internal/gui_internal_gesture.c
index d01a80f1d..0ed2805cc 100644
--- a/navit/gui/internal/gui_internal_gesture.c
+++ b/navit/gui/internal/gui_internal_gesture.c
@@ -27,119 +27,109 @@
#include "gui_internal_menu.h"
#include "gui_internal_gesture.h"
-void
-gui_internal_gesture_ring_clear(struct gui_priv *this)
-{
- this->gesture_ring_last=this->gesture_ring_first=0;
+void gui_internal_gesture_ring_clear(struct gui_priv *this) {
+ this->gesture_ring_last=this->gesture_ring_first=0;
};
-static struct gesture_elem *
-gui_internal_gesture_ring_get(struct gui_priv *this, int i)
-{
- int n=(this->gesture_ring_last-i+GESTURE_RINGSIZE)%GESTURE_RINGSIZE;
- if(n==this->gesture_ring_first)
- return NULL;
- return this->gesture_ring+n;
+static struct gesture_elem *gui_internal_gesture_ring_get(struct gui_priv *this, int i) {
+ int n=(this->gesture_ring_last-i+GESTURE_RINGSIZE)%GESTURE_RINGSIZE;
+ if(n==this->gesture_ring_first)
+ return NULL;
+ return this->gesture_ring+n;
};
-void
-gui_internal_gesture_ring_add(struct gui_priv *this, struct point *p)
-{
- long long msec;
+void gui_internal_gesture_ring_add(struct gui_priv *this, struct point *p) {
+ long long msec;
#ifndef HAVE_API_WIN32_CE
- struct timeval tv;
- gettimeofday(&tv,NULL);
- msec=((long long)tv.tv_sec)*1000+tv.tv_usec/1000;
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+ msec=((long long)tv.tv_sec)*1000+tv.tv_usec/1000;
#else
- msec=GetTickCount();
+ msec=GetTickCount();
#endif
- this->gesture_ring_last++;
- this->gesture_ring_last%=GESTURE_RINGSIZE;
- if(this->gesture_ring_last==this->gesture_ring_first) {
- this->gesture_ring_first++;
- this->gesture_ring_first%=GESTURE_RINGSIZE;
- }
- this->gesture_ring[this->gesture_ring_last].p=*p;
- this->gesture_ring[this->gesture_ring_last].msec=msec;
- dbg(lvl_info,"msec="LONGLONG_FMT" x=%d y=%d\n",msec,p->x,p->y);
+ this->gesture_ring_last++;
+ this->gesture_ring_last%=GESTURE_RINGSIZE;
+ if(this->gesture_ring_last==this->gesture_ring_first) {
+ this->gesture_ring_first++;
+ this->gesture_ring_first%=GESTURE_RINGSIZE;
+ }
+ this->gesture_ring[this->gesture_ring_last].p=*p;
+ this->gesture_ring[this->gesture_ring_last].msec=msec;
+ dbg(lvl_info,"msec="LONGLONG_FMT" x=%d y=%d",msec,p->x,p->y);
};
-int
-gui_internal_gesture_get_vector(struct gui_priv *this, long long msec, struct point *p0, int *dx, int *dy)
-{
- struct gesture_elem *g;
- int x,y,dt;
- int i;
+int gui_internal_gesture_get_vector(struct gui_priv *this, long long msec, struct point *p0, int *dx, int *dy) {
+ struct gesture_elem *g;
+ int x,y,dt;
+ int i;
- dt=0;
+ dt=0;
- if(dx) *dx=0;
- if(dy) *dy=0;
- if(p0) {
- p0->x=-1;
- p0->y=-1;
- }
+ if(dx) *dx=0;
+ if(dy) *dy=0;
+ if(p0) {
+ p0->x=-1;
+ p0->y=-1;
+ }
- g=gui_internal_gesture_ring_get(this,0);
- if(!g)
- return 0;
- x=g->p.x;
- y=g->p.y;
- if(p0) {
- *p0=g->p;
- }
- msec=g->msec;
- dbg(lvl_info,LONGLONG_FMT" %d %d\n",g->msec, g->p.x, g->p.y);
- for(i=1;(g=gui_internal_gesture_ring_get(this,i))!=NULL;i++) {
- if( msec-g->msec > 1000 )
- break;
- dt=msec-g->msec;
- if(dx) *dx=x-g->p.x;
- if(dy) *dy=y-g->p.y;
- if(p0) {
- *p0=g->p;
- }
- dbg(lvl_info,LONGLONG_FMT" %d %d\n",g->msec, g->p.x, g->p.y);
- }
- return dt;
+ g=gui_internal_gesture_ring_get(this,0);
+ if(!g)
+ return 0;
+ x=g->p.x;
+ y=g->p.y;
+ if(p0) {
+ *p0=g->p;
+ }
+ msec=g->msec;
+ dbg(lvl_info,LONGLONG_FMT" %d %d",g->msec, g->p.x, g->p.y);
+ for(i=1; (g=gui_internal_gesture_ring_get(this,i))!=NULL; i++) {
+ if( msec-g->msec > 1000 )
+ break;
+ dt=msec-g->msec;
+ if(dx) *dx=x-g->p.x;
+ if(dy) *dy=y-g->p.y;
+ if(p0) {
+ *p0=g->p;
+ }
+ dbg(lvl_info,LONGLONG_FMT" %d %d",g->msec, g->p.x, g->p.y);
+ }
+ return dt;
}
-int
-gui_internal_gesture_do(struct gui_priv *this)
-{
- int dt;
- int dx,dy;
-
- dt=gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
+int gui_internal_gesture_do(struct gui_priv *this) {
+ int dt;
+ int dx,dy;
- if( abs(dx) > this->icon_s*3 && abs(dy) < this->icon_s ) {
- struct widget *wt;
- dbg(lvl_debug,"horizontal dx=%d dy=%d\n",dx,dy);
+ dt=gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
- /* Prevent swiping if widget was scrolled beforehand */
- if(this->pressed==2)
- return 0;
+ if( abs(dx) > this->icon_s*3 && abs(dy) < this->icon_s ) {
+ struct widget *wt;
+ dbg(lvl_debug,"horizontal dx=%d dy=%d",dx,dy);
- for(wt=this->highlighted;wt && wt->type!=widget_table;wt=wt->parent);
- if(!wt || wt->type!=widget_table || !wt->data)
- return 0;
- if(this->highlighted) {
- this->highlighted->state &= ~STATE_HIGHLIGHTED;
- this->highlighted=NULL;
- }
- if(dx<0)
- gui_internal_table_button_next(this,NULL,wt);
- else
- gui_internal_table_button_prev(this,NULL,wt);
- return 1;
- } else if( abs(dy) > this->icon_s*3 && abs(dx) < this->icon_s ) {
- dbg(lvl_debug,"vertical dx=%d dy=%d\n",dx,dy);
- } else if (dt>300 && abs(dx) <this->icon_s && abs(dy) <this->icon_s ) {
- dbg(lvl_debug,"longtap dx=%d dy=%d\n",dx,dy);
- } else {
- dbg(lvl_debug,"none dx=%d dy=%d\n",dx,dy);
- }
-
- return 0;
+ /* Prevent swiping if widget was scrolled beforehand */
+ if(this->pressed==2)
+ return 0;
+
+ for(wt=this->highlighted; wt && wt->type!=widget_table; wt=wt->parent);
+ if(!wt || wt->type!=widget_table || !wt->data)
+ return 0;
+ if(this->highlighted) {
+ this->highlighted->state &= ~STATE_HIGHLIGHTED;
+ this->highlighted=NULL;
+ }
+ if(dx<0)
+ gui_internal_table_button_next(this,NULL,wt);
+ else
+ gui_internal_table_button_prev(this,NULL,wt);
+ return 1;
+ } else if( abs(dy) > this->icon_s*3 && abs(dx) < this->icon_s ) {
+ dbg(lvl_debug,"vertical dx=%d dy=%d",dx,dy);
+ } else if (dt>300 && abs(dx) <this->icon_s && abs(dy) <this->icon_s ) {
+ dbg(lvl_debug,"longtap dx=%d dy=%d",dx,dy);
+ } else {
+ dbg(lvl_debug,"none dx=%d dy=%d",dx,dy);
+ }
+
+ return 0;
};
diff --git a/navit/gui/internal/gui_internal_html.c b/navit/gui/internal/gui_internal_html.c
index 9b42fbdec..41dab9f50 100644
--- a/navit/gui/internal/gui_internal_html.c
+++ b/navit/gui/internal/gui_internal_html.c
@@ -22,483 +22,462 @@ struct gui_priv;
struct form {
- char *onsubmit;
+ char *onsubmit;
};
struct html_tag_map {
- char *tag_name;
- enum html_tag tag;
+ char *tag_name;
+ enum html_tag tag;
} html_tag_map[] = {
- {"a",html_tag_a},
- {"h1",html_tag_h1},
- {"html",html_tag_html},
- {"img",html_tag_img},
- {"script",html_tag_script},
- {"form",html_tag_form},
- {"input",html_tag_input},
- {"div",html_tag_div},
+ {"a",html_tag_a},
+ {"h1",html_tag_h1},
+ {"html",html_tag_html},
+ {"img",html_tag_img},
+ {"script",html_tag_script},
+ {"form",html_tag_form},
+ {"input",html_tag_input},
+ {"div",html_tag_div},
};
-static const char *
-find_attr(const char **names, const char **values, const char *name)
-{
- while (*names) {
- if (!g_ascii_strcasecmp(*names, name))
- return *values;
- names+=XML_ATTR_DISTANCE;
- values+=XML_ATTR_DISTANCE;
- }
- return NULL;
+static const char *find_attr(const char **names, const char **values, const char *name) {
+ while (*names) {
+ if (!g_ascii_strcasecmp(*names, name))
+ return *values;
+ names+=XML_ATTR_DISTANCE;
+ values+=XML_ATTR_DISTANCE;
+ }
+ return NULL;
}
-static char *
-find_attr_dup(const char **names, const char **values, const char *name)
-{
- return g_strdup(find_attr(names, values, name));
+static char *find_attr_dup(const char **names, const char **values, const char *name) {
+ return g_strdup(find_attr(names, values, name));
}
-void
-gui_internal_html_main_menu(struct gui_priv *this)
-{
- gui_internal_prune_menu(this, NULL);
- gui_internal_html_load_href(this, "#Main Menu", 0);
+void gui_internal_html_main_menu(struct gui_priv *this) {
+ gui_internal_prune_menu(this, NULL);
+ gui_internal_html_load_href(this, "#Main Menu", 0);
}
-static void
-gui_internal_html_command(struct gui_priv *this, struct widget *w, void *data)
-{
- gui_internal_evaluate(this,w->command);
+static void gui_internal_html_command(struct gui_priv *this, struct widget *w, void *data) {
+ gui_internal_evaluate(this,w->command);
}
-static void
-gui_internal_html_submit_set(struct gui_priv *this, struct widget *w, struct form *form)
-{
- GList *l;
- if (w->form == form && w->name) {
- struct attr *attr=attr_new_from_text(w->name, w->text?w->text:"");
- if (attr)
- gui_set_attr(this->self.u.gui, attr);
- attr_free(attr);
- }
- l=w->children;
- while (l) {
- w=l->data;
- gui_internal_html_submit_set(this, w, form);
- l=g_list_next(l);
- }
+static void gui_internal_html_submit_set(struct gui_priv *this, struct widget *w, struct form *form) {
+ GList *l;
+ if (w->form == form && w->name) {
+ struct attr *attr=attr_new_from_text(w->name, w->text?w->text:"");
+ if (attr)
+ gui_set_attr(this->self.u.gui, attr);
+ attr_free(attr);
+ }
+ l=w->children;
+ while (l) {
+ w=l->data;
+ gui_internal_html_submit_set(this, w, form);
+ l=g_list_next(l);
+ }
}
-static void
-gui_internal_html_submit(struct gui_priv *this, struct widget *w, void *data)
-{
- struct widget *menu;
- GList *l;
-
- dbg(lvl_debug,"enter form %p %s\n",w->form,w->form->onsubmit);
- l=g_list_last(this->root.children);
- menu=l->data;
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_highlight_do(this, NULL);
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
- gui_internal_html_submit_set(this, menu, w->form);
- gui_internal_evaluate(this,w->form->onsubmit);
+static void gui_internal_html_submit(struct gui_priv *this, struct widget *w, void *data) {
+ struct widget *menu;
+ GList *l;
+
+ dbg(lvl_debug,"enter form %p %s",w->form,w->form->onsubmit);
+ l=g_list_last(this->root.children);
+ menu=l->data;
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_highlight_do(this, NULL);
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ gui_internal_html_submit_set(this, menu, w->form);
+ gui_internal_evaluate(this,w->form->onsubmit);
}
-void
-gui_internal_html_load_href(struct gui_priv *this, char *href, int replace)
-{
- if (replace)
- gui_internal_prune_menu_count(this, 1, 0);
- if (href && href[0] == '#') {
- dbg(lvl_debug,"href=%s\n",href);
- g_free(this->href);
- this->href=g_strdup(href);
- gui_internal_html_menu(this, this->html_text, href+1);
- }
+void gui_internal_html_load_href(struct gui_priv *this, char *href, int replace) {
+ if (replace)
+ gui_internal_prune_menu_count(this, 1, 0);
+ if (href && href[0] == '#') {
+ dbg(lvl_debug,"href=%s",href);
+ g_free(this->href);
+ this->href=g_strdup(href);
+ gui_internal_html_menu(this, this->html_text, href+1);
+ }
}
-void
-gui_internal_html_href(struct gui_priv *this, struct widget *w, void *data)
-{
- gui_internal_html_load_href(this, w->command, 0);
+void gui_internal_html_href(struct gui_priv *this, struct widget *w, void *data) {
+ gui_internal_html_load_href(this, w->command, 0);
}
struct div_flags_map {
- char *attr;
- char *val;
- enum flags flags;
+ char *attr;
+ char *val;
+ enum flags flags;
} div_flags_map[] = {
- {"gravity","none",gravity_none},
- {"gravity","left",gravity_left},
- {"gravity","xcenter",gravity_xcenter},
- {"gravity","right",gravity_right},
- {"gravity","top",gravity_top},
- {"gravity","ycenter",gravity_ycenter},
- {"gravity","bottom",gravity_bottom},
- {"gravity","left_top",gravity_left_top},
- {"gravity","top_center",gravity_top_center},
- {"gravity","right_top",gravity_right_top},
- {"gravity","left_center",gravity_left_center},
- {"gravity","center",gravity_center},
- {"gravity","right_center",gravity_right_center},
- {"gravity","left_bottom",gravity_left_bottom},
- {"gravity","bottom_center",gravity_bottom_center},
- {"gravity","right_bottom",gravity_right_bottom},
- {"expand","1",flags_expand},
- {"fill","1",flags_fill},
- {"orientation","horizontal",orientation_horizontal},
- {"orientation","vertical",orientation_vertical},
- {"orientation","horizontal_vertical",orientation_horizontal_vertical},
+ {"gravity","none",gravity_none},
+ {"gravity","left",gravity_left},
+ {"gravity","xcenter",gravity_xcenter},
+ {"gravity","right",gravity_right},
+ {"gravity","top",gravity_top},
+ {"gravity","ycenter",gravity_ycenter},
+ {"gravity","bottom",gravity_bottom},
+ {"gravity","left_top",gravity_left_top},
+ {"gravity","top_center",gravity_top_center},
+ {"gravity","right_top",gravity_right_top},
+ {"gravity","left_center",gravity_left_center},
+ {"gravity","center",gravity_center},
+ {"gravity","right_center",gravity_right_center},
+ {"gravity","left_bottom",gravity_left_bottom},
+ {"gravity","bottom_center",gravity_bottom_center},
+ {"gravity","right_bottom",gravity_right_bottom},
+ {"expand","1",flags_expand},
+ {"fill","1",flags_fill},
+ {"orientation","horizontal",orientation_horizontal},
+ {"orientation","vertical",orientation_vertical},
+ {"orientation","horizontal_vertical",orientation_horizontal_vertical},
};
-static enum flags
-div_flag(const char **names, const char **values, char *name)
-{
- int i;
- enum flags ret=0;
- const char *value=find_attr(names, values, name);
- if (!value)
- return ret;
- for (i = 0 ; i < sizeof(div_flags_map)/sizeof(struct div_flags_map); i++) {
- if (!strcmp(div_flags_map[i].attr,name) && !strcmp(div_flags_map[i].val,value))
- ret|=div_flags_map[i].flags;
- }
- return ret;
+static enum flags div_flag(const char **names, const char **values, char *name) {
+ int i;
+ enum flags ret=0;
+ const char *value=find_attr(names, values, name);
+ if (!value)
+ return ret;
+ for (i = 0 ; i < sizeof(div_flags_map)/sizeof(struct div_flags_map); i++) {
+ if (!strcmp(div_flags_map[i].attr,name) && !strcmp(div_flags_map[i].val,value))
+ ret|=div_flags_map[i].flags;
+ }
+ return ret;
}
-static enum flags
-div_flags(const char **names, const char **values)
-{
- enum flags flags;
- flags = div_flag(names, values, "gravity");
- flags |= div_flag(names, values, "orientation");
- flags |= div_flag(names, values, "expand");
- flags |= div_flag(names, values, "fill");
- return flags;
+static enum flags div_flags(const char **names, const char **values) {
+ enum flags flags;
+ flags = div_flag(names, values, "gravity");
+ flags |= div_flag(names, values, "orientation");
+ flags |= div_flag(names, values, "expand");
+ flags |= div_flag(names, values, "fill");
+ return flags;
}
-static struct widget *
-html_image(struct gui_priv *this, const char **names, const char **values)
-{
- const char *src, *size;
- struct graphics_image *img=NULL;
-
- src=find_attr(names, values, "src");
- if (!src)
- return NULL;
- size=find_attr(names, values, "size");
- if (!size) {
- const char *class=find_attr(names, values, "class");
- if (class && !strcasecmp(class,"centry"))
- size="xs";
- else
- size="l";
- }
- if (!strcmp(size,"l"))
- img=image_new_l(this, src);
- else if (!strcmp(size,"s"))
- img=image_new_s(this, src);
- else if (!strcmp(size,"xs"))
- img=image_new_xs(this, src);
- if (!img)
- return NULL;
- return gui_internal_image_new(this, img);
+static struct widget *html_image(struct gui_priv *this, const char **names, const char **values) {
+ const char *src, *size;
+ struct graphics_image *img=NULL;
+
+ src=find_attr(names, values, "src");
+ if (!src)
+ return NULL;
+ size=find_attr(names, values, "size");
+ if (!size) {
+ const char *class=find_attr(names, values, "class");
+ if (class && !strcasecmp(class,"centry"))
+ size="xs";
+ else
+ size="l";
+ }
+ if (!strcmp(size,"l"))
+ img=image_new_l(this, src);
+ else if (!strcmp(size,"s"))
+ img=image_new_s(this, src);
+ else if (!strcmp(size,"xs"))
+ img=image_new_xs(this, src);
+ if (!img)
+ return NULL;
+ return gui_internal_image_new(this, img);
}
-static void
-gui_internal_html_start(xml_context *dummy, const char *tag_name, const char **names, const char **values, void *data, GError **error)
-{
- struct gui_priv *this=data;
- int i;
- enum html_tag tag=html_tag_none;
- struct html *html=&this->html[this->html_depth];
- const char *cond, *type, *font_size;
-
- if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
- return;
- html->skip=0;
- html->command=NULL;
- html->name=NULL;
- html->href=NULL;
- html->refresh_cond=NULL;
- html->w=NULL;
- html->container=NULL;
- html->font_size=0;
- cond=find_attr(names, values, "cond");
-
- if (cond && !this->html_skip) {
- if (!command_evaluate_to_boolean(&this->self, cond, NULL))
- html->skip=1;
- }
-
- for (i=0 ; i < sizeof(html_tag_map)/sizeof(struct html_tag_map); i++) {
- if (!g_ascii_strcasecmp(html_tag_map[i].tag_name, tag_name)) {
- tag=html_tag_map[i].tag;
- break;
- }
- }
- html->tag=tag;
- html->class=find_attr_dup(names, values, "class");
- if (!this->html_skip && !html->skip) {
- switch (tag) {
- case html_tag_a:
- html->name=find_attr_dup(names, values, "name");
- if (html->name) {
- html->skip=this->html_anchor ? strcmp(html->name,this->html_anchor) : 0;
- if (!html->skip)
- this->html_anchor_found=1;
- }
- html->command=find_attr_dup(names, values, "onclick");
- html->href=find_attr_dup(names, values, "href");
- html->refresh_cond=find_attr_dup(names, values, "refresh_cond");
- break;
- case html_tag_img:
- html->command=find_attr_dup(names, values, "onclick");
- html->w=html_image(this, names, values);
- break;
- case html_tag_form:
- this->form=g_new0(struct form, 1);
- this->form->onsubmit=find_attr_dup(names, values, "onsubmit");
- break;
- case html_tag_input:
- type=find_attr_dup(names, values, "type");
- if (!type)
- break;
- if (!strcmp(type,"image")) {
- html->w=html_image(this, names, values);
- if (html->w) {
- html->w->state|=STATE_SENSITIVE;
- html->w->func=gui_internal_html_submit;
- }
- }
- if (!strcmp(type,"text") || !strcmp(type,"password")) {
- const char *value=find_attr(names, values, "value");
- html->w=gui_internal_label_new(this, value);
- html->w->background=this->background;
- html->w->flags |= div_flags(names, values);
- html->w->state|=STATE_EDITABLE;
- if (!this->editable) {
- this->editable=html->w;
- html->w->state|=STATE_EDIT;
- }
- this->keyboard_required=1;
- if (!strcmp(type,"password"))
- html->w->flags2 |= 1;
- }
- if (html->w) {
- html->w->form=this->form;
- html->w->name=find_attr_dup(names, values, "name");
- }
- break;
- case html_tag_div:
- html->w=gui_internal_box_new(this, div_flags(names, values));
- font_size=find_attr(names, values, "font");
- if (font_size)
- html->font_size=atoi(font_size);
- html->container=this->html_container;
- this->html_container=html->w;
- break;
- default:
- break;
- }
- }
- this->html_skip+=html->skip;
- this->html_depth++;
+static void gui_internal_html_start(xml_context *dummy, const char *tag_name, const char **names, const char **values,
+ void *data,
+ GError **error) {
+ struct gui_priv *this=data;
+ int i;
+ enum html_tag tag=html_tag_none;
+ struct html *html=&this->html[this->html_depth];
+ const char *cond, *type, *font_size;
+
+ if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
+ return;
+ html->skip=0;
+ html->command=NULL;
+ html->name=NULL;
+ html->href=NULL;
+ html->refresh_cond=NULL;
+ html->w=NULL;
+ html->container=NULL;
+ html->font_size=0;
+ cond=find_attr(names, values, "cond");
+
+ if (cond && !this->html_skip) {
+ if (!command_evaluate_to_boolean(&this->self, cond, NULL))
+ html->skip=1;
+ }
+
+ for (i=0 ; i < sizeof(html_tag_map)/sizeof(struct html_tag_map); i++) {
+ if (!g_ascii_strcasecmp(html_tag_map[i].tag_name, tag_name)) {
+ tag=html_tag_map[i].tag;
+ break;
+ }
+ }
+ html->tag=tag;
+ html->class=find_attr_dup(names, values, "class");
+ if (!this->html_skip && !html->skip) {
+ switch (tag) {
+ case html_tag_a:
+ html->name=find_attr_dup(names, values, "name");
+ if (html->name) {
+ html->skip=this->html_anchor ? strcmp(html->name,this->html_anchor) : 0;
+ if (!html->skip)
+ this->html_anchor_found=1;
+ }
+ html->command=find_attr_dup(names, values, "onclick");
+ html->href=find_attr_dup(names, values, "href");
+ html->refresh_cond=find_attr_dup(names, values, "refresh_cond");
+ break;
+ case html_tag_img:
+ html->command=find_attr_dup(names, values, "onclick");
+ html->w=html_image(this, names, values);
+ break;
+ case html_tag_form:
+ this->form=g_new0(struct form, 1);
+ this->form->onsubmit=find_attr_dup(names, values, "onsubmit");
+ break;
+ case html_tag_input:
+ type=find_attr_dup(names, values, "type");
+ if (!type)
+ break;
+ if (!strcmp(type,"image")) {
+ html->w=html_image(this, names, values);
+ if (html->w) {
+ html->w->state|=STATE_SENSITIVE;
+ html->w->func=gui_internal_html_submit;
+ }
+ }
+ if (!strcmp(type,"text") || !strcmp(type,"password")) {
+ const char *value=find_attr(names, values, "value");
+ html->w=gui_internal_label_new(this, value);
+ html->w->background=this->background;
+ html->w->flags |= div_flags(names, values);
+ html->w->state|=STATE_EDITABLE;
+ if (!this->editable) {
+ this->editable=html->w;
+ html->w->state|=STATE_EDIT;
+ }
+ this->keyboard_required=1;
+ if (!strcmp(type,"password"))
+ html->w->flags2 |= 1;
+ }
+ if (html->w) {
+ html->w->form=this->form;
+ html->w->name=find_attr_dup(names, values, "name");
+ }
+ break;
+ case html_tag_div:
+ html->w=gui_internal_box_new(this, div_flags(names, values));
+ font_size=find_attr(names, values, "font");
+ if (font_size)
+ html->font_size=atoi(font_size);
+ html->container=this->html_container;
+ this->html_container=html->w;
+ break;
+ default:
+ break;
+ }
+ }
+ this->html_skip+=html->skip;
+ this->html_depth++;
}
-static void
-gui_internal_html_end(xml_context *dummy, const char *tag_name, void *data, GError **error)
-{
- struct gui_priv *this=data;
- struct html *html;
- struct html *parent=NULL;
-
- if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
- return;
- this->html_depth--;
- html=&this->html[this->html_depth];
- if (this->html_depth > 0)
- parent=&this->html[this->html_depth-1];
-
-
- if (!this->html_skip) {
- if (html->command && html->w) {
- html->w->state |= STATE_SENSITIVE;
- html->w->command=html->command;
- html->w->func=gui_internal_html_command;
- html->command=NULL;
- }
- if (parent && (parent->href || parent->command) && html->w) {
- html->w->state |= STATE_SENSITIVE;
- if (parent->command) {
- html->w->command=g_strdup(parent->command);
- html->w->func=gui_internal_html_command;
- } else {
- html->w->command=g_strdup(parent->href);
- html->w->func=gui_internal_html_href;
- }
- }
- switch (html->tag) {
- case html_tag_div:
- this->html_container=html->container;
- case html_tag_img:
- case html_tag_input:
- gui_internal_widget_append(this->html_container, html->w);
- break;
- case html_tag_form:
- this->form=NULL;
- break;
- default:
- break;
- }
- }
- this->html_skip-=html->skip;
- g_free(html->command);
- g_free(html->name);
- g_free(html->href);
- g_free(html->class);
- g_free(html->refresh_cond);
+static void gui_internal_html_end(xml_context *dummy, const char *tag_name, void *data, GError **error) {
+ struct gui_priv *this=data;
+ struct html *html;
+ struct html *parent=NULL;
+
+ if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
+ return;
+ this->html_depth--;
+ html=&this->html[this->html_depth];
+ if (this->html_depth > 0)
+ parent=&this->html[this->html_depth-1];
+
+
+ if (!this->html_skip) {
+ if (html->command && html->w) {
+ html->w->state |= STATE_SENSITIVE;
+ html->w->command=html->command;
+ html->w->func=gui_internal_html_command;
+ html->command=NULL;
+ }
+ if (parent && (parent->href || parent->command) && html->w) {
+ html->w->state |= STATE_SENSITIVE;
+ if (parent->command) {
+ html->w->command=g_strdup(parent->command);
+ html->w->func=gui_internal_html_command;
+ } else {
+ html->w->command=g_strdup(parent->href);
+ html->w->func=gui_internal_html_href;
+ }
+ }
+ switch (html->tag) {
+ case html_tag_div:
+ this->html_container=html->container;
+ case html_tag_img:
+ case html_tag_input:
+ gui_internal_widget_append(this->html_container, html->w);
+ break;
+ case html_tag_form:
+ this->form=NULL;
+ break;
+ default:
+ break;
+ }
+ }
+ this->html_skip-=html->skip;
+ g_free(html->command);
+ g_free(html->name);
+ g_free(html->href);
+ g_free(html->class);
+ g_free(html->refresh_cond);
}
-static void
-gui_internal_refresh_callback_called(struct gui_priv *this, struct menu_data *menu_data)
-{
- if (gui_internal_menu_data(this) == menu_data) {
- char *href=g_strdup(menu_data->href);
- gui_internal_html_load_href(this, href, 1);
- g_free(href);
- }
+static void gui_internal_refresh_callback_called(struct gui_priv *this, struct menu_data *menu_data) {
+ if (gui_internal_menu_data(this) == menu_data) {
+ char *href=g_strdup(menu_data->href);
+ gui_internal_html_load_href(this, href, 1);
+ g_free(href);
+ }
}
-static void
-gui_internal_set_refresh_callback(struct gui_priv *this, char *cond)
-{
- dbg(lvl_info,"cond=%s\n",cond);
- if (cond) {
- enum attr_type type;
- struct object_func *func;
- struct menu_data *menu_data=gui_internal_menu_data(this);
- dbg(lvl_info,"navit=%p\n",this->nav);
- type=command_evaluate_to_attr(&this->self, cond, NULL, &menu_data->refresh_callback_obj);
- if (type == attr_none) {
- dbg(lvl_error,"can't get type of '%s'\n",cond);
- return;
- }
- func=object_func_lookup(menu_data->refresh_callback_obj.type);
- if (!func)
- dbg(lvl_error,"'%s' has no functions\n",cond);
- if (func && !func->add_attr)
- dbg(lvl_error,"'%s' has no add_attr function\n",cond);
- if (!func || !func->add_attr)
- return;
- menu_data->refresh_callback.type=attr_callback;
- menu_data->refresh_callback.u.callback=callback_new_attr_2(callback_cast(gui_internal_refresh_callback_called),type,this,menu_data);
- func->add_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
- }
+static void gui_internal_set_refresh_callback(struct gui_priv *this, char *cond) {
+ dbg(lvl_info,"cond=%s",cond);
+ if (cond) {
+ enum attr_type type;
+ struct object_func *func;
+ struct menu_data *menu_data=gui_internal_menu_data(this);
+ dbg(lvl_info,"navit=%p",this->nav);
+ type=command_evaluate_to_attr(&this->self, cond, NULL, &menu_data->refresh_callback_obj);
+ if (type == attr_none) {
+ dbg(lvl_error,"can't get type of '%s'",cond);
+ return;
+ }
+ func=object_func_lookup(menu_data->refresh_callback_obj.type);
+ if (!func)
+ dbg(lvl_error,"'%s' has no functions",cond);
+ if (func && !func->add_attr)
+ dbg(lvl_error,"'%s' has no add_attr function",cond);
+ if (!func || !func->add_attr)
+ return;
+ menu_data->refresh_callback.type=attr_callback;
+ menu_data->refresh_callback.u.callback=callback_new_attr_2(callback_cast(gui_internal_refresh_callback_called),type,
+ this,menu_data);
+ func->add_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
+ }
}
-static void
-gui_internal_html_text(xml_context *dummy, const char *text, gsize len, void *data, GError **error)
-{
- struct gui_priv *this=data;
- struct widget *w;
- int depth=this->html_depth-1;
- struct html *html=&this->html[depth];
- gchar *text_stripped;
-
- if (this->html_skip)
- return;
- while (isspace(text[0])) {
- text++;
- len--;
- }
- while (len > 0 && isspace(text[len-1]))
- len--;
-
- text_stripped = g_strndup(text, len);
- if (html->tag == html_tag_html && depth > 2) {
- if (this->html[depth-1].tag == html_tag_script) {
- html=&this->html[depth-2];
- }
- }
- switch (html->tag) {
- case html_tag_a:
- if (html->name && len) {
- if (html->class && !strcasecmp(html->class,"clist"))
- this->html_container=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill /* |flags_scrolly */);
- else
- this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
- gui_internal_menu_data(this)->href=g_strdup(this->href);
- gui_internal_set_refresh_callback(this, html->refresh_cond);
- this->html_container->spx=this->spacing*10;
- }
- break;
- case html_tag_h1:
- if (!this->html_container) {
- this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
- this->html_container->spx=this->spacing*10;
- }
- break;
- case html_tag_img:
- if (len) {
- if (html->class && !strcasecmp(html->class, "centry"))
- w=gui_internal_box_new(this, gravity_left_top|orientation_horizontal|flags_fill);
- else
- w=gui_internal_box_new(this, gravity_center|orientation_vertical);
- gui_internal_widget_append(w, html->w);
- gui_internal_widget_append(w, gui_internal_text_new(this, _(text_stripped), gravity_left_top|orientation_vertical|flags_fill));
- html->w=w;
- }
- break;
- case html_tag_div:
- if (len) {
- gui_internal_widget_append(html->w, gui_internal_text_font_new(this, _(text_stripped), html->font_size, gravity_center|orientation_vertical));
- }
- break;
- case html_tag_script:
- dbg(lvl_debug,"execute %s\n",text_stripped);
- gui_internal_evaluate(this,text_stripped);
- break;
- default:
- break;
- }
- g_free(text_stripped);
+static void gui_internal_html_text(xml_context *dummy, const char *text, gsize len, void *data, GError **error) {
+ struct gui_priv *this=data;
+ struct widget *w;
+ int depth=this->html_depth-1;
+ struct html *html=&this->html[depth];
+ gchar *text_stripped;
+
+ if (this->html_skip)
+ return;
+ while (isspace(text[0])) {
+ text++;
+ len--;
+ }
+ while (len > 0 && isspace(text[len-1]))
+ len--;
+
+ text_stripped = g_strndup(text, len);
+ if (html->tag == html_tag_html && depth > 2) {
+ if (this->html[depth-1].tag == html_tag_script) {
+ html=&this->html[depth-2];
+ }
+ }
+ switch (html->tag) {
+ case html_tag_a:
+ if (html->name && len) {
+ if (html->class && !strcasecmp(html->class,"clist"))
+ this->html_container=gui_internal_box_new(this,
+ gravity_left_top|orientation_vertical|flags_expand|flags_fill /* |flags_scrolly */);
+ else
+ this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
+ gui_internal_menu_data(this)->href=g_strdup(this->href);
+ gui_internal_set_refresh_callback(this, html->refresh_cond);
+ this->html_container->spx=this->spacing*10;
+ }
+ break;
+ case html_tag_h1:
+ if (!this->html_container) {
+ this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
+ this->html_container->spx=this->spacing*10;
+ }
+ break;
+ case html_tag_img:
+ if (len) {
+ if (html->class && !strcasecmp(html->class, "centry"))
+ w=gui_internal_box_new(this, gravity_left_top|orientation_horizontal|flags_fill);
+ else
+ w=gui_internal_box_new(this, gravity_center|orientation_vertical);
+ gui_internal_widget_append(w, html->w);
+ gui_internal_widget_append(w, gui_internal_text_new(this, _(text_stripped),
+ gravity_left_top|orientation_vertical|flags_fill));
+ html->w=w;
+ }
+ break;
+ case html_tag_div:
+ if (len) {
+ gui_internal_widget_append(html->w, gui_internal_text_font_new(this, _(text_stripped), html->font_size,
+ gravity_center|orientation_vertical));
+ }
+ break;
+ case html_tag_script:
+ dbg(lvl_debug,"execute %s",text_stripped);
+ gui_internal_evaluate(this,text_stripped);
+ break;
+ default:
+ break;
+ }
+ g_free(text_stripped);
}
-void
-gui_internal_html_parse_text(struct gui_priv *this, char *doc)
-{
- xml_parse_text(doc, this, gui_internal_html_start, gui_internal_html_end, gui_internal_html_text);
+void gui_internal_html_parse_text(struct gui_priv *this, char *doc) {
+ int res;
+
+ res = xml_parse_text(doc, this, gui_internal_html_start, gui_internal_html_end, gui_internal_html_text);
+
+ if (!res) {
+ dbg(lvl_error, "FATAL: Failed to parse XML data (looks like incorrect configuration for internal GUI).\n");
+ exit(1);
+ }
}
-void
-gui_internal_html_menu(struct gui_priv *this, const char *document, char *anchor)
-{
- char *doc=g_strdup(document);
- graphics_draw_mode(this->gra, draw_mode_begin);
- this->html_container=NULL;
- this->html_depth=0;
- this->html_anchor=anchor;
- this->html_anchor_found=0;
- this->form=NULL;
- this->keyboard_required=0;
- this->editable=NULL;
- callback_list_call_attr_2(this->cbl,attr_gui,anchor,&doc);
- gui_internal_html_parse_text(this, doc);
- g_free(doc);
- if (this->keyboard_required) {
- this->html_container->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
- if (this->keyboard)
- gui_internal_widget_append(this->html_container, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, this->html_container, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- }
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
+void gui_internal_html_menu(struct gui_priv *this, const char *document, char *anchor) {
+ char *doc=g_strdup(document);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ this->html_container=NULL;
+ this->html_depth=0;
+ this->html_anchor=anchor;
+ this->html_anchor_found=0;
+ this->form=NULL;
+ this->keyboard_required=0;
+ this->editable=NULL;
+ callback_list_call_attr_2(this->cbl,attr_gui,anchor,&doc);
+ gui_internal_html_parse_text(this, doc);
+ g_free(doc);
+ if (this->keyboard_required) {
+ this->html_container->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
+ if (this->keyboard)
+ gui_internal_widget_append(this->html_container, gui_internal_keyboard(this,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
+ else
+ gui_internal_keyboard_show_native(this, this->html_container,
+ VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
+ }
+ gui_internal_menu_render(this);
+ graphics_draw_mode(this->gra, draw_mode_end);
}
diff --git a/navit/gui/internal/gui_internal_keyboard.c b/navit/gui/internal/gui_internal_keyboard.c
index 7ef1c3d36..19e48c468 100644
--- a/navit/gui/internal/gui_internal_keyboard.c
+++ b/navit/gui/internal/gui_internal_keyboard.c
@@ -19,22 +19,22 @@
*
* @param this The internal GUI instance
*/
-void
-gui_internal_keyboard_to_upper_case(struct gui_priv *this)
-{
- struct menu_data *md;
-
- if (!this->keyboard)
- return;
-
- md=gui_internal_menu_data(this);
-
- if (md->keyboard_mode == (VKBD_LATIN_LOWER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_UPPER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_UMLAUT_LOWER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_UPPER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_CYRILLIC_LOWER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_UPPER | VKBD_FLAG_2);
+void gui_internal_keyboard_to_upper_case(struct gui_priv *this) {
+ struct menu_data *md;
+
+ if (!this->keyboard)
+ return;
+
+ md=gui_internal_menu_data(this);
+
+ if (md->keyboard_mode == (VKBD_LATIN_LOWER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_UPPER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_UMLAUT_LOWER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_UPPER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_CYRILLIC_LOWER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_UPPER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_GREEK_LOWER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_GREEK_UPPER | VKBD_FLAG_2);
}
/**
@@ -44,22 +44,22 @@ gui_internal_keyboard_to_upper_case(struct gui_priv *this)
*
* @param this The internal GUI instance
*/
-void
-gui_internal_keyboard_to_lower_case(struct gui_priv *this)
-{
- struct menu_data *md;
-
- if (!this->keyboard)
- return;
-
- md=gui_internal_menu_data(this);
-
- if (md->keyboard_mode == (VKBD_LATIN_UPPER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_LOWER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_UMLAUT_UPPER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_LOWER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_CYRILLIC_UPPER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_LOWER | VKBD_FLAG_2);
+void gui_internal_keyboard_to_lower_case(struct gui_priv *this) {
+ struct menu_data *md;
+
+ if (!this->keyboard)
+ return;
+
+ md=gui_internal_menu_data(this);
+
+ if (md->keyboard_mode == (VKBD_LATIN_UPPER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_LOWER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_UMLAUT_UPPER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_LOWER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_CYRILLIC_UPPER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_LOWER | VKBD_FLAG_2);
+ if (md->keyboard_mode == (VKBD_GREEK_UPPER | VKBD_FLAG_2))
+ gui_internal_keyboard_do(this, md->keyboard, VKBD_GREEK_LOWER | VKBD_FLAG_2);
}
/**
@@ -72,33 +72,30 @@ gui_internal_keyboard_to_lower_case(struct gui_priv *this)
* @param wm
* @param data Not used
*/
-static void
-gui_internal_cmd_keypress(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_keypress_do(this, (char *) wm->data);
+static void gui_internal_cmd_keypress(struct gui_priv *this, struct widget *wm, void *data) {
+ gui_internal_keypress_do(this, (char *) wm->data);
}
-
-static struct widget *
-gui_internal_keyboard_key_data(struct gui_priv *this, struct widget *wkbd, char *text, int font, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data, void (*data_free)(void *data), int w, int h)
-{
- struct widget *wk;
- gui_internal_widget_append(wkbd, wk=gui_internal_button_font_new_with_callback(this, text, font,
- NULL, gravity_center|orientation_vertical, func, data));
- wk->data_free=data_free;
- wk->background=this->background;
- wk->bl=0;
- wk->br=0;
- wk->bt=0;
- wk->bb=0;
- wk->w=w;
- wk->h=h;
- return wk;
+
+static struct widget *gui_internal_keyboard_key_data(struct gui_priv *this, struct widget *wkbd, char *text, int font,
+ void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data, void (*data_free)(void *data), int w,
+ int h) {
+ struct widget *wk;
+ gui_internal_widget_append(wkbd, wk=gui_internal_button_font_new_with_callback(this, text, font,
+ NULL, gravity_center|orientation_vertical, func, data));
+ wk->data_free=data_free;
+ wk->background=this->background;
+ wk->bl=0;
+ wk->br=0;
+ wk->bt=0;
+ wk->bb=0;
+ wk->w=w;
+ wk->h=h;
+ return wk;
}
-static struct widget *
-gui_internal_keyboard_key(struct gui_priv *this, struct widget *wkbd, char *text, char *key, int w, int h)
-{
- return gui_internal_keyboard_key_data(this, wkbd, text, 0, gui_internal_cmd_keypress, g_strdup(key), g_free_func,w,h);
+static struct widget *gui_internal_keyboard_key(struct gui_priv *this, struct widget *wkbd, char *text, char *key,
+ int w, int h) {
+ return gui_internal_keyboard_key_data(this, wkbd, text, 0, gui_internal_cmd_keypress, g_strdup(key), g_free_func,w,h);
}
static void gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data);
@@ -118,14 +115,16 @@ struct gui_internal_keyb_mode {
int case_mode; /**< Mode to switch to when case CHANGE() key is pressed. */
int umlaut_mode; /**< Mode to switch to when UMLAUT() key is pressed. */
} gui_internal_keyb_modes[]= {
- /* 0: VKBD_LATIN_UPPER */ {"ABC", 2, VKBD_LATIN_LOWER, VKBD_UMLAUT_UPPER},
- /* 8: VKBD_LATIN_LOWER */ {"abc", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_LOWER},
- /*16: VKBD_NUMERIC */ {"123", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_UPPER},
- /*24: VKBD_UMLAUT_UPPER */ {"ÄÖÜ", 2, VKBD_UMLAUT_LOWER, VKBD_LATIN_UPPER},
- /*32: VKBD_UMLAUT_LOWER */ {"äöü", 2, VKBD_UMLAUT_UPPER, VKBD_LATIN_LOWER},
- /*40: VKBD_CYRILLIC_UPPER*/ {"АБВ", 2, VKBD_CYRILLIC_LOWER, VKBD_LATIN_UPPER},
- /*48: VKBD_CYRILLIC_LOWER*/ {"абв", 2, VKBD_CYRILLIC_UPPER, VKBD_LATIN_LOWER},
- /*56: VKBD_DEGREE */ {"DEG", 2, VKBD_FLAG_2, VKBD_FLAG_2}
+ /* 0: VKBD_LATIN_UPPER */ {"ABC", 2, VKBD_LATIN_LOWER, VKBD_UMLAUT_UPPER},
+ /* 8: VKBD_LATIN_LOWER */ {"abc", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_LOWER},
+ /*16: VKBD_NUMERIC */ {"123", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_UPPER},
+ /*24: VKBD_UMLAUT_UPPER */ {"ÄÖÜ", 2, VKBD_UMLAUT_LOWER, VKBD_LATIN_UPPER},
+ /*32: VKBD_UMLAUT_LOWER */ {"äöü", 2, VKBD_UMLAUT_UPPER, VKBD_LATIN_LOWER},
+ /*40: VKBD_CYRILLIC_UPPER*/ {"АБВ", 2, VKBD_CYRILLIC_LOWER, VKBD_LATIN_UPPER},
+ /*48: VKBD_CYRILLIC_LOWER*/ {"абв", 2, VKBD_CYRILLIC_UPPER, VKBD_LATIN_LOWER},
+ /*56: VKBD_DEGREE */ {"DEG", 2, VKBD_FLAG_2, VKBD_FLAG_2},
+ /*64: VKBD_GREEK_UPPER */ {"ABΓ", 2, VKBD_GREEK_LOWER, VKBD_LATIN_UPPER},
+ /*72: VKBD_GREEK_LOWER */ {"abγ", 2, VKBD_GREEK_UPPER, VKBD_LATIN_LOWER}
};
@@ -140,6 +139,17 @@ struct gui_internal_keyb_mode {
-> datai = (mode & VKBD_MASK_7) | ((x) & VKBD_LAYOUT_MASK)
#define SWCASE() MODE(gui_internal_keyb_modes[mode/8].case_mode)
#define UMLAUT() MODE(gui_internal_keyb_modes[mode/8].umlaut_mode)
+
+
+static void gui_internal_keyboard_topbox_resize(struct gui_priv *this, struct widget *w, void *data,
+ int neww, int newh) {
+ struct menu_data *md=gui_internal_menu_data(this);
+ struct widget *old_wkbdb = md->keyboard;
+
+ dbg(lvl_debug, "resize called for keyboard widget %p with w=%d, h=%d", w, neww, newh);
+ gui_internal_keyboard_do(this, old_wkbdb, md->keyboard_mode);
+}
+
/**
* @brief Creates a new keyboard widget or switches the layout of an existing widget
*
@@ -155,231 +165,493 @@ struct gui_internal_keyb_mode {
* @return {@code wkbdb} if a non-NULL value was passed, else a new keyboard widget will be returned.
*/
struct widget *
-gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
-{
- struct widget *wkbd,*wk;
- struct menu_data *md=gui_internal_menu_data(this);
- int i, max_w=this->root.w, max_h=this->root.h;
- int render=0;
- char *space="_";
- char *backspace="←";
- char *hide="▼";
- char *unhide="▲";
-
- if (wkbdb) {
- this->current.x=-1;
- this->current.y=-1;
- gui_internal_highlight(this);
- if (md->keyboard_mode & VKBD_FLAG_1024)
- render=2;
- else
- render=1;
- gui_internal_widget_children_destroy(this, wkbdb);
- } else
- wkbdb=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
- md->keyboard=wkbdb;
- md->keyboard_mode=mode;
- wkbd=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
- wkbd->background=this->background;
- wkbd->cols=8;
- wkbd->spx=0;
- wkbd->spy=0;
- max_w=max_w/8;
- max_h=max_h/8; // Allows 3 results in the list when searching for Towns
- wkbd->p.y=max_h*2;
- if (((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) || ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER)) { // Russian/Ukrainian/Belarussian layout needs more space...
- max_h=max_h*4/5;
- max_w=max_w*8/9;
- wkbd->cols=9;
- }
-
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_UPPER) {
- for (i = 0 ; i < 26 ; i++) {
- char text[]={'A'+i,'\0'};
- KEY(text);
- }
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
- if (!(mode & VKBD_MASK_7)) {
- KEY("-");
- KEY("'");
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- } else {
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- SWCASE();
- MODE(VKBD_NUMERIC);
-
- }
- UMLAUT();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_LOWER) {
- for (i = 0 ; i < 26 ; i++) {
- char text[]={'a'+i,'\0'};
- KEY(text);
- }
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
- if (!(mode & VKBD_MASK_7)) {
- KEY("-");
- KEY("'");
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- } else {
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- SWCASE();
-
- MODE(VKBD_NUMERIC);
- }
- UMLAUT();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_NUMERIC) {
- for (i = 0 ; i < 10 ; i++) {
- char text[]={'0'+i,'\0'};
- KEY(text);
- }
- /* ("8") ("9")*/KEY("."); KEY("°"); KEY("'"); KEY("\"");KEY("-"); KEY("+");
- KEY("*"); KEY("/"); KEY("("); KEY(")"); KEY("="); KEY("?"); KEY(":"); SPACER();
-
-
-
- if (!(mode & VKBD_MASK_7)) {
- SPACER();
- KEY("-");
- KEY("'");
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- SPACER();
- SPACER();
- } else {
- SPACER();
- MODE(VKBD_CYRILLIC_UPPER);
- MODE(VKBD_CYRILLIC_LOWER);
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- MODE(VKBD_LATIN_UPPER);
- MODE(VKBD_LATIN_LOWER);
- }
- UMLAUT();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_UPPER) {
- KEY("Ä"); KEY("Ë"); KEY("Ï"); KEY("Ö"); KEY("Ü"); KEY("Æ"); KEY("Ø"); KEY("Å");
- KEY("Á"); KEY("É"); KEY("Í"); KEY("Ó"); KEY("Ú"); KEY("Š"); KEY("Č"); KEY("Ž");
- KEY("À"); KEY("È"); KEY("Ì"); KEY("Ò"); KEY("Ù"); KEY("Ś"); KEY("Ć"); KEY("Ź");
- KEY("Â"); KEY("Ê"); KEY("Î"); KEY("Ô"); KEY("Û"); SPACER();
-
- UMLAUT();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_LOWER) {
- KEY("ä"); KEY("ë"); KEY("ï"); KEY("ö"); KEY("ü"); KEY("æ"); KEY("ø"); KEY("å");
- KEY("á"); KEY("é"); KEY("í"); KEY("ó"); KEY("ú"); KEY("š"); KEY("č"); KEY("ž");
- KEY("à"); KEY("è"); KEY("ì"); KEY("ò"); KEY("ù"); KEY("ś"); KEY("ć"); KEY("ź");
- KEY("â"); KEY("ê"); KEY("î"); KEY("ô"); KEY("û"); KEY("ß");
-
- UMLAUT();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) {
- KEY("А"); KEY("Б"); KEY("В"); KEY("Г"); KEY("Д"); KEY("Е"); KEY("Ж"); KEY("З"); KEY("И");
- KEY("Й"); KEY("К"); KEY("Л"); KEY("М"); KEY("Н"); KEY("О"); KEY("П"); KEY("Р"); KEY("С");
- KEY("Т"); KEY("У"); KEY("Ф"); KEY("Х"); KEY("Ц"); KEY("Ч"); KEY("Ш"); KEY("Щ"); KEY("Ъ");
- KEY("Ы"); KEY("Ь"); KEY("Э"); KEY("Ю"); KEY("Я"); KEY("Ё"); KEY("І"); KEY("Ї"); KEY("Ў");
- SPACER(); SPACER(); SPACER();
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
-
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
-
- SWCASE();
-
- MODE(VKBD_NUMERIC);
-
- SPACER();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER) {
- KEY("а"); KEY("б"); KEY("в"); KEY("г"); KEY("д"); KEY("е"); KEY("ж"); KEY("з"); KEY("и");
- KEY("й"); KEY("к"); KEY("л"); KEY("м"); KEY("н"); KEY("о"); KEY("п"); KEY("р"); KEY("с");
- KEY("т"); KEY("у"); KEY("ф"); KEY("х"); KEY("ц"); KEY("ч"); KEY("ш"); KEY("щ"); KEY("ъ");
- KEY("ы"); KEY("ь"); KEY("э"); KEY("ю"); KEY("я"); KEY("ё"); KEY("і"); KEY("ї"); KEY("ў");
- SPACER(); SPACER(); SPACER();
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
-
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
-
- SWCASE();
-
- MODE(VKBD_NUMERIC);
-
- SPACER();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
-
-
- if(md->search_list && md->search_list->type==widget_table) {
- struct table_data *td=(struct table_data*)(md->search_list->data);
- td->scroll_buttons.button_box_hide = !(mode & VKBD_FLAG_1024);
- }
-
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_DEGREE) { /* special case for coordinates input screen (enter_coord) */
- KEY("0"); KEY("1"); KEY("2"); KEY("3"); KEY("4"); SPACER(); KEY("N"); KEY("S");
- KEY("5"); KEY("6"); KEY("7"); KEY("8"); KEY("9"); SPACER(); KEY("E"); KEY("W");
- KEY("°"); KEY("."); KEY("'");
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
- SPACER();
-
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
-
- SPACER();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
-
- if (mode & VKBD_FLAG_1024) {
- char *text=NULL;
- int font=0;
- struct widget *wkl;
- mode &= ~VKBD_FLAG_1024;
- text=gui_internal_keyb_modes[mode/8].title;
- font=gui_internal_keyb_modes[mode/8].font;
- wk=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_fill);
- wk->func=gui_internal_keyboard_change;
- wk->data=wkbdb;
- wk->background=this->background;
- wk->bl=0;
- wk->br=0;
- wk->bt=0;
- wk->bb=0;
- wk->w=max_w;
- wk->h=max_h;
- wk->datai=mode;
- wk->state |= STATE_SENSITIVE;
- gui_internal_widget_append(wk, wkl=gui_internal_label_new(this, unhide));
- wkl->background=NULL;
- gui_internal_widget_append(wk, wkl=gui_internal_label_font_new(this, text, font));
- wkl->background=NULL;
- gui_internal_widget_append(wkbd, wk);
- if (render)
- render=2;
- }
- gui_internal_widget_append(wkbdb, wkbd);
- if (render == 1) {
- gui_internal_widget_pack(this, wkbdb);
- gui_internal_widget_render(this, wkbdb);
- } else if (render == 2) {
- gui_internal_menu_reset_pack(this);
- gui_internal_menu_render(this);
- }
- return wkbdb;
+gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode) {
+ struct widget *wkbd,*wk;
+ struct menu_data *md=gui_internal_menu_data(this);
+ int i, max_w=this->root.w, max_h=this->root.h;
+ int render=0;
+ char *space="_";
+ char *backspace="←";
+ char *hide="▼";
+ char *unhide="▲";
+
+ if (wkbdb) {
+ this->current.x=-1;
+ this->current.y=-1;
+ gui_internal_highlight(this);
+ if (md->keyboard_mode & VKBD_FLAG_1024)
+ render=2;
+ else
+ render=1;
+ gui_internal_widget_children_destroy(this, wkbdb);
+ gui_internal_widget_reset_pack(this, wkbdb);
+ gui_internal_widget_pack(this, wkbdb);
+ } else
+ wkbdb=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
+ md->keyboard=wkbdb;
+ md->keyboard_mode=mode;
+ wkbd=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
+ wkbd->background=this->background;
+ wkbd->cols=8;
+ wkbd->spx=0;
+ wkbd->spy=0;
+ wkbd->on_resize=gui_internal_keyboard_topbox_resize;
+ max_w=max_w/8;
+ max_h=max_h/8; // Allows 3 results in the list when searching for Towns
+ wkbd->p.y=max_h*2;
+ if (((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER)
+ || ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER)
+ || ((mode & VKBD_LAYOUT_MASK) == VKBD_GREEK_UPPER)
+ || ((mode & VKBD_LAYOUT_MASK) == VKBD_GREEK_LOWER)) { // Russian/Ukrainian/Belarussian/Greek layout needs more space...
+ max_h=max_h*4/5;
+ max_w=max_w*8/9;
+ wkbd->cols=9;
+ }
+
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_UPPER) {
+ for (i = 0 ; i < 26 ; i++) {
+ char text[]= {'A'+i,'\0'};
+ KEY(text);
+ }
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+ if (!(mode & VKBD_MASK_7)) {
+ KEY("-");
+ KEY("'");
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ } else {
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ SWCASE();
+ MODE(VKBD_NUMERIC);
+
+ }
+ UMLAUT();
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_LOWER) {
+ for (i = 0 ; i < 26 ; i++) {
+ char text[]= {'a'+i,'\0'};
+ KEY(text);
+ }
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+ if (!(mode & VKBD_MASK_7)) {
+ KEY("-");
+ KEY("'");
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ } else {
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+ }
+ UMLAUT();
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_NUMERIC) {
+ for (i = 0 ; i < 10 ; i++) {
+ char text[]= {'0'+i,'\0'};
+ KEY(text);
+ }
+ /* ("8") ("9")*/KEY(".");
+ KEY("°");
+ KEY("'");
+ KEY("\"");
+ KEY("-");
+ KEY("+");
+ KEY("*");
+ KEY("/");
+ KEY("(");
+ KEY(")");
+ KEY("=");
+ KEY("?");
+ KEY(":");
+ KEY("_");
+
+
+
+ if (!(mode & VKBD_MASK_7)) {
+ MODE(VKBD_GREEK_UPPER);
+ KEY("-");
+ KEY("'");
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ SPACER();
+ SPACER();
+ } else {
+ if (mode == VKBD_GREEK_UPPER)
+ MODE(VKBD_GREEK_LOWER);
+ else
+ MODE(VKBD_GREEK_UPPER);
+ MODE(VKBD_CYRILLIC_UPPER);
+ MODE(VKBD_CYRILLIC_LOWER);
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+ MODE(VKBD_LATIN_UPPER);
+ MODE(VKBD_LATIN_LOWER);
+ }
+ UMLAUT();
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_UPPER) {
+ KEY("Ä");
+ KEY("Ë");
+ KEY("Ï");
+ KEY("Ö");
+ KEY("Ü");
+ KEY("Æ");
+ KEY("Ø");
+ KEY("Å");
+ KEY("Á");
+ KEY("É");
+ KEY("Í");
+ KEY("Ó");
+ KEY("Ú");
+ KEY("Š");
+ KEY("Č");
+ KEY("Ž");
+ KEY("À");
+ KEY("È");
+ KEY("Ì");
+ KEY("Ò");
+ KEY("Ù");
+ KEY("Ś");
+ KEY("Ć");
+ KEY("Ź");
+ KEY("Â");
+ KEY("Ê");
+ KEY("Î");
+ KEY("Ô");
+ KEY("Û");
+ SPACER();
+
+ UMLAUT();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_LOWER) {
+ KEY("ä");
+ KEY("ë");
+ KEY("ï");
+ KEY("ö");
+ KEY("ü");
+ KEY("æ");
+ KEY("ø");
+ KEY("å");
+ KEY("á");
+ KEY("é");
+ KEY("í");
+ KEY("ó");
+ KEY("ú");
+ KEY("š");
+ KEY("č");
+ KEY("ž");
+ KEY("à");
+ KEY("è");
+ KEY("ì");
+ KEY("ò");
+ KEY("ù");
+ KEY("ś");
+ KEY("ć");
+ KEY("ź");
+ KEY("â");
+ KEY("ê");
+ KEY("î");
+ KEY("ô");
+ KEY("û");
+ KEY("ß");
+
+ UMLAUT();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) {
+ KEY("А");
+ KEY("Б");
+ KEY("В");
+ KEY("Г");
+ KEY("Д");
+ KEY("Е");
+ KEY("Ж");
+ KEY("З");
+ KEY("И");
+ KEY("Й");
+ KEY("К");
+ KEY("Л");
+ KEY("М");
+ KEY("Н");
+ KEY("О");
+ KEY("П");
+ KEY("Р");
+ KEY("С");
+ KEY("Т");
+ KEY("У");
+ KEY("Ф");
+ KEY("Х");
+ KEY("Ц");
+ KEY("Ч");
+ KEY("Ш");
+ KEY("Щ");
+ KEY("Ъ");
+ KEY("Ы");
+ KEY("Ь");
+ KEY("Э");
+ KEY("Ю");
+ KEY("Я");
+ KEY("Ё");
+ KEY("І");
+ KEY("Ї");
+ KEY("Ў");
+ SPACER();
+ SPACER();
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+
+ SPACER();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER) {
+ KEY("а");
+ KEY("б");
+ KEY("в");
+ KEY("г");
+ KEY("д");
+ KEY("е");
+ KEY("ж");
+ KEY("з");
+ KEY("и");
+ KEY("й");
+ KEY("к");
+ KEY("л");
+ KEY("м");
+ KEY("н");
+ KEY("о");
+ KEY("п");
+ KEY("р");
+ KEY("с");
+ KEY("т");
+ KEY("у");
+ KEY("ф");
+ KEY("х");
+ KEY("ц");
+ KEY("ч");
+ KEY("ш");
+ KEY("щ");
+ KEY("ъ");
+ KEY("ы");
+ KEY("ь");
+ KEY("э");
+ KEY("ю");
+ KEY("я");
+ KEY("ё");
+ KEY("і");
+ KEY("ї");
+ KEY("ў");
+ SPACER();
+ SPACER();
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+
+ SPACER();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_GREEK_UPPER) {
+ KEY("Α");
+ KEY("Β");
+ KEY("Γ");
+ KEY("Δ");
+ KEY("Ε");
+ KEY("Ζ");
+ KEY("Η");
+ KEY("Θ");
+ KEY("Ι");
+ KEY("Κ");
+ KEY("Λ");
+ KEY("Μ");
+ KEY("Ν");
+ KEY("Ξ");
+ KEY("Ο");
+ KEY("Π");
+ KEY("Ρ");
+ KEY("Σ");
+ KEY("Τ");
+ KEY("Υ");
+ KEY("Φ");
+ KEY("Χ");
+ KEY("Ψ");
+ KEY("Ω");
+ KEY("Ή");
+ KEY("Ά");
+ KEY("Ό");
+ KEY("Ί");
+ KEY("Ώ");
+ KEY("Έ");
+ KEY("Ύ");
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+
+ SPACER();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_GREEK_LOWER) {
+ KEY("α");
+ KEY("β");
+ KEY("γ");
+ KEY("δ");
+ KEY("ε");
+ KEY("ζ");
+ KEY("η");
+ KEY("θ");
+ KEY("ι");
+ KEY("κ");
+ KEY("λ");
+ KEY("μ");
+ KEY("ν");
+ KEY("ξ");
+ KEY("ο");
+ KEY("π");
+ KEY("ρ");
+ KEY("σ");
+ KEY("τ");
+ KEY("υ");
+ KEY("φ");
+ KEY("χ");
+ KEY("ψ");
+ KEY("ω");
+ KEY("ή");
+ KEY("ά");
+ KEY("ό");
+ KEY("ί");
+ KEY("ώ");
+ KEY("έ");
+ KEY("ύ");
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SWCASE();
+
+ MODE(VKBD_NUMERIC);
+
+ SPACER();
+
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+
+
+ if(md->search_list && md->search_list->type==widget_table) {
+ struct table_data *td=(struct table_data*)(md->search_list->data);
+ td->scroll_buttons.button_box_hide = !(mode & VKBD_FLAG_1024);
+ }
+
+ if ((mode & VKBD_LAYOUT_MASK) == VKBD_DEGREE) { /* special case for coordinates input screen (enter_coord) */
+ KEY("0");
+ KEY("1");
+ KEY("2");
+ KEY("3");
+ KEY("4");
+ SPACER();
+ KEY("N");
+ KEY("S");
+ KEY("5");
+ KEY("6");
+ KEY("7");
+ KEY("8");
+ KEY("9");
+ SPACER();
+ KEY("E");
+ KEY("W");
+ KEY("°");
+ KEY(".");
+ KEY("'");
+ gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
+ SPACER();
+
+ wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
+ wk->datai = mode | VKBD_FLAG_1024;
+
+ SPACER();
+ gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
+ }
+
+ if (mode & VKBD_FLAG_1024) {
+ char *text=NULL;
+ int font=0;
+ struct widget *wkl;
+ mode &= ~VKBD_FLAG_1024;
+ text=gui_internal_keyb_modes[mode/8].title;
+ font=gui_internal_keyb_modes[mode/8].font;
+ wk=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_fill);
+ wk->func=gui_internal_keyboard_change;
+ wk->data=wkbdb;
+ wk->background=this->background;
+ wk->bl=0;
+ wk->br=0;
+ wk->bt=0;
+ wk->bb=0;
+ wk->w=max_w;
+ wk->h=max_h;
+ wk->datai=mode;
+ wk->state |= STATE_SENSITIVE;
+ gui_internal_widget_append(wk, wkl=gui_internal_label_new(this, unhide));
+ wkl->background=NULL;
+ gui_internal_widget_append(wk, wkl=gui_internal_label_font_new(this, text, font));
+ wkl->background=NULL;
+ gui_internal_widget_append(wkbd, wk);
+ if (render)
+ render=2;
+ }
+ gui_internal_widget_append(wkbdb, wkbd);
+ if (render == 1) {
+ gui_internal_widget_pack(this, wkbdb);
+ gui_internal_widget_render(this, wkbdb);
+ } else if (render == 2) {
+ gui_internal_menu_reset_pack(this);
+ gui_internal_menu_render(this);
+ }
+ return wkbdb;
}
#undef KEY
#undef SPACER
@@ -401,17 +673,14 @@ gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
* @return A new keyboard widget
*/
struct widget *
-gui_internal_keyboard(struct gui_priv *this, int mode)
-{
- if (! this->keyboard)
- return NULL;
- return gui_internal_keyboard_do(this, NULL, mode);
+gui_internal_keyboard(struct gui_priv *this, int mode) {
+ if (! this->keyboard)
+ return NULL;
+ return gui_internal_keyboard_do(this, NULL, mode);
}
-static void
-gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data)
-{
- gui_internal_keyboard_do(this, key->data, key->datai);
+static void gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data) {
+ gui_internal_keyboard_do(this, key->data, key->datai);
}
/**
@@ -425,41 +694,41 @@ gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *da
* @return {@code VKBD_CYRILLIC_UPPER} for countries using the Cyrillic alphabet,
* {@code VKBD_LATIN_UPPER} otherwise
*/
-int
-gui_internal_keyboard_init_mode(char *lang)
-{
- int ret=0;
- /* do not crash if lang is NULL, which may be returned by getenv*/
- if(lang == NULL)
- return VKBD_LATIN_UPPER;
-
- /* Converting to upper case here is required for Android */
- lang=g_ascii_strup(lang,-1);
- /*
- * Set cyrillic keyboard for countries using Cyrillic alphabet
- */
- if (strstr(lang,"RU"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"UA"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"BY"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"RS"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"BG"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"MK"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"KZ"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"KG"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"TJ"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"MN"))
- ret = VKBD_CYRILLIC_UPPER;
- g_free(lang);
- return ret;
+int gui_internal_keyboard_init_mode(char *lang) {
+ int ret=0;
+ /* do not crash if lang is NULL, which may be returned by getenv*/
+ if(lang == NULL)
+ return VKBD_LATIN_UPPER;
+
+ /* Converting to upper case here is required for Android */
+ lang=g_ascii_strup(lang,-1);
+ /*
+ * Set cyrillic keyboard for countries using Cyrillic alphabet
+ */
+ if (strstr(lang,"RU"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"UA"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"BY"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"RS"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"BG"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"MK"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"KZ"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"KG"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"TJ"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"MN"))
+ ret = VKBD_CYRILLIC_UPPER;
+ else if (strstr(lang,"GR"))
+ ret = VKBD_GREEK_UPPER;
+ g_free(lang);
+ return ret;
}
@@ -481,15 +750,15 @@ gui_internal_keyboard_init_mode(char *lang)
* @param w The placeholder widget
*/
static void gui_internal_keyboard_hide_native(struct gui_priv *this_, struct widget *w) {
- struct graphics_keyboard *kbd = (struct graphics_keyboard *) w->data;
-
- if (kbd) {
- graphics_hide_native_keyboard(this_->gra, kbd);
- g_free(kbd->lang);
- g_free(kbd->gui_priv);
- } else
- dbg(lvl_warning, "no graphics_keyboard found, cleanup failed\n");
- g_free(w);
+ struct graphics_keyboard *kbd = (struct graphics_keyboard *) w->data;
+
+ if (kbd) {
+ graphics_hide_native_keyboard(this_->gra, kbd);
+ g_free(kbd->lang);
+ g_free(kbd->gui_priv);
+ } else
+ dbg(lvl_warning, "no graphics_keyboard found, cleanup failed");
+ g_free(w);
}
@@ -519,42 +788,42 @@ static void gui_internal_keyboard_hide_native(struct gui_priv *this_, struct wid
* @return The placeholder widget for the on-screen keyboard, may be {@code NULL}
*/
struct widget * gui_internal_keyboard_show_native(struct gui_priv *this, struct widget *w, int mode, char *lang) {
- struct widget *ret = NULL;
- struct menu_data *md = gui_internal_menu_data(this);
- struct graphics_keyboard *kbd = g_new0(struct graphics_keyboard, 1);
- int res;
-
- kbd->mode = mode;
- if (lang)
- kbd->lang = g_strdup(lang);
- res = graphics_show_native_keyboard(this->gra, kbd);
-
- switch(res) {
- case -1:
- dbg(lvl_error, "graphics has no show_native_keyboard method, cannot display keyboard\n");
- /* no break */
- case 0:
- g_free(kbd);
- return NULL;
- }
-
- ret = gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
- md->keyboard = ret;
- md->keyboard_mode=mode;
- ret->wfree = gui_internal_keyboard_hide_native;
- if (kbd->h < 0) {
- ret->h = w->h;
- ret->hmin = w->hmin;
- } else
- ret->h = kbd->h;
- if (kbd->w < 0) {
- ret->w = w->w;
- ret->wmin = w->wmin;
- } else
- ret->w = kbd->w;
- dbg(lvl_error, "ret->w=%d, ret->h=%d\n", ret->w, ret->h);
- ret->data = (void *) kbd;
- gui_internal_widget_append(w, ret);
- dbg(lvl_error, "return\n");
- return ret;
+ struct widget *ret = NULL;
+ struct menu_data *md = gui_internal_menu_data(this);
+ struct graphics_keyboard *kbd = g_new0(struct graphics_keyboard, 1);
+ int res;
+
+ kbd->mode = mode;
+ if (lang)
+ kbd->lang = g_strdup(lang);
+ res = graphics_show_native_keyboard(this->gra, kbd);
+
+ switch(res) {
+ case -1:
+ dbg(lvl_error, "graphics has no show_native_keyboard method, cannot display keyboard");
+ /* no break */
+ case 0:
+ g_free(kbd);
+ return NULL;
+ }
+
+ ret = gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
+ md->keyboard = ret;
+ md->keyboard_mode=mode;
+ ret->wfree = gui_internal_keyboard_hide_native;
+ if (kbd->h < 0) {
+ ret->h = w->h;
+ ret->hmin = w->hmin;
+ } else
+ ret->h = kbd->h;
+ if (kbd->w < 0) {
+ ret->w = w->w;
+ ret->wmin = w->wmin;
+ } else
+ ret->w = kbd->w;
+ dbg(lvl_error, "ret->w=%d, ret->h=%d", ret->w, ret->h);
+ ret->data = (void *) kbd;
+ gui_internal_widget_append(w, ret);
+ dbg(lvl_error, "return");
+ return ret;
}
diff --git a/navit/gui/internal/gui_internal_keyboard.h b/navit/gui/internal/gui_internal_keyboard.h
index 9b9039224..945d2c5cb 100644
--- a/navit/gui/internal/gui_internal_keyboard.h
+++ b/navit/gui/internal/gui_internal_keyboard.h
@@ -2,21 +2,23 @@
* Modes for the on-screen keyboard
*/
enum vkbd_mode {
- /* layouts */
- VKBD_LATIN_UPPER = 0, /*!< Latin uppercase characters */
- VKBD_LATIN_LOWER = 8, /*!< Latin lowercase characters */
- VKBD_NUMERIC = 16, /*!< Numeric keyboard */
- VKBD_UMLAUT_UPPER = 24, /*!< Extended Latin uppercase characters */
- VKBD_UMLAUT_LOWER = 32, /*!< Extended Latin lowercase characters */
- VKBD_CYRILLIC_UPPER = 40, /*!< Cyrillic uppercase characters */
- VKBD_CYRILLIC_LOWER = 48, /*!< Cyrillic lowercase characters */
- VKBD_DEGREE = 56, /*!< Numeric keyboard with extra characters (NESW, degree, minute) for coordinate input */
+ /* layouts */
+ VKBD_LATIN_UPPER = 0, /*!< Latin uppercase characters */
+ VKBD_LATIN_LOWER = 8, /*!< Latin lowercase characters */
+ VKBD_NUMERIC = 16, /*!< Numeric keyboard */
+ VKBD_UMLAUT_UPPER = 24, /*!< Extended Latin uppercase characters */
+ VKBD_UMLAUT_LOWER = 32, /*!< Extended Latin lowercase characters */
+ VKBD_CYRILLIC_UPPER = 40, /*!< Cyrillic uppercase characters */
+ VKBD_CYRILLIC_LOWER = 48, /*!< Cyrillic lowercase characters */
+ VKBD_DEGREE = 56, /*!< Numeric keyboard with extra characters (NESW, degree, minute) for coordinate input */
+ VKBD_GREEK_UPPER = 64, /*!< Greek uppercase letters */
+ VKBD_GREEK_LOWER = 72, /*!< Greek lowercase letters */
- /* modifiers and masks */
- VKBD_FLAG_2 = 2, /* FIXME seems to show alpha/num switch (VKBD_NUMERIC and VKBD_LATIN_* only) and switches to lowercase after first character */
- VKBD_MASK_7 = 7, /* FIXME modifiers for layout? */
- VKBD_FLAG_1024 = 1024, /* FIXME what is this for? Seems to have to do something with scroll box visibility */
- VKBD_LAYOUT_MASK = ~7, /* when XORed with the mode, preserves only the layout FIXME document properly */
+ /* modifiers and masks */
+ VKBD_FLAG_2 = 2, /* FIXME seems to show alpha/num switch (VKBD_NUMERIC and VKBD_LATIN_* only) and switches to lowercase after first character */
+ VKBD_MASK_7 = 7, /* FIXME modifiers for layout? */
+ VKBD_FLAG_1024 = 1024, /* FIXME what is this for? Seems to have to do something with scroll box visibility */
+ VKBD_LAYOUT_MASK = ~7, /* when XORed with the mode, preserves only the layout FIXME document properly */
};
/* prototypes */
diff --git a/navit/gui/internal/gui_internal_menu.c b/navit/gui/internal/gui_internal_menu.c
index 33def9983..3caae2800 100644
--- a/navit/gui/internal/gui_internal_menu.c
+++ b/navit/gui/internal/gui_internal_menu.c
@@ -15,85 +15,198 @@
#include "gui_internal_search.h"
#include "gui_internal_menu.h"
-extern char *version;
-static void
-gui_internal_menu_destroy(struct gui_priv *this, struct widget *w)
-{
- struct menu_data *menu_data=w->menu_data;
- if (menu_data) {
- if (menu_data->refresh_callback_obj.type) {
- struct object_func *func;
- func=object_func_lookup(menu_data->refresh_callback_obj.type);
- if (func && func->remove_attr)
- func->remove_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
- }
- if (menu_data->refresh_callback.u.callback)
- callback_destroy(menu_data->refresh_callback.u.callback);
+/**
+ * @brief Utility function to check if a menu widget is adapted to the display size or needs resizing (if so, the widget dimensions will be set to match those of the display
+ *
+ * @param this The GUI instance
+ * @param w The menu widget (top widget that should spawn over the entire display)
+ * @param wdisp The width of the display to check the widget against
+ * @param hdisp The width of the display to check the widget against
+ *
+ * @return true if widget w has the same size as the provided display dimensions
+ */
+
+int gui_internal_menu_needs_resizing(struct gui_priv *this, struct widget *w, int wdisp, int hdisp) {
+ if (w->w != wdisp || w->h != hdisp) {
+ w->w=wdisp;
+ w->h=hdisp;
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+/**
+ * @brief destroy a menu widget and perform the associated cleanup in the menu & submenu list
+ *
+ * @param this The GUI instance
+ * @param w The menu widget to destroy
+ */
+void gui_internal_menu_destroy(struct gui_priv *this, struct widget *w) {
+ struct menu_data *menu_data=w->menu_data;
+ if (menu_data) {
+ if (menu_data->refresh_callback_obj.type) {
+ struct object_func *func;
+ func=object_func_lookup(menu_data->refresh_callback_obj.type);
+ if (func && func->remove_attr)
+ func->remove_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
+ }
+ if (menu_data->refresh_callback.u.callback)
+ callback_destroy(menu_data->refresh_callback.u.callback);
+
+ g_free(menu_data->href);
+ g_free(menu_data);
+ }
+ gui_internal_widget_destroy(this, w);
+ this->root.children=g_list_remove(this->root.children, w);
+}
+
+/**
+ * @brief Retrieve then html anchor (href) from a menu widger
+ *
+ * @param w A widget corresponding to a menu (this widget should be an html menu)
+ *
+ * @return the string for the href, or NULL if this menu has no href (or the widget is not a menu)
+ */
+static char *gui_internal_widget_get_href(struct widget *w) {
+ if (w && w->menu_data)
+ return w->menu_data->href;
+ else
+ return NULL;
+}
- g_free(menu_data->href);
- g_free(menu_data);
- }
- gui_internal_widget_destroy(this, w);
- this->root.children=g_list_remove(this->root.children, w);
+/**
+ * @brief Reload a menu from its anchor (href)
+ *
+ * @param this The internal GUI context
+ * @param w A widget corresponding to the menu to redraw (this widget should be an html menu, thus it should have a href)
+ *
+ * @return 1 in case of success, 0 if no menu could be reloaded
+ * @note If the widget provided in @p w has no href, we will return 0
+ */
+int gui_internal_widget_reload_href(struct gui_priv *this, struct widget *w) {
+ char *ohref = gui_internal_widget_get_href(w);
+ if (ohref) {
+ char *href=g_strdup(ohref);
+ gui_internal_menu_destroy(this, w);
+ gui_internal_html_load_href(this, href, 0);
+ g_free(href);
+ return 1;
+ }
+ return 0;
}
-static void
-gui_internal_prune_menu_do(struct gui_priv *this, struct widget *w, int render)
-{
- GList *l;
- struct widget *wr,*wd;
- gui_internal_search_idle_end(this);
- while ((l = g_list_last(this->root.children))) {
- wd=l->data;
- if (wd == w) {
- void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
- if (!render)
- return;
- gui_internal_say(this, w, 0);
- redisplay=w->menu_data->redisplay;
- wr=w->menu_data->redisplay_widget;
- if (!w->menu_data->redisplay && !w->menu_data->href) {
- gui_internal_widget_render(this, w);
- return;
- }
- if (redisplay) {
- gui_internal_menu_destroy(this, w);
- redisplay(this, wr, wr->data);
- } else {
- char *href=g_strdup(w->menu_data->href);
- gui_internal_menu_destroy(this, w);
- gui_internal_html_load_href(this, href, 0);
- g_free(href);
- }
- return;
- }
- gui_internal_menu_destroy(this, wd);
- }
+/**
+ * @brief Destroy (discard) all menu screens that have been placed after widget @p w
+ *
+ * @param this The internal GUI instance
+ * @param w A widget corresponding to the last menu to keep (all subsequent menus in the list will be destroyed). NULL if all menus should be destroyed.
+ * @param render whether we should render the menu indicated by widget w (render!=0) or not (render==0)
+ */
+static void gui_internal_prune_menu_do(struct gui_priv *this, struct widget *w, int render) {
+ GList *l;
+ struct widget *wr,*wd;
+ gui_internal_search_idle_end(this);
+ /* Destroy all menus, backwards, starting from the end until we reach widget w, and redraw widget w */
+ while ((l = g_list_last(this->root.children))) {
+ wd=l->data;
+ if (wd == w) { /* This is the widget we want to bring back to display (all subsequent widgets will be destroyed in the loop) */
+ void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
+ if (!render)
+ return;
+ gui_internal_say(this, w, 0);
+ redisplay=w->menu_data->redisplay;
+ if (redisplay) {
+ gui_internal_menu_destroy(this, w);
+ wr=w->menu_data->redisplay_widget;
+ redisplay(this, wr, wr->data);
+ } else {
+ /* Make sure the new menu we are going to display spawns the whole display (in case there was a resize while a submenu was being displayed) */
+ w->w=this->root.w;
+ w->h=this->root.h;
+ /* If the foremost widget is a HTML menu, reload & redraw it from its href using gui_internal_widget_reload_href() */
+ if (!gui_internal_widget_reload_href(this,w)) {
+ /* If not, resize the foremost widget */
+ gui_internal_menu_resize(this, this->root.w, this->root.h);
+ }
+ gui_internal_menu_render(this);
+ }
+ return;
+ } else
+ gui_internal_menu_destroy(this, wd);
+ }
}
-void
-gui_internal_prune_menu(struct gui_priv *this, struct widget *w)
-{
- gui_internal_prune_menu_do(this, w, 1);
+/**
+ * @brief Destroy (discard) all menu screens that have been placed after widget @p w and redraw the display, showing widget @w
+ *
+ * @param this The internal GUI instance
+ * @param w A widget corresponding to the last menu to keep, and to draw (all subsequent menus in the list will be destroyed). NULL if all menus should be destroyed.
+ */
+void gui_internal_prune_menu(struct gui_priv *this, struct widget *w) {
+ gui_internal_prune_menu_do(this, w, 1);
}
-void
-gui_internal_prune_menu_count(struct gui_priv *this, int count, int render)
-{
- GList *l=g_list_last(this->root.children);
- struct widget *w=NULL;
- while (l && count-- > 0)
- l=g_list_previous(l);
- if (l) {
- w=l->data;
- gui_internal_prune_menu_do(this, w, render);
- }
+/**
+ * @brief Destroy (discard) the last @p count menu screens
+ *
+ * @param this The internal GUI instance
+ * @param count The number of menus to destroy at the tail of the menu/submenu stack (if <=0, no menu will be destroyed)
+ * @param render whether we should render the new last menu in the stack (render!=0) or not (render==0)
+ */
+void gui_internal_prune_menu_count(struct gui_priv *this, int count, int render) {
+ GList *l=g_list_last(this->root.children);
+ struct widget *w=NULL;
+ while (l && count-- > 0)
+ l=g_list_previous(l);
+ if (l) {
+ w=l->data;
+ gui_internal_prune_menu_do(this, w, render);
+ }
}
+/**
+ * @brief Resize the box widget (and its children) corresponding to a menu
+ *
+ * Menus are stored in a main box (topbox) that spawn the entire screen, thus, once the topbox has been resized, it will in turn resize its children,
+ * effectively resizing the whole menu display size
+ *
+ * Note: once this function has been run, widget @p w and its children have been resized, a call to gui_internal_box_render() needs to be done by the caller
+ *
+ * @param this The internal GUI instance
+ * @param w A box widget corresponding to the menu widget
+ * @param data Some data to pass to the box resize handler
+ * @param neww The new width of the display
+ * @param newh The new height of the display
+ */
+void gui_internal_menu_menu_resize(struct gui_priv *this, struct widget *w, void *data, int neww, int newh) {
+ struct padding *padding = NULL;
+
+ if (w->type != widget_box) {
+ dbg(lvl_warning, "Called on a non-box widget, ignoring");
+ return;
+ }
+ if (this->gra) {
+ padding = graphics_get_data(this->gra, "padding");
+ } else
+ dbg(lvl_warning, "cannot get padding: this->gra is NULL");
+ if (padding) {
+ w->p.x = padding->left;
+ w->p.y = padding->top;
+ w->w = neww - padding->left - padding->right;
+ w->h = newh - padding->top - padding->bottom;
+ } else {
+ w->p.x = 0;
+ w->p.y = 0;
+ w->w = neww;
+ w->h = newh;
+ }
+ gui_internal_box_resize(this, w, data, w->w, w->h);
+}
/**
- * @brief Initializes a GUI screen
+ * @brief Initializes a GUI menu screen
*
* This method initializes the internal GUI's screen on which all other elements (such as HTML menus,
* dialogs or others) are displayed.
@@ -107,267 +220,280 @@ gui_internal_prune_menu_count(struct gui_priv *this, int count, int render)
* @return The container for caller-defined widgets
*/
struct widget *
-gui_internal_menu(struct gui_priv *this, const char *label)
-{
- struct widget *menu,*w,*w1,*topbox;
- struct padding *padding = NULL;
+gui_internal_menu(struct gui_priv *this, const char *label) {
+ struct widget *menu,*w,*w1,*topbox;
- if (this->gra) {
- padding = graphics_get_data(this->gra, "padding");
- } else
- dbg(lvl_warning, "cannot get padding: this->gra is NULL\n");
+ gui_internal_search_idle_end(this);
+ topbox=gui_internal_box_new_with_label(this, 0, label);
+ gui_internal_widget_append(&this->root, topbox);
+ menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
+ menu->on_resize=gui_internal_menu_menu_resize;
+ topbox->on_resize(this, topbox, NULL, this->root.w, this->root.h);
+ /* We also have to invoke onresize() handler on menu because it is not (yet) set as a child of topbox */
+ menu->on_resize(this, menu, NULL, topbox->w, topbox->h);
+ menu->background=this->background;
+ gui_internal_apply_config(this);
+ topbox->menu_data=g_new0(struct menu_data, 1);
+ gui_internal_widget_append(topbox, menu);
+ w=gui_internal_top_bar(this);
+ gui_internal_widget_append(menu, w);
+ w=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
+ w->spx=4*this->spacing;
+ w->w=menu->w;
+ gui_internal_widget_append(menu, w);
+ if (this->flags & 16 && !(this->flags & 1024)) {
+ struct widget *wlb,*wb,*wm=w;
+ wm->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
+ w=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_expand|flags_fill);
+ dbg(lvl_info,"topbox->menu_data=%p", topbox->menu_data);
+ gui_internal_widget_append(wm, w);
+ wb=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
+ wb->bl=6;
+ wb->br=6;
+ wb->bb=6;
+ wb->bt=6;
+ wb->spx=6;
+ topbox->menu_data->button_bar=wb;
+ gui_internal_widget_append(wm, wb);
+ wlb=gui_internal_button_label(this,_("Back"),1);
+ wlb->func=gui_internal_back;
+ wlb->state |= STATE_SENSITIVE;
+ }
+ if (this->flags & 192) {
+ menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
+ menu->on_resize=gui_internal_menu_menu_resize;
+ menu->on_resize(this, menu, NULL, topbox->w, topbox->h);
+ w1=gui_internal_time_help(this);
+ gui_internal_widget_append(menu, w1);
+ w1=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(menu, w1);
+ gui_internal_widget_append(topbox, menu);
+ menu->background=NULL;
+ }
+ gui_internal_widget_pack(this, topbox);
+ gui_internal_widget_reset_pack(this, topbox);
+ if (topbox->on_resize)
+ topbox->on_resize(this, topbox, NULL, this->root.w, this->root.h);
+ return w;
+}
- gui_internal_search_idle_end(this);
- topbox=gui_internal_box_new_with_label(this, 0, label);
- topbox->w=this->root.w;
- topbox->h=this->root.h;
- gui_internal_widget_append(&this->root, topbox);
- menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
+struct menu_data *
+gui_internal_menu_data(struct gui_priv *this) {
+ GList *l;
+ struct widget *menu;
- if (padding) {
- menu->p.x = padding->left;
- menu->p.y = padding->top;
- menu->w = topbox->w - padding->left - padding->right;
- menu->h = topbox->h - padding->top - padding->bottom;
- } else {
- menu->p.x = 0;
- menu->p.y = 0;
- menu->w = topbox->w;
- menu->h = topbox->h;
- }
- menu->background=this->background;
- gui_internal_apply_config(this);
- topbox->menu_data=g_new0(struct menu_data, 1);
- gui_internal_widget_append(topbox, menu);
- w=gui_internal_top_bar(this);
- gui_internal_widget_append(menu, w);
- w=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- w->spx=4*this->spacing;
- w->w=menu->w;
- gui_internal_widget_append(menu, w);
- if (this->flags & 16 && !(this->flags & 1024)) {
- struct widget *wlb,*wb,*wm=w;
- wm->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
- w=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_expand|flags_fill);
- dbg(lvl_info,"topbox->menu_data=%p\n", topbox->menu_data);
- gui_internal_widget_append(wm, w);
- wb=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
- wb->bl=6;
- wb->br=6;
- wb->bb=6;
- wb->bt=6;
- wb->spx=6;
- topbox->menu_data->button_bar=wb;
- gui_internal_widget_append(wm, wb);
- wlb=gui_internal_button_label(this,_("Back"),1);
- wlb->func=gui_internal_back;
- wlb->state |= STATE_SENSITIVE;
- }
- if (this->flags & 192) {
- menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
- if (padding) {
- menu->p.x = padding->left;
- menu->p.y = padding->top;
- menu->w = topbox->w - padding->left - padding->right;
- menu->h = topbox->h - padding->top - padding->bottom;
- } else {
- menu->p.x = 0;
- menu->p.y = 0;
- menu->w = topbox->w;
- menu->h = topbox->h;
- }
- w1=gui_internal_time_help(this);
- gui_internal_widget_append(menu, w1);
- w1=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(menu, w1);
- gui_internal_widget_append(topbox, menu);
- menu->background=NULL;
- }
- gui_internal_widget_pack(this, topbox);
- gui_internal_widget_reset_pack(this, topbox);
- topbox->w=this->root.w;
- topbox->h=this->root.h;
- if (padding) {
- menu->p.x = padding->left;
- menu->p.y = padding->top;
- menu->w = topbox->w - padding->left - padding->right;
- menu->h = topbox->h - padding->top - padding->bottom;
- } else {
- menu->p.x = 0;
- menu->p.y = 0;
- menu->w = topbox->w;
- menu->h = topbox->h;
- }
- return w;
+ l=g_list_last(this->root.children);
+ menu=l->data;
+ return menu->menu_data;
}
-struct menu_data *
-gui_internal_menu_data(struct gui_priv *this)
-{
- GList *l;
- struct widget *menu;
+void gui_internal_menu_reset_pack(struct gui_priv *this) {
+ GList *l;
+ struct widget *top_box;
+
+ l=g_list_last(this->root.children);
+ top_box=l->data;
+ gui_internal_widget_reset_pack(this, top_box);
+}
- l=g_list_last(this->root.children);
- menu=l->data;
- return menu->menu_data;
+/**
+ * @brief Renders a menu GUI on the display
+ *
+ * @note The whole sequence of menus is kept in this->root.children (when going back one page, we just move to the previous child in the list)
+ * Thus, only the last child of this->root.children is actually displayed
+ *
+ * @param this The internal GUI instance
+ */
+void gui_internal_menu_render(struct gui_priv *this) {
+ GList *l;
+ struct widget *menu;
+
+ l=g_list_last(this->root.children);
+ menu=l->data;
+ gui_internal_say(this, menu, 0);
+ gui_internal_widget_pack(this, menu);
+ gui_internal_widget_render(this, menu);
}
-void
-gui_internal_menu_reset_pack(struct gui_priv *this)
-{
- GList *l;
- struct widget *top_box;
+/**
+ * @brief Resize the currently displayed menu
+ *
+ * @param this The internal GUI instance
+ * @param w The new width of the display
+ * @param h the new height of the display
+ */
+void gui_internal_menu_resize(struct gui_priv *this, int w, int h) {
+ GList *l;
+ struct widget *menu_topwidget;
- l=g_list_last(this->root.children);
- top_box=l->data;
- gui_internal_widget_reset_pack(this, top_box);
+ gui_internal_apply_config(this);
+ l=g_list_last(this->root.children);
+ menu_topwidget=l->data;
+ if (menu_topwidget->on_resize) {
+ dbg(lvl_debug, "Invoking resize handler for menu_topwidget at %p", menu_topwidget);
+ menu_topwidget->on_resize(this, menu_topwidget, NULL, this->root.w, this->root.h);
+ }
}
-void
-gui_internal_menu_render(struct gui_priv *this)
-{
- GList *l;
- struct widget *menu;
+/**
+ * @brief Resize a top bar created using gui_internal_top_bar()
+ *
+ * @param this The internal GUI instance
+ * @param data Some data to pass to the box resize handler
+ * @param neww The new width of the display
+ * @param newh The new height of the display
+ */
+static void gui_internal_top_bar_resize(struct gui_priv *this, struct widget *w, void *data, int neww, int newh) {
+ struct widget *new_top_bar;
- l=g_list_last(this->root.children);
- menu=l->data;
- gui_internal_say(this, menu, 0);
- gui_internal_widget_pack(this, menu);
- gui_internal_widget_render(this, menu);
+ if (w->type != widget_box) {
+ dbg(lvl_warning, "Called on a non-box widget, ignoring");
+ return;
+ }
+ new_top_bar=gui_internal_top_bar(this);
+ gui_internal_widget_move(this, w, new_top_bar);
}
+/**
+ * @brief Create an GUI top bar (containing the history of GUI menus and submenus)
+ *
+ * @param this The internal GUI instance
+ *
+ * @return The newly created top bar widget
+ */
struct widget *
-gui_internal_top_bar(struct gui_priv *this)
-{
- struct widget *w,*wm,*wh,*wc,*wcn;
- int dots_len, sep_len;
- GList *res=NULL,*l;
- int width,width_used=0,use_sep=0,incomplete=0;
- struct graphics_gc *foreground=(this->flags & 256 ? this->background : this->text_foreground);
-/* flags
- 1:Don't expand bar to screen width
- 2:Don't show Map Icon
- 4:Don't show Home Icon
- 8:Show only current menu
- 16:Don't use menu titles as button
- 32:Show navit version
- 64:Show time
- 128:Show help
- 256:Use background for menu headline
- 512:Set osd_configuration and zoom to route when setting position
- 1024:Don't show back button
- 2048:No highlighting of keyboard
- 4096:Center menu title
-*/
+gui_internal_top_bar(struct gui_priv *this) {
+ struct widget *w,*wm,*wh,*wc,*wcn;
+ int dots_len, sep_len;
+ GList *res=NULL,*l;
+ int width,width_used=0,use_sep=0,incomplete=0;
+ struct graphics_gc *foreground=(this->flags & 256 ? this->background : this->text_foreground);
+ /* flags
+ 1:Don't expand bar to screen width
+ 2:Don't show Map Icon
+ 4:Don't show Home Icon
+ 8:Show only current menu
+ 16:Don't use menu titles as button
+ 32:Show navit version
+ 64:Show time
+ 128:Show help
+ 256:Use background for menu headline
+ 512:Set osd_configuration and zoom to route when setting position
+ 1024:Don't show back button
+ 2048:No highlighting of keyboard
+ 4096:Center menu title
+ */
- w=gui_internal_box_new(this, (this->flags & 4096 ? gravity_center : gravity_left_center)|orientation_horizontal|(this->flags & 1 ? 0:flags_fill));
- w->bl=this->spacing;
- w->spx=this->spacing;
- w->background=this->background2;
- if ((this->flags & 6) == 6) {
- w->bl=10;
- w->br=10;
- w->bt=6;
- w->bb=6;
- }
- width=this->root.w-w->bl;
- if (! (this->flags & 2)) {
- wm=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, "gui_map"), gravity_center|orientation_vertical,
- gui_internal_cmd_return, NULL);
- wm->speech=g_strdup(_("Back to map"));
- gui_internal_widget_pack(this, wm);
- gui_internal_widget_append(w, wm);
- width-=wm->w;
- }
- if (! (this->flags & 4)) {
- wh=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, "gui_home"), gravity_center|orientation_vertical,
- gui_internal_cmd_main_menu, NULL);
- wh->speech=g_strdup(_("Main Menu"));
- gui_internal_widget_pack(this, wh);
- gui_internal_widget_append(w, wh);
- width-=wh->w;
- }
- if (!(this->flags & 6))
- width-=w->spx;
- l=g_list_last(this->root.children);
- wcn=gui_internal_label_new(this,".. »");
- wcn->foreground=foreground;
- dots_len=wcn->w;
- gui_internal_widget_destroy(this, wcn);
- wcn=gui_internal_label_new(this,"»");
- wcn->foreground=foreground;
- sep_len=wcn->w;
- gui_internal_widget_destroy(this, wcn);
- while (l) {
- if (g_list_previous(l) || !g_list_next(l)) {
- wc=l->data;
- wcn=gui_internal_label_new(this, wc->text);
- wcn->foreground=foreground;
- if (g_list_next(l))
- use_sep=1;
- else
- use_sep=0;
- dbg(lvl_debug,"%d (%s) + %d + %d + %d > %d\n", wcn->w, wc->text, width_used, w->spx, use_sep ? sep_len : 0, width);
- if (wcn->w + width_used + w->spx + (use_sep ? sep_len : 0) + (g_list_previous(l) ? dots_len : 0) > width) {
- incomplete=1;
- gui_internal_widget_destroy(this, wcn);
- break;
- }
- if (use_sep) {
- struct widget *wct=gui_internal_label_new(this, "»");
- wct->foreground=foreground;
- res=g_list_prepend(res, wct);
- width_used+=sep_len+w->spx;
- }
- width_used+=wcn->w;
- if (!(this->flags & 16)) {
- wcn->func=gui_internal_cmd_return;
- wcn->data=wc;
- wcn->state |= STATE_SENSITIVE;
- }
- res=g_list_prepend(res, wcn);
- if (this->flags & 8)
- break;
- }
- l=g_list_previous(l);
- }
- if (incomplete) {
- if (! res) {
- wcn=gui_internal_label_new_abbrev(this, wc->text, width-width_used-w->spx-dots_len);
- wcn->foreground=foreground;
- wcn->func=gui_internal_cmd_return;
- wcn->data=wc;
- wcn->state |= STATE_SENSITIVE;
- res=g_list_prepend(res, wcn);
- l=g_list_previous(l);
- wc=l?l->data:NULL;
- }
- if(wc) {
- wcn=gui_internal_label_new(this, ".. »");
- wcn->foreground=foreground;
- wcn->func=gui_internal_cmd_return;
- wcn->data=wc;
- wcn->state |= STATE_SENSITIVE;
- res=g_list_prepend(res, wcn);
- }
- }
- l=res;
- while (l) {
- gui_internal_widget_append(w, l->data);
- l=g_list_next(l);
- }
- if (this->flags & 32) {
- char *version_text=g_strdup_printf("Navit %s",version);
- wcn=gui_internal_label_new(this, version_text);
- g_free(version_text);
- wcn->flags=gravity_right_center|flags_expand;
- gui_internal_widget_append(w, wcn);
- }
+ w=gui_internal_box_new(this, (this->flags & 4096 ? gravity_center : gravity_left_center)|orientation_horizontal|
+ (this->flags & 1 ? 0:flags_fill));
+ w->bl=this->spacing;
+ w->spx=this->spacing;
+ w->background=this->background2;
+ if ((this->flags & 6) == 6) {
+ w->bl=10;
+ w->br=10;
+ w->bt=6;
+ w->bb=6;
+ }
+ w->on_resize=gui_internal_top_bar_resize;
+ width=this->root.w-w->bl;
+ if (! (this->flags & 2)) {
+ wm=gui_internal_button_new_with_callback(this, NULL,
+ image_new_s(this, "gui_map"), gravity_center|orientation_vertical,
+ gui_internal_cmd_return, NULL);
+ wm->speech=g_strdup(_("Back to map"));
+ gui_internal_widget_pack(this, wm);
+ gui_internal_widget_append(w, wm);
+ width-=wm->w;
+ }
+ if (! (this->flags & 4)) {
+ wh=gui_internal_button_new_with_callback(this, NULL,
+ image_new_s(this, "gui_home"), gravity_center|orientation_vertical,
+ gui_internal_cmd_main_menu, NULL);
+ wh->speech=g_strdup(_("Main Menu"));
+ gui_internal_widget_pack(this, wh);
+ gui_internal_widget_append(w, wh);
+ width-=wh->w;
+ }
+ if (!(this->flags & 6))
+ width-=w->spx;
+ l=g_list_last(this->root.children);
+ wcn=gui_internal_label_new(this,".. »");
+ wcn->foreground=foreground;
+ dots_len=wcn->w;
+ gui_internal_widget_destroy(this, wcn);
+ wcn=gui_internal_label_new(this,"»");
+ wcn->foreground=foreground;
+ sep_len=wcn->w;
+ gui_internal_widget_destroy(this, wcn);
+ while (l) {
+ if (g_list_previous(l) || !g_list_next(l)) {
+ wc=l->data;
+ wcn=gui_internal_label_new(this, wc->text);
+ wcn->foreground=foreground;
+ if (g_list_next(l))
+ use_sep=1;
+ else
+ use_sep=0;
+ dbg(lvl_debug,"%d (%s) + %d + %d + %d > %d", wcn->w, wc->text, width_used, w->spx, use_sep ? sep_len : 0, width);
+ if (wcn->w + width_used + w->spx + (use_sep ? sep_len : 0) + (g_list_previous(l) ? dots_len : 0) > width) {
+ incomplete=1;
+ gui_internal_widget_destroy(this, wcn);
+ break;
+ }
+ if (use_sep) {
+ struct widget *wct=gui_internal_label_new(this, "»");
+ wct->foreground=foreground;
+ res=g_list_prepend(res, wct);
+ width_used+=sep_len+w->spx;
+ }
+ width_used+=wcn->w;
+ if (!(this->flags & 16)) {
+ wcn->func=gui_internal_cmd_return;
+ wcn->data=wc;
+ wcn->state |= STATE_SENSITIVE;
+ }
+ res=g_list_prepend(res, wcn);
+ if (this->flags & 8)
+ break;
+ }
+ l=g_list_previous(l);
+ }
+ if (incomplete) {
+ if (! res) {
+ wcn=gui_internal_label_new_abbrev(this, wc->text, width-width_used-w->spx-dots_len);
+ wcn->foreground=foreground;
+ wcn->func=gui_internal_cmd_return;
+ wcn->data=wc;
+ wcn->state |= STATE_SENSITIVE;
+ res=g_list_prepend(res, wcn);
+ l=g_list_previous(l);
+ wc=l?l->data:NULL;
+ }
+ if(wc) {
+ wcn=gui_internal_label_new(this, ".. »");
+ wcn->foreground=foreground;
+ wcn->func=gui_internal_cmd_return;
+ wcn->data=wc;
+ wcn->state |= STATE_SENSITIVE;
+ res=g_list_prepend(res, wcn);
+ }
+ }
+ l=res;
+ while (l) {
+ gui_internal_widget_append(w, l->data);
+ l=g_list_next(l);
+ }
+ if (this->flags & 32) {
+ char *version_text=g_strdup_printf("Navit %s",NAVIT_VERSION);
+ wcn=gui_internal_label_new(this, version_text);
+ g_free(version_text);
+ wcn->flags=gravity_right_center|flags_expand;
+ gui_internal_widget_append(w, wcn);
+ }
#if 0
- if (dots)
- gui_internal_widget_destroy(this, dots);
+ if (dots)
+ gui_internal_widget_destroy(this, dots);
#endif
- return w;
+ return w;
}
diff --git a/navit/gui/internal/gui_internal_menu.h b/navit/gui/internal/gui_internal_menu.h
index 57e37d91c..3906ed23c 100644
--- a/navit/gui/internal/gui_internal_menu.h
+++ b/navit/gui/internal/gui_internal_menu.h
@@ -2,11 +2,16 @@
struct gui_priv;
struct menu_data;
struct widget;
+int gui_internal_menu_needs_resizing(struct gui_priv *this, struct widget *w, int wdisp, int hdisp);
+void gui_internal_menu_destroy(struct gui_priv *this, struct widget *w);
+int gui_internal_widget_reload_href(struct gui_priv *this, struct widget *w);
void gui_internal_prune_menu(struct gui_priv *this, struct widget *w);
void gui_internal_prune_menu_count(struct gui_priv *this, int count, int render);
+void gui_internal_menu_menu_resize(struct gui_priv *this, struct widget *w, void *data, int neww, int newh);
struct widget *gui_internal_menu(struct gui_priv *this, const char *label);
struct menu_data *gui_internal_menu_data(struct gui_priv *this);
void gui_internal_menu_reset_pack(struct gui_priv *this);
void gui_internal_menu_render(struct gui_priv *this);
+void gui_internal_menu_resize(struct gui_priv *this, int w, int h);
struct widget *gui_internal_top_bar(struct gui_priv *this);
/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_poi.c b/navit/gui/internal/gui_internal_poi.c
index cb31ecc95..839a5d061 100644
--- a/navit/gui/internal/gui_internal_poi.c
+++ b/navit/gui/internal/gui_internal_poi.c
@@ -28,121 +28,124 @@
struct item_data {
- int dist;
- char *label;
- struct item item;
- struct coord c;
+ int dist;
+ char *label;
+ struct item item;
+ struct coord c;
};
struct selector {
- char *icon;
- char *name;
- enum item_type *types;
+ char *icon;
+ char *name;
+ enum item_type *types;
};
-static enum item_type selectors_BankTypes[]={type_poi_bank,type_poi_bank, type_poi_atm,type_poi_atm, type_none};
-static enum item_type selectors_FuelTypes[]={type_poi_fuel,type_poi_fuel,type_none};
-static enum item_type selectors_BusTrainTypes[]={type_poi_rail_station,type_poi_rail_station,
- type_poi_rail_halt,type_poi_rail_tram_stop,type_poi_bus_station,type_poi_bus_stop,type_none};
-static enum item_type selectors_HotelTypes[]={type_poi_hotel,type_poi_camp_rv,type_poi_camping,type_poi_camping,
- type_poi_resort,type_poi_resort,type_poi_motel,type_poi_hostel,type_none};
-static enum item_type selectors_RestaurantTypes[]={type_poi_bar,type_poi_picnic,type_poi_burgerking,type_poi_fastfood,
- type_poi_restaurant,type_poi_restaurant,type_poi_cafe,type_poi_cafe,type_poi_pub,type_poi_pub,type_none};
-static enum item_type selectors_ShoppingTypes[]={type_poi_mall,type_poi_mall,type_poi_shop_grocery,type_poi_shop_grocery,
- type_poi_shopping,type_poi_shopping,type_poi_shop_butcher,type_poi_shop_baker,type_poi_shop_fruit,
- type_poi_shop_fruit,type_poi_shop_beverages,type_poi_shop_beverages,type_none};
-static enum item_type selectors_ServiceTypes[]={type_poi_marina,type_poi_marina,type_poi_hospital,type_poi_hospital,
- type_poi_public_utilities,type_poi_public_utilities,type_poi_police,type_poi_autoservice,type_poi_information,
- type_poi_information,type_poi_pharmacy,type_poi_pharmacy,type_poi_personal_service,type_poi_repair_service,
- type_poi_restroom,type_poi_restroom,type_none};
-static enum item_type selectors_ParkingTypes[]={type_poi_car_parking,type_poi_car_parking,type_none};
-static enum item_type selectors_LandFeaturesTypes[]={type_poi_land_feature,type_poi_rock,type_poi_dam,type_poi_dam,
- type_poi_peak,type_poi_peak,type_none};
-static enum item_type selectors_OtherTypes[]={type_point_unspecified,type_poi_land_feature-1,type_poi_rock+1,type_poi_fuel-1,
- type_poi_marina+1,type_poi_shopping-1,type_poi_shopping+1,type_poi_car_parking-1,type_poi_car_parking+1,
- type_poi_bar-1,type_poi_bank+1,type_poi_dam-1,type_poi_dam+1,type_poi_information-1,type_poi_information+1,
- type_poi_mall-1,type_poi_mall+1,type_poi_personal_service-1,type_poi_pharmacy+1,type_poi_repair_service-1,
- type_poi_repair_service+1,type_poi_restaurant-1,type_poi_restaurant+1,type_poi_restroom-1,type_poi_restroom+1,
- type_poi_shop_grocery-1,type_poi_shop_grocery+1,type_poi_peak-1,type_poi_peak+1,type_poi_motel-1,type_poi_hostel+1,
- type_poi_shop_butcher-1,type_poi_shop_baker+1,type_poi_shop_fruit-1,type_poi_shop_fruit+1,type_poi_shop_beverages-1,
- type_poi_shop_beverages+1,type_poi_pub-1,type_poi_atm+1,type_line-1,type_none};
+static enum item_type selectors_BankTypes[]= {type_poi_bank,type_poi_bank, type_poi_atm,type_poi_atm, type_none};
+static enum item_type selectors_FuelTypes[]= {type_poi_fuel,type_poi_fuel,type_none};
+static enum item_type selectors_BusTrainTypes[]= {type_poi_rail_station,type_poi_rail_station,
+ type_poi_rail_halt,type_poi_rail_tram_stop,type_poi_bus_station,type_poi_bus_stop,type_none
+ };
+static enum item_type selectors_HotelTypes[]= {type_poi_hotel,type_poi_camp_rv,type_poi_camping,type_poi_camping,
+ type_poi_resort,type_poi_resort,type_poi_motel,type_poi_hostel,type_none
+ };
+static enum item_type selectors_RestaurantTypes[]= {type_poi_bar,type_poi_picnic,type_poi_burgerking,type_poi_fastfood,
+ type_poi_restaurant,type_poi_restaurant,type_poi_cafe,type_poi_cafe,type_poi_pub,type_poi_pub,type_none
+ };
+static enum item_type selectors_ShoppingTypes[]= {type_poi_mall,type_poi_mall,type_poi_shop_grocery,type_poi_shop_grocery,
+ type_poi_shopping,type_poi_shopping,type_poi_shop_butcher,type_poi_shop_baker,type_poi_shop_fruit,
+ type_poi_shop_fruit,type_poi_shop_beverages,type_poi_shop_beverages,type_none
+ };
+static enum item_type selectors_ServiceTypes[]= {type_poi_marina,type_poi_marina,type_poi_hospital,type_poi_hospital,
+ type_poi_public_utilities,type_poi_public_utilities,type_poi_police,type_poi_autoservice,type_poi_information,
+ type_poi_information,type_poi_pharmacy,type_poi_pharmacy,type_poi_personal_service,type_poi_repair_service,
+ type_poi_restroom,type_poi_restroom,type_none
+ };
+static enum item_type selectors_ParkingTypes[]= {type_poi_car_parking,type_poi_car_parking,type_none};
+static enum item_type selectors_LandFeaturesTypes[]= {type_poi_land_feature,type_poi_rock,type_poi_dam,type_poi_dam,
+ type_poi_peak,type_poi_peak,type_none
+ };
+static enum item_type selectors_OtherTypes[]= {type_point_unspecified,type_poi_land_feature-1,type_poi_rock+1,type_poi_fuel-1,
+ type_poi_marina+1,type_poi_shopping-1,type_poi_shopping+1,type_poi_car_parking-1,type_poi_car_parking+1,
+ type_poi_bar-1,type_poi_bank+1,type_poi_dam-1,type_poi_dam+1,type_poi_information-1,type_poi_information+1,
+ type_poi_mall-1,type_poi_mall+1,type_poi_personal_service-1,type_poi_pharmacy+1,type_poi_repair_service-1,
+ type_poi_repair_service+1,type_poi_restaurant-1,type_poi_restaurant+1,type_poi_restroom-1,type_poi_restroom+1,
+ type_poi_shop_grocery-1,type_poi_shop_grocery+1,type_poi_peak-1,type_poi_peak+1,type_poi_motel-1,type_poi_hostel+1,
+ type_poi_shop_butcher-1,type_poi_shop_baker+1,type_poi_shop_fruit-1,type_poi_shop_fruit+1,type_poi_shop_beverages-1,
+ type_poi_shop_beverages+1,type_poi_pub-1,type_poi_atm+1,type_line-1,type_none
+ };
/*static enum item_type selectors_UnknownTypes[]={type_point_unkn,type_point_unkn,type_none};*/
-struct selector selectors[]={
- {"bank","Bank",selectors_BankTypes},
- {"fuel","Fuel",selectors_FuelTypes},
- {"bus_stop","Bus&Train",selectors_BusTrainTypes},
- {"hotel","Hotel",selectors_HotelTypes},
- {"restaurant","Restaurant",selectors_RestaurantTypes},
- {"shopping","Shopping",selectors_ShoppingTypes},
- {"hospital","Service",selectors_ServiceTypes},
- {"parking","Parking",selectors_ParkingTypes},
- {"peak","Land Features",selectors_LandFeaturesTypes},
- {"unknown","Other",selectors_OtherTypes},
-/* {"unknown","Unknown",selectors_UnknownTypes},*/
+struct selector selectors[]= {
+ {"bank","Bank",selectors_BankTypes},
+ {"fuel","Fuel",selectors_FuelTypes},
+ {"bus_stop","Bus&Train",selectors_BusTrainTypes},
+ {"hotel","Hotel",selectors_HotelTypes},
+ {"restaurant","Restaurant",selectors_RestaurantTypes},
+ {"shopping","Shopping",selectors_ShoppingTypes},
+ {"hospital","Service",selectors_ServiceTypes},
+ {"parking","Parking",selectors_ParkingTypes},
+ {"peak","Land Features",selectors_LandFeaturesTypes},
+ {"unknown","Other",selectors_OtherTypes},
+ /* {"unknown","Unknown",selectors_UnknownTypes},*/
};
/**
* @brief Get icon for given POI type.
*
* @param this pointer to gui context
* @param type POI type
- * @return Pointer to graphics_image object, or NULL if no picture available.
+ * @return Pointer to graphics_image object, or NULL if no picture available.
*/
-static struct graphics_image *
-gui_internal_poi_icon(struct gui_priv *this, struct item *item)
-{
- struct attr layout;
- struct attr icon_src;
- GList *layer;
- navit_get_attr(this->nav, attr_layout, &layout, NULL);
- layer=layout.u.layout->layers;
- while(layer) {
- GList *itemgra=((struct layer *)layer->data)->itemgras;
- while(itemgra) {
- GList *types=((struct itemgra *)itemgra->data)->type;
- while(types) {
- if((long)types->data==item->type) {
- GList *element=((struct itemgra *)itemgra->data)->elements;
- while(element) {
- struct element * el=element->data;
- if(el->type==element_icon) {
- char *src;
- char *icon;
- struct graphics_image *img;
- if(item_is_custom_poi(*item)) {
- struct map_rect *mr=map_rect_new(item->map, NULL);
- item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- if(item_attr_get(item, attr_icon_src, &icon_src)) {
- src=el->u.icon.src;
- if(!src || !src[0])
- src="%s";
- icon=g_strdup_printf(src,map_convert_string_tmp(item->map,icon_src.u.str));
- }
- else {
- icon=g_strdup(el->u.icon.src);
- }
- }
- else {
- icon=g_strdup(el->u.icon.src);
- }
- char *dot=g_strrstr(icon,".");
- dbg(lvl_debug,"%s %s\n", item_to_name(item->type),icon);
- if(dot)
- *dot=0;
- img=image_new_xs(this,icon);
- g_free(icon);
- if(img)
- return img;
- }
- element=g_list_next(element);
- }
- }
- types=g_list_next(types);
- }
- itemgra=g_list_next(itemgra);
- }
- layer=g_list_next(layer);
- }
- return NULL;
+static struct graphics_image *gui_internal_poi_icon(struct gui_priv *this, struct item *item) {
+ struct attr layout;
+ struct attr icon_src;
+ GList *layer;
+ navit_get_attr(this->nav, attr_layout, &layout, NULL);
+ layer=layout.u.layout->layers;
+ while(layer) {
+ GList *itemgra=((struct layer *)layer->data)->itemgras;
+ while(itemgra) {
+ GList *types=((struct itemgra *)itemgra->data)->type;
+ while(types) {
+ if((long)types->data==item->type) {
+ GList *element=((struct itemgra *)itemgra->data)->elements;
+ while(element) {
+ struct element * el=element->data;
+ if(el->type==element_icon) {
+ char *src;
+ char *icon;
+ struct graphics_image *img;
+ if(item_is_custom_poi(*item)) {
+ struct map_rect *mr=map_rect_new(item->map, NULL);
+ item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ if(item_attr_get(item, attr_icon_src, &icon_src)) {
+ src=el->u.icon.src;
+ if(!src || !src[0])
+ src="%s";
+ icon=g_strdup_printf(src,map_convert_string_tmp(item->map,icon_src.u.str));
+ } else {
+ icon=g_strdup(el->u.icon.src);
+ }
+ } else {
+ icon=g_strdup(el->u.icon.src);
+ }
+ char *dot=g_strrstr(icon,".");
+ dbg(lvl_debug,"%s %s", item_to_name(item->type),icon);
+ if(dot)
+ *dot=0;
+ img=image_new_xs(this,icon);
+ g_free(icon);
+ if(img)
+ return img;
+ }
+ element=g_list_next(element);
+ }
+ }
+ types=g_list_next(types);
+ }
+ itemgra=g_list_next(itemgra);
+ }
+ layer=g_list_next(layer);
+ }
+ return NULL;
}
/**
@@ -151,14 +154,12 @@ gui_internal_poi_icon(struct gui_priv *this, struct item *item)
* @param p reference to the object to be freed.
*/
-void
-gui_internal_poi_param_free(void *p)
-{
- if(((struct poi_param *)p)->filterstr)
- g_free(((struct poi_param *)p)->filterstr);
- if(((struct poi_param *)p)->filter)
- g_list_free(((struct poi_param *)p)->filter);
- g_free(p);
+void gui_internal_poi_param_free(void *p) {
+ if(((struct poi_param *)p)->filterstr)
+ g_free(((struct poi_param *)p)->filterstr);
+ if(((struct poi_param *)p)->filter)
+ g_list_free(((struct poi_param *)p)->filter);
+ g_free(p);
};
/**
@@ -168,24 +169,22 @@ gui_internal_poi_param_free(void *p)
* @return Cloned object reference.
*/
-static struct poi_param *
-gui_internal_poi_param_clone(struct poi_param *p)
-{
- struct poi_param *r=g_new(struct poi_param,1);
- GList *l=p->filter;
- memcpy(r,p,sizeof(struct poi_param));
- r->filter=NULL;
- r->filterstr=NULL;
- if(p->filterstr) {
- char *last=g_list_last(l)->data;
- int len=(last - p->filterstr) + strlen(last)+1;
- r->filterstr=g_memdup(p->filterstr,len);
- }
- while(l) {
- r->filter=g_list_append(r->filter, r->filterstr + ((char*)(l->data) - p->filterstr) );
- l=g_list_next(l);
- }
- return r;
+static struct poi_param *gui_internal_poi_param_clone(struct poi_param *p) {
+ struct poi_param *r=g_new(struct poi_param,1);
+ GList *l=p->filter;
+ memcpy(r,p,sizeof(struct poi_param));
+ r->filter=NULL;
+ r->filterstr=NULL;
+ if(p->filterstr) {
+ char *last=g_list_last(l)->data;
+ int len=(last - p->filterstr) + strlen(last)+1;
+ r->filterstr=g_memdup(p->filterstr,len);
+ }
+ while(l) {
+ r->filter=g_list_append(r->filter, r->filterstr + ((char*)(l->data) - p->filterstr) );
+ l=g_list_next(l);
+ }
+ return r;
};
/**
@@ -194,64 +193,60 @@ gui_internal_poi_param_clone(struct poi_param *p)
* @param text filter text.
*/
-void
-gui_internal_poi_param_set_filter(struct poi_param *param, char *text)
-{
- char *s1, *s2;
-
- param->filterstr=removecase(text);
- s1=param->filterstr;
- do {
- s2=g_utf8_strchr(s1,-1,' ');
- if(s2)
- *s2++=0;
- param->filter=g_list_append(param->filter,s1);
- if(s2) {
- while(*s2==' ')
- s2++;
- }
- s1=s2;
- } while(s2 && *s2);
+void gui_internal_poi_param_set_filter(struct poi_param *param, char *text) {
+ char *s1, *s2;
+
+ param->filterstr=removecase(text);
+ s1=param->filterstr;
+ do {
+ s2=g_utf8_strchr(s1,-1,' ');
+ if(s2)
+ *s2++=0;
+ param->filter=g_list_append(param->filter,s1);
+ if(s2) {
+ while(*s2==' ')
+ s2++;
+ }
+ s1=s2;
+ } while(s2 && *s2);
}
-static struct widget *
-gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c, int pagenb)
-{
- struct widget *wl,*wb;
- int nitems,nrows;
- int i;
- //wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal_vertical|flags_fill);
- wl->background=this->background;
- wl->w=this->root.w;
- wl->cols=this->root.w/this->icon_s;
- nitems=sizeof(selectors)/sizeof(struct selector);
- nrows=nitems/wl->cols + (nitems%wl->cols>0);
- wl->h=this->icon_l*nrows;
- for (i = 0 ; i < nitems ; i++) {
- struct poi_param *p=g_new0(struct poi_param,1);
- p->sel = 1;
- p->selnb = i;
- p->pagenb = pagenb;
- p->dist = 0;
- p->filter=NULL;
- p->filterstr=NULL;
- gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, selectors[i].icon), gravity_left_center|orientation_vertical,
- gui_internal_cmd_pois, p));
- wb->c=*c;
- wb->data_free=gui_internal_poi_param_free;
- wb->bt=10;
- }
-
- gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, "gui_search"), gravity_left_center|orientation_vertical,
- gui_internal_cmd_pois_filter, NULL));
- wb->c=*c;
- wb->bt=10;
-
- gui_internal_widget_pack(this,wl);
- return wl;
+static struct widget *gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c, int pagenb) {
+ struct widget *wl,*wb;
+ int nitems,nrows;
+ int i;
+ //wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal_vertical|flags_fill);
+ wl->background=this->background;
+ wl->w=this->root.w;
+ wl->cols=this->root.w/this->icon_s;
+ nitems=sizeof(selectors)/sizeof(struct selector);
+ nrows=nitems/wl->cols + (nitems%wl->cols>0);
+ wl->h=this->icon_l*nrows;
+ for (i = 0 ; i < nitems ; i++) {
+ struct poi_param *p=g_new0(struct poi_param,1);
+ p->sel = 1;
+ p->selnb = i;
+ p->pagenb = pagenb;
+ p->dist = 0;
+ p->filter=NULL;
+ p->filterstr=NULL;
+ gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
+ image_new_s(this, selectors[i].icon), gravity_left_center|orientation_vertical,
+ gui_internal_cmd_pois, p));
+ wb->c=*c;
+ wb->data_free=gui_internal_poi_param_free;
+ wb->bt=10;
+ }
+
+ gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
+ image_new_s(this, "gui_search"), gravity_left_center|orientation_vertical,
+ gui_internal_cmd_pois_filter, NULL));
+ wb->c=*c;
+ wb->bt=10;
+
+ gui_internal_widget_pack(this,wl);
+ return wl;
}
/**
@@ -266,67 +261,66 @@ gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c, int page
* @return Pointer to new widget.
*/
-static void
-format_dist(int dist, char *distbuf)
-{
- if (dist > 10000)
- sprintf(distbuf,"%d ", dist/1000);
- else if (dist>0)
- sprintf(distbuf,"%d.%d ", dist/1000, (dist%1000)/100);
+static void format_dist(int dist, char *distbuf) {
+ if (dist > 10000)
+ sprintf(distbuf,"%d ", dist/1000);
+ else if (dist>0)
+ sprintf(distbuf,"%d.%d ", dist/1000, (dist%1000)/100);
}
struct widget *
-gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c, struct route *route, int dist, char* name)
-{
- char distbuf[32]="";
- char dirbuf[32]="";
- char routedistbuf[32]="";
- char *type;
- struct widget *wl;
- char *text;
- struct graphics_image *icon;
-
- format_dist(dist,distbuf);
- if(c) {
- int len;
- get_compass_direction(dirbuf, transform_get_angle_delta(center, c, 0), 1);
- len=strlen(dirbuf);
- dirbuf[len]=' ';
- dirbuf[len+1]=0;
- if (route) {
- route_get_distances(route, c, 1, &dist);
- if (dist != INT_MAX)
- format_dist(dist, routedistbuf);
- }
- }
-
-
- type=item_to_name(item->type);
-
- icon=gui_internal_poi_icon(this,item);
- if(!icon && item->type==type_house_number)
- icon=image_new_xs(this,"post");
- if(!icon) {
- icon=image_new_xs(this,"gui_inactive");
- text=g_strdup_printf("%s%s%s%s %s", distbuf, dirbuf, routedistbuf, type, name);
- } else if(strlen(name)>0)
- text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, name);
- else
- text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, type);
-
- wl=gui_internal_button_new_with_callback(this, text, icon, gravity_left_center|orientation_horizontal|flags_fill, NULL, NULL);
- wl->datai=dist;
- g_free(text);
- if (name[0]) {
- wl->name=g_strdup_printf("%s %s",type,name);
- } else {
- wl->name=g_strdup(type);
- }
- wl->func=gui_internal_cmd_position;
- wl->data=(void *)9;
- wl->item=*item;
- wl->state|= STATE_SENSITIVE;
- return wl;
+gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c,
+ struct route *route, int dist, char* name) {
+ char distbuf[32]="";
+ char dirbuf[32]="";
+ char routedistbuf[32]="";
+ char *type;
+ struct widget *wl;
+ char *text;
+ struct graphics_image *icon;
+
+ format_dist(dist,distbuf);
+ if(c) {
+ int len;
+ get_compass_direction(dirbuf, transform_get_angle_delta(center, c, 0), 1);
+ len=strlen(dirbuf);
+ dirbuf[len]=' ';
+ dirbuf[len+1]=0;
+ if (route) {
+ route_get_distances(route, c, 1, &dist);
+ if (dist != INT_MAX)
+ format_dist(dist, routedistbuf);
+ }
+ }
+
+
+ type=item_to_name(item->type);
+
+ icon=gui_internal_poi_icon(this,item);
+ if(!icon && item->type==type_house_number)
+ icon=image_new_xs(this,"post");
+ if(!icon) {
+ icon=image_new_xs(this,"gui_inactive");
+ text=g_strdup_printf("%s%s%s%s %s", distbuf, dirbuf, routedistbuf, type, name);
+ } else if(strlen(name)>0)
+ text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, name);
+ else
+ text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, type);
+
+ wl=gui_internal_button_new_with_callback(this, text, icon, gravity_left_center|orientation_horizontal|flags_fill, NULL,
+ NULL);
+ wl->datai=dist;
+ g_free(text);
+ if (name[0]) {
+ wl->name=g_strdup_printf("%s %s",type,name);
+ } else {
+ wl->name=g_strdup(type);
+ }
+ wl->func=gui_internal_cmd_position;
+ wl->data=(void *)9;
+ wl->item=*item;
+ wl->state|= STATE_SENSITIVE;
+ return wl;
}
/**
@@ -336,87 +330,83 @@ gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct i
* @return Pointer to string representation of address. To be g_free()d after use.
*/
-char *
-gui_internal_compose_item_address_string(struct item *item, int prependPostal)
-{
- char *s=g_strdup("");
- struct attr attr;
- if(prependPostal && item_attr_get(item, attr_postal, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_house_number, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_street_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_street_name_systematic, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_district_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_town_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_county_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_country_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
-
- if(item_attr_get(item, attr_address, &attr))
- s=g_strjoin(" ",s,"|",map_convert_string_tmp(item->map,attr.u.str),NULL);
- return s;
+char *gui_internal_compose_item_address_string(struct item *item, int prependPostal) {
+ char *s=g_strdup("");
+ struct attr attr;
+ if(prependPostal && item_attr_get(item, attr_postal, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_house_number, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_street_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_street_name_systematic, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_district_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_town_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_county_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+ if(item_attr_get(item, attr_country_name, &attr))
+ s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
+
+ if(item_attr_get(item, attr_address, &attr))
+ s=g_strjoin(" ",s,"|",map_convert_string_tmp(item->map,attr.u.str),NULL);
+ return s;
}
-static int
-gui_internal_cmd_pois_item_selected(struct poi_param *param, struct item *item)
-{
- enum item_type *types;
- struct selector *sel = param->sel? &selectors[param->selnb]: NULL;
- enum item_type type=item->type;
- struct attr attr;
- int match=0;
- if (type >= type_line && param->filter==NULL)
- return 0;
- if (! sel || !sel->types) {
- match=1;
- } else {
- types=sel->types;
- while (*types != type_none) {
- if (item->type >= types[0] && item->type <= types[1]) {
- return 1;
- }
- types+=2;
- }
- }
- if(type == type_house_number && !param->filter)
- return 0;
- if (param->filter) {
- char *long_name, *s;
- GList *f;
- int i;
- if (param->AddressFilterType>0) {
- s=gui_internal_compose_item_address_string(item,param->AddressFilterType==2?1:0);
- } else if (item_attr_get(item, attr_label, &attr)) {
- s=g_strdup_printf("%s %s", item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str));
- } else {
- s=g_strdup(item_to_name(item->type));
- }
- long_name=removecase(s);
- g_free(s);
-
- match=0;
- for(i=0;i<3 && !match;i++) {
- char *long_name_exp=linguistics_expand_special(long_name, i);
- for(s=long_name_exp,f=param->filter;f && s;f=g_list_next(f)) {
- s=strstr(s,f->data);
- if(!s) {
- break;
- }
- s=g_utf8_strchr(s,-1,' ');
- }
- g_free(long_name_exp);
- if(!f)
- match=1;
- }
- g_free(long_name);
- }
- return match;
+static int gui_internal_cmd_pois_item_selected(struct poi_param *param, struct item *item) {
+ enum item_type *types;
+ struct selector *sel = param->sel? &selectors[param->selnb]: NULL;
+ enum item_type type=item->type;
+ struct attr attr;
+ int match=0;
+ if (type >= type_line && param->filter==NULL)
+ return 0;
+ if (! sel || !sel->types) {
+ match=1;
+ } else {
+ types=sel->types;
+ while (*types != type_none) {
+ if (item->type >= types[0] && item->type <= types[1]) {
+ return 1;
+ }
+ types+=2;
+ }
+ }
+ if(type == type_house_number && !param->filter)
+ return 0;
+ if (param->filter) {
+ char *long_name, *s;
+ GList *f;
+ int i;
+ if (param->AddressFilterType>0) {
+ s=gui_internal_compose_item_address_string(item,param->AddressFilterType==2?1:0);
+ } else if (item_attr_get(item, attr_label, &attr)) {
+ s=g_strdup_printf("%s %s", item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str));
+ } else {
+ s=g_strdup(item_to_name(item->type));
+ }
+ long_name=removecase(s);
+ g_free(s);
+
+ match=0;
+ for(i=0; i<3 && !match; i++) {
+ char *long_name_exp=linguistics_expand_special(long_name, i);
+ for(s=long_name_exp,f=param->filter; f && s; f=g_list_next(f)) {
+ s=strstr(s,f->data);
+ if(!s) {
+ break;
+ }
+ s=g_utf8_strchr(s,-1,' ');
+ }
+ g_free(long_name_exp);
+ if(!f)
+ match=1;
+ }
+ g_free(long_name);
+ }
+ return match;
}
/**
@@ -426,17 +416,15 @@ gui_internal_cmd_pois_item_selected(struct poi_param *param, struct item *item)
* @param wm called widget.
* @param data event data.
*/
-static void
-gui_internal_cmd_pois_more(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w=g_new0(struct widget,1);
- w->data=wm->data;
- w->c=wm->c;
- w->w=wm->w;
- wm->data_free=NULL;
- gui_internal_back(this, NULL, NULL);
- gui_internal_cmd_pois(this, w, w->data);
- free(w);
+static void gui_internal_cmd_pois_more(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w=g_new0(struct widget,1);
+ w->data=wm->data;
+ w->c=wm->c;
+ w->w=wm->w;
+ wm->data_free=NULL;
+ gui_internal_back(this, NULL, NULL);
+ gui_internal_cmd_pois(this, w, w->data);
+ free(w);
}
@@ -447,46 +435,42 @@ gui_internal_cmd_pois_more(struct gui_priv *this, struct widget *wm, void *data)
* @param wm called widget.
* @param data event data (pointer to editor widget containg filter text).
*/
-static void
-gui_internal_cmd_pois_filter_do(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w=data;
- struct poi_param *param;
-
- if(!w->text)
- return;
-
- if(w->data) {
- param=gui_internal_poi_param_clone(w->data);
- param->pagenb=0;
- } else {
- param=g_new0(struct poi_param,1);
- }
- if(!strcmp(wm->name,"AddressFilter"))
- param->AddressFilterType=1;
- else if(!strcmp(wm->name,"AddressFilterZip"))
- param->AddressFilterType=2;
- else
- param->AddressFilterType=0;
-
- gui_internal_poi_param_set_filter(param, w->text);
-
- gui_internal_cmd_pois(this,w,param);
- gui_internal_poi_param_free(param);
+static void gui_internal_cmd_pois_filter_do(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *w=data;
+ struct poi_param *param;
+
+ if(!w->text)
+ return;
+
+ if(w->data) {
+ param=gui_internal_poi_param_clone(w->data);
+ param->pagenb=0;
+ } else {
+ param=g_new0(struct poi_param,1);
+ }
+ if(!strcmp(wm->name,"AddressFilter"))
+ param->AddressFilterType=1;
+ else if(!strcmp(wm->name,"AddressFilterZip"))
+ param->AddressFilterType=2;
+ else
+ param->AddressFilterType=0;
+
+ gui_internal_poi_param_set_filter(param, w->text);
+
+ gui_internal_cmd_pois(this,w,param);
+ gui_internal_poi_param_free(param);
}
/**
* @brief POIs filter dialog.
* Event to handle '\r' '\n' keys pressed.
- *
+ *
*/
-static void
-gui_internal_cmd_pois_filter_changed(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (wm->text && wm->reason==gui_internal_reason_keypress_finish) {
- gui_internal_cmd_pois_filter_do(this, wm, wm);
- }
+static void gui_internal_cmd_pois_filter_changed(struct gui_priv *this, struct widget *wm, void *data) {
+ if (wm->text && wm->reason==gui_internal_reason_keypress_finish) {
+ gui_internal_cmd_pois_filter_do(this, wm, wm);
+ }
}
@@ -497,48 +481,46 @@ gui_internal_cmd_pois_filter_changed(struct gui_priv *this, struct widget *wm, v
* @param wm called widget.
* @param data event data.
*/
-void
-gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *wb, *w, *wr, *wk, *we;
- int keyboard_mode;
- keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"));
- wb=gui_internal_menu(this,"Filter");
- w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wr);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, we);
-
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
- wk->state |= STATE_EDIT|STATE_EDITABLE;
- wk->func=gui_internal_cmd_pois_filter_changed;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->name=g_strdup("POIsFilter");
- wk->c=wm->c;
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wb->state |= STATE_SENSITIVE;
- wb->func = gui_internal_cmd_pois_filter_do;
- wb->name=g_strdup("NameFilter");
- wb->data=wk;
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "post")));
- wb->state |= STATE_SENSITIVE;
- wb->name=g_strdup("AddressFilter");
- wb->func = gui_internal_cmd_pois_filter_do;
- wb->data=wk;
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "zipcode")));
- wb->state |= STATE_SENSITIVE;
- wb->name=g_strdup("AddressFilterZip");
- wb->func = gui_internal_cmd_pois_filter_do;
- wb->data=wk;
-
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
- else
- gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
- gui_internal_menu_render(this);
+void gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data) {
+ struct widget *wb, *w, *wr, *wk, *we;
+ int keyboard_mode;
+ keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"));
+ wb=gui_internal_menu(this,"Filter");
+ w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wr);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(wr, we);
+
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
+ wk->state |= STATE_EDIT|STATE_EDITABLE;
+ wk->func=gui_internal_cmd_pois_filter_changed;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->name=g_strdup("POIsFilter");
+ wk->c=wm->c;
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
+ wb->state |= STATE_SENSITIVE;
+ wb->func = gui_internal_cmd_pois_filter_do;
+ wb->name=g_strdup("NameFilter");
+ wb->data=wk;
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "post")));
+ wb->state |= STATE_SENSITIVE;
+ wb->name=g_strdup("AddressFilter");
+ wb->func = gui_internal_cmd_pois_filter_do;
+ wb->data=wk;
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "zipcode")));
+ wb->state |= STATE_SENSITIVE;
+ wb->name=g_strdup("AddressFilterZip");
+ wb->func = gui_internal_cmd_pois_filter_do;
+ wb->data=wk;
+
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
+ else
+ gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
+ gui_internal_menu_render(this);
}
@@ -550,243 +532,237 @@ gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *dat
* @param wm called widget.
* @param data event data, reference to poi_param or NULL.
*/
-void
-gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct map_selection *sel,*selm;
- struct coord c,center;
- struct mapset_handle *h;
- struct map *m;
- struct map_rect *mr;
- struct item *item;
- struct widget *wi,*w,*w2,*wb, *wtable, *row;
- enum projection pro=wm->c.pro;
- struct poi_param *param;
- int param_free=0;
- int idist,dist;
- struct selector *isel;
- int pagenb;
- int prevdist;
- // Starting value and increment of count of items to be extracted
- const int pagesize = 50;
- int maxitem, it = 0, i;
- struct item_data *items;
- struct fibheap* fh = fh_makekeyheap();
- int cnt = 0;
- struct table_data *td;
- struct widget *wl,*wt;
- char buffer[32];
- struct poi_param *paramnew;
- struct attr route;
-dbg(lvl_debug,"POIs...");
- if(data) {
- param = data;
- } else {
- param = g_new0(struct poi_param,1);
- param_free=1;
- }
- if (navit_get_attr(this->nav, attr_route, &route, NULL)) {
- struct attr route_status;
- if (!route_get_attr(route.u.route, attr_route_status, &route_status, NULL) ||
- (route_status.u.num != route_status_path_done_new &&
- route_status.u.num != route_status_path_done_incremental))
- route.u.route=NULL;
- } else
- route.u.route=NULL;
- dist=10000*(param->dist+1);
- isel = param->sel? &selectors[param->selnb]: NULL;
- pagenb = param->pagenb;
- prevdist=param->dist*10000;
- maxitem = pagesize*(pagenb+1);
- items= g_new0( struct item_data, maxitem);
-
-
- dbg(lvl_debug, "Params: sel = %i, selnb = %i, pagenb = %i, dist = %i, filterstr = %s, AddressFilterType= %d\n",
- param->sel, param->selnb, param->pagenb, param->dist, param->filterstr, param->AddressFilterType);
-
- wb=gui_internal_menu(this, isel ? isel->name : _("POIs"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- if (!isel && !param->filter)
- gui_internal_widget_append(w, gui_internal_cmd_pois_selector(this,&wm->c,pagenb));
- w2=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, w2);
-
- sel=map_selection_rect_new(&wm->c,dist*transform_scale(abs(wm->c.y)+dist*1.5),18);
- center.x=wm->c.x;
- center.y=wm->c.y;
- h=mapset_open(navit_get_mapset(this->nav));
- while ((m=mapset_next(h, 1))) {
- selm=map_selection_dup_pro(sel, pro, map_projection(m));
- mr=map_rect_new(m, selm);
- dbg(lvl_debug,"mr=%p\n", mr);
- if (mr) {
- while ((item=map_rect_get_item(mr))) {
- if (gui_internal_cmd_pois_item_selected(param, item) &&
- item_coord_get_pro(item, &c, 1, pro) &&
- coord_rect_contains(&sel->u.c_rect, &c) &&
- (idist=transform_distance(pro, &center, &c)) < dist) {
- struct item_data *data;
- struct attr attr;
- char *label;
- item_attr_rewind(item);
- if (item->type==type_house_number) {
- label=gui_internal_compose_item_address_string(item,1);
- } else if (item_attr_get(item, attr_label, &attr)) {
- label=map_convert_string(item->map,attr.u.str);
- // Buildings which label is equal to addr:housenumber value
- // are duplicated by item_house_number. Don't include such
- // buildings into the list. This is true for OSM maps created with
- // maptool patched with #859 latest patch.
- // FIXME: For non-OSM maps, we probably would better don't skip these items.
- if(item->type==type_poly_building && item_attr_get(item, attr_house_number, &attr) ) {
- if(strcmp(label,map_convert_string_tmp(item->map,attr.u.str))==0) {
- g_free(label);
- continue;
- }
- }
-
- } else {
- label=g_strdup("");
- }
-
- if(it>=maxitem) {
- data = fh_extractmin(fh);
- g_free(data->label);
- data->label=NULL;
- } else {
- data = &items[it++];
- }
- data->label=label;
- data->item = *item;
- data->c = c;
- data->dist = idist;
- // Key expression is a workaround to fight
- // probable heap collisions when two objects
- // are at the same distance. But it destroys
- // right order of POIs 2048 km away from cener
- // and if table grows more than 1024 rows.
- fh_insertkey(fh, -((idist<<10) + cnt++), data);
- if (it == maxitem)
- dist = (-fh_minkey(fh))>>10;
- }
- }
- map_rect_destroy(mr);
- }
- map_selection_destroy(selm);
- }
- map_selection_destroy(sel);
- mapset_close(h);
-
- wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- td=wtable->data;
-
- gui_internal_widget_append(w2,wtable);
-
- // Move items from heap to the table
- for(i=0;;i++)
- {
- int key = fh_minkey(fh);
- struct item_data *data = fh_extractmin(fh);
- if (data == NULL)
- {
- dbg(lvl_debug, "Empty heap: maxitem = %i, it = %i, dist = %i\n", maxitem, it, dist);
- break;
- }
- dbg(lvl_debug, "dist1: %i, dist2: %i\n", data->dist, (-key)>>10);
- if(i==(it-pagesize*pagenb) && data->dist>prevdist)
- prevdist=data->dist;
- wi=gui_internal_cmd_pois_item(this, &center, &data->item, &data->c, route.u.route, data->dist, data->label);
- wi->c.x=data->c.x;
- wi->c.y=data->c.y;
- wi->c.pro=pro;
- wi->background=this->background;
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- gui_internal_widget_append(row,wi);
- row->datai=data->dist;
- gui_internal_widget_prepend(wtable,row);
- g_free(data->label);
- }
-
- fh_deleteheap(fh);
- free(items);
-
- // Add an entry for more POI
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- row->datai=100000000; // Really far away for Earth, but won't work for bigger planets.
- gui_internal_widget_append(wtable,row);
- wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(row,wl);
- if (it == maxitem) {
- paramnew=gui_internal_poi_param_clone(param);
- paramnew->pagenb++;
- paramnew->count=it;
- snprintf(buffer, sizeof(buffer), "Get more (up to %d items)...", (paramnew->pagenb+1)*pagesize);
- wt=gui_internal_label_new(this, buffer);
- gui_internal_widget_append(wl, wt);
- wt->func=gui_internal_cmd_pois_more;
- wt->data=paramnew;
- wt->data_free=gui_internal_poi_param_free;
- wt->state |= STATE_SENSITIVE;
- wt->c = wm->c;
- } else {
- static int dist[]={1,5,10,0};
- wt=gui_internal_label_new(this, "Set distance to");
- gui_internal_widget_append(wl, wt);
- for(i=0;dist[i];i++) {
- paramnew=gui_internal_poi_param_clone(param);
- paramnew->dist+=dist[i];
- paramnew->count=it;
- snprintf(buffer, sizeof(buffer), " %i ", 10*(paramnew->dist+1));
- wt=gui_internal_label_new(this, buffer);
- gui_internal_widget_append(wl, wt);
- wt->func=gui_internal_cmd_pois_more;
- wt->data=paramnew;
- wt->data_free=gui_internal_poi_param_free;
- wt->state |= STATE_SENSITIVE;
- wt->c = wm->c;
- }
- wt=gui_internal_label_new(this, "km.");
- gui_internal_widget_append(wl, wt);
-
- }
- // Rendering now is needed to have table_data->bottomrow filled in.
- gui_internal_menu_render(this);
- td=wtable->data;
- if(td->bottom_row!=NULL)
- {
+void gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data) {
+ struct map_selection *sel,*selm;
+ struct coord c,center;
+ struct mapset_handle *h;
+ struct map *m;
+ struct map_rect *mr;
+ struct item *item;
+ struct widget *wi,*w,*w2,*wb, *wtable, *row;
+ enum projection pro=wm->c.pro;
+ struct poi_param *param;
+ int param_free=0;
+ int idist,dist;
+ struct selector *isel;
+ int pagenb;
+ int prevdist;
+ // Starting value and increment of count of items to be extracted
+ const int pagesize = 50;
+ int maxitem, it = 0, i;
+ struct item_data *items;
+ struct fibheap* fh = fh_makekeyheap();
+ int cnt = 0;
+ struct table_data *td;
+ struct widget *wl,*wt;
+ char buffer[32];
+ struct poi_param *paramnew;
+ struct attr route;
+ dbg(lvl_debug,"POIs...");
+ if(data) {
+ param = data;
+ } else {
+ param = g_new0(struct poi_param,1);
+ param_free=1;
+ }
+ if (navit_get_attr(this->nav, attr_route, &route, NULL)) {
+ struct attr route_status;
+ if (!route_get_attr(route.u.route, attr_route_status, &route_status, NULL) ||
+ (route_status.u.num != route_status_path_done_new &&
+ route_status.u.num != route_status_path_done_incremental))
+ route.u.route=NULL;
+ } else
+ route.u.route=NULL;
+ dist=10000*(param->dist+1);
+ isel = param->sel? &selectors[param->selnb]: NULL;
+ pagenb = param->pagenb;
+ prevdist=param->dist*10000;
+ maxitem = pagesize*(pagenb+1);
+ items= g_new0( struct item_data, maxitem);
+
+
+ dbg(lvl_debug, "Params: sel = %i, selnb = %i, pagenb = %i, dist = %i, filterstr = %s, AddressFilterType= %d",
+ param->sel, param->selnb, param->pagenb, param->dist, param->filterstr, param->AddressFilterType);
+
+ wb=gui_internal_menu(this, isel ? isel->name : _("POIs"));
+ w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ if (!isel && !param->filter)
+ gui_internal_widget_append(w, gui_internal_cmd_pois_selector(this,&wm->c,pagenb));
+ w2=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, w2);
+
+ sel=map_selection_rect_new(&wm->c,dist*transform_scale(abs(wm->c.y)+dist*1.5),18);
+ center.x=wm->c.x;
+ center.y=wm->c.y;
+ h=mapset_open(navit_get_mapset(this->nav));
+ while ((m=mapset_next(h, 1))) {
+ selm=map_selection_dup_pro(sel, pro, map_projection(m));
+ mr=map_rect_new(m, selm);
+ dbg(lvl_debug,"mr=%p", mr);
+ if (mr) {
+ while ((item=map_rect_get_item(mr))) {
+ if (gui_internal_cmd_pois_item_selected(param, item) &&
+ item_coord_get_pro(item, &c, 1, pro) &&
+ coord_rect_contains(&sel->u.c_rect, &c) &&
+ (idist=transform_distance(pro, &center, &c)) < dist) {
+ struct item_data *data;
+ struct attr attr;
+ char *label;
+ item_attr_rewind(item);
+ if (item->type==type_house_number) {
+ label=gui_internal_compose_item_address_string(item,1);
+ } else if (item_attr_get(item, attr_label, &attr)) {
+ label=map_convert_string(item->map,attr.u.str);
+ // Buildings which label is equal to addr:housenumber value
+ // are duplicated by item_house_number. Don't include such
+ // buildings into the list. This is true for OSM maps created with
+ // maptool patched with #859 latest patch.
+ // FIXME: For non-OSM maps, we probably would better don't skip these items.
+ if(item->type==type_poly_building && item_attr_get(item, attr_house_number, &attr) ) {
+ if(strcmp(label,map_convert_string_tmp(item->map,attr.u.str))==0) {
+ g_free(label);
+ continue;
+ }
+ }
+
+ } else {
+ label=g_strdup("");
+ }
+
+ if(it>=maxitem) {
+ data = fh_extractmin(fh);
+ g_free(data->label);
+ data->label=NULL;
+ } else {
+ data = &items[it++];
+ }
+ data->label=label;
+ data->item = *item;
+ data->c = c;
+ data->dist = idist;
+ // Key expression is a workaround to fight
+ // probable heap collisions when two objects
+ // are at the same distance. But it destroys
+ // right order of POIs 2048 km away from cener
+ // and if table grows more than 1024 rows.
+ fh_insertkey(fh, -((idist<<10) + cnt++), data);
+ if (it == maxitem)
+ dist = (-fh_minkey(fh))>>10;
+ }
+ }
+ map_rect_destroy(mr);
+ }
+ map_selection_destroy(selm);
+ }
+ map_selection_destroy(sel);
+ mapset_close(h);
+
+ wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
+ td=wtable->data;
+
+ gui_internal_widget_append(w2,wtable);
+
+ // Move items from heap to the table
+ for(i=0;; i++) {
+ int key = fh_minkey(fh);
+ struct item_data *data = fh_extractmin(fh);
+ if (data == NULL) {
+ dbg(lvl_debug, "Empty heap: maxitem = %i, it = %i, dist = %i", maxitem, it, dist);
+ break;
+ }
+ dbg(lvl_debug, "dist1: %i, dist2: %i", data->dist, (-key)>>10);
+ if(i==(it-pagesize*pagenb) && data->dist>prevdist)
+ prevdist=data->dist;
+ wi=gui_internal_cmd_pois_item(this, &center, &data->item, &data->c, route.u.route, data->dist, data->label);
+ wi->c.x=data->c.x;
+ wi->c.y=data->c.y;
+ wi->c.pro=pro;
+ wi->background=this->background;
+ row = gui_internal_widget_table_row_new(this,
+ gravity_left
+ | flags_fill
+ | orientation_horizontal);
+ gui_internal_widget_append(row,wi);
+ row->datai=data->dist;
+ gui_internal_widget_prepend(wtable,row);
+ g_free(data->label);
+ }
+
+ fh_deleteheap(fh);
+ free(items);
+
+ // Add an entry for more POI
+ row = gui_internal_widget_table_row_new(this,
+ gravity_left
+ | flags_fill
+ | orientation_horizontal);
+ row->datai=100000000; // Really far away for Earth, but won't work for bigger planets.
+ gui_internal_widget_append(wtable,row);
+ wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(row,wl);
+ if (it == maxitem) {
+ paramnew=gui_internal_poi_param_clone(param);
+ paramnew->pagenb++;
+ paramnew->count=it;
+ snprintf(buffer, sizeof(buffer), "Get more (up to %d items)...", (paramnew->pagenb+1)*pagesize);
+ wt=gui_internal_label_new(this, buffer);
+ gui_internal_widget_append(wl, wt);
+ wt->func=gui_internal_cmd_pois_more;
+ wt->data=paramnew;
+ wt->data_free=gui_internal_poi_param_free;
+ wt->state |= STATE_SENSITIVE;
+ wt->c = wm->c;
+ } else {
+ static int dist[]= {1,5,10,0};
+ wt=gui_internal_label_new(this, "Set distance to");
+ gui_internal_widget_append(wl, wt);
+ for(i=0; dist[i]; i++) {
+ paramnew=gui_internal_poi_param_clone(param);
+ paramnew->dist+=dist[i];
+ paramnew->count=it;
+ snprintf(buffer, sizeof(buffer), " %i ", 10*(paramnew->dist+1));
+ wt=gui_internal_label_new(this, buffer);
+ gui_internal_widget_append(wl, wt);
+ wt->func=gui_internal_cmd_pois_more;
+ wt->data=paramnew;
+ wt->data_free=gui_internal_poi_param_free;
+ wt->state |= STATE_SENSITIVE;
+ wt->c = wm->c;
+ }
+ wt=gui_internal_label_new(this, "km.");
+ gui_internal_widget_append(wl, wt);
+
+ }
+ // Rendering now is needed to have table_data->bottomrow filled in.
+ gui_internal_menu_render(this);
+ td=wtable->data;
+ if(td->bottom_row!=NULL) {
#if 0
- while(((struct widget*)td->bottom_row->data)->datai<=prevdist
- && (td->next_button->state & STATE_SENSITIVE))
- {
- gui_internal_table_button_next(this, td->next_button, NULL);
- }
+ while(((struct widget*)td->bottom_row->data)->datai<=prevdist
+ && (td->next_button->state & STATE_SENSITIVE)) {
+ gui_internal_table_button_next(this, td->next_button, NULL);
+ }
#else
- int firstrow=g_list_index(wtable->children, td->top_row->data);
- while(firstrow>=0) {
- int currow=g_list_index(wtable->children, td->bottom_row->data) - firstrow;
- if(currow<0) {
- dbg(lvl_debug,"Can't find bottom row in children list. Stop paging.\n");
- break;
- }
- if(currow>=param->count)
- break;
- if(!(td->scroll_buttons.next_button->state & STATE_SENSITIVE)) {
- dbg(lvl_debug,"Reached last page but item %i not found. Stop paging.\n",param->count);
- break;
- }
- gui_internal_table_button_next(this, td->scroll_buttons.next_button, NULL);
- }
+ int firstrow=g_list_index(wtable->children, td->top_row->data);
+ while(firstrow>=0) {
+ int currow=g_list_index(wtable->children, td->bottom_row->data) - firstrow;
+ if(currow<0) {
+ dbg(lvl_debug,"Can't find bottom row in children list. Stop paging.");
+ break;
+ }
+ if(currow>=param->count)
+ break;
+ if(!(td->scroll_buttons.next_button->state & STATE_SENSITIVE)) {
+ dbg(lvl_debug,"Reached last page but item %i not found. Stop paging.",param->count);
+ break;
+ }
+ gui_internal_table_button_next(this, td->scroll_buttons.next_button, NULL);
+ }
#endif
- }
- gui_internal_menu_render(this);
- if(param_free)
- g_free(param);
+ }
+ gui_internal_menu_render(this);
+ if(param_free)
+ g_free(param);
}
diff --git a/navit/gui/internal/gui_internal_poi.h b/navit/gui/internal/gui_internal_poi.h
index 665f44a70..c2515a1c6 100644
--- a/navit/gui/internal/gui_internal_poi.h
+++ b/navit/gui/internal/gui_internal_poi.h
@@ -6,40 +6,40 @@
struct poi_param {
- /**
- * =1 if selnb is defined, 0 otherwize.
- */
- unsigned char sel;
+ /**
+ * =1 if selnb is defined, 0 otherwize.
+ */
+ unsigned char sel;
- /**
- * Index to struct selector selectors[], shows what type of POIs is defined.
- */
- unsigned char selnb;
- /**
- * Page number to display.
- */
- unsigned char pagenb;
- /**
- * Radius (number of 10-kilometer intervals) to search for POIs.
- */
- unsigned char dist;
- /**
- * Should filter phrase be compared to postal address of the POI.
- * =0 - name filter, =1 - address filter, =2 - address filter, including postal code
- */
- unsigned char AddressFilterType;
- /**
- * Filter string, casefold()ed and divided into substrings at the spaces, which are replaced by ASCII 0*.
- */
- char *filterstr;
- /**
- * list of pointers to individual substrings of filterstr.
- */
- GList *filter;
- /**
- * Number of POIs in this list
- */
- int count;
+ /**
+ * Index to struct selector selectors[], shows what type of POIs is defined.
+ */
+ unsigned char selnb;
+ /**
+ * Page number to display.
+ */
+ unsigned char pagenb;
+ /**
+ * Radius (number of 10-kilometer intervals) to search for POIs.
+ */
+ unsigned char dist;
+ /**
+ * Should filter phrase be compared to postal address of the POI.
+ * =0 - name filter, =1 - address filter, =2 - address filter, including postal code
+ */
+ unsigned char AddressFilterType;
+ /**
+ * Filter string, casefold()ed and divided into substrings at the spaces, which are replaced by ASCII 0*.
+ */
+ char *filterstr;
+ /**
+ * list of pointers to individual substrings of filterstr.
+ */
+ GList *filter;
+ /**
+ * Number of POIs in this list
+ */
+ int count;
};
/* prototypes */
@@ -50,7 +50,8 @@ struct poi_param;
struct widget;
void gui_internal_poi_param_free(void *p);
void gui_internal_poi_param_set_filter(struct poi_param *param, char *text);
-struct widget *gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c, struct route *route, int dist, char *name);
+struct widget *gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item,
+ struct coord *c, struct route *route, int dist, char *name);
char *gui_internal_compose_item_address_string(struct item *item, int prependPostal);
void gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data);
void gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data);
diff --git a/navit/gui/internal/gui_internal_priv.h b/navit/gui/internal/gui_internal_priv.h
index 37b09d62a..d28cac649 100644
--- a/navit/gui/internal/gui_internal_priv.h
+++ b/navit/gui/internal/gui_internal_priv.h
@@ -6,33 +6,33 @@
*/
struct gui_config_settings {
- /**
- * The base size (in fractions of a point) to use for text.
- */
- int font_size;
- /**
- * The size (in pixels) that xs style icons should be scaled to.
- * This icon size is typically used in various lists and should be set to value which allows a list row to be easily cliked or dragged.
- */
- int icon_xs;
- /**
- * The size (in pixels) that s style icons (small) should be scaled to, used for the menu top row icons
- */
- int icon_s;
- /**
- * The size (in pixels) that l style icons should be scaled to, used for icons defined in the menu html
- */
- int icon_l;
- /**
- * The default amount of spacing (in pixels) to place between GUI elements.
- */
- int spacing;
+ /**
+ * The base size (in fractions of a point) to use for text.
+ */
+ int font_size;
+ /**
+ * The size (in pixels) that xs style icons should be scaled to.
+ * This icon size is typically used in various lists and should be set to value which allows a list row to be easily cliked or dragged.
+ */
+ int icon_xs;
+ /**
+ * The size (in pixels) that s style icons (small) should be scaled to, used for the menu top row icons
+ */
+ int icon_s;
+ /**
+ * The size (in pixels) that l style icons should be scaled to, used for icons defined in the menu html
+ */
+ int icon_l;
+ /**
+ * The default amount of spacing (in pixels) to place between GUI elements.
+ */
+ int spacing;
};
struct route_data {
- struct widget * route_table;
- int route_showing;
+ struct widget * route_table;
+ int route_showing;
};
/**
@@ -41,136 +41,136 @@ struct route_data {
* @author Martin Schaller (04/2008)
*/
struct gui_priv {
- struct navit *nav;
- struct attr self;
- struct window *win;
- struct graphics *gra;
- struct graphics_gc *background;
- struct graphics_gc *background2;
- struct graphics_gc *highlight_background;
- struct graphics_gc *foreground;
- struct graphics_gc *text_foreground;
- struct graphics_gc *text_background;
- struct color background_color, background2_color, text_foreground_color, text_background_color;
- int spacing;
- int font_size;
- char *font_name;
- int fullscreen;
- struct graphics_font *fonts[3];
- int icon_xs; /**< The size (in pixels) that xs style icons should be scaled to.
+ struct navit *nav;
+ struct attr self;
+ struct window *win;
+ struct graphics *gra;
+ struct graphics_gc *background;
+ struct graphics_gc *background2;
+ struct graphics_gc *highlight_background;
+ struct graphics_gc *foreground;
+ struct graphics_gc *text_foreground;
+ struct graphics_gc *text_background;
+ struct color background_color, background2_color, text_foreground_color, text_background_color;
+ int spacing;
+ int font_size;
+ char *font_name;
+ int fullscreen;
+ struct graphics_font *fonts[3];
+ int icon_xs; /**< The size (in pixels) that xs style icons should be scaled to.
* This icon size can be too small to click it on some devices.
*/
- int icon_s; /**< The size (in pixels) that s style icons (small) should be scaled to */
- int icon_l; /**< The size (in pixels) that l style icons should be scaled to */
- int pressed;
- struct widget *widgets;
- int widgets_count;
- int redraw;
- struct widget root;
- struct widget *highlighted,*editable;
- struct widget *highlighted_menu;
- struct pcoord clickp, vehiclep;
- struct attr *click_coord_geo, *position_coord_geo;
- struct search_list *sl;
- int ignore_button;
- int menu_on_map_click;
- char *on_map_click;
- int signal_on_map_click;
- char *country_iso2;
- int speech;
- int keyboard; /**< Whether the internal GUI keyboard is enabled */
- int keyboard_required; /**< Whether keyboard input is needed. This is only used by the
+ int icon_s; /**< The size (in pixels) that s style icons (small) should be scaled to */
+ int icon_l; /**< The size (in pixels) that l style icons should be scaled to */
+ int pressed;
+ struct widget *widgets;
+ int widgets_count;
+ int redraw;
+ struct widget root;
+ struct widget *highlighted,*editable;
+ struct widget *highlighted_menu;
+ struct pcoord clickp, vehiclep;
+ struct attr *click_coord_geo, *position_coord_geo;
+ struct search_list *sl;
+ int ignore_button;
+ int menu_on_map_click;
+ char *on_map_click;
+ int signal_on_map_click;
+ char *country_iso2;
+ int speech;
+ int keyboard; /**< Whether the internal GUI keyboard is enabled */
+ int keyboard_required; /**< Whether keyboard input is needed. This is only used by the
* HTML menu, text entry dialogs do not use this member.
*/
- struct gui_config_settings config; /**< The setting information read from the configuration file.
+ struct gui_config_settings config; /**< The setting information read from the configuration file.
* values of -1 indicate no value was specified in the config file.
*/
- struct event_idle *idle;
- struct callback *motion_cb,*button_cb,*resize_cb,*keypress_cb,*window_closed_cb,*idle_cb, *motion_timeout_callback;
- struct event_timeout *motion_timeout_event;
- struct point current;
+ struct event_idle *idle;
+ struct callback *motion_cb,*button_cb,*resize_cb,*keypress_cb,*window_closed_cb,*idle_cb, *motion_timeout_callback;
+ struct event_timeout *motion_timeout_event;
+ struct point current;
- struct callback * vehicle_cb;
- struct route_data route_data; /**< Stores information about the route. */
+ struct callback * vehicle_cb;
+ struct route_data route_data; /**< Stores information about the route. */
- struct gui_internal_data data;
- struct callback_list *cbl;
- int flags;
- int cols;
- struct attr osd_configuration; /**< The OSD configuration, a set of flags controlling which OSD
+ struct gui_internal_data data;
+ struct callback_list *cbl;
+ int flags;
+ int cols;
+ struct attr osd_configuration; /**< The OSD configuration, a set of flags controlling which OSD
* items will be visible.
*/
- int pitch; /**< The pitch for the 3D map view. */
- int flags_town,flags_street,flags_house_number;
- int radius;
- int mouse_button_clicked_on_map;
-/* html */
- char *html_text;
- int html_depth;
- struct widget *html_container;
- int html_skip;
- char *html_anchor;
- char *href;
- int html_anchor_found;
- struct form *form;
- struct html {
- int skip;
- enum html_tag {
- html_tag_none,
- html_tag_a,
- html_tag_h1,
- html_tag_html,
- html_tag_img,
- html_tag_script,
- html_tag_form,
- html_tag_input,
- html_tag_div,
- } tag;
- char *command;
- char *name;
- char *href;
- char *refresh_cond;
- char *class;
- int font_size;
- struct widget *w;
- struct widget *container;
- } html[10];
+ int pitch; /**< The pitch for the 3D map view. */
+ int flags_town,flags_street,flags_house_number;
+ int radius;
+ int mouse_button_clicked_on_map;
+ /* html */
+ char *html_text;
+ int html_depth;
+ struct widget *html_container;
+ int html_skip;
+ char *html_anchor;
+ char *href;
+ int html_anchor_found;
+ struct form *form;
+ struct html {
+ int skip;
+ enum html_tag {
+ html_tag_none,
+ html_tag_a,
+ html_tag_h1,
+ html_tag_html,
+ html_tag_img,
+ html_tag_script,
+ html_tag_form,
+ html_tag_input,
+ html_tag_div,
+ } tag;
+ char *command;
+ char *name;
+ char *href;
+ char *refresh_cond;
+ char *class;
+ int font_size;
+ struct widget *w;
+ struct widget *container;
+ } html[10];
-/* gestures */
+ /* gestures */
- struct gesture_elem {
- long long msec;
- struct point p;
- } gesture_ring[GESTURE_RINGSIZE];
- int gesture_ring_last, gesture_ring_first;
+ struct gesture_elem {
+ long long msec;
+ struct point p;
+ } gesture_ring[GESTURE_RINGSIZE];
+ int gesture_ring_last, gesture_ring_first;
- int hide_keys; //Flag to set the keyboard mode 1: hide impossible keys on search; 0: highlight them.
- int results_map_population;
+ int hide_keys; //Flag to set the keyboard mode 1: hide impossible keys on search; 0: highlight them.
+ int results_map_population;
};
struct menu_data {
- struct widget *search_list;
- struct widget *keyboard;
- struct widget *button_bar;
- struct widget *menu;
- int keyboard_mode;
- void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
- struct widget *redisplay_widget;
- char *href;
- struct attr refresh_callback_obj,refresh_callback;
+ struct widget *search_list;
+ struct widget *keyboard;
+ struct widget *button_bar;
+ struct widget *menu;
+ int keyboard_mode;
+ void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
+ struct widget *redisplay_widget;
+ char *href;
+ struct attr refresh_callback_obj,refresh_callback;
};
struct heightline {
- struct heightline *next;
- int height;
- struct coord_rect bbox;
- int count;
- struct coord c[0];
+ struct heightline *next;
+ int height;
+ struct coord_rect bbox;
+ int count;
+ struct coord c[0];
};
struct diagram_point {
- struct diagram_point *next;
- struct coord c;
+ struct diagram_point *next;
+ struct coord c;
};
/* prototypes */
enum flags;
@@ -190,18 +190,22 @@ struct widget;
struct graphics_image *image_new_xs(struct gui_priv *this, const char *name);
struct graphics_image *image_new_s(struct gui_priv *this, const char *name);
struct graphics_image *image_new_l(struct gui_priv *this, const char *name);
-struct widget *gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct attr *on, struct attr *off);
-struct widget *gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct map *map, struct attr *on, struct attr *off, int deflt);
+struct widget *gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags,
+ struct attr *on, struct attr *off);
+struct widget *gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags,
+ struct map *map, struct attr *on, struct attr *off, int deflt);
void gui_internal_say(struct gui_priv *this, struct widget *w, int questionmark);
void gui_internal_back(struct gui_priv *this, struct widget *w, void *data);
void gui_internal_cmd_return(struct gui_priv *this, struct widget *wm, void *data);
void gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data);
struct widget *gui_internal_time_help(struct gui_priv *this);
void gui_internal_apply_config(struct gui_priv *this);
-void gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_, void (*cmd)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
+void gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_,
+ void (*cmd)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
void gui_internal_call_linked_on_finish(struct gui_priv *this, struct widget *wm, void *data);
char *removecase(char *s);
-void gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in, struct widget *wm, const char *name, int flags);
+void gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in,
+ struct widget *wm, const char *name, int flags);
void gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data);
void gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data);
void gui_internal_keypress_do(struct gui_priv *this, char *key);
diff --git a/navit/gui/internal/gui_internal_search.c b/navit/gui/internal/gui_internal_search.c
index ceeeb7438..c90d4b22d 100644
--- a/navit/gui/internal/gui_internal_search.c
+++ b/navit/gui/internal/gui_internal_search.c
@@ -22,325 +22,302 @@
#include "gui_internal_keyboard.h"
#include "gui_internal_search.h"
-static void
-gui_internal_search_country(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_prune_menu_count(this, 1, 0);
- gui_internal_search(this,_("Country"),"Country",0);
+static void gui_internal_search_country(struct gui_priv *this, struct widget *widget, void *data) {
+ gui_internal_prune_menu_count(this, 1, 0);
+ gui_internal_search(this,_("Country"),"Country",0);
}
-static void
-gui_internal_search_town(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (this->sl)
- search_list_select(this->sl, attr_country_all, 0, 0);
- g_free(this->country_iso2);
- this->country_iso2=NULL;
- gui_internal_search(this,_("Town"),"Town",0);
+static void gui_internal_search_town(struct gui_priv *this, struct widget *wm, void *data) {
+ if (this->sl)
+ search_list_select(this->sl, attr_country_all, 0, 0);
+ g_free(this->country_iso2);
+ this->country_iso2=NULL;
+ gui_internal_search(this,_("Town"),"Town",0);
}
-static void
-gui_internal_search_street(struct gui_priv *this, struct widget *widget, void *data)
-{
- search_list_select(this->sl, attr_town_or_district_name, 0, 0);
- gui_internal_search(this,_("Street"),"Street",0);
+static void gui_internal_search_street(struct gui_priv *this, struct widget *widget, void *data) {
+ search_list_select(this->sl, attr_town_or_district_name, 0, 0);
+ gui_internal_search(this,_("Street"),"Street",0);
}
-static void
-gui_internal_search_house_number(struct gui_priv *this, struct widget *widget, void *data)
-{
- search_list_select(this->sl, attr_street_name, 0, 0);
- gui_internal_search(this,_("House number"),"House number",0);
+static void gui_internal_search_house_number(struct gui_priv *this, struct widget *widget, void *data) {
+ search_list_select(this->sl, attr_street_name, 0, 0);
+ gui_internal_search(this,_("House number"),"House number",0);
}
-void
-gui_internal_search_idle_end(struct gui_priv *this)
-{
- if (this->idle) {
- event_remove_idle(this->idle);
- this->idle=NULL;
- }
- if (this->idle_cb) {
- callback_destroy(this->idle_cb);
- this->idle_cb=NULL;
- }
+void gui_internal_search_idle_end(struct gui_priv *this) {
+ if (this->idle) {
+ event_remove_idle(this->idle);
+ this->idle=NULL;
+ }
+ if (this->idle_cb) {
+ callback_destroy(this->idle_cb);
+ this->idle_cb=NULL;
+ }
}
-static int
-gui_internal_search_cmp(gconstpointer _a, gconstpointer _b)
-{
- struct widget *a=(struct widget *)_a, *b=(struct widget *)_b;
- char *sa,*sb;
- int r;
- if(!b)
- if((!a || a->type!=widget_table_row || !a->text) && (!b || b->type!=widget_table_row || !b->text))
- return 0;
- if(!a || a->type!=widget_table_row || !a->text)
- return -1;
- if(!b || b->type!=widget_table_row || !b->text)
- return 1;
- r=a->datai-b->datai;
- if(r<0)
- return -1;
- if(r>0)
- return 1;
- sa=removecase(a->text);
- sb=removecase(b->text);
- r=strcmp(sa,sb);
- dbg(lvl_debug,"%s %s %d\n",sa,sb,r);
- g_free(sa);
- g_free(sb);
- return r;
+static int gui_internal_search_cmp(gconstpointer _a, gconstpointer _b) {
+ struct widget *a=(struct widget *)_a, *b=(struct widget *)_b;
+ char *sa,*sb;
+ int r;
+ if(!b)
+ if((!a || a->type!=widget_table_row || !a->text) && (!b || b->type!=widget_table_row || !b->text))
+ return 0;
+ if(!a || a->type!=widget_table_row || !a->text)
+ return -1;
+ if(!b || b->type!=widget_table_row || !b->text)
+ return 1;
+ r=a->datai-b->datai;
+ if(r<0)
+ return -1;
+ if(r>0)
+ return 1;
+ sa=removecase(a->text);
+ sb=removecase(b->text);
+ r=strcmp(sa,sb);
+ dbg(lvl_debug,"%s %s %d",sa,sb,r);
+ g_free(sa);
+ g_free(sb);
+ return r;
}
-static char *
-postal_str(struct search_list_result *res, int level)
-{
- char *ret=NULL;
- if (res->town->common.postal)
- ret=res->town->common.postal;
- if (res->town->common.postal_mask)
- ret=res->town->common.postal_mask;
- if (level == 1)
- return ret;
- if (res->street->common.postal)
- ret=res->street->common.postal;
- if (res->street->common.postal_mask)
- ret=res->street->common.postal_mask;
- if (level == 2)
- return ret;
- if (res->house_number->common.postal)
- ret=res->house_number->common.postal;
- if (res->house_number->common.postal_mask)
- ret=res->house_number->common.postal_mask;
- return ret;
+static char *postal_str(struct search_list_result *res, int level) {
+ char *ret=NULL;
+ if (res->town->common.postal)
+ ret=res->town->common.postal;
+ if (res->town->common.postal_mask)
+ ret=res->town->common.postal_mask;
+ if (level == 1)
+ return ret;
+ if (res->street->common.postal)
+ ret=res->street->common.postal;
+ if (res->street->common.postal_mask)
+ ret=res->street->common.postal_mask;
+ if (level == 2)
+ return ret;
+ if (res->house_number->common.postal)
+ ret=res->house_number->common.postal;
+ if (res->house_number->common.postal_mask)
+ ret=res->house_number->common.postal_mask;
+ return ret;
}
-static char *
-get_string_from_attr_list(struct attr **attrs, enum attr_type type, char *dflt)
-{
- struct attr attr;
- if(attr_generic_get_attr(attrs,NULL,type,&attr,NULL))
- return attr.u.str;
- else
- return dflt;
+static char *get_string_from_attr_list(struct attr **attrs, enum attr_type type, char *dflt) {
+ struct attr attr;
+ if(attr_generic_get_attr(attrs,NULL,type,&attr,NULL))
+ return attr.u.str;
+ else
+ return dflt;
}
-static char *
-district_str(struct search_list_result *res, int level, enum attr_type district, char *dflt)
-{
- char *ret=dflt;
+static char *district_str(struct search_list_result *res, int level, enum attr_type district, char *dflt) {
+ char *ret=dflt;
- ret=get_string_from_attr_list(res->town->common.attrs, district, ret);
- if (level == 1)
- return ret;
+ ret=get_string_from_attr_list(res->town->common.attrs, district, ret);
+ if (level == 1)
+ return ret;
- ret=get_string_from_attr_list(res->street->common.attrs, district, ret);
+ ret=get_string_from_attr_list(res->street->common.attrs, district, ret);
- if (level == 2)
- return ret;
+ if (level == 2)
+ return ret;
- ret=get_string_from_attr_list(res->house_number->common.attrs, district, ret);
-
- return ret;
+ ret=get_string_from_attr_list(res->house_number->common.attrs, district, ret);
+
+ return ret;
}
-static char *
-town_display_label(struct search_list_result *res, int level, int flags)
-{
- char *town=district_str(res, level,attr_town_name,"");
- char *district=district_str(res, level,attr_district_name,NULL);
- char *postal=postal_str(res, level);
- char *postal_sep=" ";
- char *district_begin=" (";
- char *district_end=")";
- char *county_sep = ", ";
- char *county = res->town->common.county_name;
-
- if (!postal)
- postal_sep=postal="";
- if (!district || (flags & 1))
- district_begin=district_end=district="";
- if (!county || !strcmp(county, town))
- county_sep=county="";
-
- if(level==1 ) {
- if(flags & 2) {
- int n=0;
- char *s[10]={NULL};
-
- s[n]=district_str(res, level, attr_state_name, NULL);
- if(s[n])
- n++;
- s[n]=district_str(res, level, attr_county_name, NULL);
- if(s[n])
- n++;
- s[n]=district_str(res, level, attr_municipality_name, NULL);
- if(s[n])
- n++;
-
- return g_strjoinv(", ",s);
- }
- county=county_sep="";
- }
-
- return g_strdup_printf("%s%s%s%s%s%s%s%s", postal, postal_sep, town, district_begin, district, district_end, county_sep, county);
+static char *town_display_label(struct search_list_result *res, int level, int flags) {
+ char *town=district_str(res, level,attr_town_name,"");
+ char *district=district_str(res, level,attr_district_name,NULL);
+ char *postal=postal_str(res, level);
+ char *postal_sep=" ";
+ char *district_begin=" (";
+ char *district_end=")";
+ char *county_sep = ", ";
+ char *county = res->town->common.county_name;
+
+ if (!postal)
+ postal_sep=postal="";
+ if (!district || (flags & 1))
+ district_begin=district_end=district="";
+ if (!county || !strcmp(county, town))
+ county_sep=county="";
+
+ if(level==1 ) {
+ if(flags & 2) {
+ int n=0;
+ char *s[10]= {NULL};
+
+ s[n]=district_str(res, level, attr_state_name, NULL);
+ if(s[n])
+ n++;
+ s[n]=district_str(res, level, attr_county_name, NULL);
+ if(s[n])
+ n++;
+ s[n]=district_str(res, level, attr_municipality_name, NULL);
+ if(s[n])
+ n++;
+
+ return g_strjoinv(", ",s);
+ }
+ county=county_sep="";
+ }
+
+ return g_strdup_printf("%s%s%s%s%s%s%s%s", postal, postal_sep, town, district_begin, district, district_end, county_sep,
+ county);
}
-static void
-gui_internal_find_next_possible_key(char *search_text, char *wm_name, char *possible_keys, char *item_name)
-{
- gchar* trunk_name;
- if (item_name) {
-
- trunk_name = linguistics_expand_special(item_name,1);
- if(!trunk_name){
- trunk_name = g_strrstr(item_name, search_text);
- }
-
- if (trunk_name) {
- int next_char_pos = strlen(search_text);
- char next_char = trunk_name[next_char_pos];
- int i;
- int len = strlen(possible_keys);
-
- for(i = 0; (i<len) && (possible_keys[i] != next_char) ;i++) ;
-
- if ((i==len || !len) && !strncmp(trunk_name, search_text, next_char_pos)) {
- possible_keys[len]=trunk_name[next_char_pos];
- possible_keys[len+1]='\0';
- }
- dbg(lvl_info,"searching for %s, found: %s, currently possible_keys: %s \n", search_text, item_name, possible_keys);
- }
- }
+static void gui_internal_find_next_possible_key(char *search_text, char *wm_name, char *possible_keys,
+ char *item_name) {
+ gchar* trunk_name;
+ if (item_name) {
+
+ trunk_name = linguistics_expand_special(item_name,1);
+ if(!trunk_name) {
+ trunk_name = g_strrstr(item_name, search_text);
+ }
+
+ if (trunk_name) {
+ int next_char_pos = strlen(search_text);
+ char next_char = trunk_name[next_char_pos];
+ int i;
+ int len = strlen(possible_keys);
+
+ for(i = 0; (i<len) && (possible_keys[i] != next_char) ; i++) ;
+
+ if ((i==len || !len) && !strncmp(trunk_name, search_text, next_char_pos)) {
+ possible_keys[len]=trunk_name[next_char_pos];
+ possible_keys[len+1]='\0';
+ }
+ dbg(lvl_info,"searching for %s, found: %s, currently possible_keys: %s ", search_text, item_name, possible_keys);
+ }
+ }
}
-static void
-gui_internal_highlight_possible_keys(struct gui_priv *this, char *possible_keys)
-{
- struct menu_data *md;
- int first_available_key_found = 0;
-
- if (!this->keyboard)
- return;
-
- md=gui_internal_menu_data(this);
- if (md && md->keyboard && !(this->flags & 2048)) {
- GList *lk=md->keyboard->children;
- graphics_draw_mode(this->gra, draw_mode_begin);
- while (lk) {
- struct widget *child=lk->data;
- GList *lk2=child->children;
- while (lk2) {
- struct widget *child_=lk2->data;
- lk2=g_list_next(lk2);
- // The data_free part is an evil hack based on the observation that
- // regular keys have set it to non-NULL whereas special keys appear
- // to have it set to NULL.
- if (child_->data && strcmp("\b", child_->data) && child_->data_free) {
- if ( (strlen(possible_keys) == 0) ||
- (g_strrstr(possible_keys, child_->data)!=NULL ) ) {
- if(this->hide_keys){
- child_->state|= STATE_SENSITIVE|STATE_CLEAR ;
- child_->state&= ~(STATE_INVISIBLE);
- }else{
- child_->state|= STATE_SENSITIVE|STATE_CLEAR|STATE_HIGHLIGHTED ;
- }
- // Select and highlight the first possible button.
- if (!first_available_key_found) {
- gui_internal_highlight_do(this, child_);
- first_available_key_found=1;
- }
- } else {
- if(this->hide_keys){
- child_->state&= ~(STATE_SELECTED|STATE_SENSITIVE) ;
- child_->state|= STATE_INVISIBLE;
- }else{
- child_->state&= ~(STATE_HIGHLIGHTED);
- }
- }
- gui_internal_widget_render(this,child_);
- }
- }
- lk=g_list_next(lk);
- }
- gui_internal_widget_render(this,md->keyboard);
- graphics_draw_mode(this->gra, draw_mode_end);
- }
+static void gui_internal_highlight_possible_keys(struct gui_priv *this, char *possible_keys) {
+ struct menu_data *md;
+ int first_available_key_found = 0;
+
+ if (!this->keyboard)
+ return;
+
+ md=gui_internal_menu_data(this);
+ if (md && md->keyboard && !(this->flags & 2048)) {
+ GList *lk=md->keyboard->children;
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ while (lk) {
+ struct widget *child=lk->data;
+ GList *lk2=child->children;
+ while (lk2) {
+ struct widget *child_=lk2->data;
+ lk2=g_list_next(lk2);
+ // The data_free part is an evil hack based on the observation that
+ // regular keys have set it to non-NULL whereas special keys appear
+ // to have it set to NULL.
+ if (child_->data && strcmp("\b", child_->data) && child_->data_free) {
+ if ( (strlen(possible_keys) == 0) ||
+ (g_strrstr(possible_keys, child_->data)!=NULL ) ) {
+ if(this->hide_keys) {
+ child_->state|= STATE_SENSITIVE|STATE_CLEAR ;
+ child_->state&= ~(STATE_INVISIBLE);
+ } else {
+ child_->state|= STATE_SENSITIVE|STATE_CLEAR|STATE_HIGHLIGHTED ;
+ }
+ // Select and highlight the first possible button.
+ if (!first_available_key_found) {
+ gui_internal_highlight_do(this, child_);
+ first_available_key_found=1;
+ }
+ } else {
+ if(this->hide_keys) {
+ child_->state&= ~(STATE_SELECTED|STATE_SENSITIVE) ;
+ child_->state|= STATE_INVISIBLE;
+ } else {
+ child_->state&= ~(STATE_HIGHLIGHTED);
+ }
+ }
+ gui_internal_widget_render(this,child_);
+ }
+ }
+ lk=g_list_next(lk);
+ }
+ gui_internal_widget_render(this,md->keyboard);
+ graphics_draw_mode(this->gra, draw_mode_end);
+ }
}
-static int
-gui_internal_get_match_quality(char *item_name, char* search_text, int is_house_number_without_street)
-{
- enum match_quality {
- full_string_match, word_match, substring_match, housenum_but_no_street_match }
- match_quality;
- if (is_house_number_without_street) {
- match_quality=housenum_but_no_street_match;
- } else if(item_name) {
- int i;
- char *folded_name=linguistics_casefold(item_name);
- char *folded_query=linguistics_casefold(search_text);
- match_quality=substring_match;
-
- for(i=0; i<3 ;i++) {
- char *exp=linguistics_expand_special(folded_name,i);
- char *p;
- if(!exp)
- continue;
- if(!strcmp(exp,folded_query)) {
- dbg(lvl_debug,"exact match for the whole string %s\n", exp);
- match_quality=full_string_match;
- g_free(exp);
- break;
- }
- if((p=strstr(exp,folded_query))!=NULL) {
- p+=strlen(folded_query);
- if(!*p||strchr(LINGUISTICS_WORD_SEPARATORS_ASCII,*p)) {
- dbg(lvl_debug,"exact matching word found inside string %s\n",exp);
- match_quality=word_match;
- }
- }
- g_free(exp);
- }
- g_free(folded_name);
- g_free(folded_query);
- }
- return match_quality;
+static int gui_internal_get_match_quality(char *item_name, char* search_text, int is_house_number_without_street) {
+ enum match_quality {
+ full_string_match, word_match, substring_match, housenum_but_no_street_match
+ }
+ match_quality;
+ if (is_house_number_without_street) {
+ match_quality=housenum_but_no_street_match;
+ } else if(item_name) {
+ int i;
+ char *folded_name=linguistics_casefold(item_name);
+ char *folded_query=linguistics_casefold(search_text);
+ match_quality=substring_match;
+
+ for(i=0; i<3 ; i++) {
+ char *exp=linguistics_expand_special(folded_name,i);
+ char *p;
+ if(!exp)
+ continue;
+ if(!strcmp(exp,folded_query)) {
+ dbg(lvl_debug,"exact match for the whole string %s", exp);
+ match_quality=full_string_match;
+ g_free(exp);
+ break;
+ }
+ if((p=strstr(exp,folded_query))!=NULL) {
+ p+=strlen(folded_query);
+ if(!*p||strchr(LINGUISTICS_WORD_SEPARATORS_ASCII,*p)) {
+ dbg(lvl_debug,"exact matching word found inside string %s",exp);
+ match_quality=word_match;
+ }
+ }
+ g_free(exp);
+ }
+ g_free(folded_name);
+ g_free(folded_query);
+ }
+ return match_quality;
}
-static struct widget*
-gui_internal_create_resultlist_entry(struct gui_priv *this, struct search_list_result *res, char *result_main_label, char *result_sublabel, void *param, char *widget_name, struct item *item)
-{
- struct widget *resultlist_entry;
- if(result_sublabel) {
- struct widget *entry_sublabel;
- resultlist_entry=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(resultlist_entry,
- gui_internal_image_new(this, image_new_xs(this, res->country->flag)));
- entry_sublabel=gui_internal_box_new(this, gravity_left_center|orientation_vertical|flags_fill);
- gui_internal_widget_append(resultlist_entry, entry_sublabel);
- gui_internal_widget_append(entry_sublabel, gui_internal_label_new(this, result_main_label));
- gui_internal_widget_append(entry_sublabel, gui_internal_label_font_new(this, result_sublabel, 1));
- resultlist_entry->func=gui_internal_cmd_position;
- resultlist_entry->data=param;
- resultlist_entry->state |= STATE_SENSITIVE;
- resultlist_entry->speech=g_strdup(result_main_label);
- } else {
- resultlist_entry=gui_internal_button_new_with_callback(this, result_main_label,
- image_new_xs(this, res->country->flag),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_position, param);
- }
- resultlist_entry->name=widget_name;
- if (res->c)
- resultlist_entry->c=*res->c;
- resultlist_entry->selection_id=res->id;
- if (item)
- resultlist_entry->item=*item;
-
- return resultlist_entry;
+static struct widget* gui_internal_create_resultlist_entry(struct gui_priv *this, struct search_list_result *res,
+ char *result_main_label,
+ char *result_sublabel, void *param, char *widget_name, struct item *item) {
+ struct widget *resultlist_entry;
+ if(result_sublabel) {
+ struct widget *entry_sublabel;
+ resultlist_entry=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(resultlist_entry,
+ gui_internal_image_new(this, image_new_xs(this, res->country->flag)));
+ entry_sublabel=gui_internal_box_new(this, gravity_left_center|orientation_vertical|flags_fill);
+ gui_internal_widget_append(resultlist_entry, entry_sublabel);
+ gui_internal_widget_append(entry_sublabel, gui_internal_label_new(this, result_main_label));
+ gui_internal_widget_append(entry_sublabel, gui_internal_label_font_new(this, result_sublabel, 1));
+ resultlist_entry->func=gui_internal_cmd_position;
+ resultlist_entry->data=param;
+ resultlist_entry->state |= STATE_SENSITIVE;
+ resultlist_entry->speech=g_strdup(result_main_label);
+ } else {
+ resultlist_entry=gui_internal_button_new_with_callback(this, result_main_label,
+ image_new_xs(this, res->country->flag),
+ gravity_left_center|orientation_horizontal|flags_fill,
+ gui_internal_cmd_position, param);
+ }
+ resultlist_entry->name=widget_name;
+ if (res->c)
+ resultlist_entry->c=*res->c;
+ resultlist_entry->selection_id=res->id;
+ if (item)
+ resultlist_entry->item=*item;
+
+ return resultlist_entry;
}
/**
@@ -348,288 +325,270 @@ gui_internal_create_resultlist_entry(struct gui_priv *this, struct search_list_r
*/
char possible_keys_incremental_search[256]="";
-static void
-gui_internal_search_idle(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param)
-{
- char *result_main_label=NULL,*result_sublabel=NULL,*item_name=NULL, *widget_name=NULL, *search_text;
- struct search_list_result *res;
- struct item *item=NULL;
- struct widget *search_input=NULL;
- struct widget *menu, *resultlist_row, *resultlist_entry;
-
- res=search_list_get_result(this->sl);
- if (!res) {
- gui_internal_search_idle_end(this);
- gui_internal_highlight_possible_keys(this, possible_keys_incremental_search);
- return;
- }
-
- if (! strcmp(wm_name,"Country")) {
- item_name=res->country->name;
- item=&res->country->common.item;
- result_main_label=g_strdup_printf("%s", res->country->name);
- } else if (! strcmp(wm_name,"Town")) {
- item=&res->town->common.item;
- item_name=res->town->common.town_name;
- result_main_label=town_display_label(res, 1, 0);
- result_sublabel=town_display_label(res, 1, 2);
- } else if (! strcmp(wm_name,"Street")) {
- item_name=res->street->name;
- item=&res->street->common.item;
- result_main_label=g_strdup(res->street->name);
- result_sublabel=town_display_label(res, 2, 1);
- } else if (! strcmp(wm_name,"House number")) {
- item_name=res->house_number->house_number;
- result_main_label=g_strdup_printf("%s, %s", item_name, res->street->name);
- result_sublabel=town_display_label(res, 3, 0);
- widget_name=g_strdup(result_main_label);
- }
- if(!item_name) {
- dbg(lvl_error, "Skipping nameless item in search (search type: %s). Please report this as a bug.\n", wm_name);
- return;
- }
-
- if(!widget_name)
- widget_name=g_strdup(item_name);
-
- menu=g_list_last(this->root.children)->data;
- search_input=gui_internal_find_widget(menu, NULL, STATE_EDIT);
- dbg_assert(search_input);
- search_text=search_input->text;
-
- gui_internal_find_next_possible_key(search_text, wm_name, possible_keys_incremental_search, item_name);
-
- resultlist_row=gui_internal_widget_table_row_new(this, gravity_left|orientation_horizontal|flags_fill);
- if (!result_sublabel)
- resultlist_row->text=g_strdup(result_main_label);
- else
- resultlist_row->text=g_strdup_printf("%s %s",item_name,result_sublabel);
- int is_house_number_without_street=!strcmp(wm_name,"House number") && !res->street->name;
- resultlist_row->datai=gui_internal_get_match_quality(item_name, search_text, is_house_number_without_street);
- gui_internal_widget_insert_sorted(search_list, resultlist_row, gui_internal_search_cmp);
-
- resultlist_entry=gui_internal_create_resultlist_entry(
- this, res, result_main_label, result_sublabel, param, widget_name, item);
- gui_internal_widget_append(resultlist_row, resultlist_entry);
- gui_internal_widget_pack(this, search_list);
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_widget_render(this, menu);
- graphics_draw_mode(this->gra, draw_mode_end);
-
- g_free(result_main_label);
- g_free(result_sublabel);
+static void gui_internal_search_idle(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param) {
+ char *result_main_label=NULL,*result_sublabel=NULL,*item_name=NULL, *widget_name=NULL, *search_text;
+ struct search_list_result *res;
+ struct item *item=NULL;
+ struct widget *search_input=NULL;
+ struct widget *menu, *resultlist_row, *resultlist_entry;
+
+ res=search_list_get_result(this->sl);
+ if (!res) {
+ gui_internal_search_idle_end(this);
+ gui_internal_highlight_possible_keys(this, possible_keys_incremental_search);
+ return;
+ }
+
+ if (! strcmp(wm_name,"Country")) {
+ item_name=res->country->name;
+ item=&res->country->common.item;
+ result_main_label=g_strdup_printf("%s", res->country->name);
+ } else if (! strcmp(wm_name,"Town")) {
+ item=&res->town->common.item;
+ item_name=res->town->common.town_name;
+ result_main_label=town_display_label(res, 1, 0);
+ result_sublabel=town_display_label(res, 1, 2);
+ } else if (! strcmp(wm_name,"Street")) {
+ item_name=res->street->name;
+ item=&res->street->common.item;
+ result_main_label=g_strdup(res->street->name);
+ result_sublabel=town_display_label(res, 2, 1);
+ } else if (! strcmp(wm_name,"House number")) {
+ item_name=res->house_number->house_number;
+ result_main_label=g_strdup_printf("%s, %s", item_name, res->street->name);
+ result_sublabel=town_display_label(res, 3, 0);
+ widget_name=g_strdup(result_main_label);
+ }
+ if(!item_name) {
+ dbg(lvl_error, "Skipping nameless item in search (search type: %s). Please report this as a bug.", wm_name);
+ return;
+ }
+
+ if(!widget_name)
+ widget_name=g_strdup(item_name);
+
+ menu=g_list_last(this->root.children)->data;
+ search_input=gui_internal_find_widget(menu, NULL, STATE_EDIT);
+ dbg_assert(search_input);
+ search_text=search_input->text;
+
+ gui_internal_find_next_possible_key(search_text, wm_name, possible_keys_incremental_search, item_name);
+
+ resultlist_row=gui_internal_widget_table_row_new(this, gravity_left|orientation_horizontal|flags_fill);
+ if (!result_sublabel)
+ resultlist_row->text=g_strdup(result_main_label);
+ else
+ resultlist_row->text=g_strdup_printf("%s %s",item_name,result_sublabel);
+ int is_house_number_without_street=!strcmp(wm_name,"House number") && !res->street->name;
+ resultlist_row->datai=gui_internal_get_match_quality(item_name, search_text, is_house_number_without_street);
+ gui_internal_widget_insert_sorted(search_list, resultlist_row, gui_internal_search_cmp);
+
+ resultlist_entry=gui_internal_create_resultlist_entry(
+ this, res, result_main_label, result_sublabel, param, widget_name, item);
+ gui_internal_widget_append(resultlist_row, resultlist_entry);
+ gui_internal_widget_pack(this, search_list);
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ gui_internal_widget_render(this, menu);
+ graphics_draw_mode(this->gra, draw_mode_end);
+
+ g_free(result_main_label);
+ g_free(result_sublabel);
}
-static void
-gui_internal_search_idle_start(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param)
-{
- this->idle_cb=callback_new_4(callback_cast(gui_internal_search_idle), this, wm_name, search_list, param);
- this->idle=event_add_idle(50,this->idle_cb);
- callback_call_0(this->idle_cb);
+static void gui_internal_search_idle_start(struct gui_priv *this, char *wm_name, struct widget *search_list,
+ void *param) {
+ this->idle_cb=callback_new_4(callback_cast(gui_internal_search_idle), this, wm_name, search_list, param);
+ this->idle=event_add_idle(50,this->idle_cb);
+ callback_call_0(this->idle_cb);
}
-static void
-gui_internal_search_changed(struct gui_priv *this, struct widget *wm, void *data)
-{
- GList *l;
- struct widget *search_list=gui_internal_menu_data(this)->search_list;
- void *param=(void *)3;
-
- gui_internal_widget_table_clear(this, search_list);
- possible_keys_incremental_search[0]='\0';
-
- if (! strcmp(wm->name,"Country"))
- param=(void *)4;
- if (! strcmp(wm->name,"Street"))
- param=(void *)5;
- if (! strcmp(wm->name,"House number"))
- param=(void *)6;
- dbg(lvl_debug,"%s now '%s'\n", wm->name, wm->text);
-
- gui_internal_search_idle_end(this);
- if (wm->text && g_utf8_strlen(wm->text, -1) > 0) {
- struct attr search_attr;
-
- dbg(lvl_debug,"process\n");
- if (! strcmp(wm->name,"Country"))
- search_attr.type=attr_country_all;
- if (! strcmp(wm->name,"Town"))
- search_attr.type=attr_town_or_district_name;
- if (! strcmp(wm->name,"Street"))
- search_attr.type=attr_street_name;
- if (! strcmp(wm->name,"House number"))
- search_attr.type=attr_house_number;
- search_attr.u.str=wm->text;
- search_list_search(this->sl, &search_attr, 1);
- gui_internal_search_idle_start(this, wm->name, search_list, param);
- } else {
- // If not enough content is entered, we highlight all keys.
- gui_internal_highlight_possible_keys(this, "");
- }
- l=g_list_last(this->root.children);
- gui_internal_widget_render(this, l->data);
+static void gui_internal_search_changed(struct gui_priv *this, struct widget *wm, void *data) {
+ GList *l;
+ struct widget *search_list=gui_internal_menu_data(this)->search_list;
+ void *param=(void *)3;
+
+ gui_internal_widget_table_clear(this, search_list);
+ possible_keys_incremental_search[0]='\0';
+
+ if (! strcmp(wm->name,"Country"))
+ param=(void *)4;
+ if (! strcmp(wm->name,"Street"))
+ param=(void *)5;
+ if (! strcmp(wm->name,"House number"))
+ param=(void *)6;
+ dbg(lvl_debug,"%s now '%s'", wm->name, wm->text);
+
+ gui_internal_search_idle_end(this);
+ if (wm->text && g_utf8_strlen(wm->text, -1) > 0) {
+ struct attr search_attr;
+
+ dbg(lvl_debug,"process");
+ if (! strcmp(wm->name,"Country"))
+ search_attr.type=attr_country_all;
+ if (! strcmp(wm->name,"Town"))
+ search_attr.type=attr_town_or_district_name;
+ if (! strcmp(wm->name,"Street"))
+ search_attr.type=attr_street_name;
+ if (! strcmp(wm->name,"House number"))
+ search_attr.type=attr_house_number;
+ search_attr.u.str=wm->text;
+ search_list_search(this->sl, &search_attr, 1);
+ gui_internal_search_idle_start(this, wm->name, search_list, param);
+ } else {
+ // If not enough content is entered, we highlight all keys.
+ gui_internal_highlight_possible_keys(this, "");
+ }
+ l=g_list_last(this->root.children);
+ gui_internal_widget_render(this, l->data);
}
-static void
-gui_internal_search_list_set_default_country(struct gui_priv *this)
-{
- struct attr search_attr, country_name, country_iso2, *country_attr;
- struct item *item;
- struct country_search *cs;
- struct tracking *tracking;
- struct search_list_result *res;
-
- country_attr=country_default();
- tracking=navit_get_tracking(this->nav);
- if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
- country_attr=&search_attr;
- if (country_attr) {
- cs=country_search_new(country_attr, 0);
- item=country_search_get_item(cs);
- if (item && item_attr_get(item, attr_country_name, &country_name)) {
- search_attr.type=attr_country_all;
- dbg(lvl_debug,"country %s\n", country_name.u.str);
- search_attr.u.str=country_name.u.str;
- search_list_search(this->sl, &search_attr, 0);
- while((res=search_list_get_result(this->sl)));
- if(this->country_iso2) {
- g_free(this->country_iso2);
- this->country_iso2=NULL;
- }
- if (item_attr_get(item, attr_country_iso2, &country_iso2))
- this->country_iso2=g_strdup(country_iso2.u.str);
- }
- country_search_destroy(cs);
- } else {
- dbg(lvl_error,"warning: no default country found\n");
- if (this->country_iso2) {
- dbg(lvl_debug,"attempting to use country '%s'\n",this->country_iso2);
- search_attr.type=attr_country_iso2;
- search_attr.u.str=this->country_iso2;
+static void gui_internal_search_list_set_default_country(struct gui_priv *this) {
+ struct attr search_attr, country_name, country_iso2, *country_attr;
+ struct item *item;
+ struct country_search *cs;
+ struct tracking *tracking;
+ struct search_list_result *res;
+
+ country_attr=country_default();
+ tracking=navit_get_tracking(this->nav);
+ if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
+ country_attr=&search_attr;
+ if (country_attr) {
+ cs=country_search_new(country_attr, 0);
+ item=country_search_get_item(cs);
+ if (item && item_attr_get(item, attr_country_name, &country_name)) {
+ search_attr.type=attr_country_all;
+ dbg(lvl_debug,"country %s", country_name.u.str);
+ search_attr.u.str=country_name.u.str;
+ search_list_search(this->sl, &search_attr, 0);
+ while((res=search_list_get_result(this->sl)));
+ if(this->country_iso2) {
+ g_free(this->country_iso2);
+ this->country_iso2=NULL;
+ }
+ if (item_attr_get(item, attr_country_iso2, &country_iso2))
+ this->country_iso2=g_strdup(country_iso2.u.str);
+ }
+ country_search_destroy(cs);
+ } else {
+ dbg(lvl_error,"warning: no default country found");
+ if (this->country_iso2) {
+ dbg(lvl_debug,"attempting to use country '%s'",this->country_iso2);
+ search_attr.type=attr_country_iso2;
+ search_attr.u.str=this->country_iso2;
search_list_search(this->sl, &search_attr, 0);
while((res=search_list_get_result(this->sl)));
- }
- }
+ }
+ }
}
-static void
-gui_internal_search_list_new(struct gui_priv *this)
-{
- struct mapset *ms=navit_get_mapset(this->nav);
- if (! this->sl) {
- this->sl=search_list_new(ms);
- gui_internal_search_list_set_default_country(this);
- }
+static void gui_internal_search_list_new(struct gui_priv *this) {
+ struct mapset *ms=navit_get_mapset(this->nav);
+ if (! this->sl) {
+ this->sl=search_list_new(ms);
+ gui_internal_search_list_set_default_country(this);
+ }
}
-void
-gui_internal_search_list_destroy(struct gui_priv *this)
-{
- if (this->sl) {
- search_list_destroy(this->sl);
- this->sl=NULL;
- }
+void gui_internal_search_list_destroy(struct gui_priv *this) {
+ if (this->sl) {
+ search_list_destroy(this->sl);
+ this->sl=NULL;
+ }
}
-void
-gui_internal_search(struct gui_priv *this, const char *what, const char *type, int flags)
-{
- struct widget *wb,*wk,*w,*wr,*we,*wl,*wnext=NULL;
- char *country;
- int keyboard_mode;
- gui_internal_search_list_new(this);
- keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(this->country_iso2 ? this->country_iso2 : getenv("LANG"));
- wb=gui_internal_menu(this, what);
- w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wr);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, we);
- if (!strcmp(type,"Country")) {
- wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_town"));
- wnext->func=gui_internal_search_town;
- } else if (!strcmp(type,"Town")) {
- if (this->country_iso2) {
+void gui_internal_search(struct gui_priv *this, const char *what, const char *type, int flags) {
+ struct widget *wb,*wk,*w,*wr,*we,*wl,*wnext=NULL;
+ char *country;
+ int keyboard_mode;
+ gui_internal_search_list_new(this);
+ keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(this->country_iso2 ? this->country_iso2 : getenv("LANG"));
+ wb=gui_internal_menu(this, what);
+ w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wb, w);
+ wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(w, wr);
+ we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
+ gui_internal_widget_append(wr, we);
+ if (!strcmp(type,"Country")) {
+ wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_town"));
+ wnext->func=gui_internal_search_town;
+ } else if (!strcmp(type,"Town")) {
+ if (this->country_iso2) {
#ifdef HAVE_API_ANDROID
- char country_iso2[strlen(this->country_iso2)+1];
- strtolower(country_iso2, this->country_iso2);
- country=g_strdup_printf("country_%s", country_iso2);
+ char country_iso2[strlen(this->country_iso2)+1];
+ strtolower(country_iso2, this->country_iso2);
+ country=g_strdup_printf("country_%s", country_iso2);
#else
- country=g_strdup_printf("country_%s", this->country_iso2);
+ country=g_strdup_printf("country_%s", this->country_iso2);
#endif
- } else
- country=g_strdup("gui_select_country");
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, country)));
- wb->state |= STATE_SENSITIVE;
- if (flags)
- wb->func = gui_internal_search_country;
- else
- wb->func = gui_internal_back;
- wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_street"));
- wnext->func=gui_internal_search_street;
- g_free(country);
- } else if (!strcmp(type,"Street")) {
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_town")));
- wb->state |= STATE_SENSITIVE;
- wb->func = gui_internal_back;
- wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_house_number"));
- wnext->func=gui_internal_search_house_number;
- } else if (!strcmp(type,"House number")) {
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_street")));
- wb->state |= STATE_SENSITIVE;
- wb->func = gui_internal_back;
- keyboard_mode = VKBD_NUMERIC | VKBD_FLAG_2;
- }
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
- if (wnext) {
- gui_internal_widget_append(we, wnext);
- wnext->state |= STATE_SENSITIVE;
- }
- wl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);//gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wr, wl);
- gui_internal_menu_data(this)->search_list=wl;
- wk->state |= STATE_EDIT|STATE_EDITABLE;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_search_changed;
- wk->name=g_strdup(type);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
- else
- gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
- gui_internal_menu_render(this);
+ } else
+ country=g_strdup("gui_select_country");
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, country)));
+ wb->state |= STATE_SENSITIVE;
+ if (flags)
+ wb->func = gui_internal_search_country;
+ else
+ wb->func = gui_internal_back;
+ wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_street"));
+ wnext->func=gui_internal_search_street;
+ g_free(country);
+ } else if (!strcmp(type,"Street")) {
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_town")));
+ wb->state |= STATE_SENSITIVE;
+ wb->func = gui_internal_back;
+ wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_house_number"));
+ wnext->func=gui_internal_search_house_number;
+ } else if (!strcmp(type,"House number")) {
+ gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_street")));
+ wb->state |= STATE_SENSITIVE;
+ wb->func = gui_internal_back;
+ keyboard_mode = VKBD_NUMERIC | VKBD_FLAG_2;
+ }
+ gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
+ if (wnext) {
+ gui_internal_widget_append(we, wnext);
+ wnext->state |= STATE_SENSITIVE;
+ }
+ wl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,
+ 1);//gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
+ gui_internal_widget_append(wr, wl);
+ gui_internal_menu_data(this)->search_list=wl;
+ wk->state |= STATE_EDIT|STATE_EDITABLE;
+ wk->background=this->background;
+ wk->flags |= flags_expand|flags_fill;
+ wk->func = gui_internal_search_changed;
+ wk->name=g_strdup(type);
+ if (this->keyboard)
+ gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
+ else
+ gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
+ gui_internal_menu_render(this);
}
-void
-gui_internal_search_house_number_in_street(struct gui_priv *this, struct widget *widget, void *data)
-{
- dbg(lvl_info,"id %d\n", widget->selection_id);
- search_list_select(this->sl, attr_street_name, 0, 0);
- search_list_select(this->sl, attr_street_name, widget->selection_id, 1);
- gui_internal_search(this,_("House number"),"House number",0);
+void gui_internal_search_house_number_in_street(struct gui_priv *this, struct widget *widget, void *data) {
+ dbg(lvl_info,"id %d", widget->selection_id);
+ search_list_select(this->sl, attr_street_name, 0, 0);
+ search_list_select(this->sl, attr_street_name, widget->selection_id, 1);
+ gui_internal_search(this,_("House number"),"House number",0);
}
-void
-gui_internal_search_street_in_town(struct gui_priv *this, struct widget *widget, void *data)
-{
- dbg(lvl_info,"id %d\n", widget->selection_id);
- search_list_select(this->sl, attr_town_or_district_name, 0, 0);
- search_list_select(this->sl, attr_town_or_district_name, widget->selection_id, 1);
- gui_internal_search(this,_("Street"),"Street",0);
+void gui_internal_search_street_in_town(struct gui_priv *this, struct widget *widget, void *data) {
+ dbg(lvl_info,"id %d", widget->selection_id);
+ search_list_select(this->sl, attr_town_or_district_name, 0, 0);
+ search_list_select(this->sl, attr_town_or_district_name, widget->selection_id, 1);
+ gui_internal_search(this,_("Street"),"Street",0);
}
-void
-gui_internal_search_town_in_country(struct gui_priv *this, struct widget *widget)
-{
- struct search_list_common *slc;
- dbg(lvl_info,"id %d\n", widget->selection_id);
- search_list_select(this->sl, attr_country_all, 0, 0);
- slc=search_list_select(this->sl, attr_country_all, widget->selection_id, 1);
- if (slc) {
- g_free(this->country_iso2);
- this->country_iso2=g_strdup(((struct search_list_country *)slc)->iso2);
- }
- gui_internal_search(this,widget->name,"Town",0);
+void gui_internal_search_town_in_country(struct gui_priv *this, struct widget *widget) {
+ struct search_list_common *slc;
+ dbg(lvl_info,"id %d", widget->selection_id);
+ search_list_select(this->sl, attr_country_all, 0, 0);
+ slc=search_list_select(this->sl, attr_country_all, widget->selection_id, 1);
+ if (slc) {
+ g_free(this->country_iso2);
+ this->country_iso2=g_strdup(((struct search_list_country *)slc)->iso2);
+ }
+ gui_internal_search(this,widget->name,"Town",0);
}
diff --git a/navit/gui/internal/gui_internal_widget.c b/navit/gui/internal/gui_internal_widget.c
index 3e1993025..3b979f011 100644
--- a/navit/gui/internal/gui_internal_widget.c
+++ b/navit/gui/internal/gui_internal_widget.c
@@ -12,135 +12,188 @@
#include "gui_internal_menu.h"
static void gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb);
+void gui_internal_box_pack(struct gui_priv *this, struct widget *w);
-static void
-gui_internal_background_render(struct gui_priv *this, struct widget *w)
-{
- struct point pnt=w->p;
- if (w->state & STATE_HIGHLIGHTED)
- graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
- else {
- if (w->background)
- graphics_draw_rectangle(this->gra, w->background, &pnt, w->w, w->h);
- }
+/**
+ * @brief Transfer the content of one widget into another one (and optionally vice-versa)
+ *
+ * @param this The internal GUI instance
+ * @param[in,out] first The first widget
+ * @param[in,out] second The second widget
+ * @param move_only If non nul, transfer only the second widget into the first widget. The second widget is then deallocated and should be be used anymore (this is a move operation)
+ */
+static void gui_internal_widget_transfer_content(struct gui_priv *this, struct widget *first, struct widget *second,
+ int move_only) {
+ struct widget *temp;
+
+ if (!first) {
+ dbg(lvl_error, "Refusing copy: first argument is NULL");
+ return;
+ }
+ if (!second) {
+ dbg(lvl_error, "Refusing copy: second argument is NULL");
+ return;
+ }
+ temp=g_new0(struct widget, 1);
+ memcpy(temp, first, sizeof(struct widget));
+ memcpy(first, second, sizeof(struct widget));
+ if (move_only) {
+ gui_internal_widget_destroy(this, temp);
+ /* gui_internal_widget_destroy() will do a g_free(temp), but will also deallocate all children widgets */
+ /* Now, we also free the struct widget pointed to by second, so variable second should not be used anymore from this point */
+ g_free(second);
+ } else {
+ memcpy(second, temp, sizeof(struct widget));
+ g_free(temp);
+ }
+}
+
+/**
+ * @brief Swap two widgets
+ *
+ * @param this The internal GUI instance
+ * @param[in,out] first The first widget
+ * @param[in,out] second The second widget
+ */
+void gui_internal_widget_swap(struct gui_priv *this, struct widget *first, struct widget *second) {
+ gui_internal_widget_transfer_content(this, first, second, 0);
+}
+
+/**
+ * @brief Move the content of one widget into another one (the @p src widget is then deallocated and should be be used anymore)
+ *
+ * @param this The internal GUI instance
+ * @param[in,out] dst The destination widget
+ * @param[in,out] src The source widget
+ */
+void gui_internal_widget_move(struct gui_priv *this, struct widget *dst, struct widget *src) {
+ gui_internal_widget_transfer_content(this, dst, src, 1);
+}
+
+static void gui_internal_background_render(struct gui_priv *this, struct widget *w) {
+ struct point pnt=w->p;
+ if (w->state & STATE_HIGHLIGHTED)
+ graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
+ else {
+ if (w->background)
+ graphics_draw_rectangle(this->gra, w->background, &pnt, w->w, w->h);
+ }
}
struct widget *
-gui_internal_label_font_new(struct gui_priv *this, const char *text, int font)
-{
- struct point p[4];
- int w=0;
- int h=0;
-
- struct widget *widget=g_new0(struct widget, 1);
- widget->type=widget_label;
- widget->font_idx=font;
- if (text) {
- widget->text=g_strdup(text);
- graphics_get_text_bbox(this->gra, this->fonts[font], widget->text, 0x10000, 0x0, p, 0);
- w=p[2].x-p[0].x;
- h=p[0].y-p[2].y;
- }
- widget->h=h+this->spacing;
- widget->texth=h;
- widget->w=w+this->spacing;
- widget->textw=w;
- widget->flags=gravity_center;
- widget->foreground=this->text_foreground;
- widget->text_background=this->text_background;
-
- return widget;
+gui_internal_label_font_new(struct gui_priv *this, const char *text, int font) {
+ struct point p[4];
+ int w=0;
+ int h=0;
+
+ struct widget *widget=g_new0(struct widget, 1);
+ widget->type=widget_label;
+ widget->font_idx=font;
+ if (text) {
+ widget->text=g_strdup(text);
+ graphics_get_text_bbox(this->gra, this->fonts[font], widget->text, 0x10000, 0x0, p, 0);
+ w=p[2].x-p[0].x;
+ h=p[0].y-p[2].y;
+ }
+ widget->h=h+this->spacing;
+ widget->texth=h;
+ widget->w=w+this->spacing;
+ widget->textw=w;
+ widget->flags=gravity_center;
+ widget->foreground=this->text_foreground;
+ widget->text_background=this->text_background;
+
+ return widget;
}
-
+
struct widget *
-gui_internal_label_new(struct gui_priv *this, const char *text)
-{
- return gui_internal_label_font_new(this, text, 0);
+gui_internal_label_new(struct gui_priv *this, const char *text) {
+ return gui_internal_label_font_new(this, text, 0);
}
struct widget *
-gui_internal_label_new_abbrev(struct gui_priv *this, const char *text, int maxwidth)
-{
- struct widget *ret=NULL;
- char *tmp=g_malloc(strlen(text)+3);
- const char *p;
- p=text+strlen(text);
- while ((p=g_utf8_find_prev_char(text, p)) >= text) {
- int i=p-text;
- strcpy(tmp, text);
- strcpy(tmp+i,"..");
- ret=gui_internal_label_new(this, tmp);
- if (ret->w < maxwidth)
- break;
- gui_internal_widget_destroy(this, ret);
- ret=NULL;
- }
- if(!ret)
- ret=gui_internal_label_new(this, "");
- g_free(tmp);
- return ret;
+gui_internal_label_new_abbrev(struct gui_priv *this, const char *text, int maxwidth) {
+ struct widget *ret=NULL;
+ char *tmp=g_malloc(strlen(text)+3);
+ const char *p;
+ p=text+strlen(text);
+ while ((p=g_utf8_find_prev_char(text, p)) >= text) {
+ int i=p-text;
+ strcpy(tmp, text);
+ strcpy(tmp+i,"..");
+ ret=gui_internal_label_new(this, tmp);
+ if (ret->w < maxwidth)
+ break;
+ gui_internal_widget_destroy(this, ret);
+ ret=NULL;
+ }
+ if(!ret)
+ ret=gui_internal_label_new(this, "");
+ g_free(tmp);
+ return ret;
}
struct widget *
-gui_internal_image_new(struct gui_priv *this, struct graphics_image *image)
-{
- struct widget *widget=g_new0(struct widget, 1);
- widget->type=widget_image;
- widget->img=image;
- if (image) {
- widget->w=image->width;
- widget->h=image->height;
- }
- return widget;
+gui_internal_image_new(struct gui_priv *this, struct graphics_image *image) {
+ struct widget *widget=g_new0(struct widget, 1);
+ widget->type=widget_image;
+ widget->img=image;
+ if (image) {
+ widget->w=image->width;
+ widget->h=image->height;
+ }
+ return widget;
}
-static void
-gui_internal_image_render(struct gui_priv *this, struct widget *w)
-{
- struct point pnt;
-
- gui_internal_background_render(this, w);
- if (w->img) {
- pnt=w->p;
- pnt.x+=w->w/2-w->img->hot.x;
- pnt.y+=w->h/2-w->img->hot.y;
- graphics_draw_image(this->gra, this->foreground, &pnt, w->img);
- }
+/**
+ * @brief Renders an image or icon, preparing it for drawing on the display
+ *
+ * @param this The internal GUI instance
+ * @param w The widget to render
+ */
+static void gui_internal_image_render(struct gui_priv *this, struct widget *w) {
+ struct point pnt;
+
+ gui_internal_background_render(this, w);
+ if (w->img) {
+ pnt=w->p;
+ pnt.x+=w->w/2-w->img->hot.x;
+ pnt.y+=w->h/2-w->img->hot.y;
+ graphics_draw_image(this->gra, this->foreground, &pnt, w->img);
+ }
}
/**
- * @brief Renders a label.
+ * @brief Renders a label, preparing it for drawing on the display
*
* @param this The internal GUI instance
* @param w The widget to render
*/
-static void
-gui_internal_label_render(struct gui_priv *this, struct widget *w)
-{
- struct point pnt=w->p;
- gui_internal_background_render(this, w);
- if (w->state & STATE_EDIT)
- graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
- if (w->text) {
- char *text;
- char *startext=(char*)g_alloca(strlen(w->text)+1);
- text=w->text;
- if (w->flags2 & 1) {
- int i;
- for (i = 0 ; i < strlen(text); i++)
- startext[i]='*';
- startext[i]='\0';
- text=startext;
- }
- if (w->flags & gravity_right) {
- pnt.y+=w->h-this->spacing;
- pnt.x+=w->w-w->textw-this->spacing;
- graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
- } else {
- pnt.y+=w->h-this->spacing;
- graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
- }
- }
+static void gui_internal_label_render(struct gui_priv *this, struct widget *w) {
+ struct point pnt=w->p;
+ gui_internal_background_render(this, w);
+ if (w->state & STATE_EDIT)
+ graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
+ if (w->text) {
+ char *text;
+ char *startext=(char*)g_alloca(strlen(w->text)+1);
+ text=w->text;
+ if (w->flags2 & 1) {
+ int i;
+ for (i = 0 ; i < strlen(text); i++)
+ startext[i]='*';
+ startext[i]='\0';
+ text=startext;
+ }
+ if (w->flags & gravity_right) {
+ pnt.y+=w->h-this->spacing;
+ pnt.x+=w->w-w->textw-this->spacing;
+ graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
+ } else {
+ pnt.y+=w->h-this->spacing;
+ graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
+ }
+ }
}
/**
@@ -155,487 +208,544 @@ gui_internal_label_render(struct gui_priv *this, struct widget *w)
* @param flags
*/
struct widget *
-gui_internal_text_font_new(struct gui_priv *this, const char *text, int font, enum flags flags)
-{
- char *s=g_strdup(text),*s2,*tok;
- struct widget *ret=gui_internal_box_new(this, flags);
- s2=s;
- while ((tok=strtok(s2,"\n"))) {
- gui_internal_widget_append(ret, gui_internal_label_font_new(this, tok, font));
- s2=NULL;
- }
- gui_internal_widget_pack(this,ret);
- g_free(s);
- return ret;
+gui_internal_text_font_new(struct gui_priv *this, const char *text, int font, enum flags flags) {
+ char *s=g_strdup(text),*s2,*tok;
+ struct widget *ret=gui_internal_box_new(this, flags);
+ s2=s;
+ while ((tok=strtok(s2,"\n"))) {
+ gui_internal_widget_append(ret, gui_internal_label_font_new(this, tok, font));
+ s2=NULL;
+ }
+ gui_internal_widget_pack(this,ret);
+ g_free(s);
+ return ret;
}
struct widget *
-gui_internal_text_new(struct gui_priv *this, const char *text, enum flags flags)
-{
- return gui_internal_text_font_new(this, text, 0, flags);
+gui_internal_text_new(struct gui_priv *this, const char *text, enum flags flags) {
+ return gui_internal_text_font_new(this, text, 0, flags);
}
struct widget *
-gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data)
-{
- struct widget *ret=NULL;
- ret=gui_internal_box_new(this, flags);
- if (ret) {
- if (image && !(flags & flags_swap))
- gui_internal_widget_append(ret, gui_internal_image_new(this, image));
- if (text)
- gui_internal_widget_append(ret, gui_internal_text_font_new(this, text, font, gravity_center|orientation_vertical));
- if (image && (flags & flags_swap))
- gui_internal_widget_append(ret, gui_internal_image_new(this, image));
- ret->func=func;
- ret->data=data;
- if (func) {
- ret->state |= STATE_SENSITIVE;
- ret->speech=g_strdup(text);
- }
- }
- return ret;
+gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font,
+ struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data),
+ void *data) {
+ struct widget *ret=NULL;
+ ret=gui_internal_box_new(this, flags);
+ if (ret) {
+ if (image && !(flags & flags_swap))
+ gui_internal_widget_append(ret, gui_internal_image_new(this, image));
+ if (text)
+ gui_internal_widget_append(ret, gui_internal_text_font_new(this, text, font, gravity_center|orientation_vertical));
+ if (image && (flags & flags_swap))
+ gui_internal_widget_append(ret, gui_internal_image_new(this, image));
+ ret->func=func;
+ ret->data=data;
+ if (func) {
+ ret->state |= STATE_SENSITIVE;
+ ret->speech=g_strdup(text);
+ }
+ }
+ return ret;
}
struct widget *
-gui_internal_button_new_with_callback(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data)
-{
- return gui_internal_button_font_new_with_callback(this, text, 0, image, flags, func, data);
+gui_internal_button_new_with_callback(struct gui_priv *this, const char *text, struct graphics_image *image,
+ enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data) {
+ return gui_internal_button_font_new_with_callback(this, text, 0, image, flags, func, data);
}
struct widget *
-gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags)
-{
- return gui_internal_button_new_with_callback(this, text, image, flags, NULL, NULL);
+gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags) {
+ return gui_internal_button_new_with_callback(this, text, image, flags, NULL, NULL);
}
struct widget *
-gui_internal_find_widget(struct widget *wi, struct point *p, int flags)
-{
- struct widget *ret,*child;
- GList *l=wi->children;
-
- if (p) {
- if (wi->p.x > p->x )
- return NULL;
- if (wi->p.y > p->y )
- return NULL;
- if ( wi->p.x + wi->w < p->x)
- return NULL;
- if ( wi->p.y + wi->h < p->y)
- return NULL;
- }
- if (wi->state & flags)
- return wi;
- while (l) {
- child=l->data;
- ret=gui_internal_find_widget(child, p, flags);
- if (ret) {
- return ret;
- }
- l=g_list_next(l);
- }
- return NULL;
+gui_internal_find_widget(struct widget *wi, struct point *p, int flags) {
+ struct widget *ret,*child;
+ GList *l=wi->children;
+
+ if (p) {
+ if (wi->p.x > p->x )
+ return NULL;
+ if (wi->p.y > p->y )
+ return NULL;
+ if ( wi->p.x + wi->w < p->x)
+ return NULL;
+ if ( wi->p.y + wi->h < p->y)
+ return NULL;
+ }
+ if (wi->state & flags)
+ return wi;
+ while (l) {
+ child=l->data;
+ ret=gui_internal_find_widget(child, p, flags);
+ if (ret) {
+ return ret;
+ }
+ l=g_list_next(l);
+ }
+ return NULL;
}
-void
-gui_internal_highlight_do(struct gui_priv *this, struct widget *found)
-{
- if (found == this->highlighted)
- return;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- if (this->highlighted) {
- this->highlighted->state &= ~STATE_HIGHLIGHTED;
- if (this->root.children && this->highlighted_menu == g_list_last(this->root.children)->data)
- gui_internal_widget_render(this, this->highlighted);
- this->highlighted=NULL;
- this->highlighted_menu=NULL;
- }
- if (found) {
- this->highlighted=found;
- this->highlighted_menu=g_list_last(this->root.children)->data;
- this->highlighted->state |= STATE_HIGHLIGHTED;
- gui_internal_widget_render(this, this->highlighted);
- dbg(lvl_debug,"%d,%d %dx%d\n", found->p.x, found->p.y, found->w, found->h);
- }
- graphics_draw_mode(this->gra, draw_mode_end);
+void gui_internal_highlight_do(struct gui_priv *this, struct widget *found) {
+ if (found == this->highlighted)
+ return;
+
+ graphics_draw_mode(this->gra, draw_mode_begin);
+ if (this->highlighted) {
+ this->highlighted->state &= ~STATE_HIGHLIGHTED;
+ if (this->root.children && this->highlighted_menu == g_list_last(this->root.children)->data)
+ gui_internal_widget_render(this, this->highlighted);
+ this->highlighted=NULL;
+ this->highlighted_menu=NULL;
+ }
+ if (found) {
+ this->highlighted=found;
+ this->highlighted_menu=g_list_last(this->root.children)->data;
+ this->highlighted->state |= STATE_HIGHLIGHTED;
+ gui_internal_widget_render(this, this->highlighted);
+ dbg(lvl_debug,"%d,%d %dx%d", found->p.x, found->p.y, found->w, found->h);
+ }
+ graphics_draw_mode(this->gra, draw_mode_end);
}
//##############################################################################################################
//# Description:
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-void
-gui_internal_highlight(struct gui_priv *this)
-{
- struct widget *menu,*found=NULL;
- if (this->current.x > -1 && this->current.y > -1) {
- menu=g_list_last(this->root.children)->data;
- found=gui_internal_find_widget(menu, &this->current, STATE_SENSITIVE);
- if (!found) {
- found=gui_internal_find_widget(menu, &this->current, STATE_EDITABLE);
- if (found) {
- if (this->editable && this->editable != found) {
- this->editable->state &= ~ STATE_EDIT;
- gui_internal_widget_render(this, this->editable);
- }
- found->state |= STATE_EDIT;
- gui_internal_widget_render(this, found);
- this->editable=found;
- found=NULL;
- }
- }
- }
- gui_internal_highlight_do(this, found);
- this->motion_timeout_event=NULL;
+void gui_internal_highlight(struct gui_priv *this) {
+ struct widget *menu,*found=NULL;
+ if (this->current.x > -1 && this->current.y > -1) {
+ menu=g_list_last(this->root.children)->data;
+ found=gui_internal_find_widget(menu, &this->current, STATE_SENSITIVE);
+ if (!found) {
+ found=gui_internal_find_widget(menu, &this->current, STATE_EDITABLE);
+ if (found) {
+ if (this->editable && this->editable != found) {
+ this->editable->state &= ~ STATE_EDIT;
+ gui_internal_widget_render(this, this->editable);
+ }
+ found->state |= STATE_EDIT;
+ gui_internal_widget_render(this, found);
+ this->editable=found;
+ found=NULL;
+ }
+ }
+ }
+ gui_internal_highlight_do(this, found);
+ this->motion_timeout_event=NULL;
}
struct widget *
-gui_internal_box_new_with_label(struct gui_priv *this, enum flags flags, const char *label)
-{
- struct widget *widget=g_new0(struct widget, 1);
-
- if (label)
- widget->text=g_strdup(label);
- widget->type=widget_box;
- widget->flags=flags;
- return widget;
+gui_internal_box_new_with_label(struct gui_priv *this, enum flags flags, const char *label) {
+ struct widget *widget=g_new0(struct widget, 1);
+
+ if (label)
+ widget->text=g_strdup(label);
+ widget->type=widget_box;
+ widget->flags=flags;
+ widget->on_resize=gui_internal_box_resize;
+ return widget;
}
struct widget *
-gui_internal_box_new(struct gui_priv *this, enum flags flags)
-{
- return gui_internal_box_new_with_label(this, flags, NULL);
+gui_internal_box_new(struct gui_priv *this, enum flags flags) {
+ return gui_internal_box_new_with_label(this, flags, NULL);
}
+/**
+ * @brief Renders a box widget, preparing it for drawing on the display
+ *
+ * @param this The internal GUI instance
+ * @param w The box widget to render
+ */
+static void gui_internal_box_render(struct gui_priv *this, struct widget *w) {
+ struct widget *wc;
+ GList *l;
-static void gui_internal_box_render(struct gui_priv *this, struct widget *w)
-{
- struct widget *wc;
- GList *l;
-
- gui_internal_background_render(this, w);
- if (w->foreground && w->border) {
- struct point pnt[5];
- pnt[0]=w->p;
- pnt[1].x=pnt[0].x+w->w;
- pnt[1].y=pnt[0].y;
- pnt[2].x=pnt[0].x+w->w;
- pnt[2].y=pnt[0].y+w->h;
- pnt[3].x=pnt[0].x;
- pnt[3].y=pnt[0].y+w->h;
- pnt[4]=pnt[0];
- graphics_gc_set_linewidth(w->foreground, w->border ? w->border : 1);
- graphics_draw_lines(this->gra, w->foreground, pnt, 5);
- graphics_gc_set_linewidth(w->foreground, 1);
- }
-
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_render(this, wc);
- l=g_list_next(l);
- }
- if (w->scroll_buttons)
- gui_internal_widget_render(this, w->scroll_buttons->button_box);
-}
+ int visual_debug = 0;
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+ static struct graphics_gc *debug_gc=NULL;
+ static struct color gui_box_debug_color= {0xffff,0x0400,0x0400,0xffff}; /* Red */
+ visual_debug = (debug_level_get("gui_internal_visual_layout") >= lvl_debug);
+#endif
+
+ if (visual_debug)
+ dbg(lvl_debug, "Internal layout visual debugging is enabled");
+
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+ if (visual_debug && !debug_gc) {
+ debug_gc = graphics_gc_new(this->gra);
+ graphics_gc_set_foreground(debug_gc, &gui_box_debug_color);
+ graphics_gc_set_linewidth(debug_gc, 1);
+ }
+#endif
+
+ gui_internal_background_render(this, w);
+ if ((w->foreground && w->border) || visual_debug) {
+ struct point pnt[5];
+ pnt[0]=w->p;
+ pnt[1].x=pnt[0].x+w->w;
+ pnt[1].y=pnt[0].y;
+ pnt[2].x=pnt[0].x+w->w;
+ pnt[2].y=pnt[0].y+w->h;
+ pnt[3].x=pnt[0].x;
+ pnt[3].y=pnt[0].y+w->h;
+ pnt[4]=pnt[0];
+ if (!visual_debug) {
+ graphics_gc_set_linewidth(w->foreground, w->border ? w->border : 1);
+ graphics_draw_lines(this->gra, w->foreground, pnt, 5);
+ graphics_gc_set_linewidth(w->foreground, 1);
+ }
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+ else
+ graphics_draw_lines(this->gra, debug_gc, pnt, 5); /* Force highlighting box borders in debug more */
+#endif
+ }
+
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_render(this, wc);
+ l=g_list_next(l);
+ }
+ if (w->scroll_buttons)
+ gui_internal_widget_render(this, w->scroll_buttons->button_box);
+}
/**
- * @brief Computes the size and location for the widget.
+ * @brief Computes the size and location for a box widget
*
* @param this The internal GUI instance
- * @param w The widget to render
+ * @param w The widget to pack
*/
-static void gui_internal_box_pack(struct gui_priv *this, struct widget *w)
-{
- struct widget *wc;
- int x0,x=0,y=0,width=0,height=0,owidth=0,oheight=0,expand=0,expandd=1,count=0,rows=0,cols=w->cols ? w->cols : 0;
- int hb=w->scroll_buttons?w->scroll_buttons->button_box->h:0;
- GList *l;
- int orientation=w->flags & 0xffff0000;
-
- if (!cols)
- cols=this->cols;
- if (!cols) {
- if ( this->root.w > this->root.h )
- cols=3;
- else
- cols=2;
- width=0;
- height=0;
- }
-
-
- /*
- * count the number of children
- */
- l=w->children;
- while (l) {
- count++;
- l=g_list_next(l);
- }
- if (orientation == orientation_horizontal_vertical && count <= cols)
- orientation=orientation_horizontal;
- switch (orientation) {
- case orientation_horizontal:
- /*
- * For horizontal orientation:
- * pack each child and find the largest height and
- * compute the total width. x spacing (spx) is considered
- *
- * If any children want to be expanded
- * we keep track of this
- */
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- if (height < wc->h)
- height=wc->h;
- width+=wc->w;
- if (wc->flags & flags_expand)
- expand+=wc->w ? wc->w : 1;
- l=g_list_next(l);
- if (l)
- width+=w->spx;
- }
- owidth=width;
- if (expand && w->w) {
- expandd=w->w-width+expand;
- owidth=w->w;
- } else
- expandd=expand=1;
- break;
- case orientation_vertical:
- /*
- * For vertical layouts:
- * We pack each child and compute the largest width and
- * the total height. y spacing (spy) is considered
- *
- * If the expand flag is set then teh expansion amount
- * is computed.
- */
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- if (width < wc->w)
- width=wc->w;
- height+=wc->h;
- if (wc->flags & flags_expand)
- expand+=wc->h ? wc->h : 1;
- l=g_list_next(l);
- if (l)
- height+=w->spy;
- }
- oheight=height;
- if (expand && w->h) {
- expandd=w->h-hb-height+expand;
- oheight=w->h-hb;
- } else
- expandd=expand=1;
- break;
- case orientation_horizontal_vertical:
- /*
- * For horizontal_vertical orientation
- * pack the children.
- * Compute the largest height and largest width.
- * Layout the widgets based on having the
- * number of columns specified by (cols)
- */
- count=0;
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- if (height < wc->h)
- height=wc->h;
- if (width < wc->w)
- width=wc->w;
- l=g_list_next(l);
- count++;
- }
- if (count < cols)
- cols=count;
- rows=(count+cols-1)/cols;
- width*=cols;
- height*=rows;
- width+=w->spx*(cols-1);
- height+=w->spy*(rows-1);
- owidth=width;
- oheight=height;
- expandd=expand=1;
- break;
- default:
- /*
- * No orientation was specified.
- * width and height are both 0.
- * The width & height of this widget
- * will be used.
- */
- if(!w->w && !w->h)
- dbg(lvl_error,"Warning width and height of a widget are 0");
- break;
- }
- if (! w->w && ! w->h) {
- w->w=w->bl+w->br+width;
- w->h=w->bt+w->bb+height+hb;
- w->packed=1;
- }
+void gui_internal_box_pack(struct gui_priv *this, struct widget *w) {
+ struct widget *wc;
+ int x0,x=0,y=0,width=0,height=0,owidth=0,oheight=0,expand=0,expandd=1,count=0,rows=0,cols=w->cols ? w->cols : 0;
+ int hb=w->scroll_buttons?w->scroll_buttons->button_box->h:0;
+ GList *l;
+ int orientation=w->flags & 0xffff0000;
+
+ if (!cols)
+ cols=this->cols;
+ if (!cols) {
+ if ( this->root.w > this->root.h )
+ cols=3;
+ else
+ cols=2;
+ width=0;
+ height=0;
+ }
+
+
+ /*
+ * count the number of children
+ */
+ l=w->children;
+ while (l) {
+ count++;
+ l=g_list_next(l);
+ }
+ if (orientation == orientation_horizontal_vertical && count <= cols)
+ orientation=orientation_horizontal;
+ switch (orientation) {
+ case orientation_horizontal:
+ /*
+ * For horizontal orientation:
+ * pack each child and find the largest height and
+ * compute the total width. x spacing (spx) is considered
+ *
+ * If any children want to be expanded
+ * we keep track of this
+ */
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_pack(this, wc);
+ if (height < wc->h)
+ height=wc->h;
+ width+=wc->w;
+ if (wc->flags & flags_expand)
+ expand+=wc->w ? wc->w : 1;
+ l=g_list_next(l);
+ if (l)
+ width+=w->spx;
+ }
+ owidth=width;
+ if (expand && w->w) {
+ expandd=w->w-width+expand;
+ owidth=w->w;
+ } else
+ expandd=expand=1;
+ break;
+ case orientation_vertical:
+ /*
+ * For vertical layouts:
+ * We pack each child and compute the largest width and
+ * the total height. y spacing (spy) is considered
+ *
+ * If the expand flag is set then teh expansion amount
+ * is computed.
+ */
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_pack(this, wc);
+ if (width < wc->w)
+ width=wc->w;
+ height+=wc->h;
+ if (wc->flags & flags_expand)
+ expand+=wc->h ? wc->h : 1;
+ l=g_list_next(l);
+ if (l)
+ height+=w->spy;
+ }
+ oheight=height;
+ if (expand && w->h) {
+ expandd=w->h-hb-height+expand;
+ oheight=w->h-hb;
+ } else
+ expandd=expand=1;
+ break;
+ case orientation_horizontal_vertical:
+ /*
+ * For horizontal_vertical orientation
+ * pack the children.
+ * Compute the largest height and largest width.
+ * Layout the widgets based on having the
+ * number of columns specified by (cols)
+ */
+ count=0;
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_pack(this, wc);
+ if (height < wc->h)
+ height=wc->h;
+ if (width < wc->w)
+ width=wc->w;
+ l=g_list_next(l);
+ count++;
+ }
+ if (count < cols)
+ cols=count;
+ rows=(count+cols-1)/cols;
+ width*=cols;
+ height*=rows;
+ width+=w->spx*(cols-1);
+ height+=w->spy*(rows-1);
+ owidth=width;
+ oheight=height;
+ expandd=expand=1;
+ break;
+ default:
+ /*
+ * No orientation was specified.
+ * width and height are both 0.
+ * The width & height of this widget
+ * will be used.
+ */
+ if(!w->w && !w->h)
+ dbg(lvl_error,"Warning width and height of a widget are 0");
+ break;
+ }
+ if (! w->w && ! w->h) {
+ w->w=w->bl+w->br+width;
+ w->h=w->bt+w->bb+height+hb;
+ w->packed=1;
+ }
#if 0
- if (expand < 100)
- expand=100;
+ if (expand < 100)
+ expand=100;
#endif
- /*
- * At this stage the width and height of this
- * widget has been computed.
- * We now make a second pass assigning heights,
- * widths and coordinates to each child widget.
- */
-
- if (w->flags & gravity_left)
- x=w->p.x+w->bl;
- if (w->flags & gravity_xcenter)
- x=w->p.x+w->w/2-owidth/2;
- if (w->flags & gravity_right)
- x=w->p.x+w->w-w->br-owidth;
- if (w->flags & gravity_top)
- y=w->p.y+w->bt;
- if (w->flags & gravity_ycenter)
- y=w->p.y+(w->h-hb)/2-oheight/2;
- if (w->flags & gravity_bottom)
- y=w->p.y+(w->h-hb)-w->bb-oheight;
- l=w->children;
- switch (orientation) {
- case orientation_horizontal:
- l=w->children;
- while (l) {
- wc=l->data;
- wc->p.x=x;
- if (wc->flags & flags_fill)
- wc->h=w->h-hb;
- if (wc->flags & flags_expand) {
- if (! wc->w)
- wc->w=1;
- wc->w=wc->w*expandd/expand;
- }
- if (w->flags & gravity_top)
- wc->p.y=y;
- if (w->flags & gravity_ycenter)
- wc->p.y=y-wc->h/2;
- if (w->flags & gravity_bottom)
- wc->p.y=y-wc->h;
- x+=wc->w+w->spx;
- l=g_list_next(l);
- }
- break;
- case orientation_vertical:
- l=w->children;
- while (l) {
- wc=l->data;
- wc->p.y=y;
- if (wc->flags & flags_fill)
- wc->w=w->w;
- if (wc->flags & flags_expand) {
- if (! wc->h)
- wc->h=1;
- wc->h=wc->h*expandd/expand;
- }
- if (w->flags & gravity_left)
- wc->p.x=x;
- if (w->flags & gravity_xcenter)
- wc->p.x=x-wc->w/2;
- if (w->flags & gravity_right)
- wc->p.x=x-wc->w;
- y+=wc->h+w->spy;
- l=g_list_next(l);
- }
- break;
- case orientation_horizontal_vertical:
- l=w->children;
- x0=x;
- count=0;
- width/=cols;
- height/=rows;
- while (l) {
- wc=l->data;
- wc->p.x=x;
- wc->p.y=y;
- if (wc->flags & flags_fill) {
- wc->w=width;
- wc->h=height;
- }
- if (w->flags & gravity_left)
- wc->p.x=x;
- if (w->flags & gravity_xcenter)
- wc->p.x=x+(width-wc->w)/2;
- if (w->flags & gravity_right)
- wc->p.x=x+width-wc->w;
- if (w->flags & gravity_top)
- wc->p.y=y;
- if (w->flags & gravity_ycenter)
- wc->p.y=y+(height-wc->h)/2;
- if (w->flags & gravity_bottom)
- wc->p.y=y-height-wc->h;
- x+=width;
- if (++count == cols) {
- count=0;
- x=x0;
- y+=height;
- }
- l=g_list_next(l);
- }
- break;
- default:
- break;
- }
- if ((w->flags & flags_scrolly) && y > w->h+w->p.y && !w->scroll_buttons) {
- w->scroll_buttons=g_new0(struct scroll_buttons, 1);
- gui_internal_scroll_buttons_init(this, w, w->scroll_buttons);
- w->scroll_buttons->button_box->w=w->w;
- w->scroll_buttons->button_box->p.x=w->p.x;
- w->scroll_buttons->button_box->p.y=w->p.y+w->h-w->scroll_buttons->button_box->h;
- gui_internal_widget_pack(this, w->scroll_buttons->button_box);
- dbg(lvl_debug,"needs buttons %d vs %d\n",y,w->h);
- gui_internal_box_pack(this, w);
- return;
- }
- /*
- * Call pack again on each child,
- * the child has now had its size and coordinates
- * set so they can repack their children.
- */
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- l=g_list_next(l);
- }
+ /*
+ * At this stage the width and height of this
+ * widget has been computed.
+ * We now make a second pass assigning heights,
+ * widths and coordinates to each child widget.
+ */
+
+ if (w->flags & gravity_left)
+ x=w->p.x+w->bl;
+ if (w->flags & gravity_xcenter)
+ x=w->p.x+w->w/2-owidth/2;
+ if (w->flags & gravity_right)
+ x=w->p.x+w->w-w->br-owidth;
+ if (w->flags & gravity_top)
+ y=w->p.y+w->bt;
+ if (w->flags & gravity_ycenter)
+ y=w->p.y+(w->h-hb)/2-oheight/2;
+ if (w->flags & gravity_bottom)
+ y=w->p.y+(w->h-hb)-w->bb-oheight;
+ l=w->children;
+ switch (orientation) {
+ case orientation_horizontal:
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ wc->p.x=x;
+ if (wc->flags & flags_fill)
+ wc->h=w->h-hb;
+ if (wc->flags & flags_expand) {
+ if (! wc->w)
+ wc->w=1;
+ wc->w=wc->w*expandd/expand;
+ }
+ if (w->flags & gravity_top)
+ wc->p.y=y;
+ if (w->flags & gravity_ycenter)
+ wc->p.y=y-wc->h/2;
+ if (w->flags & gravity_bottom)
+ wc->p.y=y-wc->h;
+ x+=wc->w+w->spx;
+ l=g_list_next(l);
+ }
+ break;
+ case orientation_vertical:
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ wc->p.y=y;
+ if (wc->flags & flags_fill)
+ wc->w=w->w;
+ if (wc->flags & flags_expand) {
+ if (! wc->h)
+ wc->h=1;
+ wc->h=wc->h*expandd/expand;
+ }
+ if (w->flags & gravity_left)
+ wc->p.x=x;
+ if (w->flags & gravity_xcenter)
+ wc->p.x=x-wc->w/2;
+ if (w->flags & gravity_right)
+ wc->p.x=x-wc->w;
+ y+=wc->h+w->spy;
+ l=g_list_next(l);
+ }
+ break;
+ case orientation_horizontal_vertical:
+ l=w->children;
+ x0=x;
+ count=0;
+ width/=cols;
+ height/=rows;
+ while (l) {
+ wc=l->data;
+ wc->p.x=x;
+ wc->p.y=y;
+ if (wc->flags & flags_fill) {
+ wc->w=width;
+ wc->h=height;
+ }
+ if (w->flags & gravity_left)
+ wc->p.x=x;
+ if (w->flags & gravity_xcenter)
+ wc->p.x=x+(width-wc->w)/2;
+ if (w->flags & gravity_right)
+ wc->p.x=x+width-wc->w;
+ if (w->flags & gravity_top)
+ wc->p.y=y;
+ if (w->flags & gravity_ycenter)
+ wc->p.y=y+(height-wc->h)/2;
+ if (w->flags & gravity_bottom)
+ wc->p.y=y-height-wc->h;
+ x+=width;
+ if (++count == cols) {
+ count=0;
+ x=x0;
+ y+=height;
+ }
+ l=g_list_next(l);
+ }
+ break;
+ default:
+ break;
+ }
+ if ((w->flags & flags_scrolly) && y > w->h+w->p.y && !w->scroll_buttons) {
+ w->scroll_buttons=g_new0(struct scroll_buttons, 1);
+ gui_internal_scroll_buttons_init(this, w, w->scroll_buttons);
+ w->scroll_buttons->button_box->w=w->w;
+ w->scroll_buttons->button_box->p.x=w->p.x;
+ w->scroll_buttons->button_box->p.y=w->p.y+w->h-w->scroll_buttons->button_box->h;
+ gui_internal_widget_pack(this, w->scroll_buttons->button_box);
+ dbg(lvl_debug,"needs buttons %d vs %d",y,w->h);
+ gui_internal_box_pack(this, w);
+ return;
+ }
+ /*
+ * Call pack again on each child,
+ * the child has now had its size and coordinates
+ * set so they can repack their children.
+ */
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_pack(this, wc);
+ l=g_list_next(l);
+ }
}
-void
-gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w)
-{
- struct widget *wc;
- GList *l;
-
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_reset_pack(this, wc);
- l=g_list_next(l);
- }
- if (w->packed) {
- w->w=0;
- w->h=0;
- }
+/**
+ * @brief Resize a box widget.
+ *
+ * @param this The internal GUI instance
+ * @param w The widget to resize
+ * @param wnew The new width of the widget
+ * @param hnew THe new height of the widget
+ */
+void gui_internal_box_resize(struct gui_priv *this, struct widget *w, void *data, int wnew, int hnew) {
+ GList *l;
+ struct widget *wb;
+
+ w->w = wnew;
+ w->h = hnew;
+
+ l=w->children;
+ while (l) {
+ wb=l->data;
+ if (wb->on_resize) {
+ int orientation=w->flags & 0xffff0000;
+ switch(orientation) {
+ case orientation_horizontal:
+ case orientation_vertical:
+ case orientation_horizontal_vertical:
+ wb->h = 0;
+ wb->w = 0;
+ gui_internal_widget_pack(this, wb);
+ break;
+ default:
+ wb->w = w->w;
+ wb->h = w->h;
+ }
+ wb->on_resize(this, wb, NULL, wb->w, wb->h);
+ }
+ l=g_list_next(l);
+ }
+
+ /* Note: this widget and its children have been resized, a call to gui_internal_box_render() needs to be done by the caller */
+}
+
+void gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w) {
+ struct widget *wc;
+ GList *l;
+
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_reset_pack(this, wc);
+ l=g_list_next(l);
+ }
+ if (w->packed) {
+ w->w=0;
+ w->h=0;
+ }
}
/**
@@ -644,15 +754,13 @@ gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w)
* @param parent The parent widget
* @param child The child widget
*/
-void
-gui_internal_widget_append(struct widget *parent, struct widget *child)
-{
- if (! child)
- return;
- if (! child->background)
- child->background=parent->background;
- parent->children=g_list_append(parent->children, child);
- child->parent=parent;
+void gui_internal_widget_append(struct widget *parent, struct widget *child) {
+ if (! child)
+ return;
+ if (! child->background)
+ child->background=parent->background;
+ parent->children=g_list_append(parent->children, child);
+ child->parent=parent;
}
/**
@@ -661,13 +769,11 @@ gui_internal_widget_append(struct widget *parent, struct widget *child)
* @param parent The parent widget
* @param child The child widget
*/
-void
-gui_internal_widget_prepend(struct widget *parent, struct widget *child)
-{
- if (! child->background)
- child->background=parent->background;
- parent->children=g_list_prepend(parent->children, child);
- child->parent=parent;
+void gui_internal_widget_prepend(struct widget *parent, struct widget *child) {
+ if (! child->background)
+ child->background=parent->background;
+ parent->children=g_list_prepend(parent->children, child);
+ child->parent=parent;
}
/**
@@ -679,14 +785,12 @@ gui_internal_widget_prepend(struct widget *parent, struct widget *child)
* @param child The child widget
* @param func The comparison function
*/
-void
-gui_internal_widget_insert_sorted(struct widget *parent, struct widget *child, GCompareFunc func)
-{
- if (! child->background)
- child->background=parent->background;
-
- parent->children=g_list_insert_sorted(parent->children, child, func);
- child->parent=parent;
+void gui_internal_widget_insert_sorted(struct widget *parent, struct widget *child, GCompareFunc func) {
+ if (! child->background)
+ child->background=parent->background;
+
+ parent->children=g_list_insert_sorted(parent->children, child, func);
+ child->parent=parent;
}
@@ -698,20 +802,18 @@ gui_internal_widget_insert_sorted(struct widget *parent, struct widget *child, G
* @param this The internal GUI instance
* @param w The widget whose children are to be destroyed
*/
-void
-gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w)
-{
- GList *l;
- struct widget *wc;
-
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_destroy(this, wc);
- l=g_list_next(l);
- }
- g_list_free(w->children);
- w->children=NULL;
+void gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w) {
+ GList *l;
+ struct widget *wc;
+
+ l=w->children;
+ while (l) {
+ wc=l->data;
+ gui_internal_widget_destroy(this, wc);
+ l=g_list_next(l);
+ }
+ g_list_free(w->children);
+ w->children=NULL;
}
@@ -724,113 +826,112 @@ gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w)
* @param this The internal GUI instance
* @param w The widget to destroy
*/
-void
-gui_internal_widget_destroy(struct gui_priv *this, struct widget *w)
-{
- gui_internal_widget_children_destroy(this, w);
- g_free(w->command);
- g_free(w->speech);
- g_free(w->text);
- if (w->img)
- graphics_image_free(this->gra, w->img);
- if (w->prefix)
- g_free(w->prefix);
- if (w->name)
- g_free(w->name);
- if (w->data_free)
- w->data_free(w->data);
- if (w->cb && w->remove_cb)
- w->remove_cb(w->instance, w->cb);
- if (w==this->highlighted)
- this->highlighted=NULL;
- if(w->wfree)
- w->wfree(this,w);
- else
- g_free(w);
+void gui_internal_widget_destroy(struct gui_priv *this, struct widget *w) {
+ gui_internal_widget_children_destroy(this, w);
+ g_free(w->command);
+ g_free(w->speech);
+ g_free(w->text);
+ if (w->img)
+ graphics_image_free(this->gra, w->img);
+ if (w->prefix)
+ g_free(w->prefix);
+ if (w->name)
+ g_free(w->name);
+ if (w->data_free)
+ w->data_free(w->data);
+ if (w->cb && w->remove_cb)
+ w->remove_cb(w->instance, w->cb);
+ if (w==this->highlighted)
+ this->highlighted=NULL;
+ if(w->wfree)
+ w->wfree(this,w);
+ else
+ g_free(w);
}
-void
-gui_internal_widget_render(struct gui_priv *this, struct widget *w)
-{
- if(w->p.x > this->root.w || w->p.y > this->root.h || w->state & STATE_INVISIBLE)
- return;
-
- switch (w->type) {
- case widget_box:
- gui_internal_box_render(this, w);
- break;
- case widget_label:
- gui_internal_label_render(this, w);
- break;
- case widget_image:
- gui_internal_image_render(this, w);
- break;
- case widget_table:
- gui_internal_table_render(this,w);
- break;
- default:
- break;
- }
+/**
+ * @brief Renders widgets, preparing it for drawing on the display
+ *
+ * The appropriate render function will be called, depending on the type of widget
+ *
+ * @param this The internal GUI instance
+ * @param w The widget to render
+ */
+void gui_internal_widget_render(struct gui_priv *this, struct widget *w) {
+ if(w->p.x > this->root.w || w->p.y > this->root.h || w->state & STATE_INVISIBLE)
+ return;
+
+ switch (w->type) {
+ case widget_box:
+ gui_internal_box_render(this, w);
+ break;
+ case widget_label:
+ gui_internal_label_render(this, w);
+ break;
+ case widget_image:
+ gui_internal_image_render(this, w);
+ break;
+ case widget_table:
+ gui_internal_table_render(this,w);
+ break;
+ default:
+ break;
+ }
}
-void
-gui_internal_widget_pack(struct gui_priv *this, struct widget *w)
-{
- switch (w->type) {
- case widget_box:
- gui_internal_box_pack(this, w);
- break;
- case widget_table:
- gui_internal_table_pack(this,w);
- default:
- break;
- }
+void gui_internal_widget_pack(struct gui_priv *this, struct widget *w) {
+ switch (w->type) {
+ case widget_box:
+ gui_internal_box_pack(this, w);
+ break;
+ case widget_table:
+ gui_internal_table_pack(this,w);
+ default:
+ break;
+ }
}
struct widget *
-gui_internal_button_label(struct gui_priv *this, const char *label, int mode)
-{
- struct widget *wl,*wlb;
- struct widget *wb=gui_internal_menu_data(this)->button_bar;
- wlb=gui_internal_box_new(this, gravity_right_center|orientation_vertical);
- wl=gui_internal_label_new(this, label);
- wlb->border=1;
- wlb->foreground=this->text_foreground;
- wlb->bl=20;
- wlb->br=20;
- wlb->bb=6;
- wlb->bt=6;
- gui_internal_widget_append(wlb, wl);
- if (mode == 1)
- gui_internal_widget_prepend(wb, wlb);
- if (mode == -1)
- gui_internal_widget_append(wb, wlb);
-
- return wlb;
+gui_internal_button_label(struct gui_priv *this, const char *label, int mode) {
+ struct widget *wl,*wlb;
+ struct widget *wb=gui_internal_menu_data(this)->button_bar;
+ wlb=gui_internal_box_new(this, gravity_right_center|orientation_vertical);
+ wl=gui_internal_label_new(this, label);
+ wlb->border=1;
+ wlb->foreground=this->text_foreground;
+ wlb->bl=20;
+ wlb->br=20;
+ wlb->bb=6;
+ wlb->bt=6;
+ gui_internal_widget_append(wlb, wl);
+ if (mode == 1)
+ gui_internal_widget_prepend(wb, wlb);
+ if (mode == -1)
+ gui_internal_widget_append(wb, wlb);
+
+ return wlb;
}
-static void
-gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb)
-{
- sb->next_button = gui_internal_button_new_with_callback(this, _("Next"), image_new_xs(this, "gui_arrow_right"),
- gravity_center|orientation_horizontal|flags_swap, gui_internal_table_button_next, widget);
- sb->prev_button = gui_internal_button_new_with_callback(this, _("Prev"), image_new_xs(this, "gui_arrow_left"),
- gravity_center|orientation_horizontal, gui_internal_table_button_prev, widget);
-
- sb->button_box=gui_internal_box_new(this, gravity_center|orientation_horizontal);
- sb->button_box->background=this->background;
- if(this->hide_keys){
- sb->prev_button->state |= STATE_INVISIBLE;
- sb->next_button->state |= STATE_INVISIBLE;
- }
- sb->prev_button->state &= ~STATE_SENSITIVE;
- sb->next_button->state &= ~STATE_SENSITIVE;
- gui_internal_widget_append(sb->button_box, sb->prev_button);
- gui_internal_widget_append(sb->button_box, sb->next_button);
-
- sb->button_box->bl=this->spacing;
- gui_internal_widget_pack(this,sb->button_box);
+static void gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb) {
+ sb->next_button = gui_internal_button_new_with_callback(this, _("Next"), image_new_xs(this, "gui_arrow_right"),
+ gravity_center|orientation_horizontal|flags_swap, gui_internal_table_button_next, widget);
+ sb->prev_button = gui_internal_button_new_with_callback(this, _("Prev"), image_new_xs(this, "gui_arrow_left"),
+ gravity_center|orientation_horizontal, gui_internal_table_button_prev, widget);
+
+ sb->button_box=gui_internal_box_new(this, gravity_center|orientation_horizontal);
+ sb->button_box->background=this->background;
+ if(this->hide_keys) {
+ sb->prev_button->state |= STATE_INVISIBLE;
+ sb->next_button->state |= STATE_INVISIBLE;
+ }
+ sb->prev_button->state &= ~STATE_SENSITIVE;
+ sb->next_button->state &= ~STATE_SENSITIVE;
+ gui_internal_widget_append(sb->button_box, sb->prev_button);
+ gui_internal_widget_append(sb->button_box, sb->next_button);
+
+ sb->button_box->bl=this->spacing;
+ gui_internal_widget_pack(this,sb->button_box);
}
/**
@@ -843,29 +944,28 @@ gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, s
* @param flags widget sizing flags.
* @return The newly created widget
*/
-struct widget * gui_internal_widget_table_new(struct gui_priv * this, enum flags flags, int buttons)
-{
- struct widget * widget = g_new0(struct widget,1);
- struct table_data * data = NULL;
- widget->type=widget_table;
- widget->flags=flags;
- widget->state=STATE_SCROLLABLE;
- widget->data=g_new0(struct table_data,1);
- widget->data_free=gui_internal_table_data_free;
-
- // We have to set background here explicitly
- // because it will be used by inner elements created later in this
- // function (navigation buttons). Else that elements won't have
- // any background.
- widget->background=this->background;
- data = (struct table_data*)widget->data;
-
- if (buttons) {
- gui_internal_scroll_buttons_init(this, widget, &data->scroll_buttons);
- gui_internal_widget_append(widget, data->scroll_buttons.button_box);
- }
-
- return widget;
+struct widget * gui_internal_widget_table_new(struct gui_priv * this, enum flags flags, int buttons) {
+ struct widget * widget = g_new0(struct widget,1);
+ struct table_data * data = NULL;
+ widget->type=widget_table;
+ widget->flags=flags;
+ widget->state=STATE_SCROLLABLE;
+ widget->data=g_new0(struct table_data,1);
+ widget->data_free=gui_internal_table_data_free;
+
+ // We have to set background here explicitly
+ // because it will be used by inner elements created later in this
+ // function (navigation buttons). Else that elements won't have
+ // any background.
+ widget->background=this->background;
+ data = (struct table_data*)widget->data;
+
+ if (buttons) {
+ gui_internal_scroll_buttons_init(this, widget, &data->scroll_buttons);
+ gui_internal_widget_append(widget, data->scroll_buttons.button_box);
+ }
+
+ return widget;
}
@@ -878,30 +978,27 @@ struct widget * gui_internal_widget_table_new(struct gui_priv * this, enum flags
* @param this The internal GUI instance
* @param table The table widget
*/
-void gui_internal_widget_table_clear(struct gui_priv * this,struct widget * table)
-{
- GList * iter;
- struct table_data * table_data = (struct table_data* ) table->data;
-
- iter = table->children;
- while(iter ) {
- if(iter->data != table_data->scroll_buttons.button_box) {
- struct widget * child = (struct widget*)iter->data;
- gui_internal_widget_destroy(this,child);
- if(table->children == iter) {
- table->children = g_list_remove(iter,iter->data);
- iter=table->children;
- }
- else
- iter = g_list_remove(iter,iter->data);
- }
- else {
- iter = g_list_next(iter);
- }
-
- }
- table_data->top_row=NULL;
- table_data->bottom_row=NULL;
+void gui_internal_widget_table_clear(struct gui_priv * this,struct widget * table) {
+ GList * iter;
+ struct table_data * table_data = (struct table_data* ) table->data;
+
+ iter = table->children;
+ while(iter ) {
+ if(iter->data != table_data->scroll_buttons.button_box) {
+ struct widget * child = (struct widget*)iter->data;
+ gui_internal_widget_destroy(this,child);
+ if(table->children == iter) {
+ table->children = g_list_remove(iter,iter->data);
+ iter=table->children;
+ } else
+ iter = g_list_remove(iter,iter->data);
+ } else {
+ iter = g_list_next(iter);
+ }
+
+ }
+ table_data->top_row=NULL;
+ table_data->bottom_row=NULL;
}
/**
@@ -911,14 +1008,12 @@ void gui_internal_widget_table_clear(struct gui_priv * this,struct widget * tabl
*
* @return GList pointer to the next row in the children list, or NULL if there are no any rows left.
*/
-GList *
-gui_internal_widget_table_next_row(GList * row)
-{
- while((row=g_list_next(row))!=NULL) {
- if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
- break;
- }
- return row;
+GList *gui_internal_widget_table_next_row(GList * row) {
+ while((row=g_list_next(row))!=NULL) {
+ if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
+ break;
+ }
+ return row;
}
/**
@@ -928,14 +1023,12 @@ gui_internal_widget_table_next_row(GList * row)
*
* @return GList pointer to the previous row in the children list, or NULL if there are no any rows left.
*/
-GList *
-gui_internal_widget_table_prev_row(GList * row)
-{
- while((row=g_list_previous(row))!=NULL) {
- if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
- break;
- }
- return row;
+GList *gui_internal_widget_table_prev_row(GList * row) {
+ while((row=g_list_previous(row))!=NULL) {
+ if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
+ break;
+ }
+ return row;
}
/**
@@ -945,16 +1038,14 @@ gui_internal_widget_table_prev_row(GList * row)
*
* @return GList pointer to the first row in the children list, or NULL if table is empty.
*/
-GList *
-gui_internal_widget_table_first_row(GList * row)
-{
- if(!row)
- return NULL;
+GList *gui_internal_widget_table_first_row(GList * row) {
+ if(!row)
+ return NULL;
- if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
- return row;
+ if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
+ return row;
- return gui_internal_widget_table_next_row(row);
+ return gui_internal_widget_table_next_row(row);
}
/**
@@ -962,14 +1053,12 @@ gui_internal_widget_table_first_row(GList * row)
*
* @return GList pointer to the top row in the children list, or NULL.
*/
-GList *
-gui_internal_widget_table_top_row(struct gui_priv *this, struct widget * table)
-{
- if(table && table->type==widget_table) {
- struct table_data *d=table->data;
- return gui_internal_widget_table_first_row(d->top_row);
- }
- return NULL;
+GList *gui_internal_widget_table_top_row(struct gui_priv *this, struct widget * table) {
+ if(table && table->type==widget_table) {
+ struct table_data *d=table->data;
+ return gui_internal_widget_table_first_row(d->top_row);
+ }
+ return NULL;
}
/**
@@ -977,19 +1066,17 @@ gui_internal_widget_table_top_row(struct gui_priv *this, struct widget * table)
*
* @return GList pointer to the top row in the children list of the table.
*/
-GList *
-gui_internal_widget_table_set_top_row(struct gui_priv *this, struct widget * table, struct widget *row)
-{
- if(table && table->type==widget_table) {
- struct table_data *d=table->data;
- d->top_row=table->children;
- while(d->top_row && d->top_row->data!=row)
- d->top_row=g_list_next(d->top_row);
- if(!d->top_row)
- d->top_row=gui_internal_widget_table_first_row(table->children);
- return d->top_row;
- }
- return NULL;
+GList *gui_internal_widget_table_set_top_row(struct gui_priv *this, struct widget * table, struct widget *row) {
+ if(table && table->type==widget_table) {
+ struct table_data *d=table->data;
+ d->top_row=table->children;
+ while(d->top_row && d->top_row->data!=row)
+ d->top_row=g_list_next(d->top_row);
+ if(!d->top_row)
+ d->top_row=gui_internal_widget_table_first_row(table->children);
+ return d->top_row;
+ }
+ return NULL;
}
@@ -1002,12 +1089,11 @@ gui_internal_widget_table_set_top_row(struct gui_priv *this, struct widget * tab
* @return The new table_row widget.
*/
struct widget *
-gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags)
-{
- struct widget * widget = g_new0(struct widget,1);
- widget->type=widget_table_row;
- widget->flags=flags;
- return widget;
+gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags) {
+ struct widget * widget = g_new0(struct widget,1);
+ widget->type=widget_table_row;
+ widget->flags=flags;
+ return widget;
}
@@ -1024,91 +1110,81 @@ gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags)
*
* The caller is responsible for freeing the returned list.
*/
-static GList *
-gui_internal_compute_table_dimensions(struct gui_priv * this,struct widget * w)
-{
-
- GList * column_desc = NULL;
- GList * current_desc=NULL;
- GList * cur_row = w->children;
- struct widget * cur_row_widget=NULL;
- GList * cur_column=NULL;
- struct widget * cell_w=NULL;
- struct table_column_desc * current_cell=NULL;
- struct table_data * table_data=NULL;
- int height=0;
- int width=0;
- int total_width=0;
- int column_count=0;
-
- /*
- * Scroll through the the table and
- * 1. Compute the maximum width + height of each column across all rows.
- */
- table_data = (struct table_data*) w->data;
- for(cur_row=w->children; cur_row ; cur_row = g_list_next(cur_row) )
- {
- cur_row_widget = (struct widget*) cur_row->data;
- current_desc = column_desc;
- if(cur_row_widget == table_data->scroll_buttons.button_box)
- {
- continue;
- }
- column_count=0;
- for(cur_column = cur_row_widget->children; cur_column;
- cur_column=g_list_next(cur_column))
- {
- cell_w = (struct widget*) cur_column->data;
- gui_internal_widget_pack(this,cell_w);
- if(current_desc == 0)
- {
- current_cell = g_new0(struct table_column_desc,1);
- column_desc = g_list_append(column_desc,current_cell);
- current_desc = g_list_last(column_desc);
- current_cell->height=cell_w->h;
- current_cell->width=cell_w->w;
- total_width+=cell_w->w;
-
- }
- else
- {
- current_cell = current_desc->data;
- height = cell_w->h;
- width = cell_w->w;
- if(current_cell->height < height )
- {
- current_cell->height = height;
- }
- if(current_cell->width < width)
- {
- total_width += (width-current_cell->width);
- current_cell->width = width;
-
-
-
- }
- current_desc = g_list_next(current_desc);
- }
- column_count++;
-
- }/* column loop */
-
- } /*row loop */
-
-
- /*
- * If the width of all columns is less than the width off
- * the table expand each cell proportionally.
- *
- */
- if(total_width+(this->spacing*column_count) < w->w ) {
- for(current_desc=column_desc; current_desc; current_desc=g_list_next(current_desc)) {
- current_cell = (struct table_column_desc*) current_desc->data;
- current_cell->width= ( (current_cell->width+this->spacing)/(float)total_width) * w->w ;
- }
- }
-
- return column_desc;
+static GList *gui_internal_compute_table_dimensions(struct gui_priv * this,struct widget * w) {
+
+ GList * column_desc = NULL;
+ GList * current_desc=NULL;
+ GList * cur_row = w->children;
+ struct widget * cur_row_widget=NULL;
+ GList * cur_column=NULL;
+ struct widget * cell_w=NULL;
+ struct table_column_desc * current_cell=NULL;
+ struct table_data * table_data=NULL;
+ int height=0;
+ int width=0;
+ int total_width=0;
+ int column_count=0;
+
+ /*
+ * Scroll through the the table and
+ * 1. Compute the maximum width + height of each column across all rows.
+ */
+ table_data = (struct table_data*) w->data;
+ for(cur_row=w->children; cur_row ; cur_row = g_list_next(cur_row) ) {
+ cur_row_widget = (struct widget*) cur_row->data;
+ current_desc = column_desc;
+ if(cur_row_widget == table_data->scroll_buttons.button_box) {
+ continue;
+ }
+ column_count=0;
+ for(cur_column = cur_row_widget->children; cur_column;
+ cur_column=g_list_next(cur_column)) {
+ cell_w = (struct widget*) cur_column->data;
+ gui_internal_widget_pack(this,cell_w);
+ if(current_desc == 0) {
+ current_cell = g_new0(struct table_column_desc,1);
+ column_desc = g_list_append(column_desc,current_cell);
+ current_desc = g_list_last(column_desc);
+ current_cell->height=cell_w->h;
+ current_cell->width=cell_w->w;
+ total_width+=cell_w->w;
+
+ } else {
+ current_cell = current_desc->data;
+ height = cell_w->h;
+ width = cell_w->w;
+ if(current_cell->height < height ) {
+ current_cell->height = height;
+ }
+ if(current_cell->width < width) {
+ total_width += (width-current_cell->width);
+ current_cell->width = width;
+
+
+
+ }
+ current_desc = g_list_next(current_desc);
+ }
+ column_count++;
+
+ }/* column loop */
+
+ } /*row loop */
+
+
+ /*
+ * If the width of all columns is less than the width off
+ * the table expand each cell proportionally.
+ *
+ */
+ if(total_width+(this->spacing*column_count) < w->w ) {
+ for(current_desc=column_desc; current_desc; current_desc=g_list_next(current_desc)) {
+ current_cell = (struct table_column_desc*) current_desc->data;
+ current_cell->width= ( (current_cell->width+this->spacing)/(float)total_width) * w->w ;
+ }
+ }
+
+ return column_desc;
}
@@ -1121,69 +1197,59 @@ gui_internal_compute_table_dimensions(struct gui_priv * this,struct widget * w)
* @param this The graphics context
* @param w The widget to pack.
*/
-void
-gui_internal_table_pack(struct gui_priv * this, struct widget * w)
-{
-
- int height=0;
- int width=0;
- int count=0;
- GList * column_data = gui_internal_compute_table_dimensions(this,w);
- GList * current=0;
- struct table_column_desc * cell_desc=0;
- struct table_data * table_data = (struct table_data*)w->data;
-
- for(current = column_data; current; current=g_list_next(current))
- {
- if(table_data->scroll_buttons.button_box == current->data )
- {
- continue;
- }
- cell_desc = (struct table_column_desc *) current->data;
- width = width + cell_desc->width + this->spacing;
- if(height < cell_desc->height)
- {
- height = cell_desc->height ;
- }
- }
-
-
-
- for(current=w->children; current; current=g_list_next(current))
- {
- if(current->data!= table_data->scroll_buttons.button_box)
- {
- count++;
- }
- }
-
- w->w = width;
- if(w->w + w->c.x > this->root.w)
- {
- w->w = this->root.w - w->c.x;
- }
-
-
- if(w->h + w->c.y > this->root.h )
- {
- /*
- * Do not allow the widget to exceed the screen.
- *
- */
- w->h = this->root.h- w->c.y - height;
- }
-
- if (table_data->scroll_buttons.button_box)
- {
- gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
- }
-
-
- /*
- * Deallocate column descriptions.
- */
- g_list_foreach(column_data,(GFunc)g_free,NULL);
- g_list_free(column_data);
+void gui_internal_table_pack(struct gui_priv * this, struct widget * w) {
+
+ int height=0;
+ int width=0;
+ int count=0;
+ GList * column_data = gui_internal_compute_table_dimensions(this,w);
+ GList * current=0;
+ struct table_column_desc * cell_desc=0;
+ struct table_data * table_data = (struct table_data*)w->data;
+
+ for(current = column_data; current; current=g_list_next(current)) {
+ if(table_data->scroll_buttons.button_box == current->data ) {
+ continue;
+ }
+ cell_desc = (struct table_column_desc *) current->data;
+ width = width + cell_desc->width + this->spacing;
+ if(height < cell_desc->height) {
+ height = cell_desc->height ;
+ }
+ }
+
+
+
+ for(current=w->children; current; current=g_list_next(current)) {
+ if(current->data!= table_data->scroll_buttons.button_box) {
+ count++;
+ }
+ }
+
+ w->w = width;
+ if(w->w + w->c.x > this->root.w) {
+ w->w = this->root.w - w->c.x;
+ }
+
+
+ if(w->h + w->c.y > this->root.h ) {
+ /*
+ * Do not allow the widget to exceed the screen.
+ *
+ */
+ w->h = this->root.h- w->c.y - height;
+ }
+
+ if (table_data->scroll_buttons.button_box) {
+ gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
+ }
+
+
+ /*
+ * Deallocate column descriptions.
+ */
+ g_list_foreach(column_data,(GFunc)g_free,NULL);
+ g_list_free(column_data);
}
@@ -1194,210 +1260,225 @@ gui_internal_table_pack(struct gui_priv * this, struct widget * w)
*
* @param table_data Data from the table object.
*/
-void
-gui_internal_table_hide_rows(struct table_data * table_data)
-{
- GList*cur_row;
- for(cur_row=table_data->top_row; cur_row ; cur_row = g_list_next(cur_row))
- {
- struct widget * cur_row_widget = (struct widget*)cur_row->data;
- if (cur_row_widget->type!=widget_table_row)
- continue;
- cur_row_widget->p.x=0;
- cur_row_widget->p.y=0;
- cur_row_widget->w=0;
- cur_row_widget->h=0;
- if(cur_row==table_data->bottom_row)
- break;
- }
+void gui_internal_table_hide_rows(struct table_data * table_data) {
+ GList*cur_row;
+ for(cur_row=table_data->top_row; cur_row ; cur_row = g_list_next(cur_row)) {
+ struct widget * cur_row_widget = (struct widget*)cur_row->data;
+ if (cur_row_widget->type!=widget_table_row)
+ continue;
+ cur_row_widget->p.x=0;
+ cur_row_widget->p.y=0;
+ cur_row_widget->w=0;
+ cur_row_widget->h=0;
+ if(cur_row==table_data->bottom_row)
+ break;
+ }
}
/**
- * @brief Renders a table widget.
+ * @brief Renders a table widget, preparing it for drawing on the display
*
- * @param this The graphics context
- * @param w The table widget to render.
+ * @param this The internal GUI instance
+ * @param w The widget to render
*/
-void
-gui_internal_table_render(struct gui_priv * this, struct widget * w)
-{
-
- int x;
- int y;
- GList * column_desc=NULL;
- GList * cur_row = NULL;
- GList * current_desc=NULL;
- struct table_data * table_data = (struct table_data*)w->data;
- int drawing_space_left=1;
- int is_first_page;
- struct table_column_desc * dim=NULL;
-
- dbg_assert(table_data);
- column_desc = gui_internal_compute_table_dimensions(this,w);
- if(!column_desc)
- return;
- y=w->p.y;
- gui_internal_table_hide_rows(table_data);
- /*
- * Skip rows that are on previous pages.
- */
- if(table_data->top_row && table_data->top_row != w->children && !table_data->scroll_buttons.button_box_hide)
- {
- cur_row = table_data->top_row;
- is_first_page=0;
- } else {
- cur_row = w->children;
- table_data->top_row=NULL;
- is_first_page=1;
- }
-
- /* First, let's mark all columns as off-screen that are in rows which are *before*
- * our current page.
- * */
- GList *row = w->children;
- while (row != cur_row) {
- struct widget * cur_row_widget = (struct widget*)row->data;
- GList * cur_column=NULL;
- if(cur_row_widget == table_data->scroll_buttons.button_box)
- {
- row = g_list_next(row);
- continue;
- }
- for(cur_column = cur_row_widget->children; cur_column;
- cur_column=g_list_next(cur_column))
- {
- struct widget * cur_widget = (struct widget*) cur_column->data;
- if(this->hide_keys){
- cur_widget->state |= STATE_INVISIBLE;
- cur_widget->state &= ~STATE_SENSITIVE;
- }else{
- cur_widget->state |= STATE_OFFSCREEN;
- }
- }
- row = g_list_next(row);
- }
-
- /*
- * Loop through each row. Drawing each cell with the proper sizes,
- * at the proper positions.
- */
- for(table_data->top_row=cur_row; cur_row; cur_row = g_list_next(cur_row))
- {
- int max_height=0, bbox_height=0;
- struct widget * cur_row_widget;
- GList * cur_column=NULL;
- current_desc = column_desc;
- cur_row_widget = (struct widget*)cur_row->data;
- x =w->p.x+this->spacing;
- if(cur_row_widget == table_data->scroll_buttons.button_box)
- {
- continue;
- }
- dim = (struct table_column_desc*)current_desc->data;
-
- if (table_data->scroll_buttons.button_box && !table_data->scroll_buttons.button_box_hide)
- bbox_height=table_data->scroll_buttons.button_box->h;
-
- if( y + dim->height + bbox_height + this->spacing >= w->p.y + w->h )
- {
- drawing_space_left=0;
- }
- for(cur_column = cur_row_widget->children; cur_column;
- cur_column=g_list_next(cur_column))
- {
- struct widget * cur_widget = (struct widget*) cur_column->data;
- if (drawing_space_left) {
- cur_widget->p.x=x;
- cur_widget->w=dim->width;
- cur_widget->p.y=y;
- cur_widget->h=dim->height;
- x=x+cur_widget->w;
- max_height = dim->height;
- /* We pack the widget before rendering to ensure that the x and y
- * coordinates get pushed down.
- */
- if(this->hide_keys){
- cur_widget->state &= ~STATE_INVISIBLE;
- cur_widget->state |= STATE_SENSITIVE;
- }else{
- cur_widget->state &= ~STATE_OFFSCREEN;
- }
- gui_internal_widget_pack(this,cur_widget);
- gui_internal_widget_render(this,cur_widget);
-
- if(dim->height > max_height)
- {
- max_height = dim->height;
- }
- } else {
- /* Deactivate contents that we don't have space for. */
- if(this->hide_keys){
- cur_widget->state |= STATE_INVISIBLE;
- cur_widget->state &= ~STATE_SENSITIVE;
- }else{
- cur_widget->state |= STATE_OFFSCREEN;
- }
- }
- }
-
- if (drawing_space_left) {
- /* Row object should have its coordinates in actual
- * state to be able to pass mouse clicks to Column objects
- */
- cur_row_widget->p.x=w->p.x;
- cur_row_widget->w=w->w;
- cur_row_widget->p.y=y;
- cur_row_widget->h=max_height;
- y = y + max_height;
- table_data->bottom_row=cur_row;
- current_desc = g_list_next(current_desc);
- }
- }
-
- /* By default, hide all scroll buttons. */
- if(this->hide_keys){
- table_data->scroll_buttons.next_button->state|= STATE_INVISIBLE;
- table_data->scroll_buttons.prev_button->state|= STATE_INVISIBLE;
- }
- table_data->scroll_buttons.next_button->state&= ~STATE_SENSITIVE;
- table_data->scroll_buttons.prev_button->state&= ~STATE_SENSITIVE;
-
- if(table_data->scroll_buttons.button_box && (!drawing_space_left || !is_first_page) && !table_data->scroll_buttons.button_box_hide )
- {
- table_data->scroll_buttons.button_box->p.y =w->p.y+w->h-table_data->scroll_buttons.button_box->h -
- this->spacing;
- if(table_data->scroll_buttons.button_box->p.y < y )
- {
- table_data->scroll_buttons.button_box->p.y=y;
- }
- table_data->scroll_buttons.button_box->p.x = w->p.x;
- table_data->scroll_buttons.button_box->w = w->w;
- gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
- if(table_data->scroll_buttons.next_button->p.y > w->p.y + w->h + table_data->scroll_buttons.next_button->h)
- {
- table_data->scroll_buttons.button_box->p.y = w->p.y + w->h -
- table_data->scroll_buttons.button_box->h;
- }
- if(!drawing_space_left)
- {
- table_data->scroll_buttons.next_button->state|= STATE_SENSITIVE;
- table_data->scroll_buttons.next_button->state&= ~STATE_INVISIBLE;
- }
-
- if(table_data->top_row != w->children)
- {
- table_data->scroll_buttons.prev_button->state|= STATE_SENSITIVE;
- table_data->scroll_buttons.prev_button->state&= ~STATE_INVISIBLE;
- }
- gui_internal_widget_render(this,table_data->scroll_buttons.button_box);
- }
-
- /*
- * Deallocate column descriptions.
- */
- g_list_foreach(column_desc,(GFunc)g_free,NULL);
- g_list_free(column_desc);
+void gui_internal_table_render(struct gui_priv * this, struct widget * w) {
+
+ int x;
+ int y;
+ GList * column_desc=NULL;
+ GList * cur_row = NULL;
+ GList * current_desc=NULL;
+ struct table_data * table_data = (struct table_data*)w->data;
+ int drawing_space_left=1;
+ int is_first_page;
+ struct table_column_desc * dim=NULL;
+
+ dbg_assert(table_data);
+ column_desc = gui_internal_compute_table_dimensions(this,w);
+ if(!column_desc)
+ return;
+ y=w->p.y;
+ gui_internal_table_hide_rows(table_data);
+ /*
+ * Skip rows that are on previous pages.
+ */
+ if(table_data->top_row && table_data->top_row != w->children && !table_data->scroll_buttons.button_box_hide) {
+ cur_row = table_data->top_row;
+ is_first_page=0;
+ } else {
+ cur_row = w->children;
+ table_data->top_row=NULL;
+ is_first_page=1;
+ }
+
+ /* First, let's mark all columns as off-screen that are in rows which are *before*
+ * our current page.
+ * */
+ GList *row = w->children;
+ while (row != cur_row) {
+ struct widget * cur_row_widget = (struct widget*)row->data;
+ GList * cur_column=NULL;
+ if(cur_row_widget == table_data->scroll_buttons.button_box) {
+ row = g_list_next(row);
+ continue;
+ }
+ for(cur_column = cur_row_widget->children; cur_column;
+ cur_column=g_list_next(cur_column)) {
+ struct widget * cur_widget = (struct widget*) cur_column->data;
+ if(this->hide_keys) {
+ cur_widget->state |= STATE_INVISIBLE;
+ cur_widget->state &= ~STATE_SENSITIVE;
+ } else {
+ cur_widget->state |= STATE_OFFSCREEN;
+ }
+ }
+ row = g_list_next(row);
+ }
+
+ /*
+ * Loop through each row. Drawing each cell with the proper sizes,
+ * at the proper positions.
+ */
+ for(table_data->top_row=cur_row; cur_row; cur_row = g_list_next(cur_row)) {
+ int max_height=0, bbox_height=0;
+ struct widget * cur_row_widget;
+ GList * cur_column=NULL;
+ current_desc = column_desc;
+ cur_row_widget = (struct widget*)cur_row->data;
+ x =w->p.x+this->spacing;
+ if(cur_row_widget == table_data->scroll_buttons.button_box) {
+ continue;
+ }
+ dim = (struct table_column_desc*)current_desc->data;
+
+ if (table_data->scroll_buttons.button_box && !table_data->scroll_buttons.button_box_hide)
+ bbox_height=table_data->scroll_buttons.button_box->h;
+
+ if( y + dim->height + bbox_height + this->spacing >= w->p.y + w->h ) {
+ drawing_space_left=0;
+ }
+ for(cur_column = cur_row_widget->children; cur_column;
+ cur_column=g_list_next(cur_column)) {
+ struct widget * cur_widget = (struct widget*) cur_column->data;
+ if (drawing_space_left) {
+ cur_widget->p.x=x;
+ cur_widget->w=dim->width;
+ cur_widget->p.y=y;
+ cur_widget->h=dim->height;
+ x=x+cur_widget->w;
+ max_height = dim->height;
+ /* We pack the widget before rendering to ensure that the x and y
+ * coordinates get pushed down.
+ */
+ if(this->hide_keys) {
+ cur_widget->state &= ~STATE_INVISIBLE;
+ cur_widget->state |= STATE_SENSITIVE;
+ } else {
+ cur_widget->state &= ~STATE_OFFSCREEN;
+ }
+
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+
+ static struct graphics_gc *debug_gc=NULL;
+ static struct color gui_table_debug_color= {0x0000,0xffff,0x0400,0xffff}; /* Green */
+ int visual_debug = (debug_level_get("gui_internal_visual_layout") >= lvl_debug);
+
+ if (visual_debug)
+ dbg(lvl_debug, "Internal layout visual debugging is enabled");
+
+ if (visual_debug && !debug_gc) {
+ debug_gc = graphics_gc_new(this->gra);
+ graphics_gc_set_foreground(debug_gc, &gui_table_debug_color);
+ graphics_gc_set_linewidth(debug_gc, 1);
+ }
+#endif
+
+ gui_internal_widget_pack(this,cur_widget);
+ gui_internal_widget_render(this,cur_widget);
+
+#if defined(GUI_INTERNAL_VISUAL_DBG)
+ if (visual_debug) {
+ struct point pnt[5];
+ pnt[0]=cur_widget->p;
+ pnt[1].x=pnt[0].x+cur_widget->w;
+ pnt[1].y=pnt[0].y;
+ pnt[2].x=pnt[0].x+cur_widget->w;
+ pnt[2].y=pnt[0].y+cur_widget->h;
+ pnt[3].x=pnt[0].x;
+ pnt[3].y=pnt[0].y+cur_widget->h;
+ pnt[4]=pnt[0];
+ graphics_draw_lines(this->gra, debug_gc, pnt, 5); /* Force highlighting table borders in debug more */
+ }
+#endif
+
+ if(dim->height > max_height) {
+ max_height = dim->height;
+ }
+ } else {
+ /* Deactivate contents that we don't have space for. */
+ if(this->hide_keys) {
+ cur_widget->state |= STATE_INVISIBLE;
+ cur_widget->state &= ~STATE_SENSITIVE;
+ } else {
+ cur_widget->state |= STATE_OFFSCREEN;
+ }
+ }
+ }
+
+ if (drawing_space_left) {
+ /* Row object should have its coordinates in actual
+ * state to be able to pass mouse clicks to Column objects
+ */
+ cur_row_widget->p.x=w->p.x;
+ cur_row_widget->w=w->w;
+ cur_row_widget->p.y=y;
+ cur_row_widget->h=max_height;
+ y = y + max_height;
+ table_data->bottom_row=cur_row;
+ current_desc = g_list_next(current_desc);
+ }
+ }
+
+ /* By default, hide all scroll buttons. */
+ if(this->hide_keys) {
+ table_data->scroll_buttons.next_button->state|= STATE_INVISIBLE;
+ table_data->scroll_buttons.prev_button->state|= STATE_INVISIBLE;
+ }
+ table_data->scroll_buttons.next_button->state&= ~STATE_SENSITIVE;
+ table_data->scroll_buttons.prev_button->state&= ~STATE_SENSITIVE;
+
+ if(table_data->scroll_buttons.button_box && (!drawing_space_left || !is_first_page)
+ && !table_data->scroll_buttons.button_box_hide ) {
+ table_data->scroll_buttons.button_box->p.y =w->p.y+w->h-table_data->scroll_buttons.button_box->h -
+ this->spacing;
+ if(table_data->scroll_buttons.button_box->p.y < y ) {
+ table_data->scroll_buttons.button_box->p.y=y;
+ }
+ table_data->scroll_buttons.button_box->p.x = w->p.x;
+ table_data->scroll_buttons.button_box->w = w->w;
+ gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
+ if(table_data->scroll_buttons.next_button->p.y > w->p.y + w->h + table_data->scroll_buttons.next_button->h) {
+ table_data->scroll_buttons.button_box->p.y = w->p.y + w->h -
+ table_data->scroll_buttons.button_box->h;
+ }
+ if(!drawing_space_left) {
+ table_data->scroll_buttons.next_button->state|= STATE_SENSITIVE;
+ table_data->scroll_buttons.next_button->state&= ~STATE_INVISIBLE;
+ }
+
+ if(table_data->top_row != w->children) {
+ table_data->scroll_buttons.prev_button->state|= STATE_SENSITIVE;
+ table_data->scroll_buttons.prev_button->state&= ~STATE_INVISIBLE;
+ }
+ gui_internal_widget_render(this,table_data->scroll_buttons.button_box);
+ }
+
+ /*
+ * Deallocate column descriptions.
+ */
+ g_list_foreach(column_desc,(GFunc)g_free,NULL);
+ g_list_free(column_desc);
}
/**
@@ -1410,37 +1491,32 @@ gui_internal_table_render(struct gui_priv * this, struct widget * w)
* @param wm The button widget that was pressed.
* @param data
*/
-void
-gui_internal_table_button_next(struct gui_priv * this, struct widget * wm, void *data)
-{
- struct widget * table_widget=NULL;
- struct table_data * table_data = NULL;
-
- if(wm)
- table_widget = (struct widget * ) wm->data;
- else
- table_widget = data;
-
- if(table_widget && table_widget->type==widget_table)
- table_data = (struct table_data*) table_widget->data;
-
- if(table_data)
- {
- GList *l=g_list_next(table_data->bottom_row);
- if(l) {
- gui_internal_table_hide_rows(table_data);
- table_data->top_row=l;
- }
- }
-
- if(wm)
- wm->state&= ~STATE_HIGHLIGHTED;
-
- gui_internal_menu_render(this);
+void gui_internal_table_button_next(struct gui_priv * this, struct widget * wm, void *data) {
+ struct widget * table_widget=NULL;
+ struct table_data * table_data = NULL;
+
+ if(wm)
+ table_widget = (struct widget * ) wm->data;
+ else
+ table_widget = data;
+
+ if(table_widget && table_widget->type==widget_table)
+ table_data = (struct table_data*) table_widget->data;
+
+ if(table_data) {
+ GList *l=g_list_next(table_data->bottom_row);
+ if(l) {
+ gui_internal_table_hide_rows(table_data);
+ table_data->top_row=l;
+ }
+ }
+
+ if(wm)
+ wm->state&= ~STATE_HIGHLIGHTED;
+
+ gui_internal_menu_render(this);
}
-
-
/**
* @brief Handles the 'previous page' table event.
*
@@ -1450,36 +1526,34 @@ gui_internal_table_button_next(struct gui_priv * this, struct widget * wm, void
* @param this The graphics context.
* @param wm The button widget that was pressed.
*/
-void
-gui_internal_table_button_prev(struct gui_priv * this, struct widget * wm, void *data)
-{
- struct widget * table_widget = NULL;
- struct table_data * table_data = NULL;
-
- if(wm)
- table_widget=(struct widget * ) wm->data;
- else
- table_widget=(struct widget * ) data;
-
- if(table_widget && table_widget->type==widget_table)
- table_data = (struct table_data*) table_widget->data;
-
- if(table_data) {
- int bottomy=table_widget->p.y+table_widget->h;
- int n;
- GList *top=table_data->top_row;
- struct widget *w=(struct widget*)top->data;
- if(table_data->scroll_buttons.button_box->p.y!=0) {
- bottomy=table_data->scroll_buttons.button_box->p.y;
- }
- n=(bottomy-w->p.y)/w->h;
- while(n-- > 0 && (top=g_list_previous(top))!=NULL);
- gui_internal_table_hide_rows(table_data);
- table_data->top_row=top;
- }
- if(wm)
- wm->state&= ~STATE_HIGHLIGHTED;
- gui_internal_menu_render(this);
+void gui_internal_table_button_prev(struct gui_priv * this, struct widget * wm, void *data) {
+ struct widget * table_widget = NULL;
+ struct table_data * table_data = NULL;
+
+ if(wm)
+ table_widget=(struct widget * ) wm->data;
+ else
+ table_widget=(struct widget * ) data;
+
+ if(table_widget && table_widget->type==widget_table)
+ table_data = (struct table_data*) table_widget->data;
+
+ if(table_data) {
+ int bottomy=table_widget->p.y+table_widget->h;
+ int n;
+ GList *top=table_data->top_row;
+ struct widget *w=(struct widget*)top->data;
+ if(table_data->scroll_buttons.button_box->p.y!=0) {
+ bottomy=table_data->scroll_buttons.button_box->p.y;
+ }
+ n=(bottomy-w->p.y)/w->h;
+ while(n-- > 0 && (top=g_list_previous(top))!=NULL);
+ gui_internal_table_hide_rows(table_data);
+ table_data->top_row=top;
+ }
+ if(wm)
+ wm->state&= ~STATE_HIGHLIGHTED;
+ gui_internal_menu_render(this);
}
@@ -1491,7 +1565,6 @@ gui_internal_table_button_prev(struct gui_priv * this, struct widget * wm, void
*
* @param p The table_data structure
*/
-void gui_internal_table_data_free(void * p)
-{
- g_free(p);
+void gui_internal_table_data_free(void * p) {
+ g_free(p);
}
diff --git a/navit/gui/internal/gui_internal_widget.h b/navit/gui/internal/gui_internal_widget.h
index 33f03e478..cc24cb44e 100644
--- a/navit/gui/internal/gui_internal_widget.h
+++ b/navit/gui/internal/gui_internal_widget.h
@@ -1,7 +1,7 @@
enum gui_internal_reason {
- gui_internal_reason_click=1,
- gui_internal_reason_keypress,
- gui_internal_reason_keypress_finish
+ gui_internal_reason_click=1,
+ gui_internal_reason_keypress,
+ gui_internal_reason_keypress_finish
};
//##############################################################################################################
@@ -10,96 +10,101 @@ enum gui_internal_reason {
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
struct widget {
- enum widget_type type;
- struct graphics_gc *background,*text_background;
- struct graphics_gc *foreground_frame;
- struct graphics_gc *foreground;
- char *text;
- struct graphics_image *img;
- /**
- * A function to be invoked on actions.
- * @li widget The widget that is receiving the button press.
- *
- */
- void (*func)(struct gui_priv *priv, struct widget *widget, void *data);
- enum gui_internal_reason reason;
- int datai;
- void *data;
- /**
- * @brief A function to deallocate data
- */
- void (*data_free)(void *data);
+ enum widget_type type;
+ struct graphics_gc *background,*text_background;
+ struct graphics_gc *foreground_frame;
+ struct graphics_gc *foreground;
+ char *text;
+ struct graphics_image *img;
+ /**
+ * A function to be invoked on actions.
+ * @param widget The widget that is receiving the button press.
+ *
+ */
+ void (*func)(struct gui_priv *priv, struct widget *widget, void *data);
+ /**
+ * A function to be invoked on resize or move
+ * @param widget The widget that is resized
+ */
+ void (*on_resize)(struct gui_priv *priv, struct widget *widget, void *data, int neww, int newh);
+ enum gui_internal_reason reason;
+ int datai;
+ void *data;
+ /**
+ * @brief A function to deallocate data
+ */
+ void (*data_free)(void *data);
- /**
- * @brief a function that will be called as the widget is being destroyed.
- * This function can act as a destructor for the widget. It allows for
- * on deallocation actions to be specified on a per widget basis.
- * This function will call g_free on the widget (if required).
- */
- void (*wfree) (struct gui_priv *this_, struct widget * w);
- char *prefix;
- char *name;
- char *speech;
- char *command;
- struct pcoord c;
- struct item item;
- int selection_id;
- int state;
- struct point p;
- int wmin,hmin;
- int w,h;
- int textw,texth;
- int font_idx;
- int bl,br,bt,bb,spx,spy;
- int border;
- int packed;
- /**
- * The number of widgets to layout horizontally when doing
- * a orientation_horizontal_vertical layout
- */
- int cols;
- enum flags flags;
- int flags2;
- void *instance;
- int (*set_attr)(void *, struct attr *);
- int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
- void (*remove_cb)(void *, struct callback *cb);
- struct callback *cb;
- struct attr on;
- struct attr off;
- int deflt;
- int is_on;
- int redraw;
- struct menu_data *menu_data;
- struct form *form;
- GList *children;
- struct widget *parent;
- struct scroll_buttons *scroll_buttons;
+ /**
+ * @brief a function that will be called as the widget is being destroyed.
+ * This function can act as a destructor for the widget. It allows for
+ * on deallocation actions to be specified on a per widget basis.
+ * This function will call g_free on the widget (if required).
+ */
+ void (*wfree) (struct gui_priv *this_, struct widget * w);
+ char *prefix;
+ char *name;
+ char *speech;
+ char *command;
+ struct pcoord c;
+ struct item item;
+ int selection_id;
+ int state;
+ struct point p;
+ int wmin,hmin;
+ int w,h;
+ int textw,texth;
+ int font_idx;
+ int bl,br,bt,bb,spx,spy;
+ int border;
+ int packed;
+ /**
+ * The number of widgets to layout horizontally when doing
+ * a orientation_horizontal_vertical layout
+ */
+ int cols;
+ enum flags flags;
+ int flags2;
+ void *instance;
+ int (*set_attr)(void *, struct attr *);
+ int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
+ void (*remove_cb)(void *, struct callback *cb);
+ struct callback *cb;
+ struct attr on;
+ struct attr off;
+ int deflt;
+ int is_on;
+ int redraw;
+ struct menu_data *menu_data;
+ struct form *form;
+ GList *children;
+ struct widget *parent;
+ struct scroll_buttons *scroll_buttons;
};
struct scroll_buttons {
- /**
- * Button box should not be displayed if button_box_hide is not zero.
- */
- int button_box_hide;
- /**
- * A container box that is the child of the table widget that contains+groups
- * the next and previous button.
- */
- struct widget * button_box;
- /**
- * A button widget to handle 'next page' requests
- */
- struct widget * next_button;
- /**
- * A button widget to handle 'previous page' requests.
- */
- struct widget * prev_button;
- /**
- * a pointer to the gui context.
- * This is needed by the free function to destroy the buttons.
- */
- struct gui_priv * this;
+ /**
+ * Button box should not be displayed if button_box_hide is not zero.
+ */
+ int button_box_hide;
+ /**
+ * A container box that is the child of the table widget that contains+groups
+ * the next and previous button.
+ */
+ struct widget * button_box;
+ /**
+ * A button widget to handle 'next page' requests
+ */
+ struct widget * next_button;
+ /**
+ * A button widget to handle 'previous page' requests.
+ */
+ struct widget * prev_button;
+ /**
+ * a pointer to the gui context.
+ * This is needed by the free function to destroy the buttons.
+ */
+ struct gui_priv * this;
};
/**
@@ -111,20 +116,19 @@ struct scroll_buttons {
* The table_data structure needs to be freed with data_free along with the widget.
*
*/
-struct table_data
-{
- /**
- * A GList pointer into a widget->children list that indicates the row
- * currently being rendered at the top of the table.
- */
- GList * top_row;
- /**
- * A Glist pointer into a widget->children list that indicates the row
- * currently being rendered at the bottom of the table.
- */
- GList * bottom_row;
+struct table_data {
+ /**
+ * A GList pointer into a widget->children list that indicates the row
+ * currently being rendered at the top of the table.
+ */
+ GList * top_row;
+ /**
+ * A Glist pointer into a widget->children list that indicates the row
+ * currently being rendered at the bottom of the table.
+ */
+ GList * bottom_row;
- struct scroll_buttons scroll_buttons;
+ struct scroll_buttons scroll_buttons;
};
@@ -133,18 +137,17 @@ struct table_data
*
*
*/
-struct table_column_desc
-{
+struct table_column_desc {
- /**
- * The computed height of a cell in the table.
- */
- int height;
+ /**
+ * The computed height of a cell in the table.
+ */
+ int height;
- /**
- * The computed width of a cell in the table.
- */
- int width;
+ /**
+ * The computed width of a cell in the table.
+ */
+ int width;
};
/* prototypes */
enum flags;
@@ -153,20 +156,28 @@ struct gui_priv;
struct point;
struct table_data;
struct widget;
+void gui_internal_widget_swap(struct gui_priv *this, struct widget *first, struct widget *second);
+void gui_internal_widget_move(struct gui_priv *this, struct widget *dst, struct widget *src);
struct widget *gui_internal_label_font_new(struct gui_priv *this, const char *text, int font);
struct widget *gui_internal_label_new(struct gui_priv *this, const char *text);
struct widget *gui_internal_label_new_abbrev(struct gui_priv *this, const char *text, int maxwidth);
struct widget *gui_internal_image_new(struct gui_priv *this, struct graphics_image *image);
struct widget *gui_internal_text_font_new(struct gui_priv *this, const char *text, int font, enum flags flags);
struct widget *gui_internal_text_new(struct gui_priv *this, const char *text, enum flags flags);
-struct widget *gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font, struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
-struct widget *gui_internal_button_new_with_callback(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
-struct widget *gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags);
+struct widget *gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font,
+ struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data),
+ void *data);
+struct widget *gui_internal_button_new_with_callback(struct gui_priv *this, const char *text,
+ struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data),
+ void *data);
+struct widget *gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image,
+ enum flags flags);
struct widget *gui_internal_find_widget(struct widget *wi, struct point *p, int flags);
void gui_internal_highlight_do(struct gui_priv *this, struct widget *found);
void gui_internal_highlight(struct gui_priv *this);
struct widget *gui_internal_box_new_with_label(struct gui_priv *this, enum flags flags, const char *label);
struct widget *gui_internal_box_new(struct gui_priv *this, enum flags flags);
+void gui_internal_box_resize(struct gui_priv *this, struct widget *w, void *data, int wnew, int hnew);
void gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w);
void gui_internal_widget_append(struct widget *parent, struct widget *child);
void gui_internal_widget_prepend(struct widget *parent, struct widget *child);
@@ -174,6 +185,7 @@ void gui_internal_widget_insert_sorted(struct widget *parent, struct widget *chi
void gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w);
void gui_internal_widget_destroy(struct gui_priv *this, struct widget *w);
void gui_internal_widget_render(struct gui_priv *this, struct widget *w);
+void gui_internal_widget_resize(struct gui_priv *this, struct widget *w, int wnew, int hnew);
void gui_internal_widget_pack(struct gui_priv *this, struct widget *w);
struct widget *gui_internal_button_label(struct gui_priv *this, const char *label, int mode);
struct widget *gui_internal_widget_table_new(struct gui_priv *this, enum flags flags, int buttons);
diff --git a/navit/gui/qml/CMakeLists.txt b/navit/gui/qml/CMakeLists.txt
index 05456d9bd..4f2f4a8ce 100644
--- a/navit/gui/qml/CMakeLists.txt
+++ b/navit/gui/qml/CMakeLists.txt
@@ -11,13 +11,13 @@ QT4_GENERATE_MOC(guiProxy.h ${CMAKE_CURRENT_BINARY_DIR}/guiProxy.moc)
QT4_GENERATE_MOC(routeProxy.h ${CMAKE_CURRENT_BINARY_DIR}/routeProxy.moc)
QT4_GENERATE_MOC(gui_qml.cpp ${CMAKE_CURRENT_BINARY_DIR}/gui_qml.moc)
module_add_library(gui_qml gui_qml.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/proxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/ngqpoint.moc
- ${CMAKE_CURRENT_BINARY_DIR}/searchProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/bookmarksProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/vehicleProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/navitProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/guiProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/routeProxy.moc
- ${CMAKE_CURRENT_BINARY_DIR}/gui_qml.moc
-)
+ ${CMAKE_CURRENT_BINARY_DIR}/proxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/ngqpoint.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/searchProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/bookmarksProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/vehicleProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/navitProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/guiProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/routeProxy.moc
+ ${CMAKE_CURRENT_BINARY_DIR}/gui_qml.moc
+ )
diff --git a/navit/gui/qml/bookmarksProxy.h b/navit/gui/qml/bookmarksProxy.h
index 03cbcbc88..8063a2058 100644
--- a/navit/gui/qml/bookmarksProxy.h
+++ b/navit/gui/qml/bookmarksProxy.h
@@ -51,7 +51,7 @@ public slots:
while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
QString label;
QString path;
-
+
if (item->type != type_bookmark && item->type != type_bookmark_folder) continue;
if (!item_attr_get(item, attr_label, &attr)) continue;
label=QString::fromLocal8Bit(attr.u.str);
@@ -72,7 +72,7 @@ public slots:
entries.appendChild(entry);
}
- dbg(lvl_info,"%s\n",retDoc.toString().toLocal8Bit().constData());
+ dbg(lvl_info,"%s",retDoc.toString().toLocal8Bit().constData());
return retDoc.toString();
}
QString AddFolder(QString description) {
@@ -144,7 +144,7 @@ public slots:
if (!item_attr_get(item, attr_label, &attr)) continue;
label=QString::fromLocal8Bit(attr.u.str);
- dbg(lvl_debug,"Bookmark is %s\n",bookmark.toStdString().c_str());
+ dbg(lvl_debug,"Bookmark is %s",bookmark.toStdString().c_str());
if (label.compare(bookmark)) continue;
item_coord_get(item, &c, 1);
if (this->object->currentPoint!=NULL) {
diff --git a/navit/gui/qml/guiProxy.h b/navit/gui/qml/guiProxy.h
index 7648eb5b3..ca46af09e 100644
--- a/navit/gui/qml/guiProxy.h
+++ b/navit/gui/qml/guiProxy.h
@@ -48,7 +48,7 @@ public:
//QDeclarativeExpression commandJS(this->object->guiWidget->rootContext(),QString(),qobject_cast<QObject*>(this->object->guiWidget->rootObject()));
//commandJS.setSourceLocation("command.js",0);
//this->function=function;
- //commandJS.eval(qobject_cast<QObject*>(this->object->guiWidget->rootObject()));
+ //commandJS.eval(qobject_cast<QObject*>(this->object->guiWidget->rootObject()));
}
signals:
void widthSignal(int);
@@ -57,7 +57,7 @@ public slots:
void pushPage(QString page) {
returnPath.push_front(page);
}
- QString popPage() {
+ QString popPage() {
if (!returnPath.empty()) {
if (returnPath.length()>1) {
returnPath.pop_front();
diff --git a/navit/gui/qml/gui_qml.cpp b/navit/gui/qml/gui_qml.cpp
index 3efc719dd..8c6f232f8 100644
--- a/navit/gui/qml/gui_qml.cpp
+++ b/navit/gui/qml/gui_qml.cpp
@@ -36,48 +36,48 @@
#include "layout.h"
struct gui_priv {
- struct navit *nav;
- struct gui *gui;
- struct attr self;
- struct vehicle* currVehicle;
-
- //configuration items
- int fullscreen;
- int menu_on_map_click;
- int signal_on_map_click;
- int w;
- int h;
- char *source;
- char *skin;
- char* icon_src;
- int radius;
- int pitch;
- int lazy; //When TRUE - menu state will not be changed during map/menu switches, FALSE - menu will be always reset to main.qml
-
- //Interface stuff
- struct callback_list *cbl;
- QCoreApplication *app;
- struct window *win;
- struct graphics *gra;
- QWidget *mainWindow;
- QWidget *graphicsWidget;
- QDeclarativeView *guiWidget;
- QDeclarativeView *prevGuiWidget;
- QStackedLayout *switcherWidget;
- struct callback *button_cb;
- struct callback *motion_cb;
- struct callback *resize_cb;
- struct callback *keypress_cb;
- struct callback *window_closed_cb;
-
- //Proxy objects
- class NGQProxyGui* guiProxy;
- class NGQProxyNavit* navitProxy;
- class NGQProxyVehicle* vehicleProxy;
- class NGQProxySearch* searchProxy;
- class NGQProxyBookmarks* bookmarksProxy;
- class NGQProxyRoute* routeProxy;
- class NGQPoint* currentPoint;
+ struct navit *nav;
+ struct gui *gui;
+ struct attr self;
+ struct vehicle* currVehicle;
+
+ //configuration items
+ int fullscreen;
+ int menu_on_map_click;
+ int signal_on_map_click;
+ int w;
+ int h;
+ char *source;
+ char *skin;
+ char* icon_src;
+ int radius;
+ int pitch;
+ int lazy; //When TRUE - menu state will not be changed during map/menu switches, FALSE - menu will be always reset to main.qml
+
+ //Interface stuff
+ struct callback_list *cbl;
+ QCoreApplication *app;
+ struct window *win;
+ struct graphics *gra;
+ QWidget *mainWindow;
+ QWidget *graphicsWidget;
+ QDeclarativeView *guiWidget;
+ QDeclarativeView *prevGuiWidget;
+ QStackedLayout *switcherWidget;
+ struct callback *button_cb;
+ struct callback *motion_cb;
+ struct callback *resize_cb;
+ struct callback *keypress_cb;
+ struct callback *window_closed_cb;
+
+ //Proxy objects
+ class NGQProxyGui* guiProxy;
+ class NGQProxyNavit* navitProxy;
+ class NGQProxyVehicle* vehicleProxy;
+ class NGQProxySearch* searchProxy;
+ class NGQProxyBookmarks* bookmarksProxy;
+ class NGQProxyRoute* routeProxy;
+ class NGQPoint* currentPoint;
};
#include "proxy.h"
@@ -90,386 +90,371 @@ struct gui_priv {
#include "guiProxy.h"
//Main window class for resizeEvent handling
-#ifdef Q_WS_X11
+#ifdef Q_WS_X11
#include <QX11EmbedWidget>
-class NGQMainWindow : public QX11EmbedWidget
-{
+class NGQMainWindow : public QX11EmbedWidget {
#else
-class NGQMainWindow : public QWidget
-{
+class NGQMainWindow : public QWidget {
#endif /* Q_WS_X11 */
public:
-#ifdef Q_WS_X11
- NGQMainWindow(struct gui_priv* this_,QWidget *parent) : QX11EmbedWidget(parent) {
+#ifdef Q_WS_X11
+ NGQMainWindow(struct gui_priv* this_,QWidget *parent) : QX11EmbedWidget(parent) {
#else
- NGQMainWindow(struct gui_priv* this_,QWidget *parent) : QWidget(parent) {
+ NGQMainWindow(struct gui_priv* this_,QWidget *parent) : QWidget(parent) {
#endif /* Q_WS_X11 */
- this->object=this_;
- }
+ this->object=this_;
+ }
protected:
- void resizeEvent(QResizeEvent *) {
- this->object->w=this->width();
- this->object->h=this->height();
- //YES, i KNOW about signal/slot thing
- this->object->guiProxy->setWidth(this->width());
- this->object->guiProxy->setHeight(this->height());
- }
- void closeEvent(QCloseEvent* event) {
- this->object->graphicsWidget->close();
- }
+ void resizeEvent(QResizeEvent *) {
+ this->object->w=this->width();
+ this->object->h=this->height();
+ //YES, i KNOW about signal/slot thing
+ this->object->guiProxy->setWidth(this->width());
+ this->object->guiProxy->setHeight(this->height());
+ }
+ void closeEvent(QCloseEvent* event) {
+ this->object->graphicsWidget->close();
+ }
private:
- struct gui_priv* object;
+ struct gui_priv* object;
};
//Meta object
#include "gui_qml.moc"
-static void gui_qml_dbus_signal(struct gui_priv *this_, struct point *p)
-{
- struct displaylist_handle *dlh;
- struct displaylist *display;
- struct displayitem *di;
-
- display=navit_get_displaylist(this_->nav);
- dlh=graphics_displaylist_open(display);
- while ((di=graphics_displaylist_next(dlh))) {
- struct item *item=graphics_displayitem_get_item(di);
- if (item_is_point(*item) && graphics_displayitem_get_displayed(di) &&
- graphics_displayitem_within_dist(display, di, p, 10)) {
- struct map_rect *mr=map_rect_new(item->map, NULL);
- struct item *itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- struct attr attr;
- if (item_attr_get(itemo, attr_data, &attr)) {
- struct attr cb,*attr_list[2];
- int valid=0;
- attr.type=attr_data;
- attr_list[0]=&attr;
- attr_list[1]=NULL;
- if (navit_get_attr(this_->nav, attr_callback_list, &cb, NULL))
- callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
- }
- map_rect_destroy(mr);
- }
- }
- graphics_displaylist_close(dlh);
+static void gui_qml_dbus_signal(struct gui_priv *this_, struct point *p) {
+ struct displaylist_handle *dlh;
+ struct displaylist *display;
+ struct displayitem *di;
+
+ display=navit_get_displaylist(this_->nav);
+ dlh=graphics_displaylist_open(display);
+ while ((di=graphics_displaylist_next(dlh))) {
+ struct item *item=graphics_displayitem_get_item(di);
+ if (item_is_point(*item) && graphics_displayitem_get_displayed(di) &&
+ graphics_displayitem_within_dist(display, di, p, 10)) {
+ struct map_rect *mr=map_rect_new(item->map, NULL);
+ struct item *itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ struct attr attr;
+ if (item_attr_get(itemo, attr_data, &attr)) {
+ struct attr cb,*attr_list[2];
+ int valid=0;
+ attr.type=attr_data;
+ attr_list[0]=&attr;
+ attr_list[1]=NULL;
+ if (navit_get_attr(this_->nav, attr_callback_list, &cb, NULL))
+ callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
+ }
+ map_rect_destroy(mr);
+ }
+ }
+ graphics_displaylist_close(dlh);
}
-static void gui_qml_button(void *data, int pressed, int button, struct point *p)
-{
- struct gui_priv *this_=(struct gui_priv*)data;
-
- // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
- if (!navit_handle_button(this_->nav, pressed, button, p, NULL)) {
- dbg(lvl_debug,"navit has handled button\n");
- return;
- }
-
- dbg(lvl_debug,"enter %d %d\n", pressed, button);
- if (this_->signal_on_map_click) {
- gui_qml_dbus_signal(this_, p);
- return;
- }
-
- if ( button == 1 && this_->menu_on_map_click ) {
- this_->guiProxy->switchToMenu(p);
- }
+static void gui_qml_button(void *data, int pressed, int button, struct point *p) {
+ struct gui_priv *this_=(struct gui_priv*)data;
+
+ // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
+ if (!navit_handle_button(this_->nav, pressed, button, p, NULL)) {
+ dbg(lvl_debug,"navit has handled button");
+ return;
+ }
+
+ dbg(lvl_debug,"enter %d %d", pressed, button);
+ if (this_->signal_on_map_click) {
+ gui_qml_dbus_signal(this_, p);
+ return;
+ }
+
+ if ( button == 1 && this_->menu_on_map_click ) {
+ this_->guiProxy->switchToMenu(p);
+ }
}
-static void gui_qml_motion(void *data, struct point *p)
-{
- struct gui_priv *this_=(struct gui_priv*)data;
- navit_handle_motion(this_->nav, p);
- return;
+static void gui_qml_motion(void *data, struct point *p) {
+ struct gui_priv *this_=(struct gui_priv*)data;
+ navit_handle_motion(this_->nav, p);
+ return;
}
-static void gui_qml_resize(void *data, int w, int h)
-{
- struct gui_priv *this_=(struct gui_priv*)data;
- navit_handle_resize(this_->nav, w, h);
+static void gui_qml_resize(void *data, int w, int h) {
+ struct gui_priv *this_=(struct gui_priv*)data;
+ navit_handle_resize(this_->nav, w, h);
}
-static void gui_qml_keypress(void *data, char *key)
-{
- struct gui_priv *this_=(struct gui_priv*) data;
- int w,h;
- struct point p;
- transform_get_size(navit_get_trans(this_->nav), &w, &h);
- switch (*key) {
- case NAVIT_KEY_UP:
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(this_->nav, &p, 1);
- break;
- case NAVIT_KEY_DOWN:
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(this_->nav, &p, 1);
- break;
- case NAVIT_KEY_LEFT:
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(this_->nav, &p, 1);
- break;
- case NAVIT_KEY_RIGHT:
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(this_->nav, &p, 1);
- break;
- case NAVIT_KEY_ZOOM_IN:
- navit_zoom_in(this_->nav, 2, NULL);
- break;
- case NAVIT_KEY_ZOOM_OUT:
- navit_zoom_out(this_->nav, 2, NULL);
- break;
- case NAVIT_KEY_RETURN:
- case NAVIT_KEY_MENU:
- p.x=w/2;
- p.y=h/2;
- this_->guiProxy->switchToMenu(&p);
- break;
- }
- return;
+static void gui_qml_keypress(void *data, char *key) {
+ struct gui_priv *this_=(struct gui_priv*) data;
+ int w,h;
+ struct point p;
+ transform_get_size(navit_get_trans(this_->nav), &w, &h);
+ switch (*key) {
+ case NAVIT_KEY_UP:
+ p.x=w/2;
+ p.y=0;
+ navit_set_center_screen(this_->nav, &p, 1);
+ break;
+ case NAVIT_KEY_DOWN:
+ p.x=w/2;
+ p.y=h;
+ navit_set_center_screen(this_->nav, &p, 1);
+ break;
+ case NAVIT_KEY_LEFT:
+ p.x=0;
+ p.y=h/2;
+ navit_set_center_screen(this_->nav, &p, 1);
+ break;
+ case NAVIT_KEY_RIGHT:
+ p.x=w;
+ p.y=h/2;
+ navit_set_center_screen(this_->nav, &p, 1);
+ break;
+ case NAVIT_KEY_ZOOM_IN:
+ navit_zoom_in(this_->nav, 2, NULL);
+ break;
+ case NAVIT_KEY_ZOOM_OUT:
+ navit_zoom_out(this_->nav, 2, NULL);
+ break;
+ case NAVIT_KEY_RETURN:
+ case NAVIT_KEY_MENU:
+ p.x=w/2;
+ p.y=h/2;
+ this_->guiProxy->switchToMenu(&p);
+ break;
+ }
+ return;
}
-static void
-gui_qml_window_closed(struct gui_priv *data)
-{
- struct gui_priv *this_=(struct gui_priv*) data;
- this_->navitProxy->quit();
+static void gui_qml_window_closed(struct gui_priv *data) {
+ struct gui_priv *this_=(struct gui_priv*) data;
+ this_->navitProxy->quit();
}
//GUI interface calls
static int argc=1;
-static char *argv[]={(char *)"navit",NULL};
-
-static int gui_qml_set_graphics(struct gui_priv *this_, struct graphics *gra)
-{
- QString xid;
- NGQMainWindow* _mainWindow;
- bool ok;
-
- this_->gra=gra;
-
- //Check if we are already in Qt environment
- if (QApplication::instance()==NULL) {
- //Not yet
- this_->app=new QApplication(argc,argv);
- } else {
- this_->app=QApplication::instance();
- }
-
- //Link graphics events
- this_->button_cb=callback_new_attr_1(callback_cast(gui_qml_button), attr_button, this_);
- graphics_add_callback(gra, this_->button_cb);
- this_->motion_cb=callback_new_attr_1(callback_cast(gui_qml_motion), attr_motion, this_);
- graphics_add_callback(gra, this_->motion_cb);
- this_->resize_cb=callback_new_attr_1(callback_cast(gui_qml_resize), attr_resize, this_);
- graphics_add_callback(gra, this_->resize_cb);
- this_->keypress_cb=callback_new_attr_1(callback_cast(gui_qml_keypress), attr_keypress, this_);
- graphics_add_callback(gra, this_->keypress_cb);
- this_->window_closed_cb=callback_new_attr_1(callback_cast(gui_qml_window_closed), attr_window_closed, this_);
- graphics_add_callback(gra, this_->window_closed_cb);
-
-
- //Create main window
- this_->switcherWidget = new QStackedLayout();
- _mainWindow = new NGQMainWindow(this_, NULL);
+static char *argv[]= {(char *)"navit",NULL};
+
+static int gui_qml_set_graphics(struct gui_priv *this_, struct graphics *gra) {
+ QString xid;
+ NGQMainWindow* _mainWindow;
+ bool ok;
+
+ this_->gra=gra;
+
+ //Check if we are already in Qt environment
+ if (QApplication::instance()==NULL) {
+ //Not yet
+ this_->app=new QApplication(argc,argv);
+ } else {
+ this_->app=QApplication::instance();
+ }
+
+ //Link graphics events
+ this_->button_cb=callback_new_attr_1(callback_cast(gui_qml_button), attr_button, this_);
+ graphics_add_callback(gra, this_->button_cb);
+ this_->motion_cb=callback_new_attr_1(callback_cast(gui_qml_motion), attr_motion, this_);
+ graphics_add_callback(gra, this_->motion_cb);
+ this_->resize_cb=callback_new_attr_1(callback_cast(gui_qml_resize), attr_resize, this_);
+ graphics_add_callback(gra, this_->resize_cb);
+ this_->keypress_cb=callback_new_attr_1(callback_cast(gui_qml_keypress), attr_keypress, this_);
+ graphics_add_callback(gra, this_->keypress_cb);
+ this_->window_closed_cb=callback_new_attr_1(callback_cast(gui_qml_window_closed), attr_window_closed, this_);
+ graphics_add_callback(gra, this_->window_closed_cb);
+
+
+ //Create main window
+ this_->switcherWidget = new QStackedLayout();
+ _mainWindow = new NGQMainWindow(this_, NULL);
#ifdef Q_WS_X11
- xid=getenv("NAVIT_XID");
- if (xid.length()>0) {
- _mainWindow->embedInto(xid.toULong(&ok,0));
- }else{
- dbg(lvl_error, "\nFATAL: Environment variable NAVIT_XID not set.\n"
- " Please set NAVIT_XID to the window ID of the window to embed into.\n");
- exit(1);
- }
+ xid=getenv("NAVIT_XID");
+ if (xid.length()>0) {
+ _mainWindow->embedInto(xid.toULong(&ok,0));
+ } else {
+ dbg(lvl_error, "FATAL: Environment variable NAVIT_XID not set."
+ " Please set NAVIT_XID to the window ID of the window to embed into.\n");
+ exit(1);
+ }
#endif /* Q_WS_X11 */
- this_->mainWindow=_mainWindow;
- if ( this_->w && this_->h ) {
- this_->mainWindow->resize(this_->w,this_->h);
- }
- if ( this_->fullscreen ) {
- this_->mainWindow->showFullScreen();
- }
-
- this_->mainWindow->setLayout(this_->switcherWidget);
-
- //Create proxy object and bind them to gui widget
- this_->guiProxy = new NGQProxyGui(this_,this_->mainWindow);
- this_->navitProxy = new NGQProxyNavit(this_,this_->mainWindow);
- this_->vehicleProxy = new NGQProxyVehicle(this_,this_->mainWindow);
- this_->searchProxy = new NGQProxySearch(this_,this_->mainWindow);
- this_->bookmarksProxy = new NGQProxyBookmarks(this_,this_->mainWindow);
- this_->routeProxy = new NGQProxyRoute(this_,this_->mainWindow);
-
- //Check, if we have compatible graphics
- this_->graphicsWidget = (QWidget*)graphics_get_data(gra,"qt_widget");
- if (this_->graphicsWidget == NULL ) {
- this_->graphicsWidget = new QLabel(QString("Sorry, current graphics type is incompatible with this gui."));
- }
+ this_->mainWindow=_mainWindow;
+ if ( this_->w && this_->h ) {
+ this_->mainWindow->resize(this_->w,this_->h);
+ }
+ if ( this_->fullscreen ) {
+ this_->mainWindow->showFullScreen();
+ }
+
+ this_->mainWindow->setLayout(this_->switcherWidget);
+
+ //Create proxy object and bind them to gui widget
+ this_->guiProxy = new NGQProxyGui(this_,this_->mainWindow);
+ this_->navitProxy = new NGQProxyNavit(this_,this_->mainWindow);
+ this_->vehicleProxy = new NGQProxyVehicle(this_,this_->mainWindow);
+ this_->searchProxy = new NGQProxySearch(this_,this_->mainWindow);
+ this_->bookmarksProxy = new NGQProxyBookmarks(this_,this_->mainWindow);
+ this_->routeProxy = new NGQProxyRoute(this_,this_->mainWindow);
+
+ //Check, if we have compatible graphics
+ this_->graphicsWidget = (QWidget*)graphics_get_data(gra,"qt_widget");
+ if (this_->graphicsWidget == NULL ) {
+ this_->graphicsWidget = new QLabel(QString("Sorry, current graphics type is incompatible with this gui."));
+ }
this_->switcherWidget->addWidget(this_->graphicsWidget);
-
- //Instantiate qml components
+
+ //Instantiate qml components
this_->guiWidget = new QDeclarativeView(NULL);
- this_->guiWidget->setResizeMode(QDeclarativeView::SizeRootObjectToView);
-
- this_->guiWidget->rootContext()->setContextProperty("gui",this_->guiProxy);
- this_->guiWidget->rootContext()->setContextProperty("navit",this_->navitProxy);
- this_->guiWidget->rootContext()->setContextProperty("vehicle",this_->vehicleProxy);
- this_->guiWidget->rootContext()->setContextProperty("search",this_->searchProxy);
- this_->guiWidget->rootContext()->setContextProperty("bookmarks",this_->bookmarksProxy);
- this_->guiWidget->rootContext()->setContextProperty("route",this_->routeProxy);
- this_->guiWidget->rootContext()->setContextProperty("point",this_->currentPoint);
-
- QString mainQml = QString(this_->source)+"/"+this_->skin+"/main.qml";
- if (!QFile(mainQml).exists()){
- dbg(lvl_error, "FATAL: QML file %s not found. Navit is not installed correctly.\n", mainQml.toAscii().constData());
- exit(1);
- }
- this_->guiWidget->setSource(QUrl::fromLocalFile(mainQml));
- this_->switcherWidget->addWidget(this_->guiWidget);
-
- //Switch to graphics
- navit_draw(this_->nav);
- this_->switcherWidget->setCurrentWidget(this_->graphicsWidget);
-
- this_->mainWindow->show();
-
- return 0;
+ this_->guiWidget->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+
+ this_->guiWidget->rootContext()->setContextProperty("gui",this_->guiProxy);
+ this_->guiWidget->rootContext()->setContextProperty("navit",this_->navitProxy);
+ this_->guiWidget->rootContext()->setContextProperty("vehicle",this_->vehicleProxy);
+ this_->guiWidget->rootContext()->setContextProperty("search",this_->searchProxy);
+ this_->guiWidget->rootContext()->setContextProperty("bookmarks",this_->bookmarksProxy);
+ this_->guiWidget->rootContext()->setContextProperty("route",this_->routeProxy);
+ this_->guiWidget->rootContext()->setContextProperty("point",this_->currentPoint);
+
+ QString mainQml = QString(this_->source)+"/"+this_->skin+"/main.qml";
+ if (!QFile(mainQml).exists()) {
+ dbg(lvl_error, "FATAL: QML file %s not found. Navit is not installed correctly.", mainQml.toAscii().constData());
+ exit(1);
+ }
+ this_->guiWidget->setSource(QUrl::fromLocalFile(mainQml));
+ this_->switcherWidget->addWidget(this_->guiWidget);
+
+ //Switch to graphics
+ navit_draw(this_->nav);
+ this_->switcherWidget->setCurrentWidget(this_->graphicsWidget);
+
+ this_->mainWindow->show();
+
+ return 0;
}
-static int
-gui_qml_get_attr(struct gui_priv *this_, enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_fullscreen:
- attr->u.num=this_->fullscreen;
- break;
- case attr_skin:
- attr->u.str=this_->skin;
- break;
- case attr_pitch:
- attr->u.num=this_->pitch;
- break;
- case attr_radius:
- attr->u.num=this_->radius;
- break;
- default:
- return 0;
- }
- attr->type=type;
- return 1;
+static int gui_qml_get_attr(struct gui_priv *this_, enum attr_type type, struct attr *attr) {
+ switch (type) {
+ case attr_fullscreen:
+ attr->u.num=this_->fullscreen;
+ break;
+ case attr_skin:
+ attr->u.str=this_->skin;
+ break;
+ case attr_pitch:
+ attr->u.num=this_->pitch;
+ break;
+ case attr_radius:
+ attr->u.num=this_->radius;
+ break;
+ default:
+ return 0;
+ }
+ attr->type=type;
+ return 1;
}
-static int
-gui_qml_set_attr(struct gui_priv *this_, struct attr *attr)
-{
- switch (attr->type) {
- case attr_fullscreen:
- if (!(this_->fullscreen) && (attr->u.num)) {
- this_->mainWindow->showFullScreen();
- }
- if ((this_->fullscreen) && !(attr->u.num)) {
- this_->mainWindow->showNormal();
- }
- this_->fullscreen=attr->u.num;
- return 1;
- case attr_pitch:
- this_->pitch=attr->u.num;
- return 1;
- case attr_radius:
- this_->radius=attr->u.num;
- return 1;
- default:
- dbg(lvl_error,"unknown attr: %s\n",attr_to_name(attr->type));
- return 1;
- }
+static int gui_qml_set_attr(struct gui_priv *this_, struct attr *attr) {
+ switch (attr->type) {
+ case attr_fullscreen:
+ if (!(this_->fullscreen) && (attr->u.num)) {
+ this_->mainWindow->showFullScreen();
+ }
+ if ((this_->fullscreen) && !(attr->u.num)) {
+ this_->mainWindow->showNormal();
+ }
+ this_->fullscreen=attr->u.num;
+ return 1;
+ case attr_pitch:
+ this_->pitch=attr->u.num;
+ return 1;
+ case attr_radius:
+ this_->radius=attr->u.num;
+ return 1;
+ default:
+ dbg(lvl_error,"unknown attr: %s",attr_to_name(attr->type));
+ return 1;
+ }
}
struct gui_methods gui_qml_methods = {
- NULL,
- NULL,
+ NULL,
+ NULL,
gui_qml_set_graphics,
- NULL,
- NULL,
- NULL,
- NULL,
- gui_qml_get_attr,
- NULL,
- gui_qml_set_attr,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ gui_qml_get_attr,
+ NULL,
+ gui_qml_set_attr,
};
-static void
-gui_qml_command(struct gui_priv *this_, char *function, struct attr **in, struct attr ***out, int *valid) {
- this_->guiProxy->processCommand(function);
+static void gui_qml_command(struct gui_priv *this_, char *function, struct attr **in, struct attr ***out, int *valid) {
+ this_->guiProxy->processCommand(function);
}
static struct command_table commands[] = {
- {"*",command_cast(gui_qml_command)},
+ {"*",command_cast(gui_qml_command)},
};
-static struct gui_priv * gui_qml_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui)
-{
- struct gui_priv *this_;
- struct attr *attr;
- *meth=gui_qml_methods;
- this_=g_new0(struct gui_priv, 1);
-
- this_->nav=nav;
- this_->gui=gui;
-
- this_->self.type=attr_gui;
- this_->self.u.gui=gui;
-
- navit_ignore_graphics_events(this_->nav, 1);
-
- this_->fullscreen = 0; //NO by default
- if( (attr=attr_search(attrs,NULL,attr_fullscreen)))
- this_->fullscreen=attr->u.num;
- this_->menu_on_map_click = 1; //YES by default;
- if( (attr=attr_search(attrs,NULL,attr_menu_on_map_click)))
- this_->menu_on_map_click=attr->u.num;
- this_->signal_on_map_click = 0; //YES by default;
- if( (attr=attr_search(attrs,NULL,attr_signal_on_map_click)))
- this_->signal_on_map_click=attr->u.num;
- this_->radius = 10; //Default value
- if( (attr=attr_search(attrs,NULL,attr_radius)))
- this_->radius=attr->u.num;
- this_->pitch = 20; //Default value
- if( (attr=attr_search(attrs,NULL,attr_pitch)))
- this_->pitch=attr->u.num;
- this_->lazy = 1; //YES by default
- if( (attr=attr_search(attrs,NULL,attr_lazy)))
- this_->lazy=attr->u.num;
- this_->w=800; //Default value
- if( (attr=attr_search(attrs,NULL,attr_width)))
- this_->w=attr->u.num;
- this_->h=600; //Default value
- if( (attr=attr_search(attrs,NULL,attr_height)))
- this_->h=attr->u.num;
- if( (attr=attr_search(attrs,NULL,attr_source)))
- this_->source=attr->u.str;
- if( (attr=attr_search(attrs,NULL,attr_skin)))
- this_->skin=attr->u.str;
- if( (attr=attr_search(attrs,NULL,attr_icon_src)))
- this_->icon_src=attr->u.str;
-
- if ( this_->source==NULL ) {
- this_->source=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"),"/gui/qml/skins",NULL);
- }
- if ( this_->skin==NULL ) {
- this_->skin=g_strdup("navit");
- }
- if ( this_->icon_src==NULL ) {
- this_->icon_src=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"),"/icons/",NULL);
- }
-
- if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
- command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this_);
- }
-
- this_->cbl=callback_list_new();
-
- return this_;
+static struct gui_priv * gui_qml_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs,
+ struct gui *gui) {
+ struct gui_priv *this_;
+ struct attr *attr;
+ *meth=gui_qml_methods;
+ this_=g_new0(struct gui_priv, 1);
+
+ this_->nav=nav;
+ this_->gui=gui;
+
+ this_->self.type=attr_gui;
+ this_->self.u.gui=gui;
+
+ navit_ignore_graphics_events(this_->nav, 1);
+
+ this_->fullscreen = 0; //NO by default
+ if( (attr=attr_search(attrs,NULL,attr_fullscreen)))
+ this_->fullscreen=attr->u.num;
+ this_->menu_on_map_click = 1; //YES by default;
+ if( (attr=attr_search(attrs,NULL,attr_menu_on_map_click)))
+ this_->menu_on_map_click=attr->u.num;
+ this_->signal_on_map_click = 0; //YES by default;
+ if( (attr=attr_search(attrs,NULL,attr_signal_on_map_click)))
+ this_->signal_on_map_click=attr->u.num;
+ this_->radius = 10; //Default value
+ if( (attr=attr_search(attrs,NULL,attr_radius)))
+ this_->radius=attr->u.num;
+ this_->pitch = 20; //Default value
+ if( (attr=attr_search(attrs,NULL,attr_pitch)))
+ this_->pitch=attr->u.num;
+ this_->lazy = 1; //YES by default
+ if( (attr=attr_search(attrs,NULL,attr_lazy)))
+ this_->lazy=attr->u.num;
+ this_->w=800; //Default value
+ if( (attr=attr_search(attrs,NULL,attr_width)))
+ this_->w=attr->u.num;
+ this_->h=600; //Default value
+ if( (attr=attr_search(attrs,NULL,attr_height)))
+ this_->h=attr->u.num;
+ if( (attr=attr_search(attrs,NULL,attr_source)))
+ this_->source=attr->u.str;
+ if( (attr=attr_search(attrs,NULL,attr_skin)))
+ this_->skin=attr->u.str;
+ if( (attr=attr_search(attrs,NULL,attr_icon_src)))
+ this_->icon_src=attr->u.str;
+
+ if ( this_->source==NULL ) {
+ this_->source=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"),"/gui/qml/skins",NULL);
+ }
+ if ( this_->skin==NULL ) {
+ this_->skin=g_strdup("navit");
+ }
+ if ( this_->icon_src==NULL ) {
+ this_->icon_src=g_strjoin(NULL,getenv("NAVIT_SHAREDIR"),"/icons/",NULL);
+ }
+
+ if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
+ command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this_);
+ }
+
+ this_->cbl=callback_list_new();
+
+ return this_;
}
void plugin_init(void) {
diff --git a/navit/gui/qml/navitProxy.h b/navit/gui/qml/navitProxy.h
index 423863b0e..d3f8a0e86 100644
--- a/navit/gui/qml/navitProxy.h
+++ b/navit/gui/qml/navitProxy.h
@@ -51,7 +51,7 @@ public slots:
while (getAttrFunc(attr_from_name(attr_name.toStdString().c_str()), &attr, iter) ) {
QStandardItem* curItem=new QStandardItem();
- //Listed attributes are usualy have very complex structure
+ //Listed attributes are usualy have very complex structure
if (attr.type==attr_layout) {
curItem->setData(QVariant(counter),NGQStandardItemModel::ItemId);
curItem->setData(QVariant(attr.u.layout->name),NGQStandardItemModel::ItemName);
diff --git a/navit/gui/qml/ngqpoint.h b/navit/gui/qml/ngqpoint.h
index 05142e5bf..14aaddc61 100644
--- a/navit/gui/qml/ngqpoint.h
+++ b/navit/gui/qml/ngqpoint.h
@@ -94,7 +94,7 @@ public:
this->c.x = c->x;
this->c.y = c->y;
this->type=type;
-
+
this->name=name;
this->coord=this->_coordString();
}
@@ -116,7 +116,7 @@ public slots:
this->coord=this->_coordString();
}
QString pointName() {
- return this->name;
+ return this->name;
}
QString coordString() {
return this->coord;
@@ -248,7 +248,7 @@ public slots:
}
map_selection_destroy(sel);
mapset_close(h);
- dbg(lvl_info,"%s\n",retDoc.toString().toLocal8Bit().constData());
+ dbg(lvl_info,"%s",retDoc.toString().toLocal8Bit().constData());
return retDoc.toString();
}
protected:
@@ -311,12 +311,12 @@ protected:
mr=map_rect_new(m, &sel);
if (! mr)
continue;
- while ((item=map_rect_get_item(mr))) {
+ while ((item=map_rect_get_item(mr))) {
data=street_get_data(item);
- if (transform_within_dist_item(&co, item->type, data->c, data->count, dist)) {
+ if (transform_within_dist_item(&co, item->type, data->c, data->count, dist)) {
if (item_attr_get(item, attr_label, &attr)) {
label=map_convert_string(m, attr.u.str);
- this->item=*item;
+ this->item=*item;
this->_setUrl(item);
if (QString(item_to_name(item->type)).startsWith(QString("poi_"))) {
ret=QString::fromLocal8Bit(item_to_name(item->type));
diff --git a/navit/gui/qml/proxy.h b/navit/gui/qml/proxy.h
index 3243dc8cb..ebdb0667a 100644
--- a/navit/gui/qml/proxy.h
+++ b/navit/gui/qml/proxy.h
@@ -35,7 +35,7 @@ public slots:
QString getAttr(const QString &attr_name) {
QString ret;
struct attr attr;
-
+
getAttrFunc(attr_from_name(attr_name.toStdString().c_str()), &attr, NULL);
if (ATTR_IS_INT(attr.type)) {
ret.setNum(attr.u.num);
@@ -55,7 +55,7 @@ public slots:
struct attr attr_value;
double *helper;
- dbg(lvl_debug,"Setting %s to %s\n",attr_name.toStdString().c_str(),attr_string.toStdString().c_str());
+ dbg(lvl_debug,"Setting %s to %s",attr_name.toStdString().c_str(),attr_string.toStdString().c_str());
getAttrFunc(attr_from_name(attr_name.toStdString().c_str()), &attr_value, NULL);
if (ATTR_IS_INT(attr_value.type)) {
@@ -81,7 +81,7 @@ public slots:
return;
}
-
+
int itemId() {
return _itemId;
}
diff --git a/navit/gui/qml/routeProxy.h b/navit/gui/qml/routeProxy.h
index a2fb4c793..fb76c492c 100644
--- a/navit/gui/qml/routeProxy.h
+++ b/navit/gui/qml/routeProxy.h
@@ -14,13 +14,13 @@ public slots:
QList<struct attr> destinations=this->_routeDestinations();
struct pcoord *coords=(struct pcoord*)malloc(sizeof(struct pcoord)*(destinations.size()+1)); //Additional destination included
- for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {
+ for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {
coords[counter]=*(iter->u.pcoord);
counter++;
}
//Add new one
- coords[counter]=*(this->object->currentPoint->pc());
+ coords[counter]=*(this->object->currentPoint->pc());
//Propagate to route engine
route_set_destinations(navit_get_route(this->object->nav),coords,counter+1,1);
@@ -30,7 +30,7 @@ public slots:
QList<struct attr> destinations=this->_routeDestinations();
for (QList<struct attr>::const_iterator iter=destinations.begin();iter!=destinations.end();iter++) {
NGQPoint helperPoint(this->object,iter->u.pcoord,MapPoint);
- dbg(lvl_debug,"Added destination %s\n",helperPoint.coordString().toLocal8Bit().constData());
+ dbg(lvl_debug,"Added destination %s",helperPoint.coordString().toLocal8Bit().constData());
}
//dbg(lvl_debug,QString::number(_itemId).toStdString().c_str());
diff --git a/navit/gui/qml/searchProxy.h b/navit/gui/qml/searchProxy.h
index 579ac3dac..3d76dc0dd 100644
--- a/navit/gui/qml/searchProxy.h
+++ b/navit/gui/qml/searchProxy.h
@@ -33,7 +33,7 @@ public:
item=country_search_get_item(cs);
if (item && item_attr_get(item, attr_country_name, &country_name)) {
search_attr.type=attr_country_all;
- dbg(lvl_debug,"country %s\n", country_name.u.str);
+ dbg(lvl_debug,"country %s", country_name.u.str);
this->country_name=QString::fromLocal8Bit(country_name.u.str);
search_attr.u.str=country_name.u.str;
search_list_search(this->sl, &search_attr, 0);
@@ -44,15 +44,15 @@ public:
}
country_search_destroy(cs);
} else {
- dbg(lvl_error,"warning: no default country found\n");
+ dbg(lvl_error,"warning: no default country found");
if (!this->country_iso2.isEmpty()) {
- dbg(lvl_debug,"attempting to use country '%s'\n",this->country_iso2.toStdString().c_str());
+ dbg(lvl_debug,"attempting to use country '%s'",this->country_iso2.toStdString().c_str());
search_attr.type=attr_country_iso2;
search_attr.u.str=(char*)this->country_iso2.toStdString().c_str();
search_list_search(this->sl, &search_attr, 0);
while((res=search_list_get_result(this->sl)));
}
- }
+ }
}
~NGQProxySearch() {
search_list_destroy(this->sl);
@@ -131,7 +131,7 @@ public slots:
}
if (res->town->common.district_name) {
entry.appendChild(this->_fieldValueHelper(retDoc,QString("name"), QString::fromLocal8Bit(res->town->common.district_name)));
- }
+ }
}
if (this->search_context=="street") {
entry.appendChild(this->_fieldValueHelper(retDoc,QString("id"), QString::number(counter)));
@@ -150,8 +150,8 @@ public slots:
this->country_name=countryName;
struct attr attr;
struct search_list_result *res;
-
- //We need to update ISO2
+
+ //We need to update ISO2
attr.type=attr_country_name;
attr.u.str=countryName.toLocal8Bit().data();
search_list_search(this->sl,&attr,0);
@@ -183,7 +183,7 @@ public slots:
attr.type=attr_town_or_district_name;
attr.u.str=townName.toLocal8Bit().data();
search_list_search(this->sl,&attr,0);
-
+
//...and street
this->street_name="";
diff --git a/navit/gui/qml/skins/navit/ButtonIcon.qml b/navit/gui/qml/skins/navit/ButtonIcon.qml
index f969ebb5a..6e0f8f032 100644
--- a/navit/gui/qml/skins/navit/ButtonIcon.qml
+++ b/navit/gui/qml/skins/navit/ButtonIcon.qml
@@ -1,40 +1,40 @@
-import Qt 4.7
-
-Rectangle {
+import Qt 4.7
+
+Rectangle {
id: container
-
- signal clicked
- property string text: "Button"
- property string icon: "Icon.png"
-
- color: "black"; smooth: true; opacity: 0.75
- width: imgItem.width+20; height: txtItem.height + 6 + imgItem.height;
- transformOrigin: Rectangle.Center;
-
- MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
-
- Image {
- id: imgItem; source: gui.iconPath+container.icon; anchors.top: container.top; anchors.horizontalCenter: container.horizontalCenter;
- width: gui.height/4; height: gui.height/4
- }
-
- Text {
- id: txtItem; text: container.text; anchors.top: imgItem.bottom; anchors.horizontalCenter: container.horizontalCenter;
- color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
- }
-
- states: [
- State {
- name: "Pressed"; when: mr.pressed == true
- PropertyChanges { target: container; scale: 2.0 }
- PropertyChanges { target: container; opacity: 1 }
-
- }
- ]
-
- transitions: Transition {
- NumberAnimation { properties: "scale"; easing.type: "OutExpo"; duration: 200 }
- NumberAnimation { properties: "opacity"; easing.type: "InQuad"; duration: 200 }
- }
-
-}
+
+ signal clicked
+ property string text: "Button"
+ property string icon: "Icon.png"
+
+ color: "black"; smooth: true; opacity: 0.75
+ width: imgItem.width+20; height: txtItem.height + 6 + imgItem.height;
+ transformOrigin: Rectangle.Center;
+
+ MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+
+ Image {
+ id: imgItem; source: gui.iconPath+container.icon; anchors.top: container.top; anchors.horizontalCenter: container.horizontalCenter;
+ width: gui.height/4; height: gui.height/4
+ }
+
+ Text {
+ id: txtItem; text: container.text; anchors.top: imgItem.bottom; anchors.horizontalCenter: container.horizontalCenter;
+ color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
+ }
+
+ states: [
+ State {
+ name: "Pressed"; when: mr.pressed == true
+ PropertyChanges { target: container; scale: 2.0 }
+ PropertyChanges { target: container; opacity: 1 }
+
+ }
+ ]
+
+ transitions: Transition {
+ NumberAnimation { properties: "scale"; easing.type: "OutExpo"; duration: 200 }
+ NumberAnimation { properties: "opacity"; easing.type: "InQuad"; duration: 200 }
+ }
+
+}
diff --git a/navit/gui/qml/skins/navit/Cellar.qml b/navit/gui/qml/skins/navit/Cellar.qml
index de4d3c146..89ecfc899 100644
--- a/navit/gui/qml/skins/navit/Cellar.qml
+++ b/navit/gui/qml/skins/navit/Cellar.qml
@@ -3,14 +3,14 @@ import "pagenavigation.js" as Navit
Rectangle {
- function onStartup(currentPage) {
+ function onStartup(currentPage) {
btnBack.opacity=0;
btnQuit.opacity=0;
if ( gui.lengthPage() > 1 ) {
btnBack.opacity=1;
}
if ( gui.lengthPage() == 1 && currentPage == "PageMain.qml" ) {
- btnQuit.opacity=1;
+ btnQuit.opacity=1;
}
}
diff --git a/navit/gui/qml/skins/navit/ListSelector.qml b/navit/gui/qml/skins/navit/ListSelector.qml
index 09c927cf1..9480275be 100644
--- a/navit/gui/qml/skins/navit/ListSelector.qml
+++ b/navit/gui/qml/skins/navit/ListSelector.qml
@@ -17,8 +17,8 @@ Rectangle {
listScroller.opacity=0.5;
}
}
-
- Component.onCompleted: startup();
+
+ Component.onCompleted: startup();
Text {
id: labelTxt; text: listselector.text; color: "White"; font.pointSize: 22;
@@ -37,7 +37,7 @@ Rectangle {
clip: true
highlightFollowsCurrentItem: true
keyNavigationWraps: true
-
+
Component.onCompleted: { list.currentIndex=listselector.itemId; }
}
Rectangle {
diff --git a/navit/gui/qml/skins/navit/PageAbout.qml b/navit/gui/qml/skins/navit/PageAbout.qml
index a96baabca..b026e73be 100644
--- a/navit/gui/qml/skins/navit/PageAbout.qml
+++ b/navit/gui/qml/skins/navit/PageAbout.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PageBookmarks.qml b/navit/gui/qml/skins/navit/PageBookmarks.qml
index 15a5982b6..46da8d865 100644
--- a/navit/gui/qml/skins/navit/PageBookmarks.qml
+++ b/navit/gui/qml/skins/navit/PageBookmarks.qml
@@ -11,7 +11,7 @@ Rectangle {
function bookmarkReload() {
listModel.xml=bookmarks.getBookmarks();
listModel.query="/bookmarks/bookmark";
- listModel.reload();
+ listModel.reload();
}
function bookmarkClick(itemName,itemType,itemCoord) {
@@ -31,9 +31,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -41,7 +41,7 @@ Rectangle {
ButtonIcon { id: folderBtn; text: "New folder"; icon: "gui_active.svg"; onClicked: folderDialog.opacity=1
anchors.top: parent.top; anchors.topMargin: page.height/16; anchors.left: parent.left; anchors.leftMargin: page.width/16
}
- ButtonIcon { id: pasteBtn; text: "Paste"; icon: "gui_active.svg"; onClicked: { bookmarks.Paste(); bookmarkReload(); }
+ ButtonIcon { id: pasteBtn; text: "Paste"; icon: "gui_active.svg"; onClicked: { bookmarks.Paste(); bookmarkReload(); }
anchors.top: parent.top; anchors.topMargin: page.height/16; anchors.left: folderBtn.right; anchors.leftMargin: page.width/16
}
@@ -109,7 +109,7 @@ Rectangle {
}
}
- ListSelector {
+ ListSelector {
id:layoutList; text: ""
anchors.top: pasteBtn.bottom;
anchors.left: parent.left;
diff --git a/navit/gui/qml/skins/navit/PageBookmarksAdd.qml b/navit/gui/qml/skins/navit/PageBookmarksAdd.qml
index 39694d2af..c02aea7c3 100644
--- a/navit/gui/qml/skins/navit/PageBookmarksAdd.qml
+++ b/navit/gui/qml/skins/navit/PageBookmarksAdd.qml
@@ -25,9 +25,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PageNavigate.qml b/navit/gui/qml/skins/navit/PageNavigate.qml
index 3d4e04bc2..32e43841f 100644
--- a/navit/gui/qml/skins/navit/PageNavigate.qml
+++ b/navit/gui/qml/skins/navit/PageNavigate.qml
@@ -23,9 +23,9 @@ Rectangle {
}
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PagePoi.qml b/navit/gui/qml/skins/navit/PagePoi.qml
index 4ab9f5c0f..71f21bb2f 100644
--- a/navit/gui/qml/skins/navit/PagePoi.qml
+++ b/navit/gui/qml/skins/navit/PagePoi.qml
@@ -64,9 +64,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -138,7 +138,7 @@ Rectangle {
}
}
- ListSelector {
+ ListSelector {
id:layoutList; text: ""
anchors.top: distanceSlider.bottom;
anchors.left: parent.left;
diff --git a/navit/gui/qml/skins/navit/PagePointInfo.qml b/navit/gui/qml/skins/navit/PagePointInfo.qml
index 1014c63df..c33027e26 100644
--- a/navit/gui/qml/skins/navit/PagePointInfo.qml
+++ b/navit/gui/qml/skins/navit/PagePointInfo.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -68,7 +68,7 @@ Rectangle {
}
}
- ListSelector {
+ ListSelector {
id:layoutList; text: "Attributes";
anchors.top: urlTxt.bottom;
anchors.left: parent.left;
diff --git a/navit/gui/qml/skins/navit/PageRoute.qml b/navit/gui/qml/skins/navit/PageRoute.qml
index a340eaa1b..ea71569b3 100644
--- a/navit/gui/qml/skins/navit/PageRoute.qml
+++ b/navit/gui/qml/skins/navit/PageRoute.qml
@@ -20,9 +20,9 @@ Rectangle {
}
route.getDestinations();
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PageSearch.qml b/navit/gui/qml/skins/navit/PageSearch.qml
index 3d9419920..bc93dce52 100644
--- a/navit/gui/qml/skins/navit/PageSearch.qml
+++ b/navit/gui/qml/skins/navit/PageSearch.qml
@@ -20,9 +20,9 @@ Rectangle {
}
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -36,19 +36,19 @@ Rectangle {
columns: 1;rows: 2;
id: gridCountry;
Text {
- id: txtItemCountry; text: "Country";
+ id: txtItemCountry; text: "Country";
color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
}
ButtonIcon {
id: btnCountry; text: search.countryName; icon: "country_"+search.countryISO2+".svgz"; onClicked: { search.searchContext="country"; Navit.load("PageSearchSelector.qml"); }
- }
+ }
}
Grid {
columns: 1; rows: 2;
id: gridCity
opacity: 0;
Text {
- id: txtItemCity; text: "Town";
+ id: txtItemCity; text: "Town";
color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
}
ButtonIcon {
@@ -67,7 +67,7 @@ Rectangle {
id: gridStreet
opacity: 0;
Text {
- id: txtItemStreet; text: "Street";
+ id: txtItemStreet; text: "Street";
color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
}
ButtonIcon {
@@ -79,7 +79,7 @@ Rectangle {
id: gridAddress;
opacity: 0;
Text {
- id: txtItemAddress; text: "Address";
+ id: txtItemAddress; text: "Address";
color: "White"; font.pointSize: gui.height/32; horizontalAlignment: Qt.AlignHCenter
}
ButtonIcon {
diff --git a/navit/gui/qml/skins/navit/PageSearchSelector.qml b/navit/gui/qml/skins/navit/PageSearchSelector.qml
index ec1ca73dd..d47fcbc71 100644
--- a/navit/gui/qml/skins/navit/PageSearchSelector.qml
+++ b/navit/gui/qml/skins/navit/PageSearchSelector.qml
@@ -40,15 +40,15 @@ Rectangle {
}
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
TextInput{
- id: searchTxt;
+ id: searchTxt;
anchors.top: parent.top; anchors.left: parent.left; anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
width: page.width; font.pointSize: 14; color: "White";focus: true; readOnly: false; cursorVisible: true;
}
@@ -78,8 +78,8 @@ Rectangle {
id: imgIcon; source: gui.iconPath+itemIcon
width: 20; height: 20;
}
- Text {
- id: txtItemName; text: itemName; color: "White";
+ Text {
+ id: txtItemName; text: itemName; color: "White";
anchors.left: imgIcon.right;anchors.leftMargin: 5
width: list.width-imgIcon.width
}
@@ -98,7 +98,7 @@ Rectangle {
}
}
- ListSelector {
+ ListSelector {
id:layoutList; text: search.searchContext; onChanged: setSearchResult()
anchors.top: searchTxt.bottom; anchors.left: parent.left; anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
width: page.width; height: page.height/2-cellar.height
diff --git a/navit/gui/qml/skins/navit/PageSettings.qml b/navit/gui/qml/skins/navit/PageSettings.qml
index f7efcacd5..2030fe56f 100644
--- a/navit/gui/qml/skins/navit/PageSettings.qml
+++ b/navit/gui/qml/skins/navit/PageSettings.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
diff --git a/navit/gui/qml/skins/navit/PageSettingsDisplay.qml b/navit/gui/qml/skins/navit/PageSettingsDisplay.qml
index 61db6a385..9d0002d9d 100644
--- a/navit/gui/qml/skins/navit/PageSettingsDisplay.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsDisplay.qml
@@ -34,9 +34,9 @@ Rectangle {
}
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -60,9 +60,9 @@ Rectangle {
}
}
- CommonHighlight { id: listHighlight}
+ CommonHighlight { id: listHighlight}
- ListSelector {
+ ListSelector {
id:layoutList; text: "Current layout"; itemId: navit.getAttrList("layout"); onChanged: navit.setObjectByName("layout",layoutList.value)
anchors.top: parent.top;
anchors.left: parent.left;
diff --git a/navit/gui/qml/skins/navit/PageSettingsLocale.qml b/navit/gui/qml/skins/navit/PageSettingsLocale.qml
index 441248484..ab4afa20d 100644
--- a/navit/gui/qml/skins/navit/PageSettingsLocale.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsLocale.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -22,7 +22,7 @@ Rectangle {
Grid {
columns: 1;rows: 3
anchors.horizontalCenter: parent.horizontalCenter;
- anchors.verticalCenter: parent.verticalCenter;
+ anchors.verticalCenter: parent.verticalCenter;
Text { id: lang; text: gui.localeName; color: "White";font.pointSize: gui.height/24 }
Text { id: langname; text: gui.langName; color: "White";font.pointSize: gui.height/24 }
diff --git a/navit/gui/qml/skins/navit/PageSettingsRules.qml b/navit/gui/qml/skins/navit/PageSettingsRules.qml
index e5238f584..007f36c84 100644
--- a/navit/gui/qml/skins/navit/PageSettingsRules.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsRules.qml
@@ -1,38 +1,38 @@
import Qt 4.7
import "pagenavigation.js" as Navit
-
-Rectangle {
- id: page
-
- width: gui.width; height: gui.height
- border.width: 1
- color: "Black"
- opacity: 0
-
- function pageOpen() {
- page.opacity = 1;
- }
-
- Component.onCompleted: pageOpen();
-
- Behavior on opacity {
- NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
- }
-
- VisualItemModel {
- id: selectorsModel
-
- ToggleSwitch { id: trackingSw; stOn: navit.getAttr("tracking"); text: "Lock on road"; onChanged: navit.setAttr("tracking",trackingSw.stOn) }
- ToggleSwitch { id: orientationSw; stOn: navit.getAttr("orientation"); text: "Northing"; onChanged: navit.setAttr("orientation",orientationSw.stOn) }
- ToggleSwitch { id: followcursorSw; stOn: navit.getAttr("follow_cursor"); text: "Map follows Vehicle"; onChanged: navit.setAttr("follow_cursor",followcursorSw.stOn) }
- ToggleSwitch { id: autozoomSw; stOn: navit.getAttr("autozoom_active"); text: "Auto zoom"; onChanged: navit.setAttr("autozoom_active",autozoomSw.stOn) }
- }
-
- ListView {
- id: selectorsList; model: selectorsModel
- focus: true; clip: true; orientation: Qt.Vertical
- anchors.verticalCenter: parent.verticalCenter; anchors.horizontalCenter: parent.horizontalCenter;
- width: trackingSw.width*1.5; height: trackingSw.height*4
- }
- Cellar {anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width }
-}
+
+Rectangle {
+ id: page
+
+ width: gui.width; height: gui.height
+ border.width: 1
+ color: "Black"
+ opacity: 0
+
+ function pageOpen() {
+ page.opacity = 1;
+ }
+
+ Component.onCompleted: pageOpen();
+
+ Behavior on opacity {
+ NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
+ }
+
+ VisualItemModel {
+ id: selectorsModel
+
+ ToggleSwitch { id: trackingSw; stOn: navit.getAttr("tracking"); text: "Lock on road"; onChanged: navit.setAttr("tracking",trackingSw.stOn) }
+ ToggleSwitch { id: orientationSw; stOn: navit.getAttr("orientation"); text: "Northing"; onChanged: navit.setAttr("orientation",orientationSw.stOn) }
+ ToggleSwitch { id: followcursorSw; stOn: navit.getAttr("follow_cursor"); text: "Map follows Vehicle"; onChanged: navit.setAttr("follow_cursor",followcursorSw.stOn) }
+ ToggleSwitch { id: autozoomSw; stOn: navit.getAttr("autozoom_active"); text: "Auto zoom"; onChanged: navit.setAttr("autozoom_active",autozoomSw.stOn) }
+ }
+
+ ListView {
+ id: selectorsList; model: selectorsModel
+ focus: true; clip: true; orientation: Qt.Vertical
+ anchors.verticalCenter: parent.verticalCenter; anchors.horizontalCenter: parent.horizontalCenter;
+ width: trackingSw.width*1.5; height: trackingSw.height*4
+ }
+ Cellar {anchors.bottom: page.bottom; anchors.horizontalCenter: page.horizontalCenter; width: page.width }
+}
diff --git a/navit/gui/qml/skins/navit/PageSettingsTools.qml b/navit/gui/qml/skins/navit/PageSettingsTools.qml
index a4af1222e..717bdc9fd 100644
--- a/navit/gui/qml/skins/navit/PageSettingsTools.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsTools.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -22,7 +22,7 @@ Rectangle {
Grid {
columns: 1;rows: 1
anchors.horizontalCenter: parent.horizontalCenter;
- anchors.verticalCenter: parent.verticalCenter;
+ anchors.verticalCenter: parent.verticalCenter;
ButtonIcon {
id: btnDisplay; text: "Locale"; icon: "gui_actions.svg"; onClicked: Navit.load("PageSettingsLocale.qml");
}
diff --git a/navit/gui/qml/skins/navit/PageSettingsVehicle.qml b/navit/gui/qml/skins/navit/PageSettingsVehicle.qml
index 157afcb00..189b8fd1f 100644
--- a/navit/gui/qml/skins/navit/PageSettingsVehicle.qml
+++ b/navit/gui/qml/skins/navit/PageSettingsVehicle.qml
@@ -12,9 +12,9 @@ Rectangle {
function pageOpen() {
page.opacity = 1;
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -43,9 +43,9 @@ Rectangle {
}
}
}
- CommonHighlight { id: listHighlight}
+ CommonHighlight { id: listHighlight}
- ListSelector {
+ ListSelector {
id:vehicleList; text: "Current vehicle profile"; itemId: navit.itemId; onChanged: {navit.setObjectByName("vehicle",vehicleList.value) }
anchors.top: parent.top; anchors.topMargin: gui.height/16; anchors.leftMargin: gui.width/32
anchors.left: parent.left; width: page.width/2;height: page.height/2
diff --git a/navit/gui/qml/skins/navit/Slider.qml b/navit/gui/qml/skins/navit/Slider.qml
index e4d56e031..698a9f6e1 100644
--- a/navit/gui/qml/skins/navit/Slider.qml
+++ b/navit/gui/qml/skins/navit/Slider.qml
@@ -39,7 +39,7 @@ Rectangle {
}
MouseArea {
anchors.fill: parent
- onReleased: { knob.x=mouse.x-15; slider.value=Math.round(fromSlider(knob.x)); slider.changed(); }
+ onReleased: { knob.x=mouse.x-15; slider.value=Math.round(fromSlider(knob.x)); slider.changed(); }
}
radius: 8; opacity: 0.7
diff --git a/navit/gui/qml/skins/navit/ToggleButton.qml b/navit/gui/qml/skins/navit/ToggleButton.qml
index 29d986601..30617644b 100644
--- a/navit/gui/qml/skins/navit/ToggleButton.qml
+++ b/navit/gui/qml/skins/navit/ToggleButton.qml
@@ -13,14 +13,14 @@ import Qt 4.7
function toggle() {
if (togglebutton.state == "on")
togglebutton.state = "off";
- else
+ else
togglebutton.state = "on";
}
function startup () {
- if (togglebutton.stOn == "1" )
+ if (togglebutton.stOn == "1" )
togglebutton.stOn = "true";
- else if (togglebutton.stOn == "0" )
+ else if (togglebutton.stOn == "0" )
togglebutton.stOn = "false";
if (togglebutton.stOn == "true")
togglebutton.state = "on";
@@ -38,7 +38,7 @@ import Qt 4.7
}
Text {
- id: txtItem; text: togglebutton.text; anchors.top: imgItem.bottom; anchors.horizontalCenter: togglebutton.horizontalCenter;
+ id: txtItem; text: togglebutton.text; anchors.top: imgItem.bottom; anchors.horizontalCenter: togglebutton.horizontalCenter;
color: "White"; font.pointSize: gui.height/64; horizontalAlignment: Qt.AlignHCenter
}
diff --git a/navit/gui/qml/skins/navit/ToggleSwitch.qml b/navit/gui/qml/skins/navit/ToggleSwitch.qml
index b1b262461..14bc7b0ba 100644
--- a/navit/gui/qml/skins/navit/ToggleSwitch.qml
+++ b/navit/gui/qml/skins/navit/ToggleSwitch.qml
@@ -15,9 +15,9 @@ import Qt 4.7
}
function startup () {
- if (toggleswitch.stOn == "1" )
+ if (toggleswitch.stOn == "1" )
toggleswitch.stOn = "true";
- else if (toggleswitch.stOn == "0" )
+ else if (toggleswitch.stOn == "0" )
toggleswitch.stOn = "false";
if (toggleswitch.stOn == "true")
toggleswitch.state = "on";
diff --git a/navit/gui/qml/skins/navit/command.js b/navit/gui/qml/skins/navit/command.js
index 071653acf..bcf0cf746 100644
--- a/navit/gui/qml/skins/navit/command.js
+++ b/navit/gui/qml/skins/navit/command.js
@@ -1,7 +1,7 @@
import Qt 4.7
Rectangle {
- id: page
+ id: page
function pageOpen(command) {
if ( command=="menu") {
@@ -11,10 +11,10 @@ Rectangle {
if (command=="quit") {
navit.quit();
}
-
+
}
-
- Component.onCompleted: pageOpen(gui.commandFunction);
-
- Text { id: myText; anchors.centerIn: parent; text: "Hi, i'm Navit!"; color: "Black"; font.pointSize: gui.height/32 }
+
+ Component.onCompleted: pageOpen(gui.commandFunction);
+
+ Text { id: myText; anchors.centerIn: parent; text: "Hi, i'm Navit!"; color: "Black"; font.pointSize: gui.height/32 }
}
diff --git a/navit/gui/qml/skins/navit/main.qml b/navit/gui/qml/skins/navit/main.qml
index 20b93d113..344dd182d 100644
--- a/navit/gui/qml/skins/navit/main.qml
+++ b/navit/gui/qml/skins/navit/main.qml
@@ -11,9 +11,9 @@ Rectangle {
function pageOpen() {
Navit.load("PageMain.qml");
}
-
- Component.onCompleted: pageOpen();
-
+
+ Component.onCompleted: pageOpen();
+
Behavior on opacity {
NumberAnimation { id: opacityAnimation; duration: 300; alwaysRunToEnd: true }
}
@@ -25,7 +25,7 @@ Rectangle {
height: gui.height-cellar.height;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.verticalCenter: parent.verticalCenter;
- }
+ }
Cellar {id: cellar;anchors.bottom: main.bottom; anchors.horizontalCenter: main.horizontalCenter; width: main.width }
}
diff --git a/navit/gui/qt5_qml/backend.cpp b/navit/gui/qt5_qml/backend.cpp
index 395fff425..4b83bad32 100644
--- a/navit/gui/qt5_qml/backend.cpp
+++ b/navit/gui/qt5_qml/backend.cpp
@@ -25,12 +25,11 @@ extern "C" {
#include "proxy.h"
}
-Backend::Backend(QObject * parent):QObject(parent)
-{
- set_default_country();
- this->search = NULL;
- _current_town = NULL;
- _current_street = NULL;
+Backend::Backend(QObject * parent):QObject(parent) {
+ set_default_country();
+ this->search = NULL;
+ _current_town = NULL;
+ _current_street = NULL;
}
/**
@@ -38,63 +37,61 @@ Backend::Backend(QObject * parent):QObject(parent)
* @param struct point *p the point coordinate where we clicked on the screen
* @returns nothing
*/
-void Backend::showMenu(struct point *p)
-{
- struct coord co;
-
- transform_reverse(navit_get_trans(nav), p, &co);
- dbg(lvl_debug, "Point 0x%x 0x%x\n", co.x, co.y);
- dbg(lvl_debug, "Screen coord : %d %d\n", p->x, p->y);
- transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &(this->g));
- dbg(lvl_debug, "%f %f\n", this->g.lat, this->g.lng);
- dbg(lvl_debug, "%p %p\n", nav, &c);
- this->c.pro = transform_get_projection(navit_get_trans(nav));
- this->c.x = co.x;
- this->c.y = co.y;
- dbg(lvl_debug, "c : %x %x\n", this->c.x, this->c.y);
-
- // As a test, set the Demo vehicle position to wherever we just clicked
- navit_set_position(this->nav, &c);
- navit_block(this->nav, 1);
- emit displayMenu("MainMenu.qml");
+void Backend::showMenu(struct point *p) {
+ struct coord co;
+
+ transform_reverse(navit_get_trans(nav), p, &co);
+ dbg(lvl_debug, "Point 0x%x 0x%x", co.x, co.y);
+ dbg(lvl_debug, "Screen coord : %d %d", p->x, p->y);
+ transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &(this->g));
+ dbg(lvl_debug, "%f %f", this->g.lat, this->g.lng);
+ dbg(lvl_debug, "%p %p", nav, &c);
+ this->c.pro = transform_get_projection(navit_get_trans(nav));
+ this->c.x = co.x;
+ this->c.y = co.y;
+ dbg(lvl_debug, "c : %x %x", this->c.x, this->c.y);
+
+ // As a test, set the Demo vehicle position to wherever we just clicked
+ navit_set_position(this->nav, &c);
+ navit_block(this->nav, 1);
+ emit displayMenu("MainMenu.qml");
}
/**
* @brief update the private m_maps list. Expected to be called from QML
* @param none
* @returns nothing
- */
-void Backend::get_maps()
-{
- struct attr attr, on, off, description, type, data, active;
- char * label;
- bool is_active;
- struct attr_iter * iter;
- _maps.clear();
-
- iter = navit_attr_iter_new();
- on.type = off.type = attr_active;
- on.u.num = 1;
- off.u.num = 0;
- while (navit_get_attr(this->nav, attr_map, &attr, iter)) {
- if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
- label = g_strdup(description.u.str);
- } else {
- if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
- type.u.str = "";
- if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
- data.u.str = "";
- label = g_strdup_printf("%s:%s", type.u.str, data.u.str);
- }
- is_active = false;
- if (map_get_attr(attr.u.map, attr_active, &active, NULL)) {
- if (active.u.num == 1) {
- is_active = true;
- }
- }
- _maps.append(new MapObject(label, is_active));
+ */
+void Backend::get_maps() {
+ struct attr attr, on, off, description, type, data, active;
+ char * label;
+ bool is_active;
+ struct attr_iter * iter;
+ _maps.clear();
+
+ iter = navit_attr_iter_new();
+ on.type = off.type = attr_active;
+ on.u.num = 1;
+ off.u.num = 0;
+ while (navit_get_attr(this->nav, attr_map, &attr, iter)) {
+ if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
+ label = g_strdup(description.u.str);
+ } else {
+ if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
+ type.u.str = "";
+ if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
+ data.u.str = "";
+ label = g_strdup_printf("%s:%s", type.u.str, data.u.str);
+ }
+ is_active = false;
+ if (map_get_attr(attr.u.map, attr_active, &active, NULL)) {
+ if (active.u.num == 1) {
+ is_active = true;
+ }
}
- emit mapsChanged();
+ _maps.append(new MapObject(label, is_active));
+ }
+ emit mapsChanged();
}
@@ -102,196 +99,190 @@ void Backend::get_maps()
* @brief update the private m_vehicles list. Expected to be called from QML
* @param none
* @returns nothing
- */
-void Backend::get_vehicles()
-{
- struct attr attr,attr2,vattr;
- struct attr_iter *iter;
- struct attr active_vehicle;
- _vehicles.clear();
-
- iter=navit_attr_iter_new();
- if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- navit_attr_iter_destroy(iter);
- _vehicles.append(new VehicleObject(g_strdup(vattr.u.str), active_vehicle.u.vehicle, attr.u.vehicle));
- dbg(lvl_debug, "done\n");
- emit vehiclesChanged();
- return;
- }
- navit_attr_iter_destroy(iter);
-
- if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
- active_vehicle.u.vehicle=NULL;
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- dbg(lvl_debug, "adding vehicle %s\n", vattr.u.str);
- _vehicles.append(
- new VehicleObject(
- g_strdup(vattr.u.str),
- attr.u.vehicle == active_vehicle.u.vehicle,
- attr.u.vehicle
- )
- );
- }
+ */
+void Backend::get_vehicles() {
+ struct attr attr,attr2,vattr;
+ struct attr_iter *iter;
+ struct attr active_vehicle;
+ _vehicles.clear();
+
+ iter=navit_attr_iter_new();
+ if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
navit_attr_iter_destroy(iter);
- emit vehiclesChanged();
+ _vehicles.append(new VehicleObject(g_strdup(vattr.u.str), active_vehicle.u.vehicle, attr.u.vehicle));
+ dbg(lvl_debug, "done");
+ emit vehiclesChanged();
+ return;
+ }
+ navit_attr_iter_destroy(iter);
+
+ if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
+ active_vehicle.u.vehicle=NULL;
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
+ dbg(lvl_debug, "adding vehicle %s", vattr.u.str);
+ _vehicles.append(
+ new VehicleObject(
+ g_strdup(vattr.u.str),
+ attr.u.vehicle == active_vehicle.u.vehicle,
+ attr.u.vehicle
+ )
+ );
+ }
+ navit_attr_iter_destroy(iter);
+ emit vehiclesChanged();
}
/**
* @brief set a pointer to the struct navit * for local use
* @param none
* @returns nothing
- */
-void Backend::set_navit(struct navit *nav)
-{
- this->nav = nav;
+ */
+void Backend::set_navit(struct navit *nav) {
+ this->nav = nav;
}
/**
* @brief set a pointer to the QQmlApplicationEngine * for local use
* @param none
* @returns nothing
- */
-void Backend::set_engine(QQmlApplicationEngine * engine)
-{
- this->engine = engine;
+ */
+void Backend::set_engine(QQmlApplicationEngine * engine) {
+ this->engine = engine;
}
/**
* @brief apply search filters on one specific item
* @param struct item * the item to filter
* @returns 0 if the item should be discarded, 1 otherwise
- */
-int Backend::filter_pois(struct item *item)
-{
- enum item_type *types;
- enum item_type type=item->type;
- if (type >= type_line)
- return 0;
- return 1;
+ */
+int Backend::filter_pois(struct item *item) {
+ enum item_type *types;
+ enum item_type type=item->type;
+ if (type >= type_line)
+ return 0;
+ return 1;
}
/**
* @brief update the private m_bookmarks list. Expected to be called from QML
* @param none
* @returns nothing
- */
-void Backend::get_bookmarks()
-{
- struct attr attr,mattr;
- struct navigation * nav = NULL;
- struct item *item;
- struct coord c;
- struct pcoord pc;
-
- _bookmarks.clear();
-
- pc.pro = transform_get_projection(navit_get_trans(this->nav));
-
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- bookmarks_item_rewind(mattr.u.bookmarks);
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr)) continue;
- dbg(lvl_debug,"full_label: %s\n", attr.u.str);
- if (item_coord_get(item, &c, 1)) {
- pc.x = c.x;
- pc.y = c.y;
- dbg(lvl_debug, "coords : %i x %i\n", pc.x, pc.y);
- _bookmarks.append(new BookmarkObject(attr.u.str, pc));
- }
- }
+ */
+void Backend::get_bookmarks() {
+ struct attr attr,mattr;
+ struct navigation * nav = NULL;
+ struct item *item;
+ struct coord c;
+ struct pcoord pc;
+
+ _bookmarks.clear();
+
+ pc.pro = transform_get_projection(navit_get_trans(this->nav));
+
+ if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
+ bookmarks_item_rewind(mattr.u.bookmarks);
+ while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
+ if (!item_attr_get(item, attr_label, &attr)) continue;
+ dbg(lvl_debug,"full_label: %s", attr.u.str);
+ if (item_coord_get(item, &c, 1)) {
+ pc.x = c.x;
+ pc.y = c.y;
+ dbg(lvl_debug, "coords : %i x %i", pc.x, pc.y);
+ _bookmarks.append(new BookmarkObject(attr.u.str, pc));
+ }
}
- emit bookmarksChanged();
+ }
+ emit bookmarksChanged();
}
/**
* @brief update the private m_pois list. Expected to be called from QML
* @param none
* @returns nothing
- */
-void Backend::get_pois()
-{
- struct map_selection * sel, * selm;
- struct coord c, center;
- struct mapset_handle * h;
- struct map * m;
- struct map_rect * mr;
- struct item * item;
- enum projection pro = this->c.pro;
- int idist, dist;
- _pois.clear();
- dist = 10000;
- sel = map_selection_rect_new(&(this->c), dist * transform_scale(abs(this->c.y) + dist * 1.5), 18);
- center.x = this->c.x;
- center.y = this->c.y;
-
- dbg(lvl_debug, "center is at %x, %x\n", center.x, center.y);
-
- h = mapset_open(navit_get_mapset(this->nav));
- while ((m = mapset_next(h, 1))) {
- selm = map_selection_dup_pro(sel, pro, map_projection(m));
- mr = map_rect_new(m, selm);
- dbg(lvl_debug, "mr=%p\n", mr);
- if (mr) {
- while ((item = map_rect_get_item(mr))) {
- if ( filter_pois(item) &&
- item_coord_get_pro(item, &c, 1, pro) &&
- coord_rect_contains(&sel->u.c_rect, &c) &&
- (idist=transform_distance(pro, &center, &c)) < dist) {
-
- struct attr attr;
- char * label;
- char * icon = get_icon(this->nav, item);
- struct pcoord item_coord;
- item_coord.pro = transform_get_projection(navit_get_trans(nav));
- item_coord.x = c.x;
- item_coord.y = c.y;
-
- idist = transform_distance(pro, &center, &c);
- if (item_attr_get(item, attr_label, &attr)) {
- label = map_convert_string(item->map, attr.u.str);
- if (icon) {
- _pois.append(new PoiObject(label, item_to_name(item->type), idist, icon, item_coord));
- }
- }
- }
+ */
+void Backend::get_pois() {
+ struct map_selection * sel, * selm;
+ struct coord c, center;
+ struct mapset_handle * h;
+ struct map * m;
+ struct map_rect * mr;
+ struct item * item;
+ enum projection pro = this->c.pro;
+ int idist, dist;
+ _pois.clear();
+ dist = 10000;
+ sel = map_selection_rect_new(&(this->c), dist * transform_scale(abs(this->c.y) + dist * 1.5), 18);
+ center.x = this->c.x;
+ center.y = this->c.y;
+
+ dbg(lvl_debug, "center is at %x, %x", center.x, center.y);
+
+ h = mapset_open(navit_get_mapset(this->nav));
+ while ((m = mapset_next(h, 1))) {
+ selm = map_selection_dup_pro(sel, pro, map_projection(m));
+ mr = map_rect_new(m, selm);
+ dbg(lvl_debug, "mr=%p", mr);
+ if (mr) {
+ while ((item = map_rect_get_item(mr))) {
+ if ( filter_pois(item) &&
+ item_coord_get_pro(item, &c, 1, pro) &&
+ coord_rect_contains(&sel->u.c_rect, &c) &&
+ (idist=transform_distance(pro, &center, &c)) < dist) {
+
+ struct attr attr;
+ char * label;
+ char * icon = get_icon(this->nav, item);
+ struct pcoord item_coord;
+ item_coord.pro = transform_get_projection(navit_get_trans(nav));
+ item_coord.x = c.x;
+ item_coord.y = c.y;
+
+ idist = transform_distance(pro, &center, &c);
+ if (item_attr_get(item, attr_label, &attr)) {
+ label = map_convert_string(item->map, attr.u.str);
+ if (icon) {
+ _pois.append(new PoiObject(label, item_to_name(item->type), idist, icon, item_coord));
}
- map_rect_destroy(mr);
+ }
}
- map_selection_destroy(selm);
+ }
+ map_rect_destroy(mr);
}
- map_selection_destroy(sel);
- mapset_close(h);
- emit poisChanged();
+ map_selection_destroy(selm);
+ }
+ map_selection_destroy(sel);
+ mapset_close(h);
+ emit poisChanged();
}
/**
* @brief get the POIs as a QList
* @param none
* @returns the pois QList
- */
-QQmlListProperty<QObject> Backend::getPois(){
- return QQmlListProperty<QObject>(this, _pois);
+ */
+QQmlListProperty<QObject> Backend::getPois() {
+ return QQmlListProperty<QObject>(this, _pois);
}
/**
* @brief get the Bookmarks as a QList
* @param none
* @returns the bookmarks QList
- */
-QQmlListProperty<QObject> Backend::getBookmarks(){
- return QQmlListProperty<QObject>(this, _bookmarks);
+ */
+QQmlListProperty<QObject> Backend::getBookmarks() {
+ return QQmlListProperty<QObject>(this, _bookmarks);
}
/**
* @brief get the maps as a QList
* @param none
* @returns the maps QList
- */
-QQmlListProperty<QObject> Backend::getMaps(){
- return QQmlListProperty<QObject>(this, _maps);
+ */
+QQmlListProperty<QObject> Backend::getMaps() {
+ return QQmlListProperty<QObject>(this, _maps);
}
@@ -299,62 +290,62 @@ QQmlListProperty<QObject> Backend::getMaps(){
* @brief get the vehicles as a QList
* @param none
* @returns the vehicles QList
- */
-QQmlListProperty<QObject> Backend::getVehicles(){
- return QQmlListProperty<QObject>(this, _vehicles);
+ */
+QQmlListProperty<QObject> Backend::getVehicles() {
+ return QQmlListProperty<QObject>(this, _vehicles);
}
/**
* @brief get the search results as a QList
* @param none
* @returns the search results QList
- */
-QQmlListProperty<QObject> Backend::getSearchResults(){
- return QQmlListProperty<QObject>(this, _search_results);
+ */
+QQmlListProperty<QObject> Backend::getSearchResults() {
+ return QQmlListProperty<QObject>(this, _search_results);
}
/**
* @brief get the active POI. Used when displaying the relevant menu
* @param none
* @returns the active POI
- */
+ */
PoiObject * Backend::activePoi() {
- dbg(lvl_debug, "name : %s\n", m_activePoi->name().toUtf8().data());
- dbg(lvl_debug, "type : %s\n", m_activePoi->type().toLatin1().data());
- return m_activePoi;
+ dbg(lvl_debug, "name : %s", m_activePoi->name().toUtf8().data());
+ dbg(lvl_debug, "type : %s", m_activePoi->type().toLatin1().data());
+ return m_activePoi;
}
/**
* @brief get the current bookmark. Used when displaying the relevant menu
* @param none
* @returns the current bookmark
- */
+ */
BookmarkObject * Backend::currentBookmark() {
- return m_currentBookmark;
+ return m_currentBookmark;
}
/**
* @brief get the currently selected vehicle. Used when displaying the relevant menu
* @param none
* @returns the active POI
- */
+ */
VehicleObject * Backend::currentVehicle() {
- struct attr attr;
- dbg(lvl_debug, "name : %s\n", m_currentVehicle->name().toUtf8().data());
- if (m_currentVehicle->vehicle()) {
- if (vehicle_get_attr(m_currentVehicle->vehicle(), attr_position_nmea, &attr, NULL))
- dbg(lvl_debug, "NMEA : %s\n", attr.u.str);
- } else {
- dbg(lvl_debug, "m_currentVehicle->v is null\n");
- }
+ struct attr attr;
+ dbg(lvl_debug, "name : %s", m_currentVehicle->name().toUtf8().data());
+ if (m_currentVehicle->vehicle()) {
+ if (vehicle_get_attr(m_currentVehicle->vehicle(), attr_position_nmea, &attr, NULL))
+ dbg(lvl_debug, "NMEA : %s", attr.u.str);
+ } else {
+ dbg(lvl_debug, "m_currentVehicle->v is null");
+ }
- return m_currentVehicle;
+ return m_currentVehicle;
}
-void Backend::block_draw(){
- navit_block(this->nav, 1);
- dbg(lvl_debug, "Draw operations blocked per UI request\n");
+void Backend::block_draw() {
+ navit_block(this->nav, 1);
+ dbg(lvl_debug, "Draw operations blocked per UI request");
}
/**
@@ -362,124 +353,124 @@ void Backend::block_draw(){
* @param int width
* @param int height
* @returns nothing
- */
-void Backend::resize(int width, int height){
- // If we need to resize the canvas, it means that something (the main map,
- // or a menu item) wants to display a map. Ensure that draw operations
- // are not blocked then.
- navit_block(this->nav, -1);
- navit_handle_resize(nav, width, height);
+ */
+void Backend::resize(int width, int height) {
+ // If we need to resize the canvas, it means that something (the main map,
+ // or a menu item) wants to display a map. Ensure that draw operations
+ // are not blocked then.
+ navit_block(this->nav, -1);
+ navit_handle_resize(nav, width, height);
}
/**
* @brief set the active POI. Used when clicking on a POI list to display one single POI
* @param int index the index of the POI in the m_pois list
* @returns nothing
- */
+ */
void Backend::setActivePoi(int index) {
- struct pcoord c;
- m_activePoi = (PoiObject *)_pois.at(index);
- c = m_activePoi->coords();
- resize(320, 240);
- navit_set_center(this->nav, &c, 1);
- emit activePoiChanged();
+ struct pcoord c;
+ m_activePoi = (PoiObject *)_pois.at(index);
+ c = m_activePoi->coords();
+ resize(320, 240);
+ navit_set_center(this->nav, &c, 1);
+ emit activePoiChanged();
}
/**
* @brief set the current bookmark. Used when clicking on a bookmark list to display one single bookmark
* @param int index the index of the bookmark in the m_bookmarks list
* @returns nothing
- */
+ */
void Backend::setCurrentBookmark(int index) {
- struct pcoord c;
- m_currentBookmark = (BookmarkObject *)_bookmarks.at(index);
- c = m_currentBookmark->coords();
- resize(320, 240);
- navit_set_center(this->nav, &c, 1);
- emit currentBookmarkChanged();
+ struct pcoord c;
+ m_currentBookmark = (BookmarkObject *)_bookmarks.at(index);
+ c = m_currentBookmark->coords();
+ resize(320, 240);
+ navit_set_center(this->nav, &c, 1);
+ emit currentBookmarkChanged();
}
/**
* @brief set the current vehicle. Used when clicking on a vehicle list to display one single vehicle
* @param int index the index of the vehicle in the m_vehicles list
* @returns nothing
- */
+ */
void Backend::setCurrentVehicle(int index) {
- m_currentVehicle = (VehicleObject *)_vehicles.at(index);
- emit currentVehicleChanged();
+ m_currentVehicle = (VehicleObject *)_vehicles.at(index);
+ emit currentVehicleChanged();
}
/**
* @brief returns the icon absolute path
* @param none
* @returns the icon absolute path as a QString
- */
-QString Backend::get_icon_path(){
- return QString(g_strjoin(NULL,"file://",getenv("NAVIT_SHAREDIR"),"/icons/",NULL));
+ */
+QString Backend::get_icon_path() {
+ return QString(g_strjoin(NULL,"file://",getenv("NAVIT_SHAREDIR"),"/icons/",NULL));
}
/**
* @brief set the destination using the currently active POI's coordinates
* @param none
* @returns nothing
- */
-void Backend::setActivePoiAsDestination(){
- struct pcoord c;
- c = m_activePoi->coords();
- dbg(lvl_debug, "Destination : %s c=%d:0x%x,0x%x\n",
- m_activePoi->name().toUtf8().data(),
- c.pro, c.x, c.y);
- navit_set_destination(this->nav, &c, m_activePoi->name().toUtf8().data(), 1);
- emit hideMenu();
+ */
+void Backend::setActivePoiAsDestination() {
+ struct pcoord c;
+ c = m_activePoi->coords();
+ dbg(lvl_debug, "Destination : %s c=%d:0x%x,0x%x",
+ m_activePoi->name().toUtf8().data(),
+ c.pro, c.x, c.y);
+ navit_set_destination(this->nav, &c, m_activePoi->name().toUtf8().data(), 1);
+ emit hideMenu();
}
/**
* @brief save the search result for the next search step
* @param int index the index of the result in the m_search_results list
* @returns nothing
- */
-void Backend::searchValidateResult(int index){
- SearchObject * r = (SearchObject *)_search_results.at(index);
- dbg(lvl_debug, "Saving %s [%i] as search result\n", r->name().toUtf8().data(), index);
- if (r->getCoords()){
- dbg(lvl_debug, "Item is at %x x %x\n", r->getCoords()->x, r->getCoords()->y);
- }
- if (_search_context == attr_country_all) {
- _current_country = g_strdup(r->name().toUtf8().data());
- _current_town = NULL;
- _current_street = NULL;
- } else if (_search_context == attr_town_name) {
- _current_town = g_strdup(r->name().toUtf8().data());
- _current_street = NULL;
- } else if (_search_context == attr_street_name) {
- _current_street = g_strdup(r->name().toUtf8().data());
- } else {
- dbg(lvl_error, "Unknown search context for '%s'\n", r->name().toUtf8().data());
- }
- // navit_set_center(this->nav, r->getCoords(), 1);
- emit displayMenu("destination_address.qml");
+ */
+void Backend::searchValidateResult(int index) {
+ SearchObject * r = (SearchObject *)_search_results.at(index);
+ dbg(lvl_debug, "Saving %s [%i] as search result", r->name().toUtf8().data(), index);
+ if (r->getCoords()) {
+ dbg(lvl_debug, "Item is at %x x %x", r->getCoords()->x, r->getCoords()->y);
+ }
+ if (_search_context == attr_country_all) {
+ _current_country = g_strdup(r->name().toUtf8().data());
+ _current_town = NULL;
+ _current_street = NULL;
+ } else if (_search_context == attr_town_name) {
+ _current_town = g_strdup(r->name().toUtf8().data());
+ _current_street = NULL;
+ } else if (_search_context == attr_street_name) {
+ _current_street = g_strdup(r->name().toUtf8().data());
+ } else {
+ dbg(lvl_error, "Unknown search context for '%s'", r->name().toUtf8().data());
+ }
+ // navit_set_center(this->nav, r->getCoords(), 1);
+ emit displayMenu("destination_address.qml");
}
/**
* @brief get the icon that matches the country currently used for searches
* @param none
* @returns an absolute path for the country icon
- */
-QString Backend::get_country_icon(char * country_iso_code){
+ */
+QString Backend::get_country_icon(char * country_iso_code) {
// if ( country_iso_code == "" ) {
// country_iso_code = _country_iso2;
// }
- return QString(g_strjoin(NULL,"file://",getenv("NAVIT_SHAREDIR"),"/icons/",country_iso_code,".svg",NULL));
+ return QString(g_strjoin(NULL,"file://",getenv("NAVIT_SHAREDIR"),"/icons/",country_iso_code,".svg",NULL));
}
static struct search_param {
- struct navit *nav;
- struct mapset *ms;
- struct search_list *sl;
- struct attr attr;
- int partial;
- void *entry_country, *entry_postal, *entry_city, *entry_district;
- void *entry_street, *entry_number;
+ struct navit *nav;
+ struct mapset *ms;
+ struct search_list *sl;
+ struct attr attr;
+ int partial;
+ void *entry_country, *entry_postal, *entry_city, *entry_district;
+ void *entry_street, *entry_number;
} search_param;
/**
@@ -487,9 +478,9 @@ static struct search_param {
* @param none
* returns nothing
*/
-void Backend::set_default_country(){
- _current_country = "Germany";
- _country_iso2 = "DE";
+void Backend::set_default_country() {
+ _current_country = "Germany";
+ _country_iso2 = "DE";
}
@@ -497,107 +488,107 @@ void Backend::set_default_country(){
* @brief update the current search results according to new inputs. Currently only works to search for towns
* @param QString text the text to search for
* @returns nothing
- */
-void Backend::updateSearch(QString text){
- struct search_list_result *res;
- struct attr search_attr;
-
- if (search == NULL){
- search=&search_param;
- dbg(lvl_debug, "search = %p\n", search);
- search->nav=this->nav;
- search->ms=navit_get_mapset(this->nav);
- search->sl=search_list_new(search->ms);
- search->partial = 1;
- dbg(lvl_debug,"attempting to use country '%s'\n", _country_iso2);
- search_attr.type=attr_country_iso2;
- search_attr.u.str=_country_iso2;
- search_list_search(search->sl, &search_attr, 0);
-
- while((res=search_list_get_result(search->sl)));
- }
-
- _search_results.clear();
- // search->attr.type=attr_country_all;
- // search->attr.type=attr_town_postal;
- // search->attr.type=attr_town_name;
- // search->attr.type=attr_street_name;
+ */
+void Backend::updateSearch(QString text) {
+ struct search_list_result *res;
+ struct attr search_attr;
+
+ if (search == NULL) {
+ search=&search_param;
+ dbg(lvl_debug, "search = %p", search);
+ search->nav=this->nav;
+ search->ms=navit_get_mapset(this->nav);
+ search->sl=search_list_new(search->ms);
+ search->partial = 1;
+ dbg(lvl_debug,"attempting to use country '%s'", _country_iso2);
+ search_attr.type=attr_country_iso2;
+ search_attr.u.str=_country_iso2;
+ search_list_search(search->sl, &search_attr, 0);
+
+ while((res=search_list_get_result(search->sl)));
+ }
+
+ _search_results.clear();
+ // search->attr.type=attr_country_all;
+ // search->attr.type=attr_town_postal;
+ // search->attr.type=attr_town_name;
+ // search->attr.type=attr_street_name;
// search->attr.type=attr_town_name;
// search->attr.u.str="Oberhaching";
// search_list_search(search->sl, &search->attr, search->partial);
// while((res=search_list_get_result(search->sl)));
- search->attr.u.str = text.toUtf8().data();
- dbg(lvl_error, "searching for %s partial %d\n", search->attr.u.str, search->partial);
-
- search->attr.type = _search_context;
- search_list_search(search->sl, &search->attr, search->partial);
- int count = 0;
- while((res=search_list_get_result(search->sl))) {
- if ( _search_context == attr_country_all && res->country) {
- char * label;
- label = g_strdup(res->country->name);
- _search_results.append(
- new SearchObject(label, get_country_icon(res->country->flag) , res->c)
- );
- }
- if ( _search_context == attr_town_name && res->town) {
- char * label;
- label = g_strdup(res->town->common.town_name);
- _search_results.append(
- new SearchObject(label, "icons/bigcity.png", res->c)
- );
- }
- if (res->street) {
- char * label;
- label = g_strdup(res->street->name);
- _search_results.append(
- new SearchObject(label, "icons/smallcity.png", res->c)
- );
- }
- if (count ++ > 50) {
- break;
- }
+ search->attr.u.str = text.toUtf8().data();
+ dbg(lvl_error, "searching for %s partial %d", search->attr.u.str, search->partial);
+
+ search->attr.type = _search_context;
+ search_list_search(search->sl, &search->attr, search->partial);
+ int count = 0;
+ while((res=search_list_get_result(search->sl))) {
+ if ( _search_context == attr_country_all && res->country) {
+ char * label;
+ label = g_strdup(res->country->name);
+ _search_results.append(
+ new SearchObject(label, get_country_icon(res->country->flag), res->c)
+ );
+ }
+ if ( _search_context == attr_town_name && res->town) {
+ char * label;
+ label = g_strdup(res->town->common.town_name);
+ _search_results.append(
+ new SearchObject(label, "icons/bigcity.png", res->c)
+ );
+ }
+ if (res->street) {
+ char * label;
+ label = g_strdup(res->street->name);
+ _search_results.append(
+ new SearchObject(label, "icons/smallcity.png", res->c)
+ );
}
- emit searchResultsChanged();
+ if (count ++ > 50) {
+ break;
+ }
+ }
+ emit searchResultsChanged();
}
-void Backend::setSearchContext(QString text){
- if (text == "country") {
- _search_context = attr_country_all;
- } else if (text == "town") {
- _search_context = attr_town_name;
- } else if (text == "street") {
- _search_context = attr_street_name;
- } else {
- dbg(lvl_error, "Unhandled search context '%s'\n", text.toUtf8().data());
- }
-
+void Backend::setSearchContext(QString text) {
+ if (text == "country") {
+ _search_context = attr_country_all;
+ } else if (text == "town") {
+ _search_context = attr_town_name;
+ } else if (text == "street") {
+ _search_context = attr_street_name;
+ } else {
+ dbg(lvl_error, "Unhandled search context '%s'", text.toUtf8().data());
+ }
+
}
QString Backend::currentCountry() {
- dbg(lvl_debug, "Current country : %s/%s\n", _country_iso2, _current_country);
- return QString(_current_country);
+ dbg(lvl_debug, "Current country : %s/%s", _country_iso2, _current_country);
+ return QString(_current_country);
}
QString Backend::currentCountryIso2() {
- dbg(lvl_debug, "Current country : %s/%s\n", _country_iso2, _current_country);
- return QString(_country_iso2);
+ dbg(lvl_debug, "Current country : %s/%s", _country_iso2, _current_country);
+ return QString(_country_iso2);
}
QString Backend::currentTown() {
- if (_current_town == NULL) {
- _current_town = "Enter City";
- }
- dbg(lvl_debug, "Current town : %s\n", _current_town);
- return QString(_current_town);
+ if (_current_town == NULL) {
+ _current_town = "Enter City";
+ }
+ dbg(lvl_debug, "Current town : %s", _current_town);
+ return QString(_current_town);
}
QString Backend::currentStreet() {
- if (_current_street == NULL) {
- _current_street = "Enter Street";
- }
- dbg(lvl_debug, "Current street : %s\n", _current_street);
- return QString(_current_street);
+ if (_current_street == NULL) {
+ _current_street = "Enter Street";
+ }
+ dbg(lvl_debug, "Current street : %s", _current_street);
+ return QString(_current_street);
}
diff --git a/navit/gui/qt5_qml/editor/main.cpp b/navit/gui/qt5_qml/editor/main.cpp
index 9089c5a29..32d6f9df4 100644
--- a/navit/gui/qt5_qml/editor/main.cpp
+++ b/navit/gui/qt5_qml/editor/main.cpp
@@ -1,8 +1,7 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
diff --git a/navit/gui/qt5_qml/gui_qt5_qml.cpp b/navit/gui/qt5_qml/gui_qt5_qml.cpp
index 1b4062d33..dfdbf5d14 100644
--- a/navit/gui/qt5_qml/gui_qt5_qml.cpp
+++ b/navit/gui/qt5_qml/gui_qt5_qml.cpp
@@ -68,7 +68,7 @@ struct gui_priv {
/* list of callbacks to navit */
struct callback_list* callbacks;
/* own callbacks *
- * TODO: Why do we need them as members? */
+ * TODO: Why do we need them as members? */
struct callback* button_cb;
struct callback* motion_cb;
struct callback* resize_cb;
@@ -95,54 +95,46 @@ struct gui_priv {
#include "backend.h"
-static void
-gui_qt5_qml_button(void* data, int pressed, int button, struct point* p)
-{
+static void gui_qt5_qml_button(void* data, int pressed, int button, struct point* p) {
struct gui_priv* gui_priv = (struct gui_priv*)data;
/* check if navit wants to handle this */
if (!navit_handle_button(gui_priv->nav, pressed, button, p, NULL)) {
- dbg(lvl_debug, "navit has handled button\n");
+ dbg(lvl_debug, "navit has handled button");
return;
}
- dbg(lvl_debug, "enter %d %d\n", pressed, button);
+ dbg(lvl_debug, "enter %d %d", pressed, button);
/* check if user requested menu */
if (button == 1 && gui_priv->menu_on_map_click) {
- dbg(lvl_debug, "navit wants us to enter menu\n");
+ dbg(lvl_debug, "navit wants us to enter menu");
/*TODO: want to emit a signal somewhere? */
gui_priv->backend->showMenu(p);
}
}
-static void
-gui_qt5_qml_motion(void* data, struct point* p)
-{
+static void gui_qt5_qml_motion(void* data, struct point* p) {
struct gui_priv* gui_priv = (struct gui_priv*)data;
- dbg(lvl_debug, "enter (%d, %d)\n", p->x, p->y);
+ dbg(lvl_debug, "enter (%d, %d)", p->x, p->y);
/* forward this to navit */
navit_handle_motion(gui_priv->nav, p);
}
-static void
-gui_qt5_qml_resize(void* data, int w, int h)
-{
+static void gui_qt5_qml_resize(void* data, int w, int h) {
struct gui_priv* gui_priv = (struct gui_priv*)data;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
/* forward this to navit */
navit_handle_resize(gui_priv->nav, w, h);
}
-static void
-gui_qml_keypress(void* data, char* key)
-{
+static void gui_qml_keypress(void* data, char* key) {
struct gui_priv* this_ = (struct gui_priv*)data;
int w, h;
struct point p;
transform_get_size(navit_get_trans(this_->nav), &w, &h);
switch (*key) {
case NAVIT_KEY_UP:
- dbg(lvl_debug, "got KEY_UP\n");
+ dbg(lvl_debug, "got KEY_UP");
p.x = w / 2;
p.y = 0;
navit_set_center_screen(this_->nav, &p, 1);
@@ -163,7 +155,7 @@ gui_qml_keypress(void* data, char* key)
navit_set_center_screen(this_->nav, &p, 1);
break;
case NAVIT_KEY_ZOOM_IN:
- dbg(lvl_debug, "got ZOOM_IN\n");
+ dbg(lvl_debug, "got ZOOM_IN");
navit_zoom_in(this_->nav, 2, NULL);
break;
case NAVIT_KEY_ZOOM_OUT:
@@ -179,11 +171,9 @@ gui_qml_keypress(void* data, char* key)
return;
}
-static int
-gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra)
-{
+static int gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra) {
struct transformation* trans;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
/* get navit transition */
trans = navit_get_trans(gui_priv->nav);
@@ -212,14 +202,14 @@ gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra)
/* get main navit window */
gui_priv->win = (struct window*)graphics_get_data(gra, "window");
if (!gui_priv->win) {
- dbg(lvl_error, "failed to obtain window from graphics plugin, cannot set graphics\n");
+ dbg(lvl_error, "failed to obtain window from graphics plugin, cannot set graphics");
return 1;
}
/* expect to have qt5 graphics. So get the qml engine prepared by graphics */
gui_priv->engine = (QQmlApplicationEngine*)graphics_get_data(gra, "engine");
if (gui_priv->engine == NULL) {
- dbg(lvl_error, "Graphics doesn't seem to be qt5, or doesn't have QML. Cannot set graphics\n");
+ dbg(lvl_error, "Graphics doesn't seem to be qt5, or doesn't have QML. Cannot set graphics");
return 1;
}
@@ -233,13 +223,13 @@ gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra)
/* find the loader component */
gui_priv->loader = gui_priv->engine->rootObjects().value(0)->findChild<QObject*>("navit_loader");
if (gui_priv->loader != NULL) {
- dbg(lvl_debug, "navit_loader found\n");
+ dbg(lvl_debug, "navit_loader found");
/* load our root window into the loader component */
gui_priv->loader->setProperty("source", "qrc:///skins/modern/main.qml");
}
transform_get_size(trans, &gui_priv->w, &gui_priv->h);
- dbg(lvl_debug, "navit provided geometry: (%d, %d)\n", gui_priv->w, gui_priv->h);
+ dbg(lvl_debug, "navit provided geometry: (%d, %d)", gui_priv->w, gui_priv->h);
/* Was resize callback already issued? */
// if (navit_get_ready(gui_priv->nav) & 2)
@@ -251,17 +241,13 @@ gui_qt5_qml_set_graphics(struct gui_priv* gui_priv, struct graphics* gra)
return 0;
}
-static int
-gui_qt5_qml_get_attr(struct gui_priv* gui_priv, enum attr_type type, struct attr* attr)
-{
- dbg(lvl_debug, "enter\n");
+static int gui_qt5_qml_get_attr(struct gui_priv* gui_priv, enum attr_type type, struct attr* attr) {
+ dbg(lvl_debug, "enter");
return 1;
}
-static int
-gui_qt5_qml_set_attr(struct gui_priv* gui_priv, struct attr* attr)
-{
- dbg(lvl_debug, "enter\n");
+static int gui_qt5_qml_set_attr(struct gui_priv* gui_priv, struct attr* attr) {
+ dbg(lvl_debug, "enter");
return 1;
}
@@ -278,13 +264,12 @@ struct gui_methods gui_qt5_qml_methods = {
gui_qt5_qml_set_attr,
};
-static struct gui_priv*
-gui_qt5_qml_new(struct navit* nav, struct gui_methods* meth, struct attr** attrs, struct gui* gui)
-{
+static struct gui_priv* gui_qt5_qml_new(struct navit* nav, struct gui_methods* meth, struct attr** attrs,
+ struct gui* gui) {
struct gui_priv* gui_priv;
struct attr* attr;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
/* tell navit our methods */
*meth = gui_qt5_qml_methods;
@@ -315,8 +300,7 @@ gui_qt5_qml_new(struct navit* nav, struct gui_methods* meth, struct attr** attrs
return gui_priv;
}
-void plugin_init(void)
-{
+void plugin_init(void) {
Q_INIT_RESOURCE(gui_qt5_qml);
plugin_register_category_gui("qt5_qml", gui_qt5_qml_new);
}
diff --git a/navit/gui/qt5_qml/proxy.c b/navit/gui/qt5_qml/proxy.c
index 6a3546716..399925519 100644
--- a/navit/gui/qt5_qml/proxy.c
+++ b/navit/gui/qt5_qml/proxy.c
@@ -11,8 +11,7 @@
#include "search.h"
-char * get_icon(struct navit *nav, struct item *item)
-{
+char * get_icon(struct navit *nav, struct item *item) {
struct attr layout;
struct attr icon_src;
@@ -25,7 +24,7 @@ char * get_icon(struct navit *nav, struct item *item)
while(itemgra) {
GList *types=((struct itemgra *)itemgra->data)->type;
while(types) {
- if((long)types->data==item->type) {
+ if((long)types->data==item->type) {
GList *element=((struct itemgra *)itemgra->data)->elements;
while(element) {
struct element * el=element->data;
@@ -41,12 +40,10 @@ char * get_icon(struct navit *nav, struct item *item)
if(!src || !src[0])
src="%s";
icon=g_strdup_printf(src,map_convert_string_tmp(item->map,icon_src.u.str));
- }
- else {
+ } else {
icon=g_strdup(el->u.icon.src);
}
- }
- else {
+ } else {
icon=g_strdup(el->u.icon.src);
}
icon[strlen(icon)-3]='s';
diff --git a/navit/gui/qt5_qml/qml_bookmark.cpp b/navit/gui/qt5_qml/qml_bookmark.cpp
index e215bcd11..5f46a3a44 100644
--- a/navit/gui/qt5_qml/qml_bookmark.cpp
+++ b/navit/gui/qt5_qml/qml_bookmark.cpp
@@ -1,32 +1,27 @@
#include "qml_bookmark.h"
BookmarkObject::BookmarkObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
BookmarkObject::BookmarkObject(
const QString &name,
struct pcoord &coords,
QObject *parent)
- : QObject(parent), m_name(name), m_coords(coords)
-{
+ : QObject(parent), m_name(name), m_coords(coords) {
}
-QString BookmarkObject::name() const
-{
+QString BookmarkObject::name() const {
return m_name;
}
-void BookmarkObject::setName(const QString &name)
-{
+void BookmarkObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-struct pcoord BookmarkObject::coords() const
-{
+struct pcoord BookmarkObject::coords() const {
return m_coords;
}
diff --git a/navit/gui/qt5_qml/qml_map.cpp b/navit/gui/qt5_qml/qml_map.cpp
index 0f38a4768..5a12a29b7 100644
--- a/navit/gui/qt5_qml/qml_map.cpp
+++ b/navit/gui/qt5_qml/qml_map.cpp
@@ -1,35 +1,29 @@
#include "qml_map.h"
MapObject::MapObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
MapObject::MapObject(const QString &name, const bool &active, QObject *parent)
- : QObject(parent), m_name(name), m_active(active)
-{
+ : QObject(parent), m_name(name), m_active(active) {
}
-QString MapObject::name() const
-{
+QString MapObject::name() const {
return m_name;
}
-void MapObject::setName(const QString &name)
-{
+void MapObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-bool MapObject::active() const
-{
+bool MapObject::active() const {
return m_active;
}
-void MapObject::setActive(const bool &active)
-{
+void MapObject::setActive(const bool &active) {
if (active != m_active) {
m_active = active;
emit activeChanged();
diff --git a/navit/gui/qt5_qml/qml_poi.cpp b/navit/gui/qt5_qml/qml_poi.cpp
index 93adf2925..8f0a0ab64 100644
--- a/navit/gui/qt5_qml/qml_poi.cpp
+++ b/navit/gui/qt5_qml/qml_poi.cpp
@@ -1,8 +1,7 @@
#include "qml_poi.h"
PoiObject::PoiObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
PoiObject::PoiObject(
@@ -12,63 +11,53 @@ PoiObject::PoiObject(
const QString &icon,
struct pcoord &coords,
QObject *parent)
- : QObject(parent), m_name(name), m_type(type), m_icon(icon), m_coords(coords)
-{
+ : QObject(parent), m_name(name), m_type(type), m_icon(icon), m_coords(coords) {
}
-QString PoiObject::name() const
-{
+QString PoiObject::name() const {
return m_name;
}
-void PoiObject::setName(const QString &name)
-{
+void PoiObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-QString PoiObject::type() const
-{
+QString PoiObject::type() const {
return m_type;
}
-void PoiObject::setType(const QString &type)
-{
+void PoiObject::setType(const QString &type) {
if (type != m_type) {
m_type = type;
emit typeChanged();
}
}
-float PoiObject::distance() const
-{
+float PoiObject::distance() const {
return m_distance/1000;
}
-void PoiObject::setDistance(const int distance)
-{
+void PoiObject::setDistance(const int distance) {
if (distance != m_distance) {
m_distance = distance;
emit distanceChanged();
}
}
-void PoiObject::setIcon(const QString &icon)
-{
+void PoiObject::setIcon(const QString &icon) {
if (icon != m_icon) {
m_icon = icon;
emit iconChanged();
}
}
-QString PoiObject::icon() const
-{
+QString PoiObject::icon() const {
return m_icon;
}
-struct pcoord PoiObject::coords() const
-{
+struct pcoord PoiObject::coords() const {
return m_coords;
}
diff --git a/navit/gui/qt5_qml/qml_search.cpp b/navit/gui/qt5_qml/qml_search.cpp
index 0a82e37d3..8c15fbd03 100644
--- a/navit/gui/qt5_qml/qml_search.cpp
+++ b/navit/gui/qt5_qml/qml_search.cpp
@@ -1,42 +1,35 @@
#include "qml_search.h"
SearchObject::SearchObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
SearchObject::SearchObject(const QString &name, const QString &icon, struct pcoord *c, QObject *parent)
- : QObject(parent), m_name(name), m_icon(icon), m_c(c)
-{
+ : QObject(parent), m_name(name), m_icon(icon), m_c(c) {
}
-QString SearchObject::name() const
-{
+QString SearchObject::name() const {
return m_name;
}
-void SearchObject::setName(const QString &name)
-{
+void SearchObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-QString SearchObject::icon() const
-{
+QString SearchObject::icon() const {
return m_icon;
}
-void SearchObject::setIcon(const QString &icon)
-{
+void SearchObject::setIcon(const QString &icon) {
if (icon != m_icon) {
m_icon = icon;
emit iconChanged();
}
}
-struct pcoord * SearchObject::getCoords() const
-{
+struct pcoord * SearchObject::getCoords() const {
return m_c;
}
diff --git a/navit/gui/qt5_qml/qml_vehicle.cpp b/navit/gui/qt5_qml/qml_vehicle.cpp
index bf79ad4c4..d09d65408 100644
--- a/navit/gui/qt5_qml/qml_vehicle.cpp
+++ b/navit/gui/qt5_qml/qml_vehicle.cpp
@@ -1,48 +1,40 @@
#include "qml_vehicle.h"
VehicleObject::VehicleObject(QObject *parent)
- : QObject(parent)
-{
+ : QObject(parent) {
}
VehicleObject::VehicleObject(const QString &name, const bool &active, struct vehicle *v, QObject *parent)
- : QObject(parent), m_name(name), m_active(active), m_vehicle(v)
-{
+ : QObject(parent), m_name(name), m_active(active), m_vehicle(v) {
}
-QString VehicleObject::name() const
-{
+QString VehicleObject::name() const {
return m_name;
}
-void VehicleObject::setName(const QString &name)
-{
+void VehicleObject::setName(const QString &name) {
if (name != m_name) {
m_name = name;
emit nameChanged();
}
}
-bool VehicleObject::active() const
-{
+bool VehicleObject::active() const {
return m_active;
}
-void VehicleObject::setActive(const bool &active)
-{
+void VehicleObject::setActive(const bool &active) {
if (active != m_active) {
m_active = active;
emit activeChanged();
}
}
-struct vehicle * VehicleObject::vehicle() const
-{
+struct vehicle * VehicleObject::vehicle() const {
return m_vehicle;
}
-void VehicleObject::setVehicle(struct vehicle * vehicle)
-{
+void VehicleObject::setVehicle(struct vehicle * vehicle) {
if (vehicle != m_vehicle) {
m_vehicle = vehicle;
emit vehicleChanged();
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg b/navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg
index 3917fc7cd..7dfd18eb4 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.chevron.down.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 37.8516,39.5833L 52.1016,24.9375L 52.1016,35.2292L 37.8516,50.2708L 23.6016,35.2292L 23.6016,24.9375L 37.8516,39.5833 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg b/navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg
index b737d9773..a84cb0b21 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.chevron.up.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 37.8516,35.625L 34.6849,38.7917L 23.6016,50.2708L 23.6016,39.9792L 37.8516,24.9375L 52.1016,39.9792L 52.1016,50.2708L 41.0182,38.7917L 37.8516,35.625 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.cog.svg b/navit/gui/qt5_qml/skins/icons/appbar.cog.svg
index 4ef1ef8c2..0c0590fcc 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.cog.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.cog.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 27.5314,21.8628L 33.0126,19.4224L 34.7616,23.3507C 36.6693,22.9269 38.6044,22.8903 40.4668,23.2026L 42.0083,19.1868L 47.6098,21.337L 46.0683,25.3528C 47.6612,26.3669 49.0747,27.6889 50.2088,29.2803L 54.1371,27.5313L 56.5776,33.0126L 52.6493,34.7616C 53.0731,36.6693 53.1097,38.6043 52.7974,40.4668L 56.8131,42.0083L 54.6629,47.6097L 50.6472,46.0683C 49.6331,47.6613 48.3111,49.0748 46.7197,50.2089L 48.4686,54.1372L 42.9874,56.5776L 41.2384,52.6493C 39.3307,53.0731 37.3957,53.1097 35.5333,52.7974L 33.9918,56.8131L 28.3903,54.6629L 29.9318,50.6472C 28.3388,49.6331 26.9252,48.3111 25.7911,46.7196L 21.8628,48.4686L 19.4224,42.9873L 23.3507,41.2383C 22.9269,39.3307 22.8903,37.3957 23.2026,35.5332L 19.1869,33.9918L 21.3371,28.3903L 25.3528,29.9318C 26.3669,28.3388 27.6889,26.9252 29.2804,25.7911L 27.5314,21.8628 Z M 34.3394,29.7781C 29.7985,31.7998 27.7564,37.1198 29.7781,41.6606C 31.7998,46.2015 37.1198,48.2436 41.6606,46.2219C 46.2015,44.2002 48.2436,38.8802 46.2219,34.3394C 44.2002,29.7985 38.8802,27.7564 34.3394,29.7781 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.cogs.svg b/navit/gui/qt5_qml/skins/icons/appbar.cogs.svg
index e3fdaa4ce..d8c1ab0fa 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.cogs.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.cogs.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 32.6227,68.9728C 33.1208,70.2446 33.7077,71.4719 34.3757,72.6471C 35.567,72.7702 36.7761,72.8333 38,72.8333C 40.6447,72.8333 43.2205,72.5386 45.6965,71.9802C 42.2807,68.5449 40.1698,63.8107 40.1698,58.5835C 40.1698,48.0901 48.6764,39.5835 59.1698,39.5835C 64.2047,39.5835 68.7822,41.5419 72.182,44.7385C 72.6094,42.5584 72.8333,40.3053 72.8333,38C 72.8333,36.442 72.731,34.908 72.5328,33.4041C 70.4772,32.3109 68.2718,31.4621 65.9554,30.8963L 65.6219,22.7367C 63.5664,22.3692 61.4511,22.1741 59.2916,22.1671L 57.491,30.1322C 54.2845,30.3184 51.2204,31.0348 48.3848,32.1949L 43.318,25.7887C 41.3995,26.7177 39.5749,27.8102 37.8622,29.0479L 41.0883,36.5527C 38.6742,38.5364 36.5919,40.9091 34.9373,43.575L 27.0703,41.3697C 26.073,43.2256 25.2319,45.178 24.5646,47.2093L 31.5867,51.385C 30.9883,53.6844 30.6698,56.0968 30.6698,58.5835L 30.746,60.6839L 23.0854,63.5239C 23.3743,65.6539 23.8474,67.7255 24.4881,69.7219L 32.6227,68.9728 Z M 27.0669,37.1755L 34.9338,39.3807C 35.9312,37.5248 36.7723,35.5724 37.4395,33.5412L 30.4175,29.3654C 31.0159,27.066 31.3344,24.6537 31.3344,22.1669L 31.2581,20.0665L 38.9187,17.2265C 38.6299,15.0965 38.1568,13.0249 37.5161,11.0285L 29.3815,11.7776C 28.4787,9.47258 27.2844,7.31377 25.8439,5.34655C 22.7943,6.48232 19.9467,8.03307 17.3698,9.93015C 20.1557,13.2359 21.8344,17.5054 21.8344,22.1669C 21.8344,32.5019 13.5826,40.9096 3.30816,41.1611C 3.60321,44.4411 4.35293,47.59 5.49381,50.5444C 8.34489,50.2806 11.0742,49.5968 13.6194,48.5555L 18.6861,54.9617C 20.6046,54.0327 22.4293,52.9403 24.142,51.7025L 20.9158,44.1977C 23.3299,42.2141 25.4123,39.8414 27.0669,37.1755 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg b/navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg
index 13e6840e5..a3e73f41a 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.fullscreen.box.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 19,57L 19,19L 57,19L 57,57L 19,57 Z M 24,29L 47,29L 47,52L 52,52L 52,24L 24,24L 24,29 Z M 24,34L 24,52L 42,52L 42,34L 24,34 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg b/navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg
index ea951fd19..273ff72cd 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.home.variant.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 24.0033,56.0078L 24.0033,38.0053L 22.0031,40.0056L 19.0027,35.0049L 38.0053,20.0028L 45.0063,25.5299L 45.0063,21.753L 49.0068,21.0029L 49.0068,28.6882L 57.008,35.0049L 54.0075,40.0056L 52.0073,38.0053L 52.0073,56.0078L 24.0033,56.0078 Z M 38.0053,26.9204L 27.0038,36.005L 27.0038,53.0074L 38.0045,53.0075L 38.0045,41.0061L 46.0058,41.0061L 46.0059,53.0075L 49.0068,53.0074L 49.0068,36.005L 38.0053,26.9204 Z M 30.004,41.0057L 35.0049,41.0057L 35.0049,47.0066L 30.004,47.0066L 30.004,41.0057 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg b/navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg
index 031bd37f5..35a156ae9 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.information.circle.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 38,19C 48.4934,19 57,27.5066 57,38C 57,48.4934 48.4934,57 38,57C 27.5066,57 19,48.4934 19,38C 19,27.5066 27.5066,19 38,19 Z M 33.25,33.25L 33.25,36.4167L 36.4166,36.4167L 36.4166,47.5L 33.25,47.5L 33.25,50.6667L 44.3333,50.6667L 44.3333,47.5L 41.1666,47.5L 41.1666,36.4167L 41.1666,33.25L 33.25,33.25 Z M 38.7917,25.3333C 37.48,25.3333 36.4167,26.3967 36.4167,27.7083C 36.4167,29.02 37.48,30.0833 38.7917,30.0833C 40.1033,30.0833 41.1667,29.02 41.1667,27.7083C 41.1667,26.3967 40.1033,25.3333 38.7917,25.3333 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg b/navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg
index ddbeb21ca..5157af942 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.layer.delete.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 18.5088,44.0374L 21.8676,40.6786L 27.4655,46.2765L 33.0634,40.6786L 36.4222,44.0374L 30.8243,49.6353L 36.4222,55.2332L 33.0634,58.592L 27.4655,52.994L 21.8676,58.592L 18.5088,55.2332L 24.1068,49.6353L 18.5088,44.0374 Z M 57.0079,38.0053L 38.0053,47.5066L 36.7482,46.8781L 39.5889,44.0374L 35.2559,39.7977L 38.0053,41.1724L 50.6737,34.8382L 57.0079,38.0053 Z M 19.0026,38.0053L 25.3369,34.8382L 32.3326,38.3361L 29.8968,40.7719L 28.1098,42.5589L 25.7193,41.3636L 21.8676,37.6052L 20.6459,38.8269L 19.0026,38.0053 Z M 38.0053,19.0027L 57.0079,28.504L 38.0053,38.0053L 19.0026,28.504L 38.0053,19.0027 Z M 57.0079,47.5066L 38.0053,57.008L 37.8778,56.9442L 39.5889,55.2332L 33.9909,49.6353L 34.6367,48.9895L 38.0053,50.6738L 50.6737,44.3395L 57.0079,47.5066 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.layer.svg b/navit/gui/qt5_qml/skins/icons/appbar.layer.svg
index 9eb28235c..b89bb2da3 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.layer.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.layer.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 57.0079,38.0053L 38.0053,47.5066L 19.0027,38.0053L 25.3369,34.8382L 38.0053,41.1724L 50.6737,34.8382L 57.0079,38.0053 Z M 38.0053,19.0027L 57.0079,28.504L 38.0053,38.0053L 19.0026,28.504L 38.0053,19.0027 Z M 57.0079,47.5066L 38.0053,57.008L 19.0026,47.5066L 25.3369,44.3395L 38.0053,50.6737L 50.6737,44.3395L 57.0079,47.5066 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg b/navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg
index 3b21754c6..a58141d22 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.location.checkin.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-linejoin="round" d="M 38,19C 42.9706,19 47,23.0294 47,28C 47,30.5642 45.9276,32.878 38,49C 30.0724,32.878 29,30.5642 29,28C 29,23.0294 33.0294,19 38,19 Z M 38,24C 35.7909,24 34,25.7909 34,28C 34,30.2092 35.7909,32 38,32C 40.2091,32 42,30.2092 42,28C 42,25.7909 40.2091,24 38,24 Z M 19,57L 24,42L 31.5,42L 33.5,46L 27.6641,46L 25.3324,53L 50.6676,53L 48.3359,46L 42.5,46L 44.5,42L 52,42L 57,57L 19,57 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.map.svg b/navit/gui/qt5_qml/skins/icons/appbar.map.svg
index 241f71e59..0a157d0da 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.map.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.map.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 27.7083,23.75L 38.7917,26.9167L 48.2917,20.5833L 62,24L 62,51L 48.2917,47.5L 38.7917,53.8333L 27.7083,50.6667L 16,55.5L 16,28.5L 27.7083,23.75 Z M 27,46.25L 27,29L 20,31.75L 20,49L 27,46.25 Z M 49,25.5L 49,42.75L 58,45.25L 58,28L 49,25.5 Z M 39,31.5L 39,49L 48,43L 48,25.5L 39,31.5 Z M 28,28.75L 28,46L 38,48.5L 38,31.75L 28,28.75 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.power.svg b/navit/gui/qt5_qml/skins/icons/appbar.power.svg
index d3f865c0d..db23bca1f 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.power.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.power.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 36.4167,36.4167L 36.4167,17.4167L 41.1667,17.4167L 41.1667,36.4167L 36.4167,36.4167 Z M 57,39.5833C 57,50.0767 48.4934,58.5833 38,58.5833C 27.5066,58.5833 19,50.0767 19,39.5833C 19,30.7301 25.0552,23.2911 33.25,21.1819L 33.25,27.8374C 28.6079,29.7165 25.3333,34.2675 25.3333,39.5833C 25.3333,46.5789 31.0044,52.25 38,52.25C 44.9956,52.25 50.6667,46.5789 50.6667,39.5833C 50.6667,34.8949 48.1194,30.8014 44.3333,28.6113L 44.3333,21.6645C 51.7129,24.2728 57,31.3106 57,39.5833 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.rocket.svg b/navit/gui/qt5_qml/skins/icons/appbar.rocket.svg
index a8c5c273a..d3b9d0a16 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.rocket.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.rocket.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 38,19C 39.4823,20.6344 43,26.1259 43,41L 47,46L 47,55L 43,50L 33,50L 29,55L 29,46L 33,41C 33,26.1259 36.0177,20.6344 38,19 Z M 38,57.5L 35,51L 41,51L 38,57.5 Z M 38,27L 36.1552,27.4612L 35.6203,30.5949L 38,30L 40.2918,30.573L 39.6953,27.4238L 38,27 Z "/>
diff --git a/navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg b/navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg
index 8ea1a7c5d..3a6e7a287 100644
--- a/navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg
+++ b/navit/gui/qt5_qml/skins/icons/appbar.transit.car.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 17.4167,50.6667C 16.5422,50.6667 15.8333,49.9578 15.8333,49.0833L 15.8333,39.5834C 15.8333,37.0877 17.2768,34.9292 19.3745,33.8972L 25.3333,19L 26.9167,19L 30.0833,19L 45.9167,19L 49.0833,19L 50.6667,19L 56.6255,33.8972C 58.7231,34.9292 60.1666,37.0877 60.1666,39.5834L 60.1667,49.0833C 60.1667,49.9578 59.4578,50.6667 58.5833,50.6667L 57,50.6667L 57,53.8333C 57,55.5822 55.5822,57 53.8333,57C 52.0844,57 50.6667,55.5822 50.6667,53.8333L 50.6667,50.6667L 25.3333,50.6667L 25.3333,53.8333C 25.3333,55.5822 23.9156,57 22.1667,57C 20.4178,57 19,55.5822 19,53.8333L 19,50.6667L 17.4167,50.6667 Z M 24.3833,33.25L 51.6166,33.25L 47.8166,23.75L 28.1833,23.75L 24.3833,33.25 Z M 24.1458,36.0209C 22.3969,36.0209 20.5833,37.8344 20.5833,39.5833C 20.5833,41.3322 22.3969,43.1458 24.1458,43.1458C 25.8947,43.1458 27.7083,41.3323 27.7083,39.5834C 27.7083,37.8345 25.8947,36.0209 24.1458,36.0209 Z M 51.8542,36.0208C 50.1053,36.0208 48.2917,37.8344 48.2917,39.5833C 48.2917,41.3322 50.1053,43.1458 51.8542,43.1458C 53.6031,43.1458 55.4167,41.3322 55.4167,39.5833C 55.4167,37.8344 53.6031,36.0208 51.8542,36.0208 Z "/>
diff --git a/navit/gui/qt5_qml/skins/menu.qml b/navit/gui/qt5_qml/skins/menu.qml
index 540a16032..0cb9ce38c 100644
--- a/navit/gui/qt5_qml/skins/menu.qml
+++ b/navit/gui/qt5_qml/skins/menu.qml
@@ -18,7 +18,7 @@ Rectangle {
anchors.leftMargin: 0
anchors.right: parent.right
anchors.rightMargin: 0
-
+
Loader {
id: menucontent
width: parent.width
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg
index 9dda725d2..c8e86b13f 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.book.list.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 22,19L 24,19L 24,57L 22,57L 22,19 Z M 26,57L 26,19.0001L 53.9999,19.0001L 53.9999,57L 26,57 Z M 30,24L 30,27L 50,27L 50,24L 30,24 Z M 30,32L 30,35L 33,35L 33,32L 30,32 Z M 36,32L 36,35L 49,35L 49,32L 36,32 Z M 30,40L 30,43L 33,43L 33,40L 30,40 Z M 36,40L 36,43L 48,43L 48,40L 36,40 Z M 30,48L 30,51L 33,51L 33,48L 30,48 Z M 36,48L 36,51L 50,51L 50,48L 36,48 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg
index 3917fc7cd..7dfd18eb4 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.down.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 37.8516,39.5833L 52.1016,24.9375L 52.1016,35.2292L 37.8516,50.2708L 23.6016,35.2292L 23.6016,24.9375L 37.8516,39.5833 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg
index b737d9773..a84cb0b21 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.chevron.up.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 37.8516,35.625L 34.6849,38.7917L 23.6016,50.2708L 23.6016,39.9792L 37.8516,24.9375L 52.1016,39.9792L 52.1016,50.2708L 41.0182,38.7917L 37.8516,35.625 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg
index f66893f7e..b23bfadeb 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.city.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 44.3333,30.0833L 57,30.0833L 57,57L 44.3333,57L 44.3333,30.0833 Z M 46.3125,35.2292L 46.3125,38L 49.0833,38L 49.0833,35.2292L 46.3125,35.2292 Z M 52.25,35.2292L 52.25,38L 55.0208,38L 55.0208,35.2292L 52.25,35.2292 Z M 46.3125,39.9792L 46.3125,42.75L 49.0833,42.75L 49.0833,39.9792L 46.3125,39.9792 Z M 52.25,39.9792L 52.25,42.75L 55.0208,42.75L 55.0208,39.9792L 52.25,39.9792 Z M 46.3125,44.7292L 46.3125,47.5L 49.0833,47.5L 49.0833,44.7292L 46.3125,44.7292 Z M 52.25,44.7292L 52.25,47.5L 55.0208,47.5L 55.0208,44.7292L 52.25,44.7292 Z M 46.3125,49.4792L 46.3125,52.25L 49.0833,52.25L 49.0833,49.4792L 46.3125,49.4792 Z M 52.25,49.4792L 52.25,52.25L 55.0208,52.25L 55.0208,49.4792L 52.25,49.4792 Z M 23.75,25.3333L 25.3333,22.1667L 26.9167,22.1667L 26.9167,18.2084L 28.5,18.2084L 28.5,22.1667L 31.6667,22.1667L 31.6667,18.2084L 33.25,18.2084L 33.25,22.1667L 34.8333,22.1667L 36.4167,25.3333L 36.4167,34.8334L 38.7917,34.8333L 41.1667,37.2083L 41.1667,57L 19,57L 19,37.2083L 21.375,34.8333L 23.75,34.8334L 23.75,25.3333 Z M 25.7291,27.3125L 25.7291,30.0834L 28.1041,30.0834L 28.1041,27.3125L 25.7291,27.3125 Z M 32.0625,27.3125L 32.0625,30.0834L 34.4375,30.0834L 34.4375,27.3125L 32.0625,27.3125 Z M 25.7291,32.0625L 25.7291,34.8334L 28.1041,34.8334L 28.1041,32.0625L 25.7291,32.0625 Z M 32.0625,32.0625L 32.0625,34.8334L 34.4375,34.8334L 34.4375,32.0625L 32.0625,32.0625 Z M 30.875,39.9792L 28.8958,39.9792L 28.8958,42.75L 30.875,42.75L 30.875,39.9792 Z M 24.5416,39.9792L 24.5416,42.75L 26.9166,42.75L 26.9166,39.9792L 24.5416,39.9792 Z M 36.0208,39.9792L 33.25,39.9792L 33.25,42.75L 36.0208,42.75L 36.0208,39.9792 Z M 30.875,44.7292L 28.8958,44.7292L 28.8958,47.5L 30.875,47.5L 30.875,44.7292 Z M 26.9166,44.7292L 24.5416,44.7292L 24.5416,47.5L 26.9166,47.5L 26.9166,44.7292 Z M 36.0208,44.7292L 33.25,44.7292L 33.25,47.5L 36.0208,47.5L 36.0208,44.7292 Z M 30.875,49.4792L 28.8958,49.4792L 28.8958,52.25L 30.875,52.25L 30.875,49.4792 Z M 26.9166,49.4792L 24.5416,49.4792L 24.5417,52.25L 26.9167,52.25L 26.9166,49.4792 Z M 36.0208,49.4792L 33.25,49.4792L 33.25,52.25L 36.0208,52.25L 36.0208,49.4792 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg
index 4ef1ef8c2..0c0590fcc 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.cog.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 27.5314,21.8628L 33.0126,19.4224L 34.7616,23.3507C 36.6693,22.9269 38.6044,22.8903 40.4668,23.2026L 42.0083,19.1868L 47.6098,21.337L 46.0683,25.3528C 47.6612,26.3669 49.0747,27.6889 50.2088,29.2803L 54.1371,27.5313L 56.5776,33.0126L 52.6493,34.7616C 53.0731,36.6693 53.1097,38.6043 52.7974,40.4668L 56.8131,42.0083L 54.6629,47.6097L 50.6472,46.0683C 49.6331,47.6613 48.3111,49.0748 46.7197,50.2089L 48.4686,54.1372L 42.9874,56.5776L 41.2384,52.6493C 39.3307,53.0731 37.3957,53.1097 35.5333,52.7974L 33.9918,56.8131L 28.3903,54.6629L 29.9318,50.6472C 28.3388,49.6331 26.9252,48.3111 25.7911,46.7196L 21.8628,48.4686L 19.4224,42.9873L 23.3507,41.2383C 22.9269,39.3307 22.8903,37.3957 23.2026,35.5332L 19.1869,33.9918L 21.3371,28.3903L 25.3528,29.9318C 26.3669,28.3388 27.6889,26.9252 29.2804,25.7911L 27.5314,21.8628 Z M 34.3394,29.7781C 29.7985,31.7998 27.7564,37.1198 29.7781,41.6606C 31.7998,46.2015 37.1198,48.2436 41.6606,46.2219C 46.2015,44.2002 48.2436,38.8802 46.2219,34.3394C 44.2002,29.7985 38.8802,27.7564 34.3394,29.7781 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg
index e3fdaa4ce..d8c1ab0fa 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.cogs.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 32.6227,68.9728C 33.1208,70.2446 33.7077,71.4719 34.3757,72.6471C 35.567,72.7702 36.7761,72.8333 38,72.8333C 40.6447,72.8333 43.2205,72.5386 45.6965,71.9802C 42.2807,68.5449 40.1698,63.8107 40.1698,58.5835C 40.1698,48.0901 48.6764,39.5835 59.1698,39.5835C 64.2047,39.5835 68.7822,41.5419 72.182,44.7385C 72.6094,42.5584 72.8333,40.3053 72.8333,38C 72.8333,36.442 72.731,34.908 72.5328,33.4041C 70.4772,32.3109 68.2718,31.4621 65.9554,30.8963L 65.6219,22.7367C 63.5664,22.3692 61.4511,22.1741 59.2916,22.1671L 57.491,30.1322C 54.2845,30.3184 51.2204,31.0348 48.3848,32.1949L 43.318,25.7887C 41.3995,26.7177 39.5749,27.8102 37.8622,29.0479L 41.0883,36.5527C 38.6742,38.5364 36.5919,40.9091 34.9373,43.575L 27.0703,41.3697C 26.073,43.2256 25.2319,45.178 24.5646,47.2093L 31.5867,51.385C 30.9883,53.6844 30.6698,56.0968 30.6698,58.5835L 30.746,60.6839L 23.0854,63.5239C 23.3743,65.6539 23.8474,67.7255 24.4881,69.7219L 32.6227,68.9728 Z M 27.0669,37.1755L 34.9338,39.3807C 35.9312,37.5248 36.7723,35.5724 37.4395,33.5412L 30.4175,29.3654C 31.0159,27.066 31.3344,24.6537 31.3344,22.1669L 31.2581,20.0665L 38.9187,17.2265C 38.6299,15.0965 38.1568,13.0249 37.5161,11.0285L 29.3815,11.7776C 28.4787,9.47258 27.2844,7.31377 25.8439,5.34655C 22.7943,6.48232 19.9467,8.03307 17.3698,9.93015C 20.1557,13.2359 21.8344,17.5054 21.8344,22.1669C 21.8344,32.5019 13.5826,40.9096 3.30816,41.1611C 3.60321,44.4411 4.35293,47.59 5.49381,50.5444C 8.34489,50.2806 11.0742,49.5968 13.6194,48.5555L 18.6861,54.9617C 20.6046,54.0327 22.4293,52.9403 24.142,51.7025L 20.9158,44.1977C 23.3299,42.2141 25.4123,39.8414 27.0669,37.1755 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg
index 13e6840e5..a3e73f41a 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.fullscreen.box.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 19,57L 19,19L 57,19L 57,57L 19,57 Z M 24,29L 47,29L 47,52L 52,52L 52,24L 24,24L 24,29 Z M 24,34L 24,52L 42,52L 42,34L 24,34 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg
index ea951fd19..273ff72cd 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.home.variant.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 24.0033,56.0078L 24.0033,38.0053L 22.0031,40.0056L 19.0027,35.0049L 38.0053,20.0028L 45.0063,25.5299L 45.0063,21.753L 49.0068,21.0029L 49.0068,28.6882L 57.008,35.0049L 54.0075,40.0056L 52.0073,38.0053L 52.0073,56.0078L 24.0033,56.0078 Z M 38.0053,26.9204L 27.0038,36.005L 27.0038,53.0074L 38.0045,53.0075L 38.0045,41.0061L 46.0058,41.0061L 46.0059,53.0075L 49.0068,53.0074L 49.0068,36.005L 38.0053,26.9204 Z M 30.004,41.0057L 35.0049,41.0057L 35.0049,47.0066L 30.004,47.0066L 30.004,41.0057 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg
index 031bd37f5..35a156ae9 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.information.circle.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 38,19C 48.4934,19 57,27.5066 57,38C 57,48.4934 48.4934,57 38,57C 27.5066,57 19,48.4934 19,38C 19,27.5066 27.5066,19 38,19 Z M 33.25,33.25L 33.25,36.4167L 36.4166,36.4167L 36.4166,47.5L 33.25,47.5L 33.25,50.6667L 44.3333,50.6667L 44.3333,47.5L 41.1666,47.5L 41.1666,36.4167L 41.1666,33.25L 33.25,33.25 Z M 38.7917,25.3333C 37.48,25.3333 36.4167,26.3967 36.4167,27.7083C 36.4167,29.02 37.48,30.0833 38.7917,30.0833C 40.1033,30.0833 41.1667,29.02 41.1667,27.7083C 41.1667,26.3967 40.1033,25.3333 38.7917,25.3333 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg
index ddbeb21ca..5157af942 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.delete.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 18.5088,44.0374L 21.8676,40.6786L 27.4655,46.2765L 33.0634,40.6786L 36.4222,44.0374L 30.8243,49.6353L 36.4222,55.2332L 33.0634,58.592L 27.4655,52.994L 21.8676,58.592L 18.5088,55.2332L 24.1068,49.6353L 18.5088,44.0374 Z M 57.0079,38.0053L 38.0053,47.5066L 36.7482,46.8781L 39.5889,44.0374L 35.2559,39.7977L 38.0053,41.1724L 50.6737,34.8382L 57.0079,38.0053 Z M 19.0026,38.0053L 25.3369,34.8382L 32.3326,38.3361L 29.8968,40.7719L 28.1098,42.5589L 25.7193,41.3636L 21.8676,37.6052L 20.6459,38.8269L 19.0026,38.0053 Z M 38.0053,19.0027L 57.0079,28.504L 38.0053,38.0053L 19.0026,28.504L 38.0053,19.0027 Z M 57.0079,47.5066L 38.0053,57.008L 37.8778,56.9442L 39.5889,55.2332L 33.9909,49.6353L 34.6367,48.9895L 38.0053,50.6738L 50.6737,44.3395L 57.0079,47.5066 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg
index 9eb28235c..b89bb2da3 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.layer.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76.0106" height="76.0106" viewBox="0 0 76.01 76.01" enable-background="new 0 0 76.01 76.01" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 57.0079,38.0053L 38.0053,47.5066L 19.0027,38.0053L 25.3369,34.8382L 38.0053,41.1724L 50.6737,34.8382L 57.0079,38.0053 Z M 38.0053,19.0027L 57.0079,28.504L 38.0053,38.0053L 19.0026,28.504L 38.0053,19.0027 Z M 57.0079,47.5066L 38.0053,57.008L 19.0026,47.5066L 25.3369,44.3395L 38.0053,50.6737L 50.6737,44.3395L 57.0079,47.5066 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg
index 3b21754c6..a58141d22 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.location.checkin.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-linejoin="round" d="M 38,19C 42.9706,19 47,23.0294 47,28C 47,30.5642 45.9276,32.878 38,49C 30.0724,32.878 29,30.5642 29,28C 29,23.0294 33.0294,19 38,19 Z M 38,24C 35.7909,24 34,25.7909 34,28C 34,30.2092 35.7909,32 38,32C 40.2091,32 42,30.2092 42,28C 42,25.7909 40.2091,24 38,24 Z M 19,57L 24,42L 31.5,42L 33.5,46L 27.6641,46L 25.3324,53L 50.6676,53L 48.3359,46L 42.5,46L 44.5,42L 52,42L 57,57L 19,57 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg
index fff6bf3e1..22f2d7001 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.location.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 26.9167,13.8542L 50.6666,13.8542L 50.6667,39.5833L 26.9167,63.3333L 26.9167,13.8542 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg
index 241f71e59..0a157d0da 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.map.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 27.7083,23.75L 38.7917,26.9167L 48.2917,20.5833L 62,24L 62,51L 48.2917,47.5L 38.7917,53.8333L 27.7083,50.6667L 16,55.5L 16,28.5L 27.7083,23.75 Z M 27,46.25L 27,29L 20,31.75L 20,49L 27,46.25 Z M 49,25.5L 49,42.75L 58,45.25L 58,28L 49,25.5 Z M 39,31.5L 39,49L 48,43L 48,25.5L 39,31.5 Z M 28,28.75L 28,46L 38,48.5L 38,31.75L 28,28.75 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg
index d3f865c0d..db23bca1f 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.power.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 36.4167,36.4167L 36.4167,17.4167L 41.1667,17.4167L 41.1667,36.4167L 36.4167,36.4167 Z M 57,39.5833C 57,50.0767 48.4934,58.5833 38,58.5833C 27.5066,58.5833 19,50.0767 19,39.5833C 19,30.7301 25.0552,23.2911 33.25,21.1819L 33.25,27.8374C 28.6079,29.7165 25.3333,34.2675 25.3333,39.5833C 25.3333,46.5789 31.0044,52.25 38,52.25C 44.9956,52.25 50.6667,46.5789 50.6667,39.5833C 50.6667,34.8949 48.1194,30.8014 44.3333,28.6113L 44.3333,21.6645C 51.7129,24.2728 57,31.3106 57,39.5833 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg
index a8c5c273a..d3b9d0a16 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.rocket.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 38,19C 39.4823,20.6344 43,26.1259 43,41L 47,46L 47,55L 43,50L 33,50L 29,55L 29,46L 33,41C 33,26.1259 36.0177,20.6344 38,19 Z M 38,57.5L 35,51L 41,51L 38,57.5 Z M 38,27L 36.1552,27.4612L 35.6203,30.5949L 38,30L 40.2918,30.573L 39.6953,27.4238L 38,27 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg
index a02cff6b7..7aded7af0 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.timer.rewind.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 53.8333,41.1667C 53.8333,49.9112 46.7445,57 38,57C 29.2555,57 22.1667,49.9112 22.1667,41.1667C 22.1667,32.9565 28.4156,26.2059 36.4167,25.4115L 36.4167,23.75L 31.6667,23.75L 31.6667,19L 44.3333,19L 44.3333,23.75L 39.5833,23.75L 39.5833,25.4115C 42.7678,25.7277 45.6747,26.9874 48.0205,28.907L 49.1629,27.7646L 46.9237,25.5254L 50.2825,22.1667L 57,28.8842L 53.6412,32.2429L 51.4021,30.0038L 50.2597,31.1462C 52.4932,33.8756 53.8333,37.3647 53.8333,41.1667 Z M 26.2296,39.5834L 30.0833,39.5834L 30.0833,42.75L 26.2296,42.75C 26.9347,48.0419 31.1248,52.232 36.4166,52.9371L 36.4166,49.0833L 39.5833,49.0833L 39.5833,52.9371C 44.8752,52.232 49.0653,48.0419 49.7703,42.75L 45.9166,42.75L 45.9166,39.5834L 49.7703,39.5834C 49.0652,34.2915 44.8751,30.1014 39.5833,29.3964L 39.5833,33.25L 36.4166,33.25L 36.4166,29.3964C 31.1248,30.1014 26.9347,34.2915 26.2296,39.5834 Z M 38,38C 39.7488,38 41.1666,39.4178 41.1666,41.1667C 41.1666,42.9156 39.7488,44.3334 38,44.3334L 31.6666,49.0834L 34.8333,41.1667C 34.8333,39.4178 36.2511,38 38,38 Z M 19.7917,33.25L 19.7917,26.938C 17.2963,30.5244 15.8333,34.883 15.8333,39.5833C 15.8333,51.8257 25.7577,61.75 38,61.75L 42.3542,61.75C 54.3778,61.75 64.1249,51.8257 64.125,39.5835C 64.125,54.0119 52.4284,65.7083 38,65.7083C 23.5716,65.7083 11.875,54.0118 11.875,39.5833C 11.875,33.9832 13.6371,28.7946 16.637,24.5417L 11.0833,24.5417L 15.0417,20.5834L 23.75,20.5833L 23.75,29.2917L 19.7917,33.25 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg b/navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg
index 8ea1a7c5d..3a6e7a287 100644
--- a/navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg
+++ b/navit/gui/qt5_qml/skins/modern/icons/appbar.transit.car.svg
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#ffffff" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 17.4167,50.6667C 16.5422,50.6667 15.8333,49.9578 15.8333,49.0833L 15.8333,39.5834C 15.8333,37.0877 17.2768,34.9292 19.3745,33.8972L 25.3333,19L 26.9167,19L 30.0833,19L 45.9167,19L 49.0833,19L 50.6667,19L 56.6255,33.8972C 58.7231,34.9292 60.1666,37.0877 60.1666,39.5834L 60.1667,49.0833C 60.1667,49.9578 59.4578,50.6667 58.5833,50.6667L 57,50.6667L 57,53.8333C 57,55.5822 55.5822,57 53.8333,57C 52.0844,57 50.6667,55.5822 50.6667,53.8333L 50.6667,50.6667L 25.3333,50.6667L 25.3333,53.8333C 25.3333,55.5822 23.9156,57 22.1667,57C 20.4178,57 19,55.5822 19,53.8333L 19,50.6667L 17.4167,50.6667 Z M 24.3833,33.25L 51.6166,33.25L 47.8166,23.75L 28.1833,23.75L 24.3833,33.25 Z M 24.1458,36.0209C 22.3969,36.0209 20.5833,37.8344 20.5833,39.5833C 20.5833,41.3322 22.3969,43.1458 24.1458,43.1458C 25.8947,43.1458 27.7083,41.3323 27.7083,39.5834C 27.7083,37.8345 25.8947,36.0209 24.1458,36.0209 Z M 51.8542,36.0208C 50.1053,36.0208 48.2917,37.8344 48.2917,39.5833C 48.2917,41.3322 50.1053,43.1458 51.8542,43.1458C 53.6031,43.1458 55.4167,41.3322 55.4167,39.5833C 55.4167,37.8344 53.6031,36.0208 51.8542,36.0208 Z "/>
diff --git a/navit/gui/qt5_qml/skins/modern/main.qml b/navit/gui/qt5_qml/skins/modern/main.qml
index 3c35a4dd0..5ffd1de3e 100644
--- a/navit/gui/qt5_qml/skins/modern/main.qml
+++ b/navit/gui/qt5_qml/skins/modern/main.qml
@@ -68,7 +68,7 @@ Rectangle {
NumberAnimation {
properties: "x,y,opacity";duration: 200
}
- onRunningChanged: {
+ onRunningChanged: {
if ((mainMenu.opacity == 0) && (!running)){
backend.resize(navit1.width, navit1.height);
console.log("transition done, hiding menu window size " + navit1.width + " x " + navit1.height)
diff --git a/navit/gui/qt5_qml/skins/modern/menu.qml b/navit/gui/qt5_qml/skins/modern/menu.qml
index ee51f68a2..bcca54b0b 100644
--- a/navit/gui/qt5_qml/skins/modern/menu.qml
+++ b/navit/gui/qt5_qml/skins/modern/menu.qml
@@ -8,7 +8,7 @@ Item {
width: parent.width
y: topBar.height
height: parent.height - ( topBar.height + bottomBar.height )
-
+
Loader {
id: menucontent
width: parent.width
diff --git a/navit/gui/qt5_qml/skins/pois.qml b/navit/gui/qt5_qml/skins/pois.qml
index bc083e1ed..a78260211 100644
--- a/navit/gui/qt5_qml/skins/pois.qml
+++ b/navit/gui/qt5_qml/skins/pois.qml
@@ -10,14 +10,14 @@ Item {
color: "#ff0000"
radius: 2
border.width: 1
-
+
Image {
id: image1
height: parent.height - 4;
source : model.modelData.active ? "icons/appbar.layer.svg" : "icons/appbar.layer.delete.svg"
opacity: model.modelData.active ? 1 : 0.4
}
-
+
Text {
width: 128
id: distanceText
@@ -27,7 +27,7 @@ Item {
anchors.left: image1.right
anchors.leftMargin: 8
}
-
+
Text {
text: name
color: "#ffffff"
@@ -35,7 +35,7 @@ Item {
anchors.left: distanceText.right
anchors.leftMargin: 8
}
-
+
MouseArea{
anchors.fill: parent
hoverEnabled: true
@@ -44,7 +44,7 @@ Item {
}
}
}
-
+
Component.onCompleted: backend.get_pois()
}
diff --git a/navit/gui/win32/CMakeLists.txt b/navit/gui/win32/CMakeLists.txt
index 16b653c9f..2c5dd0923 100644
--- a/navit/gui/win32/CMakeLists.txt
+++ b/navit/gui/win32/CMakeLists.txt
@@ -1,2 +1,2 @@
-module_add_library(gui_win32 gui_win32.c win32_gui_destination.c win32_gui_notify.c ceglue.c)
+module_add_library(gui_win32 gui_win32.c win32_gui_destination.c win32_gui_notify.c ceglue.c)
diff --git a/navit/gui/win32/ceglue.c b/navit/gui/win32/ceglue.c
index a0817f935..ff3310fb2 100644
--- a/navit/gui/win32/ceglue.c
+++ b/navit/gui/win32/ceglue.c
@@ -1,77 +1,72 @@
-#include <windows.h>
-#include "ceglue.h"
-
-BOOL FAR (*SHFullScreenPtr)(HWND hwnd, DWORD state) = NULL;
-
-void InitCeGlue (void)
-{
- HINSTANCE ayg = LoadLibraryW (TEXT ("aygshell.dll"));
- if (ayg != NULL) {
- SHFullScreenPtr = (BOOL (*)(HWND, DWORD))
- GetProcAddressW (ayg, TEXT ("SHFullScreen"));
- }
-}
-
-// code to turn of screen adopted from
-// http://msdn.microsoft.com/en-us/library/ms838354.aspx
-
-// GDI Escapes for ExtEscape()
-#define QUERYESCSUPPORT 8
-
-// The following are unique to CE
-#define GETVFRAMEPHYSICAL 6144
-#define GETVFRAMELEN 6145
-#define DBGDRIVERSTAT 6146
-#define SETPOWERMANAGEMENT 6147
-#define GETPOWERMANAGEMENT 6148
-
-
-typedef enum _VIDEO_POWER_STATE {
- VideoPowerOn = 1,
- VideoPowerStandBy,
- VideoPowerSuspend,
- VideoPowerOff
-} VIDEO_POWER_STATE, *PVIDEO_POWER_STATE;
-
-
-typedef struct _VIDEO_POWER_MANAGEMENT {
- ULONG Length;
- ULONG DPMSVersion;
- ULONG PowerState;
-} VIDEO_POWER_MANAGEMENT, *PVIDEO_POWER_MANAGEMENT;
-
-
-int CeEnableBacklight(int enable)
-{
- HDC gdc;
- int iESC=SETPOWERMANAGEMENT;
-
- gdc = GetDC(NULL);
- if (ExtEscape(gdc, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&iESC,
- 0, NULL)==0)
- {
- MessageBox(NULL,
- L"Sorry, your Pocket PC does not support DisplayOff",
- L"Pocket PC Display Off Feature",
- MB_OK);
- ReleaseDC(NULL, gdc);
- return FALSE;
- }
- else
- {
- VIDEO_POWER_MANAGEMENT vpm;
- vpm.Length = sizeof(VIDEO_POWER_MANAGEMENT);
- vpm.DPMSVersion = 0x0001;
- if (enable) {
- vpm.PowerState = VideoPowerOn;
- } else {
- vpm.PowerState = VideoPowerOff;
- }
- // Power off the display
- ExtEscape(gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) &vpm,
- 0, NULL);
- ReleaseDC(NULL, gdc);
- return TRUE;
- }
-}
-
+#include <windows.h>
+#include "ceglue.h"
+
+BOOL FAR (*SHFullScreenPtr)(HWND hwnd, DWORD state) = NULL;
+
+void InitCeGlue (void) {
+ HINSTANCE ayg = LoadLibraryW (TEXT ("aygshell.dll"));
+ if (ayg != NULL) {
+ SHFullScreenPtr = (BOOL (*)(HWND, DWORD))
+ GetProcAddressW (ayg, TEXT ("SHFullScreen"));
+ }
+}
+
+// code to turn of screen adopted from
+// http://msdn.microsoft.com/en-us/library/ms838354.aspx
+
+// GDI Escapes for ExtEscape()
+#define QUERYESCSUPPORT 8
+
+// The following are unique to CE
+#define GETVFRAMEPHYSICAL 6144
+#define GETVFRAMELEN 6145
+#define DBGDRIVERSTAT 6146
+#define SETPOWERMANAGEMENT 6147
+#define GETPOWERMANAGEMENT 6148
+
+
+typedef enum _VIDEO_POWER_STATE {
+ VideoPowerOn = 1,
+ VideoPowerStandBy,
+ VideoPowerSuspend,
+ VideoPowerOff
+} VIDEO_POWER_STATE, *PVIDEO_POWER_STATE;
+
+
+typedef struct _VIDEO_POWER_MANAGEMENT {
+ ULONG Length;
+ ULONG DPMSVersion;
+ ULONG PowerState;
+} VIDEO_POWER_MANAGEMENT, *PVIDEO_POWER_MANAGEMENT;
+
+
+int CeEnableBacklight(int enable) {
+ HDC gdc;
+ int iESC=SETPOWERMANAGEMENT;
+
+ gdc = GetDC(NULL);
+ if (ExtEscape(gdc, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&iESC,
+ 0, NULL)==0) {
+ MessageBox(NULL,
+ L"Sorry, your Pocket PC does not support DisplayOff",
+ L"Pocket PC Display Off Feature",
+ MB_OK);
+ ReleaseDC(NULL, gdc);
+ return FALSE;
+ } else {
+ VIDEO_POWER_MANAGEMENT vpm;
+ vpm.Length = sizeof(VIDEO_POWER_MANAGEMENT);
+ vpm.DPMSVersion = 0x0001;
+ if (enable) {
+ vpm.PowerState = VideoPowerOn;
+ } else {
+ vpm.PowerState = VideoPowerOff;
+ }
+ // Power off the display
+ ExtEscape(gdc, SETPOWERMANAGEMENT, vpm.Length, (LPCSTR) &vpm,
+ 0, NULL);
+ ReleaseDC(NULL, gdc);
+ return TRUE;
+ }
+}
+
diff --git a/navit/gui/win32/ceglue.h b/navit/gui/win32/ceglue.h
index b0dc79d42..bb185dbed 100644
--- a/navit/gui/win32/ceglue.h
+++ b/navit/gui/win32/ceglue.h
@@ -1,16 +1,16 @@
-#ifndef CEGLUE_H
-#define CEGLUE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern BOOL (*SHFullScreenPtr)(HWND hwnd, DWORD state);
-void InitCeGlue (void);
-
-int CeEnableBacklight(int enable);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+#ifndef CEGLUE_H
+#define CEGLUE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern BOOL (*SHFullScreenPtr)(HWND hwnd, DWORD state);
+void InitCeGlue (void);
+
+int CeEnableBacklight(int enable);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/navit/gui/win32/gui_win32.c b/navit/gui/win32/gui_win32.c
index 8a8cb37b9..63edd73df 100644
--- a/navit/gui/win32/gui_win32.c
+++ b/navit/gui/win32/gui_win32.c
@@ -36,459 +36,429 @@ const TCHAR g_szClassName[] = TEXT("navit_gui_class");
static UINT_PTR menu_id = 0;
#if 0
-static gboolean message_pump( gpointer data )
-{
+static gboolean message_pump( gpointer data ) {
MSG messages;
- Sleep( 1 );
+ Sleep( 1 );
- if (GetMessage (&messages, NULL, 0, 0))
- {
+ if (GetMessage (&messages, NULL, 0, 0)) {
TranslateMessage(&messages);
DispatchMessage(&messages);
+ } else {
+ exit( 0 );
}
- else{
- exit( 0 );
- }
- return TRUE;
+ return TRUE;
}
-static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
-{
+static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam) {
LPRECT rcParent;
int idChild;
idChild = GetWindowLong(hwndChild, GWL_ID);
- if ( idChild == ID_CHILD_GFX )
- {
- rcParent = (LPRECT) lParam;
+ if ( idChild == ID_CHILD_GFX ) {
+ rcParent = (LPRECT) lParam;
- MoveWindow( hwndChild, 0, 0, rcParent->right, rcParent->bottom, TRUE );
- PostMessage( hwndChild, WM_USER+1, 0, 0 );
- }
+ MoveWindow( hwndChild, 0, 0, rcParent->right, rcParent->bottom, TRUE );
+ PostMessage( hwndChild, WM_USER+1, 0, 0 );
+ }
return TRUE;
}
#endif
#ifndef GET_WHEEL_DELTA_WPARAM
- #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
+#define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam))
#endif
-static void CreateToolBar(HWND hwnd)
-{
- // Create Toolbar
- HWND hTool;
- TBBUTTON tbb[8];
- TBADDBITMAP tbab;
+static void CreateToolBar(HWND hwnd) {
+ // Create Toolbar
+ HWND hTool;
+ TBBUTTON tbb[8];
+ TBADDBITMAP tbab;
#if 0 /* def _WIN32_WCE */
- /* Have to initialize common controls under CE */
- INITCOMMONCONTROLSEX iccex;
- iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
- iccex.dwICC = ICC_BAR_CLASSES;
- InitCommonControlsEx (&iccex);
+ /* Have to initialize common controls under CE */
+ INITCOMMONCONTROLSEX iccex;
+ iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
+ iccex.dwICC = ICC_BAR_CLASSES;
+ InitCommonControlsEx (&iccex);
#else
- InitCommonControls();
+ InitCommonControls();
#endif
- hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
- hwnd, (HMENU)ID_CHILD_TOOLBAR, GetModuleHandle(NULL), NULL);
-
- if(hTool == NULL)
- MessageBox(hwnd, TEXT("Could not create tool bar."), TEXT("Error"), MB_OK | MB_ICONERROR);
-
- SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
-
- tbab.hInst = GetModuleHandle(NULL);
- tbab.nID = IDB_NAVITTOOLBAR;
- int iImageOffset = SendMessage(hTool, TB_ADDBITMAP, 10, (LPARAM) &tbab);
-
- int iStr;
-
- ZeroMemory(tbb, sizeof(tbb));
-
- tbb[0].iBitmap = iImageOffset;
- tbb[0].fsState = TBSTATE_ENABLED;
- tbb[0].fsStyle = TBSTYLE_BUTTON;
- tbb[0].idCommand = ID_DISPLAY_ZOOMIN;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomIn" );
- tbb[0].iString = iStr;
-
- tbb[1].iBitmap = iImageOffset+1;
- tbb[1].fsState = TBSTATE_ENABLED;
- tbb[1].fsStyle = TBSTYLE_BUTTON;
- tbb[1].idCommand = ID_DISPLAY_ZOOMOUT;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomOut" );
- tbb[1].iString = iStr;
-
- tbb[2].iBitmap = iImageOffset+4;
- tbb[2].fsState = TBSTATE_ENABLED;
- tbb[2].fsStyle = TBSTYLE_BUTTON;
- tbb[2].idCommand = ID_DISPLAY_REFRESH;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Refresh" );
- tbb[2].iString = iStr;
-
- tbb[3].iBitmap = iImageOffset+2;
- tbb[3].fsState = TBSTATE_ENABLED;
- tbb[3].fsStyle = TBSTYLE_BUTTON;
- tbb[3].idCommand = ID_DISPLAY_ZOOMIN;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Cursor" );
- tbb[3].iString = iStr;
-
- tbb[4].iBitmap = iImageOffset+5;
- tbb[4].fsState = TBSTATE_ENABLED;
- tbb[4].fsStyle = TBSTYLE_BUTTON;
- tbb[4].idCommand = ID_DISPLAY_ORIENT;
- iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Orientation" );
- tbb[4].iString = iStr;
-
- tbb[5].iBitmap = iImageOffset+8;
- tbb[5].fsState = TBSTATE_ENABLED;
- tbb[5].fsStyle = TBSTYLE_BUTTON;
- tbb[5].idCommand = ID_DISPLAY_ZOOMIN;
- iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Destination" );
- tbb[5].iString = iStr;
-
- tbb[6].iBitmap = iImageOffset+3;
- tbb[6].fsState = TBSTATE_ENABLED;
- tbb[6].fsStyle = TBSTYLE_BUTTON;
- tbb[6].idCommand = ID_DISPLAY_ZOOMIN;
- iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Roadbook" );
- tbb[6].iString = iStr;
-
- tbb[7].iBitmap = iImageOffset+9;
- tbb[7].fsState = TBSTATE_ENABLED;
- tbb[7].fsStyle = TBSTYLE_BUTTON;
- tbb[7].idCommand = ID_FILE_EXIT;
- iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"_Quit" );
- tbb[7].iString = iStr;
-
- SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
+ hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
+ hwnd, (HMENU)ID_CHILD_TOOLBAR, GetModuleHandle(NULL), NULL);
+
+ if(hTool == NULL)
+ MessageBox(hwnd, TEXT("Could not create tool bar."), TEXT("Error"), MB_OK | MB_ICONERROR);
+
+ SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
+
+ tbab.hInst = GetModuleHandle(NULL);
+ tbab.nID = IDB_NAVITTOOLBAR;
+ int iImageOffset = SendMessage(hTool, TB_ADDBITMAP, 10, (LPARAM) &tbab);
+
+ int iStr;
+
+ ZeroMemory(tbb, sizeof(tbb));
+
+ tbb[0].iBitmap = iImageOffset;
+ tbb[0].fsState = TBSTATE_ENABLED;
+ tbb[0].fsStyle = TBSTYLE_BUTTON;
+ tbb[0].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomIn" );
+ tbb[0].iString = iStr;
+
+ tbb[1].iBitmap = iImageOffset+1;
+ tbb[1].fsState = TBSTATE_ENABLED;
+ tbb[1].fsStyle = TBSTYLE_BUTTON;
+ tbb[1].idCommand = ID_DISPLAY_ZOOMOUT;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"ZoomOut" );
+ tbb[1].iString = iStr;
+
+ tbb[2].iBitmap = iImageOffset+4;
+ tbb[2].fsState = TBSTATE_ENABLED;
+ tbb[2].fsStyle = TBSTYLE_BUTTON;
+ tbb[2].idCommand = ID_DISPLAY_REFRESH;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Refresh" );
+ tbb[2].iString = iStr;
+
+ tbb[3].iBitmap = iImageOffset+2;
+ tbb[3].fsState = TBSTATE_ENABLED;
+ tbb[3].fsStyle = TBSTYLE_BUTTON;
+ tbb[3].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Cursor" );
+ tbb[3].iString = iStr;
+
+ tbb[4].iBitmap = iImageOffset+5;
+ tbb[4].fsState = TBSTATE_ENABLED;
+ tbb[4].fsStyle = TBSTYLE_BUTTON;
+ tbb[4].idCommand = ID_DISPLAY_ORIENT;
+ iStr = SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Orientation" );
+ tbb[4].iString = iStr;
+
+ tbb[5].iBitmap = iImageOffset+8;
+ tbb[5].fsState = TBSTATE_ENABLED;
+ tbb[5].fsStyle = TBSTYLE_BUTTON;
+ tbb[5].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Destination" );
+ tbb[5].iString = iStr;
+
+ tbb[6].iBitmap = iImageOffset+3;
+ tbb[6].fsState = TBSTATE_ENABLED;
+ tbb[6].fsStyle = TBSTYLE_BUTTON;
+ tbb[6].idCommand = ID_DISPLAY_ZOOMIN;
+ iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"Roadbook" );
+ tbb[6].iString = iStr;
+
+ tbb[7].iBitmap = iImageOffset+9;
+ tbb[7].fsState = TBSTATE_ENABLED;
+ tbb[7].fsStyle = TBSTYLE_BUTTON;
+ tbb[7].idCommand = ID_FILE_EXIT;
+ iStr= SendMessage(hTool, TB_ADDSTRINGW, 0, (LPARAM) L"_Quit" );
+ tbb[7].iString = iStr;
+
+ SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
}
-static void window_layout( HWND hwnd )
-{
+static void window_layout( HWND hwnd ) {
#ifndef HAVE_API_WIN32_CE
- RECT rcClient;
- RECT rcTool;
- int iToolHeight;
+ RECT rcClient;
+ RECT rcTool;
+ int iToolHeight;
- HWND hChild = GetDlgItem(hwnd, ID_CHILD_TOOLBAR);
- SendMessage(hChild, TB_AUTOSIZE, 0, 0);
+ HWND hChild = GetDlgItem(hwnd, ID_CHILD_TOOLBAR);
+ SendMessage(hChild, TB_AUTOSIZE, 0, 0);
- GetWindowRect(hChild, &rcTool);
- iToolHeight = rcTool.bottom - rcTool.top;
+ GetWindowRect(hChild, &rcTool);
+ iToolHeight = rcTool.bottom - rcTool.top;
- GetClientRect(hwnd, &rcClient);
- //printf( "BEFORE resize gui to: %d %d %d %d \n", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
+ GetClientRect(hwnd, &rcClient);
+ //printf( "BEFORE resize gui to: %d %d %d %d \n", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
- rcClient.top += iToolHeight;
+ rcClient.top += iToolHeight;
- dbg(lvl_debug, "resize gui to: %d %d %d %d \n", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
+ dbg(lvl_debug, "resize gui to: %d %d %d %d ", rcClient.left, rcClient.right, rcClient.top, rcClient.bottom );
- hChild = GetDlgItem(hwnd, ID_CHILD_GFX);
- if ( hChild )
- {
- MoveWindow( hChild, rcClient.left, rcClient.top, rcClient.right- rcClient.left, rcClient.bottom - rcClient.top, TRUE );
- PostMessage( hChild, WM_USER+1, 0, 0 );
- }
+ hChild = GetDlgItem(hwnd, ID_CHILD_GFX);
+ if ( hChild ) {
+ MoveWindow( hChild, rcClient.left, rcClient.top, rcClient.right- rcClient.left, rcClient.bottom - rcClient.top, TRUE );
+ PostMessage( hChild, WM_USER+1, 0, 0 );
+ }
#endif
}
#ifdef __CEGCC__
-static void toggle_fullscreen(HWND mWnd)
-{
- if (SHFullScreenPtr) {
- if (!ce_fullscreen) {
- (*SHFullScreenPtr)(mWnd, SHFS_HIDETASKBAR |
- SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
- } else {
- (*SHFullScreenPtr)(mWnd, SHFS_HIDESIPBUTTON);
- }
- ce_fullscreen = !ce_fullscreen;
- }
+static void toggle_fullscreen(HWND mWnd) {
+ if (SHFullScreenPtr) {
+ if (!ce_fullscreen) {
+ (*SHFullScreenPtr)(mWnd, SHFS_HIDETASKBAR |
+ SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
+ } else {
+ (*SHFullScreenPtr)(mWnd, SHFS_HIDESIPBUTTON);
+ }
+ ce_fullscreen = !ce_fullscreen;
+ }
}
-static void toggle_backlight(void)
-{
- if (ce_backlight)
- if (CeEnableBacklight(FALSE))
- ce_backlight = 0;
- else
- if (CeEnableBacklight(TRUE))
- ce_backlight = 1;
+static void toggle_backlight(void) {
+ if (ce_backlight)
+ if (CeEnableBacklight(FALSE))
+ ce_backlight = 0;
+ else if (CeEnableBacklight(TRUE))
+ ce_backlight = 1;
}
#endif
-static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
-{
+static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
RECT rcClient;
// printf( "PARENT %d %d %d \n", Message, wParam, lParam );
- switch(Message)
- {
- case WM_CREATE:
- {
- HMENU hMenu, hSubMenu;
+ switch(Message) {
+ case WM_CREATE: {
+ HMENU hMenu, hSubMenu;
- CreateToolBar( hwnd );
+ CreateToolBar( hwnd );
- hMenu = CreateMenu();
- // g_this_->hwnd = hwnd;
+ hMenu = CreateMenu();
+ // g_this_->hwnd = hwnd;
- hSubMenu = CreatePopupMenu();
+ hSubMenu = CreatePopupMenu();
- AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMIN, L"ZoomIn" );
- AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMOUT, L"ZoomOut" );
- AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_REFRESH, L"Refresh" );
- AppendMenuW(hSubMenu, MF_SEPARATOR, 0, NULL );
- AppendMenuW(hSubMenu, MF_STRING, ID_FILE_EXIT, L"_Quit" );
+ AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMIN, L"ZoomIn" );
+ AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_ZOOMOUT, L"ZoomOut" );
+ AppendMenuW(hSubMenu, MF_STRING, ID_DISPLAY_REFRESH, L"Refresh" );
+ AppendMenuW(hSubMenu, MF_SEPARATOR, 0, NULL );
+ AppendMenuW(hSubMenu, MF_STRING, ID_FILE_EXIT, L"_Quit" );
- AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, L"Display" );
- hSubMenu = CreatePopupMenu();
- AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, TEXT("&Go"));
- AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, TEXT("&Stuff"));
+ AppendMenuW(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, L"Display" );
+ hSubMenu = CreatePopupMenu();
+ AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, TEXT("&Go"));
+ AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, TEXT("&Stuff"));
#ifndef HAVE_API_WIN32_CE
- SetMenu(hwnd, hMenu);
+ SetMenu(hwnd, hMenu);
#endif
- window_layout( hwnd );
-
- }
- break;
- case WM_COMMAND:
- {
- printf( "WM_COMMAND %d\n", LOWORD(wParam) );
- struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
-
-
- switch(LOWORD(wParam))
- {
- case ID_DISPLAY_ZOOMIN:
- navit_zoom_in(gui->nav, 2, NULL);
- return 0;
- break;
- case ID_DISPLAY_ZOOMOUT:
- navit_zoom_out(gui->nav, 2, NULL);
- return 0;
- break;
- case ID_DISPLAY_REFRESH:
- navit_draw(gui->nav);
- return 0;
- break;
- case ID_DISPLAY_CURSOR:
- {
- struct attr attr;
- attr.type=attr_cursor;
- // TODO attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_cursor\n");
- }
- return 0;
- }
- break;
- case ID_DISPLAY_ORIENT:
- {
- struct attr attr;
-
- attr.type=attr_orientation;
- // attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
- attr.u.num = 0; // TODO
- if(!navit_set_attr(gui->nav, &attr)) {
- dbg(lvl_error, "Failed to set attr_orientation\n");
- }
- return 0;
- }
-
- case ID_FILE_EXIT:
- PostMessage(hwnd, WM_CLOSE, 0, 0);
- return 0;
- break;
- }
-#if HAVE_GLIB
- if ( popup_menu_array )
- {
- struct menu_priv* priv = (struct menu_priv*)g_array_index( popup_menu_array, gint, LOWORD(wParam) - POPUP_MENU_OFFSET );
-
- if ( priv )
- {
- struct callback* cb = priv->cb;
- if ( priv->cb )
- {
- callback_call_0( priv->cb );
- return 0;
- }
- }
- }
-#endif
- }
- break;
- case WM_USER+ 1:
- GetClientRect(hwnd, &rcClient);
- printf( "resize gui to: %d %d \n", rcClient.right, rcClient.bottom );
-
- window_layout( hwnd );
- //EnumChildWindows(hwnd, EnumChildProc, (LPARAM) &rcClient);
+ window_layout( hwnd );
+
+ }
+ break;
+ case WM_COMMAND: {
+ printf( "WM_COMMAND %d\n", LOWORD(wParam) );
+ struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
+
+
+ switch(LOWORD(wParam)) {
+ case ID_DISPLAY_ZOOMIN:
+ navit_zoom_in(gui->nav, 2, NULL);
+ return 0;
+ break;
+ case ID_DISPLAY_ZOOMOUT:
+ navit_zoom_out(gui->nav, 2, NULL);
+ return 0;
+ break;
+ case ID_DISPLAY_REFRESH:
+ navit_draw(gui->nav);
+ return 0;
+ break;
+ case ID_DISPLAY_CURSOR: {
+ struct attr attr;
+ attr.type=attr_cursor;
+ // TODO attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_cursor");
+ }
return 0;
- break;
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- case WM_SIZE:
- window_layout( hwnd );
+ }
+ break;
+ case ID_DISPLAY_ORIENT: {
+ struct attr attr;
+
+ attr.type=attr_orientation;
+ // attr.u.num=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(w));
+ attr.u.num = 0; // TODO
+ if(!navit_set_attr(gui->nav, &attr)) {
+ dbg(lvl_error, "Failed to set attr_orientation");
+ }
return 0;
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
-
- case WM_MOUSEWHEEL:
- {
- struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
-
- short delta = GET_WHEEL_DELTA_WPARAM( wParam );
- if ( delta > 0 )
- {
- navit_zoom_in(gui->nav, 2, NULL);
- }
- else{
- navit_zoom_out(gui->nav, 2, NULL);
- }
- }
- break;
+ }
+
+ case ID_FILE_EXIT:
+ PostMessage(hwnd, WM_CLOSE, 0, 0);
+ return 0;
+ break;
+ }
+#if HAVE_GLIB
+ if ( popup_menu_array ) {
+ struct menu_priv* priv = (struct menu_priv*)g_array_index( popup_menu_array, gint, LOWORD(wParam) - POPUP_MENU_OFFSET );
+
+ if ( priv ) {
+ struct callback* cb = priv->cb;
+ if ( priv->cb ) {
+ callback_call_0( priv->cb );
+ return 0;
+ }
+ }
+ }
+#endif
+ }
+ break;
+ case WM_USER+ 1:
+ GetClientRect(hwnd, &rcClient);
+ printf( "resize gui to: %d %d \n", rcClient.right, rcClient.bottom );
+
+ window_layout( hwnd );
+ //EnumChildWindows(hwnd, EnumChildProc, (LPARAM) &rcClient);
+ return 0;
+ break;
+ case WM_CLOSE:
+ DestroyWindow(hwnd);
+ break;
+ case WM_SIZE:
+ window_layout( hwnd );
+ return 0;
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
+
+ case WM_MOUSEWHEEL: {
+ struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
+
+ short delta = GET_WHEEL_DELTA_WPARAM( wParam );
+ if ( delta > 0 ) {
+ navit_zoom_in(gui->nav, 2, NULL);
+ } else {
+ navit_zoom_out(gui->nav, 2, NULL);
+ }
+ }
+ break;
#ifdef HAVE_API_WIN32_CE
- case WM_KEYDOWN:
- {
- struct point p;
- int w,h;
- struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
- transform_get_size(navit_get_trans(gui->nav), &w, &h);
-
- if (wParam == VK_LEFT || wParam == '4') {
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == VK_RIGHT || wParam == '6') {
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == VK_UP || wParam == '2') {
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == VK_DOWN || wParam == '8') {
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(gui->nav, &p, 1);
- } else if (wParam == '1') {
- navit_zoom_in(gui->nav, 2, NULL);
- } else if (wParam == '3') {
- navit_zoom_out(gui->nav, 2, NULL);
- } else if (wParam == '7') {
+ case WM_KEYDOWN: {
+ struct point p;
+ int w,h;
+ struct gui_priv* gui = (struct gui_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
+ transform_get_size(navit_get_trans(gui->nav), &w, &h);
+
+ if (wParam == VK_LEFT || wParam == '4') {
+ p.x=0;
+ p.y=h/2;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == VK_RIGHT || wParam == '6') {
+ p.x=w;
+ p.y=h/2;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == VK_UP || wParam == '2') {
+ p.x=w/2;
+ p.y=0;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == VK_DOWN || wParam == '8') {
+ p.x=w/2;
+ p.y=h;
+ navit_set_center_screen(gui->nav, &p, 1);
+ } else if (wParam == '1') {
+ navit_zoom_in(gui->nav, 2, NULL);
+ } else if (wParam == '3') {
+ navit_zoom_out(gui->nav, 2, NULL);
+ } else if (wParam == '7') {
#if 0
- toggle_backlight();
+ toggle_backlight();
#endif
- } else if (wParam == '9') {
+ } else if (wParam == '9') {
#if 0
- toggle_fullscreen(hwnd);
+ toggle_fullscreen(hwnd);
#endif
- }
- }
- break;
+ }
+ }
+ break;
#endif
- default:
- return DefWindowProc(hwnd, Message, wParam, lParam);
- }
- return 0;
+ default:
+ return DefWindowProc(hwnd, Message, wParam, lParam);
+ }
+ return 0;
}
-static HANDLE CreateWin32Window( void )
-{
+static HANDLE CreateWin32Window( void ) {
#ifdef HAVE_API_WIN32_CE
- WNDCLASS wc;
+ WNDCLASS wc;
#else
- WNDCLASSEX wc;
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.hIconSm = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
+ WNDCLASSEX wc;
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.hIconSm = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
#endif
- HWND hwnd;
+ HWND hwnd;
// MSG Msg;
- wc.style = 0;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 32;
- wc.hInstance = NULL;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = g_szClassName;
- wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
+ wc.style = 0;
+ wc.lpfnWndProc = WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 32;
+ wc.hInstance = NULL;
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = g_szClassName;
+ wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
#ifdef HAVE_API_WIN32_CE
- if(!RegisterClass(&wc))
+ if(!RegisterClass(&wc))
#else
- if(!RegisterClassEx(&wc))
+ if(!RegisterClassEx(&wc))
#endif
- {
- MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
+ {
+ MessageBox(NULL, TEXT("Window Registration Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
+ return 0;
+ }
- hwnd = CreateWindowEx(
- WS_EX_CLIENTEDGE,
- g_szClassName,
- TEXT( "Navit" ),
+ hwnd = CreateWindowEx(
+ WS_EX_CLIENTEDGE,
+ g_szClassName,
+ TEXT( "Navit" ),
#ifdef HAVE_API_WIN32_CE
- WS_SYSMENU | WS_CLIPCHILDREN,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ WS_SYSMENU | WS_CLIPCHILDREN,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
#else
- WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
- CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+ CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
#endif
- NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL);
- if(hwnd == NULL)
- {
- MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
- return 0;
- }
+ if(hwnd == NULL) {
+ MessageBox(NULL, TEXT("Window Creation Failed!"), TEXT("Error!"), MB_ICONEXCLAMATION | MB_OK);
+ return 0;
+ }
- ShowWindow(hwnd, TRUE);
- UpdateWindow(hwnd);
+ ShowWindow(hwnd, TRUE);
+ UpdateWindow(hwnd);
#if 0
- g_idle_add (message_pump, NULL);
+ g_idle_add (message_pump, NULL);
#endif
- return hwnd;
+ return hwnd;
}
-static int win32_gui_set_graphics(struct gui_priv *this_, struct graphics *gra)
-{
- HANDLE* wndHandle_ptr = graphics_get_data(gra, "wnd_parent_handle_ptr");
- *wndHandle_ptr = this_->hwnd;
- graphics_get_data(gra, "START_CLIENT");
- return 0;
+static int win32_gui_set_graphics(struct gui_priv *this_, struct graphics *gra) {
+ HANDLE* wndHandle_ptr = graphics_get_data(gra, "wnd_parent_handle_ptr");
+ *wndHandle_ptr = this_->hwnd;
+ graphics_get_data(gra, "START_CLIENT");
+ return 0;
}
-static void win32_gui_add_bookmark_do(struct gui_priv *gui)
-{
+static void win32_gui_add_bookmark_do(struct gui_priv *gui) {
// navit_add_bookmark(gui->nav, &gui->dialog_coord, gtk_entry_get_text(GTK_ENTRY(gui->dialog_entry)));
// gtk_widget_destroy(gui->dialog_win);
}
-static int win32_gui_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description)
-{
- return 1;
+static int win32_gui_add_bookmark(struct gui_priv *gui, struct pcoord *c, char *description) {
+ return 1;
}
@@ -496,148 +466,135 @@ static struct menu_methods menu_methods;
static struct menu_priv *add_menu( struct menu_priv *menu,
- struct menu_methods *meth,
- char *name,
- enum menu_type type,
- struct callback *cb)
-{
- struct menu_priv* ret = NULL;
-
- ret = g_new0(struct menu_priv, 1);
-
- *ret = *menu;
- *meth = menu_methods;
-
- TCHAR *menuname = newSysString(name);
-
- if ( type == menu_type_submenu )
- {
- HMENU hSubMenu = NULL;
- hSubMenu = CreatePopupMenu();
- AppendMenu(menu->hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, menuname );
- ret->hMenu = hSubMenu;
- }
- else
- {
- AppendMenu( menu->hMenu, MF_STRING, menu_id, name );
- }
-
- // g_hash_table_insert( popup_callback_hash, GINT_TO_POINTER( menu_id ), (gpointer)cb );
+ struct menu_methods *meth,
+ char *name,
+ enum menu_type type,
+ struct callback *cb) {
+ struct menu_priv* ret = NULL;
+
+ ret = g_new0(struct menu_priv, 1);
+
+ *ret = *menu;
+ *meth = menu_methods;
+
+ TCHAR *menuname = newSysString(name);
+
+ if ( type == menu_type_submenu ) {
+ HMENU hSubMenu = NULL;
+ hSubMenu = CreatePopupMenu();
+ AppendMenu(menu->hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, menuname );
+ ret->hMenu = hSubMenu;
+ } else {
+ AppendMenu( menu->hMenu, MF_STRING, menu_id, name );
+ }
+
+ // g_hash_table_insert( popup_callback_hash, GINT_TO_POINTER( menu_id ), (gpointer)cb );
#if HAVE_GLIB
- g_array_append_val( popup_menu_array, ret );
+ g_array_append_val( popup_menu_array, ret );
#endif
- ret->cb = cb;
+ ret->cb = cb;
- menu_id++;
+ menu_id++;
- return ret;
+ return ret;
}
-static void set_toggle(struct menu_priv *menu, int active)
-{
- // gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
+static void set_toggle(struct menu_priv *menu, int active) {
+ // gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(menu->action), active);
}
-static int get_toggle(struct menu_priv *menu)
-{
- // return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
- return 0;
+static int get_toggle(struct menu_priv *menu) {
+ // return gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(menu->action));
+ return 0;
}
static struct menu_methods menu_methods = {
- add_menu,
- set_toggle,
- get_toggle,
+ add_menu,
+ set_toggle,
+ get_toggle,
};
-static void popup_activate(struct menu_priv *menu)
-{
- POINT pnt;
- GetCursorPos( &pnt );
+static void popup_activate(struct menu_priv *menu) {
+ POINT pnt;
+ GetCursorPos( &pnt );
- if (menu->hMenu)
- {
- TrackPopupMenu( menu->hMenu, 0, pnt.x, pnt.y, 0, menu->wnd_handle, NULL );
- DestroyMenu( menu->hMenu );
- }
+ if (menu->hMenu) {
+ TrackPopupMenu( menu->hMenu, 0, pnt.x, pnt.y, 0, menu->wnd_handle, NULL );
+ DestroyMenu( menu->hMenu );
+ }
}
-static void popup_deactivate( struct menu_priv *menu )
-{
- DestroyMenu( menu->hMenu );
+static void popup_deactivate( struct menu_priv *menu ) {
+ DestroyMenu( menu->hMenu );
}
-static struct menu_priv* win32_gui_popup_new(struct gui_priv *this_, struct menu_methods *meth)
-{
- struct menu_priv* ret = NULL;
+static struct menu_priv* win32_gui_popup_new(struct gui_priv *this_, struct menu_methods *meth) {
+ struct menu_priv* ret = NULL;
- ret = g_new0(struct menu_priv, 1);
- *meth = menu_methods;
+ ret = g_new0(struct menu_priv, 1);
+ *meth = menu_methods;
- menu_id = POPUP_MENU_OFFSET;
+ menu_id = POPUP_MENU_OFFSET;
#if HAVE_GLIB
- if ( popup_menu_array )
- {
- g_array_free (popup_menu_array, TRUE);
- popup_menu_array = NULL;
- }
+ if ( popup_menu_array ) {
+ g_array_free (popup_menu_array, TRUE);
+ popup_menu_array = NULL;
+ }
- popup_menu_array = g_array_new (FALSE, FALSE, sizeof (gint));
+ popup_menu_array = g_array_new (FALSE, FALSE, sizeof (gint));
#endif
- ret->cb = NULL;
- ret->hMenu = CreatePopupMenu();
- ret->wnd_handle = this_->hwnd;
- meth->popup=popup_activate;
+ ret->cb = NULL;
+ ret->hMenu = CreatePopupMenu();
+ ret->wnd_handle = this_->hwnd;
+ meth->popup=popup_activate;
-printf( "create popup menu %d \n", ret->hMenu );
+ printf( "create popup menu %d \n", ret->hMenu );
- return ret;
+ return ret;
}
struct gui_methods win32_gui_methods = {
- NULL, // win32_gui_menubar_new,
- win32_gui_popup_new,
- win32_gui_set_graphics,
- NULL,
- NULL, // win32_gui_datawindow_new,
- win32_gui_add_bookmark,
+ NULL, // win32_gui_menubar_new,
+ win32_gui_popup_new,
+ win32_gui_set_graphics,
+ NULL,
+ NULL, // win32_gui_datawindow_new,
+ win32_gui_add_bookmark,
};
-static struct gui_priv *win32_gui_new( struct navit *nav, struct gui_methods *meth, struct attr **attrs)
-{
- struct gui_priv *this_;
+static struct gui_priv *win32_gui_new( struct navit *nav, struct gui_methods *meth, struct attr **attrs) {
+ struct gui_priv *this_;
#ifdef HAVE_API_WIN32_CE
- /* Do not run multiple instances under CE */
- HWND prev;
- prev = FindWindow(g_szClassName, NULL);
- if (prev) {
- ShowWindow(prev, SW_RESTORE);
- SetForegroundWindow(prev);
- InvalidateRect (prev, NULL, FALSE);
- exit(0);
- }
- InitCeGlue();
+ /* Do not run multiple instances under CE */
+ HWND prev;
+ prev = FindWindow(g_szClassName, NULL);
+ if (prev) {
+ ShowWindow(prev, SW_RESTORE);
+ SetForegroundWindow(prev);
+ InvalidateRect (prev, NULL, FALSE);
+ exit(0);
+ }
+ InitCeGlue();
#endif
- *meth=win32_gui_methods;
+ *meth=win32_gui_methods;
- this_=g_new0(struct gui_priv, 1);
- this_->nav=nav;
+ this_=g_new0(struct gui_priv, 1);
+ this_->nav=nav;
- this_->hwnd = CreateWin32Window();
- SetWindowLongPtr( this_->hwnd , DWLP_USER, (LONG_PTR)this_ );
+ this_->hwnd = CreateWin32Window();
+ SetWindowLongPtr( this_->hwnd, DWLP_USER, (LONG_PTR)this_ );
- return this_;
+ return this_;
}
-void plugin_init(void)
-{
- plugin_register_category_gui("win32", win32_gui_new);
+void plugin_init(void) {
+ plugin_register_category_gui("win32", win32_gui_new);
}
diff --git a/navit/gui/win32/win32_gui_destination.c b/navit/gui/win32/win32_gui_destination.c
index 115b9058b..82ff2c713 100644
--- a/navit/gui/win32/win32_gui_destination.c
+++ b/navit/gui/win32/win32_gui_destination.c
@@ -13,8 +13,7 @@
static const TCHAR g_szDestinationClassName[] = TEXT("navit_gui_destinationwindow_class");
-struct datawindow_priv
-{
+struct datawindow_priv {
HWND hwnd;
HWND hwndLabel;
HWND hwndEdit;
@@ -27,8 +26,7 @@ struct datawindow_priv
struct notify_priv *notifications;
};
-static void setlayout(struct datawindow_priv *datawindow)
-{
+static void setlayout(struct datawindow_priv *datawindow) {
LVCOLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
@@ -39,22 +37,18 @@ static void setlayout(struct datawindow_priv *datawindow)
lvc.cx = (winrect.right - winrect.left) - 52 ;
lvc.fmt = LVCFMT_LEFT; // left-aligned column
- switch (datawindow->currentSearchState)
- {
- case attr_country_name:
- {
+ switch (datawindow->currentSearchState) {
+ case attr_country_name: {
Edit_SetText(datawindow->hwndLabel, TEXT("Country"));
lvc.pszText = TEXT("Country");
}
break;
- case attr_town_name:
- {
+ case attr_town_name: {
Edit_SetText(datawindow->hwndLabel, TEXT("Postal or Town"));
lvc.pszText = TEXT("Town");
}
break;
- case attr_street_name:
- {
+ case attr_street_name: {
Edit_SetText(datawindow->hwndLabel, TEXT("Street"));
lvc.pszText = TEXT("Street");
}
@@ -70,16 +64,14 @@ static void setlayout(struct datawindow_priv *datawindow)
SetFocus(datawindow->hwndEdit);
}
-static void notify_apply(struct datawindow_priv *datawindow, int index, int param2)
-{
+static void notify_apply(struct datawindow_priv *datawindow, int index, int param2) {
TCHAR txtBuffer[1024];
char search_string[1024];
struct attr search_attr;
struct search_list_result *res;
-
- if ( index >= 0 )
- {
+
+ if ( index >= 0 ) {
ListView_GetItemText(datawindow->hwndList, index, 1, txtBuffer, 1024);
TCHAR_TO_UTF8(txtBuffer, search_string);
@@ -91,20 +83,16 @@ static void notify_apply(struct datawindow_priv *datawindow, int index, int para
res=search_list_get_result(datawindow->sl);
}
- switch (datawindow->currentSearchState)
- {
- case attr_country_name:
- {
+ switch (datawindow->currentSearchState) {
+ case attr_country_name: {
datawindow->currentSearchState = attr_town_name;
}
break;
- case attr_town_name:
- {
+ case attr_town_name: {
datawindow->currentSearchState = attr_street_name;
}
break;
- case attr_street_name:
- {
+ case attr_street_name: {
navit_set_destination(datawindow->nav, res->c, "Mein Test", 1);
DestroyWindow(datawindow->hwnd);
}
@@ -118,19 +106,15 @@ static void notify_apply(struct datawindow_priv *datawindow, int index, int para
}
-static void notify_back(struct datawindow_priv *datawindow, int param1, int param2)
-{
- switch (datawindow->currentSearchState)
- {
+static void notify_back(struct datawindow_priv *datawindow, int param1, int param2) {
+ switch (datawindow->currentSearchState) {
case attr_country_name:
- break;
- case attr_town_name:
- {
+ break;
+ case attr_town_name: {
datawindow->currentSearchState = attr_country_name;
}
break;
- case attr_street_name:
- {
+ case attr_street_name: {
datawindow->currentSearchState = attr_town_name;
}
break;
@@ -142,14 +126,13 @@ static void notify_back(struct datawindow_priv *datawindow, int param1, int para
setlayout(datawindow);
}
-static void notify_textchange(struct datawindow_priv *datawindow, int param1, int param2)
-{
+static void notify_textchange(struct datawindow_priv *datawindow, int param1, int param2) {
struct attr search_attr;
struct search_list_result *res;
char search_string[1024];
TCHAR converted_iso2[32];
-
+
int lineLength = Edit_LineLength(datawindow->hwndEdit, 0);
TCHAR line[lineLength + 1];
@@ -178,11 +161,9 @@ static void notify_textchange(struct datawindow_priv *datawindow, int param1, in
lvI.state = 0;
lvI.stateMask = 0;
- while ((res=search_list_get_result(datawindow->sl)) && listIndex < 50)
- {
+ while ((res=search_list_get_result(datawindow->sl)) && listIndex < 50) {
- switch (search_attr.type)
- {
+ switch (search_attr.type) {
case attr_country_name:
tcharBuffer = newSysString(res->country->name);
break;
@@ -190,12 +171,9 @@ static void notify_textchange(struct datawindow_priv *datawindow, int param1, in
tcharBuffer = newSysString(res->town->common.town_name);
break;
case attr_street_name:
- if (res->street->name)
- {
+ if (res->street->name) {
tcharBuffer = newSysString(res->street->name);
- }
- else
- {
+ } else {
continue;
}
break;
@@ -212,24 +190,20 @@ static void notify_textchange(struct datawindow_priv *datawindow, int param1, in
(void)ListView_InsertItem(datawindow->hwndList, &lvI);
ListView_SetItemText(datawindow->hwndList, listIndex, 1, tcharBuffer);
g_free(tcharBuffer);
- dbg(lvl_debug,"%s\n", res->country->name);
+ dbg(lvl_debug,"%s", res->country->name);
listIndex++;
}
}
-static void notify_destroy(struct datawindow_priv *datawindow, int param1, int param2)
-{
- if ( datawindow )
- {
+static void notify_destroy(struct datawindow_priv *datawindow, int param1, int param2) {
+ if ( datawindow ) {
search_list_destroy(datawindow->sl);
g_free(datawindow);
}
}
-static void notify_size(struct datawindow_priv *datawindow, int width, int height)
-{
- if (datawindow)
- {
+static void notify_size(struct datawindow_priv *datawindow, int width, int height) {
+ if (datawindow) {
MoveWindow(datawindow->hwndLabel,
0, 0, // starting x- and y-coordinates
width, // width of client area
@@ -261,8 +235,7 @@ static void notify_size(struct datawindow_priv *datawindow, int width, int heigh
}
}
-static BOOL init_lv_columns(HWND hWndListView)
-{
+static BOOL init_lv_columns(HWND hWndListView) {
// struct LVCOLUMN lvc = {LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM,
// LVCFMT_LEFT, 100, szText[iCol], 0, iCol, 0, 0 };
@@ -273,8 +246,7 @@ static BOOL init_lv_columns(HWND hWndListView)
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- for (iCol = 0; iCol < 2; iCol++)
- {
+ for (iCol = 0; iCol < 2; iCol++) {
lvc.iSubItem = iCol;
lvc.pszText = szText[iCol];
lvc.cx = 50; // width of column in pixels
@@ -290,8 +262,7 @@ static BOOL init_lv_columns(HWND hWndListView)
return TRUE;
}
-BOOL register_destination_window()
-{
+BOOL register_destination_window() {
WNDCLASS wc;
wc.style = 0;
@@ -305,16 +276,14 @@ BOOL register_destination_window()
wc.lpszClassName = g_szDestinationClassName;
wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_NAVIT));
- if (!RegisterClass(&wc))
- {
- dbg(lvl_error, "Window Registration Failed!\n");
+ if (!RegisterClass(&wc)) {
+ dbg(lvl_error, "Window Registration Failed!");
return FALSE;
}
return TRUE;
}
-HANDLE create_destination_window( struct navit *nav )
-{
+HANDLE create_destination_window( struct navit *nav ) {
struct datawindow_priv *this_;
@@ -337,18 +306,17 @@ HANDLE create_destination_window( struct navit *nav )
#endif
NULL, NULL, NULL, NULL);
- if (this_->hwnd == NULL)
- {
- dbg(lvl_error, "Window Creation Failed!\n");
+ if (this_->hwnd == NULL) {
+ dbg(lvl_error, "Window Creation Failed!");
return 0;
}
this_->notifications = win32_gui_notify_new(this_);
- SetWindowLongPtr( this_->hwnd , DWLP_USER, (LONG_PTR) this_->notifications );
+ SetWindowLongPtr( this_->hwnd, DWLP_USER, (LONG_PTR) this_->notifications );
this_->hwndLabel = CreateWindow(WC_STATIC, // predefined class
TEXT("Country"), // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ WS_CHILD | WS_VISIBLE | ES_LEFT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
0, 0, 0, 0, // set size in WM_SIZE message
this_->hwnd, // parent window
NULL,//(HMENU) ID_EDITCHILD, // edit control ID
@@ -357,7 +325,7 @@ HANDLE create_destination_window( struct navit *nav )
this_->hwndEdit = CreateWindow(WC_EDIT, // predefined class
NULL, // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
0, 0, 0, 0, // set size in WM_SIZE message
this_->hwnd, // parent window
NULL,//(HMENU) ID_EDITCHILD, // edit control ID
@@ -366,7 +334,7 @@ HANDLE create_destination_window( struct navit *nav )
this_->hwndList = CreateWindow(WC_LISTVIEW, // predefined class
NULL, // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
0, 0, 0, 0, // set size in WM_SIZE message
this_->hwnd, // parent window
NULL,//(HMENU) ID_EDITCHILD, // edit control ID
@@ -374,21 +342,21 @@ HANDLE create_destination_window( struct navit *nav )
NULL); // pointer not needed
this_->hwndButtonPrev = CreateWindow(WC_BUTTON, // predefined class
- TEXT("<<"), // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
- 0, 0, 0, 0, // set size in WM_SIZE message
- this_->hwnd, // parent window
- NULL,//(HMENU) ID_EDITCHILD, // edit control ID
- (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
- NULL); // pointer not needed
+ TEXT("<<"), // no window title
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ 0, 0, 0, 0, // set size in WM_SIZE message
+ this_->hwnd, // parent window
+ NULL,//(HMENU) ID_EDITCHILD, // edit control ID
+ (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
+ NULL); // pointer not needed
this_->hwndButtonNext = CreateWindow(WC_BUTTON, // predefined class
- TEXT(">>"), // no window title
- WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT , //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
- 0, 0, 0, 0, // set size in WM_SIZE message
- this_->hwnd, // parent window
- NULL,//(HMENU) ID_EDITCHILD, // edit control ID
- (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
- NULL); // pointer not needed
+ TEXT(">>"), // no window title
+ WS_CHILD | WS_VISIBLE | ES_LEFT | WS_BORDER | LVS_REPORT, //| WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL
+ 0, 0, 0, 0, // set size in WM_SIZE message
+ this_->hwnd, // parent window
+ NULL,//(HMENU) ID_EDITCHILD, // edit control ID
+ (HINSTANCE) GetWindowLong(this_->hwnd, GWL_HINSTANCE),
+ NULL); // pointer not needed
#ifdef LVS_EX_FULLROWSELECT
(void)ListView_SetExtendedListViewStyle(this_->hwndList,LVS_EX_FULLROWSELECT);
#endif
diff --git a/navit/gui/win32/win32_gui_notify.c b/navit/gui/win32/win32_gui_notify.c
index c801e9da8..222a7a5a9 100644
--- a/navit/gui/win32/win32_gui_notify.c
+++ b/navit/gui/win32/win32_gui_notify.c
@@ -4,23 +4,21 @@
#include <glib.h>
#include "win32_gui_notify.h"
-struct window_data
-{
+struct window_data {
HWND hwnd;
UINT message;
void(*func)(struct datawindow_priv *parent, int param1, int param2);
};
-struct notify_priv
-{
+struct notify_priv {
GList *window_list;
struct datawindow_priv *parent;
};
-void win32_gui_notify(struct notify_priv* notify, HWND hwnd, int message_id, void(*func)(struct datawindow_priv *parent, int param1, int param2))
-{
+void win32_gui_notify(struct notify_priv* notify, HWND hwnd, int message_id, void(*func)(struct datawindow_priv *parent,
+ int param1, int param2)) {
struct window_data *wnd_data = g_new( struct window_data,1);
wnd_data->hwnd = hwnd;
@@ -31,97 +29,81 @@ void win32_gui_notify(struct notify_priv* notify, HWND hwnd, int message_id, voi
}
-struct notify_priv* win32_gui_notify_new(struct datawindow_priv *parent)
-{
+struct notify_priv* win32_gui_notify_new(struct datawindow_priv *parent) {
struct notify_priv* notify = g_new0(struct notify_priv,1);
notify->parent = parent;
return notify;
}
-LRESULT CALLBACK message_handler(HWND hwnd, UINT win_message, WPARAM wParam, LPARAM lParam)
-{
+LRESULT CALLBACK message_handler(HWND hwnd, UINT win_message, WPARAM wParam, LPARAM lParam) {
enum message_id message = INVALID;
int param1 = -1;
int param2 = -1;
HWND hwndDlg = hwnd;
- switch (win_message)
- {
- case WM_CREATE:
- {
- message = WINDOW_CREATE;
+ switch (win_message) {
+ case WM_CREATE: {
+ message = WINDOW_CREATE;
+ }
+ break;
+ case WM_SIZE: {
+ message = WINDOW_SIZE;
+ param1 = LOWORD(lParam);
+ param2 = HIWORD(lParam);
+ }
+ break;
+ case WM_DESTROY: {
+ message = WINDOW_DESTROY;
+ }
+ break;
+ case WM_NOTIFY: {
+ hwndDlg = (((LPNMHDR)lParam)->hwndFrom);
+ switch (((LPNMHDR)lParam)->code) {
+ case NM_DBLCLK: {
+ message = DBLCLICK;
+#ifdef LPNMITEMACTIVATE
+ param1 = ((LPNMITEMACTIVATE)lParam)->iItem;
+#endif
}
break;
- case WM_SIZE:
- {
- message = WINDOW_SIZE;
- param1 = LOWORD(lParam);
- param2 = HIWORD(lParam);
+ case NM_CLICK:
+ message = CLICK;
+ break;
}
- break;
- case WM_DESTROY:
- {
- message = WINDOW_DESTROY;
+ }
+ break;
+ case WM_COMMAND: {
+ hwndDlg = (HWND)lParam;
+
+ switch (HIWORD(wParam)) {
+ case EN_CHANGE: {
+ message = CHANGE;
}
break;
- case WM_NOTIFY:
- {
- hwndDlg = (((LPNMHDR)lParam)->hwndFrom);
- switch (((LPNMHDR)lParam)->code)
- {
- case NM_DBLCLK:
- {
- message = DBLCLICK;
-#ifdef LPNMITEMACTIVATE
- param1 = ((LPNMITEMACTIVATE)lParam)->iItem;
-#endif
- }
- break;
- case NM_CLICK:
- message = CLICK;
- break;
- }
+ case BN_CLICKED: {
+ message = BUTTON_CLICK;
}
break;
- case WM_COMMAND:
- {
- hwndDlg = (HWND)lParam;
-
- switch (HIWORD(wParam))
- {
- case EN_CHANGE:
- {
- message = CHANGE;
- }
- break;
- case BN_CLICKED:
- {
- message = BUTTON_CLICK;
- }
- break;
- }
}
- break;
+ }
+ break;
- default:
- return DefWindowProc(hwnd, win_message, wParam, lParam);
+ default:
+ return DefWindowProc(hwnd, win_message, wParam, lParam);
}
- struct notify_priv* notify_data = (struct notify_priv*)GetWindowLongPtr( hwnd , DWLP_USER );
+ struct notify_priv* notify_data = (struct notify_priv*)GetWindowLongPtr( hwnd, DWLP_USER );
- if ( message != INVALID && notify_data && notify_data->window_list )
- {
+ if ( message != INVALID && notify_data && notify_data->window_list ) {
GList* current_element = g_list_first(notify_data->window_list);
struct window_data* wnd_data = NULL;
- while (current_element != NULL)
- {
+ while (current_element != NULL) {
wnd_data = current_element->data;
- if ( (wnd_data->hwnd == hwndDlg || wnd_data->hwnd == NULL) && message == wnd_data->message)
- {
+ if ( (wnd_data->hwnd == hwndDlg || wnd_data->hwnd == NULL) && message == wnd_data->message) {
wnd_data->func(notify_data->parent, param1, param2);
}
diff --git a/navit/icons/CMakeLists.txt b/navit/icons/CMakeLists.txt
index 6d40f2a92..9817aa25e 100644
--- a/navit/icons/CMakeLists.txt
+++ b/navit/icons/CMakeLists.txt
@@ -1,73 +1,74 @@
macro(convert_to_png IMAGE_INPUT IMAGE_OUTPUT SCALE)
- get_filename_component(FILE_EXT ${IMAGE_INPUT} EXT)
- string(TOUPPER ${FILE_EXT} FILE_TYPE)
- string(REGEX REPLACE "^\\." "" FILE_TYPE ${FILE_TYPE})
- if(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "rsvg-convert")
- if (${SCALE} GREATER 0)
- set(SCALE_ARGS --width=${SCALE} --height=${SCALE})
- else()
- set(SCALE_ARGS)
- endif()
- set(COMMAND_ARGS ${SCALE_ARGS} --output ${IMAGE_OUTPUT} ${IMAGE_INPUT})
- elseif(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "convert")
- if (${SCALE} GREATER 0)
- set(SCALE_ARGS -resize ${SCALE}x${SCALE})
- else()
- set(SCALE_ARGS)
- endif()
- set(COMMAND_ARGS -background none ${IMAGE_INPUT} ${SCALE_ARGS} ${IMAGE_OUTPUT})
- elseif(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "ksvgtopng")
- set (NEW_SCALE ${SCALE})
- if (${SCALE} EQUAL 0)
- file(STRINGS ${IMAGE_INPUT} NEW_SCALE_LINE REGEX "[^-]width=\"[0-9pxt.]*\"")
- string(REGEX REPLACE ".*width=\"([0-9]*).*" "\\1" NEW_SCALE ${NEW_SCALE_LINE})
- endif()
- set(COMMAND_ARGS ${NEW_SCALE} ${NEW_SCALE} ${IMAGE_INPUT} ${IMAGE_OUTPUT})
- elseif(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "inkscape")
- if (${SCALE} GREATER 0)
- set(SCALE_ARGS --export-width=${SCALE} --export-height=${SCALE})
- else()
- set(SCALE_ARGS)
- endif()
- set(COMMAND_ARGS --without-gui --export-background-opacity=0 --export-png ${IMAGE_OUTPUT} ${SCALE_ARGS} ${IMAGE_INPUT})
- else()
- message(FATAL_ERROR "no svg2png converter defined here.")
- endif()
+ get_filename_component(FILE_EXT ${IMAGE_INPUT} EXT)
+ string(TOUPPER ${FILE_EXT} FILE_TYPE)
+ string(REGEX REPLACE "^\\." "" FILE_TYPE ${FILE_TYPE})
+ if(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "rsvg-convert")
+ if (${SCALE} GREATER 0)
+ set(SCALE_ARGS --width=${SCALE} --height=${SCALE})
+ else()
+ set(SCALE_ARGS)
+ endif()
+ set(COMMAND_ARGS ${SCALE_ARGS} --output ${IMAGE_OUTPUT} ${IMAGE_INPUT})
+ elseif(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "convert")
+ if (${SCALE} GREATER 0)
+ set(SCALE_ARGS -resize ${SCALE}x${SCALE})
+ else()
+ set(SCALE_ARGS)
+ endif()
+ set(COMMAND_ARGS -background none ${IMAGE_INPUT} ${SCALE_ARGS} ${IMAGE_OUTPUT})
+ elseif(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "ksvgtopng")
+ set (NEW_SCALE ${SCALE})
+ if (${SCALE} EQUAL 0)
+ file(STRINGS ${IMAGE_INPUT} NEW_SCALE_LINE REGEX "[^-]width=\"[0-9pxt.]*\"")
+ string(REGEX MATCH "width=\"([0-9]*)[pxt]*\"" NEW_SCALE_LINE ${NEW_SCALE_LINE})
+ set(NEW_SCALE ${CMAKE_MATCH_1})
+ endif()
+ set(COMMAND_ARGS ${NEW_SCALE} ${NEW_SCALE} ${IMAGE_INPUT} ${IMAGE_OUTPUT})
+ elseif(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "inkscape")
+ if (${SCALE} GREATER 0)
+ set(SCALE_ARGS --export-width=${SCALE} --export-height=${SCALE})
+ else()
+ set(SCALE_ARGS)
+ endif()
+ set(COMMAND_ARGS --without-gui --export-background-opacity=0 --export-png ${IMAGE_OUTPUT} ${SCALE_ARGS} ${IMAGE_INPUT})
+ else()
+ message(FATAL_ERROR "no svg2png converter defined here.")
+ endif()
- add_custom_command (
- OUTPUT ${IMAGE_OUTPUT}
- DEPENDS ${IMAGE_INPUT}
- COMMAND ${IMAGE_CONVERTER_${FILE_TYPE}} ${COMMAND_ARGS}
- )
+ add_custom_command (
+ OUTPUT ${IMAGE_OUTPUT}
+ DEPENDS ${IMAGE_INPUT}
+ COMMAND ${IMAGE_CONVERTER_${FILE_TYPE}} ${COMMAND_ARGS}
+ )
endmacro()
macro(add_scale_targets IMAGE_SRC IMAGE_NAME)
- string(REPLACE "," ";" SCALES "${ARGN}")
- set(add_scale_targets_is_first_scale 1)
- foreach (CURRENT_SCALE ${SCALES})
- if(add_scale_targets_is_first_scale EQUAL 1)
- set (IMAGE_DST ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_NAME}.png)
- set(add_scale_targets_is_first_scale 0)
- elseif (${CURRENT_SCALE} EQUAL 0)
- set (IMAGE_DST ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_NAME}.png)
- message_error( "Image size value of 0 to leave image unscaled can only be given as the first value in row, e.g. -D svg2png_scaling=0,16,32 " )
- else()
- set (IMAGE_DST ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_NAME}_${CURRENT_SCALE}_${CURRENT_SCALE}.png)
- endif()
-
- if(NOT CURRENT_SCALE EQUAL -1)
- convert_to_png(
- ${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_SRC}
- ${IMAGE_DST}
- ${CURRENT_SCALE}
- )
- list(APPEND IMAGE_TARGETS ${IMAGE_DST})
- endif()
- endforeach()
+ string(REPLACE "," ";" SCALES "${ARGN}")
+ set(add_scale_targets_is_first_scale 1)
+ foreach (CURRENT_SCALE ${SCALES})
+ if(add_scale_targets_is_first_scale EQUAL 1)
+ set (IMAGE_DST ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_NAME}.png)
+ set(add_scale_targets_is_first_scale 0)
+ elseif (${CURRENT_SCALE} EQUAL 0)
+ set (IMAGE_DST ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_NAME}.png)
+ message_error( "Image size value of 0 to leave image unscaled can only be given as the first value in row, e.g. -D svg2png_scaling=0,16,32 " )
+ else()
+ set (IMAGE_DST ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_NAME}_${CURRENT_SCALE}_${CURRENT_SCALE}.png)
+ endif()
+
+ if(NOT CURRENT_SCALE EQUAL -1)
+ convert_to_png(
+ ${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_SRC}
+ ${IMAGE_DST}
+ ${CURRENT_SCALE}
+ )
+ list(APPEND IMAGE_TARGETS ${IMAGE_DST})
+ endif()
+ endforeach()
endmacro()
if(NOT DEFINED NAVIT_BINARY)
- set(NAVIT_BINARY navit CACHE STRING "Navit binary name not defined")
+ set(NAVIT_BINARY navit CACHE STRING "Navit binary name not defined")
endif()
#patch binary name in desktop file
configure_file(desktop_icons/navit.desktop.in desktop_icons/${PACKAGE}.desktop)
@@ -80,59 +81,59 @@ install(FILES desktop_icons/256x256/navit.png DESTINATION share/icons/hicolor/2
#install(FILES bench.xpm DESTINATION )
if (USE_SVG OR SVG2PNG)
- FILE(GLOB SVG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.svg" "*.svgz")
-
- if(USE_SVG)
- list(APPEND IMAGES_TO_COPY ${SVG_FILES})
- endif(USE_SVG)
- if(SVG2PNG)
- list(APPEND FILES_TO_PNG ${SVG_FILES})
- endif(SVG2PNG)
+ FILE(GLOB SVG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.svg" "*.svgz")
+
+ if(USE_SVG)
+ list(APPEND IMAGES_TO_COPY ${SVG_FILES})
+ endif(USE_SVG)
+ if(SVG2PNG)
+ list(APPEND FILES_TO_PNG ${SVG_FILES})
+ endif(SVG2PNG)
endif()
FILE(GLOB XPM_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.xpm")
if(XPM2PNG)
- foreach (IMAGE_SRC ${SVG_FILES})
- string(REGEX REPLACE ".[a-z]*\$" "" IMAGE ${IMAGE_SRC})
- list(APPEND SVG_FILES_BASENAMES ${IMAGE})
- endforeach()
- foreach (IMAGE_SRC ${XPM_FILES})
- string(REGEX REPLACE ".[a-z]*\$" "" IMAGE ${IMAGE_SRC})
- list(FIND SVG_FILES_BASENAMES ${IMAGE} DUP_IMG)
- if ( ${DUP_IMG} LESS 0 )
- list(APPEND FILES_TO_PNG ${IMAGE_SRC})
- else()
- message(STATUS "image '${IMAGE}': XPM version skipped in favor of SVG")
- endif()
- endforeach()
+ foreach (IMAGE_SRC ${SVG_FILES})
+ string(REGEX REPLACE ".[a-z]*\$" "" IMAGE ${IMAGE_SRC})
+ list(APPEND SVG_FILES_BASENAMES ${IMAGE})
+ endforeach()
+ foreach (IMAGE_SRC ${XPM_FILES})
+ string(REGEX REPLACE ".[a-z]*\$" "" IMAGE ${IMAGE_SRC})
+ list(FIND SVG_FILES_BASENAMES ${IMAGE} DUP_IMG)
+ if ( ${DUP_IMG} LESS 0 )
+ list(APPEND FILES_TO_PNG ${IMAGE_SRC})
+ else()
+ message(STATUS "image '${IMAGE}': XPM version skipped in favor of SVG")
+ endif()
+ endforeach()
else()
- list(APPEND IMAGES_TO_COPY ${XPM_FILES})
+ list(APPEND IMAGES_TO_COPY ${XPM_FILES})
endif(XPM2PNG)
foreach (IMAGE_SRC ${FILES_TO_PNG})
- string(REGEX REPLACE ".[a-z]*\$" "" IMAGE ${IMAGE_SRC})
-
- if ( IMAGE_SRC MATCHES ".*svgz*" )
- if ( DEFINED svg2png_scaling_nav AND ${IMAGE} MATCHES "^nav_")
- add_scale_targets(${IMAGE_SRC} ${IMAGE} ${svg2png_scaling_nav})
- elseif( DEFINED svg2png_scaling_flag AND ${IMAGE} MATCHES "^country_")
- add_scale_targets(${IMAGE_SRC} ${IMAGE} ${svg2png_scaling_flag})
- elseif( DEFINED svg2png_scaling)
- add_scale_targets(${IMAGE_SRC} ${IMAGE} ${svg2png_scaling})
- endif()
- else()
- add_scale_targets(${IMAGE_SRC} ${IMAGE} 0)
- endif()
-
+ string(REGEX REPLACE ".[a-z]*\$" "" IMAGE ${IMAGE_SRC})
+
+ if ( IMAGE_SRC MATCHES ".*svgz*" )
+ if ( DEFINED svg2png_scaling_nav AND ${IMAGE} MATCHES "^nav_")
+ add_scale_targets(${IMAGE_SRC} ${IMAGE} ${svg2png_scaling_nav})
+ elseif( DEFINED svg2png_scaling_flag AND ${IMAGE} MATCHES "^country_")
+ add_scale_targets(${IMAGE_SRC} ${IMAGE} ${svg2png_scaling_flag})
+ elseif( DEFINED svg2png_scaling)
+ add_scale_targets(${IMAGE_SRC} ${IMAGE} ${svg2png_scaling})
+ endif()
+ else()
+ add_scale_targets(${IMAGE_SRC} ${IMAGE} 0)
+ endif()
+
endforeach()
foreach (IMAGE_FILE ${IMAGES_TO_COPY})
- add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_FILE}"
- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_FILE}"
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_FILE}"
- "${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_FILE}"
- )
- list(APPEND IMAGE_TARGETS "${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_FILE}")
+ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_FILE}"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_FILE}"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_FILE}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_FILE}"
+ )
+ list(APPEND IMAGE_TARGETS "${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_FILE}")
endforeach()
add_custom_target(images ALL DEPENDS ${IMAGE_TARGETS})
@@ -140,7 +141,7 @@ add_custom_target(images_resource COMMAND mkdir -p ../resources/share/navit/xpm
add_dependencies(images_resource images)
install(
- FILES ${IMAGE_TARGETS}
- DESTINATION ${IMAGE_DIR}
- PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-)
+ FILES ${IMAGE_TARGETS}
+ DESTINATION ${IMAGE_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+ )
diff --git a/navit/icons/car_wash.svg b/navit/icons/car_wash.svg
index 2c17087f6..ff2fd30e5 100644
--- a/navit/icons/car_wash.svg
+++ b/navit/icons/car_wash.svg
@@ -9,14 +9,16 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- height="22"
+ height="200"
id="svg2"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="car_wash.svg"
sodipodi:version="0.32"
version="1.0"
- width="22">
+ width="200"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96">
<defs
id="defs22">
<inkscape:perspective
@@ -49,15 +51,15 @@
guidetolerance="10.0"
id="base"
inkscape:current-layer="svg2"
- inkscape:cx="19.318319"
- inkscape:cy="15.792438"
+ inkscape:cx="1"
+ inkscape:cy="14"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:window-height="705"
inkscape:window-width="1366"
inkscape:window-x="-8"
inkscape:window-y="-8"
- inkscape:zoom="16.78664"
+ inkscape:zoom="1"
objecttolerance="10.0"
pagecolor="#ffffff"
showgrid="false"
@@ -66,16 +68,16 @@
inkscape:measure-end="0,0" />
<g
id="g1327"
- transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,-1.0602338)">
+ transform="matrix(0.33570938,0,0,0.33570938,-0.1767767,5.6565586)">
<path
- d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 l 0,450.123 c 0,40.844 20.894,62.229 62.192,62.229 l 452.024,0 c 41.307,0 62.229,-20.316 62.229,-62.229 l 0,-450.123 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
+ d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 v 450.123 c 0,40.844 20.894,62.229 62.192,62.229 H 515.92 c 41.307,0 62.229,-20.316 62.229,-62.229 V 66.804 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
id="path1329"
style="fill:#111111;fill-opacity:0;stroke:#eeeeee;stroke-width:3.40799999;stroke-opacity:0"
inkscape:connector-curvature="0" />
</g>
<g
id="g2319"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2323"
@@ -84,7 +86,7 @@
</g>
<g
id="g2325"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2329"
@@ -92,43 +94,43 @@
inkscape:connector-curvature="0" />
</g>
<path
- d="m 8.6250917,8.7062005 c -0.9707376,0 -1.4856922,0.5299594 -1.7234264,1.150296 L 5.6397034,13.114997 C 5.1394385,13.179143 4.252621,13.766362 4.252621,14.878783 l 0,4.143757 1.228328,0 0,1.325194 c 0,1.630379 2.307318,1.611179 2.3073187,0 l 0,-1.325194 4.1504833,0 0.0013,0 4.150481,0 0,1.325194 c 0,1.611179 2.307307,1.630379 2.307321,0 l 0,-1.325194 1.228326,0 0,-4.143757 c 0,-1.11242 -0.886811,-1.699639 -1.387085,-1.763786 L 16.975831,9.8564965 C 16.738097,9.2361599 16.223146,8.7062005 15.252402,8.7062005 l -1.783964,0 -3.037862,0 -1.8054905,0 z m -0.0148,1.1866209 3.3257684,0 0.0027,0 0.0013,0 3.327111,0 c 0.41601,0.00392 0.594182,0.2640376 0.713049,0.6242546 l 0.951179,2.564285 -4.991339,0 -0.0013,0 -0.0027,0 -4.9899972,0 0.9511803,-2.564285 C 8.0161106,10.156859 8.1942372,9.8966951 8.6102916,9.8928214 z M 6.6716065,14.328524 c 0.5886503,0 1.0655371,0.491138 1.0655371,1.097826 -4e-7,0.606733 -0.4768868,1.099172 -1.0655371,1.099172 -0.5886073,0 -1.0655378,-0.492439 -1.0655378,-1.099172 0,-0.606687 0.4769305,-1.097826 1.0655378,-1.097826 z m 10.5356355,0 c 0.58865,0 1.06554,0.491139 1.065537,1.097826 0,0.606733 -0.476887,1.099172 -1.065537,1.099172 -0.588608,0 -1.066886,-0.492439 -1.066886,-1.099172 0,-0.606688 0.478278,-1.097826 1.066886,-1.097826 z"
+ d="m 72.114087,74.542193 c -9.296155,0 -14.227557,5.075099 -16.504191,11.015712 L 43.524867,116.76254 c -4.790728,0.61385 -13.283232,6.23768 -13.283232,16.89063 v 39.68224 h 11.762938 v 12.69052 c 0,15.61315 22.09576,15.42928 22.095767,0 v -12.69052 h 39.74662 0.0125 39.74658 v 12.69052 c 0,15.42928 22.09566,15.61315 22.0958,0 v -12.69052 h 11.76292 v -39.68224 c 0,-10.65295 -8.49244,-16.27639 -13.28327,-16.89063 L 152.08396,85.557905 c -2.27663,-5.940613 -7.208,-11.015712 -16.50421,-11.015712 H 118.49582 89.404094 72.114027 Z M 71.972355,85.90572 h 31.848825 0.0259 0.0124 31.86169 c 3.98387,0.03831 5.69011,2.528548 6.82843,5.978151 l 9.10885,24.556529 h -47.79897 -0.0124 -0.0259 -47.786116 l 9.108867,-24.556529 c 1.138319,-3.449603 2.844128,-5.940995 6.828424,-5.978151 z m -18.565589,42.47796 c 5.63714,0 10.20399,4.70334 10.20399,10.51324 -4e-6,5.81027 -4.56685,10.52607 -10.20399,10.52607 -5.636729,0 -10.203998,-4.7158 -10.203998,-10.52607 0,-5.8099 4.567269,-10.51324 10.203998,-10.51324 z m 100.893274,0 c 5.63714,0 10.20402,4.70334 10.20399,10.51324 0,5.81027 -4.56685,10.52607 -10.20399,10.52607 -5.63673,0 -10.21692,-4.7158 -10.21692,-10.52607 0,-5.8099 4.58019,-10.51324 10.21692,-10.51324 z"
id="path2301"
- style="fill:#0089cd;stroke:none"
+ style="fill:#0089cd;stroke:none;stroke-width:9.57638168"
inkscape:connector-curvature="0" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.64602429px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 11.932901,3.8702621 c 0.468232,0.00558 0.754143,-0.4345529 0.754143,-0.7483631 0,-0.6031582 -0.536638,-1.4794288 -0.754143,-1.9211706 -0.149172,0.3574271 -0.745857,1.3180124 -0.745857,1.9211706 0,0.2683029 0.277625,0.7427784 0.745857,0.7483631 z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.18657589px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 103.79093,28.231383 c 4.48397,0.05746 7.22197,-4.161418 7.22197,-7.166582 0,-5.776091 -5.13906,-14.1675881 -7.22197,-18.3978583 -1.42853,3.4227899 -7.14261,12.6217673 -7.14261,18.3978583 0,2.569344 2.65864,7.113145 7.14261,7.166582 z"
id="path833"
inkscape:connector-curvature="0"
sodipodi:nodetypes="zscsz" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.64602429px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 11.9329,7.3962952 c 0.468232,0.00558 0.754143,-0.4345529 0.754143,-0.7483631 0,-0.6031582 -0.536638,-1.4794288 -0.754143,-1.9211706 -0.149172,0.3574271 -0.745857,1.3180124 -0.745857,1.9211706 0,0.2683029 0.277625,0.7427784 0.745857,0.7483631 z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.18657589px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 103.79092,61.997994 c 4.48398,0.05746 7.22196,-4.161418 7.22196,-7.166582 0,-5.77609 -5.13905,-14.167587 -7.22196,-18.397858 -1.42852,3.422886 -7.14261,12.621768 -7.14261,18.397858 0,2.569344 2.65865,7.113145 7.14261,7.166582 z"
id="path833-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="zscsz" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.64602429px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 14.340396,3.8007984 C 14.790477,3.6715713 14.937829,3.1678357 14.847638,2.8672653 14.674288,2.2895546 13.908447,1.6044866 13.57316,1.2438939 c -0.04016,0.385219 -0.335589,1.4767665 -0.162235,2.054478 0.07711,0.2569829 0.479389,0.6316494 0.929471,0.5024265 z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.18657589px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 126.84602,27.566207 c 4.31015,-1.237556 5.72125,-6.061467 4.85755,-8.939937 -1.66006,-5.532371 -8.99405,-12.0927672 -12.20488,-15.5460114 -0.3846,3.6890146 -3.21374,14.1421144 -1.55364,19.6744864 0.73844,2.461035 4.59082,6.048922 8.90097,4.811462 z"
id="path833-3-0"
inkscape:connector-curvature="0"
sodipodi:nodetypes="zscsz" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.64602429px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 15.315677,7.2964848 C 15.757504,7.1413637 15.875383,6.6299279 15.767906,6.3350962 15.561332,5.7684156 14.757036,5.128932 14.401394,4.7883985 c -0.01774,0.3868997 -0.249348,1.4937484 -0.04277,2.0604297 0.09189,0.2520764 0.515228,0.6027736 0.957053,0.4476566 z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.18657589px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 136.18569,61.04227 c 4.2311,-1.485583 5.35995,-6.383232 4.33072,-9.206637 -1.97824,-5.426745 -9.68048,-11.550746 -13.08624,-14.811791 -0.16989,3.705102 -2.38786,14.304721 -0.40959,19.731466 0.87998,2.413918 4.93403,5.772356 9.16511,4.286962 z"
id="path833-3-0-1"
inkscape:connector-curvature="0"
sodipodi:nodetypes="zscsz" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.64602429px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 9.5336905,3.8007984 C 9.0836095,3.6715713 8.9362575,3.1678357 9.0264485,2.8672653 c 0.17335,-0.5777107 0.939191,-1.2627787 1.2744785,-1.6233714 0.04016,0.385219 0.335589,1.4767665 0.162235,2.054478 -0.07711,0.2569829 -0.4793895,0.6316494 -0.9294715,0.5024265 z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.18657589px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 80.815176,27.566207 C 76.505028,26.328651 75.093929,21.50474 75.957633,18.62627 77.617699,13.093899 84.951685,6.5335028 88.162526,3.0802586 c 0.384588,3.6890146 3.213729,14.1421144 1.553624,19.6744864 -0.738435,2.461035 -4.590817,6.048922 -8.900974,4.811462 z"
id="path833-3-0-0"
inkscape:connector-curvature="0"
sodipodi:nodetypes="zscsz" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.64602429px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 8.5584095,7.2964849 c -0.441827,-0.155121 -0.559706,-0.666557 -0.452229,-0.961389 0.206574,-0.5666804 1.01087,-1.206164 1.366512,-1.5466975 0.01774,0.3868997 0.249348,1.4937485 0.04277,2.0604295 -0.09189,0.252077 -0.515228,0.602774 -0.957053,0.447657 z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.18657589px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 71.475512,61.04227 c -4.231104,-1.485583 -5.359959,-6.383232 -4.330718,-9.206637 1.978232,-5.426745 9.680478,-11.550746 13.086242,-14.811791 0.169885,3.705102 2.387852,14.304721 0.409581,19.731466 -0.879973,2.413918 -4.934019,5.772356 -9.165105,4.286962 z"
id="path833-3-0-1-1"
inkscape:connector-curvature="0"
sodipodi:nodetypes="zscsz" />
diff --git a/navit/icons/communication.svg b/navit/icons/communication.svg
index bad45d89a..35596b3c7 100644
--- a/navit/icons/communication.svg
+++ b/navit/icons/communication.svg
@@ -9,14 +9,17 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- height="22"
+ height="200"
id="svg2"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="communication.svg"
sodipodi:version="0.32"
version="1.0"
- width="22">
+ width="200"
+ inkscape:export-filename="C:\Users\jeremy\Pictures\svg\communication.png"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96">
<defs
id="defs22">
<inkscape:perspective
@@ -49,7 +52,7 @@
guidetolerance="10.0"
id="base"
inkscape:current-layer="svg2"
- inkscape:cx="14.450743"
+ inkscape:cx="9.6858801"
inkscape:cy="12.141264"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
@@ -57,7 +60,7 @@
inkscape:window-width="1366"
inkscape:window-x="-8"
inkscape:window-y="-8"
- inkscape:zoom="17.57188"
+ inkscape:zoom="1"
objecttolerance="10.0"
pagecolor="#ffffff"
showgrid="false"
@@ -66,16 +69,16 @@
inkscape:measure-end="0,0" />
<g
id="g1327"
- transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,-1.0602338)">
+ transform="matrix(0.34431731,0,0,0.34431731,-0.1767767,0.6565548)">
<path
- d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 l 0,450.123 c 0,40.844 20.894,62.229 62.192,62.229 l 452.024,0 c 41.307,0 62.229,-20.316 62.229,-62.229 l 0,-450.123 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
+ d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 v 450.123 c 0,40.844 20.894,62.229 62.192,62.229 H 515.92 c 41.307,0 62.229,-20.316 62.229,-62.229 V 66.804 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
id="path1329"
style="fill:#111111;fill-opacity:0;stroke:#eeeeee;stroke-width:3.40799999;stroke-opacity:0"
inkscape:connector-curvature="0" />
</g>
<g
id="g2319"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2323"
@@ -84,7 +87,7 @@
</g>
<g
id="g2325"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2329"
@@ -92,39 +95,39 @@
inkscape:connector-curvature="0" />
</g>
<circle
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:2.10489988;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:19.34242439;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path898"
- cx="7.4564438"
- cy="6.1999226"
- r="2.5702684" />
+ cx="70.480728"
+ cy="55.175976"
+ r="23.618807" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:1.2851342px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 1.7888865,21.595802 C 1.7472225,18.024565 2.7605344,9.5386167 5.2788818,9.3760639 c 1.9139241,-0.076555 2.6380187,-0.132203 4.1544689,0 2.1751583,0.1782276 3.9757453,7.8313611 3.9921953,12.2197371 h -1.607697 c -0.229376,-3.388486 -0.611612,-5.480113 -1.301468,-7.693975 -0.153114,1.071798 -0.229671,7.693976 -0.229671,7.693976 H 4.9277222 L 4.6214943,13.901826 c -1.1217852,2.785041 -1.3214048,5.746992 -1.3014684,7.770533 z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:11.80940342px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 18.400196,196.65238 C 18.017335,163.8354 27.328899,85.85608 50.470592,84.362277 c 17.587504,-0.702977 24.241381,-1.214817 38.176402,0 19.988056,1.637799 36.534076,71.964233 36.685236,112.290103 h -14.77352 c -2.10778,-31.13765 -5.62024,-50.35805 -11.959493,-70.70173 -1.407001,9.84894 -2.110502,70.70173 -2.110502,70.70173 H 47.243703 l -2.814001,-70.70173 c -10.308351,25.5924 -12.142703,52.81047 -11.959503,71.40525 z"
id="path900"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccc" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:1.2851342px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 10.036017,7.7333484 c 0.706308,0.4985691 2.617492,-1.4126154 3.406895,-1.3710679 0.789403,0.041547 4.071655,0.9971401 5.027247,-0.1661899 C 19.425753,5.0327605 19.010277,1.2103904 17.680758,0.91955782 16.351238,0.62872539 10.243755,-0.32686724 9.4959004,1.7920554 8.7480459,3.910978 11.240895,5.3651405 11.656369,5.5313305 11.781013,6.320733 10.036017,7.7333484 10.036017,7.7333484 Z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:11.80940342px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 94.185039,69.267024 c 6.490431,4.581479 24.052751,-12.9809 31.306761,-12.599087 7.25402,0.382272 37.41541,9.162956 46.19657,-1.527159 8.78119,-10.690116 4.96328,-45.8147836 -7.254,-48.4872889 -12.21726,-2.6725063 -68.340379,-11.453742 -75.212592,8.0176089 -6.872212,19.47126 16.035162,32.833882 19.853062,34.361041 1.14538,7.253985 -14.889801,20.234885 -14.889801,20.234885 z"
id="path902"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csssscc" />
<circle
- style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:0.50433594;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:4.63446236;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path904"
- cx="12.427114"
- cy="3.3160748"
- r="0.24783203" />
+ cx="116.1574"
+ cy="28.675596"
+ r="2.2773874" />
<circle
- style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:0.50433594;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:4.63446236;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path904-5"
- cx="14.454914"
- cy="3.3160748"
- r="0.24783203" />
+ cx="134.79134"
+ cy="28.675596"
+ r="2.2773874" />
<circle
- style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:0.50433594;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:4.63446236;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path904-5-5"
- cx="16.446732"
- cy="3.3160748"
- r="0.24783203" />
+ cx="153.09462"
+ cy="28.675596"
+ r="2.2773874" />
</svg>
diff --git a/navit/icons/concert.svg b/navit/icons/concert.svg
index d226e4c2d..c908b056f 100644
--- a/navit/icons/concert.svg
+++ b/navit/icons/concert.svg
@@ -9,14 +9,17 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- height="22"
+ height="200"
id="svg2"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="concert.svg"
sodipodi:version="0.32"
version="1.0"
- width="22">
+ width="200"
+ inkscape:export-filename="C:\Users\jeremy\Pictures\svg\concert.png"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96">
<defs
id="defs22">
<inkscape:perspective
@@ -49,7 +52,7 @@
guidetolerance="10.0"
id="base"
inkscape:current-layer="svg2"
- inkscape:cx="20.75586"
+ inkscape:cx="14.153144"
inkscape:cy="4.6274553"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
@@ -57,7 +60,7 @@
inkscape:window-width="1366"
inkscape:window-x="-8"
inkscape:window-y="-8"
- inkscape:zoom="12.680782"
+ inkscape:zoom="1"
objecttolerance="10.0"
pagecolor="#ffffff"
showgrid="false"
@@ -67,16 +70,16 @@
inkscape:lockguides="true" />
<g
id="g1327"
- transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,-1.0602338)">
+ transform="matrix(0.34431731,0,0,0.34431731,-0.1767767,0.6565548)">
<path
- d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 l 0,450.123 c 0,40.844 20.894,62.229 62.192,62.229 l 452.024,0 c 41.307,0 62.229,-20.316 62.229,-62.229 l 0,-450.123 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
+ d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 v 450.123 c 0,40.844 20.894,62.229 62.192,62.229 H 515.92 c 41.307,0 62.229,-20.316 62.229,-62.229 V 66.804 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
id="path1329"
style="fill:#111111;fill-opacity:0;stroke:#eeeeee;stroke-width:3.40799999;stroke-opacity:0"
inkscape:connector-curvature="0" />
</g>
<g
id="g2319"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2323"
@@ -85,62 +88,42 @@
</g>
<g
id="g2325"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2329"
style="fill:#0089cd;stroke:none"
inkscape:connector-curvature="0" />
</g>
- <path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:1.16406763px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 11.89298,0.29824419 C 6.7920335,0.36448969 3.0245422,3.9744881 3.0160085,9.208339 c -0.00777,4.764226 8.8769715,12.089905 8.8769715,12.089905 0,0 8.399996,-7.12183 8.41325,-12.089905 C 20.3186,4.5706582 16.993926,0.29824419 11.89298,0.29824419 Z"
- id="path1492"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cscsc" />
- <path
- style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:0.30000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 11.875679,1.0590326 C 7.1553836,1.1203346 3.669036,4.4609421 3.6611391,9.3042242 3.6539491,13.712926 11.875679,20.491937 11.875679,20.491937 c 0,0 7.773159,-6.590374 7.785423,-11.1877128 0.01145,-4.2916004 -3.065128,-8.2451916 -7.785423,-8.2451916 z"
- id="path1492-2"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cscsc"
- inkscape:transform-center-x="-1.3165584"
- inkscape:transform-center-y="3.1070785" />
- <circle
- style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.25710332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="path1494"
- cx="11.661134"
- cy="8.7982445"
- r="7" />
<circle
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.50632137;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.95306969;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1511"
- cx="8.9422398"
- cy="12.313624"
- r="1.313432" />
+ cx="54.465088"
+ cy="171.69257"
+ r="25.818937" />
<circle
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.50632137;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.95306969;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1511-2"
- cx="13.315376"
- cy="10.128977"
- r="1.313432" />
+ cx="140.43051"
+ cy="128.74763"
+ r="25.818937" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.47141925;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.26697731;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530"
- width="1.1041681"
- height="5.7941589"
- x="9.1515036"
- y="6.3877821" />
+ width="21.705309"
+ height="113.89934"
+ x="58.578712"
+ y="55.204674" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.47141925;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.26697731;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1"
- width="1.1041681"
- height="5.7941589"
- x="13.52464"
- y="4.2824731" />
+ width="21.705309"
+ height="113.89934"
+ x="144.54413"
+ y="13.819176" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:1.75124252px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 9.1557652,6.3877811 14.628808,3.7072399 V 5.1514704 L 9.1557652,7.8504332 Z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:34.42524719px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 58.662477,55.204534 166.24943,2.511515 V 30.901629 L 58.662477,83.956741 Z"
id="path1547"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
diff --git a/navit/icons/crossing.svg b/navit/icons/crossing.svg
index 51a5aeab6..d3c1ebc17 100644
--- a/navit/icons/crossing.svg
+++ b/navit/icons/crossing.svg
@@ -9,14 +9,17 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- height="22"
+ height="200"
id="svg2"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="crossing.svg"
sodipodi:version="0.32"
version="1.0"
- width="22">
+ width="200"
+ inkscape:export-filename="C:\Users\jeremy\Pictures\svg\crossing.png"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96">
<defs
id="defs22">
<inkscape:perspective
@@ -49,7 +52,7 @@
guidetolerance="10.0"
id="base"
inkscape:current-layer="svg2"
- inkscape:cx="12.599127"
+ inkscape:cx="7.9303017"
inkscape:cy="7.2481934"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
@@ -57,7 +60,7 @@
inkscape:window-width="1366"
inkscape:window-x="-8"
inkscape:window-y="-8"
- inkscape:zoom="17.933333"
+ inkscape:zoom="1"
objecttolerance="10.0"
pagecolor="#ffffff"
showgrid="false"
@@ -67,16 +70,16 @@
inkscape:lockguides="true" />
<g
id="g1327"
- transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,-1.0602338)">
+ transform="matrix(0.34431731,0,0,0.34431731,-0.1767767,0.6565548)">
<path
- d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 l 0,450.123 c 0,40.844 20.894,62.229 62.192,62.229 l 452.024,0 c 41.307,0 62.229,-20.316 62.229,-62.229 l 0,-450.123 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
+ d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 v 450.123 c 0,40.844 20.894,62.229 62.192,62.229 H 515.92 c 41.307,0 62.229,-20.316 62.229,-62.229 V 66.804 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
id="path1329"
style="fill:#111111;fill-opacity:0;stroke:#eeeeee;stroke-width:3.40799999;stroke-opacity:0"
inkscape:connector-curvature="0" />
</g>
<g
id="g2319"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2323"
@@ -85,107 +88,87 @@
</g>
<g
id="g2325"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2329"
style="fill:#0089cd;stroke:none"
inkscape:connector-curvature="0" />
</g>
- <path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:1.16406763px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 11.89298,0.29824419 C 6.7920335,0.36448969 3.0245422,3.9744881 3.0160085,9.208339 c -0.00777,4.764226 8.8769715,12.089905 8.8769715,12.089905 0,0 8.399996,-7.12183 8.41325,-12.089905 C 20.3186,4.5706582 16.993926,0.29824419 11.89298,0.29824419 Z"
- id="path1492"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cscsc" />
- <path
- style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:0.30000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 11.875679,1.0590326 C 7.1553836,1.1203346 3.669036,4.4609421 3.6611391,9.3042242 3.6539491,13.712926 11.875679,20.491937 11.875679,20.491937 c 0,0 7.773159,-6.590374 7.785423,-11.1877128 0.01145,-4.2916004 -3.065128,-8.2451916 -7.785423,-8.2451916 z"
- id="path1492-2"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cscsc"
- inkscape:transform-center-x="-1.3165584"
- inkscape:transform-center-y="3.1070785" />
- <circle
- style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.25710332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="path1494"
- cx="11.661134"
- cy="8.7982445"
- r="7" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.47141925;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.964746;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1"
- width="1.1041681"
- height="5.7941589"
- x="15.890425"
- y="5.9333854" />
+ width="16.312975"
+ height="85.602875"
+ x="165.07462"
+ y="59.240246" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.47141925;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.964746;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1-1"
- width="1.1041681"
- height="5.7941589"
- x="13.416132"
- y="5.9333854" />
+ width="16.312975"
+ height="85.602875"
+ x="128.51941"
+ y="59.240246" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.47141925;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.964746;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1-1-7"
- width="1.1041681"
- height="5.7941589"
- x="10.965008"
- y="-11.597079"
+ width="16.312975"
+ height="85.602875"
+ x="92.306519"
+ y="-142.91566"
transform="scale(1,-1)" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.47141925;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.964746;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1-1-7-2"
- width="1.1041681"
- height="5.7941589"
- x="8.4675465"
- y="5.9333854" />
+ width="16.312975"
+ height="85.602875"
+ x="55.409027"
+ y="59.240246" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.47141925;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:6.964746;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1-1-7-2-7"
- width="1.1041681"
- height="5.7941589"
- x="5.9932542"
- y="5.9333854" />
+ width="16.312975"
+ height="85.602875"
+ x="18.853848"
+ y="59.240246" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.18637794;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:2.75354671;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1-1-7-6"
- width="1"
- height="1"
- x="11.017092"
- y="-4.9517441"
+ width="14.773995"
+ height="14.773995"
+ x="93.075996"
+ y="-44.737671"
transform="scale(1,-1)"
- inkscape:transform-center-x="-0.071419827"
- inkscape:transform-center-y="0.50357632" />
+ inkscape:transform-center-x="-1.0551502"
+ inkscape:transform-center-y="7.4398368" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.18637794;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:2.75354671;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1-1-7-6-5"
- width="1"
- height="1"
- x="11.017092"
- y="-3.1005669"
+ width="14.773995"
+ height="14.773995"
+ x="93.075996"
+ y="-17.388329"
transform="scale(1,-1)"
- inkscape:transform-center-x="-0.071419827"
- inkscape:transform-center-y="0.50357632" />
+ inkscape:transform-center-x="-1.0551502"
+ inkscape:transform-center-y="7.4398331" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.18637794;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:2.75354671;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1-1-7-6-5-6"
- width="1"
- height="1"
- x="11.017092"
- y="-13.448256"
+ width="14.773995"
+ height="14.773995"
+ x="93.075996"
+ y="-170.265"
transform="scale(1,-1)"
- inkscape:transform-center-x="-0.071419827"
- inkscape:transform-center-y="0.50357632" />
+ inkscape:transform-center-x="-1.0551502"
+ inkscape:transform-center-y="7.4398298" />
<rect
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:0.18637794;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:2.75354671;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1530-1-1-7-6-5-6-0"
- width="1"
- height="1"
- x="11.017092"
- y="-15.299434"
+ width="14.773995"
+ height="14.773995"
+ x="93.075996"
+ y="-197.61433"
transform="scale(1,-1)"
- inkscape:transform-center-x="-0.071419827"
- inkscape:transform-center-y="0.50357632" />
+ inkscape:transform-center-x="-1.0551502"
+ inkscape:transform-center-y="7.4398249" />
</svg>
diff --git a/navit/icons/dam.svg b/navit/icons/dam.svg
index 8b0448a42..af72238ca 100644
--- a/navit/icons/dam.svg
+++ b/navit/icons/dam.svg
@@ -9,14 +9,17 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- height="22"
+ height="200"
id="svg2"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="dam.svg"
sodipodi:version="0.32"
version="1.0"
- width="22">
+ width="200"
+ inkscape:export-filename="C:\Users\jeremy\Pictures\svg\dam.png"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96">
<defs
id="defs22">
<inkscape:perspective
@@ -38,7 +41,7 @@
<cc:license
rdf:resource="http://web.resource.org/cc/PublicDomain" />
<dc:language>en</dc:language>
- <dc:title />
+ <dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
@@ -49,15 +52,15 @@
guidetolerance="10.0"
id="base"
inkscape:current-layer="svg2"
- inkscape:cx="19.113183"
- inkscape:cy="10.931933"
+ inkscape:cx="98.38513"
+ inkscape:cy="57.71461"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:window-height="705"
inkscape:window-width="1366"
inkscape:window-x="-8"
inkscape:window-y="-8"
- inkscape:zoom="22.919321"
+ inkscape:zoom="5.0449372"
objecttolerance="10.0"
pagecolor="#ffffff"
showgrid="false"
@@ -65,18 +68,25 @@
inkscape:measure-start="0,0"
inkscape:measure-end="0,0"
inkscape:lockguides="true" />
+ <rect
+ style="fill:#eeeeee;fill-opacity:1;stroke:none;stroke-width:5.44347048;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect4532"
+ width="200.79305"
+ height="136.68173"
+ x="0"
+ y="36.605217" />
<g
id="g1327"
- transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,-1.0602338)">
+ transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,176.93977)">
<path
- d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 l 0,450.123 c 0,40.844 20.894,62.229 62.192,62.229 l 452.024,0 c 41.307,0 62.229,-20.316 62.229,-62.229 l 0,-450.123 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
+ d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 v 450.123 c 0,40.844 20.894,62.229 62.192,62.229 H 515.92 c 41.307,0 62.229,-20.316 62.229,-62.229 V 66.804 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
id="path1329"
style="fill:#111111;fill-opacity:0;stroke:#eeeeee;stroke-width:3.40799999;stroke-opacity:0"
inkscape:connector-curvature="0" />
</g>
<g
id="g2319"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2323"
@@ -85,7 +95,7 @@
</g>
<g
id="g2325"
- transform="matrix(0.04083073,0,0,0.04083073,35.725326,0.442546)">
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
d=""
id="path2329"
@@ -93,317 +103,297 @@
inkscape:connector-curvature="0" />
</g>
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:1.16406763px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 11.107616,0.42913812 C 6.0066699,0.49538362 2.2391786,4.105382 2.2306449,9.3392329 2.2228749,14.103459 11.107616,21.429138 11.107616,21.429138 c 0,0 8.399996,-7.12183 8.41325,-12.0899051 0.01237,-4.6376808 -3.312304,-8.91009478 -8.41325,-8.91009478 z"
- id="path1492"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cscsc" />
- <path
- style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:0.30000001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 11.090315,1.1899265 C 6.37002,1.2512285 2.8836724,4.591836 2.8757755,9.4351181 2.8685855,13.84382 11.090315,20.622831 11.090315,20.622831 c 0,0 7.773159,-6.590374 7.785423,-11.1877129 0.01145,-4.2916004 -3.065128,-8.2451916 -7.785423,-8.2451916 z"
- id="path1492-2"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cscsc"
- inkscape:transform-center-x="-1.3165584"
- inkscape:transform-center-y="3.1070785" />
- <circle
- style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.25710332;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="path1494"
- cx="10.875771"
- cy="8.9291391"
- r="7" />
- <path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830"
sodipodi:type="arc"
- sodipodi:cx="5.9102416"
- sodipodi:cy="5.5574636"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="19.048073"
+ sodipodi:cy="46.809044"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 6.7193797,5.5574636 a 0.80913812,0.82178432 0 0 1 -0.404569,0.7116861 0.80913812,0.82178432 0 0 1 -0.8091382,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.7116861" />
+ d="m 32.277136,46.809044 a 13.229063,13.435823 0 0 1 -6.614532,11.635764 13.229063,13.435823 0 0 1 -13.229063,0 13.229063,13.435823 0 0 1 -6.6145312,-11.635765" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0"
sodipodi:type="arc"
- sodipodi:cx="7.5475278"
- sodipodi:cy="5.5574636"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="45.817001"
+ sodipodi:cy="46.809044"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 8.3566659,5.5574636 a 0.80913812,0.82178432 0 0 1 -0.4045691,0.7116861 0.80913812,0.82178432 0 0 1 -0.8091381,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.7116861" />
+ d="m 59.046064,46.809044 a 13.229063,13.435823 0 0 1 -6.614531,11.635764 13.229063,13.435823 0 0 1 -13.229064,0 13.229063,13.435823 0 0 1 -6.614531,-11.635765" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-3"
sodipodi:type="arc"
- sodipodi:cx="9.1765404"
- sodipodi:cy="5.5574636"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="72.450668"
+ sodipodi:cy="46.809044"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="6.2639059"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="M 9.9855281,5.5416211 A 0.80913812,0.82178432 0 0 1 9.5900823,6.2638099 0.80913812,0.82178432 0 0 1 8.7764829,6.2717756 0.80913812,0.82178432 0 0 1 8.3674023,5.5574636" />
+ d="M 85.677273,46.550025 A 13.229063,13.435823 0 0 1 79.211902,58.357505 13.229063,13.435823 0 0 1 65.909899,58.48774 13.229063,13.435823 0 0 1 59.221605,46.809043" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-6"
sodipodi:type="arc"
- sodipodi:cx="5.9505248"
- sodipodi:cy="6.964376"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="19.706688"
+ sodipodi:cy="69.811371"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 6.7596629,6.964376 a 0.80913812,0.82178432 0 0 1 -0.404569,0.7116861 0.80913812,0.82178432 0 0 1 -0.8091382,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.7116862" />
+ d="m 32.935751,69.811371 a 13.229063,13.435823 0 0 1 -6.614532,11.635764 13.229063,13.435823 0 0 1 -13.229063,0 A 13.229063,13.435823 0 0 1 6.4776249,69.81137" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-8"
sodipodi:type="arc"
- sodipodi:cx="7.587811"
- sodipodi:cy="6.964376"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="46.475624"
+ sodipodi:cy="69.811371"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="M 8.3969491,6.964376 A 0.80913812,0.82178432 0 0 1 7.99238,7.6760621 a 0.80913812,0.82178432 0 0 1 -0.8091381,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.7116862" />
+ d="m 59.704687,69.811371 a 13.229063,13.435823 0 0 1 -6.614532,11.635764 13.229063,13.435823 0 0 1 -13.229063,0 13.229063,13.435823 0 0 1 -6.614531,-11.635765" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-3-4"
sodipodi:type="arc"
- sodipodi:cx="9.2168236"
- sodipodi:cy="6.964376"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="73.109268"
+ sodipodi:cy="69.811371"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="6.2639059"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="M 10.025811,6.9485334 A 0.80913812,0.82178432 0 0 1 9.6303655,7.6707223 0.80913812,0.82178432 0 0 1 8.8167661,7.6786879 0.80913812,0.82178432 0 0 1 8.4076855,6.9643759" />
+ d="M 86.335873,69.552352 A 13.229063,13.435823 0 0 1 79.870501,81.359832 13.229063,13.435823 0 0 1 66.568499,81.490067 13.229063,13.435823 0 0 1 59.880205,69.81137" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-6-0"
sodipodi:type="arc"
- sodipodi:cx="5.9267492"
- sodipodi:cy="8.2720375"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="19.317963"
+ sodipodi:cy="91.191093"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 6.7358873,8.2720375 a 0.80913812,0.82178432 0 0 1 -0.404569,0.7116861 0.80913812,0.82178432 0 0 1 -0.8091382,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.7116861" />
+ d="m 32.547026,91.191093 a 13.229063,13.435823 0 0 1 -6.614532,11.635767 13.229063,13.435823 0 0 1 -13.229063,0 13.229063,13.435823 0 0 1 -6.6145314,-11.635767" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-8-2"
sodipodi:type="arc"
- sodipodi:cx="7.5640359"
- sodipodi:cy="8.2720375"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="46.086906"
+ sodipodi:cy="91.191093"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 8.373174,8.2720375 a 0.80913812,0.82178432 0 0 1 -0.4045691,0.7116861 0.80913812,0.82178432 0 0 1 -0.8091381,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.7116861" />
+ d="m 59.315969,91.191093 a 13.229063,13.435823 0 0 1 -6.614531,11.635767 13.229063,13.435823 0 0 1 -13.229063,0 13.229063,13.435823 0 0 1 -6.614532,-11.635767" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-3-4-9"
sodipodi:type="arc"
- sodipodi:cx="9.1930475"
- sodipodi:cy="8.2720375"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="72.720543"
+ sodipodi:cy="91.191093"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="6.2639059"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="M 10.002035,8.256195 A 0.80913812,0.82178432 0 0 1 9.6065894,8.9783838 0.80913812,0.82178432 0 0 1 8.79299,8.9863495 0.80913812,0.82178432 0 0 1 8.3839094,8.2720375" />
+ d="M 85.947147,90.932075 A 13.229063,13.435823 0 0 1 79.481776,102.73955 13.229063,13.435823 0 0 1 66.179773,102.86979 13.229063,13.435823 0 0 1 59.49148,91.191093" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-6-0-0"
sodipodi:type="arc"
- sodipodi:cx="5.9267492"
- sodipodi:cy="9.6034737"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="19.317963"
+ sodipodi:cy="112.95952"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 6.7358873,9.6034737 a 0.80913812,0.82178432 0 0 1 -0.404569,0.7116863 0.80913812,0.82178432 0 0 1 -0.8091382,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.7116864" />
+ d="m 32.547026,112.95952 a 13.229063,13.435823 0 0 1 -6.614532,11.63576 13.229063,13.435823 0 0 1 -13.229063,0 13.229063,13.435823 0 0 1 -6.6145314,-11.63576" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-8-2-8"
sodipodi:type="arc"
- sodipodi:cx="7.5640359"
- sodipodi:cy="9.6034737"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="46.086906"
+ sodipodi:cy="112.95952"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 8.373174,9.6034737 a 0.80913812,0.82178432 0 0 1 -0.4045691,0.7116863 0.80913812,0.82178432 0 0 1 -0.8091381,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.7116864" />
+ d="m 59.315969,112.95952 a 13.229063,13.435823 0 0 1 -6.614531,11.63576 13.229063,13.435823 0 0 1 -13.229063,0 13.229063,13.435823 0 0 1 -6.614532,-11.63576" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-3-4-9-1"
sodipodi:type="arc"
- sodipodi:cx="9.1930475"
- sodipodi:cy="9.6034737"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="72.720543"
+ sodipodi:cy="112.95952"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="6.2639059"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="M 10.002035,9.5876311 A 0.80913812,0.82178432 0 0 1 9.6065894,10.30982 0.80913812,0.82178432 0 0 1 8.79299,10.317786 0.80913812,0.82178432 0 0 1 8.3839094,9.6034736" />
+ d="m 85.947147,112.7005 a 13.229063,13.435823 0 0 1 -6.465371,11.80748 13.229063,13.435823 0 0 1 -13.302003,0.13023 13.229063,13.435823 0 0 1 -6.688293,-11.67869" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-6-0-3"
sodipodi:type="arc"
- sodipodi:cx="5.9267492"
- sodipodi:cy="10.831888"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="19.317963"
+ sodipodi:cy="133.04347"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 6.7358873,10.831888 a 0.80913812,0.82178432 0 0 1 -0.404569,0.711686 0.80913812,0.82178432 0 0 1 -0.8091382,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.711686" />
+ d="m 32.547026,133.04347 a 13.229063,13.435823 0 0 1 -6.614532,11.63577 13.229063,13.435823 0 0 1 -13.229063,0 13.229063,13.435823 0 0 1 -6.6145314,-11.63577" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-8-2-6"
sodipodi:type="arc"
- sodipodi:cx="7.5640359"
- sodipodi:cy="10.831888"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="46.086906"
+ sodipodi:cy="133.04347"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 8.373174,10.831888 a 0.80913812,0.82178432 0 0 1 -0.4045691,0.711686 0.80913812,0.82178432 0 0 1 -0.8091381,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.711686" />
+ d="m 59.315969,133.04347 a 13.229063,13.435823 0 0 1 -6.614531,11.63577 13.229063,13.435823 0 0 1 -13.229063,0 13.229063,13.435823 0 0 1 -6.614532,-11.63577" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-3-4-9-7"
sodipodi:type="arc"
- sodipodi:cx="9.1930475"
- sodipodi:cy="10.839812"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="72.720543"
+ sodipodi:cy="133.17322"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="6.2639059"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="M 10.002035,10.82397 A 0.80913812,0.82178432 0 0 1 9.6065894,11.546159 0.80913812,0.82178432 0 0 1 8.79299,11.554124 0.80913812,0.82178432 0 0 1 8.3839094,10.839812" />
+ d="m 85.947147,132.9142 a 13.229063,13.435823 0 0 1 -6.465371,11.80748 13.229063,13.435823 0 0 1 -13.302003,0.13023 13.229063,13.435823 0 0 1 -6.688293,-11.67869" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29349035;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.79844189;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-6-0-0-5"
sodipodi:type="arc"
- sodipodi:cx="5.9029737"
- sodipodi:cy="12.034188"
- sodipodi:rx="0.83113402"
- sodipodi:ry="0.8185544"
+ sodipodi:cx="18.929245"
+ sodipodi:cy="152.70058"
+ sodipodi:rx="13.588687"
+ sodipodi:ry="13.383015"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 6.7341077,12.034188 a 0.83113402,0.8185544 0 0 1 -0.415567,0.708889 0.83113402,0.8185544 0 0 1 -0.8311341,0 0.83113402,0.8185544 0 0 1 -0.415567,-0.708889" />
+ d="m 32.517932,152.70058 a 13.588687,13.383015 0 0 1 -6.794344,11.59003 13.588687,13.383015 0 0 1 -13.588687,0 13.588687,13.383015 0 0 1 -6.7943429,-11.59003" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-8-2-8-6"
sodipodi:type="arc"
- sodipodi:cx="7.5640359"
- sodipodi:cy="12.032672"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="46.086906"
+ sodipodi:cy="152.67587"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 8.373174,12.032672 a 0.80913812,0.82178432 0 0 1 -0.4045691,0.711686 0.80913812,0.82178432 0 0 1 -0.8091381,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.711686" />
+ d="m 59.315969,152.67587 a 13.229063,13.435823 0 0 1 -6.614531,11.63577 13.229063,13.435823 0 0 1 -13.229063,0 13.229063,13.435823 0 0 1 -6.614532,-11.63577" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-3-4-9-1-6"
sodipodi:type="arc"
- sodipodi:cx="9.1930475"
- sodipodi:cy="12.040596"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="72.720543"
+ sodipodi:cy="152.80534"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="6.2639059"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="M 10.002035,12.024753 A 0.80913812,0.82178432 0 0 1 9.6065894,12.746942 0.80913812,0.82178432 0 0 1 8.79299,12.754908 0.80913812,0.82178432 0 0 1 8.3839094,12.040596" />
+ d="m 85.947147,152.54632 a 13.229063,13.435823 0 0 1 -6.465371,11.80748 13.229063,13.435823 0 0 1 -13.302003,0.13024 13.229063,13.435823 0 0 1 -6.688293,-11.6787" />
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="m 10.008784,5.2858401 v 7.6795369 h 2.258687 L 10.650727,5.2858401 Z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:16.34957314px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 86.0575,42.368095 V 167.92514 h 36.92857 L 96.55299,42.368095 Z"
id="path966"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-6-0-0-4"
sodipodi:type="arc"
- sodipodi:cx="12.488831"
- sodipodi:cy="10.831888"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="126.60519"
+ sodipodi:cy="133.04347"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 13.297969,10.831888 a 0.80913812,0.82178432 0 0 1 -0.404569,0.711686 0.80913812,0.82178432 0 0 1 -0.809139,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.711686" />
+ d="m 139.83425,133.04347 a 13.229063,13.435823 0 0 1 -6.61453,11.63577 13.229063,13.435823 0 0 1 -13.22907,0 13.229063,13.435823 0 0 1 -6.61453,-11.63577" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-8-2-8-2"
sodipodi:type="arc"
- sodipodi:cx="14.126117"
- sodipodi:cy="10.831888"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="153.37411"
+ sodipodi:cy="133.04347"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 14.935255,10.831888 a 0.80913812,0.82178432 0 0 1 -0.404569,0.711686 0.80913812,0.82178432 0 0 1 -0.809138,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.711686" />
+ d="m 166.60318,133.04347 a 13.229063,13.435823 0 0 1 -6.61453,11.63577 13.229063,13.435823 0 0 1 -13.22907,0 13.229063,13.435823 0 0 1 -6.61453,-11.63577" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-3-4-9-1-1"
sodipodi:type="arc"
- sodipodi:cx="15.755129"
- sodipodi:cy="10.839812"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="180.00777"
+ sodipodi:cy="133.17322"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="6.2639059"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 16.564117,10.82397 a 0.80913812,0.82178432 0 0 1 -0.395446,0.722189 0.80913812,0.82178432 0 0 1 -0.8136,0.008 0.80913812,0.82178432 0 0 1 -0.40908,-0.714312" />
+ d="m 193.23437,132.9142 a 13.229063,13.435823 0 0 1 -6.46537,11.80748 13.229063,13.435823 0 0 1 -13.302,0.13023 13.229063,13.435823 0 0 1 -6.6883,-11.67869" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-6-0-0-4-3"
sodipodi:type="arc"
- sodipodi:cx="12.631482"
- sodipodi:cy="12.032672"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="128.93752"
+ sodipodi:cy="152.67587"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 13.44062,12.032672 a 0.80913812,0.82178432 0 0 1 -0.404569,0.711686 0.80913812,0.82178432 0 0 1 -0.809138,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.711686" />
+ d="m 142.16658,152.67587 a 13.229063,13.435823 0 0 1 -6.61453,11.63577 13.229063,13.435823 0 0 1 -13.22907,0 13.229063,13.435823 0 0 1 -6.61453,-11.63577" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-8-2-8-2-2"
sodipodi:type="arc"
- sodipodi:cx="14.26877"
- sodipodi:cy="12.032672"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="155.70645"
+ sodipodi:cy="152.67587"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 15.077908,12.032672 a 0.80913812,0.82178432 0 0 1 -0.404569,0.711686 0.80913812,0.82178432 0 0 1 -0.809138,0 0.80913812,0.82178432 0 0 1 -0.404569,-0.711686" />
+ d="m 168.93551,152.67587 a 13.229063,13.435823 0 0 1 -6.61453,11.63577 13.229063,13.435823 0 0 1 -13.22906,0 13.229063,13.435823 0 0 1 -6.61453,-11.63577" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:0.29015145;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.74385262;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-3-4-9-1-1-5"
sodipodi:type="arc"
- sodipodi:cx="15.897783"
- sodipodi:cy="12.040596"
- sodipodi:rx="0.80913812"
- sodipodi:ry="0.82178432"
+ sodipodi:cx="182.3401"
+ sodipodi:cy="152.80534"
+ sodipodi:rx="13.229063"
+ sodipodi:ry="13.435823"
sodipodi:start="6.2639059"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 16.706771,12.024753 a 0.80913812,0.82178432 0 0 1 -0.395446,0.722189 0.80913812,0.82178432 0 0 1 -0.813599,0.008 0.80913812,0.82178432 0 0 1 -0.409081,-0.714312" />
+ d="m 195.56671,152.54632 a 13.229063,13.435823 0 0 1 -6.46537,11.80748 13.229063,13.435823 0 0 1 -13.30201,0.13024 13.229063,13.435823 0 0 1 -6.68829,-11.6787" />
</svg>
diff --git a/navit/icons/danger_area.svg b/navit/icons/danger_area.svg
new file mode 100644
index 000000000..7cd766e0d
--- /dev/null
+++ b/navit/icons/danger_area.svg
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="200"
+ id="svg2"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
+ sodipodi:docname="danger_area.svg"
+ sodipodi:version="0.32"
+ version="1.0"
+ width="200">
+ <defs
+ id="defs22">
+ <inkscape:perspective
+ id="perspective24"
+ inkscape:persp3d-origin="290 : 193.33333 : 1"
+ inkscape:vp_x="0 : 290 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="580 : 290 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <metadata
+ id="metadata10">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <cc:license
+ rdf:resource="http://web.resource.org/cc/PublicDomain" />
+ <dc:language>en</dc:language>
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10.0"
+ guidetolerance="10.0"
+ id="base"
+ inkscape:current-layer="svg2"
+ inkscape:cx="17.694641"
+ inkscape:cy="94.483413"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:window-height="705"
+ inkscape:window-width="1366"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:zoom="2.1796875"
+ objecttolerance="10.0"
+ pagecolor="#ffffff"
+ showgrid="false"
+ inkscape:window-maximized="1"
+ inkscape:measure-start="0,0"
+ inkscape:measure-end="0,0"
+ inkscape:lockguides="true" />
+ <g
+ id="g1327"
+ transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,176.93977)">
+ <path
+ d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 v 450.123 c 0,40.844 20.894,62.229 62.192,62.229 H 515.92 c 41.307,0 62.229,-20.316 62.229,-62.229 V 66.804 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
+ id="path1329"
+ style="fill:#111111;fill-opacity:0;stroke:#eeeeee;stroke-width:3.40799999;stroke-opacity:0"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ id="g2319"
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
+ <path
+ d=""
+ id="path2323"
+ style="fill:#0089cd;stroke:none"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ id="g2325"
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
+ <path
+ d=""
+ id="path2329"
+ style="fill:#0089cd;stroke:none"
+ inkscape:connector-curvature="0" />
+ </g>
+ <circle
+ style="fill:#ffff45;fill-opacity:1;stroke:none;stroke-width:17.50965309;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path1494"
+ cx="99.503998"
+ cy="100.1497"
+ r="97.5" />
+ <path
+ style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:9.33368969px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 98.59712,119.69848 c 9.53147,0 19.97069,-73.346332 19.51679,-82.894368 -0.45393,-9.548036 -15.43187,-10.416064 -19.51679,-10.416064 -4.0849,0 -17.24738,2.604086 -17.70125,9.982049 -0.45394,7.378105 10.43922,83.328383 17.70125,83.328383 z"
+ id="path1010"
+ inkscape:connector-curvature="0" />
+ <circle
+ style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:6.23048878;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path1012"
+ cx="99.503998"
+ cy="158.81961"
+ r="13.928572" />
+</svg>
diff --git a/navit/icons/desktop_icons/navit.desktop.in b/navit/icons/desktop_icons/navit.desktop.in
index 81486b7c6..5dc1bcfc8 100644
--- a/navit/icons/desktop_icons/navit.desktop.in
+++ b/navit/icons/desktop_icons/navit.desktop.in
@@ -3,6 +3,7 @@ Version=1.0
Name=Navit
Name[de]=Navit
Name[fr]=Navit
+Keywords=gps;navigation;maps;
Comment=The open source vector based navigation program with routing engine
Comment[de]=Ein vektorbasiertes Navigationsprogramm
Comment[fr]=Le logiciel opensource de navigation vectorielle
diff --git a/navit/icons/drinking_water.svg b/navit/icons/drinking_water.svg
index b7c676fa0..d4cf5a0c4 100644
--- a/navit/icons/drinking_water.svg
+++ b/navit/icons/drinking_water.svg
@@ -41,7 +41,7 @@
<cc:license
rdf:resource="http://web.resource.org/cc/PublicDomain" />
<dc:language>en</dc:language>
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -52,15 +52,15 @@
guidetolerance="10.0"
id="base"
inkscape:current-layer="svg2"
- inkscape:cx="11.370929"
- inkscape:cy="13.89007"
+ inkscape:cx="24.94017"
+ inkscape:cy="6.5543801"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:window-height="705"
inkscape:window-width="1366"
inkscape:window-x="-8"
inkscape:window-y="-8"
- inkscape:zoom="1"
+ inkscape:zoom="1.2239456"
objecttolerance="10.0"
pagecolor="#ffffff"
showgrid="false"
@@ -69,15 +69,6 @@
inkscape:measure-end="0,0"
inkscape:lockguides="true" />
<g
- id="g1327"
- transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,176.93977)">
- <path
- d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 v 450.123 c 0,40.844 20.894,62.229 62.192,62.229 H 515.92 c 41.307,0 62.229,-20.316 62.229,-62.229 V 66.804 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
- id="path1329"
- style="fill:#111111;fill-opacity:0;stroke:#eeeeee;stroke-width:3.40799999;stroke-opacity:0"
- inkscape:connector-curvature="0" />
- </g>
- <g
id="g2319"
transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
<path
@@ -96,71 +87,51 @@
inkscape:connector-curvature="0" />
</g>
<path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:10.5320406px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- d="M 103.33151,6.29824 C 57.180085,6.8971924 23.093259,39.55955 23.016049,86.91343 c -0.0703,43.10485 80.315461,109.38481 80.315461,109.38481 0,0 75.99996,-64.4356 76.11988,-109.38481 C 179.56331,44.953469 149.48292,6.29824 103.33151,6.29824 Z"
- id="path1492"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cscsc" />
- <path
- style="fill:#0089cd;fill-opacity:1;stroke:#ffffff;stroke-width:2.71428585;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 103.17497,13.181578 C 60.467538,13.736197 28.924393,43.960764 28.852945,87.780916 28.787893,127.66924 103.17497,189.00314 103.17497,189.00314 c 0,0 70.32858,-59.62724 70.43954,-101.222224 0.1036,-38.828762 -27.73211,-74.599338 -70.43954,-74.599338 z"
- id="path1492-2"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="cscsc"
- inkscape:transform-center-x="-11.911717"
- inkscape:transform-center-y="28.11166" />
- <circle
- style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:11.37379169;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- id="path1494"
- cx="101.23385"
- cy="83.203079"
- r="63.333332" />
- <path
- style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:4.48494482;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 75.78481,42.116135 v 6.044172 h 6.613544 v 5.037714 H 56.097479 l -6.394551,-5.190076 v 24.527009 l 6.15366,-4.993019 h 22.096237 c 0,0 1.032332,5.948357 7.292416,5.628072 5.132345,-0.262381 5.649978,-5.628072 5.649978,-5.628072 0,0 4.88195,-0.08143 8.650166,0 1.512935,0.03619 1.881805,1.131857 1.861425,2.167991 -0.11572,5.880771 0,8.4531 0,8.4531 0,0 7.17054,-0.08143 11.56274,0 0.0416,-6.641405 0.12667,-11.843515 0,-17.672624 -0.10875,-5.017629 -7.93841,-7.188333 -12.89858,-7.292381 -4.960176,-0.104048 -12.964297,0 -12.964297,0 l 3.6e-5,-5.037714 h 7.445666 v -6.044172 z"
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:10.13824272;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 62.783034,3.5735704 V 17.236455 h 14.94995 v 11.38778 H 18.27971 L 3.8247918,16.892039 V 72.335481 L 17.735175,61.048734 h 49.948669 c 0,0 2.33359,13.446294 16.48455,12.722288 11.60169,-0.593114 12.7718,-12.722288 12.7718,-12.722288 0,0 11.035676,-0.184073 19.553746,0 3.42,0.08181 4.25383,2.558569 4.20776,4.900756 -0.26158,13.293515 0,19.108279 0,19.108279 0,0 16.20905,-0.184073 26.13764,0 0.094,-15.012933 0.28634,-26.772332 0,-39.949066 -0.24583,-11.342378 -17.94482,-16.249267 -29.15731,-16.484468 -11.21251,-0.235201 -29.305866,0 -29.305866,0 l 8e-5,-11.38778 H 105.20721 V 3.5735704 Z"
id="path1679"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccscccccccccccc" />
<path
- style="fill:none;stroke:#0089cd;stroke-width:1.80952382;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 84.295582,83.191692 94.891661,127.47526 H 120.88204 L 131.07827,83.191692"
+ style="fill:none;stroke:#0089cd;stroke-width:4.09043884;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 82.021684,96.425097 105.97417,196.52835 h 58.7514 L 187.7742,96.425097"
id="path1681"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:2.09227252;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.72959375;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-6-0-0-4"
sodipodi:type="arc"
- sodipodi:cx="94.43795"
- sodipodi:cy="94.236076"
- sodipodi:rx="6.6486578"
- sodipodi:ry="5.2003613"
+ sodipodi:cx="104.94855"
+ sodipodi:cy="121.39098"
+ sodipodi:rx="15.029328"
+ sodipodi:ry="11.755445"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 101.08661,94.236076 a 6.6486578,5.2003613 0 0 1 -3.324331,4.503645 6.6486578,5.2003613 0 0 1 -6.648658,0 6.6486578,5.2003613 0 0 1 -3.324329,-4.503645" />
+ d="m 119.97788,121.39098 a 15.029328,11.755445 0 0 1 -7.51467,10.18052 15.029328,11.755445 0 0 1 -15.029327,0 15.029328,11.755445 0 0 1 -7.514664,-10.18052" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:2.09227252;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.72959375;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-8-2-8-2"
sodipodi:type="arc"
- sodipodi:cx="107.89147"
- sodipodi:cy="94.236076"
- sodipodi:rx="6.6486578"
- sodipodi:ry="5.2003613"
+ sodipodi:cx="135.36032"
+ sodipodi:cy="121.39098"
+ sodipodi:rx="15.029328"
+ sodipodi:ry="11.755445"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 114.54013,94.236076 a 6.6486578,5.2003613 0 0 1 -3.32433,4.503645 6.6486578,5.2003613 0 0 1 -6.64866,0 6.6486578,5.2003613 0 0 1 -3.32433,-4.503645" />
+ d="m 150.38965,121.39098 a 15.029328,11.755445 0 0 1 -7.51466,10.18052 15.029328,11.755445 0 0 1 -15.02933,0 15.029328,11.755445 0 0 1 -7.51467,-10.18052" />
<path
- style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:2.09227252;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ style="fill:none;fill-opacity:1;stroke:#0089cd;stroke-width:4.72959375;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path830-0-3-4-9-1-1"
sodipodi:type="arc"
- sodipodi:cx="121.27702"
- sodipodi:cy="94.286331"
- sodipodi:rx="6.6486578"
- sodipodi:ry="5.2003613"
+ sodipodi:cx="165.61842"
+ sodipodi:cy="121.5046"
+ sodipodi:rx="15.029328"
+ sodipodi:ry="11.755445"
sodipodi:start="6.2639059"
sodipodi:end="3.1415927"
sodipodi:open="true"
- d="m 127.92445,94.186078 a 6.6486578,5.2003613 0 0 1 -3.24937,4.570107 6.6486578,5.2003613 0 0 1 -6.68531,0.05041 6.6486578,5.2003613 0 0 1 -3.3614,-4.520262" />
+ d="m 180.64496,121.27798 a 15.029328,11.755445 0 0 1 -7.34521,10.33075 15.029328,11.755445 0 0 1 -15.11219,0.11395 15.029328,11.755445 0 0 1 -7.59846,-10.21808" />
</svg>
diff --git a/navit/icons/follow.svg b/navit/icons/follow.svg
new file mode 100644
index 000000000..a78beb2c8
--- /dev/null
+++ b/navit/icons/follow.svg
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="follow.svg"
+ inkscape:export-filename="/home/michael/src/navit-artwork/set_center_cursor.png"
+ inkscape:export-xdpi="134.99994"
+ inkscape:export-ydpi="134.99994">
+ <defs
+ id="defs4">
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath428">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path430" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath416">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path418" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath544">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path546" />
+ </clipPath>
+ <radialGradient
+ r="60"
+ fy="72"
+ fx="72"
+ cy="72"
+ cx="72"
+ gradientUnits="userSpaceOnUse"
+ id="radialGradient3969"
+ xlink:href="#linearGradient3785"
+ inkscape:collect="always" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3785"
+ id="radialGradient3926"
+ gradientUnits="userSpaceOnUse"
+ cx="72"
+ cy="72"
+ fx="72"
+ fy="72"
+ r="60" />
+ <linearGradient
+ id="linearGradient3785">
+ <stop
+ id="stop3787"
+ offset="0"
+ style="stop-color:#3e3e3e;stop-opacity:1;" />
+ <stop
+ id="stop3789"
+ offset="1"
+ style="stop-color:#000000;stop-opacity:1;" />
+ </linearGradient>
+ <radialGradient
+ gradientUnits="userSpaceOnUse"
+ r="60"
+ fy="72"
+ fx="72"
+ cy="72"
+ cx="72"
+ id="radialGradient3791"
+ xlink:href="#linearGradient3785"
+ inkscape:collect="always" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="15.8125"
+ inkscape:cx="15.226152"
+ inkscape:cy="21.470355"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1000"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true"
+ inkscape:snap-others="false"
+ inkscape:object-nodes="false">
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,40"
+ id="guide2985"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="8,0"
+ id="guide2989"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="40,0"
+ id="guide2991"
+ inkscape:locked="false" />
+ <inkscape:grid
+ type="xygrid"
+ id="grid3763"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1004.3622)">
+ <rect
+ style="fill:#000000;fill-opacity:0.62745098;stroke:none"
+ id="rect2993"
+ width="48"
+ height="48.000019"
+ x="3.5527137e-15"
+ y="1004.3622"
+ rx="4" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 24,1022.544 c -3.214546,0 -5.818182,2.6036 -5.818182,5.8182 0,3.2146 2.603636,5.8182 5.818182,5.8182 3.214546,0 5.818182,-2.6036 5.818182,-5.8182 0,-3.2146 -2.603636,-5.8182 -5.818182,-5.8182 z m 13.003637,4.3636 c -0.669091,-6.0654 -5.483637,-10.88 -11.549091,-11.5491 v -2.9963 h -2.909092 v 2.9963 c -6.065454,0.6691 -10.88,5.4837 -11.549091,11.5491 H 8 v 2.9092 h 2.996363 c 0.669091,6.0654 5.483637,10.88 11.549091,11.5491 v 2.9963 h 2.909092 v -2.9963 c 6.065454,-0.6691 10.88,-5.4837 11.549091,-11.5491 H 40 v -2.9092 z M 24,1038.544 c -5.621818,0 -10.181818,-4.56 -10.181818,-10.1818 0,-5.6218 4.56,-10.1818 10.181818,-10.1818 5.621818,0 10.181818,4.56 10.181818,10.1818 0,5.6218 -4.56,10.1818 -10.181818,10.1818 z"
+ id="path2"
+ style="stroke-width:0.72727275;fill:#ffffff" />
+ </g>
+</svg>
diff --git a/navit/icons/forbidden_area.svg b/navit/icons/forbidden_area.svg
new file mode 100644
index 000000000..1daf0aa0d
--- /dev/null
+++ b/navit/icons/forbidden_area.svg
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="200"
+ id="svg2"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
+ sodipodi:docname="forbidden_area.svg"
+ sodipodi:version="0.32"
+ version="1.0"
+ width="200"
+ inkscape:export-filename="C:\Users\jeremy\Pictures\svg\forbidden_area.png"
+ inkscape:export-xdpi="96"
+ inkscape:export-ydpi="96">
+ <defs
+ id="defs22">
+ <inkscape:perspective
+ id="perspective24"
+ inkscape:persp3d-origin="290 : 193.33333 : 1"
+ inkscape:vp_x="0 : 290 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="580 : 290 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <metadata
+ id="metadata10">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <cc:license
+ rdf:resource="http://web.resource.org/cc/PublicDomain" />
+ <dc:language>en</dc:language>
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10.0"
+ guidetolerance="10.0"
+ id="base"
+ inkscape:current-layer="svg2"
+ inkscape:cx="63.25448"
+ inkscape:cy="116.93699"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:window-height="705"
+ inkscape:window-width="1366"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:zoom="2.1796875"
+ objecttolerance="10.0"
+ pagecolor="#ffffff"
+ showgrid="false"
+ inkscape:window-maximized="1"
+ inkscape:measure-start="0,0"
+ inkscape:measure-end="0,0"
+ inkscape:lockguides="true" />
+ <g
+ id="g1327"
+ transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,176.93977)">
+ <path
+ d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 v 450.123 c 0,40.844 20.894,62.229 62.192,62.229 H 515.92 c 41.307,0 62.229,-20.316 62.229,-62.229 V 66.804 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
+ id="path1329"
+ style="fill:#111111;fill-opacity:0;stroke:#eeeeee;stroke-width:3.40799999;stroke-opacity:0"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ id="g2319"
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
+ <path
+ d=""
+ id="path2323"
+ style="fill:#0089cd;stroke:none"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ id="g2325"
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
+ <path
+ d=""
+ id="path2329"
+ style="fill:#0089cd;stroke:none"
+ inkscape:connector-curvature="0" />
+ </g>
+ <circle
+ style="fill:#ffd7ff;fill-opacity:1;stroke:none;stroke-width:17.50965309;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path1494"
+ cx="99.780441"
+ cy="100.87871"
+ r="97.5" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path2400"
+ d="m 99.237348,24.906864 c -6.97702,0 -12.63961,5.662522 -12.63961,12.639481 0,6.976961 5.66259,12.639483 12.63961,12.639483 6.977012,0 12.639592,-5.662522 12.639592,-12.639483 0,-6.976959 -5.66258,-12.639481 -12.639592,-12.639481 z m -19.95721,26.609421 c -6.65235,0 -9.97855,3.326143 -9.97855,9.978569 v 46.566416 c 0,3.32615 9.97855,3.32615 9.97855,0 V 74.799424 c 0,-1.330177 3.32622,-1.330177 3.32622,0 v 99.785266 c 0,6.65228 16.63099,6.65228 16.63099,0 v -63.19727 c 0,-1.33018 3.326212,-1.33018 3.326212,0 v 63.19727 c 0,6.65228 16.63099,6.65228 16.63099,0 V 74.799424 c 0,-1.330177 3.32622,-1.330177 3.32622,0 v 33.261846 c 0,3.32615 9.97856,3.32615 9.97856,0 V 61.494854 c 0,-6.652426 -6.65234,-9.978569 -13.30478,-9.978569 z"
+ style="fill:#0089cd;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.3118937"
+ sodipodi:nodetypes="cssscccccccccccccccccccc" />
+ <rect
+ style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:7.27071524;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect1712"
+ width="187.66129"
+ height="27.857143"
+ x="-234.66626"
+ y="-29.908518"
+ transform="rotate(-140.767)" />
+</svg>
diff --git a/navit/icons/government_building.svg b/navit/icons/government_building.svg
new file mode 100644
index 000000000..f12adf04b
--- /dev/null
+++ b/navit/icons/government_building.svg
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="200"
+ id="svg2"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
+ inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
+ sodipodi:docname="government_building.svg"
+ sodipodi:version="0.32"
+ version="1.0"
+ width="200">
+ <defs
+ id="defs22">
+ <inkscape:perspective
+ id="perspective24"
+ inkscape:persp3d-origin="290 : 193.33333 : 1"
+ inkscape:vp_x="0 : 290 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="580 : 290 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ </defs>
+ <metadata
+ id="metadata10">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <cc:license
+ rdf:resource="http://web.resource.org/cc/PublicDomain" />
+ <dc:language>en</dc:language>
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10.0"
+ guidetolerance="10.0"
+ id="base"
+ inkscape:current-layer="svg2"
+ inkscape:cx="63.25448"
+ inkscape:cy="98.118112"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:window-height="705"
+ inkscape:window-width="1366"
+ inkscape:window-x="-8"
+ inkscape:window-y="-8"
+ inkscape:zoom="2.1796875"
+ objecttolerance="10.0"
+ pagecolor="#ffffff"
+ showgrid="false"
+ inkscape:window-maximized="1"
+ inkscape:measure-start="0,0"
+ inkscape:measure-end="0,0"
+ inkscape:lockguides="true" />
+ <g
+ id="g1327"
+ transform="matrix(0.04083073,0,0,0.04083073,-0.1767767,176.93977)">
+ <path
+ d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 v 450.123 c 0,40.844 20.894,62.229 62.192,62.229 H 515.92 c 41.307,0 62.229,-20.316 62.229,-62.229 V 66.804 c 0,-42.601 -20.922,-65.036 -63.522,-65.036 -0.003,0 -448.494,-0.143 -448.352,0 z"
+ id="path1329"
+ style="fill:#111111;fill-opacity:0;stroke:#eeeeee;stroke-width:3.40799999;stroke-opacity:0"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ id="g2319"
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
+ <path
+ d=""
+ id="path2323"
+ style="fill:#0089cd;stroke:none"
+ inkscape:connector-curvature="0" />
+ </g>
+ <g
+ id="g2325"
+ transform="matrix(0.04083073,0,0,0.04083073,35.725326,178.44255)">
+ <path
+ d=""
+ id="path2329"
+ style="fill:#0089cd;stroke:none"
+ inkscape:connector-curvature="0" />
+ </g>
+ <path
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:19.49269104px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 9.1798926,59.466906 H 190.52231 L 99.851101,2.7306848 Z"
+ id="path925"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccc" />
+ <rect
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.1354475;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect927"
+ width="160.5358"
+ height="10.516355"
+ x="19.583216"
+ y="61.701366" />
+ <path
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.29089642;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="m 16.846267,171.67451 v 10.51391 H 8.0568816 v 15.54226 H 191.64467 v -15.54226 h -8.78936 v -10.51391 z"
+ id="rect927-7"
+ inkscape:connector-curvature="0" />
+ <rect
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.59141922;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect960"
+ width="18.032125"
+ height="93.275604"
+ x="27.863939"
+ y="74.209015" />
+ <rect
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.59141922;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect960-2"
+ width="18.032125"
+ height="93.275604"
+ x="154.58975"
+ y="74.209015" />
+ <rect
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.59141922;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect960-9"
+ width="18.032125"
+ height="93.275604"
+ x="122.90829"
+ y="74.209015" />
+ <rect
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.59141922;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect960-0"
+ width="18.032125"
+ height="93.275604"
+ x="59.545391"
+ y="74.209015" />
+ <rect
+ style="fill:#0089cd;fill-opacity:1;stroke:none;stroke-width:9.59141922;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect960-3"
+ width="18.032125"
+ height="93.275604"
+ x="91.22686"
+ y="74.209015" />
+</svg>
diff --git a/navit/icons/gui_android_menu.svg b/navit/icons/gui_android_menu.svg
index b47eae076..d8c25757b 100644
--- a/navit/icons/gui_android_menu.svg
+++ b/navit/icons/gui_android_menu.svg
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
@@ -9,112 +11,112 @@
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="48"
height="48"
- viewBox="0 0 48 48"
id="svg2"
version="1.1"
- inkscape:version="0.91 r13725"
- sodipodi:docname="gui_android_menu.svg">
- <metadata
- id="metadata12">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="gui_android_menu.svg"
+ inkscape:export-filename="/home/vonglasowm/src/navit-goodies/png/xxhdpi/gui_menu_xxhdpi.png"
+ inkscape:export-xdpi="269.99988"
+ inkscape:export-ydpi="269.99988">
<defs
- id="defs10" />
+ id="defs4">
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath428">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path430" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath416">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path418" />
+ </clipPath>
+ </defs>
<sodipodi:namedview
+ id="base"
pagecolor="#ffffff"
bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:window-width="1280"
- inkscape:window-height="948"
- id="namedview8"
- showgrid="true"
- inkscape:zoom="9.8333333"
- inkscape:cx="24"
+ inkscape:zoom="15.8125"
+ inkscape:cx="10.656127"
inkscape:cy="24"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1000"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="1"
- inkscape:current-layer="svg2"
- fit-margin-top="16"
- fit-margin-bottom="16"
- fit-margin-left="22"
- fit-margin-right="22"
- showguides="true"
- inkscape:guide-bbox="true">
- <sodipodi:guide
- position="0,12"
- orientation="0,1"
- id="guide4284"
- inkscape:label=""
- inkscape:color="rgb(0,0,255)" />
+ inkscape:object-nodes="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true">
<sodipodi:guide
- position="0,36"
orientation="0,1"
- id="guide4286"
- inkscape:label=""
- inkscape:color="rgb(0,0,255)" />
+ position="0,40"
+ id="guide2985"
+ inkscape:locked="false" />
<sodipodi:guide
- position="0,16"
orientation="0,1"
- id="guide4288"
- inkscape:label=""
- inkscape:color="rgb(0,0,255)" />
+ position="0,8"
+ id="guide2987"
+ inkscape:locked="false" />
<sodipodi:guide
- position="0,32"
- orientation="0,1"
- id="guide4290"
- inkscape:label=""
- inkscape:color="rgb(0,0,255)" />
- <sodipodi:guide
- position="12,0"
- orientation="1,0"
- id="guide4292"
- inkscape:label=""
- inkscape:color="rgb(0,0,255)" />
- <sodipodi:guide
- position="16,0"
orientation="1,0"
- id="guide4294"
- inkscape:label=""
- inkscape:color="rgb(0,0,255)" />
+ position="8,0"
+ id="guide2989"
+ inkscape:locked="false" />
<sodipodi:guide
- position="32,0"
orientation="1,0"
- id="guide4296"
- inkscape:label=""
- inkscape:color="rgb(0,0,255)" />
- <sodipodi:guide
- position="36,0"
- orientation="1,0"
- id="guide4298"
- inkscape:label=""
- inkscape:color="rgb(0,0,255)" />
+ position="40,0"
+ id="guide2991"
+ inkscape:locked="false" />
<inkscape:grid
type="xygrid"
- id="grid4300" />
+ id="grid3763"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
- <circle
- style="fill:#1a6cb6;stroke:none;stroke-width:0.79100001;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;fill-opacity:1"
- id="path4302"
- cx="24"
- cy="24"
- r="24" />
- <path
- d="m 24,20 c 1.1,0 2,-0.9 2,-2 0,-1.1 -0.9,-2 -2,-2 -1.1,0 -2,0.9 -2,2 0,1.1 0.9,2 2,2 z m 0,2 c -1.1,0 -2,0.9 -2,2 0,1.1 0.9,2 2,2 1.1,0 2,-0.9 2,-2 0,-1.1 -0.9,-2 -2,-2 z m 0,6 c -1.1,0 -2,0.9 -2,2 0,1.1 0.9,2 2,2 1.1,0 2,-0.9 2,-2 0,-1.1 -0.9,-2 -2,-2 z"
- id="path6"
- inkscape:connector-curvature="0"
- style="fill:#ffffff" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1004.3622)">
+ <rect
+ style="fill:#000000;fill-opacity:0.62745098;stroke:none"
+ id="rect2993"
+ width="48"
+ height="48.000019"
+ x="3.5527137e-15"
+ y="1004.3622"
+ rx="4" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 24,1020.3622 c 2.21,0 4,-1.79 4,-4 0,-2.21 -1.79,-4 -4,-4 -2.21,0 -4,1.79 -4,4 0,2.21 1.79,4 4,4 z m 0,4 c -2.21,0 -4,1.79 -4,4 0,2.21 1.79,4 4,4 2.21,0 4,-1.79 4,-4 0,-2.21 -1.79,-4 -4,-4 z m 0,12 c -2.21,0 -4,1.79 -4,4 0,2.21 1.79,4 4,4 2.21,0 4,-1.79 4,-4 0,-2.21 -1.79,-4 -4,-4 z"
+ id="path2"
+ style="fill:#ffffff" />
+ </g>
</svg>
diff --git a/navit/icons/gui_layers.svg b/navit/icons/gui_layers.svg
index 810b5a1d6..44bb0a32e 100644
--- a/navit/icons/gui_layers.svg
+++ b/navit/icons/gui_layers.svg
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="18.02128" height="18" id="svg5952">
- <defs id="defs5954">
- <linearGradient id="linearGradient2485-94">
- <stop id="stop2486-7" style="stop-color:#ffffff;stop-opacity:1" offset="0"/>
- <stop id="stop2487-83" style="stop-color:#aaaaaa;stop-opacity:1" offset="1"/>
- </linearGradient>
- <linearGradient id="linearGradient5704-5">
- <stop id="stop5706-120" style="stop-color:#5a5a5a;stop-opacity:1" offset="0"/>
- <stop id="stop5708-16" style="stop-color:#000000;stop-opacity:1" offset="1"/>
- </linearGradient>
- <linearGradient x1="974.19751" y1="182.46863" x2="979.80444" y2="184.8026" id="linearGradient4351" xlink:href="#linearGradient2485-94" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-173.95451)"/>
- <linearGradient x1="968.88806" y1="178.31856" x2="977.93347" y2="181.70978" id="linearGradient4353" xlink:href="#linearGradient5704-5" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-173.95451)"/>
- <linearGradient x1="974.19751" y1="182.46863" x2="979.80444" y2="184.8026" id="linearGradient4356" xlink:href="#linearGradient2485-94" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-170.95451)"/>
- <linearGradient x1="968.88806" y1="178.31856" x2="977.93347" y2="181.70978" id="linearGradient4358" xlink:href="#linearGradient5704-5" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-170.95451)"/>
- <linearGradient x1="974.19751" y1="182.46863" x2="979.80444" y2="184.8026" id="linearGradient4362" xlink:href="#linearGradient2485-94" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-167.95454)"/>
- <linearGradient x1="968.88806" y1="178.31856" x2="977.93347" y2="181.70978" id="linearGradient4364" xlink:href="#linearGradient5704-5" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-167.95454)"/>
- </defs>
- <metadata id="metadata5957">
- <rdf:RDF>
- <cc:Work rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
- <dc:title/>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <use transform="translate(-961.86731,-168.04527)" id="use13602" x="0" y="0" width="1250" height="1250" xlink:href="#rect12856"/>
- <path d="m 5.5212776,14.545453 11.0000004,0 -4,-4.9999999 -11.0000004,0 4,4.9999999 z" id="use8977" style="color:#000000;fill:url(#linearGradient4362);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4364);stroke-width:0.99994743;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;display:inline"/>
- <path d="m 5.5212776,11.545483 11.0000004,0 -4,-4.9999999 -11.0000004,0 4,4.9999999 z" id="use8059" style="color:#000000;fill:url(#linearGradient4356);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4358);stroke-width:0.99994743;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;display:inline"/>
- <path d="m 5.5212776,8.5454831 11.0000004,0 -4,-5 -11.0000004,0 4,5 z" id="use8061" style="color:#000000;fill:url(#linearGradient4351);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4353);stroke-width:0.99994743;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;display:inline"/>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="18.02128" height="18" id="svg5952">
+ <defs id="defs5954">
+ <linearGradient id="linearGradient2485-94">
+ <stop id="stop2486-7" style="stop-color:#ffffff;stop-opacity:1" offset="0"/>
+ <stop id="stop2487-83" style="stop-color:#aaaaaa;stop-opacity:1" offset="1"/>
+ </linearGradient>
+ <linearGradient id="linearGradient5704-5">
+ <stop id="stop5706-120" style="stop-color:#5a5a5a;stop-opacity:1" offset="0"/>
+ <stop id="stop5708-16" style="stop-color:#000000;stop-opacity:1" offset="1"/>
+ </linearGradient>
+ <linearGradient x1="974.19751" y1="182.46863" x2="979.80444" y2="184.8026" id="linearGradient4351" xlink:href="#linearGradient2485-94" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-173.95451)"/>
+ <linearGradient x1="968.88806" y1="178.31856" x2="977.93347" y2="181.70978" id="linearGradient4353" xlink:href="#linearGradient5704-5" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-173.95451)"/>
+ <linearGradient x1="974.19751" y1="182.46863" x2="979.80444" y2="184.8026" id="linearGradient4356" xlink:href="#linearGradient2485-94" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-170.95451)"/>
+ <linearGradient x1="968.88806" y1="178.31856" x2="977.93347" y2="181.70978" id="linearGradient4358" xlink:href="#linearGradient5704-5" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-170.95451)"/>
+ <linearGradient x1="974.19751" y1="182.46863" x2="979.80444" y2="184.8026" id="linearGradient4362" xlink:href="#linearGradient2485-94" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-167.95454)"/>
+ <linearGradient x1="968.88806" y1="178.31856" x2="977.93347" y2="181.70978" id="linearGradient4364" xlink:href="#linearGradient5704-5" gradientUnits="userSpaceOnUse" gradientTransform="translate(-963.97872,-167.95454)"/>
+ </defs>
+ <metadata id="metadata5957">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+ <dc:title/>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <use transform="translate(-961.86731,-168.04527)" id="use13602" x="0" y="0" width="1250" height="1250" xlink:href="#rect12856"/>
+ <path d="m 5.5212776,14.545453 11.0000004,0 -4,-4.9999999 -11.0000004,0 4,4.9999999 z" id="use8977" style="color:#000000;fill:url(#linearGradient4362);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4364);stroke-width:0.99994743;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;display:inline"/>
+ <path d="m 5.5212776,11.545483 11.0000004,0 -4,-4.9999999 -11.0000004,0 4,4.9999999 z" id="use8059" style="color:#000000;fill:url(#linearGradient4356);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4358);stroke-width:0.99994743;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;display:inline"/>
+ <path d="m 5.5212776,8.5454831 11.0000004,0 -4,-5 -11.0000004,0 4,5 z" id="use8061" style="color:#000000;fill:url(#linearGradient4351);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient4353);stroke-width:0.99994743;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;display:inline"/>
</svg> \ No newline at end of file
diff --git a/navit/icons/gui_map.svg b/navit/icons/gui_map.svg
index efdc2662b..19298dbc9 100644
--- a/navit/icons/gui_map.svg
+++ b/navit/icons/gui_map.svg
@@ -763,7 +763,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8748);stroke-miterlimit:4"
width="10.784556"
height="16.411282"
- href="62169F0D.png"
id="image6522"
x="61.522053"
y="-11.413214" />
@@ -771,7 +770,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8750);stroke-miterlimit:4"
width="2.3444688"
height="2.3444688"
- href="62169F0E.png"
id="image6530"
x="61.990948"
y="-10.94432" />
@@ -788,7 +786,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8756);stroke-miterlimit:4"
width="5.6267252"
height="4.6889377"
- href="62169F0F.png"
id="image6538"
x="58.708691"
y="-12.819895" />
@@ -796,7 +793,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8758);stroke-miterlimit:4"
width="2.3444688"
height="2.3444688"
- href="62169F10.png"
id="image6546"
x="62.928734"
y="-9.5376387" />
@@ -813,7 +809,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8764);stroke-miterlimit:4"
width="2.3444688"
height="3.2822564"
- href="62169F11.png"
id="image6554"
x="63.397629"
y="-10.006532" />
@@ -830,7 +825,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8770);stroke-miterlimit:4"
width="9.8467684"
height="17.34907"
- href="62169F12.png"
id="image6562"
x="52.144176"
y="-11.413214" />
@@ -838,7 +832,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8772);stroke-miterlimit:4"
width="2.3444688"
height="2.3444688"
- href="62169F13.png"
id="image6570"
x="57.770901"
y="-10.94432" />
@@ -855,7 +848,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8778);stroke-miterlimit:4"
width="4.2200437"
height="3.2822564"
- href="62169F14.png"
id="image6578"
x="56.36422"
y="-11.882107" />
@@ -863,7 +855,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8780);stroke-miterlimit:4"
width="3.7511499"
height="2.8133626"
- href="2D44FCEC.png"
id="image6606"
x="57.30201"
y="-12.819895" />
@@ -880,7 +871,6 @@
style="opacity:0.75;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8786);stroke-miterlimit:4"
width="2.3444688"
height="2.3444688"
- href="2D44FCED.png"
id="image6614"
x="58.239796"
y="-8.5998507" />
@@ -897,7 +887,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8792);stroke-miterlimit:4"
width="10.784556"
height="16.411282"
- href="2D44FCEE.png"
id="image6624"
x="61.522053"
y="-11.413214" />
@@ -905,7 +894,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8794);stroke-miterlimit:4"
width="2.3444688"
height="2.3444688"
- href="2D44FCEF.png"
id="image6632"
x="61.990948"
y="-10.94432" />
@@ -913,7 +901,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8796);stroke-miterlimit:4"
width="5.6267252"
height="4.6889377"
- href="2D44FCF0.png"
id="image6640"
x="58.708691"
y="-12.819895" />
@@ -921,7 +908,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8798);stroke-miterlimit:4"
width="2.3444688"
height="2.3444688"
- href="2D44FCF1.png"
id="image6648"
x="62.928734"
y="-9.5376387" />
@@ -929,7 +915,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8800);stroke-miterlimit:4"
width="2.3444688"
height="3.2822564"
- href="2D44FCF2.png"
id="image6656"
x="63.397629"
y="-10.006532" />
@@ -937,7 +922,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8802);stroke-miterlimit:4"
width="9.8467684"
height="17.34907"
- href="2D44FCF3.png"
id="image6664"
x="52.144176"
y="-11.413214" />
@@ -945,7 +929,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8804);stroke-miterlimit:4"
width="2.3444688"
height="2.3444688"
- href="2D44FCF4.png"
id="image6672"
x="57.770901"
y="-10.94432" />
@@ -953,7 +936,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8806);stroke-miterlimit:4"
width="4.2200437"
height="3.2822564"
- href="2D44FCF5.png"
id="image6680"
x="56.36422"
y="-11.882107" />
@@ -961,7 +943,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8808);stroke-miterlimit:4"
width="3.7511499"
height="2.8133626"
- href="2D44FD11.png"
id="image6708"
x="57.30201"
y="-12.819895" />
@@ -969,7 +950,6 @@
style="opacity:0.15750002;fill:#ffffff;fill-rule:nonzero;stroke:url(#radialGradient8810);stroke-miterlimit:4"
width="2.3444688"
height="2.3444688"
- href="2D44FD12.png"
id="image6716"
x="58.239796"
y="-8.5998507" />
diff --git a/navit/icons/navit_svg2png b/navit/icons/navit_svg2png
index 675207561..668613a61 100755
--- a/navit/icons/navit_svg2png
+++ b/navit/icons/navit_svg2png
@@ -1,5 +1,14 @@
#!/bin/sh
+exitwithhelp()
+{
+ echo "Usage: navit_svg2png <conversion_tool> <output_png_filename> [<width_px> <height_px>]"
+ echo "The input filename is the same than the output png one with svg or svgz extension"
+ echo "Possible conversion tools: ksvgtopng, ksvgtopng4, rsvg-convert, inkscape and convert"
+ echo "width_px and height_px arguments can be omitted if output png size is specified in the filename, like this: imagename_WIDTH_HEIGHT.png (ex. myPng_100_100.png)"
+ exit
+}
+
svgtopng()
{
case $svgtopng in
@@ -15,6 +24,10 @@ svgtopng()
*convert)
$svgtopng -alpha on -background none $3 -resize $1x$2 $4
;;
+ *)
+ echo "Error: unknown conversion tool"
+ exitwithhelp # unknown conversion tool
+ ;;
esac
}
@@ -26,8 +39,27 @@ svgtopng=$1
png=$2
w=$3
h=$4
+
+# if -h or --help arg is passed, print help and exit
+case "$1" in
+ '-h'|'--help'|'')
+ exitwithhelp
+ ;;
+esac
+
+# args num must be == 2 or == 4
+if [ "$#" -ne 2 ] && [ "$#" -ne 4 ];
+then
+ echo "Error: wrong number of arguments"
+ exitwithhelp
+fi
+
case "$png" in
*_[1-9]*_[1-9]*.png)
+ if [ "$#" -ne 2 ]; then
+ echo "Error: output png size is specified by filename and by arguments, plese use only one"
+ exitwithhelp # png size musn't be specifed, only in filename
+ fi
svg=${png%_*_*.png};
h=${png##*_}
w=${png%_$h}
@@ -35,6 +67,10 @@ case "$png" in
w=${w##*_}
;;
*)
+ if [ "$#" -ne 4 ]; then
+ echo "Error: please, specify output png size"
+ exitwithhelp # filename doesn't specify png size, must be done with args 3 and 4
+ fi
svg=${png%.png}
;;
esac
diff --git a/navit/icons/sound_off.svg b/navit/icons/sound_off.svg
new file mode 100644
index 000000000..b721a7243
--- /dev/null
+++ b/navit/icons/sound_off.svg
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="sound_off.svg"
+ inkscape:export-filename="/home/michael/src/navit-artwork/gui_sound_off.png"
+ inkscape:export-xdpi="134.99994"
+ inkscape:export-ydpi="134.99994">
+ <defs
+ id="defs4">
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath428">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path430" />
+ </clipPath>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="15.8125"
+ inkscape:cx="12.237154"
+ inkscape:cy="24"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1000"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true">
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,40"
+ id="guide2985"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,8"
+ id="guide2987"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="8,0"
+ id="guide2989"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="40,0"
+ id="guide2991"
+ inkscape:locked="false" />
+ <inkscape:grid
+ type="xygrid"
+ id="grid3763"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1004.3622)">
+ <rect
+ style="fill:#000000;fill-opacity:0.62745098;stroke:none"
+ id="rect2993"
+ width="48"
+ height="48.000019"
+ x="3.5527137e-15"
+ y="1004.3622"
+ rx="4" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 32,1028.3622 c 0,-3.1378 -1.813333,-5.8489 -4.444444,-7.1556 v 3.9289 L 31.92,1029.5 c 0.05333,-0.3734 0.08,-0.7556 0.08,-1.1378 z m 4.444444,0 c 0,1.6711 -0.364444,3.2444 -0.96,4.6933 l 2.693334,2.6934 C 39.333333,1033.5355 40,1031.0289 40,1028.3622 c 0,-7.6089 -5.324444,-13.9733 -12.444444,-15.5911 v 3.6711 c 5.137777,1.5289 8.888888,6.2844 8.888888,11.92 z m -26.177777,-16 L 8,1014.6289 l 8.4,8.4 H 8 v 10.6666 h 7.111111 L 24,1042.5844 v -11.9555 l 7.564444,7.5644 c -1.191111,0.9156 -2.533333,1.6533 -4.008888,2.0978 v 3.6711 c 2.444444,-0.56 4.675555,-1.68 6.551111,-3.2178 l 3.626666,3.6178 2.266667,-2.2667 -16,-16 z M 24,1014.14 20.284444,1017.8555 24,1021.5711 Z"
+ id="path2"
+ style="stroke-width:0.8888889;fill:#ffffff" />
+ </g>
+</svg>
diff --git a/navit/icons/sound_on.svg b/navit/icons/sound_on.svg
new file mode 100644
index 000000000..ce405c97f
--- /dev/null
+++ b/navit/icons/sound_on.svg
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="sound_on.svg"
+ inkscape:export-filename="/home/michael/src/navit-artwork/gui_sound.png"
+ inkscape:export-xdpi="134.99994"
+ inkscape:export-ydpi="134.99994">
+ <defs
+ id="defs4">
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath428">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path430" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath416">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path418" />
+ </clipPath>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="15.8125"
+ inkscape:cx="21.249012"
+ inkscape:cy="24"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1000"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true"
+ inkscape:object-nodes="false">
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,40"
+ id="guide2985"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,8"
+ id="guide2987"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="8,0"
+ id="guide2989"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="40,0"
+ id="guide2991"
+ inkscape:locked="false" />
+ <inkscape:grid
+ type="xygrid"
+ id="grid3763"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1004.3622)">
+ <rect
+ style="fill:#000000;fill-opacity:0.62745098;stroke:none"
+ id="rect2993"
+ width="48"
+ height="48.000019"
+ x="3.5527137e-15"
+ y="1004.3622"
+ rx="4" />
+ <path
+ inkscape:connector-curvature="0"
+ d="m 8,1023.0288 v 10.6666 h 7.111111 L 24,1042.5843 v -28.4444 l -8.888889,8.8889 z m 24,5.3333 c 0,-3.1378 -1.813333,-5.8489 -4.444444,-7.1555 v 14.32 C 30.186667,1034.211 32,1031.4999 32,1028.3621 Z m -4.444444,-15.5911 v 3.6711 c 5.137777,1.5289 8.888888,6.2845 8.888888,11.92 0,5.6356 -3.751111,10.3911 -8.888888,11.92 v 3.6711 C 34.675556,1042.3354 40,1035.9799 40,1028.3621 c 0,-7.6178 -5.324444,-13.9733 -12.444444,-15.5911 z"
+ id="path2"
+ style="stroke-width:0.8888889;fill:#ffffff" />
+ </g>
+</svg>
diff --git a/navit/icons/status_position_wait_bk.svg b/navit/icons/status_position_wait_bk.svg
index 9d1b7ca33..ac2096a99 100644
--- a/navit/icons/status_position_wait_bk.svg
+++ b/navit/icons/status_position_wait_bk.svg
@@ -57,11 +57,26 @@
id="grid4140" />
</sodipodi:namedview>
<path
- d="M 24 0 C 14.712 0 7.1992187 7.5127812 7.1992188 16.800781 C 7.1992188 29.400781 24 48 24 48 C 24 48 40.800781 29.400781 40.800781 16.800781 C 40.800781 7.5127812 33.288 2.3684758e-15 24 0 z M 24 4 C 31.131238 4 36.800781 9.6695427 36.800781 16.800781 C 36.800781 21.323004 33.110977 28.921035 29.085938 34.886719 C 26.543988 38.654253 25.528858 39.652618 24 41.476562 C 22.471142 39.652618 21.456012 38.654253 18.914062 34.886719 C 14.889022 28.921035 11.199219 21.323004 11.199219 16.800781 C 11.199219 9.6695427 16.868761 4 24 4 z "
+ d="M 24,0 C 14.712,0 7.1992188,7.5127812 7.1992188,16.800781 c 0,6.3 4.2001952,9.099414 8.4003902,15.324219 C 19.799805,38.349805 24,48 24,48 c 0,0 4.200195,-9.650195 8.40039,-15.875 4.200196,-6.224804 8.400391,-9.024219 8.400391,-15.324219 C 40.800781,7.5127812 33.288,0 24,0 Z m 0,4 C 31.131238,4 36.800781,9.6695427 36.800781,16.800781 36.736982,22 35.172,22.774 31.086,27.887 27,33 26,37.000219 24,40.476781 22,37.000219 20.828,32.774 16.914,27.887 13,23 11.199219,22 11.199219,16.800781 11.199219,9.6695427 16.868761,4 24,4 Z"
transform="scale(0.5,0.5)"
- id="path4" />
+ id="path4"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ssscssssczczcs" />
<path
d="M0 0h24v24H0z"
fill="none"
id="path6" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 9.2741765,7 C 9.2741765,7 10,5 12,5 c 2,0 3,1.2462169 3,3 0,1.7537831 -2.293761,2 -3,3 0,1.23884 0,2.5 0,2.5"
+ id="path4137"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="czzcc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 12,14.716639 12,16"
+ id="path4139"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
</svg>
diff --git a/navit/icons/status_position_wait_wh.svg b/navit/icons/status_position_wait_wh.svg
index 8bce336df..8dacc2e65 100644
--- a/navit/icons/status_position_wait_wh.svg
+++ b/navit/icons/status_position_wait_wh.svg
@@ -57,12 +57,26 @@
id="grid4140" />
</sodipodi:namedview>
<path
- d="M 24 0 C 14.712 0 7.1992187 7.5127812 7.1992188 16.800781 C 7.1992188 29.400781 24 48 24 48 C 24 48 40.800781 29.400781 40.800781 16.800781 C 40.800781 7.5127812 33.288 2.3684758e-15 24 0 z M 24 4 C 31.131238 4 36.800781 9.6695427 36.800781 16.800781 C 36.800781 21.323004 33.110977 28.921035 29.085938 34.886719 C 26.543988 38.654253 25.528858 39.652618 24 41.476562 C 22.471142 39.652618 21.456012 38.654253 18.914062 34.886719 C 14.889022 28.921035 11.199219 21.323004 11.199219 16.800781 C 11.199219 9.6695427 16.868761 4 24 4 z "
+ d="M 24,0 C 14.712,0 7.1992188,7.5127812 7.1992188,16.800781 c 0,6.3 4.2001952,9.099414 8.4003902,15.324219 C 19.799805,38.349805 24,48 24,48 c 0,0 4.200195,-9.650195 8.40039,-15.875 4.200196,-6.224804 8.400391,-9.024219 8.400391,-15.324219 C 40.800781,7.5127812 33.288,0 24,0 Z m 0,4 C 31.131238,4 36.800781,9.6695427 36.800781,16.800781 36.736982,22 35.172,22.774 31.086,27.887 27,33 26,37.000219 24,40.476781 22,37.000219 20.828,32.774 16.914,27.887 13,23 11.199219,22 11.199219,16.800781 11.199219,9.6695427 16.868761,4 24,4 Z"
transform="scale(0.5,0.5)"
id="path4"
- style="fill:#ffffff" />
+ style="fill:#ffffff"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ssscssssczczcs" />
<path
d="M0 0h24v24H0z"
fill="none"
id="path6" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 9.2741765,7 C 9.2741765,7 10,5 12,5 c 2,0 3,1.2462169 3,3 0,1.7537831 -2.293761,2 -3,3 0,1.23884 0,2.5 0,2.5"
+ id="path4137"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="czzcc" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 12,14.716639 12,16"
+ id="path4139"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cc" />
</svg>
diff --git a/navit/icons/zoom_auto.svg b/navit/icons/zoom_auto.svg
new file mode 100644
index 000000000..9136b8dea
--- /dev/null
+++ b/navit/icons/zoom_auto.svg
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="zoom_auto.svg"
+ inkscape:export-filename="/home/michael/src/navit-artwork/set_center_cursor.png"
+ inkscape:export-xdpi="134.99994"
+ inkscape:export-ydpi="134.99994">
+ <defs
+ id="defs4">
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath428">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path430" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath416">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path418" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath544">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path546" />
+ </clipPath>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="15.8125"
+ inkscape:cx="15.770278"
+ inkscape:cy="24"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1000"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true">
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,40"
+ id="guide2985"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,8"
+ id="guide2987"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="8,0"
+ id="guide2989"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="40,0"
+ id="guide2991"
+ inkscape:locked="false" />
+ <inkscape:grid
+ type="xygrid"
+ id="grid3763"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1004.3622)">
+ <rect
+ style="fill:#000000;fill-opacity:0.62745098;stroke:none"
+ id="rect2993"
+ width="48"
+ height="48.000019"
+ x="3.5527137e-15"
+ y="1004.3622"
+ rx="4" />
+ <g
+ id="g844"
+ transform="matrix(1.8296169,0,0,1.8296169,-19.444254,-858.16898)"
+ style="fill:#ffffff">
+ <path
+ sodipodi:nodetypes="cccssssccccccsssss"
+ inkscape:connector-curvature="0"
+ id="path2"
+ d="m 27.5,1033.3622 h -0.79 l -0.28,-0.27 c 0.98,-1.14 1.57,-2.62 1.57,-4.23 0,-3.59 -2.91,-6.5 -6.5,-6.5 -3.59,0 -6.5,2.91 -6.5,6.5 0,3.59 2.91,6.5 6.5,6.5 1.61,0 3.09,-0.59 4.23,-1.57 l 0.27,0.28 v 0.79 l 5,4.99 1.49,-1.49 z m -6,0 c -2.49,0 -4.5,-2.01 -4.5,-4.5 0,-2.49 2.01,-4.5 4.5,-4.5 2.49,0 4.5,2.01 4.5,4.5 0,2.49 -2.01,4.5 -4.5,4.5 z"
+ style="fill:#ffffff" />
+ <g
+ transform="translate(25.399517,1010.3004)"
+ id="text821-3"
+ style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ aria-label="A">
+ <path
+ inkscape:connector-curvature="0"
+ id="path850"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:6.66666651px;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';fill:#ffffff"
+ d="m -3.0453455,19.955254 h -1.7122396 l -0.3255208,0.976562 h -1.0384114 l 1.7643228,-4.739583 h 0.9049479 l 1.7740885,4.739583 h -1.0384114 z m -1.4485677,-0.791016 h 1.1848958 L -3.9047205,17.39015 Z" />
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/navit/icons/zoom_in.svg b/navit/icons/zoom_in.svg
index 18ff2dac8..cedcc7595 100644
--- a/navit/icons/zoom_in.svg
+++ b/navit/icons/zoom_in.svg
@@ -12,40 +12,90 @@
width="48"
height="48"
id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.48.0 r9654"
+ version="1.1"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="zoom_in.svg"
- inkscape:output_extension="org.inkscape.output.svg.inkscape"
- inkscape:export-filename="/home/zeroedout/share/usr/share/navit/xpm/zoom_in.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90"
- version="1.0">
+ inkscape:export-filename="/home/michael/src/navit-artwork/set_center_cursor.png"
+ inkscape:export-xdpi="134.99994"
+ inkscape:export-ydpi="134.99994">
<defs
- id="defs4" />
+ id="defs4">
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath428">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path430" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath416">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path418" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath544">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path546" />
+ </clipPath>
+ </defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
- gridtolerance="10000"
- guidetolerance="10"
- objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="7.919596"
- inkscape:cx="13.199956"
- inkscape:cy="14.64192"
+ inkscape:zoom="15.8125"
+ inkscape:cx="9.2964433"
+ inkscape:cy="24"
inkscape:document-units="px"
- inkscape:current-layer="g3036"
+ inkscape:current-layer="layer1"
showgrid="true"
- inkscape:window-width="1394"
- inkscape:window-height="968"
- inkscape:window-x="0"
- inkscape:window-y="20"
- width="48px"
- height="48px"
showguides="true"
- inkscape:window-maximized="0" />
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1000"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true">
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,40"
+ id="guide2985"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,8"
+ id="guide2987"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="8,0"
+ id="guide2989"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="40,0"
+ id="guide2991"
+ inkscape:locked="false" />
+ <inkscape:grid
+ type="xygrid"
+ id="grid3763"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
@@ -54,47 +104,27 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
- inkscape:label="lower copy"
- id="g3036"
- inkscape:groupmode="layer"
- style="display:inline"
- sodipodi:insensitive="true">
- <path
- transform="matrix(0.84928644,0,0,0.84928644,3.5710462,3.6632047)"
- d="m 47.603437,23.945744 a 23.549181,23.549181 0 1 1 -47.09836155,0 23.549181,23.549181 0 1 1 47.09836155,0 z"
- sodipodi:ry="23.549181"
- sodipodi:rx="23.549181"
- sodipodi:cy="23.945744"
- sodipodi:cx="24.054256"
- id="path3038"
- style="fill:#999999;fill-opacity:0.38536586;stroke:none;display:inline"
- sodipodi:type="arc" />
- <path
- transform="matrix(0.77851257,0,0,0.77851257,5.273459,5.3579376)"
- d="m 47.603437,23.945744 a 23.549181,23.549181 0 1 1 -47.09836155,0 23.549181,23.549181 0 1 1 47.09836155,0 z"
- sodipodi:ry="23.549181"
- sodipodi:rx="23.549181"
- sodipodi:cy="23.945744"
- sodipodi:cx="24.054256"
- id="path6552"
- style="fill:none;stroke:#999999;stroke-width:4.28166914;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline"
- sodipodi:type="arc" />
- </g>
- <g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
- sodipodi:insensitive="true"
- style="display:inline">
+ transform="translate(0,-1004.3622)">
+ <rect
+ style="fill:#000000;fill-opacity:0.62745098;stroke:none"
+ id="rect2993"
+ width="48"
+ height="48.000019"
+ x="3.5527137e-15"
+ y="1004.3622"
+ rx="4" />
<path
- id="path2178"
- style="fill:none;stroke:#999999;stroke-width:4.0538249;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker-start:none"
- d="m 12.508912,24 c 22.982175,0 22.982175,0 22.982175,0 m -11.63349,11.491087 0,-22.982175"
- inkscape:connector-curvature="0" />
+ inkscape:connector-curvature="0"
+ d="m 30.870212,1032.488 h -1.445398 l -0.512293,-0.494 c 1.793025,-2.0858 2.872499,-4.7936 2.872499,-7.7393 0,-6.5683 -5.324185,-11.8925 -11.89251,-11.8925 -6.568325,0 -11.89251,5.3242 -11.89251,11.8925 0,6.5683 5.324185,11.8925 11.89251,11.8925 2.945683,0 5.653516,-1.0795 7.73928,-2.8725 l 0.493996,0.5123 v 1.4454 l 9.148085,9.1298 L 40,1041.6361 Z m -10.977702,0 c -4.555746,0 -8.233276,-3.6775 -8.233276,-8.2333 0,-4.5557 3.67753,-8.2333 8.233276,-8.2333 4.555746,0 8.233276,3.6776 8.233276,8.2333 0,4.5558 -3.67753,8.2333 -8.233276,8.2333 z m 4.574042,-7.3185 h -3.659234 v 3.6593 h -1.829616 v -3.6593 h -3.659234 v -1.8296 h 3.659234 v -3.6592 h 1.829616 v 3.6592 h 3.659234 z"
+ id="path2"
+ style="stroke-width:1.8296169;fill:#ffffff" />
</g>
</svg>
diff --git a/navit/icons/zoom_manual.svg b/navit/icons/zoom_manual.svg
new file mode 100644
index 000000000..bf3f0faed
--- /dev/null
+++ b/navit/icons/zoom_manual.svg
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="zoom_manual.svg"
+ inkscape:export-filename="/home/michael/src/navit-artwork/set_center_cursor.png"
+ inkscape:export-xdpi="134.99994"
+ inkscape:export-ydpi="134.99994">
+ <defs
+ id="defs4">
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath428">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path430" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath416">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path418" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath544">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path546" />
+ </clipPath>
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="15.8125"
+ inkscape:cx="13.376125"
+ inkscape:cy="24"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ showguides="true"
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1000"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true">
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,40"
+ id="guide2985"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,8"
+ id="guide2987"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="8,0"
+ id="guide2989"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="40,0"
+ id="guide2991"
+ inkscape:locked="false" />
+ <inkscape:grid
+ type="xygrid"
+ id="grid3763"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1004.3622)">
+ <rect
+ style="fill:#000000;fill-opacity:0.62745098;stroke:none"
+ id="rect2993"
+ width="48"
+ height="48.000019"
+ x="3.5527137e-15"
+ y="1004.3622"
+ rx="4" />
+ <g
+ id="g841"
+ transform="matrix(1.8296169,0,0,1.8296169,-21.273871,-852.68013)"
+ style="fill:#ffffff">
+ <path
+ sodipodi:nodetypes="cccssssccccccsssss"
+ inkscape:connector-curvature="0"
+ id="path2"
+ d="m 28.5,1030.3622 h -0.79 l -0.28,-0.27 c 0.98,-1.14 1.57,-2.62 1.57,-4.23 0,-3.59 -2.91,-6.5 -6.5,-6.5 -3.59,0 -6.5,2.91 -6.5,6.5 0,3.59 2.91,6.5 6.5,6.5 1.61,0 3.09,-0.59 4.23,-1.57 l 0.27,0.28 v 0.79 l 5,4.99 1.49,-1.49 z m -6,0 c -2.49,0 -4.5,-2.01 -4.5,-4.5 0,-2.49 2.01,-4.5 4.5,-4.5 2.49,0 4.5,2.01 4.5,4.5 0,2.49 -2.01,4.5 -4.5,4.5 z"
+ style="fill:#ffffff" />
+ <g
+ transform="translate(13.033456,1016.3816)"
+ id="text821"
+ style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ aria-label="M">
+ <path
+ inkscape:connector-curvature="0"
+ id="path847"
+ style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:6.66666651px;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';fill:#ffffff"
+ d="M 8.2485857,7.1110504 9.4660335,10.54855 10.676971,7.1110504 h 1.282552 V 11.850634 H 10.979705 V 10.555061 L 11.077362,8.3187327 9.7980648,11.850634 H 9.1274919 L 7.8514503,8.3219879 7.9491065,10.555061 v 1.295573 H 6.972544 V 7.1110504 Z" />
+ </g>
+ </g>
+ </g>
+</svg>
diff --git a/navit/icons/zoom_out.svg b/navit/icons/zoom_out.svg
index 1d794efd2..907a703d3 100644
--- a/navit/icons/zoom_out.svg
+++ b/navit/icons/zoom_out.svg
@@ -12,48 +12,90 @@
width="48"
height="48"
id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.47 r22583"
- sodipodi:docname="zoom_in.svg"
- inkscape:output_extension="org.inkscape.output.svg.inkscape"
- inkscape:export-filename="/home/zeroedout/share/usr/share/navit/xpm/zoom_in.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90"
- version="1.0">
+ version="1.1"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="zoom_out.svg"
+ inkscape:export-filename="/home/michael/src/navit-artwork/zoom_in.png"
+ inkscape:export-xdpi="134.99994"
+ inkscape:export-ydpi="134.99994">
<defs
id="defs4">
- <inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="0 : 24 : 1"
- inkscape:vp_y="0 : 1000 : 0"
- inkscape:vp_z="48 : 24 : 1"
- inkscape:persp3d-origin="24 : 16 : 1"
- id="perspective11" />
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath428">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path430" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath416">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path418" />
+ </clipPath>
+ <clipPath
+ clipPathUnits="userSpaceOnUse"
+ id="clipPath544">
+ <path
+ inkscape:connector-curvature="0"
+ d="M 0,96 96,96 96,0 0,0 0,96 z"
+ id="path546" />
+ </clipPath>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
- gridtolerance="10000"
- guidetolerance="10"
- objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="7.919596"
- inkscape:cx="13.199956"
- inkscape:cy="14.64192"
+ inkscape:zoom="15.8125"
+ inkscape:cx="9.2964433"
+ inkscape:cy="24"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
- inkscape:window-width="1280"
- inkscape:window-height="973"
- inkscape:window-x="-6"
- inkscape:window-y="0"
- width="48px"
- height="48px"
showguides="true"
- inkscape:window-maximized="1" />
+ inkscape:guide-bbox="true"
+ inkscape:window-width="1920"
+ inkscape:window-height="1000"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="false"
+ inkscape:snap-bbox="true"
+ inkscape:bbox-nodes="true">
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,40"
+ id="guide2985"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="0,1"
+ position="0,8"
+ id="guide2987"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="8,0"
+ id="guide2989"
+ inkscape:locked="false" />
+ <sodipodi:guide
+ orientation="1,0"
+ position="40,0"
+ id="guide2991"
+ inkscape:locked="false" />
+ <inkscape:grid
+ type="xygrid"
+ id="grid3763"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
@@ -62,47 +104,27 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
- inkscape:label="lower copy"
- id="g3036"
- inkscape:groupmode="layer"
- style="display:inline"
- sodipodi:insensitive="true">
- <path
- transform="matrix(0.84928644,0,0,0.84928644,3.5710462,3.6632047)"
- d="m 47.603437,23.945744 a 23.549181,23.549181 0 1 1 -47.09836155,0 23.549181,23.549181 0 1 1 47.09836155,0 z"
- sodipodi:ry="23.549181"
- sodipodi:rx="23.549181"
- sodipodi:cy="23.945744"
- sodipodi:cx="24.054256"
- id="path3038"
- style="fill:#999999;fill-opacity:0.38536586;stroke:none;display:inline"
- sodipodi:type="arc" />
- <path
- transform="matrix(0.77851257,0,0,0.77851257,5.273459,5.3579376)"
- d="m 47.603437,23.945744 a 23.549181,23.549181 0 1 1 -47.09836155,0 23.549181,23.549181 0 1 1 47.09836155,0 z"
- sodipodi:ry="23.549181"
- sodipodi:rx="23.549181"
- sodipodi:cy="23.945744"
- sodipodi:cx="24.054256"
- id="path6552"
- style="fill:none;stroke:#999999;stroke-width:4.28166914;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline"
- sodipodi:type="arc" />
- </g>
- <g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
- style="display:inline">
+ transform="translate(0,-1004.3622)">
+ <rect
+ style="fill:#000000;fill-opacity:0.62745098;stroke:none"
+ id="rect2993"
+ width="48"
+ height="48.000019"
+ x="3.5527137e-15"
+ y="1004.3622"
+ rx="4" />
<path
- id="path2178"
- style="fill:none;stroke:#999999;stroke-width:4.0538249;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dashoffset:0;marker-start:none"
- d="m 12.508912,24 c 22.982175,0 22.982175,0 22.982175,0"
inkscape:connector-curvature="0"
- sodipodi:nodetypes="cc" />
+ d="m 30.870212,1032.488 h -1.445398 l -0.512293,-0.494 c 1.793025,-2.0858 2.872499,-4.7936 2.872499,-7.7393 0,-6.5683 -5.324185,-11.8925 -11.89251,-11.8925 -6.568325,0 -11.89251,5.3242 -11.89251,11.8925 0,6.5683 5.324185,11.8925 11.89251,11.8925 2.945683,0 5.653516,-1.0795 7.73928,-2.8725 l 0.493996,0.5123 v 1.4454 l 9.148085,9.1298 L 40,1041.6361 Z m -10.977702,0 c -4.555746,0 -8.233276,-3.6775 -8.233276,-8.2333 0,-4.5557 3.67753,-8.2333 8.233276,-8.2333 4.555746,0 8.233276,3.6776 8.233276,8.2333 0,4.5558 -3.67753,8.2333 -8.233276,8.2333 z m -4.574042,-9.1481 h 9.148084 v 1.8296 h -9.148084 z"
+ id="path2"
+ style="stroke-width:1.8296169;fill:#ffffff" />
</g>
</svg>
diff --git a/navit/iphone/downloader/Classes/DownloaderAppDelegate.h b/navit/iphone/downloader/Classes/DownloaderAppDelegate.h
index 3227e6b8f..e0cc8dc10 100644
--- a/navit/iphone/downloader/Classes/DownloaderAppDelegate.h
+++ b/navit/iphone/downloader/Classes/DownloaderAppDelegate.h
@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
@interface DownloaderAppDelegate : NSObject <UIApplicationDelegate> {
-
+
UIWindow *window;
UINavigationController *navigationController;
}
diff --git a/navit/iphone/downloader/Classes/DownloaderAppDelegate.m b/navit/iphone/downloader/Classes/DownloaderAppDelegate.m
index ff8a093a8..51b0d3705 100644
--- a/navit/iphone/downloader/Classes/DownloaderAppDelegate.m
+++ b/navit/iphone/downloader/Classes/DownloaderAppDelegate.m
@@ -19,10 +19,10 @@
#pragma mark -
#pragma mark Application lifecycle
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
-
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+
// Override point for customization after application launch.
-
+
// Set the navigation controller as the window's root view controller and display.
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
@@ -41,7 +41,7 @@
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
- Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
}
diff --git a/navit/iphone/downloader/Classes/DownloaderDetailViewController.m b/navit/iphone/downloader/Classes/DownloaderDetailViewController.m
index 97e24b1c4..2b1633ece 100644
--- a/navit/iphone/downloader/Classes/DownloaderDetailViewController.m
+++ b/navit/iphone/downloader/Classes/DownloaderDetailViewController.m
@@ -28,7 +28,7 @@
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
-
+
// Sets the Navigation bar to have the location name
self.title = [self.locationName objectForKey:NAME_KEY];
@@ -47,7 +47,7 @@
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
-
+
// Release any cached data, images, etc. that aren't in use.
}
@@ -60,7 +60,7 @@
-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
-
+
- (void)dealloc {
[locationName_ release];
[super dealloc];
diff --git a/navit/iphone/downloader/Classes/RootViewController.h b/navit/iphone/downloader/Classes/RootViewController.h
index 5cfe64cd4..2d8a6b7af 100644
--- a/navit/iphone/downloader/Classes/RootViewController.h
+++ b/navit/iphone/downloader/Classes/RootViewController.h
@@ -8,10 +8,10 @@
#import <UIKit/UIKit.h>
-@interface RootViewController : UITableViewController
+@interface RootViewController : UITableViewController
{
NSMutableArray* locations_;
-
+
}
@property (nonatomic, retain) NSMutableArray* locations;
diff --git a/navit/iphone/downloader/Classes/RootViewController.m b/navit/iphone/downloader/Classes/RootViewController.m
index d2820fe3c..9bf6c855e 100644
--- a/navit/iphone/downloader/Classes/RootViewController.m
+++ b/navit/iphone/downloader/Classes/RootViewController.m
@@ -20,14 +20,14 @@
- (void)viewDidLoad {
[super viewDidLoad];
-
+
// Sets the title of the Navigation bar.
self.title= @"Navit Map Downloader";
-
+
// Loads in the array for locations and their associated bounding boxes
NSString *path = [[NSBundle mainBundle] pathForResource:@"LocationsArray" ofType:@"plist"];
- locations_ = [[NSMutableArray alloc] initWithContentsOfFile:path];
-
+ locations_ = [[NSMutableArray alloc] initWithContentsOfFile:path];
+
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
@@ -80,21 +80,21 @@
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
+
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
// Configure the cell.
-
+
// Gets the location name from LocationsArray.plist
cell.textLabel.text = [[self.locations objectAtIndex:indexPath.row] objectForKey:NAME_KEY];
-
+
//Makes the fancy arrows to the left of the region being downloaded (e.g. "Ireland > " )
- cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
+ cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
@@ -111,14 +111,14 @@
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
-
+
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
+ }
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
- }
+ }
}
*/
@@ -143,18 +143,18 @@
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
+
DownloaderDetailViewController *detailViewController = [[DownloaderDetailViewController alloc] initWithNibName:@"DownloaderDetailViewController" bundle:nil];
- // Sets the "Back" button in the next ViewController (DownloaderDetailViewController).
+ // Sets the "Back" button in the next ViewController (DownloaderDetailViewController).
// Which, be default, pulls the name from the previous ViewController
// Here, we manually call it the text label "Back"
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil] autorelease];
-
+
// Pass the selected object to the new view controller.
detailViewController.locationName = [self.locations objectAtIndex:indexPath.row];
- [self.navigationController pushViewController:detailViewController animated:YES];
-
+ [self.navigationController pushViewController:detailViewController animated:YES];
+
[DownloaderDetailViewController release];
}
@@ -165,7 +165,7 @@
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
-
+
// Relinquish ownership any cached data, images, etc that aren't in use.
}
diff --git a/navit/iphone/downloader/main.m b/navit/iphone/downloader/main.m
index e18fb9c59..39d344c1f 100644
--- a/navit/iphone/downloader/main.m
+++ b/navit/iphone/downloader/main.m
@@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
-
+
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
diff --git a/navit/item.c b/navit/item.c
index 3f865c19d..4f64a1edb 100644
--- a/navit/item.c
+++ b/navit/item.c
@@ -27,61 +27,61 @@
#include "transform.h"
struct item_name {
- enum item_type item;
- char *name;
+ enum item_type item;
+ char *name;
};
struct item_range item_range_all = { type_none, type_last };
struct default_flags {
- enum item_type type;
- int flags;
+ enum item_type type;
+ int flags;
};
struct item busy_item;
-struct default_flags default_flags2[]={
- {type_street_nopass, AF_PBH},
- {type_street_0, AF_ALL},
- {type_street_1_city, AF_ALL},
- {type_street_2_city, AF_ALL},
- {type_street_3_city, AF_ALL},
- {type_street_4_city, AF_ALL},
- {type_highway_city, AF_MOTORIZED_FAST},
- {type_street_1_land, AF_ALL},
- {type_street_2_land, AF_ALL},
- {type_street_3_land, AF_ALL},
- {type_street_4_land, AF_ALL},
- {type_street_n_lanes, AF_MOTORIZED_FAST},
- {type_highway_land, AF_MOTORIZED_FAST},
- {type_ramp, AF_MOTORIZED_FAST},
- {type_roundabout, AF_ALL},
- {type_ferry, AF_ALL},
- {type_cycleway, AF_PBH},
- {type_track_paved, AF_ALL},
- {type_track_gravelled, AF_ALL},
- {type_track_unpaved, AF_ALL},
- {type_track_ground, AF_ALL},
- {type_track_grass, AF_ALL},
- {type_footway, AF_PBH},
- {type_living_street, AF_ALL},
- {type_street_service, AF_ALL},
- {type_street_parking_lane, AF_ALL},
- {type_bridleway, AF_PBH},
- {type_path, AF_PBH},
- {type_steps, AF_PBH},
- {type_street_pedestrian, AF_PBH},
- {type_hiking_mountain, AF_PEDESTRIAN},
- {type_hiking_mountain_demanding, AF_PEDESTRIAN},
- {type_hiking, AF_PEDESTRIAN},
- {type_hiking_alpine, AF_PEDESTRIAN},
- {type_hiking_alpine_demanding, AF_PEDESTRIAN},
- {type_hiking_alpine_difficult, AF_PEDESTRIAN},
+struct default_flags default_flags2[]= {
+ {type_street_nopass, AF_PBH},
+ {type_street_0, AF_ALL},
+ {type_street_1_city, AF_ALL},
+ {type_street_2_city, AF_ALL},
+ {type_street_3_city, AF_ALL},
+ {type_street_4_city, AF_ALL},
+ {type_highway_city, AF_MOTORIZED_FAST},
+ {type_street_1_land, AF_ALL},
+ {type_street_2_land, AF_ALL},
+ {type_street_3_land, AF_ALL},
+ {type_street_4_land, AF_ALL},
+ {type_street_n_lanes, AF_MOTORIZED_FAST},
+ {type_highway_land, AF_MOTORIZED_FAST},
+ {type_ramp, AF_MOTORIZED_FAST},
+ {type_roundabout, AF_ALL},
+ {type_ferry, AF_ALL},
+ {type_cycleway, AF_PBH},
+ {type_track_paved, AF_ALL},
+ {type_track_gravelled, AF_ALL},
+ {type_track_unpaved, AF_ALL},
+ {type_track_ground, AF_ALL},
+ {type_track_grass, AF_ALL},
+ {type_footway, AF_PBH},
+ {type_living_street, AF_ALL},
+ {type_street_service, AF_ALL},
+ {type_street_parking_lane, AF_ALL},
+ {type_bridleway, AF_PBH},
+ {type_path, AF_PBH},
+ {type_steps, AF_PBH},
+ {type_street_pedestrian, AF_PBH},
+ {type_hiking_mountain, AF_PEDESTRIAN},
+ {type_hiking_mountain_demanding, AF_PEDESTRIAN},
+ {type_hiking, AF_PEDESTRIAN},
+ {type_hiking_alpine, AF_PEDESTRIAN},
+ {type_hiking_alpine_demanding, AF_PEDESTRIAN},
+ {type_hiking_alpine_difficult, AF_PEDESTRIAN},
};
-struct item_name item_names[]={
+struct item_name item_names[]= {
#define ITEM2(x,y) ITEM(y)
#define ITEM(x) { type_##x, #x },
#include "item_def.h"
@@ -93,41 +93,33 @@ static GHashTable *default_flags_hash;
static GHashTable *item_hash;
-void
-item_create_hash(void)
-{
- int i;
- item_hash=g_hash_table_new(g_str_hash, g_str_equal);
- for (i=0 ; i < sizeof(item_names)/sizeof(struct item_name) ; i++) {
- g_hash_table_insert(item_hash, item_names[i].name, GINT_TO_POINTER(item_names[i].item));
- }
+void item_create_hash(void) {
+ int i;
+ item_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ for (i=0 ; i < sizeof(item_names)/sizeof(struct item_name) ; i++) {
+ g_hash_table_insert(item_hash, item_names[i].name, GINT_TO_POINTER(item_names[i].item));
+ }
}
-void
-item_destroy_hash(void)
-{
- g_hash_table_destroy(item_hash);
- item_hash=NULL;
+void item_destroy_hash(void) {
+ g_hash_table_destroy(item_hash);
+ item_hash=NULL;
}
-int *
-item_get_default_flags(enum item_type type)
-{
- if (!default_flags_hash) {
- int i;
- default_flags_hash=g_hash_table_new(NULL, NULL);
- for (i = 0 ; i < sizeof(default_flags2)/sizeof(struct default_flags); i++) {
- g_hash_table_insert(default_flags_hash, (void *)(long)default_flags2[i].type, &default_flags2[i].flags);
- }
- }
- return g_hash_table_lookup(default_flags_hash, (void *)(long)type);
+int *item_get_default_flags(enum item_type type) {
+ if (!default_flags_hash) {
+ int i;
+ default_flags_hash=g_hash_table_new(NULL, NULL);
+ for (i = 0 ; i < sizeof(default_flags2)/sizeof(struct default_flags); i++) {
+ g_hash_table_insert(default_flags_hash, (void *)(long)default_flags2[i].type, &default_flags2[i].flags);
+ }
+ }
+ return g_hash_table_lookup(default_flags_hash, (void *)(long)type);
}
-void
-item_cleanup(void)
-{
- if (default_flags_hash)
- g_hash_table_destroy(default_flags_hash);
+void item_cleanup(void) {
+ if (default_flags_hash)
+ g_hash_table_destroy(default_flags_hash);
}
/**
@@ -136,13 +128,14 @@ item_cleanup(void)
* This function resets the "coordinate pointer" of an item to point to the first coordinate pair,
* so that at the next call to {@code item_coord_get()} the first coordinates will be returned.
*
+ * This function is not safe to call after destroying the item's map rect, and doing so may cause errors
+ * with some map implementations.
+ *
* @param it The map item whose pointer is to be reset. This must be the active item, i.e. the last one retrieved from the
* {@code map_rect}. There can only be one active item per {@code map_rect}.
*/
-void
-item_coord_rewind(struct item *it)
-{
- it->meth->item_coord_rewind(it->priv_data);
+void item_coord_rewind(struct item *it) {
+ it->meth->item_coord_rewind(it->priv_data);
}
/**
@@ -154,6 +147,9 @@ item_coord_rewind(struct item *it)
* Coordinates are stored in the projection of the item's map. If you need them in a different projection,
* call {@code item_coord_get_pro()} instead.
*
+ * This function is not safe to call after destroying the item's map rect, and doing so may cause errors
+ * with some map implementations.
+ *
* @param it The map item whose coordinates to retrieve. This must be the active item, i.e. the last one retrieved from the
* {@code map_rect}. There can only be one active item per {@code map_rect}.
* @param c Points to a buffer that will receive the coordinates.
@@ -164,49 +160,119 @@ item_coord_rewind(struct item *it)
*
* @return The number of coordinates actually retrieved and stored in {@code c}
*/
-int
-item_coord_get(struct item *it, struct coord *c, int count)
-{
- return it->meth->item_coord_get(it->priv_data, c, count);
-}
-
-int
-item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode)
-{
- if (!it->meth->item_coord_set)
- return 0;
- return it->meth->item_coord_set(it->priv_data, c, count, mode);
-}
-
-int
-item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel)
-{
- int i,ret=it->meth->item_coord_get(it->priv_data, c, count);
- struct coord_rect r;
- struct map_selection *curr;
- if (ret <= 0 || !sel)
- return ret;
- r.lu=c[0];
- r.rl=c[0];
- for (i = 1 ; i < ret ; i++) {
- if (r.lu.x > c[i].x)
- r.lu.x=c[i].x;
- if (r.rl.x < c[i].x)
- r.rl.x=c[i].x;
- if (r.rl.y > c[i].y)
- r.rl.y=c[i].y;
- if (r.lu.y < c[i].y)
- r.lu.y=c[i].y;
- }
- curr=sel;
- while (curr) {
- struct coord_rect *sr=&curr->u.c_rect;
- if (r.lu.x <= sr->rl.x && r.rl.x >= sr->lu.x &&
- r.lu.y >= sr->rl.y && r.rl.y <= sr->lu.y)
- return ret;
- curr=curr->next;
- }
+int item_coord_get(struct item *it, struct coord *c, int count) {
+ return it->meth->item_coord_get(it->priv_data, c, count);
+}
+
+/**
+ * @brief Sets coordinates of an item
+ *
+ * This function supports different modes:
+ *
+ * \li `change_mode_delete`: Deletes the specified number of coordinates
+ * \li `change_mode_modify`: Replaces existing coordinates with new ones
+ * \li `change_mode_append`: Appends new coordinates
+ * \li `change_mode_prepend`: Prepends new coordinates
+ *
+ * TODO which coordinates are deleted/modified? Starting from the last coordinate retrieved, or the one after, or...?
+ *
+ * TODO what if `count` in delete or modify mode is bigger then the number of coordinates left?
+ *
+ * TODO where are coordinates appended/prepended? Beginning/end or current position?
+ *
+ * This function is not safe to call after destroying the item's map rect, and doing so may cause errors
+ * with some map implementations.
+ *
+ * @param it The map item whose coordinates to retrieve. This must be the active item, i.e. the last one retrieved from the
+ * {@code map_rect}. There can only be one active item per {@code map_rect}.
+ * @param c TODO new coordinates, also store for old coordinates (delete/modify)? Required in delete mode?
+ * @param count TODO number of coordinates to add, delete or modify?
+ * @param mode The change mode, see description
+ */
+int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode) {
+ if (!it->meth->item_coord_set)
return 0;
+ return it->meth->item_coord_set(it->priv_data, c, count, mode);
+}
+
+int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel) {
+ int i,ret=it->meth->item_coord_get(it->priv_data, c, count);
+ struct coord_rect r;
+ struct map_selection *curr;
+ if (ret <= 0 || !sel)
+ return ret;
+ r.lu=c[0];
+ r.rl=c[0];
+ for (i = 1 ; i < ret ; i++) {
+ if (r.lu.x > c[i].x)
+ r.lu.x=c[i].x;
+ if (r.rl.x < c[i].x)
+ r.rl.x=c[i].x;
+ if (r.rl.y > c[i].y)
+ r.rl.y=c[i].y;
+ if (r.lu.y < c[i].y)
+ r.lu.y=c[i].y;
+ }
+ curr=sel;
+ while (curr) {
+ struct coord_rect *sr=&curr->u.c_rect;
+ if (r.lu.x <= sr->rl.x && r.rl.x >= sr->lu.x &&
+ r.lu.y >= sr->rl.y && r.rl.y <= sr->lu.y)
+ return ret;
+ curr=curr->next;
+ }
+ return 0;
+}
+
+/**
+ * @brief Gets all the coordinates of an item within a specified range
+ *
+ * This will get all the coordinates of the item `i`, starting with `start` and ending with `end`, and
+ * return them in `c`, up to `max` coordinates.
+ *
+ * If `i` does not contain the coordinates in `start`, no coordinates are retrieved and zero is returned.
+ *
+ * If `i` contains the coordinates in `start` but not those in `end`, all coordinates beginning with
+ * `start` are retrieved, ending with the last coordinate of `i` or after `max` coordinates have been
+ * retrieved, whichever occurs first.
+ *
+ * This function is not safe to call after destroying the item's map rect, and doing so may cause errors
+ * with some map implementations.
+ *
+ * @important Make sure that `c` points to a buffer large enough to hold `max` coordinates!
+ *
+ * @param i The item to get the coordinates of
+ * @param c Pointer to memory allocated for holding the coordinates
+ * @param max Maximum number of coordinates to return
+ * @param start First coordinate to get
+ * @param end Last coordinate to get
+ *
+ * @return The number of coordinates stored in `c`
+ */
+int item_coord_get_within_range(struct item *i, struct coord *c, int max,
+ struct coord *start, struct coord *end) {
+ struct map_rect *mr;
+ struct item *item;
+ int rc = 0, p = 0;
+ struct coord c1;
+ mr=map_rect_new(i->map, NULL);
+ if (!mr)
+ return 0;
+ item = map_rect_get_item_byid(mr, i->id_hi, i->id_lo);
+ if (item) {
+ rc = item_coord_get(item, &c1, 1);
+ while (rc && (c1.x != start->x || c1.y != start->y)) {
+ rc = item_coord_get(item, &c1, 1);
+ }
+ while (rc && p < max) {
+ c[p++] = c1;
+ if (c1.x == end->x && c1.y == end->y)
+ break;
+ rc = item_coord_get(item, &c1, 1);
+ }
+ }
+ map_rect_destroy(mr);
+ return p;
}
/**
@@ -226,242 +292,262 @@ item_coord_get_within_selection(struct item *it, struct coord *c, int count, str
*
* @return The number of coordinates actually retrieved and stored in {@code c}
*/
-int
-item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to)
-{
- int ret=item_coord_get(it, c, count);
- int i;
- enum projection from=map_projection(it->map);
- if (from != to)
- for (i = 0 ; i < count ; i++)
- transform_from_to(c+i, from, c+i, to);
- return ret;
+int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to) {
+ int ret=item_coord_get(it, c, count);
+ int i;
+ enum projection from=map_projection(it->map);
+ if (from != to)
+ for (i = 0 ; i < count ; i++)
+ transform_from_to(c+i, from, c+i, to);
+ return ret;
}
-int
-item_coord_is_node(struct item *it)
-{
- if (it->meth->item_coord_is_node)
- return it->meth->item_coord_is_node(it->priv_data);
- return 0;
+/**
+ * @brief Whether the current coordinates of an item correspond to a node.
+ *
+ * TODO which coordinates? Last retrieved or next (to be) retrieved?
+ *
+ * This function is not safe to call after destroying the item's map rect, and doing so may cause errors
+ * with some map implementations.
+ *
+ * @param it The item
+ *
+ * @return True on success, false on failure
+ */
+int item_coord_is_node(struct item *it) {
+ if (it->meth->item_coord_is_node)
+ return it->meth->item_coord_is_node(it->priv_data);
+ return 0;
}
-void
-item_attr_rewind(struct item *it)
-{
- it->meth->item_attr_rewind(it->priv_data);
+/**
+ * @brief Resets the "attribute pointer" of an item
+ *
+ * This function resets the "attribute pointer" of an item to point to the first attribute,
+ * so that at the next call to {@code item_attr_get()} the first attribute will be returned.
+ *
+ * This function is not safe to call after destroying the item's map rect, and doing so may cause errors
+ * with some map implementations.
+ *
+ * @param it The map item whose pointer is to be reset. This must be the active item, i.e. the last one retrieved from the
+ * {@code map_rect}. There can only be one active item per {@code map_rect}.
+ */
+void item_attr_rewind(struct item *it) {
+ it->meth->item_attr_rewind(it->priv_data);
}
-int
-item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr)
-{
- return it->meth->item_attr_get(it->priv_data, attr_type, attr);
+/**
+ * @brief Gets the next matching attribute from an item
+ *
+ * This function returns the next attribute matching `attr_type` from an item and advances the
+ * "attribute pointer" accordingly, so that at the next call the next attribute will be returned.
+ *
+ * This function is not safe to call after destroying the item's map rect, and doing so may cause errors
+ * with some map implementations.
+ *
+ * @param it The map item whose attribute to retrieve. This must be the active item, i.e. the last one retrieved from the
+ * {@code map_rect}. There can only be one active item per {@code map_rect}.
+ * @param attr_type The attribute type to retrieve, or `attr_any` to retrieve the next attribute
+ * @param attr Receives the attribute retrieved
+ *
+ * @return True on success, false on failure
+ */
+int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr) {
+ return it->meth->item_attr_get(it->priv_data, attr_type, attr);
}
-int
-item_attr_set(struct item *it, struct attr *attr, enum change_mode mode)
-{
- if (!it->meth->item_attr_set)
- return 0;
- return it->meth->item_attr_set(it->priv_data, attr, mode);
+/**
+ * @brief Sets an attribute of an item
+ *
+ * This function supports different modes:
+ *
+ * \li `change_mode_delete`: Deletes the attribute
+ * \li `change_mode_modify`: Replaces an attribute
+ * \li `change_mode_append`: Appends an attribute
+ * \li `change_mode_prepend`: Prepends an attribute
+ *
+ * TODO which attribute is deleted/modified? The last one retrieved, the next one, the first matching one?
+ *
+ * TODO where are attributes appended/prepended? Beginning/end or current position?
+ *
+ * This function is not safe to call after destroying the item's map rect, and doing so may cause errors
+ * with some map implementations.
+ *
+ * @param it The map item whose coordinates to retrieve. This must be the active item, i.e. the last one retrieved from the
+ * {@code map_rect}. There can only be one active item per {@code map_rect}.
+ * @param attr TODO new attr, also store for old attr (delete/modify)? Required in delete mode (type of attr to delete)?
+ * @param mode The change mode, see description
+ */
+int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode) {
+ if (!it->meth->item_attr_set)
+ return 0;
+ return it->meth->item_attr_set(it->priv_data, attr, mode);
}
+
/**
- * @brief Set map item type.
+ * @brief Sets the type of a map item.
*
- * @param it reference to the item.
- * @param type New type for the item. Setting it to type_none is expected to delete item from the map.
- * @return Non-zero if this action is supported by the map and type is set successfully, 0 on error.
+ * @param it The item
+ * @param type The new type for the item. Setting it to type_none is expected to delete item from the map.
+ *
+ * @return Non-zero if this action is supported by the map and type is set successfully, 0 on error.
*/
-int
-item_type_set(struct item *it, enum item_type type)
-{
- if (!it->meth->item_type_set)
- return 0;
- return it->meth->item_type_set(it->priv_data, type);
+int item_type_set(struct item *it, enum item_type type) {
+ if (!it->meth->item_type_set)
+ return 0;
+ return it->meth->item_type_set(it->priv_data, type);
}
-struct item * item_new(char *type, int zoom)
-{
- struct item * it;
+struct item * item_new(char *type, int zoom) {
+ struct item * it;
- it = g_new0(struct item, 1);
+ it = g_new0(struct item, 1);
- /* FIXME evaluate arguments */
+ /* FIXME evaluate arguments */
- return it;
+ return it;
}
-enum item_type
-item_from_name(const char *name)
-{
- int i;
+enum item_type item_from_name(const char *name) {
+ int i;
- if (item_hash)
- return GPOINTER_TO_INT(g_hash_table_lookup(item_hash, name));
+ if (item_hash)
+ return GPOINTER_TO_INT(g_hash_table_lookup(item_hash, name));
- for (i=0 ; i < sizeof(item_names)/sizeof(struct item_name) ; i++) {
- if (! strcmp(item_names[i].name, name))
- return item_names[i].item;
- }
- return type_none;
+ for (i=0 ; i < sizeof(item_names)/sizeof(struct item_name) ; i++) {
+ if (! strcmp(item_names[i].name, name))
+ return item_names[i].item;
+ }
+ return type_none;
}
-char *
-item_to_name(enum item_type item)
-{
- int i;
+char *item_to_name(enum item_type item) {
+ int i;
- for (i=0 ; i < sizeof(item_names)/sizeof(struct item_name) ; i++) {
- if (item_names[i].item == item)
- return item_names[i].name;
- }
- return NULL;
+ for (i=0 ; i < sizeof(item_names)/sizeof(struct item_name) ; i++) {
+ if (item_names[i].item == item)
+ return item_names[i].name;
+ }
+ return NULL;
}
struct item_hash {
- GHashTable *h;
+ GHashTable *h;
};
-static guint
-item_hash_hash(gconstpointer key)
-{
- const struct item *itm=key;
- gconstpointer hashkey=(gconstpointer)GINT_TO_POINTER(itm->id_hi^itm->id_lo^(GPOINTER_TO_INT(itm->map)));
- return g_direct_hash(hashkey);
+static guint item_hash_hash(gconstpointer key) {
+ const struct item *itm=key;
+ gconstpointer hashkey=(gconstpointer)GINT_TO_POINTER(itm->id_hi^itm->id_lo^(GPOINTER_TO_INT(itm->map)));
+ return g_direct_hash(hashkey);
}
-static gboolean
-item_hash_equal(gconstpointer a, gconstpointer b)
-{
- const struct item *itm_a=a;
- const struct item *itm_b=b;
- if (item_is_equal(*itm_a, *itm_b))
- return TRUE;
- return FALSE;
+static gboolean item_hash_equal(gconstpointer a, gconstpointer b) {
+ const struct item *itm_a=a;
+ const struct item *itm_b=b;
+ if (item_is_equal(*itm_a, *itm_b))
+ return TRUE;
+ return FALSE;
}
-unsigned int
-item_id_hash(const void *key)
-{
- const struct item_id *id=key;
- return id->id_hi^id->id_lo;
+unsigned int item_id_hash(const void *key) {
+ const struct item_id *id=key;
+ return id->id_hi^id->id_lo;
}
-int
-item_id_equal(const void *a, const void *b)
-{
- const struct item_id *id_a=a;
- const struct item_id *id_b=b;
- return (id_a->id_hi == id_b->id_hi && id_a->id_lo == id_b->id_lo);
+int item_id_equal(const void *a, const void *b) {
+ const struct item_id *id_a=a;
+ const struct item_id *id_b=b;
+ return (id_a->id_hi == id_b->id_hi && id_a->id_lo == id_b->id_lo);
}
/**
- * @brief Derive item id_lo and id_hi from pointer, considering pointer could be 32 or 64 bit wide but both ids are 32 bit.
+ * @brief Derive item id_lo and id_hi from pointer, considering pointer could be 32 or 64 bit wide but both ids are 32 bit.
*
* @param it reference to the item.
* @param id pointer to derive item id from.
* @return Nothing.
*/
-void
-item_id_from_ptr(struct item *item, void *id)
-{
+void item_id_from_ptr(struct item *item, void *id) {
#if !defined(__LP64__) && !defined(__LLP64__) && !defined(WIN64)
- item->id_lo=(int) id;
- item->id_hi=0;
+ item->id_lo=(int) id;
+ item->id_hi=0;
#else
# ifndef _MSC_VER
- item->id_lo=((long long)id)&0xFFFFFFFFll;
+ item->id_lo=((long long)id)&0xFFFFFFFFll;
# else
- item->id_lo=((long long)id)&0xFFFFFFFFi64;
+ item->id_lo=((long long)id)&0xFFFFFFFFi64;
# endif
- item->id_hi=((long long)id)>>32;
+ item->id_hi=((long long)id)>>32;
#endif
}
struct item_hash *
-item_hash_new(void)
-{
- struct item_hash *ret=g_new(struct item_hash, 1);
+item_hash_new(void) {
+ struct item_hash *ret=g_new(struct item_hash, 1);
- ret->h=g_hash_table_new_full(item_hash_hash, item_hash_equal, g_free, NULL);
- return ret;
+ ret->h=g_hash_table_new_full(item_hash_hash, item_hash_equal, g_free, NULL);
+ return ret;
}
-void
-item_hash_insert(struct item_hash *h, struct item *item, void *val)
-{
- struct item *hitem=g_new(struct item, 1);
- *hitem=*item;
- dbg(lvl_info,"inserting (0x%x,0x%x) into %p\n", item->id_hi, item->id_lo, h->h);
- g_hash_table_insert(h->h, hitem, val);
+void item_hash_insert(struct item_hash *h, struct item *item, void *val) {
+ struct item *hitem=g_new(struct item, 1);
+ *hitem=*item;
+ dbg(lvl_info,"inserting (0x%x,0x%x) into %p", item->id_hi, item->id_lo, h->h);
+ g_hash_table_insert(h->h, hitem, val);
}
-int
-item_hash_remove(struct item_hash *h, struct item *item)
-{
- int ret;
+int item_hash_remove(struct item_hash *h, struct item *item) {
+ int ret;
- dbg(lvl_info,"removing (0x%x,0x%x) from %p\n", item->id_hi, item->id_lo, h->h);
- ret=g_hash_table_remove(h->h, item);
- dbg(lvl_info,"ret=%d\n", ret);
+ dbg(lvl_info,"removing (0x%x,0x%x) from %p", item->id_hi, item->id_lo, h->h);
+ ret=g_hash_table_remove(h->h, item);
+ dbg(lvl_info,"ret=%d", ret);
- return ret;
+ return ret;
}
-void *
-item_hash_lookup(struct item_hash *h, struct item *item)
-{
- return g_hash_table_lookup(h->h, item);
+void *item_hash_lookup(struct item_hash *h, struct item *item) {
+ return g_hash_table_lookup(h->h, item);
}
-void
-item_hash_destroy(struct item_hash *h)
-{
- g_hash_table_destroy(h->h);
- g_free(h);
+void item_hash_destroy(struct item_hash *h) {
+ g_hash_table_destroy(h->h);
+ g_free(h);
}
-int
-item_range_intersects_range(struct item_range *range1, struct item_range *range2)
-{
- if (range1->max < range2->min)
- return 0;
- if (range1->min > range2->max)
- return 0;
- return 1;
+int item_range_intersects_range(struct item_range *range1, struct item_range *range2) {
+ if (range1->max < range2->min)
+ return 0;
+ if (range1->min > range2->max)
+ return 0;
+ return 1;
}
-int
-item_range_contains_item(struct item_range *range, enum item_type type)
-{
- if (type >= range->min && type <= range->max)
- return 1;
- return 0;
+int item_range_contains_item(struct item_range *range, enum item_type type) {
+ if (type >= range->min && type <= range->max)
+ return 1;
+ return 0;
}
-void
-item_dump_attr(struct item *item, struct map *map, FILE *out)
-{
- struct attr attr;
- fprintf(out,"type=%s", item_to_name(item->type));
- while (item_attr_get(item, attr_any, &attr))
- fprintf(out," %s='%s'", attr_to_name(attr.type), attr_to_text(&attr, map, 1));
+void item_dump_attr(struct item *item, struct map *map, FILE *out) {
+ struct attr attr;
+ fprintf(out,"type=%s", item_to_name(item->type));
+ while (item_attr_get(item, attr_any, &attr))
+ fprintf(out," %s='%s'", attr_to_name(attr.type), attr_to_text(&attr, map, 1));
}
-void
-item_dump_filedesc(struct item *item, struct map *map, FILE *out)
-{
+void item_dump_filedesc(struct item *item, struct map *map, FILE *out) {
- int i,count,max=16384;
- struct coord *ca=g_alloca(sizeof(struct coord)*max);
+ int i,count,max=16384;
+ struct coord *ca=g_alloca(sizeof(struct coord)*max);
- count=item_coord_get(item, ca, item->type < type_line ? 1: max);
- if (item->type < type_line)
- fprintf(out,"mg:0x%x 0x%x ", ca[0].x, ca[0].y);
- item_dump_attr(item, map, out);
- fprintf(out,"\n");
- if (item->type >= type_line)
- for (i = 0 ; i < count ; i++)
- fprintf(out,"mg:0x%x 0x%x\n", ca[i].x, ca[i].y);
+ count=item_coord_get(item, ca, item->type < type_line ? 1: max);
+ if (item->type < type_line)
+ fprintf(out,"mg:0x%x 0x%x ", ca[0].x, ca[0].y);
+ item_dump_attr(item, map, out);
+ fprintf(out,"\n");
+ if (item->type >= type_line)
+ for (i = 0 ; i < count ; i++)
+ fprintf(out,"mg:0x%x 0x%x\n", ca[i].x, ca[i].y);
}
diff --git a/navit/item.h b/navit/item.h
index 341d4406d..5374240d2 100644
--- a/navit/item.h
+++ b/navit/item.h
@@ -51,7 +51,7 @@ extern int default_flags[];
#define item_is_town(item) ((item).type >= type_town_label && (item).type <= type_district_label_1e7)
#define item_is_district(item) ((item).type >= type_district_label && (item).type <= type_district_label_1e7)
#define item_is_poly_place(item) ((item).type >= type_poly_place1 && (item).type <= type_poly_place6)
-#define item_is_point(item) ((item).type < type_line)
+#define item_is_point(item) ((item).type < type_line)
#define item_is_custom_poi(item) ((item).type >= type_poi_customg && (item).type < type_line)
#define item_is_street(item) (((item).type >= type_street_nopass && (item).type <= type_roundabout) \
|| (item).type == type_street_service \
@@ -130,6 +130,7 @@ void item_coord_rewind(struct item *it);
int item_coord_get(struct item *it, struct coord *c, int count);
int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode);
int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel);
+int item_coord_get_within_range(struct item *i, struct coord *c, int max, struct coord *start, struct coord *end);
int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to);
int item_coord_is_node(struct item *it);
void item_attr_rewind(struct item *it);
diff --git a/navit/keys.h b/navit/keys.h
index be7527ede..a47a1bcca 100644
--- a/navit/keys.h
+++ b/navit/keys.h
@@ -3,7 +3,7 @@
#define NAVIT_KEY_RIGHT 6 /* ^R */
#define NAVIT_KEY_BACKSPACE 8 /* ^H */
#define NAVIT_KEY_RETURN 13 /* ^M */
-#define NAVIT_KEY_DOWN 14 /* ^N */
+#define NAVIT_KEY_DOWN 14 /* ^N */
#define NAVIT_KEY_ZOOM_OUT 15 /* ^O */
#define NAVIT_KEY_UP 16 /* ^P */
#define NAVIT_KEY_ZOOM_IN 17 /* ^Q */
diff --git a/navit/layout.c b/navit/layout.c
index c78e7c79d..f2f3d1a75 100644
--- a/navit/layout.c
+++ b/navit/layout.c
@@ -25,122 +25,130 @@
#include "layout.h"
#include "coord.h"
#include "debug.h"
+#include "navit.h"
-
-struct layout * layout_new(struct attr *parent, struct attr **attrs)
-{
- struct layout *l;
- struct color def_color = {COLOR_BACKGROUND_};
- struct attr *name_attr,*color_attr,*order_delta_attr,*font_attr,*day_attr,*night_attr,*active_attr;
-
- if (! (name_attr=attr_search(attrs, NULL, attr_name)))
- return NULL;
- l = g_new0(struct layout, 1);
- l->func=&layout_func;
- navit_object_ref((struct navit_object *)l);
- l->name = g_strdup(name_attr->u.str);
- if ((font_attr=attr_search(attrs, NULL, attr_font))) {
- l->font = g_strdup(font_attr->u.str);
- }
- if ((day_attr=attr_search(attrs, NULL, attr_daylayout))) {
- l->dayname = g_strdup(day_attr->u.str);
- }
- if ((night_attr=attr_search(attrs, NULL, attr_nightlayout))) {
- l->nightname = g_strdup(night_attr->u.str);
- }
- if ((color_attr=attr_search(attrs, NULL, attr_color)))
- l->color = *color_attr->u.color;
- else
- l->color = def_color;
- if ((order_delta_attr=attr_search(attrs, NULL, attr_order_delta)))
- l->order_delta=order_delta_attr->u.num;
- if ((active_attr=attr_search(attrs, NULL, attr_active)))
- l->active = active_attr->u.num;
- l->navit=parent->u.navit;
- return l;
+/**
+ * @brief Create a new layout object and attach it to a navit parent
+ *
+ * @param parent The parent for this layout (a navit attr)
+ * @param attrs An array of attributes that for this layout
+ * @return The newly created layout object
+ */
+struct layout *
+layout_new(struct attr *parent, struct attr **attrs) {
+ struct layout *l;
+ struct navit *navit;
+ struct color def_color = {COLOR_BACKGROUND_};
+ struct attr *name_attr,*color_attr,*order_delta_attr,*font_attr,*day_attr,*night_attr,*active_attr;
+
+ if (! (name_attr=attr_search(attrs, NULL, attr_name)))
+ return NULL;
+ navit = parent->u.navit;
+ if (navit_get_layout_by_name(navit, name_attr->u.str)) {
+ dbg(lvl_warning, "Another layout with name '%s' has already been parsed. Discarding subsequent duplicate.",
+ name_attr->u.str);
+ return NULL;
+ }
+
+ l = g_new0(struct layout, 1);
+ l->func=&layout_func;
+ navit_object_ref((struct navit_object *)l);
+ l->name = g_strdup(name_attr->u.str);
+ if ((font_attr=attr_search(attrs, NULL, attr_font))) {
+ l->font = g_strdup(font_attr->u.str);
+ }
+ if ((day_attr=attr_search(attrs, NULL, attr_daylayout))) {
+ l->dayname = g_strdup(day_attr->u.str);
+ }
+ if ((night_attr=attr_search(attrs, NULL, attr_nightlayout))) {
+ l->nightname = g_strdup(night_attr->u.str);
+ }
+ if ((color_attr=attr_search(attrs, NULL, attr_color)))
+ l->color = *color_attr->u.color;
+ else
+ l->color = def_color;
+ if ((order_delta_attr=attr_search(attrs, NULL, attr_order_delta)))
+ l->order_delta=order_delta_attr->u.num;
+ if ((active_attr=attr_search(attrs, NULL, attr_active)))
+ l->active = active_attr->u.num;
+ l->navit=navit;
+ return l;
}
struct attr_iter {
- GList *last;
+ GList *last;
};
struct attr_iter *
-layout_attr_iter_new(void)
-{
- return g_new0(struct attr_iter, 1);
-}
-
-void
-layout_attr_iter_destroy(struct attr_iter *iter)
-{
- g_free(iter);
-}
-
-int
-layout_get_attr(struct layout *layout, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- GList *cursor,*layer;
- attr->type=type;
- switch (type) {
- case attr_name:
- attr->u.str=layout->name;
- return 1;
- case attr_cursor:
- cursor=layout->cursors;
- while (cursor) {
- if (!iter || iter->last == g_list_previous(cursor)) {
- attr->u.cursor=cursor->data;
- if (iter)
- iter->last=cursor;
- return 1;
- }
- cursor=g_list_next(cursor);
- }
- break;
- case attr_layer:
- layer=layout->layers;
- while (layer) {
- if (!iter || iter->last == g_list_previous(layer)) {
- attr->u.layer=layer->data;
- if (iter)
- iter->last=layer;
- return 1;
- }
- layer=g_list_next(layer);
- }
- break;
- case attr_active:
- attr->u.num=layout->active;
- return 1;
- case attr_nightlayout:
- attr->u.str=layout->nightname;
- return 1;
- case attr_daylayout:
- attr->u.str=layout->dayname;
- return 1;
- default:
- break;
- }
- return 0;
-}
-
-
-int
-layout_add_attr(struct layout *layout, struct attr *attr)
-{
- switch (attr->type) {
- case attr_cursor:
- layout->cursors = g_list_append(layout->cursors, attr->u.cursor);
- break;
- case attr_layer:
- layout->layers = g_list_append(layout->layers, attr->u.layer);
- break;
- default:
- return 0;
- }
- layout->attrs=attr_generic_add_attr(layout->attrs, attr);
- return 1;
+layout_attr_iter_new(void) {
+ return g_new0(struct attr_iter, 1);
+}
+
+void layout_attr_iter_destroy(struct attr_iter *iter) {
+ g_free(iter);
+}
+
+int layout_get_attr(struct layout *layout, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ GList *cursor,*layer;
+ attr->type=type;
+ switch (type) {
+ case attr_name:
+ attr->u.str=layout->name;
+ return 1;
+ case attr_cursor:
+ cursor=layout->cursors;
+ while (cursor) {
+ if (!iter || iter->last == g_list_previous(cursor)) {
+ attr->u.cursor=cursor->data;
+ if (iter)
+ iter->last=cursor;
+ return 1;
+ }
+ cursor=g_list_next(cursor);
+ }
+ break;
+ case attr_layer:
+ layer=layout->layers;
+ while (layer) {
+ if (!iter || iter->last == g_list_previous(layer)) {
+ attr->u.layer=layer->data;
+ if (iter)
+ iter->last=layer;
+ return 1;
+ }
+ layer=g_list_next(layer);
+ }
+ break;
+ case attr_active:
+ attr->u.num=layout->active;
+ return 1;
+ case attr_nightlayout:
+ attr->u.str=layout->nightname;
+ return 1;
+ case attr_daylayout:
+ attr->u.str=layout->dayname;
+ return 1;
+ default:
+ break;
+ }
+ return 0;
+}
+
+
+int layout_add_attr(struct layout *layout, struct attr *attr) {
+ switch (attr->type) {
+ case attr_cursor:
+ layout->cursors = g_list_append(layout->cursors, attr->u.cursor);
+ break;
+ case attr_layer:
+ layout->layers = g_list_append(layout->layers, attr->u.layer);
+ break;
+ default:
+ return 0;
+ }
+ layout->attrs=attr_generic_add_attr(layout->attrs, attr);
+ return 1;
}
/**
@@ -152,509 +160,461 @@ layout_add_attr(struct layout *layout, struct attr *attr)
* @author Ralph Sennhauser (10/2009)
*/
struct cursor *
-layout_get_cursor(struct layout *this_, char *name)
-{
- GList *c;
- struct cursor *d=NULL;
+layout_get_cursor(struct layout *this_, char *name) {
+ GList *c;
+ struct cursor *d=NULL;
- c=g_list_first(this_->cursors);
- while (c) {
- if (! strcmp(((struct cursor *)c->data)->name, name))
- return c->data;
- if (! strcmp(((struct cursor *)c->data)->name, "default"))
- d=c->data;
- c=g_list_next(c);
- }
- return d;
+ c=g_list_first(this_->cursors);
+ while (c) {
+ if (! strcmp(((struct cursor *)c->data)->name, name))
+ return c->data;
+ if (! strcmp(((struct cursor *)c->data)->name, "default"))
+ d=c->data;
+ c=g_list_next(c);
+ }
+ return d;
}
struct cursor *
-cursor_new(struct attr *parent, struct attr **attrs)
-{
- struct attr *w, *h, *name, *interval, *sequence_range;
- struct cursor *this;
-
- w=attr_search(attrs, NULL, attr_w);
- h=attr_search(attrs, NULL, attr_h);
- if (! w || ! h)
- return NULL;
-
- this=g_new0(struct cursor,1);
- this->w=w->u.num;
- this->h=h->u.num;
- name=attr_search(attrs, NULL, attr_name);
- if (name)
- this->name=g_strdup(name->u.str);
- else
- this->name=g_strdup("default");
- interval=attr_search(attrs, NULL, attr_interval);
- if (interval)
- this->interval=interval->u.num;
- sequence_range=attr_search(attrs, NULL, attr_sequence_range);
- if (sequence_range) {
- struct range *r=g_new0(struct range,1);
- r->min=sequence_range->u.range.min;
- r->max=sequence_range->u.range.max;
- this->sequence_range=r;
- }
- else {
- this->sequence_range=NULL;
- }
- dbg(lvl_info,"ret=%p\n", this);
- return this;
-}
-
-void
-cursor_destroy(struct cursor *this_)
-{
- if (this_->sequence_range)
- g_free(this_->sequence_range);
- if (this_->name) {
- g_free(this_->name);
- }
- g_free(this_);
-}
-
-int
-cursor_add_attr(struct cursor *this_, struct attr *attr)
-{
- switch (attr->type) {
- case attr_itemgra:
- this_->attrs=attr_generic_add_attr(this_->attrs, attr);
- return 1;
- default:
- break;
- }
- return 0;
-}
-
-static int
-layer_set_attr_do(struct layer *l, struct attr *attr, int init)
-{
- struct attr_iter *iter;
- struct navit_object *obj;
- struct attr layer;
- switch (attr->type) {
- case attr_active:
- l->active = attr->u.num;
- return 1;
- case attr_details:
- l->details = attr->u.num;
- return 1;
- case attr_name:
- g_free(l->name);
- l->name = g_strdup(attr->u.str);
- return 1;
- case attr_ref:
- navit_object_unref((struct navit_object *)l->ref);
- l->ref=NULL;
- obj=(struct navit_object *)l->navit;
- if (obj==NULL){
- dbg(lvl_error, "Invalid layer reference '%s': Only layers inside a layout can use references.\n", attr->u.str);
- return 0;
- }
- iter=obj->func->iter_new(obj);
- while (obj->func->get_attr(obj, attr_layer, &layer, iter)) {
- if (!strcmp(layer.u.layer->name, attr->u.str)) {
- l->ref=(struct layer*)navit_object_ref(layer.u.navit_object);
- break;
- }
- }
- if (l->ref==NULL){
- dbg(lvl_error, "Ignoring reference to unknown layer '%s' in layer '%s'.\n", attr->u.str, l->name);
- }
- obj->func->iter_destroy(iter);
- default:
- return 0;
- }
-}
-
-
-
-struct layer * layer_new(struct attr *parent, struct attr **attrs)
-{
- struct layer *l;
-
- l = g_new0(struct layer, 1);
- if (parent->type == attr_layout)
- l->navit=parent->u.layout->navit;
- l->func=&layer_func;
- navit_object_ref((struct navit_object *)l);
- l->active=1;
- for (;*attrs; attrs++) {
- layer_set_attr_do(l, *attrs, 1);
- }
- if (l->name==NULL){
- dbg(lvl_error, "Ignoring layer without name.\n");
- g_free(l);
- return NULL;
- }
- return l;
-}
-
-int
-layer_get_attr(struct layer *layer, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- attr->type=type;
- switch(type) {
- case attr_active:
- attr->u.num=layer->active;
- return 1;
- case attr_details:
- attr->u.num=layer->details;
- return 1;
- case attr_name:
- if (layer->name) {
- attr->u.str=layer->name;
- return 1;
- }
- break;
- default:
- return 0;
- }
- return 0;
-}
-
-int
-layer_add_attr(struct layer *layer, struct attr *attr)
-{
- switch (attr->type) {
- case attr_itemgra:
- layer->itemgras = g_list_append(layer->itemgras, attr->u.itemgra);
- return 1;
- default:
- return 0;
- }
-}
-
-int
-layer_set_attr(struct layer *layer, struct attr *attr)
-{
- return layer_set_attr_do(layer, attr, 0);
-}
-
-static void
-layer_destroy(struct layer *layer)
-{
- attr_list_free(layer->attrs);
- g_free(layer->name);
- g_free(layer);
-}
-
-struct itemgra * itemgra_new(struct attr *parent, struct attr **attrs)
-{
- struct itemgra *itm;
- struct attr *order, *item_types, *speed_range, *angle_range, *sequence_range;
- enum item_type *type;
- struct range defrange;
-
- itm = g_new0(struct itemgra, 1);
- order=attr_search(attrs, NULL, attr_order);
- item_types=attr_search(attrs, NULL, attr_item_types);
- speed_range=attr_search(attrs, NULL, attr_speed_range);
- angle_range=attr_search(attrs, NULL, attr_angle_range);
- sequence_range=attr_search(attrs, NULL, attr_sequence_range);
- defrange.min=0;
- defrange.max=32767;
- if (order)
- itm->order=order->u.range;
- else
- itm->order=defrange;
- if (speed_range)
- itm->speed_range=speed_range->u.range;
- else
- itm->speed_range=defrange;
- if (angle_range)
- itm->angle_range=angle_range->u.range;
- else
- itm->angle_range=defrange;
- if (sequence_range)
- itm->sequence_range=sequence_range->u.range;
- else
- itm->sequence_range=defrange;
- if (item_types) {
- type=item_types->u.item_types;
- while (type && *type != type_none) {
- itm->type=g_list_append(itm->type, GINT_TO_POINTER(*type));
- type++;
- }
- }
- return itm;
-}
-int
-itemgra_add_attr(struct itemgra *itemgra, struct attr *attr)
-{
- switch (attr->type) {
- case attr_polygon:
- case attr_polyline:
- case attr_circle:
- case attr_text:
- case attr_icon:
- case attr_image:
- case attr_arrows:
- itemgra->elements = g_list_append(itemgra->elements, attr->u.element);
- return 1;
- default:
- dbg(lvl_error,"unknown: %s\n", attr_to_name(attr->type));
- return 0;
- }
-}
-
-static void
-element_set_color(struct element *e, struct attr **attrs)
-{
- struct attr *color;
- color=attr_search(attrs, NULL, attr_color);
- if (color)
- e->color=*color->u.color;
-}
-
-
-static void
-element_set_background_color(struct color *c, struct attr **attrs)
-{
- struct attr *color;
- color=attr_search(attrs, NULL, attr_background_color);
- if (color)
- *c=*color->u.color;
-}
-
-
-static void
-element_set_text_size(struct element *e, struct attr **attrs)
-{
- struct attr *text_size;
- text_size=attr_search(attrs, NULL, attr_text_size);
- if (text_size)
- e->text_size=text_size->u.num;
-}
-
-static void
-element_set_polyline_width(struct element *e, struct attr **attrs)
-{
- struct attr *width;
- width=attr_search(attrs, NULL, attr_width);
- if (width)
- e->u.polyline.width=width->u.num;
-}
-
-static void
-element_set_polyline_directed(struct element *e, struct attr **attrs)
-{
- struct attr *directed;
- directed=attr_search(attrs, NULL, attr_directed);
- if (directed)
- e->u.polyline.directed=directed->u.num;
-}
-
-static void
-element_set_polyline_dash(struct element *e, struct attr **attrs)
-{
- struct attr *dash;
- int i;
-
- dash=attr_search(attrs, NULL, attr_dash);
- if (dash) {
- for (i=0; i<4; i++) {
- if (!dash->u.dash[i])
- break;
- e->u.polyline.dash_table[i] = dash->u.dash[i];
- }
- e->u.polyline.dash_num=i;
- }
-}
-
-static void
-element_set_polyline_offset(struct element *e, struct attr **attrs)
-{
- struct attr *offset;
- offset=attr_search(attrs, NULL, attr_offset);
- if (offset)
- e->u.polyline.offset=offset->u.num;
-}
-
-static void
-element_set_circle_width(struct element *e, struct attr **attrs)
-{
- struct attr *width;
- width=attr_search(attrs, NULL, attr_width);
- if (width)
- e->u.circle.width=width->u.num;
-}
-
-static void
-element_set_circle_radius(struct element *e, struct attr **attrs)
-{
- struct attr *radius;
- radius=attr_search(attrs, NULL, attr_radius);
- if (radius)
- e->u.circle.radius=radius->u.num;
+cursor_new(struct attr *parent, struct attr **attrs) {
+ struct attr *w, *h, *name, *interval, *sequence_range;
+ struct cursor *this;
+
+ w=attr_search(attrs, NULL, attr_w);
+ h=attr_search(attrs, NULL, attr_h);
+ if (! w || ! h)
+ return NULL;
+
+ this=g_new0(struct cursor,1);
+ this->w=w->u.num;
+ this->h=h->u.num;
+ name=attr_search(attrs, NULL, attr_name);
+ if (name)
+ this->name=g_strdup(name->u.str);
+ else
+ this->name=g_strdup("default");
+ interval=attr_search(attrs, NULL, attr_interval);
+ if (interval)
+ this->interval=interval->u.num;
+ sequence_range=attr_search(attrs, NULL, attr_sequence_range);
+ if (sequence_range) {
+ struct range *r=g_new0(struct range,1);
+ r->min=sequence_range->u.range.min;
+ r->max=sequence_range->u.range.max;
+ this->sequence_range=r;
+ } else {
+ this->sequence_range=NULL;
+ }
+ dbg(lvl_info,"ret=%p", this);
+ return this;
+}
+
+void cursor_destroy(struct cursor *this_) {
+ if (this_->sequence_range)
+ g_free(this_->sequence_range);
+ if (this_->name) {
+ g_free(this_->name);
+ }
+ g_free(this_);
+}
+
+int cursor_add_attr(struct cursor *this_, struct attr *attr) {
+ switch (attr->type) {
+ case attr_itemgra:
+ this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+ return 1;
+ default:
+ break;
+ }
+ return 0;
+}
+
+static int layer_set_attr_do(struct layer *l, struct attr *attr, int init) {
+ struct attr_iter *iter;
+ struct navit_object *obj;
+ struct attr layer;
+ switch (attr->type) {
+ case attr_active:
+ l->active = attr->u.num;
+ return 1;
+ case attr_details:
+ l->details = attr->u.num;
+ return 1;
+ case attr_name:
+ g_free(l->name);
+ l->name = g_strdup(attr->u.str);
+ return 1;
+ case attr_ref:
+ navit_object_unref((struct navit_object *)l->ref);
+ l->ref=NULL;
+ obj=(struct navit_object *)l->navit;
+ if (obj==NULL) {
+ dbg(lvl_error, "Invalid layer reference '%s': Only layers inside a layout can use references.", attr->u.str);
+ return 0;
+ }
+ iter=obj->func->iter_new(obj);
+ while (obj->func->get_attr(obj, attr_layer, &layer, iter)) {
+ if (!strcmp(layer.u.layer->name, attr->u.str)) {
+ l->ref=(struct layer*)navit_object_ref(layer.u.navit_object);
+ break;
+ }
+ }
+ if (l->ref==NULL) {
+ dbg(lvl_error, "Ignoring reference to unknown layer '%s' in layer '%s'.", attr->u.str, l->name);
+ }
+ obj->func->iter_destroy(iter);
+ default:
+ return 0;
+ }
+}
+
+
+
+struct layer * layer_new(struct attr *parent, struct attr **attrs) {
+ struct layer *l;
+
+ l = g_new0(struct layer, 1);
+ if (parent->type == attr_layout)
+ l->navit=parent->u.layout->navit;
+ l->func=&layer_func;
+ navit_object_ref((struct navit_object *)l);
+ l->active=1;
+ for (; *attrs; attrs++) {
+ layer_set_attr_do(l, *attrs, 1);
+ }
+ if (l->name==NULL) {
+ dbg(lvl_error, "Ignoring layer without name.");
+ g_free(l);
+ return NULL;
+ }
+ return l;
+}
+
+int layer_get_attr(struct layer *layer, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ attr->type=type;
+ switch(type) {
+ case attr_active:
+ attr->u.num=layer->active;
+ return 1;
+ case attr_details:
+ attr->u.num=layer->details;
+ return 1;
+ case attr_name:
+ if (layer->name) {
+ attr->u.str=layer->name;
+ return 1;
+ }
+ break;
+ default:
+ return 0;
+ }
+ return 0;
+}
+
+int layer_add_attr(struct layer *layer, struct attr *attr) {
+ switch (attr->type) {
+ case attr_itemgra:
+ layer->itemgras = g_list_append(layer->itemgras, attr->u.itemgra);
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+int layer_set_attr(struct layer *layer, struct attr *attr) {
+ return layer_set_attr_do(layer, attr, 0);
+}
+
+static void layer_destroy(struct layer *layer) {
+ attr_list_free(layer->attrs);
+ g_free(layer->name);
+ g_free(layer);
+}
+
+struct itemgra * itemgra_new(struct attr *parent, struct attr **attrs) {
+ struct itemgra *itm;
+ struct attr *order, *item_types, *speed_range, *angle_range, *sequence_range;
+ enum item_type *type;
+ struct range defrange;
+
+ itm = g_new0(struct itemgra, 1);
+ order=attr_search(attrs, NULL, attr_order);
+ item_types=attr_search(attrs, NULL, attr_item_types);
+ speed_range=attr_search(attrs, NULL, attr_speed_range);
+ angle_range=attr_search(attrs, NULL, attr_angle_range);
+ sequence_range=attr_search(attrs, NULL, attr_sequence_range);
+ defrange.min=0;
+ defrange.max=32767;
+ if (order)
+ itm->order=order->u.range;
+ else
+ itm->order=defrange;
+ if (speed_range)
+ itm->speed_range=speed_range->u.range;
+ else
+ itm->speed_range=defrange;
+ if (angle_range)
+ itm->angle_range=angle_range->u.range;
+ else
+ itm->angle_range=defrange;
+ if (sequence_range)
+ itm->sequence_range=sequence_range->u.range;
+ else
+ itm->sequence_range=defrange;
+ if (item_types) {
+ type=item_types->u.item_types;
+ while (type && *type != type_none) {
+ itm->type=g_list_append(itm->type, GINT_TO_POINTER(*type));
+ type++;
+ }
+ }
+ return itm;
+}
+int itemgra_add_attr(struct itemgra *itemgra, struct attr *attr) {
+ switch (attr->type) {
+ case attr_polygon:
+ case attr_polyline:
+ case attr_circle:
+ case attr_text:
+ case attr_icon:
+ case attr_image:
+ case attr_arrows:
+ itemgra->elements = g_list_append(itemgra->elements, attr->u.element);
+ return 1;
+ default:
+ dbg(lvl_error,"unknown: %s", attr_to_name(attr->type));
+ return 0;
+ }
+}
+
+static void element_set_color(struct element *e, struct attr **attrs) {
+ struct attr *color;
+ color=attr_search(attrs, NULL, attr_color);
+ if (color)
+ e->color=*color->u.color;
+}
+
+
+static void element_set_background_color(struct color *c, struct attr **attrs) {
+ struct attr *color;
+ color=attr_search(attrs, NULL, attr_background_color);
+ if (color)
+ *c=*color->u.color;
+}
+
+
+static void element_set_text_size(struct element *e, struct attr **attrs) {
+ struct attr *text_size;
+ text_size=attr_search(attrs, NULL, attr_text_size);
+ if (text_size)
+ e->text_size=text_size->u.num;
+}
+
+static void element_set_polyline_width(struct element *e, struct attr **attrs) {
+ struct attr *width;
+ width=attr_search(attrs, NULL, attr_width);
+ if (width)
+ e->u.polyline.width=width->u.num;
+}
+
+static void element_set_polyline_directed(struct element *e, struct attr **attrs) {
+ struct attr *directed;
+ directed=attr_search(attrs, NULL, attr_directed);
+ if (directed)
+ e->u.polyline.directed=directed->u.num;
+}
+
+static void element_set_polyline_dash(struct element *e, struct attr **attrs) {
+ struct attr *dash;
+ int i;
+
+ dash=attr_search(attrs, NULL, attr_dash);
+ if (dash) {
+ for (i=0; i<4; i++) {
+ if (!dash->u.dash[i])
+ break;
+ e->u.polyline.dash_table[i] = dash->u.dash[i];
+ }
+ e->u.polyline.dash_num=i;
+ }
+}
+
+static void element_set_polyline_offset(struct element *e, struct attr **attrs) {
+ struct attr *offset;
+ offset=attr_search(attrs, NULL, attr_offset);
+ if (offset)
+ e->u.polyline.offset=offset->u.num;
+}
+
+static void element_set_circle_width(struct element *e, struct attr **attrs) {
+ struct attr *width;
+ width=attr_search(attrs, NULL, attr_width);
+ if (width)
+ e->u.circle.width=width->u.num;
+}
+
+static void element_set_circle_radius(struct element *e, struct attr **attrs) {
+ struct attr *radius;
+ radius=attr_search(attrs, NULL, attr_radius);
+ if (radius)
+ e->u.circle.radius=radius->u.num;
}
struct polygon *
-polygon_new(struct attr *parent, struct attr **attrs)
-{
- struct element *e;
- e = g_new0(struct element, 1);
- e->type=element_polygon;
- element_set_color(e, attrs);
+polygon_new(struct attr *parent, struct attr **attrs) {
+ struct element *e;
+ e = g_new0(struct element, 1);
+ e->type=element_polygon;
+ element_set_color(e, attrs);
- return (struct polygon *)e;
+ return (struct polygon *)e;
}
struct polyline *
-polyline_new(struct attr *parent, struct attr **attrs)
-{
- struct element *e;
-
- e = g_new0(struct element, 1);
- e->type=element_polyline;
- element_set_color(e, attrs);
- element_set_polyline_width(e, attrs);
- element_set_polyline_directed(e, attrs);
- element_set_polyline_dash(e, attrs);
- element_set_polyline_offset(e, attrs);
- return (struct polyline *)e;
+polyline_new(struct attr *parent, struct attr **attrs) {
+ struct element *e;
+
+ e = g_new0(struct element, 1);
+ e->type=element_polyline;
+ element_set_color(e, attrs);
+ element_set_polyline_width(e, attrs);
+ element_set_polyline_directed(e, attrs);
+ element_set_polyline_dash(e, attrs);
+ element_set_polyline_offset(e, attrs);
+ return (struct polyline *)e;
}
struct circle *
-circle_new(struct attr *parent, struct attr **attrs)
-{
- struct element *e;
- struct color color_black = {COLOR_BLACK_};
- struct color color_white = {COLOR_WHITE_};
+circle_new(struct attr *parent, struct attr **attrs) {
+ struct element *e;
+ struct color color_black = {COLOR_BLACK_};
+ struct color color_white = {COLOR_WHITE_};
- e = g_new0(struct element, 1);
- e->type=element_circle;
- e->color = color_black;
- e->u.circle.background_color = color_white;
- element_set_color(e, attrs);
- element_set_background_color(&e->u.circle.background_color, attrs);
- element_set_text_size(e, attrs);
- element_set_circle_width(e, attrs);
- element_set_circle_radius(e, attrs);
+ e = g_new0(struct element, 1);
+ e->type=element_circle;
+ e->color = color_black;
+ e->u.circle.background_color = color_white;
+ element_set_color(e, attrs);
+ element_set_background_color(&e->u.circle.background_color, attrs);
+ element_set_text_size(e, attrs);
+ element_set_circle_width(e, attrs);
+ element_set_circle_radius(e, attrs);
- return (struct circle *)e;
+ return (struct circle *)e;
}
struct text *
-text_new(struct attr *parent, struct attr **attrs)
-{
- struct element *e;
- struct color color_black = {COLOR_BLACK_};
- struct color color_white = {COLOR_WHITE_};
-
- e = g_new0(struct element, 1);
- e->type=element_text;
- element_set_text_size(e, attrs);
- e->color = color_black;
- e->u.text.background_color = color_white;
- element_set_color(e, attrs);
- element_set_background_color(&e->u.text.background_color, attrs);
-
- return (struct text *)e;
+text_new(struct attr *parent, struct attr **attrs) {
+ struct element *e;
+ struct color color_black = {COLOR_BLACK_};
+ struct color color_white = {COLOR_WHITE_};
+
+ e = g_new0(struct element, 1);
+ e->type=element_text;
+ element_set_text_size(e, attrs);
+ e->color = color_black;
+ e->u.text.background_color = color_white;
+ element_set_color(e, attrs);
+ element_set_background_color(&e->u.text.background_color, attrs);
+
+ return (struct text *)e;
}
struct icon *
-icon_new(struct attr *parent, struct attr **attrs)
-{
- struct element *e;
- struct attr *src,*w,*h,*rotation,*x,*y;
- src=attr_search(attrs, NULL, attr_src);
- if (! src)
- return NULL;
-
- e = g_malloc0(sizeof(*e)+strlen(src->u.str)+1);
- e->type=element_icon;
- e->u.icon.src=(char *)(e+1);
- if ((w=attr_search(attrs, NULL, attr_w)))
- e->u.icon.width=w->u.num;
- else
- e->u.icon.width=-1;
- if ((h=attr_search(attrs, NULL, attr_h)))
- e->u.icon.height=h->u.num;
- else
- e->u.icon.height=-1;
- if ((x=attr_search(attrs, NULL, attr_x)))
- e->u.icon.x=x->u.num;
- else
- e->u.icon.x=-1;
- if ((y=attr_search(attrs, NULL, attr_y)))
- e->u.icon.y=y->u.num;
- else
- e->u.icon.y=-1;
- if ((rotation=attr_search(attrs, NULL, attr_rotation)))
- e->u.icon.rotation=rotation->u.num;
- strcpy(e->u.icon.src,src->u.str);
-
- return (struct icon *)e;
+icon_new(struct attr *parent, struct attr **attrs) {
+ struct element *e;
+ struct attr *src,*w,*h,*rotation,*x,*y;
+ src=attr_search(attrs, NULL, attr_src);
+ if (! src)
+ return NULL;
+
+ e = g_malloc0(sizeof(*e)+strlen(src->u.str)+1);
+ e->type=element_icon;
+ e->u.icon.src=(char *)(e+1);
+ if ((w=attr_search(attrs, NULL, attr_w)))
+ e->u.icon.width=w->u.num;
+ else
+ e->u.icon.width=-1;
+ if ((h=attr_search(attrs, NULL, attr_h)))
+ e->u.icon.height=h->u.num;
+ else
+ e->u.icon.height=-1;
+ if ((x=attr_search(attrs, NULL, attr_x)))
+ e->u.icon.x=x->u.num;
+ else
+ e->u.icon.x=-1;
+ if ((y=attr_search(attrs, NULL, attr_y)))
+ e->u.icon.y=y->u.num;
+ else
+ e->u.icon.y=-1;
+ if ((rotation=attr_search(attrs, NULL, attr_rotation)))
+ e->u.icon.rotation=rotation->u.num;
+ strcpy(e->u.icon.src,src->u.str);
+
+ return (struct icon *)e;
}
struct image *
-image_new(struct attr *parent, struct attr **attrs)
-{
- struct element *e;
+image_new(struct attr *parent, struct attr **attrs) {
+ struct element *e;
- e = g_malloc0(sizeof(*e));
- e->type=element_image;
+ e = g_malloc0(sizeof(*e));
+ e->type=element_image;
- return (struct image *)e;
+ return (struct image *)e;
}
struct arrows *
-arrows_new(struct attr *parent, struct attr **attrs)
-{
- struct element *e;
- e = g_malloc0(sizeof(*e));
- e->type=element_arrows;
- element_set_color(e, attrs);
- return (struct arrows *)e;
-}
-
-int
-element_add_attr(struct element *e, struct attr *attr)
-{
- switch (attr->type) {
- case attr_coord:
- e->coord=g_realloc(e->coord,(e->coord_count+1)*sizeof(struct coord));
- e->coord[e->coord_count++]=*attr->u.coord;
- return 1;
- default:
- return 0;
- }
+arrows_new(struct attr *parent, struct attr **attrs) {
+ struct element *e;
+ e = g_malloc0(sizeof(*e));
+ e->type=element_arrows;
+ element_set_color(e, attrs);
+ return (struct arrows *)e;
+}
+
+int element_add_attr(struct element *e, struct attr *attr) {
+ switch (attr->type) {
+ case attr_coord:
+ e->coord=g_realloc(e->coord,(e->coord_count+1)*sizeof(struct coord));
+ e->coord[e->coord_count++]=*attr->u.coord;
+ return 1;
+ default:
+ return 0;
+ }
}
struct object_func layout_func = {
- attr_layout,
- (object_func_new)layout_new,
- (object_func_get_attr)layout_get_attr,
- (object_func_iter_new)layout_attr_iter_new,
- (object_func_iter_destroy)layout_attr_iter_destroy,
- (object_func_set_attr)NULL,
- (object_func_add_attr)layout_add_attr,
- (object_func_remove_attr)NULL,
- (object_func_init)NULL,
- (object_func_destroy)NULL,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_layout,
+ (object_func_new)layout_new,
+ (object_func_get_attr)layout_get_attr,
+ (object_func_iter_new)layout_attr_iter_new,
+ (object_func_iter_destroy)layout_attr_iter_destroy,
+ (object_func_set_attr)NULL,
+ (object_func_add_attr)layout_add_attr,
+ (object_func_remove_attr)NULL,
+ (object_func_init)NULL,
+ (object_func_destroy)NULL,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
struct object_func layer_func = {
- attr_layer,
- (object_func_new)layer_new,
- (object_func_get_attr)layer_get_attr,
- (object_func_iter_new)NULL,
- (object_func_iter_destroy)NULL,
- (object_func_set_attr)layer_set_attr,
- (object_func_add_attr)layer_add_attr,
- (object_func_remove_attr)NULL,
- (object_func_init)NULL,
- (object_func_destroy)layer_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_layer,
+ (object_func_new)layer_new,
+ (object_func_get_attr)layer_get_attr,
+ (object_func_iter_new)NULL,
+ (object_func_iter_destroy)NULL,
+ (object_func_set_attr)layer_set_attr,
+ (object_func_add_attr)layer_add_attr,
+ (object_func_remove_attr)NULL,
+ (object_func_init)NULL,
+ (object_func_destroy)layer_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/layout.h b/navit/layout.h
index a17d8e279..ece5d0cc8 100644
--- a/navit/layout.h
+++ b/navit/layout.h
@@ -68,13 +68,13 @@ struct element {
};
-struct itemgra {
+struct itemgra {
struct range order,sequence_range,speed_range,angle_range;
GList *type;
GList *elements;
};
-struct layer {
+struct layer {
NAVIT_OBJECT
struct navit *navit;
char *name;
diff --git a/navit/linguistics.c b/navit/linguistics.c
index 549f90e17..67b789482 100644
--- a/navit/linguistics.c
+++ b/navit/linguistics.c
@@ -4,260 +4,260 @@
#include "debug.h"
#include "linguistics.h"
-/* To have linguistics_casefold(linguistics_expand_special(s,i)) equal to linguistics_expand_special(linguistics_casefold(s),i),
+/* To have linguistics_casefold(linguistics_expand_special(s,i)) equal to linguistics_expand_special(linguistics_casefold(s),i),
* please always specify here lower case expansions for special letters not having case variants (like german ß).*/
-static const char *special[][3]={
-/* Capital Diacritics */
-/* ¨ Diaresis */
-{"Ä","A","AE"},
-{"Ë","E"},
-{"Ï","I"},
-{"Ö","O","OE"},
-{"Ü","U","UE"},
-{"Ÿ","Y"},
-/* ˝ Double Acute Accent */
-{"Ő","O","Ö"},
-{"Ű","U","Ü"},
-/* ´ Acute Accent */
-{"Á","A"},
-{"Ć","C"},
-{"É","E"},
-{"Í","I"},
-{"Ĺ","L"},
-{"Ń","N"},
-{"Ó","O"},
-{"Ŕ","R"},
-{"Ś","S"},
-{"Ú","U"},
-{"Ý","Y"},
-{"Ź","Z"},
-/* ˛ Ogonek (nosinė) */
-{"Ą","A"},
-{"Ę","E"},
-{"Į","I"},
-{"Ų","U"},
-/* ˙ Dot */
-{"Ċ","C"},
-{"Ė","E"},
-{"Ġ","G"},
-{"İ","I"},
-{"Ŀ","L"},
-{"Ż","Z"},
-/* – Stroke */
-{"Đ","D","DJ"}, /* Croatian Dj, not to be confused with the similar-looking Icelandic Eth */
-{"Ħ","H"},
-{"Ł","L"},
-{"Ŧ","T"},
-/* ˚ Ring */
-{"Å","A","AA"},
-{"Ů","U"},
-/* ˇ Caron (haček, paukščiukas) */
-{"Č","C"},
-{"Ď","D"},
-{"Ě","E"},
-{"Ľ","L"},
-{"Ň","N"},
-{"Ř","R"},
-{"Š","S"},
-{"Ť","T"},
-{"Ž","Z"},
-/* / Slash */
-{"Ø","O","OE"},
-/* ¯ Macron */
-{"Ā","A","AA"},
-{"Ē","E","EE"},
-{"Ī","I","II"},
-{"Ō","O","OO"},
-{"Ū","U","UU"},
-/* ˘ Brevis */
-{"Ă","A"},
-{"Ĕ","E"},
-{"Ğ","G"},
-{"Ĭ","I"},
-{"Ŏ","O"},
-{"Ŭ","U"},
-/* ^ Circumflex */
-{"Â","A"},
-{"Ĉ","C"},
-{"Ê","E"},
-{"Ĝ","G"},
-{"Ĥ","H"},
-{"Î","I"},
-{"Ĵ","J"},
-{"Ô","O"},
-{"Ŝ","S"},
-{"Û","U"},
-{"Ŵ","W"},
-{"Ŷ","Y"},
-/* ¸ Cedilla */
-{"Ç","C"},
-{"Ģ","G","GJ"},
-{"Ķ","K","KJ"},
-{"Ļ","L","LJ"},
-{"Ņ","N","NJ"},
-{"Ŗ","R"},
-{"Ş","S"},
-{"Ţ","T"},
-/* ~ Tilde */
-{"Ã","A"},
-{"Ĩ","I"},
-{"Ñ","N"},
-{"Õ","O"},
-{"Ũ","U"},
-/* ` Grave */
-{"À","A"},
-{"È","E"},
-{"Ì","I"},
-{"Ò","O"},
-{"Ù","U"},
-/* ligatures */
-{"Æ","A","AE"},
-{"IJ","IJ"},
-{"Œ","O","OE"},
-/* special letters */
-{"Ð","D","DH"}, /* Icelandic Eth, not to be confused with the similar-looking Croatian Dj */
-{"Ŋ","N","NG"},
-{"Þ","T","TH"},
-/* Small Diacritics */
-/* ¨ Diaresis */
-{"ä","a","ae"},
-{"ë","e"},
-{"ï","i"},
-{"ö","o","oe"},
-{"ü","u","ue"},
-{"ÿ","y"},
-/* ˝ Double Acute Accent */
-{"ő","o","ö"},
-{"ű","u","ü"},
-/* ´ Acute Accent */
-{"á","a"},
-{"ć","c"},
-{"é","e"},
-{"í","i"},
-{"ĺ","l"},
-{"ń","n"},
-{"ó","o"},
-{"ŕ","r"},
-{"ś","s"},
-{"ú","u"},
-{"ý","y"},
-{"ź","z"},
-/* ˛ Ogonek (nosinė) */
-{"ą","a"},
-{"ę","e"},
-{"į","i"},
-{"ų","u"},
-/* ˙ Dot (and dotless i) */
-{"ċ","c"},
-{"ė","e"},
-{"ġ","g"},
-{"ı","i"},
-{"ŀ","l"},
-{"ż","z"},
-/* – Stroke */
-{"đ","d","dj"},
-{"ħ","h"},
-{"ł","l"},
-{"ŧ","t"},
-/* ˚ Ring */
-{"å","a", "aa"},
-{"ů","u"},
-/* ˇ Caron (haček, paukščiukas) */
-{"č","c"},
-{"ď","d"},
-{"ě","e"},
-{"ľ","l"},
-{"ň","n"},
-{"ř","r"},
-{"š","s"},
-{"ť","t"},
-{"ž","z"},
-/* / Slash */
-{"ø","o", "oe"},
-/* Macron */
-{"ā","a","aa"},
-{"ē","e","ee"},
-{"ī","i","ii"},
-{"ō","o","oo"},
-{"ū","u","uu"},
-/* ˘ Brevis */
-{"ă","a"},
-{"ĕ","e"},
-{"ğ","g"},
-{"ĭ","i"},
-{"ŏ","o"},
-{"ŭ","u"},
-/* ^ Circumflex */
-{"â","a"},
-{"ĉ","c"},
-{"ê","e"},
-{"ĝ","g"},
-{"ĥ","h"},
-{"î","i"},
-{"ĵ","j"},
-{"ô","o"},
-{"ŝ","s"},
-{"û","u"},
-{"ŵ","w"},
-{"ŷ","y"},
-/* ¸ Cedilla */
-{"ç","c"},
-{"ģ","g","gj"},
-{"ķ","k","kj"},
-{"ļ","l","lj"},
-{"ņ","n","nj"},
-{"ŗ","r"},
-{"ş","s"},
-{"ţ","t"},
-/* ~ Tilde */
-{"ã","a"},
-{"ĩ","i"},
-{"õ","o"},
-{"ñ","n"},
-{"ũ","u"},
-/* ` Grave */
-{"à","a"},
-{"è","e"},
-{"ì","i"},
-{"ò","o"},
-{"ù","u"},
-/* ligatures */
-{"æ","a","ae"},
-{"ij","ij"},
-{"œ","o","oe"},
-{"ß","s","ss"},
-/* special letters */
-{"ð","d","dh"},
-{"ŋ","n","ng"},
-{"þ","t","th"},
+static const char *special[][3]= {
+ /* Capital Diacritics */
+ /* ¨ Diaresis */
+ {"Ä","A","AE"},
+ {"Ë","E"},
+ {"Ï","I"},
+ {"Ö","O","OE"},
+ {"Ü","U","UE"},
+ {"Ÿ","Y"},
+ /* ˝ Double Acute Accent */
+ {"Ő","O","Ö"},
+ {"Ű","U","Ü"},
+ /* ´ Acute Accent */
+ {"Á","A"},
+ {"Ć","C"},
+ {"É","E"},
+ {"Í","I"},
+ {"Ĺ","L"},
+ {"Ń","N"},
+ {"Ó","O"},
+ {"Ŕ","R"},
+ {"Ś","S"},
+ {"Ú","U"},
+ {"Ý","Y"},
+ {"Ź","Z"},
+ /* ˛ Ogonek (nosinė) */
+ {"Ą","A"},
+ {"Ę","E"},
+ {"Į","I"},
+ {"Ų","U"},
+ /* ˙ Dot */
+ {"Ċ","C"},
+ {"Ė","E"},
+ {"Ġ","G"},
+ {"İ","I"},
+ {"Ŀ","L"},
+ {"Ż","Z"},
+ /* – Stroke */
+ {"Đ","D","DJ"}, /* Croatian Dj, not to be confused with the similar-looking Icelandic Eth */
+ {"Ħ","H"},
+ {"Ł","L"},
+ {"Ŧ","T"},
+ /* ˚ Ring */
+ {"Å","A","AA"},
+ {"Ů","U"},
+ /* ˇ Caron (haček, paukščiukas) */
+ {"Č","C"},
+ {"Ď","D"},
+ {"Ě","E"},
+ {"Ľ","L"},
+ {"Ň","N"},
+ {"Ř","R"},
+ {"Š","S"},
+ {"Ť","T"},
+ {"Ž","Z"},
+ /* / Slash */
+ {"Ø","O","OE"},
+ /* ¯ Macron */
+ {"Ā","A","AA"},
+ {"Ē","E","EE"},
+ {"Ī","I","II"},
+ {"Ō","O","OO"},
+ {"Ū","U","UU"},
+ /* ˘ Brevis */
+ {"Ă","A"},
+ {"Ĕ","E"},
+ {"Ğ","G"},
+ {"Ĭ","I"},
+ {"Ŏ","O"},
+ {"Ŭ","U"},
+ /* ^ Circumflex */
+ {"Â","A"},
+ {"Ĉ","C"},
+ {"Ê","E"},
+ {"Ĝ","G"},
+ {"Ĥ","H"},
+ {"Î","I"},
+ {"Ĵ","J"},
+ {"Ô","O"},
+ {"Ŝ","S"},
+ {"Û","U"},
+ {"Ŵ","W"},
+ {"Ŷ","Y"},
+ /* ¸ Cedilla */
+ {"Ç","C"},
+ {"Ģ","G","GJ"},
+ {"Ķ","K","KJ"},
+ {"Ļ","L","LJ"},
+ {"Ņ","N","NJ"},
+ {"Ŗ","R"},
+ {"Ş","S"},
+ {"Ţ","T"},
+ /* ~ Tilde */
+ {"Ã","A"},
+ {"Ĩ","I"},
+ {"Ñ","N"},
+ {"Õ","O"},
+ {"Ũ","U"},
+ /* ` Grave */
+ {"À","A"},
+ {"È","E"},
+ {"Ì","I"},
+ {"Ò","O"},
+ {"Ù","U"},
+ /* ligatures */
+ {"Æ","A","AE"},
+ {"IJ","IJ"},
+ {"Œ","O","OE"},
+ /* special letters */
+ {"Ð","D","DH"}, /* Icelandic Eth, not to be confused with the similar-looking Croatian Dj */
+ {"Ŋ","N","NG"},
+ {"Þ","T","TH"},
+ /* Small Diacritics */
+ /* ¨ Diaresis */
+ {"ä","a","ae"},
+ {"ë","e"},
+ {"ï","i"},
+ {"ö","o","oe"},
+ {"ü","u","ue"},
+ {"ÿ","y"},
+ /* ˝ Double Acute Accent */
+ {"ő","o","ö"},
+ {"ű","u","ü"},
+ /* ´ Acute Accent */
+ {"á","a"},
+ {"ć","c"},
+ {"é","e"},
+ {"í","i"},
+ {"ĺ","l"},
+ {"ń","n"},
+ {"ó","o"},
+ {"ŕ","r"},
+ {"ś","s"},
+ {"ú","u"},
+ {"ý","y"},
+ {"ź","z"},
+ /* ˛ Ogonek (nosinė) */
+ {"ą","a"},
+ {"ę","e"},
+ {"į","i"},
+ {"ų","u"},
+ /* ˙ Dot (and dotless i) */
+ {"ċ","c"},
+ {"ė","e"},
+ {"ġ","g"},
+ {"ı","i"},
+ {"ŀ","l"},
+ {"ż","z"},
+ /* – Stroke */
+ {"đ","d","dj"},
+ {"ħ","h"},
+ {"ł","l"},
+ {"ŧ","t"},
+ /* ˚ Ring */
+ {"å","a", "aa"},
+ {"ů","u"},
+ /* ˇ Caron (haček, paukščiukas) */
+ {"č","c"},
+ {"ď","d"},
+ {"ě","e"},
+ {"ľ","l"},
+ {"ň","n"},
+ {"ř","r"},
+ {"š","s"},
+ {"ť","t"},
+ {"ž","z"},
+ /* / Slash */
+ {"ø","o", "oe"},
+ /* Macron */
+ {"ā","a","aa"},
+ {"ē","e","ee"},
+ {"ī","i","ii"},
+ {"ō","o","oo"},
+ {"ū","u","uu"},
+ /* ˘ Brevis */
+ {"ă","a"},
+ {"ĕ","e"},
+ {"ğ","g"},
+ {"ĭ","i"},
+ {"ŏ","o"},
+ {"ŭ","u"},
+ /* ^ Circumflex */
+ {"â","a"},
+ {"ĉ","c"},
+ {"ê","e"},
+ {"ĝ","g"},
+ {"ĥ","h"},
+ {"î","i"},
+ {"ĵ","j"},
+ {"ô","o"},
+ {"ŝ","s"},
+ {"û","u"},
+ {"ŵ","w"},
+ {"ŷ","y"},
+ /* ¸ Cedilla */
+ {"ç","c"},
+ {"ģ","g","gj"},
+ {"ķ","k","kj"},
+ {"ļ","l","lj"},
+ {"ņ","n","nj"},
+ {"ŗ","r"},
+ {"ş","s"},
+ {"ţ","t"},
+ /* ~ Tilde */
+ {"ã","a"},
+ {"ĩ","i"},
+ {"õ","o"},
+ {"ñ","n"},
+ {"ũ","u"},
+ /* ` Grave */
+ {"à","a"},
+ {"è","e"},
+ {"ì","i"},
+ {"ò","o"},
+ {"ù","u"},
+ /* ligatures */
+ {"æ","a","ae"},
+ {"ij","ij"},
+ {"œ","o","oe"},
+ {"ß","s","ss"},
+ /* special letters */
+ {"ð","d","dh"},
+ {"ŋ","n","ng"},
+ {"þ","t","th"},
-/* Cyrillic capital */
-{"Ё","Е"},
-{"І","I"},
-{"Ї","I"},
-{"Ў","У"},
-{"Є","Е","Э"},
-{"Ґ","Г"},
-{"Ѓ","Г"},
-{"Ђ","Д"},
-{"Ќ","К"},
-{"Љ","Л","ЛЬ"},
-{"Њ","Н","НЬ"},
-{"Џ","Ц"},
+ /* Cyrillic capital */
+ {"Ё","Е"},
+ {"І","I"},
+ {"Ї","I"},
+ {"Ў","У"},
+ {"Є","Е","Э"},
+ {"Ґ","Г"},
+ {"Ѓ","Г"},
+ {"Ђ","Д"},
+ {"Ќ","К"},
+ {"Љ","Л","ЛЬ"},
+ {"Њ","Н","НЬ"},
+ {"Џ","Ц"},
-/* Cyrillic small */
-{"ё","е"},
-{"і","i"},
-{"ї","i"},
-{"ў","у"},
-{"є","е","э"},
-{"ґ","г"},
-{"ѓ","г"},
-{"ђ","д"},
-{"ќ","к"},
-{"љ","л","ль"},
-{"њ","н","нь"},
-{"џ","ц"},
+ /* Cyrillic small */
+ {"ё","е"},
+ {"і","i"},
+ {"ї","i"},
+ {"ў","у"},
+ {"є","е","э"},
+ {"ґ","г"},
+ {"ѓ","г"},
+ {"ђ","д"},
+ {"ќ","к"},
+ {"љ","л","ль"},
+ {"њ","н","нь"},
+ {"џ","ц"},
};
@@ -266,15 +266,15 @@ static const char *special[][3]={
* Odd elements of array are strings of lower-case letters, in the order corresponding to directly preceeding even element.
* Last element of array should be NULL.
*/
-static const char *upperlower[]={
-/*Latin diacritics*/
-"ÄËÏÖÜŸŐŰÁĆÉÍĹŃÓŔŚÚÝŹĄĘĮŲĊĖĠİĿŻĐĦŁŦÅŮČĎĚĽŇŘŠŤŽØĀĒĪŌŪĂĔĞĬŎŬÂĈÊĜĤÎĴÔŜÛŴŶÇĢĶĻŅŖŞŢÃĨÑÕŨÀÈÌÒÙÆIJŒÐŊÞ",
-"äëïöüÿőűáćéíĺńóŕśúýźąęįųċėġıŀżđħłŧåůčďěľňřšťžøāēīōūăĕğĭŏŭâĉêĝĥîĵôŝûŵŷçģķļņŗşţãĩõñũàèìòùæijœðŋþ",
-/*Cyrillic*/
-"АБВГҐЃДЂЕЄЁЖЗИЙКЌЛЉМНЊОПРСТУФХЦЏЧШЩЪЫЬЭЮЯІЇЎ",
-"абвгґѓдђеєёжзийкќлљмнњопрстуфхцџчшщъыьэюяіїў",
+static const char *upperlower[]= {
+ /*Latin diacritics*/
+ "ÄËÏÖÜŸŐŰÁĆÉÍĹŃÓŔŚÚÝŹĄĘĮŲĊĖĠİĿŻĐĦŁŦÅŮČĎĚĽŇŘŠŤŽØĀĒĪŌŪĂĔĞĬŎŬÂĈÊĜĤÎĴÔŜÛŴŶÇĢĶĻŅŖŞŢÃĨÑÕŨÀÈÌÒÙÆIJŒÐŊÞ",
+ "äëïöüÿőűáćéíĺńóŕśúýźąęįųċėġıŀżđħłŧåůčďěľňřšťžøāēīōūăĕğĭŏŭâĉêĝĥîĵôŝûŵŷçģķļņŗşţãĩõñũàèìòùæijœðŋþ",
+ /*Cyrillic*/
+ "АБВГҐЃДЂЕЄЁЖЗИЙКЌЛЉМНЊОПРСТУФХЦЏЧШЩЪЫЬЭЮЯІЇЎ",
+ "абвгґѓдђеєёжзийкќлљмнњопрстуфхцџчшщъыьэюяіїў",
-NULL
+ NULL
};
static GHashTable *casefold_hash, *special_hash;
@@ -285,53 +285,49 @@ static GHashTable *casefold_hash, *special_hash;
* @param in String to prepeare.
* @return String prepared for case insensitive search. Result shoud be g_free()d after use.
*/
-char*
-linguistics_casefold(const char *in)
-{
- int len=strlen(in);
- const char *src=in;
- char *ret=g_new(char,len+1);
- char *dest=ret;
- char buf[10];
- while(*src && dest-ret<len){
- if(*src>='A' && *src<='Z') {
- *dest++=*src++ - 'A' + 'a';
- } else if (!(*src&128)) {
- *dest++=*src++;
- } else {
- int charlen;
- char *tmp, *folded;
- tmp=g_utf8_find_next_char(src,NULL);
- charlen=tmp-src+1;
- g_strlcpy(buf,src,charlen>10?10:charlen);
- folded=g_hash_table_lookup(casefold_hash,buf);
- if(folded) {
- while(*folded && dest-ret<len)
- *dest++=*folded++;
- src=tmp;
- } else {
- while(src<tmp && dest-ret<len)
- *dest++=*src++;
- }
- }
- }
- *dest=0;
- if(*src)
- dbg(lvl_error,"Casefolded string for '%s' needs extra space, result is trucated to '%s'.\n",in,ret);
- return ret;
+char* linguistics_casefold(const char *in) {
+ int len=strlen(in);
+ const char *src=in;
+ char *ret=g_new(char,len+1);
+ char *dest=ret;
+ char buf[10];
+ while(*src && dest-ret<len) {
+ if(*src>='A' && *src<='Z') {
+ *dest++=*src++ - 'A' + 'a';
+ } else if (!(*src&128)) {
+ *dest++=*src++;
+ } else {
+ int charlen;
+ char *tmp, *folded;
+ tmp=g_utf8_find_next_char(src,NULL);
+ charlen=tmp-src+1;
+ g_strlcpy(buf,src,charlen>10?10:charlen);
+ folded=g_hash_table_lookup(casefold_hash,buf);
+ if(folded) {
+ while(*folded && dest-ret<len)
+ *dest++=*folded++;
+ src=tmp;
+ } else {
+ while(src<tmp && dest-ret<len)
+ *dest++=*src++;
+ }
+ }
+ }
+ *dest=0;
+ if(*src)
+ dbg(lvl_error,"Casefolded string for '%s' needs extra space, result is truncated to '%s'.",in,ret);
+ return ret;
}
-static char**
-linguistics_get_special(const char *str, const char *end)
-{
- char *buf;
- int len;
- if(!end)
- end=g_utf8_find_next_char(str,NULL);
- len=end-str+1;
- buf=g_alloca(len);
- g_strlcpy(buf,str,len);
- return g_hash_table_lookup(special_hash,buf);
+static char** linguistics_get_special(const char *str, const char *end) {
+ char *buf;
+ int len;
+ if(!end)
+ end=g_utf8_find_next_char(str,NULL);
+ len=end-str+1;
+ buf=g_alloca(len);
+ g_strlcpy(buf,str,len);
+ return g_hash_table_lookup(special_hash,buf);
}
/**
@@ -339,42 +335,41 @@ linguistics_get_special(const char *str, const char *end)
*
* @param s1 First string to process, for example, an item name from the map. Will be linguistics_casefold()ed before comparison.
* @param s2 Second string to process, usually user supplied search string. Should be linguistics_casefold()ed before calling this function.
- * @param mode set to composition of linguistics_cmp_mode flags to have s1 linguistics_expand_special()ed, allow matches shorter than whole s1, or
+ * @param mode set to composition of linguistics_cmp_mode flags to have s1 linguistics_expand_special()ed, allow matches shorter than whole s1, or
* @param let matches start from any word boundary within s1
* @returns 0 when strings are equal
*/
-int linguistics_compare(const char *s1, const char *s2, enum linguistics_cmp_mode mode)
-{
- int ret=0;
- int i;
- int s2len=strlen(s2);
- char *s1f;
- /* Calling linguistics_casefold() before linguistics_expand_special() requires that result is independent of calling order. This seems
- to be true at the time of writing this comment. */
- s1f=linguistics_casefold(s1);
- for(i=0; i<3; i++) {
- char *s, *word;
- if(i>0)
- s=linguistics_expand_special(s1f,i);
- else
- s=s1f;
- word=s;
- while(word) {
- if(mode & linguistics_cmp_partial)
- ret=strncmp(word,s2,s2len);
- else
- ret=strcmp(word,s2);
- if(!ret || !(mode & linguistics_cmp_words))
- break;
- word=linguistics_next_word(word);
- }
- if(i>0)
- g_free(s);
- if(!ret || !(mode & linguistics_cmp_expand))
- break;
- }
- g_free(s1f);
- return ret;
+int linguistics_compare(const char *s1, const char *s2, enum linguistics_cmp_mode mode) {
+ int ret=0;
+ int i;
+ int s2len=strlen(s2);
+ char *s1f;
+ /* Calling linguistics_casefold() before linguistics_expand_special() requires that result is independent of calling order. This seems
+ to be true at the time of writing this comment. */
+ s1f=linguistics_casefold(s1);
+ for(i=0; i<3; i++) {
+ char *s, *word;
+ if(i>0)
+ s=linguistics_expand_special(s1f,i);
+ else
+ s=s1f;
+ word=s;
+ while(word) {
+ if(mode & linguistics_cmp_partial)
+ ret=strncmp(word,s2,s2len);
+ else
+ ret=strcmp(word,s2);
+ if(!ret || !(mode & linguistics_cmp_words))
+ break;
+ word=linguistics_next_word(word);
+ }
+ if(i>0)
+ g_free(s);
+ if(!ret || !(mode & linguistics_cmp_expand))
+ break;
+ }
+ g_free(s1f);
+ return ret;
}
/**
@@ -387,86 +382,80 @@ int linguistics_compare(const char *s1, const char *s2, enum linguistics_cmp_mod
* replacement has multitple letter (e.g. a-umlaut -> ae)
* @returns copy of string, with characters replaced
*/
-char *
-linguistics_expand_special(const char *str, int mode)
-{
- const char *in=str;
- char *out,*ret;
- int found=0;
- int ret_len=strlen(str);
- int in_rest=ret_len;
- out=ret=g_strdup(str);
- if (!mode)
- return ret;
- while (*in) {
- char *next=g_utf8_find_next_char(in, NULL);
- int len;
- int match=0;
+char *linguistics_expand_special(const char *str, int mode) {
+ const char *in=str;
+ char *out,*ret;
+ int found=0;
+ int ret_len=strlen(str);
+ int in_rest=ret_len;
+ out=ret=g_strdup(str);
+ if (!mode)
+ return ret;
+ while (*in) {
+ char *next=g_utf8_find_next_char(in, NULL);
+ int len;
+ int match=0;
- if(next)
- len=next-in;
- else
- len=strlen(in);
+ if(next)
+ len=next-in;
+ else
+ len=strlen(in);
- in_rest-=len;
-
- if (len > 1) {
- char **spc=linguistics_get_special(in, next);
- if (spc) {
- const char *replace=spc[mode];
- if (replace) {
- int replace_len=strlen(replace);
- if(out-ret+replace_len+in_rest>ret_len) {
- char *new_ret;
- ret_len+=(replace_len-len)*10;
- new_ret=g_realloc(ret,ret_len+1);
- out=new_ret+(out-ret);
- ret=new_ret;
- }
- dbg(lvl_debug,"found %s %s %d %s %d\n",in,spc[0],len,replace,replace_len);
- strcpy(out, replace);
- out+=replace_len;
- match=1;
- }
- }
- }
- if (match) {
- found=1;
- in+=len;
- } else {
- while (len-- > 0)
- *out++=*in++;
- }
- }
- *out++='\0';
- if (!found) {
- g_free(ret);
- ret=NULL;
- }
- return ret;
+ in_rest-=len;
+
+ if (len > 1) {
+ char **spc=linguistics_get_special(in, next);
+ if (spc) {
+ const char *replace=spc[mode];
+ if (replace) {
+ int replace_len=strlen(replace);
+ if(out-ret+replace_len+in_rest>ret_len) {
+ char *new_ret;
+ ret_len+=(replace_len-len)*10;
+ new_ret=g_realloc(ret,ret_len+1);
+ out=new_ret+(out-ret);
+ ret=new_ret;
+ }
+ dbg(lvl_debug,"found %s %s %d %s %d",in,spc[0],len,replace,replace_len);
+ strcpy(out, replace);
+ out+=replace_len;
+ match=1;
+ }
+ }
+ }
+ if (match) {
+ found=1;
+ in+=len;
+ } else {
+ while (len-- > 0)
+ *out++=*in++;
+ }
+ }
+ *out++='\0';
+ if (!found) {
+ g_free(ret);
+ ret=NULL;
+ }
+ return ret;
}
-char *
-linguistics_next_word(char *str)
-{
- int len=strcspn(str, LINGUISTICS_WORD_SEPARATORS_ASCII);
- if (!str[len] || !str[len+1])
- return NULL;
- return str+len+1;
+char *linguistics_next_word(char *str) {
+ int len=strcspn(str, LINGUISTICS_WORD_SEPARATORS_ASCII);
+ if (!str[len] || !str[len+1])
+ return NULL;
+ return str+len+1;
}
-int
-linguistics_search(const char *str)
-{
- if (!g_ascii_strcasecmp(str,"str"))
- return 0;
- if (!g_ascii_strcasecmp(str,"str."))
- return 0;
- if (!g_ascii_strcasecmp(str,"strasse"))
- return 0;
- if (!g_ascii_strcasecmp(str,"weg"))
- return 0;
- return 1;
+int linguistics_search(const char *str) {
+ if (!g_ascii_strcasecmp(str,"str"))
+ return 0;
+ if (!g_ascii_strcasecmp(str,"str."))
+ return 0;
+ if (!g_ascii_strcasecmp(str,"strasse"))
+ return 0;
+ if (!g_ascii_strcasecmp(str,"weg"))
+ return 0;
+ return 1;
}
/**
@@ -475,46 +464,41 @@ linguistics_search(const char *str)
* @param s pointer to the beginning of the char.
* @return newly allocated nul-terminated string containing one utf8 encoded character.
*/
-static char
-*linguistics_dup_utf8_char(const char *s)
-{
- char *ret, *next;
- next=g_utf8_find_next_char(s,NULL);
- ret=g_new(char, next-s+1);
- g_strlcpy(ret,s,next-s+1);
- return ret;
+static char
+*linguistics_dup_utf8_char(const char *s) {
+ char *ret, *next;
+ next=g_utf8_find_next_char(s,NULL);
+ ret=g_new(char, next-s+1);
+ g_strlcpy(ret,s,next-s+1);
+ return ret;
}
-void
-linguistics_init(void)
-{
- int i;
+void linguistics_init(void) {
+ int i;
+
+ casefold_hash=g_hash_table_new_full(g_str_hash, g_str_equal,g_free,g_free);
+
+ for (i = 0 ; upperlower[i]; i+=2) {
+ int j,k;
+ for(j=0,k=0; upperlower[i][j] && upperlower[i+1][k];) {
+ char *s1=linguistics_dup_utf8_char(upperlower[i]+j);
+ char *s2=linguistics_dup_utf8_char(upperlower[i+1]+k);
+ g_hash_table_insert(casefold_hash,s1,s2);
+ j+=strlen(s1);
+ k+=strlen(s2);
+ }
+ }
- casefold_hash=g_hash_table_new_full(g_str_hash, g_str_equal,g_free,g_free);
+ special_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ for (i = 0 ; i < sizeof(special)/sizeof(special[0]); i++)
+ g_hash_table_insert(special_hash,(gpointer)special[i][0],special[i]);
- for (i = 0 ; upperlower[i]; i+=2) {
- int j,k;
- for(j=0,k=0;upperlower[i][j] && upperlower[i+1][k];) {
- char *s1=linguistics_dup_utf8_char(upperlower[i]+j);
- char *s2=linguistics_dup_utf8_char(upperlower[i+1]+k);
- g_hash_table_insert(casefold_hash,s1,s2);
- j+=strlen(s1);
- k+=strlen(s2);
- }
- }
-
- special_hash=g_hash_table_new(g_str_hash, g_str_equal);
- for (i = 0 ; i < sizeof(special)/sizeof(special[0]); i++)
- g_hash_table_insert(special_hash,(gpointer)special[i][0],special[i]);
-
}
-void
-linguistics_free(void)
-{
- g_hash_table_destroy(casefold_hash);
- g_hash_table_destroy(special_hash);
- casefold_hash=NULL;
- special_hash=NULL;
+void linguistics_free(void) {
+ g_hash_table_destroy(casefold_hash);
+ g_hash_table_destroy(special_hash);
+ casefold_hash=NULL;
+ special_hash=NULL;
}
diff --git a/navit/log.c b/navit/log.c
index 2bca13425..3c40e9152 100644
--- a/navit/log.c
+++ b/navit/log.c
@@ -16,10 +16,10 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-
+
/** @file log.c
* @brief The log object.
- *
+ *
* This file implements everything needed for logging: the log object and its functions.
*
* @author Navit Team
@@ -49,34 +49,34 @@
#include "log.h"
struct log_data {
- int len;
- int max_len;
- char *data;
+ int len;
+ int max_len;
+ char *data;
};
struct log {
- NAVIT_OBJECT
- FILE *f;
- int overwrite;
- int empty;
- int lazy;
- int mkdir;
- int flush_size;
- int flush_time;
- struct event_timeout *timer;
- struct callback *timer_callback;
+ NAVIT_OBJECT
+ FILE *f;
+ int overwrite;
+ int empty;
+ int lazy;
+ int mkdir;
+ int flush_size;
+ int flush_time;
+ struct event_timeout *timer;
+ struct callback *timer_callback;
#ifdef HAVE_SYS_TIME_H
- struct timeval last_flush;
+ struct timeval last_flush;
#endif
- char *filename;
- char *filename_ex1;
- char *filename_ex2;
- struct log_data header;
- struct log_data data;
- struct log_data trailer;
+ char *filename;
+ char *filename_ex1;
+ char *filename_ex2;
+ struct log_data header;
+ struct log_data data;
+ struct log_data trailer;
};
-/**
+/**
* @brief Stores formatted time to a string.
*
* This function obtains local system time, formats it as specified in {@code fmt} and stores it in buffer.
@@ -87,67 +87,61 @@ struct log {
* @param fmt The format string
* @return Nothing
*/
-static void
-strftime_localtime(char *buffer, int size, char *fmt)
-{
- time_t t;
- struct tm *tm;
-
- t=time(NULL);
- tm=localtime(&t);
- strftime(buffer, size - 1, fmt, tm);
+static void strftime_localtime(char *buffer, int size, char *fmt) {
+ time_t t;
+ struct tm *tm;
+
+ t=time(NULL);
+ tm=localtime(&t);
+ strftime(buffer, size - 1, fmt, tm);
}
-/**
+/**
* @brief Expands placeholders in a filename
*
* This function examines the {@code log->filename} and replaces any placeholders
* found in it with date, time or an incremental number. If an incremental number is specified, the function
* will ensure the filename is unique. The expanded filename will be stored {@code log->filename_ex2}.
* The function uses {@code log->filename_ex1} to store the partly-expanded filename.
- *
+ *
* @param this_ The log object.
*/
-static void
-expand_filenames(struct log *this_)
-{
- char *pos,buffer[4096];
- int i;
-
- strftime_localtime(buffer, 4096, this_->filename);
- this_->filename_ex1=g_strdup(buffer);
- if ((pos=strstr(this_->filename_ex1,"%i"))) {
+static void expand_filenames(struct log *this_) {
+ char *pos,buffer[4096];
+ int i;
+
+ strftime_localtime(buffer, 4096, this_->filename);
+ this_->filename_ex1=g_strdup(buffer);
+ if ((pos=strstr(this_->filename_ex1,"%i"))) {
#ifdef HAVE_API_ANDROID
- pos[1]='d';
+ pos[1]='d';
#endif
- i=0;
- do {
- g_free(this_->filename_ex2);
- this_->filename_ex2=g_strdup_printf(this_->filename_ex1,i++);
- } while (file_exists(this_->filename_ex2));
+ i=0;
+ do {
+ g_free(this_->filename_ex2);
+ this_->filename_ex2=g_strdup_printf(this_->filename_ex1,i++);
+ } while (file_exists(this_->filename_ex2));
#ifdef HAVE_API_ANDROID
- pos[1]='i';
+ pos[1]='i';
#endif
- } else
- this_->filename_ex2=g_strdup(this_->filename_ex1);
+ } else
+ this_->filename_ex2=g_strdup(this_->filename_ex1);
}
-/**
+/**
* @brief Sets the time at which the log buffer was last flushed.
*
* This function sets {@code log->last_flush} to current time.
*
* @param this_ The log object.
*/
-static void
-log_set_last_flush(struct log *this_)
-{
+static void log_set_last_flush(struct log *this_) {
#ifdef HAVE_SYS_TIME_H
- gettimeofday(&this_->last_flush, NULL);
+ gettimeofday(&this_->last_flush, NULL);
#endif
}
-/**
+/**
* @brief Opens a log file.
*
* This function opens the log file for {@code log}.
@@ -165,47 +159,43 @@ log_set_last_flush(struct log *this_)
*
* @param this_ The log object.
*/
-static void
-log_open(struct log *this_)
-{
- char *mode;
- if (this_->overwrite)
- mode="w";
- else
- mode="r+";
- if (this_->mkdir)
- file_mkdir(this_->filename_ex2, 2);
- this_->f=fopen(this_->filename_ex2, mode);
- if (! this_->f)
- this_->f=fopen(this_->filename_ex2, "w");
- if (! this_->f)
- return;
- if (!this_->overwrite)
- fseek(this_->f, 0, SEEK_END);
- this_->empty = !ftell(this_->f);
- log_set_last_flush(this_);
+static void log_open(struct log *this_) {
+ char *mode;
+ if (this_->overwrite)
+ mode="w";
+ else
+ mode="r+";
+ if (this_->mkdir)
+ file_mkdir(this_->filename_ex2, 2);
+ this_->f=fopen(this_->filename_ex2, mode);
+ if (! this_->f)
+ this_->f=fopen(this_->filename_ex2, "w");
+ if (! this_->f)
+ return;
+ if (!this_->overwrite)
+ fseek(this_->f, 0, SEEK_END);
+ this_->empty = !ftell(this_->f);
+ log_set_last_flush(this_);
}
-/**
+/**
* @brief Closes a log file.
*
* This function writes the trailer to a log file, flushes it and closes the log file for {@code log}.
*
* @param this_ The log object.
*/
-static void
-log_close(struct log *this_)
-{
- if (! this_->f)
- return;
- if (this_->trailer.len)
- fwrite(this_->trailer.data, 1, this_->trailer.len, this_->f);
- fflush(this_->f);
- fclose(this_->f);
- this_->f=NULL;
+static void log_close(struct log *this_) {
+ if (! this_->f)
+ return;
+ if (this_->trailer.len)
+ fwrite(this_->trailer.data, 1, this_->trailer.len, this_->f);
+ fflush(this_->f);
+ fclose(this_->f);
+ this_->f=NULL;
}
-/**
+/**
* @brief Flushes the buffer of a log.
*
* This function writes buffered log data to the log file associated with {@code log}
@@ -230,49 +220,47 @@ log_close(struct log *this_)
* <br>
* {@code log_flag_truncate}: truncates the log file at the current position. On the Win32 Base API, this flag has no effect.
*/
-static void
-log_flush(struct log *this_, enum log_flags flags)
-{
- long pos;
- if (this_->lazy && !this_->f) {
- if (!this_->data.len)
- return;
- log_open(this_);
- }
- if (! this_->f)
- return;
- if (this_->empty) {
- if (this_->header.len)
- fwrite(this_->header.data, 1, this_->header.len, this_->f);
- if (this_->header.len || this_->data.len)
- this_->empty=0;
- }
- fwrite(this_->data.data, 1, this_->data.len, this_->f);
+static void log_flush(struct log *this_, enum log_flags flags) {
+ long pos;
+ if (this_->lazy && !this_->f) {
+ if (!this_->data.len)
+ return;
+ log_open(this_);
+ }
+ if (! this_->f)
+ return;
+ if (this_->empty) {
+ if (this_->header.len)
+ fwrite(this_->header.data, 1, this_->header.len, this_->f);
+ if (this_->header.len || this_->data.len)
+ this_->empty=0;
+ }
+ fwrite(this_->data.data, 1, this_->data.len, this_->f);
#ifndef HAVE_API_WIN32_BASE
- if (flags & log_flag_truncate) {
- pos=ftell(this_->f);
- ftruncate(fileno(this_->f), pos);
- }
+ if (flags & log_flag_truncate) {
+ pos=ftell(this_->f);
+ ftruncate(fileno(this_->f), pos);
+ }
#endif
- if (this_->trailer.len) {
- pos=ftell(this_->f);
- if (pos > 0) {
- fwrite(this_->trailer.data, 1, this_->trailer.len, this_->f);
- fseek(this_->f, pos, SEEK_SET);
- }
- }
- if (flags & log_flag_keep_pointer)
- fseek(this_->f, -this_->data.len, SEEK_CUR);
- fflush(this_->f);
- if (!(flags & log_flag_keep_buffer)) {
- g_free(this_->data.data);
- this_->data.data=NULL;
- this_->data.max_len=this_->data.len=0;
- }
- log_set_last_flush(this_);
+ if (this_->trailer.len) {
+ pos=ftell(this_->f);
+ if (pos > 0) {
+ fwrite(this_->trailer.data, 1, this_->trailer.len, this_->f);
+ fseek(this_->f, pos, SEEK_SET);
+ }
+ }
+ if (flags & log_flag_keep_pointer)
+ fseek(this_->f, -this_->data.len, SEEK_CUR);
+ fflush(this_->f);
+ if (!(flags & log_flag_keep_buffer)) {
+ g_free(this_->data.data);
+ this_->data.data=NULL;
+ this_->data.max_len=this_->data.len=0;
+ }
+ log_set_last_flush(this_);
}
-/**
+/**
* @brief Determines if the maximum buffer size of a log has been exceeded.
*
* This function examines the size of the data buffer to determine if it exceeds
@@ -281,13 +269,11 @@ log_flush(struct log *this_, enum log_flags flags)
* @param this_ The log object.
* @return True if the cache needs to be flushed, false otherwise.
*/
-static int
-log_flush_required(struct log *this_)
-{
- return this_->data.len > this_->flush_size;
+static int log_flush_required(struct log *this_) {
+ return this_->data.len > this_->flush_size;
}
-/**
+/**
* @brief Rotates a log file.
*
* This function rotates a log by stopping and immediately restarting it.
@@ -305,17 +291,15 @@ log_flush_required(struct log *this_)
*
* @param this_ The log object.
*/
-static void
-log_change(struct log *this_)
-{
- log_flush(this_,0);
- log_close(this_);
- expand_filenames(this_);
- if (! this_->lazy)
- log_open(this_);
+static void log_change(struct log *this_) {
+ log_flush(this_,0);
+ log_close(this_);
+ expand_filenames(this_);
+ if (! this_->lazy)
+ log_open(this_);
}
-/**
+/**
* @brief Determines if the log must be rotated.
*
* This function expands the date and time placeholders in {@code log->filename}
@@ -324,16 +308,14 @@ log_change(struct log *this_)
* @param this_ The log object.
* @return True if the date/time-dependent part of the filename has changed, false otherwise.
*/
-static int
-log_change_required(struct log *this_)
-{
- char buffer[4096];
+static int log_change_required(struct log *this_) {
+ char buffer[4096];
- strftime_localtime(buffer, 4096, this_->filename);
- return (strcmp(this_->filename_ex1, buffer) != 0);
+ strftime_localtime(buffer, 4096, this_->filename);
+ return (strcmp(this_->filename_ex1, buffer) != 0);
}
-/**
+/**
* @brief Determines if the flush interval of a log has elapsed and flushes the buffer if needed.
*
* This function calculates the difference between current time and {@code log->last_flush}.
@@ -341,21 +323,19 @@ log_change_required(struct log *this_)
*
* @param this_ The log object.
*/
-static void
-log_timer(struct log *this_)
-{
+static void log_timer(struct log *this_) {
#ifdef HAVE_SYS_TIME_H
- struct timeval tv;
- int delta;
- gettimeofday(&tv, NULL);
- delta=(tv.tv_sec-this_->last_flush.tv_sec)*1000+(tv.tv_usec-this_->last_flush.tv_usec)/1000;
- dbg(lvl_debug,"delta=%d flush_time=%d\n", delta, this_->flush_time);
- if (this_->flush_time && delta >= this_->flush_time*1000)
- log_flush(this_,0);
+ struct timeval tv;
+ int delta;
+ gettimeofday(&tv, NULL);
+ delta=(tv.tv_sec-this_->last_flush.tv_sec)*1000+(tv.tv_usec-this_->last_flush.tv_usec)/1000;
+ dbg(lvl_debug,"delta=%d flush_time=%d", delta, this_->flush_time);
+ if (this_->flush_time && delta >= this_->flush_time*1000)
+ log_flush(this_,0);
#endif
}
-/**
+/**
* @brief Gets an attribute
*
* @param this_ The log object.
@@ -364,14 +344,12 @@ log_timer(struct log *this_)
* @param iter An attribute iterator
* @return True for success, false for failure
*/
-int
-log_get_attr(struct log *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+int log_get_attr(struct log *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
}
-/**
+/**
* @brief Creates and initializes a new log object.
*
* @param parent The parent object.
@@ -379,59 +357,58 @@ log_get_attr(struct log *this_, enum attr_type type, struct attr *attr, struct a
* @return The new log object, or NULL if creation fails.
*/
struct log *
-log_new(struct attr * parent,struct attr **attrs)
-{
- struct log *ret=g_new0(struct log, 1);
- struct attr *data,*overwrite,*lazy,*mkdir,*flush_size,*flush_time;
- struct file_wordexp *wexp;
- char *filename, **wexp_data;
-
- dbg(lvl_debug,"enter\n");
- ret->func=&log_func;
- navit_object_ref((struct navit_object *)ret);
- data=attr_search(attrs, NULL, attr_data);
- if (! data)
- return NULL;
- filename=data->u.str;
- wexp=file_wordexp_new(filename);
- if (wexp && file_wordexp_get_count(wexp) > 0) {
- wexp_data=file_wordexp_get_array(wexp);
- filename=wexp_data[0];
- }
- if (filename)
- ret->filename=g_strdup(filename);
- if (wexp)
- file_wordexp_destroy(wexp);
- overwrite=attr_search(attrs, NULL, attr_overwrite);
- if (overwrite)
- ret->overwrite=overwrite->u.num;
- lazy=attr_search(attrs, NULL, attr_lazy);
- if (lazy)
- ret->lazy=lazy->u.num;
- mkdir=attr_search(attrs, NULL, attr_mkdir);
- if (mkdir)
- ret->mkdir=mkdir->u.num;
- flush_size=attr_search(attrs, NULL, attr_flush_size);
- if (flush_size)
- ret->flush_size=flush_size->u.num;
- flush_time=attr_search(attrs, NULL, attr_flush_time);
- if (flush_time)
- ret->flush_time=flush_time->u.num;
- if (ret->flush_time) {
- dbg(lvl_debug,"interval %d\n", ret->flush_time*1000);
- ret->timer_callback=callback_new_1(callback_cast(log_timer), ret);
- ret->timer=event_add_timeout(ret->flush_time*1000, 1, ret->timer_callback);
- }
- expand_filenames(ret);
- if (ret->lazy)
- log_set_last_flush(ret);
- else
- log_open(ret);
- ret->attrs=attr_list_dup(attrs);
- return ret;
+log_new(struct attr * parent,struct attr **attrs) {
+ struct log *ret=g_new0(struct log, 1);
+ struct attr *data,*overwrite,*lazy,*mkdir,*flush_size,*flush_time;
+ struct file_wordexp *wexp;
+ char *filename, **wexp_data;
+
+ dbg(lvl_debug,"enter");
+ ret->func=&log_func;
+ navit_object_ref((struct navit_object *)ret);
+ data=attr_search(attrs, NULL, attr_data);
+ if (! data)
+ return NULL;
+ filename=data->u.str;
+ wexp=file_wordexp_new(filename);
+ if (wexp && file_wordexp_get_count(wexp) > 0) {
+ wexp_data=file_wordexp_get_array(wexp);
+ filename=wexp_data[0];
+ }
+ if (filename)
+ ret->filename=g_strdup(filename);
+ if (wexp)
+ file_wordexp_destroy(wexp);
+ overwrite=attr_search(attrs, NULL, attr_overwrite);
+ if (overwrite)
+ ret->overwrite=overwrite->u.num;
+ lazy=attr_search(attrs, NULL, attr_lazy);
+ if (lazy)
+ ret->lazy=lazy->u.num;
+ mkdir=attr_search(attrs, NULL, attr_mkdir);
+ if (mkdir)
+ ret->mkdir=mkdir->u.num;
+ flush_size=attr_search(attrs, NULL, attr_flush_size);
+ if (flush_size)
+ ret->flush_size=flush_size->u.num;
+ flush_time=attr_search(attrs, NULL, attr_flush_time);
+ if (flush_time)
+ ret->flush_time=flush_time->u.num;
+ if (ret->flush_time) {
+ dbg(lvl_debug,"interval %d", ret->flush_time*1000);
+ ret->timer_callback=callback_new_1(callback_cast(log_timer), ret);
+ ret->timer=event_add_timeout(ret->flush_time*1000, 1, ret->timer_callback);
+ }
+ expand_filenames(ret);
+ if (ret->lazy)
+ log_set_last_flush(ret);
+ else
+ log_open(ret);
+ ret->attrs=attr_list_dup(attrs);
+ return ret;
}
-/**
+/**
* @brief Sets the header for a log file.
*
* This function sets the header, which is to be inserted into any log file before
@@ -441,15 +418,13 @@ log_new(struct attr * parent,struct attr **attrs)
* @param data The header data.
* @param len Size of the header data to be copied, in bytes.
*/
-void
-log_set_header(struct log *this_, char *data, int len)
-{
- this_->header.data=g_malloc(len);
- this_->header.max_len=this_->header.len=len;
- memcpy(this_->header.data, data, len);
+void log_set_header(struct log *this_, char *data, int len) {
+ this_->header.data=g_malloc(len);
+ this_->header.max_len=this_->header.len=len;
+ memcpy(this_->header.data, data, len);
}
-/**
+/**
* @brief Sets the trailer for a log file.
*
* This function sets the trailer, which is to be added to any log file after
@@ -459,18 +434,16 @@ log_set_header(struct log *this_, char *data, int len)
* @param data The trailer data.
* @param len Size of the trailer data to be copied, in bytes.
*/
-void
-log_set_trailer(struct log *this_, char *data, int len)
-{
- this_->trailer.data=g_malloc(len);
- this_->trailer.max_len=this_->trailer.len=len;
- memcpy(this_->trailer.data, data, len);
+void log_set_trailer(struct log *this_, char *data, int len) {
+ this_->trailer.data=g_malloc(len);
+ this_->trailer.max_len=this_->trailer.len=len;
+ memcpy(this_->trailer.data, data, len);
}
-/**
+/**
* @brief Writes to a log.
*
- * This function appends data to a log. It rotates the log, if needed, before
+ * This function appends data to a log. It rotates the log, if needed, before
* adding the new data. After adding, the log is flushed if the buffer exceeds
* its maximum size or if the {@code log_flag_force_flush} flag is set.
*
@@ -489,28 +462,26 @@ log_set_trailer(struct log *this_, char *data, int len)
* <br>
* {@code log_flag_truncate}: ignored
*/
-void
-log_write(struct log *this_, char *data, int len, enum log_flags flags)
-{
- dbg(lvl_debug,"enter\n");
- if (log_change_required(this_)) {
- dbg(lvl_debug,"log_change");
- log_change(this_);
- }
- if (flags & log_flag_replace_buffer)
- this_->data.len=0;
- if (this_->data.len + len > this_->data.max_len) {
- dbg(lvl_info,"overflow\n");
- this_->data.max_len+=16384; // FIXME: what if len exceeds this->data.max_len by more than 16384 bytes?
- this_->data.data=g_realloc(this_->data.data,this_->data.max_len);
- }
- memcpy(this_->data.data+this_->data.len, data, len);
- this_->data.len+=len;
- if (log_flush_required(this_) || (flags & log_flag_force_flush))
- log_flush(this_, flags);
+void log_write(struct log *this_, char *data, int len, enum log_flags flags) {
+ dbg(lvl_debug,"enter");
+ if (log_change_required(this_)) {
+ dbg(lvl_debug,"log_change");
+ log_change(this_);
+ }
+ if (flags & log_flag_replace_buffer)
+ this_->data.len=0;
+ if (this_->data.len + len > this_->data.max_len) {
+ dbg(lvl_info,"overflow");
+ this_->data.max_len+=16384; // FIXME: what if len exceeds this->data.max_len by more than 16384 bytes?
+ this_->data.data=g_realloc(this_->data.data,this_->data.max_len);
+ }
+ memcpy(this_->data.data+this_->data.len, data, len);
+ this_->data.len+=len;
+ if (log_flush_required(this_) || (flags & log_flag_force_flush))
+ log_flush(this_, flags);
}
-/**
+/**
* @brief Returns the data buffer of a log object and its length.
*
* @param this_ The log object.
@@ -518,16 +489,14 @@ log_write(struct log *this_, char *data, int len, enum log_flags flags)
* This can be NULL, in which case no information on buffer length will be stored.
* @return Pointer to the data buffer.
*/
-void *
-log_get_buffer(struct log *this_, int *len)
-{
- if (len)
- *len=this_->data.len;
- return this_->data.data;
+void *log_get_buffer(struct log *this_, int *len) {
+ if (len)
+ *len=this_->data.len;
+ return this_->data.data;
}
-/**
+/**
* @brief Writes a formatted string to a log.
*
* This function formats a string in a fashion similar to {@code printf()} and related functions
@@ -537,52 +506,48 @@ log_get_buffer(struct log *this_, int *len)
* @param fmt The format string.
* @param ... Additional arguments must be specified for each placeholder in the format string.
*/
-void
-log_printf(struct log *this_, char *fmt, ...)
-{
- char buffer[LOG_BUFFER_SIZE];
- int size;
- va_list ap;
+void log_printf(struct log *this_, char *fmt, ...) {
+ char buffer[LOG_BUFFER_SIZE];
+ int size;
+ va_list ap;
- va_start(ap, fmt);
+ va_start(ap, fmt);
- // Format the string and write it to the log
- size = g_vsnprintf(buffer, LOG_BUFFER_SIZE, fmt, ap);
- log_write(this_, buffer, size, 0);
+ // Format the string and write it to the log
+ size = g_vsnprintf(buffer, LOG_BUFFER_SIZE, fmt, ap);
+ log_write(this_, buffer, size, 0);
- va_end(ap);
+ va_end(ap);
}
-/**
+/**
* @brief Destroys a log object and frees up its memory.
*
* @param this_ The log object.
*/
-void
-log_destroy(struct log *this_)
-{
- dbg(lvl_debug,"enter\n");
- attr_list_free(this_->attrs);
- callback_destroy(this_->timer_callback);
- event_remove_timeout(this_->timer);
- log_flush(this_,0);
- log_close(this_);
- g_free(this_);
+void log_destroy(struct log *this_) {
+ dbg(lvl_debug,"enter");
+ attr_list_free(this_->attrs);
+ callback_destroy(this_->timer_callback);
+ event_remove_timeout(this_->timer);
+ log_flush(this_,0);
+ log_close(this_);
+ g_free(this_);
}
struct object_func log_func = {
- attr_log,
- (object_func_new)log_new,
- (object_func_get_attr)navit_object_get_attr,
- (object_func_iter_new)navit_object_attr_iter_new,
- (object_func_iter_destroy)navit_object_attr_iter_destroy,
- (object_func_set_attr)navit_object_set_attr,
- (object_func_add_attr)navit_object_add_attr,
- (object_func_remove_attr)navit_object_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)log_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_log,
+ (object_func_new)log_new,
+ (object_func_get_attr)navit_object_get_attr,
+ (object_func_iter_new)navit_object_attr_iter_new,
+ (object_func_iter_destroy)navit_object_attr_iter_destroy,
+ (object_func_set_attr)navit_object_set_attr,
+ (object_func_add_attr)navit_object_add_attr,
+ (object_func_remove_attr)navit_object_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)log_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/main.c b/navit/main.c
index 25dcb5267..986947f0d 100644
--- a/navit/main.c
+++ b/navit/main.c
@@ -64,351 +64,353 @@ struct map_data *map_data_default;
struct callback_list *cbl;
#ifdef HAVE_API_WIN32
-void
-setenv(char *var, char *val, int overwrite)
-{
- char *str=g_strdup_printf("%s=%s",var,val);
- if (overwrite || !getenv(var))
- putenv(str);
- g_free(str);
+void setenv(char *var, char *val, int overwrite) {
+ char *str=g_strdup_printf("%s=%s",var,val);
+ if (overwrite || !getenv(var))
+ putenv(str);
+ g_free(str);
}
#endif
/*
- * environment_vars[][0:name,1-3:mode]
- * ':' replaced with NAVIT_PREFIX
- * '::' replaced with NAVIT_PREFIX and LIBDIR
- * '~' replaced with HOME
+ * @def environment_vars
+ *
+ * @brief Environment variables automatically added (and expanded) by navit at startup
+ *
+ * A NUL-terminated string array
+ * environment_vars[0] is the name of the variable
+ * environment_vars[1] is the value used when running from source dir
+ * environment_vars[2] is the value used on Linux
+ * environment_vars[3] is the value used on Windows (see main_init())
+ * environment_vars[4] is the value used on Android
+ * ':' is replaced with NAVIT_PREFIX
+ * '::' is replaced with NAVIT_PREFIX and LIBDIR
+ * '~' is replaced with HOME
*/
-static char *environment_vars[][5]={
- {"NAVIT_LIBDIR", ":", ":/"LIB_DIR, ":\\lib", ":/lib"},
- {"NAVIT_SHAREDIR", ":", ":/"SHARE_DIR, ":", ":/share"},
- {"NAVIT_LOCALEDIR", ":/../locale",":/"LOCALE_DIR, ":\\locale", ":/locale"},
- {"NAVIT_USER_DATADIR",":", "~/.navit", ":\\data", ":/home"},
- {"NAVIT_LOGFILE", NULL, NULL, ":\\navit.log",NULL},
- {"NAVIT_LIBPREFIX", "*/.libs/", NULL, NULL, NULL},
- {NULL, NULL, NULL, NULL, NULL},
+static char *environment_vars[][5]= {
+ {"NAVIT_LIBDIR", ":", ":/"LIB_DIR, ":\\lib", ":/lib"},
+ {"NAVIT_SHAREDIR", ":", ":/"SHARE_DIR, ":", ":/share"},
+ {"NAVIT_LOCALEDIR", ":/../locale",":/"LOCALE_DIR, ":\\locale", ":/locale"},
+ {"NAVIT_USER_DATADIR",":", "~/.navit", ":\\data", ":/home"},
+ {"NAVIT_LOGFILE", NULL, NULL, ":\\navit.log",NULL},
+ {"NAVIT_LIBPREFIX", "*/.libs/", NULL, NULL, NULL},
+ {NULL, NULL, NULL, NULL, NULL},
};
-static void
-main_setup_environment(int mode)
-{
- int i=0;
- char *var,*val,*homedir;
- while ((var=environment_vars[i][0])) {
- val=environment_vars[i][mode+1];
- if (val) {
- switch (val[0]) {
- case ':':
- if (val[1] == ':')
- val=g_strdup_printf("%s/%s%s", getenv("NAVIT_PREFIX"), LIBDIR+sizeof(PREFIX), val+2);
- else
- val=g_strdup_printf("%s%s", getenv("NAVIT_PREFIX"), val+1);
- break;
- case '~':
- homedir=getenv("HOME");
- if (!homedir)
- homedir="./";
- val=g_strdup_printf("%s%s", homedir, val+1);
- break;
- default:
- val=g_strdup(val);
- break;
- }
- setenv(var, val, 0);
- g_free(val);
- }
- i++;
- }
+static void main_setup_environment(int mode) {
+ int i=0;
+ char *var,*val,*homedir;
+ while ((var=environment_vars[i][0])) {
+ val=environment_vars[i][mode+1];
+ if (val) {
+ switch (val[0]) {
+ case ':':
+ if (val[1] == ':')
+ val=g_strdup_printf("%s/%s%s", getenv("NAVIT_PREFIX"), LIBDIR+sizeof(PREFIX), val+2);
+ else
+ val=g_strdup_printf("%s%s", getenv("NAVIT_PREFIX"), val+1);
+ break;
+ case '~':
+ homedir=getenv("HOME");
+ if (!homedir)
+ homedir="./";
+ val=g_strdup_printf("%s%s", homedir, val+1);
+ break;
+ default:
+ val=g_strdup(val);
+ break;
+ }
+ setenv(var, val, 0);
+ g_free(val);
+ }
+ i++;
+ }
}
#ifdef HAVE_API_WIN32_BASE
-char *nls_table[][3]={
- // NLS Table compiled by Nick "Number6" Geoghegan
- // Not an exhaustive list, but supports 99% of all languages in Windows
- //{"LANGNAME", "CTRYNAME", "Language Code"},
- {"AFK", "ZAF", "af_ZA"}, // Afrikaans (South Africa)
- {"SQI", "ALB", "sq_AL"}, // Albanian (Albania)
- {"AMH", "ETH", "am_ET"}, // Amharic (Ethiopia)
- {"ARG", "DZA", "ar_DZ"}, // Arabic (Algeria)
- {"ARH", "BHR", "ar_BH"}, // Arabic (Bahrain)
- {"ARE", "EGY", "ar_EG"}, // Arabic (Egypt)
- {"ARI", "IRQ", "ar_IQ"}, // Arabic (Iraq)
- {"ARJ", "JOR", "ar_JO"}, // Arabic (Jordan)
- {"ARK", "KWT", "ar_KW"}, // Arabic (Kuwait)
- {"ARB", "LBN", "ar_LB"}, // Arabic (Lebanon)
- {"ARL", "LBY", "ar_LY"}, // Arabic (Libya)
- {"ARM", "MAR", "ar_MA"}, // Arabic (Morocco)
- {"ARO", "OMN", "ar_OM"}, // Arabic (Oman)
- {"ARQ", "QAT", "ar_QA"}, // Arabic (Qatar)
- {"ARA", "SAU", "ar_SA"}, // Arabic (Saudi Arabia)
- {"ARS", "SYR", "ar_SY"}, // Arabic (Syria)
- {"ART", "TUN", "ar_TN"}, // Arabic (Tunisia)
- {"ARU", "ARE", "ar_AE"}, // Arabic (U.A.E.)
- {"ARY", "YEM", "ar_YE"}, // Arabic (Yemen)
- {"HYE", "ARM", "hy_AM"}, // Armenian (Armenia)
- {"ASM", "IND", "as_IN"}, // Assamese (India)
- {"BAS", "RUS", "ba_RU"}, // Bashkir (Russia)
- {"EUQ", "ESP", "eu_ES"}, // Basque (Basque)
- {"BEL", "BLR", "be_BY"}, // Belarusian (Belarus)
- {"BNG", "BDG", "bn_BD"}, // Bengali (Bangladesh)
- {"BNG", "IND", "bn_IN"}, // Bengali (India)
- {"BRE", "FRA", "br_FR"}, // Breton (France)
- {"BGR", "BGR", "bg_BG"}, // Bulgarian (Bulgaria)
- {"CAT", "ESP", "ca_ES"}, // Catalan (Catalan)
- {"ZHH", "HKG", "zh_HK"}, // Chinese (Hong Kong S.A.R.)
- {"ZHM", "MCO", "zh_MO"}, // Chinese (Macao S.A.R.)
- {"CHS", "CHN", "zh_CN"}, // Chinese (People's Republic of China)
- {"ZHI", "SGP", "zh_SG"}, // Chinese (Singapore)
- {"CHT", "TWN", "zh_TW"}, // Chinese (Taiwan)
- {"COS", "FRA", "co_FR"}, // Corsican (France)
- {"HRV", "HRV", "hr_HR"}, // Croatian (Croatia)
- {"HRB", "BIH", "hr_BA"}, // Croatian (Latin, Bosnia and Herzegovina)
- {"CSY", "CZE", "cs_CZ"}, // Czech (Czech Republic)
- {"DAN", "DNK", "da_DK"}, // Danish (Denmark)
- {"NLB", "BEL", "nl_BE"}, // Dutch (Belgium)
- {"NLD", "NLD", "nl_NL"}, // Dutch (Netherlands)
- {"ENA", "AUS", "en_AU"}, // English (Australia)
- {"ENL", "BLZ", "en_BZ"}, // English (Belize)
- {"ENC", "CAN", "en_CA"}, // English (Canada)
- {"ENB", "CAR", "en_CB"}, // English (Caribbean)
- {"ENN", "IND", "en_IN"}, // English (India)
- {"ENI", "IRL", "en_IE"}, // English (Ireland)
- {"ENJ", "JAM", "en_JM"}, // English (Jamaica)
- {"ENM", "MYS", "en_MY"}, // English (Malaysia)
- {"ENZ", "NZL", "en_NZ"}, // English (New Zealand)
- {"ENP", "PHL", "en_PH"}, // English (Republic of the Philippines)
- {"ENE", "SGP", "en_SG"}, // English (Singapore)
- {"ENS", "ZAF", "en_ZA"}, // English (South Africa)
- {"ENT", "TTO", "en_TT"}, // English (Trinidad and Tobago)
- {"ENG", "GBR", "en_GB"}, // English (United Kingdom)
- {"ENU", "USA", "en_US"}, // English (United States)
- {"ENW", "ZWE", "en_ZW"}, // English (Zimbabwe)
- {"ETI", "EST", "et_EE"}, // Estonian (Estonia)
- {"FOS", "FRO", "fo_FO"}, // Faroese (Faroe Islands)
- {"FIN", "FIN", "fi_FI"}, // Finnish (Finland)
- {"FRB", "BEL", "fr_BE"}, // French (Belgium)
- {"FRC", "CAN", "fr_CA"}, // French (Canada)
- {"FRA", "FRA", "fr_FR"}, // French (France)
- {"FRL", "LUX", "fr_LU"}, // French (Luxembourg)
- {"FRM", "MCO", "fr_MC"}, // French (Principality of Monaco)
- {"FRS", "CHE", "fr_CH"}, // French (Switzerland)
- {"FYN", "NLD", "fy_NL"}, // Frisian (Netherlands)
- {"GLC", "ESP", "gl_ES"}, // Galician (Galician)
- {"KAT", "GEO", "ka_GE"}, // Georgian (Georgia)
- {"DEA", "AUT", "de_AT"}, // German (Austria)
- {"DEU", "DEU", "de_DE"}, // German (Germany)
- {"DEC", "LIE", "de_LI"}, // German (Liechtenstein)
- {"DEL", "LUX", "de_LU"}, // German (Luxembourg)
- {"DES", "CHE", "de_CH"}, // German (Switzerland)
- {"ELL", "GRC", "el_GR"}, // Greek (Greece)
- {"KAL", "GRL", "kl_GL"}, // Greenlandic (Greenland)
- {"GUJ", "IND", "gu_IN"}, // Gujarati (India)
- {"HEB", "ISR", "he_IL"}, // Hebrew (Israel)
- {"HIN", "IND", "hi_IN"}, // Hindi (India)
- {"HUN", "HUN", "hu_HU"}, // Hungarian (Hungary)
- {"ISL", "ISL", "is_IS"}, // Icelandic (Iceland)
- {"IBO", "NGA", "ig_NG"}, // Igbo (Nigeria)
- {"IND", "IDN", "id_ID"}, // Indonesian (Indonesia)
- {"IRE", "IRL", "ga_IE"}, // Irish (Ireland)
- {"XHO", "ZAF", "xh_ZA"}, // isiXhosa (South Africa)
- {"ZUL", "ZAF", "zu_ZA"}, // isiZulu (South Africa)
- {"ITA", "ITA", "it_IT"}, // Italian (Italy)
- {"ITS", "CHE", "it_CH"}, // Italian (Switzerland)
- {"JPN", "JPN", "ja_JP"}, // Japanese (Japan)
- {"KDI", "IND", "kn_IN"}, // Kannada (India)
- {"KKZ", "KAZ", "kk_KZ"}, // Kazakh (Kazakhstan)
- {"KHM", "KHM", "km_KH"}, // Khmer (Cambodia)
- {"KIN", "RWA", "rw_RW"}, // Kinyarwanda (Rwanda)
- {"SWK", "KEN", "sw_KE"}, // Kiswahili (Kenya)
- {"KOR", "KOR", "ko_KR"}, // Korean (Korea)
- {"KYR", "KGZ", "ky_KG"}, // Kyrgyz (Kyrgyzstan)
- {"LAO", "LAO", "lo_LA"}, // Lao (Lao P.D.R.)
- {"LVI", "LVA", "lv_LV"}, // Latvian (Latvia)
- {"LTH", "LTU", "lt_LT"}, // Lithuanian (Lithuania)
- {"LBX", "LUX", "lb_LU"}, // Luxembourgish (Luxembourg)
- {"MKI", "MKD", "mk_MK"}, // Macedonian (Former Yugoslav Republic of Macedonia)
- {"MSB", "BRN", "ms_BN"}, // Malay (Brunei Darussalam)
- {"MSL", "MYS", "ms_MY"}, // Malay (Malaysia)
- {"MYM", "IND", "ml_IN"}, // Malayalam (India)
- {"MLT", "MLT", "mt_MT"}, // Maltese (Malta)
- {"MRI", "NZL", "mi_NZ"}, // Maori (New Zealand)
- {"MAR", "IND", "mr_IN"}, // Marathi (India)
- {"MON", "MNG", "mn_MN"}, // Mongolian (Cyrillic, Mongolia)
- {"NEP", "NEP", "ne_NP"}, // Nepali (Nepal)
- {"NOR", "NOR", "nb_NO"}, // Norwegian, Bokmå(Norway)
- {"NON", "NOR", "nn_NO"}, // Norwegian, Nynorsk (Norway)
- {"OCI", "FRA", "oc_FR"}, // Occitan (France)
- {"ORI", "IND", "or_IN"}, // Oriya (India)
- {"PAS", "AFG", "ps_AF"}, // Pashto (Afghanistan)
- {"FAR", "IRN", "fa_IR"}, // Persian
- {"PLK", "POL", "pl_PL"}, // Polish (Poland)
- {"PTB", "BRA", "pt_BR"}, // Portuguese (Brazil)
- {"PTG", "PRT", "pt_PT"}, // Portuguese (Portugal)
- {"PAN", "IND", "pa_IN"}, // Punjabi (India)
- {"ROM", "ROM", "ro_RO"}, // Romanian (Romania)
- {"RMC", "CHE", "rm_CH"}, // Romansh (Switzerland)
- {"RUS", "RUS", "ru_RU"}, // Russian (Russia)
- {"SMG", "FIN", "se_FI"}, // Sami, Northern (Finland)
- {"SME", "NOR", "se_NO"}, // Sami, Northern (Norway)
- {"SMF", "SWE", "se_SE"}, // Sami, Northern (Sweden)
- {"SAN", "IND", "sa_IN"}, // Sanskrit (India)
- {"TSN", "ZAF", "tn_ZA"}, // Setswana (South Africa)
- {"SIN", "LKA", "si_LK"}, // Sinhala (Sri Lanka)
- {"SKY", "SVK", "sk_SK"}, // Slovak (Slovakia)
- {"SLV", "SVN", "sl_SI"}, // Slovenian (Slovenia)
- {"ESS", "ARG", "es_AR"}, // Spanish (Argentina)
- {"ESB", "BOL", "es_BO"}, // Spanish (Bolivia)
- {"ESL", "CHL", "es_CL"}, // Spanish (Chile)
- {"ESO", "COL", "es_CO"}, // Spanish (Colombia)
- {"ESC", "CRI", "es_CR"}, // Spanish (Costa Rica)
- {"ESD", "DOM", "es_DO"}, // Spanish (Dominican Republic)
- {"ESF", "ECU", "es_EC"}, // Spanish (Ecuador)
- {"ESE", "SLV", "es_SV"}, // Spanish (El Salvador)
- {"ESG", "GTM", "es_GT"}, // Spanish (Guatemala)
- {"ESH", "HND", "es_HN"}, // Spanish (Honduras)
- {"ESM", "MEX", "es_MX"}, // Spanish (Mexico)
- {"ESI", "NIC", "es_NI"}, // Spanish (Nicaragua)
- {"ESA", "PAN", "es_PA"}, // Spanish (Panama)
- {"ESZ", "PRY", "es_PY"}, // Spanish (Paraguay)
- {"ESR", "PER", "es_PE"}, // Spanish (Peru)
- {"ESU", "PRI", "es_PR"}, // Spanish (Puerto Rico)
- {"ESN", "ESP", "es_ES"}, // Spanish (Spain)
- {"EST", "USA", "es_US"}, // Spanish (United States)
- {"ESY", "URY", "es_UY"}, // Spanish (Uruguay)
- {"ESV", "VEN", "es_VE"}, // Spanish (Venezuela)
- {"SVF", "FIN", "sv_FI"}, // Swedish (Finland)
- {"SVE", "SWE", "sv_SE"}, // Swedish (Sweden)
- {"TAM", "IND", "ta_IN"}, // Tamil (India)
- {"TTT", "RUS", "tt_RU"}, // Tatar (Russia)
- {"TEL", "IND", "te_IN"}, // Telugu (India)
- {"THA", "THA", "th_TH"}, // Thai (Thailand)
- {"BOB", "CHN", "bo_CN"}, // Tibetan (PRC)
- {"TRK", "TUR", "tr_TR"}, // Turkish (Turkey)
- {"TUK", "TKM", "tk_TM"}, // Turkmen (Turkmenistan)
- {"UIG", "CHN", "ug_CN"}, // Uighur (PRC)
- {"UKR", "UKR", "uk_UA"}, // Ukrainian (Ukraine)
- {"URD", "PAK", "ur_PK"}, // Urdu (Islamic Republic of Pakistan)
- {"VIT", "VNM", "vi_VN"}, // Vietnamese (Vietnam)
- {"CYM", "GBR", "cy_GB"}, // Welsh (United Kingdom)
- {"WOL", "SEN", "wo_SN"}, // Wolof (Senegal)
- {"III", "CHN", "ii_CN"}, // Yi (PRC)
- {"YOR", "NGA", "yo_NG"}, // Yoruba (Nigeria)
- {NULL,NULL,NULL}, // Default - Can't find the language / Language not listed above
+char *nls_table[][3]= {
+ // NLS Table compiled by Nick "Number6" Geoghegan
+ // Not an exhaustive list, but supports 99% of all languages in Windows
+ //{"LANGNAME", "CTRYNAME", "Language Code"},
+ {"AFK", "ZAF", "af_ZA"}, // Afrikaans (South Africa)
+ {"SQI", "ALB", "sq_AL"}, // Albanian (Albania)
+ {"AMH", "ETH", "am_ET"}, // Amharic (Ethiopia)
+ {"ARG", "DZA", "ar_DZ"}, // Arabic (Algeria)
+ {"ARH", "BHR", "ar_BH"}, // Arabic (Bahrain)
+ {"ARE", "EGY", "ar_EG"}, // Arabic (Egypt)
+ {"ARI", "IRQ", "ar_IQ"}, // Arabic (Iraq)
+ {"ARJ", "JOR", "ar_JO"}, // Arabic (Jordan)
+ {"ARK", "KWT", "ar_KW"}, // Arabic (Kuwait)
+ {"ARB", "LBN", "ar_LB"}, // Arabic (Lebanon)
+ {"ARL", "LBY", "ar_LY"}, // Arabic (Libya)
+ {"ARM", "MAR", "ar_MA"}, // Arabic (Morocco)
+ {"ARO", "OMN", "ar_OM"}, // Arabic (Oman)
+ {"ARQ", "QAT", "ar_QA"}, // Arabic (Qatar)
+ {"ARA", "SAU", "ar_SA"}, // Arabic (Saudi Arabia)
+ {"ARS", "SYR", "ar_SY"}, // Arabic (Syria)
+ {"ART", "TUN", "ar_TN"}, // Arabic (Tunisia)
+ {"ARU", "ARE", "ar_AE"}, // Arabic (U.A.E.)
+ {"ARY", "YEM", "ar_YE"}, // Arabic (Yemen)
+ {"HYE", "ARM", "hy_AM"}, // Armenian (Armenia)
+ {"ASM", "IND", "as_IN"}, // Assamese (India)
+ {"BAS", "RUS", "ba_RU"}, // Bashkir (Russia)
+ {"EUQ", "ESP", "eu_ES"}, // Basque (Basque)
+ {"BEL", "BLR", "be_BY"}, // Belarusian (Belarus)
+ {"BNG", "BDG", "bn_BD"}, // Bengali (Bangladesh)
+ {"BNG", "IND", "bn_IN"}, // Bengali (India)
+ {"BRE", "FRA", "br_FR"}, // Breton (France)
+ {"BGR", "BGR", "bg_BG"}, // Bulgarian (Bulgaria)
+ {"CAT", "ESP", "ca_ES"}, // Catalan (Catalan)
+ {"ZHH", "HKG", "zh_HK"}, // Chinese (Hong Kong S.A.R.)
+ {"ZHM", "MCO", "zh_MO"}, // Chinese (Macao S.A.R.)
+ {"CHS", "CHN", "zh_CN"}, // Chinese (People's Republic of China)
+ {"ZHI", "SGP", "zh_SG"}, // Chinese (Singapore)
+ {"CHT", "TWN", "zh_TW"}, // Chinese (Taiwan)
+ {"COS", "FRA", "co_FR"}, // Corsican (France)
+ {"HRV", "HRV", "hr_HR"}, // Croatian (Croatia)
+ {"HRB", "BIH", "hr_BA"}, // Croatian (Latin, Bosnia and Herzegovina)
+ {"CSY", "CZE", "cs_CZ"}, // Czech (Czech Republic)
+ {"DAN", "DNK", "da_DK"}, // Danish (Denmark)
+ {"NLB", "BEL", "nl_BE"}, // Dutch (Belgium)
+ {"NLD", "NLD", "nl_NL"}, // Dutch (Netherlands)
+ {"ENA", "AUS", "en_AU"}, // English (Australia)
+ {"ENL", "BLZ", "en_BZ"}, // English (Belize)
+ {"ENC", "CAN", "en_CA"}, // English (Canada)
+ {"ENB", "CAR", "en_CB"}, // English (Caribbean)
+ {"ENN", "IND", "en_IN"}, // English (India)
+ {"ENI", "IRL", "en_IE"}, // English (Ireland)
+ {"ENJ", "JAM", "en_JM"}, // English (Jamaica)
+ {"ENM", "MYS", "en_MY"}, // English (Malaysia)
+ {"ENZ", "NZL", "en_NZ"}, // English (New Zealand)
+ {"ENP", "PHL", "en_PH"}, // English (Republic of the Philippines)
+ {"ENE", "SGP", "en_SG"}, // English (Singapore)
+ {"ENS", "ZAF", "en_ZA"}, // English (South Africa)
+ {"ENT", "TTO", "en_TT"}, // English (Trinidad and Tobago)
+ {"ENG", "GBR", "en_GB"}, // English (United Kingdom)
+ {"ENU", "USA", "en_US"}, // English (United States)
+ {"ENW", "ZWE", "en_ZW"}, // English (Zimbabwe)
+ {"ETI", "EST", "et_EE"}, // Estonian (Estonia)
+ {"FOS", "FRO", "fo_FO"}, // Faroese (Faroe Islands)
+ {"FIN", "FIN", "fi_FI"}, // Finnish (Finland)
+ {"FRB", "BEL", "fr_BE"}, // French (Belgium)
+ {"FRC", "CAN", "fr_CA"}, // French (Canada)
+ {"FRA", "FRA", "fr_FR"}, // French (France)
+ {"FRL", "LUX", "fr_LU"}, // French (Luxembourg)
+ {"FRM", "MCO", "fr_MC"}, // French (Principality of Monaco)
+ {"FRS", "CHE", "fr_CH"}, // French (Switzerland)
+ {"FYN", "NLD", "fy_NL"}, // Frisian (Netherlands)
+ {"GLC", "ESP", "gl_ES"}, // Galician (Galician)
+ {"KAT", "GEO", "ka_GE"}, // Georgian (Georgia)
+ {"DEA", "AUT", "de_AT"}, // German (Austria)
+ {"DEU", "DEU", "de_DE"}, // German (Germany)
+ {"DEC", "LIE", "de_LI"}, // German (Liechtenstein)
+ {"DEL", "LUX", "de_LU"}, // German (Luxembourg)
+ {"DES", "CHE", "de_CH"}, // German (Switzerland)
+ {"ELL", "GRC", "el_GR"}, // Greek (Greece)
+ {"KAL", "GRL", "kl_GL"}, // Greenlandic (Greenland)
+ {"GUJ", "IND", "gu_IN"}, // Gujarati (India)
+ {"HEB", "ISR", "he_IL"}, // Hebrew (Israel)
+ {"HIN", "IND", "hi_IN"}, // Hindi (India)
+ {"HUN", "HUN", "hu_HU"}, // Hungarian (Hungary)
+ {"ISL", "ISL", "is_IS"}, // Icelandic (Iceland)
+ {"IBO", "NGA", "ig_NG"}, // Igbo (Nigeria)
+ {"IND", "IDN", "id_ID"}, // Indonesian (Indonesia)
+ {"IRE", "IRL", "ga_IE"}, // Irish (Ireland)
+ {"XHO", "ZAF", "xh_ZA"}, // isiXhosa (South Africa)
+ {"ZUL", "ZAF", "zu_ZA"}, // isiZulu (South Africa)
+ {"ITA", "ITA", "it_IT"}, // Italian (Italy)
+ {"ITS", "CHE", "it_CH"}, // Italian (Switzerland)
+ {"JPN", "JPN", "ja_JP"}, // Japanese (Japan)
+ {"KDI", "IND", "kn_IN"}, // Kannada (India)
+ {"KKZ", "KAZ", "kk_KZ"}, // Kazakh (Kazakhstan)
+ {"KHM", "KHM", "km_KH"}, // Khmer (Cambodia)
+ {"KIN", "RWA", "rw_RW"}, // Kinyarwanda (Rwanda)
+ {"SWK", "KEN", "sw_KE"}, // Kiswahili (Kenya)
+ {"KOR", "KOR", "ko_KR"}, // Korean (Korea)
+ {"KYR", "KGZ", "ky_KG"}, // Kyrgyz (Kyrgyzstan)
+ {"LAO", "LAO", "lo_LA"}, // Lao (Lao P.D.R.)
+ {"LVI", "LVA", "lv_LV"}, // Latvian (Latvia)
+ {"LTH", "LTU", "lt_LT"}, // Lithuanian (Lithuania)
+ {"LBX", "LUX", "lb_LU"}, // Luxembourgish (Luxembourg)
+ {"MKI", "MKD", "mk_MK"}, // Macedonian (Former Yugoslav Republic of Macedonia)
+ {"MSB", "BRN", "ms_BN"}, // Malay (Brunei Darussalam)
+ {"MSL", "MYS", "ms_MY"}, // Malay (Malaysia)
+ {"MYM", "IND", "ml_IN"}, // Malayalam (India)
+ {"MLT", "MLT", "mt_MT"}, // Maltese (Malta)
+ {"MRI", "NZL", "mi_NZ"}, // Maori (New Zealand)
+ {"MAR", "IND", "mr_IN"}, // Marathi (India)
+ {"MON", "MNG", "mn_MN"}, // Mongolian (Cyrillic, Mongolia)
+ {"NEP", "NEP", "ne_NP"}, // Nepali (Nepal)
+ {"NOR", "NOR", "nb_NO"}, // Norwegian, Bokmå(Norway)
+ {"NON", "NOR", "nn_NO"}, // Norwegian, Nynorsk (Norway)
+ {"OCI", "FRA", "oc_FR"}, // Occitan (France)
+ {"ORI", "IND", "or_IN"}, // Oriya (India)
+ {"PAS", "AFG", "ps_AF"}, // Pashto (Afghanistan)
+ {"FAR", "IRN", "fa_IR"}, // Persian
+ {"PLK", "POL", "pl_PL"}, // Polish (Poland)
+ {"PTB", "BRA", "pt_BR"}, // Portuguese (Brazil)
+ {"PTG", "PRT", "pt_PT"}, // Portuguese (Portugal)
+ {"PAN", "IND", "pa_IN"}, // Punjabi (India)
+ {"ROM", "ROM", "ro_RO"}, // Romanian (Romania)
+ {"RMC", "CHE", "rm_CH"}, // Romansh (Switzerland)
+ {"RUS", "RUS", "ru_RU"}, // Russian (Russia)
+ {"SMG", "FIN", "se_FI"}, // Sami, Northern (Finland)
+ {"SME", "NOR", "se_NO"}, // Sami, Northern (Norway)
+ {"SMF", "SWE", "se_SE"}, // Sami, Northern (Sweden)
+ {"SAN", "IND", "sa_IN"}, // Sanskrit (India)
+ {"TSN", "ZAF", "tn_ZA"}, // Setswana (South Africa)
+ {"SIN", "LKA", "si_LK"}, // Sinhala (Sri Lanka)
+ {"SKY", "SVK", "sk_SK"}, // Slovak (Slovakia)
+ {"SLV", "SVN", "sl_SI"}, // Slovenian (Slovenia)
+ {"ESS", "ARG", "es_AR"}, // Spanish (Argentina)
+ {"ESB", "BOL", "es_BO"}, // Spanish (Bolivia)
+ {"ESL", "CHL", "es_CL"}, // Spanish (Chile)
+ {"ESO", "COL", "es_CO"}, // Spanish (Colombia)
+ {"ESC", "CRI", "es_CR"}, // Spanish (Costa Rica)
+ {"ESD", "DOM", "es_DO"}, // Spanish (Dominican Republic)
+ {"ESF", "ECU", "es_EC"}, // Spanish (Ecuador)
+ {"ESE", "SLV", "es_SV"}, // Spanish (El Salvador)
+ {"ESG", "GTM", "es_GT"}, // Spanish (Guatemala)
+ {"ESH", "HND", "es_HN"}, // Spanish (Honduras)
+ {"ESM", "MEX", "es_MX"}, // Spanish (Mexico)
+ {"ESI", "NIC", "es_NI"}, // Spanish (Nicaragua)
+ {"ESA", "PAN", "es_PA"}, // Spanish (Panama)
+ {"ESZ", "PRY", "es_PY"}, // Spanish (Paraguay)
+ {"ESR", "PER", "es_PE"}, // Spanish (Peru)
+ {"ESU", "PRI", "es_PR"}, // Spanish (Puerto Rico)
+ {"ESN", "ESP", "es_ES"}, // Spanish (Spain)
+ {"EST", "USA", "es_US"}, // Spanish (United States)
+ {"ESY", "URY", "es_UY"}, // Spanish (Uruguay)
+ {"ESV", "VEN", "es_VE"}, // Spanish (Venezuela)
+ {"SVF", "FIN", "sv_FI"}, // Swedish (Finland)
+ {"SVE", "SWE", "sv_SE"}, // Swedish (Sweden)
+ {"TAM", "IND", "ta_IN"}, // Tamil (India)
+ {"TTT", "RUS", "tt_RU"}, // Tatar (Russia)
+ {"TEL", "IND", "te_IN"}, // Telugu (India)
+ {"THA", "THA", "th_TH"}, // Thai (Thailand)
+ {"BOB", "CHN", "bo_CN"}, // Tibetan (PRC)
+ {"TRK", "TUR", "tr_TR"}, // Turkish (Turkey)
+ {"TUK", "TKM", "tk_TM"}, // Turkmen (Turkmenistan)
+ {"UIG", "CHN", "ug_CN"}, // Uighur (PRC)
+ {"UKR", "UKR", "uk_UA"}, // Ukrainian (Ukraine)
+ {"URD", "PAK", "ur_PK"}, // Urdu (Islamic Republic of Pakistan)
+ {"VIT", "VNM", "vi_VN"}, // Vietnamese (Vietnam)
+ {"CYM", "GBR", "cy_GB"}, // Welsh (United Kingdom)
+ {"WOL", "SEN", "wo_SN"}, // Wolof (Senegal)
+ {"III", "CHN", "ii_CN"}, // Yi (PRC)
+ {"YOR", "NGA", "yo_NG"}, // Yoruba (Nigeria)
+ {NULL,NULL,NULL}, // Default - Can't find the language / Language not listed above
};
-static void
-win_set_nls(void)
-{
- char country[32],lang[32];
- int i=0;
+static void win_set_nls(void) {
+ char country[32],lang[32];
+ int i=0;
-#ifdef HAVE_API_WIN32_CE
- wchar_t wcountry[32],wlang[32];
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, wlang, sizeof(wlang));
- WideCharToMultiByte(CP_ACP,0,wlang,-1,lang,sizeof(lang),NULL,NULL);
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, wcountry, sizeof(wcountry));
- WideCharToMultiByte(CP_ACP,0,wcountry,-1,country,sizeof(country),NULL,NULL);
+#ifdef HAVE_API_WIN32_CE
+ wchar_t wcountry[32],wlang[32];
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, wlang, sizeof(wlang));
+ WideCharToMultiByte(CP_ACP,0,wlang,-1,lang,sizeof(lang),NULL,NULL);
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, wcountry, sizeof(wcountry));
+ WideCharToMultiByte(CP_ACP,0,wcountry,-1,country,sizeof(country),NULL,NULL);
#else
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, lang, sizeof(lang));
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, country, sizeof(country));
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, lang, sizeof(lang));
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, country, sizeof(country));
#endif
- while (nls_table[i][0]) {
- if (!strcmp(nls_table[i][0], lang) && !(strcmp(nls_table[i][1], country))) {
- dbg(lvl_info,"Setting LANG=%s for Lang %s Country %s\n",nls_table[i][2], lang, country);
- setenv("LANG",nls_table[i][2],0);
- return;
- }
- i++;
- }
- dbg(lvl_error,"Lang %s Country %s not found\n",lang,country);
+ while (nls_table[i][0]) {
+ if (!strcmp(nls_table[i][0], lang) && !(strcmp(nls_table[i][1], country))) {
+ dbg(lvl_info,"Setting LANG=%s for Lang %s Country %s",nls_table[i][2], lang, country);
+ setenv("LANG",nls_table[i][2],0);
+ return;
+ }
+ i++;
+ }
+ dbg(lvl_error,"Lang %s Country %s not found",lang,country);
}
#endif
-void
-main_init(const char *program)
-{
- char *s;
+void main_update_default_layout(struct navit *navit) {
+ navit_update_current_layout(navit, NULL);
+}
+
+void main_init(const char *program) {
+ char *s;
#ifdef _UNICODE /* currently for wince */
- wchar_t wfilename[MAX_PATH + 1];
+ wchar_t wfilename[MAX_PATH + 1];
#endif
- spawn_process_init();
+ spawn_process_init();
- cbl=callback_list_new();
+ cbl=callback_list_new();
#ifdef HAVE_API_WIN32_BASE
- win_set_nls();
+ win_set_nls();
#endif
#ifndef HAVE_API_ANDROID
- setenv("LC_NUMERIC","C",1);
- setlocale(LC_ALL,"");
- setlocale(LC_NUMERIC,"C");
+ setenv("LC_NUMERIC","C",1);
+ setlocale(LC_ALL,"");
+ setlocale(LC_NUMERIC,"C");
#endif
#if !defined _WIN32 && !defined _WIN32_WCE
- if (file_exists("navit.c") || file_exists("navit.o") || file_exists("navit.lo") || file_exists("version.h")) {
- char buffer[PATH_MAX];
- printf("%s",_("Running from source directory\n"));
- getcwd(buffer, PATH_MAX); /* libc of navit returns "dummy" */
- setenv("NAVIT_PREFIX", buffer, 0);
- main_setup_environment(0);
- } else {
- if (!getenv("NAVIT_PREFIX")) {
- int l;
- int progpath_len;
- char *progpath="/bin/navit";
- l=strlen(program);
- progpath_len=strlen(progpath);
- if (l > progpath_len && !strcmp(program+l-progpath_len,progpath)) {
- s=g_strdup(program);
- s[l-progpath_len]='\0';
- if (strcmp(s, PREFIX))
- printf(_("setting '%s' to '%s'\n"), "NAVIT_PREFIX", s);
- setenv("NAVIT_PREFIX", s, 0);
- g_free(s);
- } else
- setenv("NAVIT_PREFIX", PREFIX, 0);
- }
+ if (file_exists("navit.c") || file_exists("navit.o") || file_exists("navit.lo") || file_exists("version.h")) {
+ char buffer[PATH_MAX];
+ printf("%s",_("Running from source directory\n"));
+ getcwd(buffer, PATH_MAX); /* libc of navit returns "dummy" */
+ setenv("NAVIT_PREFIX", buffer, 0);
+ main_setup_environment(0);
+ } else {
+ if (!getenv("NAVIT_PREFIX")) {
+ int l;
+ int progpath_len;
+ char *progpath="/bin/navit";
+ l=strlen(program);
+ progpath_len=strlen(progpath);
+ if (l > progpath_len && !strcmp(program+l-progpath_len,progpath)) {
+ s=g_strdup(program);
+ s[l-progpath_len]='\0';
+ if (strcmp(s, PREFIX))
+ printf(_("setting '%s' to '%s'\n"), "NAVIT_PREFIX", s);
+ setenv("NAVIT_PREFIX", s, 0);
+ g_free(s);
+ } else
+ setenv("NAVIT_PREFIX", PREFIX, 0);
+ }
#ifdef HAVE_API_ANDROID
- main_setup_environment(3);
+ main_setup_environment(3);
#else
- main_setup_environment(1);
+ main_setup_environment(1);
#endif
- }
+ }
#else /* _WIN32 || _WIN32_WCE */
- if (!getenv("NAVIT_PREFIX"))
- {
- char filename[MAX_PATH + 1],
- *end;
- int len;
+ if (!getenv("NAVIT_PREFIX")) {
+ char filename[MAX_PATH + 1],
+ *end;
+ int len;
- *filename = '\0';
+ *filename = '\0';
#ifdef _UNICODE /* currently for wince */
- if (GetModuleFileNameW(NULL, wfilename, MAX_PATH))
- {
- wcstombs(filename, wfilename, MAX_PATH);
+ if (GetModuleFileNameW(NULL, wfilename, MAX_PATH)) {
+ wcstombs(filename, wfilename, MAX_PATH);
#else
- if (GetModuleFileName(NULL, filename, MAX_PATH))
- {
+ if (GetModuleFileName(NULL, filename, MAX_PATH)) {
#endif
- end = strrchr(filename, L'\\'); /* eliminate the file name which is on the right side */
- if(end)
- *end = '\0';
- }
- len=strlen(filename);
- if (len > 4 && !strcmp(filename+len-4,"\\bin")) {
- filename[len-4]='\0';
- }
- setenv("NAVIT_PREFIX", filename, 0);
- }
- if (!getenv("HOME"))
- setenv("HOME", getenv("NAVIT_PREFIX"), 0);
- main_setup_environment(2);
+ end = strrchr(filename, L'\\'); /* eliminate the file name which is on the right side */
+ if(end)
+ *end = '\0';
+ }
+ len=strlen(filename);
+ if (len > 4 && !strcmp(filename+len-4,"\\bin")) {
+ filename[len-4]='\0';
+ }
+ setenv("NAVIT_PREFIX", filename, 0);
+ }
+ if (!getenv("HOME"))
+ setenv("HOME", getenv("NAVIT_PREFIX"), 0);
+ main_setup_environment(2);
#endif /* _WIN32 || _WIN32_WCE */
- s = getenv("NAVIT_WID");
- if (s) {
- setenv("SDL_WINDOWID", s, 0);
- }
+ s = getenv("NAVIT_WID");
+ if (s) {
+ setenv("SDL_WINDOWID", s, 0);
+ }
}
diff --git a/navit/main.h b/navit/main.h
index 47f275c09..910d56200 100644
--- a/navit/main.h
+++ b/navit/main.h
@@ -35,6 +35,7 @@ void main_add_navit(struct navit *nav);
void main_remove_navit(struct navit *nav);
int main_add_attr(struct attr *attr);
int main_remove_attr(struct attr *attr);
+void main_update_default_layout(struct navit *navit);
void main_init(const char *program);
void main_init_nls(void);
int main(int argc, char **argv);
diff --git a/navit/map.c b/navit/map.c
index 2736da9f8..526e5fe55 100644
--- a/navit/map.c
+++ b/navit/map.c
@@ -58,10 +58,10 @@
* This structure holds information about a map.
*/
struct map {
- NAVIT_OBJECT
- struct map_methods meth; /**< Structure with pointers to the map plugin's functions */
- struct map_priv *priv; /**< Private data of the map, only known to the map plugin */
- struct callback_list *attr_cbl; /**< List of callbacks that are called when attributes change */
+ NAVIT_OBJECT
+ struct map_methods meth; /**< Structure with pointers to the map plugin's functions */
+ struct map_priv *priv; /**< Private data of the map, only known to the map plugin */
+ struct callback_list *attr_cbl; /**< List of callbacks that are called when attributes change */
};
/**
@@ -70,8 +70,8 @@ struct map {
* This structure describes a rectangular extract of a map.
*/
struct map_rect {
- struct map *m; /**< The map this extract is from */
- struct map_rect_priv *priv; /**< Private data of this map rect, only known to the map plugin */
+ struct map *m; /**< The map this extract is from */
+ struct map_rect_priv *priv; /**< Private data of this map rect, only known to the map plugin */
};
/**
@@ -89,33 +89,32 @@ struct map_rect {
* @return The opened map or NULL on failure
*/
struct map *
-map_new(struct attr *parent, struct attr **attrs)
-{
- struct map *m;
- struct map_priv *(*maptype_new)(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl);
- struct attr *type=attr_search(attrs, NULL, attr_type);
-
- if (! type) {
- dbg(lvl_error,"missing type\n");
- return NULL;
- }
- maptype_new=plugin_get_category_map(type->u.str);
- if (! maptype_new) {
- dbg(lvl_error,"invalid type '%s'\n", type->u.str);
- return NULL;
- }
-
- m=g_new0(struct map, 1);
- m->attrs=attr_list_dup(attrs);
- m->func=&map_func;
- navit_object_ref((struct navit_object *)m);
- m->attr_cbl=callback_list_new();
- m->priv=maptype_new(&m->meth, attrs, m->attr_cbl);
- if (! m->priv) {
- map_destroy(m);
- m=NULL;
- }
- return m;
+map_new(struct attr *parent, struct attr **attrs) {
+ struct map *m;
+ struct map_priv *(*maptype_new)(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl);
+ struct attr *type=attr_search(attrs, NULL, attr_type);
+
+ if (! type) {
+ dbg(lvl_error,"missing type");
+ return NULL;
+ }
+ maptype_new=plugin_get_category_map(type->u.str);
+ if (! maptype_new) {
+ dbg(lvl_error,"invalid type '%s'", type->u.str);
+ return NULL;
+ }
+
+ m=g_new0(struct map, 1);
+ m->attrs=attr_list_dup(attrs);
+ m->func=&map_func;
+ navit_object_ref((struct navit_object *)m);
+ m->attr_cbl=callback_list_new();
+ m->priv=maptype_new(&m->meth, attrs, m->attr_cbl);
+ if (! m->priv) {
+ map_destroy(m);
+ m=NULL;
+ }
+ return m;
}
/**
@@ -127,20 +126,18 @@ map_new(struct attr *parent, struct attr **attrs)
* @param iter (NOT IMPLEMENTED) Used to iterate through all attributes of a type. Set this to NULL to get the first attribute, set this to an attr_iter to get the next attribute
* @return True if the attribute type was found, false if not
*/
-int
-map_get_attr(struct map *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- int ret=0;
- if (this_->meth.map_get_attr)
- ret=this_->meth.map_get_attr(this_->priv, type, attr);
- if (!ret)
- ret=attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
- if (!ret && type == attr_active) {
- attr->type=type;
- attr->u.num=1;
- return 1;
- }
- return ret;
+int map_get_attr(struct map *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ int ret=0;
+ if (this_->meth.map_get_attr)
+ ret=this_->meth.map_get_attr(this_->priv, type, attr);
+ if (!ret)
+ ret=attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+ if (!ret && type == attr_active) {
+ attr->type=type;
+ attr->u.num=1;
+ return 1;
+ }
+ return ret;
}
/**
@@ -154,14 +151,12 @@ map_get_attr(struct map *this_, enum attr_type type, struct attr *attr, struct a
* @param attr The attribute to set
* @return True if the attr could be set, false otherwise
*/
-int
-map_set_attr(struct map *this_, struct attr *attr)
-{
- this_->attrs=attr_generic_set_attr(this_->attrs, attr);
- if (this_->meth.map_set_attr)
- this_->meth.map_set_attr(this_->priv, attr);
- callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
- return 1;
+int map_set_attr(struct map *this_, struct attr *attr) {
+ this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+ if (this_->meth.map_set_attr)
+ this_->meth.map_set_attr(this_->priv, attr);
+ callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
+ return 1;
}
/**
@@ -173,10 +168,8 @@ map_set_attr(struct map *this_, struct attr *attr)
* @param this_ The map to associate the callback with
* @param cb The callback to add
*/
-void
-map_add_callback(struct map *this_, struct callback *cb)
-{
- callback_list_add(this_->attr_cbl, cb);
+void map_add_callback(struct map *this_, struct callback *cb) {
+ callback_list_add(this_->attr_cbl, cb);
}
/**
@@ -188,10 +181,8 @@ map_add_callback(struct map *this_, struct callback *cb)
* @param this_ The map to remove the callback from
* @param cb The callback to remove
*/
-void
-map_remove_callback(struct map *this_, struct callback *cb)
-{
- callback_list_remove(this_->attr_cbl, cb);
+void map_remove_callback(struct map *this_, struct callback *cb) {
+ callback_list_remove(this_->attr_cbl, cb);
}
@@ -201,36 +192,32 @@ map_remove_callback(struct map *this_, struct callback *cb)
* @param this_ Map to be checked for the need to convert strings
* @return True if strings from the map have to be converted, false otherwise
*/
-int
-map_requires_conversion(struct map *this_)
-{
- return (this_->meth.charset != NULL && strcmp(this_->meth.charset, "utf-8"));
+int map_requires_conversion(struct map *this_) {
+ return (this_->meth.charset != NULL && strcmp(this_->meth.charset, "utf-8"));
}
char *map_converted_string_tmp=NULL;
/**
- * @brief Converts a string from a map into a temporary allocated buffer. Conversion is not performed and original string is returned
- * if map doesn't require conversion. So lifetime of returned value is very limited.
+ * @brief Converts a string from a map into a temporary allocated buffer. Conversion is not performed and original string is returned
+ * if map doesn't require conversion. So lifetime of returned value is very limited.
*
* @param this_ The map the string to be converted is from
* @param str The string to be converted
* @return The converted string. Don't care about it after use.
*/
-char *
-map_convert_string_tmp(struct map *this_, char *str)
-{
- if(map_converted_string_tmp!=NULL)
- g_free(map_converted_string_tmp);
- map_converted_string_tmp=NULL;
- if(!this_ || !this_->meth.charset || !strcmp(this_->meth.charset, "utf-8"))
- return str;
- map_converted_string_tmp=g_convert(str, -1, "utf-8", this_->meth.charset, NULL, NULL, NULL);
- if(!map_converted_string_tmp) {
- dbg(lvl_error,"Error converting '%s' from %s to utf-8\n", str, this_->meth.charset);
- return str;
- }
- return map_converted_string_tmp;
+char *map_convert_string_tmp(struct map *this_, char *str) {
+ if(map_converted_string_tmp!=NULL)
+ g_free(map_converted_string_tmp);
+ map_converted_string_tmp=NULL;
+ if(!this_ || !this_->meth.charset || !strcmp(this_->meth.charset, "utf-8"))
+ return str;
+ map_converted_string_tmp=g_convert(str, -1, "utf-8", this_->meth.charset, NULL, NULL, NULL);
+ if(!map_converted_string_tmp) {
+ dbg(lvl_error,"Error converting '%s' from %s to utf-8", str, this_->meth.charset);
+ return str;
+ }
+ return map_converted_string_tmp;
}
/**
@@ -240,21 +227,17 @@ map_convert_string_tmp(struct map *this_, char *str)
* @param str The string to be converted
* @return The converted string. It has to be map_convert_free()d after use.
*/
-char *
-map_convert_string(struct map *this_, char *str)
-{
- return map_convert_dup(map_convert_string_tmp(this_,str));
+char *map_convert_string(struct map *this_, char *str) {
+ return map_convert_dup(map_convert_string_tmp(this_,str));
}
-char *
-map_convert_dup(char *str)
-{
- if(map_converted_string_tmp==str) {
- map_converted_string_tmp=NULL;
- return str;
- }
- return g_strdup(str);
+char *map_convert_dup(char *str) {
+ if(map_converted_string_tmp==str) {
+ map_converted_string_tmp=NULL;
+ return str;
+ }
+ return g_strdup(str);
}
/**
@@ -262,10 +245,8 @@ map_convert_dup(char *str)
*
* @param str The string to be freed
*/
-void
-map_convert_free(char *str)
-{
- g_free(str);
+void map_convert_free(char *str) {
+ g_free(str);
}
/**
@@ -274,10 +255,8 @@ map_convert_free(char *str)
* @param this_ The map to return the projection of
* @return The projection of the map
*/
-enum projection
-map_projection(struct map *this_)
-{
- return this_->meth.pro;
+enum projection map_projection(struct map *this_) {
+ return this_->meth.pro;
}
/**
@@ -286,10 +265,8 @@ map_projection(struct map *this_)
* @param this_ The map to set the projection of
* @param pro The projection to be set
*/
-void
-map_set_projection(struct map *this_, enum projection pro)
-{
- this_->meth.pro=pro;
+void map_set_projection(struct map *this_, enum projection pro) {
+ this_->meth.pro=pro;
}
/**
@@ -298,16 +275,14 @@ map_set_projection(struct map *this_, enum projection pro)
* @param m The map to be destroyed
*/
-void
-map_destroy(struct map *m)
-{
- if (!m)
- return;
- if (m->priv)
- m->meth.map_destroy(m->priv);
- attr_list_free(m->attrs);
- callback_list_destroy(m->attr_cbl);
- g_free(m);
+void map_destroy(struct map *m) {
+ if (!m)
+ return;
+ if (m->priv)
+ m->meth.map_destroy(m->priv);
+ attr_list_free(m->attrs);
+ callback_list_destroy(m->attr_cbl);
+ g_free(m);
}
/**
@@ -322,22 +297,21 @@ map_destroy(struct map *m)
* @return A new map rect
*/
struct map_rect *
-map_rect_new(struct map *m, struct map_selection *sel)
-{
- struct map_rect *mr;
+map_rect_new(struct map *m, struct map_selection *sel) {
+ struct map_rect *mr;
#if 0
- printf("map_rect_new 0x%x,0x%x-0x%x,0x%x\n", r->lu.x, r->lu.y, r->rl.x, r->rl.y);
+ printf("map_rect_new 0x%x,0x%x-0x%x,0x%x\n", r->lu.x, r->lu.y, r->rl.x, r->rl.y);
#endif
- mr=g_new0(struct map_rect, 1);
- mr->m=m;
- mr->priv=m->meth.map_rect_new(m->priv, sel);
- if (! mr->priv) {
- g_free(mr);
- mr=NULL;
- }
+ mr=g_new0(struct map_rect, 1);
+ mr->m=m;
+ mr->priv=m->meth.map_rect_new(m->priv, sel);
+ if (! mr->priv) {
+ g_free(mr);
+ mr=NULL;
+ }
- return mr;
+ return mr;
}
/**
@@ -350,16 +324,15 @@ map_rect_new(struct map *m, struct map_selection *sel)
* @return An item from the map rect
*/
struct item *
-map_rect_get_item(struct map_rect *mr)
-{
- struct item *ret;
- dbg_assert(mr != NULL);
- dbg_assert(mr->m != NULL);
- dbg_assert(mr->m->meth.map_rect_get_item != NULL);
- ret=mr->m->meth.map_rect_get_item(mr->priv);
- if (ret)
- ret->map=mr->m;
- return ret;
+map_rect_get_item(struct map_rect *mr) {
+ struct item *ret;
+ dbg_assert(mr != NULL);
+ dbg_assert(mr->m != NULL);
+ dbg_assert(mr->m->meth.map_rect_get_item != NULL);
+ ret=mr->m->meth.map_rect_get_item(mr->priv);
+ if (ret)
+ ret->map=mr->m;
+ return ret;
}
/**
@@ -371,16 +344,15 @@ map_rect_get_item(struct map_rect *mr)
* @return The item with the specified ID or NULL if not found
*/
struct item *
-map_rect_get_item_byid(struct map_rect *mr, int id_hi, int id_lo)
-{
- struct item *ret=NULL;
- dbg_assert(mr != NULL);
- dbg_assert(mr->m != NULL);
- if (mr->m->meth.map_rect_get_item_byid)
- ret=mr->m->meth.map_rect_get_item_byid(mr->priv, id_hi, id_lo);
- if (ret)
- ret->map=mr->m;
- return ret;
+map_rect_get_item_byid(struct map_rect *mr, int id_hi, int id_lo) {
+ struct item *ret=NULL;
+ dbg_assert(mr != NULL);
+ dbg_assert(mr->m != NULL);
+ if (mr->m->meth.map_rect_get_item_byid)
+ ret=mr->m->meth.map_rect_get_item_byid(mr->priv, id_hi, id_lo);
+ if (ret)
+ ret->map=mr->m;
+ return ret;
}
/**
@@ -388,13 +360,11 @@ map_rect_get_item_byid(struct map_rect *mr, int id_hi, int id_lo)
*
* @param mr The map rect to be destroyed
*/
-void
-map_rect_destroy(struct map_rect *mr)
-{
- if (mr) {
- mr->m->meth.map_rect_destroy(mr->priv);
- g_free(mr);
- }
+void map_rect_destroy(struct map_rect *mr) {
+ if (mr) {
+ mr->m->meth.map_rect_destroy(mr->priv);
+ g_free(mr);
+ }
}
/**
@@ -404,9 +374,9 @@ map_rect_destroy(struct map_rect *mr)
* used as "handle" to retrieve items from a search.
*/
struct map_search {
- struct map *m;
- struct attr search_attr;
- void *priv;
+ struct map *m;
+ struct attr search_attr;
+ void *priv;
};
/**
@@ -422,13 +392,13 @@ struct map_search {
* strings - a search for a street named "street" would match to "streetfoo", but not to
* "somestreet". Search is case insensitive.
*
- * The item passed to this function specifies a "superior item" to "search within" - e.g. a town
+ * The item passed to this function specifies a "superior item" to "search within" - e.g. a town
* in which we want to search for a street, or a country in which to search for a town.
*
* Please also note that the search for countries is not handled by map plugins but by navit internally -
* have a look into country.c for details. Because of that every map plugin has to accept a country item
* to be passed as "superior item".
- *
+ *
* Note: If you change something here, please make sure to also update the documentation of mapset_search_new()
* in mapset.c!
*
@@ -439,31 +409,31 @@ struct map_search {
* @return A new map search struct for this search
*/
struct map_search *
-map_search_new(struct map *m, struct item *item, struct attr *search_attr, int partial)
-{
- struct map_search *this_;
- dbg(lvl_debug,"enter(%p,%p,%p,%d)\n", m, item, search_attr, partial);
- dbg(lvl_debug,"0x%x 0x%x 0x%x\n", attr_country_all, search_attr->type, attr_country_name);
- this_=g_new0(struct map_search,1);
- this_->m=m;
- this_->search_attr=*search_attr;
- if ((search_attr->type >= attr_country_all && search_attr->type <= attr_country_name) || search_attr->type == attr_country_id)
- this_->priv=country_search_new(&this_->search_attr, partial);
- else {
- if (m->meth.map_search_new) {
- if (m->meth.charset)
- this_->search_attr.u.str=g_convert(this_->search_attr.u.str, -1,m->meth.charset,"utf-8",NULL,NULL,NULL);
- this_->priv=m->meth.map_search_new(m->priv, item, &this_->search_attr, partial);
- if (! this_->priv) {
- g_free(this_);
- this_=NULL;
- }
- } else {
- g_free(this_);
- this_=NULL;
- }
- }
- return this_;
+map_search_new(struct map *m, struct item *item, struct attr *search_attr, int partial) {
+ struct map_search *this_;
+ dbg(lvl_debug,"enter(%p,%p,%p,%d)", m, item, search_attr, partial);
+ dbg(lvl_debug,"0x%x 0x%x 0x%x", attr_country_all, search_attr->type, attr_country_name);
+ this_=g_new0(struct map_search,1);
+ this_->m=m;
+ this_->search_attr=*search_attr;
+ if ((search_attr->type >= attr_country_all && search_attr->type <= attr_country_name)
+ || search_attr->type == attr_country_id)
+ this_->priv=country_search_new(&this_->search_attr, partial);
+ else {
+ if (m->meth.map_search_new) {
+ if (m->meth.charset)
+ this_->search_attr.u.str=g_convert(this_->search_attr.u.str, -1,m->meth.charset,"utf-8",NULL,NULL,NULL);
+ this_->priv=m->meth.map_search_new(m->priv, item, &this_->search_attr, partial);
+ if (! this_->priv) {
+ g_free(this_);
+ this_=NULL;
+ }
+ } else {
+ g_free(this_);
+ this_=NULL;
+ }
+ }
+ return this_;
}
/**
@@ -477,18 +447,18 @@ map_search_new(struct map *m, struct item *item, struct attr *search_attr, int p
* @return One item of the result
*/
struct item *
-map_search_get_item(struct map_search *this_)
-{
- struct item *ret;
+map_search_get_item(struct map_search *this_) {
+ struct item *ret;
- if (! this_)
- return NULL;
- if ((this_->search_attr.type >= attr_country_all && this_->search_attr.type <= attr_country_name) || this_->search_attr.type == attr_country_id)
- return country_search_get_item(this_->priv);
- ret=this_->m->meth.map_search_get_item(this_->priv);
- if (ret)
- ret->map=this_->m;
- return ret;
+ if (! this_)
+ return NULL;
+ if ((this_->search_attr.type >= attr_country_all && this_->search_attr.type <= attr_country_name)
+ || this_->search_attr.type == attr_country_id)
+ return country_search_get_item(this_->priv);
+ ret=this_->m->meth.map_search_get_item(this_->priv);
+ if (ret)
+ ret->map=this_->m;
+ return ret;
}
/**
@@ -496,19 +466,17 @@ map_search_get_item(struct map_search *this_)
*
* @param this_ The map search struct to be destroyed
*/
-void
-map_search_destroy(struct map_search *this_)
-{
- if (! this_)
- return;
- if (this_->search_attr.type >= attr_country_all && this_->search_attr.type <= attr_country_name)
- country_search_destroy(this_->priv);
- else {
- if (this_->m->meth.charset)
- g_free(this_->search_attr.u.str);
- this_->m->meth.map_search_destroy(this_->priv);
- }
- g_free(this_);
+void map_search_destroy(struct map_search *this_) {
+ if (! this_)
+ return;
+ if (this_->search_attr.type >= attr_country_all && this_->search_attr.type <= attr_country_name)
+ country_search_destroy(this_->priv);
+ else {
+ if (this_->m->meth.charset)
+ g_free(this_->search_attr.u.str);
+ this_->m->meth.map_search_destroy(this_->priv);
+ }
+ g_free(this_);
}
/**
@@ -520,16 +488,15 @@ map_search_destroy(struct map_search *this_)
* @return The new map selection
*/
struct map_selection *
-map_selection_rect_new(struct pcoord *center, int distance, int order)
-{
- struct map_selection *ret=g_new0(struct map_selection, 1);
- ret->order=order;
- ret->range=item_range_all;
- ret->u.c_rect.lu.x=center->x-distance;
- ret->u.c_rect.lu.y=center->y+distance;
- ret->u.c_rect.rl.x=center->x+distance;
- ret->u.c_rect.rl.y=center->y-distance;
- return ret;
+map_selection_rect_new(struct pcoord *center, int distance, int order) {
+ struct map_selection *ret=g_new0(struct map_selection, 1);
+ ret->order=order;
+ ret->range=item_range_all;
+ ret->u.c_rect.lu.x=center->x-distance;
+ ret->u.c_rect.lu.y=center->y+distance;
+ ret->u.c_rect.rl.x=center->x+distance;
+ ret->u.c_rect.rl.y=center->y-distance;
+ return ret;
}
/**
@@ -544,23 +511,22 @@ map_selection_rect_new(struct pcoord *center, int distance, int order)
* @return A duplicated, transformed map selection
*/
struct map_selection *
-map_selection_dup_pro(struct map_selection *sel, enum projection from, enum projection to)
-{
- struct map_selection *next,**last;
- struct map_selection *ret=NULL;
- last=&ret;
- while (sel) {
- next = g_new(struct map_selection, 1);
- *next=*sel;
- if (from != projection_none || to != projection_none) {
- transform_from_to(&sel->u.c_rect.lu, from, &next->u.c_rect.lu, to);
- transform_from_to(&sel->u.c_rect.rl, from, &next->u.c_rect.rl, to);
- }
- *last=next;
- last=&next->next;
- sel = sel->next;
- }
- return ret;
+map_selection_dup_pro(struct map_selection *sel, enum projection from, enum projection to) {
+ struct map_selection *next,**last;
+ struct map_selection *ret=NULL;
+ last=&ret;
+ while (sel) {
+ next = g_new(struct map_selection, 1);
+ *next=*sel;
+ if (from != projection_none || to != projection_none) {
+ transform_from_to(&sel->u.c_rect.lu, from, &next->u.c_rect.lu, to);
+ transform_from_to(&sel->u.c_rect.rl, from, &next->u.c_rect.rl, to);
+ }
+ *last=next;
+ last=&next->next;
+ sel = sel->next;
+ }
+ return ret;
}
/**
@@ -570,9 +536,8 @@ map_selection_dup_pro(struct map_selection *sel, enum projection from, enum proj
* @return The duplicated map selection
*/
struct map_selection *
-map_selection_dup(struct map_selection *sel)
-{
- return map_selection_dup_pro(sel, projection_none, projection_none);
+map_selection_dup(struct map_selection *sel) {
+ return map_selection_dup_pro(sel, projection_none, projection_none);
}
/**
@@ -580,15 +545,13 @@ map_selection_dup(struct map_selection *sel)
*
* @param sel The map selection to be destroyed
*/
-void
-map_selection_destroy(struct map_selection *sel)
-{
- struct map_selection *next;
- while (sel) {
- next = sel->next;
- g_free(sel);
- sel = next;
- }
+void map_selection_destroy(struct map_selection *sel) {
+ struct map_selection *next;
+ while (sel) {
+ next = sel->next;
+ g_free(sel);
+ sel = next;
+ }
}
/**
@@ -601,23 +564,21 @@ map_selection_destroy(struct map_selection *sel)
* @param item The item that the rectangle should be built around
* @return True if the rectangle is within the selection, false otherwise
*/
-int
-map_selection_contains_item_rect(struct map_selection *sel, struct item *item)
-{
- struct coord c;
- struct coord_rect r;
- int count=0;
- while (item_coord_get(item, &c, 1)) {
- if (! count) {
- r.lu=c;
- r.rl=c;
- } else
- coord_rect_extend(&r, &c);
- count++;
- }
- if (! count)
- return 0;
- return map_selection_contains_rect(sel, &r);
+int map_selection_contains_item_rect(struct map_selection *sel, struct item *item) {
+ struct coord c;
+ struct coord_rect r;
+ int count=0;
+ while (item_coord_get(item, &c, 1)) {
+ if (! count) {
+ r.lu=c;
+ r.rl=c;
+ } else
+ coord_rect_extend(&r, &c);
+ count++;
+ }
+ if (! count)
+ return 0;
+ return map_selection_contains_rect(sel, &r);
}
@@ -634,25 +595,23 @@ map_selection_contains_item_rect(struct map_selection *sel, struct item *item)
* @return True if there is a match, false otherwise
*/
-int
-map_selection_contains_item_range(struct map_selection *sel, int follow, struct item_range *range, int count)
-{
- int i;
- if (! sel)
- return 1;
- while (sel) {
- for (i = 0 ; i < count ; i++) {
- if (item_range_intersects_range(&sel->range, &range[i]))
- return 1;
- }
- if (! follow)
- break;
- sel=sel->next;
- }
- return 0;
+int map_selection_contains_item_range(struct map_selection *sel, int follow, struct item_range *range, int count) {
+ int i;
+ if (! sel)
+ return 1;
+ while (sel) {
+ for (i = 0 ; i < count ; i++) {
+ if (item_range_intersects_range(&sel->range, &range[i]))
+ return 1;
+ }
+ if (! follow)
+ break;
+ sel=sel->next;
+ }
+ return 0;
}
/**
- * @brief Checks if a selection contains a item
+ * @brief Checks if a selection contains a item
*
* This function checks if a selection contains a item type
*
@@ -662,19 +621,17 @@ map_selection_contains_item_range(struct map_selection *sel, int follow, struct
* @return True if there is a match, false otherwise
*/
-int
-map_selection_contains_item(struct map_selection *sel, int follow, enum item_type type)
-{
- if (! sel)
- return 1;
- while (sel) {
- if (item_range_contains_item(&sel->range, type))
- return 1;
- if (! follow)
- break;
- sel=sel->next;
- }
- return 0;
+int map_selection_contains_item(struct map_selection *sel, int follow, enum item_type type) {
+ if (! sel)
+ return 1;
+ while (sel) {
+ if (item_range_contains_item(&sel->range, type))
+ return 1;
+ if (! follow)
+ break;
+ sel=sel->next;
+ }
+ return 0;
}
@@ -686,66 +643,56 @@ map_selection_contains_item(struct map_selection *sel, int follow, enum item_typ
* @param priv The private data that should be checked.
* @return True if priv is the private data of map
*/
-int
-map_priv_is(struct map *map, struct map_priv *priv)
-{
- return (map->priv == priv);
+int map_priv_is(struct map *map, struct map_priv *priv) {
+ return (map->priv == priv);
}
-void
-map_dump_filedesc(struct map *map, FILE *out)
-{
- struct map_rect *mr=map_rect_new(map, NULL);
- struct item *item;
+void map_dump_filedesc(struct map *map, FILE *out) {
+ struct map_rect *mr=map_rect_new(map, NULL);
+ struct item *item;
- while ((item = map_rect_get_item(mr)))
- item_dump_filedesc(item, map, out);
- map_rect_destroy(mr);
+ while ((item = map_rect_get_item(mr)))
+ item_dump_filedesc(item, map, out);
+ map_rect_destroy(mr);
}
-void
-map_dump_file(struct map *map, const char *file)
-{
- FILE *f;
- f=fopen(file,"w");
- if (f) {
- map_dump_filedesc(map, f);
- fclose(f);
- } else
- dbg(lvl_error,"failed to open file '%s'\n",file);
+void map_dump_file(struct map *map, const char *file) {
+ FILE *f;
+ f=fopen(file,"w");
+ if (f) {
+ map_dump_filedesc(map, f);
+ fclose(f);
+ } else
+ dbg(lvl_error,"failed to open file '%s'",file);
}
-void
-map_dump(struct map *map)
-{
- map_dump_filedesc(map, stdout);
+void map_dump(struct map *map) {
+ map_dump_filedesc(map, stdout);
}
-struct item *
-map_rect_create_item(struct map_rect *mr, enum item_type type_)
-{
- if(mr && mr->priv && mr->m) {
- return mr->m->meth.map_rect_create_item(mr->priv, type_) ;
- }
- else {
- return NULL;
- }
+struct item *
+map_rect_create_item(struct map_rect *mr, enum item_type type_) {
+ if(mr && mr->priv && mr->m) {
+ return mr->m->meth.map_rect_create_item(mr->priv, type_) ;
+ } else {
+ return NULL;
+ }
}
struct object_func map_func = {
- attr_map,
- (object_func_new)map_new,
- (object_func_get_attr)map_get_attr,
- (object_func_iter_new)NULL,
- (object_func_iter_destroy)NULL,
- (object_func_set_attr)map_set_attr,
- (object_func_add_attr)NULL,
- (object_func_remove_attr)NULL,
- (object_func_init)NULL,
- (object_func_destroy)map_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_map,
+ (object_func_new)map_new,
+ (object_func_get_attr)map_get_attr,
+ (object_func_iter_new)NULL,
+ (object_func_iter_destroy)NULL,
+ (object_func_set_attr)map_set_attr,
+ (object_func_add_attr)NULL,
+ (object_func_remove_attr)NULL,
+ (object_func_init)NULL,
+ (object_func_destroy)map_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/map.h b/navit/map.h
index 305c26b96..df8f9bf4e 100644
--- a/navit/map.h
+++ b/navit/map.h
@@ -18,7 +18,7 @@
*/
/** @file
- *
+ *
* @brief Contains exported functions / structures for map.c
*
* This file contains code that works together with map.c and that is exported
@@ -65,12 +65,16 @@ struct map_selection {
};
/**
- * @brief Holds all functions a map plugin has to implement to be useable
+ * @brief Holds all functions a map plugin has to implement to be usable
*
- * This structure holds pointers to a map plugin's functions navit's core will call
- * to communicate with the plugin. For further information look into map.c - there exist
+ * This structure holds pointers to a map plugin's functions, which Navit's core will call
+ * to communicate with the plugin. For further information look into map.c, which has
* functions with the same names acting more or less as "wrappers" around the functions here.
* Especially the arguments (and their meaning) of each function will be described there.
+ *
+ * Note that there is no separate method to remove an item from a map. This is instead accomplished by
+ * retrieving the item, then setting its type to `type_none` via its `item_type_set` method (provided
+ * the item and its map support removal).
*/
struct map_methods {
enum projection pro; /**< The projection used for that type of map */
@@ -79,13 +83,13 @@ struct map_methods {
struct map_rect_priv * (*map_rect_new)(struct map_priv *map, struct map_selection *sel); /**< Function to create a new map rect on the map. */
void (*map_rect_destroy)(struct map_rect_priv *mr); /**< Function to destroy a map rect */
struct item * (*map_rect_get_item)(struct map_rect_priv *mr); /**< Function to return the next item from a map rect */
- struct item * (*map_rect_get_item_byid)(struct map_rect_priv *mr, int id_hi, int id_lo); /**< Function to get an item with a specific ID from a map rect */
- struct map_search_priv *(*map_search_new)(struct map_priv *map, struct item *item, struct attr *search, int partial); /**< Function to start a new search on the map */
- void (*map_search_destroy)(struct map_search_priv *ms); /**< Function to destroy a map search struct */
- struct item * (*map_search_get_item)(struct map_search_priv *ms); /**< Function to get the next item of a search on the map */
+ struct item * (*map_rect_get_item_byid)(struct map_rect_priv *mr, int id_hi, int id_lo); /**< Function to get an item with a specific ID from a map rect, can be NULL */
+ struct map_search_priv *(*map_search_new)(struct map_priv *map, struct item *item, struct attr *search, int partial); /**< Function to start a new search on the map, can be NULL */
+ void (*map_search_destroy)(struct map_search_priv *ms); /**< Function to destroy a map search struct, ignored if `map_search_new` is NULL */
+ struct item * (*map_search_get_item)(struct map_search_priv *ms); /**< Function to get the next item of a search on the map, ignored if `map_search_new` is NULL */
struct item * (*map_rect_create_item)(struct map_rect_priv *mr, enum item_type type); /**< Function to create a new item in the map */
- int (*map_get_attr)(struct map_priv *priv, enum attr_type type, struct attr *attr);
- int (*map_set_attr)(struct map_priv *priv, struct attr *attr);
+ int (*map_get_attr)(struct map_priv *priv, enum attr_type type, struct attr *attr); /**< Function to get a map attribute, can be NULL */
+ int (*map_set_attr)(struct map_priv *priv, struct attr *attr); /**< Function to set a map attribute, can be NULL */
};
diff --git a/navit/map/binfile/CMakeLists.txt b/navit/map/binfile/CMakeLists.txt
index 9b5a6cc96..62ef1326b 100644
--- a/navit/map/binfile/CMakeLists.txt
+++ b/navit/map/binfile/CMakeLists.txt
@@ -1 +1 @@
-module_add_library(map_binfile binfile.c)
+module_add_library(map_binfile binfile.c)
diff --git a/navit/map/binfile/binfile.c b/navit/map/binfile/binfile.c
index 93cbbd466..7cc707ac8 100644
--- a/navit/map/binfile/binfile.c
+++ b/navit/map/binfile/binfile.c
@@ -62,40 +62,40 @@ static int map_id;
* used for working with the data.
*/
struct tile {
- int *start; //!< Memory address of the buffer containing the tile data (the actual map data).
- int *end; //!< First memory address not belonging to the tile data.
- /**< Thus tile->end - tile->start represents the size of the tile data
- * in multiples of 4 Bytes.
- */
- int *pos; //!< Pointer to current position (start of current item) inside the tile data.
- int *pos_coord_start; //!< Pointer to the first element inside the current item that is a coordinate.
- /**< That is the first position after the header of an
- * item. The header holds 3 entries each 32bit wide integers:
- * header[0] holds the size of the whole item (excluding this size field)
- * header[1] holds the type of the item
- * header[2] holds the size of the coordinates in the tile
- */
- int *pos_coord; //!< Current position in the coordinates region of the current item.
- int *pos_attr_start; //!< Pointer to the first attr data structure of the current item.
- int *pos_attr; //!< Current position in the attr region of the current item.
- int *pos_next; //!< Pointer to the next item (the item which follows the "current item" as indicated by *pos).
- struct file *fi; //!< The file from which this tile was loaded.
- int zipfile_num;
- int mode;
+ int *start; //!< Memory address of the buffer containing the tile data (the actual map data).
+ int *end; //!< First memory address not belonging to the tile data.
+ /**< Thus tile->end - tile->start represents the size of the tile data
+ * in multiples of 4 Bytes.
+ */
+ int *pos; //!< Pointer to current position (start of current item) inside the tile data.
+ int *pos_coord_start; //!< Pointer to the first element inside the current item that is a coordinate.
+ /**< That is the first position after the header of an
+ * item. The header holds 3 entries each 32bit wide integers:
+ * header[0] holds the size of the whole item (excluding this size field)
+ * header[1] holds the type of the item
+ * header[2] holds the size of the coordinates in the tile
+ */
+ int *pos_coord; //!< Current position in the coordinates region of the current item.
+ int *pos_attr_start; //!< Pointer to the first attr data structure of the current item.
+ int *pos_attr; //!< Current position in the attr region of the current item.
+ int *pos_next; //!< Pointer to the next item (the item which follows the "current item" as indicated by *pos).
+ struct file *fi; //!< The file from which this tile was loaded.
+ int zipfile_num;
+ int mode;
};
struct map_download {
- int state;
- struct map_priv *m;
- struct map_rect_priv *mr;
- struct file *http,*file;
- int zipfile,toffset,tlength,progress,read,dl_size;
- long long offset,start_offset,cd1offset,size;
- struct zip64_eoc *zip64_eoc;
- struct zip64_eocl *zip64_eocl;
- struct zip_eoc *zip_eoc;
- struct zip_cd *cd_copy,*cd;
+ int state;
+ struct map_priv *m;
+ struct map_rect_priv *mr;
+ struct file *http,*file;
+ int zipfile,toffset,tlength,progress,read,dl_size;
+ long long offset,start_offset,cd1offset,size;
+ struct zip64_eoc *zip64_eoc;
+ struct zip64_eocl *zip64_eocl;
+ struct zip_eoc *zip_eoc;
+ struct zip_cd *cd_copy,*cd;
};
/**
@@ -103,56 +103,56 @@ struct map_download {
*
*/
struct map_priv {
- int id;
- char *filename; //!< Filename of the binfile.
- char *cachedir;
- struct file *fi,*http;
- struct file **fis;
- struct zip_cd *index_cd;
- int index_offset;
- int cde_size;
- struct zip_eoc *eoc;
- struct zip64_eoc *eoc64;
- int zip_members;
- unsigned char *search_data;
- int search_offset;
- int search_size;
- int version;
- int check_version;
- int map_version;
- GHashTable *changes;
- char *map_release;
- int flags;
- char *url;
- int update_available;
- char *progress;
- struct callback_list *cbl;
- struct map_download *download;
- int redirect;
- long download_enabled;
- int last_searched_town_id_hi;
- int last_searched_town_id_lo;
+ int id;
+ char *filename; //!< Filename of the binfile.
+ char *cachedir;
+ struct file *fi,*http;
+ struct file **fis;
+ struct zip_cd *index_cd;
+ int index_offset;
+ int cde_size;
+ struct zip_eoc *eoc;
+ struct zip64_eoc *eoc64;
+ int zip_members;
+ unsigned char *search_data;
+ int search_offset;
+ int search_size;
+ int version;
+ int check_version;
+ int map_version;
+ GHashTable *changes;
+ char *map_release;
+ int flags;
+ char *url;
+ int update_available;
+ char *progress;
+ struct callback_list *cbl;
+ struct map_download *download;
+ int redirect;
+ long download_enabled;
+ int last_searched_town_id_hi;
+ int last_searched_town_id_lo;
};
struct map_rect_priv {
- int *start;
- int *end;
- enum attr_type attr_last;
- int label;
- int *label_attr[5];
- struct map_selection *sel;
- struct map_priv *m;
- struct item item;
- int tile_depth;
- struct tile tiles[8];
- struct tile *t;
- int country_id;
- char *url;
- struct attr attrs[8];
- int status;
- struct map_search_priv *msp;
+ int *start;
+ int *end;
+ enum attr_type attr_last;
+ int label;
+ int *label_attr[5];
+ struct map_selection *sel;
+ struct map_priv *m;
+ struct item item;
+ int tile_depth;
+ struct tile tiles[8];
+ struct tile *t;
+ int country_id;
+ char *url;
+ struct attr attrs[8];
+ int status;
+ struct map_search_priv *msp;
#ifdef DEBUG_SIZE
- int size;
+ int size;
#endif
};
@@ -162,18 +162,18 @@ struct map_rect_priv {
* when starting a search, and is used for retrieving results.
*/
struct map_search_priv {
- struct map_priv *map; /**< Map to search in. */
- struct map_rect_priv *mr; /**< Map rectangle to search inside. */
- struct map_rect_priv *mr_item;
- struct item *item;
- struct attr search; /**< Attribute specifying what to search for. */
- struct map_selection ms;
- GList *boundaries;
- int partial; /**< Find partial matches? */
- int mode;
- struct coord_rect rect_new;
- char *parent_name;
- GHashTable *search_results;
+ struct map_priv *map; /**< Map to search in. */
+ struct map_rect_priv *mr; /**< Map rectangle to search inside. */
+ struct map_rect_priv *mr_item;
+ struct item *item;
+ struct attr search; /**< Attribute specifying what to search for. */
+ struct map_selection ms;
+ GList *boundaries;
+ int partial; /**< Find partial matches? */
+ int mode;
+ struct coord_rect rect_new;
+ char *parent_name;
+ GHashTable *search_results;
};
@@ -184,127 +184,120 @@ static int map_binfile_open(struct map_priv *m);
static void map_binfile_destroy(struct map_priv *m);
static void lfh_to_cpu(struct zip_lfh *lfh) {
- dbg_assert(lfh != NULL);
- if (lfh->ziplocsig != zip_lfh_sig) {
- lfh->ziplocsig = le32_to_cpu(lfh->ziplocsig);
- lfh->zipver = le16_to_cpu(lfh->zipver);
- lfh->zipgenfld = le16_to_cpu(lfh->zipgenfld);
- lfh->zipmthd = le16_to_cpu(lfh->zipmthd);
- lfh->ziptime = le16_to_cpu(lfh->ziptime);
- lfh->zipdate = le16_to_cpu(lfh->zipdate);
- lfh->zipcrc = le32_to_cpu(lfh->zipcrc);
- lfh->zipsize = le32_to_cpu(lfh->zipsize);
- lfh->zipuncmp = le32_to_cpu(lfh->zipuncmp);
- lfh->zipfnln = le16_to_cpu(lfh->zipfnln);
- lfh->zipxtraln = le16_to_cpu(lfh->zipxtraln);
- }
+ dbg_assert(lfh != NULL);
+ if (lfh->ziplocsig != zip_lfh_sig) {
+ lfh->ziplocsig = le32_to_cpu(lfh->ziplocsig);
+ lfh->zipver = le16_to_cpu(lfh->zipver);
+ lfh->zipgenfld = le16_to_cpu(lfh->zipgenfld);
+ lfh->zipmthd = le16_to_cpu(lfh->zipmthd);
+ lfh->ziptime = le16_to_cpu(lfh->ziptime);
+ lfh->zipdate = le16_to_cpu(lfh->zipdate);
+ lfh->zipcrc = le32_to_cpu(lfh->zipcrc);
+ lfh->zipsize = le32_to_cpu(lfh->zipsize);
+ lfh->zipuncmp = le32_to_cpu(lfh->zipuncmp);
+ lfh->zipfnln = le16_to_cpu(lfh->zipfnln);
+ lfh->zipxtraln = le16_to_cpu(lfh->zipxtraln);
+ }
}
static void cd_to_cpu(struct zip_cd *zcd) {
- dbg_assert(zcd != NULL);
- if (zcd->zipcensig != zip_cd_sig) {
- zcd->zipcensig = le32_to_cpu(zcd->zipcensig);
- zcd->zipccrc = le32_to_cpu(zcd->zipccrc);
- zcd->zipcsiz = le32_to_cpu(zcd->zipcsiz);
- zcd->zipcunc = le32_to_cpu(zcd->zipcunc);
- zcd->zipcfnl = le16_to_cpu(zcd->zipcfnl);
- zcd->zipcxtl = le16_to_cpu(zcd->zipcxtl);
- zcd->zipccml = le16_to_cpu(zcd->zipccml);
- zcd->zipdsk = le16_to_cpu(zcd->zipdsk);
- zcd->zipint = le16_to_cpu(zcd->zipint);
- zcd->zipext = le32_to_cpu(zcd->zipext);
- zcd->zipofst = le32_to_cpu(zcd->zipofst);
- }
+ dbg_assert(zcd != NULL);
+ if (zcd->zipcensig != zip_cd_sig) {
+ zcd->zipcensig = le32_to_cpu(zcd->zipcensig);
+ zcd->zipccrc = le32_to_cpu(zcd->zipccrc);
+ zcd->zipcsiz = le32_to_cpu(zcd->zipcsiz);
+ zcd->zipcunc = le32_to_cpu(zcd->zipcunc);
+ zcd->zipcfnl = le16_to_cpu(zcd->zipcfnl);
+ zcd->zipcxtl = le16_to_cpu(zcd->zipcxtl);
+ zcd->zipccml = le16_to_cpu(zcd->zipccml);
+ zcd->zipdsk = le16_to_cpu(zcd->zipdsk);
+ zcd->zipint = le16_to_cpu(zcd->zipint);
+ zcd->zipext = le32_to_cpu(zcd->zipext);
+ zcd->zipofst = le32_to_cpu(zcd->zipofst);
+ }
}
static void eoc_to_cpu(struct zip_eoc *eoc) {
- dbg_assert(eoc != NULL);
- if (eoc->zipesig != zip_eoc_sig) {
- eoc->zipesig = le32_to_cpu(eoc->zipesig);
- eoc->zipedsk = le16_to_cpu(eoc->zipedsk);
- eoc->zipecen = le16_to_cpu(eoc->zipecen);
- eoc->zipenum = le16_to_cpu(eoc->zipenum);
- eoc->zipecenn = le16_to_cpu(eoc->zipecenn);
- eoc->zipecsz = le32_to_cpu(eoc->zipecsz);
- eoc->zipeofst = le32_to_cpu(eoc->zipeofst);
- eoc->zipecoml = le16_to_cpu(eoc->zipecoml);
- }
+ dbg_assert(eoc != NULL);
+ if (eoc->zipesig != zip_eoc_sig) {
+ eoc->zipesig = le32_to_cpu(eoc->zipesig);
+ eoc->zipedsk = le16_to_cpu(eoc->zipedsk);
+ eoc->zipecen = le16_to_cpu(eoc->zipecen);
+ eoc->zipenum = le16_to_cpu(eoc->zipenum);
+ eoc->zipecenn = le16_to_cpu(eoc->zipecenn);
+ eoc->zipecsz = le32_to_cpu(eoc->zipecsz);
+ eoc->zipeofst = le32_to_cpu(eoc->zipeofst);
+ eoc->zipecoml = le16_to_cpu(eoc->zipecoml);
+ }
}
static void binfile_check_version(struct map_priv *m);
-static struct zip_eoc *
-binfile_read_eoc(struct file *fi)
-{
- struct zip_eoc *eoc;
- eoc=(struct zip_eoc *)file_data_read(fi,fi->size-sizeof(struct zip_eoc), sizeof(struct zip_eoc));
- if (eoc) {
- eoc_to_cpu(eoc);
- dbg(lvl_debug,"sig 0x%x\n", eoc->zipesig);
- if (eoc->zipesig != zip_eoc_sig) {
- dbg(lvl_error,"map file %s: eoc signature check failed: 0x%x vs 0x%x\n", fi->name, eoc->zipesig,zip_eoc_sig);
- file_data_free(fi,(unsigned char *)eoc);
- eoc=NULL;
- }
- }
- return eoc;
-}
-
-static struct zip64_eoc *
-binfile_read_eoc64(struct file *fi)
-{
- struct zip64_eocl *eocl;
- struct zip64_eoc *eoc;
- eocl=(struct zip64_eocl *)file_data_read(fi,fi->size-sizeof(struct zip_eoc)-sizeof(struct zip64_eocl), sizeof(struct zip64_eocl));
- if (!eocl)
- return NULL;
- dbg(lvl_debug,"sig 0x%x\n", eocl->zip64lsig);
- if (eocl->zip64lsig != zip64_eocl_sig) {
- file_data_free(fi,(unsigned char *)eocl);
- dbg(lvl_warning,"map file %s: eocl wrong\n", fi->name);
- return NULL;
- }
- eoc=(struct zip64_eoc *)file_data_read(fi,eocl->zip64lofst, sizeof(struct zip64_eoc));
- if (eoc) {
- if (eoc->zip64esig != zip64_eoc_sig) {
- file_data_free(fi,(unsigned char *)eoc);
- dbg(lvl_warning,"map file %s: eoc wrong\n", fi->name);
- eoc=NULL;
- }
- dbg(lvl_debug,"eoc64 ok 0x"LONGLONG_HEX_FMT " 0x"LONGLONG_HEX_FMT "\n",eoc->zip64eofst,eoc->zip64ecsz);
- }
- file_data_free(fi,(unsigned char *)eocl);
- return eoc;
-}
-
-static int
-binfile_cd_extra(struct zip_cd *cd)
-{
- return cd->zipcfnl+cd->zipcxtl;
-}
-
-static struct zip_cd *
-binfile_read_cd(struct map_priv *m, int offset, int len)
-{
- struct zip_cd *cd;
- long long cdoffset=m->eoc64?m->eoc64->zip64eofst:m->eoc->zipeofst;
- if (len == -1) {
- cd=(struct zip_cd *)file_data_read(m->fi,cdoffset+offset, sizeof(*cd));
- cd_to_cpu(cd);
- len=binfile_cd_extra(cd);
- file_data_free(m->fi,(unsigned char *)cd);
- }
- cd=(struct zip_cd *)file_data_read(m->fi,cdoffset+offset, sizeof(*cd)+len);
- if (cd) {
- dbg(lvl_debug,"cd at "LONGLONG_FMT" %zu bytes\n",cdoffset+offset, sizeof(*cd)+len);
- cd_to_cpu(cd);
- dbg(lvl_debug,"sig 0x%x\n", cd->zipcensig);
- if (cd->zipcensig != zip_cd_sig) {
- file_data_free(m->fi,(unsigned char *)cd);
- cd=NULL;
- }
- }
- return cd;
+static struct zip_eoc *binfile_read_eoc(struct file *fi) {
+ struct zip_eoc *eoc;
+ eoc=(struct zip_eoc *)file_data_read(fi,fi->size-sizeof(struct zip_eoc), sizeof(struct zip_eoc));
+ if (eoc) {
+ eoc_to_cpu(eoc);
+ dbg(lvl_debug,"sig 0x%x", eoc->zipesig);
+ if (eoc->zipesig != zip_eoc_sig) {
+ dbg(lvl_error,"map file %s: eoc signature check failed: 0x%x vs 0x%x", fi->name, eoc->zipesig,zip_eoc_sig);
+ file_data_free(fi,(unsigned char *)eoc);
+ eoc=NULL;
+ }
+ }
+ return eoc;
+}
+
+static struct zip64_eoc *binfile_read_eoc64(struct file *fi) {
+ struct zip64_eocl *eocl;
+ struct zip64_eoc *eoc;
+ eocl=(struct zip64_eocl *)file_data_read(fi,fi->size-sizeof(struct zip_eoc)-sizeof(struct zip64_eocl),
+ sizeof(struct zip64_eocl));
+ if (!eocl)
+ return NULL;
+ dbg(lvl_debug,"sig 0x%x", eocl->zip64lsig);
+ if (eocl->zip64lsig != zip64_eocl_sig) {
+ file_data_free(fi,(unsigned char *)eocl);
+ dbg(lvl_warning,"map file %s: eocl wrong", fi->name);
+ return NULL;
+ }
+ eoc=(struct zip64_eoc *)file_data_read(fi,eocl->zip64lofst, sizeof(struct zip64_eoc));
+ if (eoc) {
+ if (eoc->zip64esig != zip64_eoc_sig) {
+ file_data_free(fi,(unsigned char *)eoc);
+ dbg(lvl_warning,"map file %s: eoc wrong", fi->name);
+ eoc=NULL;
+ }
+ dbg(lvl_debug,"eoc64 ok 0x"LONGLONG_HEX_FMT " 0x"LONGLONG_HEX_FMT "",eoc->zip64eofst,eoc->zip64ecsz);
+ }
+ file_data_free(fi,(unsigned char *)eocl);
+ return eoc;
+}
+
+static int binfile_cd_extra(struct zip_cd *cd) {
+ return cd->zipcfnl+cd->zipcxtl;
+}
+
+static struct zip_cd *binfile_read_cd(struct map_priv *m, int offset, int len) {
+ struct zip_cd *cd;
+ long long cdoffset=m->eoc64?m->eoc64->zip64eofst:m->eoc->zipeofst;
+ if (len == -1) {
+ cd=(struct zip_cd *)file_data_read(m->fi,cdoffset+offset, sizeof(*cd));
+ cd_to_cpu(cd);
+ len=binfile_cd_extra(cd);
+ file_data_free(m->fi,(unsigned char *)cd);
+ }
+ cd=(struct zip_cd *)file_data_read(m->fi,cdoffset+offset, sizeof(*cd)+len);
+ if (cd) {
+ dbg(lvl_debug,"cd at "LONGLONG_FMT" %zu bytes",cdoffset+offset, sizeof(*cd)+len);
+ cd_to_cpu(cd);
+ dbg(lvl_debug,"sig 0x%x", cd->zipcensig);
+ if (cd->zipcensig != zip_cd_sig) {
+ file_data_free(m->fi,(unsigned char *)cd);
+ cd=NULL;
+ }
+ }
+ return cd;
}
/**
@@ -314,18 +307,16 @@ binfile_read_cd(struct map_priv *m, int offset, int len)
* @param cd pointer to zip central directory structure
* @return pointer to ZIP64 extra field, or NULL if not available
*/
-static struct zip_cd_ext *
-binfile_cd_ext(struct zip_cd *cd)
-{
- struct zip_cd_ext *ext;
- if (cd->zipofst != zip_size_64bit_placeholder)
- return NULL;
- if (cd->zipcxtl != sizeof(*ext))
- return NULL;
- ext=(struct zip_cd_ext *)((unsigned char *)cd+sizeof(*cd)+cd->zipcfnl);
- if (ext->tag != zip_extra_header_id_zip64 || ext->size != 8)
- return NULL;
- return ext;
+static struct zip_cd_ext *binfile_cd_ext(struct zip_cd *cd) {
+ struct zip_cd_ext *ext;
+ if (cd->zipofst != zip_size_64bit_placeholder)
+ return NULL;
+ if (cd->zipcxtl != sizeof(*ext))
+ return NULL;
+ ext=(struct zip_cd_ext *)((unsigned char *)cd+sizeof(*cd)+cd->zipcfnl);
+ if (ext->tag != zip_extra_header_id_zip64 || ext->size != 8)
+ return NULL;
+ return ext;
}
/**
@@ -333,148 +324,133 @@ binfile_cd_ext(struct zip_cd *cd)
* @return Offset of local file header in zip file.
* Will use ZIP64 data if present.
*/
-static long long
-binfile_cd_offset(struct zip_cd *cd)
-{
- struct zip_cd_ext *ext=binfile_cd_ext(cd);
- if (ext)
- return ext->zipofst;
- else
- return cd->zipofst;
-}
-
-static struct zip_lfh *
-binfile_read_lfh(struct file *fi, long long offset)
-{
- struct zip_lfh *lfh;
-
- lfh=(struct zip_lfh *)(file_data_read(fi,offset,sizeof(struct zip_lfh)));
- if (lfh) {
- lfh_to_cpu(lfh);
- if (lfh->ziplocsig != zip_lfh_sig) {
- file_data_free(fi,(unsigned char *)lfh);
- lfh=NULL;
- }
- }
- return lfh;
-}
-
-static unsigned char *
-binfile_read_content(struct map_priv *m, struct file *fi, long long offset, struct zip_lfh *lfh)
-{
- unsigned char *ret=NULL;
-
- offset+=sizeof(struct zip_lfh)+lfh->zipfnln;
- switch (lfh->zipmthd) {
- case 0:
- offset+=lfh->zipxtraln;
- ret=file_data_read(fi,offset, lfh->zipuncmp);
- break;
- case 8:
- offset+=lfh->zipxtraln;
- ret=file_data_read_compressed(fi,offset, lfh->zipsize, lfh->zipuncmp);
- break;
- default:
- dbg(lvl_error,"map file %s: unknown compression method %d\n", fi->name, lfh->zipmthd);
- }
- return ret;
-}
-
-static int
-binfile_search_cd(struct map_priv *m, int offset, char *name, int partial, int skip)
-{
- int size=4096;
- int end=m->eoc64?m->eoc64->zip64ecsz:m->eoc->zipecsz;
- int len=strlen(name);
- long long cdoffset=m->eoc64?m->eoc64->zip64eofst:m->eoc->zipeofst;
- struct zip_cd *cd;
+static long long binfile_cd_offset(struct zip_cd *cd) {
+ struct zip_cd_ext *ext=binfile_cd_ext(cd);
+ if (ext)
+ return ext->zipofst;
+ else
+ return cd->zipofst;
+}
+
+static struct zip_lfh *binfile_read_lfh(struct file *fi, long long offset) {
+ struct zip_lfh *lfh;
+
+ lfh=(struct zip_lfh *)(file_data_read(fi,offset,sizeof(struct zip_lfh)));
+ if (lfh) {
+ lfh_to_cpu(lfh);
+ if (lfh->ziplocsig != zip_lfh_sig) {
+ file_data_free(fi,(unsigned char *)lfh);
+ lfh=NULL;
+ }
+ }
+ return lfh;
+}
+
+static unsigned char *binfile_read_content(struct map_priv *m, struct file *fi, long long offset, struct zip_lfh *lfh) {
+ unsigned char *ret=NULL;
+
+ offset+=sizeof(struct zip_lfh)+lfh->zipfnln;
+ switch (lfh->zipmthd) {
+ case 0:
+ offset+=lfh->zipxtraln;
+ ret=file_data_read(fi,offset, lfh->zipuncmp);
+ break;
+ case 8:
+ offset+=lfh->zipxtraln;
+ ret=file_data_read_compressed(fi,offset, lfh->zipsize, lfh->zipuncmp);
+ break;
+ default:
+ dbg(lvl_error,"map file %s: unknown compression method %d", fi->name, lfh->zipmthd);
+ }
+ return ret;
+}
+
+static int binfile_search_cd(struct map_priv *m, int offset, char *name, int partial, int skip) {
+ int size=4096;
+ int end=m->eoc64?m->eoc64->zip64ecsz:m->eoc->zipecsz;
+ int len=strlen(name);
+ long long cdoffset=m->eoc64?m->eoc64->zip64eofst:m->eoc->zipeofst;
+ struct zip_cd *cd;
#if 0
- dbg(lvl_debug,"end=%d\n",end);
+ dbg(lvl_debug,"end=%d",end);
#endif
- while (offset < end) {
- cd=(struct zip_cd *)(m->search_data+offset-m->search_offset);
- if (! m->search_data ||
- m->search_offset > offset ||
- offset-m->search_offset+sizeof(*cd) > m->search_size ||
- offset-m->search_offset+sizeof(*cd)+cd->zipcfnl+cd->zipcxtl > m->search_size
- ) {
+ while (offset < end) {
+ cd=(struct zip_cd *)(m->search_data+offset-m->search_offset);
+ if (! m->search_data ||
+ m->search_offset > offset ||
+ offset-m->search_offset+sizeof(*cd) > m->search_size ||
+ offset-m->search_offset+sizeof(*cd)+cd->zipcfnl+cd->zipcxtl > m->search_size
+ ) {
#if 0
- dbg(lvl_debug,"reload %p %d %d\n", m->search_data, m->search_offset, offset);
+ dbg(lvl_debug,"reload %p %d %d", m->search_data, m->search_offset, offset);
#endif
- if (m->search_data)
- file_data_free(m->fi,m->search_data);
- m->search_offset=offset;
- m->search_size=end-offset;
- if (m->search_size > size)
- m->search_size=size;
- m->search_data=file_data_read(m->fi,cdoffset+m->search_offset,m->search_size);
- cd=(struct zip_cd *)m->search_data;
- }
+ if (m->search_data)
+ file_data_free(m->fi,m->search_data);
+ m->search_offset=offset;
+ m->search_size=end-offset;
+ if (m->search_size > size)
+ m->search_size=size;
+ m->search_data=file_data_read(m->fi,cdoffset+m->search_offset,m->search_size);
+ cd=(struct zip_cd *)m->search_data;
+ }
#if 0
- dbg(lvl_debug,"offset=%d search_offset=%d search_size=%d search_data=%p cd=%p\n", offset, m->search_offset, m->search_size, m->search_data, cd);
- dbg(lvl_debug,"offset=%d fn='%s'\n",offset,cd->zipcfn);
+ dbg(lvl_debug,"offset=%d search_offset=%d search_size=%d search_data=%p cd=%p", offset, m->search_offset,
+ m->search_size, m->search_data, cd);
+ dbg(lvl_debug,"offset=%d fn='%s'",offset,cd->zipcfn);
#endif
- if (!skip &&
- (partial || cd->zipcfnl == len) &&
- !strncmp(cd->zipcfn, name, len))
- return offset;
- skip=0;
- offset+=sizeof(*cd)+cd->zipcfnl+cd->zipcxtl+cd->zipccml;
-;
- }
- return -1;
-}
-
-static void
-map_destroy_binfile(struct map_priv *m)
-{
- dbg(lvl_debug,"map_destroy_binfile\n");
- if (m->fi)
- map_binfile_close(m);
- map_binfile_destroy(m);
-}
-
-static void
-binfile_coord_rewind(void *priv_data)
-{
- struct map_rect_priv *mr=priv_data;
- struct tile *t=mr->t;
- t->pos_coord=t->pos_coord_start;
-}
-
-static inline int
-binfile_coord_left(void *priv_data)
-{
- struct map_rect_priv *mr=priv_data;
- struct tile *t=mr->t;
- return (t->pos_attr_start-t->pos_coord)/2;
-}
-
-static int
-binfile_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr=priv_data;
- struct tile *t=mr->t;
- int max,ret=0;
- max=binfile_coord_left(priv_data);
- if (count > max)
- count=max;
+ if (!skip &&
+ (partial || cd->zipcfnl == len) &&
+ !strncmp(cd->zipcfn, name, len))
+ return offset;
+ skip=0;
+ offset+=sizeof(*cd)+cd->zipcfnl+cd->zipcxtl+cd->zipccml;
+ ;
+ }
+ return -1;
+}
+
+static void map_destroy_binfile(struct map_priv *m) {
+ dbg(lvl_debug,"map_destroy_binfile");
+ if (m->fi)
+ map_binfile_close(m);
+ map_binfile_destroy(m);
+}
+
+static void binfile_coord_rewind(void *priv_data) {
+ struct map_rect_priv *mr=priv_data;
+ struct tile *t=mr->t;
+ t->pos_coord=t->pos_coord_start;
+}
+
+static inline int binfile_coord_left(void *priv_data) {
+ struct map_rect_priv *mr=priv_data;
+ struct tile *t=mr->t;
+ return (t->pos_attr_start-t->pos_coord)/2;
+}
+
+static int binfile_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr=priv_data;
+ struct tile *t=mr->t;
+ int max,ret=0;
+ max=binfile_coord_left(priv_data);
+ if (count > max)
+ count=max;
#if __BYTE_ORDER == __LITTLE_ENDIAN
- memcpy(c, t->pos_coord, count*sizeof(struct coord));
+ memcpy(c, t->pos_coord, count*sizeof(struct coord));
#else
- {
- int i=0,end=count*sizeof(struct coord)/sizeof(int);
- int *src=(int *)t->pos_coord;
- int *dst=(int *)c;
- while (i++ < end) {
- *dst++=le32_to_cpu(*src);
- src++;
- }
- }
+ {
+ int i=0,end=count*sizeof(struct coord)/sizeof(int);
+ int *src=(int *)t->pos_coord;
+ int *dst=(int *)c;
+ while (i++ < end) {
+ *dst++=le32_to_cpu(*src);
+ src++;
+ }
+ }
#endif
- t->pos_coord+=count*2;
- ret=count;
- return ret;
+ t->pos_coord+=count*2;
+ ret=count;
+ return ret;
}
/**
@@ -482,1689 +458,1582 @@ binfile_coord_get(void *priv_data, struct coord *c, int count)
* @param
* @return
*/
-static void
-binfile_attr_rewind(void *priv_data)
-{
- struct map_rect_priv *mr=priv_data;
- struct tile *t=mr->t;
- t->pos_attr=t->pos_attr_start;
- mr->label=0;
- memset(mr->label_attr, 0, sizeof(mr->label_attr));
-
-}
-
-static char *
-binfile_extract(struct map_priv *m, char *dir, char *filename, int partial)
-{
- char *full,*fulld,*sep;
- unsigned char *start;
- int len,offset=m->index_offset;
- struct zip_cd *cd;
- struct zip_lfh *lfh;
- FILE *f;
-
- for (;;) {
- offset=binfile_search_cd(m, offset, filename, partial, 1);
- if (offset == -1)
- break;
- cd=binfile_read_cd(m, offset, -1);
- len=strlen(dir)+1+cd->zipcfnl+1;
- full=g_malloc(len);
- strcpy(full,dir);
- strcpy(full+strlen(full),"/");
- strncpy(full+strlen(full),cd->zipcfn,cd->zipcfnl);
- full[len-1]='\0';
- fulld=g_strdup(full);
- sep=strrchr(fulld, '/');
- if (sep) {
- *sep='\0';
- file_mkdir(fulld, 1);
- }
- if (full[len-2] != '/') {
- lfh=binfile_read_lfh(m->fi, binfile_cd_offset(cd));
- start=binfile_read_content(m, m->fi, binfile_cd_offset(cd), lfh);
- dbg(lvl_debug,"fopen '%s'\n", full);
- f=fopen(full,"w");
- fwrite(start, lfh->zipuncmp, 1, f);
- fclose(f);
- file_data_free(m->fi, start);
- file_data_free(m->fi, (unsigned char *)lfh);
- }
- file_data_free(m->fi, (unsigned char *)cd);
- g_free(fulld);
- g_free(full);
- if (! partial)
- break;
- }
-
- return g_strdup_printf("%s/%s",dir,filename);
-}
-
-static int
-binfile_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr=priv_data;
- struct tile *t=mr->t;
- enum attr_type type;
- int i,size;
-
- if (attr_type != mr->attr_last) {
- t->pos_attr=t->pos_attr_start;
- mr->attr_last=attr_type;
- }
- while (t->pos_attr < t->pos_next) {
- size=le32_to_cpu(*(t->pos_attr++));
- type=le32_to_cpu(t->pos_attr[0]);
- if (type == attr_label)
- mr->label=1;
- if (type == attr_house_number)
- mr->label_attr[0]=t->pos_attr;
- if (type == attr_street_name)
- mr->label_attr[1]=t->pos_attr;
- if (type == attr_street_name_systematic)
- mr->label_attr[2]=t->pos_attr;
- if (type == attr_district_name && mr->item.type < type_line)
- mr->label_attr[3]=t->pos_attr;
- if (type == attr_town_name && mr->item.type < type_line)
- mr->label_attr[4]=t->pos_attr;
- if (type == attr_type || attr_type == attr_any) {
- if (attr_type == attr_any) {
- dbg(lvl_debug,"pos %p attr %s size %d\n", t->pos_attr-1, attr_to_name(type), size);
- }
- attr->type=type;
- if (ATTR_IS_GROUP(type)) {
- int i=0;
- int *subpos=t->pos_attr+1;
- int size_rem=size-1;
- i=0;
- while (size_rem > 0 && i < 7) {
- int subsize=le32_to_cpu(*subpos++);
- int subtype=le32_to_cpu(subpos[0]);
- mr->attrs[i].type=subtype;
- attr_data_set_le(&mr->attrs[i], subpos+1);
- subpos+=subsize;
- size_rem-=subsize+1;
- i++;
- }
- mr->attrs[i].type=type_none;
- mr->attrs[i].u.data=NULL;
- attr->u.attrs=mr->attrs;
- } else {
- attr_data_set_le(attr, t->pos_attr+1);
- if (type == attr_url_local) {
- g_free(mr->url);
- mr->url=binfile_extract(mr->m, mr->m->cachedir, attr->u.str, 1);
- attr->u.str=mr->url;
- }
- if (type == attr_flags && mr->m->map_version < 1)
- attr->u.num |= AF_CAR;
- }
- t->pos_attr+=size;
- return 1;
- } else {
- t->pos_attr+=size;
- }
- }
- if (!mr->label && (attr_type == attr_any || attr_type == attr_label)) {
- for (i = 0 ; i < sizeof(mr->label_attr)/sizeof(int *) ; i++) {
- if (mr->label_attr[i]) {
- mr->label=1;
- attr->type=attr_label;
- attr_data_set_le(attr,mr->label_attr[i]+1);
- return 1;
- }
- }
- }
- return 0;
+static void binfile_attr_rewind(void *priv_data) {
+ struct map_rect_priv *mr=priv_data;
+ struct tile *t=mr->t;
+ t->pos_attr=t->pos_attr_start;
+ mr->label=0;
+ memset(mr->label_attr, 0, sizeof(mr->label_attr));
+
+}
+
+static char *binfile_extract(struct map_priv *m, char *dir, char *filename, int partial) {
+ char *full,*fulld,*sep;
+ unsigned char *start;
+ int len,offset=m->index_offset;
+ struct zip_cd *cd;
+ struct zip_lfh *lfh;
+ FILE *f;
+
+ for (;;) {
+ offset=binfile_search_cd(m, offset, filename, partial, 1);
+ if (offset == -1)
+ break;
+ cd=binfile_read_cd(m, offset, -1);
+ len=strlen(dir)+1+cd->zipcfnl+1;
+ full=g_malloc(len);
+ strcpy(full,dir);
+ strcpy(full+strlen(full),"/");
+ strncpy(full+strlen(full),cd->zipcfn,cd->zipcfnl);
+ full[len-1]='\0';
+ fulld=g_strdup(full);
+ sep=strrchr(fulld, '/');
+ if (sep) {
+ *sep='\0';
+ file_mkdir(fulld, 1);
+ }
+ if (full[len-2] != '/') {
+ lfh=binfile_read_lfh(m->fi, binfile_cd_offset(cd));
+ start=binfile_read_content(m, m->fi, binfile_cd_offset(cd), lfh);
+ dbg(lvl_debug,"fopen '%s'", full);
+ f=fopen(full,"w");
+ fwrite(start, lfh->zipuncmp, 1, f);
+ fclose(f);
+ file_data_free(m->fi, start);
+ file_data_free(m->fi, (unsigned char *)lfh);
+ }
+ file_data_free(m->fi, (unsigned char *)cd);
+ g_free(fulld);
+ g_free(full);
+ if (! partial)
+ break;
+ }
+
+ return g_strdup_printf("%s/%s",dir,filename);
+}
+
+static int binfile_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr=priv_data;
+ struct tile *t=mr->t;
+ enum attr_type type;
+ int i,size;
+
+ if (attr_type != mr->attr_last) {
+ t->pos_attr=t->pos_attr_start;
+ mr->attr_last=attr_type;
+ }
+ while (t->pos_attr < t->pos_next) {
+ size=le32_to_cpu(*(t->pos_attr++));
+ type=le32_to_cpu(t->pos_attr[0]);
+ if (type == attr_label)
+ mr->label=1;
+ if (type == attr_house_number)
+ mr->label_attr[0]=t->pos_attr;
+ if (type == attr_street_name)
+ mr->label_attr[1]=t->pos_attr;
+ if (type == attr_street_name_systematic)
+ mr->label_attr[2]=t->pos_attr;
+ if (type == attr_district_name && mr->item.type < type_line)
+ mr->label_attr[3]=t->pos_attr;
+ if (type == attr_town_name && mr->item.type < type_line)
+ mr->label_attr[4]=t->pos_attr;
+ if (type == attr_type || attr_type == attr_any) {
+ if (attr_type == attr_any) {
+ dbg(lvl_debug,"pos %p attr %s size %d", t->pos_attr-1, attr_to_name(type), size);
+ }
+ attr->type=type;
+ if (ATTR_IS_GROUP(type)) {
+ int i=0;
+ int *subpos=t->pos_attr+1;
+ int size_rem=size-1;
+ i=0;
+ while (size_rem > 0 && i < 7) {
+ int subsize=le32_to_cpu(*subpos++);
+ int subtype=le32_to_cpu(subpos[0]);
+ mr->attrs[i].type=subtype;
+ attr_data_set_le(&mr->attrs[i], subpos+1);
+ subpos+=subsize;
+ size_rem-=subsize+1;
+ i++;
+ }
+ mr->attrs[i].type=type_none;
+ mr->attrs[i].u.data=NULL;
+ attr->u.attrs=mr->attrs;
+ } else {
+ attr_data_set_le(attr, t->pos_attr+1);
+ if (type == attr_url_local) {
+ g_free(mr->url);
+ mr->url=binfile_extract(mr->m, mr->m->cachedir, attr->u.str, 1);
+ attr->u.str=mr->url;
+ }
+ if (type == attr_flags && mr->m->map_version < 1)
+ attr->u.num |= AF_CAR;
+ }
+ t->pos_attr+=size;
+ return 1;
+ } else {
+ t->pos_attr+=size;
+ }
+ }
+ if (!mr->label && (attr_type == attr_any || attr_type == attr_label)) {
+ for (i = 0 ; i < sizeof(mr->label_attr)/sizeof(int *) ; i++) {
+ if (mr->label_attr[i]) {
+ mr->label=1;
+ attr->type=attr_label;
+ attr_data_set_le(attr,mr->label_attr[i]+1);
+ return 1;
+ }
+ }
+ }
+ return 0;
}
struct binfile_hash_entry {
- struct item_id id;
- int flags;
- int data[0];
+ struct item_id id;
+ int flags;
+ int data[0];
};
-static guint
-binfile_hash_entry_hash(gconstpointer key)
-{
- const struct binfile_hash_entry *entry=key;
- return (entry->id.id_hi ^ entry->id.id_lo);
-}
-
-static gboolean
-binfile_hash_entry_equal(gconstpointer a, gconstpointer b)
-{
- const struct binfile_hash_entry *entry1=a,*entry2=b;
- return (entry1->id.id_hi==entry2->id.id_hi && entry1->id.id_lo == entry2->id.id_lo);
-}
+static guint binfile_hash_entry_hash(gconstpointer key) {
+ const struct binfile_hash_entry *entry=key;
+ return (entry->id.id_hi ^ entry->id.id_lo);
+}
+
+static gboolean binfile_hash_entry_equal(gconstpointer a, gconstpointer b) {
+ const struct binfile_hash_entry *entry1=a,*entry2=b;
+ return (entry1->id.id_hi==entry2->id.id_hi && entry1->id.id_lo == entry2->id.id_lo);
+}
+
+static int *binfile_item_dup(struct map_priv *m, struct item *item, struct tile *t, int extend) {
+ int size=le32_to_cpu(t->pos[0]);
+ struct binfile_hash_entry *entry=g_malloc(sizeof(struct binfile_hash_entry)+(size+1+extend)*sizeof(int));
+ void *ret=entry->data;
+ entry->id.id_hi=item->id_hi;
+ entry->id.id_lo=item->id_lo;
+ entry->flags=1;
+ dbg(lvl_debug,"id 0x%x,0x%x",entry->id.id_hi,entry->id.id_lo);
+
+ memcpy(ret, t->pos, (size+1)*sizeof(int));
+ if (!m->changes)
+ m->changes=g_hash_table_new_full(binfile_hash_entry_hash, binfile_hash_entry_equal, g_free, NULL);
+ g_hash_table_replace(m->changes, entry, entry);
+ dbg(lvl_debug,"ret %p",ret);
+ return ret;
+}
+
+static int binfile_coord_set(void *priv_data, struct coord *c, int count, enum change_mode mode) {
+ struct map_rect_priv *mr=priv_data;
+ struct tile *t=mr->t,*tn,new;
+ int i,delta,move_len;
+ int write_offset,move_offset,aoffset,coffset,clen;
+ int *data;
+
+ {
+ int *i=t->pos,j=0;
+ dbg(lvl_debug,"Before: pos_coord=%td",t->pos_coord-i);
+ while (i < t->pos_next)
+ dbg(lvl_debug,"%d:0x%x",j++,*i++);
+
+ }
+ aoffset=t->pos_attr-t->pos_attr_start;
+ coffset=t->pos_coord-t->pos_coord_start-2;
+ clen=t->pos_attr_start-t->pos_coord+2;
+ dbg(lvl_debug,"coffset=%d clen=%d",coffset,clen);
+ switch (mode) {
+ case change_mode_delete:
+ if (count*2 > clen)
+ count=clen/2;
+ delta=-count*2;
+ move_offset=coffset+count*2;
+ move_len=t->pos_next-t->pos_coord_start-move_offset;
+ write_offset=0;
+ break;
+ case change_mode_modify:
+ write_offset=coffset;
+ if (count*2 > clen) {
+ delta=count*2-clen;
+ move_offset=t->pos_attr_start-t->pos_coord_start;
+ move_len=t->pos_next-t->pos_coord_start-move_offset;
+ } else {
+ move_len=0;
+ move_offset=0;
+ delta=0;
+ }
+ break;
+ case change_mode_prepend:
+ delta=count*2;
+ move_offset=coffset-2;
+ move_len=t->pos_next-t->pos_coord_start-move_offset;
+ write_offset=coffset-2;
+ break;
+ case change_mode_append:
+ delta=count*2;
+ move_offset=coffset;
+ move_len=t->pos_next-t->pos_coord_start-move_offset;
+ write_offset=coffset;
+ break;
+ default:
+ return 0;
+ }
+ dbg(lvl_debug,"delta %d",delta);
+ data=binfile_item_dup(mr->m, &mr->item, t, delta > 0 ? delta:0);
+ data[0]=cpu_to_le32(le32_to_cpu(data[0])+delta);
+ data[2]=cpu_to_le32(le32_to_cpu(data[2])+delta);
+ new.pos=new.start=data;
+ new.zipfile_num=t->zipfile_num;
+ new.mode=2;
+ push_tile(mr, &new, 0, 0);
+ setup_pos(mr);
+ tn=mr->t;
+ tn->pos_coord=tn->pos_coord_start+coffset;
+ tn->pos_attr=tn->pos_attr_start+aoffset;
+ dbg(lvl_debug,"moving %d ints from offset %td to %td",move_len,tn->pos_coord_start+move_offset-data,
+ tn->pos_coord_start+move_offset+delta-data);
+ memmove(tn->pos_coord_start+move_offset+delta, tn->pos_coord_start+move_offset, move_len*4);
+ {
+ int *i=tn->pos,j=0;
+ dbg(lvl_debug,"After move: pos_coord=%td",tn->pos_coord-i);
+ while (i < tn->pos_next)
+ dbg(lvl_debug,"%d:0x%x",j++,*i++);
+ }
+ if (mode != change_mode_append)
+ tn->pos_coord+=move_offset;
+ if (mode != change_mode_delete) {
+ dbg(lvl_debug,"writing %d ints at offset %td",count*2,write_offset+tn->pos_coord_start-data);
+ for (i = 0 ; i < count ; i++) {
+ tn->pos_coord_start[write_offset++]=c[i].x;
+ tn->pos_coord_start[write_offset++]=c[i].y;
+ }
-static int *
-binfile_item_dup(struct map_priv *m, struct item *item, struct tile *t, int extend)
-{
- int size=le32_to_cpu(t->pos[0]);
- struct binfile_hash_entry *entry=g_malloc(sizeof(struct binfile_hash_entry)+(size+1+extend)*sizeof(int));
- void *ret=entry->data;
- entry->id.id_hi=item->id_hi;
- entry->id.id_lo=item->id_lo;
- entry->flags=1;
- dbg(lvl_debug,"id 0x%x,0x%x\n",entry->id.id_hi,entry->id.id_lo);
-
- memcpy(ret, t->pos, (size+1)*sizeof(int));
- if (!m->changes)
- m->changes=g_hash_table_new_full(binfile_hash_entry_hash, binfile_hash_entry_equal, g_free, NULL);
- g_hash_table_replace(m->changes, entry, entry);
- dbg(lvl_debug,"ret %p\n",ret);
- return ret;
-}
-
-static int
-binfile_coord_set(void *priv_data, struct coord *c, int count, enum change_mode mode)
-{
- struct map_rect_priv *mr=priv_data;
- struct tile *t=mr->t,*tn,new;
- int i,delta,move_len;
- int write_offset,move_offset,aoffset,coffset,clen;
- int *data;
-
- {
- int *i=t->pos,j=0;
- dbg(lvl_debug,"Before: pos_coord=%td\n",t->pos_coord-i);
- while (i < t->pos_next)
- dbg(lvl_debug,"%d:0x%x\n",j++,*i++);
-
- }
- aoffset=t->pos_attr-t->pos_attr_start;
- coffset=t->pos_coord-t->pos_coord_start-2;
- clen=t->pos_attr_start-t->pos_coord+2;
- dbg(lvl_debug,"coffset=%d clen=%d\n",coffset,clen);
- switch (mode) {
- case change_mode_delete:
- if (count*2 > clen)
- count=clen/2;
- delta=-count*2;
- move_offset=coffset+count*2;
- move_len=t->pos_next-t->pos_coord_start-move_offset;
- write_offset=0;
- break;
- case change_mode_modify:
- write_offset=coffset;
- if (count*2 > clen) {
- delta=count*2-clen;
- move_offset=t->pos_attr_start-t->pos_coord_start;
- move_len=t->pos_next-t->pos_coord_start-move_offset;
- } else {
- move_len=0;
- move_offset=0;
- delta=0;
- }
- break;
- case change_mode_prepend:
- delta=count*2;
- move_offset=coffset-2;
- move_len=t->pos_next-t->pos_coord_start-move_offset;
- write_offset=coffset-2;
- break;
- case change_mode_append:
- delta=count*2;
- move_offset=coffset;
- move_len=t->pos_next-t->pos_coord_start-move_offset;
- write_offset=coffset;
- break;
- default:
- return 0;
- }
- dbg(lvl_debug,"delta %d\n",delta);
- data=binfile_item_dup(mr->m, &mr->item, t, delta > 0 ? delta:0);
- data[0]=cpu_to_le32(le32_to_cpu(data[0])+delta);
- data[2]=cpu_to_le32(le32_to_cpu(data[2])+delta);
- new.pos=new.start=data;
- new.zipfile_num=t->zipfile_num;
- new.mode=2;
- push_tile(mr, &new, 0, 0);
- setup_pos(mr);
- tn=mr->t;
- tn->pos_coord=tn->pos_coord_start+coffset;
- tn->pos_attr=tn->pos_attr_start+aoffset;
- dbg(lvl_debug,"moving %d ints from offset %td to %td\n",move_len,tn->pos_coord_start+move_offset-data,tn->pos_coord_start+move_offset+delta-data);
- memmove(tn->pos_coord_start+move_offset+delta, tn->pos_coord_start+move_offset, move_len*4);
- {
- int *i=tn->pos,j=0;
- dbg(lvl_debug,"After move: pos_coord=%td\n",tn->pos_coord-i);
- while (i < tn->pos_next)
- dbg(lvl_debug,"%d:0x%x\n",j++,*i++);
- }
- if (mode != change_mode_append)
- tn->pos_coord+=move_offset;
- if (mode != change_mode_delete) {
- dbg(lvl_debug,"writing %d ints at offset %td\n",count*2,write_offset+tn->pos_coord_start-data);
- for (i = 0 ; i < count ; i++) {
- tn->pos_coord_start[write_offset++]=c[i].x;
- tn->pos_coord_start[write_offset++]=c[i].y;
- }
-
- }
- {
- int *i=tn->pos,j=0;
- dbg(lvl_debug,"After: pos_coord=%td\n",tn->pos_coord-i);
- while (i < tn->pos_next)
- dbg(lvl_debug,"%d:0x%x\n",j++,*i++);
- }
- return 1;
-}
-
-static int
-binfile_attr_set(void *priv_data, struct attr *attr, enum change_mode mode)
-{
- struct map_rect_priv *mr=priv_data;
- struct tile *t=mr->t,*tn,new;
- int offset,delta,move_len;
- int write_offset,move_offset,naoffset,coffset,oattr_len;
- int nattr_size,nattr_len,pad;
- int *data;
-
- {
- int *i=t->pos,j=0;
- dbg(lvl_debug,"Before: pos_attr=%td\n",t->pos_attr-i);
- while (i < t->pos_next)
- dbg(lvl_debug,"%d:0x%x\n",j++,*i++);
-
- }
-
- write_offset=0;
- naoffset=t->pos_attr-t->pos_attr_start;
- coffset=t->pos_coord-t->pos_coord_start;
- offset=0;
- oattr_len=0;
- if (!naoffset) {
- if (mode == change_mode_delete || mode == change_mode_modify) {
- dbg(lvl_error,"no attribute selected\n");
- return 0;
- }
- if (mode == change_mode_append)
- naoffset=t->pos_next-t->pos_attr_start;
- }
- while (offset < naoffset) {
- oattr_len=le32_to_cpu(t->pos_attr_start[offset])+1;
- dbg(lvl_debug,"len %d\n",oattr_len);
- write_offset=offset;
- offset+=oattr_len;
- }
- move_len=t->pos_next-t->pos_attr_start-offset;
- move_offset=offset;
- switch (mode) {
- case change_mode_delete:
- nattr_size=0;
- nattr_len=0;
- pad=0;
- break;
- case change_mode_modify:
- case change_mode_prepend:
- case change_mode_append:
- nattr_size=attr_data_size(attr);
- pad=(4-(nattr_size%4))%4;
- nattr_len=(nattr_size+pad)/4+2;
- if (mode == change_mode_prepend) {
- move_offset=write_offset;
- move_len+=oattr_len;
- }
- if (mode == change_mode_append) {
- write_offset=move_offset;
- }
- break;
- default:
- return 0;
- }
- if (mode == change_mode_delete || mode == change_mode_modify)
- delta=nattr_len-oattr_len;
- else
- delta=nattr_len;
- dbg(lvl_debug,"delta %d oattr_len %d nattr_len %d\n",delta,oattr_len, nattr_len);
- data=binfile_item_dup(mr->m, &mr->item, t, delta > 0 ? delta:0);
- data[0]=cpu_to_le32(le32_to_cpu(data[0])+delta);
- new.pos=new.start=data;
- new.zipfile_num=t->zipfile_num;
- new.mode=2;
- push_tile(mr, &new, 0, 0);
- setup_pos(mr);
- tn=mr->t;
- tn->pos_coord=tn->pos_coord_start+coffset;
- tn->pos_attr=tn->pos_attr_start+offset;
- dbg(lvl_debug,"attr start %td offset %d\n",tn->pos_attr_start-data,offset);
- dbg(lvl_debug,"moving %d ints from offset %td to %td\n",move_len,tn->pos_attr_start+move_offset-data,tn->pos_attr_start+move_offset+delta-data);
- memmove(tn->pos_attr_start+move_offset+delta, tn->pos_attr_start+move_offset, move_len*4);
- if (mode != change_mode_append)
- tn->pos_attr+=delta;
- {
- int *i=tn->pos,j=0;
- dbg(lvl_debug,"After move: pos_attr=%td\n",tn->pos_attr-i);
- while (i < tn->pos_next)
- dbg(lvl_debug,"%d:0x%x\n",j++,*i++);
- }
- if (nattr_len) {
- int *nattr=tn->pos_attr_start+write_offset;
- dbg(lvl_debug,"writing %d ints at %td\n",nattr_len,nattr-data);
- nattr[0]=cpu_to_le32(nattr_len-1);
- nattr[1]=cpu_to_le32(attr->type);
- memcpy(nattr+2, attr_data_get(attr), nattr_size);
- memset((unsigned char *)(nattr+2)+nattr_size, 0, pad);
- }
- {
- int *i=tn->pos,j=0;
- dbg(lvl_debug,"After: pos_attr=%td\n",tn->pos_attr-i);
- while (i < tn->pos_next)
- dbg(lvl_debug,"After: pos_attr=%td\n",tn->pos_attr-i);
- while (i < tn->pos_next)
- dbg(lvl_debug,"%d:0x%x\n",j++,*i++);
- }
- return 1;
+ }
+ {
+ int *i=tn->pos,j=0;
+ dbg(lvl_debug,"After: pos_coord=%td",tn->pos_coord-i);
+ while (i < tn->pos_next)
+ dbg(lvl_debug,"%d:0x%x",j++,*i++);
+ }
+ return 1;
+}
+
+static int binfile_attr_set(void *priv_data, struct attr *attr, enum change_mode mode) {
+ struct map_rect_priv *mr=priv_data;
+ struct tile *t=mr->t,*tn,new;
+ int offset,delta,move_len;
+ int write_offset,move_offset,naoffset,coffset,oattr_len;
+ int nattr_size,nattr_len,pad;
+ int *data;
+
+ {
+ int *i=t->pos,j=0;
+ dbg(lvl_debug,"Before: pos_attr=%td",t->pos_attr-i);
+ while (i < t->pos_next)
+ dbg(lvl_debug,"%d:0x%x",j++,*i++);
+
+ }
+
+ write_offset=0;
+ naoffset=t->pos_attr-t->pos_attr_start;
+ coffset=t->pos_coord-t->pos_coord_start;
+ offset=0;
+ oattr_len=0;
+ if (!naoffset) {
+ if (mode == change_mode_delete || mode == change_mode_modify) {
+ dbg(lvl_error,"no attribute selected");
+ return 0;
+ }
+ if (mode == change_mode_append)
+ naoffset=t->pos_next-t->pos_attr_start;
+ }
+ while (offset < naoffset) {
+ oattr_len=le32_to_cpu(t->pos_attr_start[offset])+1;
+ dbg(lvl_debug,"len %d",oattr_len);
+ write_offset=offset;
+ offset+=oattr_len;
+ }
+ move_len=t->pos_next-t->pos_attr_start-offset;
+ move_offset=offset;
+ switch (mode) {
+ case change_mode_delete:
+ nattr_size=0;
+ nattr_len=0;
+ pad=0;
+ break;
+ case change_mode_modify:
+ case change_mode_prepend:
+ case change_mode_append:
+ nattr_size=attr_data_size(attr);
+ pad=(4-(nattr_size%4))%4;
+ nattr_len=(nattr_size+pad)/4+2;
+ if (mode == change_mode_prepend) {
+ move_offset=write_offset;
+ move_len+=oattr_len;
+ }
+ if (mode == change_mode_append) {
+ write_offset=move_offset;
+ }
+ break;
+ default:
+ return 0;
+ }
+ if (mode == change_mode_delete || mode == change_mode_modify)
+ delta=nattr_len-oattr_len;
+ else
+ delta=nattr_len;
+ dbg(lvl_debug,"delta %d oattr_len %d nattr_len %d",delta,oattr_len, nattr_len);
+ data=binfile_item_dup(mr->m, &mr->item, t, delta > 0 ? delta:0);
+ data[0]=cpu_to_le32(le32_to_cpu(data[0])+delta);
+ new.pos=new.start=data;
+ new.zipfile_num=t->zipfile_num;
+ new.mode=2;
+ push_tile(mr, &new, 0, 0);
+ setup_pos(mr);
+ tn=mr->t;
+ tn->pos_coord=tn->pos_coord_start+coffset;
+ tn->pos_attr=tn->pos_attr_start+offset;
+ dbg(lvl_debug,"attr start %td offset %d",tn->pos_attr_start-data,offset);
+ dbg(lvl_debug,"moving %d ints from offset %td to %td",move_len,tn->pos_attr_start+move_offset-data,
+ tn->pos_attr_start+move_offset+delta-data);
+ memmove(tn->pos_attr_start+move_offset+delta, tn->pos_attr_start+move_offset, move_len*4);
+ if (mode != change_mode_append)
+ tn->pos_attr+=delta;
+ {
+ int *i=tn->pos,j=0;
+ dbg(lvl_debug,"After move: pos_attr=%td",tn->pos_attr-i);
+ while (i < tn->pos_next)
+ dbg(lvl_debug,"%d:0x%x",j++,*i++);
+ }
+ if (nattr_len) {
+ int *nattr=tn->pos_attr_start+write_offset;
+ dbg(lvl_debug,"writing %d ints at %td",nattr_len,nattr-data);
+ nattr[0]=cpu_to_le32(nattr_len-1);
+ nattr[1]=cpu_to_le32(attr->type);
+ memcpy(nattr+2, attr_data_get(attr), nattr_size);
+ memset((unsigned char *)(nattr+2)+nattr_size, 0, pad);
+ }
+ {
+ int *i=tn->pos,j=0;
+ dbg(lvl_debug,"After: pos_attr=%td",tn->pos_attr-i);
+ while (i < tn->pos_next)
+ dbg(lvl_debug,"After: pos_attr=%td",tn->pos_attr-i);
+ while (i < tn->pos_next)
+ dbg(lvl_debug,"%d:0x%x",j++,*i++);
+ }
+ return 1;
}
static struct item_methods methods_binfile = {
- binfile_coord_rewind,
- binfile_coord_get,
- binfile_attr_rewind,
- binfile_attr_get,
- NULL,
- binfile_attr_set,
- binfile_coord_set,
+ binfile_coord_rewind,
+ binfile_coord_get,
+ binfile_attr_rewind,
+ binfile_attr_get,
+ NULL,
+ binfile_attr_set,
+ binfile_coord_set,
};
-static void
-push_tile(struct map_rect_priv *mr, struct tile *t, int offset, int length)
-{
- dbg_assert(mr->tile_depth < 8);
- mr->t=&mr->tiles[mr->tile_depth++];
- *(mr->t)=*t;
- mr->t->pos=mr->t->pos_next=mr->t->start+offset;
- if (length == -1)
- length=le32_to_cpu(mr->t->pos[0])+1;
- if (length > 0)
- mr->t->end=mr->t->pos+length;
-}
-
-static int
-pop_tile(struct map_rect_priv *mr)
-{
- if (mr->tile_depth <= 1)
- return 0;
- if (mr->t->mode < 2)
- file_data_free(mr->m->fi, (unsigned char *)(mr->t->start));
+static void push_tile(struct map_rect_priv *mr, struct tile *t, int offset, int length) {
+ dbg_assert(mr->tile_depth < 8);
+ mr->t=&mr->tiles[mr->tile_depth++];
+ *(mr->t)=*t;
+ mr->t->pos=mr->t->pos_next=mr->t->start+offset;
+ if (length == -1)
+ length=le32_to_cpu(mr->t->pos[0])+1;
+ if (length > 0)
+ mr->t->end=mr->t->pos+length;
+}
+
+static int pop_tile(struct map_rect_priv *mr) {
+ if (mr->tile_depth <= 1)
+ return 0;
+ if (mr->t->mode < 2)
+ file_data_free(mr->m->fi, (unsigned char *)(mr->t->start));
#ifdef DEBUG_SIZE
#if DEBUG_SIZE > 0
- dbg(lvl_debug,"leave %d\n",mr->t->zipfile_num);
+ dbg(lvl_debug,"leave %d",mr->t->zipfile_num);
#endif
#endif
- mr->t=&mr->tiles[--mr->tile_depth-1];
- return 1;
-}
-
-
-static int
-zipfile_to_tile(struct map_priv *m, struct zip_cd *cd, struct tile *t)
-{
- char buffer[1024];
- struct zip_lfh *lfh;
- char *zipfn;
- struct file *fi;
- dbg(lvl_debug,"enter %p %p %p\n", m, cd, t);
- dbg(lvl_debug,"cd->zipofst=0x"LONGLONG_HEX_FMT "\n", binfile_cd_offset(cd));
- t->start=NULL;
- t->mode=1;
- if (m->fis)
- fi=m->fis[cd->zipdsk];
- else
- fi=m->fi;
- lfh=binfile_read_lfh(fi, binfile_cd_offset(cd));
- zipfn=(char *)(file_data_read(fi,binfile_cd_offset(cd)+sizeof(struct zip_lfh), lfh->zipfnln));
- strncpy(buffer, zipfn, lfh->zipfnln);
- buffer[lfh->zipfnln]='\0';
- t->start=(int *)binfile_read_content(m, fi, binfile_cd_offset(cd), lfh);
- t->end=t->start+lfh->zipuncmp/4;
- t->fi=fi;
- file_data_free(fi, (unsigned char *)zipfn);
- file_data_free(fi, (unsigned char *)lfh);
- return t->start != NULL;
-}
-
-
-static int
-map_binfile_handle_redirect(struct map_priv *m)
-{
- char *location=file_http_header(m->http, "location");
- if (!location) {
- m->redirect=0;
- return 0;
- }
- if (m->redirect)
- return 0;
- m->redirect=1;
- dbg(lvl_debug,"redirected from %s to %s\n",m->url,location);
- g_free(m->url);
- m->url=g_strdup(location);
- file_destroy(m->http);
- m->http=NULL;
-
- return 1;
-}
-
-static int
-map_binfile_http_request(struct map_priv *m, struct attr **attrs)
-{
- if (!m->http) {
- m->http=file_create(NULL, attrs);
- } else {
- file_request(m->http, attrs);
- }
- return 1;
-}
-
-
-static long long
-map_binfile_download_size(struct map_priv *m)
-{
- struct attr url={attr_url};
- struct attr http_method={attr_http_method};
- struct attr persistent={attr_persistent};
- struct attr *attrs[4];
- int size_ret;
- long long ret;
- void *data;
-
- do {
- attrs[0]=&url;
- url.u.str=m->url;
- attrs[1]=&http_method;
- http_method.u.str="HEAD";
- persistent.u.num=1;
- attrs[2]=&persistent;
- attrs[3]=NULL;
-
- map_binfile_http_request(m, attrs);
- data=file_data_read_special(m->http, 0, &size_ret);
- g_free(data);
- if (size_ret < 0)
- return 0;
- } while (map_binfile_handle_redirect(m));
-
- ret=file_size(m->http);
- dbg(lvl_debug,"file size "LONGLONG_FMT"\n",ret);
- return ret;
-}
-
-
-static int
-map_binfile_http_close(struct map_priv *m)
-{
- if (m->http) {
- file_destroy(m->http);
- m->http=NULL;
- }
- return 1;
-}
-
-
-static struct file *
-map_binfile_http_range(struct map_priv *m, long long offset, int size)
-{
- struct attr *attrs[4];
- struct attr url={attr_url};
- struct attr http_header={attr_http_header};
- struct attr persistent={attr_persistent};
-
- persistent.u.num=1;
- attrs[0]=&url;
- attrs[1]=&http_header;
- attrs[2]=&persistent;
- attrs[3]=NULL;
-
- url.u.str=m->url;
- http_header.u.str=g_strdup_printf("Range: bytes="LONGLONG_FMT"-"LONGLONG_FMT,offset, offset+size-1);
- map_binfile_http_request(m, attrs);
- g_free(http_header.u.str);
- return m->http;
-}
-
-static unsigned char *
-map_binfile_download_range(struct map_priv *m, long long offset, int size)
-{
- unsigned char *ret;
- int size_ret;
- struct file *http=map_binfile_http_range(m, offset, size);
-
- ret=file_data_read_special(http, size, &size_ret);
- if (size_ret != size) {
- dbg(lvl_debug,"size %d vs %d\n",size,size_ret);
- g_free(ret);
- return NULL;
- }
- return ret;
-}
-
-static struct zip_cd *
-download_cd(struct map_download *download)
-{
- struct map_priv *m=download->m;
- struct zip64_eoc *zip64_eoc=(struct zip64_eoc *)file_data_read(m->fi, 0, sizeof(*zip64_eoc));
- struct zip_cd *cd=(struct zip_cd *)map_binfile_download_range(m, zip64_eoc->zip64eofst+download->zipfile*m->cde_size,m->cde_size);
- file_data_free(m->fi, (unsigned char *)zip64_eoc);
- dbg(lvl_debug,"needed cd, result %p\n",cd);
- return cd;
-}
-
-static int
-download_request(struct map_download *download)
-{
- struct attr url={attr_url};
- struct attr http_header={attr_http_header};
- struct attr persistent={attr_persistent};
- struct attr *attrs[4];
-
- if(!download->m->download_enabled)
- {
- dbg(lvl_error,"Tried downloading while it's not allowed\n");
- return 0;
- }
- attrs[0]=&url;
- persistent.u.num=1;
- attrs[1]=&persistent;
- attrs[2]=NULL;
- if (strchr(download->m->url,'?')) {
- url.u.str=g_strdup_printf("%smemberid=%d",download->m->url,download->zipfile);
- download->dl_size=-1;
- } else {
- long long offset=binfile_cd_offset(download->cd_copy);
- int size=download->cd_copy->zipcsiz+sizeof(struct zip_lfh)+download->cd_copy->zipcfnl;
- url.u.str=g_strdup(download->m->url);
- http_header.u.str=g_strdup_printf("Range: bytes="LONGLONG_FMT"-"LONGLONG_FMT,offset,offset+size-1);
- attrs[2]=&http_header;
- attrs[3]=NULL;
- download->dl_size=size;
- }
- dbg(lvl_debug,"encountered missing tile %d %s(%s), Downloading %d bytes at "LONGLONG_FMT"\n",download->zipfile, url.u.str,(char *)(download->cd_copy+1), download->dl_size, download->offset);
- map_binfile_http_request(download->m, attrs);
- g_free(url.u.str);
- download->http=download->m->http;
- return 1;
-}
-
-
-static int
-download_start(struct map_download *download)
-{
- long long offset;
- struct zip_eoc *eoc;
-
- if (!download->cd->zipcensig) {
- download->cd_copy=download_cd(download);
- } else {
- download->cd_copy=g_malloc(download->m->cde_size);
- memcpy(download->cd_copy, download->cd, download->m->cde_size);
- }
- file_data_remove(download->file, (unsigned char *)download->cd);
- download->cd=NULL;
- offset=file_size(download->file);
- offset-=sizeof(struct zip_eoc);
- eoc=(struct zip_eoc *)file_data_read(download->file, offset, sizeof(struct zip_eoc));
- download->zip_eoc=g_malloc(sizeof(struct zip_eoc));
- memcpy(download->zip_eoc, eoc, sizeof(struct zip_eoc));
- file_data_remove(download->file, (unsigned char *)eoc);
- download->start_offset=download->offset=offset;
- return download_request(download);
-}
-
-static int
-download_download(struct map_download *download)
-{
- int size=64*1024,size_ret;
- unsigned char *data;
- if (download->dl_size != -1 && size > download->dl_size)
- size=download->dl_size;
- if (!size)
- return 1;
- data=file_data_read_special(download->http, size, &size_ret);
- if (!download->read && download->m->http && map_binfile_handle_redirect(download->m)) {
- g_free(data);
- download_request(download);
- return 0;
- }
-
- dbg(lvl_debug,"got %d bytes writing at offset "LONGLONG_FMT"\n",size_ret,download->offset);
- if (size_ret <= 0) {
- g_free(data);
- return 1;
- }
- file_data_write(download->file, download->offset, size_ret, data);
- download->offset+=size_ret;
- download->read+=size_ret;
- download->dl_size-=size_ret;
- if (download->dl_size != -1)
- download->progress=download->read*100/(download->read+download->dl_size);
- return 0;
-}
-
-static int
-download_finish(struct map_download *download)
-{
- struct zip_lfh *lfh;
- char *lfh_filename;
- struct zip_cd_ext *ext;
- long long lfh_offset;
- file_data_write(download->file, download->offset, sizeof(struct zip_eoc), (void *)download->zip_eoc);
- lfh=(struct zip_lfh *)(file_data_read(download->file,download->start_offset, sizeof(struct zip_lfh)));
- ext=binfile_cd_ext(download->cd_copy);
- if (ext)
- ext->zipofst=download->start_offset;
- else
- download->cd_copy->zipofst=download->start_offset;
- download->cd_copy->zipcsiz=lfh->zipsize;
- download->cd_copy->zipcunc=lfh->zipuncmp;
- download->cd_copy->zipccrc=lfh->zipcrc;
- lfh_offset = binfile_cd_offset(download->cd_copy)+sizeof(struct zip_lfh);
- lfh_filename=(char *)file_data_read(download->file,lfh_offset,lfh->zipfnln);
- memcpy(download->cd_copy+1,lfh_filename,lfh->zipfnln);
- file_data_remove(download->file,(void *)lfh_filename);
- file_data_remove(download->file,(void *)lfh);
- file_data_write(download->file, download->m->eoc->zipeofst + download->zipfile*download->m->cde_size, binfile_cd_extra(download->cd_copy)+sizeof(struct zip_cd), (void *)download->cd_copy);
- file_data_flush(download->file, download->m->eoc->zipeofst + download->zipfile*download->m->cde_size, sizeof(struct zip_cd));
-
- g_free(download->cd_copy);
- download->cd=(struct zip_cd *)(file_data_read(download->file, download->m->eoc->zipeofst + download->zipfile*download->m->cde_size, download->m->cde_size));
- cd_to_cpu(download->cd);
- dbg(lvl_debug,"Offset %d\n",download->cd->zipofst);
- return 1;
-}
-
-static int
-download_planet_size(struct map_download *download)
-{
- download->size=map_binfile_download_size(download->m);
- dbg(lvl_debug,"Planet size "LONGLONG_FMT"\n",download->size);
- if (!download->size)
- return 0;
- return 1;
-}
-
-static int
-download_eoc(struct map_download *download)
-{
- download->zip64_eoc=(struct zip64_eoc *)map_binfile_download_range(download->m, download->size-98, 98);
- if (!download->zip64_eoc)
- return 0;
- download->zip64_eocl=(struct zip64_eocl *)(download->zip64_eoc+1);
- download->zip_eoc=(struct zip_eoc *)(download->zip64_eocl+1);
- if (download->zip64_eoc->zip64esig != zip64_eoc_sig || download->zip64_eocl->zip64lsig != zip64_eocl_sig || download->zip_eoc->zipesig != zip_eoc_sig)
- {
- dbg(lvl_error,"wrong signature on zip64_eoc downloaded from "LONGLONG_FMT"\n",download->size-98);
- g_free(download->zip64_eoc);
- return 0;
- }
- return 1;
-}
-
-static int
-download_directory_start(struct map_download *download)
-{
- download->http=map_binfile_http_range(download->m, download->zip64_eoc->zip64eofst, download->zip64_eoc->zip64ecsz);
- if (!download->http)
- return 0;
- return 1;
+ mr->t=&mr->tiles[--mr->tile_depth-1];
+ return 1;
+}
+
+
+static int zipfile_to_tile(struct map_priv *m, struct zip_cd *cd, struct tile *t) {
+ char buffer[1024];
+ struct zip_lfh *lfh;
+ char *zipfn;
+ struct file *fi;
+ dbg(lvl_debug,"enter %p %p %p", m, cd, t);
+ dbg(lvl_debug,"cd->zipofst=0x"LONGLONG_HEX_FMT "", binfile_cd_offset(cd));
+ t->start=NULL;
+ t->mode=1;
+ if (m->fis)
+ fi=m->fis[cd->zipdsk];
+ else
+ fi=m->fi;
+ lfh=binfile_read_lfh(fi, binfile_cd_offset(cd));
+ zipfn=(char *)(file_data_read(fi,binfile_cd_offset(cd)+sizeof(struct zip_lfh), lfh->zipfnln));
+ strncpy(buffer, zipfn, lfh->zipfnln);
+ buffer[lfh->zipfnln]='\0';
+ t->start=(int *)binfile_read_content(m, fi, binfile_cd_offset(cd), lfh);
+ t->end=t->start+lfh->zipuncmp/4;
+ t->fi=fi;
+ file_data_free(fi, (unsigned char *)zipfn);
+ file_data_free(fi, (unsigned char *)lfh);
+ return t->start != NULL;
+}
+
+
+static int map_binfile_handle_redirect(struct map_priv *m) {
+ char *location=file_http_header(m->http, "location");
+ if (!location) {
+ m->redirect=0;
+ return 0;
+ }
+ if (m->redirect)
+ return 0;
+ m->redirect=1;
+ dbg(lvl_debug,"redirected from %s to %s",m->url,location);
+ g_free(m->url);
+ m->url=g_strdup(location);
+ file_destroy(m->http);
+ m->http=NULL;
+
+ return 1;
+}
+
+static int map_binfile_http_request(struct map_priv *m, struct attr **attrs) {
+ if (!m->http) {
+ m->http=file_create(NULL, attrs);
+ } else {
+ file_request(m->http, attrs);
+ }
+ return 1;
+}
+
+
+static long long map_binfile_download_size(struct map_priv *m) {
+ struct attr url= {attr_url};
+ struct attr http_method= {attr_http_method};
+ struct attr persistent= {attr_persistent};
+ struct attr *attrs[4];
+ int size_ret;
+ long long ret;
+ void *data;
+
+ do {
+ attrs[0]=&url;
+ url.u.str=m->url;
+ attrs[1]=&http_method;
+ http_method.u.str="HEAD";
+ persistent.u.num=1;
+ attrs[2]=&persistent;
+ attrs[3]=NULL;
+
+ map_binfile_http_request(m, attrs);
+ data=file_data_read_special(m->http, 0, &size_ret);
+ g_free(data);
+ if (size_ret < 0)
+ return 0;
+ } while (map_binfile_handle_redirect(m));
+
+ ret=file_size(m->http);
+ dbg(lvl_debug,"file size "LONGLONG_FMT"",ret);
+ return ret;
+}
+
+
+static int map_binfile_http_close(struct map_priv *m) {
+ if (m->http) {
+ file_destroy(m->http);
+ m->http=NULL;
+ }
+ return 1;
+}
+
+
+static struct file *map_binfile_http_range(struct map_priv *m, long long offset, int size) {
+ struct attr *attrs[4];
+ struct attr url= {attr_url};
+ struct attr http_header= {attr_http_header};
+ struct attr persistent= {attr_persistent};
+
+ persistent.u.num=1;
+ attrs[0]=&url;
+ attrs[1]=&http_header;
+ attrs[2]=&persistent;
+ attrs[3]=NULL;
+
+ url.u.str=m->url;
+ http_header.u.str=g_strdup_printf("Range: bytes="LONGLONG_FMT"-"LONGLONG_FMT,offset, offset+size-1);
+ map_binfile_http_request(m, attrs);
+ g_free(http_header.u.str);
+ return m->http;
+}
+
+static unsigned char *map_binfile_download_range(struct map_priv *m, long long offset, int size) {
+ unsigned char *ret;
+ int size_ret;
+ struct file *http=map_binfile_http_range(m, offset, size);
+
+ ret=file_data_read_special(http, size, &size_ret);
+ if (size_ret != size) {
+ dbg(lvl_debug,"size %d vs %d",size,size_ret);
+ g_free(ret);
+ return NULL;
+ }
+ return ret;
+}
+
+static struct zip_cd *download_cd(struct map_download *download) {
+ struct map_priv *m=download->m;
+ struct zip64_eoc *zip64_eoc=(struct zip64_eoc *)file_data_read(m->fi, 0, sizeof(*zip64_eoc));
+ struct zip_cd *cd=(struct zip_cd *)map_binfile_download_range(m, zip64_eoc->zip64eofst+download->zipfile*m->cde_size,
+ m->cde_size);
+ file_data_free(m->fi, (unsigned char *)zip64_eoc);
+ dbg(lvl_debug,"needed cd, result %p",cd);
+ return cd;
+}
+
+static int download_request(struct map_download *download) {
+ struct attr url= {attr_url};
+ struct attr http_header= {attr_http_header};
+ struct attr persistent= {attr_persistent};
+ struct attr *attrs[4];
+
+ if(!download->m->download_enabled) {
+ dbg(lvl_error,"Tried downloading while it's not allowed");
+ return 0;
+ }
+ attrs[0]=&url;
+ persistent.u.num=1;
+ attrs[1]=&persistent;
+ attrs[2]=NULL;
+ if (strchr(download->m->url,'?')) {
+ url.u.str=g_strdup_printf("%smemberid=%d",download->m->url,download->zipfile);
+ download->dl_size=-1;
+ } else {
+ long long offset=binfile_cd_offset(download->cd_copy);
+ int size=download->cd_copy->zipcsiz+sizeof(struct zip_lfh)+download->cd_copy->zipcfnl;
+ url.u.str=g_strdup(download->m->url);
+ http_header.u.str=g_strdup_printf("Range: bytes="LONGLONG_FMT"-"LONGLONG_FMT,offset,offset+size-1);
+ attrs[2]=&http_header;
+ attrs[3]=NULL;
+ download->dl_size=size;
+ }
+ dbg(lvl_debug,"encountered missing tile %d %s(%s), Downloading %d bytes at "LONGLONG_FMT"",download->zipfile, url.u.str,
+ (char *)(download->cd_copy+1), download->dl_size, download->offset);
+ map_binfile_http_request(download->m, attrs);
+ g_free(url.u.str);
+ download->http=download->m->http;
+ return 1;
+}
+
+
+static int download_start(struct map_download *download) {
+ long long offset;
+ struct zip_eoc *eoc;
+
+ if (!download->cd->zipcensig) {
+ download->cd_copy=download_cd(download);
+ } else {
+ download->cd_copy=g_malloc(download->m->cde_size);
+ memcpy(download->cd_copy, download->cd, download->m->cde_size);
+ }
+ file_data_remove(download->file, (unsigned char *)download->cd);
+ download->cd=NULL;
+ offset=file_size(download->file);
+ offset-=sizeof(struct zip_eoc);
+ eoc=(struct zip_eoc *)file_data_read(download->file, offset, sizeof(struct zip_eoc));
+ download->zip_eoc=g_malloc(sizeof(struct zip_eoc));
+ memcpy(download->zip_eoc, eoc, sizeof(struct zip_eoc));
+ file_data_remove(download->file, (unsigned char *)eoc);
+ download->start_offset=download->offset=offset;
+ return download_request(download);
+}
+
+static int download_download(struct map_download *download) {
+ int size=64*1024,size_ret;
+ unsigned char *data;
+ if (download->dl_size != -1 && size > download->dl_size)
+ size=download->dl_size;
+ if (!size)
+ return 1;
+ data=file_data_read_special(download->http, size, &size_ret);
+ if (!download->read && download->m->http && map_binfile_handle_redirect(download->m)) {
+ g_free(data);
+ download_request(download);
+ return 0;
+ }
+
+ dbg(lvl_debug,"got %d bytes writing at offset "LONGLONG_FMT"",size_ret,download->offset);
+ if (size_ret <= 0) {
+ g_free(data);
+ return 1;
+ }
+ file_data_write(download->file, download->offset, size_ret, data);
+ download->offset+=size_ret;
+ download->read+=size_ret;
+ download->dl_size-=size_ret;
+ if (download->dl_size != -1)
+ download->progress=download->read*100/(download->read+download->dl_size);
+ return 0;
+}
+
+static int download_finish(struct map_download *download) {
+ struct zip_lfh *lfh;
+ char *lfh_filename;
+ struct zip_cd_ext *ext;
+ long long lfh_offset;
+ file_data_write(download->file, download->offset, sizeof(struct zip_eoc), (void *)download->zip_eoc);
+ lfh=(struct zip_lfh *)(file_data_read(download->file,download->start_offset, sizeof(struct zip_lfh)));
+ ext=binfile_cd_ext(download->cd_copy);
+ if (ext)
+ ext->zipofst=download->start_offset;
+ else
+ download->cd_copy->zipofst=download->start_offset;
+ download->cd_copy->zipcsiz=lfh->zipsize;
+ download->cd_copy->zipcunc=lfh->zipuncmp;
+ download->cd_copy->zipccrc=lfh->zipcrc;
+ lfh_offset = binfile_cd_offset(download->cd_copy)+sizeof(struct zip_lfh);
+ lfh_filename=(char *)file_data_read(download->file,lfh_offset,lfh->zipfnln);
+ memcpy(download->cd_copy+1,lfh_filename,lfh->zipfnln);
+ file_data_remove(download->file,(void *)lfh_filename);
+ file_data_remove(download->file,(void *)lfh);
+ file_data_write(download->file, download->m->eoc->zipeofst + download->zipfile*download->m->cde_size,
+ binfile_cd_extra(download->cd_copy)+sizeof(struct zip_cd), (void *)download->cd_copy);
+ file_data_flush(download->file, download->m->eoc->zipeofst + download->zipfile*download->m->cde_size,
+ sizeof(struct zip_cd));
+
+ g_free(download->cd_copy);
+ download->cd=(struct zip_cd *)(file_data_read(download->file,
+ download->m->eoc->zipeofst + download->zipfile*download->m->cde_size, download->m->cde_size));
+ cd_to_cpu(download->cd);
+ dbg(lvl_debug,"Offset %d",download->cd->zipofst);
+ return 1;
+}
+
+static int download_planet_size(struct map_download *download) {
+ download->size=map_binfile_download_size(download->m);
+ dbg(lvl_debug,"Planet size "LONGLONG_FMT"",download->size);
+ if (!download->size)
+ return 0;
+ return 1;
+}
+
+static int download_eoc(struct map_download *download) {
+ download->zip64_eoc=(struct zip64_eoc *)map_binfile_download_range(download->m, download->size-98, 98);
+ if (!download->zip64_eoc)
+ return 0;
+ download->zip64_eocl=(struct zip64_eocl *)(download->zip64_eoc+1);
+ download->zip_eoc=(struct zip_eoc *)(download->zip64_eocl+1);
+ if (download->zip64_eoc->zip64esig != zip64_eoc_sig || download->zip64_eocl->zip64lsig != zip64_eocl_sig
+ || download->zip_eoc->zipesig != zip_eoc_sig) {
+ dbg(lvl_error,"wrong signature on zip64_eoc downloaded from "LONGLONG_FMT"",download->size-98);
+ g_free(download->zip64_eoc);
+ return 0;
+ }
+ return 1;
+}
+
+static int download_directory_start(struct map_download *download) {
+ download->http=map_binfile_http_range(download->m, download->zip64_eoc->zip64eofst, download->zip64_eoc->zip64ecsz);
+ if (!download->http)
+ return 0;
+ return 1;
+}
+
+static int download_directory_do(struct map_download *download) {
+ int count;
+
+ for (count = 0 ; count < 100 ; count++) {
+ int cd_xlen, size_ret;
+ unsigned char *cd_data;
+ struct zip_cd *cd;
+ cd=(struct zip_cd *)file_data_read_special(download->http, sizeof(*cd), &size_ret);
+ cd->zipcunc=0;
+ dbg(lvl_debug,"size_ret=%d",size_ret);
+ if (!size_ret)
+ return 0;
+ if (size_ret != sizeof(*cd) || cd->zipcensig != zip_cd_sig) {
+ dbg(lvl_error,"error1 size=%d vs %zu",size_ret, sizeof(*cd));
+ return 0;
+ }
+ file_data_write(download->file, download->offset, sizeof(*cd), (unsigned char *)cd);
+ download->offset+=sizeof(*cd);
+ cd_xlen=cd->zipcfnl+cd->zipcxtl;
+ cd_data=file_data_read_special(download->http, cd_xlen, &size_ret);
+ if (size_ret != cd_xlen) {
+ dbg(lvl_error,"error2 size=%d vs %d",size_ret,cd_xlen);
+ return 0;
+ }
+ file_data_write(download->file, download->offset, cd_xlen, cd_data);
+ download->offset+=cd_xlen;
+ g_free(cd);
+ g_free(cd_data);
+ }
+ return 1;
}
-static int
-download_directory_do(struct map_download *download)
-{
- int count;
-
- for (count = 0 ; count < 100 ; count++) {
- int cd_xlen, size_ret;
- unsigned char *cd_data;
- struct zip_cd *cd;
- cd=(struct zip_cd *)file_data_read_special(download->http, sizeof(*cd), &size_ret);
- cd->zipcunc=0;
- dbg(lvl_debug,"size_ret=%d\n",size_ret);
- if (!size_ret)
- return 0;
- if (size_ret != sizeof(*cd) || cd->zipcensig != zip_cd_sig) {
- dbg(lvl_error,"error1 size=%d vs %zu\n",size_ret, sizeof(*cd));
- return 0;
- }
- file_data_write(download->file, download->offset, sizeof(*cd), (unsigned char *)cd);
- download->offset+=sizeof(*cd);
- cd_xlen=cd->zipcfnl+cd->zipcxtl;
- cd_data=file_data_read_special(download->http, cd_xlen, &size_ret);
- if (size_ret != cd_xlen) {
- dbg(lvl_error,"error2 size=%d vs %d\n",size_ret,cd_xlen);
- return 0;
- }
- file_data_write(download->file, download->offset, cd_xlen, cd_data);
- download->offset+=cd_xlen;
- g_free(cd);
- g_free(cd_data);
- }
- return 1;
-}
-
-static int
-download_directory_finish(struct map_download *download)
-{
- download->http=NULL;
- return 1;
+static int download_directory_finish(struct map_download *download) {
+ download->http=NULL;
+ return 1;
}
-static int
-download_initial_finish(struct map_download *download)
-{
- download->zip64_eoc->zip64eofst=download->cd1offset;
- download->zip64_eocl->zip64lofst=download->offset;
- download->zip_eoc->zipeofst=download->cd1offset;
+static int download_initial_finish(struct map_download *download) {
+ download->zip64_eoc->zip64eofst=download->cd1offset;
+ download->zip64_eocl->zip64lofst=download->offset;
+ download->zip_eoc->zipeofst=download->cd1offset;
#if 0
- file_data_write(download->file, download->offset, sizeof(*download->zip64_eoc), (unsigned char *)download->zip64_eoc);
- download->offset+=sizeof(*download->zip64_eoc);
- file_data_write(download->file, download->offset, sizeof(*download->zip64_eocl), (unsigned char *)download->zip64_eocl);
- download->offset+=sizeof(*download->zip64_eocl);
+ file_data_write(download->file, download->offset, sizeof(*download->zip64_eoc), (unsigned char *)download->zip64_eoc);
+ download->offset+=sizeof(*download->zip64_eoc);
+ file_data_write(download->file, download->offset, sizeof(*download->zip64_eocl), (unsigned char *)download->zip64_eocl);
+ download->offset+=sizeof(*download->zip64_eocl);
#endif
- file_data_write(download->file, download->offset, sizeof(*download->zip_eoc), (unsigned char *)download->zip_eoc);
- download->offset+=sizeof(*download->zip_eoc);
- g_free(download->zip64_eoc);
- download->zip64_eoc=NULL;
- return 1;
+ file_data_write(download->file, download->offset, sizeof(*download->zip_eoc), (unsigned char *)download->zip_eoc);
+ download->offset+=sizeof(*download->zip_eoc);
+ g_free(download->zip64_eoc);
+ download->zip64_eoc=NULL;
+ return 1;
}
-static void
-push_zipfile_tile_do(struct map_rect_priv *mr, struct zip_cd *cd, int zipfile, int offset, int length)
+static void push_zipfile_tile_do(struct map_rect_priv *mr, struct zip_cd *cd, int zipfile, int offset, int length)
{
- struct tile t;
- struct map_priv *m=mr->m;
- struct file *f=m->fi;
+ struct tile t;
+ struct map_priv *m=mr->m;
+ struct file *f=m->fi;
- dbg(lvl_debug,"enter %p %d\n", mr, zipfile);
+ dbg(lvl_debug,"enter %p %d", mr, zipfile);
#ifdef DEBUG_SIZE
#if DEBUG_SIZE > 0
- {
- char filename[cd->zipcfnl+1];
- memcpy(filename, cd+1, cd->zipcfnl);
- filename[cd->zipcfnl]='\0';
- dbg(lvl_debug,"enter %d (%s) %d\n",zipfile, filename, cd->zipcunc);
- }
+ {
+ char filename[cd->zipcfnl+1];
+ memcpy(filename, cd+1, cd->zipcfnl);
+ filename[cd->zipcfnl]='\0';
+ dbg(lvl_debug,"enter %d (%s) %d",zipfile, filename, cd->zipcunc);
+ }
#endif
- mr->size+=cd->zipcunc;
+ mr->size+=cd->zipcunc;
#endif
- t.zipfile_num=zipfile;
- if (zipfile_to_tile(m, cd, &t))
- push_tile(mr, &t, offset, length);
- file_data_free(f, (unsigned char *)cd);
-}
-
-
-static struct zip_cd *
-download(struct map_priv *m, struct map_rect_priv *mr, struct zip_cd *cd, int zipfile, int offset, int length, int async)
-{
- struct map_download *download;
-
- if(!m->download_enabled)
- return NULL;
-
- if (async == 2) {
- download=m->download;
- } else {
- download=g_new0(struct map_download, 1);
- if (mr) {
- download->m=m;
- download->mr=mr;
- download->file=m->fi;
- download->cd=cd;
- download->zipfile=zipfile;
- download->toffset=offset;
- download->tlength=length;
- download->state=1;
- } else {
- struct attr readwrite={attr_readwrite,{(void *)1}};
- struct attr create={attr_create,{(void *)1}};
- struct attr *attrs[3];
- attrs[0]=&readwrite;
- attrs[1]=&create;
- attrs[2]=NULL;
- download->file=file_create(m->filename,attrs);
- download->m=m;
- download->state=4;
- }
- }
- if (async == 1) {
- m->download=download;
- g_free(m->progress);
- if (download->mr)
- m->progress=g_strdup_printf("Download Tile %d 0%%",download->zipfile);
- else
- m->progress=g_strdup_printf("Download Map Information 0%%");
- callback_list_call_attr_0(m->cbl, attr_progress);
- return NULL;
- }
- for (;;) {
- dbg(lvl_debug,"state=%d\n",download->state);
- switch (download->state) {
- case 0:
- dbg(lvl_error,"error\n");
- break;
- case 1:
- if (download_start(download))
- download->state=2;
- else
- download->state=0;
- break;
- case 2:
- if (download_download(download))
- download->state=3;
- else {
- g_free(m->progress);
- m->progress=g_strdup_printf("Download Tile %d %d%%",download->zipfile,download->progress);
- callback_list_call_attr_0(m->cbl, attr_progress);
- }
- break;
- case 3:
- if (download_finish(download)) {
- struct zip_cd *ret;
- g_free(m->progress);
- m->progress=g_strdup_printf("Download Tile %d 100%%",download->zipfile);
- callback_list_call_attr_0(m->cbl, attr_progress);
- if (async) {
- push_zipfile_tile_do(download->mr, download->cd, download->zipfile, download->toffset, download->tlength);
- ret=NULL;
- } else
- ret=download->cd;
- g_free(m->progress);
- m->progress=NULL;
- g_free(download);
- if (async)
- m->download=NULL;
- return ret;
- } else
- download->state=0;
- break;
- case 4:
- if (download_planet_size(download))
- download->state=5;
- else
- download->state=0;
- break;
- case 5:
- g_free(m->progress);
- m->progress=g_strdup_printf("Download Map Information 50%%");
- callback_list_call_attr_0(m->cbl, attr_progress);
- if (download_eoc(download))
- download->state=6;
- else {
- dbg(lvl_error,"download of eoc failed\n");
- download->state=0;
- }
- break;
- case 6:
- g_free(m->progress);
- m->progress=g_strdup_printf("Download Map Information 100%%");
- callback_list_call_attr_0(m->cbl, attr_progress);
- if (download_directory_start(download))
- download->state=7;
- else
- download->state=0;
- break;
- case 7:
- g_free(m->progress);
- m->progress=g_strdup_printf("Download Map Directory %d%%",(int)(download->offset*100/download->zip64_eoc->zip64ecsz));
- callback_list_call_attr_0(m->cbl, attr_progress);
- if (!download_directory_do(download))
- download->state=8;
- break;
- case 8:
- if (download_directory_finish(download))
- download->state=9;
- else
- download->state=0;
- break;
- case 9:
- download_initial_finish(download);
- m->fi=download->file;
- g_free(m->progress);
- m->progress=NULL;
- g_free(download);
- if (async)
- m->download=NULL;
- map_binfile_open(m);
- break;
- }
- if (async)
- return NULL;
- }
-}
-
-static int
-push_zipfile_tile(struct map_rect_priv *mr, int zipfile, int offset, int length, int async)
-{
- struct map_priv *m=mr->m;
- struct file *f=m->fi;
- long long cdoffset=m->eoc64?m->eoc64->zip64eofst:m->eoc->zipeofst;
- struct zip_cd *cd=(struct zip_cd *)(file_data_read(f, cdoffset + zipfile*m->cde_size, m->cde_size));
- dbg(lvl_debug,"read from "LONGLONG_FMT" %d bytes\n",cdoffset + zipfile*m->cde_size, m->cde_size);
- cd_to_cpu(cd);
- if (!cd->zipcunc && m->url) {
- cd=download(m, mr, cd, zipfile, offset, length, async);
- if (!cd)
- return 1;
- }
- push_zipfile_tile_do(mr, cd, zipfile, offset, length);
- return 0;
-}
-
-static struct map_rect_priv *
-map_rect_new_binfile_int(struct map_priv *map, struct map_selection *sel)
-{
- struct map_rect_priv *mr;
-
- binfile_check_version(map);
- dbg(lvl_debug,"map_rect_new_binfile\n");
- if (!map->fi && !map->url)
- return NULL;
- map_binfile_http_close(map);
- mr=g_new0(struct map_rect_priv, 1);
- mr->m=map;
- mr->sel=sel;
- mr->item.id_hi=0;
- mr->item.id_lo=0;
- mr->item.meth=&methods_binfile;
- mr->item.priv_data=mr;
- return mr;
-}
-
-static void
-tile_bbox(char *tile, int len, struct coord_rect *r)
-{
- struct coord c;
- int overlap=1;
- int xo,yo;
- struct coord_rect world_bbox = {
- { WORLD_BOUNDINGBOX_MIN_X, WORLD_BOUNDINGBOX_MAX_Y}, /* left upper corner */
- { WORLD_BOUNDINGBOX_MAX_X, WORLD_BOUNDINGBOX_MIN_Y}, /* right lower corner */
- };
- *r=world_bbox;
- while (len) {
- c.x=(r->lu.x+r->rl.x)/2;
- c.y=(r->lu.y+r->rl.y)/2;
- xo=(r->rl.x-r->lu.x)*overlap/100;
- yo=(r->lu.y-r->rl.y)*overlap/100;
- switch (*tile) {
- case 'a':
- r->lu.x=c.x-xo;
- r->rl.y=c.y-yo;
- break;
- case 'b':
- r->rl.x=c.x+xo;
- r->rl.y=c.y-yo;
- break;
- case 'c':
- r->lu.x=c.x-xo;
- r->lu.y=c.y+yo;
- break;
- case 'd':
- r->rl.x=c.x+xo;
- r->lu.y=c.y+yo;
- break;
- default:
- return;
- }
- tile++;
- len--;
+ t.zipfile_num=zipfile;
+ if (zipfile_to_tile(m, cd, &t))
+ push_tile(mr, &t, offset, length);
+ file_data_free(f, (unsigned char *)cd);
+}
+
+
+static struct zip_cd *download(struct map_priv *m, struct map_rect_priv *mr, struct zip_cd *cd, int zipfile, int offset,
+ int length,
+ int async) {
+ struct map_download *download;
+
+ if(!m->download_enabled)
+ return NULL;
+
+ if (async == 2) {
+ download=m->download;
+ } else {
+ download=g_new0(struct map_download, 1);
+ if (mr) {
+ download->m=m;
+ download->mr=mr;
+ download->file=m->fi;
+ download->cd=cd;
+ download->zipfile=zipfile;
+ download->toffset=offset;
+ download->tlength=length;
+ download->state=1;
+ } else {
+ struct attr readwrite= {attr_readwrite,{(void *)1}};
+ struct attr create= {attr_create,{(void *)1}};
+ struct attr *attrs[3];
+ attrs[0]=&readwrite;
+ attrs[1]=&create;
+ attrs[2]=NULL;
+ download->file=file_create(m->filename,attrs);
+ download->m=m;
+ download->state=4;
}
-}
-
-static int
-map_download_selection_check(struct zip_cd *cd, struct map_selection *sel)
-{
- struct coord_rect cd_rect;
- if (cd->zipcunc)
- return 0;
- tile_bbox((char *)(cd+1), cd->zipcfnl, &cd_rect);
- while (sel) {
- if (coord_rect_overlap(&cd_rect, &sel->u.c_rect))
- return 1;
- sel=sel->next;
- }
- return 0;
-}
-
-static void
-map_download_selection(struct map_priv *m, struct map_rect_priv *mr, struct map_selection *sel)
-{
- int i;
- struct zip_cd *cd;
- for (i = 0 ; i < m->zip_members ; i++) {
- cd=binfile_read_cd(m, m->cde_size*i, -1);
- if (map_download_selection_check(cd, sel))
- download(m, mr, cd, i, 0, 0, 0);
- file_data_free(m->fi, (unsigned char *)cd);
- }
-}
-
-static struct map_rect_priv *
-map_rect_new_binfile(struct map_priv *map, struct map_selection *sel)
-{
- struct map_rect_priv *mr=map_rect_new_binfile_int(map, sel);
- struct tile t;
- dbg(lvl_debug,"zip_members=%d\n", map->zip_members);
- if (map->url && map->fi && sel && sel->order == 255) {
- map_download_selection(map, mr, sel);
- }
- if (map->eoc)
- mr->status=1;
- else {
- unsigned char *d;
- if (map->fi) {
- d=file_data_read(map->fi, 0, map->fi->size);
- t.start=(int *)d;
- t.end=(int *)(d+map->fi->size);
- t.fi=map->fi;
- t.zipfile_num=0;
- t.mode=0;
- push_tile(mr, &t, 0, 0);
- } else if (map->url && !map->download) {
- download(map, NULL, NULL, 0, 0, 0, 1);
- mr->status=1;
- }
- }
- return mr;
-}
-
-static void
-write_changes_do(gpointer key, gpointer value, gpointer user_data)
-{
- struct binfile_hash_entry *entry=key;
- FILE *out=user_data;
- if (entry->flags) {
- entry->flags=0;
- fwrite(entry, sizeof(*entry)+(le32_to_cpu(entry->data[0])+1)*4, 1, out);
- dbg(lvl_debug,"yes\n");
- }
-}
-
-static void
-write_changes(struct map_priv *m)
-{
- FILE *changes;
- char *changes_file;
- if (!m->changes)
- return;
- changes_file=g_strdup_printf("%s.log",m->filename);
- changes=fopen(changes_file,"ab");
- g_hash_table_foreach(m->changes, write_changes_do, changes);
- fclose(changes);
- g_free(changes_file);
-}
-
-static void
-load_changes(struct map_priv *m)
-{
- FILE *changes;
- char *changes_file;
- struct binfile_hash_entry entry,*e;
- int size;
- changes_file=g_strdup_printf("%s.log",m->filename);
- changes=fopen(changes_file,"rb");
- if (! changes) {
- g_free(changes_file);
- return;
- }
- m->changes=g_hash_table_new_full(binfile_hash_entry_hash, binfile_hash_entry_equal, g_free, NULL);
- while (fread(&entry, sizeof(entry), 1, changes) == 1) {
- if (fread(&size, sizeof(size), 1, changes) != 1)
- break;
- e=g_malloc(sizeof(struct binfile_hash_entry)+(le32_to_cpu(size)+1)*4);
- *e=entry;
- e->data[0]=size;
- if (fread(e->data+1, le32_to_cpu(size)*4, 1, changes) != 1)
- break;
- g_hash_table_replace(m->changes, e, e);
- }
- fclose(changes);
- g_free(changes_file);
-}
-
-
-static void
-map_rect_destroy_binfile(struct map_rect_priv *mr)
-{
- write_changes(mr->m);
- while (pop_tile(mr));
+ }
+ if (async == 1) {
+ m->download=download;
+ g_free(m->progress);
+ if (download->mr)
+ m->progress=g_strdup_printf("Download Tile %d 0%%",download->zipfile);
+ else
+ m->progress=g_strdup_printf("Download Map Information 0%%");
+ callback_list_call_attr_0(m->cbl, attr_progress);
+ return NULL;
+ }
+ for (;;) {
+ dbg(lvl_debug,"state=%d",download->state);
+ switch (download->state) {
+ case 0:
+ dbg(lvl_error,"error");
+ break;
+ case 1:
+ if (download_start(download))
+ download->state=2;
+ else
+ download->state=0;
+ break;
+ case 2:
+ if (download_download(download))
+ download->state=3;
+ else {
+ g_free(m->progress);
+ m->progress=g_strdup_printf("Download Tile %d %d%%",download->zipfile,download->progress);
+ callback_list_call_attr_0(m->cbl, attr_progress);
+ }
+ break;
+ case 3:
+ if (download_finish(download)) {
+ struct zip_cd *ret;
+ g_free(m->progress);
+ m->progress=g_strdup_printf("Download Tile %d 100%%",download->zipfile);
+ callback_list_call_attr_0(m->cbl, attr_progress);
+ if (async) {
+ push_zipfile_tile_do(download->mr, download->cd, download->zipfile, download->toffset, download->tlength);
+ ret=NULL;
+ } else
+ ret=download->cd;
+ g_free(m->progress);
+ m->progress=NULL;
+ g_free(download);
+ if (async)
+ m->download=NULL;
+ return ret;
+ } else
+ download->state=0;
+ break;
+ case 4:
+ if (download_planet_size(download))
+ download->state=5;
+ else
+ download->state=0;
+ break;
+ case 5:
+ g_free(m->progress);
+ m->progress=g_strdup_printf("Download Map Information 50%%");
+ callback_list_call_attr_0(m->cbl, attr_progress);
+ if (download_eoc(download))
+ download->state=6;
+ else {
+ dbg(lvl_error,"download of eoc failed");
+ download->state=0;
+ }
+ break;
+ case 6:
+ g_free(m->progress);
+ m->progress=g_strdup_printf("Download Map Information 100%%");
+ callback_list_call_attr_0(m->cbl, attr_progress);
+ if (download_directory_start(download))
+ download->state=7;
+ else
+ download->state=0;
+ break;
+ case 7:
+ g_free(m->progress);
+ m->progress=g_strdup_printf("Download Map Directory %d%%",(int)(download->offset*100/download->zip64_eoc->zip64ecsz));
+ callback_list_call_attr_0(m->cbl, attr_progress);
+ if (!download_directory_do(download))
+ download->state=8;
+ break;
+ case 8:
+ if (download_directory_finish(download))
+ download->state=9;
+ else
+ download->state=0;
+ break;
+ case 9:
+ download_initial_finish(download);
+ m->fi=download->file;
+ g_free(m->progress);
+ m->progress=NULL;
+ g_free(download);
+ if (async)
+ m->download=NULL;
+ map_binfile_open(m);
+ break;
+ }
+ if (async)
+ return NULL;
+ }
+}
+
+static int push_zipfile_tile(struct map_rect_priv *mr, int zipfile, int offset, int length, int async) {
+ struct map_priv *m=mr->m;
+ struct file *f=m->fi;
+ long long cdoffset=m->eoc64?m->eoc64->zip64eofst:m->eoc->zipeofst;
+ struct zip_cd *cd=(struct zip_cd *)(file_data_read(f, cdoffset + zipfile*m->cde_size, m->cde_size));
+ dbg(lvl_debug,"read from "LONGLONG_FMT" %d bytes",cdoffset + zipfile*m->cde_size, m->cde_size);
+ cd_to_cpu(cd);
+ if (!cd->zipcunc && m->url) {
+ cd=download(m, mr, cd, zipfile, offset, length, async);
+ if (!cd)
+ return 1;
+ }
+ push_zipfile_tile_do(mr, cd, zipfile, offset, length);
+ return 0;
+}
+
+static struct map_rect_priv *map_rect_new_binfile_int(struct map_priv *map, struct map_selection *sel) {
+ struct map_rect_priv *mr;
+
+ binfile_check_version(map);
+ dbg(lvl_debug,"map_rect_new_binfile");
+ if (!map->fi && !map->url)
+ return NULL;
+ map_binfile_http_close(map);
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->m=map;
+ mr->sel=sel;
+ mr->item.id_hi=0;
+ mr->item.id_lo=0;
+ mr->item.meth=&methods_binfile;
+ mr->item.priv_data=mr;
+ return mr;
+}
+
+static void tile_bbox(char *tile, int len, struct coord_rect *r) {
+ struct coord c;
+ int overlap=1;
+ int xo,yo;
+ struct coord_rect world_bbox = {
+ { WORLD_BOUNDINGBOX_MIN_X, WORLD_BOUNDINGBOX_MAX_Y}, /* left upper corner */
+ { WORLD_BOUNDINGBOX_MAX_X, WORLD_BOUNDINGBOX_MIN_Y}, /* right lower corner */
+ };
+ *r=world_bbox;
+ while (len) {
+ c.x=(r->lu.x+r->rl.x)/2;
+ c.y=(r->lu.y+r->rl.y)/2;
+ xo=(r->rl.x-r->lu.x)*overlap/100;
+ yo=(r->lu.y-r->rl.y)*overlap/100;
+ switch (*tile) {
+ case 'a':
+ r->lu.x=c.x-xo;
+ r->rl.y=c.y-yo;
+ break;
+ case 'b':
+ r->rl.x=c.x+xo;
+ r->rl.y=c.y-yo;
+ break;
+ case 'c':
+ r->lu.x=c.x-xo;
+ r->lu.y=c.y+yo;
+ break;
+ case 'd':
+ r->rl.x=c.x+xo;
+ r->lu.y=c.y+yo;
+ break;
+ default:
+ return;
+ }
+ tile++;
+ len--;
+ }
+}
+
+static int map_download_selection_check(struct zip_cd *cd, struct map_selection *sel) {
+ struct coord_rect cd_rect;
+ if (cd->zipcunc)
+ return 0;
+ tile_bbox((char *)(cd+1), cd->zipcfnl, &cd_rect);
+ while (sel) {
+ if (coord_rect_overlap(&cd_rect, &sel->u.c_rect))
+ return 1;
+ sel=sel->next;
+ }
+ return 0;
+}
+
+static void map_download_selection(struct map_priv *m, struct map_rect_priv *mr, struct map_selection *sel) {
+ int i;
+ struct zip_cd *cd;
+ for (i = 0 ; i < m->zip_members ; i++) {
+ cd=binfile_read_cd(m, m->cde_size*i, -1);
+ if (map_download_selection_check(cd, sel))
+ download(m, mr, cd, i, 0, 0, 0);
+ file_data_free(m->fi, (unsigned char *)cd);
+ }
+}
+
+static struct map_rect_priv *map_rect_new_binfile(struct map_priv *map, struct map_selection *sel) {
+ struct map_rect_priv *mr=map_rect_new_binfile_int(map, sel);
+ struct tile t;
+ dbg(lvl_debug,"zip_members=%d", map->zip_members);
+ if (map->url && map->fi && sel && sel->order == 255) {
+ map_download_selection(map, mr, sel);
+ }
+ if (map->eoc)
+ mr->status=1;
+ else {
+ unsigned char *d;
+ if (map->fi) {
+ d=file_data_read(map->fi, 0, map->fi->size);
+ t.start=(int *)d;
+ t.end=(int *)(d+map->fi->size);
+ t.fi=map->fi;
+ t.zipfile_num=0;
+ t.mode=0;
+ push_tile(mr, &t, 0, 0);
+ } else if (map->url && !map->download) {
+ download(map, NULL, NULL, 0, 0, 0, 1);
+ mr->status=1;
+ }
+ }
+ return mr;
+}
+
+static void write_changes_do(gpointer key, gpointer value, gpointer user_data) {
+ struct binfile_hash_entry *entry=key;
+ FILE *out=user_data;
+ if (entry->flags) {
+ entry->flags=0;
+ fwrite(entry, sizeof(*entry)+(le32_to_cpu(entry->data[0])+1)*4, 1, out);
+ dbg(lvl_debug,"yes");
+ }
+}
+
+static void write_changes(struct map_priv *m) {
+ FILE *changes;
+ char *changes_file;
+ if (!m->changes)
+ return;
+ changes_file=g_strdup_printf("%s.log",m->filename);
+ changes=fopen(changes_file,"ab");
+ g_hash_table_foreach(m->changes, write_changes_do, changes);
+ fclose(changes);
+ g_free(changes_file);
+}
+
+static void load_changes(struct map_priv *m) {
+ FILE *changes;
+ char *changes_file;
+ struct binfile_hash_entry entry,*e;
+ int size;
+ changes_file=g_strdup_printf("%s.log",m->filename);
+ changes=fopen(changes_file,"rb");
+ if (! changes) {
+ g_free(changes_file);
+ return;
+ }
+ m->changes=g_hash_table_new_full(binfile_hash_entry_hash, binfile_hash_entry_equal, g_free, NULL);
+ while (fread(&entry, sizeof(entry), 1, changes) == 1) {
+ if (fread(&size, sizeof(size), 1, changes) != 1)
+ break;
+ e=g_malloc(sizeof(struct binfile_hash_entry)+(le32_to_cpu(size)+1)*4);
+ *e=entry;
+ e->data[0]=size;
+ if (fread(e->data+1, le32_to_cpu(size)*4, 1, changes) != 1)
+ break;
+ g_hash_table_replace(m->changes, e, e);
+ }
+ fclose(changes);
+ g_free(changes_file);
+}
+
+
+static void map_rect_destroy_binfile(struct map_rect_priv *mr) {
+ write_changes(mr->m);
+ while (pop_tile(mr));
#ifdef DEBUG_SIZE
- dbg(lvl_debug,"size=%d kb\n",mr->size/1024);
+ dbg(lvl_debug,"size=%d kb",mr->size/1024);
#endif
- if (mr->tiles[0].fi && mr->tiles[0].start)
- file_data_free(mr->tiles[0].fi, (unsigned char *)(mr->tiles[0].start));
- g_free(mr->url);
- map_binfile_http_close(mr->m);
- g_free(mr);
-}
-
-static void
-setup_pos(struct map_rect_priv *mr)
-{
- int size,coord_size;
- struct tile *t=mr->t;
- size=le32_to_cpu(t->pos[0]);
- if (size > 1024*1024 || size < 0) {
- dbg(lvl_debug,"size=0x%x\n", size);
+ if (mr->tiles[0].fi && mr->tiles[0].start)
+ file_data_free(mr->tiles[0].fi, (unsigned char *)(mr->tiles[0].start));
+ g_free(mr->url);
+ map_binfile_http_close(mr->m);
+ g_free(mr);
+}
+
+static void setup_pos(struct map_rect_priv *mr) {
+ int size,coord_size;
+ struct tile *t=mr->t;
+ size=le32_to_cpu(t->pos[0]);
+ if (size > 1024*1024 || size < 0) {
+ dbg(lvl_debug,"size=0x%x", size);
#if 0
- fprintf(stderr,"offset=%d\n", (unsigned char *)(mr->pos)-mr->m->f->begin);
-#endif
- dbg(lvl_debug,"size error\n");
- }
- t->pos_next=t->pos+size+1;
- mr->item.type=le32_to_cpu(t->pos[1]);
- coord_size=le32_to_cpu(t->pos[2]);
- t->pos_coord_start=t->pos+3;
- t->pos_attr_start=t->pos_coord_start+coord_size;
-}
-
-static int
-selection_contains(struct map_selection *sel, struct coord_rect *r, struct range *mima)
-{
- int order;
- if (! sel)
- return 1;
- while (sel) {
- if (coord_rect_overlap(r, &sel->u.c_rect)) {
- order=sel->order;
- dbg(lvl_debug,"min %d max %d order %d\n", mima->min, mima->max, order);
- if (!mima->min && !mima->max)
- return 1;
- if (order >= mima->min && order <= mima->max)
- return 1;
- }
- sel=sel->next;
- }
- return 0;
-}
-
-static void
-map_parse_country_binfile(struct map_rect_priv *mr)
-{
- struct attr at;
-
- if (!binfile_attr_get(mr->item.priv_data, attr_country_id, &at))
- return;
-
- if( at.u.num != mr->country_id)
- return;
-
- if (!binfile_attr_get(mr->item.priv_data, attr_zipfile_ref, &at))
- return;
-
- if(mr->msp)
- {
- struct attr *search=&mr->msp->search;
- if(search->type==attr_town_name || search->type==attr_district_name || search->type==attr_town_or_district_name) {
- struct attr af, al;
- if(binfile_attr_get(mr->item.priv_data, attr_first_key, &af)) {
- if(linguistics_compare(af.u.str,search->u.str,linguistics_cmp_partial)>0) {
- dbg(lvl_debug,"Skipping index item with first_key='%s'\n", af.u.str);
- return;
- }
- }
- if(binfile_attr_get(mr->item.priv_data, attr_last_key, &al)) {
- if(linguistics_compare(al.u.str,search->u.str,linguistics_cmp_partial)<0) {
- dbg(lvl_debug,"Skipping index item with first_key='%s', last_key='%s'\n", af.u.str, al.u.str);
- return;
- }
- }
- }
- }
-
- push_zipfile_tile(mr, at.u.num, 0, 0, 0);
-}
-
-static int
-map_parse_submap(struct map_rect_priv *mr, int async)
-{
- struct coord_rect r;
- struct coord c[2];
- struct attr at;
- struct range mima;
- if (binfile_coord_get(mr->item.priv_data, c, 2) != 2)
- return 0;
- r.lu.x=c[0].x;
- r.lu.y=c[1].y;
- r.rl.x=c[1].x;
- r.rl.y=c[0].y;
- if (!binfile_attr_get(mr->item.priv_data, attr_order, &at))
- return 0;
-#if __BYTE_ORDER == __BIG_ENDIAN
- mima.min=le16_to_cpu(at.u.range.max);
- mima.max=le16_to_cpu(at.u.range.min);
-#else
- mima=at.u.range;
+ fprintf(stderr,"offset=%d\n", (unsigned char *)(mr->pos)-mr->m->f->begin);
#endif
- if (!mr->m->eoc || !selection_contains(mr->sel, &r, &mima))
- return 0;
- if (!binfile_attr_get(mr->item.priv_data, attr_zipfile_ref, &at))
- return 0;
- dbg(lvl_debug,"pushing zipfile %ld from %d\n", at.u.num, mr->t->zipfile_num);
- return push_zipfile_tile(mr, at.u.num, 0, 0, async);
-}
-
-static int
-push_modified_item(struct map_rect_priv *mr)
-{
- struct item_id id;
- struct binfile_hash_entry *entry;
- id.id_hi=mr->item.id_hi;
- id.id_lo=mr->item.id_lo;
- entry=g_hash_table_lookup(mr->m->changes, &id);
- if (entry) {
- struct tile tn;
- tn.pos_next=tn.pos=tn.start=entry->data;
- tn.zipfile_num=mr->item.id_hi;
- tn.mode=2;
- tn.end=tn.start+le32_to_cpu(entry->data[0])+1;
- push_tile(mr, &tn, 0, 0);
- return 1;
- }
- return 0;
-}
-
-static struct item *
-map_rect_get_item_binfile(struct map_rect_priv *mr)
-{
- struct tile *t;
- struct map_priv *m=mr->m;
- if (m->download) {
- download(m, NULL, NULL, 0, 0, 0, 2);
- return &busy_item;
- }
- if (mr->status == 1) {
- mr->status=0;
- if (push_zipfile_tile(mr, m->zip_members-1, 0, 0, 1))
- return &busy_item;
- }
- for (;;) {
- t=mr->t;
- if (! t)
- return NULL;
- t->pos=t->pos_next;
- if (t->pos >= t->end) {
- if (pop_tile(mr))
- continue;
- return NULL;
- }
- setup_pos(mr);
- binfile_coord_rewind(mr);
- binfile_attr_rewind(mr);
- if ((mr->item.type == type_submap) && (!mr->country_id)) {
- if (map_parse_submap(mr, 1))
- return &busy_item;
- continue;
- }
- if (t->mode != 2) {
- mr->item.id_hi=t->zipfile_num;
- mr->item.id_lo=t->pos-t->start;
- if (mr->m->changes && push_modified_item(mr))
- continue;
- }
- if (mr->country_id)
- {
- if (mr->item.type == type_countryindex) {
- map_parse_country_binfile(mr);
- }
- if (item_is_town(mr->item))
- {
- return &mr->item;
- } else {
- continue;
- }
- }
- return &mr->item;
- }
-}
-
-static struct item *
-map_rect_get_item_byid_binfile(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- struct tile *t;
- if (mr->m->eoc) {
- while (pop_tile(mr));
- push_zipfile_tile(mr, id_hi, 0, 0, 0);
- }
- t=mr->t;
- t->pos=t->start+id_lo;
- mr->item.id_hi=id_hi;
- mr->item.id_lo=id_lo;
- if (mr->m->changes)
- push_modified_item(mr);
- setup_pos(mr);
- binfile_coord_rewind(mr);
- binfile_attr_rewind(mr);
- return &mr->item;
-}
-
-static int
-binmap_search_by_index(struct map_priv *map, struct item *item, struct map_rect_priv **ret)
-{
- struct attr zipfile_ref;
- int *data;
-
- if (!item) {
- *ret=NULL;
- return 0;
- }
- if (item_attr_get(item, attr_item_id, &zipfile_ref)) {
- data=zipfile_ref.u.data;
- *ret=map_rect_new_binfile_int(map, NULL);
- push_zipfile_tile(*ret, le32_to_cpu(data[0]), le32_to_cpu(data[1]), -1, 0);
- return 3;
- }
- if (item_attr_get(item, attr_zipfile_ref, &zipfile_ref)) {
- *ret=map_rect_new_binfile_int(map, NULL);
- push_zipfile_tile(*ret, zipfile_ref.u.num, 0, 0, 0);
- return 1;
- }
- if (item_attr_get(item, attr_zipfile_ref_block, &zipfile_ref)) {
- data=zipfile_ref.u.data;
- *ret=map_rect_new_binfile_int(map, NULL);
- push_zipfile_tile(*ret, le32_to_cpu(data[0]), le32_to_cpu(data[1]), le32_to_cpu(data[2]), 0);
- return 2;
- }
- *ret=NULL;
- return 0;
-}
-
-static struct map_rect_priv *
-binmap_search_street_by_place(struct map_priv *map, struct item *town, struct coord *c, struct map_selection *sel, GList **boundaries)
-{
- struct attr town_name, poly_town_name;
- struct map_rect_priv *map_rec2;
- struct item *place;
- int found=0;
-
- if (!item_attr_get(town, attr_label, &town_name))
- return NULL;
- sel->range = item_range_all;
- sel->order = 18;
- sel->next = NULL;
- sel->u.c_rect.lu=*c;
- sel->u.c_rect.rl=*c;
- map_rec2=map_rect_new_binfile(map, sel);
- while ((place=map_rect_get_item_binfile(map_rec2))) {
- if (item_is_poly_place(*place) &&
- item_attr_get(place, attr_label, &poly_town_name) &&
- !strcmp(poly_town_name.u.str,town_name.u.str)) {
- struct coord *c;
- int i,count;
- struct geom_poly_segment *bnd;
- count=binfile_coord_left(map_rec2);
- c=g_new(struct coord,count);
- found=1;
- item_coord_get(place, c, count);
- for (i = 0 ; i < count ; i++)
- coord_rect_extend(&sel->u.c_rect, &c[i]);
- bnd=g_new(struct geom_poly_segment,1);
- bnd->first=c;
- bnd->last=c+count-1;
- bnd->type=geom_poly_segment_type_way_outer;
- *boundaries=g_list_prepend(*boundaries,bnd);
- }
- }
- map_rect_destroy_binfile(map_rec2);
- if (found)
- return map_rect_new_binfile(map, sel);
- return NULL;
-}
-
-static int
-binmap_get_estimated_town_size(struct item *town)
-{
- int size = 10000;
- switch (town->type) {
- case type_town_label_1e5:
- case type_town_label_5e4:
- case type_town_label_2e4:
- case type_district_label_1e5:
- case type_district_label_5e4:
- case type_district_label_2e4:
- size = 5000;
- break;
- case type_town_label_1e4:
- case type_town_label_5e3:
- case type_town_label_2e3:
- case type_district_label_1e4:
- case type_district_label_5e3:
- case type_district_label_2e3:
- size = 2500;
- break;
- case type_town_label_1e3:
- case type_town_label_5e2:
- case type_town_label_2e2:
- case type_town_label_1e2:
- case type_town_label_5e1:
- case type_town_label_2e1:
- case type_town_label_1e1:
- case type_town_label_5e0:
- case type_town_label_2e0:
- case type_town_label_1e0:
- case type_town_label_0e0:
- case type_district_label_1e3:
- case type_district_label_5e2:
- case type_district_label_2e2:
- case type_district_label_1e2:
- case type_district_label_5e1:
- case type_district_label_2e1:
- case type_district_label_1e1:
- case type_district_label_5e0:
- case type_district_label_2e0:
- case type_district_label_1e0:
- case type_district_label_0e0:
- size = 1000;
- break;
- default:
- break;
- }
- return size;
-}
-
-static struct map_rect_priv *
-binmap_search_street_by_estimate(struct map_priv *map, struct item *town, struct coord *c, struct map_selection *sel)
-{
- int size = binmap_get_estimated_town_size(town);
-
- sel->u.c_rect.lu.x = c->x-size;
- sel->u.c_rect.lu.y = c->y+size;
- sel->u.c_rect.rl.x = c->x+size;
- sel->u.c_rect.rl.y = c->y-size;
- return map_rect_new_binfile(map, sel);
+ dbg(lvl_debug,"size error");
+ }
+ t->pos_next=t->pos+size+1;
+ mr->item.type=le32_to_cpu(t->pos[1]);
+ coord_size=le32_to_cpu(t->pos[2]);
+ t->pos_coord_start=t->pos+3;
+ t->pos_attr_start=t->pos_coord_start+coord_size;
+}
+
+static int selection_contains(struct map_selection *sel, struct coord_rect *r, struct range *mima) {
+ int order;
+ if (! sel)
+ return 1;
+ while (sel) {
+ if (coord_rect_overlap(r, &sel->u.c_rect)) {
+ order=sel->order;
+ dbg(lvl_debug,"min %d max %d order %d", mima->min, mima->max, order);
+ if (!mima->min && !mima->max)
+ return 1;
+ if (order >= mima->min && order <= mima->max)
+ return 1;
+ }
+ sel=sel->next;
+ }
+ return 0;
}
-static struct map_rect_priv *
-binmap_search_housenumber_by_estimate(struct map_priv *map, struct coord *c, struct map_selection *sel)
-{
- int size = 400;
- sel->u.c_rect.lu.x = c->x-size;
- sel->u.c_rect.lu.y = c->y+size;
- sel->u.c_rect.rl.x = c->x+size;
- sel->u.c_rect.rl.y = c->y-size;
-
- sel->range = item_range_all;
- sel->order = 18;
+static void map_parse_country_binfile(struct map_rect_priv *mr) {
+ struct attr at;
- return map_rect_new_binfile(map, sel);
-}
+ if (!binfile_attr_get(mr->item.priv_data, attr_country_id, &at))
+ return;
+ if( at.u.num != mr->country_id)
+ return;
-static int
-binmap_get_estimated_boundaries (struct item *town, GList **boundaries)
-{
- int size = binmap_get_estimated_town_size(town);
- struct coord tc;
-
- if (item_coord_get(town, &tc, 1))
- {
- struct geom_poly_segment *bnd;
- struct coord *c;
- c=g_new(struct coord,5);
- bnd=g_new(struct geom_poly_segment,1);
- c[0].x = tc.x + size;
- c[0].y = tc.y - size;
- c[1].x = tc.x - size;
- c[1].y = tc.y - size;
- c[2].x = tc.x - size;
- c[2].y = tc.y + size;
- c[3].x = tc.x + size;
- c[3].y = tc.y + size;
- c[4].x = c[0].x;
- c[4].y = c[0].y;
- bnd->first=&c[0];
- bnd->last=&c[4];
- bnd->type=geom_poly_segment_type_way_outer;
- *boundaries=g_list_prepend(*boundaries,bnd);
- return 1;
- }
- return 0;
-}
-
-static struct map_search_priv *
-binmap_search_new(struct map_priv *map, struct item *item, struct attr *search, int partial)
-{
- struct map_rect_priv *map_rec;
- struct map_search_priv *msp=g_new0(struct map_search_priv, 1);
- struct item *town;
- int idx;
-
- msp->search = *search;
- msp->partial = partial;
- if(ATTR_IS_STRING(msp->search.type))
- msp->search.u.str=linguistics_casefold(search->u.str);
+ if (!binfile_attr_get(mr->item.priv_data, attr_zipfile_ref, &at))
+ return;
- /*
+ if(mr->msp) {
+ struct attr *search=&mr->msp->search;
+ if(search->type==attr_town_name || search->type==attr_district_name || search->type==attr_town_or_district_name) {
+ struct attr af, al;
+ if(binfile_attr_get(mr->item.priv_data, attr_first_key, &af)) {
+ if(linguistics_compare(af.u.str,search->u.str,linguistics_cmp_partial)>0) {
+ dbg(lvl_debug,"Skipping index item with first_key='%s'", af.u.str);
+ return;
+ }
+ }
+ if(binfile_attr_get(mr->item.priv_data, attr_last_key, &al)) {
+ if(linguistics_compare(al.u.str,search->u.str,linguistics_cmp_partial)<0) {
+ dbg(lvl_debug,"Skipping index item with first_key='%s', last_key='%s'", af.u.str, al.u.str);
+ return;
+ }
+ }
+ }
+ }
+
+ push_zipfile_tile(mr, at.u.num, 0, 0, 0);
+}
+
+static int map_parse_submap(struct map_rect_priv *mr, int async) {
+ struct coord_rect r;
+ struct coord c[2];
+ struct attr at;
+ struct range mima;
+ if (binfile_coord_get(mr->item.priv_data, c, 2) != 2)
+ return 0;
+ r.lu.x=c[0].x;
+ r.lu.y=c[1].y;
+ r.rl.x=c[1].x;
+ r.rl.y=c[0].y;
+ if (!binfile_attr_get(mr->item.priv_data, attr_order, &at))
+ return 0;
+#if __BYTE_ORDER == __BIG_ENDIAN
+ mima.min=le16_to_cpu(at.u.range.max);
+ mima.max=le16_to_cpu(at.u.range.min);
+#else
+ mima=at.u.range;
+#endif
+ if (!mr->m->eoc || !selection_contains(mr->sel, &r, &mima))
+ return 0;
+ if (!binfile_attr_get(mr->item.priv_data, attr_zipfile_ref, &at))
+ return 0;
+ dbg(lvl_debug,"pushing zipfile %ld from %d", at.u.num, mr->t->zipfile_num);
+ return push_zipfile_tile(mr, at.u.num, 0, 0, async);
+}
+
+static int push_modified_item(struct map_rect_priv *mr) {
+ struct item_id id;
+ struct binfile_hash_entry *entry;
+ id.id_hi=mr->item.id_hi;
+ id.id_lo=mr->item.id_lo;
+ entry=g_hash_table_lookup(mr->m->changes, &id);
+ if (entry) {
+ struct tile tn;
+ tn.pos_next=tn.pos=tn.start=entry->data;
+ tn.zipfile_num=mr->item.id_hi;
+ tn.mode=2;
+ tn.end=tn.start+le32_to_cpu(entry->data[0])+1;
+ push_tile(mr, &tn, 0, 0);
+ return 1;
+ }
+ return 0;
+}
+
+static struct item *map_rect_get_item_binfile(struct map_rect_priv *mr) {
+ struct tile *t;
+ struct map_priv *m=mr->m;
+ if (m->download) {
+ download(m, NULL, NULL, 0, 0, 0, 2);
+ return &busy_item;
+ }
+ if (mr->status == 1) {
+ mr->status=0;
+ if (push_zipfile_tile(mr, m->zip_members-1, 0, 0, 1))
+ return &busy_item;
+ }
+ for (;;) {
+ t=mr->t;
+ if (! t)
+ return NULL;
+ t->pos=t->pos_next;
+ if (t->pos >= t->end) {
+ if (pop_tile(mr))
+ continue;
+ return NULL;
+ }
+ setup_pos(mr);
+ binfile_coord_rewind(mr);
+ binfile_attr_rewind(mr);
+ if ((mr->item.type == type_submap) && (!mr->country_id)) {
+ if (map_parse_submap(mr, 1))
+ return &busy_item;
+ continue;
+ }
+ if (t->mode != 2) {
+ mr->item.id_hi=t->zipfile_num;
+ mr->item.id_lo=t->pos-t->start;
+ if (mr->m->changes && push_modified_item(mr))
+ continue;
+ }
+ if (mr->country_id) {
+ if (mr->item.type == type_countryindex) {
+ map_parse_country_binfile(mr);
+ }
+ if (item_is_town(mr->item)) {
+ return &mr->item;
+ } else {
+ continue;
+ }
+ }
+ return &mr->item;
+ }
+}
+
+static struct item *map_rect_get_item_byid_binfile(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ struct tile *t;
+ if (mr->m->eoc) {
+ while (pop_tile(mr));
+ push_zipfile_tile(mr, id_hi, 0, 0, 0);
+ }
+ t=mr->t;
+ t->pos=t->start+id_lo;
+ mr->item.id_hi=id_hi;
+ mr->item.id_lo=id_lo;
+ if (mr->m->changes)
+ push_modified_item(mr);
+ setup_pos(mr);
+ binfile_coord_rewind(mr);
+ binfile_attr_rewind(mr);
+ return &mr->item;
+}
+
+static int binmap_search_by_index(struct map_priv *map, struct item *item, struct map_rect_priv **ret) {
+ struct attr zipfile_ref;
+ int *data;
+
+ if (!item) {
+ *ret=NULL;
+ return 0;
+ }
+ if (item_attr_get(item, attr_item_id, &zipfile_ref)) {
+ data=zipfile_ref.u.data;
+ *ret=map_rect_new_binfile_int(map, NULL);
+ push_zipfile_tile(*ret, le32_to_cpu(data[0]), le32_to_cpu(data[1]), -1, 0);
+ return 3;
+ }
+ if (item_attr_get(item, attr_zipfile_ref, &zipfile_ref)) {
+ *ret=map_rect_new_binfile_int(map, NULL);
+ push_zipfile_tile(*ret, zipfile_ref.u.num, 0, 0, 0);
+ return 1;
+ }
+ if (item_attr_get(item, attr_zipfile_ref_block, &zipfile_ref)) {
+ data=zipfile_ref.u.data;
+ *ret=map_rect_new_binfile_int(map, NULL);
+ push_zipfile_tile(*ret, le32_to_cpu(data[0]), le32_to_cpu(data[1]), le32_to_cpu(data[2]), 0);
+ return 2;
+ }
+ *ret=NULL;
+ return 0;
+}
+
+static struct map_rect_priv *binmap_search_street_by_place(struct map_priv *map, struct item *town, struct coord *c,
+ struct map_selection *sel,
+ GList **boundaries) {
+ struct attr town_name, poly_town_name;
+ struct map_rect_priv *map_rec2;
+ struct item *place;
+ int found=0;
+
+ if (!item_attr_get(town, attr_label, &town_name))
+ return NULL;
+ sel->range = item_range_all;
+ sel->order = 18;
+ sel->next = NULL;
+ sel->u.c_rect.lu=*c;
+ sel->u.c_rect.rl=*c;
+ map_rec2=map_rect_new_binfile(map, sel);
+ while ((place=map_rect_get_item_binfile(map_rec2))) {
+ if (item_is_poly_place(*place) &&
+ item_attr_get(place, attr_label, &poly_town_name) &&
+ !strcmp(poly_town_name.u.str,town_name.u.str)) {
+ struct coord *c;
+ int i,count;
+ struct geom_poly_segment *bnd;
+ count=binfile_coord_left(map_rec2);
+ c=g_new(struct coord,count);
+ found=1;
+ item_coord_get(place, c, count);
+ for (i = 0 ; i < count ; i++)
+ coord_rect_extend(&sel->u.c_rect, &c[i]);
+ bnd=g_new(struct geom_poly_segment,1);
+ bnd->first=c;
+ bnd->last=c+count-1;
+ bnd->type=geom_poly_segment_type_way_outer;
+ *boundaries=g_list_prepend(*boundaries,bnd);
+ }
+ }
+ map_rect_destroy_binfile(map_rec2);
+ if (found)
+ return map_rect_new_binfile(map, sel);
+ return NULL;
+}
+
+static int binmap_get_estimated_town_size(struct item *town) {
+ int size = 10000;
+ switch (town->type) {
+ case type_town_label_1e5:
+ case type_town_label_5e4:
+ case type_town_label_2e4:
+ case type_district_label_1e5:
+ case type_district_label_5e4:
+ case type_district_label_2e4:
+ size = 5000;
+ break;
+ case type_town_label_1e4:
+ case type_town_label_5e3:
+ case type_town_label_2e3:
+ case type_district_label_1e4:
+ case type_district_label_5e3:
+ case type_district_label_2e3:
+ size = 2500;
+ break;
+ case type_town_label_1e3:
+ case type_town_label_5e2:
+ case type_town_label_2e2:
+ case type_town_label_1e2:
+ case type_town_label_5e1:
+ case type_town_label_2e1:
+ case type_town_label_1e1:
+ case type_town_label_5e0:
+ case type_town_label_2e0:
+ case type_town_label_1e0:
+ case type_town_label_0e0:
+ case type_district_label_1e3:
+ case type_district_label_5e2:
+ case type_district_label_2e2:
+ case type_district_label_1e2:
+ case type_district_label_5e1:
+ case type_district_label_2e1:
+ case type_district_label_1e1:
+ case type_district_label_5e0:
+ case type_district_label_2e0:
+ case type_district_label_1e0:
+ case type_district_label_0e0:
+ size = 1000;
+ break;
+ default:
+ break;
+ }
+ return size;
+}
+
+static struct map_rect_priv *binmap_search_street_by_estimate(struct map_priv *map, struct item *town, struct coord *c,
+ struct map_selection *sel) {
+ int size = binmap_get_estimated_town_size(town);
+
+ sel->u.c_rect.lu.x = c->x-size;
+ sel->u.c_rect.lu.y = c->y+size;
+ sel->u.c_rect.rl.x = c->x+size;
+ sel->u.c_rect.rl.y = c->y-size;
+ return map_rect_new_binfile(map, sel);
+}
+
+static struct map_rect_priv *binmap_search_housenumber_by_estimate(struct map_priv *map, struct coord *c,
+ struct map_selection *sel) {
+ int size = 400;
+ sel->u.c_rect.lu.x = c->x-size;
+ sel->u.c_rect.lu.y = c->y+size;
+ sel->u.c_rect.rl.x = c->x+size;
+ sel->u.c_rect.rl.y = c->y-size;
+
+ sel->range = item_range_all;
+ sel->order = 18;
+
+ return map_rect_new_binfile(map, sel);
+}
+
+
+static int binmap_get_estimated_boundaries (struct item *town, GList **boundaries) {
+ int size = binmap_get_estimated_town_size(town);
+ struct coord tc;
+
+ if (item_coord_get(town, &tc, 1)) {
+ struct geom_poly_segment *bnd;
+ struct coord *c;
+ c=g_new(struct coord,5);
+ bnd=g_new(struct geom_poly_segment,1);
+ c[0].x = tc.x + size;
+ c[0].y = tc.y - size;
+ c[1].x = tc.x - size;
+ c[1].y = tc.y - size;
+ c[2].x = tc.x - size;
+ c[2].y = tc.y + size;
+ c[3].x = tc.x + size;
+ c[3].y = tc.y + size;
+ c[4].x = c[0].x;
+ c[4].y = c[0].y;
+ bnd->first=&c[0];
+ bnd->last=&c[4];
+ bnd->type=geom_poly_segment_type_way_outer;
+ *boundaries=g_list_prepend(*boundaries,bnd);
+ return 1;
+ }
+ return 0;
+}
+
+static struct map_search_priv *binmap_search_new(struct map_priv *map, struct item *item, struct attr *search,
+ int partial) {
+ struct map_rect_priv *map_rec;
+ struct map_search_priv *msp=g_new0(struct map_search_priv, 1);
+ struct item *town;
+ int idx;
+
+ msp->search = *search;
+ msp->partial = partial;
+ if(ATTR_IS_STRING(msp->search.type))
+ msp->search.u.str=linguistics_casefold(search->u.str);
+
+ /*
* NOTE: If you implement search for other attributes than attr_town_name and attr_street_name,
* please update this comment and the documentation for map_search_new() in map.c
*/
- switch (search->type) {
- case attr_country_name:
- break;
- case attr_town_name:
- case attr_town_or_district_name:
- case attr_town_postal:
- map_rec = map_rect_new_binfile(map, NULL);
- if (!map_rec)
- break;
- map_rec->country_id = item->id_lo;
- map_rec->msp = msp;
- msp->mr = map_rec;
- return msp;
- break;
- case attr_street_name:
- if (! item->map)
- break;
- if (!map_priv_is(item->map, map))
- break;
- map_rec = map_rect_new_binfile(map, NULL);
- town = map_rect_get_item_byid_binfile(map_rec, item->id_hi, item->id_lo);
- if (town) {
- struct coord c;
-
- if (binmap_search_by_index(map, town, &msp->mr))
- msp->mode = 1;
- else {
- map->last_searched_town_id_hi = town->id_hi;
- map->last_searched_town_id_lo = town->id_lo;
- if (item_coord_get(town, &c, 1)) {
- if ((msp->mr=binmap_search_street_by_place(map, town, &c, &msp->ms, &msp->boundaries)))
- msp->mode = 2;
- else {
- msp->mr=binmap_search_street_by_estimate(map, town, &c, &msp->ms);
- msp->mode = 3;
- }
- }
- }
- map_rect_destroy_binfile(map_rec);
- if (!msp->mr)
- break;
- return msp;
- }
- map_rect_destroy_binfile(map_rec);
- break;
- case attr_house_number:
- dbg(lvl_debug,"case house_number");
- if (! item->map)
- break;
- if (!map_priv_is(item->map, map))
- break;
- msp->map=map;
- msp->mr_item = map_rect_new_binfile(map, NULL);
- msp->item = map_rect_get_item_byid_binfile(msp->mr_item, item->id_hi, item->id_lo);
- idx=binmap_search_by_index(map, msp->item, &msp->mr);
- if (idx)
- msp->mode = 1;
- else
- {
- struct coord c;
- if (item_coord_get(msp->item, &c, 1))
- {
- struct attr attr;
- map_rec = map_rect_new_binfile(map, NULL);
- town = map_rect_get_item_byid_binfile(map_rec, map->last_searched_town_id_hi, map->last_searched_town_id_lo);
- if (town)
- msp->mr = binmap_search_street_by_place(map, town, &c, &msp->ms, &msp->boundaries);
- if (msp->boundaries)
- dbg(lvl_debug, "using map town boundaries\n");
- if (!msp->boundaries && town)
- {
- binmap_get_estimated_boundaries(town, &msp->boundaries);
- if (msp->boundaries)
- dbg(lvl_debug, "using estimated boundaries\n");
- }
- map_rect_destroy_binfile(map_rec);
- /* start searching in area around the street segment even if town boundaries are available */
- msp->mr=binmap_search_housenumber_by_estimate(map, &c, &msp->ms);
- msp->mode = 2;
- msp->rect_new=msp->ms.u.c_rect;
- if(item_attr_get(msp->item, attr_street_name, &attr))
- msp->parent_name=g_strdup(attr.u.str);
- dbg(lvl_debug,"pn=%s\n",msp->parent_name);
- }
- }
- if (idx != 3) {
- map_rect_destroy_binfile(msp->mr_item);
- msp->mr_item=NULL;
- }
- if (!msp->mr)
- {
- break;
- }
- return msp;
- default:
- break;
- }
- if(ATTR_IS_STRING(msp->search.type))
- g_free(msp->search.u.str);
- g_free(msp);
- return NULL;
-}
-
-
-struct duplicate
-{
- struct coord c;
- char str[0];
+ switch (search->type) {
+ case attr_country_name:
+ break;
+ case attr_town_name:
+ case attr_town_or_district_name:
+ case attr_town_postal:
+ map_rec = map_rect_new_binfile(map, NULL);
+ if (!map_rec)
+ break;
+ map_rec->country_id = item->id_lo;
+ map_rec->msp = msp;
+ msp->mr = map_rec;
+ return msp;
+ break;
+ case attr_street_name:
+ if (! item->map)
+ break;
+ if (!map_priv_is(item->map, map))
+ break;
+ map_rec = map_rect_new_binfile(map, NULL);
+ town = map_rect_get_item_byid_binfile(map_rec, item->id_hi, item->id_lo);
+ if (town) {
+ struct coord c;
+
+ if (binmap_search_by_index(map, town, &msp->mr))
+ msp->mode = 1;
+ else {
+ map->last_searched_town_id_hi = town->id_hi;
+ map->last_searched_town_id_lo = town->id_lo;
+ if (item_coord_get(town, &c, 1)) {
+ if ((msp->mr=binmap_search_street_by_place(map, town, &c, &msp->ms, &msp->boundaries)))
+ msp->mode = 2;
+ else {
+ msp->mr=binmap_search_street_by_estimate(map, town, &c, &msp->ms);
+ msp->mode = 3;
+ }
+ }
+ }
+ map_rect_destroy_binfile(map_rec);
+ if (!msp->mr)
+ break;
+ return msp;
+ }
+ map_rect_destroy_binfile(map_rec);
+ break;
+ case attr_house_number:
+ dbg(lvl_debug,"case house_number");
+ if (! item->map)
+ break;
+ if (!map_priv_is(item->map, map))
+ break;
+ msp->map=map;
+ msp->mr_item = map_rect_new_binfile(map, NULL);
+ msp->item = map_rect_get_item_byid_binfile(msp->mr_item, item->id_hi, item->id_lo);
+ idx=binmap_search_by_index(map, msp->item, &msp->mr);
+ if (idx)
+ msp->mode = 1;
+ else {
+ struct coord c;
+ if (item_coord_get(msp->item, &c, 1)) {
+ struct attr attr;
+ map_rec = map_rect_new_binfile(map, NULL);
+ town = map_rect_get_item_byid_binfile(map_rec, map->last_searched_town_id_hi, map->last_searched_town_id_lo);
+ if (town)
+ msp->mr = binmap_search_street_by_place(map, town, &c, &msp->ms, &msp->boundaries);
+ if (msp->boundaries)
+ dbg(lvl_debug, "using map town boundaries");
+ if (!msp->boundaries && town) {
+ binmap_get_estimated_boundaries(town, &msp->boundaries);
+ if (msp->boundaries)
+ dbg(lvl_debug, "using estimated boundaries");
+ }
+ map_rect_destroy_binfile(map_rec);
+ /* start searching in area around the street segment even if town boundaries are available */
+ msp->mr=binmap_search_housenumber_by_estimate(map, &c, &msp->ms);
+ msp->mode = 2;
+ msp->rect_new=msp->ms.u.c_rect;
+ if(item_attr_get(msp->item, attr_street_name, &attr))
+ msp->parent_name=g_strdup(attr.u.str);
+ dbg(lvl_debug,"pn=%s",msp->parent_name);
+ }
+ }
+ if (idx != 3) {
+ map_rect_destroy_binfile(msp->mr_item);
+ msp->mr_item=NULL;
+ }
+ if (!msp->mr) {
+ break;
+ }
+ return msp;
+ default:
+ break;
+ }
+ if(ATTR_IS_STRING(msp->search.type))
+ g_free(msp->search.u.str);
+ g_free(msp);
+ return NULL;
+}
+
+
+struct duplicate {
+ struct coord c;
+ char str[0];
};
-static guint
-duplicate_hash(gconstpointer key)
-{
- const struct duplicate *d=key;
- return d->c.x^d->c.y^g_str_hash(d->str);
+static guint duplicate_hash(gconstpointer key) {
+ const struct duplicate *d=key;
+ return d->c.x^d->c.y^g_str_hash(d->str);
}
-static gboolean
-duplicate_equal(gconstpointer a, gconstpointer b)
-{
- const struct duplicate *da=a;
- const struct duplicate *db=b;
- return (da->c.x == db->c.x && da->c.y == db->c.y && g_str_equal(da->str,db->str));
+static gboolean duplicate_equal(gconstpointer a, gconstpointer b) {
+ const struct duplicate *da=a;
+ const struct duplicate *db=b;
+ return (da->c.x == db->c.x && da->c.y == db->c.y && g_str_equal(da->str,db->str));
}
/**
@@ -2176,43 +2045,42 @@ duplicate_equal(gconstpointer a, gconstpointer b)
* returns - pointer to new struct duplicate, if this item is not already exist in hash
* - NULL if this item already exists in duplicate hash or doesnt have an attr_type attr;
*/
-static struct duplicate*
-duplicate_test(struct map_search_priv *msp, struct item *item, enum attr_type attr_type, enum attr_type attr_type2)
-{
-struct attr attr;
- struct attr attr2;
- int len;
- char *buffer;
- struct duplicate *d;
-
- if (!msp->search_results)
- msp->search_results = g_hash_table_new_full(duplicate_hash, duplicate_equal, g_free, NULL);
- binfile_attr_rewind(item->priv_data);
- if (!item_attr_get(item, attr_type, &attr))
- return NULL;
- len=sizeof(struct coord)+strlen(attr.u.str)+1;
- binfile_attr_rewind(item->priv_data);
- if (attr_type2 && item_attr_get(item, attr_type2, &attr2) && attr2.u.str) {
- len = len + strlen(attr2.u.str);
- }
- buffer=g_alloca(sizeof(char)*len);
- d=(struct duplicate *)buffer;
- if (!item_coord_get(item, &d->c, 1)) {
- d->c.x=0;
- d->c.y=0;
- }
- strcpy(d->str, attr.u.str);
- if(attr_type2 && attr2.u.str){
- strcat(d->str,attr2.u.str);
- }
- binfile_coord_rewind(item->priv_data);
- binfile_attr_rewind(item->priv_data);
- if (!g_hash_table_lookup(msp->search_results, d)) {
- struct duplicate *dr=g_malloc(len);
- memcpy(dr, d, len);
- return dr;
- }
- return NULL;
+static struct duplicate* duplicate_test(struct map_search_priv *msp, struct item *item, enum attr_type attr_type,
+ enum attr_type attr_type2) {
+ struct attr attr;
+ struct attr attr2;
+ int len;
+ char *buffer;
+ struct duplicate *d;
+
+ if (!msp->search_results)
+ msp->search_results = g_hash_table_new_full(duplicate_hash, duplicate_equal, g_free, NULL);
+ binfile_attr_rewind(item->priv_data);
+ if (!item_attr_get(item, attr_type, &attr))
+ return NULL;
+ len=sizeof(struct coord)+strlen(attr.u.str)+1;
+ binfile_attr_rewind(item->priv_data);
+ if (attr_type2 && item_attr_get(item, attr_type2, &attr2) && attr2.u.str) {
+ len = len + strlen(attr2.u.str);
+ }
+ buffer=g_alloca(sizeof(char)*len);
+ d=(struct duplicate *)buffer;
+ if (!item_coord_get(item, &d->c, 1)) {
+ d->c.x=0;
+ d->c.y=0;
+ }
+ strcpy(d->str, attr.u.str);
+ if(attr_type2 && attr2.u.str) {
+ strcat(d->str,attr2.u.str);
+ }
+ binfile_coord_rewind(item->priv_data);
+ binfile_attr_rewind(item->priv_data);
+ if (!g_hash_table_lookup(msp->search_results, d)) {
+ struct duplicate *dr=g_malloc(len);
+ memcpy(dr, d, len);
+ return dr;
+ }
+ return NULL;
}
/**
@@ -2220,10 +2088,8 @@ struct attr attr;
* @param msp pointer to private map search data
* @param duplicate Duplicate info to insert
*/
-static void
-duplicate_insert(struct map_search_priv *msp, struct duplicate *d)
-{
- g_hash_table_insert(msp->search_results, d, GINT_TO_POINTER(1));
+static void duplicate_insert(struct map_search_priv *msp, struct duplicate *d) {
+ g_hash_table_insert(msp->search_results, d, GINT_TO_POINTER(1));
}
/**
@@ -2235,619 +2101,585 @@ duplicate_insert(struct map_search_priv *msp, struct duplicate *d)
* @returns 0 if item is not a duplicate
* 1 if item is duplicate or doesn't have required attr_type attribute
*/
-static int
-duplicate(struct map_search_priv *msp, struct item *item, enum attr_type attr_type, enum attr_type attr_type2)
-{
- struct duplicate *d=duplicate_test(msp, item, attr_type, attr_type2);
- if(!d)
- return 1;
- duplicate_insert(msp,d);
- return 0;
+static int duplicate(struct map_search_priv *msp, struct item *item, enum attr_type attr_type,
+ enum attr_type attr_type2) {
+ struct duplicate *d=duplicate_test(msp, item, attr_type, attr_type2);
+ if(!d)
+ return 1;
+ duplicate_insert(msp,d);
+ return 0;
}
-static int
-item_inside_poly_list(struct item *it, GList *l)
-{
+static int item_inside_poly_list(struct item *it, GList *l) {
- while(l) {
- struct geom_poly_segment *p=l->data;
- int count=p->last-p->first+1;
- struct coord c;
- int ccount;
- item_coord_rewind(it);
- ccount=binfile_coord_left(it->priv_data);
- if(ccount==1)
- item_coord_get(it,&c,1);
- else if(ccount==2) {
- struct coord c2;
- item_coord_get(it,&c,1);
- item_coord_get(it,&c2,1);
- c.x=(c.x+c2.x)/2;
- c.y=(c.y+c2.y)/2;
- } else {
- if(ccount>3)
- ccount/=2;
- else
- ccount=2;
- while(--ccount>0)
- item_coord_get(it,&c,1);
- }
- if(geom_poly_point_inside(p->first,count,&c))
- return 1;
- l=g_list_next(l);
- }
- return 0;
-}
-
-static struct item *
-binmap_search_get_item(struct map_search_priv *map_search)
-{
- struct item* it;
- struct attr at;
- enum linguistics_cmp_mode mode=(map_search->partial?linguistics_cmp_partial:0);
-
- for (;;) {
- while ((it = map_rect_get_item_binfile(map_search->mr))) {
- int has_house_number=0;
- switch (map_search->search.type) {
- case attr_town_postal:
- case attr_town_name:
- case attr_district_name:
- case attr_town_or_district_name:
- if (map_search->mr->tile_depth > 1 && item_is_town(*it) && map_search->search.type == attr_town_postal) {
- if (binfile_attr_get(it->priv_data, attr_town_postal, &at)) {
- if (!linguistics_compare(at.u.str, map_search->search.u.str, mode)) {
- /* check for duplicate combination of town_name and town_postal */
- if (!duplicate(map_search, it, attr_town_name, attr_town_postal)) {
- return it;
- } else {
- break;
- }
- }
- }
- }
- if (map_search->mr->tile_depth > 1 && item_is_town(*it) && map_search->search.type != attr_district_name) {
- if (binfile_attr_get(it->priv_data, attr_town_name_match, &at) || binfile_attr_get(it->priv_data, attr_town_name, &at)) {
- if (!linguistics_compare(at.u.str, map_search->search.u.str, mode) && !duplicate(map_search, it, attr_town_name,0))
- return it;
- }
- }
- if (map_search->mr->tile_depth > 1 && item_is_district(*it) && map_search->search.type != attr_town_name) {
- if (binfile_attr_get(it->priv_data, attr_district_name_match, &at) || binfile_attr_get(it->priv_data, attr_district_name, &at)) {
- if (!linguistics_compare(at.u.str, map_search->search.u.str, mode) && !duplicate(map_search, it, attr_town_name,0))
- return it;
- }
- }
- break;
- case attr_street_name:
- if (map_search->mode == 1) {
- if (binfile_attr_get(it->priv_data, attr_street_name_match, &at) || binfile_attr_get(it->priv_data, attr_street_name, &at)) {
- if (!linguistics_compare(at.u.str, map_search->search.u.str, mode) && !duplicate(map_search, it, attr_street_name,0)) {
- return it;
- }
- }
- continue;
- }
- if (item_is_street(*it)) {
- struct attr at;
- if (!map_selection_contains_item_rect(map_search->mr->sel, it))
- break;
-
- if(binfile_attr_get(it->priv_data, attr_label, &at)) {
- struct coord c[128];
- struct duplicate *d;
-
- /* Extracting all coords here makes duplicate_new() not consider them (we don't want all
- * street segments to be reported as separate streets). */
- while(item_coord_get(it,c,128)>0);
- d=duplicate_test(map_search, it, attr_label,0);
- if(!d)
- break;
-
- if(linguistics_compare(at.u.str, map_search->search.u.str, mode|linguistics_cmp_expand|linguistics_cmp_words)) {
- /* Remember this non-matching street name in duplicate hash to skip name
- * comparison for its following segments */
- duplicate_insert(map_search, d);
- break;
- }
-
- if(map_search->boundaries && !item_inside_poly_list(it,map_search->boundaries)) {
- /* Other segments may fit the town poly. Do not update hash for now. */
- g_free(d);
- break;
- }
-
- duplicate_insert(map_search, d);
- item_coord_rewind(it);
- return it;
- }
- }
- break;
- case attr_house_number:
- has_house_number=binfile_attr_get(it->priv_data, attr_house_number, &at);
- if ((has_house_number
- || it->type == type_house_number_interpolation_even || it->type == type_house_number_interpolation_odd
- || it->type == type_house_number_interpolation_all
- || (map_search->mode == 1 && item_is_street(*it))|| it->type == type_house_number)
- && !(map_search->boundaries && !item_inside_poly_list(it,map_search->boundaries)))
- {
- if (has_house_number)
- {
- struct attr at2;
- if ((binfile_attr_get(it->priv_data, attr_street_name, &at2) || map_search->mode!=2) && !linguistics_compare(at.u.str, map_search->search.u.str, mode)
- && !strcmp(at2.u.str, map_search->parent_name))
- {
- if (!duplicate(map_search, it, attr_house_number,0))
- {
- binfile_attr_rewind(it->priv_data);
- return it;
- }
- }
- }
- else
- {
- struct attr at2;
- if ((binfile_attr_get(it->priv_data, attr_street_name, &at2) || map_search->mode!=2) && !strcmp(at2.u.str, map_search->parent_name))
- {
- if (!duplicate(map_search, it, attr_house_number_interpolation_no_ends_incrmt_2,0))
- {
- binfile_attr_rewind(it->priv_data);
- return it;
- }
- else if (!duplicate(map_search, it, attr_house_number_interpolation_no_ends_incrmt_1,0))
- {
- binfile_attr_rewind(it->priv_data);
- return it;
- }
- } else {
- if (!( it->type == type_house_number_interpolation_even || it->type == type_house_number_interpolation_odd
- || it->type == type_house_number_interpolation_all))
- return it;
- }
-
- }
- } else if( item_is_street(*it) && map_search->mode==2 && map_search->parent_name && binfile_attr_get(it->priv_data, attr_street_name, &at) && !strcmp(at.u.str, map_search->parent_name) )
- {
- /* If matching street segment found, prepare to expand house number search region +100m around each way point */
- if (!(map_search->boundaries && !item_inside_poly_list(it,map_search->boundaries)))
- {
- struct coord c;
- while(item_coord_get(it,&c,1))
- {
- c.x-=100;
- c.y-=100;
- coord_rect_extend(&map_search->rect_new,&c);
- c.x+=200;
- c.y+=200;
- coord_rect_extend(&map_search->rect_new,&c);
- }
- }
- }
- continue;
- default:
- return NULL;
- }
- }
- if(map_search->search.type==attr_house_number && map_search->mode==2 && map_search->parent_name) {
- /* For unindexed house number search, check if street segments extending possible housenumber locations were found */
- if(map_search->ms.u.c_rect.lu.x!=map_search->rect_new.lu.x || map_search->ms.u.c_rect.lu.y!=map_search->rect_new.lu.y ||
- map_search->ms.u.c_rect.rl.x!=map_search->rect_new.rl.x || map_search->ms.u.c_rect.rl.y!=map_search->rect_new.rl.y) {
- map_search->ms.u.c_rect=map_search->rect_new;
- map_rect_destroy_binfile(map_search->mr);
- map_search->mr=map_rect_new_binfile(map_search->map, &map_search->ms);
- dbg(lvl_debug,"Extended house number search region to %d x %d, restarting...\n",map_search->ms.u.c_rect.rl.x - map_search->ms.u.c_rect.lu.x, map_search->ms.u.c_rect.lu.y-map_search->ms.u.c_rect.rl.y);
- continue;
- }
- }
- if (!map_search->mr_item)
- return NULL;
- map_rect_destroy_binfile(map_search->mr);
- if (!binmap_search_by_index(map_search->map, map_search->item, &map_search->mr))
- return NULL;
- }
-}
-
-
-static void
-binmap_search_destroy(struct map_search_priv *ms)
-{
- if (ms->search_results)
- g_hash_table_destroy(ms->search_results);
- if(ATTR_IS_STRING(ms->search.type))
- g_free(ms->search.u.str);
- if(ms->parent_name)
- g_free(ms->parent_name);
- if (ms->mr_item)
- map_rect_destroy_binfile(ms->mr_item);
- if (ms->mr)
- map_rect_destroy_binfile(ms->mr);
- while(ms->boundaries) {
- geom_poly_segment_destroy(ms->boundaries->data);
- ms->boundaries=g_list_delete_link(ms->boundaries,ms->boundaries);
- }
- g_free(ms);
-}
-
-static int
-binmap_get_attr(struct map_priv *m, enum attr_type type, struct attr *attr)
-{
- attr->type=type;
- switch (type) {
- case attr_map_release:
- if (m->map_release) {
- attr->u.str=m->map_release;
- return 1;
- }
- break;
- case attr_progress:
- if (m->progress) {
- attr->u.str=m->progress;
- return 1;
- }
- default:
- break;
- }
- return 0;
-}
-
-static int
-binmap_set_attr(struct map_priv *map, struct attr *attr)
-{
- switch (attr->type) {
- case attr_update:
- map->download_enabled = attr->u.num;
- return 1;
- default:
- return 0;
- }
+ while(l) {
+ struct geom_poly_segment *p=l->data;
+ int count=p->last-p->first+1;
+ struct coord c;
+ int ccount;
+ item_coord_rewind(it);
+ ccount=binfile_coord_left(it->priv_data);
+ if(ccount==1)
+ item_coord_get(it,&c,1);
+ else if(ccount==2) {
+ struct coord c2;
+ item_coord_get(it,&c,1);
+ item_coord_get(it,&c2,1);
+ c.x=(c.x+c2.x)/2;
+ c.y=(c.y+c2.y)/2;
+ } else {
+ if(ccount>3)
+ ccount/=2;
+ else
+ ccount=2;
+ while(--ccount>0)
+ item_coord_get(it,&c,1);
+ }
+ if(geom_poly_point_inside(p->first,count,&c))
+ return 1;
+ l=g_list_next(l);
+ }
+ return 0;
+}
+
+static struct item *binmap_search_get_item(struct map_search_priv *map_search) {
+ struct item* it;
+ struct attr at;
+ enum linguistics_cmp_mode mode=(map_search->partial?linguistics_cmp_partial:0);
+
+ for (;;) {
+ while ((it = map_rect_get_item_binfile(map_search->mr))) {
+ int has_house_number=0;
+ switch (map_search->search.type) {
+ case attr_town_postal:
+ case attr_town_name:
+ case attr_district_name:
+ case attr_town_or_district_name:
+ if (map_search->mr->tile_depth > 1 && item_is_town(*it) && map_search->search.type == attr_town_postal) {
+ if (binfile_attr_get(it->priv_data, attr_town_postal, &at)) {
+ if (!linguistics_compare(at.u.str, map_search->search.u.str, mode)) {
+ /* check for duplicate combination of town_name and town_postal */
+ if (!duplicate(map_search, it, attr_town_name, attr_town_postal)) {
+ return it;
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ if (map_search->mr->tile_depth > 1 && item_is_town(*it) && map_search->search.type != attr_district_name) {
+ if (binfile_attr_get(it->priv_data, attr_town_name_match, &at)
+ || binfile_attr_get(it->priv_data, attr_town_name, &at)) {
+ if (!linguistics_compare(at.u.str, map_search->search.u.str, mode) && !duplicate(map_search, it, attr_town_name,0))
+ return it;
+ }
+ }
+ if (map_search->mr->tile_depth > 1 && item_is_district(*it) && map_search->search.type != attr_town_name) {
+ if (binfile_attr_get(it->priv_data, attr_district_name_match, &at)
+ || binfile_attr_get(it->priv_data, attr_district_name, &at)) {
+ if (!linguistics_compare(at.u.str, map_search->search.u.str, mode) && !duplicate(map_search, it, attr_town_name,0))
+ return it;
+ }
+ }
+ break;
+ case attr_street_name:
+ if (map_search->mode == 1) {
+ if (binfile_attr_get(it->priv_data, attr_street_name_match, &at)
+ || binfile_attr_get(it->priv_data, attr_street_name, &at)) {
+ if (!linguistics_compare(at.u.str, map_search->search.u.str, mode) && !duplicate(map_search, it, attr_street_name,0)) {
+ return it;
+ }
+ }
+ continue;
+ }
+ if (item_is_street(*it)) {
+ struct attr at;
+ if (!map_selection_contains_item_rect(map_search->mr->sel, it))
+ break;
+
+ if(binfile_attr_get(it->priv_data, attr_label, &at)) {
+ struct coord c[128];
+ struct duplicate *d;
+
+ /* Extracting all coords here makes duplicate_new() not consider them (we don't want all
+ * street segments to be reported as separate streets). */
+ while(item_coord_get(it,c,128)>0);
+ d=duplicate_test(map_search, it, attr_label,0);
+ if(!d)
+ break;
+
+ if(linguistics_compare(at.u.str, map_search->search.u.str, mode|linguistics_cmp_expand|linguistics_cmp_words)) {
+ /* Remember this non-matching street name in duplicate hash to skip name
+ * comparison for its following segments */
+ duplicate_insert(map_search, d);
+ break;
+ }
+
+ if(map_search->boundaries && !item_inside_poly_list(it,map_search->boundaries)) {
+ /* Other segments may fit the town poly. Do not update hash for now. */
+ g_free(d);
+ break;
+ }
+
+ duplicate_insert(map_search, d);
+ item_coord_rewind(it);
+ return it;
+ }
+ }
+ break;
+ case attr_house_number:
+ has_house_number=binfile_attr_get(it->priv_data, attr_house_number, &at);
+ if ((has_house_number
+ || it->type == type_house_number_interpolation_even || it->type == type_house_number_interpolation_odd
+ || it->type == type_house_number_interpolation_all
+ || (map_search->mode == 1 && item_is_street(*it))|| it->type == type_house_number)
+ && !(map_search->boundaries && !item_inside_poly_list(it,map_search->boundaries))) {
+ if (has_house_number) {
+ struct attr at2;
+ if ((binfile_attr_get(it->priv_data, attr_street_name, &at2) || map_search->mode!=2)
+ && !linguistics_compare(at.u.str, map_search->search.u.str, mode)
+ && !strcmp(at2.u.str, map_search->parent_name)) {
+ if (!duplicate(map_search, it, attr_house_number,0)) {
+ binfile_attr_rewind(it->priv_data);
+ return it;
+ }
+ }
+ } else {
+ struct attr at2;
+ if ((binfile_attr_get(it->priv_data, attr_street_name, &at2) || map_search->mode!=2)
+ && !strcmp(at2.u.str, map_search->parent_name)) {
+ if (!duplicate(map_search, it, attr_house_number_interpolation_no_ends_incrmt_2,0)) {
+ binfile_attr_rewind(it->priv_data);
+ return it;
+ } else if (!duplicate(map_search, it, attr_house_number_interpolation_no_ends_incrmt_1,0)) {
+ binfile_attr_rewind(it->priv_data);
+ return it;
+ }
+ } else {
+ if (!( it->type == type_house_number_interpolation_even || it->type == type_house_number_interpolation_odd
+ || it->type == type_house_number_interpolation_all))
+ return it;
+ }
+
+ }
+ } else if( item_is_street(*it) && map_search->mode==2 && map_search->parent_name
+ && binfile_attr_get(it->priv_data, attr_street_name, &at) && !strcmp(at.u.str, map_search->parent_name) ) {
+ /* If matching street segment found, prepare to expand house number search region +100m around each way point */
+ if (!(map_search->boundaries && !item_inside_poly_list(it,map_search->boundaries))) {
+ struct coord c;
+ while(item_coord_get(it,&c,1)) {
+ c.x-=100;
+ c.y-=100;
+ coord_rect_extend(&map_search->rect_new,&c);
+ c.x+=200;
+ c.y+=200;
+ coord_rect_extend(&map_search->rect_new,&c);
+ }
+ }
+ }
+ continue;
+ default:
+ return NULL;
+ }
+ }
+ if(map_search->search.type==attr_house_number && map_search->mode==2 && map_search->parent_name) {
+ /* For unindexed house number search, check if street segments extending possible housenumber locations were found */
+ if(map_search->ms.u.c_rect.lu.x!=map_search->rect_new.lu.x || map_search->ms.u.c_rect.lu.y!=map_search->rect_new.lu.y ||
+ map_search->ms.u.c_rect.rl.x!=map_search->rect_new.rl.x || map_search->ms.u.c_rect.rl.y!=map_search->rect_new.rl.y) {
+ map_search->ms.u.c_rect=map_search->rect_new;
+ map_rect_destroy_binfile(map_search->mr);
+ map_search->mr=map_rect_new_binfile(map_search->map, &map_search->ms);
+ dbg(lvl_debug,"Extended house number search region to %d x %d, restarting...",
+ map_search->ms.u.c_rect.rl.x - map_search->ms.u.c_rect.lu.x, map_search->ms.u.c_rect.lu.y-map_search->ms.u.c_rect.rl.y);
+ continue;
+ }
+ }
+ if (!map_search->mr_item)
+ return NULL;
+ map_rect_destroy_binfile(map_search->mr);
+ if (!binmap_search_by_index(map_search->map, map_search->item, &map_search->mr))
+ return NULL;
+ }
+}
+
+
+static void binmap_search_destroy(struct map_search_priv *ms) {
+ if (ms->search_results)
+ g_hash_table_destroy(ms->search_results);
+ if(ATTR_IS_STRING(ms->search.type))
+ g_free(ms->search.u.str);
+ if(ms->parent_name)
+ g_free(ms->parent_name);
+ if (ms->mr_item)
+ map_rect_destroy_binfile(ms->mr_item);
+ if (ms->mr)
+ map_rect_destroy_binfile(ms->mr);
+ while(ms->boundaries) {
+ geom_poly_segment_destroy(ms->boundaries->data);
+ ms->boundaries=g_list_delete_link(ms->boundaries,ms->boundaries);
+ }
+ g_free(ms);
+}
+
+static int binmap_get_attr(struct map_priv *m, enum attr_type type, struct attr *attr) {
+ attr->type=type;
+ switch (type) {
+ case attr_map_release:
+ if (m->map_release) {
+ attr->u.str=m->map_release;
+ return 1;
+ }
+ break;
+ case attr_progress:
+ if (m->progress) {
+ attr->u.str=m->progress;
+ return 1;
+ }
+ default:
+ break;
+ }
+ return 0;
+}
+
+static int binmap_set_attr(struct map_priv *map, struct attr *attr) {
+ switch (attr->type) {
+ case attr_update:
+ map->download_enabled = attr->u.num;
+ return 1;
+ default:
+ return 0;
+ }
}
static struct map_methods map_methods_binfile = {
- projection_mg,
- "utf-8",
- map_destroy_binfile,
- map_rect_new_binfile,
- map_rect_destroy_binfile,
- map_rect_get_item_binfile,
- map_rect_get_item_byid_binfile,
- binmap_search_new,
- binmap_search_destroy,
- binmap_search_get_item,
- NULL,
- binmap_get_attr,
- binmap_set_attr,
+ projection_mg,
+ "utf-8",
+ map_destroy_binfile,
+ map_rect_new_binfile,
+ map_rect_destroy_binfile,
+ map_rect_get_item_binfile,
+ map_rect_get_item_byid_binfile,
+ binmap_search_new,
+ binmap_search_destroy,
+ binmap_search_get_item,
+ NULL,
+ binmap_get_attr,
+ binmap_set_attr,
};
-static int
-binfile_get_index(struct map_priv *m)
-{
- int len;
- int cde_index_size;
- int offset;
- struct zip_cd *cd;
-
- len = strlen("index");
- cde_index_size = sizeof(struct zip_cd)+len;
- if (m->eoc64)
- offset = m->eoc64->zip64ecsz-cde_index_size;
- else
- offset = m->eoc->zipecsz-cde_index_size;
- cd = binfile_read_cd(m, offset, len);
-
- if (!cd) {
- cde_index_size+=sizeof(struct zip_cd_ext);
- if (m->eoc64)
- offset = m->eoc64->zip64ecsz-cde_index_size;
- else
- offset = m->eoc->zipecsz-cde_index_size;
- cd = binfile_read_cd(m, offset, len+sizeof(struct zip_cd_ext));
- }
- if (cd) {
- if (cd->zipcfnl == len && !strncmp(cd->zipcfn, "index", len)) {
- m->index_offset=offset;
- m->index_cd=cd;
- return 1;
- }
- }
- offset=binfile_search_cd(m, 0, "index", 0, 0);
- if (offset == -1)
- return 0;
- cd=binfile_read_cd(m, offset, -1);
- if (!cd)
- return 0;
- m->index_offset=offset;
- m->index_cd=cd;
- return 1;
-}
-
-static int
-map_binfile_zip_setup(struct map_priv *m, char *filename, int mmap)
-{
- struct zip_cd *first_cd;
- int i;
- if (!(m->eoc=binfile_read_eoc(m->fi))) {
- dbg(lvl_error,"map file %s: unable to read eoc\n", filename);
- return 0;
- }
- dbg_assert(m->eoc->zipedsk == m->eoc->zipecen);
- if (m->eoc->zipedsk && strlen(filename) > 3) {
- char *tmpfilename=g_strdup(filename),*ext=tmpfilename+strlen(tmpfilename)-3;
- m->fis=g_new(struct file *,m->eoc->zipedsk);
- for (i = 0 ; i < m->eoc->zipedsk-1 ; i++) {
- sprintf(ext,"b%02d",i+1);
- m->fis[i]=file_create(tmpfilename, 0);
- if (mmap)
- file_mmap(m->fis[i]);
- }
- m->fis[m->eoc->zipedsk-1]=m->fi;
- g_free(tmpfilename);
- }
- dbg(lvl_debug,"num_disk %d\n",m->eoc->zipedsk);
- m->eoc64=binfile_read_eoc64(m->fi);
- if (!binfile_get_index(m)) {
- dbg(lvl_error,"map file %s: no index found\n", filename);
- return 0;
- }
- if (!(first_cd=binfile_read_cd(m, 0, 0))) {
- dbg(lvl_error,"map file %s: unable to get first cd\n", filename);
- return 0;
- }
- m->cde_size=sizeof(struct zip_cd)+first_cd->zipcfnl+first_cd->zipcxtl;
- m->zip_members=m->index_offset/m->cde_size+1;
- dbg(lvl_debug,"cde_size %d\n", m->cde_size);
- dbg(lvl_debug,"members %d\n",m->zip_members);
- file_data_free(m->fi, (unsigned char *)first_cd);
- if (mmap)
- file_mmap(m->fi);
- return 1;
+static int binfile_get_index(struct map_priv *m) {
+ int len;
+ int cde_index_size;
+ int offset;
+ struct zip_cd *cd;
+
+ len = strlen("index");
+ cde_index_size = sizeof(struct zip_cd)+len;
+ if (m->eoc64)
+ offset = m->eoc64->zip64ecsz-cde_index_size;
+ else
+ offset = m->eoc->zipecsz-cde_index_size;
+ cd = binfile_read_cd(m, offset, len);
+
+ if (!cd) {
+ cde_index_size+=sizeof(struct zip_cd_ext);
+ if (m->eoc64)
+ offset = m->eoc64->zip64ecsz-cde_index_size;
+ else
+ offset = m->eoc->zipecsz-cde_index_size;
+ cd = binfile_read_cd(m, offset, len+sizeof(struct zip_cd_ext));
+ }
+ if (cd) {
+ if (cd->zipcfnl == len && !strncmp(cd->zipcfn, "index", len)) {
+ m->index_offset=offset;
+ m->index_cd=cd;
+ return 1;
+ }
+ }
+ offset=binfile_search_cd(m, 0, "index", 0, 0);
+ if (offset == -1)
+ return 0;
+ cd=binfile_read_cd(m, offset, -1);
+ if (!cd)
+ return 0;
+ m->index_offset=offset;
+ m->index_cd=cd;
+ return 1;
+}
+
+static int map_binfile_zip_setup(struct map_priv *m, char *filename, int mmap) {
+ struct zip_cd *first_cd;
+ int i;
+ if (!(m->eoc=binfile_read_eoc(m->fi))) {
+ dbg(lvl_error,"map file %s: unable to read eoc", filename);
+ return 0;
+ }
+ dbg_assert(m->eoc->zipedsk == m->eoc->zipecen);
+ if (m->eoc->zipedsk && strlen(filename) > 3) {
+ char *tmpfilename=g_strdup(filename),*ext=tmpfilename+strlen(tmpfilename)-3;
+ m->fis=g_new(struct file *,m->eoc->zipedsk);
+ for (i = 0 ; i < m->eoc->zipedsk-1 ; i++) {
+ sprintf(ext,"b%02d",i+1);
+ m->fis[i]=file_create(tmpfilename, 0);
+ if (mmap)
+ file_mmap(m->fis[i]);
+ }
+ m->fis[m->eoc->zipedsk-1]=m->fi;
+ g_free(tmpfilename);
+ }
+ dbg(lvl_debug,"num_disk %d",m->eoc->zipedsk);
+ m->eoc64=binfile_read_eoc64(m->fi);
+ if (!binfile_get_index(m)) {
+ dbg(lvl_error,"map file %s: no index found", filename);
+ return 0;
+ }
+ if (!(first_cd=binfile_read_cd(m, 0, 0))) {
+ dbg(lvl_error,"map file %s: unable to get first cd", filename);
+ return 0;
+ }
+ m->cde_size=sizeof(struct zip_cd)+first_cd->zipcfnl+first_cd->zipcxtl;
+ m->zip_members=m->index_offset/m->cde_size+1;
+ dbg(lvl_debug,"cde_size %d", m->cde_size);
+ dbg(lvl_debug,"members %d",m->zip_members);
+ file_data_free(m->fi, (unsigned char *)first_cd);
+ if (mmap)
+ file_mmap(m->fi);
+ return 1;
}
#if 0
-static int
-map_binfile_download_initial(struct map_priv *m)
-{
- struct attr readwrite={attr_readwrite,{(void *)1}};
- struct attr create={attr_create,{(void *)1}};
- struct attr *attrs[4];
- struct file *out;
- long long woffset=0,planet_size;
- int size_ret;
- int cd1size,cdisize;
- long long cd1offset,cdioffset;
- struct zip64_eoc *zip64_eoc;
- struct zip64_eocl *zip64_eocl;
- struct zip_eoc *zip_eoc;
- struct zip_cd *cd1,*cdn,*cdi;
- int count,chunk,cdoffset=0;
- int mode=1;
- struct map_download *download=g_new0(struct map_download, 1);
-
- attrs[0]=&readwrite;
- attrs[1]=&create;
- attrs[2]=NULL;
- download->file=file_create(m->filename,attrs);
- download->m=m;
- download_planet_size(download);
- download_eoc(download);
- download_directory_start(download);
- while (download_directory_do(download));
- download_directory_finish(download);
- download_initial_finish(download);
- m->fi=download->file;
- g_free(download);
- return 1;
-
-
- cd1size=sizeof(*cd1);
- cd1offset=zip64_eoc->zip64eofst;
- cd1=(struct zip_cd *)map_binfile_download_range(m, cd1offset, cd1size);
- if (!cd1)
- return 0;
- cd1size=sizeof(*cd1)+binfile_cd_extra(cd1);
- g_free(cd1);
- cd1=(struct zip_cd *)map_binfile_download_range(m, cd1offset, cd1size);
- if (!cd1)
- return 0;
- cd1->zipcunc=0;
- cdisize=sizeof(*cdi)+strlen("index")+cd1->zipcxtl;
- cdioffset=zip64_eoc->zip64eofst+zip64_eoc->zip64ecsz-cdisize;
- cdi=(struct zip_cd *)map_binfile_download_range(m, cdioffset, cdisize);
- if (!cdi) {
- g_free(cd1);
- return 0;
- }
- cdi->zipcunc=0;
- cdn=g_malloc0(cd1size*256);
-
- file_data_write(out, woffset, sizeof(*zip64_eoc), (unsigned char *)zip64_eoc);
- woffset+=sizeof(*zip64_eoc);
- cdoffset=woffset;
-
- file_data_write(out, woffset, cd1size, (unsigned char *)cd1);
- woffset+=cd1size;
- count=(cdioffset-cd1offset)/cd1size-1;
- while (count > 0) {
- if (count > 256)
- chunk=256;
- else
- chunk=count;
- file_data_write(out, woffset, cd1size*chunk, (unsigned char *)cdn);
- woffset+=cd1size*chunk;
- count-=chunk;
- }
- g_free(cdn);
- g_free(cd1);
- file_data_write(out, woffset, cdisize, (unsigned char *)cdi);
- woffset+=cdisize;
+static int map_binfile_download_initial(struct map_priv *m) {
+ struct attr readwrite= {attr_readwrite,{(void *)1}};
+ struct attr create= {attr_create,{(void *)1}};
+ struct attr *attrs[4];
+ struct file *out;
+ long long woffset=0,planet_size;
+ int size_ret;
+ int cd1size,cdisize;
+ long long cd1offset,cdioffset;
+ struct zip64_eoc *zip64_eoc;
+ struct zip64_eocl *zip64_eocl;
+ struct zip_eoc *zip_eoc;
+ struct zip_cd *cd1,*cdn,*cdi;
+ int count,chunk,cdoffset=0;
+ int mode=1;
+ struct map_download *download=g_new0(struct map_download, 1);
+
+ attrs[0]=&readwrite;
+ attrs[1]=&create;
+ attrs[2]=NULL;
+ download->file=file_create(m->filename,attrs);
+ download->m=m;
+ download_planet_size(download);
+ download_eoc(download);
+ download_directory_start(download);
+ while (download_directory_do(download));
+ download_directory_finish(download);
+ download_initial_finish(download);
+ m->fi=download->file;
+ g_free(download);
+ return 1;
+
+
+ cd1size=sizeof(*cd1);
+ cd1offset=zip64_eoc->zip64eofst;
+ cd1=(struct zip_cd *)map_binfile_download_range(m, cd1offset, cd1size);
+ if (!cd1)
+ return 0;
+ cd1size=sizeof(*cd1)+binfile_cd_extra(cd1);
+ g_free(cd1);
+ cd1=(struct zip_cd *)map_binfile_download_range(m, cd1offset, cd1size);
+ if (!cd1)
+ return 0;
+ cd1->zipcunc=0;
+ cdisize=sizeof(*cdi)+strlen("index")+cd1->zipcxtl;
+ cdioffset=zip64_eoc->zip64eofst+zip64_eoc->zip64ecsz-cdisize;
+ cdi=(struct zip_cd *)map_binfile_download_range(m, cdioffset, cdisize);
+ if (!cdi) {
+ g_free(cd1);
+ return 0;
+ }
+ cdi->zipcunc=0;
+ cdn=g_malloc0(cd1size*256);
+
+ file_data_write(out, woffset, sizeof(*zip64_eoc), (unsigned char *)zip64_eoc);
+ woffset+=sizeof(*zip64_eoc);
+ cdoffset=woffset;
+
+ file_data_write(out, woffset, cd1size, (unsigned char *)cd1);
+ woffset+=cd1size;
+ count=(cdioffset-cd1offset)/cd1size-1;
+ while (count > 0) {
+ if (count > 256)
+ chunk=256;
+ else
+ chunk=count;
+ file_data_write(out, woffset, cd1size*chunk, (unsigned char *)cdn);
+ woffset+=cd1size*chunk;
+ count-=chunk;
+ }
+ g_free(cdn);
+ g_free(cd1);
+ file_data_write(out, woffset, cdisize, (unsigned char *)cdi);
+ woffset+=cdisize;
}
#endif
-static int
-map_binfile_open(struct map_priv *m)
-{
- int *magic;
- struct map_rect_priv *mr;
- struct item *item;
- struct attr attr;
- struct attr readwrite={attr_readwrite, {(void *)1}};
- struct attr *attrs[]={&readwrite, NULL};
-
- dbg(lvl_debug,"file_create %s\n", m->filename);
- m->fi=file_create(m->filename, m->url?attrs:NULL);
- if (! m->fi && m->url)
- return 0;
- if (! m->fi) {
- dbg(lvl_error,"Failed to load '%s'\n", m->filename);
- return 0;
- }
- if (m->check_version)
- m->version=file_version(m->fi, m->check_version);
- magic=(int *)file_data_read(m->fi, 0, 4);
- if (!magic) {
- file_destroy(m->fi);
- m->fi=NULL;
- return 0;
- }
- *magic = le32_to_cpu(*magic);
- if (*magic == zip_lfh_sig || *magic == zip_split_sig || *magic == zip_cd_sig || *magic == zip64_eoc_sig) {
- if (!map_binfile_zip_setup(m, m->filename, m->flags & 1)) {
- dbg(lvl_error,"invalid file format for '%s'\n", m->filename);
- file_destroy(m->fi);
- m->fi=NULL;
- return 0;
- }
- } else if (*magic == zip_lfh_sig_rev || *magic == zip_split_sig_rev || *magic == zip_cd_sig_rev || *magic == zip64_eoc_sig_rev) {
- dbg(lvl_error,"endianness mismatch for '%s'\n", m->filename);
- file_destroy(m->fi);
- m->fi=NULL;
- return 0;
- } else
- file_mmap(m->fi);
- file_data_free(m->fi, (unsigned char *)magic);
- m->cachedir=g_strdup("/tmp/navit");
- m->map_version=0;
- mr=map_rect_new_binfile(m, NULL);
- if (mr) {
- while ((item=map_rect_get_item_binfile(mr)) == &busy_item);
- if (item && item->type == type_map_information) {
- if (binfile_attr_get(item->priv_data, attr_version, &attr))
- m->map_version=attr.u.num;
- if (binfile_attr_get(item->priv_data, attr_map_release, &attr))
- m->map_release=g_strdup(attr.u.str);
- if (m->url && binfile_attr_get(item->priv_data, attr_url, &attr)) {
- dbg(lvl_debug,"url config %s map %s\n",m->url,attr.u.str);
- if (strcmp(m->url, attr.u.str))
- m->update_available=1;
- g_free(m->url);
- m->url=g_strdup(attr.u.str);
- }
- }
- map_rect_destroy_binfile(mr);
- if (m->map_version >= 16) {
- dbg(lvl_error,"%s: This map is incompatible with your navit version. Please update navit. (map version %d)\n",
- m->filename, m->map_version);
- return 0;
- }
- }
- return 1;
-}
-
-static void
-map_binfile_close(struct map_priv *m)
-{
- int i;
- file_data_free(m->fi, (unsigned char *)m->index_cd);
- file_data_free(m->fi, (unsigned char *)m->eoc);
- file_data_free(m->fi, (unsigned char *)m->eoc64);
- g_free(m->cachedir);
- g_free(m->map_release);
- if (m->fis) {
- for (i = 0 ; i < m->eoc->zipedsk ; i++) {
- file_destroy(m->fis[i]);
- }
- } else
- file_destroy(m->fi);
-}
-
-static void
-map_binfile_destroy(struct map_priv *m)
-{
- g_free(m->filename);
- g_free(m->url);
- g_free(m->progress);
- g_free(m);
-}
-
-
-static void
-binfile_check_version(struct map_priv *m)
-{
- int version=-1;
- if (!m->check_version)
- return;
- if (m->fi)
- version=file_version(m->fi, m->check_version);
- if (version != m->version) {
- if (m->fi)
- map_binfile_close(m);
- map_binfile_open(m);
- }
-}
-
-
-static struct map_priv *
-map_new_binfile(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct map_priv *m;
- struct attr *data=attr_search(attrs, NULL, attr_data);
- struct attr *check_version,*flags,*url,*download_enabled;
- struct file_wordexp *wexp;
- char **wexp_data;
- if (! data)
- return NULL;
-
- wexp=file_wordexp_new(data->u.str);
- wexp_data=file_wordexp_get_array(wexp);
- dbg(lvl_debug,"map_new_binfile %s\n", data->u.str);
- *meth=map_methods_binfile;
-
- m=g_new0(struct map_priv, 1);
- m->cbl=cbl;
- m->id=++map_id;
- m->filename=g_strdup(wexp_data[0]);
- file_wordexp_destroy(wexp);
- check_version=attr_search(attrs, NULL, attr_check_version);
- if (check_version)
- m->check_version=check_version->u.num;
- flags=attr_search(attrs, NULL, attr_flags);
- if (flags)
- m->flags=flags->u.num;
- url=attr_search(attrs, NULL, attr_url);
- if (url)
- m->url=g_strdup(url->u.str);
- download_enabled = attr_search(attrs, NULL, attr_update);
- if (download_enabled)
- m->download_enabled=download_enabled->u.num;
-
- if (!map_binfile_open(m) && !m->check_version && !m->url) {
- map_binfile_destroy(m);
- m=NULL;
- } else {
- load_changes(m);
- }
- return m;
-}
-
-void
-plugin_init(void)
-{
- dbg(lvl_debug,"binfile: plugin_init\n");
- if (sizeof(struct zip_cd) != 46) {
- dbg(lvl_error,"error: sizeof(struct zip_cd)=%zu\n",sizeof(struct zip_cd));
- }
- plugin_register_category_map("binfile", map_new_binfile);
+static int map_binfile_open(struct map_priv *m) {
+ int *magic;
+ struct map_rect_priv *mr;
+ struct item *item;
+ struct attr attr;
+ struct attr readwrite= {attr_readwrite, {(void *)1}};
+ struct attr *attrs[]= {&readwrite, NULL};
+
+ dbg(lvl_debug,"file_create %s", m->filename);
+ m->fi=file_create(m->filename, m->url?attrs:NULL);
+ if (! m->fi && m->url)
+ return 0;
+ if (! m->fi) {
+ dbg(lvl_error,"Failed to load '%s'", m->filename);
+ return 0;
+ }
+ if (m->check_version)
+ m->version=file_version(m->fi, m->check_version);
+ magic=(int *)file_data_read(m->fi, 0, 4);
+ if (!magic) {
+ file_destroy(m->fi);
+ m->fi=NULL;
+ return 0;
+ }
+ *magic = le32_to_cpu(*magic);
+ if (*magic == zip_lfh_sig || *magic == zip_split_sig || *magic == zip_cd_sig || *magic == zip64_eoc_sig) {
+ if (!map_binfile_zip_setup(m, m->filename, m->flags & 1)) {
+ dbg(lvl_error,"invalid file format for '%s'", m->filename);
+ file_destroy(m->fi);
+ m->fi=NULL;
+ return 0;
+ }
+ } else if (*magic == zip_lfh_sig_rev || *magic == zip_split_sig_rev || *magic == zip_cd_sig_rev
+ || *magic == zip64_eoc_sig_rev) {
+ dbg(lvl_error,"endianness mismatch for '%s'", m->filename);
+ file_destroy(m->fi);
+ m->fi=NULL;
+ return 0;
+ } else
+ file_mmap(m->fi);
+ file_data_free(m->fi, (unsigned char *)magic);
+ m->cachedir=g_strdup("/tmp/navit");
+ m->map_version=0;
+ mr=map_rect_new_binfile(m, NULL);
+ if (mr) {
+ while ((item=map_rect_get_item_binfile(mr)) == &busy_item);
+ if (item && item->type == type_map_information) {
+ if (binfile_attr_get(item->priv_data, attr_version, &attr))
+ m->map_version=attr.u.num;
+ if (binfile_attr_get(item->priv_data, attr_map_release, &attr))
+ m->map_release=g_strdup(attr.u.str);
+ if (m->url && binfile_attr_get(item->priv_data, attr_url, &attr)) {
+ dbg(lvl_debug,"url config %s map %s",m->url,attr.u.str);
+ if (strcmp(m->url, attr.u.str))
+ m->update_available=1;
+ g_free(m->url);
+ m->url=g_strdup(attr.u.str);
+ }
+ }
+ map_rect_destroy_binfile(mr);
+ if (m->map_version >= 16) {
+ dbg(lvl_error,"%s: This map is incompatible with your navit version. Please update navit. (map version %d)",
+ m->filename, m->map_version);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static void map_binfile_close(struct map_priv *m) {
+ int i;
+ file_data_free(m->fi, (unsigned char *)m->index_cd);
+ file_data_free(m->fi, (unsigned char *)m->eoc);
+ file_data_free(m->fi, (unsigned char *)m->eoc64);
+ g_free(m->cachedir);
+ g_free(m->map_release);
+ if (m->fis) {
+ for (i = 0 ; i < m->eoc->zipedsk ; i++) {
+ file_destroy(m->fis[i]);
+ }
+ } else
+ file_destroy(m->fi);
+}
+
+static void map_binfile_destroy(struct map_priv *m) {
+ g_free(m->filename);
+ g_free(m->url);
+ g_free(m->progress);
+ g_free(m);
+}
+
+
+static void binfile_check_version(struct map_priv *m) {
+ int version=-1;
+ if (!m->check_version)
+ return;
+ if (m->fi)
+ version=file_version(m->fi, m->check_version);
+ if (version != m->version) {
+ if (m->fi)
+ map_binfile_close(m);
+ map_binfile_open(m);
+ }
+}
+
+
+static struct map_priv *map_new_binfile(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *m;
+ struct attr *data=attr_search(attrs, NULL, attr_data);
+ struct attr *check_version,*flags,*url,*download_enabled;
+ struct file_wordexp *wexp;
+ char **wexp_data;
+ if (! data)
+ return NULL;
+
+ wexp=file_wordexp_new(data->u.str);
+ wexp_data=file_wordexp_get_array(wexp);
+ dbg(lvl_debug,"map_new_binfile %s", data->u.str);
+ *meth=map_methods_binfile;
+
+ m=g_new0(struct map_priv, 1);
+ m->cbl=cbl;
+ m->id=++map_id;
+ m->filename=g_strdup(wexp_data[0]);
+ file_wordexp_destroy(wexp);
+ check_version=attr_search(attrs, NULL, attr_check_version);
+ if (check_version)
+ m->check_version=check_version->u.num;
+ flags=attr_search(attrs, NULL, attr_flags);
+ if (flags)
+ m->flags=flags->u.num;
+ url=attr_search(attrs, NULL, attr_url);
+ if (url)
+ m->url=g_strdup(url->u.str);
+ download_enabled = attr_search(attrs, NULL, attr_update);
+ if (download_enabled)
+ m->download_enabled=download_enabled->u.num;
+
+ if (!map_binfile_open(m) && !m->check_version && !m->url) {
+ map_binfile_destroy(m);
+ m=NULL;
+ } else {
+ load_changes(m);
+ }
+ return m;
+}
+
+void plugin_init(void) {
+ dbg(lvl_debug,"binfile: plugin_init");
+ if (sizeof(struct zip_cd) != 46) {
+ dbg(lvl_error,"error: sizeof(struct zip_cd)=%zu",sizeof(struct zip_cd));
+ }
+ plugin_register_category_map("binfile", map_new_binfile);
}
diff --git a/navit/map/csv/csv.c b/navit/map/csv/csv.c
index 2726e8ab9..e463985b0 100644
--- a/navit/map/csv/csv.c
+++ b/navit/map/csv/csv.c
@@ -45,841 +45,791 @@
static int map_id;
/*prototypes*/
-static int
-csv_coord_set(void *priv_data, struct coord *c, int count, enum change_mode mode);
+static int csv_coord_set(void *priv_data, struct coord *c, int count, enum change_mode mode);
static struct item * csv_create_item(struct map_rect_priv *mr, enum item_type it_type);
static void quadtree_item_free(void *mr, struct quadtree_item *qitem);
static void quadtree_item_free_do(void *qitem);
-struct quadtree_data
-{
- enum item_type type;
- int id_lo;
- GList* attr_list;
- struct item *item;
+struct quadtree_data {
+ enum item_type type;
+ int id_lo;
+ GList* attr_list;
+ struct item *item;
};
-struct quadtree_data *quadtree_data_dup(struct quadtree_data *qdata)
-{
- struct quadtree_data *ret=g_new0(struct quadtree_data,1);
- GList *l;
- ret->type=qdata->type;
- ret->id_lo=qdata->id_lo;
- ret->item=g_new(struct item,1);
- *(ret->item)=*(qdata->item);
- for(l=qdata->attr_list;l;l=g_list_next(l)) {
- ret->attr_list=g_list_prepend(ret->attr_list,attr_dup(l->data));
- }
- return ret;
+struct quadtree_data *quadtree_data_dup(struct quadtree_data *qdata) {
+ struct quadtree_data *ret=g_new0(struct quadtree_data,1);
+ GList *l;
+ ret->type=qdata->type;
+ ret->id_lo=qdata->id_lo;
+ ret->item=g_new(struct item,1);
+ *(ret->item)=*(qdata->item);
+ for(l=qdata->attr_list; l; l=g_list_next(l)) {
+ ret->attr_list=g_list_prepend(ret->attr_list,attr_dup(l->data));
+ }
+ return ret;
}
-static void
-save_map_csv(struct map_priv *m)
-{
- if(m->filename && m->dirty) {
- char* filename = g_strdup_printf("%s.tmp",m->filename);
- FILE* fp;
- int ferr = 0;
- char *csv_line = 0;
- char *tmpstr = 0;
- char *oldstr = 0;
- struct quadtree_iter *iter;
- struct quadtree_item *qitem;
-
- if( ! (fp=fopen(filename,"w+"))) {
- dbg(lvl_error, "Error opening csv file to write new entries");
- return;
- }
- /*query the world*/
- iter=quadtree_query(m->tree_root, -180, 180, -180, 180, quadtree_item_free, m);
-
- while((qitem = quadtree_item_next(iter))!=NULL) {
- int i;
- enum attr_type *at = m->attr_types;
- if(qitem->deleted)
- continue;
- csv_line = NULL;
- tmpstr = NULL;
- for(i=0;i<m->attr_cnt;++i) {
- if(*at == attr_position_latitude) {
- tmpstr = g_strdup_printf("%lf",qitem->latitude);
- } else if(*at == attr_position_longitude) {
- tmpstr = g_strdup_printf("%lf",qitem->longitude);
- } else {
- GList* attr_list = ((struct quadtree_data*)(qitem->data))->attr_list;
- GList* attr_it = attr_list;
- struct attr* found_attr = NULL;
- /*search attributes*/
- while(attr_it) {
- if(((struct attr*)(attr_it->data))->type == *at) {
- found_attr = attr_it->data;
- break;
- }
- attr_it = g_list_next(attr_it);
- }
- if(found_attr) {
- if(ATTR_IS_INT(*at)) {
- tmpstr = g_strdup_printf("%d", (int)found_attr->u.num);
- } else if(ATTR_IS_DOUBLE(*at)) {
- tmpstr = g_strdup_printf("%lf", *found_attr->u.numd);
- } else if(ATTR_IS_STRING(*at)) {
- tmpstr = g_strdup(found_attr->u.str);
- } else {
- dbg(lvl_error,"Cant represent attribute %s\n",attr_to_name(*at));
- tmpstr=g_strdup("");
- }
- } else {
- dbg(lvl_debug,"No value defined for the atribute %s, assuming empty string\n",attr_to_name(*at));
- tmpstr=g_strdup("");
- }
- }
- if(i>0) {
- oldstr = csv_line;
- csv_line = g_strdup_printf("%s,%s",csv_line,tmpstr);
- g_free(tmpstr);
- g_free(oldstr);
- tmpstr = NULL;
- } else {
- csv_line=tmpstr;
- }
- ++at;
- }
-
- if(m->charset) {
- tmpstr=g_convert(csv_line, -1,m->charset,"utf-8",NULL,NULL,NULL);
- if(!tmpstr)
- dbg(lvl_error,"Error converting '%s' to %s\n",csv_line, m->charset);
- } else
- tmpstr=csv_line;
-
- if(tmpstr && fprintf(fp,"%s\n", tmpstr)<0) {
- ferr = 1;
- }
- g_free(csv_line);
- if(m->charset)
- g_free(tmpstr);
- }
-
- if(fclose(fp)) {
- ferr = 1;
- }
-
- if(! ferr) {
- unlink(m->filename);
- rename(filename,m->filename);
- m->dirty = 0;
- }
- g_free(filename);
- quadtree_query_free(iter);
-
- }
+static void save_map_csv(struct map_priv *m) {
+ if(m->filename && m->dirty) {
+ char* filename = g_strdup_printf("%s.tmp",m->filename);
+ FILE* fp;
+ int ferr = 0;
+ char *csv_line = 0;
+ char *tmpstr = 0;
+ char *oldstr = 0;
+ struct quadtree_iter *iter;
+ struct quadtree_item *qitem;
+
+ if( ! (fp=fopen(filename,"w+"))) {
+ dbg(lvl_error, "Error opening csv file to write new entries");
+ return;
+ }
+ /*query the world*/
+ iter=quadtree_query(m->tree_root, -180, 180, -180, 180, quadtree_item_free, m);
+
+ while((qitem = quadtree_item_next(iter))!=NULL) {
+ int i;
+ enum attr_type *at = m->attr_types;
+ if(qitem->deleted)
+ continue;
+ csv_line = NULL;
+ tmpstr = NULL;
+ for(i=0; i<m->attr_cnt; ++i) {
+ if(*at == attr_position_latitude) {
+ tmpstr = g_strdup_printf("%lf",qitem->latitude);
+ } else if(*at == attr_position_longitude) {
+ tmpstr = g_strdup_printf("%lf",qitem->longitude);
+ } else {
+ GList* attr_list = ((struct quadtree_data*)(qitem->data))->attr_list;
+ GList* attr_it = attr_list;
+ struct attr* found_attr = NULL;
+ /*search attributes*/
+ while(attr_it) {
+ if(((struct attr*)(attr_it->data))->type == *at) {
+ found_attr = attr_it->data;
+ break;
+ }
+ attr_it = g_list_next(attr_it);
+ }
+ if(found_attr) {
+ if(ATTR_IS_INT(*at)) {
+ tmpstr = g_strdup_printf("%d", (int)found_attr->u.num);
+ } else if(ATTR_IS_DOUBLE(*at)) {
+ tmpstr = g_strdup_printf("%lf", *found_attr->u.numd);
+ } else if(ATTR_IS_STRING(*at)) {
+ tmpstr = g_strdup(found_attr->u.str);
+ } else {
+ dbg(lvl_error,"Cant represent attribute %s",attr_to_name(*at));
+ tmpstr=g_strdup("");
+ }
+ } else {
+ dbg(lvl_debug,"No value defined for the attribute %s, assuming empty string",attr_to_name(*at));
+ tmpstr=g_strdup("");
+ }
+ }
+ if(i>0) {
+ oldstr = csv_line;
+ csv_line = g_strdup_printf("%s,%s",csv_line,tmpstr);
+ g_free(tmpstr);
+ g_free(oldstr);
+ tmpstr = NULL;
+ } else {
+ csv_line=tmpstr;
+ }
+ ++at;
+ }
+
+ if(m->charset) {
+ tmpstr=g_convert(csv_line, -1,m->charset,"utf-8",NULL,NULL,NULL);
+ if(!tmpstr)
+ dbg(lvl_error,"Error converting '%s' to %s",csv_line, m->charset);
+ } else
+ tmpstr=csv_line;
+
+ if(tmpstr && fprintf(fp,"%s\n", tmpstr)<0) {
+ ferr = 1;
+ }
+ g_free(csv_line);
+ if(m->charset)
+ g_free(tmpstr);
+ }
+
+ if(fclose(fp)) {
+ ferr = 1;
+ }
+
+ if(! ferr) {
+ unlink(m->filename);
+ rename(filename,m->filename);
+ m->dirty = 0;
+ }
+ g_free(filename);
+ quadtree_query_free(iter);
+
+ }
}
static const int zoom_max = 18;
-static void
-map_destroy_csv(struct map_priv *m)
-{
- dbg(lvl_debug,"map_destroy_csv\n");
- /*save if changed */
- save_map_csv(m);
- g_hash_table_destroy(m->qitem_hash);
- quadtree_destroy(m->tree_root);
- g_free(m->filename);
- g_free(m->charset);
- g_free(m->attr_types);
- g_free(m);
+static void map_destroy_csv(struct map_priv *m) {
+ dbg(lvl_debug,"map_destroy_csv");
+ /*save if changed */
+ save_map_csv(m);
+ g_hash_table_destroy(m->qitem_hash);
+ quadtree_destroy(m->tree_root);
+ g_free(m->filename);
+ g_free(m->charset);
+ g_free(m->attr_types);
+ g_free(m);
}
-static void
-csv_coord_rewind(void *priv_data)
-{
+static void csv_coord_rewind(void *priv_data) {
}
-static int
-csv_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr=priv_data;
- if(mr) {
- *c = mr->c;
- return 1;
- }
- else {
- return 0;
- }
+static int csv_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr=priv_data;
+ if(mr) {
+ *c = mr->c;
+ return 1;
+ } else {
+ return 0;
+ }
}
-static void
-csv_attr_rewind(void *priv_data)
-{
- /*TODO implement if needed*/
+static void csv_attr_rewind(void *priv_data) {
+ /*TODO implement if needed*/
}
-static int
-csv_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- int i, bAttrFound = 0;
- GList* attr_list;
- struct map_rect_priv *mr=priv_data;
- enum attr_type *at;
- if( !mr || !mr->m || !mr->m->attr_types ) {
- return 0;
- }
-
- attr_list = ((struct quadtree_data*)(mr->qitem->data))->attr_list;
-
- if (attr_type == attr_any) {
- if (mr->at_iter==NULL) { /*start iteration*/
- mr->at_iter = attr_list;
- if (mr->at_iter) {
- *attr = *(struct attr*)(mr->at_iter->data);
- return 1;
- } else { /*empty attr list*/
- mr->at_iter = NULL;
- return 0;
- }
- } else { /*continue iteration*/
- mr->at_iter = g_list_next(mr->at_iter);
- if(mr->at_iter) {
- *attr = *(struct attr*)mr->at_iter->data;
- return 1;
- } else {
- return 0;
- }
- }
- return 0;
- }
-
- at = mr->m->attr_types;
-
- for(i=0;i<mr->m->attr_cnt;++i) {
- if(*at == attr_type) {
- bAttrFound = 1;
- break;
- }
- ++at;
- }
-
- if(!bAttrFound) {
- return 0;
- }
-
- while(attr_list) {
- if(((struct attr*)attr_list->data)->type == attr_type) {
- *attr = *(struct attr*)attr_list->data;
- return 1;
- }
- attr_list = g_list_next(attr_list);
- }
- return 0;
+static int csv_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ int i, bAttrFound = 0;
+ GList* attr_list;
+ struct map_rect_priv *mr=priv_data;
+ enum attr_type *at;
+ if( !mr || !mr->m || !mr->m->attr_types ) {
+ return 0;
+ }
+
+ attr_list = ((struct quadtree_data*)(mr->qitem->data))->attr_list;
+
+ if (attr_type == attr_any) {
+ if (mr->at_iter==NULL) { /*start iteration*/
+ mr->at_iter = attr_list;
+ if (mr->at_iter) {
+ *attr = *(struct attr*)(mr->at_iter->data);
+ return 1;
+ } else { /*empty attr list*/
+ mr->at_iter = NULL;
+ return 0;
+ }
+ } else { /*continue iteration*/
+ mr->at_iter = g_list_next(mr->at_iter);
+ if(mr->at_iter) {
+ *attr = *(struct attr*)mr->at_iter->data;
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ return 0;
+ }
+
+ at = mr->m->attr_types;
+
+ for(i=0; i<mr->m->attr_cnt; ++i) {
+ if(*at == attr_type) {
+ bAttrFound = 1;
+ break;
+ }
+ ++at;
+ }
+
+ if(!bAttrFound) {
+ return 0;
+ }
+
+ while(attr_list) {
+ if(((struct attr*)attr_list->data)->type == attr_type) {
+ *attr = *(struct attr*)attr_list->data;
+ return 1;
+ }
+ attr_list = g_list_next(attr_list);
+ }
+ return 0;
}
-static int
-csv_attr_set(void *priv_data, struct attr *attr, enum change_mode mode)
-{
- struct map_rect_priv* mr;
- struct map_priv* m;
- int i, bFound;
- struct attr *attr_new;
- GList *attr_list, *curr_attr_list;
- enum attr_type *at;
-
- mr = (struct map_rect_priv*)priv_data;
- if(!mr || !mr->qitem) {
- return 0;
- }
-
- m = mr->m;
- bFound = 0;
- at = m->attr_types;
-
- /*if attribute is not supported by this csv map return 0*/
- for(i=0;i<m->attr_cnt;++i) {
- if(*at==attr->type) {
- bFound = 1;
- break;
- }
- ++at;
- }
- if( ! bFound) {
- return 0;
- }
- m->dirty = 1;
- attr_new = attr_dup(attr);
- attr_list = ((struct quadtree_data*)(mr->qitem->data))->attr_list;
- curr_attr_list = attr_list;
-
- while(attr_list) {
- if(((struct attr*)attr_list->data)->type == attr->type) {
- switch(mode) {
- case change_mode_delete:
- attr_free((struct attr*)attr_list->data);
- curr_attr_list = g_list_delete_link(curr_attr_list,attr_list);
- m->dirty = 1;
- /* FIXME: To preserve consistency, may be the save_map_csv should be called here... */
- attr_free(attr_new);
- return 1;
- case change_mode_modify:
- case change_mode_prepend:
- case change_mode_append:
- /* replace existing attribute */
- if(attr_list->data) {
- attr_free((struct attr*)attr_list->data);
- }
- attr_list->data = attr_new;
- m->dirty = 1;
- save_map_csv(m);
- return 1;
- default:
- attr_free(attr_new);
- return 0;
- }
- }
- attr_list = g_list_next(attr_list);
- }
-
- if( mode==change_mode_modify || mode==change_mode_prepend || mode==change_mode_append) {
- /* add new attribute */
- curr_attr_list = g_list_prepend(curr_attr_list, attr_new);
- ((struct quadtree_data*)(mr->qitem->data))->attr_list = curr_attr_list;
- m->dirty = 1;
- save_map_csv(m);
- return 1;
- }
- attr_free(attr_new);
- return 0;
+static int csv_attr_set(void *priv_data, struct attr *attr, enum change_mode mode) {
+ struct map_rect_priv* mr;
+ struct map_priv* m;
+ int i, bFound;
+ struct attr *attr_new;
+ GList *attr_list, *curr_attr_list;
+ enum attr_type *at;
+
+ mr = (struct map_rect_priv*)priv_data;
+ if(!mr || !mr->qitem) {
+ return 0;
+ }
+
+ m = mr->m;
+ bFound = 0;
+ at = m->attr_types;
+
+ /*if attribute is not supported by this csv map return 0*/
+ for(i=0; i<m->attr_cnt; ++i) {
+ if(*at==attr->type) {
+ bFound = 1;
+ break;
+ }
+ ++at;
+ }
+ if( ! bFound) {
+ return 0;
+ }
+ m->dirty = 1;
+ attr_new = attr_dup(attr);
+ attr_list = ((struct quadtree_data*)(mr->qitem->data))->attr_list;
+ curr_attr_list = attr_list;
+
+ while(attr_list) {
+ if(((struct attr*)attr_list->data)->type == attr->type) {
+ switch(mode) {
+ case change_mode_delete:
+ attr_free((struct attr*)attr_list->data);
+ curr_attr_list = g_list_delete_link(curr_attr_list,attr_list);
+ m->dirty = 1;
+ /* FIXME: To preserve consistency, may be the save_map_csv should be called here... */
+ attr_free(attr_new);
+ return 1;
+ case change_mode_modify:
+ case change_mode_prepend:
+ case change_mode_append:
+ /* replace existing attribute */
+ if(attr_list->data) {
+ attr_free((struct attr*)attr_list->data);
+ }
+ attr_list->data = attr_new;
+ m->dirty = 1;
+ save_map_csv(m);
+ return 1;
+ default:
+ attr_free(attr_new);
+ return 0;
+ }
+ }
+ attr_list = g_list_next(attr_list);
+ }
+
+ if( mode==change_mode_modify || mode==change_mode_prepend || mode==change_mode_append) {
+ /* add new attribute */
+ curr_attr_list = g_list_prepend(curr_attr_list, attr_new);
+ ((struct quadtree_data*)(mr->qitem->data))->attr_list = curr_attr_list;
+ m->dirty = 1;
+ save_map_csv(m);
+ return 1;
+ }
+ attr_free(attr_new);
+ return 0;
}
-static int
-csv_type_set(void *priv_data, enum item_type type)
-{
- struct map_rect_priv* mr = (struct map_rect_priv*)priv_data;
- dbg(lvl_debug,"Enter %d\n", type);
+static int csv_type_set(void *priv_data, enum item_type type) {
+ struct map_rect_priv* mr = (struct map_rect_priv*)priv_data;
+ dbg(lvl_debug,"Enter %d", type);
- if(!mr || !mr->qitem) {
- dbg(lvl_debug,"Nothing to do\n");
- return 0;
- }
+ if(!mr || !mr->qitem) {
+ dbg(lvl_debug,"Nothing to do");
+ return 0;
+ }
- if(type!=type_none)
- return 0;
+ if(type!=type_none)
+ return 0;
- mr->qitem->deleted=1;
- dbg(lvl_debug,"Item %p is deleted\n",mr->qitem);
+ mr->qitem->deleted=1;
+ dbg(lvl_debug,"Item %p is deleted",mr->qitem);
- return 1;
+ return 1;
}
static struct item_methods methods_csv = {
- csv_coord_rewind,
- csv_coord_get,
- csv_attr_rewind,
- csv_attr_get,
- NULL,
- csv_attr_set,
- csv_coord_set,
- csv_type_set
+ csv_coord_rewind,
+ csv_coord_get,
+ csv_attr_rewind,
+ csv_attr_get,
+ NULL,
+ csv_attr_set,
+ csv_coord_set,
+ csv_type_set
};
/*
* Sets coordinate of an existing item (either on the new list or an item with coord )
*/
-static int
-csv_coord_set(void *priv_data, struct coord *c, int count, enum change_mode mode)
-{
- struct quadtree_item query_item, *insert_item, *query_res;
- struct coord_geo cg;
- struct map_rect_priv* mr;
- struct map_priv* m;
- struct quadtree_item* qi;
- GList* new_it;
- dbg(lvl_debug,"Set coordinates %d %d\n", c->x, c->y);
-
- /* for now we only support coord modification only */
- if( ! change_mode_modify) {
- return 0;
- }
- /* csv driver supports one coord per record only */
- if( count != 1) {
- return 0;
- }
-
- /* get curr_item of given map_rect */
- mr = (struct map_rect_priv*)priv_data;
- m = mr->m;
-
- if(!mr->qitem) {
- return 0;
- }
-
- qi = mr->qitem;
-
- transform_to_geo(projection_mg, &c[0], &cg);
-
- /* if it is on the new list remove from new list and add it to the tree with the coord */
- new_it = m->new_items;
- while(new_it) {
- if(new_it->data==qi) {
- break;
- }
- new_it = g_list_next(new_it);
- }
- if(new_it) {
- qi->longitude = cg.lng;
- qi->latitude = cg.lat;
- quadtree_add( m->tree_root, qi, mr->qiter);
- dbg(lvl_debug,"Set coordinates %f %f\n", cg.lng, cg.lat);
- m->new_items = g_list_remove_link(m->new_items,new_it);
- m->dirty=1;
- save_map_csv(m);
- return 1;
- }
-
- /* else update quadtree item with the new coord
- remove item from the quadtree */
- query_item.longitude = cg.lng;
- query_item.latitude = cg.lat;
- query_res = quadtree_find_item(m->tree_root, &query_item);
- if(!query_res) {
- return 0;
- }
- quadtree_delete_item(m->tree_root, query_res);
- /* add item to the tree with the new coord */
- insert_item=g_new0(struct quadtree_item,1);
- insert_item->data=quadtree_data_dup(query_res->data);
- insert_item->longitude = cg.lng;
- insert_item->latitude = cg.lat;
- quadtree_add(m->tree_root, query_res, mr->qiter);
-
- mr->qitem->ref_count--;
- mr->qitem=insert_item;
- mr->qitem->ref_count++;
-
- m->dirty = 1;
- save_map_csv(m);
- return 1;
+static int csv_coord_set(void *priv_data, struct coord *c, int count, enum change_mode mode) {
+ struct quadtree_item query_item, *insert_item, *query_res;
+ struct coord_geo cg;
+ struct map_rect_priv* mr;
+ struct map_priv* m;
+ struct quadtree_item* qi;
+ GList* new_it;
+ dbg(lvl_debug,"Set coordinates %d %d", c->x, c->y);
+
+ /* for now we only support coord modification only */
+ if( ! change_mode_modify) {
+ return 0;
+ }
+ /* csv driver supports one coord per record only */
+ if( count != 1) {
+ return 0;
+ }
+
+ /* get curr_item of given map_rect */
+ mr = (struct map_rect_priv*)priv_data;
+ m = mr->m;
+
+ if(!mr->qitem) {
+ return 0;
+ }
+
+ qi = mr->qitem;
+
+ transform_to_geo(projection_mg, &c[0], &cg);
+
+ /* if it is on the new list remove from new list and add it to the tree with the coord */
+ new_it = m->new_items;
+ while(new_it) {
+ if(new_it->data==qi) {
+ break;
+ }
+ new_it = g_list_next(new_it);
+ }
+ if(new_it) {
+ qi->longitude = cg.lng;
+ qi->latitude = cg.lat;
+ quadtree_add( m->tree_root, qi, mr->qiter);
+ dbg(lvl_debug,"Set coordinates %f %f", cg.lng, cg.lat);
+ m->new_items = g_list_remove_link(m->new_items,new_it);
+ m->dirty=1;
+ save_map_csv(m);
+ return 1;
+ }
+
+ /* else update quadtree item with the new coord
+ remove item from the quadtree */
+ query_item.longitude = cg.lng;
+ query_item.latitude = cg.lat;
+ query_res = quadtree_find_item(m->tree_root, &query_item);
+ if(!query_res) {
+ return 0;
+ }
+ quadtree_delete_item(m->tree_root, query_res);
+ /* add item to the tree with the new coord */
+ insert_item=g_new0(struct quadtree_item,1);
+ insert_item->data=quadtree_data_dup(query_res->data);
+ insert_item->longitude = cg.lng;
+ insert_item->latitude = cg.lat;
+ quadtree_add(m->tree_root, query_res, mr->qiter);
+
+ mr->qitem->ref_count--;
+ mr->qitem=insert_item;
+ mr->qitem->ref_count++;
+
+ m->dirty = 1;
+ save_map_csv(m);
+ return 1;
}
-static void quadtree_item_free(void *this, struct quadtree_item *qitem)
-{
- struct map_priv* m=this;
- struct quadtree_data * qdata=qitem->data;
- if(m) {
- g_hash_table_remove(m->qitem_hash,&(qdata->item->id_lo));
- }
+static void quadtree_item_free(void *this, struct quadtree_item *qitem) {
+ struct map_priv* m=this;
+ struct quadtree_data * qdata=qitem->data;
+ if(m) {
+ g_hash_table_remove(m->qitem_hash,&(qdata->item->id_lo));
+ }
}
-static void quadtree_item_free_do(void *data)
-{
- struct quadtree_item *qitem=data;
- GList* attr_it;
- struct attr* attr;
- struct quadtree_data * qdata=qitem->data;
- if(qdata) {
- for(attr_it = qdata->attr_list;attr_it;attr_it = g_list_next(attr_it)) {
- attr = attr_it->data;
- attr_free(attr);
- }
- g_list_free(qdata->attr_list);
- g_free(qdata->item);
- g_free(qitem->data);
- }
- g_free(data);
+static void quadtree_item_free_do(void *data) {
+ struct quadtree_item *qitem=data;
+ GList* attr_it;
+ struct attr* attr;
+ struct quadtree_data * qdata=qitem->data;
+ if(qdata) {
+ for(attr_it = qdata->attr_list; attr_it; attr_it = g_list_next(attr_it)) {
+ attr = attr_it->data;
+ attr_free(attr);
+ }
+ g_list_free(qdata->attr_list);
+ g_free(qdata->item);
+ g_free(qitem->data);
+ }
+ g_free(data);
}
-static void map_csv_debug_dump_hash_item(gpointer key, gpointer value, gpointer user_data)
-{
- struct quadtree_item *qi=value;
- GList *attrs;
- dbg(lvl_debug,"%p del=%d ref=%d\n", qi,qi->deleted, qi->ref_count);
- attrs=((struct quadtree_data *)qi->data)->attr_list;
- while(attrs) {
- if(((struct attr*)attrs->data)->type==attr_label)
- dbg(lvl_debug,"... %s\n",((struct attr*)attrs->data)->u.str);
- attrs=g_list_next(attrs);
- }
+static void map_csv_debug_dump_hash_item(gpointer key, gpointer value, gpointer user_data) {
+ struct quadtree_item *qi=value;
+ GList *attrs;
+ dbg(lvl_debug,"%p del=%d ref=%d", qi,qi->deleted, qi->ref_count);
+ attrs=((struct quadtree_data *)qi->data)->attr_list;
+ while(attrs) {
+ if(((struct attr*)attrs->data)->type==attr_label)
+ dbg(lvl_debug,"... %s",((struct attr*)attrs->data)->u.str);
+ attrs=g_list_next(attrs);
+ }
}
/**
* Dump all map data (including deleted items) to the log.
*/
-static void map_csv_debug_dump(struct map_priv *map)
-{
- g_hash_table_foreach(map->qitem_hash, map_csv_debug_dump_hash_item, NULL);
+static void map_csv_debug_dump(struct map_priv *map) {
+ g_hash_table_foreach(map->qitem_hash, map_csv_debug_dump_hash_item, NULL);
}
-static struct map_rect_priv *
-map_rect_new_csv(struct map_priv *map, struct map_selection *sel)
-{
- struct map_rect_priv *mr;
- struct coord_geo lu;
- struct coord_geo rl;
- struct quadtree_iter *res = NULL;
- dbg(lvl_debug,"map_rect_new_csv\n");
- if(debug_level_get("map_csv")>2) {
- map_csv_debug_dump(map);
- }
- mr=g_new0(struct map_rect_priv, 1);
- mr->m=map;
- mr->bStarted = 0;
- mr->sel=sel;
- if (map->flags & 1)
- mr->item.id_hi=1;
- else
- mr->item.id_hi=0;
- mr->item.id_lo=0;
- mr->item.meth=&methods_csv;
- mr->item.priv_data=mr;
-
- if(!sel) {
- lu.lng=-180;
- lu.lat=180;
- rl.lng=180;
- rl.lat=-180;
- } else {
- transform_to_geo(projection_mg, &sel->u.c_rect.lu, &lu);
- transform_to_geo(projection_mg, &sel->u.c_rect.rl, &rl);
- }
- res=quadtree_query(map->tree_root, lu.lng, rl.lng, rl.lat, lu.lat, quadtree_item_free, mr->m);
- mr->qiter = res;
- mr->qitem = NULL;
- return mr;
+static struct map_rect_priv *map_rect_new_csv(struct map_priv *map, struct map_selection *sel) {
+ struct map_rect_priv *mr;
+ struct coord_geo lu;
+ struct coord_geo rl;
+ struct quadtree_iter *res = NULL;
+ dbg(lvl_debug,"map_rect_new_csv");
+ if(debug_level_get("map_csv")>2) {
+ map_csv_debug_dump(map);
+ }
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->m=map;
+ mr->bStarted = 0;
+ mr->sel=sel;
+ if (map->flags & 1)
+ mr->item.id_hi=1;
+ else
+ mr->item.id_hi=0;
+ mr->item.id_lo=0;
+ mr->item.meth=&methods_csv;
+ mr->item.priv_data=mr;
+
+ if(!sel) {
+ lu.lng=-180;
+ lu.lat=180;
+ rl.lng=180;
+ rl.lat=-180;
+ } else {
+ transform_to_geo(projection_mg, &sel->u.c_rect.lu, &lu);
+ transform_to_geo(projection_mg, &sel->u.c_rect.rl, &rl);
+ }
+ res=quadtree_query(map->tree_root, lu.lng, rl.lng, rl.lat, lu.lat, quadtree_item_free, mr->m);
+ mr->qiter = res;
+ mr->qitem = NULL;
+ return mr;
}
-static void
-map_rect_destroy_csv(struct map_rect_priv *mr)
-{
- if(mr->qitem)
- mr->qitem->ref_count--;
+static void map_rect_destroy_csv(struct map_rect_priv *mr) {
+ if(mr->qitem)
+ mr->qitem->ref_count--;
- if(mr->qiter)
- quadtree_query_free(mr->qiter);
+ if(mr->qiter)
+ quadtree_query_free(mr->qiter);
- g_free(mr);
+ g_free(mr);
}
-static struct item *
-map_rect_get_item_csv(struct map_rect_priv *mr)
-{
-
- if(mr->qitem)
- mr->qitem->ref_count--;
-
- mr->qitem=quadtree_item_next(mr->qiter);
-
- if(mr->qitem) {
- struct item* ret=&(mr->item);
- struct coord_geo cg;
- mr->qitem->ref_count++;
- mr->item = *(((struct quadtree_data*)(mr->qitem->data))->item);
- ret->priv_data=mr;
- cg.lng = mr->qitem->longitude;
- cg.lat = mr->qitem->latitude;
- transform_from_geo(projection_mg, &cg, &mr->c);
- return ret;
- }
- return NULL;
+static struct item *map_rect_get_item_csv(struct map_rect_priv *mr) {
+
+ if(mr->qitem)
+ mr->qitem->ref_count--;
+
+ mr->qitem=quadtree_item_next(mr->qiter);
+
+ if(mr->qitem) {
+ struct item* ret=&(mr->item);
+ struct coord_geo cg;
+ mr->qitem->ref_count++;
+ mr->item = *(((struct quadtree_data*)(mr->qitem->data))->item);
+ ret->priv_data=mr;
+ cg.lng = mr->qitem->longitude;
+ cg.lat = mr->qitem->latitude;
+ transform_from_geo(projection_mg, &cg, &mr->c);
+ return ret;
+ }
+ return NULL;
}
-static struct item *
-map_rect_get_item_byid_csv(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- /*currently id_hi is ignored*/
-
- struct quadtree_item *qit = g_hash_table_lookup(mr->m->qitem_hash,&id_lo);
-
- if(mr->qitem )
- mr->qitem->ref_count--;
-
- if(qit) {
- mr->qitem = qit;
- mr->qitem->ref_count++;
- mr->item=*(((struct quadtree_data*)(qit->data))->item);
- mr->item.priv_data=mr;
- return &(mr->item);
- } else {
- mr->qitem = NULL;
- return NULL;
- }
+static struct item *map_rect_get_item_byid_csv(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ /*currently id_hi is ignored*/
+
+ struct quadtree_item *qit = g_hash_table_lookup(mr->m->qitem_hash,&id_lo);
+
+ if(mr->qitem )
+ mr->qitem->ref_count--;
+
+ if(qit) {
+ mr->qitem = qit;
+ mr->qitem->ref_count++;
+ mr->item=*(((struct quadtree_data*)(qit->data))->item);
+ mr->item.priv_data=mr;
+ return &(mr->item);
+ } else {
+ mr->qitem = NULL;
+ return NULL;
+ }
}
-static int
-csv_get_attr(struct map_priv *m, enum attr_type type, struct attr *attr)
-{
- return 0;
+static int csv_get_attr(struct map_priv *m, enum attr_type type, struct attr *attr) {
+ return 0;
}
-static struct item *
-csv_create_item(struct map_rect_priv *mr, enum item_type it_type)
-{
- struct map_priv* m;
- struct quadtree_data* qd;
- struct quadtree_item* qi;
- struct item* curr_item;
- int* pID;
- if(mr && mr->m) {
- m = mr->m;
- }
- else {
- return NULL;
- }
-
- if( m->item_type != it_type) {
- return NULL;
- }
-
- m->dirty = 1;
- /*add item to the map*/
- curr_item = item_new("",zoom_max);
- curr_item->type = m->item_type;
- curr_item->meth=&methods_csv;
-
- curr_item->id_lo = m->next_item_idx;
- if (m->flags & 1)
- curr_item->id_hi=1;
- else
- curr_item->id_hi=0;
-
- qd = g_new0(struct quadtree_data,1);
- qi = g_new0(struct quadtree_item,1);
- qd->item = curr_item;
- qd->attr_list = NULL;
- qi->data = qd;
- /*we don`t have valid coord yet*/
- qi->longitude = 0;
- qi->latitude = 0;
- /*add the coord less item to the new list*/
- m->new_items = g_list_prepend(m->new_items, qi);
- if(mr->qitem)
- mr->qitem->ref_count--;
- mr->qitem=qi;
- mr->item=*curr_item;
- mr->item.priv_data=mr;
- mr->qitem->ref_count++;
- /*don't add to the quadtree yet, wait until we have a valid coord*/
- pID = g_new(int,1);
- *pID = m->next_item_idx;
- g_hash_table_insert(m->qitem_hash, pID,qi);
- ++m->next_item_idx;
- return &mr->item;
+static struct item *csv_create_item(struct map_rect_priv *mr, enum item_type it_type) {
+ struct map_priv* m;
+ struct quadtree_data* qd;
+ struct quadtree_item* qi;
+ struct item* curr_item;
+ int* pID;
+ if(mr && mr->m) {
+ m = mr->m;
+ } else {
+ return NULL;
+ }
+
+ if( m->item_type != it_type) {
+ return NULL;
+ }
+
+ m->dirty = 1;
+ /*add item to the map*/
+ curr_item = item_new("",zoom_max);
+ curr_item->type = m->item_type;
+ curr_item->meth=&methods_csv;
+
+ curr_item->id_lo = m->next_item_idx;
+ if (m->flags & 1)
+ curr_item->id_hi=1;
+ else
+ curr_item->id_hi=0;
+
+ qd = g_new0(struct quadtree_data,1);
+ qi = g_new0(struct quadtree_item,1);
+ qd->item = curr_item;
+ qd->attr_list = NULL;
+ qi->data = qd;
+ /*we don`t have valid coord yet*/
+ qi->longitude = 0;
+ qi->latitude = 0;
+ /*add the coord less item to the new list*/
+ m->new_items = g_list_prepend(m->new_items, qi);
+ if(mr->qitem)
+ mr->qitem->ref_count--;
+ mr->qitem=qi;
+ mr->item=*curr_item;
+ mr->item.priv_data=mr;
+ mr->qitem->ref_count++;
+ /*don't add to the quadtree yet, wait until we have a valid coord*/
+ pID = g_new(int,1);
+ *pID = m->next_item_idx;
+ g_hash_table_insert(m->qitem_hash, pID,qi);
+ ++m->next_item_idx;
+ return &mr->item;
}
static struct map_methods map_methods_csv = {
- projection_mg,
- "utf-8",
- map_destroy_csv,
- map_rect_new_csv,
- map_rect_destroy_csv,
- map_rect_get_item_csv,
- map_rect_get_item_byid_csv,
- NULL,
- NULL,
- NULL,
- csv_create_item,
- csv_get_attr,
+ projection_mg,
+ "utf-8",
+ map_destroy_csv,
+ map_rect_new_csv,
+ map_rect_destroy_csv,
+ map_rect_get_item_csv,
+ map_rect_get_item_byid_csv,
+ NULL,
+ NULL,
+ NULL,
+ csv_create_item,
+ csv_get_attr,
};
-static struct map_priv *
-map_new_csv(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct map_priv *m = NULL;
- struct attr *attr_types;
- struct attr *item_type_attr;
- struct attr *data;
- struct attr *flags;
- struct attr *charset;
- int bLonFound = 0;
- int bLatFound = 0;
- int attr_cnt = 0;
- enum attr_type* attr_type_list = NULL;
- struct quadtree_node* tree_root = quadtree_node_new(NULL,-180,180,-180,180);
- m = g_new0(struct map_priv, 1);
- m->id = ++map_id;
- m->qitem_hash = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, quadtree_item_free_do);
- m->tree_root = tree_root;
-
- attr_types = attr_search(attrs, NULL, attr_attr_types);
- if(attr_types) {
- enum attr_type* at = attr_types->u.attr_types;
- while(*at != attr_none) {
- attr_type_list = g_realloc(attr_type_list,sizeof(enum attr_type)*(attr_cnt+1));
- attr_type_list[attr_cnt] = *at;
- if(*at==attr_position_latitude) {
- bLatFound = 1;
- }
- else if(*at==attr_position_longitude) {
- bLonFound = 1;
- }
- ++attr_cnt;
- ++at;
- }
- m->attr_cnt = attr_cnt;
- m->attr_types = attr_type_list;
- } else {
- m->attr_types = NULL;
- return NULL;
- }
-
- charset = attr_search(attrs, NULL, attr_charset);
- if(charset) {
- dbg(lvl_debug,"charset:%s\n",charset->u.str);
- m->charset=g_strdup(charset->u.str);
- } else {
- m->charset=g_strdup(map_methods_csv.charset);
- }
-
- if(bLonFound==0 || bLatFound==0) {
- return NULL;
- }
-
- item_type_attr=attr_search(attrs, NULL, attr_item_type);
-
- if( !item_type_attr || item_type_attr->u.item_type==type_none) {
- return NULL;
- }
-
- m->item_type = item_type_attr->u.item_type;
-
- flags=attr_search(attrs, NULL, attr_flags);
- if (flags)
- m->flags=flags->u.num;
-
- *meth = map_methods_csv;
-
- data=attr_search(attrs, NULL, attr_data);
-
- if(data) {
- struct file_wordexp *wexp;
- char **wexp_data;
- FILE *fp;
- wexp=file_wordexp_new(data->u.str);
- wexp_data=file_wordexp_get_array(wexp);
- dbg(lvl_debug,"map_new_csv %s\n", data->u.str);
- m->filename=g_strdup(wexp_data[0]);
- file_wordexp_destroy(wexp);
-
- /*load csv file into quadtree structure*/
- /*if column number is wrong skip*/
- if((fp=fopen(m->filename,"rt"))) {
- const int max_line_len = 256;
- char *linebuf=g_alloca(sizeof(char)*max_line_len);
- while(!feof(fp)) {
- if(fgets(linebuf,max_line_len,fp)) {
- char *line=g_convert(linebuf, -1,"utf-8",m->charset,NULL,NULL,NULL);
- char *line2=NULL;
- char *delim = ",";
- int col_cnt=0;
- char *tok;
- if(!line) {
- dbg(lvl_error,"Error converting '%s' to utf-8 from %s\n",linebuf, m->charset);
- continue;
- }
- if(line[strlen(line)-1]=='\n' || line[strlen(line)-1]=='\r') {
- line[strlen(line)-1] = '\0';
- }
- line2 = g_strdup(line);
- while((tok=strtok( (col_cnt==0)?line:NULL , delim))) {
- ++col_cnt;
- }
-
- if(col_cnt==attr_cnt) {
- int cnt = 0; /*index of current attr*/
- char*tok;
- GList* attr_list = NULL;
- int bAddSum = 1;
- double longitude = 0.0, latitude=0.0;
- struct item *curr_item = item_new("",zoom_max);/*does not use parameters*/
-
- curr_item->type = item_type_attr->u.item_type;
- curr_item->id_lo = m->next_item_idx;
- if (m->flags & 1)
- curr_item->id_hi=1;
- else
- curr_item->id_hi=0;
- curr_item->meth=&methods_csv;
-
-
- while((tok=strtok( (cnt==0)?line2:NULL , delim))) {
- struct attr*curr_attr = g_new0(struct attr,1);
- int bAdd = 1;
- curr_attr->type = attr_types->u.attr_types[cnt];
- if(ATTR_IS_STRING(attr_types->u.attr_types[cnt])) {
- curr_attr->u.str = g_strdup(tok);
- }
- else if(ATTR_IS_INT(attr_types->u.attr_types[cnt])) {
- curr_attr->u.num = atoi(tok);
- }
- else if(ATTR_IS_DOUBLE(attr_types->u.attr_types[cnt])) {
- double *d = g_new(double,1);
- *d = atof(tok);
- curr_attr->u.numd = d;
- if(attr_types->u.attr_types[cnt] == attr_position_longitude) {
- longitude = *d;
- }
- if(attr_types->u.attr_types[cnt] == attr_position_latitude) {
- latitude = *d;
- }
- }
- else {
- /*unknown attribute*/
- bAddSum = bAdd = 0;
- g_free(curr_attr);
- }
-
- if(bAdd) {
- attr_list = g_list_prepend(attr_list, curr_attr);
- }
- ++cnt;
- }
- if(bAddSum && (longitude!=0.0 || latitude!=0.0)) {
- struct quadtree_data* qd = g_new0(struct quadtree_data,1);
- struct quadtree_item* qi =g_new0(struct quadtree_item,1);
- int* pID = g_new(int,1);
- qd->item = curr_item;
- qd->attr_list = attr_list;
- qi->data = qd;
- qi->longitude = longitude;
- qi->latitude = latitude;
- quadtree_add(tree_root, qi, NULL);
- *pID = m->next_item_idx;
- g_hash_table_insert(m->qitem_hash, pID,qi);
- ++m->next_item_idx;
- dbg(lvl_debug,"%s\n",line);
- }
- else {
- g_free(curr_item);
- }
-
- }
- else {
- dbg(lvl_error,"ERROR: Non-matching attr count and column count: %d %d SKIPPING line: %s\n",col_cnt, attr_cnt,line);
- }
- g_free(line);
- g_free(line2);
- }
- }
- fclose(fp);
- }
- else {
- dbg(lvl_error,"Error opening csv map file '%s': %s\n", m->filename, strerror(errno));
- return NULL;
- }
- } else {
- dbg(lvl_debug,"No data attribute, starting with in-memory map\n");
- }
-
- dbg(lvl_info,"%p\n",tree_root);
- return m;
+static struct map_priv *map_new_csv(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *m = NULL;
+ struct attr *attr_types;
+ struct attr *item_type_attr;
+ struct attr *data;
+ struct attr *flags;
+ struct attr *charset;
+ int bLonFound = 0;
+ int bLatFound = 0;
+ int attr_cnt = 0;
+ enum attr_type* attr_type_list = NULL;
+ struct quadtree_node* tree_root = quadtree_node_new(NULL,-180,180,-180,180);
+ m = g_new0(struct map_priv, 1);
+ m->id = ++map_id;
+ m->qitem_hash = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, quadtree_item_free_do);
+ m->tree_root = tree_root;
+
+ attr_types = attr_search(attrs, NULL, attr_attr_types);
+ if(attr_types) {
+ enum attr_type* at = attr_types->u.attr_types;
+ while(*at != attr_none) {
+ attr_type_list = g_realloc(attr_type_list,sizeof(enum attr_type)*(attr_cnt+1));
+ attr_type_list[attr_cnt] = *at;
+ if(*at==attr_position_latitude) {
+ bLatFound = 1;
+ } else if(*at==attr_position_longitude) {
+ bLonFound = 1;
+ }
+ ++attr_cnt;
+ ++at;
+ }
+ m->attr_cnt = attr_cnt;
+ m->attr_types = attr_type_list;
+ } else {
+ m->attr_types = NULL;
+ return NULL;
+ }
+
+ charset = attr_search(attrs, NULL, attr_charset);
+ if(charset) {
+ dbg(lvl_debug,"charset:%s",charset->u.str);
+ m->charset=g_strdup(charset->u.str);
+ } else {
+ m->charset=g_strdup(map_methods_csv.charset);
+ }
+
+ if(bLonFound==0 || bLatFound==0) {
+ return NULL;
+ }
+
+ item_type_attr=attr_search(attrs, NULL, attr_item_type);
+
+ if( !item_type_attr || item_type_attr->u.item_type==type_none) {
+ return NULL;
+ }
+
+ m->item_type = item_type_attr->u.item_type;
+
+ flags=attr_search(attrs, NULL, attr_flags);
+ if (flags)
+ m->flags=flags->u.num;
+
+ *meth = map_methods_csv;
+
+ data=attr_search(attrs, NULL, attr_data);
+
+ if(data) {
+ struct file_wordexp *wexp;
+ char **wexp_data;
+ FILE *fp;
+ wexp=file_wordexp_new(data->u.str);
+ wexp_data=file_wordexp_get_array(wexp);
+ dbg(lvl_debug,"map_new_csv %s", data->u.str);
+ m->filename=g_strdup(wexp_data[0]);
+ file_wordexp_destroy(wexp);
+
+ /*load csv file into quadtree structure*/
+ /*if column number is wrong skip*/
+ if((fp=fopen(m->filename,"rt"))) {
+ const int max_line_len = 256;
+ char *linebuf=g_alloca(sizeof(char)*max_line_len);
+ while(!feof(fp)) {
+ if(fgets(linebuf,max_line_len,fp)) {
+ char *line=g_convert(linebuf, -1,"utf-8",m->charset,NULL,NULL,NULL);
+ char *line2=NULL;
+ char *delim = ",";
+ int col_cnt=0;
+ char *tok;
+ if(!line) {
+ dbg(lvl_error,"Error converting '%s' to utf-8 from %s",linebuf, m->charset);
+ continue;
+ }
+ if(line[strlen(line)-1]=='\n' || line[strlen(line)-1]=='\r') {
+ line[strlen(line)-1] = '\0';
+ }
+ line2 = g_strdup(line);
+ while((tok=strtok( (col_cnt==0)?line:NULL, delim))) {
+ ++col_cnt;
+ }
+
+ if(col_cnt==attr_cnt) {
+ int cnt = 0; /*index of current attr*/
+ char*tok;
+ GList* attr_list = NULL;
+ int bAddSum = 1;
+ double longitude = 0.0, latitude=0.0;
+ struct item *curr_item = item_new("",zoom_max);/*does not use parameters*/
+
+ curr_item->type = item_type_attr->u.item_type;
+ curr_item->id_lo = m->next_item_idx;
+ if (m->flags & 1)
+ curr_item->id_hi=1;
+ else
+ curr_item->id_hi=0;
+ curr_item->meth=&methods_csv;
+
+
+ while((tok=strtok( (cnt==0)?line2:NULL, delim))) {
+ struct attr*curr_attr = g_new0(struct attr,1);
+ int bAdd = 1;
+ curr_attr->type = attr_types->u.attr_types[cnt];
+ if(ATTR_IS_STRING(attr_types->u.attr_types[cnt])) {
+ curr_attr->u.str = g_strdup(tok);
+ } else if(ATTR_IS_INT(attr_types->u.attr_types[cnt])) {
+ curr_attr->u.num = atoi(tok);
+ } else if(ATTR_IS_DOUBLE(attr_types->u.attr_types[cnt])) {
+ double *d = g_new(double,1);
+ *d = atof(tok);
+ curr_attr->u.numd = d;
+ if(attr_types->u.attr_types[cnt] == attr_position_longitude) {
+ longitude = *d;
+ }
+ if(attr_types->u.attr_types[cnt] == attr_position_latitude) {
+ latitude = *d;
+ }
+ } else {
+ /*unknown attribute*/
+ bAddSum = bAdd = 0;
+ g_free(curr_attr);
+ }
+
+ if(bAdd) {
+ attr_list = g_list_prepend(attr_list, curr_attr);
+ }
+ ++cnt;
+ }
+ if(bAddSum && (longitude!=0.0 || latitude!=0.0)) {
+ struct quadtree_data* qd = g_new0(struct quadtree_data,1);
+ struct quadtree_item* qi =g_new0(struct quadtree_item,1);
+ int* pID = g_new(int,1);
+ qd->item = curr_item;
+ qd->attr_list = attr_list;
+ qi->data = qd;
+ qi->longitude = longitude;
+ qi->latitude = latitude;
+ quadtree_add(tree_root, qi, NULL);
+ *pID = m->next_item_idx;
+ g_hash_table_insert(m->qitem_hash, pID,qi);
+ ++m->next_item_idx;
+ dbg(lvl_debug,"%s",line);
+ } else {
+ g_free(curr_item);
+ }
+
+ } else {
+ dbg(lvl_error,"ERROR: Non-matching attr count and column count: %d %d SKIPPING line: %s",col_cnt, attr_cnt,line);
+ }
+ g_free(line);
+ g_free(line2);
+ }
+ }
+ fclose(fp);
+ } else {
+ dbg(lvl_error,"Error opening csv map file '%s': %s", m->filename, strerror(errno));
+ return NULL;
+ }
+ } else {
+ dbg(lvl_debug,"No data attribute, starting with in-memory map");
+ }
+
+ dbg(lvl_info,"%p",tree_root);
+ return m;
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug,"csv: plugin_init\n");
- plugin_register_category_map("csv", map_new_csv);
+void plugin_init(void) {
+ dbg(lvl_debug,"csv: plugin_init");
+ plugin_register_category_map("csv", map_new_csv);
}
diff --git a/navit/map/csv/csv.h b/navit/map/csv/csv.h
index 0ea31b18c..c32be1eff 100644
--- a/navit/map/csv/csv.h
+++ b/navit/map/csv/csv.h
@@ -32,13 +32,13 @@ struct map_priv {
GHashTable*qitem_hash;
char* filename;
/*need to write map file on exit*/
- int dirty;
+ int dirty;
int attr_cnt;
enum attr_type *attr_types;
int next_item_idx;
enum item_type item_type;
/*list of quadtree items that have no coord set yet ()*/
- GList* new_items;
+ GList* new_items;
char *charset;
};
diff --git a/navit/map/csv/quadtree.c b/navit/map/csv/quadtree.c
index ca6068541..eda5a476d 100644
--- a/navit/map/csv/quadtree.c
+++ b/navit/map/csv/quadtree.c
@@ -34,34 +34,32 @@
/* Structure describing quadtree iterative query */
struct quadtree_iter {
- /* List representing stack of quad_tree_iter_nodes referring to higher-level quadtree_nodes */
- GList *iter_nodes;
- double xmin,xmax,ymin,ymax;
- /* Current item pointer */
- struct quadtree_item *item;
- void (*item_free)(void *context, struct quadtree_item *qitem);
- void *item_free_context;
+ /* List representing stack of quad_tree_iter_nodes referring to higher-level quadtree_nodes */
+ GList *iter_nodes;
+ double xmin,xmax,ymin,ymax;
+ /* Current item pointer */
+ struct quadtree_item *item;
+ void (*item_free)(void *context, struct quadtree_item *qitem);
+ void *item_free_context;
};
/* Structure describing one level of the quadtree iterative query */
struct quadtree_iter_node {
- struct quadtree_node *node;
- /* Number of subnode being analyzed (for non-leafs) */
- int subnode;
- /* Number of item being analyzed (for leafs) */
- int item;
- /* Number of subitems in items array (for leafs) */
- int node_num;
- /* If the node referenced was a leaf when it was analyzed */
- int is_leaf;
- struct quadtree_item *items[QUADTREE_NODE_CAPACITY];
-};
-
-
-static double
-dist_sq(double x1,double y1,double x2,double y2)
-{
- return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
+ struct quadtree_node *node;
+ /* Number of subnode being analyzed (for non-leafs) */
+ int subnode;
+ /* Number of item being analyzed (for leafs) */
+ int item;
+ /* Number of subitems in items array (for leafs) */
+ int node_num;
+ /* If the node referenced was a leaf when it was analyzed */
+ int is_leaf;
+ struct quadtree_item *items[QUADTREE_NODE_CAPACITY];
+};
+
+
+static double dist_sq(double x1,double y1,double x2,double y2) {
+ return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}
struct quadtree_node*
@@ -79,34 +77,33 @@ quadtree_node_new(struct quadtree_node* parent, double xmin, double xmax, double
/*
* searches all four subnodes recursively for the list of items within a rectangle
*/
-void
-quadtree_find_rect_items(struct quadtree_node* this_, double dXMin, double dXMax, double dYMin, double dYMax, GList**out) {
+void quadtree_find_rect_items(struct quadtree_node* this_, double dXMin, double dXMax, double dYMin, double dYMax,
+ GList**out) {
struct quadtree_node* nodes[4] = { this_->aa, this_->ab, this_->ba, this_->bb };
- if( this_->is_leaf ) {
+ if( this_->is_leaf ) {
int i;
- for(i=0;i<this_->node_num;++i) { //select only items within input rectangle
- if(dXMin<=this_->items[i]->longitude && this_->items[i]->longitude<=dXMax &&
- dYMin<=this_->items[i]->latitude && this_->items[i]->latitude<=dYMax
- ) {
- *out=g_list_prepend(*out,this_->items[i]);
- }
+ for(i=0; i<this_->node_num; ++i) { //select only items within input rectangle
+ if(dXMin<=this_->items[i]->longitude && this_->items[i]->longitude<=dXMax &&
+ dYMin<=this_->items[i]->latitude && this_->items[i]->latitude<=dYMax
+ ) {
+ *out=g_list_prepend(*out,this_->items[i]);
+ }
+ }
+ } else {
+ int i;
+ for( i=0; i<4; ++i) {
+ if(nodes[i] ) {
+ //limit flooding
+ if(nodes[i]->xmax<dXMin || dXMax<nodes[i]->xmin ||
+ nodes[i]->ymax<dYMin || dYMax<nodes[i]->ymin
+ ) {
+ continue;
+ }
+ //recurse into subtiles if there is at least one subtile corner within input rectangle
+ quadtree_find_rect_items(nodes[i],dXMin,dXMax,dYMin,dYMax,out);
+ }
}
- }
- else {
- int i;
- for( i=0;i<4;++i) {
- if(nodes[i] ) {
- //limit flooding
- if(nodes[i]->xmax<dXMin || dXMax<nodes[i]->xmin ||
- nodes[i]->ymax<dYMin || dYMax<nodes[i]->ymin
- ) {
- continue;
- }
- //recurse into subtiles if there is at least one subtile corner within input rectangle
- quadtree_find_rect_items(nodes[i],dXMin,dXMax,dYMin,dYMax,out);
- }
- }
}
}
@@ -114,46 +111,46 @@ quadtree_find_rect_items(struct quadtree_node* this_, double dXMin, double dXMax
* searches all four subnodes recursively for the closest item
*/
struct quadtree_item*
-quadtree_find_nearest_flood(struct quadtree_node* this_, struct quadtree_item* item, double current_max, struct quadtree_node* toSkip) {
+quadtree_find_nearest_flood(struct quadtree_node* this_, struct quadtree_item* item, double current_max,
+ struct quadtree_node* toSkip) {
struct quadtree_node* nodes[4] = { this_->aa, this_->ab, this_->ba, this_->bb };
struct quadtree_item*res = NULL;
- if( this_->is_leaf ) {
+ if( this_->is_leaf ) {
int i;
double distance_sq = current_max;
- for(i=0;i<this_->node_num;++i) {
+ for(i=0; i<this_->node_num; ++i) {
double curr_dist_sq = dist_sq(item->longitude,item->latitude,this_->items[i]->longitude,this_->items[i]->latitude);
if(curr_dist_sq<distance_sq) {
distance_sq = curr_dist_sq;
res = this_->items[i];
}
}
- }
- else {
- int i;
- for( i=0;i<4;++i) {
- if(nodes[i] && nodes[i]!=toSkip) {
- //limit flooding
- struct quadtree_item*res_tmp = NULL;
- if(
- dist_sq(nodes[i]->xmin,nodes[i]->ymin,item->longitude,item->latitude)<current_max ||
- dist_sq(nodes[i]->xmax,nodes[i]->ymin,item->longitude,item->latitude)<current_max ||
- dist_sq(nodes[i]->xmax,nodes[i]->ymax,item->longitude,item->latitude)<current_max ||
- dist_sq(nodes[i]->xmin,nodes[i]->ymax,item->longitude,item->latitude)<current_max
- ) {
- res_tmp = quadtree_find_nearest_flood(nodes[i],item,current_max,NULL);
- }
- if(res_tmp) {
- double curr_dist_sq;
- res = res_tmp;
- curr_dist_sq = dist_sq(item->longitude,item->latitude,res->longitude,res->latitude);
- if(curr_dist_sq<current_max) {
- current_max = curr_dist_sq;
+ } else {
+ int i;
+ for( i=0; i<4; ++i) {
+ if(nodes[i] && nodes[i]!=toSkip) {
+ //limit flooding
+ struct quadtree_item*res_tmp = NULL;
+ if(
+ dist_sq(nodes[i]->xmin,nodes[i]->ymin,item->longitude,item->latitude)<current_max ||
+ dist_sq(nodes[i]->xmax,nodes[i]->ymin,item->longitude,item->latitude)<current_max ||
+ dist_sq(nodes[i]->xmax,nodes[i]->ymax,item->longitude,item->latitude)<current_max ||
+ dist_sq(nodes[i]->xmin,nodes[i]->ymax,item->longitude,item->latitude)<current_max
+ ) {
+ res_tmp = quadtree_find_nearest_flood(nodes[i],item,current_max,NULL);
+ }
+ if(res_tmp) {
+ double curr_dist_sq;
+ res = res_tmp;
+ curr_dist_sq = dist_sq(item->longitude,item->latitude,res->longitude,res->latitude);
+ if(curr_dist_sq<current_max) {
+ current_max = curr_dist_sq;
+ }
+ }
}
- }
- }
- }
+ }
}
- return res;
+ return res;
}
/*
@@ -163,129 +160,117 @@ struct quadtree_item*
quadtree_find_item(struct quadtree_node* this_, struct quadtree_item* item) {
struct quadtree_item*res = NULL;
if( ! this_ ) {
- return NULL;
+ return NULL;
}
- if( this_->is_leaf ) {
+ if( this_->is_leaf ) {
int i;
- for(i=0;i<this_->node_num;++i) {
+ for(i=0; i<this_->node_num; ++i) {
//TODO equality check may not be correct on float values! maybe it can be replaced by range check with some tolerance
if(item->longitude==this_->items[i]->longitude && item->latitude==this_->items[i]->latitude) {
res = this_->items[i];
return res;
}
}
- return NULL;
- }
- else {
+ return NULL;
+ } else {
if(
- this_->aa &&
- this_->aa->xmin<=item->longitude && item->longitude<this_->aa->xmax &&
- this_->aa->ymin<=item->latitude && item->latitude<this_->aa->ymax
- ) {
- res = quadtree_find_item(this_->aa,item);
- }
- else if(
- this_->ab &&
- this_->ab->xmin<=item->longitude && item->longitude<this_->ab->xmax &&
- this_->ab->ymin<=item->latitude && item->latitude<this_->ab->ymax
- ) {
- res = quadtree_find_item(this_->ab,item);
- }
- else if(
- this_->ba &&
- this_->ba->xmin<=item->longitude && item->longitude<this_->ba->xmax &&
- this_->ba->ymin<=item->latitude && item->latitude<this_->ba->ymax
- ) {
- res = quadtree_find_item(this_->ba,item);
- }
- else if(
- this_->bb &&
- this_->bb->xmin<=item->longitude && item->longitude<this_->bb->xmax &&
- this_->bb->ymin<=item->latitude && item->latitude<this_->bb->ymax
- ) {
- res = quadtree_find_item(this_->bb,item);
- }
- else {
- return NULL;
+ this_->aa &&
+ this_->aa->xmin<=item->longitude && item->longitude<this_->aa->xmax &&
+ this_->aa->ymin<=item->latitude && item->latitude<this_->aa->ymax
+ ) {
+ res = quadtree_find_item(this_->aa,item);
+ } else if(
+ this_->ab &&
+ this_->ab->xmin<=item->longitude && item->longitude<this_->ab->xmax &&
+ this_->ab->ymin<=item->latitude && item->latitude<this_->ab->ymax
+ ) {
+ res = quadtree_find_item(this_->ab,item);
+ } else if(
+ this_->ba &&
+ this_->ba->xmin<=item->longitude && item->longitude<this_->ba->xmax &&
+ this_->ba->ymin<=item->latitude && item->latitude<this_->ba->ymax
+ ) {
+ res = quadtree_find_item(this_->ba,item);
+ } else if(
+ this_->bb &&
+ this_->bb->xmin<=item->longitude && item->longitude<this_->bb->xmax &&
+ this_->bb->ymin<=item->latitude && item->latitude<this_->bb->ymax
+ ) {
+ res = quadtree_find_item(this_->bb,item);
+ } else {
+ return NULL;
}
}
- return res;
+ return res;
}
/*
* returns the containing node for an item
*/
-struct quadtree_node*
-quadtree_find_containing_node(struct quadtree_node* root, struct quadtree_item* item)
-{
+struct quadtree_node*
+quadtree_find_containing_node(struct quadtree_node* root, struct quadtree_item* item) {
struct quadtree_node*res = NULL;
if( ! root ) {
- return NULL;
+ return NULL;
}
- if( root->is_leaf ) {
+ if( root->is_leaf ) {
int i;
- for(i=0;i<root->node_num;++i) {
+ for(i=0; i<root->node_num; ++i) {
if(item == root->items[i]) {
res = root;
}
}
- }
- else {
+ } else {
if(
- root->aa &&
- root->aa->xmin<=item->longitude && item->longitude<root->aa->xmax &&
- root->aa->ymin<=item->latitude && item->latitude<root->aa->ymax
- ) {
- res = quadtree_find_containing_node(root->aa,item);
- }
- else if(
- root->ab &&
- root->ab->xmin<=item->longitude && item->longitude<root->ab->xmax &&
- root->ab->ymin<=item->latitude && item->latitude<root->ab->ymax
- ) {
- res = quadtree_find_containing_node(root->ab,item);
- }
- else if(
- root->ba &&
- root->ba->xmin<=item->longitude && item->longitude<root->ba->xmax &&
- root->ba->ymin<=item->latitude && item->latitude<root->ba->ymax
- ) {
- res = quadtree_find_containing_node(root->ba,item);
- }
- else if(
- root->bb &&
- root->bb->xmin<=item->longitude && item->longitude<root->bb->xmax &&
- root->bb->ymin<=item->latitude && item->latitude<root->bb->ymax
- ) {
- res = quadtree_find_containing_node(root->bb,item);
- }
- else {
- //this should not happen
+ root->aa &&
+ root->aa->xmin<=item->longitude && item->longitude<root->aa->xmax &&
+ root->aa->ymin<=item->latitude && item->latitude<root->aa->ymax
+ ) {
+ res = quadtree_find_containing_node(root->aa,item);
+ } else if(
+ root->ab &&
+ root->ab->xmin<=item->longitude && item->longitude<root->ab->xmax &&
+ root->ab->ymin<=item->latitude && item->latitude<root->ab->ymax
+ ) {
+ res = quadtree_find_containing_node(root->ab,item);
+ } else if(
+ root->ba &&
+ root->ba->xmin<=item->longitude && item->longitude<root->ba->xmax &&
+ root->ba->ymin<=item->latitude && item->latitude<root->ba->ymax
+ ) {
+ res = quadtree_find_containing_node(root->ba,item);
+ } else if(
+ root->bb &&
+ root->bb->xmin<=item->longitude && item->longitude<root->bb->xmax &&
+ root->bb->ymin<=item->latitude && item->latitude<root->bb->ymax
+ ) {
+ res = quadtree_find_containing_node(root->bb,item);
+ } else {
+ //this should not happen
}
}
- return res;
+ return res;
}
-int quadtree_delete_item(struct quadtree_node* root, struct quadtree_item* item)
-{
+int quadtree_delete_item(struct quadtree_node* root, struct quadtree_item* item) {
- struct quadtree_node* qn = quadtree_find_containing_node(root,item);
- int i, bFound=0;
+ struct quadtree_node* qn = quadtree_find_containing_node(root,item);
+ int i, bFound=0;
- if(!qn || !qn->node_num) {
- return 0;
- }
+ if(!qn || !qn->node_num) {
+ return 0;
+ }
- for(i=0;i<qn->node_num;++i) {
- if( qn->items[i] == item) {
- qn->items[i]->deleted=1;
- bFound=1;
+ for(i=0; i<qn->node_num; ++i) {
+ if( qn->items[i] == item) {
+ qn->items[i]->deleted=1;
+ bFound=1;
+ }
}
- }
- return bFound;
+ return bFound;
}
@@ -297,247 +282,240 @@ quadtree_find_nearest(struct quadtree_node* this_, struct quadtree_item* item) {
struct quadtree_item*res = NULL;
double distance_sq = MAX_DOUBLE;
if( ! this_ ) {
- return NULL;
+ return NULL;
}
- if( this_->is_leaf ) {
+ if( this_->is_leaf ) {
int i;
- for(i=0;i<this_->node_num;++i) {
+ for(i=0; i<this_->node_num; ++i) {
double curr_dist_sq = dist_sq(item->longitude,item->latitude,this_->items[i]->longitude,this_->items[i]->latitude);
if(curr_dist_sq<distance_sq) {
distance_sq = curr_dist_sq;
res = this_->items[i];
}
}
- //go up n levels
- if(!res && this_->parent) {
- struct quadtree_item*res2 = NULL;
- struct quadtree_node* anchestor = this_->parent;
- int cnt = 0;
- while (anchestor->parent && cnt<4) {
- anchestor = anchestor->parent;
- ++cnt;
- }
- res2 = quadtree_find_nearest_flood(anchestor,item,distance_sq,NULL);
- if(res2) {
- res = res2;
- }
- }
- } else {
- if(
- this_->aa &&
- this_->aa->xmin<=item->longitude && item->longitude<this_->aa->xmax &&
- this_->aa->ymin<=item->latitude && item->latitude<this_->aa->ymax
- ) {
- res = quadtree_find_nearest(this_->aa,item);
- }
- else if(
- this_->ab &&
- this_->ab->xmin<=item->longitude && item->longitude<this_->ab->xmax &&
- this_->ab->ymin<=item->latitude && item->latitude<this_->ab->ymax
- ) {
- res = quadtree_find_nearest(this_->ab,item);
- }
- else if(
- this_->ba &&
- this_->ba->xmin<=item->longitude && item->longitude<this_->ba->xmax &&
- this_->ba->ymin<=item->latitude && item->latitude<this_->ba->ymax
- ) {
- res = quadtree_find_nearest(this_->ba,item);
- }
- else if(
- this_->bb &&
- this_->bb->xmin<=item->longitude && item->longitude<this_->bb->xmax &&
- this_->bb->ymin<=item->latitude && item->latitude<this_->bb->ymax
- ) {
- res = quadtree_find_nearest(this_->bb,item);
- }
- else {
- if(this_->parent) {
- //go up two levels
- struct quadtree_node* anchestor = this_->parent;
+ //go up n levels
+ if(!res && this_->parent) {
+ struct quadtree_item*res2 = NULL;
+ struct quadtree_node* anchestor = this_->parent;
int cnt = 0;
while (anchestor->parent && cnt<4) {
- anchestor = anchestor->parent;
- ++cnt;
- }
- res = quadtree_find_nearest_flood(anchestor,item,distance_sq,NULL);
+ anchestor = anchestor->parent;
+ ++cnt;
+ }
+ res2 = quadtree_find_nearest_flood(anchestor,item,distance_sq,NULL);
+ if(res2) {
+ res = res2;
+ }
+ }
+ } else {
+ if(
+ this_->aa &&
+ this_->aa->xmin<=item->longitude && item->longitude<this_->aa->xmax &&
+ this_->aa->ymin<=item->latitude && item->latitude<this_->aa->ymax
+ ) {
+ res = quadtree_find_nearest(this_->aa,item);
+ } else if(
+ this_->ab &&
+ this_->ab->xmin<=item->longitude && item->longitude<this_->ab->xmax &&
+ this_->ab->ymin<=item->latitude && item->latitude<this_->ab->ymax
+ ) {
+ res = quadtree_find_nearest(this_->ab,item);
+ } else if(
+ this_->ba &&
+ this_->ba->xmin<=item->longitude && item->longitude<this_->ba->xmax &&
+ this_->ba->ymin<=item->latitude && item->latitude<this_->ba->ymax
+ ) {
+ res = quadtree_find_nearest(this_->ba,item);
+ } else if(
+ this_->bb &&
+ this_->bb->xmin<=item->longitude && item->longitude<this_->bb->xmax &&
+ this_->bb->ymin<=item->latitude && item->latitude<this_->bb->ymax
+ ) {
+ res = quadtree_find_nearest(this_->bb,item);
+ } else {
+ if(this_->parent) {
+ //go up two levels
+ struct quadtree_node* anchestor = this_->parent;
+ int cnt = 0;
+ while (anchestor->parent && cnt<4) {
+ anchestor = anchestor->parent;
+ ++cnt;
+ }
+ res = quadtree_find_nearest_flood(anchestor,item,distance_sq,NULL);
+ }
}
- }
}
- return res;
+ return res;
}
/**
- * @brief Free space occupied by deleted unreferenced items.
+ * @brief Free space occupied by deleted unreferenced items.
* @param node pointer to the quadtree node
* @param iter Quadtree iteration context.
* @return nothing
*/
-void quadtree_node_drop_garbage(struct quadtree_node* node, struct quadtree_iter *iter)
-{
- int i,j;
- int node_num=node->node_num;
- dbg(lvl_debug,"Processing unreferenced subnode children...\n");
- for(i=0,j=0;i<node_num;i++) {
- if(node->items[i]->deleted && !node->items[i]->ref_count) {
- if(iter->item_free) {
- (iter->item_free)(iter->item_free_context, node->items[i]);
- } else {
- g_free(node->items[i]);
- }
- node->node_num--;
- node->items[i]=NULL;
- } else {
- node->items[j++]=node->items[i];
- }
- if(i>j)
- node->items[i]=NULL;
- }
+void quadtree_node_drop_garbage(struct quadtree_node* node, struct quadtree_iter *iter) {
+ int i,j;
+ int node_num=node->node_num;
+ dbg(lvl_debug,"Processing unreferenced subnode children...");
+ for(i=0,j=0; i<node_num; i++) {
+ if(node->items[i]->deleted && !node->items[i]->ref_count) {
+ if(iter->item_free) {
+ (iter->item_free)(iter->item_free_context, node->items[i]);
+ } else {
+ g_free(node->items[i]);
+ }
+ node->node_num--;
+ node->items[i]=NULL;
+ } else {
+ node->items[j++]=node->items[i];
+ }
+ if(i>j)
+ node->items[i]=NULL;
+ }
}
/**
- * @brief Add new node to quadtree.
+ * @brief Add new node to quadtree.
* @param this_ pointer to the quadtree (root) node
* @param item item to add
* @param iter Quadtree iteration context. Can be NULL if no garbage collection is needed.
* @return nothing
*/
-void
-quadtree_add(struct quadtree_node* this_, struct quadtree_item* item, struct quadtree_iter *iter) {
+void quadtree_add(struct quadtree_node* this_, struct quadtree_item* item, struct quadtree_iter *iter) {
if( this_->is_leaf ) {
int bSame = 1;
int i;
-
+
if(iter)
- quadtree_node_drop_garbage(this_, iter);
-
+ quadtree_node_drop_garbage(this_, iter);
+
if(QUADTREE_NODE_CAPACITY-1 == this_->node_num) {
- double lon, lat;
- //avoid infinite recursion when all elements have the same coordinate
- lon = this_->items[0]->longitude;
- lat = this_->items[0]->latitude;
- for(i=1;i<this_->node_num;++i) {
- if (lon != this_->items[i]->longitude || lat != this_->items[i]->latitude) {
- bSame = 0;
- break;
+ double lon, lat;
+ //avoid infinite recursion when all elements have the same coordinate
+ lon = this_->items[0]->longitude;
+ lat = this_->items[0]->latitude;
+ for(i=1; i<this_->node_num; ++i) {
+ if (lon != this_->items[i]->longitude || lat != this_->items[i]->latitude) {
+ bSame = 0;
+ break;
+ }
+ }
+ if (bSame) {
+ //FIXME: memleak and items thrown away if more than QUADTREE_NODE_CAPACITY-1 items with same coordinates added.
+ dbg(lvl_error,"Unable to add another item with same coordinates. Throwing item to the ground. Will leak %p.",item);
+ return;
}
- }
- if (bSame) {
- //FIXME: memleak and items thrown away if more than QUADTREE_NODE_CAPACITY-1 items with same coordinates added.
- dbg(lvl_error,"Unable to add another item with same coordinates. Throwing item to the ground. Will leak %p.\n",item);
- return;
- }
- this_->items[this_->node_num++] = item;
- quadtree_split(this_);
+ this_->items[this_->node_num++] = item;
+ quadtree_split(this_);
} else {
- this_->items[this_->node_num++] = item;
+ this_->items[this_->node_num++] = item;
}
- }
- else {
+ } else {
if(
- this_->xmin<=item->longitude && item->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 &&
- this_->ymin<=item->latitude && item->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0
- ) {
- if(!this_->aa) {
- this_->aa = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0 , this_->ymin, this_->ymin+(this_->ymax-this_->ymin)/2.0 );
- }
- quadtree_add(this_->aa,item,iter);
- }
- else if(
- this_->xmin+(this_->xmax-this_->xmin)/2.0<=item->longitude && item->longitude<this_->xmax &&
- this_->ymin<=item->latitude && item->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0
- ) {
- if(!this_->ab) {
- this_->ab = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax , this_->ymin, this_->ymin+(this_->ymax-this_->ymin)/2.0 );
- }
- quadtree_add(this_->ab,item,iter);
- }
- else if(
- this_->xmin<=item->longitude && item->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 &&
- this_->ymin+(this_->ymax-this_->ymin)/2.0<=item->latitude && item->latitude<this_->ymax
- ) {
- if(!this_->ba) {
- this_->ba = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0 , this_->ymin+(this_->ymax-this_->ymin)/2.0 , this_->ymax);
- }
- quadtree_add(this_->ba,item,iter);
- }
- else if(
- this_->xmin+(this_->xmax-this_->xmin)/2.0<=item->longitude && item->longitude<this_->xmax &&
- this_->ymin+(this_->ymax-this_->ymin)/2.0<=item->latitude && item->latitude<this_->ymax
- ) {
- if(!this_->bb) {
- this_->bb = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax , this_->ymin+(this_->ymax-this_->ymin)/2.0 , this_->ymax);
- }
- quadtree_add(this_->bb,item,iter);
+ this_->xmin<=item->longitude && item->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 &&
+ this_->ymin<=item->latitude && item->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0
+ ) {
+ if(!this_->aa) {
+ this_->aa = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->ymin,
+ this_->ymin+(this_->ymax-this_->ymin)/2.0 );
+ }
+ quadtree_add(this_->aa,item,iter);
+ } else if(
+ this_->xmin+(this_->xmax-this_->xmin)/2.0<=item->longitude && item->longitude<this_->xmax &&
+ this_->ymin<=item->latitude && item->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0
+ ) {
+ if(!this_->ab) {
+ this_->ab = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax, this_->ymin,
+ this_->ymin+(this_->ymax-this_->ymin)/2.0 );
+ }
+ quadtree_add(this_->ab,item,iter);
+ } else if(
+ this_->xmin<=item->longitude && item->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 &&
+ this_->ymin+(this_->ymax-this_->ymin)/2.0<=item->latitude && item->latitude<this_->ymax
+ ) {
+ if(!this_->ba) {
+ this_->ba = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0,
+ this_->ymin+(this_->ymax-this_->ymin)/2.0, this_->ymax);
+ }
+ quadtree_add(this_->ba,item,iter);
+ } else if(
+ this_->xmin+(this_->xmax-this_->xmin)/2.0<=item->longitude && item->longitude<this_->xmax &&
+ this_->ymin+(this_->ymax-this_->ymin)/2.0<=item->latitude && item->latitude<this_->ymax
+ ) {
+ if(!this_->bb) {
+ this_->bb = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax,
+ this_->ymin+(this_->ymax-this_->ymin)/2.0, this_->ymax);
+ }
+ quadtree_add(this_->bb,item,iter);
}
}
}
-void
-quadtree_split(struct quadtree_node* this_) {
+void quadtree_split(struct quadtree_node* this_) {
int i;
this_->is_leaf = 0;
- for(i=0;i<this_->node_num;++i) {
+ for(i=0; i<this_->node_num; ++i) {
if(
- this_->xmin<=this_->items[i]->longitude && this_->items[i]->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 &&
- this_->ymin<=this_->items[i]->latitude && this_->items[i]->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0
- ) {
- if(!this_->aa) {
- this_->aa = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0 , this_->ymin, this_->ymin+(this_->ymax-this_->ymin)/2.0 );
- }
- quadtree_add(this_->aa,this_->items[i],NULL);
- }
- else if(
- this_->xmin+(this_->xmax-this_->xmin)/2.0<=this_->items[i]->longitude && this_->items[i]->longitude<this_->xmax &&
- this_->ymin<=this_->items[i]->latitude && this_->items[i]->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0
- ) {
- if(!this_->ab) {
- this_->ab = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax , this_->ymin, this_->ymin+(this_->ymax-this_->ymin)/2.0 );
- }
- quadtree_add(this_->ab,this_->items[i],NULL);
- }
- else if(
- this_->xmin<=this_->items[i]->longitude && this_->items[i]->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 &&
- this_->ymin+(this_->ymax-this_->ymin)/2.0<=this_->items[i]->latitude && this_->items[i]->latitude<this_->ymax
- ) {
- if(!this_->ba) {
- this_->ba = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0 , this_->ymin+(this_->ymax-this_->ymin)/2.0 , this_->ymax);
- }
- quadtree_add(this_->ba,this_->items[i],NULL);
- }
- else if(
- this_->xmin+(this_->xmax-this_->xmin)/2.0<=this_->items[i]->longitude && this_->items[i]->longitude<this_->xmax &&
- this_->ymin+(this_->ymax-this_->ymin)/2.0<=this_->items[i]->latitude && this_->items[i]->latitude<this_->ymax
- ) {
- if(!this_->bb) {
- this_->bb = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax , this_->ymin+(this_->ymax-this_->ymin)/2.0 , this_->ymax);
- }
- quadtree_add(this_->bb,this_->items[i],NULL);
+ this_->xmin<=this_->items[i]->longitude && this_->items[i]->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 &&
+ this_->ymin<=this_->items[i]->latitude && this_->items[i]->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0
+ ) {
+ if(!this_->aa) {
+ this_->aa = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->ymin,
+ this_->ymin+(this_->ymax-this_->ymin)/2.0 );
+ }
+ quadtree_add(this_->aa,this_->items[i],NULL);
+ } else if(
+ this_->xmin+(this_->xmax-this_->xmin)/2.0<=this_->items[i]->longitude && this_->items[i]->longitude<this_->xmax &&
+ this_->ymin<=this_->items[i]->latitude && this_->items[i]->latitude<this_->ymin+(this_->ymax-this_->ymin)/2.0
+ ) {
+ if(!this_->ab) {
+ this_->ab = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax, this_->ymin,
+ this_->ymin+(this_->ymax-this_->ymin)/2.0 );
+ }
+ quadtree_add(this_->ab,this_->items[i],NULL);
+ } else if(
+ this_->xmin<=this_->items[i]->longitude && this_->items[i]->longitude<this_->xmin+(this_->xmax-this_->xmin)/2.0 &&
+ this_->ymin+(this_->ymax-this_->ymin)/2.0<=this_->items[i]->latitude && this_->items[i]->latitude<this_->ymax
+ ) {
+ if(!this_->ba) {
+ this_->ba = quadtree_node_new( this_, this_->xmin, this_->xmin+(this_->xmax-this_->xmin)/2.0,
+ this_->ymin+(this_->ymax-this_->ymin)/2.0, this_->ymax);
+ }
+ quadtree_add(this_->ba,this_->items[i],NULL);
+ } else if(
+ this_->xmin+(this_->xmax-this_->xmin)/2.0<=this_->items[i]->longitude && this_->items[i]->longitude<this_->xmax &&
+ this_->ymin+(this_->ymax-this_->ymin)/2.0<=this_->items[i]->latitude && this_->items[i]->latitude<this_->ymax
+ ) {
+ if(!this_->bb) {
+ this_->bb = quadtree_node_new( this_, this_->xmin+(this_->xmax-this_->xmin)/2.0, this_->xmax,
+ this_->ymin+(this_->ymax-this_->ymin)/2.0, this_->ymax);
+ }
+ quadtree_add(this_->bb,this_->items[i],NULL);
}
this_->items[i]=NULL;
}
this_->node_num = 0;
}
-void
-quadtree_destroy(struct quadtree_node* this_) {
+void quadtree_destroy(struct quadtree_node* this_) {
if(this_->aa) {
quadtree_destroy(this_->aa);
- this_->aa = NULL;
+ this_->aa = NULL;
}
if(this_->ab) {
quadtree_destroy(this_->ab);
- this_->ab = NULL;
+ this_->ab = NULL;
}
if(this_->ba) {
quadtree_destroy(this_->ba);
- this_->ba = NULL;
+ this_->ba = NULL;
}
if(this_->bb) {
quadtree_destroy(this_->bb);
- this_->bb = NULL;
+ this_->bb = NULL;
}
free(this_);
}
@@ -553,32 +531,32 @@ quadtree_destroy(struct quadtree_node* this_) {
* @param item_free_context data to be passed as a first parameter to item_free function
* @return pointer to the quad tree iteration structure.
*/
-struct quadtree_iter *quadtree_query(struct quadtree_node *this_, double dXMin, double dXMax, double dYMin, double dYMax,void (*item_free)(void *context, struct quadtree_item *qitem), void *item_free_context)
-{
- struct quadtree_iter *ret=g_new0(struct quadtree_iter,1);
- struct quadtree_iter_node *n=g_new0(struct quadtree_iter_node,1);
- ret->xmin=dXMin;
- ret->xmax=dXMax;
- ret->ymin=dYMin;
- ret->ymax=dYMax;
- dbg(lvl_debug,"%f %f %f %f\n",dXMin,dXMax,dYMin,dYMax)
- ret->item_free=item_free;
- ret->item_free_context=item_free_context;
- n->node=this_;
- ret->iter_nodes=g_list_prepend(ret->iter_nodes,n);
- n->is_leaf=this_->is_leaf;
- if(this_->is_leaf) {
- int i;
- n->node_num=this_->node_num;
- for(i=0;i<n->node_num;i++) {
- n->items[i]=this_->items[i];
- n->items[i]->ref_count++;
- }
- }
-
- this_->ref_count++;
- dbg(lvl_debug,"Query %p \n",this_)
- return ret;
+struct quadtree_iter *quadtree_query(struct quadtree_node *this_, double dXMin, double dXMax, double dYMin,
+ double dYMax,void (*item_free)(void *context, struct quadtree_item *qitem), void *item_free_context) {
+ struct quadtree_iter *ret=g_new0(struct quadtree_iter,1);
+ struct quadtree_iter_node *n=g_new0(struct quadtree_iter_node,1);
+ ret->xmin=dXMin;
+ ret->xmax=dXMax;
+ ret->ymin=dYMin;
+ ret->ymax=dYMax;
+ dbg(lvl_debug,"%f %f %f %f",dXMin,dXMax,dYMin,dYMax)
+ ret->item_free=item_free;
+ ret->item_free_context=item_free_context;
+ n->node=this_;
+ ret->iter_nodes=g_list_prepend(ret->iter_nodes,n);
+ n->is_leaf=this_->is_leaf;
+ if(this_->is_leaf) {
+ int i;
+ n->node_num=this_->node_num;
+ for(i=0; i<n->node_num; i++) {
+ n->items[i]=this_->items[i];
+ n->items[i]->ref_count++;
+ }
+ }
+
+ this_->ref_count++;
+ dbg(lvl_debug,"Query %p ",this_)
+ return ret;
}
@@ -586,12 +564,11 @@ struct quadtree_iter *quadtree_query(struct quadtree_node *this_, double dXMin,
* @brief End iteration.
* @param iter Pointer to the quadtree iteration structure.
*/
-void quadtree_query_free(struct quadtree_iter *iter)
-{
- //Get the rest of the data to collect garbage and dereference all the items/nodes
- //TODO: No need to iterate the whole tree here. Just dereference nodes/items (if any).
- while(quadtree_item_next(iter));
- g_free(iter);
+void quadtree_query_free(struct quadtree_iter *iter) {
+ //Get the rest of the data to collect garbage and dereference all the items/nodes
+ //TODO: No need to iterate the whole tree here. Just dereference nodes/items (if any).
+ while(quadtree_item_next(iter));
+ g_free(iter);
}
@@ -599,10 +576,9 @@ void quadtree_query_free(struct quadtree_iter *iter)
* @brief Mark current item of iterator for deletion.
* @param iter Pointer to the quadtree iteration structure.
*/
-void quadtree_item_delete(struct quadtree_iter *iter)
-{
- if(iter->item)
- iter->item->deleted=1;
+void quadtree_item_delete(struct quadtree_iter *iter) {
+ if(iter->item)
+ iter->item->deleted=1;
}
/*
@@ -610,118 +586,119 @@ void quadtree_item_delete(struct quadtree_iter *iter)
* @param iter Pointer to the quadtree iteration structure.
* @return pointer to the next item, or NULL if no items are left.
*/
-struct quadtree_item * quadtree_item_next(struct quadtree_iter *iter)
-{
- struct quadtree_iter_node *iter_node;
- struct quadtree_node *subnode;
-
- if(iter->item) {
- iter->item->ref_count--;
- iter->item=NULL;
- }
-
- while(iter->iter_nodes) {
- struct quadtree_node *nodes[4];
- int i;
- iter_node=iter->iter_nodes->data;
-
- if(iter_node->is_leaf) {
- /* Try to find undeleted item in the current node */
- dbg(lvl_debug,"find item %p %p ...\n",iter->iter_nodes,iter->iter_nodes->data);
- while(iter_node->item<iter_node->node_num) {
- dbg(lvl_debug,"%d %d\n",iter_node->item,iter_node->items[iter_node->item]->deleted);
- if(iter_node->items[iter_node->item]->deleted) {
- iter_node->item++;
- continue;
- }
- iter->item=iter_node->items[iter_node->item];
- iter_node->item++;
- dbg(lvl_debug,"Returning %p\n",iter->item);
- iter->item->ref_count++;
- return iter->item;
- }
- for(i=0;i<iter_node->node_num;i++) {
- iter_node->items[i]->ref_count--;
- }
- } else {
- /* No items left, try to find non-empty subnode */
- nodes[0]=iter_node->node->aa;
- nodes[1]=iter_node->node->ab;
- nodes[2]=iter_node->node->ba;
- nodes[3]=iter_node->node->bb;
-
- for(subnode=NULL;!subnode && iter_node->subnode<4;iter_node->subnode++) {
- i=iter_node->subnode;
- if(!nodes[i] || !rects_overlap(nodes[i]->xmin, nodes[i]->ymin, nodes[i]->xmax, nodes[i]->ymax, iter->xmin, iter->ymin, iter->xmax, iter->ymax))
- continue;
- dbg(lvl_debug,"%f %f %f %f\n",nodes[i]->xmin, nodes[i]->xmax, nodes[i]->ymin, nodes[i]->ymax)
- subnode=nodes[i];
- }
-
- if(subnode) {
- /* Go one level deeper */
- dbg(lvl_debug,"Go one level deeper...\n");
- iter_node=g_new0(struct quadtree_iter_node, 1);
- iter_node->node=subnode;
- iter_node->is_leaf=subnode->is_leaf;
- if(iter_node->is_leaf) {
- int i;
- iter_node->node_num=subnode->node_num;
- for(i=0;i<iter_node->node_num;i++) {
- iter_node->items[i]=subnode->items[i];
- iter_node->items[i]->ref_count++;
- }
- }
- subnode->ref_count++;
- iter->iter_nodes=g_list_prepend(iter->iter_nodes,iter_node);
- continue;
- }
- }
-
- /* No nodes and items left, fix up current subnode... */
- iter_node=iter->iter_nodes->data;
- subnode=iter_node->node;
- subnode->ref_count--;
-
- if(!subnode->aa && !subnode->ab && !subnode->ba && !subnode->bb)
- subnode->is_leaf=1;
-
- /* 1. free deleted unreferenced items */
- quadtree_node_drop_garbage(subnode, iter);
-
- /* 2. remove empty leaf subnode if it's unreferenced */
-
- if(!subnode->ref_count && !subnode->node_num && subnode->is_leaf ) {
- dbg(lvl_debug,"Going to delete an empty unreferenced leaf subnode...\n");
-
- if(subnode->parent) {
- if(subnode->parent->aa==subnode) {
- subnode->parent->aa=NULL;
- } else if(subnode->parent->ab==subnode) {
- subnode->parent->ab=NULL;
- } else if(subnode->parent->ba==subnode) {
- subnode->parent->ba=NULL;
- } else if(subnode->parent->bb==subnode) {
- subnode->parent->bb=NULL;
- } else {
- dbg(lvl_error,"Found Quadtree structure corruption while trying to free an empty node.\n");
- }
-
- if(!subnode->parent->aa && !subnode->parent->ab && !subnode->parent->ba && !subnode->parent->bb )
- subnode->parent->is_leaf=1;
- g_free(subnode);
- } else
- dbg(lvl_debug,"Quadtree is empty. NOT deleting the root subnode...\n");
-
- }
-
- /* Go one step towards root */
- dbg(lvl_info,"Going towards root...\n");
- g_free(iter->iter_nodes->data);
- iter->iter_nodes=g_list_delete_link(iter->iter_nodes,iter->iter_nodes);
- }
-
- iter->item=NULL;
- return NULL;
+struct quadtree_item * quadtree_item_next(struct quadtree_iter *iter) {
+ struct quadtree_iter_node *iter_node;
+ struct quadtree_node *subnode;
+
+ if(iter->item) {
+ iter->item->ref_count--;
+ iter->item=NULL;
+ }
+
+ while(iter->iter_nodes) {
+ struct quadtree_node *nodes[4];
+ int i;
+ iter_node=iter->iter_nodes->data;
+
+ if(iter_node->is_leaf) {
+ /* Try to find undeleted item in the current node */
+ dbg(lvl_debug,"find item %p %p ...",iter->iter_nodes,iter->iter_nodes->data);
+ while(iter_node->item<iter_node->node_num) {
+ dbg(lvl_debug,"%d %d",iter_node->item,iter_node->items[iter_node->item]->deleted);
+ if(iter_node->items[iter_node->item]->deleted) {
+ iter_node->item++;
+ continue;
+ }
+ iter->item=iter_node->items[iter_node->item];
+ iter_node->item++;
+ dbg(lvl_debug,"Returning %p",iter->item);
+ iter->item->ref_count++;
+ return iter->item;
+ }
+ for(i=0; i<iter_node->node_num; i++) {
+ iter_node->items[i]->ref_count--;
+ }
+ } else {
+ /* No items left, try to find non-empty subnode */
+ nodes[0]=iter_node->node->aa;
+ nodes[1]=iter_node->node->ab;
+ nodes[2]=iter_node->node->ba;
+ nodes[3]=iter_node->node->bb;
+
+ for(subnode=NULL; !subnode && iter_node->subnode<4; iter_node->subnode++) {
+ i=iter_node->subnode;
+ if(!nodes[i]
+ || !rects_overlap(nodes[i]->xmin, nodes[i]->ymin, nodes[i]->xmax, nodes[i]->ymax, iter->xmin, iter->ymin, iter->xmax,
+ iter->ymax))
+ continue;
+ dbg(lvl_debug,"%f %f %f %f",nodes[i]->xmin, nodes[i]->xmax, nodes[i]->ymin, nodes[i]->ymax)
+ subnode=nodes[i];
+ }
+
+ if(subnode) {
+ /* Go one level deeper */
+ dbg(lvl_debug,"Go one level deeper...");
+ iter_node=g_new0(struct quadtree_iter_node, 1);
+ iter_node->node=subnode;
+ iter_node->is_leaf=subnode->is_leaf;
+ if(iter_node->is_leaf) {
+ int i;
+ iter_node->node_num=subnode->node_num;
+ for(i=0; i<iter_node->node_num; i++) {
+ iter_node->items[i]=subnode->items[i];
+ iter_node->items[i]->ref_count++;
+ }
+ }
+ subnode->ref_count++;
+ iter->iter_nodes=g_list_prepend(iter->iter_nodes,iter_node);
+ continue;
+ }
+ }
+
+ /* No nodes and items left, fix up current subnode... */
+ iter_node=iter->iter_nodes->data;
+ subnode=iter_node->node;
+ subnode->ref_count--;
+
+ if(!subnode->aa && !subnode->ab && !subnode->ba && !subnode->bb)
+ subnode->is_leaf=1;
+
+ /* 1. free deleted unreferenced items */
+ quadtree_node_drop_garbage(subnode, iter);
+
+ /* 2. remove empty leaf subnode if it's unreferenced */
+
+ if(!subnode->ref_count && !subnode->node_num && subnode->is_leaf ) {
+ dbg(lvl_debug,"Going to delete an empty unreferenced leaf subnode...");
+
+ if(subnode->parent) {
+ if(subnode->parent->aa==subnode) {
+ subnode->parent->aa=NULL;
+ } else if(subnode->parent->ab==subnode) {
+ subnode->parent->ab=NULL;
+ } else if(subnode->parent->ba==subnode) {
+ subnode->parent->ba=NULL;
+ } else if(subnode->parent->bb==subnode) {
+ subnode->parent->bb=NULL;
+ } else {
+ dbg(lvl_error,"Found Quadtree structure corruption while trying to free an empty node.");
+ }
+
+ if(!subnode->parent->aa && !subnode->parent->ab && !subnode->parent->ba && !subnode->parent->bb )
+ subnode->parent->is_leaf=1;
+ g_free(subnode);
+ } else
+ dbg(lvl_debug,"Quadtree is empty. NOT deleting the root subnode...");
+
+ }
+
+ /* Go one step towards root */
+ dbg(lvl_info,"Going towards root...");
+ g_free(iter->iter_nodes->data);
+ iter->iter_nodes=g_list_delete_link(iter->iter_nodes,iter->iter_nodes);
+ }
+
+ iter->item=NULL;
+ return NULL;
}
diff --git a/navit/map/csv/quadtree.h b/navit/map/csv/quadtree.h
index 389339456..ab96a97ac 100644
--- a/navit/map/csv/quadtree.h
+++ b/navit/map/csv/quadtree.h
@@ -45,7 +45,7 @@ struct quadtree_node {
int ref_count;
};
-struct quadtree_iter;
+struct quadtree_iter;
struct quadtree_node* quadtree_node_new(struct quadtree_node* parent, double xmin, double xmax, double ymin, double ymax );
struct quadtree_item* quadtree_find_nearest_flood(struct quadtree_node* this_, struct quadtree_item* item, double current_max, struct quadtree_node* toSkip);
diff --git a/navit/map/filter/CMakeLists.txt b/navit/map/filter/CMakeLists.txt
index 15da3f3c6..7ea4221a5 100644
--- a/navit/map/filter/CMakeLists.txt
+++ b/navit/map/filter/CMakeLists.txt
@@ -1 +1 @@
-module_add_library(map_filter filter.c)
+module_add_library(map_filter filter.c)
diff --git a/navit/map/filter/filter.c b/navit/map/filter/filter.c
index cecae7fc0..8d46db564 100644
--- a/navit/map/filter/filter.c
+++ b/navit/map/filter/filter.c
@@ -38,398 +38,358 @@
#include "endianess.h"
struct filter_entry {
- enum item_type first,last;
- enum attr_type cond_attr;
- char *cond_str;
+ enum item_type first,last;
+ enum attr_type cond_attr;
+ char *cond_str;
};
struct filter {
- GList *old;
- GList *new;
+ GList *old;
+ GList *new;
};
struct map_priv {
- struct map *parent;
- GList *filters;
+ struct map *parent;
+ GList *filters;
};
struct map_rect_priv {
- struct map_selection *sel;
- struct map_priv *m;
- struct map_rect *parent;
- struct item item,*parent_item;
+ struct map_selection *sel;
+ struct map_priv *m;
+ struct map_rect *parent;
+ struct item item,*parent_item;
};
struct map_search_priv {
- struct map_rect_priv *mr;
+ struct map_rect_priv *mr;
};
-static enum item_type
-filter_type(struct map_priv *m, struct item *item)
-{
- GList *filters=m->filters;
- struct filter_entry *entry;
- while (filters) {
- struct filter *filter=filters->data;
- int pos=0,count=0;
- GList *old,*new;
- old=filter->old;
- while (old) {
- entry=old->data;
- if (item->type >= entry->first && item->type <= entry->last)
- break;
- pos+=entry->last-entry->first+1;
- old=g_list_next(old);
- }
- if (old && entry && entry->cond_attr != attr_none) {
- struct attr attr;
- if (entry->cond_attr == attr_id) {
- char idstr[64];
- sprintf(idstr,"0x%x 0x%x",item->id_hi,item->id_lo);
- if (strcmp(entry->cond_str, idstr))
- old=NULL;
- } else if (!item_attr_get(item, entry->cond_attr, &attr)) {
- old=NULL;
- } else {
- char *wildcard=strchr(entry->cond_str,'*');
- int len;
- if (!wildcard)
- len=strlen(entry->cond_str)+1;
- else
- len=wildcard-entry->cond_str;
- if (strncmp(entry->cond_str, attr.u.str, len))
- old=NULL;
- }
- item_attr_rewind(item);
- }
- if (old) {
- new=filter->new;
- if (!new)
- return item->type;
- while (new) {
- struct filter_entry *entry=new->data;
- count+=entry->last-entry->first+1;
- new=g_list_next(new);
- }
- pos%=count;
- new=filter->new;
- while (new) {
- struct filter_entry *entry=new->data;
- if (pos <= entry->last-entry->first)
- return entry->first+pos;
- pos-=entry->last-entry->first+1;
- new=g_list_next(new);
- }
- }
- filters=g_list_next(filters);
- }
- return item->type;
+static enum item_type filter_type(struct map_priv *m, struct item *item) {
+ GList *filters=m->filters;
+ struct filter_entry *entry;
+ while (filters) {
+ struct filter *filter=filters->data;
+ int pos=0,count=0;
+ GList *old,*new;
+ old=filter->old;
+ while (old) {
+ entry=old->data;
+ if (item->type >= entry->first && item->type <= entry->last)
+ break;
+ pos+=entry->last-entry->first+1;
+ old=g_list_next(old);
+ }
+ if (old && entry && entry->cond_attr != attr_none) {
+ struct attr attr;
+ if (entry->cond_attr == attr_id) {
+ char idstr[64];
+ sprintf(idstr,"0x%x 0x%x",item->id_hi,item->id_lo);
+ if (strcmp(entry->cond_str, idstr))
+ old=NULL;
+ } else if (!item_attr_get(item, entry->cond_attr, &attr)) {
+ old=NULL;
+ } else {
+ char *wildcard=strchr(entry->cond_str,'*');
+ int len;
+ if (!wildcard)
+ len=strlen(entry->cond_str)+1;
+ else
+ len=wildcard-entry->cond_str;
+ if (strncmp(entry->cond_str, attr.u.str, len))
+ old=NULL;
+ }
+ item_attr_rewind(item);
+ }
+ if (old) {
+ new=filter->new;
+ if (!new)
+ return item->type;
+ while (new) {
+ struct filter_entry *entry=new->data;
+ count+=entry->last-entry->first+1;
+ new=g_list_next(new);
+ }
+ pos%=count;
+ new=filter->new;
+ while (new) {
+ struct filter_entry *entry=new->data;
+ if (pos <= entry->last-entry->first)
+ return entry->first+pos;
+ pos-=entry->last-entry->first+1;
+ new=g_list_next(new);
+ }
+ }
+ filters=g_list_next(filters);
+ }
+ return item->type;
}
-static void
-free_filter_entry(struct filter_entry *filter)
-{
- g_free(filter->cond_str);
- g_free(filter);
+static void free_filter_entry(struct filter_entry *filter) {
+ g_free(filter->cond_str);
+ g_free(filter);
}
-static void
-free_filter(struct filter *filter)
-{
- g_list_foreach(filter->old, (GFunc)free_filter_entry, NULL);
- g_list_free(filter->old);
- filter->old=NULL;
- g_list_foreach(filter->new, (GFunc)free_filter_entry, NULL);
- g_list_free(filter->new);
- filter->new=NULL;
+static void free_filter(struct filter *filter) {
+ g_list_foreach(filter->old, (GFunc)free_filter_entry, NULL);
+ g_list_free(filter->old);
+ filter->old=NULL;
+ g_list_foreach(filter->new, (GFunc)free_filter_entry, NULL);
+ g_list_free(filter->new);
+ filter->new=NULL;
}
-static void
-free_filters(struct map_priv *m)
-{
- g_list_foreach(m->filters, (GFunc)free_filter, NULL);
- g_list_free(m->filters);
- m->filters=NULL;
+static void free_filters(struct map_priv *m) {
+ g_list_foreach(m->filters, (GFunc)free_filter, NULL);
+ g_list_free(m->filters);
+ m->filters=NULL;
}
-static GList *
-parse_filter(char *filter)
-{
- GList *ret=NULL;
- for (;;) {
- char *condition,*range,*next=strchr(filter,',');
- struct filter_entry *entry=g_new0(struct filter_entry, 1);
- if (next)
- *next++='\0';
- condition=strchr(filter,'[');
- if (condition)
- *condition++='\0';
- range=strchr(filter,'-');
- if (range)
- *range++='\0';
- if (!strcmp(filter,"*") && !range) {
- entry->first=type_none;
- entry->last=type_last;
- } else {
- entry->first=item_from_name(filter);
- if (range)
- entry->last=item_from_name(range);
- else
- entry->last=entry->first;
- }
- if (condition) {
- char *end=strchr(condition,']');
- char *eq=strchr(condition,'=');
- if (end && eq && eq < end) {
- *end='\0';
- *eq++='\0';
- if (eq[0] == '"' || eq[0] == '\'') {
- char *quote=strchr(eq+1,eq[0]);
- if (quote) {
- eq++;
- *quote='\0';
- }
- }
- entry->cond_attr=attr_from_name(condition);
- entry->cond_str=g_strdup(eq);
- }
- }
- ret=g_list_append(ret, entry);
- if (!next)
- break;
- filter=next;
- }
- return ret;
+static GList *parse_filter(char *filter) {
+ GList *ret=NULL;
+ for (;;) {
+ char *condition,*range,*next=strchr(filter,',');
+ struct filter_entry *entry=g_new0(struct filter_entry, 1);
+ if (next)
+ *next++='\0';
+ condition=strchr(filter,'[');
+ if (condition)
+ *condition++='\0';
+ range=strchr(filter,'-');
+ if (range)
+ *range++='\0';
+ if (!strcmp(filter,"*") && !range) {
+ entry->first=type_none;
+ entry->last=type_last;
+ } else {
+ entry->first=item_from_name(filter);
+ if (range)
+ entry->last=item_from_name(range);
+ else
+ entry->last=entry->first;
+ }
+ if (condition) {
+ char *end=strchr(condition,']');
+ char *eq=strchr(condition,'=');
+ if (end && eq && eq < end) {
+ *end='\0';
+ *eq++='\0';
+ if (eq[0] == '"' || eq[0] == '\'') {
+ char *quote=strchr(eq+1,eq[0]);
+ if (quote) {
+ eq++;
+ *quote='\0';
+ }
+ }
+ entry->cond_attr=attr_from_name(condition);
+ entry->cond_str=g_strdup(eq);
+ }
+ }
+ ret=g_list_append(ret, entry);
+ if (!next)
+ break;
+ filter=next;
+ }
+ return ret;
}
-static void
-parse_filters(struct map_priv *m, char *filter)
-{
- char *filter_copy=g_strdup(filter);
- char *str=filter_copy;
-
- free_filters(m);
- for (;;) {
- char *pos,*bracket,*eq,*next=strchr(str,';');
- struct filter *filter=g_new0(struct filter, 1);
- if (next)
- *next++='\0';
- pos=str;
- for (;;) {
- eq=strchr(pos,'=');
- if (eq) {
- bracket=strchr(pos,'[');
- if (bracket && bracket < eq) {
- bracket=strchr(pos,']');
- if (bracket)
- pos=bracket+1;
- else {
- eq=NULL;
- break;
- }
- } else {
- *eq++='\0';
- break;
- }
- } else
- break;
- }
- filter->old=parse_filter(str);
- if (eq)
- filter->new=parse_filter(eq);
- m->filters=g_list_append(m->filters,filter);
- if (!next)
- break;
- str=next;
- }
- g_free(filter_copy);
+static void parse_filters(struct map_priv *m, char *filter) {
+ char *filter_copy=g_strdup(filter);
+ char *str=filter_copy;
+
+ free_filters(m);
+ for (;;) {
+ char *pos,*bracket,*eq,*next=strchr(str,';');
+ struct filter *filter=g_new0(struct filter, 1);
+ if (next)
+ *next++='\0';
+ pos=str;
+ for (;;) {
+ eq=strchr(pos,'=');
+ if (eq) {
+ bracket=strchr(pos,'[');
+ if (bracket && bracket < eq) {
+ bracket=strchr(pos,']');
+ if (bracket)
+ pos=bracket+1;
+ else {
+ eq=NULL;
+ break;
+ }
+ } else {
+ *eq++='\0';
+ break;
+ }
+ } else
+ break;
+ }
+ filter->old=parse_filter(str);
+ if (eq)
+ filter->new=parse_filter(eq);
+ m->filters=g_list_append(m->filters,filter);
+ if (!next)
+ break;
+ str=next;
+ }
+ g_free(filter_copy);
}
-static void
-map_filter_coord_rewind(void *priv_data)
-{
- struct map_rect_priv *mr=priv_data;
- item_coord_rewind(mr->parent_item);
+static void map_filter_coord_rewind(void *priv_data) {
+ struct map_rect_priv *mr=priv_data;
+ item_coord_rewind(mr->parent_item);
}
-static int
-map_filter_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr=priv_data;
- return item_coord_get(mr->parent_item, c, count);
+static int map_filter_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr=priv_data;
+ return item_coord_get(mr->parent_item, c, count);
}
-static void
-map_filter_attr_rewind(void *priv_data)
-{
- struct map_rect_priv *mr=priv_data;
- item_attr_rewind(mr->parent_item);
+static void map_filter_attr_rewind(void *priv_data) {
+ struct map_rect_priv *mr=priv_data;
+ item_attr_rewind(mr->parent_item);
}
-static int
-map_filter_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr=priv_data;
- return item_attr_get(mr->parent_item, attr_type, attr);
+static int map_filter_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr=priv_data;
+ return item_attr_get(mr->parent_item, attr_type, attr);
}
static struct item_methods methods_filter = {
- map_filter_coord_rewind,
- map_filter_coord_get,
- map_filter_attr_rewind,
- map_filter_attr_get,
+ map_filter_coord_rewind,
+ map_filter_coord_get,
+ map_filter_attr_rewind,
+ map_filter_attr_get,
};
-static struct map_rect_priv *
-map_filter_rect_new(struct map_priv *map, struct map_selection *sel)
-{
- struct map_rect_priv *mr=NULL;
- struct map_rect *parent;
- parent=map_rect_new(map->parent, sel);
- if (parent) {
- mr=g_new0(struct map_rect_priv, 1);
- mr->m=map;
- mr->sel=sel;
- mr->parent=parent;
- mr->item.meth=&methods_filter;
- mr->item.priv_data=mr;
- }
- return mr;
+static struct map_rect_priv *map_filter_rect_new(struct map_priv *map, struct map_selection *sel) {
+ struct map_rect_priv *mr=NULL;
+ struct map_rect *parent;
+ parent=map_rect_new(map->parent, sel);
+ if (parent) {
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->m=map;
+ mr->sel=sel;
+ mr->parent=parent;
+ mr->item.meth=&methods_filter;
+ mr->item.priv_data=mr;
+ }
+ return mr;
}
-static void
-map_filter_rect_destroy(struct map_rect_priv *mr)
-{
- map_rect_destroy(mr->parent);
- g_free(mr);
+static void map_filter_rect_destroy(struct map_rect_priv *mr) {
+ map_rect_destroy(mr->parent);
+ g_free(mr);
}
-static struct item *
-map_filter_rect_get_item(struct map_rect_priv *mr)
-{
- mr->parent_item=map_rect_get_item(mr->parent);
- if (!mr->parent_item)
- return NULL;
- mr->item.type=filter_type(mr->m,mr->parent_item);
- mr->item.id_lo=mr->parent_item->id_lo;
- mr->item.id_hi=mr->parent_item->id_hi;
- return &mr->item;
+static struct item *map_filter_rect_get_item(struct map_rect_priv *mr) {
+ mr->parent_item=map_rect_get_item(mr->parent);
+ if (!mr->parent_item)
+ return NULL;
+ mr->item.type=filter_type(mr->m,mr->parent_item);
+ mr->item.id_lo=mr->parent_item->id_lo;
+ mr->item.id_hi=mr->parent_item->id_hi;
+ return &mr->item;
}
-static struct item *
-map_filter_rect_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- dbg(lvl_debug,"enter\n");
- mr->parent_item=map_rect_get_item_byid(mr->parent, id_hi, id_lo);
- if (!mr->parent_item)
- return NULL;
- mr->item.type=filter_type(mr->m,mr->parent_item);
- mr->item.id_lo=mr->parent_item->id_lo;
- mr->item.id_hi=mr->parent_item->id_hi;
- return &mr->item;
+static struct item *map_filter_rect_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ dbg(lvl_debug,"enter");
+ mr->parent_item=map_rect_get_item_byid(mr->parent, id_hi, id_lo);
+ if (!mr->parent_item)
+ return NULL;
+ mr->item.type=filter_type(mr->m,mr->parent_item);
+ mr->item.id_lo=mr->parent_item->id_lo;
+ mr->item.id_hi=mr->parent_item->id_hi;
+ return &mr->item;
}
-static struct map_search_priv *
-map_filter_search_new(struct map_priv *map, struct item *item, struct attr *search, int partial)
-{
- dbg(lvl_debug,"enter\n");
- return NULL;
+static struct map_search_priv *map_filter_search_new(struct map_priv *map, struct item *item, struct attr *search,
+ int partial) {
+ dbg(lvl_debug,"enter");
+ return NULL;
}
-static struct item *
-map_filter_search_get_item(struct map_search_priv *map_search)
-{
- dbg(lvl_debug,"enter\n");
- return NULL;
+static struct item *map_filter_search_get_item(struct map_search_priv *map_search) {
+ dbg(lvl_debug,"enter");
+ return NULL;
}
-static void
-map_filter_search_destroy(struct map_search_priv *ms)
-{
- dbg(lvl_debug,"enter\n");
+static void map_filter_search_destroy(struct map_search_priv *ms) {
+ dbg(lvl_debug,"enter");
}
-static void
-map_filter_destroy(struct map_priv *m)
-{
- map_destroy(m->parent);
- g_free(m);
+static void map_filter_destroy(struct map_priv *m) {
+ map_destroy(m->parent);
+ g_free(m);
}
-static int
-map_filter_set_attr(struct map_priv *m, struct attr *attr)
-{
- switch (attr->type) {
- case attr_filter:
- parse_filters(m,attr->u.str);
- return 1;
- default:
- return 0;
- }
+static int map_filter_set_attr(struct map_priv *m, struct attr *attr) {
+ switch (attr->type) {
+ case attr_filter:
+ parse_filters(m,attr->u.str);
+ return 1;
+ default:
+ return 0;
+ }
}
static struct map_methods map_methods_filter = {
- projection_mg,
- "utf-8",
- map_filter_destroy,
- map_filter_rect_new,
- map_filter_rect_destroy,
- map_filter_rect_get_item,
- map_filter_rect_get_item_byid,
- map_filter_search_new,
- map_filter_search_destroy,
- map_filter_search_get_item,
- NULL,
- NULL,
- map_filter_set_attr,
+ projection_mg,
+ "utf-8",
+ map_filter_destroy,
+ map_filter_rect_new,
+ map_filter_rect_destroy,
+ map_filter_rect_get_item,
+ map_filter_rect_get_item_byid,
+ map_filter_search_new,
+ map_filter_search_destroy,
+ map_filter_search_get_item,
+ NULL,
+ NULL,
+ map_filter_set_attr,
};
-static struct map_priv *
-map_filter_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct map_priv *m=NULL;
- struct attr **parent_attrs,type,*subtype=attr_search(attrs, NULL, attr_subtype),*filter=attr_search(attrs, NULL, attr_filter);
- struct map *map;
- int i,j;
- if (! subtype || !filter)
- return NULL;
- i=0;
- while (attrs[i])
- i++;
- parent_attrs=g_new(struct attr *,i+1);
- i=0;
- j=0;
- while (attrs[i]) {
- if (attrs[i]->type != attr_filter && attrs[i]->type != attr_type) {
- if (attrs[i]->type == attr_subtype) {
- type=*attrs[i];
- type.type = attr_type;
- parent_attrs[j]=&type;
- } else
- parent_attrs[j]=attrs[i];
- j++;
- }
- i++;
- }
- parent_attrs[j]=NULL;
- *meth=map_methods_filter;
- map=map_new(NULL, parent_attrs);
- if (map) {
- m=g_new0(struct map_priv, 1);
- m->parent=map;
- parse_filters(m,filter->u.str);
- }
- g_free(parent_attrs);
- return m;
+static struct map_priv *map_filter_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *m=NULL;
+ struct attr **parent_attrs,type,*subtype=attr_search(attrs, NULL, attr_subtype),*filter=attr_search(attrs, NULL,
+ attr_filter);
+ struct map *map;
+ int i,j;
+ if (! subtype || !filter)
+ return NULL;
+ i=0;
+ while (attrs[i])
+ i++;
+ parent_attrs=g_new(struct attr *,i+1);
+ i=0;
+ j=0;
+ while (attrs[i]) {
+ if (attrs[i]->type != attr_filter && attrs[i]->type != attr_type) {
+ if (attrs[i]->type == attr_subtype) {
+ type=*attrs[i];
+ type.type = attr_type;
+ parent_attrs[j]=&type;
+ } else
+ parent_attrs[j]=attrs[i];
+ j++;
+ }
+ i++;
+ }
+ parent_attrs[j]=NULL;
+ *meth=map_methods_filter;
+ map=map_new(NULL, parent_attrs);
+ if (map) {
+ m=g_new0(struct map_priv, 1);
+ m->parent=map;
+ parse_filters(m,filter->u.str);
+ }
+ g_free(parent_attrs);
+ return m;
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug,"filter: plugin_init\n");
- plugin_register_category_map("filter", map_filter_new);
+void plugin_init(void) {
+ dbg(lvl_debug,"filter: plugin_init");
+ plugin_register_category_map("filter", map_filter_new);
}
diff --git a/navit/map/garmin/CMakeLists.txt b/navit/map/garmin/CMakeLists.txt
index b52c8c577..b60128a9c 100644
--- a/navit/map/garmin/CMakeLists.txt
+++ b/navit/map/garmin/CMakeLists.txt
@@ -4,9 +4,9 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR})
# add the command to generate the source code
add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/g2nbuiltin.h
- COMMAND gentypes ${CMAKE_CURRENT_SOURCE_DIR}/garmintypes.txt ${CMAKE_CURRENT_BINARY_DIR}/g2nbuiltin.h
- DEPENDS gentypes
- )
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/g2nbuiltin.h
+ COMMAND gentypes ${CMAKE_CURRENT_SOURCE_DIR}/garmintypes.txt ${CMAKE_CURRENT_BINARY_DIR}/g2nbuiltin.h
+ DEPENDS gentypes
+ )
module_add_library(map_garmin garmin.c gar2navit.c g2nbuiltin.h)
diff --git a/navit/map/garmin/gar2navit.c b/navit/map/garmin/gar2navit.c
index 7c4450401..703895b69 100644
--- a/navit/map/garmin/gar2navit.c
+++ b/navit/map/garmin/gar2navit.c
@@ -12,9 +12,9 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
-
+
Garmin and MapSource are registered trademarks or trademarks
of Garmin Ltd. or one of its subsidiaries.
@@ -54,165 +54,159 @@ GROUP is
#include "gar2navit.h"
static int add_def(struct gar2nav_conv *conv, int type, unsigned short minid,
- unsigned short maxid, unsigned int group, char *ntype,
- char *descr)
-{
- enum item_type it;
- struct gar2navit *g2n;
- dlog(11, "group=%d type=%d routable=%u min=%04X max=%04X ntype=%s descr=%s\n",
- group, type, minid, maxid, ntype, descr);
- it = item_from_name(ntype);
- if (it==type_none) {
- dlog(1, "Please define: %s\n", ntype);
- }
- g2n = calloc(1, sizeof(*g2n));
- if (!g2n)
- return -1;
- g2n->id = minid;
- g2n->maxid = maxid;
- g2n->ntype = it;
- g2n->descr = strdup(descr);
- g2n->group = group;
- if (type == 1) {
- g2n->next = conv->points;
- conv->points = g2n;
- } else if (type == 2) {
- g2n->next = conv->polylines;
- conv->polylines = g2n;
- } else if (type == 3) {
- g2n->next = conv->polygons;
- conv->polygons = g2n;
- }
- return 0;
+ unsigned short maxid, unsigned int group, char *ntype,
+ char *descr) {
+ enum item_type it;
+ struct gar2navit *g2n;
+ dlog(11, "group=%d type=%d routable=%u min=%04X max=%04X ntype=%s descr=%s\n",
+ group, type, minid, maxid, ntype, descr);
+ it = item_from_name(ntype);
+ if (it==type_none) {
+ dlog(1, "Please define: %s\n", ntype);
+ }
+ g2n = calloc(1, sizeof(*g2n));
+ if (!g2n)
+ return -1;
+ g2n->id = minid;
+ g2n->maxid = maxid;
+ g2n->ntype = it;
+ g2n->descr = strdup(descr);
+ g2n->group = group;
+ if (type == 1) {
+ g2n->next = conv->points;
+ conv->points = g2n;
+ } else if (type == 2) {
+ g2n->next = conv->polylines;
+ conv->polylines = g2n;
+ } else if (type == 3) {
+ g2n->next = conv->polygons;
+ conv->polygons = g2n;
+ }
+ return 0;
}
-static int load_types_file(char *file, struct gar2nav_conv *conv)
-{
- char buf[4096];
- char descr[4096];
- char ntype[4096];
- FILE *fp;
- unsigned int minid, maxid, group;
- int rc;
- int type = -1;
-
- fp = fopen(file, "r");
- if (!fp)
- return -1;
- while (fgets(buf, sizeof(buf), fp)) {
- if (*buf == '#' || *buf == '\n')
- continue;
- if (!strncasecmp(buf, "POINT", 5)) {
- type = 1;
- continue;
- } else if (!strncasecmp(buf, "POI", 3)) {
- type = 1;
- continue;
- } else if (!strncasecmp(buf, "POLYLINE", 8)) {
- type = 2;
- continue;
- } else if (!strncasecmp(buf, "POLYGONE", 8)) {
- type = 3;
- continue;
- }
- // assume only lines are routable
- rc = sscanf(buf, "%d, 0x%04X - 0x%04X = %[^\t , ] , %[^\n]",
- &group, &minid, &maxid, ntype, descr);
- if (rc != 5) {
- maxid = 0;
- rc = sscanf(buf, "%d,0x%04X = %[^\t, ], %[^\n]",
- &group, &minid, ntype, descr);
- if (rc != 4) {
- dlog(1, "Invalid line rc=%d:[%s]\n",rc, buf);
- dlog(1, "minid=%04X ntype=[%s] des=[%s]\n",
- minid, ntype, descr);
- continue;
- }
- }
- add_def(conv, type, minid, maxid, group, ntype, descr);
- }
- fclose(fp);
- return 1;
+static int load_types_file(char *file, struct gar2nav_conv *conv) {
+ char buf[4096];
+ char descr[4096];
+ char ntype[4096];
+ FILE *fp;
+ unsigned int minid, maxid, group;
+ int rc;
+ int type = -1;
+
+ fp = fopen(file, "r");
+ if (!fp)
+ return -1;
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (*buf == '#' || *buf == '\n')
+ continue;
+ if (!strncasecmp(buf, "POINT", 5)) {
+ type = 1;
+ continue;
+ } else if (!strncasecmp(buf, "POI", 3)) {
+ type = 1;
+ continue;
+ } else if (!strncasecmp(buf, "POLYLINE", 8)) {
+ type = 2;
+ continue;
+ } else if (!strncasecmp(buf, "POLYGONE", 8)) {
+ type = 3;
+ continue;
+ }
+ // assume only lines are routable
+ rc = sscanf(buf, "%d, 0x%04X - 0x%04X = %[^\t , ] , %[^\n]",
+ &group, &minid, &maxid, ntype, descr);
+ if (rc != 5) {
+ maxid = 0;
+ rc = sscanf(buf, "%d,0x%04X = %[^\t, ], %[^\n]",
+ &group, &minid, ntype, descr);
+ if (rc != 4) {
+ dlog(1, "Invalid line rc=%d:[%s]\n",rc, buf);
+ dlog(1, "minid=%04X ntype=[%s] des=[%s]\n",
+ minid, ntype, descr);
+ continue;
+ }
+ }
+ add_def(conv, type, minid, maxid, group, ntype, descr);
+ }
+ fclose(fp);
+ return 1;
}
-struct gar2nav_conv *g2n_conv_load(char *file)
-{
- struct gar2nav_conv *c;
- int rc;
-
- c = calloc(1, sizeof(*c));
- if (!c)
- return c;
- rc = load_types_file(file, c);
- if (rc < 0) {
- dlog(1, "Failed to load: [%s]\n", file);
- free(c);
- return NULL;
- }
- return c;
+struct gar2nav_conv *g2n_conv_load(char *file) {
+ struct gar2nav_conv *c;
+ int rc;
+
+ c = calloc(1, sizeof(*c));
+ if (!c)
+ return c;
+ rc = load_types_file(file, c);
+ if (rc < 0) {
+ dlog(1, "Failed to load: [%s]\n", file);
+ free(c);
+ return NULL;
+ }
+ return c;
}
-enum item_type g2n_get_type(struct gar2nav_conv *c, unsigned int type, unsigned short id)
-{
- struct gar2navit *def = NULL;
- int group;
- group = (type >> G2N_KIND_SHIFT);
- type &= ~G2N_KIND_MASK;
- if (type == G2N_POINT)
- def = c->points;
- else if (type == G2N_POLYLINE)
- def = c->polylines;
- else if (type == G2N_POLYGONE)
- def = c->polygons;
- else {
- dlog(1, "Unknown conversion type:%d\n", type);
- return type_none;
- }
-
- if (!def) {
- dlog(5, "No conversion data for %d\n", type);
- return type_none;
- }
-
- while (def) {
- if (def->group == group &&
- ((!def->maxid && def->id == id) ||
- (def->id <= id && id <= def->maxid)))
- return def->ntype;
- def = def->next;
- }
- dlog(5, "Type[%d]:ID:[%04X] unknown\n", type, id);
- return type == G2N_POINT ? type_point_unkn : type_street_unkn;
+enum item_type g2n_get_type(struct gar2nav_conv *c, unsigned int type, unsigned short id) {
+ struct gar2navit *def = NULL;
+ int group;
+ group = (type >> G2N_KIND_SHIFT);
+ type &= ~G2N_KIND_MASK;
+ if (type == G2N_POINT)
+ def = c->points;
+ else if (type == G2N_POLYLINE)
+ def = c->polylines;
+ else if (type == G2N_POLYGONE)
+ def = c->polygons;
+ else {
+ dlog(1, "Unknown conversion type:%d\n", type);
+ return type_none;
+ }
+
+ if (!def) {
+ dlog(5, "No conversion data for %d\n", type);
+ return type_none;
+ }
+
+ while (def) {
+ if (def->group == group &&
+ ((!def->maxid && def->id == id) ||
+ (def->id <= id && id <= def->maxid)))
+ return def->ntype;
+ def = def->next;
+ }
+ dlog(5, "Type[%d]:ID:[%04X] unknown\n", type, id);
+ return type == G2N_POINT ? type_point_unkn : type_street_unkn;
}
-char *g2n_get_descr(struct gar2nav_conv *c, int type, unsigned short id)
-{
- struct gar2navit *def = NULL;
- if (type == G2N_POINT)
- def = c->points;
- else if (type == G2N_POLYLINE)
- def = c->polylines;
- else if (type == G2N_POLYGONE)
- def = c->polygons;
- else {
- dlog(1, "Unknown conversion type:%d\n", type);
- return NULL;
- }
- while (def) {
- if ((!def->maxid && def->id == id) ||
- (def->id <= id && id <= def->maxid))
- return def->descr;
- def = def->next;
- }
- dlog(5, "Type[%d]:ID:[%04X] unknown\n", type, id);
- return NULL;
+char *g2n_get_descr(struct gar2nav_conv *c, int type, unsigned short id) {
+ struct gar2navit *def = NULL;
+ if (type == G2N_POINT)
+ def = c->points;
+ else if (type == G2N_POLYLINE)
+ def = c->polylines;
+ else if (type == G2N_POLYGONE)
+ def = c->polygons;
+ else {
+ dlog(1, "Unknown conversion type:%d\n", type);
+ return NULL;
+ }
+ while (def) {
+ if ((!def->maxid && def->id == id) ||
+ (def->id <= id && id <= def->maxid))
+ return def->descr;
+ def = def->next;
+ }
+ dlog(5, "Type[%d]:ID:[%04X] unknown\n", type, id);
+ return NULL;
}
#if 0
-int main(int argc, char **argv)
-{
- load_types_file(argv[1], NULL);
- return 0;
+int main(int argc, char **argv) {
+ load_types_file(argv[1], NULL);
+ return 0;
}
#endif
diff --git a/navit/map/garmin/gar2navit.h b/navit/map/garmin/gar2navit.h
index 27c5f65e1..d6d22cc0a 100644
--- a/navit/map/garmin/gar2navit.h
+++ b/navit/map/garmin/gar2navit.h
@@ -12,9 +12,9 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
-
+
Garmin and MapSource are registered trademarks or trademarks
of Garmin Ltd. or one of its subsidiaries.
diff --git a/navit/map/garmin/garmin.c b/navit/map/garmin/garmin.c
index 2e7263081..00a6fa115 100644
--- a/navit/map/garmin/garmin.c
+++ b/navit/map/garmin/garmin.c
@@ -12,9 +12,9 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
-
+
Garmin and MapSource are registered trademarks or trademarks
of Garmin Ltd. or one of its subsidiaries.
@@ -50,948 +50,884 @@
static int map_id;
struct map_priv {
- int id;
- char *filename;
- struct gar2nav_conv *conv;
- struct gar *g;
+ int id;
+ char *filename;
+ struct gar2nav_conv *conv;
+ struct gar *g;
};
struct map_rect_priv {
- int id;
- struct coord_rect r;
- char *label; // FIXME: Register all strings for searches
- int limit;
- struct map_priv *mpriv;
- struct gmap *gmap;
- struct gobject *cobj;
- struct gobject *objs;
- struct item item;
- unsigned int last_coord;
- void *last_itterated;
- struct coord last_c;
- void *last_oattr;
- unsigned int last_attr;
- struct gar_search *search;
+ int id;
+ struct coord_rect r;
+ char *label; // FIXME: Register all strings for searches
+ int limit;
+ struct map_priv *mpriv;
+ struct gmap *gmap;
+ struct gobject *cobj;
+ struct gobject *objs;
+ struct item item;
+ unsigned int last_coord;
+ void *last_itterated;
+ struct coord last_c;
+ void *last_oattr;
+ unsigned int last_attr;
+ struct gar_search *search;
};
int garmin_debug = 10;
-void
-logfn(char *file, int line, int level, char *fmt, ...)
-{
- va_list ap;
- char fileline[256];
- int sz;
- if (level > garmin_debug)
- return;
- va_start(ap, fmt);
- sz = sprintf(fileline, "%s:%d:%d|", file, line, level);
- debug_vprintf(0, "", strlen(""), fileline, sz,
- 1, fmt, ap);
- va_end(ap);
+void logfn(char *file, int line, int level, char *fmt, ...) {
+ va_list ap;
+ char fileline[256];
+ int sz;
+ if (level > garmin_debug)
+ return;
+ va_start(ap, fmt);
+ sz = sprintf(fileline, "%s:%d:%d|", file, line, level);
+ debug_vprintf(0, "", strlen(""), fileline, sz,
+ 1, fmt, ap);
+ va_end(ap);
}
// need a base map and a map
struct gscale {
- char *label;
- float scale;
- int bits;
+ char *label;
+ float scale;
+ int bits;
};
static struct gscale mapscales[] = {
- {"7000 km", 70000.0, 8}
- ,{"5000 km", 50000.0, 8}
- ,{"3000 km", 30000.0, 9}
- ,{"2000 km", 20000.0, 9}
- ,{"1500 km", 15000.0, 10}
- ,{"1000 km", 10000.0, 10}
- ,{"700 km", 7000.0, 11}
- ,{"500 km", 5000.0, 11}
- ,{"300 km", 3000.0, 13}
- ,{"200 km", 2000.0, 13}
- ,{"150 km", 1500.0, 13}
- ,{"100 km", 1000.0, 14}
- ,{"70 km", 700.0, 15}
- ,{"50 km", 500.0, 16}
- ,{"30 km", 300.0, 16}
- ,{"20 km", 200.0, 17}
- ,{"15 km", 150.0, 17}
- ,{"10 km", 100.0, 18}
- ,{"7 km", 70.0, 18}
- ,{"5 km", 50.0, 19}
- ,{"3 km", 30.0, 19}
- ,{"2 km", 20.0, 20}
- ,{"1.5 km", 15.0, 22}
- ,{"1 km", 10.0, 24}
- ,{"700 m", 7.0, 24}
- ,{"500 m", 5.0, 24}
- ,{"300 m", 3.0, 24}
- ,{"200 m", 2.0, 24}
- ,{"150 m", 1.5, 24}
- ,{"100 m", 1.0, 24}
- ,{"70 m", 0.7, 24}
- ,{"50 m", 0.5, 24}
- ,{"30 m", 0.3, 24}
- ,{"20 m", 0.2, 24}
- ,{"15 m", 0.1, 24}
- ,{"10 m", 0.15, 24}
+ {"7000 km", 70000.0, 8}
+ ,{"5000 km", 50000.0, 8}
+ ,{"3000 km", 30000.0, 9}
+ ,{"2000 km", 20000.0, 9}
+ ,{"1500 km", 15000.0, 10}
+ ,{"1000 km", 10000.0, 10}
+ ,{"700 km", 7000.0, 11}
+ ,{"500 km", 5000.0, 11}
+ ,{"300 km", 3000.0, 13}
+ ,{"200 km", 2000.0, 13}
+ ,{"150 km", 1500.0, 13}
+ ,{"100 km", 1000.0, 14}
+ ,{"70 km", 700.0, 15}
+ ,{"50 km", 500.0, 16}
+ ,{"30 km", 300.0, 16}
+ ,{"20 km", 200.0, 17}
+ ,{"15 km", 150.0, 17}
+ ,{"10 km", 100.0, 18}
+ ,{"7 km", 70.0, 18}
+ ,{"5 km", 50.0, 19}
+ ,{"3 km", 30.0, 19}
+ ,{"2 km", 20.0, 20}
+ ,{"1.5 km", 15.0, 22}
+ ,{"1 km", 10.0, 24}
+ ,{"700 m", 7.0, 24}
+ ,{"500 m", 5.0, 24}
+ ,{"300 m", 3.0, 24}
+ ,{"200 m", 2.0, 24}
+ ,{"150 m", 1.5, 24}
+ ,{"100 m", 1.0, 24}
+ ,{"70 m", 0.7, 24}
+ ,{"50 m", 0.5, 24}
+ ,{"30 m", 0.3, 24}
+ ,{"20 m", 0.2, 24}
+ ,{"15 m", 0.1, 24}
+ ,{"10 m", 0.15, 24}
};
-static int
-garmin_object_label(struct gobject *o, struct attr *attr)
-{
- struct map_rect_priv *mr = o->priv_data;
- char *codepage;
- char *label;
- if (!mr) {
- dlog(1, "Error object do not have priv_data!!\n");
- return 0;
- }
- if (mr->label) {
- free(mr->label);
- }
- label = gar_get_object_lbl(o);
- if (label) {
- codepage = gar_obj_codepage(o);
- if (*codepage != 'a') {
- mr->label = g_convert(label, -1,"utf-8",codepage,NULL,NULL,NULL);
- free(label);
- } else
- mr->label = label;
- } else {
- mr->label = NULL;
- return 0;
- }
- if (mr->label) {
- char *cp = mr->label;
- /* FIXME Process label and give only the visible part */
- if (*mr->label == '@' || *mr->label == '^')
- cp++;
- /* FIXME: If zoomlevel is high convert ^ in the string to spaces */
- attr->u.str = cp;
- return 1;
- }
- return 0;
+static int garmin_object_label(struct gobject *o, struct attr *attr) {
+ struct map_rect_priv *mr = o->priv_data;
+ char *codepage;
+ char *label;
+ if (!mr) {
+ dlog(1, "Error object do not have priv_data!!\n");
+ return 0;
+ }
+ if (mr->label) {
+ free(mr->label);
+ }
+ label = gar_get_object_lbl(o);
+ if (label) {
+ codepage = gar_obj_codepage(o);
+ if (*codepage != 'a') {
+ mr->label = g_convert(label, -1,"utf-8",codepage,NULL,NULL,NULL);
+ free(label);
+ } else
+ mr->label = label;
+ } else {
+ mr->label = NULL;
+ return 0;
+ }
+ if (mr->label) {
+ char *cp = mr->label;
+ /* FIXME Process label and give only the visible part */
+ if (*mr->label == '@' || *mr->label == '^')
+ cp++;
+ /* FIXME: If zoomlevel is high convert ^ in the string to spaces */
+ attr->u.str = cp;
+ return 1;
+ }
+ return 0;
}
-static int
-garmin_object_debug(struct gobject *o, struct attr *attr)
-{
- struct map_rect_priv *mr = o->priv_data;
- if (!mr) {
- dlog(1, "Error object do not have priv_data!!\n");
- return 0;
- }
- if (mr->label)
- free(mr->label);
- mr->label = gar_object_debug_str(o);
- if (mr->label) {
- attr->u.str = mr->label;
- return 1;
- }
- return 0;
+static int garmin_object_debug(struct gobject *o, struct attr *attr) {
+ struct map_rect_priv *mr = o->priv_data;
+ if (!mr) {
+ dlog(1, "Error object do not have priv_data!!\n");
+ return 0;
+ }
+ if (mr->label)
+ free(mr->label);
+ mr->label = gar_object_debug_str(o);
+ if (mr->label) {
+ attr->u.str = mr->label;
+ return 1;
+ }
+ return 0;
}
-static struct map_search_priv *
-gmap_search_new(struct map_priv *map, struct item *item, struct attr *search, int partial)
-{
- struct map_rect_priv *mr=g_new0(struct map_rect_priv, 1);
- struct gar_search *gs;
- int rc;
-
- dlog(1, "Called!\n");
- mr->mpriv=map;
- gs = g_new0(struct gar_search,1);
- if (!gs) {
- dlog(1, "Can not init search \n");
- free(mr);
- return NULL;
- }
- mr->search = gs;
- switch (search->type) {
- case attr_country_name:
- gs->type = GS_COUNTRY;
- break;
- case attr_town_name:
- gs->type = GS_CITY;
- break;
- case attr_town_postal:
- gs->type = GS_ZIP;
- break;
- case attr_street_name:
- gs->type = GS_ROAD;
- break;
+static struct map_search_priv *gmap_search_new(struct map_priv *map, struct item *item, struct attr *search,
+ int partial) {
+ struct map_rect_priv *mr=g_new0(struct map_rect_priv, 1);
+ struct gar_search *gs;
+ int rc;
+
+ dlog(1, "Called!\n");
+ mr->mpriv=map;
+ gs = g_new0(struct gar_search,1);
+ if (!gs) {
+ dlog(1, "Can not init search \n");
+ free(mr);
+ return NULL;
+ }
+ mr->search = gs;
+ switch (search->type) {
+ case attr_country_name:
+ gs->type = GS_COUNTRY;
+ break;
+ case attr_town_name:
+ gs->type = GS_CITY;
+ break;
+ case attr_town_postal:
+ gs->type = GS_ZIP;
+ break;
+ case attr_street_name:
+ gs->type = GS_ROAD;
+ break;
#if 0 /* someday */
- case attr_region_name:
- case attr_intersection:
- case attr_housenumber:
+ case attr_region_name:
+ case attr_intersection:
+ case attr_housenumber:
#endif
- default:
- dlog(1, "Don't know how to search for %d\n", search->type);
- goto out_err;
- }
- gs->match = partial ? GM_START : GM_EXACT;
- gs->needle = strdup(search->u.str);
- dlog(5, "Needle: %s\n", gs->needle);
-
- mr->gmap = gar_find_subfiles(mr->mpriv->g, gs, GO_GET_SEARCH);
- if (!mr->gmap) {
- dlog(1, "Can not init search \n");
- goto out_err;
- }
- rc = gar_get_objects(mr->gmap, 0, gs, &mr->objs, GO_GET_SEARCH);
- if (rc < 0) {
- dlog(1, "Error loading objects\n");
- goto out_err;
- }
- mr->cobj = mr->objs;
- dlog(4, "Loaded %d objects\n", rc);
- return (struct map_search_priv *)mr;
+ default:
+ dlog(1, "Don't know how to search for %d\n", search->type);
+ goto out_err;
+ }
+ gs->match = partial ? GM_START : GM_EXACT;
+ gs->needle = strdup(search->u.str);
+ dlog(5, "Needle: %s\n", gs->needle);
+
+ mr->gmap = gar_find_subfiles(mr->mpriv->g, gs, GO_GET_SEARCH);
+ if (!mr->gmap) {
+ dlog(1, "Can not init search \n");
+ goto out_err;
+ }
+ rc = gar_get_objects(mr->gmap, 0, gs, &mr->objs, GO_GET_SEARCH);
+ if (rc < 0) {
+ dlog(1, "Error loading objects\n");
+ goto out_err;
+ }
+ mr->cobj = mr->objs;
+ dlog(4, "Loaded %d objects\n", rc);
+ return (struct map_search_priv *)mr;
out_err:
- free(gs);
- free(mr);
- return NULL;
+ free(gs);
+ free(mr);
+ return NULL;
}
/* Assumes that only one item will be itterated at time! */
-static void
-coord_rewind(void *priv_data)
-{
- struct gobject *g = priv_data;
- struct map_rect_priv *mr = g->priv_data;
- mr->last_coord = 0;
+static void coord_rewind(void *priv_data) {
+ struct gobject *g = priv_data;
+ struct map_rect_priv *mr = g->priv_data;
+ mr->last_coord = 0;
};
-static void
-attr_rewind(void *priv_data)
-{
- struct gobject *g = priv_data;
- struct map_rect_priv *mr = g->priv_data;
- mr->last_attr = 0;
+static void attr_rewind(void *priv_data) {
+ struct gobject *g = priv_data;
+ struct map_rect_priv *mr = g->priv_data;
+ mr->last_attr = 0;
};
-static int
-point_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct gobject *g = priv_data;
- struct map_rect_priv *mr = g->priv_data;
- struct gcoord gc;
- if (!count)
- return 0;
- if (g != mr->last_itterated) {
- mr->last_itterated = g;
- mr->last_coord = 0;
- }
-
- if (mr->last_coord > 0)
- return 0;
-
- gar_get_object_coord(mr->gmap, g, &gc);
- c->x = gc.x;
- c->y = gc.y;
- mr->last_coord++;
+static int point_coord_get(void *priv_data, struct coord *c, int count) {
+ struct gobject *g = priv_data;
+ struct map_rect_priv *mr = g->priv_data;
+ struct gcoord gc;
+ if (!count)
+ return 0;
+ if (g != mr->last_itterated) {
+ mr->last_itterated = g;
+ mr->last_coord = 0;
+ }
+
+ if (mr->last_coord > 0)
+ return 0;
+
+ gar_get_object_coord(mr->gmap, g, &gc);
+ c->x = gc.x;
+ c->y = gc.y;
+ mr->last_coord++;
// dlog(1,"point: x=%d y=%d\n", c->x, c->y);
- // dlog(1, "point: x=%f y=%f\n", GARDEG(c->x), GARDEG(c->y));
- return 1;
+ // dlog(1, "point: x=%f y=%f\n", GARDEG(c->x), GARDEG(c->y));
+ return 1;
}
-static int
-coord_is_node(void *priv_data)
-{
- struct gobject *g = priv_data;
- struct map_rect_priv *mr = g->priv_data;
+static int coord_is_node(void *priv_data) {
+ struct gobject *g = priv_data;
+ struct map_rect_priv *mr = g->priv_data;
- return gar_is_object_dcoord_node(mr->gmap, g, mr->last_coord);
+ return gar_is_object_dcoord_node(mr->gmap, g, mr->last_coord);
}
-static int
-poly_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct gobject *g = priv_data;
- struct map_rect_priv *mr = g->priv_data;
- int ndeltas = 0, total = 0;
- struct gcoord dc;
-
- if (!count)
- return 0;
-
- if (g != mr->last_itterated) {
- mr->last_itterated = g;
- mr->last_coord = 0;
- }
- ndeltas = gar_get_object_deltas(g);
- if (mr->last_coord > ndeltas + 1)
- return 0;
- while (count --) {
- if (mr->last_coord == 0) {
- gar_get_object_coord(mr->gmap, g, &dc);
- mr->last_c.x = dc.x;
- mr->last_c.y = dc.y;
- } else {
- if (!gar_get_object_dcoord(mr->gmap, g, mr->last_coord - 1, &dc)) {
- mr->last_coord = ndeltas + 2;
- return total;
- }
- mr->last_c.x += dc.x;
- mr->last_c.y += dc.y;
- }
- c->x = mr->last_c.x;
- c->y = mr->last_c.y;
- ddlog(1, "poly: x=%f y=%f\n", GARDEG(c->x), GARDEG(c->y));
+static int poly_coord_get(void *priv_data, struct coord *c, int count) {
+ struct gobject *g = priv_data;
+ struct map_rect_priv *mr = g->priv_data;
+ int ndeltas = 0, total = 0;
+ struct gcoord dc;
+
+ if (!count)
+ return 0;
+
+ if (g != mr->last_itterated) {
+ mr->last_itterated = g;
+ mr->last_coord = 0;
+ }
+ ndeltas = gar_get_object_deltas(g);
+ if (mr->last_coord > ndeltas + 1)
+ return 0;
+ while (count --) {
+ if (mr->last_coord == 0) {
+ gar_get_object_coord(mr->gmap, g, &dc);
+ mr->last_c.x = dc.x;
+ mr->last_c.y = dc.y;
+ } else {
+ if (!gar_get_object_dcoord(mr->gmap, g, mr->last_coord - 1, &dc)) {
+ mr->last_coord = ndeltas + 2;
+ return total;
+ }
+ mr->last_c.x += dc.x;
+ mr->last_c.y += dc.y;
+ }
+ c->x = mr->last_c.x;
+ c->y = mr->last_c.y;
+ ddlog(1, "poly: x=%f y=%f\n", GARDEG(c->x), GARDEG(c->y));
// dlog(1,"poly: x=%d y=%d\n", c->x, c->y);
- c++;
- total++;
- mr->last_coord ++;
- }
- return total;
+ c++;
+ total++;
+ mr->last_coord ++;
+ }
+ return total;
}
-// for _any we must return one by one
-static int
-point_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct gobject *g = priv_data;
- struct map_rect_priv *mr = g->priv_data;
- int rc;
- switch (attr_type) {
- case attr_any:
- if (g != mr->last_oattr) {
- mr->last_oattr = g;
- mr->last_attr = 0;
- }
- switch(mr->last_attr) {
- case 0:
- mr->last_attr++;
- attr->type = attr_label;
- rc = garmin_object_label(g, attr);
- if (rc)
- return rc;
- case 1:
- mr->last_attr++;
- attr->type = attr_debug;
- rc = garmin_object_debug(g, attr);
- if (rc)
- return rc;
- case 2:
- mr->last_attr++;
- if (g->type == GO_POLYLINE) {
- attr->type = attr_street_name;
- rc = garmin_object_label(g, attr);
- if (rc)
- return rc;
- }
- case 3:
- mr->last_attr++;
- attr->type = attr_flags;
- attr->u.num = 0;
- rc = gar_object_flags(g);
- if (rc & F_ONEWAY)
- attr->u.num |= AF_ONEWAY;
- if (rc & F_SEGMENTED)
- attr->u.num |= AF_SEGMENTED;
- return 1;
- default:
- return 0;
- }
- break;
- case attr_label:
- attr->type = attr_label;
- return garmin_object_label(g, attr);
- case attr_town_name:
- attr->type = attr_town_name;
- return garmin_object_label(g, attr);
- case attr_street_name:
- attr->type = attr_type;
- return garmin_object_label(g, attr);
- case attr_street_name_systematic:
- /* TODO: Get secondary labels of roads */
- return 0;
- case attr_flags:
- attr->type = attr_flags;
- attr->u.num = 0;
- rc = gar_object_flags(g);
- if (rc & F_ONEWAY)
- attr->u.num |= AF_ONEWAY;
- if (rc & F_SEGMENTED)
- attr->u.num |= AF_SEGMENTED;
- return 1;
- default:
- dlog(1, "Don't know about attribute %d[%04X]=%s yet\n", attr_type,attr_type, attr_to_name(attr_type));
- }
-
- return 0;
+// for _any we must return one by one
+static int point_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct gobject *g = priv_data;
+ struct map_rect_priv *mr = g->priv_data;
+ int rc;
+ switch (attr_type) {
+ case attr_any:
+ if (g != mr->last_oattr) {
+ mr->last_oattr = g;
+ mr->last_attr = 0;
+ }
+ switch(mr->last_attr) {
+ case 0:
+ mr->last_attr++;
+ attr->type = attr_label;
+ rc = garmin_object_label(g, attr);
+ if (rc)
+ return rc;
+ case 1:
+ mr->last_attr++;
+ attr->type = attr_debug;
+ rc = garmin_object_debug(g, attr);
+ if (rc)
+ return rc;
+ case 2:
+ mr->last_attr++;
+ if (g->type == GO_POLYLINE) {
+ attr->type = attr_street_name;
+ rc = garmin_object_label(g, attr);
+ if (rc)
+ return rc;
+ }
+ case 3:
+ mr->last_attr++;
+ attr->type = attr_flags;
+ attr->u.num = 0;
+ rc = gar_object_flags(g);
+ if (rc & F_ONEWAY)
+ attr->u.num |= AF_ONEWAY;
+ if (rc & F_SEGMENTED)
+ attr->u.num |= AF_SEGMENTED;
+ return 1;
+ default:
+ return 0;
+ }
+ break;
+ case attr_label:
+ attr->type = attr_label;
+ return garmin_object_label(g, attr);
+ case attr_town_name:
+ attr->type = attr_town_name;
+ return garmin_object_label(g, attr);
+ case attr_street_name:
+ attr->type = attr_type;
+ return garmin_object_label(g, attr);
+ case attr_street_name_systematic:
+ /* TODO: Get secondary labels of roads */
+ return 0;
+ case attr_flags:
+ attr->type = attr_flags;
+ attr->u.num = 0;
+ rc = gar_object_flags(g);
+ if (rc & F_ONEWAY)
+ attr->u.num |= AF_ONEWAY;
+ if (rc & F_SEGMENTED)
+ attr->u.num |= AF_SEGMENTED;
+ return 1;
+ default:
+ dlog(1, "Don't know about attribute %d[%04X]=%s yet\n", attr_type,attr_type, attr_to_name(attr_type));
+ }
+
+ return 0;
}
static struct item_methods methods_garmin_point = {
- coord_rewind,
- point_coord_get,
- attr_rewind,
- point_attr_get,
+ coord_rewind,
+ point_coord_get,
+ attr_rewind,
+ point_attr_get,
};
static struct item_methods methods_garmin_poly = {
- coord_rewind,
- poly_coord_get,
- attr_rewind, // point_attr_rewind,
- point_attr_get, // poly_attr_get,
- coord_is_node,
+ coord_rewind,
+ poly_coord_get,
+ attr_rewind, // point_attr_rewind,
+ point_attr_get, // poly_attr_get,
+ coord_is_node,
};
-static int
-search_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct gobject *g = priv_data;
- struct map_rect_priv *mr = g->priv_data;
- int rc;
- switch (attr_type) {
- case attr_any:
- if (g != mr->last_oattr) {
- mr->last_oattr = g;
- mr->last_attr = 0;
- }
- switch(mr->last_attr) {
- case 0:
- mr->last_attr++;
- attr->type = attr_label;
- rc = garmin_object_label(g, attr);
- if (rc)
- return rc;
- case 1:
- mr->last_attr++;
- attr->type = attr_debug;
- rc = garmin_object_debug(g, attr);
- if (rc)
- return rc;
- case 2:
- mr->last_attr++;
- if (g->type == GO_POLYLINE) {
- attr->type = attr_street_name;
- rc = garmin_object_label(g, attr);
- if (rc)
- return rc;
- }
- case 3:
- mr->last_attr++;
- attr->type = attr_flags;
- attr->u.num = 0;
- rc = gar_object_flags(g);
- if (rc & F_ONEWAY)
- attr->u.num |= AF_ONEWAY;
- if (rc & F_SEGMENTED)
- attr->u.num |= AF_SEGMENTED;
- return 1;
- default:
- return 0;
- }
- break;
- case attr_label:
- attr->type = attr_label;
- return garmin_object_label(g, attr);
- case attr_town_name:
- attr->type = attr_town_name;
- if (mr->label)
- free(mr->label);
- mr->label = gar_srch_get_city(g);
- attr->u.str = mr->label;
- if (attr->u.str)
- return 1;
- return 0;
- case attr_town_id:
- rc = gar_srch_get_cityid(g);
- if (rc) {
- attr->type = attr_town_id;
- attr->u.num = rc;
- return 1;
- }
- return 0;
- case attr_town_postal:
- attr->type = attr_town_postal;
- attr->u.str = gar_srch_get_zip(g);
- if (attr->u.str)
- return 1;
- return 0;
- case attr_street_name:
- attr->type = attr_street_name;
- if (mr->label)
- free(mr->label);
- mr->label = gar_srch_get_roadname(g);
- attr->u.str = mr->label;
- if (attr->u.str)
- return 1;
- return 0;
- case attr_street_id:
- attr->type = attr_street_id;
- attr->u.num = gar_srch_get_roadid(g);
- if (attr->u.num)
- return 1;
- return 0;
- case attr_flags:
- attr->type = attr_flags;
- attr->u.num = 0;
- rc = gar_object_flags(g);
- if (rc & F_ONEWAY)
- attr->u.num |= AF_ONEWAY;
- if (rc & F_SEGMENTED)
- attr->u.num |= AF_SEGMENTED;
- return 1;
- case attr_country_id:
- rc = gar_srch_get_countryid(g);
- if (rc) {
- attr->type = attr_country_id;
- attr->u.num = rc;
- return 1;
- }
- return 0;
- case attr_country_name:
- attr->type = attr_country_name;
- attr->u.str = gar_srch_get_country(g);
- if (attr->u.str)
- return 1;
- return 0;
- case attr_district_id:
- rc = gar_srch_get_regionid(g);
- if (rc) {
- attr->type = attr_district_id;
- attr->u.num = rc;
- return 1;
- }
- return 0;
- case attr_district_name:
- attr->type = attr_district_name;
- attr->u.str = gar_srch_get_region(g);
- if (attr->u.str)
- return 1;
- return 0;
- case attr_town_streets_item:
- return 0;
- default:
- dlog(1, "Don't know about attribute %d[%04X]=%s yet\n",
- attr_type,attr_type, attr_to_name(attr_type));
- }
-
- return 0;
+static int search_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct gobject *g = priv_data;
+ struct map_rect_priv *mr = g->priv_data;
+ int rc;
+ switch (attr_type) {
+ case attr_any:
+ if (g != mr->last_oattr) {
+ mr->last_oattr = g;
+ mr->last_attr = 0;
+ }
+ switch(mr->last_attr) {
+ case 0:
+ mr->last_attr++;
+ attr->type = attr_label;
+ rc = garmin_object_label(g, attr);
+ if (rc)
+ return rc;
+ case 1:
+ mr->last_attr++;
+ attr->type = attr_debug;
+ rc = garmin_object_debug(g, attr);
+ if (rc)
+ return rc;
+ case 2:
+ mr->last_attr++;
+ if (g->type == GO_POLYLINE) {
+ attr->type = attr_street_name;
+ rc = garmin_object_label(g, attr);
+ if (rc)
+ return rc;
+ }
+ case 3:
+ mr->last_attr++;
+ attr->type = attr_flags;
+ attr->u.num = 0;
+ rc = gar_object_flags(g);
+ if (rc & F_ONEWAY)
+ attr->u.num |= AF_ONEWAY;
+ if (rc & F_SEGMENTED)
+ attr->u.num |= AF_SEGMENTED;
+ return 1;
+ default:
+ return 0;
+ }
+ break;
+ case attr_label:
+ attr->type = attr_label;
+ return garmin_object_label(g, attr);
+ case attr_town_name:
+ attr->type = attr_town_name;
+ if (mr->label)
+ free(mr->label);
+ mr->label = gar_srch_get_city(g);
+ attr->u.str = mr->label;
+ if (attr->u.str)
+ return 1;
+ return 0;
+ case attr_town_id:
+ rc = gar_srch_get_cityid(g);
+ if (rc) {
+ attr->type = attr_town_id;
+ attr->u.num = rc;
+ return 1;
+ }
+ return 0;
+ case attr_town_postal:
+ attr->type = attr_town_postal;
+ attr->u.str = gar_srch_get_zip(g);
+ if (attr->u.str)
+ return 1;
+ return 0;
+ case attr_street_name:
+ attr->type = attr_street_name;
+ if (mr->label)
+ free(mr->label);
+ mr->label = gar_srch_get_roadname(g);
+ attr->u.str = mr->label;
+ if (attr->u.str)
+ return 1;
+ return 0;
+ case attr_street_id:
+ attr->type = attr_street_id;
+ attr->u.num = gar_srch_get_roadid(g);
+ if (attr->u.num)
+ return 1;
+ return 0;
+ case attr_flags:
+ attr->type = attr_flags;
+ attr->u.num = 0;
+ rc = gar_object_flags(g);
+ if (rc & F_ONEWAY)
+ attr->u.num |= AF_ONEWAY;
+ if (rc & F_SEGMENTED)
+ attr->u.num |= AF_SEGMENTED;
+ return 1;
+ case attr_country_id:
+ rc = gar_srch_get_countryid(g);
+ if (rc) {
+ attr->type = attr_country_id;
+ attr->u.num = rc;
+ return 1;
+ }
+ return 0;
+ case attr_country_name:
+ attr->type = attr_country_name;
+ attr->u.str = gar_srch_get_country(g);
+ if (attr->u.str)
+ return 1;
+ return 0;
+ case attr_district_id:
+ rc = gar_srch_get_regionid(g);
+ if (rc) {
+ attr->type = attr_district_id;
+ attr->u.num = rc;
+ return 1;
+ }
+ return 0;
+ case attr_district_name:
+ attr->type = attr_district_name;
+ attr->u.str = gar_srch_get_region(g);
+ if (attr->u.str)
+ return 1;
+ return 0;
+ case attr_town_streets_item:
+ return 0;
+ default:
+ dlog(1, "Don't know about attribute %d[%04X]=%s yet\n",
+ attr_type,attr_type, attr_to_name(attr_type));
+ }
+
+ return 0;
}
-static int
-search_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct gobject *g = priv_data;
- struct map_rect_priv *mr = g->priv_data;
- struct gcoord gc;
- if (!count)
- return 0;
- if (g != mr->last_itterated) {
- mr->last_itterated = g;
- mr->last_coord = 0;
- }
-
- if (mr->last_coord > 0)
- return 0;
-
- if (gar_get_object_coord(mr->gmap, g, &gc)) {
- c->x = gc.x;
- c->y = gc.y;
- mr->last_coord++;
- return 1;
- }
- return 0;
+static int search_coord_get(void *priv_data, struct coord *c, int count) {
+ struct gobject *g = priv_data;
+ struct map_rect_priv *mr = g->priv_data;
+ struct gcoord gc;
+ if (!count)
+ return 0;
+ if (g != mr->last_itterated) {
+ mr->last_itterated = g;
+ mr->last_coord = 0;
+ }
+
+ if (mr->last_coord > 0)
+ return 0;
+
+ if (gar_get_object_coord(mr->gmap, g, &gc)) {
+ c->x = gc.x;
+ c->y = gc.y;
+ mr->last_coord++;
+ return 1;
+ }
+ return 0;
}
static struct item_methods methods_garmin_search = {
- coord_rewind,
- search_coord_get,
- attr_rewind,
- search_attr_get,
+ coord_rewind,
+ search_coord_get,
+ attr_rewind,
+ search_attr_get,
};
-static struct item *
-garmin_poi2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype)
-{
- if (mr->mpriv->conv) {
- int mask = gar_object_group(o) << G2N_KIND_SHIFT;
- mr->item.type = g2n_get_type(mr->mpriv->conv, G2N_POINT|mask, otype);
- }
- mr->item.meth = &methods_garmin_point;
- return &mr->item;
+static struct item *garmin_poi2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype) {
+ if (mr->mpriv->conv) {
+ int mask = gar_object_group(o) << G2N_KIND_SHIFT;
+ mr->item.type = g2n_get_type(mr->mpriv->conv, G2N_POINT|mask, otype);
+ }
+ mr->item.meth = &methods_garmin_point;
+ return &mr->item;
}
-static struct item *
-garmin_pl2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype)
-{
- if (mr->mpriv->conv) {
- int mask = gar_object_group(o) << G2N_KIND_SHIFT;
- mr->item.type = g2n_get_type(mr->mpriv->conv, G2N_POLYLINE|mask, otype);
- }
- mr->item.meth = &methods_garmin_poly;
- return &mr->item;
+static struct item *garmin_pl2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype) {
+ if (mr->mpriv->conv) {
+ int mask = gar_object_group(o) << G2N_KIND_SHIFT;
+ mr->item.type = g2n_get_type(mr->mpriv->conv, G2N_POLYLINE|mask, otype);
+ }
+ mr->item.meth = &methods_garmin_poly;
+ return &mr->item;
}
-static struct item *
-garmin_pg2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype)
-{
- if (mr->mpriv->conv) {
- int mask = gar_object_group(o) << G2N_KIND_SHIFT;
- mr->item.type = g2n_get_type(mr->mpriv->conv, G2N_POLYGONE|mask, otype);
- }
- mr->item.meth = &methods_garmin_poly;
- return &mr->item;
+static struct item *garmin_pg2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype) {
+ if (mr->mpriv->conv) {
+ int mask = gar_object_group(o) << G2N_KIND_SHIFT;
+ mr->item.type = g2n_get_type(mr->mpriv->conv, G2N_POLYGONE|mask, otype);
+ }
+ mr->item.meth = &methods_garmin_poly;
+ return &mr->item;
}
-static struct item *
-garmin_srch2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype)
-{
- mr->item.type = type_country_label;
- mr->item.meth = &methods_garmin_search;
- return &mr->item;
+static struct item *garmin_srch2item(struct map_rect_priv *mr, struct gobject *o, unsigned short otype) {
+ mr->item.type = type_country_label;
+ mr->item.meth = &methods_garmin_search;
+ return &mr->item;
}
-static struct item *
-garmin_obj2item(struct map_rect_priv *mr, struct gobject *o)
-{
- unsigned short otype;
- otype = gar_obj_type(o);
- mr->item.type = type_none;
- switch (o->type) {
- case GO_POINT:
- return garmin_poi2item(mr, o, otype);
- case GO_POLYLINE:
- return garmin_pl2item(mr, o, otype);
- case GO_POLYGON:
- return garmin_pg2item(mr, o, otype);
- case GO_ROAD:
- return garmin_pl2item(mr, o, otype);
+static struct item *garmin_obj2item(struct map_rect_priv *mr, struct gobject *o) {
+ unsigned short otype;
+ otype = gar_obj_type(o);
+ mr->item.type = type_none;
+ switch (o->type) {
+ case GO_POINT:
+ return garmin_poi2item(mr, o, otype);
+ case GO_POLYLINE:
+ return garmin_pl2item(mr, o, otype);
+ case GO_POLYGON:
+ return garmin_pg2item(mr, o, otype);
+ case GO_ROAD:
+ return garmin_pl2item(mr, o, otype);
#if 0
- case GO_SEARCH:
- return garmin_srch2item(mr, o, otype);
+ case GO_SEARCH:
+ return garmin_srch2item(mr, o, otype);
#endif
- default:
- dlog(1, "Unknown garmin object type:%d\n",
- o->type);
- }
- return NULL;
+ default:
+ dlog(1, "Unknown garmin object type:%d\n",
+ o->type);
+ }
+ return NULL;
}
-static struct item *
-gmap_rect_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- struct gobject *o;
- o = mr->objs = gar_get_object_by_id(mr->mpriv->g, id_hi, id_lo);
- if (!o) {
- dlog(1, "Can not find object\n");
- return NULL;
- }
-
- mr->item.id_hi = id_hi;
- mr->item.id_lo = id_lo;
- mr->item.priv_data = o;
- mr->item.type = type_none;
- o->priv_data = mr;
- if (!garmin_obj2item(mr, o))
- return NULL;
- return &mr->item;
+static struct item *gmap_rect_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ struct gobject *o;
+ o = mr->objs = gar_get_object_by_id(mr->mpriv->g, id_hi, id_lo);
+ if (!o) {
+ dlog(1, "Can not find object\n");
+ return NULL;
+ }
+
+ mr->item.id_hi = id_hi;
+ mr->item.id_lo = id_lo;
+ mr->item.priv_data = o;
+ mr->item.type = type_none;
+ o->priv_data = mr;
+ if (!garmin_obj2item(mr, o))
+ return NULL;
+ return &mr->item;
}
-static struct item *
-gmap_rect_get_item(struct map_rect_priv *mr)
-{
- struct gobject *o;
- if (!mr->objs)
- return NULL;
- if (!mr->cobj)
- return NULL;
- // mr->cobj = mr->objs;
- o = mr->cobj;
+static struct item *gmap_rect_get_item(struct map_rect_priv *mr) {
+ struct gobject *o;
+ if (!mr->objs)
+ return NULL;
+ if (!mr->cobj)
+ return NULL;
+ // mr->cobj = mr->objs;
+ o = mr->cobj;
// dlog(1, "gi:o=%p\n", o);
- mr->cobj = mr->cobj->next;
- if (o) {
- mr->item.id_hi = gar_object_mapid(o);
- mr->item.id_lo = gar_object_index(o);
- mr->item.priv_data = o;
- mr->item.type = type_none;
- o->priv_data = mr;
- if (!garmin_obj2item(mr, o))
- return NULL;
- return &mr->item;
- }
- return NULL;
+ mr->cobj = mr->cobj->next;
+ if (o) {
+ mr->item.id_hi = gar_object_mapid(o);
+ mr->item.id_lo = gar_object_index(o);
+ mr->item.priv_data = o;
+ mr->item.type = type_none;
+ o->priv_data = mr;
+ if (!garmin_obj2item(mr, o))
+ return NULL;
+ return &mr->item;
+ }
+ return NULL;
}
#define max(a,b) ((a) > (b) ? (a) : (b))
struct nl2gl_t {
- int g;
- int bits;
- char *descr;
+ int g;
+ int bits;
+ char *descr;
};
-struct nl2gl_t nl2gl_1[] = {
- { /* 0 */ .g = 12, .descr = "0-120m", },
- { /* 1 */ .g = 11, .descr = "0-120m", },
- { /* 2 */ .g = 10, .descr = "0-120m", },
- { /* 3 */ .g = 9, .descr = "0-120m", },
- { /* 4 */ .g = 8, .descr = "0-120m", },
- { /* 5 */ .g = 7, .descr = "0-120m", },
- { /* 6 */ .g = 6, .descr = "0-120m", },
- { /* 7 */ .g = 5, .descr = "0-120m", },
- { /* 8 */ .g = 4, .descr = "0-120m", },
- { /* 9 */ .g = 4, .descr = "0-120m", },
- { /* 10 */ .g = 3, .descr = "0-120m", },
- { /* 11 */ .g = 3, .descr = "0-120m", },
- { /* 12 */ .g = 2, .descr = "0-120m", },
- { /* 13 */ .g = 2, .descr = "0-120m", },
- { /* 14 */ .g = 2, .descr = "0-120m", },
- { /* 15 */ .g = 1, .descr = "0-120m", },
- { /* 16 */ .g = 1, .descr = "0-120m", },
- { /* 17 */ .g = 1, .descr = "0-120m", },
- { /* 18 */ .g = 0, .descr = "0-120m", },
+struct nl2gl_t nl2gl_1[] = {
+ { /* 0 */ .g = 12, .descr = "0-120m", },
+ { /* 1 */ .g = 11, .descr = "0-120m", },
+ { /* 2 */ .g = 10, .descr = "0-120m", },
+ { /* 3 */ .g = 9, .descr = "0-120m", },
+ { /* 4 */ .g = 8, .descr = "0-120m", },
+ { /* 5 */ .g = 7, .descr = "0-120m", },
+ { /* 6 */ .g = 6, .descr = "0-120m", },
+ { /* 7 */ .g = 5, .descr = "0-120m", },
+ { /* 8 */ .g = 4, .descr = "0-120m", },
+ { /* 9 */ .g = 4, .descr = "0-120m", },
+ { /* 10 */ .g = 3, .descr = "0-120m", },
+ { /* 11 */ .g = 3, .descr = "0-120m", },
+ { /* 12 */ .g = 2, .descr = "0-120m", },
+ { /* 13 */ .g = 2, .descr = "0-120m", },
+ { /* 14 */ .g = 2, .descr = "0-120m", },
+ { /* 15 */ .g = 1, .descr = "0-120m", },
+ { /* 16 */ .g = 1, .descr = "0-120m", },
+ { /* 17 */ .g = 1, .descr = "0-120m", },
+ { /* 18 */ .g = 0, .descr = "0-120m", },
};
-struct nl2gl_t nl2gl[] = {
- { /* 0 */ .g = 9, .descr = "0-120m", },
- { /* 1 */ .g = 9, .descr = "0-120m", },
- { /* 2 */ .g = 8, .descr = "0-120m", },
- { /* 3 */ .g = 8, .descr = "0-120m", },
- { /* 4 */ .g = 7, .descr = "0-120m", },
- { /* 5 */ .g = 7, .descr = "0-120m", },
- { /* 6 */ .g = 6, .descr = "0-120m", },
- { /* 7 */ .g = 6, .descr = "0-120m", },
- { /* 8 */ .g = 5, .descr = "0-120m", },
- { /* 9 */ .g = 5, .descr = "0-120m", },
- { /* 10 */ .g = 4, .descr = "0-120m", },
- { /* 11 */ .g = 4, .descr = "0-120m", },
- { /* 12 */ .g = 3, .descr = "0-120m", },
- { /* 13 */ .g = 3, .descr = "0-120m", },
- { /* 14 */ .g = 2, .descr = "0-120m", },
- { /* 15 */ .g = 2, .descr = "0-120m", },
- { /* 16 */ .g = 1, .descr = "0-120m", },
- { /* 17 */ .g = 1, .descr = "0-120m", },
- { /* 18 */ .g = 0, .descr = "0-120m", },
+struct nl2gl_t nl2gl[] = {
+ { /* 0 */ .g = 9, .descr = "0-120m", },
+ { /* 1 */ .g = 9, .descr = "0-120m", },
+ { /* 2 */ .g = 8, .descr = "0-120m", },
+ { /* 3 */ .g = 8, .descr = "0-120m", },
+ { /* 4 */ .g = 7, .descr = "0-120m", },
+ { /* 5 */ .g = 7, .descr = "0-120m", },
+ { /* 6 */ .g = 6, .descr = "0-120m", },
+ { /* 7 */ .g = 6, .descr = "0-120m", },
+ { /* 8 */ .g = 5, .descr = "0-120m", },
+ { /* 9 */ .g = 5, .descr = "0-120m", },
+ { /* 10 */ .g = 4, .descr = "0-120m", },
+ { /* 11 */ .g = 4, .descr = "0-120m", },
+ { /* 12 */ .g = 3, .descr = "0-120m", },
+ { /* 13 */ .g = 3, .descr = "0-120m", },
+ { /* 14 */ .g = 2, .descr = "0-120m", },
+ { /* 15 */ .g = 2, .descr = "0-120m", },
+ { /* 16 */ .g = 1, .descr = "0-120m", },
+ { /* 17 */ .g = 1, .descr = "0-120m", },
+ { /* 18 */ .g = 0, .descr = "0-120m", },
};
-static int
-get_level(struct map_selection *sel)
-{
- return sel->order;
+static int get_level(struct map_selection *sel) {
+ return sel->order;
}
-static int
-garmin_get_selection(struct map_rect_priv *map, struct map_selection *sel)
-{
- struct gar_rect r;
- struct gmap *gm;
- struct gobject **glast = NULL;
- int rc;
- int sl, el;
- int level = 0; // 18; /* max level for maps, overview maps can have bigger
- /* levels we do not deal w/ them
- */
- int flags = 0;
- if (sel && sel->range.min == type_street_0 && sel->range.max == type_ferry) {
- // Get all roads
- flags = GO_GET_ROUTABLE;
- } else if (sel)
- flags = GO_GET_SORTED;
-
- if (sel) {
- r.lulat = sel->u.c_rect.lu.y;
- r.lulong = sel->u.c_rect.lu.x;
- r.rllat = sel->u.c_rect.rl.y;
- r.rllong = sel->u.c_rect.rl.x;
- level = get_level(sel);
+static int garmin_get_selection(struct map_rect_priv *map, struct map_selection *sel) {
+ struct gar_rect r;
+ struct gmap *gm;
+ struct gobject **glast = NULL;
+ int rc;
+ int sl, el;
+ int level = 0; // 18; /* max level for maps, overview maps can have bigger
+ /* levels we do not deal w/ them
+ */
+ int flags = 0;
+ if (sel && sel->range.min == type_street_0 && sel->range.max == type_ferry) {
+ // Get all roads
+ flags = GO_GET_ROUTABLE;
+ } else if (sel)
+ flags = GO_GET_SORTED;
+
+ if (sel) {
+ r.lulat = sel->u.c_rect.lu.y;
+ r.lulong = sel->u.c_rect.lu.x;
+ r.rllat = sel->u.c_rect.rl.y;
+ r.rllong = sel->u.c_rect.rl.x;
+ level = get_level(sel);
// level = nl2gl[level].g;
- dlog(2, "Looking level=%d for %f %f %f %f\n",
- level, r.lulat, r.lulong, r.rllat, r.rllong);
- }
- gm = gar_find_subfiles(map->mpriv->g, sel ? &r : NULL, flags);
- if (!gm) {
- if (sel) {
- dlog(1, "Can not find map data for the area: %f %f %f %f\n",
- r.lulat, r.lulong, r.rllat, r.rllong);
- } else {
- dlog(1, "Can not find map data\n");
- }
- return -1;
- }
-#if 0
- sl = (18-(gm->maxlevel - gm->minlevel))/2;
- el = sl + (gm->maxlevel - gm->minlevel);
- if (level < sl)
- level = sl;
- if (level > el)
- level = el;
- level = level - sl;
- level = (gm->maxlevel - gm->minlevel) - level;
- dlog(3, "sl=%d el=%d level=%d\n", sl, el, level);
-#endif
- sl = (18-gm->zoomlevels)/2;
- el = sl + gm->zoomlevels;
- if (level < sl)
- level = sl;
- if (level > el)
- level = el;
- level = level - sl;
- level = gm->basebits + level;
- dlog(3, "sl=%d el=%d level=%d\n", sl, el, level);
- map->gmap = gm;
- glast = &map->objs;
- while (*glast) {
- if ((*glast)->next) {
- *glast = (*glast)->next;
- } else
- break;
- }
- rc = gar_get_objects(gm, level, sel ? &r : NULL, glast, flags);
- if (rc < 0) {
- dlog(1, "Error loading objects\n");
- return -1;
- }
- map->cobj = map->objs;
- dlog(2, "Loaded %d objects\n", rc);
- return rc;
+ dlog(2, "Looking level=%d for %f %f %f %f\n",
+ level, r.lulat, r.lulong, r.rllat, r.rllong);
+ }
+ gm = gar_find_subfiles(map->mpriv->g, sel ? &r : NULL, flags);
+ if (!gm) {
+ if (sel) {
+ dlog(1, "Can not find map data for the area: %f %f %f %f\n",
+ r.lulat, r.lulong, r.rllat, r.rllong);
+ } else {
+ dlog(1, "Can not find map data\n");
+ }
+ return -1;
+ }
+ sl = (18-gm->zoomlevels)/2;
+ el = sl + gm->zoomlevels;
+ if (level < sl)
+ level = sl;
+ if (level > el)
+ level = el;
+ level = level - sl;
+ level = gm->basebits + level;
+ dlog(3, "sl=%d el=%d level=%d\n", sl, el, level);
+ map->gmap = gm;
+ glast = &map->objs;
+ while (*glast) {
+ if ((*glast)->next) {
+ *glast = (*glast)->next;
+ } else
+ break;
+ }
+ rc = gar_get_objects(gm, level, sel ? &r : NULL, glast, flags);
+ if (rc < 0) {
+ dlog(1, "Error loading objects\n");
+ return -1;
+ }
+ map->cobj = map->objs;
+ dlog(2, "Loaded %d objects\n", rc);
+ return rc;
}
// Can not return NULL, navit segfaults
-static struct map_rect_priv *
-gmap_rect_new(struct map_priv *map, struct map_selection *sel)
-{
- struct map_selection *ms = sel;
- struct map_rect_priv *mr;
-
- if (!map)
- return NULL;
- mr = calloc(1, sizeof(*mr));
- if (!mr)
- return mr;
- mr->mpriv = map;
- if (!sel) {
- return mr;
- } else {
- while (ms) {
- dlog(2, "order %d\n", ms->order);
- if (garmin_get_selection(mr, ms) < 0) {
- // free(mr);
- // return NULL;
- }
- ms = ms->next;
- }
- }
- return mr;
+static struct map_rect_priv *gmap_rect_new(struct map_priv *map, struct map_selection *sel) {
+ struct map_selection *ms = sel;
+ struct map_rect_priv *mr;
+
+ if (!map)
+ return NULL;
+ mr = calloc(1, sizeof(*mr));
+ if (!mr)
+ return mr;
+ mr->mpriv = map;
+ if (!sel) {
+ return mr;
+ } else {
+ while (ms) {
+ dlog(2, "order %d\n", ms->order);
+ if (garmin_get_selection(mr, ms) < 0) {
+ // free(mr);
+ // return NULL;
+ }
+ ms = ms->next;
+ }
+ }
+ return mr;
}
-static void
-gmap_rect_destroy(struct map_rect_priv *mr)
-{
- dlog(11,"destroy maprect\n");
- if (mr->gmap)
- gar_free_gmap(mr->gmap);
- if (mr->objs)
- gar_free_objects(mr->objs);
- if (mr->label)
- free(mr->label);
- free(mr);
+static void gmap_rect_destroy(struct map_rect_priv *mr) {
+ dlog(11,"destroy maprect\n");
+ if (mr->gmap)
+ gar_free_gmap(mr->gmap);
+ if (mr->objs)
+ gar_free_objects(mr->objs);
+ if (mr->label)
+ free(mr->label);
+ free(mr);
}
-static void
-gmap_search_destroy(struct map_search_priv *ms)
-{
- gmap_rect_destroy((struct map_rect_priv *)ms);
+static void gmap_search_destroy(struct map_search_priv *ms) {
+ gmap_rect_destroy((struct map_rect_priv *)ms);
}
-static void
-gmap_destroy(struct map_priv *m)
-{
- dlog(5, "garmin_map_destroy\n");
- if (m->g)
- gar_free(m->g);
- if (m->filename)
- free(m->filename);
- free(m);
+static void gmap_destroy(struct map_priv *m) {
+ dlog(5, "garmin_map_destroy\n");
+ if (m->g)
+ gar_free(m->g);
+ if (m->filename)
+ free(m->filename);
+ free(m);
}
static struct map_methods map_methods = {
- projection_garmin,
- "utf-8",
- gmap_destroy,
- gmap_rect_new,
- gmap_rect_destroy,
- gmap_rect_get_item,
- gmap_rect_get_item_byid,
- gmap_search_new,
- gmap_search_destroy,
- NULL,
+ projection_garmin,
+ "utf-8",
+ gmap_destroy,
+ gmap_rect_new,
+ gmap_rect_destroy,
+ gmap_rect_get_item,
+ gmap_rect_get_item_byid,
+ gmap_search_new,
+ gmap_search_destroy,
+ NULL,
};
-static struct map_priv *
-gmap_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct map_priv *m;
- struct attr *data;
- struct attr *debug;
- struct attr *flags;
- char buf[PATH_MAX];
- struct stat st;
- int dl = 1;
- struct gar_config cfg;
- int debugmask = 0;
-
- data=attr_search(attrs, NULL, attr_data);
- if (! data)
- return NULL;
- debug=attr_search(attrs, NULL, attr_debug);
- if (debug) {
- dl = atoi(debug->u.str);
- if (!dl)
- dl = 1;
- }
- flags=attr_search(attrs, NULL, attr_flags);
- if (flags) {
- debugmask = flags->u.num;
- }
- m=g_new(struct map_priv, 1);
- m->id=++map_id;
- m->filename = strdup(data->u.str);
- if (!m->filename) {
- g_free(m);
- return NULL;
- }
- memset(&cfg, 0, sizeof(struct gar_config));
- cfg.opm = OPM_GPS;
- cfg.debuglevel = dl;
- cfg.debugmask = debugmask;
- garmin_debug = dl;
- m->g = gar_init_cfg(NULL, logfn, &cfg);
- if (!m->g) {
- g_free(m->filename);
- g_free(m);
- return NULL;
- }
- // we want the data now, later we can load only what's necessery
- if (gar_img_load(m->g, m->filename, 1) < 0) {
- gar_free(m->g);
- g_free(m->filename);
- g_free(m);
- return NULL;
- }
- m->conv = NULL;
- snprintf(buf, sizeof(buf), "%s.types", m->filename);
- if (!stat(buf, &st)) {
- dlog(1, "Loading custom types from %s\n", buf);
- m->conv = g2n_conv_load(buf);
- }
- if (!m->conv) {
- dlog(1, "Using builtin types\n");
- m->conv = g2n_default_conv();
- }
- if (!m->conv) {
- dlog(1, "Failed to load map types\n");
- }
- *meth=map_methods;
- return m;
+static struct map_priv *gmap_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *m;
+ struct attr *data;
+ struct attr *debug;
+ struct attr *flags;
+ char buf[PATH_MAX];
+ struct stat st;
+ int dl = 1;
+ struct gar_config cfg;
+ int debugmask = 0;
+
+ data=attr_search(attrs, NULL, attr_data);
+ if (! data)
+ return NULL;
+ debug=attr_search(attrs, NULL, attr_debug);
+ if (debug) {
+ dl = atoi(debug->u.str);
+ if (!dl)
+ dl = 1;
+ }
+ flags=attr_search(attrs, NULL, attr_flags);
+ if (flags) {
+ debugmask = flags->u.num;
+ }
+ m=g_new(struct map_priv, 1);
+ m->id=++map_id;
+ m->filename = strdup(data->u.str);
+ if (!m->filename) {
+ g_free(m);
+ return NULL;
+ }
+ memset(&cfg, 0, sizeof(struct gar_config));
+ cfg.opm = OPM_GPS;
+ cfg.debuglevel = dl;
+ cfg.debugmask = debugmask;
+ garmin_debug = dl;
+ m->g = gar_init_cfg(NULL, logfn, &cfg);
+ if (!m->g) {
+ g_free(m->filename);
+ g_free(m);
+ return NULL;
+ }
+ // we want the data now, later we can load only what's necessery
+ if (gar_img_load(m->g, m->filename, 1) < 0) {
+ gar_free(m->g);
+ g_free(m->filename);
+ g_free(m);
+ return NULL;
+ }
+ m->conv = NULL;
+ snprintf(buf, sizeof(buf), "%s.types", m->filename);
+ if (!stat(buf, &st)) {
+ dlog(1, "Loading custom types from %s\n", buf);
+ m->conv = g2n_conv_load(buf);
+ }
+ if (!m->conv) {
+ dlog(1, "Using builtin types\n");
+ m->conv = g2n_default_conv();
+ }
+ if (!m->conv) {
+ dlog(1, "Failed to load map types\n");
+ }
+ *meth=map_methods;
+ return m;
}
-void
-plugin_init(void)
-{
- plugin_register_category_map("garmin", gmap_new);
+void plugin_init(void) {
+ plugin_register_category_map("garmin", gmap_new);
}
diff --git a/navit/map/garmin/garmin.h b/navit/map/garmin/garmin.h
index 94e893b12..c1feaacba 100644
--- a/navit/map/garmin/garmin.h
+++ b/navit/map/garmin/garmin.h
@@ -12,9 +12,9 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
-
+
Garmin and MapSource are registered trademarks or trademarks
of Garmin Ltd. or one of its subsidiaries.
diff --git a/navit/map/garmin/garmintypes.txt b/navit/map/garmin/garmintypes.txt
index ce8b0d495..5f902f937 100644
--- a/navit/map/garmin/garmintypes.txt
+++ b/navit/map/garmin/garmintypes.txt
@@ -46,7 +46,7 @@ POINT
0, 0x2000-0x203F = highway_exit, Exit
0, 0x2100-0x213F = highway_exit, Exit with Services
0, 0x2200-0x223F = highway_exit, Exit with Restroom
-0, 0x2300-0x233F = highway_exit, Exit with Convinience Store
+0, 0x2300-0x233F = highway_exit, Exit with Convenience Store
0, 0x2400-0x243F = highway_exit, Exit with Weight Station
0, 0x2500-0x253F = highway_exit, Exit with Toolbooth Booth
0, 0x2600-0x263F = highway_exit, Exit with Information
@@ -155,7 +155,7 @@ POINT
0, 0x3004 = poi_justice, Justice
0, 0x3005 = poi_concert, Concert hall(point)
0, 0x3006 = poi_border_station, Border Station(point)
-0, 0x3007 = poi_goverment_building, Goverment Building
+0, 0x3007 = poi_government_building, Government Building
0, 0x3008 = poi_firebrigade, FireFighters Station
0, 0x4000-0x403F = poi_golf, Golf
@@ -181,7 +181,7 @@ POINT
0, 0x5400-0x543F = poi_swimming, Swimming
0, 0x5500-0x553F = poi_dam, Dam
-0, 0x5600-0x563F = poi_forbidden_area, Forbiden Area
+0, 0x5600-0x563F = poi_forbidden_area, Forbidden Area
0, 0x5700-0x573F = poi_danger_area, Danger Area
0, 0x5800-0x583F = poi_restricted_area, Restricted Area
@@ -300,7 +300,7 @@ POINT
0, 0x1614 = poi_marine_type, lighted Navaid, violet
0, 0x1615 = poi_marine_type, lighted Navaid, blue
0, 0x1616 = poi_marine_type, lighted Navaid, multi colored
-# RGN2-4 types
+# RGN2-4 types
# Marine types start
1, 0x0100 = point_unkn, Light
1, 0x0102 = point_unkn, Light with north topmark
@@ -409,7 +409,7 @@ POINT
1, 0x0d07 = poi_zoo, Zoo
1, 0x0d08 = poi_stadium, Sportpark, Stadium
1, 0x0d0a = poi_bar, Wine Bar
-1, 0x0d14 = poi_hospital, Hospital
+1, 0x0d14 = poi_hospital, Hospital
1, 0x0e01 = poi_theater, Theater
1, 0x0e02 = poi_bar, Bar
1, 0x0e03 = poi_cinema, Cinema
@@ -438,9 +438,9 @@ POINT
1, 0x100b = poi_car_parking, Parking
1, 0x100d = poi_car_dealer_parts, Car Dealer(point)
1, 0x100e = poi_car_wash, Car Wash
-1, 0x1011 = poi_bussines_service, Business Service
+1, 0x1011 = poi_business_service, Business Service
1, 0x1012 = poi_communication, Communication
-1, 0x1013 = poi_repair_service, Repair Service
+1, 0x1013 = poi_repair_service, Repair Service
1, 0x1014 = poi_social_service, Social Service
1, 0x1015 = poi_public_utilities, Utility
1, 0x1101 = poi_police, Police Station
@@ -464,7 +464,7 @@ POINT
1, 0x140c = town_label_1e0, Village (100-200)
1, 0x140d = town_label_0e0, Village (0-100)
1, 0x1500 = poi_personal_service, Personal Service
-1, 0x1501 = poi_bussines_service, Bussines Service
+1, 0x1501 = poi_business_service, Business Service
POLYLINE
@@ -633,7 +633,7 @@ POLYGONE
0, 0x51 = poly_wetland, Wetland
0, 0x52 = tundra, Tundra
0, 0x53 = poly_flats, Flats
-# RGN2-4
+# RGN2-4
# Marine
1, 0x0100 = street_unkn, Land - white
1, 0x0101 = street_unkn, Land - non-urban
diff --git a/navit/map/garmin/gentypes.c b/navit/map/garmin/gentypes.c
index 16682a55a..5f7b28687 100644
--- a/navit/map/garmin/gentypes.c
+++ b/navit/map/garmin/gentypes.c
@@ -12,9 +12,9 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
-
+
Garmin and MapSource are registered trademarks or trademarks
of Garmin Ltd. or one of its subsidiaries.
@@ -59,90 +59,87 @@ static int add_def(struct gar2nav_conv *conv, int type, unsigned short minid,
char *descr)
*/
-static void print_header(FILE *fp)
-{
- fprintf(fp, "// This is autogenerated file -- DO NOT EDIT\n");
- fprintf(fp, "struct gar2nav_conv *g2n_default_conv(void)\n"
- "{\n"
- "\tstruct gar2nav_conv *conv;\n"
- "\n"
- "\tconv = calloc(1, sizeof(*conv));\n"
- "\tif (!conv)\n"
- "\t\treturn conv;\n");
+static void print_header(FILE *fp) {
+ fprintf(fp, "// This is autogenerated file -- DO NOT EDIT\n");
+ fprintf(fp, "struct gar2nav_conv *g2n_default_conv(void)\n"
+ "{\n"
+ "\tstruct gar2nav_conv *conv;\n"
+ "\n"
+ "\tconv = calloc(1, sizeof(*conv));\n"
+ "\tif (!conv)\n"
+ "\t\treturn conv;\n");
}
-static int load_types_file(char *file, char *out)
-{
- char buf[4096];
- char descr[4096];
- char ntype[4096];
- FILE *fp;
- unsigned int minid, maxid, group;
- int rc;
- int type = -1;
- FILE *fpout = stdout;
-
- fp = fopen(file, "r");
- if (!fp)
- return -1;
- if (out) {
- fpout = fopen(out, "w");
- if (!fpout)
- return -1;
- }
- print_header(fpout);
- while (fgets(buf, sizeof(buf), fp)) {
- if (*buf == '#' || *buf == '\n')
- continue;
- if (!strncasecmp(buf, "POINT", 5)) {
- type = 1;
- continue;
- } else if (!strncasecmp(buf, "POI", 3)) {
- type = 1;
- continue;
- } else if (!strncasecmp(buf, "POLYLINE", 8)) {
- type = 2;
- continue;
- } else if (!strncasecmp(buf, "POLYGONE", 8)) {
- type = 3;
- continue;
- }
-
- rc = sscanf(buf, "%d, 0x%04X - 0x%04X = %[^\t , ] , %[^\n]",
- &group, &minid, &maxid, ntype, descr);
- if (rc != 5) {
- maxid = 0;
- rc = sscanf(buf, "%d, 0x%04X = %[^\t, ], %[^\n]",
- &group,&minid, ntype, descr);
- if (rc != 4) {
- dlog(1, "Invalid line rc=%d:[%s]\n",rc, buf);
- dlog(1, "minid=%04X ntype=[%s] des=[%s]\n",
- minid, ntype, descr);
- continue;
- }
- }
-
- fprintf(fpout, "\tadd_def(conv, %d, %#.04x, %#.04x, %d, \"%s\", \"%s\");\n",
- type, minid, maxid, group, ntype, descr);
- }
- fprintf(fpout, "\treturn conv;\n");
- fprintf(fpout, "}\n");
- fclose(fp);
- if (out)
- fclose(fpout);
- return 1;
+static int load_types_file(char *file, char *out) {
+ char buf[4096];
+ char descr[4096];
+ char ntype[4096];
+ FILE *fp;
+ unsigned int minid, maxid, group;
+ int rc;
+ int type = -1;
+ FILE *fpout = stdout;
+
+ fp = fopen(file, "r");
+ if (!fp)
+ return -1;
+ if (out) {
+ fpout = fopen(out, "w");
+ if (!fpout)
+ return -1;
+ }
+ print_header(fpout);
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (*buf == '#' || *buf == '\n')
+ continue;
+ if (!strncasecmp(buf, "POINT", 5)) {
+ type = 1;
+ continue;
+ } else if (!strncasecmp(buf, "POI", 3)) {
+ type = 1;
+ continue;
+ } else if (!strncasecmp(buf, "POLYLINE", 8)) {
+ type = 2;
+ continue;
+ } else if (!strncasecmp(buf, "POLYGONE", 8)) {
+ type = 3;
+ continue;
+ }
+
+ rc = sscanf(buf, "%d, 0x%04X - 0x%04X = %[^\t , ] , %[^\n]",
+ &group, &minid, &maxid, ntype, descr);
+ if (rc != 5) {
+ maxid = 0;
+ rc = sscanf(buf, "%d, 0x%04X = %[^\t, ], %[^\n]",
+ &group,&minid, ntype, descr);
+ if (rc != 4) {
+ dlog(1, "Invalid line rc=%d:[%s]\n",rc, buf);
+ dlog(1, "minid=%04X ntype=[%s] des=[%s]\n",
+ minid, ntype, descr);
+ continue;
+ }
+ }
+
+ fprintf(fpout, "\tadd_def(conv, %d, %#.04x, %#.04x, %d, \"%s\", \"%s\");\n",
+ type, minid, maxid, group, ntype, descr);
+ }
+ fprintf(fpout, "\treturn conv;\n");
+ fprintf(fpout, "}\n");
+ fclose(fp);
+ if (out)
+ fclose(fpout);
+ return 1;
}
-int main(int argc, char **argv)
-{
- if (argc!=3) {
- fprintf(stderr, "Usage: %s garmintypes.txt outfile.c\n",
- argv[0]);
- return -1;
- }
- if (load_types_file(argv[1], argv[2]) < 0) {
- unlink(argv[2]);
- return -1;
- }
- return 0;
+int main(int argc, char **argv) {
+ if (argc!=3) {
+ fprintf(stderr, "Usage: %s garmintypes.txt outfile.c\n",
+ argv[0]);
+ return -1;
+ }
+ if (load_types_file(argv[1], argv[2]) < 0) {
+ unlink(argv[2]);
+ return -1;
+ }
+ return 0;
}
diff --git a/navit/map/garmin_img/garmin_img.c b/navit/map/garmin_img/garmin_img.c
index f7dccf89c..73a7dc92b 100644
--- a/navit/map/garmin_img/garmin_img.c
+++ b/navit/map/garmin_img/garmin_img.c
@@ -37,8 +37,8 @@
#include "coord.h"
struct file {
- FILE *f;
- int offset;
+ FILE *f;
+ int offset;
};
@@ -46,1468 +46,1383 @@ int shift=5;
int subdiv_next=0x10;
-static void *
-file_read(struct file *f, int offset, int size)
-{
- void *ptr;
- int ret;
-
- ptr=calloc(size, 1);
- if (! ptr)
- return ptr;
- fseek(f->f, f->offset+offset, SEEK_SET);
- ret=fread(ptr, size, 1, f->f);
- if (ret != 1) {
- printf("fread %d vs %d offset %d+%d(0x%x)\n", ret, size, f->offset, offset,offset);
- g_assert(1==0);
- }
- return ptr;
+static void *file_read(struct file *f, int offset, int size) {
+ void *ptr;
+ int ret;
+
+ ptr=calloc(size, 1);
+ if (! ptr)
+ return ptr;
+ fseek(f->f, f->offset+offset, SEEK_SET);
+ ret=fread(ptr, size, 1, f->f);
+ if (ret != 1) {
+ printf("fread %d vs %d offset %d+%d(0x%x)\n", ret, size, f->offset, offset,offset);
+ g_assert(1==0);
+ }
+ return ptr;
}
-static void
-file_free(void *ptr)
-{
- free(ptr);
+static void file_free(void *ptr) {
+ free(ptr);
}
struct offset_len {
- int offset;
- int length;
+ int offset;
+ int length;
} __attribute ((packed));
-static void
-dump_offset_len(struct offset_len *off_len)
-{
- printf("offset: 0x%x(%d) length 0x%x(%d)\n", off_len->offset, off_len->offset, off_len->length, off_len->length);
+static void dump_offset_len(struct offset_len *off_len) {
+ printf("offset: 0x%x(%d) length 0x%x(%d)\n", off_len->offset, off_len->offset, off_len->length, off_len->length);
}
struct timestamp {
- short creation_year;
- char creation_month;
- char creation_day;
- char creation_hour;
- char creation_minute;
- char creation_second;
+ short creation_year;
+ char creation_month;
+ char creation_day;
+ char creation_hour;
+ char creation_minute;
+ char creation_second;
} __attribute__((packed));
struct img_header {
- char xor;
- char zero1[9];
- char update_month;
- char update_year;
- char zero2[3];
- char checksum[1];
- char signature[7];
- char unknown1[1];
- char unknown2[2];
- char unknown3[2];
- char unknown4[2];
- char unknown5[2];
- char zero3[25];
- struct timestamp ts;
- char unknown6;
- char map_file_identifier[7];
- char unknown12;
- char map_description1[20];
- short unknown13;
- short unknown14;
- char e1;
- char e2;
- char other[413];
- char zero4[512];
- char unknown7;
- char unknown8[11];
- int file_offset;
- char unknown9;
- char unknown10[15];
- char unknown11[480];
+ char xor;
+ char zero1[9];
+ char update_month;
+ char update_year;
+ char zero2[3];
+ char checksum[1];
+ char signature[7];
+ char unknown1[1];
+ char unknown2[2];
+ char unknown3[2];
+ char unknown4[2];
+ char unknown5[2];
+ char zero3[25];
+ struct timestamp ts;
+ char unknown6;
+ char map_file_identifier[7];
+ char unknown12;
+ char map_description1[20];
+ short unknown13;
+ short unknown14;
+ char e1;
+ char e2;
+ char other[413];
+ char zero4[512];
+ char unknown7;
+ char unknown8[11];
+ int file_offset;
+ char unknown9;
+ char unknown10[15];
+ char unknown11[480];
} __attribute__((packed));
-static void
-dump_ts(struct timestamp *ts)
-{
- printf("%d-%02d-%02d %02d:%02d:%02d\n", ts->creation_year, ts->creation_month, ts->creation_day, ts->creation_hour, ts->creation_minute, ts->creation_second);
+static void dump_ts(struct timestamp *ts) {
+ printf("%d-%02d-%02d %02d:%02d:%02d\n", ts->creation_year, ts->creation_month, ts->creation_day, ts->creation_hour,
+ ts->creation_minute, ts->creation_second);
}
#if 0
-static void
-dump_img(struct img_header *img_hdr)
-{
- printf("signature: '%s'\n", img_hdr->signature);
- printf("creation: ");
- dump_ts(&img_hdr->ts);
- printf("map_file_identifier: '%s'\n", img_hdr->map_file_identifier);
- printf("file_offset: 0x%x\n", img_hdr->file_offset);
- printf("e1: 0x%x(%d)\n", img_hdr->e1, img_hdr->e1);
- printf("e2: 0x%x(%d)\n", img_hdr->e2, img_hdr->e2);
- printf("offset 0x%x\n", (int) &img_hdr->e1 - (int) img_hdr);
- printf("size %d\n", sizeof(*img_hdr));
+static void dump_img(struct img_header *img_hdr) {
+ printf("signature: '%s'\n", img_hdr->signature);
+ printf("creation: ");
+ dump_ts(&img_hdr->ts);
+ printf("map_file_identifier: '%s'\n", img_hdr->map_file_identifier);
+ printf("file_offset: 0x%x\n", img_hdr->file_offset);
+ printf("e1: 0x%x(%d)\n", img_hdr->e1, img_hdr->e1);
+ printf("e2: 0x%x(%d)\n", img_hdr->e2, img_hdr->e2);
+ printf("offset 0x%x\n", (int) &img_hdr->e1 - (int) img_hdr);
+ printf("size %d\n", sizeof(*img_hdr));
}
#endif
struct fat_block {
- char flag;
- char filename[8];
- char type[3];
- int size;
- char zero1;
- char part;
- char zero[14];
- unsigned short blocks[240];
+ char flag;
+ char filename[8];
+ char type[3];
+ int size;
+ char zero1;
+ char part;
+ char zero[14];
+ unsigned short blocks[240];
} __attribute__((packed));
#if 0
-static void
-dump_fat_block(struct fat_block *fat_blk)
-{
- int i=0;
- char name[9];
- char type[4];
- printf("flag: 0x%x(%d)\n", fat_blk->flag, fat_blk->flag);
- strcpy(name, fat_blk->filename);
- name[8]='\0';
- strcpy(type, fat_blk->type);
- type[3]='\0';
- printf("name: '%s.%s'\n", name, type);
- printf("size: 0x%x(%d)\n", fat_blk->size, fat_blk->size);
- printf("part: 0x%x(%d)\n", fat_blk->part, fat_blk->part);
- printf("blocks: ");
- while (i < 240) {
- printf("0x%x(%d) ",fat_blk->blocks[i], fat_blk->blocks[i]);
- if (fat_blk->blocks[i] == 0xffff)
- break;
- i++;
- }
- printf("size: %d\n", sizeof(*fat_blk));
-
+static void dump_fat_block(struct fat_block *fat_blk) {
+ int i=0;
+ char name[9];
+ char type[4];
+ printf("flag: 0x%x(%d)\n", fat_blk->flag, fat_blk->flag);
+ strcpy(name, fat_blk->filename);
+ name[8]='\0';
+ strcpy(type, fat_blk->type);
+ type[3]='\0';
+ printf("name: '%s.%s'\n", name, type);
+ printf("size: 0x%x(%d)\n", fat_blk->size, fat_blk->size);
+ printf("part: 0x%x(%d)\n", fat_blk->part, fat_blk->part);
+ printf("blocks: ");
+ while (i < 240) {
+ printf("0x%x(%d) ",fat_blk->blocks[i], fat_blk->blocks[i]);
+ if (fat_blk->blocks[i] == 0xffff)
+ break;
+ i++;
+ }
+ printf("size: %d\n", sizeof(*fat_blk));
+
}
#endif
struct file_header {
- short header_len;
- char type[10];
- char unknown1;
- char unknown2;
- struct timestamp ts;
+ short header_len;
+ char type[10];
+ char unknown1;
+ char unknown2;
+ struct timestamp ts;
} __attribute__((packed));
-static void
-dump_file(struct file_header *fil_hdr)
-{
- printf("header_len: %d\n", fil_hdr->header_len);
- printf("type: '%s'\n", fil_hdr->type);
- printf("unknown1: 0x%x(%d)\n", fil_hdr->unknown1, fil_hdr->unknown1);
- printf("unknown2: 0x%x(%d)\n", fil_hdr->unknown2, fil_hdr->unknown2);
- printf("creation: ");
- dump_ts(&fil_hdr->ts);
- printf("size %d\n", sizeof(*fil_hdr));
+static void dump_file(struct file_header *fil_hdr) {
+ printf("header_len: %d\n", fil_hdr->header_len);
+ printf("type: '%s'\n", fil_hdr->type);
+ printf("unknown1: 0x%x(%d)\n", fil_hdr->unknown1, fil_hdr->unknown1);
+ printf("unknown2: 0x%x(%d)\n", fil_hdr->unknown2, fil_hdr->unknown2);
+ printf("creation: ");
+ dump_ts(&fil_hdr->ts);
+ printf("size %d\n", sizeof(*fil_hdr));
}
struct region_header {
- struct file_header fil_hdr;
- struct offset_len offset_len;
+ struct file_header fil_hdr;
+ struct offset_len offset_len;
} __attribute__((packed));
#if 0
-static void
-dump_region(struct region_header *rgn_hdr)
-{
- dump_offset_len(&rgn_hdr->offset_len);
+static void dump_region(struct region_header *rgn_hdr) {
+ dump_offset_len(&rgn_hdr->offset_len);
}
#endif
struct map_priv {
- int id;
- char *filename;
+ int id;
+ char *filename;
};
struct map_rect_priv {
- struct coord_rect r;
- int limit;
-
- struct file tre;
- struct tree_header *tre_hdr;
- struct file rgn;
- struct region_header *rgn_hdr;
- struct file lbl;
- struct label_header *lbl_hdr;
- char *label;
-
- int subdiv_level_count;
- int subdiv_pos;
- char *subdiv;
-
- int rgn_offset;
- int rgn_end;
- struct rgn_point *pnt;
- struct rgn_poly *ply;
- unsigned char *ply_data;
- int ply_bitpos;
- int ply_bitcount;
- int ply_lngbits;
- int ply_latbits;
- int ply_lng;
- int ply_lat;
- int ply_lnglimit;
- int ply_latlimit;
- int ply_lngsign;
- int ply_latsign;
- struct offset_len rgn_items[4];
- int rgn_type;
-
- int count;
-
- FILE *f;
- long pos;
- char line[256];
- int attr_pos;
- enum attr_type attr_last;
- char attrs[256];
- char attr[256];
- double lat,lng;
- char lat_c,lng_c;
- int eoc;
- struct map_priv *m;
- struct item item;
+ struct coord_rect r;
+ int limit;
+
+ struct file tre;
+ struct tree_header *tre_hdr;
+ struct file rgn;
+ struct region_header *rgn_hdr;
+ struct file lbl;
+ struct label_header *lbl_hdr;
+ char *label;
+
+ int subdiv_level_count;
+ int subdiv_pos;
+ char *subdiv;
+
+ int rgn_offset;
+ int rgn_end;
+ struct rgn_point *pnt;
+ struct rgn_poly *ply;
+ unsigned char *ply_data;
+ int ply_bitpos;
+ int ply_bitcount;
+ int ply_lngbits;
+ int ply_latbits;
+ int ply_lng;
+ int ply_lat;
+ int ply_lnglimit;
+ int ply_latlimit;
+ int ply_lngsign;
+ int ply_latsign;
+ struct offset_len rgn_items[4];
+ int rgn_type;
+
+ int count;
+
+ FILE *f;
+ long pos;
+ char line[256];
+ int attr_pos;
+ enum attr_type attr_last;
+ char attrs[256];
+ char attr[256];
+ double lat,lng;
+ char lat_c,lng_c;
+ int eoc;
+ struct map_priv *m;
+ struct item item;
};
static int map_id;
-static int
-contains_coord(char *line)
-{
- return g_ascii_isdigit(line[0]);
+static int contains_coord(char *line) {
+ return g_ascii_isdigit(line[0]);
}
static int debug=1;
-static int
-get_tag(char *line, char *name, int *pos, char *ret)
-{
- int len,quoted;
- char *p,*e,*n;
-
- if (debug)
- printf("get_tag %s from %s\n", name, line);
- if (! name)
- return 0;
- len=strlen(name);
- if (pos)
- p=line+*pos;
- else
- p=line;
- for(;;) {
- while (*p == ' ') {
- p++;
- }
- if (! *p)
- return 0;
- n=p;
- e=index(p,'=');
- if (! e)
- return 0;
- p=e+1;
- quoted=0;
- while (*p) {
- if (*p == ' ' && !quoted)
- break;
- if (*p == '"')
- quoted=1-quoted;
- p++;
- }
- if (e-n == len && !strncmp(n, name, len)) {
- e++;
- len=p-e;
- if (e[0] == '"') {
- e++;
- len-=2;
- }
- strncpy(ret, e, len);
- ret[len]='\0';
- if (pos)
- *pos=p-line;
- return 1;
- }
- }
- return 0;
+static int get_tag(char *line, char *name, int *pos, char *ret) {
+ int len,quoted;
+ char *p,*e,*n;
+
+ if (debug)
+ printf("get_tag %s from %s\n", name, line);
+ if (! name)
+ return 0;
+ len=strlen(name);
+ if (pos)
+ p=line+*pos;
+ else
+ p=line;
+ for(;;) {
+ while (*p == ' ') {
+ p++;
+ }
+ if (! *p)
+ return 0;
+ n=p;
+ e=index(p,'=');
+ if (! e)
+ return 0;
+ p=e+1;
+ quoted=0;
+ while (*p) {
+ if (*p == ' ' && !quoted)
+ break;
+ if (*p == '"')
+ quoted=1-quoted;
+ p++;
+ }
+ if (e-n == len && !strncmp(n, name, len)) {
+ e++;
+ len=p-e;
+ if (e[0] == '"') {
+ e++;
+ len-=2;
+ }
+ strncpy(ret, e, len);
+ ret[len]='\0';
+ if (pos)
+ *pos=p-line;
+ return 1;
+ }
+ }
+ return 0;
}
-static void
-get_line(struct map_rect_priv *mr)
-{
- mr->pos=ftell(mr->f);
- fgets(mr->line, 256, mr->f);
+static void get_line(struct map_rect_priv *mr) {
+ mr->pos=ftell(mr->f);
+ fgets(mr->line, 256, mr->f);
}
-static void
-map_destroy_garmin_img(struct map_priv *m)
-{
- if (debug)
- printf("map_destroy_garmin_img\n");
- g_free(m);
+static void map_destroy_garmin_img(struct map_priv *m) {
+ if (debug)
+ printf("map_destroy_garmin_img\n");
+ g_free(m);
}
-static char *
-map_charset_garmin_img(struct map_priv *m)
-{
- return "iso8859-1";
+static char *map_charset_garmin_img(struct map_priv *m) {
+ return "iso8859-1";
}
-static enum projection
-map_projection_garmin_img(struct map_priv *m)
-{
- return projection_garmin;
+static enum projection map_projection_garmin_img(struct map_priv *m) {
+ return projection_garmin;
}
struct label_data_offset {
- struct offset_len offset_len;
- char multiplier;
- char data;
+ struct offset_len offset_len;
+ char multiplier;
+ char data;
} __attribute ((packed));
#if 0
-static void
-dump_label_data_offset(struct label_data_offset *lbl_dat)
-{
- dump_offset_len(&lbl_dat->offset_len);
- printf("multiplier 0x%x(%d)\n", lbl_dat->multiplier, lbl_dat->multiplier);
- printf("data 0x%x(%d)\n", lbl_dat->data, lbl_dat->data);
+static void dump_label_data_offset(struct label_data_offset *lbl_dat) {
+ dump_offset_len(&lbl_dat->offset_len);
+ printf("multiplier 0x%x(%d)\n", lbl_dat->multiplier, lbl_dat->multiplier);
+ printf("data 0x%x(%d)\n", lbl_dat->data, lbl_dat->data);
}
#endif
struct label_data {
- struct offset_len offset_len;
- short size;
- int zero;
+ struct offset_len offset_len;
+ short size;
+ int zero;
} __attribute ((packed));
-static void
-dump_label_data(struct label_data *lbl_dat)
-{
- dump_offset_len(&lbl_dat->offset_len);
- printf("size 0x%x(%d)\n", lbl_dat->size, lbl_dat->size);
+static void dump_label_data(struct label_data *lbl_dat) {
+ dump_offset_len(&lbl_dat->offset_len);
+ printf("size 0x%x(%d)\n", lbl_dat->size, lbl_dat->size);
}
struct tree_header {
- struct file_header fil_hdr;
- char boundary[12];
- struct offset_len level;
- struct offset_len subdivision;
- struct label_data copyright;
- struct offset_len tre7;
- short unknown1;
- char zero1;
- struct label_data polyline;
- struct label_data polygon;
- struct label_data point;
- int mapid;
+ struct file_header fil_hdr;
+ char boundary[12];
+ struct offset_len level;
+ struct offset_len subdivision;
+ struct label_data copyright;
+ struct offset_len tre7;
+ short unknown1;
+ char zero1;
+ struct label_data polyline;
+ struct label_data polygon;
+ struct label_data point;
+ int mapid;
};
-static void
-dump_tree_header(struct tree_header *tre_hdr)
-{
- printf("tree_header:\n");
- dump_file(&tre_hdr->fil_hdr);
- printf("level: "); dump_offset_len(&tre_hdr->level);
- printf("subdivision: "); dump_offset_len(&tre_hdr->subdivision);
- printf("copyright: "); dump_label_data(&tre_hdr->copyright);
- printf("polyline: "); dump_label_data(&tre_hdr->polyline);
- printf("polygon: "); dump_label_data(&tre_hdr->polygon);
- printf("point: "); dump_label_data(&tre_hdr->point);
- printf("len: 0x%x(%d)\n", sizeof(*tre_hdr), sizeof(*tre_hdr));
+static void dump_tree_header(struct tree_header *tre_hdr) {
+ printf("tree_header:\n");
+ dump_file(&tre_hdr->fil_hdr);
+ printf("level: ");
+ dump_offset_len(&tre_hdr->level);
+ printf("subdivision: ");
+ dump_offset_len(&tre_hdr->subdivision);
+ printf("copyright: ");
+ dump_label_data(&tre_hdr->copyright);
+ printf("polyline: ");
+ dump_label_data(&tre_hdr->polyline);
+ printf("polygon: ");
+ dump_label_data(&tre_hdr->polygon);
+ printf("point: ");
+ dump_label_data(&tre_hdr->point);
+ printf("len: 0x%x(%d)\n", sizeof(*tre_hdr), sizeof(*tre_hdr));
}
struct label_header {
- struct file_header fil_hdr;
- struct label_data_offset label;
- struct label_data country;
- struct label_data region;
- struct label_data city;
- struct label_data poi_index;
- struct label_data_offset poi_properties;
- short zero1;
- char zero2;
- struct label_data poi_types;
- struct label_data zip;
- struct label_data hway;
- struct label_data exit;
- struct label_data hway_data;
- int unknown1;
- short unknown2;
- struct offset_len sort_descriptor;
- struct label_data lbl13;
- struct label_data lbl14;
+ struct file_header fil_hdr;
+ struct label_data_offset label;
+ struct label_data country;
+ struct label_data region;
+ struct label_data city;
+ struct label_data poi_index;
+ struct label_data_offset poi_properties;
+ short zero1;
+ char zero2;
+ struct label_data poi_types;
+ struct label_data zip;
+ struct label_data hway;
+ struct label_data exit;
+ struct label_data hway_data;
+ int unknown1;
+ short unknown2;
+ struct offset_len sort_descriptor;
+ struct label_data lbl13;
+ struct label_data lbl14;
} __attribute((packed));
#if 0
-static void
-dump_label(struct label_header *lbl_hdr)
-{
- dump_file(&lbl_hdr->fil_hdr);
- printf("label:\n");
- dump_label_data_offset(&lbl_hdr->label);
- printf("country:\n");
- dump_label_data(&lbl_hdr->country);
- printf("region:\n");
- dump_label_data(&lbl_hdr->region);
- printf("city:\n");
- dump_label_data(&lbl_hdr->city);
- printf("poi_index:\n");
- dump_label_data(&lbl_hdr->poi_index);
- printf("poi_properties:\n");
- dump_label_data_offset(&lbl_hdr->poi_properties);
- printf("poi_types:\n");
- dump_label_data(&lbl_hdr->poi_types);
- printf("zip:\n");
- dump_label_data(&lbl_hdr->zip);
- printf("hway:\n");
- dump_label_data(&lbl_hdr->hway);
- printf("exit:\n");
- dump_label_data(&lbl_hdr->exit);
- printf("hway_data:\n");
- dump_label_data(&lbl_hdr->hway_data);
- printf("lbl13:\n");
- dump_label_data(&lbl_hdr->lbl13);
- printf("lbl14:\n");
- dump_label_data(&lbl_hdr->lbl14);
- printf("len: 0x%x(%d)\n", sizeof(*lbl_hdr), sizeof(*lbl_hdr));
+static void dump_label(struct label_header *lbl_hdr) {
+ dump_file(&lbl_hdr->fil_hdr);
+ printf("label:\n");
+ dump_label_data_offset(&lbl_hdr->label);
+ printf("country:\n");
+ dump_label_data(&lbl_hdr->country);
+ printf("region:\n");
+ dump_label_data(&lbl_hdr->region);
+ printf("city:\n");
+ dump_label_data(&lbl_hdr->city);
+ printf("poi_index:\n");
+ dump_label_data(&lbl_hdr->poi_index);
+ printf("poi_properties:\n");
+ dump_label_data_offset(&lbl_hdr->poi_properties);
+ printf("poi_types:\n");
+ dump_label_data(&lbl_hdr->poi_types);
+ printf("zip:\n");
+ dump_label_data(&lbl_hdr->zip);
+ printf("hway:\n");
+ dump_label_data(&lbl_hdr->hway);
+ printf("exit:\n");
+ dump_label_data(&lbl_hdr->exit);
+ printf("hway_data:\n");
+ dump_label_data(&lbl_hdr->hway_data);
+ printf("lbl13:\n");
+ dump_label_data(&lbl_hdr->lbl13);
+ printf("lbl14:\n");
+ dump_label_data(&lbl_hdr->lbl14);
+ printf("len: 0x%x(%d)\n", sizeof(*lbl_hdr), sizeof(*lbl_hdr));
}
#endif
struct triple {
- unsigned char data[3];
+ unsigned char data[3];
} __attribute((packed));
-static unsigned int
-triple_u(struct triple *t)
-{
- return t->data[0] | (t->data[1] << 8) | (t->data[2] << 16);
+static unsigned int triple_u(struct triple *t) {
+ return t->data[0] | (t->data[1] << 8) | (t->data[2] << 16);
}
-static int
-triple(struct triple *t)
-{
- int ret=t->data[0] | (t->data[1] << 8) | (t->data[2] << 16);
- if (ret > 1<<23)
- ret=ret-(1<<24);
- return ret;
+static int triple(struct triple *t) {
+ int ret=t->data[0] | (t->data[1] << 8) | (t->data[2] << 16);
+ if (ret > 1<<23)
+ ret=ret-(1<<24);
+ return ret;
}
-static void
-dump_triple_u(struct triple *t)
-{
- int val=triple_u(t);
- printf("0x%x(%d)\n", val, val);
+static void dump_triple_u(struct triple *t) {
+ int val=triple_u(t);
+ printf("0x%x(%d)\n", val, val);
}
struct tcoord {
- struct triple lng,lat;
+ struct triple lng,lat;
} __attribute((packed));
-static void
-dump_tcoord(struct tcoord *t)
-{
- printf ("0x%x(%d),0x%x(%d)\n", triple_u(&t->lng), triple_u(&t->lng), triple_u(&t->lat), triple_u(&t->lat));
+static void dump_tcoord(struct tcoord *t) {
+ printf ("0x%x(%d),0x%x(%d)\n", triple_u(&t->lng), triple_u(&t->lng), triple_u(&t->lat), triple_u(&t->lat));
}
struct level {
- unsigned char zoom;
- unsigned char bits_per_coord;
- unsigned short subdivisions;
+ unsigned char zoom;
+ unsigned char bits_per_coord;
+ unsigned short subdivisions;
} __attribute((packed));
-static void
-dump_level(struct level *lvl)
-{
- printf("level:\n");
- printf("\tzoom 0x%x(%d)\n", lvl->zoom, lvl->zoom);
- printf("\tbits_per_coord 0x%x(%d)\n", lvl->bits_per_coord, lvl->bits_per_coord);
- printf("\tsubdivisions 0x%x(%d)\n", lvl->subdivisions, lvl->subdivisions);
+static void dump_level(struct level *lvl) {
+ printf("level:\n");
+ printf("\tzoom 0x%x(%d)\n", lvl->zoom, lvl->zoom);
+ printf("\tbits_per_coord 0x%x(%d)\n", lvl->bits_per_coord, lvl->bits_per_coord);
+ printf("\tsubdivisions 0x%x(%d)\n", lvl->subdivisions, lvl->subdivisions);
}
struct subdivision {
- struct triple rgn_offset;
- unsigned char types;
- struct tcoord center;
- unsigned short width;
- unsigned short height;
- unsigned short next;
+ struct triple rgn_offset;
+ unsigned char types;
+ struct tcoord center;
+ unsigned short width;
+ unsigned short height;
+ unsigned short next;
} __attribute((packed));
-static void
-dump_subdivision(struct subdivision *sub)
-{
- printf("subdivision:\n");
- printf("\trgn_offset: "); dump_triple_u(&sub->rgn_offset);
- printf("\ttypes: 0x%x(%d)\n", sub->types, sub->types);
- printf("\tcenter: "); dump_tcoord(&sub->center);
- printf("\tsize: 0x%x(%d)x0x%x(%d) %s\n",sub->width & 0x7fff, sub->width & 0x7fff, sub->height, sub->height, sub->width & 0x8000 ? "Terminating" : "");
- printf("\tnext: 0x%x(%d)\n",sub->next, sub->next);
-
- printf("\tlen: 0x%x(%d)\n", sizeof(*sub), sizeof(*sub));
+static void dump_subdivision(struct subdivision *sub) {
+ printf("subdivision:\n");
+ printf("\trgn_offset: ");
+ dump_triple_u(&sub->rgn_offset);
+ printf("\ttypes: 0x%x(%d)\n", sub->types, sub->types);
+ printf("\tcenter: ");
+ dump_tcoord(&sub->center);
+ printf("\tsize: 0x%x(%d)x0x%x(%d) %s\n",sub->width & 0x7fff, sub->width & 0x7fff, sub->height, sub->height,
+ sub->width & 0x8000 ? "Terminating" : "");
+ printf("\tnext: 0x%x(%d)\n",sub->next, sub->next);
+
+ printf("\tlen: 0x%x(%d)\n", sizeof(*sub), sizeof(*sub));
}
struct rgn_point {
- unsigned char info;
- struct triple lbl_offset;
- short lng_delta;
- short lat_delta;
- unsigned char subtype;
+ unsigned char info;
+ struct triple lbl_offset;
+ short lng_delta;
+ short lat_delta;
+ unsigned char subtype;
} __attribute((packed));
-static void
-dump_point(struct rgn_point *pnt)
-{
- printf("point:\n");
- printf("\tinfo 0x%x(%d)\n", pnt->info, pnt->info);
- printf("\tlbl_offset 0x%x(%d)\n", triple_u(&pnt->lbl_offset), triple_u(&pnt->lbl_offset));
- printf("\tlng_delta 0x%x(%d)\n", pnt->lng_delta, pnt->lng_delta);
- printf("\tlat_delta 0x%x(%d)\n", pnt->lat_delta, pnt->lat_delta);
- printf("\tsubtype 0x%x(%d)\n", pnt->subtype, pnt->subtype);
- printf("\tlen: 0x%x(%d)\n", sizeof(*pnt), sizeof(*pnt));
+static void dump_point(struct rgn_point *pnt) {
+ printf("point:\n");
+ printf("\tinfo 0x%x(%d)\n", pnt->info, pnt->info);
+ printf("\tlbl_offset 0x%x(%d)\n", triple_u(&pnt->lbl_offset), triple_u(&pnt->lbl_offset));
+ printf("\tlng_delta 0x%x(%d)\n", pnt->lng_delta, pnt->lng_delta);
+ printf("\tlat_delta 0x%x(%d)\n", pnt->lat_delta, pnt->lat_delta);
+ printf("\tsubtype 0x%x(%d)\n", pnt->subtype, pnt->subtype);
+ printf("\tlen: 0x%x(%d)\n", sizeof(*pnt), sizeof(*pnt));
}
struct rgn_poly {
- unsigned char info;
- struct triple lbl_offset;
- short lng_delta;
- short lat_delta;
- union {
- struct {
- unsigned char bitstream_len;
- unsigned char bitstream_info;
- } __attribute((packed)) p1;
- struct {
- unsigned short bitstream_len;
- unsigned char bitstream_info;
- } __attribute((packed)) p2;
- } __attribute((packed)) u;
+ unsigned char info;
+ struct triple lbl_offset;
+ short lng_delta;
+ short lat_delta;
+ union {
+ struct {
+ unsigned char bitstream_len;
+ unsigned char bitstream_info;
+ } __attribute((packed)) p1;
+ struct {
+ unsigned short bitstream_len;
+ unsigned char bitstream_info;
+ } __attribute((packed)) p2;
+ } __attribute((packed)) u;
} __attribute((packed));
-static void
-dump_poly(struct rgn_poly *ply)
-{
- printf("poly:\n");
- printf("\tinfo 0x%x(%d)\n", ply->info, ply->info);
- printf("\tlbl_offset 0x%x(%d)\n", triple_u(&ply->lbl_offset), triple_u(&ply->lbl_offset));
- printf("\tlng_delta 0x%x(%d)\n", ply->lng_delta, ply->lng_delta);
- printf("\tlat_delta 0x%x(%d)\n", ply->lat_delta, ply->lat_delta);
- if (ply->info & 0x80) {
- printf("\tbitstream_len 0x%x(%d)\n", ply->u.p2.bitstream_len, ply->u.p2.bitstream_len);
- printf("\tbitstream_info 0x%x(%d)\n", ply->u.p2.bitstream_info, ply->u.p2.bitstream_info);
- } else {
- printf("\tbitstream_len 0x%x(%d)\n", ply->u.p1.bitstream_len, ply->u.p1.bitstream_len);
- printf("\tbitstream_info 0x%x(%d)\n", ply->u.p1.bitstream_info, ply->u.p1.bitstream_info);
- }
- printf("\tlen: 0x%x(%d)\n", sizeof(*ply), sizeof(*ply));
+static void dump_poly(struct rgn_poly *ply) {
+ printf("poly:\n");
+ printf("\tinfo 0x%x(%d)\n", ply->info, ply->info);
+ printf("\tlbl_offset 0x%x(%d)\n", triple_u(&ply->lbl_offset), triple_u(&ply->lbl_offset));
+ printf("\tlng_delta 0x%x(%d)\n", ply->lng_delta, ply->lng_delta);
+ printf("\tlat_delta 0x%x(%d)\n", ply->lat_delta, ply->lat_delta);
+ if (ply->info & 0x80) {
+ printf("\tbitstream_len 0x%x(%d)\n", ply->u.p2.bitstream_len, ply->u.p2.bitstream_len);
+ printf("\tbitstream_info 0x%x(%d)\n", ply->u.p2.bitstream_info, ply->u.p2.bitstream_info);
+ } else {
+ printf("\tbitstream_len 0x%x(%d)\n", ply->u.p1.bitstream_len, ply->u.p1.bitstream_len);
+ printf("\tbitstream_info 0x%x(%d)\n", ply->u.p1.bitstream_info, ply->u.p1.bitstream_info);
+ }
+ printf("\tlen: 0x%x(%d)\n", sizeof(*ply), sizeof(*ply));
}
-static void
-dump_hex(void *ptr, int len)
-{
- unsigned char *c=ptr;
- while (len--) {
- printf("%02x ", *c++);
- }
- printf("\n");
+static void dump_hex(void *ptr, int len) {
+ unsigned char *c=ptr;
+ while (len--) {
+ printf("%02x ", *c++);
+ }
+ printf("\n");
}
-static void
-dump_hex_r(void *ptr, int len, int rec)
-{
- unsigned char *c=ptr;
- int l=rec;
- while (len--) {
- printf("%02x ", *c++);
- if (! --l) {
- printf("\n");
- l=rec;
- }
- }
- printf("\n");
+static void dump_hex_r(void *ptr, int len, int rec) {
+ unsigned char *c=ptr;
+ int l=rec;
+ while (len--) {
+ printf("%02x ", *c++);
+ if (! --l) {
+ printf("\n");
+ l=rec;
+ }
+ }
+ printf("\n");
}
#if 0
-static void
-dump_label_offset(struct map_rect_priv *mr, int offset)
-{
- void *p;
- p=file_read(&mr->lbl, mr->lbl_hdr->label.offset_len.offset+offset, 128);
- printf("%s\n", (char *)p);
+static void dump_label_offset(struct map_rect_priv *mr, int offset) {
+ void *p;
+ p=file_read(&mr->lbl, mr->lbl_hdr->label.offset_len.offset+offset, 128);
+ printf("%s\n", (char *)p);
}
#endif
#if 0
-static void
-dump_region_item(struct subdivision *sub, struct file *rgn, struct map_rect_priv *mr)
-{
- int offset,item_offset,i,j;
- unsigned short count=0;
- unsigned short *offsets[4];
- unsigned short *file_offsets;
- struct rgn_point *pnt;
-
- offset=triple_u(&sub->rgn_offset)+mr->rgn_hdr->offset_len.offset;
- file_offsets=file_read(rgn, offset, 90*sizeof(unsigned short));
- printf("0x%x ", offset); dump_hex(file_offsets, 90);
- for (i=0 ; i < 4 ; i++) {
- printf("i=%d\n", i);
- if (sub->types & (0x10 << i)) {
- if (count) {
- offsets[i]=&file_offsets[count-1];
- } else
- offsets[i]=&count;
- count++;
- } else
- offsets[i]=NULL;
-
- }
- count--;
- count*=2;
- for (i=0 ; i < 4 ; i++) {
- printf("i=%d\n", i);
- if (offsets[i]) {
- printf("offset[%d]=0x%x(%d)\n", i, *offsets[i], *offsets[i]);
- switch (i) {
- case 0:
- printf("point\n");
- break;
- case 1:
- printf("indexed point\n");
- break;
- case 2:
- printf("polyline\n");
- break;
- case 3:
- printf("polygon\n");
- break;
- }
- item_offset=offset+*offsets[i];
- switch (i) {
- case 0:
- case 1:
- for (j = 0 ; j < 10 ; j++) {
- struct coord_geo g;
- char buffer[1024];
- double conv=180.0/(1UL<<23);
- pnt=file_read(rgn, item_offset, sizeof(*pnt)*20);
- // printf("0x%x ", item_offset); dump_hex(pnt, 32);
- dump_point(pnt);
- g.lng=(triple(&sub->center.lng)+(pnt->lng_delta << shift))*conv;
- g.lat=(triple(&sub->center.lat)+(pnt->lat_delta << shift))*conv;
- printf("%f %f\n", g.lng, g.lat);
- coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,
- buffer,sizeof(buffer));
- printf("%s\n", buffer);
- dump_label_offset(mr, triple_u(&pnt->lbl_offset));
- if (pnt->info & 0x80)
- item_offset+=sizeof(*pnt);
- else
- item_offset+=sizeof(*pnt)-1;
- }
- }
- } else {
- printf("offset[%d] doesn't exist\n", i);
- }
- }
- file_free(file_offsets);
+static void dump_region_item(struct subdivision *sub, struct file *rgn, struct map_rect_priv *mr) {
+ int offset,item_offset,i,j;
+ unsigned short count=0;
+ unsigned short *offsets[4];
+ unsigned short *file_offsets;
+ struct rgn_point *pnt;
+
+ offset=triple_u(&sub->rgn_offset)+mr->rgn_hdr->offset_len.offset;
+ file_offsets=file_read(rgn, offset, 90*sizeof(unsigned short));
+ printf("0x%x ", offset);
+ dump_hex(file_offsets, 90);
+ for (i=0 ; i < 4 ; i++) {
+ printf("i=%d\n", i);
+ if (sub->types & (0x10 << i)) {
+ if (count) {
+ offsets[i]=&file_offsets[count-1];
+ } else
+ offsets[i]=&count;
+ count++;
+ } else
+ offsets[i]=NULL;
+
+ }
+ count--;
+ count*=2;
+ for (i=0 ; i < 4 ; i++) {
+ printf("i=%d\n", i);
+ if (offsets[i]) {
+ printf("offset[%d]=0x%x(%d)\n", i, *offsets[i], *offsets[i]);
+ switch (i) {
+ case 0:
+ printf("point\n");
+ break;
+ case 1:
+ printf("indexed point\n");
+ break;
+ case 2:
+ printf("polyline\n");
+ break;
+ case 3:
+ printf("polygon\n");
+ break;
+ }
+ item_offset=offset+*offsets[i];
+ switch (i) {
+ case 0:
+ case 1:
+ for (j = 0 ; j < 10 ; j++) {
+ struct coord_geo g;
+ char buffer[1024];
+ double conv=180.0/(1UL<<23);
+ pnt=file_read(rgn, item_offset, sizeof(*pnt)*20);
+ // printf("0x%x ", item_offset); dump_hex(pnt, 32);
+ dump_point(pnt);
+ g.lng=(triple(&sub->center.lng)+(pnt->lng_delta << shift))*conv;
+ g.lat=(triple(&sub->center.lat)+(pnt->lat_delta << shift))*conv;
+ printf("%f %f\n", g.lng, g.lat);
+ coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,
+ buffer,sizeof(buffer));
+ printf("%s\n", buffer);
+ dump_label_offset(mr, triple_u(&pnt->lbl_offset));
+ if (pnt->info & 0x80)
+ item_offset+=sizeof(*pnt);
+ else
+ item_offset+=sizeof(*pnt)-1;
+ }
+ }
+ } else {
+ printf("offset[%d] doesn't exist\n", i);
+ }
+ }
+ file_free(file_offsets);
}
#endif
-static void
-dump_levels(struct map_rect_priv *mr)
-{
- int i,offset;
- struct level *lvl;
-
- offset=mr->tre_hdr->level.offset;
- for (i = 0 ; i < mr->tre_hdr->level.length/sizeof(*lvl) ; i++) {
- lvl=file_read(&mr->tre, offset, sizeof(*lvl));
- dump_level(lvl);
- offset+=sizeof(*lvl);
- }
+static void dump_levels(struct map_rect_priv *mr) {
+ int i,offset;
+ struct level *lvl;
+
+ offset=mr->tre_hdr->level.offset;
+ for (i = 0 ; i < mr->tre_hdr->level.length/sizeof(*lvl) ; i++) {
+ lvl=file_read(&mr->tre, offset, sizeof(*lvl));
+ dump_level(lvl);
+ offset+=sizeof(*lvl);
+ }
}
#if 0
-static void
-dump_tree(struct file *f, struct file *rgn, struct map_rect_priv *mr)
-{
- struct tree_header *tre_hdr;
- struct subdivision *sub;
- int i,offset;
-
- tre_hdr=file_read(f, 0, sizeof(*tre_hdr));
- dump_tree_header(tre_hdr);
- offset=tre_hdr->subdivision.offset;
- sub=file_read(f, offset, sizeof(*sub));
- dump_subdivision(sub);
- offset+=sizeof(*sub);
- for (i = 1 ; i < tre_hdr->subdivision.length/sizeof(*sub) ; i++) {
- printf("i=%d\n", i);
- sub=file_read(f, offset, sizeof(*sub));
- dump_subdivision(sub);
- dump_region_item(sub, rgn, mr);
- if (sub->width & 0x8000)
- break;
- offset+=sizeof(*sub);
- }
- file_free(tre_hdr);
+static void dump_tree(struct file *f, struct file *rgn, struct map_rect_priv *mr) {
+ struct tree_header *tre_hdr;
+ struct subdivision *sub;
+ int i,offset;
+
+ tre_hdr=file_read(f, 0, sizeof(*tre_hdr));
+ dump_tree_header(tre_hdr);
+ offset=tre_hdr->subdivision.offset;
+ sub=file_read(f, offset, sizeof(*sub));
+ dump_subdivision(sub);
+ offset+=sizeof(*sub);
+ for (i = 1 ; i < tre_hdr->subdivision.length/sizeof(*sub) ; i++) {
+ printf("i=%d\n", i);
+ sub=file_read(f, offset, sizeof(*sub));
+ dump_subdivision(sub);
+ dump_region_item(sub, rgn, mr);
+ if (sub->width & 0x8000)
+ break;
+ offset+=sizeof(*sub);
+ }
+ file_free(tre_hdr);
}
#endif
#if 0
-static void
-dump_labels(struct file *f)
-{
- struct label_header *lbl_hdr;
-
- lbl_hdr=file_read(f, 0, sizeof(*lbl_hdr));
- printf("**labels**\n");
- dump_label(lbl_hdr);
- file_free(lbl_hdr);
+static void dump_labels(struct file *f) {
+ struct label_header *lbl_hdr;
+
+ lbl_hdr=file_read(f, 0, sizeof(*lbl_hdr));
+ printf("**labels**\n");
+ dump_label(lbl_hdr);
+ file_free(lbl_hdr);
#if 0
- labels=alloca(lbl_hdr.label_length);
- file_read(f, lbl_hdr.label_offset, labels, lbl_hdr.label_length);
- l=labels;
- while (l < labels+lbl_hdr.label_length) {
- printf("'%s'(%d)\n", l, strlen(l));
- l+=strlen(l)+1;
- }
+ labels=alloca(lbl_hdr.label_length);
+ file_read(f, lbl_hdr.label_offset, labels, lbl_hdr.label_length);
+ l=labels;
+ while (l < labels+lbl_hdr.label_length) {
+ printf("'%s'(%d)\n", l, strlen(l));
+ l+=strlen(l)+1;
+ }
#endif
-
+
}
#endif
-static void
-garmin_img_coord_rewind(void *priv_data)
-{
+static void garmin_img_coord_rewind(void *priv_data) {
}
-static void
-parse_line(struct map_rect_priv *mr)
-{
- int pos=0;
- sscanf(mr->line,"%lf %c %lf %c %n",&mr->lat,&mr->lat_c,&mr->lng,&mr->lng_c,&pos);
- if (pos < strlen(mr->line)) {
- strcpy(mr->attrs, mr->line+pos);
- }
+static void parse_line(struct map_rect_priv *mr) {
+ int pos=0;
+ sscanf(mr->line,"%lf %c %lf %c %n",&mr->lat,&mr->lat_c,&mr->lng,&mr->lng_c,&pos);
+ if (pos < strlen(mr->line)) {
+ strcpy(mr->attrs, mr->line+pos);
+ }
}
-static int
-get_bits(struct map_rect_priv *mr, int bits)
-{
- unsigned long ret;
- ret=L(*((unsigned long *)(mr->ply_data+mr->ply_bitpos/8)));
- ret >>= (mr->ply_bitpos & 7);
- ret &= (1 << bits)-1;
- mr->ply_bitpos+=bits;
- return ret;
+static int get_bits(struct map_rect_priv *mr, int bits) {
+ unsigned long ret;
+ ret=L(*((unsigned long *)(mr->ply_data+mr->ply_bitpos/8)));
+ ret >>= (mr->ply_bitpos & 7);
+ ret &= (1 << bits)-1;
+ mr->ply_bitpos+=bits;
+ return ret;
}
-static int
-garmin_img_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr=priv_data;
- struct subdivision *sub=(struct subdivision *)(mr->subdiv+mr->subdiv_pos);
- int ret=0;
- int debug=0;
- if (debug)
- printf("garmin_img_coord_get %d\n",count);
- if (debug)
- dump_subdivision(sub);
- while (count--) {
- if (mr->rgn_type < 2) {
- c->x=triple(&sub->center.lng)+(mr->pnt->lng_delta << shift);
- c->y=triple(&sub->center.lat)+(mr->pnt->lat_delta << shift);
- } else {
- if (! mr->ply_bitpos) {
- if (mr->ply->info & 0x80) {
- mr->ply_bitcount=mr->ply->u.p2.bitstream_len*8;
- mr->ply_lngbits=mr->ply->u.p2.bitstream_info & 0xf;
- mr->ply_latbits=mr->ply->u.p2.bitstream_info >> 4;
- } else {
- mr->ply_bitcount=mr->ply->u.p1.bitstream_len*8;
- mr->ply_lngbits=mr->ply->u.p1.bitstream_info & 0xf;
- mr->ply_latbits=mr->ply->u.p1.bitstream_info >> 4;
- }
- if (mr->ply_lngbits <= 9)
- mr->ply_lngbits+=2;
- if (mr->ply_latbits <= 9)
- mr->ply_latbits+=2;
- if (! get_bits(mr,1)) {
- mr->ply_lngbits+=1;
- mr->ply_lngsign=0;
- } else
- if (get_bits(mr, 1))
- mr->ply_lngsign=-1;
- else
- mr->ply_lngsign=1;
- if (! get_bits(mr,1)) {
- mr->ply_latbits+=1;
- mr->ply_latsign=0;
- } else
- if (get_bits(mr, 1))
- mr->ply_latsign=-1;
- else
- mr->ply_latsign=1;
- mr->ply_lnglimit=1 << (mr->ply_lngbits-1);
- mr->ply_latlimit=1 << (mr->ply_latbits-1);
- mr->ply_lng=mr->ply->lng_delta;
- mr->ply_lat=mr->ply->lat_delta;
- if (debug)
- printf("lngbits %d latbits %d bitcount %d\n", mr->ply_lngbits, mr->ply_latbits, mr->ply_bitcount);
- c->x=0;
- c->y=0;
- } else {
- if (mr->ply_bitpos + mr->ply_lngbits + mr->ply_latbits > mr->ply_bitcount) {
- if (debug)
- printf("out of bits %d + %d + %d >= %d\n", mr->ply_bitpos, mr->ply_lngbits, mr->ply_latbits, mr->ply_bitcount);
- return ret;
- }
- c->x=0;
- c->y=0;
- int x,y;
- for (;;) {
- x=get_bits(mr,mr->ply_lngbits);
- if (debug)
- printf("x %d ", x);
- if (mr->ply_lngsign || x != mr->ply_lnglimit)
- break;
- c->x += x-1;
- }
- if (mr->ply_lngsign) {
- c->x=x*mr->ply_lngsign;
- } else {
- if (x >= mr->ply_lnglimit)
- c->x = x - (mr->ply_lnglimit << 1) - c->x;
- else
- c->x +=x;
- }
- for (;;) {
- y=get_bits(mr,mr->ply_latbits);
- if (debug)
- printf("y %d ", y);
- if (mr->ply_latsign || y != mr->ply_latlimit)
- break;
- c->y += y-1;
- }
- if (mr->ply_latsign) {
- c->y=y*mr->ply_latsign;
- } else {
- if (y >= mr->ply_latlimit)
- c->y = y - (mr->ply_latlimit << 1) - c->y;
- else
- c->y +=y;
- }
- mr->ply_lng += c->x;
- mr->ply_lat += c->y;
- }
- if (debug)
- printf(": x %d y %d\n", c->x, c->y);
-
- c->x=triple(&sub->center.lng)+(mr->ply_lng << shift);
- c->y=triple(&sub->center.lat)+(mr->ply_lat << shift);
- }
+static int garmin_img_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr=priv_data;
+ struct subdivision *sub=(struct subdivision *)(mr->subdiv+mr->subdiv_pos);
+ int ret=0;
+ int debug=0;
+ if (debug)
+ printf("garmin_img_coord_get %d\n",count);
+ if (debug)
+ dump_subdivision(sub);
+ while (count--) {
+ if (mr->rgn_type < 2) {
+ c->x=triple(&sub->center.lng)+(mr->pnt->lng_delta << shift);
+ c->y=triple(&sub->center.lat)+(mr->pnt->lat_delta << shift);
+ } else {
+ if (! mr->ply_bitpos) {
+ if (mr->ply->info & 0x80) {
+ mr->ply_bitcount=mr->ply->u.p2.bitstream_len*8;
+ mr->ply_lngbits=mr->ply->u.p2.bitstream_info & 0xf;
+ mr->ply_latbits=mr->ply->u.p2.bitstream_info >> 4;
+ } else {
+ mr->ply_bitcount=mr->ply->u.p1.bitstream_len*8;
+ mr->ply_lngbits=mr->ply->u.p1.bitstream_info & 0xf;
+ mr->ply_latbits=mr->ply->u.p1.bitstream_info >> 4;
+ }
+ if (mr->ply_lngbits <= 9)
+ mr->ply_lngbits+=2;
+ if (mr->ply_latbits <= 9)
+ mr->ply_latbits+=2;
+ if (! get_bits(mr,1)) {
+ mr->ply_lngbits+=1;
+ mr->ply_lngsign=0;
+ } else if (get_bits(mr, 1))
+ mr->ply_lngsign=-1;
+ else
+ mr->ply_lngsign=1;
+ if (! get_bits(mr,1)) {
+ mr->ply_latbits+=1;
+ mr->ply_latsign=0;
+ } else if (get_bits(mr, 1))
+ mr->ply_latsign=-1;
+ else
+ mr->ply_latsign=1;
+ mr->ply_lnglimit=1 << (mr->ply_lngbits-1);
+ mr->ply_latlimit=1 << (mr->ply_latbits-1);
+ mr->ply_lng=mr->ply->lng_delta;
+ mr->ply_lat=mr->ply->lat_delta;
+ if (debug)
+ printf("lngbits %d latbits %d bitcount %d\n", mr->ply_lngbits, mr->ply_latbits, mr->ply_bitcount);
+ c->x=0;
+ c->y=0;
+ } else {
+ if (mr->ply_bitpos + mr->ply_lngbits + mr->ply_latbits > mr->ply_bitcount) {
+ if (debug)
+ printf("out of bits %d + %d + %d >= %d\n", mr->ply_bitpos, mr->ply_lngbits, mr->ply_latbits, mr->ply_bitcount);
+ return ret;
+ }
+ c->x=0;
+ c->y=0;
+ int x,y;
+ for (;;) {
+ x=get_bits(mr,mr->ply_lngbits);
+ if (debug)
+ printf("x %d ", x);
+ if (mr->ply_lngsign || x != mr->ply_lnglimit)
+ break;
+ c->x += x-1;
+ }
+ if (mr->ply_lngsign) {
+ c->x=x*mr->ply_lngsign;
+ } else {
+ if (x >= mr->ply_lnglimit)
+ c->x = x - (mr->ply_lnglimit << 1) - c->x;
+ else
+ c->x +=x;
+ }
+ for (;;) {
+ y=get_bits(mr,mr->ply_latbits);
+ if (debug)
+ printf("y %d ", y);
+ if (mr->ply_latsign || y != mr->ply_latlimit)
+ break;
+ c->y += y-1;
+ }
+ if (mr->ply_latsign) {
+ c->y=y*mr->ply_latsign;
+ } else {
+ if (y >= mr->ply_latlimit)
+ c->y = y - (mr->ply_latlimit << 1) - c->y;
+ else
+ c->y +=y;
+ }
+ mr->ply_lng += c->x;
+ mr->ply_lat += c->y;
+ }
+ if (debug)
+ printf(": x %d y %d\n", c->x, c->y);
+
+ c->x=triple(&sub->center.lng)+(mr->ply_lng << shift);
+ c->y=triple(&sub->center.lat)+(mr->ply_lat << shift);
+ }
#if 0
- c->x-=0x6f160;
- c->y-=0x181f59;
- c->x+=0x168ca1;
- c->y+=0x68d815;
+ c->x-=0x6f160;
+ c->y-=0x181f59;
+ c->x+=0x168ca1;
+ c->y+=0x68d815;
#endif
- c++;
- ret++;
- if (mr->rgn_type < 2)
- return ret;
- }
- return ret;
+ c++;
+ ret++;
+ if (mr->rgn_type < 2)
+ return ret;
+ }
+ return ret;
}
-static char *
-get_label_offset(struct map_rect_priv *mr, int offset)
-{
- g_assert(offset < mr->lbl_hdr->label.offset_len.length);
- return file_read(&mr->lbl, mr->lbl_hdr->label.offset_len.offset+offset, 128);
+static char *get_label_offset(struct map_rect_priv *mr, int offset) {
+ g_assert(offset < mr->lbl_hdr->label.offset_len.length);
+ return file_read(&mr->lbl, mr->lbl_hdr->label.offset_len.offset+offset, 128);
}
-static void
-garmin_img_attr_rewind(void *priv_data)
-{
+static void garmin_img_attr_rewind(void *priv_data) {
}
-static int
-garmin_img_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr=priv_data;
- int debug=0;
-
- if (debug)
- printf("garmin_img_attr_get\n");
- if (attr_type == attr_label) {
- if (debug)
- printf("garmin_img_attr_get label\n");
- attr->type=attr_type;
- if (mr->rgn_type < 2) {
- if (mr->label)
- file_free(mr->label);
- mr->label=get_label_offset(mr, triple_u(&mr->pnt->lbl_offset) & 0x3fffff);
- attr->u.str=mr->label;
- } else {
- attr->u.str="";
- }
- return 1;
- }
- return 0;
+static int garmin_img_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr=priv_data;
+ int debug=0;
+
+ if (debug)
+ printf("garmin_img_attr_get\n");
+ if (attr_type == attr_label) {
+ if (debug)
+ printf("garmin_img_attr_get label\n");
+ attr->type=attr_type;
+ if (mr->rgn_type < 2) {
+ if (mr->label)
+ file_free(mr->label);
+ mr->label=get_label_offset(mr, triple_u(&mr->pnt->lbl_offset) & 0x3fffff);
+ attr->u.str=mr->label;
+ } else {
+ attr->u.str="";
+ }
+ return 1;
+ }
+ return 0;
}
static struct item_methods methods_garmin_img = {
- garmin_img_coord_rewind,
- garmin_img_coord_get,
- garmin_img_attr_rewind,
- garmin_img_attr_get,
+ garmin_img_coord_rewind,
+ garmin_img_coord_get,
+ garmin_img_attr_rewind,
+ garmin_img_attr_get,
};
-static int rgn_next_type(struct map_rect_priv *mr)
-{
- while (mr->rgn_type < 3) {
- mr->rgn_type++;
- if (mr->rgn_items[mr->rgn_type].offset && mr->rgn_items[mr->rgn_type].length != 0) {
- mr->rgn_offset=mr->rgn_items[mr->rgn_type].offset;
- mr->rgn_end=mr->rgn_offset+mr->rgn_items[mr->rgn_type].length;
- return 0;
- }
- }
- return 1;
+static int rgn_next_type(struct map_rect_priv *mr) {
+ while (mr->rgn_type < 3) {
+ mr->rgn_type++;
+ if (mr->rgn_items[mr->rgn_type].offset && mr->rgn_items[mr->rgn_type].length != 0) {
+ mr->rgn_offset=mr->rgn_items[mr->rgn_type].offset;
+ mr->rgn_end=mr->rgn_offset+mr->rgn_items[mr->rgn_type].length;
+ return 0;
+ }
+ }
+ return 1;
}
-static int
-sub_next(struct map_rect_priv *mr, int next)
-{
- int i,offset,first=-1,last=-1,count=-1;
- int end;
- unsigned short *offsets;
- int debug=0;
-
- if (mr->subdiv_level_count <= 0)
- return 1;
- if (debug)
- printf("%d left\n", mr->subdiv_level_count);
- mr->subdiv_level_count--;
-
+static int sub_next(struct map_rect_priv *mr, int next) {
+ int i,offset,first=-1,last=-1,count=-1;
+ int end;
+ unsigned short *offsets;
+ int debug=0;
+
+ if (mr->subdiv_level_count <= 0)
+ return 1;
+ if (debug)
+ printf("%d left\n", mr->subdiv_level_count);
+ mr->subdiv_level_count--;
+
#if 0
- if (next && mr->subdiv[mr->subdiv_current].width & 0x8000)
- return 1;
+ if (next && mr->subdiv[mr->subdiv_current].width & 0x8000)
+ return 1;
#endif
- if (debug)
- dump_hex_r(mr->subdiv+mr->subdiv_pos, 64, 14);
- mr->subdiv_pos+=next;
- if (debug)
- printf("subdiv_pos 0x%x\n", mr->subdiv_pos);
- if (mr->subdiv_pos > mr->tre_hdr->subdivision.length)
- return 1;
- struct subdivision *sub=(struct subdivision *)(mr->subdiv+mr->subdiv_pos);
- offset=triple_u(&sub->rgn_offset)+mr->rgn_hdr->offset_len.offset;
- if (debug) {
- printf("offset=0x%x\n", offset);
- dump_subdivision(sub);
- }
- offsets=file_read(&mr->rgn, offset, 3*sizeof(unsigned short));
-
- if (! next)
- next=subdiv_next;
- if (mr->subdiv_pos+next < mr->tre_hdr->subdivision.length)
- end=triple_u(&((struct subdivision *)(mr->subdiv+mr->subdiv_pos+next))->rgn_offset)+mr->rgn_hdr->offset_len.offset;
- else
- end=mr->rgn_hdr->offset_len.offset+mr->rgn_hdr->offset_len.length;
- if (debug) {
- dump_subdivision(sub);
- dump_hex(offsets, 6);
- }
- for (i=0 ; i < 4 ; i++) {
- if (debug)
- printf("i=%d ", i);
- if (sub->types & (0x10 << i)) {
- if (debug)
- printf("+ ");
- if (first == -1) {
- first=i;
- mr->rgn_items[i].offset=offset;
- if (debug)
- printf("\n");
- } else {
- mr->rgn_items[i].offset=offset+offsets[count];
- if (debug)
- printf("0x%x\n", offsets[count]);
- mr->rgn_items[last].length=mr->rgn_items[i].offset-mr->rgn_items[last].offset;
- }
- last=i;
- count++;
- } else {
- if (debug)
- printf("-\n");
- mr->rgn_items[i].offset=0;
- mr->rgn_items[i].length=0;
- }
-
- }
- if (first != -1) {
- mr->rgn_items[first].offset+=count*2;
- mr->rgn_items[first].length-=count*2;
- mr->rgn_items[last].length=end-mr->rgn_items[last].offset;
- }
- if (debug) {
- for (i=0 ; i < 4 ; i++) {
- printf("%d 0x%x 0x%x\n", i, mr->rgn_items[i].offset, mr->rgn_items[i].length);
- }
- }
- mr->rgn_type=-1;
- rgn_next_type(mr);
- if (debug)
- printf("*** offset 0x%x\n", mr->rgn_offset);
- file_free(offsets);
- return 0;
+ if (debug)
+ dump_hex_r(mr->subdiv+mr->subdiv_pos, 64, 14);
+ mr->subdiv_pos+=next;
+ if (debug)
+ printf("subdiv_pos 0x%x\n", mr->subdiv_pos);
+ if (mr->subdiv_pos > mr->tre_hdr->subdivision.length)
+ return 1;
+ struct subdivision *sub=(struct subdivision *)(mr->subdiv+mr->subdiv_pos);
+ offset=triple_u(&sub->rgn_offset)+mr->rgn_hdr->offset_len.offset;
+ if (debug) {
+ printf("offset=0x%x\n", offset);
+ dump_subdivision(sub);
+ }
+ offsets=file_read(&mr->rgn, offset, 3*sizeof(unsigned short));
+
+ if (! next)
+ next=subdiv_next;
+ if (mr->subdiv_pos+next < mr->tre_hdr->subdivision.length)
+ end=triple_u(&((struct subdivision *)(mr->subdiv+mr->subdiv_pos+next))->rgn_offset)+mr->rgn_hdr->offset_len.offset;
+ else
+ end=mr->rgn_hdr->offset_len.offset+mr->rgn_hdr->offset_len.length;
+ if (debug) {
+ dump_subdivision(sub);
+ dump_hex(offsets, 6);
+ }
+ for (i=0 ; i < 4 ; i++) {
+ if (debug)
+ printf("i=%d ", i);
+ if (sub->types & (0x10 << i)) {
+ if (debug)
+ printf("+ ");
+ if (first == -1) {
+ first=i;
+ mr->rgn_items[i].offset=offset;
+ if (debug)
+ printf("\n");
+ } else {
+ mr->rgn_items[i].offset=offset+offsets[count];
+ if (debug)
+ printf("0x%x\n", offsets[count]);
+ mr->rgn_items[last].length=mr->rgn_items[i].offset-mr->rgn_items[last].offset;
+ }
+ last=i;
+ count++;
+ } else {
+ if (debug)
+ printf("-\n");
+ mr->rgn_items[i].offset=0;
+ mr->rgn_items[i].length=0;
+ }
+
+ }
+ if (first != -1) {
+ mr->rgn_items[first].offset+=count*2;
+ mr->rgn_items[first].length-=count*2;
+ mr->rgn_items[last].length=end-mr->rgn_items[last].offset;
+ }
+ if (debug) {
+ for (i=0 ; i < 4 ; i++) {
+ printf("%d 0x%x 0x%x\n", i, mr->rgn_items[i].offset, mr->rgn_items[i].length);
+ }
+ }
+ mr->rgn_type=-1;
+ rgn_next_type(mr);
+ if (debug)
+ printf("*** offset 0x%x\n", mr->rgn_offset);
+ file_free(offsets);
+ return 0;
}
int item_count;
-static struct map_rect_priv *
-map_rect_new_garmin_img(struct map_priv *map, struct coord_rect *r, struct layer *layers, int limit)
-{
- struct map_rect_priv *mr;
- struct img_header img;
-
- if (debug)
- printf("map_rect_new_garmin_img\n");
- mr=g_new0(struct map_rect_priv, 1);
- mr->m=map;
- if (r)
- mr->r=*r;
- mr->limit=limit;
- mr->item.id_hi=0;
- mr->item.id_lo=0;
- mr->item.meth=&methods_garmin_img;
- mr->item.priv_data=mr;
- mr->f=fopen(map->filename, "r");
-
- fread(&img, sizeof(img), 1, mr->f);
+static struct map_rect_priv *map_rect_new_garmin_img(struct map_priv *map, struct coord_rect *r, struct layer *layers,
+ int limit) {
+ struct map_rect_priv *mr;
+ struct img_header img;
+
+ if (debug)
+ printf("map_rect_new_garmin_img\n");
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->m=map;
+ if (r)
+ mr->r=*r;
+ mr->limit=limit;
+ mr->item.id_hi=0;
+ mr->item.id_lo=0;
+ mr->item.meth=&methods_garmin_img;
+ mr->item.priv_data=mr;
+ mr->f=fopen(map->filename, "r");
+
+ fread(&img, sizeof(img), 1, mr->f);
#if 0
- dump_img(&img);
- for (i = 0 ; i < (img.file_offset-sizeof(img))/sizeof(fat_blk) ; i++) {
- fread(&fat_blk, sizeof(fat_blk), 1, mr->f);
- if (!fat_blk.flag)
- break;
- dump_fat_block(&fat_blk);
- }
+ dump_img(&img);
+ for (i = 0 ; i < (img.file_offset-sizeof(img))/sizeof(fat_blk) ; i++) {
+ fread(&fat_blk, sizeof(fat_blk), 1, mr->f);
+ if (!fat_blk.flag)
+ break;
+ dump_fat_block(&fat_blk);
+ }
#endif
- mr->rgn.offset=0xa*2048;
- mr->rgn.f=mr->f;
- mr->rgn_hdr=file_read(&mr->rgn, 0, sizeof(*mr->rgn_hdr));
+ mr->rgn.offset=0xa*2048;
+ mr->rgn.f=mr->f;
+ mr->rgn_hdr=file_read(&mr->rgn, 0, sizeof(*mr->rgn_hdr));
- mr->tre.offset=0x62b*2048;
- mr->tre.f=mr->f;
- mr->tre_hdr=file_read(&mr->tre, 0, sizeof(*mr->tre_hdr));
+ mr->tre.offset=0x62b*2048;
+ mr->tre.f=mr->f;
+ mr->tre_hdr=file_read(&mr->tre, 0, sizeof(*mr->tre_hdr));
- mr->lbl.offset=0x64a*2048;
- mr->lbl.f=mr->f;
- mr->lbl_hdr=file_read(&mr->lbl, 0, sizeof(*mr->lbl_hdr));
+ mr->lbl.offset=0x64a*2048;
+ mr->lbl.f=mr->f;
+ mr->lbl_hdr=file_read(&mr->lbl, 0, sizeof(*mr->lbl_hdr));
- mr->subdiv=file_read(&mr->tre, mr->tre_hdr->subdivision.offset, mr->tre_hdr->subdivision.length);
+ mr->subdiv=file_read(&mr->tre, mr->tre_hdr->subdivision.offset, mr->tre_hdr->subdivision.length);
#if 0
- dump_hex_r(mr->subdiv, mr->tre_hdr->subdivision.length, 16);
+ dump_hex_r(mr->subdiv, mr->tre_hdr->subdivision.length, 16);
#endif
- dump_tree_header(mr->tre_hdr);
-
- dump_levels(mr);
-
-
- printf("limit=%d\n", limit);
- if (limit < 3) {
- mr->subdiv_pos=0;
- mr->subdiv_level_count=1;
- shift=11;
- } else if (limit < 6) {
- mr->subdiv_pos=1*sizeof(struct subdivision);
- mr->subdiv_level_count=5;
- shift=9;
- } else if (limit < 8) {
- mr->subdiv_pos=6*sizeof(struct subdivision);
- mr->subdiv_level_count=9;
- shift=7;
- } else if (limit < 10) {
- mr->subdiv_pos=15*sizeof(struct subdivision);
- mr->subdiv_level_count=143;
- shift=5;
- } else {
- mr->subdiv_pos=158*sizeof(struct subdivision);
- mr->subdiv_level_count=4190;
- shift=2;
- subdiv_next=14;
- }
+ dump_tree_header(mr->tre_hdr);
+
+ dump_levels(mr);
+
+
+ printf("limit=%d\n", limit);
+ if (limit < 3) {
+ mr->subdiv_pos=0;
+ mr->subdiv_level_count=1;
+ shift=11;
+ } else if (limit < 6) {
+ mr->subdiv_pos=1*sizeof(struct subdivision);
+ mr->subdiv_level_count=5;
+ shift=9;
+ } else if (limit < 8) {
+ mr->subdiv_pos=6*sizeof(struct subdivision);
+ mr->subdiv_level_count=9;
+ shift=7;
+ } else if (limit < 10) {
+ mr->subdiv_pos=15*sizeof(struct subdivision);
+ mr->subdiv_level_count=143;
+ shift=5;
+ } else {
+ mr->subdiv_pos=158*sizeof(struct subdivision);
+ mr->subdiv_level_count=4190;
+ shift=2;
+ subdiv_next=14;
+ }
#if 0
- mr->rgn_offset=triple_u(&mr->subdiv[mr->subdiv_current].rgn_offset)+mr->rgn_hdr->offset_len.offset+4;
- mr->rgn_type=1;
- mr->rgn_end=mr->rgn_offset+20*8;
+ mr->rgn_offset=triple_u(&mr->subdiv[mr->subdiv_current].rgn_offset)+mr->rgn_hdr->offset_len.offset+4;
+ mr->rgn_type=1;
+ mr->rgn_end=mr->rgn_offset+20*8;
#endif
- mr->count=0;
- item_count=0;
+ mr->count=0;
+ item_count=0;
#if 0
- printf("*** offset 0x%x\n", 0x656c-mr->rgn.offset);
- printf("*** offset 0x%x\n", mr->rgn_offset);
+ printf("*** offset 0x%x\n", 0x656c-mr->rgn.offset);
+ printf("*** offset 0x%x\n", mr->rgn_offset);
#endif
#if 1
- sub_next(mr, 0);
+ sub_next(mr, 0);
#endif
#if 0
- {
- struct rgn_point *pnt;
- int i;
- int offset=0x65cc;
- for (i = 0 ; i < 26 ; i++) {
- pnt=file_read(&mr->rgn, 0x656c+8*i-mr->rgn.offset, sizeof(*pnt));
- // dump_hex(pnt, sizeof(*pnt));
- dump_point(pnt);
- dump_label_offset(mr, triple_u(&pnt->lbl_offset));
- }
- }
- exit(0);
+ {
+ struct rgn_point *pnt;
+ int i;
+ int offset=0x65cc;
+ for (i = 0 ; i < 26 ; i++) {
+ pnt=file_read(&mr->rgn, 0x656c+8*i-mr->rgn.offset, sizeof(*pnt));
+ // dump_hex(pnt, sizeof(*pnt));
+ dump_point(pnt);
+ dump_label_offset(mr, triple_u(&pnt->lbl_offset));
+ }
+ }
+ exit(0);
#endif
#if 0
- dump_tree(&mr->tre,&mr->rgn,mr);
+ dump_tree(&mr->tre,&mr->rgn,mr);
#endif
#if 0
- f.offset=0x64a*2048;
- f.f=mr->f;
- dump_labels(&f);
+ f.offset=0x64a*2048;
+ f.f=mr->f;
+ dump_labels(&f);
#endif
#if 0
- fseek(mr->f, img.file_offset, SEEK_SET);
- fread(&fil, sizeof(fil), 1, mr->f);
- dump_file(&fil);
- fread(&rgn, sizeof(rgn), 1, mr->f);
- dump_region(&rgn);
- fseek(mr->f, rgn.data_length, SEEK_CUR);
- fread(&fil, sizeof(fil), 1, mr->f);
- dump_file(&fil);
+ fseek(mr->f, img.file_offset, SEEK_SET);
+ fread(&fil, sizeof(fil), 1, mr->f);
+ dump_file(&fil);
+ fread(&rgn, sizeof(rgn), 1, mr->f);
+ dump_region(&rgn);
+ fseek(mr->f, rgn.data_length, SEEK_CUR);
+ fread(&fil, sizeof(fil), 1, mr->f);
+ dump_file(&fil);
#endif
- return mr;
+ return mr;
}
-static void
-map_rect_destroy_garmin_img(struct map_rect_priv *mr)
-{
- fclose(mr->f);
- g_free(mr);
+static void map_rect_destroy_garmin_img(struct map_rect_priv *mr) {
+ fclose(mr->f);
+ g_free(mr);
}
-static struct item *
-map_rect_get_item_garmin_img(struct map_rect_priv *mr)
-{
- char *p,type[256];
- int ptype;
- int debug=0;
-
- item_count++;
-
- if (debug)
- printf("map_rect_get_item_garmin_img\n");
- for (;;) {
- if (mr->rgn_offset < mr->rgn_end) {
- if (debug)
- printf("data available\n");
- if (mr->rgn_type >= 2) {
- int len;
- if (debug)
- printf("polyline %d\n", mr->count);
- if (mr->ply)
- file_free(mr->ply);
- mr->ply=file_read(&mr->rgn, mr->rgn_offset, sizeof(*mr->ply)*3);
- if(triple_u(&mr->ply->lbl_offset) >= mr->lbl_hdr->label.offset_len.length) {
- printf("item_count %d\n", item_count);
- dump_poly(mr->ply);
- dump_hex(mr->ply, 32);
- printf("%d vs %d\n", triple_u(&mr->ply->lbl_offset), mr->lbl_hdr->label.offset_len.length);
- }
- g_assert(triple_u(&mr->ply->lbl_offset) < mr->lbl_hdr->label.offset_len.length);
- if (debug) {
- dump_hex(mr->ply, 16);
- dump_poly(mr->ply);
- }
- if (mr->ply_data)
- file_free(mr->ply_data);
- mr->rgn_offset+=10;
- if (mr->ply->info & 0x80) {
- mr->rgn_offset++;
- len=mr->ply->u.p2.bitstream_len;
- } else
- len=mr->ply->u.p1.bitstream_len;
-
- mr->ply_data=file_read(&mr->rgn, mr->rgn_offset, len);
- mr->rgn_offset += len;
- mr->ply_bitpos=0;
- // dump_hex(mr->ply_data, 32);
- if (mr->rgn_type == 3) {
- switch(mr->ply->info & 0x7f) {
- case 0x1: /* large urban area (>200k) */
- mr->item.type=type_town_poly;
- break;
- case 0xd: /* reservation */
- mr->item.type=type_park_poly;
- break;
- case 0xe: /* airport runway */
- mr->item.type=type_airport_poly;
- break;
- case 0x14: /* national park */
- mr->item.type=type_park_poly;
- break;
- case 0x32: /* sea */
- case 0x3d: /* large lake (77-250km2) */
- case 0x4c: /* intermittend water */
- mr->item.type=type_water_poly;
- break;
- case 0x4b: /* background */
- continue;
- default:
- printf("unknown polygon: 0x%x\n", mr->ply->info);
- mr->item.type=type_street_3_city;
- }
- } else {
- switch(mr->ply->info & 0x3f) {
- case 0x1: /* major highway */
- mr->item.type=type_highway_land;
- break;
- case 0x2: /* principal highway */
- mr->item.type=type_street_3_land;
- break;
- case 0x6: /* residental street */
- mr->item.type=type_street_2_land;
- break;
- case 0x16: /* walkway/trail */
- mr->item.type=type_street_1_land;
- break;
- case 0x1e: /* international boundary */
- mr->item.type=type_border_country;
- break;
- case 0x20: /* minor land contour 1/10 */
- mr->item.type=type_height_line_1;
- break;
- case 0x21: /* major land contour 1/2 */
- mr->item.type=type_height_line_2;
- break;
- default:
- printf("unknown polyline: 0x%x\n", mr->ply->info);
- mr->item.type=type_street_3_city;
- }
- }
- return &mr->item;
- }
- if (mr->pnt)
- file_free(mr->pnt);
- mr->pnt=file_read(&mr->rgn, mr->rgn_offset, sizeof(*mr->pnt));
- mr->item.type=type_none;
- int subtype=mr->pnt->subtype;
- if (mr->pnt->lbl_offset.data[2] & 0x80)
- mr->rgn_offset+=9;
- else {
- mr->rgn_offset+=8;
- subtype=0;
- }
- switch(mr->pnt->info) {
- case 0x3: /* large city 2-5M */
- mr->item.type=type_town_label_2e6;
- break;
- case 0xa: /* small city/town 10-20k */
- mr->item.type=type_town_label_1e4;
- break;
- case 0xd: /* settlement 1-2K */
- mr->item.type=type_town_label_1e3;
- break;
- case 0x11: /* settlement less 100 */
- mr->item.type=type_town_label_5e1;
- break;
- case 0x1c:
- switch(subtype) {
- case 0x01:
- mr->item.type=type_poi_wreck;
- break;
- }
- break;
- case 0x20:
- mr->item.type=type_highway_exit;
- break;
- case 0x25:
- mr->item.type=type_poi_toll_booth;
- break;
- case 0x2b:
- switch(subtype) {
- case 0x01:
- mr->item.type=type_poi_hotel;
- break;
- case 0x03:
- mr->item.type=type_poi_camp_rv;
- break;
- }
- break;
- case 0x2c:
- switch(subtype) {
- case 0x00:
- mr->item.type=type_poi_attraction;
- break;
- case 0x02:
- mr->item.type=type_poi_museum_history;
- break;
- }
- break;
- case 0x2e:
- mr->item.type=type_poi_shopping;
- break;
- case 0x2f:
- switch(subtype) {
- case 0x01:
- mr->item.type=type_poi_fuel;
- break;
- case 0x07:
- mr->item.type=type_poi_car_dealer_parts;
- break;
- case 0x0b:
- mr->item.type=type_poi_car_parking;
- break;
- case 0x15:
- mr->item.type=type_poi_public_utilities;
- break;
- }
- break;
- case 0x30:
- switch(subtype) {
- case 0x02:
- mr->item.type=type_poi_hospital;
- break;
- }
- break;
- case 0x43:
- mr->item.type=type_poi_marina;
- break;
- case 0x46:
- mr->item.type=type_poi_bar;
- break;
- case 0x48:
- mr->item.type=type_poi_camping;
- break;
- case 0x49:
- mr->item.type=type_poi_park;
- break;
- case 0x4a:
- mr->item.type=type_poi_picnic;
- break;
- case 0x59: /* airport */
- mr->item.type=type_poi_airport;
- break;
- case 0x64:
- switch(subtype) {
- case 0x1:
- mr->item.type=type_poi_bridge;
- break;
- case 0x2:
- mr->item.type=type_poi_building;
- break;
- case 0x15:
- mr->item.type=type_town_ghost;
- break;
- }
- break;
- case 0x65:
- switch(subtype) {
- case 0x0:
- mr->item.type=type_poi_water_feature;
- break;
- case 0xc:
- mr->item.type=type_poi_island;
- break;
- case 0xd:
- mr->item.type=type_poi_lake;
- break;
- }
- break;
- case 0x66:
- switch(subtype) {
- case 0x0:
- mr->item.type=type_poi_land_feature;
- break;
- case 0x6:
- mr->item.type=type_poi_cape;
- break;
- case 0x14:
- mr->item.type=type_poi_rock;
- break;
- }
- break;
- }
- if (mr->item.type == type_none) {
- printf("unknown point: 0x%x 0x%x\n", mr->pnt->info, mr->pnt->subtype);
- dump_point(mr->pnt);
- printf("label: %s\n", get_label_offset(mr, triple_u(&mr->pnt->lbl_offset) & 0x3fffff));
- mr->item.type=type_town_label;
- }
- return &mr->item;
- }
- if (debug)
- printf("out of data for type\n");
- if (rgn_next_type(mr)) {
- if (debug)
- printf("out of data for region\n");
- if (sub_next(mr, subdiv_next)) {
- if (debug)
- printf("out of data for subdivision\n");
- return NULL;
- }
- }
- }
+static struct item *map_rect_get_item_garmin_img(struct map_rect_priv *mr) {
+ char *p,type[256];
+ int ptype;
+ int debug=0;
+
+ item_count++;
+
+ if (debug)
+ printf("map_rect_get_item_garmin_img\n");
+ for (;;) {
+ if (mr->rgn_offset < mr->rgn_end) {
+ if (debug)
+ printf("data available\n");
+ if (mr->rgn_type >= 2) {
+ int len;
+ if (debug)
+ printf("polyline %d\n", mr->count);
+ if (mr->ply)
+ file_free(mr->ply);
+ mr->ply=file_read(&mr->rgn, mr->rgn_offset, sizeof(*mr->ply)*3);
+ if(triple_u(&mr->ply->lbl_offset) >= mr->lbl_hdr->label.offset_len.length) {
+ printf("item_count %d\n", item_count);
+ dump_poly(mr->ply);
+ dump_hex(mr->ply, 32);
+ printf("%d vs %d\n", triple_u(&mr->ply->lbl_offset), mr->lbl_hdr->label.offset_len.length);
+ }
+ g_assert(triple_u(&mr->ply->lbl_offset) < mr->lbl_hdr->label.offset_len.length);
+ if (debug) {
+ dump_hex(mr->ply, 16);
+ dump_poly(mr->ply);
+ }
+ if (mr->ply_data)
+ file_free(mr->ply_data);
+ mr->rgn_offset+=10;
+ if (mr->ply->info & 0x80) {
+ mr->rgn_offset++;
+ len=mr->ply->u.p2.bitstream_len;
+ } else
+ len=mr->ply->u.p1.bitstream_len;
+
+ mr->ply_data=file_read(&mr->rgn, mr->rgn_offset, len);
+ mr->rgn_offset += len;
+ mr->ply_bitpos=0;
+ // dump_hex(mr->ply_data, 32);
+ if (mr->rgn_type == 3) {
+ switch(mr->ply->info & 0x7f) {
+ case 0x1: /* large urban area (>200k) */
+ mr->item.type=type_town_poly;
+ break;
+ case 0xd: /* reservation */
+ mr->item.type=type_park_poly;
+ break;
+ case 0xe: /* airport runway */
+ mr->item.type=type_airport_poly;
+ break;
+ case 0x14: /* national park */
+ mr->item.type=type_park_poly;
+ break;
+ case 0x32: /* sea */
+ case 0x3d: /* large lake (77-250km2) */
+ case 0x4c: /* intermittend water */
+ mr->item.type=type_water_poly;
+ break;
+ case 0x4b: /* background */
+ continue;
+ default:
+ printf("unknown polygon: 0x%x\n", mr->ply->info);
+ mr->item.type=type_street_3_city;
+ }
+ } else {
+ switch(mr->ply->info & 0x3f) {
+ case 0x1: /* major highway */
+ mr->item.type=type_highway_land;
+ break;
+ case 0x2: /* principal highway */
+ mr->item.type=type_street_3_land;
+ break;
+ case 0x6: /* residental street */
+ mr->item.type=type_street_2_land;
+ break;
+ case 0x16: /* walkway/trail */
+ mr->item.type=type_street_1_land;
+ break;
+ case 0x1e: /* international boundary */
+ mr->item.type=type_border_country;
+ break;
+ case 0x20: /* minor land contour 1/10 */
+ mr->item.type=type_height_line_1;
+ break;
+ case 0x21: /* major land contour 1/2 */
+ mr->item.type=type_height_line_2;
+ break;
+ default:
+ printf("unknown polyline: 0x%x\n", mr->ply->info);
+ mr->item.type=type_street_3_city;
+ }
+ }
+ return &mr->item;
+ }
+ if (mr->pnt)
+ file_free(mr->pnt);
+ mr->pnt=file_read(&mr->rgn, mr->rgn_offset, sizeof(*mr->pnt));
+ mr->item.type=type_none;
+ int subtype=mr->pnt->subtype;
+ if (mr->pnt->lbl_offset.data[2] & 0x80)
+ mr->rgn_offset+=9;
+ else {
+ mr->rgn_offset+=8;
+ subtype=0;
+ }
+ switch(mr->pnt->info) {
+ case 0x3: /* large city 2-5M */
+ mr->item.type=type_town_label_2e6;
+ break;
+ case 0xa: /* small city/town 10-20k */
+ mr->item.type=type_town_label_1e4;
+ break;
+ case 0xd: /* settlement 1-2K */
+ mr->item.type=type_town_label_1e3;
+ break;
+ case 0x11: /* settlement less 100 */
+ mr->item.type=type_town_label_5e1;
+ break;
+ case 0x1c:
+ switch(subtype) {
+ case 0x01:
+ mr->item.type=type_poi_wreck;
+ break;
+ }
+ break;
+ case 0x20:
+ mr->item.type=type_highway_exit;
+ break;
+ case 0x25:
+ mr->item.type=type_poi_toll_booth;
+ break;
+ case 0x2b:
+ switch(subtype) {
+ case 0x01:
+ mr->item.type=type_poi_hotel;
+ break;
+ case 0x03:
+ mr->item.type=type_poi_camp_rv;
+ break;
+ }
+ break;
+ case 0x2c:
+ switch(subtype) {
+ case 0x00:
+ mr->item.type=type_poi_attraction;
+ break;
+ case 0x02:
+ mr->item.type=type_poi_museum_history;
+ break;
+ }
+ break;
+ case 0x2e:
+ mr->item.type=type_poi_shopping;
+ break;
+ case 0x2f:
+ switch(subtype) {
+ case 0x01:
+ mr->item.type=type_poi_fuel;
+ break;
+ case 0x07:
+ mr->item.type=type_poi_car_dealer_parts;
+ break;
+ case 0x0b:
+ mr->item.type=type_poi_car_parking;
+ break;
+ case 0x15:
+ mr->item.type=type_poi_public_utilities;
+ break;
+ }
+ break;
+ case 0x30:
+ switch(subtype) {
+ case 0x02:
+ mr->item.type=type_poi_hospital;
+ break;
+ }
+ break;
+ case 0x43:
+ mr->item.type=type_poi_marina;
+ break;
+ case 0x46:
+ mr->item.type=type_poi_bar;
+ break;
+ case 0x48:
+ mr->item.type=type_poi_camping;
+ break;
+ case 0x49:
+ mr->item.type=type_poi_park;
+ break;
+ case 0x4a:
+ mr->item.type=type_poi_picnic;
+ break;
+ case 0x59: /* airport */
+ mr->item.type=type_poi_airport;
+ break;
+ case 0x64:
+ switch(subtype) {
+ case 0x1:
+ mr->item.type=type_poi_bridge;
+ break;
+ case 0x2:
+ mr->item.type=type_poi_building;
+ break;
+ case 0x15:
+ mr->item.type=type_town_ghost;
+ break;
+ }
+ break;
+ case 0x65:
+ switch(subtype) {
+ case 0x0:
+ mr->item.type=type_poi_water_feature;
+ break;
+ case 0xc:
+ mr->item.type=type_poi_island;
+ break;
+ case 0xd:
+ mr->item.type=type_poi_lake;
+ break;
+ }
+ break;
+ case 0x66:
+ switch(subtype) {
+ case 0x0:
+ mr->item.type=type_poi_land_feature;
+ break;
+ case 0x6:
+ mr->item.type=type_poi_cape;
+ break;
+ case 0x14:
+ mr->item.type=type_poi_rock;
+ break;
+ }
+ break;
+ }
+ if (mr->item.type == type_none) {
+ printf("unknown point: 0x%x 0x%x\n", mr->pnt->info, mr->pnt->subtype);
+ dump_point(mr->pnt);
+ printf("label: %s\n", get_label_offset(mr, triple_u(&mr->pnt->lbl_offset) & 0x3fffff));
+ mr->item.type=type_town_label;
+ }
+ return &mr->item;
+ }
+ if (debug)
+ printf("out of data for type\n");
+ if (rgn_next_type(mr)) {
+ if (debug)
+ printf("out of data for region\n");
+ if (sub_next(mr, subdiv_next)) {
+ if (debug)
+ printf("out of data for subdivision\n");
+ return NULL;
+ }
+ }
+ }
}
-static struct item *
-map_rect_get_item_byid_garmin_img(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- fseek(mr->f, id_lo, SEEK_SET);
- get_line(mr);
- mr->item.id_hi=id_hi;
- return map_rect_get_item_garmin_img(mr);
+static struct item *map_rect_get_item_byid_garmin_img(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ fseek(mr->f, id_lo, SEEK_SET);
+ get_line(mr);
+ mr->item.id_hi=id_hi;
+ return map_rect_get_item_garmin_img(mr);
}
static struct map_methods map_methods_garmin_img = {
- projection_garmin,
- "iso8859-1",
- map_destroy_garmin_img,
- map_charset_garmin_img,
- map_projection_garmin_img,
- map_rect_new_garmin_img,
- map_rect_destroy_garmin_img,
- map_rect_get_item_garmin_img,
- map_rect_get_item_byid_garmin_img,
+ projection_garmin,
+ "iso8859-1",
+ map_destroy_garmin_img,
+ map_charset_garmin_img,
+ map_projection_garmin_img,
+ map_rect_new_garmin_img,
+ map_rect_destroy_garmin_img,
+ map_rect_get_item_garmin_img,
+ map_rect_get_item_byid_garmin_img,
};
-static struct map_priv *
-map_new_garmin_img(struct map_methods *meth, struct attr **attrs)
-{
- struct map_priv *m;
- struct attr *data=attr_search(attrs, NULL, attr_data);
- if (! data)
- return NULL;
-
- *meth=map_methods_garmin_img;
- m=g_new(struct map_priv, 1);
- m->id=++map_id;
- m->filename=g_strdup(data->u.str);
- return m;
+static struct map_priv *map_new_garmin_img(struct map_methods *meth, struct attr **attrs) {
+ struct map_priv *m;
+ struct attr *data=attr_search(attrs, NULL, attr_data);
+ if (! data)
+ return NULL;
+
+ *meth=map_methods_garmin_img;
+ m=g_new(struct map_priv, 1);
+ m->id=++map_id;
+ m->filename=g_strdup(data->u.str);
+ return m;
}
-void
-plugin_init(void)
-{
- plugin_register_category_map("garmin_img", map_new_garmin_img);
+void plugin_init(void) {
+ plugin_register_category_map("garmin_img", map_new_garmin_img);
}
diff --git a/navit/map/mg/block.c b/navit/map/mg/block.c
index b2bb64ac0..1b2dbeec7 100644
--- a/navit/map/mg/block.c
+++ b/navit/map/mg/block.c
@@ -26,273 +26,259 @@
int block_lin_count,block_idx_count,block_active_count,block_mem,block_active_mem;
struct block_index_item {
- /*unsigned int blocknum;
- unsigned int blocks;*/
- unsigned char p[8];
+ /*unsigned int blocknum;
+ unsigned int blocks;*/
+ unsigned char p[8];
};
-static inline unsigned int block_index_item_get_blocknum(struct block_index_item * blk) { unsigned char *p = blk->p; return get_u32(&p); }
-static inline unsigned int block_index_item_get_blocks(struct block_index_item * blk) { unsigned char *p = blk->p+4; return get_u32(&p); }
+static inline unsigned int block_index_item_get_blocknum(struct block_index_item * blk) {
+ unsigned char *p = blk->p;
+ return get_u32(&p);
+}
+static inline unsigned int block_index_item_get_blocks(struct block_index_item * blk) {
+ unsigned char *p = blk->p+4;
+ return get_u32(&p);
+}
struct block_index {
-/* unsigned int blocks;
- unsigned int size;
- unsigned int next;
- struct block_index_item list[0];*/
- unsigned char p[12];
+ /* unsigned int blocks;
+ unsigned int size;
+ unsigned int next;
+ struct block_index_item list[0];*/
+ unsigned char p[12];
};
-static inline unsigned int block_index_get_blocks(struct block_index * blk) { unsigned char *p = blk->p; return get_u32(&p); }
-static inline unsigned int block_index_get_size(struct block_index * blk) { unsigned char *p = blk->p+4; return get_u32(&p); }
-static inline unsigned int block_index_get_next(struct block_index * blk) { unsigned char *p = blk->p+8; return get_u32(&p); }
-static inline struct block_index_item * block_index_get_list(struct block_index * blk) { return (struct block_index_item *)(blk->p+12); }
+static inline unsigned int block_index_get_blocks(struct block_index * blk) {
+ unsigned char *p = blk->p;
+ return get_u32(&p);
+}
+static inline unsigned int block_index_get_size(struct block_index * blk) {
+ unsigned char *p = blk->p+4;
+ return get_u32(&p);
+}
+static inline unsigned int block_index_get_next(struct block_index * blk) {
+ unsigned char *p = blk->p+8;
+ return get_u32(&p);
+}
+static inline struct block_index_item * block_index_get_list(struct block_index * blk) {
+ return (struct block_index_item *)(blk->p+12);
+}
-static struct block *
-block_get(unsigned char **p)
-{
- struct block *ret=(struct block *)(*p);
- *p += sizeof(*ret);
- return ret;
+static struct block *block_get(unsigned char **p) {
+ struct block *ret=(struct block *)(*p);
+ *p += sizeof(*ret);
+ return ret;
}
-static struct block *
-block_get_byid(struct file *file, int id, unsigned char **p_ret)
-{
- struct block_index *blk_idx;
- int blk_num,max;
+static struct block *block_get_byid(struct file *file, int id, unsigned char **p_ret) {
+ struct block_index *blk_idx;
+ int blk_num,max;
- blk_idx=(struct block_index *)(file->begin+0x1000);
- max=(block_index_get_size(blk_idx)-sizeof(struct block_index))/sizeof(struct block_index_item);
- block_mem+=24;
- while (id >= max) {
- blk_idx=(struct block_index *)(file->begin+block_index_get_next(blk_idx)*512);
- id-=max;
- }
- blk_num=block_index_item_get_blocknum(&block_index_get_list(blk_idx)[id]);
+ blk_idx=(struct block_index *)(file->begin+0x1000);
+ max=(block_index_get_size(blk_idx)-sizeof(struct block_index))/sizeof(struct block_index_item);
+ block_mem+=24;
+ while (id >= max) {
+ blk_idx=(struct block_index *)(file->begin+block_index_get_next(blk_idx)*512);
+ id-=max;
+ }
+ blk_num=block_index_item_get_blocknum(&block_index_get_list(blk_idx)[id]);
- *p_ret=file->begin+blk_num*512;
- return block_get(p_ret);
+ *p_ret=file->begin+blk_num*512;
+ return block_get(p_ret);
}
-int
-block_get_byindex(struct file *file, int idx, struct block_priv *blk)
-{
- dbg(lvl_debug,"idx=%d\n", idx);
- blk->b=block_get_byid(file, idx, &blk->p);
- blk->block_start=(unsigned char *)(blk->b);
- blk->p_start=blk->p;
- blk->end=blk->block_start+block_get_size(blk->b);
+int block_get_byindex(struct file *file, int idx, struct block_priv *blk) {
+ dbg(lvl_debug,"idx=%d", idx);
+ blk->b=block_get_byid(file, idx, &blk->p);
+ blk->block_start=(unsigned char *)(blk->b);
+ blk->p_start=blk->p;
+ blk->end=blk->block_start+block_get_size(blk->b);
- return 1;
+ return 1;
}
-static void
-block_setup_tags(struct map_rect_priv *mr)
-{
- int len;
- unsigned char *p,*t;
- char *str;
+static void block_setup_tags(struct map_rect_priv *mr) {
+ int len;
+ unsigned char *p,*t;
+ char *str;
- mr->b.binarytree=0;
+ mr->b.binarytree=0;
- p=mr->file->begin+0x0c;
- while (*p) {
- str=get_string(&p);
- len=get_u32_unal(&p);
- t=p;
- /* printf("String '%s' len %d\n", str, len); */
- if (! strcmp(str,"FirstBatBlock")) {
- /* printf("%ld\n", get_u32_unal(&t)); */
- } else if (! strcmp(str,"MaxBlockSize")) {
- /* printf("%ld\n", get_u32_unal(&t)); */
- } else if (! strcmp(str,"FREE_BLOCK_LIST")) {
- /* printf("%ld\n", get_u32_unal(&t)); */
- } else if (! strcmp(str,"TotalRect")) {
- mr->b.b_rect.lu.x=get_u32_unal(&t);
- mr->b.b_rect.lu.y=get_u32_unal(&t);
- mr->b.b_rect.rl.x=get_u32_unal(&t);
- mr->b.b_rect.rl.y=get_u32_unal(&t);
- /* printf("0x%x,0x%x-0x%x,0x%x\n", mr->b.b_rect.lu.x, mr->b.b_rect.lu.y, mr->b.b_rect.rl.x, mr->b.b_rect.rl.y); */
- } else if (! strcmp(str,"Version")) {
- /* printf("0x%lx\n", get_u32_unal(&t)); */
- } else if (! strcmp(str,"Categories")) {
- /* printf("0x%x\n", get_u16(&t)); */
- } else if (! strcmp(str,"binaryTree")) {
- mr->b.binarytree=get_u32_unal(&t);
- /* printf("%d\n", mr->b.binarytree); */
- } else if (! strcmp(str,"CategorySets")) {
- /* printf("0x%x\n", get_u16(&t)); */
- } else if (! strcmp(str,"Kommentar")) {
- /* printf("%s\n", get_string(&t)); */
- }
- p+=len;
- }
+ p=mr->file->begin+0x0c;
+ while (*p) {
+ str=get_string(&p);
+ len=get_u32_unal(&p);
+ t=p;
+ /* printf("String '%s' len %d\n", str, len); */
+ if (! strcmp(str,"FirstBatBlock")) {
+ /* printf("%ld\n", get_u32_unal(&t)); */
+ } else if (! strcmp(str,"MaxBlockSize")) {
+ /* printf("%ld\n", get_u32_unal(&t)); */
+ } else if (! strcmp(str,"FREE_BLOCK_LIST")) {
+ /* printf("%ld\n", get_u32_unal(&t)); */
+ } else if (! strcmp(str,"TotalRect")) {
+ mr->b.b_rect.lu.x=get_u32_unal(&t);
+ mr->b.b_rect.lu.y=get_u32_unal(&t);
+ mr->b.b_rect.rl.x=get_u32_unal(&t);
+ mr->b.b_rect.rl.y=get_u32_unal(&t);
+ /* printf("0x%x,0x%x-0x%x,0x%x\n", mr->b.b_rect.lu.x, mr->b.b_rect.lu.y, mr->b.b_rect.rl.x, mr->b.b_rect.rl.y); */
+ } else if (! strcmp(str,"Version")) {
+ /* printf("0x%lx\n", get_u32_unal(&t)); */
+ } else if (! strcmp(str,"Categories")) {
+ /* printf("0x%x\n", get_u16(&t)); */
+ } else if (! strcmp(str,"binaryTree")) {
+ mr->b.binarytree=get_u32_unal(&t);
+ /* printf("%d\n", mr->b.binarytree); */
+ } else if (! strcmp(str,"CategorySets")) {
+ /* printf("0x%x\n", get_u16(&t)); */
+ } else if (! strcmp(str,"Kommentar")) {
+ /* printf("%s\n", get_string(&t)); */
+ }
+ p+=len;
+ }
}
#if 0
-static void
-block_rect_print(struct coord_rect *r)
-{
- printf ("0x%x,0x%x-0x%x,0x%x (0x%x,0x%x)", r->lu.x, r->lu.y, r->rl.x, r->rl.y, r->lu.x/2+r->rl.x/2,r->lu.y/2+r->rl.y/2);
+static void block_rect_print(struct coord_rect *r) {
+ printf ("0x%x,0x%x-0x%x,0x%x (0x%x,0x%x)", r->lu.x, r->lu.y, r->rl.x, r->rl.y, r->lu.x/2+r->rl.x/2,r->lu.y/2+r->rl.y/2);
}
#endif
-static void
-block_rect_same(struct coord_rect *r1, struct coord_rect *r2)
-{
- dbg_assert(r1->lu.x==r2->lu.x);
- dbg_assert(r1->lu.y==r2->lu.y);
- dbg_assert(r1->rl.x==r2->rl.x);
- dbg_assert(r1->rl.y==r2->rl.y);
+static void block_rect_same(struct coord_rect *r1, struct coord_rect *r2) {
+ dbg_assert(r1->lu.x==r2->lu.x);
+ dbg_assert(r1->lu.y==r2->lu.y);
+ dbg_assert(r1->rl.x==r2->rl.x);
+ dbg_assert(r1->rl.y==r2->rl.y);
}
-int
-block_init(struct map_rect_priv *mr)
-{
- mr->b.block_num=-1;
- mr->b.bt.b=NULL;
- mr->b.bt.next=0;
- block_setup_tags(mr);
- if (mr->b.binarytree) {
- mr->b.bt.next=mr->b.binarytree;
- mr->b.bt.p=NULL;
- mr->b.bt.block_count=0;
- }
- if (mr->cur_sel && !coord_rect_overlap(&mr->cur_sel->u.c_rect, &mr->b.b_rect))
- return 0;
- return block_next(mr);
+int block_init(struct map_rect_priv *mr) {
+ mr->b.block_num=-1;
+ mr->b.bt.b=NULL;
+ mr->b.bt.next=0;
+ block_setup_tags(mr);
+ if (mr->b.binarytree) {
+ mr->b.bt.next=mr->b.binarytree;
+ mr->b.bt.p=NULL;
+ mr->b.bt.block_count=0;
+ }
+ if (mr->cur_sel && !coord_rect_overlap(&mr->cur_sel->u.c_rect, &mr->b.b_rect))
+ return 0;
+ return block_next(mr);
}
-int
-block_next_lin(struct map_rect_priv *mr)
-{
- struct coord_rect r;
- for (;;) {
- block_lin_count++;
- block_mem+=sizeof(struct block *);
- mr->b.block_num++;
- if (! mr->b.block_num)
- mr->b.p=mr->file->begin+0x2000;
- else
- mr->b.p=mr->b.block_start+block_get_blocks(mr->b.b)*512;
- if (mr->b.p >= mr->file->end) {
- dbg(lvl_debug,"end of blocks %p vs %p\n", mr->b.p, mr->file->end);
- return 0;
- }
- mr->b.block_start=mr->b.p;
- mr->b.b=block_get(&mr->b.p);
- mr->b.p_start=mr->b.p;
- mr->b.end=mr->b.block_start+block_get_size(mr->b.b);
- if (block_get_count(mr->b.b) == -1) {
- dbg(lvl_warning,"empty blocks\n");
- return 0;
- }
- block_get_r(mr->b.b, &r);
- if (!mr->cur_sel || coord_rect_overlap(&mr->cur_sel->u.c_rect, &r)) {
- block_active_count++;
- block_active_mem+=block_get_blocks(mr->b.b)*512-sizeof(struct block *);
- dbg(lvl_debug,"block ok\n");
- return 1;
- }
- dbg(lvl_info,"block not in cur_sel\n");
- }
+int block_next_lin(struct map_rect_priv *mr) {
+ struct coord_rect r;
+ for (;;) {
+ block_lin_count++;
+ block_mem+=sizeof(struct block *);
+ mr->b.block_num++;
+ if (! mr->b.block_num)
+ mr->b.p=mr->file->begin+0x2000;
+ else
+ mr->b.p=mr->b.block_start+block_get_blocks(mr->b.b)*512;
+ if (mr->b.p >= mr->file->end) {
+ dbg(lvl_debug,"end of blocks %p vs %p", mr->b.p, mr->file->end);
+ return 0;
+ }
+ mr->b.block_start=mr->b.p;
+ mr->b.b=block_get(&mr->b.p);
+ mr->b.p_start=mr->b.p;
+ mr->b.end=mr->b.block_start+block_get_size(mr->b.b);
+ if (block_get_count(mr->b.b) == -1) {
+ dbg(lvl_warning,"empty blocks");
+ return 0;
+ }
+ block_get_r(mr->b.b, &r);
+ if (!mr->cur_sel || coord_rect_overlap(&mr->cur_sel->u.c_rect, &r)) {
+ block_active_count++;
+ block_active_mem+=block_get_blocks(mr->b.b)*512-sizeof(struct block *);
+ dbg(lvl_debug,"block ok");
+ return 1;
+ }
+ dbg(lvl_info,"block not in cur_sel");
+ }
}
-int
-block_next(struct map_rect_priv *mr)
-{
- int blk_num,coord,r_h,r_w;
- struct block_bt_priv *bt=&mr->b.bt;
- struct coord_rect r;
+int block_next(struct map_rect_priv *mr) {
+ int blk_num,coord,r_h,r_w;
+ struct block_bt_priv *bt=&mr->b.bt;
+ struct coord_rect r;
- if (!mr->b.binarytree || ! mr->cur_sel)
- return block_next_lin(mr);
- for (;;) {
- if (! bt->p) {
- dbg(lvl_debug,"block 0x%x\n", bt->next);
- if (bt->next == -1)
- return 0;
- bt->b=block_get_byid(mr->file, bt->next, &bt->p);
- bt->end=(unsigned char *)mr->b.bt.b+block_get_size(mr->b.bt.b);
- bt->next=block_get_next(bt->b);
- bt->order=0;
- dbg(lvl_debug,"size 0x%x next 0x%x\n", block_get_size(bt->b), block_get_next(bt->b));
- if (! mr->b.bt.block_count) {
-#if 0
- if (debug) {
- printf("idx rect ");
- block_rect_print(&mr->b.bt.b->r);
- }
-#endif
- block_get_r(bt->b, &bt->r);
- bt->r_curr=bt->r;
- coord=get_u32(&mr->b.bt.p);
- } else {
- bt->p=(unsigned char *)bt->b+0xc;
- }
- bt->block_count++;
- }
- while (mr->b.bt.p < mr->b.bt.end) {
- block_idx_count++;
- blk_num=get_u32(&mr->b.bt.p);
- coord=get_u32(&mr->b.bt.p);
- block_mem+=8;
- dbg(lvl_debug,"%p vs %p coord 0x%x ", mr->b.bt.end, mr->b.bt.p, coord);
- dbg(lvl_debug,"block 0x%x", blk_num);
-
- r_w=bt->r_curr.rl.x-bt->r_curr.lu.x;
- r_h=bt->r_curr.lu.y-bt->r_curr.rl.y;
-#if 0
- if (debug) {
- printf(" rect1 ");
- block_rect_print(&bt->r_curr);
- printf(" %dx%d", r_w, r_h);
- }
-#endif
- mr->b.b=NULL;
- if (blk_num != -1) {
- block_mem+=8;
- if (coord_rect_overlap(&mr->cur_sel->u.c_rect, &bt->r_curr)) {
- mr->b.b=block_get_byid(mr->file, blk_num, &mr->b.p);
- mr->b.block_num=blk_num;
- dbg_assert(mr->b.b != NULL);
- mr->b.block_start=(unsigned char *)(mr->b.b);
- mr->b.p_start=mr->b.p;
- mr->b.end=mr->b.block_start+block_get_size(mr->b.b);
- block_get_r(mr->b.b, &r);
- block_rect_same(&r, &bt->r_curr);
- }
- }
- if (coord != -1) {
- bt->stack[bt->stackp]=bt->r_curr;
- if (r_w > r_h) {
- bt->r_curr.rl.x=coord;
- bt->stack[bt->stackp].lu.x=coord+1;
- } else {
- bt->r_curr.lu.y=coord;
- bt->stack[bt->stackp].rl.y=coord+1;
- }
- bt->stackp++;
- dbg_assert(bt->stackp < BT_STACK_SIZE);
- } else {
- if (bt->stackp) {
- bt->stackp--;
- bt->r_curr=bt->stack[bt->stackp];
- } else {
- bt->r_curr=bt->r;
- bt->order++;
- if (bt->order > 100)
- return 0;
- }
- }
- if (mr->b.b) {
- block_active_count++;
- block_active_mem+=block_get_blocks(mr->b.b)*512;
- return 1;
- }
- }
- bt->p=NULL;
- }
- return 0;
+ if (!mr->b.binarytree || ! mr->cur_sel)
+ return block_next_lin(mr);
+ for (;;) {
+ if (! bt->p) {
+ dbg(lvl_debug,"block 0x%x", bt->next);
+ if (bt->next == -1)
+ return 0;
+ bt->b=block_get_byid(mr->file, bt->next, &bt->p);
+ bt->end=(unsigned char *)mr->b.bt.b+block_get_size(mr->b.bt.b);
+ bt->next=block_get_next(bt->b);
+ bt->order=0;
+ dbg(lvl_debug,"size 0x%x next 0x%x", block_get_size(bt->b), block_get_next(bt->b));
+ if (! mr->b.bt.block_count) {
+ block_get_r(bt->b, &bt->r);
+ bt->r_curr=bt->r;
+ coord=get_u32(&mr->b.bt.p);
+ } else {
+ bt->p=(unsigned char *)bt->b+0xc;
+ }
+ bt->block_count++;
+ }
+ while (mr->b.bt.p < mr->b.bt.end) {
+ block_idx_count++;
+ blk_num=get_u32(&mr->b.bt.p);
+ coord=get_u32(&mr->b.bt.p);
+ block_mem+=8;
+ dbg(lvl_debug,"%p vs %p coord 0x%x ", mr->b.bt.end, mr->b.bt.p, coord);
+ dbg(lvl_debug,"block 0x%x", blk_num);
+
+ r_w=bt->r_curr.rl.x-bt->r_curr.lu.x;
+ r_h=bt->r_curr.lu.y-bt->r_curr.rl.y;
+ mr->b.b=NULL;
+ if (blk_num != -1) {
+ block_mem+=8;
+ if (coord_rect_overlap(&mr->cur_sel->u.c_rect, &bt->r_curr)) {
+ mr->b.b=block_get_byid(mr->file, blk_num, &mr->b.p);
+ mr->b.block_num=blk_num;
+ dbg_assert(mr->b.b != NULL);
+ mr->b.block_start=(unsigned char *)(mr->b.b);
+ mr->b.p_start=mr->b.p;
+ mr->b.end=mr->b.block_start+block_get_size(mr->b.b);
+ block_get_r(mr->b.b, &r);
+ block_rect_same(&r, &bt->r_curr);
+ }
+ }
+ if (coord != -1) {
+ bt->stack[bt->stackp]=bt->r_curr;
+ if (r_w > r_h) {
+ bt->r_curr.rl.x=coord;
+ bt->stack[bt->stackp].lu.x=coord+1;
+ } else {
+ bt->r_curr.lu.y=coord;
+ bt->stack[bt->stackp].rl.y=coord+1;
+ }
+ bt->stackp++;
+ dbg_assert(bt->stackp < BT_STACK_SIZE);
+ } else {
+ if (bt->stackp) {
+ bt->stackp--;
+ bt->r_curr=bt->stack[bt->stackp];
+ } else {
+ bt->r_curr=bt->r;
+ bt->order++;
+ if (bt->order > 100)
+ return 0;
+ }
+ }
+ if (mr->b.b) {
+ block_active_count++;
+ block_active_mem+=block_get_blocks(mr->b.b)*512;
+ return 1;
+ }
+ }
+ bt->p=NULL;
+ }
+ return 0;
}
diff --git a/navit/map/mg/map.c b/navit/map/mg/map.c
index 13561e154..50860e193 100644
--- a/navit/map/mg/map.c
+++ b/navit/map/mg/map.c
@@ -29,585 +29,562 @@
GList *maps;
static struct country_isonum {
- int country;
- int isonum;
- int postal_len;
- char *postal_prefix;
-} country_isonums[]={
- { 1,203},
- { 2,703},
- { 7,674},
- { 11,233},
- { 12,268},
- { 13,428},
- { 14,440},
- { 15,498},
- { 16,643},
- { 17,804},
- { 18,112},
- { 20,818},
- { 30,300},
- { 31,528},
- { 32, 56},
- { 33,250},
- { 34,724},
- { 36,348},
- { 39,380},
- { 40,642},
- { 41,756},
- { 43, 40},
- { 44,826},
- { 45,208},
- { 46,752},
- { 47,578},
- { 48,616},
- { 49,276,5,"D@@"},
- { 50,292},
- { 51,620},
- { 52,442},
- { 53,372},
- { 54,352},
- { 55, 8},
- { 56,470},
- { 57,196},
- { 58,246},
- { 59,100},
- { 61,422},
- { 62, 20},
- { 63,760},
- { 66,682},
- { 71,434},
- { 72,376},
- { 73,275},
- { 75,438},
- { 76,504},
- { 77, 12},
- { 78,788},
- { 81,688},
- { 83,400},
- { 85,191},
- { 86,705},
- { 87, 70},
- { 89,807},
- { 90,792},
- { 93,492},
- { 94, 31},
- { 95, 51},
- { 98,234},
- { 99,732},
- {336,774},
+ int country;
+ int isonum;
+ int postal_len;
+ char *postal_prefix;
+} country_isonums[]= {
+ { 1,203},
+ { 2,703},
+ { 7,674},
+ { 11,233},
+ { 12,268},
+ { 13,428},
+ { 14,440},
+ { 15,498},
+ { 16,643},
+ { 17,804},
+ { 18,112},
+ { 20,818},
+ { 30,300},
+ { 31,528},
+ { 32, 56},
+ { 33,250},
+ { 34,724},
+ { 36,348},
+ { 39,380},
+ { 40,642},
+ { 41,756},
+ { 43, 40},
+ { 44,826},
+ { 45,208},
+ { 46,752},
+ { 47,578},
+ { 48,616},
+ { 49,276,5,"D@@"},
+ { 50,292},
+ { 51,620},
+ { 52,442},
+ { 53,372},
+ { 54,352},
+ { 55, 8},
+ { 56,470},
+ { 57,196},
+ { 58,246},
+ { 59,100},
+ { 61,422},
+ { 62, 20},
+ { 63,760},
+ { 66,682},
+ { 71,434},
+ { 72,376},
+ { 73,275},
+ { 75,438},
+ { 76,504},
+ { 77, 12},
+ { 78,788},
+ { 81,688},
+ { 83,400},
+ { 85,191},
+ { 86,705},
+ { 87, 70},
+ { 89,807},
+ { 90,792},
+ { 93,492},
+ { 94, 31},
+ { 95, 51},
+ { 98,234},
+ { 99,732},
+ {336,774},
};
struct map_priv * map_new_mg(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl);
static int map_id;
-static char *file[]={
- [file_border_ply]="border.ply",
- [file_bridge_ply]="bridge.ply",
- [file_build_ply]="build.ply",
- [file_golf_ply]="golf.ply",
- [file_height_ply]="height.ply",
- [file_natpark_ply]="natpark.ply",
- [file_nature_ply]="nature.ply",
- [file_other_ply]="other.ply",
- [file_rail_ply]="rail.ply",
- [file_sea_ply]="sea.ply",
- [file_street_bti]="street.bti",
- [file_street_str]="street.str",
- [file_strname_stn]="strname.stn",
- [file_town_twn]="town.twn",
- [file_tunnel_ply]="tunnel.ply",
- [file_water_ply]="water.ply",
- [file_woodland_ply]="woodland.ply",
+static char *file[]= {
+ [file_border_ply]="border.ply",
+ [file_bridge_ply]="bridge.ply",
+ [file_build_ply]="build.ply",
+ [file_golf_ply]="golf.ply",
+ [file_height_ply]="height.ply",
+ [file_natpark_ply]="natpark.ply",
+ [file_nature_ply]="nature.ply",
+ [file_other_ply]="other.ply",
+ [file_rail_ply]="rail.ply",
+ [file_sea_ply]="sea.ply",
+ [file_street_bti]="street.bti",
+ [file_street_str]="street.str",
+ [file_strname_stn]="strname.stn",
+ [file_town_twn]="town.twn",
+ [file_tunnel_ply]="tunnel.ply",
+ [file_water_ply]="water.ply",
+ [file_woodland_ply]="woodland.ply",
};
-int mg_country_from_isonum(int isonum)
-{
- int i;
- for (i = 0 ; i < sizeof(country_isonums)/sizeof(struct country_isonum) ; i++)
- if (country_isonums[i].isonum == isonum)
- return country_isonums[i].country;
- return 0;
+int mg_country_from_isonum(int isonum) {
+ int i;
+ for (i = 0 ; i < sizeof(country_isonums)/sizeof(struct country_isonum) ; i++)
+ if (country_isonums[i].isonum == isonum)
+ return country_isonums[i].country;
+ return 0;
}
-int mg_country_to_isonum(int country)
-{
- int i;
- for (i = 0 ; i < sizeof(country_isonums)/sizeof(struct country_isonum) ; i++)
- if (country_isonums[i].country == country)
- return country_isonums[i].isonum;
- return 0;
+int mg_country_to_isonum(int country) {
+ int i;
+ for (i = 0 ; i < sizeof(country_isonums)/sizeof(struct country_isonum) ; i++)
+ if (country_isonums[i].country == country)
+ return country_isonums[i].isonum;
+ return 0;
}
-int mg_country_postal_len(int country)
-{
- int i;
- for (i = 0 ; i < sizeof(country_isonums)/sizeof(struct country_isonum) ; i++)
- if (country_isonums[i].country == country)
- return country_isonums[i].postal_len;
- return 0;
+int mg_country_postal_len(int country) {
+ int i;
+ for (i = 0 ; i < sizeof(country_isonums)/sizeof(struct country_isonum) ; i++)
+ if (country_isonums[i].country == country)
+ return country_isonums[i].postal_len;
+ return 0;
}
-static char *mg_country_postal_prefix(int isonum)
-{
- int i;
- for (i = 0 ; i < sizeof(country_isonums)/sizeof(struct country_isonum) ; i++)
- if (country_isonums[i].isonum == isonum)
- return country_isonums[i].postal_prefix;
- return NULL;
+static char *mg_country_postal_prefix(int isonum) {
+ int i;
+ for (i = 0 ; i < sizeof(country_isonums)/sizeof(struct country_isonum) ; i++)
+ if (country_isonums[i].isonum == isonum)
+ return country_isonums[i].postal_prefix;
+ return NULL;
}
-struct item_range town_ranges[]={
- {type_town_label,type_port_label},
+struct item_range town_ranges[]= {
+ {type_town_label,type_port_label},
};
-struct item_range street_ranges[]={
- {type_street_nopass,type_street_unkn},
+struct item_range street_ranges[]= {
+ {type_street_nopass,type_street_unkn},
};
-struct item_range poly_ranges[]={
- {type_border_country,type_water_line},
- {type_street_unkn,type_street_unkn},
- {type_area,type_last},
+struct item_range poly_ranges[]= {
+ {type_border_country,type_water_line},
+ {type_street_unkn,type_street_unkn},
+ {type_area,type_last},
};
-static int
-file_next(struct map_rect_priv *mr)
-{
- int debug=0;
-
- for (;;) {
- mr->current_file++;
- if (mr->current_file >= file_end)
- return 0;
- mr->file=mr->m->file[mr->current_file];
- if (! mr->file)
- continue;
- switch (mr->current_file) {
- case file_strname_stn:
- continue;
- case file_town_twn:
- if (mr->cur_sel && !map_selection_contains_item_range(mr->cur_sel, 0, town_ranges, sizeof(town_ranges)/sizeof(struct item_range)))
- continue;
- break;
- case file_street_str:
- if (mr->cur_sel && !map_selection_contains_item_range(mr->cur_sel, 0, street_ranges, sizeof(street_ranges)/sizeof(struct item_range)))
- continue;
- break;
- default:
- if (mr->cur_sel && !map_selection_contains_item_range(mr->cur_sel, 0, poly_ranges, sizeof(poly_ranges)/sizeof(struct item_range)))
- continue;
- break;
- }
- if (debug)
- printf("current file: '%s'\n", file[mr->current_file]);
- mr->cur_sel=mr->xsel;
- if (block_init(mr))
- return 1;
- }
+static int file_next(struct map_rect_priv *mr) {
+ int debug=0;
+
+ for (;;) {
+ mr->current_file++;
+ if (mr->current_file >= file_end)
+ return 0;
+ mr->file=mr->m->file[mr->current_file];
+ if (! mr->file)
+ continue;
+ switch (mr->current_file) {
+ case file_strname_stn:
+ continue;
+ case file_town_twn:
+ if (mr->cur_sel
+ && !map_selection_contains_item_range(mr->cur_sel, 0, town_ranges, sizeof(town_ranges)/sizeof(struct item_range)))
+ continue;
+ break;
+ case file_street_str:
+ if (mr->cur_sel
+ && !map_selection_contains_item_range(mr->cur_sel, 0, street_ranges, sizeof(street_ranges)/sizeof(struct item_range)))
+ continue;
+ break;
+ default:
+ if (mr->cur_sel
+ && !map_selection_contains_item_range(mr->cur_sel, 0, poly_ranges, sizeof(poly_ranges)/sizeof(struct item_range)))
+ continue;
+ break;
+ }
+ if (debug)
+ printf("current file: '%s'\n", file[mr->current_file]);
+ mr->cur_sel=mr->xsel;
+ if (block_init(mr))
+ return 1;
+ }
}
-static void
-map_destroy_mg(struct map_priv *m)
-{
- int i;
+static void map_destroy_mg(struct map_priv *m) {
+ int i;
- printf("mg_map_destroy\n");
- for (i = 0 ; i < file_end ; i++) {
- if (m->file[i])
- file_destroy(m->file[i]);
- }
+ printf("mg_map_destroy\n");
+ for (i = 0 ; i < file_end ; i++) {
+ if (m->file[i])
+ file_destroy(m->file[i]);
+ }
}
extern int block_lin_count,block_idx_count,block_active_count,block_mem,block_active_mem;
struct map_rect_priv *
-map_rect_new_mg(struct map_priv *map, struct map_selection *sel)
-{
- struct map_rect_priv *mr;
- int i;
-
- block_lin_count=0;
- block_idx_count=0;
- block_active_count=0;
- block_mem=0;
- block_active_mem=0;
- mr=g_new0(struct map_rect_priv, 1);
- mr->m=map;
- mr->xsel=sel;
- mr->current_file=-1;
- if (sel && sel->next)
- for (i=0 ; i < file_end ; i++)
- mr->block_hash[i]=g_hash_table_new(g_int_hash,g_int_equal);
- file_next(mr);
- return mr;
+map_rect_new_mg(struct map_priv *map, struct map_selection *sel) {
+ struct map_rect_priv *mr;
+ int i;
+
+ block_lin_count=0;
+ block_idx_count=0;
+ block_active_count=0;
+ block_mem=0;
+ block_active_mem=0;
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->m=map;
+ mr->xsel=sel;
+ mr->current_file=-1;
+ if (sel && sel->next)
+ for (i=0 ; i < file_end ; i++)
+ mr->block_hash[i]=g_hash_table_new(g_int_hash,g_int_equal);
+ file_next(mr);
+ return mr;
}
-static struct item *
-map_rect_get_item_mg(struct map_rect_priv *mr)
-{
- for (;;) {
- switch (mr->current_file) {
- case file_town_twn:
- if (town_get(mr, &mr->town, &mr->item))
- return &mr->item;
- break;
- case file_border_ply:
- case file_bridge_ply:
- case file_build_ply:
- case file_golf_ply:
- /* case file_height_ply: */
- case file_natpark_ply:
- case file_nature_ply:
- case file_other_ply:
- case file_rail_ply:
- case file_sea_ply:
- /* case file_tunnel_ply: */
- case file_water_ply:
- case file_woodland_ply:
- if (poly_get(mr, &mr->poly, &mr->item))
- return &mr->item;
- break;
- case file_street_str:
- if (street_get(mr, &mr->street, &mr->item))
- return &mr->item;
- break;
- case file_end:
- return NULL;
- default:
- break;
- }
- if (block_next(mr))
- continue;
- if (mr->cur_sel->next) {
- mr->cur_sel=mr->cur_sel->next;
- if (block_init(mr))
- continue;
- }
- if (file_next(mr))
- continue;
- dbg(lvl_debug,"lin_count %d idx_count %d active_count %d %d kB (%d kB)\n", block_lin_count, block_idx_count, block_active_count, (block_mem+block_active_mem)/1024, block_active_mem/1024);
- return NULL;
- }
+static struct item *map_rect_get_item_mg(struct map_rect_priv *mr) {
+ for (;;) {
+ switch (mr->current_file) {
+ case file_town_twn:
+ if (town_get(mr, &mr->town, &mr->item))
+ return &mr->item;
+ break;
+ case file_border_ply:
+ case file_bridge_ply:
+ case file_build_ply:
+ case file_golf_ply:
+ /* case file_height_ply: */
+ case file_natpark_ply:
+ case file_nature_ply:
+ case file_other_ply:
+ case file_rail_ply:
+ case file_sea_ply:
+ /* case file_tunnel_ply: */
+ case file_water_ply:
+ case file_woodland_ply:
+ if (poly_get(mr, &mr->poly, &mr->item))
+ return &mr->item;
+ break;
+ case file_street_str:
+ if (street_get(mr, &mr->street, &mr->item))
+ return &mr->item;
+ break;
+ case file_end:
+ return NULL;
+ default:
+ break;
+ }
+ if (block_next(mr))
+ continue;
+ if (mr->cur_sel->next) {
+ mr->cur_sel=mr->cur_sel->next;
+ if (block_init(mr))
+ continue;
+ }
+ if (file_next(mr))
+ continue;
+ dbg(lvl_debug,"lin_count %d idx_count %d active_count %d %d kB (%d kB)", block_lin_count, block_idx_count,
+ block_active_count, (block_mem+block_active_mem)/1024, block_active_mem/1024);
+ return NULL;
+ }
}
struct item *
-map_rect_get_item_byid_mg(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- mr->current_file = (id_hi >> 16) & 0xff;
- switch (mr->current_file) {
- case file_town_twn:
- if (town_get_byid(mr, &mr->town, id_hi, id_lo, &mr->item))
- return &mr->item;
- break;
- case file_street_str:
- if (street_get_byid(mr, &mr->street, id_hi, id_lo, &mr->item))
- return &mr->item;
- break;
- case file_strname_stn:
- if (street_name_get_byid(mr, &mr->street, id_hi, id_lo, &mr->item))
- return &mr->item;
- break;
- default:
- if (poly_get_byid(mr, &mr->poly, id_hi, id_lo, &mr->item))
- return &mr->item;
- break;
- }
- return NULL;
+map_rect_get_item_byid_mg(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ mr->current_file = (id_hi >> 16) & 0xff;
+ switch (mr->current_file) {
+ case file_town_twn:
+ if (town_get_byid(mr, &mr->town, id_hi, id_lo, &mr->item))
+ return &mr->item;
+ break;
+ case file_street_str:
+ if (street_get_byid(mr, &mr->street, id_hi, id_lo, &mr->item))
+ return &mr->item;
+ break;
+ case file_strname_stn:
+ if (street_name_get_byid(mr, &mr->street, id_hi, id_lo, &mr->item))
+ return &mr->item;
+ break;
+ default:
+ if (poly_get_byid(mr, &mr->poly, id_hi, id_lo, &mr->item))
+ return &mr->item;
+ break;
+ }
+ return NULL;
}
-void
-map_rect_destroy_mg(struct map_rect_priv *mr)
-{
- int i;
- for (i=0 ; i < file_end ; i++)
- if (mr->block_hash[i])
- g_hash_table_destroy(mr->block_hash[i]);
- g_free(mr);
+void map_rect_destroy_mg(struct map_rect_priv *mr) {
+ int i;
+ for (i=0 ; i < file_end ; i++)
+ if (mr->block_hash[i])
+ g_hash_table_destroy(mr->block_hash[i]);
+ g_free(mr);
}
-static char *
-map_search_mg_convert_special(char *str)
-{
- char *ret,*c=g_malloc(strlen(str)*2+1);
-
- ret=c;
- for (;;) {
- switch ((unsigned char)(*str)) {
- case 0xc4:
- *c++='A';
- break;
- case 0xd6:
- *c++='O';
- break;
- case 0xdc:
- *c++='U';
- break;
- case 0xdf:
- *c++='s';
- *c++='s';
- break;
- case 0xe4:
- *c++='a';
- break;
- case 0xf6:
- *c++='o';
- break;
- case 0xfc:
- *c++='u';
- break;
- default:
- dbg(lvl_debug,"0x%x\n", *str);
- *c++=*str;
- break;
- }
- if (! *str)
- return ret;
- str++;
- }
+static char *map_search_mg_convert_special(char *str) {
+ char *ret,*c=g_malloc(strlen(str)*2+1);
+
+ ret=c;
+ for (;;) {
+ switch ((unsigned char)(*str)) {
+ case 0xc4:
+ *c++='A';
+ break;
+ case 0xd6:
+ *c++='O';
+ break;
+ case 0xdc:
+ *c++='U';
+ break;
+ case 0xdf:
+ *c++='s';
+ *c++='s';
+ break;
+ case 0xe4:
+ *c++='a';
+ break;
+ case 0xf6:
+ *c++='o';
+ break;
+ case 0xfc:
+ *c++='u';
+ break;
+ default:
+ dbg(lvl_debug,"0x%x", *str);
+ *c++=*str;
+ break;
+ }
+ if (! *str)
+ return ret;
+ str++;
+ }
}
-static int
-map_search_setup(struct map_rect_priv *mr)
-{
- char *prefix;
- dbg(lvl_debug,"%s\n", attr_to_name(mr->search_type));
- switch (mr->search_type) {
- case attr_town_postal:
- if (mr->search_item.type != type_country_label) {
- dbg(lvl_error,"wrong parent type %s\n", item_to_name(mr->search_item.type));
- return 0;
- }
- prefix=mg_country_postal_prefix(mr->search_item.id_lo);
- if (! prefix)
- return 0;
- tree_search_init(mr->m->dirname, "town.b1", &mr->ts, 0);
- mr->current_file=file_town_twn;
- mr->search_str=g_strdup_printf("%s%s",prefix,mr->search_attr->u.str);
- dbg(lvl_debug,"search_str='%s'\n",mr->search_str);
- mr->search_country=mg_country_from_isonum(mr->search_item.id_lo);
- break;
- case attr_town_name:
- if (mr->search_item.type != type_country_label) {
- dbg(lvl_error,"wrong parent type %s\n", item_to_name(mr->search_item.type));
- return 0;
- }
- tree_search_init(mr->m->dirname, "town.b2", &mr->ts, 0x1000);
- mr->current_file=file_town_twn;
- mr->search_str=map_search_mg_convert_special(mr->search_attr->u.str);
- mr->search_country=mg_country_from_isonum(mr->search_item.id_lo);
- break;
- case attr_district_name:
- if (mr->search_item.type != type_country_label) {
- dbg(lvl_error,"wrong parent type %s\n", item_to_name(mr->search_item.type));
- return 0;
- }
- tree_search_init(mr->m->dirname, "town.b3", &mr->ts, 0x1000);
- mr->current_file=file_town_twn;
- mr->search_str=map_search_mg_convert_special(mr->search_attr->u.str);
- mr->search_country=mg_country_from_isonum(mr->search_item.id_lo);
- break;
- case attr_street_name:
- if (mr->search_item.type != type_town_streets) {
- GList *tmp=maps;
- struct item *item=NULL;
- struct attr attr;
- struct map_rect_priv *mr2;
- while (tmp) {
- mr2=map_rect_new_mg(tmp->data, NULL);
- item=map_rect_get_item_byid_mg(mr2, mr->search_item.id_hi, mr->search_item.id_lo);
- if (item)
- break;
- map_rect_destroy_mg(mr2);
- tmp=g_list_next(tmp);
- }
- if (item) {
- if (item_attr_get(item, attr_town_streets_item, &attr)) {
- mr->search_item=*attr.u.item;
- map_rect_destroy_mg(mr2);
- } else {
- map_rect_destroy_mg(mr2);
- return 0;
- }
- } else {
- dbg(lvl_error,"wrong parent type %s %p 0x%x 0x%x\n", item_to_name(mr->search_item.type), item, mr->search_item.id_hi, mr->search_item.id_lo);
- return 0;
- }
- }
- dbg(lvl_debug,"street_assoc=0x%x\n", mr->search_item.id_lo);
- tree_search_init(mr->m->dirname, "strname.b1", &mr->ts, 0);
- mr->current_file=file_strname_stn;
- mr->search_str=g_strdup(mr->search_attr->u.str);
- break;
- case attr_house_number:
- if (!map_priv_is(mr->search_item.map, mr->m))
- return 0;
- if (!housenumber_search_setup(mr)) {
- dbg(lvl_error,"failed to search for attr_house_number\n");
- return 0;
- }
- break;
- default:
- dbg(lvl_error,"unknown search %s\n",attr_to_name(mr->search_type));
- return 0;
- }
- mr->file=mr->m->file[mr->current_file];
- block_init(mr);
- return 1;
+static int map_search_setup(struct map_rect_priv *mr) {
+ char *prefix;
+ dbg(lvl_debug,"%s", attr_to_name(mr->search_type));
+ switch (mr->search_type) {
+ case attr_town_postal:
+ if (mr->search_item.type != type_country_label) {
+ dbg(lvl_error,"wrong parent type %s", item_to_name(mr->search_item.type));
+ return 0;
+ }
+ prefix=mg_country_postal_prefix(mr->search_item.id_lo);
+ if (! prefix)
+ return 0;
+ tree_search_init(mr->m->dirname, "town.b1", &mr->ts, 0);
+ mr->current_file=file_town_twn;
+ mr->search_str=g_strdup_printf("%s%s",prefix,mr->search_attr->u.str);
+ dbg(lvl_debug,"search_str='%s'",mr->search_str);
+ mr->search_country=mg_country_from_isonum(mr->search_item.id_lo);
+ break;
+ case attr_town_name:
+ if (mr->search_item.type != type_country_label) {
+ dbg(lvl_error,"wrong parent type %s", item_to_name(mr->search_item.type));
+ return 0;
+ }
+ tree_search_init(mr->m->dirname, "town.b2", &mr->ts, 0x1000);
+ mr->current_file=file_town_twn;
+ mr->search_str=map_search_mg_convert_special(mr->search_attr->u.str);
+ mr->search_country=mg_country_from_isonum(mr->search_item.id_lo);
+ break;
+ case attr_district_name:
+ if (mr->search_item.type != type_country_label) {
+ dbg(lvl_error,"wrong parent type %s", item_to_name(mr->search_item.type));
+ return 0;
+ }
+ tree_search_init(mr->m->dirname, "town.b3", &mr->ts, 0x1000);
+ mr->current_file=file_town_twn;
+ mr->search_str=map_search_mg_convert_special(mr->search_attr->u.str);
+ mr->search_country=mg_country_from_isonum(mr->search_item.id_lo);
+ break;
+ case attr_street_name:
+ if (mr->search_item.type != type_town_streets) {
+ GList *tmp=maps;
+ struct item *item=NULL;
+ struct attr attr;
+ struct map_rect_priv *mr2;
+ while (tmp) {
+ mr2=map_rect_new_mg(tmp->data, NULL);
+ item=map_rect_get_item_byid_mg(mr2, mr->search_item.id_hi, mr->search_item.id_lo);
+ if (item)
+ break;
+ map_rect_destroy_mg(mr2);
+ tmp=g_list_next(tmp);
+ }
+ if (item) {
+ if (item_attr_get(item, attr_town_streets_item, &attr)) {
+ mr->search_item=*attr.u.item;
+ map_rect_destroy_mg(mr2);
+ } else {
+ map_rect_destroy_mg(mr2);
+ return 0;
+ }
+ } else {
+ dbg(lvl_error,"wrong parent type %s %p 0x%x 0x%x", item_to_name(mr->search_item.type), item, mr->search_item.id_hi,
+ mr->search_item.id_lo);
+ return 0;
+ }
+ }
+ dbg(lvl_debug,"street_assoc=0x%x", mr->search_item.id_lo);
+ tree_search_init(mr->m->dirname, "strname.b1", &mr->ts, 0);
+ mr->current_file=file_strname_stn;
+ mr->search_str=g_strdup(mr->search_attr->u.str);
+ break;
+ case attr_house_number:
+ if (!map_priv_is(mr->search_item.map, mr->m))
+ return 0;
+ if (!housenumber_search_setup(mr)) {
+ dbg(lvl_error,"failed to search for attr_house_number");
+ return 0;
+ }
+ break;
+ default:
+ dbg(lvl_error,"unknown search %s",attr_to_name(mr->search_type));
+ return 0;
+ }
+ mr->file=mr->m->file[mr->current_file];
+ block_init(mr);
+ return 1;
}
static void map_search_cleanup(struct map_rect_priv *mr);
static struct item * map_search_get_item_mg(struct map_search_priv *ms);
-static struct map_search_priv *
-map_search_new_mg(struct map_priv *map, struct item *item, struct attr *search, int partial)
-{
- struct map_rect_priv *mr=g_new0(struct map_rect_priv, 1);
- dbg(lvl_debug,"searching for %s '%s'\n", attr_to_name(search->type), search->u.str);
- dbg(lvl_debug,"id_lo=0x%x\n", item->id_lo);
- dbg(lvl_debug,"search=%s\n", search->u.str);
- mr->m=map;
- mr->search_attr=attr_dup(search);
- mr->search_type=search->type;
- mr->search_item=*item;
- mr->search_partial=partial;
- if (search->type == attr_town_or_district_name) {
- mr->search_type=attr_town_name;
- mr->search_type_next=attr_district_name;
- }
- if (!map_search_setup(mr)) {
- dbg(lvl_warning,"map_search_new_mg failed\n");
- g_free(mr);
- return NULL;
- }
- mr->search_mr_tmp=map_rect_new_mg(map, NULL);
-
- return (struct map_search_priv *)mr;
+static struct map_search_priv *map_search_new_mg(struct map_priv *map, struct item *item, struct attr *search,
+ int partial) {
+ struct map_rect_priv *mr=g_new0(struct map_rect_priv, 1);
+ dbg(lvl_debug,"searching for %s '%s'", attr_to_name(search->type), search->u.str);
+ dbg(lvl_debug,"id_lo=0x%x", item->id_lo);
+ dbg(lvl_debug,"search=%s", search->u.str);
+ mr->m=map;
+ mr->search_attr=attr_dup(search);
+ mr->search_type=search->type;
+ mr->search_item=*item;
+ mr->search_partial=partial;
+ if (search->type == attr_town_or_district_name) {
+ mr->search_type=attr_town_name;
+ mr->search_type_next=attr_district_name;
+ }
+ if (!map_search_setup(mr)) {
+ dbg(lvl_warning,"map_search_new_mg failed");
+ g_free(mr);
+ return NULL;
+ }
+ mr->search_mr_tmp=map_rect_new_mg(map, NULL);
+
+ return (struct map_search_priv *)mr;
}
-static void
-map_search_cleanup(struct map_rect_priv *mr)
-{
- g_free(mr->search_str);
- mr->search_str=NULL;
- tree_search_free(&mr->ts);
- mr->search_linear=0;
- mr->search_p=NULL;
- mr->search_blk_count=0;
- mr->search_blk_off=NULL;
- mr->search_block=0;
+static void map_search_cleanup(struct map_rect_priv *mr) {
+ g_free(mr->search_str);
+ mr->search_str=NULL;
+ tree_search_free(&mr->ts);
+ mr->search_linear=0;
+ mr->search_p=NULL;
+ mr->search_blk_count=0;
+ mr->search_blk_off=NULL;
+ mr->search_block=0;
}
-static void
-map_search_destroy_mg(struct map_search_priv *ms)
-{
- struct map_rect_priv *mr=(struct map_rect_priv *)ms;
-
- dbg(lvl_debug,"mr=%p\n", mr);
- if (! mr)
- return;
- map_search_cleanup(mr);
- if (mr->search_mr_tmp)
- map_rect_destroy_mg(mr->search_mr_tmp);
- attr_free(mr->search_attr);
- g_free(mr);
+static void map_search_destroy_mg(struct map_search_priv *ms) {
+ struct map_rect_priv *mr=(struct map_rect_priv *)ms;
+
+ dbg(lvl_debug,"mr=%p", mr);
+ if (! mr)
+ return;
+ map_search_cleanup(mr);
+ if (mr->search_mr_tmp)
+ map_rect_destroy_mg(mr->search_mr_tmp);
+ attr_free(mr->search_attr);
+ g_free(mr);
}
-static struct item *
-map_search_get_item_mg(struct map_search_priv *ms)
-{
- struct map_rect_priv *mr=(struct map_rect_priv *)ms;
- struct item *ret=NULL;
-
- if (! mr)
- return NULL;
- switch (mr->search_type) {
- case attr_town_postal:
- case attr_town_name:
- case attr_district_name:
- ret=town_search_get_item(mr);
- break;
- case attr_street_name:
- ret=street_search_get_item(mr);
- break;
- case attr_house_number:
- ret=housenumber_search_get_item(mr);
- break;
- default:
- dbg(lvl_error,"unknown search %s\n",attr_to_name(mr->search_type));
- break;
- }
- if (!ret && mr->search_type_next != attr_none) {
- mr->search_type=mr->search_type_next;
- mr->search_type_next=attr_none;
- map_search_cleanup(mr);
- map_search_setup(mr);
- return map_search_get_item_mg(ms);
- }
- return ret;
+static struct item *map_search_get_item_mg(struct map_search_priv *ms) {
+ struct map_rect_priv *mr=(struct map_rect_priv *)ms;
+ struct item *ret=NULL;
+
+ if (! mr)
+ return NULL;
+ switch (mr->search_type) {
+ case attr_town_postal:
+ case attr_town_name:
+ case attr_district_name:
+ ret=town_search_get_item(mr);
+ break;
+ case attr_street_name:
+ ret=street_search_get_item(mr);
+ break;
+ case attr_house_number:
+ ret=housenumber_search_get_item(mr);
+ break;
+ default:
+ dbg(lvl_error,"unknown search %s",attr_to_name(mr->search_type));
+ break;
+ }
+ if (!ret && mr->search_type_next != attr_none) {
+ mr->search_type=mr->search_type_next;
+ mr->search_type_next=attr_none;
+ map_search_cleanup(mr);
+ map_search_setup(mr);
+ return map_search_get_item_mg(ms);
+ }
+ return ret;
}
static struct map_methods map_methods_mg = {
- projection_mg,
- "iso8859-1",
- map_destroy_mg,
- map_rect_new_mg,
- map_rect_destroy_mg,
- map_rect_get_item_mg,
- map_rect_get_item_byid_mg,
- map_search_new_mg,
- map_search_destroy_mg,
- map_search_get_item_mg,
+ projection_mg,
+ "iso8859-1",
+ map_destroy_mg,
+ map_rect_new_mg,
+ map_rect_destroy_mg,
+ map_rect_get_item_mg,
+ map_rect_get_item_byid_mg,
+ map_search_new_mg,
+ map_search_destroy_mg,
+ map_search_get_item_mg,
};
struct map_priv *
-map_new_mg(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct map_priv *m;
- int i,maybe_missing;
- struct attr *data=attr_search(attrs, NULL, attr_data);
- char *filename;
- struct file_wordexp *wexp;
- char **wexp_data;
-
- if (! data)
- return NULL;
-
- wexp=file_wordexp_new(data->u.str);
- wexp_data=file_wordexp_get_array(wexp);
-
- *meth=map_methods_mg;
- data=attr_search(attrs, NULL, attr_data);
-
- m=g_new(struct map_priv, 1);
- m->id=++map_id;
- m->dirname=g_strdup(wexp_data[0]);
- file_wordexp_destroy(wexp);
- for (i = 0 ; i < file_end ; i++) {
- if (file[i]) {
- filename=g_strdup_printf("%s/%s", m->dirname, file[i]);
- m->file[i]=file_create_caseinsensitive(filename, 0);
- if (! m->file[i]) {
- maybe_missing=(i == file_border_ply || i == file_height_ply || i == file_sea_ply);
- if (! maybe_missing)
- dbg(lvl_error,"Failed to load %s\n", filename);
- } else
- file_mmap(m->file[i]);
- g_free(filename);
- }
- }
- maps=g_list_append(maps, m);
-
- return m;
+map_new_mg(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *m;
+ int i,maybe_missing;
+ struct attr *data=attr_search(attrs, NULL, attr_data);
+ char *filename;
+ struct file_wordexp *wexp;
+ char **wexp_data;
+
+ if (! data)
+ return NULL;
+
+ wexp=file_wordexp_new(data->u.str);
+ wexp_data=file_wordexp_get_array(wexp);
+
+ *meth=map_methods_mg;
+ data=attr_search(attrs, NULL, attr_data);
+
+ m=g_new(struct map_priv, 1);
+ m->id=++map_id;
+ m->dirname=g_strdup(wexp_data[0]);
+ file_wordexp_destroy(wexp);
+ for (i = 0 ; i < file_end ; i++) {
+ if (file[i]) {
+ filename=g_strdup_printf("%s/%s", m->dirname, file[i]);
+ m->file[i]=file_create_caseinsensitive(filename, 0);
+ if (! m->file[i]) {
+ maybe_missing=(i == file_border_ply || i == file_height_ply || i == file_sea_ply);
+ if (! maybe_missing)
+ dbg(lvl_error,"Failed to load %s", filename);
+ } else
+ file_mmap(m->file[i]);
+ g_free(filename);
+ }
+ }
+ maps=g_list_append(maps, m);
+
+ return m;
}
-void
-plugin_init(void)
-{
- plugin_register_category_map("mg", map_new_mg);
+void plugin_init(void) {
+ plugin_register_category_map("mg", map_new_mg);
}
diff --git a/navit/map/mg/poly.c b/navit/map/mg/poly.c
index 7c73d4587..2c42d9740 100644
--- a/navit/map/mg/poly.c
+++ b/navit/map/mg/poly.c
@@ -21,245 +21,232 @@
#include "debug.h"
#include "mg.h"
-static void
-poly_coord_rewind(void *priv_data)
-{
- struct poly_priv *poly=priv_data;
+static void poly_coord_rewind(void *priv_data) {
+ struct poly_priv *poly=priv_data;
- poly->p=poly->subpoly_start;
+ poly->p=poly->subpoly_start;
}
-static int
-poly_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct poly_priv *poly=priv_data;
- int ret=0;
-
- while (count--) {
- if (poly->p >= poly->subpoly_next)
- break;
- c->x=get_u32_unal(&poly->p);
- c->y=get_u32_unal(&poly->p);
- c++;
- ret++;
- }
- return ret;
+static int poly_coord_get(void *priv_data, struct coord *c, int count) {
+ struct poly_priv *poly=priv_data;
+ int ret=0;
+
+ while (count--) {
+ if (poly->p >= poly->subpoly_next)
+ break;
+ c->x=get_u32_unal(&poly->p);
+ c->y=get_u32_unal(&poly->p);
+ c++;
+ ret++;
+ }
+ return ret;
}
-static void
-poly_attr_rewind(void *priv_data)
-{
- struct poly_priv *poly=priv_data;
+static void poly_attr_rewind(void *priv_data) {
+ struct poly_priv *poly=priv_data;
- poly->aidx=0;
+ poly->aidx=0;
}
-static int
-poly_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct poly_priv *poly=priv_data;
+static int poly_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct poly_priv *poly=priv_data;
- attr->type=attr_type;
- switch (attr_type) {
- case attr_any:
- while (poly->attr_next != attr_none) {
- if (poly_attr_get(poly, poly->attr_next, attr))
- return 1;
- }
- return 0;
- case attr_label:
- attr->u.str=poly->name;
- poly->attr_next=attr_none;
- if (attr->u.str[0])
- return 1;
- return 0;
- default:
- return 0;
- }
- return 1;
+ attr->type=attr_type;
+ switch (attr_type) {
+ case attr_any:
+ while (poly->attr_next != attr_none) {
+ if (poly_attr_get(poly, poly->attr_next, attr))
+ return 1;
+ }
+ return 0;
+ case attr_label:
+ attr->u.str=poly->name;
+ poly->attr_next=attr_none;
+ if (attr->u.str[0])
+ return 1;
+ return 0;
+ default:
+ return 0;
+ }
+ return 1;
}
static struct item_methods poly_meth = {
- poly_coord_rewind,
- poly_coord_get,
- poly_attr_rewind,
- poly_attr_get,
+ poly_coord_rewind,
+ poly_coord_get,
+ poly_attr_rewind,
+ poly_attr_get,
};
-static void
-poly_get_data(struct poly_priv *poly, unsigned char **p)
-{
- poly->c[0].x=get_u32_unal(p);
- poly->c[0].y=get_u32_unal(p);
- poly->c[1].x=get_u32_unal(p);
- poly->c[1].y=get_u32_unal(p);
- *p+=sizeof(struct coord);
- poly->name=(char *)(*p);
- while (**p) {
- (*p)++;
- }
- (*p)++;
- poly->order=*(*p)++;
- poly->type=*(*p)++;
- poly->polys=get_u32_unal(p);
- poly->count=(unsigned int *)(*p); (*p)+=poly->polys*sizeof(unsigned int);
- poly->count_sum=get_u32_unal(p);
+static void poly_get_data(struct poly_priv *poly, unsigned char **p) {
+ poly->c[0].x=get_u32_unal(p);
+ poly->c[0].y=get_u32_unal(p);
+ poly->c[1].x=get_u32_unal(p);
+ poly->c[1].y=get_u32_unal(p);
+ *p+=sizeof(struct coord);
+ poly->name=(char *)(*p);
+ while (**p) {
+ (*p)++;
+ }
+ (*p)++;
+ poly->order=*(*p)++;
+ poly->type=*(*p)++;
+ poly->polys=get_u32_unal(p);
+ poly->count=(unsigned int *)(*p);
+ (*p)+=poly->polys*sizeof(unsigned int);
+ poly->count_sum=get_u32_unal(p);
}
-int
-poly_get(struct map_rect_priv *mr, struct poly_priv *poly, struct item *item)
-{
- struct coord_rect r;
-
- for (;;) {
- if (mr->b.p >= mr->b.end)
- return 0;
- if (mr->b.p == mr->b.p_start) {
- poly->poly_num=0;
- poly->subpoly_num=0;
- poly->subpoly_num_all=0;
- poly->poly_next=mr->b.p;
- item->meth=&poly_meth;
- }
- if (poly->poly_num >= block_get_count(mr->b.b))
- return 0;
- if (!poly->subpoly_num) {
- mr->b.p=poly->poly_next;
- item->id_lo=mr->b.p-mr->file->begin;
- poly_get_data(poly, &mr->b.p);
- poly->poly_next=mr->b.p+poly->count_sum*sizeof(struct coord);
- poly->poly_num++;
- r.lu=poly->c[0];
- r.rl=poly->c[1];
- if (mr->cur_sel && (poly->order > mr->cur_sel->order*3 || !coord_rect_overlap(&mr->cur_sel->u.c_rect, &r))) {
- poly->subpoly_num_all+=poly->polys;
- mr->b.p=poly->poly_next;
- continue;
- }
- switch(poly->type) {
- case 0x13:
- item->type=type_poly_wood;
- break;
- case 0x14:
- item->type=type_poly_town;
- break;
- case 0x15:
- item->type=type_poly_cemetery;
- break;
- case 0x16:
- item->type=type_poly_building;
- break;
- case 0x17:
- item->type=type_poly_museum;
- break;
- case 0x19:
- item->type=type_poly_place;
- break;
- case 0x1b:
- item->type=type_poly_commercial_center;
- break;
- case 0x1e:
- item->type=type_poly_industry;
- break;
- case 0x23:
- /* FIXME: what is this ?*/
- item->type=type_poly_place;
- break;
- case 0x24:
- item->type=type_poly_car_parking;
- break;
- case 0x28:
- item->type=type_poly_airport;
- break;
- case 0x29:
- item->type=type_poly_station;
- break;
- case 0x2d:
- item->type=type_poly_hospital;
- break;
- case 0x2e:
- item->type=type_poly_hospital;
- break;
- case 0x2f:
- item->type=type_poly_university;
- break;
- case 0x30:
- item->type=type_poly_university;
- break;
- case 0x32:
- item->type=type_poly_park;
- break;
- case 0x34:
- item->type=type_poly_sport;
- break;
- case 0x35:
- item->type=type_poly_sport;
- break;
- case 0x37:
- item->type=type_poly_golf_course;
- break;
- case 0x38:
- item->type=type_poly_national_park;
- break;
- case 0x39:
- item->type=type_poly_nature_park;
- break;
- case 0x3c:
- item->type=type_poly_water;
- break;
- case 0xbc:
- item->type=type_water_line;
- break;
- case 0xc3:
- /* FIXME: what is this ?*/
- item->type=type_border_state;
- break;
- case 0xc6:
- item->type=type_border_country;
- break;
- case 0xc7:
- item->type=type_border_state;
- break;
- case 0xd0:
- item->type=type_rail;
- break;
- default:
- dbg(lvl_error,"Unknown poly type 0x%x '%s' 0x%x,0x%x\n", poly->type,poly->name,r.lu.x,r.lu.y);
- item->type=type_street_unkn;
- }
- if (!map_selection_contains_item(mr->cur_sel, 0, item->type)) {
- poly->subpoly_num_all+=poly->polys;
- mr->b.p=poly->poly_next;
- continue;
- }
- } else
- mr->b.p=poly->subpoly_next;
- dbg(lvl_debug,"%d %d %s\n", poly->subpoly_num_all, mr->b.block_num, poly->name);
- item->id_lo=poly->subpoly_num_all | (mr->b.block_num << 16);
- item->id_hi=(mr->current_file << 16);
- dbg(lvl_debug,"0x%x 0x%x\n", item->id_lo, item->id_hi);
- poly->subpoly_next=mr->b.p+L(poly->count[poly->subpoly_num])*sizeof(struct coord);
- poly->subpoly_num++;
- poly->subpoly_num_all++;
- if (poly->subpoly_num >= poly->polys)
- poly->subpoly_num=0;
- poly->subpoly_start=poly->p=mr->b.p;
- item->priv_data=poly;
- poly->attr_next=attr_label;
- return 1;
+int poly_get(struct map_rect_priv *mr, struct poly_priv *poly, struct item *item) {
+ struct coord_rect r;
+
+ for (;;) {
+ if (mr->b.p >= mr->b.end)
+ return 0;
+ if (mr->b.p == mr->b.p_start) {
+ poly->poly_num=0;
+ poly->subpoly_num=0;
+ poly->subpoly_num_all=0;
+ poly->poly_next=mr->b.p;
+ item->meth=&poly_meth;
}
+ if (poly->poly_num >= block_get_count(mr->b.b))
+ return 0;
+ if (!poly->subpoly_num) {
+ mr->b.p=poly->poly_next;
+ item->id_lo=mr->b.p-mr->file->begin;
+ poly_get_data(poly, &mr->b.p);
+ poly->poly_next=mr->b.p+poly->count_sum*sizeof(struct coord);
+ poly->poly_num++;
+ r.lu=poly->c[0];
+ r.rl=poly->c[1];
+ if (mr->cur_sel && (poly->order > mr->cur_sel->order*3 || !coord_rect_overlap(&mr->cur_sel->u.c_rect, &r))) {
+ poly->subpoly_num_all+=poly->polys;
+ mr->b.p=poly->poly_next;
+ continue;
+ }
+ switch(poly->type) {
+ case 0x13:
+ item->type=type_poly_wood;
+ break;
+ case 0x14:
+ item->type=type_poly_town;
+ break;
+ case 0x15:
+ item->type=type_poly_cemetery;
+ break;
+ case 0x16:
+ item->type=type_poly_building;
+ break;
+ case 0x17:
+ item->type=type_poly_museum;
+ break;
+ case 0x19:
+ item->type=type_poly_place;
+ break;
+ case 0x1b:
+ item->type=type_poly_commercial_center;
+ break;
+ case 0x1e:
+ item->type=type_poly_industry;
+ break;
+ case 0x23:
+ /* FIXME: what is this ?*/
+ item->type=type_poly_place;
+ break;
+ case 0x24:
+ item->type=type_poly_car_parking;
+ break;
+ case 0x28:
+ item->type=type_poly_airport;
+ break;
+ case 0x29:
+ item->type=type_poly_station;
+ break;
+ case 0x2d:
+ item->type=type_poly_hospital;
+ break;
+ case 0x2e:
+ item->type=type_poly_hospital;
+ break;
+ case 0x2f:
+ item->type=type_poly_university;
+ break;
+ case 0x30:
+ item->type=type_poly_university;
+ break;
+ case 0x32:
+ item->type=type_poly_park;
+ break;
+ case 0x34:
+ item->type=type_poly_sport;
+ break;
+ case 0x35:
+ item->type=type_poly_sport;
+ break;
+ case 0x37:
+ item->type=type_poly_golf_course;
+ break;
+ case 0x38:
+ item->type=type_poly_national_park;
+ break;
+ case 0x39:
+ item->type=type_poly_nature_park;
+ break;
+ case 0x3c:
+ item->type=type_poly_water;
+ break;
+ case 0xbc:
+ item->type=type_water_line;
+ break;
+ case 0xc3:
+ /* FIXME: what is this ?*/
+ item->type=type_border_state;
+ break;
+ case 0xc6:
+ item->type=type_border_country;
+ break;
+ case 0xc7:
+ item->type=type_border_state;
+ break;
+ case 0xd0:
+ item->type=type_rail;
+ break;
+ default:
+ dbg(lvl_error,"Unknown poly type 0x%x '%s' 0x%x,0x%x", poly->type,poly->name,r.lu.x,r.lu.y);
+ item->type=type_street_unkn;
+ }
+ if (!map_selection_contains_item(mr->cur_sel, 0, item->type)) {
+ poly->subpoly_num_all+=poly->polys;
+ mr->b.p=poly->poly_next;
+ continue;
+ }
+ } else
+ mr->b.p=poly->subpoly_next;
+ dbg(lvl_debug,"%d %d %s", poly->subpoly_num_all, mr->b.block_num, poly->name);
+ item->id_lo=poly->subpoly_num_all | (mr->b.block_num << 16);
+ item->id_hi=(mr->current_file << 16);
+ dbg(lvl_debug,"0x%x 0x%x", item->id_lo, item->id_hi);
+ poly->subpoly_next=mr->b.p+L(poly->count[poly->subpoly_num])*sizeof(struct coord);
+ poly->subpoly_num++;
+ poly->subpoly_num_all++;
+ if (poly->subpoly_num >= poly->polys)
+ poly->subpoly_num=0;
+ poly->subpoly_start=poly->p=mr->b.p;
+ item->priv_data=poly;
+ poly->attr_next=attr_label;
+ return 1;
+ }
}
-int
-poly_get_byid(struct map_rect_priv *mr, struct poly_priv *poly, int id_hi, int id_lo, struct item *item)
-{
- int count=id_lo & 0xffff;
- int ret=0;
- block_get_byindex(mr->m->file[mr->current_file], id_lo >> 16, &mr->b);
- while (count-- >= 0) {
- ret=poly_get(mr, poly, item);
- }
- return ret;
+int poly_get_byid(struct map_rect_priv *mr, struct poly_priv *poly, int id_hi, int id_lo, struct item *item) {
+ int count=id_lo & 0xffff;
+ int ret=0;
+ block_get_byindex(mr->m->file[mr->current_file], id_lo >> 16, &mr->b);
+ while (count-- >= 0) {
+ ret=poly_get(mr, poly, item);
+ }
+ return ret;
}
diff --git a/navit/map/mg/street.c b/navit/map/mg/street.c
index 6aad6e5a0..d0841f4bc 100644
--- a/navit/map/mg/street.c
+++ b/navit/map/mg/street.c
@@ -30,780 +30,689 @@ int coord_debug;
static void street_name_numbers_get(struct street_name_numbers *name_numbers, unsigned char **p);
static void street_name_number_get(struct street_name_number *name_number, unsigned char **p);
-static void
-street_name_debug(struct street_name *sn, FILE *out)
-{
- struct street_name_numbers nns;
- unsigned char *p=sn->aux_data;
- unsigned char *end=p+sn->aux_len;
- int i;
-
- while (p < end) {
- unsigned char *pn,*pn_end;
- struct street_name_number nn;
- street_name_numbers_get(&nns, &p);
- fprintf(out,"0x%x 0x%x type=town_label label=\"%s(%d):0x%x:%d%s-%d%s\" debug=\"len=0x%x\"",nns.c->x,nns.c->y,sn->name2, sn->segment_count, nns.tag, nns.first.number,nns.first.suffix,nns.last.number,nns.last.suffix,nns.len);
- for (i = 0 ; i < sn->segment_count ; i++) {
- fprintf(out," debug=\"segment(%d)=0x%x\"",i,sn->segments[i].segid);
- }
- fprintf(out,"\n");
- pn=nns.aux_data;
- pn_end=nns.aux_data+nns.aux_len;
- while (pn < pn_end) {
- street_name_number_get(&nn, &pn);
- fprintf(out,"0x%x 0x%x type=town_label label=\"%s:0x%x:%d%s-%d%s\" debug=\"len=0x%x\"\n", nn.c->x, nn.c->y, sn->name2, nn.tag, nn.first.number, nn.first.suffix, nn.last.number,nn.last.suffix,nn.len);
- }
- }
- fflush(out);
+static void street_name_debug(struct street_name *sn, FILE *out) {
+ struct street_name_numbers nns;
+ unsigned char *p=sn->aux_data;
+ unsigned char *end=p+sn->aux_len;
+ int i;
+
+ while (p < end) {
+ unsigned char *pn,*pn_end;
+ struct street_name_number nn;
+ street_name_numbers_get(&nns, &p);
+ fprintf(out,"0x%x 0x%x type=town_label label=\"%s(%d):0x%x:%d%s-%d%s\" debug=\"len=0x%x\"",nns.c->x,nns.c->y,sn->name2,
+ sn->segment_count, nns.tag, nns.first.number,nns.first.suffix,nns.last.number,nns.last.suffix,nns.len);
+ for (i = 0 ; i < sn->segment_count ; i++) {
+ fprintf(out," debug=\"segment(%d)=0x%x\"",i,sn->segments[i].segid);
+ }
+ fprintf(out,"\n");
+ pn=nns.aux_data;
+ pn_end=nns.aux_data+nns.aux_len;
+ while (pn < pn_end) {
+ street_name_number_get(&nn, &pn);
+ fprintf(out,"0x%x 0x%x type=town_label label=\"%s:0x%x:%d%s-%d%s\" debug=\"len=0x%x\"\n", nn.c->x, nn.c->y, sn->name2,
+ nn.tag, nn.first.number, nn.first.suffix, nn.last.number,nn.last.suffix,nn.len);
+ }
+ }
+ fflush(out);
}
#endif
-static void
-street_name_get(struct street_name *name, unsigned char **p)
-{
-#if 0
- static FILE *out;
- static GHashTable *hash;
-#endif
- unsigned char *start=*p;
- name->len=get_u16_unal(p);
- name->country=get_u16_unal(p);
- name->townassoc=get_u32_unal(p);
- name->name1=get_string(p);
- name->name2=get_string(p);
- name->segment_count=get_u32_unal(p);
- name->segments=(struct street_name_segment *)(*p);
- (*p)+=(sizeof (struct street_name_segment))*name->segment_count;
- name->aux_len=name->len-(*p-start);
- name->aux_data=*p;
- name->tmp_len=name->aux_len;
- name->tmp_data=name->aux_data;
- *p=start+name->len;
-#if 0
- if (! out) {
- out=fopen("hn.txt","a");
- }
- if (! hash) {
- hash=g_hash_table_new(NULL,NULL);
- }
- if (! g_hash_table_lookup(hash, *p)) {
- g_hash_table_insert(hash, *p, (void *)1);
- street_name_debug(name, out);
- }
-#endif
-}
-
-static int
-street_name_eod(struct street_name *name)
-{
- return (name->tmp_data >= name->aux_data+name->aux_len);
-}
-
-static void
-street_name_numbers_get(struct street_name_numbers *name_numbers, unsigned char **p)
-{
- unsigned char *start=*p;
- name_numbers->len=get_u16_unal(p);
- name_numbers->tag=get_u8(p);
- name_numbers->dist=get_u32_unal(p);
- name_numbers->country=get_u32_unal(p);
- name_numbers->c=coord_get(p);
- name_numbers->first.number=get_u16_unal(p);
- name_numbers->first.suffix=get_string(p);
- name_numbers->last.number=get_u16_unal(p);
- name_numbers->last.suffix=get_string(p);
- name_numbers->segment_count=get_u32_unal(p);
- name_numbers->segments=(struct street_name_segment *)(*p);
- (*p)+=sizeof(struct street_name_segment)*name_numbers->segment_count;
- name_numbers->aux_len=name_numbers->len-(*p-start);
- name_numbers->aux_data=*p;
- name_numbers->tmp_len=name_numbers->aux_len;
- name_numbers->tmp_data=name_numbers->aux_data;
- *p=start+name_numbers->len;
-}
-
-static int
-street_name_numbers_eod(struct street_name_numbers *name_numbers)
-{
- return (name_numbers->tmp_data >= name_numbers->aux_data+name_numbers->aux_len);
-}
-
-static void
-street_name_number_get(struct street_name_number *name_number, unsigned char **p)
-{
- unsigned char *start=*p;
- name_number->len=get_u16_unal(p);
- name_number->tag=get_u8(p);
- name_number->c=coord_get(p);
- name_number->first.number=get_u16_unal(p);
- name_number->first.suffix=get_string(p);
- name_number->last.number=get_u16_unal(p);
- name_number->last.suffix=get_string(p);
- name_number->segment=(struct street_name_segment *)p;
- *p=start+name_number->len;
-}
-
-static void
-street_name_get_by_id(struct street_name *name, struct file *file, unsigned long id)
-{
- unsigned char *p;
- if (id) {
- p=file->begin+id+0x2000;
- street_name_get(name, &p);
- }
-}
-
-static int street_get_bytes(struct coord_rect *r)
-{
- int bytes,dx,dy;
- bytes=2;
- dx=r->rl.x-r->lu.x;
- dy=r->lu.y-r->rl.y;
- dbg_assert(dx > 0);
- dbg_assert(dy > 0);
- if (dx > 32767 || dy > 32767)
- bytes=3;
- if (dx > 8388608 || dy > 8388608)
- bytes=4;
-
- return bytes;
-}
-
-static int street_get_coord(unsigned char **pos, int bytes, struct coord_rect *ref, struct coord *f)
-{
- unsigned char *p;
- int x,y,flags=0;
-
- p=*pos;
- x=*p++;
- x|=(*p++) << 8;
- if (bytes == 2) {
- if ( x > 0x7fff) {
- x=0x10000-x;
- flags=1;
- }
- }
- else if (bytes == 3) {
- x|=(*p++) << 16;
- if ( x > 0x7fffff) {
- x=0x1000000-x;
- flags=1;
- }
- } else {
- x|=(*p++) << 16;
- x|=(*p++) << 24;
- if (x < 0) {
- x=-x;
- flags=1;
- }
- }
- y=*p++;
- y|=(*p++) << 8;
- if (bytes == 3) {
- y|=(*p++) << 16;
- } else if (bytes == 4) {
- y|=(*p++) << 16;
- y|=(*p++) << 24;
- }
- if (f) {
- f->x=ref->lu.x+x;
- f->y=ref->rl.y+y;
- dbg(lvl_debug,"0x%x,0x%x + 0x%x,0x%x = 0x%x,0x%x\n", x, y, ref->lu.x, ref->rl.y, f->x, f->y);
- }
- *pos=p;
- return flags;
-}
-
-static void
-street_coord_get_begin(unsigned char **p)
-{
- struct street_str *str;
-
- str=(struct street_str *)(*p);
- while (street_str_get_segid(str)) {
- str++;
- }
- (*p)=(unsigned char *)str;
- (*p)+=4;
-}
-
-
-static void
-street_coord_rewind(void *priv_data)
-{
- struct street_priv *street=priv_data;
-
- street->p=street->next=NULL;
- street->status=street->status_rewind;
-}
-
-static int
-street_coord_get_helper(struct street_priv *street, struct coord *c)
-{
- unsigned char *n;
- if (street->p+street->bytes*2 >= street->end)
- return 0;
- if (street->status >= 4)
- return 0;
- n=street->p;
- if (street_get_coord(&street->p, street->bytes, &street->ref, c)) {
- if (street->status)
- street->next=n;
- street->status+=2;
- if (street->status == 5)
- return 0;
- }
- return 1;
-}
-
-static int
-street_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct street_priv *street=priv_data;
- int ret=0,i,scount;
+static void street_name_get(struct street_name *name, unsigned char **p) {
+ unsigned char *start=*p;
+ name->len=get_u16_unal(p);
+ name->country=get_u16_unal(p);
+ name->townassoc=get_u32_unal(p);
+ name->name1=get_string(p);
+ name->name2=get_string(p);
+ name->segment_count=get_u32_unal(p);
+ name->segments=(struct street_name_segment *)(*p);
+ (*p)+=(sizeof (struct street_name_segment))*name->segment_count;
+ name->aux_len=name->len-(*p-start);
+ name->aux_data=*p;
+ name->tmp_len=name->aux_len;
+ name->tmp_data=name->aux_data;
+ *p=start+name->len;
+}
+
+static int street_name_eod(struct street_name *name) {
+ return (name->tmp_data >= name->aux_data+name->aux_len);
+}
+
+static void street_name_numbers_get(struct street_name_numbers *name_numbers, unsigned char **p) {
+ unsigned char *start=*p;
+ name_numbers->len=get_u16_unal(p);
+ name_numbers->tag=get_u8(p);
+ name_numbers->dist=get_u32_unal(p);
+ name_numbers->country=get_u32_unal(p);
+ name_numbers->c=coord_get(p);
+ name_numbers->first.number=get_u16_unal(p);
+ name_numbers->first.suffix=get_string(p);
+ name_numbers->last.number=get_u16_unal(p);
+ name_numbers->last.suffix=get_string(p);
+ name_numbers->segment_count=get_u32_unal(p);
+ name_numbers->segments=(struct street_name_segment *)(*p);
+ (*p)+=sizeof(struct street_name_segment)*name_numbers->segment_count;
+ name_numbers->aux_len=name_numbers->len-(*p-start);
+ name_numbers->aux_data=*p;
+ name_numbers->tmp_len=name_numbers->aux_len;
+ name_numbers->tmp_data=name_numbers->aux_data;
+ *p=start+name_numbers->len;
+}
+
+static int street_name_numbers_eod(struct street_name_numbers *name_numbers) {
+ return (name_numbers->tmp_data >= name_numbers->aux_data+name_numbers->aux_len);
+}
+
+static void street_name_number_get(struct street_name_number *name_number, unsigned char **p) {
+ unsigned char *start=*p;
+ name_number->len=get_u16_unal(p);
+ name_number->tag=get_u8(p);
+ name_number->c=coord_get(p);
+ name_number->first.number=get_u16_unal(p);
+ name_number->first.suffix=get_string(p);
+ name_number->last.number=get_u16_unal(p);
+ name_number->last.suffix=get_string(p);
+ name_number->segment=(struct street_name_segment *)p;
+ *p=start+name_number->len;
+}
+
+static void street_name_get_by_id(struct street_name *name, struct file *file, unsigned long id) {
+ unsigned char *p;
+ if (id) {
+ p=file->begin+id+0x2000;
+ street_name_get(name, &p);
+ }
+}
+
+static int street_get_bytes(struct coord_rect *r) {
+ int bytes,dx,dy;
+ bytes=2;
+ dx=r->rl.x-r->lu.x;
+ dy=r->lu.y-r->rl.y;
+ dbg_assert(dx > 0);
+ dbg_assert(dy > 0);
+ if (dx > 32767 || dy > 32767)
+ bytes=3;
+ if (dx > 8388608 || dy > 8388608)
+ bytes=4;
+
+ return bytes;
+}
+
+static int street_get_coord(unsigned char **pos, int bytes, struct coord_rect *ref, struct coord *f) {
+ unsigned char *p;
+ int x,y,flags=0;
+
+ p=*pos;
+ x=*p++;
+ x|=(*p++) << 8;
+ if (bytes == 2) {
+ if ( x > 0x7fff) {
+ x=0x10000-x;
+ flags=1;
+ }
+ } else if (bytes == 3) {
+ x|=(*p++) << 16;
+ if ( x > 0x7fffff) {
+ x=0x1000000-x;
+ flags=1;
+ }
+ } else {
+ x|=(*p++) << 16;
+ x|=(*p++) << 24;
+ if (x < 0) {
+ x=-x;
+ flags=1;
+ }
+ }
+ y=*p++;
+ y|=(*p++) << 8;
+ if (bytes == 3) {
+ y|=(*p++) << 16;
+ } else if (bytes == 4) {
+ y|=(*p++) << 16;
+ y|=(*p++) << 24;
+ }
+ if (f) {
+ f->x=ref->lu.x+x;
+ f->y=ref->rl.y+y;
+ dbg(lvl_debug,"0x%x,0x%x + 0x%x,0x%x = 0x%x,0x%x", x, y, ref->lu.x, ref->rl.y, f->x, f->y);
+ }
+ *pos=p;
+ return flags;
+}
+
+static void street_coord_get_begin(unsigned char **p) {
+ struct street_str *str;
+
+ str=(struct street_str *)(*p);
+ while (street_str_get_segid(str)) {
+ str++;
+ }
+ (*p)=(unsigned char *)str;
+ (*p)+=4;
+}
+
+
+static void street_coord_rewind(void *priv_data) {
+ struct street_priv *street=priv_data;
+
+ street->p=street->next=NULL;
+ street->status=street->status_rewind;
+}
+
+static int street_coord_get_helper(struct street_priv *street, struct coord *c) {
+ unsigned char *n;
+ if (street->p+street->bytes*2 >= street->end)
+ return 0;
+ if (street->status >= 4)
+ return 0;
+ n=street->p;
+ if (street_get_coord(&street->p, street->bytes, &street->ref, c)) {
+ if (street->status)
+ street->next=n;
+ street->status+=2;
+ if (street->status == 5)
+ return 0;
+ }
+ return 1;
+}
+
+static int street_coord_get(void *priv_data, struct coord *c, int count) {
+ struct street_priv *street=priv_data;
+ int ret=0,i,scount;
#ifdef DEBUG_COORD_GET
- int segid,debug=0;
+ int segid,debug=0;
#endif
- if (! street->p && count) {
- street->p=street->coord_begin;
- scount=street->str-street->str_start;
- for (i = 0 ; i < scount ; i++) {
- street->status=street_str_get_segid(&street->str[i+1]) >= 0 ? 0:1;
- while (street_coord_get_helper(street, c));
- street->p=street->next;
- }
- street->status_rewind=street->status=street_str_get_segid(&street->str[1]) >= 0 ? 0:1;
- }
+ if (! street->p && count) {
+ street->p=street->coord_begin;
+ scount=street->str-street->str_start;
+ for (i = 0 ; i < scount ; i++) {
+ street->status=street_str_get_segid(&street->str[i+1]) >= 0 ? 0:1;
+ while (street_coord_get_helper(street, c));
+ street->p=street->next;
+ }
+ street->status_rewind=street->status=street_str_get_segid(&street->str[1]) >= 0 ? 0:1;
+ }
#ifdef DEBUG_COORD_GET
- segid=street_str_get_segid(&street->str[0]);
- if (segid < 0)
- segid=-segid;
- if (segid == 0x15)
- debug=1;
- if (debug) {
- dbg(lvl_debug,"enter 0x%x\n",segid);
- }
+ segid=street_str_get_segid(&street->str[0]);
+ if (segid < 0)
+ segid=-segid;
+ if (segid == 0x15)
+ debug=1;
+ if (debug) {
+ dbg(lvl_debug,"enter 0x%x",segid);
+ }
#endif
- while (count > 0) {
- if (street_coord_get_helper(street, c)) {
+ while (count > 0) {
+ if (street_coord_get_helper(street, c)) {
#ifdef DEBUG_COORD_GET
- if (debug) {
- dbg(lvl_debug,"0x%x,0x%x\n", c->x, c->y);
- }
+ if (debug) {
+ dbg(lvl_debug,"0x%x,0x%x", c->x, c->y);
+ }
#endif
- c++;
- ret++;
- count--;
- } else {
- street->more=0;
- return ret;
- }
- }
- return ret;
-}
-
- static void
-street_attr_rewind(void *priv_data)
-{
- /* struct street_priv *street=priv_data; */
-
-}
-
-static int
-street_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct street_priv *street=priv_data;
- int nameid;
-
- dbg(lvl_debug,"segid 0x%x\n", street_str_get_segid(street->str));
- attr->type=attr_type;
- switch (attr_type) {
- case attr_any:
- while (street->attr_next != attr_none) {
- if (street_attr_get(street, street->attr_next, attr))
- return 1;
- }
- return 0;
- case attr_label:
- street->attr_next=attr_street_name;
- nameid=street_str_get_nameid(street->str);
- if (! nameid)
- return 0;
- if (! street->name.len)
- street_name_get_by_id(&street->name,street->name_file,nameid);
- attr->u.str=street->name.name2;
- if (attr->u.str && attr->u.str[0])
- return 1;
- attr->u.str=street->name.name1;
- if (attr->u.str && attr->u.str[0])
- return 1;
- return 0;
- case attr_street_name:
- street->attr_next=attr_street_name_systematic;
- nameid=street_str_get_nameid(street->str);
- if (! nameid)
- return 0;
- if (! street->name.len)
- street_name_get_by_id(&street->name,street->name_file,nameid);
- attr->u.str=street->name.name2;
- return ((attr->u.str && attr->u.str[0]) ? 1:0);
- case attr_street_name_systematic:
- street->attr_next=attr_flags;
- nameid=street_str_get_nameid(street->str);
- if (! nameid)
- return 0;
- if (! street->name.len)
- street_name_get_by_id(&street->name,street->name_file,nameid);
- attr->u.str=street->name.name1;
- return ((attr->u.str && attr->u.str[0]) ? 1:0);
- case attr_flags:
- attr->u.num=street->flags;
- street->attr_next=attr_country_id;
- return 1;
- case attr_country_id:
- street->attr_next=attr_debug;
- nameid=street_str_get_nameid(street->str);
- if (! nameid)
- return 0;
- if (! street->name.len)
- street_name_get_by_id(&street->name,street->name_file,nameid);
- attr->u.num=mg_country_to_isonum(street->name.country);
- return 1;
- case attr_debug:
- street->attr_next=attr_none;
- {
- struct street_str *str=street->str;
- sprintf(street->debug,"order:0x%x\nsegid:0x%x\nlimit:0x%x\nunknown2:0x%x\nunknown3:0x%x\ntype:0x%x\nnameid:0x%x\ntownassoc:0x%x",street_header_get_order(street->header),street_str_get_segid(str),street_str_get_limit(str),street_str_get_unknown2(str),street_str_get_unknown3(str),street_str_get_type(str),street_str_get_nameid(str), street->name.len ? street->name.townassoc : 0);
- attr->u.str=street->debug;
- }
- return 1;
- default:
- return 0;
- }
- return 1;
+ c++;
+ ret++;
+ count--;
+ } else {
+ street->more=0;
+ return ret;
+ }
+ }
+ return ret;
+}
+
+static void street_attr_rewind(void *priv_data) {
+ /* struct street_priv *street=priv_data; */
+
+}
+
+static int street_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct street_priv *street=priv_data;
+ int nameid;
+
+ dbg(lvl_debug,"segid 0x%x", street_str_get_segid(street->str));
+ attr->type=attr_type;
+ switch (attr_type) {
+ case attr_any:
+ while (street->attr_next != attr_none) {
+ if (street_attr_get(street, street->attr_next, attr))
+ return 1;
+ }
+ return 0;
+ case attr_label:
+ street->attr_next=attr_street_name;
+ nameid=street_str_get_nameid(street->str);
+ if (! nameid)
+ return 0;
+ if (! street->name.len)
+ street_name_get_by_id(&street->name,street->name_file,nameid);
+ attr->u.str=street->name.name2;
+ if (attr->u.str && attr->u.str[0])
+ return 1;
+ attr->u.str=street->name.name1;
+ if (attr->u.str && attr->u.str[0])
+ return 1;
+ return 0;
+ case attr_street_name:
+ street->attr_next=attr_street_name_systematic;
+ nameid=street_str_get_nameid(street->str);
+ if (! nameid)
+ return 0;
+ if (! street->name.len)
+ street_name_get_by_id(&street->name,street->name_file,nameid);
+ attr->u.str=street->name.name2;
+ return ((attr->u.str && attr->u.str[0]) ? 1:0);
+ case attr_street_name_systematic:
+ street->attr_next=attr_flags;
+ nameid=street_str_get_nameid(street->str);
+ if (! nameid)
+ return 0;
+ if (! street->name.len)
+ street_name_get_by_id(&street->name,street->name_file,nameid);
+ attr->u.str=street->name.name1;
+ return ((attr->u.str && attr->u.str[0]) ? 1:0);
+ case attr_flags:
+ attr->u.num=street->flags;
+ street->attr_next=attr_country_id;
+ return 1;
+ case attr_country_id:
+ street->attr_next=attr_debug;
+ nameid=street_str_get_nameid(street->str);
+ if (! nameid)
+ return 0;
+ if (! street->name.len)
+ street_name_get_by_id(&street->name,street->name_file,nameid);
+ attr->u.num=mg_country_to_isonum(street->name.country);
+ return 1;
+ case attr_debug:
+ street->attr_next=attr_none;
+ {
+ struct street_str *str=street->str;
+ sprintf(street->debug,
+ "order:0x%x\nsegid:0x%x\nlimit:0x%x\nunknown2:0x%x\nunknown3:0x%x\ntype:0x%x\nnameid:0x%x\ntownassoc:0x%x",
+ street_header_get_order(street->header),street_str_get_segid(str),street_str_get_limit(str),
+ street_str_get_unknown2(str),street_str_get_unknown3(str),street_str_get_type(str),street_str_get_nameid(str),
+ street->name.len ? street->name.townassoc : 0);
+ attr->u.str=street->debug;
+ }
+ return 1;
+ default:
+ return 0;
+ }
+ return 1;
}
static struct item_methods street_meth = {
- street_coord_rewind,
- street_coord_get,
- street_attr_rewind,
- street_attr_get,
+ street_coord_rewind,
+ street_coord_get,
+ street_attr_rewind,
+ street_attr_get,
};
-static void
-street_get_data(struct street_priv *street, unsigned char **p)
-{
- street->header=(struct street_header *)(*p);
- (*p)+=sizeof(struct street_header);
- street->type_count=street_header_get_count(street->header);
- street->type=(struct street_type *)(*p);
- (*p)+=street->type_count*sizeof(struct street_type);
-}
-
- /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */
-static unsigned char limit[]={0,0,1,1,1,2,2,4,6,6,12,13,14,20,20,20,20,20,20};
-
-int
-street_get(struct map_rect_priv *mr, struct street_priv *street, struct item *item)
-{
- int *flags;
- struct coord_rect r;
- for (;;) {
- while (street->more) {
- struct coord c;
- street_coord_get(street, &c, 1);
- }
-#if 0
- if (street->housenumber) {
- if (street_get_housenumber(mr, street, item))
- return 1;
- street->housenumber=0;
- }
-#endif
- if (mr->b.p == mr->b.p_start) {
- street_get_data(street, &mr->b.p);
- street->name_file=mr->m->file[file_strname_stn];
- if (mr->cur_sel && street_header_get_order(street->header) > limit[mr->cur_sel->order])
- return 0;
- street->end=mr->b.end;
- block_get_r(mr->b.b, &r);
- street->ref=r;
- street->bytes=street_get_bytes(&r);
- street->str_start=street->str=(struct street_str *)mr->b.p;
- street->coord_begin=mr->b.p;
- street_coord_get_begin(&street->coord_begin);
- street->p=street->coord_begin;
- street->type--;
- item->meth=&street_meth;
- item->priv_data=street;
- } else {
- street->str++;
- street->p=street->next;
- }
- if (! street_str_get_segid(street->str))
- return 0;
- if (street_str_get_segid(street->str) < 0)
- street->type++;
-#if 0
- dbg_assert(street->p != NULL);
-#endif
- street->next=NULL;
- street->status_rewind=street->status=street_str_get_segid(&street->str[1]) >= 0 ? 0:1;
-#if 0
- if (street->type->country != 0x31) {
- printf("country=0x%x\n", street->type->country);
- }
-#endif
- item->id_hi=street_type_get_country(street->type) | (mr->current_file << 16);
- item->id_lo=street_str_get_segid(street->str) > 0 ? street_str_get_segid(street->str) : -street_str_get_segid(street->str);
- switch(street_str_get_type(street->str) & 0x1f) {
- case 0xf: /* very small street */
- if (street_str_get_limit(street->str) == 0x33)
- item->type=type_street_nopass;
- else
- item->type=type_street_0;
- break;
- case 0xd:
- item->type=type_ferry;
- break;
- case 0xc: /* small street */
- item->type=type_street_1_city;
- break;
- case 0xb:
- item->type=type_street_2_city;
- break;
- case 0xa:
- if ((street_str_get_limit(street->str) == 0x03 || street_str_get_limit(street->str) == 0x30) && street_header_get_order(street->header) < 4)
- item->type=type_street_4_city;
- else
- item->type=type_street_3_city;
- break;
- case 0x9:
- if (street_header_get_order(street->header) < 5)
- item->type=type_street_4_city;
- else if (street_header_get_order(street->header) < 7)
- item->type=type_street_2_city;
- else
- item->type=type_street_1_city;
- break;
- case 0x8:
- item->type=type_street_2_land;
- break;
- case 0x7:
- if ((street_str_get_limit(street->str) == 0x03 || street_str_get_limit(street->str) == 0x30) && street_header_get_order(street->header) < 4)
- item->type=type_street_4_city;
- else
- item->type=type_street_3_land;
- break;
- case 0x6:
- item->type=type_ramp;
- break;
- case 0x5:
- item->type=type_street_4_land;
- break;
- case 0x4:
- item->type=type_street_4_land;
- break;
- case 0x3:
- item->type=type_street_n_lanes;
- break;
- case 0x2:
- item->type=type_highway_city;
- break;
- case 0x1:
- item->type=type_highway_land;
- break;
- default:
- item->type=type_street_unkn;
- dbg(lvl_error,"unknown type 0x%x\n",street_str_get_type(street->str));
- }
- flags=item_get_default_flags(item->type);
- if (flags)
- street->flags=*flags;
- else
- street->flags=0;
- if (street_str_get_type(street->str) & 0x40) {
- street->flags|=(street_str_get_limit(street->str) & 0x30) ? AF_ONEWAYREV:0;
- street->flags|=(street_str_get_limit(street->str) & 0x03) ? AF_ONEWAY:0;
- } else {
- street->flags|=(street_str_get_limit(street->str) & 0x30) ? AF_ONEWAY:0;
- street->flags|=(street_str_get_limit(street->str) & 0x03) ? AF_ONEWAYREV:0;
- }
-#if 0
- coord_debug=(street->str->unknown2 != 0x40 || street->str->unknown3 != 0x40);
- if (coord_debug) {
- item->type=type_street_unkn;
- printf("%d %02x %02x %02x %02x\n", street->str->segid, street->str->type, street->str->limit, street->str->unknown2, street->str->unknown3);
- }
-#endif
- street->p_rewind=street->p;
- street->name.len=0;
- street->attr_next=attr_label;
- street->more=1;
- street->housenumber=1;
- street->hn_count=0;
- if (!map_selection_contains_item(mr->cur_sel, 0, item->type))
- continue;
- item->meth=&street_meth;
- item->priv_data=street;
- return 1;
- }
-}
-
-int
-street_get_byid(struct map_rect_priv *mr, struct street_priv *street, int id_hi, int id_lo, struct item *item)
-{
- int country=id_hi & 0xffff;
- int res;
- struct coord_rect r;
- dbg(lvl_debug,"enter(%p,%p,0x%x,0x%x,%p)\n", mr, street, id_hi, id_lo, item);
- if (! country)
- return 0;
- if (! tree_search_hv(mr->m->dirname, "street", (id_lo >> 8) | (country << 24), id_lo & 0xff, &res))
- return 0;
- dbg(lvl_debug,"res=0x%x (blk=0x%x)\n", res, res >> 12);
- block_get_byindex(mr->m->file[mr->current_file], res >> 12, &mr->b);
- street_get_data(street, &mr->b.p);
- street->name_file=mr->m->file[file_strname_stn];
- street->end=mr->b.end;
- block_get_r(mr->b.b, &r);
- street->ref=r;
- street->bytes=street_get_bytes(&r);
- street->str_start=street->str=(struct street_str *)mr->b.p;
- street->coord_begin=mr->b.p;
- street_coord_get_begin(&street->coord_begin);
- street->p=street->coord_begin;
- street->type--;
- item->meth=&street_meth;
- item->priv_data=street;
- street->str+=(res & 0xfff)-1;
- dbg(lvl_debug,"segid 0x%x\n", street_str_get_segid(&street->str[1]));
- return street_get(mr, street, item);
-#if 0
- mr->b.p=mr->b.block_start+(res & 0xffff);
- return town_get(mr, twn, item);
-#endif
-
- return 0;
+static void street_get_data(struct street_priv *street, unsigned char **p) {
+ street->header=(struct street_header *)(*p);
+ (*p)+=sizeof(struct street_header);
+ street->type_count=street_header_get_count(street->header);
+ street->type=(struct street_type *)(*p);
+ (*p)+=street->type_count*sizeof(struct street_type);
+}
+
+/*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */
+static unsigned char limit[]= {0,0,1,1,1,2,2,4,6,6,12,13,14,20,20,20,20,20,20};
+
+int street_get(struct map_rect_priv *mr, struct street_priv *street, struct item *item) {
+ int *flags;
+ struct coord_rect r;
+ for (;;) {
+ while (street->more) {
+ struct coord c;
+ street_coord_get(street, &c, 1);
+ }
+ if (mr->b.p == mr->b.p_start) {
+ street_get_data(street, &mr->b.p);
+ street->name_file=mr->m->file[file_strname_stn];
+ if (mr->cur_sel && street_header_get_order(street->header) > limit[mr->cur_sel->order])
+ return 0;
+ street->end=mr->b.end;
+ block_get_r(mr->b.b, &r);
+ street->ref=r;
+ street->bytes=street_get_bytes(&r);
+ street->str_start=street->str=(struct street_str *)mr->b.p;
+ street->coord_begin=mr->b.p;
+ street_coord_get_begin(&street->coord_begin);
+ street->p=street->coord_begin;
+ street->type--;
+ item->meth=&street_meth;
+ item->priv_data=street;
+ } else {
+ street->str++;
+ street->p=street->next;
+ }
+ if (! street_str_get_segid(street->str))
+ return 0;
+ if (street_str_get_segid(street->str) < 0)
+ street->type++;
+ street->next=NULL;
+ street->status_rewind=street->status=street_str_get_segid(&street->str[1]) >= 0 ? 0:1;
+ item->id_hi=street_type_get_country(street->type) | (mr->current_file << 16);
+ item->id_lo=street_str_get_segid(street->str) > 0 ? street_str_get_segid(street->str) : -street_str_get_segid(
+ street->str);
+ switch(street_str_get_type(street->str) & 0x1f) {
+ case 0xf: /* very small street */
+ if (street_str_get_limit(street->str) == 0x33)
+ item->type=type_street_nopass;
+ else
+ item->type=type_street_0;
+ break;
+ case 0xd:
+ item->type=type_ferry;
+ break;
+ case 0xc: /* small street */
+ item->type=type_street_1_city;
+ break;
+ case 0xb:
+ item->type=type_street_2_city;
+ break;
+ case 0xa:
+ if ((street_str_get_limit(street->str) == 0x03 || street_str_get_limit(street->str) == 0x30)
+ && street_header_get_order(street->header) < 4)
+ item->type=type_street_4_city;
+ else
+ item->type=type_street_3_city;
+ break;
+ case 0x9:
+ if (street_header_get_order(street->header) < 5)
+ item->type=type_street_4_city;
+ else if (street_header_get_order(street->header) < 7)
+ item->type=type_street_2_city;
+ else
+ item->type=type_street_1_city;
+ break;
+ case 0x8:
+ item->type=type_street_2_land;
+ break;
+ case 0x7:
+ if ((street_str_get_limit(street->str) == 0x03 || street_str_get_limit(street->str) == 0x30)
+ && street_header_get_order(street->header) < 4)
+ item->type=type_street_4_city;
+ else
+ item->type=type_street_3_land;
+ break;
+ case 0x6:
+ item->type=type_ramp;
+ break;
+ case 0x5:
+ item->type=type_street_4_land;
+ break;
+ case 0x4:
+ item->type=type_street_4_land;
+ break;
+ case 0x3:
+ item->type=type_street_n_lanes;
+ break;
+ case 0x2:
+ item->type=type_highway_city;
+ break;
+ case 0x1:
+ item->type=type_highway_land;
+ break;
+ default:
+ item->type=type_street_unkn;
+ dbg(lvl_error,"unknown type 0x%x",street_str_get_type(street->str));
+ }
+ flags=item_get_default_flags(item->type);
+ if (flags)
+ street->flags=*flags;
+ else
+ street->flags=0;
+ if (street_str_get_type(street->str) & 0x40) {
+ street->flags|=(street_str_get_limit(street->str) & 0x30) ? AF_ONEWAYREV:0;
+ street->flags|=(street_str_get_limit(street->str) & 0x03) ? AF_ONEWAY:0;
+ } else {
+ street->flags|=(street_str_get_limit(street->str) & 0x30) ? AF_ONEWAY:0;
+ street->flags|=(street_str_get_limit(street->str) & 0x03) ? AF_ONEWAYREV:0;
+ }
+ street->p_rewind=street->p;
+ street->name.len=0;
+ street->attr_next=attr_label;
+ street->more=1;
+ street->housenumber=1;
+ street->hn_count=0;
+ if (!map_selection_contains_item(mr->cur_sel, 0, item->type))
+ continue;
+ item->meth=&street_meth;
+ item->priv_data=street;
+ return 1;
+ }
+}
+
+int street_get_byid(struct map_rect_priv *mr, struct street_priv *street, int id_hi, int id_lo, struct item *item) {
+ int country=id_hi & 0xffff;
+ int res;
+ struct coord_rect r;
+ dbg(lvl_debug,"enter(%p,%p,0x%x,0x%x,%p)", mr, street, id_hi, id_lo, item);
+ if (! country)
+ return 0;
+ if (! tree_search_hv(mr->m->dirname, "street", (id_lo >> 8) | (country << 24), id_lo & 0xff, &res))
+ return 0;
+ dbg(lvl_debug,"res=0x%x (blk=0x%x)", res, res >> 12);
+ block_get_byindex(mr->m->file[mr->current_file], res >> 12, &mr->b);
+ street_get_data(street, &mr->b.p);
+ street->name_file=mr->m->file[file_strname_stn];
+ street->end=mr->b.end;
+ block_get_r(mr->b.b, &r);
+ street->ref=r;
+ street->bytes=street_get_bytes(&r);
+ street->str_start=street->str=(struct street_str *)mr->b.p;
+ street->coord_begin=mr->b.p;
+ street_coord_get_begin(&street->coord_begin);
+ street->p=street->coord_begin;
+ street->type--;
+ item->meth=&street_meth;
+ item->priv_data=street;
+ street->str+=(res & 0xfff)-1;
+ dbg(lvl_debug,"segid 0x%x", street_str_get_segid(&street->str[1]));
+ return street_get(mr, street, item);
}
struct street_name_index {
- int block;
- unsigned short country;
- int town_assoc;
- char name[0];
+ int block;
+ unsigned short country;
+ int town_assoc;
+ char name[0];
} __attribute__((packed));
-static unsigned char
-latin1_tolower(unsigned char c)
-{
- if (c >= 'A' && c <= 'Z')
- return c - 'A' + 'a';
- if (c == 0xc4 || c == 0xc9 || c == 0xd6 || c == 0xdc)
- return c+0x20;
- return c;
-}
-
-static unsigned char
-latin1_tolower_ascii(unsigned char c)
-{
- unsigned char ret=latin1_tolower(c);
- switch (ret) {
- case 0xe4:
- return 'a';
- case 0xe9:
- return 'e';
- case 0xf6:
- return 'o';
- case 0xfc:
- return 'u';
- default:
- if (ret >= 0x80)
- dbg(lvl_debug,"ret=0x%x\n",c);
- return ret;
- }
-}
-
-static int
-strncasecmp_latin1(char *str1, char *str2, int len)
-{
- int d;
- while (len--) {
- d=latin1_tolower((unsigned char)(*str1))-latin1_tolower((unsigned char)(*str2));
- if (d)
- return d;
- if (! *str1)
- return 0;
- str1++;
- str2++;
- }
- return 0;
-}
-
-static int
-strncasecmp_latin1_ascii(char *str1, char *str2, int len)
-{
- int d;
- while (len--) {
- d=latin1_tolower_ascii((unsigned char)(*str1))-latin1_tolower_ascii((unsigned char)(*str2));
- if (d)
- return d;
- if (! *str1)
- return 0;
- str1++;
- str2++;
- }
- return 0;
-}
-
-static int
-street_search_compare_do(struct map_rect_priv *mr, int country, int town_assoc, char *name)
-{
- int d,len;
-
- dbg(lvl_debug,"enter");
- dbg(lvl_debug,"country 0x%x town_assoc 0x%x name '%s'\n", country, town_assoc, name);
- d=(mr->search_item.id_hi & 0xffff)-country;
- dbg(lvl_debug,"country %d (%d vs %d)\n", d, mr->search_item.id_hi & 0xffff, country);
- if (!d) {
- if (mr->search_item.id_lo == town_assoc ) {
- dbg(lvl_debug,"town_assoc match (0x%x)\n", town_assoc);
- len=mr->search_partial ? strlen(mr->search_str):INT_MAX;
- d=strncasecmp_latin1(mr->search_str, name, len);
- if (!strncasecmp_latin1_ascii(mr->search_str, name, len))
- d=0;
- dbg(lvl_debug,"string %d\n", d);
- } else {
- if (town_assoc < mr->search_item.id_lo)
- d=1;
- else
- d=-1;
- dbg(lvl_debug,"assoc %d 0x%x-0x%x\n",d, mr->search_item.id_lo, town_assoc);
- }
- }
- dbg(lvl_debug,"d=%d\n", d);
- return d;
-}
-
-static int
-street_search_compare(unsigned char **p, struct map_rect_priv *mr)
-{
- struct street_name_index *i;
- int ret;
-
- dbg(lvl_debug,"enter\n");
- i=(struct street_name_index *)(*p);
- *p+=sizeof(*i)+strlen(i->name)+1;
-
- dbg(lvl_debug,"block 0x%x\n", i->block);
-
- ret=street_search_compare_do(mr, i->country, i->town_assoc, i->name);
- if (ret <= 0)
- mr->search_block=i->block;
- return ret;
-}
-
-static void
-street_name_coord_rewind(void *priv_data)
-{
- /* struct street_priv *street=priv_data; */
-
-}
-
-static void
-street_name_attr_rewind(void *priv_data)
-{
- /* struct street_priv *street=priv_data; */
-
-}
-
-static int
-street_name_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr=priv_data;
- struct street_name_numbers snns;
- unsigned char *p=mr->street.name.aux_data;
-
- dbg(lvl_debug,"aux_data=%p\n", p);
- if (count) {
- street_name_numbers_get(&snns, &p);
- street_name_numbers_get_coord(&snns, c);
- return 1;
- }
-
- return 0;
+static unsigned char latin1_tolower(unsigned char c) {
+ if (c >= 'A' && c <= 'Z')
+ return c - 'A' + 'a';
+ if (c == 0xc4 || c == 0xc9 || c == 0xd6 || c == 0xdc)
+ return c+0x20;
+ return c;
+}
+
+static unsigned char latin1_tolower_ascii(unsigned char c) {
+ unsigned char ret=latin1_tolower(c);
+ switch (ret) {
+ case 0xe4:
+ return 'a';
+ case 0xe9:
+ return 'e';
+ case 0xf6:
+ return 'o';
+ case 0xfc:
+ return 'u';
+ default:
+ if (ret >= 0x80)
+ dbg(lvl_debug,"ret=0x%x",c);
+ return ret;
+ }
+}
+
+static int strncasecmp_latin1(char *str1, char *str2, int len) {
+ int d;
+ while (len--) {
+ d=latin1_tolower((unsigned char)(*str1))-latin1_tolower((unsigned char)(*str2));
+ if (d)
+ return d;
+ if (! *str1)
+ return 0;
+ str1++;
+ str2++;
+ }
+ return 0;
+}
+
+static int strncasecmp_latin1_ascii(char *str1, char *str2, int len) {
+ int d;
+ while (len--) {
+ d=latin1_tolower_ascii((unsigned char)(*str1))-latin1_tolower_ascii((unsigned char)(*str2));
+ if (d)
+ return d;
+ if (! *str1)
+ return 0;
+ str1++;
+ str2++;
+ }
+ return 0;
+}
+
+static int street_search_compare_do(struct map_rect_priv *mr, int country, int town_assoc, char *name) {
+ int d,len;
+
+ dbg(lvl_debug,"enter");
+ dbg(lvl_debug,"country 0x%x town_assoc 0x%x name '%s'", country, town_assoc, name);
+ d=(mr->search_item.id_hi & 0xffff)-country;
+ dbg(lvl_debug,"country %d (%d vs %d)", d, mr->search_item.id_hi & 0xffff, country);
+ if (!d) {
+ if (mr->search_item.id_lo == town_assoc ) {
+ dbg(lvl_debug,"town_assoc match (0x%x)", town_assoc);
+ len=mr->search_partial ? strlen(mr->search_str):INT_MAX;
+ d=strncasecmp_latin1(mr->search_str, name, len);
+ if (!strncasecmp_latin1_ascii(mr->search_str, name, len))
+ d=0;
+ dbg(lvl_debug,"string %d", d);
+ } else {
+ if (town_assoc < mr->search_item.id_lo)
+ d=1;
+ else
+ d=-1;
+ dbg(lvl_debug,"assoc %d 0x%x-0x%x",d, mr->search_item.id_lo, town_assoc);
+ }
+ }
+ dbg(lvl_debug,"d=%d", d);
+ return d;
+}
+
+static int street_search_compare(unsigned char **p, struct map_rect_priv *mr) {
+ struct street_name_index *i;
+ int ret;
+
+ dbg(lvl_debug,"enter");
+ i=(struct street_name_index *)(*p);
+ *p+=sizeof(*i)+strlen(i->name)+1;
+
+ dbg(lvl_debug,"block 0x%x", i->block);
+
+ ret=street_search_compare_do(mr, i->country, i->town_assoc, i->name);
+ if (ret <= 0)
+ mr->search_block=i->block;
+ return ret;
+}
+
+static void street_name_coord_rewind(void *priv_data) {
+ /* struct street_priv *street=priv_data; */
+
+}
+
+static void street_name_attr_rewind(void *priv_data) {
+ /* struct street_priv *street=priv_data; */
+
+}
+
+static int street_name_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr=priv_data;
+ struct street_name_numbers snns;
+ unsigned char *p=mr->street.name.aux_data;
+
+ dbg(lvl_debug,"aux_data=%p", p);
+ if (count) {
+ street_name_numbers_get(&snns, &p);
+ street_name_numbers_get_coord(&snns, c);
+ return 1;
+ }
+
+ return 0;
}
#if 0
-static void
-debug(struct map_rect_priv *mr)
-{
- int i;
- struct street_name_numbers nns;
- unsigned char *p=mr->street.name.aux_data;
- unsigned char *end=p+mr->street.name.aux_len;
- printf("len=0x%x\n", mr->street.name.aux_len);
- for (i = 0 ; i < mr->street.name.aux_len ; i++) {
- printf("%02x ",mr->street.name.aux_data[i]);
- }
- printf("\n");
- {
- while (p < end) {
- unsigned char *pn,*pn_end;
- struct street_name_number nn;
- street_name_numbers_get(&nns, &p);
- printf("name_numbers:\n");
- printf(" len 0x%x\n", nns.len);
- printf(" tag 0x%x\n", nns.tag);
- printf(" dist 0x%x\n", nns.dist);
- printf(" country 0x%x\n", nns.country);
- printf(" coord 0x%x,0x%x\n", nns.c->x, nns.c->y);
- printf(" first %d\n", nns.first.number);
- printf(" last %d\n", nns.last.number);
- printf(" segment count 0x%x\n", nns.segment_count);
- printf(" aux_len 0x%x\n", nns.aux_len);
- pn=nns.aux_data;
- pn_end=nns.aux_data+nns.aux_len;
- while (pn < pn_end) {
- printf(" number:\n");
- street_name_number_get(&nn, &pn);
- printf(" len 0x%x\n", nn.len);
- printf(" tag 0x%x\n", nn.tag);
- printf(" coord 0x%x,0x%x\n", nn.c->x, nn.c->y);
- printf(" first %d\n", nn.first.number);
- printf(" last %d\n", nn.last.number);
- }
- }
- }
+static void debug(struct map_rect_priv *mr) {
+ int i;
+ struct street_name_numbers nns;
+ unsigned char *p=mr->street.name.aux_data;
+ unsigned char *end=p+mr->street.name.aux_len;
+ printf("len=0x%x\n", mr->street.name.aux_len);
+ for (i = 0 ; i < mr->street.name.aux_len ; i++) {
+ printf("%02x ",mr->street.name.aux_data[i]);
+ }
+ printf("\n");
+ {
+ while (p < end) {
+ unsigned char *pn,*pn_end;
+ struct street_name_number nn;
+ street_name_numbers_get(&nns, &p);
+ printf("name_numbers:\n");
+ printf(" len 0x%x\n", nns.len);
+ printf(" tag 0x%x\n", nns.tag);
+ printf(" dist 0x%x\n", nns.dist);
+ printf(" country 0x%x\n", nns.country);
+ printf(" coord 0x%x,0x%x\n", nns.c->x, nns.c->y);
+ printf(" first %d\n", nns.first.number);
+ printf(" last %d\n", nns.last.number);
+ printf(" segment count 0x%x\n", nns.segment_count);
+ printf(" aux_len 0x%x\n", nns.aux_len);
+ pn=nns.aux_data;
+ pn_end=nns.aux_data+nns.aux_len;
+ while (pn < pn_end) {
+ printf(" number:\n");
+ street_name_number_get(&nn, &pn);
+ printf(" len 0x%x\n", nn.len);
+ printf(" tag 0x%x\n", nn.tag);
+ printf(" coord 0x%x,0x%x\n", nn.c->x, nn.c->y);
+ printf(" first %d\n", nn.first.number);
+ printf(" last %d\n", nn.last.number);
+ }
+ }
+ }
}
#endif
-static int
-street_name_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr=priv_data;
-
- attr->type=attr_type;
- switch (attr_type) {
- case attr_street_name:
- attr->u.str=mr->street.name.name2;
- return ((attr->u.str && attr->u.str[0]) ? 1:0);
- case attr_street_name_systematic:
- attr->u.str=mr->street.name.name1;
- return ((attr->u.str && attr->u.str[0]) ? 1:0);
- case attr_town_name:
- case attr_district_name:
- case attr_postal:
- if (!mr->search_item_tmp)
- mr->search_item_tmp=map_rect_get_item_byid_mg(mr->search_mr_tmp, mr->street.name_numbers.country | (file_town_twn << 16), mr->street.name_numbers.dist);
- if (!mr->search_item_tmp)
- return 0;
- return item_attr_get(mr->search_item_tmp, attr_type, attr);
- default:
- dbg(lvl_error,"unknown attr %s\n",attr_to_name(attr_type));
- return 0;
- }
+static int street_name_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr=priv_data;
+
+ attr->type=attr_type;
+ switch (attr_type) {
+ case attr_street_name:
+ attr->u.str=mr->street.name.name2;
+ return ((attr->u.str && attr->u.str[0]) ? 1:0);
+ case attr_street_name_systematic:
+ attr->u.str=mr->street.name.name1;
+ return ((attr->u.str && attr->u.str[0]) ? 1:0);
+ case attr_town_name:
+ case attr_district_name:
+ case attr_postal:
+ if (!mr->search_item_tmp)
+ mr->search_item_tmp=map_rect_get_item_byid_mg(mr->search_mr_tmp,
+ mr->street.name_numbers.country | (file_town_twn << 16), mr->street.name_numbers.dist);
+ if (!mr->search_item_tmp)
+ return 0;
+ return item_attr_get(mr->search_item_tmp, attr_type, attr);
+ default:
+ dbg(lvl_error,"unknown attr %s",attr_to_name(attr_type));
+ return 0;
+ }
}
@@ -811,264 +720,247 @@ street_name_attr_get(void *priv_data, enum attr_type attr_type, struct attr *att
static struct item_methods street_name_meth = {
- street_name_coord_rewind,
- street_name_coord_get,
- street_name_attr_rewind,
- street_name_attr_get,
+ street_name_coord_rewind,
+ street_name_coord_get,
+ street_name_attr_rewind,
+ street_name_attr_get,
};
-int
-street_name_get_byid(struct map_rect_priv *mr, struct street_priv *street, int id_hi, int id_lo, struct item *item)
-{
- mr->current_file=id_hi >> 16;
- street->name_file=mr->m->file[mr->current_file];
- item->type=type_street_name;
- item->id_hi=id_hi;
- item->id_lo=id_lo;
- item->meth=&street_name_meth;
- item->map=NULL;
- item->priv_data=mr;
- mr->b.p=street->name_file->begin+item->id_lo;
- dbg(lvl_debug,"last %p map %p file %d begin %p\n", mr->b.p, mr->m, mr->current_file, mr->m->file[mr->current_file]->begin);
- street_name_get(&street->name, &mr->b.p);
- return 1;
-}
-
-static struct item *
-street_search_get_item_street_name(struct map_rect_priv *mr)
-{
- int dir=1,leaf;
- unsigned char *last;
-
- dbg(lvl_debug,"enter\n");
- if (! mr->search_blk_count) {
- dbg(lvl_debug,"partial 0x%x '%s' ***\n", mr->town.street_assoc, mr->search_str);
- if (mr->search_linear)
- return NULL;
- dbg(lvl_debug,"tree_search_next\n");
- mr->search_block=-1;
- while ((leaf=tree_search_next(&mr->ts, &mr->search_p, dir)) != -1) {
- dir=street_search_compare(&mr->search_p, mr);
- }
- dbg(lvl_debug,"dir=%d mr->search_block=0x%x\n", dir, mr->search_block);
- if (mr->search_block == -1)
- return NULL;
- mr->search_blk_count=1;
- block_get_byindex(mr->m->file[file_strname_stn], mr->search_block, &mr->b);
- mr->b.p=mr->b.block_start+12;
- }
- dbg(lvl_debug,"name id %td\n", mr->b.p-mr->m->file[file_strname_stn]->begin);
- if (! mr->search_blk_count)
- return NULL;
- for (;;) {
- if (mr->b.p >= mr->b.end) {
- if (!block_next_lin(mr)) {
- dbg(lvl_debug,"end of blocks in %p, %p\n", mr->m->file[file_strname_stn]->begin, mr->m->file[file_strname_stn]->end);
- return NULL;
- }
- mr->b.p=mr->b.block_start+12;
- }
- while (mr->b.p < mr->b.end) {
- last=mr->b.p;
- street_name_get(&mr->street.name, &mr->b.p);
- dir=street_search_compare_do(mr, mr->street.name.country, mr->street.name.townassoc, mr->street.name.name2);
- dbg(lvl_debug,"country 0x%x assoc 0x%x name1 '%s' name2 '%s' dir=%d\n", mr->street.name.country, mr->street.name.townassoc, mr->street.name.name1, mr->street.name.name2, dir);
- if (dir < 0) {
- dbg(lvl_debug,"end of data\n");
- mr->search_blk_count=0;
- return NULL;
- }
- if (!dir) {
- dbg(lvl_debug,"result country 0x%x assoc 0x%x name1 '%s' name2 '%s' dir=%d aux_data=%p len=0x%x\n", mr->street.name.country, mr->street.name.townassoc, mr->street.name.name1, mr->street.name.name2, dir, mr->street.name.aux_data, mr->street.name.aux_len);
- mr->item.type = type_street_name;
- mr->item.id_hi=(file_strname_stn << 16);
- mr->item.id_lo=last-mr->m->file[file_strname_stn]->begin;
- dbg(lvl_debug,"id 0x%x 0x%x last %p map %p file %d begin %p\n", mr->item.id_hi, mr->item.id_lo, last, mr->m, mr->current_file, mr->m->file[mr->current_file]->begin);
- mr->item.meth=&street_name_meth;
- mr->item.map=NULL;
- mr->item.priv_data=mr;
- /* debug(mr); */
- dbg(lvl_debug,"last %p\n",last);
- return &mr->item;
- }
- }
- }
+int street_name_get_byid(struct map_rect_priv *mr, struct street_priv *street, int id_hi, int id_lo,
+ struct item *item) {
+ mr->current_file=id_hi >> 16;
+ street->name_file=mr->m->file[mr->current_file];
+ item->type=type_street_name;
+ item->id_hi=id_hi;
+ item->id_lo=id_lo;
+ item->meth=&street_name_meth;
+ item->map=NULL;
+ item->priv_data=mr;
+ mr->b.p=street->name_file->begin+item->id_lo;
+ dbg(lvl_debug,"last %p map %p file %d begin %p", mr->b.p, mr->m, mr->current_file,
+ mr->m->file[mr->current_file]->begin);
+ street_name_get(&street->name, &mr->b.p);
+ return 1;
+}
+
+static struct item *street_search_get_item_street_name(struct map_rect_priv *mr) {
+ int dir=1,leaf;
+ unsigned char *last;
+
+ dbg(lvl_debug,"enter");
+ if (! mr->search_blk_count) {
+ dbg(lvl_debug,"partial 0x%x '%s' ***", mr->town.street_assoc, mr->search_str);
+ if (mr->search_linear)
+ return NULL;
+ dbg(lvl_debug,"tree_search_next");
+ mr->search_block=-1;
+ while ((leaf=tree_search_next(&mr->ts, &mr->search_p, dir)) != -1) {
+ dir=street_search_compare(&mr->search_p, mr);
+ }
+ dbg(lvl_debug,"dir=%d mr->search_block=0x%x", dir, mr->search_block);
+ if (mr->search_block == -1)
+ return NULL;
+ mr->search_blk_count=1;
+ block_get_byindex(mr->m->file[file_strname_stn], mr->search_block, &mr->b);
+ mr->b.p=mr->b.block_start+12;
+ }
+ dbg(lvl_debug,"name id %td", mr->b.p-mr->m->file[file_strname_stn]->begin);
+ if (! mr->search_blk_count)
+ return NULL;
+ for (;;) {
+ if (mr->b.p >= mr->b.end) {
+ if (!block_next_lin(mr)) {
+ dbg(lvl_debug,"end of blocks in %p, %p", mr->m->file[file_strname_stn]->begin, mr->m->file[file_strname_stn]->end);
+ return NULL;
+ }
+ mr->b.p=mr->b.block_start+12;
+ }
+ while (mr->b.p < mr->b.end) {
+ last=mr->b.p;
+ street_name_get(&mr->street.name, &mr->b.p);
+ dir=street_search_compare_do(mr, mr->street.name.country, mr->street.name.townassoc, mr->street.name.name2);
+ dbg(lvl_debug,"country 0x%x assoc 0x%x name1 '%s' name2 '%s' dir=%d", mr->street.name.country,
+ mr->street.name.townassoc, mr->street.name.name1, mr->street.name.name2, dir);
+ if (dir < 0) {
+ dbg(lvl_debug,"end of data");
+ mr->search_blk_count=0;
+ return NULL;
+ }
+ if (!dir) {
+ dbg(lvl_debug,"result country 0x%x assoc 0x%x name1 '%s' name2 '%s' dir=%d aux_data=%p len=0x%x",
+ mr->street.name.country, mr->street.name.townassoc, mr->street.name.name1, mr->street.name.name2, dir,
+ mr->street.name.aux_data, mr->street.name.aux_len);
+ mr->item.type = type_street_name;
+ mr->item.id_hi=(file_strname_stn << 16);
+ mr->item.id_lo=last-mr->m->file[file_strname_stn]->begin;
+ dbg(lvl_debug,"id 0x%x 0x%x last %p map %p file %d begin %p", mr->item.id_hi, mr->item.id_lo, last, mr->m,
+ mr->current_file, mr->m->file[mr->current_file]->begin);
+ mr->item.meth=&street_name_meth;
+ mr->item.map=NULL;
+ mr->item.priv_data=mr;
+ /* debug(mr); */
+ dbg(lvl_debug,"last %p",last);
+ return &mr->item;
+ }
+ }
+ }
}
struct item *
-street_search_get_item(struct map_rect_priv *mr)
-{
- struct item *item;
- for (;;) {
- if (!mr->street.name.tmp_data || street_name_eod(&mr->street.name)) {
- item=street_search_get_item_street_name(mr);
- if (!item)
- return NULL;
- if (!mr->street.name.aux_len)
- return item;
- }
- mr->item.id_hi++;
- street_name_numbers_get(&mr->street.name_numbers, &mr->street.name.tmp_data);
- mr->search_item_tmp=NULL;
- return &mr->item;
- }
-}
-
-static int
-street_name_numbers_next(struct map_rect_priv *mr)
-{
- if (street_name_eod(&mr->street.name))
- return 0;
- dbg(lvl_debug,"%p vs %p\n",mr->street.name.tmp_data, mr->street.name.aux_data);
- street_name_numbers_get(&mr->street.name_numbers, &mr->street.name.tmp_data);
- return 1;
-}
-
-static int
-street_name_number_next(struct map_rect_priv *mr)
-{
- if (street_name_numbers_eod(&mr->street.name_numbers))
- return 0;
- street_name_number_get(&mr->street.name_number, &mr->street.name_numbers.tmp_data);
- sprintf(mr->street.first_number,"%d%s",mr->street.name_number.first.number,mr->street.name_number.first.suffix);
- sprintf(mr->street.last_number,"%d%s",mr->street.name_number.last.number,mr->street.name_number.last.suffix);
- mr->street.current_number[0]='\0';
- return 1;
-}
-
-static void
-housenumber_coord_rewind(void *priv_data)
-{
- /* struct street_priv *street=priv_data; */
-
-}
-
-static void
-housenumber_attr_rewind(void *priv_data)
-{
- /* struct street_priv *street=priv_data; */
-
-}
-
-static int
-housenumber_coord_get(void *priv_data, struct coord *c, int count)
-{
- return 0;
-}
-
-static int
-housenumber_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr=priv_data;
- attr->type=attr_type;
- switch (attr_type) {
- case attr_house_number:
- attr->u.str=mr->street.current_number;
- return 1;
- case attr_town_name:
- case attr_district_name:
- case attr_postal:
- if (!mr->search_item_tmp)
- mr->search_item_tmp=map_rect_get_item_byid_mg(mr->search_mr_tmp, mr->street.name_numbers.country | (file_town_twn << 16), mr->street.name_numbers.dist);
- if (!mr->search_item_tmp)
- return 0;
- return item_attr_get(mr->search_item_tmp, attr_type, attr);
- default:
- dbg(lvl_error,"unknown attr %s\n",attr_to_name(attr_type));
- return 0;
- }
+street_search_get_item(struct map_rect_priv *mr) {
+ struct item *item;
+ for (;;) {
+ if (!mr->street.name.tmp_data || street_name_eod(&mr->street.name)) {
+ item=street_search_get_item_street_name(mr);
+ if (!item)
+ return NULL;
+ if (!mr->street.name.aux_len)
+ return item;
+ }
+ mr->item.id_hi++;
+ street_name_numbers_get(&mr->street.name_numbers, &mr->street.name.tmp_data);
+ mr->search_item_tmp=NULL;
+ return &mr->item;
+ }
+}
+
+static int street_name_numbers_next(struct map_rect_priv *mr) {
+ if (street_name_eod(&mr->street.name))
+ return 0;
+ dbg(lvl_debug,"%p vs %p",mr->street.name.tmp_data, mr->street.name.aux_data);
+ street_name_numbers_get(&mr->street.name_numbers, &mr->street.name.tmp_data);
+ return 1;
+}
+
+static int street_name_number_next(struct map_rect_priv *mr) {
+ if (street_name_numbers_eod(&mr->street.name_numbers))
+ return 0;
+ street_name_number_get(&mr->street.name_number, &mr->street.name_numbers.tmp_data);
+ sprintf(mr->street.first_number,"%d%s",mr->street.name_number.first.number,mr->street.name_number.first.suffix);
+ sprintf(mr->street.last_number,"%d%s",mr->street.name_number.last.number,mr->street.name_number.last.suffix);
+ mr->street.current_number[0]='\0';
+ return 1;
+}
+
+static void housenumber_coord_rewind(void *priv_data) {
+ /* struct street_priv *street=priv_data; */
+
+}
+
+static void housenumber_attr_rewind(void *priv_data) {
+ /* struct street_priv *street=priv_data; */
+
+}
+
+static int housenumber_coord_get(void *priv_data, struct coord *c, int count) {
+ return 0;
+}
+
+static int housenumber_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr=priv_data;
+ attr->type=attr_type;
+ switch (attr_type) {
+ case attr_house_number:
+ attr->u.str=mr->street.current_number;
+ return 1;
+ case attr_town_name:
+ case attr_district_name:
+ case attr_postal:
+ if (!mr->search_item_tmp)
+ mr->search_item_tmp=map_rect_get_item_byid_mg(mr->search_mr_tmp,
+ mr->street.name_numbers.country | (file_town_twn << 16), mr->street.name_numbers.dist);
+ if (!mr->search_item_tmp)
+ return 0;
+ return item_attr_get(mr->search_item_tmp, attr_type, attr);
+ default:
+ dbg(lvl_error,"unknown attr %s",attr_to_name(attr_type));
+ return 0;
+ }
}
static struct item_methods housenumber_meth = {
- housenumber_coord_rewind,
- housenumber_coord_get,
- housenumber_attr_rewind,
- housenumber_attr_get,
+ housenumber_coord_rewind,
+ housenumber_coord_get,
+ housenumber_attr_rewind,
+ housenumber_attr_get,
};
-int
-housenumber_search_setup(struct map_rect_priv *mr)
-{
- dbg(lvl_debug,"enter (0x%x,0x%x)\n",mr->search_item.id_hi,mr->search_item.id_lo);
- int id=mr->search_item.id_hi & 0xff;
- mr->current_file=file_strname_stn;
- mr->street.name_file=mr->m->file[mr->current_file];
- mr->b.p=mr->street.name_file->begin+mr->search_item.id_lo;
- mr->search_str=g_strdup(mr->search_attr->u.str);
- dbg(lvl_debug,"last %p\n",mr->b.p);
- street_name_get(&mr->street.name, &mr->b.p);
-#if 0
- debug(mr);
-#endif
- while (id > 0) {
- id--;
- dbg(lvl_debug,"loop\n");
- if (!street_name_numbers_next(mr))
- return 0;
- }
- mr->item.type=type_house_number;
- mr->item.priv_data=mr;
- mr->item.id_hi=mr->search_item.id_hi + 0x100;
- mr->item.meth=&housenumber_meth;
- if (!id)
- mr->item.id_hi+=1;
- mr->item.id_lo=mr->search_item.id_lo;
- dbg(lvl_debug,"getting name_number %p vs %p + %d\n",mr->street.name_numbers.tmp_data,mr->street.name_numbers.aux_data, mr->street.name_numbers.aux_len);
- if (!street_name_number_next(mr))
- return 0;
- dbg(lvl_debug,"enter\n");
- // debug(mr);
- return 1;
-}
-
-static int
-house_number_next(char *number, char *first, char *last, int interpolation, int *percentage)
-{
- int firstn=atoi(first);
- int lastn=atoi(last);
- int current,delta,len=lastn-firstn;
- if (interpolation) {
- len/=2;
- }
- if (!number[0]) {
- strcpy(number,first);
- delta=0;
- } else {
- current=atoi(number)+(interpolation ? 2:1);
- if (current > lastn)
- return 0;
- sprintf(number,"%d",current);
- delta=current-firstn;
- }
- if (percentage) {
- if (len)
- *percentage=delta*100/len;
- else
- *percentage=50;
- }
- return 1;
+int housenumber_search_setup(struct map_rect_priv *mr) {
+ dbg(lvl_debug,"enter (0x%x,0x%x)",mr->search_item.id_hi,mr->search_item.id_lo);
+ int id=mr->search_item.id_hi & 0xff;
+ mr->current_file=file_strname_stn;
+ mr->street.name_file=mr->m->file[mr->current_file];
+ mr->b.p=mr->street.name_file->begin+mr->search_item.id_lo;
+ mr->search_str=g_strdup(mr->search_attr->u.str);
+ dbg(lvl_debug,"last %p",mr->b.p);
+ street_name_get(&mr->street.name, &mr->b.p);
+ while (id > 0) {
+ id--;
+ dbg(lvl_debug,"loop");
+ if (!street_name_numbers_next(mr))
+ return 0;
+ }
+ mr->item.type=type_house_number;
+ mr->item.priv_data=mr;
+ mr->item.id_hi=mr->search_item.id_hi + 0x100;
+ mr->item.meth=&housenumber_meth;
+ if (!id)
+ mr->item.id_hi+=1;
+ mr->item.id_lo=mr->search_item.id_lo;
+ dbg(lvl_debug,"getting name_number %p vs %p + %d",mr->street.name_numbers.tmp_data,mr->street.name_numbers.aux_data,
+ mr->street.name_numbers.aux_len);
+ if (!street_name_number_next(mr))
+ return 0;
+ dbg(lvl_debug,"enter");
+ // debug(mr);
+ return 1;
+}
+
+static int house_number_next(char *number, char *first, char *last, int interpolation, int *percentage) {
+ int firstn=atoi(first);
+ int lastn=atoi(last);
+ int current,delta,len=lastn-firstn;
+ if (interpolation) {
+ len/=2;
+ }
+ if (!number[0]) {
+ strcpy(number,first);
+ delta=0;
+ } else {
+ current=atoi(number)+(interpolation ? 2:1);
+ if (current > lastn)
+ return 0;
+ sprintf(number,"%d",current);
+ delta=current-firstn;
+ }
+ if (percentage) {
+ if (len)
+ *percentage=delta*100/len;
+ else
+ *percentage=50;
+ }
+ return 1;
}
struct item *
-housenumber_search_get_item(struct map_rect_priv *mr)
-{
- int d;
- dbg(lvl_debug,"enter %s %s\n",mr->street.first_number,mr->street.last_number);
- for (;;) {
- if (!house_number_next(mr->street.current_number, mr->street.first_number, mr->street.last_number, 0, NULL)) {
- if (!street_name_number_next(mr))
- return NULL;
- continue;
- }
- if (mr->search_partial)
- d=strncasecmp(mr->search_str, mr->street.current_number, strlen(mr->search_str));
- else
- d=strcasecmp(mr->search_str, mr->street.current_number);
- if (!d) {
- mr->search_item_tmp=NULL;
- return &mr->item;
- }
- }
-}
+housenumber_search_get_item(struct map_rect_priv *mr) {
+ int d;
+ dbg(lvl_debug,"enter %s %s",mr->street.first_number,mr->street.last_number);
+ for (;;) {
+ if (!house_number_next(mr->street.current_number, mr->street.first_number, mr->street.last_number, 0, NULL)) {
+ if (!street_name_number_next(mr))
+ return NULL;
+ continue;
+ }
+ if (mr->search_partial)
+ d=strncasecmp(mr->search_str, mr->street.current_number, strlen(mr->search_str));
+ else
+ d=strcasecmp(mr->search_str, mr->street.current_number);
+ if (!d) {
+ mr->search_item_tmp=NULL;
+ return &mr->item;
+ }
+ }
+}
diff --git a/navit/map/mg/town.c b/navit/map/mg/town.c
index 0fd19be0d..b7b7eb487 100644
--- a/navit/map/mg/town.c
+++ b/navit/map/mg/town.c
@@ -24,264 +24,245 @@
-static void
-town_coord_rewind(void *priv_data)
-{
- struct town_priv *twn=priv_data;
+static void town_coord_rewind(void *priv_data) {
+ struct town_priv *twn=priv_data;
- twn->cidx=0;
+ twn->cidx=0;
}
-static int
-town_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct town_priv *twn=priv_data;
+static int town_coord_get(void *priv_data, struct coord *c, int count) {
+ struct town_priv *twn=priv_data;
- if (twn->cidx || count <= 0)
- return 0;
- twn->cidx=1;
- *c=twn->c;
- return 1;
+ if (twn->cidx || count <= 0)
+ return 0;
+ twn->cidx=1;
+ *c=twn->c;
+ return 1;
}
-static void
-town_attr_rewind(void *priv_data)
-{
- struct town_priv *twn=priv_data;
+static void town_attr_rewind(void *priv_data) {
+ struct town_priv *twn=priv_data;
- twn->aidx=0;
- twn->attr_next=attr_label;
+ twn->aidx=0;
+ twn->attr_next=attr_label;
}
-static int
-town_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct town_priv *twn=priv_data;
- int len;
+static int town_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct town_priv *twn=priv_data;
+ int len;
- attr->type=attr_type;
- switch (attr_type) {
- case attr_any:
- while (twn->attr_next != attr_none) {
- if (town_attr_get(twn, twn->attr_next, attr))
- return 1;
- }
- return 0;
- case attr_label:
- attr->u.str=twn->district;
- twn->attr_next=attr_town_name;
- if (attr->u.str[0])
- return 1;
- attr->u.str=twn->name;
- return ((attr->u.str && attr->u.str[0]) ? 1:0);
- case attr_town_name:
- attr->u.str=twn->name;
- twn->attr_next=attr_town_postal;
- return ((attr->u.str && attr->u.str[0]) ? 1:0);
- case attr_town_postal:
- case attr_postal:
- strncpy(twn->postal, twn->postal_code1, 32);
- attr->u.str=twn->postal;
- len=mg_country_postal_len(twn->country);
- if (!len)
- len=31;
- twn->postal[len]='\0';
- twn->attr_next=attr_district_name;
- return ((attr->u.str && attr->u.str[0]) ? 1:0);
- case attr_district_name:
- attr->u.str=twn->district;
- twn->attr_next=attr_debug;
- return ((attr->u.str && attr->u.str[0]) ? 1:0);
- case attr_town_streets_item:
- twn->town_attr_item.type=type_town_streets;
- twn->town_attr_item.id_hi=twn->country | (file_town_twn << 16) | 0x10000000;
- twn->town_attr_item.id_lo=twn->street_assoc;
- attr->u.item=&twn->town_attr_item;
- twn->attr_next=attr_debug;
- return 1;
- case attr_debug:
- sprintf(twn->debug, "order %d\nsize %d\nstreet_assoc 0x%x", twn->order, twn->size, twn->street_assoc);
- attr->u.str=twn->debug;
- twn->attr_next=attr_none;
- return 1;
- default:
- dbg(lvl_warning, "Don't know about attribute %d[%04X]=%s yet\n",
- attr_type, attr_type, attr_to_name(attr_type));
- return 0;
- }
- return 1;
+ attr->type=attr_type;
+ switch (attr_type) {
+ case attr_any:
+ while (twn->attr_next != attr_none) {
+ if (town_attr_get(twn, twn->attr_next, attr))
+ return 1;
+ }
+ return 0;
+ case attr_label:
+ attr->u.str=twn->district;
+ twn->attr_next=attr_town_name;
+ if (attr->u.str[0])
+ return 1;
+ attr->u.str=twn->name;
+ return ((attr->u.str && attr->u.str[0]) ? 1:0);
+ case attr_town_name:
+ attr->u.str=twn->name;
+ twn->attr_next=attr_town_postal;
+ return ((attr->u.str && attr->u.str[0]) ? 1:0);
+ case attr_town_postal:
+ case attr_postal:
+ strncpy(twn->postal, twn->postal_code1, 32);
+ attr->u.str=twn->postal;
+ len=mg_country_postal_len(twn->country);
+ if (!len)
+ len=31;
+ twn->postal[len]='\0';
+ twn->attr_next=attr_district_name;
+ return ((attr->u.str && attr->u.str[0]) ? 1:0);
+ case attr_district_name:
+ attr->u.str=twn->district;
+ twn->attr_next=attr_debug;
+ return ((attr->u.str && attr->u.str[0]) ? 1:0);
+ case attr_town_streets_item:
+ twn->town_attr_item.type=type_town_streets;
+ twn->town_attr_item.id_hi=twn->country | (file_town_twn << 16) | 0x10000000;
+ twn->town_attr_item.id_lo=twn->street_assoc;
+ attr->u.item=&twn->town_attr_item;
+ twn->attr_next=attr_debug;
+ return 1;
+ case attr_debug:
+ sprintf(twn->debug, "order %d\nsize %d\nstreet_assoc 0x%x", twn->order, twn->size, twn->street_assoc);
+ attr->u.str=twn->debug;
+ twn->attr_next=attr_none;
+ return 1;
+ default:
+ dbg(lvl_warning, "Don't know about attribute %d[%04X]=%s yet",
+ attr_type, attr_type, attr_to_name(attr_type));
+ return 0;
+ }
+ return 1;
}
static struct item_methods town_meth = {
- town_coord_rewind,
- town_coord_get,
- town_attr_rewind,
- town_attr_get,
+ town_coord_rewind,
+ town_coord_get,
+ town_attr_rewind,
+ town_attr_get,
};
-static void
-town_get_data(struct town_priv *twn, unsigned char **p)
-{
- twn->id=get_u32_unal(p);
- twn->c.x=get_u32_unal(p);
- twn->c.y=get_u32_unal(p);
- twn->name=get_string(p);
- twn->district=get_string(p);
- twn->postal_code1=get_string(p);
- twn->order=get_u8(p); /* 1-15 (19) */
- twn->country=get_u16_unal(p);
- twn->type=get_u8(p);
- twn->unknown2=get_u32_unal(p);
- twn->size=get_u8(p);
- twn->street_assoc=get_u32_unal(p);
- twn->unknown3=get_u8(p);
- twn->postal_code2=get_string(p);
- twn->unknown4=get_u32_unal(p);
-#if 0
- printf("%s\t%s\t%s\t%d\t%d\t%d\n",twn->name,twn->district,twn->postal_code1,twn->order, twn->country, twn->type);
-#endif
+static void town_get_data(struct town_priv *twn, unsigned char **p) {
+ twn->id=get_u32_unal(p);
+ twn->c.x=get_u32_unal(p);
+ twn->c.y=get_u32_unal(p);
+ twn->name=get_string(p);
+ twn->district=get_string(p);
+ twn->postal_code1=get_string(p);
+ twn->order=get_u8(p); /* 1-15 (19) */
+ twn->country=get_u16_unal(p);
+ twn->type=get_u8(p);
+ twn->unknown2=get_u32_unal(p);
+ twn->size=get_u8(p);
+ twn->street_assoc=get_u32_unal(p);
+ twn->unknown3=get_u8(p);
+ twn->postal_code2=get_string(p);
+ twn->unknown4=get_u32_unal(p);
}
- /*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */
-static unsigned char limit[]={0,1,2,2,4,6,8,10,11,13,14,14,14,20,20,20,20,20,20};
+/*0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 */
+static unsigned char limit[]= {0,1,2,2,4,6,8,10,11,13,14,14,14,20,20,20,20,20,20};
-static enum item_type town_item[]={type_town_label_5e1, type_town_label_1e2, type_town_label_2e2, type_town_label_5e2, type_town_label_1e3, type_town_label_1e3, type_town_label_2e3, type_town_label_5e3, type_town_label_1e4, type_town_label_2e4, type_town_label_5e4, type_town_label_1e5, type_town_label_1e5, type_town_label_2e5, type_town_label_5e5, type_town_label_1e6, type_town_label_2e6};
-static enum item_type district_item[]={type_district_label_5e1, type_district_label_1e2, type_district_label_2e2, type_district_label_5e2, type_district_label_1e3, type_district_label_1e3, type_district_label_2e3, type_district_label_5e3, type_district_label_1e4, type_district_label_2e4, type_district_label_5e4, type_district_label_1e5, type_district_label_1e5, type_district_label_2e5, type_district_label_5e5, type_district_label_1e6, type_district_label_2e6};
-int
-town_get(struct map_rect_priv *mr, struct town_priv *twn, struct item *item)
-{
- int size;
- for (;;) {
- if (mr->b.p >= mr->b.end)
- return 0;
- town_get_data(twn, &mr->b.p);
- twn->cidx=0;
- twn->aidx=0;
- twn->attr_next=attr_label;
- if (! mr->cur_sel || (twn->order <= limit[mr->cur_sel->order] && coord_rect_contains(&mr->cur_sel->u.c_rect,&twn->c))) {
- switch(twn->type) {
- case 1:
- size=twn->size;
- if (size >= sizeof(town_item)/sizeof(enum item_type))
- size=sizeof(town_item)/sizeof(enum item_type)-1;
- item->type=town_item[size];
- break;
- case 3:
- size=twn->size;
- if (size == 6 && twn->order < 14)
- size++;
- if (size == 5 && twn->order < 14)
- size+=2;
- if (size >= sizeof(district_item)/sizeof(enum item_type))
- size=sizeof(district_item)/sizeof(enum item_type)-1;
- item->type=district_item[size];
- break;
- case 4:
- item->type=type_port_label;
- break;
- case 9:
- item->type=type_highway_exit_label;
- break;
- default:
- printf("unknown town type 0x%x '%s' '%s' 0x%x,0x%x\n", twn->type, twn->name, twn->district, twn->c.x, twn->c.y);
- item->type=type_town_label;
- }
- if (map_selection_contains_item(mr->cur_sel, 0, item->type)) {
- item->id_hi=twn->country | (mr->current_file << 16);
- item->id_lo=twn->id;
- item->priv_data=twn;
- item->meth=&town_meth;
- return 1;
- }
- }
- }
+static enum item_type town_item[]= {type_town_label_5e1, type_town_label_1e2, type_town_label_2e2, type_town_label_5e2, type_town_label_1e3, type_town_label_1e3, type_town_label_2e3, type_town_label_5e3, type_town_label_1e4, type_town_label_2e4, type_town_label_5e4, type_town_label_1e5, type_town_label_1e5, type_town_label_2e5, type_town_label_5e5, type_town_label_1e6, type_town_label_2e6};
+static enum item_type district_item[]= {type_district_label_5e1, type_district_label_1e2, type_district_label_2e2, type_district_label_5e2, type_district_label_1e3, type_district_label_1e3, type_district_label_2e3, type_district_label_5e3, type_district_label_1e4, type_district_label_2e4, type_district_label_5e4, type_district_label_1e5, type_district_label_1e5, type_district_label_2e5, type_district_label_5e5, type_district_label_1e6, type_district_label_2e6};
+int town_get(struct map_rect_priv *mr, struct town_priv *twn, struct item *item) {
+ int size;
+ for (;;) {
+ if (mr->b.p >= mr->b.end)
+ return 0;
+ town_get_data(twn, &mr->b.p);
+ twn->cidx=0;
+ twn->aidx=0;
+ twn->attr_next=attr_label;
+ if (! mr->cur_sel || (twn->order <= limit[mr->cur_sel->order] && coord_rect_contains(&mr->cur_sel->u.c_rect,&twn->c))) {
+ switch(twn->type) {
+ case 1:
+ size=twn->size;
+ if (size >= sizeof(town_item)/sizeof(enum item_type))
+ size=sizeof(town_item)/sizeof(enum item_type)-1;
+ item->type=town_item[size];
+ break;
+ case 3:
+ size=twn->size;
+ if (size == 6 && twn->order < 14)
+ size++;
+ if (size == 5 && twn->order < 14)
+ size+=2;
+ if (size >= sizeof(district_item)/sizeof(enum item_type))
+ size=sizeof(district_item)/sizeof(enum item_type)-1;
+ item->type=district_item[size];
+ break;
+ case 4:
+ item->type=type_port_label;
+ break;
+ case 9:
+ item->type=type_highway_exit_label;
+ break;
+ default:
+ printf("unknown town type 0x%x '%s' '%s' 0x%x,0x%x\n", twn->type, twn->name, twn->district, twn->c.x, twn->c.y);
+ item->type=type_town_label;
+ }
+ if (map_selection_contains_item(mr->cur_sel, 0, item->type)) {
+ item->id_hi=twn->country | (mr->current_file << 16);
+ item->id_lo=twn->id;
+ item->priv_data=twn;
+ item->meth=&town_meth;
+ return 1;
+ }
+ }
+ }
}
-int
-town_get_byid(struct map_rect_priv *mr, struct town_priv *twn, int id_hi, int id_lo, struct item *item)
-{
- int country=id_hi & 0xffff;
- int res;
- if (!tree_search_hv(mr->m->dirname, "town", (id_lo >> 8) | (country << 24), id_lo & 0xff, &res))
- return 0;
- block_get_byindex(mr->m->file[mr->current_file], res >> 16, &mr->b);
- mr->b.p=mr->b.block_start+(res & 0xffff);
- return town_get(mr, twn, item);
+int town_get_byid(struct map_rect_priv *mr, struct town_priv *twn, int id_hi, int id_lo, struct item *item) {
+ int country=id_hi & 0xffff;
+ int res;
+ if (!tree_search_hv(mr->m->dirname, "town", (id_lo >> 8) | (country << 24), id_lo & 0xff, &res))
+ return 0;
+ block_get_byindex(mr->m->file[mr->current_file], res >> 16, &mr->b);
+ mr->b.p=mr->b.block_start+(res & 0xffff);
+ return town_get(mr, twn, item);
}
-static int
-town_search_compare(unsigned char **p, struct map_rect_priv *mr)
-{
- int country, d;
- char *name;
+static int town_search_compare(unsigned char **p, struct map_rect_priv *mr) {
+ int country, d;
+ char *name;
- if (mr->search_type == attr_town_postal) {
- mr->search_blk_count=1;
- mr->search_blk_off=(struct block_offset *)(*p);
- *p+=4;
- name=get_string(p);
- d=0;
- } else {
- country=get_u16_unal(p);
- dbg(lvl_debug,"country 0x%x ", country);
- name=get_string(p);
- dbg(lvl_debug,"name '%s' ",name);
- mr->search_blk_count=get_u32_unal(p);
- mr->search_blk_off=(struct block_offset *)(*p);
- dbg(lvl_debug,"len %d ", mr->search_blk_count);
- (*p)+=mr->search_blk_count*4;
- d=mr->search_country-country;
- }
- if (!d) {
- if (mr->search_partial)
- d=strncasecmp(mr->search_str, name, strlen(mr->search_str));
- else
- d=strcasecmp(mr->search_str, name);
- }
- dbg(lvl_debug,"%d \n",d);
- return d;
+ if (mr->search_type == attr_town_postal) {
+ mr->search_blk_count=1;
+ mr->search_blk_off=(struct block_offset *)(*p);
+ *p+=4;
+ name=get_string(p);
+ d=0;
+ } else {
+ country=get_u16_unal(p);
+ dbg(lvl_debug,"country 0x%x ", country);
+ name=get_string(p);
+ dbg(lvl_debug,"name '%s' ",name);
+ mr->search_blk_count=get_u32_unal(p);
+ mr->search_blk_off=(struct block_offset *)(*p);
+ dbg(lvl_debug,"len %d ", mr->search_blk_count);
+ (*p)+=mr->search_blk_count*4;
+ d=mr->search_country-country;
+ }
+ if (!d) {
+ if (mr->search_partial)
+ d=strncasecmp(mr->search_str, name, strlen(mr->search_str));
+ else
+ d=strcasecmp(mr->search_str, name);
+ }
+ dbg(lvl_debug,"%d ",d);
+ return d;
}
struct item *
-town_search_get_item(struct map_rect_priv *mr)
-{
- int dir=1,leaf;
+town_search_get_item(struct map_rect_priv *mr) {
+ int dir=1,leaf;
- if (! mr->search_blk_count) {
- dbg(lvl_debug,"partial %d 0x%x '%s' ***\n", mr->search_partial, mr->search_country, mr->search_str);
- if (! mr->search_linear) {
- while ((leaf=tree_search_next(&mr->ts, &mr->search_p, dir)) != -1) {
- dir=town_search_compare(&mr->search_p, mr);
- if (! dir) {
- mr->search_linear=1;
- mr->search_p=NULL;
- break;
- }
- }
- if (! mr->search_linear) {
- dbg(lvl_warning,"not found\n");
- return NULL;
- }
- }
- if (! tree_search_next_lin(&mr->ts, &mr->search_p)) {
- dbg(lvl_debug,"linear not found\n");
- return NULL;
- }
- if (town_search_compare(&mr->search_p, mr)) {
- dbg(lvl_debug,"no match\n");
- return NULL;
- }
- dbg(lvl_debug,"found %d blocks\n",mr->search_blk_count);
- }
- if (! mr->search_blk_count)
- return NULL;
- dbg(lvl_debug,"block 0x%x offset 0x%x\n", block_offset_get_block(mr->search_blk_off), block_offset_get_offset(mr->search_blk_off));
- block_get_byindex(mr->m->file[mr->current_file], block_offset_get_block(mr->search_blk_off), &mr->b);
- mr->b.p=mr->b.block_start+block_offset_get_offset(mr->search_blk_off);
- town_get(mr, &mr->town, &mr->item);
- mr->search_blk_off++;
- mr->search_blk_count--;
- return &mr->item;
+ if (! mr->search_blk_count) {
+ dbg(lvl_debug,"partial %d 0x%x '%s' ***", mr->search_partial, mr->search_country, mr->search_str);
+ if (! mr->search_linear) {
+ while ((leaf=tree_search_next(&mr->ts, &mr->search_p, dir)) != -1) {
+ dir=town_search_compare(&mr->search_p, mr);
+ if (! dir) {
+ mr->search_linear=1;
+ mr->search_p=NULL;
+ break;
+ }
+ }
+ if (! mr->search_linear) {
+ dbg(lvl_warning,"not found");
+ return NULL;
+ }
+ }
+ if (! tree_search_next_lin(&mr->ts, &mr->search_p)) {
+ dbg(lvl_debug,"linear not found");
+ return NULL;
+ }
+ if (town_search_compare(&mr->search_p, mr)) {
+ dbg(lvl_debug,"no match");
+ return NULL;
+ }
+ dbg(lvl_debug,"found %d blocks",mr->search_blk_count);
+ }
+ if (! mr->search_blk_count)
+ return NULL;
+ dbg(lvl_debug,"block 0x%x offset 0x%x", block_offset_get_block(mr->search_blk_off),
+ block_offset_get_offset(mr->search_blk_off));
+ block_get_byindex(mr->m->file[mr->current_file], block_offset_get_block(mr->search_blk_off), &mr->b);
+ mr->b.p=mr->b.block_start+block_offset_get_offset(mr->search_blk_off);
+ town_get(mr, &mr->town, &mr->item);
+ mr->search_blk_off++;
+ mr->search_blk_count--;
+ return &mr->item;
}
diff --git a/navit/map/mg/tree.c b/navit/map/mg/tree.c
index e456ca87c..baa448e3c 100644
--- a/navit/map/mg/tree.c
+++ b/navit/map/mg/tree.c
@@ -23,258 +23,285 @@
#include "mg.h"
struct tree_hdr {
- /*unsigned int addr;
- unsigned int size;
- unsigned int low;*/
- unsigned char p[12];
+ /*unsigned int addr;
+ unsigned int size;
+ unsigned int low;*/
+ unsigned char p[12];
};
-static inline unsigned int tree_hdr_get_addr(struct tree_hdr * tree) { unsigned char *p = tree->p; return get_u32(&p); }
-static inline unsigned int tree_hdr_get_size(struct tree_hdr * tree) { unsigned char *p = tree->p+4; return get_u32(&p); }
-static inline unsigned int tree_hdr_get_low(struct tree_hdr * tree) { unsigned char *p = tree->p+8; return get_u32(&p); }
+static inline unsigned int tree_hdr_get_addr(struct tree_hdr * tree) {
+ unsigned char *p = tree->p;
+ return get_u32(&p);
+}
+static inline unsigned int tree_hdr_get_size(struct tree_hdr * tree) {
+ unsigned char *p = tree->p+4;
+ return get_u32(&p);
+}
+static inline unsigned int tree_hdr_get_low(struct tree_hdr * tree) {
+ unsigned char *p = tree->p+8;
+ return get_u32(&p);
+}
struct tree_hdr_h {
-/* unsigned int addr;
- unsigned int size;*/
- unsigned char p[8];
+ /* unsigned int addr;
+ unsigned int size;*/
+ unsigned char p[8];
};
-static inline unsigned int tree_hdr_h_get_addr(struct tree_hdr_h * tree) { unsigned char *p = tree->p; return get_u32(&p); }
-static inline unsigned int tree_hdr_h_get_size(struct tree_hdr_h * tree) { unsigned char *p = tree->p+4; return get_u32(&p); }
+static inline unsigned int tree_hdr_h_get_addr(struct tree_hdr_h * tree) {
+ unsigned char *p = tree->p;
+ return get_u32(&p);
+}
+static inline unsigned int tree_hdr_h_get_size(struct tree_hdr_h * tree) {
+ unsigned char *p = tree->p+4;
+ return get_u32(&p);
+}
struct tree_leaf_h {
-/* unsigned int lower;
- unsigned int higher;
- unsigned int match;
- unsigned int value;*/
- unsigned char p[16];
+ /* unsigned int lower;
+ unsigned int higher;
+ unsigned int match;
+ unsigned int value;*/
+ unsigned char p[16];
};
-static inline unsigned int tree_leaf_h_get_lower(struct tree_leaf_h * tree) { unsigned char *p = tree->p; return get_u32(&p); }
-static inline unsigned int tree_leaf_h_get_higher(struct tree_leaf_h * tree) { unsigned char *p = tree->p+4; return get_u32(&p); }
-static inline unsigned int tree_leaf_h_get_match(struct tree_leaf_h * tree) { unsigned char *p = tree->p+8; return get_u32(&p); }
-static inline unsigned int tree_leaf_h_get_value(struct tree_leaf_h * tree) { unsigned char *p = tree->p+12; return get_u32(&p); }
+static inline unsigned int tree_leaf_h_get_lower(struct tree_leaf_h * tree) {
+ unsigned char *p = tree->p;
+ return get_u32(&p);
+}
+static inline unsigned int tree_leaf_h_get_higher(struct tree_leaf_h * tree) {
+ unsigned char *p = tree->p+4;
+ return get_u32(&p);
+}
+static inline unsigned int tree_leaf_h_get_match(struct tree_leaf_h * tree) {
+ unsigned char *p = tree->p+8;
+ return get_u32(&p);
+}
+static inline unsigned int tree_leaf_h_get_value(struct tree_leaf_h * tree) {
+ unsigned char *p = tree->p+12;
+ return get_u32(&p);
+}
struct tree_hdr_v {
- /*unsigned int count;
- unsigned int next;
- unsigned int unknown;*/
- unsigned char p[12];
+ /*unsigned int count;
+ unsigned int next;
+ unsigned int unknown;*/
+ unsigned char p[12];
};
-static inline unsigned int tree_hdr_v_get_count(struct tree_hdr_v * tree) { unsigned char *p = tree->p; return get_u32_unal(&p); }
-static inline unsigned int tree_hdr_v_get_next(struct tree_hdr_v * tree) { unsigned char *p = tree->p+4; return get_u32_unal(&p); }
-static inline unsigned int tree_hdr_v_get_unknown(struct tree_hdr_v * tree) { unsigned char *p = tree->p+8; return get_u32_unal(&p); }
+static inline unsigned int tree_hdr_v_get_count(struct tree_hdr_v * tree) {
+ unsigned char *p = tree->p;
+ return get_u32_unal(&p);
+}
+static inline unsigned int tree_hdr_v_get_next(struct tree_hdr_v * tree) {
+ unsigned char *p = tree->p+4;
+ return get_u32_unal(&p);
+}
+static inline unsigned int tree_hdr_v_get_unknown(struct tree_hdr_v * tree) {
+ unsigned char *p = tree->p+8;
+ return get_u32_unal(&p);
+}
struct tree_leaf_v {
- unsigned char key;
- /*int value;*/
- unsigned char p[4];
+ unsigned char key;
+ /*int value;*/
+ unsigned char p[4];
} __attribute__((packed));
-static inline int tree_leaf_v_get_value(struct tree_leaf_v * tree) { unsigned char *p = tree->p; return get_u32_unal(&p); }
+static inline int tree_leaf_v_get_value(struct tree_leaf_v * tree) {
+ unsigned char *p = tree->p;
+ return get_u32_unal(&p);
+}
-static int
-tree_search_h(struct file *file, unsigned int search)
-{
- unsigned char *p=file->begin,*end;
- int last,i=0,value,lower;
- struct tree_hdr_h *thdr;
- struct tree_leaf_h *tleaf;
+static int tree_search_h(struct file *file, unsigned int search) {
+ unsigned char *p=file->begin,*end;
+ int last,i=0,value,lower;
+ struct tree_hdr_h *thdr;
+ struct tree_leaf_h *tleaf;
- dbg(lvl_debug,"enter\n");
- while (i++ < 1000) {
- thdr=(struct tree_hdr_h *)p;
- p+=sizeof(*thdr);
- end=p+tree_hdr_h_get_size(thdr);
- dbg(lvl_debug,"@%td\n", p-file->begin);
- last=0;
- while (p < end) {
- tleaf=(struct tree_leaf_h *)p;
- p+=sizeof(*tleaf);
- dbg(lvl_debug,"low:0x%x high:0x%x match:0x%x val:0x%x search:0x%x\n", tree_leaf_h_get_lower(tleaf), tree_leaf_h_get_higher(tleaf), tree_leaf_h_get_match(tleaf), tree_leaf_h_get_value(tleaf), search);
- value=tree_leaf_h_get_value(tleaf);
- if (value == search)
- return tree_leaf_h_get_match(tleaf);
- if (value > search) {
- dbg(lvl_debug,"lower\n");
- lower=tree_leaf_h_get_lower(tleaf);
- if (lower)
- last=lower;
- break;
- }
- last=tree_leaf_h_get_higher(tleaf);
- }
- if (! last || last == -1)
- return 0;
- p=file->begin+last;
- }
- return 0;
+ dbg(lvl_debug,"enter");
+ while (i++ < 1000) {
+ thdr=(struct tree_hdr_h *)p;
+ p+=sizeof(*thdr);
+ end=p+tree_hdr_h_get_size(thdr);
+ dbg(lvl_debug,"@%td", p-file->begin);
+ last=0;
+ while (p < end) {
+ tleaf=(struct tree_leaf_h *)p;
+ p+=sizeof(*tleaf);
+ dbg(lvl_debug,"low:0x%x high:0x%x match:0x%x val:0x%x search:0x%x", tree_leaf_h_get_lower(tleaf),
+ tree_leaf_h_get_higher(tleaf), tree_leaf_h_get_match(tleaf), tree_leaf_h_get_value(tleaf), search);
+ value=tree_leaf_h_get_value(tleaf);
+ if (value == search)
+ return tree_leaf_h_get_match(tleaf);
+ if (value > search) {
+ dbg(lvl_debug,"lower");
+ lower=tree_leaf_h_get_lower(tleaf);
+ if (lower)
+ last=lower;
+ break;
+ }
+ last=tree_leaf_h_get_higher(tleaf);
+ }
+ if (! last || last == -1)
+ return 0;
+ p=file->begin+last;
+ }
+ return 0;
}
-static int
-tree_search_v(struct file *file, int offset, int search)
-{
- unsigned char *p=file->begin+offset;
- int i=0,count,next;
- struct tree_hdr_v *thdr;
- struct tree_leaf_v *tleaf;
- while (i++ < 1000) {
- thdr=(struct tree_hdr_v *)p;
- p+=sizeof(*thdr);
- count=tree_hdr_v_get_count(thdr);
- dbg(lvl_debug,"offset=%td count=0x%x\n", p-file->begin, count);
- while (count--) {
- tleaf=(struct tree_leaf_v *)p;
- p+=sizeof(*tleaf);
- dbg(lvl_debug,"0x%x 0x%x\n", tleaf->key, search);
- if (tleaf->key == search)
- return tree_leaf_v_get_value(tleaf);
- }
- next=tree_hdr_v_get_next(thdr);
- if (! next)
- break;
- p=file->begin+next;
- }
- return 0;
+static int tree_search_v(struct file *file, int offset, int search) {
+ unsigned char *p=file->begin+offset;
+ int i=0,count,next;
+ struct tree_hdr_v *thdr;
+ struct tree_leaf_v *tleaf;
+ while (i++ < 1000) {
+ thdr=(struct tree_hdr_v *)p;
+ p+=sizeof(*thdr);
+ count=tree_hdr_v_get_count(thdr);
+ dbg(lvl_debug,"offset=%td count=0x%x", p-file->begin, count);
+ while (count--) {
+ tleaf=(struct tree_leaf_v *)p;
+ p+=sizeof(*tleaf);
+ dbg(lvl_debug,"0x%x 0x%x", tleaf->key, search);
+ if (tleaf->key == search)
+ return tree_leaf_v_get_value(tleaf);
+ }
+ next=tree_hdr_v_get_next(thdr);
+ if (! next)
+ break;
+ p=file->begin+next;
+ }
+ return 0;
}
-int
-tree_search_hv(char *dirname, char *filename, unsigned int search_h, unsigned int search_v, int *result)
-{
- struct file *f_idx_h, *f_idx_v;
- char buffer[4096];
- int h,v;
+int tree_search_hv(char *dirname, char *filename, unsigned int search_h, unsigned int search_v, int *result) {
+ struct file *f_idx_h, *f_idx_v;
+ char buffer[4096];
+ int h,v;
- dbg(lvl_debug,"enter(%s, %s, 0x%x, 0x%x, %p)\n",dirname, filename, search_h, search_v, result);
- sprintf(buffer, "%s/%s.h1", dirname, filename);
- f_idx_h=file_create_caseinsensitive(buffer, 0);
- if ((!f_idx_h) || (!file_mmap(f_idx_h)))
- return 0;
- sprintf(buffer, "%s/%s.v1", dirname, filename);
- f_idx_v=file_create_caseinsensitive(buffer, 0);
- dbg(lvl_debug,"%p %p\n", f_idx_h, f_idx_v);
- if ((!f_idx_v) || (!file_mmap(f_idx_v))) {
- file_destroy(f_idx_h);
- return 0;
- }
- if ((h=tree_search_h(f_idx_h, search_h))) {
- dbg(lvl_debug,"h=0x%x\n", h);
- if ((v=tree_search_v(f_idx_v, h, search_v))) {
- dbg(lvl_debug,"v=0x%x\n", v);
- *result=v;
- file_destroy(f_idx_v);
- file_destroy(f_idx_h);
- dbg(lvl_debug,"return 1\n");
- return 1;
- }
- }
- file_destroy(f_idx_v);
- file_destroy(f_idx_h);
- dbg(lvl_debug,"return 0\n");
- return 0;
+ dbg(lvl_debug,"enter(%s, %s, 0x%x, 0x%x, %p)",dirname, filename, search_h, search_v, result);
+ sprintf(buffer, "%s/%s.h1", dirname, filename);
+ f_idx_h=file_create_caseinsensitive(buffer, 0);
+ if ((!f_idx_h) || (!file_mmap(f_idx_h)))
+ return 0;
+ sprintf(buffer, "%s/%s.v1", dirname, filename);
+ f_idx_v=file_create_caseinsensitive(buffer, 0);
+ dbg(lvl_debug,"%p %p", f_idx_h, f_idx_v);
+ if ((!f_idx_v) || (!file_mmap(f_idx_v))) {
+ file_destroy(f_idx_h);
+ return 0;
+ }
+ if ((h=tree_search_h(f_idx_h, search_h))) {
+ dbg(lvl_debug,"h=0x%x", h);
+ if ((v=tree_search_v(f_idx_v, h, search_v))) {
+ dbg(lvl_debug,"v=0x%x", v);
+ *result=v;
+ file_destroy(f_idx_v);
+ file_destroy(f_idx_h);
+ dbg(lvl_debug,"return 1");
+ return 1;
+ }
+ }
+ file_destroy(f_idx_v);
+ file_destroy(f_idx_h);
+ dbg(lvl_debug,"return 0");
+ return 0;
}
-static struct tree_search_node *
-tree_search_enter(struct tree_search *ts, int offset)
-{
- struct tree_search_node *tsn=&ts->nodes[++ts->curr_node];
- unsigned char *p;
- p=ts->f->begin+offset;
- tsn->hdr=(struct tree_hdr *)p;
- tsn->p=p+sizeof(struct tree_hdr);
- tsn->last=tsn->p;
- tsn->end=p+tree_hdr_get_size(tsn->hdr);
- tsn->low=tree_hdr_get_low(tsn->hdr);
- tsn->high=tree_hdr_get_low(tsn->hdr);
- dbg(lvl_debug,"pos %td addr 0x%ux size 0x%ux low 0x%ux end %tu\n", p-ts->f->begin, tree_hdr_get_addr(tsn->hdr), tree_hdr_get_size(tsn->hdr), tree_hdr_get_low(tsn->hdr), tsn->end-ts->f->begin);
- return tsn;
+static struct tree_search_node *tree_search_enter(struct tree_search *ts, int offset) {
+ struct tree_search_node *tsn=&ts->nodes[++ts->curr_node];
+ unsigned char *p;
+ p=ts->f->begin+offset;
+ tsn->hdr=(struct tree_hdr *)p;
+ tsn->p=p+sizeof(struct tree_hdr);
+ tsn->last=tsn->p;
+ tsn->end=p+tree_hdr_get_size(tsn->hdr);
+ tsn->low=tree_hdr_get_low(tsn->hdr);
+ tsn->high=tree_hdr_get_low(tsn->hdr);
+ dbg(lvl_debug,"pos %td addr 0x%ux size 0x%ux low 0x%ux end %tu", p-ts->f->begin, tree_hdr_get_addr(tsn->hdr),
+ tree_hdr_get_size(tsn->hdr), tree_hdr_get_low(tsn->hdr), tsn->end-ts->f->begin);
+ return tsn;
}
-int tree_search_next(struct tree_search *ts, unsigned char **p, int dir)
-{
- struct tree_search_node *tsn=&ts->nodes[ts->curr_node];
+int tree_search_next(struct tree_search *ts, unsigned char **p, int dir) {
+ struct tree_search_node *tsn=&ts->nodes[ts->curr_node];
- if (! *p)
- *p=tsn->p;
- dbg(lvl_debug,"next *p=%p dir=%d\n", *p, dir);
- dbg(lvl_debug,"low1=0x%x high1=0x%x\n", tsn->low, tsn->high);
- if (dir <= 0) {
- dbg(lvl_debug,"down 0x%x\n", tsn->low);
- if (tsn->low != 0xffffffff) {
- tsn=tree_search_enter(ts, tsn->low);
- *p=tsn->p;
- tsn->high=get_u32(p);
- ts->last_node=ts->curr_node;
- dbg(lvl_debug,"saving last2 %d %td\n", ts->curr_node, tsn->last-ts->f->begin);
- dbg(lvl_debug,"high2=0x%x\n", tsn->high);
- return 0;
- }
- return -1;
- }
- tsn->low=tsn->high;
- tsn->last=*p;
- tsn->high=get_u32_unal(p);
- dbg(lvl_debug,"saving last3 %d %p\n", ts->curr_node, tsn->last);
- if (*p < tsn->end)
- return (tsn->low == 0xffffffff ? 1 : 0);
- dbg(lvl_debug,"end reached high=0x%x\n",tsn->high);
- if (tsn->low != 0xffffffff) {
- dbg(lvl_debug,"low 0x%x\n", tsn->low);
- tsn=tree_search_enter(ts, tsn->low);
- *p=tsn->p;
- tsn->high=get_u32_unal(p);
- ts->last_node=ts->curr_node;
- dbg(lvl_debug,"saving last4 %d %td\n", ts->curr_node, tsn->last-ts->f->begin);
- dbg(lvl_debug,"high4=0x%x\n", tsn->high);
- return 0;
- }
- return -1;
+ if (! *p)
+ *p=tsn->p;
+ dbg(lvl_debug,"next *p=%p dir=%d", *p, dir);
+ dbg(lvl_debug,"low1=0x%x high1=0x%x", tsn->low, tsn->high);
+ if (dir <= 0) {
+ dbg(lvl_debug,"down 0x%x", tsn->low);
+ if (tsn->low != 0xffffffff) {
+ tsn=tree_search_enter(ts, tsn->low);
+ *p=tsn->p;
+ tsn->high=get_u32(p);
+ ts->last_node=ts->curr_node;
+ dbg(lvl_debug,"saving last2 %d %td", ts->curr_node, tsn->last-ts->f->begin);
+ dbg(lvl_debug,"high2=0x%x", tsn->high);
+ return 0;
+ }
+ return -1;
+ }
+ tsn->low=tsn->high;
+ tsn->last=*p;
+ tsn->high=get_u32_unal(p);
+ dbg(lvl_debug,"saving last3 %d %p", ts->curr_node, tsn->last);
+ if (*p < tsn->end)
+ return (tsn->low == 0xffffffff ? 1 : 0);
+ dbg(lvl_debug,"end reached high=0x%x",tsn->high);
+ if (tsn->low != 0xffffffff) {
+ dbg(lvl_debug,"low 0x%x", tsn->low);
+ tsn=tree_search_enter(ts, tsn->low);
+ *p=tsn->p;
+ tsn->high=get_u32_unal(p);
+ ts->last_node=ts->curr_node;
+ dbg(lvl_debug,"saving last4 %d %td", ts->curr_node, tsn->last-ts->f->begin);
+ dbg(lvl_debug,"high4=0x%x", tsn->high);
+ return 0;
+ }
+ return -1;
}
-int tree_search_next_lin(struct tree_search *ts, unsigned char **p)
-{
- struct tree_search_node *tsn=&ts->nodes[ts->curr_node];
- int high;
-
- dbg(lvl_debug,"pos=%d %td\n", ts->curr_node, *p-ts->f->begin);
- if (*p)
- ts->nodes[ts->last_node].last=*p;
- *p=tsn->last;
- for (;;) {
- high=get_u32_unal(p);
- if (*p < tsn->end) {
- ts->last_node=ts->curr_node;
- while (high != 0xffffffff) {
- tsn=tree_search_enter(ts, high);
- dbg(lvl_debug,"reload %d\n",ts->curr_node);
- high=tsn->low;
- }
- return 1;
- }
- dbg(lvl_debug,"eon %d %td %td\n", ts->curr_node, *p-ts->f->begin, tsn->end-ts->f->begin);
- if (! ts->curr_node)
- break;
- ts->curr_node--;
- tsn=&ts->nodes[ts->curr_node];
- *p=tsn->last;
- }
+int tree_search_next_lin(struct tree_search *ts, unsigned char **p) {
+ struct tree_search_node *tsn=&ts->nodes[ts->curr_node];
+ int high;
+
+ dbg(lvl_debug,"pos=%d %td", ts->curr_node, *p-ts->f->begin);
+ if (*p)
+ ts->nodes[ts->last_node].last=*p;
+ *p=tsn->last;
+ for (;;) {
+ high=get_u32_unal(p);
+ if (*p < tsn->end) {
+ ts->last_node=ts->curr_node;
+ while (high != 0xffffffff) {
+ tsn=tree_search_enter(ts, high);
+ dbg(lvl_debug,"reload %d",ts->curr_node);
+ high=tsn->low;
+ }
+ return 1;
+ }
+ dbg(lvl_debug,"eon %d %td %td", ts->curr_node, *p-ts->f->begin, tsn->end-ts->f->begin);
+ if (! ts->curr_node)
+ break;
+ ts->curr_node--;
+ tsn=&ts->nodes[ts->curr_node];
+ *p=tsn->last;
+ }
- return 0;
+ return 0;
}
-void
-tree_search_init(char *dirname, char *filename, struct tree_search *ts, int offset)
-{
- char buffer[4096];
- sprintf(buffer, "%s/%s", dirname, filename);
- ts->f=file_create_caseinsensitive(buffer, 0);
- ts->curr_node=-1;
- if (ts->f) {
- file_mmap(ts->f);
- tree_search_enter(ts, offset);
- }
+void tree_search_init(char *dirname, char *filename, struct tree_search *ts, int offset) {
+ char buffer[4096];
+ sprintf(buffer, "%s/%s", dirname, filename);
+ ts->f=file_create_caseinsensitive(buffer, 0);
+ ts->curr_node=-1;
+ if (ts->f) {
+ file_mmap(ts->f);
+ tree_search_enter(ts, offset);
+ }
}
-void
-tree_search_free(struct tree_search *ts)
-{
- if (ts->f)
- file_destroy(ts->f);
+void tree_search_free(struct tree_search *ts) {
+ if (ts->f)
+ file_destroy(ts->f);
}
diff --git a/navit/map/shapefile/shapefile.c b/navit/map/shapefile/shapefile.c
index e3eb4b723..df4d64ea5 100644
--- a/navit/map/shapefile/shapefile.c
+++ b/navit/map/shapefile/shapefile.c
@@ -42,647 +42,594 @@
#define IS_POLYGON(x) ((x).nSHPType == SHPT_POLYGON || (x).nSHPType == SHPT_POLYGONZ || (x).nSHPType == SHPT_POLYGONM)
struct map_priv {
- int id;
- char *filename;
- char *charset;
- SHPHandle hSHP;
- DBFHandle hDBF;
- int nShapeType, nEntities, nFields;
- double adfMinBound[4], adfMaxBound[4];
- struct longest_match *lm;
- char *dbfmap_data;
- struct coord offset;
- enum projection pro;
- int flags;
+ int id;
+ char *filename;
+ char *charset;
+ SHPHandle hSHP;
+ DBFHandle hDBF;
+ int nShapeType, nEntities, nFields;
+ double adfMinBound[4], adfMaxBound[4];
+ struct longest_match *lm;
+ char *dbfmap_data;
+ struct coord offset;
+ enum projection pro;
+ int flags;
};
struct map_rect_priv {
- struct map_selection *sel;
- struct map_priv *m;
- struct item item;
- int idx;
- int cidx,cidx_rewind;
- int part,part_rewind;
- int aidx;
- enum attr_type anext;
- SHPObject *psShape;
- char *str;
- char *line;
- int attr_pos;
- struct attr *attr;
+ struct map_selection *sel;
+ struct map_priv *m;
+ struct item item;
+ int idx;
+ int cidx,cidx_rewind;
+ int part,part_rewind;
+ int aidx;
+ enum attr_type anext;
+ SHPObject *psShape;
+ char *str;
+ char *line;
+ int attr_pos;
+ struct attr *attr;
};
-static void
-map_destroy_shapefile(struct map_priv *m)
-{
- dbg(lvl_debug,"map_destroy_shapefile\n");
- g_free(m);
-}
-
-static void
-shapefile_coord_rewind(void *priv_data)
-{
- struct map_rect_priv *mr=priv_data;
- mr->cidx=mr->cidx_rewind;
- mr->part=mr->part_rewind;
-}
-
-static void
-shapefile_coord(struct map_rect_priv *mr, int idx, struct coord *c)
-{
- SHPObject *psShape=mr->psShape;
- struct coord cs;
- struct coord_geo g;
-
- if (!mr->m->pro) {
- g.lng=psShape->padfX[idx]+mr->m->offset.x;
- g.lat=psShape->padfY[idx]+mr->m->offset.y;
- transform_from_geo(projection_mg, &g, c);
- } else {
- cs.x=psShape->padfX[idx]+mr->m->offset.x;
- cs.y=psShape->padfY[idx]+mr->m->offset.y;
- transform_from_to(&cs, mr->m->pro, c, projection_mg);
- }
-}
-
-static int
-shapefile_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr=priv_data;
- int ret=0;
- int idx;
-
- SHPObject *psShape=mr->psShape;
- while (count) {
- idx=mr->cidx;
- if (idx >= psShape->nVertices)
- break;
- if (mr->part+1 < psShape->nParts && idx == psShape->panPartStart[mr->part+1]) {
- if (IS_POLYGON(*psShape)) {
- mr->part++;
- shapefile_coord(mr, 0, c);
- } else if (IS_ARC(*psShape)) {
- break;
- } else {
- dbg_assert("Neither POLYGON or ARC and has parts" == NULL);
- }
- } else {
- shapefile_coord(mr, idx, c);
- mr->cidx++;
- }
- ret++;
- c++;
- count--;
- }
- return ret;
-}
-
-static void
-shapefile_attr_rewind(void *priv_data)
-{
- struct map_rect_priv *mr=priv_data;
- mr->aidx=0;
- mr->attr_pos=0;
- if (mr->m->flags & 1)
- mr->anext=attr_none;
- else
- mr->anext=attr_debug;
+static void map_destroy_shapefile(struct map_priv *m) {
+ dbg(lvl_debug,"map_destroy_shapefile");
+ g_free(m);
+}
+
+static void shapefile_coord_rewind(void *priv_data) {
+ struct map_rect_priv *mr=priv_data;
+ mr->cidx=mr->cidx_rewind;
+ mr->part=mr->part_rewind;
+}
+
+static void shapefile_coord(struct map_rect_priv *mr, int idx, struct coord *c) {
+ SHPObject *psShape=mr->psShape;
+ struct coord cs;
+ struct coord_geo g;
+
+ if (!mr->m->pro) {
+ g.lng=psShape->padfX[idx]+mr->m->offset.x;
+ g.lat=psShape->padfY[idx]+mr->m->offset.y;
+ transform_from_geo(projection_mg, &g, c);
+ } else {
+ cs.x=psShape->padfX[idx]+mr->m->offset.x;
+ cs.y=psShape->padfY[idx]+mr->m->offset.y;
+ transform_from_to(&cs, mr->m->pro, c, projection_mg);
+ }
+}
+
+static int shapefile_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr=priv_data;
+ int ret=0;
+ int idx;
+
+ SHPObject *psShape=mr->psShape;
+ while (count) {
+ idx=mr->cidx;
+ if (idx >= psShape->nVertices)
+ break;
+ if (mr->part+1 < psShape->nParts && idx == psShape->panPartStart[mr->part+1]) {
+ if (IS_POLYGON(*psShape)) {
+ mr->part++;
+ shapefile_coord(mr, 0, c);
+ } else if (IS_ARC(*psShape)) {
+ break;
+ } else {
+ dbg_assert("Neither POLYGON or ARC and has parts" == NULL);
+ }
+ } else {
+ shapefile_coord(mr, idx, c);
+ mr->cidx++;
+ }
+ ret++;
+ c++;
+ count--;
+ }
+ return ret;
+}
+
+static void shapefile_attr_rewind(void *priv_data) {
+ struct map_rect_priv *mr=priv_data;
+ mr->aidx=0;
+ mr->attr_pos=0;
+ if (mr->m->flags & 1)
+ mr->anext=attr_none;
+ else
+ mr->anext=attr_debug;
}
struct longest_match_list_item {
- void *data;
- int match_idx_count;
- int *match_idx;
+ void *data;
+ int match_idx_count;
+ int *match_idx;
};
struct longest_match_list {
- GList *longest_match_list_items;
+ GList *longest_match_list_items;
};
struct longest_match {
- GHashTable *match_hash;
- char *match_present;
- int match_present_count;
- GList *longest_match_lists;
- int longest_match_list_count;
+ GHashTable *match_hash;
+ char *match_present;
+ int match_present_count;
+ GList *longest_match_lists;
+ int longest_match_list_count;
};
-static void
-longest_match_add_match(struct longest_match *lm, struct longest_match_list_item *lmi, char *match)
-{
- int idx;
- if (!(idx=(int)(long)g_hash_table_lookup(lm->match_hash, match))) {
- idx=lm->match_present_count++;
- lm->match_present=g_renew(char, lm->match_present, lm->match_present_count);
- g_hash_table_insert(lm->match_hash, g_strdup(match), (gpointer)(long)idx);
- }
- lmi->match_idx=g_renew(int, lmi->match_idx, lmi->match_idx_count+1);
- lmi->match_idx[lmi->match_idx_count++]=idx;
-}
-
-static void
-longest_match_item_destroy(struct longest_match_list_item *lmi, long flags)
-{
- if (!lmi)
- return;
- if (flags & 2) {
- g_free(lmi->data);
- }
- g_free(lmi->match_idx);
- g_free(lmi);
+static void longest_match_add_match(struct longest_match *lm, struct longest_match_list_item *lmi, char *match) {
+ int idx;
+ if (!(idx=(int)(long)g_hash_table_lookup(lm->match_hash, match))) {
+ idx=lm->match_present_count++;
+ lm->match_present=g_renew(char, lm->match_present, lm->match_present_count);
+ g_hash_table_insert(lm->match_hash, g_strdup(match), (gpointer)(long)idx);
+ }
+ lmi->match_idx=g_renew(int, lmi->match_idx, lmi->match_idx_count+1);
+ lmi->match_idx[lmi->match_idx_count++]=idx;
}
-static struct longest_match_list_item *
-longest_match_item_new(struct longest_match_list *lml, void *data)
-{
- struct longest_match_list_item *ret=g_new0(struct longest_match_list_item,1);
- lml->longest_match_list_items=g_list_append(lml->longest_match_list_items, ret);
- ret->data=data;
-
- return ret;
-}
-
-static struct longest_match_list *
-longest_match_list_new(struct longest_match *lm)
-{
- struct longest_match_list *ret=g_new0(struct longest_match_list,1);
- lm->longest_match_lists=g_list_append(lm->longest_match_lists, ret);
- return ret;
-}
-
-static void
-longest_match_list_destroy(struct longest_match_list *lml, long flags)
-{
- if (!lml)
- return;
- if (flags & 1) {
- g_list_foreach(lml->longest_match_list_items, (GFunc)longest_match_item_destroy, (gpointer)flags);
- g_list_free(lml->longest_match_list_items);
- }
- g_free(lml);
-}
-
-static struct longest_match_list *
-longest_match_get_list(struct longest_match *lm, int list)
-{
- GList *l=lm->longest_match_lists;
- while (l && list > 0) {
- l=g_list_next(l);
- list++;
- }
- if (l)
- return l->data;
- return NULL;
-}
-
-static struct longest_match *
-longest_match_new(void)
-{
- struct longest_match *ret=g_new0(struct longest_match,1);
- ret->match_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
- ret->match_present_count=1;
- return ret;
-}
-
-static void
-longest_match_destroy(struct longest_match *lm, long flags)
-{
- if (!lm)
- return;
- if (flags & 1) {
- g_list_foreach(lm->longest_match_lists, (GFunc)longest_match_list_destroy, (gpointer)flags);
- g_list_free(lm->longest_match_lists);
- }
- g_hash_table_destroy(lm->match_hash);
- g_free(lm->match_present);
- g_free(lm);
-}
-
-static void
-longest_match_clear(struct longest_match *lm)
-{
- if (lm->match_present)
- memset(lm->match_present, 0, lm->match_present_count);
-}
-
-static void
-longest_match_add_key_value(struct longest_match *lm, char *k, char *v)
-{
- char* buffer=g_alloca(strlen(k)+strlen(v)+2);
- int idx;
-
- strcpy(buffer,"*=*");
- if ((idx=(int)(long)g_hash_table_lookup(lm->match_hash, buffer)))
- lm->match_present[idx]=1;
-
- sprintf(buffer,"%s=*", k);
- if ((idx=(int)(long)g_hash_table_lookup(lm->match_hash, buffer)))
- lm->match_present[idx]=2;
-
- sprintf(buffer,"*=%s", v);
- if ((idx=(int)(long)g_hash_table_lookup(lm->match_hash, buffer)))
- lm->match_present[idx]=2;
-
- sprintf(buffer,"%s=%s", k, v);
- if ((idx=(int)(long)g_hash_table_lookup(lm->match_hash, buffer)))
- lm->match_present[idx]=4;
-}
-
-static int
-longest_match_list_find(struct longest_match *lm, struct longest_match_list *lml, void **list, int max_list_len)
-{
- int j,longest=0,ret=0,sum,val;
- struct longest_match_list_item *curr;
- GList *l=lml->longest_match_list_items;
-
-
- while (l) {
- sum=0;
- curr=l->data;
- for (j = 0 ; j < curr->match_idx_count ; j++) {
- val=lm->match_present[curr->match_idx[j]];
- if (val)
- sum+=val;
- else {
- sum=-1;
- break;
- }
- }
- if (sum > longest) {
- longest=sum;
- ret=0;
- }
- if (sum > 0 && sum == longest && ret < max_list_len)
- list[ret++]=curr->data;
- l=g_list_next(l);
- }
- return ret;
-}
-
-
-static void
-build_match(struct longest_match *lm, struct longest_match_list *lml, char *line)
-{
- struct longest_match_list_item *lmli;
- char *kvl=NULL,*i=NULL,*p,*kv;
- dbg(lvl_debug,"line=%s\n",line);
- kvl=line;
- p=strchr(line,'\t');
- if (p) {
- while (*p == '\t')
- *p++='\0';
- i=p;
- }
- lmli=longest_match_item_new(lml,g_strdup(i));
- while ((kv=strtok(kvl, ","))) {
- kvl=NULL;
- longest_match_add_match(lm, lmli, kv);
- }
-}
-
-static void
-build_matches(struct map_priv *m,char *matches)
-{
- char *matches2=g_strdup(matches);
- char *l=matches2,*p;
- struct longest_match_list *lml;
-
- m->lm=longest_match_new();
- lml=longest_match_list_new(m->lm);
- while (l) {
- p=strchr(l,'\n');
- if (p)
- *p++='\0';
- if (strlen(l))
- build_match(m->lm,lml,l);
- l=p;
- }
- g_free(matches2);
-}
-
-static void
-process_fields(struct map_priv *m, int id)
-{
- int i;
- char szTitle[12],*str;
- int nWidth, nDecimals;
-
- for (i = 0 ; i < m->nFields ; i++) {
-
- switch (DBFGetFieldInfo(m->hDBF, i, szTitle, &nWidth, &nDecimals )) {
- case FTString:
- str=g_strdup(DBFReadStringAttribute( m->hDBF, id, i ));
- break;
- case FTInteger:
- str=g_strdup_printf("%d",DBFReadIntegerAttribute( m->hDBF, id, i ));
- break;
- case FTDouble:
- str=g_strdup_printf("%lf",DBFReadDoubleAttribute( m->hDBF, id, i ));
- break;
- case FTInvalid:
- str=NULL;
- break;
- default:
- str=NULL;
- }
- longest_match_add_key_value(m->lm, szTitle, str);
- }
-}
-
-static int
-attr_resolve(struct map_rect_priv *mr, enum attr_type attr_type, struct attr *attr)
-{
- char name[1024];
- char value[1024];
- char szTitle[12];
- const char *str;
- char *col,*type=NULL;
- int i,len, nWidth, nDecimals;
- if (!mr->line)
- return 0;
- if (attr_type != attr_any)
- type=attr_to_name(attr_type);
- if (attr_from_line(mr->line,type,&mr->attr_pos,value,name)) {
- len=strlen(value);
- if (value[0] == '$' && value[1] == '{' && value[len-1] == '}') {
- int found=0;
- value[len-1]='\0';
- col=value+2;
- for (i = 0 ; i < mr->m->nFields ; i++) {
- if (DBFGetFieldInfo(mr->m->hDBF, i, szTitle, &nWidth, &nDecimals ) == FTString && !strcmp(szTitle,col)) {
- str=DBFReadStringAttribute( mr->m->hDBF, mr->item.id_hi, i);
- strcpy(value,str);
- found=1;
- break;
- }
- }
- if (!found)
- value[0]='\0';
- }
- if (!value[0])
- return -1;
- dbg(lvl_debug,"name=%s value=%s\n",name,value);
- attr_free(mr->attr);
- mr->attr=attr_new_from_text(name,value);
- if (mr->attr) {
- *attr=*mr->attr;
- return 1;
- }
- return -1;
- }
- return 0;
-}
-
-static int
-shapefile_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr=priv_data;
- struct map_priv *m=mr->m;
- char szTitle[12],*pszTypeName, *str;
- int code, ret, nWidth, nDecimals;
-
- attr->type=attr_type;
- switch (attr_type) {
- case attr_any:
- while ((code=attr_resolve(mr, attr_type, attr))) {
- if (code == 1)
- return 1;
- }
- while (mr->anext != attr_none) {
- ret=shapefile_attr_get(priv_data, mr->anext, attr);
- if (ret)
- return ret;
- }
- return 0;
- case attr_debug:
- if (mr->aidx >= m->nFields) {
- mr->anext=attr_none;
- return 0;
- }
- switch (DBFGetFieldInfo(m->hDBF, mr->aidx, szTitle, &nWidth, &nDecimals )) {
- case FTString:
- pszTypeName = "String";
- str=g_strdup(DBFReadStringAttribute( m->hDBF, mr->item.id_hi, mr->aidx ));
- break;
- case FTInteger:
- pszTypeName = "Integer";
- str=g_strdup_printf("%d",DBFReadIntegerAttribute( m->hDBF, mr->item.id_hi, mr->aidx ));
- break;
- case FTDouble:
- pszTypeName = "Double";
- str=g_strdup_printf("%lf",DBFReadDoubleAttribute( m->hDBF, mr->item.id_hi, mr->aidx ));
- break;
- case FTInvalid:
- pszTypeName = "Invalid";
- str=NULL;
- break;
- default:
- pszTypeName = "Unknown";
- str=NULL;
- }
- g_free(mr->str);
- mr->str=attr->u.str=g_strdup_printf("%s=%s(%s)",szTitle,str,pszTypeName);
- g_free(str);
- mr->aidx++;
- return 1;
- default:
- return (attr_resolve(mr, attr_type, attr) == 1);
- }
+static void longest_match_item_destroy(struct longest_match_list_item *lmi, long flags) {
+ if (!lmi)
+ return;
+ if (flags & 2) {
+ g_free(lmi->data);
+ }
+ g_free(lmi->match_idx);
+ g_free(lmi);
+}
+
+static struct longest_match_list_item *longest_match_item_new(struct longest_match_list *lml, void *data) {
+ struct longest_match_list_item *ret=g_new0(struct longest_match_list_item,1);
+ lml->longest_match_list_items=g_list_append(lml->longest_match_list_items, ret);
+ ret->data=data;
+
+ return ret;
+}
+
+static struct longest_match_list *longest_match_list_new(struct longest_match *lm) {
+ struct longest_match_list *ret=g_new0(struct longest_match_list,1);
+ lm->longest_match_lists=g_list_append(lm->longest_match_lists, ret);
+ return ret;
+}
+
+static void longest_match_list_destroy(struct longest_match_list *lml, long flags) {
+ if (!lml)
+ return;
+ if (flags & 1) {
+ g_list_foreach(lml->longest_match_list_items, (GFunc)longest_match_item_destroy, (gpointer)flags);
+ g_list_free(lml->longest_match_list_items);
+ }
+ g_free(lml);
+}
+
+static struct longest_match_list *longest_match_get_list(struct longest_match *lm, int list) {
+ GList *l=lm->longest_match_lists;
+ while (l && list > 0) {
+ l=g_list_next(l);
+ list++;
+ }
+ if (l)
+ return l->data;
+ return NULL;
+}
+
+static struct longest_match *longest_match_new(void) {
+ struct longest_match *ret=g_new0(struct longest_match,1);
+ ret->match_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ ret->match_present_count=1;
+ return ret;
+}
+
+static void longest_match_destroy(struct longest_match *lm, long flags) {
+ if (!lm)
+ return;
+ if (flags & 1) {
+ g_list_foreach(lm->longest_match_lists, (GFunc)longest_match_list_destroy, (gpointer)flags);
+ g_list_free(lm->longest_match_lists);
+ }
+ g_hash_table_destroy(lm->match_hash);
+ g_free(lm->match_present);
+ g_free(lm);
+}
+
+static void longest_match_clear(struct longest_match *lm) {
+ if (lm->match_present)
+ memset(lm->match_present, 0, lm->match_present_count);
+}
+
+static void longest_match_add_key_value(struct longest_match *lm, char *k, char *v) {
+ char* buffer=g_alloca(strlen(k)+strlen(v)+2);
+ int idx;
+
+ strcpy(buffer,"*=*");
+ if ((idx=(int)(long)g_hash_table_lookup(lm->match_hash, buffer)))
+ lm->match_present[idx]=1;
+
+ sprintf(buffer,"%s=*", k);
+ if ((idx=(int)(long)g_hash_table_lookup(lm->match_hash, buffer)))
+ lm->match_present[idx]=2;
+
+ sprintf(buffer,"*=%s", v);
+ if ((idx=(int)(long)g_hash_table_lookup(lm->match_hash, buffer)))
+ lm->match_present[idx]=2;
+
+ sprintf(buffer,"%s=%s", k, v);
+ if ((idx=(int)(long)g_hash_table_lookup(lm->match_hash, buffer)))
+ lm->match_present[idx]=4;
+}
+
+static int longest_match_list_find(struct longest_match *lm, struct longest_match_list *lml, void **list,
+ int max_list_len) {
+ int j,longest=0,ret=0,sum,val;
+ struct longest_match_list_item *curr;
+ GList *l=lml->longest_match_list_items;
+
+
+ while (l) {
+ sum=0;
+ curr=l->data;
+ for (j = 0 ; j < curr->match_idx_count ; j++) {
+ val=lm->match_present[curr->match_idx[j]];
+ if (val)
+ sum+=val;
+ else {
+ sum=-1;
+ break;
+ }
+ }
+ if (sum > longest) {
+ longest=sum;
+ ret=0;
+ }
+ if (sum > 0 && sum == longest && ret < max_list_len)
+ list[ret++]=curr->data;
+ l=g_list_next(l);
+ }
+ return ret;
+}
+
+
+static void build_match(struct longest_match *lm, struct longest_match_list *lml, char *line) {
+ struct longest_match_list_item *lmli;
+ char *kvl=NULL,*i=NULL,*p,*kv;
+ dbg(lvl_debug,"line=%s",line);
+ kvl=line;
+ p=strchr(line,'\t');
+ if (p) {
+ while (*p == '\t')
+ *p++='\0';
+ i=p;
+ }
+ lmli=longest_match_item_new(lml,g_strdup(i));
+ while ((kv=strtok(kvl, ","))) {
+ kvl=NULL;
+ longest_match_add_match(lm, lmli, kv);
+ }
+}
+
+static void build_matches(struct map_priv *m,char *matches) {
+ char *matches2=g_strdup(matches);
+ char *l=matches2,*p;
+ struct longest_match_list *lml;
+
+ m->lm=longest_match_new();
+ lml=longest_match_list_new(m->lm);
+ while (l) {
+ p=strchr(l,'\n');
+ if (p)
+ *p++='\0';
+ if (strlen(l))
+ build_match(m->lm,lml,l);
+ l=p;
+ }
+ g_free(matches2);
+}
+
+static void process_fields(struct map_priv *m, int id) {
+ int i;
+ char szTitle[12],*str;
+ int nWidth, nDecimals;
+
+ for (i = 0 ; i < m->nFields ; i++) {
+
+ switch (DBFGetFieldInfo(m->hDBF, i, szTitle, &nWidth, &nDecimals )) {
+ case FTString:
+ str=g_strdup(DBFReadStringAttribute( m->hDBF, id, i ));
+ break;
+ case FTInteger:
+ str=g_strdup_printf("%d",DBFReadIntegerAttribute( m->hDBF, id, i ));
+ break;
+ case FTDouble:
+ str=g_strdup_printf("%lf",DBFReadDoubleAttribute( m->hDBF, id, i ));
+ break;
+ case FTInvalid:
+ str=NULL;
+ break;
+ default:
+ str=NULL;
+ }
+ longest_match_add_key_value(m->lm, szTitle, str);
+ }
+}
+
+static int attr_resolve(struct map_rect_priv *mr, enum attr_type attr_type, struct attr *attr) {
+ char name[1024];
+ char value[1024];
+ char szTitle[12];
+ const char *str;
+ char *col,*type=NULL;
+ int i,len, nWidth, nDecimals;
+ if (!mr->line)
+ return 0;
+ if (attr_type != attr_any)
+ type=attr_to_name(attr_type);
+ if (attr_from_line(mr->line,type,&mr->attr_pos,value,name)) {
+ len=strlen(value);
+ if (value[0] == '$' && value[1] == '{' && value[len-1] == '}') {
+ int found=0;
+ value[len-1]='\0';
+ col=value+2;
+ for (i = 0 ; i < mr->m->nFields ; i++) {
+ if (DBFGetFieldInfo(mr->m->hDBF, i, szTitle, &nWidth, &nDecimals ) == FTString && !strcmp(szTitle,col)) {
+ str=DBFReadStringAttribute( mr->m->hDBF, mr->item.id_hi, i);
+ strcpy(value,str);
+ found=1;
+ break;
+ }
+ }
+ if (!found)
+ value[0]='\0';
+ }
+ if (!value[0])
+ return -1;
+ dbg(lvl_debug,"name=%s value=%s",name,value);
+ attr_free(mr->attr);
+ mr->attr=attr_new_from_text(name,value);
+ if (mr->attr) {
+ *attr=*mr->attr;
+ return 1;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+static int shapefile_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr=priv_data;
+ struct map_priv *m=mr->m;
+ char szTitle[12],*pszTypeName, *str;
+ int code, ret, nWidth, nDecimals;
+
+ attr->type=attr_type;
+ switch (attr_type) {
+ case attr_any:
+ while ((code=attr_resolve(mr, attr_type, attr))) {
+ if (code == 1)
+ return 1;
+ }
+ while (mr->anext != attr_none) {
+ ret=shapefile_attr_get(priv_data, mr->anext, attr);
+ if (ret)
+ return ret;
+ }
+ return 0;
+ case attr_debug:
+ if (mr->aidx >= m->nFields) {
+ mr->anext=attr_none;
+ return 0;
+ }
+ switch (DBFGetFieldInfo(m->hDBF, mr->aidx, szTitle, &nWidth, &nDecimals )) {
+ case FTString:
+ pszTypeName = "String";
+ str=g_strdup(DBFReadStringAttribute( m->hDBF, mr->item.id_hi, mr->aidx ));
+ break;
+ case FTInteger:
+ pszTypeName = "Integer";
+ str=g_strdup_printf("%d",DBFReadIntegerAttribute( m->hDBF, mr->item.id_hi, mr->aidx ));
+ break;
+ case FTDouble:
+ pszTypeName = "Double";
+ str=g_strdup_printf("%lf",DBFReadDoubleAttribute( m->hDBF, mr->item.id_hi, mr->aidx ));
+ break;
+ case FTInvalid:
+ pszTypeName = "Invalid";
+ str=NULL;
+ break;
+ default:
+ pszTypeName = "Unknown";
+ str=NULL;
+ }
+ g_free(mr->str);
+ mr->str=attr->u.str=g_strdup_printf("%s=%s(%s)",szTitle,str,pszTypeName);
+ g_free(str);
+ mr->aidx++;
+ return 1;
+ default:
+ return (attr_resolve(mr, attr_type, attr) == 1);
+ }
}
static struct item_methods methods_shapefile = {
- shapefile_coord_rewind,
- shapefile_coord_get,
- shapefile_attr_rewind,
- shapefile_attr_get,
+ shapefile_coord_rewind,
+ shapefile_coord_get,
+ shapefile_attr_rewind,
+ shapefile_attr_get,
};
-static struct map_rect_priv *
-map_rect_new_shapefile(struct map_priv *map, struct map_selection *sel)
-{
- struct map_rect_priv *mr;
- char *dbfmapfile=g_strdup_printf("%s.dbfmap", map->filename);
- void *data;
- struct file *file;
- int size;
- int changed=0;
- if ((file=file_create(dbfmapfile, 0))) {
- size=file_size(file);
- data=file_data_read_all(file);
- if (data) {
- if (!map->dbfmap_data || size != strlen(map->dbfmap_data) || strncmp(data,map->dbfmap_data,size)) {
- g_free(map->dbfmap_data);
- map->dbfmap_data=g_malloc(size+1);
- memcpy(map->dbfmap_data, data, size);
- map->dbfmap_data[size]='\0';
- changed=1;
- }
- file_data_free(file, data);
- }
- file_destroy(file);
- } else {
- dbg(lvl_error,"Failed to open %s\n",dbfmapfile);
- if (map->dbfmap_data) {
- changed=1;
- g_free(map->dbfmap_data);
- map->dbfmap_data=NULL;
- }
- }
- dbg(lvl_debug,"%s changed %d old %p\n",dbfmapfile,changed,map->dbfmap_data);
- if (changed) {
- longest_match_destroy(map->lm,1);
- map->lm=NULL;
- if (map->dbfmap_data) {
- build_matches(map,map->dbfmap_data);
- }
- }
- dbg(lvl_debug,"map_rect_new_shapefile\n");
- mr=g_new0(struct map_rect_priv, 1);
- mr->m=map;
- mr->idx=0;
- mr->item.id_lo=0;
- mr->item.id_hi=0;
- mr->item.meth=&methods_shapefile;
- mr->item.priv_data=mr;
- g_free(dbfmapfile);
- return mr;
-}
-
-
-static void
-map_rect_destroy_shapefile(struct map_rect_priv *mr)
-{
- if (mr->psShape)
- SHPDestroyObject(mr->psShape);
- attr_free(mr->attr);
- g_free(mr->str);
- g_free(mr);
-}
-
-static struct item *
-map_rect_get_item_shapefile(struct map_rect_priv *mr)
-{
- struct map_priv *m=mr->m;
- void *lines[5];
- struct longest_match_list *lml;
- int count;
- char type[1024];
-
- if (mr->psShape && IS_ARC(*mr->psShape) && mr->part+1 < mr->psShape->nParts) {
- mr->part++;
- mr->part_rewind=mr->part;
- mr->cidx_rewind=mr->psShape->panPartStart[mr->part];
- } else {
- if (mr->idx >= m->nEntities)
- return NULL;
- mr->item.id_hi=mr->idx;
- if (mr->psShape)
- SHPDestroyObject(mr->psShape);
- mr->psShape=SHPReadObject(m->hSHP, mr->idx);
- if (mr->psShape->nVertices > 1)
- mr->item.type=type_street_unkn;
- else
- mr->item.type=type_point_unkn;
- if (m->lm) {
- longest_match_clear(m->lm);
- process_fields(m, mr->idx);
-
- lml=longest_match_get_list(m->lm, 0);
- count=longest_match_list_find(m->lm, lml, lines, sizeof(lines)/sizeof(void *));
- if (count) {
- mr->line=lines[0];
- if (attr_from_line(mr->line,"type",NULL,type,NULL)) {
- dbg(lvl_debug,"type='%s'\n", type);
- mr->item.type=item_from_name(type);
- if (mr->item.type == type_none && strcmp(type,"none"))
- dbg(lvl_error,"Warning: type '%s' unknown\n", type);
- } else {
- dbg(lvl_debug,"failed to get attribute type\n");
- }
- } else
- mr->line=NULL;
- }
- mr->idx++;
- mr->part_rewind=0;
- mr->cidx_rewind=0;
- }
- shapefile_coord_rewind(mr);
- shapefile_attr_rewind(mr);
- return &mr->item;
-}
-
-static struct item *
-map_rect_get_item_byid_shapefile(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- mr->idx=id_hi;
- while (id_lo--) {
- if (!map_rect_get_item_shapefile(mr))
- return NULL;
- }
- return map_rect_get_item_shapefile(mr);
+static struct map_rect_priv *map_rect_new_shapefile(struct map_priv *map, struct map_selection *sel) {
+ struct map_rect_priv *mr;
+ char *dbfmapfile=g_strdup_printf("%s.dbfmap", map->filename);
+ void *data;
+ struct file *file;
+ int size;
+ int changed=0;
+ if ((file=file_create(dbfmapfile, 0))) {
+ size=file_size(file);
+ data=file_data_read_all(file);
+ if (data) {
+ if (!map->dbfmap_data || size != strlen(map->dbfmap_data) || strncmp(data,map->dbfmap_data,size)) {
+ g_free(map->dbfmap_data);
+ map->dbfmap_data=g_malloc(size+1);
+ memcpy(map->dbfmap_data, data, size);
+ map->dbfmap_data[size]='\0';
+ changed=1;
+ }
+ file_data_free(file, data);
+ }
+ file_destroy(file);
+ } else {
+ dbg(lvl_error,"Failed to open %s",dbfmapfile);
+ if (map->dbfmap_data) {
+ changed=1;
+ g_free(map->dbfmap_data);
+ map->dbfmap_data=NULL;
+ }
+ }
+ dbg(lvl_debug,"%s changed %d old %p",dbfmapfile,changed,map->dbfmap_data);
+ if (changed) {
+ longest_match_destroy(map->lm,1);
+ map->lm=NULL;
+ if (map->dbfmap_data) {
+ build_matches(map,map->dbfmap_data);
+ }
+ }
+ dbg(lvl_debug,"map_rect_new_shapefile");
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->m=map;
+ mr->idx=0;
+ mr->item.id_lo=0;
+ mr->item.id_hi=0;
+ mr->item.meth=&methods_shapefile;
+ mr->item.priv_data=mr;
+ g_free(dbfmapfile);
+ return mr;
+}
+
+
+static void map_rect_destroy_shapefile(struct map_rect_priv *mr) {
+ if (mr->psShape)
+ SHPDestroyObject(mr->psShape);
+ attr_free(mr->attr);
+ g_free(mr->str);
+ g_free(mr);
+}
+
+static struct item *map_rect_get_item_shapefile(struct map_rect_priv *mr) {
+ struct map_priv *m=mr->m;
+ void *lines[5];
+ struct longest_match_list *lml;
+ int count;
+ char type[1024];
+
+ if (mr->psShape && IS_ARC(*mr->psShape) && mr->part+1 < mr->psShape->nParts) {
+ mr->part++;
+ mr->part_rewind=mr->part;
+ mr->cidx_rewind=mr->psShape->panPartStart[mr->part];
+ } else {
+ if (mr->idx >= m->nEntities)
+ return NULL;
+ mr->item.id_hi=mr->idx;
+ if (mr->psShape)
+ SHPDestroyObject(mr->psShape);
+ mr->psShape=SHPReadObject(m->hSHP, mr->idx);
+ if (mr->psShape->nVertices > 1)
+ mr->item.type=type_street_unkn;
+ else
+ mr->item.type=type_point_unkn;
+ if (m->lm) {
+ longest_match_clear(m->lm);
+ process_fields(m, mr->idx);
+
+ lml=longest_match_get_list(m->lm, 0);
+ count=longest_match_list_find(m->lm, lml, lines, sizeof(lines)/sizeof(void *));
+ if (count) {
+ mr->line=lines[0];
+ if (attr_from_line(mr->line,"type",NULL,type,NULL)) {
+ dbg(lvl_debug,"type='%s'", type);
+ mr->item.type=item_from_name(type);
+ if (mr->item.type == type_none && strcmp(type,"none"))
+ dbg(lvl_error,"Warning: type '%s' unknown", type);
+ } else {
+ dbg(lvl_debug,"failed to get attribute type");
+ }
+ } else
+ mr->line=NULL;
+ }
+ mr->idx++;
+ mr->part_rewind=0;
+ mr->cidx_rewind=0;
+ }
+ shapefile_coord_rewind(mr);
+ shapefile_attr_rewind(mr);
+ return &mr->item;
+}
+
+static struct item *map_rect_get_item_byid_shapefile(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ mr->idx=id_hi;
+ while (id_lo--) {
+ if (!map_rect_get_item_shapefile(mr))
+ return NULL;
+ }
+ return map_rect_get_item_shapefile(mr);
}
static struct map_methods map_methods_shapefile = {
- projection_mg,
- "iso8859-1",
- map_destroy_shapefile,
- map_rect_new_shapefile,
- map_rect_destroy_shapefile,
- map_rect_get_item_shapefile,
- map_rect_get_item_byid_shapefile,
+ projection_mg,
+ "iso8859-1",
+ map_destroy_shapefile,
+ map_rect_new_shapefile,
+ map_rect_destroy_shapefile,
+ map_rect_get_item_shapefile,
+ map_rect_get_item_byid_shapefile,
};
-static struct map_priv *
-map_new_shapefile(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct map_priv *m;
- struct attr *data=attr_search(attrs, NULL, attr_data);
- struct attr *charset=attr_search(attrs, NULL, attr_charset);
- struct attr *projectionname=attr_search(attrs, NULL, attr_projectionname);
- struct attr *flags=attr_search(attrs, NULL, attr_flags);
- struct file_wordexp *wexp;
- char *wdata;
- char **wexp_data;
- char *shapefile,*dbffile;
- if (! data)
- return NULL;
- dbg(lvl_debug,"map_new_shapefile %s\n", data->u.str);
- wdata=g_strdup(data->u.str);
- wexp=file_wordexp_new(wdata);
- wexp_data=file_wordexp_get_array(wexp);
- *meth=map_methods_shapefile;
-
- m=g_new0(struct map_priv, 1);
- m->filename=g_strdup(wexp_data[0]);
- shapefile=g_strdup_printf("%s.shp", m->filename);
- m->hSHP=SHPOpen(shapefile, "rb" );
- SHPGetInfo( m->hSHP, &m->nEntities, &m->nShapeType, m->adfMinBound, m->adfMaxBound );
- g_free(shapefile);
- dbffile=g_strdup_printf("%s.dbf", m->filename);
- m->hDBF=DBFOpen(dbffile, "rb");
- m->nFields=DBFGetFieldCount(m->hDBF);
- g_free(dbffile);
- dbg(lvl_debug,"map_new_shapefile %s %s\n", m->filename, wdata);
- if (charset) {
- m->charset=g_strdup(charset->u.str);
- meth->charset=m->charset;
- }
- if (projectionname)
- m->pro=projection_from_name(projectionname->u.str, &m->offset);
- if (flags)
- m->flags=flags->u.num;
- file_wordexp_destroy(wexp);
- return m;
-}
-
-void
-plugin_init(void)
-{
- dbg(lvl_debug,"shapefile: plugin_init\n");
- plugin_register_category_map("shapefile", map_new_shapefile);
+static struct map_priv *map_new_shapefile(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *m;
+ struct attr *data=attr_search(attrs, NULL, attr_data);
+ struct attr *charset=attr_search(attrs, NULL, attr_charset);
+ struct attr *projectionname=attr_search(attrs, NULL, attr_projectionname);
+ struct attr *flags=attr_search(attrs, NULL, attr_flags);
+ struct file_wordexp *wexp;
+ char *wdata;
+ char **wexp_data;
+ char *shapefile,*dbffile;
+ if (! data)
+ return NULL;
+ dbg(lvl_debug,"map_new_shapefile %s", data->u.str);
+ wdata=g_strdup(data->u.str);
+ wexp=file_wordexp_new(wdata);
+ wexp_data=file_wordexp_get_array(wexp);
+ *meth=map_methods_shapefile;
+
+ m=g_new0(struct map_priv, 1);
+ m->filename=g_strdup(wexp_data[0]);
+ shapefile=g_strdup_printf("%s.shp", m->filename);
+ m->hSHP=SHPOpen(shapefile, "rb" );
+ SHPGetInfo( m->hSHP, &m->nEntities, &m->nShapeType, m->adfMinBound, m->adfMaxBound );
+ g_free(shapefile);
+ dbffile=g_strdup_printf("%s.dbf", m->filename);
+ m->hDBF=DBFOpen(dbffile, "rb");
+ m->nFields=DBFGetFieldCount(m->hDBF);
+ g_free(dbffile);
+ dbg(lvl_debug,"map_new_shapefile %s %s", m->filename, wdata);
+ if (charset) {
+ m->charset=g_strdup(charset->u.str);
+ meth->charset=m->charset;
+ }
+ if (projectionname)
+ m->pro=projection_from_name(projectionname->u.str, &m->offset);
+ if (flags)
+ m->flags=flags->u.num;
+ file_wordexp_destroy(wexp);
+ return m;
+}
+
+void plugin_init(void) {
+ dbg(lvl_debug,"shapefile: plugin_init");
+ plugin_register_category_map("shapefile", map_new_shapefile);
}
/************************************************************************/
@@ -692,7 +639,7 @@ plugin_init(void)
static SAFile VSI_SHP_Open( const char *pszFilename, const char *pszAccess )
{
- return (SAFile)fopen(pszFilename, pszAccess);
+ return (SAFile)fopen(pszFilename, pszAccess);
}
/************************************************************************/
@@ -702,7 +649,7 @@ static SAFile VSI_SHP_Open( const char *pszFilename, const char *pszAccess )
static SAOffset VSI_SHP_Read( void *p, SAOffset size, SAOffset nmemb, SAFile file )
{
- return fread(p, size, nmemb, (FILE *)file);
+ return fread(p, size, nmemb, (FILE *)file);
}
/************************************************************************/
@@ -712,7 +659,7 @@ static SAOffset VSI_SHP_Read( void *p, SAOffset size, SAOffset nmemb, SAFile fil
static SAOffset VSI_SHP_Write( void *p, SAOffset size, SAOffset nmemb, SAFile file )
{
- return fwrite(p, size, nmemb, (FILE *)file);
+ return fwrite(p, size, nmemb, (FILE *)file);
}
/************************************************************************/
@@ -722,7 +669,7 @@ static SAOffset VSI_SHP_Write( void *p, SAOffset size, SAOffset nmemb, SAFile fi
static SAOffset VSI_SHP_Seek( SAFile file, SAOffset offset, int whence )
{
- return fseek((FILE *)file, offset, whence);
+ return fseek((FILE *)file, offset, whence);
}
/************************************************************************/
@@ -732,14 +679,14 @@ static SAOffset VSI_SHP_Seek( SAFile file, SAOffset offset, int whence )
static SAOffset VSI_SHP_Tell( SAFile file )
{
- return ftell((FILE *)file);
+ return ftell((FILE *)file);
}
static int VSI_SHP_Flush( SAFile file )
{
- return fflush((FILE *)file);
+ return fflush((FILE *)file);
}
/************************************************************************/
@@ -749,7 +696,7 @@ static int VSI_SHP_Flush( SAFile file )
static int VSI_SHP_Close( SAFile file )
{
- return fclose((FILE *)file);
+ return fclose((FILE *)file);
}
/************************************************************************/
@@ -759,7 +706,7 @@ static int VSI_SHP_Close( SAFile file )
static void VSI_SHP_Error( const char *message )
{
- dbg(lvl_error,"error:%s\n", message);
+ dbg(lvl_error,"error:%s", message);
}
/************************************************************************/
@@ -769,7 +716,7 @@ static void VSI_SHP_Error( const char *message )
static int VSI_SHP_Remove( const char *pszFilename )
{
- return unlink(pszFilename);
+ return unlink(pszFilename);
}
/************************************************************************/
diff --git a/navit/map/textfile/textfile.c b/navit/map/textfile/textfile.c
index 43be12368..a7310e224 100644
--- a/navit/map/textfile/textfile.c
+++ b/navit/map/textfile/textfile.c
@@ -38,362 +38,333 @@
static int map_id;
-static void
-remove_comment_line(char* line){
- if (line[0]==TEXTFILE_COMMENT_CHAR){
- line='\0';
- }
+static void remove_comment_line(char* line) {
+ if (line[0]==TEXTFILE_COMMENT_CHAR) {
+ line='\0';
+ }
}
-static void
-get_line(struct map_rect_priv *mr)
-{
- if(mr->f) {
- if (!mr->m->is_pipe)
- mr->pos=ftell(mr->f);
- else
- mr->pos+=mr->lastlen;
- fgets(mr->line, TEXTFILE_LINE_SIZE, mr->f);
- dbg(lvl_debug,"read textfile line: %s\n", mr->line);
- remove_comment_line(mr->line);
- mr->lastlen=strlen(mr->line)+1;
- if (strlen(mr->line) >= TEXTFILE_LINE_SIZE-1)
- dbg(lvl_error, "line too long: %s\n", mr->line);
- }
+static void get_line(struct map_rect_priv *mr) {
+ if(mr->f) {
+ if (!mr->m->is_pipe)
+ mr->pos=ftell(mr->f);
+ else
+ mr->pos+=mr->lastlen;
+ fgets(mr->line, TEXTFILE_LINE_SIZE, mr->f);
+ dbg(lvl_debug,"read textfile line: %s", mr->line);
+ remove_comment_line(mr->line);
+ mr->lastlen=strlen(mr->line)+1;
+ if (strlen(mr->line) >= TEXTFILE_LINE_SIZE-1)
+ dbg(lvl_error, "line too long: %s", mr->line);
+ }
}
-static void
-map_destroy_textfile(struct map_priv *m)
-{
- g_free(m->filename);
- if(m->charset) {
- g_free(m->charset);
- }
- g_free(m);
+static void map_destroy_textfile(struct map_priv *m) {
+ g_free(m->filename);
+ if(m->charset) {
+ g_free(m->charset);
+ }
+ g_free(m);
}
-static void
-textfile_coord_rewind(void *priv_data)
-{
+static void textfile_coord_rewind(void *priv_data) {
}
-static int
-parse_line(struct map_rect_priv *mr, int attr)
-{
- int pos;
+static int parse_line(struct map_rect_priv *mr, int attr) {
+ int pos;
- pos=coord_parse(mr->line, projection_mg, &mr->c);
- if (pos < strlen(mr->line) && attr) {
- strcpy(mr->attrs, mr->line+pos);
- }
- return pos;
+ pos=coord_parse(mr->line, projection_mg, &mr->c);
+ if (pos < strlen(mr->line) && attr) {
+ strcpy(mr->attrs, mr->line+pos);
+ }
+ return pos;
}
-static int
-textfile_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr=priv_data;
- int ret=0;
- dbg(lvl_warning,"enter, count: %d\n",count);
- while (count--) {
- if (mr->f && !feof(mr->f) && (!mr->item.id_hi || !mr->eoc) && parse_line(mr, mr->item.id_hi)) {
- if (c){
- *c=mr->c;
- dbg(lvl_debug,"c=0x%x,0x%x\n", c->x, c->y);
- c++;
- }
- ret++;
- get_line(mr);
- if (mr->item.id_hi)
- mr->eoc=1;
- } else {
- mr->more=0;
- break;
- }
- }
- return ret;
+static int textfile_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr=priv_data;
+ int ret=0;
+ dbg(lvl_warning,"enter, count: %d",count);
+ while (count--) {
+ if (mr->f && !feof(mr->f) && (!mr->item.id_hi || !mr->eoc) && parse_line(mr, mr->item.id_hi)) {
+ if (c) {
+ *c=mr->c;
+ dbg(lvl_debug,"c=0x%x,0x%x", c->x, c->y);
+ c++;
+ }
+ ret++;
+ get_line(mr);
+ if (mr->item.id_hi)
+ mr->eoc=1;
+ } else {
+ mr->more=0;
+ break;
+ }
+ }
+ return ret;
}
-static void
-textfile_attr_rewind(void *priv_data)
-{
- struct map_rect_priv *mr=priv_data;
- mr->attr_pos=0;
- mr->attr_last=attr_none;
+static void textfile_attr_rewind(void *priv_data) {
+ struct map_rect_priv *mr=priv_data;
+ mr->attr_pos=0;
+ mr->attr_last=attr_none;
}
-static void
-textfile_encode_attr(char *attr_val, enum attr_type attr_type, struct attr *attr)
-{
- if (attr_type >= attr_type_int_begin && attr_type <= attr_type_int_end)
- attr->u.num=atoi(attr_val);
- else
- attr->u.str=attr_val;
+static void textfile_encode_attr(char *attr_val, enum attr_type attr_type, struct attr *attr) {
+ if (attr_type >= attr_type_int_begin && attr_type <= attr_type_int_end)
+ attr->u.num=atoi(attr_val);
+ else
+ attr->u.str=attr_val;
}
-static int
-textfile_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr=priv_data;
- char *str=NULL;
- dbg(lvl_debug,"mr=%p attrs='%s' ", mr, mr->attrs);
- if (attr_type != mr->attr_last) {
- dbg(lvl_debug,"reset attr_pos\n");
- mr->attr_pos=0;
- mr->attr_last=attr_type;
- }
- if (attr_type == attr_any) {
- dbg(lvl_debug,"attr_any");
- if (attr_from_line(mr->attrs,NULL,&mr->attr_pos,mr->attr, mr->attr_name)) {
- attr_type=attr_from_name(mr->attr_name);
- dbg(lvl_debug,"found attr '%s' 0x%x\n", mr->attr_name, attr_type);
- attr->type=attr_type;
- textfile_encode_attr(mr->attr, attr_type, attr);
- return 1;
- }
- } else {
- str=attr_to_name(attr_type);
- dbg(lvl_debug,"attr='%s' ",str);
- if (attr_from_line(mr->attrs,str,&mr->attr_pos,mr->attr, NULL)) {
- textfile_encode_attr(mr->attr, attr_type, attr);
- dbg(lvl_debug,"found\n");
- return 1;
- }
- }
- dbg(lvl_debug,"not found\n");
- return 0;
+static int textfile_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr=priv_data;
+ char *str=NULL;
+ dbg(lvl_debug,"mr=%p attrs='%s' ", mr, mr->attrs);
+ if (attr_type != mr->attr_last) {
+ dbg(lvl_debug,"reset attr_pos");
+ mr->attr_pos=0;
+ mr->attr_last=attr_type;
+ }
+ if (attr_type == attr_any) {
+ dbg(lvl_debug,"attr_any");
+ if (attr_from_line(mr->attrs,NULL,&mr->attr_pos,mr->attr, mr->attr_name)) {
+ attr_type=attr_from_name(mr->attr_name);
+ dbg(lvl_debug,"found attr '%s' 0x%x", mr->attr_name, attr_type);
+ attr->type=attr_type;
+ textfile_encode_attr(mr->attr, attr_type, attr);
+ return 1;
+ }
+ } else {
+ str=attr_to_name(attr_type);
+ dbg(lvl_debug,"attr='%s' ",str);
+ if (attr_from_line(mr->attrs,str,&mr->attr_pos,mr->attr, NULL)) {
+ textfile_encode_attr(mr->attr, attr_type, attr);
+ dbg(lvl_debug,"found");
+ return 1;
+ }
+ }
+ dbg(lvl_debug,"not found");
+ return 0;
}
static struct item_methods methods_textfile = {
- textfile_coord_rewind,
- textfile_coord_get,
- textfile_attr_rewind,
- textfile_attr_get,
+ textfile_coord_rewind,
+ textfile_coord_get,
+ textfile_attr_rewind,
+ textfile_attr_get,
};
-static struct map_rect_priv *
-map_rect_new_textfile(struct map_priv *map, struct map_selection *sel)
-{
- struct map_rect_priv *mr;
+static struct map_rect_priv *map_rect_new_textfile(struct map_priv *map, struct map_selection *sel) {
+ struct map_rect_priv *mr;
- dbg(lvl_debug,"enter\n");
- mr=g_new0(struct map_rect_priv, 1);
- mr->m=map;
- mr->sel=sel;
- if (map->flags & 1)
- mr->item.id_hi=1;
- else
- mr->item.id_hi=0;
- mr->item.id_lo=0;
- mr->item.meth=&methods_textfile;
- mr->item.priv_data=mr;
- if (map->is_pipe) {
+ dbg(lvl_debug,"enter");
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->m=map;
+ mr->sel=sel;
+ if (map->flags & 1)
+ mr->item.id_hi=1;
+ else
+ mr->item.id_hi=0;
+ mr->item.id_lo=0;
+ mr->item.meth=&methods_textfile;
+ mr->item.priv_data=mr;
+ if (map->is_pipe) {
#ifdef HAVE_POPEN
- char *oargs,*args=g_strdup(map->filename),*sep=" ";
- enum layer_type lay;
- g_free(mr->args);
- while (sel) {
- oargs=args;
- args=g_strdup_printf("%s 0x%x 0x%x 0x%x 0x%x", oargs, sel->u.c_rect.lu.x, sel->u.c_rect.lu.y, sel->u.c_rect.rl.x, sel->u.c_rect.rl.y);
- g_free(oargs);
- for (lay=layer_town ; lay < layer_end ; lay++) {
- oargs=args;
- args=g_strdup_printf("%s%s%d", oargs, sep, sel->order);
- g_free(oargs);
- sep=",";
- }
- sel=sel->next;
- }
- dbg(lvl_debug,"popen args %s\n", args);
- mr->args=args;
- mr->f=popen(mr->args, "r");
- mr->pos=0;
- mr->lastlen=0;
+ char *oargs,*args=g_strdup(map->filename),*sep=" ";
+ enum layer_type lay;
+ g_free(mr->args);
+ while (sel) {
+ oargs=args;
+ args=g_strdup_printf("%s 0x%x 0x%x 0x%x 0x%x", oargs, sel->u.c_rect.lu.x, sel->u.c_rect.lu.y, sel->u.c_rect.rl.x,
+ sel->u.c_rect.rl.y);
+ g_free(oargs);
+ for (lay=layer_town ; lay < layer_end ; lay++) {
+ oargs=args;
+ args=g_strdup_printf("%s%s%d", oargs, sep, sel->order);
+ g_free(oargs);
+ sep=",";
+ }
+ sel=sel->next;
+ }
+ dbg(lvl_debug,"popen args %s", args);
+ mr->args=args;
+ mr->f=popen(mr->args, "r");
+ mr->pos=0;
+ mr->lastlen=0;
#else
- dbg(lvl_error,"unable to work with pipes %s\n",map->filename);
-#endif
- } else {
- mr->f=fopen(map->filename, "r");
- }
- if(!mr->f) {
- if (!(errno == ENOENT && map->no_warning_if_map_file_missing)) {
- dbg(lvl_error, "error opening textfile %s: %s\n", map->filename, strerror(errno));
- }
- }
- get_line(mr);
- return mr;
+ dbg(lvl_error,"unable to work with pipes %s",map->filename);
+#endif
+ } else {
+ mr->f=fopen(map->filename, "r");
+ }
+ if(!mr->f) {
+ if (!(errno == ENOENT && map->no_warning_if_map_file_missing)) {
+ dbg(lvl_error, "error opening textfile %s: %s", map->filename, strerror(errno));
+ }
+ }
+ get_line(mr);
+ return mr;
}
-static void
-map_rect_destroy_textfile(struct map_rect_priv *mr)
-{
- if (mr->f) {
- if (mr->m->is_pipe) {
+static void map_rect_destroy_textfile(struct map_rect_priv *mr) {
+ if (mr->f) {
+ if (mr->m->is_pipe) {
#ifdef HAVE_POPEN
- pclose(mr->f);
+ pclose(mr->f);
#endif
- }
- else {
- fclose(mr->f);
- }
- }
- g_free(mr);
+ } else {
+ fclose(mr->f);
+ }
+ }
+ g_free(mr);
}
-static struct item *
-map_rect_get_item_textfile(struct map_rect_priv *mr)
-{
- char *p,type[TEXTFILE_LINE_SIZE];
- dbg(lvl_debug,"map_rect_get_item_textfile id_hi=%d line=%s", mr->item.id_hi, mr->line);
- if (!mr->f) {
- return NULL;
- }
- while (mr->more) {
- struct coord c;
- textfile_coord_get(mr, &c, 1);
- }
- for(;;) {
- if (feof(mr->f)) {
- dbg(lvl_debug,"map_rect_get_item_textfile: eof %d\n",mr->item.id_hi);
- if (mr->m->flags & 1) {
- if (!mr->item.id_hi)
- return NULL;
- mr->item.id_hi=0;
- } else {
- if (mr->item.id_hi)
- return NULL;
- mr->item.id_hi=1;
- }
- if (mr->m->is_pipe) {
+static struct item *map_rect_get_item_textfile(struct map_rect_priv *mr) {
+ char *p,type[TEXTFILE_LINE_SIZE];
+ dbg(lvl_debug,"map_rect_get_item_textfile id_hi=%d line=%s", mr->item.id_hi, mr->line);
+ if (!mr->f) {
+ return NULL;
+ }
+ while (mr->more) {
+ struct coord c;
+ textfile_coord_get(mr, &c, 1);
+ }
+ for(;;) {
+ if (feof(mr->f)) {
+ dbg(lvl_debug,"map_rect_get_item_textfile: eof %d",mr->item.id_hi);
+ if (mr->m->flags & 1) {
+ if (!mr->item.id_hi)
+ return NULL;
+ mr->item.id_hi=0;
+ } else {
+ if (mr->item.id_hi)
+ return NULL;
+ mr->item.id_hi=1;
+ }
+ if (mr->m->is_pipe) {
#ifdef HAVE_POPEN
- pclose(mr->f);
- mr->f=popen(mr->args, "r");
- mr->pos=0;
- mr->lastlen=0;
+ pclose(mr->f);
+ mr->f=popen(mr->args, "r");
+ mr->pos=0;
+ mr->lastlen=0;
#endif
- } else {
- fseek(mr->f, 0, SEEK_SET);
- clearerr(mr->f);
- }
- get_line(mr);
- }
- if ((p=strchr(mr->line,'\n')))
- *p='\0';
- if (mr->item.id_hi) {
- mr->attrs[0]='\0';
- if (!parse_line(mr, 1)) {
- get_line(mr);
- continue;
- }
- dbg(lvl_debug,"map_rect_get_item_textfile: point found\n");
- mr->eoc=0;
- mr->item.id_lo=mr->pos;
- } else {
- if (parse_line(mr, 1)) {
- get_line(mr);
- continue;
- }
- dbg(lvl_debug,"map_rect_get_item_textfile: line found\n");
- if (! mr->line[0]) {
- get_line(mr);
- continue;
- }
- mr->item.id_lo=mr->pos;
- strcpy(mr->attrs, mr->line);
- get_line(mr);
- dbg(lvl_debug,"mr=%p attrs=%s\n", mr, mr->attrs);
- }
- dbg(lvl_debug,"get_attrs %s\n", mr->attrs);
- if (attr_from_line(mr->attrs,"type",NULL,type,NULL)) {
- dbg(lvl_debug,"type='%s'\n", type);
- mr->item.type=item_from_name(type);
- if (mr->item.type == type_none)
- dbg(lvl_error, "Warning: type '%s' unknown\n", type);
- } else {
- get_line(mr);
- continue;
- }
- mr->attr_last=attr_none;
- mr->more=1;
- dbg(lvl_debug,"return attr='%s'\n", mr->attrs);
- return &mr->item;
- }
+ } else {
+ fseek(mr->f, 0, SEEK_SET);
+ clearerr(mr->f);
+ }
+ get_line(mr);
+ }
+ if ((p=strchr(mr->line,'\n')))
+ *p='\0';
+ if (mr->item.id_hi) {
+ mr->attrs[0]='\0';
+ if (!parse_line(mr, 1)) {
+ get_line(mr);
+ continue;
+ }
+ dbg(lvl_debug,"map_rect_get_item_textfile: point found");
+ mr->eoc=0;
+ mr->item.id_lo=mr->pos;
+ } else {
+ if (parse_line(mr, 1)) {
+ get_line(mr);
+ continue;
+ }
+ dbg(lvl_debug,"map_rect_get_item_textfile: line found");
+ if (! mr->line[0]) {
+ get_line(mr);
+ continue;
+ }
+ mr->item.id_lo=mr->pos;
+ strcpy(mr->attrs, mr->line);
+ get_line(mr);
+ dbg(lvl_debug,"mr=%p attrs=%s", mr, mr->attrs);
+ }
+ dbg(lvl_debug,"get_attrs %s", mr->attrs);
+ if (attr_from_line(mr->attrs,"type",NULL,type,NULL)) {
+ dbg(lvl_debug,"type='%s'", type);
+ mr->item.type=item_from_name(type);
+ if (mr->item.type == type_none)
+ dbg(lvl_error, "Warning: type '%s' unknown", type);
+ } else {
+ get_line(mr);
+ continue;
+ }
+ mr->attr_last=attr_none;
+ mr->more=1;
+ dbg(lvl_debug,"return attr='%s'", mr->attrs);
+ return &mr->item;
+ }
}
-static struct item *
-map_rect_get_item_byid_textfile(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- if (mr->m->is_pipe) {
+static struct item *map_rect_get_item_byid_textfile(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ if (mr->m->is_pipe) {
#ifndef _MSC_VER
- pclose(mr->f);
- mr->f=popen(mr->args, "r");
- mr->pos=0;
- mr->lastlen=0;
+ pclose(mr->f);
+ mr->f=popen(mr->args, "r");
+ mr->pos=0;
+ mr->lastlen=0;
#endif /* _MSC_VER */
- } else
- fseek(mr->f, id_lo, SEEK_SET);
- get_line(mr);
- mr->item.id_hi=id_hi;
- return map_rect_get_item_textfile(mr);
+ } else
+ fseek(mr->f, id_lo, SEEK_SET);
+ get_line(mr);
+ mr->item.id_hi=id_hi;
+ return map_rect_get_item_textfile(mr);
}
static struct map_methods map_methods_textfile = {
- projection_mg,
- "utf-8",
- map_destroy_textfile,
- map_rect_new_textfile,
- map_rect_destroy_textfile,
- map_rect_get_item_textfile,
- map_rect_get_item_byid_textfile,
+ projection_mg,
+ "utf-8",
+ map_destroy_textfile,
+ map_rect_new_textfile,
+ map_rect_destroy_textfile,
+ map_rect_get_item_textfile,
+ map_rect_get_item_byid_textfile,
};
-static struct map_priv *
-map_new_textfile(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct map_priv *m;
- struct attr *data=attr_search(attrs, NULL, attr_data);
- struct attr *charset=attr_search(attrs, NULL, attr_charset);
- struct attr *flags=attr_search(attrs, NULL, attr_flags);
- struct attr *no_warn=attr_search(attrs, NULL, attr_no_warning_if_map_file_missing);
- struct file_wordexp *wexp;
- int len,is_pipe=0;
- char *wdata;
- char **wexp_data;
- if (! data)
- return NULL;
- dbg(lvl_debug,"map_new_textfile %s\n", data->u.str);
- wdata=g_strdup(data->u.str);
- len=strlen(wdata);
- if (len && wdata[len-1] == '|') {
- wdata[len-1]='\0';
- is_pipe=1;
- }
- wexp=file_wordexp_new(wdata);
- wexp_data=file_wordexp_get_array(wexp);
- *meth=map_methods_textfile;
+static struct map_priv *map_new_textfile(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *m;
+ struct attr *data=attr_search(attrs, NULL, attr_data);
+ struct attr *charset=attr_search(attrs, NULL, attr_charset);
+ struct attr *flags=attr_search(attrs, NULL, attr_flags);
+ struct attr *no_warn=attr_search(attrs, NULL, attr_no_warning_if_map_file_missing);
+ struct file_wordexp *wexp;
+ int len,is_pipe=0;
+ char *wdata;
+ char **wexp_data;
+ if (! data)
+ return NULL;
+ dbg(lvl_debug,"map_new_textfile %s", data->u.str);
+ wdata=g_strdup(data->u.str);
+ len=strlen(wdata);
+ if (len && wdata[len-1] == '|') {
+ wdata[len-1]='\0';
+ is_pipe=1;
+ }
+ wexp=file_wordexp_new(wdata);
+ wexp_data=file_wordexp_get_array(wexp);
+ *meth=map_methods_textfile;
- m=g_new0(struct map_priv, 1);
- m->id=++map_id;
- m->filename=g_strdup(wexp_data[0]);
- m->is_pipe=is_pipe;
- m->no_warning_if_map_file_missing=(no_warn!=NULL) && (no_warn->u.num);
- if (flags)
- m->flags=flags->u.num;
- dbg(lvl_debug,"map_new_textfile %s %s\n", m->filename, wdata);
- if (charset) {
- m->charset=g_strdup(charset->u.str);
- meth->charset=m->charset;
- }
- file_wordexp_destroy(wexp);
- g_free(wdata);
- return m;
+ m=g_new0(struct map_priv, 1);
+ m->id=++map_id;
+ m->filename=g_strdup(wexp_data[0]);
+ m->is_pipe=is_pipe;
+ m->no_warning_if_map_file_missing=(no_warn!=NULL) && (no_warn->u.num);
+ if (flags)
+ m->flags=flags->u.num;
+ dbg(lvl_debug,"map_new_textfile %s %s", m->filename, wdata);
+ if (charset) {
+ m->charset=g_strdup(charset->u.str);
+ meth->charset=m->charset;
+ }
+ file_wordexp_destroy(wexp);
+ g_free(wdata);
+ return m;
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug,"textfile: plugin_init\n");
- plugin_register_category_map("textfile", map_new_textfile);
+void plugin_init(void) {
+ dbg(lvl_debug,"textfile: plugin_init");
+ plugin_register_category_map("textfile", map_new_textfile);
}
diff --git a/navit/maps.c b/navit/maps.c
index 628713dd2..4caf6dcf8 100644
--- a/navit/maps.c
+++ b/navit/maps.c
@@ -28,75 +28,74 @@
struct maps;
struct maps *
-maps_new(struct attr *parent, struct attr **attrs)
-{
- struct attr *data,**attrs_dup;
- if (!parent) {
- dbg(lvl_error,"No parent\n");
- return NULL;
- }
- if (parent->type != attr_mapset) {
- dbg(lvl_error,"Parent must be mapset\n");
- return NULL;
- }
- dbg(lvl_debug,"enter\n");
- attrs_dup=attr_list_dup(attrs);
- data=attr_search(attrs_dup, NULL, attr_data);
- if (data) {
- struct file_wordexp *wexp=file_wordexp_new(data->u.str);
- int i,count=file_wordexp_get_count(wexp);
- char **array=file_wordexp_get_array(wexp);
- struct attr *name;
- struct attr *name_provided = attr_search(attrs_dup, NULL, attr_name);
+maps_new(struct attr *parent, struct attr **attrs) {
+ struct attr *data,**attrs_dup;
+ if (!parent) {
+ dbg(lvl_error,"No parent");
+ return NULL;
+ }
+ if (parent->type != attr_mapset) {
+ dbg(lvl_error,"Parent must be mapset");
+ return NULL;
+ }
+ dbg(lvl_debug,"enter");
+ attrs_dup=attr_list_dup(attrs);
+ data=attr_search(attrs_dup, NULL, attr_data);
+ if (data) {
+ struct file_wordexp *wexp=file_wordexp_new(data->u.str);
+ int i,count=file_wordexp_get_count(wexp);
+ char **array=file_wordexp_get_array(wexp);
+ struct attr *name;
+ struct attr *name_provided = attr_search(attrs_dup, NULL, attr_name);
- // if no name was provided, fill the name with the location
- if (!name_provided) {
- struct attr name_tmp;
- name_tmp.type = attr_name;
- name_tmp.u.str="NULL";
- attrs_dup=attr_generic_add_attr(attrs_dup, &name_tmp);
- name = attr_search(attrs_dup, NULL, attr_name);
- }
+ // if no name was provided, fill the name with the location
+ if (!name_provided) {
+ struct attr name_tmp;
+ name_tmp.type = attr_name;
+ name_tmp.u.str="NULL";
+ attrs_dup=attr_generic_add_attr(attrs_dup, &name_tmp);
+ name = attr_search(attrs_dup, NULL, attr_name);
+ }
- for (i = 0 ; i < count ; i++) {
- struct attr map;
- g_free(data->u.str);
- data->u.str=g_strdup(array[i]);
+ for (i = 0 ; i < count ; i++) {
+ struct attr map;
+ g_free(data->u.str);
+ data->u.str=g_strdup(array[i]);
- if (!name_provided) {
- g_free(name->u.str);
- name->u.str=g_strdup(array[i]);
- }
+ if (!name_provided) {
+ g_free(name->u.str);
+ name->u.str=g_strdup(array[i]);
+ }
- map.type=attr_map;
- map.u.map=map_new(parent, attrs_dup);
+ map.type=attr_map;
+ map.u.map=map_new(parent, attrs_dup);
- if (map.u.map) {
- mapset_add_attr(parent->u.mapset, &map);
- navit_object_unref(map.u.navit_object);
- }
-
- }
- file_wordexp_destroy(wexp);
- } else {
- dbg(lvl_error,"no data attribute\n");
- }
- attr_list_free(attrs_dup);
- return NULL;
+ if (map.u.map) {
+ mapset_add_attr(parent->u.mapset, &map);
+ navit_object_unref(map.u.navit_object);
+ }
+
+ }
+ file_wordexp_destroy(wexp);
+ } else {
+ dbg(lvl_error,"no data attribute");
+ }
+ attr_list_free(attrs_dup);
+ return NULL;
}
struct object_func maps_func = {
- attr_maps,
- (object_func_new)maps_new,
- (object_func_get_attr)NULL,
- (object_func_iter_new)NULL,
- (object_func_iter_destroy)NULL,
- (object_func_set_attr)NULL,
- (object_func_add_attr)NULL,
- (object_func_remove_attr)NULL,
- (object_func_init)NULL,
- (object_func_destroy)NULL,
- (object_func_dup)NULL,
- (object_func_ref)NULL,
- (object_func_unref)NULL,
+ attr_maps,
+ (object_func_new)maps_new,
+ (object_func_get_attr)NULL,
+ (object_func_iter_new)NULL,
+ (object_func_iter_destroy)NULL,
+ (object_func_set_attr)NULL,
+ (object_func_add_attr)NULL,
+ (object_func_remove_attr)NULL,
+ (object_func_init)NULL,
+ (object_func_destroy)NULL,
+ (object_func_dup)NULL,
+ (object_func_ref)NULL,
+ (object_func_unref)NULL,
};
diff --git a/navit/maps/CMakeLists.txt b/navit/maps/CMakeLists.txt
index c3f8ae7c4..ee9babdf9 100644
--- a/navit/maps/CMakeLists.txt
+++ b/navit/maps/CMakeLists.txt
@@ -1,44 +1,43 @@
if(SAMPLE_MAP)
- set(SAMPLE_MAP_NAME osm_bbox_11.3,47.9,11.7,48.2)
- set(maptool_args "--attr-debug-level=5")
+ set(SAMPLE_MAP_NAME osm_bbox_11.3,47.9,11.7,48.2)
+ set(maptool_args "--attr-debug-level=5")
- GET_TARGET_PROPERTY(MAPTOOL_PATH maptool LOCATION)
- add_custom_target(sample_map ALL DEPENDS ${SAMPLE_MAP_NAME}.xml)
- add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.xml
- COMMAND ${CMAKE_COMMAND} -D TYPE=binfile -D DATA=${SAMPLE_MAP_NAME}.bin
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.xml
- -P ${PROJECT_SOURCE_DIR}/cmake/navit_writemapxml.cmake
- VERBATIM
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
- )
- if(DOWNLOAD_SAMPLE_MAP)
- add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
- COMMAND ${CMAKE_COMMAND}
- -D URL=http://www.navit-project.org/maps/${SAMPLE_MAP_NAME}.bin
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
- -P ${PROJECT_SOURCE_DIR}/cmake/navit_download.cmake
- VERBATIM
- )
- else()
- add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
- COMMAND bzcat ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.osm.bz2
- | ${MAPTOOL_PATH} ${maptool_args} ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
- VERBATIM
- DEPENDS maptool ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.osm.bz2
- )
- add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.osm.bz2
- COMMAND ${CMAKE_COMMAND}
- -D URL=http://www.navit-project.org/maps/${SAMPLE_MAP_NAME}.osm.bz2
- -D DST=${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.osm.bz2
- -P ${PROJECT_SOURCE_DIR}/cmake/navit_download.cmake
- VERBATIM
- )
- endif()
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
- DESTINATION ${SHARE_DIR}/maps
- PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+ add_custom_target(sample_map ALL DEPENDS ${SAMPLE_MAP_NAME}.xml)
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.xml
+ COMMAND ${CMAKE_COMMAND} -D TYPE=binfile -D DATA=${SAMPLE_MAP_NAME}.bin
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.xml
+ -P ${PROJECT_SOURCE_DIR}/cmake/navit_writemapxml.cmake
+ VERBATIM
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
+ )
+ if(DOWNLOAD_SAMPLE_MAP)
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
+ COMMAND ${CMAKE_COMMAND}
+ -D URL=http://www1.navit-project.org/maps/${SAMPLE_MAP_NAME}.bin
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
+ -P ${PROJECT_SOURCE_DIR}/cmake/navit_download.cmake
+ VERBATIM
+ )
+ else()
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
+ COMMAND bzcat ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.osm.bz2
+ | $<TARGET_FILE:maptool> ${maptool_args} ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
+ VERBATIM
+ DEPENDS maptool ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.osm.bz2
+ )
+ add_custom_command (
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.osm.bz2
+ COMMAND ${CMAKE_COMMAND}
+ -D URL=http://www1.navit-project.org/maps/${SAMPLE_MAP_NAME}.osm.bz2
+ -D DST=${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.osm.bz2
+ -P ${PROJECT_SOURCE_DIR}/cmake/navit_download.cmake
+ VERBATIM
+ )
+ endif()
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SAMPLE_MAP_NAME}.bin
+ DESTINATION ${SHARE_DIR}/maps
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
endif()
diff --git a/navit/mapset.c b/navit/mapset.c
index 6c3d0b5d1..a2e914b6b 100644
--- a/navit/mapset.c
+++ b/navit/mapset.c
@@ -18,7 +18,7 @@
*/
/** @file
- *
+ *
* @brief Contains code used for loading more than one map
*
* The code in this file introduces "mapsets", which are collections of several maps.
@@ -42,49 +42,44 @@
* This structure holds a complete mapset
*/
struct mapset {
- NAVIT_OBJECT
- GList *maps; /**< Linked list of all the maps in the mapset */
+ NAVIT_OBJECT
+ GList *maps; /**< Linked list of all the maps in the mapset */
};
struct attr_iter {
- GList *last;
+ GList *last;
};
/**
* @brief Creates a new, empty mapset
*
- * @return The new mapset
+ * @return The new mapset
*/
-struct mapset *mapset_new(struct attr *parent, struct attr **attrs)
-{
- struct mapset *ms;
+struct mapset *mapset_new(struct attr *parent, struct attr **attrs) {
+ struct mapset *ms;
- ms=g_new0(struct mapset, 1);
- ms->func=&mapset_func;
- navit_object_ref((struct navit_object *)ms);
- ms->attrs=attr_list_dup(attrs);
+ ms=g_new0(struct mapset, 1);
+ ms->func=&mapset_func;
+ navit_object_ref((struct navit_object *)ms);
+ ms->attrs=attr_list_dup(attrs);
- return ms;
+ return ms;
}
-struct mapset *mapset_dup(struct mapset *ms)
-{
- struct mapset *ret=mapset_new(NULL, ms->attrs);
- ret->maps=g_list_copy(ms->maps);
- return ret;
+struct mapset *mapset_dup(struct mapset *ms) {
+ struct mapset *ret=mapset_new(NULL, ms->attrs);
+ ret->maps=g_list_copy(ms->maps);
+ return ret;
}
struct attr_iter *
-mapset_attr_iter_new(void)
-{
- return g_new0(struct attr_iter, 1);
+mapset_attr_iter_new(void) {
+ return g_new0(struct attr_iter, 1);
}
-void
-mapset_attr_iter_destroy(struct attr_iter *iter)
-{
- g_free(iter);
+void mapset_attr_iter_destroy(struct attr_iter *iter) {
+ g_free(iter);
}
/**
@@ -93,69 +88,62 @@ mapset_attr_iter_destroy(struct attr_iter *iter)
* @param ms The mapset to add the map to
* @param m The map to be added
*/
-int
-mapset_add_attr(struct mapset *ms, struct attr *attr)
-{
- switch (attr->type) {
- case attr_map:
- ms->attrs=attr_generic_add_attr(ms->attrs,attr);
- ms->maps=g_list_append(ms->maps, attr->u.map);
- return 1;
- default:
- return 0;
- }
+int mapset_add_attr(struct mapset *ms, struct attr *attr) {
+ switch (attr->type) {
+ case attr_map:
+ ms->attrs=attr_generic_add_attr(ms->attrs,attr);
+ ms->maps=g_list_append(ms->maps, attr->u.map);
+ return 1;
+ default:
+ return 0;
+ }
}
-int
-mapset_remove_attr(struct mapset *ms, struct attr *attr)
-{
- switch (attr->type) {
- case attr_map:
- ms->attrs=attr_generic_remove_attr(ms->attrs,attr);
- ms->maps=g_list_remove(ms->maps, attr->u.map);
- return 1;
- default:
- return 0;
- }
+int mapset_remove_attr(struct mapset *ms, struct attr *attr) {
+ switch (attr->type) {
+ case attr_map:
+ ms->attrs=attr_generic_remove_attr(ms->attrs,attr);
+ ms->maps=g_list_remove(ms->maps, attr->u.map);
+ return 1;
+ default:
+ return 0;
+ }
}
-int
-mapset_get_attr(struct mapset *ms, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- GList *map;
- map=ms->maps;
- attr->type=type;
- switch (type) {
- case attr_map:
- while (map) {
- if (!iter || iter->last == g_list_previous(map)) {
- attr->u.map=map->data;
- if (iter)
- iter->last=map;
- return 1;
- }
- map=g_list_next(map);
- }
- break;
- default:
- break;
- }
- return 0;
+int mapset_get_attr(struct mapset *ms, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ GList *map;
+ map=ms->maps;
+ attr->type=type;
+ switch (type) {
+ case attr_map:
+ while (map) {
+ if (!iter || iter->last == g_list_previous(map)) {
+ attr->u.map=map->data;
+ if (iter)
+ iter->last=map;
+ return 1;
+ }
+ map=g_list_next(map);
+ }
+ break;
+ default:
+ break;
+ }
+ return 0;
}
/**
- * @brief Destroys a mapset.
+ * @brief Destroys a mapset.
*
* This destroys a mapset. Please note that it does not touch the contained maps
* in any way.
*
* @param ms The mapset to be destroyed
*/
-void mapset_destroy(struct mapset *ms)
-{
- g_list_free(ms->maps);
- attr_list_free(ms->attrs);
- g_free(ms);
+void mapset_destroy(struct mapset *ms) {
+ g_list_free(ms->maps);
+ attr_list_free(ms->attrs);
+ g_free(ms);
}
/**
@@ -165,7 +153,7 @@ void mapset_destroy(struct mapset *ms)
* all maps in a mapset.
*/
struct mapset_handle {
- GList *l; /**< Pointer to the current (next) map */
+ GList *l; /**< Pointer to the current (next) map */
};
/**
@@ -178,16 +166,14 @@ struct mapset_handle {
* @return The new mapset handle
*/
struct mapset_handle *
-mapset_open(struct mapset *ms)
-{
- struct mapset_handle *ret=NULL;
- if(ms)
- {
- ret=g_new(struct mapset_handle, 1);
- ret->l=ms->maps;
- }
-
- return ret;
+mapset_open(struct mapset *ms) {
+ struct mapset_handle *ret=NULL;
+ if(ms) {
+ ret=g_new(struct mapset_handle, 1);
+ ret->l=ms->maps;
+ }
+
+ return ret;
}
/**
@@ -200,35 +186,34 @@ mapset_open(struct mapset *ms)
* @param active Set to true to only get active maps (See description)
* @return The next map
*/
-struct map * mapset_next(struct mapset_handle *msh, int active)
-{
- struct map *ret;
- struct attr active_attr;
-
- for (;;) {
- if (!msh || !msh->l)
- return NULL;
- ret=msh->l->data;
- msh->l=g_list_next(msh->l);
- if (!active)
- return ret;
- if (active == 2 && map_get_attr(ret, attr_route_active, &active_attr, NULL)) {
- if (active_attr.u.num)
- return ret;
- else
- continue;
- }
- if (active == 3 && map_get_attr(ret, attr_search_active, &active_attr, NULL)) {
- if (active_attr.u.num)
- return ret;
- else
- continue;
- }
- if (!map_get_attr(ret, attr_active, &active_attr, NULL))
- return ret;
- if (active_attr.u.num)
- return ret;
- }
+struct map * mapset_next(struct mapset_handle *msh, int active) {
+ struct map *ret;
+ struct attr active_attr;
+
+ for (;;) {
+ if (!msh || !msh->l)
+ return NULL;
+ ret=msh->l->data;
+ msh->l=g_list_next(msh->l);
+ if (!active)
+ return ret;
+ if (active == 2 && map_get_attr(ret, attr_route_active, &active_attr, NULL)) {
+ if (active_attr.u.num)
+ return ret;
+ else
+ continue;
+ }
+ if (active == 3 && map_get_attr(ret, attr_search_active, &active_attr, NULL)) {
+ if (active_attr.u.num)
+ return ret;
+ else
+ continue;
+ }
+ if (!map_get_attr(ret, attr_active, &active_attr, NULL))
+ return ret;
+ if (active_attr.u.num)
+ return ret;
+ }
}
/**
@@ -238,26 +223,25 @@ struct map * mapset_next(struct mapset_handle *msh, int active)
* @param map_name the map name used by the search
* @return The next map
*/
-struct map *
-mapset_get_map_by_name(struct mapset *ms, const char*map_name)
-{
- struct mapset_handle*msh;
- struct map*curr_map;
- struct attr map_attr;
- if( !ms || !map_name ) {
- return NULL;
- }
- msh=mapset_open(ms);
- while ((curr_map=mapset_next(msh, 1))) {
- //get map name
- if(map_get_attr(curr_map,attr_name, &map_attr,NULL)) {
- if( ! strcmp(map_attr.u.str, map_name)) {
- break;
- }
- }
- }
- mapset_close(msh);
- return curr_map;
+struct map *
+mapset_get_map_by_name(struct mapset *ms, const char*map_name) {
+ struct mapset_handle*msh;
+ struct map*curr_map;
+ struct attr map_attr;
+ if( !ms || !map_name ) {
+ return NULL;
+ }
+ msh=mapset_open(ms);
+ while ((curr_map=mapset_next(msh, 1))) {
+ //get map name
+ if(map_get_attr(curr_map,attr_name, &map_attr,NULL)) {
+ if( ! strcmp(map_attr.u.str, map_name)) {
+ break;
+ }
+ }
+ }
+ mapset_close(msh);
+ return curr_map;
}
/**
@@ -265,26 +249,24 @@ mapset_get_map_by_name(struct mapset *ms, const char*map_name)
*
* @param msh Mapset handle to be closed
*/
-void
-mapset_close(struct mapset_handle *msh)
-{
- g_free(msh);
+void mapset_close(struct mapset_handle *msh) {
+ g_free(msh);
}
/**
* @brief Holds information about a search in a mapset
*
- * This struct holds information about a search (e.g. for a street) in a mapset.
+ * This struct holds information about a search (e.g. for a street) in a mapset.
*
* @sa For a more detailed description see the documentation of mapset_search_new().
*/
struct mapset_search {
- GList *map; /**< The list of maps to be searched within */
- struct map_search *ms; /**< A map search struct for the map currently active */
- struct item *item; /**< "Superior" item. */
- struct attr *search_attr; /**< Attribute to be searched for. */
- int partial; /**< Indicates if one would like to have partial matches */
- struct mapset *mapset; /**< reference to current mapset. Set to NULL when all maps are searched */
+ GList *map; /**< The list of maps to be searched within */
+ struct map_search *ms; /**< A map search struct for the map currently active */
+ struct item *item; /**< "Superior" item. */
+ struct attr *search_attr; /**< Attribute to be searched for. */
+ int partial; /**< Indicates if one would like to have partial matches */
+ struct mapset *mapset; /**< reference to current mapset. Set to NULL when all maps are searched */
};
/**
@@ -297,7 +279,7 @@ struct mapset_search {
* strings - a search for a street named "street" would match to "streetfoo", but not to
* "somestreet". Search is case insensitive.
*
- * The item passed to this function specifies a "superior item" to "search within" - e.g. a town
+ * The item passed to this function specifies a "superior item" to "search within" - e.g. a town
* in which we want to search for a street, or a country in which to search for a town.
*
* @param ms The mapset that should be searched
@@ -307,23 +289,19 @@ struct mapset_search {
* @return A new mapset search struct for this search
*/
struct mapset_search *
-mapset_search_new(struct mapset *ms, struct item *item, struct attr *search_attr, int partial)
-{
- struct mapset_search *this;
- dbg(lvl_debug,"enter(%p,%p,%p,%d)\n", ms, item, search_attr, partial);
- this=g_new0(struct mapset_search,1);
- if(this != NULL && ms!=NULL )
- {
- this->mapset=ms;
- this->item=item;
- this->search_attr=search_attr;
- this->partial=partial;
- return this;
- }
- else
- {
- return NULL;
- }
+mapset_search_new(struct mapset *ms, struct item *item, struct attr *search_attr, int partial) {
+ struct mapset_search *this;
+ dbg(lvl_debug,"enter(%p,%p,%p,%d)", ms, item, search_attr, partial);
+ this=g_new0(struct mapset_search,1);
+ if(this != NULL && ms!=NULL ) {
+ this->mapset=ms;
+ this->item=item;
+ this->search_attr=search_attr;
+ this->partial=partial;
+ return this;
+ } else {
+ return NULL;
+ }
}
/**
@@ -337,52 +315,52 @@ mapset_search_new(struct mapset *ms, struct item *item, struct attr *search_attr
* @return The next found item or NULL if there are no more items found
*/
struct item *
-mapset_search_get_item(struct mapset_search *this_)
-{
- struct item *ret=NULL;
- struct attr active_attr;
- int country_search=this_->search_attr->type >= attr_country_all && this_->search_attr->type <= attr_country_name;
-
- while ((this_) && (this_->mapset) && (!this_->ms || !(ret=map_search_get_item(this_->ms)))) { /* The current map has no more items to be returned */
-
- /* Use only the first map from the mapset to search for country codes. */
- if (this_->map && country_search)
- break;
-
- for (;;) {
- if (!this_->map)
- this_->map=this_->mapset->maps;
- else
- this_->map=g_list_next(this_->map);
-
- if (!this_->map) {
- /* No more maps left, mark this mapset_search as finished */
- this_->mapset=NULL;
- break;
- }
-
- /* Any map can be used for country search, regardless of it's attr_active value */
- if(country_search)
- break;
-
- if (map_get_attr(this_->map->data, attr_search_active, &active_attr, NULL)) {
- if (!active_attr.u.num)
- continue;
- }
- if (!map_get_attr(this_->map->data, attr_active, &active_attr, NULL))
- break;
- if (active_attr.u.num)
- break;
- }
- if(this_->ms) {
- map_search_destroy(this_->ms);
- this_->ms=NULL;
- }
- if (! this_->map)
- break;
- this_->ms=map_search_new(this_->map->data, this_->item, this_->search_attr, this_->partial);
- }
- return ret;
+mapset_search_get_item(struct mapset_search *this_) {
+ struct item *ret=NULL;
+ struct attr active_attr;
+ int country_search=this_->search_attr->type >= attr_country_all && this_->search_attr->type <= attr_country_name;
+
+ while ((this_) && (this_->mapset) && (!this_->ms
+ || !(ret=map_search_get_item(this_->ms)))) { /* The current map has no more items to be returned */
+
+ /* Use only the first map from the mapset to search for country codes. */
+ if (this_->map && country_search)
+ break;
+
+ for (;;) {
+ if (!this_->map)
+ this_->map=this_->mapset->maps;
+ else
+ this_->map=g_list_next(this_->map);
+
+ if (!this_->map) {
+ /* No more maps left, mark this mapset_search as finished */
+ this_->mapset=NULL;
+ break;
+ }
+
+ /* Any map can be used for country search, regardless of it's attr_active value */
+ if(country_search)
+ break;
+
+ if (map_get_attr(this_->map->data, attr_search_active, &active_attr, NULL)) {
+ if (!active_attr.u.num)
+ continue;
+ }
+ if (!map_get_attr(this_->map->data, attr_active, &active_attr, NULL))
+ break;
+ if (active_attr.u.num)
+ break;
+ }
+ if(this_->ms) {
+ map_search_destroy(this_->ms);
+ this_->ms=NULL;
+ }
+ if (! this_->map)
+ break;
+ this_->ms=map_search_new(this_->map->data, this_->item, this_->search_attr, this_->partial);
+ }
+ return ret;
}
/**
@@ -390,29 +368,27 @@ mapset_search_get_item(struct mapset_search *this_)
*
* @param this The mapset search to be destroyed
*/
-void
-mapset_search_destroy(struct mapset_search *this_)
-{
- if (this_) {
- map_search_destroy(this_->ms);
- g_free(this_);
- }
+void mapset_search_destroy(struct mapset_search *this_) {
+ if (this_) {
+ map_search_destroy(this_->ms);
+ g_free(this_);
+ }
}
struct object_func mapset_func = {
- attr_mapset,
- (object_func_new)mapset_new,
- (object_func_get_attr)mapset_get_attr,
- (object_func_iter_new)mapset_attr_iter_new,
- (object_func_iter_destroy)mapset_attr_iter_destroy,
- (object_func_set_attr)NULL,
- (object_func_add_attr)mapset_add_attr,
- (object_func_remove_attr)mapset_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)mapset_destroy,
- (object_func_dup)mapset_dup,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_mapset,
+ (object_func_new)mapset_new,
+ (object_func_get_attr)mapset_get_attr,
+ (object_func_iter_new)mapset_attr_iter_new,
+ (object_func_iter_destroy)mapset_attr_iter_destroy,
+ (object_func_set_attr)NULL,
+ (object_func_add_attr)mapset_add_attr,
+ (object_func_remove_attr)mapset_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)mapset_destroy,
+ (object_func_dup)mapset_dup,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/maptool/CMakeLists.txt b/navit/maptool/CMakeLists.txt
index 0c006daee..624ea907b 100644
--- a/navit/maptool/CMakeLists.txt
+++ b/navit/maptool/CMakeLists.txt
@@ -1,20 +1,33 @@
-
if(BUILD_MAPTOOL)
- add_definitions( -DMODULE=maptool ${NAVIT_COMPILE_FLAGS})
- include_directories(${CMAKE_CURRENT_SOURCE_DIR})
- SET(MAPTOOL_SOURCE boundaries.c buffer.c ch.c coastline.c itembin.c itembin_buffer.c misc.c osm.c osm_o5m.c osm_relations.c sourcesink.c tempfile.c tile.c zip.c osm_xml.c)
- if(NOT MSVC)
- SET(MAPTOOL_SOURCE ${MAPTOOL_SOURCE} osm_protobuf.c osm_protobufdb.c generated-code/fileformat.pb-c.c generated-code/osmformat.pb-c.c google/protobuf-c/protobuf-c.c)
- endif(NOT MSVC)
- add_library (maptool_core ${MAPTOOL_SOURCE})
- add_executable (maptool maptool.c)
- if(NOT MSVC)
- SET(NAVIT_LIBS ${NAVIT_LIBS} m)
- endif(NOT MSVC)
- target_link_libraries(maptool maptool_core ${NAVIT_LIBNAME} ${NAVIT_LIBS})
-
- install(TARGETS maptool
- DESTINATION ${BIN_DIR}
- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+
+ find_package(Protobuf-c REQUIRED)
+ include_directories(${PROTOBUF-C_INCLUDE_DIR})
+ include_directories(${CMAKE_CURRENT_BINARY_DIR})
+ #PROTOBUF_C_GENERATE_C(PROTO_SRCS PROTO_HDRS zfs.proto)
+
+ add_definitions( -DMODULE=maptool ${NAVIT_COMPILE_FLAGS})
+
+ add_executable (maptool maptool.c)
+ add_library (maptool_core boundaries.c buffer.c ch.c coastline.c itembin.c
+ itembin_buffer.c misc.c osm.c osm_o5m.c osm_psql.c osm_relations.c
+ sourcesink.c tempfile.c tile.c zip.c osm_xml.c)
+
+ if(NOT MSVC)
+ PROTOBUF_C_GENERATE_C (PROTO_SRCS PROTO_HDRS osmformat.proto)
+ PROTOBUF_C_GENERATE_C (PROTO_SRCS PROTO_HDRS fileformat.proto)
+ target_sources(maptool_core PRIVATE osm_protobuf.c osm_protobufdb.c
+ fileformat.pb-c.c osmformat.pb-c.c)
+ target_link_libraries(maptool_core ${PROTOBUF_C_LIBRARY})
+ endif(NOT MSVC)
+
+ if(NOT MSVC)
+ SET(NAVIT_LIBS ${NAVIT_LIBS} m)
+ endif(NOT MSVC)
+
+ target_link_libraries(maptool maptool_core ${NAVIT_LIBNAME} ${NAVIT_LIBS})
+
+ install(TARGETS maptool
+ DESTINATION ${BIN_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif()
diff --git a/navit/maptool/boundaries.c b/navit/maptool/boundaries.c
index 605b6fb7b..2f64d092c 100644
--- a/navit/maptool/boundaries.c
+++ b/navit/maptool/boundaries.c
@@ -23,364 +23,312 @@
#define strcasecmp _stricmp
#endif
-char *
-osm_tag_value(struct item_bin *ib, char *key)
-{
- char *tag=NULL;
- int len=strlen(key);
- while ((tag=item_bin_get_attr(ib, attr_osm_tag, tag))) {
- if (!strncmp(tag,key,len) && tag[len] == '=')
- return tag+len+1;
- }
- return NULL;
+char *osm_tag_value(struct item_bin *ib, char *key) {
+ char *tag=NULL;
+ int len=strlen(key);
+ while ((tag=item_bin_get_attr(ib, attr_osm_tag, tag))) {
+ if (!strncmp(tag,key,len) && tag[len] == '=')
+ return tag+len+1;
+ }
+ return NULL;
}
#if 0
-static char *
-osm_tag_name(struct item_bin *ib)
-{
- return osm_tag_value(ib, "name");
+static char *osm_tag_name(struct item_bin *ib) {
+ return osm_tag_value(ib, "name");
}
#endif
-osmid
-boundary_relid(struct boundary *b)
-{
- long long *id;
- if (!b)
- return 0;
- if (!b->ib)
- return 0;
- id=item_bin_get_attr(b->ib, attr_osm_relationid, NULL);
- if (id)
- return *id;
- return 0;
+osmid boundary_relid(struct boundary *b) {
+ long long *id;
+ if (!b)
+ return 0;
+ if (!b->ib)
+ return 0;
+ id=item_bin_get_attr(b->ib, attr_osm_relationid, NULL);
+ if (id)
+ return *id;
+ return 0;
}
-static void
-process_boundaries_member(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv)
-{
- struct boundary *b=relation_priv;
- enum geom_poly_segment_type role=(long)member_priv;
- int *dup;
- dup=item_bin_get_attr(member,attr_duplicate,NULL);
- if(!dup || *dup==0)
- b->segments=g_list_prepend(b->segments,item_bin_to_poly_segment(member, role));
+static void process_boundaries_member(void *func_priv, void *relation_priv, struct item_bin *member,
+ void *member_priv) {
+ struct boundary *b=relation_priv;
+ enum geom_poly_segment_type role=(long)member_priv;
+ int *dup;
+ dup=item_bin_get_attr(member,attr_duplicate,NULL);
+ if(!dup || *dup==0)
+ b->segments=g_list_prepend(b->segments,item_bin_to_poly_segment(member, role));
}
-static GList *
-process_boundaries_setup(FILE *boundaries, struct relations *relations)
-{
- struct item_bin *ib;
- GList *boundaries_list=NULL;
- struct relations_func *relations_func;
+static GList *process_boundaries_setup(FILE *boundaries, struct relations *relations) {
+ struct item_bin *ib;
+ GList *boundaries_list=NULL;
+ struct relations_func *relations_func;
- relations_func=relations_func_new(process_boundaries_member, NULL);
- while ((ib=read_item(boundaries))) {
- char *member=NULL;
- struct boundary *boundary=g_new0(struct boundary, 1);
- char *admin_level=osm_tag_value(ib, "admin_level");
- char *iso=osm_tag_value(ib, "ISO3166-1");
- int has_subrelations=0;
- int has_outer_ways=0;
-
- processed_relations++;
-
- if(!iso)
- iso=osm_tag_value(ib, "iso3166-1:alpha2");
-
- if (admin_level && !strcmp(admin_level, "2")) {
- if(!iso) {
- char *int_name=osm_tag_value(ib,"int_name");
- if(int_name && !strcmp(int_name,"France"))
- iso="FR";
- }
- if (iso) {
- struct country_table *country=country_from_iso2(iso);
- if (!country)
- osm_warning("relation",item_bin_get_relationid(ib),0,"Country Boundary contains unknown ISO3166-1 value '%s'\n",iso);
- else {
- boundary->iso2=g_strdup(iso);
- osm_info("relation",item_bin_get_relationid(ib),0,"Country Boundary for '%s'\n",iso);
- }
- boundary->country=country;
- } else
- osm_warning("relation",item_bin_get_relationid(ib),0,"Country Boundary doesn't contain an ISO3166-1 tag\n");
- }
- while ((member=item_bin_get_attr(ib, attr_osm_member, member))) {
- long long osm_id;
- int read=0;
- enum relation_member_type member_type;
- int member_type_numeric;
- char *rolestr;
+ relations_func=relations_func_new(process_boundaries_member, NULL);
+ while ((ib=read_item(boundaries))) {
+ char *member=NULL;
+ struct boundary *boundary=g_new0(struct boundary, 1);
+ char *admin_level=osm_tag_value(ib, "admin_level");
+ char *iso=osm_tag_value(ib, "ISO3166-1");
+ int has_subrelations=0;
+ int has_outer_ways=0;
- if (sscanf(member,RELATION_MEMBER_PARSE_FORMAT,&member_type_numeric,&osm_id,&read) < 2)
- continue;
-
- member_type=(enum relation_member_type)member_type_numeric;
- rolestr=member+read;
-
- if(member_type==rel_member_node) {
- if(!strcmp(rolestr,"admin_centre") || !strcmp(rolestr,"admin_center"))
- boundary->admin_centre=osm_id;
- }
- if(member_type==rel_member_way) {
- enum geom_poly_segment_type role;
- if (!strcmp(rolestr,"outer") || !strcmp(rolestr,"exclave")) {
- has_outer_ways=1;
- role=geom_poly_segment_type_way_outer;
- }
- else if (!strcmp(rolestr,"inner") || !strcmp(rolestr,"enclave"))
- role=geom_poly_segment_type_way_inner;
- else if (!strcmp(rolestr,""))
- role=geom_poly_segment_type_way_unknown;
- else {
- osm_warning("relation",item_bin_get_relationid(ib),0,"Unknown role %s in member ",rolestr);
- osm_warning("way",osm_id,1,"\n");
- role=geom_poly_segment_type_none;
- }
- relations_add_relation_member_entry(relations, relations_func, boundary, (gpointer)role, rel_member_way, osm_id);
- }
- if(member_type==rel_member_relation) {
- if (!strcmp(rolestr,"outer") || !strcmp(rolestr,"exclave") || !strcmp(rolestr,"inner") || !strcmp(rolestr,"enclave"))
- has_subrelations++;
- }
- }
- if(boundary->iso2 && has_subrelations)
- osm_warning("relation",item_bin_get_relationid(ib),0,"Country boundary '%s' has %d relations as boundary segments. These are not supported yet.\n", boundary->iso2, has_subrelations);
- if(boundary->iso2 && !has_outer_ways) {
- osm_warning("relation",item_bin_get_relationid(ib),0,"Skipping country boundary for '%s' because it has no outer ways.\n", boundary->iso2);
- g_free(boundary->iso2);
- boundary->iso2=NULL;
- }
+ processed_relations++;
- boundary->ib=item_bin_dup(ib);
- boundaries_list=g_list_append(boundaries_list, boundary);
- }
- return boundaries_list;
+ if(!iso)
+ iso=osm_tag_value(ib, "iso3166-1:alpha2");
+
+ if (!g_strcmp0(admin_level, "2")) {
+ if(!iso) {
+ char *int_name=osm_tag_value(ib,"int_name");
+ if(!g_strcmp0(int_name,"France"))
+ iso="FR";
+ }
+ if (iso) {
+ struct country_table *country=country_from_iso2(iso);
+ if (!country)
+ osm_warning("relation",item_bin_get_relationid(ib),0,"Country Boundary contains unknown ISO3166-1 value '%s'\n",iso);
+ else {
+ boundary->iso2=g_strdup(iso);
+ osm_info("relation",item_bin_get_relationid(ib),0,"Country Boundary for '%s'\n",iso);
+ }
+ boundary->country=country;
+ } else
+ osm_warning("relation",item_bin_get_relationid(ib),0,"Country Boundary doesn't contain an ISO3166-1 tag\n");
+ }
+ while ((member=item_bin_get_attr(ib, attr_osm_member, member))) {
+ long long osm_id;
+ int read=0;
+ enum relation_member_type member_type;
+ int member_type_numeric;
+ char *rolestr;
+
+ if (sscanf(member,RELATION_MEMBER_PARSE_FORMAT,&member_type_numeric,&osm_id,&read) < 2)
+ continue;
+
+ member_type=(enum relation_member_type)member_type_numeric;
+ rolestr=member+read;
+
+ if(member_type==rel_member_node) {
+ if(!g_strcmp0(rolestr,"admin_centre") || !g_strcmp0(rolestr,"admin_center"))
+ boundary->admin_centre=osm_id;
+ }
+ if(member_type==rel_member_way) {
+ enum geom_poly_segment_type role;
+ if (!g_strcmp0(rolestr,"outer") || !g_strcmp0(rolestr,"exclave")) {
+ has_outer_ways=1;
+ role=geom_poly_segment_type_way_outer;
+ } else if (!g_strcmp0(rolestr,"inner") || !g_strcmp0(rolestr,"enclave"))
+ role=geom_poly_segment_type_way_inner;
+ else if (!g_strcmp0(rolestr,""))
+ role=geom_poly_segment_type_way_unknown;
+ else {
+ osm_warning("relation",item_bin_get_relationid(ib),0,"Unknown role %s in member ",rolestr);
+ osm_warning("way",osm_id,1,"\n");
+ role=geom_poly_segment_type_none;
+ }
+ relations_add_relation_member_entry(relations, relations_func, boundary, (gpointer)role, rel_member_way, osm_id);
+ }
+ if(member_type==rel_member_relation) {
+ if (!g_strcmp0(rolestr,"outer") || !g_strcmp0(rolestr,"exclave") || !g_strcmp0(rolestr,"inner")
+ || !g_strcmp0(rolestr,"enclave"))
+ has_subrelations++;
+ }
+ }
+ if(boundary->iso2 && has_subrelations)
+ osm_warning("relation",item_bin_get_relationid(ib),0,
+ "Country boundary '%s' has %d relations as boundary segments. These are not supported yet.\n", boundary->iso2,
+ has_subrelations);
+ if(boundary->iso2 && !has_outer_ways) {
+ osm_warning("relation",item_bin_get_relationid(ib),0,
+ "Skipping country boundary for '%s' because it has no outer ways.\n", boundary->iso2);
+ g_free(boundary->iso2);
+ boundary->iso2=NULL;
+ }
+
+ boundary->ib=item_bin_dup(ib);
+ boundaries_list=g_list_append(boundaries_list, boundary);
+ }
+ return boundaries_list;
}
-GList *
-boundary_find_matches(GList *l, struct coord *c)
-{
- GList *ret=NULL;
- while (l) {
- struct boundary *boundary=l->data;
- if (bbox_contains_coord(&boundary->r, c)) {
- if (geom_poly_segments_point_inside(boundary->sorted_segments,c) > 0)
- ret=g_list_prepend(ret, boundary);
- ret=g_list_concat(ret,boundary_find_matches(boundary->children, c));
- }
- l=g_list_next(l);
- }
- return ret;
+GList *boundary_find_matches(GList *l, struct coord *c) {
+ GList *ret=NULL;
+ while (l) {
+ struct boundary *boundary=l->data;
+ if (bbox_contains_coord(&boundary->r, c)) {
+ if (geom_poly_segments_point_inside(boundary->sorted_segments,c) > 0)
+ ret=g_list_prepend(ret, boundary);
+ ret=g_list_concat(ret,boundary_find_matches(boundary->children, c));
+ }
+ l=g_list_next(l);
+ }
+ return ret;
}
#if 0
-static void
-test(GList *boundaries_list)
-{
- struct item_bin *ib;
- FILE *f=fopen("country_276.bin.unsorted","r");
- printf("start\n");
- while ((ib=read_item(f))) {
- struct coord *c=(struct coord *)(ib+1);
- char *name=item_bin_get_attr(ib, attr_town_name, NULL);
- printf("%s:",name);
- boundary_find_matches(boundaries_list, c);
- printf("\n");
- }
- fclose(f);
- printf("end\n");
+static void test(GList *boundaries_list) {
+ struct item_bin *ib;
+ FILE *f=fopen("country_276.bin.unsorted","r");
+ printf("start\n");
+ while ((ib=read_item(f))) {
+ struct coord *c=(struct coord *)(ib+1);
+ char *name=item_bin_get_attr(ib, attr_town_name, NULL);
+ printf("%s:",name);
+ boundary_find_matches(boundaries_list, c);
+ printf("\n");
+ }
+ fclose(f);
+ printf("end\n");
}
-static void
-dump_hierarchy(GList *l, char *prefix)
-{
- char *newprefix=g_alloca(sizeof(char)*(strlen(prefix)+2));
- strcpy(newprefix, prefix);
- strcat(newprefix," ");
- while (l) {
- struct boundary *boundary=l->data;
- fprintf(stderr,"%s:%s (0x%x,0x%x)-(0x%x,0x%x)\n",prefix,osm_tag_name(boundary->ib),boundary->r.l.x,boundary->r.l.y,boundary->r.h.x,boundary->r.h.y);
- dump_hierarchy(boundary->children, newprefix);
- l=g_list_next(l);
- }
+static void dump_hierarchy(GList *l, char *prefix) {
+ char *newprefix=g_alloca(sizeof(char)*(strlen(prefix)+2));
+ strcpy(newprefix, prefix);
+ strcat(newprefix," ");
+ while (l) {
+ struct boundary *boundary=l->data;
+ fprintf(stderr,"%s:%s (0x%x,0x%x)-(0x%x,0x%x)\n",prefix,osm_tag_name(boundary->ib),boundary->r.l.x,boundary->r.l.y,
+ boundary->r.h.x,boundary->r.h.y);
+ dump_hierarchy(boundary->children, newprefix);
+ l=g_list_next(l);
+ }
}
-static gint
-boundary_bbox_compare(gconstpointer a, gconstpointer b)
-{
- const struct boundary *boundarya=a;
- const struct boundary *boundaryb=b;
- long long areaa=bbox_area(&boundarya->r);
- long long areab=bbox_area(&boundaryb->r);
- if (areaa > areab)
- return 1;
- if (areaa < areab)
- return -1;
- return 0;
+static gint boundary_bbox_compare(gconstpointer a, gconstpointer b) {
+ const struct boundary *boundarya=a;
+ const struct boundary *boundaryb=b;
+ long long areaa=bbox_area(&boundarya->r);
+ long long areab=bbox_area(&boundaryb->r);
+ if (areaa > areab)
+ return 1;
+ if (areaa < areab)
+ return -1;
+ return 0;
}
#endif
-static GList *
-process_boundaries_insert(GList *list, struct boundary *boundary)
-{
- GList *l=list;
- while (l) {
- struct boundary *b=l->data;
- if (bbox_contains_bbox(&boundary->r, &b->r)) {
- list=g_list_remove(list, b);
- boundary->children=g_list_prepend(boundary->children, b);
- l=list;
- } else if (bbox_contains_bbox(&b->r, &boundary->r)) {
- b->children=process_boundaries_insert(b->children, boundary);
- return list;
- } else
- l=g_list_next(l);
- }
- return g_list_prepend(list, boundary);
+static GList *process_boundaries_insert(GList *list, struct boundary *boundary) {
+ GList *l=list;
+ while (l) {
+ struct boundary *b=l->data;
+ if (bbox_contains_bbox(&boundary->r, &b->r)) {
+ list=g_list_remove(list, b);
+ boundary->children=g_list_prepend(boundary->children, b);
+ l=list;
+ } else if (bbox_contains_bbox(&b->r, &boundary->r)) {
+ b->children=process_boundaries_insert(b->children, boundary);
+ return list;
+ } else
+ l=g_list_next(l);
+ }
+ return g_list_prepend(list, boundary);
}
-static GList *
-process_boundaries_finish(GList *boundaries_list)
-{
- GList *l,*sl;
- GList *ret=NULL;
- l=boundaries_list;
- while (l) {
- struct boundary *boundary=l->data;
- int first=1;
- FILE *f=NULL,*fu=NULL;
- if (boundary->country) {
- char *name=g_strdup_printf("country_%s_poly",boundary->iso2);
- f=tempfile("",name,1);
- g_free(name);
- }
- boundary->sorted_segments=geom_poly_segments_sort(boundary->segments, geom_poly_segment_type_way_right_side);
- sl=boundary->sorted_segments;
- while (sl) {
- struct geom_poly_segment *gs=sl->data;
- struct coord *c=gs->first;
- while (c <= gs->last) {
- if (first) {
- boundary->r.l=*c;
- boundary->r.h=*c;
- first=0;
- } else
- bbox_extend(c, &boundary->r);
- c++;
- }
- if (f) {
- struct item_bin *ib=tmp_item_bin;
- item_bin_init(ib, type_selected_line);
- /* FIXME check for overflow */
- item_bin_add_coord(ib, gs->first, gs->last-gs->first+1);
- item_bin_write(ib, f);
- }
- if (boundary->country) {
- if (!coord_is_equal(*gs->first,*gs->last)) {
- struct item_bin *ib;
- if (!fu) {
- char *name=g_strdup_printf("country_%s_broken",boundary->iso2);
- fu=tempfile("",name,1);
- g_free(name);
- }
- ib=tmp_item_bin;
- item_bin_init(ib, type_selected_point);
- item_bin_add_coord(ib, gs->first, 1);
- item_bin_write(ib, fu);
- item_bin_init(ib, type_selected_point);
- item_bin_add_coord(ib, gs->last, 1);
- item_bin_write(ib, fu);
- }
- }
- sl=g_list_next(sl);
- }
- ret=process_boundaries_insert(ret, boundary);
- l=g_list_next(l);
- if (f)
- fclose(f);
- if (fu) {
- if (boundary->country)
- osm_warning("relation",item_bin_get_relationid(boundary->ib),0,"Broken country polygon '%s'\n",boundary->iso2);
- fclose(fu);
- }
-
- }
-#if 0
- printf("hierarchy\n");
-#endif
-#if 0
- boundaries_list=g_list_sort(boundaries_list, boundary_bbox_compare);
- l=boundaries_list;
- while (l) {
- struct boundary *boundary=l->data;
- GList *l2,*ln;
- ln=l2=g_list_next(l);
- while (l2) {
- struct boundary *boundary2=l2->data;
- if (bbox_contains_bbox(&boundary2->r, &boundary->r)) {
- boundaries_list=g_list_remove(boundaries_list, boundary);
- boundary2->children=g_list_append(boundary2->children, boundary);
-#if 0
- printf("found\n");
-#endif
- break;
- }
- l2=g_list_next(l2);
- }
- l=ln;
- }
- dump_hierarchy(boundaries_list,"");
-#if 0
- printf("hierarchy done\n");
- printf("test\n");
- test(boundaries_list);
-#endif
-#endif
- return ret;
+static GList *process_boundaries_finish(GList *boundaries_list) {
+ GList *l,*sl;
+ GList *ret=NULL;
+ l=boundaries_list;
+ while (l) {
+ struct boundary *boundary=l->data;
+ int first=1;
+ FILE *f=NULL,*fu=NULL;
+ if (boundary->country) {
+ char *name=g_strdup_printf("country_%s_poly",boundary->iso2);
+ f=tempfile("",name,1);
+ g_free(name);
+ }
+ boundary->sorted_segments=geom_poly_segments_sort(boundary->segments, geom_poly_segment_type_way_right_side);
+ sl=boundary->sorted_segments;
+ while (sl) {
+ struct geom_poly_segment *gs=sl->data;
+ struct coord *c=gs->first;
+ while (c <= gs->last) {
+ if (first) {
+ boundary->r.l=*c;
+ boundary->r.h=*c;
+ first=0;
+ } else
+ bbox_extend(c, &boundary->r);
+ c++;
+ }
+ if (f) {
+ struct item_bin *ib=tmp_item_bin;
+ item_bin_init(ib, type_selected_line);
+ /* FIXME check for overflow */
+ item_bin_add_coord(ib, gs->first, gs->last-gs->first+1);
+ item_bin_write(ib, f);
+ }
+ if (boundary->country) {
+ if (!coord_is_equal(*gs->first,*gs->last)) {
+ struct item_bin *ib;
+ if (!fu) {
+ char *name=g_strdup_printf("country_%s_broken",boundary->iso2);
+ fu=tempfile("",name,1);
+ g_free(name);
+ }
+ ib=tmp_item_bin;
+ item_bin_init(ib, type_selected_point);
+ item_bin_add_coord(ib, gs->first, 1);
+ item_bin_write(ib, fu);
+ item_bin_init(ib, type_selected_point);
+ item_bin_add_coord(ib, gs->last, 1);
+ item_bin_write(ib, fu);
+ }
+ }
+ sl=g_list_next(sl);
+ }
+ ret=process_boundaries_insert(ret, boundary);
+ l=g_list_next(l);
+ if (f)
+ fclose(f);
+ if (fu) {
+ if (boundary->country)
+ osm_warning("relation",item_bin_get_relationid(boundary->ib),0,"Broken country polygon '%s'\n",boundary->iso2);
+ fclose(fu);
+ }
+
+ }
+ return ret;
}
-GList *
-process_boundaries(FILE *boundaries, FILE *ways)
-{
- GList *boundaries_list;
- struct relations *relations=relations_new();
+GList *process_boundaries(FILE *boundaries, FILE *ways) {
+ GList *boundaries_list;
+ struct relations *relations=relations_new();
- boundaries_list=process_boundaries_setup(boundaries, relations);
- relations_process(relations, NULL, ways);
- relations_destroy(relations);
- return process_boundaries_finish(boundaries_list);
+ boundaries_list=process_boundaries_setup(boundaries, relations);
+ relations_process(relations, NULL, ways);
+ relations_destroy(relations);
+ return process_boundaries_finish(boundaries_list);
}
-void
-free_boundaries(GList *bl)
-{
- GList *l=bl;
- while (l) {
- struct boundary *boundary=l->data;
- GList *s=boundary->segments;
- while (s) {
- struct geom_poly_segment *seg=s->data;
- g_free(seg->first);
- g_free(seg);
- s=g_list_next(s);
- };
- s=boundary->sorted_segments;
- while (s) {
- struct geom_poly_segment *seg=s->data;
- g_free(seg->first);
- g_free(seg);
- s=g_list_next(s);
- };
- g_list_free(boundary->segments);
- g_list_free(boundary->sorted_segments);
- g_free(boundary->ib);
- g_free(boundary->iso2);
- free_boundaries(boundary->children);
- g_free(boundary);
- l=g_list_next(l);
- }
- g_list_free(bl);
+void free_boundaries(GList *bl) {
+ GList *l=bl;
+ while (l) {
+ struct boundary *boundary=l->data;
+ GList *s=boundary->segments;
+ while (s) {
+ struct geom_poly_segment *seg=s->data;
+ g_free(seg->first);
+ g_free(seg);
+ s=g_list_next(s);
+ };
+ s=boundary->sorted_segments;
+ while (s) {
+ struct geom_poly_segment *seg=s->data;
+ g_free(seg->first);
+ g_free(seg);
+ s=g_list_next(s);
+ };
+ g_list_free(boundary->segments);
+ g_list_free(boundary->sorted_segments);
+ g_free(boundary->ib);
+ g_free(boundary->iso2);
+ free_boundaries(boundary->children);
+ g_free(boundary);
+ l=g_list_next(l);
+ }
+ g_list_free(bl);
}
diff --git a/navit/maptool/buffer.c b/navit/maptool/buffer.c
index 2907b0670..08f65f2b6 100644
--- a/navit/maptool/buffer.c
+++ b/navit/maptool/buffer.c
@@ -1,6 +1,6 @@
/**
* Navit, a modular navigation system.
- * Copyright (C) 2005-2011 Navit Team
+ * Copyright (C) 2005-2018 Navit Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -21,56 +21,76 @@
#include "maptool.h"
#include "debug.h"
-void
-save_buffer(char *filename, struct buffer *b, long long offset)
-{
- FILE *f;
- f=fopen(filename,"rb+");
- if (! f)
- f=fopen(filename,"wb+");
-
- dbg_assert(f != NULL);
- dbg_assert(fseeko(f, offset, SEEK_SET)==0);
- dbg_assert(fwrite(b->base, b->size, 1, f)==1);
- fclose(f);
-}
+/**
+ * @brief Saves a buffer to a file
+ *
+ * This function saves a buffer to a file.
+ *
+ * @param filename The name of the while to where the buffer is saved to.
+ * @param b Buffer which is saved to file.
+ * @param offset
+ */
+void save_buffer(char *filename, struct buffer *b, long long offset) {
+ FILE *f;
+ f=fopen(filename,"rb+");
+ if (! f)
+ f=fopen(filename,"wb+");
-void
-load_buffer(char *filename, struct buffer *b, long long offset, long long size)
-{
- FILE *f;
- long long len;
- dbg_assert(size>=0);
- dbg_assert(offset>=0);
- if (b->base)
- free(b->base);
- b->malloced=0;
- f=fopen(filename,"rb");
- fseeko(f, 0, SEEK_END);
- len=ftello(f);
- dbg_assert(len>=0);
- if (offset+size > len) {
- size=len-offset;
- }
- b->size=b->malloced=size;
- dbg_assert(b->size>0);
-#if 0
- fprintf(stderr,"reading "LONGLONG_FMT" bytes from %s of "LONGLONG_FMT" bytes at "LONGLONG_FMT"\n", b->size, filename, len, offset);
-#endif
- fseeko(f, offset, SEEK_SET);
- b->base=malloc(b->size);
- dbg_assert(b->base != NULL);
- fread(b->base, b->size, 1, f);
- fclose(f);
+ dbg_assert(f != NULL);
+ dbg_assert(fseeko(f, offset, SEEK_SET)==0);
+ dbg_assert(fwrite(b->base, b->size, 1, f)==1);
+ fclose(f);
}
+/**
+ * @brief Loads a buffer from a file
+ *
+ * This function loads a buffer from a file.
+ *
+ * @param filename The name of the while to where the buffer is loaded from.
+ * @param b Buffer in which file is loaded.
+ * @param offset
+ * @return indicator if operation suceeded
+ */
+int load_buffer(char *filename, struct buffer *b, long long offset, long long size) {
+ FILE *f;
+ long long len;
+ dbg_assert(size>=0);
+ dbg_assert(offset>=0);
+ g_free(b->base);
+ b->malloced=0;
+ f=fopen(filename,"rb");
+ fseeko(f, 0, SEEK_END);
+ len=ftello(f);
+ dbg_assert(len>=0);
+ if (offset+size > len) {
+ size=len-offset;
+ }
+ b->size=b->malloced=size;
+ dbg_assert(b->size>0);
-long long
-sizeof_buffer(char *filename)
-{
- long long ret;
- FILE *f=fopen(filename,"rb");
- fseeko(f, 0, SEEK_END);
- ret=ftello(f);
- fclose(f);
- return ret;
+ fseeko(f, offset, SEEK_SET);
+ b->base=g_malloc(b->size);
+ if (fread(b->base, b->size, 1, f) == 0) {
+ dbg(lvl_warning, "fread failed");
+ fclose(f);
+ return 0;
+ }
+ fclose(f);
+ return 1;
+}
+/**
+ * @brief Determines size of buffer for file
+ *
+ * This function determines the size of the buffer required to read a file.
+ *
+ * @param filename Name of file for which the required size of the buffer is determined
+ * @return required size of buffer
+ */
+long long sizeof_buffer(char *filename) {
+ long long ret;
+ FILE *f=fopen(filename,"rb");
+ fseeko(f, 0, SEEK_END);
+ ret=ftello(f);
+ fclose(f);
+ return ret;
}
diff --git a/navit/maptool/ch.c b/navit/maptool/ch.c
index b1b0b1bf6..29c3f81ee 100644
--- a/navit/maptool/ch.c
+++ b/navit/maptool/ch.c
@@ -33,32 +33,32 @@
#endif
struct ch_edge {
- int flags;
- int weight;
- struct item_id target,middle;
+ int flags;
+ int weight;
+ struct item_id target,middle;
};
struct node {
- int first_edge;
- int dummy;
+ int first_edge;
+ int dummy;
} *nodes;
int node_count;
struct edge {
- unsigned target:26;
- unsigned scedge1:6;
- unsigned weight:28;
- unsigned type:2;
- unsigned flags:2;
- unsigned int edge_count;
- unsigned scedge2:6;
- unsigned scmiddle:26;
+ unsigned target:26;
+ unsigned scedge1:6;
+ unsigned weight:28;
+ unsigned type:2;
+ unsigned flags:2;
+ unsigned int edge_count;
+ unsigned scedge2:6;
+ unsigned scmiddle:26;
} *edges;
int edge_count;
struct newnode {
- int newnode;
+ int newnode;
} *newnodes;
int newnode_count;
@@ -66,7 +66,7 @@ int newnode_count;
GHashTable *newnode_hash;
struct edge_hash_item {
- int first,last;
+ int first,last;
};
@@ -80,471 +80,431 @@ GHashTable *sgr_nodes_hash;
static int ch_levels=14;
-static int
-road_speed(enum item_type type)
-{
- switch (type) {
- case type_street_0:
- case type_street_1_city:
- case type_living_street:
- case type_street_service:
- case type_track_gravelled:
- case type_track_unpaved:
- return 10;
- case type_street_2_city:
- case type_track_paved:
- return 30;
- case type_street_3_city:
- return 40;
- case type_street_4_city:
- return 50;
- case type_highway_city:
- return 80;
- case type_street_1_land:
- return 60;
- case type_street_2_land:
- return 65;
- case type_street_3_land:
- return 70;
- case type_street_4_land:
- return 80;
- case type_street_n_lanes:
- return 120;
- case type_highway_land:
- return 120;
- case type_ramp:
- return 40;
- case type_roundabout:
- return 10;
- case type_ferry:
- return 40;
- default:
- return 0;
- }
+static int road_speed(enum item_type type) {
+ switch (type) {
+ case type_street_0:
+ case type_street_1_city:
+ case type_living_street:
+ case type_street_service:
+ case type_track_gravelled:
+ case type_track_unpaved:
+ return 10;
+ case type_street_2_city:
+ case type_track_paved:
+ return 30;
+ case type_street_3_city:
+ return 40;
+ case type_street_4_city:
+ return 50;
+ case type_highway_city:
+ return 80;
+ case type_street_1_land:
+ return 60;
+ case type_street_2_land:
+ return 65;
+ case type_street_3_land:
+ return 70;
+ case type_street_4_land:
+ return 80;
+ case type_street_n_lanes:
+ return 120;
+ case type_highway_land:
+ return 120;
+ case type_ramp:
+ return 40;
+ case type_roundabout:
+ return 10;
+ case type_ferry:
+ return 40;
+ default:
+ return 0;
+ }
}
-static void
-coord_slice_free(void *data)
-{
- g_slice_free(struct coord, data);
+static void coord_slice_free(void *data) {
+ g_slice_free(struct coord, data);
}
-static GHashTable *
-coord_hash_new(void)
-{
- return g_hash_table_new_full(coord_hash, coord_equal, coord_slice_free, NULL);
+static GHashTable *coord_hash_new(void) {
+ return g_hash_table_new_full(coord_hash, coord_equal, coord_slice_free, NULL);
}
-static void
-item_id_slice_free(void *data)
-{
- g_slice_free(struct item_id, data);
+static void item_id_slice_free(void *data) {
+ g_slice_free(struct item_id, data);
}
-static void
-add_node_to_hash(FILE *idx, GHashTable *hash, struct coord *c, int *nodes)
-{
- if (! g_hash_table_lookup(hash, c)) {
- struct coord *ct=g_slice_new(struct coord);
- *ct=*c;
- fwrite(c, sizeof(*c), 1, idx);
- (*nodes)++;
- g_hash_table_insert(hash, ct, GINT_TO_POINTER(*nodes));
- }
+static void add_node_to_hash(FILE *idx, GHashTable *hash, struct coord *c, int *nodes) {
+ if (! g_hash_table_lookup(hash, c)) {
+ struct coord *ct=g_slice_new(struct coord);
+ *ct=*c;
+ fwrite(c, sizeof(*c), 1, idx);
+ (*nodes)++;
+ g_hash_table_insert(hash, ct, GINT_TO_POINTER(*nodes));
+ }
}
-static void
-edge_hash_slice_free(void *data)
-{
- g_slice_free(struct edge_hash_item, data);
+static void edge_hash_slice_free(void *data) {
+ g_slice_free(struct edge_hash_item, data);
}
-static guint
-edge_hash_hash(gconstpointer key)
-{
- const struct edge_hash_item *itm=key;
- return itm->first*2654435761UL+itm->last;
+static guint edge_hash_hash(gconstpointer key) {
+ const struct edge_hash_item *itm=key;
+ return itm->first*2654435761UL+itm->last;
}
-static gboolean
-edge_hash_equal(gconstpointer a, gconstpointer b)
-{
- const struct edge_hash_item *itm_a=a;
- const struct edge_hash_item *itm_b=b;
- return (itm_a->first == itm_b->first && itm_a->last == itm_b->last);
+static gboolean edge_hash_equal(gconstpointer a, gconstpointer b) {
+ const struct edge_hash_item *itm_a=a;
+ const struct edge_hash_item *itm_b=b;
+ return (itm_a->first == itm_b->first && itm_a->last == itm_b->last);
}
-static void
-ch_generate_ddsg(FILE *in, FILE *ref, FILE *idx, FILE *ddsg)
-{
- GHashTable *hash=coord_hash_new();
- struct item_bin *ib;
- int nodes=0,edges=0;
-
- while ((ib=read_item(in))) {
- int ccount=ib->clen/2;
- struct coord *c=(struct coord *)(ib+1);
- if (road_speed(ib->type)) {
- add_node_to_hash(idx, hash, &c[0], &nodes);
- add_node_to_hash(idx, hash, &c[ccount-1], &nodes);
- edges++;
- }
- }
- edge_hash=g_hash_table_new_full(edge_hash_hash, edge_hash_equal, edge_hash_slice_free, item_id_slice_free);
- fseek(in, 0, SEEK_SET);
- fprintf(ddsg,"d\n");
- fprintf(ddsg,"%d %d\n", nodes, edges);
- while ((ib=read_item(in))) {
- int i,ccount=ib->clen/2;
- struct coord *c=(struct coord *)(ib+1);
- int n1,n2,speed=road_speed(ib->type);
- struct item_id road_id;
- double l;
- fread(&road_id, sizeof(road_id), 1, ref);
- if (speed) {
- struct edge_hash_item *hi=g_slice_new(struct edge_hash_item);
- struct item_id *id=g_slice_new(struct item_id);
- *id=road_id;
- dbg_assert((n1=GPOINTER_TO_INT(g_hash_table_lookup(hash, &c[0]))) != 0);
- dbg_assert((n2=GPOINTER_TO_INT(g_hash_table_lookup(hash, &c[ccount-1]))) != 0);
- l=0;
- for (i = 0 ; i < ccount-1 ; i++) {
- l+=sqrt(sq(c[i+1].x-c[i].x)+sq(c[i+1].y-c[i].y));
- }
- fprintf(ddsg,"%d %d %d 0\n", n1-1, n2-1, (int)(l*36/speed));
- hi->first=n1-1;
- hi->last=n2-1;
- g_hash_table_insert(edge_hash, hi, id);
- }
- }
- g_hash_table_destroy(hash);
+static void ch_generate_ddsg(FILE *in, FILE *ref, FILE *idx, FILE *ddsg) {
+ GHashTable *hash=coord_hash_new();
+ struct item_bin *ib;
+ int nodes=0,edges=0;
+
+ while ((ib=read_item(in))) {
+ int ccount=ib->clen/2;
+ struct coord *c=(struct coord *)(ib+1);
+ if (road_speed(ib->type)) {
+ add_node_to_hash(idx, hash, &c[0], &nodes);
+ add_node_to_hash(idx, hash, &c[ccount-1], &nodes);
+ edges++;
+ }
+ }
+ edge_hash=g_hash_table_new_full(edge_hash_hash, edge_hash_equal, edge_hash_slice_free, item_id_slice_free);
+ fseek(in, 0, SEEK_SET);
+ fprintf(ddsg,"d\n");
+ fprintf(ddsg,"%d %d\n", nodes, edges);
+ while ((ib=read_item(in))) {
+ int i,ccount=ib->clen/2;
+ struct coord *c=(struct coord *)(ib+1);
+ int n1,n2,speed=road_speed(ib->type);
+ struct item_id road_id;
+ double l;
+
+ if (fread(&road_id, sizeof(road_id), 1, ref) == 0) {
+ dbg(lvl_warning, "fread failed");
+ continue;
+ }
+ if (speed) {
+ struct edge_hash_item *hi=g_slice_new(struct edge_hash_item);
+ struct item_id *id=g_slice_new(struct item_id);
+ *id=road_id;
+ dbg_assert((n1=GPOINTER_TO_INT(g_hash_table_lookup(hash, &c[0]))) != 0);
+ dbg_assert((n2=GPOINTER_TO_INT(g_hash_table_lookup(hash, &c[ccount-1]))) != 0);
+ l=0;
+ for (i = 0 ; i < ccount-1 ; i++) {
+ l+=sqrt(sq(c[i+1].x-c[i].x)+sq(c[i+1].y-c[i].y));
+ }
+ fprintf(ddsg,"%d %d %d 0\n", n1-1, n2-1, (int)(l*36/speed));
+ hi->first=n1-1;
+ hi->last=n2-1;
+ g_hash_table_insert(edge_hash, hi, id);
+ }
+ }
+ g_hash_table_destroy(hash);
}
-static void
-ch_generate_sgr(char *suffix)
-{
+static void ch_generate_sgr(char *suffix) {
#ifndef HAVE_API_WIN32_CE
- char command[1024];
- sprintf(command,"./contraction-hierarchies-20080621/main -s -p -f ddsg_%s.tmp -o hcn_%s.tmp -l hcn_log_%s.tmp -x 190 -y 1 -e 600 -p 1000 -k 1,3.3,2,10,3,10,5",suffix,suffix,suffix);
- printf("%s\n",command);
- system(command);
- sprintf(command,"./contraction-hierarchies-20080621/main -c -f ddsg_%s.tmp -h hcn_%s.tmp -k 1,3.3,2,10,3,10,5 -C ch_%s.tmp -O 1 -z sgr_%s.tmp",suffix,suffix,suffix,suffix);
- printf("%s\n",command);
- system(command);
+ char command[1024];
+ int system_result;
+ sprintf(command,
+ "./contraction-hierarchies-20080621/main -s -p -f ddsg_%s.tmp -o hcn_%s.tmp -l hcn_log_%s.tmp -x 190 -y 1 -e 600 -p 1000 -k 1,3.3,2,10,3,10,5",
+ suffix,suffix,suffix);
+ printf("%s\n",command);
+ system_result = system(command);
+ if (system_result == -1) {
+ dbg(lvl_warning, "Running main failed");
+ }
+ sprintf(command,
+ "./contraction-hierarchies-20080621/main -c -f ddsg_%s.tmp -h hcn_%s.tmp -k 1,3.3,2,10,3,10,5 -C ch_%s.tmp -O 1 -z sgr_%s.tmp",
+ suffix,suffix,suffix,suffix);
+ printf("%s\n",command);
+ system_result = system(command);
+ if (system_result == -1) {
+ dbg(lvl_warning, "Running main failed");
+ }
#endif
}
-static void
-ch_process_node(FILE *out, int node, int resolve)
-{
- int first_edge_id=nodes[node].first_edge;
- int last_edge_id=nodes[node+1].first_edge;
- int edge_id;
- struct ch_edge ch_edge;
- struct item_bin *item_bin;
- struct edge_hash_item fwd,rev;
- int oldnode;
- memset(&ch_edge, 0, sizeof(ch_edge));
- item_bin=init_item(type_ch_node);
- oldnode=GPOINTER_TO_INT(g_hash_table_lookup(newnode_hash, GINT_TO_POINTER(node)));
-#if 0
- dbg(lvl_debug,"0x%x,0x%x\n",node_index[oldnode].x,node_index[oldnode].y);
-#endif
- item_bin_add_coord(item_bin, &node_index[oldnode], 1);
- fwd.first=oldnode;
- rev.last=oldnode;
- for (edge_id = first_edge_id ; edge_id < last_edge_id ; edge_id++) {
- if (resolve) {
- struct edge *edge=&edges[edge_id];
- int oldnode=GPOINTER_TO_INT(g_hash_table_lookup(newnode_hash, GINT_TO_POINTER((int)edge->target)));
- struct item_id *id;
- ch_edge.weight=edge->weight;
- fwd.last=oldnode;
- rev.first=oldnode;
- ch_edge.flags=edge->flags & 3;
- if (edge->scmiddle == 67108863) {
- id=g_hash_table_lookup(edge_hash, &fwd);
- if (!id) {
- ch_edge.flags|=8;
- id=g_hash_table_lookup(edge_hash, &rev);
- }
- if (id == NULL) {
- fprintf(stderr,"Shortcut %d Weight %d\n",edge->scmiddle,edge->weight);
- fprintf(stderr,"Neither %d-%d nor %d-%d exists\n",fwd.first,fwd.last,rev.first,rev.last);
- exit(1);
- } else {
- ch_edge.middle=*id;
-#if 0
- dbg(lvl_debug,"middle street id for is "ITEM_ID_FMT"\n",ITEM_ID_ARGS(*id));
-#endif
- }
- } else {
- ch_edge.flags|=4;
- id=g_hash_table_lookup(sgr_nodes_hash, GINT_TO_POINTER((int)edge->scmiddle));
- dbg_assert(id != NULL);
- ch_edge.middle=*id;
-#if 0
- dbg(lvl_debug,"middle node id for is "ITEM_ID_FMT"\n",ITEM_ID_ARGS(*id));
-#endif
- }
- id=g_hash_table_lookup(sgr_nodes_hash, GINT_TO_POINTER((int)edge->target));
-#if 0
- dbg(lvl_debug,"id for %d is "ITEM_ID_FMT"\n",edge->target,ITEM_ID_ARGS(*id));
-#endif
- if (id == NULL) {
- fprintf(stderr,"Failed to look up target %d\n",edge->target);
- } else {
- ch_edge.target=*id;
- }
- }
- item_bin_add_attr_data(item_bin,attr_ch_edge,&ch_edge,sizeof(ch_edge));
- }
- item_bin_write(item_bin, out);
+static void ch_process_node(FILE *out, int node, int resolve) {
+ int first_edge_id=nodes[node].first_edge;
+ int last_edge_id=nodes[node+1].first_edge;
+ int edge_id;
+ struct ch_edge ch_edge;
+ struct item_bin *item_bin;
+ struct edge_hash_item fwd,rev;
+ int oldnode;
+ memset(&ch_edge, 0, sizeof(ch_edge));
+ item_bin=init_item(type_ch_node);
+ oldnode=GPOINTER_TO_INT(g_hash_table_lookup(newnode_hash, GINT_TO_POINTER(node)));
+ item_bin_add_coord(item_bin, &node_index[oldnode], 1);
+ fwd.first=oldnode;
+ rev.last=oldnode;
+ for (edge_id = first_edge_id ; edge_id < last_edge_id ; edge_id++) {
+ if (resolve) {
+ struct edge *edge=&edges[edge_id];
+ int oldnode=GPOINTER_TO_INT(g_hash_table_lookup(newnode_hash, GINT_TO_POINTER((int)edge->target)));
+ struct item_id *id;
+ ch_edge.weight=edge->weight;
+ fwd.last=oldnode;
+ rev.first=oldnode;
+ ch_edge.flags=edge->flags & 3;
+ if (edge->scmiddle == 67108863) {
+ id=g_hash_table_lookup(edge_hash, &fwd);
+ if (!id) {
+ ch_edge.flags|=8;
+ id=g_hash_table_lookup(edge_hash, &rev);
+ }
+ if (id == NULL) {
+ fprintf(stderr,"Shortcut %d Weight %d\n",edge->scmiddle,edge->weight);
+ fprintf(stderr,"Neither %d-%d nor %d-%d exists\n",fwd.first,fwd.last,rev.first,rev.last);
+ exit(1);
+ } else {
+ ch_edge.middle=*id;
+ }
+ } else {
+ ch_edge.flags|=4;
+ id=g_hash_table_lookup(sgr_nodes_hash, GINT_TO_POINTER((int)edge->scmiddle));
+ dbg_assert(id != NULL);
+ ch_edge.middle=*id;
+ }
+ id=g_hash_table_lookup(sgr_nodes_hash, GINT_TO_POINTER((int)edge->target));
+ if (id == NULL) {
+ fprintf(stderr,"Failed to look up target %d\n",edge->target);
+ } else {
+ ch_edge.target=*id;
+ }
+ }
+ item_bin_add_attr_data(item_bin,attr_ch_edge,&ch_edge,sizeof(ch_edge));
+ }
+ item_bin_write(item_bin, out);
}
-static void
-ch_process_nodes(FILE *out, int pos, int count, int resolve)
-{
- int i;
- printf("count %d sum=%d newnode_count=%d\n",count,pos,newnode_count);
- for (i = 0 ; i < count ; i++)
- ch_process_node(out, pos+i, resolve);
+static void ch_process_nodes(FILE *out, int pos, int count, int resolve) {
+ int i;
+ printf("count %d sum=%d newnode_count=%d\n",count,pos,newnode_count);
+ for (i = 0 ; i < count ; i++)
+ ch_process_node(out, pos+i, resolve);
}
-static void
-ch_process(FILE **files, int depth, int resolve)
-{
- int count=newnode_count;
- int pos=0;
+static void ch_process(FILE **files, int depth, int resolve) {
+ int count=newnode_count;
+ int pos=0;
- while (depth > 0 && pos < newnode_count) {
- count=(count+1)/2;
- ch_process_nodes(files[depth], pos, count, resolve);
- pos+=count;
- depth--;
- }
- ch_process_nodes(files[depth], pos, newnode_count-pos, resolve);
+ while (depth > 0 && pos < newnode_count) {
+ count=(count+1)/2;
+ ch_process_nodes(files[depth], pos, count, resolve);
+ pos+=count;
+ depth--;
+ }
+ ch_process_nodes(files[depth], pos, newnode_count-pos, resolve);
}
-static void
-ch_setup(char *suffix)
-{
- int i;
- if (!sgr) {
- int *data,size,offset=0;
- char *filename=tempfile_name(suffix,"sgr");
- printf("filename=%s\n",filename);
- sgr=file_create(filename,0);
- g_free(filename);
- dbg_assert(sgr != NULL);
- file_mmap(sgr);
-
- size=sizeof(int);
- data=(int *)file_data_read(sgr, offset, size);
- node_count=*data;
- offset+=size;
-
- size=node_count*sizeof(struct node);
- nodes=(struct node *)file_data_read(sgr, offset, size);
- offset+=size;
-
- size=sizeof(int);
- data=(int *)file_data_read(sgr, offset, size);
- edge_count=*data;
- offset+=size;
-
- size=edge_count*sizeof(struct edge);
- edges=(struct edge *)file_data_read(sgr, offset, size);
- offset+=size;
-
- size=sizeof(int);
- data=(int *)file_data_read(sgr, offset, size);
- newnode_count=*data;
- offset+=size;
-
- size=edge_count*sizeof(struct newnode);
- newnodes=(struct newnode *)file_data_read(sgr, offset, size);
- offset+=size;
-
- newnode_hash=g_hash_table_new(NULL, NULL);
-
- for (i = 0 ; i < newnode_count ; i++) {
- g_hash_table_insert(newnode_hash, GINT_TO_POINTER(newnodes[i].newnode), GINT_TO_POINTER(i));
- }
- }
- if (!ddsg_node_index) {
- char *filename=tempfile_name(suffix,"ddsg_coords");
- ddsg_node_index=file_create(filename,0);
- g_free(filename);
- dbg_assert(ddsg_node_index != NULL);
- file_mmap(ddsg_node_index);
- node_index=(struct coord *)file_data_read(ddsg_node_index, 0, file_size(ddsg_node_index));
- }
+static void ch_setup(char *suffix) {
+ int i;
+ if (!sgr) {
+ int *data,size,offset=0;
+ char *filename=tempfile_name(suffix,"sgr");
+ printf("filename=%s\n",filename);
+ sgr=file_create(filename,0);
+ g_free(filename);
+ dbg_assert(sgr != NULL);
+ file_mmap(sgr);
+
+ size=sizeof(int);
+ data=(int *)file_data_read(sgr, offset, size);
+ node_count=*data;
+ offset+=size;
+
+ size=node_count*sizeof(struct node);
+ nodes=(struct node *)file_data_read(sgr, offset, size);
+ offset+=size;
+
+ size=sizeof(int);
+ data=(int *)file_data_read(sgr, offset, size);
+ edge_count=*data;
+ offset+=size;
+
+ size=edge_count*sizeof(struct edge);
+ edges=(struct edge *)file_data_read(sgr, offset, size);
+ offset+=size;
+
+ size=sizeof(int);
+ data=(int *)file_data_read(sgr, offset, size);
+ newnode_count=*data;
+ offset+=size;
+
+ size=edge_count*sizeof(struct newnode);
+ newnodes=(struct newnode *)file_data_read(sgr, offset, size);
+ offset+=size;
+
+ newnode_hash=g_hash_table_new(NULL, NULL);
+
+ for (i = 0 ; i < newnode_count ; i++) {
+ g_hash_table_insert(newnode_hash, GINT_TO_POINTER(newnodes[i].newnode), GINT_TO_POINTER(i));
+ }
+ }
+ if (!ddsg_node_index) {
+ char *filename=tempfile_name(suffix,"ddsg_coords");
+ ddsg_node_index=file_create(filename,0);
+ g_free(filename);
+ dbg_assert(ddsg_node_index != NULL);
+ file_mmap(ddsg_node_index);
+ node_index=(struct coord *)file_data_read(ddsg_node_index, 0, file_size(ddsg_node_index));
+ }
}
-static void
-ch_create_tempfiles(char *suffix, FILE **files, int count, int mode)
-{
- char name[256];
- int i;
+static void ch_create_tempfiles(char *suffix, FILE **files, int count, int mode) {
+ char name[256];
+ int i;
- for (i = 0 ; i <= count ; i++) {
- sprintf(name,"graph_%d",i);
- files[i]=tempfile(suffix, name, mode);
- }
+ for (i = 0 ; i <= count ; i++) {
+ sprintf(name,"graph_%d",i);
+ files[i]=tempfile(suffix, name, mode);
+ }
}
-static void
-ch_close_tempfiles(FILE **files, int count)
-{
- int i;
+static void ch_close_tempfiles(FILE **files, int count) {
+ int i;
- for (i = 0 ; i <= count ; i++) {
- fclose(files[i]);
- }
+ for (i = 0 ; i <= count ; i++) {
+ fclose(files[i]);
+ }
}
#if 0
-static void
-ch_remove_tempfiles(char *suffix, int count)
-{
- char name[256];
- int i;
-
- for (i = 0 ; i <= count ; i++) {
- sprintf(name,"graph_%d",i);
- tempfile_unlink(suffix, name);
- }
+static void ch_remove_tempfiles(char *suffix, int count) {
+ char name[256];
+ int i;
+
+ for (i = 0 ; i <= count ; i++) {
+ sprintf(name,"graph_%d",i);
+ tempfile_unlink(suffix, name);
+ }
}
#endif
-static void
-ch_copy_to_tiles(char *suffix, int count, struct tile_info *info, FILE *ref)
-{
- char name[256];
- int i;
- FILE *f;
- struct item_bin *item_bin;
-
- for (i = count ; i >= 0 ; i--) {
- sprintf(name,"graph_%d",i);
- f=tempfile(suffix, name, 0);
- while ((item_bin = read_item(f))) {
- tile_write_item_minmax(info, item_bin, ref, i, i);
- }
- fclose(f);
- }
+static void ch_copy_to_tiles(char *suffix, int count, struct tile_info *info, FILE *ref) {
+ char name[256];
+ int i;
+ FILE *f;
+ struct item_bin *item_bin;
+
+ for (i = count ; i >= 0 ; i--) {
+ sprintf(name,"graph_%d",i);
+ f=tempfile(suffix, name, 0);
+ while ((item_bin = read_item(f))) {
+ tile_write_item_minmax(info, item_bin, ref, i, i);
+ }
+ fclose(f);
+ }
}
-void
-ch_generate_tiles(char *map_suffix, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info)
-{
- struct tile_info info;
- FILE *in,*ref,*ddsg_coords,*ddsg;
- FILE **graphfiles;
- info.write=0;
- info.maxlen=0;
- info.suffix=suffix;
- info.tiles_list=NULL;
- info.tilesdir_out=tilesdir_out;
- graphfiles=g_alloca(sizeof(FILE*)*(ch_levels+1));
-
- ch_create_tempfiles(suffix, graphfiles, ch_levels, 1);
- in=tempfile(map_suffix,"ways_split",0);
- ref=tempfile(map_suffix,"ways_split_ref",0);
- ddsg_coords=tempfile(suffix,"ddsg_coords",1);
- ddsg=tempfile(suffix,"ddsg",1);
- ch_generate_ddsg(in, ref, ddsg_coords, ddsg);
- fclose(in);
- fclose(ref);
- fclose(ddsg_coords);
- fclose(ddsg);
- ch_generate_sgr(suffix);
- ch_setup(suffix);
- ch_process(graphfiles, ch_levels, 0);
- ch_close_tempfiles(graphfiles, ch_levels);
-
- tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
- ch_copy_to_tiles(suffix, ch_levels, &info, NULL);
- merge_tiles(&info);
-
- write_tilesdir(&info, zip_info, tilesdir_out);
+void ch_generate_tiles(char *map_suffix, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info) {
+ struct tile_info info;
+ FILE *in,*ref,*ddsg_coords,*ddsg;
+ FILE **graphfiles;
+ info.write=0;
+ info.maxlen=0;
+ info.suffix=suffix;
+ info.tiles_list=NULL;
+ info.tilesdir_out=tilesdir_out;
+ graphfiles=g_alloca(sizeof(FILE*)*(ch_levels+1));
+
+ ch_create_tempfiles(suffix, graphfiles, ch_levels, 1);
+ in=tempfile(map_suffix,"ways_split",0);
+ ref=tempfile(map_suffix,"ways_split_ref",0);
+ ddsg_coords=tempfile(suffix,"ddsg_coords",1);
+ ddsg=tempfile(suffix,"ddsg",1);
+ ch_generate_ddsg(in, ref, ddsg_coords, ddsg);
+ fclose(in);
+ fclose(ref);
+ fclose(ddsg_coords);
+ fclose(ddsg);
+ ch_generate_sgr(suffix);
+ ch_setup(suffix);
+ ch_process(graphfiles, ch_levels, 0);
+ ch_close_tempfiles(graphfiles, ch_levels);
+
+ tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ ch_copy_to_tiles(suffix, ch_levels, &info, NULL);
+ merge_tiles(&info);
+
+ write_tilesdir(&info, zip_info, tilesdir_out);
}
-void
-ch_assemble_map(char *map_suffix, char *suffix, struct zip_info *zip_info)
-{
- struct tile_info info;
- struct tile_head *th;
- FILE **graphfiles=g_alloca(sizeof(FILE*)*(ch_levels+1));
- FILE *ref;
- struct item_id id;
- int nodeid=0;
-
- info.write=1;
- info.maxlen=zip_get_maxnamelen(zip_info);
- info.suffix=suffix;
- info.tiles_list=NULL;
- info.tilesdir_out=NULL;
- ref=tempfile(suffix,"sgr_ref",1);
-
- create_tile_hash();
-
- th=tile_head_root;
- while (th) {
- th->zip_data=NULL;
- th->process=1;
- th=th->next;
- }
-
- ch_setup(suffix);
- ch_copy_to_tiles(suffix, ch_levels, &info, ref);
- fclose(ref);
- ref=tempfile(suffix,"sgr_ref",0);
- sgr_nodes_hash=g_hash_table_new_full(NULL, NULL, NULL, item_id_slice_free);
- while (fread(&id, sizeof(id), 1, ref)) {
- struct item_id *id2=g_slice_new(struct item_id);
- *id2=id;
-#if 0
- dbg(lvl_debug,"%d is "ITEM_ID_FMT"\n",nodeid,ITEM_ID_ARGS(*id2));
-#endif
- g_hash_table_insert(sgr_nodes_hash, GINT_TO_POINTER(nodeid), id2);
- nodeid++;
- }
- th=tile_head_root;
- while (th) {
- th->zip_data=malloc(th->total_size);
- th->total_size_used=0;
- th=th->next;
- }
- ch_create_tempfiles(suffix, graphfiles, ch_levels, 1);
- ch_process(graphfiles, ch_levels, 1);
- ch_close_tempfiles(graphfiles, ch_levels);
-
- g_hash_table_destroy(newnode_hash);
- g_hash_table_destroy(edge_hash);
- g_hash_table_destroy(sgr_nodes_hash);
-
- ch_copy_to_tiles(suffix, ch_levels, &info, NULL);
- write_tilesdir(&info, zip_info, NULL);
-
- th=tile_head_root;
- while (th) {
- if (th->name[0]) {
- if (th->total_size != th->total_size_used) {
- fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used);
- exit(1);
- }
- write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size);
- } else {
- fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info));
- }
- g_free(th->zip_data);
- th=th->next;
+void ch_assemble_map(char *map_suffix, char *suffix, struct zip_info *zip_info) {
+ struct tile_info info;
+ struct tile_head *th;
+ FILE **graphfiles=g_alloca(sizeof(FILE*)*(ch_levels+1));
+ FILE *ref;
+ struct item_id id;
+ int nodeid=0;
+
+ info.write=1;
+ info.maxlen=zip_get_maxnamelen(zip_info);
+ info.suffix=suffix;
+ info.tiles_list=NULL;
+ info.tilesdir_out=NULL;
+ ref=tempfile(suffix,"sgr_ref",1);
+
+ create_tile_hash();
+
+ th=tile_head_root;
+ while (th) {
+ th->zip_data=NULL;
+ th->process=1;
+ th=th->next;
+ }
+
+ ch_setup(suffix);
+ ch_copy_to_tiles(suffix, ch_levels, &info, ref);
+ fclose(ref);
+ ref=tempfile(suffix,"sgr_ref",0);
+ sgr_nodes_hash=g_hash_table_new_full(NULL, NULL, NULL, item_id_slice_free);
+ while (fread(&id, sizeof(id), 1, ref)) {
+ struct item_id *id2=g_slice_new(struct item_id);
+ *id2=id;
+ g_hash_table_insert(sgr_nodes_hash, GINT_TO_POINTER(nodeid), id2);
+ nodeid++;
+ }
+ th=tile_head_root;
+ while (th) {
+ th->zip_data=g_malloc(th->total_size);
+ th->total_size_used=0;
+ th=th->next;
+ }
+ ch_create_tempfiles(suffix, graphfiles, ch_levels, 1);
+ ch_process(graphfiles, ch_levels, 1);
+ ch_close_tempfiles(graphfiles, ch_levels);
+
+ g_hash_table_destroy(newnode_hash);
+ g_hash_table_destroy(edge_hash);
+ g_hash_table_destroy(sgr_nodes_hash);
+
+ ch_copy_to_tiles(suffix, ch_levels, &info, NULL);
+ write_tilesdir(&info, zip_info, NULL);
+
+ th=tile_head_root;
+ while (th) {
+ if (th->name[0]) {
+ if (th->total_size != th->total_size_used) {
+ fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used);
+ exit(1);
+ }
+ write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size);
+ } else {
+ fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info));
}
+ g_free(th->zip_data);
+ th=th->next;
+ }
}
diff --git a/navit/maptool/coastline.c b/navit/maptool/coastline.c
index 4e17fd652..d96f86ab0 100644
--- a/navit/maptool/coastline.c
+++ b/navit/maptool/coastline.c
@@ -19,653 +19,498 @@
#include "maptool.h"
#include "debug.h"
-struct coastline_tile
-{
- osmid wayid;
- int edges;
+struct coastline_tile {
+ osmid wayid;
+ int edges;
};
-static int distance_from_ll(struct coord *c, struct rect *bbox)
-{
- int dist=0;
- if (c->x == bbox->l.x)
- return dist+c->y-bbox->l.y;
- dist+=bbox->h.y-bbox->l.y;
- if (c->y == bbox->h.y)
- return dist+c->x-bbox->l.x;
- dist+=bbox->h.x-bbox->l.x;
- if (c->x == bbox->h.x)
- return dist+bbox->h.y-c->y;
- dist+=bbox->h.y-bbox->l.y;
- if (c->y == bbox->l.y)
- return dist+bbox->h.x-c->x;
- return -1;
+static int distance_from_ll(struct coord *c, struct rect *bbox) {
+ int dist=0;
+ if (c->x == bbox->l.x)
+ return dist+c->y-bbox->l.y;
+ dist+=bbox->h.y-bbox->l.y;
+ if (c->y == bbox->h.y)
+ return dist+c->x-bbox->l.x;
+ dist+=bbox->h.x-bbox->l.x;
+ if (c->x == bbox->h.x)
+ return dist+bbox->h.y-c->y;
+ dist+=bbox->h.y-bbox->l.y;
+ if (c->y == bbox->l.y)
+ return dist+bbox->h.x-c->x;
+ return -1;
}
-static struct geom_poly_segment *
-find_next(struct rect *bbox, GList *segments, struct coord *c, int exclude, struct coord *ci)
-{
- int min=INT_MAX,search=distance_from_ll(c, bbox)+(exclude?1:0);
- GList *curr;
- int i;
- struct geom_poly_segment *ret=NULL;
+static struct geom_poly_segment *find_next(struct rect *bbox, GList *segments, struct coord *c, int exclude,
+ struct coord *ci) {
+ int min=INT_MAX,search=distance_from_ll(c, bbox)+(exclude?1:0);
+ GList *curr;
+ int i;
+ struct geom_poly_segment *ret=NULL;
- for (i = 0 ; i < 2 ; i++) {
- curr=segments;
- dbg(lvl_debug,"search distance %d\n",search);
- while (curr) {
- struct geom_poly_segment *seg=curr->data;
- int dist=distance_from_ll(seg->first, bbox);
- dbg(lvl_debug,"0x%x 0x%x dist %d\n",seg->first->x,seg->first->y,dist);
- if (dist != -1 && seg->first != seg->last && dist < min && (dist >= search)) {
- min=dist;
- ci[0]=*seg->first;
- ci[1]=*seg->last;
- ret=seg;
- }
- curr=g_list_next(curr);
- }
- if (ret || !search)
- break;
- search=0;
- }
- return ret;
+ for (i = 0 ; i < 2 ; i++) {
+ curr=segments;
+ dbg(lvl_debug,"search distance %d",search);
+ while (curr) {
+ struct geom_poly_segment *seg=curr->data;
+ int dist=distance_from_ll(seg->first, bbox);
+ dbg(lvl_debug,"0x%x 0x%x dist %d",seg->first->x,seg->first->y,dist);
+ if (dist != -1 && seg->first != seg->last && dist < min && (dist >= search)) {
+ min=dist;
+ ci[0]=*seg->first;
+ ci[1]=*seg->last;
+ ret=seg;
+ }
+ curr=g_list_next(curr);
+ }
+ if (ret || !search)
+ break;
+ search=0;
+ }
+ return ret;
}
-static void
-close_polygon(struct item_bin *ib, struct coord *from, struct coord *to, int dir, struct rect *bbox, int *edges)
-{
- int i,e,dist,fromdist,todist;
- int full=(bbox->h.x-bbox->l.x+bbox->h.y-bbox->l.y)*2;
- int corners=0,first_corner=0;
- struct coord c;
- if (dir > 0) {
- fromdist=distance_from_ll(from, bbox);
- todist=distance_from_ll(to, bbox);
- } else {
- fromdist=distance_from_ll(to, bbox);
- todist=distance_from_ll(from, bbox);
- }
-#if 0
- fprintf(stderr,"close_polygon fromdist %d todist %d full %d dir %d\n", fromdist, todist, full, dir);
-#endif
- if (fromdist > todist)
- todist+=full;
-#if 0
- fprintf(stderr,"close_polygon corrected fromdist %d todist %d full %d dir %d\n", fromdist, todist, full, dir);
-#endif
- for (i = 0 ; i < 8 ; i++) {
- if (dir > 0)
- e=i;
- else
- e=7-i;
- switch (e%4) {
- case 0:
- c=bbox->l;
- break;
- case 1:
- c.x=bbox->l.x;
- c.y=bbox->h.y;
- break;
- case 2:
- c=bbox->h;
- break;
- case 3:
- c.x=bbox->h.x;
- c.y=bbox->l.y;
- break;
- }
- dist=distance_from_ll(&c, bbox);
- if (e & 4)
- dist+=full;
-#if 0
- fprintf(stderr,"dist %d %d\n",e,dist);
-#endif
- if (dist > fromdist && dist < todist) {
- item_bin_add_coord(ib, &c, 1);
-#if 0
- fprintf(stderr,"add\n");
-#endif
- }
- if (dist >= fromdist && dist <= todist) {
- if (!corners)
- first_corner=e;
- corners++;
- }
- }
- while (corners >= 2) {
- *edges |= 1<<(first_corner%4);
- first_corner++;
- corners--;
- }
+static void close_polygon(struct item_bin *ib, struct coord *from, struct coord *to, int dir, struct rect *bbox,
+ int *edges) {
+ int i,e,dist,fromdist,todist;
+ int full=(bbox->h.x-bbox->l.x+bbox->h.y-bbox->l.y)*2;
+ int corners=0,first_corner=0;
+ struct coord c;
+ if (dir > 0) {
+ fromdist=distance_from_ll(from, bbox);
+ todist=distance_from_ll(to, bbox);
+ } else {
+ fromdist=distance_from_ll(to, bbox);
+ todist=distance_from_ll(from, bbox);
+ }
+ if (fromdist > todist)
+ todist+=full;
+ for (i = 0 ; i < 8 ; i++) {
+ if (dir > 0)
+ e=i;
+ else
+ e=7-i;
+ switch (e%4) {
+ case 0:
+ c=bbox->l;
+ break;
+ case 1:
+ c.x=bbox->l.x;
+ c.y=bbox->h.y;
+ break;
+ case 2:
+ c=bbox->h;
+ break;
+ case 3:
+ c.x=bbox->h.x;
+ c.y=bbox->l.y;
+ break;
+ }
+ dist=distance_from_ll(&c, bbox);
+ if (e & 4)
+ dist+=full;
+ if (dist > fromdist && dist < todist) {
+ item_bin_add_coord(ib, &c, 1);
+ }
+ if (dist >= fromdist && dist <= todist) {
+ if (!corners)
+ first_corner=e;
+ corners++;
+ }
+ }
+ while (corners >= 2) {
+ *edges |= 1<<(first_corner%4);
+ first_corner++;
+ corners--;
+ }
}
struct coastline_tile_data {
- struct item_bin_sink_func *sink;
- GHashTable *tile_edges;
- int level;
- GList *k,*v;
+ struct item_bin_sink_func *sink;
+ GHashTable *tile_edges;
+ int level;
+ GList *k,*v;
};
-static GList *
-tile_data_to_segments(int *tile_data)
-{
- int *end=tile_data+tile_data[0];
- int *curr=tile_data+1;
- GList *segments=NULL;
- int count=0;
+static GList *tile_data_to_segments(int *tile_data) {
+ int *end=tile_data+tile_data[0];
+ int *curr=tile_data+1;
+ GList *segments=NULL;
+ int count=0;
- while (curr < end) {
- struct item_bin *ib=(struct item_bin *)curr;
- segments=g_list_prepend(segments,item_bin_to_poly_segment(ib, geom_poly_segment_type_way_right_side));
- curr+=ib->len+1;
- count++;
- }
-#if 0
- fprintf(stderr,"%d segments\n",count);
-#endif
- return segments;
+ while (curr < end) {
+ struct item_bin *ib=(struct item_bin *)curr;
+ segments=g_list_prepend(segments,item_bin_to_poly_segment(ib, geom_poly_segment_type_way_right_side));
+ curr+=ib->len+1;
+ count++;
+ }
+ return segments;
}
-static void
-tile_collector_process_tile(char *tile, int *tile_data, struct coastline_tile_data *data)
-{
- int poly_start_valid,tile_start_valid,exclude,search=0;
- struct rect bbox;
- struct coord cn[2],end,poly_start,tile_start;
- struct geom_poly_segment *first;
- struct item_bin *ib=NULL;
- struct item_bin_sink *out=data->sink->priv_data[1];
- int edges=0,flags;
- GList *sorted_segments,*curr;
- struct item_bin *ibt=(struct item_bin *)(tile_data+1);
- struct coastline_tile *ct=g_new0(struct coastline_tile, 1);
- ct->wayid=item_bin_get_wayid(ibt);
-#if 0
- if (strncmp(tile,"bcdbdcabddddba",7))
- return;
-#endif
-#if 0
- if (strncmp(tile,"bcdbdcaaaaddba",14))
- return;
-#endif
-#if 0
- fprintf(stderr,"tile %s of size %d\n", tile, *tile_data);
-#endif
- tile_bbox(tile, &bbox, 0);
- curr=tile_data_to_segments(tile_data);
- sorted_segments=geom_poly_segments_sort(curr, geom_poly_segment_type_way_right_side);
- g_list_foreach(curr,(GFunc)geom_poly_segment_destroy,NULL);
- g_list_free(curr);
-
-#if 0
-{
- GList *sort_segments=sorted_segments;
- int count=0;
- while (sort_segments) {
- struct geom_poly_segment *seg=sort_segments->data;
- struct item_bin *ib=(struct item_bin *)buffer;
- char *text=g_strdup_printf("segment %d type %d %p %s area "LONGLONG_FMT,count++,seg->type,sort_segments,coord_is_equal(*seg->first, *seg->last) ? "closed":"open",geom_poly_area(seg->first,seg->last-seg->first+1));
- item_bin_init(ib, type_rg_segment);
- item_bin_add_coord(ib, seg->first, seg->last-seg->first+1);
- item_bin_add_attr_string(ib, attr_debug, text);
- // fprintf(stderr,"%s\n",text);
- g_free(text);
- // item_bin_dump(ib, stderr);
- item_bin_write_to_sink(ib, out, NULL);
- sort_segments=g_list_next(sort_segments);
- }
-}
-#endif
- flags=0;
- curr=sorted_segments;
- while (curr) {
- struct geom_poly_segment *seg=curr->data;
- switch (seg->type) {
- case geom_poly_segment_type_way_inner:
- flags|=1;
- break;
- case geom_poly_segment_type_way_outer:
- flags|=2;
- break;
- default:
- flags|=4;
- break;
- }
- curr=g_list_next(curr);
- }
- if (flags == 1) {
- ct->edges=15;
- ib=init_item(type_poly_water_tiled);
- item_bin_bbox(ib, &bbox);
- item_bin_add_attr_longlong(ib, attr_osm_wayid, ct->wayid);
- item_bin_write_to_sink(ib, out, NULL);
- g_hash_table_insert(data->tile_edges, g_strdup(tile), ct);
- return;
- }
-#if 1
- end=bbox.l;
- tile_start_valid=0;
- poly_start_valid=0;
- exclude=0;
- poly_start.x=0;
- poly_start.y=0;
- tile_start.x=0;
- tile_start.y=0;
- for (;;) {
- search++;
- // item_bin_write_debug_point_to_sink(out, &end, "Search %d",search);
- dbg(lvl_debug,"searching next polygon from 0x%x 0x%x\n",end.x,end.y);
- first=find_next(&bbox, sorted_segments, &end, exclude, cn);
- exclude=1;
- if (!first)
- break;
- if (!tile_start_valid) {
- tile_start=cn[0];
- tile_start_valid=1;
- } else {
- if (cn[0].x == tile_start.x && cn[0].y == tile_start.y) {
- dbg(lvl_debug,"end of tile reached\n");
- break;
- }
- }
- if (first->type == geom_poly_segment_type_none) {
- end=cn[0];
- continue;
- }
- poly_start_valid=0;
- dbg(lvl_debug,"start of polygon 0x%x 0x%x\n",cn[0].x,cn[0].y);
- for (;;) {
- if (!poly_start_valid) {
- poly_start=cn[0];
- poly_start_valid=1;
- ib=init_item(type_poly_water_tiled);
- } else {
- close_polygon(ib, &end, &cn[0], 1, &bbox, &edges);
- if (cn[0].x == poly_start.x && cn[0].y == poly_start.y) {
- dbg(lvl_debug,"poly end reached\n");
- item_bin_add_attr_longlong(ib, attr_osm_wayid, ct->wayid);
- item_bin_write_to_sink(ib, out, NULL);
- end=cn[0];
- break;
- }
- }
- if (first->type == geom_poly_segment_type_none)
- break;
- item_bin_add_coord(ib, first->first, first->last-first->first+1);
- first->type=geom_poly_segment_type_none;
- end=cn[1];
- if (distance_from_ll(&end, &bbox) == -1) {
- dbg(lvl_debug,"incomplete\n");
- break;
- }
- first=find_next(&bbox, sorted_segments, &end, 1, cn);
- dbg(lvl_debug,"next segment of polygon 0x%x 0x%x\n",cn[0].x,cn[0].y);
- }
- if (search > 55)
- break;
- }
- g_list_foreach(sorted_segments,(GFunc)geom_poly_segment_destroy,NULL);
- g_list_free(sorted_segments);
-#endif
+static void tile_collector_process_tile(char *tile, int *tile_data, struct coastline_tile_data *data) {
+ int poly_start_valid,tile_start_valid,exclude,search=0;
+ struct rect bbox;
+ struct coord cn[2],end,poly_start,tile_start;
+ struct geom_poly_segment *first;
+ struct item_bin *ib=NULL;
+ struct item_bin_sink *out=data->sink->priv_data[1];
+ int edges=0,flags;
+ GList *sorted_segments,*curr;
+ struct item_bin *ibt=(struct item_bin *)(tile_data+1);
+ struct coastline_tile *ct=g_new0(struct coastline_tile, 1);
+ ct->wayid=item_bin_get_wayid(ibt);
+ tile_bbox(tile, &bbox, 0);
+ curr=tile_data_to_segments(tile_data);
+ sorted_segments=geom_poly_segments_sort(curr, geom_poly_segment_type_way_right_side);
+ g_list_foreach(curr,(GFunc)geom_poly_segment_destroy,NULL);
+ g_list_free(curr);
-#if 0
- {
- int *end=tile_data+tile_data[0];
- int *curr=tile_data+1;
- while (curr < end) {
- struct item_bin *ib=(struct item_bin *)curr;
- // item_bin_dump(ib);
- ib->type=type_rg_segment;
- item_bin_write_to_sink(ib, out, NULL);
- curr+=ib->len+1;
-#if 0
- {
- struct coord *c[2];
- int i;
- char *s;
- c[0]=(struct coord *)(ib+1);
- c[1]=c[0]+ib->clen/2-1;
- for (i = 0 ; i < 2 ; i++) {
- s=coord_to_str(c[i]);
- item_bin_write_debug_point_to_sink(out, c[i], "%s",s);
- g_free(s);
- }
-
- }
-#endif
- }
- }
-#endif
- ct->edges=edges;
- g_hash_table_insert(data->tile_edges, g_strdup(tile), ct);
-#if 0
- item_bin_init(ib, type_border_country);
- item_bin_bbox(ib, &bbox);
- item_bin_add_attr_string(ib, attr_debug, tile);
- item_bin_write_to_sink(ib, out, NULL);
-#endif
-#if 0
- c.x=(bbox.l.x+bbox.h.x)/2;
- c.y=(bbox.l.y+bbox.h.y)/2;
- item_bin_write_debug_point_to_sink(out, &c, "%s %d",tile,edges);
-#endif
+ flags=0;
+ curr=sorted_segments;
+ while (curr) {
+ struct geom_poly_segment *seg=curr->data;
+ switch (seg->type) {
+ case geom_poly_segment_type_way_inner:
+ flags|=1;
+ break;
+ case geom_poly_segment_type_way_outer:
+ flags|=2;
+ break;
+ default:
+ flags|=4;
+ break;
+ }
+ curr=g_list_next(curr);
+ }
+ if (flags == 1) {
+ ct->edges=15;
+ ib=init_item(type_poly_water_tiled);
+ item_bin_bbox(ib, &bbox);
+ item_bin_add_attr_longlong(ib, attr_osm_wayid, ct->wayid);
+ item_bin_write_to_sink(ib, out, NULL);
+ g_hash_table_insert(data->tile_edges, g_strdup(tile), ct);
+ return;
+ }
+ end=bbox.l;
+ tile_start_valid=0;
+ poly_start_valid=0;
+ exclude=0;
+ poly_start.x=0;
+ poly_start.y=0;
+ tile_start.x=0;
+ tile_start.y=0;
+ for (;;) {
+ search++;
+ // item_bin_write_debug_point_to_sink(out, &end, "Search %d",search);
+ dbg(lvl_debug,"searching next polygon from 0x%x 0x%x",end.x,end.y);
+ first=find_next(&bbox, sorted_segments, &end, exclude, cn);
+ exclude=1;
+ if (!first)
+ break;
+ if (!tile_start_valid) {
+ tile_start=cn[0];
+ tile_start_valid=1;
+ } else {
+ if (cn[0].x == tile_start.x && cn[0].y == tile_start.y) {
+ dbg(lvl_debug,"end of tile reached");
+ break;
+ }
+ }
+ if (first->type == geom_poly_segment_type_none) {
+ end=cn[0];
+ continue;
+ }
+ poly_start_valid=0;
+ dbg(lvl_debug,"start of polygon 0x%x 0x%x",cn[0].x,cn[0].y);
+ for (;;) {
+ if (!poly_start_valid) {
+ poly_start=cn[0];
+ poly_start_valid=1;
+ ib=init_item(type_poly_water_tiled);
+ } else {
+ close_polygon(ib, &end, &cn[0], 1, &bbox, &edges);
+ if (cn[0].x == poly_start.x && cn[0].y == poly_start.y) {
+ dbg(lvl_debug,"poly end reached");
+ item_bin_add_attr_longlong(ib, attr_osm_wayid, ct->wayid);
+ item_bin_write_to_sink(ib, out, NULL);
+ end=cn[0];
+ break;
+ }
+ }
+ if (first->type == geom_poly_segment_type_none)
+ break;
+ item_bin_add_coord(ib, first->first, first->last-first->first+1);
+ first->type=geom_poly_segment_type_none;
+ end=cn[1];
+ if (distance_from_ll(&end, &bbox) == -1) {
+ dbg(lvl_debug,"incomplete");
+ break;
+ }
+ first=find_next(&bbox, sorted_segments, &end, 1, cn);
+ dbg(lvl_debug,"next segment of polygon 0x%x 0x%x",cn[0].x,cn[0].y);
+ }
+ if (search > 55)
+ break;
+ }
+ g_list_foreach(sorted_segments,(GFunc)geom_poly_segment_destroy,NULL);
+ g_list_free(sorted_segments);
+
+ ct->edges=edges;
+ g_hash_table_insert(data->tile_edges, g_strdup(tile), ct);
}
-static void
-ocean_tile(GHashTable *hash, char *tile, char c, osmid wayid, struct item_bin_sink *out)
-{
- int len=strlen(tile);
- char *tile2=g_alloca(sizeof(char)*(len+1));
- struct rect bbox;
- struct item_bin *ib;
- struct coastline_tile *ct;
+static void ocean_tile(GHashTable *hash, char *tile, char c, osmid wayid, struct item_bin_sink *out) {
+ int len=strlen(tile);
+ char *tile2=g_alloca(sizeof(char)*(len+1));
+ struct rect bbox;
+ struct item_bin *ib;
+ struct coastline_tile *ct;
- strcpy(tile2, tile);
- tile2[len-1]=c;
- //fprintf(stderr,"Testing %s\n",tile2);
- ct=g_hash_table_lookup(hash, tile2);
- if (ct)
- return;
- //fprintf(stderr,"%s ok\n",tile2);
- tile_bbox(tile2, &bbox, 0);
- ib=init_item(type_poly_water_tiled);
- item_bin_bbox(ib, &bbox);
- item_bin_add_attr_longlong(ib, attr_osm_wayid, wayid);
- item_bin_write_to_sink(ib, out, NULL);
- ct=g_new0(struct coastline_tile, 1);
- ct->edges=15;
- ct->wayid=wayid;
- g_hash_table_insert(hash, g_strdup(tile2), ct);
-#if 0
- item_bin_init(ib, type_border_country);
- item_bin_bbox(ib, &bbox);
- item_bin_add_attr_string(ib, attr_debug, tile2);
- item_bin_write_to_sink(ib, out, NULL);
-#endif
-#if 0
- {
- struct coord co;
- co.x=(bbox.l.x+bbox.h.x)/2;
- co.y=(bbox.l.y+bbox.h.y)/2;
- item_bin_write_debug_point_to_sink(out, &co, "%s 15",tile2);
- }
-#endif
+ strcpy(tile2, tile);
+ tile2[len-1]=c;
+ //fprintf(stderr,"Testing %s\n",tile2);
+ ct=g_hash_table_lookup(hash, tile2);
+ if (ct)
+ return;
+ //fprintf(stderr,"%s ok\n",tile2);
+ tile_bbox(tile2, &bbox, 0);
+ ib=init_item(type_poly_water_tiled);
+ item_bin_bbox(ib, &bbox);
+ item_bin_add_attr_longlong(ib, attr_osm_wayid, wayid);
+ item_bin_write_to_sink(ib, out, NULL);
+ ct=g_new0(struct coastline_tile, 1);
+ ct->edges=15;
+ ct->wayid=wayid;
+ g_hash_table_insert(hash, g_strdup(tile2), ct);
}
/* ba */
/* dc */
-static void
-tile_collector_add_siblings(char *tile, struct coastline_tile *ct, struct coastline_tile_data *data)
-{
- int len=strlen(tile);
- char t=tile[len-1];
- struct item_bin_sink *out=data->sink->priv_data[1];
- int edges=ct->edges;
- int debug=0;
-#if 0
- if (!strncmp(tile,"bcacccaadbdcd",10))
- debug=1;
-#endif
- if (debug)
- fprintf(stderr,"%s (%c) has %d edges active\n",tile,t,edges);
- if (t == 'a' && (edges & 1))
- ocean_tile(data->tile_edges, tile, 'b', ct->wayid, out);
- if (t == 'a' && (edges & 8))
- ocean_tile(data->tile_edges, tile, 'c', ct->wayid, out);
- if (t == 'b' && (edges & 4))
- ocean_tile(data->tile_edges, tile, 'a', ct->wayid, out);
- if (t == 'b' && (edges & 8))
- ocean_tile(data->tile_edges, tile, 'd', ct->wayid, out);
- if (t == 'c' && (edges & 1))
- ocean_tile(data->tile_edges, tile, 'd', ct->wayid, out);
- if (t == 'c' && (edges & 2))
- ocean_tile(data->tile_edges, tile, 'a', ct->wayid, out);
- if (t == 'd' && (edges & 4))
- ocean_tile(data->tile_edges, tile, 'c', ct->wayid, out);
- if (t == 'd' && (edges & 2))
- ocean_tile(data->tile_edges, tile, 'b', ct->wayid, out);
+static void tile_collector_add_siblings(char *tile, struct coastline_tile *ct, struct coastline_tile_data *data) {
+ int len=strlen(tile);
+ char t=tile[len-1];
+ struct item_bin_sink *out=data->sink->priv_data[1];
+ int edges=ct->edges;
+ int debug=0;
+ if (debug)
+ fprintf(stderr,"%s (%c) has %d edges active\n",tile,t,edges);
+ if (t == 'a' && (edges & 1))
+ ocean_tile(data->tile_edges, tile, 'b', ct->wayid, out);
+ if (t == 'a' && (edges & 8))
+ ocean_tile(data->tile_edges, tile, 'c', ct->wayid, out);
+ if (t == 'b' && (edges & 4))
+ ocean_tile(data->tile_edges, tile, 'a', ct->wayid, out);
+ if (t == 'b' && (edges & 8))
+ ocean_tile(data->tile_edges, tile, 'd', ct->wayid, out);
+ if (t == 'c' && (edges & 1))
+ ocean_tile(data->tile_edges, tile, 'd', ct->wayid, out);
+ if (t == 'c' && (edges & 2))
+ ocean_tile(data->tile_edges, tile, 'a', ct->wayid, out);
+ if (t == 'd' && (edges & 4))
+ ocean_tile(data->tile_edges, tile, 'c', ct->wayid, out);
+ if (t == 'd' && (edges & 2))
+ ocean_tile(data->tile_edges, tile, 'b', ct->wayid, out);
}
-static int
-tile_sibling_edges(GHashTable *hash, char *tile, char c)
-{
- int len=strlen(tile);
- char *tile2=g_alloca(sizeof(char)*(len+1));
- struct coastline_tile *ct;
- strcpy(tile2, tile);
- tile2[len-1]=c;
- ct=g_hash_table_lookup(hash, tile2);
- if (ct)
- return ct->edges;
- return 15;
+static int tile_sibling_edges(GHashTable *hash, char *tile, char c) {
+ int len=strlen(tile);
+ char *tile2=g_alloca(sizeof(char)*(len+1));
+ struct coastline_tile *ct;
+ strcpy(tile2, tile);
+ tile2[len-1]=c;
+ ct=g_hash_table_lookup(hash, tile2);
+ if (ct)
+ return ct->edges;
+ return 15;
}
#if 0
-static void
-ocean_tile2(struct rect *r, int dx, int dy, int wf, int hf, struct item_bin_sink *out)
-{
- struct item_bin *ib;
- int w=r->h.x-r->l.x;
- int h=r->h.y-r->l.y;
- char tile2[32];
- struct rect bbox;
- bbox.l.x=r->l.x+dx*w;
- bbox.l.y=r->l.y+dy*h;
- bbox.h.x=bbox.l.x+w*wf;
- bbox.h.y=bbox.l.y+h*hf;
- //fprintf(stderr,"0x%x,0x%x-0x%x,0x%x -> 0x%x,0x%x-0x%x,0x%x\n",r->l.x,r->l.y,r->h.x,r->h.y,bbox.l.x,bbox.l.y,bbox.h.x,bbox.h.y);
- ib=init_item(type_poly_water_tiled);
- item_bin_bbox(ib, &bbox);
- item_bin_write_to_sink(ib, out, NULL);
+static void ocean_tile2(struct rect *r, int dx, int dy, int wf, int hf, struct item_bin_sink *out) {
+ struct item_bin *ib;
+ int w=r->h.x-r->l.x;
+ int h=r->h.y-r->l.y;
+ char tile2[32];
+ struct rect bbox;
+ bbox.l.x=r->l.x+dx*w;
+ bbox.l.y=r->l.y+dy*h;
+ bbox.h.x=bbox.l.x+w*wf;
+ bbox.h.y=bbox.l.y+h*hf;
+ //fprintf(stderr,"0x%x,0x%x-0x%x,0x%x -> 0x%x,0x%x-0x%x,0x%x\n",r->l.x,r->l.y,r->h.x,r->h.y,bbox.l.x,bbox.l.y,bbox.h.x,bbox.h.y);
+ ib=init_item(type_poly_water_tiled);
+ item_bin_bbox(ib, &bbox);
+ item_bin_write_to_sink(ib, out, NULL);
#if 0
- item_bin_init(ib, type_border_country);
- item_bin_bbox(ib, &bbox);
- item_bin_add_attr_string(ib, attr_debug, tile2);
- item_bin_write_to_sink(ib, out, NULL);
+ item_bin_init(ib, type_border_country);
+ item_bin_bbox(ib, &bbox);
+ item_bin_add_attr_string(ib, attr_debug, tile2);
+ item_bin_write_to_sink(ib, out, NULL);
#endif
- tile(&bbox, NULL, tile2, 32, 0, NULL);
+ tile(&bbox, NULL, tile2, 32, 0, NULL);
#if 0
- {
- struct coord co;
- co.x=(bbox.l.x+bbox.h.x)/2;
- co.y=(bbox.l.y+bbox.h.y)/2;
- item_bin_write_debug_point_to_sink(out, &co, "%s 15",tile2);
- }
+ {
+ struct coord co;
+ co.x=(bbox.l.x+bbox.h.x)/2;
+ co.y=(bbox.l.y+bbox.h.y)/2;
+ item_bin_write_debug_point_to_sink(out, &co, "%s 15",tile2);
+ }
#endif
}
#endif
-static void
-tile_collector_add_siblings2(char *tile, struct coastline_tile *ct, struct coastline_tile_data *data)
-{
- int edges=ct->edges;
- int pedges=0;
- int debug=0;
- int len=strlen(tile);
- struct coastline_tile *cn, *co;
- char *tile2=g_alloca(sizeof(char)*(len+1));
- char t=tile[len-1];
- strcpy(tile2, tile);
- tile2[len-1]='\0';
-#if 0
- if (!strncmp(tile,"bcacccaadbdcd",10))
- debug=1;
-#endif
- if (debug)
- fprintf(stderr,"len of %s %d vs %d\n",tile,len,data->level);
+static void tile_collector_add_siblings2(char *tile, struct coastline_tile *ct, struct coastline_tile_data *data) {
+ int edges=ct->edges;
+ int pedges=0;
+ int debug=0;
+ int len=strlen(tile);
+ struct coastline_tile *cn, *co;
+ char *tile2=g_alloca(sizeof(char)*(len+1));
+ char t=tile[len-1];
+ strcpy(tile2, tile);
+ tile2[len-1]='\0';
+ if (debug)
+ fprintf(stderr,"len of %s %d vs %d\n",tile,len,data->level);
- if (debug)
- fprintf(stderr,"checking siblings of '%s' with %d edges active\n",tile,edges);
- if (t == 'b' && (edges & 1) && (tile_sibling_edges(data->tile_edges, tile, 'd') & 1))
- pedges|=1;
- if (t == 'd' && (edges & 2) && (tile_sibling_edges(data->tile_edges, tile, 'b') & 1))
- pedges|=1;
- if (t == 'a' && (edges & 2) && (tile_sibling_edges(data->tile_edges, tile, 'b') & 2))
- pedges|=2;
- if (t == 'b' && (edges & 2) && (tile_sibling_edges(data->tile_edges, tile, 'a') & 2))
- pedges|=2;
- if (t == 'a' && (edges & 4) && (tile_sibling_edges(data->tile_edges, tile, 'c') & 4))
- pedges|=4;
- if (t == 'c' && (edges & 4) && (tile_sibling_edges(data->tile_edges, tile, 'a') & 4))
- pedges|=4;
- if (t == 'd' && (edges & 8) && (tile_sibling_edges(data->tile_edges, tile, 'c') & 8))
- pedges|=8;
- if (t == 'c' && (edges & 8) && (tile_sibling_edges(data->tile_edges, tile, 'd') & 8))
- pedges|=8;
- co=g_hash_table_lookup(data->tile_edges, tile2);
- if (debug)
- fprintf(stderr,"result '%s' %d old %d\n",tile2,pedges,co?co->edges:0);
- cn=g_new0(struct coastline_tile, 1);
- cn->edges=pedges;
- if (co) {
- cn->edges|=co->edges;
- cn->wayid=co->wayid;
- } else
- cn->wayid=ct->wayid;
- g_hash_table_insert(data->tile_edges, g_strdup(tile2), cn);
+ if (debug)
+ fprintf(stderr,"checking siblings of '%s' with %d edges active\n",tile,edges);
+ if (t == 'b' && (edges & 1) && (tile_sibling_edges(data->tile_edges, tile, 'd') & 1))
+ pedges|=1;
+ if (t == 'd' && (edges & 2) && (tile_sibling_edges(data->tile_edges, tile, 'b') & 1))
+ pedges|=1;
+ if (t == 'a' && (edges & 2) && (tile_sibling_edges(data->tile_edges, tile, 'b') & 2))
+ pedges|=2;
+ if (t == 'b' && (edges & 2) && (tile_sibling_edges(data->tile_edges, tile, 'a') & 2))
+ pedges|=2;
+ if (t == 'a' && (edges & 4) && (tile_sibling_edges(data->tile_edges, tile, 'c') & 4))
+ pedges|=4;
+ if (t == 'c' && (edges & 4) && (tile_sibling_edges(data->tile_edges, tile, 'a') & 4))
+ pedges|=4;
+ if (t == 'd' && (edges & 8) && (tile_sibling_edges(data->tile_edges, tile, 'c') & 8))
+ pedges|=8;
+ if (t == 'c' && (edges & 8) && (tile_sibling_edges(data->tile_edges, tile, 'd') & 8))
+ pedges|=8;
+ co=g_hash_table_lookup(data->tile_edges, tile2);
+ if (debug)
+ fprintf(stderr,"result '%s' %d old %d\n",tile2,pedges,co?co->edges:0);
+ cn=g_new0(struct coastline_tile, 1);
+ cn->edges=pedges;
+ if (co) {
+ cn->edges|=co->edges;
+ cn->wayid=co->wayid;
+ } else
+ cn->wayid=ct->wayid;
+ g_hash_table_insert(data->tile_edges, g_strdup(tile2), cn);
}
-static void
-foreach_tile_func(gpointer key, gpointer value, gpointer user_data)
-{
- struct coastline_tile_data *data=user_data;
- if (strlen((char *)key) == data->level) {
- data->k=g_list_prepend(data->k, key);
- data->v=g_list_prepend(data->v, value);
- }
+static void foreach_tile_func(gpointer key, gpointer value, gpointer user_data) {
+ struct coastline_tile_data *data=user_data;
+ if (strlen((char *)key) == data->level) {
+ data->k=g_list_prepend(data->k, key);
+ data->v=g_list_prepend(data->v, value);
+ }
}
-static void
-foreach_tile(struct coastline_tile_data *data, void(*func)(char *, struct coastline_tile *, struct coastline_tile_data *))
-{
- GList *k,*v;
- data->k=NULL;
- data->v=NULL;
-
- g_hash_table_foreach(data->tile_edges, foreach_tile_func, data);
- k=data->k;
- v=data->v;
- while (k) {
- func(k->data,v->data,data);
- k=g_list_next(k);
- v=g_list_next(v);
- }
- g_list_free(data->k);
- g_list_free(data->v);
+static void foreach_tile(struct coastline_tile_data *data, void(*func)(char *, struct coastline_tile *,
+ struct coastline_tile_data *)) {
+ GList *k,*v;
+ data->k=NULL;
+ data->v=NULL;
+
+ g_hash_table_foreach(data->tile_edges, foreach_tile_func, data);
+ k=data->k;
+ v=data->v;
+ while (k) {
+ func(k->data,v->data,data);
+ k=g_list_next(k);
+ v=g_list_next(v);
+ }
+ g_list_free(data->k);
+ g_list_free(data->v);
}
-static int
-tile_collector_finish(struct item_bin_sink_func *tile_collector)
-{
- struct coastline_tile_data data;
- int i;
- GHashTable *hash;
- data.sink=tile_collector;
- data.tile_edges=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
- hash=tile_collector->priv_data[0];
- fprintf(stderr,"tile_collector_finish\n");
+static int tile_collector_finish(struct item_bin_sink_func *tile_collector) {
+ struct coastline_tile_data data;
+ int i;
+ GHashTable *hash;
+ data.sink=tile_collector;
+ data.tile_edges=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ hash=tile_collector->priv_data[0];
+ fprintf(stderr,"tile_collector_finish\n");
#if 1
- g_hash_table_foreach(hash, (GHFunc) tile_collector_process_tile, &data);
-#endif
- fprintf(stderr,"tile_collector_finish foreach done\n");
- g_hash_table_destroy(hash);
- fprintf(stderr,"tile_collector_finish destroy done\n");
- for (i = 14 ; i > 0 ; i--) {
- fprintf(stderr,"Level=%d\n",i);
- data.level=i;
- foreach_tile(&data, tile_collector_add_siblings);
- fprintf(stderr,"*");
- foreach_tile(&data, tile_collector_add_siblings);
- fprintf(stderr,"*");
- foreach_tile(&data, tile_collector_add_siblings);
- fprintf(stderr,"*");
- foreach_tile(&data, tile_collector_add_siblings);
- fprintf(stderr,"*");
- foreach_tile(&data, tile_collector_add_siblings2);
- fprintf(stderr,"*\n");
- foreach_tile(&data, tile_collector_add_siblings2);
- fprintf(stderr,"*\n");
- foreach_tile(&data, tile_collector_add_siblings2);
- fprintf(stderr,"*\n");
- foreach_tile(&data, tile_collector_add_siblings2);
- fprintf(stderr,"*\n");
- }
-#if 0
- data.level=13;
- g_hash_table_foreach(data.tile_edges, tile_collector_add_siblings, &data);
- g_hash_table_foreach(data.tile_edges, tile_collector_add_siblings, &data);
- g_hash_table_foreach(data.tile_edges, tile_collector_add_siblings2, &data);
- data.level=12;
- g_hash_table_foreach(data.tile_edges, tile_collector_add_siblings, &data);
- g_hash_table_foreach(data.tile_edges, tile_collector_add_siblings, &data);
+ g_hash_table_foreach(hash, (GHFunc) tile_collector_process_tile, &data);
#endif
- item_bin_sink_func_destroy(tile_collector);
- fprintf(stderr,"tile_collector_finish done\n");
- return 0;
+ fprintf(stderr,"tile_collector_finish foreach done\n");
+ g_hash_table_destroy(hash);
+ fprintf(stderr,"tile_collector_finish destroy done\n");
+ for (i = 14 ; i > 0 ; i--) {
+ fprintf(stderr,"Level=%d\n",i);
+ data.level=i;
+ foreach_tile(&data, tile_collector_add_siblings);
+ fprintf(stderr,"*");
+ foreach_tile(&data, tile_collector_add_siblings);
+ fprintf(stderr,"*");
+ foreach_tile(&data, tile_collector_add_siblings);
+ fprintf(stderr,"*");
+ foreach_tile(&data, tile_collector_add_siblings);
+ fprintf(stderr,"*");
+ foreach_tile(&data, tile_collector_add_siblings2);
+ fprintf(stderr,"*\n");
+ foreach_tile(&data, tile_collector_add_siblings2);
+ fprintf(stderr,"*\n");
+ foreach_tile(&data, tile_collector_add_siblings2);
+ fprintf(stderr,"*\n");
+ foreach_tile(&data, tile_collector_add_siblings2);
+ fprintf(stderr,"*\n");
+ }
+ item_bin_sink_func_destroy(tile_collector);
+ fprintf(stderr,"tile_collector_finish done\n");
+ return 0;
}
-static int
-coastline_processor_process(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data)
-{
-#if 0
- int i;
- struct coord *c=(struct coord *)(ib+1);
- for (i = 0 ; i < 19 ; i++) {
- c[i]=c[i+420];
- }
- ib->clen=(i-1)*2;
-#endif
- item_bin_write_clipped(ib, func->priv_data[0], func->priv_data[1]);
- return 0;
+static int coastline_processor_process(struct item_bin_sink_func *func, struct item_bin *ib,
+ struct tile_data *tile_data) {
+ item_bin_write_clipped(ib, func->priv_data[0], func->priv_data[1]);
+ return 0;
}
-static struct item_bin_sink_func *
-coastline_processor_new(struct item_bin_sink *out)
-{
- struct item_bin_sink_func *coastline_processor=item_bin_sink_func_new(coastline_processor_process);
- struct item_bin_sink *tiles=item_bin_sink_new();
- struct item_bin_sink_func *tile_collector=tile_collector_new(out);
- struct tile_parameter *param=g_new0(struct tile_parameter, 1);
+static struct item_bin_sink_func *coastline_processor_new(struct item_bin_sink *out) {
+ struct item_bin_sink_func *coastline_processor=item_bin_sink_func_new(coastline_processor_process);
+ struct item_bin_sink *tiles=item_bin_sink_new();
+ struct item_bin_sink_func *tile_collector=tile_collector_new(out);
+ struct tile_parameter *param=g_new0(struct tile_parameter, 1);
- param->min=14;
- param->max=14;
- param->overlap=0;
- param->attr_to_copy=attr_osm_wayid;
+ param->min=14;
+ param->max=14;
+ param->overlap=0;
+ param->attr_to_copy=attr_osm_wayid;
- item_bin_sink_add_func(tiles, tile_collector);
- coastline_processor->priv_data[0]=param;
- coastline_processor->priv_data[1]=tiles;
- coastline_processor->priv_data[2]=tile_collector;
- return coastline_processor;
+ item_bin_sink_add_func(tiles, tile_collector);
+ coastline_processor->priv_data[0]=param;
+ coastline_processor->priv_data[1]=tiles;
+ coastline_processor->priv_data[2]=tile_collector;
+ return coastline_processor;
}
-static void
-coastline_processor_finish(struct item_bin_sink_func *coastline_processor)
-{
- struct tile_parameter *param=coastline_processor->priv_data[0];
- struct item_bin_sink *tiles=coastline_processor->priv_data[1];
- struct item_bin_sink_func *tile_collector=coastline_processor->priv_data[2];
- g_free(param);
- tile_collector_finish(tile_collector);
- item_bin_sink_destroy(tiles);
- item_bin_sink_func_destroy(coastline_processor);
+static void coastline_processor_finish(struct item_bin_sink_func *coastline_processor) {
+ struct tile_parameter *param=coastline_processor->priv_data[0];
+ struct item_bin_sink *tiles=coastline_processor->priv_data[1];
+ struct item_bin_sink_func *tile_collector=coastline_processor->priv_data[2];
+ g_free(param);
+ tile_collector_finish(tile_collector);
+ item_bin_sink_destroy(tiles);
+ item_bin_sink_func_destroy(coastline_processor);
}
-void
-process_coastlines(FILE *in, FILE *out)
-{
- struct item_bin_sink *reader=file_reader_new(in,-1,0);
- struct item_bin_sink_func *file_writer=file_writer_new(out);
- struct item_bin_sink *result=item_bin_sink_new();
- struct item_bin_sink_func *coastline_processor=coastline_processor_new(result);
- item_bin_sink_add_func(reader, coastline_processor);
- item_bin_sink_add_func(result, file_writer);
- file_reader_finish(reader);
- coastline_processor_finish(coastline_processor);
- file_writer_finish(file_writer);
- item_bin_sink_destroy(result);
+void process_coastlines(FILE *in, FILE *out) {
+ struct item_bin_sink *reader=file_reader_new(in,-1,0);
+ struct item_bin_sink_func *file_writer=file_writer_new(out);
+ struct item_bin_sink *result=item_bin_sink_new();
+ struct item_bin_sink_func *coastline_processor=coastline_processor_new(result);
+ item_bin_sink_add_func(reader, coastline_processor);
+ item_bin_sink_add_func(result, file_writer);
+ file_reader_finish(reader);
+ coastline_processor_finish(coastline_processor);
+ file_writer_finish(file_writer);
+ item_bin_sink_destroy(result);
}
diff --git a/navit/maptool/fileformat.proto b/navit/maptool/fileformat.proto
index 006cba767..2f1765935 100644
--- a/navit/maptool/fileformat.proto
+++ b/navit/maptool/fileformat.proto
@@ -1,3 +1,4 @@
+syntax = "proto2";
option java_package = "crosby.binary";
package OSMPBF;
@@ -32,5 +33,3 @@ message BlobHeader {
optional bytes indexdata = 2;
required int32 datasize = 3;
}
-
-
diff --git a/navit/maptool/generated-code/fileformat.pb-c.c b/navit/maptool/generated-code/fileformat.pb-c.c
deleted file mode 100644
index f67ba94d5..000000000
--- a/navit/maptool/generated-code/fileformat.pb-c.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/* Generated by the protocol buffer compiler. DO NOT EDIT! */
-
-/* Do not generate deprecated warnings for self */
-#ifndef PROTOBUF_C_NO_DEPRECATED
-#define PROTOBUF_C_NO_DEPRECATED
-#endif
-
-#include "fileformat.pb-c.h"
-void osmpbf__blob__init
- (OSMPBF__Blob *message)
-{
- static OSMPBF__Blob init_value = OSMPBF__BLOB__INIT;
- *message = init_value;
-}
-size_t osmpbf__blob__get_packed_size
- (const OSMPBF__Blob *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__blob__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__blob__pack
- (const OSMPBF__Blob *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__blob__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__blob__pack_to_buffer
- (const OSMPBF__Blob *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__blob__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__Blob *
- osmpbf__blob__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__Blob *)
- protobuf_c_message_unpack (&osmpbf__blob__descriptor,
- allocator, len, data);
-}
-void osmpbf__blob__free_unpacked
- (OSMPBF__Blob *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__blob__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__blob_header__init
- (OSMPBF__BlobHeader *message)
-{
- static OSMPBF__BlobHeader init_value = OSMPBF__BLOB_HEADER__INIT;
- *message = init_value;
-}
-size_t osmpbf__blob_header__get_packed_size
- (const OSMPBF__BlobHeader *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__blob_header__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__blob_header__pack
- (const OSMPBF__BlobHeader *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__blob_header__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__blob_header__pack_to_buffer
- (const OSMPBF__BlobHeader *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__blob_header__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__BlobHeader *
- osmpbf__blob_header__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__BlobHeader *)
- protobuf_c_message_unpack (&osmpbf__blob_header__descriptor,
- allocator, len, data);
-}
-void osmpbf__blob_header__free_unpacked
- (OSMPBF__BlobHeader *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__blob_header__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-static const ProtobufCFieldDescriptor osmpbf__blob__field_descriptors[5] =
-{
- {
- "raw",
- 1,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_BYTES,
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, has_raw),
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, raw),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "raw_size",
- 2,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_INT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, has_raw_size),
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, raw_size),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "zlib_data",
- 3,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_BYTES,
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, has_zlib_data),
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, zlib_data),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "lzma_data",
- 4,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_BYTES,
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, has_lzma_data),
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, lzma_data),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "OBSOLETE_bzip2_data",
- 5,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_BYTES,
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, has_obsolete_bzip2_data),
- PROTOBUF_C_OFFSETOF(OSMPBF__Blob, obsolete_bzip2_data),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__blob__field_indices_by_name[] = {
- 4, /* field[4] = OBSOLETE_bzip2_data */
- 3, /* field[3] = lzma_data */
- 0, /* field[0] = raw */
- 1, /* field[1] = raw_size */
- 2, /* field[2] = zlib_data */
-};
-static const ProtobufCIntRange osmpbf__blob__number_ranges[1 + 1] =
-{
- { 1, 0 },
- { 0, 5 }
-};
-const ProtobufCMessageDescriptor osmpbf__blob__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.Blob",
- "Blob",
- "OSMPBF__Blob",
- "OSMPBF",
- sizeof(OSMPBF__Blob),
- 5,
- osmpbf__blob__field_descriptors,
- osmpbf__blob__field_indices_by_name,
- 1, osmpbf__blob__number_ranges,
- (ProtobufCMessageInit) osmpbf__blob__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const ProtobufCFieldDescriptor osmpbf__blob_header__field_descriptors[3] =
-{
- {
- "type",
- 1,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_STRING,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__BlobHeader, type),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "indexdata",
- 2,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_BYTES,
- PROTOBUF_C_OFFSETOF(OSMPBF__BlobHeader, has_indexdata),
- PROTOBUF_C_OFFSETOF(OSMPBF__BlobHeader, indexdata),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "datasize",
- 3,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_INT32,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__BlobHeader, datasize),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__blob_header__field_indices_by_name[] = {
- 2, /* field[2] = datasize */
- 1, /* field[1] = indexdata */
- 0, /* field[0] = type */
-};
-static const ProtobufCIntRange osmpbf__blob_header__number_ranges[1 + 1] =
-{
- { 1, 0 },
- { 0, 3 }
-};
-const ProtobufCMessageDescriptor osmpbf__blob_header__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.BlobHeader",
- "BlobHeader",
- "OSMPBF__BlobHeader",
- "OSMPBF",
- sizeof(OSMPBF__BlobHeader),
- 3,
- osmpbf__blob_header__field_descriptors,
- osmpbf__blob_header__field_indices_by_name,
- 1, osmpbf__blob_header__number_ranges,
- (ProtobufCMessageInit) osmpbf__blob_header__init,
- NULL,NULL,NULL /* reserved[123] */
-};
diff --git a/navit/maptool/generated-code/fileformat.pb-c.h b/navit/maptool/generated-code/fileformat.pb-c.h
deleted file mode 100644
index 9996bfbea..000000000
--- a/navit/maptool/generated-code/fileformat.pb-c.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Generated by the protocol buffer compiler. DO NOT EDIT! */
-
-#ifndef PROTOBUF_C_fileformat_2eproto__INCLUDED
-#define PROTOBUF_C_fileformat_2eproto__INCLUDED
-
-#include <google/protobuf-c/protobuf-c.h>
-
-PROTOBUF_C_BEGIN_DECLS
-
-
-typedef struct _OSMPBF__Blob OSMPBF__Blob;
-typedef struct _OSMPBF__BlobHeader OSMPBF__BlobHeader;
-
-
-/* --- enums --- */
-
-
-/* --- messages --- */
-
-struct _OSMPBF__Blob
-{
- ProtobufCMessage base;
- protobuf_c_boolean has_raw;
- ProtobufCBinaryData raw;
- protobuf_c_boolean has_raw_size;
- int32_t raw_size;
- protobuf_c_boolean has_zlib_data;
- ProtobufCBinaryData zlib_data;
- protobuf_c_boolean has_lzma_data;
- ProtobufCBinaryData lzma_data;
- protobuf_c_boolean has_obsolete_bzip2_data PROTOBUF_C_DEPRECATED;
- ProtobufCBinaryData obsolete_bzip2_data PROTOBUF_C_DEPRECATED;
-};
-#define OSMPBF__BLOB__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__blob__descriptor) \
- , 0,{0,NULL}, 0,0, 0,{0,NULL}, 0,{0,NULL}, 0,{0,NULL} }
-
-
-struct _OSMPBF__BlobHeader
-{
- ProtobufCMessage base;
- char *type;
- protobuf_c_boolean has_indexdata;
- ProtobufCBinaryData indexdata;
- int32_t datasize;
-};
-#define OSMPBF__BLOB_HEADER__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__blob_header__descriptor) \
- , NULL, 0,{0,NULL}, 0 }
-
-
-/* OSMPBF__Blob methods */
-void osmpbf__blob__init
- (OSMPBF__Blob *message);
-size_t osmpbf__blob__get_packed_size
- (const OSMPBF__Blob *message);
-size_t osmpbf__blob__pack
- (const OSMPBF__Blob *message,
- uint8_t *out);
-size_t osmpbf__blob__pack_to_buffer
- (const OSMPBF__Blob *message,
- ProtobufCBuffer *buffer);
-OSMPBF__Blob *
- osmpbf__blob__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__blob__free_unpacked
- (OSMPBF__Blob *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__BlobHeader methods */
-void osmpbf__blob_header__init
- (OSMPBF__BlobHeader *message);
-size_t osmpbf__blob_header__get_packed_size
- (const OSMPBF__BlobHeader *message);
-size_t osmpbf__blob_header__pack
- (const OSMPBF__BlobHeader *message,
- uint8_t *out);
-size_t osmpbf__blob_header__pack_to_buffer
- (const OSMPBF__BlobHeader *message,
- ProtobufCBuffer *buffer);
-OSMPBF__BlobHeader *
- osmpbf__blob_header__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__blob_header__free_unpacked
- (OSMPBF__BlobHeader *message,
- ProtobufCAllocator *allocator);
-/* --- per-message closures --- */
-
-typedef void (*OSMPBF__Blob_Closure)
- (const OSMPBF__Blob *message,
- void *closure_data);
-typedef void (*OSMPBF__BlobHeader_Closure)
- (const OSMPBF__BlobHeader *message,
- void *closure_data);
-
-/* --- services --- */
-
-
-/* --- descriptors --- */
-
-extern const ProtobufCMessageDescriptor osmpbf__blob__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__blob_header__descriptor;
-
-PROTOBUF_C_END_DECLS
-
-
-#endif /* PROTOBUF_fileformat_2eproto__INCLUDED */
diff --git a/navit/maptool/generated-code/osmformat.pb-c.c b/navit/maptool/generated-code/osmformat.pb-c.c
deleted file mode 100644
index f31a72c4e..000000000
--- a/navit/maptool/generated-code/osmformat.pb-c.c
+++ /dev/null
@@ -1,1582 +0,0 @@
-/* Generated by the protocol buffer compiler. DO NOT EDIT! */
-
-/* Do not generate deprecated warnings for self */
-#ifndef PROTOBUF_C_NO_DEPRECATED
-#define PROTOBUF_C_NO_DEPRECATED
-#endif
-
-#include "osmformat.pb-c.h"
-void osmpbf__header_block__init
- (OSMPBF__HeaderBlock *message)
-{
- static OSMPBF__HeaderBlock init_value = OSMPBF__HEADER_BLOCK__INIT;
- *message = init_value;
-}
-size_t osmpbf__header_block__get_packed_size
- (const OSMPBF__HeaderBlock *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__header_block__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__header_block__pack
- (const OSMPBF__HeaderBlock *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__header_block__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__header_block__pack_to_buffer
- (const OSMPBF__HeaderBlock *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__header_block__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__HeaderBlock *
- osmpbf__header_block__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__HeaderBlock *)
- protobuf_c_message_unpack (&osmpbf__header_block__descriptor,
- allocator, len, data);
-}
-void osmpbf__header_block__free_unpacked
- (OSMPBF__HeaderBlock *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__header_block__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__header_bbox__init
- (OSMPBF__HeaderBBox *message)
-{
- static OSMPBF__HeaderBBox init_value = OSMPBF__HEADER_BBOX__INIT;
- *message = init_value;
-}
-size_t osmpbf__header_bbox__get_packed_size
- (const OSMPBF__HeaderBBox *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__header_bbox__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__header_bbox__pack
- (const OSMPBF__HeaderBBox *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__header_bbox__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__header_bbox__pack_to_buffer
- (const OSMPBF__HeaderBBox *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__header_bbox__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__HeaderBBox *
- osmpbf__header_bbox__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__HeaderBBox *)
- protobuf_c_message_unpack (&osmpbf__header_bbox__descriptor,
- allocator, len, data);
-}
-void osmpbf__header_bbox__free_unpacked
- (OSMPBF__HeaderBBox *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__header_bbox__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__primitive_block__init
- (OSMPBF__PrimitiveBlock *message)
-{
- static OSMPBF__PrimitiveBlock init_value = OSMPBF__PRIMITIVE_BLOCK__INIT;
- *message = init_value;
-}
-size_t osmpbf__primitive_block__get_packed_size
- (const OSMPBF__PrimitiveBlock *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__primitive_block__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__primitive_block__pack
- (const OSMPBF__PrimitiveBlock *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__primitive_block__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__primitive_block__pack_to_buffer
- (const OSMPBF__PrimitiveBlock *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__primitive_block__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__PrimitiveBlock *
- osmpbf__primitive_block__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__PrimitiveBlock *)
- protobuf_c_message_unpack (&osmpbf__primitive_block__descriptor,
- allocator, len, data);
-}
-void osmpbf__primitive_block__free_unpacked
- (OSMPBF__PrimitiveBlock *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__primitive_block__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__primitive_group__init
- (OSMPBF__PrimitiveGroup *message)
-{
- static OSMPBF__PrimitiveGroup init_value = OSMPBF__PRIMITIVE_GROUP__INIT;
- *message = init_value;
-}
-size_t osmpbf__primitive_group__get_packed_size
- (const OSMPBF__PrimitiveGroup *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__primitive_group__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__primitive_group__pack
- (const OSMPBF__PrimitiveGroup *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__primitive_group__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__primitive_group__pack_to_buffer
- (const OSMPBF__PrimitiveGroup *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__primitive_group__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__PrimitiveGroup *
- osmpbf__primitive_group__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__PrimitiveGroup *)
- protobuf_c_message_unpack (&osmpbf__primitive_group__descriptor,
- allocator, len, data);
-}
-void osmpbf__primitive_group__free_unpacked
- (OSMPBF__PrimitiveGroup *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__primitive_group__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__string_table__init
- (OSMPBF__StringTable *message)
-{
- static OSMPBF__StringTable init_value = OSMPBF__STRING_TABLE__INIT;
- *message = init_value;
-}
-size_t osmpbf__string_table__get_packed_size
- (const OSMPBF__StringTable *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__string_table__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__string_table__pack
- (const OSMPBF__StringTable *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__string_table__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__string_table__pack_to_buffer
- (const OSMPBF__StringTable *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__string_table__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__StringTable *
- osmpbf__string_table__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__StringTable *)
- protobuf_c_message_unpack (&osmpbf__string_table__descriptor,
- allocator, len, data);
-}
-void osmpbf__string_table__free_unpacked
- (OSMPBF__StringTable *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__string_table__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__info__init
- (OSMPBF__Info *message)
-{
- static OSMPBF__Info init_value = OSMPBF__INFO__INIT;
- *message = init_value;
-}
-size_t osmpbf__info__get_packed_size
- (const OSMPBF__Info *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__info__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__info__pack
- (const OSMPBF__Info *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__info__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__info__pack_to_buffer
- (const OSMPBF__Info *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__info__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__Info *
- osmpbf__info__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__Info *)
- protobuf_c_message_unpack (&osmpbf__info__descriptor,
- allocator, len, data);
-}
-void osmpbf__info__free_unpacked
- (OSMPBF__Info *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__info__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__dense_info__init
- (OSMPBF__DenseInfo *message)
-{
- static OSMPBF__DenseInfo init_value = OSMPBF__DENSE_INFO__INIT;
- *message = init_value;
-}
-size_t osmpbf__dense_info__get_packed_size
- (const OSMPBF__DenseInfo *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__dense_info__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__dense_info__pack
- (const OSMPBF__DenseInfo *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__dense_info__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__dense_info__pack_to_buffer
- (const OSMPBF__DenseInfo *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__dense_info__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__DenseInfo *
- osmpbf__dense_info__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__DenseInfo *)
- protobuf_c_message_unpack (&osmpbf__dense_info__descriptor,
- allocator, len, data);
-}
-void osmpbf__dense_info__free_unpacked
- (OSMPBF__DenseInfo *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__dense_info__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__change_set__init
- (OSMPBF__ChangeSet *message)
-{
- static OSMPBF__ChangeSet init_value = OSMPBF__CHANGE_SET__INIT;
- *message = init_value;
-}
-size_t osmpbf__change_set__get_packed_size
- (const OSMPBF__ChangeSet *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__change_set__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__change_set__pack
- (const OSMPBF__ChangeSet *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__change_set__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__change_set__pack_to_buffer
- (const OSMPBF__ChangeSet *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__change_set__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__ChangeSet *
- osmpbf__change_set__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__ChangeSet *)
- protobuf_c_message_unpack (&osmpbf__change_set__descriptor,
- allocator, len, data);
-}
-void osmpbf__change_set__free_unpacked
- (OSMPBF__ChangeSet *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__change_set__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__node__init
- (OSMPBF__Node *message)
-{
- static OSMPBF__Node init_value = OSMPBF__NODE__INIT;
- *message = init_value;
-}
-size_t osmpbf__node__get_packed_size
- (const OSMPBF__Node *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__node__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__node__pack
- (const OSMPBF__Node *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__node__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__node__pack_to_buffer
- (const OSMPBF__Node *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__node__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__Node *
- osmpbf__node__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__Node *)
- protobuf_c_message_unpack (&osmpbf__node__descriptor,
- allocator, len, data);
-}
-void osmpbf__node__free_unpacked
- (OSMPBF__Node *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__node__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__dense_nodes__init
- (OSMPBF__DenseNodes *message)
-{
- static OSMPBF__DenseNodes init_value = OSMPBF__DENSE_NODES__INIT;
- *message = init_value;
-}
-size_t osmpbf__dense_nodes__get_packed_size
- (const OSMPBF__DenseNodes *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__dense_nodes__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__dense_nodes__pack
- (const OSMPBF__DenseNodes *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__dense_nodes__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__dense_nodes__pack_to_buffer
- (const OSMPBF__DenseNodes *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__dense_nodes__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__DenseNodes *
- osmpbf__dense_nodes__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__DenseNodes *)
- protobuf_c_message_unpack (&osmpbf__dense_nodes__descriptor,
- allocator, len, data);
-}
-void osmpbf__dense_nodes__free_unpacked
- (OSMPBF__DenseNodes *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__dense_nodes__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__way__init
- (OSMPBF__Way *message)
-{
- static OSMPBF__Way init_value = OSMPBF__WAY__INIT;
- *message = init_value;
-}
-size_t osmpbf__way__get_packed_size
- (const OSMPBF__Way *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__way__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__way__pack
- (const OSMPBF__Way *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__way__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__way__pack_to_buffer
- (const OSMPBF__Way *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__way__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__Way *
- osmpbf__way__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__Way *)
- protobuf_c_message_unpack (&osmpbf__way__descriptor,
- allocator, len, data);
-}
-void osmpbf__way__free_unpacked
- (OSMPBF__Way *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__way__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-void osmpbf__relation__init
- (OSMPBF__Relation *message)
-{
- static OSMPBF__Relation init_value = OSMPBF__RELATION__INIT;
- *message = init_value;
-}
-size_t osmpbf__relation__get_packed_size
- (const OSMPBF__Relation *message)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__relation__descriptor);
- return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
-}
-size_t osmpbf__relation__pack
- (const OSMPBF__Relation *message,
- uint8_t *out)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__relation__descriptor);
- return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
-}
-size_t osmpbf__relation__pack_to_buffer
- (const OSMPBF__Relation *message,
- ProtobufCBuffer *buffer)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__relation__descriptor);
- return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
-}
-OSMPBF__Relation *
- osmpbf__relation__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- return (OSMPBF__Relation *)
- protobuf_c_message_unpack (&osmpbf__relation__descriptor,
- allocator, len, data);
-}
-void osmpbf__relation__free_unpacked
- (OSMPBF__Relation *message,
- ProtobufCAllocator *allocator)
-{
- PROTOBUF_C_ASSERT (message->base.descriptor == &osmpbf__relation__descriptor);
- protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
-}
-static const ProtobufCFieldDescriptor osmpbf__header_block__field_descriptors[5] =
-{
- {
- "bbox",
- 1,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_MESSAGE,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBlock, bbox),
- &osmpbf__header_bbox__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "required_features",
- 4,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_STRING,
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBlock, n_required_features),
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBlock, required_features),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "optional_features",
- 5,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_STRING,
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBlock, n_optional_features),
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBlock, optional_features),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "writingprogram",
- 16,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_STRING,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBlock, writingprogram),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "source",
- 17,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_STRING,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBlock, source),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__header_block__field_indices_by_name[] = {
- 0, /* field[0] = bbox */
- 2, /* field[2] = optional_features */
- 1, /* field[1] = required_features */
- 4, /* field[4] = source */
- 3, /* field[3] = writingprogram */
-};
-static const ProtobufCIntRange osmpbf__header_block__number_ranges[3 + 1] =
-{
- { 1, 0 },
- { 4, 1 },
- { 16, 3 },
- { 0, 5 }
-};
-const ProtobufCMessageDescriptor osmpbf__header_block__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.HeaderBlock",
- "HeaderBlock",
- "OSMPBF__HeaderBlock",
- "OSMPBF",
- sizeof(OSMPBF__HeaderBlock),
- 5,
- osmpbf__header_block__field_descriptors,
- osmpbf__header_block__field_indices_by_name,
- 3, osmpbf__header_block__number_ranges,
- (ProtobufCMessageInit) osmpbf__header_block__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const ProtobufCFieldDescriptor osmpbf__header_bbox__field_descriptors[4] =
-{
- {
- "left",
- 1,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_SINT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBBox, left),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "right",
- 2,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_SINT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBBox, right),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "top",
- 3,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_SINT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBBox, top),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "bottom",
- 4,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_SINT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__HeaderBBox, bottom),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__header_bbox__field_indices_by_name[] = {
- 3, /* field[3] = bottom */
- 0, /* field[0] = left */
- 1, /* field[1] = right */
- 2, /* field[2] = top */
-};
-static const ProtobufCIntRange osmpbf__header_bbox__number_ranges[1 + 1] =
-{
- { 1, 0 },
- { 0, 4 }
-};
-const ProtobufCMessageDescriptor osmpbf__header_bbox__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.HeaderBBox",
- "HeaderBBox",
- "OSMPBF__HeaderBBox",
- "OSMPBF",
- sizeof(OSMPBF__HeaderBBox),
- 4,
- osmpbf__header_bbox__field_descriptors,
- osmpbf__header_bbox__field_indices_by_name,
- 1, osmpbf__header_bbox__number_ranges,
- (ProtobufCMessageInit) osmpbf__header_bbox__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const int32_t osmpbf__primitive_block__granularity__default_value = 100;
-static const int64_t osmpbf__primitive_block__lat_offset__default_value = 0;
-static const int64_t osmpbf__primitive_block__lon_offset__default_value = 0;
-static const int32_t osmpbf__primitive_block__date_granularity__default_value = 1000;
-static const ProtobufCFieldDescriptor osmpbf__primitive_block__field_descriptors[6] =
-{
- {
- "stringtable",
- 1,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_MESSAGE,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, stringtable),
- &osmpbf__string_table__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "primitivegroup",
- 2,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_MESSAGE,
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, n_primitivegroup),
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, primitivegroup),
- &osmpbf__primitive_group__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "granularity",
- 17,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_INT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, has_granularity),
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, granularity),
- NULL,
- &osmpbf__primitive_block__granularity__default_value,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "date_granularity",
- 18,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_INT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, has_date_granularity),
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, date_granularity),
- NULL,
- &osmpbf__primitive_block__date_granularity__default_value,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "lat_offset",
- 19,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_INT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, has_lat_offset),
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, lat_offset),
- NULL,
- &osmpbf__primitive_block__lat_offset__default_value,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "lon_offset",
- 20,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_INT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, has_lon_offset),
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveBlock, lon_offset),
- NULL,
- &osmpbf__primitive_block__lon_offset__default_value,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__primitive_block__field_indices_by_name[] = {
- 3, /* field[3] = date_granularity */
- 2, /* field[2] = granularity */
- 4, /* field[4] = lat_offset */
- 5, /* field[5] = lon_offset */
- 1, /* field[1] = primitivegroup */
- 0, /* field[0] = stringtable */
-};
-static const ProtobufCIntRange osmpbf__primitive_block__number_ranges[2 + 1] =
-{
- { 1, 0 },
- { 17, 2 },
- { 0, 6 }
-};
-const ProtobufCMessageDescriptor osmpbf__primitive_block__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.PrimitiveBlock",
- "PrimitiveBlock",
- "OSMPBF__PrimitiveBlock",
- "OSMPBF",
- sizeof(OSMPBF__PrimitiveBlock),
- 6,
- osmpbf__primitive_block__field_descriptors,
- osmpbf__primitive_block__field_indices_by_name,
- 2, osmpbf__primitive_block__number_ranges,
- (ProtobufCMessageInit) osmpbf__primitive_block__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const ProtobufCFieldDescriptor osmpbf__primitive_group__field_descriptors[5] =
-{
- {
- "nodes",
- 1,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_MESSAGE,
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveGroup, n_nodes),
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveGroup, nodes),
- &osmpbf__node__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "dense",
- 2,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_MESSAGE,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveGroup, dense),
- &osmpbf__dense_nodes__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "ways",
- 3,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_MESSAGE,
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveGroup, n_ways),
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveGroup, ways),
- &osmpbf__way__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "relations",
- 4,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_MESSAGE,
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveGroup, n_relations),
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveGroup, relations),
- &osmpbf__relation__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "changesets",
- 5,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_MESSAGE,
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveGroup, n_changesets),
- PROTOBUF_C_OFFSETOF(OSMPBF__PrimitiveGroup, changesets),
- &osmpbf__change_set__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__primitive_group__field_indices_by_name[] = {
- 4, /* field[4] = changesets */
- 1, /* field[1] = dense */
- 0, /* field[0] = nodes */
- 3, /* field[3] = relations */
- 2, /* field[2] = ways */
-};
-static const ProtobufCIntRange osmpbf__primitive_group__number_ranges[1 + 1] =
-{
- { 1, 0 },
- { 0, 5 }
-};
-const ProtobufCMessageDescriptor osmpbf__primitive_group__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.PrimitiveGroup",
- "PrimitiveGroup",
- "OSMPBF__PrimitiveGroup",
- "OSMPBF",
- sizeof(OSMPBF__PrimitiveGroup),
- 5,
- osmpbf__primitive_group__field_descriptors,
- osmpbf__primitive_group__field_indices_by_name,
- 1, osmpbf__primitive_group__number_ranges,
- (ProtobufCMessageInit) osmpbf__primitive_group__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const ProtobufCFieldDescriptor osmpbf__string_table__field_descriptors[1] =
-{
- {
- "s",
- 1,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_BYTES,
- PROTOBUF_C_OFFSETOF(OSMPBF__StringTable, n_s),
- PROTOBUF_C_OFFSETOF(OSMPBF__StringTable, s),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__string_table__field_indices_by_name[] = {
- 0, /* field[0] = s */
-};
-static const ProtobufCIntRange osmpbf__string_table__number_ranges[1 + 1] =
-{
- { 1, 0 },
- { 0, 1 }
-};
-const ProtobufCMessageDescriptor osmpbf__string_table__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.StringTable",
- "StringTable",
- "OSMPBF__StringTable",
- "OSMPBF",
- sizeof(OSMPBF__StringTable),
- 1,
- osmpbf__string_table__field_descriptors,
- osmpbf__string_table__field_indices_by_name,
- 1, osmpbf__string_table__number_ranges,
- (ProtobufCMessageInit) osmpbf__string_table__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const int32_t osmpbf__info__version__default_value = -1;
-static const ProtobufCFieldDescriptor osmpbf__info__field_descriptors[5] =
-{
- {
- "version",
- 1,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_INT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, has_version),
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, version),
- NULL,
- &osmpbf__info__version__default_value,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "timestamp",
- 2,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_INT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, has_timestamp),
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, timestamp),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "changeset",
- 3,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_INT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, has_changeset),
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, changeset),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "uid",
- 4,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_INT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, has_uid),
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, uid),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "user_sid",
- 5,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_UINT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, has_user_sid),
- PROTOBUF_C_OFFSETOF(OSMPBF__Info, user_sid),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__info__field_indices_by_name[] = {
- 2, /* field[2] = changeset */
- 1, /* field[1] = timestamp */
- 3, /* field[3] = uid */
- 4, /* field[4] = user_sid */
- 0, /* field[0] = version */
-};
-static const ProtobufCIntRange osmpbf__info__number_ranges[1 + 1] =
-{
- { 1, 0 },
- { 0, 5 }
-};
-const ProtobufCMessageDescriptor osmpbf__info__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.Info",
- "Info",
- "OSMPBF__Info",
- "OSMPBF",
- sizeof(OSMPBF__Info),
- 5,
- osmpbf__info__field_descriptors,
- osmpbf__info__field_indices_by_name,
- 1, osmpbf__info__number_ranges,
- (ProtobufCMessageInit) osmpbf__info__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const ProtobufCFieldDescriptor osmpbf__dense_info__field_descriptors[5] =
-{
- {
- "version",
- 1,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_INT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, n_version),
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, version),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "timestamp",
- 2,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_SINT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, n_timestamp),
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, timestamp),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "changeset",
- 3,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_SINT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, n_changeset),
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, changeset),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "uid",
- 4,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_SINT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, n_uid),
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, uid),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "user_sid",
- 5,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_SINT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, n_user_sid),
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseInfo, user_sid),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__dense_info__field_indices_by_name[] = {
- 2, /* field[2] = changeset */
- 1, /* field[1] = timestamp */
- 3, /* field[3] = uid */
- 4, /* field[4] = user_sid */
- 0, /* field[0] = version */
-};
-static const ProtobufCIntRange osmpbf__dense_info__number_ranges[1 + 1] =
-{
- { 1, 0 },
- { 0, 5 }
-};
-const ProtobufCMessageDescriptor osmpbf__dense_info__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.DenseInfo",
- "DenseInfo",
- "OSMPBF__DenseInfo",
- "OSMPBF",
- sizeof(OSMPBF__DenseInfo),
- 5,
- osmpbf__dense_info__field_descriptors,
- osmpbf__dense_info__field_indices_by_name,
- 1, osmpbf__dense_info__number_ranges,
- (ProtobufCMessageInit) osmpbf__dense_info__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const ProtobufCFieldDescriptor osmpbf__change_set__field_descriptors[1] =
-{
- {
- "id",
- 1,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_INT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__ChangeSet, id),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__change_set__field_indices_by_name[] = {
- 0, /* field[0] = id */
-};
-static const ProtobufCIntRange osmpbf__change_set__number_ranges[1 + 1] =
-{
- { 1, 0 },
- { 0, 1 }
-};
-const ProtobufCMessageDescriptor osmpbf__change_set__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.ChangeSet",
- "ChangeSet",
- "OSMPBF__ChangeSet",
- "OSMPBF",
- sizeof(OSMPBF__ChangeSet),
- 1,
- osmpbf__change_set__field_descriptors,
- osmpbf__change_set__field_indices_by_name,
- 1, osmpbf__change_set__number_ranges,
- (ProtobufCMessageInit) osmpbf__change_set__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const ProtobufCFieldDescriptor osmpbf__node__field_descriptors[6] =
-{
- {
- "id",
- 1,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_SINT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__Node, id),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "keys",
- 2,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_UINT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Node, n_keys),
- PROTOBUF_C_OFFSETOF(OSMPBF__Node, keys),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "vals",
- 3,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_UINT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Node, n_vals),
- PROTOBUF_C_OFFSETOF(OSMPBF__Node, vals),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "info",
- 4,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_MESSAGE,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__Node, info),
- &osmpbf__info__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "lat",
- 8,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_SINT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__Node, lat),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "lon",
- 9,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_SINT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__Node, lon),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__node__field_indices_by_name[] = {
- 0, /* field[0] = id */
- 3, /* field[3] = info */
- 1, /* field[1] = keys */
- 4, /* field[4] = lat */
- 5, /* field[5] = lon */
- 2, /* field[2] = vals */
-};
-static const ProtobufCIntRange osmpbf__node__number_ranges[2 + 1] =
-{
- { 1, 0 },
- { 8, 4 },
- { 0, 6 }
-};
-const ProtobufCMessageDescriptor osmpbf__node__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.Node",
- "Node",
- "OSMPBF__Node",
- "OSMPBF",
- sizeof(OSMPBF__Node),
- 6,
- osmpbf__node__field_descriptors,
- osmpbf__node__field_indices_by_name,
- 2, osmpbf__node__number_ranges,
- (ProtobufCMessageInit) osmpbf__node__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const ProtobufCFieldDescriptor osmpbf__dense_nodes__field_descriptors[5] =
-{
- {
- "id",
- 1,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_SINT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseNodes, n_id),
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseNodes, id),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "denseinfo",
- 5,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_MESSAGE,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseNodes, denseinfo),
- &osmpbf__dense_info__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "lat",
- 8,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_SINT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseNodes, n_lat),
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseNodes, lat),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "lon",
- 9,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_SINT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseNodes, n_lon),
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseNodes, lon),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "keys_vals",
- 10,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_INT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseNodes, n_keys_vals),
- PROTOBUF_C_OFFSETOF(OSMPBF__DenseNodes, keys_vals),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__dense_nodes__field_indices_by_name[] = {
- 1, /* field[1] = denseinfo */
- 0, /* field[0] = id */
- 4, /* field[4] = keys_vals */
- 2, /* field[2] = lat */
- 3, /* field[3] = lon */
-};
-static const ProtobufCIntRange osmpbf__dense_nodes__number_ranges[3 + 1] =
-{
- { 1, 0 },
- { 5, 1 },
- { 8, 2 },
- { 0, 5 }
-};
-const ProtobufCMessageDescriptor osmpbf__dense_nodes__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.DenseNodes",
- "DenseNodes",
- "OSMPBF__DenseNodes",
- "OSMPBF",
- sizeof(OSMPBF__DenseNodes),
- 5,
- osmpbf__dense_nodes__field_descriptors,
- osmpbf__dense_nodes__field_indices_by_name,
- 3, osmpbf__dense_nodes__number_ranges,
- (ProtobufCMessageInit) osmpbf__dense_nodes__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-static const ProtobufCFieldDescriptor osmpbf__way__field_descriptors[5] =
-{
- {
- "id",
- 1,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_INT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__Way, id),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "keys",
- 2,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_UINT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Way, n_keys),
- PROTOBUF_C_OFFSETOF(OSMPBF__Way, keys),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "vals",
- 3,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_UINT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Way, n_vals),
- PROTOBUF_C_OFFSETOF(OSMPBF__Way, vals),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "info",
- 4,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_MESSAGE,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__Way, info),
- &osmpbf__info__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "refs",
- 8,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_SINT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__Way, n_refs),
- PROTOBUF_C_OFFSETOF(OSMPBF__Way, refs),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__way__field_indices_by_name[] = {
- 0, /* field[0] = id */
- 3, /* field[3] = info */
- 1, /* field[1] = keys */
- 4, /* field[4] = refs */
- 2, /* field[2] = vals */
-};
-static const ProtobufCIntRange osmpbf__way__number_ranges[2 + 1] =
-{
- { 1, 0 },
- { 8, 4 },
- { 0, 5 }
-};
-const ProtobufCMessageDescriptor osmpbf__way__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.Way",
- "Way",
- "OSMPBF__Way",
- "OSMPBF",
- sizeof(OSMPBF__Way),
- 5,
- osmpbf__way__field_descriptors,
- osmpbf__way__field_indices_by_name,
- 2, osmpbf__way__number_ranges,
- (ProtobufCMessageInit) osmpbf__way__init,
- NULL,NULL,NULL /* reserved[123] */
-};
-const ProtobufCEnumValue osmpbf__relation__member_type__enum_values_by_number[3] =
-{
- { "NODE", "OSMPBF__RELATION__MEMBER_TYPE__NODE", 0 },
- { "WAY", "OSMPBF__RELATION__MEMBER_TYPE__WAY", 1 },
- { "RELATION", "OSMPBF__RELATION__MEMBER_TYPE__RELATION", 2 },
-};
-static const ProtobufCIntRange osmpbf__relation__member_type__value_ranges[] = {
-{0, 0},{0, 3}
-};
-const ProtobufCEnumValueIndex osmpbf__relation__member_type__enum_values_by_name[3] =
-{
- { "NODE", 0 },
- { "RELATION", 2 },
- { "WAY", 1 },
-};
-const ProtobufCEnumDescriptor osmpbf__relation__member_type__descriptor =
-{
- PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC,
- "OSMPBF.Relation.MemberType",
- "MemberType",
- "OSMPBF__Relation__MemberType",
- "OSMPBF",
- 3,
- osmpbf__relation__member_type__enum_values_by_number,
- 3,
- osmpbf__relation__member_type__enum_values_by_name,
- 1,
- osmpbf__relation__member_type__value_ranges,
- NULL,NULL,NULL,NULL /* reserved[1234] */
-};
-static const ProtobufCFieldDescriptor osmpbf__relation__field_descriptors[7] =
-{
- {
- "id",
- 1,
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_INT64,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, id),
- NULL,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "keys",
- 2,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_UINT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, n_keys),
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, keys),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "vals",
- 3,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_UINT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, n_vals),
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, vals),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "info",
- 4,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_TYPE_MESSAGE,
- 0, /* quantifier_offset */
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, info),
- &osmpbf__info__descriptor,
- NULL,
- 0, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "roles_sid",
- 8,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_INT32,
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, n_roles_sid),
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, roles_sid),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "memids",
- 9,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_SINT64,
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, n_memids),
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, memids),
- NULL,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
- {
- "types",
- 10,
- PROTOBUF_C_LABEL_REPEATED,
- PROTOBUF_C_TYPE_ENUM,
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, n_types),
- PROTOBUF_C_OFFSETOF(OSMPBF__Relation, types),
- &osmpbf__relation__member_type__descriptor,
- NULL,
- 1, /* packed */
- 0,NULL,NULL /* reserved1,reserved2, etc */
- },
-};
-static const unsigned osmpbf__relation__field_indices_by_name[] = {
- 0, /* field[0] = id */
- 3, /* field[3] = info */
- 1, /* field[1] = keys */
- 5, /* field[5] = memids */
- 4, /* field[4] = roles_sid */
- 6, /* field[6] = types */
- 2, /* field[2] = vals */
-};
-static const ProtobufCIntRange osmpbf__relation__number_ranges[2 + 1] =
-{
- { 1, 0 },
- { 8, 4 },
- { 0, 7 }
-};
-const ProtobufCMessageDescriptor osmpbf__relation__descriptor =
-{
- PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC,
- "OSMPBF.Relation",
- "Relation",
- "OSMPBF__Relation",
- "OSMPBF",
- sizeof(OSMPBF__Relation),
- 7,
- osmpbf__relation__field_descriptors,
- osmpbf__relation__field_indices_by_name,
- 2, osmpbf__relation__number_ranges,
- (ProtobufCMessageInit) osmpbf__relation__init,
- NULL,NULL,NULL /* reserved[123] */
-};
diff --git a/navit/maptool/generated-code/osmformat.pb-c.h b/navit/maptool/generated-code/osmformat.pb-c.h
deleted file mode 100644
index 32ac75767..000000000
--- a/navit/maptool/generated-code/osmformat.pb-c.h
+++ /dev/null
@@ -1,523 +0,0 @@
-/* Generated by the protocol buffer compiler. DO NOT EDIT! */
-
-#ifndef PROTOBUF_C_osmformat_2eproto__INCLUDED
-#define PROTOBUF_C_osmformat_2eproto__INCLUDED
-
-#include <google/protobuf-c/protobuf-c.h>
-
-PROTOBUF_C_BEGIN_DECLS
-
-
-typedef struct _OSMPBF__HeaderBlock OSMPBF__HeaderBlock;
-typedef struct _OSMPBF__HeaderBBox OSMPBF__HeaderBBox;
-typedef struct _OSMPBF__PrimitiveBlock OSMPBF__PrimitiveBlock;
-typedef struct _OSMPBF__PrimitiveGroup OSMPBF__PrimitiveGroup;
-typedef struct _OSMPBF__StringTable OSMPBF__StringTable;
-typedef struct _OSMPBF__Info OSMPBF__Info;
-typedef struct _OSMPBF__DenseInfo OSMPBF__DenseInfo;
-typedef struct _OSMPBF__ChangeSet OSMPBF__ChangeSet;
-typedef struct _OSMPBF__Node OSMPBF__Node;
-typedef struct _OSMPBF__DenseNodes OSMPBF__DenseNodes;
-typedef struct _OSMPBF__Way OSMPBF__Way;
-typedef struct _OSMPBF__Relation OSMPBF__Relation;
-
-
-/* --- enums --- */
-
-typedef enum _OSMPBF__Relation__MemberType {
- OSMPBF__RELATION__MEMBER_TYPE__NODE = 0,
- OSMPBF__RELATION__MEMBER_TYPE__WAY = 1,
- OSMPBF__RELATION__MEMBER_TYPE__RELATION = 2
-} OSMPBF__Relation__MemberType;
-
-/* --- messages --- */
-
-struct _OSMPBF__HeaderBlock
-{
- ProtobufCMessage base;
- OSMPBF__HeaderBBox *bbox;
- size_t n_required_features;
- char **required_features;
- size_t n_optional_features;
- char **optional_features;
- char *writingprogram;
- char *source;
-};
-#define OSMPBF__HEADER_BLOCK__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__header_block__descriptor) \
- , NULL, 0,NULL, 0,NULL, NULL, NULL }
-
-
-struct _OSMPBF__HeaderBBox
-{
- ProtobufCMessage base;
- int64_t left;
- int64_t right;
- int64_t top;
- int64_t bottom;
-};
-#define OSMPBF__HEADER_BBOX__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__header_bbox__descriptor) \
- , 0, 0, 0, 0 }
-
-
-struct _OSMPBF__PrimitiveBlock
-{
- ProtobufCMessage base;
- OSMPBF__StringTable *stringtable;
- size_t n_primitivegroup;
- OSMPBF__PrimitiveGroup **primitivegroup;
- protobuf_c_boolean has_granularity;
- int32_t granularity;
- protobuf_c_boolean has_lat_offset;
- int64_t lat_offset;
- protobuf_c_boolean has_lon_offset;
- int64_t lon_offset;
- protobuf_c_boolean has_date_granularity;
- int32_t date_granularity;
-};
-#define OSMPBF__PRIMITIVE_BLOCK__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__primitive_block__descriptor) \
- , NULL, 0,NULL, 0,100, 0,0, 0,0, 0,1000 }
-
-
-struct _OSMPBF__PrimitiveGroup
-{
- ProtobufCMessage base;
- size_t n_nodes;
- OSMPBF__Node **nodes;
- OSMPBF__DenseNodes *dense;
- size_t n_ways;
- OSMPBF__Way **ways;
- size_t n_relations;
- OSMPBF__Relation **relations;
- size_t n_changesets;
- OSMPBF__ChangeSet **changesets;
-};
-#define OSMPBF__PRIMITIVE_GROUP__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__primitive_group__descriptor) \
- , 0,NULL, NULL, 0,NULL, 0,NULL, 0,NULL }
-
-
-struct _OSMPBF__StringTable
-{
- ProtobufCMessage base;
- size_t n_s;
- ProtobufCBinaryData *s;
-};
-#define OSMPBF__STRING_TABLE__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__string_table__descriptor) \
- , 0,NULL }
-
-
-struct _OSMPBF__Info
-{
- ProtobufCMessage base;
- protobuf_c_boolean has_version;
- int32_t version;
- protobuf_c_boolean has_timestamp;
- int64_t timestamp;
- protobuf_c_boolean has_changeset;
- int64_t changeset;
- protobuf_c_boolean has_uid;
- int32_t uid;
- protobuf_c_boolean has_user_sid;
- uint32_t user_sid;
-};
-#define OSMPBF__INFO__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__info__descriptor) \
- , 0,-1, 0,0, 0,0, 0,0, 0,0 }
-
-
-struct _OSMPBF__DenseInfo
-{
- ProtobufCMessage base;
- size_t n_version;
- int32_t *version;
- size_t n_timestamp;
- int64_t *timestamp;
- size_t n_changeset;
- int64_t *changeset;
- size_t n_uid;
- int32_t *uid;
- size_t n_user_sid;
- int32_t *user_sid;
-};
-#define OSMPBF__DENSE_INFO__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__dense_info__descriptor) \
- , 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL }
-
-
-struct _OSMPBF__ChangeSet
-{
- ProtobufCMessage base;
- int64_t id;
-};
-#define OSMPBF__CHANGE_SET__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__change_set__descriptor) \
- , 0 }
-
-
-struct _OSMPBF__Node
-{
- ProtobufCMessage base;
- int64_t id;
- size_t n_keys;
- uint32_t *keys;
- size_t n_vals;
- uint32_t *vals;
- OSMPBF__Info *info;
- int64_t lat;
- int64_t lon;
-};
-#define OSMPBF__NODE__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__node__descriptor) \
- , 0, 0,NULL, 0,NULL, NULL, 0, 0 }
-
-
-struct _OSMPBF__DenseNodes
-{
- ProtobufCMessage base;
- size_t n_id;
- int64_t *id;
- OSMPBF__DenseInfo *denseinfo;
- size_t n_lat;
- int64_t *lat;
- size_t n_lon;
- int64_t *lon;
- size_t n_keys_vals;
- int32_t *keys_vals;
-};
-#define OSMPBF__DENSE_NODES__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__dense_nodes__descriptor) \
- , 0,NULL, NULL, 0,NULL, 0,NULL, 0,NULL }
-
-
-struct _OSMPBF__Way
-{
- ProtobufCMessage base;
- int64_t id;
- size_t n_keys;
- uint32_t *keys;
- size_t n_vals;
- uint32_t *vals;
- OSMPBF__Info *info;
- size_t n_refs;
- int64_t *refs;
-};
-#define OSMPBF__WAY__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__way__descriptor) \
- , 0, 0,NULL, 0,NULL, NULL, 0,NULL }
-
-
-struct _OSMPBF__Relation
-{
- ProtobufCMessage base;
- int64_t id;
- size_t n_keys;
- uint32_t *keys;
- size_t n_vals;
- uint32_t *vals;
- OSMPBF__Info *info;
- size_t n_roles_sid;
- int32_t *roles_sid;
- size_t n_memids;
- int64_t *memids;
- size_t n_types;
- OSMPBF__Relation__MemberType *types;
-};
-#define OSMPBF__RELATION__INIT \
- { PROTOBUF_C_MESSAGE_INIT (&osmpbf__relation__descriptor) \
- , 0, 0,NULL, 0,NULL, NULL, 0,NULL, 0,NULL, 0,NULL }
-
-
-/* OSMPBF__HeaderBlock methods */
-void osmpbf__header_block__init
- (OSMPBF__HeaderBlock *message);
-size_t osmpbf__header_block__get_packed_size
- (const OSMPBF__HeaderBlock *message);
-size_t osmpbf__header_block__pack
- (const OSMPBF__HeaderBlock *message,
- uint8_t *out);
-size_t osmpbf__header_block__pack_to_buffer
- (const OSMPBF__HeaderBlock *message,
- ProtobufCBuffer *buffer);
-OSMPBF__HeaderBlock *
- osmpbf__header_block__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__header_block__free_unpacked
- (OSMPBF__HeaderBlock *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__HeaderBBox methods */
-void osmpbf__header_bbox__init
- (OSMPBF__HeaderBBox *message);
-size_t osmpbf__header_bbox__get_packed_size
- (const OSMPBF__HeaderBBox *message);
-size_t osmpbf__header_bbox__pack
- (const OSMPBF__HeaderBBox *message,
- uint8_t *out);
-size_t osmpbf__header_bbox__pack_to_buffer
- (const OSMPBF__HeaderBBox *message,
- ProtobufCBuffer *buffer);
-OSMPBF__HeaderBBox *
- osmpbf__header_bbox__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__header_bbox__free_unpacked
- (OSMPBF__HeaderBBox *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__PrimitiveBlock methods */
-void osmpbf__primitive_block__init
- (OSMPBF__PrimitiveBlock *message);
-size_t osmpbf__primitive_block__get_packed_size
- (const OSMPBF__PrimitiveBlock *message);
-size_t osmpbf__primitive_block__pack
- (const OSMPBF__PrimitiveBlock *message,
- uint8_t *out);
-size_t osmpbf__primitive_block__pack_to_buffer
- (const OSMPBF__PrimitiveBlock *message,
- ProtobufCBuffer *buffer);
-OSMPBF__PrimitiveBlock *
- osmpbf__primitive_block__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__primitive_block__free_unpacked
- (OSMPBF__PrimitiveBlock *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__PrimitiveGroup methods */
-void osmpbf__primitive_group__init
- (OSMPBF__PrimitiveGroup *message);
-size_t osmpbf__primitive_group__get_packed_size
- (const OSMPBF__PrimitiveGroup *message);
-size_t osmpbf__primitive_group__pack
- (const OSMPBF__PrimitiveGroup *message,
- uint8_t *out);
-size_t osmpbf__primitive_group__pack_to_buffer
- (const OSMPBF__PrimitiveGroup *message,
- ProtobufCBuffer *buffer);
-OSMPBF__PrimitiveGroup *
- osmpbf__primitive_group__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__primitive_group__free_unpacked
- (OSMPBF__PrimitiveGroup *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__StringTable methods */
-void osmpbf__string_table__init
- (OSMPBF__StringTable *message);
-size_t osmpbf__string_table__get_packed_size
- (const OSMPBF__StringTable *message);
-size_t osmpbf__string_table__pack
- (const OSMPBF__StringTable *message,
- uint8_t *out);
-size_t osmpbf__string_table__pack_to_buffer
- (const OSMPBF__StringTable *message,
- ProtobufCBuffer *buffer);
-OSMPBF__StringTable *
- osmpbf__string_table__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__string_table__free_unpacked
- (OSMPBF__StringTable *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__Info methods */
-void osmpbf__info__init
- (OSMPBF__Info *message);
-size_t osmpbf__info__get_packed_size
- (const OSMPBF__Info *message);
-size_t osmpbf__info__pack
- (const OSMPBF__Info *message,
- uint8_t *out);
-size_t osmpbf__info__pack_to_buffer
- (const OSMPBF__Info *message,
- ProtobufCBuffer *buffer);
-OSMPBF__Info *
- osmpbf__info__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__info__free_unpacked
- (OSMPBF__Info *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__DenseInfo methods */
-void osmpbf__dense_info__init
- (OSMPBF__DenseInfo *message);
-size_t osmpbf__dense_info__get_packed_size
- (const OSMPBF__DenseInfo *message);
-size_t osmpbf__dense_info__pack
- (const OSMPBF__DenseInfo *message,
- uint8_t *out);
-size_t osmpbf__dense_info__pack_to_buffer
- (const OSMPBF__DenseInfo *message,
- ProtobufCBuffer *buffer);
-OSMPBF__DenseInfo *
- osmpbf__dense_info__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__dense_info__free_unpacked
- (OSMPBF__DenseInfo *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__ChangeSet methods */
-void osmpbf__change_set__init
- (OSMPBF__ChangeSet *message);
-size_t osmpbf__change_set__get_packed_size
- (const OSMPBF__ChangeSet *message);
-size_t osmpbf__change_set__pack
- (const OSMPBF__ChangeSet *message,
- uint8_t *out);
-size_t osmpbf__change_set__pack_to_buffer
- (const OSMPBF__ChangeSet *message,
- ProtobufCBuffer *buffer);
-OSMPBF__ChangeSet *
- osmpbf__change_set__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__change_set__free_unpacked
- (OSMPBF__ChangeSet *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__Node methods */
-void osmpbf__node__init
- (OSMPBF__Node *message);
-size_t osmpbf__node__get_packed_size
- (const OSMPBF__Node *message);
-size_t osmpbf__node__pack
- (const OSMPBF__Node *message,
- uint8_t *out);
-size_t osmpbf__node__pack_to_buffer
- (const OSMPBF__Node *message,
- ProtobufCBuffer *buffer);
-OSMPBF__Node *
- osmpbf__node__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__node__free_unpacked
- (OSMPBF__Node *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__DenseNodes methods */
-void osmpbf__dense_nodes__init
- (OSMPBF__DenseNodes *message);
-size_t osmpbf__dense_nodes__get_packed_size
- (const OSMPBF__DenseNodes *message);
-size_t osmpbf__dense_nodes__pack
- (const OSMPBF__DenseNodes *message,
- uint8_t *out);
-size_t osmpbf__dense_nodes__pack_to_buffer
- (const OSMPBF__DenseNodes *message,
- ProtobufCBuffer *buffer);
-OSMPBF__DenseNodes *
- osmpbf__dense_nodes__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__dense_nodes__free_unpacked
- (OSMPBF__DenseNodes *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__Way methods */
-void osmpbf__way__init
- (OSMPBF__Way *message);
-size_t osmpbf__way__get_packed_size
- (const OSMPBF__Way *message);
-size_t osmpbf__way__pack
- (const OSMPBF__Way *message,
- uint8_t *out);
-size_t osmpbf__way__pack_to_buffer
- (const OSMPBF__Way *message,
- ProtobufCBuffer *buffer);
-OSMPBF__Way *
- osmpbf__way__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__way__free_unpacked
- (OSMPBF__Way *message,
- ProtobufCAllocator *allocator);
-/* OSMPBF__Relation methods */
-void osmpbf__relation__init
- (OSMPBF__Relation *message);
-size_t osmpbf__relation__get_packed_size
- (const OSMPBF__Relation *message);
-size_t osmpbf__relation__pack
- (const OSMPBF__Relation *message,
- uint8_t *out);
-size_t osmpbf__relation__pack_to_buffer
- (const OSMPBF__Relation *message,
- ProtobufCBuffer *buffer);
-OSMPBF__Relation *
- osmpbf__relation__unpack
- (ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void osmpbf__relation__free_unpacked
- (OSMPBF__Relation *message,
- ProtobufCAllocator *allocator);
-/* --- per-message closures --- */
-
-typedef void (*OSMPBF__HeaderBlock_Closure)
- (const OSMPBF__HeaderBlock *message,
- void *closure_data);
-typedef void (*OSMPBF__HeaderBBox_Closure)
- (const OSMPBF__HeaderBBox *message,
- void *closure_data);
-typedef void (*OSMPBF__PrimitiveBlock_Closure)
- (const OSMPBF__PrimitiveBlock *message,
- void *closure_data);
-typedef void (*OSMPBF__PrimitiveGroup_Closure)
- (const OSMPBF__PrimitiveGroup *message,
- void *closure_data);
-typedef void (*OSMPBF__StringTable_Closure)
- (const OSMPBF__StringTable *message,
- void *closure_data);
-typedef void (*OSMPBF__Info_Closure)
- (const OSMPBF__Info *message,
- void *closure_data);
-typedef void (*OSMPBF__DenseInfo_Closure)
- (const OSMPBF__DenseInfo *message,
- void *closure_data);
-typedef void (*OSMPBF__ChangeSet_Closure)
- (const OSMPBF__ChangeSet *message,
- void *closure_data);
-typedef void (*OSMPBF__Node_Closure)
- (const OSMPBF__Node *message,
- void *closure_data);
-typedef void (*OSMPBF__DenseNodes_Closure)
- (const OSMPBF__DenseNodes *message,
- void *closure_data);
-typedef void (*OSMPBF__Way_Closure)
- (const OSMPBF__Way *message,
- void *closure_data);
-typedef void (*OSMPBF__Relation_Closure)
- (const OSMPBF__Relation *message,
- void *closure_data);
-
-/* --- services --- */
-
-
-/* --- descriptors --- */
-
-extern const ProtobufCMessageDescriptor osmpbf__header_block__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__header_bbox__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__primitive_block__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__primitive_group__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__string_table__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__info__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__dense_info__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__change_set__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__node__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__dense_nodes__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__way__descriptor;
-extern const ProtobufCMessageDescriptor osmpbf__relation__descriptor;
-extern const ProtobufCEnumDescriptor osmpbf__relation__member_type__descriptor;
-
-PROTOBUF_C_END_DECLS
-
-
-#endif /* PROTOBUF_osmformat_2eproto__INCLUDED */
diff --git a/navit/maptool/google/protobuf-c/protobuf-c-private.h b/navit/maptool/google/protobuf-c/protobuf-c-private.h
deleted file mode 100644
index 01bbd35aa..000000000
--- a/navit/maptool/google/protobuf-c/protobuf-c-private.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* --- protobuf-c-private.h: private structures and functions --- */
-/*
- * Copyright 2008, Dave Benson.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with
- * the License. You may obtain a copy of the License
- * at http://www.apache.org/licenses/LICENSE-2.0 Unless
- * required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-/* === needs to be declared for the PROTOBUF_C_BUFFER_SIMPLE_INIT macro === */
-
-void protobuf_c_buffer_simple_append (ProtobufCBuffer *buffer,
- size_t len,
- const unsigned char *data);
-
-/* === stuff which needs to be declared for use in the generated code === */
-
-struct _ProtobufCEnumValueIndex
-{
- const char *name;
- unsigned index; /* into values[] array */
-};
-
-/* IntRange: helper structure for optimizing
- int => index lookups
- in the case where the keys are mostly consecutive values,
- as they presumably are for enums and fields.
-
- The data structures assumes that the values in the original
- array are sorted */
-struct _ProtobufCIntRange
-{
- int start_value;
- unsigned orig_index;
- /* NOTE: the number of values in the range can
- be inferred by looking at the next element's orig_index.
- a dummy element is added to make this simple */
-};
-
-
-/* === declared for exposition on ProtobufCIntRange === */
-/* note: ranges must have an extra sentinel IntRange at the end whose
- orig_index is set to the number of actual values in the original array */
-/* returns -1 if no orig_index found */
-int protobuf_c_int_ranges_lookup (unsigned n_ranges,
- ProtobufCIntRange *ranges);
-
-#define PROTOBUF_C_SERVICE_DESCRIPTOR_MAGIC 0x14159bc3
-#define PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC 0x28aaeef9
-#define PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC 0x114315af
-
-/* === behind the scenes on the generated service's __init functions */
-typedef void (*ProtobufCServiceDestroy) (ProtobufCService *service);
-void
-protobuf_c_service_generated_init (ProtobufCService *service,
- const ProtobufCServiceDescriptor *descriptor,
- ProtobufCServiceDestroy destroy);
-
-void
-protobuf_c_service_invoke_internal(ProtobufCService *service,
- unsigned method_index,
- const ProtobufCMessage *input,
- ProtobufCClosure closure,
- void *closure_data);
diff --git a/navit/maptool/google/protobuf-c/protobuf-c.c b/navit/maptool/google/protobuf-c/protobuf-c.c
deleted file mode 100644
index 7cb727bf9..000000000
--- a/navit/maptool/google/protobuf-c/protobuf-c.c
+++ /dev/null
@@ -1,2603 +0,0 @@
-/* --- protobuf-c.c: public protobuf c runtime implementation --- */
-
-/*
- * Copyright 2008, Dave Benson.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with
- * the License. You may obtain a copy of the License
- * at http://www.apache.org/licenses/LICENSE-2.0 Unless
- * required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* TODO items:
-
- * 64-BIT OPTIMIZATION: certain implementations use 32-bit math even on 64-bit platforms
- (uint64_size, uint64_pack, parse_uint64)
-
- * get_packed_size and pack seem to use type-prefixed names,
- whereas parse uses type-suffixed names. pick one and stick with it.
- Decision: go with type-suffixed, since the type (or its instance)
- is typically the object of the verb.
- NOTE: perhaps the "parse" methods should be reanemd to "unpack"
- at the same time. (this only affects internal (static) functions)
-
- * use TRUE and FALSE instead of 1 and 0 as appropriate
-
- * use size_t consistently
- */
-
-#include <stdio.h> /* for occasional printf()s */
-#include <stdlib.h> /* for abort(), malloc() etc */
-#include <string.h> /* for strlen(), memcpy(), memmove() */
-
-#ifndef PRINT_UNPACK_ERRORS
-#define PRINT_UNPACK_ERRORS 1
-#endif
-
-#include "protobuf-c.h"
-
-#define MAX_UINT64_ENCODED_SIZE 10
-
-/* convenience macros */
-#define TMPALLOC(allocator, size) ((allocator)->tmp_alloc ((allocator)->allocator_data, (size)))
-#define FREE(allocator, ptr) \
- do { if ((ptr) != NULL) ((allocator)->free ((allocator)->allocator_data, (ptr))); } while(0)
-#define UNALIGNED_ALLOC(allocator, size) ALLOC (allocator, size) /* placeholder */
-#define STRUCT_MEMBER_P(struct_p, struct_offset) \
- ((void *) ((uint8_t*) (struct_p) + (struct_offset)))
-#define STRUCT_MEMBER(member_type, struct_p, struct_offset) \
- (*(member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset)))
-#define STRUCT_MEMBER_PTR(member_type, struct_p, struct_offset) \
- ((member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset)))
-#define TRUE 1
-#define FALSE 0
-
-static void
-alloc_failed_warning (unsigned size, const char *filename, unsigned line)
-{
- fprintf (stderr,
- "WARNING: out-of-memory allocating a block of size %u (%s:%u)\n",
- size, filename, line);
-}
-
-/* Try to allocate memory, running some special code if it fails. */
-#define DO_ALLOC(dst, allocator, size, fail_code) \
-{ size_t da__allocation_size = (size); \
- if (da__allocation_size == 0) \
- dst = NULL; \
- else if ((dst=((allocator)->alloc ((allocator)->allocator_data, \
- da__allocation_size))) == NULL) \
- { \
- alloc_failed_warning (da__allocation_size, __FILE__, __LINE__); \
- fail_code; \
- } \
-}
-#define DO_UNALIGNED_ALLOC DO_ALLOC /* placeholder */
-
-
-
-#define ASSERT_IS_ENUM_DESCRIPTOR(desc) \
- assert((desc)->magic == PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC)
-#define ASSERT_IS_MESSAGE_DESCRIPTOR(desc) \
- assert((desc)->magic == PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC)
-#define ASSERT_IS_MESSAGE(message) \
- ASSERT_IS_MESSAGE_DESCRIPTOR((message)->descriptor)
-#define ASSERT_IS_SERVICE_DESCRIPTOR(desc) \
- assert((desc)->magic == PROTOBUF_C_SERVICE_DESCRIPTOR_MAGIC)
-
-/* --- allocator --- */
-
-static void protobuf_c_out_of_memory_default (void)
-{
- fprintf (stderr, "Out Of Memory!!!\n");
- abort ();
-}
-void (*protobuf_c_out_of_memory) (void) = protobuf_c_out_of_memory_default;
-
-static void *system_alloc(void *allocator_data, size_t size)
-{
- void *rv;
- (void) allocator_data;
- if (size == 0)
- return NULL;
- rv = malloc (size);
- if (rv == NULL)
- protobuf_c_out_of_memory ();
- return rv;
-}
-
-static void system_free (void *allocator_data, void *data)
-{
- (void) allocator_data;
- if (data)
- free (data);
-}
-
-/* Some users may configure the default allocator;
- providing your own allocator to unpack() is prefered.
- this allocator is still used for packing nested messages. */
-ProtobufCAllocator protobuf_c_default_allocator =
-{
- system_alloc,
- system_free,
- NULL,
- 8192,
- NULL
-};
-
-/* Users should NOT modify this structure,
- but it's difficult to prevent.
-
- please modify protobuf_c_default_allocator instead. */
-ProtobufCAllocator protobuf_c_system_allocator =
-{
- system_alloc,
- system_free,
- NULL,
- 8192,
- NULL
-};
-
-/* === buffer-simple === */
-void
-protobuf_c_buffer_simple_append (ProtobufCBuffer *buffer,
- size_t len,
- const uint8_t *data)
-{
- ProtobufCBufferSimple *simp = (ProtobufCBufferSimple *) buffer;
- size_t new_len = simp->len + len;
- if (new_len > simp->alloced)
- {
- size_t new_alloced = simp->alloced * 2;
- uint8_t *new_data;
- while (new_alloced < new_len)
- new_alloced += new_alloced;
- DO_ALLOC (new_data, &protobuf_c_default_allocator, new_alloced, return);
- memcpy (new_data, simp->data, simp->len);
- if (simp->must_free_data)
- FREE (&protobuf_c_default_allocator, simp->data);
- else
- simp->must_free_data = 1;
- simp->data = new_data;
- simp->alloced = new_alloced;
- }
- memcpy (simp->data + simp->len, data, len);
- simp->len = new_len;
-}
-
-/* === get_packed_size() === */
-
-/* Return the number of bytes required to store the
- tag for the field (which includes 3 bits for
- the wire-type, and a single bit that denotes the end-of-tag. */
-static inline size_t
-get_tag_size (unsigned number)
-{
- if (number < (1<<4))
- return 1;
- else if (number < (1<<11))
- return 2;
- else if (number < (1<<18))
- return 3;
- else if (number < (1<<25))
- return 4;
- else
- return 5;
-}
-
-/* Return the number of bytes required to store
- a variable-length unsigned integer that fits in 32-bit uint
- in base-128 encoding. */
-static inline size_t
-uint32_size (uint32_t v)
-{
- if (v < (1<<7))
- return 1;
- else if (v < (1<<14))
- return 2;
- else if (v < (1<<21))
- return 3;
- else if (v < (1<<28))
- return 4;
- else
- return 5;
-}
-/* Return the number of bytes required to store
- a variable-length signed integer that fits in 32-bit int
- in base-128 encoding. */
-static inline size_t
-int32_size (int32_t v)
-{
- if (v < 0)
- return 10;
- else if (v < (1<<7))
- return 1;
- else if (v < (1<<14))
- return 2;
- else if (v < (1<<21))
- return 3;
- else if (v < (1<<28))
- return 4;
- else
- return 5;
-}
-/* return the zigzag-encoded 32-bit unsigned int from a 32-bit signed int */
-static inline uint32_t
-zigzag32 (int32_t v)
-{
- if (v < 0)
- return ((uint32_t)(-v)) * 2 - 1;
- else
- return v * 2;
-}
-/* Return the number of bytes required to store
- a variable-length signed integer that fits in 32-bit int,
- converted to unsigned via the zig-zag algorithm,
- then packed using base-128 encoding. */
-static inline size_t
-sint32_size (int32_t v)
-{
- return uint32_size(zigzag32(v));
-}
-
-/* Return the number of bytes required to store
- a variable-length unsigned integer that fits in 64-bit uint
- in base-128 encoding. */
-static inline size_t
-uint64_size (uint64_t v)
-{
- uint32_t upper_v = (v>>32);
- if (upper_v == 0)
- return uint32_size ((uint32_t)v);
- else if (upper_v < (1<<3))
- return 5;
- else if (upper_v < (1<<10))
- return 6;
- else if (upper_v < (1<<17))
- return 7;
- else if (upper_v < (1<<24))
- return 8;
- else if (upper_v < (1U<<31))
- return 9;
- else
- return 10;
-}
-
-/* return the zigzag-encoded 64-bit unsigned int from a 64-bit signed int */
-static inline uint64_t
-zigzag64 (int64_t v)
-{
- if (v < 0)
- return ((uint64_t)(-v)) * 2 - 1;
- else
- return v * 2;
-}
-
-/* Return the number of bytes required to store
- a variable-length signed integer that fits in 64-bit int,
- converted to unsigned via the zig-zag algorithm,
- then packed using base-128 encoding. */
-static inline size_t
-sint64_size (int64_t v)
-{
- return uint64_size(zigzag64(v));
-}
-
-/* Get serialized size of a single field in the message,
- including the space needed by the identifying tag. */
-static size_t
-required_field_get_packed_size (const ProtobufCFieldDescriptor *field,
- const void *member)
-{
- size_t rv = get_tag_size (field->id);
- switch (field->type)
- {
- case PROTOBUF_C_TYPE_SINT32:
- return rv + sint32_size (*(const int32_t *) member);
- case PROTOBUF_C_TYPE_INT32:
- return rv + int32_size (*(const uint32_t *) member);
- case PROTOBUF_C_TYPE_UINT32:
- return rv + uint32_size (*(const uint32_t *) member);
- case PROTOBUF_C_TYPE_SINT64:
- return rv + sint64_size (*(const int64_t *) member);
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- return rv + uint64_size (*(const uint64_t *) member);
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- return rv + 4;
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- return rv + 8;
- case PROTOBUF_C_TYPE_BOOL:
- return rv + 1;
- case PROTOBUF_C_TYPE_FLOAT:
- return rv + 4;
- case PROTOBUF_C_TYPE_DOUBLE:
- return rv + 8;
- case PROTOBUF_C_TYPE_ENUM:
- // TODO: is this correct for negative-valued enums?
- return rv + uint32_size (*(const uint32_t *) member);
- case PROTOBUF_C_TYPE_STRING:
- {
- const char *str = *(char * const *) member;
- size_t len = str ? strlen (str) : 0;
- return rv + uint32_size (len) + len;
- }
- case PROTOBUF_C_TYPE_BYTES:
- {
- size_t len = ((const ProtobufCBinaryData*) member)->len;
- return rv + uint32_size (len) + len;
- }
- //case PROTOBUF_C_TYPE_GROUP:
- case PROTOBUF_C_TYPE_MESSAGE:
- {
- const ProtobufCMessage *msg = * (ProtobufCMessage * const *) member;
- size_t subrv = msg ? protobuf_c_message_get_packed_size (msg) : 0;
- return rv + uint32_size (subrv) + subrv;
- }
- }
- PROTOBUF_C_ASSERT_NOT_REACHED ();
- return 0;
-}
-
-/* Get serialized size of a single optional field in the message,
- including the space needed by the identifying tag.
- Returns 0 if the optional field isn't set. */
-static size_t
-optional_field_get_packed_size (const ProtobufCFieldDescriptor *field,
- const protobuf_c_boolean *has,
- const void *member)
-{
- if (field->type == PROTOBUF_C_TYPE_MESSAGE
- || field->type == PROTOBUF_C_TYPE_STRING)
- {
- const void *ptr = * (const void * const *) member;
- if (ptr == NULL
- || ptr == field->default_value)
- return 0;
- }
- else
- {
- if (!*has)
- return 0;
- }
- return required_field_get_packed_size (field, member);
-}
-
-/* Get serialized size of a repeated field in the message,
- which may consist of any number of values (including 0).
- Includes the space needed by the identifying tags (as needed). */
-static size_t
-repeated_field_get_packed_size (const ProtobufCFieldDescriptor *field,
- size_t count,
- const void *member)
-{
- size_t header_size;
- size_t rv = 0;
- unsigned i;
- void *array = * (void * const *) member;
- if (count == 0)
- return 0;
- header_size = get_tag_size (field->id);
- if (!field->packed)
- header_size *= count;
- switch (field->type)
- {
- case PROTOBUF_C_TYPE_SINT32:
- for (i = 0; i < count; i++)
- rv += sint32_size (((int32_t*)array)[i]);
- break;
- case PROTOBUF_C_TYPE_INT32:
- for (i = 0; i < count; i++)
- rv += int32_size (((uint32_t*)array)[i]);
- break;
- case PROTOBUF_C_TYPE_UINT32:
- case PROTOBUF_C_TYPE_ENUM:
- for (i = 0; i < count; i++)
- rv += uint32_size (((uint32_t*)array)[i]);
- break;
- case PROTOBUF_C_TYPE_SINT64:
- for (i = 0; i < count; i++)
- rv += sint64_size (((int64_t*)array)[i]);
- break;
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- for (i = 0; i < count; i++)
- rv += uint64_size (((uint64_t*)array)[i]);
- break;
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- rv += 4 * count;
- break;
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- rv += 8 * count;
- break;
- case PROTOBUF_C_TYPE_BOOL:
- rv += count;
- break;
- case PROTOBUF_C_TYPE_STRING:
- for (i = 0; i < count; i++)
- {
- size_t len = strlen (((char**) array)[i]);
- rv += uint32_size (len) + len;
- }
- break;
-
- case PROTOBUF_C_TYPE_BYTES:
- for (i = 0; i < count; i++)
- {
- size_t len = ((ProtobufCBinaryData*) array)[i].len;
- rv += uint32_size (len) + len;
- }
- break;
- case PROTOBUF_C_TYPE_MESSAGE:
- for (i = 0; i < count; i++)
- {
- size_t len = protobuf_c_message_get_packed_size (((ProtobufCMessage **) array)[i]);
- rv += uint32_size (len) + len;
- }
- break;
- //case PROTOBUF_C_TYPE_GROUP: // NOT SUPPORTED
- }
- if (field->packed)
- header_size += uint32_size (rv);
- return header_size + rv;
-}
-
-/* Get the packed size of a unknown field (meaning one that
- is passed through mostly uninterpreted... this is done
- for forward compatibilty with the addition of new fields). */
-static inline size_t
-unknown_field_get_packed_size (const ProtobufCMessageUnknownField *field)
-{
- return get_tag_size (field->tag) + field->len;
-}
-
-/* Get the number of bytes that the message will occupy once serialized. */
-size_t
-protobuf_c_message_get_packed_size(const ProtobufCMessage *message)
-{
- unsigned i;
- size_t rv = 0;
- ASSERT_IS_MESSAGE (message);
- for (i = 0; i < message->descriptor->n_fields; i++)
- {
- const ProtobufCFieldDescriptor *field = message->descriptor->fields + i;
- const void *member = ((const char *) message) + field->offset;
- const void *qmember = ((const char *) message) + field->quantifier_offset;
-
- if (field->label == PROTOBUF_C_LABEL_REQUIRED)
- rv += required_field_get_packed_size (field, member);
- else if (field->label == PROTOBUF_C_LABEL_OPTIONAL)
- rv += optional_field_get_packed_size (field, qmember, member);
- else
- rv += repeated_field_get_packed_size (field, * (const size_t *) qmember, member);
- }
- for (i = 0; i < message->n_unknown_fields; i++)
- rv += unknown_field_get_packed_size (&message->unknown_fields[i]);
- return rv;
-}
-/* === pack() === */
-/* Pack an unsigned 32-bit integer in base-128 encoding, and return the number of bytes needed:
- this will be 5 or less. */
-static inline size_t
-uint32_pack (uint32_t value, uint8_t *out)
-{
- unsigned rv = 0;
- if (value >= 0x80)
- {
- out[rv++] = value | 0x80;
- value >>= 7;
- if (value >= 0x80)
- {
- out[rv++] = value | 0x80;
- value >>= 7;
- if (value >= 0x80)
- {
- out[rv++] = value | 0x80;
- value >>= 7;
- if (value >= 0x80)
- {
- out[rv++] = value | 0x80;
- value >>= 7;
- }
- }
- }
- }
- /* assert: value<128 */
- out[rv++] = value;
- return rv;
-}
-
-/* Pack a 32-bit signed integer, returning the number of bytes needed.
- Negative numbers are packed as twos-complement 64-bit integers. */
-static inline size_t
-int32_pack (int32_t value, uint8_t *out)
-{
- if (value < 0)
- {
- out[0] = value | 0x80;
- out[1] = (value>>7) | 0x80;
- out[2] = (value>>14) | 0x80;
- out[3] = (value>>21) | 0x80;
- out[4] = (value>>28) | 0x80;
- out[5] = out[6] = out[7] = out[8] = 0xff;
- out[9] = 0x01;
- return 10;
- }
- else
- return uint32_pack (value, out);
-}
-
-/* Pack a 32-bit integer in zigwag encoding. */
-static inline size_t
-sint32_pack (int32_t value, uint8_t *out)
-{
- return uint32_pack (zigzag32 (value), out);
-}
-
-/* Pack a 64-bit unsigned integer that fits in a 64-bit uint,
- using base-128 encoding. */
-static size_t
-uint64_pack (uint64_t value, uint8_t *out)
-{
- uint32_t hi = value>>32;
- uint32_t lo = value;
- unsigned rv;
- if (hi == 0)
- return uint32_pack ((uint32_t)lo, out);
- out[0] = (lo) | 0x80;
- out[1] = (lo>>7) | 0x80;
- out[2] = (lo>>14) | 0x80;
- out[3] = (lo>>21) | 0x80;
- if (hi < 8)
- {
- out[4] = (hi<<4) | (lo>>28);
- return 5;
- }
- else
- {
- out[4] = ((hi&7)<<4) | (lo>>28) | 0x80;
- hi >>= 3;
- }
- rv = 5;
- while (hi >= 128)
- {
- out[rv++] = hi | 0x80;
- hi >>= 7;
- }
- out[rv++] = hi;
- return rv;
-}
-
-/* Pack a 64-bit signed integer in zigzan encoding,
- return the size of the packed output.
- (Max returned value is 10) */
-static inline size_t
-sint64_pack (int64_t value, uint8_t *out)
-{
- return uint64_pack (zigzag64 (value), out);
-}
-
-/* Pack a 32-bit value, little-endian.
- Used for fixed32, sfixed32, float) */
-static inline size_t
-fixed32_pack (uint32_t value, uint8_t *out)
-{
-#ifdef IS_LITTLE_ENDIAN
- memcpy (out, &value, 4);
-#else
- out[0] = value;
- out[1] = value>>8;
- out[2] = value>>16;
- out[3] = value>>24;
-#endif
- return 4;
-}
-
-/* Pack a 64-bit fixed-length value.
- (Used for fixed64, sfixed64, double) */
-/* XXX: the big-endian impl is really only good for 32-bit machines,
- a 64-bit version would be appreciated, plus a way
- to decide to use 64-bit math where convenient. */
-static inline size_t
-fixed64_pack (uint64_t value, uint8_t *out)
-{
-#ifdef IS_LITTLE_ENDIAN
- memcpy (out, &value, 8);
-#else
- fixed32_pack (value, out);
- fixed32_pack (value>>32, out+4);
-#endif
- return 8;
-}
-
-
-/* Pack a boolean as 0 or 1, even though the protobuf_c_boolean
- can really assume any integer value. */
-/* XXX: perhaps on some platforms "*out = !!value" would be
- a better impl, b/c that is idiotmatic c++ in some stl impls. */
-static inline size_t
-boolean_pack (protobuf_c_boolean value, uint8_t *out)
-{
- *out = value ? 1 : 0;
- return 1;
-}
-
-/* Pack a length-prefixed string.
- The input string is NUL-terminated.
-
- The NULL pointer is treated as an empty string.
- This isn't really necessary, but it allows people
- to leave required strings blank.
- (See Issue 13 in the bug tracker for a
- little more explanation).
- */
-static inline size_t
-string_pack (const char * str, uint8_t *out)
-{
- if (str == NULL)
- {
- out[0] = 0;
- return 1;
- }
- else
- {
- size_t len = strlen (str);
- size_t rv = uint32_pack (len, out);
- memcpy (out + rv, str, len);
- return rv + len;
- }
-}
-
-static inline size_t
-binary_data_pack (const ProtobufCBinaryData *bd, uint8_t *out)
-{
- size_t len = bd->len;
- size_t rv = uint32_pack (len, out);
- memcpy (out + rv, bd->data, len);
- return rv + len;
-}
-
-static inline size_t
-prefixed_message_pack (const ProtobufCMessage *message, uint8_t *out)
-{
- if (message == NULL)
- {
- out[0] = 0;
- return 1;
- }
- else
- {
- size_t rv = protobuf_c_message_pack (message, out + 1);
- uint32_t rv_packed_size = uint32_size (rv);
- if (rv_packed_size != 1)
- memmove (out + rv_packed_size, out + 1, rv);
- return uint32_pack (rv, out) + rv;
- }
-}
-
-/* wire-type will be added in required_field_pack() */
-/* XXX: just call uint64_pack on 64-bit platforms. */
-static size_t
-tag_pack (uint32_t id, uint8_t *out)
-{
- if (id < (1<<(32-3)))
- return uint32_pack (id<<3, out);
- else
- return uint64_pack (((uint64_t)id) << 3, out);
-}
-
-static size_t
-required_field_pack (const ProtobufCFieldDescriptor *field,
- const void *member,
- uint8_t *out)
-{
- size_t rv = tag_pack (field->id, out);
- switch (field->type)
- {
- case PROTOBUF_C_TYPE_SINT32:
- out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- return rv + sint32_pack (*(const int32_t *) member, out + rv);
- case PROTOBUF_C_TYPE_INT32:
- out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- return rv + int32_pack (*(const uint32_t *) member, out + rv);
- case PROTOBUF_C_TYPE_UINT32:
- case PROTOBUF_C_TYPE_ENUM:
- out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- return rv + uint32_pack (*(const uint32_t *) member, out + rv);
- case PROTOBUF_C_TYPE_SINT64:
- out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- return rv + sint64_pack (*(const int64_t *) member, out + rv);
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- return rv + uint64_pack (*(const uint64_t *) member, out + rv);
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- out[0] |= PROTOBUF_C_WIRE_TYPE_32BIT;
- return rv + fixed32_pack (*(const uint32_t *) member, out + rv);
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- out[0] |= PROTOBUF_C_WIRE_TYPE_64BIT;
- return rv + fixed64_pack (*(const uint64_t *) member, out + rv);
- case PROTOBUF_C_TYPE_BOOL:
- out[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- return rv + boolean_pack (*(const protobuf_c_boolean *) member, out + rv);
- case PROTOBUF_C_TYPE_STRING:
- {
- out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
- return rv + string_pack (*(char * const *) member, out + rv);
- }
-
- case PROTOBUF_C_TYPE_BYTES:
- {
- const ProtobufCBinaryData * bd = ((const ProtobufCBinaryData*) member);
- out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
- return rv + binary_data_pack (bd, out + rv);
- }
- //case PROTOBUF_C_TYPE_GROUP: // NOT SUPPORTED
- case PROTOBUF_C_TYPE_MESSAGE:
- {
- out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
- return rv + prefixed_message_pack (*(ProtobufCMessage * const *) member,
- out + rv);
- }
- }
- PROTOBUF_C_ASSERT_NOT_REACHED ();
- return 0;
-}
-static size_t
-optional_field_pack (const ProtobufCFieldDescriptor *field,
- const protobuf_c_boolean *has,
- const void *member,
- uint8_t *out)
-{
- if (field->type == PROTOBUF_C_TYPE_MESSAGE
- || field->type == PROTOBUF_C_TYPE_STRING)
- {
- const void *ptr = * (const void * const *) member;
- if (ptr == NULL
- || ptr == field->default_value)
- return 0;
- }
- else
- {
- if (!*has)
- return 0;
- }
- return required_field_pack (field, member, out);
-}
-
-/* TODO: implement as a table lookup */
-static inline size_t
-sizeof_elt_in_repeated_array (ProtobufCType type)
-{
- switch (type)
- {
- case PROTOBUF_C_TYPE_SINT32:
- case PROTOBUF_C_TYPE_INT32:
- case PROTOBUF_C_TYPE_UINT32:
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- case PROTOBUF_C_TYPE_ENUM:
- return 4;
- case PROTOBUF_C_TYPE_SINT64:
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- return 8;
- case PROTOBUF_C_TYPE_BOOL:
- return sizeof (protobuf_c_boolean);
- case PROTOBUF_C_TYPE_STRING:
- case PROTOBUF_C_TYPE_MESSAGE:
- return sizeof (void *);
- case PROTOBUF_C_TYPE_BYTES:
- return sizeof (ProtobufCBinaryData);
- }
- PROTOBUF_C_ASSERT_NOT_REACHED ();
- return 0;
-}
-
-static void
-copy_to_little_endian_32 (void *out, const void *in, unsigned N)
-{
-#ifdef IS_LITTLE_ENDIAN
- memcpy (out, in, N * 4);
-#else
- unsigned i;
- const uint32_t *ini = in;
- for (i = 0; i < N; i++)
- fixed32_pack (ini[i], (uint8_t*)out + 4*i);
-#endif
-}
-static void
-copy_to_little_endian_64 (void *out, const void *in, unsigned N)
-{
-#ifdef IS_LITTLE_ENDIAN
- memcpy (out, in, N * 8);
-#else
- unsigned i;
- const uint64_t *ini = in;
- for (i = 0; i < N; i++)
- fixed64_pack (ini[i], (uint8_t*)out + 8*i);
-#endif
-}
-
-static unsigned
-get_type_min_size (ProtobufCType type)
-{
- if (type == PROTOBUF_C_TYPE_SFIXED32
- || type == PROTOBUF_C_TYPE_FIXED32
- || type == PROTOBUF_C_TYPE_FLOAT)
- return 4;
- if (type == PROTOBUF_C_TYPE_SFIXED64
- || type == PROTOBUF_C_TYPE_FIXED64
- || type == PROTOBUF_C_TYPE_DOUBLE)
- return 8;
- return 1;
-}
-
-static size_t
-repeated_field_pack (const ProtobufCFieldDescriptor *field,
- size_t count,
- const void *member,
- uint8_t *out)
-{
- char *array = * (char * const *) member;
- unsigned i;
- if (field->packed)
- {
- unsigned header_len;
- unsigned len_start;
- unsigned min_length;
- unsigned payload_len;
- unsigned length_size_min;
- unsigned actual_length_size;
- uint8_t *payload_at;
- if (count == 0)
- return 0;
- header_len = tag_pack (field->id, out);
- out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
- len_start = header_len;
- min_length = get_type_min_size (field->type) * count;
- length_size_min = uint32_size (min_length);
- header_len += length_size_min;
- payload_at = out + header_len;
- switch (field->type)
- {
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- copy_to_little_endian_32 (payload_at, array, count);
- payload_at += count * 4;
- break;
-
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- copy_to_little_endian_64 (payload_at, array, count);
- payload_at += count * 8;
- break;
-
- case PROTOBUF_C_TYPE_INT32:
- {
- const int32_t *arr = (const int32_t *) array;
- for (i = 0; i < count; i++)
- payload_at += int32_pack (arr[i], payload_at);
- }
- break;
-
- case PROTOBUF_C_TYPE_SINT32:
- {
- const int32_t *arr = (const int32_t *) array;
- for (i = 0; i < count; i++)
- payload_at += sint32_pack (arr[i], payload_at);
- }
- break;
-
- case PROTOBUF_C_TYPE_SINT64:
- {
- const int64_t *arr = (const int64_t *) array;
- for (i = 0; i < count; i++)
- payload_at += sint64_pack (arr[i], payload_at);
- }
- break;
- case PROTOBUF_C_TYPE_ENUM:
- case PROTOBUF_C_TYPE_UINT32:
- {
- const uint32_t *arr = (const uint32_t *) array;
- for (i = 0; i < count; i++)
- payload_at += uint32_pack (arr[i], payload_at);
- }
- break;
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- {
- const uint64_t *arr = (const uint64_t *) array;
- for (i = 0; i < count; i++)
- payload_at += uint64_pack (arr[i], payload_at);
- }
- break;
- case PROTOBUF_C_TYPE_BOOL:
- {
- const protobuf_c_boolean *arr = (const protobuf_c_boolean *) array;
- for (i = 0; i < count; i++)
- payload_at += boolean_pack (arr[i], payload_at);
- }
- break;
-
- default:
- assert (0);
- }
- payload_len = payload_at - (out + header_len);
- actual_length_size = uint32_size (payload_len);
- if (length_size_min != actual_length_size)
- {
- assert (actual_length_size == length_size_min + 1);
- memmove (out + header_len + 1, out + header_len, payload_len);
- header_len++;
- }
- uint32_pack (payload_len, out + len_start);
- return header_len + payload_len;
- }
- else
- {
- /* CONSIDER: optimize this case a bit (by putting the loop inside the switch) */
- size_t rv = 0;
- unsigned siz = sizeof_elt_in_repeated_array (field->type);
- for (i = 0; i < count; i++)
- {
- rv += required_field_pack (field, array, out + rv);
- array += siz;
- }
- return rv;
- }
-}
-static size_t
-unknown_field_pack (const ProtobufCMessageUnknownField *field,
- uint8_t *out)
-{
- size_t rv = tag_pack (field->tag, out);
- out[0] |= field->wire_type;
- memcpy (out + rv, field->data, field->len);
- return rv + field->len;
-}
-
-size_t
-protobuf_c_message_pack (const ProtobufCMessage *message,
- uint8_t *out)
-{
- unsigned i;
- size_t rv = 0;
- ASSERT_IS_MESSAGE (message);
- for (i = 0; i < message->descriptor->n_fields; i++)
- {
- const ProtobufCFieldDescriptor *field = message->descriptor->fields + i;
- const void *member = ((const char *) message) + field->offset;
-
- /* it doesn't hurt to compute qmember (a pointer to the quantifier
- field of the structure), but the pointer is only valid if
- the field is one of:
- - a repeated field
- - an optional field that isn't a pointer type
- (meaning: not a message or a string) */
- const void *qmember = ((const char *) message) + field->quantifier_offset;
-
- if (field->label == PROTOBUF_C_LABEL_REQUIRED)
- rv += required_field_pack (field, member, out + rv);
- else if (field->label == PROTOBUF_C_LABEL_OPTIONAL)
- /* note that qmember is bogus for strings and messages,
- but it isn't used */
- rv += optional_field_pack (field, qmember, member, out + rv);
- else
- rv += repeated_field_pack (field, * (const size_t *) qmember, member, out + rv);
- }
- for (i = 0; i < message->n_unknown_fields; i++)
- rv += unknown_field_pack (&message->unknown_fields[i], out + rv);
- return rv;
-}
-
-/* === pack_to_buffer() === */
-static size_t
-required_field_pack_to_buffer (const ProtobufCFieldDescriptor *field,
- const void *member,
- ProtobufCBuffer *buffer)
-{
- size_t rv;
- uint8_t scratch[MAX_UINT64_ENCODED_SIZE * 2];
- rv = tag_pack (field->id, scratch);
- switch (field->type)
- {
- case PROTOBUF_C_TYPE_SINT32:
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- rv += sint32_pack (*(const int32_t *) member, scratch + rv);
- buffer->append (buffer, rv, scratch);
- break;
- case PROTOBUF_C_TYPE_INT32:
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- rv += int32_pack (*(const uint32_t *) member, scratch + rv);
- buffer->append (buffer, rv, scratch);
- break;
- case PROTOBUF_C_TYPE_UINT32:
- case PROTOBUF_C_TYPE_ENUM:
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- rv += uint32_pack (*(const uint32_t *) member, scratch + rv);
- buffer->append (buffer, rv, scratch);
- break;
- case PROTOBUF_C_TYPE_SINT64:
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- rv += sint64_pack (*(const int64_t *) member, scratch + rv);
- buffer->append (buffer, rv, scratch);
- break;
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- rv += uint64_pack (*(const uint64_t *) member, scratch + rv);
- buffer->append (buffer, rv, scratch);
- break;
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_32BIT;
- rv += fixed32_pack (*(const uint32_t *) member, scratch + rv);
- buffer->append (buffer, rv, scratch);
- break;
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_64BIT;
- rv += fixed64_pack (*(const uint64_t *) member, scratch + rv);
- buffer->append (buffer, rv, scratch);
- break;
- case PROTOBUF_C_TYPE_BOOL:
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_VARINT;
- rv += boolean_pack (*(const protobuf_c_boolean *) member, scratch + rv);
- buffer->append (buffer, rv, scratch);
- break;
- case PROTOBUF_C_TYPE_STRING:
- {
- const char *str = *(char * const *) member;
- size_t sublen = str ? strlen (str) : 0;
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
- rv += uint32_pack (sublen, scratch + rv);
- buffer->append (buffer, rv, scratch);
- buffer->append (buffer, sublen, (const uint8_t *) str);
- rv += sublen;
- break;
- }
-
- case PROTOBUF_C_TYPE_BYTES:
- {
- const ProtobufCBinaryData * bd = ((const ProtobufCBinaryData*) member);
- size_t sublen = bd->len;
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
- rv += uint32_pack (sublen, scratch + rv);
- buffer->append (buffer, rv, scratch);
- buffer->append (buffer, sublen, bd->data);
- rv += sublen;
- break;
- }
- //PROTOBUF_C_TYPE_GROUP, // NOT SUPPORTED
- case PROTOBUF_C_TYPE_MESSAGE:
- {
- uint8_t simple_buffer_scratch[256];
- size_t sublen;
- ProtobufCBufferSimple simple_buffer
- = PROTOBUF_C_BUFFER_SIMPLE_INIT (simple_buffer_scratch);
- const ProtobufCMessage *msg = *(ProtobufCMessage * const *) member;
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
- if (msg == NULL)
- sublen = 0;
- else
- sublen = protobuf_c_message_pack_to_buffer (msg, &simple_buffer.base);
- rv += uint32_pack (sublen, scratch + rv);
- buffer->append (buffer, rv, scratch);
- buffer->append (buffer, sublen, simple_buffer.data);
- rv += sublen;
- PROTOBUF_C_BUFFER_SIMPLE_CLEAR (&simple_buffer);
- break;
- }
- default:
- PROTOBUF_C_ASSERT_NOT_REACHED ();
- }
- return rv;
-}
-static size_t
-optional_field_pack_to_buffer (const ProtobufCFieldDescriptor *field,
- const protobuf_c_boolean *has,
- const void *member,
- ProtobufCBuffer *buffer)
-{
- if (field->type == PROTOBUF_C_TYPE_MESSAGE
- || field->type == PROTOBUF_C_TYPE_STRING)
- {
- const void *ptr = * (const void * const *) member;
- if (ptr == NULL
- || ptr == field->default_value)
- return 0;
- }
- else
- {
- if (!*has)
- return 0;
- }
- return required_field_pack_to_buffer (field, member, buffer);
-}
-
-static size_t
-get_packed_payload_length (const ProtobufCFieldDescriptor *field,
- unsigned count,
- const void *array)
-{
- unsigned rv = 0;
- unsigned i;
- switch (field->type)
- {
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- return count * 4;
-
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- return count * 8;
-
- case PROTOBUF_C_TYPE_INT32:
- {
- const int32_t *arr = (const int32_t *) array;
- for (i = 0; i < count; i++)
- rv += int32_size (arr[i]);
- }
- break;
-
- case PROTOBUF_C_TYPE_SINT32:
- {
- const int32_t *arr = (const int32_t *) array;
- for (i = 0; i < count; i++)
- rv += sint32_size (arr[i]);
- }
- break;
- case PROTOBUF_C_TYPE_ENUM:
- case PROTOBUF_C_TYPE_UINT32:
- {
- const uint32_t *arr = (const uint32_t *) array;
- for (i = 0; i < count; i++)
- rv += uint32_size (arr[i]);
- }
- break;
-
- case PROTOBUF_C_TYPE_SINT64:
- {
- const int64_t *arr = (const int64_t *) array;
- for (i = 0; i < count; i++)
- rv += sint64_size (arr[i]);
- }
- break;
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- {
- const uint64_t *arr = (const uint64_t *) array;
- for (i = 0; i < count; i++)
- rv += uint64_size (arr[i]);
- }
- break;
- case PROTOBUF_C_TYPE_BOOL:
- return count;
- default:
- assert (0);
- }
- return rv;
-}
-static size_t
-pack_buffer_packed_payload (const ProtobufCFieldDescriptor *field,
- unsigned count,
- const void *array,
- ProtobufCBuffer *buffer)
-{
- uint8_t scratch[16];
- size_t rv = 0;
- unsigned i;
- switch (field->type)
- {
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
-#ifdef IS_LITTLE_ENDIAN
- rv = count * 4;
- goto no_packing_needed;
-#else
- for (i = 0; i < count; i++)
- {
- unsigned len = fixed32_pack (((uint32_t*)array)[i], scratch);
- buffer->append (buffer, len, scratch);
- rv += len;
- }
-#endif
- break;
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
-#ifdef IS_LITTLE_ENDIAN
- rv = count * 8;
- goto no_packing_needed;
-#else
- for (i = 0; i < count; i++)
- {
- unsigned len = fixed64_pack (((uint64_t*)array)[i], scratch);
- buffer->append (buffer, len, scratch);
- rv += len;
- }
- break;
-#endif
- case PROTOBUF_C_TYPE_INT32:
- for (i = 0; i < count; i++)
- {
- unsigned len = int32_pack (((int32_t*)array)[i], scratch);
- buffer->append (buffer, len, scratch);
- rv += len;
- }
- break;
-
- case PROTOBUF_C_TYPE_SINT32:
- for (i = 0; i < count; i++)
- {
- unsigned len = sint32_pack (((int32_t*)array)[i], scratch);
- buffer->append (buffer, len, scratch);
- rv += len;
- }
- break;
- case PROTOBUF_C_TYPE_ENUM:
- case PROTOBUF_C_TYPE_UINT32:
- for (i = 0; i < count; i++)
- {
- unsigned len = uint32_pack (((uint32_t*)array)[i], scratch);
- buffer->append (buffer, len, scratch);
- rv += len;
- }
- break;
-
- case PROTOBUF_C_TYPE_SINT64:
- for (i = 0; i < count; i++)
- {
- unsigned len = sint64_pack (((int64_t*)array)[i], scratch);
- buffer->append (buffer, len, scratch);
- rv += len;
- }
- break;
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- for (i = 0; i < count; i++)
- {
- unsigned len = uint64_pack (((uint64_t*)array)[i], scratch);
- buffer->append (buffer, len, scratch);
- rv += len;
- }
- break;
- case PROTOBUF_C_TYPE_BOOL:
- for (i = 0; i < count; i++)
- {
- unsigned len = boolean_pack (((protobuf_c_boolean*)array)[i], scratch);
- buffer->append (buffer, len, scratch);
- rv += len;
- }
- return count;
- default:
- assert(0);
- }
- return rv;
-
-#ifdef IS_LITTLE_ENDIAN
-no_packing_needed:
- buffer->append (buffer, rv, array);
- return rv;
-#endif
-}
-
-static size_t
-repeated_field_pack_to_buffer (const ProtobufCFieldDescriptor *field,
- unsigned count,
- const void *member,
- ProtobufCBuffer *buffer)
-{
- char *array = * (char * const *) member;
- if (count == 0)
- return 0;
- if (field->packed)
- {
- uint8_t scratch[MAX_UINT64_ENCODED_SIZE * 2];
- size_t rv = tag_pack (field->id, scratch);
- size_t payload_len = get_packed_payload_length (field, count, array);
- size_t tmp;
- scratch[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
- rv += uint32_pack (payload_len, scratch + rv);
- buffer->append (buffer, rv, scratch);
- tmp = pack_buffer_packed_payload (field, count, array, buffer);
- if (tmp != payload_len){
- fprintf (stderr, "Unexpected payload length: %zu (expected: %zu). Aborting.\n", tmp, payload_len);
- abort ();
- }
- return rv + payload_len;
- }
- else
- {
- size_t siz;
- unsigned i;
- /* CONSIDER: optimize this case a bit (by putting the loop inside the switch) */
- unsigned rv = 0;
- siz = sizeof_elt_in_repeated_array (field->type);
- for (i = 0; i < count; i++)
- {
- rv += required_field_pack_to_buffer (field, array, buffer);
- array += siz;
- }
- return rv;
- }
-}
-
-static size_t
-unknown_field_pack_to_buffer (const ProtobufCMessageUnknownField *field,
- ProtobufCBuffer *buffer)
-{
- uint8_t header[MAX_UINT64_ENCODED_SIZE];
- size_t rv = tag_pack (field->tag, header);
- header[0] |= field->wire_type;
- buffer->append (buffer, rv, header);
- buffer->append (buffer, field->len, field->data);
- return rv + field->len;
-}
-
-size_t
-protobuf_c_message_pack_to_buffer (const ProtobufCMessage *message,
- ProtobufCBuffer *buffer)
-{
- unsigned i;
- size_t rv = 0;
- ASSERT_IS_MESSAGE (message);
- for (i = 0; i < message->descriptor->n_fields; i++)
- {
- const ProtobufCFieldDescriptor *field = message->descriptor->fields + i;
- const void *member = ((const char *) message) + field->offset;
- const void *qmember = ((const char *) message) + field->quantifier_offset;
-
- if (field->label == PROTOBUF_C_LABEL_REQUIRED)
- rv += required_field_pack_to_buffer (field, member, buffer);
- else if (field->label == PROTOBUF_C_LABEL_OPTIONAL)
- rv += optional_field_pack_to_buffer (field, qmember, member, buffer);
- else
- rv += repeated_field_pack_to_buffer (field, * (const size_t *) qmember, member, buffer);
- }
- for (i = 0; i < message->n_unknown_fields; i++)
- rv += unknown_field_pack_to_buffer (&message->unknown_fields[i], buffer);
-
- return rv;
-}
-
-/* === unpacking === */
-#if PRINT_UNPACK_ERRORS
-# define UNPACK_ERROR(args) do { printf args;printf("\n"); }while(0)
-#else
-# define UNPACK_ERROR(args) do { } while (0)
-#endif
-
-static inline int
-int_range_lookup (unsigned n_ranges,
- const ProtobufCIntRange *ranges,
- int value)
-{
- unsigned start, n;
- if (n_ranges == 0)
- return -1;
- start = 0;
- n = n_ranges;
- while (n > 1)
- {
- unsigned mid = start + n / 2;
- if (value < ranges[mid].start_value)
- {
- n = mid - start;
- }
- else if (value >= ranges[mid].start_value + (int)(ranges[mid+1].orig_index-ranges[mid].orig_index))
- {
- unsigned new_start = mid + 1;
- n = start + n - new_start;
- start = new_start;
- }
- else
- return (value - ranges[mid].start_value) + ranges[mid].orig_index;
- }
- if (n > 0)
- {
- unsigned start_orig_index = ranges[start].orig_index;
- unsigned range_size = ranges[start+1].orig_index - start_orig_index;
-
- if (ranges[start].start_value <= value
- && value < (int)(ranges[start].start_value + range_size))
- return (value - ranges[start].start_value) + start_orig_index;
- }
- return -1;
-}
-
-static size_t
-parse_tag_and_wiretype (size_t len,
- const uint8_t *data,
- uint32_t *tag_out,
- ProtobufCWireType *wiretype_out)
-{
- unsigned max_rv = len > 5 ? 5 : len;
- uint32_t tag = (data[0]&0x7f) >> 3;
- unsigned shift = 4;
- unsigned rv;
- *wiretype_out = data[0] & 7;
- if ((data[0] & 0x80) == 0)
- {
- *tag_out = tag;
- return 1;
- }
- for (rv = 1; rv < max_rv; rv++)
- if (data[rv] & 0x80)
- {
- tag |= (data[rv] & 0x7f) << shift;
- shift += 7;
- }
- else
- {
- tag |= data[rv] << shift;
- *tag_out = tag;
- return rv + 1;
- }
- return 0; /* error: bad header */
-}
-
-/* sizeof(ScannedMember) must be <= (1<<BOUND_SIZEOF_SCANNED_MEMBER_LOG2) */
-#define BOUND_SIZEOF_SCANNED_MEMBER_LOG2 5
-typedef struct _ScannedMember ScannedMember;
-struct _ScannedMember
-{
- uint32_t tag;
- uint8_t wire_type;
- uint8_t length_prefix_len;
- const ProtobufCFieldDescriptor *field;
- size_t len;
- const uint8_t *data;
-};
-
-static inline uint32_t
-scan_length_prefixed_data (size_t len, const uint8_t *data, size_t *prefix_len_out)
-{
- unsigned hdr_max = len < 5 ? len : 5;
- unsigned hdr_len;
- uint32_t val = 0;
- unsigned i;
- unsigned shift = 0;
- for (i = 0; i < hdr_max; i++)
- {
- val |= (data[i] & 0x7f) << shift;
- shift += 7;
- if ((data[i] & 0x80) == 0)
- break;
- }
- if (i == hdr_max)
- {
- UNPACK_ERROR (("error parsing length for length-prefixed data"));
- return 0;
- }
- hdr_len = i + 1;
- *prefix_len_out = hdr_len;
- if (hdr_len + val > len)
- {
- UNPACK_ERROR (("data too short after length-prefix of %u",
- val));
- return 0;
- }
- return hdr_len + val;
-}
-
-static size_t
-max_b128_numbers (size_t len, const uint8_t *data)
-{
- size_t rv = 0;
- while (len--)
- if ((*data++ & 0x80) == 0)
- ++rv;
- return rv;
-}
-
-
-/* Given a raw slab of packed-repeated values,
- determine the number of elements.
- This function detects certain kinds of errors
- but not others; the remaining error checking is done by
- parse_packed_repeated_member() */
-static protobuf_c_boolean
-count_packed_elements (ProtobufCType type,
- size_t len,
- const uint8_t *data,
- size_t *count_out)
-{
- switch (type)
- {
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- if (len % 4 != 0)
- {
- UNPACK_ERROR (("length must be a multiple of 4 for fixed-length 32-bit types"));
- return FALSE;
- }
- *count_out = len / 4;
- return TRUE;
-
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- if (len % 8 != 0)
- {
- UNPACK_ERROR (("length must be a multiple of 8 for fixed-length 64-bit types"));
- return FALSE;
- }
- *count_out = len / 8;
- return TRUE;
-
- case PROTOBUF_C_TYPE_INT32:
- case PROTOBUF_C_TYPE_SINT32:
- case PROTOBUF_C_TYPE_ENUM:
- case PROTOBUF_C_TYPE_UINT32:
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_SINT64:
- case PROTOBUF_C_TYPE_UINT64:
- *count_out = max_b128_numbers (len, data);
- return TRUE;
- case PROTOBUF_C_TYPE_BOOL:
- *count_out = len;
- return TRUE;
-
- case PROTOBUF_C_TYPE_STRING:
- case PROTOBUF_C_TYPE_BYTES:
- case PROTOBUF_C_TYPE_MESSAGE:
- default:
- UNPACK_ERROR (("bad protobuf-c type %u for packed-repeated", type));
- return FALSE;
- }
-}
-
-static inline uint32_t
-parse_uint32 (unsigned len, const uint8_t *data)
-{
- unsigned rv = data[0] & 0x7f;
- if (len > 1)
- {
- rv |= ((data[1] & 0x7f) << 7);
- if (len > 2)
- {
- rv |= ((data[2] & 0x7f) << 14);
- if (len > 3)
- {
- rv |= ((data[3] & 0x7f) << 21);
- if (len > 4)
- rv |= (data[4] << 28);
- }
- }
- }
- return rv;
-}
-static inline uint32_t
-parse_int32 (unsigned len, const uint8_t *data)
-{
- return parse_uint32 (len, data);
-}
-static inline int32_t
-unzigzag32 (uint32_t v)
-{
- if (v&1)
- return -(v>>1) - 1;
- else
- return v>>1;
-}
-static inline uint32_t
-parse_fixed_uint32 (const uint8_t *data)
-{
-#ifdef IS_LITTLE_ENDIAN
- uint32_t t;
- memcpy (&t, data, 4);
- return t;
-#else
- return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
-#endif
-}
-static uint64_t
-parse_uint64 (unsigned len, const uint8_t *data)
-{
- unsigned shift, i;
- if (len < 5)
- return parse_uint32 (len, data);
- uint64_t rv = ((data[0] & 0x7f))
- | ((data[1] & 0x7f)<<7)
- | ((data[2] & 0x7f)<<14)
- | ((data[3] & 0x7f)<<21);
- shift = 28;
- for (i = 4; i < len; i++)
- {
- rv |= (((uint64_t)(data[i]&0x7f)) << shift);
- shift += 7;
- }
- return rv;
-}
-static inline int64_t
-unzigzag64 (uint64_t v)
-{
- if (v&1)
- return -(v>>1) - 1;
- else
- return v>>1;
-}
-static inline uint64_t
-parse_fixed_uint64 (const uint8_t *data)
-{
-#ifdef IS_LITTLE_ENDIAN
- uint64_t t;
- memcpy (&t, data, 8);
- return t;
-#else
- return (uint64_t)parse_fixed_uint32 (data)
- | (((uint64_t)parse_fixed_uint32(data+4)) << 32);
-#endif
-}
-static protobuf_c_boolean
-parse_boolean (unsigned len, const uint8_t *data)
-{
- unsigned i;
- for (i = 0; i < len; i++)
- if (data[i] & 0x7f)
- return 1;
- return 0;
-}
-static protobuf_c_boolean
-parse_required_member (ScannedMember *scanned_member,
- void *member,
- ProtobufCAllocator *allocator,
- protobuf_c_boolean maybe_clear)
-{
- unsigned len = scanned_member->len;
- const uint8_t *data = scanned_member->data;
- ProtobufCWireType wire_type = scanned_member->wire_type;
- switch (scanned_member->field->type)
- {
- case PROTOBUF_C_TYPE_INT32:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
- return 0;
- *(uint32_t*)member = parse_int32 (len, data);
- return 1;
- case PROTOBUF_C_TYPE_UINT32:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
- return 0;
- *(uint32_t*)member = parse_uint32 (len, data);
- return 1;
- case PROTOBUF_C_TYPE_SINT32:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
- return 0;
- *(int32_t*)member = unzigzag32 (parse_uint32 (len, data));
- return 1;
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_32BIT)
- return 0;
- *(uint32_t*)member = parse_fixed_uint32 (data);
- return 1;
-
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
- return 0;
- *(uint64_t*)member = parse_uint64 (len, data);
- return 1;
- case PROTOBUF_C_TYPE_SINT64:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
- return 0;
- *(int64_t*)member = unzigzag64 (parse_uint64 (len, data));
- return 1;
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_64BIT)
- return 0;
- *(uint64_t*)member = parse_fixed_uint64 (data);
- return 1;
-
- case PROTOBUF_C_TYPE_BOOL:
- *(protobuf_c_boolean*)member = parse_boolean (len, data);
- return 1;
-
- case PROTOBUF_C_TYPE_ENUM:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_VARINT)
- return 0;
- *(uint32_t*)member = parse_uint32 (len, data);
- return 1;
-
- case PROTOBUF_C_TYPE_STRING:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
- return 0;
- {
- char **pstr = member;
- unsigned pref_len = scanned_member->length_prefix_len;
- if (maybe_clear && *pstr != NULL)
- {
- const char *def = scanned_member->field->default_value;
- if (*pstr != NULL && *pstr != def)
- FREE (allocator, *pstr);
- }
- DO_ALLOC (*pstr, allocator, len - pref_len + 1, return 0);
- memcpy (*pstr, data + pref_len, len - pref_len);
- (*pstr)[len-pref_len] = 0;
- return 1;
- }
- case PROTOBUF_C_TYPE_BYTES:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
- return 0;
- {
- ProtobufCBinaryData *bd = member;
- const ProtobufCBinaryData *def_bd;
- unsigned pref_len = scanned_member->length_prefix_len;
- def_bd = scanned_member->field->default_value;
- if (maybe_clear && bd->data != NULL && bd->data != def_bd->data)
- FREE (allocator, bd->data);
- DO_ALLOC (bd->data, allocator, len - pref_len, return 0);
- memcpy (bd->data, data + pref_len, len - pref_len);
- bd->len = len - pref_len;
- return 1;
- }
- //case PROTOBUF_C_TYPE_GROUP, // NOT SUPPORTED
- case PROTOBUF_C_TYPE_MESSAGE:
- if (wire_type != PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
- return 0;
- {
- ProtobufCMessage **pmessage = member;
- ProtobufCMessage *subm;
- const ProtobufCMessage *def_mess;
- unsigned pref_len = scanned_member->length_prefix_len;
- def_mess = scanned_member->field->default_value;
- if (maybe_clear && *pmessage != NULL && *pmessage != def_mess)
- protobuf_c_message_free_unpacked (*pmessage, allocator);
- subm = protobuf_c_message_unpack (scanned_member->field->descriptor,
- allocator,
- len - pref_len, data + pref_len);
- *pmessage = subm; /* since we freed the message we must clear the field, even if NULL */
- if (subm == NULL)
- return 0;
- return 1;
- }
- }
- return 0;
-}
-
-static protobuf_c_boolean
-parse_optional_member (ScannedMember *scanned_member,
- void *member,
- ProtobufCMessage *message,
- ProtobufCAllocator *allocator)
-{
- if (!parse_required_member (scanned_member, member, allocator, TRUE))
- return 0;
- if (scanned_member->field->quantifier_offset != 0)
- STRUCT_MEMBER (protobuf_c_boolean,
- message,
- scanned_member->field->quantifier_offset) = 1;
- return 1;
-}
-
-static protobuf_c_boolean
-parse_repeated_member (ScannedMember *scanned_member,
- void *member,
- ProtobufCMessage *message,
- ProtobufCAllocator *allocator)
-{
- const ProtobufCFieldDescriptor *field = scanned_member->field;
- size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset);
- size_t siz = sizeof_elt_in_repeated_array (field->type);
- char *array = *(char**)member;
- if (!parse_required_member (scanned_member,
- array + siz * (*p_n),
- allocator,
- FALSE))
- return 0;
- *p_n += 1;
- return 1;
-}
-
-static unsigned scan_varint (unsigned len, const uint8_t *data)
-{
- unsigned i;
- if (len > 10)
- len = 10;
- for (i = 0; i < len; i++)
- if ((data[i] & 0x80) == 0)
- break;
- if (i == len)
- return 0;
- return i + 1;
-}
-
-static protobuf_c_boolean
-parse_packed_repeated_member (ScannedMember *scanned_member,
- void *member,
- ProtobufCMessage *message)
-{
- const ProtobufCFieldDescriptor *field = scanned_member->field;
- size_t *p_n = STRUCT_MEMBER_PTR(size_t, message, field->quantifier_offset);
- size_t siz = sizeof_elt_in_repeated_array (field->type);
- char *array = *(char**)member + siz * (*p_n);
- const uint8_t *at = scanned_member->data + scanned_member->length_prefix_len;
- size_t rem = scanned_member->len - scanned_member->length_prefix_len;
- size_t count = 0;
- unsigned i;
- switch (field->type)
- {
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- count = (scanned_member->len - scanned_member->length_prefix_len) / 4;
-#ifdef IS_LITTLE_ENDIAN
- goto no_unpacking_needed;
-#else
- for (i = 0; i < count; i++)
- {
- ((uint32_t*)array)[i] = parse_fixed_uint32 (at);
- at += 4;
- }
-#endif
- break;
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- count = (scanned_member->len - scanned_member->length_prefix_len) / 8;
-#ifdef IS_LITTLE_ENDIAN
- goto no_unpacking_needed;
-#else
- for (i = 0; i < count; i++)
- {
- ((uint64_t*)array)[i] = parse_fixed_uint64 (at);
- at += 8;
- }
- break;
-#endif
- case PROTOBUF_C_TYPE_INT32:
- while (rem > 0)
- {
- unsigned s = scan_varint (rem, at);
- if (s == 0)
- {
- UNPACK_ERROR (("bad packed-repeated int32 value"));
- return FALSE;
- }
- ((int32_t*)array)[count++] = parse_int32 (s, at);
- at += s;
- rem -= s;
- }
- break;
-
- case PROTOBUF_C_TYPE_SINT32:
- while (rem > 0)
- {
- unsigned s = scan_varint (rem, at);
- if (s == 0)
- {
- UNPACK_ERROR (("bad packed-repeated sint32 value"));
- return FALSE;
- }
- ((int32_t*)array)[count++] = unzigzag32 (parse_uint32 (s, at));
- at += s;
- rem -= s;
- }
- break;
- case PROTOBUF_C_TYPE_ENUM:
- case PROTOBUF_C_TYPE_UINT32:
- while (rem > 0)
- {
- unsigned s = scan_varint (rem, at);
- if (s == 0)
- {
- UNPACK_ERROR (("bad packed-repeated enum or uint32 value"));
- return FALSE;
- }
- ((uint32_t*)array)[count++] = parse_uint32 (s, at);
- at += s;
- rem -= s;
- }
- break;
-
- case PROTOBUF_C_TYPE_SINT64:
- while (rem > 0)
- {
- unsigned s = scan_varint (rem, at);
- if (s == 0)
- {
- UNPACK_ERROR (("bad packed-repeated sint64 value"));
- return FALSE;
- }
- ((int64_t*)array)[count++] = unzigzag64 (parse_uint64 (s, at));
- at += s;
- rem -= s;
- }
- break;
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_UINT64:
- while (rem > 0)
- {
- unsigned s = scan_varint (rem, at);
- if (s == 0)
- {
- UNPACK_ERROR (("bad packed-repeated int64/uint64 value"));
- return FALSE;
- }
- ((int64_t*)array)[count++] = parse_uint64 (s, at);
- at += s;
- rem -= s;
- }
- break;
- case PROTOBUF_C_TYPE_BOOL:
- count = rem;
- for (i = 0; i < count; i++)
- {
- if (at[i] > 1)
- {
- UNPACK_ERROR (("bad packed-repeated boolean value"));
- return FALSE;
- }
- ((protobuf_c_boolean*)array)[i] = at[i];
- }
- break;
- default:
- assert(0);
- }
- *p_n += count;
- return TRUE;
-
-#ifdef IS_LITTLE_ENDIAN
-no_unpacking_needed:
- memcpy (array, at, count * siz);
- *p_n += count;
- return TRUE;
-#endif
-}
-
-static protobuf_c_boolean
-parse_member (ScannedMember *scanned_member,
- ProtobufCMessage *message,
- ProtobufCAllocator *allocator)
-{
- const ProtobufCFieldDescriptor *field = scanned_member->field;
- void *member;
- if (field == NULL)
- {
- ProtobufCMessageUnknownField *ufield = message->unknown_fields + (message->n_unknown_fields++);
- ufield->tag = scanned_member->tag;
- ufield->wire_type = scanned_member->wire_type;
- ufield->len = scanned_member->len;
- DO_UNALIGNED_ALLOC (ufield->data, allocator, scanned_member->len, return 0);
- memcpy (ufield->data, scanned_member->data, ufield->len);
- return 1;
- }
- member = (char*)message + field->offset;
- switch (field->label)
- {
- case PROTOBUF_C_LABEL_REQUIRED:
- return parse_required_member (scanned_member, member, allocator, TRUE);
- case PROTOBUF_C_LABEL_OPTIONAL:
- return parse_optional_member (scanned_member, member, message, allocator);
- case PROTOBUF_C_LABEL_REPEATED:
- if (field->packed
- && scanned_member->wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
- return parse_packed_repeated_member (scanned_member, member, message);
- else
- return parse_repeated_member (scanned_member, member, message, allocator);
- }
- PROTOBUF_C_ASSERT_NOT_REACHED ();
- return 0;
-}
-
-
-/* TODO: expose/use this function if desc->message_init==NULL
- (which occurs for old code, and may be useful for certain
- programatic techniques for generating descriptors). */
-static void
-protobuf_c_message_init_generic (const ProtobufCMessageDescriptor *desc,
- ProtobufCMessage *message)
-{
- unsigned i;
- memset (message, 0, desc->sizeof_message);
- message->descriptor = desc;
- for (i = 0; i < desc->n_fields; i++)
- if (desc->fields[i].default_value != NULL
- && desc->fields[i].label != PROTOBUF_C_LABEL_REPEATED)
- {
- void *field = STRUCT_MEMBER_P (message, desc->fields[i].offset);
- const void *dv = desc->fields[i].default_value;
- switch (desc->fields[i].type)
- {
- case PROTOBUF_C_TYPE_INT32:
- case PROTOBUF_C_TYPE_SINT32:
- case PROTOBUF_C_TYPE_SFIXED32:
- case PROTOBUF_C_TYPE_UINT32:
- case PROTOBUF_C_TYPE_FIXED32:
- case PROTOBUF_C_TYPE_FLOAT:
- case PROTOBUF_C_TYPE_ENUM:
- memcpy (field, dv, 4);
- break;
-
- case PROTOBUF_C_TYPE_INT64:
- case PROTOBUF_C_TYPE_SINT64:
- case PROTOBUF_C_TYPE_SFIXED64:
- case PROTOBUF_C_TYPE_UINT64:
- case PROTOBUF_C_TYPE_FIXED64:
- case PROTOBUF_C_TYPE_DOUBLE:
- memcpy (field, dv, 8);
- break;
-
- case PROTOBUF_C_TYPE_BOOL:
- memcpy (field, dv, sizeof (protobuf_c_boolean));
- break;
-
- case PROTOBUF_C_TYPE_BYTES:
- memcpy (field, dv, sizeof (ProtobufCBinaryData));
- break;
-
- case PROTOBUF_C_TYPE_STRING:
- case PROTOBUF_C_TYPE_MESSAGE:
- /* the next line essentially implements a cast from const,
- which is totally unavoidable. */
- *(const void**)field = dv;
- break;
- }
- }
-}
-
-/* ScannedMember slabs (an unpacking implementation detail).
- Before doing real unpacking, we first scan through the
- elements to see how many there are (for repeated fields),
- and which field to use (for non-repeated fields given twice).
-
- * In order to avoid allocations for small messages,
- we keep a stack-allocated slab of ScannedMembers of
- size FIRST_SCANNED_MEMBER_SLAB_SIZE (16).
- After we fill that up, we allocate each slab twice
- as large as the previous one. */
-#define FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2 4
-
-/* The number of slabs, including the stack-allocated ones;
- choose the number so that we would overflow if we needed
- a slab larger than provided. */
-#define MAX_SCANNED_MEMBER_SLAB \
- (sizeof(void*)*8 - 1 \
- - BOUND_SIZEOF_SCANNED_MEMBER_LOG2 \
- - FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2)
-
-ProtobufCMessage *
-protobuf_c_message_unpack (const ProtobufCMessageDescriptor *desc,
- ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data)
-{
- ProtobufCMessage *rv;
- size_t rem = len;
- const uint8_t *at = data;
- const ProtobufCFieldDescriptor *last_field = desc->fields + 0;
- ScannedMember first_member_slab[1<<FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2];
-
- /* scanned_member_slabs[i] is an array of arrays of ScannedMember.
- The first slab (scanned_member_slabs[0] is just a pointer to
- first_member_slab), above. All subsequent slabs will be allocated
- using the allocator. */
- ScannedMember *scanned_member_slabs[MAX_SCANNED_MEMBER_SLAB+1];
- unsigned which_slab = 0; /* the slab we are currently populating */
- unsigned in_slab_index = 0; /* number of members in the slab */
- size_t n_unknown = 0;
- unsigned f;
- unsigned i_slab;
- unsigned last_field_index = 0;
- unsigned long *required_fields_bitmap;
- unsigned required_fields_bitmap_len;
- static const unsigned word_bits = sizeof(long) * 8;
-
- ASSERT_IS_MESSAGE_DESCRIPTOR (desc);
-
- if (allocator == NULL)
- allocator = &protobuf_c_default_allocator;
-
- required_fields_bitmap_len = (desc->n_fields + word_bits - 1) / word_bits;
- required_fields_bitmap = alloca(required_fields_bitmap_len * sizeof(long));
- memset(required_fields_bitmap, 0, required_fields_bitmap_len * sizeof(long));
-
- DO_ALLOC (rv, allocator, desc->sizeof_message, return NULL);
- scanned_member_slabs[0] = first_member_slab;
-
- /* Generated code always defines "message_init".
- However, we provide a fallback for (1) users of old protobuf-c
- generated-code that do not provide the function,
- and (2) descriptors constructed from some other source
- (most likely, direct construction from the .proto file) */
- if (desc->message_init != NULL)
- protobuf_c_message_init (desc, rv);
- else
- protobuf_c_message_init_generic (desc, rv);
-
- while (rem > 0)
- {
- uint32_t tag;
- ProtobufCWireType wire_type;
- size_t used = parse_tag_and_wiretype (rem, at, &tag, &wire_type);
- const ProtobufCFieldDescriptor *field;
- ScannedMember tmp;
- if (used == 0)
- {
- UNPACK_ERROR (("error parsing tag/wiretype at offset %u",
- (unsigned)(at-data)));
- goto error_cleanup_during_scan;
- }
- /* XXX: consider optimizing for field[1].id == tag, if field[1] exists! */
- if (last_field->id != tag)
- {
- /* lookup field */
- int field_index = int_range_lookup (desc->n_field_ranges,
- desc->field_ranges,
- tag);
- if (field_index < 0)
- {
- field = NULL;
- n_unknown++;
- }
- else
- {
- field = desc->fields + field_index;
- last_field = field;
- last_field_index = field_index;
- }
- }
- else
- field = last_field;
-
- if (field != NULL && field->label == PROTOBUF_C_LABEL_REQUIRED)
- required_fields_bitmap[last_field_index / word_bits] |= (1UL << (last_field_index % word_bits));
-
- at += used;
- rem -= used;
- tmp.tag = tag;
- tmp.wire_type = wire_type;
- tmp.field = field;
- tmp.data = at;
- switch (wire_type)
- {
- case PROTOBUF_C_WIRE_TYPE_VARINT:
- {
- unsigned max_len = rem < 10 ? rem : 10;
- unsigned i;
- for (i = 0; i < max_len; i++)
- if ((at[i] & 0x80) == 0)
- break;
- if (i == max_len)
- {
- UNPACK_ERROR (("unterminated varint at offset %u",
- (unsigned)(at-data)));
- goto error_cleanup_during_scan;
- }
- tmp.len = i + 1;
- }
- break;
- case PROTOBUF_C_WIRE_TYPE_64BIT:
- if (rem < 8)
- {
- UNPACK_ERROR (("too short after 64bit wiretype at offset %u",
- (unsigned)(at-data)));
- goto error_cleanup_during_scan;
- }
- tmp.len = 8;
- break;
- case PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED:
- {
- size_t pref_len;
- tmp.len = scan_length_prefixed_data (rem, at, &pref_len);
- if (tmp.len == 0)
- {
- /* NOTE: scan_length_prefixed_data calls UNPACK_ERROR */
- goto error_cleanup_during_scan;
- }
- tmp.length_prefix_len = pref_len;
- break;
- }
- case PROTOBUF_C_WIRE_TYPE_32BIT:
- if (rem < 4)
- {
- UNPACK_ERROR (("too short after 32bit wiretype at offset %u",
- (unsigned)(at-data)));
- goto error_cleanup_during_scan;
- }
- tmp.len = 4;
- break;
- default:
- UNPACK_ERROR (("unsupported tag %u at offset %u",
- wire_type, (unsigned)(at-data)));
- goto error_cleanup_during_scan;
- }
- if (in_slab_index == (1U<<(which_slab+FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2)))
- {
- size_t size;
- in_slab_index = 0;
- if (which_slab == MAX_SCANNED_MEMBER_SLAB)
- {
- UNPACK_ERROR (("too many fields"));
- goto error_cleanup_during_scan;
- }
- which_slab++;
- size = sizeof(ScannedMember) << (which_slab+FIRST_SCANNED_MEMBER_SLAB_SIZE_LOG2);
- /* TODO: consider using alloca() ! */
- if (allocator->tmp_alloc != NULL)
- scanned_member_slabs[which_slab] = TMPALLOC(allocator, size);
- else
- DO_ALLOC (scanned_member_slabs[which_slab], allocator, size, goto error_cleanup_during_scan);
- }
- scanned_member_slabs[which_slab][in_slab_index++] = tmp;
-
- if (field != NULL && field->label == PROTOBUF_C_LABEL_REPEATED)
- {
- size_t *n = STRUCT_MEMBER_PTR (size_t, rv, field->quantifier_offset);
- if (field->packed
- && wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
- {
- size_t count;
- if (!count_packed_elements (field->type,
- tmp.len - tmp.length_prefix_len,
- tmp.data + tmp.length_prefix_len,
- &count))
- {
- UNPACK_ERROR (("counting packed elements"));
- goto error_cleanup_during_scan;
- }
- *n += count;
- }
- else
- *n += 1;
- }
-
- at += tmp.len;
- rem -= tmp.len;
- }
-
- /* allocate space for repeated fields, also check that all required fields have been set */
- for (f = 0; f < desc->n_fields; f++)
- {
- const ProtobufCFieldDescriptor *field = desc->fields + f;
- if (field->label == PROTOBUF_C_LABEL_REPEATED)
- {
- size_t siz = sizeof_elt_in_repeated_array (field->type);
- size_t *n_ptr = STRUCT_MEMBER_PTR (size_t, rv, field->quantifier_offset);
- if (*n_ptr != 0)
- {
- unsigned n = *n_ptr;
- *n_ptr = 0;
- assert(rv->descriptor != NULL);
-#define CLEAR_REMAINING_N_PTRS() \
- for(f++;f < desc->n_fields; f++) \
- { \
- field = desc->fields + f; \
- if (field->label == PROTOBUF_C_LABEL_REPEATED) \
- STRUCT_MEMBER (size_t, rv, field->quantifier_offset) = 0; \
- }
- DO_ALLOC (STRUCT_MEMBER (void *, rv, field->offset),
- allocator, siz * n,
- CLEAR_REMAINING_N_PTRS (); goto error_cleanup);
-#undef CLEAR_REMAINING_N_PTRS
- }
- }
- else if (field->label == PROTOBUF_C_LABEL_REQUIRED)
- {
- if (field->default_value == NULL && 0 == (required_fields_bitmap[f / word_bits] & (1UL << (f % word_bits))))
- {
- UNPACK_ERROR (("message '%s': missing required field '%s'", desc->name, field->name));
- goto error_cleanup;
- }
- }
- }
-
- /* allocate space for unknown fields */
- if (n_unknown)
- {
- DO_ALLOC (rv->unknown_fields,
- allocator, n_unknown * sizeof (ProtobufCMessageUnknownField),
- goto error_cleanup);
- }
-
- /* do real parsing */
- for (i_slab = 0; i_slab <= which_slab; i_slab++)
- {
- unsigned max = (i_slab == which_slab) ? in_slab_index : (1U<<(i_slab+4));
- ScannedMember *slab = scanned_member_slabs[i_slab];
- unsigned j;
- for (j = 0; j < max; j++)
- {
- if (!parse_member (slab + j, rv, allocator))
- {
- UNPACK_ERROR (("error parsing member %s of %s",
- slab->field ? slab->field->name : "*unknown-field*", desc->name));
- goto error_cleanup;
- }
- }
- }
-
- /* cleanup */
- if (allocator->tmp_alloc == NULL)
- {
- unsigned j;
- for (j = 1; j <= which_slab; j++)
- FREE (allocator, scanned_member_slabs[j]);
- }
-
- return rv;
-
-error_cleanup:
- protobuf_c_message_free_unpacked (rv, allocator);
- if (allocator->tmp_alloc == NULL)
- {
- unsigned j;
- for (j = 1; j <= which_slab; j++)
- FREE (allocator, scanned_member_slabs[j]);
- }
- return NULL;
-
-error_cleanup_during_scan:
- FREE (allocator, rv);
- if (allocator->tmp_alloc == NULL)
- {
- unsigned j;
- for (j = 1; j <= which_slab; j++)
- FREE (allocator, scanned_member_slabs[j]);
- }
- return NULL;
-}
-
-/* === free_unpacked === */
-void
-protobuf_c_message_free_unpacked (ProtobufCMessage *message,
- ProtobufCAllocator *allocator)
-{
- const ProtobufCMessageDescriptor *desc = message->descriptor;
- unsigned f;
- ASSERT_IS_MESSAGE (message);
- if (allocator == NULL)
- allocator = &protobuf_c_default_allocator;
- message->descriptor = NULL;
- for (f = 0; f < desc->n_fields; f++)
- {
- if (desc->fields[f].label == PROTOBUF_C_LABEL_REPEATED)
- {
- size_t n = STRUCT_MEMBER (size_t, message, desc->fields[f].quantifier_offset);
- void * arr = STRUCT_MEMBER (void *, message, desc->fields[f].offset);
- if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING)
- {
- unsigned i;
- for (i = 0; i < n; i++)
- FREE (allocator, ((char**)arr)[i]);
- }
- else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES)
- {
- unsigned i;
- for (i = 0; i < n; i++)
- FREE (allocator, ((ProtobufCBinaryData*)arr)[i].data);
- }
- else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE)
- {
- unsigned i;
- for (i = 0; i < n; i++)
- protobuf_c_message_free_unpacked (((ProtobufCMessage**)arr)[i], allocator);
- }
- if (arr != NULL)
- FREE (allocator, arr);
- }
- else if (desc->fields[f].type == PROTOBUF_C_TYPE_STRING)
- {
- char *str = STRUCT_MEMBER (char *, message, desc->fields[f].offset);
- if (str && str != desc->fields[f].default_value)
- FREE (allocator, str);
- }
- else if (desc->fields[f].type == PROTOBUF_C_TYPE_BYTES)
- {
- void *data = STRUCT_MEMBER (ProtobufCBinaryData, message, desc->fields[f].offset).data;
- const ProtobufCBinaryData *default_bd;
- default_bd = desc->fields[f].default_value;
- if (data != NULL
- && (default_bd == NULL || default_bd->data != data))
- FREE (allocator, data);
- }
- else if (desc->fields[f].type == PROTOBUF_C_TYPE_MESSAGE)
- {
- ProtobufCMessage *sm;
- sm = STRUCT_MEMBER (ProtobufCMessage *, message,desc->fields[f].offset);
- if (sm && sm != desc->fields[f].default_value)
- protobuf_c_message_free_unpacked (sm, allocator);
- }
- }
-
- for (f = 0; f < message->n_unknown_fields; f++)
- FREE (allocator, message->unknown_fields[f].data);
- if (message->unknown_fields != NULL)
- FREE (allocator, message->unknown_fields);
-
- FREE (allocator, message);
-}
-
-/* === services === */
-typedef void (*GenericHandler)(void *service,
- const ProtobufCMessage *input,
- ProtobufCClosure closure,
- void *closure_data);
-void
-protobuf_c_service_invoke_internal(ProtobufCService *service,
- unsigned method_index,
- const ProtobufCMessage *input,
- ProtobufCClosure closure,
- void *closure_data)
-{
- GenericHandler *handlers;
- GenericHandler handler;
-
- /* Verify that method_index is within range.
- If this fails, you are likely invoking a newly added
- method on an old service. (Although other memory corruption
- bugs can cause this assertion too) */
- PROTOBUF_C_ASSERT (method_index < service->descriptor->n_methods);
-
- /* Get the array of virtual methods (which are enumerated by
- the generated code) */
- handlers = (GenericHandler *) (service + 1);
-
- /* get our method and invoke it */
- /* TODO: seems like handler==NULL is a situation that
- needs handling */
- handler = handlers[method_index];
- (*handler) (service, input, closure, closure_data);
-}
-
-void
-protobuf_c_service_generated_init (ProtobufCService *service,
- const ProtobufCServiceDescriptor *descriptor,
- ProtobufCServiceDestroy destroy)
-{
- ASSERT_IS_SERVICE_DESCRIPTOR(descriptor);
- service->descriptor = descriptor;
- service->destroy = destroy;
- service->invoke = protobuf_c_service_invoke_internal;
- memset (service + 1, 0, descriptor->n_methods * sizeof (GenericHandler));
-}
-
-void protobuf_c_service_destroy (ProtobufCService *service)
-{
- service->destroy (service);
-}
-
-/* --- querying the descriptors --- */
-const ProtobufCEnumValue *
-protobuf_c_enum_descriptor_get_value_by_name
- (const ProtobufCEnumDescriptor *desc,
- const char *name)
-{
- unsigned start = 0, count = desc->n_value_names;
- while (count > 1)
- {
- unsigned mid = start + count / 2;
- int rv = strcmp (desc->values_by_name[mid].name, name);
- if (rv == 0)
- return desc->values + desc->values_by_name[mid].index;
- else if (rv < 0)
- {
- count = start + count - (mid + 1);
- start = mid + 1;
- }
- else
- count = mid - start;
- }
- if (count == 0)
- return NULL;
- if (strcmp (desc->values_by_name[start].name, name) == 0)
- return desc->values + desc->values_by_name[start].index;
- return NULL;
-}
-const ProtobufCEnumValue *
-protobuf_c_enum_descriptor_get_value
- (const ProtobufCEnumDescriptor *desc,
- int value)
-{
- int rv = int_range_lookup (desc->n_value_ranges, desc->value_ranges, value);
- if (rv < 0)
- return NULL;
- return desc->values + rv;
-}
-
-const ProtobufCFieldDescriptor *
-protobuf_c_message_descriptor_get_field_by_name
- (const ProtobufCMessageDescriptor *desc,
- const char *name)
-{
- unsigned start = 0, count = desc->n_fields;
- const ProtobufCFieldDescriptor *field;
- while (count > 1)
- {
- unsigned mid = start + count / 2;
- int rv;
- field = desc->fields + desc->fields_sorted_by_name[mid];
- rv = strcmp (field->name, name);
- if (rv == 0)
- return field;
- else if (rv < 0)
- {
- count = start + count - (mid + 1);
- start = mid + 1;
- }
- else
- count = mid - start;
- }
- if (count == 0)
- return NULL;
- field = desc->fields + desc->fields_sorted_by_name[start];
- if (strcmp (field->name, name) == 0)
- return field;
- return NULL;
-}
-
-const ProtobufCFieldDescriptor *
-protobuf_c_message_descriptor_get_field
- (const ProtobufCMessageDescriptor *desc,
- unsigned value)
-{
- int rv = int_range_lookup (desc->n_field_ranges,
- desc->field_ranges,
- value);
- if (rv < 0)
- return NULL;
- return desc->fields + rv;
-}
-
-const ProtobufCMethodDescriptor *
-protobuf_c_service_descriptor_get_method_by_name
- (const ProtobufCServiceDescriptor *desc,
- const char *name)
-{
- unsigned start = 0, count = desc->n_methods;
- while (count > 1)
- {
- unsigned mid = start + count / 2;
- unsigned mid_index = desc->method_indices_by_name[mid];
- const char *mid_name = desc->methods[mid_index].name;
- int rv = strcmp (mid_name, name);
- if (rv == 0)
- return desc->methods + desc->method_indices_by_name[mid];
- if (rv < 0)
- {
- count = start + count - (mid + 1);
- start = mid + 1;
- }
- else
- {
- count = mid - start;
- }
- }
- if (count == 0)
- return NULL;
- if (strcmp (desc->methods[desc->method_indices_by_name[start]].name, name) == 0)
- return desc->methods + desc->method_indices_by_name[start];
- return NULL;
-}
diff --git a/navit/maptool/google/protobuf-c/protobuf-c.h b/navit/maptool/google/protobuf-c/protobuf-c.h
deleted file mode 100644
index 98bd77b2a..000000000
--- a/navit/maptool/google/protobuf-c/protobuf-c.h
+++ /dev/null
@@ -1,444 +0,0 @@
-/* --- protobuf-c.h: public protobuf c runtime api --- */
-
-/*
- * Copyright 2008, Dave Benson.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with
- * the License. You may obtain a copy of the License
- * at http://www.apache.org/licenses/LICENSE-2.0 Unless
- * required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on
- * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef __PROTOBUF_C_RUNTIME_H_
-#define __PROTOBUF_C_RUNTIME_H_
-
-#include <stddef.h>
-#include <assert.h>
-
-#ifdef __cplusplus
-# define PROTOBUF_C_BEGIN_DECLS extern "C" {
-# define PROTOBUF_C_END_DECLS }
-#else
-# define PROTOBUF_C_BEGIN_DECLS
-# define PROTOBUF_C_END_DECLS
-#endif
-
-#if !defined(PROTOBUF_C_NO_DEPRECATED) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-#define PROTOBUF_C_DEPRECATED __attribute__((__deprecated__))
-#else
-#define PROTOBUF_C_DEPRECATED
-#endif
-
-/* Define int32_t, int64_t, uint32_t, uint64_t, uint8_t.
-
- Usually, just include <inttypes.h> to do the work.
- XXX: should we use stdint.h?
- */
-#ifndef PROTOBUF_C_SKIP_INTTYPES_H
-# if defined(_MSC_VER)
- /* On windows, in ms visual studio, define the types ourselves */
-# define int32_t signed __int32
-# define uint32_t unsigned __int32
-# define int64_t signed __int64
-# define uint64_t unsigned __int64
-# define uint8_t unsigned char
-# else
- /* Use the system inttypes.h */
-# include <inttypes.h>
-# endif
-#endif
-
-PROTOBUF_C_BEGIN_DECLS
-
-typedef enum
-{
- PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_LABEL_OPTIONAL,
- PROTOBUF_C_LABEL_REPEATED
-} ProtobufCLabel;
-
-typedef enum
-{
- PROTOBUF_C_TYPE_INT32,
- PROTOBUF_C_TYPE_SINT32,
- PROTOBUF_C_TYPE_SFIXED32,
- PROTOBUF_C_TYPE_INT64,
- PROTOBUF_C_TYPE_SINT64,
- PROTOBUF_C_TYPE_SFIXED64,
- PROTOBUF_C_TYPE_UINT32,
- PROTOBUF_C_TYPE_FIXED32,
- PROTOBUF_C_TYPE_UINT64,
- PROTOBUF_C_TYPE_FIXED64,
- PROTOBUF_C_TYPE_FLOAT,
- PROTOBUF_C_TYPE_DOUBLE,
- PROTOBUF_C_TYPE_BOOL,
- PROTOBUF_C_TYPE_ENUM,
- PROTOBUF_C_TYPE_STRING,
- PROTOBUF_C_TYPE_BYTES,
- //PROTOBUF_C_TYPE_GROUP, // NOT SUPPORTED
- PROTOBUF_C_TYPE_MESSAGE,
-} ProtobufCType;
-
-typedef int protobuf_c_boolean;
-#define PROTOBUF_C_OFFSETOF(struct, member) offsetof(struct, member)
-
-#define PROTOBUF_C_ASSERT(condition) assert(condition)
-#define PROTOBUF_C_ASSERT_NOT_REACHED() assert(0)
-
-typedef struct _ProtobufCBinaryData ProtobufCBinaryData;
-struct _ProtobufCBinaryData
-{
- size_t len;
- uint8_t *data;
-};
-
-typedef struct _ProtobufCIntRange ProtobufCIntRange; /* private */
-
-/* --- memory management --- */
-typedef struct _ProtobufCAllocator ProtobufCAllocator;
-struct _ProtobufCAllocator
-{
- void *(*alloc)(void *allocator_data, size_t size);
- void (*free)(void *allocator_data, void *pointer);
- void *(*tmp_alloc)(void *allocator_data, size_t size);
- unsigned max_alloca;
- void *allocator_data;
-};
-
-/* This is a configurable allocator.
- * By default, it uses the system allocator (meaning malloc() and free()).
- * This is typically changed to adapt to frameworks that provide
- * some nonstandard allocation functions.
- *
- * NOTE: you may modify this allocator.
- */
-extern ProtobufCAllocator protobuf_c_default_allocator; /* settable */
-
-/* This is the system allocator, meaning it uses malloc() and free().
- *
- * NOTE: please do NOT modify this allocator.
- */
-extern ProtobufCAllocator protobuf_c_system_allocator; /* use malloc, free etc */
-
-/* This is the function that our default allocators call when they
- run out-of-memory. The default behavior of this function is to
- terminate your program. */
-extern void (*protobuf_c_out_of_memory) (void);
-
-/* --- append-only data buffer --- */
-typedef struct _ProtobufCBuffer ProtobufCBuffer;
-struct _ProtobufCBuffer
-{
- void (*append)(ProtobufCBuffer *buffer,
- size_t len,
- const uint8_t *data);
-};
-/* --- enums --- */
-typedef struct _ProtobufCEnumValue ProtobufCEnumValue;
-typedef struct _ProtobufCEnumValueIndex ProtobufCEnumValueIndex;
-typedef struct _ProtobufCEnumDescriptor ProtobufCEnumDescriptor;
-
-/* ProtobufCEnumValue: this represents a single value of
- * an enumeration.
- * 'name' is the string identifying this value, as given in the .proto file.
- * 'c_name' is the full name of the C enumeration value.
- * 'value' is the number assigned to this value, as given in the .proto file.
- */
-struct _ProtobufCEnumValue
-{
- const char *name;
- const char *c_name;
- int value;
-};
-
-/* ProtobufCEnumDescriptor: the represents the enum as a whole,
- * with all its values.
- * 'magic' is a code we check to ensure that the api is used correctly.
- * 'name' is the qualified name (e.g. "namespace.Type").
- * 'short_name' is the unqualified name ("Type"), as given in the .proto file.
- * 'package_name' is the '.'-separated namespace
- * 'n_values' is the number of distinct values.
- * 'values' is the array of distinct values.
- * 'n_value_names' number of named values (including aliases).
- * 'value_names' are the named values (including aliases).
- *
- * The rest of the values are private essentially.
- *
- * see also: Use protobuf_c_enum_descriptor_get_value_by_name()
- * and protobuf_c_enum_descriptor_get_value() to efficiently
- * lookup values in the descriptor.
- */
-struct _ProtobufCEnumDescriptor
-{
- uint32_t magic;
-
- const char *name;
- const char *short_name;
- const char *c_name;
- const char *package_name;
-
- /* sorted by value */
- unsigned n_values;
- const ProtobufCEnumValue *values;
-
- /* sorted by name */
- unsigned n_value_names;
- const ProtobufCEnumValueIndex *values_by_name;
-
- /* value-ranges, for faster lookups by number */
- unsigned n_value_ranges;
- const ProtobufCIntRange *value_ranges;
-
- void *reserved1;
- void *reserved2;
- void *reserved3;
- void *reserved4;
-};
-
-/* --- messages --- */
-typedef struct _ProtobufCMessageDescriptor ProtobufCMessageDescriptor;
-typedef struct _ProtobufCFieldDescriptor ProtobufCFieldDescriptor;
-typedef struct _ProtobufCMessage ProtobufCMessage;
-typedef void (*ProtobufCMessageInit)(ProtobufCMessage *);
-/* ProtobufCFieldDescriptor: description of a single field
- * in a message.
- * 'name' is the name of the field, as given in the .proto file.
- * 'id' is the code representing the field, as given in the .proto file.
- * 'label' is one of PROTOBUF_C_LABEL_{REQUIRED,OPTIONAL,REPEATED}
- * 'type' is the type of field.
- * 'quantifier_offset' is the offset in bytes into the message's C structure
- * for this member's "has_MEMBER" field (for optional members) or
- * "n_MEMBER" field (for repeated members).
- * 'offset' is the offset in bytes into the message's C structure
- * for the member itself.
- * 'descriptor' is a pointer to a ProtobufC{Enum,Message}Descriptor
- * if type is PROTOBUF_C_TYPE_{ENUM,MESSAGE} respectively,
- * otherwise NULL.
- * 'default_value' is a pointer to a default value for this field,
- * where allowed.
- */
-struct _ProtobufCFieldDescriptor
-{
- const char *name;
- uint32_t id;
- ProtobufCLabel label;
- ProtobufCType type;
- unsigned quantifier_offset;
- unsigned offset;
- const void *descriptor; /* for MESSAGE and ENUM types */
- const void *default_value; /* or NULL if no default-value */
- protobuf_c_boolean packed;
-
- unsigned reserved_flags;
- void *reserved2;
- void *reserved3;
-};
-/* ProtobufCMessageDescriptor: description of a message.
- *
- * 'magic' is a code we check to ensure that the api is used correctly.
- * 'name' is the qualified name (e.g. "namespace.Type").
- * 'short_name' is the unqualified name ("Type"), as given in the .proto file.
- * 'c_name' is the c-formatted name of the structure
- * 'package_name' is the '.'-separated namespace
- * 'sizeof_message' is the size in bytes of the C structure
- * representing an instance of this type of message.
- * 'n_fields' is the number of known fields in this message.
- * 'fields' is the fields sorted by id number.
- * 'fields_sorted_by_name', 'n_field_ranges' and 'field_ranges'
- * are used for looking up fields by name and id. (private)
- */
-struct _ProtobufCMessageDescriptor
-{
- uint32_t magic;
-
- const char *name;
- const char *short_name;
- const char *c_name;
- const char *package_name;
-
- size_t sizeof_message;
-
- /* sorted by field-id */
- unsigned n_fields;
- const ProtobufCFieldDescriptor *fields;
- const unsigned *fields_sorted_by_name;
-
- /* ranges, optimization for looking up fields */
- unsigned n_field_ranges;
- const ProtobufCIntRange *field_ranges;
-
- ProtobufCMessageInit message_init;
- void *reserved1;
- void *reserved2;
- void *reserved3;
-};
-
-
-/* ProtobufCMessage: an instance of a message.
- *
- * ProtobufCMessage is sort-of a lightweight
- * base-class for all messages.
- *
- * In particular, ProtobufCMessage doesn't have
- * any allocation policy associated with it.
- * That's because it is common to create ProtobufCMessage's
- * on the stack. In fact, we that's what we recommend
- * for sending messages (because if you just allocate from the
- * stack, then you can't really have a memory leak).
- *
- * This means that functions like protobuf_c_message_unpack()
- * which return a ProtobufCMessage must be paired
- * with a free function, like protobuf_c_message_free_unpacked().
- *
- * 'descriptor' gives the locations and types of the members of message
- * 'n_unknown_fields' is the number of fields we didn't recognize.
- * 'unknown_fields' are fields we didn't recognize.
- */
-typedef struct _ProtobufCMessageUnknownField ProtobufCMessageUnknownField;
-struct _ProtobufCMessage
-{
- const ProtobufCMessageDescriptor *descriptor;
- unsigned n_unknown_fields;
- ProtobufCMessageUnknownField *unknown_fields;
-};
-#define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL }
-
-/* To pack a message: you have two options:
- (1) you can compute the size of the message
- using protobuf_c_message_get_packed_size()
- then pass protobuf_c_message_pack() a buffer of
- that length.
- (2) Provide a virtual buffer (a ProtobufCBuffer) to
- accept data as we scan through it.
- */
-size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message);
-size_t protobuf_c_message_pack (const ProtobufCMessage *message,
- uint8_t *out);
-size_t protobuf_c_message_pack_to_buffer (const ProtobufCMessage *message,
- ProtobufCBuffer *buffer);
-
-ProtobufCMessage *
- protobuf_c_message_unpack (const ProtobufCMessageDescriptor *,
- ProtobufCAllocator *allocator,
- size_t len,
- const uint8_t *data);
-void protobuf_c_message_free_unpacked (ProtobufCMessage *message,
- ProtobufCAllocator *allocator);
-
-/* WARNING: 'message' must be a block of memory
- of size descriptor->sizeof_message. */
-#define protobuf_c_message_init(descriptor, message) ((descriptor)->message_init((ProtobufCMessage*) (message)))
-
-/* --- services --- */
-typedef struct _ProtobufCMethodDescriptor ProtobufCMethodDescriptor;
-typedef struct _ProtobufCServiceDescriptor ProtobufCServiceDescriptor;
-
-struct _ProtobufCMethodDescriptor
-{
- const char *name;
- const ProtobufCMessageDescriptor *input;
- const ProtobufCMessageDescriptor *output;
-};
-struct _ProtobufCServiceDescriptor
-{
- uint32_t magic;
-
- const char *name;
- const char *short_name;
- const char *c_name;
- const char *package;
- unsigned n_methods;
- const ProtobufCMethodDescriptor *methods; /* in order from .proto file */
- const unsigned *method_indices_by_name;
-};
-
-typedef struct _ProtobufCService ProtobufCService;
-typedef void (*ProtobufCClosure)(const ProtobufCMessage *message,
- void *closure_data);
-struct _ProtobufCService
-{
- const ProtobufCServiceDescriptor *descriptor;
- void (*invoke)(ProtobufCService *service,
- unsigned method_index,
- const ProtobufCMessage *input,
- ProtobufCClosure closure,
- void *closure_data);
- void (*destroy) (ProtobufCService *service);
-};
-
-
-void protobuf_c_service_destroy (ProtobufCService *);
-
-
-/* --- querying the descriptors --- */
-const ProtobufCEnumValue *
-protobuf_c_enum_descriptor_get_value_by_name
- (const ProtobufCEnumDescriptor *desc,
- const char *name);
-const ProtobufCEnumValue *
-protobuf_c_enum_descriptor_get_value
- (const ProtobufCEnumDescriptor *desc,
- int value);
-const ProtobufCFieldDescriptor *
-protobuf_c_message_descriptor_get_field_by_name
- (const ProtobufCMessageDescriptor *desc,
- const char *name);
-const ProtobufCFieldDescriptor *
-protobuf_c_message_descriptor_get_field
- (const ProtobufCMessageDescriptor *desc,
- unsigned value);
-const ProtobufCMethodDescriptor *
-protobuf_c_service_descriptor_get_method_by_name
- (const ProtobufCServiceDescriptor *desc,
- const char *name);
-
-/* --- wire format enums --- */
-typedef enum
-{
- PROTOBUF_C_WIRE_TYPE_VARINT,
- PROTOBUF_C_WIRE_TYPE_64BIT,
- PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED,
- PROTOBUF_C_WIRE_TYPE_START_GROUP, /* unsupported */
- PROTOBUF_C_WIRE_TYPE_END_GROUP, /* unsupported */
- PROTOBUF_C_WIRE_TYPE_32BIT
-} ProtobufCWireType;
-
-/* --- unknown message fields --- */
-struct _ProtobufCMessageUnknownField
-{
- uint32_t tag;
- ProtobufCWireType wire_type;
- size_t len;
- uint8_t *data;
-};
-
-/* --- extra (superfluous) api: trivial buffer --- */
-typedef struct _ProtobufCBufferSimple ProtobufCBufferSimple;
-struct _ProtobufCBufferSimple
-{
- ProtobufCBuffer base;
- size_t alloced;
- size_t len;
- uint8_t *data;
- protobuf_c_boolean must_free_data;
-};
-#define PROTOBUF_C_BUFFER_SIMPLE_INIT(array_of_bytes) \
-{ { protobuf_c_buffer_simple_append }, \
- sizeof(array_of_bytes), 0, (array_of_bytes), 0 }
-#define PROTOBUF_C_BUFFER_SIMPLE_CLEAR(simp_buf) \
- do { if ((simp_buf)->must_free_data) \
- protobuf_c_default_allocator.free (&protobuf_c_default_allocator.allocator_data, (simp_buf)->data); } while (0)
-
-/* ====== private ====== */
-#include "protobuf-c-private.h"
-
-
-PROTOBUF_C_END_DECLS
-
-#endif /* __PROTOBUF_C_RUNTIME_H_ */
diff --git a/navit/maptool/itembin.c b/navit/maptool/itembin.c
index 98b0c52a6..6f1328355 100644
--- a/navit/maptool/itembin.c
+++ b/navit/maptool/itembin.c
@@ -27,692 +27,613 @@
-int
-item_bin_read(struct item_bin *ib, FILE *in)
-{
- if (fread(ib, 4, 1, in) == 0)
- return 0;
- if (!ib->len)
- return 1;
- if (fread((unsigned char *)ib+4, ib->len*4, 1, in))
- return 2;
- return 0;
-}
-
-void
-item_bin_set_type(struct item_bin *ib, enum item_type type)
-{
- ib->type=type;
-}
-
-void
-item_bin_init(struct item_bin *ib, enum item_type type)
-{
- ib->clen=0;
- ib->len=2;
- item_bin_set_type(ib, type);
-}
-
-
-void
-item_bin_add_coord(struct item_bin *ib, struct coord *coords_to_add, int count)
-{
- struct coord *coord_list=(struct coord *)(ib+1);
- coord_list+=ib->clen/2;
- memcpy(coord_list, coords_to_add, count*sizeof(struct coord));
- ib->clen+=count*2;
- ib->len+=count*2;
-}
-
-void
-item_bin_add_coord_reverse(struct item_bin *ib, struct coord *c, int count)
-{
- int i;
- for (i = count-1 ; i >= 0 ; i--)
- item_bin_add_coord(ib, &c[i], 1);
-}
-
-void
-item_bin_bbox(struct item_bin *ib, struct rect *r)
-{
- struct coord c;
- item_bin_add_coord(ib, &r->l, 1);
- c.x=r->h.x;
- c.y=r->l.y;
- item_bin_add_coord(ib, &c, 1);
- item_bin_add_coord(ib, &r->h, 1);
- c.x=r->l.x;
- c.y=r->h.y;
- item_bin_add_coord(ib, &c, 1);
- item_bin_add_coord(ib, &r->l, 1);
-}
-
-void
-item_bin_copy_coord(struct item_bin *ib, struct item_bin *from, int dir)
-{
- struct coord *c=(struct coord *)(from+1);
- int i,count=from->clen/2;
- if (dir >= 0) {
- item_bin_add_coord(ib, c, count);
- return;
- }
- for (i = 1 ; i <= count ; i++)
- item_bin_add_coord(ib, &c[count-i], 1);
-}
-
-void
-item_bin_copy_attr(struct item_bin *ib, struct item_bin *from, enum attr_type attr)
-{
- struct attr_bin *ab=item_bin_get_attr_bin(from, attr, NULL);
- if (ab)
- item_bin_add_attr_data(ib, ab->type, (void *)(ab+1), (ab->len-1)*4);
- assert(attr == attr_osm_wayid);
- assert(item_bin_get_wayid(ib) == item_bin_get_wayid(from));
-}
-
-void
-item_bin_add_coord_rect(struct item_bin *ib, struct rect *r)
-{
- item_bin_add_coord(ib, &r->l, 1);
- item_bin_add_coord(ib, &r->h, 1);
-}
-
-int
-attr_bin_write_data(struct attr_bin *ab, enum attr_type type, void *data, int size)
-{
- int pad=(4-(size%4))%4;
- ab->type=type;
- memcpy(ab+1, data, size);
- memset((unsigned char *)(ab+1)+size, 0, pad);
- ab->len=(size+pad)/4+1;
- return ab->len+1;
-}
-
-int
-attr_bin_write_attr(struct attr_bin *ab, struct attr *attr)
-{
- return attr_bin_write_data(ab, attr->type, attr_data_get(attr), attr_data_size(attr));
-}
-
-void
-item_bin_add_attr_data(struct item_bin *ib, enum attr_type type, void *data, int size)
-{
- struct attr_bin *ab=(struct attr_bin *)((int *)ib+ib->len+1);
- ib->len+=attr_bin_write_data(ab, type, data, size);
-}
-
-void
-item_bin_add_attr(struct item_bin *ib, struct attr *attr)
-{
- struct attr_bin *ab=(struct attr_bin *)((int *)ib+ib->len+1);
- if (ATTR_IS_GROUP(attr->type)) {
- int i=0;
- int *abptr;
- ab->type=attr->type;
- ab->len=1;
- abptr=(int *)(ab+1);
- while (attr->u.attrs[i].type) {
- int size=attr_bin_write_attr((struct attr_bin *)abptr, &attr->u.attrs[i]);
- ab->len+=size;
- abptr+=size;
- i++;
- }
- ib->len+=ab->len+1;
-
- } else
- ib->len+=attr_bin_write_attr(ab, attr);
-
-}
-
-void
-item_bin_remove_attr(struct item_bin *ib, void *ptr)
-{
- unsigned char *s=(unsigned char *)ib;
- unsigned char *e=s+(ib->len+1)*4;
- s+=sizeof(struct item_bin)+ib->clen*4;
- while (s < e) {
- struct attr_bin *ab=(struct attr_bin *)s;
- s+=(ab->len+1)*4;
- if ((void *)(ab+1) == ptr) {
- ib->len-=ab->len+1;
- memmove(ab,s,e-s);
- return;
- }
- }
-}
-
-void
-item_bin_add_attr_int(struct item_bin *ib, enum attr_type type, int val)
-{
- struct attr attr;
- attr.type=type;
- attr.u.num=val;
- item_bin_add_attr(ib, &attr);
-}
-
-void *
-item_bin_get_attr(struct item_bin *ib, enum attr_type type, void *last)
-{
- unsigned char *s=(unsigned char *)ib;
- unsigned char *e=s+(ib->len+1)*4;
- s+=sizeof(struct item_bin)+ib->clen*4;
- while (s < e) {
- struct attr_bin *ab=(struct attr_bin *)s;
- s+=(ab->len+1)*4;
- if (ab->type == type && (void *)(ab+1) > last) {
- return (ab+1);
- }
- }
- return NULL;
+int item_bin_read(struct item_bin *ib, FILE *in) {
+ if (fread(ib, 4, 1, in) == 0)
+ return 0;
+ if (!ib->len)
+ return 1;
+ if (fread((unsigned char *)ib+4, ib->len*4, 1, in))
+ return 2;
+ return 0;
+}
+
+void item_bin_set_type(struct item_bin *ib, enum item_type type) {
+ ib->type=type;
+}
+
+void item_bin_init(struct item_bin *ib, enum item_type type) {
+ ib->clen=0;
+ ib->len=2;
+ item_bin_set_type(ib, type);
+}
+
+
+void item_bin_add_coord(struct item_bin *ib, struct coord *coords_to_add, int count) {
+ struct coord *coord_list=(struct coord *)(ib+1);
+ coord_list+=ib->clen/2;
+ memcpy(coord_list, coords_to_add, count*sizeof(struct coord));
+ ib->clen+=count*2;
+ ib->len+=count*2;
+}
+
+void item_bin_add_coord_reverse(struct item_bin *ib, struct coord *c, int count) {
+ int i;
+ for (i = count-1 ; i >= 0 ; i--)
+ item_bin_add_coord(ib, &c[i], 1);
+}
+
+void item_bin_bbox(struct item_bin *ib, struct rect *r) {
+ struct coord c;
+ item_bin_add_coord(ib, &r->l, 1);
+ c.x=r->h.x;
+ c.y=r->l.y;
+ item_bin_add_coord(ib, &c, 1);
+ item_bin_add_coord(ib, &r->h, 1);
+ c.x=r->l.x;
+ c.y=r->h.y;
+ item_bin_add_coord(ib, &c, 1);
+ item_bin_add_coord(ib, &r->l, 1);
+}
+
+void item_bin_copy_coord(struct item_bin *ib, struct item_bin *from, int dir) {
+ struct coord *c=(struct coord *)(from+1);
+ int i,count=from->clen/2;
+ if (dir >= 0) {
+ item_bin_add_coord(ib, c, count);
+ return;
+ }
+ for (i = 1 ; i <= count ; i++)
+ item_bin_add_coord(ib, &c[count-i], 1);
+}
+
+void item_bin_copy_attr(struct item_bin *ib, struct item_bin *from, enum attr_type attr) {
+ struct attr_bin *ab=item_bin_get_attr_bin(from, attr, NULL);
+ if (ab)
+ item_bin_add_attr_data(ib, ab->type, (void *)(ab+1), (ab->len-1)*4);
+ assert(attr == attr_osm_wayid);
+ assert(item_bin_get_wayid(ib) == item_bin_get_wayid(from));
+}
+
+void item_bin_add_coord_rect(struct item_bin *ib, struct rect *r) {
+ item_bin_add_coord(ib, &r->l, 1);
+ item_bin_add_coord(ib, &r->h, 1);
+}
+
+int attr_bin_write_data(struct attr_bin *ab, enum attr_type type, void *data, int size) {
+ int pad=(4-(size%4))%4;
+ ab->type=type;
+ memcpy(ab+1, data, size);
+ memset((unsigned char *)(ab+1)+size, 0, pad);
+ ab->len=(size+pad)/4+1;
+ return ab->len+1;
+}
+
+int attr_bin_write_attr(struct attr_bin *ab, struct attr *attr) {
+ return attr_bin_write_data(ab, attr->type, attr_data_get(attr), attr_data_size(attr));
+}
+
+void item_bin_add_attr_data(struct item_bin *ib, enum attr_type type, void *data, int size) {
+ struct attr_bin *ab=(struct attr_bin *)((int *)ib+ib->len+1);
+ ib->len+=attr_bin_write_data(ab, type, data, size);
+}
+
+void item_bin_add_attr(struct item_bin *ib, struct attr *attr) {
+ struct attr_bin *ab=(struct attr_bin *)((int *)ib+ib->len+1);
+ if (ATTR_IS_GROUP(attr->type)) {
+ int i=0;
+ int *abptr;
+ ab->type=attr->type;
+ ab->len=1;
+ abptr=(int *)(ab+1);
+ while (attr->u.attrs[i].type) {
+ int size=attr_bin_write_attr((struct attr_bin *)abptr, &attr->u.attrs[i]);
+ ab->len+=size;
+ abptr+=size;
+ i++;
+ }
+ ib->len+=ab->len+1;
+
+ } else
+ ib->len+=attr_bin_write_attr(ab, attr);
+
+}
+
+void item_bin_remove_attr(struct item_bin *ib, void *ptr) {
+ unsigned char *s=(unsigned char *)ib;
+ unsigned char *e=s+(ib->len+1)*4;
+ s+=sizeof(struct item_bin)+ib->clen*4;
+ while (s < e) {
+ struct attr_bin *ab=(struct attr_bin *)s;
+ s+=(ab->len+1)*4;
+ if ((void *)(ab+1) == ptr) {
+ ib->len-=ab->len+1;
+ memmove(ab,s,e-s);
+ return;
+ }
+ }
+}
+
+void item_bin_add_attr_int(struct item_bin *ib, enum attr_type type, int val) {
+ struct attr attr;
+ attr.type=type;
+ attr.u.num=val;
+ item_bin_add_attr(ib, &attr);
+}
+
+void *item_bin_get_attr(struct item_bin *ib, enum attr_type type, void *last) {
+ unsigned char *s=(unsigned char *)ib;
+ unsigned char *e=s+(ib->len+1)*4;
+ s+=sizeof(struct item_bin)+ib->clen*4;
+ while (s < e) {
+ struct attr_bin *ab=(struct attr_bin *)s;
+ s+=(ab->len+1)*4;
+ if (ab->type == type && (void *)(ab+1) > last) {
+ return (ab+1);
+ }
+ }
+ return NULL;
}
struct attr_bin *
-item_bin_get_attr_bin(struct item_bin *ib, enum attr_type type, void *last)
-{
- unsigned char *s=(unsigned char *)ib;
- unsigned char *e=s+(ib->len+1)*4;
- s+=sizeof(struct item_bin)+ib->clen*4;
- while (s < e) {
- struct attr_bin *ab=(struct attr_bin *)s;
- s+=(ab->len+1)*4;
- if (ab->type == type && (void *)(ab+1) > last) {
- return ab;
- }
- }
- return NULL;
+item_bin_get_attr_bin(struct item_bin *ib, enum attr_type type, void *last) {
+ unsigned char *s=(unsigned char *)ib;
+ unsigned char *e=s+(ib->len+1)*4;
+ s+=sizeof(struct item_bin)+ib->clen*4;
+ while (s < e) {
+ struct attr_bin *ab=(struct attr_bin *)s;
+ s+=(ab->len+1)*4;
+ if (ab->type == type && (void *)(ab+1) > last) {
+ return ab;
+ }
+ }
+ return NULL;
}
struct attr_bin *
-item_bin_get_attr_bin_last(struct item_bin *ib)
-{
- struct attr_bin *ab=NULL;
- unsigned char *s=(unsigned char *)ib;
- unsigned char *e=s+(ib->len+1)*4;
- s+=sizeof(struct item_bin)+ib->clen*4;
- while (s < e) {
- ab=(struct attr_bin *)s;
- s+=(ab->len+1)*4;
- }
- return ab;
-}
-
-void
-item_bin_add_attr_longlong(struct item_bin *ib, enum attr_type type, long long val)
-{
- struct attr attr;
- attr.type=type;
- attr.u.num64=&val;
- item_bin_add_attr(ib, &attr);
-}
-
-void
-item_bin_add_attr_string(struct item_bin *ib, enum attr_type type, char *str)
-{
- struct attr attr;
- if (! str)
- return;
- attr.type=type;
- attr.u.str=str;
- item_bin_add_attr(ib, &attr);
-}
-
-void
-item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, short max)
-{
- struct attr attr;
- attr.type=type;
- attr.u.range.min=min;
- attr.u.range.max=max;
- item_bin_add_attr(ib, &attr);
-}
-
-void
-item_bin_write(struct item_bin *ib, FILE *out)
-{
- dbg_assert(fwrite(ib, (ib->len+1)*4, 1, out)==1);
+item_bin_get_attr_bin_last(struct item_bin *ib) {
+ struct attr_bin *ab=NULL;
+ unsigned char *s=(unsigned char *)ib;
+ unsigned char *e=s+(ib->len+1)*4;
+ s+=sizeof(struct item_bin)+ib->clen*4;
+ while (s < e) {
+ ab=(struct attr_bin *)s;
+ s+=(ab->len+1)*4;
+ }
+ return ab;
+}
+
+void item_bin_add_attr_longlong(struct item_bin *ib, enum attr_type type, long long val) {
+ struct attr attr;
+ attr.type=type;
+ attr.u.num64=&val;
+ item_bin_add_attr(ib, &attr);
+}
+
+void item_bin_add_attr_string(struct item_bin *ib, enum attr_type type, char *str) {
+ struct attr attr;
+ if (! str)
+ return;
+ attr.type=type;
+ attr.u.str=str;
+ item_bin_add_attr(ib, &attr);
+}
+
+void item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, short max) {
+ struct attr attr;
+ attr.type=type;
+ attr.u.range.min=min;
+ attr.u.range.max=max;
+ item_bin_add_attr(ib, &attr);
+}
+
+void item_bin_write(struct item_bin *ib, FILE *out) {
+ dbg_assert(fwrite(ib, (ib->len+1)*4, 1, out)==1);
}
struct item_bin *
-item_bin_dup(struct item_bin *ib)
-{
- int len=(ib->len+1)*4;
- struct item_bin *ret=g_malloc(len);
- memcpy(ret, ib, len);
-
- return ret;
-}
-
-void
-item_bin_write_clipped(struct item_bin *ib, struct tile_parameter *param, struct item_bin_sink *out)
-{
- struct tile_data tile_data;
- int i;
- bbox((struct coord *)(ib+1), ib->clen/2, &tile_data.item_bbox);
- tile_data.buffer[0]='\0';
- tile_data.tile_depth=tile(&tile_data.item_bbox, NULL, tile_data.buffer, param->max, param->overlap, &tile_data.tile_bbox);
- if (tile_data.tile_depth == param->max || tile_data.tile_depth >= param->min) {
- item_bin_write_to_sink(ib, out, &tile_data);
- return;
- }
- for (i = 0 ; i < 4 ; i++) {
- struct rect clip_rect;
- tile_data.buffer[tile_data.tile_depth]='a'+i;
- tile_data.buffer[tile_data.tile_depth+1]='\0';
- tile_bbox(tile_data.buffer, &clip_rect, param->overlap);
- if (ib->type < type_area)
- clip_line(ib, &clip_rect, param, out);
- else
- clip_polygon(ib, &clip_rect, param, out);
- }
-}
-
-static char *
-coord_to_str(struct coord *c)
-{
- int x=c->x;
- int y=c->y;
- char *sx="";
- char *sy="";
- if (x < 0) {
- sx="-";
- x=-x;
- }
- if (y < 0) {
- sy="-";
- y=-y;
- }
- return g_strdup_printf("%s0x%x %s0x%x",sx,x,sy,y);
-}
-
-static void
-dump_coord(struct coord *c, FILE *out)
-{
- char *str=coord_to_str(c);
- fprintf(out,"%s",str);
- g_free(str);
-}
-
-
-void
-item_bin_dump(struct item_bin *ib, FILE *out)
-{
- struct coord *c;
- struct attr_bin *a;
- struct attr attr;
- int *attr_start;
- int *attr_end;
- int i;
- char *str;
-
- c=(struct coord *)(ib+1);
- if (ib->type < type_line) {
- dump_coord(c,out);
- fprintf(out, " ");
- }
- attr_start=(int *)(ib+1)+ib->clen;
- attr_end=(int *)ib+ib->len+1;
- fprintf(out,"type=%s", item_to_name(ib->type));
- while (attr_start < attr_end) {
- a=(struct attr_bin *)(attr_start);
- attr_start+=a->len+1;
- attr.type=a->type;
- attr_data_set(&attr, (a+1));
- str=attr_to_text(&attr, NULL, 1);
- fprintf(out," %s=\"%s\"", attr_to_name(a->type), str);
- g_free(str);
- }
- fprintf(out," debug=\"length=%d\"", ib->len);
- fprintf(out,"\n");
- if (ib->type >= type_line) {
- for (i = 0 ; i < ib->clen/2 ; i++) {
- dump_coord(c+i,out);
- fprintf(out,"\n");
- }
- }
-}
-
-void
-dump_itembin(struct item_bin *ib)
-{
- item_bin_dump(ib, stdout);
+item_bin_dup(struct item_bin *ib) {
+ int len=(ib->len+1)*4;
+ struct item_bin *ret=g_malloc(len);
+ memcpy(ret, ib, len);
+
+ return ret;
+}
+
+void item_bin_write_clipped(struct item_bin *ib, struct tile_parameter *param, struct item_bin_sink *out) {
+ struct tile_data tile_data;
+ int i;
+ bbox((struct coord *)(ib+1), ib->clen/2, &tile_data.item_bbox);
+ tile_data.buffer[0]='\0';
+ tile_data.tile_depth=tile(&tile_data.item_bbox, NULL, tile_data.buffer, param->max, param->overlap,
+ &tile_data.tile_bbox);
+ if (tile_data.tile_depth == param->max || tile_data.tile_depth >= param->min) {
+ item_bin_write_to_sink(ib, out, &tile_data);
+ return;
+ }
+ for (i = 0 ; i < 4 ; i++) {
+ struct rect clip_rect;
+ tile_data.buffer[tile_data.tile_depth]='a'+i;
+ tile_data.buffer[tile_data.tile_depth+1]='\0';
+ tile_bbox(tile_data.buffer, &clip_rect, param->overlap);
+ if (ib->type < type_area)
+ clip_line(ib, &clip_rect, param, out);
+ else
+ clip_polygon(ib, &clip_rect, param, out);
+ }
+}
+
+static char *coord_to_str(struct coord *c) {
+ int x=c->x;
+ int y=c->y;
+ char *sx="";
+ char *sy="";
+ if (x < 0) {
+ sx="-";
+ x=-x;
+ }
+ if (y < 0) {
+ sy="-";
+ y=-y;
+ }
+ return g_strdup_printf("%s0x%x %s0x%x",sx,x,sy,y);
+}
+
+static void dump_coord(struct coord *c, FILE *out) {
+ char *str=coord_to_str(c);
+ fprintf(out,"%s",str);
+ g_free(str);
+}
+
+
+void item_bin_dump(struct item_bin *ib, FILE *out) {
+ struct coord *c;
+ struct attr_bin *a;
+ struct attr attr;
+ int *attr_start;
+ int *attr_end;
+ int i;
+ char *str;
+
+ c=(struct coord *)(ib+1);
+ if (ib->type < type_line) {
+ dump_coord(c,out);
+ fprintf(out, " ");
+ }
+ attr_start=(int *)(ib+1)+ib->clen;
+ attr_end=(int *)ib+ib->len+1;
+ fprintf(out,"type=%s", item_to_name(ib->type));
+ while (attr_start < attr_end) {
+ a=(struct attr_bin *)(attr_start);
+ attr_start+=a->len+1;
+ attr.type=a->type;
+ attr_data_set(&attr, (a+1));
+ str=attr_to_text(&attr, NULL, 1);
+ fprintf(out," %s=\"%s\"", attr_to_name(a->type), str);
+ g_free(str);
+ }
+ fprintf(out," debug=\"length=%d\"", ib->len);
+ fprintf(out,"\n");
+ if (ib->type >= type_line) {
+ for (i = 0 ; i < ib->clen/2 ; i++) {
+ dump_coord(c+i,out);
+ fprintf(out,"\n");
+ }
+ }
+}
+
+void dump_itembin(struct item_bin *ib) {
+ item_bin_dump(ib, stdout);
}
struct population_table {
- enum item_type type;
- int population;
+ enum item_type type;
+ int population;
};
static struct population_table town_population[] = {
- {type_town_label_0e0,0},
- {type_town_label_1e0,1},
- {type_town_label_2e0,2},
- {type_town_label_5e0,5},
- {type_town_label_1e1,10},
- {type_town_label_2e1,20},
- {type_town_label_5e1,50},
- {type_town_label_1e2,100},
- {type_town_label_2e2,200},
- {type_town_label_5e2,500},
- {type_town_label_1e3,1000},
- {type_town_label_2e3,2000},
- {type_town_label_5e3,5000},
- {type_town_label_1e4,10000},
- {type_town_label_2e4,20000},
- {type_town_label_5e4,50000},
- {type_town_label_1e5,100000},
- {type_town_label_2e5,200000},
- {type_town_label_5e5,500000},
- {type_town_label_1e6,1000000},
- {type_town_label_2e6,2000000},
- {type_town_label_5e6,5000000},
- {type_town_label_1e7,10000000},
+ {type_town_label_0e0,0},
+ {type_town_label_1e0,1},
+ {type_town_label_2e0,2},
+ {type_town_label_5e0,5},
+ {type_town_label_1e1,10},
+ {type_town_label_2e1,20},
+ {type_town_label_5e1,50},
+ {type_town_label_1e2,100},
+ {type_town_label_2e2,200},
+ {type_town_label_5e2,500},
+ {type_town_label_1e3,1000},
+ {type_town_label_2e3,2000},
+ {type_town_label_5e3,5000},
+ {type_town_label_1e4,10000},
+ {type_town_label_2e4,20000},
+ {type_town_label_5e4,50000},
+ {type_town_label_1e5,100000},
+ {type_town_label_2e5,200000},
+ {type_town_label_5e5,500000},
+ {type_town_label_1e6,1000000},
+ {type_town_label_2e6,2000000},
+ {type_town_label_5e6,5000000},
+ {type_town_label_1e7,10000000},
};
static struct population_table district_population[] = {
- {type_district_label_0e0,0},
- {type_district_label_1e0,1},
- {type_district_label_2e0,2},
- {type_district_label_5e0,5},
- {type_district_label_1e1,10},
- {type_district_label_2e1,20},
- {type_district_label_5e1,50},
- {type_district_label_1e2,100},
- {type_district_label_2e2,200},
- {type_district_label_5e2,500},
- {type_district_label_1e3,1000},
- {type_district_label_2e3,2000},
- {type_district_label_5e3,5000},
- {type_district_label_1e4,10000},
- {type_district_label_2e4,20000},
- {type_district_label_5e4,50000},
- {type_district_label_1e5,100000},
- {type_district_label_2e5,200000},
- {type_district_label_5e5,500000},
- {type_district_label_1e6,1000000},
- {type_district_label_2e6,2000000},
- {type_district_label_5e6,5000000},
- {type_district_label_1e7,10000000},
+ {type_district_label_0e0,0},
+ {type_district_label_1e0,1},
+ {type_district_label_2e0,2},
+ {type_district_label_5e0,5},
+ {type_district_label_1e1,10},
+ {type_district_label_2e1,20},
+ {type_district_label_5e1,50},
+ {type_district_label_1e2,100},
+ {type_district_label_2e2,200},
+ {type_district_label_5e2,500},
+ {type_district_label_1e3,1000},
+ {type_district_label_2e3,2000},
+ {type_district_label_5e3,5000},
+ {type_district_label_1e4,10000},
+ {type_district_label_2e4,20000},
+ {type_district_label_5e4,50000},
+ {type_district_label_1e5,100000},
+ {type_district_label_2e5,200000},
+ {type_district_label_5e5,500000},
+ {type_district_label_1e6,1000000},
+ {type_district_label_2e6,2000000},
+ {type_district_label_5e6,5000000},
+ {type_district_label_1e7,10000000},
};
-void
-item_bin_set_type_by_population(struct item_bin *ib, int population)
-{
- struct population_table *table;
- int i,count;
-
- if (population < 0)
- population=0;
- if (item_is_district(*ib)) {
- table=district_population;
- count=sizeof(district_population)/sizeof(district_population[0]);
- } else {
- table=town_population;
- count=sizeof(town_population)/sizeof(town_population[0]);
- }
- for (i = 0 ; i < count ; i++) {
- if (population < table[i].population)
- break;
- }
- item_bin_set_type(ib, table[i-1].type);
-}
-
-
-void
-item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, int maxdepth, FILE *out)
-{
- char *word=item_bin_get_attr(ib, type, NULL);
- int i,words=0,len;
- char tilename[32]="";
-
- if (!word)
- return;
-
- if(maxdepth && ib->clen>0) {
- struct rect r;
- struct coord *c=(struct coord *)(ib+1);
- r.l=c[0];
- r.h=c[0];
- for (i = 1 ; i < ib->clen/2 ; i++)
- bbox_extend(&c[i], &r);
- tile(&r,NULL,tilename,maxdepth,overlap,NULL);
- }
-
- /* insert attr_tile_name attribute before the attribute used as alphabetical key (of type type) */
- if(maxdepth) {
- item_bin_add_attr_string(ib, attr_tile_name, tilename);
- item_bin_add_attr_string(ib, type, word);
- item_bin_remove_attr(ib,word);
- word=item_bin_get_attr(ib, type, NULL);
- }
- len=ib->len;
- do {
- if (linguistics_search(word)) {
- for (i = 0 ; i < 3 ; i++) {
- char *str=linguistics_expand_special(word, i);
- if (str) {
- ib->len=len;
- if (i || words)
- item_bin_add_attr_string(ib, match, str);
- item_bin_write(ib, out);
- g_free(str);
- }
- }
- words++;
- }
- word=linguistics_next_word(word);
- } while (word);
-}
-
-static int
-item_bin_sort_compare(const void *p1, const void *p2)
-{
- struct item_bin *ib1=*((struct item_bin **)p1),*ib2=*((struct item_bin **)p2);
- struct attr_bin *attr1,*attr2;
- char *s1,*s2;
- int ret;
-
- attr1=item_bin_get_attr_bin(ib1, attr_tile_name, NULL);
- attr2=item_bin_get_attr_bin(ib2, attr_tile_name, NULL);
- if(attr1&&attr2) {
- s1=(char *)(attr1+1);
- s2=(char *)(attr2+1);
- ret=strcmp(s1,s2);
- if(ret)
- return ret;
- }
-#if 0
- dbg_assert(ib1->clen==2);
- dbg_assert(ib2->clen==2);
- attr1=(struct attr_bin *)((int *)(ib1+1)+ib1->clen);
- attr2=(struct attr_bin *)((int *)(ib2+1)+ib1->clen);
-#else
- attr1=item_bin_get_attr_bin_last(ib1);
- attr2=item_bin_get_attr_bin_last(ib2);
-#endif
-#if 0
- dbg_assert(attr1->type == attr_town_name || attr1->type == attr_town_name_match);
- dbg_assert(attr2->type == attr_town_name || attr2->type == attr_town_name_match);
-#endif
- s1=(char *)(attr1+1);
- s2=(char *)(attr2+1);
- if (attr1->type == attr_house_number && attr2->type == attr_house_number) {
- ret=atoi(s1)-atoi(s2);
- if (ret)
- return ret;
- }
-
- s1=linguistics_casefold(s1);
- s2=linguistics_casefold(s2);
-
- ret=strcmp(s1, s2);
- g_free(s1);
- g_free(s2);
-
- if (!ret) {
- int match1=0,match2=0;
- match1=(attr1->type == attr_town_name_match || attr1->type == attr_district_name_match);
- match2=(attr2->type == attr_town_name_match || attr2->type == attr_district_name_match);
- ret=match1-match2;
- }
-#if 0
- fprintf(stderr,"sort_countries_compare p1=%p p2=%p %s %s\n",p1,p2,s1,s2);
-#endif
- return ret;
-}
-
-int
-item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size)
-{
- int j,k,count,rc=0;
- struct coord *c;
- struct item_bin *ib;
- FILE *f;
- unsigned char *p,**idx,*buffer;
- if (file_get_contents(in_file, &buffer, size)) {
- ib=(struct item_bin *)buffer;
- p=buffer;
- count=0;
- while (p < buffer+*size) {
- count++;
- p+=(*((int *)p)+1)*4;
- }
- idx=g_malloc(count*sizeof(void *));
- p=buffer;
- for (j = 0 ; j < count ; j++) {
- idx[j]=p;
- p+=(*((int *)p)+1)*4;
- }
- qsort(idx, count, sizeof(void *), item_bin_sort_compare);
- f=fopen(out_file,"wb");
- for (j = 0 ; j < count ; j++) {
- ib=(struct item_bin *)(idx[j]);
- c=(struct coord *)(ib+1);
- dbg_assert(fwrite(ib, (ib->len+1)*4, 1, f)==1);
- if (r) {
- for (k = 0 ; k < ib->clen/2 ; k++) {
- if (rc)
- bbox_extend(&c[k], r);
- else {
- r->l=c[k];
- r->h=c[k];
- }
- rc++;
- }
- }
- }
- fclose(f);
- g_free(idx);
- g_free(buffer);
- return 1;
- }
- return 0;
+void item_bin_set_type_by_population(struct item_bin *ib, int population) {
+ struct population_table *table;
+ int i,count;
+
+ if (population < 0)
+ population=0;
+ if (item_is_district(*ib)) {
+ table=district_population;
+ count=sizeof(district_population)/sizeof(district_population[0]);
+ } else {
+ table=town_population;
+ count=sizeof(town_population)/sizeof(town_population[0]);
+ }
+ for (i = 0 ; i < count ; i++) {
+ if (population < table[i].population)
+ break;
+ }
+ item_bin_set_type(ib, table[i-1].type);
+}
+
+
+void item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, int maxdepth, FILE *out) {
+ char *word=item_bin_get_attr(ib, type, NULL);
+ int i,words=0,len;
+ char tilename[32]="";
+
+ if (!word)
+ return;
+
+ if(maxdepth && ib->clen>0) {
+ struct rect r;
+ struct coord *c=(struct coord *)(ib+1);
+ r.l=c[0];
+ r.h=c[0];
+ for (i = 1 ; i < ib->clen/2 ; i++)
+ bbox_extend(&c[i], &r);
+ tile(&r,NULL,tilename,maxdepth,overlap,NULL);
+ }
+
+ /* insert attr_tile_name attribute before the attribute used as alphabetical key (of type type) */
+ if(maxdepth) {
+ item_bin_add_attr_string(ib, attr_tile_name, tilename);
+ item_bin_add_attr_string(ib, type, word);
+ item_bin_remove_attr(ib,word);
+ word=item_bin_get_attr(ib, type, NULL);
+ }
+ len=ib->len;
+ do {
+ if (linguistics_search(word)) {
+ for (i = 0 ; i < 3 ; i++) {
+ char *str=linguistics_expand_special(word, i);
+ if (str) {
+ ib->len=len;
+ if (i || words)
+ item_bin_add_attr_string(ib, match, str);
+ item_bin_write(ib, out);
+ g_free(str);
+ }
+ }
+ words++;
+ }
+ word=linguistics_next_word(word);
+ } while (word);
+}
+
+static int item_bin_sort_compare(const void *p1, const void *p2) {
+ struct item_bin *ib1=*((struct item_bin **)p1),*ib2=*((struct item_bin **)p2);
+ struct attr_bin *attr1,*attr2;
+ char *s1,*s2;
+ int ret;
+
+ attr1=item_bin_get_attr_bin(ib1, attr_tile_name, NULL);
+ attr2=item_bin_get_attr_bin(ib2, attr_tile_name, NULL);
+ if(attr1&&attr2) {
+ s1=(char *)(attr1+1);
+ s2=(char *)(attr2+1);
+ ret=g_strcmp0(s1,s2);
+ if(ret)
+ return ret;
+ }
+ attr1=item_bin_get_attr_bin_last(ib1);
+ attr2=item_bin_get_attr_bin_last(ib2);
+ s1=(char *)(attr1+1);
+ s2=(char *)(attr2+1);
+ if (attr1->type == attr_house_number && attr2->type == attr_house_number) {
+ ret=atoi(s1)-atoi(s2);
+ if (ret)
+ return ret;
+ }
+
+ s1=linguistics_casefold(s1);
+ s2=linguistics_casefold(s2);
+
+ ret=g_strcmp0(s1, s2);
+ g_free(s1);
+ g_free(s2);
+
+ if (!ret) {
+ int match1=0,match2=0;
+ match1=(attr1->type == attr_town_name_match || attr1->type == attr_district_name_match);
+ match2=(attr2->type == attr_town_name_match || attr2->type == attr_district_name_match);
+ ret=match1-match2;
+ }
+ return ret;
+}
+
+int item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size) {
+ int j,k,count,rc=0;
+ struct coord *c;
+ struct item_bin *ib;
+ FILE *f;
+ unsigned char *p,**idx,*buffer;
+ if (file_get_contents(in_file, &buffer, size)) {
+ ib=(struct item_bin *)buffer;
+ p=buffer;
+ count=0;
+ while (p < buffer+*size) {
+ count++;
+ p+=(*((int *)p)+1)*4;
+ }
+ idx=g_malloc(count*sizeof(void *));
+ p=buffer;
+ for (j = 0 ; j < count ; j++) {
+ idx[j]=p;
+ p+=(*((int *)p)+1)*4;
+ }
+ qsort(idx, count, sizeof(void *), item_bin_sort_compare);
+ f=fopen(out_file,"wb");
+ for (j = 0 ; j < count ; j++) {
+ ib=(struct item_bin *)(idx[j]);
+ c=(struct coord *)(ib+1);
+ dbg_assert(fwrite(ib, (ib->len+1)*4, 1, f)==1);
+ if (r) {
+ for (k = 0 ; k < ib->clen/2 ; k++) {
+ if (rc)
+ bbox_extend(&c[k], r);
+ else {
+ r->l=c[k];
+ r->h=c[k];
+ }
+ rc++;
+ }
+ }
+ }
+ fclose(f);
+ g_free(idx);
+ g_free(buffer);
+ return 1;
+ }
+ return 0;
}
struct geom_poly_segment *
-item_bin_to_poly_segment(struct item_bin *ib, int type)
-{
- struct geom_poly_segment *ret=g_new(struct geom_poly_segment, 1);
- int count=ib->clen*sizeof(int)/sizeof(struct coord);
- ret->type=type;
- ret->first=g_new(struct coord, count);
- ret->last=ret->first+count-1;
- geom_coord_copy((struct coord *)(ib+1), ret->first, count, 0);
- return ret;
-}
-
-void
-clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out)
-{
- char *buffer=g_alloca(sizeof(char)*(ib->len*4+32));
- struct item_bin *ib_new=(struct item_bin *)buffer;
- struct coord *pa=(struct coord *)(ib+1);
- int count=ib->clen/2;
- struct coord p1,p2;
- int i,code;
- item_bin_init(ib_new, ib->type);
- for (i = 0 ; i < count ; i++) {
- if (i) {
- p1.x=pa[i-1].x;
- p1.y=pa[i-1].y;
- p2.x=pa[i].x;
- p2.y=pa[i].y;
- /* 0 = invisible, 1 = completely visible, 3 = start point clipped, 5 = end point clipped, 7 both points clipped */
- code=geom_clip_line_code(&p1, &p2, r);
+item_bin_to_poly_segment(struct item_bin *ib, int type) {
+ struct geom_poly_segment *ret=g_new(struct geom_poly_segment, 1);
+ int count=ib->clen*sizeof(int)/sizeof(struct coord);
+ ret->type=type;
+ ret->first=g_new(struct coord, count);
+ ret->last=ret->first+count-1;
+ geom_coord_copy((struct coord *)(ib+1), ret->first, count, 0);
+ return ret;
+}
+
+void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out) {
+ char *buffer=g_alloca(sizeof(char)*(ib->len*4+32));
+ struct item_bin *ib_new=(struct item_bin *)buffer;
+ struct coord *pa=(struct coord *)(ib+1);
+ int count=ib->clen/2;
+ struct coord p1,p2;
+ int i,code;
+ item_bin_init(ib_new, ib->type);
+ for (i = 0 ; i < count ; i++) {
+ if (i) {
+ p1.x=pa[i-1].x;
+ p1.y=pa[i-1].y;
+ p2.x=pa[i].x;
+ p2.y=pa[i].y;
+ /* 0 = invisible, 1 = completely visible, 3 = start point clipped, 5 = end point clipped, 7 both points clipped */
+ code=geom_clip_line_code(&p1, &p2, r);
#if 1
- if (((code == 1 || code == 5) && ib_new->clen == 0) || (code & 2)) {
- item_bin_add_coord(ib_new, &p1, 1);
- }
- if (code) {
- item_bin_add_coord(ib_new, &p2, 1);
- }
- if (i == count-1 || (code & 4)) {
- if (param->attr_to_copy)
- item_bin_copy_attr(ib_new, ib, param->attr_to_copy);
- if (ib_new->clen)
- item_bin_write_clipped(ib_new, param, out);
- item_bin_init(ib_new, ib->type);
- }
+ if (((code == 1 || code == 5) && ib_new->clen == 0) || (code & 2)) {
+ item_bin_add_coord(ib_new, &p1, 1);
+ }
+ if (code) {
+ item_bin_add_coord(ib_new, &p2, 1);
+ }
+ if (i == count-1 || (code & 4)) {
+ if (param->attr_to_copy)
+ item_bin_copy_attr(ib_new, ib, param->attr_to_copy);
+ if (ib_new->clen)
+ item_bin_write_clipped(ib_new, param, out);
+ item_bin_init(ib_new, ib->type);
+ }
#else
- if (code) {
- item_bin_init(ib_new, ib->type);
- item_bin_add_coord(ib_new, &p1, 1);
- item_bin_add_coord(ib_new, &p2, 1);
- if (param->attr_to_copy)
- item_bin_copy_attr(ib_new, ib, param->attr_to_copy);
- item_bin_write_clipped(ib_new, param, out);
- }
+ if (code) {
+ item_bin_init(ib_new, ib->type);
+ item_bin_add_coord(ib_new, &p1, 1);
+ item_bin_add_coord(ib_new, &p2, 1);
+ if (param->attr_to_copy)
+ item_bin_copy_attr(ib_new, ib, param->attr_to_copy);
+ item_bin_write_clipped(ib_new, param, out);
+ }
#endif
- }
- }
-}
-
-void
-clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out)
-{
- int count_in=ib->clen/2;
- struct coord *pin,*p,*s,pi;
- char *buffer1=g_alloca(sizeof(char)*(ib->len*4+ib->clen*7+32));
- struct item_bin *ib1=(struct item_bin *)buffer1;
- char *buffer2=g_alloca(sizeof(char)*(ib->len*4+ib->clen*7+32));
- struct item_bin *ib2=(struct item_bin *)buffer2;
- struct item_bin *ib_in,*ib_out;
- int edge,i;
- ib_out=ib1;
- ib_in=ib;
- for (edge = 0 ; edge < 4 ; edge++) {
- count_in=ib_in->clen/2;
- pin=(struct coord *)(ib_in+1);
- p=pin;
- s=pin+count_in-1;
- item_bin_init(ib_out, ib_in->type);
- for (i = 0 ; i < count_in ; i++) {
- if (geom_is_inside(p, r, edge)) {
- if (! geom_is_inside(s, r, edge)) {
- geom_poly_intersection(s,p,r,edge,&pi);
- item_bin_add_coord(ib_out, &pi, 1);
- }
- item_bin_add_coord(ib_out, p, 1);
- } else {
- if (geom_is_inside(s, r, edge)) {
- geom_poly_intersection(p,s,r,edge,&pi);
- item_bin_add_coord(ib_out, &pi, 1);
- }
- }
- s=p;
- p++;
- }
- if (ib_in == ib1) {
- ib_in=ib2;
- ib_out=ib1;
- } else {
- ib_in=ib1;
- ib_out=ib2;
- }
- }
- if (ib_in->clen) {
- if (param->attr_to_copy)
- item_bin_copy_attr(ib_in, ib, param->attr_to_copy);
- item_bin_write_clipped(ib_in, param, out);
- }
+ }
+ }
+}
+
+void clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out) {
+ int count_in=ib->clen/2;
+ struct coord *pin,*p,*s,pi;
+ char *buffer1=g_alloca(sizeof(char)*(ib->len*4+ib->clen*7+32));
+ struct item_bin *ib1=(struct item_bin *)buffer1;
+ char *buffer2=g_alloca(sizeof(char)*(ib->len*4+ib->clen*7+32));
+ struct item_bin *ib2=(struct item_bin *)buffer2;
+ struct item_bin *ib_in,*ib_out;
+ int edge,i;
+ ib_out=ib1;
+ ib_in=ib;
+ for (edge = 0 ; edge < 4 ; edge++) {
+ count_in=ib_in->clen/2;
+ pin=(struct coord *)(ib_in+1);
+ p=pin;
+ s=pin+count_in-1;
+ item_bin_init(ib_out, ib_in->type);
+ for (i = 0 ; i < count_in ; i++) {
+ if (geom_is_inside(p, r, edge)) {
+ if (! geom_is_inside(s, r, edge)) {
+ geom_poly_intersection(s,p,r,edge,&pi);
+ item_bin_add_coord(ib_out, &pi, 1);
+ }
+ item_bin_add_coord(ib_out, p, 1);
+ } else {
+ if (geom_is_inside(s, r, edge)) {
+ geom_poly_intersection(p,s,r,edge,&pi);
+ item_bin_add_coord(ib_out, &pi, 1);
+ }
+ }
+ s=p;
+ p++;
+ }
+ if (ib_in == ib1) {
+ ib_in=ib2;
+ ib_out=ib1;
+ } else {
+ ib_in=ib1;
+ ib_out=ib2;
+ }
+ }
+ if (ib_in->clen) {
+ if (param->attr_to_copy)
+ item_bin_copy_attr(ib_in, ib, param->attr_to_copy);
+ item_bin_write_clipped(ib_in, param, out);
+ }
}
diff --git a/navit/maptool/itembin_buffer.c b/navit/maptool/itembin_buffer.c
index 980749539..a3d63cf17 100644
--- a/navit/maptool/itembin_buffer.c
+++ b/navit/maptool/itembin_buffer.c
@@ -30,48 +30,44 @@ struct item_bin *tmp_item_bin=(struct item_bin *)(void *)misc_item_buffer;
static struct node_item *tmp_node_item=(struct node_item *)(void *)misc_item_buffer;
struct node_item *
-read_node_item(FILE *in)
-{
- if (fread(tmp_node_item, sizeof(struct node_item), 1, in) != 1)
- return NULL;
- return tmp_node_item;
+read_node_item(FILE *in) {
+ if (fread(tmp_node_item, sizeof(struct node_item), 1, in) != 1)
+ return NULL;
+ return tmp_node_item;
}
struct item_bin *
-read_item(FILE *in)
-{
- struct item_bin *ib=(struct item_bin *) misc_item_buffer;
- for (;;) {
- switch (item_bin_read(ib, in)) {
- case 0:
- return NULL;
- case 2:
- dbg_assert((ib->len+1)*4 < sizeof(misc_item_buffer));
- bytes_read+=(ib->len+1)*sizeof(int);
- return ib;
- default:
- continue;
- }
- }
+read_item(FILE *in) {
+ struct item_bin *ib=(struct item_bin *) misc_item_buffer;
+ for (;;) {
+ switch (item_bin_read(ib, in)) {
+ case 0:
+ return NULL;
+ case 2:
+ dbg_assert((ib->len+1)*4 < sizeof(misc_item_buffer));
+ bytes_read+=(ib->len+1)*sizeof(int);
+ return ib;
+ default:
+ continue;
+ }
+ }
}
struct item_bin *
-read_item_range(FILE *in, int *min, int *max)
-{
- struct range r;
+read_item_range(FILE *in, int *min, int *max) {
+ struct range r;
- if (fread(&r, sizeof(r), 1, in) != 1)
- return NULL;
- *min=r.min;
- *max=r.max;
- return read_item(in);
+ if (fread(&r, sizeof(r), 1, in) != 1)
+ return NULL;
+ *min=r.min;
+ *max=r.max;
+ return read_item(in);
}
struct item_bin *
-init_item(enum item_type type)
-{
- struct item_bin *ib=(struct item_bin *) misc_item_buffer;
+init_item(enum item_type type) {
+ struct item_bin *ib=(struct item_bin *) misc_item_buffer;
- item_bin_init(ib, type);
- return ib;
+ item_bin_init(ib, type);
+ return ib;
}
diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c
index b1db65eeb..422bc96bf 100644
--- a/navit/maptool/maptool.c
+++ b/navit/maptool/maptool.c
@@ -26,6 +26,7 @@
#include <signal.h>
#include <stdio.h>
#include <math.h>
+#include <errno.h>
#ifdef _MSC_VER
#include "getopt_long.h"
#define atoll _atoi64
@@ -57,12 +58,13 @@ int slices;
int unknown_country;
char ch_suffix[] ="r"; /* Used to make compiler happy due to Bug 35903 in gcc */
/** Textual description of available experimental features, or NULL (=none available). */
-char* experimental_feature_description = "Move coastline data to order 6 tiles. Makes map look more smooth, but may affect drawing/searching performance."; /* add description here */
+char* experimental_feature_description =
+ "Move coastline data to order 6 tiles. Makes map look more smooth, but may affect drawing/searching performance."; /* add description here */
/** Indicates if experimental features (if available) were enabled. */
int experimental;
struct buffer node_buffer = {
- 64*1024*1024,
+ 64*1024*1024,
};
int processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles;
@@ -80,1028 +82,1001 @@ static struct timespec start_ts;
/*
Asynchronous signal safe lltoa function (note: no trailing \0 char!)
*/
-static int assafe_lltoa(long long n, int maxlen, char *buf)
-{
- int i;
- int out_length;
+static int assafe_lltoa(long long n, int maxlen, char *buf) {
+ int i;
+ int out_length;
- if(maxlen<1)
- return 0;
+ if(maxlen<1)
+ return 0;
- if(n<0) {
- n=-n;
- buf[0]='-';
- maxlen--;
- buf++;
- } else if(n==0) {
- buf[0]='0';
- return 1;
- }
+ if(n<0) {
+ n=-n;
+ buf[0]='-';
+ maxlen--;
+ buf++;
+ } else if(n==0) {
+ buf[0]='0';
+ return 1;
+ }
- for(i=0; n>0 && i<maxlen; i++) {
- buf[i]='0'+(n%10);
- n/=10;
- }
- out_length=i;
- for(i=0;i<out_length/2;i++) {
- char c=buf[i];
- buf[i]=buf[out_length-i-1];
- buf[out_length-i-1]=c;
- }
- return out_length;
+ for(i=0; n>0 && i<maxlen; i++) {
+ buf[i]='0'+(n%10);
+ n/=10;
+ }
+ out_length=i;
+ for(i=0; i<out_length/2; i++) {
+ char c=buf[i];
+ buf[i]=buf[out_length-i-1];
+ buf[out_length-i-1]=c;
+ }
+ return out_length;
}
/*
Asynchronous signal safe string copy to buffer function (note: no trailing \0 char!)
*/
-static int assafe_strcp2buf(char *str, int maxlen, char *buf)
-{
- int i;
- for(i=0;str[i] && i<maxlen;i++)
- buf[i]=str[i];
- return i;
+static int assafe_strcp2buf(char *str, int maxlen, char *buf) {
+ int i;
+ for(i=0; str[i] && i<maxlen; i++)
+ buf[i]=str[i];
+ return i;
}
-static void
-progress_time(void)
-{
- struct timespec ts;
- int seconds;
- const int buflen=20;
- char buf[buflen];
- int pos=1;
- buf[0]=' ';
+static void progress_time(void) {
+ struct timespec ts;
+ int seconds;
+ const int buflen=20;
+ char buf[buflen];
+ int pos=1;
+ buf[0]=' ';
#ifdef _WIN32
- gettimeofday(&ts, NULL);
+ gettimeofday(&ts, NULL);
#else
- clock_gettime(CLOCK_REALTIME, &ts);
+ clock_gettime(CLOCK_REALTIME, &ts);
#endif
- seconds=ts.tv_sec-start_ts.tv_sec;
- pos+=assafe_lltoa(seconds/60, buflen-pos, buf+pos);
- seconds%=60;
- pos+=assafe_strcp2buf(seconds>9?":":":0", buflen-pos, buf+pos);
- pos+=assafe_lltoa(seconds, buflen-pos, buf+pos);
- write(2,buf,pos);
+ seconds=ts.tv_sec-start_ts.tv_sec;
+ pos+=assafe_lltoa(seconds/60, buflen-pos, buf+pos);
+ seconds%=60;
+ pos+=assafe_strcp2buf(seconds>9?":":":0", buflen-pos, buf+pos);
+ pos+=assafe_lltoa(seconds, buflen-pos, buf+pos);
+ if (write(2,buf,pos) == -1) {
+ dbg(lvl_warning, "Writing progress time failed. Error-Code: %d", errno);
+ }
}
-static void
-progress_memory(void)
-{
+static void progress_memory(void) {
#ifdef HAVE_SBRK
- long mem=(long)sbrk(0)-start_brk;
- const int buflen=20;
- char buf[buflen];
- int pos=1;
- buf[0]=' ';
- pos+=assafe_lltoa(mem/1024/1024, buflen-pos, buf+pos);
- pos+=assafe_strcp2buf(" MB", buflen-pos, buf+pos);
- write(2,buf,pos);
+ long mem=(long)sbrk(0)-start_brk;
+ const int buflen=20;
+ char buf[buflen];
+ int pos=1;
+ int write_result;
+ buf[0]=' ';
+ pos+=assafe_lltoa(mem/1024/1024, buflen-pos, buf+pos);
+ pos+=assafe_strcp2buf(" MB", buflen-pos, buf+pos);
+ write_result = write(2,buf,pos);
+ if (write_result == -1) {
+ dbg(lvl_warning, "Writing progress memory failed. Error-Code: %d", errno);
+ }
#endif
}
-static void
-sig_alrm_do(int sig)
-{
- const int buflen=1024;
- char buf[buflen];
- int pos=0;
+static void sig_alrm_do(int sig) {
+ const int buflen=1024;
+ char buf[buflen];
+ int pos=0;
+ int write_result;
#ifndef _WIN32
- signal(SIGALRM, sig_alrm_do);
- alarm(30);
+ signal(SIGALRM, sig_alrm_do);
+ alarm(30);
#endif
- pos+=assafe_strcp2buf("PROGRESS", buflen-pos, buf+pos);
- pos+=assafe_lltoa(phase, buflen-pos, buf+pos);
- pos+=assafe_strcp2buf(": Processed ", buflen-pos, buf+pos);
- pos+=assafe_lltoa(processed_nodes, buflen-pos, buf+pos);
- pos+=assafe_strcp2buf(" nodes (", buflen-pos, buf+pos);
- pos+=assafe_lltoa(processed_nodes_out, buflen-pos, buf+pos);
- pos+=assafe_strcp2buf(" out) ", buflen-pos, buf+pos);
- pos+=assafe_lltoa(processed_ways, buflen-pos, buf+pos);
- pos+=assafe_strcp2buf(" ways ", buflen-pos, buf+pos);
- pos+=assafe_lltoa(processed_relations, buflen-pos, buf+pos);
- pos+=assafe_strcp2buf(" relations ", buflen-pos, buf+pos);
- pos+=assafe_lltoa(processed_tiles, buflen-pos, buf+pos);
- pos+=assafe_strcp2buf(" tiles", buflen-pos, buf+pos);
- write(2,buf,pos);
- progress_time();
- progress_memory();
+ pos+=assafe_strcp2buf("PROGRESS", buflen-pos, buf+pos);
+ pos+=assafe_lltoa(phase, buflen-pos, buf+pos);
+ pos+=assafe_strcp2buf(": Processed ", buflen-pos, buf+pos);
+ pos+=assafe_lltoa(processed_nodes, buflen-pos, buf+pos);
+ pos+=assafe_strcp2buf(" nodes (", buflen-pos, buf+pos);
+ pos+=assafe_lltoa(processed_nodes_out, buflen-pos, buf+pos);
+ pos+=assafe_strcp2buf(" out) ", buflen-pos, buf+pos);
+ pos+=assafe_lltoa(processed_ways, buflen-pos, buf+pos);
+ pos+=assafe_strcp2buf(" ways ", buflen-pos, buf+pos);
+ pos+=assafe_lltoa(processed_relations, buflen-pos, buf+pos);
+ pos+=assafe_strcp2buf(" relations ", buflen-pos, buf+pos);
+ pos+=assafe_lltoa(processed_tiles, buflen-pos, buf+pos);
+ pos+=assafe_strcp2buf(" tiles", buflen-pos, buf+pos);
+ write_result = write(2,buf,pos);
+ if (write_result == -1) {
+ dbg(lvl_warning, "Writing sig alrm ailed. Error-Code: %d", errno);
+ }
+ progress_time();
+ progress_memory();
#ifndef _WIN32
- write(2,"\r\n",2);
+ write_result = write(2,"\r\n",2);
+ if (write_result == -1) {
+ dbg(lvl_warning, "Writing new line in sig alrm ailed. Error-Code: %d", errno);
+ }
#else
- write(2,"\n",1);
+ write_result = write(2,"\n",1);
+ if (write_result == -1) {
+ dbg(lvl_warning, "Writing new line in sig alrm ailed. Error-Code: %d", errno);
+ }
#endif
}
-void
-sig_alrm(int sig)
-{
- fflush(stderr);
- sig_alrm_do(sig);
+void sig_alrm(int sig) {
+ fflush(stderr);
+ sig_alrm_do(sig);
}
-void
-sig_alrm_end(void)
-{
+void sig_alrm_end(void) {
#ifndef _WIN32
- alarm(0);
+ alarm(0);
#endif
}
-static struct files_relation_processing *
-files_relation_processing_new(FILE *line2poi, char *suffix) {
- struct files_relation_processing *result = g_new(struct files_relation_processing, 1);
- result->ways_in=tempfile(suffix,"ways_split",0);
- result->ways_out=tempfile(suffix,"ways_split_relproc_tmp",1);
- result->nodes_in=tempfile(suffix,"nodes",0);
- result->nodes_out=tempfile(suffix,"nodes_relproc_tmp",1);
- result->nodes2_in=NULL;
- result->nodes2_out=NULL;
- if(line2poi) {
- result->nodes2_in=tempfile(suffix,"way2poi_result",0);
- result->nodes2_out=tempfile(suffix,"way2poi_result_relproc_tmp",1);
- }
- return result;
+static struct files_relation_processing *files_relation_processing_new(FILE *line2poi, char *suffix) {
+ struct files_relation_processing *result = g_new(struct files_relation_processing, 1);
+ result->ways_in=tempfile(suffix,"ways_split",0);
+ result->ways_out=tempfile(suffix,"ways_split_relproc_tmp",1);
+ result->nodes_in=tempfile(suffix,"nodes",0);
+ result->nodes_out=tempfile(suffix,"nodes_relproc_tmp",1);
+ result->nodes2_in=NULL;
+ result->nodes2_out=NULL;
+ if(line2poi) {
+ result->nodes2_in=tempfile(suffix,"way2poi_result",0);
+ result->nodes2_out=tempfile(suffix,"way2poi_result_relproc_tmp",1);
+ }
+ return result;
}
-static void
-files_relation_processing_destroy(struct files_relation_processing *files_relproc, char *suffix) {
- fclose(files_relproc->ways_in);
- fclose(files_relproc->nodes_in);
- fclose(files_relproc->ways_out);
- fclose(files_relproc->nodes_out);
- tempfile_rename(suffix,"ways_split_relproc_tmp","ways_split");
- tempfile_rename(suffix,"nodes_relproc_tmp","nodes");
- if(files_relproc->nodes2_in) {
- fclose(files_relproc->nodes2_in);
- fclose(files_relproc->nodes2_out);
- tempfile_rename(suffix,"way2poi_result_relproc_tmp","way2poi_result");
- }
- g_free(files_relproc);
+static void files_relation_processing_destroy(struct files_relation_processing *files_relproc, char *suffix) {
+ fclose(files_relproc->ways_in);
+ fclose(files_relproc->nodes_in);
+ fclose(files_relproc->ways_out);
+ fclose(files_relproc->nodes_out);
+ tempfile_rename(suffix,"ways_split_relproc_tmp","ways_split");
+ tempfile_rename(suffix,"nodes_relproc_tmp","nodes");
+ if(files_relproc->nodes2_in) {
+ fclose(files_relproc->nodes2_in);
+ fclose(files_relproc->nodes2_out);
+ tempfile_rename(suffix,"way2poi_result_relproc_tmp","way2poi_result");
+ }
+ g_free(files_relproc);
}
static struct plugins *plugins;
-static void add_plugin(char *path)
-{
- struct attr pa_attr={attr_path};
- struct attr pl_attr={attr_plugins};
- struct attr *attrs[2]={&pa_attr,NULL};
+static void add_plugin(char *path) {
+ struct attr pa_attr= {attr_path};
+ struct attr pl_attr= {attr_plugins};
+ struct attr *attrs[2]= {&pa_attr,NULL};
- if (! plugins) {
- file_init();
- plugins=plugins_new();
- }
- pa_attr.u.str=path;
- pl_attr.u.plugins=plugins;
- plugin_new(&pl_attr,attrs);
+ if (! plugins) {
+ file_init();
+ plugins=plugins_new();
+ }
+ pa_attr.u.str=path;
+ pl_attr.u.plugins=plugins;
+ plugin_new(&pl_attr,attrs);
}
-static void
-maptool_init(FILE* rule_file)
-{
- if (plugins)
- plugins_init(plugins);
- osm_init(rule_file);
+static void maptool_init(FILE* rule_file) {
+ if (plugins)
+ plugins_init(plugins);
+ osm_init(rule_file);
}
-static void
-usage(void)
-{
- FILE *f = stdout;
- /* DEVELOPERS : don't forget to update the manpage if you modify theses options */
- fprintf(f,"\n");
- fprintf(f,"maptool - parse osm textfile and convert to Navit binfile format\n\n");
- fprintf(f,"Usage (for OSM XML data):\n");
- fprintf(f,"bzcat planet.osm.bz2 | maptool mymap.bin\n");
- fprintf(f,"Usage (for OSM Protobuf/PBF data):\n");
- fprintf(f,"maptool --protobuf -i planet.osm.pbf planet.bin\n");
- fprintf(f,"Available switches:\n");
- fprintf(f,"-h (--help) : this screen\n");
- fprintf(f,"-6 (--64bit) : set zip 64 bit compression\n");
- fprintf(f,"-a (--attr-debug-level) <level> : control which data is included in the debug attribute\n");
- fprintf(f,"-c (--dump-coordinates) : dump coordinates after phase 1\n");
+static void usage(void) {
+ FILE *f = stdout;
+ /* DEVELOPERS : don't forget to update the manpage if you modify theses options */
+ fprintf(f,"\n");
+ fprintf(f,"maptool - parse osm textfile and convert to Navit binfile format\n\n");
+ fprintf(f,"Usage (for OSM XML data):\n");
+ fprintf(f,"bzcat planet.osm.bz2 | maptool mymap.bin\n");
+ fprintf(f,"Usage (for OSM Protobuf/PBF data):\n");
+ fprintf(f,"maptool --protobuf -i planet.osm.pbf planet.bin\n");
+ fprintf(f,"Available switches:\n");
+ fprintf(f,"-h (--help) : this screen\n");
+ fprintf(f,"-6 (--64bit) : set zip 64 bit compression\n");
+ fprintf(f,"-a (--attr-debug-level) <level> : control which data is included in the debug attribute\n");
+ fprintf(f,"-c (--dump-coordinates) : dump coordinates after phase 1\n");
#ifdef HAVE_POSTGRESQL
- fprintf(f,"-d (--db) <conn. string> : get osm data out of a postgresql database with osm simple scheme and given connect string\n");
+ fprintf(f,
+ "-d (--db) <conn. string> : get osm data out of a postgresql database with osm simple scheme and given connect string\n");
#endif
- fprintf(f,"-D (--dump) : dump map data to standard output in Navit textfile format\n");
- fprintf(f,"-e (--end) <phase> : end at specified phase\n");
- fprintf(f,"-E (--experimental) : Enable experimental features (%s)\n",
- experimental_feature_description ? experimental_feature_description : "-not available in this version-");
- fprintf(f,"-i (--input-file) <file> : specify the input file name (OSM), overrules default stdin\n");
- fprintf(f,"-k (--keep-tmpfiles) : do not delete tmp files after processing. useful to reuse them\n");
- fprintf(f,"-M (--o5m) : input data is in o5m format\n");
- fprintf(f,"-n (--ignore-unknown) : do not output ways and nodes with unknown type\n");
- fprintf(f,"-N (--nodes-only) : process only nodes\n");
- fprintf(f,"-P (--protobuf) : input data is in pbf (Protocol Buffer) format\n");
- fprintf(f,"-r (--rule-file) <file> : read mapping rules from specified file\n");
- fprintf(f,"-s (--start) <phase> : start at specified phase\n");
- fprintf(f,"-S (--slice-size) <size> : limit memory to use for some large internal buffers, in bytes. Default is %dGB.\n", SLIZE_SIZE_DEFAULT_GB);
- fprintf(f,"-t (--timestamp) <y-m-dTh:m:s> : Set zip timestamp\n");
- fprintf(f,"-w (--dedupe-ways) : ensure no duplicate ways or nodes. useful when using several input files\n");
- fprintf(f,"-W (--ways-only) : process only ways\n");
- fprintf(f,"-U (--unknown-country) : add objects with unknown country to index\n");
- fprintf(f,"-x (--index-size) : set maximum country index size in bytes\n");
- fprintf(f,"-z (--compression-level) <level> : set the compression level\n");
- fprintf(f,"Internal options (undocumented):\n");
- fprintf(f,"-b (--binfile)\n");
- fprintf(f,"-B \n");
- fprintf(f,"-m (--map) \n");
- fprintf(f,"-O \n");
- fprintf(f,"-p (--plugin) \n");
- fprintf(f,"-u (--url) \n");
-
- exit(0);
+ fprintf(f,"-D (--dump) : dump map data to standard output in Navit textfile format\n");
+ fprintf(f,"-e (--end) <phase> : end at specified phase\n");
+ fprintf(f,"-E (--experimental) : Enable experimental features (%s)\n",
+ experimental_feature_description ? experimental_feature_description : "-not available in this version-");
+ fprintf(f,"-i (--input-file) <file> : specify the input file name (OSM), overrules default stdin\n");
+ fprintf(f,"-k (--keep-tmpfiles) : do not delete tmp files after processing. useful to reuse them\n");
+ fprintf(f,"-M (--o5m) : input data is in o5m format\n");
+ fprintf(f,"-n (--ignore-unknown) : do not output ways and nodes with unknown type\n");
+ fprintf(f,"-N (--nodes-only) : process only nodes\n");
+ fprintf(f,"-P (--protobuf) : input data is in pbf (Protocol Buffer) format\n");
+ fprintf(f,"-r (--rule-file) <file> : read mapping rules from specified file\n");
+ fprintf(f,"-s (--start) <phase> : start at specified phase\n");
+ fprintf(f,
+ "-S (--slice-size) <size> : limit memory to use for some large internal buffers, in bytes. Default is %dGB.\n",
+ SLIZE_SIZE_DEFAULT_GB);
+ fprintf(f,"-t (--timestamp) <y-m-dTh:m:s> : Set zip timestamp\n");
+ fprintf(f,
+ "-w (--dedupe-ways) : ensure no duplicate ways or nodes. useful when using several input files\n");
+ fprintf(f,"-W (--ways-only) : process only ways\n");
+ fprintf(f,"-U (--unknown-country) : add objects with unknown country to index\n");
+ fprintf(f,"-x (--index-size) : set maximum country index size in bytes\n");
+ fprintf(f,"-z (--compression-level) <level> : set the compression level\n");
+ fprintf(f,"Internal options (undocumented):\n");
+ fprintf(f,"-b (--binfile)\n");
+ fprintf(f,"-B \n");
+ fprintf(f,"-m (--map) \n");
+ fprintf(f,"-O \n");
+ fprintf(f,"-p (--plugin) \n");
+ fprintf(f,"-u (--url) \n");
+
+ exit(0);
}
struct maptool_params {
- int zip64;
- int keep_tmpfiles;
- int process_nodes;
- int process_ways;
- int process_relations;
- char *protobufdb;
- char *protobufdb_operation;
- int start;
- int end;
- int dump;
- int o5m;
- int compression_level;
- int protobuf;
- int dump_coordinates;
- int input;
- GList *map_handles;
- FILE* input_file;
- FILE* rule_file;
- char *url;
- struct maptool_osm osm;
- FILE *ways_split;
- char *timestamp;
- char *result;
- char *dbstr;
- int node_table_loaded;
- int countries_loaded;
- int tilesdir_loaded;
- int max_index_size;
+ int zip64;
+ int keep_tmpfiles;
+ int process_nodes;
+ int process_ways;
+ int process_relations;
+ char *protobufdb;
+ char *protobufdb_operation;
+ int start;
+ int end;
+ int dump;
+ int o5m;
+ int compression_level;
+ int protobuf;
+ int dump_coordinates;
+ int input;
+ GList *map_handles;
+ FILE* input_file;
+ FILE* rule_file;
+ char *url;
+ struct maptool_osm osm;
+ FILE *ways_split;
+ char *timestamp;
+ char *result;
+ char *dbstr;
+ int node_table_loaded;
+ int countries_loaded;
+ int tilesdir_loaded;
+ int max_index_size;
};
-static int
-parse_option(struct maptool_params *p, char **argv, int argc, int *option_index)
-{
- char *optarg_cp,*attr_name,*attr_value;
- struct map *handle;
- struct attr *attrs[10];
- int pos,c,i;
+static int parse_option(struct maptool_params *p, char **argv, int argc, int *option_index) {
+ char *optarg_cp,*attr_name,*attr_value;
+ struct map *handle;
+ struct attr *attrs[10];
+ int pos,c,i;
- static struct option long_options[] = {
- {"64bit", 0, 0, '6'},
- {"attr-debug-level", 1, 0, 'a'},
- {"binfile", 0, 0, 'b'},
- {"compression-level", 1, 0, 'z'},
+ static struct option long_options[] = {
+ {"64bit", 0, 0, '6'},
+ {"attr-debug-level", 1, 0, 'a'},
+ {"binfile", 0, 0, 'b'},
+ {"compression-level", 1, 0, 'z'},
#ifdef HAVE_POSTGRESQL
- {"db", 1, 0, 'd'},
+ {"db", 1, 0, 'd'},
#endif
- {"dedupe-ways", 0, 0, 'w'},
- {"dump", 0, 0, 'D'},
- {"dump-coordinates", 0, 0, 'c'},
- {"end", 1, 0, 'e'},
- {"experimental", 0, 0, 'E'},
- {"help", 0, 0, 'h'},
- {"keep-tmpfiles", 0, 0, 'k'},
- {"nodes-only", 0, 0, 'N'},
- {"map", 1, 0, 'm'},
- {"o5m", 0, 0, 'M'},
- {"plugin", 1, 0, 'p'},
- {"protobuf", 0, 0, 'P'},
- {"start", 1, 0, 's'},
- {"timestamp", 1, 0, 't'},
- {"input-file", 1, 0, 'i'},
- {"rule-file", 1, 0, 'r'},
- {"ignore-unknown", 0, 0, 'n'},
- {"url", 1, 0, 'u'},
- {"ways-only", 0, 0, 'W'},
- {"slice-size", 1, 0, 'S'},
- {"unknown-country", 0, 0, 'U'},
- {"index-size", 0, 0, 'x'},
- {0, 0, 0, 0}
- };
- c = getopt_long (argc, argv, "6B:DEMNO:PS:Wa:bc"
+ {"dedupe-ways", 0, 0, 'w'},
+ {"dump", 0, 0, 'D'},
+ {"dump-coordinates", 0, 0, 'c'},
+ {"end", 1, 0, 'e'},
+ {"experimental", 0, 0, 'E'},
+ {"help", 0, 0, 'h'},
+ {"keep-tmpfiles", 0, 0, 'k'},
+ {"nodes-only", 0, 0, 'N'},
+ {"map", 1, 0, 'm'},
+ {"o5m", 0, 0, 'M'},
+ {"plugin", 1, 0, 'p'},
+ {"protobuf", 0, 0, 'P'},
+ {"start", 1, 0, 's'},
+ {"timestamp", 1, 0, 't'},
+ {"input-file", 1, 0, 'i'},
+ {"rule-file", 1, 0, 'r'},
+ {"ignore-unknown", 0, 0, 'n'},
+ {"url", 1, 0, 'u'},
+ {"ways-only", 0, 0, 'W'},
+ {"slice-size", 1, 0, 'S'},
+ {"unknown-country", 0, 0, 'U'},
+ {"index-size", 0, 0, 'x'},
+ {0, 0, 0, 0}
+ };
+ c = getopt_long (argc, argv, "6B:DEMNO:PS:Wa:bc"
#ifdef HAVE_POSTGRESQL
- "d:"
+ "d:"
#endif
- "e:hi:knm:p:r:s:t:wu:z:Ux:", long_options, option_index);
- if (c == -1)
- return 1;
- switch (c) {
- case '6':
- p->zip64=1;
- break;
- case 'B':
- p->protobufdb=optarg;
- break;
- case 'D':
- p->dump=1;
- break;
- case 'E':
- experimental=1;
- break;
- case 'M':
- p->o5m=1;
- break;
- case 'N':
- p->process_ways=0;
- break;
- case 'R':
- p->process_relations=0;
- break;
- case 'O':
- p->protobufdb_operation=optarg;
- p->dump=1;
- break;
- case 'P':
- p->protobuf=1;
- break;
- case 'S':
- slice_size=atoll(optarg);
- break;
- case 'W':
- p->process_nodes=0;
- break;
- case 'U':
- unknown_country=1;
- break;
- case 'a':
- attr_debug_level=atoi(optarg);
- break;
- case 'b':
- p->input=1;
- break;
- case 'c':
- p->dump_coordinates=1;
- break;
+ "e:hi:knm:p:r:s:t:wu:z:Ux:", long_options, option_index);
+ if (c == -1)
+ return 1;
+ switch (c) {
+ case '6':
+ p->zip64=1;
+ break;
+ case 'B':
+ p->protobufdb=optarg;
+ break;
+ case 'D':
+ p->dump=1;
+ break;
+ case 'E':
+ experimental=1;
+ break;
+ case 'M':
+ p->o5m=1;
+ break;
+ case 'N':
+ p->process_ways=0;
+ break;
+ case 'R':
+ p->process_relations=0;
+ break;
+ case 'O':
+ p->protobufdb_operation=optarg;
+ p->dump=1;
+ break;
+ case 'P':
+ p->protobuf=1;
+ break;
+ case 'S':
+ slice_size=atoll(optarg);
+ break;
+ case 'W':
+ p->process_nodes=0;
+ break;
+ case 'U':
+ unknown_country=1;
+ break;
+ case 'a':
+ attr_debug_level=atoi(optarg);
+ break;
+ case 'b':
+ p->input=1;
+ break;
+ case 'c':
+ p->dump_coordinates=1;
+ break;
#ifdef HAVE_POSTGRESQL
- case 'd':
- p->dbstr=optarg;
- break;
+ case 'd':
+ p->dbstr=optarg;
+ break;
#endif
- case 'e':
- p->end=atoi(optarg);
- break;
- case 'h':
- return 2;
- case 'm':
- optarg_cp=g_strdup(optarg);
- pos=0;
- i=0;
- attr_name=g_strdup(optarg);
- attr_value=g_strdup(optarg);
- while (i < 9 && attr_from_line(optarg_cp, NULL, &pos, attr_value, attr_name)) {
- attrs[i]=attr_new_from_text(attr_name,attr_value);
- if (attrs[i]) {
- i++;
- } else {
- fprintf(stderr,"Failed to convert %s=%s to attribute\n",attr_name,attr_value);
- }
- attr_value=g_strdup(optarg);
- }
- attrs[i++]=NULL;
- g_free(attr_value);
- g_free(optarg_cp);
- handle=map_new(NULL, attrs);
- if (! handle) {
- fprintf(stderr,"Failed to create map from attributes\n");
- exit(1);
- }
- p->map_handles=g_list_append(p->map_handles,handle);
- break;
- case 'n':
- fprintf(stderr,"I will IGNORE unknown types\n");
- ignore_unknown=1;
- break;
- case 'k':
- fprintf(stderr,"I will KEEP tmp files\n");
- p->keep_tmpfiles=1;
- break;
- case 'p':
- add_plugin(optarg);
- break;
- case 's':
- p->start=atoi(optarg);
- break;
- case 't':
- p->timestamp=optarg;
- break;
- case 'w':
- dedupe_ways_hash=g_hash_table_new(NULL, NULL);
- break;
- case 'i':
- p->input_file = fopen( optarg, "r" );
- if (p->input_file == NULL )
- {
- fprintf( stderr, "\nInput file (%s) not found\n", optarg );
- exit( 1 );
- }
- break;
- case 'r':
- p->rule_file = fopen( optarg, "r" );
- if (p->rule_file == NULL )
- {
- fprintf( stderr, "\nRule file (%s) not found\n", optarg );
- exit( 1 );
- }
- break;
- case 'u':
- p->url=optarg;
- break;
- case 'x':
- p->max_index_size=atoi(optarg);
- break;
+ case 'e':
+ p->end=atoi(optarg);
+ break;
+ case 'h':
+ return 2;
+ case 'm':
+ optarg_cp=g_strdup(optarg);
+ pos=0;
+ i=0;
+ attr_name=g_strdup(optarg);
+ attr_value=g_strdup(optarg);
+ while (i < 9 && attr_from_line(optarg_cp, NULL, &pos, attr_value, attr_name)) {
+ attrs[i]=attr_new_from_text(attr_name,attr_value);
+ if (attrs[i]) {
+ i++;
+ } else {
+ fprintf(stderr,"Failed to convert %s=%s to attribute\n",attr_name,attr_value);
+ }
+ attr_value=g_strdup(optarg);
+ }
+ attrs[i++]=NULL;
+ g_free(attr_value);
+ g_free(optarg_cp);
+ handle=map_new(NULL, attrs);
+ if (! handle) {
+ fprintf(stderr,"Failed to create map from attributes\n");
+ exit(1);
+ }
+ p->map_handles=g_list_append(p->map_handles,handle);
+ break;
+ case 'n':
+ fprintf(stderr,"I will IGNORE unknown types\n");
+ ignore_unknown=1;
+ break;
+ case 'k':
+ fprintf(stderr,"I will KEEP tmp files\n");
+ p->keep_tmpfiles=1;
+ break;
+ case 'p':
+ add_plugin(optarg);
+ break;
+ case 's':
+ p->start=atoi(optarg);
+ break;
+ case 't':
+ p->timestamp=optarg;
+ break;
+ case 'w':
+ dedupe_ways_hash=g_hash_table_new(NULL, NULL);
+ break;
+ case 'i':
+ p->input_file = fopen( optarg, "r" );
+ if (p->input_file == NULL ) {
+ fprintf( stderr, "\nInput file (%s) not found\n", optarg );
+ exit( 1 );
+ }
+ break;
+ case 'r':
+ p->rule_file = fopen( optarg, "r" );
+ if (p->rule_file == NULL ) {
+ fprintf( stderr, "\nRule file (%s) not found\n", optarg );
+ exit( 1 );
+ }
+ break;
+ case 'u':
+ p->url=optarg;
+ break;
+ case 'x':
+ p->max_index_size=atoi(optarg);
+ break;
#ifdef HAVE_ZLIB
- case 'z':
- p->compression_level=atoi(optarg);
- break;
+ case 'z':
+ p->compression_level=atoi(optarg);
+ break;
#endif
- case '?':
- default:
- return 0;
- }
- return 3;
+ case '?':
+ default:
+ return 0;
+ }
+ return 3;
}
-static int
-start_phase(struct maptool_params *p, char *str)
-{
- phase++;
- if (p->start <= phase && p->end >= phase) {
- fprintf(stderr,"PROGRESS: Phase %d: %s",phase,str);
- fflush(stderr);
- progress_time();
- progress_memory();
- fprintf(stderr,"\n");
- return 1;
- } else
- return 0;
+static int start_phase(struct maptool_params *p, char *str) {
+ phase++;
+ if (p->start <= phase && p->end >= phase) {
+ fprintf(stderr,"PROGRESS: Phase %d: %s",phase,str);
+ fflush(stderr);
+ progress_time();
+ progress_memory();
+ fprintf(stderr,"\n");
+ return 1;
+ } else
+ return 0;
}
-static void
-exit_with_error(char* error_message) {
- fprintf(stderr, "%s", error_message);
- exit(1);
+static void exit_with_error(char* error_message) {
+ fprintf(stderr, "%s", error_message);
+ exit(1);
}
-static void
-osm_read_input_data(struct maptool_params *p, char *suffix)
-{
- unlink("coords.tmp");
- if (p->process_ways)
- p->osm.ways=tempfile(suffix,"ways",1);
- if (p->process_nodes) {
- p->osm.nodes=tempfile(suffix,"nodes",1);
- p->osm.towns=tempfile(suffix,"towns",1);
- }
- if (p->process_ways && p->process_nodes) {
- p->osm.turn_restrictions=tempfile(suffix,"turn_restrictions",1);
- p->osm.line2poi=tempfile(suffix,"line2poi",1);
- p->osm.poly2poi=tempfile(suffix,"poly2poi",1);
- }
- if (p->process_relations) {
- p->osm.boundaries=tempfile(suffix,"boundaries",1);
- p->osm.associated_streets=tempfile(suffix,"associated_streets",1);
- p->osm.house_number_interpolations=tempfile(suffix,"house_number_interpolations",1);
- }
+static void osm_read_input_data(struct maptool_params *p, char *suffix) {
+ unlink("coords.tmp");
+ if (p->process_ways)
+ p->osm.ways=tempfile(suffix,"ways",1);
+ if (p->process_nodes) {
+ p->osm.nodes=tempfile(suffix,"nodes",1);
+ p->osm.towns=tempfile(suffix,"towns",1);
+ }
+ if (p->process_ways && p->process_nodes) {
+ p->osm.turn_restrictions=tempfile(suffix,"turn_restrictions",1);
+ p->osm.line2poi=tempfile(suffix,"line2poi",1);
+ p->osm.poly2poi=tempfile(suffix,"poly2poi",1);
+ }
+ if (p->process_relations) {
+ p->osm.boundaries=tempfile(suffix,"boundaries",1);
+ p->osm.associated_streets=tempfile(suffix,"associated_streets",1);
+ p->osm.house_number_interpolations=tempfile(suffix,"house_number_interpolations",1);
+ }
#ifdef HAVE_POSTGRESQL
- if (p->dbstr)
- map_collect_data_osm_db(p->dbstr,&p->osm);
- else
+ if (p->dbstr)
+ map_collect_data_osm_db(p->dbstr,&p->osm);
+ else
#endif
- if (p->map_handles) {
- GList *l;
- phase1_map(p->map_handles,p->osm.ways,p->osm.nodes);
- l=p->map_handles;
- while (l) {
- map_destroy(l->data);
- l=g_list_next(l);
- }
- }
- else if (p->protobuf) {
+ if (p->map_handles) {
+ GList *l;
+ phase1_map(p->map_handles,p->osm.ways,p->osm.nodes);
+ l=p->map_handles;
+ while (l) {
+ map_destroy(l->data);
+ l=g_list_next(l);
+ }
+ } else if (p->protobuf) {
#ifdef _MSC_VER
- exit_with_error("Option -P not yet supported on MSVC\n");
+ exit_with_error("Option -P not yet supported on MSVC\n");
#else
- map_collect_data_osm_protobuf(p->input_file,&p->osm);
+ map_collect_data_osm_protobuf(p->input_file,&p->osm);
#endif
- }
- else if (p->o5m)
- map_collect_data_osm_o5m(p->input_file,&p->osm);
- else
- map_collect_data_osm(p->input_file,&p->osm);
+ } else if (p->o5m)
+ map_collect_data_osm_o5m(p->input_file,&p->osm);
+ else
+ map_collect_data_osm(p->input_file,&p->osm);
- if (node_buffer.size==0 && !p->map_handles){
- fprintf(stderr,"No nodes found - looks like an invalid input file.\n");
- exit(1);
- }
- flush_nodes(1);
- if (p->osm.ways)
- fclose(p->osm.ways);
- if (p->osm.nodes)
- fclose(p->osm.nodes);
- if (p->osm.turn_restrictions)
- fclose(p->osm.turn_restrictions);
- if (p->osm.associated_streets)
- fclose(p->osm.associated_streets);
- if (p->osm.house_number_interpolations)
- fclose(p->osm.house_number_interpolations);
- if (p->osm.boundaries)
- fclose(p->osm.boundaries);
- if (p->osm.poly2poi)
- fclose(p->osm.poly2poi);
- if (p->osm.line2poi)
- fclose(p->osm.line2poi);
- if (p->osm.towns)
- fclose(p->osm.towns);
+ if (node_buffer.size==0 && !p->map_handles) {
+ fprintf(stderr,"No nodes found - looks like an invalid input file.\n");
+ exit(1);
+ }
+ flush_nodes(1);
+ if (p->osm.ways)
+ fclose(p->osm.ways);
+ if (p->osm.nodes)
+ fclose(p->osm.nodes);
+ if (p->osm.turn_restrictions)
+ fclose(p->osm.turn_restrictions);
+ if (p->osm.associated_streets)
+ fclose(p->osm.associated_streets);
+ if (p->osm.house_number_interpolations)
+ fclose(p->osm.house_number_interpolations);
+ if (p->osm.boundaries)
+ fclose(p->osm.boundaries);
+ if (p->osm.poly2poi)
+ fclose(p->osm.poly2poi);
+ if (p->osm.line2poi)
+ fclose(p->osm.line2poi);
+ if (p->osm.towns)
+ fclose(p->osm.towns);
}
int debug_ref=0;
-static void
-osm_count_references(struct maptool_params *p, char *suffix, int clear)
-{
- int i,first=1;
- fprintf(stderr,"%d slices\n",slices);
- for (i = slices-1 ; i>=0 ; i--) {
- fprintf(stderr, "slice %d of %d\n",slices-i-1,slices-1);
- if (!first) {
- FILE *ways=tempfile(suffix,"ways",0);
- load_buffer("coords.tmp",&node_buffer, i*slice_size, slice_size);
- if (clear)
- clear_node_item_buffer();
- ref_ways(ways);
- save_buffer("coords.tmp",&node_buffer, i*slice_size);
- fclose(ways);
- }
- FILE *poly2poi=tempfile(suffix,first?"poly2poi":"poly2poi_resolved",0);
- FILE *poly2poinew=tempfile(suffix,"poly2poi_resolved_new",1);
- FILE *line2poi=tempfile(suffix,first?"line2poi":"line2poi_resolved",0);
- FILE *line2poinew=tempfile(suffix,"line2poi_resolved_new",1);
- resolve_ways(poly2poi, poly2poinew);
- resolve_ways(line2poi, line2poinew);
- fclose(poly2poi);
- fclose(poly2poinew);
- fclose(line2poi);
- fclose(line2poinew);
- tempfile_rename(suffix,"poly2poi_resolved_new","poly2poi_resolved");
- tempfile_rename(suffix,"line2poi_resolved_new","line2poi_resolved");
- if (first && !p->keep_tmpfiles) {
- tempfile_unlink(suffix,"poly2poi");
- tempfile_unlink(suffix,"line2poi");
- }
- first=0;
- }
+static void osm_count_references(struct maptool_params *p, char *suffix, int clear) {
+ int i,first=1;
+ fprintf(stderr,"%d slices\n",slices);
+ for (i = slices-1 ; i>=0 ; i--) {
+ fprintf(stderr, "slice %d of %d\n",slices-i-1,slices-1);
+ if (!first) {
+ FILE *ways=tempfile(suffix,"ways",0);
+ load_buffer("coords.tmp",&node_buffer, i*slice_size, slice_size);
+ if (clear)
+ clear_node_item_buffer();
+ ref_ways(ways);
+ save_buffer("coords.tmp",&node_buffer, i*slice_size);
+ fclose(ways);
+ }
+ FILE *poly2poi=tempfile(suffix,first?"poly2poi":"poly2poi_resolved",0);
+ FILE *poly2poinew=tempfile(suffix,"poly2poi_resolved_new",1);
+ FILE *line2poi=tempfile(suffix,first?"line2poi":"line2poi_resolved",0);
+ FILE *line2poinew=tempfile(suffix,"line2poi_resolved_new",1);
+ resolve_ways(poly2poi, poly2poinew);
+ resolve_ways(line2poi, line2poinew);
+ fclose(poly2poi);
+ fclose(poly2poinew);
+ fclose(line2poi);
+ fclose(line2poinew);
+ tempfile_rename(suffix,"poly2poi_resolved_new","poly2poi_resolved");
+ tempfile_rename(suffix,"line2poi_resolved_new","line2poi_resolved");
+ if (first && !p->keep_tmpfiles) {
+ tempfile_unlink(suffix,"poly2poi");
+ tempfile_unlink(suffix,"line2poi");
+ }
+ first=0;
+ }
}
-static void
-osm_resolve_coords_and_split_at_intersections(struct maptool_params *p, char *suffix)
-{
- FILE *ways, *ways_split, *ways_split_index, *graph, *coastline;
- int i;
+static void osm_resolve_coords_and_split_at_intersections(struct maptool_params *p, char *suffix) {
+ FILE *ways, *ways_split, *ways_split_index, *graph, *coastline;
+ int i;
- ways=tempfile(suffix,"ways",0);
- for (i = 0 ; i < slices ; i++) {
- int final=(i >= slices-1);
- ways_split=tempfile(suffix,"ways_split",1);
- ways_split_index=final ? tempfile(suffix,"ways_split_index",1) : NULL;
- graph=tempfile(suffix,"graph",1);
- coastline=tempfile(suffix,"coastline",1);
- if (i)
- load_buffer("coords.tmp",&node_buffer, i*slice_size, slice_size);
- map_resolve_coords_and_split_at_intersections(ways,ways_split,ways_split_index,graph,coastline,final);
- fclose(ways_split);
- if (ways_split_index)
- fclose(ways_split_index);
- fclose(ways);
- fclose(graph);
- fclose(coastline);
- if (! final) {
- tempfile_rename(suffix,"ways_split","ways_to_resolve");
- ways=tempfile(suffix,"ways_to_resolve",0);
- }
- }
- if(!p->keep_tmpfiles)
- tempfile_unlink(suffix,"ways");
- tempfile_unlink(suffix,"ways_to_resolve");
+ ways=tempfile(suffix,"ways",0);
+ for (i = 0 ; i < slices ; i++) {
+ int final=(i >= slices-1);
+ ways_split=tempfile(suffix,"ways_split",1);
+ ways_split_index=final ? tempfile(suffix,"ways_split_index",1) : NULL;
+ graph=tempfile(suffix,"graph",1);
+ coastline=tempfile(suffix,"coastline",1);
+ if (i)
+ load_buffer("coords.tmp",&node_buffer, i*slice_size, slice_size);
+ map_resolve_coords_and_split_at_intersections(ways,ways_split,ways_split_index,graph,coastline,final);
+ fclose(ways_split);
+ if (ways_split_index)
+ fclose(ways_split_index);
+ fclose(ways);
+ fclose(graph);
+ fclose(coastline);
+ if (! final) {
+ tempfile_rename(suffix,"ways_split","ways_to_resolve");
+ ways=tempfile(suffix,"ways_to_resolve",0);
+ }
+ }
+ if(!p->keep_tmpfiles)
+ tempfile_unlink(suffix,"ways");
+ tempfile_unlink(suffix,"ways_to_resolve");
}
-static void
-osm_process_way2poi(struct maptool_params *p, char *suffix)
-{
- FILE *poly2poi=tempfile(suffix,"poly2poi_resolved",0);
- FILE *line2poi=tempfile(suffix,"line2poi_resolved",0);
- FILE *way2poi_result=tempfile(suffix,"way2poi_result",1);
- if (poly2poi) {
- process_way2poi(poly2poi, way2poi_result, type_area);
- fclose(poly2poi);
- }
- if (line2poi) {
- process_way2poi(line2poi, way2poi_result, type_line);
- fclose(line2poi);
- }
- fclose(way2poi_result);
+static void osm_process_way2poi(struct maptool_params *p, char *suffix) {
+ FILE *poly2poi=tempfile(suffix,"poly2poi_resolved",0);
+ FILE *line2poi=tempfile(suffix,"line2poi_resolved",0);
+ FILE *way2poi_result=tempfile(suffix,"way2poi_result",1);
+ if (poly2poi) {
+ process_way2poi(poly2poi, way2poi_result, type_area);
+ fclose(poly2poi);
+ }
+ if (line2poi) {
+ process_way2poi(line2poi, way2poi_result, type_line);
+ fclose(line2poi);
+ }
+ fclose(way2poi_result);
}
-static void
-osm_process_coastlines(struct maptool_params *p, char *suffix)
-{
- FILE *coastline=tempfile(suffix,"coastline",0);
- if (coastline) {
- FILE *coastline_result=tempfile(suffix,"coastline_result",1);
- process_coastlines(coastline, coastline_result);
- fclose(coastline_result);
- fclose(coastline);
- }
+static void osm_process_coastlines(struct maptool_params *p, char *suffix) {
+ FILE *coastline=tempfile(suffix,"coastline",0);
+ if (coastline) {
+ FILE *coastline_result=tempfile(suffix,"coastline_result",1);
+ process_coastlines(coastline, coastline_result);
+ fclose(coastline_result);
+ fclose(coastline);
+ }
}
-static void
-osm_process_turn_restrictions(struct maptool_params *p, char *suffix)
-{
- FILE *ways_split, *ways_split_index, *relations, *coords;
- p->osm.turn_restrictions=tempfile(suffix,"turn_restrictions",0);
- if (!p->osm.turn_restrictions)
- return;
- relations=tempfile(suffix,"relations",1);
- coords=fopen("coords.tmp","rb");
- ways_split=tempfile(suffix,"ways_split",0);
- ways_split_index=tempfile(suffix,"ways_split_index",0);
- process_turn_restrictions(p->osm.turn_restrictions,coords,ways_split,ways_split_index,relations);
- fclose(ways_split_index);
- fclose(ways_split);
- fclose(coords);
- fclose(relations);
- fclose(p->osm.turn_restrictions);
- if(!p->keep_tmpfiles)
- tempfile_unlink(suffix,"turn_restrictions");
+static void osm_process_turn_restrictions(struct maptool_params *p, char *suffix) {
+ FILE *ways_split, *ways_split_index, *relations, *coords;
+ p->osm.turn_restrictions=tempfile(suffix,"turn_restrictions",0);
+ if (!p->osm.turn_restrictions)
+ return;
+ relations=tempfile(suffix,"relations",1);
+ coords=fopen("coords.tmp","rb");
+ ways_split=tempfile(suffix,"ways_split",0);
+ ways_split_index=tempfile(suffix,"ways_split_index",0);
+ process_turn_restrictions(p->osm.turn_restrictions,coords,ways_split,ways_split_index,relations);
+ fclose(ways_split_index);
+ fclose(ways_split);
+ fclose(coords);
+ fclose(relations);
+ fclose(p->osm.turn_restrictions);
+ if(!p->keep_tmpfiles)
+ tempfile_unlink(suffix,"turn_restrictions");
}
-static void
-maptool_dump(struct maptool_params *p, char *suffix)
-{
- char *files[10];
- int i,files_count=0;
- if (p->process_nodes)
- files[files_count++]="nodes";
- if (p->process_ways)
- files[files_count++]="ways_split";
- if (p->process_relations)
- files[files_count++]="relations";
- for (i = 0 ; i < files_count ; i++) {
- FILE *f=tempfile(suffix,files[i],0);
- if (f) {
- dump(f);
- fclose(f);
- }
- }
+static void maptool_dump(struct maptool_params *p, char *suffix) {
+ char *files[10];
+ int i,files_count=0;
+ if (p->process_nodes)
+ files[files_count++]="nodes";
+ if (p->process_ways)
+ files[files_count++]="ways_split";
+ if (p->process_relations)
+ files[files_count++]="relations";
+ for (i = 0 ; i < files_count ; i++) {
+ FILE *f=tempfile(suffix,files[i],0);
+ if (f) {
+ dump(f);
+ fclose(f);
+ }
+ }
}
-static void
-maptool_generate_tiles(struct maptool_params *p, char *suffix, char **filenames, int filename_count, int first, char *suffix0)
-{
- struct zip_info *zip_info;
- FILE *tilesdir;
- FILE *files[10];
- int zipnum, f;
- if (first) {
- zip_info=zip_new();
- zip_set_zip64(zip_info, p->zip64);
- zip_set_timestamp(zip_info, p->timestamp);
- }
- zipnum=zip_get_zipnum(zip_info);
- tilesdir=tempfile(suffix,"tilesdir",1);
- if (!strcmp(suffix,ch_suffix)) { /* Makes compiler happy due to bug 35903 in gcc */
- ch_generate_tiles(suffix0,suffix,tilesdir,zip_info);
- } else {
- for (f = 0 ; f < filename_count ; f++)
- files[f]=tempfile(suffix,filenames[f],0);
- phase4(files,filename_count,0,suffix,tilesdir,zip_info);
- for (f = 0 ; f < filename_count ; f++) {
- if (files[f])
- fclose(files[f]);
- }
- }
- fclose(tilesdir);
- zip_set_zipnum(zip_info,zipnum);
+static void maptool_generate_tiles(struct maptool_params *p, char *suffix, char **filenames, int filename_count,
+ int first,
+ char *suffix0) {
+ struct zip_info *zip_info;
+ FILE *tilesdir;
+ FILE *files[10];
+ int zipnum, f;
+ if (first) {
+ zip_info=zip_new();
+ zip_set_zip64(zip_info, p->zip64);
+ zip_set_timestamp(zip_info, p->timestamp);
+ }
+ zipnum=zip_get_zipnum(zip_info);
+ tilesdir=tempfile(suffix,"tilesdir",1);
+ if (!g_strcmp0(suffix,ch_suffix)) { /* Makes compiler happy due to bug 35903 in gcc */
+ ch_generate_tiles(suffix0,suffix,tilesdir,zip_info);
+ } else {
+ for (f = 0 ; f < filename_count ; f++)
+ files[f]=tempfile(suffix,filenames[f],0);
+ phase4(files,filename_count,0,suffix,tilesdir,zip_info);
+ for (f = 0 ; f < filename_count ; f++) {
+ if (files[f])
+ fclose(files[f]);
+ }
+ }
+ fclose(tilesdir);
+ zip_set_zipnum(zip_info,zipnum);
}
-static void
-maptool_assemble_map(struct maptool_params *p, char *suffix, char **filenames, char **referencenames, int filename_count, int first, int last, char *suffix0)
-{
- FILE *files[10];
- FILE *references[10];
- struct zip_info *zip_info;
- int zipnum,f;
+static void maptool_assemble_map(struct maptool_params *p, char *suffix, char **filenames, char **referencenames,
+ int filename_count, int first, int last, char *suffix0) {
+ FILE *files[10];
+ FILE *references[10];
+ struct zip_info *zip_info;
+ int zipnum,f;
- if (first) {
- char *zipdir=tempfile_name("zipdir","");
- char *zipindex=tempfile_name("index","");
- zip_info=zip_new();
- zip_set_zip64(zip_info, p->zip64);
- zip_set_timestamp(zip_info, p->timestamp);
- zip_set_maxnamelen(zip_info, 14+strlen(suffix0));
- zip_set_compression_level(zip_info, p->compression_level);
- if(!zip_open(zip_info, p->result, zipdir, zipindex)) {
- fprintf(stderr,"Fatal: Could not write output file.\n");
- exit(1);
- }
- if (p->url) {
- map_information_attrs[1].type=attr_url;
- map_information_attrs[1].u.str=p->url;
- }
- index_init(zip_info, 1);
- }
- if (!strcmp(suffix,ch_suffix)) { /* Makes compiler happy due to bug 35903 in gcc */
- ch_assemble_map(suffix0,suffix,zip_info);
- } else {
- for (f = 0 ; f < filename_count ; f++) {
- files[f]=tempfile(suffix, filenames[f], 0);
- if (referencenames[f])
- references[f]=tempfile(suffix,referencenames[f],1);
- else
- references[f]=NULL;
- }
- phase5(files,references,filename_count,0,suffix,zip_info);
- for (f = 0 ; f < filename_count ; f++) {
- if (files[f])
- fclose(files[f]);
- if (references[f])
- fclose(references[f]);
- }
- }
- if(!p->keep_tmpfiles) {
- tempfile_unlink(suffix,"relations");
- tempfile_unlink(suffix,"nodes");
- tempfile_unlink(suffix,"ways_split");
- tempfile_unlink(suffix,"poly2poi_resolved");
- tempfile_unlink(suffix,"line2poi_resolved");
- tempfile_unlink(suffix,"ways_split_ref");
- tempfile_unlink(suffix,"coastline");
- tempfile_unlink(suffix,"turn_restrictions");
- tempfile_unlink(suffix,"graph");
- tempfile_unlink(suffix,"tilesdir");
- tempfile_unlink(suffix,"boundaries");
- tempfile_unlink(suffix,"way2poi_result");
- tempfile_unlink(suffix,"coastline_result");
- tempfile_unlink(suffix,"towns_poly");
- unlink("coords.tmp");
- }
- if (last) {
- zipnum=zip_get_zipnum(zip_info);
- add_aux_tiles("auxtiles.txt", zip_info);
- write_countrydir(zip_info,p->max_index_size);
- zip_set_zipnum(zip_info, zipnum);
- write_aux_tiles(zip_info);
- zip_write_index(zip_info);
- zip_write_directory(zip_info);
- zip_close(zip_info);
- if (!p->keep_tmpfiles) {
- remove_countryfiles();
- tempfile_unlink("index","");
- tempfile_unlink("zipdir","");
- }
- }
+ if (first) {
+ char *zipdir=tempfile_name("zipdir","");
+ char *zipindex=tempfile_name("index","");
+ zip_info=zip_new();
+ zip_set_zip64(zip_info, p->zip64);
+ zip_set_timestamp(zip_info, p->timestamp);
+ zip_set_maxnamelen(zip_info, 14+strlen(suffix0));
+ zip_set_compression_level(zip_info, p->compression_level);
+ if(!zip_open(zip_info, p->result, zipdir, zipindex)) {
+ fprintf(stderr,"Fatal: Could not write output file.\n");
+ exit(1);
+ }
+ if (p->url) {
+ map_information_attrs[1].type=attr_url;
+ map_information_attrs[1].u.str=p->url;
+ }
+ index_init(zip_info, 1);
+ }
+ if (!g_strcmp0(suffix,ch_suffix)) { /* Makes compiler happy due to bug 35903 in gcc */
+ ch_assemble_map(suffix0,suffix,zip_info);
+ } else {
+ for (f = 0 ; f < filename_count ; f++) {
+ files[f]=tempfile(suffix, filenames[f], 0);
+ if (referencenames[f])
+ references[f]=tempfile(suffix,referencenames[f],1);
+ else
+ references[f]=NULL;
+ }
+ phase5(files,references,filename_count,0,suffix,zip_info);
+ for (f = 0 ; f < filename_count ; f++) {
+ if (files[f])
+ fclose(files[f]);
+ if (references[f])
+ fclose(references[f]);
+ }
+ }
+ if(!p->keep_tmpfiles) {
+ tempfile_unlink(suffix,"relations");
+ tempfile_unlink(suffix,"nodes");
+ tempfile_unlink(suffix,"ways_split");
+ tempfile_unlink(suffix,"poly2poi_resolved");
+ tempfile_unlink(suffix,"line2poi_resolved");
+ tempfile_unlink(suffix,"ways_split_ref");
+ tempfile_unlink(suffix,"coastline");
+ tempfile_unlink(suffix,"turn_restrictions");
+ tempfile_unlink(suffix,"graph");
+ tempfile_unlink(suffix,"tilesdir");
+ tempfile_unlink(suffix,"boundaries");
+ tempfile_unlink(suffix,"way2poi_result");
+ tempfile_unlink(suffix,"coastline_result");
+ tempfile_unlink(suffix,"towns_poly");
+ unlink("coords.tmp");
+ }
+ if (last) {
+ zipnum=zip_get_zipnum(zip_info);
+ add_aux_tiles("auxtiles.txt", zip_info);
+ write_countrydir(zip_info,p->max_index_size);
+ zip_set_zipnum(zip_info, zipnum);
+ write_aux_tiles(zip_info);
+ zip_write_index(zip_info);
+ zip_write_directory(zip_info);
+ zip_close(zip_info);
+ if (!p->keep_tmpfiles) {
+ remove_countryfiles();
+ tempfile_unlink("index","");
+ tempfile_unlink("zipdir","");
+ }
+ }
}
-static void
-maptool_load_node_table(struct maptool_params *p, int last)
-{
- if (!p->node_table_loaded) {
- slices=(sizeof_buffer("coords.tmp")+(long long)slice_size-(long long)1)/(long long)slice_size;
- assert(slices>0);
- load_buffer("coords.tmp",&node_buffer,last?(slices-1)*slice_size:0, slice_size);
- p->node_table_loaded=1;
- }
+static void maptool_load_node_table(struct maptool_params *p, int last) {
+ if (!p->node_table_loaded) {
+ slices=(sizeof_buffer("coords.tmp")+(long long)slice_size-(long long)1)/(long long)slice_size;
+ assert(slices>0);
+ load_buffer("coords.tmp",&node_buffer,last?(slices-1)*slice_size:0, slice_size);
+ p->node_table_loaded=1;
+ }
}
-static void
-maptool_load_countries(struct maptool_params *p)
-{
- if (!p->countries_loaded) {
- load_countries();
- p->countries_loaded=1;
- }
+static void maptool_load_countries(struct maptool_params *p) {
+ if (!p->countries_loaded) {
+ load_countries();
+ p->countries_loaded=1;
+ }
}
-static void
-maptool_load_tilesdir(struct maptool_params *p, char *suffix)
-{
- if (!p->tilesdir_loaded) {
- FILE *tilesdir=tempfile(suffix,"tilesdir",0);
- load_tilesdir(tilesdir);
- p->tilesdir_loaded=1;
- }
+static void maptool_load_tilesdir(struct maptool_params *p, char *suffix) {
+ if (!p->tilesdir_loaded) {
+ FILE *tilesdir=tempfile(suffix,"tilesdir",0);
+ load_tilesdir(tilesdir);
+ p->tilesdir_loaded=1;
+ }
}
-int main(int argc, char **argv)
-{
- struct maptool_params p;
- char *suffixes[]={""};
- char *suffix=suffixes[0];
- char *filenames[20];
- char *referencenames[20];
- int filename_count=0;
+int main(int argc, char **argv) {
+ struct maptool_params p;
+ char *suffixes[]= {""};
+ char *suffix=suffixes[0];
+ char *filenames[20];
+ char *referencenames[20];
+ int filename_count=0;
- int suffix_count=sizeof(suffixes)/sizeof(char *);
- int i;
- int suffix_start=0;
- int option_index=0;
- main_init(argv[0]);
+ int suffix_count=sizeof(suffixes)/sizeof(char *);
+ int i;
+ int suffix_start=0;
+ int option_index=0;
+ main_init(argv[0]);
#ifndef HAVE_GLIB
- _g_slice_thread_init_nomessage();
+ _g_slice_thread_init_nomessage();
#endif
- linguistics_init();
+ linguistics_init();
- memset(&p, 0, sizeof(p));
+ memset(&p, 0, sizeof(p));
#ifdef HAVE_ZLIB
- p.compression_level=9;
+ p.compression_level=9;
#endif
- p.start=1;
- p.end=99;
- p.input_file=stdin;
- p.process_nodes=1;
- p.process_ways=1;
- p.process_relations=1;
- p.timestamp=current_to_iso8601();
- p.max_index_size=65536;
+ p.start=1;
+ p.end=99;
+ p.input_file=stdin;
+ p.process_nodes=1;
+ p.process_ways=1;
+ p.process_relations=1;
+ p.timestamp=current_to_iso8601();
+ p.max_index_size=65536;
#ifdef HAVE_SBRK
- start_brk=(long)sbrk(0);
+ start_brk=(long)sbrk(0);
#endif
#ifdef _WIN32
- gettimeofday(&start_ts,NULL);
+ gettimeofday(&start_ts,NULL);
#else
- clock_gettime(CLOCK_REALTIME, &start_ts);
+ clock_gettime(CLOCK_REALTIME, &start_ts);
#endif
- while (1) {
- int parse_result=parse_option(&p, argv, argc, &option_index);
- if (!parse_result) {
- exit(1);
- }
- if (parse_result == 1)
- break;
- if (parse_result == 2) {
- usage();
- exit(0);
- }
- }
- if (experimental && (!experimental_feature_description )) {
- exit_with_error("No experimental features available in this version, aborting. \n");
- }
- if (optind < argc -1) {
- exit_with_error("Only one non-option argument allowed.\n");
- }
- if (p.dump == 0 && optind != argc -1) {
- exit_with_error("Please specify an output file.\n");
- }
- if (p.dump == 1 && optind != argc) {
- exit_with_error("Please do not specify an output file in dump mode.\n");
- }
+ while (1) {
+ int parse_result=parse_option(&p, argv, argc, &option_index);
+ if (!parse_result) {
+ exit(1);
+ }
+ if (parse_result == 1)
+ break;
+ if (parse_result == 2) {
+ usage();
+ exit(0);
+ }
+ }
+ if (experimental && (!experimental_feature_description )) {
+ exit_with_error("No experimental features available in this version, aborting. \n");
+ }
+ if (optind < argc -1) {
+ exit_with_error("Only one non-option argument allowed.\n");
+ }
+ if (p.dump == 0 && optind != argc -1) {
+ exit_with_error("Please specify an output file.\n");
+ }
+ if (p.dump == 1 && optind != argc) {
+ exit_with_error("Please do not specify an output file in dump mode.\n");
+ }
- p.result=argv[optind];
+ p.result=argv[optind];
- // initialize plugins and OSM mappings
- maptool_init(p.rule_file);
- if (p.protobufdb_operation) {
+ // initialize plugins and OSM mappings
+ maptool_init(p.rule_file);
+ if (p.protobufdb_operation) {
#ifdef _MSC_VER
- exit_with_error("Option -O not yet supported on MSVC\n");
+ exit_with_error("Option -O not yet supported on MSVC\n");
#else
- osm_protobufdb_load(p.input_file, p.protobufdb);
- return 0;
+ osm_protobufdb_load(p.input_file, p.protobufdb);
+ return 0;
#endif
- }
- phase=0;
+ }
+ phase=0;
+
+ // input from an OSM file
+ if (p.input == 0) {
+ if (start_phase(&p, "reading input data")) {
+ osm_read_input_data(&p, suffix);
+ p.node_table_loaded=1;
+ }
+ if (start_phase(&p, "counting references and resolving ways")) {
+ maptool_load_node_table(&p,1);
+ osm_count_references(&p, suffix, p.start == phase);
+ }
+ if (start_phase(&p,"converting ways to pois")) {
+ osm_process_way2poi(&p, suffix);
+ }
+ if (start_phase(&p,"splitting at intersections")) {
+ if (p.process_ways) {
+ maptool_load_node_table(&p,0);
+ osm_resolve_coords_and_split_at_intersections(&p, suffix);
+ }
+ }
+ g_free(node_buffer.base);
+ node_buffer.base=NULL;
+ node_buffer.malloced=0;
+ node_buffer.size=0;
+ p.node_table_loaded=0;
+ } else {
+ if (start_phase(&p,"reading data")) {
+ FILE *ways_split=tempfile(suffix,"ways_split",1);
+ process_binfile(stdin, ways_split);
+ fclose(ways_split);
+ }
+ }
+ if (start_phase(&p,"generating coastlines")) {
+ osm_process_coastlines(&p, suffix);
+ }
+ if (start_phase(&p,"assigning towns to countries")) {
+ FILE *towns=tempfile(suffix,"towns",0),*boundaries=NULL,*ways=NULL;
+ if (towns) {
+ boundaries=tempfile(suffix,"boundaries",0);
+ ways=tempfile(suffix,"ways_split",0);
+ osm_process_towns(towns,boundaries,ways,suffix);
+ fclose(ways);
+ fclose(boundaries);
+ fclose(towns);
+ if(!p.keep_tmpfiles)
+ tempfile_unlink(suffix,"towns");
+ }
+ }
+ if (start_phase(&p,"sorting countries")) {
+ sort_countries(p.keep_tmpfiles);
+ p.countries_loaded=1;
+ }
+ if (start_phase(&p,"generating turn restrictions")) {
+ if (p.process_relations) {
+ osm_process_turn_restrictions(&p, suffix);
+ }
+ if(!p.keep_tmpfiles)
+ tempfile_unlink(suffix,"ways_split_index");
+ }
+ if (p.process_relations && p.process_ways && p.process_nodes
+ && start_phase(&p,"processing associated street relations")) {
+ struct files_relation_processing *files_relproc = files_relation_processing_new(p.osm.line2poi, suffix);
+ p.osm.associated_streets=tempfile(suffix,"associated_streets",0);
+ if (p.osm.associated_streets) {
- // input from an OSM file
- if (p.input == 0) {
- if (start_phase(&p, "reading input data")) {
- osm_read_input_data(&p, suffix);
- p.node_table_loaded=1;
- }
- if (start_phase(&p, "counting references and resolving ways")) {
- maptool_load_node_table(&p,1);
- osm_count_references(&p, suffix, p.start == phase);
- }
- if (start_phase(&p,"converting ways to pois")) {
- osm_process_way2poi(&p, suffix);
- }
- if (start_phase(&p,"splitting at intersections")) {
- if (p.process_ways) {
- maptool_load_node_table(&p,0);
- osm_resolve_coords_and_split_at_intersections(&p, suffix);
- }
- }
- free(node_buffer.base);
- node_buffer.base=NULL;
- node_buffer.malloced=0;
- node_buffer.size=0;
- p.node_table_loaded=0;
- } else {
- if (start_phase(&p,"reading data")) {
- FILE *ways_split=tempfile(suffix,"ways_split",1);
- process_binfile(stdin, ways_split);
- fclose(ways_split);
- }
- }
- if (start_phase(&p,"generating coastlines")) {
- osm_process_coastlines(&p, suffix);
- }
- if (start_phase(&p,"assigning towns to countries")) {
- FILE *towns=tempfile(suffix,"towns",0),*boundaries=NULL,*ways=NULL;
- if (towns) {
- boundaries=tempfile(suffix,"boundaries",0);
- ways=tempfile(suffix,"ways_split",0);
- osm_process_towns(towns,boundaries,ways,suffix);
- fclose(ways);
- fclose(boundaries);
- fclose(towns);
- if(!p.keep_tmpfiles)
- tempfile_unlink(suffix,"towns");
- }
- }
- if (start_phase(&p,"sorting countries")) {
- sort_countries(p.keep_tmpfiles);
- p.countries_loaded=1;
- }
- if (start_phase(&p,"generating turn restrictions")) {
- if (p.process_relations) {
- osm_process_turn_restrictions(&p, suffix);
- }
- if(!p.keep_tmpfiles)
- tempfile_unlink(suffix,"ways_split_index");
- }
- if (p.process_relations && p.process_ways && p.process_nodes && start_phase(&p,"processing associated street relations")) {
- struct files_relation_processing *files_relproc = files_relation_processing_new(p.osm.line2poi, suffix);
- p.osm.associated_streets=tempfile(suffix,"associated_streets",0);
- if (p.osm.associated_streets) {
-
- process_associated_streets(p.osm.associated_streets, files_relproc);
+ process_associated_streets(p.osm.associated_streets, files_relproc);
- fclose(p.osm.associated_streets);
- files_relation_processing_destroy(files_relproc, suffix);
- if(!p.keep_tmpfiles) {
- tempfile_unlink(suffix,"associated_streets");
- }
- }
- }
- if (p.process_relations && p.process_ways && p.process_nodes && start_phase(&p,"processing house number interpolations")) {
- // OSM house number interpolations are handled like a relation.
- struct files_relation_processing *files_relproc = files_relation_processing_new(p.osm.line2poi, suffix);
- p.osm.house_number_interpolations=tempfile(suffix,"house_number_interpolations",0);
- if (p.osm.house_number_interpolations) {
+ fclose(p.osm.associated_streets);
+ files_relation_processing_destroy(files_relproc, suffix);
+ if(!p.keep_tmpfiles) {
+ tempfile_unlink(suffix,"associated_streets");
+ }
+ }
+ }
+ if (p.process_relations && p.process_ways && p.process_nodes
+ && start_phase(&p,"processing house number interpolations")) {
+ // OSM house number interpolations are handled like a relation.
+ struct files_relation_processing *files_relproc = files_relation_processing_new(p.osm.line2poi, suffix);
+ p.osm.house_number_interpolations=tempfile(suffix,"house_number_interpolations",0);
+ if (p.osm.house_number_interpolations) {
- process_house_number_interpolations(p.osm.house_number_interpolations, files_relproc);
+ process_house_number_interpolations(p.osm.house_number_interpolations, files_relproc);
- fclose(p.osm.house_number_interpolations);
- files_relation_processing_destroy(files_relproc, suffix);
- if(!p.keep_tmpfiles) {
- tempfile_unlink(suffix,"house_number_interpolations");
- }
- }
- }
- if (p.dump == 1 && start_phase(&p,"dumping")) {
- maptool_dump(&p, suffix);
- exit(0);
- }
- if (p.process_relations) {
- filenames[filename_count]="relations";
- referencenames[filename_count++]=NULL;
- filenames[filename_count]="towns_poly";
- referencenames[filename_count++]=NULL;
- }
- if (p.process_ways) {
- filenames[filename_count]="ways_split";
- referencenames[filename_count++]=NULL;
- filenames[filename_count]="coastline_result";
- referencenames[filename_count++]=NULL;
- }
- if (p.process_nodes) {
- filenames[filename_count]="nodes";
- referencenames[filename_count++]=NULL;
- filenames[filename_count]="way2poi_result";
- referencenames[filename_count++]=NULL;
- }
- for (i = suffix_start ; i < suffix_count ; i++) {
- suffix=suffixes[i];
- if (start_phase(&p,"generating tiles")) {
- maptool_load_countries(&p);
- maptool_generate_tiles(&p, suffix, filenames, filename_count, i == suffix_start, suffixes[0]);
- p.tilesdir_loaded=1;
- }
- if (start_phase(&p,"assembling map")) {
- maptool_load_countries(&p);
- maptool_load_tilesdir(&p, suffix);
- maptool_assemble_map(&p, suffix, filenames, referencenames, filename_count, i == suffix_start, i == suffix_count-1, suffixes[0]);
- }
- phase-=2;
- }
- phase+=2;
- start_phase(&p,"done");
- return 0;
+ fclose(p.osm.house_number_interpolations);
+ files_relation_processing_destroy(files_relproc, suffix);
+ if(!p.keep_tmpfiles) {
+ tempfile_unlink(suffix,"house_number_interpolations");
+ }
+ }
+ }
+ if (p.dump == 1 && start_phase(&p,"dumping")) {
+ maptool_dump(&p, suffix);
+ exit(0);
+ }
+ if (p.process_relations) {
+ filenames[filename_count]="relations";
+ referencenames[filename_count++]=NULL;
+ filenames[filename_count]="towns_poly";
+ referencenames[filename_count++]=NULL;
+ }
+ if (p.process_ways) {
+ filenames[filename_count]="ways_split";
+ referencenames[filename_count++]=NULL;
+ filenames[filename_count]="coastline_result";
+ referencenames[filename_count++]=NULL;
+ }
+ if (p.process_nodes) {
+ filenames[filename_count]="nodes";
+ referencenames[filename_count++]=NULL;
+ filenames[filename_count]="way2poi_result";
+ referencenames[filename_count++]=NULL;
+ }
+ for (i = suffix_start ; i < suffix_count ; i++) {
+ suffix=suffixes[i];
+ if (start_phase(&p,"generating tiles")) {
+ maptool_load_countries(&p);
+ maptool_generate_tiles(&p, suffix, filenames, filename_count, i == suffix_start, suffixes[0]);
+ p.tilesdir_loaded=1;
+ }
+ if (start_phase(&p,"assembling map")) {
+ maptool_load_countries(&p);
+ maptool_load_tilesdir(&p, suffix);
+ maptool_assemble_map(&p, suffix, filenames, referencenames, filename_count, i == suffix_start, i == suffix_count-1,
+ suffixes[0]);
+ }
+ phase-=2;
+ }
+ phase+=2;
+ start_phase(&p,"done");
+ return 0;
}
diff --git a/navit/maptool/maptool.h b/navit/maptool/maptool.h
index ce147b1a4..edb2a77ef 100644
--- a/navit/maptool/maptool.h
+++ b/navit/maptool/maptool.h
@@ -177,7 +177,7 @@ struct buffer {
};
void save_buffer(char *filename, struct buffer *b, long long offset);
-void load_buffer(char *filename, struct buffer *b, long long offset, long long size);
+int load_buffer(char *filename, struct buffer *b, long long offset, long long size);
long long sizeof_buffer(char *filename);
/* ch.c */
@@ -398,7 +398,7 @@ void index_submap_add(struct tile_info *info, struct tile_head *th);
/* zip.c */
void write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data, int data_size);
-void zip_write_index(struct zip_info *info);
+int zip_write_index(struct zip_info *info);
int zip_write_directory(struct zip_info *info);
struct zip_info *zip_new(void);
void zip_set_zip64(struct zip_info *info, int on);
diff --git a/navit/maptool/misc.c b/navit/maptool/misc.c
index 90b03d462..1c30b94f7 100644
--- a/navit/maptool/misc.c
+++ b/navit/maptool/misc.c
@@ -48,407 +48,374 @@
#define phase1_coord_max 16384
struct rect world_bbox = {
- { WORLD_BOUNDINGBOX_MIN_X, WORLD_BOUNDINGBOX_MIN_Y},
- { WORLD_BOUNDINGBOX_MAX_X, WORLD_BOUNDINGBOX_MAX_Y},
+ { WORLD_BOUNDINGBOX_MIN_X, WORLD_BOUNDINGBOX_MIN_Y},
+ { WORLD_BOUNDINGBOX_MAX_X, WORLD_BOUNDINGBOX_MAX_Y},
};
-void
-bbox_extend(struct coord *c, struct rect *r)
-{
- if (c->x < r->l.x)
- r->l.x=c->x;
- if (c->y < r->l.y)
- r->l.y=c->y;
- if (c->x > r->h.x)
- r->h.x=c->x;
- if (c->y > r->h.y)
- r->h.y=c->y;
+void bbox_extend(struct coord *c, struct rect *r) {
+ if (c->x < r->l.x)
+ r->l.x=c->x;
+ if (c->y < r->l.y)
+ r->l.y=c->y;
+ if (c->x > r->h.x)
+ r->h.x=c->x;
+ if (c->y > r->h.y)
+ r->h.y=c->y;
}
-void
-bbox(struct coord *c, int count, struct rect *r)
-{
- if (! count)
- return;
- r->l=*c;
- r->h=*c;
- while (--count) {
- c++;
- bbox_extend(c, r);
- }
+void bbox(struct coord *c, int count, struct rect *r) {
+ if (! count)
+ return;
+ r->l=*c;
+ r->h=*c;
+ while (--count) {
+ c++;
+ bbox_extend(c, r);
+ }
}
-int
-contains_bbox(int xl, int yl, int xh, int yh, struct rect *r)
-{
- if (r->h.x < xl || r->h.x > xh) {
- return 0;
- }
- if (r->l.x > xh || r->l.x < xl) {
- return 0;
- }
- if (r->h.y < yl || r->h.y > yh) {
- return 0;
- }
- if (r->l.y > yh || r->l.y < yl) {
- return 0;
- }
- return 1;
+int contains_bbox(int xl, int yl, int xh, int yh, struct rect *r) {
+ if (r->h.x < xl || r->h.x > xh) {
+ return 0;
+ }
+ if (r->l.x > xh || r->l.x < xl) {
+ return 0;
+ }
+ if (r->h.y < yl || r->h.y > yh) {
+ return 0;
+ }
+ if (r->l.y > yh || r->l.y < yl) {
+ return 0;
+ }
+ return 1;
}
-int
-bbox_contains_coord(struct rect *r, struct coord *c)
-{
- if (r->h.x < c->x)
- return 0;
- if (r->l.x > c->x)
- return 0;
- if (r->h.y < c->y)
- return 0;
- if (r->l.y > c->y)
- return 0;
- return 1;
+int bbox_contains_coord(struct rect *r, struct coord *c) {
+ if (r->h.x < c->x)
+ return 0;
+ if (r->l.x > c->x)
+ return 0;
+ if (r->h.y < c->y)
+ return 0;
+ if (r->l.y > c->y)
+ return 0;
+ return 1;
}
-int
-bbox_contains_bbox(struct rect *out, struct rect *in)
-{
- if (out->h.x < in->h.x)
- return 0;
- if (out->l.x > in->l.x)
- return 0;
- if (out->h.y < in->h.y)
- return 0;
- if (out->l.y > in->l.y)
- return 0;
- return 1;
+int bbox_contains_bbox(struct rect *out, struct rect *in) {
+ if (out->h.x < in->h.x)
+ return 0;
+ if (out->l.x > in->l.x)
+ return 0;
+ if (out->h.y < in->h.y)
+ return 0;
+ if (out->l.y > in->l.y)
+ return 0;
+ return 1;
}
-long long
-bbox_area(struct rect const *r)
-{
- return ((long long)r->h.x-r->l.x)*(r->h.y-r->l.y);
+long long bbox_area(struct rect const *r) {
+ return ((long long)r->h.x-r->l.x)*(r->h.y-r->l.y);
}
-void
-phase1_map(GList *maps, FILE *out_ways, FILE *out_nodes)
-{
- struct map_rect *mr;
- struct item *item;
- int count;
- struct coord ca[phase1_coord_max];
- struct attr attr;
- struct item_bin *item_bin;
-
- while (maps) {
- mr=map_rect_new(maps->data, NULL);
- while ((item = map_rect_get_item(mr))) {
- count=item_coord_get(item, ca, item->type < type_line ? 1: phase1_coord_max);
- item_bin=init_item(item->type);
- item_bin_add_coord(item_bin, ca, count);
- while (item_attr_get(item, attr_any, &attr)) {
- if (attr.type >= attr_type_string_begin && attr.type <= attr_type_string_end) {
- attr.u.str=map_convert_string(maps->data, attr.u.str);
- if (attr.u.str) {
- item_bin_add_attr(item_bin, &attr);
- map_convert_free(attr.u.str);
- }
- } else
- item_bin_add_attr(item_bin, &attr);
- }
- if (item->type >= type_line)
- item_bin_write(item_bin, out_ways);
- else
- item_bin_write(item_bin, out_nodes);
- }
- map_rect_destroy(mr);
- maps=g_list_next(maps);
- }
+void phase1_map(GList *maps, FILE *out_ways, FILE *out_nodes) {
+ struct map_rect *mr;
+ struct item *item;
+ int count;
+ struct coord ca[phase1_coord_max];
+ struct attr attr;
+ struct item_bin *item_bin;
+
+ while (maps) {
+ mr=map_rect_new(maps->data, NULL);
+ while ((item = map_rect_get_item(mr))) {
+ count=item_coord_get(item, ca, item->type < type_line ? 1: phase1_coord_max);
+ item_bin=init_item(item->type);
+ item_bin_add_coord(item_bin, ca, count);
+ while (item_attr_get(item, attr_any, &attr)) {
+ if (attr.type >= attr_type_string_begin && attr.type <= attr_type_string_end) {
+ attr.u.str=map_convert_string(maps->data, attr.u.str);
+ if (attr.u.str) {
+ item_bin_add_attr(item_bin, &attr);
+ map_convert_free(attr.u.str);
+ }
+ } else
+ item_bin_add_attr(item_bin, &attr);
+ }
+ if (item->type >= type_line)
+ item_bin_write(item_bin, out_ways);
+ else
+ item_bin_write(item_bin, out_nodes);
+ }
+ map_rect_destroy(mr);
+ maps=g_list_next(maps);
+ }
}
-int
-item_order_by_type(enum item_type type)
-{
- int max=14;
- switch (type) {
- case type_town_label_1e7:
- case type_town_label_5e6:
- max=3;
- break;
- case type_town_label_2e6:
- case type_town_label_1e6:
- max=5;
- break;
- case type_town_label_5e5:
- case type_district_label_1e7:
- case type_district_label_5e6:
- case type_district_label_2e6:
- case type_district_label_1e6:
- case type_district_label_5e5:
- max=6;
- break;
- case type_town_label_2e5:
- case type_town_label_1e5:
- case type_district_label_2e5:
- case type_district_label_1e5:
- case type_street_n_lanes:
- case type_highway_city:
- case type_highway_land:
- case type_ramp:
- max=8;
- break;
- case type_town_label_5e4:
- case type_town_label_2e4:
- case type_town_label_1e4:
- case type_district_label_5e4:
- case type_district_label_2e4:
- case type_district_label_1e4:
- max=9;
- break;
- case type_poly_water_tiled:
- if(experimental)
- max=9;
- break;
- case type_street_4_land:
- case type_street_4_city:
- max=10;
- break;
- case type_town_label_5e3:
- case type_town_label_2e3:
- case type_town_label_1e3:
- case type_district_label_5e3:
- case type_district_label_2e3:
- case type_district_label_1e3:
- case type_street_3_city:
- case type_street_3_land:
- max=12;
- break;
- default:
- break;
- }
- return max;
+int item_order_by_type(enum item_type type) {
+ int max=14;
+ switch (type) {
+ case type_town_label_1e7:
+ case type_town_label_5e6:
+ max=3;
+ break;
+ case type_town_label_2e6:
+ case type_town_label_1e6:
+ max=5;
+ break;
+ case type_town_label_5e5:
+ case type_district_label_1e7:
+ case type_district_label_5e6:
+ case type_district_label_2e6:
+ case type_district_label_1e6:
+ case type_district_label_5e5:
+ max=6;
+ break;
+ case type_town_label_2e5:
+ case type_town_label_1e5:
+ case type_district_label_2e5:
+ case type_district_label_1e5:
+ case type_street_n_lanes:
+ case type_highway_city:
+ case type_highway_land:
+ case type_ramp:
+ max=8;
+ break;
+ case type_town_label_5e4:
+ case type_town_label_2e4:
+ case type_town_label_1e4:
+ case type_district_label_5e4:
+ case type_district_label_2e4:
+ case type_district_label_1e4:
+ max=9;
+ break;
+ case type_poly_water_tiled:
+ if(experimental)
+ max=9;
+ break;
+ case type_street_4_land:
+ case type_street_4_city:
+ max=10;
+ break;
+ case type_town_label_5e3:
+ case type_town_label_2e3:
+ case type_town_label_1e3:
+ case type_district_label_5e3:
+ case type_district_label_2e3:
+ case type_district_label_1e3:
+ case type_street_3_city:
+ case type_street_3_land:
+ max=12;
+ break;
+ default:
+ break;
+ }
+ return max;
}
-static void
-phase34_process_file(struct tile_info *info, FILE *in, FILE *reference)
-{
- struct item_bin *ib;
- struct attr_bin *a;
- int max;
-
- while ((ib=read_item(in))) {
- if (ib->type < 0x80000000)
- processed_nodes++;
- else
- processed_ways++;
- max=item_order_by_type(ib->type);
- a=item_bin_get_attr_bin(ib, attr_order, NULL);
- if(a) {
- int max2=((struct range *)(a+1))->max;
- if(max>max2)
- max=max2;
- }
- tile_write_item_minmax(info, ib, reference, 0, max);
- }
+static void phase34_process_file(struct tile_info *info, FILE *in, FILE *reference) {
+ struct item_bin *ib;
+ struct attr_bin *a;
+ int max;
+
+ while ((ib=read_item(in))) {
+ if (ib->type < 0x80000000)
+ processed_nodes++;
+ else
+ processed_ways++;
+ max=item_order_by_type(ib->type);
+ a=item_bin_get_attr_bin(ib, attr_order, NULL);
+ if(a) {
+ int max2=((struct range *)(a+1))->max;
+ if(max>max2)
+ max=max2;
+ }
+ tile_write_item_minmax(info, ib, reference, 0, max);
+ }
}
-static void
-phase34_process_file_range(struct tile_info *info, FILE *in, FILE *reference)
-{
- struct item_bin *ib;
- int min,max;
-
- while ((ib=read_item_range(in, &min, &max))) {
- if (ib->type < 0x80000000)
- processed_nodes++;
- else
- processed_ways++;
- tile_write_item_minmax(info, ib, reference, min, max);
- }
+static void phase34_process_file_range(struct tile_info *info, FILE *in, FILE *reference) {
+ struct item_bin *ib;
+ int min,max;
+
+ while ((ib=read_item_range(in, &min, &max))) {
+ if (ib->type < 0x80000000)
+ processed_nodes++;
+ else
+ processed_ways++;
+ tile_write_item_minmax(info, ib, reference, min, max);
+ }
}
-static int
-phase34(struct tile_info *info, struct zip_info *zip_info, FILE **in, FILE **reference, int in_count, int with_range)
-{
- int i;
-
- processed_nodes=processed_nodes_out=processed_ways=processed_relations=processed_tiles=0;
- bytes_read=0;
- sig_alrm(0);
- if (! info->write)
- tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
- for (i = 0 ; i < in_count ; i++) {
- if (in[i]) {
- if (with_range)
- phase34_process_file_range(info, in[i], reference ? reference[i]:NULL);
- else
- phase34_process_file(info, in[i], reference ? reference[i]:NULL);
- }
- }
- if (! info->write)
- merge_tiles(info);
- sig_alrm(0);
- sig_alrm_end();
- write_tilesdir(info, zip_info, info->tilesdir_out);
-
- return 0;
+static int phase34(struct tile_info *info, struct zip_info *zip_info, FILE **in, FILE **reference, int in_count,
+ int with_range) {
+ int i;
+
+ processed_nodes=processed_nodes_out=processed_ways=processed_relations=processed_tiles=0;
+ bytes_read=0;
+ sig_alrm(0);
+ if (! info->write)
+ tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ for (i = 0 ; i < in_count ; i++) {
+ if (in[i]) {
+ if (with_range)
+ phase34_process_file_range(info, in[i], reference ? reference[i]:NULL);
+ else
+ phase34_process_file(info, in[i], reference ? reference[i]:NULL);
+ }
+ }
+ if (! info->write)
+ merge_tiles(info);
+ sig_alrm(0);
+ sig_alrm_end();
+ write_tilesdir(info, zip_info, info->tilesdir_out);
+
+ return 0;
}
-void
-dump(FILE *in)
-{
- struct item_bin *ib;
- while ((ib=read_item(in))) {
- dump_itembin(ib);
- }
+void dump(FILE *in) {
+ struct item_bin *ib;
+ while ((ib=read_item(in))) {
+ dump_itembin(ib);
+ }
}
-int
-phase4(FILE **in, int in_count, int with_range, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info)
-{
- struct tile_info info;
- info.write=0;
- info.maxlen=0;
- info.suffix=suffix;
- info.tiles_list=NULL;
- info.tilesdir_out=tilesdir_out;
- return phase34(&info, zip_info, in, NULL, in_count, with_range);
+int phase4(FILE **in, int in_count, int with_range, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info) {
+ struct tile_info info;
+ info.write=0;
+ info.maxlen=0;
+ info.suffix=suffix;
+ info.tiles_list=NULL;
+ info.tilesdir_out=tilesdir_out;
+ return phase34(&info, zip_info, in, NULL, in_count, with_range);
}
-static int
-process_slice(FILE **in, FILE **reference, int in_count, int with_range, long long size, char *suffix, struct zip_info *zip_info)
-{
- struct tile_head *th;
- char *slice_data,*zip_data;
- int zipfiles=0;
- struct tile_info info;
- int i;
-
- slice_data=malloc(size);
- assert(slice_data != NULL);
- zip_data=slice_data;
- th=tile_head_root;
- while (th) {
- if (th->process) {
- th->zip_data=zip_data;
- zip_data+=th->total_size;
- }
- th=th->next;
- }
- for (i = 0 ; i < in_count ; i++) {
- if (in[i])
- fseek(in[i], 0, SEEK_SET);
- if (reference && reference[i]) {
- fseek(reference[i], 0, SEEK_SET);
- }
- }
- info.write=1;
- info.maxlen=zip_get_maxnamelen(zip_info);
- info.suffix=suffix;
- info.tiles_list=NULL;
- info.tilesdir_out=NULL;
- phase34(&info, zip_info, in, reference, in_count, with_range);
-
- for (th=tile_head_root;th;th=th->next) {
- if (!th->process)
- continue;
- if (th->name[0]) {
- if (th->total_size != th->total_size_used) {
- fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used);
- exit(1);
- }
- write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size);
- zipfiles++;
- } else {
- dbg_assert(fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info))==1);
- }
- }
- free(slice_data);
-
- return zipfiles;
+static int process_slice(FILE **in, FILE **reference, int in_count, int with_range, long long size, char *suffix,
+ struct zip_info *zip_info) {
+ struct tile_head *th;
+ char *slice_data,*zip_data;
+ int zipfiles=0;
+ struct tile_info info;
+ int i;
+
+ slice_data=g_malloc(size);
+ zip_data=slice_data;
+ th=tile_head_root;
+ while (th) {
+ if (th->process) {
+ th->zip_data=zip_data;
+ zip_data+=th->total_size;
+ }
+ th=th->next;
+ }
+ for (i = 0 ; i < in_count ; i++) {
+ if (in[i])
+ fseek(in[i], 0, SEEK_SET);
+ if (reference && reference[i]) {
+ fseek(reference[i], 0, SEEK_SET);
+ }
+ }
+ info.write=1;
+ info.maxlen=zip_get_maxnamelen(zip_info);
+ info.suffix=suffix;
+ info.tiles_list=NULL;
+ info.tilesdir_out=NULL;
+ phase34(&info, zip_info, in, reference, in_count, with_range);
+
+ for (th=tile_head_root; th; th=th->next) {
+ if (!th->process)
+ continue;
+ if (th->name[0]) {
+ if (th->total_size != th->total_size_used) {
+ fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used);
+ exit(1);
+ }
+ write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size);
+ zipfiles++;
+ } else {
+ dbg_assert(fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info))==1);
+ }
+ }
+ g_free(slice_data);
+
+ return zipfiles;
}
-int
-phase5(FILE **in, FILE **references, int in_count, int with_range, char *suffix, struct zip_info *zip_info)
-{
- long long size;
- int slices;
- int zipnum,written_tiles;
- struct tile_head *th,*th2;
- create_tile_hash();
-
- th=tile_head_root;
- size=0;
- slices=0;
- fprintf(stderr, "Maximum slice size "LONGLONG_FMT"\n", slice_size);
- while (th) {
- if (size + th->total_size > slice_size) {
- fprintf(stderr,"Slice %d is of size "LONGLONG_FMT"\n", slices, size);
- size=0;
- slices++;
- }
- size+=th->total_size;
- th=th->next;
- }
- if (size)
- fprintf(stderr,"Slice %d is of size "LONGLONG_FMT"\n", slices, size);
- th=tile_head_root;
- size=0;
- slices=0;
- while (th) {
- th2=tile_head_root;
- while (th2) {
- th2->process=0;
- th2=th2->next;
- }
- size=0;
- while (th && size+th->total_size < slice_size) {
- size+=th->total_size;
- th->process=1;
- th=th->next;
- }
- /* process_slice() modifies zip_info, but need to retain old info */
- zipnum=zip_get_zipnum(zip_info);
- written_tiles=process_slice(in, references, in_count, with_range, size, suffix, zip_info);
- zip_set_zipnum(zip_info, zipnum+written_tiles);
- slices++;
- }
- return 0;
+int phase5(FILE **in, FILE **references, int in_count, int with_range, char *suffix, struct zip_info *zip_info) {
+ long long size;
+ int slices;
+ int zipnum,written_tiles;
+ struct tile_head *th,*th2;
+ create_tile_hash();
+
+ th=tile_head_root;
+ size=0;
+ slices=0;
+ fprintf(stderr, "Maximum slice size "LONGLONG_FMT"\n", slice_size);
+ while (th) {
+ if (size + th->total_size > slice_size) {
+ fprintf(stderr,"Slice %d is of size "LONGLONG_FMT"\n", slices, size);
+ size=0;
+ slices++;
+ }
+ size+=th->total_size;
+ th=th->next;
+ }
+ if (size)
+ fprintf(stderr,"Slice %d is of size "LONGLONG_FMT"\n", slices, size);
+ th=tile_head_root;
+ size=0;
+ slices=0;
+ while (th) {
+ th2=tile_head_root;
+ while (th2) {
+ th2->process=0;
+ th2=th2->next;
+ }
+ size=0;
+ while (th && size+th->total_size < slice_size) {
+ size+=th->total_size;
+ th->process=1;
+ th=th->next;
+ }
+ /* process_slice() modifies zip_info, but need to retain old info */
+ zipnum=zip_get_zipnum(zip_info);
+ written_tiles=process_slice(in, references, in_count, with_range, size, suffix, zip_info);
+ zip_set_zipnum(zip_info, zipnum+written_tiles);
+ slices++;
+ }
+ return 0;
}
-void
-process_binfile(FILE *in, FILE *out)
-{
- struct item_bin *ib;
- while ((ib=read_item(in))) {
- item_bin_write(ib, out);
- }
+void process_binfile(FILE *in, FILE *out) {
+ struct item_bin *ib;
+ while ((ib=read_item(in))) {
+ item_bin_write(ib, out);
+ }
}
-void
-add_aux_tiles(char *name, struct zip_info *info)
-{
- char buffer[4096];
- char *s;
- FILE *in;
- FILE *tmp;
- in=fopen(name,"rb");
- if (!in)
- return;
- while (fscanf(in,"%s",buffer) == 1) {
- s=strchr(buffer,'/');
- if (s)
- s++;
- else
- s=buffer;
- tmp=fopen(buffer,"rb");
- if (tmp) {
- fseek(tmp, 0, SEEK_END);
- add_aux_tile(info, s, buffer, ftell(tmp));
- fclose(tmp);
- }
- }
- fclose(in);
+void add_aux_tiles(char *name, struct zip_info *info) {
+ char buffer[4096];
+ char *s;
+ FILE *in;
+ FILE *tmp;
+ in=fopen(name,"rb");
+ if (!in)
+ return;
+ while (fscanf(in,"%s",buffer) == 1) {
+ s=strchr(buffer,'/');
+ if (s)
+ s++;
+ else
+ s=buffer;
+ tmp=fopen(buffer,"rb");
+ if (tmp) {
+ fseek(tmp, 0, SEEK_END);
+ add_aux_tile(info, s, buffer, ftell(tmp));
+ fclose(tmp);
+ }
+ }
+ fclose(in);
}
diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c
index 1d56834fb..f640c8674 100644
--- a/navit/maptool/osm.c
+++ b/navit/maptool/osm.c
@@ -73,9 +73,9 @@ int attr_strings_buffer_free_offset;
struct coord coord_buffer[MAX_COORD_COUNT];
struct attr_mapping {
- enum item_type type;
- int attr_present_idx_count;
- int attr_present_idx[0];
+ enum item_type type;
+ int attr_present_idx_count;
+ int attr_present_idx[0];
};
static void nodes_ref_item_bin(struct item_bin *ib);
@@ -95,34 +95,34 @@ static void attr_longest_match_clear(void);
enum attr_strings_type {
- attr_string_phone,
- attr_string_fax,
- attr_string_email,
- attr_string_url,
- attr_string_district_name,
- attr_string_street_name,
- attr_string_street_name_systematic,
- attr_string_street_name_systematic_nat,
- attr_string_street_name_systematic_int,
- attr_string_ref,
- attr_string_exit_to,
- attr_string_street_destination,
- attr_string_street_destination_forward,
- attr_string_street_destination_backward,
- attr_string_house_number,
- attr_string_label,
- attr_string_postal,
- attr_string_population,
- attr_string_county_name,
- attr_string_last,
+ attr_string_phone,
+ attr_string_fax,
+ attr_string_email,
+ attr_string_url,
+ attr_string_district_name,
+ attr_string_street_name,
+ attr_string_street_name_systematic,
+ attr_string_street_name_systematic_nat,
+ attr_string_street_name_systematic_int,
+ attr_string_ref,
+ attr_string_exit_to,
+ attr_string_street_destination,
+ attr_string_street_destination_forward,
+ attr_string_street_destination_backward,
+ attr_string_house_number,
+ attr_string_label,
+ attr_string_postal,
+ attr_string_population,
+ attr_string_county_name,
+ attr_string_last,
};
char *attr_strings[attr_string_last];
-char *osm_types[]={"unknown","node","way","relation"};
+char *osm_types[]= {"unknown","node","way","relation"};
/*
- * These macros are designed to handle maptool internal node id reference representation. This representation does not leak
+ * These macros are designed to handle maptool internal node id reference representation. This representation does not leak
* to binfile, so it's safe to change it without breaking binfile binary compatibility.
* Currently it keeps low 31 bits in y coordinate and up to 30 high order bits in x coordinate, allowing for 61 bit osm node id in total.
*/
@@ -132,269 +132,269 @@ char *osm_types[]={"unknown","node","way","relation"};
#define GET_REF(c) ((((osmid)(c).x & ~REF_MARKER)<<31) + (c).y )
#define SET_REF(c,ref) do { (c).x = REF_MARKER | ((osmid)(ref)>>31); (c).y = (osmid)(ref) & 0x7fffffffull; } while(0)
-/* Table of country codes with possible is_in spellings.
- * Note: If you update this list, check also country array in country.c
+/* Table of country codes with possible is_in spellings.
+ * Note: If you update this list, check also country array in country.c
*/
struct country_table {
- int countryid;
- char *names;
- char *admin_levels;
- FILE *file;
- int size;
- struct rect r;
- int nparts;
+ int countryid;
+ char *names;
+ char *admin_levels;
+ FILE *file;
+ int size;
+ struct rect r;
+ int nparts;
} country_table[] = {
- { 4,"Afghanistan"},
- { 8,"Albania"},
- { 10,"Antarctica"},
- { 12,"Algeria"},
- { 16,"American Samoa"},
- { 20,"Andorra"},
- { 24,"Angola"},
- { 28,"Antigua and Barbuda"},
- { 31,"Azerbaijan"},
- { 32,"Argentina,República Argentina,AR "},
- { 36,"Australia,AUS"},
- { 40,"Austria,Österreich,AUT"},
- { 44,"Bahamas"},
- { 48,"Bahrain"},
- { 50,"Bangladesh"},
- { 51,"Armenia"},
- { 52,"Barbados"},
- { 56,"Belgium,Belgique,Belgie,België,Belgien","345c7M"},
- { 60,"Bermuda"},
- { 64,"Bhutan"},
- { 68,"Bolivia, Plurinational State of"},
- { 70,"Bosnia and Herzegovina,Bosna i Hercegovina,Босна и Херцеговина"},
- { 72,"Botswana"},
- { 74,"Bouvet Island"},
- { 76,"Brazil"},
- { 84,"Belize"},
- { 86,"British Indian Ocean Territory"},
- { 90,"Solomon Islands"},
- { 92,"Virgin Islands, British"},
- { 96,"Brunei Darussalam"},
- { 100,"Bulgaria,България"},
- { 104,"Myanmar"},
- { 108,"Burundi"},
- { 112,"Belarus"},
- { 116,"Cambodia"},
- { 120,"Cameroon"},
- { 124,"Canada"},
- { 132,"Cape Verde"},
- { 136,"Cayman Islands"},
- { 140,"Central African Republic"},
- { 144,"Sri Lanka"},
- { 148,"Chad"},
- { 152,"Chile"},
- { 156,"China"},
- { 158,"Taiwan, Province of China"},
- { 162,"Christmas Island"},
- { 166,"Cocos (Keeling) Islands"},
- { 170,"Colombia"},
- { 174,"Comoros"},
- { 175,"Mayotte"},
- { 178,"Congo"},
- { 180,"Congo, the Democratic Republic of the"},
- { 184,"Cook Islands"},
- { 188,"Costa Rica"},
- { 191,"Croatia,Republika Hrvatska,HR"},
- { 192,"Cuba"},
- { 196,"Cyprus"},
- { 203,"Czech Republic,Česká republika,CZ"},
- { 204,"Benin"},
- { 208,"Denmark,Danmark,DK"},
- { 212,"Dominica"},
- { 214,"Dominican Republic"},
- { 218,"Ecuador"},
- { 222,"El Salvador"},
- { 226,"Equatorial Guinea"},
- { 231,"Ethiopia"},
- { 232,"Eritrea"},
- { 233,"Estonia"},
- { 234,"Faroe Islands,Føroyar"},
- { 238,"Falkland Islands (Malvinas)"},
- { 239,"South Georgia and the South Sandwich Islands"},
- { 242,"Fiji"},
- { 246,"Finland,Suomi"},
- { 248,"Åland Islands"},
- { 250,"France,République française,FR","3s5c7M"},
- { 254,"French Guiana"},
- { 258,"French Polynesia"},
- { 260,"French Southern Territories"},
- { 262,"Djibouti"},
- { 266,"Gabon"},
- { 268,"Georgia"},
- { 270,"Gambia"},
- { 275,"Palestinian Territory, Occupied"},
- { 276,"Germany,Deutschland,Bundesrepublik Deutschland","345c7M"},
- { 288,"Ghana"},
- { 292,"Gibraltar"},
- { 296,"Kiribati"},
- { 300,"Greece"},
- { 304,"Greenland"},
- { 308,"Grenada"},
- { 312,"Guadeloupe"},
- { 316,"Guam"},
- { 320,"Guatemala"},
- { 324,"Guinea"},
- { 328,"Guyana"},
- { 332,"Haiti"},
- { 334,"Heard Island and McDonald Islands"},
- { 336,"Holy See (Vatican City State)"},
- { 340,"Honduras"},
- { 344,"Hong Kong"},
- { 348,"Hungary,Magyarország"},
- { 352,"Iceland"},
- { 356,"India"},
- { 360,"Indonesia"},
- { 364,"Iran, Islamic Republic of"},
- { 368,"Iraq"},
- { 372,"Ireland"},
- { 376,"Israel"},
- { 380,"Italy,Italia"},
- { 384,"Côte d'Ivoire"},
- { 388,"Jamaica"},
- { 392,"Japan"},
- { 398,"Kazakhstan"},
- { 400,"Jordan"},
- { 404,"Kenya"},
- { 408,"Korea, Democratic People's Republic of"},
- { 410,"Korea, Republic of"},
- { 414,"Kuwait"},
- { 417,"Kyrgyzstan"},
- { 418,"Lao People's Democratic Republic"},
- { 422,"Lebanon"},
- { 426,"Lesotho"},
- { 428,"Latvia"},
- { 430,"Liberia"},
- { 434,"Libyan Arab Jamahiriya"},
- { 438,"Liechtenstein"},
- { 440,"Lithuania,Lietuva"},
- { 442,"Luxembourg"},
- { 446,"Macao"},
- { 450,"Madagascar"},
- { 454,"Malawi"},
- { 458,"Malaysia"},
- { 462,"Maldives"},
- { 466,"Mali"},
- { 470,"Malta"},
- { 474,"Martinique"},
- { 478,"Mauritania"},
- { 480,"Mauritius"},
- { 484,"Mexico"},
- { 492,"Monaco"},
- { 496,"Mongolia"},
- { 498,"Moldova, Republic of"},
- { 499,"Montenegro,Црна Гора,Crna Gora"},
- { 500,"Montserrat"},
- { 504,"Morocco"},
- { 508,"Mozambique"},
- { 512,"Oman"},
- { 516,"Namibia"},
- { 520,"Nauru"},
- { 524,"Nepal"},
- { 528,"Nederland,The Netherlands,Niederlande,NL,Netherlands","3c567M"},
- { 530,"Netherlands Antilles"},
- { 531,"Curacao"},
- { 533,"Aruba"},
- { 534,"Sint Maarten (Dutch part)"},
- { 535,"Bonaire, Sint Eustatius and Saba"},
- { 540,"New Caledonia"},
- { 548,"Vanuatu"},
- { 554,"New Zealand"},
- { 558,"Nicaragua"},
- { 562,"Niger"},
- { 566,"Nigeria"},
- { 570,"Niue"},
- { 574,"Norfolk Island"},
- { 578,"Norway,Norge,Noreg,NO"},
- { 580,"Northern Mariana Islands"},
- { 581,"United States Minor Outlying Islands"},
- { 583,"Micronesia, Federated States of"},
- { 584,"Marshall Islands"},
- { 585,"Palau"},
- { 586,"Pakistan"},
- { 591,"Panama"},
- { 598,"Papua New Guinea"},
- { 600,"Paraguay"},
- { 604,"Peru"},
- { 608,"Philippines"},
- { 612,"Pitcairn"},
- { 616,"Poland,Polska,PL","3s5cmT"},
- { 620,"Portugal"},
- { 624,"Guinea-Bissau"},
- { 626,"Timor-Leste"},
- { 630,"Puerto Rico"},
- { 634,"Qatar"},
- { 638,"Réunion"},
- { 642,"România,Romania,RO"},
- { 643,"Россия,Российская Федерация,Russia,Russian Federation","3s5c7m"},
- { 646,"Rwanda"},
- { 652,"Saint Barthélemy"},
- { 654,"Saint Helena, Ascension and Tristan da Cunha"},
- { 659,"Saint Kitts and Nevis"},
- { 660,"Anguilla"},
- { 662,"Saint Lucia"},
- { 663,"Saint Martin (French part)"},
- { 666,"Saint Pierre and Miquelon"},
- { 670,"Saint Vincent and the Grenadines"},
- { 674,"San Marino"},
- { 678,"Sao Tome and Principe"},
- { 682,"Saudi Arabia"},
- { 686,"Senegal"},
- { 688,"Srbija,Србија,Serbia"},
- { 690,"Seychelles"},
- { 694,"Sierra Leone"},
- { 702,"Singapore"},
- { 703,"Slovakia,Slovensko,SK"},
- { 704,"Viet Nam"},
- { 705,"Slovenia,Republika Slovenija,SI"},
- { 706,"Somalia"},
- { 710,"South Africa"},
- { 716,"Zimbabwe"},
- { 724,"Spain,Espana,España,Reino de Espana,Reino de España","345scm"},
- { 728,"South Sudan"},
- { 732,"Western Sahara"},
- { 736,"Sudan"},
- { 740,"Suriname"},
- { 744,"Svalbard and Jan Mayen"},
- { 748,"Swaziland"},
- { 752,"Sweden,Sverige,Konungariket Sverige,SE"},
- { 756,"Switzerland,Schweiz","3s5c7M"},
- { 760,"Syrian Arab Republic"},
- { 762,"Tajikistan"},
- { 764,"Thailand"},
- { 768,"Togo"},
- { 772,"Tokelau"},
- { 776,"Tonga"},
- { 780,"Trinidad and Tobago"},
- { 784,"United Arab Emirates"},
- { 788,"Tunisia"},
- { 792,"Turkey"},
- { 795,"Turkmenistan"},
- { 796,"Turks and Caicos Islands"},
- { 798,"Tuvalu"},
- { 800,"Uganda"},
- { 804,"Ukraine","3s5c78"},
- { 807,"Macedonia,Македонија"},
- { 818,"Egypt"},
- { 826,"United Kingdom,UK","3s5c7m"},
- { 831,"Guernsey"},
- { 832,"Jersey"},
- { 833,"Isle of Man"},
- { 834,"Tanzania, United Republic of"},
- { 840,"USA","3s5c7m"},
- { 850,"Virgin Islands, U.S."},
- { 854,"Burkina Faso"},
- { 858,"Uruguay"},
- { 860,"Uzbekistan"},
- { 862,"Venezuela, Bolivarian Republic of"},
- { 876,"Wallis and Futuna"},
- { 882,"Samoa"},
- { 887,"Yemen"},
- { 894,"Zambia"},
- { 999,"Unknown"},
+ { 4,"Afghanistan"},
+ { 8,"Albania"},
+ { 10,"Antarctica"},
+ { 12,"Algeria"},
+ { 16,"American Samoa"},
+ { 20,"Andorra"},
+ { 24,"Angola"},
+ { 28,"Antigua and Barbuda"},
+ { 31,"Azerbaijan"},
+ { 32,"Argentina,República Argentina,AR "},
+ { 36,"Australia,AUS"},
+ { 40,"Austria,Österreich,AUT"},
+ { 44,"Bahamas"},
+ { 48,"Bahrain"},
+ { 50,"Bangladesh"},
+ { 51,"Armenia"},
+ { 52,"Barbados"},
+ { 56,"Belgium,Belgique,Belgie,België,Belgien","345c7M"},
+ { 60,"Bermuda"},
+ { 64,"Bhutan"},
+ { 68,"Bolivia, Plurinational State of"},
+ { 70,"Bosnia and Herzegovina,Bosna i Hercegovina,Босна и Херцеговина"},
+ { 72,"Botswana"},
+ { 74,"Bouvet Island"},
+ { 76,"Brazil"},
+ { 84,"Belize"},
+ { 86,"British Indian Ocean Territory"},
+ { 90,"Solomon Islands"},
+ { 92,"Virgin Islands, British"},
+ { 96,"Brunei Darussalam"},
+ { 100,"Bulgaria,България"},
+ { 104,"Myanmar"},
+ { 108,"Burundi"},
+ { 112,"Belarus"},
+ { 116,"Cambodia"},
+ { 120,"Cameroon"},
+ { 124,"Canada"},
+ { 132,"Cape Verde"},
+ { 136,"Cayman Islands"},
+ { 140,"Central African Republic"},
+ { 144,"Sri Lanka"},
+ { 148,"Chad"},
+ { 152,"Chile"},
+ { 156,"China"},
+ { 158,"Taiwan, Province of China"},
+ { 162,"Christmas Island"},
+ { 166,"Cocos (Keeling) Islands"},
+ { 170,"Colombia"},
+ { 174,"Comoros"},
+ { 175,"Mayotte"},
+ { 178,"Congo"},
+ { 180,"Congo, the Democratic Republic of the"},
+ { 184,"Cook Islands"},
+ { 188,"Costa Rica"},
+ { 191,"Croatia,Republika Hrvatska,HR"},
+ { 192,"Cuba"},
+ { 196,"Cyprus"},
+ { 203,"Czech Republic,Česká republika,CZ"},
+ { 204,"Benin"},
+ { 208,"Denmark,Danmark,DK"},
+ { 212,"Dominica"},
+ { 214,"Dominican Republic"},
+ { 218,"Ecuador"},
+ { 222,"El Salvador"},
+ { 226,"Equatorial Guinea"},
+ { 231,"Ethiopia"},
+ { 232,"Eritrea"},
+ { 233,"Estonia"},
+ { 234,"Faroe Islands,Føroyar"},
+ { 238,"Falkland Islands (Malvinas)"},
+ { 239,"South Georgia and the South Sandwich Islands"},
+ { 242,"Fiji"},
+ { 246,"Finland,Suomi"},
+ { 248,"Åland Islands"},
+ { 250,"France,République française,FR","3s5c7M"},
+ { 254,"French Guiana"},
+ { 258,"French Polynesia"},
+ { 260,"French Southern Territories"},
+ { 262,"Djibouti"},
+ { 266,"Gabon"},
+ { 268,"Georgia"},
+ { 270,"Gambia"},
+ { 275,"Palestinian Territory, Occupied"},
+ { 276,"Germany,Deutschland,Bundesrepublik Deutschland","345c7M"},
+ { 288,"Ghana"},
+ { 292,"Gibraltar"},
+ { 296,"Kiribati"},
+ { 300,"Greece"},
+ { 304,"Greenland"},
+ { 308,"Grenada"},
+ { 312,"Guadeloupe"},
+ { 316,"Guam"},
+ { 320,"Guatemala"},
+ { 324,"Guinea"},
+ { 328,"Guyana"},
+ { 332,"Haiti"},
+ { 334,"Heard Island and McDonald Islands"},
+ { 336,"Holy See (Vatican City State)"},
+ { 340,"Honduras"},
+ { 344,"Hong Kong"},
+ { 348,"Hungary,Magyarország"},
+ { 352,"Iceland"},
+ { 356,"India"},
+ { 360,"Indonesia"},
+ { 364,"Iran, Islamic Republic of"},
+ { 368,"Iraq"},
+ { 372,"Ireland"},
+ { 376,"Israel"},
+ { 380,"Italy,Italia"},
+ { 384,"Côte d'Ivoire"},
+ { 388,"Jamaica"},
+ { 392,"Japan"},
+ { 398,"Kazakhstan"},
+ { 400,"Jordan"},
+ { 404,"Kenya"},
+ { 408,"Korea, Democratic People's Republic of"},
+ { 410,"Korea, Republic of"},
+ { 414,"Kuwait"},
+ { 417,"Kyrgyzstan"},
+ { 418,"Lao People's Democratic Republic"},
+ { 422,"Lebanon"},
+ { 426,"Lesotho"},
+ { 428,"Latvia"},
+ { 430,"Liberia"},
+ { 434,"Libyan Arab Jamahiriya"},
+ { 438,"Liechtenstein"},
+ { 440,"Lithuania,Lietuva"},
+ { 442,"Luxembourg"},
+ { 446,"Macao"},
+ { 450,"Madagascar"},
+ { 454,"Malawi"},
+ { 458,"Malaysia"},
+ { 462,"Maldives"},
+ { 466,"Mali"},
+ { 470,"Malta"},
+ { 474,"Martinique"},
+ { 478,"Mauritania"},
+ { 480,"Mauritius"},
+ { 484,"Mexico"},
+ { 492,"Monaco"},
+ { 496,"Mongolia"},
+ { 498,"Moldova, Republic of"},
+ { 499,"Montenegro,Црна Гора,Crna Gora"},
+ { 500,"Montserrat"},
+ { 504,"Morocco"},
+ { 508,"Mozambique"},
+ { 512,"Oman"},
+ { 516,"Namibia"},
+ { 520,"Nauru"},
+ { 524,"Nepal"},
+ { 528,"Nederland,The Netherlands,Niederlande,NL,Netherlands","3c567M"},
+ { 530,"Netherlands Antilles"},
+ { 531,"Curacao"},
+ { 533,"Aruba"},
+ { 534,"Sint Maarten (Dutch part)"},
+ { 535,"Bonaire, Sint Eustatius and Saba"},
+ { 540,"New Caledonia"},
+ { 548,"Vanuatu"},
+ { 554,"New Zealand"},
+ { 558,"Nicaragua"},
+ { 562,"Niger"},
+ { 566,"Nigeria"},
+ { 570,"Niue"},
+ { 574,"Norfolk Island"},
+ { 578,"Norway,Norge,Noreg,NO"},
+ { 580,"Northern Mariana Islands"},
+ { 581,"United States Minor Outlying Islands"},
+ { 583,"Micronesia, Federated States of"},
+ { 584,"Marshall Islands"},
+ { 585,"Palau"},
+ { 586,"Pakistan"},
+ { 591,"Panama"},
+ { 598,"Papua New Guinea"},
+ { 600,"Paraguay"},
+ { 604,"Peru"},
+ { 608,"Philippines"},
+ { 612,"Pitcairn"},
+ { 616,"Poland,Polska,PL","3s5cmT"},
+ { 620,"Portugal"},
+ { 624,"Guinea-Bissau"},
+ { 626,"Timor-Leste"},
+ { 630,"Puerto Rico"},
+ { 634,"Qatar"},
+ { 638,"Réunion"},
+ { 642,"România,Romania,RO"},
+ { 643,"Россия,Российская Федерация,Russia,Russian Federation","3s5c7m"},
+ { 646,"Rwanda"},
+ { 652,"Saint Barthélemy"},
+ { 654,"Saint Helena, Ascension and Tristan da Cunha"},
+ { 659,"Saint Kitts and Nevis"},
+ { 660,"Anguilla"},
+ { 662,"Saint Lucia"},
+ { 663,"Saint Martin (French part)"},
+ { 666,"Saint Pierre and Miquelon"},
+ { 670,"Saint Vincent and the Grenadines"},
+ { 674,"San Marino"},
+ { 678,"Sao Tome and Principe"},
+ { 682,"Saudi Arabia"},
+ { 686,"Senegal"},
+ { 688,"Srbija,Србија,Serbia"},
+ { 690,"Seychelles"},
+ { 694,"Sierra Leone"},
+ { 702,"Singapore"},
+ { 703,"Slovakia,Slovensko,SK"},
+ { 704,"Viet Nam"},
+ { 705,"Slovenia,Republika Slovenija,SI"},
+ { 706,"Somalia"},
+ { 710,"South Africa"},
+ { 716,"Zimbabwe"},
+ { 724,"Spain,Espana,España,Reino de Espana,Reino de España","345scm"},
+ { 728,"South Sudan"},
+ { 732,"Western Sahara"},
+ { 736,"Sudan"},
+ { 740,"Suriname"},
+ { 744,"Svalbard and Jan Mayen"},
+ { 748,"Swaziland"},
+ { 752,"Sweden,Sverige,Konungariket Sverige,SE"},
+ { 756,"Switzerland,Schweiz","3s5c7M"},
+ { 760,"Syrian Arab Republic"},
+ { 762,"Tajikistan"},
+ { 764,"Thailand"},
+ { 768,"Togo"},
+ { 772,"Tokelau"},
+ { 776,"Tonga"},
+ { 780,"Trinidad and Tobago"},
+ { 784,"United Arab Emirates"},
+ { 788,"Tunisia"},
+ { 792,"Turkey"},
+ { 795,"Turkmenistan"},
+ { 796,"Turks and Caicos Islands"},
+ { 798,"Tuvalu"},
+ { 800,"Uganda"},
+ { 804,"Ukraine","3s5c78"},
+ { 807,"Macedonia,Македонија"},
+ { 818,"Egypt"},
+ { 826,"United Kingdom,UK","3s5c7m"},
+ { 831,"Guernsey"},
+ { 832,"Jersey"},
+ { 833,"Isle of Man"},
+ { 834,"Tanzania, United Republic of"},
+ { 840,"USA","3s5c7m"},
+ { 850,"Virgin Islands, U.S."},
+ { 854,"Burkina Faso"},
+ { 858,"Uruguay"},
+ { 860,"Uzbekistan"},
+ { 862,"Venezuela, Bolivarian Republic of"},
+ { 876,"Wallis and Futuna"},
+ { 882,"Samoa"},
+ { 887,"Yemen"},
+ { 894,"Zambia"},
+ { 999,"Unknown"},
};
// first char - item type
@@ -402,448 +402,444 @@ struct country_table {
// =? - used both for nodes and ways
// otherwise - nodes
-static char *attrmap={
- "n *=* point_unkn\n"
- "? addr:housenumber=* house_number\n"
- "? aeroway=aerodrome poi_airport\n"
- "? aeroway=airport poi_airport\n"
- "? aeroway=helipad poi_heliport\n"
- "? aeroway=terminal poi_airport\n"
- "? amenity=atm poi_atm\n"
- "? amenity=bank poi_bank\n"
- "? amenity=bar poi_bar\n"
- "n amenity=bench poi_bench\n"
- "? amenity=bicycle_rental poi_bicycle_rental\n"
- "? amenity=bicycle_parking poi_bicycle_parking\n"
- "? amenity=biergarten poi_biergarten\n"
- "? amenity=bus_station poi_bus_station\n"
- "? amenity=cafe poi_cafe\n"
- "? amenity=car_sharing poi_car_sharing\n"
- "? amenity=car_wash poi_car_wash\n"
- "? amenity=cinema poi_cinema\n"
- "? amenity=college poi_school_college\n"
- "? amenity=courthouse poi_justice\n"
- "? amenity=drinking_water poi_potable_water\n"
- "? amenity=fast_food poi_fastfood\n"
- "? amenity=fire_station poi_firebrigade\n"
- "? amenity=fountain poi_fountain\n"
- "? amenity=fuel poi_fuel\n"
- "? amenity=grave_yard poi_cemetery\n"
- "? amenity=hospital poi_hospital\n"
- "? amenity=hunting_stand poi_hunting_stand\n"
- "? amenity=kindergarten poi_kindergarten\n"
- "? amenity=library poi_library\n"
- "? amenity=nightclub poi_nightclub\n"
- "? amenity=park_bench poi_bench\n"
- "? amenity=parking poi_car_parking\n"
- "? amenity=pharmacy poi_pharmacy\n"
- "? amenity=place_of_worship,religion=christian poi_church\n"
- "? amenity=place_of_worship poi_worship\n"
- "? amenity=police poi_police\n"
- "? amenity=post_box poi_post_box\n"
- "? amenity=post_office poi_post_office\n"
- "? amenity=prison poi_prison\n"
- "? amenity=pub poi_pub\n"
- "? amenity=public_building poi_public_office\n"
- "? amenity=recycling poi_recycling\n"
- "? amenity=restaurant,cuisine=fine_dining poi_dining\n"
- "? amenity=restaurant poi_restaurant\n"
- "? amenity=school poi_school\n"
- "? amenity=shelter poi_shelter\n"
- "? amenity=taxi poi_taxi\n"
- "? amenity=tec_common tec_common\n"
- "? amenity=telephone poi_telephone\n"
- "? amenity=theatre poi_theater\n"
- "? amenity=toilets poi_restroom\n"
- "? amenity=townhall poi_townhall\n"
- "? amenity=university poi_school_university\n"
- "? amenity=vending_machine poi_vending_machine\n"
- "n barrier=bollard barrier_bollard\n"
- "n barrier=cycle_barrier barrier_cycle\n"
- "n barrier=lift_gate barrier_lift_gate\n"
- "? car=car_rental poi_car_rent\n"
- "? highway=bus_station poi_bus_station\n"
- "? highway=bus_stop poi_bus_stop\n"
- "n highway=mini_roundabout mini_roundabout\n"
- "n highway=motorway_junction highway_exit\n"
- "n highway=stop traffic_sign_stop\n"
- "n highway=toll_booth poi_toll_booth\n"
- "n highway=traffic_signals traffic_signals\n"
- "n highway=turning_circle turning_circle\n"
- "? historic=boundary_stone poi_boundary_stone\n"
- "? historic=castle poi_castle\n"
- "? historic=memorial poi_memorial\n"
- "? historic=monument poi_monument\n"
- "? historic=ruins poi_ruins\n"
+static char *attrmap= {
+ "n *=* point_unkn\n"
+ "? addr:housenumber=* house_number\n"
+ "? aeroway=aerodrome poi_airport\n"
+ "? aeroway=airport poi_airport\n"
+ "? aeroway=helipad poi_heliport\n"
+ "? aeroway=terminal poi_airport\n"
+ "? amenity=atm poi_atm\n"
+ "? amenity=bank poi_bank\n"
+ "? amenity=bar poi_bar\n"
+ "n amenity=bench poi_bench\n"
+ "? amenity=bicycle_rental poi_bicycle_rental\n"
+ "? amenity=bicycle_parking poi_bicycle_parking\n"
+ "? amenity=biergarten poi_biergarten\n"
+ "? amenity=bus_station poi_bus_station\n"
+ "? amenity=cafe poi_cafe\n"
+ "? amenity=car_sharing poi_car_sharing\n"
+ "? amenity=car_wash poi_car_wash\n"
+ "? amenity=cinema poi_cinema\n"
+ "? amenity=college poi_school_college\n"
+ "? amenity=courthouse poi_justice\n"
+ "? amenity=drinking_water poi_potable_water\n"
+ "? amenity=fast_food poi_fastfood\n"
+ "? amenity=fire_station poi_firebrigade\n"
+ "? amenity=fountain poi_fountain\n"
+ "? amenity=fuel poi_fuel\n"
+ "? amenity=grave_yard poi_cemetery\n"
+ "? amenity=hospital poi_hospital\n"
+ "? amenity=hunting_stand poi_hunting_stand\n"
+ "? amenity=kindergarten poi_kindergarten\n"
+ "? amenity=library poi_library\n"
+ "? amenity=nightclub poi_nightclub\n"
+ "? amenity=park_bench poi_bench\n"
+ "? amenity=parking poi_car_parking\n"
+ "? amenity=pharmacy poi_pharmacy\n"
+ "? amenity=place_of_worship,religion=christian poi_church\n"
+ "? amenity=place_of_worship poi_worship\n"
+ "? amenity=police poi_police\n"
+ "? amenity=post_box poi_post_box\n"
+ "? amenity=post_office poi_post_office\n"
+ "? amenity=prison poi_prison\n"
+ "? amenity=pub poi_pub\n"
+ "? amenity=public_building poi_public_office\n"
+ "? amenity=recycling poi_recycling\n"
+ "? amenity=restaurant,cuisine=fine_dining poi_dining\n"
+ "? amenity=restaurant poi_restaurant\n"
+ "? amenity=school poi_school\n"
+ "? amenity=shelter poi_shelter\n"
+ "? amenity=taxi poi_taxi\n"
+ "? amenity=tec_common tec_common\n"
+ "? amenity=telephone poi_telephone\n"
+ "? amenity=theatre poi_theater\n"
+ "? amenity=toilets poi_restroom\n"
+ "? amenity=townhall poi_townhall\n"
+ "? amenity=university poi_school_university\n"
+ "? amenity=vending_machine poi_vending_machine\n"
+ "n barrier=bollard barrier_bollard\n"
+ "n barrier=cycle_barrier barrier_cycle\n"
+ "n barrier=lift_gate barrier_lift_gate\n"
+ "? car=car_rental poi_car_rent\n"
+ "? highway=bus_station poi_bus_station\n"
+ "? highway=bus_stop poi_bus_stop\n"
+ "n highway=mini_roundabout mini_roundabout\n"
+ "n highway=motorway_junction highway_exit\n"
+ "n highway=stop traffic_sign_stop\n"
+ "n highway=toll_booth poi_toll_booth\n"
+ "n highway=traffic_signals traffic_signals\n"
+ "n highway=turning_circle turning_circle\n"
+ "? historic=boundary_stone poi_boundary_stone\n"
+ "? historic=castle poi_castle\n"
+ "? historic=memorial poi_memorial\n"
+ "? historic=monument poi_monument\n"
+ "? historic=ruins poi_ruins\n"
// "? historic=* poi_ruins\n"
- "? landuse=cemetery poi_cemetery\n"
- "? leisure=fishing poi_fish\n"
- "? leisure=golf_course poi_golf\n"
- "? leisure=marina poi_marine\n"
- "? leisure=playground poi_playground\n"
- "? leisure=slipway poi_boat_ramp\n"
- "? leisure=sports_centre poi_sport\n"
- "? leisure=stadium poi_stadium\n"
- "? man_made=tower poi_tower\n"
- "? military=airfield poi_military\n"
- "? military=barracks poi_military\n"
- "? military=bunker poi_military\n"
- "? military=danger_area poi_danger_area\n"
- "? military=range poi_military\n"
- "? natural=bay poi_bay\n"
- "? natural=peak,ele=* poi_peak\n" // show only major peaks with elevation
- "? natural=tree poi_tree\n"
- "n place=city town_label_2e5\n"
- "n place=hamlet town_label_2e2\n"
- "n place=locality town_label_2e0\n"
- "n place=suburb district_label\n"
- "n place=town town_label_2e4\n"
- "n place=village town_label_2e3\n"
- "n power=tower power_tower\n"
- "n power=sub_station power_substation\n"
- "n railway=halt poi_rail_halt\n"
- "n railway=level_crossing poi_level_crossing\n"
- "? railway=station poi_rail_station\n"
- "? railway=tram_stop poi_rail_tram_stop\n"
- "? shop=baker poi_shop_baker\n"
- "? shop=bakery poi_shop_baker\n"
- "? shop=beverages poi_shop_beverages\n"
- "? shop=bicycle poi_shop_bicycle\n"
- "? shop=butcher poi_shop_butcher\n"
- "? shop=car poi_car_dealer_parts\n"
- "? shop=car_repair poi_repair_service\n"
- "? shop=clothes poi_shop_apparel\n"
- "? shop=convenience poi_shop_grocery\n"
- "? shop=chemist poi_shop_drugstore\n"
- "? shop=florist poi_shop_florist\n"
- "? shop=fruit poi_shop_fruit\n"
- "? shop=furniture poi_shop_furniture\n"
- "? shop=garden_centre poi_shop_handg\n"
- "? shop=hardware poi_shop_handg\n"
- "? shop=hairdresser poi_hairdresser\n"
- "? shop=kiosk poi_shop_kiosk\n"
- "? shop=optician poi_shop_optician\n"
- "? shop=parfum poi_shop_parfum\n"
- "? shop=photo poi_shop_photo\n"
- "? shop=shoes poi_shop_shoes\n"
- "? shop=supermarket poi_shopping\n"
- "? shop=mall poi_mall\n"
- "? sport=10pin poi_bowling\n"
- "? sport=baseball poi_baseball\n"
- "? sport=basketball poi_basketball\n"
- "? sport=climbing poi_climbing\n"
- "? sport=golf poi_golf\n"
- "? sport=motor_sports poi_motor_sport\n"
- "? sport=skiing poi_skiing\n"
- "? sport=soccer poi_soccer\n"
- "? sport=stadium poi_stadium\n"
- "? sport=swimming poi_swimming\n"
- "? sport=tennis poi_tennis\n"
- "? tourism=attraction poi_attraction\n"
- "? tourism=camp_site poi_camp_rv\n"
- "? tourism=caravan_site poi_camp_rv\n"
- "? tourism=guest_house poi_guesthouse\n"
- "? tourism=hostel poi_hostel\n"
- "? tourism=hotel poi_hotel\n"
- "? tourism=information poi_information\n"
- "? tourism=motel poi_motel\n"
- "? tourism=museum poi_museum_history\n"
- "? tourism=picnic_site poi_picnic\n"
- "? tourism=theme_park poi_resort\n"
- "? tourism=viewpoint poi_viewpoint\n"
- "? tourism=zoo poi_zoo\n"
- "n traffic_sign=city_limit traffic_sign_city_limit\n"
- "n highway=speed_camera tec_common\n"
- "w *=* street_unkn\n"
- "w addr:interpolation=even house_number_interpolation_even\n"
- "w addr:interpolation=odd house_number_interpolation_odd\n"
- "w addr:interpolation=all house_number_interpolation_all\n"
- "w addr:interpolation=alphabetic house_number_interpolation_alphabetic\n"
- "w aerialway=cable_car lift_cable_car\n"
- "w aerialway=chair_lift lift_chair\n"
- "w aerialway=drag_lift lift_drag\n"
- "w aeroway=aerodrome poly_airport\n"
- "w aeroway=apron poly_apron\n"
- "w aeroway=runway aeroway_runway\n"
- "w aeroway=taxiway aeroway_taxiway\n"
- "w aeroway=terminal poly_terminal\n"
- "w amenity=college poly_college\n"
- "w amenity=grave_yard poly_cemetery\n"
- "w amenity=parking poly_car_parking\n"
- "w amenity=place_of_worship poly_building\n"
- "w amenity=university poly_university\n"
- "w boundary=administrative,admin_level=2 border_country\n"
- "w boundary=civil border_civil\n"
- "w boundary=national_park border_national_park\n"
- "w boundary=political border_political\n"
- "w building=* poly_building\n"
- "w contour_ext=elevation_major height_line_1\n"
- "w contour_ext=elevation_medium height_line_2\n"
- "w contour_ext=elevation_minor height_line_3\n"
- "w highway=bridleway bridleway\n"
- "w highway=bus_guideway bus_guideway\n"
- "w highway=construction street_construction\n"
- "w highway=cyclepath cycleway\n"
- "w highway=cycleway cycleway\n"
- "w highway=footway footway\n"
- "w highway=footway,piste:type=nordic footway_and_piste_nordic\n"
- "w highway=living_street living_street\n"
- "w highway=minor street_1_land\n"
- "w highway=parking_lane street_parking_lane\n"
- "w highway=path path\n"
- "w highway=path,bicycle=designated cycleway\n"
- "w highway=path,bicycle=official cycleway\n"
- "w highway=path,bicycle=designated,foot=designated cycleway\n"
- "w highway=path,bicycle=official,foot=official cycleway\n"
- "w highway=path,foot=designated footway\n"
- "w highway=path,foot=official footway\n"
- "w highway=path,horse=designated bridleway\n"
- "w highway=path,horse=official bridleway\n"
- "w highway=path,sac_scale=alpine_hiking hiking_alpine\n"
- "w highway=path,sac_scale=demanding_alpine_hiking hiking_alpine_demanding\n"
- "w highway=path,sac_scale=demanding_mountain_hiking hiking_mountain_demanding\n"
- "w highway=path,sac_scale=difficult_alpine_hiking hiking_alpine_difficult\n"
- "w highway=path,sac_scale=hiking hiking\n"
- "w highway=path,sac_scale=mountain_hiking hiking_mountain\n"
- "w highway=pedestrian street_pedestrian\n"
- "w highway=pedestrian,area=1 poly_pedestrian\n"
- "w highway=plaza poly_plaza\n"
- "w highway=motorway highway_land\n"
- "w highway=motorway,rural=0 highway_city\n"
- "w highway=motorway_link ramp\n"
- "w highway=trunk street_n_lanes\n"
- "w highway=trunk_link ramp\n"
- "w highway=primary street_4_land\n"
- "w highway=primary,name=*,rural=1 street_4_land\n"
- "w highway=primary,name=* street_4_city\n"
- "w highway=primary,rural=0 street_4_city\n"
- "w highway=primary_link ramp\n"
- "w highway=secondary street_3_land\n"
- "w highway=secondary,name=*,rural=1 street_3_land\n"
- "w highway=secondary,name=* street_3_city\n"
- "w highway=secondary,rural=0 street_3_city\n"
- "w highway=secondary,area=1 poly_street_3\n"
- "w highway=secondary_link ramp\n"
- "w highway=tertiary street_2_land\n"
- "w highway=tertiary,name=*,rural=1 street_2_land\n"
- "w highway=tertiary,name=* street_2_city\n"
- "w highway=tertiary,rural=0 street_2_city\n"
- "w highway=tertiary,area=1 poly_street_2\n"
- "w highway=tertiary_link ramp\n"
- "w highway=residential street_1_city\n"
- "w highway=residential,area=1 poly_street_1\n"
- "w highway=unclassified street_1_city\n"
- "w highway=unclassified,area=1 poly_street_1\n"
- "w highway=road street_1_city\n"
- "w highway=service street_service\n"
- "w highway=service,area=1 poly_service\n"
- "w highway=service,service=parking_aisle street_parking_lane\n"
- "w highway=track track_gravelled\n"
- "w highway=track,surface=grass track_grass\n"
- "w highway=track,surface=gravel track_gravelled\n"
- "w highway=track,surface=ground track_ground\n"
- "w highway=track,surface=paved track_paved\n"
- "w highway=track,surface=unpaved track_unpaved\n"
- "w highway=track,tracktype=grade1 track_paved\n"
- "w highway=track,tracktype=grade2 track_gravelled\n"
- "w highway=track,tracktype=grade3 track_unpaved\n"
- "w highway=track,tracktype=grade4 track_ground\n"
- "w highway=track,tracktype=grade5 track_grass\n"
- "w highway=track,surface=paved,tracktype=grade1 track_paved\n"
- "w highway=track,surface=gravel,tracktype=grade2 track_gravelled\n"
- "w highway=track,surface=unpaved,tracktype=grade3 track_unpaved\n"
- "w highway=track,surface=ground,tracktype=grade4 track_ground\n"
- "w highway=track,surface=grass,tracktype=grade5 track_grass\n"
- "w highway=unsurfaced track_gravelled\n"
- "w highway=steps steps\n"
- "w historic=archaeological_site poly_archaeological_site\n"
- "w historic=battlefield poly_battlefield\n"
- "w historic=ruins poly_ruins\n"
- "w historic=town_gate poly_building\n"
- "w landuse=allotments poly_allotments\n"
- "w landuse=basin poly_basin\n"
- "w landuse=brownfield poly_brownfield\n"
- "w landuse=cemetery poly_cemetery\n"
- "w landuse=commercial poly_commercial\n"
- "w landuse=construction poly_construction\n"
- "w landuse=farm poly_farm\n"
- "w landuse=farmland poly_farm\n"
- "w landuse=farmyard poly_town\n"
- "w landuse=forest poly_wood\n"
- "w landuse=grass poly_meadow\n"
- "w landuse=greenfield poly_greenfield\n"
- "w landuse=industrial poly_industry\n"
- "w landuse=landfill poly_landfill\n"
- "w landuse=military poly_military\n"
- "w landuse=meadow poly_meadow\n"
- "w landuse=plaza poly_plaza\n"
- "w landuse=quarry poly_quarry\n"
- "w landuse=railway poly_railway\n"
- "w landuse=recreation_ground poly_recreation_ground\n"
- "w landuse=reservoir poly_reservoir\n"
- "w landuse=residential poly_town\n"
- "w landuse=residential,area=1 poly_town\n"
- "w landuse=retail poly_retail\n"
- "w landuse=village_green poly_village_green\n"
- "w landuse=vineyard poly_farm\n"
- "w landuse=depot poly_depot\n"
- "w landuse=garages poly_garages\n"
- "w landuse=greenhouse_horticulture poly_greenhouse\n"
- "w landuse=orchard poly_orchard\n"
- "w landuse=plant_nursery poly_plantnursery\n"
- "w landuse=port poly_port\n"
- "w landuse=salt_pond poly_saltpond\n"
- "w leisure=common poly_common\n"
- "w leisure=fishing poly_fishing\n"
- "w leisure=garden poly_garden\n"
- "w leisure=golf_course poly_golf_course\n"
- "w leisure=marina poly_marina\n"
- "w leisure=nature_reserve poly_nature_reserve\n"
- "w leisure=park poly_park\n"
- "w leisure=pitch poly_sports_pitch\n"
- "w leisure=playground poly_playground\n"
- "w leisure=sports_centre poly_sport\n"
- "w leisure=stadium poly_sports_stadium\n"
- "w leisure=track poly_sports_track\n"
- "w leisure=water_park poly_water_park\n"
- "w military=airfield poly_airfield\n"
- "w military=barracks poly_barracks\n"
- "w military=danger_area poly_danger_area\n"
- "w military=naval_base poly_naval_base\n"
- "w military=range poly_range\n"
- "w natural=beach poly_beach\n"
- "w natural=coastline water_line\n"
- "w natural=fell poly_fell\n"
- "w natural=glacier poly_glacier\n"
- "w natural=grassland poly_meadow\n"
- "w natural=heath poly_heath\n"
- "w natural=land poly_land\n"
- "w natural=marsh poly_marsh\n"
- "w natural=meadow poly_meadow\n"
- "w natural=mud poly_mud\n"
- "w natural=sand poly_beach\n"
- "w natural=scree poly_scree\n"
- "w natural=scrub poly_scrub\n"
- "w natural=water poly_water\n"
- "w natural=wetland poly_mud\n"
- "w natural=wood poly_wood\n"
- "w piste:type=downhill,piste:difficulty=advanced piste_downhill_advanced\n"
- "w piste:type=downhill,piste:difficulty=easy piste_downhill_easy\n"
- "w piste:type=downhill,piste:difficulty=expert piste_downhill_expert\n"
- "w piste:type=downhill,piste:difficulty=freeride piste_downhill_freeride\n"
- "w piste:type=downhill,piste:difficulty=intermediate piste_downhill_intermediate\n"
- "w piste:type=downhill,piste:difficulty=novice piste_downhill_novice\n"
- "w piste:type=nordic piste_nordic\n"
- "w place=suburb poly_place1\n"
- "w place=hamlet poly_place2\n"
- "w place=isolated_dwelling poly_place2\n"
- "w place=locality poly_place2\n"
- "w place=village poly_place3\n"
- "w place=municipality poly_place4\n"
- "w place=town poly_place5\n"
- "w place=city poly_place6\n"
- "w de:place=city poly_place6\n"
- "w power=line powerline\n"
- "w railway=abandoned rail_abandoned\n"
- "w railway=disused rail_disused\n"
- "w railway=light_rail rail_light\n"
- "w railway=monorail rail_mono\n"
- "w railway=narrow_gauge rail_narrow_gauge\n"
- "w railway=preserved rail_preserved\n"
- "w railway=rail rail\n"
- "w railway=subway rail_subway\n"
- "w railway=tram rail_tram\n"
- "w route=ferry ferry\n"
- "w route=ski piste_nordic\n"
- "w sport=* poly_sport\n"
- "w tourism=artwork poly_artwork\n"
- "w tourism=attraction poly_attraction\n"
- "w tourism=camp_site poly_camp_site\n"
- "w tourism=caravan_site poly_caravan_site\n"
- "w tourism=picnic_site poly_picnic_site\n"
- "w tourism=theme_park poly_theme_park\n"
- "w tourism=zoo poly_zoo\n"
- "w waterway=canal water_canal\n"
- "w waterway=drain water_drain\n"
- "w waterway=river water_river\n"
- "w waterway=riverbank poly_water\n"
- "w waterway=stream water_stream\n"
- "w barrier=ditch ditch\n"
- "w barrier=hedge hedge\n"
- "w barrier=fence fence\n"
- "w barrier=wall wall\n"
- "w barrier=retaining_wall retaining_wall\n"
- "w barrier=city_wall city_wall\n"
+ "? landuse=cemetery poi_cemetery\n"
+ "? leisure=fishing poi_fish\n"
+ "? leisure=golf_course poi_golf\n"
+ "? leisure=marina poi_marine\n"
+ "? leisure=playground poi_playground\n"
+ "? leisure=slipway poi_boat_ramp\n"
+ "? leisure=sports_centre poi_sport\n"
+ "? leisure=stadium poi_stadium\n"
+ "? man_made=tower poi_tower\n"
+ "? military=airfield poi_military\n"
+ "? military=barracks poi_military\n"
+ "? military=bunker poi_military\n"
+ "? military=danger_area poi_danger_area\n"
+ "? military=range poi_military\n"
+ "? natural=bay poi_bay\n"
+ "? natural=peak,ele=* poi_peak\n" // show only major peaks with elevation
+ "? natural=tree poi_tree\n"
+ "n place=city town_label_2e5\n"
+ "n place=hamlet town_label_2e2\n"
+ "n place=locality town_label_2e0\n"
+ "n place=suburb district_label\n"
+ "n place=town town_label_2e4\n"
+ "n place=village town_label_2e3\n"
+ "n power=tower power_tower\n"
+ "n power=sub_station power_substation\n"
+ "n railway=halt poi_rail_halt\n"
+ "n railway=level_crossing poi_level_crossing\n"
+ "? railway=station poi_rail_station\n"
+ "? railway=tram_stop poi_rail_tram_stop\n"
+ "? shop=baker poi_shop_baker\n"
+ "? shop=bakery poi_shop_baker\n"
+ "? shop=beverages poi_shop_beverages\n"
+ "? shop=bicycle poi_shop_bicycle\n"
+ "? shop=butcher poi_shop_butcher\n"
+ "? shop=car poi_car_dealer_parts\n"
+ "? shop=car_repair poi_repair_service\n"
+ "? shop=clothes poi_shop_apparel\n"
+ "? shop=convenience poi_shop_grocery\n"
+ "? shop=chemist poi_shop_drugstore\n"
+ "? shop=florist poi_shop_florist\n"
+ "? shop=fruit poi_shop_fruit\n"
+ "? shop=furniture poi_shop_furniture\n"
+ "? shop=garden_centre poi_shop_handg\n"
+ "? shop=hardware poi_shop_handg\n"
+ "? shop=hairdresser poi_hairdresser\n"
+ "? shop=kiosk poi_shop_kiosk\n"
+ "? shop=optician poi_shop_optician\n"
+ "? shop=parfum poi_shop_parfum\n"
+ "? shop=photo poi_shop_photo\n"
+ "? shop=shoes poi_shop_shoes\n"
+ "? shop=supermarket poi_shopping\n"
+ "? shop=mall poi_mall\n"
+ "? sport=10pin poi_bowling\n"
+ "? sport=baseball poi_baseball\n"
+ "? sport=basketball poi_basketball\n"
+ "? sport=climbing poi_climbing\n"
+ "? sport=golf poi_golf\n"
+ "? sport=motor_sports poi_motor_sport\n"
+ "? sport=skiing poi_skiing\n"
+ "? sport=soccer poi_soccer\n"
+ "? sport=stadium poi_stadium\n"
+ "? sport=swimming poi_swimming\n"
+ "? sport=tennis poi_tennis\n"
+ "? tourism=attraction poi_attraction\n"
+ "? tourism=camp_site poi_camp_rv\n"
+ "? tourism=caravan_site poi_camp_rv\n"
+ "? tourism=guest_house poi_guesthouse\n"
+ "? tourism=hostel poi_hostel\n"
+ "? tourism=hotel poi_hotel\n"
+ "? tourism=information poi_information\n"
+ "? tourism=motel poi_motel\n"
+ "? tourism=museum poi_museum_history\n"
+ "? tourism=picnic_site poi_picnic\n"
+ "? tourism=theme_park poi_resort\n"
+ "? tourism=viewpoint poi_viewpoint\n"
+ "? tourism=zoo poi_zoo\n"
+ "n traffic_sign=city_limit traffic_sign_city_limit\n"
+ "n highway=speed_camera tec_common\n"
+ "w *=* street_unkn\n"
+ "w addr:interpolation=even house_number_interpolation_even\n"
+ "w addr:interpolation=odd house_number_interpolation_odd\n"
+ "w addr:interpolation=all house_number_interpolation_all\n"
+ "w addr:interpolation=alphabetic house_number_interpolation_alphabetic\n"
+ "w aerialway=cable_car lift_cable_car\n"
+ "w aerialway=chair_lift lift_chair\n"
+ "w aerialway=drag_lift lift_drag\n"
+ "w aeroway=aerodrome poly_airport\n"
+ "w aeroway=apron poly_apron\n"
+ "w aeroway=runway aeroway_runway\n"
+ "w aeroway=taxiway aeroway_taxiway\n"
+ "w aeroway=terminal poly_terminal\n"
+ "w amenity=college poly_college\n"
+ "w amenity=grave_yard poly_cemetery\n"
+ "w amenity=parking poly_car_parking\n"
+ "w amenity=place_of_worship poly_building\n"
+ "w amenity=university poly_university\n"
+ "w boundary=administrative,admin_level=2 border_country\n"
+ "w boundary=civil border_civil\n"
+ "w boundary=national_park border_national_park\n"
+ "w boundary=political border_political\n"
+ "w building=* poly_building\n"
+ "w contour_ext=elevation_major height_line_1\n"
+ "w contour_ext=elevation_medium height_line_2\n"
+ "w contour_ext=elevation_minor height_line_3\n"
+ "w highway=bridleway bridleway\n"
+ "w highway=bus_guideway bus_guideway\n"
+ "w highway=construction street_construction\n"
+ "w highway=cyclepath cycleway\n"
+ "w highway=cycleway cycleway\n"
+ "w highway=footway footway\n"
+ "w highway=footway,piste:type=nordic footway_and_piste_nordic\n"
+ "w highway=living_street living_street\n"
+ "w highway=minor street_1_land\n"
+ "w highway=parking_lane street_parking_lane\n"
+ "w highway=path path\n"
+ "w highway=path,bicycle=designated cycleway\n"
+ "w highway=path,bicycle=official cycleway\n"
+ "w highway=path,bicycle=designated,foot=designated cycleway\n"
+ "w highway=path,bicycle=official,foot=official cycleway\n"
+ "w highway=path,foot=designated footway\n"
+ "w highway=path,foot=official footway\n"
+ "w highway=path,horse=designated bridleway\n"
+ "w highway=path,horse=official bridleway\n"
+ "w highway=path,sac_scale=alpine_hiking hiking_alpine\n"
+ "w highway=path,sac_scale=demanding_alpine_hiking hiking_alpine_demanding\n"
+ "w highway=path,sac_scale=demanding_mountain_hiking hiking_mountain_demanding\n"
+ "w highway=path,sac_scale=difficult_alpine_hiking hiking_alpine_difficult\n"
+ "w highway=path,sac_scale=hiking hiking\n"
+ "w highway=path,sac_scale=mountain_hiking hiking_mountain\n"
+ "w highway=pedestrian street_pedestrian\n"
+ "w highway=pedestrian,area=1 poly_pedestrian\n"
+ "w highway=plaza poly_plaza\n"
+ "w highway=motorway highway_land\n"
+ "w highway=motorway,rural=0 highway_city\n"
+ "w highway=motorway_link ramp\n"
+ "w highway=trunk street_n_lanes\n"
+ "w highway=trunk_link ramp\n"
+ "w highway=primary street_4_land\n"
+ "w highway=primary,name=*,rural=1 street_4_land\n"
+ "w highway=primary,name=* street_4_city\n"
+ "w highway=primary,rural=0 street_4_city\n"
+ "w highway=primary_link ramp\n"
+ "w highway=secondary street_3_land\n"
+ "w highway=secondary,name=*,rural=1 street_3_land\n"
+ "w highway=secondary,name=* street_3_city\n"
+ "w highway=secondary,rural=0 street_3_city\n"
+ "w highway=secondary,area=1 poly_street_3\n"
+ "w highway=secondary_link ramp\n"
+ "w highway=tertiary street_2_land\n"
+ "w highway=tertiary,name=*,rural=1 street_2_land\n"
+ "w highway=tertiary,name=* street_2_city\n"
+ "w highway=tertiary,rural=0 street_2_city\n"
+ "w highway=tertiary,area=1 poly_street_2\n"
+ "w highway=tertiary_link ramp\n"
+ "w highway=residential street_1_city\n"
+ "w highway=residential,area=1 poly_street_1\n"
+ "w highway=unclassified street_1_city\n"
+ "w highway=unclassified,area=1 poly_street_1\n"
+ "w highway=road street_1_city\n"
+ "w highway=service street_service\n"
+ "w highway=service,area=1 poly_service\n"
+ "w highway=service,service=parking_aisle street_parking_lane\n"
+ "w highway=track track_gravelled\n"
+ "w highway=track,surface=grass track_grass\n"
+ "w highway=track,surface=gravel track_gravelled\n"
+ "w highway=track,surface=ground track_ground\n"
+ "w highway=track,surface=paved track_paved\n"
+ "w highway=track,surface=unpaved track_unpaved\n"
+ "w highway=track,tracktype=grade1 track_paved\n"
+ "w highway=track,tracktype=grade2 track_gravelled\n"
+ "w highway=track,tracktype=grade3 track_unpaved\n"
+ "w highway=track,tracktype=grade4 track_ground\n"
+ "w highway=track,tracktype=grade5 track_grass\n"
+ "w highway=track,surface=paved,tracktype=grade1 track_paved\n"
+ "w highway=track,surface=gravel,tracktype=grade2 track_gravelled\n"
+ "w highway=track,surface=unpaved,tracktype=grade3 track_unpaved\n"
+ "w highway=track,surface=ground,tracktype=grade4 track_ground\n"
+ "w highway=track,surface=grass,tracktype=grade5 track_grass\n"
+ "w highway=unsurfaced track_gravelled\n"
+ "w highway=steps steps\n"
+ "w historic=archaeological_site poly_archaeological_site\n"
+ "w historic=battlefield poly_battlefield\n"
+ "w historic=ruins poly_ruins\n"
+ "w historic=town_gate poly_building\n"
+ "w landuse=allotments poly_allotments\n"
+ "w landuse=basin poly_basin\n"
+ "w landuse=brownfield poly_brownfield\n"
+ "w landuse=cemetery poly_cemetery\n"
+ "w landuse=commercial poly_commercial\n"
+ "w landuse=construction poly_construction\n"
+ "w landuse=farm poly_farm\n"
+ "w landuse=farmland poly_farm\n"
+ "w landuse=farmyard poly_town\n"
+ "w landuse=forest poly_wood\n"
+ "w landuse=grass poly_meadow\n"
+ "w landuse=greenfield poly_greenfield\n"
+ "w landuse=industrial poly_industry\n"
+ "w landuse=landfill poly_landfill\n"
+ "w landuse=military poly_military\n"
+ "w landuse=meadow poly_meadow\n"
+ "w landuse=plaza poly_plaza\n"
+ "w landuse=quarry poly_quarry\n"
+ "w landuse=railway poly_railway\n"
+ "w landuse=recreation_ground poly_recreation_ground\n"
+ "w landuse=reservoir poly_reservoir\n"
+ "w landuse=residential poly_town\n"
+ "w landuse=residential,area=1 poly_town\n"
+ "w landuse=retail poly_retail\n"
+ "w landuse=village_green poly_village_green\n"
+ "w landuse=vineyard poly_farm\n"
+ "w landuse=depot poly_depot\n"
+ "w landuse=garages poly_garages\n"
+ "w landuse=greenhouse_horticulture poly_greenhouse\n"
+ "w landuse=orchard poly_orchard\n"
+ "w landuse=plant_nursery poly_plantnursery\n"
+ "w landuse=port poly_port\n"
+ "w landuse=salt_pond poly_saltpond\n"
+ "w leisure=common poly_common\n"
+ "w leisure=fishing poly_fishing\n"
+ "w leisure=garden poly_garden\n"
+ "w leisure=golf_course poly_golf_course\n"
+ "w leisure=marina poly_marina\n"
+ "w leisure=nature_reserve poly_nature_reserve\n"
+ "w leisure=park poly_park\n"
+ "w leisure=pitch poly_sports_pitch\n"
+ "w leisure=playground poly_playground\n"
+ "w leisure=sports_centre poly_sport\n"
+ "w leisure=stadium poly_sports_stadium\n"
+ "w leisure=track poly_sports_track\n"
+ "w leisure=water_park poly_water_park\n"
+ "w military=airfield poly_airfield\n"
+ "w military=barracks poly_barracks\n"
+ "w military=danger_area poly_danger_area\n"
+ "w military=naval_base poly_naval_base\n"
+ "w military=range poly_range\n"
+ "w natural=beach poly_beach\n"
+ "w natural=coastline water_line\n"
+ "w natural=fell poly_fell\n"
+ "w natural=glacier poly_glacier\n"
+ "w natural=grassland poly_meadow\n"
+ "w natural=heath poly_heath\n"
+ "w natural=land poly_land\n"
+ "w natural=marsh poly_marsh\n"
+ "w natural=meadow poly_meadow\n"
+ "w natural=mud poly_mud\n"
+ "w natural=sand poly_beach\n"
+ "w natural=scree poly_scree\n"
+ "w natural=scrub poly_scrub\n"
+ "w natural=water poly_water\n"
+ "w natural=wetland poly_mud\n"
+ "w natural=wood poly_wood\n"
+ "w piste:type=downhill,piste:difficulty=advanced piste_downhill_advanced\n"
+ "w piste:type=downhill,piste:difficulty=easy piste_downhill_easy\n"
+ "w piste:type=downhill,piste:difficulty=expert piste_downhill_expert\n"
+ "w piste:type=downhill,piste:difficulty=freeride piste_downhill_freeride\n"
+ "w piste:type=downhill,piste:difficulty=intermediate piste_downhill_intermediate\n"
+ "w piste:type=downhill,piste:difficulty=novice piste_downhill_novice\n"
+ "w piste:type=nordic piste_nordic\n"
+ "w place=suburb poly_place1\n"
+ "w place=hamlet poly_place2\n"
+ "w place=isolated_dwelling poly_place2\n"
+ "w place=locality poly_place2\n"
+ "w place=village poly_place3\n"
+ "w place=municipality poly_place4\n"
+ "w place=town poly_place5\n"
+ "w place=city poly_place6\n"
+ "w de:place=city poly_place6\n"
+ "w power=line powerline\n"
+ "w railway=abandoned rail_abandoned\n"
+ "w railway=disused rail_disused\n"
+ "w railway=light_rail rail_light\n"
+ "w railway=monorail rail_mono\n"
+ "w railway=narrow_gauge rail_narrow_gauge\n"
+ "w railway=preserved rail_preserved\n"
+ "w railway=rail rail\n"
+ "w railway=subway rail_subway\n"
+ "w railway=tram rail_tram\n"
+ "w route=ferry ferry\n"
+ "w route=ski piste_nordic\n"
+ "w sport=* poly_sport\n"
+ "w tourism=artwork poly_artwork\n"
+ "w tourism=attraction poly_attraction\n"
+ "w tourism=camp_site poly_camp_site\n"
+ "w tourism=caravan_site poly_caravan_site\n"
+ "w tourism=picnic_site poly_picnic_site\n"
+ "w tourism=theme_park poly_theme_park\n"
+ "w tourism=zoo poly_zoo\n"
+ "w waterway=canal water_canal\n"
+ "w waterway=drain water_drain\n"
+ "w waterway=river water_river\n"
+ "w waterway=riverbank poly_water\n"
+ "w waterway=stream water_stream\n"
+ "w barrier=ditch ditch\n"
+ "w barrier=hedge hedge\n"
+ "w barrier=fence fence\n"
+ "w barrier=wall wall\n"
+ "w barrier=retaining_wall retaining_wall\n"
+ "w barrier=city_wall city_wall\n"
};
-static void
-build_attrmap_line(char *line)
-{
- char *t=NULL,*kvl=NULL,*i=NULL,*p,*kv;
- struct attr_mapping *attr_mapping=g_malloc0(sizeof(struct attr_mapping));
- int idx,attr_mapping_count=0;
- t=line;
- p=strpbrk(t," \t");
- if (p) {
- while (*p && isspace(*p))
- *p++='\0';
- kvl=p;
- p=strpbrk(kvl," \t");;
- }
- if (p) {
- while (*p && isspace(*p))
- *p++='\0';
- i=p;
- }
- if (t[0] == 'w') {
- if (! i)
- i="street_unkn";
- } else {
- if (! i)
- i="point_unkn";
- }
- attr_mapping->type=item_from_name(i);
- if (!attr_mapping->type) {
- printf("no id found for '%s'\n",i);
- }
- while ((kv=strtok(kvl, ","))) {
- kvl=NULL;
- if (!(idx=(int)(long)g_hash_table_lookup(attr_hash, kv))) {
- idx=attr_present_count++;
- g_hash_table_insert(attr_hash, kv, (gpointer)(long long)idx);
- }
- attr_mapping=g_realloc(attr_mapping, sizeof(struct attr_mapping)+(attr_mapping_count+1)*sizeof(int));
- attr_mapping->attr_present_idx[attr_mapping_count++]=idx;
- attr_mapping->attr_present_idx_count=attr_mapping_count;
- }
- if (t[0]== 'w') {
- attr_mapping_way=g_realloc(attr_mapping_way, sizeof(*attr_mapping_way)*(attr_mapping_way_count+1));
- attr_mapping_way[attr_mapping_way_count++]=attr_mapping;
- if(item_is_poly_place(*attr_mapping)) {
- attr_mapping_rel2poly_place=g_realloc(attr_mapping_rel2poly_place, sizeof(*attr_mapping_rel2poly_place)*(attr_mapping_rel2poly_place_count+1));
- attr_mapping_rel2poly_place[attr_mapping_rel2poly_place_count++]=attr_mapping;
- }
- }
- if (t[0]== '?') {
- attr_mapping_way2poi=g_realloc(attr_mapping_way2poi, sizeof(*attr_mapping_way2poi)*(attr_mapping_way2poi_count+1));
- attr_mapping_way2poi[attr_mapping_way2poi_count++]=attr_mapping;
- }
- if (t[0]!= 'w') {
- attr_mapping_node=g_realloc(attr_mapping_node, sizeof(*attr_mapping_node)*(attr_mapping_node_count+1));
- attr_mapping_node[attr_mapping_node_count++]=attr_mapping;
- }
-
-}
-
-static void
-build_attrmap(FILE* rule_file)
-{
- attr_hash=g_hash_table_new(g_str_hash, g_str_equal);
- attr_present_count=1;
+static void build_attrmap_line(char *line) {
+ char *t=NULL,*kvl=NULL,*i=NULL,*p,*kv;
+ struct attr_mapping *attr_mapping=g_malloc0(sizeof(struct attr_mapping));
+ int idx,attr_mapping_count=0;
+ t=line;
+ p=strpbrk(t," \t");
+ if (p) {
+ while (*p && isspace(*p))
+ *p++='\0';
+ kvl=p;
+ p=strpbrk(kvl," \t");;
+ }
+ if (p) {
+ while (*p && isspace(*p))
+ *p++='\0';
+ i=p;
+ }
+ if (t[0] == 'w') {
+ if (! i)
+ i="street_unkn";
+ } else {
+ if (! i)
+ i="point_unkn";
+ }
+ attr_mapping->type=item_from_name(i);
+ if (!attr_mapping->type) {
+ printf("no id found for '%s'\n",i);
+ }
+ while ((kv=strtok(kvl, ","))) {
+ kvl=NULL;
+ if (!(idx=(int)(long)g_hash_table_lookup(attr_hash, kv))) {
+ idx=attr_present_count++;
+ g_hash_table_insert(attr_hash, kv, (gpointer)(long long)idx);
+ }
+ attr_mapping=g_realloc(attr_mapping, sizeof(struct attr_mapping)+(attr_mapping_count+1)*sizeof(int));
+ attr_mapping->attr_present_idx[attr_mapping_count++]=idx;
+ attr_mapping->attr_present_idx_count=attr_mapping_count;
+ }
+ if (t[0]== 'w') {
+ attr_mapping_way=g_realloc(attr_mapping_way, sizeof(*attr_mapping_way)*(attr_mapping_way_count+1));
+ attr_mapping_way[attr_mapping_way_count++]=attr_mapping;
+ if(item_is_poly_place(*attr_mapping)) {
+ attr_mapping_rel2poly_place=g_realloc(attr_mapping_rel2poly_place,
+ sizeof(*attr_mapping_rel2poly_place)*(attr_mapping_rel2poly_place_count+1));
+ attr_mapping_rel2poly_place[attr_mapping_rel2poly_place_count++]=attr_mapping;
+ }
+ }
+ if (t[0]== '?') {
+ attr_mapping_way2poi=g_realloc(attr_mapping_way2poi, sizeof(*attr_mapping_way2poi)*(attr_mapping_way2poi_count+1));
+ attr_mapping_way2poi[attr_mapping_way2poi_count++]=attr_mapping;
+ }
+ if (t[0]!= 'w') {
+ attr_mapping_node=g_realloc(attr_mapping_node, sizeof(*attr_mapping_node)*(attr_mapping_node_count+1));
+ attr_mapping_node[attr_mapping_node_count++]=attr_mapping;
+ }
+
+}
+
+static void build_attrmap(FILE* rule_file) {
+ attr_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ attr_present_count=1;
// build attribute map from rule file if given
- if( rule_file )
- {
+ if( rule_file ) {
char buffer[200], *p;
while (fgets( buffer, 200, rule_file )) {
p=strchr(buffer,'\n');
@@ -854,8 +850,7 @@ build_attrmap(FILE* rule_file)
fclose( rule_file );
}
// use hardcoded default attributes
- else
- {
+ else {
char *p,*map=g_strdup(attrmap);
while (map) {
p=strchr(map,'\n');
@@ -867,504 +862,466 @@ build_attrmap(FILE* rule_file)
}
}
- attr_present=g_malloc0(sizeof(*attr_present)*attr_present_count);
-}
-
-static void
-build_countrytable(void)
-{
- int i;
- char *names,*str,*tok;
- country_table_hash=g_hash_table_new(g_str_hash, g_str_equal);
- for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
- names=g_strdup(country_table[i].names);
- str=names;
- while ((tok=strtok(str, ","))) {
- str=NULL;
- g_hash_table_insert(country_table_hash, tok, (gpointer)&country_table[i]);
- }
- }
-}
-
-static void
-osm_logv(char *prefix, char *objtype, osmid id, int cont, struct coord_geo *geo, char *fmt, va_list ap)
-{
- char str[4096];
- vsnprintf(str, sizeof(str), fmt, ap);
- if(cont)
- prefix="";
- if(objtype)
- fprintf(stderr,"%shttp://www.openstreetmap.org/%s/"OSMID_FMT" %s", prefix, objtype, id, str);
- else if(geo)
- fprintf(stderr,"%shttp://www.openstreetmap.org/#map=19/%.5f/%.5f %s",prefix, geo->lat, geo->lng, str);
- else
- fprintf(stderr,"%s[no osm object info] %s",prefix, str);
-}
-
-void
-osm_warning(char *type, osmid id, int cont, char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- osm_logv("OSM Warning:", type, id, cont, NULL, fmt, ap);
- va_end(ap);
-}
-
-void
-osm_info(char *type, osmid id, int cont, char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- osm_logv("OSM Info:", type, id, cont, NULL, fmt, ap);
- va_end(ap);
-}
-
-static void
-itembin_warning(struct item_bin *ib, int cont, char *fmt, ...)
-{
- char *type=NULL;
- osmid id;
- struct coord_geo geo;
- va_list ap;
- if(0!=(id=item_bin_get_nodeid(ib))) {
- type="node";
- } else if(0!=(id=item_bin_get_wayid(ib))) {
- type="way";
- } else if(0!=(id=item_bin_get_relationid(ib))) {
- type="relation";
- } else {
- struct coord *c=(struct coord *)(ib+1);
- transform_to_geo(projection_mg, c, &geo);
- }
-
- va_start(ap, fmt);
- osm_logv("OSM Warning:", type, id, cont, &geo, fmt, ap);
- va_end(ap);
-}
-
-static void
-attr_strings_clear(void)
-{
- attr_strings_buffer_free_offset=0;
- memset(attr_strings, 0, sizeof(attr_strings));
-}
-
-static void
-attr_strings_save(enum attr_strings_type id, char *str)
-{
- int str_size=strlen(str)+1;
- dbg_assert(attr_strings_buffer_free_offset+str_size<sizeof(attr_strings_buffer));
- attr_strings[id]=attr_strings_buffer+attr_strings_buffer_free_offset;
- g_strlcpy(attr_strings[id], str, str_size);
- attr_strings_buffer_free_offset+=str_size;
-}
-
-static osmid
-item_bin_get_nodeid_from_attr(struct item_bin *ib, enum attr_type attr_type)
-{
- unsigned long long *ret=item_bin_get_attr(ib, attr_type, NULL);
- if (ret)
- return *ret;
- return 0;
-}
-
-osmid
-item_bin_get_nodeid(struct item_bin *ib)
-{
- return item_bin_get_nodeid_from_attr(ib, attr_osm_nodeid);
-}
-
-osmid
-item_bin_get_wayid(struct item_bin *ib)
-{
- unsigned long long *ret=item_bin_get_attr(ib, attr_osm_wayid, NULL);
- if (ret)
- return *ret;
- return 0;
-}
-
-osmid
-item_bin_get_relationid(struct item_bin *ib)
-{
- unsigned long long *ret=item_bin_get_attr(ib, attr_osm_relationid, NULL);
- if (ret)
- return *ret;
- return 0;
-}
-
-osmid
-item_bin_get_id(struct item_bin *ib)
-{
- osmid ret;
- if (ib->type < 0x80000000)
- return item_bin_get_nodeid(ib);
- ret=item_bin_get_wayid(ib);
- if (!ret)
- ret=item_bin_get_relationid(ib);
- return ret;
+ attr_present=g_malloc0(sizeof(*attr_present)*attr_present_count);
+}
+
+static void build_countrytable(void) {
+ int i;
+ char *names,*str,*tok;
+ country_table_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
+ names=g_strdup(country_table[i].names);
+ str=names;
+ while ((tok=strtok(str, ","))) {
+ str=NULL;
+ g_hash_table_insert(country_table_hash, tok, (gpointer)&country_table[i]);
+ }
+ }
+}
+
+static void osm_logv(char *prefix, char *objtype, osmid id, int cont, struct coord_geo *geo, char *fmt, va_list ap) {
+ char str[4096];
+ vsnprintf(str, sizeof(str), fmt, ap);
+ if(cont)
+ prefix="";
+ if(objtype)
+ fprintf(stderr,"%shttp://www.openstreetmap.org/%s/"OSMID_FMT" %s", prefix, objtype, id, str);
+ else if(geo)
+ fprintf(stderr,"%shttp://www.openstreetmap.org/#map=19/%.5f/%.5f %s",prefix, geo->lat, geo->lng, str);
+ else
+ fprintf(stderr,"%s[no osm object info] %s",prefix, str);
+}
+
+void osm_warning(char *type, osmid id, int cont, char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ osm_logv("OSM Warning:", type, id, cont, NULL, fmt, ap);
+ va_end(ap);
+}
+
+void osm_info(char *type, osmid id, int cont, char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ osm_logv("OSM Info:", type, id, cont, NULL, fmt, ap);
+ va_end(ap);
+}
+
+static void itembin_warning(struct item_bin *ib, int cont, char *fmt, ...) {
+ char *type=NULL;
+ osmid id;
+ struct coord_geo geo;
+ va_list ap;
+ if(0!=(id=item_bin_get_nodeid(ib))) {
+ type="node";
+ } else if(0!=(id=item_bin_get_wayid(ib))) {
+ type="way";
+ } else if(0!=(id=item_bin_get_relationid(ib))) {
+ type="relation";
+ } else {
+ struct coord *c=(struct coord *)(ib+1);
+ transform_to_geo(projection_mg, c, &geo);
+ }
+
+ va_start(ap, fmt);
+ osm_logv("OSM Warning:", type, id, cont, &geo, fmt, ap);
+ va_end(ap);
+}
+
+static void attr_strings_clear(void) {
+ attr_strings_buffer_free_offset=0;
+ memset(attr_strings, 0, sizeof(attr_strings));
+}
+
+static void attr_strings_save(enum attr_strings_type id, char *str) {
+ int str_size=strlen(str)+1;
+ dbg_assert(attr_strings_buffer_free_offset+str_size<sizeof(attr_strings_buffer));
+ attr_strings[id]=attr_strings_buffer+attr_strings_buffer_free_offset;
+ g_strlcpy(attr_strings[id], str, str_size);
+ attr_strings_buffer_free_offset+=str_size;
+}
+
+static osmid item_bin_get_nodeid_from_attr(struct item_bin *ib, enum attr_type attr_type) {
+ unsigned long long *ret=item_bin_get_attr(ib, attr_type, NULL);
+ if (ret)
+ return *ret;
+ return 0;
+}
+
+osmid item_bin_get_nodeid(struct item_bin *ib) {
+ return item_bin_get_nodeid_from_attr(ib, attr_osm_nodeid);
+}
+
+osmid item_bin_get_wayid(struct item_bin *ib) {
+ unsigned long long *ret=item_bin_get_attr(ib, attr_osm_wayid, NULL);
+ if (ret)
+ return *ret;
+ return 0;
+}
+
+osmid item_bin_get_relationid(struct item_bin *ib) {
+ unsigned long long *ret=item_bin_get_attr(ib, attr_osm_relationid, NULL);
+ if (ret)
+ return *ret;
+ return 0;
+}
+
+osmid item_bin_get_id(struct item_bin *ib) {
+ osmid ret;
+ if (ib->type < 0x80000000)
+ return item_bin_get_nodeid(ib);
+ ret=item_bin_get_wayid(ib);
+ if (!ret)
+ ret=item_bin_get_relationid(ib);
+ return ret;
}
static int node_is_tagged;
static void relation_add_tag(char *k, char *v);
-static int
-access_value(char *v)
-{
- if (!strcmp(v,"1"))
- return 1;
- if (!strcmp(v,"yes"))
- return 1;
- if (!strcmp(v,"designated"))
- return 1;
- if (!strcmp(v,"official"))
- return 1;
- if (!strcmp(v,"permissive"))
- return 1;
- if (!strcmp(v,"0"))
- return 2;
- if (!strcmp(v,"no"))
- return 2;
- if (!strcmp(v,"agricultural"))
- return 2;
- if (!strcmp(v,"forestry"))
- return 2;
- if (!strcmp(v,"private"))
- return 2;
- if (!strcmp(v,"delivery"))
- return 2;
- if (!strcmp(v,"destination"))
- return 2;
- return 3;
-}
-
-static void
-osm_update_attr_present(char *k, char *v);
-
-void
-osm_add_tag(char *k, char *v)
-{
- int level=2;
- if (in_relation) {
- relation_add_tag(k,v);
- return;
- }
- if (! strcmp(k,"ele")){
- attr_strings_save(attr_string_label, v);
- level=9;
- }
- if (! strcmp(k,"time"))
- level=9;
- if (! strcmp(k,"created_by"))
- level=9;
- if (! strncmp(k,"tiger:",6) || !strcmp(k,"AND_nodes"))
- level=9;
- if (! strcmp(k,"converted_by") || ! strcmp(k,"source"))
- level=8;
- if (! strncmp(k,"osmarender:",11) || !strncmp(k,"svg:",4))
- level=8;
- if (! strcmp(k,"layer"))
- level=7;
- if (! strcasecmp(v,"true") || ! strcasecmp(v,"yes"))
- v="1";
- if (! strcasecmp(v,"false") || ! strcasecmp(v,"no"))
- v="0";
- if (! strcmp(k,"oneway")) {
- if (!strcmp(v,"1")) {
- flags[0] |= AF_ONEWAY | AF_ROUNDABOUT_VALID;
- }
- if (! strcmp(v,"-1")) {
- flags[0] |= AF_ONEWAYREV | AF_ROUNDABOUT_VALID;
- }
- if (!in_way)
- level=6;
- else
- level=5;
- }
- if (! strcmp(k,"junction")) {
- if (! strcmp(v,"roundabout"))
- flags[0] |= AF_ONEWAY | AF_ROUNDABOUT | AF_ROUNDABOUT_VALID;
- }
- if (! strcmp(k,"maxspeed")) {
- if (strstr(v, "mph")) {
- maxspeed_attr_value = (int)floor(atof(v) * 1.609344);
- } else {
- maxspeed_attr_value = atoi(v);
- }
- if (maxspeed_attr_value)
- flags[0] |= AF_SPEED_LIMIT;
- level=5;
- }
- if (! strcmp(k,"toll")) {
- if (!strcmp(v,"1")) {
- flags[0] |= AF_TOLL;
- }
- }
- if (! strcmp(k,"access")) {
- if (strcmp(v,"destination"))
- flagsa[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_HORSE|AF_BIKE|AF_PEDESTRIAN;
- else
- flags[0] |= AF_THROUGH_TRAFFIC_LIMIT;
- if (! strcmp(v,"hov"))
- flags[0] |= AF_HIGH_OCCUPANCY_CAR_ONLY;
- level=5;
- }
- if (! strcmp(k,"vehicle")) {
- flags[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_BIKE;
- level=5;
- }
- if (! strcmp(k,"motor_vehicle")) {
- flags[access_value(v)] |= AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED;
- level=5;
- }
- if (! strcmp(k,"bicycle")) {
- flags[access_value(v)] |= AF_BIKE;
- level=5;
- }
- if (! strcmp(k,"foot")) {
- flags[access_value(v)] |= AF_PEDESTRIAN;
- level=5;
- }
- if (! strcmp(k,"horse")) {
- flags[access_value(v)] |= AF_HORSE;
- level=5;
- }
- if (! strcmp(k,"moped")) {
- flags[access_value(v)] |= AF_MOPED;
- level=5;
- }
- if (! strcmp(k,"motorcycle")) {
- flags[access_value(v)] |= AF_MOTORCYCLE;
- level=5;
- }
- if (! strcmp(k,"motorcar")) {
- flags[access_value(v)] |= AF_CAR;
- level=5;
- }
- if (! strcmp(k,"hov")) {
- flags[access_value(v)] |= AF_HIGH_OCCUPANCY_CAR;
- level=5;
- }
- if (! strcmp(k,"bus")) {
- flags[access_value(v)] |= AF_PUBLIC_BUS;
- level=5;
- }
- if (! strcmp(k,"taxi")) {
- flags[access_value(v)] |= AF_TAXI;
- level=5;
- }
- if (! strcmp(k,"goods")) {
- flags[access_value(v)] |= AF_DELIVERY_TRUCK;
- level=5;
- }
- if (! strcmp(k,"hgv")) {
- flags[access_value(v)] |= AF_TRANSPORT_TRUCK;
- level=5;
- }
- if (! strcmp(k,"emergency")) {
- flags[access_value(v)] |= AF_EMERGENCY_VEHICLES;
- level=5;
- }
- if (! strcmp(k,"hazmat")) {
- flags[access_value(v)] |= AF_DANGEROUS_GOODS;
- level=5;
- }
- if (! strcmp(k,"tunnel") && !strcmp(v,"1")) {
- flags[0] |= AF_UNDERGROUND;
- }
- if (! strcmp(k,"note"))
- level=5;
- if (! strcmp(k,"name")) {
- attr_strings_save(attr_string_label, v);
- level=5;
- }
- if (! strcmp(k,"addr:email")) {
- attr_strings_save(attr_string_email, v);
- level=5;
- }
- if (! strcmp(k,"addr:suburb")) {
- attr_strings_save(attr_string_district_name, v);
- level=5;
- }
- if (! strcmp(k,"addr:housenumber")) {
- attr_strings_save(attr_string_house_number, v);
- level=5;
- }
- if (! strcmp(k,"addr:street")) {
- attr_strings_save(attr_string_street_name, v);
- level=5;
- }
- if (! strcmp(k,"phone")) {
- attr_strings_save(attr_string_phone, v);
- level=5;
- }
- if (! strcmp(k,"fax")) {
- attr_strings_save(attr_string_fax, v);
- level=5;
- }
- if (! strcmp(k,"postal_code")) {
- attr_strings_save(attr_string_postal, v);
- level=5;
- }
- if (! strcmp(k,"addr:postcode") && !attr_strings[attr_string_postal]) {
- attr_strings_save(attr_string_postal, v);
- level=5;
- }
- if (! strcmp(k,"openGeoDB:postal_codes") && !attr_strings[attr_string_postal]) {
- attr_strings_save(attr_string_postal, v);
- level=5;
- }
- if (! strcmp(k,"population")) {
- attr_strings_save(attr_string_population, v);
- level=5;
- }
- if (! strcmp(k,"openGeoDB:population") && !attr_strings[attr_string_population]) {
- attr_strings_save(attr_string_population, v);
- level=5;
- }
- if ((! strcmp(k,"ref")) || (! strcmp(k,"destination:ref"))) {
- if (in_way)
- attr_strings_save(attr_string_street_name_systematic, v);
- /* for exit number of highway_exit poi */
- else attr_strings_save(attr_string_ref, v);
- level=5;
- }
- if (! strcmp(k,"nat_ref")) {
- if (in_way)
- attr_strings_save(attr_string_street_name_systematic_nat, v);
- level=5;
- }
- if (! strcmp(k,"int_ref")) {
- if (in_way)
- attr_strings_save(attr_string_street_name_systematic_int, v);
- level=5;
- }
- if (! strcmp(k,"destination")) {
- if (in_way)
- attr_strings_save(attr_string_street_destination, v);
- level=5;
- }
- if (! strcmp(k,"destination:forward"))
- {
- if (in_way)
- attr_strings_save(attr_string_street_destination_forward, v);
- level=5;
- }
- if (! strcmp(k,"destination:backward"))
- {
- if (in_way)
- attr_strings_save(attr_string_street_destination_backward, v);
- level=5;
- }
- if (! strcmp(k,"exit_to")) {
- attr_strings_save(attr_string_exit_to, v);
- level=5;
- }
- if (! strcmp(k,"openGeoDB:is_in")) {
- if (!is_in_buffer[0])
- g_strlcpy(is_in_buffer, v, sizeof(is_in_buffer));
- level=5;
- }
- if (! strcmp(k,"is_in")) {
- if (!is_in_buffer[0])
- g_strlcpy(is_in_buffer, v, sizeof(is_in_buffer));
- level=5;
- }
- if (! strcmp(k,"is_in:country")) {
- /**
- * Sometimes there is no is_in tag, only is_in:country.
- * I put this here so it can be overwritten by the previous if clause if there IS an is_in tag.
- */
- g_strlcpy(is_in_buffer, v, sizeof(is_in_buffer));
- level=5;
- }
- if (! strcmp(k,"place_county")) {
- /**
- * Ireland uses the place_county OSM tag to describe what county a town is in.
- * This would be equivalent to is_in: Town; Locality; Country
- * A real world example would be Node: Moycullen (52234625)
- * The tag is processed as Moycullen; Galway; Ireland
- * where Galway is the county
- */
- g_strlcpy(is_in_buffer, "Ireland", sizeof(is_in_buffer));
- attr_strings_save(attr_string_county_name, v);
- level=5;
- }
- if (! strcmp(k,"gnis:ST_alpha")) {
- /* assume a gnis tag means it is part of the USA:
- http://en.wikipedia.org/wiki/Geographic_Names_Information_System
- many US towns do not have is_in tags
- */
- g_strlcpy(is_in_buffer, "USA", sizeof(is_in_buffer));
- level=5;
- }
- if (! strcmp(k,"lanes")) {
- level=5;
- }
- if (attr_debug_level >= level) {
- int bytes_left = sizeof( debug_attr_buffer ) - strlen(debug_attr_buffer) - 1;
- if ( bytes_left > 0 )
- {
- snprintf(debug_attr_buffer+strlen(debug_attr_buffer), bytes_left, " %s=%s", k, v);
- debug_attr_buffer[ sizeof( debug_attr_buffer ) - 1 ] = '\0';
- node_is_tagged=1;
- }
- }
- if (level < 6)
- node_is_tagged=1;
-
- osm_update_attr_present(k, v);
-}
-
-static void
-osm_update_attr_present(char *k, char *v)
-{
- const int bufsize=BUFFER_SIZE*2+2;
- int idx;
- char *p, buffer[bufsize];
-
- g_strlcpy(buffer,"*=*", bufsize);
- if ((idx=(int)(long)g_hash_table_lookup(attr_hash, buffer))) {
- dbg_assert(idx<attr_present_count);
- attr_present[idx]=1;
- }
-
- snprintf(buffer,bufsize,"%s=*", k);
- for(p=buffer;*p;p++)
- if(isspace(*p)) *p='_';
- if ((idx=(int)(long)g_hash_table_lookup(attr_hash, buffer))) {
- dbg_assert(idx<attr_present_count);
- attr_present[idx]=2;
- }
-
- snprintf(buffer,bufsize,"*=%s", v);
- for(p=buffer;*p;p++)
- if(isspace(*p)) *p='_';
- if ((idx=(int)(long)g_hash_table_lookup(attr_hash, buffer))) {
- dbg_assert(idx<attr_present_count);
- attr_present[idx]=2;
- }
-
- snprintf(buffer,bufsize,"%s=%s", k, v);
- for(p=buffer;*p;p++)
- if(isspace(*p)) *p='_';
- if ((idx=(int)(long)g_hash_table_lookup(attr_hash, buffer))) {
- dbg_assert(idx<attr_present_count);
- attr_present[idx]=4;
- }
+static int access_value(char *v) {
+ if (!g_strcmp0(v,"1"))
+ return 1;
+ if (!g_strcmp0(v,"yes"))
+ return 1;
+ if (!g_strcmp0(v,"designated"))
+ return 1;
+ if (!g_strcmp0(v,"official"))
+ return 1;
+ if (!g_strcmp0(v,"permissive"))
+ return 1;
+ if (!g_strcmp0(v,"0"))
+ return 2;
+ if (!g_strcmp0(v,"no"))
+ return 2;
+ if (!g_strcmp0(v,"agricultural"))
+ return 2;
+ if (!g_strcmp0(v,"forestry"))
+ return 2;
+ if (!g_strcmp0(v,"private"))
+ return 2;
+ if (!g_strcmp0(v,"delivery"))
+ return 2;
+ if (!g_strcmp0(v,"destination"))
+ return 2;
+ return 3;
+}
+
+static void osm_update_attr_present(char *k, char *v);
+
+void osm_add_tag(char *k, char *v) {
+ int level=2;
+ if (in_relation) {
+ relation_add_tag(k,v);
+ return;
+ }
+ if (! g_strcmp0(k,"ele")) {
+ attr_strings_save(attr_string_label, v);
+ level=9;
+ }
+ if (! g_strcmp0(k,"time"))
+ level=9;
+ if (! g_strcmp0(k,"created_by"))
+ level=9;
+ if (! strncmp(k,"tiger:",6) || !g_strcmp0(k,"AND_nodes"))
+ level=9;
+ if (! g_strcmp0(k,"converted_by") || ! g_strcmp0(k,"source"))
+ level=8;
+ if (! strncmp(k,"osmarender:",11) || !strncmp(k,"svg:",4))
+ level=8;
+ if (! g_strcmp0(k,"layer"))
+ level=7;
+ if (! strcasecmp(v,"true") || ! strcasecmp(v,"yes"))
+ v="1";
+ if (! strcasecmp(v,"false") || ! strcasecmp(v,"no"))
+ v="0";
+ if (! g_strcmp0(k,"oneway")) {
+ if (!g_strcmp0(v,"1")) {
+ flags[0] |= AF_ONEWAY | AF_ROUNDABOUT_VALID;
+ }
+ if (! g_strcmp0(v,"-1")) {
+ flags[0] |= AF_ONEWAYREV | AF_ROUNDABOUT_VALID;
+ }
+ if (!in_way)
+ level=6;
+ else
+ level=5;
+ }
+ if (! g_strcmp0(k,"junction")) {
+ if (! g_strcmp0(v,"roundabout"))
+ flags[0] |= AF_ONEWAY | AF_ROUNDABOUT | AF_ROUNDABOUT_VALID;
+ }
+ if (! g_strcmp0(k,"maxspeed")) {
+ if (strstr(v, "mph")) {
+ maxspeed_attr_value = (int)floor(atof(v) * 1.609344);
+ } else {
+ maxspeed_attr_value = atoi(v);
+ }
+ if (maxspeed_attr_value)
+ flags[0] |= AF_SPEED_LIMIT;
+ level=5;
+ }
+ if (! g_strcmp0(k,"toll")) {
+ if (!g_strcmp0(v,"1")) {
+ flags[0] |= AF_TOLL;
+ }
+ }
+ if (! g_strcmp0(k,"access")) {
+ if (g_strcmp0(v,"destination"))
+ flagsa[access_value(v)] |=
+ AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_HORSE|AF_BIKE|AF_PEDESTRIAN;
+ else
+ flags[0] |= AF_THROUGH_TRAFFIC_LIMIT;
+ if (! g_strcmp0(v,"hov"))
+ flags[0] |= AF_HIGH_OCCUPANCY_CAR_ONLY;
+ level=5;
+ }
+ if (! g_strcmp0(k,"vehicle")) {
+ flags[access_value(v)] |=
+ AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED|AF_BIKE;
+ level=5;
+ }
+ if (! g_strcmp0(k,"motor_vehicle")) {
+ flags[access_value(v)] |=
+ AF_DANGEROUS_GOODS|AF_EMERGENCY_VEHICLES|AF_TRANSPORT_TRUCK|AF_DELIVERY_TRUCK|AF_PUBLIC_BUS|AF_TAXI|AF_HIGH_OCCUPANCY_CAR|AF_CAR|AF_MOTORCYCLE|AF_MOPED;
+ level=5;
+ }
+ if (! g_strcmp0(k,"bicycle")) {
+ flags[access_value(v)] |= AF_BIKE;
+ level=5;
+ }
+ if (! g_strcmp0(k,"foot")) {
+ flags[access_value(v)] |= AF_PEDESTRIAN;
+ level=5;
+ }
+ if (! g_strcmp0(k,"horse")) {
+ flags[access_value(v)] |= AF_HORSE;
+ level=5;
+ }
+ if (! g_strcmp0(k,"moped")) {
+ flags[access_value(v)] |= AF_MOPED;
+ level=5;
+ }
+ if (! g_strcmp0(k,"motorcycle")) {
+ flags[access_value(v)] |= AF_MOTORCYCLE;
+ level=5;
+ }
+ if (! g_strcmp0(k,"motorcar")) {
+ flags[access_value(v)] |= AF_CAR;
+ level=5;
+ }
+ if (! g_strcmp0(k,"hov")) {
+ flags[access_value(v)] |= AF_HIGH_OCCUPANCY_CAR;
+ level=5;
+ }
+ if (! g_strcmp0(k,"bus")) {
+ flags[access_value(v)] |= AF_PUBLIC_BUS;
+ level=5;
+ }
+ if (! g_strcmp0(k,"taxi")) {
+ flags[access_value(v)] |= AF_TAXI;
+ level=5;
+ }
+ if (! g_strcmp0(k,"goods")) {
+ flags[access_value(v)] |= AF_DELIVERY_TRUCK;
+ level=5;
+ }
+ if (! g_strcmp0(k,"hgv")) {
+ flags[access_value(v)] |= AF_TRANSPORT_TRUCK;
+ level=5;
+ }
+ if (! g_strcmp0(k,"emergency")) {
+ flags[access_value(v)] |= AF_EMERGENCY_VEHICLES;
+ level=5;
+ }
+ if (! g_strcmp0(k,"hazmat")) {
+ flags[access_value(v)] |= AF_DANGEROUS_GOODS;
+ level=5;
+ }
+ if (! g_strcmp0(k,"tunnel") && !g_strcmp0(v,"1")) {
+ flags[0] |= AF_UNDERGROUND;
+ }
+ if (! g_strcmp0(k,"note"))
+ level=5;
+ if (! g_strcmp0(k,"name")) {
+ attr_strings_save(attr_string_label, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"addr:email")) {
+ attr_strings_save(attr_string_email, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"addr:suburb")) {
+ attr_strings_save(attr_string_district_name, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"addr:housenumber")) {
+ attr_strings_save(attr_string_house_number, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"addr:street")) {
+ attr_strings_save(attr_string_street_name, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"phone")) {
+ attr_strings_save(attr_string_phone, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"fax")) {
+ attr_strings_save(attr_string_fax, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"postal_code")) {
+ attr_strings_save(attr_string_postal, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"addr:postcode") && !attr_strings[attr_string_postal]) {
+ attr_strings_save(attr_string_postal, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"openGeoDB:postal_codes") && !attr_strings[attr_string_postal]) {
+ attr_strings_save(attr_string_postal, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"population")) {
+ attr_strings_save(attr_string_population, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"openGeoDB:population") && !attr_strings[attr_string_population]) {
+ attr_strings_save(attr_string_population, v);
+ level=5;
+ }
+ if ((! g_strcmp0(k,"ref")) || (! g_strcmp0(k,"destination:ref"))) {
+ if (in_way)
+ attr_strings_save(attr_string_street_name_systematic, v);
+ /* for exit number of highway_exit poi */
+ else attr_strings_save(attr_string_ref, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"nat_ref")) {
+ if (in_way)
+ attr_strings_save(attr_string_street_name_systematic_nat, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"int_ref")) {
+ if (in_way)
+ attr_strings_save(attr_string_street_name_systematic_int, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"destination")) {
+ if (in_way)
+ attr_strings_save(attr_string_street_destination, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"destination:forward")) {
+ if (in_way)
+ attr_strings_save(attr_string_street_destination_forward, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"destination:backward")) {
+ if (in_way)
+ attr_strings_save(attr_string_street_destination_backward, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"exit_to")) {
+ attr_strings_save(attr_string_exit_to, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"openGeoDB:is_in")) {
+ if (!is_in_buffer[0])
+ g_strlcpy(is_in_buffer, v, sizeof(is_in_buffer));
+ level=5;
+ }
+ if (! g_strcmp0(k,"is_in")) {
+ if (!is_in_buffer[0])
+ g_strlcpy(is_in_buffer, v, sizeof(is_in_buffer));
+ level=5;
+ }
+ if (! g_strcmp0(k,"is_in:country")) {
+ /**
+ * Sometimes there is no is_in tag, only is_in:country.
+ * I put this here so it can be overwritten by the previous if clause if there IS an is_in tag.
+ */
+ g_strlcpy(is_in_buffer, v, sizeof(is_in_buffer));
+ level=5;
+ }
+ if (! g_strcmp0(k,"place_county")) {
+ /**
+ * Ireland uses the place_county OSM tag to describe what county a town is in.
+ * This would be equivalent to is_in: Town; Locality; Country
+ * A real world example would be Node: Moycullen (52234625)
+ * The tag is processed as Moycullen; Galway; Ireland
+ * where Galway is the county
+ */
+ g_strlcpy(is_in_buffer, "Ireland", sizeof(is_in_buffer));
+ attr_strings_save(attr_string_county_name, v);
+ level=5;
+ }
+ if (! g_strcmp0(k,"gnis:ST_alpha")) {
+ /* assume a gnis tag means it is part of the USA:
+ http://en.wikipedia.org/wiki/Geographic_Names_Information_System
+ many US towns do not have is_in tags
+ */
+ g_strlcpy(is_in_buffer, "USA", sizeof(is_in_buffer));
+ level=5;
+ }
+ if (! g_strcmp0(k,"lanes")) {
+ level=5;
+ }
+ if (attr_debug_level >= level) {
+ int bytes_left = sizeof( debug_attr_buffer ) - strlen(debug_attr_buffer) - 1;
+ if ( bytes_left > 0 ) {
+ snprintf(debug_attr_buffer+strlen(debug_attr_buffer), bytes_left, " %s=%s", k, v);
+ debug_attr_buffer[ sizeof( debug_attr_buffer ) - 1 ] = '\0';
+ node_is_tagged=1;
+ }
+ }
+ if (level < 6)
+ node_is_tagged=1;
+
+ osm_update_attr_present(k, v);
}
-int coord_count;
+static void osm_update_attr_present(char *k, char *v) {
+ const int bufsize=BUFFER_SIZE*2+2;
+ int idx;
+ char *p, buffer[bufsize];
+
+ g_strlcpy(buffer,"*=*", bufsize);
+ if ((idx=(int)(long)g_hash_table_lookup(attr_hash, buffer))) {
+ dbg_assert(idx<attr_present_count);
+ attr_present[idx]=1;
+ }
-static void
-extend_buffer(struct buffer *b)
-{
- b->malloced+=b->malloced_step;
- b->base=realloc(b->base, b->malloced);
- if (b->base == NULL) {
- fprintf(stderr,"realloc of %d bytes failed\n",(int)b->malloced);
- exit(1);
- }
+ snprintf(buffer,bufsize,"%s=*", k);
+ for(p=buffer; *p; p++)
+ if(isspace(*p)) *p='_';
+ if ((idx=(int)(long)g_hash_table_lookup(attr_hash, buffer))) {
+ dbg_assert(idx<attr_present_count);
+ attr_present[idx]=2;
+ }
+
+ snprintf(buffer,bufsize,"*=%s", v);
+ for(p=buffer; *p; p++)
+ if(isspace(*p)) *p='_';
+ if ((idx=(int)(long)g_hash_table_lookup(attr_hash, buffer))) {
+ dbg_assert(idx<attr_present_count);
+ attr_present[idx]=2;
+ }
+
+ snprintf(buffer,bufsize,"%s=%s", k, v);
+ for(p=buffer; *p; p++)
+ if(isspace(*p)) *p='_';
+ if ((idx=(int)(long)g_hash_table_lookup(attr_hash, buffer))) {
+ dbg_assert(idx<attr_present_count);
+ attr_present[idx]=4;
+ }
+}
+int coord_count;
+
+static void extend_buffer(struct buffer *b) {
+ b->malloced+=b->malloced_step;
+ b->base=g_realloc(b->base, b->malloced);
}
/** The node currently being processed. */
@@ -1373,613 +1330,566 @@ static struct node_item *current_node;
osmid id_last_node;
GHashTable *node_hash,*way_hash;
-static void
-node_buffer_to_hash(void)
-{
- int i,count=node_buffer.size/sizeof(struct node_item);
- struct node_item *ni=(struct node_item *)node_buffer.base;
-
- for (i = 0 ; i < count ; i++)
- g_hash_table_insert(node_hash, (gpointer)(long long)(ni[i].nd_id), (gpointer)(long long)i);
-}
-
-void
-flush_nodes(int final)
-{
- fprintf(stderr,"flush_nodes %d\n",final);
- save_buffer("coords.tmp",&node_buffer,slices*slice_size);
- if (!final) {
- node_buffer.size=0;
- }
- slices++;
-}
-
-static struct node_item*
-allocate_node_item_in_buffer(void) {
- struct node_item* new_node;
- if (node_buffer.size + sizeof(struct node_item) > node_buffer.malloced)
- extend_buffer(&node_buffer);
- if (node_buffer.size + sizeof(struct node_item) > slice_size) {
- flush_nodes(0);
- }
- new_node=(struct node_item *)(node_buffer.base+node_buffer.size);
- node_buffer.size+=sizeof(struct node_item);
- return new_node;
-}
-
-static void
-remove_last_node_item_from_buffer(void) {
- node_buffer.size-=sizeof(struct node_item);
-}
-
-void
-osm_add_node(osmid id, double lat, double lon)
-{
- in_node=1;
- attr_strings_clear();
- node_is_tagged=0;
- nodeid=id;
- item.type=type_point_unkn;
- debug_attr_buffer[0]='\0';
- is_in_buffer[0]='\0';
- debug_attr_buffer[0]='\0';
- osmid_attr.type=attr_osm_nodeid;
- osmid_attr.len=3;
- osmid_attr_value=id;
-
- current_node=allocate_node_item_in_buffer();
- dbg_assert(id < ((2ull<<NODE_ID_BITS)-1));
- current_node->nd_id=id;
- current_node->ref_way=0;
- current_node->c.x=lon*6371000.0*M_PI/180;
- current_node->c.y=log(tan(M_PI_4+lat*M_PI/360))*6371000.0;
- if (! node_hash) {
- if (current_node->nd_id > id_last_node) {
- id_last_node=current_node->nd_id;
- } else {
- fprintf(stderr,"INFO: Nodes out of sequence (new " OSMID_FMT " vs old " OSMID_FMT "), adding hash\n",
- (osmid)current_node->nd_id, id_last_node);
- node_hash=g_hash_table_new(NULL, NULL);
- node_buffer_to_hash();
- }
- } else
- if (!g_hash_table_lookup(node_hash, (gpointer)(long long)(current_node->nd_id)))
- g_hash_table_insert(node_hash, (gpointer)(long long)(current_node->nd_id),
- (gpointer)(long long)(current_node-(struct node_item *)node_buffer.base));
- else {
- remove_last_node_item_from_buffer();
- nodeid=0;
- }
-
-}
-
-void
-clear_node_item_buffer(void)
-{
- int j,count=node_buffer.size/sizeof(struct node_item);
- struct node_item *ni=(struct node_item *)(node_buffer.base);
- for (j = 0 ; j < count ; j++) {
- ni[j].ref_way=0;
- }
-}
-
-static long long
-node_item_find_index_in_ordered_list(osmid id)
-{
- struct node_item *node_buffer_base=(struct node_item *)(node_buffer.base);
- long long node_count=node_buffer.size/sizeof(struct node_item);
- long long search_step=node_count>4 ? node_count/4 : 1;
- long long search_index=node_count/2;
- if (node_buffer_base[0].nd_id > id)
- return -1;
- if (node_buffer_base[node_count-1].nd_id < id)
- return -1;
- while (node_buffer_base[search_index].nd_id != id) {
-#if 0
- fprintf(stderr,"search_index=%d node_count=%d search_step=%d id=%d node_buffer_base[search_index].id=%d\n",
- search_index, node_count, search_step, id, node_buffer_base[search_index].id);
-#endif
- if (node_buffer_base[search_index].nd_id < id) {
- search_index+=search_step;
- if (search_step == 1) {
- if (search_index >= node_count)
- return -1;
- if (node_buffer_base[search_index].nd_id > id)
- return -1;
- } else {
- if (search_index >= node_count)
- search_index=node_count-1;
- }
- } else {
- search_index-=search_step;
- if (search_step == 1) {
- if (search_index < 0)
- return -1;
- if (node_buffer_base[search_index].nd_id < id)
- return -1;
- } else {
- if (search_index < 0)
- search_index=0;
- }
- }
- if (search_step > 1)
- search_step/=2;
- }
- return search_index;
-}
-
-static struct node_item *
-node_item_get(osmid id)
-{
- struct node_item *node_buffer_base=(struct node_item *)(node_buffer.base);
- long long result_index;
- if (node_hash) {
- // Use g_hash_table_lookup_extended instead of g_hash_table_lookup
- // to distinguish a key with a value 0 from a missing key.
- if (!g_hash_table_lookup_extended (node_hash, (gpointer)(id), NULL,
- (gpointer)&result_index)) {
- result_index=-1;
+static void node_buffer_to_hash(void) {
+ int i,count=node_buffer.size/sizeof(struct node_item);
+ struct node_item *ni=(struct node_item *)node_buffer.base;
+
+ for (i = 0 ; i < count ; i++)
+ g_hash_table_insert(node_hash, (gpointer)(long long)(ni[i].nd_id), (gpointer)(long long)i);
+}
+
+void flush_nodes(int final) {
+ fprintf(stderr,"flush_nodes %d\n",final);
+ save_buffer("coords.tmp",&node_buffer,slices*slice_size);
+ if (!final) {
+ node_buffer.size=0;
+ }
+ slices++;
+}
+
+static struct node_item* allocate_node_item_in_buffer(void) {
+ struct node_item* new_node;
+ if (node_buffer.size + sizeof(struct node_item) > node_buffer.malloced)
+ extend_buffer(&node_buffer);
+ if (node_buffer.size + sizeof(struct node_item) > slice_size) {
+ flush_nodes(0);
+ }
+ new_node=(struct node_item *)(node_buffer.base+node_buffer.size);
+ node_buffer.size+=sizeof(struct node_item);
+ return new_node;
+}
+
+static void remove_last_node_item_from_buffer(void) {
+ node_buffer.size-=sizeof(struct node_item);
+}
+
+void osm_add_node(osmid id, double lat, double lon) {
+ in_node=1;
+ attr_strings_clear();
+ node_is_tagged=0;
+ nodeid=id;
+ item.type=type_point_unkn;
+ debug_attr_buffer[0]='\0';
+ is_in_buffer[0]='\0';
+ debug_attr_buffer[0]='\0';
+ osmid_attr.type=attr_osm_nodeid;
+ osmid_attr.len=3;
+ osmid_attr_value=id;
+
+ current_node=allocate_node_item_in_buffer();
+ dbg_assert(id < ((2ull<<NODE_ID_BITS)-1));
+ current_node->nd_id=id;
+ current_node->ref_way=0;
+ current_node->c.x=lon*6371000.0*M_PI/180;
+ current_node->c.y=log(tan(M_PI_4+lat*M_PI/360))*6371000.0;
+ if (! node_hash) {
+ if (current_node->nd_id > id_last_node) {
+ id_last_node=current_node->nd_id;
+ } else {
+ fprintf(stderr,"INFO: Nodes out of sequence (new " OSMID_FMT " vs old " OSMID_FMT "), adding hash\n",
+ (osmid)current_node->nd_id, id_last_node);
+ node_hash=g_hash_table_new(NULL, NULL);
+ node_buffer_to_hash();
+ }
+ } else if (!g_hash_table_lookup(node_hash, (gpointer)(long long)(current_node->nd_id)))
+ g_hash_table_insert(node_hash, (gpointer)(long long)(current_node->nd_id),
+ (gpointer)(long long)(current_node-(struct node_item *)node_buffer.base));
+ else {
+ remove_last_node_item_from_buffer();
+ nodeid=0;
+ }
+
+}
+
+void clear_node_item_buffer(void) {
+ int j,count=node_buffer.size/sizeof(struct node_item);
+ struct node_item *ni=(struct node_item *)(node_buffer.base);
+ for (j = 0 ; j < count ; j++) {
+ ni[j].ref_way=0;
+ }
+}
+
+static long long node_item_find_index_in_ordered_list(osmid id) {
+ struct node_item *node_buffer_base=(struct node_item *)(node_buffer.base);
+ long long node_count=node_buffer.size/sizeof(struct node_item);
+ long long search_step=node_count>4 ? node_count/4 : 1;
+ long long search_index=node_count/2;
+ if (node_buffer_base[0].nd_id > id)
+ return -1;
+ if (node_buffer_base[node_count-1].nd_id < id)
+ return -1;
+ while (node_buffer_base[search_index].nd_id != id) {
+ if (node_buffer_base[search_index].nd_id < id) {
+ search_index+=search_step;
+ if (search_step == 1) {
+ if (search_index >= node_count)
+ return -1;
+ if (node_buffer_base[search_index].nd_id > id)
+ return -1;
+ } else {
+ if (search_index >= node_count)
+ search_index=node_count-1;
+ }
+ } else {
+ search_index-=search_step;
+ if (search_step == 1) {
+ if (search_index < 0)
+ return -1;
+ if (node_buffer_base[search_index].nd_id < id)
+ return -1;
+ } else {
+ if (search_index < 0)
+ search_index=0;
}
- } else {
- result_index=node_item_find_index_in_ordered_list(id);
- }
- return result_index!=-1 ? node_buffer_base+result_index : NULL;
+ }
+ if (search_step > 1)
+ search_step/=2;
+ }
+ return search_index;
+}
+
+static struct node_item *node_item_get(osmid id) {
+ struct node_item *node_buffer_base=(struct node_item *)(node_buffer.base);
+ long long result_index;
+ if (node_hash) {
+ // Use g_hash_table_lookup_extended instead of g_hash_table_lookup
+ // to distinguish a key with a value 0 from a missing key.
+ if (!g_hash_table_lookup_extended (node_hash, (gpointer)(id), NULL,
+ (gpointer)&result_index)) {
+ result_index=-1;
+ }
+ } else {
+ result_index=node_item_find_index_in_ordered_list(id);
+ }
+ return result_index!=-1 ? node_buffer_base+result_index : NULL;
}
#if 0
-static int
-load_node(FILE *coords, int p, struct node_item *ret)
-{
- fseek(coords, p*sizeof(struct node_item), SEEK_SET);
- if (fread(ret, sizeof(*ret), 1, coords) != 1) {
- fprintf(stderr,"read failed\n");
- return 0;
- }
- return 1;
+static int load_node(FILE *coords, int p, struct node_item *ret) {
+ fseek(coords, p*sizeof(struct node_item), SEEK_SET);
+ if (fread(ret, sizeof(*ret), 1, coords) != 1) {
+ fprintf(stderr,"read failed\n");
+ return 0;
+ }
+ return 1;
}
#endif
#if 0
-static int
-node_item_get_from_file(FILE *coords, osmid id, struct node_item *ret)
-{
- int count;
- int interval;
- int p;
- if (node_hash) {
- int i;
- i=(int)(long)(g_hash_table_lookup(node_hash, (gpointer)(long)id));
- fseek(coords, i*sizeof(*ret), SEEK_SET);
- if (fread(ret, sizeof(*ret), 1, coords) == 1)
- return 1;
- else
- return 0;
- }
-
- fseek(coords, 0, SEEK_END);
- count=ftello(coords)/sizeof(struct node_item);
- interval=count/4;
- p=count/2;
- if(interval==0) {
- // If fewer than 4 nodes defined so far set interval to 1 to
- // avoid infinite loop
- interval = 1;
- }
- if (!load_node(coords, p, ret))
- return 0;
- for (;;) {
- if (ret->id == id)
- return 1;
- if (ret->id < id) {
- p+=interval;
- if (interval == 1) {
- if (p >= count)
- return 0;
- if (!load_node(coords, p, ret))
- return 0;
- if (ret->id > id)
- return 0;
- } else {
- if (p >= count)
- p=count-1;
- if (!load_node(coords, p, ret))
- return 0;
- }
- } else {
- p-=interval;
- if (interval == 1) {
- if (p < 0)
- return 0;
- if (!load_node(coords, p, ret))
- return 0;
- if (ret->id < id)
- return 0;
- } else {
- if (p < 0)
- p=0;
- if (!load_node(coords, p, ret))
- return 0;
- }
- }
- if (interval > 1)
- interval/=2;
- }
-}
-#endif
-void
-osm_add_way(osmid id)
-{
- static osmid wayid_last;
-
- in_way=1;
- wayid=id;
- coord_count=0;
- attr_strings_clear();
- item.type=type_street_unkn;
- debug_attr_buffer[0]='\0';
- maxspeed_attr_value=0;
- flags_attr_value = 0;
- memset(flags, 0, sizeof(flags));
- memset(flagsa, 0, sizeof(flagsa));
- debug_attr_buffer[0]='\0';
- osmid_attr_value=id;
- if (wayid < wayid_last && !way_hash) {
- fprintf(stderr,"INFO: Ways out of sequence (new "OSMID_FMT" vs old "OSMID_FMT"), adding hash\n", wayid, wayid_last);
- way_hash=g_hash_table_new(NULL, NULL);
- }
- wayid_last=wayid;
+static int node_item_get_from_file(FILE *coords, osmid id, struct node_item *ret) {
+ int count;
+ int interval;
+ int p;
+ if (node_hash) {
+ int i;
+ i=(int)(long)(g_hash_table_lookup(node_hash, (gpointer)(long)id));
+ fseek(coords, i*sizeof(*ret), SEEK_SET);
+ if (fread(ret, sizeof(*ret), 1, coords) == 1)
+ return 1;
+ else
+ return 0;
+ }
+
+ fseek(coords, 0, SEEK_END);
+ count=ftello(coords)/sizeof(struct node_item);
+ interval=count/4;
+ p=count/2;
+ if(interval==0) {
+ // If fewer than 4 nodes defined so far set interval to 1 to
+ // avoid infinite loop
+ interval = 1;
+ }
+ if (!load_node(coords, p, ret))
+ return 0;
+ for (;;) {
+ if (ret->id == id)
+ return 1;
+ if (ret->id < id) {
+ p+=interval;
+ if (interval == 1) {
+ if (p >= count)
+ return 0;
+ if (!load_node(coords, p, ret))
+ return 0;
+ if (ret->id > id)
+ return 0;
+ } else {
+ if (p >= count)
+ p=count-1;
+ if (!load_node(coords, p, ret))
+ return 0;
+ }
+ } else {
+ p-=interval;
+ if (interval == 1) {
+ if (p < 0)
+ return 0;
+ if (!load_node(coords, p, ret))
+ return 0;
+ if (ret->id < id)
+ return 0;
+ } else {
+ if (p < 0)
+ p=0;
+ if (!load_node(coords, p, ret))
+ return 0;
+ }
+ }
+ if (interval > 1)
+ interval/=2;
+ }
+}
+#endif
+void osm_add_way(osmid id) {
+ static osmid wayid_last;
+
+ in_way=1;
+ wayid=id;
+ coord_count=0;
+ attr_strings_clear();
+ item.type=type_street_unkn;
+ debug_attr_buffer[0]='\0';
+ maxspeed_attr_value=0;
+ flags_attr_value = 0;
+ memset(flags, 0, sizeof(flags));
+ memset(flagsa, 0, sizeof(flagsa));
+ debug_attr_buffer[0]='\0';
+ osmid_attr_value=id;
+ if (wayid < wayid_last && !way_hash) {
+ fprintf(stderr,"INFO: Ways out of sequence (new "OSMID_FMT" vs old "OSMID_FMT"), adding hash\n", wayid, wayid_last);
+ way_hash=g_hash_table_new(NULL, NULL);
+ }
+ wayid_last=wayid;
}
char relation_type[BUFFER_SIZE];
char iso_code[BUFFER_SIZE];
int boundary;
-void
-osm_add_relation(osmid id)
-{
- osmid_attr_value=id;
- in_relation=1;
- debug_attr_buffer[0]='\0';
- relation_type[0]='\0';
- iso_code[0]='\0';
- boundary=0;
- item_bin_init(tmp_item_bin, type_none);
- item_bin_add_attr_longlong(tmp_item_bin, attr_osm_relationid, osmid_attr_value);
-}
-
-static int
-country_id_from_iso2(char *iso)
-{
- int ret=0;
- if (iso) {
- struct country_search *search;
- struct attr country_iso2,country_id;
- struct item *item;
- country_iso2.type=attr_country_iso2;
- country_iso2.u.str=iso;
- search=country_search_new(&country_iso2,0);
- if ((item=country_search_get_item(search)) && item_attr_get(item, attr_country_id, &country_id))
- ret=country_id.u.num;
-
- country_search_destroy(search);
- }
- return ret;
-}
-
-static struct country_table *
-country_from_countryid(int id)
-{
- int i;
- for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
- if (country_table[i].countryid == id)
- return &country_table[i];
- }
- return NULL;
+void osm_add_relation(osmid id) {
+ osmid_attr_value=id;
+ in_relation=1;
+ debug_attr_buffer[0]='\0';
+ relation_type[0]='\0';
+ iso_code[0]='\0';
+ boundary=0;
+ item_bin_init(tmp_item_bin, type_none);
+ item_bin_add_attr_longlong(tmp_item_bin, attr_osm_relationid, osmid_attr_value);
+}
+
+static int country_id_from_iso2(char *iso) {
+ int ret=0;
+ if (iso) {
+ struct country_search *search;
+ struct attr country_iso2,country_id;
+ struct item *item;
+ country_iso2.type=attr_country_iso2;
+ country_iso2.u.str=iso;
+ search=country_search_new(&country_iso2,0);
+ if ((item=country_search_get_item(search)) && item_attr_get(item, attr_country_id, &country_id))
+ ret=country_id.u.num;
+
+ country_search_destroy(search);
+ }
+ return ret;
+}
+
+static struct country_table *country_from_countryid(int id) {
+ int i;
+ for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
+ if (country_table[i].countryid == id)
+ return &country_table[i];
+ }
+ return NULL;
}
struct country_table *
-country_from_iso2(char *iso)
-{
- return country_from_countryid(country_id_from_iso2(iso));
+country_from_iso2(char *iso) {
+ return country_from_countryid(country_id_from_iso2(iso));
}
-void
-osm_end_relation(struct maptool_osm *osm)
-{
- enum item_type type;
+void osm_end_relation(struct maptool_osm *osm) {
+ enum item_type type;
- in_relation=0;
+ in_relation=0;
- if(attr_longest_match(attr_mapping_rel2poly_place, attr_mapping_rel2poly_place_count, &type, 1)) {
- tmp_item_bin->type=type;
- }
- else
- type=type_none;
+ if(attr_longest_match(attr_mapping_rel2poly_place, attr_mapping_rel2poly_place_count, &type, 1)) {
+ tmp_item_bin->type=type;
+ } else
+ type=type_none;
- if ((!strcmp(relation_type, "multipolygon") || !strcmp(relation_type, "boundary")) && (boundary || type!=type_none)) {
- item_bin_write(tmp_item_bin, osm->boundaries);
- }
+ if ((!g_strcmp0(relation_type, "multipolygon") || !g_strcmp0(relation_type, "boundary"))
+ && (boundary || type!=type_none)) {
+ item_bin_write(tmp_item_bin, osm->boundaries);
+ }
- if (!strcmp(relation_type, "restriction") && (tmp_item_bin->type == type_street_turn_restriction_no || tmp_item_bin->type == type_street_turn_restriction_only))
- item_bin_write(tmp_item_bin, osm->turn_restrictions);
+ if (!g_strcmp0(relation_type, "restriction") && (tmp_item_bin->type == type_street_turn_restriction_no
+ || tmp_item_bin->type == type_street_turn_restriction_only))
+ item_bin_write(tmp_item_bin, osm->turn_restrictions);
+
+ if (!g_strcmp0(relation_type, "associatedStreet") )
+ item_bin_write(tmp_item_bin, osm->associated_streets);
+
+ attr_longest_match_clear();
+}
+
+void osm_add_member(enum relation_member_type type, osmid ref, char *role) {
+ const int bufsize=BUFFER_SIZE*3+3;
+ char member_buffer[bufsize];
+ struct attr memberattr = { attr_osm_member };
+
+ snprintf(member_buffer,bufsize, RELATION_MEMBER_PRINT_FORMAT, (int)type, (long long) ref, role);
+ memberattr.u.str=member_buffer;
+ item_bin_add_attr(tmp_item_bin, &memberattr);
+}
+
+static void relation_add_tag(char *k, char *v) {
+ int add_tag=1;
+ if (!g_strcmp0(k,"type")) {
+ g_strlcpy(relation_type, v, sizeof(relation_type));
+ add_tag=0;
+ } else if (!g_strcmp0(k,"restriction")) {
+ if (!strncmp(v,"no_",3)) {
+ tmp_item_bin->type=type_street_turn_restriction_no;
+ add_tag=0;
+ } else if (!strncmp(v,"only_",5)) {
+ tmp_item_bin->type=type_street_turn_restriction_only;
+ add_tag=0;
+ } else {
+ tmp_item_bin->type=type_none;
+ osm_warning("relation", osmid_attr_value, 0, "Unknown restriction %s\n",v);
+ }
+ } else if (!g_strcmp0(k,"boundary")) {
+ if (!g_strcmp0(v,"administrative") || !g_strcmp0(v,"postal_code")) {
+ boundary=1;
+ }
+ } else if (!g_strcmp0(k,"ISO3166-1") || !g_strcmp0(k,"ISO3166-1:alpha2")) {
+ g_strlcpy(iso_code, v, sizeof(iso_code));
+ }
+ if (add_tag) {
+ char *tag;
+ tag=g_alloca(strlen(k)+strlen(v)+2);
+ sprintf(tag,"%s=%s",k,v);
+ item_bin_add_attr_string(tmp_item_bin, attr_osm_tag, tag);
+ }
- if (!strcmp(relation_type, "associatedStreet") )
- item_bin_write(tmp_item_bin, osm->associated_streets);
-
- attr_longest_match_clear();
+ osm_update_attr_present(k,v);
}
-void
-osm_add_member(enum relation_member_type type, osmid ref, char *role)
-{
- const int bufsize=BUFFER_SIZE*3+3;
- char member_buffer[bufsize];
- struct attr memberattr = { attr_osm_member };
- snprintf(member_buffer,bufsize, RELATION_MEMBER_PRINT_FORMAT, (int)type, (long long) ref, role);
- memberattr.u.str=member_buffer;
- item_bin_add_attr(tmp_item_bin, &memberattr);
+static int attr_longest_match(struct attr_mapping **mapping, int mapping_count, enum item_type *types,
+ int types_count) {
+ int i,j,longest=0,ret=0,sum,val;
+ struct attr_mapping *curr;
+ for (i = 0 ; i < mapping_count ; i++) {
+ sum=0;
+ curr=mapping[i];
+ for (j = 0 ; j < curr->attr_present_idx_count ; j++) {
+ val=attr_present[curr->attr_present_idx[j]];
+ if (val)
+ sum+=val;
+ else {
+ sum=-1;
+ break;
+ }
+ }
+ if (sum > longest) {
+ longest=sum;
+ ret=0;
+ }
+ if (sum > 0 && sum == longest && ret < types_count)
+ types[ret++]=curr->type;
+ }
+ return ret;
}
-static void
-relation_add_tag(char *k, char *v)
-{
- int add_tag=1;
-#if 0
- fprintf(stderr,"add tag %s %s\n",k,v);
-#endif
- if (!strcmp(k,"type")) {
- g_strlcpy(relation_type, v, sizeof(relation_type));
- add_tag=0;
- }
- else if (!strcmp(k,"restriction")) {
- if (!strncmp(v,"no_",3)) {
- tmp_item_bin->type=type_street_turn_restriction_no;
- add_tag=0;
- } else if (!strncmp(v,"only_",5)) {
- tmp_item_bin->type=type_street_turn_restriction_only;
- add_tag=0;
- } else {
- tmp_item_bin->type=type_none;
- osm_warning("relation", osmid_attr_value, 0, "Unknown restriction %s\n",v);
- }
- } else if (!strcmp(k,"boundary")) {
- if (!strcmp(v,"administrative") || !strcmp(v,"postal_code")) {
- boundary=1;
- }
- } else if (!strcmp(k,"ISO3166-1") || !strcmp(k,"ISO3166-1:alpha2")) {
- g_strlcpy(iso_code, v, sizeof(iso_code));
- }
- if (add_tag) {
- char *tag;
- tag=g_alloca(strlen(k)+strlen(v)+2);
- sprintf(tag,"%s=%s",k,v);
- item_bin_add_attr_string(tmp_item_bin, attr_osm_tag, tag);
- }
-
- osm_update_attr_present(k,v);
-}
-
-
-static int
-attr_longest_match(struct attr_mapping **mapping, int mapping_count, enum item_type *types, int types_count)
-{
- int i,j,longest=0,ret=0,sum,val;
- struct attr_mapping *curr;
- for (i = 0 ; i < mapping_count ; i++) {
- sum=0;
- curr=mapping[i];
- for (j = 0 ; j < curr->attr_present_idx_count ; j++) {
- val=attr_present[curr->attr_present_idx[j]];
- if (val)
- sum+=val;
- else {
- sum=-1;
- break;
- }
- }
- if (sum > longest) {
- longest=sum;
- ret=0;
- }
- if (sum > 0 && sum == longest && ret < types_count)
- types[ret++]=curr->type;
- }
- return ret;
-}
-
-static void
-attr_longest_match_clear(void)
-{
- memset(attr_present, 0, sizeof(*attr_present)*attr_present_count);
-}
-
-void
-osm_end_way(struct maptool_osm *osm)
-{
- int i,count;
- int *def_flags,add_flags;
- enum item_type types[10];
- struct item_bin *item_bin;
- int count_lines=0, count_areas=0;
-
- in_way=0;
-
- if (! osm->ways)
- return;
-
- if (dedupe_ways_hash) {
- if (g_hash_table_lookup(dedupe_ways_hash, (gpointer)(long long)wayid))
- return;
- g_hash_table_insert(dedupe_ways_hash, (gpointer)(long long)wayid, (gpointer)1);
- }
-
- count=attr_longest_match(attr_mapping_way, attr_mapping_way_count, types, sizeof(types)/sizeof(enum item_type));
- if (!count) {
- count=1;
- types[0]=type_street_unkn;
- }
- if (count >= 10) {
- fprintf(stderr,"way id "OSMID_FMT"\n",osmid_attr_value);
- dbg_assert(count < 10);
- }
- for (i = 0 ; i < count ; i++) {
- add_flags=0;
- if (types[i] == type_none)
- continue;
- if (ignore_unknown && (types[i] == type_street_unkn || types[i] == type_point_unkn))
- continue;
- if (types[i] != type_street_unkn) {
- if(types[i]<type_area)
- count_lines++;
- else
- count_areas++;
- }
- item_bin=init_item(types[i]);
- item_bin_add_coord(item_bin, coord_buffer, coord_count);
- nodes_ref_item_bin(item_bin);
- def_flags=item_get_default_flags(types[i]);
- if (def_flags) {
- flags_attr_value=((*def_flags & ~flagsa[2]) | flags[0] | flags[1] | flagsa[1]) & ~flags[2];
- if (flags_attr_value != *def_flags)
- add_flags=1;
- }
- item_bin_add_attr_string(item_bin, def_flags ? attr_street_name : attr_label, attr_strings[attr_string_label]);
- item_bin_add_attr_string(item_bin, attr_district_name, attr_strings[attr_string_district_name]);
- item_bin_add_attr_string(item_bin, attr_street_name_systematic, attr_strings[attr_string_street_name_systematic]);
- item_bin_add_attr_string(item_bin, attr_street_name_systematic_nat, attr_strings[attr_string_street_name_systematic_nat]);
- item_bin_add_attr_string(item_bin, attr_street_destination, attr_strings[attr_string_street_destination]);
- item_bin_add_attr_string(item_bin, attr_street_destination_forward, attr_strings[attr_string_street_destination_forward]);
- item_bin_add_attr_string(item_bin, attr_street_destination_backward, attr_strings[attr_string_street_destination_backward]);
- item_bin_add_attr_longlong(item_bin, attr_osm_wayid, osmid_attr_value);
- if (debug_attr_buffer[0])
- item_bin_add_attr_string(item_bin, attr_debug, debug_attr_buffer);
- if (add_flags)
- item_bin_add_attr_int(item_bin, attr_flags, flags_attr_value);
- if (maxspeed_attr_value)
- item_bin_add_attr_int(item_bin, attr_maxspeed, maxspeed_attr_value);
- if(i>0)
- item_bin_add_attr_int(item_bin, attr_duplicate, 1);
- item_bin_write(item_bin,osm->ways);
-
- if (types[i]>=type_house_number_interpolation_even && types[i]<=type_house_number_interpolation_alphabetic){
- struct item_bin *item_bin_interpolation_way=init_item(types[i]);
- item_bin_add_attr_longlong(item_bin, attr_osm_wayid, osmid_attr_value);
- item_bin_add_attr_longlong(item_bin, attr_osm_nodeid_first_node, GET_REF(coord_buffer[0]));
- item_bin_add_attr_longlong(item_bin, attr_osm_nodeid_last_node, GET_REF(coord_buffer[coord_count-1]));
- item_bin_write(item_bin_interpolation_way, osm->house_number_interpolations);
- }
- }
- if(osm->line2poi) {
- count=attr_longest_match(attr_mapping_way2poi, attr_mapping_way2poi_count, types, sizeof(types)/sizeof(enum item_type));
- dbg_assert(count < 10);
- for (i = 0 ; i < count ; i++) {
- if (types[i] == type_none || types[i] == type_point_unkn)
- continue;
- item_bin=init_item(types[i]);
- item_bin_add_coord(item_bin, coord_buffer, coord_count);
- item_bin_add_attr_string(item_bin, attr_label, attr_strings[attr_string_label]);
- item_bin_add_attr_string(item_bin, attr_house_number, attr_strings[attr_string_house_number]);
- item_bin_add_attr_string(item_bin, attr_district_name, attr_strings[attr_string_district_name]);
- item_bin_add_attr_string(item_bin, attr_street_name, attr_strings[attr_string_street_name]);
- item_bin_add_attr_string(item_bin, attr_phone, attr_strings[attr_string_phone]);
- item_bin_add_attr_string(item_bin, attr_fax, attr_strings[attr_string_fax]);
- item_bin_add_attr_string(item_bin, attr_email, attr_strings[attr_string_email]);
- item_bin_add_attr_string(item_bin, attr_county_name, attr_strings[attr_string_county_name]);
- item_bin_add_attr_string(item_bin, attr_url, attr_strings[attr_string_url]);
- item_bin_add_attr_longlong(item_bin, attr_osm_wayid, osmid_attr_value);
- item_bin_write(item_bin, count_areas<=count_lines ? osm->line2poi:osm->poly2poi);
- }
- }
- attr_longest_match_clear();
-}
-
-void
-osm_end_node(struct maptool_osm *osm)
-{
- int count,i;
- char *postal;
- enum item_type types[10];
- struct item_bin *item_bin;
- in_node=0;
-
- if (!osm->nodes || ! node_is_tagged || ! nodeid)
- return;
- count=attr_longest_match(attr_mapping_node, attr_mapping_node_count, types, sizeof(types)/sizeof(enum item_type));
- if (!count) {
- types[0]=type_point_unkn;
- count=1;
- }
- if (count >= 10) {
- fprintf(stderr,"node id "OSMID_FMT"\n",osmid_attr_value);
- dbg_assert(count < 10);
- }
- for (i = 0 ; i < count ; i++) {
- if (types[i] == type_none)
- continue;
- if (ignore_unknown && (types[i] == type_street_unkn || types[i] == type_point_unkn))
- continue;
- item_bin=init_item(types[i]);
- if (item_is_town(*item_bin) && attr_strings[attr_string_population])
- item_bin_set_type_by_population(item_bin, atoi(attr_strings[attr_string_population]));
- item_bin_add_coord(item_bin, &current_node->c, 1);
- item_bin_add_attr_string(item_bin, item_is_town(*item_bin) ? attr_town_name : attr_label, attr_strings[attr_string_label]);
- item_bin_add_attr_string(item_bin, attr_house_number, attr_strings[attr_string_house_number]);
- item_bin_add_attr_string(item_bin, attr_street_name, attr_strings[attr_string_street_name]);
- item_bin_add_attr_string(item_bin, attr_phone, attr_strings[attr_string_phone]);
- item_bin_add_attr_string(item_bin, attr_fax, attr_strings[attr_string_fax]);
- item_bin_add_attr_string(item_bin, attr_email, attr_strings[attr_string_email]);
- item_bin_add_attr_string(item_bin, attr_county_name, attr_strings[attr_string_county_name]);
- item_bin_add_attr_string(item_bin, attr_url, attr_strings[attr_string_url]);
- item_bin_add_attr_longlong(item_bin, attr_osm_nodeid, osmid_attr_value);
- item_bin_add_attr_string(item_bin, attr_ref, attr_strings[attr_string_ref]);
- item_bin_add_attr_string(item_bin, attr_exit_to, attr_strings[attr_string_exit_to]);
- item_bin_add_attr_string(item_bin, attr_debug, debug_attr_buffer);
- postal=attr_strings[attr_string_postal];
- if (postal) {
- char *sep=strchr(postal,',');
- if (sep)
- *sep='\0';
- item_bin_add_attr_string(item_bin, item_is_town(*item_bin) ? attr_town_postal : attr_postal, postal);
- }
- item_bin_write(item_bin,osm->nodes);
- if (item_is_town(*item_bin) && attr_strings[attr_string_label] && osm->towns) {
- item_bin=init_item(item_bin->type);
- item_bin_add_coord(item_bin, &current_node->c, 1);
- item_bin_add_attr_string(item_bin, attr_osm_is_in, is_in_buffer);
- item_bin_add_attr_longlong(item_bin, attr_osm_nodeid, osmid_attr_value);
- item_bin_add_attr_string(item_bin, attr_town_postal, postal);
- item_bin_add_attr_string(item_bin, attr_county_name, attr_strings[attr_string_county_name]);
- item_bin_add_attr_string(item_bin, item_is_district(*item_bin)?attr_district_name:attr_town_name, attr_strings[attr_string_label]);
- item_bin_write(item_bin, osm->towns);
- }
- }
- processed_nodes_out++;
- attr_longest_match_clear();
+static void attr_longest_match_clear(void) {
+ memset(attr_present, 0, sizeof(*attr_present)*attr_present_count);
+}
+
+void osm_end_way(struct maptool_osm *osm) {
+ int i,count;
+ int *def_flags,add_flags;
+ enum item_type types[10];
+ struct item_bin *item_bin;
+ int count_lines=0, count_areas=0;
+
+ in_way=0;
+
+ if (! osm->ways)
+ return;
+
+ if (dedupe_ways_hash) {
+ if (g_hash_table_lookup(dedupe_ways_hash, (gpointer)(long long)wayid))
+ return;
+ g_hash_table_insert(dedupe_ways_hash, (gpointer)(long long)wayid, (gpointer)1);
+ }
+
+ count=attr_longest_match(attr_mapping_way, attr_mapping_way_count, types, sizeof(types)/sizeof(enum item_type));
+ if (!count) {
+ count=1;
+ types[0]=type_street_unkn;
+ }
+ if (count >= 10) {
+ fprintf(stderr,"way id "OSMID_FMT"\n",osmid_attr_value);
+ dbg_assert(count < 10);
+ }
+ for (i = 0 ; i < count ; i++) {
+ add_flags=0;
+ if (types[i] == type_none)
+ continue;
+ if (ignore_unknown && (types[i] == type_street_unkn || types[i] == type_point_unkn))
+ continue;
+ if (types[i] != type_street_unkn) {
+ if(types[i]<type_area)
+ count_lines++;
+ else
+ count_areas++;
+ }
+ item_bin=init_item(types[i]);
+ item_bin_add_coord(item_bin, coord_buffer, coord_count);
+ nodes_ref_item_bin(item_bin);
+ def_flags=item_get_default_flags(types[i]);
+ if (def_flags) {
+ flags_attr_value=((*def_flags & ~flagsa[2]) | flags[0] | flags[1] | flagsa[1]) & ~flags[2];
+ if (flags_attr_value != *def_flags)
+ add_flags=1;
+ }
+ item_bin_add_attr_string(item_bin, def_flags ? attr_street_name : attr_label, attr_strings[attr_string_label]);
+ item_bin_add_attr_string(item_bin, attr_district_name, attr_strings[attr_string_district_name]);
+ item_bin_add_attr_string(item_bin, attr_street_name_systematic, attr_strings[attr_string_street_name_systematic]);
+ item_bin_add_attr_string(item_bin, attr_street_name_systematic_nat,
+ attr_strings[attr_string_street_name_systematic_nat]);
+ item_bin_add_attr_string(item_bin, attr_street_destination, attr_strings[attr_string_street_destination]);
+ item_bin_add_attr_string(item_bin, attr_street_destination_forward,
+ attr_strings[attr_string_street_destination_forward]);
+ item_bin_add_attr_string(item_bin, attr_street_destination_backward,
+ attr_strings[attr_string_street_destination_backward]);
+ item_bin_add_attr_longlong(item_bin, attr_osm_wayid, osmid_attr_value);
+ if (debug_attr_buffer[0])
+ item_bin_add_attr_string(item_bin, attr_debug, debug_attr_buffer);
+ if (add_flags)
+ item_bin_add_attr_int(item_bin, attr_flags, flags_attr_value);
+ if (maxspeed_attr_value)
+ item_bin_add_attr_int(item_bin, attr_maxspeed, maxspeed_attr_value);
+ if(i>0)
+ item_bin_add_attr_int(item_bin, attr_duplicate, 1);
+ item_bin_write(item_bin,osm->ways);
+
+ if (types[i]>=type_house_number_interpolation_even && types[i]<=type_house_number_interpolation_alphabetic) {
+ struct item_bin *item_bin_interpolation_way=init_item(types[i]);
+ item_bin_add_attr_longlong(item_bin, attr_osm_wayid, osmid_attr_value);
+ item_bin_add_attr_longlong(item_bin, attr_osm_nodeid_first_node, GET_REF(coord_buffer[0]));
+ item_bin_add_attr_longlong(item_bin, attr_osm_nodeid_last_node, GET_REF(coord_buffer[coord_count-1]));
+ item_bin_write(item_bin_interpolation_way, osm->house_number_interpolations);
+ }
+ }
+ if(osm->line2poi) {
+ count=attr_longest_match(attr_mapping_way2poi, attr_mapping_way2poi_count, types, sizeof(types)/sizeof(enum item_type));
+ dbg_assert(count < 10);
+ for (i = 0 ; i < count ; i++) {
+ if (types[i] == type_none || types[i] == type_point_unkn)
+ continue;
+ item_bin=init_item(types[i]);
+ item_bin_add_coord(item_bin, coord_buffer, coord_count);
+ item_bin_add_attr_string(item_bin, attr_label, attr_strings[attr_string_label]);
+ item_bin_add_attr_string(item_bin, attr_house_number, attr_strings[attr_string_house_number]);
+ item_bin_add_attr_string(item_bin, attr_district_name, attr_strings[attr_string_district_name]);
+ item_bin_add_attr_string(item_bin, attr_street_name, attr_strings[attr_string_street_name]);
+ item_bin_add_attr_string(item_bin, attr_phone, attr_strings[attr_string_phone]);
+ item_bin_add_attr_string(item_bin, attr_fax, attr_strings[attr_string_fax]);
+ item_bin_add_attr_string(item_bin, attr_email, attr_strings[attr_string_email]);
+ item_bin_add_attr_string(item_bin, attr_county_name, attr_strings[attr_string_county_name]);
+ item_bin_add_attr_string(item_bin, attr_url, attr_strings[attr_string_url]);
+ item_bin_add_attr_longlong(item_bin, attr_osm_wayid, osmid_attr_value);
+ item_bin_write(item_bin, count_areas<=count_lines ? osm->line2poi:osm->poly2poi);
+ }
+ }
+ attr_longest_match_clear();
+}
+
+void osm_end_node(struct maptool_osm *osm) {
+ int count,i;
+ char *postal;
+ enum item_type types[10];
+ struct item_bin *item_bin;
+ in_node=0;
+
+ if (!osm->nodes || ! node_is_tagged || ! nodeid)
+ return;
+ count=attr_longest_match(attr_mapping_node, attr_mapping_node_count, types, sizeof(types)/sizeof(enum item_type));
+ if (!count) {
+ types[0]=type_point_unkn;
+ count=1;
+ }
+ if (count >= 10) {
+ fprintf(stderr,"node id "OSMID_FMT"\n",osmid_attr_value);
+ dbg_assert(count < 10);
+ }
+ for (i = 0 ; i < count ; i++) {
+ if (types[i] == type_none)
+ continue;
+ if (ignore_unknown && (types[i] == type_street_unkn || types[i] == type_point_unkn))
+ continue;
+ item_bin=init_item(types[i]);
+ if (item_is_town(*item_bin) && attr_strings[attr_string_population])
+ item_bin_set_type_by_population(item_bin, atoi(attr_strings[attr_string_population]));
+ item_bin_add_coord(item_bin, &current_node->c, 1);
+ item_bin_add_attr_string(item_bin, item_is_town(*item_bin) ? attr_town_name : attr_label,
+ attr_strings[attr_string_label]);
+ item_bin_add_attr_string(item_bin, attr_house_number, attr_strings[attr_string_house_number]);
+ item_bin_add_attr_string(item_bin, attr_street_name, attr_strings[attr_string_street_name]);
+ item_bin_add_attr_string(item_bin, attr_phone, attr_strings[attr_string_phone]);
+ item_bin_add_attr_string(item_bin, attr_fax, attr_strings[attr_string_fax]);
+ item_bin_add_attr_string(item_bin, attr_email, attr_strings[attr_string_email]);
+ item_bin_add_attr_string(item_bin, attr_county_name, attr_strings[attr_string_county_name]);
+ item_bin_add_attr_string(item_bin, attr_url, attr_strings[attr_string_url]);
+ item_bin_add_attr_longlong(item_bin, attr_osm_nodeid, osmid_attr_value);
+ item_bin_add_attr_string(item_bin, attr_ref, attr_strings[attr_string_ref]);
+ item_bin_add_attr_string(item_bin, attr_exit_to, attr_strings[attr_string_exit_to]);
+ item_bin_add_attr_string(item_bin, attr_debug, debug_attr_buffer);
+ postal=attr_strings[attr_string_postal];
+ if (postal) {
+ char *sep=strchr(postal,',');
+ if (sep)
+ *sep='\0';
+ item_bin_add_attr_string(item_bin, item_is_town(*item_bin) ? attr_town_postal : attr_postal, postal);
+ }
+ item_bin_write(item_bin,osm->nodes);
+ if (item_is_town(*item_bin) && attr_strings[attr_string_label] && osm->towns) {
+ item_bin=init_item(item_bin->type);
+ item_bin_add_coord(item_bin, &current_node->c, 1);
+ item_bin_add_attr_string(item_bin, attr_osm_is_in, is_in_buffer);
+ item_bin_add_attr_longlong(item_bin, attr_osm_nodeid, osmid_attr_value);
+ item_bin_add_attr_string(item_bin, attr_town_postal, postal);
+ item_bin_add_attr_string(item_bin, attr_county_name, attr_strings[attr_string_county_name]);
+ item_bin_add_attr_string(item_bin, item_is_district(*item_bin)?attr_district_name:attr_town_name,
+ attr_strings[attr_string_label]);
+ item_bin_write(item_bin, osm->towns);
+ }
+ }
+ processed_nodes_out++;
+ attr_longest_match_clear();
}
#define MAX_TOWN_ADMIN_LEVELS 11
struct town_country {
- /* attrs[0] is reserved for postal code */
- /* attrs[1..] are for osm admin levels 3.. (admin_level=2 is always a country boundary)*/
- struct attr attrs[MAX_TOWN_ADMIN_LEVELS];
- struct country_table *country;
+ /* attrs[0] is reserved for postal code */
+ /* attrs[1..] are for osm admin levels 3.. (admin_level=2 is always a country boundary)*/
+ struct attr attrs[MAX_TOWN_ADMIN_LEVELS];
+ struct country_table *country;
};
-static struct town_country *
-town_country_new(struct country_table *country)
-{
- struct town_country *ret=g_malloc0(sizeof(struct town_country));
- ret->country=country;
- return ret;
+static struct town_country *town_country_new(struct country_table *country) {
+ struct town_country *ret=g_malloc0(sizeof(struct town_country));
+ ret->country=country;
+ return ret;
}
-static void
-town_country_destroy(struct town_country *tc)
-{
- g_free(tc);
+static void town_country_destroy(struct town_country *tc) {
+ g_free(tc);
}
/**
@@ -1989,33 +1899,29 @@ town_country_destroy(struct town_country *tc)
* @param in country country to add the town to
* @returns refernce to then new town_country structure added to the list, or NULL if GList already had an entry for the country given
*/
-static struct town_country *
-town_country_list_insert_if_new(GList **town_country_list, struct country_table *country)
-{
- GList *l;
- struct town_country *ret;
+static struct town_country *town_country_list_insert_if_new(GList **town_country_list, struct country_table *country) {
+ GList *l;
+ struct town_country *ret;
- if(!country)
- return NULL;
+ if(!country)
+ return NULL;
- for(l=*town_country_list; l; l=g_list_next(l)) {
- if(((struct town_country*)l->data)->country==country)
- return NULL;
- }
+ for(l=*town_country_list; l; l=g_list_next(l)) {
+ if(((struct town_country*)l->data)->country==country)
+ return NULL;
+ }
- ret=town_country_new(country);
- *town_country_list=g_list_prepend(*town_country_list, ret);
- return ret;
+ ret=town_country_new(country);
+ *town_country_list=g_list_prepend(*town_country_list, ret);
+ return ret;
}
-static GList *
-osm_process_town_unknown_country(void)
-{
- static struct country_table *unknown;
- if (!unknown)
- unknown=country_from_countryid(999);
+static GList *osm_process_town_unknown_country(void) {
+ static struct country_table *unknown;
+ if (!unknown)
+ unknown=country_from_countryid(999);
- return g_list_prepend(NULL, town_country_new(unknown));
+ return g_list_prepend(NULL, town_country_new(unknown));
}
@@ -2026,27 +1932,25 @@ osm_process_town_unknown_country(void)
* @param in town_hash hash of all town names
* @returns refernce to a list of struct town_country* the town belongs to
*/
-static char *
-osm_process_town_get_town_name_from_is_in(struct item_bin *ib, GHashTable *town_hash)
-{
- char *is_in=item_bin_get_attr(ib, attr_osm_is_in, NULL);
- char *tok,*dup,*buf;
- char *town=NULL;
-
- if(!is_in)
- return NULL;
-
- dup=g_strdup(is_in);
- buf=dup;
- while (!town && (tok=strtok(buf, ",;"))) {
- while (*tok==' ')
- tok++;
- town=g_hash_table_lookup(town_hash, tok);
- buf=NULL;
- }
- g_free(dup);
+static char *osm_process_town_get_town_name_from_is_in(struct item_bin *ib, GHashTable *town_hash) {
+ char *is_in=item_bin_get_attr(ib, attr_osm_is_in, NULL);
+ char *tok,*dup,*buf;
+ char *town=NULL;
+
+ if(!is_in)
+ return NULL;
+
+ dup=g_strdup(is_in);
+ buf=dup;
+ while (!town && (tok=strtok(buf, ",;"))) {
+ while (*tok==' ')
+ tok++;
+ town=g_hash_table_lookup(town_hash, tok);
+ buf=NULL;
+ }
+ g_free(dup);
- return town;
+ return town;
}
@@ -2055,30 +1959,28 @@ osm_process_town_get_town_name_from_is_in(struct item_bin *ib, GHashTable *town_
* @param in ib pointer to item_bin structure holding town information
* @returns refernce to a list of struct town_country* the town belongs to
*/
-static GList *
-osm_process_town_by_is_in(struct item_bin *ib)
-{
- struct country_table *country;
- char *is_in=item_bin_get_attr(ib, attr_osm_is_in, NULL);
- char *tok,*dup,*buf;
- GList *town_country_list=NULL;
-
- if(!is_in)
- return NULL;
-
- dup=g_strdup(is_in);
- buf=dup;
- while ((tok=strtok(buf, ",;"))) {
- while (*tok==' ')
- tok++;
- country=g_hash_table_lookup(country_table_hash,tok);
- town_country_list_insert_if_new(&town_country_list, country);
- buf=NULL;
- }
+static GList *osm_process_town_by_is_in(struct item_bin *ib) {
+ struct country_table *country;
+ char *is_in=item_bin_get_attr(ib, attr_osm_is_in, NULL);
+ char *tok,*dup,*buf;
+ GList *town_country_list=NULL;
+
+ if(!is_in)
+ return NULL;
+
+ dup=g_strdup(is_in);
+ buf=dup;
+ while ((tok=strtok(buf, ",;"))) {
+ while (*tok==' ')
+ tok++;
+ country=g_hash_table_lookup(country_table_hash,tok);
+ town_country_list_insert_if_new(&town_country_list, country);
+ buf=NULL;
+ }
- g_free(dup);
+ g_free(dup);
- return town_country_list;
+ return town_country_list;
}
/**
@@ -2089,80 +1991,78 @@ osm_process_town_by_is_in(struct item_bin *ib)
* @param in matches list of administrative boundaries the town belongs to (data is struct boundary *)
* @returns nothing
*/
-static void
-osm_process_town_by_boundary_update_attrs(struct item_bin *town, struct town_country *tc, GList *matches)
-{
- long long *nodeid;
- long long node_id=0;
- int max_possible_adm_level=-1;
- int max_adm_level=0;
- GList *l;
- int a;
-
- if(tc->country->admin_levels)
- max_possible_adm_level=strlen(tc->country->admin_levels)+3;
-
- nodeid=item_bin_get_attr(town, attr_osm_nodeid, NULL);
- if(nodeid)
- node_id=*nodeid;
-
- for(l=matches;l;l=g_list_next(l)) {
- struct boundary *b=l->data;
- char *boundary_admin_level_string;
- char *name;
- char *postal=osm_tag_value(b->ib, "postal_code");
-
- if (postal) {
- tc->attrs[0].type=attr_town_postal;
- tc->attrs[0].u.str=postal;
- }
-
- if(max_possible_adm_level==-1)
- continue;
-
- boundary_admin_level_string=osm_tag_value(b->ib, "admin_level");
-
- if (!boundary_admin_level_string)
- continue;
-
- a=atoi(boundary_admin_level_string);
- if (a > 2 && a < max_possible_adm_level) {
- enum attr_type attr_type=attr_none;
- switch(tc->country->admin_levels[a-3]) {
- case 's':
- attr_type=attr_state_name;
- break;
- case 'c':
- attr_type=attr_county_name;
- break;
- case 'M':
- /* Here we patch the boundary itself to convert it to town polygon later*/
- b->ib->type=type_poly_place6;
- case 'm':
- attr_type=attr_municipality_name;
- break;
- case 'T':
- /* Here we patch the boundary itself to convert it to town polygon later*/
- b->ib->type=type_poly_place6;
- break;
- }
- name=osm_tag_value(b->ib, "name");
- if (name && attr_type != attr_none) {
- tc->attrs[a-2].type=attr_type;
- tc->attrs[a-2].u.str=name;
- }
- }
- if(b->admin_centre && b->admin_centre==node_id) {
- if(!max_adm_level || max_adm_level<a) {
- max_adm_level=a;
- }
- }
- }
-
- /* Administrative centres are not to be contained in their own districts. */
- if(max_adm_level>0)
- for(a=max_possible_adm_level-1;a>max_adm_level && a>2;a--)
- tc->attrs[a-2].type=type_none;
+static void osm_process_town_by_boundary_update_attrs(struct item_bin *town, struct town_country *tc, GList *matches) {
+ long long *nodeid;
+ long long node_id=0;
+ int max_possible_adm_level=-1;
+ int max_adm_level=0;
+ GList *l;
+ int a;
+
+ if(tc->country->admin_levels)
+ max_possible_adm_level=strlen(tc->country->admin_levels)+3;
+
+ nodeid=item_bin_get_attr(town, attr_osm_nodeid, NULL);
+ if(nodeid)
+ node_id=*nodeid;
+
+ for(l=matches; l; l=g_list_next(l)) {
+ struct boundary *b=l->data;
+ char *boundary_admin_level_string;
+ char *name;
+ char *postal=osm_tag_value(b->ib, "postal_code");
+
+ if (postal) {
+ tc->attrs[0].type=attr_town_postal;
+ tc->attrs[0].u.str=postal;
+ }
+
+ if(max_possible_adm_level==-1)
+ continue;
+
+ boundary_admin_level_string=osm_tag_value(b->ib, "admin_level");
+
+ if (!boundary_admin_level_string)
+ continue;
+
+ a=atoi(boundary_admin_level_string);
+ if (a > 2 && a < max_possible_adm_level) {
+ enum attr_type attr_type=attr_none;
+ switch(tc->country->admin_levels[a-3]) {
+ case 's':
+ attr_type=attr_state_name;
+ break;
+ case 'c':
+ attr_type=attr_county_name;
+ break;
+ case 'M':
+ /* Here we patch the boundary itself to convert it to town polygon later*/
+ b->ib->type=type_poly_place6;
+ case 'm':
+ attr_type=attr_municipality_name;
+ break;
+ case 'T':
+ /* Here we patch the boundary itself to convert it to town polygon later*/
+ b->ib->type=type_poly_place6;
+ break;
+ }
+ name=osm_tag_value(b->ib, "name");
+ if (name && attr_type != attr_none) {
+ tc->attrs[a-2].type=attr_type;
+ tc->attrs[a-2].u.str=name;
+ }
+ }
+ if(b->admin_centre && b->admin_centre==node_id) {
+ if(!max_adm_level || max_adm_level<a) {
+ max_adm_level=a;
+ }
+ }
+ }
+
+ /* Administrative centres are not to be contained in their own districts. */
+ if(max_adm_level>0)
+ for(a=max_possible_adm_level-1; a>max_adm_level && a>2; a--)
+ tc->attrs[a-2].type=type_none;
}
/**
@@ -2173,1085 +2073,1035 @@ osm_process_town_by_boundary_update_attrs(struct item_bin *town, struct town_cou
* @param in c town center coordinates
* @returns refernce to the list of town_country structures
*/
-static GList *
-osm_process_town_by_boundary(GList *bl, struct item_bin *town, struct coord *c)
-{
- GList *matches=boundary_find_matches(bl, c);
- GList *town_country_list=NULL;
- GList *l;
-
- for (l=matches;l;l=g_list_next(l)) {
- struct boundary *match=l->data;
- if (match->country) {
- struct town_country *tc=town_country_list_insert_if_new(&town_country_list, match->country);
- if(tc)
- osm_process_town_by_boundary_update_attrs(town, tc, matches);
- }
- }
-
- g_list_free(matches);
-
- return town_country_list;
-}
-
-static void
-osm_town_relations_to_poly(GList *boundaries, FILE *towns_poly)
-{
- while(boundaries) {
- struct boundary *b=boundaries->data;
- if(item_is_poly_place(*b->ib)) {
- GList *s=b->sorted_segments;
- while(s) {
- struct geom_poly_segment *seg=s->data;
- if((seg->type==geom_poly_segment_type_way_outer || seg->type==geom_poly_segment_type_way_unknown) && coord_is_equal(*seg->first,*seg->last)) {
- struct item_bin *ib=init_item(b->ib->type);
- void *a;
- item_bin_add_coord(ib, seg->first, seg->last-seg->first+1);
- a=osm_tag_value(b->ib, "name");
- if(a)
- item_bin_add_attr_string(ib,attr_label,a);
- a=osm_tag_value(b->ib, "osm_relationid");
- if(a)
- item_bin_add_attr_longlong(ib,attr_osm_relationid,atol(a));
- item_bin_write(ib, towns_poly);
- }
- s=g_list_next(s);
- }
- }
- osm_town_relations_to_poly(b->children, towns_poly);
- boundaries=g_list_next(boundaries);
- }
-}
-
-
-void
-osm_process_towns(FILE *in, FILE *boundaries, FILE *ways, char *suffix)
-{
- struct item_bin *ib;
- GList *bl;
- GHashTable *town_hash;
- FILE *towns_poly;
-
- processed_nodes=processed_nodes_out=processed_ways=processed_relations=processed_tiles=0;
- bytes_read=0;
- sig_alrm(0);
-
- bl=process_boundaries(boundaries, ways);
-
- fprintf(stderr, "Processed boundaries\n");
-
- town_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
- while ((ib=read_item(in))) {
- if (!item_is_district(*ib))
- {
- char *townname=item_bin_get_attr(ib, attr_town_name, NULL);
- char *dup=strdup(townname);
- g_hash_table_replace(town_hash, dup, dup);
- }
- }
- fseek(in, 0, SEEK_SET);
-
- fprintf(stderr, "Finished town table rebuild\n");
-
- while ((ib=read_item(in))) {
- struct coord *c=(struct coord *)(ib+1);
- GList *tc_list, *l;
- struct item_bin *ib_copy=NULL;
-
- processed_nodes++;
-
- tc_list=osm_process_town_by_boundary(bl, ib, c);
- if (!tc_list)
- tc_list=osm_process_town_by_is_in(ib);
-
- if (!tc_list && unknown_country)
- tc_list=osm_process_town_unknown_country();
-
- if (!tc_list) {
- itembin_warning(ib, 0, "Lost town %s %s\n", item_bin_get_attr(ib, attr_town_name, NULL), item_bin_get_attr(ib, attr_district_name, NULL));
- }
-
- if(tc_list && g_list_next(tc_list))
- ib_copy=item_bin_dup(ib);
-
- l=tc_list;
- while(l) {
- struct town_country *tc=l->data;
- char *is_in;
- long long *nodeid;
- char *town_name=NULL;
- int i;
-
- if (!tc->country->file) {
- char *name=g_strdup_printf("country_%d.unsorted.tmp", tc->country->countryid);
- tc->country->file=fopen(name,"wb");
- g_free(name);
- }
-
- if (item_is_district(*ib) && NULL!=(town_name=osm_process_town_get_town_name_from_is_in(ib, town_hash))) {
- struct attr attr_new_town_name;
- attr_new_town_name.type = attr_town_name;
- attr_new_town_name.u.str = town_name;
- item_bin_add_attr(ib, &attr_new_town_name);
- }
-
- if ((is_in=item_bin_get_attr(ib, attr_osm_is_in, NULL))!=NULL)
- item_bin_remove_attr(ib, is_in);
-
- nodeid=item_bin_get_attr(ib, attr_osm_nodeid, NULL);
-
- if (nodeid)
- item_bin_remove_attr(ib, nodeid);
-
- /* Treat district like a town, if we did not find the town it belongs to */
- if (!item_bin_get_attr(ib, attr_town_name, NULL)) {
- char *district_name = item_bin_get_attr(ib, attr_district_name, NULL);
-
- if (district_name) {
- struct attr attr_new_town_name;
- attr_new_town_name.type = attr_town_name;
- attr_new_town_name.u.str = district_name;
-
- item_bin_add_attr(ib, &attr_new_town_name);
- item_bin_remove_attr(ib, district_name);
- }
- }
-
- /* FIXME: preserved from old code, but we'll have to reconsider if we really should drop attribute
- * explicitely set on the town osm node and use an attribute derived from one of its surrounding boundaries. Thus we would
- * use town central district' postal code instead of town one. */
- if (tc->attrs[0].type != attr_none) {
- char *postal=item_bin_get_attr(ib, attr_town_postal, NULL);
- if (postal)
- item_bin_remove_attr(ib, postal);
- }
-
- for (i = 0 ; i < MAX_TOWN_ADMIN_LEVELS ; i++) {
- if (tc->attrs[i].type != attr_none)
- item_bin_add_attr(ib, &tc->attrs[i]);
- }
-
- if(item_bin_get_attr(ib, attr_district_name, NULL))
- item_bin_write_match(ib, attr_district_name, attr_district_name_match, 5, tc->country->file);
- else
- item_bin_write_match(ib, attr_town_name, attr_town_name_match, 5, tc->country->file);
-
- town_country_destroy(tc);
- processed_nodes_out++;
- l=g_list_next(l);
- if(l!=NULL)
- memcpy(ib, ib_copy, (ib_copy->len+1)*4);
- }
- g_free(ib_copy);
- g_list_free(tc_list);
- }
-
- towns_poly=tempfile(suffix,"towns_poly",1);
- osm_town_relations_to_poly(bl, towns_poly);
- fclose(towns_poly);
-
- g_hash_table_destroy(town_hash);
- free_boundaries(bl);
-
- sig_alrm(0);
- sig_alrm_end();
-
- fprintf(stderr, "Finished processing towns\n");
-}
-
-void
-sort_countries(int keep_tmpfiles)
-{
- int i;
- struct country_table *co;
- char *name_in,*name_out;
- for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
- co=&country_table[i];
- if (co->file) {
- fclose(co->file);
- co->file=NULL;
- }
- name_in=g_strdup_printf("country_%d.unsorted.tmp", co->countryid);
- name_out=g_strdup_printf("country_%d.tmp", co->countryid);
- co->r=world_bbox;
- item_bin_sort_file(name_in, name_out, &co->r, &co->size);
- if (!keep_tmpfiles)
- unlink(name_in);
- g_free(name_in);
- g_free(name_out);
- }
+static GList *osm_process_town_by_boundary(GList *bl, struct item_bin *town, struct coord *c) {
+ GList *matches=boundary_find_matches(bl, c);
+ GList *town_country_list=NULL;
+ GList *l;
+
+ for (l=matches; l; l=g_list_next(l)) {
+ struct boundary *match=l->data;
+ if (match->country) {
+ struct town_country *tc=town_country_list_insert_if_new(&town_country_list, match->country);
+ if(tc)
+ osm_process_town_by_boundary_update_attrs(town, tc, matches);
+ }
+ }
+
+ g_list_free(matches);
+
+ return town_country_list;
+}
+
+static void osm_town_relations_to_poly(GList *boundaries, FILE *towns_poly) {
+ while(boundaries) {
+ struct boundary *b=boundaries->data;
+ if(item_is_poly_place(*b->ib)) {
+ GList *s=b->sorted_segments;
+ while(s) {
+ struct geom_poly_segment *seg=s->data;
+ if((seg->type==geom_poly_segment_type_way_outer || seg->type==geom_poly_segment_type_way_unknown)
+ && coord_is_equal(*seg->first,*seg->last)) {
+ struct item_bin *ib=init_item(b->ib->type);
+ void *a;
+ item_bin_add_coord(ib, seg->first, seg->last-seg->first+1);
+ a=osm_tag_value(b->ib, "name");
+ if(a)
+ item_bin_add_attr_string(ib,attr_label,a);
+ a=osm_tag_value(b->ib, "osm_relationid");
+ if(a)
+ item_bin_add_attr_longlong(ib,attr_osm_relationid,atol(a));
+ item_bin_write(ib, towns_poly);
+ }
+ s=g_list_next(s);
+ }
+ }
+ osm_town_relations_to_poly(b->children, towns_poly);
+ boundaries=g_list_next(boundaries);
+ }
+}
+
+
+void osm_process_towns(FILE *in, FILE *boundaries, FILE *ways, char *suffix) {
+ struct item_bin *ib;
+ GList *bl;
+ GHashTable *town_hash;
+ FILE *towns_poly;
+
+ processed_nodes=processed_nodes_out=processed_ways=processed_relations=processed_tiles=0;
+ bytes_read=0;
+ sig_alrm(0);
+
+ bl=process_boundaries(boundaries, ways);
+
+ fprintf(stderr, "Processed boundaries\n");
+
+ town_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+ while ((ib=read_item(in))) {
+ if (!item_is_district(*ib)) {
+ char *townname=item_bin_get_attr(ib, attr_town_name, NULL);
+ char *dup=g_strdup(townname);
+ g_hash_table_replace(town_hash, dup, dup);
+ }
+ }
+ fseek(in, 0, SEEK_SET);
+
+ fprintf(stderr, "Finished town table rebuild\n");
+
+ while ((ib=read_item(in))) {
+ struct coord *c=(struct coord *)(ib+1);
+ GList *tc_list, *l;
+ struct item_bin *ib_copy=NULL;
+
+ processed_nodes++;
+
+ tc_list=osm_process_town_by_boundary(bl, ib, c);
+ if (!tc_list)
+ tc_list=osm_process_town_by_is_in(ib);
+
+ if (!tc_list && unknown_country)
+ tc_list=osm_process_town_unknown_country();
+
+ if (!tc_list) {
+ itembin_warning(ib, 0, "Lost town %s %s\n", item_bin_get_attr(ib, attr_town_name, NULL), item_bin_get_attr(ib,
+ attr_district_name, NULL));
+ }
+
+ if(tc_list && g_list_next(tc_list))
+ ib_copy=item_bin_dup(ib);
+
+ l=tc_list;
+ while(l) {
+ struct town_country *tc=l->data;
+ char *is_in;
+ long long *nodeid;
+ char *town_name=NULL;
+ int i;
+
+ if (!tc->country->file) {
+ char *name=g_strdup_printf("country_%d.unsorted.tmp", tc->country->countryid);
+ tc->country->file=fopen(name,"wb");
+ g_free(name);
+ }
+
+ if (item_is_district(*ib) && NULL!=(town_name=osm_process_town_get_town_name_from_is_in(ib, town_hash))) {
+ struct attr attr_new_town_name;
+ attr_new_town_name.type = attr_town_name;
+ attr_new_town_name.u.str = town_name;
+ item_bin_add_attr(ib, &attr_new_town_name);
+ }
+
+ if ((is_in=item_bin_get_attr(ib, attr_osm_is_in, NULL))!=NULL)
+ item_bin_remove_attr(ib, is_in);
+
+ nodeid=item_bin_get_attr(ib, attr_osm_nodeid, NULL);
+
+ if (nodeid)
+ item_bin_remove_attr(ib, nodeid);
+
+ /* Treat district like a town, if we did not find the town it belongs to */
+ if (!item_bin_get_attr(ib, attr_town_name, NULL)) {
+ char *district_name = item_bin_get_attr(ib, attr_district_name, NULL);
+
+ if (district_name) {
+ struct attr attr_new_town_name;
+ attr_new_town_name.type = attr_town_name;
+ attr_new_town_name.u.str = district_name;
+
+ item_bin_add_attr(ib, &attr_new_town_name);
+ item_bin_remove_attr(ib, district_name);
+ }
+ }
+
+ /* FIXME: preserved from old code, but we'll have to reconsider if we really should drop attribute
+ * explicitely set on the town osm node and use an attribute derived from one of its surrounding boundaries. Thus we would
+ * use town central district' postal code instead of town one. */
+ if (tc->attrs[0].type != attr_none) {
+ char *postal=item_bin_get_attr(ib, attr_town_postal, NULL);
+ if (postal)
+ item_bin_remove_attr(ib, postal);
+ }
+
+ for (i = 0 ; i < MAX_TOWN_ADMIN_LEVELS ; i++) {
+ if (tc->attrs[i].type != attr_none)
+ item_bin_add_attr(ib, &tc->attrs[i]);
+ }
+
+ if(item_bin_get_attr(ib, attr_district_name, NULL))
+ item_bin_write_match(ib, attr_district_name, attr_district_name_match, 5, tc->country->file);
+ else
+ item_bin_write_match(ib, attr_town_name, attr_town_name_match, 5, tc->country->file);
+
+ town_country_destroy(tc);
+ processed_nodes_out++;
+ l=g_list_next(l);
+ if(l!=NULL)
+ memcpy(ib, ib_copy, (ib_copy->len+1)*4);
+ }
+ g_free(ib_copy);
+ g_list_free(tc_list);
+ }
+
+ towns_poly=tempfile(suffix,"towns_poly",1);
+ osm_town_relations_to_poly(bl, towns_poly);
+ fclose(towns_poly);
+
+ g_hash_table_destroy(town_hash);
+ free_boundaries(bl);
+
+ sig_alrm(0);
+ sig_alrm_end();
+
+ fprintf(stderr, "Finished processing towns\n");
+}
+
+void sort_countries(int keep_tmpfiles) {
+ int i;
+ struct country_table *co;
+ char *name_in,*name_out;
+ for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
+ co=&country_table[i];
+ if (co->file) {
+ fclose(co->file);
+ co->file=NULL;
+ }
+ name_in=g_strdup_printf("country_%d.unsorted.tmp", co->countryid);
+ name_out=g_strdup_printf("country_%d.tmp", co->countryid);
+ co->r=world_bbox;
+ item_bin_sort_file(name_in, name_out, &co->r, &co->size);
+ if (!keep_tmpfiles)
+ unlink(name_in);
+ g_free(name_in);
+ g_free(name_out);
+ }
}
struct relation_member {
- enum relation_member_type type;
- long long id;
- char *role;
+ enum relation_member_type type;
+ long long id;
+ char *role;
};
-static void
-parse_relation_member_string(char *relation_member_string, struct relation_member *memb)
-{
- int len;
- int type_numeric;
- sscanf(relation_member_string,RELATION_MEMBER_PARSE_FORMAT,&type_numeric,&memb->id,&len);
- memb->type=(enum relation_member_type)type_numeric;
- memb->role=relation_member_string+len;
-}
-
-static int
-search_relation_member(struct item_bin *ib, char *role, struct relation_member *memb, int *min_count)
-{
- char *str=NULL;
- int count=0;
- while ((str=item_bin_get_attr(ib, attr_osm_member, str))) {
- parse_relation_member_string(str, memb);
- count++;
- if (!strcmp(memb->role, role) && (!min_count || *min_count < count)) {
- if (min_count)
- *min_count=count;
- return 1;
- }
- }
- return 0;
+static void parse_relation_member_string(char *relation_member_string, struct relation_member *memb) {
+ int len;
+ int type_numeric;
+ sscanf(relation_member_string,RELATION_MEMBER_PARSE_FORMAT,&type_numeric,&memb->id,&len);
+ memb->type=(enum relation_member_type)type_numeric;
+ memb->role=relation_member_string+len;
+}
+
+static int search_relation_member(struct item_bin *ib, char *role, struct relation_member *memb, int *min_count) {
+ char *str=NULL;
+ int count=0;
+ while ((str=item_bin_get_attr(ib, attr_osm_member, str))) {
+ parse_relation_member_string(str, memb);
+ count++;
+ if (!g_strcmp0(memb->role, role) && (!min_count || *min_count < count)) {
+ if (min_count)
+ *min_count=count;
+ return 1;
+ }
+ }
+ return 0;
}
#if 0
-static int
-load_way_index(FILE *ways_index, int p, long long *idx)
-{
- int step=sizeof(*idx)*2;
- fseek(ways_index, p*step, SEEK_SET);
- if (fread(idx, step, 1, ways_index) != 1) {
- fprintf(stderr,"read failed\n");
- return 0;
- }
- return 1;
+static int load_way_index(FILE *ways_index, int p, long long *idx) {
+ int step=sizeof(*idx)*2;
+ fseek(ways_index, p*step, SEEK_SET);
+ if (fread(idx, step, 1, ways_index) != 1) {
+ fprintf(stderr,"read failed\n");
+ return 0;
+ }
+ return 1;
}
#endif
#if 0
-static int
-seek_to_way(FILE *way, FILE *ways_index, osmid wayid)
-{
- long offset;
- long long idx[2];
- int count,interval,p;
- if (way_hash) {
- if (!(g_hash_table_lookup_extended(way_hash, (gpointer)(long)wayid, NULL, (gpointer)&offset)))
- return 0;
- fseek(way, offset, SEEK_SET);
- return 1;
- }
- fseek(ways_index, 0, SEEK_END);
- count=ftello(ways_index)/sizeof(idx);
- interval=count/4;
- p=count/2;
- if(interval==0) {
- // If fewer than 4 nodes defined so far set interval to 1 to
- // avoid infinite loop
- interval = 1;
- }
- if (!load_way_index(ways_index, p, idx))
- return 0;
- for (;;) {
- if (idx[0] == wayid) {
- fseek(way, idx[1], SEEK_SET);
- return 1;
- }
- if (idx[0] < wayid) {
- p+=interval;
- if (interval == 1) {
- if (p >= count)
- return 0;
- if (!load_way_index(ways_index, p, idx))
- return 0;
- if (idx[0] > wayid)
- return 0;
- } else {
- if (p >= count)
- p=count-1;
- if (!load_way_index(ways_index, p, idx))
- return 0;
- }
- } else {
- p-=interval;
- if (interval == 1) {
- if (p < 0)
- return 0;
- if (!load_way_index(ways_index, p, idx))
- return 0;
- if (idx[0] < wayid)
- return 0;
- } else {
- if (p < 0)
- p=0;
- if (!load_way_index(ways_index, p, idx))
- return 0;
- }
- }
- if (interval > 1)
- interval/=2;
- }
+static int seek_to_way(FILE *way, FILE *ways_index, osmid wayid) {
+ long offset;
+ long long idx[2];
+ int count,interval,p;
+ if (way_hash) {
+ if (!(g_hash_table_lookup_extended(way_hash, (gpointer)(long)wayid, NULL, (gpointer)&offset)))
+ return 0;
+ fseek(way, offset, SEEK_SET);
+ return 1;
+ }
+ fseek(ways_index, 0, SEEK_END);
+ count=ftello(ways_index)/sizeof(idx);
+ interval=count/4;
+ p=count/2;
+ if(interval==0) {
+ // If fewer than 4 nodes defined so far set interval to 1 to
+ // avoid infinite loop
+ interval = 1;
+ }
+ if (!load_way_index(ways_index, p, idx))
+ return 0;
+ for (;;) {
+ if (idx[0] == wayid) {
+ fseek(way, idx[1], SEEK_SET);
+ return 1;
+ }
+ if (idx[0] < wayid) {
+ p+=interval;
+ if (interval == 1) {
+ if (p >= count)
+ return 0;
+ if (!load_way_index(ways_index, p, idx))
+ return 0;
+ if (idx[0] > wayid)
+ return 0;
+ } else {
+ if (p >= count)
+ p=count-1;
+ if (!load_way_index(ways_index, p, idx))
+ return 0;
+ }
+ } else {
+ p-=interval;
+ if (interval == 1) {
+ if (p < 0)
+ return 0;
+ if (!load_way_index(ways_index, p, idx))
+ return 0;
+ if (idx[0] < wayid)
+ return 0;
+ } else {
+ if (p < 0)
+ p=0;
+ if (!load_way_index(ways_index, p, idx))
+ return 0;
+ }
+ }
+ if (interval > 1)
+ interval/=2;
+ }
}
#endif
#if 0
-static struct coord *
-get_way(FILE *way, FILE *ways_index, struct coord *c, long long wayid, struct item_bin *ret, int debug)
-{
- long long currid;
- int last;
- struct coord *ic;
- if (!seek_to_way(way, ways_index, wayid)) {
- if (debug)
- fprintf(stderr,"not found in index");
- return NULL;
- }
- while (item_bin_read(ret, way)) {
- currid=item_bin_get_wayid(ret);
- if (debug)
- fprintf(stderr,LONGLONG_FMT":",currid);
- if (currid != wayid)
- return NULL;
- ic=(struct coord *)(ret+1);
- last=ret->clen/2-1;
- if (debug)
- fprintf(stderr,"(0x%x,0x%x)-(0x%x,0x%x)",ic[0].x,ic[0].y,ic[last].x,ic[last].y);
- if (!c)
- return &ic[0];
- if (ic[0].x == c->x && ic[0].y == c->y)
- return &ic[last];
- if (ic[last].x == c->x && ic[last].y == c->y)
- return &ic[0];
- }
- return NULL;
+static struct coord *get_way(FILE *way, FILE *ways_index, struct coord *c, long long wayid, struct item_bin *ret,
+ int debug) {
+ long long currid;
+ int last;
+ struct coord *ic;
+ if (!seek_to_way(way, ways_index, wayid)) {
+ if (debug)
+ fprintf(stderr,"not found in index");
+ return NULL;
+ }
+ while (item_bin_read(ret, way)) {
+ currid=item_bin_get_wayid(ret);
+ if (debug)
+ fprintf(stderr,LONGLONG_FMT":",currid);
+ if (currid != wayid)
+ return NULL;
+ ic=(struct coord *)(ret+1);
+ last=ret->clen/2-1;
+ if (debug)
+ fprintf(stderr,"(0x%x,0x%x)-(0x%x,0x%x)",ic[0].x,ic[0].y,ic[last].x,ic[last].y);
+ if (!c)
+ return &ic[0];
+ if (ic[0].x == c->x && ic[0].y == c->y)
+ return &ic[last];
+ if (ic[last].x == c->x && ic[last].y == c->y)
+ return &ic[0];
+ }
+ return NULL;
}
#endif
struct associated_street {
- osmid relid;
- char *name;
+ osmid relid;
+ char *name;
};
struct process_relation_member_func_priv {
- FILE *out;
- GList *allocations;
+ FILE *out;
+ GList *allocations;
};
-static void
-process_associated_street_member(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv_unused)
-{
- struct process_relation_member_func_priv *fp=func_priv;
- struct associated_street *rel=relation_priv;
- if(!fp->out) {
- /* Pass 1, fill associated street names in relation_priv */
- char *name;
- if(!rel->name && item_is_street(*member) && (name=item_bin_get_attr(member,attr_street_name,NULL))!=NULL ) {
- rel->name=g_strdup(name);
- fp->allocations=g_list_prepend(fp->allocations, rel->name);
- }
- } else {
- /* Pass 2, add associated street names to relation members which do not have street name attr defined but
- have house number defined or are streets */
- int type_implies_streetname=item_is_street(*member) ||
- member->type==type_house_number_interpolation_even ||
- member->type==type_house_number_interpolation_odd ||
- member->type==type_house_number_interpolation_all ||
- member->type==type_house_number_interpolation_alphabetic;
- if(rel->name && !item_bin_get_attr(member,attr_street_name,NULL) && (type_implies_streetname || item_bin_get_attr(member,attr_house_number,NULL)))
- item_bin_add_attr_string(member, attr_street_name, rel->name);
- item_bin_write(member,fp->out);
- }
+static void process_associated_street_member(void *func_priv, void *relation_priv, struct item_bin *member,
+ void *member_priv_unused) {
+ struct process_relation_member_func_priv *fp=func_priv;
+ struct associated_street *rel=relation_priv;
+ if(!fp->out) {
+ /* Pass 1, fill associated street names in relation_priv */
+ char *name;
+ if(!rel->name && item_is_street(*member) && (name=item_bin_get_attr(member,attr_street_name,NULL))!=NULL ) {
+ rel->name=g_strdup(name);
+ fp->allocations=g_list_prepend(fp->allocations, rel->name);
+ }
+ } else {
+ /* Pass 2, add associated street names to relation members which do not have street name attr defined but
+ have house number defined or are streets */
+ int type_implies_streetname=item_is_street(*member) ||
+ member->type==type_house_number_interpolation_even ||
+ member->type==type_house_number_interpolation_odd ||
+ member->type==type_house_number_interpolation_all ||
+ member->type==type_house_number_interpolation_alphabetic;
+ if(rel->name && !item_bin_get_attr(member,attr_street_name,NULL) && (type_implies_streetname
+ || item_bin_get_attr(member,attr_house_number,NULL)))
+ item_bin_add_attr_string(member, attr_street_name, rel->name);
+ item_bin_write(member,fp->out);
+ }
}
struct house_number_interpolation {
- osmid wayid;
- char* street_name;
- osmid nodeid_first_node;
- char* house_number_first_node;
- osmid nodeid_last_node;
- char* house_number_last_node;
+ osmid wayid;
+ char* street_name;
+ osmid nodeid_first_node;
+ char* house_number_first_node;
+ osmid nodeid_last_node;
+ char* house_number_last_node;
};
-static void
-process_house_number_interpolation_member(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv_unused)
-{
- struct process_relation_member_func_priv *fp=func_priv;
- struct house_number_interpolation *rel=relation_priv;
- if(!fp->out) {
- /* Pass 1, read street name & house numbers from first & last node.*/
- char *street_name;
- char *house_number;
- if((street_name=item_bin_get_attr(member,attr_street_name,NULL))) {
- rel->street_name=g_strdup(street_name);
- fp->allocations=g_list_prepend(fp->allocations, rel->street_name);
- }
- if ((house_number=item_bin_get_attr(member,attr_house_number,NULL))) {
- osmid* nodeid;
- char *house_number_dup;
- if((nodeid=item_bin_get_attr(member,attr_osm_nodeid,NULL))) {
- house_number_dup=g_strdup(house_number);
- fp->allocations=g_list_prepend(fp->allocations, house_number_dup);
- if (*nodeid==rel->nodeid_first_node){
- rel->house_number_first_node=house_number_dup;
- }else{
- rel->house_number_last_node=house_number_dup;
- }
- }
- }
- } else {
- /* Pass 2, add interpolation information to interpolation ways. */
- enum attr_type attr_for_interpolation = 0;
- switch (member->type){
- case type_house_number_interpolation_even:
- case type_house_number_interpolation_odd:
- attr_for_interpolation = attr_house_number_interpolation_no_ends_incrmt_2;
- break;
- case type_house_number_interpolation_all:
- attr_for_interpolation = attr_house_number_interpolation_no_ends_incrmt_1;
- break;
- default:
- // alphabetic interpolation not (yet) supported
- break;
- }
- if(attr_for_interpolation && rel->street_name){
- item_bin_add_attr_string(member, attr_street_name, rel->street_name);
- char* house_number_from_to = g_strconcat(rel->house_number_first_node, "-", rel->house_number_last_node, NULL);
- fp->allocations=g_list_prepend(fp->allocations, house_number_from_to);
- item_bin_add_attr_string(member, attr_for_interpolation, house_number_from_to);
- }
- item_bin_write(member,fp->out);
- }
-}
-
-static void
-relation_func_writethrough(void *func_priv, void *relation_priv_unused, struct item_bin *member, void *member_priv_unused)
-{
- FILE *out=*(FILE **)func_priv;
- if(out)
- item_bin_write(member,out);
-}
-
-
-static void
-process_associated_streets_setup(FILE *in, struct relations *relations, struct process_relation_member_func_priv *fp)
-{
- struct relation_member relm;
- long long relid;
- struct item_bin *ib;
- struct relations_func *relations_func;
- int min_count;
-
- fseek(in, 0, SEEK_SET);
- relations_func=relations_func_new(process_associated_street_member, fp);
- while ((ib=read_item(in))) {
- char *name=osm_tag_value(ib, "name");
- int namelen=name?strlen(name)+1:0;
- struct associated_street *rel=g_malloc0(sizeof(struct associated_street)+namelen);
- relid=item_bin_get_relationid(ib);
- rel->relid=relid;
- if(name) {
- rel->name=(char*)(rel+1);
- g_strlcpy(rel->name,name,namelen);
- }
- min_count=0;
- while(search_relation_member(ib, "street",&relm,&min_count)) {
- if(relm.type==rel_member_way)
- relations_add_relation_member_entry(relations, relations_func, rel, NULL, relm.type, relm.id);
- }
- min_count=0;
- while(search_relation_member(ib, "house",&relm,&min_count)) {
- relations_add_relation_member_entry(relations, relations_func, rel, NULL, relm.type, relm.id);
- }
- min_count=0;
- while(search_relation_member(ib, "addr:houselink",&relm,&min_count)) {
- relations_add_relation_member_entry(relations, relations_func, rel, NULL, relm.type, relm.id);
- }
- min_count=0;
- while(search_relation_member(ib, "address",&relm,&min_count)) {
- relations_add_relation_member_entry(relations, relations_func, rel, NULL, relm.type, relm.id);
- }
- }
- relations_func=relations_func_new(relation_func_writethrough, &fp->out);
- relations_add_relation_default_entry(relations, relations_func);
-}
-
-void
-process_associated_streets(FILE *in, struct files_relation_processing *files_relproc)
-{
- struct relations *relations=relations_new();
- struct process_relation_member_func_priv fp={NULL,NULL};
- fseek(in, 0, SEEK_SET);
- process_associated_streets_setup(in, relations, &fp);
-
- /* Set noname relations names from their street members */
- fseek(files_relproc->ways_in, 0, SEEK_SET);
- relations_process(relations, NULL, files_relproc->ways_in);
-
- /* Set street names on all members */
- fp.out=files_relproc->ways_out;
- fseek(files_relproc->ways_in, 0, SEEK_SET);
- relations_process(relations, NULL, files_relproc->ways_in);
-
- fp.out=files_relproc->nodes_out;
- fseek(files_relproc->nodes_in, 0, SEEK_SET);
- relations_process(relations, NULL, files_relproc->nodes_in);
-
- if(files_relproc->nodes2_in) {
- fp.out=files_relproc->nodes2_out;
- fseek(files_relproc->nodes2_in, 0, SEEK_SET);
- relations_process(relations, NULL, files_relproc->nodes2_in);
- }
-
- relations_destroy(relations);
- g_list_foreach(fp.allocations, (GFunc)free, NULL);
- g_list_free(fp.allocations);
-}
-
-static void
-process_house_number_interpolations_setup(FILE *in, struct relations *relations, struct process_relation_member_func_priv *fp)
-{
- struct item_bin *ib;
- struct relations_func *relations_func_process_hn_interpol;
-
- fseek(in, 0, SEEK_SET);
- relations_func_process_hn_interpol=relations_func_new(process_house_number_interpolation_member, fp);
- while ((ib=read_item(in))) {
- struct house_number_interpolation *hn_interpol=g_malloc0(sizeof(struct house_number_interpolation));
- hn_interpol->wayid=item_bin_get_wayid(ib);
- hn_interpol->nodeid_first_node=item_bin_get_nodeid_from_attr(ib, attr_osm_nodeid_first_node);
- hn_interpol->nodeid_last_node=item_bin_get_nodeid_from_attr(ib, attr_osm_nodeid_last_node);
- dbg_assert(hn_interpol->wayid && hn_interpol->nodeid_first_node && hn_interpol->nodeid_last_node);
- relations_add_relation_member_entry(relations, relations_func_process_hn_interpol, hn_interpol, NULL, rel_member_node, hn_interpol->nodeid_first_node);
- relations_add_relation_member_entry(relations, relations_func_process_hn_interpol, hn_interpol, NULL, rel_member_node, hn_interpol->nodeid_last_node);
- relations_add_relation_member_entry(relations, relations_func_process_hn_interpol, hn_interpol, NULL, rel_member_way, hn_interpol->wayid);
- }
- relations_add_relation_default_entry(relations, relations_func_new(relation_func_writethrough, &fp->out));
-}
-
-void
-process_house_number_interpolations(FILE *in, struct files_relation_processing *files_relproc) {
- struct relations *relations=relations_new();
- struct process_relation_member_func_priv fp={NULL,NULL};
- fseek(in, 0, SEEK_SET);
- process_house_number_interpolations_setup(in, relations, &fp);
-
- /* Copy house numbers & street names from first/last node to interpolation way. */
- fseek(files_relproc->ways_in, 0, SEEK_SET);
- relations_process(relations, NULL, files_relproc->ways_in);
-
- fseek(files_relproc->nodes_in, 0, SEEK_SET);
- relations_process(relations, NULL, files_relproc->nodes_in);
-
- /* Set street names on all members */
- fp.out=files_relproc->ways_out;
- fseek(files_relproc->ways_in, 0, SEEK_SET);
- relations_process(relations, NULL, files_relproc->ways_in);
-
- fp.out=files_relproc->nodes_out;
- fseek(files_relproc->nodes_in, 0, SEEK_SET);
- relations_process(relations, NULL, files_relproc->nodes_in);
-
- if(files_relproc->nodes2_in) {
- fp.out=files_relproc->nodes2_out;
- fseek(files_relproc->nodes2_in, 0, SEEK_SET);
- relations_process(relations, NULL, files_relproc->nodes2_in);
- }
-
- relations_destroy(relations);
- g_list_foreach(fp.allocations, (GFunc)free, NULL);
- g_list_free(fp.allocations);
+static void process_house_number_interpolation_member(void *func_priv, void *relation_priv, struct item_bin *member,
+ void *member_priv_unused) {
+ struct process_relation_member_func_priv *fp=func_priv;
+ struct house_number_interpolation *rel=relation_priv;
+ if(!fp->out) {
+ /* Pass 1, read street name & house numbers from first & last node.*/
+ char *street_name;
+ char *house_number;
+ if((street_name=item_bin_get_attr(member,attr_street_name,NULL))) {
+ rel->street_name=g_strdup(street_name);
+ fp->allocations=g_list_prepend(fp->allocations, rel->street_name);
+ }
+ if ((house_number=item_bin_get_attr(member,attr_house_number,NULL))) {
+ osmid* nodeid;
+ char *house_number_dup;
+ if((nodeid=item_bin_get_attr(member,attr_osm_nodeid,NULL))) {
+ house_number_dup=g_strdup(house_number);
+ fp->allocations=g_list_prepend(fp->allocations, house_number_dup);
+ if (*nodeid==rel->nodeid_first_node) {
+ rel->house_number_first_node=house_number_dup;
+ } else {
+ rel->house_number_last_node=house_number_dup;
+ }
+ }
+ }
+ } else {
+ /* Pass 2, add interpolation information to interpolation ways. */
+ enum attr_type attr_for_interpolation = 0;
+ switch (member->type) {
+ case type_house_number_interpolation_even:
+ case type_house_number_interpolation_odd:
+ attr_for_interpolation = attr_house_number_interpolation_no_ends_incrmt_2;
+ break;
+ case type_house_number_interpolation_all:
+ attr_for_interpolation = attr_house_number_interpolation_no_ends_incrmt_1;
+ break;
+ default:
+ // alphabetic interpolation not (yet) supported
+ break;
+ }
+ if(attr_for_interpolation && rel->street_name) {
+ item_bin_add_attr_string(member, attr_street_name, rel->street_name);
+ char* house_number_from_to = g_strconcat(rel->house_number_first_node, "-", rel->house_number_last_node, NULL);
+ fp->allocations=g_list_prepend(fp->allocations, house_number_from_to);
+ item_bin_add_attr_string(member, attr_for_interpolation, house_number_from_to);
+ }
+ item_bin_write(member,fp->out);
+ }
+}
+
+static void relation_func_writethrough(void *func_priv, void *relation_priv_unused, struct item_bin *member,
+ void *member_priv_unused) {
+ FILE *out=*(FILE **)func_priv;
+ if(out)
+ item_bin_write(member,out);
+}
+
+
+static void process_associated_streets_setup(FILE *in, struct relations *relations,
+ struct process_relation_member_func_priv *fp) {
+ struct relation_member relm;
+ long long relid;
+ struct item_bin *ib;
+ struct relations_func *relations_func;
+ int min_count;
+
+ fseek(in, 0, SEEK_SET);
+ relations_func=relations_func_new(process_associated_street_member, fp);
+ while ((ib=read_item(in))) {
+ char *name=osm_tag_value(ib, "name");
+ int namelen=name?strlen(name)+1:0;
+ struct associated_street *rel=g_malloc0(sizeof(struct associated_street)+namelen);
+ relid=item_bin_get_relationid(ib);
+ rel->relid=relid;
+ if(name) {
+ rel->name=(char*)(rel+1);
+ g_strlcpy(rel->name,name,namelen);
+ }
+ min_count=0;
+ while(search_relation_member(ib, "street",&relm,&min_count)) {
+ if(relm.type==rel_member_way)
+ relations_add_relation_member_entry(relations, relations_func, rel, NULL, relm.type, relm.id);
+ }
+ min_count=0;
+ while(search_relation_member(ib, "house",&relm,&min_count)) {
+ relations_add_relation_member_entry(relations, relations_func, rel, NULL, relm.type, relm.id);
+ }
+ min_count=0;
+ while(search_relation_member(ib, "addr:houselink",&relm,&min_count)) {
+ relations_add_relation_member_entry(relations, relations_func, rel, NULL, relm.type, relm.id);
+ }
+ min_count=0;
+ while(search_relation_member(ib, "address",&relm,&min_count)) {
+ relations_add_relation_member_entry(relations, relations_func, rel, NULL, relm.type, relm.id);
+ }
+ }
+ relations_func=relations_func_new(relation_func_writethrough, &fp->out);
+ relations_add_relation_default_entry(relations, relations_func);
+}
+
+void process_associated_streets(FILE *in, struct files_relation_processing *files_relproc) {
+ struct relations *relations=relations_new();
+ struct process_relation_member_func_priv fp= {NULL,NULL};
+ fseek(in, 0, SEEK_SET);
+ process_associated_streets_setup(in, relations, &fp);
+
+ /* Set noname relations names from their street members */
+ fseek(files_relproc->ways_in, 0, SEEK_SET);
+ relations_process(relations, NULL, files_relproc->ways_in);
+
+ /* Set street names on all members */
+ fp.out=files_relproc->ways_out;
+ fseek(files_relproc->ways_in, 0, SEEK_SET);
+ relations_process(relations, NULL, files_relproc->ways_in);
+
+ fp.out=files_relproc->nodes_out;
+ fseek(files_relproc->nodes_in, 0, SEEK_SET);
+ relations_process(relations, NULL, files_relproc->nodes_in);
+
+ if(files_relproc->nodes2_in) {
+ fp.out=files_relproc->nodes2_out;
+ fseek(files_relproc->nodes2_in, 0, SEEK_SET);
+ relations_process(relations, NULL, files_relproc->nodes2_in);
+ }
+
+ relations_destroy(relations);
+ g_list_foreach(fp.allocations, (GFunc)free, NULL);
+ g_list_free(fp.allocations);
+}
+
+static void process_house_number_interpolations_setup(FILE *in, struct relations *relations,
+ struct process_relation_member_func_priv *fp) {
+ struct item_bin *ib;
+ struct relations_func *relations_func_process_hn_interpol;
+
+ fseek(in, 0, SEEK_SET);
+ relations_func_process_hn_interpol=relations_func_new(process_house_number_interpolation_member, fp);
+ while ((ib=read_item(in))) {
+ struct house_number_interpolation *hn_interpol=g_malloc0(sizeof(struct house_number_interpolation));
+ hn_interpol->wayid=item_bin_get_wayid(ib);
+ hn_interpol->nodeid_first_node=item_bin_get_nodeid_from_attr(ib, attr_osm_nodeid_first_node);
+ hn_interpol->nodeid_last_node=item_bin_get_nodeid_from_attr(ib, attr_osm_nodeid_last_node);
+ dbg_assert(hn_interpol->wayid && hn_interpol->nodeid_first_node && hn_interpol->nodeid_last_node);
+ relations_add_relation_member_entry(relations, relations_func_process_hn_interpol, hn_interpol, NULL, rel_member_node,
+ hn_interpol->nodeid_first_node);
+ relations_add_relation_member_entry(relations, relations_func_process_hn_interpol, hn_interpol, NULL, rel_member_node,
+ hn_interpol->nodeid_last_node);
+ relations_add_relation_member_entry(relations, relations_func_process_hn_interpol, hn_interpol, NULL, rel_member_way,
+ hn_interpol->wayid);
+ }
+ relations_add_relation_default_entry(relations, relations_func_new(relation_func_writethrough, &fp->out));
+}
+
+void process_house_number_interpolations(FILE *in, struct files_relation_processing *files_relproc) {
+ struct relations *relations=relations_new();
+ struct process_relation_member_func_priv fp= {NULL,NULL};
+ fseek(in, 0, SEEK_SET);
+ process_house_number_interpolations_setup(in, relations, &fp);
+
+ /* Copy house numbers & street names from first/last node to interpolation way. */
+ fseek(files_relproc->ways_in, 0, SEEK_SET);
+ relations_process(relations, NULL, files_relproc->ways_in);
+
+ fseek(files_relproc->nodes_in, 0, SEEK_SET);
+ relations_process(relations, NULL, files_relproc->nodes_in);
+
+ /* Set street names on all members */
+ fp.out=files_relproc->ways_out;
+ fseek(files_relproc->ways_in, 0, SEEK_SET);
+ relations_process(relations, NULL, files_relproc->ways_in);
+
+ fp.out=files_relproc->nodes_out;
+ fseek(files_relproc->nodes_in, 0, SEEK_SET);
+ relations_process(relations, NULL, files_relproc->nodes_in);
+
+ if(files_relproc->nodes2_in) {
+ fp.out=files_relproc->nodes2_out;
+ fseek(files_relproc->nodes2_in, 0, SEEK_SET);
+ relations_process(relations, NULL, files_relproc->nodes2_in);
+ }
+
+ relations_destroy(relations);
+ g_list_foreach(fp.allocations, (GFunc)free, NULL);
+ g_list_free(fp.allocations);
}
struct turn_restriction {
- osmid relid;
- enum item_type type;
- struct coord *c[3];
- int c_count[3];
- struct rect r;
- int order;
+ osmid relid;
+ enum item_type type;
+ struct coord *c[3];
+ int c_count[3];
+ struct rect r;
+ int order;
};
-static void
-process_turn_restrictions_member(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv)
-{
- int i,count,type=(long)member_priv;
- struct turn_restriction *turn_restriction=relation_priv;
- struct coord *c=(struct coord *)(member+1);
- int ccount=member->clen/2;
-
- if (member->type < type_line)
- count=1;
- else
- count=2;
- turn_restriction->c[type]=g_renew(struct coord, turn_restriction->c[type], turn_restriction->c_count[type]+count);
- turn_restriction->c[type][turn_restriction->c_count[type]++]=c[0];
- if (count > 1)
- turn_restriction->c[type][turn_restriction->c_count[type]++]=c[ccount-1];
- if(IS_REF(turn_restriction->r.l)) {
- turn_restriction->r.l=c[0];
- turn_restriction->r.h=c[0];
- i=1;
- } else
- i=0;
- for(;i<ccount;i++)
- bbox_extend(&c[i], &turn_restriction->r);
-
- i=item_order_by_type(member->type);
- if(i<turn_restriction->order)
- turn_restriction->order=i;
-
-}
-
-static void
-process_turn_restrictions_fromto(struct turn_restriction *t, int type, struct coord **c)
-{
- int i,j;
- for (i = 0 ; i < t->c_count[type] ; i+=2) {
- for (j = 0 ; j < t->c_count[1] ; j++) {
- if (coord_is_equal(t->c[type][i],t->c[1][j])) {
- c[0]=&t->c[type][i+1];
- c[1]=&t->c[type][i];
- return;
- }
- if (coord_is_equal(t->c[type][i+1],t->c[1][j])) {
- c[0]=&t->c[type][i];
- c[1]=&t->c[type][i+1];
- return;
- }
- }
- }
-}
-
-static void
-process_turn_restrictions_dump_coord(struct coord *c, int count)
-{
- int i;
- for (i = 0 ; i < count ; i++) {
- fprintf(stderr,"(0x%x,0x%x)",c[i].x,c[i].y);
- }
-}
-
-static void
-process_turn_restrictions_finish(GList *tr, FILE *out)
-{
- GList *l=tr;
- while (l) {
- struct turn_restriction *t=l->data;
- struct coord *c[4]={NULL,NULL,NULL,NULL};
- struct item_bin *ib=tmp_item_bin;
-
- if (!t->c_count[0]) {
- osm_warning("relation",t->relid,0,"turn restriction: from member not found\n");
- } else if (!t->c_count[1]) {
- osm_warning("relation",t->relid,0,"turn restriction: via member not found\n");
- } else if (!t->c_count[2]) {
- osm_warning("relation",t->relid,0,"turn restriction: to member not found\n");
- } else {
- process_turn_restrictions_fromto(t, 0, c);
- process_turn_restrictions_fromto(t, 2, c+2);
- if (!c[0] || !c[2]) {
- osm_warning("relation",t->relid,0,"turn restriction: via (");
- process_turn_restrictions_dump_coord(t->c[1], t->c_count[1]);
- fprintf(stderr,")");
- if (!c[0]) {
- fprintf(stderr," failed to connect to from (");
- process_turn_restrictions_dump_coord(t->c[0], t->c_count[0]);
- fprintf(stderr,")");
- }
- if (!c[2]) {
- fprintf(stderr," failed to connect to to (");
- process_turn_restrictions_dump_coord(t->c[2], t->c_count[2]);
- fprintf(stderr,")");
- }
- fprintf(stderr,"\n");
- } else {
- if (t->c_count[1] <= 2) {
- int order;
- char tilebuf[20]="";
- item_bin_init(ib,t->type);
- item_bin_add_coord(ib, c[0], 1);
- item_bin_add_coord(ib, c[1], 1);
- if (t->c_count[1] > 1)
- item_bin_add_coord(ib, c[3], 1);
- item_bin_add_coord(ib, c[2], 1);
-
- order=tile(&t->r,"",tilebuf,sizeof(tilebuf)-1,overlap,NULL);
- if(order > t->order)
- order=t->order;
- item_bin_add_attr_range(ib,attr_order,0,order);
-
- item_bin_write(ib, out);
- }
-
- }
- }
- g_free(t->c[0]);
- g_free(t->c[1]);
- g_free(t->c[2]);
- g_free(t);
- l=g_list_next(l);
- }
- g_list_free(tr);
-}
-
-static GList *
-process_turn_restrictions_setup(FILE *in, struct relations *relations)
-{
- struct relation_member fromm,tom,viam,tmpm;
- long long relid;
- struct item_bin *ib;
- struct relations_func *relations_func;
- int min_count;
- GList *turn_restrictions=NULL;
-
- fseek(in, 0, SEEK_SET);
- relations_func=relations_func_new(process_turn_restrictions_member, NULL);
- while ((ib=read_item(in))) {
- struct turn_restriction *turn_restriction;
- relid=item_bin_get_relationid(ib);
- min_count=0;
- if (!search_relation_member(ib, "from",&fromm,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: from member missing\n");
- continue;
- }
- if (search_relation_member(ib, "from",&tmpm,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: multiple from members\n");
- continue;
- }
- min_count=0;
- if (!search_relation_member(ib, "to",&tom,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: to member missing\n");
- continue;
- }
- if (search_relation_member(ib, "to",&tmpm,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: multiple to members\n");
- continue;
- }
- min_count=0;
- if (!search_relation_member(ib, "via",&viam,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: via member missing\n");
- continue;
- }
- if (search_relation_member(ib, "via",&tmpm,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: multiple via member\n");
- continue;
- }
- if (fromm.type != rel_member_way) {
- osm_warning("relation",relid,0,"turn restriction: wrong type for from member ");
- osm_warning(osm_types[fromm.type],fromm.id,1,"\n");
- continue;
- }
- if (tom.type != rel_member_way) {
- osm_warning("relation",relid,0,"turn restriction: wrong type for to member ");
- osm_warning(osm_types[tom.type],tom.id,1,"\n");
- continue;
- }
- if (viam.type != rel_member_node && viam.type != rel_member_way) {
- osm_warning("relation",relid,0,"turn restriction: wrong type for via member ");
- osm_warning(osm_types[viam.type],viam.id,1,"\n");
- continue;
- }
- turn_restriction=g_new0(struct turn_restriction, 1);
- turn_restriction->relid=relid;
- turn_restriction->type=ib->type;
- turn_restriction->r.l.x=1<<30;
- turn_restriction->order=255;
- relations_add_relation_member_entry(relations, relations_func, turn_restriction, (gpointer) 0, fromm.type, fromm.id);
- relations_add_relation_member_entry(relations, relations_func, turn_restriction, (gpointer) 1, viam.type, viam.id);
- relations_add_relation_member_entry(relations, relations_func, turn_restriction, (gpointer) 2, tom.type, tom.id);
- turn_restrictions=g_list_append(turn_restrictions, turn_restriction);
- }
- return turn_restrictions;
-}
-
-void
-process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out)
-{
- struct relations *relations=relations_new();
- GList *turn_restrictions;
- fseek(in, 0, SEEK_SET);
- turn_restrictions=process_turn_restrictions_setup(in, relations);
- relations_process(relations, coords, ways);
- process_turn_restrictions_finish(turn_restrictions, out);
- relations_destroy(relations);
+static void process_turn_restrictions_member(void *func_priv, void *relation_priv, struct item_bin *member,
+ void *member_priv) {
+ int i,count,type=(long)member_priv;
+ struct turn_restriction *turn_restriction=relation_priv;
+ struct coord *c=(struct coord *)(member+1);
+ int ccount=member->clen/2;
+
+ if (member->type < type_line)
+ count=1;
+ else
+ count=2;
+ turn_restriction->c[type]=g_renew(struct coord, turn_restriction->c[type], turn_restriction->c_count[type]+count);
+ turn_restriction->c[type][turn_restriction->c_count[type]++]=c[0];
+ if (count > 1)
+ turn_restriction->c[type][turn_restriction->c_count[type]++]=c[ccount-1];
+ if(IS_REF(turn_restriction->r.l)) {
+ turn_restriction->r.l=c[0];
+ turn_restriction->r.h=c[0];
+ i=1;
+ } else
+ i=0;
+ for(; i<ccount; i++)
+ bbox_extend(&c[i], &turn_restriction->r);
+
+ i=item_order_by_type(member->type);
+ if(i<turn_restriction->order)
+ turn_restriction->order=i;
+
+}
+
+static void process_turn_restrictions_fromto(struct turn_restriction *t, int type, struct coord **c) {
+ int i,j;
+ for (i = 0 ; i < t->c_count[type] ; i+=2) {
+ for (j = 0 ; j < t->c_count[1] ; j++) {
+ if (coord_is_equal(t->c[type][i],t->c[1][j])) {
+ c[0]=&t->c[type][i+1];
+ c[1]=&t->c[type][i];
+ return;
+ }
+ if (coord_is_equal(t->c[type][i+1],t->c[1][j])) {
+ c[0]=&t->c[type][i];
+ c[1]=&t->c[type][i+1];
+ return;
+ }
+ }
+ }
+}
+
+static void process_turn_restrictions_dump_coord(struct coord *c, int count) {
+ int i;
+ for (i = 0 ; i < count ; i++) {
+ fprintf(stderr,"(0x%x,0x%x)",c[i].x,c[i].y);
+ }
+}
+
+static void process_turn_restrictions_finish(GList *tr, FILE *out) {
+ GList *l=tr;
+ while (l) {
+ struct turn_restriction *t=l->data;
+ struct coord *c[4]= {NULL,NULL,NULL,NULL};
+ struct item_bin *ib=tmp_item_bin;
+
+ if (!t->c_count[0]) {
+ osm_warning("relation",t->relid,0,"turn restriction: from member not found\n");
+ } else if (!t->c_count[1]) {
+ osm_warning("relation",t->relid,0,"turn restriction: via member not found\n");
+ } else if (!t->c_count[2]) {
+ osm_warning("relation",t->relid,0,"turn restriction: to member not found\n");
+ } else {
+ process_turn_restrictions_fromto(t, 0, c);
+ process_turn_restrictions_fromto(t, 2, c+2);
+ if (!c[0] || !c[2]) {
+ osm_warning("relation",t->relid,0,"turn restriction: via (");
+ process_turn_restrictions_dump_coord(t->c[1], t->c_count[1]);
+ fprintf(stderr,")");
+ if (!c[0]) {
+ fprintf(stderr," failed to connect to from (");
+ process_turn_restrictions_dump_coord(t->c[0], t->c_count[0]);
+ fprintf(stderr,")");
+ }
+ if (!c[2]) {
+ fprintf(stderr," failed to connect to to (");
+ process_turn_restrictions_dump_coord(t->c[2], t->c_count[2]);
+ fprintf(stderr,")");
+ }
+ fprintf(stderr,"\n");
+ } else {
+ if (t->c_count[1] <= 2) {
+ int order;
+ char tilebuf[20]="";
+ item_bin_init(ib,t->type);
+ item_bin_add_coord(ib, c[0], 1);
+ item_bin_add_coord(ib, c[1], 1);
+ if (t->c_count[1] > 1)
+ item_bin_add_coord(ib, c[3], 1);
+ item_bin_add_coord(ib, c[2], 1);
+
+ order=tile(&t->r,"",tilebuf,sizeof(tilebuf)-1,overlap,NULL);
+ if(order > t->order)
+ order=t->order;
+ item_bin_add_attr_range(ib,attr_order,0,order);
+
+ item_bin_write(ib, out);
+ }
+
+ }
+ }
+ g_free(t->c[0]);
+ g_free(t->c[1]);
+ g_free(t->c[2]);
+ g_free(t);
+ l=g_list_next(l);
+ }
+ g_list_free(tr);
+}
+
+static GList *process_turn_restrictions_setup(FILE *in, struct relations *relations) {
+ struct relation_member fromm,tom,viam,tmpm;
+ long long relid;
+ struct item_bin *ib;
+ struct relations_func *relations_func;
+ int min_count;
+ GList *turn_restrictions=NULL;
+
+ fseek(in, 0, SEEK_SET);
+ relations_func=relations_func_new(process_turn_restrictions_member, NULL);
+ while ((ib=read_item(in))) {
+ struct turn_restriction *turn_restriction;
+ relid=item_bin_get_relationid(ib);
+ min_count=0;
+ if (!search_relation_member(ib, "from",&fromm,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: from member missing\n");
+ continue;
+ }
+ if (search_relation_member(ib, "from",&tmpm,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: multiple from members\n");
+ continue;
+ }
+ min_count=0;
+ if (!search_relation_member(ib, "to",&tom,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: to member missing\n");
+ continue;
+ }
+ if (search_relation_member(ib, "to",&tmpm,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: multiple to members\n");
+ continue;
+ }
+ min_count=0;
+ if (!search_relation_member(ib, "via",&viam,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: via member missing\n");
+ continue;
+ }
+ if (search_relation_member(ib, "via",&tmpm,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: multiple via member\n");
+ continue;
+ }
+ if (fromm.type != rel_member_way) {
+ osm_warning("relation",relid,0,"turn restriction: wrong type for from member ");
+ osm_warning(osm_types[fromm.type],fromm.id,1,"\n");
+ continue;
+ }
+ if (tom.type != rel_member_way) {
+ osm_warning("relation",relid,0,"turn restriction: wrong type for to member ");
+ osm_warning(osm_types[tom.type],tom.id,1,"\n");
+ continue;
+ }
+ if (viam.type != rel_member_node && viam.type != rel_member_way) {
+ osm_warning("relation",relid,0,"turn restriction: wrong type for via member ");
+ osm_warning(osm_types[viam.type],viam.id,1,"\n");
+ continue;
+ }
+ turn_restriction=g_new0(struct turn_restriction, 1);
+ turn_restriction->relid=relid;
+ turn_restriction->type=ib->type;
+ turn_restriction->r.l.x=1<<30;
+ turn_restriction->order=255;
+ relations_add_relation_member_entry(relations, relations_func, turn_restriction, (gpointer) 0, fromm.type, fromm.id);
+ relations_add_relation_member_entry(relations, relations_func, turn_restriction, (gpointer) 1, viam.type, viam.id);
+ relations_add_relation_member_entry(relations, relations_func, turn_restriction, (gpointer) 2, tom.type, tom.id);
+ turn_restrictions=g_list_append(turn_restrictions, turn_restriction);
+ }
+ return turn_restrictions;
+}
+
+void process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out) {
+ struct relations *relations=relations_new();
+ GList *turn_restrictions;
+ fseek(in, 0, SEEK_SET);
+ turn_restrictions=process_turn_restrictions_setup(in, relations);
+ relations_process(relations, coords, ways);
+ process_turn_restrictions_finish(turn_restrictions, out);
+ relations_destroy(relations);
}
#if 0
-void
-process_turn_restrictions_old(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out)
-{
- struct relation_member fromm,tom,viam,tmpm;
- struct node_item ni;
- long long relid;
- char from_buffer[65536],to_buffer[65536],via_buffer[65536];
- struct item_bin *ib,*from=(struct item_bin *)from_buffer,*to=(struct item_bin *)to_buffer,*via=(struct item_bin *)via_buffer;
- struct coord *fromc,*toc,*viafrom,*viato,*tmp;
- int min_count;
- while ((ib=read_item(in))) {
- relid=item_bin_get_relationid(ib);
- min_count=0;
- if (!search_relation_member(ib, "from",&fromm,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: from member missing\n");
- continue;
- }
- if (search_relation_member(ib, "from",&tmpm,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: multiple from members\n");
- continue;
- }
- min_count=0;
- if (!search_relation_member(ib, "to",&tom,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: to member missing\n");
- continue;
- }
- if (search_relation_member(ib, "to",&tmpm,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: multiple to members\n");
- continue;
- }
- min_count=0;
- if (!search_relation_member(ib, "via",&viam,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: via member missing\n");
- continue;
- }
- if (search_relation_member(ib, "via",&tmpm,&min_count)) {
- osm_warning("relation",relid,0,"turn restriction: multiple via member\n");
- continue;
- }
- if (fromm.type != 2) {
- osm_warning("relation",relid,0,"turn restriction: wrong type for from member ");
- osm_warning(osm_types[fromm.type],fromm.id,1,"\n");
- continue;
- }
- if (tom.type != 2) {
- osm_warning("relation",relid,0,"turn restriction: wrong type for to member ");
- osm_warning(osm_types[tom.type],tom.id,1,"\n");
- continue;
- }
- if (viam.type != 1 && viam.type != 2) {
- osm_warning("relation",relid,0,"turn restriction: wrong type for via member ");
- osm_warning(osm_types[viam.type],viam.id,1,"\n");
- continue;
- }
- if (viam.type == 1) {
- if (!node_item_get_from_file(coords, viam.id, &ni)) {
- osm_warning("relation",relid,0,"turn restriction: failed to get via member ");
- osm_warning(osm_types[viam.type],viam.id,1,"\n");
- continue;
- }
- viafrom=&ni.c;
- viato=&ni.c;
- } else {
- if (!(viafrom=get_way(ways, ways_index, NULL, viam.id, via, 0))) {
- osm_warning("relation",relid,0,"turn restriction: failed to get first via coordinate from ");
- osm_warning(osm_types[viam.type],viam.id,1,"\n");
- continue;
- }
- if (!(viato=get_way(ways, ways_index, viafrom, viam.id, via, 0))) {
- osm_warning("relation",relid,0,"turn restriction: failed to get last via coordinate from ");
- osm_warning(osm_types[viam.type],viam.id,1,"\n");
- continue;
- }
-
- }
+void process_turn_restrictions_old(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out) {
+ struct relation_member fromm,tom,viam,tmpm;
+ struct node_item ni;
+ long long relid;
+ char from_buffer[65536],to_buffer[65536],via_buffer[65536];
+ struct item_bin *ib,*from=(struct item_bin *)from_buffer,*to=(struct item_bin *)to_buffer,
+ *via=(struct item_bin *)via_buffer;
+ struct coord *fromc,*toc,*viafrom,*viato,*tmp;
+ int min_count;
+ while ((ib=read_item(in))) {
+ relid=item_bin_get_relationid(ib);
+ min_count=0;
+ if (!search_relation_member(ib, "from",&fromm,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: from member missing\n");
+ continue;
+ }
+ if (search_relation_member(ib, "from",&tmpm,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: multiple from members\n");
+ continue;
+ }
+ min_count=0;
+ if (!search_relation_member(ib, "to",&tom,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: to member missing\n");
+ continue;
+ }
+ if (search_relation_member(ib, "to",&tmpm,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: multiple to members\n");
+ continue;
+ }
+ min_count=0;
+ if (!search_relation_member(ib, "via",&viam,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: via member missing\n");
+ continue;
+ }
+ if (search_relation_member(ib, "via",&tmpm,&min_count)) {
+ osm_warning("relation",relid,0,"turn restriction: multiple via member\n");
+ continue;
+ }
+ if (fromm.type != 2) {
+ osm_warning("relation",relid,0,"turn restriction: wrong type for from member ");
+ osm_warning(osm_types[fromm.type],fromm.id,1,"\n");
+ continue;
+ }
+ if (tom.type != 2) {
+ osm_warning("relation",relid,0,"turn restriction: wrong type for to member ");
+ osm_warning(osm_types[tom.type],tom.id,1,"\n");
+ continue;
+ }
+ if (viam.type != 1 && viam.type != 2) {
+ osm_warning("relation",relid,0,"turn restriction: wrong type for via member ");
+ osm_warning(osm_types[viam.type],viam.id,1,"\n");
+ continue;
+ }
+ if (viam.type == 1) {
+ if (!node_item_get_from_file(coords, viam.id, &ni)) {
+ osm_warning("relation",relid,0,"turn restriction: failed to get via member ");
+ osm_warning(osm_types[viam.type],viam.id,1,"\n");
+ continue;
+ }
+ viafrom=&ni.c;
+ viato=&ni.c;
+ } else {
+ if (!(viafrom=get_way(ways, ways_index, NULL, viam.id, via, 0))) {
+ osm_warning("relation",relid,0,"turn restriction: failed to get first via coordinate from ");
+ osm_warning(osm_types[viam.type],viam.id,1,"\n");
+ continue;
+ }
+ if (!(viato=get_way(ways, ways_index, viafrom, viam.id, via, 0))) {
+ osm_warning("relation",relid,0,"turn restriction: failed to get last via coordinate from ");
+ osm_warning(osm_types[viam.type],viam.id,1,"\n");
+ continue;
+ }
+
+ }
#if 0
- fprintf(stderr,"via "LONGLONG_FMT" vs %d\n",viam.id, ni.id);
- fprintf(stderr,"coord 0x%x,0x%x\n",ni.c.x,ni.c.y);
- fprintf(stderr,"Lookup "LONGLONG_FMT"\n",fromm.id);
+ fprintf(stderr,"via "LONGLONG_FMT" vs %d\n",viam.id, ni.id);
+ fprintf(stderr,"coord 0x%x,0x%x\n",ni.c.x,ni.c.y);
+ fprintf(stderr,"Lookup "LONGLONG_FMT"\n",fromm.id);
#endif
- if (!(fromc=get_way(ways, ways_index, viafrom, fromm.id, from, 0))) {
- if (viam.type == 1 || !(fromc=get_way(ways, ways_index, viato, fromm.id, from, 0))) {
- osm_warning("relation",relid,0,"turn restriction: failed to connect via ");
- osm_warning(osm_types[viam.type],viam.id,1," 0x%x,0x%x-0x%x,0x%x to from member ",viafrom->x,viafrom->y,viato->x,viato->y);
- osm_warning(osm_types[fromm.type],fromm.id,1," (");
- get_way(ways, ways_index, viafrom, fromm.id, from, 1);
- fprintf(stderr,")\n");
- continue;
- } else {
- tmp=viato;
- viato=viafrom;
- viafrom=tmp;
- }
- }
- if (!(toc=get_way(ways, ways_index, viato, tom.id, to, 0))) {
- osm_warning("relation",relid,0,"turn restriction: failed to connect via ");
- osm_warning(osm_types[viam.type],viam.id,1," 0x%x,0x%x-0x%x,0x%x to to member ",viafrom->x,viafrom->y,viato->x,viato->y);
- osm_warning(osm_types[tom.type],tom.id,1," (");
- get_way(ways, ways_index, viato, tom.id, to, 1);
- fprintf(stderr,")\n");
- continue;
- }
+ if (!(fromc=get_way(ways, ways_index, viafrom, fromm.id, from, 0))) {
+ if (viam.type == 1 || !(fromc=get_way(ways, ways_index, viato, fromm.id, from, 0))) {
+ osm_warning("relation",relid,0,"turn restriction: failed to connect via ");
+ osm_warning(osm_types[viam.type],viam.id,1," 0x%x,0x%x-0x%x,0x%x to from member ",viafrom->x,viafrom->y,viato->x,
+ viato->y);
+ osm_warning(osm_types[fromm.type],fromm.id,1," (");
+ get_way(ways, ways_index, viafrom, fromm.id, from, 1);
+ fprintf(stderr,")\n");
+ continue;
+ } else {
+ tmp=viato;
+ viato=viafrom;
+ viafrom=tmp;
+ }
+ }
+ if (!(toc=get_way(ways, ways_index, viato, tom.id, to, 0))) {
+ osm_warning("relation",relid,0,"turn restriction: failed to connect via ");
+ osm_warning(osm_types[viam.type],viam.id,1," 0x%x,0x%x-0x%x,0x%x to to member ",viafrom->x,viafrom->y,viato->x,
+ viato->y);
+ osm_warning(osm_types[tom.type],tom.id,1," (");
+ get_way(ways, ways_index, viato, tom.id, to, 1);
+ fprintf(stderr,")\n");
+ continue;
+ }
#if 0
- fprintf(stderr,"(0x%x,0x%x)-(0x%x,0x%x)-(0x%x,0x%x)\n",fromc->x,fromc->y, ni.c.x, ni.c.y, toc->x, toc->y);
+ fprintf(stderr,"(0x%x,0x%x)-(0x%x,0x%x)-(0x%x,0x%x)\n",fromc->x,fromc->y, ni.c.x, ni.c.y, toc->x, toc->y);
#endif
- item_bin_init(ib,ib->type);
- item_bin_add_coord(ib, fromc, 1);
- item_bin_add_coord(ib, viafrom, 1);
- if (viam.type == 2)
- item_bin_add_coord(ib, viato, 1);
- item_bin_add_coord(ib, toc, 1);
- item_bin_write(item_bin, out);
- }
+ item_bin_init(ib,ib->type);
+ item_bin_add_coord(ib, fromc, 1);
+ item_bin_add_coord(ib, viafrom, 1);
+ if (viam.type == 2)
+ item_bin_add_coord(ib, viato, 1);
+ item_bin_add_coord(ib, toc, 1);
+ item_bin_write(item_bin, out);
+ }
}
#endif
#if 0
-static void
-process_countries(FILE *way, FILE *ways_index)
-{
- FILE *in=fopen("country_de.tmp","r");
- struct item_bin *ib;
- char buffer2[400000];
- struct item_bin *ib2=(struct item_bin *)buffer2;
- GList *segments=NULL,*sort_segments;
- fseek(in, 0, SEEK_SET);
- while ((ib=read_item(in))) {
- char *str=NULL;
- struct relation_member member;
- while ((str=item_bin_get_attr(ib, attr_osm_member, str))) {
- if (!parse_relation_member_string(str, &member))
- break;
- if (member.type == 2) {
- if (!seek_to_way(way, ways_index, member.id)) {
- fprintf(stderr,"not found in index");
- break;
- }
- while (item_bin_read(ib2, way)) {
- if (item_bin_get_wayid(ib2) != member.id)
- break;
- segments=g_list_prepend(segments,item_bin_to_poly_segment(ib2, geom_poly_segment_type_way_unknown));
- break;
- }
- }
- }
- }
- sort_segments=geom_poly_segments_sort(segments, geom_poly_segment_type_way_left_side);
- FILE *tmp=fopen("tst.txt","w");
- while (sort_segments) {
- struct geom_poly_segment *seg=sort_segments->data;
- if (!seg) {
- fprintf(stderr,"is null\n");
- } else {
- fprintf(stderr,"segment %p %s area "LONGLONG_FMT"\n",sort_segments,coord_is_equal(*seg->first, *seg->last) ? "closed":"open",geom_poly_area(seg->first,seg->last-seg->first+1));
- }
+static void process_countries(FILE *way, FILE *ways_index) {
+ FILE *in=fopen("country_de.tmp","r");
+ struct item_bin *ib;
+ char buffer2[400000];
+ struct item_bin *ib2=(struct item_bin *)buffer2;
+ GList *segments=NULL,*sort_segments;
+ fseek(in, 0, SEEK_SET);
+ while ((ib=read_item(in))) {
+ char *str=NULL;
+ struct relation_member member;
+ while ((str=item_bin_get_attr(ib, attr_osm_member, str))) {
+ if (!parse_relation_member_string(str, &member))
+ break;
+ if (member.type == 2) {
+ if (!seek_to_way(way, ways_index, member.id)) {
+ fprintf(stderr,"not found in index");
+ break;
+ }
+ while (item_bin_read(ib2, way)) {
+ if (item_bin_get_wayid(ib2) != member.id)
+ break;
+ segments=g_list_prepend(segments,item_bin_to_poly_segment(ib2, geom_poly_segment_type_way_unknown));
+ break;
+ }
+ }
+ }
+ }
+ sort_segments=geom_poly_segments_sort(segments, geom_poly_segment_type_way_left_side);
+ FILE *tmp=fopen("tst.txt","w");
+ while (sort_segments) {
+ struct geom_poly_segment *seg=sort_segments->data;
+ if (!seg) {
+ fprintf(stderr,"is null\n");
+ } else {
+ fprintf(stderr,"segment %p %s area "LONGLONG_FMT"\n",sort_segments,coord_is_equal(*seg->first,
+ *seg->last) ? "closed":"open",geom_poly_area(seg->first,seg->last-seg->first+1));
+ }
#if 0
- int count=seg->last-seg->first+1;
- item_bin_init(ib, type_border_country);
- item_bin_add_coord(ib, seg->first, count);
- item_bin_dump(ib, tmp);
+ int count=seg->last-seg->first+1;
+ item_bin_init(ib, type_border_country);
+ item_bin_add_coord(ib, seg->first, count);
+ item_bin_dump(ib, tmp);
#endif
- sort_segments=g_list_next(sort_segments);
- }
- fclose(tmp);
- fclose(in);
+ sort_segments=g_list_next(sort_segments);
+ }
+ fclose(tmp);
+ fclose(in);
}
#endif
-static void
-node_ref_way(osmid node)
-{
- struct node_item *ni;
- ni=node_item_get(node);
- if (ni)
- ni->ref_way++;
-}
-
-static void
-nodes_ref_item_bin(struct item_bin *ib)
-{
- int i;
- struct coord *c=(struct coord *)(ib+1);
- for (i = 0 ; i < ib->clen/2 ; i++)
- node_ref_way(GET_REF(c[i]));
-}
-
-
-void
-osm_add_nd(osmid ref)
-{
- SET_REF(coord_buffer[coord_count], ref);
- coord_count++;
- if (coord_count > MAX_COORD_COUNT) {
- fprintf(stderr,"ERROR: Overflow - more than %d coordinates in one way.\n", MAX_COORD_COUNT);
- exit(1);
- }
-}
-
-static void
-write_item_way_subsection_index(FILE *out, FILE *out_index, FILE *out_graph, struct item_bin *orig, long long *last_id)
-{
- osmid idx[2];
- idx[0]=item_bin_get_wayid(orig);
- idx[1]=ftello(out);
- if (way_hash) {
- if (!(g_hash_table_lookup_extended(way_hash, (gpointer)(long long)idx[0], NULL, NULL)))
- g_hash_table_insert(way_hash, (gpointer)(long long)idx[0], (gpointer)(long long)idx[1]);
- } else {
- if (!last_id || *last_id != idx[0])
- dbg_assert(fwrite(idx, sizeof(idx), 1, out_index)==1);
- if (last_id)
- *last_id=idx[0];
- }
-}
-
-static void
-write_item_way_subsection(FILE *out, FILE *out_index, FILE *out_graph, struct item_bin *orig, int first, int last, long long *last_id)
-{
- struct item_bin new;
- struct coord *c=(struct coord *)(orig+1);
- char *attr=(char *)(c+orig->clen/2);
- int attr_len=orig->len-orig->clen-2;
- processed_ways++;
- new.type=orig->type;
- new.clen=(last-first+1)*2;
- new.len=new.clen+attr_len+2;
- if (out_index)
- write_item_way_subsection_index(out, out_index, out_graph, orig, last_id);
-#if 0
- fprintf(stderr,"first %d last %d type 0x%x len %d clen %d attr_len %d\n", first, last, new.type, new.len, new.clen, attr_len);
-#endif
- dbg_assert(fwrite(&new, sizeof(new), 1, out)==1);
- dbg_assert(fwrite(c+first, new.clen*4, 1, out)==1);
- dbg_assert(fwrite(attr, attr_len*4, 1, out)==1);
-#if 0
- fwrite(&new, sizeof(new), 1, out_graph);
- fwrite(c+first, new.clen*4, 1, out_graph);
- fwrite(attr, attr_len*4, 1, out_graph);
-#endif
+static void node_ref_way(osmid node) {
+ struct node_item *ni;
+ ni=node_item_get(node);
+ if (ni)
+ ni->ref_way++;
+}
+
+static void nodes_ref_item_bin(struct item_bin *ib) {
+ int i;
+ struct coord *c=(struct coord *)(ib+1);
+ for (i = 0 ; i < ib->clen/2 ; i++)
+ node_ref_way(GET_REF(c[i]));
}
-void
-ref_ways(FILE *in)
-{
- struct item_bin *ib;
- fseek(in, 0, SEEK_SET);
- while ((ib=read_item(in)))
- nodes_ref_item_bin(ib);
+void osm_add_nd(osmid ref) {
+ SET_REF(coord_buffer[coord_count], ref);
+ coord_count++;
+ if (coord_count > MAX_COORD_COUNT) {
+ fprintf(stderr,"ERROR: Overflow - more than %d coordinates in one way.\n", MAX_COORD_COUNT);
+ exit(1);
+ }
}
-void
-resolve_ways(FILE *in, FILE *out)
-{
- struct item_bin *ib;
- struct coord *c;
- int i;
- struct node_item *ni;
+static void write_item_way_subsection_index(FILE *out, FILE *out_index, FILE *out_graph, struct item_bin *orig,
+ long long *last_id) {
+ osmid idx[2];
+ idx[0]=item_bin_get_wayid(orig);
+ idx[1]=ftello(out);
+ if (way_hash) {
+ if (!(g_hash_table_lookup_extended(way_hash, (gpointer)(long long)idx[0], NULL, NULL)))
+ g_hash_table_insert(way_hash, (gpointer)(long long)idx[0], (gpointer)(long long)idx[1]);
+ } else {
+ if (!last_id || *last_id != idx[0])
+ dbg_assert(fwrite(idx, sizeof(idx), 1, out_index)==1);
+ if (last_id)
+ *last_id=idx[0];
+ }
+}
- fseek(in, 0, SEEK_SET);
- while ((ib=read_item(in))) {
- c=(struct coord *)(ib+1);
- for (i = 0 ; i < ib->clen/2 ; i++) {
- if(!IS_REF(c[i]))
- continue;
- ni=node_item_get(GET_REF(c[i]));
- if(ni) {
- c[i].x=ni->c.x;
- c[i].y=ni->c.y;
- }
+static void write_item_way_subsection(FILE *out, FILE *out_index, FILE *out_graph, struct item_bin *orig, int first,
+ int last,
+ long long *last_id) {
+ struct item_bin new;
+ struct coord *c=(struct coord *)(orig+1);
+ char *attr=(char *)(c+orig->clen/2);
+ int attr_len=orig->len-orig->clen-2;
+ processed_ways++;
+ new.type=orig->type;
+ new.clen=(last-first+1)*2;
+ new.len=new.clen+attr_len+2;
+ if (out_index)
+ write_item_way_subsection_index(out, out_index, out_graph, orig, last_id);
+ dbg_assert(fwrite(&new, sizeof(new), 1, out)==1);
+ dbg_assert(fwrite(c+first, new.clen*4, 1, out)==1);
+ dbg_assert(fwrite(attr, attr_len*4, 1, out)==1);
+}
+
+void ref_ways(FILE *in) {
+ struct item_bin *ib;
+
+ fseek(in, 0, SEEK_SET);
+ while ((ib=read_item(in)))
+ nodes_ref_item_bin(ib);
+}
+
+void resolve_ways(FILE *in, FILE *out) {
+ struct item_bin *ib;
+ struct coord *c;
+ int i;
+ struct node_item *ni;
+
+ fseek(in, 0, SEEK_SET);
+ while ((ib=read_item(in))) {
+ c=(struct coord *)(ib+1);
+ for (i = 0 ; i < ib->clen/2 ; i++) {
+ if(!IS_REF(c[i]))
+ continue;
+ ni=node_item_get(GET_REF(c[i]));
+ if(ni) {
+ c[i].x=ni->c.x;
+ c[i].y=ni->c.y;
+ }
- }
- item_bin_write(ib,out);
- }
+ }
+ item_bin_write(ib,out);
+ }
}
/**
@@ -3261,278 +3111,265 @@ resolve_ways(FILE *in, FILE *out)
* @param in type input file original contents type: type_line or type_area
* @returns nothing
*/
-void
-process_way2poi(FILE *in, FILE *out, int type)
-{
- struct item_bin *ib;
- while ((ib=read_item(in))) {
- int count=ib->clen/2;
- if(count>1 && ib->type<type_line) {
- struct coord *c=(struct coord *)(ib+1), c1, c2;
- int done=0;
- if(type==type_area) {
- if(count<3) {
- osm_warning("way",item_bin_get_wayid(ib),0,"Broken polygon, less than 3 points defined\n");
- } else if(!geom_poly_centroid(c, count, &c1)) {
- osm_warning("way",item_bin_get_wayid(ib),0,"Broken polygon, area is 0\n");
- } else {
- if(geom_poly_point_inside(c, count, &c1)) {
- c[0]=c1;
- } else {
- geom_poly_closest_point(c, count, &c1, &c2);
- c[0]=c2;
- }
- done=1;
- }
- }
- if(!done) {
- geom_line_middle(c,count,&c1);
- c[0]=c1;
- }
- write_item_way_subsection(out, NULL, NULL, ib, 0, 0, NULL);
- }
- }
-}
-
-
-int
-map_resolve_coords_and_split_at_intersections(FILE *in, FILE *out, FILE *out_index, FILE *out_graph, FILE *out_coastline, int final)
-{
- struct coord *c;
- int i,ccount,last,remaining;
- osmid ndref;
- struct item_bin *ib;
- struct node_item *ni;
- long long last_id=0;
- processed_nodes=processed_nodes_out=processed_ways=processed_relations=processed_tiles=0;
- sig_alrm(0);
- while ((ib=read_item(in))) {
-#if 0
- fprintf(stderr,"type 0x%x len %d clen %d\n", ib->type, ib->len, ib->clen);
-#endif
- ccount=ib->clen/2;
- if (ccount <= 1)
- continue;
- c=(struct coord *)(ib+1);
- last=0;
- for (i = 0 ; i < ccount ; i++) {
- if (IS_REF(c[i])) {
- ndref=GET_REF(c[i]);
- ni=node_item_get(ndref);
- if (ni) {
- c[i]=ni->c;
- if (ni->ref_way > 1 && i != 0 && i != ccount-1 && i != last && item_get_default_flags(ib->type)) {
- write_item_way_subsection(out, out_index, out_graph, ib, last, i, &last_id);
- last=i;
- }
- } else if (final) {
- osm_warning("way",item_bin_get_wayid(ib),0,"Non-existing reference to ");
- osm_warning("node",ndref,1,"\n");
- remaining=(ib->len+1)*4-sizeof(struct item_bin)-i*sizeof(struct coord);
- memmove(&c[i], &c[i+1], remaining);
- ib->clen-=2;
- ib->len-=2;
- i--;
- ccount--;
- }
- }
- }
- if (ccount) {
- write_item_way_subsection(out, out_index, out_graph, ib, last, ccount-1, &last_id);
- if (final && ib->type == type_water_line && out_coastline) {
- write_item_way_subsection(out_coastline, NULL, NULL, ib, last, ccount-1, NULL);
- }
- }
- }
- sig_alrm(0);
- sig_alrm_end();
- return 0;
-}
-
-static void
-index_country_add(struct zip_info *info, int country_id, char*first_key, char *last_key, char *tile, char *filename, int size, FILE *out)
-{
- struct item_bin *item_bin=init_item(type_countryindex);
- int num=0, zip_num;
- char tilename[32];
-
- do {
- snprintf(tilename,sizeof(tilename),"%ss%d", tile, num);
- num++;
- zip_num=add_aux_tile(info, tilename, filename, size);
- } while (zip_num == -1);
-
- item_bin_add_attr_int(item_bin, attr_country_id, country_id);
-
- if(first_key)
- item_bin_add_attr_string(item_bin, attr_first_key, first_key);
-
- if(last_key)
- item_bin_add_attr_string(item_bin, attr_last_key, last_key);
-
- item_bin_add_attr_int(item_bin, attr_zipfile_ref, zip_num);
- item_bin_write(item_bin, out);
-}
-
-void
-write_countrydir(struct zip_info *zip_info, int max_index_size)
-{
- int i;
- int max=11;
- char filename[32];
- struct country_table *co;
- for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
- co=&country_table[i];
- if(co->size) {
- FILE *in;
- char countrypart[32];
- char partsuffix[32];
- FILE *out=NULL;
- char *outname=NULL;
- int partsize;
- char buffer[50000];
- struct item_bin *ib=(struct item_bin*)buffer;
- int ibsize;
- char tileco[32]="";
- char tileprev[32]="";
- char tilecur[32]="";
- char *countryindexname;
- FILE *countryindex;
- char key[1024]="",first_key[1024]="",last_key[1024]="";
-
- tile(&co->r, "", tileco, max, overlap, NULL);
-
- snprintf(filename,sizeof(filename),"country_%d.tmp", co->countryid);
- in=fopen(filename,"rb");
-
- snprintf(countrypart,sizeof(countrypart),"country_%d_p",co->countryid);
-
- countryindex=tempfile("0",countrypart,1);
- countryindexname=tempfile_name("0",countrypart);
-
- partsize=0;
-
- while(1) {
- int r=item_bin_read(ib,in);
- struct attr_bin *a;
- ibsize=r>0?(ib->len+1)*4 : 0;
- if(ibsize) {
- g_strlcpy(tileprev,tilecur,sizeof(tileprev));
- a=item_bin_get_attr_bin(ib, attr_tile_name, NULL);
- if(a) {
- g_strlcpy(tilecur,(char *)(a+1),sizeof(tilecur));
- item_bin_remove_attr(ib,a+1);
- }
- else
- tilecur[0]=0;
-
- a=item_bin_get_attr_bin_last(ib);
- if(a && ATTR_IS_STRING(a->type))
- g_strlcpy(key,(char *)(a+1),sizeof(key));
- }
-
- /* If output file is already opened, and:
- - we have reached end of input file, or
- - adding new tile would make index part too big, or
- - item just read belongs to a different tile than the previous one,
- then close existing output file, put reference to the country index tile.*/
- if(out && (!r || (partsize && ((partsize+ibsize)>max_index_size)) || strcmp(tileprev,tilecur)) ) {
- partsize=ftello(out);
- fclose(out);
- out=NULL;
- index_country_add(zip_info,co->countryid,first_key,last_key,strlen(tileco)>strlen(tileprev)?tileco:tileprev,outname,partsize,countryindex);
- g_free(outname);
- outname=NULL;
- g_strlcpy(first_key,key,sizeof(first_key));
- }
-
- /* No items left, finish this country index. */
- if(!r)
- break;
-
- /* Open new output file. */
- if(!out) {
- co->nparts++;
- snprintf(partsuffix,sizeof(partsuffix),"%d",co->nparts);
- out=tempfile(partsuffix,countrypart,1);
- outname=tempfile_name(partsuffix,countrypart);
- partsize=0;
- }
-
- item_bin_write(ib,out);
- partsize+=ibsize;
- g_strlcpy(last_key,key,sizeof(last_key));
- }
-
- partsize=ftello(countryindex);
- if(partsize)
- index_country_add(zip_info,co->countryid,NULL,NULL,tileco,countryindexname, partsize, zip_get_index(zip_info));
- fclose(countryindex);
- g_free(countryindexname);
- fclose(in);
- }
- }
-}
-
-void
-load_countries(void)
-{
- char filename[32];
- FILE *f;
- int i;
- struct country_table *co;
-
- for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
- co=&country_table[i];
- sprintf(filename,"country_%d.tmp", co->countryid);
- f=fopen(filename,"rb");
- if (f) {
- int i,first=1;
- struct item_bin *ib;
- while ((ib=read_item(f))) {
- struct coord *c=(struct coord *)(ib+1);
- co->size+=ib->len*4+4;
- for (i = 0 ; i < ib->clen/2 ; i++) {
- if (first) {
- co->r.l=c[i];
- co->r.h=c[i];
- first=0;
- } else
- bbox_extend(&c[i], &co->r);
- }
- }
- fseek(f, 0, SEEK_END);
- co->size=ftello(f);
- fclose(f);
- }
- }
-}
-
-void
-remove_countryfiles(void)
-{
- int i,j;
- char filename[32];
- struct country_table *co;
-
- for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
- co=&country_table[i];
- if (co->size) {
- sprintf(filename,"country_%d.tmp", co->countryid);
- unlink(filename);
- }
- for(j=0; j<=co->nparts;j++) {
- char partsuffix[32];
- sprintf(filename,"country_%d_p", co->countryid);
- sprintf(partsuffix,"%d",j);
- tempfile_unlink(partsuffix,filename);
- }
- }
-}
-
-void osm_init(FILE* rule_file)
-{
- build_attrmap(rule_file);
- build_countrytable();
+void process_way2poi(FILE *in, FILE *out, int type) {
+ struct item_bin *ib;
+ while ((ib=read_item(in))) {
+ int count=ib->clen/2;
+ if(count>1 && ib->type<type_line) {
+ struct coord *c=(struct coord *)(ib+1), c1, c2;
+ int done=0;
+ if(type==type_area) {
+ if(count<3) {
+ osm_warning("way",item_bin_get_wayid(ib),0,"Broken polygon, less than 3 points defined\n");
+ } else if(!geom_poly_centroid(c, count, &c1)) {
+ osm_warning("way",item_bin_get_wayid(ib),0,"Broken polygon, area is 0\n");
+ } else {
+ if(geom_poly_point_inside(c, count, &c1)) {
+ c[0]=c1;
+ } else {
+ geom_poly_closest_point(c, count, &c1, &c2);
+ c[0]=c2;
+ }
+ done=1;
+ }
+ }
+ if(!done) {
+ geom_line_middle(c,count,&c1);
+ c[0]=c1;
+ }
+ write_item_way_subsection(out, NULL, NULL, ib, 0, 0, NULL);
+ }
+ }
+}
+
+
+int map_resolve_coords_and_split_at_intersections(FILE *in, FILE *out, FILE *out_index, FILE *out_graph,
+ FILE *out_coastline, int final) {
+ struct coord *c;
+ int i,ccount,last,remaining;
+ osmid ndref;
+ struct item_bin *ib;
+ struct node_item *ni;
+ long long last_id=0;
+ processed_nodes=processed_nodes_out=processed_ways=processed_relations=processed_tiles=0;
+ sig_alrm(0);
+ while ((ib=read_item(in))) {
+ ccount=ib->clen/2;
+ if (ccount <= 1)
+ continue;
+ c=(struct coord *)(ib+1);
+ last=0;
+ for (i = 0 ; i < ccount ; i++) {
+ if (IS_REF(c[i])) {
+ ndref=GET_REF(c[i]);
+ ni=node_item_get(ndref);
+ if (ni) {
+ c[i]=ni->c;
+ if (ni->ref_way > 1 && i != 0 && i != ccount-1 && i != last && item_get_default_flags(ib->type)) {
+ write_item_way_subsection(out, out_index, out_graph, ib, last, i, &last_id);
+ last=i;
+ }
+ } else if (final) {
+ osm_warning("way",item_bin_get_wayid(ib),0,"Non-existing reference to ");
+ osm_warning("node",ndref,1,"\n");
+ remaining=(ib->len+1)*4-sizeof(struct item_bin)-i*sizeof(struct coord);
+ memmove(&c[i], &c[i+1], remaining);
+ ib->clen-=2;
+ ib->len-=2;
+ i--;
+ ccount--;
+ }
+ }
+ }
+ if (ccount) {
+ write_item_way_subsection(out, out_index, out_graph, ib, last, ccount-1, &last_id);
+ if (final && ib->type == type_water_line && out_coastline) {
+ write_item_way_subsection(out_coastline, NULL, NULL, ib, last, ccount-1, NULL);
+ }
+ }
+ }
+ sig_alrm(0);
+ sig_alrm_end();
+ return 0;
+}
+
+static void index_country_add(struct zip_info *info, int country_id, char*first_key, char *last_key, char *tile,
+ char *filename,
+ int size, FILE *out) {
+ struct item_bin *item_bin=init_item(type_countryindex);
+ int num=0, zip_num;
+ char tilename[32];
+
+ do {
+ snprintf(tilename,sizeof(tilename),"%ss%d", tile, num);
+ num++;
+ zip_num=add_aux_tile(info, tilename, filename, size);
+ } while (zip_num == -1);
+
+ item_bin_add_attr_int(item_bin, attr_country_id, country_id);
+
+ if(first_key)
+ item_bin_add_attr_string(item_bin, attr_first_key, first_key);
+
+ if(last_key)
+ item_bin_add_attr_string(item_bin, attr_last_key, last_key);
+
+ item_bin_add_attr_int(item_bin, attr_zipfile_ref, zip_num);
+ item_bin_write(item_bin, out);
+}
+
+void write_countrydir(struct zip_info *zip_info, int max_index_size) {
+ int i;
+ int max=11;
+ char filename[32];
+ struct country_table *co;
+ for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
+ co=&country_table[i];
+ if(co->size) {
+ FILE *in;
+ char countrypart[32];
+ char partsuffix[32];
+ FILE *out=NULL;
+ char *outname=NULL;
+ int partsize;
+ char buffer[50000];
+ struct item_bin *ib=(struct item_bin*)buffer;
+ int ibsize;
+ char tileco[32]="";
+ char tileprev[32]="";
+ char tilecur[32]="";
+ char *countryindexname;
+ FILE *countryindex;
+ char key[1024]="",first_key[1024]="",last_key[1024]="";
+
+ tile(&co->r, "", tileco, max, overlap, NULL);
+
+ snprintf(filename,sizeof(filename),"country_%d.tmp", co->countryid);
+ in=fopen(filename,"rb");
+
+ snprintf(countrypart,sizeof(countrypart),"country_%d_p",co->countryid);
+
+ countryindex=tempfile("0",countrypart,1);
+ countryindexname=tempfile_name("0",countrypart);
+
+ partsize=0;
+
+ while(1) {
+ int r=item_bin_read(ib,in);
+ struct attr_bin *a;
+ ibsize=r>0?(ib->len+1)*4 : 0;
+ if(ibsize) {
+ g_strlcpy(tileprev,tilecur,sizeof(tileprev));
+ a=item_bin_get_attr_bin(ib, attr_tile_name, NULL);
+ if(a) {
+ g_strlcpy(tilecur,(char *)(a+1),sizeof(tilecur));
+ item_bin_remove_attr(ib,a+1);
+ } else
+ tilecur[0]=0;
+
+ a=item_bin_get_attr_bin_last(ib);
+ if(a && ATTR_IS_STRING(a->type))
+ g_strlcpy(key,(char *)(a+1),sizeof(key));
+ }
+
+ /* If output file is already opened, and:
+ - we have reached end of input file, or
+ - adding new tile would make index part too big, or
+ - item just read belongs to a different tile than the previous one,
+ then close existing output file, put reference to the country index tile.*/
+ if(out && (!r || (partsize && ((partsize+ibsize)>max_index_size)) || g_strcmp0(tileprev,tilecur)) ) {
+ partsize=ftello(out);
+ fclose(out);
+ out=NULL;
+ index_country_add(zip_info,co->countryid,first_key,last_key,strlen(tileco)>strlen(tileprev)?tileco:tileprev,outname,
+ partsize,countryindex);
+ g_free(outname);
+ outname=NULL;
+ g_strlcpy(first_key,key,sizeof(first_key));
+ }
+
+ /* No items left, finish this country index. */
+ if(!r)
+ break;
+
+ /* Open new output file. */
+ if(!out) {
+ co->nparts++;
+ snprintf(partsuffix,sizeof(partsuffix),"%d",co->nparts);
+ out=tempfile(partsuffix,countrypart,1);
+ outname=tempfile_name(partsuffix,countrypart);
+ partsize=0;
+ }
+
+ item_bin_write(ib,out);
+ partsize+=ibsize;
+ g_strlcpy(last_key,key,sizeof(last_key));
+ }
+
+ partsize=ftello(countryindex);
+ if(partsize)
+ index_country_add(zip_info,co->countryid,NULL,NULL,tileco,countryindexname, partsize, zip_get_index(zip_info));
+ fclose(countryindex);
+ g_free(countryindexname);
+ fclose(in);
+ }
+ }
+}
+
+void load_countries(void) {
+ char filename[32];
+ FILE *f;
+ int i;
+ struct country_table *co;
+
+ for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
+ co=&country_table[i];
+ sprintf(filename,"country_%d.tmp", co->countryid);
+ f=fopen(filename,"rb");
+ if (f) {
+ int i,first=1;
+ struct item_bin *ib;
+ while ((ib=read_item(f))) {
+ struct coord *c=(struct coord *)(ib+1);
+ co->size+=ib->len*4+4;
+ for (i = 0 ; i < ib->clen/2 ; i++) {
+ if (first) {
+ co->r.l=c[i];
+ co->r.h=c[i];
+ first=0;
+ } else
+ bbox_extend(&c[i], &co->r);
+ }
+ }
+ fseek(f, 0, SEEK_END);
+ co->size=ftello(f);
+ fclose(f);
+ }
+ }
+}
+
+void remove_countryfiles(void) {
+ int i,j;
+ char filename[32];
+ struct country_table *co;
+
+ for (i = 0 ; i < sizeof(country_table)/sizeof(struct country_table) ; i++) {
+ co=&country_table[i];
+ if (co->size) {
+ sprintf(filename,"country_%d.tmp", co->countryid);
+ unlink(filename);
+ }
+ for(j=0; j<=co->nparts; j++) {
+ char partsuffix[32];
+ sprintf(filename,"country_%d_p", co->countryid);
+ sprintf(partsuffix,"%d",j);
+ tempfile_unlink(partsuffix,filename);
+ }
+ }
+}
+
+void osm_init(FILE* rule_file) {
+ build_attrmap(rule_file);
+ build_countrytable();
}
diff --git a/navit/maptool/osm_o5m.c b/navit/maptool/osm_o5m.c
index d6957067d..df64358e6 100644
--- a/navit/maptool/osm_o5m.c
+++ b/navit/maptool/osm_o5m.c
@@ -5,348 +5,326 @@
static int print;
-static char *types[]={"node","way","relation"};
+static char *types[]= {"node","way","relation"};
struct o5m {
- unsigned char buffer[65536*2];
- int buffer_size;
- unsigned char *buffer_start;
- unsigned char *buffer_end;
- FILE *in;
- int error;
+ unsigned char buffer[65536*2];
+ int buffer_size;
+ unsigned char *buffer_start;
+ unsigned char *buffer_end;
+ FILE *in;
+ int error;
- int lat, lon, uid, version;
- unsigned long long id, rid[3], changeset;
- time_t timestamp;
- char *user;
+ int lat, lon, uid, version;
+ unsigned long long id, rid[3], changeset;
+ time_t timestamp;
+ char *user;
};
static struct string_table {
- char strings[15000][256];
- int pos;
+ char strings[15000][256];
+ int pos;
} st;
static double latlon_scale=10000000.0;
#define buffer_end(o,x) ((o)->buffer_start+(x) > (o)->buffer_end && !fill_buffer((o), (x)))
-static int
-fill_buffer(struct o5m *o, int min)
-{
- int count;
+static int fill_buffer(struct o5m *o, int min) {
+ int count;
- memmove(o->buffer, o->buffer_start, o->buffer_end-o->buffer_start);
- o->buffer_end-=o->buffer_start-o->buffer;
- o->buffer_start=o->buffer;
- count=fread(o->buffer_end, 1, o->buffer+o->buffer_size-o->buffer_end, o->in);
- if (!count)
- return 0;
- o->buffer_end+=count;
- return (min <= o->buffer_end - o->buffer);
+ memmove(o->buffer, o->buffer_start, o->buffer_end-o->buffer_start);
+ o->buffer_end-=o->buffer_start-o->buffer;
+ o->buffer_start=o->buffer;
+ count=fread(o->buffer_end, 1, o->buffer+o->buffer_size-o->buffer_end, o->in);
+ if (!count)
+ return 0;
+ o->buffer_end+=count;
+ return (min <= o->buffer_end - o->buffer);
}
-static unsigned long long
-get_uval(unsigned char **p)
-{
- unsigned char c;
- unsigned long long ret=0;
- int shift=0;
+static unsigned long long get_uval(unsigned char **p) {
+ unsigned char c;
+ unsigned long long ret=0;
+ int shift=0;
- for (;;) {
- c=*((*p)++);
- ret+=((unsigned long long)c & 0x7f) << shift;
- if (!(c & 0x80))
- return ret;
- shift+=7;
- }
+ for (;;) {
+ c=*((*p)++);
+ ret+=((unsigned long long)c & 0x7f) << shift;
+ if (!(c & 0x80))
+ return ret;
+ shift+=7;
+ }
}
-static long long
-get_sval(unsigned char **p)
-{
- unsigned long long ret=get_uval(p);
- if (ret & 1) {
- return -((long long)(ret >> 1)+1);
- } else {
- return ret >> 1;
- }
+static long long get_sval(unsigned char **p) {
+ unsigned long long ret=get_uval(p);
+ if (ret & 1) {
+ return -((long long)(ret >> 1)+1);
+ } else {
+ return ret >> 1;
+ }
}
-static void
-get_strings(struct string_table *st, unsigned char **p, char **s1, char **s2)
-{
- int len,xlen=0;
- *s1=(char *)*p;
- len=strlen(*s1);
- xlen=1;
- if (s2) {
- *s2=*s1+len+1;
- len+=strlen(*s2);
- xlen++;
- }
- (*p)+=len+xlen;
- if (len <= 250) {
- memcpy(st->strings[st->pos++], *s1, len+xlen);
- if (st->pos >= 15000)
- st->pos=0;
- }
+static void get_strings(struct string_table *st, unsigned char **p, char **s1, char **s2) {
+ int len,xlen=0;
+ *s1=(char *)*p;
+ len=strlen(*s1);
+ xlen=1;
+ if (s2) {
+ *s2=*s1+len+1;
+ len+=strlen(*s2);
+ xlen++;
+ }
+ (*p)+=len+xlen;
+ if (len <= 250) {
+ memcpy(st->strings[st->pos++], *s1, len+xlen);
+ if (st->pos >= 15000)
+ st->pos=0;
+ }
}
-static void
-get_strings_ref(struct string_table *st, int ref, char **s1, char **s2)
-{
- int pos=st->pos-ref;
-
- if (pos < 0)
- pos+=15000;
- *s1=st->strings[pos];
- if (s2)
- *s2=*s1+strlen(*s1)+1;
+static void get_strings_ref(struct string_table *st, int ref, char **s1, char **s2) {
+ int pos=st->pos-ref;
+
+ if (pos < 0)
+ pos+=15000;
+ *s1=st->strings[pos];
+ if (s2)
+ *s2=*s1+strlen(*s1)+1;
}
-static void
-print_escaped(char *s)
-{
- for (;;) {
- switch (*s) {
- case 0:
- return;
- case 9:
- case 13:
- case 34:
- case 38:
- case 39:
- case 60:
- case 62:
- printf("&#%d;",*s);
- break;
- default:
- putc(*s,stdout);
- break;
- }
- s++;
- }
+static void print_escaped(char *s) {
+ for (;;) {
+ switch (*s) {
+ case 0:
+ return;
+ case 9:
+ case 13:
+ case 34:
+ case 38:
+ case 39:
+ case 60:
+ case 62:
+ printf("&#%d;",*s);
+ break;
+ default:
+ putc(*s,stdout);
+ break;
+ }
+ s++;
+ }
}
-static void
-o5m_reset(struct o5m *o)
-{
- o->lat=0;
- o->lon=0;
- o->id=0;
- o->rid[0]=0;
- o->rid[1]=0;
- o->rid[2]=0;
- o->changeset=0;
- o->timestamp=0;
+static void o5m_reset(struct o5m *o) {
+ o->lat=0;
+ o->lon=0;
+ o->id=0;
+ o->rid[0]=0;
+ o->rid[1]=0;
+ o->rid[2]=0;
+ o->changeset=0;
+ o->timestamp=0;
}
-static void
-o5m_print_start(struct o5m *o, int c)
-{
- printf("\t<%s id=\""LONGLONG_FMT"\"",types[c-0x10],o->id);
+static void o5m_print_start(struct o5m *o, int c) {
+ printf("\t<%s id=\""LONGLONG_FMT"\"",types[c-0x10],o->id);
}
-static void
-o5m_print_version(struct o5m *o, int tags)
-{
- char timestamp_str[64];
- if (o->version) {
- strftime(timestamp_str, sizeof(timestamp_str), "%Y-%m-%dT%H:%M:%SZ", gmtime(&o->timestamp));
- printf(" version=\"%d\" timestamp=\"%s\" changeset=\""LONGLONG_FMT"\"",o->version,timestamp_str,o->changeset);
- if (o->uid) {
- printf(" uid=\"%d\" user=\"",o->uid);
- print_escaped(o->user);
- printf("\"");
- }
- }
- printf("%s\n",tags?">":"/>");
+static void o5m_print_version(struct o5m *o, int tags) {
+ char timestamp_str[64];
+ if (o->version) {
+ strftime(timestamp_str, sizeof(timestamp_str), "%Y-%m-%dT%H:%M:%SZ", gmtime(&o->timestamp));
+ printf(" version=\"%d\" timestamp=\"%s\" changeset=\""LONGLONG_FMT"\"",o->version,timestamp_str,o->changeset);
+ if (o->uid) {
+ printf(" uid=\"%d\" user=\"",o->uid);
+ print_escaped(o->user);
+ printf("\"");
+ }
+ }
+ printf("%s\n",tags?">":"/>");
}
-static void
-o5m_print_end(char c)
-{
- printf("\t</%s>\n",types[c-0x10]);
+static void o5m_print_end(char c) {
+ printf("\t</%s>\n",types[c-0x10]);
}
-int
-map_collect_data_osm_o5m(FILE *in, struct maptool_osm *osm)
-{
- struct o5m o;
- unsigned char c, *end, *rend;
- int len, rlen, ref, tags;
- char *uidstr, *role;
+int map_collect_data_osm_o5m(FILE *in, struct maptool_osm *osm) {
+ struct o5m o;
+ unsigned char c, *end, *rend;
+ int len, rlen, ref, tags;
+ char *uidstr, *role;
+
+ if (print) {
+ printf("<?xml version='1.0' encoding='UTF-8'?>\n");
+ printf("<osm version=\"0.6\" generator=\"osmconvert 0.1X6\">\n");
+ }
- if (print) {
- printf("<?xml version='1.0' encoding='UTF-8'?>\n");
- printf("<osm version=\"0.6\" generator=\"osmconvert 0.1X6\">\n");
- }
+ o5m_reset(&o);
+ o.buffer_size=sizeof(o.buffer);
+ o.buffer_start=o.buffer;
+ o.buffer_end=o.buffer;
+ o.error=0;
+ o.in=in;
- o5m_reset(&o);
- o.buffer_size=sizeof(o.buffer);
- o.buffer_start=o.buffer;
- o.buffer_end=o.buffer;
- o.error=0;
- o.in=in;
-
- fill_buffer(&o,1);
- for (;;) {
- if (buffer_end(&o, 1)) {
- fprintf(stderr,"unexpected eof\n");
- return 1;
- }
- c=*(o.buffer_start++);
- switch (c) {
- case 0x10:
- case 0x11:
- case 0x12:
- (void)buffer_end(&o, 4);
- len=get_uval(&o.buffer_start);
- if (o.buffer_start > o.buffer_end) {
- fprintf(stderr,"unexpected eof\n");
- return 0;
- }
- if (buffer_end(&o, len)) {
- fprintf(stderr,"unexpected eof or buffer too small, item type %d, item size %d\n", c, len);
- return 0;
- }
- end=o.buffer_start+len;
- o.id+=get_sval(&o.buffer_start);
- o.version=get_uval(&o.buffer_start);
- if (o.version) {
- o.timestamp+=get_sval(&o.buffer_start);
- if (o.timestamp) {
- o.changeset+=get_sval(&o.buffer_start);
- ref=get_uval(&o.buffer_start);
- if (ref)
- get_strings_ref(&st, ref, &uidstr, &o.user);
- else
- get_strings(&st, &o.buffer_start, &uidstr, &o.user);
- o.uid=get_uval((unsigned char **)&uidstr);
- }
- }
- if (print)
- o5m_print_start(&o, c);
- switch (c) {
- case 0x10:
- o.lon+=get_sval(&o.buffer_start);
- o.lat+=get_sval(&o.buffer_start);
- osm_add_node(o.id, o.lat/latlon_scale,o.lon/latlon_scale);
- tags=end > o.buffer_start;
- if (print) {
- printf(" lat=\"%.7f\" lon=\"%.7f\"",o.lat/10000000.0,o.lon/10000000.0);
- o5m_print_version(&o, tags);
- }
- break;
- case 0x11:
- osm_add_way(o.id);
- rlen=get_uval(&o.buffer_start);
- tags=end > o.buffer_start;
- rend=o.buffer_start+rlen;
- if (print)
- o5m_print_version(&o, tags);
- while (o.buffer_start < rend) {
- o.rid[0]+=get_sval(&o.buffer_start);
- osm_add_nd(o.rid[0]);
- if (print)
- printf("\t\t<nd ref=\""LONGLONG_FMT"\"/>\n",o.rid[0]);
- }
- break;
- case 0x12:
- osm_add_relation(o.id);
- rlen=get_uval(&o.buffer_start);
- tags=end > o.buffer_start;
- rend=o.buffer_start+rlen;
- if (print)
- o5m_print_version(&o, tags);
- while (o.buffer_start < rend) {
- long long delta=get_sval(&o.buffer_start);
- int r;
- ref=get_uval(&o.buffer_start);
- if (ref)
- get_strings_ref(&st, ref, &role, NULL);
- else
- get_strings(&st, &o.buffer_start, &role, NULL);
- r=role[0]-'0';
- if (r < 0)
- r=0;
- if (r > 2)
- r=2;
- o.rid[r]+=delta;
- osm_add_member(r+1, o.rid[r], role+1);
- if (print)
- printf("\t\t<member type=\"%s\" ref=\""LONGLONG_FMT"\" role=\"%s\"/>\n",types[r], o.rid[r], role+1);
- }
- break;
- }
- while (end > o.buffer_start) {
- char *k, *v;
- ref=get_uval(&o.buffer_start);
- if (ref)
- get_strings_ref(&st, ref, &k, &v);
- else
- get_strings(&st, &o.buffer_start, &k, &v);
- osm_add_tag(k, v);
- if (print) {
- printf("\t\t<tag k=\"");
- print_escaped(k);
- printf("\" v=\"");
- print_escaped(v);
- printf("\"/>\n");
- }
- }
- if (print && tags) {
- o5m_print_end(c);
- }
- switch (c) {
- case 0x10:
- osm_end_node(osm);
- break;
- case 0x11:
- osm_end_way(osm);
- break;
- case 0x12:
- osm_end_relation(osm);
- break;
- }
- break;
- case 0xdb:
- if (print)
- printf("\t<bounds minlat=\"-180.0000000\" minlon=\"-90.0000000\" maxlat=\"180.0000000\" maxlon=\"90.0000000\"/>\n");
- len=get_uval(&o.buffer_start);
- if (o.buffer_start > o.buffer_end) {
- return 0;
- }
- if (buffer_end(&o, len)) {
- return 0;
- }
- o.buffer_start+=len;
- break;
- case 0xe0:
- if (buffer_end(&o, 5))
- return 0;
- o.buffer_start+=5;
- break;
- case 0xfe:
- return 1;
- case 0xff:
- o5m_reset(&o);
- break;
- default:
- fprintf(stderr,"Unknown tag 0x%x\n",c);
- /* Fall through */
- case 0xdc: /* File timestamp: silently ignore it */
- len=get_uval(&o.buffer_start);
- if (o.buffer_start > o.buffer_end) {
- return 0;
- }
- if (buffer_end(&o, len)) {
- return 0;
- }
- o.buffer_start+=len;
- break;
- }
- }
- return 0;
+ fill_buffer(&o,1);
+ for (;;) {
+ if (buffer_end(&o, 1)) {
+ fprintf(stderr,"unexpected eof\n");
+ return 1;
+ }
+ c=*(o.buffer_start++);
+ switch (c) {
+ case 0x10:
+ case 0x11:
+ case 0x12:
+ (void)buffer_end(&o, 4);
+ len=get_uval(&o.buffer_start);
+ if (o.buffer_start > o.buffer_end) {
+ fprintf(stderr,"unexpected eof\n");
+ return 0;
+ }
+ if (buffer_end(&o, len)) {
+ fprintf(stderr,"unexpected eof or buffer too small, item type %d, item size %d\n", c, len);
+ return 0;
+ }
+ end=o.buffer_start+len;
+ o.id+=get_sval(&o.buffer_start);
+ o.version=get_uval(&o.buffer_start);
+ if (o.version) {
+ o.timestamp+=get_sval(&o.buffer_start);
+ if (o.timestamp) {
+ o.changeset+=get_sval(&o.buffer_start);
+ ref=get_uval(&o.buffer_start);
+ if (ref)
+ get_strings_ref(&st, ref, &uidstr, &o.user);
+ else
+ get_strings(&st, &o.buffer_start, &uidstr, &o.user);
+ o.uid=get_uval((unsigned char **)&uidstr);
+ }
+ }
+ if (print)
+ o5m_print_start(&o, c);
+ switch (c) {
+ case 0x10:
+ o.lon+=get_sval(&o.buffer_start);
+ o.lat+=get_sval(&o.buffer_start);
+ osm_add_node(o.id, o.lat/latlon_scale,o.lon/latlon_scale);
+ tags=end > o.buffer_start;
+ if (print) {
+ printf(" lat=\"%.7f\" lon=\"%.7f\"",o.lat/10000000.0,o.lon/10000000.0);
+ o5m_print_version(&o, tags);
+ }
+ break;
+ case 0x11:
+ osm_add_way(o.id);
+ rlen=get_uval(&o.buffer_start);
+ tags=end > o.buffer_start;
+ rend=o.buffer_start+rlen;
+ if (print)
+ o5m_print_version(&o, tags);
+ while (o.buffer_start < rend) {
+ o.rid[0]+=get_sval(&o.buffer_start);
+ osm_add_nd(o.rid[0]);
+ if (print)
+ printf("\t\t<nd ref=\""LONGLONG_FMT"\"/>\n",o.rid[0]);
+ }
+ break;
+ case 0x12:
+ osm_add_relation(o.id);
+ rlen=get_uval(&o.buffer_start);
+ tags=end > o.buffer_start;
+ rend=o.buffer_start+rlen;
+ if (print)
+ o5m_print_version(&o, tags);
+ while (o.buffer_start < rend) {
+ long long delta=get_sval(&o.buffer_start);
+ int r;
+ ref=get_uval(&o.buffer_start);
+ if (ref)
+ get_strings_ref(&st, ref, &role, NULL);
+ else
+ get_strings(&st, &o.buffer_start, &role, NULL);
+ r=role[0]-'0';
+ if (r < 0)
+ r=0;
+ if (r > 2)
+ r=2;
+ o.rid[r]+=delta;
+ osm_add_member(r+1, o.rid[r], role+1);
+ if (print)
+ printf("\t\t<member type=\"%s\" ref=\""LONGLONG_FMT"\" role=\"%s\"/>\n",types[r], o.rid[r], role+1);
+ }
+ break;
+ }
+ while (end > o.buffer_start) {
+ char *k, *v;
+ ref=get_uval(&o.buffer_start);
+ if (ref)
+ get_strings_ref(&st, ref, &k, &v);
+ else
+ get_strings(&st, &o.buffer_start, &k, &v);
+ osm_add_tag(k, v);
+ if (print) {
+ printf("\t\t<tag k=\"");
+ print_escaped(k);
+ printf("\" v=\"");
+ print_escaped(v);
+ printf("\"/>\n");
+ }
+ }
+ if (print && tags) {
+ o5m_print_end(c);
+ }
+ switch (c) {
+ case 0x10:
+ osm_end_node(osm);
+ break;
+ case 0x11:
+ osm_end_way(osm);
+ break;
+ case 0x12:
+ osm_end_relation(osm);
+ break;
+ }
+ break;
+ case 0xdb:
+ if (print)
+ printf("\t<bounds minlat=\"-180.0000000\" minlon=\"-90.0000000\" maxlat=\"180.0000000\" maxlon=\"90.0000000\"/>\n");
+ len=get_uval(&o.buffer_start);
+ if (o.buffer_start > o.buffer_end) {
+ return 0;
+ }
+ if (buffer_end(&o, len)) {
+ return 0;
+ }
+ o.buffer_start+=len;
+ break;
+ case 0xe0:
+ if (buffer_end(&o, 5))
+ return 0;
+ o.buffer_start+=5;
+ break;
+ case 0xfe:
+ return 1;
+ case 0xff:
+ o5m_reset(&o);
+ break;
+ default:
+ fprintf(stderr,"Unknown tag 0x%x\n",c);
+ /* Fall through */
+ case 0xdc: /* File timestamp: silently ignore it */
+ len=get_uval(&o.buffer_start);
+ if (o.buffer_start > o.buffer_end) {
+ return 0;
+ }
+ if (buffer_end(&o, len)) {
+ return 0;
+ }
+ o.buffer_start+=len;
+ break;
+ }
+ }
+ return 0;
}
diff --git a/navit/maptool/osm_protobuf.c b/navit/maptool/osm_protobuf.c
index b6eb5f2ca..4f71010e4 100644
--- a/navit/maptool/osm_protobuf.c
+++ b/navit/maptool/osm_protobuf.c
@@ -26,8 +26,8 @@
#include "debug.h"
#include "linguistics.h"
#include "file.h"
-#include "generated-code/fileformat.pb-c.h"
-#include "generated-code/osmformat.pb-c.h"
+#include "fileformat.pb-c.h"
+#include "osmformat.pb-c.h"
static double latlon_scale=10000000.0;
@@ -46,340 +46,240 @@ static double latlon_scale=10000000.0;
return NULL; \
}
-static OSMPBF__BlobHeader *
-read_header(FILE *f)
-{
- unsigned char *buffer,lenb[4];
- int len;
+static OSMPBF__BlobHeader *read_header(FILE *f) {
+ unsigned char *buffer,lenb[4];
+ int len;
- if (fread(lenb, 4, 1, f) != 1)
- return NULL;
- len=(lenb[0] << 24) | (lenb[1] << 16) | (lenb[2] << 8) | lenb[3];
- SANITY_CHECK_LENGTH(len, MAX_HEADER_LENGTH)
- buffer=alloca(len);
- if (fread(buffer, len, 1, f) != 1)
- return NULL;
- return osmpbf__blob_header__unpack(&protobuf_c_system_allocator, len, buffer);
+ if (fread(lenb, 4, 1, f) != 1)
+ return NULL;
+ len=(lenb[0] << 24) | (lenb[1] << 16) | (lenb[2] << 8) | lenb[3];
+ SANITY_CHECK_LENGTH(len, MAX_HEADER_LENGTH)
+ buffer=alloca(len);
+ if (fread(buffer, len, 1, f) != 1)
+ return NULL;
+ return osmpbf__blob_header__unpack(NULL, len, buffer);
}
-static OSMPBF__Blob *
-read_blob(OSMPBF__BlobHeader *header, FILE *f, unsigned char *buffer)
-{
- int len=header->datasize;
- SANITY_CHECK_LENGTH(len, MAX_BLOB_LENGTH)
- if (fread(buffer, len, 1, f) != 1)
- return NULL;
- return osmpbf__blob__unpack(&protobuf_c_system_allocator, len, buffer);
+static OSMPBF__Blob *read_blob(OSMPBF__BlobHeader *header, FILE *f, unsigned char *buffer) {
+ int len=header->datasize;
+ SANITY_CHECK_LENGTH(len, MAX_BLOB_LENGTH)
+ if (fread(buffer, len, 1, f) != 1)
+ return NULL;
+ return osmpbf__blob__unpack(NULL, len, buffer);
}
-static unsigned char *
-uncompress_blob(OSMPBF__Blob *blob)
-{
- unsigned char *ret=malloc(blob->raw_size);
- int zerr;
- z_stream strm;
+static unsigned char *uncompress_blob(OSMPBF__Blob *blob) {
+ unsigned char *ret=g_malloc(blob->raw_size);
+ int zerr;
+ z_stream strm;
- if (!ret)
- return NULL;
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in=blob->zlib_data.len;
- strm.next_in=blob->zlib_data.data;
- strm.avail_out=blob->raw_size;
- strm.next_out=ret;
- zerr = inflateInit(&strm);
- if (zerr != Z_OK) {
- free(ret);
- return NULL;
- }
- zerr = inflate(&strm, Z_NO_FLUSH);
- if (zerr != Z_STREAM_END) {
- free(ret);
- return NULL;
- }
- inflateEnd(&strm);
- return ret;
+ if (!ret)
+ return NULL;
+ strm.zalloc = Z_NULL;
+ strm.zfree = Z_NULL;
+ strm.opaque = Z_NULL;
+ strm.avail_in=blob->zlib_data.len;
+ strm.next_in=blob->zlib_data.data;
+ strm.avail_out=blob->raw_size;
+ strm.next_out=ret;
+ zerr = inflateInit(&strm);
+ if (zerr != Z_OK) {
+ g_free(ret);
+ return NULL;
+ }
+ zerr = inflate(&strm, Z_NO_FLUSH);
+ if (zerr != Z_STREAM_END) {
+ g_free(ret);
+ return NULL;
+ }
+ inflateEnd(&strm);
+ return ret;
}
-static int
-get_string(char *buffer, int buffer_size, OSMPBF__PrimitiveBlock *primitive_block, int id, int escape)
-{
- int len=primitive_block->stringtable->s[id].len;
- char *data=(char *)primitive_block->stringtable->s[id].data;
- if (primitive_block->stringtable->s[id].len >= buffer_size) {
- buffer[0]='\0';
- return 0;
- }
- if (escape) {
- int i;
- char *p=buffer;
- for (i = 0 ; i < len ; i++) {
- switch(data[i]) {
- case '\t':
- case '\r':
- case '\n':
- case '>':
- case '<':
- case '\'':
- case '"':
- case '&':
- sprintf(p,"&#%d;",data[i]);
- p+=strlen(p);
- break;
- default:
- *p++=data[i];
- }
- }
- *p++='\0';
- return 1;
- } else {
- strncpy(buffer, data, len);
- buffer[len]='\0';
- return 1;
- }
+static int get_string(char *buffer, int buffer_size, OSMPBF__PrimitiveBlock *primitive_block, int id, int escape) {
+ int len=primitive_block->stringtable->s[id].len;
+ char *data=(char *)primitive_block->stringtable->s[id].data;
+ if (primitive_block->stringtable->s[id].len >= buffer_size) {
+ buffer[0]='\0';
+ return 0;
+ }
+ if (escape) {
+ int i;
+ char *p=buffer;
+ for (i = 0 ; i < len ; i++) {
+ switch(data[i]) {
+ case '\t':
+ case '\r':
+ case '\n':
+ case '>':
+ case '<':
+ case '\'':
+ case '"':
+ case '&':
+ sprintf(p,"&#%d;",data[i]);
+ p+=strlen(p);
+ break;
+ default:
+ *p++=data[i];
+ }
+ }
+ *p++='\0';
+ return 1;
+ } else {
+ strncpy(buffer, data, len);
+ buffer[len]='\0';
+ return 1;
+ }
}
-static void
-process_osmheader(OSMPBF__Blob *blob, unsigned char *data)
-{
- OSMPBF__HeaderBlock *header_block;
- header_block=osmpbf__header_block__unpack(&protobuf_c_system_allocator, blob->raw_size, data);
- osmpbf__header_block__free_unpacked(header_block, &protobuf_c_system_allocator);
+static void process_osmheader(OSMPBF__Blob *blob, unsigned char *data) {
+ OSMPBF__HeaderBlock *header_block;
+ header_block=osmpbf__header_block__unpack(NULL, blob->raw_size, data);
+ osmpbf__header_block__free_unpacked(header_block, NULL);
}
#if 0
-static void
-process_user(OSMPBF__PrimitiveBlock *primitive_block, int user_sid, int uid, int swap)
-{
- char userbuff[1024];
- get_string(userbuff, sizeof(userbuff), primitive_block, user_sid, 1);
- if (userbuff[0] && uid != -1) {
- if (swap)
- printf(" uid=\"%d\" user=\"%s\"",uid,userbuff);
- else
- printf(" user=\"%s\" uid=\"%d\"",userbuff,uid);
- }
+static void process_user(OSMPBF__PrimitiveBlock *primitive_block, int user_sid, int uid, int swap) {
+ char userbuff[1024];
+ get_string(userbuff, sizeof(userbuff), primitive_block, user_sid, 1);
+ if (userbuff[0] && uid != -1) {
+ if (swap)
+ printf(" uid=\"%d\" user=\"%s\"",uid,userbuff);
+ else
+ printf(" user=\"%s\" uid=\"%d\"",userbuff,uid);
+ }
}
-static void
-process_timestamp(long long timestamp)
-{
- time_t ts;
- struct tm *tm;
- char tsbuff[1024];
- ts=timestamp;
- tm=gmtime(&ts);
- strftime(tsbuff, sizeof(tsbuff), "%Y-%m-%dT%H:%M:%SZ", tm);
- printf(" timestamp=\"%s\"",tsbuff);
+static void process_timestamp(long long timestamp) {
+ time_t ts;
+ struct tm *tm;
+ char tsbuff[1024];
+ ts=timestamp;
+ tm=gmtime(&ts);
+ strftime(tsbuff, sizeof(tsbuff), "%Y-%m-%dT%H:%M:%SZ", tm);
+ printf(" timestamp=\"%s\"",tsbuff);
}
#endif
-static void
-process_tag(OSMPBF__PrimitiveBlock *primitive_block, int key, int val)
-{
- char keybuff[1024];
- char valbuff[1024];
-#if 0
- get_string(keybuff, sizeof(keybuff), primitive_block, key, 1);
- get_string(valbuff, sizeof(valbuff), primitive_block, val, 1);
- printf("\t\t<tag k=\"%s\" v=\"%s\" />\n",keybuff,valbuff);
-#else
- get_string(keybuff, sizeof(keybuff), primitive_block, key, 0);
- get_string(valbuff, sizeof(valbuff), primitive_block, val, 0);
- osm_add_tag(keybuff, valbuff);
-#endif
+static void process_tag(OSMPBF__PrimitiveBlock *primitive_block, int key, int val) {
+ char keybuff[1024];
+ char valbuff[1024];
+ get_string(keybuff, sizeof(keybuff), primitive_block, key, 0);
+ get_string(valbuff, sizeof(valbuff), primitive_block, val, 0);
+ osm_add_tag(keybuff, valbuff);
}
-static void
-process_dense(OSMPBF__PrimitiveBlock *primitive_block, OSMPBF__DenseNodes *dense, struct maptool_osm *osm)
-{
- int i,j=0,has_tags;
- long long id=0,lat=0,lon=0,changeset=0,timestamp=0;
- int user_sid=0,uid=0;
+static void process_dense(OSMPBF__PrimitiveBlock *primitive_block, OSMPBF__DenseNodes *dense, struct maptool_osm *osm) {
+ int i,j=0,has_tags;
+ long long id=0,lat=0,lon=0,changeset=0,timestamp=0;
+ int user_sid=0,uid=0;
- if (!dense)
- return;
+ if (!dense)
+ return;
- for (i = 0 ; i < dense->n_id ; i++) {
- id+=dense->id[i];
- lat+=dense->lat[i];
- lon+=dense->lon[i];
- changeset+=dense->denseinfo->changeset[i];
- user_sid+=dense->denseinfo->user_sid[i];
- uid+=dense->denseinfo->uid[i];
- timestamp+=dense->denseinfo->timestamp[i];
- has_tags=dense->keys_vals && dense->keys_vals[j];
- osm_add_node(id, lat/latlon_scale,lon/latlon_scale);
-#if 0
- printf("\t<node id=\"%Ld\" lat=\"%.7f\" lon=\"%.7f\" version=\"%d\" changeset=\"%Ld\"",id,lat/latlon_scale,lon/latlon_scale,dense->denseinfo->version[i],changeset);
- process_user(primitive_block, user_sid, uid, 0);
- process_timestamp(timestamp);
-#endif
- if (has_tags) {
-#if 0
- printf(">\n");
-#endif
- while (dense->keys_vals[j]) {
- process_tag(primitive_block, dense->keys_vals[j], dense->keys_vals[j+1]);
- j+=2;
- }
-#if 0
- printf("\t</node>\n");
- } else
- printf("/>\n");
-#else
- }
-#endif
- osm_end_node(osm);
- j++;
- }
+ for (i = 0 ; i < dense->n_id ; i++) {
+ id+=dense->id[i];
+ lat+=dense->lat[i];
+ lon+=dense->lon[i];
+ changeset+=dense->denseinfo->changeset[i];
+ user_sid+=dense->denseinfo->user_sid[i];
+ uid+=dense->denseinfo->uid[i];
+ timestamp+=dense->denseinfo->timestamp[i];
+ has_tags=dense->keys_vals && dense->keys_vals[j];
+ osm_add_node(id, lat/latlon_scale,lon/latlon_scale);
+ if (has_tags) {
+ while (dense->keys_vals[j]) {
+ process_tag(primitive_block, dense->keys_vals[j], dense->keys_vals[j+1]);
+ j+=2;
+ }
+ }
+ osm_end_node(osm);
+ j++;
+ }
}
#if 0
-static void
-process_info(OSMPBF__PrimitiveBlock *primitive_block, OSMPBF__Info *info)
-{
- printf(" version=\"%d\" changeset=\"%Ld\"",info->version,info->changeset);
- process_user(primitive_block, info->user_sid, info->uid, 1);
- process_timestamp(info->timestamp);
+static void process_info(OSMPBF__PrimitiveBlock *primitive_block, OSMPBF__Info *info) {
+ printf(" version=\"%d\" changeset=\"%Ld\"",info->version,info->changeset);
+ process_user(primitive_block, info->user_sid, info->uid, 1);
+ process_timestamp(info->timestamp);
}
#endif
-static void
-process_way(OSMPBF__PrimitiveBlock *primitive_block, OSMPBF__Way *way, struct maptool_osm *osm)
-{
- int i;
- long long ref=0;
+static void process_way(OSMPBF__PrimitiveBlock *primitive_block, OSMPBF__Way *way, struct maptool_osm *osm) {
+ int i;
+ long long ref=0;
- osm_add_way(way->id);
-#if 0
- printf("\t<way id=\"%Ld\"",way->id);
- process_info(primitive_block, way->info);
- printf(">\n");
-#else
-#endif
- for (i = 0 ; i < way->n_refs ; i++) {
- ref+=way->refs[i];
- osm_add_nd(ref);
-#if 0
- printf("\t\t<nd ref=\"%Ld\"/>\n",ref);
-#else
-#endif
- }
- for (i = 0 ; i < way->n_keys ; i++)
- process_tag(primitive_block, way->keys[i], way->vals[i]);
-#if 0
- printf("\t</way>\n");
-#endif
- osm_end_way(osm);
+ osm_add_way(way->id);
+ for (i = 0 ; i < way->n_refs ; i++) {
+ ref+=way->refs[i];
+ osm_add_nd(ref);
+ }
+ for (i = 0 ; i < way->n_keys ; i++)
+ process_tag(primitive_block, way->keys[i], way->vals[i]);
+ osm_end_way(osm);
}
-static void
-process_relation(OSMPBF__PrimitiveBlock *primitive_block, OSMPBF__Relation *relation, struct maptool_osm *osm)
-{
- int i;
- long long ref=0;
- char rolebuff[1024];
+static void process_relation(OSMPBF__PrimitiveBlock *primitive_block, OSMPBF__Relation *relation,
+ struct maptool_osm *osm) {
+ int i;
+ long long ref=0;
+ char rolebuff[1024];
-#if 0
- printf("\t<relation id=\"%Ld\"",relation->id);
- process_info(primitive_block, relation->info);
- printf(">\n");
-#endif
- osm_add_relation(relation->id);
- for (i = 0 ; i < relation->n_roles_sid ; i++) {
-#if 0
- printf("\t\t<member type=\"");
- switch (relation->types[i]) {
- case 0:
- printf("node");
- break;
- case 1:
- printf("way");
- break;
- case 2:
- printf("relation");
- break;
- default:
- printf("unknown");
- break;
- }
-#endif
- ref+=relation->memids[i];
- get_string(rolebuff, sizeof(rolebuff), primitive_block, relation->roles_sid[i], 1);
-#if 0
- printf("\" ref=\"%Ld\" role=\"%s\"/>\n",ref,rolebuff);
-#else
- osm_add_member(relation->types[i]+1,ref,rolebuff);
-#endif
- }
- for (i = 0 ; i < relation->n_keys ; i++)
- process_tag(primitive_block, relation->keys[i], relation->vals[i]);
-#if 0
- printf("\t</relation>\n");
-#else
- osm_end_relation(osm);
-#endif
+ osm_add_relation(relation->id);
+ for (i = 0 ; i < relation->n_roles_sid ; i++) {
+ ref+=relation->memids[i];
+ get_string(rolebuff, sizeof(rolebuff), primitive_block, relation->roles_sid[i], 1);
+ osm_add_member(relation->types[i]+1,ref,rolebuff);
+ }
+ for (i = 0 ; i < relation->n_keys ; i++)
+ process_tag(primitive_block, relation->keys[i], relation->vals[i]);
+ osm_end_relation(osm);
}
-static void
-process_osmdata(OSMPBF__Blob *blob, unsigned char *data, struct maptool_osm *osm)
-{
- int i,j;
- OSMPBF__PrimitiveBlock *primitive_block;
- primitive_block=osmpbf__primitive_block__unpack(&protobuf_c_system_allocator, blob->raw_size, data);
- for (i = 0 ; i < primitive_block->n_primitivegroup ; i++) {
- OSMPBF__PrimitiveGroup *primitive_group=primitive_block->primitivegroup[i];
- process_dense(primitive_block, primitive_group->dense, osm);
- for (j = 0 ; j < primitive_group->n_ways ; j++)
- process_way(primitive_block, primitive_group->ways[j], osm);
- for (j = 0 ; j < primitive_group->n_relations ; j++)
- process_relation(primitive_block, primitive_group->relations[j], osm);
-#if 0
- printf("Group %p %d %d %d %d\n",primitive_group->dense,primitive_group->n_nodes,primitive_group->n_ways,primitive_group->n_relations,primitive_group->n_changesets);
-#endif
- }
- osmpbf__primitive_block__free_unpacked(primitive_block, &protobuf_c_system_allocator);
+static void process_osmdata(OSMPBF__Blob *blob, unsigned char *data, struct maptool_osm *osm) {
+ int i,j;
+ OSMPBF__PrimitiveBlock *primitive_block;
+ primitive_block=osmpbf__primitive_block__unpack(NULL, blob->raw_size, data);
+ for (i = 0 ; i < primitive_block->n_primitivegroup ; i++) {
+ OSMPBF__PrimitiveGroup *primitive_group=primitive_block->primitivegroup[i];
+ process_dense(primitive_block, primitive_group->dense, osm);
+ for (j = 0 ; j < primitive_group->n_ways ; j++)
+ process_way(primitive_block, primitive_group->ways[j], osm);
+ for (j = 0 ; j < primitive_group->n_relations ; j++)
+ process_relation(primitive_block, primitive_group->relations[j], osm);
+ }
+ osmpbf__primitive_block__free_unpacked(primitive_block, NULL);
}
-int
-map_collect_data_osm_protobuf(FILE *in, struct maptool_osm *osm)
-{
- OSMPBF__BlobHeader *header;
- OSMPBF__Blob *blob;
- unsigned char *data;
- unsigned char *buffer=malloc(MAX_BLOB_LENGTH);
+int map_collect_data_osm_protobuf(FILE *in, struct maptool_osm *osm) {
+ OSMPBF__BlobHeader *header;
+ OSMPBF__Blob *blob;
+ unsigned char *data;
+ unsigned char *buffer=g_malloc(MAX_BLOB_LENGTH);
-#if 0
- printf("<?xml version='1.0' encoding='UTF-8'?>\n");
- printf("<osm version=\"0.6\" generator=\"pbf2osm\">\n");
-#endif
- while ((header=read_header(in))) {
- blob=read_blob(header, in, buffer);
- data=uncompress_blob(blob);
- if (!strcmp(header->type,"OSMHeader")) {
- process_osmheader(blob, data);
- } else if (!strcmp(header->type,"OSMData")) {
- process_osmdata(blob, data, osm);
- } else {
- printf("skipping fileblock of unknown type '%s'\n", header->type);
- free(buffer);
- return 0;
- }
- free(data);
- osmpbf__blob__free_unpacked(blob, &protobuf_c_system_allocator);
- osmpbf__blob_header__free_unpacked(header, &protobuf_c_system_allocator);
- }
- free(buffer);
-#if 0
- printf("</osm>\n");
-#endif
- return 1;
+ while ((header=read_header(in))) {
+ blob=read_blob(header, in, buffer);
+ data=uncompress_blob(blob);
+ if (!g_strcmp0(header->type,"OSMHeader")) {
+ process_osmheader(blob, data);
+ } else if (!g_strcmp0(header->type,"OSMData")) {
+ process_osmdata(blob, data, osm);
+ } else {
+ printf("skipping fileblock of unknown type '%s'\n", header->type);
+ g_free(buffer);
+ return 0;
+ }
+ g_free(data);
+ osmpbf__blob__free_unpacked(blob, NULL);
+ osmpbf__blob_header__free_unpacked(header, NULL);
+ }
+ g_free(buffer);
+ return 1;
}
diff --git a/navit/maptool/osm_protobufdb.c b/navit/maptool/osm_protobufdb.c
index 2b242df9c..64b601280 100644
--- a/navit/maptool/osm_protobufdb.c
+++ b/navit/maptool/osm_protobufdb.c
@@ -26,184 +26,170 @@
#include "debug.h"
#include "linguistics.h"
#include "file.h"
-#include "generated-code/fileformat.pb-c.h"
-#include "generated-code/osmformat.pb-c.h"
+#include "fileformat.pb-c.h"
+#include "osmformat.pb-c.h"
static double latlon_scale=10000000.0;
struct db_config {
- int node_ids_per_file;
- int node_ids_per_blob;
- int node_ids_per_group;
- int way_ids_per_file;
- int way_ids_per_blob;
- int way_ids_per_group;
- int relation_ids_per_file;
- int relation_ids_per_blob;
- int relation_ids_per_group;
+ int node_ids_per_file;
+ int node_ids_per_blob;
+ int node_ids_per_group;
+ int way_ids_per_file;
+ int way_ids_per_blob;
+ int way_ids_per_group;
+ int relation_ids_per_file;
+ int relation_ids_per_blob;
+ int relation_ids_per_group;
} db_config = {
- 200000, 30000, 500,
- 40000, 1000, 30,
- 10000, 500, 20,
+ 200000, 30000, 500,
+ 40000, 1000, 30,
+ 10000, 500, 20,
};
struct osm_protobufdb_context {
- int current_file, current_block, active_block;
- int in_node, in_way, in_relation;
- OSMPBF__Node n;
- OSMPBF__Way w;
- OSMPBF__Relation r;
- OSMPBF__Info i;
- FILE *f;
- OSMPBF__PrimitiveBlock *pb;
- OSMPBF__PrimitiveGroup *pg;
- GHashTable *string_hash;
- OSMPBF__DenseInfo *di;
- OSMPBF__DenseNodes *dn;
- OSMPBF__StringTable *st;
+ int current_file, current_block, active_block;
+ int in_node, in_way, in_relation;
+ OSMPBF__Node n;
+ OSMPBF__Way w;
+ OSMPBF__Relation r;
+ OSMPBF__Info i;
+ FILE *f;
+ OSMPBF__PrimitiveBlock *pb;
+ OSMPBF__PrimitiveGroup *pg;
+ GHashTable *string_hash;
+ OSMPBF__DenseInfo *di;
+ OSMPBF__DenseNodes *dn;
+ OSMPBF__StringTable *st;
} context;
-static int
-osm_protobufdb_write_blob(OSMPBF__Blob *blob, FILE *out)
-{
- unsigned char lenb[4];
- int len,blen;
- unsigned char *buffer;
- OSMPBF__BlobHeader header=OSMPBF__BLOB_HEADER__INIT;
-
-
-
- blen=osmpbf__blob__get_packed_size(blob);
- header.type="OSMData";
- header.datasize=blen;
- len=osmpbf__blob_header__get_packed_size(&header);
- buffer=alloca(len);
- lenb[0]=len>>24;
- lenb[1]=len>>16;
- lenb[2]=len>>8;
- lenb[3]=len;
- osmpbf__blob_header__pack(&header, buffer);
- if (fwrite(lenb, sizeof(lenb), 1, out) != 1)
- return 0;
- if (fwrite(buffer, len, 1, out) != 1)
- return 0;
- buffer=alloca(blen);
- osmpbf__blob__pack(blob, buffer);
- if (fwrite(buffer, blen, 1, out) != 1)
- return 0;
- return 1;
+static int osm_protobufdb_write_blob(OSMPBF__Blob *blob, FILE *out) {
+ unsigned char lenb[4];
+ int len,blen;
+ unsigned char *buffer;
+ OSMPBF__BlobHeader header=OSMPBF__BLOB_HEADER__INIT;
+
+
+
+ blen=osmpbf__blob__get_packed_size(blob);
+ header.type="OSMData";
+ header.datasize=blen;
+ len=osmpbf__blob_header__get_packed_size(&header);
+ buffer=alloca(len);
+ lenb[0]=len>>24;
+ lenb[1]=len>>16;
+ lenb[2]=len>>8;
+ lenb[3]=len;
+ osmpbf__blob_header__pack(&header, buffer);
+ if (fwrite(lenb, sizeof(lenb), 1, out) != 1)
+ return 0;
+ if (fwrite(buffer, len, 1, out) != 1)
+ return 0;
+ buffer=alloca(blen);
+ osmpbf__blob__pack(blob, buffer);
+ if (fwrite(buffer, blen, 1, out) != 1)
+ return 0;
+ return 1;
}
#if 0
-void
-dump_block(OSMPBF__PrimitiveBlock *pb)
-{
- int i,j;
- printf("%d groups\n",pb->n_primitivegroup);
- for (i = 0 ; i < pb->n_primitivegroup ; i++) {
- printf("%d relations\n",pb->primitivegroup[i]->n_relations);
- for (j = 0 ; j < pb->primitivegroup[i]->n_relations ; j++) {
- printf("Info %d\n",pb->primitivegroup[i]->relations[j]->info->version);
- }
- }
+void dump_block(OSMPBF__PrimitiveBlock *pb) {
+ int i,j;
+ printf("%d groups\n",pb->n_primitivegroup);
+ for (i = 0 ; i < pb->n_primitivegroup ; i++) {
+ printf("%d relations\n",pb->primitivegroup[i]->n_relations);
+ for (j = 0 ; j < pb->primitivegroup[i]->n_relations ; j++) {
+ printf("Info %d\n",pb->primitivegroup[i]->relations[j]->info->version);
+ }
+ }
}
#endif
-static int
-osm_protobufdb_finish_block(struct osm_protobufdb_context *ctx)
-{
- OSMPBF__Blob *blob,empty_blob=OSMPBF__BLOB__INIT;
- int len;
- if (!ctx->pb)
- return 0;
- len=osmpbf__primitive_block__get_packed_size(ctx->pb);
-
- while (ctx->current_block < ctx->active_block) {
- osm_protobufdb_write_blob(&empty_blob, ctx->f);
- ctx->current_block++;
- }
- blob=malloc(sizeof(*blob));
- *blob=empty_blob;
- blob->has_raw=1;
- blob->has_raw_size=1;
- blob->raw.data=malloc(len);
- osmpbf__primitive_block__pack(ctx->pb, blob->raw.data);
- blob->raw.len=len;
- blob->raw_size=len;
- osm_protobufdb_write_blob(blob, ctx->f);
- osmpbf__blob__free_unpacked(blob, &protobuf_c_system_allocator);
- osmpbf__primitive_block__free_unpacked(ctx->pb, &protobuf_c_system_allocator);
- ctx->pb=NULL;
- ctx->current_block++;
- return 1;
-}
-
-static int
-osm_protobufdb_start_block(struct osm_protobufdb_context *ctx, int blocknum)
-{
- OSMPBF__PrimitiveBlock pb=OSMPBF__PRIMITIVE_BLOCK__INIT;
- OSMPBF__StringTable st=OSMPBF__STRING_TABLE__INIT;
- if (ctx->active_block == blocknum)
- return 0;
- osm_protobufdb_finish_block(ctx);
- ctx->active_block=blocknum;
- ctx->pb=malloc(sizeof(*ctx->pb));
- *ctx->pb=pb;
- ctx->pb->stringtable=malloc(sizeof(*ctx->pb->stringtable));
- *ctx->pb->stringtable=st;
- ctx->st=ctx->pb->stringtable;
- return 1;
-}
-
-static int
-osm_protobufdb_start_group(struct osm_protobufdb_context *ctx, int groupnum)
-{
- OSMPBF__PrimitiveGroup pg=OSMPBF__PRIMITIVE_GROUP__INIT;
- if (ctx->pb->n_primitivegroup <= groupnum) {
- ctx->pb->primitivegroup=realloc(ctx->pb->primitivegroup, (groupnum+1)*sizeof(ctx->pb->primitivegroup[0]));
- while (ctx->pb->n_primitivegroup <= groupnum) {
- ctx->pb->primitivegroup[ctx->pb->n_primitivegroup]=malloc(sizeof(*context.pg));
- *ctx->pb->primitivegroup[ctx->pb->n_primitivegroup++]=pg;
- }
- g_hash_table_destroy(ctx->string_hash);
- ctx->string_hash=g_hash_table_new(g_str_hash, g_str_equal);
- }
- ctx->pg=ctx->pb->primitivegroup[groupnum];
- if (!ctx->pg) {
- ctx->pg=malloc(sizeof(*context.pg));
- *ctx->pg=pg;
- ctx->pb->primitivegroup[groupnum]=ctx->pg;
- }
- return 1;
+static int osm_protobufdb_finish_block(struct osm_protobufdb_context *ctx) {
+ OSMPBF__Blob *blob,empty_blob=OSMPBF__BLOB__INIT;
+ int len;
+ if (!ctx->pb)
+ return 0;
+ len=osmpbf__primitive_block__get_packed_size(ctx->pb);
+
+ while (ctx->current_block < ctx->active_block) {
+ osm_protobufdb_write_blob(&empty_blob, ctx->f);
+ ctx->current_block++;
+ }
+ blob=g_malloc(sizeof(*blob));
+ *blob=empty_blob;
+ blob->has_raw=1;
+ blob->has_raw_size=1;
+ blob->raw.data=g_malloc(len);
+ osmpbf__primitive_block__pack(ctx->pb, blob->raw.data);
+ blob->raw.len=len;
+ blob->raw_size=len;
+ osm_protobufdb_write_blob(blob, ctx->f);
+ osmpbf__blob__free_unpacked(blob, NULL);
+ osmpbf__primitive_block__free_unpacked(ctx->pb, NULL);
+ ctx->pb=NULL;
+ ctx->current_block++;
+ return 1;
+}
+
+static int osm_protobufdb_start_block(struct osm_protobufdb_context *ctx, int blocknum) {
+ OSMPBF__PrimitiveBlock pb=OSMPBF__PRIMITIVE_BLOCK__INIT;
+ OSMPBF__StringTable st=OSMPBF__STRING_TABLE__INIT;
+ if (ctx->active_block == blocknum)
+ return 0;
+ osm_protobufdb_finish_block(ctx);
+ ctx->active_block=blocknum;
+ ctx->pb=g_malloc(sizeof(*ctx->pb));
+ *ctx->pb=pb;
+ ctx->pb->stringtable=g_malloc(sizeof(*ctx->pb->stringtable));
+ *ctx->pb->stringtable=st;
+ ctx->st=ctx->pb->stringtable;
+ return 1;
+}
+
+static int osm_protobufdb_start_group(struct osm_protobufdb_context *ctx, int groupnum) {
+ OSMPBF__PrimitiveGroup pg=OSMPBF__PRIMITIVE_GROUP__INIT;
+ if (ctx->pb->n_primitivegroup <= groupnum) {
+ ctx->pb->primitivegroup=g_realloc(ctx->pb->primitivegroup, (groupnum+1)*sizeof(ctx->pb->primitivegroup[0]));
+ while (ctx->pb->n_primitivegroup <= groupnum) {
+ ctx->pb->primitivegroup[ctx->pb->n_primitivegroup]=g_malloc(sizeof(*context.pg));
+ *ctx->pb->primitivegroup[ctx->pb->n_primitivegroup++]=pg;
+ }
+ g_hash_table_destroy(ctx->string_hash);
+ ctx->string_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ }
+ ctx->pg=ctx->pb->primitivegroup[groupnum];
+ if (!ctx->pg) {
+ ctx->pg=g_malloc(sizeof(*context.pg));
+ *ctx->pg=pg;
+ ctx->pb->primitivegroup[groupnum]=ctx->pg;
+ }
+ return 1;
}
#if 0
-static int
-osm_protobufdb_start_densenode(struct osm_protobufdb_context *ctx)
-{
- OSMPBF__DenseInfo di=OSMPBF__DENSE_INFO__INIT;
- OSMPBF__DenseNodes dn=OSMPBF__DENSE_NODES__INIT;
-
- if (!ctx->pg->dense) {
- ctx->dn=malloc(sizeof(*context.dn));
- *ctx->dn=dn;
- ctx->pg->dense=ctx->dn;
- } else
- ctx->dn=ctx->pg->dense;
- if (!ctx->dn->denseinfo) {
- ctx->di=malloc(sizeof(*context.di));
- *ctx->di=di;
- ctx->dn->denseinfo=ctx->di;
- } else
- ctx->di=ctx->dn->denseinfo;
- return 1;
-}
-
-static void
-osm_protobufdb_write_primitive_group(OSMPBF__PrimitiveGroup *pg, OSMPBF__PrimitiveBlock *pb)
-{
- pb->primitivegroup=realloc(pb->primitivegroup,(pb->n_primitivegroup+1)*sizeof(OSMPBF__PrimitiveGroup *));
- pb->primitivegroup[pb->n_primitivegroup++]=pg;
+static int osm_protobufdb_start_densenode(struct osm_protobufdb_context *ctx) {
+ OSMPBF__DenseInfo di=OSMPBF__DENSE_INFO__INIT;
+ OSMPBF__DenseNodes dn=OSMPBF__DENSE_NODES__INIT;
+
+ if (!ctx->pg->dense) {
+ ctx->dn=g_malloc(sizeof(*context.dn));
+ *ctx->dn=dn;
+ ctx->pg->dense=ctx->dn;
+ } else
+ ctx->dn=ctx->pg->dense;
+ if (!ctx->dn->denseinfo) {
+ ctx->di=g_malloc(sizeof(*context.di));
+ *ctx->di=di;
+ ctx->dn->denseinfo=ctx->di;
+ } else
+ ctx->di=ctx->dn->denseinfo;
+ return 1;
+}
+
+static void osm_protobufdb_write_primitive_group(OSMPBF__PrimitiveGroup *pg, OSMPBF__PrimitiveBlock *pb) {
+ pb->primitivegroup=g_realloc(pb->primitivegroup,(pb->n_primitivegroup+1)*sizeof(OSMPBF__PrimitiveGroup *));
+ pb->primitivegroup[pb->n_primitivegroup++]=pg;
}
#endif
@@ -211,655 +197,518 @@ osm_protobufdb_write_primitive_group(OSMPBF__PrimitiveGroup *pg, OSMPBF__Primiti
#define insert(struct, member, pos) {\
int n=struct->n_##member; \
int s=sizeof(struct->member[0]); \
- struct->member=realloc(struct->member, (n+1)*s); \
+ struct->member=g_realloc(struct->member, (n+1)*s); \
memmove(&struct->member[n+1], &struct->member[n], (pos-n)*s); \
memset(&struct->member[n], 0, s); \
struct->n_##member++;\
}
#if 0
-static int
-osm_protobufdb_insert_densenode(long long id, OSMPBF__Node *offset, OSMPBF__Info *offseti, OSMPBF__DenseNodes *dn)
-{
- int i,l,p;
- memset(offset, 0, sizeof(*offset));
- offseti->timestamp=0;
- offseti->changeset=0;
- offseti->user_sid=0;
- offseti->uid=0;
- l=dn->n_id;
- for (i = 0 ; i < l ; i++) {
- offset->id+=dn->id[i];
- offset->lat+=dn->lat[i];
- offset->lon+=dn->lon[i];
- offseti->timestamp+=dn->denseinfo->timestamp[i];
- offseti->changeset+=dn->denseinfo->changeset[i];
- offseti->user_sid+=dn->denseinfo->user_sid[i];
- offseti->uid+=dn->denseinfo->uid[i];
- }
- p=l;
- insert(dn, id, p);
- insert(dn, lat, p);
- insert(dn, lon, p);
- insert(dn->denseinfo, version, p);
- insert(dn->denseinfo, timestamp, p);
- insert(dn->denseinfo, changeset, p);
- insert(dn->denseinfo, user_sid, p);
- insert(dn->denseinfo, uid, p);
- return p;
-}
-
-static void
-osm_protobufdb_modify_densenode(OSMPBF__Node *node, OSMPBF__Info *info, OSMPBF__Node *offset, OSMPBF__Info *offseti, int pos, OSMPBF__DenseNodes *dn)
-{
- int i;
- if (pos+1 < dn->n_id) {
- dn->id[pos+1]+=dn->id[pos]-node->id;
- dn->lat[pos+1]+=dn->lat[pos]-node->lat;
- dn->lon[pos+1]+=dn->lon[pos]-node->lon;
- dn->denseinfo->timestamp[pos+1]+=dn->denseinfo->timestamp[pos]-info->timestamp;
- dn->denseinfo->changeset[pos+1]+=dn->denseinfo->changeset[pos]-info->changeset;
- dn->denseinfo->user_sid[pos+1]+=dn->denseinfo->user_sid[pos]-info->user_sid;
- dn->denseinfo->uid[pos+1]+=dn->denseinfo->uid[pos]-info->uid;
- }
- dn->id[pos]=node->id-offset->id;
- dn->lat[pos]=node->lat-offset->lat;
- dn->lon[pos]=node->lon-offset->lon;
- dn->keys_vals=realloc(dn->keys_vals, (dn->n_keys_vals+node->n_keys+node->n_vals+1)*sizeof(dn->keys_vals[0]));
- for (i = 0 ; i < node->n_keys ; i++) {
- dn->keys_vals[dn->n_keys_vals++]=node->keys[i];
- dn->keys_vals[dn->n_keys_vals++]=node->vals[i];
- }
- dn->keys_vals[dn->n_keys_vals++]=0;
- dn->denseinfo->version[pos]=info->version;
- dn->denseinfo->timestamp[pos]=info->timestamp-offseti->timestamp;
- dn->denseinfo->changeset[pos]=info->changeset-offseti->changeset;
- dn->denseinfo->user_sid[pos]=info->user_sid-offseti->user_sid;
- dn->denseinfo->uid[pos]=info->uid-offseti->uid;
+static int osm_protobufdb_insert_densenode(long long id, OSMPBF__Node *offset, OSMPBF__Info *offseti,
+ OSMPBF__DenseNodes *dn) {
+ int i,l,p;
+ memset(offset, 0, sizeof(*offset));
+ offseti->timestamp=0;
+ offseti->changeset=0;
+ offseti->user_sid=0;
+ offseti->uid=0;
+ l=dn->n_id;
+ for (i = 0 ; i < l ; i++) {
+ offset->id+=dn->id[i];
+ offset->lat+=dn->lat[i];
+ offset->lon+=dn->lon[i];
+ offseti->timestamp+=dn->denseinfo->timestamp[i];
+ offseti->changeset+=dn->denseinfo->changeset[i];
+ offseti->user_sid+=dn->denseinfo->user_sid[i];
+ offseti->uid+=dn->denseinfo->uid[i];
+ }
+ p=l;
+ insert(dn, id, p);
+ insert(dn, lat, p);
+ insert(dn, lon, p);
+ insert(dn->denseinfo, version, p);
+ insert(dn->denseinfo, timestamp, p);
+ insert(dn->denseinfo, changeset, p);
+ insert(dn->denseinfo, user_sid, p);
+ insert(dn->denseinfo, uid, p);
+ return p;
+}
+
+static void osm_protobufdb_modify_densenode(OSMPBF__Node *node, OSMPBF__Info *info, OSMPBF__Node *offset,
+ OSMPBF__Info *offseti,
+ int pos, OSMPBF__DenseNodes *dn) {
+ int i;
+ if (pos+1 < dn->n_id) {
+ dn->id[pos+1]+=dn->id[pos]-node->id;
+ dn->lat[pos+1]+=dn->lat[pos]-node->lat;
+ dn->lon[pos+1]+=dn->lon[pos]-node->lon;
+ dn->denseinfo->timestamp[pos+1]+=dn->denseinfo->timestamp[pos]-info->timestamp;
+ dn->denseinfo->changeset[pos+1]+=dn->denseinfo->changeset[pos]-info->changeset;
+ dn->denseinfo->user_sid[pos+1]+=dn->denseinfo->user_sid[pos]-info->user_sid;
+ dn->denseinfo->uid[pos+1]+=dn->denseinfo->uid[pos]-info->uid;
+ }
+ dn->id[pos]=node->id-offset->id;
+ dn->lat[pos]=node->lat-offset->lat;
+ dn->lon[pos]=node->lon-offset->lon;
+ dn->keys_vals=g_realloc(dn->keys_vals, (dn->n_keys_vals+node->n_keys+node->n_vals+1)*sizeof(dn->keys_vals[0]));
+ for (i = 0 ; i < node->n_keys ; i++) {
+ dn->keys_vals[dn->n_keys_vals++]=node->keys[i];
+ dn->keys_vals[dn->n_keys_vals++]=node->vals[i];
+ }
+ dn->keys_vals[dn->n_keys_vals++]=0;
+ dn->denseinfo->version[pos]=info->version;
+ dn->denseinfo->timestamp[pos]=info->timestamp-offseti->timestamp;
+ dn->denseinfo->changeset[pos]=info->changeset-offseti->changeset;
+ dn->denseinfo->user_sid[pos]=info->user_sid-offseti->user_sid;
+ dn->denseinfo->uid[pos]=info->uid-offseti->uid;
}
#endif
-static int
-osm_protobufdb_insert_node(long long id, OSMPBF__PrimitiveGroup *pg)
-{
- int l,p;
- OSMPBF__Node node=OSMPBF__NODE__INIT;
- l=pg->n_nodes;
- p=l;
- insert(pg, nodes, p);
- pg->nodes[p]=malloc(sizeof(*pg->nodes[0]));
- *pg->nodes[p]=node;
- return p;
-}
-
-static void
-osm_protobufdb_modify_node(OSMPBF__Node *node, OSMPBF__Info *info, int pos, OSMPBF__PrimitiveGroup *pg)
-{
- OSMPBF__Node *n=pg->nodes[pos];
- OSMPBF__Info *old_info;
-
- if (n->keys)
- free(n->keys);
- if (n->vals)
- free(n->vals);
- old_info=n->info;
- *n=*node;
- if (!info) {
- if (old_info)
- osmpbf__info__free_unpacked(old_info, &protobuf_c_system_allocator);
- n->info=NULL;
- } else {
- if (old_info)
- n->info=old_info;
- else
- n->info=malloc(sizeof(*info));
- *n->info=*info;
- }
-
-}
-
-static int
-osm_protobufdb_insert_way(long long id, OSMPBF__PrimitiveGroup *pg)
-{
- int l,p;
- OSMPBF__Way way=OSMPBF__WAY__INIT;
- l=pg->n_ways;
- p=l;
- insert(pg, ways, p);
- pg->ways[p]=malloc(sizeof(*pg->ways[0]));
- *pg->ways[p]=way;
- return p;
-}
-
-static void
-osm_protobufdb_modify_way(OSMPBF__Way *way, OSMPBF__Info *info, int pos, OSMPBF__PrimitiveGroup *pg)
-{
- OSMPBF__Way *w=pg->ways[pos];
- OSMPBF__Info *old_info;
- int i;
- long long ref=0;
-
- if (w->keys)
- free(w->keys);
- if (w->vals)
- free(w->vals);
- if (w->refs)
- free(w->refs);
- old_info=w->info;
- *w=*way;
- for (i = 0 ; i < w->n_refs ; i++) {
- w->refs[i]-=ref;
- ref+=w->refs[i];
- }
- if (!info) {
- if (old_info)
- osmpbf__info__free_unpacked(old_info, &protobuf_c_system_allocator);
- w->info=NULL;
- } else {
- if (old_info)
- w->info=old_info;
- else
- w->info=malloc(sizeof(*info));
- *w->info=*info;
- }
-
-}
-
-static int
-osm_protobufdb_insert_relation(long long id, OSMPBF__PrimitiveGroup *pg)
-{
- int l,p;
- OSMPBF__Relation relation=OSMPBF__RELATION__INIT;
- l=pg->n_relations;
- p=l;
- insert(pg, relations, p);
- pg->relations[p]=malloc(sizeof(*pg->relations[0]));
- *pg->relations[p]=relation;
- return p;
-}
-
-static void
-osm_protobufdb_modify_relation(OSMPBF__Relation *relation, OSMPBF__Info *info, int pos, OSMPBF__PrimitiveGroup *pg)
-{
- OSMPBF__Relation *r=pg->relations[pos];
- OSMPBF__Info *old_info;
- int i;
- long long ref=0;
-
- if (r->keys)
- free(r->keys);
- if (r->vals)
- free(r->vals);
- if (r->roles_sid)
- free(r->roles_sid);
- if (r->memids)
- free(r->memids);
- if (r->types)
- free(r->types);
- old_info=r->info;
- *r=*relation;
- for (i = 0 ; i < r->n_memids ; i++) {
- r->memids[i]-=ref;
- ref+=r->memids[i];
- }
- if (!info) {
- if (old_info)
- osmpbf__info__free_unpacked(old_info, &protobuf_c_system_allocator);
- r->info=NULL;
- } else {
- if (old_info)
- r->info=old_info;
- else
- r->info=malloc(sizeof(*info));
- *r->info=*info;
- }
-
-}
-
-static int
-osm_protobufdb_string(struct osm_protobufdb_context *ctx, char *str)
-{
- char *strd;
- OSMPBF__StringTable *st=ctx->st;
-
- gpointer value;
- assert(ctx->string_hash != NULL);
- if (g_hash_table_lookup_extended(ctx->string_hash, str, NULL, &value)) {
- return (long)value;
- }
- if (!st->n_s) {
- st->n_s++;
- }
- strd=strdup(str);
- st->s=realloc(st->s, sizeof(st->s[0])*(st->n_s+1));
- if (st->n_s == 1) {
- st->s[0].data=NULL;
- st->s[0].len=0;
- }
- st->s[st->n_s].data=(unsigned char *)strd;
- st->s[st->n_s].len=strlen(strd);
- g_hash_table_insert(ctx->string_hash, strd, (gpointer)st->n_s);
- return st->n_s++;
-}
-
-
-static int
-osm_protobufdb_finish_file(struct osm_protobufdb_context *ctx)
-{
- osm_protobufdb_finish_block(ctx);
- if (ctx->f) {
- fclose(ctx->f);
- ctx->f=NULL;
- }
- ctx->current_file=-1;
- return 1;
-}
-
-
-static int
-osm_protobufdb_start_file(struct osm_protobufdb_context *ctx, int type, int num)
-{
- char name[1024];
- if (ctx->current_file == num)
- return 0;
- osm_protobufdb_finish_file(ctx);
- sprintf(name,"tst/%d-%08d",type,num);
- ctx->f=fopen(name,"w");
- ctx->current_file=num;
- ctx->current_block=0;
- ctx->active_block=-1;
- return 1;
-}
-
-static void
-test(void)
-{
-#if 0
- struct node n,o;
- long long id=1;
- long long lat=0;
- long long lon=0;
- long long timestamp=0;
- long long changeset=0;
- int version=1;
- int user_sid=0;
- int uid=0;
- int p;
- n.id=1;
-#endif
-#if 0
- OSMPBF__DenseInfo di=OSMPBF__DENSE_INFO__INIT;
- OSMPBF__DenseNodes dn=OSMPBF__DENSE_NODES__INIT;
-#endif
-
- context.current_file=-1;
-
-#if 0
- context.di=malloc(sizeof(*context.di));
- *context.di=di;
- context.dn=malloc(sizeof(*context.dn));
- *context.dn=dn;
-#endif
-
-#if 0
- di.n_version=1;
- di.version=&version;
- di.n_timestamp=1;
- di.timestamp=&timestamp;
- di.n_changeset=1;
- di.changeset=&changeset;
- di.n_user_sid=1;
- di.user_sid=&user_sid;
- di.n_uid=1;
- di.uid=&uid;
-#endif
-#if 0
- n.id=1;
- n.lat=1;
- n.lon=1;
- n.timestamp=1;
- n.changeset=1;
- n.version=1;
- n.user_sid=0;
- n.uid=0;
- p=osm_protobufdb_insert_densenode(&n.id, &o, &dn);
- osm_protobufdb_modify(&n, &o, p, &dn);
- p=osm_protobufdb_insert_densenode(&n.id, &o, &dn);
- osm_protobufdb_modify(&n, &o, p, &dn);
-#endif
-
-
-#if 0
- dn.n_id=1;
- dn.id=&id;
- dn.n_lat=1;
- dn.lat=&lat;
- dn.n_lon=1;
- dn.lon=&lon;
-#endif
-#if 0
- st.n_s=1;
- data.data="Test";
- data.len=4;
- st.s=&data;
-#endif
-}
-
-static void
-finish(void)
-{
- osm_protobufdb_finish_file(&context);
-#if 0
- osm_protobufdb_write_primitive_group(context.pg, context.pb);
- osm_protobufdb_write_primitive_block(context.pb, context.blob);
- osm_protobufdb_write_blob_to_file();
-#endif
-}
-
-static long long
-osm_protobufdb_timestamp(char *str)
-{
- struct tm tm;
- int res=sscanf(str,"%d-%d-%dT%d:%d:%dZ",&tm.tm_year,&tm.tm_mon,&tm.tm_mday,&tm.tm_hour,&tm.tm_min,&tm.tm_sec);
- if (res != 6)
- return 0;
- tm.tm_year-=1900;
- tm.tm_mon-=1;
+static int osm_protobufdb_insert_node(long long id, OSMPBF__PrimitiveGroup *pg) {
+ int l,p;
+ OSMPBF__Node node=OSMPBF__NODE__INIT;
+ l=pg->n_nodes;
+ p=l;
+ insert(pg, nodes, p);
+ pg->nodes[p]=g_malloc(sizeof(*pg->nodes[0]));
+ *pg->nodes[p]=node;
+ return p;
+}
+
+static void osm_protobufdb_modify_node(OSMPBF__Node *node, OSMPBF__Info *info, int pos, OSMPBF__PrimitiveGroup *pg) {
+ OSMPBF__Node *n=pg->nodes[pos];
+ OSMPBF__Info *old_info;
+
+ g_free(n->keys);
+ g_free(n->vals);
+ old_info=n->info;
+ *n=*node;
+ if (!info) {
+ if (old_info)
+ osmpbf__info__free_unpacked(old_info, NULL);
+ n->info=NULL;
+ } else {
+ if (old_info)
+ n->info=old_info;
+ else
+ n->info=g_malloc(sizeof(*info));
+ *n->info=*info;
+ }
+
+}
+
+static int osm_protobufdb_insert_way(long long id, OSMPBF__PrimitiveGroup *pg) {
+ int l,p;
+ OSMPBF__Way way=OSMPBF__WAY__INIT;
+ l=pg->n_ways;
+ p=l;
+ insert(pg, ways, p);
+ pg->ways[p]=g_malloc(sizeof(*pg->ways[0]));
+ *pg->ways[p]=way;
+ return p;
+}
+
+static void osm_protobufdb_modify_way(OSMPBF__Way *way, OSMPBF__Info *info, int pos, OSMPBF__PrimitiveGroup *pg) {
+ OSMPBF__Way *w=pg->ways[pos];
+ OSMPBF__Info *old_info;
+ int i;
+ long long ref=0;
+
+ g_free(w->keys);
+ g_free(w->vals);
+ g_free(w->refs);
+ old_info=w->info;
+ *w=*way;
+ for (i = 0 ; i < w->n_refs ; i++) {
+ w->refs[i]-=ref;
+ ref+=w->refs[i];
+ }
+ if (!info) {
+ if (old_info)
+ osmpbf__info__free_unpacked(old_info, NULL);
+ w->info=NULL;
+ } else {
+ if (old_info)
+ w->info=old_info;
+ else
+ w->info=g_malloc(sizeof(*info));
+ *w->info=*info;
+ }
+
+}
+
+static int osm_protobufdb_insert_relation(long long id, OSMPBF__PrimitiveGroup *pg) {
+ int l,p;
+ OSMPBF__Relation relation=OSMPBF__RELATION__INIT;
+ l=pg->n_relations;
+ p=l;
+ insert(pg, relations, p);
+ pg->relations[p]=g_malloc(sizeof(*pg->relations[0]));
+ *pg->relations[p]=relation;
+ return p;
+}
+
+static void osm_protobufdb_modify_relation(OSMPBF__Relation *relation, OSMPBF__Info *info, int pos,
+ OSMPBF__PrimitiveGroup *pg) {
+ OSMPBF__Relation *r=pg->relations[pos];
+ OSMPBF__Info *old_info;
+ int i;
+ long long ref=0;
+
+ g_free(r->keys);
+ g_free(r->vals);
+ g_free(r->roles_sid);
+ g_free(r->memids);
+ g_free(r->types);
+ old_info=r->info;
+ *r=*relation;
+ for (i = 0 ; i < r->n_memids ; i++) {
+ r->memids[i]-=ref;
+ ref+=r->memids[i];
+ }
+ if (!info) {
+ if (old_info)
+ osmpbf__info__free_unpacked(old_info, NULL);
+ r->info=NULL;
+ } else {
+ if (old_info)
+ r->info=old_info;
+ else
+ r->info=g_malloc(sizeof(*info));
+ *r->info=*info;
+ }
+
+}
+
+static int osm_protobufdb_string(struct osm_protobufdb_context *ctx, char *str) {
+ char *strd;
+ OSMPBF__StringTable *st=ctx->st;
+
+ gpointer value;
+ assert(ctx->string_hash != NULL);
+ if (g_hash_table_lookup_extended(ctx->string_hash, str, NULL, &value)) {
+ return (long)value;
+ }
+ if (!st->n_s) {
+ st->n_s++;
+ }
+ strd=g_strdup(str);
+ st->s=g_realloc(st->s, sizeof(st->s[0])*(st->n_s+1));
+ if (st->n_s == 1) {
+ st->s[0].data=NULL;
+ st->s[0].len=0;
+ }
+ st->s[st->n_s].data=(unsigned char *)strd;
+ st->s[st->n_s].len=strlen(strd);
+ g_hash_table_insert(ctx->string_hash, strd, (gpointer)st->n_s);
+ return st->n_s++;
+}
+
+
+static int osm_protobufdb_finish_file(struct osm_protobufdb_context *ctx) {
+ osm_protobufdb_finish_block(ctx);
+ if (ctx->f) {
+ fclose(ctx->f);
+ ctx->f=NULL;
+ }
+ ctx->current_file=-1;
+ return 1;
+}
+
+
+static int osm_protobufdb_start_file(struct osm_protobufdb_context *ctx, int type, int num) {
+ char name[1024];
+ if (ctx->current_file == num)
+ return 0;
+ osm_protobufdb_finish_file(ctx);
+ sprintf(name,"tst/%d-%08d",type,num);
+ ctx->f=fopen(name,"w");
+ ctx->current_file=num;
+ ctx->current_block=0;
+ ctx->active_block=-1;
+ return 1;
+}
+
+static void test(void) {
+ context.current_file=-1;
+}
+
+static void finish(void) {
+ osm_protobufdb_finish_file(&context);
+}
+
+static long long osm_protobufdb_timestamp(char *str) {
+ struct tm tm;
+ int res=sscanf(str,"%d-%d-%dT%d:%d:%dZ",&tm.tm_year,&tm.tm_mon,&tm.tm_mday,&tm.tm_hour,&tm.tm_min,&tm.tm_sec);
+ if (res != 6)
+ return 0;
+ tm.tm_year-=1900;
+ tm.tm_mon-=1;
#if defined(HAVE_API_WIN32_BASE) || defined(ANDROID)
- return 0;
+ return 0;
#else
- return timegm(&tm);
+ return timegm(&tm);
#endif
}
-static void
-osm_protobufdb_parse_info(struct osm_protobufdb_context *ctx, char *str)
-{
- char version[1024];
- char changeset[1024];
- char user[1024];
- char uid[1024];
- char timestamp[1024];
-
- OSMPBF__Info *i=&ctx->i, ii=OSMPBF__INFO__INIT;
- *i=ii;
- if (osm_xml_get_attribute(str, "version", version, sizeof(version))) {
- i->version=atoi(version);
- i->has_version=1;
- }
- if (osm_xml_get_attribute(str, "changeset", changeset, sizeof(changeset))) {
- i->changeset=atoll(changeset);
- i->has_changeset=1;
- }
- if (osm_xml_get_attribute(str, "user", user, sizeof(user))) {
- osm_xml_decode_entities(user);
- i->user_sid=osm_protobufdb_string(ctx, user);
- i->has_user_sid=1;
- }
- if (osm_xml_get_attribute(str, "uid", uid, sizeof(uid))) {
- i->uid=atoi(uid);
- i->has_uid=1;
- }
- if (osm_xml_get_attribute(str, "timestamp", timestamp, sizeof(timestamp))) {
- i->timestamp=osm_protobufdb_timestamp(timestamp);
- i->has_timestamp=1;
- }
-}
-
-static int
-osm_protobufdb_parse_node(struct osm_protobufdb_context *ctx, char *str)
-{
- char id[1024];
- char lat[1024];
- char lon[1024];
- OSMPBF__Node *n=&ctx->n, ni=OSMPBF__NODE__INIT;
-
- *n=ni;
- if (!osm_xml_get_attribute(str, "id", id, sizeof(id)))
- return 0;
- if (!osm_xml_get_attribute(str, "lat", lat, sizeof(lat)))
- return 0;
- if (!osm_xml_get_attribute(str, "lon", lon, sizeof(lon)))
- return 0;
- n->id=atoll(id);
- n->lat=atof(lat)*latlon_scale+0.5;
- n->lon=atof(lon)*latlon_scale+0.5;
- int file=n->id/db_config.node_ids_per_file;
- int fileo=n->id%db_config.node_ids_per_file;
- int blob=fileo/db_config.node_ids_per_blob;
- int blobo=fileo%db_config.node_ids_per_blob;
- int group=blobo/db_config.node_ids_per_group;
-
- osm_protobufdb_start_file(ctx, 1, file);
- osm_protobufdb_start_block(ctx, blob);
- osm_protobufdb_start_group(ctx, group);
- osm_protobufdb_parse_info(ctx, str);
- ctx->in_node=1;
- return 1;
-}
-
-static int
-osm_protobufdb_end_node(struct osm_protobufdb_context *ctx)
-{
- int p;
-#if 0
- OSMPBF__Node *n=&ctx->n,offset;
- OSMPBF__Info *i=&ctx->i,offseti;
- osm_protobufdb_start_densenode(ctx);
- p=osm_protobufdb_insert_densenode(n->id, &offset, &offseti, context.dn);
- osm_protobufdb_modify_densenode(n, i, &offset, &offseti, p, context.dn);
-#else
- p=osm_protobufdb_insert_node(ctx->n.id, ctx->pg);
- osm_protobufdb_modify_node(&ctx->n, &ctx->i, p, ctx->pg);
-#endif
- ctx->in_node=0;
- return 1;
-}
-
-
-static int
-osm_protobufdb_parse_way(struct osm_protobufdb_context *ctx, char *str)
-{
- char id[1024];
- OSMPBF__Way *w=&ctx->w, wi=OSMPBF__WAY__INIT;
-
- *w=wi;
- if (!osm_xml_get_attribute(str, "id", id, sizeof(id)))
- return 0;
- w->id=atoll(id);
- int file=w->id/db_config.way_ids_per_file;
- int fileo=w->id%db_config.way_ids_per_file;
- int blob=fileo/db_config.way_ids_per_blob;
- int blobo=fileo%db_config.way_ids_per_blob;
- int group=blobo/db_config.way_ids_per_group;
-
- osm_protobufdb_start_file(ctx, 2, file);
- osm_protobufdb_start_block(ctx, blob);
- osm_protobufdb_start_group(ctx, group);
- osm_protobufdb_parse_info(ctx, str);
- ctx->in_way=1;
- return 1;
-}
-
-static int
-osm_protobufdb_end_way(struct osm_protobufdb_context *ctx)
-{
- int p;
- p=osm_protobufdb_insert_way(ctx->w.id, ctx->pg);
- osm_protobufdb_modify_way(&ctx->w, &ctx->i, p, ctx->pg);
- ctx->in_way=0;
- return 1;
-}
-
-static int
-osm_protobufdb_parse_relation(struct osm_protobufdb_context *ctx, char *str)
-{
- char id[1024];
- OSMPBF__Relation *r=&ctx->r, ri=OSMPBF__RELATION__INIT;
-
- *r=ri;
- if (!osm_xml_get_attribute(str, "id", id, sizeof(id)))
- return 0;
- r->id=atoll(id);
- int file=r->id/db_config.relation_ids_per_file;
- int fileo=r->id%db_config.relation_ids_per_file;
- int blob=fileo/db_config.relation_ids_per_blob;
- int blobo=fileo%db_config.relation_ids_per_blob;
- int group=blobo/db_config.relation_ids_per_group;
-
- osm_protobufdb_start_file(ctx, 3, file);
- osm_protobufdb_start_block(ctx, blob);
- osm_protobufdb_start_group(ctx, group);
- osm_protobufdb_parse_info(ctx, str);
- ctx->in_relation=1;
- return 1;
-}
-
-static int
-osm_protobufdb_end_relation(struct osm_protobufdb_context *ctx)
-{
- int p;
- p=osm_protobufdb_insert_relation(ctx->r.id, ctx->pg);
- osm_protobufdb_modify_relation(&ctx->r, &ctx->i, p, ctx->pg);
- ctx->in_node=0;
- return 1;
-}
-
-static int
-osm_protobufdb_parse_tag(struct osm_protobufdb_context *ctx, char *str)
-{
- OSMPBF__Node *n=&ctx->n;
- OSMPBF__Way *w=&ctx->w;
- OSMPBF__Relation *r=&ctx->r;
- char k_buffer[BUFFER_SIZE];
- char v_buffer[BUFFER_SIZE];
- if (!osm_xml_get_attribute(str, "k", k_buffer, BUFFER_SIZE))
- return 0;
- if (!osm_xml_get_attribute(str, "v", v_buffer, BUFFER_SIZE))
- return 0;
- osm_xml_decode_entities(v_buffer);
- if (ctx->in_node) {
- n->keys=realloc(n->keys, (n->n_keys+1)*sizeof(n->keys[0]));
- n->vals=realloc(n->vals, (n->n_vals+1)*sizeof(n->vals[0]));
- n->keys[n->n_keys++]=osm_protobufdb_string(ctx, k_buffer);
- n->vals[n->n_vals++]=osm_protobufdb_string(ctx, v_buffer);
- }
- if (ctx->in_way) {
- w->keys=realloc(w->keys, (w->n_keys+1)*sizeof(w->keys[0]));
- w->vals=realloc(w->vals, (w->n_vals+1)*sizeof(w->vals[0]));
- w->keys[w->n_keys++]=osm_protobufdb_string(ctx, k_buffer);
- w->vals[w->n_vals++]=osm_protobufdb_string(ctx, v_buffer);
- }
- if (ctx->in_relation) {
- r->keys=realloc(r->keys, (r->n_keys+1)*sizeof(r->keys[0]));
- r->vals=realloc(r->vals, (r->n_vals+1)*sizeof(r->vals[0]));
- r->keys[r->n_keys++]=osm_protobufdb_string(ctx, k_buffer);
- r->vals[r->n_vals++]=osm_protobufdb_string(ctx, v_buffer);
- }
- return 1;
-}
-
-static int
-osm_protobufdb_parse_nd(struct osm_protobufdb_context *ctx, char *str)
-{
- OSMPBF__Way *w=&ctx->w;
- char ref_buffer[BUFFER_SIZE];
- if (!osm_xml_get_attribute(str, "ref", ref_buffer, BUFFER_SIZE))
- return 0;
- if (ctx->in_way) {
- w->refs=realloc(w->refs, (w->n_refs+1)*sizeof(w->refs[0]));
- w->refs[w->n_refs++]=atoll(ref_buffer);
- }
- return 1;
-}
-
-static int
-osm_protobufdb_parse_member(struct osm_protobufdb_context *ctx, char *str)
-{
- OSMPBF__Relation *r=&ctx->r;
- char type_buffer[BUFFER_SIZE];
- char ref_buffer[BUFFER_SIZE];
- char role_buffer[BUFFER_SIZE];
- int type=0;
- if (!osm_xml_get_attribute(str, "type", type_buffer, BUFFER_SIZE))
- return 0;
- if (!osm_xml_get_attribute(str, "ref", ref_buffer, BUFFER_SIZE))
- return 0;
- if (!osm_xml_get_attribute(str, "role", role_buffer, BUFFER_SIZE))
- return 0;
- if (!strcmp(type_buffer,"node"))
- type=0;
- else if (!strcmp(type_buffer,"way"))
- type=1;
- else if (!strcmp(type_buffer,"relation"))
- type=2;
- if (ctx->in_relation) {
- r->roles_sid=realloc(r->roles_sid, (r->n_roles_sid+1)*sizeof(r->roles_sid[0]));
- r->roles_sid[r->n_roles_sid++]=osm_protobufdb_string(ctx, role_buffer);
- r->memids=realloc(r->memids, (r->n_memids+1)*sizeof(r->memids[0]));
- r->memids[r->n_memids++]=atoll(ref_buffer);
- r->types=realloc(r->types, (r->n_types+1)*sizeof(r->types[0]));
- r->types[r->n_types++]=type;
- }
- return 1;
-}
-
-
-
-int
-osm_protobufdb_load(FILE *in, char *dir)
-{
- int size=BUFFER_SIZE;
- char buffer[size];
- char *p;
- sig_alrm(0);
- test();
- while (fgets(buffer, size, in)) {
- int closed=strstr(buffer,"/>")?1:0;
- p=strchr(buffer,'<');
- if (! p) {
- fprintf(stderr,"WARNING: wrong line %s\n", buffer);
- continue;
- }
- if (!strncmp(p, "<?xml ",6)) {
- } else if (!strncmp(p, "<osm ",5)) {
- } else if (!strncmp(p, "<bound ",7)) {
- } else if (!strncmp(p, "<node ",6)) {
- if (!osm_protobufdb_parse_node(&context, p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- if (closed)
- osm_protobufdb_end_node(&context);
- processed_nodes++;
- } else if (!strncmp(p, "<tag ",5)) {
- if (!osm_protobufdb_parse_tag(&context, p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- } else if (!strncmp(p, "<way ",5)) {
- if (!osm_protobufdb_parse_way(&context, p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- if (closed)
- osm_protobufdb_end_way(&context);
- processed_ways++;
- } else if (!strncmp(p, "<nd ",4)) {
- if (!osm_protobufdb_parse_nd(&context, p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- } else if (!strncmp(p, "<relation ",10)) {
- if (!osm_protobufdb_parse_relation(&context, p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- processed_relations++;
- } else if (!strncmp(p, "<member ",8)) {
- if (!osm_protobufdb_parse_member(&context, p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- } else if (!strncmp(p, "</node>",7)) {
- osm_protobufdb_end_node(&context);
- } else if (!strncmp(p, "</way>",6)) {
- osm_protobufdb_end_way(&context);
- } else if (!strncmp(p, "</relation>",11)) {
- osm_protobufdb_end_relation(&context);
- } else if (!strncmp(p, "</osm>",6)) {
- } else {
- fprintf(stderr,"WARNING: unknown tag in %s\n", buffer);
- }
- }
- finish();
- return 1;
+static void osm_protobufdb_parse_info(struct osm_protobufdb_context *ctx, char *str) {
+ char version[1024];
+ char changeset[1024];
+ char user[1024];
+ char uid[1024];
+ char timestamp[1024];
+
+ OSMPBF__Info *i=&ctx->i, ii=OSMPBF__INFO__INIT;
+ *i=ii;
+ if (osm_xml_get_attribute(str, "version", version, sizeof(version))) {
+ i->version=atoi(version);
+ i->has_version=1;
+ }
+ if (osm_xml_get_attribute(str, "changeset", changeset, sizeof(changeset))) {
+ i->changeset=atoll(changeset);
+ i->has_changeset=1;
+ }
+ if (osm_xml_get_attribute(str, "user", user, sizeof(user))) {
+ osm_xml_decode_entities(user);
+ i->user_sid=osm_protobufdb_string(ctx, user);
+ i->has_user_sid=1;
+ }
+ if (osm_xml_get_attribute(str, "uid", uid, sizeof(uid))) {
+ i->uid=atoi(uid);
+ i->has_uid=1;
+ }
+ if (osm_xml_get_attribute(str, "timestamp", timestamp, sizeof(timestamp))) {
+ i->timestamp=osm_protobufdb_timestamp(timestamp);
+ i->has_timestamp=1;
+ }
+}
+
+static int osm_protobufdb_parse_node(struct osm_protobufdb_context *ctx, char *str) {
+ char id[1024];
+ char lat[1024];
+ char lon[1024];
+ OSMPBF__Node *n=&ctx->n, ni=OSMPBF__NODE__INIT;
+
+ *n=ni;
+ if (!osm_xml_get_attribute(str, "id", id, sizeof(id)))
+ return 0;
+ if (!osm_xml_get_attribute(str, "lat", lat, sizeof(lat)))
+ return 0;
+ if (!osm_xml_get_attribute(str, "lon", lon, sizeof(lon)))
+ return 0;
+ n->id=atoll(id);
+ n->lat=atof(lat)*latlon_scale+0.5;
+ n->lon=atof(lon)*latlon_scale+0.5;
+ int file=n->id/db_config.node_ids_per_file;
+ int fileo=n->id%db_config.node_ids_per_file;
+ int blob=fileo/db_config.node_ids_per_blob;
+ int blobo=fileo%db_config.node_ids_per_blob;
+ int group=blobo/db_config.node_ids_per_group;
+
+ osm_protobufdb_start_file(ctx, 1, file);
+ osm_protobufdb_start_block(ctx, blob);
+ osm_protobufdb_start_group(ctx, group);
+ osm_protobufdb_parse_info(ctx, str);
+ ctx->in_node=1;
+ return 1;
+}
+
+static int osm_protobufdb_end_node(struct osm_protobufdb_context *ctx) {
+ int p;
+ p=osm_protobufdb_insert_node(ctx->n.id, ctx->pg);
+ osm_protobufdb_modify_node(&ctx->n, &ctx->i, p, ctx->pg);
+ ctx->in_node=0;
+ return 1;
+}
+
+
+static int osm_protobufdb_parse_way(struct osm_protobufdb_context *ctx, char *str) {
+ char id[1024];
+ OSMPBF__Way *w=&ctx->w, wi=OSMPBF__WAY__INIT;
+
+ *w=wi;
+ if (!osm_xml_get_attribute(str, "id", id, sizeof(id)))
+ return 0;
+ w->id=atoll(id);
+ int file=w->id/db_config.way_ids_per_file;
+ int fileo=w->id%db_config.way_ids_per_file;
+ int blob=fileo/db_config.way_ids_per_blob;
+ int blobo=fileo%db_config.way_ids_per_blob;
+ int group=blobo/db_config.way_ids_per_group;
+
+ osm_protobufdb_start_file(ctx, 2, file);
+ osm_protobufdb_start_block(ctx, blob);
+ osm_protobufdb_start_group(ctx, group);
+ osm_protobufdb_parse_info(ctx, str);
+ ctx->in_way=1;
+ return 1;
+}
+
+static int osm_protobufdb_end_way(struct osm_protobufdb_context *ctx) {
+ int p;
+ p=osm_protobufdb_insert_way(ctx->w.id, ctx->pg);
+ osm_protobufdb_modify_way(&ctx->w, &ctx->i, p, ctx->pg);
+ ctx->in_way=0;
+ return 1;
+}
+
+static int osm_protobufdb_parse_relation(struct osm_protobufdb_context *ctx, char *str) {
+ char id[1024];
+ OSMPBF__Relation *r=&ctx->r, ri=OSMPBF__RELATION__INIT;
+
+ *r=ri;
+ if (!osm_xml_get_attribute(str, "id", id, sizeof(id)))
+ return 0;
+ r->id=atoll(id);
+ int file=r->id/db_config.relation_ids_per_file;
+ int fileo=r->id%db_config.relation_ids_per_file;
+ int blob=fileo/db_config.relation_ids_per_blob;
+ int blobo=fileo%db_config.relation_ids_per_blob;
+ int group=blobo/db_config.relation_ids_per_group;
+
+ osm_protobufdb_start_file(ctx, 3, file);
+ osm_protobufdb_start_block(ctx, blob);
+ osm_protobufdb_start_group(ctx, group);
+ osm_protobufdb_parse_info(ctx, str);
+ ctx->in_relation=1;
+ return 1;
+}
+
+static int osm_protobufdb_end_relation(struct osm_protobufdb_context *ctx) {
+ int p;
+ p=osm_protobufdb_insert_relation(ctx->r.id, ctx->pg);
+ osm_protobufdb_modify_relation(&ctx->r, &ctx->i, p, ctx->pg);
+ ctx->in_node=0;
+ return 1;
+}
+
+static int osm_protobufdb_parse_tag(struct osm_protobufdb_context *ctx, char *str) {
+ OSMPBF__Node *n=&ctx->n;
+ OSMPBF__Way *w=&ctx->w;
+ OSMPBF__Relation *r=&ctx->r;
+ char k_buffer[BUFFER_SIZE];
+ char v_buffer[BUFFER_SIZE];
+ if (!osm_xml_get_attribute(str, "k", k_buffer, BUFFER_SIZE))
+ return 0;
+ if (!osm_xml_get_attribute(str, "v", v_buffer, BUFFER_SIZE))
+ return 0;
+ osm_xml_decode_entities(v_buffer);
+ if (ctx->in_node) {
+ n->keys=g_realloc(n->keys, (n->n_keys+1)*sizeof(n->keys[0]));
+ n->vals=g_realloc(n->vals, (n->n_vals+1)*sizeof(n->vals[0]));
+ n->keys[n->n_keys++]=osm_protobufdb_string(ctx, k_buffer);
+ n->vals[n->n_vals++]=osm_protobufdb_string(ctx, v_buffer);
+ }
+ if (ctx->in_way) {
+ w->keys=g_realloc(w->keys, (w->n_keys+1)*sizeof(w->keys[0]));
+ w->vals=g_realloc(w->vals, (w->n_vals+1)*sizeof(w->vals[0]));
+ w->keys[w->n_keys++]=osm_protobufdb_string(ctx, k_buffer);
+ w->vals[w->n_vals++]=osm_protobufdb_string(ctx, v_buffer);
+ }
+ if (ctx->in_relation) {
+ r->keys=g_realloc(r->keys, (r->n_keys+1)*sizeof(r->keys[0]));
+ r->vals=g_realloc(r->vals, (r->n_vals+1)*sizeof(r->vals[0]));
+ r->keys[r->n_keys++]=osm_protobufdb_string(ctx, k_buffer);
+ r->vals[r->n_vals++]=osm_protobufdb_string(ctx, v_buffer);
+ }
+ return 1;
+}
+
+static int osm_protobufdb_parse_nd(struct osm_protobufdb_context *ctx, char *str) {
+ OSMPBF__Way *w=&ctx->w;
+ char ref_buffer[BUFFER_SIZE];
+ if (!osm_xml_get_attribute(str, "ref", ref_buffer, BUFFER_SIZE))
+ return 0;
+ if (ctx->in_way) {
+ w->refs=g_realloc(w->refs, (w->n_refs+1)*sizeof(w->refs[0]));
+ w->refs[w->n_refs++]=atoll(ref_buffer);
+ }
+ return 1;
+}
+
+static int osm_protobufdb_parse_member(struct osm_protobufdb_context *ctx, char *str) {
+ OSMPBF__Relation *r=&ctx->r;
+ char type_buffer[BUFFER_SIZE];
+ char ref_buffer[BUFFER_SIZE];
+ char role_buffer[BUFFER_SIZE];
+ int type=0;
+ if (!osm_xml_get_attribute(str, "type", type_buffer, BUFFER_SIZE))
+ return 0;
+ if (!osm_xml_get_attribute(str, "ref", ref_buffer, BUFFER_SIZE))
+ return 0;
+ if (!osm_xml_get_attribute(str, "role", role_buffer, BUFFER_SIZE))
+ return 0;
+ if (!g_strcmp0(type_buffer,"node"))
+ type=0;
+ else if (!g_strcmp0(type_buffer,"way"))
+ type=1;
+ else if (!g_strcmp0(type_buffer,"relation"))
+ type=2;
+ if (ctx->in_relation) {
+ r->roles_sid=g_realloc(r->roles_sid, (r->n_roles_sid+1)*sizeof(r->roles_sid[0]));
+ r->roles_sid[r->n_roles_sid++]=osm_protobufdb_string(ctx, role_buffer);
+ r->memids=g_realloc(r->memids, (r->n_memids+1)*sizeof(r->memids[0]));
+ r->memids[r->n_memids++]=atoll(ref_buffer);
+ r->types=g_realloc(r->types, (r->n_types+1)*sizeof(r->types[0]));
+ r->types[r->n_types++]=type;
+ }
+ return 1;
+}
+
+
+
+int osm_protobufdb_load(FILE *in, char *dir) {
+ int size=BUFFER_SIZE;
+ char buffer[size];
+ char *p;
+ sig_alrm(0);
+ test();
+ while (fgets(buffer, size, in)) {
+ int closed=strstr(buffer,"/>")?1:0;
+ p=strchr(buffer,'<');
+ if (! p) {
+ fprintf(stderr,"WARNING: wrong line %s\n", buffer);
+ continue;
+ }
+ if (!strncmp(p, "<?xml ",6)) {
+ } else if (!strncmp(p, "<osm ",5)) {
+ } else if (!strncmp(p, "<bound ",7)) {
+ } else if (!strncmp(p, "<node ",6)) {
+ if (!osm_protobufdb_parse_node(&context, p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ if (closed)
+ osm_protobufdb_end_node(&context);
+ processed_nodes++;
+ } else if (!strncmp(p, "<tag ",5)) {
+ if (!osm_protobufdb_parse_tag(&context, p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ } else if (!strncmp(p, "<way ",5)) {
+ if (!osm_protobufdb_parse_way(&context, p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ if (closed)
+ osm_protobufdb_end_way(&context);
+ processed_ways++;
+ } else if (!strncmp(p, "<nd ",4)) {
+ if (!osm_protobufdb_parse_nd(&context, p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ } else if (!strncmp(p, "<relation ",10)) {
+ if (!osm_protobufdb_parse_relation(&context, p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ processed_relations++;
+ } else if (!strncmp(p, "<member ",8)) {
+ if (!osm_protobufdb_parse_member(&context, p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ } else if (!strncmp(p, "</node>",7)) {
+ osm_protobufdb_end_node(&context);
+ } else if (!strncmp(p, "</way>",6)) {
+ osm_protobufdb_end_way(&context);
+ } else if (!strncmp(p, "</relation>",11)) {
+ osm_protobufdb_end_relation(&context);
+ } else if (!strncmp(p, "</osm>",6)) {
+ } else {
+ fprintf(stderr,"WARNING: unknown tag in %s\n", buffer);
+ }
+ }
+ finish();
+ return 1;
}
diff --git a/navit/maptool/osm_psql.c b/navit/maptool/osm_psql.c
index 53ba780bc..a8dac6914 100644
--- a/navit/maptool/osm_psql.c
+++ b/navit/maptool/osm_psql.c
@@ -25,165 +25,248 @@
#include "linguistics.h"
#include "file.h"
#ifdef HAVE_POSTGRESQL
-#include <libpq-fe.h>
+#include <postgresql/libpq-fe.h>
-int
-map_collect_data_osm_db(char *dbstr, struct maptool_osm *osm)
-{
- PGconn *conn;
- PGresult *res,*node,*way,*tag;
- int count,tagged,i,j,k;
- long min, max, id, tag_id, node_id;
- char query[256];
-
- sig_alrm(0);
- conn=PQconnectdb(dbstr);
- if (! conn) {
- fprintf(stderr,"Failed to connect to database with '%s'\n",dbstr);
- exit(1);
- }
- res=PQexec(conn, "begin");
- if (! res) {
- fprintf(stderr, "Cannot begin transaction: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- res=PQexec(conn, "set transaction isolation level serializable");
- if (! res) {
- fprintf(stderr, "Cannot set isolation level: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- res=PQexec(conn, "declare node cursor for select id,x(coordinate),y(coordinate) from node order by id");
- if (! res) {
- fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- res=PQexec(conn, "declare way cursor for select id from way order by id");
- if (! res) {
- fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- res=PQexec(conn, "declare relation cursor for select id from relation order by id");
- if (! res) {
- fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- for (;;) {
- node=PQexec(conn, "fetch 100000 from node");
- if (! node) {
- fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
- PQclear(node);
- exit(1);
- }
- count=PQntuples(node);
- if (! count)
- break;
- min=atol(PQgetvalue(node, 0, 0));
- max=atol(PQgetvalue(node, count-1, 0));
- sprintf(query,"select node_id,name,value from node_tag where node_id >= %ld and node_id <= %ld order by node_id", min, max);
- tag=PQexec(conn, query);
- if (! tag) {
- fprintf(stderr, "Cannot query node_tag: %s\n", PQerrorMessage(conn));
- exit(1);
- }
- j=0;
- for (i = 0 ; i < count ; i++) {
- id=atol(PQgetvalue(node, i, 0));
- osm_add_node(id, atof(PQgetvalue(node, i, 1)), atof(PQgetvalue(node, i, 2)));
- tagged=0;
- processed_nodes++;
- while (j < PQntuples(tag)) {
- tag_id=atol(PQgetvalue(tag, j, 0));
- if (tag_id == id) {
- osm_add_tag(PQgetvalue(tag, j, 1), PQgetvalue(tag, j, 2));
- tagged=1;
- j++;
- }
- if (tag_id < id)
- j++;
- if (tag_id > id)
- break;
- }
- osm_end_node(osm);
- }
- PQclear(tag);
- PQclear(node);
- }
- for (;;) {
- way=PQexec(conn, "fetch 100000 from way");
- if (! way) {
- fprintf(stderr, "Cannot setup cursor for ways: %s\n", PQerrorMessage(conn));
- PQclear(node);
- exit(1);
- }
- count=PQntuples(way);
- if (! count)
- break;
- min=atol(PQgetvalue(way, 0, 0));
- max=atol(PQgetvalue(way, count-1, 0));
- sprintf(query,"select way_id,node_id from way_node where way_id >= %ld and way_id <= %ld order by way_id,sequence_id", min, max);
- node=PQexec(conn, query);
- if (! node) {
- fprintf(stderr, "Cannot query way_node: %s\n", PQerrorMessage(conn));
- exit(1);
- }
- sprintf(query,"select way_id,name,value from way_tag where way_id >= %ld and way_id <= %ld order by way_id", min, max);
- tag=PQexec(conn, query);
- if (! tag) {
- fprintf(stderr, "Cannot query way_tag: %s\n", PQerrorMessage(conn));
- exit(1);
- }
- j=0;
- k=0;
- for (i = 0 ; i < count ; i++) {
- id=atol(PQgetvalue(way, i, 0));
- osm_add_way(id);
- tagged=0;
- processed_ways++;
- while (k < PQntuples(node)) {
- node_id=atol(PQgetvalue(node, k, 0));
- if (node_id == id) {
- osm_add_nd(atoll(PQgetvalue(node, k, 1)));
- tagged=1;
- k++;
- }
- if (node_id < id)
- k++;
- if (node_id > id)
- break;
- }
- while (j < PQntuples(tag)) {
- tag_id=atol(PQgetvalue(tag, j, 0));
- if (tag_id == id) {
- osm_add_tag(PQgetvalue(tag, j, 1), PQgetvalue(tag, j, 2));
- tagged=1;
- j++;
- }
- if (tag_id < id)
- j++;
- if (tag_id > id)
- break;
- }
- if (tagged)
- osm_end_way(osm);
- }
- PQclear(tag);
- PQclear(node);
- PQclear(way);
- }
+int map_collect_data_osm_db(char *dbstr, struct maptool_osm *osm) {
+ PGconn *conn;
+ PGresult *res;
+ char query[256];
- res=PQexec(conn, "commit");
- if (! res) {
- fprintf(stderr, "Cannot commit transaction: %s\n", PQerrorMessage(conn));
- PQclear(res);
- exit(1);
- }
- sig_alrm(0);
- sig_alrm_end();
- return 1;
+ sig_alrm(0);
+ conn=PQconnectdb(dbstr);
+ if (! conn) {
+ fprintf(stderr,"Failed to connect to database with '%s'\n",dbstr);
+ exit(1);
+ }
+ fprintf(stderr,"connected to database with '%s'\n",dbstr);
+ res=PQexec(conn, "begin");
+ if (! res) {
+ fprintf(stderr, "Cannot begin transaction: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ res=PQexec(conn, "set transaction isolation level serializable");
+ if (! res) {
+ fprintf(stderr, "Cannot set isolation level: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ res=PQexec(conn, "declare nodes cursor for select id, ST_Y(geom), ST_X(geom) from nodes order by id");
+ if (! res) {
+ fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ res=PQexec(conn, "declare ways cursor for select id from ways order by id");
+ if (! res) {
+ fprintf(stderr, "Cannot setup cursor for ways: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ res=PQexec(conn, "declare relations cursor for select id from relations order by id");
+ if (! res) {
+ fprintf(stderr, "Cannot setup cursor for relations: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+
+ for (;;) {
+ int j=0, count=0;
+ long min, max, id, tag_id;
+ PGresult *node, *tag;
+ node=PQexec(conn, "fetch 100000 from nodes");
+ if (! node) {
+ fprintf(stderr, "Cannot setup cursor for nodes: %s\n", PQerrorMessage(conn));
+ PQclear(node);
+ exit(1);
+ }
+ count=PQntuples(node);
+ fprintf(stderr, "fetch got %i nodes\n", count);
+ if (! count)
+ break;
+ min=atol(PQgetvalue(node, 0, 0));
+ max=atol(PQgetvalue(node, count-1, 0));
+ sprintf(query,"select node_id,k,v from node_tags where node_id >= %ld and node_id <= %ld order by node_id", min, max);
+ tag=PQexec(conn, query);
+ if (! tag) {
+ fprintf(stderr, "Cannot query node_tag: %s\n", PQerrorMessage(conn));
+ exit(1);
+ }
+ fprintf(stderr, "query node_tag got : %i tuples\n", PQntuples(tag));
+ for (int i = 0 ; i < count ; i++) {
+ id=atol(PQgetvalue(node, i, 0));
+ osm_add_node(id, atof(PQgetvalue(node, i, 1)), atof(PQgetvalue(node, i, 2)));
+ processed_nodes++;
+ while (j < PQntuples(tag)) {
+ tag_id=atol(PQgetvalue(tag, j, 0));
+ if (tag_id == id) {
+ osm_add_tag(PQgetvalue(tag, j, 1), PQgetvalue(tag, j, 2));
+ j++;
+ }
+ if (tag_id < id)
+ j++;
+ if (tag_id > id)
+ break;
+ }
+ osm_end_node(osm);
+ }
+ PQclear(tag);
+ PQclear(node);
+ }
+
+ for (;;) {
+ int j=0, k=0, count=0, tagged=0;
+ long min, max, id, tag_id, node_id;
+ PGresult *node,*way,*tag;
+ way=PQexec(conn, "fetch 25000 from ways");
+ if (! way) {
+ fprintf(stderr, "Cannot setup cursor for ways: %s\n", PQerrorMessage(conn));
+ PQclear(way);
+ exit(1);
+ }
+ count=PQntuples(way);
+ fprintf(stderr, "fetch got %i ways\n", count);
+ if (! count)
+ break;
+ min=atol(PQgetvalue(way, 0, 0));
+ max=atol(PQgetvalue(way, count-1, 0));
+ fprintf(stderr, "continue with %i ways\n", count);
+ sprintf(query,"select way_id,node_id from way_nodes where way_id >= %ld and way_id <= %ld order by way_id,sequence_id",
+ min, max);
+ node=PQexec(conn, query);
+ if (! node) {
+ fprintf(stderr, "Cannot query way_node: %s\n", PQerrorMessage(conn));
+ exit(1);
+ }
+ sprintf(query,"select way_id,k,v from way_tags where way_id >= %ld and way_id <= %ld order by way_id", min, max);
+ tag=PQexec(conn, query);
+ if (! tag) {
+ fprintf(stderr, "Cannot query way_tag: %s\n", PQerrorMessage(conn));
+ exit(1);
+ }
+ for (int i = 0 ; i < count ; i++) {
+ id=atol(PQgetvalue(way, i, 0));
+ osm_add_way(id);
+ tagged=0;
+ processed_ways++;
+ while (k < PQntuples(node)) {
+ node_id=atol(PQgetvalue(node, k, 0));
+ if (node_id == id) {
+ osm_add_nd(atoll(PQgetvalue(node, k, 1)));
+ tagged=1;
+ k++;
+ }
+ if (node_id < id)
+ k++;
+ if (node_id > id)
+ break;
+ }
+ while (j < PQntuples(tag)) {
+ tag_id=atol(PQgetvalue(tag, j, 0));
+ if (tag_id == id) {
+ osm_add_tag(PQgetvalue(tag, j, 1), PQgetvalue(tag, j, 2));
+ tagged=1;
+ j++;
+ }
+ if (tag_id < id)
+ j++;
+ if (tag_id > id)
+ break;
+ }
+ if (tagged)
+ osm_end_way(osm);
+ }
+ PQclear(tag);
+ PQclear(node);
+ PQclear(way);
+ }
+
+ for (;;) {
+ int j=0, k=0, count=0, tagged=0;
+ long min, max, id;
+ PGresult *tag, *relation, *member;
+ relation=PQexec(conn, "fetch 40000 from relations");
+ if (! relation) {
+ fprintf(stderr, "Cannot setup cursor for relations: %s\n", PQerrorMessage(conn));
+ PQclear(relation);
+ exit(1);
+ }
+ count=PQntuples(relation);
+ fprintf(stderr, "Got %i relations\n", count);
+ if (! count)
+ break;
+ min=atol(PQgetvalue(relation, 0, 0));
+ max=atol(PQgetvalue(relation, count-1, 0));
+ sprintf(query,
+ "select relation_id,k,v from relation_tags where relation_id >= %ld and relation_id <= %ld order by relation_id", min,
+ max);
+ tag=PQexec(conn, query);
+ if (! tag) {
+ fprintf(stderr, "Cannot query relation_tag: %s\n", PQerrorMessage(conn));
+ exit(1);
+ }
+ sprintf(query,
+ "select relation_id, member_id, member_type, member_role from relation_members where relation_id >= %ld and relation_id <= %ld order by relation_id, sequence_id",
+ min, max);
+ member=PQexec(conn, query);
+ if (! member) {
+ fprintf(stderr, "Cannot query relation_members: %s\n", PQerrorMessage(conn));
+ exit(1);
+ }
+ for (int i = 0 ; i < count ; i++) {
+ id=atol(PQgetvalue(relation, i, 0));
+ osm_add_relation(id);
+ tagged = 0;
+ while (j < PQntuples(tag)) {
+ long tag_relation_id=atol(PQgetvalue(tag, j, 0));
+ if (tag_relation_id == id) {
+ osm_add_tag(PQgetvalue(tag, j, 1), PQgetvalue(tag, j, 2));
+ tagged=1;
+ j++;
+ }
+ if (tag_relation_id < id)
+ j++;
+ if (tag_relation_id > id)
+ break;
+ }
+ while (k < PQntuples(member)) {
+ long member_relation_id=atol(PQgetvalue(member, k, 0));
+ if (member_relation_id == id) {
+ int relmember_type=0; //type unknown
+ if (!g_strcmp0(PQgetvalue(member,k, 2),"W")) {
+ relmember_type=2;
+ } else {
+ if (!g_strcmp0(PQgetvalue(member,k, 2),"N")) {
+ relmember_type=1;
+ } else {
+ if (!g_strcmp0(PQgetvalue(member,k, 2),"R")) {
+ relmember_type=3;
+ }
+ }
+ }
+ osm_add_member(relmember_type,atoll(PQgetvalue(member,k, 1)),PQgetvalue(member,k, 3));
+ k++;
+ }
+ if (member_relation_id < id)
+ k++;
+ if (member_relation_id > id)
+ break;
+ }
+ if (tagged)
+ osm_end_relation(osm);
+ }
+ PQclear(relation);
+ PQclear(member);
+ PQclear(tag);
+ }
+ res=PQexec(conn, "commit");
+ if (! res) {
+ fprintf(stderr, "Cannot commit transaction: %s\n", PQerrorMessage(conn));
+ PQclear(res);
+ exit(1);
+ }
+ sig_alrm(0);
+ sig_alrm_end();
+ return 1;
}
#endif
diff --git a/navit/maptool/osm_relations.c b/navit/maptool/osm_relations.c
index 591ca7d9d..a6084f21e 100644
--- a/navit/maptool/osm_relations.c
+++ b/navit/maptool/osm_relations.c
@@ -23,67 +23,61 @@
/** Information about all members of a relation type and how to process them. */
struct relations {
- /** Hashes for nodes, ways and relations which are members. */
- GHashTable *member_hash[3];
- /** Default entries for processing items which are not a member of any relation. */
- GList *default_members;
+ /** Hashes for nodes, ways and relations which are members. */
+ GHashTable *member_hash[3];
+ /** Default entries for processing items which are not a member of any relation. */
+ GList *default_members;
};
struct relations_func {
- void (*func)(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv);
- void *func_priv;
+ void (*func)(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv);
+ void *func_priv;
};
struct relations_member {
- osmid memberid;
- void *relation_priv,*member_priv;
- struct relations_func *func;
+ osmid memberid;
+ void *relation_priv,*member_priv;
+ struct relations_func *func;
};
-static guint
-relations_member_hash(gconstpointer key)
-{
- const struct relations_member *memb=key;
- return (memb->memberid >> 32)^(memb->memberid & 0xffffffff);
+static guint relations_member_hash(gconstpointer key) {
+ const struct relations_member *memb=key;
+ return (memb->memberid >> 32)^(memb->memberid & 0xffffffff);
}
-static gboolean
-relations_member_equal(gconstpointer a, gconstpointer b)
-{
- const struct relations_member *memba=a;
- const struct relations_member *membb=b;
- return (memba->memberid == membb->memberid);
+static gboolean relations_member_equal(gconstpointer a, gconstpointer b) {
+ const struct relations_member *memba=a;
+ const struct relations_member *membb=b;
+ return (memba->memberid == membb->memberid);
}
struct relations *
-relations_new(void)
-{
- struct relations *ret=g_new0(struct relations, 1);
- int i;
-
- for (i = 0 ; i < 3 ; i++)
- ret->member_hash[i]=g_hash_table_new(relations_member_hash, relations_member_equal);
- return ret;
+relations_new(void) {
+ struct relations *ret=g_new0(struct relations, 1);
+ int i;
+
+ for (i = 0 ; i < 3 ; i++)
+ ret->member_hash[i]=g_hash_table_new(relations_member_hash, relations_member_equal);
+ return ret;
}
struct relations_func *
-relations_func_new(void (*func)(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv), void *func_priv)
-{
- struct relations_func *relations_func=g_new(struct relations_func, 1);
- relations_func->func=func;
- relations_func->func_priv=func_priv;
- return relations_func;
+relations_func_new(void (*func)(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv),
+ void *func_priv) {
+ struct relations_func *relations_func=g_new(struct relations_func, 1);
+ relations_func->func=func;
+ relations_func->func_priv=func_priv;
+ return relations_func;
}
-static struct relations_member *
-relations_member_new(struct relations_func *func, void *relation_priv, void *member_priv, osmid id)
-{
- struct relations_member *memb=g_new(struct relations_member, 1);
- memb->memberid=id;
- memb->relation_priv=relation_priv;
- memb->member_priv=member_priv;
- memb->func=func;
- return memb;
+static struct relations_member *relations_member_new(struct relations_func *func, void *relation_priv,
+ void *member_priv, osmid id) {
+ struct relations_member *memb=g_new(struct relations_member, 1);
+ memb->memberid=id;
+ memb->relation_priv=relation_priv;
+ memb->member_priv=member_priv;
+ memb->func=func;
+ return memb;
}
/*
* @brief Add an entry for a relation member to the relations collection.
@@ -96,14 +90,12 @@ relations_member_new(struct relations_func *func, void *relation_priv, void *mem
* @param in type Type of this member (node, way etc.).
* @param in id OSM ID of relation member.
*/
-void
-relations_add_relation_member_entry(struct relations *rel, struct relations_func *func, void
- *relation_priv, void *member_priv, enum relation_member_type type, osmid id)
-{
- struct relations_member *memb=relations_member_new(func, relation_priv, member_priv, id);
- GHashTable *member_hash=rel->member_hash[type-1];
- // The real key is the OSM ID, but we recycle "memb" as key to avoid a second allocating for the key.
- g_hash_table_insert(member_hash, memb, g_list_append(g_hash_table_lookup(member_hash, memb), memb));
+void relations_add_relation_member_entry(struct relations *rel, struct relations_func *func, void
+ *relation_priv, void *member_priv, enum relation_member_type type, osmid id) {
+ struct relations_member *memb=relations_member_new(func, relation_priv, member_priv, id);
+ GHashTable *member_hash=rel->member_hash[type-1];
+ // The real key is the OSM ID, but we recycle "memb" as key to avoid a second allocating for the key.
+ g_hash_table_insert(member_hash, memb, g_list_append(g_hash_table_lookup(member_hash, memb), memb));
}
/*
@@ -114,11 +106,9 @@ relations_add_relation_member_entry(struct relations *rel, struct relations_func
* @param in rel relations collection to add the new member to
* @param in func structure defining function to call when this member is read
*/
-void
-relations_add_relation_default_entry(struct relations *rel, struct relations_func *func)
-{
- struct relations_member *memb=relations_member_new(func, NULL, NULL, 0);
- rel->default_members=g_list_append(rel->default_members, memb);
+void relations_add_relation_default_entry(struct relations *rel, struct relations_func *func) {
+ struct relations_member *memb=relations_member_new(func, NULL, NULL, 0);
+ rel->default_members=g_list_append(rel->default_members, memb);
}
@@ -130,71 +120,65 @@ relations_add_relation_default_entry(struct relations *rel, struct relations_fun
* @param in nodes file containing nodes in "coords.tmp" format
* @param in ways file containing items in item_bin format. This file may contain both nodes, ways, and relations in that format.
*/
-void
-relations_process(struct relations *rel, FILE *nodes, FILE *ways)
-{
- char buffer[128];
- struct item_bin *ib=(struct item_bin *)buffer;
- osmid *id;
- struct coord *c=(struct coord *)(ib+1),cn={0,0};
- struct node_item *ni;
- GList *l;
-
- if (nodes) {
- item_bin_init(ib, type_point_unkn);
- item_bin_add_coord(ib, &cn, 1);
- item_bin_add_attr_longlong(ib, attr_osm_nodeid, 0);
- id=item_bin_get_attr(ib, attr_osm_nodeid, NULL);
- while ((ni=read_node_item(nodes))) {
- *id=ni->nd_id;
- *c=ni->c;
- l=g_hash_table_lookup(rel->member_hash[0], id);
- while (l) {
- struct relations_member *memb=l->data;
- memb->func->func(memb->func->func_priv, memb->relation_priv, ib, memb->member_priv);
- l=g_list_next(l);
- }
- }
- }
- if (ways) {
- while ((ib=read_item(ways))) {
- l=NULL;
- if(NULL!=(id=item_bin_get_attr(ib, attr_osm_nodeid, NULL)))
- l=g_hash_table_lookup(rel->member_hash[0], id);
- else if(NULL!=(id=item_bin_get_attr(ib, attr_osm_wayid, NULL)))
- l=g_hash_table_lookup(rel->member_hash[1], id);
- else if(NULL!=(id=item_bin_get_attr(ib, attr_osm_relationid, NULL)))
- l=g_hash_table_lookup(rel->member_hash[2], id);
- if(!l)
- l=rel->default_members;
- while (l) {
- struct relations_member *memb=l->data;
- memb->func->func(memb->func->func_priv, memb->relation_priv, ib, memb->member_priv);
- l=g_list_next(l);
- }
- }
- }
+void relations_process(struct relations *rel, FILE *nodes, FILE *ways) {
+ char buffer[128];
+ struct item_bin *ib=(struct item_bin *)buffer;
+ osmid *id;
+ struct coord *c=(struct coord *)(ib+1),cn= {0,0};
+ struct node_item *ni;
+ GList *l;
+
+ if (nodes) {
+ item_bin_init(ib, type_point_unkn);
+ item_bin_add_coord(ib, &cn, 1);
+ item_bin_add_attr_longlong(ib, attr_osm_nodeid, 0);
+ id=item_bin_get_attr(ib, attr_osm_nodeid, NULL);
+ while ((ni=read_node_item(nodes))) {
+ *id=ni->nd_id;
+ *c=ni->c;
+ l=g_hash_table_lookup(rel->member_hash[0], id);
+ while (l) {
+ struct relations_member *memb=l->data;
+ memb->func->func(memb->func->func_priv, memb->relation_priv, ib, memb->member_priv);
+ l=g_list_next(l);
+ }
+ }
+ }
+ if (ways) {
+ while ((ib=read_item(ways))) {
+ l=NULL;
+ if(NULL!=(id=item_bin_get_attr(ib, attr_osm_nodeid, NULL)))
+ l=g_hash_table_lookup(rel->member_hash[0], id);
+ else if(NULL!=(id=item_bin_get_attr(ib, attr_osm_wayid, NULL)))
+ l=g_hash_table_lookup(rel->member_hash[1], id);
+ else if(NULL!=(id=item_bin_get_attr(ib, attr_osm_relationid, NULL)))
+ l=g_hash_table_lookup(rel->member_hash[2], id);
+ if(!l)
+ l=rel->default_members;
+ while (l) {
+ struct relations_member *memb=l->data;
+ memb->func->func(memb->func->func_priv, memb->relation_priv, ib, memb->member_priv);
+ l=g_list_next(l);
+ }
+ }
+ }
}
-static void
-relations_destroy_func(void *key, GList *l, void *data)
-{
- GList *ll=l;
- while (ll) {
- g_free(ll->data);
- ll=g_list_next(ll);
- }
- g_list_free(l);
+static void relations_destroy_func(void *key, GList *l, void *data) {
+ GList *ll=l;
+ while (ll) {
+ g_free(ll->data);
+ ll=g_list_next(ll);
+ }
+ g_list_free(l);
}
-void
-relations_destroy(struct relations *relations)
-{
- int i;
+void relations_destroy(struct relations *relations) {
+ int i;
- for (i = 0 ; i < 3 ; i++) {
- g_hash_table_foreach(relations->member_hash[i], (GHFunc)relations_destroy_func, NULL);
- g_hash_table_destroy(relations->member_hash[i]);
- }
- g_free(relations);
+ for (i = 0 ; i < 3 ; i++) {
+ g_hash_table_foreach(relations->member_hash[i], (GHFunc)relations_destroy_func, NULL);
+ g_hash_table_destroy(relations->member_hash[i]);
+ }
+ g_free(relations);
}
diff --git a/navit/maptool/osm_xml.c b/navit/maptool/osm_xml.c
index c107a8048..6cef06493 100644
--- a/navit/maptool/osm_xml.c
+++ b/navit/maptool/osm_xml.c
@@ -26,220 +26,201 @@
#endif
#include "maptool.h"
-int
-osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size)
-{
- int len=strlen(attribute);
- char *pos,*i,s,*attr;
- attr=g_alloca(len+2);
- strcpy(attr, attribute);
- strcpy(attr+len, "=");
- pos=strstr(xml, attr);
- if (! pos)
- return 0;
- pos+=len+1;
- s=*pos++;
- if (! s)
- return 0;
- i=strchr(pos, s);
- if (! i)
- return 0;
- if (i - pos > buffer_size) {
- fprintf(stderr,"Buffer overflow %ld vs %d\n", (long)(i-pos), buffer_size);
- return 0;
- }
- strncpy(buffer, pos, i-pos);
- buffer[i-pos]='\0';
- return 1;
+int osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size) {
+ int len=strlen(attribute);
+ char *pos,*i,s,*attr;
+ attr=g_alloca(len+2);
+ strcpy(attr, attribute);
+ strcpy(attr+len, "=");
+ pos=strstr(xml, attr);
+ if (! pos)
+ return 0;
+ pos+=len+1;
+ s=*pos++;
+ if (! s)
+ return 0;
+ i=strchr(pos, s);
+ if (! i)
+ return 0;
+ if (i - pos > buffer_size) {
+ fprintf(stderr,"Buffer overflow %ld vs %d\n", (long)(i-pos), buffer_size);
+ return 0;
+ }
+ strncpy(buffer, pos, i-pos);
+ buffer[i-pos]='\0';
+ return 1;
}
static struct entity {
- char *entity;
- char c;
+ char *entity;
+ char c;
} entities[]= {
- {"&quot;",'"'},
- {"&apos;",'\''},
- {"&amp;",'&'},
- {"&lt;",'<'},
- {"&gt;",'>'},
- {"&#34;",'"'},
- {"&#39;",'\''},
- {"&#38;",'&'},
- {"&#60;",'<'},
- {"&#62;",'>'},
- {"&#123;",'{'},
- {"&#125;",'}'},
+ {"&quot;",'"'},
+ {"&apos;",'\''},
+ {"&amp;",'&'},
+ {"&lt;",'<'},
+ {"&gt;",'>'},
+ {"&#34;",'"'},
+ {"&#39;",'\''},
+ {"&#38;",'&'},
+ {"&#60;",'<'},
+ {"&#62;",'>'},
+ {"&#123;",'{'},
+ {"&#125;",'}'},
};
-void
-osm_xml_decode_entities(char *buffer)
-{
- char *pos=buffer;
- int i,len;
+void osm_xml_decode_entities(char *buffer) {
+ char *pos=buffer;
+ int i,len;
- while ((pos=strchr(pos, '&'))) {
- for (i = 0 ; i < sizeof(entities)/sizeof(struct entity); i++) {
- len=strlen(entities[i].entity);
- if (!strncmp(pos, entities[i].entity, len)) {
- *pos=entities[i].c;
- memmove(pos+1, pos+len, strlen(pos+len)+1);
- break;
- }
- }
- pos++;
- }
+ while ((pos=strchr(pos, '&'))) {
+ for (i = 0 ; i < sizeof(entities)/sizeof(struct entity); i++) {
+ len=strlen(entities[i].entity);
+ if (!strncmp(pos, entities[i].entity, len)) {
+ *pos=entities[i].c;
+ memmove(pos+1, pos+len, strlen(pos+len)+1);
+ break;
+ }
+ }
+ pos++;
+ }
}
-static int
-parse_tag(char *p)
-{
- char k_buffer[BUFFER_SIZE];
- char v_buffer[BUFFER_SIZE];
- if (!osm_xml_get_attribute(p, "k", k_buffer, BUFFER_SIZE))
- return 0;
- if (!osm_xml_get_attribute(p, "v", v_buffer, BUFFER_SIZE))
- return 0;
- osm_xml_decode_entities(v_buffer);
- osm_add_tag(k_buffer, v_buffer);
- return 1;
+static int parse_tag(char *p) {
+ char k_buffer[BUFFER_SIZE];
+ char v_buffer[BUFFER_SIZE];
+ if (!osm_xml_get_attribute(p, "k", k_buffer, BUFFER_SIZE))
+ return 0;
+ if (!osm_xml_get_attribute(p, "v", v_buffer, BUFFER_SIZE))
+ return 0;
+ osm_xml_decode_entities(v_buffer);
+ osm_add_tag(k_buffer, v_buffer);
+ return 1;
}
-static int
-parse_node(char *p)
-{
- char id_buffer[BUFFER_SIZE];
- char lat_buffer[BUFFER_SIZE];
- char lon_buffer[BUFFER_SIZE];
- if (!osm_xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
- return 0;
- if (!osm_xml_get_attribute(p, "lat", lat_buffer, BUFFER_SIZE))
- return 0;
- if (!osm_xml_get_attribute(p, "lon", lon_buffer, BUFFER_SIZE))
- return 0;
- osm_add_node(atoll(id_buffer), atof(lat_buffer), atof(lon_buffer));
- return 1;
+static int parse_node(char *p) {
+ char id_buffer[BUFFER_SIZE];
+ char lat_buffer[BUFFER_SIZE];
+ char lon_buffer[BUFFER_SIZE];
+ if (!osm_xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
+ return 0;
+ if (!osm_xml_get_attribute(p, "lat", lat_buffer, BUFFER_SIZE))
+ return 0;
+ if (!osm_xml_get_attribute(p, "lon", lon_buffer, BUFFER_SIZE))
+ return 0;
+ osm_add_node(atoll(id_buffer), atof(lat_buffer), atof(lon_buffer));
+ return 1;
}
-static int
-parse_way(char *p)
-{
- char id_buffer[BUFFER_SIZE];
- if (!osm_xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
- return 0;
- osm_add_way(atoll(id_buffer));
- return 1;
+static int parse_way(char *p) {
+ char id_buffer[BUFFER_SIZE];
+ if (!osm_xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
+ return 0;
+ osm_add_way(atoll(id_buffer));
+ return 1;
}
-static int
-parse_relation(char *p)
-{
- char id_buffer[BUFFER_SIZE];
- if (!osm_xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
- return 0;
- osm_add_relation(atoll(id_buffer));
- return 1;
+static int parse_relation(char *p) {
+ char id_buffer[BUFFER_SIZE];
+ if (!osm_xml_get_attribute(p, "id", id_buffer, BUFFER_SIZE))
+ return 0;
+ osm_add_relation(atoll(id_buffer));
+ return 1;
}
-static int
-parse_member(char *p)
-{
- char type_buffer[BUFFER_SIZE];
- char ref_buffer[BUFFER_SIZE];
- char role_buffer[BUFFER_SIZE];
- enum relation_member_type type;
- if (!osm_xml_get_attribute(p, "type", type_buffer, BUFFER_SIZE))
- return 0;
- if (!osm_xml_get_attribute(p, "ref", ref_buffer, BUFFER_SIZE))
- return 0;
- if (!osm_xml_get_attribute(p, "role", role_buffer, BUFFER_SIZE))
- return 0;
- if (!strcmp(type_buffer,"node"))
- type=rel_member_node;
- else if (!strcmp(type_buffer,"way"))
- type=rel_member_way;
- else if (!strcmp(type_buffer,"relation"))
- type=rel_member_relation;
- else {
- fprintf(stderr,"Unknown type '%s'\n",type_buffer);
- return 0;
- }
- osm_add_member(type, atoll(ref_buffer), role_buffer);
-
- return 1;
+static int parse_member(char *p) {
+ char type_buffer[BUFFER_SIZE];
+ char ref_buffer[BUFFER_SIZE];
+ char role_buffer[BUFFER_SIZE];
+ enum relation_member_type type;
+ if (!osm_xml_get_attribute(p, "type", type_buffer, BUFFER_SIZE))
+ return 0;
+ if (!osm_xml_get_attribute(p, "ref", ref_buffer, BUFFER_SIZE))
+ return 0;
+ if (!osm_xml_get_attribute(p, "role", role_buffer, BUFFER_SIZE))
+ return 0;
+ if (!g_strcmp0(type_buffer,"node"))
+ type=rel_member_node;
+ else if (!g_strcmp0(type_buffer,"way"))
+ type=rel_member_way;
+ else if (!g_strcmp0(type_buffer,"relation"))
+ type=rel_member_relation;
+ else {
+ fprintf(stderr,"Unknown type '%s'\n",type_buffer);
+ return 0;
+ }
+ osm_add_member(type, atoll(ref_buffer), role_buffer);
+
+ return 1;
}
-static int
-parse_nd(char *p)
-{
- char ref_buffer[BUFFER_SIZE];
- if (!osm_xml_get_attribute(p, "ref", ref_buffer, BUFFER_SIZE))
- return 0;
- osm_add_nd(atoll(ref_buffer));
- return 1;
+static int parse_nd(char *p) {
+ char ref_buffer[BUFFER_SIZE];
+ if (!osm_xml_get_attribute(p, "ref", ref_buffer, BUFFER_SIZE))
+ return 0;
+ osm_add_nd(atoll(ref_buffer));
+ return 1;
}
-static int
-xml_declaration_in_line(char* buffer){
- return !strncmp(buffer, "<?xml ", 6);
+static int xml_declaration_in_line(char* buffer) {
+ return !strncmp(buffer, "<?xml ", 6);
}
-int
-map_collect_data_osm(FILE *in, struct maptool_osm *osm)
-{
- int size=BUFFER_SIZE;
- char buffer[BUFFER_SIZE];
- char *p;
- sig_alrm(0);
- if (!fgets(buffer, size, in) || !xml_declaration_in_line(buffer)){
- fprintf(stderr,"FATAL: First line does not start with XML declaration;\n"
- "this does not look like a valid OSM file.\n");
- exit(EXIT_FAILURE);
- }
- while (fgets(buffer, size, in)) {
- p=strchr(buffer,'<');
- if (! p) {
- fprintf(stderr,"FATAL: wrong line in input data (does not start with '<'): %s\n", buffer);
- fprintf(stderr,"This does not look like a valid OSM file.\n"
- "Note that maptool can only process OSM files without wrapped or empty lines.\n");
- exit(EXIT_FAILURE);
- }
- if (!strncmp(p, "<osm ",5)) {
- } else if (!strncmp(p, "<bound ",7)) {
- } else if (!strncmp(p, "<node ",6)) {
- if (!parse_node(p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- processed_nodes++;
- } else if (!strncmp(p, "<tag ",5)) {
- if (!parse_tag(p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- } else if (!strncmp(p, "<way ",5)) {
- if (!parse_way(p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- processed_ways++;
- } else if (!strncmp(p, "<nd ",4)) {
- if (!parse_nd(p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- } else if (!strncmp(p, "<relation ",10)) {
- if (!parse_relation(p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- processed_relations++;
- } else if (!strncmp(p, "<member ",8)) {
- if (!parse_member(p))
- fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
- } else if (!strncmp(p, "</node>",7)) {
- osm_end_node(osm);
- } else if (!strncmp(p, "</way>",6)) {
- osm_end_way(osm);
- } else if (!strncmp(p, "</relation>",11)) {
- osm_end_relation(osm);
- } else if (!strncmp(p, "</osm>",6)) {
- } else {
- fprintf(stderr,"WARNING: unknown tag in %s\n", buffer);
- }
- }
- sig_alrm(0);
- sig_alrm_end();
- return 1;
+int map_collect_data_osm(FILE *in, struct maptool_osm *osm) {
+ int size=BUFFER_SIZE;
+ char buffer[BUFFER_SIZE];
+ char *p;
+ sig_alrm(0);
+ if (!fgets(buffer, size, in) || !xml_declaration_in_line(buffer)) {
+ fprintf(stderr,"FATAL: First line does not start with XML declaration;\n"
+ "this does not look like a valid OSM file.\n");
+ exit(EXIT_FAILURE);
+ }
+ while (fgets(buffer, size, in)) {
+ p=strchr(buffer,'<');
+ if (! p) {
+ fprintf(stderr,"FATAL: wrong line in input data (does not start with '<'): %s\n", buffer);
+ fprintf(stderr,"This does not look like a valid OSM file.\n"
+ "Note that maptool can only process OSM files without wrapped or empty lines.\n");
+ exit(EXIT_FAILURE);
+ }
+ if (!strncmp(p, "<osm ",5)) {
+ } else if (!strncmp(p, "<bound ",7)) {
+ } else if (!strncmp(p, "<node ",6)) {
+ if (!parse_node(p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ processed_nodes++;
+ } else if (!strncmp(p, "<tag ",5)) {
+ if (!parse_tag(p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ } else if (!strncmp(p, "<way ",5)) {
+ if (!parse_way(p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ processed_ways++;
+ } else if (!strncmp(p, "<nd ",4)) {
+ if (!parse_nd(p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ } else if (!strncmp(p, "<relation ",10)) {
+ if (!parse_relation(p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ processed_relations++;
+ } else if (!strncmp(p, "<member ",8)) {
+ if (!parse_member(p))
+ fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
+ } else if (!strncmp(p, "</node>",7)) {
+ osm_end_node(osm);
+ } else if (!strncmp(p, "</way>",6)) {
+ osm_end_way(osm);
+ } else if (!strncmp(p, "</relation>",11)) {
+ osm_end_relation(osm);
+ } else if (!strncmp(p, "</osm>",6)) {
+ } else {
+ fprintf(stderr,"WARNING: unknown tag in %s\n", buffer);
+ }
+ }
+ sig_alrm(0);
+ sig_alrm_end();
+ return 1;
}
diff --git a/navit/maptool/osmformat.proto b/navit/maptool/osmformat.proto
index 73f6472a9..78d747ef6 100644
--- a/navit/maptool/osmformat.proto
+++ b/navit/maptool/osmformat.proto
@@ -1,7 +1,8 @@
+syntax = "proto2";
option java_package = "crosby.binary";
package OSMPBF;
-/* OSM Binary file format
+/* OSM Binary file format
This is the master schema file of the OSM binary file format. This
file is designed to support limited random-access and future
@@ -42,7 +43,7 @@ message HeaderBlock {
repeated string required_features = 4;
repeated string optional_features = 5;
- optional string writingprogram = 16;
+ optional string writingprogram = 16;
optional string source = 17; // From the bbox field.
}
@@ -68,13 +69,13 @@ message PrimitiveBlock {
repeated PrimitiveGroup primitivegroup = 2;
// Granularity, units of nanodegrees, used to store coordinates in this block
- optional int32 granularity = 17 [default=100];
+ optional int32 granularity = 17 [default=100];
// Offset value between the output coordinates coordinates and the granularity grid in unites of nanodegrees.
optional int64 lat_offset = 19 [default=0];
- optional int64 lon_offset = 20 [default=0];
+ optional int64 lon_offset = 20 [default=0];
// Granularity of dates, normally represented in units of milliseconds since the 1970 epoch.
- optional int32 date_granularity = 18 [default=1000];
+ optional int32 date_granularity = 18 [default=1000];
// Proposed extension:
@@ -112,7 +113,7 @@ message Info {
/** Optional metadata that may be included into each primitive. Special dense format used in DenseNodes. */
message DenseInfo {
- repeated int32 version = 1 [packed = true];
+ repeated int32 version = 1 [packed = true];
repeated sint64 timestamp = 2 [packed = true]; // DELTA coded
repeated sint64 changeset = 3 [packed = true]; // DELTA coded
repeated sint32 uid = 4 [packed = true]; // DELTA coded
@@ -124,7 +125,7 @@ message DenseInfo {
// TODO: REMOVE THIS?
message ChangeSet {
required int64 id = 1;
-//
+//
// // Parallel arrays.
// repeated uint32 keys = 2 [packed = true]; // String IDs.
// repeated uint32 vals = 3 [packed = true]; // String IDs.
@@ -153,7 +154,7 @@ message Node {
/* Used to densly represent a sequence of nodes that do not have any tags.
We represent these nodes columnwise as five columns: ID's, lats, and
-lons, all delta coded. When metadata is not omitted,
+lons, all delta coded. When metadata is not omitted,
We encode keys & vals for all nodes as a single array of integers
containing key-stringid and val-stringid, using a stringid of 0 as a
@@ -172,7 +173,7 @@ message DenseNodes {
repeated sint64 lon = 9 [packed = true]; // DELTA coded
// Special packing of keys and vals into one array. May be empty if all nodes in this block are tagless.
- repeated int32 keys_vals = 10 [packed = true];
+ repeated int32 keys_vals = 10 [packed = true];
}
@@ -192,7 +193,7 @@ message Relation {
NODE = 0;
WAY = 1;
RELATION = 2;
- }
+ }
required int64 id = 1;
// Parallel arrays.
@@ -206,4 +207,3 @@ message Relation {
repeated sint64 memids = 9 [packed = true]; // DELTA encoded
repeated MemberType types = 10 [packed = true];
}
-
diff --git a/navit/maptool/sourcesink.c b/navit/maptool/sourcesink.c
index 97aa7de7d..eedd433d9 100644
--- a/navit/maptool/sourcesink.c
+++ b/navit/maptool/sourcesink.c
@@ -25,145 +25,125 @@
#include "maptool.h"
struct item_bin_sink *
-item_bin_sink_new(void)
-{
- struct item_bin_sink *ret=g_new0(struct item_bin_sink, 1);
+item_bin_sink_new(void) {
+ struct item_bin_sink *ret=g_new0(struct item_bin_sink, 1);
- return ret;
+ return ret;
}
struct item_bin_sink_func *
-item_bin_sink_func_new(int (*func)(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data))
-{
- struct item_bin_sink_func *ret=g_new0(struct item_bin_sink_func, 1);
- ret->func=func;
- return ret;
+item_bin_sink_func_new(int (*func)(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data)) {
+ struct item_bin_sink_func *ret=g_new0(struct item_bin_sink_func, 1);
+ ret->func=func;
+ return ret;
}
-void
-item_bin_sink_func_destroy(struct item_bin_sink_func *func)
-{
- g_free(func);
+void item_bin_sink_func_destroy(struct item_bin_sink_func *func) {
+ g_free(func);
}
-void
-item_bin_sink_add_func(struct item_bin_sink *sink, struct item_bin_sink_func *func)
-{
- sink->sink_funcs=g_list_append(sink->sink_funcs, func);
+void item_bin_sink_add_func(struct item_bin_sink *sink, struct item_bin_sink_func *func) {
+ sink->sink_funcs=g_list_append(sink->sink_funcs, func);
}
-void
-item_bin_sink_destroy(struct item_bin_sink *sink)
-{
- /* g_list_foreach(sink->sink_funcs, (GFunc)g_free, NULL); */
- g_list_free(sink->sink_funcs);
- g_free(sink);
+void item_bin_sink_destroy(struct item_bin_sink *sink) {
+ /* g_list_foreach(sink->sink_funcs, (GFunc)g_free, NULL); */
+ g_list_free(sink->sink_funcs);
+ g_free(sink);
}
-int
-item_bin_write_to_sink(struct item_bin *ib, struct item_bin_sink *sink, struct tile_data *tile_data)
-{
- GList *list=sink->sink_funcs;
- int ret=0;
- while (list) {
- struct item_bin_sink_func *func=list->data;
- ret=func->func(func, ib, tile_data);
- if (ret)
- break;
- list=g_list_next(list);
- }
- return ret;
+int item_bin_write_to_sink(struct item_bin *ib, struct item_bin_sink *sink, struct tile_data *tile_data) {
+ GList *list=sink->sink_funcs;
+ int ret=0;
+ while (list) {
+ struct item_bin_sink_func *func=list->data;
+ ret=func->func(func, ib, tile_data);
+ if (ret)
+ break;
+ list=g_list_next(list);
+ }
+ return ret;
}
struct item_bin_sink *
-file_reader_new(FILE *in, int limit, int offset)
-{
- struct item_bin_sink *ret;
- if (!in)
- return NULL;
- ret=item_bin_sink_new();
- ret->priv_data[0]=in;
- ret->priv_data[1]=(void *)(long)limit;
- ret->priv_data[2]=(void *)(long)offset;
- fseek(in, 0, SEEK_SET);
- return ret;
+file_reader_new(FILE *in, int limit, int offset) {
+ struct item_bin_sink *ret;
+ if (!in)
+ return NULL;
+ ret=item_bin_sink_new();
+ ret->priv_data[0]=in;
+ ret->priv_data[1]=(void *)(long)limit;
+ ret->priv_data[2]=(void *)(long)offset;
+ fseek(in, 0, SEEK_SET);
+ return ret;
}
-int
-file_reader_finish(struct item_bin_sink *sink)
-{
- struct item_bin *ib;
- int ret =0;
- FILE *in=sink->priv_data[0];
- int limit=(int)(long)sink->priv_data[1];
- int offset=(int)(long)sink->priv_data[2];
- while ((ib=read_item(in))) {
- if (offset > 0) {
- offset--;
- } else {
- ret=item_bin_write_to_sink(ib, sink, NULL);
- if (ret || (limit != -1 && !--limit)) {
- item_bin_sink_destroy(sink);
- return ret;
- }
- }
- }
- item_bin_sink_destroy(sink);
- return 0;
+int file_reader_finish(struct item_bin_sink *sink) {
+ struct item_bin *ib;
+ int ret =0;
+ FILE *in=sink->priv_data[0];
+ int limit=(int)(long)sink->priv_data[1];
+ int offset=(int)(long)sink->priv_data[2];
+ while ((ib=read_item(in))) {
+ if (offset > 0) {
+ offset--;
+ } else {
+ ret=item_bin_write_to_sink(ib, sink, NULL);
+ if (ret || (limit != -1 && !--limit)) {
+ item_bin_sink_destroy(sink);
+ return ret;
+ }
+ }
+ }
+ item_bin_sink_destroy(sink);
+ return 0;
}
-int
-file_writer_process(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data)
-{
- FILE *out=func->priv_data[0];
- item_bin_write(ib, out);
- return 0;
+int file_writer_process(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data) {
+ FILE *out=func->priv_data[0];
+ item_bin_write(ib, out);
+ return 0;
}
struct item_bin_sink_func *
-file_writer_new(FILE *out)
-{
- struct item_bin_sink_func *file_writer;
- if (!out)
- return NULL;
- file_writer=item_bin_sink_func_new(file_writer_process);
- file_writer->priv_data[0]=out;
- return file_writer;
+file_writer_new(FILE *out) {
+ struct item_bin_sink_func *file_writer;
+ if (!out)
+ return NULL;
+ file_writer=item_bin_sink_func_new(file_writer_process);
+ file_writer->priv_data[0]=out;
+ return file_writer;
}
-int
-file_writer_finish(struct item_bin_sink_func *file_writer)
-{
- item_bin_sink_func_destroy(file_writer);
- return 0;
+int file_writer_finish(struct item_bin_sink_func *file_writer) {
+ item_bin_sink_func_destroy(file_writer);
+ return 0;
}
-int
-tile_collector_process(struct item_bin_sink_func *tile_collector, struct item_bin *ib, struct tile_data *tile_data)
-{
- int *buffer,*buffer2;
- int len=ib->len+1;
- GHashTable *hash=tile_collector->priv_data[0];
- buffer=g_hash_table_lookup(hash, tile_data->buffer);
- buffer2=g_malloc((len+(buffer ? buffer[0] : 1))*4);
- if (buffer) {
- memcpy(buffer2, buffer, buffer[0]*4);
- } else
- buffer2[0]=1;
- memcpy(buffer2+buffer2[0], ib, len*4);
- buffer2[0]+=len;
- g_hash_table_insert(hash, g_strdup(tile_data->buffer), buffer2);
- return 0;
+int tile_collector_process(struct item_bin_sink_func *tile_collector, struct item_bin *ib,
+ struct tile_data *tile_data) {
+ int *buffer,*buffer2;
+ int len=ib->len+1;
+ GHashTable *hash=tile_collector->priv_data[0];
+ buffer=g_hash_table_lookup(hash, tile_data->buffer);
+ buffer2=g_malloc((len+(buffer ? buffer[0] : 1))*4);
+ if (buffer) {
+ memcpy(buffer2, buffer, buffer[0]*4);
+ } else
+ buffer2[0]=1;
+ memcpy(buffer2+buffer2[0], ib, len*4);
+ buffer2[0]+=len;
+ g_hash_table_insert(hash, g_strdup(tile_data->buffer), buffer2);
+ return 0;
}
struct item_bin_sink_func *
-tile_collector_new(struct item_bin_sink *out)
-{
- struct item_bin_sink_func *tile_collector;
- tile_collector=item_bin_sink_func_new(tile_collector_process);
- tile_collector->priv_data[0]=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
- tile_collector->priv_data[1]=out;
- return tile_collector;
+tile_collector_new(struct item_bin_sink *out) {
+ struct item_bin_sink_func *tile_collector;
+ tile_collector=item_bin_sink_func_new(tile_collector_process);
+ tile_collector->priv_data[0]=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+ tile_collector->priv_data[1]=out;
+ return tile_collector;
}
diff --git a/navit/maptool/tempfile.c b/navit/maptool/tempfile.c
index d00acd21b..bdb4dad96 100644
--- a/navit/maptool/tempfile.c
+++ b/navit/maptool/tempfile.c
@@ -23,45 +23,37 @@
#include "maptool.h"
#include "debug.h"
-char *
-tempfile_name(char *suffix, char *name)
-{
- return g_strdup_printf("%s_%s.tmp",name, suffix);
+char *tempfile_name(char *suffix, char *name) {
+ return g_strdup_printf("%s_%s.tmp",name, suffix);
}
-FILE *
-tempfile(char *suffix, char *name, int mode)
-{
- char *buffer=tempfile_name(suffix, name);
- FILE *ret=NULL;
- switch (mode) {
- case 0:
- ret=fopen(buffer, "rb");
- break;
- case 1:
- ret=fopen(buffer, "wb+");
- break;
- case 2:
- ret=fopen(buffer, "ab");
- break;
- }
- g_free(buffer);
- return ret;
+FILE *tempfile(char *suffix, char *name, int mode) {
+ char *buffer=tempfile_name(suffix, name);
+ FILE *ret=NULL;
+ switch (mode) {
+ case 0:
+ ret=fopen(buffer, "rb");
+ break;
+ case 1:
+ ret=fopen(buffer, "wb+");
+ break;
+ case 2:
+ ret=fopen(buffer, "ab");
+ break;
+ }
+ g_free(buffer);
+ return ret;
}
-void
-tempfile_unlink(char *suffix, char *name)
-{
- char buffer[4096];
- sprintf(buffer,"%s_%s.tmp",name, suffix);
- unlink(buffer);
+void tempfile_unlink(char *suffix, char *name) {
+ char buffer[4096];
+ sprintf(buffer,"%s_%s.tmp",name, suffix);
+ unlink(buffer);
}
-void
-tempfile_rename(char *suffix, char *from, char *to)
-{
- char buffer_from[4096],buffer_to[4096];
- sprintf(buffer_from,"%s_%s.tmp",from,suffix);
- sprintf(buffer_to,"%s_%s.tmp",to,suffix);
- dbg_assert(rename(buffer_from, buffer_to) == 0);
-
+void tempfile_rename(char *suffix, char *from, char *to) {
+ char buffer_from[4096],buffer_to[4096];
+ sprintf(buffer_from,"%s_%s.tmp",from,suffix);
+ sprintf(buffer_to,"%s_%s.tmp",to,suffix);
+ dbg_assert(rename(buffer_from, buffer_to) == 0);
+
}
diff --git a/navit/maptool/tile.c b/navit/maptool/tile.c
index 9d9f94145..f0d10332a 100644
--- a/navit/maptool/tile.c
+++ b/navit/maptool/tile.c
@@ -50,653 +50,599 @@ GList *aux_tile_list;
struct tile_head *tile_head_root;
GHashTable *strings_hash,*tile_hash,*tile_hash2;
-static char* string_hash_lookup( const char* key )
-{
- char* key_ptr = NULL;
+static char* string_hash_lookup( const char* key ) {
+ char* key_ptr = NULL;
- if ( strings_hash == NULL ) {
- strings_hash = g_hash_table_new(g_str_hash, g_str_equal);
- }
+ if ( strings_hash == NULL ) {
+ strings_hash = g_hash_table_new(g_str_hash, g_str_equal);
+ }
- if ( ( key_ptr = g_hash_table_lookup(strings_hash, key )) == NULL ) {
- key_ptr = g_strdup( key );
- g_hash_table_insert(strings_hash, key_ptr, (gpointer)key_ptr );
+ if ( ( key_ptr = g_hash_table_lookup(strings_hash, key )) == NULL ) {
+ key_ptr = g_strdup( key );
+ g_hash_table_insert(strings_hash, key_ptr, (gpointer)key_ptr );
- }
- return key_ptr;
+ }
+ return key_ptr;
}
-static char** th_get_subtile( const struct tile_head* th, int idx )
-{
- char* subtile_ptr = NULL;
- subtile_ptr = (char*)th + sizeof( struct tile_head ) + idx * sizeof( char *);
- return (char**)subtile_ptr;
+static char** th_get_subtile( const struct tile_head* th, int idx ) {
+ char* subtile_ptr = NULL;
+ subtile_ptr = (char*)th + sizeof( struct tile_head ) + idx * sizeof( char *);
+ return (char**)subtile_ptr;
}
-int
-tile(struct rect *r, char *suffix, char *ret, int max, int overlap, struct rect *tr)
-{
- int x0,x2,x4;
- int y0,y2,y4;
- int xo,yo;
- int i;
- struct rect rr=*r;
-
- x0=world_bbox.l.x;
- y0=world_bbox.l.y;
- x4=world_bbox.h.x;
- y4=world_bbox.h.y;
-
- if(rr.l.x<x0)
- rr.l.x=x0;
- if(rr.h.x<x0)
- rr.h.x=x0;
- if(rr.l.y<y0)
- rr.l.y=y0;
- if(rr.h.y<y0)
- rr.h.y=y0;
- if(rr.l.x>x4)
- rr.l.x=x4;
- if(rr.h.x>x4)
- rr.h.x=x4;
- if(rr.l.y>y4)
- rr.l.y=y4;
- if(rr.h.y>y4)
- rr.h.y=y4;
-
- for (i = 0 ; i < max ; i++) {
- x2=(x0+x4)/2;
- y2=(y0+y4)/2;
- xo=(x4-x0)*overlap/100;
- yo=(y4-y0)*overlap/100;
- if ( contains_bbox(x0,y0,x2+xo,y2+yo,&rr)) {
- strcat(ret,"d");
- x4=x2+xo;
- y4=y2+yo;
- } else if (contains_bbox(x2-xo,y0,x4,y2+yo,&rr)) {
- strcat(ret,"c");
- x0=x2-xo;
- y4=y2+yo;
- } else if (contains_bbox(x0,y2-yo,x2+xo,y4,&rr)) {
- strcat(ret,"b");
- x4=x2+xo;
- y0=y2-yo;
- } else if (contains_bbox(x2-xo,y2-yo,x4,y4,&rr)) {
- strcat(ret,"a");
- x0=x2-xo;
- y0=y2-yo;
- } else
- break;
- }
- if (tr) {
- tr->l.x=x0;
- tr->l.y=y0;
- tr->h.x=x4;
- tr->h.y=y4;
- }
- if (suffix)
- strcat(ret,suffix);
- return i;
+int tile(struct rect *r, char *suffix, char *ret, int max, int overlap, struct rect *tr) {
+ int x0,x2,x4;
+ int y0,y2,y4;
+ int xo,yo;
+ int i;
+ struct rect rr=*r;
+
+ x0=world_bbox.l.x;
+ y0=world_bbox.l.y;
+ x4=world_bbox.h.x;
+ y4=world_bbox.h.y;
+
+ if(rr.l.x<x0)
+ rr.l.x=x0;
+ if(rr.h.x<x0)
+ rr.h.x=x0;
+ if(rr.l.y<y0)
+ rr.l.y=y0;
+ if(rr.h.y<y0)
+ rr.h.y=y0;
+ if(rr.l.x>x4)
+ rr.l.x=x4;
+ if(rr.h.x>x4)
+ rr.h.x=x4;
+ if(rr.l.y>y4)
+ rr.l.y=y4;
+ if(rr.h.y>y4)
+ rr.h.y=y4;
+
+ for (i = 0 ; i < max ; i++) {
+ x2=(x0+x4)/2;
+ y2=(y0+y4)/2;
+ xo=(x4-x0)*overlap/100;
+ yo=(y4-y0)*overlap/100;
+ if ( contains_bbox(x0,y0,x2+xo,y2+yo,&rr)) {
+ strcat(ret,"d");
+ x4=x2+xo;
+ y4=y2+yo;
+ } else if (contains_bbox(x2-xo,y0,x4,y2+yo,&rr)) {
+ strcat(ret,"c");
+ x0=x2-xo;
+ y4=y2+yo;
+ } else if (contains_bbox(x0,y2-yo,x2+xo,y4,&rr)) {
+ strcat(ret,"b");
+ x4=x2+xo;
+ y0=y2-yo;
+ } else if (contains_bbox(x2-xo,y2-yo,x4,y4,&rr)) {
+ strcat(ret,"a");
+ x0=x2-xo;
+ y0=y2-yo;
+ } else
+ break;
+ }
+ if (tr) {
+ tr->l.x=x0;
+ tr->l.y=y0;
+ tr->h.x=x4;
+ tr->h.y=y4;
+ }
+ if (suffix)
+ strcat(ret,suffix);
+ return i;
}
-void
-tile_bbox(char *tile, struct rect *r, int overlap)
-{
- struct coord c;
- int xo,yo;
- *r=world_bbox;
- while (*tile) {
- c.x=(r->l.x+r->h.x)/2;
- c.y=(r->l.y+r->h.y)/2;
- xo=(r->h.x-r->l.x)*overlap/100;
- yo=(r->h.y-r->l.y)*overlap/100;
- switch (*tile) {
- case 'a':
- r->l.x=c.x-xo;
- r->l.y=c.y-yo;
- break;
- case 'b':
- r->h.x=c.x+xo;
- r->l.y=c.y-yo;
- break;
- case 'c':
- r->l.x=c.x-xo;
- r->h.y=c.y+yo;
- break;
- case 'd':
- r->h.x=c.x+xo;
- r->h.y=c.y+yo;
- break;
- }
- tile++;
- }
+void tile_bbox(char *tile, struct rect *r, int overlap) {
+ struct coord c;
+ int xo,yo;
+ *r=world_bbox;
+ while (*tile) {
+ c.x=(r->l.x+r->h.x)/2;
+ c.y=(r->l.y+r->h.y)/2;
+ xo=(r->h.x-r->l.x)*overlap/100;
+ yo=(r->h.y-r->l.y)*overlap/100;
+ switch (*tile) {
+ case 'a':
+ r->l.x=c.x-xo;
+ r->l.y=c.y-yo;
+ break;
+ case 'b':
+ r->h.x=c.x+xo;
+ r->l.y=c.y-yo;
+ break;
+ case 'c':
+ r->l.x=c.x-xo;
+ r->h.y=c.y+yo;
+ break;
+ case 'd':
+ r->h.x=c.x+xo;
+ r->h.y=c.y+yo;
+ break;
+ }
+ tile++;
+ }
}
-int
-tile_len(char *tile)
-{
- int ret=0;
- while (tile[0] >= 'a' && tile[0] <= 'd') {
- tile++;
- ret++;
- }
- return ret;
+int tile_len(char *tile) {
+ int ret=0;
+ while (tile[0] >= 'a' && tile[0] <= 'd') {
+ tile++;
+ ret++;
+ }
+ return ret;
}
-static void
-tile_extend(char *tile, struct item_bin *ib, GList **tiles_list)
-{
- struct tile_head *th=NULL;
- if (debug_tile(tile))
- fprintf(stderr,"Tile:Writing %d bytes to '%s' (%p,%p) 0x%x "LONGLONG_FMT"\n", (ib->len+1)*4, tile, g_hash_table_lookup(tile_hash, tile), tile_hash2 ? g_hash_table_lookup(tile_hash2, tile) : NULL, ib->type, item_bin_get_id(ib));
- if (tile_hash2)
- th=g_hash_table_lookup(tile_hash2, tile);
- if (!th)
- th=g_hash_table_lookup(tile_hash, tile);
- if (! th) {
- th=malloc(sizeof(struct tile_head)+ sizeof( char* ) );
- assert(th != NULL);
- // strcpy(th->subtiles, tile);
- th->num_subtiles=1;
- th->total_size=0;
- th->total_size_used=0;
- th->zipnum=0;
- th->zip_data=NULL;
- th->name=string_hash_lookup(tile);
- *th_get_subtile( th, 0 ) = th->name;
-
- if (tile_hash2)
- g_hash_table_insert(tile_hash2, string_hash_lookup( th->name ), th);
- if (tiles_list)
- *tiles_list=g_list_append(*tiles_list, string_hash_lookup( th->name ) );
- processed_tiles++;
- if (debug_tile(tile))
- fprintf(stderr,"new '%s'\n", tile);
- }
- th->total_size+=ib->len*4+4;
- if (debug_tile(tile))
- fprintf(stderr,"New total size of %s(%p):%d\n", th->name, th, th->total_size);
- g_hash_table_insert(tile_hash, string_hash_lookup( th->name ), th);
+static void tile_extend(char *tile, struct item_bin *ib, GList **tiles_list) {
+ struct tile_head *th=NULL;
+ if (debug_tile(tile))
+ fprintf(stderr,"Tile:Writing %d bytes to '%s' (%p,%p) 0x%x "LONGLONG_FMT"\n", (ib->len+1)*4, tile,
+ g_hash_table_lookup(tile_hash, tile), tile_hash2 ? g_hash_table_lookup(tile_hash2, tile) : NULL, ib->type,
+ item_bin_get_id(ib));
+ if (tile_hash2)
+ th=g_hash_table_lookup(tile_hash2, tile);
+ if (!th)
+ th=g_hash_table_lookup(tile_hash, tile);
+ if (! th) {
+ th=g_malloc(sizeof(struct tile_head)+ sizeof( char* ) );
+ // strcpy(th->subtiles, tile);
+ th->num_subtiles=1;
+ th->total_size=0;
+ th->total_size_used=0;
+ th->zipnum=0;
+ th->zip_data=NULL;
+ th->name=string_hash_lookup(tile);
+ *th_get_subtile( th, 0 ) = th->name;
+
+ if (tile_hash2)
+ g_hash_table_insert(tile_hash2, string_hash_lookup( th->name ), th);
+ if (tiles_list)
+ *tiles_list=g_list_append(*tiles_list, string_hash_lookup( th->name ) );
+ processed_tiles++;
+ if (debug_tile(tile))
+ fprintf(stderr,"new '%s'\n", tile);
+ }
+ th->total_size+=ib->len*4+4;
+ if (debug_tile(tile))
+ fprintf(stderr,"New total size of %s(%p):%d\n", th->name, th, th->total_size);
+ g_hash_table_insert(tile_hash, string_hash_lookup( th->name ), th);
}
-static int
-tile_data_size(char *tile)
-{
- struct tile_head *th;
- th=g_hash_table_lookup(tile_hash, tile);
- if (! th)
- return 0;
- return th->total_size;
+static int tile_data_size(char *tile) {
+ struct tile_head *th;
+ th=g_hash_table_lookup(tile_hash, tile);
+ if (! th)
+ return 0;
+ return th->total_size;
}
-static int
-merge_tile(char *base, char *sub)
-{
- struct tile_head *thb, *ths;
- thb=g_hash_table_lookup(tile_hash, base);
- ths=g_hash_table_lookup(tile_hash, sub);
- if (! ths)
- return 0;
- if (debug_tile(base) || debug_tile(sub))
- fprintf(stderr,"merging '%s'(%p) (%d) with '%s'(%p) (%d)\n", base, thb, thb ? thb->total_size : 0, sub, ths, ths->total_size);
- if (! thb) {
- thb=ths;
- g_hash_table_remove(tile_hash, sub);
- thb->name=string_hash_lookup(base);
- g_hash_table_insert(tile_hash, string_hash_lookup( thb->name ), thb);
-
- } else {
- thb=realloc(thb, sizeof(struct tile_head)+( ths->num_subtiles+thb->num_subtiles ) * sizeof( char*) );
- assert(thb != NULL);
- memcpy( th_get_subtile( thb, thb->num_subtiles ), th_get_subtile( ths, 0 ), ths->num_subtiles * sizeof( char*) );
- thb->num_subtiles+=ths->num_subtiles;
- thb->total_size+=ths->total_size;
- g_hash_table_insert(tile_hash, string_hash_lookup( thb->name ), thb);
- g_hash_table_remove(tile_hash, sub);
- g_free(ths);
- }
- return 1;
+static int merge_tile(char *base, char *sub) {
+ struct tile_head *thb, *ths;
+ thb=g_hash_table_lookup(tile_hash, base);
+ ths=g_hash_table_lookup(tile_hash, sub);
+ if (! ths)
+ return 0;
+ if (debug_tile(base) || debug_tile(sub))
+ fprintf(stderr,"merging '%s'(%p) (%d) with '%s'(%p) (%d)\n", base, thb, thb ? thb->total_size : 0, sub, ths,
+ ths->total_size);
+ if (! thb) {
+ thb=ths;
+ g_hash_table_remove(tile_hash, sub);
+ thb->name=string_hash_lookup(base);
+ g_hash_table_insert(tile_hash, string_hash_lookup( thb->name ), thb);
+
+ } else {
+ thb=g_realloc(thb, sizeof(struct tile_head)+( ths->num_subtiles+thb->num_subtiles ) * sizeof( char*) );
+ memcpy( th_get_subtile( thb, thb->num_subtiles ), th_get_subtile( ths, 0 ), ths->num_subtiles * sizeof( char*) );
+ thb->num_subtiles+=ths->num_subtiles;
+ thb->total_size+=ths->total_size;
+ g_hash_table_insert(tile_hash, string_hash_lookup( thb->name ), thb);
+ g_hash_table_remove(tile_hash, sub);
+ g_free(ths);
+ }
+ return 1;
}
-static gint
-get_tiles_list_cmp(gconstpointer s1, gconstpointer s2)
-{
- return strcmp((char *)s1, (char *)s2);
+static gint get_tiles_list_cmp(gconstpointer s1, gconstpointer s2) {
+ return g_strcmp0((char *)s1, (char *)s2);
}
-static void
-get_tiles_list_func(char *key, struct tile_head *th, GList **list)
-{
- *list=g_list_prepend(*list, key);
+static void get_tiles_list_func(char *key, struct tile_head *th, GList **list) {
+ *list=g_list_prepend(*list, key);
}
-static GList *
-get_tiles_list(void)
-{
- GList *ret=NULL;
- g_hash_table_foreach(tile_hash, (GHFunc)get_tiles_list_func, &ret);
- ret=g_list_sort(ret, get_tiles_list_cmp);
- return ret;
+static GList *get_tiles_list(void) {
+ GList *ret=NULL;
+ g_hash_table_foreach(tile_hash, (GHFunc)get_tiles_list_func, &ret);
+ ret=g_list_sort(ret, get_tiles_list_cmp);
+ return ret;
}
#if 0
-static void
-write_tile(char *key, struct tile_head *th, gpointer dummy)
-{
- FILE *f;
- char buffer[1024];
- fprintf(stderr,"DEBUG: Writing %s\n", key);
- strcpy(buffer,"tiles/");
- strcat(buffer,key);
+static void write_tile(char *key, struct tile_head *th, gpointer dummy) {
+ FILE *f;
+ char buffer[1024];
+ fprintf(stderr,"DEBUG: Writing %s\n", key);
+ strcpy(buffer,"tiles/");
+ strcat(buffer,key);
#if 0
- strcat(buffer,".bin");
+ strcat(buffer,".bin");
#endif
- f=fopen(buffer, "wb+");
- while (th) {
- fwrite(th->data, th->size, 1, f);
- th=th->next;
- }
- fclose(f);
+ f=fopen(buffer, "wb+");
+ while (th) {
+ fwrite(th->data, th->size, 1, f);
+ th=th->next;
+ }
+ fclose(f);
}
#endif
-static void
-write_item(char *tile, struct item_bin *ib, FILE *reference)
-{
- struct tile_head *th;
- int size;
-
- th=g_hash_table_lookup(tile_hash2, tile);
- if (debug_itembin(ib)) {
- fprintf(stderr,"tile head %p\n",th);
- }
- if (! th)
- th=g_hash_table_lookup(tile_hash, tile);
- if (th) {
- if (debug_itembin(ib)) {
- fprintf(stderr,"Match %s %d %s\n",tile,th->process,th->name);
- dump_itembin(ib);
- }
- if (th->process != 0 && th->process != 1) {
- fprintf(stderr,"error with tile '%s' of length %d\n", tile, (int)strlen(tile));
- abort();
- }
- if (! th->process) {
- if (reference)
- fseek(reference, 8, SEEK_CUR);
- return;
- }
- if (debug_tile(tile))
- fprintf(stderr,"Data:Writing %d bytes to '%s' (%p,%p) 0x%x\n", (ib->len+1)*4, tile, g_hash_table_lookup(tile_hash, tile), tile_hash2 ? g_hash_table_lookup(tile_hash2, tile) : NULL, ib->type);
- size=(ib->len+1)*4;
- if (th->total_size_used+size > th->total_size) {
- fprintf(stderr,"Overflow in tile %s (used %d max %d item %d)\n", tile, th->total_size_used, th->total_size, size);
- exit(1);
- return;
- }
- if (reference) {
- int offset=th->total_size_used/4;
- dbg_assert(fwrite(&th->zipnum, sizeof(th->zipnum), 1, reference)==1);
- dbg_assert(fwrite(&offset, sizeof(th->total_size_used), 1, reference)==1);
- }
- if (th->zip_data)
- memcpy(th->zip_data+th->total_size_used, ib, size);
- th->total_size_used+=size;
- } else {
- fprintf(stderr,"no tile hash found for %s\n", tile);
- exit(1);
- }
+static void write_item(char *tile, struct item_bin *ib, FILE *reference) {
+ struct tile_head *th;
+ int size;
+
+ th=g_hash_table_lookup(tile_hash2, tile);
+ if (debug_itembin(ib)) {
+ fprintf(stderr,"tile head %p\n",th);
+ }
+ if (! th)
+ th=g_hash_table_lookup(tile_hash, tile);
+ if (th) {
+ if (debug_itembin(ib)) {
+ fprintf(stderr,"Match %s %d %s\n",tile,th->process,th->name);
+ dump_itembin(ib);
+ }
+ if (th->process != 0 && th->process != 1) {
+ fprintf(stderr,"error with tile '%s' of length %d\n", tile, (int)strlen(tile));
+ abort();
+ }
+ if (! th->process) {
+ if (reference)
+ fseek(reference, 8, SEEK_CUR);
+ return;
+ }
+ if (debug_tile(tile))
+ fprintf(stderr,"Data:Writing %d bytes to '%s' (%p,%p) 0x%x\n", (ib->len+1)*4, tile, g_hash_table_lookup(tile_hash,
+ tile), tile_hash2 ? g_hash_table_lookup(tile_hash2, tile) : NULL, ib->type);
+ size=(ib->len+1)*4;
+ if (th->total_size_used+size > th->total_size) {
+ fprintf(stderr,"Overflow in tile %s (used %d max %d item %d)\n", tile, th->total_size_used, th->total_size, size);
+ exit(1);
+ return;
+ }
+ if (reference) {
+ int offset=th->total_size_used/4;
+ dbg_assert(fwrite(&th->zipnum, sizeof(th->zipnum), 1, reference)==1);
+ dbg_assert(fwrite(&offset, sizeof(th->total_size_used), 1, reference)==1);
+ }
+ if (th->zip_data)
+ memcpy(th->zip_data+th->total_size_used, ib, size);
+ th->total_size_used+=size;
+ } else {
+ fprintf(stderr,"no tile hash found for %s\n", tile);
+ exit(1);
+ }
}
-void
-tile_write_item_to_tile(struct tile_info *info, struct item_bin *ib, FILE *reference, char *name)
-{
- if (info->write)
- write_item(name, ib, reference);
- else
- tile_extend(name, ib, info->tiles_list);
+void tile_write_item_to_tile(struct tile_info *info, struct item_bin *ib, FILE *reference, char *name) {
+ if (info->write)
+ write_item(name, ib, reference);
+ else
+ tile_extend(name, ib, info->tiles_list);
}
-void
-tile_write_item_minmax(struct tile_info *info, struct item_bin *ib, FILE *reference, int min, int max)
-{
- struct rect r;
- char buffer[1024];
- bbox((struct coord *)(ib+1), ib->clen/2, &r);
- buffer[0]='\0';
- tile(&r, info->suffix, buffer, max, overlap, NULL);
- tile_write_item_to_tile(info, ib, reference, buffer);
+void tile_write_item_minmax(struct tile_info *info, struct item_bin *ib, FILE *reference, int min, int max) {
+ struct rect r;
+ char buffer[1024];
+ bbox((struct coord *)(ib+1), ib->clen/2, &r);
+ buffer[0]='\0';
+ tile(&r, info->suffix, buffer, max, overlap, NULL);
+ tile_write_item_to_tile(info, ib, reference, buffer);
}
-int
-add_aux_tile(struct zip_info *zip_info, char *name, char *filename, int size)
-{
- struct aux_tile *at;
- GList *l;
- l=aux_tile_list;
- while (l) {
- at=l->data;
- if (!strcmp(at->name, name)) {
- return -1;
- }
- l=g_list_next(l);
- }
- at=g_new0(struct aux_tile, 1);
- at->name=g_strdup(name);
- at->filename=g_strdup(filename);
- at->size=size;
- aux_tile_list=g_list_append(aux_tile_list, at);
- fprintf(stderr,"Adding %s as %s\n",filename, name);
- return zip_add_member(zip_info);
+int add_aux_tile(struct zip_info *zip_info, char *name, char *filename, int size) {
+ struct aux_tile *at;
+ GList *l;
+ l=aux_tile_list;
+ while (l) {
+ at=l->data;
+ if (!g_strcmp0(at->name, name)) {
+ return -1;
+ }
+ l=g_list_next(l);
+ }
+ at=g_new0(struct aux_tile, 1);
+ at->name=g_strdup(name);
+ at->filename=g_strdup(filename);
+ at->size=size;
+ aux_tile_list=g_list_append(aux_tile_list, at);
+ fprintf(stderr,"Adding %s as %s\n",filename, name);
+ return zip_add_member(zip_info);
}
-int
-write_aux_tiles(struct zip_info *zip_info)
-{
- GList *l=aux_tile_list;
- struct aux_tile *at;
- char *buffer;
- FILE *f;
- int count=0;
-
- while (l) {
- at=l->data;
- buffer=malloc(at->size);
- assert(buffer != NULL);
- f=fopen(at->filename,"rb");
- assert(f != NULL);
- fread(buffer, at->size, 1, f);
- fclose(f);
- write_zipmember(zip_info, at->name, zip_get_maxnamelen(zip_info), buffer, at->size);
- free(buffer);
- count++;
- l=g_list_next(l);
- zip_add_member(zip_info);
- }
- return count;
+int write_aux_tiles(struct zip_info *zip_info) {
+ GList *l=aux_tile_list;
+ struct aux_tile *at;
+ char *buffer;
+ FILE *f;
+ int count=0;
+
+ while (l) {
+ at=l->data;
+ buffer=g_malloc(at->size);
+ f=fopen(at->filename,"rb");
+ assert(f != NULL);
+
+ if (fread(buffer, at->size, 1, f) == 0) {
+ dbg(lvl_warning, "fread failed");
+ fclose(f);
+ } else {
+ fclose(f);
+ write_zipmember(zip_info, at->name, zip_get_maxnamelen(zip_info), buffer, at->size);
+ count++;
+ l=g_list_next(l);
+ zip_add_member(zip_info);
+ }
+ g_free(buffer);
+ }
+ return count;
}
-static int
-add_tile_hash(struct tile_head *th)
-{
- int idx,len,maxnamelen=0;
- char **data;
+static int add_tile_hash(struct tile_head *th) {
+ int idx,len,maxnamelen=0;
+ char **data;
-#if 0
- g_hash_table_insert(tile_hash2, string_hash_lookup( th->name ), th);
-#endif
- for( idx = 0; idx < th->num_subtiles; idx++ ) {
+ for( idx = 0; idx < th->num_subtiles; idx++ ) {
- data = th_get_subtile( th, idx );
+ data = th_get_subtile( th, idx );
- if (debug_tile(((char *)data)) || debug_tile(th->name)) {
- fprintf(stderr,"Parent for '%s' is '%s'\n", *data, th->name);
- }
+ if (debug_tile(((char *)data)) || debug_tile(th->name)) {
+ fprintf(stderr,"Parent for '%s' is '%s'\n", *data, th->name);
+ }
- g_hash_table_insert(tile_hash2, *data, th);
+ g_hash_table_insert(tile_hash2, *data, th);
- len = strlen( *data );
+ len = strlen( *data );
- if (len > maxnamelen) {
- maxnamelen=len;
- }
- }
- return maxnamelen;
+ if (len > maxnamelen) {
+ maxnamelen=len;
+ }
+ }
+ return maxnamelen;
}
-int
-create_tile_hash(void)
-{
- struct tile_head *th;
- int len,maxnamelen=0;
-
- tile_hash2=g_hash_table_new(g_str_hash, g_str_equal);
- th=tile_head_root;
- while (th) {
- len=add_tile_hash(th);
- if (len > maxnamelen)
- maxnamelen=len;
- th=th->next;
- }
- return maxnamelen;
+int create_tile_hash(void) {
+ struct tile_head *th;
+ int len,maxnamelen=0;
+
+ tile_hash2=g_hash_table_new(g_str_hash, g_str_equal);
+ th=tile_head_root;
+ while (th) {
+ len=add_tile_hash(th);
+ if (len > maxnamelen)
+ maxnamelen=len;
+ th=th->next;
+ }
+ return maxnamelen;
}
-static void
-create_tile_hash_list(GList *list)
-{
- GList *next;
- struct tile_head *th;
-
- tile_hash2=g_hash_table_new(g_str_hash, g_str_equal);
-
- next=g_list_first(list);
- while (next) {
- th=g_hash_table_lookup(tile_hash, next->data);
- if (!th) {
- fprintf(stderr,"No tile found for '%s'\n", (char *)(next->data));
- }
- add_tile_hash(th);
- next=g_list_next(next);
- }
+static void create_tile_hash_list(GList *list) {
+ GList *next;
+ struct tile_head *th;
+
+ tile_hash2=g_hash_table_new(g_str_hash, g_str_equal);
+
+ next=g_list_first(list);
+ while (next) {
+ th=g_hash_table_lookup(tile_hash, next->data);
+ if (!th) {
+ fprintf(stderr,"No tile found for '%s'\n", (char *)(next->data));
+ }
+ add_tile_hash(th);
+ next=g_list_next(next);
+ }
}
-void
-load_tilesdir(FILE *in)
-{
- char tile[32],subtile[32],c;
- int size,zipnum=0;
- struct tile_head **last;
- create_tile_hash();
- tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
- last=&tile_head_root;
- while (fscanf(in,"%[^:]:%d",tile,&size) == 2) {
- struct tile_head *th=malloc(sizeof(struct tile_head));
- if (!strcmp(tile,"index"))
- tile[0]='\0';
- th->num_subtiles=0;
- th->total_size=size;
- th->total_size_used=0;
- th->zipnum=zipnum++;
- th->zip_data=NULL;
- th->name=string_hash_lookup(tile);
-#if 0
- printf("tile '%s' %d\n",tile,size);
-#endif
- while (fscanf(in,":%[^:\n]",subtile) == 1) {
-#if 0
- printf("subtile '%s'\n",subtile);
-#endif
- th=realloc(th, sizeof(struct tile_head)+(th->num_subtiles+1)*sizeof(char*));
- *th_get_subtile( th, th->num_subtiles ) = string_hash_lookup(subtile);
- th->num_subtiles++;
- }
- *last=th;
- last=&th->next;
- add_tile_hash(th);
- g_hash_table_insert(tile_hash, th->name, th);
- if (fread(&c, 1, 1, in) != 1 || c != '\n') {
- printf("syntax error\n");
- }
- }
- *last=NULL;
+void load_tilesdir(FILE *in) {
+ char tile[32],subtile[32],c;
+ int size,zipnum=0;
+ struct tile_head **last;
+ create_tile_hash();
+ tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
+ last=&tile_head_root;
+ while (fscanf(in,"%[^:]:%d",tile,&size) == 2) {
+ struct tile_head *th=g_malloc(sizeof(struct tile_head));
+ if (!g_strcmp0(tile,"index"))
+ tile[0]='\0';
+ th->num_subtiles=0;
+ th->total_size=size;
+ th->total_size_used=0;
+ th->zipnum=zipnum++;
+ th->zip_data=NULL;
+ th->name=string_hash_lookup(tile);
+ while (fscanf(in,":%[^:\n]",subtile) == 1) {
+ th=g_realloc(th, sizeof(struct tile_head)+(th->num_subtiles+1)*sizeof(char*));
+ *th_get_subtile( th, th->num_subtiles ) = string_hash_lookup(subtile);
+ th->num_subtiles++;
+ }
+ *last=th;
+ last=&th->next;
+ add_tile_hash(th);
+ g_hash_table_insert(tile_hash, th->name, th);
+ if (fread(&c, 1, 1, in) != 1 || c != '\n') {
+ printf("syntax error\n");
+ }
+ }
+ *last=NULL;
}
-void
-write_tilesdir(struct tile_info *info, struct zip_info *zip_info, FILE *out)
-{
- int idx,len,maxlen;
- GList *next,*tiles_list;
- char **data;
- struct tile_head *th,**last=NULL;
-
- tiles_list=get_tiles_list();
- info->tiles_list=&tiles_list;
- if (! info->write)
- create_tile_hash_list(tiles_list);
- next=g_list_first(tiles_list);
- last=&tile_head_root;
- maxlen=info->maxlen;
- if (! maxlen) {
- while (next) {
- if (strlen(next->data) > maxlen)
- maxlen=strlen(next->data);
- next=g_list_next(next);
- }
- }
- len=maxlen;
- while (len >= 0) {
-#if 0
- fprintf(stderr,"PROGRESS: collecting tiles with len=%d\n", len);
-#endif
- next=g_list_first(tiles_list);
- while (next) {
- if (strlen(next->data) == len) {
- th=g_hash_table_lookup(tile_hash, next->data);
- if (!info->write) {
- *last=th;
- last=&th->next;
- th->next=NULL;
- th->zipnum=zip_get_zipnum(zip_info);
- fprintf(out,"%s:%d",strlen((char *)next->data)?(char *)next->data:"index",th->total_size);
-
- for ( idx = 0; idx< th->num_subtiles; idx++ ){
- data= th_get_subtile( th, idx );
- fprintf(out,":%s", *data);
- }
-
- fprintf(out,"\n");
- }
- if (th->name[strlen(info->suffix)])
- index_submap_add(info, th);
- zip_add_member(zip_info);
- processed_tiles++;
- }
- next=g_list_next(next);
- }
- len--;
- }
- g_list_free(tiles_list);
- if (info->suffix[0] && info->write) {
- struct item_bin *item_bin=init_item(type_submap);
- item_bin_add_coord_rect(item_bin, &world_bbox);
- item_bin_add_attr_range(item_bin, attr_order, 0, 255);
- item_bin_add_attr_int(item_bin, attr_zipfile_ref, zip_get_zipnum(zip_info)-1);
- item_bin_write(item_bin, zip_get_index(zip_info));
- }
+void write_tilesdir(struct tile_info *info, struct zip_info *zip_info, FILE *out) {
+ int idx,len,maxlen;
+ GList *next,*tiles_list;
+ char **data;
+ struct tile_head *th,**last=NULL;
+
+ tiles_list=get_tiles_list();
+ info->tiles_list=&tiles_list;
+ if (! info->write)
+ create_tile_hash_list(tiles_list);
+ next=g_list_first(tiles_list);
+ last=&tile_head_root;
+ maxlen=info->maxlen;
+ if (! maxlen) {
+ while (next) {
+ if (strlen(next->data) > maxlen)
+ maxlen=strlen(next->data);
+ next=g_list_next(next);
+ }
+ }
+ len=maxlen;
+ while (len >= 0) {
+ next=g_list_first(tiles_list);
+ while (next) {
+ if (strlen(next->data) == len) {
+ th=g_hash_table_lookup(tile_hash, next->data);
+ if (!info->write) {
+ *last=th;
+ last=&th->next;
+ th->next=NULL;
+ th->zipnum=zip_get_zipnum(zip_info);
+ fprintf(out,"%s:%d",strlen((char *)next->data)?(char *)next->data:"index",th->total_size);
+
+ for ( idx = 0; idx< th->num_subtiles; idx++ ) {
+ data= th_get_subtile( th, idx );
+ fprintf(out,":%s", *data);
+ }
+
+ fprintf(out,"\n");
+ }
+ if (th->name[strlen(info->suffix)])
+ index_submap_add(info, th);
+ zip_add_member(zip_info);
+ processed_tiles++;
+ }
+ next=g_list_next(next);
+ }
+ len--;
+ }
+ g_list_free(tiles_list);
+ if (info->suffix[0] && info->write) {
+ struct item_bin *item_bin=init_item(type_submap);
+ item_bin_add_coord_rect(item_bin, &world_bbox);
+ item_bin_add_attr_range(item_bin, attr_order, 0, 255);
+ item_bin_add_attr_int(item_bin, attr_zipfile_ref, zip_get_zipnum(zip_info)-1);
+ item_bin_write(item_bin, zip_get_index(zip_info));
+ }
}
-void
-merge_tiles(struct tile_info *info)
-{
- struct tile_head *th;
- char basetile[1024];
- char subtile[1024];
- GList *tiles_list_sorted,*last;
- int i,i_min,len,size_all,size[5],size_min,work_done;
- long long zip_size;
-
- do {
- tiles_list_sorted=get_tiles_list();
- fprintf(stderr,"PROGRESS: sorting %d tiles\n", g_list_length(tiles_list_sorted));
- tiles_list_sorted=g_list_sort(tiles_list_sorted, (GCompareFunc)strcmp);
- fprintf(stderr,"PROGRESS: sorting %d tiles done\n", g_list_length(tiles_list_sorted));
- last=g_list_last(tiles_list_sorted);
- zip_size=0;
- while (last) {
- th=g_hash_table_lookup(tile_hash, last->data);
- zip_size+=th->total_size;
- last=g_list_previous(last);
- }
- last=g_list_last(tiles_list_sorted);
- work_done=0;
- while (last) {
- processed_tiles++;
- len=tile_len(last->data);
- if (len >= 1) {
- strcpy(basetile,last->data);
- basetile[len-1]='\0';
- strcat(basetile, info->suffix);
- strcpy(subtile,last->data);
- for (i = 0 ; i < 4 ; i++) {
- subtile[len-1]='a'+i;
- size[i]=tile_data_size(subtile);
- }
- size[4]=tile_data_size(basetile);
- size_all=size[0]+size[1]+size[2]+size[3]+size[4];
- if (size_all < 65536 && size_all > 0 && size_all != size[4]) {
- for (i = 0 ; i < 4 ; i++) {
- subtile[len-1]='a'+i;
- work_done+=merge_tile(basetile, subtile);
- }
- } else {
- for (;;) {
- size_min=size_all;
- i_min=-1;
- for (i = 0 ; i < 4 ; i++) {
- if (size[i] && size[i] < size_min) {
- size_min=size[i];
- i_min=i;
- }
- }
- if (i_min == -1)
- break;
- if (size[4]+size_min >= 65536)
- break;
- subtile[len-1]='a'+i_min;
- work_done+=merge_tile(basetile, subtile);
- size[4]+=size[i_min];
- size[i_min]=0;
- }
- }
- }
- last=g_list_previous(last);
- }
- g_list_free(tiles_list_sorted);
- fprintf(stderr,"PROGRESS: merged %d tiles\n", work_done);
- } while (work_done);
+void merge_tiles(struct tile_info *info) {
+ struct tile_head *th;
+ char basetile[1024];
+ char subtile[1024];
+ GList *tiles_list_sorted,*last;
+ int i,i_min,len,size_all,size[5],size_min,work_done;
+ long long zip_size;
+
+ do {
+ tiles_list_sorted=get_tiles_list();
+ fprintf(stderr,"PROGRESS: sorting %d tiles\n", g_list_length(tiles_list_sorted));
+ tiles_list_sorted=g_list_sort(tiles_list_sorted, (GCompareFunc)g_strcmp0);
+ fprintf(stderr,"PROGRESS: sorting %d tiles done\n", g_list_length(tiles_list_sorted));
+ last=g_list_last(tiles_list_sorted);
+ zip_size=0;
+ while (last) {
+ th=g_hash_table_lookup(tile_hash, last->data);
+ zip_size+=th->total_size;
+ last=g_list_previous(last);
+ }
+ last=g_list_last(tiles_list_sorted);
+ work_done=0;
+ while (last) {
+ processed_tiles++;
+ len=tile_len(last->data);
+ if (len >= 1) {
+ strcpy(basetile,last->data);
+ basetile[len-1]='\0';
+ strcat(basetile, info->suffix);
+ strcpy(subtile,last->data);
+ for (i = 0 ; i < 4 ; i++) {
+ subtile[len-1]='a'+i;
+ size[i]=tile_data_size(subtile);
+ }
+ size[4]=tile_data_size(basetile);
+ size_all=size[0]+size[1]+size[2]+size[3]+size[4];
+ if (size_all < 65536 && size_all > 0 && size_all != size[4]) {
+ for (i = 0 ; i < 4 ; i++) {
+ subtile[len-1]='a'+i;
+ work_done+=merge_tile(basetile, subtile);
+ }
+ } else {
+ for (;;) {
+ size_min=size_all;
+ i_min=-1;
+ for (i = 0 ; i < 4 ; i++) {
+ if (size[i] && size[i] < size_min) {
+ size_min=size[i];
+ i_min=i;
+ }
+ }
+ if (i_min == -1)
+ break;
+ if (size[4]+size_min >= 65536)
+ break;
+ subtile[len-1]='a'+i_min;
+ work_done+=merge_tile(basetile, subtile);
+ size[4]+=size[i_min];
+ size[i_min]=0;
+ }
+ }
+ }
+ last=g_list_previous(last);
+ }
+ g_list_free(tiles_list_sorted);
+ fprintf(stderr,"PROGRESS: merged %d tiles\n", work_done);
+ } while (work_done);
}
struct attr map_information_attrs[32];
-void
-index_init(struct zip_info *info, int version)
-{
- struct item_bin *item_bin;
- int i;
- map_information_attrs[0].type=attr_version;
- map_information_attrs[0].u.num=version;
- item_bin=init_item(type_map_information);
- for (i = 0 ; i < 32 ; i++) {
- if (!map_information_attrs[i].type)
- break;
- item_bin_add_attr(item_bin, &map_information_attrs[i]);
- }
- item_bin_write(item_bin, zip_get_index(info));
+void index_init(struct zip_info *info, int version) {
+ struct item_bin *item_bin;
+ int i;
+ map_information_attrs[0].type=attr_version;
+ map_information_attrs[0].u.num=version;
+ item_bin=init_item(type_map_information);
+ for (i = 0 ; i < 32 ; i++) {
+ if (!map_information_attrs[i].type)
+ break;
+ item_bin_add_attr(item_bin, &map_information_attrs[i]);
+ }
+ item_bin_write(item_bin, zip_get_index(info));
}
-void
-index_submap_add(struct tile_info *info, struct tile_head *th)
-{
- int tlen=tile_len(th->name);
- int len=tlen;
- char *index_tile;
- struct rect r;
- struct item_bin *item_bin;
-
- index_tile=g_alloca(len+1+strlen(info->suffix));
- strcpy(index_tile, th->name);
- if (len > 6)
- len=6;
- else
- len=0;
- index_tile[len]=0;
- strcat(index_tile, info->suffix);
- tile_bbox(th->name, &r, overlap);
-
- item_bin=init_item(type_submap);
- item_bin_add_coord_rect(item_bin, &r);
- item_bin_add_attr_range(item_bin, attr_order, (tlen > 4)?tlen-4 : 0, 255);
- item_bin_add_attr_int(item_bin, attr_zipfile_ref, th->zipnum);
- tile_write_item_to_tile(info, item_bin, NULL, index_tile);
+void index_submap_add(struct tile_info *info, struct tile_head *th) {
+ int tlen=tile_len(th->name);
+ int len=tlen;
+ char *index_tile;
+ struct rect r;
+ struct item_bin *item_bin;
+
+ index_tile=g_alloca(len+1+strlen(info->suffix));
+ strcpy(index_tile, th->name);
+ if (len > 6)
+ len=6;
+ else
+ len=0;
+ index_tile[len]=0;
+ strcat(index_tile, info->suffix);
+ tile_bbox(th->name, &r, overlap);
+
+ item_bin=init_item(type_submap);
+ item_bin_add_coord_rect(item_bin, &r);
+ item_bin_add_attr_range(item_bin, attr_order, (tlen > 4)?tlen-4 : 0, 255);
+ item_bin_add_attr_int(item_bin, attr_zipfile_ref, th->zipnum);
+ tile_write_item_to_tile(info, item_bin, NULL, index_tile);
}
diff --git a/navit/maptool/zip.c b/navit/maptool/zip.c
index a4e040974..33fcab6c0 100644
--- a/navit/maptool/zip.c
+++ b/navit/maptool/zip.c
@@ -26,339 +26,304 @@
#include "zipfile.h"
struct zip_info {
- int zipnum;
- int dir_size;
- long long offset;
- int compression_level;
- int maxnamelen;
- int zip64;
- short date;
- short time;
- FILE *res2;
- FILE *index;
- FILE *dir;
+ int zipnum;
+ int dir_size;
+ long long offset;
+ int compression_level;
+ int maxnamelen;
+ int zip64;
+ short date;
+ short time;
+ FILE *res2;
+ FILE *index;
+ FILE *dir;
};
-static int
-zip_write(struct zip_info *info, void *data, int len)
-{
- if (fwrite(data, len, 1, info->res2) != 1)
- return 0;
- return 1;
+static int zip_write(struct zip_info *info, void *data, int len) {
+ if (fwrite(data, len, 1, info->res2) != 1)
+ return 0;
+ return 1;
}
#ifdef HAVE_ZLIB
-static int
-compress2_int(Byte *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
- stream.opaque = (voidpf)0;
-
- err = deflateInit2(&stream, level, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY);
- if (err != Z_OK) return err;
-
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
-
- err = deflateEnd(&stream);
- return err;
+static int compress2_int(Byte *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level) {
+ z_stream stream;
+ int err;
+
+ stream.next_in = (Bytef*)source;
+ stream.avail_in = (uInt)sourceLen;
+ stream.next_out = dest;
+ stream.avail_out = (uInt)*destLen;
+ if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+
+ stream.zalloc = (alloc_func)0;
+ stream.zfree = (free_func)0;
+ stream.opaque = (voidpf)0;
+
+ err = deflateInit2(&stream, level, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY);
+ if (err != Z_OK) return err;
+
+ err = deflate(&stream, Z_FINISH);
+ if (err != Z_STREAM_END) {
+ deflateEnd(&stream);
+ return err == Z_OK ? Z_BUF_ERROR : err;
+ }
+ *destLen = stream.total_out;
+
+ err = deflateEnd(&stream);
+ return err;
}
#endif
-void
-write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data, int data_size)
-{
- struct zip_lfh lfh = {
- 0x04034b50,
- 0x0a,
- 0x0,
- 0x0,
- zip_info->time,
- zip_info->date,
- 0x0,
- 0x0,
- 0x0,
- filelen,
- 0x0,
- };
- struct zip_cd cd = {
- 0x02014b50,
- 0x17,
- 0x00,
- 0x0a,
- 0x00,
- 0x0000,
- 0x0,
- zip_info->time,
- zip_info->date,
- 0x0,
- 0x0,
- 0x0,
- filelen,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0,
- zip_info->offset,
- };
- struct zip_cd_ext cd_ext = {
- 0x1,
- 0x8,
- zip_info->offset,
- };
- char *filename;
- int crc=0,len,comp_size=data_size;
- uLongf destlen=data_size+data_size/500+12;
- char *compbuffer;
-
- compbuffer = malloc(destlen);
- if (!compbuffer) {
- fprintf(stderr, "No more memory.\n");
- exit (1);
- }
- crc=crc32(0, NULL, 0);
- crc=crc32(crc, (unsigned char *)data, data_size);
- lfh.zipmthd=zip_info->compression_level ? 8:0;
+void write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data, int data_size) {
+ struct zip_lfh lfh = {
+ 0x04034b50,
+ 0x0a,
+ 0x0,
+ 0x0,
+ zip_info->time,
+ zip_info->date,
+ 0x0,
+ 0x0,
+ 0x0,
+ filelen,
+ 0x0,
+ };
+ struct zip_cd cd = {
+ 0x02014b50,
+ 0x17,
+ 0x00,
+ 0x0a,
+ 0x00,
+ 0x0000,
+ 0x0,
+ zip_info->time,
+ zip_info->date,
+ 0x0,
+ 0x0,
+ 0x0,
+ filelen,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0,
+ zip_info->offset,
+ };
+ struct zip_cd_ext cd_ext = {
+ 0x1,
+ 0x8,
+ zip_info->offset,
+ };
+ char *filename;
+ int crc=0,len,comp_size=data_size;
+ uLongf destlen=data_size+data_size/500+12;
+ char *compbuffer;
+
+ compbuffer = g_malloc(destlen);
+ crc=crc32(0, NULL, 0);
+ crc=crc32(crc, (unsigned char *)data, data_size);
+ lfh.zipmthd=zip_info->compression_level ? 8:0;
#ifdef HAVE_ZLIB
- if (zip_info->compression_level) {
- int error=compress2_int((Byte *)compbuffer, &destlen, (Bytef *)data, data_size, zip_info->compression_level);
- if (error == Z_OK) {
- if (destlen < data_size) {
- data=compbuffer;
- comp_size=destlen;
- } else
- lfh.zipmthd=0;
- } else {
- fprintf(stderr,"compress2 returned %d\n", error);
- }
- }
+ if (zip_info->compression_level) {
+ int error=compress2_int((Byte *)compbuffer, &destlen, (Bytef *)data, data_size, zip_info->compression_level);
+ if (error == Z_OK) {
+ if (destlen < data_size) {
+ data=compbuffer;
+ comp_size=destlen;
+ } else
+ lfh.zipmthd=0;
+ } else {
+ fprintf(stderr,"compress2 returned %d\n", error);
+ }
+ }
#endif
- lfh.zipcrc=crc;
- lfh.zipsize=comp_size;
- lfh.zipuncmp=data_size;
- cd.zipccrc=crc;
- cd.zipcsiz=lfh.zipsize;
- cd.zipcunc=data_size;
- cd.zipcmthd=lfh.zipmthd;
- if (zip_info->zip64) {
- cd.zipofst=0xffffffff;
- cd.zipcxtl+=sizeof(cd_ext);
- }
- filename=g_alloca(filelen+1);
- strcpy(filename, name);
- len=strlen(filename);
- while (len < filelen) {
- filename[len++]='_';
- }
- filename[filelen]='\0';
- zip_write(zip_info, &lfh, sizeof(lfh));
- zip_write(zip_info, filename, filelen);
- zip_info->offset+=sizeof(lfh)+filelen;
- zip_write(zip_info, data, comp_size);
- zip_info->offset+=comp_size;
- dbg_assert(fwrite(&cd, sizeof(cd), 1, zip_info->dir)==1);
- dbg_assert(fwrite(filename, filelen, 1, zip_info->dir)==1);
- zip_info->dir_size+=sizeof(cd)+filelen;
- if (zip_info->zip64) {
- dbg_assert(fwrite(&cd_ext, sizeof(cd_ext), 1, zip_info->dir)==1);
- zip_info->dir_size+=sizeof(cd_ext);
- }
-
- free(compbuffer);
+ lfh.zipcrc=crc;
+ lfh.zipsize=comp_size;
+ lfh.zipuncmp=data_size;
+ cd.zipccrc=crc;
+ cd.zipcsiz=lfh.zipsize;
+ cd.zipcunc=data_size;
+ cd.zipcmthd=lfh.zipmthd;
+ if (zip_info->zip64) {
+ cd.zipofst=0xffffffff;
+ cd.zipcxtl+=sizeof(cd_ext);
+ }
+ filename=g_alloca(filelen+1);
+ strcpy(filename, name);
+ len=strlen(filename);
+ while (len < filelen) {
+ filename[len++]='_';
+ }
+ filename[filelen]='\0';
+ zip_write(zip_info, &lfh, sizeof(lfh));
+ zip_write(zip_info, filename, filelen);
+ zip_info->offset+=sizeof(lfh)+filelen;
+ zip_write(zip_info, data, comp_size);
+ zip_info->offset+=comp_size;
+ dbg_assert(fwrite(&cd, sizeof(cd), 1, zip_info->dir)==1);
+ dbg_assert(fwrite(filename, filelen, 1, zip_info->dir)==1);
+ zip_info->dir_size+=sizeof(cd)+filelen;
+ if (zip_info->zip64) {
+ dbg_assert(fwrite(&cd_ext, sizeof(cd_ext), 1, zip_info->dir)==1);
+ zip_info->dir_size+=sizeof(cd_ext);
+ }
+
+ g_free(compbuffer);
}
-void
-zip_write_index(struct zip_info *info)
-{
- int size=ftell(info->index);
- char *buffer;
-
- buffer=g_alloca(size);
- fseek(info->index, 0, SEEK_SET);
- fread(buffer, size, 1, info->index);
- write_zipmember(info, "index", strlen("index"), buffer, size);
- info->zipnum++;
+int zip_write_index(struct zip_info *info) {
+ int size=ftell(info->index);
+ char *buffer;
+
+ buffer=g_alloca(size);
+ fseek(info->index, 0, SEEK_SET);
+
+ if (fread(buffer, size, 1, info->index) == 0) {
+ dbg(lvl_warning, "fread failed");
+ return 1;
+ } else {
+ write_zipmember(info, "index", strlen("index"), buffer, size);
+ }
+ info->zipnum++;
+ return 0;
}
-static void
-zip_write_file_data(struct zip_info *info, FILE *in)
-{
- size_t size;
- char buffer[4096];
- while ((size=fread(buffer, 1, 4096, in)))
- zip_write(info, buffer, size);
+static void zip_write_file_data(struct zip_info *info, FILE *in) {
+ size_t size;
+ char buffer[4096];
+ while ((size=fread(buffer, 1, 4096, in)))
+ zip_write(info, buffer, size);
}
-int
-zip_write_directory(struct zip_info *info)
-{
- struct zip_eoc eoc = {
- 0x06054b50,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0,
- 0x0,
- 0x0,
- };
- struct zip64_eoc eoc64 = {
- 0x06064b50,
- 0x0,
- 0x0,
- 0x0403,
- 0x0,
- 0x0,
- 0x0,
- 0x0,
- 0x0,
- 0x0,
- };
- struct zip64_eocl eocl = {
- 0x07064b50,
- 0x0,
- 0x0,
- 0x0,
- };
-
- fseek(info->dir, 0, SEEK_SET);
- zip_write_file_data(info, info->dir);
- if (info->zip64) {
- eoc64.zip64esize=sizeof(eoc64)-12;
- eoc64.zip64enum=info->zipnum;
- eoc64.zip64ecenn=info->zipnum;
- eoc64.zip64ecsz=info->dir_size;
- eoc64.zip64eofst=info->offset;
- zip_write(info, &eoc64, sizeof(eoc64));
- eocl.zip64lofst=info->offset+info->dir_size;
- zip_write(info, &eocl, sizeof(eocl));
- }
- eoc.zipenum=info->zipnum;
- eoc.zipecenn=info->zipnum;
- eoc.zipecsz=info->dir_size;
- eoc.zipeofst=info->offset;
- zip_write(info, &eoc, sizeof(eoc));
- sig_alrm(0);
+int zip_write_directory(struct zip_info *info) {
+ struct zip_eoc eoc = {
+ 0x06054b50,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0000,
+ 0x0,
+ 0x0,
+ 0x0,
+ };
+ struct zip64_eoc eoc64 = {
+ 0x06064b50,
+ 0x0,
+ 0x0,
+ 0x0403,
+ 0x0,
+ 0x0,
+ 0x0,
+ 0x0,
+ 0x0,
+ 0x0,
+ };
+ struct zip64_eocl eocl = {
+ 0x07064b50,
+ 0x0,
+ 0x0,
+ 0x0,
+ };
+
+ fseek(info->dir, 0, SEEK_SET);
+ zip_write_file_data(info, info->dir);
+ if (info->zip64) {
+ eoc64.zip64esize=sizeof(eoc64)-12;
+ eoc64.zip64enum=info->zipnum;
+ eoc64.zip64ecenn=info->zipnum;
+ eoc64.zip64ecsz=info->dir_size;
+ eoc64.zip64eofst=info->offset;
+ zip_write(info, &eoc64, sizeof(eoc64));
+ eocl.zip64lofst=info->offset+info->dir_size;
+ zip_write(info, &eocl, sizeof(eocl));
+ }
+ eoc.zipenum=info->zipnum;
+ eoc.zipecenn=info->zipnum;
+ eoc.zipecsz=info->dir_size;
+ eoc.zipeofst=info->offset;
+ zip_write(info, &eoc, sizeof(eoc));
+ sig_alrm(0);
#ifndef _WIN32
- alarm(0);
+ alarm(0);
#endif
- return 0;
+ return 0;
}
struct zip_info *
-zip_new(void)
-{
- return g_new0(struct zip_info, 1);
+zip_new(void) {
+ return g_new0(struct zip_info, 1);
}
-void
-zip_set_zip64(struct zip_info *info, int on)
-{
- info->zip64=on;
+void zip_set_zip64(struct zip_info *info, int on) {
+ info->zip64=on;
}
-void
-zip_set_compression_level(struct zip_info *info, int level)
-{
- info->compression_level=level;
+void zip_set_compression_level(struct zip_info *info, int level) {
+ info->compression_level=level;
}
-void
-zip_set_maxnamelen(struct zip_info *info, int max)
-{
- info->maxnamelen=max;
+void zip_set_maxnamelen(struct zip_info *info, int max) {
+ info->maxnamelen=max;
}
-int
-zip_get_maxnamelen(struct zip_info *info)
-{
- return info->maxnamelen;
+int zip_get_maxnamelen(struct zip_info *info) {
+ return info->maxnamelen;
}
-int
-zip_add_member(struct zip_info *info)
-{
- return info->zipnum++;
+int zip_add_member(struct zip_info *info) {
+ return info->zipnum++;
}
-int
-zip_set_timestamp(struct zip_info *info, char *timestamp)
-{
- int year,month,day,hour,min,sec;
+int zip_set_timestamp(struct zip_info *info, char *timestamp) {
+ int year,month,day,hour,min,sec;
- if (sscanf(timestamp,"%d-%d-%dT%d:%d:%d",&year,&month,&day,&hour,&min,&sec) == 6) {
- info->date=day | (month << 5) | ((year-1980) << 9);
- info->time=(sec >> 1) | (min << 5) | (hour << 11);
- return 1;
- }
- return 0;
+ if (sscanf(timestamp,"%d-%d-%dT%d:%d:%d",&year,&month,&day,&hour,&min,&sec) == 6) {
+ info->date=day | (month << 5) | ((year-1980) << 9);
+ info->time=(sec >> 1) | (min << 5) | (hour << 11);
+ return 1;
+ }
+ return 0;
}
-int
-zip_open(struct zip_info *info, char *out, char *dir, char *index)
-{
- info->res2=fopen(out,"wb+");
- if(!info->res2) {
- fprintf(stderr,"Could not open output zip file %s\n", out);
- return 0;
- }
- info->dir=fopen(dir,"wb+");
- if(!info->dir) {
- fprintf(stderr,"Could not open zip directory %s\n", dir);
- return 0;
- }
- info->index=fopen(index,"wb+");
- if(!info->index) {
- fprintf(stderr,"Could not open index %s\n", index);
- return 0;
- }
- return 1;
+int zip_open(struct zip_info *info, char *out, char *dir, char *index) {
+ info->res2=fopen(out,"wb+");
+ if(!info->res2) {
+ fprintf(stderr,"Could not open output zip file %s\n", out);
+ return 0;
+ }
+ info->dir=fopen(dir,"wb+");
+ if(!info->dir) {
+ fprintf(stderr,"Could not open zip directory %s\n", dir);
+ return 0;
+ }
+ info->index=fopen(index,"wb+");
+ if(!info->index) {
+ fprintf(stderr,"Could not open index %s\n", index);
+ return 0;
+ }
+ return 1;
}
-FILE *
-zip_get_index(struct zip_info *info)
-{
- return info->index;
+FILE *zip_get_index(struct zip_info *info) {
+ return info->index;
}
-int
-zip_get_zipnum(struct zip_info *info)
-{
- return info->zipnum;
+int zip_get_zipnum(struct zip_info *info) {
+ return info->zipnum;
}
-void
-zip_set_zipnum(struct zip_info *info, int num)
-{
- info->zipnum=num;
+void zip_set_zipnum(struct zip_info *info, int num) {
+ info->zipnum=num;
}
-void
-zip_close(struct zip_info *info)
-{
- fclose(info->index);
- fclose(info->dir);
- fclose(info->res2);
+void zip_close(struct zip_info *info) {
+ fclose(info->index);
+ fclose(info->dir);
+ fclose(info->res2);
}
-void
-zip_destroy(struct zip_info *info)
-{
- g_free(info);
+void zip_destroy(struct zip_info *info) {
+ g_free(info);
}
diff --git a/navit/maptype.c b/navit/maptype.c
index cb77a1d5b..3e8b74f2e 100644
--- a/navit/maptype.c
+++ b/navit/maptype.c
@@ -26,26 +26,24 @@
static struct maptype *maptype_root;
-void
-maptype_register(char *name, struct map_priv *(*map_new)(struct map_methods *meth, char *data, char **charset, enum projection *pro))
-{
- struct maptype *mt;
- mt=g_new(struct maptype, 1);
- mt->name=g_strdup(name);
- mt->map_new=map_new;
- mt->next=maptype_root;
- maptype_root=mt;
+void maptype_register(char *name, struct map_priv *(*map_new)(struct map_methods *meth, char *data, char **charset,
+ enum projection *pro)) {
+ struct maptype *mt;
+ mt=g_new(struct maptype, 1);
+ mt->name=g_strdup(name);
+ mt->map_new=map_new;
+ mt->next=maptype_root;
+ maptype_root=mt;
}
struct maptype *
-maptype_get(const char *name)
-{
- struct maptype *mt=maptype_root;
+maptype_get(const char *name) {
+ struct maptype *mt=maptype_root;
- while (mt) {
- if (!g_ascii_strcasecmp(mt->name, name))
- return mt;
- mt=mt->next;
- }
- return NULL;
+ while (mt) {
+ if (!g_ascii_strcasecmp(mt->name, name))
+ return mt;
+ mt=mt->next;
+ }
+ return NULL;
}
diff --git a/navit/maptype.h b/navit/maptype.h
index 7ebf233b6..d2b86a51b 100644
--- a/navit/maptype.h
+++ b/navit/maptype.h
@@ -26,7 +26,7 @@ enum projection;
struct maptype {
char *name;
struct map_priv *(*map_new)(struct map_methods *meth, char *data, char **charset, enum projection *pro);
- struct maptype *next;
+ struct maptype *next;
};
/* prototypes */
diff --git a/navit/menu.c b/navit/menu.c
index 92afa6c73..629c981d2 100644
--- a/navit/menu.c
+++ b/navit/menu.c
@@ -22,26 +22,23 @@
#include "debug.h"
struct menu *
-menu_add(struct menu *menu, char *name, enum menu_type type, struct callback *cb)
-{
- struct menu *this;
- if (! menu || ! menu->meth.add)
- return NULL;
- this=g_new0(struct menu, 1);
- this->priv=(*menu->meth.add)(menu->priv, &this->meth, name, type, cb);
- if (! this->priv) {
- g_free(this);
- return NULL;
- }
+menu_add(struct menu *menu, char *name, enum menu_type type, struct callback *cb) {
+ struct menu *this;
+ if (! menu || ! menu->meth.add)
+ return NULL;
+ this=g_new0(struct menu, 1);
+ this->priv=(*menu->meth.add)(menu->priv, &this->meth, name, type, cb);
+ if (! this->priv) {
+ g_free(this);
+ return NULL;
+ }
- return this;
+ return this;
}
-void
-menu_popup(struct menu *menu)
-{
- if (! menu || ! menu->meth.popup)
- return;
- (*menu->meth.popup)(menu->priv);
+void menu_popup(struct menu *menu) {
+ if (! menu || ! menu->meth.popup)
+ return;
+ (*menu->meth.popup)(menu->priv);
}
diff --git a/navit/messages.c b/navit/messages.c
index 80b17236a..bcb3f5e74 100644
--- a/navit/messages.c
+++ b/navit/messages.c
@@ -25,133 +25,123 @@
#include "attr.h"
struct messagelist {
- struct message *messages; /**< All the messages that can currently be shown */
- int last_mid; /**< Last Message ID */
- int maxage; /**< Maximum age of messages */
- int maxnum; /**< Maximum number of messages */
- struct callback *msg_cleanup_cb; /**< Callback to clean up the messages */
- struct event_timeout *msg_cleanup_to; /**< Idle event to clean up the messages */
+ struct message *messages; /**< All the messages that can currently be shown */
+ int last_mid; /**< Last Message ID */
+ int maxage; /**< Maximum age of messages */
+ int maxnum; /**< Maximum number of messages */
+ struct callback *msg_cleanup_cb; /**< Callback to clean up the messages */
+ struct event_timeout *msg_cleanup_to; /**< Idle event to clean up the messages */
};
-int
-message_new(struct messagelist *this_, const char *message)
-{
- struct message *msg;
+int message_new(struct messagelist *this_, const char *message) {
+ struct message *msg;
- msg = g_new0(struct message, 1);
- msg->text = g_strdup(message);
- msg->id = ++(this_->last_mid);
- msg->time = time(NULL);
+ msg = g_new0(struct message, 1);
+ msg->text = g_strdup(message);
+ msg->id = ++(this_->last_mid);
+ msg->time = time(NULL);
- msg->next = this_->messages;
- this_->messages = msg;
+ msg->next = this_->messages;
+ this_->messages = msg;
- return msg->id;
+ return msg->id;
}
-int
-message_delete(struct messagelist *this_, int mid)
-{
- struct message *msg,*last;;
-
- msg = this_->messages;
- last = NULL;
-
- while (msg) {
- if (msg->id == mid) {
- break;
- }
-
- last = msg;
- msg = msg->next;
- }
-
- if (msg) {
- if (last) {
- last->next = msg->next;
- } else {
- this_->messages = msg->next;
- }
-
- g_free(msg->text);
- g_free(msg);
-
- return 1;
- } else {
- return 0;
- }
+int message_delete(struct messagelist *this_, int mid) {
+ struct message *msg,*last;;
+
+ msg = this_->messages;
+ last = NULL;
+
+ while (msg) {
+ if (msg->id == mid) {
+ break;
+ }
+
+ last = msg;
+ msg = msg->next;
+ }
+
+ if (msg) {
+ if (last) {
+ last->next = msg->next;
+ } else {
+ this_->messages = msg->next;
+ }
+
+ g_free(msg->text);
+ g_free(msg);
+
+ return 1;
+ } else {
+ return 0;
+ }
}
-static void
-message_cleanup(struct messagelist *this_)
-{
- struct message *msg,*next,*prev=NULL;
- int i;
- time_t now;
+static void message_cleanup(struct messagelist *this_) {
+ struct message *msg,*next,*prev=NULL;
+ int i;
+ time_t now;
- msg = this_->messages;
+ msg = this_->messages;
- now = time(NULL);
+ now = time(NULL);
- i = 0;
- while (msg && (i < this_->maxnum)) {
- if ((this_->maxage > 0) && (now - msg->time) > this_->maxage) {
- break;
- }
+ i = 0;
+ while (msg && (i < this_->maxnum)) {
+ if ((this_->maxage > 0) && (now - msg->time) > this_->maxage) {
+ break;
+ }
- i++;
- prev = msg;
- msg = msg->next;
- }
+ i++;
+ prev = msg;
+ msg = msg->next;
+ }
- if (prev) {
- prev->next = NULL;
- } else {
- this_->messages = NULL;
- }
+ if (prev) {
+ prev->next = NULL;
+ } else {
+ this_->messages = NULL;
+ }
- while (msg) {
- next = msg->next;
+ while (msg) {
+ next = msg->next;
- g_free(msg->text);
- g_free(msg);
+ g_free(msg->text);
+ g_free(msg);
- msg = next;
- }
+ msg = next;
+ }
}
struct messagelist
-*messagelist_new(struct attr **attrs)
-{
- struct messagelist *this = g_new0(struct messagelist, 1);
- struct attr num_attr,age_attr;
-
- if (attr_generic_get_attr(attrs, NULL, attr_message_maxage, &age_attr, NULL)) {
- this->maxage = age_attr.u.num;
- } else {
- this->maxage = 10;
- }
-
- if (attr_generic_get_attr(attrs, NULL, attr_message_maxnum, &num_attr, NULL)) {
- this->maxnum = num_attr.u.num;
- } else {
- this->maxnum = 3;
- }
-
- return this;
+*messagelist_new(struct attr **attrs) {
+ struct messagelist *this = g_new0(struct messagelist, 1);
+ struct attr num_attr,age_attr;
+
+ if (attr_generic_get_attr(attrs, NULL, attr_message_maxage, &age_attr, NULL)) {
+ this->maxage = age_attr.u.num;
+ } else {
+ this->maxage = 10;
+ }
+
+ if (attr_generic_get_attr(attrs, NULL, attr_message_maxnum, &num_attr, NULL)) {
+ this->maxnum = num_attr.u.num;
+ } else {
+ this->maxnum = 3;
+ }
+
+ return this;
}
-void
-messagelist_init(struct messagelist *this_)
-{
- if (!event_system())
- return;
- this_->msg_cleanup_cb = callback_new_1(callback_cast(message_cleanup), this_);
- this_->msg_cleanup_to = event_add_timeout(1000, 1, this_->msg_cleanup_cb);
+void messagelist_init(struct messagelist *this_) {
+ if (!event_system())
+ return;
+ this_->msg_cleanup_cb = callback_new_1(callback_cast(message_cleanup), this_);
+ this_->msg_cleanup_to = event_add_timeout(1000, 1, this_->msg_cleanup_cb);
}
-struct message
-*message_get(struct messagelist *this_)
-{
- return this_->messages;
+struct message
+*message_get(struct messagelist *this_) {
+ return this_->messages;
}
diff --git a/navit/navigation.c b/navit/navigation.c
index 0812093d1..bc216ec15 100644
--- a/navit/navigation.c
+++ b/navit/navigation.c
@@ -98,104 +98,121 @@ static int u_turn_limit = 165;
* These states are dependent on the current distance to the turn;
* the distances are configured in navit.xml for every type of highway. */
enum announcement_level {
- level_connect = -2,
- level_error = -1,
- level_now = 0,
- level_meters = 1,
- level_soon = 2,
- level_follow = 3
+ level_connect = -2,
+ level_error = -1,
+ level_now = 0,
+ level_meters = 1,
+ level_soon = 2,
+ level_follow = 3
};
enum gender {unknown, masculine, feminine, neuter};
struct suffix {
- char *fullname;
- char *abbrev;
- int gender;
+ char *fullname;
+ char *abbrev;
+ int gender;
} suffixes[]= {
- /* DE */
- {"weg", NULL, masculine},
-/* {"platz", "pl.", masculine}, collides with Lithuanian "plentas" (which is more frequent) */
- {"platz", NULL, masculine},
- {"ring", NULL, masculine},
- {"bogen", NULL, masculine},
- {"allee", NULL, feminine},
- {"gasse", NULL, feminine},
- {"straße", "str.", feminine},
-
- /* EN */
- {"street", NULL, masculine},
- {"drive", NULL, masculine},
-
- /* FR */
- {"boulevard", NULL, masculine},
- {"chemin", NULL, neuter},
- {"rue", NULL, feminine},
-
- /* LT, as per http://wiki.openstreetmap.org/wiki/WikiProject_Lithuania */
- {"gatvė", "g.", feminine},
- {"plentas", "pl.", masculine},
- {"prospektas", "pr.", masculine},
- {"alėja", "al.", feminine},
- {"skersgatvis", "skg.", masculine},
- {"aikštė", "a.", feminine},
-
- /* NL */
- {"straat", NULL, neuter},
-/* {"weg", NULL, neuter}, doubles-up with German */
- {"baan", NULL, neuter},
- {"laan", NULL, neuter},
- {"wegel", NULL, neuter},
+ /* DE */
+ {"weg", NULL, masculine},
+ /* {"platz", "pl.", masculine}, collides with Lithuanian "plentas" (which is more frequent) */
+ {"platz", NULL, masculine},
+ {"ring", NULL, masculine},
+ {"bogen", NULL, masculine},
+ {"allee", NULL, feminine},
+ {"gasse", NULL, feminine},
+ {"straße", "str.", feminine},
+
+ /* EN */
+ {"street", NULL, masculine},
+ {"drive", NULL, masculine},
+
+ /* FR */
+ {"boulevard", NULL, masculine},
+ {"chemin", NULL, neuter},
+ {"rue", NULL, feminine},
+
+ /* LT, as per http://wiki.openstreetmap.org/wiki/WikiProject_Lithuania */
+ {"gatvė", "g.", feminine},
+ {"plentas", "pl.", masculine},
+ {"prospektas", "pr.", masculine},
+ {"alėja", "al.", feminine},
+ {"skersgatvis", "skg.", masculine},
+ {"aikštė", "a.", feminine},
+
+ /* NL */
+ {"straat", NULL, neuter},
+ /* {"weg", NULL, neuter}, doubles-up with German */
+ {"baan", NULL, neuter},
+ {"laan", NULL, neuter},
+ {"wegel", NULL, neuter},
};
enum nav_status_int {
- status_none = 0,
- status_busy = 1,
- status_has_ritem = 2,
- status_has_sitem = 4
+ status_none = 0,
+ status_busy = 1,
+ status_has_ritem = 2,
+ status_has_sitem = 4
};
struct navigation {
- NAVIT_OBJECT
- struct route *route;
- struct map *map;
- struct item_hash *hash;
- struct vehicleprofile *vehicleprofile;
- struct navigation_itm *first;
- struct navigation_itm *last;
- struct navigation_command *cmd_first;
- struct navigation_command *cmd_last;
- struct callback_list *callback_speech;
- struct callback_list *callback;
- struct navit *navit;
- struct speech *speech;
- int level_last;
- struct item item_last;
- int turn_around;
- int turn_around_limit;
- int distance_turn;
- struct callback *route_cb;
- int announce[route_item_last-route_item_first+1][3];
- int tell_street_name;
- int delay;
- int curr_delay;
- int turn_around_count;
- int flags;
- struct map_rect *route_mr; /**< Map rect on the route map, used for maneuver generation */
- enum nav_status_int status_int; /**< Internal status information used during maneuver generation */
- struct callback *idle_cb; /**< Idle callback to process the route map */
- struct event_idle *idle_ev; /**< The pointer to the idle event */
- int nav_status; /**< Status of the navigation engine */
+ NAVIT_OBJECT
+ struct route *route;
+ struct map *map;
+ struct item_hash *hash;
+ struct vehicleprofile *vehicleprofile;
+ struct navigation_itm *first;
+ struct navigation_itm *last;
+ struct navigation_command *cmd_first;
+ struct navigation_command *cmd_last;
+ struct callback_list *callback_speech;
+ struct callback_list *callback;
+ struct navit *navit;
+ struct speech *speech;
+ int level_last;
+ struct item item_last;
+ int turn_around;
+ int turn_around_limit;
+ int distance_turn;
+ struct callback *route_cb;
+ int announce[route_item_last-route_item_first+1][3];
+ int tell_street_name;
+ int delay;
+ int curr_delay;
+ int turn_around_count;
+ int flags;
+ struct map_rect *route_mr; /**< Map rect on the route map, used for maneuver generation */
+ enum nav_status_int status_int; /**< Internal status information used during maneuver generation */
+ struct callback *idle_cb; /**< Idle callback to process the route map */
+ struct event_idle *idle_ev; /**< The pointer to the idle event */
+ int nav_status; /**< Status of the navigation engine */
};
/** @brief Set of simplified distance values that are easy to be pronounced.
* Used for the 'vocabulary_distances' configuration.
*/
-int distances[]={1,2,3,4,5,10,25,50,75,100,150,200,250,300,400,500,750,-1};
+/**
+ * This method of calculating the number of elements in an array
+ * (#define SIZE_OF_ARRAY_DISTANCES, below) will work for most modern
+ * processors. It may cause problems on a few obscure processors, none
+ * of which are likely candidates for navit anyway.
+ *
+ * It works like so: Modern processors simply stuff the elements of an
+ * int array into memory one after the other, with no gaps. Some older
+ * processors might not do so, due to memory alignment issues. This
+ * method does not take such gaps into account. For more discussion,
+ * see https://github.com/navit-gps/navit/pull/373
+ *
+ * So if you are on an oddball processor and start getting really odd
+ * values for distances, this might be the reason. Good luck!
+ */
+const int distances[]= {1,2,3,4,5,10,25,50,75,100,150,200,250,300,400,500,750};
+#define SIZE_OF_ARRAY_DISTANCES (sizeof (distances)/sizeof (int))
+#define LAST_DISTANCE (SIZE_OF_ARRAY_DISTANCES - 1)
/* Allowed values for navigation_maneuver.merge_or_exit
* The numeric values are chosen in such a way that they can be interpreted as flags:
@@ -244,36 +261,37 @@ int distances[]={1,2,3,4,5,10,25,50,75,100,150,200,250,300,400,500,750,-1};
* was used to determine the former two.
*/
struct navigation_maneuver {
- enum item_type type; /**< The type of maneuver to perform. Any {@code nav_*} item is permitted here, with one exception:
+ enum item_type
+ type; /**< The type of maneuver to perform. Any {@code nav_*} item is permitted here, with one exception:
merge or exit maneuvers are indicated by the {@code merge_or_exit} member. The {@code item_type}
for such maneuvers should be a turn instruction in cases where the maneuver is ambiguous, or
{@code nav_none} for cases in which we would expect the driver to perform this maneuver even
without being instructed to do so. **/
- int delta; /**< Bearing difference (the angle the driver has to steer) for the maneuver */
- int merge_or_exit; /**< Whether we are merging into or exiting from a motorway_like road or we are at an interchange */
- int is_complex_t_junction; /**< Whether we are coming from the "stem" of a T junction whose "bar" is a dual-carriageway road and
+ int delta; /**< Bearing difference (the angle the driver has to steer) for the maneuver */
+ int merge_or_exit; /**< Whether we are merging into or exiting from a motorway_like road or we are at an interchange */
+ int is_complex_t_junction; /**< Whether we are coming from the "stem" of a T junction whose "bar" is a dual-carriageway road and
crossing the opposite lane of the "bar" first (i.e. turning left in countries that drive on the
right, or turning right in countries that drive on the left). For these maneuvers
{@code num_options} is 1 (which means we normally wouldn't announce the maneuver) but drivers
would expect an announcement in such cases. */
- int num_options; /**< Number of permitted candidate ways, i.e. ways which we may enter (based on access flags of the
+ int num_options; /**< Number of permitted candidate ways, i.e. ways which we may enter (based on access flags of the
way but without considering turn restrictions). Permitted candidate ways include the route. */
- int num_new_motorways; /**< Number of permitted candidate ways that are motorway-like.
+ int num_new_motorways; /**< Number of permitted candidate ways that are motorway-like.
Numbers greater then one should be interpreted as "more than one", not as a precise number. */
- int num_other_ways; /**< Number of permitted candidate ways that are neither ramps nor motorway-like */
- int old_cat; /**< Maneuver category of the way leading to the maneuver */
- int new_cat; /**< Maneuver category of the selected way after the maneuver */
- int max_cat; /**< Highest maneuver category of any permitted candidate way other than the route */
- int num_similar_ways; /**< Number of candidate ways (including the route) that have a {@code maneuver_category()} similar
+ int num_other_ways; /**< Number of permitted candidate ways that are neither ramps nor motorway-like */
+ int old_cat; /**< Maneuver category of the way leading to the maneuver */
+ int new_cat; /**< Maneuver category of the selected way after the maneuver */
+ int max_cat; /**< Highest maneuver category of any permitted candidate way other than the route */
+ int num_similar_ways; /**< Number of candidate ways (including the route) that have a {@code maneuver_category()} similar
to {@code old_cat}. See {@code maneuver_required2()} for definition of "similar". */
- int left; /**< Minimum bearing delta of any candidate way left of the route, -180 for none */
- int right; /**< Minimum bearing delta of any candidate way right of the route, 180 for none */
- int is_unambiguous; /**< Whether the maneuver is unambiguous. A maneuver is unambiguous if, despite
+ int left; /**< Minimum bearing delta of any candidate way left of the route, -180 for none */
+ int right; /**< Minimum bearing delta of any candidate way right of the route, 180 for none */
+ int is_unambiguous; /**< Whether the maneuver is unambiguous. A maneuver is unambiguous if, despite
multiple candidate way being available, we can reasonable expect the driver to
continue on the route without being told to do so. This is typically the case when
the route stays on the main road and goes straight, while all other candidate ways
are minor roads and involve a significant turn. */
- int is_same_street; /**< Whether the street keeps its name after the maneuver. */
+ int is_same_street; /**< Whether the street keeps its name after the maneuver. */
};
/**
@@ -282,13 +300,13 @@ struct navigation_maneuver {
* An instance of this structure is generated for each navigation maneuver that is to be announced.
*/
struct navigation_command {
- struct navigation_itm *itm; /**< The navigation item following the maneuver */
- struct navigation_command *next; /**< next command in the list */
- struct navigation_command *prev; /**< previous command in the list */
- int delta; /**< bearing change at maneuver */
- int roundabout_delta; /**< if we are leaving a roundabout, effective bearing change (between entry and exit) with some corrections applied */
- int length; /**< if the maneuver is a roundabout, distance between entry and exit (plus penalty), else 0 */
- struct navigation_maneuver *maneuver; /**< Details on the maneuver to perform */
+ struct navigation_itm *itm; /**< The navigation item following the maneuver */
+ struct navigation_command *next; /**< next command in the list */
+ struct navigation_command *prev; /**< previous command in the list */
+ int delta; /**< bearing change at maneuver */
+ int roundabout_delta; /**< if we are leaving a roundabout, effective bearing change (between entry and exit) with some corrections applied */
+ int length; /**< if the maneuver is a roundabout, distance between entry and exit (plus penalty), else 0 */
+ struct navigation_maneuver *maneuver; /**< Details on the maneuver to perform */
};
/*
@@ -296,32 +314,32 @@ struct navigation_command {
*
*/
struct navigation_way {
- struct navigation_way *next; /**< Pointer to a linked-list of all navigation_ways from this navigation item */
- short dir; /**< The direction -1 or 1 of the way */
- short angle2; /**< The bearing at the start or the way (0 = north, 90 =east etc.) */
- int flags; /**< The flags of the way */
- struct item item; /**< The item of the way */
- char *name; /**< The street name ({@code street_name} attribute) */
- char *name_systematic; /**< The road number ({@code street_name_systematic} attribute, OSM: {@code ref}) */
- char *exit_ref; /**< Exit_ref if found on the first node of the way*/
- char *exit_label; /**< Exit_label if found on the first node of the way*/
- struct street_destination *destination; /**< The destination this way leads to (OSM: {@code destination}) */
+ struct navigation_way *next; /**< Pointer to a linked-list of all navigation_ways from this navigation item */
+ short dir; /**< The direction -1 or 1 of the way */
+ short angle2; /**< The bearing at the start or the way (0 = north, 90 =east etc.) */
+ int flags; /**< The flags of the way */
+ struct item item; /**< The item of the way */
+ char *name; /**< The street name ({@code street_name} attribute) */
+ char *name_systematic; /**< The road number ({@code street_name_systematic} attribute, OSM: {@code ref}) */
+ char *exit_ref; /**< Exit_ref if found on the first node of the way*/
+ char *exit_label; /**< Exit_label if found on the first node of the way*/
+ struct street_destination *destination; /**< The destination this way leads to (OSM: {@code destination}) */
};
struct navigation_itm {
- struct navigation_way way;
- int angle_end; /**< The bearing at the end of {@code way} */
- struct coord start,end;
- int time;
- int length;
- int speed;
- int dest_time;
- int dest_length;
- int told; /**< Indicates if this item's announcement has been told earlier and should not be told again*/
- int streetname_told; /**< Indicates if this item's streetname has been told in speech navigation*/
- int dest_count;
- struct navigation_itm *next;
- struct navigation_itm *prev;
+ struct navigation_way way;
+ int angle_end; /**< The bearing at the end of {@code way} */
+ struct coord start,end;
+ int time;
+ int length;
+ int speed;
+ int dest_time;
+ int dest_length;
+ int told; /**< Indicates if this item's announcement has been told earlier and should not be told again*/
+ int streetname_told; /**< Indicates if this item's streetname has been told in speech navigation*/
+ int dest_count;
+ struct navigation_itm *next;
+ struct navigation_itm *prev;
};
@@ -333,9 +351,9 @@ struct navigation_itm {
* traffic sign's (ex. Paris, Senlis ...)
*/
struct street_destination {
- struct street_destination *next;
- char *destination;
- int rank;
+ struct street_destination *next;
+ char *destination;
+ int rank;
};
@@ -356,33 +374,27 @@ static void navigation_flush(struct navigation *this_);
* @param angle2 The second angle
* @return The difference between the angles, see description
*/
-static int
-angle_delta(int angle1, int angle2)
-{
- int delta=angle2-angle1;
- if (delta <= -180)
- delta+=360;
- if (delta > 180)
- delta-=360;
- return delta;
+static int angle_delta(int angle1, int angle2) {
+ int delta=angle2-angle1;
+ if (delta <= -180)
+ delta+=360;
+ if (delta > 180)
+ delta-=360;
+ return delta;
}
-static int
-angle_median(int angle1, int angle2)
-{
- int delta=angle_delta(angle1, angle2);
- int ret=angle1+delta/2;
- if (ret < 0)
- ret+=360;
- if (ret > 360)
- ret-=360;
- return ret;
+static int angle_median(int angle1, int angle2) {
+ int delta=angle_delta(angle1, angle2);
+ int ret=angle1+delta/2;
+ if (ret < 0)
+ ret+=360;
+ if (ret > 360)
+ ret-=360;
+ return ret;
}
-static int
-angle_opposite(int angle)
-{
- return ((angle+180)%360);
+static int angle_opposite(int angle) {
+ return ((angle+180)%360);
}
@@ -399,19 +411,20 @@ angle_opposite(int angle)
* @param new_name_systematic The systematic name of the second item to be checked
* @return True if both old and new are on the same street
*/
-static int
-is_same_street2(char *old_name, char *old_name_systematic, char *new_name, char *new_name_systematic)
-{
- if (old_name && new_name && !strcmp(old_name, new_name)) {
- dbg(lvl_debug,"is_same_street: '%s' '%s' vs '%s' '%s' yes (1.)\n", old_name_systematic, new_name_systematic, old_name, new_name);
- return 1;
- }
- if (old_name_systematic && new_name_systematic && !strcmp(old_name_systematic, new_name_systematic)) {
- dbg(lvl_debug,"is_same_street: '%s' '%s' vs '%s' '%s' yes (2.)\n", old_name_systematic, new_name_systematic, old_name, new_name);
- return 1;
- }
- dbg(lvl_debug,"is_same_street: '%s' '%s' vs '%s' '%s' no\n", old_name_systematic, new_name_systematic, old_name, new_name);
- return 0;
+static int is_same_street2(char *old_name, char *old_name_systematic, char *new_name, char *new_name_systematic) {
+ if (old_name && new_name && !strcmp(old_name, new_name)) {
+ dbg(lvl_debug,"is_same_street: '%s' '%s' vs '%s' '%s' yes (1.)", old_name_systematic, new_name_systematic, old_name,
+ new_name);
+ return 1;
+ }
+ if (old_name_systematic && new_name_systematic && !strcmp(old_name_systematic, new_name_systematic)) {
+ dbg(lvl_debug,"is_same_street: '%s' '%s' vs '%s' '%s' yes (2.)", old_name_systematic, new_name_systematic, old_name,
+ new_name);
+ return 1;
+ }
+ dbg(lvl_debug,"is_same_street: '%s' '%s' vs '%s' '%s' no", old_name_systematic, new_name_systematic, old_name,
+ new_name);
+ return 0;
}
@@ -432,14 +445,13 @@ is_same_street2(char *old_name, char *old_name_systematic, char *new_name, char
* Note that way geometry (other than {@code angle2}) is not compared. If necessary, the caller needs to
* make geometry-related comparisons separately.
*/
-static int
-is_same_way(struct navigation_way * w1, struct navigation_way * w2) {
- if (!is_same_street2(w1->name, w1->name_systematic, w2->name, w2->name_systematic))
- return 0;
- if ((w1->angle2 == w2->angle2) && (w1->item.type == w2->item.type))
- return 1;
- else
- return 0;
+static int is_same_way(struct navigation_way * w1, struct navigation_way * w2) {
+ if (!is_same_street2(w1->name, w1->name_systematic, w2->name, w2->name_systematic))
+ return 0;
+ if ((w1->angle2 == w2->angle2) && (w1->item.type == w2->item.type))
+ return 1;
+ else
+ return 0;
}
@@ -448,19 +460,18 @@ is_same_way(struct navigation_way * w1, struct navigation_way * w2) {
*
* @param list the list to be freed
*/
-static void
-free_list(struct street_destination *list) {
-
- if (list){
- struct street_destination *clist;
- while (list){
- clist = list->next;
- g_free(list->destination);
- g_free(list);
- list = clist;
- }
- list = NULL;
- }
+static void free_list(struct street_destination *list) {
+
+ if (list) {
+ struct street_destination *clist;
+ while (list) {
+ clist = list->next;
+ g_free(list->destination);
+ g_free(list);
+ list = clist;
+ }
+ list = NULL;
+ }
}
/**
@@ -474,49 +485,42 @@ free_list(struct street_destination *list) {
* @param sep a char to be used as separator to split the raw_string
* @return the number of entries in the list
*/
-static int
-split_string_to_list(struct navigation_way *way, char* raw_string, char sep)
-{
-
- struct street_destination *new_street_destination = NULL;
- struct street_destination *next_street_destination_remember = NULL;
- char *pos1 = raw_string;
- char *pos2;
- int count = 0;
-
- free_list(way->destination); /*in case this is a retry with a different separator.*/
- dbg(lvl_debug,"raw_string=%s split with %c\n",raw_string, sep);
- if (strlen(raw_string)>0)
- {
- count = 1;
- while (pos1)
- {
- new_street_destination = g_new(struct street_destination, 1);
- new_street_destination->next = next_street_destination_remember;
- next_street_destination_remember = new_street_destination ;
- if ((pos2 = strrchr(pos1, sep)) != NULL)
- {
- *pos2 = '\0' ;
- while (isspace(pos2[1]))
- pos2++;
- new_street_destination->destination = g_strdup(pos2+1);
- new_street_destination->rank=0;
- dbg(lvl_debug,"splitted_off_string=%s\n",new_street_destination->destination);
- count++;
- }
- else
- {
- while (isspace(pos1[0]))
- pos1++;
- new_street_destination->destination = g_strdup(pos1);
- new_street_destination->rank=0;
- pos1 = NULL;
- dbg(lvl_debug,"head_of_string=%s\n",new_street_destination->destination);
- }
- way->destination = next_street_destination_remember;
- }
- }
- return count;
+static int split_string_to_list(struct navigation_way *way, char* raw_string, char sep) {
+
+ struct street_destination *new_street_destination = NULL;
+ struct street_destination *next_street_destination_remember = NULL;
+ char *pos1 = raw_string;
+ char *pos2;
+ int count = 0;
+
+ free_list(way->destination); /*in case this is a retry with a different separator.*/
+ dbg(lvl_debug,"raw_string=%s split with %c",raw_string, sep);
+ if (strlen(raw_string)>0) {
+ count = 1;
+ while (pos1) {
+ new_street_destination = g_new(struct street_destination, 1);
+ new_street_destination->next = next_street_destination_remember;
+ next_street_destination_remember = new_street_destination ;
+ if ((pos2 = strrchr(pos1, sep)) != NULL) {
+ *pos2 = '\0' ;
+ while (isspace(pos2[1]))
+ pos2++;
+ new_street_destination->destination = g_strdup(pos2+1);
+ new_street_destination->rank=0;
+ dbg(lvl_debug,"splitted_off_string=%s",new_street_destination->destination);
+ count++;
+ } else {
+ while (isspace(pos1[0]))
+ pos1++;
+ new_street_destination->destination = g_strdup(pos1);
+ new_street_destination->rank=0;
+ pos1 = NULL;
+ dbg(lvl_debug,"head_of_string=%s",new_street_destination->destination);
+ }
+ way->destination = next_street_destination_remember;
+ }
+ }
+ return count;
}
@@ -526,19 +530,16 @@ split_string_to_list(struct navigation_way *way, char* raw_string, char sep)
*
* If all items in the list have a zero rank, the first one will be returned.
*/
-static struct street_destination *
-get_bestranked(struct street_destination *street_destination)
-{
- struct street_destination *selected_street_destination;
-
- selected_street_destination = street_destination;
- while (selected_street_destination)
- {
- if (selected_street_destination->rank > 0)
- return selected_street_destination;
- selected_street_destination = selected_street_destination->next;
- }
- return street_destination;
+static struct street_destination *get_bestranked(struct street_destination *street_destination) {
+ struct street_destination *selected_street_destination;
+
+ selected_street_destination = street_destination;
+ while (selected_street_destination) {
+ if (selected_street_destination->rank > 0)
+ return selected_street_destination;
+ selected_street_destination = selected_street_destination->next;
+ }
+ return street_destination;
}
/**
@@ -549,43 +550,36 @@ get_bestranked(struct street_destination *street_destination)
* @param command
* @return 1 if successful, zero otherwise
*/
-static int
-set_highrank(struct street_destination *street_destination, struct navigation_command *command)
-{
- struct street_destination *future_street_destination = NULL;
- struct navigation_command *next_command;
- char* destination_string;
- int success = 0;
- destination_string = street_destination->destination;
-
- if (command->next)
- {
- next_command=command->next;
- while (next_command)
- {
- if (next_command->itm->way.destination)
- break;
- if (!next_command->next)
- break;
- next_command=next_command->next;
- }
- if (next_command->itm->way.destination)
- future_street_destination = next_command->itm->way.destination;
- else future_street_destination = NULL;
- }
-
- while (future_street_destination)
- {
- if ((strcmp(destination_string,future_street_destination->destination)==0))
- {
- future_street_destination->rank=99;
- success =1;
- }
- else
- future_street_destination->rank=0;
- future_street_destination=future_street_destination->next;
- }
- return success;
+static int set_highrank(struct street_destination *street_destination, struct navigation_command *command) {
+ struct street_destination *future_street_destination = NULL;
+ struct navigation_command *next_command;
+ char* destination_string;
+ int success = 0;
+ destination_string = street_destination->destination;
+
+ if (command->next) {
+ next_command=command->next;
+ while (next_command) {
+ if (next_command->itm->way.destination)
+ break;
+ if (!next_command->next)
+ break;
+ next_command=next_command->next;
+ }
+ if (next_command->itm->way.destination)
+ future_street_destination = next_command->itm->way.destination;
+ else future_street_destination = NULL;
+ }
+
+ while (future_street_destination) {
+ if ((strcmp(destination_string,future_street_destination->destination)==0)) {
+ future_street_destination->rank=99;
+ success =1;
+ } else
+ future_street_destination->rank=0;
+ future_street_destination=future_street_destination->next;
+ }
+ return success;
}
@@ -596,83 +590,78 @@ set_highrank(struct street_destination *street_destination, struct navigation_co
* command items so that the destination name has a relevance over several announcements. If there is no 'winner'
* the entry is selected that is at top of the destination.
*/
-static char*
-select_announced_destinations(struct navigation_command *current_command)
-{
- struct street_destination *current_destination = NULL; /* the list pointer of the destination_names of the current command. */
- struct street_destination *search_destination = NULL; /* the list pointer of the destination_names of the respective search_command. */
-
- struct navigation_command *search_command = NULL;
-
- #define MAX_LOOPS 10 /* limits the number of next command items to investigate over */
- #define MAX_DESTINATIONS 10 /* limits the number of destination entries to investigate */
- int destination_count[MAX_DESTINATIONS]; /* contains the hits of identical destinations over all */
- /* investigated command items - a 'high score' of destination names */
- int destination_index = 0;
- int search_command_counter = 0;
- int i, max_hits=0, max_hit_index;
-
- /* search over every following command for seeking identical destination_names */
- if (current_command->itm->way.destination)
- { /* can we investigate over the following commands? */
- if (current_command->next)
- { /* loop over every destination of the current command, as far as there are not more than MAX_DESTINATIONS entries. */
- destination_index = 0; /* start with the first destination */
- current_destination = current_command->itm->way.destination;
- while (current_destination && (destination_index < MAX_DESTINATIONS))
- { /* initialize the search command */
- search_command = current_command->next;
- search_command_counter = 0;
- destination_count[destination_index]=0;
- while (search_command && (search_command_counter < MAX_LOOPS))
- {
- if (search_command->itm && search_command->itm->way.destination)
- { /* has the search command any destinations ? */
- search_destination = search_command->itm->way.destination;
- while (search_destination)
- { /* Search this name in the destination list of the current command. */
- if (0 == strcmp(current_destination->destination, search_destination->destination))
- { /* enter the destination_name in the investigation list*/
- destination_count[destination_index]++;
- search_destination = NULL; /* break condition */
- }
- else search_destination = search_destination->next;
- }
- }
- search_command_counter++;
- search_command = search_command->next;
- }
- destination_index++;
- current_destination = current_destination->next;
- }
-
- /* search for the best candidate */
- max_hits = 0;
- max_hit_index = 0;
- for (i = 0; i < destination_index; i++)
- {
- if (destination_count[i] > max_hits)
- {
- max_hits = destination_count[i];
- max_hit_index = i;
- }
- }
- /* jump to the corresponding destination_name */
- current_destination = current_command->itm->way.destination;
- for (i = 0; i < max_hit_index; i++)
- {
- current_destination = current_destination->next;
- }
-
- dbg(lvl_debug,"%s, max hits =%i\n",current_destination->destination,max_hits);
- set_highrank(current_destination,current_command);
- }
- }
-
- /* return the best candidate, if there is any.*/
- if (max_hits)
- return g_strdup(current_destination->destination);
- return g_strdup(current_destination ? get_bestranked(current_destination)->destination:NULL);
+static char* select_announced_destinations(struct navigation_command *current_command) {
+ struct street_destination *current_destination =
+ NULL; /* the list pointer of the destination_names of the current command. */
+ struct street_destination *search_destination =
+ NULL; /* the list pointer of the destination_names of the respective search_command. */
+
+ struct navigation_command *search_command = NULL;
+
+#define MAX_LOOPS 10 /* limits the number of next command items to investigate over */
+#define MAX_DESTINATIONS 10 /* limits the number of destination entries to investigate */
+ int destination_count[MAX_DESTINATIONS]; /* contains the hits of identical destinations over all */
+ /* investigated command items - a 'high score' of destination names */
+ int destination_index = 0;
+ int search_command_counter = 0;
+ int i, max_hits=0, max_hit_index;
+
+ /* search over every following command for seeking identical destination_names */
+ if (current_command->itm->way.destination) {
+ /* can we investigate over the following commands? */
+ if (current_command->next) {
+ /* loop over every destination of the current command, as far as there are not more than MAX_DESTINATIONS entries. */
+ destination_index = 0; /* start with the first destination */
+ current_destination = current_command->itm->way.destination;
+ while (current_destination && (destination_index < MAX_DESTINATIONS)) {
+ /* initialize the search command */
+ search_command = current_command->next;
+ search_command_counter = 0;
+ destination_count[destination_index]=0;
+ while (search_command && (search_command_counter < MAX_LOOPS)) {
+ if (search_command->itm && search_command->itm->way.destination) {
+ /* has the search command any destinations ? */
+ search_destination = search_command->itm->way.destination;
+ while (search_destination) {
+ /* Search this name in the destination list of the current command. */
+ if (0 == strcmp(current_destination->destination, search_destination->destination)) {
+ /* enter the destination_name in the investigation list*/
+ destination_count[destination_index]++;
+ search_destination = NULL; /* break condition */
+ } else search_destination = search_destination->next;
+ }
+ }
+ search_command_counter++;
+ search_command = search_command->next;
+ }
+ destination_index++;
+ current_destination = current_destination->next;
+ }
+
+ /* search for the best candidate */
+ max_hits = 0;
+ max_hit_index = 0;
+ for (i = 0; i < destination_index; i++) {
+ if (destination_count[i] > max_hits) {
+ max_hits = destination_count[i];
+ max_hit_index = i;
+ }
+ }
+ /* jump to the corresponding destination_name */
+ current_destination = current_command->itm->way.destination;
+ for (i = 0; i < max_hit_index; i++) {
+ current_destination = current_destination->next;
+ }
+
+ dbg(lvl_debug,"%s, max hits =%i",current_destination->destination,max_hits);
+ set_highrank(current_destination,current_command);
+ }
+ }
+
+ /* return the best candidate, if there is any.*/
+ if (max_hits)
+ return g_strdup(current_destination->destination);
+ return g_strdup(current_destination ? get_bestranked(current_destination)->destination:NULL);
}
@@ -685,187 +674,175 @@ select_announced_destinations(struct navigation_command *current_command)
* {@code g_free()} when the result is no longer needed.
*/
char *nav_status_to_text(int status) {
- char *ret;
-
- switch (status) {
- case status_invalid:
- ret = g_strdup("status_invalid");
- break;
- case status_no_route:
- ret = g_strdup("status_no_route");
- break;
- case status_no_destination:
- ret = g_strdup("status_no_destination");
- break;
- case status_position_wait:
- ret = g_strdup("status_position_wait");
- break;
- case status_calculating:
- ret = g_strdup("status_calculating");
- break;
- case status_recalculating:
- ret = g_strdup("status_recalculating");
- break;
- case status_routing:
- ret = g_strdup("status_routing");
- break;
- default:
- ret = g_strdup_printf("status_unknown_%d", status);
- }
- return ret;
+ char *ret;
+
+ switch (status) {
+ case status_invalid:
+ ret = g_strdup("status_invalid");
+ break;
+ case status_no_route:
+ ret = g_strdup("status_no_route");
+ break;
+ case status_no_destination:
+ ret = g_strdup("status_no_destination");
+ break;
+ case status_position_wait:
+ ret = g_strdup("status_position_wait");
+ break;
+ case status_calculating:
+ ret = g_strdup("status_calculating");
+ break;
+ case status_recalculating:
+ ret = g_strdup("status_recalculating");
+ break;
+ case status_routing:
+ ret = g_strdup("status_routing");
+ break;
+ default:
+ ret = g_strdup_printf("status_unknown_%d", status);
+ }
+ return ret;
}
-int
-navigation_get_attr(struct navigation *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- struct map_rect *mr;
- struct item *item;
- dbg(lvl_debug,"enter %s\n", attr_to_name(type));
- switch (type) {
- case attr_map:
- attr->u.map=this_->map;
- break;
- case attr_item_type:
- case attr_length:
- case attr_navigation_speech:
- case attr_street_name:
- case attr_street_name_systematic:
- case attr_street_destination:
-
- mr=map_rect_new(this_->map, NULL);
- while ((item=map_rect_get_item(mr))) {
- if (item->type != type_nav_none && item->type != type_nav_position) {
- if (type == attr_item_type)
- attr->u.item_type=item->type;
- else {
- if (!item_attr_get(item, type, attr))
- item=NULL;
- }
- break;
- }
- }
- map_rect_destroy(mr);
- if (!item)
- return 0;
- break;
- case attr_turn_around_count:
- attr->u.num=this_->turn_around_count;
- break;
- case attr_nav_status:
- attr->u.num=this_->nav_status;
- break;
- default:
- return navit_object_get_attr((struct navit_object *)this_, type, attr, iter);
- }
- attr->type=type;
- return 1;
+int navigation_get_attr(struct navigation *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ struct map_rect *mr;
+ struct item *item;
+ dbg(lvl_debug,"enter %s", attr_to_name(type));
+ switch (type) {
+ case attr_map:
+ attr->u.map=this_->map;
+ break;
+ case attr_item_type:
+ case attr_length:
+ case attr_navigation_speech:
+ case attr_street_name:
+ case attr_street_name_systematic:
+ case attr_street_destination:
+
+ mr=map_rect_new(this_->map, NULL);
+ while ((item=map_rect_get_item(mr))) {
+ if (item->type != type_nav_none && item->type != type_nav_position) {
+ if (type == attr_item_type)
+ attr->u.item_type=item->type;
+ else {
+ if (!item_attr_get(item, type, attr))
+ item=NULL;
+ }
+ break;
+ }
+ }
+ map_rect_destroy(mr);
+ if (!item)
+ return 0;
+ break;
+ case attr_turn_around_count:
+ attr->u.num=this_->turn_around_count;
+ break;
+ case attr_nav_status:
+ attr->u.num=this_->nav_status;
+ break;
+ default:
+ return navit_object_get_attr((struct navit_object *)this_, type, attr, iter);
+ }
+ attr->type=type;
+ return 1;
}
-static void
-navigation_set_turnaround(struct navigation *this_, int val)
-{
- if (this_->turn_around_count != val) {
- struct attr attr=ATTR_INT(turn_around_count, val);
- this_->turn_around_count=val;
- navit_object_callbacks((struct navit_object *)this_, &attr);
- }
+static void navigation_set_turnaround(struct navigation *this_, int val) {
+ if (this_->turn_around_count != val) {
+ struct attr attr=ATTR_INT(turn_around_count, val);
+ this_->turn_around_count=val;
+ navit_object_callbacks((struct navit_object *)this_, &attr);
+ }
}
-int
-navigation_set_attr(struct navigation *this_, struct attr *attr)
-{
- switch (attr->type) {
- case attr_speech:
- this_->speech=attr->u.speech;
- break;
- case attr_nav_status:
- this_->nav_status = attr->u.num;
- break;
- default:
- break;
- }
- return navit_object_set_attr((struct navit_object *)this_, attr);
+int navigation_set_attr(struct navigation *this_, struct attr *attr) {
+ switch (attr->type) {
+ case attr_speech:
+ this_->speech=attr->u.speech;
+ break;
+ case attr_nav_status:
+ this_->nav_status = attr->u.num;
+ break;
+ default:
+ break;
+ }
+ return navit_object_set_attr((struct navit_object *)this_, attr);
}
struct navigation *
-navigation_new(struct attr *parent, struct attr **attrs)
-{
- int i,j;
- struct attr * attr;
- struct navigation *ret=(struct navigation *)navit_object_new(attrs, &navigation_func, sizeof(struct navigation));
- ret->hash=item_hash_new();
- ret->callback=callback_list_new();
- ret->callback_speech=callback_list_new();
- ret->level_last=4;
- ret->distance_turn=50;
- ret->turn_around_limit=3;
- ret->navit=parent->u.navit;
- ret->tell_street_name=1;
- ret->route_mr = NULL;
-
- for (j = 0 ; j <= route_item_last-route_item_first ; j++) {
- for (i = 0 ; i < 3 ; i++) {
- ret->announce[j][i]=-1;
- }
- }
-
- if ((attr=attr_search(attrs, NULL, attr_tell_street_name))) {
- ret->tell_street_name = attr->u.num;
- }
- if ((attr=attr_search(attrs, NULL, attr_delay))) {
- ret->delay = attr->u.num;
- }
- if ((attr=attr_search(attrs, NULL, attr_flags))) {
- ret->flags = attr->u.num;
- }
- return ret;
+navigation_new(struct attr *parent, struct attr **attrs) {
+ int i,j;
+ struct attr * attr;
+ struct navigation *ret=(struct navigation *)navit_object_new(attrs, &navigation_func, sizeof(struct navigation));
+ ret->hash=item_hash_new();
+ ret->callback=callback_list_new();
+ ret->callback_speech=callback_list_new();
+ ret->level_last=4;
+ ret->distance_turn=50;
+ ret->turn_around_limit=3;
+ ret->navit=parent->u.navit;
+ ret->tell_street_name=1;
+ ret->route_mr = NULL;
+
+ for (j = 0 ; j <= route_item_last-route_item_first ; j++) {
+ for (i = 0 ; i < 3 ; i++) {
+ ret->announce[j][i]=-1;
+ }
+ }
+
+ if ((attr=attr_search(attrs, NULL, attr_tell_street_name))) {
+ ret->tell_street_name = attr->u.num;
+ }
+ if ((attr=attr_search(attrs, NULL, attr_delay))) {
+ ret->delay = attr->u.num;
+ }
+ if ((attr=attr_search(attrs, NULL, attr_flags))) {
+ ret->flags = attr->u.num;
+ }
+ return ret;
}
-int
-navigation_set_announce(struct navigation *this_, enum item_type type, int *level)
-{
- int i;
- if (type < route_item_first || type > route_item_last) {
- dbg(lvl_debug,"street type %d out of range [%d,%d]", type, route_item_first, route_item_last);
- return 0;
- }
- for (i = 0 ; i < 3 ; i++)
- this_->announce[type-route_item_first][i]=level[i];
- return 1;
+int navigation_set_announce(struct navigation *this_, enum item_type type, int *level) {
+ int i;
+ if (type < route_item_first || type > route_item_last) {
+ dbg(lvl_debug,"street type %d out of range [%d,%d]", type, route_item_first, route_item_last);
+ return 0;
+ }
+ for (i = 0 ; i < 3 ; i++)
+ this_->announce[type-route_item_first][i]=level[i];
+ return 1;
}
-static enum announcement_level
-navigation_get_announce_level(struct navigation *this_, enum item_type type, int dist)
-{
- enum announcement_level level;
-
- if (type < route_item_first || type > route_item_last)
- {
- dbg(lvl_error," item outside routable range\n");
- return level_error;
- }
- for (level = level_now ; level < level_follow ; level++) {
- if (dist <= this_->announce[type-route_item_first][level])
- return level;
- }
- return level;
+static enum announcement_level navigation_get_announce_level(struct navigation *this_, enum item_type type, int dist) {
+ enum announcement_level level;
+
+ if (type < route_item_first || type > route_item_last) {
+ dbg(lvl_error," item outside routable range");
+ return level_error;
+ }
+ for (level = level_now ; level < level_follow ; level++) {
+ if (dist <= this_->announce[type-route_item_first][level])
+ return level;
+ }
+ return level;
}
static int is_way_allowed(struct navigation *nav, struct navigation_way *way, int mode);
-static enum announcement_level
-navigation_get_announce_level_cmd(struct navigation *this_, struct navigation_itm *itm, struct navigation_command *cmd, int distance)
-{
- enum announcement_level level2,level=navigation_get_announce_level(this_, itm->way.item.type, distance);
- if (this_->cmd_first->itm->prev) {
- level2=navigation_get_announce_level(this_, cmd->itm->prev->way.item.type, distance);
- if (level2 > level) {
- level = level2;
- }
- }
- return level;
+static enum announcement_level navigation_get_announce_level_cmd(struct navigation *this_, struct navigation_itm *itm,
+ struct navigation_command *cmd,
+ int distance) {
+ enum announcement_level level2,level=navigation_get_announce_level(this_, itm->way.item.type, distance);
+ if (this_->cmd_first->itm->prev) {
+ level2=navigation_get_announce_level(this_, cmd->itm->prev->way.item.type, distance);
+ if (level2 > level) {
+ level = level2;
+ }
+ }
+ return level;
}
/* 0=N,90=E */
@@ -878,133 +855,110 @@ navigation_get_announce_level_cmd(struct navigation *this_, struct navigation_it
*
* @return The bearing in degrees, {@code 0 <= result < 360}.
*/
-static int
-road_angle(struct coord *c1, struct coord *c2, int dir)
-{
- int ret=transform_get_angle_delta(c1, c2, dir);
- dbg(lvl_debug, "road_angle(0x%x,0x%x - 0x%x,0x%x)=%d\n", c1->x, c1->y, c2->x, c2->y, ret);
- return ret;
+static int road_angle(struct coord *c1, struct coord *c2, int dir) {
+ int ret=transform_get_angle_delta(c1, c2, dir);
+ dbg(lvl_debug, "road_angle(0x%x,0x%x - 0x%x,0x%x)=%d", c1->x, c1->y, c2->x, c2->y, ret);
+ return ret;
}
static const char
-*get_count_str(int n)
-{
- switch (n) {
- case 0:
- /* TRANSLATORS: the following counts refer to streets */
- return _("zeroth"); /* Not sure if this exists, neither if it will ever be needed */
- case 1:
- return _("first");
- case 2:
- return _("second");
- case 3:
- return _("third");
- case 4:
- return _("fourth");
- case 5:
- return _("fifth");
- case 6:
- return _("sixth");
- default:
- return NULL;
- }
+*get_count_str(int n) {
+ switch (n) {
+ case 0:
+ /* TRANSLATORS: the following counts refer to streets */
+ return _("zeroth"); /* Not sure if this exists, neither if it will ever be needed */
+ case 1:
+ return _("first");
+ case 2:
+ return _("second");
+ case 3:
+ return _("third");
+ case 4:
+ return _("fourth");
+ case 5:
+ return _("fifth");
+ case 6:
+ return _("sixth");
+ default:
+ return NULL;
+ }
}
static const char
-*get_exit_count_str(int n)
-{
- switch (n) {
- case 0:
- /* TRANSLATORS: the following counts refer to roundabout exits */
- return _("zeroth exit"); /* Not sure if this exists, neither if it will ever be needed */
- case 1:
- return _("first exit");
- case 2:
- return _("second exit");
- case 3:
- return _("third exit");
- case 4:
- return _("fourth exit");
- case 5:
- return _("fifth exit");
- case 6:
- return _("sixth exit");
- default:
- return NULL;
- }
+*get_exit_count_str(int n) {
+ switch (n) {
+ case 0:
+ /* TRANSLATORS: the following counts refer to roundabout exits */
+ return _("zeroth exit"); /* Not sure if this exists, neither if it will ever be needed */
+ case 1:
+ return _("first exit");
+ case 2:
+ return _("second exit");
+ case 3:
+ return _("third exit");
+ case 4:
+ return _("fourth exit");
+ case 5:
+ return _("fifth exit");
+ case 6:
+ return _("sixth exit");
+ default:
+ return NULL;
+ }
}
-static int
-round_distance(int dist)
-{
- if (dist < 100) {
- dist=(dist+5)/10;
- return dist*10;
- }
- if (dist < 250) {
- dist=(dist+13)/25;
- return dist*25;
- }
- if (dist < 500) {
- dist=(dist+25)/50;
- return dist*50;
- }
- if (dist < 1000) {
- dist=(dist+50)/100;
- return dist*100;
- }
- if (dist < 5000) {
- dist=(dist+50)/100;
- return dist*100;
- }
- if (dist < 100000) {
- dist=(dist+500)/1000;
- return dist*1000;
- }
- dist=(dist+5000)/10000;
- return dist*10000;
-}
-
-/** @brief Returns the last element of the simplified numbers containing a distance value.
-* @return value with the highest distance.
-*/
-static int
-distance_set_last(void)
-{
- static int i=0;
- if (i == 0) {
- while (distances[i] > 0)
- i++;
- }
- return distances[i-1];
+static int round_distance(int dist) {
+ if (dist < 100) {
+ dist=(dist+5)/10;
+ return dist*10;
+ }
+ if (dist < 250) {
+ dist=(dist+13)/25;
+ return dist*25;
+ }
+ if (dist < 500) {
+ dist=(dist+25)/50;
+ return dist*50;
+ }
+ if (dist < 1000) {
+ dist=(dist+50)/100;
+ return dist*100;
+ }
+ if (dist < 5000) {
+ dist=(dist+50)/100;
+ return dist*100;
+ }
+ if (dist < 100000) {
+ dist=(dist+500)/1000;
+ return dist*1000;
+ }
+ dist=(dist+5000)/10000;
+ return dist*10000;
}
/** @brief Restricts the distance value to a simple set of pronounceable numbers.
* @param dist The distance to be processed
* @return distance Simplified distance value
*/
-static int
-round_distance_reduced( int dist )
-{
- int factor = 1;
- if (dist > distance_set_last())
- {
- dist=(dist+500)/1000;
- factor = 1000;
- }
-
- int i=0,d=0,m=0;
- while (distances[i] > 0) {
- if (!i || abs(distances[i]-dist) <= d) {
- d=abs(distances[i]-dist);
- m=i;
- }
- if (distances[i] > dist)
- break;
- i++;
- }
- dbg(lvl_debug,"converted %d to %d with factor %d\n",dist,distances[m],factor);
- return distances[m] * factor;
+static int round_distance_reduced( int dist ) {
+ int factor = 1;
+ if (dist > distances[LAST_DISTANCE]) {
+ dist=(dist+500)/1000;
+ factor = 1000;
+ }
+
+ int i=0,d=0,m=0;
+ while (i < SIZE_OF_ARRAY_DISTANCES) {
+ if (!i || abs(distances[i]-dist) <= d) {
+ d=abs(distances[i]-dist);
+ m=i;
+ }
+ if (distances[i] > dist)
+ break;
+ i++;
+ }
+ dbg(lvl_debug,"converted %d to %d with factor %d",dist,distances[m],factor);
+ return distances[m] * factor;
}
@@ -1014,110 +968,98 @@ round_distance_reduced( int dist )
* 'imperial' if set distinguishes the distance statement between miles and feet. Maximum distance in feet is 500.
* 'vocabulary_distances' if set constrains the distance values to a set of simple pronounceable numbers.
*
-* @param nav The navigation object.
-* @param dist Distance in meters.
-* @param type The type of announcement precision.
-* @param is_length 1 for length statement, 0 for distance statement.
-* @return String with length/distance statement.
+* @param nav The navigation object.
+* @param dist_meters Distance in meters.
+* @param type The type of announcement precision.
+* @param is_length 1 for length statement, 0 for distance statement.
+* @return String with length/distance statement.
*/
-static char *
-get_distance_str(struct navigation *nav, int dist_meters, enum attr_type type, int is_length)
-{
- int imperial=0,vocabulary=1; /* default configuration */
-
- /* Get configuration */
- struct attr attr;
- if (navit_get_attr(nav->navit, attr_imperial, &attr, NULL))
- imperial=attr.u.num;
- if (nav->speech && speech_get_attr(nav->speech, attr_vocabulary_distances, &attr, NULL))
- vocabulary=attr.u.num;
- /****************************/
-
- if (imperial) {
-
- int dist_feet = dist_meters * FEET_PER_METER;
-
- if (vocabulary > 0)
- {
- /* normal statement */
- if (type != attr_navigation_long_exact)
- dist_feet = round_distance(dist_feet);
- }
- else
- {
- /* statement with reduced vocabularies */
- dist_feet = round_distance_reduced(dist_feet);
- }
-
- /* check for statement in feet */
- if (dist_feet <= 500)
- {
- if (is_length)
- return g_strdup_printf(_("%d feet"), dist_feet);
- else
- return g_strdup_printf(_("in %d feet"), dist_feet);
- }
-
- int dist_miles = (double) dist_meters / (double)METERS_PER_MILE + 0.5;
-
- if (vocabulary == 0)
- {
- /* statement with reduced vocabularies */
- dist_miles = round_distance_reduced(dist_miles);
- }
-
- if ((dist_meters < METERS_PER_MILE) && (vocabulary > 0))
- {
- /* values smaller than one need extra treatment for one decimal place. For reduced vocabulary it shall remain 'one'. */
- int rem = (((double)dist_meters / (double)METERS_PER_MILE) + 0.05) * 10.0;
- dist_miles= 0;
- if (is_length)
- return g_strdup_printf(_("%d.%d miles"), dist_miles, rem);
- else
- return g_strdup_printf(_("in %d.%d miles"), dist_miles, rem);
- }
-
- if (is_length)
- return g_strdup_printf(navit_nls_ngettext("one mile","%d miles", dist_miles), dist_miles);
- else
- return g_strdup_printf(navit_nls_ngettext("in one mile","in %d miles", dist_miles), dist_miles);
-
- } else {
-
- if (vocabulary > 0)
- {
- /* normal statement */
- if (type != attr_navigation_long_exact)
- dist_meters = round_distance(dist_meters);
- }
- else
- {
- /* statement with reduced vocabularies */
- dist_meters = round_distance_reduced(dist_meters);
- }
-
- if (dist_meters < 1000)
- {
- if (is_length)
- return g_strdup_printf(_("%d meters"), dist_meters);
- else
- return g_strdup_printf(_("in %d meters"), dist_meters);
- }
- if (dist_meters < 5000) {
- /* Distances below 5 km shall be announced with one decimal place. */
- int rem=(dist_meters/100)%10;
- if (rem) {
- if (is_length)
- return g_strdup_printf(_("%d.%d kilometers"), dist_meters/1000, rem);
- else
- return g_strdup_printf(_("in %d.%d kilometers"), dist_meters/1000, rem);
- }
- }
- if (is_length)
- return g_strdup_printf(navit_nls_ngettext("one kilometer","%d kilometers", dist_meters/1000), dist_meters/1000);
- else
- return g_strdup_printf(navit_nls_ngettext("in one kilometer","in %d kilometers", dist_meters/1000), dist_meters/1000);
- }
+static char *get_distance_str(struct navigation *nav, int dist_meters, enum attr_type type, int is_length) {
+ int imperial=0,vocabulary=1; /* default configuration */
+
+ /* Get configuration */
+ struct attr attr;
+ if (navit_get_attr(nav->navit, attr_imperial, &attr, NULL))
+ imperial=attr.u.num;
+ if (nav->speech && speech_get_attr(nav->speech, attr_vocabulary_distances, &attr, NULL))
+ vocabulary=attr.u.num;
+ /****************************/
+
+ if (imperial) {
+
+ int dist_feet = dist_meters * FEET_PER_METER;
+
+ if (vocabulary > 0) {
+ /* normal statement */
+ if (type != attr_navigation_long_exact)
+ dist_feet = round_distance(dist_feet);
+ } else {
+ /* statement with reduced vocabularies */
+ dist_feet = round_distance_reduced(dist_feet);
+ }
+
+ /* check for statement in feet */
+ if (dist_feet <= 500) {
+ if (is_length)
+ return g_strdup_printf(_("%d feet"), dist_feet);
+ else
+ return g_strdup_printf(_("in %d feet"), dist_feet);
+ }
+
+ int dist_miles = (double) dist_meters * (double)METERS_TO_MILES + 0.5;
+
+ if (vocabulary == 0) {
+ /* statement with reduced vocabularies */
+ dist_miles = round_distance_reduced(dist_miles);
+ }
+
+ if ((dist_meters < METERS_TO_MILES) && (vocabulary > 0)) {
+ /* values smaller than one need extra treatment for one decimal place. For reduced vocabulary it shall remain 'one'. */
+ int rem = (((double)dist_meters * (double)METERS_TO_MILES) + 0.05) * 10.0;
+ dist_miles= 0;
+ if (is_length)
+ return g_strdup_printf(_("%d.%d miles"), dist_miles, rem);
+ else
+ return g_strdup_printf(_("in %d.%d miles"), dist_miles, rem);
+ }
+
+ if (is_length)
+ return g_strdup_printf(navit_nls_ngettext("one mile","%d miles", dist_miles), dist_miles);
+ else
+ return g_strdup_printf(navit_nls_ngettext("in one mile","in %d miles", dist_miles), dist_miles);
+
+ } else {
+
+ if (vocabulary > 0) {
+ /* normal statement */
+ if (type != attr_navigation_long_exact)
+ dist_meters = round_distance(dist_meters);
+ } else {
+ /* statement with reduced vocabularies */
+ dist_meters = round_distance_reduced(dist_meters);
+ }
+
+ if (dist_meters < 1000) {
+ if (is_length)
+ return g_strdup_printf(_("%d meters"), dist_meters);
+ else
+ return g_strdup_printf(_("in %d meters"), dist_meters);
+ }
+ if (dist_meters < 5000) {
+ /* Distances below 5 km shall be announced with one decimal place. */
+ int rem=(dist_meters/100)%10;
+ if (rem) {
+ if (is_length)
+ return g_strdup_printf(_("%d.%d kilometers"), dist_meters/1000, rem);
+ else
+ return g_strdup_printf(_("in %d.%d kilometers"), dist_meters/1000, rem);
+ }
+ }
+ if (is_length)
+ return g_strdup_printf(navit_nls_ngettext("one kilometer","%d kilometers", dist_meters/1000), dist_meters/1000);
+ else
+ return g_strdup_printf(navit_nls_ngettext("in one kilometer","in %d kilometers", dist_meters/1000), dist_meters/1000);
+ }
}
/**
@@ -1133,70 +1075,68 @@ get_distance_str(struct navigation *nav, int dist_meters, enum attr_type type, i
* @param w The way to initialize. The {@code item}, {@code id_hi}, {@code id_lo} and {@code dir}
* members of this struct must be set prior to calling this function.
*/
-static void
-navigation_way_init(struct navigation_way *w)
-{
- struct coord cbuf[2];
- struct item *realitem;
- struct coord c;
- struct map_rect *mr;
- struct attr attr;
-
- w->angle2 = invalid_angle;
- mr = map_rect_new(w->item.map, NULL);
- if (!mr)
- return;
-
- realitem = map_rect_get_item_byid(mr, w->item.id_hi, w->item.id_lo);
- if (!realitem) {
- dbg(lvl_warning,"Item from segment not found on map!\n");
- map_rect_destroy(mr);
- return;
- }
-
- if (realitem->type < type_line || realitem->type >= type_area) {
- map_rect_destroy(mr);
- return;
- }
- if (item_attr_get(realitem, attr_flags, &attr))
- w->flags=attr.u.num;
- else
- w->flags=0;
- if (item_attr_get(realitem, attr_street_name, &attr))
- w->name=map_convert_string(realitem->map,attr.u.str);
- else
- w->name=NULL;
- if (item_attr_get(realitem, attr_street_name_systematic, &attr))
- w->name_systematic=map_convert_string(realitem->map,attr.u.str);
- else
- w->name_systematic=NULL;
-
- if (w->dir < 0) {
- if (item_coord_get(realitem, cbuf, 2) != 2) {
- dbg(lvl_warning,"Using calculate_angle() with a less-than-two-coords-item?\n");
- map_rect_destroy(mr);
- return;
- }
-
- while (item_coord_get(realitem, &c, 1)) {
- cbuf[0] = cbuf[1];
- cbuf[1] = c;
- }
-
- } else {
- if (item_coord_get(realitem, cbuf, 2) != 2) {
- dbg(lvl_warning,"Using calculate_angle() with a less-than-two-coords-item?\n");
- map_rect_destroy(mr);
- return;
- }
- c = cbuf[0];
- cbuf[0] = cbuf[1];
- cbuf[1] = c;
- }
-
- map_rect_destroy(mr);
-
- w->angle2=road_angle(&cbuf[1],&cbuf[0],0);
+static void navigation_way_init(struct navigation_way *w) {
+ struct coord cbuf[2];
+ struct item *realitem;
+ struct coord c;
+ struct map_rect *mr;
+ struct attr attr;
+
+ w->angle2 = invalid_angle;
+ mr = map_rect_new(w->item.map, NULL);
+ if (!mr)
+ return;
+
+ realitem = map_rect_get_item_byid(mr, w->item.id_hi, w->item.id_lo);
+ if (!realitem) {
+ dbg(lvl_warning,"Item from segment not found on map!");
+ map_rect_destroy(mr);
+ return;
+ }
+
+ if (realitem->type < type_line || realitem->type >= type_area) {
+ map_rect_destroy(mr);
+ return;
+ }
+ if (item_attr_get(realitem, attr_flags, &attr))
+ w->flags=attr.u.num;
+ else
+ w->flags=0;
+ if (item_attr_get(realitem, attr_street_name, &attr))
+ w->name=map_convert_string(realitem->map,attr.u.str);
+ else
+ w->name=NULL;
+ if (item_attr_get(realitem, attr_street_name_systematic, &attr))
+ w->name_systematic=map_convert_string(realitem->map,attr.u.str);
+ else
+ w->name_systematic=NULL;
+
+ if (w->dir < 0) {
+ if (item_coord_get(realitem, cbuf, 2) != 2) {
+ dbg(lvl_warning,"Using calculate_angle() with a less-than-two-coords-item?");
+ map_rect_destroy(mr);
+ return;
+ }
+
+ while (item_coord_get(realitem, &c, 1)) {
+ cbuf[0] = cbuf[1];
+ cbuf[1] = c;
+ }
+
+ } else {
+ if (item_coord_get(realitem, cbuf, 2) != 2) {
+ dbg(lvl_warning,"Using calculate_angle() with a less-than-two-coords-item?");
+ map_rect_destroy(mr);
+ return;
+ }
+ c = cbuf[0];
+ cbuf[0] = cbuf[1];
+ cbuf[1] = c;
+ }
+
+ map_rect_destroy(mr);
+
+ w->angle2=road_angle(&cbuf[1],&cbuf[0],0);
}
@@ -1229,80 +1169,80 @@ navigation_way_init(struct navigation_way *w)
*
* @return The delta, {@code -180 < delta <= 180}, or {@code invalid_angle} if an error occurred.
*/
-static int
-navigation_way_get_max_delta(struct navigation_way *w, enum projection pro, int angle, double dist, int dir) {
- double dist_left = dist; /* distance from last examined point */
- int ret = invalid_angle;
- int tmp_delta;
- int eff_dir = dir * w->dir; /* effective direction: +1 to examine section from start of way, -1 from end of way */
- struct coord cbuf[2];
- struct item *realitem;
- struct coord c;
- struct map_rect *mr;
-
- mr = map_rect_new(w->item.map, NULL);
- if (!mr)
- return ret;
-
- realitem = map_rect_get_item_byid(mr, w->item.id_hi, w->item.id_lo);
- if (!realitem) {
- dbg(lvl_warning,"Item from segment not found on map!\n");
- map_rect_destroy(mr);
- return ret;
- }
-
- if (realitem->type < type_line || realitem->type >= type_area) {
- map_rect_destroy(mr);
- return ret;
- }
-
- if (item_coord_get(realitem, &cbuf[1], 1) != 1) {
- dbg(lvl_warning,"item has no coords\n");
- map_rect_destroy(mr);
- return ret;
- }
-
- if (eff_dir < 0) {
- /* we're going against the direction of the item:
- * measure its total length and set dist_left to difference of total length and distance */
- dist_left = 0;
- while (item_coord_get(realitem, &c, 1)) {
- cbuf[0] = cbuf[1];
- cbuf[1] = c;
- dist_left += transform_distance(pro, &cbuf[0], &cbuf[1]);
- }
-
- /* if dist is less that the distance of the way, make dist_left the distance from the other end
- * else set it to zero (so we'll examine the whole way) */
- if (dist_left > dist)
- dist_left -= dist;
- else
- dist_left = 0;
-
- item_coord_rewind(realitem);
-
- if (item_coord_get(realitem, &cbuf[1], 1) != 1) {
- dbg(lvl_warning,"item has no more coords after rewind\n");
- map_rect_destroy(mr);
- return ret;
- }
- }
-
- while (item_coord_get(realitem, &c, 1)) {
- if ((eff_dir > 0) && (dist_left <= 0))
- break;
- cbuf[0] = cbuf[1];
- cbuf[1] = c;
- dist_left -= transform_distance(pro, &cbuf[0], &cbuf[1]);
- if ((eff_dir < 0) && (dist_left > 0))
- continue;
- tmp_delta = angle_delta(angle, road_angle(&cbuf[0], &cbuf[1], w->dir));
- if ((ret == invalid_angle) || (abs(ret) < abs(tmp_delta)) || ((abs(ret) == abs(tmp_delta)) && (eff_dir < 0)))
- ret = tmp_delta;
- }
-
- map_rect_destroy(mr);
- return ret;
+static int navigation_way_get_max_delta(struct navigation_way *w, enum projection pro, int angle, double dist,
+ int dir) {
+ double dist_left = dist; /* distance from last examined point */
+ int ret = invalid_angle;
+ int tmp_delta;
+ int eff_dir = dir * w->dir; /* effective direction: +1 to examine section from start of way, -1 from end of way */
+ struct coord cbuf[2];
+ struct item *realitem;
+ struct coord c;
+ struct map_rect *mr;
+
+ mr = map_rect_new(w->item.map, NULL);
+ if (!mr)
+ return ret;
+
+ realitem = map_rect_get_item_byid(mr, w->item.id_hi, w->item.id_lo);
+ if (!realitem) {
+ dbg(lvl_warning,"Item from segment not found on map!");
+ map_rect_destroy(mr);
+ return ret;
+ }
+
+ if (realitem->type < type_line || realitem->type >= type_area) {
+ map_rect_destroy(mr);
+ return ret;
+ }
+
+ if (item_coord_get(realitem, &cbuf[1], 1) != 1) {
+ dbg(lvl_warning,"item has no coords");
+ map_rect_destroy(mr);
+ return ret;
+ }
+
+ if (eff_dir < 0) {
+ /* we're going against the direction of the item:
+ * measure its total length and set dist_left to difference of total length and distance */
+ dist_left = 0;
+ while (item_coord_get(realitem, &c, 1)) {
+ cbuf[0] = cbuf[1];
+ cbuf[1] = c;
+ dist_left += transform_distance(pro, &cbuf[0], &cbuf[1]);
+ }
+
+ /* if dist is less that the distance of the way, make dist_left the distance from the other end
+ * else set it to zero (so we'll examine the whole way) */
+ if (dist_left > dist)
+ dist_left -= dist;
+ else
+ dist_left = 0;
+
+ item_coord_rewind(realitem);
+
+ if (item_coord_get(realitem, &cbuf[1], 1) != 1) {
+ dbg(lvl_warning,"item has no more coords after rewind");
+ map_rect_destroy(mr);
+ return ret;
+ }
+ }
+
+ while (item_coord_get(realitem, &c, 1)) {
+ if ((eff_dir > 0) && (dist_left <= 0))
+ break;
+ cbuf[0] = cbuf[1];
+ cbuf[1] = c;
+ dist_left -= transform_distance(pro, &cbuf[0], &cbuf[1]);
+ if ((eff_dir < 0) && (dist_left > 0))
+ continue;
+ tmp_delta = angle_delta(angle, road_angle(&cbuf[0], &cbuf[1], w->dir));
+ if ((ret == invalid_angle) || (abs(ret) < abs(tmp_delta)) || ((abs(ret) == abs(tmp_delta)) && (eff_dir < 0)))
+ ret = tmp_delta;
+ }
+
+ map_rect_destroy(mr);
+ return ret;
}
/**
@@ -1310,21 +1250,19 @@ navigation_way_get_max_delta(struct navigation_way *w, enum projection pro, int
*
* @param itm The item that should have its ways cleared
*/
-static void
-navigation_itm_ways_clear(struct navigation_itm *itm)
-{
- struct navigation_way *c,*n;
-
- c = itm->way.next;
- while (c) {
- n = c->next;
- map_convert_free(c->name);
- map_convert_free(c->name_systematic);
- g_free(c);
- c = n;
- }
-
- itm->way.next = NULL;
+static void navigation_itm_ways_clear(struct navigation_itm *itm) {
+ struct navigation_way *c,*n;
+
+ c = itm->way.next;
+ while (c) {
+ n = c->next;
+ map_convert_free(c->name);
+ map_convert_free(c->name_systematic);
+ g_free(c);
+ c = n;
+ }
+
+ itm->way.next = NULL;
}
/**
@@ -1336,87 +1274,86 @@ navigation_itm_ways_clear(struct navigation_itm *itm)
* @param itm The item that should be updated
* @param graph_map The route graph's map that these items are on
*/
-static void
-navigation_itm_ways_update(struct navigation_itm *itm, struct map *graph_map)
-{
- struct map_selection coord_sel;
- struct map_rect *g_rect; /* Contains a map rectangle from the route graph's map */
- struct item *i,*sitem;
- struct attr sitem_attr,direction_attr;
- struct navigation_way *w, *l, *h;
-
- dbg(lvl_debug, "entering for item: %s %s %s\n", item_to_name(itm->way.item.type), itm->way.name_systematic, itm->way.name);
-
- navigation_itm_ways_clear(itm);
-
- /* These values cause the code in route.c to get us only the route graph point and connected segments */
- coord_sel.next = NULL;
- coord_sel.u.c_rect.lu = itm->start;
- coord_sel.u.c_rect.rl = itm->start;
- /* the selection's order is ignored */
-
- g_rect = map_rect_new(graph_map, &coord_sel);
-
- i = map_rect_get_item(g_rect);
- if (!i || i->type != type_rg_point) { /* probably offroad? */
- map_rect_destroy(g_rect);
- return ;
- }
-
- w = NULL;
-
- while (1) {
- i = map_rect_get_item(g_rect);
-
- if (!i) {
- break;
- }
-
- if (i->type != type_rg_segment) {
- continue;
- }
-
- if (!item_attr_get(i,attr_street_item,&sitem_attr)) {
- dbg(lvl_warning, "Got no street item for route graph item in entering_straight()\n");
- continue;
- }
-
- if (!item_attr_get(i,attr_direction,&direction_attr)) {
- continue;
- }
-
- sitem = sitem_attr.u.item;
- if (sitem->type == type_street_turn_restriction_no || sitem->type == type_street_turn_restriction_only)
- continue;
-
- if (item_is_equal(itm->way.item,*sitem) || ((itm->prev) && item_is_equal(itm->prev->way.item,*sitem))) {
- continue;
- }
-
- l = w;
- w = g_new0(struct navigation_way, 1);
- w->dir = direction_attr.u.num;
- w->item = *sitem;
- w->next = l;
- navigation_way_init(w); /* calculate and set w->angle2 */
-
- dbg(lvl_debug, "- retrieved way: %s %s %s\n", item_to_name(w->item.type), w->name_systematic, w->name);
-
- /* check if w is already in the list */
- h = l;
- while (h) {
- if (is_same_way(w, h)) {
- g_free(w);
- w = l;
- dbg(lvl_debug, " - way is already in list, discarding\n");
- }
- h = h->next;
- }
- }
-
- map_rect_destroy(g_rect);
-
- itm->way.next = w;
+static void navigation_itm_ways_update(struct navigation_itm *itm, struct map *graph_map) {
+ struct map_selection coord_sel;
+ struct map_rect *g_rect; /* Contains a map rectangle from the route graph's map */
+ struct item *i,*sitem;
+ struct attr sitem_attr,direction_attr;
+ struct navigation_way *w, *l, *h;
+
+ dbg(lvl_debug, "entering for item: %s %s %s", item_to_name(itm->way.item.type), itm->way.name_systematic,
+ itm->way.name);
+
+ navigation_itm_ways_clear(itm);
+
+ /* These values cause the code in route.c to get us only the route graph point and connected segments */
+ coord_sel.next = NULL;
+ coord_sel.u.c_rect.lu = itm->start;
+ coord_sel.u.c_rect.rl = itm->start;
+ /* the selection's order is ignored */
+
+ g_rect = map_rect_new(graph_map, &coord_sel);
+
+ i = map_rect_get_item(g_rect);
+ if (!i || i->type != type_rg_point) { /* probably offroad? */
+ map_rect_destroy(g_rect);
+ return ;
+ }
+
+ w = NULL;
+
+ while (1) {
+ i = map_rect_get_item(g_rect);
+
+ if (!i) {
+ break;
+ }
+
+ if (i->type != type_rg_segment) {
+ continue;
+ }
+
+ if (!item_attr_get(i,attr_street_item,&sitem_attr)) {
+ dbg(lvl_warning, "Got no street item for route graph item in entering_straight()");
+ continue;
+ }
+
+ if (!item_attr_get(i,attr_direction,&direction_attr)) {
+ continue;
+ }
+
+ sitem = sitem_attr.u.item;
+ if (sitem->type == type_street_turn_restriction_no || sitem->type == type_street_turn_restriction_only)
+ continue;
+
+ if (item_is_equal(itm->way.item,*sitem) || ((itm->prev) && item_is_equal(itm->prev->way.item,*sitem))) {
+ continue;
+ }
+
+ l = w;
+ w = g_new0(struct navigation_way, 1);
+ w->dir = direction_attr.u.num;
+ w->item = *sitem;
+ w->next = l;
+ navigation_way_init(w); /* calculate and set w->angle2 */
+
+ dbg(lvl_debug, "- retrieved way: %s %s %s", item_to_name(w->item.type), w->name_systematic, w->name);
+
+ /* check if w is already in the list */
+ h = l;
+ while (h) {
+ if (is_same_way(w, h)) {
+ g_free(w);
+ w = l;
+ dbg(lvl_debug, " - way is already in list, discarding");
+ }
+ h = h->next;
+ }
+ }
+
+ map_rect_destroy(g_rect);
+
+ itm->way.next = w;
}
/**
@@ -1430,69 +1367,65 @@ navigation_itm_ways_update(struct navigation_itm *itm, struct map *graph_map)
* @param end The first navigation item to keep. If it is NULL or not found in the list, all items
* will be destroyed.
*/
-static void
-navigation_destroy_itms_cmds(struct navigation *this_, struct navigation_itm *end)
-{
- struct navigation_itm *itm;
- struct navigation_command *cmd;
- dbg(lvl_info,"enter this_=%p this_->first=%p this_->cmd_first=%p end=%p\n", this_, this_->first, this_->cmd_first, end);
- if (this_->cmd_first)
- dbg(lvl_info,"this_->cmd_first->itm=%p\n", this_->cmd_first->itm);
- while (this_->first && this_->first != end) {
- itm=this_->first;
- dbg(lvl_debug,"destroying %p\n", itm);
- item_hash_remove(this_->hash, &itm->way.item);
- this_->first=itm->next;
- if (this_->first)
- this_->first->prev=NULL;
- if (this_->cmd_first && this_->cmd_first->itm == itm->next) {
- cmd=this_->cmd_first;
- this_->cmd_first=cmd->next;
- if (cmd->next) {
- cmd->next->prev = NULL;
- }
- if (cmd->maneuver)
- g_free(cmd->maneuver);
- g_free(cmd);
- }
-
- map_convert_free(itm->way.name);
- map_convert_free(itm->way.name_systematic);
- map_convert_free(itm->way.exit_ref);
- map_convert_free(itm->way.exit_label);
- free_list(itm->way.destination);
- navigation_itm_ways_clear(itm);
- g_free(itm);
- }
- if (! this_->first)
- this_->last=NULL;
- if (! this_->first && end)
- dbg(lvl_error,"end wrong\n");
- dbg(lvl_info,"ret this_->first=%p this_->cmd_first=%p\n",this_->first, this_->cmd_first);
+static void navigation_destroy_itms_cmds(struct navigation *this_, struct navigation_itm *end) {
+ struct navigation_itm *itm;
+ struct navigation_command *cmd;
+ dbg(lvl_info,"enter this_=%p this_->first=%p this_->cmd_first=%p end=%p", this_, this_->first, this_->cmd_first, end);
+ if (this_->cmd_first)
+ dbg(lvl_info,"this_->cmd_first->itm=%p", this_->cmd_first->itm);
+ while (this_->first && this_->first != end) {
+ itm=this_->first;
+ dbg(lvl_debug,"destroying %p", itm);
+ item_hash_remove(this_->hash, &itm->way.item);
+ this_->first=itm->next;
+ if (this_->first)
+ this_->first->prev=NULL;
+ if (this_->cmd_first && this_->cmd_first->itm == itm->next) {
+ cmd=this_->cmd_first;
+ this_->cmd_first=cmd->next;
+ if (cmd->next) {
+ cmd->next->prev = NULL;
+ }
+ if (cmd->maneuver)
+ g_free(cmd->maneuver);
+ g_free(cmd);
+ }
+
+ map_convert_free(itm->way.name);
+ map_convert_free(itm->way.name_systematic);
+ map_convert_free(itm->way.exit_ref);
+ map_convert_free(itm->way.exit_label);
+ free_list(itm->way.destination);
+ navigation_itm_ways_clear(itm);
+ g_free(itm);
+ }
+ if (! this_->first)
+ this_->last=NULL;
+ if (! this_->first && end)
+ dbg(lvl_error,"end wrong");
+ dbg(lvl_info,"ret this_->first=%p this_->cmd_first=%p",this_->first, this_->cmd_first);
}
-static void
-navigation_itm_update(struct navigation_itm *itm, struct item *ritem)
-{
- struct attr length, time, speed;
-
- if (! item_attr_get(ritem, attr_length, &length)) {
- dbg(lvl_error,"no length\n");
- return;
- }
- if (! item_attr_get(ritem, attr_time, &time)) {
- dbg(lvl_error,"no time\n");
- return;
- }
- if (! item_attr_get(ritem, attr_speed, &speed)) {
- dbg(lvl_error,"no speed\n");
- return;
- }
-
- dbg(lvl_debug,"length=%ld time=%ld speed=%ld\n", length.u.num, time.u.num, speed.u.num);
- itm->length=length.u.num;
- itm->time=time.u.num;
- itm->speed=speed.u.num;
+static void navigation_itm_update(struct navigation_itm *itm, struct item *ritem) {
+ struct attr length, time, speed;
+
+ if (! item_attr_get(ritem, attr_length, &length)) {
+ dbg(lvl_error,"no length");
+ return;
+ }
+ if (! item_attr_get(ritem, attr_time, &time)) {
+ dbg(lvl_error,"no time");
+ return;
+ }
+ if (! item_attr_get(ritem, attr_speed, &speed)) {
+ dbg(lvl_error,"no speed");
+ return;
+ }
+
+ dbg(lvl_debug,"length=%ld time=%ld speed=%ld", length.u.num, time.u.num, speed.u.num);
+ itm->length=length.u.num;
+ itm->time=time.u.num;
+ itm->speed=speed.u.num;
}
/**
@@ -1511,210 +1444,189 @@ navigation_itm_update(struct navigation_itm *itm, struct item *ritem)
* @param routeitem the routeitem from which to create a navigation item
* @return the new navigation_itm (used nowhere)
*/
-static struct navigation_itm *
-navigation_itm_new(struct navigation *this_, struct item *routeitem)
-{
- struct navigation_itm *ret=g_new0(struct navigation_itm, 1);
- int i=0;
- struct item *streetitem;
- struct map *graph_map = NULL;
- struct attr street_item,direction,route_attr;
- struct map_rect *mr;
- struct attr attr;
- struct coord c[5];
- struct coord exitcoord;
-
- if (routeitem) {
- ret->streetname_told=0;
- if (! item_attr_get(routeitem, attr_street_item, &street_item)) {
- dbg(lvl_warning, "no street item\n");
- g_free(ret);
- ret = NULL;
- return ret;
- }
-
- if (item_attr_get(routeitem, attr_direction, &direction))
- ret->way.dir=direction.u.num;
- else
- ret->way.dir=0;
-
- streetitem=street_item.u.item;
- ret->way.item=*streetitem;
- item_hash_insert(this_->hash, streetitem, ret);
-
- mr=map_rect_new(streetitem->map, NULL);
- struct map *tmap = streetitem->map;
-
- if (! (streetitem=map_rect_get_item_byid(mr, streetitem->id_hi, streetitem->id_lo))) {
- g_free(ret);
- map_rect_destroy(mr);
- return NULL;
- }
-
- if (item_attr_get(streetitem, attr_flags, &attr))
- ret->way.flags=attr.u.num;
-
- if (item_attr_get(streetitem, attr_street_name, &attr))
- ret->way.name=map_convert_string(streetitem->map,attr.u.str);
-
- if (item_attr_get(streetitem, attr_street_name_systematic, &attr))
- ret->way.name_systematic=map_convert_string(streetitem->map,attr.u.str);
-
- if (ret->way.flags && (ret->way.flags & AF_ONEWAY))
- {
- if (item_attr_get(streetitem, attr_street_destination, &attr))
- {
- char *destination_raw;
- destination_raw=map_convert_string(streetitem->map,attr.u.str);
- dbg(lvl_debug,"destination_raw =%s\n",destination_raw);
- split_string_to_list(&(ret->way),destination_raw, ';');
- g_free(destination_raw);
- }
- }
- else
- {
- if (ret->way.dir == 1)
- {
- if (item_attr_get(streetitem, attr_street_destination_forward, &attr))
- {
- char *destination_raw;
- destination_raw=map_convert_string(streetitem->map,attr.u.str);
- dbg(lvl_debug,"destination_raw forward =%s\n",destination_raw);
- split_string_to_list(&(ret->way),destination_raw, ';');
- g_free(destination_raw);
- }
-
- }
- if (ret->way.dir == -1)
- {
- if (item_attr_get(streetitem, attr_street_destination_backward, &attr))
- {
- char *destination_raw;
- destination_raw=map_convert_string(streetitem->map,attr.u.str);
- dbg(lvl_debug,"destination_raw backward =%s\n",destination_raw);
- split_string_to_list(&(ret->way),destination_raw, ';');
- g_free(destination_raw);
- }
- }
- }
- navigation_itm_update(ret, routeitem);
-
- while (item_coord_get(routeitem, &c[i], 1))
- {
- dbg(lvl_debug, "coord %d 0x%x 0x%x\n", i, c[i].x ,c[i].y);
- if (i < 4)
- i++;
- else
- {
- c[2]=c[3];
- c[3]=c[4];
- }
- }
-
- i--;
- if (i>=1)
- {
- ret->way.angle2=road_angle(&c[0], &c[1], 0);
- ret->angle_end=road_angle(&c[i-1], &c[i], 0);
- }
- ret->start=c[0];
- ret->end=c[i];
-
- if(item_attr_get(routeitem, attr_route, &route_attr))
- graph_map = route_get_graph_map(route_attr.u.route);
- if (graph_map )
- {
- if (this_->last)
- ret->prev=this_->last;
- navigation_itm_ways_update(ret,graph_map);
- }
-
- /* If we have a ramp, check the map for higway_exit info,
- * but only on the first node of the ramp.
- * We are doing the same for motorway-like roads because some
- * interchanges use motorway types for the links between two
- * motorways.
- * Ramps with nodes in reverse order and oneway=-1 are not
- * specifically handled, but no occurence known so far either.
- * If present, obtain exit_ref, exit_label and exit_to
- * from the map.
- */
- if (ret->way.next && ((streetitem->type == type_ramp) || (streetitem->type == type_highway_land)
- || (streetitem->type == type_highway_city) || (streetitem->type == type_street_n_lanes)))
- {
- struct map_selection mselexit;
- struct item *rampitem;
- dbg(lvl_debug,"test ramp\n");
- mselexit.next = NULL;
- mselexit.u.c_rect.lu = c[0] ;
- mselexit.u.c_rect.rl = c[0] ;
- mselexit.range = item_range_all;
- mselexit.order =18;
-
- map_rect_destroy(mr);
- mr = map_rect_new(tmap, &mselexit);
-
- while ((rampitem=map_rect_get_item(mr)))
- {
- if (rampitem->type == type_highway_exit && item_coord_get(rampitem, &exitcoord, 1)
- && exitcoord.x == c[0].x && exitcoord.y == c[0].y)
- {
- while (item_attr_get(rampitem, attr_any, &attr))
- {
- if (attr.type && attr.type == attr_label)
- {
- dbg(lvl_debug,"exit_label=%s\n",attr.u.str);
- ret->way.exit_label= map_convert_string(tmap,attr.u.str);
- }
- if (attr.type == attr_ref)
- {
- dbg(lvl_debug,"exit_ref=%s\n",attr.u.str);
- ret->way.exit_ref= map_convert_string(tmap,attr.u.str);
- }
- if (attr.type == attr_exit_to)
- {
- /* use exit_to as a fall back in case :
- * - there is no regular destination info
- * - we are not coming from a ramp already
- */
- if (attr.u.str
- && !ret->way.destination
- && (ret->way.item.type == type_ramp)
- && (this_->last)
- && (!(this_->last->way.item.type == type_ramp))) {
- char *destination_raw;
- destination_raw=map_convert_string(tmap,attr.u.str);
- dbg(lvl_debug,"destination_raw from exit_to =%s\n",destination_raw);
- if ((split_string_to_list(&(ret->way),destination_raw, ';')) < 2)
- /*
- * if a first try did not result in an actual splitting
- * retry with ',' as a separator because in France a bad
- * mapping practice exists to separate exit_to with ','
- * instead of ';'
- */
- (split_string_to_list(&(ret->way),destination_raw, ','));
- g_free(destination_raw);
- }
- }
- }
- }
- }
- }
- dbg(lvl_debug,"i=%d start %d end %d '%s' \n", i, ret->way.angle2, ret->angle_end, ret->way.name_systematic);
- map_rect_destroy(mr);
- } else {
- if (this_->last)
- ret->start=ret->end=this_->last->end;
- }
- if (! this_->first)
- this_->first=ret;
- if (this_->last) {
- this_->last->next=ret;
- ret->prev=this_->last;
- }
- dbg(lvl_debug,"ret=%p\n", ret);
- this_->last=ret;
- return ret;
+static struct navigation_itm *navigation_itm_new(struct navigation *this_, struct item *routeitem) {
+ struct navigation_itm *ret=g_new0(struct navigation_itm, 1);
+ int i=0;
+ struct item *streetitem;
+ struct map *graph_map = NULL;
+ struct attr street_item,direction,route_attr;
+ struct map_rect *mr;
+ struct attr attr;
+ struct coord c[5];
+ struct coord exitcoord;
+
+ if (routeitem) {
+ ret->streetname_told=0;
+ if (! item_attr_get(routeitem, attr_street_item, &street_item)) {
+ dbg(lvl_warning, "no street item");
+ g_free(ret);
+ ret = NULL;
+ return ret;
+ }
+
+ if (item_attr_get(routeitem, attr_direction, &direction))
+ ret->way.dir=direction.u.num;
+ else
+ ret->way.dir=0;
+
+ streetitem=street_item.u.item;
+ ret->way.item=*streetitem;
+ item_hash_insert(this_->hash, streetitem, ret);
+
+ mr=map_rect_new(streetitem->map, NULL);
+ struct map *tmap = streetitem->map;
+
+ if (! (streetitem=map_rect_get_item_byid(mr, streetitem->id_hi, streetitem->id_lo))) {
+ g_free(ret);
+ map_rect_destroy(mr);
+ return NULL;
+ }
+
+ if (item_attr_get(streetitem, attr_flags, &attr))
+ ret->way.flags=attr.u.num;
+
+ if (item_attr_get(streetitem, attr_street_name, &attr))
+ ret->way.name=map_convert_string(streetitem->map,attr.u.str);
+
+ if (item_attr_get(streetitem, attr_street_name_systematic, &attr))
+ ret->way.name_systematic=map_convert_string(streetitem->map,attr.u.str);
+
+ if (ret->way.flags && (ret->way.flags & AF_ONEWAY)) {
+ if (item_attr_get(streetitem, attr_street_destination, &attr)) {
+ char *destination_raw;
+ destination_raw=map_convert_string(streetitem->map,attr.u.str);
+ dbg(lvl_debug,"destination_raw =%s",destination_raw);
+ split_string_to_list(&(ret->way),destination_raw, ';');
+ g_free(destination_raw);
+ }
+ } else {
+ if (ret->way.dir == 1) {
+ if (item_attr_get(streetitem, attr_street_destination_forward, &attr)) {
+ char *destination_raw;
+ destination_raw=map_convert_string(streetitem->map,attr.u.str);
+ dbg(lvl_debug,"destination_raw forward =%s",destination_raw);
+ split_string_to_list(&(ret->way),destination_raw, ';');
+ g_free(destination_raw);
+ }
+
+ }
+ if (ret->way.dir == -1) {
+ if (item_attr_get(streetitem, attr_street_destination_backward, &attr)) {
+ char *destination_raw;
+ destination_raw=map_convert_string(streetitem->map,attr.u.str);
+ dbg(lvl_debug,"destination_raw backward =%s",destination_raw);
+ split_string_to_list(&(ret->way),destination_raw, ';');
+ g_free(destination_raw);
+ }
+ }
+ }
+ navigation_itm_update(ret, routeitem);
+
+ while (item_coord_get(routeitem, &c[i], 1)) {
+ dbg(lvl_debug, "coord %d 0x%x 0x%x", i, c[i].x,c[i].y);
+ if (i < 4)
+ i++;
+ else {
+ c[2]=c[3];
+ c[3]=c[4];
+ }
+ }
+
+ i--;
+ if (i>=1) {
+ ret->way.angle2=road_angle(&c[0], &c[1], 0);
+ ret->angle_end=road_angle(&c[i-1], &c[i], 0);
+ }
+ ret->start=c[0];
+ ret->end=c[i];
+
+ if(item_attr_get(routeitem, attr_route, &route_attr))
+ graph_map = route_get_graph_map(route_attr.u.route);
+ if (graph_map ) {
+ if (this_->last)
+ ret->prev=this_->last;
+ navigation_itm_ways_update(ret,graph_map);
+ }
+
+ /* If we have a ramp, check the map for higway_exit info,
+ * but only on the first node of the ramp.
+ * We are doing the same for motorway-like roads because some
+ * interchanges use motorway types for the links between two
+ * motorways.
+ * Ramps with nodes in reverse order and oneway=-1 are not
+ * specifically handled, but no occurence known so far either.
+ * If present, obtain exit_ref, exit_label and exit_to
+ * from the map.
+ */
+ if (ret->way.next && ((streetitem->type == type_ramp) || (streetitem->type == type_highway_land)
+ || (streetitem->type == type_highway_city) || (streetitem->type == type_street_n_lanes))) {
+ struct map_selection mselexit;
+ struct item *rampitem;
+ dbg(lvl_debug,"test ramp");
+ mselexit.next = NULL;
+ mselexit.u.c_rect.lu = c[0] ;
+ mselexit.u.c_rect.rl = c[0] ;
+ mselexit.range = item_range_all;
+ mselexit.order =18;
+
+ map_rect_destroy(mr);
+ mr = map_rect_new(tmap, &mselexit);
+
+ while ((rampitem=map_rect_get_item(mr))) {
+ if (rampitem->type == type_highway_exit && item_coord_get(rampitem, &exitcoord, 1)
+ && exitcoord.x == c[0].x && exitcoord.y == c[0].y) {
+ while (item_attr_get(rampitem, attr_any, &attr)) {
+ if (attr.type && attr.type == attr_label) {
+ dbg(lvl_debug,"exit_label=%s",attr.u.str);
+ ret->way.exit_label= map_convert_string(tmap,attr.u.str);
+ }
+ if (attr.type == attr_ref) {
+ dbg(lvl_debug,"exit_ref=%s",attr.u.str);
+ ret->way.exit_ref= map_convert_string(tmap,attr.u.str);
+ }
+ if (attr.type == attr_exit_to) {
+ /* use exit_to as a fall back in case :
+ * - there is no regular destination info
+ * - we are not coming from a ramp already
+ */
+ if (attr.u.str
+ && !ret->way.destination
+ && (ret->way.item.type == type_ramp)
+ && (this_->last)
+ && (!(this_->last->way.item.type == type_ramp))) {
+ char *destination_raw;
+ destination_raw=map_convert_string(tmap,attr.u.str);
+ dbg(lvl_debug,"destination_raw from exit_to =%s",destination_raw);
+ if ((split_string_to_list(&(ret->way),destination_raw, ';')) < 2)
+ /*
+ * if a first try did not result in an actual splitting
+ * retry with ',' as a separator because in France a bad
+ * mapping practice exists to separate exit_to with ','
+ * instead of ';'
+ */
+ (split_string_to_list(&(ret->way),destination_raw, ','));
+ g_free(destination_raw);
+ }
+ }
+ }
+ }
+ }
+ }
+ dbg(lvl_debug,"i=%d start %d end %d '%s' ", i, ret->way.angle2, ret->angle_end, ret->way.name_systematic);
+ map_rect_destroy(mr);
+ } else {
+ if (this_->last)
+ ret->start=ret->end=this_->last->end;
+ }
+ if (! this_->first)
+ this_->first=ret;
+ if (this_->last) {
+ this_->last->next=ret;
+ ret->prev=this_->last;
+ }
+ dbg(lvl_debug,"ret=%p", ret);
+ this_->last=ret;
+ return ret;
}
/**
@@ -1729,42 +1641,41 @@ navigation_itm_new(struct navigation *this_, struct item *routeitem)
* @param direction Set to < 0 to count turns to the left >= 0 for turns to the right
* @return The number of possibilities to turn or -1 on error
*/
-static int
-count_possible_turns(struct navigation *nav, struct navigation_itm *from, struct navigation_itm *to, int direction)
-{
- int count;
- struct navigation_itm *curr;
- struct navigation_way *w;
-
- count = 0;
- curr = from->next;
- while (curr && (curr != to)) {
- w = curr->way.next;
-
- while (w) {
- if (is_way_allowed(nav, w, 4)) {
- if (direction < 0) {
- if (angle_delta(curr->prev->angle_end, w->angle2) < 0) {
- count++;
- break;
- }
- } else {
- if (angle_delta(curr->prev->angle_end, w->angle2) > 0) {
- count++;
- break;
- }
- }
- }
- w = w->next;
- }
- curr = curr->next;
- }
-
- if (!curr) { /* from does not lead to to? */
- return -1;
- }
-
- return count;
+static int count_possible_turns(struct navigation *nav, struct navigation_itm *from, struct navigation_itm *to,
+ int direction) {
+ int count;
+ struct navigation_itm *curr;
+ struct navigation_way *w;
+
+ count = 0;
+ curr = from->next;
+ while (curr && (curr != to)) {
+ w = curr->way.next;
+
+ while (w) {
+ if (is_way_allowed(nav, w, 4)) {
+ if (direction < 0) {
+ if (angle_delta(curr->prev->angle_end, w->angle2) < 0) {
+ count++;
+ break;
+ }
+ } else {
+ if (angle_delta(curr->prev->angle_end, w->angle2) > 0) {
+ count++;
+ break;
+ }
+ }
+ }
+ w = w->next;
+ }
+ curr = curr->next;
+ }
+
+ if (!curr) { /* from does not lead to to? */
+ return -1;
+ }
+
+ return count;
}
/**
@@ -1778,76 +1689,73 @@ count_possible_turns(struct navigation *nav, struct navigation_itm *from, struct
* @param this_ The navigation whose destination / time should be calculated
* @param incr Set this to true to only calculate the first item. See description.
*/
-static void
-calculate_dest_distance(struct navigation *this_, int incr)
-{
- int len=0, time=0, count=0;
- struct navigation_itm *next,*itm=this_->last;
- dbg(lvl_debug, "enter this_=%p, incr=%d\n", this_, incr);
- if (incr) {
- if (itm) {
- dbg(lvl_info, "old values: (%p) time=%d lenght=%d\n", itm, itm->dest_length, itm->dest_time);
- } else {
- dbg(lvl_info, "old values: itm is null\n");
- }
- itm=this_->first;
- next=itm->next;
- dbg(lvl_info, "itm values: time=%d lenght=%d\n", itm->length, itm->time);
- dbg(lvl_info, "next values: (%p) time=%d lenght=%d\n", next, next->dest_length, next->dest_time);
- itm->dest_length=next->dest_length+itm->length;
- itm->dest_count=next->dest_count+1;
- itm->dest_time=next->dest_time+itm->time;
- dbg(lvl_info, "new values: time=%d lenght=%d\n", itm->dest_length, itm->dest_time);
- return;
- }
- while (itm) {
- len+=itm->length;
- time+=itm->time;
- itm->dest_length=len;
- itm->dest_time=time;
- itm->dest_count=count++;
- itm=itm->prev;
- }
- dbg(lvl_debug,"len %d time %d\n", len, time);
+static void calculate_dest_distance(struct navigation *this_, int incr) {
+ int len=0, time=0, count=0;
+ struct navigation_itm *next,*itm=this_->last;
+ dbg(lvl_debug, "enter this_=%p, incr=%d", this_, incr);
+ if (incr) {
+ if (itm) {
+ dbg(lvl_info, "old values: (%p) time=%d lenght=%d", itm, itm->dest_length, itm->dest_time);
+ } else {
+ dbg(lvl_info, "old values: itm is null");
+ }
+ itm=this_->first;
+ next=itm->next;
+ dbg(lvl_info, "itm values: time=%d lenght=%d", itm->length, itm->time);
+ dbg(lvl_info, "next values: (%p) time=%d lenght=%d", next, next->dest_length, next->dest_time);
+ itm->dest_length=next->dest_length+itm->length;
+ itm->dest_count=next->dest_count+1;
+ itm->dest_time=next->dest_time+itm->time;
+ dbg(lvl_info, "new values: time=%d lenght=%d", itm->dest_length, itm->dest_time);
+ return;
+ }
+ while (itm) {
+ len+=itm->length;
+ time+=itm->time;
+ itm->dest_length=len;
+ itm->dest_time=time;
+ itm->dest_count=count++;
+ itm=itm->prev;
+ }
+ dbg(lvl_debug,"len %d time %d", len, time);
}
-static int maneuver_category(enum item_type type)
-{
- switch (type) {
- case type_street_0:
- return 1;
- case type_street_1_city:
- return 2;
- case type_street_2_city:
- return 3;
- case type_street_3_city:
- return 4;
- case type_street_4_city:
- return 5;
- case type_highway_city:
- return 7;
- case type_street_1_land:
- return 2;
- case type_street_2_land:
- return 3;
- case type_street_3_land:
- return 4;
- case type_street_4_land:
- return 5;
- case type_street_n_lanes:
- return 6;
- case type_highway_land:
- return 7;
- case type_ramp:
- return 0;
- case type_roundabout:
- return 0;
- case type_ferry:
- return 0;
- default:
- return 0;
- }
+static int maneuver_category(enum item_type type) {
+ switch (type) {
+ case type_street_0:
+ return 1;
+ case type_street_1_city:
+ return 2;
+ case type_street_2_city:
+ return 3;
+ case type_street_3_city:
+ return 4;
+ case type_street_4_city:
+ return 5;
+ case type_highway_city:
+ return 7;
+ case type_street_1_land:
+ return 2;
+ case type_street_2_land:
+ return 3;
+ case type_street_3_land:
+ return 4;
+ case type_street_4_land:
+ return 5;
+ case type_street_n_lanes:
+ return 6;
+ case type_highway_land:
+ return 7;
+ case type_ramp:
+ return 0;
+ case type_roundabout:
+ return 0;
+ case type_ferry:
+ return 0;
+ default:
+ return 0;
+ }
}
@@ -1867,23 +1775,22 @@ static int maneuver_category(enum item_type type)
* @return True if entry is permitted, false otherwise. If {@code nav->vehicleprofile} is null, true is returned.
*/
- /* (jandegr) this gets called from within show_maneuver with mode=3 for roundabouts
- * and with mode=4 from within count_possible_turns() for the use with
- * 'take the manieth road to the left/right'
- * However over here mode is ignored, so the 'manieth' road excludes unallowed oneway's,
- * but IMHO it should count all drivable roads. For roundabouts it seems to be ok.
- *
- */
+/* (jandegr) this gets called from within show_maneuver with mode=3 for roundabouts
+* and with mode=4 from within count_possible_turns() for the use with
+* 'take the manieth road to the left/right'
+* However over here mode is ignored, so the 'manieth' road excludes unallowed oneway's,
+* but IMHO it should count all drivable roads. For roundabouts it seems to be ok.
+*
+*/
-static int
-is_way_allowed(struct navigation *nav, struct navigation_way *way, int mode)
-{
- if (!nav->vehicleprofile || !way->flags)
- return 1;
- if (mode)
- return ((way->flags & (way->dir >= 0 ? nav->vehicleprofile->flags_forward_mask : nav->vehicleprofile->flags_reverse_mask)) == nav->vehicleprofile->flags);
- else
- return ((way->flags & nav->vehicleprofile->flags) == nav->vehicleprofile->flags);
+static int is_way_allowed(struct navigation *nav, struct navigation_way *way, int mode) {
+ if (!nav->vehicleprofile || !way->flags)
+ return 1;
+ if (mode)
+ return ((way->flags & (way->dir >= 0 ? nav->vehicleprofile->flags_forward_mask :
+ nav->vehicleprofile->flags_reverse_mask)) == nav->vehicleprofile->flags);
+ else
+ return ((way->flags & nav->vehicleprofile->flags) == nav->vehicleprofile->flags);
}
/**
@@ -1899,14 +1806,13 @@ is_way_allowed(struct navigation *nav, struct navigation_way *way, int mode)
* @param extended Whether to consider ramps and service roads to be motorway-like
* @return True for motorway-like, false otherwise
*/
-static int
-is_motorway_like(struct navigation_way *way, int extended)
-{
- if ((way->item.type == type_highway_land) || (way->item.type == type_highway_city) || ((way->item.type == type_street_n_lanes) && (way->flags & AF_ONEWAYMASK)))
- return 1;
- if ((extended) && ((way->item.type == type_ramp) || (way->item.type == type_street_service)))
- return 1;
- return 0;
+static int is_motorway_like(struct navigation_way *way, int extended) {
+ if ((way->item.type == type_highway_land) || (way->item.type == type_highway_city)
+ || ((way->item.type == type_street_n_lanes) && (way->flags & AF_ONEWAYMASK)))
+ return 1;
+ if ((extended) && ((way->item.type == type_ramp) || (way->item.type == type_street_service)))
+ return 1;
+ return 0;
}
/**
@@ -1915,11 +1821,10 @@ is_motorway_like(struct navigation_way *way, int extended)
* @param way The way to be examined
* @return True for ramp, false otherwise
*/
-static int
-is_ramp(struct navigation_way *way) {
- if (way->item.type == type_ramp)
- return 1;
- return 0;
+static int is_ramp(struct navigation_way *way) {
+ if (way->item.type == type_ramp)
+ return 1;
+ return 0;
}
/**
@@ -1936,409 +1841,418 @@ is_ramp(struct navigation_way *way) {
* for freeing up the buffer once it is no longer needed.
* @return True if navit should guide the user, false otherwise
*/
-static int
-maneuver_required2 (struct navigation *nav, struct navigation_itm *old, struct navigation_itm *new, struct navigation_maneuver **maneuver)
-{
- struct navigation_maneuver m; /* if the function returns true, this will be passed in the maneuver argument */
- struct navigation_itm *ni; /* temporary navigation item used for comparisons that examine previous or subsequent maneuvers */
- int ret=0;
- int dw; /* temporary bearing difference between old and w (way being examined) */
- int dlim; /* if no other ways are within +/- dlim, the maneuver is unambiguous */
- int dc; /* if new and another way are within +/-min_turn_limit and on the same side, bearing difference for the other way; else d */
- char *r=NULL; /* human-legible reason for announcing or not announcing the maneuver */
- struct navigation_way *w; /* temporary way to examine */
- struct navigation_way *through_segment2 = NULL; /* off-route segment of through road at complex T junction */
- int wcat;
- int junction_limit = 100; /* maximum distance between two carriageways at a junction */
- int motorways_left = 0, motorways_right = 0; /* number of motorway-like roads left or right of new->way */
- int coming_from_motorway = 0; /* when the maneuver changes from one ramp to another,
+static int maneuver_required2 (struct navigation *nav, struct navigation_itm *old, struct navigation_itm *new,
+ struct navigation_maneuver **maneuver) {
+ struct navigation_maneuver m; /* if the function returns true, this will be passed in the maneuver argument */
+ struct navigation_itm
+ *ni; /* temporary navigation item used for comparisons that examine previous or subsequent maneuvers */
+ int ret=0;
+ int dw; /* temporary bearing difference between old and w (way being examined) */
+ int dlim; /* if no other ways are within +/- dlim, the maneuver is unambiguous */
+ int dc; /* if new and another way are within +/-min_turn_limit and on the same side, bearing difference for the other way; else d */
+ char *r=NULL; /* human-legible reason for announcing or not announcing the maneuver */
+ struct navigation_way *w; /* temporary way to examine */
+ struct navigation_way *through_segment2 = NULL; /* off-route segment of through road at complex T junction */
+ int wcat;
+ int junction_limit = 100; /* maximum distance between two carriageways at a junction */
+ int motorways_left = 0, motorways_right = 0; /* number of motorway-like roads left or right of new->way */
+ int coming_from_motorway = 0; /* when the maneuver changes from one ramp to another,
* whether the last non-ramp road was motorway-like */
- int route_leaves_motorway = 0; /* when the maneuver changes from a motorway-like road to a ramp,
+ int route_leaves_motorway = 0; /* when the maneuver changes from a motorway-like road to a ramp,
* whether a subsequent maneuver leaves the motorway (changing direction
* is considered leaving the motorway) */
- *maneuver = NULL;
-
- m.type = type_nav_none;
- m.delta = angle_delta(old->angle_end, new->way.angle2);
- m.merge_or_exit = mex_none;
- m.is_complex_t_junction = 0;
- m.num_options = 0;
- m.num_new_motorways = 0;
- m.num_other_ways = 0;
- m.num_similar_ways = 0;
- m.old_cat = maneuver_category(old->way.item.type);
- m.new_cat = maneuver_category(new->way.item.type);
- m.max_cat = -1;
- m.left = -180;
- m.right = 180;
- m.is_unambiguous = 1;
- /* Check whether the street keeps its name */
- m.is_same_street = is_same_street2(old->way.name, old->way.name_systematic, new->way.name, new->way.name_systematic);
-
- dc = m.delta;
-
- dbg(lvl_debug,"enter %p %p %p\n",old, new, maneuver);
-#if 0
- dbg(lvl_debug, "old=%s %s, new=%s %s, angle old=%d, angle new=%d, d=%i\n ", old->way.name, old->way.name_systematic, new->way.name, new->way.name_systematic, old->angle_end, new->way.angle2, d);
-#endif
- if (!new->way.next || (new->way.next && (new->way.next->angle2 == new->way.angle2) && !new->way.next->next)) {
- /* No announcement necessary (with extra magic to eliminate duplicate ways) */
- r="no: Only one possibility";
- } else if (!new->way.next->next && new->way.next->item.type == type_ramp && !is_way_allowed(nav,new->way.next,1)) {
- /* If the other way is only a ramp and it is one-way in the wrong direction, no announcement necessary */
- r="no: Only ramp and unallowed direction ";
- ret=0;
- }
- if (! r) {
- /* Announce exit from roundabout, but not entry or staying in it */
- if ((old->way.flags & AF_ROUNDABOUT) && ! (new->way.flags & AF_ROUNDABOUT)) {
- r="yes: leaving roundabout";
- ret=1;
- } else if (!new->way.next->next && !(old->way.flags & AF_ROUNDABOUT) && (new->way.flags & AF_ROUNDABOUT) && (new->way.next->flags & AF_ROUNDABOUT)) {
- /* this rather complicated construct makes sure we suppress announcements
- * only when we're entering a roundabout AND there are no other options */
- r="no: entering roundabout";
- } else if ((old->way.flags & AF_ROUNDABOUT) && (new->way.flags & AF_ROUNDABOUT)) {
- r="no: staying in roundabout";
- }
- }
- if (!r) {
- /* Analyze all options (including new->way).
- * Anything that iterates over the whole set of options should be done here. This avoids
- * looping over the entire set of ways multiple times, which aims to improve performance
- * and predictability (because the same filter is applied to the ways being analyzed).
- */
- w = &(new->way);
- int through_segments = 0;
- while (w) {
- /* in case of overlapping ways, avoid counting the way on the route twice */
- if ((w->angle2 != new->way.angle2) || (w == &(new->way))) {
- dw=angle_delta(old->angle_end, w->angle2);
- if (is_way_allowed(nav,w,1)) {
- dbg(lvl_debug, "- Examining allowed way: %s %s %s, delta=%i\n", item_to_name(w->item.type), w->name_systematic, w->name, dw);
- m.num_options++;
- /* ways of similar category */
- if (maneuver_category(w->item.type) == m.old_cat) {
- /* TODO: considering a maneuver_category difference of 1 to be similar, e.g.
- * if (abs(maneuver_category(w->item.type) - m.old_cat) <= 1)
- * will improve things in some cases but also introduce some junk maneuvers,
- * e.g. at complex junctions. If we relax the maneuver_category requirement,
- * we may need some extra requirements. */
- m.num_similar_ways++;
- }
- /* motorway-like ways */
- if ((m.num_new_motorways < 2) && is_motorway_like(w, 0)) {
- /* Count all motorway-like segments:
- * - always count new
- * - if new or w have an exit_ref or exit_label, count w
- * - if old, new and w have the same name_systematic, do not count w
- * - if one of old, new and w has no name_systematic, count w
- * This is for handling temporary splits (e.g. at toll booths), which should
- * be counted as one motorway for the purpose of navigation. On the other hand,
- * occasionally a motorway may split at an interchange with both segments
- * retaining the name, in which case we want to count both motorways. */
- if ((w == &(new->way))
- || new->way.exit_ref
- || new->way.exit_label
- || w->exit_ref
- || w->exit_label
- || !old->way.name_systematic
- || !new->way.name_systematic
- || !w->name_systematic
- || strcmp(old->way.name_systematic, new->way.name_systematic)
- || strcmp(old->way.name_systematic, w->name_systematic))
- m.num_new_motorways++;
- } else if (!is_motorway_like(w, 1)) {
- m.num_other_ways++;
- }
- if (w != &(new->way)) {
- /* if we're exiting from a motorway, check which side of the ramp the motorway is on */
- if (is_motorway_like(w, 0) && is_motorway_like(&(old->way), 0) && new->way.item.type == type_ramp) {
- if (dw < m.delta)
- motorways_left++;
- else
- motorways_right++;
- }
-
- if (dw < m.delta) {
- if (dw > m.left)
- m.left=dw;
- } else {
- if (dw < m.right)
- m.right=dw;
- }
-
- /* If almost-straight ways are present, the maneuver is ambiguous. We are counting only ways having
- * a nonzero maneuver category (street_0 or higher), excluding ramps, service roads and anything closed
- * to motorized traffic. Exceptions apply when the new way itself has a maneuver category of 0.
- * Note that this is in addition for the dlim calculations we do further below, as they fail to
- * catch some ambiguous cases for very low deltas. */
- if ((dw > -min_turn_limit) && (dw < min_turn_limit) && ((maneuver_category(w->item.type) != 0) || (maneuver_category(new->way.item.type) == 0)))
- m.is_unambiguous = 0;
-
- if (dw < 0) {
- if (dw > -min_turn_limit && m.delta < 0 && m.delta > -min_turn_limit)
- dc=dw;
- } else {
- if (dw < min_turn_limit && m.delta > 0 && m.delta < min_turn_limit)
- dc=dw;
- }
- wcat=maneuver_category(w->item.type);
- /* If any other street has the same name, we can't use the same name criterion.
- * Exceptions apply if we're coming from a motorway-like road and:
- * - the other road is motorway-like (a motorway might split up temporarily) or
- * - the other road is a ramp or service road (they are sometimes tagged with the name of the motorway)
- * The second one is really a workaround for bad tagging practice in OSM. Since entering
- * a ramp always creates a maneuver, we don't expect the workaround to have any unwanted
- * side effects.
- */
- if (m.is_same_street && is_same_street2(old->way.name, old->way.name_systematic, w->name, w->name_systematic) && (!is_motorway_like(&(old->way), 0) || (!is_motorway_like(w, 0) && w->item.type != type_ramp)) && is_way_allowed(nav,w,2))
- m.is_same_street=0;
- /* If the route category changes to a lower one but another road has the same route category as old,
- * it is not clear which of the two the driver would perceive as the "same street", hence reset is_same_street */
- /* Mark if the street has a higher or the same category */
- if (wcat > m.max_cat)
- m.max_cat=wcat;
- } /* if w != new->way */
- /* if is_way_allowed */
- } else {
- /* If we're merging onto a motorway, check which side of the ramp the motorway is on.
- * This requires examining the candidate ways which are NOT allowed. */
- if (is_motorway_like(w, 0) && is_motorway_like(&(new->way), 0) && old->way.item.type == type_ramp) {
- if (dw < 0)
- motorways_left++;
- else
- motorways_right++;
- }
- /* if !is_way_allowed */
- } /* if is_way_allowed || !is_way_allowed */
- if (w->flags & AF_ONEWAYMASK) {
- /* count through_segments (even if they are not allowed) to check if we are at a complex T junction */
- if (is_same_street2(new->way.name, new->way.name_systematic, w->name, w->name_systematic))
- /* count segments belonging to the same street */
- through_segments++;
- else if ((!through_segment2 && (abs(angle_delta(angle_opposite(w->angle2), new->way.angle2)) < min_turn_limit))
- || (through_segment2 && (abs(angle_delta(angle_opposite(w->angle2), new->way.angle2)) < abs(angle_delta(angle_opposite(through_segment2->angle2), new->way.angle2))))) {
- /* also count near-straight continuations of new (the through road may change names at the junction) */
- if (!through_segment2)
- through_segments++;
- through_segment2 = w;
- }
- }
- } /* if w is not a duplicate of way->next */
- w = w->next;
- } /* while w */
- if ((abs(m.delta) >= min_turn_limit) && (through_segments >= 2)) {
- /* If we have to make a considerable turn (min_turn_limit or more),
- * check whether we are approaching a complex T junction from the "stem"
- * (which would need an announcement).
- * Complex means that the through road is a dual-carriageway road.
- * This is the case only if at least 2 segments (including new) are one-way
- * (regardless of direction) and have the same name as new or through_segment2.
- * More than 2 such segments are possible e.g. where two physically separated
- * lanes join.
- * To find out if there is another carriageway, we need to analyze the previous
- * maneuvers.
- */
- int hist_through_segments = 0;
- int hist_dist = old->length; /* distance between previous and current maneuver */
- ni = old;
- while (ni && (hist_through_segments == 0) && (hist_dist <= junction_limit)) {
- /* TODO: shouldn't the condition be (hist_through_segments < 2) to catch through segments that are slightly offset?? */
- struct navigation_way *w = ni->way.next;
- while (w) {
- if (is_same_street2(new->way.name, new->way.name_systematic, w->name, w->name_systematic)
- || (through_segment2 && is_same_street2(through_segment2->name, through_segment2->name_systematic, w->name, w->name_systematic)))
- hist_through_segments++;
- w = w->next;
- }
- ni = ni->prev;
- if (ni)
- hist_dist += ni->length;
- }
- if (hist_through_segments >= 2) {
- /* Require at least 2 segments (there may be more than two in cases such as
- * local-express lane systems or separate cycleways) */
- ret=1;
- m.is_complex_t_junction = 1;
- r="yes: turning into multi-carriageway through-road of T junction";
- }
- }
- }
- if (!r && abs(m.delta) > 75) {
- /* always make an announcement if you have to make a sharp turn */
- r="yes: delta over 75";
- ret=1;
- } else if (!r && abs(m.delta) >= min_turn_limit) {
- if ((m.new_cat >= maneuver_category(type_street_2_city)) && (m.num_similar_ways > 1)) {
- /* When coming from street_2_* or higher category road, check if
- * - we have multiple options of the same category and
- * - we have to make a considerable turn (at least min_turn_limit)
- * If both is the case, ANNOUNCE.
- */
- ret=1;
- r="yes: more than one similar road and delta >= min_turn_limit";
- }
- }
- if ((!r) && (m.num_options <= 1))
- r="no: only one option permitted";
- if (!r) {
- if (is_motorway_like(&(old->way), 0) && (m.num_other_ways == 0) && (m.num_new_motorways > 1) && ((m.left > -90) || (m.right < 90))) {
- /* If we are at a motorway interchange, ANNOUNCE
- * We are assuming a motorway interchange when old way and at least
- * two possible ways are motorway-like and allowed.
- * Additionally we require one way (other than the new way) within +/-90°.
- * This prevents the rule from essentially announcing "don't do the U turn"
- * at the beginning of a single-carriageway section, which is occasionally
- * found on motorways.
- * If any of the possible ways is neither motorway-like nor a ramp,
- * we are probably on a trunk road with level crossings and not
- * at a motorway interchange.
- */
- r="yes: motorway interchange (multiple motorways)";
- m.merge_or_exit = mex_interchange;
- ret=1;
- } else if (is_motorway_like(&(old->way), 0) && is_motorway_like(&(new->way), 0) && (m.num_other_ways == 0) && (!m.is_same_street)) {
- /* Another sign that we are at a motorway interchange is if the street name changes
- */
- r="yes: motorway interchange (name changes)";
- m.merge_or_exit = mex_interchange;
- ret=1;
- } else if ((new->way.item.type == type_ramp) && ((m.num_other_ways == 0) || (abs(m.delta) >= min_turn_limit)) && ((m.left > -90) || (m.right < 90))) {
- /* Motorway ramps can be confusing, therefore we need to lower the bar for announcing a maneuver.
- * When the new way is a ramp, we check for the following criteria:
- * - All available ways are either motorway-like or ramps.
- * This prevents this rule from firing in non-motorway settings, which is needed to avoid
- * superfluous maneuvers when the minor road of a complex T junction is a ramp.
- * - If the above is not met, the maneuver must involve a turn (min_turn_limit or more) to enter the ramp.
- * - Additionally, there must be one way (other than the new way) within +/-90°.
- * This prevents the rule from essentially announcing "don't do the U turn" where the ramps for
- * two opposite directions merge.
- * If the criteria are satisfied, announce.
- */
- r="yes: entering ramp";
- ret=1;
- }
- }
- if (!r) {
- /* get the delta limit for checking for other streets. It is lower if the street has no other
- streets of the same or higher category */
- if (m.new_cat < m.old_cat)
- dlim=80;
- else
- dlim=120;
- /* if the street is really straight, the others might be closer to straight */
- if (abs(m.delta) < 20)
- dlim/=2;
- /* if both old and new way have a category of 0, or if both ways and at least one other way are
- * in the same category and no other ways are higher,
- * dlim is 620/256 (roughly 2.5) times the delta of the maneuver */
- if ((m.max_cat == m.new_cat && m.max_cat == m.old_cat) || (m.new_cat == 0 && m.old_cat == 0))
- dlim=abs(m.delta)*620/256;
- /* if both old and new way are in higher than highest encountered category,
- * dlim is 128/256 times (i.e. one half) the delta of the maneuver */
- else if (m.max_cat < m.new_cat && m.max_cat < m.old_cat)
- dlim=abs(m.delta)*128/256;
- /* if no other ways are within +/-dlim, the maneuver is unambiguous */
- if (m.left >= -dlim || m.right <= dlim)
- m.is_unambiguous = 0;
- /* if another way is within +/-min_turn_limit and on the same side as new, the maneuver is ambiguous */
- if (dc != m.delta) {
- dbg(lvl_debug, "m.delta %d vs dc %d\n", m.delta, dc);
- m.is_unambiguous=0;
- }
- if (!m.is_same_street && m.is_unambiguous < 1) { /* FIXME: why < 1? */
- ret=1;
- r="yes: different street and ambiguous";
- }
- /* we should have cat of the candidate within dlim
- * instead of testing against max_cat.
- * The highest cat road might be well outside dlim
- */
- else if (m.max_cat >= m.new_cat && m.is_unambiguous < 1)
- {
- ret = 1;
- r="yes: ambiguous because of other candidates within dlim";
- }
- else
- r="no: same street or unambiguous";
+ *maneuver = NULL;
+
+ m.type = type_nav_none;
+ m.delta = angle_delta(old->angle_end, new->way.angle2);
+ m.merge_or_exit = mex_none;
+ m.is_complex_t_junction = 0;
+ m.num_options = 0;
+ m.num_new_motorways = 0;
+ m.num_other_ways = 0;
+ m.num_similar_ways = 0;
+ m.old_cat = maneuver_category(old->way.item.type);
+ m.new_cat = maneuver_category(new->way.item.type);
+ m.max_cat = -1;
+ m.left = -180;
+ m.right = 180;
+ m.is_unambiguous = 1;
+ /* Check whether the street keeps its name */
+ m.is_same_street = is_same_street2(old->way.name, old->way.name_systematic, new->way.name, new->way.name_systematic);
+
+ dc = m.delta;
+
+ dbg(lvl_debug,"enter %p %p %p",old, new, maneuver);
+ if (!new->way.next || (new->way.next && (new->way.next->angle2 == new->way.angle2) && !new->way.next->next)) {
+ /* No announcement necessary (with extra magic to eliminate duplicate ways) */
+ r="no: Only one possibility";
+ } else if (!new->way.next->next && new->way.next->item.type == type_ramp && !is_way_allowed(nav,new->way.next,1)) {
+ /* If the other way is only a ramp and it is one-way in the wrong direction, no announcement necessary */
+ r="no: Only ramp and unallowed direction ";
+ ret=0;
+ }
+ if (! r) {
+ /* Announce exit from roundabout, but not entry or staying in it */
+ if ((old->way.flags & AF_ROUNDABOUT) && ! (new->way.flags & AF_ROUNDABOUT)) {
+ r="yes: leaving roundabout";
+ ret=1;
+ } else if (!new->way.next->next && !(old->way.flags & AF_ROUNDABOUT) && (new->way.flags & AF_ROUNDABOUT)
+ && (new->way.next->flags & AF_ROUNDABOUT)) {
+ /* this rather complicated construct makes sure we suppress announcements
+ * only when we're entering a roundabout AND there are no other options */
+ r="no: entering roundabout";
+ } else if ((old->way.flags & AF_ROUNDABOUT) && (new->way.flags & AF_ROUNDABOUT)) {
+ r="no: staying in roundabout";
+ }
+ }
+ if (!r) {
+ /* Analyze all options (including new->way).
+ * Anything that iterates over the whole set of options should be done here. This avoids
+ * looping over the entire set of ways multiple times, which aims to improve performance
+ * and predictability (because the same filter is applied to the ways being analyzed).
+ */
+ w = &(new->way);
+ int through_segments = 0;
+ while (w) {
+ /* in case of overlapping ways, avoid counting the way on the route twice */
+ if ((w->angle2 != new->way.angle2) || (w == &(new->way))) {
+ dw=angle_delta(old->angle_end, w->angle2);
+ if (is_way_allowed(nav,w,1)) {
+ dbg(lvl_debug, "- Examining allowed way: %s %s %s, delta=%i", item_to_name(w->item.type), w->name_systematic, w->name,
+ dw);
+ m.num_options++;
+ /* ways of similar category */
+ if (maneuver_category(w->item.type) == m.old_cat) {
+ /* TODO: considering a maneuver_category difference of 1 to be similar, e.g.
+ * if (abs(maneuver_category(w->item.type) - m.old_cat) <= 1)
+ * will improve things in some cases but also introduce some junk maneuvers,
+ * e.g. at complex junctions. If we relax the maneuver_category requirement,
+ * we may need some extra requirements. */
+ m.num_similar_ways++;
+ }
+ /* motorway-like ways */
+ if ((m.num_new_motorways < 2) && is_motorway_like(w, 0)) {
+ /* Count all motorway-like segments:
+ * - always count new
+ * - if new or w have an exit_ref or exit_label, count w
+ * - if old, new and w have the same name_systematic, do not count w
+ * - if one of old, new and w has no name_systematic, count w
+ * This is for handling temporary splits (e.g. at toll booths), which should
+ * be counted as one motorway for the purpose of navigation. On the other hand,
+ * occasionally a motorway may split at an interchange with both segments
+ * retaining the name, in which case we want to count both motorways. */
+ if ((w == &(new->way))
+ || new->way.exit_ref
+ || new->way.exit_label
+ || w->exit_ref
+ || w->exit_label
+ || !old->way.name_systematic
+ || !new->way.name_systematic
+ || !w->name_systematic
+ || strcmp(old->way.name_systematic, new->way.name_systematic)
+ || strcmp(old->way.name_systematic, w->name_systematic))
+ m.num_new_motorways++;
+ } else if (!is_motorway_like(w, 1)) {
+ m.num_other_ways++;
+ }
+ if (w != &(new->way)) {
+ /* if we're exiting from a motorway, check which side of the ramp the motorway is on */
+ if (is_motorway_like(w, 0) && is_motorway_like(&(old->way), 0) && new->way.item.type == type_ramp) {
+ if (dw < m.delta)
+ motorways_left++;
+ else
+ motorways_right++;
+ }
+
+ if (dw < m.delta) {
+ if (dw > m.left)
+ m.left=dw;
+ } else {
+ if (dw < m.right)
+ m.right=dw;
+ }
+
+ /* If almost-straight ways are present, the maneuver is ambiguous. We are counting only ways having
+ * a nonzero maneuver category (street_0 or higher), excluding ramps, service roads and anything closed
+ * to motorized traffic. Exceptions apply when the new way itself has a maneuver category of 0.
+ * Note that this is in addition for the dlim calculations we do further below, as they fail to
+ * catch some ambiguous cases for very low deltas. */
+ if ((dw > -min_turn_limit) && (dw < min_turn_limit) && ((maneuver_category(w->item.type) != 0)
+ || (maneuver_category(new->way.item.type) == 0)))
+ m.is_unambiguous = 0;
+
+ if (dw < 0) {
+ if (dw > -min_turn_limit && m.delta < 0 && m.delta > -min_turn_limit)
+ dc=dw;
+ } else {
+ if (dw < min_turn_limit && m.delta > 0 && m.delta < min_turn_limit)
+ dc=dw;
+ }
+ wcat=maneuver_category(w->item.type);
+ /* If any other street has the same name, we can't use the same name criterion.
+ * Exceptions apply if we're coming from a motorway-like road and:
+ * - the other road is motorway-like (a motorway might split up temporarily) or
+ * - the other road is a ramp or service road (they are sometimes tagged with the name of the motorway)
+ * The second one is really a workaround for bad tagging practice in OSM. Since entering
+ * a ramp always creates a maneuver, we don't expect the workaround to have any unwanted
+ * side effects.
+ */
+ if (m.is_same_street && is_same_street2(old->way.name, old->way.name_systematic, w->name, w->name_systematic)
+ && (!is_motorway_like(&(old->way), 0) || (!is_motorway_like(w, 0) && w->item.type != type_ramp))
+ && is_way_allowed(nav,w,2))
+ m.is_same_street=0;
+ /* If the route category changes to a lower one but another road has the same route category as old,
+ * it is not clear which of the two the driver would perceive as the "same street", hence reset is_same_street */
+ /* Mark if the street has a higher or the same category */
+ if (wcat > m.max_cat)
+ m.max_cat=wcat;
+ } /* if w != new->way */
+ /* if is_way_allowed */
+ } else {
+ /* If we're merging onto a motorway, check which side of the ramp the motorway is on.
+ * This requires examining the candidate ways which are NOT allowed. */
+ if (is_motorway_like(w, 0) && is_motorway_like(&(new->way), 0) && old->way.item.type == type_ramp) {
+ if (dw < 0)
+ motorways_left++;
+ else
+ motorways_right++;
+ }
+ /* if !is_way_allowed */
+ } /* if is_way_allowed || !is_way_allowed */
+ if (w->flags & AF_ONEWAYMASK) {
+ /* count through_segments (even if they are not allowed) to check if we are at a complex T junction */
+ if (is_same_street2(new->way.name, new->way.name_systematic, w->name, w->name_systematic))
+ /* count segments belonging to the same street */
+ through_segments++;
+ else if ((!through_segment2 && (abs(angle_delta(angle_opposite(w->angle2), new->way.angle2)) < min_turn_limit))
+ || (through_segment2
+ && (abs(angle_delta(angle_opposite(w->angle2),
+ new->way.angle2)) < abs(angle_delta(angle_opposite(through_segment2->angle2), new->way.angle2))))) {
+ /* also count near-straight continuations of new (the through road may change names at the junction) */
+ if (!through_segment2)
+ through_segments++;
+ through_segment2 = w;
+ }
+ }
+ } /* if w is not a duplicate of way->next */
+ w = w->next;
+ } /* while w */
+ if ((abs(m.delta) >= min_turn_limit) && (through_segments >= 2)) {
+ /* If we have to make a considerable turn (min_turn_limit or more),
+ * check whether we are approaching a complex T junction from the "stem"
+ * (which would need an announcement).
+ * Complex means that the through road is a dual-carriageway road.
+ * This is the case only if at least 2 segments (including new) are one-way
+ * (regardless of direction) and have the same name as new or through_segment2.
+ * More than 2 such segments are possible e.g. where two physically separated
+ * lanes join.
+ * To find out if there is another carriageway, we need to analyze the previous
+ * maneuvers.
+ */
+ int hist_through_segments = 0;
+ int hist_dist = old->length; /* distance between previous and current maneuver */
+ ni = old;
+ while (ni && (hist_through_segments == 0) && (hist_dist <= junction_limit)) {
+ /* TODO: shouldn't the condition be (hist_through_segments < 2) to catch through segments that are slightly offset?? */
+ struct navigation_way *w = ni->way.next;
+ while (w) {
+ if (is_same_street2(new->way.name, new->way.name_systematic, w->name, w->name_systematic)
+ || (through_segment2
+ && is_same_street2(through_segment2->name, through_segment2->name_systematic, w->name, w->name_systematic)))
+ hist_through_segments++;
+ w = w->next;
+ }
+ ni = ni->prev;
+ if (ni)
+ hist_dist += ni->length;
+ }
+ if (hist_through_segments >= 2) {
+ /* Require at least 2 segments (there may be more than two in cases such as
+ * local-express lane systems or separate cycleways) */
+ ret=1;
+ m.is_complex_t_junction = 1;
+ r="yes: turning into multi-carriageway through-road of T junction";
+ }
+ }
+ }
+ if (!r && abs(m.delta) > 75) {
+ /* always make an announcement if you have to make a sharp turn */
+ r="yes: delta over 75";
+ ret=1;
+ } else if (!r && abs(m.delta) >= min_turn_limit) {
+ if ((m.new_cat >= maneuver_category(type_street_2_city)) && (m.num_similar_ways > 1)) {
+ /* When coming from street_2_* or higher category road, check if
+ * - we have multiple options of the same category and
+ * - we have to make a considerable turn (at least min_turn_limit)
+ * If both is the case, ANNOUNCE.
+ */
+ ret=1;
+ r="yes: more than one similar road and delta >= min_turn_limit";
+ }
+ }
+ if ((!r) && (m.num_options <= 1))
+ r="no: only one option permitted";
+ if (!r) {
+ if (is_motorway_like(&(old->way), 0) && (m.num_other_ways == 0) && (m.num_new_motorways > 1) && ((m.left > -90)
+ || (m.right < 90))) {
+ /* If we are at a motorway interchange, ANNOUNCE
+ * We are assuming a motorway interchange when old way and at least
+ * two possible ways are motorway-like and allowed.
+ * Additionally we require one way (other than the new way) within +/-90°.
+ * This prevents the rule from essentially announcing "don't do the U turn"
+ * at the beginning of a single-carriageway section, which is occasionally
+ * found on motorways.
+ * If any of the possible ways is neither motorway-like nor a ramp,
+ * we are probably on a trunk road with level crossings and not
+ * at a motorway interchange.
+ */
+ r="yes: motorway interchange (multiple motorways)";
+ m.merge_or_exit = mex_interchange;
+ ret=1;
+ } else if (is_motorway_like(&(old->way), 0) && is_motorway_like(&(new->way), 0) && (m.num_other_ways == 0)
+ && (!m.is_same_street)) {
+ /* Another sign that we are at a motorway interchange is if the street name changes
+ */
+ r="yes: motorway interchange (name changes)";
+ m.merge_or_exit = mex_interchange;
+ ret=1;
+ } else if ((new->way.item.type == type_ramp) && ((m.num_other_ways == 0) || (abs(m.delta) >= min_turn_limit))
+ && ((m.left > -90) || (m.right < 90))) {
+ /* Motorway ramps can be confusing, therefore we need to lower the bar for announcing a maneuver.
+ * When the new way is a ramp, we check for the following criteria:
+ * - All available ways are either motorway-like or ramps.
+ * This prevents this rule from firing in non-motorway settings, which is needed to avoid
+ * superfluous maneuvers when the minor road of a complex T junction is a ramp.
+ * - If the above is not met, the maneuver must involve a turn (min_turn_limit or more) to enter the ramp.
+ * - Additionally, there must be one way (other than the new way) within +/-90°.
+ * This prevents the rule from essentially announcing "don't do the U turn" where the ramps for
+ * two opposite directions merge.
+ * If the criteria are satisfied, announce.
+ */
+ r="yes: entering ramp";
+ ret=1;
+ }
+ }
+ if (!r) {
+ /* get the delta limit for checking for other streets. It is lower if the street has no other
+ streets of the same or higher category */
+ if (m.new_cat < m.old_cat)
+ dlim=80;
+ else
+ dlim=120;
+ /* if the street is really straight, the others might be closer to straight */
+ if (abs(m.delta) < 20)
+ dlim/=2;
+ /* if both old and new way have a category of 0, or if both ways and at least one other way are
+ * in the same category and no other ways are higher,
+ * dlim is 620/256 (roughly 2.5) times the delta of the maneuver */
+ if ((m.max_cat == m.new_cat && m.max_cat == m.old_cat) || (m.new_cat == 0 && m.old_cat == 0))
+ dlim=abs(m.delta)*620/256;
+ /* if both old and new way are in higher than highest encountered category,
+ * dlim is 128/256 times (i.e. one half) the delta of the maneuver */
+ else if (m.max_cat < m.new_cat && m.max_cat < m.old_cat)
+ dlim=abs(m.delta)*128/256;
+ /* if no other ways are within +/-dlim, the maneuver is unambiguous */
+ if (m.left >= -dlim || m.right <= dlim)
+ m.is_unambiguous = 0;
+ /* if another way is within +/-min_turn_limit and on the same side as new, the maneuver is ambiguous */
+ if (dc != m.delta) {
+ dbg(lvl_debug, "m.delta %d vs dc %d", m.delta, dc);
+ m.is_unambiguous=0;
+ }
+ if (!m.is_same_street && m.is_unambiguous < 1) { /* FIXME: why < 1? */
+ ret=1;
+ r="yes: different street and ambiguous";
+ }
+ /* we should have cat of the candidate within dlim
+ * instead of testing against max_cat.
+ * The highest cat road might be well outside dlim
+ */
+ else if (m.max_cat >= m.new_cat && m.is_unambiguous < 1) {
+ ret = 1;
+ r="yes: ambiguous because of other candidates within dlim";
+ } else
+ r="no: same street or unambiguous";
#ifdef DEBUG
- r=g_strdup_printf("%s: d %d left %d right %d dlim=%d cat old:%d new:%d max:%d unambiguous=%d same_street=%d", ret==1?"yes":"no", m.delta, m.left, m.right, dlim, m.old_cat, m.new_cat, m.max_cat, m.is_unambiguous, m.is_same_street);
+ r=g_strdup_printf("%s: d %d left %d right %d dlim=%d cat old:%d new:%d max:%d unambiguous=%d same_street=%d",
+ ret==1?"yes":"no", m.delta, m.left, m.right, dlim, m.old_cat, m.new_cat, m.max_cat, m.is_unambiguous, m.is_same_street);
#endif
- }
-
- if (m.merge_or_exit == mex_none) {
- if (old->way.item.type == type_ramp && is_motorway_like(&(new->way), 0)) {
- if (motorways_left)
- m.merge_or_exit = mex_merge_left;
- else if (motorways_right)
- m.merge_or_exit = mex_merge_right;
- /* if there are no motorways on either side, we are not merging
- * (more likely the start of a motorway) */
-
- if (m.merge_or_exit != mex_none) {
- ret=1;
- if (!r)
- r = "yes: merging onto motorway-like road";
- }
- } else if (is_motorway_like(&(old->way), 1) && (new->way.item.type == type_ramp)) {
- /* Detect interchanges - if:
- * - we're entering a ramp,
- * - we're coming from a motorway-like road (directly or via ramps),
- * - the route is taking us onto another motorway-like road and
- * - none of the ways in between connects to any non-motorway roads,
- * set m.merge_or_exit = mex_interchange.
- * The last condition is to prevent direction changes (i.e. exit motorway and take
- * access ramp for opposite direction) from being misinterpreted as interchanges. */
- ni = old;
- coming_from_motorway = 1;
- while (coming_from_motorway && ni && (ni->way.item.type == type_ramp)) {
- w = &(ni->way);
- while (coming_from_motorway && w) {
- coming_from_motorway = is_motorway_like(w, 1);
- w = w->next;
- }
- ni = ni->prev;
- }
- if (ni && coming_from_motorway)
- coming_from_motorway = is_motorway_like(&(ni->way), 0);
- ni = new->next;
- route_leaves_motorway = !coming_from_motorway;
- while (!route_leaves_motorway && ni && (ni->way.item.type == type_ramp)) {
- w = &(ni->way);
- while (!route_leaves_motorway && w) {
- route_leaves_motorway = !is_motorway_like(w, 1);
- w = w->next;
- }
- ni = ni->next;
- }
- if (ni && !route_leaves_motorway && is_motorway_like(&(ni->way), 0))
- m.merge_or_exit = mex_interchange;
- else if (is_motorway_like(&(old->way), 0) || (coming_from_motorway && new->way.exit_ref)) {
- if (motorways_left && (m.left > -90))
- m.merge_or_exit = mex_exit_right;
- else if (motorways_right && (m.right < 90))
- m.merge_or_exit = mex_exit_left;
- /* if there are no motorways within +/-90 degrees on either side, this is not an exit
- * (more likely the end of a motorway) */
- }
-
- if (is_motorway_like(&(old->way), 0) && (m.merge_or_exit != mex_none)) {
- ret=1;
- if (!r)
- r = "yes: leaving motorway-like road";
- }
- }
- }
-
- if (ret) {
- *maneuver = g_new(struct navigation_maneuver, 1);
- memcpy(*maneuver, &m, sizeof(struct navigation_maneuver));
- }
- if (r)
- dbg(lvl_debug, "%s %s %s -> %s %s %s: %s, delta=%i, merge_or_exit=%i\n", item_to_name(old->way.item.type), old->way.name_systematic, old->way.name, item_to_name(new->way.item.type), new->way.name_systematic, new->way.name, r, m.delta, m.merge_or_exit);
- return ret;
+ }
+
+ if (m.merge_or_exit == mex_none) {
+ if (old->way.item.type == type_ramp && is_motorway_like(&(new->way), 0)) {
+ if (motorways_left)
+ m.merge_or_exit = mex_merge_left;
+ else if (motorways_right)
+ m.merge_or_exit = mex_merge_right;
+ /* if there are no motorways on either side, we are not merging
+ * (more likely the start of a motorway) */
+
+ if (m.merge_or_exit != mex_none) {
+ ret=1;
+ if (!r)
+ r = "yes: merging onto motorway-like road";
+ }
+ } else if (is_motorway_like(&(old->way), 1) && (new->way.item.type == type_ramp)) {
+ /* Detect interchanges - if:
+ * - we're entering a ramp,
+ * - we're coming from a motorway-like road (directly or via ramps),
+ * - the route is taking us onto another motorway-like road and
+ * - none of the ways in between connects to any non-motorway roads,
+ * set m.merge_or_exit = mex_interchange.
+ * The last condition is to prevent direction changes (i.e. exit motorway and take
+ * access ramp for opposite direction) from being misinterpreted as interchanges. */
+ ni = old;
+ coming_from_motorway = 1;
+ while (coming_from_motorway && ni && (ni->way.item.type == type_ramp)) {
+ w = &(ni->way);
+ while (coming_from_motorway && w) {
+ coming_from_motorway = is_motorway_like(w, 1);
+ w = w->next;
+ }
+ ni = ni->prev;
+ }
+ if (ni && coming_from_motorway)
+ coming_from_motorway = is_motorway_like(&(ni->way), 0);
+ ni = new->next;
+ route_leaves_motorway = !coming_from_motorway;
+ while (!route_leaves_motorway && ni && (ni->way.item.type == type_ramp)) {
+ w = &(ni->way);
+ while (!route_leaves_motorway && w) {
+ route_leaves_motorway = !is_motorway_like(w, 1);
+ w = w->next;
+ }
+ ni = ni->next;
+ }
+ if (ni && !route_leaves_motorway && is_motorway_like(&(ni->way), 0))
+ m.merge_or_exit = mex_interchange;
+ else if (is_motorway_like(&(old->way), 0) || (coming_from_motorway && new->way.exit_ref)) {
+ if (motorways_left && (m.left > -90))
+ m.merge_or_exit = mex_exit_right;
+ else if (motorways_right && (m.right < 90))
+ m.merge_or_exit = mex_exit_left;
+ /* if there are no motorways within +/-90 degrees on either side, this is not an exit
+ * (more likely the end of a motorway) */
+ }
+
+ if (is_motorway_like(&(old->way), 0) && (m.merge_or_exit != mex_none)) {
+ ret=1;
+ if (!r)
+ r = "yes: leaving motorway-like road";
+ }
+ }
+ }
+
+ if (ret) {
+ *maneuver = g_new(struct navigation_maneuver, 1);
+ memcpy(*maneuver, &m, sizeof(struct navigation_maneuver));
+ }
+ if (r)
+ dbg(lvl_debug, "%s %s %s -> %s %s %s: %s, delta=%i, merge_or_exit=%i", item_to_name(old->way.item.type),
+ old->way.name_systematic, old->way.name, item_to_name(new->way.item.type), new->way.name_systematic, new->way.name, r,
+ m.delta, m.merge_or_exit);
+ return ret;
}
/**
@@ -2354,16 +2268,14 @@ maneuver_required2 (struct navigation *nav, struct navigation_itm *old, struct n
* are outside of their specified range, the result is undefined.
*/
static int adjust_delta(int delta, int reference) {
- if ((delta >= 0) && (delta - reference) > 180) {
- dbg(lvl_debug,"adjusting delta from %d to %d\n", delta, delta - 360);
- return delta - 360;
- }
- else if ((delta <= 0) && (reference - delta) > 180) {
- dbg(lvl_debug,"adjusting delta from %d to %d\n", delta, delta + 360);
- return delta + 360;
- }
- else
- return delta;
+ if ((delta >= 0) && (delta - reference) > 180) {
+ dbg(lvl_debug,"adjusting delta from %d to %d", delta, delta - 360);
+ return delta - 360;
+ } else if ((delta <= 0) && (reference - delta) > 180) {
+ dbg(lvl_debug,"adjusting delta from %d to %d", delta, delta + 360);
+ return delta + 360;
+ } else
+ return delta;
}
/**
@@ -2402,263 +2314,268 @@ static int adjust_delta(int delta, int reference) {
* this function
* @param itm The navigation item for the maneuver to exit the roundabout
*/
-static void navigation_analyze_roundabout(struct navigation *this_, struct navigation_command *cmd, struct navigation_itm *itm) {
- enum item_type r = type_none, l = type_none;
- int len = 0; /* length of roundabout segment */
- int roundabout_length; /* estimated total length of roundabout */
- int angle = 0;
- int entry_tangent; /* tangent of the roundabout at entry point, against direction of route */
- int exit_tangent; /* tangent of the roundabout at exit point, in direction of route */
- int entry_road_angle, exit_road_angle; /* angles before and after approach segments */
- struct navigation_itm *itm2; /* items before itm to examine, up to first roundabout segment on route */
- struct navigation_itm *itm3; /* items before itm2 and after itm to examine */
- struct navigation_way *w; /* continuation of the roundabout after we leave it */
- struct navigation_way *w2; /* segment of the roundabout leading to the point at which we enter it */
- int dtsir = 0; /* delta to stay in roundabout */
- int d, dmax = 0; /* when examining deltas of roundabout approaches, current and maximum encountered */
- int delta1, delta2, delta3; /* for roundabout delta calculated with different approaches */
- int dist_left; /* when examining ways around the roundabout to a certain threshold, the distance we have left to go */
- int central_angle; /* approximate central angle for the roundabout arc that is part of the route */
- int abort; /* whether a (complex) criterion for aborting a loop has been met */
-
- /* Find continuation of roundabout after the exit. Don't simply use itm->way.next here, it will break
- * if a node in the roundabout is shared by more than one way */
- w = itm->way.next;
- while (w && !(w->flags & AF_ROUNDABOUT))
- w = w->next;
- if (w) {
- /* When exiting a roundabout, w should never be null, thus this
- * code will always be executed. Checking for the condition anyway ensures
- * that botched map data (roundabout ending with nowhere else to go) will not
- * cause a crash. For the same reason we're using dtsir with a default value of 0.
- */
-
- dtsir = angle_delta(itm->prev->angle_end, w->angle2);
- dbg(lvl_debug,"delta to stay in roundabout %d\n", dtsir);
-
- exit_tangent = angle_median(itm->prev->angle_end, w->angle2);
- dbg(lvl_debug,"exit %d median from %d, %d\n", exit_tangent, itm->prev->angle_end, w->angle2);
-
- /* Move back to where we enter the roundabout, calculate length in roundabout */
- itm2=itm;
- while (itm2->prev && (itm2->prev->way.flags & AF_ROUNDABOUT)) {
- itm2=itm2->prev;
- len+=itm2->length;
- angle=itm2->angle_end;
- }
-
- /* Find the segment of the roundabout leading up to the point at which we enter it. Again, don't simply
- * use itm2->way.next here, it will break if a node in the roundabout is shared by more than one way */
- w2 = itm2->way.next;
- while (w2 && !(w2->flags & AF_ROUNDABOUT))
- w2 = w2->next;
-
- /* Calculate entry angle */
- if (itm2 && w2) {
- entry_tangent = angle_median(angle_opposite(itm2->way.angle2), w2->angle2);
- dbg(lvl_debug, "entry %d median from %d (%d), %d\n", entry_tangent, angle_opposite(itm2->way.angle2), itm2->way.angle2, itm2->way.next->angle2);
- } else {
- entry_tangent = angle_opposite(angle);
- } /* endif itm2 && w2 */
- dbg(lvl_debug, "entry %d exit %d\n", entry_tangent, exit_tangent);
-
- delta2 = angle_delta(entry_tangent, exit_tangent);
- dbg(lvl_debug, "delta2 %d\n", delta2);
-
- if (itm2->prev) {
- /* If there are V-shaped approach segments and we are turning around or making a sharp turn,
- * delta1 may point in the wrong direction, thus we need adjust_delta() to correct this. */
- delta1 = adjust_delta(angle_delta(itm2->prev->angle_end, itm->way.angle2), delta2);
-
- /* Now try to figure out the error range for delta1. Errors are caused by turns in the approach segments
- * just before the roundabout. We use the last segment before the approach as a reference.
- * We assume the approach to begin when one of the following is true:
- * - a way turns into a ramp
- * - a way turns into a one-way road
- * - a certain distance from the roundabout, proportional to its circumference, is exceeded
- * Simply comparing bearings at these points may cause confusion with certain road layouts (namely
- * S-shaped dual-carriageway roads), hence we examine the entire approach segment and take the largest
- * delta (relative to the end of the approach segment) which we encounter.
- * This is done for both ends of the roundabout.
- */
-
- /* Approximate roundabout circumference based on len and approximate central angle of route segment.
- * The central angle is approximated using the unweighted average of delta1 and delta2,
- * which is somewhat crude but sufficient for our purposes. */
- central_angle = abs((delta1 + delta2) / 2 + ((cmd->delta < dtsir) ? 180 : -180));
- if (central_angle)
- roundabout_length = len * 360 / central_angle;
- else {
- dbg(lvl_error,"central_angle in roundabout_length computation lead to divide by zero (delta1 = %d, delta2 = %d, cmd->delta = %d, dtsir = %d, len = %d)",delta1,delta2,cmd->delta,dtsir,len);
- roundabout_length = len;
- }
- dbg(lvl_debug,"roundabout_length = %dm (for central_angle = %d degrees)\n", roundabout_length, central_angle);
-
- /* in the case of separate carriageways, approach roads become hard to identify, thus we keep a cap on distance.
- * Currently this is at most half the length of the roundabout, which has worked well in tests but can be tweaked
- * to further improve results. */
- dist_left = roundabout_length / 2;
- dbg(lvl_debug,"examining roads for up to %dm\n", dist_left);
-
- /* examine items before roundabout */
- itm3 = itm2->prev; /* last segment before roundabout */
- abort = 0;
- while (itm3->prev) {
- if ((itm3->next && is_ramp(&(itm3->next->way)) && !is_ramp(&(itm3->way))) || !(itm3->way.flags & AF_ONEWAYMASK)) {
- dbg(lvl_debug,"items before roundabout: break because ramp or oneway ends, %dm left\n", dist_left);
- dist_left = 0; /* to make sure we don't examine the following way in depth */
- break;
- }
- if (dist_left <= itm3->length) {
- dbg(lvl_debug,"items before roundabout: maximum distance reached, %dm left, item length %dm\n", dist_left, itm3->length);
- break;
- }
- d = navigation_way_get_max_delta(&(itm3->way), map_projection(this_->map), itm2->prev->angle_end, dist_left, -1);
- if ((d != invalid_angle) && (abs(d) > abs(dmax)))
- dmax = d;
- w2 = itm3->way.next;
- while (w2) {
- /* Stop examining ways at a turn maneuver (more than one way allowed and route does not follow straightest path) */
- if (is_way_allowed(this_, w2, 0)
- && (abs(angle_delta(angle_opposite(w2->angle2), itm3->way.angle2)) <= abs(angle_delta(itm3->prev->angle_end, itm3->way.angle2)))) {
- /* FIXME: comparing angles probably does not work well for near-equal angles */
- abort = 1;
- break;
- }
- w2 = w2->next;
- }
- if (abort) {
- dbg(lvl_debug,"items before roundabout: break because of potential turn maneuver, %dm left\n", dist_left);
- dist_left = itm3->length;
- break;
- }
- dist_left -= itm3->length;
- itm3 = itm3->prev;
- }
- if (dist_left == 0) {
- d = angle_delta(itm2->prev->angle_end, itm3->angle_end);
- } else if (dist_left < itm3->length) {
- d = navigation_way_get_max_delta(&(itm3->way), map_projection(this_->map), itm2->prev->angle_end, dist_left, -1);
- } else {
- /* not enough objects in navigation map, use most distant one
- * - or dist_left == itm3->length, this saves a few CPU cycles over the above */
- d = angle_delta(itm2->prev->angle_end, itm3->way.angle2);
- }
- if ((d != invalid_angle) && (abs(d) > abs(dmax)))
- dmax = d;
- entry_road_angle = (itm2->prev->angle_end + dmax) % 360;
- dbg(lvl_debug,"entry_road_angle %d (%d + %d)\n", entry_road_angle, itm2->prev->angle_end, dmax);
-
- /* examine items after roundabout */
- dmax = 0;
- dist_left = roundabout_length / 2;
- itm3 = itm; /* first segment after roundabout */
- abort = 0;
- while (itm3->next) {
- if ((itm3->prev && is_ramp(&(itm3->prev->way)) && !is_ramp(&(itm3->way))) || !(itm3->way.flags & AF_ONEWAYMASK)) {
- dbg(lvl_debug,"items after roundabout: break because ramp or oneway ends, %dm left\n", dist_left);
- dist_left = 0; /* to make sure we don't examine the following way in depth */
- break;
- }
- if (dist_left <= itm3->length) {
- dbg(lvl_debug,"items after roundabout: maximum distance reached, %dm left, item length %dm\n", dist_left, itm3->length);
- break;
- }
- d = navigation_way_get_max_delta(&(itm3->way), map_projection(this_->map), itm->way.angle2, dist_left, 1);
- if ((d != invalid_angle) && (abs(d) > abs(dmax)))
- dmax = d;
- w2 = itm3->next->way.next;
- while (w2) {
- /* Stop examining ways at a turn maneuver (more than one way allowed and route does not follow straightest path) */
- if (is_way_allowed(this_, w2, 0)
- && (abs(angle_delta(itm3->angle_end, w2->angle2)) <= abs(angle_delta(itm3->angle_end, itm3->next->way.angle2)))) {
- /* FIXME: comparing angles probably does not work well for near-equal angles */
- abort = 1;
- break;
- }
- w2 = w2->next;
- }
- if (abort) {
- dbg(lvl_debug,"items after roundabout: break because of potential turn maneuver, %dm left\n", dist_left);
- dist_left = itm3->length;
- break;
- }
- dist_left -= itm3->length;
- itm3 = itm3->next;
- }
- if (dist_left == 0) {
- d = angle_delta(itm->way.angle2, itm3->way.angle2);
- } else if (dist_left < itm3->length) {
- d = navigation_way_get_max_delta(&(itm3->way), map_projection(this_->map), itm->way.angle2, dist_left, 1);
- } else {
- /* not enough objects in navigation map, use most distant one
- * - or dist_left == itm3->length, this saves a few CPU cycles over the above */
- d = angle_delta(itm->way.angle2, itm3->angle_end);
- }
- if ((d != invalid_angle) && (abs(d) > abs(dmax)))
- dmax = d;
-
- exit_road_angle = (itm->way.angle2 + dmax) % 360;
- dbg(lvl_debug,"exit_road_angle %d (%d + %d)\n", exit_road_angle, itm->way.angle2, dmax);
-
- dbg(lvl_debug,"delta1 %d\n", delta1);
-
- delta3 = adjust_delta(angle_delta(entry_road_angle, exit_road_angle), delta2);
- dbg(lvl_debug,"delta3 %d\n", delta3);
-
- cmd->roundabout_delta = delta3;
- dbg(lvl_debug,"roundabout_delta %d\n", cmd->roundabout_delta);
- } else {
- /* we don't know where we entered the roundabout, so we can't calculate delta1 */
- cmd->roundabout_delta = delta2;
- } /* endif itm2->prev */
- cmd->length=len+roundabout_extra_length;
- } /* if w */
-
- /* set cmd->maneuver->type */
- switch (((180 + 22) - cmd->roundabout_delta) / 45) {
- case 0:
- case 1:
- r = type_nav_roundabout_r1;
- l = type_nav_roundabout_l7;
- break;
- case 2:
- r = type_nav_roundabout_r2;
- l = type_nav_roundabout_l6;
- break;
- case 3:
- r = type_nav_roundabout_r3;
- l = type_nav_roundabout_l5;
- break;
- case 4:
- r = type_nav_roundabout_r4;
- l = type_nav_roundabout_l4;
- break;
- case 5:
- r = type_nav_roundabout_r5;
- l = type_nav_roundabout_l3;
- break;
- case 6:
- r = type_nav_roundabout_r6;
- l = type_nav_roundabout_l2;
- break;
- case 7:
- r = type_nav_roundabout_r7;
- l = type_nav_roundabout_l1;
- break;
- case 8:
- r = type_nav_roundabout_r8;
- l = type_nav_roundabout_l8;
- break;
- }
- dbg(lvl_debug,"delta %d\n", cmd->delta);
- /* if delta to leave the roundabout (cmd->delta) is less than delta to stay in roundabout (dtsir),
- * we're exiting to the left, so we're probably in a clockwise roundabout, and vice versa */
- if (cmd->delta < dtsir)
- cmd->maneuver->type = l;
- else
- cmd->maneuver->type = r;
- dbg(lvl_debug,"type %s\n", item_to_name(cmd->maneuver->type));
+static void navigation_analyze_roundabout(struct navigation *this_, struct navigation_command *cmd,
+ struct navigation_itm *itm) {
+ enum item_type r = type_none, l = type_none;
+ int len = 0; /* length of roundabout segment */
+ int roundabout_length; /* estimated total length of roundabout */
+ int angle = 0;
+ int entry_tangent; /* tangent of the roundabout at entry point, against direction of route */
+ int exit_tangent; /* tangent of the roundabout at exit point, in direction of route */
+ int entry_road_angle, exit_road_angle; /* angles before and after approach segments */
+ struct navigation_itm *itm2; /* items before itm to examine, up to first roundabout segment on route */
+ struct navigation_itm *itm3; /* items before itm2 and after itm to examine */
+ struct navigation_way *w; /* continuation of the roundabout after we leave it */
+ struct navigation_way *w2; /* segment of the roundabout leading to the point at which we enter it */
+ int dtsir = 0; /* delta to stay in roundabout */
+ int d, dmax = 0; /* when examining deltas of roundabout approaches, current and maximum encountered */
+ int delta1, delta2, delta3; /* for roundabout delta calculated with different approaches */
+ int dist_left; /* when examining ways around the roundabout to a certain threshold, the distance we have left to go */
+ int central_angle; /* approximate central angle for the roundabout arc that is part of the route */
+ int abort; /* whether a (complex) criterion for aborting a loop has been met */
+
+ /* Find continuation of roundabout after the exit. Don't simply use itm->way.next here, it will break
+ * if a node in the roundabout is shared by more than one way */
+ w = itm->way.next;
+ while (w && !(w->flags & AF_ROUNDABOUT))
+ w = w->next;
+ if (w) {
+ /* When exiting a roundabout, w should never be null, thus this
+ * code will always be executed. Checking for the condition anyway ensures
+ * that botched map data (roundabout ending with nowhere else to go) will not
+ * cause a crash. For the same reason we're using dtsir with a default value of 0.
+ */
+
+ dtsir = angle_delta(itm->prev->angle_end, w->angle2);
+ dbg(lvl_debug,"delta to stay in roundabout %d", dtsir);
+
+ exit_tangent = angle_median(itm->prev->angle_end, w->angle2);
+ dbg(lvl_debug,"exit %d median from %d, %d", exit_tangent, itm->prev->angle_end, w->angle2);
+
+ /* Move back to where we enter the roundabout, calculate length in roundabout */
+ itm2=itm;
+ while (itm2->prev && (itm2->prev->way.flags & AF_ROUNDABOUT)) {
+ itm2=itm2->prev;
+ len+=itm2->length;
+ angle=itm2->angle_end;
+ }
+
+ /* Find the segment of the roundabout leading up to the point at which we enter it. Again, don't simply
+ * use itm2->way.next here, it will break if a node in the roundabout is shared by more than one way */
+ w2 = itm2->way.next;
+ while (w2 && !(w2->flags & AF_ROUNDABOUT))
+ w2 = w2->next;
+
+ /* Calculate entry angle */
+ if (itm2 && w2) {
+ entry_tangent = angle_median(angle_opposite(itm2->way.angle2), w2->angle2);
+ dbg(lvl_debug, "entry %d median from %d (%d), %d", entry_tangent, angle_opposite(itm2->way.angle2), itm2->way.angle2,
+ itm2->way.next->angle2);
+ } else {
+ entry_tangent = angle_opposite(angle);
+ } /* endif itm2 && w2 */
+ dbg(lvl_debug, "entry %d exit %d", entry_tangent, exit_tangent);
+
+ delta2 = angle_delta(entry_tangent, exit_tangent);
+ dbg(lvl_debug, "delta2 %d", delta2);
+
+ if (itm2->prev) {
+ /* If there are V-shaped approach segments and we are turning around or making a sharp turn,
+ * delta1 may point in the wrong direction, thus we need adjust_delta() to correct this. */
+ delta1 = adjust_delta(angle_delta(itm2->prev->angle_end, itm->way.angle2), delta2);
+
+ /* Now try to figure out the error range for delta1. Errors are caused by turns in the approach segments
+ * just before the roundabout. We use the last segment before the approach as a reference.
+ * We assume the approach to begin when one of the following is true:
+ * - a way turns into a ramp
+ * - a way turns into a one-way road
+ * - a certain distance from the roundabout, proportional to its circumference, is exceeded
+ * Simply comparing bearings at these points may cause confusion with certain road layouts (namely
+ * S-shaped dual-carriageway roads), hence we examine the entire approach segment and take the largest
+ * delta (relative to the end of the approach segment) which we encounter.
+ * This is done for both ends of the roundabout.
+ */
+
+ /* Approximate roundabout circumference based on len and approximate central angle of route segment.
+ * The central angle is approximated using the unweighted average of delta1 and delta2,
+ * which is somewhat crude but sufficient for our purposes. */
+ central_angle = abs((delta1 + delta2) / 2 + ((cmd->delta < dtsir) ? 180 : -180));
+ if (central_angle)
+ roundabout_length = len * 360 / central_angle;
+ else {
+ dbg(lvl_error,
+ "central_angle in roundabout_length computation lead to divide by zero (delta1 = %d, delta2 = %d, cmd->delta = %d, dtsir = %d, len = %d)",
+ delta1,delta2,cmd->delta,dtsir,len);
+ roundabout_length = len;
+ }
+ dbg(lvl_debug,"roundabout_length = %dm (for central_angle = %d degrees)", roundabout_length, central_angle);
+
+ /* in the case of separate carriageways, approach roads become hard to identify, thus we keep a cap on distance.
+ * Currently this is at most half the length of the roundabout, which has worked well in tests but can be tweaked
+ * to further improve results. */
+ dist_left = roundabout_length / 2;
+ dbg(lvl_debug,"examining roads for up to %dm", dist_left);
+
+ /* examine items before roundabout */
+ itm3 = itm2->prev; /* last segment before roundabout */
+ abort = 0;
+ while (itm3->prev) {
+ if ((itm3->next && is_ramp(&(itm3->next->way)) && !is_ramp(&(itm3->way))) || !(itm3->way.flags & AF_ONEWAYMASK)) {
+ dbg(lvl_debug,"items before roundabout: break because ramp or oneway ends, %dm left", dist_left);
+ dist_left = 0; /* to make sure we don't examine the following way in depth */
+ break;
+ }
+ if (dist_left <= itm3->length) {
+ dbg(lvl_debug,"items before roundabout: maximum distance reached, %dm left, item length %dm", dist_left, itm3->length);
+ break;
+ }
+ d = navigation_way_get_max_delta(&(itm3->way), map_projection(this_->map), itm2->prev->angle_end, dist_left, -1);
+ if ((d != invalid_angle) && (abs(d) > abs(dmax)))
+ dmax = d;
+ w2 = itm3->way.next;
+ while (w2) {
+ /* Stop examining ways at a turn maneuver (more than one way allowed and route does not follow straightest path) */
+ if (is_way_allowed(this_, w2, 0)
+ && (abs(angle_delta(angle_opposite(w2->angle2), itm3->way.angle2)) <= abs(angle_delta(itm3->prev->angle_end,
+ itm3->way.angle2)))) {
+ /* FIXME: comparing angles probably does not work well for near-equal angles */
+ abort = 1;
+ break;
+ }
+ w2 = w2->next;
+ }
+ if (abort) {
+ dbg(lvl_debug,"items before roundabout: break because of potential turn maneuver, %dm left", dist_left);
+ dist_left = itm3->length;
+ break;
+ }
+ dist_left -= itm3->length;
+ itm3 = itm3->prev;
+ }
+ if (dist_left == 0) {
+ d = angle_delta(itm2->prev->angle_end, itm3->angle_end);
+ } else if (dist_left < itm3->length) {
+ d = navigation_way_get_max_delta(&(itm3->way), map_projection(this_->map), itm2->prev->angle_end, dist_left, -1);
+ } else {
+ /* not enough objects in navigation map, use most distant one
+ * - or dist_left == itm3->length, this saves a few CPU cycles over the above */
+ d = angle_delta(itm2->prev->angle_end, itm3->way.angle2);
+ }
+ if ((d != invalid_angle) && (abs(d) > abs(dmax)))
+ dmax = d;
+ entry_road_angle = (itm2->prev->angle_end + dmax) % 360;
+ dbg(lvl_debug,"entry_road_angle %d (%d + %d)", entry_road_angle, itm2->prev->angle_end, dmax);
+
+ /* examine items after roundabout */
+ dmax = 0;
+ dist_left = roundabout_length / 2;
+ itm3 = itm; /* first segment after roundabout */
+ abort = 0;
+ while (itm3->next) {
+ if ((itm3->prev && is_ramp(&(itm3->prev->way)) && !is_ramp(&(itm3->way))) || !(itm3->way.flags & AF_ONEWAYMASK)) {
+ dbg(lvl_debug,"items after roundabout: break because ramp or oneway ends, %dm left", dist_left);
+ dist_left = 0; /* to make sure we don't examine the following way in depth */
+ break;
+ }
+ if (dist_left <= itm3->length) {
+ dbg(lvl_debug,"items after roundabout: maximum distance reached, %dm left, item length %dm", dist_left, itm3->length);
+ break;
+ }
+ d = navigation_way_get_max_delta(&(itm3->way), map_projection(this_->map), itm->way.angle2, dist_left, 1);
+ if ((d != invalid_angle) && (abs(d) > abs(dmax)))
+ dmax = d;
+ w2 = itm3->next->way.next;
+ while (w2) {
+ /* Stop examining ways at a turn maneuver (more than one way allowed and route does not follow straightest path) */
+ if (is_way_allowed(this_, w2, 0)
+ && (abs(angle_delta(itm3->angle_end, w2->angle2)) <= abs(angle_delta(itm3->angle_end, itm3->next->way.angle2)))) {
+ /* FIXME: comparing angles probably does not work well for near-equal angles */
+ abort = 1;
+ break;
+ }
+ w2 = w2->next;
+ }
+ if (abort) {
+ dbg(lvl_debug,"items after roundabout: break because of potential turn maneuver, %dm left", dist_left);
+ dist_left = itm3->length;
+ break;
+ }
+ dist_left -= itm3->length;
+ itm3 = itm3->next;
+ }
+ if (dist_left == 0) {
+ d = angle_delta(itm->way.angle2, itm3->way.angle2);
+ } else if (dist_left < itm3->length) {
+ d = navigation_way_get_max_delta(&(itm3->way), map_projection(this_->map), itm->way.angle2, dist_left, 1);
+ } else {
+ /* not enough objects in navigation map, use most distant one
+ * - or dist_left == itm3->length, this saves a few CPU cycles over the above */
+ d = angle_delta(itm->way.angle2, itm3->angle_end);
+ }
+ if ((d != invalid_angle) && (abs(d) > abs(dmax)))
+ dmax = d;
+
+ exit_road_angle = (itm->way.angle2 + dmax) % 360;
+ dbg(lvl_debug,"exit_road_angle %d (%d + %d)", exit_road_angle, itm->way.angle2, dmax);
+
+ dbg(lvl_debug,"delta1 %d", delta1);
+
+ delta3 = adjust_delta(angle_delta(entry_road_angle, exit_road_angle), delta2);
+ dbg(lvl_debug,"delta3 %d", delta3);
+
+ cmd->roundabout_delta = delta3;
+ dbg(lvl_debug,"roundabout_delta %d", cmd->roundabout_delta);
+ } else {
+ /* we don't know where we entered the roundabout, so we can't calculate delta1 */
+ cmd->roundabout_delta = delta2;
+ } /* endif itm2->prev */
+ cmd->length=len+roundabout_extra_length;
+ } /* if w */
+
+ /* set cmd->maneuver->type */
+ switch (((180 + 22) - cmd->roundabout_delta) / 45) {
+ case 0:
+ case 1:
+ r = type_nav_roundabout_r1;
+ l = type_nav_roundabout_l7;
+ break;
+ case 2:
+ r = type_nav_roundabout_r2;
+ l = type_nav_roundabout_l6;
+ break;
+ case 3:
+ r = type_nav_roundabout_r3;
+ l = type_nav_roundabout_l5;
+ break;
+ case 4:
+ r = type_nav_roundabout_r4;
+ l = type_nav_roundabout_l4;
+ break;
+ case 5:
+ r = type_nav_roundabout_r5;
+ l = type_nav_roundabout_l3;
+ break;
+ case 6:
+ r = type_nav_roundabout_r6;
+ l = type_nav_roundabout_l2;
+ break;
+ case 7:
+ r = type_nav_roundabout_r7;
+ l = type_nav_roundabout_l1;
+ break;
+ case 8:
+ r = type_nav_roundabout_r8;
+ l = type_nav_roundabout_l8;
+ break;
+ }
+ dbg(lvl_debug,"delta %d", cmd->delta);
+ /* if delta to leave the roundabout (cmd->delta) is less than delta to stay in roundabout (dtsir),
+ * we're exiting to the left, so we're probably in a clockwise roundabout, and vice versa */
+ if (cmd->delta < dtsir)
+ cmd->maneuver->type = l;
+ else
+ cmd->maneuver->type = r;
+ dbg(lvl_debug,"type %s", item_to_name(cmd->maneuver->type));
}
@@ -2677,186 +2594,183 @@ static void navigation_analyze_roundabout(struct navigation *this_, struct navig
*
* @return The new command
*/
-static struct navigation_command *
-command_new(struct navigation *this_, struct navigation_itm *itm, struct navigation_maneuver *maneuver)
-{
- struct navigation_command *ret=g_new0(struct navigation_command, 1);
- struct navigation_way *w; /* the way in which to turn. */
- int more_ways_for_strength = 0; /* Counts the number of ways of the current node that turn
+static struct navigation_command *command_new(struct navigation *this_, struct navigation_itm *itm,
+ struct navigation_maneuver *maneuver) {
+ struct navigation_command *ret=g_new0(struct navigation_command, 1);
+ struct navigation_way *w; /* the way in which to turn. */
+ int more_ways_for_strength = 0; /* Counts the number of ways of the current node that turn
to the same direction as the route way. Strengthening criterion. */
- int turn_no_of_route_way = 0; /* The number of the route way of all ways that turn to the same direction.
+ int turn_no_of_route_way = 0; /* The number of the route way of all ways that turn to the same direction.
Count direction from abs(0 degree) up to abs(180 degree). Strengthening criterion. */
- dbg(lvl_debug,"enter this_=%p itm=%p maneuver=%p delta=%d\n", this_, itm, maneuver, maneuver->delta);
- ret->maneuver = maneuver;
- ret->delta=maneuver->delta;
- ret->itm=itm;
-
- /* Possible maneuver types:
- * nav_none (default, change wherever we encounter it – unless the maneuver is a merge, which has only merge_or_exit)
- * nav_straight (set below)
- * nav_keep_{left|right} (set below)
- * nav_{right|left}_{1..3} (set below)
- * nav_turnaround (TODO: when we have a U turn without known direction? Needs full implementation!)
- * nav_turnaround_{left|right} (set below)
- * nav_roundabout_{r|l}{1..8} (set below, special handling)
- * nav_exit_{left|right} (do not set here)
- * nav_merge_{left|right} (do not set here)
- * nav_destination (if this is set, leave it)
- * nav_position (do not set here)
- */
-
- if (ret->maneuver->type != type_nav_destination) {
- /* FIXME: this will not catch cases in which entry and exit share the same node and we just *touch* the roundabout */
- if (itm && itm->prev && !(itm->way.flags & AF_ROUNDABOUT) && (itm->prev->way.flags & AF_ROUNDABOUT)) {
- navigation_analyze_roundabout(this_, ret, itm);
- } else {
- /* non-roundabout turn --> */
-
- /* set ret->maneuver->type */
- if (abs(ret->delta) >= min_turn_limit) {
-
- /* Strengthening criterion: If there are more ways in the same direction, in which the vehicle can turn,
- the announcement shall be more precise. I.e. the strengthening is dependent on which of the possible ways
- the route turn shall be. So, with the selection of one of the possible ways a certain turn angle pattern
- becomes active.
- Second criterion: the turn angle of the route way defines the strengthening of the announcement according
- to the pattern. */
- w = itm->next->way.next;
-
- if (angle_delta(itm->next->way.angle2,itm->angle_end) < 0) { /* next turns or bends left */
- while (w) {
- if (angle_delta(w->angle2,itm->angle_end) < -min_turn_limit) {
- more_ways_for_strength++; /* there is an additional way that also turns left.
+ dbg(lvl_debug,"enter this_=%p itm=%p maneuver=%p delta=%d", this_, itm, maneuver, maneuver->delta);
+ ret->maneuver = maneuver;
+ ret->delta=maneuver->delta;
+ ret->itm=itm;
+
+ /* Possible maneuver types:
+ * nav_none (default, change wherever we encounter it – unless the maneuver is a merge, which has only merge_or_exit)
+ * nav_straight (set below)
+ * nav_keep_{left|right} (set below)
+ * nav_{right|left}_{1..3} (set below)
+ * nav_turnaround (TODO: when we have a U turn without known direction? Needs full implementation!)
+ * nav_turnaround_{left|right} (set below)
+ * nav_roundabout_{r|l}{1..8} (set below, special handling)
+ * nav_exit_{left|right} (do not set here)
+ * nav_merge_{left|right} (do not set here)
+ * nav_destination (if this is set, leave it)
+ * nav_position (do not set here)
+ */
+
+ if (ret->maneuver->type != type_nav_destination) {
+ /* FIXME: this will not catch cases in which entry and exit share the same node and we just *touch* the roundabout */
+ if (itm && itm->prev && !(itm->way.flags & AF_ROUNDABOUT) && (itm->prev->way.flags & AF_ROUNDABOUT)) {
+ navigation_analyze_roundabout(this_, ret, itm);
+ } else {
+ /* non-roundabout turn --> */
+
+ /* set ret->maneuver->type */
+ if (abs(ret->delta) >= min_turn_limit) {
+
+ /* Strengthening criterion: If there are more ways in the same direction, in which the vehicle can turn,
+ the announcement shall be more precise. I.e. the strengthening is dependent on which of the possible ways
+ the route turn shall be. So, with the selection of one of the possible ways a certain turn angle pattern
+ becomes active.
+ Second criterion: the turn angle of the route way defines the strengthening of the announcement according
+ to the pattern. */
+ w = itm->next->way.next;
+
+ if (angle_delta(itm->next->way.angle2,itm->angle_end) < 0) { /* next turns or bends left */
+ while (w) {
+ if (angle_delta(w->angle2,itm->angle_end) < -min_turn_limit) {
+ more_ways_for_strength++; /* there is an additional way that also turns left.
Note: the route turn is not contained
Left means more than min_turn_limit, less is straight on */
- if (angle_delta(w->angle2,itm->angle_end) < ret->delta)
- turn_no_of_route_way++; /* this way is on the left side of the route way */
- }
- w = w->next;
- }
- } else { /* next turns or bends right. Same investigation, but mirrored. */
- while (w) {
- if (angle_delta(w->angle2,itm->angle_end) > min_turn_limit) {
- more_ways_for_strength++;
- if (angle_delta(w->angle2,itm->angle_end) > ret->delta)
- turn_no_of_route_way++; /* this way is on the right side of the route way */
- }
- w = w->next;
- }
- }
-
-
- /* Investigate the strengthening of announcement. */
- switch (more_ways_for_strength) {
- case 0:
- /* Only one possibility to turn to this direction */
- if (ret->delta < -sharp_turn_limit) {
- ret->maneuver->type = type_nav_left_3; /* strongly left */
- } else if (ret->delta <= 0) {
- ret->maneuver->type = type_nav_left_2; /* normally left */
- } else if (ret->delta <= sharp_turn_limit) {
- ret->maneuver->type = type_nav_right_2;/* normally right */
- } else {
- ret->maneuver->type = type_nav_right_3;/* strongly right */
- }
- break;
- case 1:
- /* One additional possibility to turn to the same direction */
- if (turn_no_of_route_way == 0) {
- /* the route is less strong to turn */
- if (ret->delta < -turn_2_limit) {
- ret->maneuver->type = type_nav_left_2; /* normally left */
- } else if (ret->delta <= 0) {
- ret->maneuver->type = type_nav_left_1; /* easily left */
- } else if (ret->delta <= turn_2_limit) {
- ret->maneuver->type = type_nav_right_1; /* easily right */
- } else {
- ret->maneuver->type = type_nav_right_2; /* normally right */
- }
- } else {
- if (ret->delta < -sharp_turn_limit) {
- ret->maneuver->type = type_nav_left_3; /* strongly left */
- } else if (ret->delta <= 0) {
- ret->maneuver->type = type_nav_left_2; /* normally left */
- } else if (ret->delta <= sharp_turn_limit) {
- ret->maneuver->type = type_nav_right_2; /* normally right */
- } else {
- ret->maneuver->type = type_nav_right_3; /* strongly right */
- }
- }
- break;
- default:
- /* Two or more additional possibilities to turn to the same direction. */
- if (turn_no_of_route_way == 0) {
- if (ret->delta < -turn_2_limit) {
- ret->maneuver->type = type_nav_left_2; /* normally left */
- } else if (ret->delta <= 0) {
- ret->maneuver->type = type_nav_left_1; /* easily left */
- } else if (ret->delta <= turn_2_limit) {
- ret->maneuver->type = type_nav_right_1; /* easily right */
- } else {
- ret->maneuver->type = type_nav_right_2; /* normally right */
- }
- }
- else if (turn_no_of_route_way == 1) {
- if (ret->delta < -sharp_turn_limit) {
- ret->maneuver->type = type_nav_left_3; /* strongly left */
- } else if (ret->delta <= 0) {
- ret->maneuver->type = type_nav_left_2; /* normally left */
- } else if (ret->delta <= sharp_turn_limit) {
- ret->maneuver->type = type_nav_right_2; /* normally right */
- } else {
- ret->maneuver->type = type_nav_right_3; /* strongly right */
- }
- }
- else if (turn_no_of_route_way > 1) {
- /* if the route is the strongest of all possible turns here */
- if (ret->delta < -u_turn_limit) {
- ret->maneuver->type = type_nav_turnaround_left; /* turn around left */
- } else if (ret->delta < -sharp_turn_limit) {
- ret->maneuver->type = type_nav_left_3; /* strongly left */
- } else if (ret->delta <= 0) {
- ret->maneuver->type = type_nav_left_2; /* normally left */
- } else if (ret->delta <= sharp_turn_limit) {
- ret->maneuver->type = type_nav_right_2; /* normally right */
- } else if (ret->delta <= u_turn_limit) {
- ret->maneuver->type = type_nav_right_3; /* strongly right */
- } else {
- ret->maneuver->type = type_nav_turnaround_right; /* turn around right */
- }
- }
- break;
- }
- } else {
- /* if the route goes straight:
- * If there's another way on one side of the route within 2 * min_turn_limit (not both - the expression below is a logical XOR),
- * the maneuver is "keep left" or "keep right", else it is "go straight".
- * Note that neighbors are not necessarily straight.
- * The boundary may need some tweaking, (2 * min_turn_limit) may not be ideal but it's a first shot which ensures that other straight ways
- * will always fulfill the neighbor criteria. */
- int has_left_neighbor = (ret->maneuver->left - ret->delta > 2 * -min_turn_limit);
- int has_right_neighbor = (ret->maneuver->right - ret->delta < 2 * min_turn_limit);
- if (!(has_left_neighbor) != !(has_right_neighbor)) {
- if (has_left_neighbor)
- ret->maneuver->type = type_nav_keep_right;
- else
- ret->maneuver->type = type_nav_keep_left;
- } else
- ret->maneuver->type = type_nav_straight;
- } /* endif ret->delta */
- }
- }
-
- if (this_->cmd_last) {
- this_->cmd_last->next=ret;
- ret->prev = this_->cmd_last;
- }
- this_->cmd_last=ret;
-
- if (!this_->cmd_first)
- this_->cmd_first=ret;
- return ret;
+ if (angle_delta(w->angle2,itm->angle_end) < ret->delta)
+ turn_no_of_route_way++; /* this way is on the left side of the route way */
+ }
+ w = w->next;
+ }
+ } else { /* next turns or bends right. Same investigation, but mirrored. */
+ while (w) {
+ if (angle_delta(w->angle2,itm->angle_end) > min_turn_limit) {
+ more_ways_for_strength++;
+ if (angle_delta(w->angle2,itm->angle_end) > ret->delta)
+ turn_no_of_route_way++; /* this way is on the right side of the route way */
+ }
+ w = w->next;
+ }
+ }
+
+
+ /* Investigate the strengthening of announcement. */
+ switch (more_ways_for_strength) {
+ case 0:
+ /* Only one possibility to turn to this direction */
+ if (ret->delta < -sharp_turn_limit) {
+ ret->maneuver->type = type_nav_left_3; /* strongly left */
+ } else if (ret->delta <= 0) {
+ ret->maneuver->type = type_nav_left_2; /* normally left */
+ } else if (ret->delta <= sharp_turn_limit) {
+ ret->maneuver->type = type_nav_right_2;/* normally right */
+ } else {
+ ret->maneuver->type = type_nav_right_3;/* strongly right */
+ }
+ break;
+ case 1:
+ /* One additional possibility to turn to the same direction */
+ if (turn_no_of_route_way == 0) {
+ /* the route is less strong to turn */
+ if (ret->delta < -turn_2_limit) {
+ ret->maneuver->type = type_nav_left_2; /* normally left */
+ } else if (ret->delta <= 0) {
+ ret->maneuver->type = type_nav_left_1; /* easily left */
+ } else if (ret->delta <= turn_2_limit) {
+ ret->maneuver->type = type_nav_right_1; /* easily right */
+ } else {
+ ret->maneuver->type = type_nav_right_2; /* normally right */
+ }
+ } else {
+ if (ret->delta < -sharp_turn_limit) {
+ ret->maneuver->type = type_nav_left_3; /* strongly left */
+ } else if (ret->delta <= 0) {
+ ret->maneuver->type = type_nav_left_2; /* normally left */
+ } else if (ret->delta <= sharp_turn_limit) {
+ ret->maneuver->type = type_nav_right_2; /* normally right */
+ } else {
+ ret->maneuver->type = type_nav_right_3; /* strongly right */
+ }
+ }
+ break;
+ default:
+ /* Two or more additional possibilities to turn to the same direction. */
+ if (turn_no_of_route_way == 0) {
+ if (ret->delta < -turn_2_limit) {
+ ret->maneuver->type = type_nav_left_2; /* normally left */
+ } else if (ret->delta <= 0) {
+ ret->maneuver->type = type_nav_left_1; /* easily left */
+ } else if (ret->delta <= turn_2_limit) {
+ ret->maneuver->type = type_nav_right_1; /* easily right */
+ } else {
+ ret->maneuver->type = type_nav_right_2; /* normally right */
+ }
+ } else if (turn_no_of_route_way == 1) {
+ if (ret->delta < -sharp_turn_limit) {
+ ret->maneuver->type = type_nav_left_3; /* strongly left */
+ } else if (ret->delta <= 0) {
+ ret->maneuver->type = type_nav_left_2; /* normally left */
+ } else if (ret->delta <= sharp_turn_limit) {
+ ret->maneuver->type = type_nav_right_2; /* normally right */
+ } else {
+ ret->maneuver->type = type_nav_right_3; /* strongly right */
+ }
+ } else if (turn_no_of_route_way > 1) {
+ /* if the route is the strongest of all possible turns here */
+ if (ret->delta < -u_turn_limit) {
+ ret->maneuver->type = type_nav_turnaround_left; /* turn around left */
+ } else if (ret->delta < -sharp_turn_limit) {
+ ret->maneuver->type = type_nav_left_3; /* strongly left */
+ } else if (ret->delta <= 0) {
+ ret->maneuver->type = type_nav_left_2; /* normally left */
+ } else if (ret->delta <= sharp_turn_limit) {
+ ret->maneuver->type = type_nav_right_2; /* normally right */
+ } else if (ret->delta <= u_turn_limit) {
+ ret->maneuver->type = type_nav_right_3; /* strongly right */
+ } else {
+ ret->maneuver->type = type_nav_turnaround_right; /* turn around right */
+ }
+ }
+ break;
+ }
+ } else {
+ /* if the route goes straight:
+ * If there's another way on one side of the route within 2 * min_turn_limit (not both - the expression below is a logical XOR),
+ * the maneuver is "keep left" or "keep right", else it is "go straight".
+ * Note that neighbors are not necessarily straight.
+ * The boundary may need some tweaking, (2 * min_turn_limit) may not be ideal but it's a first shot which ensures that other straight ways
+ * will always fulfill the neighbor criteria. */
+ int has_left_neighbor = (ret->maneuver->left - ret->delta > 2 * -min_turn_limit);
+ int has_right_neighbor = (ret->maneuver->right - ret->delta < 2 * min_turn_limit);
+ if (!(has_left_neighbor) != !(has_right_neighbor)) {
+ if (has_left_neighbor)
+ ret->maneuver->type = type_nav_keep_right;
+ else
+ ret->maneuver->type = type_nav_keep_left;
+ } else
+ ret->maneuver->type = type_nav_straight;
+ } /* endif ret->delta */
+ }
+ }
+
+ if (this_->cmd_last) {
+ this_->cmd_last->next=ret;
+ ret->prev = this_->cmd_last;
+ }
+ this_->cmd_last=ret;
+
+ if (!this_->cmd_first)
+ this_->cmd_first=ret;
+ return ret;
}
@@ -2866,53 +2780,47 @@ command_new(struct navigation *this_, struct navigation_itm *itm, struct navigat
* @param this_ The navigation object for which to create turn instructions
* @param route Not used
*/
-static void
-make_maneuvers(struct navigation *this_, struct route *route)
-{
- struct navigation_itm *itm, *last=NULL, *last_itm=NULL;
- struct navigation_maneuver *maneuver;
- itm=this_->first;
- this_->cmd_last=NULL;
- this_->cmd_first=NULL;
- while (itm) {
- if (last) {
- if (maneuver_required2(this_, last_itm, itm, &maneuver)) {
- command_new(this_, itm, maneuver);
- }
- } else
- last=itm;
- last_itm=itm;
- itm=itm->next;
- }
- maneuver = g_new0(struct navigation_maneuver, 1);
- maneuver->type = type_nav_destination;
- command_new(this_, last_itm, maneuver);
+static void make_maneuvers(struct navigation *this_, struct route *route) {
+ struct navigation_itm *itm, *last=NULL, *last_itm=NULL;
+ struct navigation_maneuver *maneuver;
+ itm=this_->first;
+ this_->cmd_last=NULL;
+ this_->cmd_first=NULL;
+ while (itm) {
+ if (last) {
+ if (maneuver_required2(this_, last_itm, itm, &maneuver)) {
+ command_new(this_, itm, maneuver);
+ }
+ } else
+ last=itm;
+ last_itm=itm;
+ itm=itm->next;
+ }
+ maneuver = g_new0(struct navigation_maneuver, 1);
+ maneuver->type = type_nav_destination;
+ command_new(this_, last_itm, maneuver);
}
-static int
-contains_suffix(char *name, char *suffix)
-{
- if (!suffix)
- return 0;
- if (strlen(name) < strlen(suffix))
- return 0;
- return !navit_utf8_strcasecmp(name+strlen(name)-strlen(suffix), suffix);
+static int contains_suffix(char *name, char *suffix) {
+ if (!suffix)
+ return 0;
+ if (strlen(name) < strlen(suffix))
+ return 0;
+ return !navit_utf8_strcasecmp(name+strlen(name)-strlen(suffix), suffix);
}
-static char *
-replace_suffix(char *name, char *search, char *replace)
-{
- int len=strlen(name)-strlen(search);
- char *ret=g_malloc(len+strlen(replace)+1);
- strncpy(ret, name, len);
- strcpy(ret+len, replace);
- if (isupper(name[len])) {
- ret[len]=toupper(ret[len]);
- }
+static char *replace_suffix(char *name, char *search, char *replace) {
+ int len=strlen(name)-strlen(search);
+ char *ret=g_malloc(len+strlen(replace)+1);
+ strncpy(ret, name, len);
+ strcpy(ret+len, replace);
+ if (isupper(name[len])) {
+ ret[len]=toupper(ret[len]);
+ }
- return ret;
+ return ret;
}
@@ -2927,135 +2835,136 @@ replace_suffix(char *name, char *search, char *replace)
* the {@code navigation_item} associated with the previous {@code navigation_command}
* @param prefix A space will be added as a prefix to the string returned, or a null string for no prefix
*/
-static char *
-navigation_item_destination(struct navigation *nav, struct navigation_command *cmd, struct navigation_itm *next, char *prefix)
-{
- char *ret = NULL, *name1 = NULL, *sep = "", *name2 = "";
- char *name = NULL, *name_systematic=NULL;
- int i, gender = unknown;
- int vocabulary1=1;
- int vocabulary2=1;
- struct attr attr;
- struct navigation_itm *itm = cmd->itm;
- struct navigation_itm *itm_pre = NULL;
- struct navigation_itm *itm_post = NULL;
-
- if (! prefix)
- prefix="";
- /* check the configuration of navit.xml */
- if (nav->speech && speech_get_attr(nav->speech, attr_vocabulary_name, &attr, NULL))
- vocabulary1=attr.u.num; /* shall the street name be announced? */
- if (nav->speech && speech_get_attr(nav->speech, attr_vocabulary_name_systematic, &attr, NULL))
- vocabulary2=attr.u.num; /* shall the systematic name be announced? */
-
- /* On motorway links don't announce the name of the ramp as this is done by name_systematic and the street_destination. */
- if (vocabulary1 && (itm->way.item.type != type_ramp))
- name=itm->way.name;
-
- if (vocabulary2)
- name_systematic=itm->way.name_systematic;
-
- if (name) {
- name1 = g_strdup(name);
- for (i = 0; i < sizeof(suffixes)/sizeof(suffixes[0]); i++) {
- if (contains_suffix(name, suffixes[i].fullname)) {
- gender = suffixes[i].gender;
- g_free(name1);
- name1 = g_strdup(name);
- break;
- }
- if (contains_suffix(name, suffixes[i].abbrev)) {
- gender = suffixes[i].gender;
- g_free(name1);
- name1 = replace_suffix(name, suffixes[i].abbrev, suffixes[i].fullname);
- break;
- }
- }
- if (name_systematic) {
- name2 = name_systematic;
- sep=" ";
- }
- } else
- name1 = g_strdup("");
-
- if (cmd->maneuver && cmd->maneuver->type && (cmd->maneuver->merge_or_exit & mex_merge)) {
- if (name_systematic)
- /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Systematic Street Name 3: Separator (Space if required), 4: Street Name */
- ret = g_strdup_printf(_("%1$sonto the %2$s%3$s%4$s"), prefix, name_systematic, sep, name1);
- else if (name)
- switch (gender) {
- case unknown:
- /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name */
- ret = g_strdup_printf(_("%1$sonto %2$s"), prefix, name1);
- break;
- case masculine:
- /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Masculine form. The stuff after | doesn't have to be included */
- ret=g_strdup_printf(_("%1$sonto %2$s|masculine form"), prefix, name1);
- break;
- case feminine:
- /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Feminine form. The stuff after | doesn't have to be included */
- ret=g_strdup_printf(_("%1$sonto %2$s|feminine form"), prefix, name1);
- break;
- case neuter:
- /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Neuter form. The stuff after | doesn't have to be included */
- ret=g_strdup_printf(_("%1$sonto %2$s|neuter form"), prefix, name1);
- break;
- }
- else ret = g_strdup("");
- } else if (!name && !name_systematic && itm->way.item.type == type_ramp && (!cmd->maneuver || (cmd->maneuver->merge_or_exit != mex_interchange))) {
- itm_pre = itm->prev;
- while (itm_pre && (itm_pre->way.item.type == type_ramp))
- itm_pre = itm_pre->prev;
- itm_post = itm->next;
- while (itm_post && (itm_post->way.item.type == type_ramp) && (!cmd->next || (itm_post != cmd->next->itm)))
- itm_post = itm_post->next;
- if (((itm_post) && is_motorway_like(&(itm_post->way), 0))
- && ((itm_pre) && !is_motorway_like(&(itm_pre->way), 0)))
- /* TRANSLATORS: motorway ramp refers to the slip road for entering a motorway. */
- ret = g_strdup_printf("%s%s",prefix,_("onto the motorway ramp")); /* This is only announced when there is no additional info about the ramp and the ramp leads to a motorway. */
- else
- ret = g_strdup("");
- } else if (!name && !name_systematic)
- ret = g_strdup("");
- else if (name) {
- switch (gender) {
- case unknown:
- /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name */
- ret=g_strdup_printf(_("%sinto %s%s%s"), prefix, name, sep, name2);
- break;
- case masculine:
- /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Masculine form. The stuff after | doesn't have to be included */
- ret=g_strdup_printf(_("%sinto %s%s%s|masculine form"), prefix, name1, sep, name2);
- break;
- case feminine:
- /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Feminine form. The stuff after | doesn't have to be included */
- ret=g_strdup_printf(_("%sinto %s%s%s|feminine form"), prefix, name1, sep, name2);
- break;
- case neuter:
- /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Neuter form. The stuff after | doesn't have to be included */
- ret=g_strdup_printf(_("%sinto %s%s%s|neuter form"), prefix, name1, sep, name2);
- break;
- }
-
- } else
- /* TRANSLATORS: gives the name of the next road to turn into (into the E17) */
- ret=g_strdup_printf(_("%sinto the %s"),prefix,name_systematic);
- g_free(name1);
- name1=ret;
- while (name1 && *name1) {
- switch (*name1) {
- case '|':
- *name1='\0';
- break;
- case '/':
- *name1++=' ';
- break;
- default:
- name1++;
- break;
- }
- }
- return ret;
+static char *navigation_item_destination(struct navigation *nav, struct navigation_command *cmd,
+ struct navigation_itm *next,
+ char *prefix) {
+ char *ret = NULL, *name1 = NULL, *sep = "", *name2 = "";
+ char *name = NULL, *name_systematic=NULL;
+ int i, gender = unknown;
+ int vocabulary1=1;
+ int vocabulary2=1;
+ struct attr attr;
+ struct navigation_itm *itm = cmd->itm;
+ struct navigation_itm *itm_pre = NULL;
+ struct navigation_itm *itm_post = NULL;
+
+ if (! prefix)
+ prefix="";
+ /* check the configuration of navit.xml */
+ if (nav->speech && speech_get_attr(nav->speech, attr_vocabulary_name, &attr, NULL))
+ vocabulary1=attr.u.num; /* shall the street name be announced? */
+ if (nav->speech && speech_get_attr(nav->speech, attr_vocabulary_name_systematic, &attr, NULL))
+ vocabulary2=attr.u.num; /* shall the systematic name be announced? */
+
+ /* On motorway links don't announce the name of the ramp as this is done by name_systematic and the street_destination. */
+ if (vocabulary1 && (itm->way.item.type != type_ramp))
+ name=itm->way.name;
+
+ if (vocabulary2)
+ name_systematic=itm->way.name_systematic;
+
+ if (name) {
+ name1 = g_strdup(name);
+ for (i = 0; i < sizeof(suffixes)/sizeof(suffixes[0]); i++) {
+ if (contains_suffix(name, suffixes[i].fullname)) {
+ gender = suffixes[i].gender;
+ g_free(name1);
+ name1 = g_strdup(name);
+ break;
+ }
+ if (contains_suffix(name, suffixes[i].abbrev)) {
+ gender = suffixes[i].gender;
+ g_free(name1);
+ name1 = replace_suffix(name, suffixes[i].abbrev, suffixes[i].fullname);
+ break;
+ }
+ }
+ if (name_systematic) {
+ name2 = name_systematic;
+ sep=" ";
+ }
+ } else
+ name1 = g_strdup("");
+
+ if (cmd->maneuver && cmd->maneuver->type && (cmd->maneuver->merge_or_exit & mex_merge)) {
+ if (name_systematic)
+ /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Systematic Street Name 3: Separator (Space if required), 4: Street Name */
+ ret = g_strdup_printf(_("%1$sonto the %2$s%3$s%4$s"), prefix, name_systematic, sep, name1);
+ else if (name)
+ switch (gender) {
+ case unknown:
+ /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name */
+ ret = g_strdup_printf(_("%1$sonto %2$s"), prefix, name1);
+ break;
+ case masculine:
+ /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Masculine form. The stuff after | doesn't have to be included */
+ ret=g_strdup_printf(_("%1$sonto %2$s|masculine form"), prefix, name1);
+ break;
+ case feminine:
+ /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Feminine form. The stuff after | doesn't have to be included */
+ ret=g_strdup_printf(_("%1$sonto %2$s|feminine form"), prefix, name1);
+ break;
+ case neuter:
+ /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Neuter form. The stuff after | doesn't have to be included */
+ ret=g_strdup_printf(_("%1$sonto %2$s|neuter form"), prefix, name1);
+ break;
+ } else ret = g_strdup("");
+ } else if (!name && !name_systematic && itm->way.item.type == type_ramp && (!cmd->maneuver
+ || (cmd->maneuver->merge_or_exit != mex_interchange))) {
+ itm_pre = itm->prev;
+ while (itm_pre && (itm_pre->way.item.type == type_ramp))
+ itm_pre = itm_pre->prev;
+ itm_post = itm->next;
+ while (itm_post && (itm_post->way.item.type == type_ramp) && (!cmd->next || (itm_post != cmd->next->itm)))
+ itm_post = itm_post->next;
+ if (((itm_post) && is_motorway_like(&(itm_post->way), 0))
+ && ((itm_pre) && !is_motorway_like(&(itm_pre->way), 0)))
+ /* TRANSLATORS: motorway ramp refers to the slip road for entering a motorway. */
+ ret = g_strdup_printf("%s%s",prefix,
+ _("onto the motorway ramp")); /* This is only announced when there is no additional info about the ramp and the ramp leads to a motorway. */
+ else
+ ret = g_strdup("");
+ } else if (!name && !name_systematic)
+ ret = g_strdup("");
+ else if (name) {
+ switch (gender) {
+ case unknown:
+ /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name */
+ ret=g_strdup_printf(_("%sinto %s%s%s"), prefix, name, sep, name2);
+ break;
+ case masculine:
+ /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Masculine form. The stuff after | doesn't have to be included */
+ ret=g_strdup_printf(_("%sinto %s%s%s|masculine form"), prefix, name1, sep, name2);
+ break;
+ case feminine:
+ /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Feminine form. The stuff after | doesn't have to be included */
+ ret=g_strdup_printf(_("%sinto %s%s%s|feminine form"), prefix, name1, sep, name2);
+ break;
+ case neuter:
+ /* TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Neuter form. The stuff after | doesn't have to be included */
+ ret=g_strdup_printf(_("%sinto %s%s%s|neuter form"), prefix, name1, sep, name2);
+ break;
+ }
+
+ } else
+ /* TRANSLATORS: gives the name of the next road to turn into (into the E17) */
+ ret=g_strdup_printf(_("%sinto the %s"),prefix,name_systematic);
+ g_free(name1);
+ name1=ret;
+ while (name1 && *name1) {
+ switch (*name1) {
+ case '|':
+ *name1='\0';
+ break;
+ case '/':
+ *name1++=' ';
+ break;
+ default:
+ name1++;
+ break;
+ }
+ }
+ return ret;
}
@@ -3079,36 +2988,35 @@ navigation_item_destination(struct navigation *nav, struct navigation_command *c
* @param street_destination_announce The name of the street following the maneuver. This argument
* may be NULL, in which case the exit name will not be suppressed.
*/
-static char *
-navigation_cmd_get_exit_announce(struct navigation_command *this_, char *street_destination_announce) {
- char * ret = NULL;
- char *folded_exit_label=NULL;
- char *folded_street_destination_announce=NULL;
-
- if (this_->itm->way.exit_label) {
- folded_exit_label = linguistics_casefold(this_->itm->way.exit_label);
- if (street_destination_announce)
- folded_street_destination_announce = linguistics_casefold(street_destination_announce);
- else
- folded_street_destination_announce = g_strdup("");
-
- if (!strstr(folded_street_destination_announce, folded_exit_label)) { /* No redundancy? */
- if (this_->itm->way.exit_ref)
- ret = g_strdup_printf("%1$s %2$s", this_->itm->way.exit_ref, this_->itm->way.exit_label);
- else
- ret = g_strdup_printf("%1$s", this_->itm->way.exit_label);
- } else if (this_->itm->way.exit_ref)
- ret = g_strdup_printf("%1$s", this_->itm->way.exit_ref);
-
- } else {
- if (this_->itm->way.exit_ref)
- ret = g_strdup_printf("%1$s", this_->itm->way.exit_ref);
- }
-
- g_free(folded_exit_label);
- g_free(folded_street_destination_announce);
-
- return ret;
+static char *navigation_cmd_get_exit_announce(struct navigation_command *this_, char *street_destination_announce) {
+ char * ret = NULL;
+ char *folded_exit_label=NULL;
+ char *folded_street_destination_announce=NULL;
+
+ if (this_->itm->way.exit_label) {
+ folded_exit_label = linguistics_casefold(this_->itm->way.exit_label);
+ if (street_destination_announce)
+ folded_street_destination_announce = linguistics_casefold(street_destination_announce);
+ else
+ folded_street_destination_announce = g_strdup("");
+
+ if (!strstr(folded_street_destination_announce, folded_exit_label)) { /* No redundancy? */
+ if (this_->itm->way.exit_ref)
+ ret = g_strdup_printf("%1$s %2$s", this_->itm->way.exit_ref, this_->itm->way.exit_label);
+ else
+ ret = g_strdup_printf("%1$s", this_->itm->way.exit_label);
+ } else if (this_->itm->way.exit_ref)
+ ret = g_strdup_printf("%1$s", this_->itm->way.exit_ref);
+
+ } else {
+ if (this_->itm->way.exit_ref)
+ ret = g_strdup_printf("%1$s", this_->itm->way.exit_ref);
+ }
+
+ g_free(folded_exit_label);
+ g_free(folded_street_destination_announce);
+
+ return ret;
}
@@ -3127,419 +3035,405 @@ navigation_cmd_get_exit_announce(struct navigation_command *this_, char *street_
* @param connect Whether this is the second of two connected announcements, as in "turn left
* in..., then turn right"
*/
-static char *
-show_maneuver(struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd, enum attr_type type, enum announcement_level level)
-{
-
- int distance=itm->dest_length-cmd->itm->dest_length;
- char *d=NULL,*ret=NULL;
- char *street_destination_announce=NULL;
- int skip_roads = 0;
- int count_roundabout;
- struct navigation_itm *cur;
- struct navigation_way *candidate_way;
- int tellstreetname = 0;
- char *at = NULL; /* Motorway junction name */
- char *direction = NULL; /* The direction-dependent part of the maneuver */
- char *destination = NULL;
- char *street_destination = NULL;
- char *instruction = NULL;
- char *strength = NULL; /* Strength of turn like 'easily', 'strongly', etc. */
-
-
- if (type != attr_navigation_long_exact)
- distance=round_distance(distance);
-
- if (type == attr_navigation_speech) {
- if (nav->turn_around && nav->turn_around == nav->turn_around_limit) {
- if (level == level_connect) {
- return g_strdup(""); /* there is no ',then turn around' */
- } else {
- navigation_set_turnaround(nav, nav->turn_around_count+1);
- return g_strdup(_("When possible, please turn around"));
- }
- }
- navigation_set_turnaround(nav, 0);
- dbg(lvl_debug,"distance=%d level=%d type=0x%x\n", distance, level, itm->way.item.type);
- }
-
-
- street_destination=select_announced_destinations(cmd);
- if (street_destination)
- if (level == level_connect) {
- /* for the connected announcement suppress the destination, if this is the same as in the first part of the announcement */
- if (cmd->prev) {
- char *street_destination_previous = select_announced_destinations(cmd->prev);
- if (street_destination_previous && strstr(street_destination_previous, street_destination)) { /* doesn't have any new information? */
- street_destination_announce=g_strdup("");
- } else {
- /* TRANSLATORS: the argument is the destination to follow */
- street_destination_announce=g_strdup_printf(_("towards %s"),street_destination);
- }
- g_free(street_destination_previous);
- } else {
- street_destination_announce=g_strdup_printf(_("towards %s"),street_destination);
- }
- } else {
- street_destination_announce=g_strdup_printf(_("towards %s"),street_destination);
- }
- else street_destination_announce=g_strdup("");
- g_free(street_destination);
-
- if (cmd->itm->prev->way.flags & AF_ROUNDABOUT)
- {
- cur = cmd->itm->prev;
- count_roundabout = 0;
- while (cur && (cur->way.flags & AF_ROUNDABOUT))
- {
- candidate_way=cur->next->way.next;
- while (candidate_way)
- {
- if (candidate_way && is_way_allowed(nav,candidate_way,3))
- /* If the next segment has no exit or the exit isn't allowed, don't count it */
- {
- count_roundabout++;
- /* As soon as we have an allowed one on this node,
- * stop further counting for this node.
- */
- break;
- }
- candidate_way=candidate_way->next;
- }
- cur = cur->prev;
- }
-
- /*try to figure out if the entry node has a usable exit as well
- *
- * this will fail for left-hand driving areas
- */
- if (cur && cur->next)
- {
- candidate_way=cur->next->way.next;
- while (candidate_way)
- {
- if (candidate_way && is_way_allowed(nav,candidate_way,3)
- /*&& (angle_delta(cur->angle_end,candidate_way->angle2) > 0) && ( angle_delta(candidate_way->angle2,cur->next->way.angle2) < 0 )*/)
- /*for right-hand traffic, exits should be to the right anyway to allow smooth turns, so leave this out until we find a counterexample :)*/
- {
- count_roundabout++;
- /* As soon as we have an allowed one on this node,
- * stop further counting for this node.
- */
- break;
- }
- candidate_way=candidate_way->next;
- }
- }
-
- switch (level)
- {
- case level_follow:
- d=get_distance_str(nav, distance, type, 1);
- return g_strdup_printf(_("Follow the road for the next %s"), d);
- case level_soon:
- return g_strdup(_("Enter the roundabout soon"));
- case level_meters:
- d = get_distance_str(nav, distance, attr_navigation_short, 0);
- /* TRANSLATORS: %s is the distance to the roundabout */
- ret = g_strdup_printf(_("Enter the roundabout %s"), d);
- g_free(d);
- return ret;
- case level_connect:
- return g_strdup(_("then enter the roundabout"));
- case level_now:
- /* TRANSLATORS: first arg. is the manieth exit, second arg. is the destination to follow */
- return g_strdup_printf(_("Leave the roundabout at the %1$s %2$s"), get_exit_count_str(count_roundabout),street_destination_announce);
- default :
- dbg(lvl_error,"unexpected announcement level %d\n", level);
- return g_strdup_printf("internal error");
- }
- }
-
- if (cmd->maneuver && cmd->maneuver->type)
- {
- if (cmd->itm->next)
- {
- if(type == attr_navigation_speech)
- { /* In voice mode */
- /* In Voice Mode only tell the street name in level_meters or in level_ if level 1 was skipped */
- if (level == level_meters)
- { /* we are close to the intersection */
- cmd->itm->streetname_told = 1; /* remember to be checked when we turn */
- tellstreetname = 1; /* Ok, so we tell the name of the street */
- }
- else if (level == level_now)
- {
- if(cmd->itm->streetname_told == 0) /* we are right at the intersection */
- tellstreetname = 1;
- else
- cmd->itm->streetname_told = 0; /* reset just in case we come to the same street again */
- }
- else if (level == level_connect)
- {
- tellstreetname = 1;
- }
- }
- else
- tellstreetname = 1;
- }
-
-
- switch (level)
- {
- case level_soon :
- d=g_strdup(_("soon"));
- break;
- case level_meters :
- d=get_distance_str(nav, distance, attr_navigation_short, 0);
- break;
- case level_now :
- d=g_strdup(_("now"));
- break;
- case level_connect :
- d=g_strdup(_("then"));
- break;
- default :
- d = g_strdup("");
- break;
- }
-
- if (tellstreetname)
- destination=navigation_item_destination(nav, cmd, itm, " ");
- else destination = g_strdup("");
-
- if (!(cmd->maneuver->merge_or_exit == mex_none ))
- {
- char *exit_announce=NULL;
-
- /* interchange or exit announcement shall be a long distance information only.
- But if so, exit_label shall not be announced in case it is a substring
- of destination info to avoid redundancy and not let the sentence become too long.
- Otherwise, if there is no additional destination info, just say it at level_meters. */
- if ((level == level_soon) || ((level == level_meters) && (!street_destination_announce && !destination)) || (type != attr_navigation_speech)) {
- exit_announce = navigation_cmd_get_exit_announce(cmd, street_destination_announce);
- }
-
- switch (cmd->maneuver->merge_or_exit)
- {
- case mex_merge_left:
- case mex_merge_right:
- if (cmd->maneuver->merge_or_exit == mex_merge_right) {
- if (level == level_connect)
- /* TRANSLATORS: the arg. is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included. */
- instruction = g_strdup_printf(_("then merge%1$s|right"), destination);
- else
- /* TRANSLATORS: the first arg. is distance, the second is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included. */
- instruction = g_strdup_printf(_("Merge %1$s%2$s|right"), d, destination);
- } else {
- if (level == level_connect)
- /* TRANSLATORS: the arg. is the phrase 'onto ...'. Left merge, the stuff after | doesn't have to be included. */
- instruction = g_strdup_printf(_("then merge%1$s|left"), destination);
- else
- /* TRANSLATORS: the first arg. is distance, the second is the phrase 'onto ...'. Left merge, the stuff after | doesn't have to be included. */
- instruction = g_strdup_printf(_("Merge %1$s%2$s|left"), d, destination);
- }
- break;
- case mex_exit_left:
- case mex_exit_right:
- direction = (cmd->maneuver->merge_or_exit == mex_exit_left) ?
- g_strdup(_("on your left")) :
- g_strdup(_("on your right"));
- if (exit_announce)
- /* TRANSLATORS: the first arg. is exit ref and/or name, the second is the direction of exit and the third is distance */
- instruction = g_strdup_printf(_("Take exit %1$s %2$s %3$s"), exit_announce, direction, d);
- else
- /* TRANSLATORS: the first arg. is the direction of exit, the second is distance, the third is destination */
- instruction = g_strdup_printf(_("Take the exit %1$s %2$s%3$s"), direction, d, destination);
-
- break;
- }
-
- if (!instruction && exit_announce) {
- /* TRANSLATORS: as in "Keep right at interchange 42 Greenmond-West" */
- at = g_strdup_printf(" %1$s %2$s", cmd->maneuver->merge_or_exit == mex_interchange ? (_("at interchange")) : (_( "at exit")),
- exit_announce ? exit_announce : "");
- }
- g_free(exit_announce);
- }
- if (!instruction) {
- if (!at)
- at = g_strdup("");
- switch (cmd->maneuver->type) {
- case type_nav_straight :
- if (level == level_connect)
- /* TRANSLATORS: the arg. is where to do the maneuver */
- instruction = g_strdup_printf(_("then continue straight%1$s"), at);
- else
- /* TRANSLATORS: the first arg. is distance, the second is where to do the maneuver, the third is destination */
- instruction = g_strdup_printf(_("Continue straight %1$s%2$s%3$s"), d, at, destination);
- break;
- case type_nav_keep_right :
- if (level == level_connect)
- /* TRANSLATORS: the arg. is where to do the maneuver */
- instruction = g_strdup_printf(_("then keep right%1$s"), at);
- else
- /* TRANSLATORS: the first arg. is distance, the second is where to do the maneuver, the third is destination */
- instruction = g_strdup_printf(_("Keep right %1$s%2$s%3$s"), d, at, destination);
- break;
- case type_nav_keep_left :
- if (level == level_connect)
- /* TRANSLATORS: the arg. is where to do the maneuver */
- instruction = g_strdup_printf(_("then keep left%1$s"), at);
- else
- /* TRANSLATORS: the first arg. is distance, the second is where to do the maneuver, the third is destination */
- instruction = g_strdup_printf(_("Keep left %1$s%2$s%3$s"), d, at, destination);
- break;
- case type_nav_right_1 :
- case type_nav_right_2 :
- case type_nav_right_3 :
- case type_nav_left_1 :
- case type_nav_left_2 :
- case type_nav_left_3 :
- /* generic turn case */
- switch (cmd->maneuver->type) {
- case type_nav_right_1 :
- case type_nav_right_2 :
- case type_nav_right_3 :
- /* TRANSLATORS: "right" as in "turn right" */
- direction = g_strdup(_("right"));
- if (level == level_now)
- skip_roads = count_possible_turns(nav, cmd->prev ? cmd->prev->itm : nav->first, cmd->itm, 90);
- else if (level == level_connect)
- /* Robotaxi: todo - must tidy up skip_roads == -1 issue */
- skip_roads = count_possible_turns(nav, itm->next ? itm->next : itm, cmd->itm, 90);
- break;
- case type_nav_left_1 :
- case type_nav_left_2 :
- case type_nav_left_3 :
- /* TRANSLATORS: "left" as in "turn left" */
- direction = g_strdup(_("left"));
- if (level == level_now)
- skip_roads = count_possible_turns(nav, cmd->prev ? cmd->prev->itm : nav->first, cmd->itm, -90);
- else if (level == level_connect)
- skip_roads = count_possible_turns(nav, itm->next ? itm->next : itm, cmd->itm, -90);
- break;
- default:
- direction = g_strdup("");
- break;
- }
- switch (cmd->maneuver->type) {
- case type_nav_right_1 :
- case type_nav_left_1 :
- /* TRANSLATORS: as in "turn easily right" */
- strength = g_strdup(_("easily "));
- break;
- case type_nav_right_3 :
- case type_nav_left_3 :
- /* TRANSLATORS: as in "turn strongly right" */
- strength = g_strdup(_("strongly "));
- break;
- default:
- strength = g_strdup("");
- break;
- }
- /* Robotaxi: todo - must tidy up skip_roads == -1 issue */
- if (skip_roads > 0) {
- if (skip_roads < 6) {
- if (level == level_connect)
- instruction = g_strdup_printf(_("then take the %1$s road to the %2$s"), get_count_str(skip_roads+1), direction);
- else
- instruction = g_strdup_printf(_("Take the %1$s road to the %2$s"), get_count_str(skip_roads+1), direction);
- /*and preserve skip_roads to signal that we already have an instruction*/
- } else {
- g_free(d);
- d=g_strdup_printf(_("after %i roads"),skip_roads);
- skip_roads = 0; /*signal an instruction still has to be created*/
- }
- }
- /* cave: no else - may come from 'if (skip_roads)' above ! */
- if (skip_roads <= 0) {
- /* TRANSLATORS: the first arg. is strength, the second is direction, the third is distance, the fourth is destination */
- instruction = g_strdup_printf(_("Turn %1$s%2$s %3$s%4$s"), strength, direction, d, destination);
- }
- break;
- case type_nav_turnaround_left:
- if (level == level_connect)
- /* TRANSLATORS: Left U-turn, the stuff after | doesn't have to be included. */
- instruction = g_strdup(_("then make a U-turn|left"));
- else
- /* TRANSLATORS: the arg. is distance. Left U-turn, the stuff after | doesn't have to be included. */
- instruction = g_strdup_printf(_("Make a U-turn %1$s|left"), d);
- break;
- case type_nav_turnaround_right:
- if (level == level_connect)
- /* TRANSLATORS: Right U-turn, the stuff after | doesn't have to be included. */
- instruction = g_strdup(_("then make a U-turn|right"));
- else
- /* TRANSLATORS: the arg. is distance. Right U-turn, the stuff after | doesn't have to be included. */
- instruction = g_strdup_printf(_("Make a U-turn %1$s|right"), d);
- break;
- case type_nav_none:
- /*An empty placeholder that we can use in the future for
- * some motorway commands that are now suppressed but we
- * can in some cases make it say here :
- * 'follow destination blabla' without any further driving instructions,
- * in cases where relevant destination info is available.
- * Even if there is no driving command to be announced, in some cases
- * there is an overhead roadsign in preparation of an upcoming road-split,
- * and then we can give useful info to the driver.
- *
- * UNTESTED !
- *
- */
- instruction = g_strdup(_("follow"));
- break;
- case type_nav_destination:
- /* the old code used to clear the route destination when this was the only
- * instruction left. Was that useful ?
- * Should be tested with the old code what happens if the driver
- * 'overshoots' the destination and the route destination is already cleared.
- * I suppose it will now keep guiding the user to destination untill another one
- * is set or a 'stop navigation' action is done using the gui.
- */
- if (level == level_connect)
- instruction=g_strdup(_("then you have reached your destination."));
- else
- /* TRANSLATORS: the arg. is distance */
- instruction=g_strdup_printf(_("You have reached your destination %s"), d);
- break;
- default:
- dbg(lvl_error,"unhandled instruction\n");
- break;
- }
- }
- }
- switch (level)
- {
- case level_follow:
- d=get_distance_str(nav, distance, type, 1);
- ret=g_strdup_printf(_("Follow the road for the next %s"), d);
- break;
- case level_soon:
- if (at) /* 'at' contains interchange or exit information that shall not be combined with street_destination_announce */
- ret= g_strdup_printf(("%1$s %2$s"),instruction,"");
- else
- ret= g_strdup_printf(("%1$s %2$s"),instruction,street_destination_announce);
- break;
- case level_meters:
- case level_connect:
- case level_now:
- ret= g_strdup_printf(("%1$s %2$s"),instruction,street_destination_announce);
- break;
- default :
- ret= g_strdup_printf(("%1$s %2$s"),instruction,street_destination_announce);
- dbg(lvl_error,"unexpected announcement level %d\n", level);
- break;
- }
-
- g_free(at);
- g_free(d);
- g_free(destination);
- g_free(direction);
- g_free(instruction);
- g_free(street_destination_announce);
- g_free(strength);
- return ret;
+static char *show_maneuver(struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd,
+ enum attr_type type,
+ enum announcement_level level) {
+
+ int distance=itm->dest_length-cmd->itm->dest_length;
+ char *d=NULL,*ret=NULL;
+ char *street_destination_announce=NULL;
+ int skip_roads = 0;
+ int count_roundabout;
+ struct navigation_itm *cur;
+ struct navigation_way *candidate_way;
+ int tellstreetname = 0;
+ char *at = NULL; /* Motorway junction name */
+ char *direction = NULL; /* The direction-dependent part of the maneuver */
+ char *destination = NULL;
+ char *street_destination = NULL;
+ char *instruction = NULL;
+ char *strength = NULL; /* Strength of turn like 'easily', 'strongly', etc. */
+
+
+ if (type != attr_navigation_long_exact)
+ distance=round_distance(distance);
+
+ if (type == attr_navigation_speech) {
+ if (nav->turn_around && nav->turn_around == nav->turn_around_limit) {
+ if (level == level_connect) {
+ return g_strdup(""); /* there is no ',then turn around' */
+ } else {
+ navigation_set_turnaround(nav, nav->turn_around_count+1);
+ return g_strdup(_("When possible, please turn around"));
+ }
+ }
+ navigation_set_turnaround(nav, 0);
+ dbg(lvl_debug,"distance=%d level=%d type=0x%x", distance, level, itm->way.item.type);
+ }
+
+
+ street_destination=select_announced_destinations(cmd);
+ if (street_destination)
+ if (level == level_connect) {
+ /* for the connected announcement suppress the destination, if this is the same as in the first part of the announcement */
+ if (cmd->prev) {
+ char *street_destination_previous = select_announced_destinations(cmd->prev);
+ if (street_destination_previous
+ && strstr(street_destination_previous, street_destination)) { /* doesn't have any new information? */
+ street_destination_announce=g_strdup("");
+ } else {
+ /* TRANSLATORS: the argument is the destination to follow */
+ street_destination_announce=g_strdup_printf(_("towards %s"),street_destination);
+ }
+ g_free(street_destination_previous);
+ } else {
+ street_destination_announce=g_strdup_printf(_("towards %s"),street_destination);
+ }
+ } else {
+ street_destination_announce=g_strdup_printf(_("towards %s"),street_destination);
+ } else street_destination_announce=g_strdup("");
+ g_free(street_destination);
+
+ if (cmd->itm->prev->way.flags & AF_ROUNDABOUT) {
+ cur = cmd->itm->prev;
+ count_roundabout = 0;
+ while (cur && (cur->way.flags & AF_ROUNDABOUT)) {
+ candidate_way=cur->next->way.next;
+ while (candidate_way) {
+ if (candidate_way && is_way_allowed(nav,candidate_way,3))
+ /* If the next segment has no exit or the exit isn't allowed, don't count it */
+ {
+ count_roundabout++;
+ /* As soon as we have an allowed one on this node,
+ * stop further counting for this node.
+ */
+ break;
+ }
+ candidate_way=candidate_way->next;
+ }
+ cur = cur->prev;
+ }
+
+ /*try to figure out if the entry node has a usable exit as well
+ *
+ * this will fail for left-hand driving areas
+ */
+ if (cur && cur->next) {
+ candidate_way=cur->next->way.next;
+ while (candidate_way) {
+ if (candidate_way && is_way_allowed(nav,candidate_way,3)
+ /*&& (angle_delta(cur->angle_end,candidate_way->angle2) > 0) && ( angle_delta(candidate_way->angle2,cur->next->way.angle2) < 0 )*/)
+ /*for right-hand traffic, exits should be to the right anyway to allow smooth turns, so leave this out until we find a counterexample :)*/
+ {
+ count_roundabout++;
+ /* As soon as we have an allowed one on this node,
+ * stop further counting for this node.
+ */
+ break;
+ }
+ candidate_way=candidate_way->next;
+ }
+ }
+
+ switch (level) {
+ case level_follow:
+ d=get_distance_str(nav, distance, type, 1);
+ return g_strdup_printf(_("Follow the road for the next %s"), d);
+ case level_soon:
+ return g_strdup(_("Enter the roundabout soon"));
+ case level_meters:
+ d = get_distance_str(nav, distance, attr_navigation_short, 0);
+ /* TRANSLATORS: %s is the distance to the roundabout */
+ ret = g_strdup_printf(_("Enter the roundabout %s"), d);
+ g_free(d);
+ return ret;
+ case level_connect:
+ return g_strdup(_("then enter the roundabout"));
+ case level_now:
+ /* TRANSLATORS: first arg. is the manieth exit, second arg. is the destination to follow */
+ return g_strdup_printf(_("Leave the roundabout at the %1$s %2$s"), get_exit_count_str(count_roundabout),
+ street_destination_announce);
+ default :
+ dbg(lvl_error,"unexpected announcement level %d", level);
+ return g_strdup_printf("internal error");
+ }
+ }
+
+ if (cmd->maneuver && cmd->maneuver->type) {
+ if (cmd->itm->next) {
+ if(type == attr_navigation_speech) {
+ /* In voice mode */
+ /* In Voice Mode only tell the street name in level_meters or in level_ if level 1 was skipped */
+ if (level == level_meters) {
+ /* we are close to the intersection */
+ cmd->itm->streetname_told = 1; /* remember to be checked when we turn */
+ tellstreetname = 1; /* Ok, so we tell the name of the street */
+ } else if (level == level_now) {
+ if(cmd->itm->streetname_told == 0) /* we are right at the intersection */
+ tellstreetname = 1;
+ else
+ cmd->itm->streetname_told = 0; /* reset just in case we come to the same street again */
+ } else if (level == level_connect) {
+ tellstreetname = 1;
+ }
+ } else
+ tellstreetname = 1;
+ }
+
+
+ switch (level) {
+ case level_soon :
+ d=g_strdup(_("soon"));
+ break;
+ case level_meters :
+ d=get_distance_str(nav, distance, attr_navigation_short, 0);
+ break;
+ case level_now :
+ d=g_strdup(_("now"));
+ break;
+ case level_connect :
+ d=g_strdup(_("then"));
+ break;
+ default :
+ d = g_strdup("");
+ break;
+ }
+
+ if (tellstreetname)
+ destination=navigation_item_destination(nav, cmd, itm, " ");
+ else destination = g_strdup("");
+
+ if (!(cmd->maneuver->merge_or_exit == mex_none )) {
+ char *exit_announce=NULL;
+
+ /* interchange or exit announcement shall be a long distance information only.
+ But if so, exit_label shall not be announced in case it is a substring
+ of destination info to avoid redundancy and not let the sentence become too long.
+ Otherwise, if there is no additional destination info, just say it at level_meters. */
+ if ((level == level_soon) || ((level == level_meters) && (!street_destination_announce && !destination))
+ || (type != attr_navigation_speech)) {
+ exit_announce = navigation_cmd_get_exit_announce(cmd, street_destination_announce);
+ }
+
+ switch (cmd->maneuver->merge_or_exit) {
+ case mex_merge_left:
+ case mex_merge_right:
+ if (cmd->maneuver->merge_or_exit == mex_merge_right) {
+ if (level == level_connect)
+ /* TRANSLATORS: the arg. is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included. */
+ instruction = g_strdup_printf(_("then merge%1$s|right"), destination);
+ else
+ /* TRANSLATORS: the first arg. is distance, the second is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included. */
+ instruction = g_strdup_printf(_("Merge %1$s%2$s|right"), d, destination);
+ } else {
+ if (level == level_connect)
+ /* TRANSLATORS: the arg. is the phrase 'onto ...'. Left merge, the stuff after | doesn't have to be included. */
+ instruction = g_strdup_printf(_("then merge%1$s|left"), destination);
+ else
+ /* TRANSLATORS: the first arg. is distance, the second is the phrase 'onto ...'. Left merge, the stuff after | doesn't have to be included. */
+ instruction = g_strdup_printf(_("Merge %1$s%2$s|left"), d, destination);
+ }
+ break;
+ case mex_exit_left:
+ case mex_exit_right:
+ direction = (cmd->maneuver->merge_or_exit == mex_exit_left) ?
+ g_strdup(_("on your left")) :
+ g_strdup(_("on your right"));
+ if (exit_announce)
+ /* TRANSLATORS: the first arg. is exit ref and/or name, the second is the direction of exit and the third is distance */
+ instruction = g_strdup_printf(_("Take exit %1$s %2$s %3$s"), exit_announce, direction, d);
+ else
+ /* TRANSLATORS: the first arg. is the direction of exit, the second is distance, the third is destination */
+ instruction = g_strdup_printf(_("Take the exit %1$s %2$s%3$s"), direction, d, destination);
+
+ break;
+ }
+
+ if (!instruction && exit_announce) {
+ /* TRANSLATORS: as in "Keep right at interchange 42 Greenmond-West" */
+ at = g_strdup_printf(" %1$s %2$s", cmd->maneuver->merge_or_exit == mex_interchange ? (_("at interchange")) :
+ (_( "at exit")),
+ exit_announce ? exit_announce : "");
+ }
+ g_free(exit_announce);
+ }
+ if (!instruction) {
+ if (!at)
+ at = g_strdup("");
+ switch (cmd->maneuver->type) {
+ case type_nav_straight :
+ if (level == level_connect)
+ /* TRANSLATORS: the arg. is where to do the maneuver */
+ instruction = g_strdup_printf(_("then continue straight%1$s"), at);
+ else
+ /* TRANSLATORS: the first arg. is distance, the second is where to do the maneuver, the third is destination */
+ instruction = g_strdup_printf(_("Continue straight %1$s%2$s%3$s"), d, at, destination);
+ break;
+ case type_nav_keep_right :
+ if (level == level_connect)
+ /* TRANSLATORS: the arg. is where to do the maneuver */
+ instruction = g_strdup_printf(_("then keep right%1$s"), at);
+ else
+ /* TRANSLATORS: the first arg. is distance, the second is where to do the maneuver, the third is destination */
+ instruction = g_strdup_printf(_("Keep right %1$s%2$s%3$s"), d, at, destination);
+ break;
+ case type_nav_keep_left :
+ if (level == level_connect)
+ /* TRANSLATORS: the arg. is where to do the maneuver */
+ instruction = g_strdup_printf(_("then keep left%1$s"), at);
+ else
+ /* TRANSLATORS: the first arg. is distance, the second is where to do the maneuver, the third is destination */
+ instruction = g_strdup_printf(_("Keep left %1$s%2$s%3$s"), d, at, destination);
+ break;
+ case type_nav_right_1 :
+ case type_nav_right_2 :
+ case type_nav_right_3 :
+ case type_nav_left_1 :
+ case type_nav_left_2 :
+ case type_nav_left_3 :
+ /* generic turn case */
+ switch (cmd->maneuver->type) {
+ case type_nav_right_1 :
+ case type_nav_right_2 :
+ case type_nav_right_3 :
+ /* TRANSLATORS: "right" as in "turn right" */
+ direction = g_strdup(_("right"));
+ if (level == level_now)
+ skip_roads = count_possible_turns(nav, cmd->prev ? cmd->prev->itm : nav->first, cmd->itm, 90);
+ else if (level == level_connect)
+ /* Robotaxi: todo - must tidy up skip_roads == -1 issue */
+ skip_roads = count_possible_turns(nav, itm->next ? itm->next : itm, cmd->itm, 90);
+ break;
+ case type_nav_left_1 :
+ case type_nav_left_2 :
+ case type_nav_left_3 :
+ /* TRANSLATORS: "left" as in "turn left" */
+ direction = g_strdup(_("left"));
+ if (level == level_now)
+ skip_roads = count_possible_turns(nav, cmd->prev ? cmd->prev->itm : nav->first, cmd->itm, -90);
+ else if (level == level_connect)
+ skip_roads = count_possible_turns(nav, itm->next ? itm->next : itm, cmd->itm, -90);
+ break;
+ default:
+ direction = g_strdup("");
+ break;
+ }
+ switch (cmd->maneuver->type) {
+ case type_nav_right_1 :
+ case type_nav_left_1 :
+ /* TRANSLATORS: as in "turn easily right" */
+ strength = g_strdup(_("easily "));
+ break;
+ case type_nav_right_3 :
+ case type_nav_left_3 :
+ /* TRANSLATORS: as in "turn strongly right" */
+ strength = g_strdup(_("strongly "));
+ break;
+ default:
+ strength = g_strdup("");
+ break;
+ }
+ /* Robotaxi: todo - must tidy up skip_roads == -1 issue */
+ if (skip_roads > 0) {
+ if (skip_roads < 6) {
+ if (level == level_connect)
+ instruction = g_strdup_printf(_("then take the %1$s road to the %2$s"), get_count_str(skip_roads+1), direction);
+ else
+ instruction = g_strdup_printf(_("Take the %1$s road to the %2$s"), get_count_str(skip_roads+1), direction);
+ /*and preserve skip_roads to signal that we already have an instruction*/
+ } else {
+ g_free(d);
+ d=g_strdup_printf(_("after %i roads"),skip_roads);
+ skip_roads = 0; /*signal an instruction still has to be created*/
+ }
+ }
+ /* cave: no else - may come from 'if (skip_roads)' above ! */
+ if (skip_roads <= 0) {
+ /* TRANSLATORS: the first arg. is strength, the second is direction, the third is distance, the fourth is destination */
+ instruction = g_strdup_printf(_("Turn %1$s%2$s %3$s%4$s"), strength, direction, d, destination);
+ }
+ break;
+ case type_nav_turnaround_left:
+ if (level == level_connect)
+ /* TRANSLATORS: Left U-turn, the stuff after | doesn't have to be included. */
+ instruction = g_strdup(_("then make a U-turn|left"));
+ else
+ /* TRANSLATORS: the arg. is distance. Left U-turn, the stuff after | doesn't have to be included. */
+ instruction = g_strdup_printf(_("Make a U-turn %1$s|left"), d);
+ break;
+ case type_nav_turnaround_right:
+ if (level == level_connect)
+ /* TRANSLATORS: Right U-turn, the stuff after | doesn't have to be included. */
+ instruction = g_strdup(_("then make a U-turn|right"));
+ else
+ /* TRANSLATORS: the arg. is distance. Right U-turn, the stuff after | doesn't have to be included. */
+ instruction = g_strdup_printf(_("Make a U-turn %1$s|right"), d);
+ break;
+ case type_nav_none:
+ /*An empty placeholder that we can use in the future for
+ * some motorway commands that are now suppressed but we
+ * can in some cases make it say here :
+ * 'follow destination blabla' without any further driving instructions,
+ * in cases where relevant destination info is available.
+ * Even if there is no driving command to be announced, in some cases
+ * there is an overhead roadsign in preparation of an upcoming road-split,
+ * and then we can give useful info to the driver.
+ *
+ * UNTESTED !
+ *
+ */
+ instruction = g_strdup(_("follow"));
+ break;
+ case type_nav_destination:
+ /* the old code used to clear the route destination when this was the only
+ * instruction left. Was that useful ?
+ * Should be tested with the old code what happens if the driver
+ * 'overshoots' the destination and the route destination is already cleared.
+ * I suppose it will now keep guiding the user to destination untill another one
+ * is set or a 'stop navigation' action is done using the gui.
+ */
+ if (level == level_connect)
+ instruction=g_strdup(_("then you have reached your destination."));
+ else
+ /* TRANSLATORS: the arg. is distance */
+ instruction=g_strdup_printf(_("You have reached your destination %s"), d);
+ break;
+ default:
+ dbg(lvl_error,"unhandled instruction");
+ break;
+ }
+ }
+ }
+ switch (level) {
+ case level_follow:
+ d=get_distance_str(nav, distance, type, 1);
+ ret=g_strdup_printf(_("Follow the road for the next %s"), d);
+ break;
+ case level_soon:
+ if (at) /* 'at' contains interchange or exit information that shall not be combined with street_destination_announce */
+ ret= g_strdup_printf(("%1$s %2$s"),instruction,"");
+ else
+ ret= g_strdup_printf(("%1$s %2$s"),instruction,street_destination_announce);
+ break;
+ case level_meters:
+ case level_connect:
+ case level_now:
+ ret= g_strdup_printf(("%1$s %2$s"),instruction,street_destination_announce);
+ break;
+ default :
+ ret= g_strdup_printf(("%1$s %2$s"),instruction,street_destination_announce);
+ dbg(lvl_error,"unexpected announcement level %d", level);
+ break;
+ }
+
+ g_free(at);
+ g_free(d);
+ g_free(destination);
+ g_free(direction);
+ g_free(instruction);
+ g_free(street_destination_announce);
+ g_free(strength);
+ return ret;
}
@@ -3564,122 +3458,123 @@ show_maneuver(struct navigation *nav, struct navigation_itm *itm, struct navigat
*
* @return An announcement that should be made
*/
-static char *
-show_next_maneuvers(struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd, enum attr_type type)
-{
- int distance = itm->dest_length-cmd->itm->dest_length; /* distance from e.g. current GPS position to next announced turn position */
- enum announcement_level level;
- char *ret,*buf,*next;
-
-
- if (type != attr_navigation_speech) {
- return show_maneuver(nav, itm, cmd, type, level_meters); /* We only accumulate maneuvers in speech navigation */
- }
-
-
- level = navigation_get_announce_level_cmd(nav, itm, cmd, distance-cmd->length);
-
- if (level > level_soon) {
- /* suppress the 'follow the road..' announcement, if the next 'soon' announcement is just a few meters away, so just quit */
- if ((distance - cmd->length) < (nav->announce[itm->way.item.type - route_item_first][2] + 2 * nav->announce[itm->way.item.type - route_item_first][0])) {
- /* a few meters away is defined by two times the distance of the 'now'-distance. */
- return g_strdup("");
- }
- }
- else if ((level == level_soon) && (itm->told == 1)) {
- /* suppress the 'soon' announcement, if the last announcement already concatenated this, so just quit */
- return g_strdup("");
- }
- else if ((level == level_meters) && (itm->told == 1)) {
- /* suppress the 'in xx meters..' announcement, if the 'soon' announcement is just a few meters away, so just quit */
- if ((distance - cmd->length) < (nav->announce[itm->way.item.type - route_item_first][1] + 2 * nav->announce[itm->way.item.type - route_item_first][0])) {
- /* a few meters away is defined by two times the distance of the 'now'-distance. */
- return g_strdup("");
- }
- }
-
- ret = show_maneuver(nav, itm, cmd, type, level);
-
- if (level > level_meters) {
- return ret; /* We only concatenate maneuvers that are close each other, so quit here */
- }
-
- if (cmd->next && cmd->itm) {
- /* determine the level of the command that comes immediately after that. */
- enum announcement_level nextlevel = navigation_get_announce_level(nav, cmd->itm->way.item.type, cmd->itm->dest_length - cmd->next->itm->dest_length);
-
- /* If this level starts with 1 or 0 concatenate the following announcement to the current: */
- if (nextlevel <= level_soon) {
- next = show_maneuver(nav, cmd->itm, cmd->next, type, level_connect);
- if (*next != '\0') /* is the second announcement not an empty string? */
- {
- cmd->itm->told = 1;
- buf = ret;
- ret = g_strdup_printf("%s, %s", buf, next); /* concatenate both announcements */
- g_free(buf);
- }
- g_free(next);
- }
+static char *show_next_maneuvers(struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd,
+ enum attr_type type) {
+ int distance = itm->dest_length
+ -cmd->itm->dest_length; /* distance from e.g. current GPS position to next announced turn position */
+ enum announcement_level level;
+ char *ret,*buf,*next;
+
+
+ if (type != attr_navigation_speech) {
+ return show_maneuver(nav, itm, cmd, type, level_meters); /* We only accumulate maneuvers in speech navigation */
+ }
+
+
+ level = navigation_get_announce_level_cmd(nav, itm, cmd, distance-cmd->length);
+
+ if (level > level_soon) {
+ /* suppress the 'follow the road..' announcement, if the next 'soon' announcement is just a few meters away, so just quit */
+ if ((distance - cmd->length) < (nav->announce[itm->way.item.type - route_item_first][2] + 2 *
+ nav->announce[itm->way.item.type - route_item_first][0])) {
+ /* a few meters away is defined by two times the distance of the 'now'-distance. */
+ return g_strdup("");
}
+ } else if ((level == level_soon) && (itm->told == 1)) {
+ /* suppress the 'soon' announcement, if the last announcement already concatenated this, so just quit */
+ return g_strdup("");
+ } else if ((level == level_meters) && (itm->told == 1)) {
+ /* suppress the 'in xx meters..' announcement, if the 'soon' announcement is just a few meters away, so just quit */
+ if ((distance - cmd->length) < (nav->announce[itm->way.item.type - route_item_first][1] + 2 *
+ nav->announce[itm->way.item.type - route_item_first][0])) {
+ /* a few meters away is defined by two times the distance of the 'now'-distance. */
+ return g_strdup("");
+ }
+ }
+
+ ret = show_maneuver(nav, itm, cmd, type, level);
+
+ if (level > level_meters) {
+ return ret; /* We only concatenate maneuvers that are close each other, so quit here */
+ }
+
+ if (cmd->next && cmd->itm) {
+ /* determine the level of the command that comes immediately after that. */
+ enum announcement_level nextlevel = navigation_get_announce_level(nav, cmd->itm->way.item.type,
+ cmd->itm->dest_length - cmd->next->itm->dest_length);
+
+ /* If this level starts with 1 or 0 concatenate the following announcement to the current: */
+ if (nextlevel <= level_soon) {
+ next = show_maneuver(nav, cmd->itm, cmd->next, type, level_connect);
+ if (*next != '\0') { /* is the second announcement not an empty string? */
+ cmd->itm->told = 1;
+ buf = ret;
+ ret = g_strdup_printf("%s, %s", buf, next); /* concatenate both announcements */
+ g_free(buf);
+ }
+ g_free(next);
+ }
+ }
- return ret;
+ return ret;
}
-static void
-navigation_call_callbacks(struct navigation *this_, int force_speech)
-{
- int distance, level = 0;
- void *p=this_;
- if (!this_->cmd_first)
- return;
- callback_list_call(this_->callback, 1, &p);
- dbg(lvl_debug,"force_speech=%d turn_around=%d turn_around_limit=%d\n", force_speech, this_->turn_around, this_->turn_around_limit);
- distance=this_->first->dest_length-this_->cmd_first->itm->dest_length;
- if (this_->turn_around_limit && this_->turn_around == this_->turn_around_limit) {
- dbg(lvl_debug,"distance=%d distance_turn=%d\n", distance, this_->distance_turn);
- while (distance > this_->distance_turn) {
- this_->level_last=4;
- level=4;
- force_speech=2;
- if (this_->distance_turn >= 500)
- this_->distance_turn*=2;
- else
- this_->distance_turn=500;
- }
- } else if (!this_->turn_around_limit || this_->turn_around == -this_->turn_around_limit+1) {
- this_->distance_turn=50;
- distance-=this_->cmd_first->length;
- level=navigation_get_announce_level_cmd(this_, this_->first, this_->cmd_first, distance);
- if (level < this_->level_last) {
- /* only tell if the level is valid for more than 3 seconds */
- int speed_distance=this_->first->speed*30/36;
- if (distance < speed_distance || navigation_get_announce_level_cmd(this_, this_->first, this_->cmd_first, distance-speed_distance) == level) {
- dbg(lvl_debug,"distance %d speed_distance %d\n",distance,speed_distance);
- dbg(lvl_debug,"level %d < %d\n", level, this_->level_last);
- this_->level_last=level;
- force_speech=3;
- }
- }
- if (!item_is_equal(this_->cmd_first->itm->way.item, this_->item_last)) {
- this_->item_last=this_->cmd_first->itm->way.item;
- if (this_->delay)
- this_->curr_delay=this_->delay;
- else
- force_speech=5;
- } else {
- if (this_->curr_delay) {
- this_->curr_delay--;
- if (!this_->curr_delay)
- force_speech=4;
- }
- }
- }
- if (force_speech) {
- this_->level_last=level;
- this_->curr_delay=0;
- dbg(lvl_debug,"force_speech=%d distance=%d level=%d type=0x%x\n", force_speech, distance, level, this_->first->way.item.type);
- callback_list_call(this_->callback_speech, 1, &p);
- }
+static void navigation_call_callbacks(struct navigation *this_, int force_speech) {
+ int distance, level = 0;
+ void *p=this_;
+ if (!this_->cmd_first)
+ return;
+ callback_list_call(this_->callback, 1, &p);
+ dbg(lvl_debug,"force_speech=%d turn_around=%d turn_around_limit=%d", force_speech, this_->turn_around,
+ this_->turn_around_limit);
+ distance=this_->first->dest_length-this_->cmd_first->itm->dest_length;
+ if (this_->turn_around_limit && this_->turn_around == this_->turn_around_limit) {
+ dbg(lvl_debug,"distance=%d distance_turn=%d", distance, this_->distance_turn);
+ while (distance > this_->distance_turn) {
+ this_->level_last=4;
+ level=4;
+ force_speech=2;
+ if (this_->distance_turn >= 500)
+ this_->distance_turn*=2;
+ else
+ this_->distance_turn=500;
+ }
+ } else if (!this_->turn_around_limit || this_->turn_around == -this_->turn_around_limit+1) {
+ this_->distance_turn=50;
+ distance-=this_->cmd_first->length;
+ level=navigation_get_announce_level_cmd(this_, this_->first, this_->cmd_first, distance);
+ if (level < this_->level_last) {
+ /* only tell if the level is valid for more than 3 seconds */
+ int speed_distance=this_->first->speed*30/36;
+ if (distance < speed_distance
+ || navigation_get_announce_level_cmd(this_, this_->first, this_->cmd_first, distance-speed_distance) == level) {
+ dbg(lvl_debug,"distance %d speed_distance %d",distance,speed_distance);
+ dbg(lvl_debug,"level %d < %d", level, this_->level_last);
+ this_->level_last=level;
+ force_speech=3;
+ }
+ }
+ if (!item_is_equal(this_->cmd_first->itm->way.item, this_->item_last)) {
+ this_->item_last=this_->cmd_first->itm->way.item;
+ if (this_->delay)
+ this_->curr_delay=this_->delay;
+ else
+ force_speech=5;
+ } else {
+ if (this_->curr_delay) {
+ this_->curr_delay--;
+ if (!this_->curr_delay)
+ force_speech=4;
+ }
+ }
+ }
+ if (force_speech) {
+ this_->level_last=level;
+ this_->curr_delay=0;
+ dbg(lvl_debug,"force_speech=%d distance=%d level=%d type=0x%x", force_speech, distance, level,
+ this_->first->way.item.type);
+ callback_list_call(this_->callback_speech, 1, &p);
+ }
}
/**
@@ -3697,45 +3592,44 @@ navigation_call_callbacks(struct navigation *this_, int force_speech)
* @param cancel If true, only cleanup (deallocation of objects) will be done and no maneuvers will be generated.
* If false, maneuvers will be generated.
*/
-static void
-navigation_update_done(struct navigation *this_, int cancel) {
- int incr = 0;
- struct map_rect *mr = this_->route_mr;
- struct attr nav_status;
-
- if (this_->idle_ev)
- event_remove_idle(this_->idle_ev);
- if (this_->idle_cb)
- callback_destroy(this_->idle_cb);
- this_->idle_ev=NULL;
- this_->idle_cb=NULL;
-
- if (!cancel) {
- nav_status.type = attr_nav_status;
- nav_status.u.num = status_routing;
- if (!(this_->status_int & status_has_sitem))
- navigation_destroy_itms_cmds(this_, NULL);
- else {
- if (!(this_->status_int & status_has_ritem)) {
- navigation_itm_new(this_, NULL);
- make_maneuvers(this_,this_->route);
- }
- calculate_dest_distance(this_, incr);
- profile(0,"end");
- navigation_call_callbacks(this_, FALSE);
- }
- navigation_set_attr(this_, &nav_status);
- }
- /*
- * In order to ensure that route_mr holds either NULL or a valid pointer at any given time,
- * always pass a copy of it to map_rect_destroy() and set route_mr to NULL prior to calling
- * map_rect_destroy(). The reason is that map_rect_destroy() for a route map may indirectly
- * call navigation_update(), which will modify the same members. For the same reason,
- * status_int must be reset before the call to map_rect_destroy().
- */
- this_->status_int = status_none;
- this_->route_mr = NULL;
- map_rect_destroy(mr);
+static void navigation_update_done(struct navigation *this_, int cancel) {
+ int incr = 0;
+ struct map_rect *mr = this_->route_mr;
+ struct attr nav_status;
+
+ if (this_->idle_ev)
+ event_remove_idle(this_->idle_ev);
+ if (this_->idle_cb)
+ callback_destroy(this_->idle_cb);
+ this_->idle_ev=NULL;
+ this_->idle_cb=NULL;
+
+ if (!cancel) {
+ nav_status.type = attr_nav_status;
+ nav_status.u.num = status_routing;
+ if (!(this_->status_int & status_has_sitem))
+ navigation_destroy_itms_cmds(this_, NULL);
+ else {
+ if (!(this_->status_int & status_has_ritem)) {
+ navigation_itm_new(this_, NULL);
+ make_maneuvers(this_,this_->route);
+ }
+ calculate_dest_distance(this_, incr);
+ profile(0,"end");
+ navigation_call_callbacks(this_, FALSE);
+ }
+ navigation_set_attr(this_, &nav_status);
+ }
+ /*
+ * In order to ensure that route_mr holds either NULL or a valid pointer at any given time,
+ * always pass a copy of it to map_rect_destroy() and set route_mr to NULL prior to calling
+ * map_rect_destroy(). The reason is that map_rect_destroy() for a route map may indirectly
+ * call navigation_update(), which will modify the same members. For the same reason,
+ * status_int must be reset before the call to map_rect_destroy().
+ */
+ this_->status_int = status_none;
+ this_->route_mr = NULL;
+ map_rect_destroy(mr);
}
/**
@@ -3745,63 +3639,62 @@ navigation_update_done(struct navigation *this_, int cancel) {
* {@code route_mr} member. After processing completes, the {@code route_mr} member will no longer
* be valid.
*/
-static void
-navigation_update_idle(struct navigation *this_) {
- int count = 100; /* Maximum number of items retrieved in one run of this function.
+static void navigation_update_idle(struct navigation *this_) {
+ int count = 100; /* Maximum number of items retrieved in one run of this function.
* This should be set low enough for each pass to complete in less
* than a second even on low-performance devices. */
- struct item *ritem; /* Holds an item from the route map */
- struct item *sitem; /* Holds the item from the actual map which corresponds to ritem */
- struct attr street_item, street_direction;
- struct navigation_itm *itm;
-
- /* Do not use the route_path_flag_cancel flag here because it is also used whenever
- * destinations or waypoints change, not just when the user stops navigation altogether
- */
- if (!route_has_graph(this_->route)) {
- navigation_update_done(this_, 1);
- return;
- }
-
- while (count > 0) {
- if (!(ritem = map_rect_get_item(this_->route_mr))) {
- this_->status_int &= ~(status_has_ritem);
- break;
- }
- this_->status_int |= status_has_ritem;
- if ((ritem)->type == type_route_start && this_->turn_around > -this_->turn_around_limit+1)
- this_->turn_around--;
- if ((ritem)->type == type_route_start_reverse && this_->turn_around < this_->turn_around_limit)
- this_->turn_around++;
- if ((ritem)->type != type_street_route)
- continue;
- if ((!(this_->status_int & status_has_sitem)) && item_attr_get(ritem, attr_street_item, &street_item)) {
- this_->status_int |= status_has_sitem;
- if (!item_attr_get(ritem, attr_direction, &street_direction))
- street_direction.u.num = 0;
- sitem = street_item.u.item;
- dbg(lvl_debug,"sitem=%p\n", sitem);
- itm = item_hash_lookup(this_->hash, sitem);
- dbg(lvl_info,"itm for item with id (0x%x,0x%x) is %p\n", sitem->id_hi, sitem->id_lo, itm);
- if (itm && itm->way.dir != street_direction.u.num) {
- dbg(lvl_info,"wrong direction\n");
- itm = NULL;
- }
- navigation_destroy_itms_cmds(this_, itm);
- if (itm) {
- navigation_itm_update(itm, ritem);
- break;
- }
- dbg(lvl_debug,"not on track\n");
- }
- navigation_itm_new(this_, ritem);
- count--;
- }
- if (count > 0) {
- /* if count > 0, one of the break conditions in the loop was true and we're done */
- navigation_update_done(this_, 0);
- return;
- }
+ struct item *ritem; /* Holds an item from the route map */
+ struct item *sitem; /* Holds the item from the actual map which corresponds to ritem */
+ struct attr street_item, street_direction;
+ struct navigation_itm *itm;
+
+ /* Do not use the route_path_flag_cancel flag here because it is also used whenever
+ * destinations or waypoints change, not just when the user stops navigation altogether
+ */
+ if (!route_has_graph(this_->route)) {
+ navigation_update_done(this_, 1);
+ return;
+ }
+
+ while (count > 0) {
+ if (!(ritem = map_rect_get_item(this_->route_mr))) {
+ this_->status_int &= ~(status_has_ritem);
+ break;
+ }
+ this_->status_int |= status_has_ritem;
+ if ((ritem)->type == type_route_start && this_->turn_around > -this_->turn_around_limit+1)
+ this_->turn_around--;
+ if ((ritem)->type == type_route_start_reverse && this_->turn_around < this_->turn_around_limit)
+ this_->turn_around++;
+ if ((ritem)->type != type_street_route)
+ continue;
+ if ((!(this_->status_int & status_has_sitem)) && item_attr_get(ritem, attr_street_item, &street_item)) {
+ this_->status_int |= status_has_sitem;
+ if (!item_attr_get(ritem, attr_direction, &street_direction))
+ street_direction.u.num = 0;
+ sitem = street_item.u.item;
+ dbg(lvl_debug,"sitem=%p", sitem);
+ itm = item_hash_lookup(this_->hash, sitem);
+ dbg(lvl_info,"itm for item with id (0x%x,0x%x) is %p", sitem->id_hi, sitem->id_lo, itm);
+ if (itm && itm->way.dir != street_direction.u.num) {
+ dbg(lvl_info,"wrong direction");
+ itm = NULL;
+ }
+ navigation_destroy_itms_cmds(this_, itm);
+ if (itm) {
+ navigation_itm_update(itm, ritem);
+ break;
+ }
+ dbg(lvl_debug,"not on track");
+ }
+ navigation_itm_new(this_, ritem);
+ count--;
+ }
+ if (count > 0) {
+ /* if count > 0, one of the break conditions in the loop was true and we're done */
+ navigation_update_done(this_, 0);
+ return;
+ }
}
/**
@@ -3815,87 +3708,82 @@ navigation_update_idle(struct navigation *this_) {
* @param route The route
* @param attr The route status attribute
*/
-static void
-navigation_update(struct navigation *this_, struct route *route, struct attr *attr)
-{
- struct map *map;
- struct attr vehicleprofile;
- struct attr nav_status;
-
- if (attr->type != attr_route_status)
- return;
-
- dbg(lvl_debug,"enter\n");
-
- nav_status.type = attr_nav_status;
- switch(attr->u.num) {
- case route_status_not_found:
- nav_status.u.num = status_no_route;
- break;
- case route_status_no_destination:
- nav_status.u.num = status_no_destination;
- break;
- case route_status_destination_set:
- nav_status.u.num = status_position_wait;
- break;
- case route_status_building_path:
- case route_status_building_graph:
- case route_status_path_done_new:
- case route_status_path_done_incremental:
- nav_status.u.num = (this_->nav_status >= status_recalculating) ? status_recalculating : status_calculating;
- }
- navigation_set_attr(this_, &nav_status);
-
- if (attr->u.num == route_status_no_destination || attr->u.num == route_status_not_found || attr->u.num == route_status_path_done_new)
- navigation_flush(this_);
- if (attr->u.num != route_status_path_done_new && attr->u.num != route_status_path_done_incremental) {
- if (this_->status_int & status_busy) {
- navigation_update_done(this_, 1);
- }
- return;
- }
-
- if (! this_->route)
- return;
- map=route_get_map(this_->route);
- if (! map)
- return;
- this_->route_mr = map_rect_new(map, NULL);
- if (! this_->route_mr)
- return;
- if (route_get_attr(route, attr_vehicleprofile, &vehicleprofile, NULL))
- this_->vehicleprofile=vehicleprofile.u.vehicleprofile;
- else
- this_->vehicleprofile=NULL;
- dbg(lvl_debug,"enter\n");
-
- this_->status_int = status_busy;
- if (route_get_flags(this_->route) & route_path_flag_async) {
- this_->idle_cb = callback_new_1(callback_cast(navigation_update_idle), this_);
- this_->idle_ev = event_add_idle(50, this_->idle_cb);
- } else {
- this_->idle_ev = NULL;
- this_->idle_cb = NULL;
- while (this_->status_int & status_busy)
- navigation_update_idle(this_);
- }
+static void navigation_update(struct navigation *this_, struct route *route, struct attr *attr) {
+ struct map *map;
+ struct attr vehicleprofile;
+ struct attr nav_status;
+
+ if (attr->type != attr_route_status)
+ return;
+
+ dbg(lvl_debug,"enter");
+
+ nav_status.type = attr_nav_status;
+ switch(attr->u.num) {
+ case route_status_not_found:
+ nav_status.u.num = status_no_route;
+ break;
+ case route_status_no_destination:
+ nav_status.u.num = status_no_destination;
+ break;
+ case route_status_destination_set:
+ nav_status.u.num = status_position_wait;
+ break;
+ case route_status_building_path:
+ case route_status_building_graph:
+ case route_status_path_done_new:
+ case route_status_path_done_incremental:
+ nav_status.u.num = (this_->nav_status >= status_recalculating) ? status_recalculating : status_calculating;
+ }
+ navigation_set_attr(this_, &nav_status);
+
+ if (attr->u.num == route_status_no_destination || attr->u.num == route_status_not_found
+ || attr->u.num == route_status_path_done_new)
+ navigation_flush(this_);
+ if (attr->u.num != route_status_path_done_new && attr->u.num != route_status_path_done_incremental) {
+ if (this_->status_int & status_busy) {
+ navigation_update_done(this_, 1);
+ }
+ return;
+ }
+
+ if (! this_->route)
+ return;
+ map=route_get_map(this_->route);
+ if (! map)
+ return;
+ this_->route_mr = map_rect_new(map, NULL);
+ if (! this_->route_mr)
+ return;
+ if (route_get_attr(route, attr_vehicleprofile, &vehicleprofile, NULL))
+ this_->vehicleprofile=vehicleprofile.u.vehicleprofile;
+ else
+ this_->vehicleprofile=NULL;
+ dbg(lvl_debug,"enter");
+
+ this_->status_int = status_busy;
+ if (route_get_flags(this_->route) & route_path_flag_async) {
+ this_->idle_cb = callback_new_1(callback_cast(navigation_update_idle), this_);
+ this_->idle_ev = event_add_idle(50, this_->idle_cb);
+ } else {
+ this_->idle_ev = NULL;
+ this_->idle_cb = NULL;
+ while (this_->status_int & status_busy)
+ navigation_update_idle(this_);
+ }
}
-static void
-navigation_flush(struct navigation *this_)
-{
- navigation_destroy_itms_cmds(this_, NULL);
+static void navigation_flush(struct navigation *this_) {
+ navigation_destroy_itms_cmds(this_, NULL);
}
-void
-navigation_destroy(struct navigation *this_)
-{
- navigation_flush(this_);
- item_hash_destroy(this_->hash);
- callback_list_destroy(this_->callback);
- callback_list_destroy(this_->callback_speech);
- g_free(this_);
+void navigation_destroy(struct navigation *this_) {
+ navigation_flush(this_);
+ item_hash_destroy(this_->hash);
+ callback_list_destroy(this_->callback);
+ callback_list_destroy(this_->callback_speech);
+ g_free(this_);
}
/**
@@ -3922,22 +3810,20 @@ navigation_destroy(struct navigation *this_)
*
* @return true on success, false on failure
*/
-int
-navigation_register_callback(struct navigation *this_, enum attr_type type, struct callback *cb)
-{
- struct attr attr_cbl;
-
- if (type == attr_navigation_speech)
- callback_list_add(this_->callback_speech, cb);
- else if (type == attr_navigation_long)
- callback_list_add(this_->callback, cb);
- else {
- if (navigation_get_attr(this_, attr_callback_list, &attr_cbl, NULL))
- callback_list_add(attr_cbl.u.callback_list, cb);
- else
- return 0;
- }
- return 1;
+int navigation_register_callback(struct navigation *this_, enum attr_type type, struct callback *cb) {
+ struct attr attr_cbl;
+
+ if (type == attr_navigation_speech)
+ callback_list_add(this_->callback_speech, cb);
+ else if (type == attr_navigation_long)
+ callback_list_add(this_->callback, cb);
+ else {
+ if (navigation_get_attr(this_, attr_callback_list, &attr_cbl, NULL))
+ callback_list_add(attr_cbl.u.callback_list, cb);
+ else
+ return 0;
+ }
+ return 1;
}
/**
@@ -3952,343 +3838,332 @@ navigation_register_callback(struct navigation *this_, enum attr_type type, stru
* @param type The attribute type
* @param cb The callback function
*/
-void
-navigation_unregister_callback(struct navigation *this_, enum attr_type type, struct callback *cb)
-{
- struct attr attr_cbl;
-
- if (type == attr_navigation_speech)
- callback_list_remove(this_->callback_speech, cb);
- else if (type == attr_navigation_long)
- callback_list_remove(this_->callback, cb);
- else if (navigation_get_attr(this_, attr_callback_list, &attr_cbl, NULL))
- callback_list_remove(attr_cbl.u.callback_list, cb);
+void navigation_unregister_callback(struct navigation *this_, enum attr_type type, struct callback *cb) {
+ struct attr attr_cbl;
+
+ if (type == attr_navigation_speech)
+ callback_list_remove(this_->callback_speech, cb);
+ else if (type == attr_navigation_long)
+ callback_list_remove(this_->callback, cb);
+ else if (navigation_get_attr(this_, attr_callback_list, &attr_cbl, NULL))
+ callback_list_remove(attr_cbl.u.callback_list, cb);
}
struct map *
-navigation_get_map(struct navigation *this_)
-{
- struct attr *attrs[5];
- struct attr type,navigation,data,description;
- type.type=attr_type;
- type.u.str="navigation";
- navigation.type=attr_navigation;
- navigation.u.navigation=this_;
- data.type=attr_data;
- data.u.str="";
- description.type=attr_description;
- description.u.str="Navigation";
-
- attrs[0]=&type;
- attrs[1]=&navigation;
- attrs[2]=&data;
- attrs[3]=&description;
- attrs[4]=NULL;
- if (! this_->map)
- this_->map=map_new(NULL, attrs);
- return this_->map;
+navigation_get_map(struct navigation *this_) {
+ struct attr *attrs[5];
+ struct attr type,navigation,data,description;
+ type.type=attr_type;
+ type.u.str="navigation";
+ navigation.type=attr_navigation;
+ navigation.u.navigation=this_;
+ data.type=attr_data;
+ data.u.str="";
+ description.type=attr_description;
+ description.u.str="Navigation";
+
+ attrs[0]=&type;
+ attrs[1]=&navigation;
+ attrs[2]=&data;
+ attrs[3]=&description;
+ attrs[4]=NULL;
+ if (! this_->map)
+ this_->map=map_new(NULL, attrs);
+ return this_->map;
}
struct map_priv {
- struct navigation *navigation;
+ struct navigation *navigation;
};
struct map_rect_priv {
- struct navigation *nav;
- struct navigation_command *cmd;
- struct navigation_command *cmd_next;
- struct navigation_itm *itm;
- struct navigation_itm *itm_next;
- struct navigation_itm *cmd_itm;
- struct navigation_itm *cmd_itm_next;
- struct item item;
- enum attr_type attr_next;
- int ccount;
- int debug_idx;
- struct navigation_way *ways;
- int show_all;
- char *str;
+ struct navigation *nav;
+ struct navigation_command *cmd;
+ struct navigation_command *cmd_next;
+ struct navigation_itm *itm;
+ struct navigation_itm *itm_next;
+ struct navigation_itm *cmd_itm;
+ struct navigation_itm *cmd_itm_next;
+ struct item item;
+ enum attr_type attr_next;
+ int ccount;
+ int debug_idx;
+ struct navigation_way *ways;
+ int show_all;
+ char *str;
};
-static int
-navigation_map_item_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *this=priv_data;
- if (this->ccount || ! count)
- return 0;
- *c=this->itm->start;
- this->ccount=1;
- return 1;
+static int navigation_map_item_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *this=priv_data;
+ if (this->ccount || ! count)
+ return 0;
+ *c=this->itm->start;
+ this->ccount=1;
+ return 1;
}
-static void
-navigation_map_item_coord_rewind(void *priv_data)
-{
- struct map_rect_priv *this=priv_data;
- this->ccount=0;
+static void navigation_map_item_coord_rewind(void *priv_data) {
+ struct map_rect_priv *this=priv_data;
+ this->ccount=0;
}
-static int
-navigation_map_item_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *this_=priv_data;
- struct navigation_command *cmd=this_->cmd;
- struct navigation_maneuver *maneuver = NULL;
- struct navigation_itm *itm=this_->itm;
- struct navigation_itm *prev=itm->prev;
- char *exit_announce=NULL;
- attr->type=attr_type;
-
- if (this_->str) {
- g_free(this_->str);
- this_->str=NULL;
- }
-
- if (cmd) {
- if (cmd->itm != itm)
- cmd=NULL;
- }
- if (cmd && cmd->maneuver)
- maneuver = cmd->maneuver;
- switch(attr_type) {
- case attr_level:
- if (cmd) {
- int distance=this_->cmd_itm->dest_length-cmd->itm->dest_length;
- distance=round_distance(distance);
- attr->u.num=navigation_get_announce_level(this_->nav, this_->cmd_itm->way.item.type, distance-cmd->length);
- return 1;
- }
- return 0;
- case attr_navigation_short:
- this_->attr_next=attr_navigation_long;
- if (cmd) {
- this_->str=attr->u.str=show_next_maneuvers(this_->nav, this_->cmd_itm, cmd, attr_type);
- return 1;
- }
- return 0;
- case attr_navigation_long:
- this_->attr_next=attr_navigation_long_exact;
- if (cmd) {
- this_->str=attr->u.str=show_next_maneuvers(this_->nav, this_->cmd_itm, cmd, attr_type);
- return 1;
- }
- return 0;
- case attr_navigation_long_exact:
- this_->attr_next=attr_navigation_speech;
- if (cmd) {
- this_->str=attr->u.str=show_next_maneuvers(this_->nav, this_->cmd_itm, cmd, attr_type);
- return 1;
- }
- return 0;
- case attr_navigation_speech:
- this_->attr_next=attr_length;
- if (cmd) {
- this_->str=attr->u.str=show_next_maneuvers(this_->nav, this_->cmd_itm, this_->cmd, attr_type);
- return 1;
- }
- return 0;
- case attr_length:
- this_->attr_next=attr_time;
- if (cmd) {
- attr->u.num=this_->cmd_itm->dest_length-cmd->itm->dest_length;
- return 1;
- }
- return 0;
- case attr_time:
- this_->attr_next=attr_destination_length;
- if (cmd) {
- attr->u.num=this_->cmd_itm->dest_time-cmd->itm->dest_time;
- return 1;
- }
- return 0;
- case attr_destination_length:
- attr->u.num=itm->dest_length;
- this_->attr_next=attr_destination_time;
- return 1;
- case attr_destination_time:
- attr->u.num=itm->dest_time;
- this_->attr_next=attr_street_name;
- return 1;
- case attr_street_name:
- attr->u.str=itm->way.name;
- this_->attr_next=attr_street_name_systematic;
- if (attr->u.str){
- return 1;}
- return 0;
- case attr_street_name_systematic:
- attr->u.str=itm->way.name_systematic;
- this_->attr_next=attr_street_destination;
- if (attr->u.str){
- return 1;}
- return 0;
- case attr_street_destination:
- this_->attr_next=attr_name;
- if (cmd && itm->way.destination && itm->way.destination->destination)
- this_->str=attr->u.str=select_announced_destinations(cmd);
- else attr->u.str=NULL;
- if (attr->u.str){
- return 1;}
- return 0;
-
- case attr_name:
- /* attr_name returns exit_ref and exit_label if available,
- * preceded by the word 'exit' or 'interchange'.
- *
- * Otherwise it returns street name and name_systematic, if available
- *
- * FIXME should a new attr. be defined for this, and if yes, which ?
- */
- this_->attr_next=attr_debug;
- attr->u.str=NULL;
- exit_announce = navigation_cmd_get_exit_announce(cmd, NULL);
- if (exit_announce && maneuver)
- /* TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East" */
- this_->str=attr->u.str=g_strdup_printf("%s %s", maneuver->merge_or_exit & mex_interchange ? (_("Interchange")) : (_("Exit")),
- exit_announce ? exit_announce : "");
- else if (itm->way.name || itm->way.name_systematic)
- this_->str=attr->u.str=g_strdup_printf("%s %s",
- itm->way.name ? itm->way.name : "",itm->way.name_systematic ? itm->way.name_systematic : "");
- if (attr->u.str){
- return 1;}
- return 0;
- case attr_debug:
- switch(this_->debug_idx) {
- case 0:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("angle:%d (- %d)", itm->way.angle2, itm->angle_end);
- return 1;
- case 1:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("item type:%s", item_to_name(itm->way.item.type));
- return 1;
- case 2:
- this_->debug_idx++;
- if (cmd) {
- this_->str=attr->u.str=g_strdup_printf("delta:%d", cmd->delta);
- return 1;
- }
- case 3:
- this_->debug_idx++;
- if (prev) {
- this_->str=attr->u.str=g_strdup_printf("prev street_name:%s", prev->way.name);
- return 1;
- }
- case 4:
- this_->debug_idx++;
- if (prev) {
- this_->str=attr->u.str=g_strdup_printf("prev street_name_systematic:%s", prev->way.name_systematic);
- return 1;
- }
- case 5:
- this_->debug_idx++;
- if (prev) {
- this_->str=attr->u.str=g_strdup_printf("prev angle:(%d -) %d", prev->way.angle2, prev->angle_end);
- return 1;
- }
- case 6:
- this_->debug_idx++;
- this_->ways=itm->way.next;
- if (prev) {
- this_->str=attr->u.str=g_strdup_printf("prev item type:%s", item_to_name(prev->way.item.type));
- return 1;
- }
- case 7:
- if (this_->ways && prev) {
- this_->str=attr->u.str=g_strdup_printf("other item angle:%d delta:%d flags:%d dir:%d type:%s id:(0x%x,0x%x)", this_->ways->angle2, angle_delta(prev->angle_end, this_->ways->angle2), this_->ways->flags, this_->ways->dir, item_to_name(this_->ways->item.type), this_->ways->item.id_hi, this_->ways->item.id_lo);
- this_->ways=this_->ways->next;
- return 1;
- }
- this_->debug_idx++;
- case 8:
- this_->debug_idx++;
- if (prev) {
- struct navigation_maneuver *maneuver = NULL;
- maneuver_required2(this_->nav, prev, itm, &maneuver);
- this_->str=attr->u.str=g_strdup_printf("type: %s, is_complex_t_junction: %d, is_same_street: %d, is_unambiguous: %d, merge_or_exit: %d, old_cat: %d, new_cat: %d, max_cat: %d, num_options: %d, num_similar_ways: %d, num_new_motorways: %d, num_other_ways: %d, left: %d, right: %d, delta: %d",
- item_to_name(maneuver->type),
- maneuver->is_complex_t_junction,
- maneuver->is_same_street,
- maneuver->is_unambiguous,
- maneuver->merge_or_exit,
- maneuver->old_cat,
- maneuver->new_cat,
- maneuver->max_cat,
- maneuver->num_options,
- maneuver->num_similar_ways,
- maneuver->num_new_motorways,
- maneuver->num_other_ways,
- maneuver->left,
- maneuver->right,
- maneuver->delta);
- return 1;
- }
-
- default:
- this_->attr_next=attr_none;
- return 0;
- }
- case attr_any:
- while (this_->attr_next != attr_none) {
- if (navigation_map_item_attr_get(priv_data, this_->attr_next, attr))
- return 1;
- }
- return 0;
- default:
- attr->type=attr_none;
- return 0;
- }
+static int navigation_map_item_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *this_=priv_data;
+ struct navigation_command *cmd=this_->cmd;
+ struct navigation_maneuver *maneuver = NULL;
+ struct navigation_itm *itm=this_->itm;
+ struct navigation_itm *prev=itm->prev;
+ char *exit_announce=NULL;
+ attr->type=attr_type;
+
+ if (this_->str) {
+ g_free(this_->str);
+ this_->str=NULL;
+ }
+
+ if (cmd) {
+ if (cmd->itm != itm)
+ cmd=NULL;
+ }
+ if (cmd && cmd->maneuver)
+ maneuver = cmd->maneuver;
+ switch(attr_type) {
+ case attr_level:
+ if (cmd) {
+ int distance=this_->cmd_itm->dest_length-cmd->itm->dest_length;
+ distance=round_distance(distance);
+ attr->u.num=navigation_get_announce_level(this_->nav, this_->cmd_itm->way.item.type, distance-cmd->length);
+ return 1;
+ }
+ return 0;
+ case attr_navigation_short:
+ this_->attr_next=attr_navigation_long;
+ if (cmd) {
+ this_->str=attr->u.str=show_next_maneuvers(this_->nav, this_->cmd_itm, cmd, attr_type);
+ return 1;
+ }
+ return 0;
+ case attr_navigation_long:
+ this_->attr_next=attr_navigation_long_exact;
+ if (cmd) {
+ this_->str=attr->u.str=show_next_maneuvers(this_->nav, this_->cmd_itm, cmd, attr_type);
+ return 1;
+ }
+ return 0;
+ case attr_navigation_long_exact:
+ this_->attr_next=attr_navigation_speech;
+ if (cmd) {
+ this_->str=attr->u.str=show_next_maneuvers(this_->nav, this_->cmd_itm, cmd, attr_type);
+ return 1;
+ }
+ return 0;
+ case attr_navigation_speech:
+ this_->attr_next=attr_length;
+ if (cmd) {
+ this_->str=attr->u.str=show_next_maneuvers(this_->nav, this_->cmd_itm, this_->cmd, attr_type);
+ return 1;
+ }
+ return 0;
+ case attr_length:
+ this_->attr_next=attr_time;
+ if (cmd) {
+ attr->u.num=this_->cmd_itm->dest_length-cmd->itm->dest_length;
+ return 1;
+ }
+ return 0;
+ case attr_time:
+ this_->attr_next=attr_destination_length;
+ if (cmd) {
+ attr->u.num=this_->cmd_itm->dest_time-cmd->itm->dest_time;
+ return 1;
+ }
+ return 0;
+ case attr_destination_length:
+ attr->u.num=itm->dest_length;
+ this_->attr_next=attr_destination_time;
+ return 1;
+ case attr_destination_time:
+ attr->u.num=itm->dest_time;
+ this_->attr_next=attr_street_name;
+ return 1;
+ case attr_street_name:
+ attr->u.str=itm->way.name;
+ this_->attr_next=attr_street_name_systematic;
+ if (attr->u.str) {
+ return 1;
+ }
+ return 0;
+ case attr_street_name_systematic:
+ attr->u.str=itm->way.name_systematic;
+ this_->attr_next=attr_street_destination;
+ if (attr->u.str) {
+ return 1;
+ }
+ return 0;
+ case attr_street_destination:
+ this_->attr_next=attr_name;
+ if (cmd && itm->way.destination && itm->way.destination->destination)
+ this_->str=attr->u.str=select_announced_destinations(cmd);
+ else attr->u.str=NULL;
+ if (attr->u.str) {
+ return 1;
+ }
+ return 0;
+
+ case attr_name:
+ /* attr_name returns exit_ref and exit_label if available,
+ * preceded by the word 'exit' or 'interchange'.
+ *
+ * Otherwise it returns street name and name_systematic, if available
+ *
+ * FIXME should a new attr. be defined for this, and if yes, which ?
+ */
+ this_->attr_next=attr_debug;
+ attr->u.str=NULL;
+ exit_announce = navigation_cmd_get_exit_announce(cmd, NULL);
+ if (exit_announce && maneuver)
+ /* TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East" */
+ this_->str=attr->u.str=g_strdup_printf("%s %s",
+ maneuver->merge_or_exit & mex_interchange ? (_("Interchange")) : (_("Exit")),
+ exit_announce ? exit_announce : "");
+ else if (itm->way.name || itm->way.name_systematic)
+ this_->str=attr->u.str=g_strdup_printf("%s %s",
+ itm->way.name ? itm->way.name : "",itm->way.name_systematic ? itm->way.name_systematic : "");
+ if (attr->u.str) {
+ return 1;
+ }
+ return 0;
+ case attr_debug:
+ switch(this_->debug_idx) {
+ case 0:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("angle:%d (- %d)", itm->way.angle2, itm->angle_end);
+ return 1;
+ case 1:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("item type:%s", item_to_name(itm->way.item.type));
+ return 1;
+ case 2:
+ this_->debug_idx++;
+ if (cmd) {
+ this_->str=attr->u.str=g_strdup_printf("delta:%d", cmd->delta);
+ return 1;
+ }
+ case 3:
+ this_->debug_idx++;
+ if (prev) {
+ this_->str=attr->u.str=g_strdup_printf("prev street_name:%s", prev->way.name);
+ return 1;
+ }
+ case 4:
+ this_->debug_idx++;
+ if (prev) {
+ this_->str=attr->u.str=g_strdup_printf("prev street_name_systematic:%s", prev->way.name_systematic);
+ return 1;
+ }
+ case 5:
+ this_->debug_idx++;
+ if (prev) {
+ this_->str=attr->u.str=g_strdup_printf("prev angle:(%d -) %d", prev->way.angle2, prev->angle_end);
+ return 1;
+ }
+ case 6:
+ this_->debug_idx++;
+ this_->ways=itm->way.next;
+ if (prev) {
+ this_->str=attr->u.str=g_strdup_printf("prev item type:%s", item_to_name(prev->way.item.type));
+ return 1;
+ }
+ case 7:
+ if (this_->ways && prev) {
+ this_->str=attr->u.str=g_strdup_printf("other item angle:%d delta:%d flags:%d dir:%d type:%s id:(0x%x,0x%x)",
+ this_->ways->angle2, angle_delta(prev->angle_end, this_->ways->angle2), this_->ways->flags, this_->ways->dir,
+ item_to_name(this_->ways->item.type), this_->ways->item.id_hi, this_->ways->item.id_lo);
+ this_->ways=this_->ways->next;
+ return 1;
+ }
+ this_->debug_idx++;
+ case 8:
+ this_->debug_idx++;
+ if (prev) {
+ struct navigation_maneuver *maneuver = NULL;
+ maneuver_required2(this_->nav, prev, itm, &maneuver);
+ this_->str=attr->u.str=
+ g_strdup_printf("type: %s, is_complex_t_junction: %d, is_same_street: %d, is_unambiguous: %d, merge_or_exit: %d, old_cat: %d, new_cat: %d, max_cat: %d, num_options: %d, num_similar_ways: %d, num_new_motorways: %d, num_other_ways: %d, left: %d, right: %d, delta: %d",
+ item_to_name(maneuver->type),
+ maneuver->is_complex_t_junction,
+ maneuver->is_same_street,
+ maneuver->is_unambiguous,
+ maneuver->merge_or_exit,
+ maneuver->old_cat,
+ maneuver->new_cat,
+ maneuver->max_cat,
+ maneuver->num_options,
+ maneuver->num_similar_ways,
+ maneuver->num_new_motorways,
+ maneuver->num_other_ways,
+ maneuver->left,
+ maneuver->right,
+ maneuver->delta);
+ return 1;
+ }
+
+ default:
+ this_->attr_next=attr_none;
+ return 0;
+ }
+ case attr_any:
+ while (this_->attr_next != attr_none) {
+ if (navigation_map_item_attr_get(priv_data, this_->attr_next, attr))
+ return 1;
+ }
+ return 0;
+ default:
+ attr->type=attr_none;
+ return 0;
+ }
}
-static void
-navigation_map_item_attr_rewind(void *priv_data)
-{
- struct map_rect_priv *priv = priv_data;
- priv->debug_idx=0;
- priv->attr_next=attr_navigation_short;
+static void navigation_map_item_attr_rewind(void *priv_data) {
+ struct map_rect_priv *priv = priv_data;
+ priv->debug_idx=0;
+ priv->attr_next=attr_navigation_short;
}
static struct item_methods navigation_map_item_methods = {
- navigation_map_item_coord_rewind,
- navigation_map_item_coord_get,
- navigation_map_item_attr_rewind,
- navigation_map_item_attr_get,
+ navigation_map_item_coord_rewind,
+ navigation_map_item_coord_get,
+ navigation_map_item_attr_rewind,
+ navigation_map_item_attr_get,
};
-static void
-navigation_map_destroy(struct map_priv *priv)
-{
- g_free(priv);
+static void navigation_map_destroy(struct map_priv *priv) {
+ g_free(priv);
}
-static void
-navigation_map_rect_init(struct map_rect_priv *priv)
-{
- priv->cmd_next=priv->nav->cmd_first;
- priv->cmd_itm_next=priv->itm_next=priv->nav->first;
+static void navigation_map_rect_init(struct map_rect_priv *priv) {
+ priv->cmd_next=priv->nav->cmd_first;
+ priv->cmd_itm_next=priv->itm_next=priv->nav->first;
}
-static struct map_rect_priv *
-navigation_map_rect_new(struct map_priv *priv, struct map_selection *sel)
-{
- struct navigation *nav=priv->navigation;
- struct map_rect_priv *ret=g_new0(struct map_rect_priv, 1);
- ret->nav=nav;
- navigation_map_rect_init(ret);
- ret->item.meth=&navigation_map_item_methods;
- ret->item.priv_data=ret;
+static struct map_rect_priv *navigation_map_rect_new(struct map_priv *priv, struct map_selection *sel) {
+ struct navigation *nav=priv->navigation;
+ struct map_rect_priv *ret=g_new0(struct map_rect_priv, 1);
+ ret->nav=nav;
+ navigation_map_rect_init(ret);
+ ret->item.meth=&navigation_map_item_methods;
+ ret->item.priv_data=ret;
#ifdef DEBUG
- ret->show_all=1;
+ ret->show_all=1;
#endif
- return ret;
+ return ret;
}
-static void
-navigation_map_rect_destroy(struct map_rect_priv *priv)
-{
- g_free(priv->str);
- g_free(priv);
+static void navigation_map_rect_destroy(struct map_rect_priv *priv) {
+ g_free(priv->str);
+ g_free(priv);
}
/**
@@ -4311,60 +4186,59 @@ navigation_map_rect_destroy(struct map_rect_priv *priv)
*
* @return The item, or NULL if there are no more items in the map rectangle
*/
-static struct item *
-navigation_map_get_item(struct map_rect_priv *priv)
-{
- struct item *ret=&priv->item;
- if (!priv->itm_next)
- return NULL;
- priv->itm=priv->itm_next;
- priv->cmd=priv->cmd_next;
- priv->cmd_itm=priv->cmd_itm_next;
- if (!priv->cmd)
- return NULL;
- if (!priv->show_all && priv->itm->prev != NULL)
- priv->itm=priv->cmd->itm;
- priv->itm_next=priv->itm->next;
- if (priv->itm->prev)
- ret->type=type_nav_none;
- else
- ret->type=type_nav_position;
- if (priv->cmd->itm == priv->itm) {
- priv->cmd_itm_next=priv->cmd->itm;
- priv->cmd_next=priv->cmd->next;
- if (priv->cmd_itm_next && !priv->cmd_itm_next->next)
- ret->type=type_nav_destination; /* FIXME: do we need to set that here? The generic case should catch that now... */
- else if (priv->cmd->maneuver && ((priv->cmd->maneuver->type != type_nav_none) || (priv->cmd->maneuver->merge_or_exit & (mex_merge | mex_exit)))) {
- /* if maneuver type or merge_or_exit is set, use these values */
- /* FIXME: make decision to use merge_or_exit context-dependent */
- switch (priv->cmd->maneuver->merge_or_exit) {
- case mex_merge_left:
- ret->type=type_nav_merge_left;
- break;
- case mex_merge_right:
- ret->type=type_nav_merge_right;
- break;
- case mex_exit_left:
- ret->type=type_nav_exit_left;
- break;
- case mex_exit_right:
- ret->type=type_nav_exit_right;
- break;
- default:
- /* exit or merge without a direction should never happen,
- * mex_intersection results in a regular instruction,
- * thus all these are handled by the default case,
- * which is to return the type field */
- ret->type = priv->cmd->maneuver->type;
- }
- } /* else if priv->cmd->maneuver ... */
- } /* if priv->cmd->itm == priv->itm */
- navigation_map_item_coord_rewind(priv);
- navigation_map_item_attr_rewind(priv);
-
- ret->id_lo=priv->itm->dest_count;
- dbg(lvl_debug,"type=%d\n", ret->type);
- return ret;
+static struct item *navigation_map_get_item(struct map_rect_priv *priv) {
+ struct item *ret=&priv->item;
+ if (!priv->itm_next)
+ return NULL;
+ priv->itm=priv->itm_next;
+ priv->cmd=priv->cmd_next;
+ priv->cmd_itm=priv->cmd_itm_next;
+ if (!priv->cmd)
+ return NULL;
+ if (!priv->show_all && priv->itm->prev != NULL)
+ priv->itm=priv->cmd->itm;
+ priv->itm_next=priv->itm->next;
+ if (priv->itm->prev)
+ ret->type=type_nav_none;
+ else
+ ret->type=type_nav_position;
+ if (priv->cmd->itm == priv->itm) {
+ priv->cmd_itm_next=priv->cmd->itm;
+ priv->cmd_next=priv->cmd->next;
+ if (priv->cmd_itm_next && !priv->cmd_itm_next->next)
+ ret->type=type_nav_destination; /* FIXME: do we need to set that here? The generic case should catch that now... */
+ else if (priv->cmd->maneuver && ((priv->cmd->maneuver->type != type_nav_none)
+ || (priv->cmd->maneuver->merge_or_exit & (mex_merge | mex_exit)))) {
+ /* if maneuver type or merge_or_exit is set, use these values */
+ /* FIXME: make decision to use merge_or_exit context-dependent */
+ switch (priv->cmd->maneuver->merge_or_exit) {
+ case mex_merge_left:
+ ret->type=type_nav_merge_left;
+ break;
+ case mex_merge_right:
+ ret->type=type_nav_merge_right;
+ break;
+ case mex_exit_left:
+ ret->type=type_nav_exit_left;
+ break;
+ case mex_exit_right:
+ ret->type=type_nav_exit_right;
+ break;
+ default:
+ /* exit or merge without a direction should never happen,
+ * mex_intersection results in a regular instruction,
+ * thus all these are handled by the default case,
+ * which is to return the type field */
+ ret->type = priv->cmd->maneuver->type;
+ }
+ } /* else if priv->cmd->maneuver ... */
+ } /* if priv->cmd->itm == priv->itm */
+ navigation_map_item_coord_rewind(priv);
+ navigation_map_item_attr_rewind(priv);
+
+ ret->id_lo=priv->itm->dest_count;
+ dbg(lvl_debug,"type=%d", ret->type);
+ return ret;
}
/**
@@ -4386,85 +4260,77 @@ navigation_map_get_item(struct map_rect_priv *priv)
*
* @return The item, or NULL if an item with the ID specified was not found in the map rectangle
*/
-static struct item *
-navigation_map_get_item_byid(struct map_rect_priv *priv, int id_hi, int id_lo)
-{
- struct item *ret;
- navigation_map_rect_init(priv);
- while ((ret=navigation_map_get_item(priv))) {
- if (ret->id_hi == id_hi && ret->id_lo == id_lo)
- return ret;
- }
- return NULL;
+static struct item *navigation_map_get_item_byid(struct map_rect_priv *priv, int id_hi, int id_lo) {
+ struct item *ret;
+ navigation_map_rect_init(priv);
+ while ((ret=navigation_map_get_item(priv))) {
+ if (ret->id_hi == id_hi && ret->id_lo == id_lo)
+ return ret;
+ }
+ return NULL;
}
static struct map_methods navigation_map_meth = {
- projection_mg,
- "utf-8",
- navigation_map_destroy,
- navigation_map_rect_new,
- navigation_map_rect_destroy,
- navigation_map_get_item,
- navigation_map_get_item_byid,
- NULL,
- NULL,
- NULL,
+ projection_mg,
+ "utf-8",
+ navigation_map_destroy,
+ navigation_map_rect_new,
+ navigation_map_rect_destroy,
+ navigation_map_get_item,
+ navigation_map_get_item_byid,
+ NULL,
+ NULL,
+ NULL,
};
-static struct map_priv *
-navigation_map_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct map_priv *ret;
- struct attr *navigation_attr;
+static struct map_priv *navigation_map_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *ret;
+ struct attr *navigation_attr;
- navigation_attr=attr_search(attrs, NULL, attr_navigation);
- if (! navigation_attr)
- return NULL;
- ret=g_new0(struct map_priv, 1);
- *meth=navigation_map_meth;
- ret->navigation=navigation_attr->u.navigation;
+ navigation_attr=attr_search(attrs, NULL, attr_navigation);
+ if (! navigation_attr)
+ return NULL;
+ ret=g_new0(struct map_priv, 1);
+ *meth=navigation_map_meth;
+ ret->navigation=navigation_attr->u.navigation;
- return ret;
+ return ret;
}
-void
-navigation_set_route(struct navigation *this_, struct route *route)
-{
- struct attr callback;
- if (!this_->route_cb)
- this_->route_cb=callback_new_attr_1(callback_cast(navigation_update), attr_route_status, this_);
- callback.type=attr_callback;
- callback.u.callback=this_->route_cb;
- if (this_->route)
- route_remove_attr(this_->route, &callback);
- this_->route=route;
- if (this_->route) {
- struct attr route_status;
- route_add_attr(this_->route, &callback);
- if (route_get_attr(this_->route, attr_route_status, &route_status, NULL))
- navigation_update(this_, this_->route, &route_status);
- }
+void navigation_set_route(struct navigation *this_, struct route *route) {
+ struct attr callback;
+ if (!this_->route_cb)
+ this_->route_cb=callback_new_attr_1(callback_cast(navigation_update), attr_route_status, this_);
+ callback.type=attr_callback;
+ callback.u.callback=this_->route_cb;
+ if (this_->route)
+ route_remove_attr(this_->route, &callback);
+ this_->route=route;
+ if (this_->route) {
+ struct attr route_status;
+ route_add_attr(this_->route, &callback);
+ if (route_get_attr(this_->route, attr_route_status, &route_status, NULL))
+ navigation_update(this_, this_->route, &route_status);
+ }
}
-void
-navigation_init(void)
-{
- plugin_register_category_map("navigation", navigation_map_new);
+void navigation_init(void) {
+ plugin_register_category_map("navigation", navigation_map_new);
}
struct object_func navigation_func = {
- attr_navigation,
- (object_func_new)navigation_new,
- (object_func_get_attr)navigation_get_attr,
- (object_func_iter_new)navit_object_attr_iter_new,
- (object_func_iter_destroy)navit_object_attr_iter_destroy,
- (object_func_set_attr)navigation_set_attr,
- (object_func_add_attr)navit_object_add_attr,
- (object_func_remove_attr)navit_object_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)navigation_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_navigation,
+ (object_func_new)navigation_new,
+ (object_func_get_attr)navigation_get_attr,
+ (object_func_iter_new)navit_object_attr_iter_new,
+ (object_func_iter_destroy)navit_object_attr_iter_destroy,
+ (object_func_set_attr)navigation_set_attr,
+ (object_func_add_attr)navit_object_add_attr,
+ (object_func_remove_attr)navit_object_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)navigation_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/navigation.h b/navit/navigation.h
index 28faa015c..0651dbc79 100644
--- a/navit/navigation.h
+++ b/navit/navigation.h
@@ -22,7 +22,17 @@
#define FEET_PER_METER 3.2808399
#define FEET_PER_MILE 5280
-#define METERS_PER_MILE 1609
+#define KILOMETERS_TO_MILES 0.62137119 /* Kilometers to miles */
+
+/* It appears that distances to be displayed, such as distances to
+ * maneuvers, are in meters. Multiply that by METERS_PER_MILE and you
+ * have miles. */
+#define METERS_TO_MILES (KILOMETERS_TO_MILES/1000.0) /* Meters to miles */
+/* #define METERS_PER_MILE (1000.0/KILOMETERS_TO_MILES) */
+
+/* Meters per second to kilometers per hour. GPSD delivers speeds in
+ * meters per second. */
+#define MPS_TO_KPH 3.6
#ifdef __cplusplus
extern "C" {
diff --git a/navit/navit.c b/navit/navit.c
index 13e33653b..875a20c82 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -44,6 +44,7 @@
#include "coord.h"
#include "point.h"
#include "transform.h"
+#include "traffic.h"
#include "param.h"
#include "menu.h"
#include "graphics.h"
@@ -96,17 +97,17 @@
//! The vehicle used for navigation.
struct navit_vehicle {
- int follow;
- /*! Limit of the follow counter. See navit_add_vehicle */
- int follow_curr;
- /*! Deprecated : follow counter itself. When it reaches 'update' counts, map is recentered*/
- struct coord coord;
- int dir;
- int speed;
- struct coord last; /*< Position of the last update of this vehicle */
- struct vehicle *vehicle;
- struct attr callback;
- int animate_cursor;
+ int follow;
+ /*! Limit of the follow counter. See navit_add_vehicle */
+ int follow_curr;
+ /*! Deprecated : follow counter itself. When it reaches 'update' counts, map is recentered*/
+ struct coord coord;
+ int dir;
+ int speed;
+ struct coord last; /*< Position of the last update of this vehicle */
+ struct vehicle *vehicle;
+ struct attr callback;
+ int animate_cursor;
};
struct navit_audio_plugin {
@@ -117,87 +118,88 @@ struct navit_audio_plugin {
struct navit {
- NAVIT_OBJECT
- struct attr self;
- GList *mapsets;
- GList *layouts;
- struct gui *gui;
- struct layout *layout_current;
- struct graphics *gra;
- struct action *action;
- struct transformation *trans, *trans_cursor;
- struct compass *compass;
- struct route *route;
- struct navigation *navigation;
- struct speech *speech;
- struct tracking *tracking;
- int ready;
- struct window *win;
- struct displaylist *displaylist;
- int tracking_flag;
- int orientation;
- int recentdest_count;
- int osd_configuration;
- GList *audio_plugins;
- GList *vehicles;
- GList *windows_items;
- struct navit_audio_plugin *audio;
- struct navit_vehicle *vehicle;
- struct callback_list *attr_cbl;
- struct callback *nav_speech_cb, *roadbook_callback, *popup_callback, *route_cb, *progress_cb;
- struct datawindow *roadbook_window;
- struct map *former_destination;
- struct point pressed, last, current;
- int button_pressed,moved,popped,zoomed;
- int center_timeout;
- int autozoom_secs;
- int autozoom_min;
- int autozoom_max;
- int autozoom_active;
- int autozoom_paused;
- struct event_timeout *button_timeout, *motion_timeout;
- struct callback *motion_timeout_callback;
- int ignore_button;
- int ignore_graphics_events;
- struct log *textfile_debug_log;
- struct pcoord destination;
- int destination_valid;
- int blocked; /**< Whether draw operations are currently blocked. This can be a combination of the
+ NAVIT_OBJECT
+ struct attr self;
+ GList *mapsets;
+ GList *layouts;
+ struct gui *gui;
+ char *default_layout_name; /*!< The default layout indicated by the config file (if any) */
+ struct layout *layout_current; /*!< The current layout theme used to display the map */
+ struct graphics *gra;
+ struct action *action;
+ struct transformation *trans, *trans_cursor;
+ struct compass *compass;
+ struct route *route;
+ struct navigation *navigation;
+ struct speech *speech;
+ struct tracking *tracking;
+ int ready;
+ struct window *win;
+ struct displaylist *displaylist;
+ int tracking_flag;
+ int orientation;
+ int recentdest_count;
+ int osd_configuration;
+ GList *vehicles;
+ GList *windows_items;
+ struct navit_vehicle *vehicle;
+ struct callback_list *attr_cbl;
+ struct callback *nav_speech_cb, *roadbook_callback, *popup_callback, *route_cb, *progress_cb;
+ struct datawindow *roadbook_window;
+ struct map *former_destination;
+ struct point pressed, last, current;
+ int button_pressed,moved,popped,zoomed;
+ int center_timeout;
+ int autozoom_secs;
+ int autozoom_min;
+ int autozoom_max;
+ int autozoom_active;
+ int autozoom_paused;
+ struct event_timeout *button_timeout, *motion_timeout;
+ struct callback *motion_timeout_callback;
+ int ignore_button;
+ int ignore_graphics_events;
+ struct log *textfile_debug_log;
+ struct pcoord destination;
+ int destination_valid;
+ GList *audio_plugins;
+ struct navit_audio_plugin *audio;
+ int blocked; /**< Whether draw operations are currently blocked. This can be a combination of the
following flags:
1: draw operations are blocked
2: draw operations are pending, requiring a redraw once draw operations are unblocked */
- int w,h;
- int drag_bitmap;
- int use_mousewheel;
- struct messagelist *messages;
- struct callback *resize_callback,*button_callback,*motion_callback,*predraw_callback;
- struct vehicleprofile *vehicleprofile;
- GList *vehicleprofiles;
- int pitch;
- int follow_cursor;
- int prevTs;
- int graphics_flags;
- int zoom_min, zoom_max;
- int radius;
- struct bookmarks *bookmarks;
- int flags;
- /* 1=No graphics ok */
- /* 2=No gui ok */
- int border;
- int imperial;
- int waypoints_flag;
- struct coord_geo center;
- int auto_switch; /*auto switching between day/night layout enabled ?*/
+ int w,h;
+ int drag_bitmap;
+ int use_mousewheel;
+ struct messagelist *messages;
+ struct callback *resize_callback,*button_callback,*motion_callback,*predraw_callback;
+ struct vehicleprofile *vehicleprofile;
+ GList *vehicleprofiles;
+ int pitch;
+ int follow_cursor;
+ int prevTs;
+ int graphics_flags;
+ int zoom_min, zoom_max;
+ int radius;
+ struct bookmarks *bookmarks;
+ int flags;
+ /* 1=No graphics ok */
+ /* 2=No gui ok */
+ int border;
+ int imperial;
+ int waypoints_flag;
+ struct coord_geo center;
+ int auto_switch; /*auto switching between day/night layout enabled ?*/
};
struct gui *main_loop_gui;
struct attr_iter {
- void *iter;
- union {
- GList *list;
- struct mapset_handle *mapset_handle;
- } u;
+ void *iter;
+ union {
+ GList *list;
+ struct mapset_handle *mapset_handle;
+ } u;
};
static void navit_vehicle_update_position(struct navit *this_, struct navit_vehicle *nv);
@@ -212,32 +214,161 @@ static void navit_cmd_set_center_cursor(struct navit *this_);
static void navit_cmd_announcer_toggle(struct navit *this_);
static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv);
static int navit_set_vehicleprofile(struct navit *this_, struct vehicleprofile *vp);
-static void navit_cmd_switch_layout_day_night(struct navit *this_, char *function, struct attr **in, struct attr ***out, int valid);
+static void navit_cmd_switch_layout_day_night(struct navit *this_, char *function, struct attr **in, struct attr ***out,
+ int valid);
struct object_func navit_func;
struct navit *global_navit;
-void
-navit_add_mapset(struct navit *this_, struct mapset *ms)
-{
- this_->mapsets = g_list_append(this_->mapsets, ms);
+void navit_add_mapset(struct navit *this_, struct mapset *ms) {
+ this_->mapsets = g_list_append(this_->mapsets, ms);
}
+/**
+ * @brief Get the current mapset
+ *
+ * @param this_ The navit instance
+ *
+ * @return A pointer to the current mapset
+ */
struct mapset *
-navit_get_mapset(struct navit *this_)
-{
- if(this_->mapsets){
- return this_->mapsets->data;
- } else {
- dbg(lvl_error,"No mapsets enabled! Is it on purpose? Navit can't draw a map. Please check your navit.xml\n");
- }
- return NULL;
+navit_get_mapset(struct navit *this_) {
+ if(this_->mapsets) {
+ return this_->mapsets->data;
+ } else {
+ dbg(lvl_error,"No mapsets enabled! Is it on purpose? Navit can't draw a map. Please check your navit.xml");
+ }
+ return NULL;
+}
+
+/**
+ * @brief Get the search result map (and create it if it does not exist)
+ *
+ * @param this_ The navit instance
+ *
+ * @return A pointer to the map named "search_results" or NULL if there wasa failure
+ */
+struct map *navit_get_search_results_map(struct navit *this_) {
+
+ struct mapset *ms;
+ struct map *map;
+
+ ms=navit_get_mapset(this_);
+
+ if(!ms)
+ return NULL;
+
+ map=mapset_get_map_by_name(ms, "search_results");
+ if(!map) {
+ struct attr *attrs[10], attrmap;
+ enum attr_type types[]= {attr_position_longitude,attr_position_latitude,attr_label,attr_none};
+ int i;
+
+ attrs[0]=g_new0(struct attr,1);
+ attrs[0]->type=attr_type;
+ attrs[0]->u.str="csv";
+
+ attrs[1]=g_new0(struct attr,1);
+ attrs[1]->type=attr_name;
+ attrs[1]->u.str="search_results";
+
+ attrs[2]=g_new0(struct attr,1);
+ attrs[2]->type=attr_charset;
+ attrs[2]->u.str="utf-8";
+
+ attrs[3]=g_new0(struct attr,1);
+ attrs[3]->type=attr_item_type;
+ attrs[3]->u.num=type_found_item;
+
+ attrs[4]=g_new0(struct attr,1);
+ attrs[4]->type=attr_attr_types;
+ attrs[4]->u.attr_types=types;
+ attrs[5]=NULL;
+
+ attrmap.type=attr_map;
+ map=attrmap.u.map=map_new(NULL,attrs);
+ if(map)
+ mapset_add_attr(ms,&attrmap);
+
+ for(i=0; attrs[i]; i++)
+ g_free(attrs[i]);
+ }
+ return map;
+}
+
+/**
+ * @brief Populate a map containing one or more search result points
+ *
+ * These search results will be displayed as an overlay on the top of the geographic map.
+ *
+ * @warning Each call to this function will replace currently displayed results, it will not add to them
+ *
+ * @param this_ The navit instance
+ * @param search_results A GList storing {@code struct lcoord} elements to display on the result map
+ * If this argument in NULL, all existing results will be removed from the map
+ * @param[in,out] coord_rect An optional rectangular zone that will be extended to contain all result points
+ * or NULL if no zone needs to be computed
+ * @return The number of results actually added to the map
+ */
+int navit_populate_search_results_map(struct navit *this_, GList *search_results, struct coord_rect *r) {
+ struct map *map;
+ struct map_rect *mr;
+ struct item *item;
+ GList *curr_result = search_results;
+ int count;
+ char *name_label;
+
+ map = navit_get_search_results_map(this_);
+ if(!map)
+ return 0;
+
+ mr = map_rect_new(map, NULL);
+
+ if(!mr)
+ return 0;
+
+ /* Clean the map */
+ while((item = map_rect_get_item(mr))!=NULL) {
+ item_type_set(item,type_none);
+ }
+
+ if(!search_results) {
+ map_rect_destroy(mr);
+ dbg(lvl_warning,"NULL result table - only map clean up is done.");
+ return 0;
+ }
+
+ /* Populate the map with search results*/
+ for(curr_result = search_results, count=0; curr_result; curr_result=g_list_next(curr_result)) {
+ struct lcoord *point = curr_result->data;
+ struct item* it;
+ if(point->label==NULL)
+ continue;
+ dbg(lvl_info,"%s",point->label);
+ it=map_rect_create_item(mr,type_found_item);
+ if(it) {
+ struct attr a;
+ item_coord_set(it, &(point->c), 1, change_mode_modify);
+ a.type=attr_label;
+ name_label = g_strdup(point->label);
+ square_shape_str(name_label);
+ a.u.str=name_label;
+ item_attr_set(it, &a, change_mode_modify);
+ if (r) {
+ if(!count++)
+ r->lu=r->rl=point->c;
+ else
+ coord_rect_extend(r,&(point->c));
+ }
+ }
+ }
+ map_rect_destroy(mr);
+ return count;
}
struct tracking *
-navit_get_tracking(struct navit *this_)
-{
- return this_->tracking;
+navit_get_tracking(struct navit *this_) {
+ return this_->tracking;
}
/**
@@ -250,151 +381,129 @@ navit_get_tracking(struct navit *this_)
* destination.txt, bookmark.txt, ...)
*
*/
-char*
-navit_get_user_data_directory(int create) {
- char *dir;
- dir = getenv("NAVIT_USER_DATADIR");
- if (create && !file_exists(dir)) {
- dbg(lvl_debug,"creating dir %s\n", dir);
- if (file_mkdir(dir,0)) {
- dbg(lvl_error,"failed creating dir %s\n", dir);
- return NULL;
- }
- }
- return dir;
+char* navit_get_user_data_directory(int create) {
+ char *dir;
+ dir = getenv("NAVIT_USER_DATADIR");
+ if (create && !file_exists(dir)) {
+ dbg(lvl_debug,"creating dir %s", dir);
+ if (file_mkdir(dir,0)) {
+ dbg(lvl_error,"failed creating dir %s", dir);
+ return NULL;
+ }
+ }
+ return dir;
}
-void
-navit_draw_async(struct navit *this_, int async)
-{
+void navit_draw_async(struct navit *this_, int async) {
- if (this_->blocked) {
- this_->blocked |= 2;
- return;
- }
- transform_setup_source_rect(this_->trans);
- graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL, this_->graphics_flags|1);
+ if (this_->blocked) {
+ this_->blocked |= 2;
+ return;
+ }
+ transform_setup_source_rect(this_->trans);
+ graphics_draw(this_->gra, this_->displaylist, this_->mapsets->data, this_->trans, this_->layout_current, async, NULL,
+ this_->graphics_flags|1);
}
-void
-navit_draw(struct navit *this_)
-{
- if (this_->ready == 3)
- navit_draw_async(this_, 0);
+void navit_draw(struct navit *this_) {
+ if (this_->ready == 3)
+ navit_draw_async(this_, 0);
}
-int
-navit_get_ready(struct navit *this_)
-{
- return this_->ready;
+int navit_get_ready(struct navit *this_) {
+ return this_->ready;
}
-void
-navit_draw_displaylist(struct navit *this_)
-{
- if (this_->ready == 3)
- graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, this_->graphics_flags|1);
+void navit_draw_displaylist(struct navit *this_) {
+ if (this_->ready == 3)
+ graphics_displaylist_draw(this_->gra, this_->displaylist, this_->trans, this_->layout_current, this_->graphics_flags|1);
}
-static void
-navit_map_progress(struct navit *this_)
-{
- struct map *map;
- struct mapset *ms;
- struct mapset_handle *msh;
- struct attr attr;
- struct point p;
- if (this_->ready != 3)
- return;
- p.x=10;
- p.y=32;
-
- ms=this_->mapsets->data;
- msh=mapset_open(ms);
- while (msh && (map=mapset_next(msh, 0))) {
- if (map_get_attr(map, attr_progress, &attr, NULL)) {
- char *str=g_strdup_printf("%s ",attr.u.str);
- graphics_draw_mode(this_->gra, draw_mode_begin);
- graphics_draw_text_std(this_->gra, 16, str, &p);
- g_free(str);
- p.y+=32;
- graphics_draw_mode(this_->gra, draw_mode_end);
- }
- }
- mapset_close(msh);
+static void navit_map_progress(struct navit *this_) {
+ struct map *map;
+ struct mapset *ms;
+ struct mapset_handle *msh;
+ struct attr attr;
+ struct point p;
+ if (this_->ready != 3)
+ return;
+ p.x=10;
+ p.y=32;
+
+ ms=this_->mapsets->data;
+ msh=mapset_open(ms);
+ while (msh && (map=mapset_next(msh, 0))) {
+ if (map_get_attr(map, attr_progress, &attr, NULL)) {
+ char *str=g_strdup_printf("%s ",attr.u.str);
+ graphics_draw_mode(this_->gra, draw_mode_begin);
+ graphics_draw_text_std(this_->gra, 16, str, &p);
+ g_free(str);
+ p.y+=32;
+ graphics_draw_mode(this_->gra, draw_mode_end);
+ }
+ }
+ mapset_close(msh);
}
-static void
-navit_redraw_route(struct navit *this_, struct route *route, struct attr *attr)
-{
- int updated;
- if (attr->type != attr_route_status)
- return;
- updated=attr->u.num;
- if (this_->ready != 3)
- return;
- if (updated != route_status_path_done_new)
- return;
- if (this_->vehicle) {
- if (this_->vehicle->follow_curr == 1)
- return;
- if (this_->vehicle->follow_curr <= this_->vehicle->follow)
- this_->vehicle->follow_curr=this_->vehicle->follow;
- }
- navit_draw(this_);
+static void navit_redraw_route(struct navit *this_, struct route *route, struct attr *attr) {
+ int updated;
+ if (attr->type != attr_route_status)
+ return;
+ updated=attr->u.num;
+ if (this_->ready != 3)
+ return;
+ if (updated != route_status_path_done_new)
+ return;
+ if (this_->vehicle) {
+ if (this_->vehicle->follow_curr == 1)
+ return;
+ if (this_->vehicle->follow_curr <= this_->vehicle->follow)
+ this_->vehicle->follow_curr=this_->vehicle->follow;
+ }
+ navit_draw(this_);
}
-void
-navit_handle_resize(struct navit *this_, int w, int h)
-{
- struct map_selection sel;
- int callback=(this_->ready == 1);
- this_->ready |= 2;
- memset(&sel, 0, sizeof(sel));
- this_->w=w;
- this_->h=h;
- sel.u.p_rect.rl.x=w;
- sel.u.p_rect.rl.y=h;
- transform_set_screen_selection(this_->trans, &sel);
- graphics_init(this_->gra);
- graphics_set_rect(this_->gra, &sel.u.p_rect);
- if (callback)
- callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_);
- if (this_->ready == 3)
- navit_draw_async(this_, 1);
+void navit_handle_resize(struct navit *this_, int w, int h) {
+ struct map_selection sel;
+ int callback=(this_->ready == 1);
+ this_->ready |= 2;
+ memset(&sel, 0, sizeof(sel));
+ this_->w=w;
+ this_->h=h;
+ sel.u.p_rect.rl.x=w;
+ sel.u.p_rect.rl.y=h;
+ transform_set_screen_selection(this_->trans, &sel);
+ graphics_init(this_->gra);
+ graphics_set_rect(this_->gra, &sel.u.p_rect);
+ if (callback)
+ callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_);
+ if (this_->ready == 3)
+ navit_draw_async(this_, 1);
}
-static void
-navit_resize(void *data, int w, int h)
-{
- struct navit *this=data;
- if (!this->ignore_graphics_events)
- navit_handle_resize(this, w, h);
+static void navit_resize(void *data, int w, int h) {
+ struct navit *this=data;
+ if (!this->ignore_graphics_events)
+ navit_handle_resize(this, w, h);
}
-int
-navit_get_width(struct navit *this_)
-{
- return this_->w;
+int navit_get_width(struct navit *this_) {
+ return this_->w;
}
-int
-navit_get_height(struct navit *this_)
-{
- return this_->h;
+int navit_get_height(struct navit *this_) {
+ return this_->h;
}
-static void
-navit_popup(void *data)
-{
- struct navit *this_=data;
- popup(this_, 1, &this_->pressed);
- this_->button_timeout=NULL;
- this_->popped=1;
+static void navit_popup(void *data) {
+ struct navit *this_=data;
+ popup(this_, 1, &this_->pressed);
+ this_->button_timeout=NULL;
+ this_->popped=1;
}
@@ -412,242 +521,219 @@ navit_popup(void *data)
* @param this_ The navit instance
* @return {@code true} if the caller should ignore the button event, {@code false} if it should handle it
*/
-int
-navit_ignore_button(struct navit *this_)
-{
- if (this_->ignore_button)
- return 1;
- this_->ignore_button=1;
- return 0;
+int navit_ignore_button(struct navit *this_) {
+ if (this_->ignore_button)
+ return 1;
+ this_->ignore_button=1;
+ return 0;
}
-void
-navit_ignore_graphics_events(struct navit *this_, int ignore)
-{
- this_->ignore_graphics_events=ignore;
+void navit_ignore_graphics_events(struct navit *this_, int ignore) {
+ this_->ignore_graphics_events=ignore;
}
-static int
-navit_restrict_to_range(int value, int min, int max){
- if (value>max) {
- value = max;
- }
- if (value<min) {
- value = min;
- }
- return value;
+static int navit_restrict_to_range(int value, int min, int max) {
+ if (value>max) {
+ value = max;
+ }
+ if (value<min) {
+ value = min;
+ }
+ return value;
}
-static void
-navit_restrict_map_center_to_world_boundingbox(struct transformation *tr, struct coord *new_center){
- new_center->x = navit_restrict_to_range(new_center->x, WORLD_BOUNDINGBOX_MIN_X, WORLD_BOUNDINGBOX_MAX_X);
- new_center->y = navit_restrict_to_range(new_center->y, WORLD_BOUNDINGBOX_MIN_Y, WORLD_BOUNDINGBOX_MAX_Y);
+static void navit_restrict_map_center_to_world_boundingbox(struct transformation *tr, struct coord *new_center) {
+ new_center->x = navit_restrict_to_range(new_center->x, WORLD_BOUNDINGBOX_MIN_X, WORLD_BOUNDINGBOX_MAX_X);
+ new_center->y = navit_restrict_to_range(new_center->y, WORLD_BOUNDINGBOX_MIN_Y, WORLD_BOUNDINGBOX_MAX_Y);
}
/**
* @brief Change map center position by translating from "old" to "new".
*/
-static void
-update_transformation(struct transformation *tr, struct point *old, struct point *new)
-{
- /* Code for rotation was removed in rev. 5252; see Trac #1078. */
- struct coord coord_old,coord_new;
- struct coord center_new,*center_old;
- if (!transform_reverse(tr, old, &coord_old))
- return;
- if (!transform_reverse(tr, new, &coord_new))
- return;
- center_old=transform_get_center(tr);
- center_new.x=center_old->x+coord_old.x-coord_new.x;
- center_new.y=center_old->y+coord_old.y-coord_new.y;
- navit_restrict_map_center_to_world_boundingbox(tr, &center_new);
- dbg(lvl_debug,"change center from 0x%x,0x%x to 0x%x,0x%x\n", center_old->x, center_old->y, center_new.x, center_new.y);
- transform_set_center(tr, &center_new);
-}
-
-void
-navit_set_timeout(struct navit *this_)
-{
- struct attr follow;
- follow.type=attr_follow;
- follow.u.num=this_->center_timeout;
- navit_set_attr(this_, &follow);
-}
-
-int
-navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback)
-{
- int border=16;
+static void update_transformation(struct transformation *tr, struct point *old, struct point *new) {
+ /* Code for rotation was removed in rev. 5252; see Trac #1078. */
+ struct coord coord_old,coord_new;
+ struct coord center_new,*center_old;
+ if (!transform_reverse(tr, old, &coord_old))
+ return;
+ if (!transform_reverse(tr, new, &coord_new))
+ return;
+ center_old=transform_get_center(tr);
+ center_new.x=center_old->x+coord_old.x-coord_new.x;
+ center_new.y=center_old->y+coord_old.y-coord_new.y;
+ navit_restrict_map_center_to_world_boundingbox(tr, &center_new);
+ dbg(lvl_debug,"change center from 0x%x,0x%x to 0x%x,0x%x", center_old->x, center_old->y, center_new.x, center_new.y);
+ transform_set_center(tr, &center_new);
+}
+
+void navit_set_timeout(struct navit *this_) {
+ struct attr follow;
+ follow.type=attr_follow;
+ follow.u.num=this_->center_timeout;
+ navit_set_attr(this_, &follow);
+}
+
+int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p,
+ struct callback *popup_callback) {
+ int border=16;
+
+ dbg(lvl_debug,"button %d %s (ignore: %d)",button,pressed?"pressed":"released",this_->ignore_button);
+ callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, GINT_TO_POINTER(pressed), GINT_TO_POINTER(button), p);
+ if (this_->ignore_button) {
+ this_->ignore_button=0;
+ return 0;
+ }
+ if (pressed) {
+ this_->pressed=*p;
+ this_->last=*p;
+ this_->zoomed=0;
+ if (button == 1) {
+ this_->button_pressed=1;
+ this_->moved=0;
+ this_->popped=0;
+ if (popup_callback)
+ this_->button_timeout=event_add_timeout(500, 0, popup_callback);
+ }
+ if (button == 2)
+ navit_set_center_screen(this_, p, 1);
+ if (button == 3)
+ popup(this_, button, p);
+ if (button == 4 && this_->use_mousewheel) {
+ this_->zoomed = 1;
+ navit_zoom_in(this_, 2, p);
+ }
+ if (button == 5 && this_->use_mousewheel) {
+ this_->zoomed = 1;
+ navit_zoom_out(this_, 2, p);
+ }
+ } else {
- dbg(lvl_debug,"button %d %s (ignore: %d)\n",button,pressed?"pressed":"released",this_->ignore_button);
- callback_list_call_attr_4(this_->attr_cbl, attr_button, this_, GINT_TO_POINTER(pressed), GINT_TO_POINTER(button), p);
- if (this_->ignore_button) {
- this_->ignore_button=0;
- return 0;
- }
- if (pressed) {
- this_->pressed=*p;
- this_->last=*p;
- this_->zoomed=0;
- if (button == 1) {
- this_->button_pressed=1;
- this_->moved=0;
- this_->popped=0;
- if (popup_callback)
- this_->button_timeout=event_add_timeout(500, 0, popup_callback);
- }
- if (button == 2)
- navit_set_center_screen(this_, p, 1);
- if (button == 3)
- popup(this_, button, p);
- if (button == 4 && this_->use_mousewheel) {
- this_->zoomed = 1;
- navit_zoom_in(this_, 2, p);
- }
- if (button == 5 && this_->use_mousewheel) {
- this_->zoomed = 1;
- navit_zoom_out(this_, 2, p);
- }
- } else {
-
- this_->button_pressed=0;
- if (this_->button_timeout) {
- event_remove_timeout(this_->button_timeout);
- this_->button_timeout=NULL;
- if (! this_->moved && ! transform_within_border(this_->trans, p, border)) {
- navit_set_center_screen(this_, p, !this_->zoomed);
- }
- }
- if (this_->motion_timeout) {
- event_remove_timeout(this_->motion_timeout);
- this_->motion_timeout=NULL;
- }
- if (this_->moved) {
- dbg(lvl_debug, "mouse drag (%d, %d)->(%d, %d)\n", this_->pressed.x, this_->pressed.y, p->x, p->y);
- update_transformation(this_->trans, &this_->pressed, p);
- graphics_draw_drag(this_->gra, NULL);
- transform_copy(this_->trans, this_->trans_cursor);
- graphics_overlay_disable(this_->gra, 0);
- if (!this_->zoomed)
- navit_set_timeout(this_);
- navit_draw(this_);
- } else
- return 1;
- }
- return 0;
+ this_->button_pressed=0;
+ if (this_->button_timeout) {
+ event_remove_timeout(this_->button_timeout);
+ this_->button_timeout=NULL;
+ if (! this_->moved && ! transform_within_border(this_->trans, p, border)) {
+ navit_set_center_screen(this_, p, !this_->zoomed);
+ }
+ }
+ if (this_->motion_timeout) {
+ event_remove_timeout(this_->motion_timeout);
+ this_->motion_timeout=NULL;
+ }
+ if (this_->moved) {
+ dbg(lvl_debug, "mouse drag (%d, %d)->(%d, %d)", this_->pressed.x, this_->pressed.y, p->x, p->y);
+ update_transformation(this_->trans, &this_->pressed, p);
+ graphics_draw_drag(this_->gra, NULL);
+ transform_copy(this_->trans, this_->trans_cursor);
+ graphics_overlay_disable(this_->gra, 0);
+ if (!this_->zoomed)
+ navit_set_timeout(this_);
+ navit_draw(this_);
+ } else
+ return 1;
+ }
+ return 0;
}
-static void
-navit_button(void *data, int pressed, int button, struct point *p)
-{
- struct navit *this=data;
- dbg(lvl_debug,"enter %d %d ignore %d\n",pressed,button,this->ignore_graphics_events);
- if (!this->ignore_graphics_events) {
- if (! this->popup_callback)
- this->popup_callback=callback_new_1(callback_cast(navit_popup), this);
- navit_handle_button(this, pressed, button, p, this->popup_callback);
- }
+static void navit_button(void *data, int pressed, int button, struct point *p) {
+ struct navit *this=data;
+ dbg(lvl_debug,"enter %d %d ignore %d",pressed,button,this->ignore_graphics_events);
+ if (!this->ignore_graphics_events) {
+ if (! this->popup_callback)
+ this->popup_callback=callback_new_1(callback_cast(navit_popup), this);
+ navit_handle_button(this, pressed, button, p, this->popup_callback);
+ }
}
-static void
-navit_motion_timeout(struct navit *this_)
-{
- int dx, dy;
-
- if (this_->drag_bitmap) {
- struct point point;
- point.x=(this_->current.x-this_->pressed.x);
- point.y=(this_->current.y-this_->pressed.y);
- if (graphics_draw_drag(this_->gra, &point)) {
- graphics_overlay_disable(this_->gra, 1);
- graphics_draw_mode(this_->gra, draw_mode_end);
- this_->moved=1;
- this_->motion_timeout=NULL;
- return;
- }
- }
- dx=(this_->current.x-this_->last.x);
- dy=(this_->current.y-this_->last.y);
- if (dx || dy) {
- struct transformation *tr;
- this_->last=this_->current;
- graphics_overlay_disable(this_->gra, 1);
- tr=transform_dup(this_->trans);
- update_transformation(tr, &this_->pressed, &this_->current);
- graphics_draw_cancel(this_->gra, this_->displaylist);
- graphics_displaylist_draw(this_->gra, this_->displaylist, tr, this_->layout_current, this_->graphics_flags|512);
- transform_destroy(tr);
- this_->moved=1;
- }
- this_->motion_timeout=NULL;
- return;
-}
+static void navit_motion_timeout(struct navit *this_) {
+ int dx, dy;
-void
-navit_handle_motion(struct navit *this_, struct point *p)
-{
- int dx, dy;
-
- if (this_->button_pressed && !this_->popped) {
- dx=(p->x-this_->pressed.x);
- dy=(p->y-this_->pressed.y);
- if (dx < -8 || dx > 8 || dy < -8 || dy > 8) {
- this_->moved=1;
- if (this_->button_timeout) {
- event_remove_timeout(this_->button_timeout);
- this_->button_timeout=NULL;
- }
- this_->current=*p;
- if (! this_->motion_timeout_callback)
- this_->motion_timeout_callback=callback_new_1(callback_cast(navit_motion_timeout), this_);
- if (! this_->motion_timeout)
- this_->motion_timeout=event_add_timeout(this_->drag_bitmap?10:100, 0, this_->motion_timeout_callback);
- }
- }
+ if (this_->drag_bitmap) {
+ struct point point;
+ point.x=(this_->current.x-this_->pressed.x);
+ point.y=(this_->current.y-this_->pressed.y);
+ if (graphics_draw_drag(this_->gra, &point)) {
+ graphics_overlay_disable(this_->gra, 1);
+ graphics_draw_mode(this_->gra, draw_mode_end);
+ this_->moved=1;
+ this_->motion_timeout=NULL;
+ return;
+ }
+ }
+ dx=(this_->current.x-this_->last.x);
+ dy=(this_->current.y-this_->last.y);
+ if (dx || dy) {
+ struct transformation *tr;
+ this_->last=this_->current;
+ graphics_overlay_disable(this_->gra, 1);
+ tr=transform_dup(this_->trans);
+ update_transformation(tr, &this_->pressed, &this_->current);
+ graphics_draw_cancel(this_->gra, this_->displaylist);
+ graphics_displaylist_draw(this_->gra, this_->displaylist, tr, this_->layout_current, this_->graphics_flags|512);
+ transform_destroy(tr);
+ this_->moved=1;
+ }
+ this_->motion_timeout=NULL;
+ return;
+}
+
+void navit_handle_motion(struct navit *this_, struct point *p) {
+ int dx, dy;
+
+ if (this_->button_pressed && !this_->popped) {
+ dx=(p->x-this_->pressed.x);
+ dy=(p->y-this_->pressed.y);
+ if (dx < -8 || dx > 8 || dy < -8 || dy > 8) {
+ this_->moved=1;
+ if (this_->button_timeout) {
+ event_remove_timeout(this_->button_timeout);
+ this_->button_timeout=NULL;
+ }
+ this_->current=*p;
+ if (! this_->motion_timeout_callback)
+ this_->motion_timeout_callback=callback_new_1(callback_cast(navit_motion_timeout), this_);
+ if (! this_->motion_timeout)
+ this_->motion_timeout=event_add_timeout(this_->drag_bitmap?10:100, 0, this_->motion_timeout_callback);
+ }
+ }
}
-static void
-navit_motion(void *data, struct point *p)
-{
- struct navit *this=data;
- if (!this->ignore_graphics_events)
- navit_handle_motion(this, p);
+static void navit_motion(void *data, struct point *p) {
+ struct navit *this=data;
+ if (!this->ignore_graphics_events)
+ navit_handle_motion(this, p);
}
-static void
-navit_predraw(struct navit *this_)
-{
- GList *l;
- struct navit_vehicle *nv;
- transform_copy(this_->trans, this_->trans_cursor);
- l=this_->vehicles;
- while (l) {
- nv=l->data;
- navit_vehicle_draw(this_, nv, NULL);
- l=g_list_next(l);
- }
+static void navit_predraw(struct navit *this_) {
+ GList *l;
+ struct navit_vehicle *nv;
+ transform_copy(this_->trans, this_->trans_cursor);
+ l=this_->vehicles;
+ while (l) {
+ nv=l->data;
+ navit_vehicle_draw(this_, nv, NULL);
+ l=g_list_next(l);
+ }
}
-static void
-navit_scale(struct navit *this_, long scale, struct point *p, int draw)
-{
- struct coord c1, c2, *center;
- if (scale < this_->zoom_min)
- scale=this_->zoom_min;
- if (scale > this_->zoom_max)
- scale=this_->zoom_max;
- if (p)
- transform_reverse(this_->trans, p, &c1);
- transform_set_scale(this_->trans, scale);
- if (p) {
- transform_reverse(this_->trans, p, &c2);
- center = transform_center(this_->trans);
- center->x += c1.x - c2.x;
- center->y += c1.y - c2.y;
- }
- if (draw)
- navit_draw(this_);
+static void navit_scale(struct navit *this_, long scale, struct point *p, int draw) {
+ struct coord c1, c2, *center;
+ if (scale < this_->zoom_min)
+ scale=this_->zoom_min;
+ if (scale > this_->zoom_max)
+ scale=this_->zoom_max;
+ if (p)
+ transform_reverse(this_->trans, p, &c1);
+ transform_set_scale(this_->trans, scale);
+ if (p) {
+ transform_reverse(this_->trans, p, &c2);
+ center = transform_center(this_->trans);
+ center->x += c1.x - c2.x;
+ center->y += c1.y - c2.y;
+ }
+ if (draw)
+ navit_draw(this_);
}
/**
@@ -661,49 +747,47 @@ navit_scale(struct navit *this_, long scale, struct point *p, int draw)
* @param speed The vehicles speed in meters per second
* @param dir The direction into which the vehicle moves
*/
-static void
-navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw)
-{
- struct point pc;
- int distance,w,h;
- double new_scale;
- long scale;
+static void navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw) {
+ struct point pc;
+ int distance,w,h;
+ double new_scale;
+ long scale;
- if (! this_->autozoom_active) {
- return;
- }
+ if (! this_->autozoom_active) {
+ return;
+ }
- if(this_->autozoom_paused){
- this_->autozoom_paused--;
- return;
- }
-
- distance = speed * this_->autozoom_secs;
-
- transform_get_size(this_->trans, &w, &h);
- transform(this_->trans, transform_get_projection(this_->trans), center, &pc, 1, 0, 0, NULL);
- scale = transform_get_scale(this_->trans);
-
- /* We make sure that the point we want to see is within a certain range
- * around the vehicle. The radius of this circle is the size of the
- * screen. This doesn't necessarily mean the point is visible because of
- * perspective etc. Quite rough, but should be enough. */
-
- if (w > h) {
- new_scale = (double)distance / h * 16;
- } else {
- new_scale = (double)distance / w * 16;
- }
+ if(this_->autozoom_paused) {
+ this_->autozoom_paused--;
+ return;
+ }
- if (abs(new_scale - scale) < 2) {
- return; // Smoothing
- }
- if (new_scale > this_->autozoom_max)
- new_scale=this_->autozoom_max;
- if (new_scale < this_->autozoom_min)
- new_scale=this_->autozoom_min;
- if (new_scale != scale)
- navit_scale(this_, (long)new_scale, &pc, 0);
+ distance = speed * this_->autozoom_secs;
+
+ transform_get_size(this_->trans, &w, &h);
+ transform(this_->trans, transform_get_projection(this_->trans), center, &pc, 1, 0, 0, NULL);
+ scale = transform_get_scale(this_->trans);
+
+ /* We make sure that the point we want to see is within a certain range
+ * around the vehicle. The radius of this circle is the size of the
+ * screen. This doesn't necessarily mean the point is visible because of
+ * perspective etc. Quite rough, but should be enough. */
+
+ if (w > h) {
+ new_scale = (double)distance / h * 16;
+ } else {
+ new_scale = (double)distance / w * 16;
+ }
+
+ if (abs(new_scale - scale) < 2) {
+ return; // Smoothing
+ }
+ if (new_scale > this_->autozoom_max)
+ new_scale=this_->autozoom_max;
+ if (new_scale < this_->autozoom_min)
+ new_scale=this_->autozoom_min;
+ if (new_scale != scale)
+ navit_scale(this_, (long)new_scale, &pc, 0);
}
/**
@@ -714,16 +798,14 @@ navit_autozoom(struct navit *this_, struct coord *center, int speed, int draw)
* @param p The invariant point (if set to NULL, default to center)
* @returns nothing
*/
-void
-navit_zoom_in(struct navit *this_, int factor, struct point *p)
-{
- long scale=transform_get_scale(this_->trans)/factor;
- if(this_->autozoom_active){
- this_->autozoom_paused = 10;
- }
- if (scale < 1)
- scale=1;
- navit_scale(this_, scale, p, 1);
+void navit_zoom_in(struct navit *this_, int factor, struct point *p) {
+ long scale=transform_get_scale(this_->trans)/factor;
+ if(this_->autozoom_active) {
+ this_->autozoom_paused = 10;
+ }
+ if (scale < 1)
+ scale=1;
+ navit_scale(this_, scale, p, 1);
}
/**
@@ -734,59 +816,47 @@ navit_zoom_in(struct navit *this_, int factor, struct point *p)
* @param p The invariant point (if set to NULL, default to center)
* @returns nothing
*/
-void
-navit_zoom_out(struct navit *this_, int factor, struct point *p)
-{
- long scale=transform_get_scale(this_->trans)*factor;
- if(this_->autozoom_active){
- this_->autozoom_paused = 10;
- }
- navit_scale(this_, scale, p, 1);
+void navit_zoom_out(struct navit *this_, int factor, struct point *p) {
+ long scale=transform_get_scale(this_->trans)*factor;
+ if(this_->autozoom_active) {
+ this_->autozoom_paused = 10;
+ }
+ navit_scale(this_, scale, p, 1);
}
-void
-navit_zoom_in_cursor(struct navit *this_, int factor)
-{
- struct point p;
- if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) {
- navit_zoom_in(this_, factor, &p);
- this_->vehicle->follow_curr=this_->vehicle->follow;
- } else
- navit_zoom_in(this_, factor, NULL);
+void navit_zoom_in_cursor(struct navit *this_, int factor) {
+ struct point p;
+ if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) {
+ navit_zoom_in(this_, factor, &p);
+ this_->vehicle->follow_curr=this_->vehicle->follow;
+ } else
+ navit_zoom_in(this_, factor, NULL);
}
-void
-navit_zoom_out_cursor(struct navit *this_, int factor)
-{
- struct point p;
- if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) {
- navit_zoom_out(this_, 2, &p);
- this_->vehicle->follow_curr=this_->vehicle->follow;
- } else
- navit_zoom_out(this_, 2, NULL);
+void navit_zoom_out_cursor(struct navit *this_, int factor) {
+ struct point p;
+ if (this_->vehicle && this_->vehicle->follow_curr <= 1 && navit_get_cursor_pnt(this_, &p, 0, NULL)) {
+ navit_zoom_out(this_, 2, &p);
+ this_->vehicle->follow_curr=this_->vehicle->follow;
+ } else
+ navit_zoom_out(this_, 2, NULL);
}
-static int
-navit_cmd_zoom_in(struct navit *this_)
-{
-
- navit_zoom_in_cursor(this_, 2);
- return 0;
+static int navit_cmd_zoom_in(struct navit *this_) {
+
+ navit_zoom_in_cursor(this_, 2);
+ return 0;
}
-static int
-navit_cmd_zoom_out(struct navit *this_)
-{
- navit_zoom_out_cursor(this_, 2);
- return 0;
+static int navit_cmd_zoom_out(struct navit *this_) {
+ navit_zoom_out_cursor(this_, 2);
+ return 0;
}
-static void
-navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str)
- navit_say(this, in[0]->u.str);
+static void navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str)
+ navit_say(this, in[0]->u.str);
}
static GHashTable *cmd_int_var_hash = NULL;
@@ -798,26 +868,25 @@ static GHashTable *cmd_attr_var_hash = NULL;
* @param navit The navit instance
* @param function unused (needed to match command function signature)
* @param in input attributes in[0] is the key string, in[1] is the integer value to store
- * @param out output attributes, unused
- * @param valid unused
+ * @param out output attributes, unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char*key;
- struct attr*val;
- if(!cmd_int_var_hash) {
- cmd_int_var_hash = g_hash_table_new(g_str_hash, g_str_equal);
- }
+static void navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char*key;
+ struct attr*val;
+ if(!cmd_int_var_hash) {
+ cmd_int_var_hash = g_hash_table_new(g_str_hash, g_str_equal);
+ }
- if ( (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) &&
- (in && in[1] && ATTR_IS_NUMERIC(in[1]->type))) {
- val = g_new(struct attr,1);
- attr_dup_content(in[1],val);
- key = g_strdup(in[0]->u.str);
- g_hash_table_insert(cmd_int_var_hash, key, val);
- }
+ if ( (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) &&
+ (in && in[1] && ATTR_IS_NUMERIC(in[1]->type))) {
+ val = g_new(struct attr,1);
+ attr_dup_content(in[1],val);
+ key = g_strdup(in[0]->u.str);
+ g_hash_table_insert(cmd_int_var_hash, key, val);
+ }
}
@@ -827,27 +896,26 @@ navit_cmd_set_int_var(struct navit *this, char *function, struct attr **in, stru
* @param navit The navit instance
* @param function unused (needed to match command function signature)
* @param in input attributes in[0] is the key string, in[1] is the attr* value to store
- * @param out output attributes, unused
- * @param valid unused
+ * @param out output attributes, unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char*key;
- struct attr*val;
- if(!cmd_attr_var_hash) {
- cmd_attr_var_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)attr_free);
- }
+static void navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ char*key;
+ struct attr*val;
+ if(!cmd_attr_var_hash) {
+ cmd_attr_var_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)attr_free);
+ }
- if ( (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) &&
- (in && in[1] )) {
- val = attr_dup(in[1]);
- key = g_strdup(in[0]->u.str);
- g_hash_table_insert(cmd_attr_var_hash, key, val);
- } else {
- dbg(lvl_warning, "Wrong parameters for set_attr_var() command function\n");
- }
+ if ( (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) &&
+ (in && in[1] )) {
+ val = attr_dup(in[1]);
+ key = g_strdup(in[0]->u.str);
+ g_hash_table_insert(cmd_attr_var_hash, key, val);
+ } else {
+ dbg(lvl_warning, "Wrong parameters for set_attr_var() command function");
+ }
}
@@ -859,26 +927,25 @@ navit_cmd_set_attr_var(struct navit *this, char *function, struct attr **in, str
* @param function unused (needed to match command function signature)
* @param in input attribute in[0] is the name of the layer
* @param out output unused
- * @param valid unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) {
- if(this->layout_current && this->layout_current->layers) {
- GList* layers = this->layout_current->layers;
- while (layers) {
- struct layer*l=layers->data;
- if(l && !strcmp(l->name,in[0]->u.str) ) {
- l->active ^= 1;
- navit_draw(this);
- return;
- }
- layers=g_list_next(layers);
- }
- }
+static void navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) {
+ if(this->layout_current && this->layout_current->layers) {
+ GList* layers = this->layout_current->layers;
+ while (layers) {
+ struct layer*l=layers->data;
+ if(l && !strcmp(l->name,in[0]->u.str) ) {
+ l->active ^= 1;
+ navit_draw(this);
+ return;
+ }
+ layers=g_list_next(layers);
+ }
}
+ }
}
/**
@@ -886,90 +953,89 @@ navit_cmd_toggle_layer(struct navit *this, char *function, struct attr **in, str
*
* @param navit The navit instance
* @param function unused (needed to match command function signature)
- * @param in input attribute in[0] is the name of the map
+ * @param in input attribute in[0] is the name of the map
* @param out output attribute, 0 on error or the id of the created item on success
- * @param valid unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr **list = g_new0(struct attr *,2);
- struct attr*val = g_new0(struct attr,1);
- struct mapset* ms;
- struct map_selection sel;
- const int selection_range = 10;
- enum item_type item_type;
- struct item *it;
- struct map* curr_map = NULL;
- struct coord curr_coord;
- struct map_rect *mr;
-
- //return invalid item on error
- val->type = attr_none;
- val->u.item = NULL;
- list[0] = val;
- list[1] = NULL;
- *out = list;
- if (
- in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name
- in[1] && ATTR_IS_STRING(in[1]->type) && in[1]->u.str //item type
- ) {
-
- if(!(ms=navit_get_mapset(this))) {
- dbg(lvl_error, "Command function map_add_curr_pos(): there is no active mapset\n");
- return;
- }
+static void navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct attr **list = g_new0(struct attr *,2);
+ struct attr*val = g_new0(struct attr,1);
+ struct mapset* ms;
+ struct map_selection sel;
+ const int selection_range = 10;
+ enum item_type item_type;
+ struct item *it;
+ struct map* curr_map = NULL;
+ struct coord curr_coord;
+ struct map_rect *mr;
+
+ //return invalid item on error
+ val->type = attr_none;
+ val->u.item = NULL;
+ list[0] = val;
+ list[1] = NULL;
+ *out = list;
+ if (
+ in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str && //map name
+ in[1] && ATTR_IS_STRING(in[1]->type) && in[1]->u.str //item type
+ ) {
+
+ if(!(ms=navit_get_mapset(this))) {
+ dbg(lvl_error, "Command function map_add_curr_pos(): there is no active mapset");
+ return;
+ }
- if((item_type = item_from_name(in[1]->u.str))==type_none) {
- dbg(lvl_error, "Command function map_add_curr_pos(): unknown item type\n");
- return;
- }
+ if((item_type = item_from_name(in[1]->u.str))==type_none) {
+ dbg(lvl_error, "Command function map_add_curr_pos(): unknown item type");
+ return;
+ }
- curr_map = mapset_get_map_by_name(ms, in[0]->u.str);
+ curr_map = mapset_get_map_by_name(ms, in[0]->u.str);
- //no map with the given name found
- if( ! curr_map) {
- dbg(lvl_error, "Command function map_add_curr_pos(): map not found\n");
- return;
- }
-
- if(this->vehicle && this->vehicle->vehicle ) {
- struct attr pos_attr;
- if(vehicle_get_attr(this->vehicle->vehicle,attr_position_coord_geo,&pos_attr,NULL)) {
- transform_from_geo(projection_mg, pos_attr.u.coord_geo, &curr_coord);
- } else {
- dbg(lvl_error, "Command function map_add_curr_pos(): vehicle position is not accessible\n");
- return;
- }
- } else {
- dbg(lvl_error, "Command function map_add_curr_pos(): no vehicle\n");
- return;
- }
+ //no map with the given name found
+ if( ! curr_map) {
+ dbg(lvl_error, "Command function map_add_curr_pos(): map not found");
+ return;
+ }
- sel.next=NULL;
- sel.order=18;
- sel.range.min=type_none;
- sel.range.max=type_tec_common;
- sel.u.c_rect.lu.x=curr_coord.x-selection_range;
- sel.u.c_rect.lu.y=curr_coord.y+selection_range;
- sel.u.c_rect.rl.x=curr_coord.x+selection_range;
- sel.u.c_rect.rl.y=curr_coord.y-selection_range;
-
- mr = map_rect_new(curr_map, &sel);
- if(mr) {
-
- it = map_rect_create_item( mr, item_type);
- if (it) {
- struct attr attr;
- attr.type=attr_type_item_begin;
- attr.u.item=it;
- attr_dup_content(&attr,val);
- item_coord_set(it,&curr_coord, 1, change_mode_modify);
- }
- }
- map_rect_destroy(mr);
+ if(this->vehicle && this->vehicle->vehicle ) {
+ struct attr pos_attr;
+ if(vehicle_get_attr(this->vehicle->vehicle,attr_position_coord_geo,&pos_attr,NULL)) {
+ transform_from_geo(projection_mg, pos_attr.u.coord_geo, &curr_coord);
+ } else {
+ dbg(lvl_error, "Command function map_add_curr_pos(): vehicle position is not accessible");
+ return;
+ }
+ } else {
+ dbg(lvl_error, "Command function map_add_curr_pos(): no vehicle");
+ return;
}
+
+ sel.next=NULL;
+ sel.order=18;
+ sel.range.min=type_none;
+ sel.range.max=type_tec_common;
+ sel.u.c_rect.lu.x=curr_coord.x-selection_range;
+ sel.u.c_rect.lu.y=curr_coord.y+selection_range;
+ sel.u.c_rect.rl.x=curr_coord.x+selection_range;
+ sel.u.c_rect.rl.y=curr_coord.y-selection_range;
+
+ mr = map_rect_new(curr_map, &sel);
+ if(mr) {
+
+ it = map_rect_create_item( mr, item_type);
+ if (it) {
+ struct attr attr;
+ attr.type=attr_type_item_begin;
+ attr.u.item=it;
+ attr_dup_content(&attr,val);
+ item_coord_set(it,&curr_coord, 1, change_mode_modify);
+ }
+ }
+ map_rect_destroy(mr);
+ }
}
/**
@@ -979,62 +1045,62 @@ navit_cmd_map_add_curr_pos(struct navit *this, char *function, struct attr **in,
* @param function unused (needed to match command function signature)
* @param in input attribute in[0] - name of the map ; in[1] - item ; in[2] - attr name ; in[3] - attr value
* @param out output attribute, 0 on error, 1 on success
- * @param valid unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- if (
- in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str &&//map name
- in[1] && ATTR_IS_ITEM(in[1]->type) && in[2]->u.item &&//item
- in[2] && ATTR_IS_STRING(in[2]->type) && in[2]->u.str && //attr_type str
- in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str //attr_value str
- ) {
- struct attr attr_to_set;
- struct map* curr_map = NULL;
- struct mapset *ms;
- struct item *it;
- struct map_rect *mr;
-
- if(ATTR_IS_STRING(attr_from_name(in[2]->u.str))) {
- attr_to_set.u.str = in[3]->u.str;
- attr_to_set.type = attr_from_name(in[2]->u.str);
- }
- else if(ATTR_IS_INT(attr_from_name(in[2]->u.str))) {
- attr_to_set.u.num = atoi(in[3]->u.str);
- attr_to_set.type = attr_from_name(in[2]->u.str);
- }
- else if(ATTR_IS_DOUBLE(attr_from_name(in[2]->u.str))) {
- double* val = g_new0(double,1);
- *val = atof(in[3]->u.str);
- attr_to_set.u.numd = val;
- attr_to_set.type = attr_from_name(in[2]->u.str);
- }
+static void navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ if (
+ in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str &&//map name
+ in[1] && ATTR_IS_ITEM(in[1]->type) && in[2]->u.item &&//item
+ in[2] && ATTR_IS_STRING(in[2]->type) && in[2]->u.str && //attr_type str
+ in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str //attr_value str
+ ) {
+ struct attr attr_to_set;
+ struct map* curr_map = NULL;
+ struct mapset *ms;
+ struct item *it;
+ struct map_rect *mr;
+
+ if(ATTR_IS_STRING(attr_from_name(in[2]->u.str))) {
+ attr_to_set.u.str = in[3]->u.str;
+ attr_to_set.type = attr_from_name(in[2]->u.str);
+ } else if(ATTR_IS_INT(attr_from_name(in[2]->u.str))) {
+ attr_to_set.u.num = atoi(in[3]->u.str);
+ attr_to_set.type = attr_from_name(in[2]->u.str);
+ } else if(ATTR_IS_DOUBLE(attr_from_name(in[2]->u.str))) {
+ double* val = g_new0(double,1);
+ *val = atof(in[3]->u.str);
+ attr_to_set.u.numd = val;
+ attr_to_set.type = attr_from_name(in[2]->u.str);
+ }
- ms = navit_get_mapset(this);
+ ms = navit_get_mapset(this);
- curr_map = mapset_get_map_by_name(ms, in[0]->u.str);
+ curr_map = mapset_get_map_by_name(ms, in[0]->u.str);
- if( ! curr_map) {
- return;
- }
-
- mr=map_rect_new(curr_map,NULL);
- it=in[1]->u.item;
- it=map_rect_get_item_byid(mr,it->id_hi,it->id_lo);
-
- if(it) {
- item_attr_set(it, &attr_to_set, change_mode_modify);
- }
- map_rect_destroy(mr);
- } else {
- dbg(lvl_debug,"Error in command function item_set_attr()\n");
- dbg(lvl_debug,"Command function item_set_attr(): map cond: %d\n",(in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str)?1:0);
- dbg(lvl_debug,"Command function item_set_attr(): item cond: %d\n",(in[1] && ATTR_IS_ITEM(in[1]->type))?1:0);
- dbg(lvl_debug,"Command function item_set_attr(): attr type cond: %d\n",(in[2] && ATTR_IS_STRING(in[2]->type) && in[2]->u.str)?1:0);
- dbg(lvl_debug,"Command function item_set_attr(): attr val cond: %d\n",(in[3] && ATTR_IS_STRING(in[3]->type) && in[3]->u.str)?1:0);
- }
+ if( ! curr_map) {
+ return;
+ }
+
+ mr=map_rect_new(curr_map,NULL);
+ it=in[1]->u.item;
+ it=map_rect_get_item_byid(mr,it->id_hi,it->id_lo);
+
+ if(it) {
+ item_attr_set(it, &attr_to_set, change_mode_modify);
+ }
+ map_rect_destroy(mr);
+ } else {
+ dbg(lvl_debug,"Error in command function item_set_attr()");
+ dbg(lvl_debug,"Command function item_set_attr(): map cond: %d",(in[0] && ATTR_IS_STRING(in[0]->type)
+ && in[0]->u.str)?1:0);
+ dbg(lvl_debug,"Command function item_set_attr(): item cond: %d",(in[1] && ATTR_IS_ITEM(in[1]->type))?1:0);
+ dbg(lvl_debug,"Command function item_set_attr(): attr type cond: %d",(in[2] && ATTR_IS_STRING(in[2]->type)
+ && in[2]->u.str)?1:0);
+ dbg(lvl_debug,"Command function item_set_attr(): attr val cond: %d",(in[3] && ATTR_IS_STRING(in[3]->type)
+ && in[3]->u.str)?1:0);
+ }
}
/**
@@ -1043,35 +1109,33 @@ navit_cmd_map_item_set_attr(struct navit *this, char *function, struct attr **in
* @param navit The navit instance
* @param function unused (needed to match command function signature)
* @param in input attribute in[0] is the key string
- * @param out output attribute, the attr for the given key string if exists or NULL
- * @param valid unused
+ * @param out output attribute, the attr for the given key string if exists or NULL
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr **list = g_new0(struct attr *,2);
- list[1] = NULL;
- *out = list;
- if(!cmd_attr_var_hash) {
- struct attr*val = g_new0(struct attr,1);
- val->type = attr_type_item_begin;
- val->u.item = NULL;
- list[0] = val;
- return;
- }
- if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) {
- struct attr*ret = g_hash_table_lookup(cmd_attr_var_hash, in[0]->u.str);
- if(ret) {
- list[0] = attr_dup(ret);
- }
- else {
- struct attr*val = g_new0(struct attr,1);
- val->type = attr_type_int_begin;
- val->u.item = NULL;
- list[0] = val;
- }
+static void navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct attr **list = g_new0(struct attr *,2);
+ list[1] = NULL;
+ *out = list;
+ if(!cmd_attr_var_hash) {
+ struct attr*val = g_new0(struct attr,1);
+ val->type = attr_type_item_begin;
+ val->u.item = NULL;
+ list[0] = val;
+ return;
+ }
+ if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) {
+ struct attr*ret = g_hash_table_lookup(cmd_attr_var_hash, in[0]->u.str);
+ if(ret) {
+ list[0] = attr_dup(ret);
+ } else {
+ struct attr*val = g_new0(struct attr,1);
+ val->type = attr_type_int_begin;
+ val->u.item = NULL;
+ list[0] = val;
}
+ }
}
@@ -1081,35 +1145,33 @@ navit_cmd_get_attr_var(struct navit *this, char *function, struct attr **in, str
* @param navit The navit instance
* @param function unused (needed to match command function signature)
* @param in input attribute in[0] is the key string
- * @param out output attribute, the value for the given key string if exists or 0
- * @param valid unused
+ * @param out output attribute, the value for the given key string if exists or 0
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr **list = g_new0(struct attr *,2);
- list[1] = NULL;
- *out = list;
- if(!cmd_int_var_hash) {
- struct attr*val = g_new0(struct attr,1);
- val->type = attr_type_int_begin;
- val->u.num = 0;
- list[0] = val;
- return;
- }
- if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) {
- struct attr*ret = g_hash_table_lookup(cmd_int_var_hash, in[0]->u.str);
- if(ret) {
- list[0] = attr_dup(ret);
- }
- else {
- struct attr*val = g_new0(struct attr,1);
- val->type = attr_type_int_begin;
- val->u.num = 0;
- list[0] = val;
- }
+static void navit_cmd_get_int_var(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct attr **list = g_new0(struct attr *,2);
+ list[1] = NULL;
+ *out = list;
+ if(!cmd_int_var_hash) {
+ struct attr*val = g_new0(struct attr,1);
+ val->type = attr_type_int_begin;
+ val->u.num = 0;
+ list[0] = val;
+ return;
+ }
+ if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) {
+ struct attr*ret = g_hash_table_lookup(cmd_int_var_hash, in[0]->u.str);
+ if(ret) {
+ list[0] = attr_dup(ret);
+ } else {
+ struct attr*val = g_new0(struct attr,1);
+ val->type = attr_type_int_begin;
+ val->u.num = 0;
+ list[0] = val;
}
+ }
}
GList *cmd_int_var_stack = NULL;
@@ -1120,18 +1182,16 @@ GList *cmd_int_var_stack = NULL;
* @param navit The navit instance
* @param function unused (needed to match command function signature)
* @param in input attribute in[0] is the integer attibute to push
- * @param out output attributes, unused
- * @param valid unused
+ * @param out output attributes, unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- if (in && in[0] && ATTR_IS_NUMERIC(in[0]->type)) {
- struct attr*val = g_new(struct attr,1);
- attr_dup_content(in[0],val);
- cmd_int_var_stack = g_list_prepend(cmd_int_var_stack, val);
- }
+static void navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ if (in && in[0] && ATTR_IS_NUMERIC(in[0]->type)) {
+ struct attr*val = g_new(struct attr,1);
+ attr_dup_content(in[0],val);
+ cmd_int_var_stack = g_list_prepend(cmd_int_var_stack, val);
+ }
}
/**
@@ -1141,25 +1201,22 @@ navit_cmd_push_int(struct navit *this, char *function, struct attr **in, struct
* @param function unused (needed to match command function signature)
* @param in input attributes unused
* @param out output attribute, the value popped if stack isn't empty or 0
- * @param valid unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr **list = g_new0(struct attr *,2);
- if(!cmd_int_var_stack) {
- struct attr*val = g_new0(struct attr,1);
- val->type = attr_type_int_begin;
- val->u.num = 0;
- list[0] = val;
- }
- else {
- list[0] = cmd_int_var_stack->data;
- cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack,cmd_int_var_stack);
- }
- list[1] = NULL;
- *out = list;
+static void navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ struct attr **list = g_new0(struct attr *,2);
+ if(!cmd_int_var_stack) {
+ struct attr*val = g_new0(struct attr,1);
+ val->type = attr_type_int_begin;
+ val->u.num = 0;
+ list[0] = val;
+ } else {
+ list[0] = cmd_int_var_stack->data;
+ cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack,cmd_int_var_stack);
+ }
+ list[1] = NULL;
+ *out = list;
}
/**
@@ -1169,125 +1226,116 @@ navit_cmd_pop_int(struct navit *this, char *function, struct attr **in, struct a
* @param function unused (needed to match command function signature)
* @param in input attributes unused
* @param out output attribute, the size of stack
- * @param valid unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr **list;
- struct attr *attr = g_new0(struct attr ,1);
- attr->type = attr_type_int_begin;
- if(!cmd_int_var_stack) {
- attr->u.num = 0;
- }
- else {
- attr->u.num = g_list_length(cmd_int_var_stack);
- }
- list = g_new0(struct attr *,2);
- list[0] = attr;
- list[1] = NULL;
- *out = list;
- cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack,cmd_int_var_stack);
-}
-
-static struct attr **
-navit_get_coord(struct navit *this, struct attr **in, struct pcoord *pc)
-{
- if (!in)
- return NULL;
- if (!in[0])
- return NULL;
- pc->pro = transform_get_projection(this->trans);
- if (ATTR_IS_STRING(in[0]->type)) {
- struct coord c;
- coord_parse(in[0]->u.str, pc->pro, &c);
- pc->x=c.x;
- pc->y=c.y;
- in++;
- } else if (ATTR_IS_COORD(in[0]->type)) {
- pc->x=in[0]->u.coord->x;
- pc->y=in[0]->u.coord->y;
- in++;
- } else if (ATTR_IS_PCOORD(in[0]->type)) {
- *pc=*in[0]->u.pcoord;
- in++;
- } else if (in[1] && in[2] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type) && ATTR_IS_INT(in[2]->type)) {
- pc->pro=in[0]->u.num;
- pc->x=in[1]->u.num;
- pc->y=in[2]->u.num;
- in+=3;
- } else if (in[1] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type)) {
- pc->x=in[0]->u.num;
- pc->y=in[1]->u.num;
- in+=2;
- } else
- return NULL;
- return in;
-}
-
-static void
-navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct pcoord pc;
- char *description=NULL;
- in=navit_get_coord(this, in, &pc);
- if (!in)
- return;
- if (in[0] && ATTR_IS_STRING(in[0]->type))
- description=in[0]->u.str;
- navit_set_destination(this, &pc, description, 1);
+static void navit_cmd_int_stack_size(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct attr **list;
+ struct attr *attr = g_new0(struct attr,1);
+ attr->type = attr_type_int_begin;
+ if(!cmd_int_var_stack) {
+ attr->u.num = 0;
+ } else {
+ attr->u.num = g_list_length(cmd_int_var_stack);
+ }
+ list = g_new0(struct attr *,2);
+ list[0] = attr;
+ list[1] = NULL;
+ *out = list;
+ cmd_int_var_stack = g_list_remove_link(cmd_int_var_stack,cmd_int_var_stack);
+}
+
+static struct attr ** navit_get_coord(struct navit *this, struct attr **in, struct pcoord *pc) {
+ if (!in)
+ return NULL;
+ if (!in[0])
+ return NULL;
+ pc->pro = transform_get_projection(this->trans);
+ if (ATTR_IS_STRING(in[0]->type)) {
+ struct coord c;
+ coord_parse(in[0]->u.str, pc->pro, &c);
+ pc->x=c.x;
+ pc->y=c.y;
+ in++;
+ } else if (ATTR_IS_COORD(in[0]->type)) {
+ pc->x=in[0]->u.coord->x;
+ pc->y=in[0]->u.coord->y;
+ in++;
+ } else if (ATTR_IS_PCOORD(in[0]->type)) {
+ *pc=*in[0]->u.pcoord;
+ in++;
+ } else if (in[1] && in[2] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type) && ATTR_IS_INT(in[2]->type)) {
+ pc->pro=in[0]->u.num;
+ pc->x=in[1]->u.num;
+ pc->y=in[2]->u.num;
+ in+=3;
+ } else if (in[1] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type)) {
+ pc->x=in[0]->u.num;
+ pc->y=in[1]->u.num;
+ in+=2;
+ } else
+ return NULL;
+ return in;
+}
+
+static void navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct pcoord pc;
+ char *description=NULL;
+ in=navit_get_coord(this, in, &pc);
+ if (!in)
+ return;
+ if (in[0] && ATTR_IS_STRING(in[0]->type))
+ description=in[0]->u.str;
+ navit_set_destination(this, &pc, description, 1);
}
-static void
-navit_cmd_route_remove_next_waypoint(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- navit_remove_waypoint(this);
+static void navit_cmd_route_remove_next_waypoint(struct navit *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ navit_remove_waypoint(this);
}
-static void
-navit_cmd_route_remove_last_waypoint(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- navit_remove_nth_waypoint(this, navit_get_destination_count(this)-1);
+static void navit_cmd_route_remove_last_waypoint(struct navit *this, char *function, struct attr **in,
+ struct attr ***out,
+ int *valid) {
+ navit_remove_nth_waypoint(this, navit_get_destination_count(this)-1);
}
-static void
-navit_cmd_set_center(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct pcoord pc;
- int set_timeout=0;
- in=navit_get_coord(this, in, &pc);
- if (!in)
- return;
- if(in[0] && ATTR_IS_INT(in[0]->type))
- set_timeout=in[0]->u.num!=0;
- navit_set_center(this, &pc, set_timeout);
+static void navit_cmd_set_center(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ struct pcoord pc;
+ int set_timeout=0;
+ in=navit_get_coord(this, in, &pc);
+ if (!in)
+ return;
+ if(in[0] && ATTR_IS_INT(in[0]->type))
+ set_timeout=in[0]->u.num!=0;
+ navit_set_center(this, &pc, set_timeout);
}
-static void
-navit_cmd_set_position(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct pcoord pc;
- in=navit_get_coord(this, in, &pc);
- if (!in)
- return;
- navit_set_position(this, &pc);
+static void navit_cmd_set_position(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct pcoord pc;
+ in=navit_get_coord(this, in, &pc);
+ if (!in)
+ return;
+ navit_set_position(this, &pc);
}
-static void
-navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr;
- attr.type=attr_type_string_begin;
- attr.u.str="Fix me";
- if (out) {
- *out=attr_generic_add_attr(*out, &attr);
- }
+static void navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ struct attr attr;
+ attr.type=attr_type_string_begin;
+ attr.u.str="Fix me";
+ if (out) {
+ *out=attr_generic_add_attr(*out, &attr);
+ }
}
/**
@@ -1297,34 +1345,32 @@ navit_cmd_fmt_coordinates(struct navit *this, char *function, struct attr **in,
* @param function unused (needed to match command function signature)
* @param in input attributes in[0] - separator, in[1..] - attributes to join
* @param out output attribute joined attribute as string
- * @param valid unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr;
- gchar *ret, *sep;
- int i;
- attr.type=attr_type_string_begin;
- attr.u.str=NULL;
- if(in[0] && in[1]) {
- sep=attr_to_text(in[0],NULL,1);
- ret=attr_to_text(in[1],NULL,1);
- for(i=2;in[i];i++) {
- gchar *in_i=attr_to_text(in[i],NULL,1);
- gchar *r=g_strjoin(sep,ret,in_i,NULL);
- g_free(in_i);
- g_free(ret);
- ret=r;
- }
- g_free(sep);
- attr.u.str=ret;
- if(out) {
- *out=attr_generic_add_attr(*out, &attr);
- }
- g_free(ret);
- }
+static void navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ struct attr attr;
+ gchar *ret, *sep;
+ int i;
+ attr.type=attr_type_string_begin;
+ attr.u.str=NULL;
+ if(in[0] && in[1]) {
+ sep=attr_to_text(in[0],NULL,1);
+ ret=attr_to_text(in[1],NULL,1);
+ for(i=2; in[i]; i++) {
+ gchar *in_i=attr_to_text(in[i],NULL,1);
+ gchar *r=g_strjoin(sep,ret,in_i,NULL);
+ g_free(in_i);
+ g_free(ret);
+ ret=r;
+ }
+ g_free(sep);
+ attr.u.str=ret;
+ if(out) {
+ *out=attr_generic_add_attr(*out, &attr);
+ }
+ g_free(ret);
+ }
}
/**
@@ -1334,57 +1380,55 @@ navit_cmd_strjoin(struct navit *this, char *function, struct attr **in, struct a
* @param function unused (needed to match command function signature)
* @param in input attributes in[0] - name of executable, in[1..] - parameters
* @param out output attribute unused
- * @param valid unused
+ * @param valid unused
* @returns nothing
*/
-static void
-navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- int i,j, nparms, nvalid;
- char ** argv=NULL;
- struct spawn_process_info *pi;
-
- nparms=0;
- nvalid=0;
- if(in) {
- while(in[nparms]) {
- if (in[nparms]->type!=attr_none)
- nvalid++;
- nparms++;
- }
- }
-
- if(nvalid>0) {
- argv=g_new(char*,nvalid+1);
- for(i=0,j=0;in[i];i++) {
- if(in[i]->type!=attr_none ) {
- argv[j++]=attr_to_text(in[i],NULL,1);
- } else {
- dbg(lvl_debug,"Parameter #%i is attr_none - skipping\n",i);
- }
- }
- argv[j]=NULL;
- pi=spawn_process(argv);
-
- // spawn_process() testing suite - uncomment following code to test.
- //sleep(3);
- // example of non-blocking wait
- //int st=spawn_process_check_status(pi,0);dbg(lvl_debug,"status %i\n",st);
- // example of blocking wait
- //st=spawn_process_check_status(pi,1);dbg(lvl_debug,"status %i\n",st);
- // example of wait after process is finished and status is
- // already tested
- //st=spawn_process_check_status(pi,1);dbg(lvl_debug,"status %i\n",st);
- // example of wait after process is finished and status is
- // already tested - unblocked
- //st=spawn_process_check_status(pi,0);dbg(lvl_debug,"status %i\n",st);
-
- // End testing suite
- spawn_process_info_free(pi);
- for(i=0;argv[i];i++)
- g_free(argv[i]);
- g_free(argv);
- }
+static void navit_cmd_spawn(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) {
+ int i,j, nparms, nvalid;
+ char ** argv=NULL;
+ struct spawn_process_info *pi;
+
+ nparms=0;
+ nvalid=0;
+ if(in) {
+ while(in[nparms]) {
+ if (in[nparms]->type!=attr_none)
+ nvalid++;
+ nparms++;
+ }
+ }
+
+ if(nvalid>0) {
+ argv=g_new(char*,nvalid+1);
+ for(i=0,j=0; in[i]; i++) {
+ if(in[i]->type!=attr_none ) {
+ argv[j++]=attr_to_text(in[i],NULL,1);
+ } else {
+ dbg(lvl_debug,"Parameter #%i is attr_none - skipping",i);
+ }
+ }
+ argv[j]=NULL;
+ pi=spawn_process(argv);
+
+ // spawn_process() testing suite - uncomment following code to test.
+ //sleep(3);
+ // example of non-blocking wait
+ //int st=spawn_process_check_status(pi,0);dbg(lvl_debug,"status %i",st);
+ // example of blocking wait
+ //st=spawn_process_check_status(pi,1);dbg(lvl_debug,"status %i",st);
+ // example of wait after process is finished and status is
+ // already tested
+ //st=spawn_process_check_status(pi,1);dbg(lvl_debug,"status %i",st);
+ // example of wait after process is finished and status is
+ // already tested - unblocked
+ //st=spawn_process_check_status(pi,0);dbg(lvl_debug,"status %i",st);
+
+ // End testing suite
+ spawn_process_info_free(pi);
+ for(i=0; argv[i]; i++)
+ g_free(argv[i]);
+ g_free(argv);
+ }
}
static void
@@ -1665,205 +1709,188 @@ audio_get_tracks(struct navit *this, const int playlist_index)
static struct command_table commands[] = {
- {"zoom_in",command_cast(navit_cmd_zoom_in)},
- {"zoom_out",command_cast(navit_cmd_zoom_out)},
- {"zoom_to_route",command_cast(navit_cmd_zoom_to_route)},
- {"say",command_cast(navit_cmd_say)},
- {"set_center",command_cast(navit_cmd_set_center)},
- {"set_center_cursor",command_cast(navit_cmd_set_center_cursor)},
- {"set_destination",command_cast(navit_cmd_set_destination)},
- {"set_position",command_cast(navit_cmd_set_position)},
- {"route_remove_next_waypoint",command_cast(navit_cmd_route_remove_next_waypoint)},
- {"route_remove_last_waypoint",command_cast(navit_cmd_route_remove_last_waypoint)},
- {"set_position",command_cast(navit_cmd_set_position)},
- {"announcer_toggle",command_cast(navit_cmd_announcer_toggle)},
- {"fmt_coordinates",command_cast(navit_cmd_fmt_coordinates)},
- {"set_int_var",command_cast(navit_cmd_set_int_var)},
- {"get_int_var",command_cast(navit_cmd_get_int_var)},
- {"push_int",command_cast(navit_cmd_push_int)},
- {"pop_int",command_cast(navit_cmd_pop_int)},
- {"int_stack_size",command_cast(navit_cmd_int_stack_size)},
- {"toggle_layer",command_cast(navit_cmd_toggle_layer)},
- {"strjoin",command_cast(navit_cmd_strjoin)},
- {"spawn",command_cast(navit_cmd_spawn)},
- {"map_add_curr_pos",command_cast(navit_cmd_map_add_curr_pos)},
- {"map_item_set_attr",command_cast(navit_cmd_map_item_set_attr)},
- {"set_attr_var",command_cast(navit_cmd_set_attr_var)},
- {"get_attr_var",command_cast(navit_cmd_get_attr_var)},
- {"switch_layout_day_night",command_cast(navit_cmd_switch_layout_day_night)},
- {"volume_down",command_cast(audio_volume_down)},
- {"volume_toggle",command_cast(audio_volume_toggle)},
- {"volume_up",command_cast(audio_volume_up)},
- {"audio_playback_previous",command_cast(audio_playback_previous)},
- {"audio_playback_toggle",command_cast(audio_playback_toggle)},
- {"audio_playback_play",command_cast(audio_playback_play)},
- {"audio_playback_pause",command_cast(audio_playback_pause)},
- {"audio_playback_next",command_cast(audio_playback_next)},
- {"audio_playback_previous_playlist",command_cast(audio_playback_previous_playlist)},
- {"audio_playback_next_playlist",command_cast(audio_playback_next_playlist)},
- {"audio_playback_previous_artist",command_cast(audio_playback_previous_artist)},
- {"audio_playback_next_artist",command_cast(audio_playback_next_artist)},
- {"audio_playback_toggle_repeat",command_cast(audio_playback_toggle_repeat)},
- {"audio_playback_toggle_shuffle",command_cast(audio_playback_toggle_shuffle)},
-
+ {"zoom_in",command_cast(navit_cmd_zoom_in)},
+ {"zoom_out",command_cast(navit_cmd_zoom_out)},
+ {"zoom_to_route",command_cast(navit_cmd_zoom_to_route)},
+ {"say",command_cast(navit_cmd_say)},
+ {"set_center",command_cast(navit_cmd_set_center)},
+ {"set_center_cursor",command_cast(navit_cmd_set_center_cursor)},
+ {"set_destination",command_cast(navit_cmd_set_destination)},
+ {"set_position",command_cast(navit_cmd_set_position)},
+ {"route_remove_next_waypoint",command_cast(navit_cmd_route_remove_next_waypoint)},
+ {"route_remove_last_waypoint",command_cast(navit_cmd_route_remove_last_waypoint)},
+ {"set_position",command_cast(navit_cmd_set_position)},
+ {"announcer_toggle",command_cast(navit_cmd_announcer_toggle)},
+ {"fmt_coordinates",command_cast(navit_cmd_fmt_coordinates)},
+ {"set_int_var",command_cast(navit_cmd_set_int_var)},
+ {"get_int_var",command_cast(navit_cmd_get_int_var)},
+ {"push_int",command_cast(navit_cmd_push_int)},
+ {"pop_int",command_cast(navit_cmd_pop_int)},
+ {"int_stack_size",command_cast(navit_cmd_int_stack_size)},
+ {"toggle_layer",command_cast(navit_cmd_toggle_layer)},
+ {"strjoin",command_cast(navit_cmd_strjoin)},
+ {"spawn",command_cast(navit_cmd_spawn)},
+ {"map_add_curr_pos",command_cast(navit_cmd_map_add_curr_pos)},
+ {"map_item_set_attr",command_cast(navit_cmd_map_item_set_attr)},
+ {"set_attr_var",command_cast(navit_cmd_set_attr_var)},
+ {"get_attr_var",command_cast(navit_cmd_get_attr_var)},
+ {"switch_layout_day_night",command_cast(navit_cmd_switch_layout_day_night)},
+ {"volume_down",command_cast(audio_volume_down)},
+ {"volume_toggle",command_cast(audio_volume_toggle)},
+ {"volume_up",command_cast(audio_volume_up)},
+ {"audio_playback_previous",command_cast(audio_playback_previous)},
+ {"audio_playback_toggle",command_cast(audio_playback_toggle)},
+ {"audio_playback_play",command_cast(audio_playback_play)},
+ {"audio_playback_pause",command_cast(audio_playback_pause)},
+ {"audio_playback_next",command_cast(audio_playback_next)},
+ {"audio_playback_previous_playlist",command_cast(audio_playback_previous_playlist)},
+ {"audio_playback_next_playlist",command_cast(audio_playback_next_playlist)},
+ {"audio_playback_previous_artist",command_cast(audio_playback_previous_artist)},
+ {"audio_playback_next_artist",command_cast(audio_playback_next_artist)},
+ {"audio_playback_toggle_repeat",command_cast(audio_playback_toggle_repeat)},
+ {"audio_playback_toggle_shuffle",command_cast(audio_playback_toggle_shuffle)},
};
-
-void
-navit_command_add_table(struct navit*this_, struct command_table *commands, int count)
-{
- command_add_table(this_->attr_cbl, commands, count, this_);
+
+void navit_command_add_table(struct navit*this_, struct command_table *commands, int count) {
+ command_add_table(this_->attr_cbl, commands, count, this_);
}
struct navit *
-navit_new(struct attr *parent, struct attr **attrs)
-{
- struct navit *this_=g_new0(struct navit, 1);
- struct pcoord center;
- struct coord co;
- struct coord_geo g;
- enum projection pro=projection_mg;
- int zoom = 256;
- g.lat=53.13;
- g.lng=11.70;
-
- this_->func=&navit_func;
- navit_object_ref((struct navit_object *)this_);
- this_->attrs=attr_list_dup(attrs);
- this_->self.type=attr_navit;
- this_->self.u.navit=this_;
- this_->attr_cbl=callback_list_new();
-
- this_->orientation=-1;
- this_->tracking_flag=1;
- this_->recentdest_count=10;
- this_->osd_configuration=-1;
-
- this_->center_timeout = 10;
- this_->use_mousewheel = 1;
- this_->autozoom_secs = 10;
- this_->autozoom_min = 7;
- this_->autozoom_active = 0;
- this_->autozoom_paused = 0;
- this_->zoom_min = 1;
- this_->zoom_max = 2097152;
- this_->autozoom_max = this_->zoom_max;
- this_->follow_cursor = 1;
- this_->radius = 30;
- this_->border = 16;
- this_->auto_switch = TRUE;
-
- transform_from_geo(pro, &g, &co);
- center.x=co.x;
- center.y=co.y;
- center.pro = pro;
- this_->trans = transform_new(&center, zoom, (this_->orientation != -1) ? this_->orientation : 0);
- this_->trans_cursor = transform_new(&center, zoom, (this_->orientation != -1) ? this_->orientation : 0);
-
- this_->bookmarks=bookmarks_new(&this_->self, NULL, this_->trans);
-
- this_->prevTs=0;
-
- for (;*attrs; attrs++) {
- navit_set_attr_do(this_, *attrs, 1);
- }
- this_->displaylist=graphics_displaylist_new();
- command_add_table(this_->attr_cbl, commands, sizeof(commands)/sizeof(struct command_table), this_);
+navit_new(struct attr *parent, struct attr **attrs) {
+ struct navit *this_=g_new0(struct navit, 1);
+ struct pcoord center;
+ struct coord co;
+ struct coord_geo g;
+ enum projection pro=projection_mg;
+ int zoom = 256;
+ g.lat=53.13;
+ g.lng=11.70;
+
+ this_->func=&navit_func;
+ navit_object_ref((struct navit_object *)this_);
+ this_->attrs=attr_list_dup(attrs);
+ this_->self.type=attr_navit;
+ this_->self.u.navit=this_;
+ this_->attr_cbl=callback_list_new();
+
+ this_->orientation=-1;
+ this_->tracking_flag=1;
+ this_->recentdest_count=10;
+ this_->osd_configuration=-1;
+ this_->default_layout_name=NULL;
+
+ this_->center_timeout = 10;
+ this_->use_mousewheel = 1;
+ this_->autozoom_secs = 10;
+ this_->autozoom_min = 7;
+ this_->autozoom_active = 0;
+ this_->autozoom_paused = 0;
+ this_->zoom_min = 1;
+ this_->zoom_max = 2097152;
+ this_->autozoom_max = this_->zoom_max;
+ this_->follow_cursor = 1;
+ this_->radius = 30;
+ this_->border = 16;
+ this_->auto_switch = TRUE;
+
+ transform_from_geo(pro, &g, &co);
+ center.x=co.x;
+ center.y=co.y;
+ center.pro = pro;
+ this_->trans = transform_new(&center, zoom, (this_->orientation != -1) ? this_->orientation : 0);
+ this_->trans_cursor = transform_new(&center, zoom, (this_->orientation != -1) ? this_->orientation : 0);
+
+ this_->bookmarks=bookmarks_new(&this_->self, NULL, this_->trans);
+
+ this_->prevTs=0;
+
+ for (; *attrs; attrs++) {
+ navit_set_attr_do(this_, *attrs, 1);
+ }
+ this_->displaylist=graphics_displaylist_new();
+ command_add_table(this_->attr_cbl, commands, sizeof(commands)/sizeof(struct command_table), this_);
- this_->messages = messagelist_new(attrs);
+ this_->messages = messagelist_new(attrs);
- dbg(lvl_debug,"return %p\n",this_);
-
- return this_;
+ dbg(lvl_debug,"return %p",this_);
+
+ return this_;
}
-static int
-navit_set_gui(struct navit *this_, struct gui *gui)
-{
- if (this_->gui)
- return 0;
- this_->gui=gui;
- if (gui_has_main_loop(this_->gui)) {
- if (! main_loop_gui) {
- main_loop_gui=this_->gui;
- } else {
- dbg(lvl_error,"gui with main loop already active, ignoring this instance");
- return 0;
- }
- }
- return 1;
+static int navit_set_gui(struct navit *this_, struct gui *gui) {
+ if (this_->gui)
+ return 0;
+ this_->gui=gui;
+ if (gui_has_main_loop(this_->gui)) {
+ if (! main_loop_gui) {
+ main_loop_gui=this_->gui;
+ } else {
+ dbg(lvl_error,"gui with main loop already active, ignoring this instance");
+ return 0;
+ }
+ }
+ return 1;
}
-void
-navit_add_message(struct navit *this_, const char *message)
-{
- message_new(this_->messages, message);
+void navit_add_message(struct navit *this_, const char *message) {
+ message_new(this_->messages, message);
}
struct message
-*navit_get_messages(struct navit *this_)
-{
- return message_get(this_->messages);
+*navit_get_messages(struct navit *this_) {
+ return message_get(this_->messages);
}
-static int
-navit_set_graphics(struct navit *this_, struct graphics *gra)
-{
- if (this_->gra)
- return 0;
- this_->gra=gra;
- this_->resize_callback=callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_);
- graphics_add_callback(gra, this_->resize_callback);
- this_->button_callback=callback_new_attr_1(callback_cast(navit_button), attr_button, this_);
- graphics_add_callback(gra, this_->button_callback);
- this_->motion_callback=callback_new_attr_1(callback_cast(navit_motion), attr_motion, this_);
- graphics_add_callback(gra, this_->motion_callback);
- this_->predraw_callback=callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_);
- graphics_add_callback(gra, this_->predraw_callback);
- return 1;
+static int navit_set_graphics(struct navit *this_, struct graphics *gra) {
+ if (this_->gra)
+ return 0;
+ this_->gra=gra;
+ this_->resize_callback=callback_new_attr_1(callback_cast(navit_resize), attr_resize, this_);
+ graphics_add_callback(gra, this_->resize_callback);
+ this_->button_callback=callback_new_attr_1(callback_cast(navit_button), attr_button, this_);
+ graphics_add_callback(gra, this_->button_callback);
+ this_->motion_callback=callback_new_attr_1(callback_cast(navit_motion), attr_motion, this_);
+ graphics_add_callback(gra, this_->motion_callback);
+ this_->predraw_callback=callback_new_attr_1(callback_cast(navit_predraw), attr_predraw, this_);
+ graphics_add_callback(gra, this_->predraw_callback);
+ return 1;
}
struct graphics *
-navit_get_graphics(struct navit *this_)
-{
- return this_->gra;
+navit_get_graphics(struct navit *this_) {
+ return this_->gra;
}
struct vehicleprofile *
-navit_get_vehicleprofile(struct navit *this_)
-{
- return this_->vehicleprofile;
+navit_get_vehicleprofile(struct navit *this_) {
+ return this_->vehicleprofile;
}
-GList *
-navit_get_vehicleprofiles(struct navit *this_)
-{
- return this_->vehicleprofiles;
+GList *navit_get_vehicleprofiles(struct navit *this_) {
+ return this_->vehicleprofiles;
}
-static void
-navit_projection_set(struct navit *this_, enum projection pro, int draw)
-{
- struct coord_geo g;
- struct coord *c;
+static void navit_projection_set(struct navit *this_, enum projection pro, int draw) {
+ struct coord_geo g;
+ struct coord *c;
- c=transform_center(this_->trans);
- transform_to_geo(transform_get_projection(this_->trans), c, &g);
- transform_set_projection(this_->trans, pro);
- transform_from_geo(pro, &g, c);
- if (draw)
- navit_draw(this_);
+ c=transform_center(this_->trans);
+ transform_to_geo(transform_get_projection(this_->trans), c, &g);
+ transform_set_projection(this_->trans, pro);
+ transform_from_geo(pro, &g, c);
+ if (draw)
+ navit_draw(this_);
}
-static void
-navit_mark_navigation_stopped(char *former_destination_file){
- FILE *f;
- f=fopen(former_destination_file, "a");
- if (f) {
- fprintf(f,"%s", TEXTFILE_COMMENT_NAVI_STOPPED);
- fclose(f);
- }else{
- dbg(lvl_error, "Error setting mark in destination file %s: %s\n", former_destination_file, strerror(errno));
- }
+static void navit_mark_navigation_stopped(char *former_destination_file) {
+ FILE *f;
+ f=fopen(former_destination_file, "a");
+ if (f) {
+ fprintf(f,"%s", TEXTFILE_COMMENT_NAVI_STOPPED);
+ fclose(f);
+ } else {
+ dbg(lvl_error, "Error setting mark in destination file %s: %s", former_destination_file, strerror(errno));
+ }
}
@@ -1876,51 +1903,52 @@ navit_mark_navigation_stopped(char *former_destination_file){
* @param async Set to 1 to do route calculation asynchronously
* @return nothing
*/
-void
-navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async)
-{
- char *destination_file;
- destination_file = bookmarks_get_destination_file(TRUE);
- if (c) {
- this_->destination=*c;
- this_->destination_valid=1;
-
- dbg(lvl_debug, "c=(%i,%i)\n", c->x,c->y);
- bookmarks_append_destinations(this_->former_destination, destination_file, c, 1, type_former_destination, description, this_->recentdest_count);
- } else {
- this_->destination_valid=0;
- bookmarks_append_destinations(this_->former_destination, destination_file, NULL, 0, type_former_destination, NULL, this_->recentdest_count);
- navit_mark_navigation_stopped(destination_file);
- }
- g_free(destination_file);
-
- callback_list_call_attr_0(this_->attr_cbl, attr_destination);
-
- if (this_->route) {
- struct attr attr;
- int dstcount;
- struct pcoord *pc;
-
- navit_get_attr(this_, attr_waypoints_flag, &attr, NULL);
- if (this_->waypoints_flag==0 || route_get_destination_count(this_->route)==0){
- route_set_destination(this_->route, c, async);
- }else{
- route_append_destination(this_->route, c, async);
- }
+void navit_set_destination(struct navit *this_, struct pcoord *c, const char *description, int async) {
+ char *destination_file;
+ destination_file = bookmarks_get_destination_file(TRUE);
+ if (c) {
+ this_->destination=*c;
+ this_->destination_valid=1;
+
+ dbg(lvl_debug, "c=(%i,%i)", c->x,c->y);
+ bookmarks_append_destinations(this_->former_destination, destination_file, c, 1, type_former_destination, description,
+ this_->recentdest_count);
+ } else {
+ this_->destination_valid=0;
+ bookmarks_append_destinations(this_->former_destination, destination_file, NULL, 0, type_former_destination, NULL,
+ this_->recentdest_count);
+ navit_mark_navigation_stopped(destination_file);
+ }
+ g_free(destination_file);
- dstcount=route_get_destination_count(this_->route);
- if(dstcount>0) {
- destination_file = bookmarks_get_destination_file(TRUE);
- pc=g_new(struct pcoord,dstcount);
- route_get_destinations(this_->route,pc,dstcount);
- bookmarks_append_destinations(this_->former_destination, destination_file, pc, dstcount, type_former_itinerary, description, this_->recentdest_count);
- g_free(pc);
- g_free(destination_file);
- }
+ callback_list_call_attr_0(this_->attr_cbl, attr_destination);
- if (this_->ready == 3 && !(this_->flags & 4))
- navit_draw(this_);
- }
+ if (this_->route) {
+ struct attr attr;
+ int dstcount;
+ struct pcoord *pc;
+
+ navit_get_attr(this_, attr_waypoints_flag, &attr, NULL);
+ if (this_->waypoints_flag==0 || route_get_destination_count(this_->route)==0) {
+ route_set_destination(this_->route, c, async);
+ } else {
+ route_append_destination(this_->route, c, async);
+ }
+
+ dstcount=route_get_destination_count(this_->route);
+ if(dstcount>0) {
+ destination_file = bookmarks_get_destination_file(TRUE);
+ pc=g_new(struct pcoord,dstcount);
+ route_get_destinations(this_->route,pc,dstcount);
+ bookmarks_append_destinations(this_->former_destination, destination_file, pc, dstcount, type_former_itinerary,
+ description, this_->recentdest_count);
+ g_free(pc);
+ g_free(destination_file);
+ }
+
+ if (this_->ready == 3 && !(this_->flags & 4))
+ navit_draw(this_);
+ }
}
/**
@@ -1931,15 +1959,14 @@ navit_set_destination(struct navit *this_, struct pcoord *c, const char *descrip
* @param description A label which allows the user to later identify this destination in the former destinations selection
* @returns nothing
*/
-void
-navit_add_destination_description(struct navit *this_, struct pcoord *c, const char *description)
-{
- char *destination_file;
- if (c) {
- destination_file = bookmarks_get_destination_file(TRUE);
- bookmarks_append_destinations(this_->former_destination, destination_file, c, 1, type_former_destination, description, this_->recentdest_count);
- g_free(destination_file);
- }
+void navit_add_destination_description(struct navit *this_, struct pcoord *c, const char *description) {
+ char *destination_file;
+ if (c) {
+ destination_file = bookmarks_get_destination_file(TRUE);
+ bookmarks_append_destinations(this_->former_destination, destination_file, c, 1, type_former_destination, description,
+ this_->recentdest_count);
+ g_free(destination_file);
+ }
}
@@ -1952,75 +1979,64 @@ navit_add_destination_description(struct navit *this_, struct pcoord *c, const c
* @param async If routing should be done asynchronously
* @returns nothing
*/
-void
-navit_set_destinations(struct navit *this_, struct pcoord *c, int count, const char *description, int async)
-{
- char *destination_file;
- if (c && count) {
- this_->destination=c[count-1];
- this_->destination_valid=1;
-
- destination_file = bookmarks_get_destination_file(TRUE);
- bookmarks_append_destinations(this_->former_destination, destination_file, c, count, type_former_itinerary, description, this_->recentdest_count);
- g_free(destination_file);
- } else
- this_->destination_valid=0;
- callback_list_call_attr_0(this_->attr_cbl, attr_destination);
- if (this_->route) {
- route_set_destinations(this_->route, c, count, async);
-
- if (this_->ready == 3)
- navit_draw(this_);
- }
+void navit_set_destinations(struct navit *this_, struct pcoord *c, int count, const char *description, int async) {
+ char *destination_file;
+ if (c && count) {
+ this_->destination=c[count-1];
+ this_->destination_valid=1;
+
+ destination_file = bookmarks_get_destination_file(TRUE);
+ bookmarks_append_destinations(this_->former_destination, destination_file, c, count, type_former_itinerary, description,
+ this_->recentdest_count);
+ g_free(destination_file);
+ } else
+ this_->destination_valid=0;
+ callback_list_call_attr_0(this_->attr_cbl, attr_destination);
+ if (this_->route) {
+ route_set_destinations(this_->route, c, count, async);
+
+ if (this_->ready == 3)
+ navit_draw(this_);
+ }
}
-int
-navit_get_destinations(struct navit *this_, struct pcoord *pc, int count)
-{
- if(!this_->route)
- return 0;
- return route_get_destinations(this_->route, pc, count);
+int navit_get_destinations(struct navit *this_, struct pcoord *pc, int count) {
+ if(!this_->route)
+ return 0;
+ return route_get_destinations(this_->route, pc, count);
}
-int
-navit_get_destination_count(struct navit *this_)
-{
- if(!this_->route)
- return 0;
- return route_get_destination_count(this_->route);
+int navit_get_destination_count(struct navit *this_) {
+ if(!this_->route)
+ return 0;
+ return route_get_destination_count(this_->route);
}
-char*
-navit_get_destination_description(struct navit *this_, int n)
-{
- if(!this_->route)
- return NULL;
- return route_get_destination_description(this_->route, n);
+char* navit_get_destination_description(struct navit *this_, int n) {
+ if(!this_->route)
+ return NULL;
+ return route_get_destination_description(this_->route, n);
}
-void
-navit_remove_nth_waypoint(struct navit *this_, int n)
-{
- if(!this_->route)
- return;
- if (route_get_destination_count(this_->route)>1){
- route_remove_nth_waypoint(this_->route, n);
- }else{
- navit_set_destination(this_, NULL, NULL, 0);
- }
+void navit_remove_nth_waypoint(struct navit *this_, int n) {
+ if(!this_->route)
+ return;
+ if (route_get_destination_count(this_->route)>1) {
+ route_remove_nth_waypoint(this_->route, n);
+ } else {
+ navit_set_destination(this_, NULL, NULL, 0);
+ }
}
-void
-navit_remove_waypoint(struct navit *this_)
-{
- if(!this_->route)
- return;
- if (route_get_destination_count(this_->route)>1){
- route_remove_waypoint(this_->route);
- }else{
- navit_set_destination(this_, NULL, NULL, 0);
- }
+void navit_remove_waypoint(struct navit *this_) {
+ if(!this_->route)
+ return;
+ if (route_get_destination_count(this_->route)>1) {
+ route_remove_waypoint(this_->route);
+ } else {
+ navit_set_destination(this_, NULL, NULL, 0);
+ }
}
/**
@@ -2031,158 +2047,148 @@ navit_remove_waypoint(struct navit *this_)
* @param this_ The navit struct whose route should be checked.
* @return True if the route is set, false otherwise.
*/
-int
-navit_check_route(struct navit *this_)
-{
- if (this_->route) {
- return route_get_path_set(this_->route);
- }
+int navit_check_route(struct navit *this_) {
+ if (this_->route) {
+ return route_get_path_set(this_->route);
+ }
- return 0;
+ return 0;
}
-static int
-navit_former_destinations_active(struct navit *this_)
-{
- char *destination_file_name = bookmarks_get_destination_file(FALSE);
- FILE *destination_file;
- int active=0;
- char lastline[100];
- destination_file=fopen(destination_file_name,"r");
- if (destination_file) {
- while(fgets(lastline, sizeof(lastline), destination_file));
- fclose(destination_file);
- if ((lastline != NULL) && (strcmp(lastline, TEXTFILE_COMMENT_NAVI_STOPPED))){
- active=1;
- }
- }
- g_free(destination_file_name);
- return active;
+static int navit_former_destinations_active(struct navit *this_) {
+ char *destination_file_name = bookmarks_get_destination_file(FALSE);
+ FILE *destination_file;
+ int active=0;
+ char lastline[100];
+ destination_file=fopen(destination_file_name,"r");
+ if (destination_file) {
+ while(fgets(lastline, sizeof(lastline), destination_file));
+ fclose(destination_file);
+ if ((lastline != NULL) && (strcmp(lastline, TEXTFILE_COMMENT_NAVI_STOPPED))) {
+ active=1;
+ }
+ }
+ g_free(destination_file_name);
+ return active;
}
-struct map* read_former_destinations_from_file(){
- struct attr type, data, no_warn, flags, *attrs[5];
- char *destination_file = bookmarks_get_destination_file(FALSE);
- struct map *m;
+struct map* read_former_destinations_from_file() {
+ struct attr type, data, no_warn, flags, *attrs[5];
+ char *destination_file = bookmarks_get_destination_file(FALSE);
+ struct map *m;
- type.type=attr_type;
- type.u.str="textfile";
+ type.type=attr_type;
+ type.u.str="textfile";
- data.type=attr_data;
- data.u.str=destination_file;
+ data.type=attr_data;
+ data.u.str=destination_file;
- no_warn.type=attr_no_warning_if_map_file_missing;
- no_warn.u.num=1;
+ no_warn.type=attr_no_warning_if_map_file_missing;
+ no_warn.u.num=1;
- flags.type=attr_flags;
- flags.u.num=1;
+ flags.type=attr_flags;
+ flags.u.num=1;
- attrs[0]=&type; attrs[1]=&data; attrs[2]=&flags;
- attrs[3]=&no_warn; attrs[4]=NULL;
+ attrs[0]=&type;
+ attrs[1]=&data;
+ attrs[2]=&flags;
+ attrs[3]=&no_warn;
+ attrs[4]=NULL;
- m=map_new(NULL, attrs);
- g_free(destination_file);
- return m;
+ m=map_new(NULL, attrs);
+ g_free(destination_file);
+ return m;
}
-static void
-navit_add_former_destinations_from_file(struct navit *this_)
-{
- struct item *item;
- int i,valid=0,count=0,maxcount=1;
- struct coord *c=g_new(struct coord, maxcount);
- struct pcoord *pc;
- struct map_rect *mr;
-
- this_->former_destination=read_former_destinations_from_file();
- if (!this_->route || !navit_former_destinations_active(this_) || !this_->vehicle)
- return;
- mr=map_rect_new(this_->former_destination, NULL);
- while ((item=map_rect_get_item(mr))) {
- if (item->type == type_former_itinerary || item->type == type_former_itinerary_part) {
- count=item_coord_get(item, c, maxcount);
- while(count==maxcount) {
- maxcount*=2;
- c=g_realloc(c, sizeof(struct coord)*maxcount);
- count+=item_coord_get(item, &c[count], maxcount-count);
- }
- if(count)
- valid=1;
- }
- }
- map_rect_destroy(mr);
- if (valid && count > 0) {
- pc=g_new(struct pcoord, count);
- for (i = 0 ; i < count ; i++) {
- pc[i].pro=map_projection(this_->former_destination);
- pc[i].x=c[i].x;
- pc[i].y=c[i].y;
- }
- if (count == 1)
- route_set_destination(this_->route, &pc[0], 1);
- else
- route_set_destinations(this_->route, pc, count, 1);
- this_->destination=pc[count-1];
- this_->destination_valid=1;
- g_free(pc);
- }
- g_free(c);
-}
+static void navit_add_former_destinations_from_file(struct navit *this_) {
+ struct item *item;
+ int i,valid=0,count=0,maxcount=1;
+ struct coord *c=g_new(struct coord, maxcount);
+ struct pcoord *pc;
+ struct map_rect *mr;
-
-void
-navit_textfile_debug_log(struct navit *this_, const char *fmt, ...)
-{
- va_list ap;
- char *str1,*str2;
- va_start(ap, fmt);
- if (this_->textfile_debug_log && this_->vehicle) {
- str1=g_strdup_vprintf(fmt, ap);
- str2=g_strdup_printf("0x%x 0x%x%s%s\n", this_->vehicle->coord.x, this_->vehicle->coord.y, strlen(str1) ? " " : "", str1);
- log_write(this_->textfile_debug_log, str2, strlen(str2), 0);
- g_free(str2);
- g_free(str1);
- }
- va_end(ap);
+ this_->former_destination=read_former_destinations_from_file();
+ if (!this_->route || !navit_former_destinations_active(this_) || !this_->vehicle)
+ return;
+ mr=map_rect_new(this_->former_destination, NULL);
+ while ((item=map_rect_get_item(mr))) {
+ if (item->type == type_former_itinerary || item->type == type_former_itinerary_part) {
+ count=item_coord_get(item, c, maxcount);
+ while(count==maxcount) {
+ maxcount*=2;
+ c=g_realloc(c, sizeof(struct coord)*maxcount);
+ count+=item_coord_get(item, &c[count], maxcount-count);
+ }
+ if(count)
+ valid=1;
+ }
+ }
+ map_rect_destroy(mr);
+ if (valid && count > 0) {
+ pc=g_new(struct pcoord, count);
+ for (i = 0 ; i < count ; i++) {
+ pc[i].pro=map_projection(this_->former_destination);
+ pc[i].x=c[i].x;
+ pc[i].y=c[i].y;
+ }
+ if (count == 1)
+ route_set_destination(this_->route, &pc[0], 1);
+ else
+ route_set_destinations(this_->route, pc, count, 1);
+ this_->destination=pc[count-1];
+ this_->destination_valid=1;
+ g_free(pc);
+ }
+ g_free(c);
}
-void
-navit_textfile_debug_log_at(struct navit *this_, struct pcoord *pc, const char *fmt, ...)
-{
- va_list ap;
- char *str1,*str2;
- va_start(ap, fmt);
- if (this_->textfile_debug_log && this_->vehicle) {
- str1=g_strdup_vprintf(fmt, ap);
- str2=g_strdup_printf("0x%x 0x%x%s%s\n", pc->x, pc->y, strlen(str1) ? " " : "", str1);
- log_write(this_->textfile_debug_log, str2, strlen(str2), 0);
- g_free(str2);
- g_free(str1);
- }
- va_end(ap);
+
+void navit_textfile_debug_log(struct navit *this_, const char *fmt, ...) {
+ va_list ap;
+ char *str1,*str2;
+ va_start(ap, fmt);
+ if (this_->textfile_debug_log && this_->vehicle) {
+ str1=g_strdup_vprintf(fmt, ap);
+ str2=g_strdup_printf("0x%x 0x%x%s%s\n", this_->vehicle->coord.x, this_->vehicle->coord.y, strlen(str1) ? " " : "",
+ str1);
+ log_write(this_->textfile_debug_log, str2, strlen(str2), 0);
+ g_free(str2);
+ g_free(str1);
+ }
+ va_end(ap);
+}
+
+void navit_textfile_debug_log_at(struct navit *this_, struct pcoord *pc, const char *fmt, ...) {
+ va_list ap;
+ char *str1,*str2;
+ va_start(ap, fmt);
+ if (this_->textfile_debug_log && this_->vehicle) {
+ str1=g_strdup_vprintf(fmt, ap);
+ str2=g_strdup_printf("0x%x 0x%x%s%s\n", pc->x, pc->y, strlen(str1) ? " " : "", str1);
+ log_write(this_->textfile_debug_log, str2, strlen(str2), 0);
+ g_free(str2);
+ g_free(str1);
+ }
+ va_end(ap);
}
-void
-navit_say(struct navit *this_, const char *text)
-{
- struct attr attr;
- if(this_->speech) {
- if (!speech_get_attr(this_->speech, attr_active, &attr, NULL))
- attr.u.num = 1;
- dbg(lvl_debug, "this_.speech->active %ld\n", attr.u.num);
- if(attr.u.num)
- speech_say(this_->speech, text);
- }
+void navit_say(struct navit *this_, const char *text) {
+ struct attr attr;
+ if(this_->speech) {
+ if (!speech_get_attr(this_->speech, attr_active, &attr, NULL))
+ attr.u.num = 1;
+ dbg(lvl_debug, "this_.speech->active %ld", attr.u.num);
+ if(attr.u.num)
+ speech_say(this_->speech, text);
+ }
}
/**
* @brief Toggles the navigation announcer for navit
* @param this_ The navit object
*/
-static void
-navit_cmd_announcer_toggle(struct navit *this_)
-{
+static void navit_cmd_announcer_toggle(struct navit *this_) {
struct attr attr, speechattr;
// search for the speech attribute
@@ -2206,377 +2212,377 @@ navit_cmd_announcer_toggle(struct navit *this_)
callback_list_call_attr_1(this_->attr_cbl, attr_speech, this_);
}
-void
-navit_speak(struct navit *this_)
-{
- struct navigation *nav=this_->navigation;
- struct map *map=NULL;
- struct map_rect *mr=NULL;
- struct item *item;
- struct attr attr;
+void navit_speak(struct navit *this_) {
+ struct navigation *nav=this_->navigation;
+ struct map *map=NULL;
+ struct map_rect *mr=NULL;
+ struct item *item;
+ struct attr attr;
if (!speech_get_attr(this_->speech, attr_active, &attr, NULL))
attr.u.num = 1;
- dbg(lvl_debug, "this_.speech->active %ld\n", attr.u.num);
+ dbg(lvl_debug, "this_.speech->active %ld", attr.u.num);
if(!attr.u.num)
return;
- if (nav)
- map=navigation_get_map(nav);
- if (map)
- mr=map_rect_new(map, NULL);
- if (mr) {
- while ((item=map_rect_get_item(mr)) && (item->type == type_nav_position || item->type == type_nav_none));
- if (item && item_attr_get(item, attr_navigation_speech, &attr)) {
- if (*attr.u.str != '\0') {
- speech_say(this_->speech, attr.u.str);
- navit_add_message(this_, attr.u.str);
- }
- navit_textfile_debug_log(this_, "type=announcement label=\"%s\"", attr.u.str);
- }
- map_rect_destroy(mr);
- }
+ if (nav)
+ map=navigation_get_map(nav);
+ if (map)
+ mr=map_rect_new(map, NULL);
+ if (mr) {
+ while ((item=map_rect_get_item(mr)) && (item->type == type_nav_position || item->type == type_nav_none));
+ if (item && item_attr_get(item, attr_navigation_speech, &attr)) {
+ if (*attr.u.str != '\0') {
+ speech_say(this_->speech, attr.u.str);
+ navit_add_message(this_, attr.u.str);
+ }
+ navit_textfile_debug_log(this_, "type=announcement label=\"%s\"", attr.u.str);
+ }
+ map_rect_destroy(mr);
+ }
}
-static void
-navit_window_roadbook_update(struct navit *this_)
-{
- struct navigation *nav=this_->navigation;
- struct map *map=NULL;
- struct map_rect *mr=NULL;
- struct item *item;
- struct attr attr;
- struct param_list param[5];
- int secs;
-
- /* Respect the Imperial attribute as we enlighten the user. */
- int imperial = FALSE; /* default to using metric measures. */
- if (navit_get_attr(this_, attr_imperial, &attr, NULL))
- imperial=attr.u.num;
-
- dbg(lvl_debug,"enter\n");
- datawindow_mode(this_->roadbook_window, 1);
- if (nav)
- map=navigation_get_map(nav);
- if (map)
- mr=map_rect_new(map, NULL);
- dbg(lvl_debug,"nav=%p map=%p mr=%p\n", nav, map, mr);
- if (mr) {
- dbg(lvl_debug,"while loop\n");
- while ((item=map_rect_get_item(mr))) {
- dbg(lvl_debug,"item=%p\n", item);
- attr.u.str=NULL;
- if (item->type != type_nav_position) {
- item_attr_get(item, attr_navigation_long, &attr);
- if (attr.u.str == NULL) {
- continue;
- }
- dbg(lvl_info, "Command='%s'\n", attr.u.str);
- param[0].value=g_strdup(attr.u.str);
- } else
- param[0].value=_("Position");
- param[0].name=_("Command");
-
- item_attr_get(item, attr_length, &attr);
- dbg(lvl_info, "Length=%ld\n", attr.u.num);
- param[1].name=_("Length");
-
- if ( attr.u.num >= 2000 )
- {
- param[1].value=g_strdup_printf("%5.1f %s",
- imperial == TRUE ? (float)attr.u.num / METERS_PER_MILE : (float)attr.u.num / 1000,
- imperial == TRUE ? _("mi") : _("km")
- );
- }
- else
- {
- param[1].value=g_strdup_printf("%7.0f %s",
- imperial == TRUE ? (attr.u.num * FEET_PER_METER) : attr.u.num,
- imperial == TRUE ? _("feet") : _("m")
- );
- }
-
- item_attr_get(item, attr_time, &attr);
- dbg(lvl_info, "Time=%ld\n", attr.u.num);
- secs=attr.u.num/10;
- param[2].name=_("Time");
- if ( secs >= 3600 )
- {
- param[2].value=g_strdup_printf("%d:%02d:%02d",secs / 60, ( secs / 60 ) % 60 , secs % 60);
- }
- else
- {
- param[2].value=g_strdup_printf("%d:%02d",secs / 60, secs % 60);
- }
-
- item_attr_get(item, attr_destination_length, &attr);
- dbg(lvl_info, "Destlength=%ld\n", attr.u.num);
- param[3].name=_("Destination Length");
- if ( attr.u.num >= 2000 )
- {
- param[3].value=g_strdup_printf("%5.1f %s",
- imperial == TRUE ? (float)attr.u.num / METERS_PER_MILE : (float)attr.u.num / 1000,
- imperial == TRUE ? _("mi") : _("km")
- );
- }
- else
- {
- param[3].value=g_strdup_printf("%7.0f %s",
- imperial == TRUE ? (attr.u.num * FEET_PER_METER) : attr.u.num,
- imperial == TRUE ? _("feet") : _("m")
- );
- }
-
- item_attr_get(item, attr_destination_time, &attr);
- dbg(lvl_info, "Desttime=%ld\n", attr.u.num);
- secs=attr.u.num/10;
- param[4].name=_("Destination Time");
- if ( secs >= 3600 )
- {
- param[4].value=g_strdup_printf("%d:%02d:%02d",secs / 3600, (secs / 60 ) % 60 , secs % 60);
- }
- else
- {
- param[4].value=g_strdup_printf("%d:%02d",secs / 60, secs % 60);
- }
- datawindow_add(this_->roadbook_window, param, 5);
- }
- map_rect_destroy(mr);
- }
- datawindow_mode(this_->roadbook_window, 0);
+static void navit_window_roadbook_update(struct navit *this_) {
+ struct navigation *nav=this_->navigation;
+ struct map *map=NULL;
+ struct map_rect *mr=NULL;
+ struct item *item;
+ struct attr attr;
+ struct param_list param[5];
+ int secs;
+
+ /* Respect the Imperial attribute as we enlighten the user. */
+ int imperial = FALSE; /* default to using metric measures. */
+ if (navit_get_attr(this_, attr_imperial, &attr, NULL))
+ imperial=attr.u.num;
+
+ dbg(lvl_debug,"enter");
+ datawindow_mode(this_->roadbook_window, 1);
+ if (nav)
+ map=navigation_get_map(nav);
+ if (map)
+ mr=map_rect_new(map, NULL);
+ dbg(lvl_debug,"nav=%p map=%p mr=%p", nav, map, mr);
+ if (mr) {
+ dbg(lvl_debug,"while loop");
+ while ((item=map_rect_get_item(mr))) {
+ dbg(lvl_debug,"item=%p", item);
+ attr.u.str=NULL;
+ if (item->type != type_nav_position) {
+ item_attr_get(item, attr_navigation_long, &attr);
+ if (attr.u.str == NULL) {
+ continue;
+ }
+ dbg(lvl_info, "Command='%s'", attr.u.str);
+ param[0].value=g_strdup(attr.u.str);
+ } else
+ param[0].value=_("Position");
+ param[0].name=_("Command");
+
+ /* Distance to the next maneuver. */
+ item_attr_get(item, attr_length, &attr);
+ dbg(lvl_info, "Length=%ld in meters", attr.u.num);
+ param[1].name=_("Length");
+
+ if ( attr.u.num >= 2000 ) {
+ param[1].value=g_strdup_printf("%5.1f %s",
+ imperial == TRUE ? (float)attr.u.num * METERS_TO_MILES : (float)attr.u.num / 1000,
+ imperial == TRUE ? _("mi") : _("km")
+ );
+ } else {
+ param[1].value=g_strdup_printf("%7.0f %s",
+ imperial == TRUE ? (attr.u.num * FEET_PER_METER) : attr.u.num,
+ imperial == TRUE ? _("feet") : _("m")
+ );
+ }
+
+ /* Time to next maneuver. */
+ item_attr_get(item, attr_time, &attr);
+ dbg(lvl_info, "Time=%ld", attr.u.num);
+ secs=attr.u.num/10;
+ param[2].name=_("Time");
+ if ( secs >= 3600 ) {
+ param[2].value=g_strdup_printf("%d:%02d:%02d",secs / 60, ( secs / 60 ) % 60, secs % 60);
+ } else {
+ param[2].value=g_strdup_printf("%d:%02d",secs / 60, secs % 60);
+ }
+
+ /* Distance from next maneuver to destination. */
+ item_attr_get(item, attr_destination_length, &attr);
+ dbg(lvl_info, "Destlength=%ld in meters.", attr.u.num);
+ param[3].name=_("Destination Length");
+ if ( attr.u.num >= 2000 ) {
+ param[3].value=g_strdup_printf("%5.1f %s",
+ imperial == TRUE ? (float)attr.u.num * METERS_TO_MILES : (float)attr.u.num / 1000,
+ imperial == TRUE ? _("mi") : _("km")
+ );
+ } else {
+ param[3].value=g_strdup_printf("%7.0f %s",
+ imperial == TRUE ? (attr.u.num * FEET_PER_METER) : attr.u.num,
+ imperial == TRUE ? _("feet") : _("m")
+ );
+ }
+
+ /* Time from next maneuver to destination. */
+ item_attr_get(item, attr_destination_time, &attr);
+ dbg(lvl_info, "Desttime=%ld", attr.u.num);
+ secs=attr.u.num/10;
+ param[4].name=_("Destination Time");
+ if ( secs >= 3600 ) {
+ param[4].value=g_strdup_printf("%d:%02d:%02d",secs / 3600, (secs / 60 ) % 60, secs % 60);
+ } else {
+ param[4].value=g_strdup_printf("%d:%02d",secs / 60, secs % 60);
+ }
+ datawindow_add(this_->roadbook_window, param, 5);
+ }
+ map_rect_destroy(mr);
+ }
+ datawindow_mode(this_->roadbook_window, 0);
}
-void
-navit_window_roadbook_destroy(struct navit *this_)
-{
- dbg(lvl_debug, "enter\n");
- navigation_unregister_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback);
- callback_destroy(this_->roadbook_callback);
- this_->roadbook_window=NULL;
- this_->roadbook_callback=NULL;
+void navit_window_roadbook_destroy(struct navit *this_) {
+ dbg(lvl_debug, "enter");
+ navigation_unregister_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback);
+ callback_destroy(this_->roadbook_callback);
+ this_->roadbook_window=NULL;
+ this_->roadbook_callback=NULL;
}
-void
-navit_window_roadbook_new(struct navit *this_)
-{
- if (!this_->gui || this_->roadbook_callback || this_->roadbook_window) {
- return;
- }
+void navit_window_roadbook_new(struct navit *this_) {
+ if (!this_->gui || this_->roadbook_callback || this_->roadbook_window) {
+ return;
+ }
- this_->roadbook_callback=callback_new_1(callback_cast(navit_window_roadbook_update), this_);
- navigation_register_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback);
- this_->roadbook_window=gui_datawindow_new(this_->gui, _("Roadbook"), NULL, callback_new_1(callback_cast(navit_window_roadbook_destroy), this_));
- navit_window_roadbook_update(this_);
+ this_->roadbook_callback=callback_new_1(callback_cast(navit_window_roadbook_update), this_);
+ navigation_register_callback(this_->navigation, attr_navigation_long, this_->roadbook_callback);
+ this_->roadbook_window=gui_datawindow_new(this_->gui, _("Roadbook"), NULL,
+ callback_new_1(callback_cast(navit_window_roadbook_destroy), this_));
+ navit_window_roadbook_update(this_);
}
-void
-navit_init(struct navit *this_)
-{
- struct mapset *ms;
- struct map *map;
- int callback;
- char *center_file;
-
- dbg(lvl_info,"enter gui %p graphics %p\n",this_->gui,this_->gra);
-
- if (!this_->gui && !(this_->flags & 2)) {
- dbg(lvl_error,"FATAL: No GUI available.\n");
- exit(1);
- }
- if (!this_->gra && !(this_->flags & 1)) {
- dbg(lvl_error,"FATAL: No graphics subsystem available.\n");
- exit(1);
- }
- dbg(lvl_info,"Connecting gui to graphics\n");
- if (this_->gui && this_->gra && gui_set_graphics(this_->gui, this_->gra)) {
- struct attr attr_type_gui, attr_type_graphics;
- gui_get_attr(this_->gui, attr_type, &attr_type_gui, NULL);
- graphics_get_attr(this_->gra, attr_type, &attr_type_graphics, NULL);
- dbg(lvl_error,"FATAL: Failed to connect graphics '%s' to gui '%s'\n", attr_type_graphics.u.str, attr_type_gui.u.str);
- dbg(lvl_error,"Please see http://wiki.navit-project.org/index.php/Failed_to_connect_graphics_to_gui "
- "for explanations and solutions\n");
- exit(1);
- }
- if (this_->speech && this_->navigation) {
- struct attr speech;
- speech.type=attr_speech;
- speech.u.speech=this_->speech;
- navigation_set_attr(this_->navigation, &speech);
- }
- dbg(lvl_info,"Initializing graphics\n");
- dbg(lvl_info,"Setting Vehicle\n");
- navit_set_vehicle(this_, this_->vehicle);
- dbg(lvl_info,"Adding dynamic maps to mapset %p\n",this_->mapsets);
- if (this_->mapsets) {
- struct mapset_handle *msh;
- ms=this_->mapsets->data;
- this_->progress_cb=callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_);
- msh=mapset_open(ms);
- while (msh && (map=mapset_next(msh, 0))) {
- //pass new callback instance for each map in the mapset to make map callback list destruction work correctly
- struct callback *pcb = callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_);
- map_add_callback(map, pcb);
- }
- mapset_close(msh);
-
- if (this_->route) {
- if ((map=route_get_map(this_->route))) {
- struct attr map_a;
- map_a.type=attr_map;
- map_a.u.map=map;
- mapset_add_attr(ms, &map_a);
- }
- if ((map=route_get_graph_map(this_->route))) {
- struct attr map_a,active;
- map_a.type=attr_map;
- map_a.u.map=map;
- active.type=attr_active;
- active.u.num=0;
- mapset_add_attr(ms, &map_a);
- map_set_attr(map, &active);
- }
- route_set_mapset(this_->route, ms);
- route_set_projection(this_->route, transform_get_projection(this_->trans));
- }
- if (this_->tracking) {
- tracking_set_mapset(this_->tracking, ms);
- if (this_->route)
- tracking_set_route(this_->tracking, this_->route);
- }
- if (this_->navigation) {
- if ((map=navigation_get_map(this_->navigation))) {
- struct attr map_a,active;
- map_a.type=attr_map;
- map_a.u.map=map;
- active.type=attr_active;
- active.u.num=0;
- mapset_add_attr(ms, &map_a);
- map_set_attr(map, &active);
- }
- }
- if (this_->tracking) {
- if ((map=tracking_get_map(this_->tracking))) {
- struct attr map_a,active;
- map_a.type=attr_map;
- map_a.u.map=map;
- active.type=attr_active;
- active.u.num=0;
- mapset_add_attr(ms, &map_a);
- map_set_attr(map, &active);
- }
- }
- navit_add_former_destinations_from_file(this_);
- } else {
- dbg(lvl_error, "FATAL: No mapset available. Please add a (valid) mapset to your configuration.\n");
- exit(1);
- }
- if (this_->route) {
- struct attr callback;
- this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
- callback.type=attr_callback;
- callback.u.callback=this_->route_cb;
- route_add_attr(this_->route, &callback);
- }
- if (this_->navigation) {
- if (this_->speech) {
- this_->nav_speech_cb=callback_new_1(callback_cast(navit_speak), this_);
- navigation_register_callback(this_->navigation, attr_navigation_speech, this_->nav_speech_cb);
- }
- if (this_->route)
- navigation_set_route(this_->navigation, this_->route);
- }
- dbg(lvl_info,"Setting Center\n");
- center_file = bookmarks_get_center_file(FALSE);
- bookmarks_set_center_from_file(this_->bookmarks, center_file);
- g_free(center_file);
- global_navit=this_;
-
- messagelist_init(this_->messages);
+void navit_init(struct navit *this_) {
+ struct mapset *ms;
+ struct map *map;
+ int callback;
+ char *center_file;
+ struct attr_iter *iter;
+ struct attr *attr;
+ struct traffic * traffic;
- navit_set_cursors(this_);
+ dbg(lvl_info,"enter gui %p graphics %p",this_->gui,this_->gra);
- callback_list_call_attr_1(this_->attr_cbl, attr_navit, this_);
- callback=(this_->ready == 2);
- this_->ready|=1;
- dbg(lvl_info,"ready=%d\n",this_->ready);
- if (this_->ready == 3)
- navit_draw_async(this_, 1);
- if (callback)
- callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_);
-}
+ if (!this_->gui && !(this_->flags & 2)) {
+ dbg(lvl_error,"FATAL: No GUI available.");
+ exit(1);
+ }
+ if (!this_->gra && !(this_->flags & 1)) {
+ dbg(lvl_error,"FATAL: No graphics subsystem available.");
+ exit(1);
+ }
+ dbg(lvl_info,"Connecting gui to graphics");
+ if (this_->gui && this_->gra && gui_set_graphics(this_->gui, this_->gra)) {
+ struct attr attr_type_gui, attr_type_graphics;
+ gui_get_attr(this_->gui, attr_type, &attr_type_gui, NULL);
+ graphics_get_attr(this_->gra, attr_type, &attr_type_graphics, NULL);
+ dbg(lvl_error,"FATAL: Failed to connect graphics '%s' to gui '%s'", attr_type_graphics.u.str, attr_type_gui.u.str);
+ dbg(lvl_error,"Please see http://wiki.navit-project.org/index.php/Failed_to_connect_graphics_to_gui "
+ "for explanations and solutions\n");
+ exit(1);
+ }
+ if (this_->speech && this_->navigation) {
+ struct attr speech;
+ speech.type=attr_speech;
+ speech.u.speech=this_->speech;
+ navigation_set_attr(this_->navigation, &speech);
+ }
+ dbg(lvl_info,"Initializing graphics");
+ dbg(lvl_info,"Setting Vehicle");
+ navit_set_vehicle(this_, this_->vehicle);
+ dbg(lvl_info,"Adding dynamic maps to mapset %p",this_->mapsets);
+ if (this_->mapsets) {
+ struct mapset_handle *msh;
+ ms=this_->mapsets->data;
+ this_->progress_cb=callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_);
+ msh=mapset_open(ms);
+ while (msh && (map=mapset_next(msh, 0))) {
+ //pass new callback instance for each map in the mapset to make map callback list destruction work correctly
+ struct callback *pcb = callback_new_attr_1(callback_cast(navit_map_progress), attr_progress, this_);
+ map_add_callback(map, pcb);
+ }
+ mapset_close(msh);
+
+ if (this_->route) {
+ if ((map=route_get_map(this_->route))) {
+ struct attr map_a;
+ map_a.type=attr_map;
+ map_a.u.map=map;
+ mapset_add_attr(ms, &map_a);
+ }
+ if ((map=route_get_graph_map(this_->route))) {
+ struct attr map_a,active;
+ map_a.type=attr_map;
+ map_a.u.map=map;
+ active.type=attr_active;
+ active.u.num=0;
+ mapset_add_attr(ms, &map_a);
+ map_set_attr(map, &active);
+ }
+ route_set_mapset(this_->route, ms);
+ route_set_projection(this_->route, transform_get_projection(this_->trans));
+ }
+ if (this_->tracking) {
+ tracking_set_mapset(this_->tracking, ms);
+ if (this_->route)
+ tracking_set_route(this_->tracking, this_->route);
+ }
-void
-navit_zoom_to_rect(struct navit *this_, struct coord_rect *r)
-{
- struct coord c;
- int w,h,scale=16;
-
- c.x=(r->rl.x+r->lu.x)/2;
- c.y=(r->rl.y+r->lu.y)/2;
- transform_set_center(this_->trans, &c);
- transform_get_size(this_->trans, &w, &h);
- dbg(lvl_debug,"center 0x%x,0x%x w %d h %d\n",c.x,c.y,w,h);
- dbg(lvl_debug,"%x,%x-%x,%x\n", r->lu.x,r->lu.y,r->rl.x,r->rl.y);
- while (scale < 1<<20) {
- struct point p1,p2;
- transform_set_scale(this_->trans, scale);
- transform_setup_source_rect(this_->trans);
- transform(this_->trans, transform_get_projection(this_->trans), &r->lu, &p1, 1, 0, 0, NULL);
- transform(this_->trans, transform_get_projection(this_->trans), &r->rl, &p2, 1, 0, 0, NULL);
- dbg(lvl_debug,"%d,%d-%d,%d\n",p1.x,p1.y,p2.x,p2.y);
- if (p1.x < 0 || p2.x < 0 || p1.x > w || p2.x > w ||
- p1.y < 0 || p2.y < 0 || p1.y > h || p2.y > h)
- scale*=2;
- else
- break;
-
- }
- dbg(lvl_debug,"scale=%d (0x%x) of %d (0x%x)\n",scale,scale,1<<20,1<<20);
- if (this_->ready == 3)
- navit_draw_async(this_,0);
-}
+ attr = g_new0(struct attr, 1);
+ iter = navit_attr_iter_new();
+ map = NULL;
+ while (navit_get_attr(this_, attr_traffic, attr, iter)) {
+ traffic = (struct traffic *) attr->u.navit_object;
+ traffic_set_mapset(traffic, ms);
+ if (this_->route)
+ traffic_set_route(traffic, this_->route);
+ /* add the first map found */
+ if (!map && (map = traffic_get_map(traffic))) {
+ struct attr map_a;
+ map_a.type = attr_map;
+ map_a.u.map = map;
+ mapset_add_attr(ms, &map_a);
+ }
+ }
+ navit_attr_iter_destroy(iter);
+ g_free(attr);
+
+ if (this_->navigation) {
+ if ((map=navigation_get_map(this_->navigation))) {
+ struct attr map_a,active;
+ map_a.type=attr_map;
+ map_a.u.map=map;
+ active.type=attr_active;
+ active.u.num=0;
+ mapset_add_attr(ms, &map_a);
+ map_set_attr(map, &active);
+ }
+ }
+ if (this_->tracking) {
+ if ((map=tracking_get_map(this_->tracking))) {
+ struct attr map_a,active;
+ map_a.type=attr_map;
+ map_a.u.map=map;
+ active.type=attr_active;
+ active.u.num=0;
+ mapset_add_attr(ms, &map_a);
+ map_set_attr(map, &active);
+ }
+ }
+ navit_add_former_destinations_from_file(this_);
+ } else {
+ dbg(lvl_error, "FATAL: No mapset available. Please add a (valid) mapset to your configuration.");
+ exit(1);
+ }
+ if (this_->route) {
+ struct attr callback;
+ this_->route_cb=callback_new_attr_1(callback_cast(navit_redraw_route), attr_route_status, this_);
+ callback.type=attr_callback;
+ callback.u.callback=this_->route_cb;
+ route_add_attr(this_->route, &callback);
+ }
+ if (this_->navigation) {
+ if (this_->speech) {
+ this_->nav_speech_cb=callback_new_1(callback_cast(navit_speak), this_);
+ navigation_register_callback(this_->navigation, attr_navigation_speech, this_->nav_speech_cb);
+ }
+ if (this_->route)
+ navigation_set_route(this_->navigation, this_->route);
+ }
+ dbg(lvl_info,"Setting Center");
+ center_file = bookmarks_get_center_file(FALSE);
+ bookmarks_set_center_from_file(this_->bookmarks, center_file);
+ g_free(center_file);
+ global_navit=this_;
+
+ messagelist_init(this_->messages);
+
+ navit_set_cursors(this_);
+
+ callback_list_call_attr_1(this_->attr_cbl, attr_navit, this_);
+ callback=(this_->ready == 2);
+ this_->ready|=1;
+ dbg(lvl_info,"ready=%d",this_->ready);
+ if (this_->ready == 3)
+ navit_draw_async(this_, 1);
+ if (callback)
+ callback_list_call_attr_1(this_->attr_cbl, attr_graphics_ready, this_);
+}
+
+void navit_zoom_to_rect(struct navit *this_, struct coord_rect *r) {
+ struct coord c;
+ int w,h,scale=16;
+
+ c.x=(r->rl.x+r->lu.x)/2;
+ c.y=(r->rl.y+r->lu.y)/2;
+ transform_set_center(this_->trans, &c);
+ transform_get_size(this_->trans, &w, &h);
+ dbg(lvl_debug,"center 0x%x,0x%x w %d h %d",c.x,c.y,w,h);
+ dbg(lvl_debug,"%x,%x-%x,%x", r->lu.x,r->lu.y,r->rl.x,r->rl.y);
+ while (scale < 1<<20) {
+ struct point p1,p2;
+ transform_set_scale(this_->trans, scale);
+ transform_setup_source_rect(this_->trans);
+ transform(this_->trans, transform_get_projection(this_->trans), &r->lu, &p1, 1, 0, 0, NULL);
+ transform(this_->trans, transform_get_projection(this_->trans), &r->rl, &p2, 1, 0, 0, NULL);
+ dbg(lvl_debug,"%d,%d-%d,%d",p1.x,p1.y,p2.x,p2.y);
+ if (p1.x < 0 || p2.x < 0 || p1.x > w || p2.x > w ||
+ p1.y < 0 || p2.y < 0 || p1.y > h || p2.y > h)
+ scale*=2;
+ else
+ break;
-void
-navit_zoom_to_route(struct navit *this_, int orientation)
-{
- struct map *map;
- struct map_rect *mr=NULL;
- struct item *item;
- struct coord c;
- struct coord_rect r;
- int count=0;
- if (! this_->route)
- return;
- dbg(lvl_debug,"enter\n");
- map=route_get_map(this_->route);
- dbg(lvl_debug,"map=%p\n",map);
- if (map)
- mr=map_rect_new(map, NULL);
- dbg(lvl_debug,"mr=%p\n",mr);
- if (mr) {
- while ((item=map_rect_get_item(mr))) {
- dbg(lvl_debug,"item=%s\n", item_to_name(item->type));
- while (item_coord_get(item, &c, 1)) {
- dbg(lvl_debug,"coord\n");
- if (!count)
- r.lu=r.rl=c;
- else
- coord_rect_extend(&r, &c);
- count++;
- }
- }
- map_rect_destroy(mr);
- }
- if (! count)
- return;
- if (orientation != -1)
- transform_set_yaw(this_->trans, orientation);
- navit_zoom_to_rect(this_, &r);
+ }
+ dbg(lvl_debug,"scale=%d (0x%x) of %d (0x%x)",scale,scale,1<<20,1<<20);
+ if (this_->ready == 3)
+ navit_draw_async(this_,0);
+}
+
+void navit_zoom_to_route(struct navit *this_, int orientation) {
+ struct map *map;
+ struct map_rect *mr=NULL;
+ struct item *item;
+ struct coord c;
+ struct coord_rect r;
+ int count=0;
+ if (! this_->route)
+ return;
+ dbg(lvl_debug,"enter");
+ map=route_get_map(this_->route);
+ dbg(lvl_debug,"map=%p",map);
+ if (map)
+ mr=map_rect_new(map, NULL);
+ dbg(lvl_debug,"mr=%p",mr);
+ if (mr) {
+ while ((item=map_rect_get_item(mr))) {
+ dbg(lvl_debug,"item=%s", item_to_name(item->type));
+ while (item_coord_get(item, &c, 1)) {
+ dbg(lvl_debug,"coord");
+ if (!count)
+ r.lu=r.rl=c;
+ else
+ coord_rect_extend(&r, &c);
+ count++;
+ }
+ }
+ map_rect_destroy(mr);
+ }
+ if (! count)
+ return;
+ if (orientation != -1)
+ transform_set_yaw(this_->trans, orientation);
+ navit_zoom_to_rect(this_, &r);
}
-static void
-navit_cmd_zoom_to_route(struct navit *this)
-{
- navit_zoom_to_route(this, 0);
+static void navit_cmd_zoom_to_route(struct navit *this) {
+ navit_zoom_to_route(this, 0);
}
@@ -2587,39 +2593,35 @@ navit_cmd_zoom_to_route(struct navit *this)
* @param center The point where to center the map, including its projection
* @returns nothing
*/
-void
-navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout)
-{
- struct coord *c=transform_center(this_->trans);
- struct coord c1,c2;
- enum projection pro = transform_get_projection(this_->trans);
- if (pro != center->pro) {
- c1.x = center->x;
- c1.y = center->y;
- transform_from_to(&c1, center->pro, &c2, pro);
- } else {
- c2.x = center->x;
- c2.y = center->y;
- }
- *c=c2;
- if (set_timeout)
- navit_set_timeout(this_);
- if (this_->ready == 3)
- navit_draw(this_);
+void navit_set_center(struct navit *this_, struct pcoord *center, int set_timeout) {
+ struct coord *c=transform_center(this_->trans);
+ struct coord c1,c2;
+ enum projection pro = transform_get_projection(this_->trans);
+ if (pro != center->pro) {
+ c1.x = center->x;
+ c1.y = center->y;
+ transform_from_to(&c1, center->pro, &c2, pro);
+ } else {
+ c2.x = center->x;
+ c2.y = center->y;
+ }
+ *c=c2;
+ if (set_timeout)
+ navit_set_timeout(this_);
+ if (this_->ready == 3)
+ navit_draw(this_);
}
-static void
-navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout)
-{
- int width, height;
- struct point po;
- transform_set_center(this_->trans, c);
- transform_get_size(this_->trans, &width, &height);
- po.x=width/2;
- po.y=height/2;
- update_transformation(this_->trans, &po, p);
- if (set_timeout)
- navit_set_timeout(this_);
+static void navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point *p, int set_timeout) {
+ int width, height;
+ struct point po;
+ transform_set_center(this_->trans, c);
+ transform_get_size(this_->trans, &width, &height);
+ po.x=width/2;
+ po.y=height/2;
+ update_transformation(this_->trans, &po, p);
+ if (set_timeout)
+ navit_set_timeout(this_);
}
/**
@@ -2628,28 +2630,26 @@ navit_set_center_coord_screen(struct navit *this_, struct coord *c, struct point
* @param this_ A navit instance
* @author Ralph Sennhauser (10/2009)
*/
-static void
-navit_set_cursors(struct navit *this_)
-{
- struct attr name;
- struct navit_vehicle *nv;
- struct cursor *c;
- GList *v;
-
- v=g_list_first(this_->vehicles); // GList of navit_vehicles
- while (v) {
- nv=v->data;
- if (vehicle_get_attr(nv->vehicle, attr_cursorname, &name, NULL)) {
- if (!strcmp(name.u.str,"none"))
- c=NULL;
- else
- c=layout_get_cursor(this_->layout_current, name.u.str);
- } else
- c=layout_get_cursor(this_->layout_current, "default");
- vehicle_set_cursor(nv->vehicle, c, 0);
- v=g_list_next(v);
- }
- return;
+static void navit_set_cursors(struct navit *this_) {
+ struct attr name;
+ struct navit_vehicle *nv;
+ struct cursor *c;
+ GList *v;
+
+ v=g_list_first(this_->vehicles); // GList of navit_vehicles
+ while (v) {
+ nv=v->data;
+ if (vehicle_get_attr(nv->vehicle, attr_cursorname, &name, NULL)) {
+ if (!strcmp(name.u.str,"none"))
+ c=NULL;
+ else
+ c=layout_get_cursor(this_->layout_current, name.u.str);
+ } else
+ c=layout_get_cursor(this_->layout_current, "default");
+ vehicle_set_cursor(nv->vehicle, c, 0);
+ v=g_list_next(v);
+ }
+ return;
}
@@ -2668,70 +2668,68 @@ navit_set_cursors(struct navit *this_)
*
* @return Always 1
*/
-static int
-navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir)
-{
- int width, height;
- struct navit_vehicle *nv=this_->vehicle;
- struct padding *padding = NULL;
+static int navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, int *dir) {
+ int width, height;
+ struct navit_vehicle *nv=this_->vehicle;
+ struct padding *padding = NULL;
- float offset=this_->radius; // Cursor offset from the center of the screen (percent).
+ float offset=this_->radius; // Cursor offset from the center of the screen (percent).
#if 0 /* Better improve track.c to get that issue resolved or make it configurable with being off the default, the jumping back to the center is a bit annoying */
- float min_offset = 0.; // Percent offset at min_offset_speed.
- float max_offset = 30.; // Percent offset at max_offset_speed.
- int min_offset_speed = 2; // Speed in km/h
- int max_offset_speed = 50; // Speed in km/h
- // Calculate cursor offset from the center of the screen, upon speed.
- if (nv->speed <= min_offset_speed) {
- offset = min_offset;
- } else if (nv->speed > max_offset_speed) {
- offset = max_offset;
- } else {
- offset = (max_offset - min_offset) / (max_offset_speed - min_offset_speed) * (nv->speed - min_offset_speed);
- }
+ float min_offset = 0.; // Percent offset at min_offset_speed.
+ float max_offset = 30.; // Percent offset at max_offset_speed.
+ int min_offset_speed = 2; // Speed in km/h
+ int max_offset_speed = 50; // Speed in km/h
+ // Calculate cursor offset from the center of the screen, upon speed.
+ if (nv->speed <= min_offset_speed) {
+ offset = min_offset;
+ } else if (nv->speed > max_offset_speed) {
+ offset = max_offset;
+ } else {
+ offset = (max_offset - min_offset) / (max_offset_speed - min_offset_speed) * (nv->speed - min_offset_speed);
+ }
#endif
- if (this_->gra) {
- padding = graphics_get_data(this_->gra, "padding");
- } else
- dbg(lvl_warning, "cannot get padding: this->gra is NULL\n");
+ if (this_->gra) {
+ padding = graphics_get_data(this_->gra, "padding");
+ } else
+ dbg(lvl_warning, "cannot get padding: this->gra is NULL");
- transform_get_size(this_->trans, &width, &height);
- dbg(lvl_debug, "width=%d height=%d\n", width, height);
+ transform_get_size(this_->trans, &width, &height);
+ dbg(lvl_debug, "width=%d height=%d", width, height);
- if (padding) {
- width -= (padding->left + padding->right);
- height -= (padding->top + padding->bottom);
- dbg(lvl_debug, "corrected for padding: width=%d height=%d\n", width, height);
- }
+ if (padding) {
+ width -= (padding->left + padding->right);
+ height -= (padding->top + padding->bottom);
+ dbg(lvl_debug, "corrected for padding: width=%d height=%d", width, height);
+ }
- if (this_->orientation == -1 || keep_orientation) {
- p->x=50*width/100;
- p->y=(50 + offset)*height/100;
- if (dir)
- *dir=keep_orientation?this_->orientation:nv->dir;
- } else {
- int mdir;
- if (this_->tracking && this_->tracking_flag) {
- mdir = tracking_get_angle(this_->tracking) - this_->orientation;
- } else {
- mdir=nv->dir-this_->orientation;
- }
+ if (this_->orientation == -1 || keep_orientation) {
+ p->x=50*width/100;
+ p->y=(50 + offset)*height/100;
+ if (dir)
+ *dir=keep_orientation?this_->orientation:nv->dir;
+ } else {
+ int mdir;
+ if (this_->tracking && this_->tracking_flag) {
+ mdir = tracking_get_angle(this_->tracking) - this_->orientation;
+ } else {
+ mdir=nv->dir-this_->orientation;
+ }
- p->x=(50 - offset*sin(M_PI*mdir/180.))*width/100;
- p->y=(50 + offset*cos(M_PI*mdir/180.))*height/100;
- if (dir)
- *dir=this_->orientation;
- }
+ p->x=(50 - offset*sin(M_PI*mdir/180.))*width/100;
+ p->y=(50 + offset*cos(M_PI*mdir/180.))*height/100;
+ if (dir)
+ *dir=this_->orientation;
+ }
- if (padding) {
- p->x += padding->left;
- p->y += padding->top;
- }
+ if (padding) {
+ p->x += padding->left;
+ p->y += padding->top;
+ }
- dbg(lvl_debug, "x=%d y=%d, offset=%f\n", p->x, p->y, offset);
+ dbg(lvl_debug, "x=%d y=%d, offset=%f", p->x, p->y, offset);
- return 1;
+ return 1;
}
/**
@@ -2748,20 +2746,18 @@ navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation,
* @param keep_orientation Whether to maintain the current map orientation. If false, the map will be rotated
* so that the bearing of the vehicle is up.
*/
-void
-navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation)
-{
- int dir;
- struct point pn;
- struct navit_vehicle *nv=this_->vehicle;
- struct attr attr;
- if (vehicle_get_attr(nv->vehicle, attr_position_valid, &attr, NULL) && (attr.u.num == attr_position_valid_invalid))
- return;
- navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir);
- transform_set_yaw(this_->trans, dir);
- navit_set_center_coord_screen(this_, &nv->coord, &pn, 0);
- if (autozoom)
- navit_autozoom(this_, &nv->coord, nv->speed, 0);
+void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation) {
+ int dir;
+ struct point pn;
+ struct navit_vehicle *nv=this_->vehicle;
+ struct attr attr;
+ if (vehicle_get_attr(nv->vehicle, attr_position_valid, &attr, NULL) && (attr.u.num == attr_position_valid_invalid))
+ return;
+ navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir);
+ transform_set_yaw(this_->trans, dir);
+ navit_set_center_coord_screen(this_, &nv->coord, &pn, 0);
+ if (autozoom)
+ navit_autozoom(this_, &nv->coord, nv->speed, 0);
}
/**
@@ -2772,12 +2768,10 @@ navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation)
*
*@param this_ The navit object
*/
-static void
-navit_set_center_cursor_draw(struct navit *this_)
-{
- navit_set_center_cursor(this_,1,0);
- if (this_->ready == 3)
- navit_draw_async(this_, 1);
+static void navit_set_center_cursor_draw(struct navit *this_) {
+ navit_set_center_cursor(this_,1,0);
+ if (this_->ready == 3)
+ navit_draw_async(this_, 1);
}
/**
@@ -2788,598 +2782,635 @@ navit_set_center_cursor_draw(struct navit *this_)
*
*@param this_ The navit object
*/
-static void
-navit_cmd_set_center_cursor(struct navit *this_)
-{
- navit_set_center_cursor_draw(this_);
-}
-
-void
-navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout)
-{
- struct coord c;
- struct pcoord pc;
- transform_reverse(this_->trans, p, &c);
- pc.x = c.x;
- pc.y = c.y;
- pc.pro = transform_get_projection(this_->trans);
- navit_set_center(this_, &pc, set_timeout);
-}
-
-static int
-navit_set_attr_do(struct navit *this_, struct attr *attr, int init)
-{
- int dir=0, orient_old=0, attr_updated=0;
- struct coord co;
- long zoom;
- GList *l;
- struct navit_vehicle *nv;
- struct layout *lay;
- struct attr active;
- active.type=attr_active;
- active.u.num=0;
-
- dbg(lvl_debug, "enter, this_=%p, attr=%p (%s), init=%d\n", this_, attr, attr_to_name(attr->type), init);
-
- switch (attr->type) {
- case attr_autozoom:
- attr_updated=(this_->autozoom_secs != attr->u.num);
- this_->autozoom_secs = attr->u.num;
- break;
- case attr_autozoom_active:
- attr_updated=(this_->autozoom_active != attr->u.num);
- this_->autozoom_active = attr->u.num;
- break;
- case attr_center:
- transform_from_geo(transform_get_projection(this_->trans), attr->u.coord_geo, &co);
- dbg(lvl_debug,"0x%x,0x%x\n",co.x,co.y);
- transform_set_center(this_->trans, &co);
- break;
- case attr_drag_bitmap:
- attr_updated=(this_->drag_bitmap != !!attr->u.num);
- this_->drag_bitmap=!!attr->u.num;
- break;
- case attr_flags:
- attr_updated=(this_->flags != attr->u.num);
- this_->flags=attr->u.num;
- break;
- case attr_flags_graphics:
- attr_updated=(this_->graphics_flags != attr->u.num);
- this_->graphics_flags=attr->u.num;
- break;
- case attr_follow:
- if (!this_->vehicle)
- return 0;
- attr_updated=(this_->vehicle->follow_curr != attr->u.num);
- this_->vehicle->follow_curr = attr->u.num;
- break;
- case attr_layout:
- if(!attr->u.layout)
- return 0;
- if(this_->layout_current!=attr->u.layout) {
- this_->layout_current=attr->u.layout;
- graphics_font_destroy_all(this_->gra);
- navit_set_cursors(this_);
- if (this_->ready == 3)
- navit_draw(this_);
- attr_updated=1;
- }
- break;
- case attr_layout_name:
- if(!attr->u.str)
- return 0;
- l=this_->layouts;
- while (l) {
- lay=l->data;
- if (!strcmp(lay->name,attr->u.str)) {
- struct attr attr;
- attr.type=attr_layout;
- attr.u.layout=lay;
- return navit_set_attr_do(this_, &attr, init);
- }
- l=g_list_next(l);
- }
- return 0;
- case attr_map_border:
- if (this_->border != attr->u.num) {
- this_->border=attr->u.num;
- attr_updated=1;
- }
- break;
- case attr_orientation:
- orient_old=this_->orientation;
- this_->orientation=attr->u.num;
- if (!init) {
- if (this_->orientation != -1) {
- dir = this_->orientation;
- } else {
- if (this_->vehicle) {
- dir = this_->vehicle->dir;
- }
- }
- transform_set_yaw(this_->trans, dir);
- if (orient_old != this_->orientation) {
+static void navit_cmd_set_center_cursor(struct navit *this_) {
+ navit_set_center_cursor_draw(this_);
+}
+
+void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout) {
+ struct coord c;
+ struct pcoord pc;
+ transform_reverse(this_->trans, p, &c);
+ pc.x = c.x;
+ pc.y = c.y;
+ pc.pro = transform_get_projection(this_->trans);
+ navit_set_center(this_, &pc, set_timeout);
+}
+
+static int navit_set_attr_do(struct navit *this_, struct attr *attr, int init) {
+ int dir=0, orient_old=0, attr_updated=0;
+ struct coord co;
+ long zoom;
+ GList *l;
+ struct navit_vehicle *nv;
+ struct layout *lay;
+ struct attr active;
+ active.type=attr_active;
+ active.u.num=0;
+
+ dbg(lvl_debug, "enter, this_=%p, attr=%p (%s), init=%d", this_, attr, attr_to_name(attr->type), init);
+
+ switch (attr->type) {
+ case attr_autozoom:
+ attr_updated=(this_->autozoom_secs != attr->u.num);
+ this_->autozoom_secs = attr->u.num;
+ break;
+ case attr_autozoom_active:
+ attr_updated=(this_->autozoom_active != attr->u.num);
+ this_->autozoom_active = attr->u.num;
+ break;
+ case attr_center:
+ transform_from_geo(transform_get_projection(this_->trans), attr->u.coord_geo, &co);
+ dbg(lvl_debug,"0x%x,0x%x",co.x,co.y);
+ transform_set_center(this_->trans, &co);
+ break;
+ case attr_drag_bitmap:
+ attr_updated=(this_->drag_bitmap != !!attr->u.num);
+ this_->drag_bitmap=!!attr->u.num;
+ break;
+ case attr_flags:
+ attr_updated=(this_->flags != attr->u.num);
+ this_->flags=attr->u.num;
+ break;
+ case attr_flags_graphics:
+ attr_updated=(this_->graphics_flags != attr->u.num);
+ this_->graphics_flags=attr->u.num;
+ break;
+ case attr_follow:
+ if (!this_->vehicle)
+ return 0;
+ attr_updated=(this_->vehicle->follow_curr != attr->u.num);
+ this_->vehicle->follow_curr = attr->u.num;
+ break;
+ case attr_default_layout:
+ if(!attr->u.str)
+ return 0;
+ if(this_->default_layout_name) /* There is already a default layout, ignore this new value */
+ g_free(this_->default_layout_name); /* Drop the previous layout name, use the this one instead */
+ this_->default_layout_name=g_strdup(attr->u.str);
+ attr_updated=1;
+ break;
+ case attr_layout:
+ if(!attr->u.layout)
+ return 0;
+ if(this_->layout_current!=attr->u.layout) {
+ navit_update_current_layout(this_, attr->u.layout);
+ graphics_font_destroy_all(this_->gra);
+ navit_set_cursors(this_);
+ if (this_->ready == 3)
+ navit_draw(this_);
+ attr_updated=1;
+ }
+ break;
+ case attr_layout_name:
+ if(!attr->u.str)
+ return 0;
+ l=this_->layouts;
+ while (l) {
+ lay=l->data;
+ if (!strcmp(lay->name,attr->u.str)) {
+ struct attr attr;
+ attr.type=attr_layout;
+ attr.u.layout=lay;
+ return navit_set_attr_do(this_, &attr, init);
+ }
+ l=g_list_next(l);
+ }
+ return 0;
+ case attr_map_border:
+ if (this_->border != attr->u.num) {
+ this_->border=attr->u.num;
+ attr_updated=1;
+ }
+ break;
+ case attr_orientation:
+ orient_old=this_->orientation;
+ this_->orientation=attr->u.num;
+ if (!init) {
+ if (this_->orientation != -1) {
+ dir = this_->orientation;
+ } else {
+ if (this_->vehicle) {
+ dir = this_->vehicle->dir;
+ }
+ }
+ transform_set_yaw(this_->trans, dir);
+ if (orient_old != this_->orientation) {
#if 0
- if (this_->ready == 3)
- navit_draw(this_);
+ if (this_->ready == 3)
+ navit_draw(this_);
#endif
- attr_updated=1;
- }
- }
- break;
- case attr_osd_configuration:
- dbg(lvl_debug,"setting osd_configuration to %ld (was %d)\n", attr->u.num, this_->osd_configuration);
- attr_updated=(this_->osd_configuration != attr->u.num);
- this_->osd_configuration=attr->u.num;
- break;
- case attr_pitch:
- attr_updated=(this_->pitch != attr->u.num);
- this_->pitch=attr->u.num;
- transform_set_pitch(this_->trans, round(this_->pitch*sqrt(240*320)/sqrt(this_->w*this_->h))); // Pitch corrected for window resolution
- if (!init && attr_updated && this_->ready == 3)
- navit_draw(this_);
- break;
- case attr_projection:
- if(this_->trans && transform_get_projection(this_->trans) != attr->u.projection) {
- navit_projection_set(this_, attr->u.projection, !init);
- attr_updated=1;
- }
- break;
- case attr_radius:
- attr_updated=(this_->radius != attr->u.num);
- this_->radius=attr->u.num;
- break;
- case attr_recent_dest:
- attr_updated=(this_->recentdest_count != attr->u.num);
- this_->recentdest_count=attr->u.num;
- break;
- case attr_speech:
- if(this_->speech && this_->speech != attr->u.speech) {
- attr_updated=1;
- this_->speech = attr->u.speech;
- }
- break;
- case attr_timeout:
- attr_updated=(this_->center_timeout != attr->u.num);
- this_->center_timeout = attr->u.num;
- break;
- case attr_tracking:
- attr_updated=(this_->tracking_flag != !!attr->u.num);
- this_->tracking_flag=!!attr->u.num;
- break;
- case attr_transformation:
- this_->trans=attr->u.transformation;
- break;
- case attr_use_mousewheel:
- attr_updated=(this_->use_mousewheel != !!attr->u.num);
- this_->use_mousewheel=!!attr->u.num;
- break;
- case attr_vehicle:
- if (!attr->u.vehicle) {
- if (this_->vehicle) {
- vehicle_set_attr(this_->vehicle->vehicle, &active);
- navit_set_vehicle(this_, NULL);
- attr_updated=1;
- }
- break;
- }
- l=this_->vehicles;
- while(l) {
- nv=l->data;
- if (nv->vehicle == attr->u.vehicle) {
- if (!this_->vehicle || this_->vehicle->vehicle != attr->u.vehicle) {
- if (this_->vehicle)
- vehicle_set_attr(this_->vehicle->vehicle, &active);
- active.u.num=1;
- vehicle_set_attr(nv->vehicle, &active);
- attr_updated=1;
- }
- navit_set_vehicle(this_, nv);
- }
- l=g_list_next(l);
- }
- break;
- case attr_vehicleprofile:
- attr_updated=navit_set_vehicleprofile(this_, attr->u.vehicleprofile);
- break;
- case attr_zoom:
- zoom=transform_get_scale(this_->trans);
- attr_updated=(zoom != attr->u.num);
- transform_set_scale(this_->trans, attr->u.num);
- if (attr_updated && !init)
- navit_draw(this_);
- break;
- case attr_zoom_min:
- attr_updated=(attr->u.num != this_->zoom_min);
- this_->zoom_min=attr->u.num;
- break;
- case attr_zoom_max:
- attr_updated=(attr->u.num != this_->zoom_max);
- this_->zoom_max=attr->u.num;
- break;
- case attr_message:
- navit_add_message(this_, attr->u.str);
- break;
- case attr_follow_cursor:
- attr_updated=(this_->follow_cursor != !!attr->u.num);
- this_->follow_cursor=!!attr->u.num;
- break;
- case attr_imperial:
- attr_updated=(this_->imperial != attr->u.num);
- this_->imperial=attr->u.num;
- break;
- case attr_waypoints_flag:
- attr_updated=(this_->waypoints_flag != !!attr->u.num);
- this_->waypoints_flag=!!attr->u.num;
- break;
- default:
- dbg(lvl_debug, "calling generic setter method for attribute type %s\n", attr_to_name(attr->type))
- return navit_object_set_attr((struct navit_object *) this_, attr);
- }
- if (attr_updated && !init) {
- callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
- if (attr->type == attr_osd_configuration)
- graphics_draw_mode(this_->gra, draw_mode_end);
- }
- return 1;
+ attr_updated=1;
+ }
+ }
+ break;
+ case attr_osd_configuration:
+ dbg(lvl_debug,"setting osd_configuration to %ld (was %d)", attr->u.num, this_->osd_configuration);
+ attr_updated=(this_->osd_configuration != attr->u.num);
+ this_->osd_configuration=attr->u.num;
+ break;
+ case attr_pitch:
+ attr_updated=(this_->pitch != attr->u.num);
+ this_->pitch=attr->u.num;
+ transform_set_pitch(this_->trans, round(this_->pitch*sqrt(240*320)/sqrt(
+ this_->w*this_->h))); // Pitch corrected for window resolution
+ if (!init && attr_updated && this_->ready == 3)
+ navit_draw(this_);
+ break;
+ case attr_projection:
+ if(this_->trans && transform_get_projection(this_->trans) != attr->u.projection) {
+ navit_projection_set(this_, attr->u.projection, !init);
+ attr_updated=1;
+ }
+ break;
+ case attr_radius:
+ attr_updated=(this_->radius != attr->u.num);
+ this_->radius=attr->u.num;
+ break;
+ case attr_recent_dest:
+ attr_updated=(this_->recentdest_count != attr->u.num);
+ this_->recentdest_count=attr->u.num;
+ break;
+ case attr_speech:
+ if(this_->speech && this_->speech != attr->u.speech) {
+ attr_updated=1;
+ this_->speech = attr->u.speech;
+ }
+ break;
+ case attr_timeout:
+ attr_updated=(this_->center_timeout != attr->u.num);
+ this_->center_timeout = attr->u.num;
+ break;
+ case attr_tracking:
+ attr_updated=(this_->tracking_flag != !!attr->u.num);
+ this_->tracking_flag=!!attr->u.num;
+ break;
+ case attr_transformation:
+ this_->trans=attr->u.transformation;
+ break;
+ case attr_use_mousewheel:
+ attr_updated=(this_->use_mousewheel != !!attr->u.num);
+ this_->use_mousewheel=!!attr->u.num;
+ break;
+ case attr_vehicle:
+ if (!attr->u.vehicle) {
+ if (this_->vehicle) {
+ vehicle_set_attr(this_->vehicle->vehicle, &active);
+ navit_set_vehicle(this_, NULL);
+ attr_updated=1;
+ }
+ break;
+ }
+ l=this_->vehicles;
+ while(l) {
+ nv=l->data;
+ if (nv->vehicle == attr->u.vehicle) {
+ if (!this_->vehicle || this_->vehicle->vehicle != attr->u.vehicle) {
+ if (this_->vehicle)
+ vehicle_set_attr(this_->vehicle->vehicle, &active);
+ active.u.num=1;
+ vehicle_set_attr(nv->vehicle, &active);
+ attr_updated=1;
+ }
+ navit_set_vehicle(this_, nv);
+ }
+ l=g_list_next(l);
+ }
+ break;
+ case attr_vehicleprofile:
+ attr_updated=navit_set_vehicleprofile(this_, attr->u.vehicleprofile);
+ break;
+ case attr_zoom:
+ zoom=transform_get_scale(this_->trans);
+ attr_updated=(zoom != attr->u.num);
+ transform_set_scale(this_->trans, attr->u.num);
+ if (attr_updated && !init)
+ navit_draw(this_);
+ break;
+ case attr_zoom_min:
+ attr_updated=(attr->u.num != this_->zoom_min);
+ this_->zoom_min=attr->u.num;
+ break;
+ case attr_zoom_max:
+ attr_updated=(attr->u.num != this_->zoom_max);
+ this_->zoom_max=attr->u.num;
+ break;
+ case attr_message:
+ navit_add_message(this_, attr->u.str);
+ break;
+ case attr_follow_cursor:
+ attr_updated=(this_->follow_cursor != !!attr->u.num);
+ this_->follow_cursor=!!attr->u.num;
+ break;
+ case attr_imperial:
+ attr_updated=(this_->imperial != attr->u.num);
+ this_->imperial=attr->u.num;
+ break;
+ case attr_waypoints_flag:
+ attr_updated=(this_->waypoints_flag != !!attr->u.num);
+ this_->waypoints_flag=!!attr->u.num;
+ break;
+ default:
+ dbg(lvl_debug, "calling generic setter method for attribute type %s", attr_to_name(attr->type))
+ return navit_object_set_attr((struct navit_object *) this_, attr);
+ }
+ if (attr_updated && !init) {
+ callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
+ if (attr->type == attr_osd_configuration)
+ graphics_draw_mode(this_->gra, draw_mode_end);
+ }
+ return 1;
}
-int
-navit_set_attr(struct navit *this_, struct attr *attr)
-{
- return navit_set_attr_do(this_, attr, 0);
+int navit_set_attr(struct navit *this_, struct attr *attr) {
+ return navit_set_attr_do(this_, attr, 0);
}
-int
-navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- struct message *msg;
- struct coord *c;
- int len,offset;
- int ret=1;
-
- switch (type) {
- case attr_message:
- msg = navit_get_messages(this_);
-
- if (!msg) {
- return 0;
- }
+int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ struct message *msg;
+ struct coord *c;
+ int len,offset;
+ int ret=1;
- len = 0;
- while (msg) {
- len += strlen(msg->text) + 1;
- msg = msg->next;
- }
- attr->u.str = g_malloc(len + 1);
-
- msg = navit_get_messages(this_);
- offset = 0;
- while (msg) {
- g_stpcpy((attr->u.str + offset), msg->text);
- offset += strlen(msg->text);
- attr->u.str[offset] = '\n';
- offset++;
-
- msg = msg->next;
- }
+ switch (type) {
+ case attr_message:
+ msg = navit_get_messages(this_);
- attr->u.str[len] = '\0';
- break;
- case attr_imperial:
- attr->u.num=this_->imperial;
- break;
- case attr_bookmark_map:
- attr->u.map=bookmarks_get_map(this_->bookmarks);
- break;
- case attr_bookmarks:
- attr->u.bookmarks=this_->bookmarks;
- break;
- case attr_callback_list:
- attr->u.callback_list=this_->attr_cbl;
- break;
- case attr_center:
- c=transform_get_center(this_->trans);
- transform_to_geo(transform_get_projection(this_->trans), c, &this_->center);
- attr->u.coord_geo=&this_->center;
- break;
- case attr_destination:
- if (! this_->destination_valid)
- return 0;
- attr->u.pcoord=&this_->destination;
- break;
- case attr_displaylist:
- attr->u.displaylist=this_->displaylist;
- return (attr->u.displaylist != NULL);
- case attr_follow:
- if (!this_->vehicle)
- return 0;
- attr->u.num=this_->vehicle->follow_curr;
- break;
- case attr_former_destination_map:
- attr->u.map=this_->former_destination;
- break;
- case attr_graphics:
- attr->u.graphics=this_->gra;
- ret=(attr->u.graphics != NULL);
- break;
- case attr_gui:
- attr->u.gui=this_->gui;
- ret=(attr->u.gui != NULL);
- break;
- case attr_layer:
- ret=attr_generic_get_attr(this_->attrs, NULL, type, attr, iter?(struct attr_iter *)&iter->iter:NULL);
- break;
- case attr_layout:
- if (iter) {
- if (iter->u.list) {
- iter->u.list=g_list_next(iter->u.list);
- } else {
- iter->u.list=this_->layouts;
- }
- if (!iter->u.list)
- return 0;
- attr->u.layout=(struct layout *)iter->u.list->data;
- } else {
- attr->u.layout=this_->layout_current;
- }
- break;
- case attr_map:
- if (iter && this_->mapsets) {
- if (!iter->u.mapset_handle) {
- iter->u.mapset_handle=mapset_open((struct mapset *)this_->mapsets->data);
- }
- attr->u.map=mapset_next(iter->u.mapset_handle, 0);
- if(!attr->u.map) {
- mapset_close(iter->u.mapset_handle);
- return 0;
- }
- } else {
- return 0;
- }
- break;
- case attr_mapset:
- attr->u.mapset=this_->mapsets->data;
- ret=(attr->u.mapset != NULL);
- break;
- case attr_navigation:
- attr->u.navigation=this_->navigation;
- break;
- case attr_orientation:
- attr->u.num=this_->orientation;
- break;
- case attr_osd:
- ret=attr_generic_get_attr(this_->attrs, NULL, type, attr, iter?(struct attr_iter *)&iter->iter:NULL);
- break;
- case attr_osd_configuration:
- attr->u.num=this_->osd_configuration;
- break;
- case attr_pitch:
- attr->u.num=round(transform_get_pitch(this_->trans)*sqrt(this_->w*this_->h)/sqrt(240*320)); // Pitch corrected for window resolution
- break;
- case attr_projection:
- if(this_->trans) {
- attr->u.num=transform_get_projection(this_->trans);
- } else {
- return 0;
- }
- break;
- case attr_route:
- attr->u.route=this_->route;
- break;
- case attr_speech:
- if(this_->speech) {
- attr->u.speech=this_->speech;
- } else {
- return 0;
- }
- break;
- case attr_timeout:
- attr->u.num=this_->center_timeout;
- break;
- case attr_tracking:
- attr->u.num=this_->tracking_flag;
- break;
- case attr_trackingo:
- attr->u.tracking=this_->tracking;
- break;
- case attr_transformation:
- attr->u.transformation=this_->trans;
- break;
- case attr_vehicle:
- if(iter) {
- if(iter->u.list) {
- iter->u.list=g_list_next(iter->u.list);
- } else {
- iter->u.list=this_->vehicles;
- }
- if(!iter->u.list)
- return 0;
- attr->u.vehicle=((struct navit_vehicle*)iter->u.list->data)->vehicle;
- } else {
- if(this_->vehicle) {
- attr->u.vehicle=this_->vehicle->vehicle;
- } else {
- return 0;
- }
- }
- break;
- case attr_vehicleprofile:
- if (iter) {
- if(iter->u.list) {
- iter->u.list=g_list_next(iter->u.list);
- } else {
- iter->u.list=this_->vehicleprofiles;
- }
- if(!iter->u.list)
- return 0;
- attr->u.vehicleprofile=iter->u.list->data;
- } else {
- attr->u.vehicleprofile=this_->vehicleprofile;
- }
- break;
- case attr_zoom:
- attr->u.num=transform_get_scale(this_->trans);
- break;
- case attr_autozoom_active:
- attr->u.num=this_->autozoom_active;
- break;
- case attr_follow_cursor:
- attr->u.num=this_->follow_cursor;
- break;
- case attr_waypoints_flag:
- attr->u.num=this_->waypoints_flag;
- break;
- default:
- dbg(lvl_debug, "calling generic getter method for attribute type %s\n", attr_to_name(type))
- return navit_object_get_attr((struct navit_object *) this_, type, attr, iter);
- }
- attr->type=type;
- return ret;
+ if (!msg) {
+ return 0;
+ }
+
+ len = 0;
+ while (msg) {
+ len += strlen(msg->text) + 1;
+ msg = msg->next;
+ }
+ attr->u.str = g_malloc(len + 1);
+
+ msg = navit_get_messages(this_);
+ offset = 0;
+ while (msg) {
+ g_stpcpy((attr->u.str + offset), msg->text);
+ offset += strlen(msg->text);
+ attr->u.str[offset] = '\n';
+ offset++;
+
+ msg = msg->next;
+ }
+
+ attr->u.str[len] = '\0';
+ break;
+ case attr_imperial:
+ attr->u.num=this_->imperial;
+ break;
+ case attr_bookmark_map:
+ attr->u.map=bookmarks_get_map(this_->bookmarks);
+ break;
+ case attr_bookmarks:
+ attr->u.bookmarks=this_->bookmarks;
+ break;
+ case attr_callback_list:
+ attr->u.callback_list=this_->attr_cbl;
+ break;
+ case attr_center:
+ c=transform_get_center(this_->trans);
+ transform_to_geo(transform_get_projection(this_->trans), c, &this_->center);
+ attr->u.coord_geo=&this_->center;
+ break;
+ case attr_destination:
+ if (! this_->destination_valid)
+ return 0;
+ attr->u.pcoord=&this_->destination;
+ break;
+ case attr_displaylist:
+ attr->u.displaylist=this_->displaylist;
+ return (attr->u.displaylist != NULL);
+ case attr_follow:
+ if (!this_->vehicle)
+ return 0;
+ attr->u.num=this_->vehicle->follow_curr;
+ break;
+ case attr_former_destination_map:
+ attr->u.map=this_->former_destination;
+ break;
+ case attr_graphics:
+ attr->u.graphics=this_->gra;
+ ret=(attr->u.graphics != NULL);
+ break;
+ case attr_gui:
+ attr->u.gui=this_->gui;
+ ret=(attr->u.gui != NULL);
+ break;
+ case attr_layer:
+ ret=attr_generic_get_attr(this_->attrs, NULL, type, attr, iter?(struct attr_iter *)&iter->iter:NULL);
+ break;
+ case attr_layout:
+ if (iter) {
+ if (iter->u.list) {
+ iter->u.list=g_list_next(iter->u.list);
+ } else {
+ iter->u.list=this_->layouts;
+ }
+ if (!iter->u.list)
+ return 0;
+ attr->u.layout=(struct layout *)iter->u.list->data;
+ } else {
+ attr->u.layout=this_->layout_current;
+ }
+ break;
+ case attr_map:
+ if (iter && this_->mapsets) {
+ if (!iter->u.mapset_handle) {
+ iter->u.mapset_handle=mapset_open((struct mapset *)this_->mapsets->data);
+ }
+ attr->u.map=mapset_next(iter->u.mapset_handle, 0);
+ if(!attr->u.map) {
+ mapset_close(iter->u.mapset_handle);
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+ break;
+ case attr_mapset:
+ attr->u.mapset=this_->mapsets->data;
+ ret=(attr->u.mapset != NULL);
+ break;
+ case attr_navigation:
+ attr->u.navigation=this_->navigation;
+ break;
+ case attr_orientation:
+ attr->u.num=this_->orientation;
+ break;
+ case attr_osd:
+ ret=attr_generic_get_attr(this_->attrs, NULL, type, attr, iter?(struct attr_iter *)&iter->iter:NULL);
+ break;
+ case attr_osd_configuration:
+ attr->u.num=this_->osd_configuration;
+ break;
+ case attr_pitch:
+ attr->u.num=round(transform_get_pitch(this_->trans)*sqrt(this_->w*this_->h)/sqrt(
+ 240*320)); // Pitch corrected for window resolution
+ break;
+ case attr_projection:
+ if(this_->trans) {
+ attr->u.num=transform_get_projection(this_->trans);
+ } else {
+ return 0;
+ }
+ break;
+ case attr_route:
+ attr->u.route=this_->route;
+ break;
+ case attr_speech:
+ if(this_->speech) {
+ attr->u.speech=this_->speech;
+ } else {
+ return 0;
+ }
+ break;
+ case attr_timeout:
+ attr->u.num=this_->center_timeout;
+ break;
+ case attr_tracking:
+ attr->u.num=this_->tracking_flag;
+ break;
+ case attr_trackingo:
+ attr->u.tracking=this_->tracking;
+ break;
+ case attr_transformation:
+ attr->u.transformation=this_->trans;
+ break;
+ case attr_vehicle:
+ if(iter) {
+ if(iter->u.list) {
+ iter->u.list=g_list_next(iter->u.list);
+ } else {
+ iter->u.list=this_->vehicles;
+ }
+ if(!iter->u.list)
+ return 0;
+ attr->u.vehicle=((struct navit_vehicle*)iter->u.list->data)->vehicle;
+ } else {
+ if(this_->vehicle) {
+ attr->u.vehicle=this_->vehicle->vehicle;
+ } else {
+ return 0;
+ }
+ }
+ break;
+ case attr_vehicleprofile:
+ if (iter) {
+ if(iter->u.list) {
+ iter->u.list=g_list_next(iter->u.list);
+ } else {
+ iter->u.list=this_->vehicleprofiles;
+ }
+ if(!iter->u.list)
+ return 0;
+ attr->u.vehicleprofile=iter->u.list->data;
+ } else {
+ attr->u.vehicleprofile=this_->vehicleprofile;
+ }
+ break;
+ case attr_zoom:
+ attr->u.num=transform_get_scale(this_->trans);
+ break;
+ case attr_autozoom_active:
+ attr->u.num=this_->autozoom_active;
+ break;
+ case attr_follow_cursor:
+ attr->u.num=this_->follow_cursor;
+ break;
+ case attr_waypoints_flag:
+ attr->u.num=this_->waypoints_flag;
+ break;
+ default:
+ dbg(lvl_debug, "calling generic getter method for attribute type %s", attr_to_name(type))
+ return navit_object_get_attr((struct navit_object *) this_, type, attr, iter);
+ }
+ attr->type=type;
+ return ret;
}
-static int
-navit_add_log(struct navit *this_, struct log *log)
-{
- struct attr type_attr;
- if (!log_get_attr(log, attr_type, &type_attr, NULL))
- return 0;
- if (!strcmp(type_attr.u.str, "textfile_debug")) {
- char *header = "type=track_tracked\n";
- if (this_->textfile_debug_log)
- return 0;
- log_set_header(log, header, strlen(header));
- this_->textfile_debug_log=log;
- return 1;
- }
- return 0;
+/**
+ * @brief Select the default layout by name
+ *
+ * @param this_ The navit instance
+ * @param name The new default layout's name
+ *
+ * @return The first layout match (if any), or NULL if there was no match
+ */
+struct layout *navit_get_layout_by_name(struct navit *this_, const char *layout_name) {
+ struct attr_iter *iter;
+ struct attr layout_attr;
+ struct layout *result = NULL;
+
+ if (!layout_name)
+ return NULL;
+ iter=navit_attr_iter_new();
+ while (navit_get_attr(this_, attr_layout, &layout_attr, iter)) {
+ if (strcmp(layout_attr.u.layout->name, layout_name) == 0) {
+ result = layout_attr.u.layout;
+ }
+ }
+ navit_attr_iter_destroy(iter);
+ return result;
}
-static int
-navit_add_layout(struct navit *this_, struct layout *layout)
-{
- struct attr active;
- this_->layouts = g_list_append(this_->layouts, layout);
- layout_get_attr(layout, attr_active, &active, NULL);
- if(active.u.num || !this_->layout_current) {
- this_->layout_current=layout;
- return 1;
- }
- return 0;
+/**
+ * @brief Set the current layout
+ *
+ * @param this_ The navit instance
+ * @param layout The layout to set as default (if NULL, we will set the current layout according to the default name stored in this_->default_layout_name
+ *
+ * @note If argument @p layout is NULL and the default layout name in the config file does not exist or has not been provided in the config file, the default layout is unchanged
+ */
+void navit_update_current_layout(struct navit *this_, struct layout *layout) {
+ struct layout *default_layout = NULL;
+
+ if (layout) {
+ this_->layout_current=layout;
+ } else {
+ if (this_->default_layout_name) { /* If a default layout name was provided */
+ default_layout=navit_get_layout_by_name(this_, this_->default_layout_name);
+ if (default_layout) {
+ dbg(lvl_debug, "Found the config-specified default layout '%s'", this_->default_layout_name);
+ this_->layout_current=default_layout;
+ return;
+ } else {
+ dbg(lvl_warning, "No definition exists in config for specified default layout '%s'", this_->default_layout_name);
+ }
+ }
+ }
}
-int
-navit_add_attr(struct navit *this_, struct attr *attr)
-{
- int ret=1;
- switch (attr->type) {
- case attr_callback:
- navit_add_callback(this_, attr->u.callback);
- break;
- case attr_log:
- ret=navit_add_log(this_, attr->u.log);
- break;
- case attr_gui:
- ret=navit_set_gui(this_, attr->u.gui);
- break;
- case attr_graphics:
- ret=navit_set_graphics(this_, attr->u.graphics);
- break;
- case attr_layout:
- navit_add_layout(this_, attr->u.layout);
- break;
- case attr_route:
- this_->route=attr->u.route;
- break;
- case attr_mapset:
- this_->mapsets = g_list_append(this_->mapsets, attr->u.mapset);
- break;
- case attr_navigation:
- this_->navigation=attr->u.navigation;
- break;
- case attr_osd:
- break;
- case attr_recent_dest:
- this_->recentdest_count = attr->u.num;
- break;
- case attr_speech:
- this_->speech=attr->u.speech;
- break;
- case attr_trackingo:
- this_->tracking=attr->u.tracking;
- break;
- case attr_vehicle:
- ret=navit_add_vehicle(this_, attr->u.vehicle);
- break;
- case attr_vehicleprofile:
- this_->vehicleprofiles=g_list_append(this_->vehicleprofiles, attr->u.vehicleprofile);
- break;
- case attr_autozoom_min:
- this_->autozoom_min = attr->u.num;
- break;
- case attr_autozoom_max:
- this_->autozoom_max = attr->u.num;
- break;
- case attr_layer:
- case attr_script:
- break;
- case attr_audio:
- ret=navit_add_audio(this_, attr->u.audio);
- break;
- default:
- return 0;
- }
- if (ret)
- this_->attrs=attr_generic_add_attr(this_->attrs, attr);
- callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
- return ret;
+static int navit_add_log(struct navit *this_, struct log *log) {
+ struct attr type_attr;
+ if (!log_get_attr(log, attr_type, &type_attr, NULL))
+ return 0;
+ if (!strcmp(type_attr.u.str, "textfile_debug")) {
+ char *header = "type=track_tracked\n";
+ if (this_->textfile_debug_log)
+ return 0;
+ log_set_header(log, header, strlen(header));
+ this_->textfile_debug_log=log;
+ return 1;
+ }
+ return 0;
}
-int
-navit_remove_attr(struct navit *this_, struct attr *attr)
-{
- int ret=1;
- switch (attr->type) {
- case attr_callback:
- navit_remove_callback(this_, attr->u.callback);
- break;
- case attr_vehicle:
- case attr_osd:
- this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
- return 1;
- default:
- return 0;
- }
- return ret;
+static int navit_add_layout(struct navit *this_, struct layout *layout) {
+ struct attr active;
+ this_->layouts = g_list_append(this_->layouts, layout);
+ layout_get_attr(layout, attr_active, &active, NULL);
+ if(active.u.num || !this_->layout_current) {
+ this_->layout_current=layout;
+ return 1;
+ }
+ return 0;
+}
+
+int navit_add_attr(struct navit *this_, struct attr *attr) {
+ int ret=1;
+ switch (attr->type) {
+ case attr_callback:
+ navit_add_callback(this_, attr->u.callback);
+ break;
+ case attr_log:
+ ret=navit_add_log(this_, attr->u.log);
+ break;
+ case attr_gui:
+ ret=navit_set_gui(this_, attr->u.gui);
+ break;
+ case attr_graphics:
+ ret=navit_set_graphics(this_, attr->u.graphics);
+ break;
+ case attr_layout:
+ navit_add_layout(this_, attr->u.layout);
+ break;
+ case attr_route:
+ this_->route=attr->u.route;
+ break;
+ case attr_mapset:
+ this_->mapsets = g_list_append(this_->mapsets, attr->u.mapset);
+ break;
+ case attr_navigation:
+ this_->navigation=attr->u.navigation;
+ break;
+ case attr_osd:
+ break;
+ case attr_recent_dest:
+ this_->recentdest_count = attr->u.num;
+ break;
+ case attr_speech:
+ this_->speech=attr->u.speech;
+ break;
+ case attr_trackingo:
+ this_->tracking=attr->u.tracking;
+ break;
+ case attr_vehicle:
+ ret=navit_add_vehicle(this_, attr->u.vehicle);
+ break;
+ case attr_vehicleprofile:
+ this_->vehicleprofiles=g_list_append(this_->vehicleprofiles, attr->u.vehicleprofile);
+ break;
+ case attr_autozoom_min:
+ this_->autozoom_min = attr->u.num;
+ break;
+ case attr_autozoom_max:
+ this_->autozoom_max = attr->u.num;
+ break;
+ case attr_layer:
+ case attr_script:
+ case attr_traffic:
+ break;
+ case attr_audio:
+ ret=navit_add_audio(this_, attr->u.audio);
+ break;
+ default:
+ return 0;
+ }
+ if (ret)
+ this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+ callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
+ return ret;
+}
+
+int navit_remove_attr(struct navit *this_, struct attr *attr) {
+ int ret=1;
+ switch (attr->type) {
+ case attr_callback:
+ navit_remove_callback(this_, attr->u.callback);
+ break;
+ case attr_vehicle:
+ case attr_osd:
+ this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
+ return 1;
+ default:
+ return 0;
+ }
+ return ret;
}
struct attr_iter *
-navit_attr_iter_new(void)
-{
- return g_new0(struct attr_iter, 1);
+navit_attr_iter_new(void) {
+ return g_new0(struct attr_iter, 1);
}
-void
-navit_attr_iter_destroy(struct attr_iter *iter)
-{
- g_free(iter);
+void navit_attr_iter_destroy(struct attr_iter *iter) {
+ g_free(iter);
}
-void
-navit_add_callback(struct navit *this_, struct callback *cb)
-{
- callback_list_add(this_->attr_cbl, cb);
+void navit_add_callback(struct navit *this_, struct callback *cb) {
+ callback_list_add(this_->attr_cbl, cb);
}
-void
-navit_remove_callback(struct navit *this_, struct callback *cb)
-{
- callback_list_remove(this_->attr_cbl, cb);
+void navit_remove_callback(struct navit *this_, struct callback *cb) {
+ callback_list_remove(this_->attr_cbl, cb);
}
-static int
-coord_not_set(struct coord c){
- return !(c.x || c.y);
+static int coord_not_set(struct coord c) {
+ return !(c.x || c.y);
}
/**
@@ -3391,23 +3422,21 @@ coord_not_set(struct coord c){
* @returns nothing
*/
-static void
-navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt)
-{
- struct point cursor_pnt;
- enum projection pro;
+static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt) {
+ struct point cursor_pnt;
+ enum projection pro;
- if (this_->blocked||coord_not_set(nv->coord))
- return;
- if (pnt)
- cursor_pnt=*pnt;
- else {
- pro=transform_get_projection(this_->trans_cursor);
- if (!pro)
- return;
- transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
- }
- vehicle_draw(nv->vehicle, this_->gra, &cursor_pnt, nv->dir-transform_get_yaw(this_->trans_cursor), nv->speed);
+ if (this_->blocked||coord_not_set(nv->coord))
+ return;
+ if (pnt)
+ cursor_pnt=*pnt;
+ else {
+ pro=transform_get_projection(this_->trans_cursor);
+ if (!pro)
+ return;
+ transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
+ }
+ vehicle_draw(nv->vehicle, this_->gra, &cursor_pnt, nv->dir-transform_get_yaw(this_->trans_cursor), nv->speed);
}
/**
@@ -3431,103 +3460,104 @@ navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *
* @param this_ The navit object
* @param nv The {@code navit_vehicle} which reported a new position
*/
-static void
-navit_vehicle_update_position(struct navit *this_, struct navit_vehicle *nv) {
- struct attr attr_valid, attr_dir, attr_speed, attr_pos;
- struct pcoord cursor_pc;
- struct point cursor_pnt, *pnt=&cursor_pnt;
- struct tracking *tracking=NULL;
- struct pcoord *pc;
- enum projection pro=transform_get_projection(this_->trans_cursor);
- int count;
- int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
- void *attr_object;
- char *destination_file;
- char *description;
-
- profile(0,NULL);
- if (this_->ready == 3)
- navit_layout_switch(this_);
- if (this_->vehicle == nv && this_->tracking_flag)
- tracking=this_->tracking;
- if (tracking) {
- tracking_update(tracking, nv->vehicle, this_->vehicleprofile, pro);
- attr_object=tracking;
- get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))tracking_get_attr;
- } else {
- attr_object=nv->vehicle;
- get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))vehicle_get_attr;
- }
- if (get_attr(attr_object, attr_position_valid, &attr_valid, NULL))
- if (!attr_valid.u.num != attr_position_valid_invalid)
- return;
- if (! get_attr(attr_object, attr_position_direction, &attr_dir, NULL) ||
- ! get_attr(attr_object, attr_position_speed, &attr_speed, NULL) ||
- ! get_attr(attr_object, attr_position_coord_geo, &attr_pos, NULL)) {
- profile(0,"return 2\n");
- return;
- }
- nv->dir=*attr_dir.u.numd;
- nv->speed=*attr_speed.u.numd;
- transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord);
- if (nv != this_->vehicle) {
- if (this_->ready == 3)
- navit_vehicle_draw(this_, nv, NULL);
- profile(0,"return 3\n");
- return;
- }
- cursor_pc.x = nv->coord.x;
- cursor_pc.y = nv->coord.y;
- cursor_pc.pro = pro;
- if (this_->route) {
- if (tracking)
- route_set_position_from_tracking(this_->route, tracking, pro);
- else
- route_set_position(this_->route, &cursor_pc);
- }
- callback_list_call_attr_0(this_->attr_cbl, attr_position);
- navit_textfile_debug_log(this_, "type=trackpoint_tracked");
- if (this_->ready == 3) {
- if (this_->gui && nv->speed > 2)
- navit_disable_suspend();
-
- transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
- if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow &&
- (nv->follow_curr == 1 || !transform_within_border(this_->trans_cursor, &cursor_pnt, this_->border)))
- navit_set_center_cursor_draw(this_);
- else
- navit_vehicle_draw(this_, nv, pnt);
-
- if (nv->follow_curr > 1)
- nv->follow_curr--;
- else
- nv->follow_curr=nv->follow;
- }
- callback_list_call_attr_2(this_->attr_cbl, attr_position_coord_geo, this_, nv->vehicle);
-
- /* Finally, if we reached our destination, stop navigation. */
- if (this_->route) {
- switch(route_destination_reached(this_->route)) {
- case 1:
- description=route_get_destination_description(this_->route, 0);
- route_remove_waypoint(this_->route);
- count=route_get_destination_count(this_->route);
- pc=g_alloca(sizeof(*pc)*count);
- route_get_destinations(this_->route, pc, count);
- destination_file = bookmarks_get_destination_file(TRUE);
- bookmarks_append_destinations(this_->former_destination, destination_file, pc, count, type_former_itinerary_part, description, this_->recentdest_count);
- g_free(destination_file);
- g_free(description);
- break;
- case 2:
- destination_file = bookmarks_get_destination_file(TRUE);
- bookmarks_append_destinations(this_->former_destination, destination_file, NULL, 0, type_former_itinerary_part, NULL, this_->recentdest_count);
- navit_set_destination(this_, NULL, NULL, 0);
- g_free(destination_file);
- break;
- }
- }
- profile(0,"return 5\n");
+static void navit_vehicle_update_position(struct navit *this_, struct navit_vehicle *nv) {
+ struct attr attr_valid, attr_dir, attr_speed, attr_pos;
+ struct pcoord cursor_pc;
+ struct point cursor_pnt, *pnt=&cursor_pnt;
+ struct tracking *tracking=NULL;
+ struct pcoord *pc;
+ enum projection pro=transform_get_projection(this_->trans_cursor);
+ int count;
+ int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
+ void *attr_object;
+ char *destination_file;
+ char *description;
+
+ profile(0,NULL);
+ if (this_->ready == 3)
+ navit_layout_switch(this_);
+ if (this_->vehicle == nv && this_->tracking_flag)
+ tracking=this_->tracking;
+ if (tracking) {
+ tracking_update(tracking, nv->vehicle, this_->vehicleprofile, pro);
+ attr_object=tracking;
+ get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))tracking_get_attr;
+ } else {
+ attr_object=nv->vehicle;
+ get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))vehicle_get_attr;
+ }
+ if (get_attr(attr_object, attr_position_valid, &attr_valid, NULL))
+ if (!attr_valid.u.num != attr_position_valid_invalid)
+ return;
+ if (! get_attr(attr_object, attr_position_direction, &attr_dir, NULL) ||
+ ! get_attr(attr_object, attr_position_speed, &attr_speed, NULL) ||
+ ! get_attr(attr_object, attr_position_coord_geo, &attr_pos, NULL)) {
+ profile(0,"return 2\n");
+ return;
+ }
+ nv->dir=*attr_dir.u.numd;
+ nv->speed=*attr_speed.u.numd;
+ transform_from_geo(pro, attr_pos.u.coord_geo, &nv->coord);
+ if (nv != this_->vehicle) {
+ if (this_->ready == 3)
+ navit_vehicle_draw(this_, nv, NULL);
+ profile(0,"return 3\n");
+ return;
+ }
+ cursor_pc.x = nv->coord.x;
+ cursor_pc.y = nv->coord.y;
+ cursor_pc.pro = pro;
+ if (this_->route) {
+ if (tracking)
+ route_set_position_from_tracking(this_->route, tracking, pro);
+ else
+ route_set_position(this_->route, &cursor_pc);
+ }
+ callback_list_call_attr_0(this_->attr_cbl, attr_position);
+ navit_textfile_debug_log(this_, "type=trackpoint_tracked");
+ if (this_->ready == 3) {
+ if (this_->gui && nv->speed > 2)
+ navit_disable_suspend();
+
+ transform(this_->trans_cursor, pro, &nv->coord, &cursor_pnt, 1, 0, 0, NULL);
+ if (this_->button_pressed != 1 && this_->follow_cursor && nv->follow_curr <= nv->follow &&
+ (nv->follow_curr == 1 || !transform_within_border(this_->trans_cursor, &cursor_pnt, this_->border)))
+ navit_set_center_cursor_draw(this_);
+ else
+ navit_vehicle_draw(this_, nv, pnt);
+
+ if (nv->follow_curr > 1)
+ nv->follow_curr--;
+ else
+ nv->follow_curr=nv->follow;
+ }
+ callback_list_call_attr_2(this_->attr_cbl, attr_position_coord_geo, this_, nv->vehicle);
+
+ /* Finally, if we reached our destination, stop navigation. */
+ if (this_->route) {
+ switch(route_destination_reached(this_->route)) {
+ case 1:
+ description=route_get_destination_description(this_->route, 0);
+ route_remove_waypoint(this_->route);
+ count=route_get_destination_count(this_->route);
+ pc=g_alloca(sizeof(*pc)*count);
+ route_get_destinations(this_->route, pc, count);
+ destination_file = bookmarks_get_destination_file(TRUE);
+ bookmarks_append_destinations(this_->former_destination, destination_file, pc, count, type_former_itinerary_part,
+ description, this_->recentdest_count);
+ g_free(destination_file);
+ g_free(description);
+ break;
+ case 2:
+ destination_file = bookmarks_get_destination_file(TRUE);
+ bookmarks_append_destinations(this_->former_destination, destination_file, NULL, 0, type_former_itinerary_part, NULL,
+ this_->recentdest_count);
+ navit_set_destination(this_, NULL, NULL, 0);
+ g_free(destination_file);
+ break;
+ }
+ }
+ profile(0,"return 5\n");
}
@@ -3585,19 +3615,18 @@ navit_audio_update_status(struct navit *this_, struct navit_audio_plugin *na, en
* @param nv The {@code navit_vehicle} which reported a new status attribute
* @param type The type of attribute with has changed
*/
-static void
-navit_vehicle_update_status(struct navit *this_, struct navit_vehicle *nv, enum attr_type type) {
- if (this_->vehicle != nv)
- return;
- switch(type) {
- case attr_position_fix_type:
- case attr_position_sats_used:
- case attr_position_hdop:
- callback_list_call_attr_2(this_->attr_cbl, type, this_, nv->vehicle);
- break;
- default:
- return;
- }
+static void navit_vehicle_update_status(struct navit *this_, struct navit_vehicle *nv, enum attr_type type) {
+ if (this_->vehicle != nv)
+ return;
+ switch(type) {
+ case attr_position_fix_type:
+ case attr_position_sats_used:
+ case attr_position_hdop:
+ callback_list_call_attr_2(this_->attr_cbl, type, this_, nv->vehicle);
+ break;
+ default:
+ return;
+ }
}
/**
@@ -3608,72 +3637,63 @@ navit_vehicle_update_status(struct navit *this_, struct navit_vehicle *nv, enum
* @returns nothing
*/
-void
-navit_set_position(struct navit *this_, struct pcoord *c)
-{
- if (this_->route) {
- route_set_position(this_->route, c);
- callback_list_call_attr_0(this_->attr_cbl, attr_position);
- }
- if (this_->ready == 3)
- navit_draw(this_);
-}
-
-static int
-navit_set_vehicleprofile(struct navit *this_, struct vehicleprofile *vp)
-{
- if (this_->vehicleprofile == vp)
- return 0;
- this_->vehicleprofile=vp;
- if (this_->route)
- route_set_profile(this_->route, this_->vehicleprofile);
- return 1;
-}
-
-int
-navit_set_vehicleprofile_name(struct navit *this_, char *name)
-{
- struct attr attr;
- GList *l;
- l=this_->vehicleprofiles;
- while (l) {
- if (vehicleprofile_get_attr(l->data, attr_name, &attr, NULL)) {
- if (!strcmp(attr.u.str, name)) {
- navit_set_vehicleprofile(this_, l->data);
- return 1;
- }
- }
- l=g_list_next(l);
- }
- return 0;
+void navit_set_position(struct navit *this_, struct pcoord *c) {
+ if (this_->route) {
+ route_set_position(this_->route, c);
+ callback_list_call_attr_0(this_->attr_cbl, attr_position);
+ }
+ if (this_->ready == 3)
+ navit_draw(this_);
+}
+
+static int navit_set_vehicleprofile(struct navit *this_, struct vehicleprofile *vp) {
+ if (this_->vehicleprofile == vp)
+ return 0;
+ this_->vehicleprofile=vp;
+ if (this_->route)
+ route_set_profile(this_->route, this_->vehicleprofile);
+ return 1;
+}
+
+int navit_set_vehicleprofile_name(struct navit *this_, char *name) {
+ struct attr attr;
+ GList *l;
+ l=this_->vehicleprofiles;
+ while (l) {
+ if (vehicleprofile_get_attr(l->data, attr_name, &attr, NULL)) {
+ if (!strcmp(attr.u.str, name)) {
+ navit_set_vehicleprofile(this_, l->data);
+ return 1;
+ }
+ }
+ l=g_list_next(l);
+ }
+ return 0;
}
-static void
-navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv)
-{
- struct attr attr;
- this_->vehicle=nv;
- if (nv && vehicle_get_attr(nv->vehicle, attr_profilename, &attr, NULL)) {
- if (navit_set_vehicleprofile_name(this_, attr.u.str))
- return;
- }
- if (!this_->vehicleprofile) { // When deactivating vehicle, keep the last profile if any
- if (!navit_set_vehicleprofile_name(this_,"car")) {
- /* We do not have a fallback "car" profile
- * so lets set any profile */
- GList *l;
- l=this_->vehicleprofiles;
- if (l) {
- this_->vehicleprofile=l->data;
- if (this_->route)
- route_set_profile(this_->route, this_->vehicleprofile);
- }
- }
- }
- else {
- if (this_->route)
- route_set_profile(this_->route, this_->vehicleprofile);
- }
+static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv) {
+ struct attr attr;
+ this_->vehicle=nv;
+ if (nv && vehicle_get_attr(nv->vehicle, attr_profilename, &attr, NULL)) {
+ if (navit_set_vehicleprofile_name(this_, attr.u.str))
+ return;
+ }
+ if (!this_->vehicleprofile) { // When deactivating vehicle, keep the last profile if any
+ if (!navit_set_vehicleprofile_name(this_,"car")) {
+ /* We do not have a fallback "car" profile
+ * so lets set any profile */
+ GList *l;
+ l=this_->vehicleprofiles;
+ if (l) {
+ this_->vehicleprofile=l->data;
+ if (this_->route)
+ route_set_profile(this_->route, this_->vehicleprofile);
+ }
+ }
+ } else {
+ if (this_->route)
+ route_set_profile(this_->route, this_->vehicleprofile);
+ }
}
/**
@@ -3715,147 +3735,143 @@ navit_add_audio(struct navit *this_, struct audio *a)
* @param v The vehicle to register
* @return True for success
*/
-static int
-navit_add_vehicle(struct navit *this_, struct vehicle *v)
-{
- struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1);
- struct attr follow, active, animate;
- nv->vehicle=v;
- nv->follow=0;
- nv->last.x = 0;
- nv->last.y = 0;
- nv->animate_cursor=0;
- if ((vehicle_get_attr(v, attr_follow, &follow, NULL)))
- nv->follow=follow.u.num;
- nv->follow_curr=nv->follow;
- this_->vehicles=g_list_append(this_->vehicles, nv);
- if ((vehicle_get_attr(v, attr_active, &active, NULL)) && active.u.num)
- navit_set_vehicle(this_, nv);
- if ((vehicle_get_attr(v, attr_animate, &animate, NULL)))
- nv->animate_cursor=animate.u.num;
- nv->callback.type=attr_callback;
- nv->callback.u.callback=callback_new_attr_2(callback_cast(navit_vehicle_update_position), attr_position_coord_geo, this_, nv);
- vehicle_add_attr(nv->vehicle, &nv->callback);
- nv->callback.u.callback=callback_new_attr_3(callback_cast(navit_vehicle_update_status), attr_position_fix_type, this_, nv, attr_position_fix_type);
- vehicle_add_attr(nv->vehicle, &nv->callback);
- nv->callback.u.callback=callback_new_attr_3(callback_cast(navit_vehicle_update_status), attr_position_sats_used, this_, nv, attr_position_sats_used);
- vehicle_add_attr(nv->vehicle, &nv->callback);
- nv->callback.u.callback=callback_new_attr_3(callback_cast(navit_vehicle_update_status), attr_position_hdop, this_, nv, attr_position_hdop);
- vehicle_add_attr(nv->vehicle, &nv->callback);
- vehicle_set_attr(nv->vehicle, &this_->self);
- return 1;
+static int navit_add_vehicle(struct navit *this_, struct vehicle *v) {
+ struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1);
+ struct attr follow, active, animate;
+ nv->vehicle=v;
+ nv->follow=0;
+ nv->last.x = 0;
+ nv->last.y = 0;
+ nv->animate_cursor=0;
+ if ((vehicle_get_attr(v, attr_follow, &follow, NULL)))
+ nv->follow=follow.u.num;
+ nv->follow_curr=nv->follow;
+ this_->vehicles=g_list_append(this_->vehicles, nv);
+ if ((vehicle_get_attr(v, attr_active, &active, NULL)) && active.u.num)
+ navit_set_vehicle(this_, nv);
+ if ((vehicle_get_attr(v, attr_animate, &animate, NULL)))
+ nv->animate_cursor=animate.u.num;
+ nv->callback.type=attr_callback;
+ nv->callback.u.callback=callback_new_attr_2(callback_cast(navit_vehicle_update_position), attr_position_coord_geo,
+ this_, nv);
+ vehicle_add_attr(nv->vehicle, &nv->callback);
+ nv->callback.u.callback=callback_new_attr_3(callback_cast(navit_vehicle_update_status), attr_position_fix_type, this_,
+ nv, attr_position_fix_type);
+ vehicle_add_attr(nv->vehicle, &nv->callback);
+ nv->callback.u.callback=callback_new_attr_3(callback_cast(navit_vehicle_update_status), attr_position_sats_used, this_,
+ nv, attr_position_sats_used);
+ vehicle_add_attr(nv->vehicle, &nv->callback);
+ nv->callback.u.callback=callback_new_attr_3(callback_cast(navit_vehicle_update_status), attr_position_hdop, this_, nv,
+ attr_position_hdop);
+ vehicle_add_attr(nv->vehicle, &nv->callback);
+ vehicle_set_attr(nv->vehicle, &this_->self);
+ return 1;
}
struct gui *
-navit_get_gui(struct navit *this_)
-{
- return this_->gui;
+navit_get_gui(struct navit *this_) {
+ return this_->gui;
}
struct transformation *
-navit_get_trans(struct navit *this_)
-{
- return this_->trans;
+navit_get_trans(struct navit *this_) {
+ return this_->trans;
}
struct route *
-navit_get_route(struct navit *this_)
-{
- return this_->route;
+navit_get_route(struct navit *this_) {
+ return this_->route;
}
struct navigation *
-navit_get_navigation(struct navit *this_)
-{
- return this_->navigation;
+navit_get_navigation(struct navit *this_) {
+ return this_->navigation;
}
struct displaylist *
-navit_get_displaylist(struct navit *this_)
-{
- return this_->displaylist;
+navit_get_displaylist(struct navit *this_) {
+ return this_->displaylist;
}
/*todo : make it switch to nightlayout when we are in a tunnel */
-void
-navit_layout_switch(struct navit *n)
-{
+void navit_layout_switch(struct navit *n) {
- int currTs=0;
- struct attr iso8601_attr,geo_attr,valid_attr,layout_attr;
- double trise,tset,trise_actual;
- struct layout *l;
- int year, month, day;
- int after_sunrise = FALSE;
- int after_sunset = FALSE;
+ int currTs=0;
+ struct attr iso8601_attr,geo_attr,valid_attr,layout_attr;
+ double trise,tset,trise_actual;
+ struct layout *l;
+ int year, month, day;
+ int after_sunrise = FALSE;
+ int after_sunset = FALSE;
- if (navit_get_attr(n,attr_layout,&layout_attr,NULL)!=1) {
- return; //No layout - nothing to switch
- }
- if (!n->vehicle)
- return;
- l=layout_attr.u.layout;
-
- if (l->dayname || l->nightname) {
- //Ok, we know that we have profile to switch
-
- //Check that we aren't calculating too fast
- if (vehicle_get_attr(n->vehicle->vehicle, attr_position_time_iso8601,&iso8601_attr,NULL)==1) {
- currTs=iso8601_to_secs(iso8601_attr.u.str);
- dbg(lvl_debug,"currTs: %u:%u\n",currTs%86400/3600,((currTs%86400)%3600)/60);
- }
- dbg(lvl_debug,"prevTs: %u:%u\n",n->prevTs%86400/3600,((n->prevTs%86400)%3600)/60);
+ if (navit_get_attr(n,attr_layout,&layout_attr,NULL)!=1) {
+ return; //No layout - nothing to switch
+ }
+ if (!n->vehicle)
+ return;
+ l=layout_attr.u.layout;
- if (n->auto_switch == FALSE)
- return;
+ if (l->dayname || l->nightname) {
+ //Ok, we know that we have profile to switch
- if (currTs-(n->prevTs)<60) {
- //We've have to wait a little
- return;
- }
+ //Check that we aren't calculating too fast
+ if (vehicle_get_attr(n->vehicle->vehicle, attr_position_time_iso8601,&iso8601_attr,NULL)==1) {
+ currTs=iso8601_to_secs(iso8601_attr.u.str);
+ dbg(lvl_debug,"currTs: %u:%u",currTs%86400/3600,((currTs%86400)%3600)/60);
+ }
+ dbg(lvl_debug,"prevTs: %u:%u",n->prevTs%86400/3600,((n->prevTs%86400)%3600)/60);
- if (sscanf(iso8601_attr.u.str,"%d-%02d-%02dT",&year,&month,&day) != 3)
- return;
- if (vehicle_get_attr(n->vehicle->vehicle, attr_position_valid, &valid_attr,NULL) && valid_attr.u.num==attr_position_valid_invalid) {
- return; //No valid fix yet
- }
- if (vehicle_get_attr(n->vehicle->vehicle, attr_position_coord_geo,&geo_attr,NULL)!=1) {
- //No position - no sun
- return;
- }
- //We calculate sunrise anyway, cause it is needed both for day and for night
- if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lng,geo_attr.u.coord_geo->lat,-5,1,&trise,&tset)!=0) {
- dbg(lvl_debug,"near the pole sun never rises/sets, so we should never switch profiles\n");
- dbg(lvl_debug,"trise: %u:%u\n",HOURS(trise),MINUTES(trise));
- dbg(lvl_debug,"tset: %u:%u\n",HOURS(tset),MINUTES(tset));
- n->prevTs=currTs;
- return;
- }
- trise_actual=trise;
- dbg(lvl_debug,"trise: %u:%u\n",HOURS(trise),MINUTES(trise));
- dbg(lvl_debug,"tset: %u:%u\n",HOURS(tset),MINUTES(tset));
- dbg(lvl_debug,"dayname = %s, name =%s \n",l->dayname, l->name);
- dbg(lvl_debug,"nightname = %s, name = %s \n",l->nightname, l->name);
- if (HOURS(trise)*60+MINUTES(trise)<(currTs%86400)/60) {
- after_sunrise = TRUE;
- }
-
- if (((HOURS(tset)*60+MINUTES(tset)<(currTs%86400)/60)) ||
- ((HOURS(trise_actual)*60+MINUTES(trise_actual)>(currTs%86400)/60))) {
- after_sunset = TRUE;
- }
- if (after_sunrise && !after_sunset && l->dayname) {
- navit_set_layout_by_name(n,l->dayname);
- dbg(lvl_debug,"layout set to day\n");
- }else if (after_sunset && l->nightname) {
- navit_set_layout_by_name(n,l->nightname);
- dbg(lvl_debug,"layout set to night\n");
- }
- n->prevTs=currTs;
- }
+ if (n->auto_switch == FALSE)
+ return;
+
+ if (currTs-(n->prevTs)<60) {
+ //We've have to wait a little
+ return;
+ }
+
+ if (sscanf(iso8601_attr.u.str,"%d-%02d-%02dT",&year,&month,&day) != 3)
+ return;
+ if (vehicle_get_attr(n->vehicle->vehicle, attr_position_valid, &valid_attr,NULL)
+ && valid_attr.u.num==attr_position_valid_invalid) {
+ return; //No valid fix yet
+ }
+ if (vehicle_get_attr(n->vehicle->vehicle, attr_position_coord_geo,&geo_attr,NULL)!=1) {
+ //No position - no sun
+ return;
+ }
+ //We calculate sunrise anyway, cause it is needed both for day and for night
+ if (__sunriset__(year,month,day,geo_attr.u.coord_geo->lng,geo_attr.u.coord_geo->lat,-5,1,&trise,&tset)!=0) {
+ dbg(lvl_debug,"near the pole sun never rises/sets, so we should never switch profiles");
+ dbg(lvl_debug,"trise: %u:%u",HOURS(trise),MINUTES(trise));
+ dbg(lvl_debug,"tset: %u:%u",HOURS(tset),MINUTES(tset));
+ n->prevTs=currTs;
+ return;
+ }
+ trise_actual=trise;
+ dbg(lvl_debug,"trise: %u:%u",HOURS(trise),MINUTES(trise));
+ dbg(lvl_debug,"tset: %u:%u",HOURS(tset),MINUTES(tset));
+ dbg(lvl_debug,"dayname = %s, name =%s ",l->dayname, l->name);
+ dbg(lvl_debug,"nightname = %s, name = %s ",l->nightname, l->name);
+ if (HOURS(trise)*60+MINUTES(trise)<(currTs%86400)/60) {
+ after_sunrise = TRUE;
+ }
+
+ if (((HOURS(tset)*60+MINUTES(tset)<(currTs%86400)/60)) ||
+ ((HOURS(trise_actual)*60+MINUTES(trise_actual)>(currTs%86400)/60))) {
+ after_sunset = TRUE;
+ }
+ if (after_sunrise && !after_sunset && l->dayname) {
+ navit_set_layout_by_name(n,l->dayname);
+ dbg(lvl_debug,"layout set to day");
+ } else if (after_sunset && l->nightname) {
+ navit_set_layout_by_name(n,l->nightname);
+ dbg(lvl_debug,"layout set to night");
+ }
+ n->prevTs=currTs;
+ }
}
/**
@@ -3879,83 +3895,74 @@ navit_layout_switch(struct navit *n)
* the version of the active layout (day/night/undefined)
*/
static
-void navit_cmd_switch_layout_day_night(struct navit *this_, char *function, struct attr **in, struct attr ***out, int valid)
-{
+void navit_cmd_switch_layout_day_night(struct navit *this_, char *function, struct attr **in, struct attr ***out,
+ int valid) {
- if (!(in && in[0] && ATTR_IS_STRING(in[0]->type))) {
- return;
- }
+ if (!(in && in[0] && ATTR_IS_STRING(in[0]->type))) {
+ return;
+ }
- dbg(lvl_debug," called with mode =%s\n",in[0]->u.str);
+ dbg(lvl_debug," called with mode =%s",in[0]->u.str);
- if (!this_->layout_current)
- return;
+ if (!this_->layout_current)
+ return;
if (!this_->vehicle)
- return;
+ return;
- if (!strcmp(in[0]->u.str,"manual")) {
- this_->auto_switch = FALSE;
- }
- else if (!strcmp(in[0]->u.str,"auto")) {
- this_->auto_switch = TRUE;
- this_->prevTs = 0;
- navit_layout_switch(this_);
- }
- else if (!strcmp(in[0]->u.str,"manual_toggle")) {
- if (this_->layout_current->dayname) {
- navit_set_layout_by_name(this_,this_->layout_current->dayname);
- this_->auto_switch = FALSE;
- dbg(lvl_debug,"toggeled layout to = %s\n",this_->layout_current->name);
- }
- else if (this_->layout_current->nightname) {
- navit_set_layout_by_name(this_,this_->layout_current->nightname);
- this_->auto_switch = FALSE;
- dbg(lvl_debug,"toggeled layout to = %s\n",this_->layout_current->name);
- }
- }
- else if (!strcmp(in[0]->u.str,"manual_day") && this_->layout_current->dayname) {
- navit_set_layout_by_name(this_,this_->layout_current->dayname);
- this_->auto_switch = FALSE;
- dbg(lvl_debug,"switched layout to = %s\n",this_->layout_current->name);
- }
- else if (!strcmp(in[0]->u.str,"manual_night") && this_->layout_current->nightname) {
- navit_set_layout_by_name(this_,this_->layout_current->nightname);
- this_->auto_switch = FALSE;
- dbg(lvl_debug,"switched layout to = %s\n",this_->layout_current->name);
- }
+ if (!strcmp(in[0]->u.str,"manual")) {
+ this_->auto_switch = FALSE;
+ } else if (!strcmp(in[0]->u.str,"auto")) {
+ this_->auto_switch = TRUE;
+ this_->prevTs = 0;
+ navit_layout_switch(this_);
+ } else if (!strcmp(in[0]->u.str,"manual_toggle")) {
+ if (this_->layout_current->dayname) {
+ navit_set_layout_by_name(this_,this_->layout_current->dayname);
+ this_->auto_switch = FALSE;
+ dbg(lvl_debug,"toggeled layout to = %s",this_->layout_current->name);
+ } else if (this_->layout_current->nightname) {
+ navit_set_layout_by_name(this_,this_->layout_current->nightname);
+ this_->auto_switch = FALSE;
+ dbg(lvl_debug,"toggeled layout to = %s",this_->layout_current->name);
+ }
+ } else if (!strcmp(in[0]->u.str,"manual_day") && this_->layout_current->dayname) {
+ navit_set_layout_by_name(this_,this_->layout_current->dayname);
+ this_->auto_switch = FALSE;
+ dbg(lvl_debug,"switched layout to = %s",this_->layout_current->name);
+ } else if (!strcmp(in[0]->u.str,"manual_night") && this_->layout_current->nightname) {
+ navit_set_layout_by_name(this_,this_->layout_current->nightname);
+ this_->auto_switch = FALSE;
+ dbg(lvl_debug,"switched layout to = %s",this_->layout_current->name);
+ }
- dbg(lvl_debug,"auto = %i\n",this_->auto_switch);
- return;
+ dbg(lvl_debug,"auto = %i",this_->auto_switch);
+ return;
}
-int
-navit_set_vehicle_by_name(struct navit *n,const char *name)
-{
+int navit_set_vehicle_by_name(struct navit *n,const char *name) {
struct vehicle *v;
struct attr_iter *iter;
struct attr vehicle_attr, name_attr;
- iter=navit_attr_iter_new();
+ iter=navit_attr_iter_new();
while (navit_get_attr(n,attr_vehicle,&vehicle_attr,iter)) {
- v=vehicle_attr.u.vehicle;
- vehicle_get_attr(v,attr_name,&name_attr,NULL);
- if (name_attr.type==attr_name) {
- if (!strcmp(name,name_attr.u.str)) {
- navit_set_attr(n,&vehicle_attr);
- navit_attr_iter_destroy(iter);
- return 1;
- }
- }
- }
+ v=vehicle_attr.u.vehicle;
+ vehicle_get_attr(v,attr_name,&name_attr,NULL);
+ if (name_attr.type==attr_name) {
+ if (!strcmp(name,name_attr.u.str)) {
+ navit_set_attr(n,&vehicle_attr);
+ navit_attr_iter_destroy(iter);
+ return 1;
+ }
+ }
+ }
navit_attr_iter_destroy(iter);
return 0;
}
-int
-navit_set_layout_by_name(struct navit *n,const char *name)
-{
+int navit_set_layout_by_name(struct navit *n,const char *name) {
struct layout *l;
struct attr_iter iter;
struct attr layout_attr;
@@ -3963,34 +3970,33 @@ navit_set_layout_by_name(struct navit *n,const char *name)
iter.u.list=0x00;
if (navit_get_attr(n,attr_layout,&layout_attr,&iter)!=1) {
- return 0; //No layouts - nothing to do
+ return 0; //No layouts - nothing to do
}
if (iter.u.list==NULL) {
- return 0;
+ return 0;
}
-
+
iter.u.list=g_list_first(iter.u.list);
-
+
while(iter.u.list) {
- l=(struct layout*)iter.u.list->data;
- if (!strcmp(name,l->name)) {
- layout_attr.u.layout=l;
- layout_attr.type=attr_layout;
- navit_set_attr(n,&layout_attr);
- iter.u.list=g_list_first(iter.u.list);
- return 1;
- }
- iter.u.list=g_list_next(iter.u.list);
+ l=(struct layout*)iter.u.list->data;
+ if (!strcmp(name,l->name)) {
+ layout_attr.u.layout=l;
+ layout_attr.type=attr_layout;
+ navit_set_attr(n,&layout_attr);
+ iter.u.list=g_list_first(iter.u.list);
+ return 1;
+ }
+ iter.u.list=g_list_next(iter.u.list);
}
iter.u.list=g_list_first(iter.u.list);
return 0;
}
-void
-navit_disable_suspend() {
- gui_disable_suspend(global_navit->gui);
- callback_list_call_attr_0(global_navit->attr_cbl,attr_unsuspend);
+void navit_disable_suspend() {
+ gui_disable_suspend(global_navit->gui);
+ callback_list_call_attr_0(global_navit->attr_cbl,attr_unsuspend);
}
/**
@@ -4011,105 +4017,100 @@ navit_disable_suspend() {
*
* @return {@code true} if a redraw operation was triggered, {@code false} if not
*/
-int
-navit_block(struct navit *this_, int block)
-{
- if (block > 0) {
- this_->blocked |= 1;
- if (graphics_draw_cancel(this_->gra, this_->displaylist))
- this_->blocked |= 2;
- return 0;
- }
- if ((this_->blocked & 2) || block < 0) {
- this_->blocked=0;
- navit_draw(this_);
- return 1;
- }
- this_->blocked=0;
- return 0;
+int navit_block(struct navit *this_, int block) {
+ if (block > 0) {
+ this_->blocked |= 1;
+ if (graphics_draw_cancel(this_->gra, this_->displaylist))
+ this_->blocked |= 2;
+ return 0;
+ }
+ if ((this_->blocked & 2) || block < 0) {
+ this_->blocked=0;
+ navit_draw(this_);
+ return 1;
+ }
+ this_->blocked=0;
+ return 0;
}
/**
* @brief Returns whether redraw operations are currently blocked.
*/
-int navit_get_blocked(struct navit *this_)
-{
- return this_->blocked;
+int navit_get_blocked(struct navit *this_) {
+ return this_->blocked;
}
-void
-navit_destroy(struct navit *this_)
-{
- dbg(lvl_debug,"enter %p\n",this_);
- graphics_draw_cancel(this_->gra, this_->displaylist);
- callback_list_call_attr_1(this_->attr_cbl, attr_destroy, this_);
- attr_list_free(this_->attrs);
-
- if(cmd_int_var_hash) {
- g_hash_table_destroy(cmd_int_var_hash);
- cmd_int_var_hash=NULL;
- }
- if(cmd_attr_var_hash) {
- g_hash_table_destroy(cmd_attr_var_hash);
- cmd_attr_var_hash=NULL;
- }
- if(cmd_int_var_stack) {
- g_list_foreach(cmd_int_var_stack, (GFunc)attr_free, NULL);
- g_list_free(cmd_int_var_stack);
- cmd_int_var_stack=NULL;
- }
+void navit_destroy(struct navit *this_) {
+ dbg(lvl_debug,"enter %p",this_);
+ graphics_draw_cancel(this_->gra, this_->displaylist);
+ callback_list_call_attr_1(this_->attr_cbl, attr_destroy, this_);
+ attr_list_free(this_->attrs);
- if (this_->bookmarks) {
- char *center_file = bookmarks_get_center_file(TRUE);
- bookmarks_write_center_to_file(this_->bookmarks, center_file);
- g_free(center_file);
- bookmarks_destroy(this_->bookmarks);
- }
+ if(cmd_int_var_hash) {
+ g_hash_table_destroy(cmd_int_var_hash);
+ cmd_int_var_hash=NULL;
+ }
+ if(cmd_attr_var_hash) {
+ g_hash_table_destroy(cmd_attr_var_hash);
+ cmd_attr_var_hash=NULL;
+ }
+ if(cmd_int_var_stack) {
+ g_list_foreach(cmd_int_var_stack, (GFunc)attr_free, NULL);
+ g_list_free(cmd_int_var_stack);
+ cmd_int_var_stack=NULL;
+ }
- callback_destroy(this_->nav_speech_cb);
- callback_destroy(this_->roadbook_callback);
- callback_destroy(this_->popup_callback);
- callback_destroy(this_->motion_timeout_callback);
- callback_destroy(this_->progress_cb);
-
- if(this_->gra) {
- graphics_remove_callback(this_->gra, this_->resize_callback);
- graphics_remove_callback(this_->gra, this_->button_callback);
- graphics_remove_callback(this_->gra, this_->motion_callback);
- graphics_remove_callback(this_->gra, this_->predraw_callback);
- }
+ if (this_->bookmarks) {
+ char *center_file = bookmarks_get_center_file(TRUE);
+ bookmarks_write_center_to_file(this_->bookmarks, center_file);
+ g_free(center_file);
+ bookmarks_destroy(this_->bookmarks);
+ }
+
+ callback_destroy(this_->nav_speech_cb);
+ callback_destroy(this_->roadbook_callback);
+ callback_destroy(this_->popup_callback);
+ callback_destroy(this_->motion_timeout_callback);
+ callback_destroy(this_->progress_cb);
+
+ if(this_->gra) {
+ graphics_remove_callback(this_->gra, this_->resize_callback);
+ graphics_remove_callback(this_->gra, this_->button_callback);
+ graphics_remove_callback(this_->gra, this_->motion_callback);
+ graphics_remove_callback(this_->gra, this_->predraw_callback);
+ }
- callback_destroy(this_->resize_callback);
- callback_destroy(this_->motion_callback);
- callback_destroy(this_->predraw_callback);
+ callback_destroy(this_->resize_callback);
+ callback_destroy(this_->motion_callback);
+ callback_destroy(this_->predraw_callback);
- callback_destroy(this_->route_cb);
- if (this_->route)
- route_destroy(this_->route);
+ callback_destroy(this_->route_cb);
+ if (this_->route)
+ route_destroy(this_->route);
- map_destroy(this_->former_destination);
+ map_destroy(this_->former_destination);
- graphics_displaylist_destroy(this_->displaylist);
+ graphics_displaylist_destroy(this_->displaylist);
- graphics_free(this_->gra);
+ graphics_free(this_->gra);
- g_free(this_);
+ g_free(this_);
}
struct object_func navit_func = {
- attr_navit,
- (object_func_new)navit_new,
- (object_func_get_attr)navit_get_attr,
- (object_func_iter_new)navit_attr_iter_new,
- (object_func_iter_destroy)navit_attr_iter_destroy,
- (object_func_set_attr)navit_set_attr,
- (object_func_add_attr)navit_add_attr,
- (object_func_remove_attr)navit_remove_attr,
- (object_func_init)navit_init,
- (object_func_destroy)navit_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_navit,
+ (object_func_new)navit_new,
+ (object_func_get_attr)navit_get_attr,
+ (object_func_iter_new)navit_attr_iter_new,
+ (object_func_iter_destroy)navit_attr_iter_destroy,
+ (object_func_set_attr)navit_set_attr,
+ (object_func_add_attr)navit_add_attr,
+ (object_func_remove_attr)navit_remove_attr,
+ (object_func_init)navit_init,
+ (object_func_destroy)navit_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
/** @} */
diff --git a/navit/navit.dtd b/navit/navit.dtd
index c17602725..645816a93 100644
--- a/navit/navit.dtd
+++ b/navit/navit.dtd
@@ -17,7 +17,7 @@
<!ATTLIST log flush_size CDATA #IMPLIED>
<!ATTLIST log flush_time CDATA #IMPLIED>
<!ATTLIST log attr_types CDATA #IMPLIED>
-<!ELEMENT navit (graphics,gui+,log*,osd*,vehicle*,tracking,vehicleprofile*,route,navigation,speech,mapset+,layout+)*>
+<!ELEMENT navit (graphics,gui+,log*,osd*,traffic*,vehicle*,tracking?,vehicleprofile*,route,navigation,speech,mapset+,layer+,layout+) >
<!ATTLIST navit center CDATA #REQUIRED>
<!ATTLIST navit zoom CDATA #REQUIRED>
<!ATTLIST navit tracking CDATA #REQUIRED>
@@ -65,6 +65,8 @@
<!ELEMENT cursor (itemgra+)>
<!ATTLIST cursor w CDATA #REQUIRED>
<!ATTLIST cursor h CDATA #REQUIRED>
+<!ELEMENT traffic EMPTY>
+<!ATTLIST traffic type CDATA #REQUIRED>
<!ELEMENT tracking ANY>
<!ATTLIST tracking cdf_histsize CDATA #IMPLIED>
<!ELEMENT route EMPTY>
diff --git a/navit/navit.h b/navit/navit.h
index 898ff6cff..f543a7baf 100644
--- a/navit/navit.h
+++ b/navit/navit.h
@@ -39,6 +39,7 @@ struct coord_rect;
struct displaylist;
struct graphics;
struct gui;
+struct layout;
struct mapset;
struct message;
struct navigation;
@@ -53,6 +54,8 @@ struct command_table;
struct item;
void navit_add_mapset(struct navit *this_, struct mapset *ms);
struct mapset *navit_get_mapset(struct navit *this_);
+struct map *navit_get_search_results_map(struct navit *this_);
+int navit_populate_search_results_map(struct navit *navit, GList *search_results, struct coord_rect *r);
struct tracking *navit_get_tracking(struct navit *this_);
char *navit_get_user_data_directory(int create);
void navit_draw_async(struct navit *this_, int async);
@@ -103,6 +106,8 @@ void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orienta
void navit_set_center_screen(struct navit *this_, struct point *p, int set_timeout);
int navit_set_attr(struct navit *this_, struct attr *attr);
int navit_get_attr(struct navit *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
+struct layout *navit_get_layout_by_name(struct navit *this_, const char *layout_name);
+void navit_update_current_layout(struct navit *this_, struct layout *layout);
int navit_add_attr(struct navit *this_, struct attr *attr);
int navit_remove_attr(struct navit *this_, struct attr *attr);
struct attr_iter *navit_attr_iter_new(void);
diff --git a/navit/navit_layout_bike_shipped.xml b/navit/navit_layout_bike_shipped.xml
new file mode 100644
index 000000000..dd5a9943a
--- /dev/null
+++ b/navit/navit_layout_bike_shipped.xml
@@ -0,0 +1,1052 @@
+<?xml version="1.0"?>
+<layout xmlns:xi="http://www.w3.org/2001/XInclude" name="Bike" color="#ffefb7" font="Liberation Sans">
+ <cursor w="26" h="26">
+ <itemgra>
+ <circle color="#0000ff" radius="24" width="2">
+ <coord x="0" y="0"/>
+ </circle>
+ </itemgra>
+ <itemgra speed_range="-2">
+ <polyline color="#0000ff" width="2">
+ <coord x="0" y="0"/>
+ <coord x="0" y="0"/>
+ </polyline>
+ </itemgra>
+ <itemgra speed_range="3-">
+ <polyline color="#0000ff" width="2">
+ <coord x="-7" y="-10"/>
+ <coord x="0" y="12"/>
+ <coord x="7" y="-10"/>
+ </polyline>
+ </itemgra>
+ </cursor>
+ <layer name="Landuse">
+ <itemgra item_types="image" order="0-">
+ <image/>
+ </itemgra>
+ <itemgra item_types="poly_wood" order="0-">
+ <polygon color="#8ec78d"/>
+ </itemgra>
+ <itemgra item_types="poly_town" order="0-">
+ <polygon color="#ffc895"/>
+ <polyline color="#ebb481"/>
+ </itemgra>
+ <itemgra item_types="poly_park" order="0-">
+ <polygon color="#7cc334"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_water" order="0-">
+ <polygon color="#82c8ea"/>
+ <polyline color="#5096b8"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_land" order="0-">
+ <polygon color="#ffefb7"/>
+ <polyline color="#ffefb7"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_airport" order="0-">
+ <polygon color="#a0a0a0"/>
+ </itemgra>
+ <itemgra item_types="poly_sport" order="0-">
+ <polygon color="#ff8c00"/>
+ </itemgra>
+ <itemgra item_types="poly_industry,poly_place,poly_railway" order="0-">
+ <polygon color="#e6e6e6"/>
+ </itemgra>
+ <itemgra item_types="poly_commercial" order="0-">
+ <polygon color="#fff8dc"/>
+ </itemgra>
+ <itemgra item_types="poly_industry,poly_building,poly_place,poly_brownfield,poly_greenfield,poly_construction,poly_railway" order="0-">
+ <polygon color="#ecd8ff"/>
+ </itemgra>
+ <itemgra item_types="poly_farm" order="0-">
+ <polygon color="#c7f1a3"/>
+ <polyline color="#79c691"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_meadow" order="0-">
+ <polygon color="#c7f1a3"/>
+ <polyline color="#79c691"/>
+ </itemgra>
+ <itemgra item_types="poly_scree,poly_scrub,poly_fell,poly_heath" order="0-">
+ <polygon color="#c7f1a3"/>
+ <polyline color="#79c691"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_marsh,poly_mud,poly_quarry" order="0-">
+ <polygon color="#DEB887"/>
+ <polyline color="#DEB887"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_allotments,poly_playground,poly_village_green,poly_recreation_ground,poly_common,poly_garden" order="0-">
+ <polygon color="#c7f1a3"/>
+ <polyline color="#79c691"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_ruins" order="0-">
+ <polygon color="#b6a6a6"/>
+ </itemgra>
+ <itemgra item_types="poly_apron" order="0-">
+ <polygon color="#d0d0d0"/>
+ </itemgra>
+ <itemgra item_types="poly_terminal" order="7-">
+ <polygon color="#e3c6a6"/>
+ </itemgra>
+ <itemgra item_types="poly_cemetery" order="1-">
+ <polygon color="#bde3cb"/>
+ </itemgra>
+ <itemgra item_types="poly_car_parking" order="1-">
+ <polygon color="#d2d2d2"/>
+ </itemgra>
+ <itemgra item_types="poly_building" order="0-">
+ <polygon color="#ff6347"/>
+ </itemgra>
+ </layer>
+ <layer name="Contour Lines">
+ <itemgra item_types="height_line_1" order="8">
+ <polyline color="#A9A9A9" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="height_line_1" order="9">
+ <polyline color="#A9A9A9" width="2"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="height_line_2" order="9">
+ <polyline color="#A9A9A9" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="height_line_1" order="10-">
+ <polyline color="#A9A9A9" width="3"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="height_line_2" order="10-">
+ <polyline color="#A9A9A9" width="2"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="height_line_3" order="10-">
+ <polyline color="#A9A9A9" width="1"/>
+ </itemgra>
+ </layer>
+ <!-- "Contour Lines" -->
+ <layer name="Barriers">
+ <itemgra item_types="ditch" order="8-">
+ <polyline color="#B8860B" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="hedge" order="8-">
+ <polyline color="#90EE90" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="fence" order="8-">
+ <polyline color="#808080" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="wall" order="8-">
+ <polyline color="#808080" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="retaining_wall" order="8-">
+ <polyline color="#808080" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="city_wall" order="8-">
+ <polyline color="#CD5C5C" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ </layer>
+ <!-- "Barriers" -->
+ <layer name="Waterways">
+ <itemgra item_types="water_line" order="0-">
+ <polyline color="#82c8ea" width="2"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="0-">
+ <polyline color="#82c8ea" width="4"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="0-">
+ <polyline color="#82c8ea" width="3"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_stream" order="0-">
+ <polyline color="#82c8ea" width="2"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_drain" order="0-">
+ <polyline color="#82c8ea" width="1"/>
+ <text text_size="5"/>
+ </itemgra>
+ </layer>
+ <layer name="Borders">
+ <itemgra item_types="border_state" order="0-5">
+ <polyline color="#778899" width="3"/>
+ <polyline color="#ffefb7" dash="3,2,1,3" width="1"/>
+ </itemgra>
+ <itemgra item_types="border_country" order="0-5">
+ <polyline color="#778899" width="2"/>
+ <polyline color="#ffefb7" dash="3,2,1,3" width="1"/>
+ </itemgra>
+ <itemgra item_types="border_state" order="6-11">
+ <polyline color="#778899" width="3"/>
+ <polyline color="#ffefb7" dash="6,6,1,6" width="1"/>
+ </itemgra>
+ <itemgra item_types="border_country" order="6-11">
+ <polyline color="#778899" width="2"/>
+ <polyline color="#ffefb7" dash="6,6,1,6" width="1"/>
+ </itemgra>
+ <itemgra item_types="border_state" order="12-20">
+ <polyline color="#778899" width="3"/>
+ <polyline color="#ffefb7" dash="10,10,2,10" width="1"/>
+ </itemgra>
+ <itemgra item_types="border_country" order="12-20">
+ <polyline color="#778899" width="2"/>
+ <polyline color="#ffefb7" dash="10,10,2,10" width="1"/>
+ </itemgra>
+ </layer>
+ <layer name="Current Route">
+ <itemgra item_types="street_route" order="2">
+ <polyline color="#FF00FF" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="3-5">
+ <polyline color="#FF00FF" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="6">
+ <polyline color="#FF00FF" width="10"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="7-8">
+ <polyline color="#FF00FF" width="16"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="9-10">
+ <polyline color="#FF00FF" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="11">
+ <polyline color="#FF00FF" width="28"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="12">
+ <polyline color="#FF00FF" width="32"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="13">
+ <polyline color="#FF00FF" width="52"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="14">
+ <polyline color="#FF00FF" width="64"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="15">
+ <polyline color="#FF00FF" width="68"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="16">
+ <polyline color="#FF00FF" width="132"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="17">
+ <polyline color="#FF00FF" width="268"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="18">
+ <polyline color="#FF00FF" width="530"/>
+ </itemgra>
+ </layer>
+ <layer name="Ways and Paths">
+ <itemgra item_types="powerline" order="12-">
+ <polyline color="#778899" width="1"/>
+ <polyline color="#778899" dash="1,80" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_nopass" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_paved" order="8-">
+ <polyline color="#d2d2d2" width="5"/>
+ <polyline color="#fefefe" width="3"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled" order="9-">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#fefefe" width="2"/>
+ </itemgra>
+ <itemgra item_types="track_unpaved" order="10-">
+ <polyline color="#d2d2d2" width="3"/>
+ <polyline color="#fefefe" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_ground" order="11-">
+ <polyline color="#d2d2d2" width="3"/>
+ <polyline color="#fefefe" width="1" dash="6,6"/>
+ </itemgra>
+ <itemgra item_types="track_grass" order="12-">
+ <polyline color="#fefefe" width="2"/>
+ <polyline color="#ffefb7" width="1" dash="6,6"/>
+ </itemgra>
+ <itemgra item_types="bridleway" order="10-">
+ <polyline color="#8b4513" width="3"/>
+ <polyline color="#f4a460" width="1"/>
+ </itemgra>
+ <itemgra item_types="cycleway" order="10-">
+ <polyline color="#006400" width="4"/>
+ <polyline color="#3cb371" width="2"/>
+ </itemgra>
+ <itemgra item_types="footway" order="12-">
+ <polyline color="#8b4513" width="3"/>
+ <polyline color="#CD853F" width="1"/>
+ </itemgra>
+ <itemgra item_types="steps" order="12-">
+ <polyline color="#8b4513" width="3"/>
+ <polyline color="#F4A460" width="1" dash="6,4"/>
+ </itemgra>
+ <itemgra item_types="path" order="11-">
+ <polyline color="#8b4513" width="3"/>
+ <polyline color="#ffefb7" width="1" dash="2,4"/>
+ </itemgra>
+ <itemgra item_types="hiking" order="11-">
+ <polyline color="#8b4513" width="2"/>
+ <polyline color="#ffefb7" width="1" dash="4,4"/>
+ </itemgra>
+ <itemgra item_types="hiking_mountain" order="11-">
+ <polyline color="#8b4513" width="2"/>
+ <polyline color="#ffefb7" width="1" dash="6,4"/>
+ </itemgra>
+ <itemgra item_types="hiking_mountain_demanding" order="13-">
+ <polyline color="#8b4513" width="2"/>
+ <polyline color="#ffefb7" width="1" dash="8,4"/>
+ </itemgra>
+ <itemgra item_types="hiking_alpine" order="13-">
+ <polyline color="#8b4513" width="1" dash="10,4"/>
+ </itemgra>
+ <itemgra item_types="hiking_alpine_demanding" order="14-">
+ <polyline color="#8b4513" width="1" dash="12,4"/>
+ </itemgra>
+ <itemgra item_types="hiking_alpine_difficult" order="14-">
+ <polyline color="#8b4513" width="1" dash="14,4"/>
+ </itemgra>
+ </layer>
+ <layer name="Streets">
+ <itemgra item_types="poly_pedestrian,poly_plaza" order="0-">
+ <polygon color="#d2d2d2"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="10">
+ <polyline color="#d2d2d2" width="3"/>
+ <polyline color="#dddddd" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="11">
+ <polyline color="#d2d2d2" width="5"/>
+ <polyline color="#dddddd" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="12">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#dddddd" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="13">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#dddddd" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="14">
+ <polyline color="#d2d2d2" width="13"/>
+ <polyline color="#dddddd" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="15">
+ <polyline color="#d2d2d2" width="18"/>
+ <polyline color="#dddddd" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="16">
+ <polyline color="#d2d2d2" width="21"/>
+ <polyline color="#dddddd" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="17">
+ <polyline color="#d2d2d2" width="25"/>
+ <polyline color="#dddddd" width="21"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="18">
+ <polyline color="#d2d2d2" width="40"/>
+ <polyline color="#dddddd" width="34"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="9">
+ <polyline color="#d2d2d2" width="2"/>
+ <polyline color="#fefefe" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="10">
+ <polyline color="#d2d2d2" width="3"/>
+ <polyline color="#fefefe" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="11">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#fefefe" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="12">
+ <polyline color="#d2d2d2" width="5"/>
+ <polyline color="#fefefe" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="13">
+ <polyline color="#d2d2d2" width="6"/>
+ <polyline color="#fefefe" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="14">
+ <polyline color="#d2d2d2" width="7"/>
+ <polyline color="#fefefe" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="15">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#fefefe" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="16">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#fefefe" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="17">
+ <polyline color="#d2d2d2" width="10"/>
+ <polyline color="#fefefe" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="18">
+ <polyline color="#d2d2d2" width="11"/>
+ <polyline color="#fefefe" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="12">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#fefefe" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="13">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#fefefe" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="14">
+ <polyline color="#d2d2d2" width="5"/>
+ <polyline color="#fefefe" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="15">
+ <polyline color="#d2d2d2" width="6"/>
+ <polyline color="#fefefe" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="16">
+ <polyline color="#d2d2d2" width="7"/>
+ <polyline color="#fefefe" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="17">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#fefefe" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="18">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#fefefe" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="8-10">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#ffffff" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="11">
+ <polyline color="#d2d2d2" width="6"/>
+ <polyline color="#ffffff" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="12">
+ <polyline color="#d2d2d2" width="10"/>
+ <polyline color="#ffffff" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="13">
+ <polyline color="#d2d2d2" width="12"/>
+ <polyline color="#ffffff" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="14">
+ <polyline color="#d2d2d2" width="15"/>
+ <polyline color="#ffffff" width="13"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="15">
+ <polyline color="#d2d2d2" width="17"/>
+ <polyline color="#ffffff" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="16">
+ <polyline color="#d2d2d2" width="33"/>
+ <polyline color="#ffffff" width="26"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="17">
+ <polyline color="#d2d2d2" width="69"/>
+ <polyline color="#ffffff" width="61"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="18">
+ <polyline color="#d2d2d2" width="132"/>
+ <polyline color="#ffffff" width="126"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="7-8">
+ <polyline color="#c0c0c0" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="9">
+ <polyline color="#c0c0c0" width="3"/>
+ <polyline color="#ffff00" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="10">
+ <polyline color="#c0c0c0" width="4"/>
+ <polyline color="#ffff00" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="11">
+ <polyline color="#c0c0c0" width="5"/>
+ <polyline color="#ffff00" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="12">
+ <polyline color="#c0c0c0" width="7"/>
+ <polyline color="#ffff00" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="13">
+ <polyline color="#c0c0c0" width="11"/>
+ <polyline color="#ffff00" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="14">
+ <polyline color="#c0c0c0" width="14"/>
+ <polyline color="#ffff00" width="11"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="15">
+ <polyline color="#c0c0c0" width="19"/>
+ <polyline color="#ffff00" width="15"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="16">
+ <polyline color="#c0c0c0" width="30"/>
+ <polyline color="#ffff00" width="26"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="17">
+ <polyline color="#c0c0c0" width="63"/>
+ <polyline color="#ffff00" width="57"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="18">
+ <polyline color="#c0c0c0" width="100"/>
+ <polyline color="#ffff00" width="90"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="7-8">
+ <polyline color="#a0a0a0" width="3"/>
+ <polyline color="#ffff00" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="9">
+ <polyline color="#a0a0a0" width="5"/>
+ <polyline color="#ffff00" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="10">
+ <polyline color="#a0a0a0" width="8"/>
+ <polyline color="#ffff00" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="11">
+ <polyline color="#a0a0a0" width="9"/>
+ <polyline color="#ffff00" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="12">
+ <polyline color="#a0a0a0" width="13"/>
+ <polyline color="#ffff00" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="13">
+ <polyline color="#a0a0a0" width="18"/>
+ <polyline color="#ffff00" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="14">
+ <polyline color="#a0a0a0" width="21"/>
+ <polyline color="#ffff00" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="15">
+ <polyline color="#a0a0a0" width="25"/>
+ <polyline color="#ffff00" width="21"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="16">
+ <polyline color="#a0a0a0" width="40"/>
+ <polyline color="#ffff00" width="34"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="17">
+ <polyline color="#a0a0a0" width="79"/>
+ <polyline color="#ffff00" width="73"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="18">
+ <polyline color="#a0a0a0" width="156"/>
+ <polyline color="#ffff00" width="150"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="2-6">
+ <polyline color="#404040" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="7-8">
+ <polyline color="#404040" width="3"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="9">
+ <polyline color="#000000" width="5"/>
+ <polyline color="#ff0000" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="10">
+ <polyline color="#000000" width="6"/>
+ <polyline color="#ff0000" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11">
+ <polyline color="#000000" width="9"/>
+ <polyline color="#ff0000" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="12">
+ <polyline color="#000000" width="13"/>
+ <polyline color="#ff0000" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="13">
+ <polyline color="#000000" width="18"/>
+ <polyline color="#ff0000" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="14">
+ <polyline color="#000000" width="21"/>
+ <polyline color="#ff0000" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="15">
+ <polyline color="#000000" width="24"/>
+ <polyline color="#ff0000" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="16">
+ <polyline color="#000000" width="39"/>
+ <polyline color="#ff0000" width="33"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="17">
+ <polyline color="#000000" width="78"/>
+ <polyline color="#ff0000" width="72"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="18">
+ <polyline color="#000000" width="156"/>
+ <polyline color="#ff0000" width="150"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="2">
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="3-5">
+ <polyline color="#ff0000" width="3"/>
+ <polyline color="#ffff00" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="6">
+ <polyline color="#ff0000" width="4"/>
+ <polyline color="#ffff00" width="2"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="7-8">
+ <polyline color="#ff0000" width="7"/>
+ <polyline color="#ffff00" width="5"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="9-10">
+ <polyline color="#ff0000" width="9"/>
+ <polyline color="#ffff00" width="5"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="11">
+ <polyline color="#ff0000" width="13"/>
+ <polyline color="#ffff00" width="9"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="12">
+ <polyline color="#ff0000" width="15"/>
+ <polyline color="#ffff00" width="10"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="13">
+ <polyline color="#ff0000" width="25"/>
+ <polyline color="#ffff00" width="17"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="14">
+ <polyline color="#ff0000" width="31"/>
+ <polyline color="#ffff00" width="24"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="15">
+ <polyline color="#ff0000" width="33"/>
+ <polyline color="#ffff00" width="27"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="16">
+ <polyline color="#ff0000" width="65"/>
+ <polyline color="#ffff00" width="59"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="17">
+ <polyline color="#ff0000" width="133"/>
+ <polyline color="#ffff00" width="127"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="18">
+ <polyline color="#ff0000" width="264"/>
+ <polyline color="#ffff00" width="258"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ </layer>
+ <layer name="Aerialways">
+ <itemgra item_types="aeroway_taxiway" order="10">
+ <polyline color="#989994" width="4"/>
+ <polyline color="#d3dbbc" width="2"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="11">
+ <polyline color="#989994" width="6"/>
+ <polyline color="#d3dbbc" width="4"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="12">
+ <polyline color="#989994" width="10"/>
+ <polyline color="#d3dbbc" width="8"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="13">
+ <polyline color="#989994" width="12"/>
+ <polyline color="#d3dbbc" width="9"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="14">
+ <polyline color="#989994" width="15"/>
+ <polyline color="#d3dbbc" width="13"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="15">
+ <polyline color="#989994" width="17"/>
+ <polyline color="#d3dbbc" width="14"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="16">
+ <polyline color="#989994" width="33"/>
+ <polyline color="#d3dbbc" width="26"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="17">
+ <polyline color="#989994" width="69"/>
+ <polyline color="#d3dbbc" width="61"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="18">
+ <polyline color="#989994" width="132"/>
+ <polyline color="#d3dbbc" width="126"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="2-6">
+ <polyline color="#404040" width="1"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="7-8">
+ <polyline color="#404040" width="3"/>
+ <polyline color="#d3dbbc" width="1"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="9">
+ <polyline color="#6b6f5f" width="5"/>
+ <polyline color="#d3dbbc" width="3"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="10">
+ <polyline color="#6b6f5f" width="6"/>
+ <polyline color="#d3dbbc" width="4"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="11">
+ <polyline color="#6b6f5f" width="9"/>
+ <polyline color="#d3dbbc" width="7"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="12">
+ <polyline color="#6b6f5f" width="13"/>
+ <polyline color="#d3dbbc" width="9"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="13">
+ <polyline color="#6b6f5f" width="18"/>
+ <polyline color="#d3dbbc" width="14"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="14">
+ <polyline color="#6b6f5f" width="21"/>
+ <polyline color="#d3dbbc" width="17"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="15">
+ <polyline color="#6b6f5f" width="24"/>
+ <polyline color="#d3dbbc" width="20"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="16">
+ <polyline color="#6b6f5f" width="39"/>
+ <polyline color="#d3dbbc" width="33"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="17">
+ <polyline color="#6b6f5f" width="78"/>
+ <polyline color="#d3dbbc" width="72"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="18">
+ <polyline color="#6b6f5f" width="156"/>
+ <polyline color="#d3dbbc" width="150"/>
+ </itemgra>
+ </layer>
+ <layer name="Railways">
+ <itemgra item_types="rail" order="6-9">
+ <polyline color="#696969" width="4"/>
+ <polyline color="#FFFFFF" dash="2,5" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail_narrow_gauge" order="6-9">
+ <polyline color="#696969" width="4"/>
+ <polyline color="#FFFFFF" dash="2,5" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail" order="10-13">
+ <polyline color="#696969" width="6"/>
+ <polyline color="#FFFFFF" dash="3,8" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail_narrow_gauge" order="10-13">
+ <polyline color="#696969" width="6"/>
+ <polyline color="#FFFFFF" dash="3,8" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail" order="14-18">
+ <polyline color="#696969" width="8"/>
+ <polyline color="#FFFFFF" dash="4,12" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail_narrow_gauge" order="14-18">
+ <polyline color="#696969" width="8"/>
+ <polyline color="#FFFFFF" dash="4,12" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail_light" order="10-13">
+ <polyline color="#696969" width="4"/>
+ <polyline color="#FFFFFF" dash="2,5" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail_light" order="14-18">
+ <polyline color="#696969" width="6"/>
+ <polyline color="#FFFFFF" dash="4,8" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail_subway" order="8-">
+ <polyline color="#696969" width="2"/>
+ <polyline color="#FFFFFF" dash="5,5" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail_mono" order="10-">
+ <polyline color="#696969" width="2"/>
+ </itemgra>
+ <itemgra item_types="rail_tram,bus_guideway" order="10-">
+ <polyline color="#696969" width="2"/>
+ </itemgra>
+ <itemgra item_types="rail_preserved" order="10-">
+ <polyline color="#696969" width="1" dash="7"/>
+ </itemgra>
+ <itemgra item_types="rail_disused" order="12-">
+ <polyline color="#d3d3d3" width="1" dash="10"/>
+ </itemgra>
+ <itemgra item_types="rail_abandoned" order="12-">
+ <polyline color="#f5f5f5" width="1" dash="10"/>
+ </itemgra>
+ <itemgra item_types="lift_cable_car" order="10-">
+ <polyline color="#778899" width="5"/>
+ <polyline color="#ffefb7" dash="1,40" width="1"/>
+ </itemgra>
+ <itemgra item_types="lift_chair" order="10-">
+ <polyline color="#778899" width="5"/>
+ <polyline color="#ffefb7" dash="1,40" width="1"/>
+ </itemgra>
+ <itemgra item_types="lift_drag" order="10-">
+ <polyline color="#778899" width="5"/>
+ <polyline color="#ffefb7" dash="1,40" width="1"/>
+ </itemgra>
+ <itemgra item_types="ferry" order="5-">
+ <polyline color="#000000" width="3"/>
+ <polyline color="#ffefb7" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="track" order="3-">
+ <polyline color="#3f3f3f" width="1"/>
+ </itemgra>
+ </layer>
+ <layer name="Internal">
+ <itemgra item_types="track" order="7-">
+ <polyline color="#3f3f3f" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_tracked" order="7-">
+ <polyline color="#3f3fff" width="3"/>
+ </itemgra>
+ <itemgra item_types="rg_segment" order="12-">
+ <polyline color="#FF089C" width="1"/>
+ <arrows color="#FF089C" width="1"/>
+ </itemgra>
+ <itemgra item_types="rg_point" order="12-">
+ <circle color="#FF089C" radius="10" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="nav_left_1" order="0-">
+ <icon src="nav_left_1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_left_2" order="0-">
+ <icon src="nav_left_2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_left_3" order="0-">
+ <icon src="nav_left_3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_1" order="0-">
+ <icon src="nav_right_1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_2" order="0-">
+ <icon src="nav_right_2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_3" order="0-">
+ <icon src="nav_right_3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_straight" order="0-">
+ <icon src="nav_straight_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_turnaround_left" order="0-">
+ <icon src="nav_turnaround_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_turnaround_right" order="0-">
+ <icon src="nav_turnaround_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l1" order="0-">
+ <icon src="nav_roundabout_l1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r1" order="0-">
+ <icon src="nav_roundabout_r1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l2" order="0-">
+ <icon src="nav_roundabout_l2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r2" order="0-">
+ <icon src="nav_roundabout_r2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l3" order="0-">
+ <icon src="nav_roundabout_l3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r3" order="0-">
+ <icon src="nav_roundabout_r3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l4" order="0-">
+ <icon src="nav_roundabout_l4_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r4" order="0-">
+ <icon src="nav_roundabout_r4_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l5" order="0-">
+ <icon src="nav_roundabout_l5_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r5" order="0-">
+ <icon src="nav_roundabout_r5_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l6" order="0-">
+ <icon src="nav_roundabout_l6_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r6" order="0-">
+ <icon src="nav_roundabout_r6_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l7" order="0-">
+ <icon src="nav_roundabout_l7_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r7" order="0-">
+ <icon src="nav_roundabout_r7_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l8" order="0-">
+ <icon src="nav_roundabout_l8_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r8" order="0-">
+ <icon src="nav_roundabout_r8_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_keep_left" order="0-">
+ <icon src="nav_keep_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_merge_left" order="0-">
+ <icon src="nav_merge_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_keep_right" order="0-">
+ <icon src="nav_keep_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_merge_right" order="0-">
+ <icon src="nav_merge_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_exit_left" order="0-">
+ <icon src="nav_exit_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_exit_right" order="0-">
+ <icon src="nav_exit_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="route_end" order="0-">
+ <icon src="nav_destination_bk.svg" w="32" h="32" x="4" y="30"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="2">
+ <circle color="#000000" radius="4" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="3-5">
+ <circle color="#000000" radius="8" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="6">
+ <circle color="#000000" radius="10" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="7-8">
+ <circle color="#000000" radius="16" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="9-10">
+ <circle color="#000000" radius="20" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="11">
+ <circle color="#000000" radius="28" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="12">
+ <circle color="#000000" radius="32" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="13">
+ <circle color="#000000" radius="52" width="4" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="14">
+ <circle color="#000000" radius="64" width="4" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="15">
+ <circle color="#000000" radius="68" width="6" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="16">
+ <circle color="#000000" radius="132" width="8" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="17">
+ <circle color="#000000" radius="268" width="8" text_size="48"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="18">
+ <circle color="#000000" radius="530" width="8" text_size="48"/>
+ </itemgra>
+ <itemgra item_types="nav_none" order="0-">
+ <icon src="unknown.svg"/>
+ </itemgra>
+ <itemgra item_types="announcement" order="7-">
+ <icon src="gui_sound_32_32.png"/>
+ <circle color="#FF089C" radius="10" text_size="7"/>
+ </itemgra>
+ </layer>
+ <layer name="Street Labels">
+ <itemgra item_types="highway_exit_label" order="10-">
+ <circle color="#000000" radius="3" text_size="12"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street" order="10-18">
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp" order="11-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land" order="12-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="track,track_paved,track_gravelled,track_unpaved,track_ground,track_grass" order="12-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="bridleway,cycleway,footway,steps,path" order="12-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="hiking,hiking_mountain,hiking_mountain_demanding,hiking_alpine,hiking_alpine_demanding,hiking_alpine_difficult" order="12-18">
+ <text text_size="9"/>
+ </itemgra>
+ </layer>
+ <layer name="Unknown Elements">
+ <!-- This entry shows all unknown linear elements as blue lines -->
+ <!--
+ <itemgra item_types="street_unkn" order="0-">
+ <polyline color="#8080ff" width="3"/>
+ </itemgra>
+ -->
+ </layer>
+ <layer name="Place Labels">
+ <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="12-">
+ <circle color="#000000" radius="3" text_size="12"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3" order="9-">
+ <circle color="#000000" radius="3" text_size="12"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e3,town_label_2e3,town_label_5e3,place_label" order="9-">
+ <circle color="#000000" radius="3" text_size="12"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4" order="7-">
+ <circle color="#000000" radius="3" text_size="12"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e4,town_label_2e4,town_label_5e4" order="7-">
+ <circle color="#000000" radius="3" text_size="12"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5" order="5-">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="5-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6" order="3-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6" order="3-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e7,district_label_1e7" order="1-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ </layer>
+ <xi:include xpointer="xpointer(/config/navit/layout[@name='Car']/layer[@name='POI Symbols'])"/>
+ <!--<xi:include xpointer="xpointer(/config/navit/layout[@name='Car']/layer[@name='POI Labels'])"/> -->
+ <!-- "Bicycle POIs" -->
+ <layer name="Bicycle POI Symbols">
+ <itemgra item_types="poi_bicycle_parking" order="12-">
+ <icon src="bicycle_parking.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bicycle_rental" order="11-">
+ <icon src="bicycle_rental.png"/>
+ </itemgra>
+ </layer>
+ <layer name="Bicycle POI Labels">
+ <itemgra item_types="poi_bicycle_parking,poi_bicycle_rental" order="14-">
+ <circle color="#606060" radius="0" width="0" text_size="10"/>
+ </itemgra>
+ </layer>
+ <layer name="Found items" ref="Found items"/>
+</layout>
diff --git a/navit/navit_layout_car_android_shipped.xml b/navit/navit_layout_car_android_shipped.xml
new file mode 100644
index 000000000..046d52d37
--- /dev/null
+++ b/navit/navit_layout_car_android_shipped.xml
@@ -0,0 +1,1338 @@
+<?xml version="1.0"?>
+<layout xmlns:xi="http://www.w3.org/2001/XInclude" name="Car-Android" color="#fef9ee" font="Liberation Sans">
+ <cursor w="57" h="57">
+ <itemgra speed_range="-2">
+ <polyline color="#00BC00" radius="0" width="4">
+ <coord x="0" y="0"/>
+ </polyline>
+ <circle color="#008500" radius="9" width="3">
+ <coord x="0" y="0"/>
+ </circle>
+ <circle color="#00BC00" radius="13" width="3">
+ <coord x="0" y="0"/>
+ </circle>
+ <circle color="#008500" radius="18" width="3">
+ <coord x="0" y="0"/>
+ </circle>
+ </itemgra>
+ <itemgra speed_range="3-">
+ <polygon color="#00000066">
+ <coord x="-21" y="-27"/>
+ <coord x="0" y="12"/>
+ <coord x="21" y="-27"/>
+ <coord x="0" y="-12"/>
+ <coord x="-21" y="-27"/>
+ </polygon>
+ <polygon color="#008500">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="-21" y="-18"/>
+ </polygon>
+ <polygon color="#00BC00">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="21" y="-18"/>
+ </polygon>
+ <polyline color="#008500" width="1">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="-21" y="-18"/>
+ </polyline>
+ <polyline color="#008500" width="1">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="21" y="-18"/>
+ </polyline>
+ </itemgra>
+ </cursor>
+ <layer name="polygons">
+ <itemgra item_types="poly_wood" order="13-">
+ <polygon color="#8ec78d"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_water_tiled">
+ <polygon color="#82c8ea"/>
+ </itemgra>
+ <itemgra item_types="poly_water" order="10-">
+ <polygon color="#82c8ea"/>
+ <polyline color="#5096b8"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_flats,poly_scrub,poly_military_zone,poly_marine,plantation,tundra" order="14-">
+ <polygon color="#a0a0a0"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_park" order="14-">
+ <polygon color="#7cc334"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="14">
+ <polyline color="#d2d2d2" width="13"/>
+ <polyline color="#dddddd" width="9"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="15">
+ <polyline color="#d2d2d2" width="18"/>
+ <polyline color="#dddddd" width="14"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="16">
+ <polyline color="#d2d2d2" width="21"/>
+ <polyline color="#dddddd" width="17"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="17">
+ <polyline color="#d2d2d2" width="25"/>
+ <polyline color="#dddddd" width="21"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="18">
+ <polyline color="#d2d2d2" width="40"/>
+ <polyline color="#dddddd" width="34"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_airport" order="5-">
+ <polygon color="#a0a0a0"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="6-7">
+ <polyline color="#82c8ea" width="3"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="8-9">
+ <polyline color="#82c8ea" width="4"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="10-">
+ <polyline color="#82c8ea" width="4"/>
+ <text text_size="10"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="13-">
+ <polyline color="#82c8ea" width="3"/>
+ <text text_size="10"/>
+ </itemgra>
+ <itemgra item_types="water_stream" order="13-">
+ <polyline color="#82c8ea" width="2"/>
+ <text text_size="7"/>
+ </itemgra>
+ <itemgra item_types="water_drain" order="14-">
+ <polyline color="#82c8ea" width="1"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_apron" order="13-">
+ <polygon color="#d0d0d0"/>
+ </itemgra>
+ <itemgra item_types="poly_terminal" order="14-">
+ <polygon color="#e3c6a6"/>
+ </itemgra>
+ <itemgra item_types="poly_car_parking" order="15-">
+ <polygon color="#e7cf87"/>
+ </itemgra>
+ <itemgra item_types="poly_building" order="14-">
+ <polygon color="#b6a6a6"/>
+ </itemgra>
+ <itemgra item_types="rail" order="13-">
+ <polyline color="#696969" width="3"/>
+ <polyline color="#ffffff" width="1" dash="5,5"/>
+ </itemgra>
+ <itemgra item_types="ferry" order="14-">
+ <polyline color="#000000" width="1" dash="10"/>
+ </itemgra>
+ <itemgra item_types="border_country" order="0-">
+ <polyline color="#808080" width="1" dash="10,5,2,5"/>
+ </itemgra>
+ <itemgra item_types="border_state" order="0-">
+ <polyline color="#808080" width="4"/>
+ </itemgra>
+ </layer>
+ <layer name="streets">
+ <itemgra item_types="street_route" order="2">
+ <polyline color="#69e068" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="3-5">
+ <polyline color="#69e068" width="10"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="6">
+ <polyline color="#69e068" width="12"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="7-8">
+ <polyline color="#69e068" width="16"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="9-10">
+ <polyline color="#69e068" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="11">
+ <polyline color="#69e068" width="28"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="12">
+ <polyline color="#69e068" width="32"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="13">
+ <polyline color="#69e068" width="52"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="14">
+ <polyline color="#69e068" width="64"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="15">
+ <polyline color="#69e068" width="68"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="16">
+ <polyline color="#69e068" width="132"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="17">
+ <polyline color="#69e068" width="268"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="18">
+ <polyline color="#69e068" width="530"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="2">
+ <polyline color="#ba00b8" width="4"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="3-5">
+ <polyline color="#ba00b8" width="8"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="6">
+ <polyline color="#ba00b8" width="10"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="7-8">
+ <polyline color="#ba00b8" width="16"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="9-10">
+ <polyline color="#ba00b8" width="20"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="11">
+ <polyline color="#ba00b8" width="28"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="12">
+ <polyline color="#ba00b8" width="32"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="13">
+ <polyline color="#ba00b8" width="52"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="14">
+ <polyline color="#ba00b8" width="64"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="15">
+ <polyline color="#ba00b8" width="68"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="16">
+ <polyline color="#ba00b8" width="132"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="17">
+ <polyline color="#ba00b8" width="268"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="18">
+ <polyline color="#ba00b8" width="530"/>
+ </itemgra>
+ <itemgra item_types="forest_way_1" order="14-">
+ <polyline color="#0070c0" width="6"/>
+ </itemgra>
+ <itemgra item_types="forest_way_2" order="14-">
+ <polyline color="#ff0000" width="3"/>
+ </itemgra>
+ <itemgra item_types="forest_way_3" order="14-">
+ <polyline color="#ff0000" width="1" dash="2,4"/>
+ </itemgra>
+ <itemgra item_types="forest_way_4" order="14-">
+ <polyline color="#119a2e" width="1" dash="4,10"/>
+ </itemgra>
+ <itemgra item_types="street_nopass" order="14-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_paved" order="14-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled" order="14">
+ <polyline color="#ffffff" width="4"/>
+ <polyline color="#800000" width="1" dash="4,8"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled" order="15-16">
+ <polyline color="#ffffff" width="5"/>
+ <polyline color="#800000" width="1" dash="5,10"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled" order="17-">
+ <polyline color="#ffffff" width="7"/>
+ <polyline color="#800000" width="1" dash="7,15"/>
+ </itemgra>
+ <itemgra item_types="track_unpaved" order="14-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="bridleway" order="14-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="cycleway" order="14-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="lift_cable_car" order="15-">
+ <polyline color="#696969" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="lift_chair" order="15-">
+ <polyline color="#696969" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="lift_drag" order="15-">
+ <polyline color="#696969" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="footway" order="15-16">
+ <polyline color="#ffffff" width="5"/>
+ <polyline color="#ff0000" width="1" dash="5,10"/>
+ </itemgra>
+ <itemgra item_types="footway" order="17-">
+ <polyline color="#ffffff" width="7"/>
+ <polyline color="#ff0000" width="1" dash="7,15"/>
+ </itemgra>
+ <itemgra item_types="steps" order="15-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="14">
+ <polyline color="#d2d2d2" width="13"/>
+ <polyline color="#dddddd" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="15">
+ <polyline color="#d2d2d2" width="18"/>
+ <polyline color="#dddddd" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="16">
+ <polyline color="#d2d2d2" width="21"/>
+ <polyline color="#dddddd" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="17">
+ <polyline color="#d2d2d2" width="25"/>
+ <polyline color="#dddddd" width="21"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="18">
+ <polyline color="#d2d2d2" width="40"/>
+ <polyline color="#dddddd" width="34"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="14">
+ <polyline color="#d2d2d2" width="7"/>
+ <polyline color="#fefefe" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="15">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#fefefe" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="16">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#fefefe" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="17">
+ <polyline color="#d2d2d2" width="10"/>
+ <polyline color="#fefefe" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="18">
+ <polyline color="#d2d2d2" width="11"/>
+ <polyline color="#fefefe" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="15">
+ <polyline color="#d2d2d2" width="6"/>
+ <polyline color="#fefefe" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="16">
+ <polyline color="#d2d2d2" width="7"/>
+ <polyline color="#fefefe" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="17">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#fefefe" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="18">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#fefefe" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="12">
+ <polyline color="#d2d2d2" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="13-14">
+ <polyline color="#d2d2d2" width="17"/>
+ <polyline color="#ffffff" width="13"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="15">
+ <polyline color="#d2d2d2" width="18"/>
+ <polyline color="#ffffff" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="16">
+ <polyline color="#d2d2d2" width="30"/>
+ <polyline color="#ffffff" width="26"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="17">
+ <polyline color="#d2d2d2" width="67"/>
+ <polyline color="#ffffff" width="61"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="18">
+ <polyline color="#d2d2d2" width="132"/>
+ <polyline color="#ffffff" width="126"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="11-12">
+ <polyline color="#c0c0c0" width="9"/>
+ <polyline color="#fefc8c" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="13-14">
+ <polyline color="#c0c0c0" width="13"/>
+ <polyline color="#fefc8c" width="11"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="15">
+ <polyline color="#c0c0c0" width="19"/>
+ <polyline color="#fefc8c" width="15"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="16">
+ <polyline color="#c0c0c0" width="30"/>
+ <polyline color="#fefc8c" width="26"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="17">
+ <polyline color="#c0c0c0" width="63"/>
+ <polyline color="#fefc8c" width="57"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="18">
+ <polyline color="#c0c0c0" width="100"/>
+ <polyline color="#fefc8c" width="90"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="11-12">
+ <polyline color="#a0a0a0" width="9"/>
+ <polyline color="#fefc8c" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="13-14">
+ <polyline color="#a0a0a0" width="21"/>
+ <polyline color="#fefc8c" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="15">
+ <polyline color="#a0a0a0" width="25"/>
+ <polyline color="#fefc8c" width="21"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="16">
+ <polyline color="#a0a0a0" width="40"/>
+ <polyline color="#fefc8c" width="34"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="17">
+ <polyline color="#a0a0a0" width="79"/>
+ <polyline color="#fefc8c" width="73"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="18">
+ <polyline color="#a0a0a0" width="156"/>
+ <polyline color="#fefc8c" width="150"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="2-6">
+ <polyline color="#f8dc79" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="7-8">
+ <polyline color="#f8dc79" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="9">
+ <polyline color="#f8dc79" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="10">
+ <polyline color="#f8dc79" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11">
+ <polyline color="#000000" width="9"/>
+ <polyline color="#f8dc79" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="12">
+ <polyline color="#000000" width="13"/>
+ <polyline color="#f8dc79" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="13">
+ <polyline color="#000000" width="18"/>
+ <polyline color="#f8dc79" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="14">
+ <polyline color="#000000" width="21"/>
+ <polyline color="#f8dc79" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="15">
+ <polyline color="#000000" width="24"/>
+ <polyline color="#f8dc79" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="16">
+ <polyline color="#000000" width="39"/>
+ <polyline color="#f8dc79" width="33"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="17">
+ <polyline color="#000000" width="78"/>
+ <polyline color="#f8dc79" width="72"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="18">
+ <polyline color="#000000" width="156"/>
+ <polyline color="#f8dc79" width="150"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="0-1">
+ <polyline color="#fc843b" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="2">
+ <polyline color="#fc843b" width="3"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="3-5">
+ <polyline color="#fc843b" width="6"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="6">
+ <polyline color="#fc843b" width="6"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="7-8">
+ <polyline color="#fc843b" width="6"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="9">
+ <polyline color="#fc843b" width="7"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="10">
+ <polyline color="#fc843b" width="9"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="11">
+ <polyline color="#a8aab3" width="13"/>
+ <polyline color="#fc843b" width="9"/>
+ <polyline color="#a8aab3" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="12">
+ <polyline color="#a8aab3" width="15"/>
+ <polyline color="#fc843b" width="10"/>
+ <polyline color="#a8aab3" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="13">
+ <polyline color="#a8aab3" width="25"/>
+ <polyline color="#fc843b" width="17"/>
+ <polyline color="#a8aab3" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="14">
+ <polyline color="#a8aab3" width="31"/>
+ <polyline color="#fc843b" width="24"/>
+ <polyline color="#a8aab3" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="15">
+ <polyline color="#a8aab3" width="33"/>
+ <polyline color="#fc843b" width="27"/>
+ <polyline color="#a8aab3" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="16">
+ <polyline color="#a8aab3" width="65"/>
+ <polyline color="#fc843b" width="59"/>
+ <polyline color="#a8aab3" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="17">
+ <polyline color="#a8aab3" width="133"/>
+ <polyline color="#fc843b" width="127"/>
+ <polyline color="#a8aab3" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="18">
+ <polyline color="#a8aab3" width="264"/>
+ <polyline color="#fc843b" width="258"/>
+ <polyline color="#a8aab3" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_exit_label" order="13-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street" order="13-18">
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp" order="13-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land,footway" order="13-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="7-8">
+ <polyline color="#ff9000" width="8"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="9-10">
+ <polyline color="#ff9000" width="10"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="11">
+ <polyline color="#ff9000" width="14"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="12">
+ <polyline color="#ff9000" width="16"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="13">
+ <polyline color="#ff9000" width="26"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="14">
+ <polyline color="#ff9000" width="32"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="15">
+ <polyline color="#ff9000" width="34"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="16">
+ <polyline color="#ff9000" width="66"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="17">
+ <polyline color="#ff9000" width="134"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="18">
+ <polyline color="#ff9000" width="265"/>
+ </itemgra>
+ </layer>
+ <layer name="polylines">
+ <itemgra item_types="rail_tram" order="13-">
+ <polyline color="#606060" width="2"/>
+ </itemgra>
+ </layer>
+ <layer name="labels">
+ <itemgra item_types="house_number" order="15-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="13-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3" order="12-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e3,place_label" order="10-">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4" order="11-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_2e3" order="11-">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_5e3,town_label_1e4,town_label_2e4,town_label_5e4" order="11-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5" order="10-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_2e3" order="10">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6,district_label_1e7" order="9-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_5e3" order="9-10">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e4" order="8-9">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_2e4,town_label_5e4" order="7-8">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="5-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7" order="5-">
+ <circle color="#000000" radius="3" text_size="20"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="4">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7" order="4">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7" order="0-3">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ </layer>
+ <layer name="Internal">
+ <itemgra item_types="track" order="7-">
+ <polyline color="#3f3f3f" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_tracked" order="7-">
+ <polyline color="#3f3fff" width="3"/>
+ </itemgra>
+ <itemgra item_types="rg_segment" order="12-">
+ <polyline color="#FF089C" width="1"/>
+ <arrows color="#FF089C" width="1"/>
+ </itemgra>
+ <itemgra item_types="rg_point" order="12-">
+ <circle color="#FF089C" radius="10" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="nav_left_1" order="0-">
+ <icon src="nav_left_1_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_left_2" order="0-">
+ <icon src="nav_left_2_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_left_3" order="0-">
+ <icon src="nav_left_3_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_1" order="0-">
+ <icon src="nav_right_1_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_2" order="0-">
+ <icon src="nav_right_2_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_3" order="0-">
+ <icon src="nav_right_3_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_straight" order="0-">
+ <icon src="nav_straight_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_turnaround_left" order="0-">
+ <icon src="nav_turnaround_left_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_turnaround_right" order="0-">
+ <icon src="nav_turnaround_right_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l1" order="0-">
+ <icon src="nav_roundabout_l1_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r1" order="0-">
+ <icon src="nav_roundabout_r1_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l2" order="0-">
+ <icon src="nav_roundabout_l2_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r2" order="0-">
+ <icon src="nav_roundabout_r2_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l3" order="0-">
+ <icon src="nav_roundabout_l3_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r3" order="0-">
+ <icon src="nav_roundabout_r3_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l4" order="0-">
+ <icon src="nav_roundabout_l4_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r4" order="0-">
+ <icon src="nav_roundabout_r4_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l5" order="0-">
+ <icon src="nav_roundabout_l5_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r5" order="0-">
+ <icon src="nav_roundabout_r5_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l6" order="0-">
+ <icon src="nav_roundabout_l6_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r6" order="0-">
+ <icon src="nav_roundabout_r6_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l7" order="0-">
+ <icon src="nav_roundabout_l7_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r7" order="0-">
+ <icon src="nav_roundabout_r7_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l8" order="0-">
+ <icon src="nav_roundabout_l8_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r8" order="0-">
+ <icon src="nav_roundabout_r8_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_keep_left" order="0-">
+ <icon src="nav_keep_left_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_merge_left" order="0-">
+ <icon src="nav_merge_left_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_keep_right" order="0-">
+ <icon src="nav_keep_right_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_merge_right" order="0-">
+ <icon src="nav_merge_right_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_exit_left" order="0-">
+ <icon src="nav_exit_left_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_exit_right" order="0-">
+ <icon src="nav_exit_right_bk.png" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="route_end" order="0-">
+ <icon src="nav_destination_bk.png" w="32" h="32" x="4" y="30"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="2">
+ <circle color="#000000" radius="4" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="3-5">
+ <circle color="#000000" radius="8" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="6">
+ <circle color="#000000" radius="10" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="7-8">
+ <circle color="#000000" radius="16" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="9-10">
+ <circle color="#000000" radius="20" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="11">
+ <circle color="#000000" radius="28" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="12">
+ <circle color="#000000" radius="32" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="13">
+ <circle color="#000000" radius="52" width="4" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="14">
+ <circle color="#000000" radius="64" width="4" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="15">
+ <circle color="#000000" radius="68" width="6" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="16">
+ <circle color="#000000" radius="132" width="8" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="17">
+ <circle color="#000000" radius="268" width="8" text_size="48"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="18">
+ <circle color="#000000" radius="530" width="8" text_size="48"/>
+ </itemgra>
+ <itemgra item_types="nav_none" order="0-">
+ <icon src="unknown.png"/>
+ </itemgra>
+ <itemgra item_types="announcement" order="7-">
+ <icon src="gui_sound_32_32.png"/>
+ <circle color="#FF089C" radius="10" text_size="7"/>
+ </itemgra>
+ </layer>
+ <layer name="POI Symbols" active="1">
+ <itemgra item_types="mini_roundabout" order="12-">
+ <icon src="mini_roundabout.png"/>
+ </itemgra>
+ <itemgra item_types="turning_circle" order="12-">
+ <icon src="mini_roundabout.png"/>
+ </itemgra>
+ <itemgra item_types="poi_airport" order="6-">
+ <icon src="airport.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fuel" order="12-">
+ <icon src="fuel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bridge" order="12-">
+ <icon src="bridge.png"/>
+ </itemgra>
+ <itemgra item_types="highway_exit" order="12-">
+ <icon src="exit.png"/>
+ </itemgra>
+ <itemgra item_types="poi_auto_club" order="13-">
+ <icon src="auto_club.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bank" order="13-">
+ <icon src="bank.png"/>
+ </itemgra>
+ <itemgra item_types="poi_atm" order="13-">
+ <icon src="atm.png"/>
+ </itemgra>
+ <itemgra item_types="poi_danger_area" order="13-">
+ <icon src="danger_16_16.png"/>
+ </itemgra>
+ <itemgra item_types="poi_forbidden_area" order="13-">
+ <icon src="forbidden_area.png"/>
+ </itemgra>
+ <itemgra item_types="poi_tunnel" order="12-">
+ <icon src="tunnel.png"/>
+ </itemgra>
+ <itemgra item_types="traffic_signals" order="14-">
+ <icon src="traffic_signals.png"/>
+ </itemgra>
+ </layer>
+ <layer name="POI Labels" active="1">
+ <itemgra item_types="poi_airport,town_ghost,poi_hotel,poi_car_parking,poi_car_dealer_parts,poi_fuel,poi_shopping,poi_attraction,poi_cafe,poi_bar,poi_pub,highway_exit,poi_camp_rv,poi_museum_history,poi_hospital,poi_dining,poi_fastfood,poi_police,poi_autoservice,poi_bank,poi_atm,poi_bus_station,poi_bus_stop,poi_business_service,poi_car_rent,poi_church,poi_bahai,poi_buddhist,poi_hindu,poi_islamic,poi_jain,poi_jewish,poi_pagan,poi_pastafarian,poi_shinto,poi_sikh,poi_taoist,poi_cinema,poi_concert,poi_drinking_water,poi_emergency,poi_fair,poi_fish,poi_government_building,poi_hotspring,poi_information,poi_justice,poi_landmark,poi_library,poi_mall,poi_manmade_feature,poi_marine,poi_marine_type,poi_mark,poi_oil_field,poi_peak,poi_personal_service,poi_pharmacy,poi_post_office,poi_public_office,poi_rail_halt,poi_rail_station,poi_rail_tram_stop,poi_repair_service,poi_resort,poi_restaurant,poi_restricted_area,poi_sailing,poi_scenic_area,poi_school,poi_service,poi_shop_retail,poi_skiing,poi_social_service,poi_sport,poi_stadium,poi_swimming,poi_theater,poi_townhall,poi_trail,poi_truck_stop,poi_tunnel,poi_worship,poi_wrecker,poi_zoo,poi_biergarten,poi_castle,poi_ruins,poi_memorial,poi_monument,poi_shelter,poi_fountain,poi_viewpoint,vehicle" order="15-">
+ <circle color="#606060" radius="0" width="0" text_size="10"/>
+ </itemgra>
+ </layer>
+ <layer name="Android-POI-Icons-full" active="0">
+ <itemgra item_types="mini_roundabout" order="12-">
+ <icon src="mini_roundabout.png"/>
+ </itemgra>
+ <itemgra item_types="turning_circle" order="12-">
+ <icon src="mini_roundabout.png"/>
+ </itemgra>
+ <itemgra item_types="poi_airport" order="5-">
+ <icon src="airport.png"/>
+ </itemgra>
+ <itemgra item_types="town_ghost" order="10-">
+ <icon src="ghost_town.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hotel" order="12-">
+ <icon src="hotel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_parking" order="11-">
+ <icon src="parking.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_dealer_parts" order="12-">
+ <icon src="car_dealer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fuel" order="12-">
+ <icon src="fuel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shopping" order="12-">
+ <icon src="shopping.png"/>
+ </itemgra>
+ <itemgra item_types="poi_attraction" order="11-">
+ <icon src="attraction.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cafe" order="12-">
+ <icon src="cafe.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bar" order="12-">
+ <icon src="bar.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pub" order="12-">
+ <icon src="beer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bridge" order="12-">
+ <icon src="bridge.png"/>
+ </itemgra>
+ <itemgra item_types="highway_exit" order="11-">
+ <icon src="exit.png"/>
+ </itemgra>
+ <itemgra item_types="poi_camp_rv" order="12-">
+ <icon src="camping.png"/>
+ </itemgra>
+ <itemgra item_types="poi_museum_history" order="12-">
+ <icon src="museum.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hospital" order="12-">
+ <icon src="hospital.png"/>
+ </itemgra>
+ <itemgra item_types="poi_dining" order="12-">
+ <icon src="restaurant.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fastfood" order="12-">
+ <icon src="fastfood.png"/>
+ </itemgra>
+ <itemgra item_types="poi_police" order="12-">
+ <icon src="police.png"/>
+ </itemgra>
+ <itemgra item_types="poi_auto_club" order="12-">
+ <icon src="auto_club.png"/>
+ </itemgra>
+ <itemgra item_types="poi_autoservice" order="12-">
+ <icon src="car_dealer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bank" order="12-">
+ <icon src="bank.png"/>
+ </itemgra>
+ <itemgra item_types="poi_atm" order="12-">
+ <icon src="atm.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bay" order="12-">
+ <icon src="bay.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bend" order="12-">
+ <icon src="bend.png"/>
+ </itemgra>
+ <itemgra item_types="poi_boat_ramp" order="12-">
+ <icon src="boat_ramp.png"/>
+ </itemgra>
+ <itemgra item_types="poi_border_station" order="12-">
+ <icon src="border_station.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bowling" order="12-">
+ <icon src="bowling.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bus_station" order="11-">
+ <icon src="bus.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bus_stop" order="12-">
+ <icon src="bus_stop.png"/>
+ </itemgra>
+ <itemgra item_types="poi_business_service" order="12-">
+ <icon src="bussines_service.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_rent" order="12-">
+ <icon src="car_rent.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_sharing" order="11-">
+ <icon src="car_sharing.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_wash" order="12-">
+ <icon src="car_wash.png"/>
+ </itemgra>
+ <itemgra item_types="poi_casino" order="12-">
+ <icon src="casino.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cemetery" order="12-">
+ <icon src="cemetery.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_church" order="11-">
+ <icon src="church.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bahai" order="11-">
+ <icon src="bahai.png"/>
+ </itemgra>
+ <itemgra item_types="poi_buddhist" order="11-">
+ <icon src="buddhist.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hindu" order="11-">
+ <icon src="hindu.png"/>
+ </itemgra>
+ <itemgra item_types="poi_islamic" order="11-">
+ <icon src="islamic.png"/>
+ </itemgra>
+ <itemgra item_types="poi_jain" order="11-">
+ <icon src="jain.png"/>
+ </itemgra>
+ <itemgra item_types="poi_jewish" order="11-">
+ <icon src="jewish.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pagan" order="11-">
+ <icon src="pagan.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pastafarian" order="11-">
+ <icon src="pastafarian.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shinto" order="11-">
+ <icon src="shinto.png"/>
+ </itemgra>
+ <itemgra item_types="poi_sikh" order="11-">
+ <icon src="sikh.png"/>
+ </itemgra>
+ <itemgra item_types="poi_taoist" order="11-">
+ <icon src="taoist.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cinema" order="12-">
+ <icon src="cinema.png"/>
+ </itemgra>
+ <itemgra item_types="poi_communication" order="12-">
+ <icon src="communication.png"/>
+ </itemgra>
+ <itemgra item_types="poi_concert" order="12-">
+ <icon src="concert.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cove" order="12-">
+ <icon src="cove.png"/>
+ </itemgra>
+ <itemgra item_types="poi_crossing" order="12-">
+ <icon src="crossing.png"/>
+ </itemgra>
+ <itemgra item_types="poi_dam" order="12-">
+ <icon src="dam.png"/>
+ </itemgra>
+ <itemgra item_types="poi_danger_area" order="12-">
+ <icon src="danger_16_16.png"/>
+ </itemgra>
+ <itemgra item_types="poi_danger_sea_wreck" order="12-">
+ <icon src="dangerous.png"/>
+ </itemgra>
+ <itemgra item_types="poi_daymark" order="12-">
+ <icon src="daymark.png"/>
+ </itemgra>
+ <itemgra item_types="poi_diving" order="12-">
+ <icon src="diving.png"/>
+ </itemgra>
+ <itemgra item_types="poi_drinking_water" order="13-">
+ <icon src="drinking_water.png"/>
+ </itemgra>
+ <itemgra item_types="poi_emergency" order="12-">
+ <icon src="emergency.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fair" order="12-">
+ <icon src="fair.png"/>
+ </itemgra>
+ <itemgra item_types="poi_firebrigade" order="12-">
+ <icon src="firebrigade.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fish" order="9-">
+ <icon src="fish.png"/>
+ </itemgra>
+ <itemgra item_types="poi_forbidden_area" order="12-">
+ <icon src="forbidden_area.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_gps" order="15-">
+ <icon src="garmin.png"/>
+ </itemgra>
+ <itemgra item_types="poi_golf" order="12-">
+ <icon src="golf.png"/>
+ </itemgra>
+ <itemgra item_types="poi_government_building" order="12-">
+ <icon src="government_building.png"/>
+ </itemgra>
+ <itemgra item_types="poi_height" order="12-">
+ <icon src="height.png"/>
+ </itemgra>
+ <itemgra item_types="poi_heliport" order="8-">
+ <icon src="heliport.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hotspring" order="12-">
+ <icon src="hotspring.png"/>
+ </itemgra>
+ <itemgra item_types="poi_icesport" order="12-">
+ <icon src="icesport.png"/>
+ </itemgra>
+ <itemgra item_types="poi_information" order="12-">
+ <icon src="information.png"/>
+ </itemgra>
+ <itemgra item_types="poi_justice" order="12-">
+ <icon src="justice.png"/>
+ </itemgra>
+ <itemgra item_types="poi_landmark" order="11-">
+ <icon src="landmark.png"/>
+ </itemgra>
+ <itemgra item_types="poi_levee" order="12-">
+ <icon src="levee.png"/>
+ </itemgra>
+ <itemgra item_types="poi_level_crossing" order="11-">
+ <icon src="level_crossing.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_library" order="12-">
+ <icon src="library.png"/>
+ </itemgra>
+ <itemgra item_types="poi_locale" order="12-">
+ <icon src="locale.png"/>
+ </itemgra>
+ <itemgra item_types="poi_loudspeaker" order="12-">
+ <icon src="loudspeaker.png"/>
+ </itemgra>
+ <itemgra item_types="poi_mall" order="12-">
+ <icon src="mall.png"/>
+ </itemgra>
+ <itemgra item_types="poi_manmade_feature" order="12-">
+ <icon src="manmade_feature.png"/>
+ </itemgra>
+ <itemgra item_types="poi_marine" order="12-">
+ <icon src="marine.png"/>
+ </itemgra>
+ <itemgra item_types="poi_marine_type" order="12-">
+ <icon src="marine_type.png"/>
+ </itemgra>
+ <itemgra item_types="poi_mark" order="12-">
+ <icon src="mark.png"/>
+ </itemgra>
+ <itemgra item_types="poi_military" order="11-">
+ <icon src="military.png"/>
+ </itemgra>
+ <itemgra item_types="poi_mine" order="12-">
+ <icon src="mine.png"/>
+ </itemgra>
+ <itemgra item_types="poi_nondangerous" order="12-">
+ <icon src="nondangerous.png"/>
+ </itemgra>
+ <itemgra item_types="poi_oil_field" order="12-">
+ <icon src="oil_field.png"/>
+ </itemgra>
+ <itemgra item_types="poi_peak" order="7-">
+ <icon src="peak.png"/>
+ </itemgra>
+ <itemgra item_types="poi_personal_service" order="12-">
+ <icon src="personal_service.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pharmacy" order="12-">
+ <icon src="pharmacy.png"/>
+ </itemgra>
+ <itemgra item_types="poi_post_office,poi_post_box" order="13-">
+ <icon src="post.png"/>
+ </itemgra>
+ <itemgra item_types="poi_public_office" order="12-">
+ <icon src="public_office.png"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_halt" order="11-">
+ <circle color="#ff0000" radius="3" width="3"/>
+ <circle color="#000000" radius="5" width="2" text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_station" order="9-">
+ <circle color="#ff0000" radius="3" width="3"/>
+ <circle color="#000000" radius="6" width="2" text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_tram_stop" order="10-11">
+ <circle color="#ff0000" radius="2" width="2"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_tram_stop" order="12-">
+ <circle color="#ff0000" radius="3" width="3"/>
+ <circle color="#606060" radius="5" width="2" text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poi_repair_service" order="12-">
+ <icon src="repair_service.png"/>
+ </itemgra>
+ <itemgra item_types="poi_resort" order="12-">
+ <icon src="resort.png"/>
+ </itemgra>
+ <itemgra item_types="poi_restaurant" order="12-">
+ <icon src="restaurant.png"/>
+ </itemgra>
+ <itemgra item_types="poi_restricted_area" order="12-">
+ <icon src="restricted_area.png"/>
+ </itemgra>
+ <itemgra item_types="poi_restroom" order="13-">
+ <icon src="toilets.png"/>
+ </itemgra>
+ <itemgra item_types="poi_sailing" order="12-">
+ <icon src="sailing.png"/>
+ </itemgra>
+ <itemgra item_types="poi_scenic_area" order="12-">
+ <icon src="scenic_area.png"/>
+ </itemgra>
+ <itemgra item_types="poi_school" order="12-">
+ <icon src="school.png"/>
+ </itemgra>
+ <itemgra item_types="poi_service" order="12-">
+ <icon src="service.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_apparel" order="12-">
+ <icon src="shop_apparel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_bicycle" order="12-">
+ <icon src="bicycle_shop.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_computer" order="12-">
+ <icon src="shop_computer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_department" order="12-">
+ <icon src="shop_department.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_furniture" order="12-">
+ <icon src="shop_furnish.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_grocery" order="12-">
+ <icon src="shop_grocery.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_handg" order="12-">
+ <icon src="shop_handg.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_merchandise" order="12-">
+ <icon src="shop_merchandise.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_retail" order="12-">
+ <icon src="shop_retail.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shower" order="13-">
+ <icon src="shower.png"/>
+ </itemgra>
+ <itemgra item_types="poi_skiing" order="11-">
+ <icon src="skiing.png"/>
+ </itemgra>
+ <itemgra item_types="poi_social_service" order="12-">
+ <icon src="social_service.png"/>
+ </itemgra>
+ <itemgra item_types="poi_sounding" order="12-">
+ <icon src="sounding.png"/>
+ </itemgra>
+ <itemgra item_types="poi_sport" order="12-">
+ <icon src="sport.png"/>
+ </itemgra>
+ <itemgra item_types="poi_stadium" order="11-">
+ <icon src="stadium.png"/>
+ </itemgra>
+ <itemgra item_types="poi_swimming" order="12-">
+ <icon src="swimming.png"/>
+ </itemgra>
+ <itemgra item_types="poi_telephone" order="13-">
+ <icon src="telephone.png"/>
+ </itemgra>
+ <itemgra item_types="poi_theater" order="12-">
+ <icon src="theater.png"/>
+ </itemgra>
+ <itemgra item_types="poi_tide" order="12-">
+ <icon src="tide.png"/>
+ </itemgra>
+ <itemgra item_types="poi_tower" order="13-">
+ <icon src="tower.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_townhall" order="12-">
+ <icon src="townhall.png"/>
+ </itemgra>
+ <itemgra item_types="poi_trail" order="12-">
+ <icon src="trail.png"/>
+ </itemgra>
+ <itemgra item_types="poi_truck_stop" order="12-">
+ <icon src="truck_stop.png"/>
+ </itemgra>
+ <itemgra item_types="poi_tunnel" order="12-">
+ <icon src="tunnel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_wine" order="12-">
+ <icon src="wine.png"/>
+ </itemgra>
+ <itemgra item_types="poi_worship" order="8-">
+ <icon src="worship.png"/>
+ </itemgra>
+ <itemgra item_types="poi_wrecker" order="12-">
+ <icon src="wrecker.png"/>
+ </itemgra>
+ <itemgra item_types="poi_zoo" order="9-">
+ <icon src="zoo.png"/>
+ </itemgra>
+ <itemgra item_types="poi_picnic" order="12-">
+ <icon src="picnic.png"/>
+ </itemgra>
+ <itemgra item_types="poi_playground" order="12-">
+ <icon src="playground.png"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_multi" order="12-">
+ <icon src="gc_multi.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_tradi" order="12-">
+ <icon src="gc_tradi.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_event" order="12-">
+ <icon src="gc_event.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_mystery" order="12-">
+ <icon src="gc_mystery.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_question" order="12-">
+ <icon src="gc_question.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_stages" order="12-">
+ <icon src="gc_stages.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_reference" order="12-">
+ <icon src="gc_reference.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_webcam" order="12-">
+ <icon src="gc_webcam.xpm"/>
+ </itemgra>
+ <itemgra item_types="traffic_signals" order="13-">
+ <icon src="traffic_signals.png"/>
+ </itemgra>
+ <itemgra item_types="poi_wifi" order="13-">
+ <icon src="wifi.png"/>
+ </itemgra>
+ <itemgra item_types="poi_image" order="12-">
+ <image/>
+ </itemgra>
+ <itemgra item_types="poi_bench" order="13-">
+ <icon src="bench.png"/>
+ </itemgra>
+ <itemgra item_types="poi_biergarten" order="12-">
+ <icon src="biergarten.png"/>
+ </itemgra>
+ <itemgra item_types="poi_boundary_stone" order="13-">
+ <icon src="boundary_stone.png"/>
+ </itemgra>
+ <itemgra item_types="poi_castle" order="11-">
+ <icon src="castle.png"/>
+ </itemgra>
+ <itemgra item_types="poi_ruins" order="11-">
+ <icon src="ruins.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hunting_stand" order="12-">
+ <icon src="hunting_stand.png"/>
+ </itemgra>
+ <itemgra item_types="poi_memorial" order="12-">
+ <icon src="memorial.png"/>
+ </itemgra>
+ <itemgra item_types="poi_monument" order="12-">
+ <icon src="memorial.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shelter" order="11-">
+ <icon src="shelter.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fountain" order="13-">
+ <icon src="fountain.png"/>
+ </itemgra>
+ <itemgra item_types="poi_potable_water" order="13-">
+ <icon src="drinking_water.png"/>
+ </itemgra>
+ <itemgra item_types="poi_toilets" order="12-">
+ <icon src="toilets.png"/>
+ </itemgra>
+ <itemgra item_types="poi_viewpoint" order="10-">
+ <icon src="viewpoint.png"/>
+ </itemgra>
+ <itemgra item_types="tec_common" order="11-">
+ <icon src="tec_common.png"/>
+ </itemgra>
+ <itemgra item_types="vehicle" order="0-">
+ <icon src="gui_vehicle_16_16.png"/>
+ </itemgra>
+ <itemgra item_types="vehicle_pedestrian" order="0-">
+ <icon src="gui_vehicle_pedestrian_16_16.png"/>
+ </itemgra>
+ <itemgra item_types="poi_custom0,poi_custom1,poi_custom2,poi_custom3,poi_custom4,poi_custom5,poi_custom6,poi_custom7,poi_custom8,poi_custom9,poi_customa,poi_customb,poi_customc,poi_customd,poi_custome,poi_customf" order="10-">
+ <icon src="%s"/>
+ </itemgra>
+ </layer>
+ <layer name="Android-POI-Labels-full" active="0">
+ <itemgra item_types="poi_airport,town_ghost,poi_hotel,poi_car_parking,poi_car_dealer_parts,poi_car_sharing,poi_fuel,poi_shopping,poi_attraction,poi_cafe,poi_bar,poi_pub,highway_exit,poi_camp_rv,poi_museum_history,poi_hospital,poi_dining,poi_fastfood,poi_police,poi_autoservice,poi_bank,poi_atm,poi_bus_station,poi_bus_stop,poi_business_service,poi_car_rent,poi_church,poi_bahai,poi_buddhist,poi_hindu,poi_islamic,poi_jain,poi_jewish,poi_pagan,poi_pastafarian,poi_shinto,poi_sikh,poi_taoist,poi_cinema,poi_concert,poi_drinking_water,poi_emergency,poi_fair,poi_fish,poi_government_building,poi_hotspring,poi_information,poi_justice,poi_landmark,poi_library,poi_mall,poi_manmade_feature,poi_marine,poi_marine_type,poi_mark,poi_oil_field,poi_peak,poi_personal_service,poi_pharmacy,poi_post_office,poi_public_office,poi_rail_halt,poi_rail_station,poi_rail_tram_stop,poi_repair_service,poi_resort,poi_restaurant,poi_restricted_area,poi_sailing,poi_scenic_area,poi_shop_bicycle,poi_school,poi_service,poi_shop_retail,poi_skiing,poi_social_service,poi_sport,poi_stadium,poi_swimming,poi_theater,poi_townhall,poi_trail,poi_truck_stop,poi_tunnel,poi_worship,poi_wrecker,poi_zoo,poi_biergarten,poi_castle,poi_ruins,poi_memorial,poi_monument,poi_shelter,poi_fountain,poi_viewpoint,vehicle" order="14-">
+ <circle color="#606060" radius="0" width="0" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="poi_custom0,poi_custom1,poi_custom2,poi_custom3,poi_custom4,poi_custom5,poi_custom6,poi_custom7,poi_custom8,poi_custom9,poi_customa,poi_customb,poi_customc,poi_customd,poi_custome,poi_customf" order="14-">
+ <circle color="#606060" radius="0" width="0" text_size="10"/>
+ </itemgra>
+ </layer>
+ <layer name="Found items" ref="Found items"/>
+</layout>
diff --git a/navit/navit_layout_car_dark_shipped.xml b/navit/navit_layout_car_dark_shipped.xml
new file mode 100644
index 000000000..b24978a57
--- /dev/null
+++ b/navit/navit_layout_car_dark_shipped.xml
@@ -0,0 +1,1725 @@
+<?xml version="1.0"?>
+<layout xmlns:xi="http://www.w3.org/2001/XInclude" name="Car-dark" daylayout="Car" color="#011001">
+ <cursor w="57" h="57">
+ <itemgra speed_range="-2">
+ <polyline color="#0000BC" radius="0" width="4">
+ <coord x="0" y="0"/>
+ </polyline>
+ <circle color="#000085" radius="9" width="3">
+ <coord x="0" y="0"/>
+ </circle>
+ <circle color="#0000BC" radius="13" width="3">
+ <coord x="0" y="0"/>
+ </circle>
+ <circle color="#000085" radius="18" width="3">
+ <coord x="0" y="0"/>
+ </circle>
+ </itemgra>
+ <itemgra speed_range="3-">
+ <polygon color="#000085">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="-21" y="-18"/>
+ </polygon>
+ <polygon color="#0000BC">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="21" y="-18"/>
+ </polygon>
+ <polygon color="#00009C">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="-3"/>
+ <coord x="0" y="-9"/>
+ <coord x="-21" y="-18"/>
+ </polygon>
+ <polygon color="#000065">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="-3"/>
+ <coord x="0" y="-9"/>
+ <coord x="21" y="-18"/>
+ </polygon>
+ <polyline color="#000085" width="1">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="-21" y="-18"/>
+ </polyline>
+ <polyline color="#000085" width="1">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="21" y="-18"/>
+ </polyline>
+ <polyline color="#000085" width="1">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="-3"/>
+ <coord x="0" y="-9"/>
+ <coord x="-21" y="-18"/>
+ </polyline>
+ <polyline color="#000085" width="1">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="-3"/>
+ <coord x="0" y="-9"/>
+ <coord x="21" y="-18"/>
+ </polyline>
+ </itemgra>
+ </cursor>
+ <layer name="polygons">
+ <!-- Colors based on Car layout; R/34 G/8 B/9 -->
+ <itemgra item_types="image" order="0-">
+ <image/>
+ </itemgra>
+ <itemgra item_types="poly_nature_reserve" order="10-">
+ <polygon color="#061d15"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_glacier" order="10-">
+ <polygon color="#071e19"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_town" order="0-">
+ <polygon color="#191711"/>
+ </itemgra>
+ <itemgra item_types="poly_naval_base" order="10-">
+ <polygon color="#03140f"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_airfield" order="10-">
+ <polygon color="#071b16"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_university" order="8-">
+ <polygon color="#140f14"/>
+ </itemgra>
+ <itemgra item_types="poly_college" order="10-">
+ <polygon color="#071f1a"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_attraction" order="10-">
+ <polygon color="#00150b"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_theme_park" order="10-">
+ <polygon color="#00150b"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_water_park" order="10-">
+ <polygon color="#041915"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_zoo" order="10-">
+ <polygon color="#061811"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_depot" order="10-">
+ <polygon color="#051610"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_railway" order="10-">
+ <polygon color="#051815"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_port" order="10-">
+ <polygon color="#031111"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_marina" order="10-">
+ <polygon color="#051916"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_commercial" order="10-">
+ <polygon color="#071f16"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_retail" order="10-">
+ <polygon color="#06170f"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_plaza" order="10-">
+ <polygon color="#061914"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_battlefield" order="10-">
+ <polygon color="#010703"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_archaeological_site" order="10-">
+ <polygon color="#061b13"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_ruins" order="10-">
+ <polygon color="#061b13"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_camp_site" order="10-">
+ <polygon color="#011400"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_caravan_site" order="10-">
+ <polygon color="#041303"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_golf_course" order="10-">
+ <polygon color="#021403"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_marsh" order="10-">
+ <polygon color="#020803"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_fell" order="10-">
+ <polygon color="#05170b"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_greenfield" order="10-">
+ <polygon color="#071f19"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_brownfield" order="10-">
+ <polygon color="#05170f"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_heath" order="10-">
+ <polygon color="#061c11"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_scree" order="10-">
+ <polygon color="#071d17"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_quarry" order="10-">
+ <polygon color="#071a12"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_landfill" order="10-">
+ <polygon color="#04130f"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_construction" order="10-">
+ <polygon color="#070e02"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_range" order="10-">
+ <polygon color="#030d0a"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_danger_area" order="10-">
+ <polygon color="#071802"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_common" order="10-">
+ <polygon color="#031605"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_recreation_ground" order="10-">
+ <polygon color="#041500"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_playground" order="10-">
+ <polygon color="#05190d"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_fishing" order="10-">
+ <polygon color="#030700"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_allotments" order="10-">
+ <polygon color="#071b13"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_garden" order="10-">
+ <polygon color="#061e12"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_village_green" order="10-">
+ <polygon color="#041607"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_picnic_site" order="10-">
+ <polygon color="#030f07"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_wood" order="0-">
+ <polygon color="#041a06"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_greenhouse" order="10-">
+ <polygon color="#071d16"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_orchard" order="10-">
+ <polygon color="#041b10"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_plantnursery" order="10-">
+ <polygon color="#051b12"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_farm" order="0-">
+ <polygon color="#041a06"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_meadow" order="0-">
+ <polygon color="#041a06"/>
+ </itemgra>
+ <itemgra item_types="poly_land" order="0-">
+ <polygon color="#011001"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_flats,poly_scrub,poly_military_zone,poly_marine,plantation,tundra" order="0-">
+ <polygon color="#041a06"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_park" order="0-">
+ <polygon color="#041a06"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_beach" order="0-">
+ <polygon color="#081f0b"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_mud" order="0-">
+ <polygon color="#02071d"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="10">
+ <polygon color="#202020"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="11">
+ <polyline color="#1e0728" width="3"/>
+ <polygon color="#202020"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="12">
+ <polyline color="#1e0728" width="5"/>
+ <polygon color="#202020"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="13">
+ <polyline color="#1e0728" width="6"/>
+ <polygon color="#202020"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="14">
+ <polyline color="#1e0728" width="7"/>
+ <polygon color="#202020"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="15">
+ <polyline color="#1e0728" width="9"/>
+ <polygon color="#202020"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="16">
+ <polyline color="#1e0728" width="10"/>
+ <polygon color="#202020"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="17">
+ <polyline color="#1e0728" width="12"/>
+ <polygon color="#202020"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="18">
+ <polyline color="#1e0728" width="20"/>
+ <polygon color="#202020"/>
+ </itemgra>
+ <itemgra item_types="poly_airport" order="0-">
+ <polygon color="#002e00"/>
+ </itemgra>
+ <itemgra item_types="poly_sport,poly_sports_pitch" order="0-">
+ <polygon color="#0c220c"/>
+ </itemgra>
+ <itemgra item_types="poly_industry,poly_place" order="0-">
+ <polygon color="#111111"/>
+ </itemgra>
+ <itemgra item_types="poly_service" order="8-18">
+ <polygon color="#1a1a1a"/>
+ <polyline color="#282828" width="1"/>
+ </itemgra>
+ <itemgra item_types="poly_street_1" order="8-13">
+ <polygon color="#24092f"/>
+ </itemgra>
+ <itemgra item_types="poly_street_1" order="14-16">
+ <polygon color="#24092f"/>
+ </itemgra>
+ <itemgra item_types="poly_street_1" order="17-18">
+ <polygon color="#24092f"/>
+ </itemgra>
+ <itemgra item_types="poly_street_2" order="7-12">
+ <polygon color="#c5c300"/>
+ <polyline color="#c0c0c0" width="1"/>
+ </itemgra>
+ <itemgra item_types="poly_street_2" order="13-16">
+ <polygon color="#c5c300"/>
+ <polyline color="#c0c0c0" width="2"/>
+ </itemgra>
+ <itemgra item_types="poly_street_2" order="17-18">
+ <polygon color="#c5c300"/>
+ <polyline color="#c0c0c0" width="3"/>
+ </itemgra>
+ <itemgra item_types="poly_street_3" order="7-11">
+ <polygon color="#c5c300"/>
+ <polyline color="#a0a0a0" width="1"/>
+ </itemgra>
+ <itemgra item_types="poly_street_3" order="12-15">
+ <polygon color="#c5c300"/>
+ <polyline color="#a0a0a0" width="2"/>
+ </itemgra>
+ <itemgra item_types="poly_street_3" order="16-18">
+ <polygon color="#c5c300"/>
+ <polyline color="#a0a0a0" width="3"/>
+ </itemgra>
+ <itemgra item_types="poly_saltpond" order="10-">
+ <polygon color="#061008"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_water,poly_basin,poly_reservoir" order="0-">
+ <polygon color="#010321"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_line" order="0-">
+ <polyline color="#010321" width="1"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="4-5">
+ <polyline color="#010321" width="1"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="6">
+ <polyline color="#010321" width="2"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="7">
+ <polyline color="#010321" width="3"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="8-9">
+ <polyline color="#010321" width="4"/>
+ <text color="#55c4bd" background_color="#000000" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="10-">
+ <polyline color="#010321" width="4"/>
+ <text color="#55c4bd" background_color="#000000" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="6">
+ <polyline color="#010321" width="1"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="7">
+ <polyline color="#010321" width="2"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="8-9">
+ <polyline color="#010321" width="3"/>
+ <text color="#55c4bd" background_color="#000000" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="10-">
+ <polyline color="#010321" width="3"/>
+ <text color="#55c4bd" background_color="#000000" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="water_stream" order="8-9">
+ <polyline color="#010321" width="1"/>
+ </itemgra>
+ <itemgra item_types="water_stream" order="10-">
+ <polyline color="#010321" width="2"/>
+ <text color="#55c4bd" background_color="#000000" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="water_drain" order="10-">
+ <polyline color="#010321" width="1"/>
+ <text color="#55c4bd" background_color="#000000" text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_apron" order="0-">
+ <polygon color="#041a06"/>
+ </itemgra>
+ <itemgra item_types="poly_terminal" order="7-">
+ <polygon color="#282424"/>
+ </itemgra>
+ <itemgra item_types="poly_cemetery" order="8-">
+ <polygon color="#041a06"/>
+ </itemgra>
+ <itemgra item_types="poly_car_parking" order="8-">
+ <polygon color="#1a170f"/>
+ </itemgra>
+ <itemgra item_types="poly_artwork" order="10-">
+ <polygon color="#082015"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_sports_stadium" order="10-">
+ <polygon color="#03180a"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_sports_track" order="10-">
+ <polygon color="#050b08"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_barracks" order="10-">
+ <polygon color="#051511"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_garages" order="10-">
+ <polygon color="#061b16"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_building" order="8-">
+ <polygon color="#282424"/>
+ </itemgra>
+ <itemgra item_types="rail" order="6-8">
+ <polyline color="#282828" width="2"/>
+ <polyline color="#3d3d3d" dash="1,5" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail" order="9-">
+ <polyline color="#282828" width="3"/>
+ <polyline color="#3d3d3d" dash="1,5" width="1"/>
+ </itemgra>
+ <itemgra item_types="ferry" order="5-">
+ <polyline color="#113111" width="1" dash="10"/>
+ </itemgra>
+ <itemgra item_types="border_country" order="0-">
+ <polyline color="#0d0b41" width="1" dash="10,5,2,5"/>
+ </itemgra>
+ <itemgra item_types="border_state" order="0-">
+ <polyline color="#808080" width="1"/>
+ </itemgra>
+ </layer>
+ <layer name="heightlines">
+ <itemgra item_types="height_line_1" order="0-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="height_line_2" order="0-">
+ <polyline color="#000000" width="2"/>
+ </itemgra>
+ </layer>
+ <layer name="streets">
+ <itemgra item_types="street_route" order="2">
+ <polyline color="#0000a0" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="3-5">
+ <polyline color="#0000a0" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="6">
+ <polyline color="#0000a0" width="10"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="7-8">
+ <polyline color="#0000a0" width="16"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="9-10">
+ <polyline color="#0000a0" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="11">
+ <polyline color="#0000a0" width="28"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="12">
+ <polyline color="#0000a0" width="32"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="13">
+ <polyline color="#0000a0" width="52"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="14">
+ <polyline color="#0000a0" width="64"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="15">
+ <polyline color="#0000a0" width="68"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="16">
+ <polyline color="#0000a0" width="132"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="17">
+ <polyline color="#0000a0" width="268"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="18">
+ <polyline color="#0000a0" width="530"/>
+ </itemgra>
+ <itemgra item_types="street_nopass" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_paved" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled" order="10-12">
+ <polyline color="#800000" width="1" dash="3,6"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled" order="13-14">
+ <polyline color="#3d3d3d" width="4"/>
+ <polyline color="#800000" width="1" dash="4,8"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled" order="15-16">
+ <polyline color="#3d3d3d" width="5"/>
+ <polyline color="#800000" width="1" dash="5,10"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled" order="17-">
+ <polyline color="#3d3d3d" width="7"/>
+ <polyline color="#800000" width="1" dash="7,15"/>
+ </itemgra>
+ <itemgra item_types="track_unpaved" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="bridleway" order="10-">
+ <polyline color="#1e0728" width="1"/>
+ </itemgra>
+ <itemgra item_types="cycleway" order="10-">
+ <polyline color="#1e0728" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_novice" order="10-12">
+ <polyline color="#00A000" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_novice" order="13-14">
+ <polyline color="#00A000" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_novice" order="15-16">
+ <polyline color="#00A000" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_novice" order="17-">
+ <polyline color="#00A000" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_easy" order="10-12">
+ <polyline color="#0000ff" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_easy" order="13-14">
+ <polyline color="#0000ff" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_easy" order="15-16">
+ <polyline color="#0000ff" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_easy" order="17-">
+ <polyline color="#0000ff" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_intermediate" order="10-12">
+ <polyline color="#900000" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_intermediate" order="13-14">
+ <polyline color="#900000" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_intermediate" order="15-16">
+ <polyline color="#900000" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_intermediate" order="17-">
+ <polyline color="#900000" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_advanced" order="10-12">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_advanced" order="13-14">
+ <polyline color="#000000" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_advanced" order="15-16">
+ <polyline color="#000000" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_advanced" order="17-">
+ <polyline color="#000000" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_expert" order="10-12">
+ <polyline color="#ffaa00" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_expert" order="13-14">
+ <polyline color="#ffaa00" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_expert" order="15-16">
+ <polyline color="#ffaa00" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_expert" order="17-">
+ <polyline color="#ffaa00" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_freeride" order="10-12">
+ <polyline color="#c5c300" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_freeride" order="13-14">
+ <polyline color="#c5c300" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_freeride" order="15-16">
+ <polyline color="#c5c300" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_freeride" order="17-">
+ <polyline color="#c5c300" width="5"/>
+ </itemgra>
+ <itemgra item_types="lift_cable_car" order="6-">
+ <polyline color="#3d3d3d" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="lift_chair" order="6-">
+ <polyline color="#3d3d3d" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="lift_drag" order="6-">
+ <polyline color="#3d3d3d" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="piste_nordic" order="10-12">
+ <polyline color="#0000ff" width="1" dash="3,6"/>
+ </itemgra>
+ <itemgra item_types="piste_nordic" order="13-14">
+ <polyline color="#0000ff" width="2"/>
+ <polyline color="#000000" width="1" dash="4,8"/>
+ </itemgra>
+ <itemgra item_types="piste_nordic" order="15-16">
+ <polyline color="#0000ff" width="3"/>
+ <polyline color="#000000" width="1" dash="5,10"/>
+ </itemgra>
+ <itemgra item_types="piste_nordic" order="17-">
+ <polyline color="#0000ff" width="5"/>
+ <polyline color="#000000" width="1" dash="7,15"/>
+ </itemgra>
+ <itemgra item_types="footway" order="11-12">
+ <polyline color="#4e0000" width="1" dash="3,6"/>
+ </itemgra>
+ <itemgra item_types="footway" order="13-14">
+ <polyline color="#4e0000" width="2"/>
+ <polyline color="#000000" width="1" dash="4,8"/>
+ </itemgra>
+ <itemgra item_types="footway" order="15-16">
+ <polyline color="#4e0000" width="3"/>
+ <polyline color="#000000" width="1" dash="5,10"/>
+ </itemgra>
+ <itemgra item_types="footway" order="17-">
+ <polyline color="#4e0000" width="5"/>
+ <polyline color="#000000" width="1" dash="7,15"/>
+ </itemgra>
+ <itemgra item_types="steps" order="14-15">
+ <polyline color="#4d4e11" width="1"/>
+ </itemgra>
+ <itemgra item_types="steps" order="16">
+ <polyline color="#4d4e11" width="2"/>
+ </itemgra>
+ <itemgra item_types="steps" order="17-18">
+ <polyline color="#4d4e11" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="10">
+ <polyline color="#1e0728" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="11">
+ <polyline color="#1e0728" width="5"/>
+ <polyline color="#202020" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="12">
+ <polyline color="#1e0728" width="8"/>
+ <polyline color="#202020" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="13">
+ <polyline color="#1e0728" width="9"/>
+ <polyline color="#202020" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="14">
+ <polyline color="#1e0728" width="13"/>
+ <polyline color="#202020" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="15">
+ <polyline color="#1e0728" width="18"/>
+ <polyline color="#202020" width="10"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="16">
+ <polyline color="#1e0728" width="21"/>
+ <polyline color="#202020" width="13"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="17">
+ <polyline color="#1e0728" width="25"/>
+ <polyline color="#202020" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="18">
+ <polyline color="#1e0728" width="40"/>
+ <polyline color="#202020" width="30"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="10">
+ <polyline color="#2c2c2c" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="11">
+ <polyline color="#2c2c2c" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="12">
+ <polyline color="#2c2c2c" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="13">
+ <polyline color="#2c2c2c" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="14">
+ <polyline color="#2c2c2c" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="15">
+ <polyline color="#2c2c2c" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="16">
+ <polyline color="#2c2c2c" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="17">
+ <polyline color="#2c2c2c" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="18">
+ <polyline color="#2c2c2c" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="12">
+ <polyline color="#2c2c2c" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="13">
+ <polyline color="#2c2c2c" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="14">
+ <polyline color="#2c2c2c" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="15">
+ <polyline color="#2c2c2c" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="16">
+ <polyline color="#2c2c2c" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="17">
+ <polyline color="#2c2c2c" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="18">
+ <polyline color="#2c2c2c" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="10">
+ <polyline color="#24092f" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="11">
+ <polyline color="#24092f" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="12">
+ <polyline color="#24092f" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="13">
+ <polyline color="#24092f" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="14">
+ <polyline color="#24092f" width="13"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="15">
+ <polyline color="#24092f" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="16">
+ <polyline color="#24092f" width="26"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="17">
+ <polyline color="#24092f" width="61"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="18">
+ <polyline color="#24092f" width="126"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="8">
+ <polyline color="#1d4c19" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="9">
+ <polyline color="#1d4c19" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="10">
+ <polyline color="#1d4c19" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="11">
+ <polyline color="#1d4c19" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="12">
+ <polyline color="#1d4c19" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="13">
+ <polyline color="#1d4c19" width="11"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="14">
+ <polyline color="#1d4c19" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="15">
+ <polyline color="#1d4c19" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="16">
+ <polyline color="#1d4c19" width="30"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="17">
+ <polyline color="#1d4c19" width="67"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="18">
+ <polyline color="#1d4c19" width="138"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="7-8">
+ <polyline color="#4d4e11" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="9">
+ <polyline color="#4d4e11" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="10">
+ <polyline color="#4d4e11" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="11">
+ <polyline color="#4d4e11" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="12">
+ <polyline color="#4d4e11" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="13">
+ <polyline color="#4d4e11" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="14">
+ <polyline color="#4d4e11" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="15">
+ <polyline color="#4d4e11" width="21"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="16">
+ <polyline color="#4d4e11" width="34"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="17">
+ <polyline color="#4d4e11" width="73"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="18">
+ <polyline color="#4d4e11" width="150"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="2-5">
+ <polyline color="#430000" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="6-8">
+ <polyline color="#430000" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="9">
+ <polyline color="#430000" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="10">
+ <polyline color="#430000" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11">
+ <polyline color="#430000" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="12">
+ <polyline color="#430000" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="13">
+ <polyline color="#430000" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="14">
+ <polyline color="#430000" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="15">
+ <polyline color="#430000" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="16">
+ <polyline color="#430000" width="33"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="17">
+ <polyline color="#430000" width="72"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="18">
+ <polyline color="#430000" width="150"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="2">
+ <polyline color="#760000" width="1"/>
+ </itemgra>
+ <!--1d4c19/0d740d-->
+ <itemgra item_types="highway_city,highway_land" order="3-5">
+ <polyline color="#640000" width="3"/>
+ <polyline color="#0a5c0a" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="6">
+ <polyline color="#640000" width="4"/>
+ <polyline color="#0a5c0a" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="7-8">
+ <polyline color="#640000" width="6"/>
+ <polyline color="#005b00" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="9-10">
+ <polyline color="#640000" width="8"/>
+ <polyline color="#0a5c0a" width="2"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="11">
+ <polyline color="#640000" width="12"/>
+ <polyline color="#0a5c0a" width="3"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="12">
+ <polyline color="#640000" width="13"/>
+ <polyline color="#0a5c0a" width="3"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="13">
+ <polyline color="#640000" width="17"/>
+ <polyline color="#0a5c0a" width="4"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="14">
+ <polyline color="#640000" width="24"/>
+ <polyline color="#0a5c0a" width="4"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="15">
+ <polyline color="#640000" width="27"/>
+ <polyline color="#0a5c0a" width="5"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="16">
+ <polyline color="#640000" width="59"/>
+ <polyline color="#0a5c0a" width="6"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="17">
+ <polyline color="#640000" width="127"/>
+ <polyline color="#0a5c0a" width="7"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="18">
+ <polyline color="#640000" width="258"/>
+ <polyline color="#0a5c0a" width="8"/>
+ </itemgra>
+ <!-- This entry shows all unknown linear elements as blue lines -->
+ <!--
+ <itemgra item_types="street_unkn" order="0-">
+ <polyline color="#8080ff" width="3"/>
+ </itemgra>
+ -->
+ <itemgra item_types="highway_exit_label" order="10-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street" order="10-18">
+ <text text_size="8" color="#55c4bd" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp" order="11-18">
+ <text text_size="9" color="#55c4bd" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land,footway" order="12-18">
+ <text text_size="9" color="#55c4bd" background_color="#000000"/>
+ </itemgra>
+ </layer>
+ <layer name="polylines">
+ <itemgra item_types="aeroway_taxiway" order="10">
+ <polyline color="#404040" width="4"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="11">
+ <polyline color="#404040" width="6"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="12">
+ <polyline color="#404040" width="10"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="13">
+ <polyline color="#404040" width="12"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="14">
+ <polyline color="#404040" width="15"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="15">
+ <polyline color="#404040" width="17"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="16">
+ <polyline color="#404040" width="33"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="17">
+ <polyline color="#404040" width="69"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="18">
+ <polyline color="#404040" width="132"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="2-6">
+ <polyline color="#404040" width="1"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="7-8">
+ <polyline color="#404040" width="3"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="9">
+ <polyline color="#404040" width="5"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="10">
+ <polyline color="#404040" width="6"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="11">
+ <polyline color="#404040" width="9"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="12">
+ <polyline color="#404040" width="13"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="13">
+ <polyline color="#404040" width="18"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="14">
+ <polyline color="#404040" width="21"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="15">
+ <polyline color="#404040" width="24"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="16">
+ <polyline color="#404040" width="39"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="17">
+ <polyline color="#404040" width="78"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="18">
+ <polyline color="#404040" width="156"/>
+ </itemgra>
+ <itemgra item_types="rail_tram,bus_guideway" order="10-">
+ <polyline color="#3d3d3d" width="2"/>
+ </itemgra>
+ </layer>
+ <layer name="labels">
+ <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="12-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3" order="11-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e3,town_label_2e3,town_label_5e3,place_label" order="10-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4" order="9-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e4,town_label_2e4,town_label_5e4" order="8-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5" order="6-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="4-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6" order="3-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6" order="2-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e7,district_label_1e7" order="1-">
+ <circle color="#55c4bd" background_color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ </layer>
+ <layer name="Internal">
+ <itemgra item_types="track" order="3-">
+ <polyline color="#3f3f3f" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_tracked" order="7-">
+ <polyline color="#3f3fff" width="3"/>
+ </itemgra>
+ <itemgra item_types="rg_segment" order="0-">
+ <polyline color="#FF089C" width="1"/>
+ <arrows color="#FF089C" width="1"/>
+ </itemgra>
+ <itemgra item_types="rg_point" order="0-">
+ <circle color="#FF089C" radius="10" background_color="#000000" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="nav_left_1" order="0-">
+ <icon src="nav_left_1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_left_2" order="0-">
+ <icon src="nav_left_2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_left_3" order="0-">
+ <icon src="nav_left_3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_1" order="0-">
+ <icon src="nav_right_1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_2" order="0-">
+ <icon src="nav_right_2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_3" order="0-">
+ <icon src="nav_right_3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_straight" order="0-">
+ <icon src="nav_straight_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_turnaround_left" order="0-">
+ <icon src="nav_turnaround_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_turnaround_right" order="0-">
+ <icon src="nav_turnaround_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l1" order="0-">
+ <icon src="nav_roundabout_l1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r1" order="0-">
+ <icon src="nav_roundabout_r1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l2" order="0-">
+ <icon src="nav_roundabout_l2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r2" order="0-">
+ <icon src="nav_roundabout_r2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l3" order="0-">
+ <icon src="nav_roundabout_l3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r3" order="0-">
+ <icon src="nav_roundabout_r3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l4" order="0-">
+ <icon src="nav_roundabout_l4_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r4" order="0-">
+ <icon src="nav_roundabout_r4_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l5" order="0-">
+ <icon src="nav_roundabout_l5_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r5" order="0-">
+ <icon src="nav_roundabout_r5_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l6" order="0-">
+ <icon src="nav_roundabout_l6_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r6" order="0-">
+ <icon src="nav_roundabout_r6_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l7" order="0-">
+ <icon src="nav_roundabout_l7_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r7" order="0-">
+ <icon src="nav_roundabout_r7_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l8" order="0-">
+ <icon src="nav_roundabout_l8_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r8" order="0-">
+ <icon src="nav_roundabout_r8_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_keep_left" order="0-">
+ <icon src="nav_keep_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_merge_left" order="0-">
+ <icon src="nav_merge_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_keep_right" order="0-">
+ <icon src="nav_keep_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_merge_right" order="0-">
+ <icon src="nav_merge_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_exit_left" order="0-">
+ <icon src="nav_exit_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_exit_right" order="0-">
+ <icon src="nav_exit_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="route_end" order="0-">
+ <icon src="nav_destination_wh.svg" w="32" h="32" x="4" y="30"/>
+ </itemgra>
+ <itemgra item_types="nav_none" order="0-">
+ <icon src="unknown.svg"/>
+ </itemgra>
+ <itemgra item_types="announcement" order="7-">
+ <icon src="gui_sound_32_32.png"/>
+ <circle color="#FF089C" radius="10" background_color="#000000" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="2">
+ <circle color="#00a0a0" radius="4" width="2" background_color="#000000" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="3-5">
+ <circle color="#00a0a0" radius="8" width="2" background_color="#000000" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="6">
+ <circle color="#00a0a0" radius="10" width="2" background_color="#000000" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="7-8">
+ <circle color="#00a0a0" radius="16" width="2" background_color="#000000" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="9-10">
+ <circle color="#00a0a0" radius="20" width="4" background_color="#000000" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="11">
+ <circle color="#00a0a0" radius="28" width="4" background_color="#000000" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="12">
+ <circle color="#00a0a0" radius="32" width="4" background_color="#000000" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="13">
+ <circle color="#00a0a0" radius="52" width="4" background_color="#000000" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="14">
+ <circle color="#00a0a0" radius="64" width="4" background_color="#000000" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="15">
+ <circle color="#00a0a0" radius="68" width="6" background_color="#000000" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="16">
+ <circle color="#00a0a0" radius="132" width="8" background_color="#000000" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="17">
+ <circle color="#00a0a0" radius="268" width="8" background_color="#000000" text_size="48"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="18">
+ <circle color="#00a0a0" radius="530" width="8" background_color="#000000" text_size="48"/>
+ </itemgra>
+ </layer>
+ <layer name="POI Symbols">
+ <itemgra item_types="mini_roundabout" order="12-">
+ <icon src="mini_roundabout.png"/>
+ </itemgra>
+ <itemgra item_types="turning_circle" order="12-">
+ <icon src="mini_roundabout.png"/>
+ </itemgra>
+ <itemgra item_types="poi_airport" order="5-">
+ <icon src="airport.png"/>
+ </itemgra>
+ <itemgra item_types="town_ghost" order="0-">
+ <icon src="ghost_town.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_hotel" order="12-">
+ <icon src="hotel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_parking" order="11-">
+ <icon src="parking.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_sharing" order="11-">
+ <icon src="car_sharing.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_dealer_parts" order="0-">
+ <icon src="car_dealer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fuel" order="10-">
+ <icon src="fuel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shopping" order="10-">
+ <icon src="shopping.png"/>
+ </itemgra>
+ <itemgra item_types="poi_attraction" order="8-">
+ <icon src="attraction.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cafe" order="12-">
+ <icon src="cafe.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bar" order="12-">
+ <icon src="bar.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pub" order="12-">
+ <icon src="beer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bridge" order="0-">
+ <icon src="bridge.xpm"/>
+ </itemgra>
+ <itemgra item_types="highway_exit" order="11-">
+ <icon src="exit.png"/>
+ </itemgra>
+ <itemgra item_types="poi_camp_rv" order="9-">
+ <icon src="camping.png"/>
+ </itemgra>
+ <itemgra item_types="poi_museum_history" order="12-">
+ <icon src="museum.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hospital" order="12-">
+ <icon src="hospital.png"/>
+ </itemgra>
+ <!-- not really usefull -->
+ <!--
+ <itemgra item_types="point_unkn" order="0-">
+ <circle color="#8080ff" radius="3"/>
+ </itemgra>
+ -->
+ <itemgra item_types="poi_dining" order="12-">
+ <icon src="restaurant.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fastfood" order="12-">
+ <icon src="fastfood.png"/>
+ </itemgra>
+ <itemgra item_types="poi_police" order="12-">
+ <icon src="police.png"/>
+ </itemgra>
+ <itemgra item_types="poi_auto_club" order="0-">
+ <icon src="auto_club.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_autoservice" order="0-">
+ <icon src="car_dealer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bank" order="12-">
+ <icon src="bank.png"/>
+ </itemgra>
+ <itemgra item_types="poi_atm" order="12-">
+ <icon src="atm.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bay" order="0-">
+ <icon src="bay.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_bend" order="0-">
+ <icon src="bend.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_boat_ramp" order="12-">
+ <icon src="boat_ramp.png"/>
+ </itemgra>
+ <itemgra item_types="poi_border_station" order="0-">
+ <icon src="border_station.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_bowling" order="0-">
+ <icon src="bowling.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_bus_station" order="12-">
+ <icon src="bus.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bus_stop" order="12-">
+ <icon src="bus_stop.png"/>
+ </itemgra>
+ <itemgra item_types="poi_business_service" order="0-">
+ <icon src="bussines_service.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_car_rent" order="11-">
+ <icon src="car_rent.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_wash" order="12-">
+ <icon src="car_wash.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_casino" order="11-">
+ <icon src="casino.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cemetery" order="11-">
+ <icon src="cemetery.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_church" order="11-">
+ <icon src="church.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bahai" order="11-">
+ <icon src="bahai.png"/>
+ </itemgra>
+ <itemgra item_types="poi_buddhist" order="11-">
+ <icon src="buddhist.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hindu" order="11-">
+ <icon src="hindu.png"/>
+ </itemgra>
+ <itemgra item_types="poi_islamic" order="11-">
+ <icon src="islamic.png"/>
+ </itemgra>
+ <itemgra item_types="poi_jain" order="11-">
+ <icon src="jain.png"/>
+ </itemgra>
+ <itemgra item_types="poi_jewish" order="11-">
+ <icon src="jewish.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pagan" order="11-">
+ <icon src="pagan.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pastafarian" order="11-">
+ <icon src="pastafarian.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shinto" order="11-">
+ <icon src="shinto.png"/>
+ </itemgra>
+ <itemgra item_types="poi_sikh" order="11-">
+ <icon src="sikh.png"/>
+ </itemgra>
+ <itemgra item_types="poi_taoist" order="11-">
+ <icon src="taoist.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cinema" order="12-">
+ <icon src="cinema.png"/>
+ </itemgra>
+ <itemgra item_types="poi_communication" order="0-">
+ <icon src="communication.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_concert" order="0-">
+ <icon src="concert.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_cove" order="0-">
+ <icon src="cove.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_crossing" order="0-">
+ <icon src="crossing.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_dam" order="0-">
+ <icon src="dam.png"/>
+ </itemgra>
+ <itemgra item_types="poi_danger_area" order="12-">
+ <icon src="danger_16_16.png"/>
+ </itemgra>
+ <itemgra item_types="poi_danger_sea_wreck" order="0-">
+ <icon src="dangerous.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_daymark" order="0-">
+ <icon src="daymark.png"/>
+ </itemgra>
+ <itemgra item_types="poi_diving" order="0-">
+ <icon src="diving.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_drinking_water" order="0-">
+ <icon src="drinking_water.png"/>
+ </itemgra>
+ <itemgra item_types="poi_emergency" order="0-">
+ <icon src="emergency.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fair" order="0-">
+ <icon src="fair.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_firebrigade" order="12-">
+ <icon src="firebrigade.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fish" order="0-">
+ <icon src="fish.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_forbidden_area" order="0-">
+ <icon src="forbidden_area.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_gps" order="0-">
+ <icon src="garmin.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_golf" order="12-">
+ <icon src="golf.png"/>
+ </itemgra>
+ <itemgra item_types="poi_government_building" order="0-">
+ <icon src="government_building.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_height" order="0-">
+ <icon src="height.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_heliport" order="7-">
+ <icon src="heliport.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hotspring" order="0-">
+ <icon src="hotspring.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_icesport" order="0-">
+ <icon src="icesport.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_information" order="12-">
+ <icon src="information.png"/>
+ </itemgra>
+ <itemgra item_types="poi_justice" order="10-">
+ <icon src="justice.png"/>
+ </itemgra>
+ <itemgra item_types="poi_landmark" order="0-">
+ <icon src="landmark.png"/>
+ </itemgra>
+ <itemgra item_types="poi_levee" order="0-">
+ <icon src="levee.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_level_crossing" order="11-">
+ <icon src="level_crossing.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_library" order="12-">
+ <icon src="library.png"/>
+ </itemgra>
+ <itemgra item_types="poi_locale" order="0-">
+ <icon src="locale.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_loudspeaker" order="0-">
+ <icon src="loudspeaker.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_mall" order="0-">
+ <icon src="mall.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_manmade_feature" order="0-">
+ <icon src="manmade_feature.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_marine" order="0-">
+ <icon src="marine.png"/>
+ </itemgra>
+ <itemgra item_types="poi_marine_type" order="0-">
+ <icon src="marine_type.png"/>
+ </itemgra>
+ <itemgra item_types="poi_mark" order="0-">
+ <icon src="mark.png"/>
+ </itemgra>
+ <itemgra item_types="poi_military" order="0-">
+ <icon src="military.png"/>
+ </itemgra>
+ <itemgra item_types="poi_mine" order="0-">
+ <icon src="mine.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_nondangerous" order="0-">
+ <icon src="nondangerous.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_oil_field" order="0-">
+ <icon src="oil_field.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_peak" order="6-">
+ <icon src="peak.png"/>
+ </itemgra>
+ <itemgra item_types="poi_personal_service" order="0-">
+ <icon src="personal_service.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_pharmacy" order="12-">
+ <icon src="pharmacy.png"/>
+ </itemgra>
+ <itemgra item_types="poi_post_office,poi_post_box" order="13-">
+ <icon src="post.png"/>
+ </itemgra>
+ <itemgra item_types="poi_public_office" order="0-">
+ <icon src="public_office.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_halt" order="10-">
+ <circle color="#000000" radius="3" width="3"/>
+ <circle color="#3d3d3d" background_color="#000000" radius="6" width="2" text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_station" order="11-">
+ <circle color="#000000" radius="3" width="3"/>
+ <circle color="#3d3d3d" background_color="#000000" radius="6" width="2" text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_tram_stop" order="10-11">
+ <circle color="#3d3d3d" background_color="#000000" radius="2" width="2"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_tram_stop" order="12-">
+ <circle color="#000000" radius="3" width="3"/>
+ <circle color="#3d3d3d" background_color="#000000" radius="6" width="2" text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poi_repair_service" order="0-">
+ <icon src="repair_service.png"/>
+ </itemgra>
+ <itemgra item_types="poi_resort" order="0-">
+ <icon src="resort.png"/>
+ </itemgra>
+ <itemgra item_types="poi_restaurant" order="12-">
+ <icon src="restaurant.png"/>
+ </itemgra>
+ <itemgra item_types="poi_restricted_area" order="0-">
+ <icon src="restricted_area.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_restroom" order="13-">
+ <icon src="toilets.png"/>
+ </itemgra>
+ <itemgra item_types="poi_sailing" order="0-">
+ <icon src="sailing.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_scenic_area" order="0-">
+ <icon src="scenic_area.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_school" order="12-">
+ <icon src="school.png"/>
+ </itemgra>
+ <itemgra item_types="poi_service" order="0-">
+ <icon src="service.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_apparel" order="0-">
+ <icon src="shop_apparel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_computer" order="0-">
+ <icon src="shop_computer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_department" order="0-">
+ <icon src="shop_department.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_furniture" order="0-">
+ <icon src="shop_furnish.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_grocery" order="0-">
+ <icon src="shop_grocery.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_handg" order="0-">
+ <icon src="shop_handg.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_merchandise" order="0-">
+ <icon src="shop_merchandise.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_retail" order="0-">
+ <icon src="shop_retail.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shower" order="0-">
+ <icon src="shower.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_skiing" order="12-">
+ <icon src="skiing.png"/>
+ </itemgra>
+ <itemgra item_types="poi_social_service" order="0-">
+ <icon src="social_service.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_sounding" order="0-">
+ <icon src="sounding.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_sport" order="12-">
+ <icon src="sport.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_stadium" order="0-">
+ <icon src="stadium.png"/>
+ </itemgra>
+ <itemgra item_types="poi_swimming" order="12-">
+ <icon src="swimming.png"/>
+ </itemgra>
+ <itemgra item_types="poi_taxi" order="13-">
+ <icon src="taxi.png"/>
+ </itemgra>
+ <itemgra item_types="poi_telephone" order="13-">
+ <icon src="telephone.png"/>
+ </itemgra>
+ <itemgra item_types="poi_theater" order="12-">
+ <icon src="theater.png"/>
+ </itemgra>
+ <itemgra item_types="poi_tide" order="0-">
+ <icon src="tide.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_tower" order="13-">
+ <icon src="tower.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_townhall" order="12-">
+ <icon src="townhall.png"/>
+ </itemgra>
+ <itemgra item_types="poi_trail" order="0-">
+ <icon src="trail.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_truck_stop" order="0-">
+ <icon src="truck_stop.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_tunnel" order="0-">
+ <icon src="tunnel.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_wifi" order="11-">
+ <icon src="wifi.png"/>
+ </itemgra>
+ <itemgra item_types="poi_wine" order="0-">
+ <icon src="wine.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_worship" order="0-">
+ <icon src="worship.png"/>
+ </itemgra>
+ <itemgra item_types="poi_wrecker" order="0-">
+ <icon src="wrecker.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_zoo" order="10-">
+ <icon src="zoo.png"/>
+ </itemgra>
+ <itemgra item_types="poi_picnic" order="11-">
+ <icon src="picnic.png"/>
+ </itemgra>
+ <itemgra item_types="poi_playground" order="12-">
+ <icon src="playground.png"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_multi" order="0-">
+ <icon src="gc_multi.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_tradi" order="0-">
+ <icon src="gc_tradi.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_event" order="0-">
+ <icon src="gc_event.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_mystery" order="0-">
+ <icon src="gc_mystery.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_question" order="0-">
+ <icon src="gc_question.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_stages" order="0-">
+ <icon src="gc_stages.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_reference" order="0-">
+ <icon src="gc_reference.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_webcam" order="0-">
+ <icon src="gc_webcam.xpm"/>
+ </itemgra>
+ <itemgra item_types="traffic_signals" order="13-">
+ <icon src="traffic_signals.png"/>
+ </itemgra>
+ <itemgra item_types="poi_image" order="0-">
+ <image/>
+ </itemgra>
+ <!-- I'm not sure if the following stuff should appear in any layout. Maybe portions should only apply to the bike layout? -->
+ <itemgra item_types="poi_bench" order="13-">
+ <icon src="bench.png"/>
+ </itemgra>
+ <itemgra item_types="poi_biergarten" order="12-">
+ <icon src="beer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_boundary_stone" order="13-">
+ <icon src="boundary_stone.png"/>
+ </itemgra>
+ <itemgra item_types="poi_castle" order="12-">
+ <icon src="castle.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hunting_stand" order="13-">
+ <icon src="hunting_stand.png"/>
+ </itemgra>
+ <itemgra item_types="poi_memorial" order="12-">
+ <icon src="memorial.png"/>
+ </itemgra>
+ <itemgra item_types="poi_monument" order="12-">
+ <icon src="memorial.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shelter" order="10-">
+ <icon src="shelter.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fountain" order="12-">
+ <icon src="fountain.png"/>
+ </itemgra>
+ <itemgra item_types="poi_potable_water" order="12-">
+ <icon src="drinking_water.png"/>
+ </itemgra>
+ <itemgra item_types="poi_toilets" order="12-">
+ <icon src="toilets.png"/>
+ </itemgra>
+ <itemgra item_types="poi_viewpoint" order="12-">
+ <icon src="viewpoint.png"/>
+ </itemgra>
+ <itemgra item_types="tec_common" order="11-">
+ <icon src="tec_common.png"/>
+ </itemgra>
+ <itemgra item_types="vehicle" order="0-">
+ <icon src="gui_vehicle_16_16.png"/>
+ </itemgra>
+ <itemgra item_types="vehicle_pedestrian" order="0-">
+ <icon src="gui_vehicle_pedestrian_16_16.png"/>
+ </itemgra>
+ </layer>
+ <layer name="POI Labels">
+ <itemgra item_types="poi_airport,town_ghost,poi_hotel,poi_car_parking,poi_car_dealer_parts,poi_fuel,poi_shopping,poi_attraction,poi_cafe,poi_bar,poi_pub,highway_exit,poi_camp_rv,poi_museum_history,poi_hospital,poi_dining,poi_fastfood,poi_police,poi_autoservice,poi_bank,poi_atm,poi_bus_station,poi_bus_stop,poi_business_service,poi_car_rent,poi_car_sharing,poi_church,poi_bahai,poi_buddhist,poi_hindu,poi_islamic,poi_jain,poi_jewish,poi_pagan,poi_pastafarian,poi_shinto,poi_sikh,poi_taoist,poi_cinema,poi_concert,poi_drinking_water,poi_emergency,poi_fair,poi_fish,poi_government_building,poi_hotspring,poi_information,poi_justice,poi_landmark,poi_library,poi_mall,poi_manmade_feature,poi_marine,poi_marine_type,poi_mark,poi_oil_field,poi_peak,poi_personal_service,poi_pharmacy,poi_post_office,poi_public_office,poi_rail_halt,poi_rail_station,poi_rail_tram_stop,poi_repair_service,poi_resort,poi_restaurant,poi_restricted_area,poi_sailing,poi_scenic_area,poi_school,poi_service,poi_shop_retail,poi_skiing,poi_social_service,poi_sport,poi_stadium,poi_swimming,poi_theater,poi_townhall,poi_trail,poi_truck_stop,poi_tunnel,poi_worship,poi_wrecker,poi_zoo,poi_biergarten,poi_castle,poi_ruins,poi_memorial,poi_monument,poi_shelter,poi_fountain,poi_viewpoint,vehicle" order="14-">
+ <circle color="#606060" background_color="#000000" radius="0" width="0" text_size="10"/>
+ </itemgra>
+ </layer>
+ <layer name="Found items" ref="Found items"/>
+</layout>
diff --git a/navit/navit_layout_car_shipped.xml b/navit/navit_layout_car_shipped.xml
new file mode 100644
index 000000000..e772ab9f4
--- /dev/null
+++ b/navit/navit_layout_car_shipped.xml
@@ -0,0 +1,2015 @@
+<?xml version="1.0"?>
+<layout xmlns:xi="http://www.w3.org/2001/XInclude" name="Car" nightlayout="Car-dark" color="#ffefb7" font="Liberation Sans">
+ <cursor w="57" h="57">
+ <itemgra speed_range="-2">
+ <polyline color="#00BC00" radius="0" width="4">
+ <coord x="0" y="0"/>
+ </polyline>
+ <circle color="#008500" radius="9" width="3">
+ <coord x="0" y="0"/>
+ </circle>
+ <circle color="#00BC00" radius="13" width="3">
+ <coord x="0" y="0"/>
+ </circle>
+ <circle color="#008500" radius="18" width="3">
+ <coord x="0" y="0"/>
+ </circle>
+ </itemgra>
+ <itemgra speed_range="3-">
+ <polygon color="#008500">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="-21" y="-18"/>
+ </polygon>
+ <polygon color="#00BC00">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="21" y="-18"/>
+ </polygon>
+ <polygon color="#009C00">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="-3"/>
+ <coord x="0" y="-9"/>
+ <coord x="-21" y="-18"/>
+ </polygon>
+ <polygon color="#006500">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="-3"/>
+ <coord x="0" y="-9"/>
+ <coord x="21" y="-18"/>
+ </polygon>
+ <polyline color="#008500" width="1">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="-21" y="-18"/>
+ </polyline>
+ <polyline color="#008500" width="1">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="21"/>
+ <coord x="0" y="-3"/>
+ <coord x="21" y="-18"/>
+ </polyline>
+ <polyline color="#008500" width="1">
+ <coord x="-21" y="-18"/>
+ <coord x="0" y="-3"/>
+ <coord x="0" y="-9"/>
+ <coord x="-21" y="-18"/>
+ </polyline>
+ <polyline color="#008500" width="1">
+ <coord x="21" y="-18"/>
+ <coord x="0" y="-3"/>
+ <coord x="0" y="-9"/>
+ <coord x="21" y="-18"/>
+ </polyline>
+ </itemgra>
+ </cursor>
+ <layer name="polygons">
+ <itemgra item_types="image" order="0-">
+ <image/>
+ </itemgra>
+ <itemgra item_types="poly_nature_reserve" order="10-">
+ <polygon color="#cedec6"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_glacier" order="10-">
+ <polygon color="#ddecec"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_town" order="0-">
+ <polygon color="#ffc895"/>
+ <polyline color="#ebb481"/>
+ </itemgra>
+ <itemgra item_types="poly_naval_base" order="10-">
+ <polygon color="#6a9993"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_airfield" order="10-">
+ <polygon color="#ecd3cf"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_university" order="8-">
+ <polygon color="#d68fb8"/>
+ <polyline color="#881155"/>
+ </itemgra>
+ <itemgra item_types="poly_college" order="10-">
+ <polygon color="#f4f4f4"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_attraction" order="10-">
+ <polygon color="#01a36c"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_theme_park" order="10-">
+ <polygon color="#01a36c"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_water_park" order="10-">
+ <polygon color="#8cc1c8"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_zoo" order="10-">
+ <polygon color="#ccbda5"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_depot" order="10-">
+ <polygon color="#c2b098"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_railway" order="10-">
+ <polygon color="#b3b9c5"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_port" order="10-">
+ <polygon color="#8188a0"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_marina" order="10-">
+ <polygon color="#aac4d2"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_commercial" order="10-">
+ <polygon color="#eaeed3"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_retail" order="10-">
+ <polygon color="#d6b690"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_plaza" order="10-">
+ <polygon color="#cac4bc"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_battlefield" order="10-">
+ <polygon color="#373d1c"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_archaeological_site" order="10-">
+ <polygon color="#d9cfb6"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_ruins" order="10-">
+ <polygon color="#d9cfb6"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_camp_site" order="10-">
+ <polygon color="#339900"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_caravan_site" order="10-">
+ <polygon color="#8d9723"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_golf_course" order="10-">
+ <polygon color="#419a22"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_marsh" order="10-">
+ <polygon color="#553f23"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_fell" order="10-">
+ <polygon color="#bbb56b"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_greenfield" order="10-">
+ <polygon color="#f1eee8"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_brownfield" order="10-">
+ <polygon color="#b6b690"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_heath" order="10-">
+ <polygon color="#d6d99f"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_scree" order="10-">
+ <polygon color="#eee5dc"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_quarry" order="10-">
+ <polygon color="#e4caad"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_landfill" order="10-">
+ <polygon color="#999893"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_construction" order="10-">
+ <polygon color="#f47216"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_range" order="10-">
+ <polygon color="#6d6b63"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_danger_area" order="10-">
+ <polygon color="#f2ba1b"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_common" order="10-">
+ <polygon color="#7bab36"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_recreation_ground" order="10-">
+ <polygon color="#8fa400"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_playground" order="10-">
+ <polygon color="#b4c479"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_fishing" order="10-">
+ <polygon color="#713907"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_allotments" order="10-">
+ <polygon color="#eecfb3"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_garden" order="10-">
+ <polygon color="#cfeca8"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_village_green" order="10-">
+ <polygon color="#93ac47"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_picnic_site" order="10-">
+ <polygon color="#797548"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_wood" order="0-">
+ <polygon color="#8ec78d"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_greenhouse" order="10-">
+ <polygon color="#f9e8cb"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_orchard" order="10-">
+ <polygon color="#9edc90"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_plantnursery" order="10-">
+ <polygon color="#addea2"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_farm" order="0-">
+ <polygon color="#c7f1a3"/>
+ <polyline color="#79c691"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_meadow" order="0-">
+ <polygon color="#c7f1a3"/>
+ <polyline color="#79c691"/>
+ </itemgra>
+ <itemgra item_types="poly_water_tiled" order="0-">
+ <polygon color="#82c8ea"/>
+ </itemgra>
+ <itemgra item_types="poly_land" order="0-">
+ <polygon color="#ffefb7"/>
+ <polyline color="#ffefb7"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_flats,poly_scrub,poly_military_zone,poly_marine,plantation,tundra" order="9-">
+ <polygon color="#a0a0a0"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_park" order="0-">
+ <polygon color="#7cc334"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_beach" order="0-">
+ <polygon color="#fbed66"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_mud" order="0-">
+ <polygon color="#96ced4"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="10">
+ <polyline color="#d2d2d2" width="3"/>
+ <polyline color="#dddddd" width="1"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="11">
+ <polyline color="#d2d2d2" width="5"/>
+ <polyline color="#dddddd" width="3"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="12">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#dddddd" width="6"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="13">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#dddddd" width="7"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="14">
+ <polyline color="#d2d2d2" width="13"/>
+ <polyline color="#dddddd" width="9"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="15">
+ <polyline color="#d2d2d2" width="18"/>
+ <polyline color="#dddddd" width="14"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="16">
+ <polyline color="#d2d2d2" width="21"/>
+ <polyline color="#dddddd" width="17"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="17">
+ <polyline color="#d2d2d2" width="25"/>
+ <polyline color="#dddddd" width="21"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_pedestrian" order="18">
+ <polyline color="#d2d2d2" width="40"/>
+ <polyline color="#dddddd" width="34"/>
+ <polygon color="#dddddd"/>
+ </itemgra>
+ <itemgra item_types="poly_airport" order="0-">
+ <polygon color="#a0a0a0"/>
+ </itemgra>
+ <itemgra item_types="poly_sport,poly_sports_pitch" order="0-">
+ <polygon color="#4af04f"/>
+ </itemgra>
+ <itemgra item_types="poly_industry,poly_place" order="0-">
+ <polygon color="#e6e6e6"/>
+ </itemgra>
+ <itemgra item_types="poly_service" order="8-18">
+ <polygon color="#fefefe"/>
+ <polyline color="#d2d2d2" width="1"/>
+ </itemgra>
+ <itemgra item_types="poly_street_1" order="8-13">
+ <polygon color="#ffffff"/>
+ <polyline color="#d2d2d2" width="1"/>
+ </itemgra>
+ <itemgra item_types="poly_street_1" order="14-16">
+ <polygon color="#ffffff"/>
+ <polyline color="#d2d2d2" width="2"/>
+ </itemgra>
+ <itemgra item_types="poly_street_1" order="17-18">
+ <polygon color="#ffffff"/>
+ <polyline color="#d2d2d2" width="3"/>
+ </itemgra>
+ <itemgra item_types="poly_street_2" order="7-12">
+ <polygon color="#ffff00"/>
+ <polyline color="#c0c0c0" width="1"/>
+ </itemgra>
+ <itemgra item_types="poly_street_2" order="13-16">
+ <polygon color="#ffff00"/>
+ <polyline color="#c0c0c0" width="2"/>
+ </itemgra>
+ <itemgra item_types="poly_street_2" order="17-18">
+ <polygon color="#ffff00"/>
+ <polyline color="#c0c0c0" width="3"/>
+ </itemgra>
+ <itemgra item_types="poly_street_3" order="7-11">
+ <polygon color="#ffff00"/>
+ <polyline color="#a0a0a0" width="1"/>
+ </itemgra>
+ <itemgra item_types="poly_street_3" order="12-15">
+ <polygon color="#ffff00"/>
+ <polyline color="#a0a0a0" width="2"/>
+ </itemgra>
+ <itemgra item_types="poly_street_3" order="16-18">
+ <polygon color="#ffff00"/>
+ <polyline color="#a0a0a0" width="3"/>
+ </itemgra>
+ <itemgra item_types="poly_saltpond" order="10-">
+ <polygon color="#d7804a"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_water,poly_basin,poly_reservoir" order="0-">
+ <polygon color="#82c8ea"/>
+ <polyline color="#5096b8"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_line" order="0-">
+ <polyline color="#5096b8" width="1"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="4-5">
+ <polyline color="#82c8ea" width="1"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="6">
+ <polyline color="#82c8ea" width="2"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="7">
+ <polyline color="#82c8ea" width="3"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="8-9">
+ <polyline color="#82c8ea" width="4"/>
+ <text text_size="7"/>
+ </itemgra>
+ <itemgra item_types="water_river" order="10-">
+ <polyline color="#82c8ea" width="4"/>
+ <text text_size="10"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="6">
+ <polyline color="#82c8ea" width="1"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="7">
+ <polyline color="#82c8ea" width="2"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="8-9">
+ <polyline color="#82c8ea" width="3"/>
+ <text text_size="7"/>
+ </itemgra>
+ <itemgra item_types="water_canal" order="10-">
+ <polyline color="#82c8ea" width="3"/>
+ <text text_size="10"/>
+ </itemgra>
+ <itemgra item_types="water_stream" order="8-9">
+ <polyline color="#82c8ea" width="1"/>
+ </itemgra>
+ <itemgra item_types="water_stream" order="10-">
+ <polyline color="#82c8ea" width="2"/>
+ <text text_size="7"/>
+ </itemgra>
+ <itemgra item_types="water_drain" order="10-">
+ <polyline color="#82c8ea" width="1"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_apron" order="0-">
+ <polygon color="#d0d0d0"/>
+ </itemgra>
+ <itemgra item_types="poly_terminal" order="7-">
+ <polygon color="#e3c6a6"/>
+ </itemgra>
+ <itemgra item_types="poly_cemetery" order="1-">
+ <polygon color="#bde3cb"/>
+ </itemgra>
+ <itemgra item_types="poly_car_parking" order="1-">
+ <polygon color="#e7cf87"/>
+ </itemgra>
+ <itemgra item_types="poly_artwork" order="10-">
+ <polygon color="#fefbc5"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_sports_stadium" order="10-">
+ <polygon color="#6eb85d"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_sports_track" order="10-">
+ <polygon color="#b6554e"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_barracks" order="10-">
+ <polygon color="#b6a6a6"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_garages" order="10-">
+ <polygon color="#deddcc"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_building" order="0-">
+ <polygon color="#b6a6a6"/>
+ </itemgra>
+ <itemgra item_types="rail" order="6-">
+ <polyline color="#696969" width="3"/>
+ <polyline color="#ffffff" width="1" dash="5,5"/>
+ </itemgra>
+ <itemgra item_types="ferry" order="5-">
+ <polyline color="#000000" width="1" dash="10"/>
+ </itemgra>
+ <itemgra item_types="border_country" order="0-">
+ <polyline color="#b8434e" width="1" dash="10,5,2,5"/>
+ </itemgra>
+ <itemgra item_types="border_state" order="0-">
+ <polyline color="#808080" width="1"/>
+ </itemgra>
+ </layer>
+ <layer name="heightlines">
+ <itemgra item_types="height_line_1" order="7">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="height_line_1" order="8-">
+ <polyline color="#000000" width="3"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="height_line_2" order="8">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="height_line_2" order="9-">
+ <polyline color="#000000" width="2"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="height_line_3" order="9-11">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="height_line_3" order="12-">
+ <polyline color="#000000" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ </layer>
+ <layer name="streets">
+ <itemgra item_types="street_route" order="2">
+ <polyline color="#0000a0" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="3-5">
+ <polyline color="#0000a0" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="6">
+ <polyline color="#0000a0" width="10"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="7-8">
+ <polyline color="#0000a0" width="16"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="9-10">
+ <polyline color="#0000a0" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="11">
+ <polyline color="#0000a0" width="28"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="12">
+ <polyline color="#0000a0" width="32"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="13">
+ <polyline color="#0000a0" width="52"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="14">
+ <polyline color="#0000a0" width="64"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="15">
+ <polyline color="#0000a0" width="68"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="16">
+ <polyline color="#0000a0" width="132"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="17">
+ <polyline color="#0000a0" width="268"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="18">
+ <polyline color="#0000a0" width="530"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="2">
+ <polyline color="#ba00b8" width="4"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="3-5">
+ <polyline color="#ba00b8" width="8"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="6">
+ <polyline color="#ba00b8" width="10"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="7-8">
+ <polyline color="#ba00b8" width="16"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="9-10">
+ <polyline color="#ba00b8" width="20"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="11">
+ <polyline color="#ba00b8" width="28"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="12">
+ <polyline color="#ba00b8" width="32"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="13">
+ <polyline color="#ba00b8" width="52"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="14">
+ <polyline color="#ba00b8" width="64"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="15">
+ <polyline color="#ba00b8" width="68"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="16">
+ <polyline color="#ba00b8" width="132"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="17">
+ <polyline color="#ba00b8" width="268"/>
+ </itemgra>
+ <itemgra item_types="selected_line" order="18">
+ <polyline color="#ba00b8" width="530"/>
+ </itemgra>
+ <itemgra item_types="forest_way_1" order="10-">
+ <polyline color="#0070c0" width="6"/>
+ </itemgra>
+ <itemgra item_types="forest_way_2" order="10-">
+ <polyline color="#ff0000" width="3"/>
+ </itemgra>
+ <itemgra item_types="forest_way_3" order="10-">
+ <polyline color="#ff0000" width="1" dash="2,4"/>
+ </itemgra>
+ <itemgra item_types="forest_way_4" order="10-">
+ <polyline color="#119a2e" width="1" dash="4,10"/>
+ </itemgra>
+ <itemgra item_types="street_nopass" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_paved" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled,track_grass" order="10-12">
+ <polyline color="#800000" width="1" dash="3,6"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled,track_grass" order="13-14">
+ <polyline color="#ffffff" width="4"/>
+ <polyline color="#800000" width="1" dash="4,8"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled,track_grass" order="15-16">
+ <polyline color="#ffffff" width="5"/>
+ <polyline color="#800000" width="1" dash="5,10"/>
+ </itemgra>
+ <itemgra item_types="track_gravelled,track_grass" order="17-">
+ <polyline color="#ffffff" width="7"/>
+ <polyline color="#800000" width="1" dash="7,15"/>
+ </itemgra>
+ <itemgra item_types="track_unpaved,track_ground,path,hiking,hiking_mountain,hiking_mountain_demanding,hiking_alpine,hiking_alpine_demanding,hiking_alpine_difficult" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="bridleway" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="cycleway" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_novice" order="10-12">
+ <polyline color="#00A000" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_novice" order="13-14">
+ <polyline color="#00A000" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_novice" order="15-16">
+ <polyline color="#00A000" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_novice" order="17-">
+ <polyline color="#00A000" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_easy" order="10-12">
+ <polyline color="#0000ff" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_easy" order="13-14">
+ <polyline color="#0000ff" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_easy" order="15-16">
+ <polyline color="#0000ff" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_easy" order="17-">
+ <polyline color="#0000ff" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_intermediate" order="10-12">
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_intermediate" order="13-14">
+ <polyline color="#ff0000" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_intermediate" order="15-16">
+ <polyline color="#ff0000" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_intermediate" order="17-">
+ <polyline color="#ff0000" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_advanced" order="10-12">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_advanced" order="13-14">
+ <polyline color="#000000" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_advanced" order="15-16">
+ <polyline color="#000000" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_advanced" order="17-">
+ <polyline color="#000000" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_expert" order="10-12">
+ <polyline color="#ffaa00" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_expert" order="13-14">
+ <polyline color="#ffaa00" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_expert" order="15-16">
+ <polyline color="#ffaa00" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_expert" order="17-">
+ <polyline color="#ffaa00" width="5"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_freeride" order="10-12">
+ <polyline color="#ffff00" width="1"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_freeride" order="13-14">
+ <polyline color="#ffff00" width="2"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_freeride" order="15-16">
+ <polyline color="#ffff00" width="3"/>
+ </itemgra>
+ <itemgra item_types="piste_downhill_freeride" order="17-">
+ <polyline color="#ffff00" width="5"/>
+ </itemgra>
+ <itemgra item_types="lift_cable_car" order="6-">
+ <polyline color="#696969" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="lift_chair" order="6-">
+ <polyline color="#696969" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="lift_drag" order="6-">
+ <polyline color="#696969" width="1" dash="5"/>
+ </itemgra>
+ <itemgra item_types="piste_nordic" order="10-12">
+ <polyline color="#0000ff" width="1" dash="3,6" offset="4"/>
+ </itemgra>
+ <itemgra item_types="piste_nordic" order="13-14">
+ <polyline color="#ffffff" width="4" offset="6"/>
+ <polyline color="#0000ff" width="1" dash="4,8" offset="6"/>
+ </itemgra>
+ <itemgra item_types="piste_nordic" order="15-16">
+ <polyline color="#ffffff" width="5" offset="7"/>
+ <polyline color="#0000ff" width="1" dash="5,10" offset="7"/>
+ </itemgra>
+ <itemgra item_types="piste_nordic" order="17-">
+ <polyline color="#ffffff" width="7" offset="10"/>
+ <polyline color="#0000ff" width="1" dash="7,15" offset="10"/>
+ </itemgra>
+ <itemgra item_types="footway_and_piste_nordic" order="10-12">
+ <polyline color="#ff0000" width="1" dash="3,15"/>
+ <polyline color="#0000ff" width="1" dash="3,15" offset="9"/>
+ </itemgra>
+ <itemgra item_types="footway_and_piste_nordic" order="13-14">
+ <polyline color="#ffffff" width="4"/>
+ <polyline color="#ff0000" width="2"/>
+ <polyline color="#0000ff" width="1" dash="4,20" offset="12"/>
+ </itemgra>
+ <itemgra item_types="footway_and_piste_nordic" order="15-16">
+ <polyline color="#ffffff" width="5"/>
+ <polyline color="#ff0000" width="3"/>
+ <polyline color="#0000ff" width="1" dash="5,25" offset="15"/>
+ </itemgra>
+ <itemgra item_types="footway_and_piste_nordic" order="17-">
+ <polyline color="#ffffff" width="7"/>
+ <polyline color="#ff0000" width="5"/>
+ <polyline color="#0000ff" width="1" dash="7,37" offset="22"/>
+ </itemgra>
+ <itemgra item_types="footway" order="10-12">
+ <polyline color="#ff0000" width="1" dash="3,6"/>
+ </itemgra>
+ <itemgra item_types="footway" order="13-14">
+ <polyline color="#ffffff" width="4"/>
+ <polyline color="#ff0000" width="1" dash="4,8"/>
+ </itemgra>
+ <itemgra item_types="footway" order="15-16">
+ <polyline color="#ffffff" width="5"/>
+ <polyline color="#ff0000" width="1" dash="5,10"/>
+ </itemgra>
+ <itemgra item_types="footway" order="17-">
+ <polyline color="#ffffff" width="7"/>
+ <polyline color="#ff0000" width="1" dash="7,15"/>
+ </itemgra>
+ <itemgra item_types="steps" order="10-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="10">
+ <polyline color="#d2d2d2" width="3"/>
+ <polyline color="#dddddd" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="11">
+ <polyline color="#d2d2d2" width="5"/>
+ <polyline color="#dddddd" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="12">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#dddddd" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="13">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#dddddd" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="14">
+ <polyline color="#d2d2d2" width="13"/>
+ <polyline color="#dddddd" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="15">
+ <polyline color="#d2d2d2" width="18"/>
+ <polyline color="#dddddd" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="16">
+ <polyline color="#d2d2d2" width="21"/>
+ <polyline color="#dddddd" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="17">
+ <polyline color="#d2d2d2" width="25"/>
+ <polyline color="#dddddd" width="21"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="18">
+ <polyline color="#d2d2d2" width="40"/>
+ <polyline color="#dddddd" width="34"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="10">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#fefefe" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="11">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#fefefe" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="12">
+ <polyline color="#d2d2d2" width="5"/>
+ <polyline color="#fefefe" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="13">
+ <polyline color="#d2d2d2" width="6"/>
+ <polyline color="#fefefe" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="14">
+ <polyline color="#d2d2d2" width="7"/>
+ <polyline color="#fefefe" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="15">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#fefefe" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="16">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#fefefe" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="17">
+ <polyline color="#d2d2d2" width="10"/>
+ <polyline color="#fefefe" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_service" order="18">
+ <polyline color="#d2d2d2" width="11"/>
+ <polyline color="#fefefe" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="12">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#fefefe" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="13">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#fefefe" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="14">
+ <polyline color="#d2d2d2" width="5"/>
+ <polyline color="#fefefe" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="15">
+ <polyline color="#d2d2d2" width="6"/>
+ <polyline color="#fefefe" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="16">
+ <polyline color="#d2d2d2" width="7"/>
+ <polyline color="#fefefe" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="17">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#fefefe" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_parking_lane" order="18">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#fefefe" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="10">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#ffffff" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="11">
+ <polyline color="#d2d2d2" width="6"/>
+ <polyline color="#ffffff" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="12">
+ <polyline color="#d2d2d2" width="10"/>
+ <polyline color="#ffffff" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="13">
+ <polyline color="#d2d2d2" width="11"/>
+ <polyline color="#ffffff" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="14">
+ <polyline color="#d2d2d2" width="17"/>
+ <polyline color="#ffffff" width="13"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="15">
+ <polyline color="#d2d2d2" width="18"/>
+ <polyline color="#ffffff" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="16">
+ <polyline color="#d2d2d2" width="30"/>
+ <polyline color="#ffffff" width="26"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="17">
+ <polyline color="#d2d2d2" width="67"/>
+ <polyline color="#ffffff" width="61"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="18">
+ <polyline color="#d2d2d2" width="132"/>
+ <polyline color="#ffffff" width="126"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="7-8">
+ <polyline color="#c0c0c0" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="9">
+ <polyline color="#c0c0c0" width="3"/>
+ <polyline color="#ffff00" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="10">
+ <polyline color="#c0c0c0" width="4"/>
+ <polyline color="#ffff00" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="11">
+ <polyline color="#c0c0c0" width="5"/>
+ <polyline color="#ffff00" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="12">
+ <polyline color="#c0c0c0" width="7"/>
+ <polyline color="#ffff00" width="5"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="13">
+ <polyline color="#c0c0c0" width="11"/>
+ <polyline color="#ffff00" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="14">
+ <polyline color="#c0c0c0" width="14"/>
+ <polyline color="#ffff00" width="11"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="15">
+ <polyline color="#c0c0c0" width="19"/>
+ <polyline color="#ffff00" width="15"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="16">
+ <polyline color="#c0c0c0" width="30"/>
+ <polyline color="#ffff00" width="26"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="17">
+ <polyline color="#c0c0c0" width="63"/>
+ <polyline color="#ffff00" width="57"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,ramp" order="18">
+ <polyline color="#c0c0c0" width="100"/>
+ <polyline color="#ffff00" width="90"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="7-8">
+ <polyline color="#a0a0a0" width="3"/>
+ <polyline color="#ffff00" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="9">
+ <polyline color="#a0a0a0" width="5"/>
+ <polyline color="#ffff00" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="10">
+ <polyline color="#a0a0a0" width="8"/>
+ <polyline color="#ffff00" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="11">
+ <polyline color="#a0a0a0" width="9"/>
+ <polyline color="#ffff00" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="12">
+ <polyline color="#a0a0a0" width="13"/>
+ <polyline color="#ffff00" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="13">
+ <polyline color="#a0a0a0" width="18"/>
+ <polyline color="#ffff00" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="14">
+ <polyline color="#a0a0a0" width="21"/>
+ <polyline color="#ffff00" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="15">
+ <polyline color="#a0a0a0" width="25"/>
+ <polyline color="#ffff00" width="21"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="16">
+ <polyline color="#a0a0a0" width="40"/>
+ <polyline color="#ffff00" width="34"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="17">
+ <polyline color="#a0a0a0" width="79"/>
+ <polyline color="#ffff00" width="73"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,roundabout" order="18">
+ <polyline color="#a0a0a0" width="156"/>
+ <polyline color="#ffff00" width="150"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="2-6">
+ <polyline color="#404040" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="7-8">
+ <polyline color="#404040" width="3"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="9">
+ <polyline color="#000000" width="5"/>
+ <polyline color="#ff0000" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="10">
+ <polyline color="#000000" width="6"/>
+ <polyline color="#ff0000" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11">
+ <polyline color="#000000" width="9"/>
+ <polyline color="#ff0000" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="12">
+ <polyline color="#000000" width="13"/>
+ <polyline color="#ff0000" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="13">
+ <polyline color="#000000" width="18"/>
+ <polyline color="#ff0000" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="14">
+ <polyline color="#000000" width="21"/>
+ <polyline color="#ff0000" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="15">
+ <polyline color="#000000" width="24"/>
+ <polyline color="#ff0000" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="16">
+ <polyline color="#000000" width="39"/>
+ <polyline color="#ff0000" width="33"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="17">
+ <polyline color="#000000" width="78"/>
+ <polyline color="#ff0000" width="72"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="18">
+ <polyline color="#000000" width="156"/>
+ <polyline color="#ff0000" width="150"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="2">
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="3-5">
+ <polyline color="#ff0000" width="3"/>
+ <polyline color="#ffff00" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="6">
+ <polyline color="#ff0000" width="4"/>
+ <polyline color="#ffff00" width="2"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="7-8">
+ <polyline color="#ff0000" width="7"/>
+ <polyline color="#ffff00" width="5"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="9-10">
+ <polyline color="#ff0000" width="9"/>
+ <polyline color="#ffff00" width="5"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="11">
+ <polyline color="#ff0000" width="13"/>
+ <polyline color="#ffff00" width="9"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="12">
+ <polyline color="#ff0000" width="15"/>
+ <polyline color="#ffff00" width="10"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="13">
+ <polyline color="#ff0000" width="25"/>
+ <polyline color="#ffff00" width="17"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="14">
+ <polyline color="#ff0000" width="31"/>
+ <polyline color="#ffff00" width="24"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="15">
+ <polyline color="#ff0000" width="33"/>
+ <polyline color="#ffff00" width="27"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="16">
+ <polyline color="#ff0000" width="65"/>
+ <polyline color="#ffff00" width="59"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="17">
+ <polyline color="#ff0000" width="133"/>
+ <polyline color="#ffff00" width="127"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="18">
+ <polyline color="#ff0000" width="264"/>
+ <polyline color="#ffff00" width="258"/>
+ <polyline color="#ff0000" width="1"/>
+ </itemgra>
+ <itemgra item_types="tracking_0" order="0-">
+ <polyline color="#000000" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_10" order="0-">
+ <polyline color="#191919" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_20" order="0-">
+ <polyline color="#333333" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_30" order="0-">
+ <polyline color="#4c4c4c" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_40" order="0-">
+ <polyline color="#666666" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_50" order="0-">
+ <polyline color="#7f7f7f" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_60" order="0-">
+ <polyline color="#999999" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_70" order="0-">
+ <polyline color="#b2b2b2" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_80" order="0-">
+ <polyline color="#cccccc" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_90" order="0-">
+ <polyline color="#e5e5e5" width="3"/>
+ </itemgra>
+ <itemgra item_types="tracking_100" order="0-">
+ <polyline color="#ffffff" width="3"/>
+ </itemgra>
+ <itemgra item_types="highway_exit_label" order="10-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street" order="10-18">
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp" order="11-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land,footway" order="12-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="2">
+ <polyline color="#ff9000" width="2"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="3-5">
+ <polyline color="#ff9000" width="4"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="6">
+ <polyline color="#ff9000" width="5"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="7-8">
+ <polyline color="#ff9000" width="8"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="9-10">
+ <polyline color="#ff9000" width="10"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="11">
+ <polyline color="#ff9000" width="14"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="12">
+ <polyline color="#ff9000" width="16"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="13">
+ <polyline color="#ff9000" width="26"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="14">
+ <polyline color="#ff9000" width="32"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="15">
+ <polyline color="#ff9000" width="34"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="16">
+ <polyline color="#ff9000" width="66"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="17">
+ <polyline color="#ff9000" width="134"/>
+ </itemgra>
+ <itemgra item_types="traffic_distortion" order="18">
+ <polyline color="#ff9000" width="265"/>
+ </itemgra>
+ </layer>
+ <layer name="polylines">
+ <itemgra item_types="aeroway_taxiway" order="10">
+ <polyline color="#989994" width="4"/>
+ <polyline color="#d3dbbc" width="2"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="11">
+ <polyline color="#989994" width="6"/>
+ <polyline color="#d3dbbc" width="4"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="12">
+ <polyline color="#989994" width="10"/>
+ <polyline color="#d3dbbc" width="8"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="13">
+ <polyline color="#989994" width="12"/>
+ <polyline color="#d3dbbc" width="9"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="14">
+ <polyline color="#989994" width="15"/>
+ <polyline color="#d3dbbc" width="13"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="15">
+ <polyline color="#989994" width="17"/>
+ <polyline color="#d3dbbc" width="14"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="16">
+ <polyline color="#989994" width="33"/>
+ <polyline color="#d3dbbc" width="26"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="17">
+ <polyline color="#989994" width="69"/>
+ <polyline color="#d3dbbc" width="61"/>
+ </itemgra>
+ <itemgra item_types="aeroway_taxiway" order="18">
+ <polyline color="#989994" width="132"/>
+ <polyline color="#d3dbbc" width="126"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="2-6">
+ <polyline color="#404040" width="1"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="7-8">
+ <polyline color="#404040" width="3"/>
+ <polyline color="#d3dbbc" width="1"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="9">
+ <polyline color="#6b6f5f" width="5"/>
+ <polyline color="#d3dbbc" width="3"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="10">
+ <polyline color="#6b6f5f" width="6"/>
+ <polyline color="#d3dbbc" width="4"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="11">
+ <polyline color="#6b6f5f" width="9"/>
+ <polyline color="#d3dbbc" width="7"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="12">
+ <polyline color="#6b6f5f" width="13"/>
+ <polyline color="#d3dbbc" width="9"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="13">
+ <polyline color="#6b6f5f" width="18"/>
+ <polyline color="#d3dbbc" width="14"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="14">
+ <polyline color="#6b6f5f" width="21"/>
+ <polyline color="#d3dbbc" width="17"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="15">
+ <polyline color="#6b6f5f" width="24"/>
+ <polyline color="#d3dbbc" width="20"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="16">
+ <polyline color="#6b6f5f" width="39"/>
+ <polyline color="#d3dbbc" width="33"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="17">
+ <polyline color="#6b6f5f" width="78"/>
+ <polyline color="#d3dbbc" width="72"/>
+ </itemgra>
+ <itemgra item_types="aeroway_runway" order="18">
+ <polyline color="#6b6f5f" width="156"/>
+ <polyline color="#d3dbbc" width="150"/>
+ </itemgra>
+ <itemgra item_types="rail_tram" order="10-">
+ <polyline color="#606060" width="2"/>
+ </itemgra>
+ </layer>
+ <layer name="labels">
+ <itemgra item_types="house_number" order="15-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="11-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3" order="10-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e3,place_label" order="10-">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4" order="9-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_2e3" order="9-">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_5e3,town_label_1e4,town_label_2e4,town_label_5e4" order="9-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5" order="8-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_2e3" order="8">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6,district_label_1e7" order="7-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_5e3" order="7-8">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e4" order="6-8">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_2e4,town_label_5e4" order="5-8">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="5-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7" order="5-">
+ <circle color="#000000" radius="3" text_size="20"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="3-4">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7" order="3-4">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7" order="0-2">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ </layer>
+ <layer name="Internal">
+ <itemgra item_types="track" order="7-">
+ <polyline color="#3f3f3f" width="1"/>
+ </itemgra>
+ <itemgra item_types="track_tracked" order="7-">
+ <polyline color="#3f3fff" width="3"/>
+ </itemgra>
+ <itemgra item_types="rg_segment" order="12-">
+ <polyline color="#FF089C" width="1"/>
+ <arrows color="#FF089C" width="1"/>
+ <text text_size="15"/>
+ </itemgra>
+ <itemgra item_types="rg_point" order="12-">
+ <circle color="#FF089C" radius="10" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="nav_left_1" order="0-">
+ <icon src="nav_left_1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_left_2" order="0-">
+ <icon src="nav_left_2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_left_3" order="0-">
+ <icon src="nav_left_3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_1" order="0-">
+ <icon src="nav_right_1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_2" order="0-">
+ <icon src="nav_right_2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_right_3" order="0-">
+ <icon src="nav_right_3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_straight" order="0-">
+ <icon src="nav_straight_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_turnaround_left" order="0-">
+ <icon src="nav_turnaround_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_turnaround_right" order="0-">
+ <icon src="nav_turnaround_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l1" order="0-">
+ <icon src="nav_roundabout_l1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r1" order="0-">
+ <icon src="nav_roundabout_r1_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l2" order="0-">
+ <icon src="nav_roundabout_l2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r2" order="0-">
+ <icon src="nav_roundabout_r2_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l3" order="0-">
+ <icon src="nav_roundabout_l3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r3" order="0-">
+ <icon src="nav_roundabout_r3_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l4" order="0-">
+ <icon src="nav_roundabout_l4_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r4" order="0-">
+ <icon src="nav_roundabout_r4_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l5" order="0-">
+ <icon src="nav_roundabout_l5_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r5" order="0-">
+ <icon src="nav_roundabout_r5_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l6" order="0-">
+ <icon src="nav_roundabout_l6_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r6" order="0-">
+ <icon src="nav_roundabout_r6_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l7" order="0-">
+ <icon src="nav_roundabout_l7_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r7" order="0-">
+ <icon src="nav_roundabout_r7_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_l8" order="0-">
+ <icon src="nav_roundabout_l8_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_roundabout_r8" order="0-">
+ <icon src="nav_roundabout_r8_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_keep_left" order="0-">
+ <icon src="nav_keep_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_merge_left" order="0-">
+ <icon src="nav_merge_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_keep_right" order="0-">
+ <icon src="nav_keep_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_merge_right" order="0-">
+ <icon src="nav_merge_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_exit_left" order="0-">
+ <icon src="nav_exit_left_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="nav_exit_right" order="0-">
+ <icon src="nav_exit_right_bk.svg" w="32" h="32"/>
+ </itemgra>
+ <itemgra item_types="route_end" order="0-">
+ <icon src="nav_destination_bk.svg" w="32" h="32" x="4" y="30"/>
+ </itemgra>
+ <itemgra item_types="nav_none" order="0-">
+ <icon src="unknown.svg"/>
+ </itemgra>
+ <itemgra item_types="announcement" order="7-">
+ <icon src="gui_sound_32_32.png"/>
+ <circle color="#FF089C" radius="10" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="2">
+ <circle color="#008080" radius="4" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="3-5">
+ <circle color="#008080" radius="8" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="6">
+ <circle color="#008080" radius="10" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="7-8">
+ <circle color="#008080" radius="16" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="9-10">
+ <circle color="#008080" radius="20" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="11">
+ <circle color="#008080" radius="28" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="12">
+ <circle color="#008080" radius="32" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="13">
+ <circle color="#008080" radius="52" width="4" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="14">
+ <circle color="#008080" radius="64" width="4" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="15">
+ <circle color="#008080" radius="68" width="6" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="16">
+ <circle color="#008080" radius="132" width="8" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="17">
+ <circle color="#008080" radius="268" width="8" text_size="48"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="18">
+ <circle color="#008080" radius="530" width="8" text_size="48"/>
+ </itemgra>
+ </layer>
+ <layer name="Unknown" enabled="no">
+ <!-- This entry shows all unknow point elements as blue circles -->
+ <itemgra item_types="point_unkn" order="9-">
+ <circle color="#8080ff" radius="3"/>
+ </itemgra>
+ <!-- This entry shows all unknown linear elements as blue lines -->
+ <itemgra item_types="street_unkn" order="0-">
+ <polyline color="#8080ff" width="3"/>
+ </itemgra>
+ </layer>
+ <layer name="POI Symbols">
+ <itemgra item_types="mini_roundabout" order="12-">
+ <icon src="mini_roundabout.png"/>
+ </itemgra>
+ <itemgra item_types="turning_circle" order="12-">
+ <icon src="mini_roundabout.png"/>
+ </itemgra>
+ <itemgra item_types="poi_airport" order="5-">
+ <icon src="airport.png"/>
+ </itemgra>
+ <itemgra item_types="town_ghost" order="10-">
+ <icon src="ghost_town.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_hotel" order="12-">
+ <icon src="hotel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_parking" order="11-">
+ <icon src="parking.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_dealer_parts" order="12-">
+ <icon src="car_dealer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_sharing" order="11-">
+ <icon src="car_sharing.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fuel" order="12-">
+ <icon src="fuel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shopping" order="12-">
+ <icon src="shopping.png"/>
+ </itemgra>
+ <itemgra item_types="poi_attraction" order="11-">
+ <icon src="attraction.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cafe" order="12-">
+ <icon src="cafe.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bar" order="12-">
+ <icon src="bar.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pub" order="12-">
+ <icon src="beer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bridge" order="12-">
+ <icon src="bridge.xpm"/>
+ </itemgra>
+ <itemgra item_types="highway_exit" order="11-">
+ <icon src="exit.png"/>
+ </itemgra>
+ <itemgra item_types="poi_camp_rv" order="12-">
+ <icon src="camping.png"/>
+ </itemgra>
+ <itemgra item_types="poi_museum_history" order="12-">
+ <icon src="museum.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hospital" order="12-">
+ <icon src="hospital.png"/>
+ </itemgra>
+ <itemgra item_types="poi_dining" order="12-">
+ <icon src="restaurant.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fastfood" order="12-">
+ <icon src="fastfood.png"/>
+ </itemgra>
+ <itemgra item_types="poi_police" order="12-">
+ <icon src="police.png"/>
+ </itemgra>
+ <itemgra item_types="poi_auto_club" order="12-">
+ <icon src="auto_club.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_autoservice" order="12-">
+ <icon src="car_dealer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bank" order="12-">
+ <icon src="bank.png"/>
+ </itemgra>
+ <itemgra item_types="poi_atm" order="12-">
+ <icon src="atm.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bay" order="12-">
+ <icon src="bay.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_bend" order="12-">
+ <icon src="bend.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_boat_ramp" order="12-">
+ <icon src="boat_ramp.png"/>
+ </itemgra>
+ <itemgra item_types="poi_border_station" order="12-">
+ <icon src="border_station.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_bowling" order="12-">
+ <icon src="bowling.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_bus_station" order="11-">
+ <icon src="bus.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bus_stop" order="12-">
+ <icon src="bus_stop.png"/>
+ </itemgra>
+ <itemgra item_types="poi_business_service" order="12-">
+ <icon src="bussines_service.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_car_rent" order="12-">
+ <icon src="car_rent.png"/>
+ </itemgra>
+ <itemgra item_types="poi_car_wash" order="12-">
+ <icon src="car_wash.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_casino" order="12-">
+ <icon src="casino.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cemetery" order="12-">
+ <icon src="cemetery.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_church" order="11-">
+ <icon src="church.png"/>
+ </itemgra>
+ <itemgra item_types="poi_bahai" order="11-">
+ <icon src="bahai.png"/>
+ </itemgra>
+ <itemgra item_types="poi_buddhist" order="11-">
+ <icon src="buddhist.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hindu" order="11-">
+ <icon src="hindu.png"/>
+ </itemgra>
+ <itemgra item_types="poi_islamic" order="11-">
+ <icon src="islamic.png"/>
+ </itemgra>
+ <itemgra item_types="poi_jain" order="11-">
+ <icon src="jain.png"/>
+ </itemgra>
+ <itemgra item_types="poi_jewish" order="11-">
+ <icon src="jewish.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pagan" order="11-">
+ <icon src="pagan.png"/>
+ </itemgra>
+ <itemgra item_types="poi_pastafarian" order="11-">
+ <icon src="pastafarian.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shinto" order="11-">
+ <icon src="shinto.png"/>
+ </itemgra>
+ <itemgra item_types="poi_sikh" order="11-">
+ <icon src="sikh.png"/>
+ </itemgra>
+ <itemgra item_types="poi_taoist" order="11-">
+ <icon src="taoist.png"/>
+ </itemgra>
+ <itemgra item_types="poi_cinema" order="12-">
+ <icon src="cinema.png"/>
+ </itemgra>
+ <itemgra item_types="poi_communication" order="12-">
+ <icon src="communication.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_concert" order="12-">
+ <icon src="concert.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_cove" order="12-">
+ <icon src="cove.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_crossing" order="12-">
+ <icon src="crossing.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_dam" order="12-">
+ <icon src="dam.png"/>
+ </itemgra>
+ <itemgra item_types="poi_danger_area" order="12-">
+ <icon src="danger_16_16.png"/>
+ </itemgra>
+ <itemgra item_types="poi_danger_sea_wreck" order="12-">
+ <icon src="dangerous.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_daymark" order="12-">
+ <icon src="daymark.png"/>
+ </itemgra>
+ <itemgra item_types="poi_diving" order="12-">
+ <icon src="diving.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_drinking_water" order="13-">
+ <icon src="drinking_water.png"/>
+ </itemgra>
+ <itemgra item_types="poi_emergency" order="12-">
+ <icon src="emergency.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fair" order="12-">
+ <icon src="fair.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_firebrigade" order="12-">
+ <icon src="firebrigade.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fish" order="9-">
+ <icon src="fish.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_forbidden_area" order="12-">
+ <icon src="forbidden_area.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_bicycle" order="12-">
+ <icon src="bicycle_shop.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_gps" order="15-">
+ <icon src="garmin.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_golf" order="12-">
+ <icon src="golf.png"/>
+ </itemgra>
+ <itemgra item_types="poi_government_building" order="12-">
+ <icon src="government_building.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_height" order="12-">
+ <icon src="height.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_heliport" order="8-">
+ <icon src="heliport.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hotspring" order="12-">
+ <icon src="hotspring.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_icesport" order="12-">
+ <icon src="icesport.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_information" order="12-">
+ <icon src="information.png"/>
+ </itemgra>
+ <itemgra item_types="poi_justice" order="12-">
+ <icon src="justice.png"/>
+ </itemgra>
+ <itemgra item_types="poi_landmark" order="11-">
+ <icon src="landmark.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_levee" order="12-">
+ <icon src="levee.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_level_crossing" order="11-">
+ <icon src="level_crossing.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_library" order="12-">
+ <icon src="library.png"/>
+ </itemgra>
+ <itemgra item_types="poi_locale" order="12-">
+ <icon src="locale.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_loudspeaker" order="12-">
+ <icon src="loudspeaker.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_mall" order="12-">
+ <icon src="mall.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_manmade_feature" order="12-">
+ <icon src="manmade_feature.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_marine" order="12-">
+ <icon src="marine.png"/>
+ </itemgra>
+ <itemgra item_types="poi_marine_type" order="12-">
+ <icon src="marine_type.png"/>
+ </itemgra>
+ <itemgra item_types="poi_mark" order="12-">
+ <icon src="mark.png"/>
+ </itemgra>
+ <itemgra item_types="poi_military" order="11-">
+ <icon src="military.png"/>
+ </itemgra>
+ <itemgra item_types="poi_mine" order="12-">
+ <icon src="mine.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_nondangerous" order="12-">
+ <icon src="nondangerous.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_oil_field" order="12-">
+ <icon src="oil_field.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_peak" order="7-">
+ <icon src="peak.png"/>
+ </itemgra>
+ <itemgra item_types="poi_personal_service" order="12-">
+ <icon src="personal_service.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_pharmacy" order="12-">
+ <icon src="pharmacy.png"/>
+ </itemgra>
+ <itemgra item_types="poi_post_office,poi_post_box" order="13-">
+ <icon src="post.png"/>
+ </itemgra>
+ <itemgra item_types="poi_public_office" order="12-">
+ <icon src="public_office.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_halt" order="11-">
+ <circle color="#ff0000" radius="3" width="3"/>
+ <circle color="#000000" radius="5" width="2" text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_station" order="9-">
+ <circle color="#ff0000" radius="3" width="3"/>
+ <circle color="#000000" radius="6" width="2" text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_tram_stop" order="10-11">
+ <circle color="#ff0000" radius="2" width="2"/>
+ </itemgra>
+ <itemgra item_types="poi_rail_tram_stop" order="12-">
+ <circle color="#ff0000" radius="3" width="3"/>
+ <circle color="#606060" radius="5" width="2" text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poi_repair_service" order="12-">
+ <icon src="repair_service.png"/>
+ </itemgra>
+ <itemgra item_types="poi_resort" order="12-">
+ <icon src="resort.png"/>
+ </itemgra>
+ <itemgra item_types="poi_restaurant" order="12-">
+ <icon src="restaurant.png"/>
+ </itemgra>
+ <itemgra item_types="poi_restricted_area" order="12-">
+ <icon src="restricted_area.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_restroom" order="13-">
+ <icon src="toilets.png"/>
+ </itemgra>
+ <itemgra item_types="poi_sailing" order="12-">
+ <icon src="sailing.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_scenic_area" order="12-">
+ <icon src="scenic_area.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_school" order="12-">
+ <icon src="school.png"/>
+ </itemgra>
+ <itemgra item_types="poi_service" order="12-">
+ <icon src="service.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_apparel" order="12-">
+ <icon src="shop_apparel.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_computer" order="12-">
+ <icon src="shop_computer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_department" order="12-">
+ <icon src="shop_department.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_furniture" order="12-">
+ <icon src="shop_furnish.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_grocery" order="12-">
+ <icon src="shop_grocery.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_handg" order="12-">
+ <icon src="shop_handg.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_merchandise" order="12-">
+ <icon src="shop_merchandise.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shop_retail" order="12-">
+ <icon src="shop_retail.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_shower" order="13-">
+ <icon src="shower.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_skiing" order="11-">
+ <icon src="skiing.png"/>
+ </itemgra>
+ <itemgra item_types="poi_social_service" order="12-">
+ <icon src="social_service.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_sounding" order="12-">
+ <icon src="sounding.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_sport" order="12-">
+ <icon src="sport.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_stadium" order="11-">
+ <icon src="stadium.png"/>
+ </itemgra>
+ <itemgra item_types="poi_swimming" order="12-">
+ <icon src="swimming.png"/>
+ </itemgra>
+ <itemgra item_types="poi_telephone" order="13-">
+ <icon src="telephone.png"/>
+ </itemgra>
+ <itemgra item_types="poi_theater" order="12-">
+ <icon src="theater.png"/>
+ </itemgra>
+ <itemgra item_types="poi_tide" order="12-">
+ <icon src="tide.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_tower" order="13-">
+ <icon src="tower.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_townhall" order="12-">
+ <icon src="townhall.png"/>
+ </itemgra>
+ <itemgra item_types="poi_trail" order="12-">
+ <icon src="trail.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_truck_stop" order="12-">
+ <icon src="truck_stop.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_tunnel" order="12-">
+ <icon src="tunnel.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_wine" order="12-">
+ <icon src="wine.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_worship" order="8-">
+ <icon src="worship.png"/>
+ </itemgra>
+ <itemgra item_types="poi_wrecker" order="12-">
+ <icon src="wrecker.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_zoo" order="9-">
+ <icon src="zoo.png"/>
+ </itemgra>
+ <itemgra item_types="poi_picnic" order="12-">
+ <icon src="picnic.png"/>
+ </itemgra>
+ <itemgra item_types="poi_playground" order="12-">
+ <icon src="playground.png"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_multi" order="12-">
+ <icon src="gc_multi.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_tradi" order="12-">
+ <icon src="gc_tradi.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_event" order="12-">
+ <icon src="gc_event.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_mystery" order="12-">
+ <icon src="gc_mystery.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_question" order="12-">
+ <icon src="gc_question.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_stages" order="12-">
+ <icon src="gc_stages.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_reference" order="12-">
+ <icon src="gc_reference.xpm"/>
+ </itemgra>
+ <itemgra item_types="poi_gc_webcam" order="12-">
+ <icon src="gc_webcam.xpm"/>
+ </itemgra>
+ <itemgra item_types="traffic_signals" order="13-">
+ <icon src="traffic_signals.png"/>
+ </itemgra>
+ <itemgra item_types="poi_wifi" order="13-">
+ <icon src="wifi.png"/>
+ </itemgra>
+ <itemgra item_types="poi_taxi" order="13-">
+ <icon src="taxi.png"/>
+ </itemgra>
+ <itemgra item_types="poi_image" order="12-">
+ <image/>
+ </itemgra>
+ <!-- I'm not sure if the following stuff should appear in any layout. Maybe portions should only apply to the bicyle layout. -->
+ <itemgra item_types="poi_bench" order="13-">
+ <icon src="bench.png"/>
+ </itemgra>
+ <itemgra item_types="poi_biergarten" order="12-">
+ <icon src="beer.png"/>
+ </itemgra>
+ <itemgra item_types="poi_boundary_stone" order="13-">
+ <icon src="boundary_stone.png"/>
+ </itemgra>
+ <itemgra item_types="poi_castle" order="11-">
+ <icon src="castle.png"/>
+ </itemgra>
+ <itemgra item_types="poi_ruins" order="11-">
+ <icon src="ruins.png"/>
+ </itemgra>
+ <itemgra item_types="poi_hunting_stand" order="12-">
+ <icon src="hunting_stand.png"/>
+ </itemgra>
+ <itemgra item_types="poi_memorial" order="12-">
+ <icon src="memorial.png"/>
+ </itemgra>
+ <itemgra item_types="poi_monument" order="12-">
+ <icon src="memorial.png"/>
+ </itemgra>
+ <itemgra item_types="poi_shelter" order="11-">
+ <icon src="shelter.png"/>
+ </itemgra>
+ <itemgra item_types="poi_fountain" order="13-">
+ <icon src="fountain.png"/>
+ </itemgra>
+ <itemgra item_types="poi_potable_water" order="13-">
+ <icon src="drinking_water.png"/>
+ </itemgra>
+ <itemgra item_types="poi_toilets" order="12-">
+ <icon src="toilets.png"/>
+ </itemgra>
+ <itemgra item_types="poi_viewpoint" order="10-">
+ <icon src="viewpoint.png"/>
+ </itemgra>
+ <itemgra item_types="tec_common" order="11-">
+ <icon src="tec_common.png"/>
+ </itemgra>
+ <itemgra item_types="vehicle" order="0-">
+ <icon src="gui_vehicle_16_16.png"/>
+ </itemgra>
+ <itemgra item_types="vehicle_pedestrian" order="0-">
+ <icon src="gui_vehicle_pedestrian_16_16.png"/>
+ </itemgra>
+ <itemgra item_types="poi_custom0,poi_custom1,poi_custom2,poi_custom3,poi_custom4,poi_custom5,poi_custom6,poi_custom7,poi_custom8,poi_custom9,poi_customa,poi_customb,poi_customc,poi_customd,poi_custome,poi_customf" order="10-">
+ <icon src="%s"/>
+ </itemgra>
+ </layer>
+ <layer name="POI Labels">
+ <itemgra item_types="poi_airport,town_ghost,poi_hotel,poi_car_parking,poi_car_dealer_parts,poi_car_sharing,poi_fuel,poi_shopping,poi_attraction,poi_cafe,poi_bar,poi_pub,highway_exit,poi_camp_rv,poi_museum_history,poi_hospital,poi_dining,poi_fastfood,poi_police,poi_autoservice,poi_bank,poi_atm,poi_bus_station,poi_bus_stop,poi_business_service,poi_car_rent,poi_church,poi_bahai,poi_buddhist,poi_hindu,poi_islamic,poi_jain,poi_jewish,poi_pagan,poi_pastafarian,poi_shinto,poi_sikh,poi_taoist,poi_cinema,poi_concert,poi_drinking_water,poi_emergency,poi_fair,poi_fish,poi_government_building,poi_hotspring,poi_information,poi_justice,poi_landmark,poi_library,poi_mall,poi_manmade_feature,poi_marine,poi_marine_type,poi_mark,poi_oil_field,poi_peak,poi_personal_service,poi_pharmacy,poi_post_office,poi_public_office,poi_rail_halt,poi_rail_station,poi_rail_tram_stop,poi_repair_service,poi_resort,poi_restaurant,poi_restricted_area,poi_sailing,poi_scenic_area,poi_school,poi_service,poi_shop_bicycle,poi_shop_retail,poi_skiing,poi_social_service,poi_sport,poi_stadium,poi_swimming,poi_theater,poi_townhall,poi_trail,poi_truck_stop,poi_tunnel,poi_worship,poi_wrecker,poi_zoo,poi_biergarten,poi_castle,poi_ruins,poi_memorial,poi_monument,poi_shelter,poi_fountain,poi_viewpoint,vehicle" order="14-">
+ <circle color="#606060" radius="0" width="0" text_size="10"/>
+ </itemgra>
+ <itemgra item_types="poi_custom0,poi_custom1,poi_custom2,poi_custom3,poi_custom4,poi_custom5,poi_custom6,poi_custom7,poi_custom8,poi_custom9,poi_customa,poi_customb,poi_customc,poi_customd,poi_custome,poi_customf" order="14-">
+ <circle color="#606060" radius="0" width="0" text_size="10"/>
+ </itemgra>
+ </layer>
+ <layer name="Found items" ref="Found items"/>
+</layout>
diff --git a/navit/navit_layout_car_simple_shipped.xml b/navit/navit_layout_car_simple_shipped.xml
new file mode 100644
index 000000000..4029833f5
--- /dev/null
+++ b/navit/navit_layout_car_simple_shipped.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0"?>
+<layout xmlns:xi="http://www.w3.org/2001/XInclude" name="Car-simple" color="#839ea9">
+ <layer name="polygon">
+ <itemgra item_types="poly_town" order="8-">
+ <polygon color="#6b8091"/>
+ </itemgra>
+ </layer>
+ <layer name="streets">
+ <itemgra item_types="water_line" order="11-">
+ <polyline width="3" color="#5e71a7"/>
+ </itemgra>
+ <itemgra item_types="rail" order="9-">
+ <polyline width="4" color="#a4bac8"/>
+ <polyline width="1" color="#e0e0e0" dash="4,6"/>
+ </itemgra>
+ <itemgra item_types="street_1_city,street_1_land" order="12-">
+ <polyline width="5" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="12-">
+ <polyline width="7" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_1_city,street_1_land" order="11">
+ <polyline width="3" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="9-11">
+ <polyline width="5" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="11-">
+ <polyline width="9" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="8-10">
+ <polyline width="7" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11-">
+ <polyline width="9" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="8-10">
+ <polyline width="7" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="6-7">
+ <polyline width="3" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="4-">
+ <polyline width="9" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_route">
+ <polyline width="11" color="#516170"/>
+ </itemgra>
+ <itemgra item_types="street_1_city,street_1_land" order="12-">
+ <polyline width="3" color="#a4bac8"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="12-">
+ <polyline width="5" color="#90a3af"/>
+ </itemgra>
+ <itemgra item_types="street_1_city,street_1_land" order="11">
+ <polyline width="1" color="#a4bac8"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="9-11">
+ <polyline width="3" color="#90a3af"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="11-">
+ <polyline width="6" color="#a4bac8"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="8-10">
+ <polyline width="4" color="#a4bac8"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11-">
+ <polyline width="6" color="#c7e1f2"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="8-10">
+ <polyline width="4" color="#c7e1f2"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="6-7">
+ <polyline width="1" color="#c7e1f2"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="4-">
+ <polyline width="3" color="#c0e1ff"/>
+ </itemgra>
+ <itemgra item_types="street_route">
+ <polyline width="9" color="#ffffff"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end">
+ <circle color="#000000" radius="8" width="2" text_size="24"/>
+ </itemgra>
+ </layer>
+ <layer name="labels">
+ <itemgra item_types="water_line" order="11-">
+ <text text_size="16" color="#0000ff"/>
+ </itemgra>
+ <itemgra item_types="street_1_city,street_2_city,street_3_city,street_4_city,highway_city,street_1_land,street_2_land,street_3_land,street_4_land,street_n_lanes,highway_land,living_street,footway">
+ <text text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="10-">
+ <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e3,town_label_2e3,district_label_1e3,district_label_2e3" order="9-">
+ <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="town_label_5e3,district_label_5e3" order="8-">
+ <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e4,district_label_1e4" order="7-">
+ <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="town_label_2e4,district_label_2e4" order="6-">
+ <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="town_label_5e4,town_label_1e5,district_label_5e4,district_label_1e5" order="5-">
+ <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="town_label_2e5,district_label_2e5" order="4-">
+ <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="town_label_5e5,district_label_5e5" order="2-">
+ <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7,district_label_1e6,district_label_2e6,district_label_5e6,district_label_1e7">
+ <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
+ </itemgra>
+ </layer>
+ <layer name="Found items" ref="Found items"/>
+</layout>
diff --git a/navit/navit_layout_th_shipped.xml b/navit/navit_layout_th_shipped.xml
new file mode 100644
index 000000000..aebc79d6e
--- /dev/null
+++ b/navit/navit_layout_th_shipped.xml
@@ -0,0 +1,547 @@
+<?xml version="1.0"?>
+<layout xmlns:xi="http://www.w3.org/2001/XInclude" name="T@H" font="Liberation Sans">
+ <cursor w="26" h="26">
+ <itemgra>
+ <circle color="#0000ff" radius="24" width="2">
+ <coord x="0" y="0"/>
+ </circle>
+ </itemgra>
+ <itemgra speed_range="-2">
+ <polyline color="#0000ff" width="2">
+ <coord x="0" y="0"/>
+ <coord x="0" y="0"/>
+ </polyline>
+ </itemgra>
+ <itemgra speed_range="3-">
+ <polyline color="#0000ff" width="2">
+ <coord x="-7" y="-10"/>
+ <coord x="0" y="12"/>
+ <coord x="7" y="-10"/>
+ </polyline>
+ </itemgra>
+ </cursor>
+ <layer name="sea" details="0">
+ <!-- landuse=forest -->
+ <itemgra item_types="poly_wood" order="0-">
+ <polygon color="#72bf81"/>
+ </itemgra>
+ <itemgra item_types="poly_flats,poly_scrub,poly_military_zone,poly_marine,plantation,tundra" order="0-">
+ <polygon color="#a0a0a0"/>
+ <text text_size="5"/>
+ </itemgra>
+ <!-- landuse=residential -->
+ <itemgra item_types="poly_town" order="0-">
+ <polygon color="#f2f2f2"/>
+ </itemgra>
+ <!-- natural=water -->
+ <itemgra item_types="poly_water" order="0-">
+ <polygon color="#b5d6f1"/>
+ <polyline color="#b5d6f1"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="poly_water_tiled" order="0-">
+ <polygon color="#b5d6f1"/>
+ </itemgra>
+ <!-- leisure=park -->
+ <itemgra item_types="poly_park" order="0-">
+ <polygon color="#c7f1a3"/>
+ <polyline color="#79c691"/>
+ <text text_size="5"/>
+ </itemgra>
+ <itemgra item_types="poly_airport" order="0-">
+ <polygon color="#a0a0a0"/>
+ </itemgra>
+ <itemgra item_types="poly_sport" order="0-">
+ <polygon color="#4af04f"/>
+ </itemgra>
+ <!-- landuse=industrial -->
+ <itemgra item_types="poly_industry,poly_building,poly_place" order="0-">
+ <polygon color="#ecd8ff"/>
+ </itemgra>
+ <!-- waterway=stream -->
+ <itemgra item_types="water_line" order="0-4">
+ <polyline color="#b5d6f1" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
+ <!-- railway=subway -->
+ <itemgra item_types="rail" order="6">
+ <polyline color="#aaaaaa" width="1"/>
+ </itemgra>
+ <itemgra item_types="rail" order="7-8">
+ <polyline color="#aaaaaa" width="2"/>
+ </itemgra>
+ <itemgra item_types="rail" order="9-">
+ <polyline color="#aaaaaa" width="6"/>
+ </itemgra>
+ <itemgra item_types="ferry" order="5-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="border_country" order="0-">
+ <polyline color="#b8434e" width="1"/>
+ </itemgra>
+ <itemgra item_types="border_state" order="0-">
+ <polyline color="#808080" width="1"/>
+ </itemgra>
+ <itemgra item_types="height_line_1" order="0-">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="height_line_2" order="0-">
+ <polyline color="#000000" width="2"/>
+ </itemgra>
+ <!-- routing -->
+ <itemgra item_types="street_route" order="2">
+ <polyline color="#0000a0" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="3-5">
+ <polyline color="#0000a0" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="6">
+ <polyline color="#0000a0" width="10"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="7-8">
+ <polyline color="#0000a0" width="16"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="9-10">
+ <polyline color="#0000a0" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="11">
+ <polyline color="#0000a0" width="28"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="12">
+ <polyline color="#0000a0" width="32"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="13">
+ <polyline color="#0000a0" width="52"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="14">
+ <polyline color="#0000a0" width="64"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="15">
+ <polyline color="#0000a0" width="68"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="16">
+ <polyline color="#0000a0" width="132"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="17">
+ <polyline color="#0000a0" width="268"/>
+ </itemgra>
+ <itemgra item_types="street_route" order="18">
+ <polyline color="#0000a0" width="530"/>
+ </itemgra>
+ <!-- highway=service,footway, ,... -->
+ <itemgra item_types="street_pedestrian,living_street" order="10">
+ <polyline color="#d2d2d2" width="3"/>
+ <polyline color="#dddddd" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="11">
+ <polyline color="#d2d2d2" width="5"/>
+ <polyline color="#dddddd" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="12">
+ <polyline color="#d2d2d2" width="8"/>
+ <polyline color="#dddddd" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="13">
+ <polyline color="#d2d2d2" width="9"/>
+ <polyline color="#dddddd" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="14">
+ <polyline color="#d2d2d2" width="13"/>
+ <polyline color="#dddddd" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="15">
+ <polyline color="#d2d2d2" width="18"/>
+ <polyline color="#dddddd" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="16">
+ <polyline color="#d2d2d2" width="21"/>
+ <polyline color="#dddddd" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="17">
+ <polyline color="#d2d2d2" width="25"/>
+ <polyline color="#dddddd" width="21"/>
+ </itemgra>
+ <itemgra item_types="street_pedestrian,living_street" order="18">
+ <polyline color="#d2d2d2" width="40"/>
+ <polyline color="#dddddd" width="34"/>
+ </itemgra>
+ <itemgra item_types="street_nopass" order="10">
+ <polyline color="#efeaa0" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_nopass" order="11-12">
+ <polyline color="#efeaa0" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_nopass" order="13-">
+ <polyline color="#efeaa0" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="10">
+ <polyline color="#d2d2d2" width="4"/>
+ <polyline color="#ffffff" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="11">
+ <polyline color="#d2d2d2" width="6"/>
+ <polyline color="#ffffff" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="12">
+ <polyline color="#d2d2d2" width="10"/>
+ <polyline color="#ffffff" width="8"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="13">
+ <polyline color="#d2d2d2" width="12"/>
+ <polyline color="#ffffff" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="14">
+ <polyline color="#d2d2d2" width="15"/>
+ <polyline color="#ffffff" width="13"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="15">
+ <polyline color="#d2d2d2" width="17"/>
+ <polyline color="#ffffff" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="16">
+ <polyline color="#d2d2d2" width="33"/>
+ <polyline color="#ffffff" width="26"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="17">
+ <polyline color="#d2d2d2" width="69"/>
+ <polyline color="#ffffff" width="61"/>
+ </itemgra>
+ <itemgra item_types="street_0,street_1_city,street_1_land" order="18">
+ <polyline color="#d2d2d2" width="132"/>
+ <polyline color="#ffffff" width="126"/>
+ </itemgra>
+ <!-- highway=tertiary -->
+ <itemgra item_types="street_2_city,street_2_land" order="7-8">
+ <polyline color="#c4c4c4" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="9">
+ <polyline color="#c4c4c4" width="4"/>
+ <polyline color="#f7f496" width="2"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="10">
+ <polyline color="#c4c4c4" width="6"/>
+ <polyline color="#f7f496" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="11">
+ <polyline color="#c4c4c4" width="8"/>
+ <polyline color="#f7f496" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="12">
+ <polyline color="#c4c4c4" width="12"/>
+ <polyline color="#f7f496" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="13">
+ <polyline color="#c4c4c4" width="15"/>
+ <polyline color="#f7f496" width="11"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="14">
+ <polyline color="#c4c4c4" width="18"/>
+ <polyline color="#f7f496" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="15">
+ <polyline color="#c4c4c4" width="21"/>
+ <polyline color="#f7f496" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="16">
+ <polyline color="#c4c4c4" width="35"/>
+ <polyline color="#f7f496" width="30"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="17">
+ <polyline color="#c4c4c4" width="73"/>
+ <polyline color="#f7f496" width="67"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land" order="18">
+ <polyline color="#c4c4c4" width="144"/>
+ <polyline color="#f7f496" width="138"/>
+ </itemgra>
+ <!-- highway=secondary -->
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="7">
+ <polyline color="#fdbf6f" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="8">
+ <polyline color="#000000" width="2"/>
+ <polyline color="#fdbf6f" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="9">
+ <polyline color="#000000" width="5"/>
+ <polyline color="#fdbf6f" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="10">
+ <polyline color="#000000" width="8"/>
+ <polyline color="#fdbf6f" width="6"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="11">
+ <polyline color="#000000" width="9"/>
+ <polyline color="#fdbf6f" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="12">
+ <polyline color="#000000" width="11"/>
+ <polyline color="#fdbf6f" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="13">
+ <polyline color="#000000" width="16"/>
+ <polyline color="#fdbf6f" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="14">
+ <polyline color="#000000" width="19"/>
+ <polyline color="#fdbf6f" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="15">
+ <polyline color="#000000" width="23"/>
+ <polyline color="#fdbf6f" width="21"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="16">
+ <polyline color="#000000" width="36"/>
+ <polyline color="#fdbf6f" width="34"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="17">
+ <polyline color="#000000" width="75"/>
+ <polyline color="#fdbf6f" width="73"/>
+ </itemgra>
+ <itemgra item_types="street_3_city,street_3_land,ramp" order="18">
+ <polyline color="#000000" width="152"/>
+ <polyline color="#fdbf6f" width="150"/>
+ </itemgra>
+ <!-- highway=primary -->
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="2-6">
+ <polyline color="#e46d71" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="7-8">
+ <polyline color="#e46d71" width="3"/>
+ <polyline color="#e46d71" width="1"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="9">
+ <polyline color="#e46d71" width="5"/>
+ <polyline color="#e46d71" width="3"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="10">
+ <polyline color="#e46d71" width="6"/>
+ <polyline color="#e46d71" width="4"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11">
+ <polyline color="#e46d71" width="9"/>
+ <polyline color="#e46d71" width="7"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="12">
+ <polyline color="#e46d71" width="13"/>
+ <polyline color="#e46d71" width="9"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="13">
+ <polyline color="#e46d71" width="18"/>
+ <polyline color="#e46d71" width="14"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="14">
+ <polyline color="#e46d71" width="21"/>
+ <polyline color="#e46d71" width="17"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="15">
+ <polyline color="#e46d71" width="24"/>
+ <polyline color="#e46d71" width="20"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="16">
+ <polyline color="#e46d71" width="39"/>
+ <polyline color="#e46d71" width="33"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="17">
+ <polyline color="#e46d71" width="78"/>
+ <polyline color="#e46d71" width="72"/>
+ </itemgra>
+ <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="18">
+ <polyline color="#e46d71" width="156"/>
+ <polyline color="#e46d71" width="150"/>
+ </itemgra>
+ <!-- highway=motorway -->
+ <itemgra item_types="highway_city,highway_land" order="2">
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="3-5">
+ <polyline color="#87908a" width="3"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="6">
+ <polyline color="#87908a" width="4"/>
+ <polyline color="#809bc0" width="2"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="7-8">
+ <polyline color="#87908a" width="7"/>
+ <polyline color="#809bc0" width="5"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="9-10">
+ <polyline color="#87908a" width="9"/>
+ <polyline color="#809bc0" width="5"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="11">
+ <polyline color="#87908a" width="13"/>
+ <polyline color="#809bc0" width="9"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="12">
+ <polyline color="#87908a" width="15"/>
+ <polyline color="#809bc0" width="10"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="13">
+ <polyline color="#87908a" width="25"/>
+ <polyline color="#809bc0" width="17"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="14">
+ <polyline color="#87908a" width="31"/>
+ <polyline color="#809bc0" width="24"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="15">
+ <polyline color="#87908a" width="33"/>
+ <polyline color="#809bc0" width="27"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="16">
+ <polyline color="#87908a" width="65"/>
+ <polyline color="#809bc0" width="59"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="17">
+ <polyline color="#87908a" width="133"/>
+ <polyline color="#809bc0" width="127"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_city,highway_land" order="18">
+ <polyline color="#87908a" width="264"/>
+ <polyline color="#809bc0" width="258"/>
+ <polyline color="#809bc0" width="1"/>
+ </itemgra>
+ <itemgra item_types="highway_exit_label" order="10-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <!-- highway=primary (font)-->
+ <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street" order="10-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp" order="11-18">
+ <text text_size="9"/>
+ </itemgra>
+ <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land,footway" order="12-18">
+ <text text_size="9"/>
+ </itemgra>
+ <!-- place=suburb -->
+ <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="9-">
+ <circle color="#000000" radius="3" text_size="9"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3" order="11-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e3,town_label_2e3,town_label_5e3,place_label" order="10-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4" order="9-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e4,town_label_2e4,town_label_5e4" order="8-">
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5" order="6-">
+ <circle color="#000000" radius="3" text_size="10"/>
+ </itemgra>
+ <!-- place=city -->
+ <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="4-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6" order="3-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6" order="2-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="town_label_1e7,district_label_1e7" order="1-">
+ <circle color="#000000" radius="3" text_size="15"/>
+ </itemgra>
+ <itemgra item_types="rg_point" order="0-">
+ <circle color="#FF089C" radius="10"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="2">
+ <circle color="#008080" radius="4" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="3-5">
+ <circle color="#008080" radius="8" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="6">
+ <circle color="#008080" radius="10" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="7-8">
+ <circle color="#008080" radius="16" width="2" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="9-10">
+ <circle color="#008080" radius="20" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="11">
+ <circle color="#008080" radius="28" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="12">
+ <circle color="#008080" radius="32" width="4" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="13">
+ <circle color="#008080" radius="52" width="4" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="14">
+ <circle color="#008080" radius="64" width="4" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="15">
+ <circle color="#008080" radius="68" width="6" text_size="24"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="16">
+ <circle color="#008080" radius="132" width="8" text_size="32"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="17">
+ <circle color="#008080" radius="268" width="8" text_size="48"/>
+ </itemgra>
+ <itemgra item_types="waypoint,route_end" order="18">
+ <circle color="#008080" radius="530" width="8" text_size="48"/>
+ </itemgra>
+ <!-- !!!!...POIs...!!!! -->
+ <!-- amenity=bank -->
+ <itemgra item_types="poi_bank" order="14-">
+ <icon src="bank.png"/>
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <itemgra item_types="poi_atm" order="12-">
+ <icon src="atm.png"/>
+ </itemgra>
+ <!-- amenity=fuel -->
+ <itemgra item_types="poi_fuel" order="14-">
+ <icon src="fuel.png"/>
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <!-- amenity=hospitalg -->
+ <itemgra item_types="poi_hospital" order="14-">
+ <icon src="hospital.png"/>
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <!-- amenity=parking -->
+ <itemgra item_types="poi_car_parking" order="14-">
+ <icon src="parking.png"/>
+ </itemgra>
+ <!-- amenity=police -->
+ <itemgra item_types="poi_police" order="14-">
+ <icon src="police.png"/>
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <!-- amenity=restaurant -->
+ <itemgra item_types="poi_restaurant" order="14-">
+ <icon src="restaurant.png"/>
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <!-- leisure=golf_curse -->
+ <itemgra item_types="poi_golf" order="14-">
+ <icon src="golf.png"/>
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ <!-- tourism=hotel -->
+ <itemgra item_types="poi_hotel" order="14-">
+ <icon src="hotel.png"/>
+ <circle color="#000000" radius="3" text_size="7"/>
+ </itemgra>
+ </layer>
+ <layer name="Found items" ref="Found items"/>
+</layout>
diff --git a/navit/navit_nls.c b/navit/navit_nls.c
index a4b32a45a..02aa580c7 100644
--- a/navit/navit_nls.c
+++ b/navit/navit_nls.c
@@ -16,79 +16,69 @@
static GList *textdomains;
#endif
-char *
-navit_nls_add_textdomain(const char *package, const char *dir)
-{
+char *navit_nls_add_textdomain(const char *package, const char *dir) {
#ifdef USE_NATIVE_LANGUAGE_SUPPORT
- char *ret=bindtextdomain(package, dir);
- bind_textdomain_codeset(package, "UTF-8");
- textdomains=g_list_append(textdomains, g_strdup(package));
- return ret;
+ char *ret=bindtextdomain(package, dir);
+ bind_textdomain_codeset(package, "UTF-8");
+ textdomains=g_list_append(textdomains, g_strdup(package));
+ return ret;
#else
- return NULL;
+ return NULL;
#endif
}
-void
-navit_nls_remove_textdomain(const char *package)
-{
+void navit_nls_remove_textdomain(const char *package) {
#ifdef USE_NATIVE_LANGUAGE_SUPPORT
- GList *i=textdomains;
- while (i) {
- if (!strcmp(i->data, package)) {
- textdomains=g_list_remove_all(textdomains, i->data);
- g_free(i->data);
- return;
- }
- i=g_list_next(i);
- }
+ GList *i=textdomains;
+ while (i) {
+ if (!strcmp(i->data, package)) {
+ textdomains=g_list_remove_all(textdomains, i->data);
+ g_free(i->data);
+ return;
+ }
+ i=g_list_next(i);
+ }
#endif
}
-const char *
-navit_nls_gettext(const char *msgid)
-{
+const char *navit_nls_gettext(const char *msgid) {
#ifdef USE_NATIVE_LANGUAGE_SUPPORT
- GList *i=textdomains;
- while (i) {
- const char *ret=dgettext(i->data, msgid);
- if (ret != msgid)
- return ret;
- i=g_list_next(i);
- }
+ GList *i=textdomains;
+ while (i) {
+ const char *ret=dgettext(i->data, msgid);
+ if (ret != msgid)
+ return ret;
+ i=g_list_next(i);
+ }
#endif
- return msgid;
+ return msgid;
}
-const char *
-navit_nls_ngettext(const char *msgid, const char *msgid_plural, unsigned long int n)
-{
+const char *navit_nls_ngettext(const char *msgid, const char *msgid_plural, unsigned long int n) {
#ifdef USE_NATIVE_LANGUAGE_SUPPORT
- GList *i=textdomains;
- while (i) {
- const char *ret=dngettext(i->data, msgid, msgid_plural, n);
- if (ret != msgid && ret != msgid_plural)
- return ret;
- i=g_list_next(i);
- }
+ GList *i=textdomains;
+ while (i) {
+ const char *ret=dngettext(i->data, msgid, msgid_plural, n);
+ if (ret != msgid && ret != msgid_plural)
+ return ret;
+ i=g_list_next(i);
+ }
#endif
- if (n == 1) {
- return msgid;
- } else {
- return msgid_plural;
- }
+ if (n == 1) {
+ return msgid;
+ } else {
+ return msgid_plural;
+ }
}
-void
-navit_nls_main_init(void)
-{
+void navit_nls_main_init(void) {
#ifdef USE_NATIVE_LANGUAGE_SUPPORT
#ifdef FORCE_LOCALE
#define STRINGIFY2(x) #x
#define STRINGIFY(x) STRINGIFY2(x)
- setlocale(LC_MESSAGES,STRINGIFY(FORCE_LOCALE));
+ setlocale(LC_MESSAGES,STRINGIFY(FORCE_LOCALE));
#endif
- navit_nls_add_textdomain(PACKAGE, getenv("NAVIT_LOCALEDIR"));
- textdomain(PACKAGE);
+ navit_nls_add_textdomain(PACKAGE, getenv("NAVIT_LOCALEDIR"));
+ textdomain(PACKAGE);
#endif
}
diff --git a/navit/navit_shipped.xml b/navit/navit_shipped.xml
index 680308df0..409b149e8 100644
--- a/navit/navit_shipped.xml
+++ b/navit/navit_shipped.xml
@@ -27,27 +27,32 @@
<!-- timestamps 0/1 - prefix log messages with a timestamp -->
<debug name="timestamps" level="0"/>
- <!-- center= defines which map location Navit will show after first start.
- It will only be used for the first start; subsequent starts will remember the
- last position (in center.txt).
- Center coordinates format: "Long Lat" in decimal degrees (WGS 84).
- For other formats see http://wiki.navit-project.org/index.php/Coordinate_format.
- -->
- <navit center="11.5666 48.1333" zoom="256" tracking="1" orientation="-1" recent_dest="250" drag_bitmap="0">
- <!-- Use one of gtk_drawing_area, qt_qpainter or sdl.
- On windows systems, use win32 -->
+ <!--
+ center= defines which map location Navit will show after first start.
+ It will only be used for the first start; subsequent starts will remember the
+ last position (in center.txt).
+ Center coordinates format: "Long Lat" in decimal degrees (WGS 84).
+ For other formats see http://wiki.navit-project.org/index.php/Coordinate_format.
+ -->
+ <navit center="11.5666 48.1333" zoom="256" tracking="1" orientation="-1" recent_dest="250" drag_bitmap="0" default_layout="Car">
+ <!-- Use one of gtk_drawing_area, qt_qpainter or sdl. On windows systems, use win32 -->
<graphics type="gtk_drawing_area"/>
- <!-- The following line let you select which graphical user interface you'd like to use.
+ <!--
+ The following line let you select which graphical user interface you'd like to use.
Options include internal (optimized for touch screen devices), gtk (useful for desktop computers).
- If you don't like the internal gui, set enabled=yes for the following tag and enabled=no for the gui internal tag -->
+ If you don't like the internal gui, set enabled=yes for the following tag and enabled=no for the gui internal tag
+ -->
<gui type="gtk" enabled="no" menubar="1" toolbar="1" statusbar="1"/>
- <!--
- In case of the internal GUI, you can even influence the size of the text and of the icons in the toolbar and the viewport.
- Here's an example for a freerunner: -->
- <!-- <gui type="internal" font_size="350" icon_xs="32" icon_s="96" icon_l="96"/> -->
- <!-- The action that appears on map click is configurable with the attribute "on_map_click".
- To get the prvious behaviour of showing the map point menu use on_map_click='menu("#Map Point")'
- -->
+ <!--
+ In case of the internal GUI, you can even influence the size of the text and of the icons in the toolbar and the viewport.
+ Here's an example for a freerunner:
+ <gui type="internal" font_size="350" icon_xs="32" icon_s="96" icon_l="96"/>
+ -->
+
+ <!--
+ The action that appears on map click is configurable with the attribute "on_map_click".
+ To get the previous behaviour of showing the map point menu use on_map_click='menu("#Map Point")'
+ -->
<gui type="internal" enabled="yes"><![CDATA[
<html>
<a name='Main Menu'><text>Main menu</text>
@@ -99,9 +104,9 @@ Navigation</text></img>
<img src='gui_actions' onclick='route_description()'><text>Description</text></img>
<img src='gui_heightprofile' onclick='route_height_profile()'><text>Height Profile</text></img>
<img cond='navit.waypoints_flag &amp;&amp; (navit.route.route_status&amp;1)' src='cursor_still' onclick='waypoints()'><text>Waypoints</text></img>
- <img cond='navit.waypoints_flag &amp;&amp; (navit.route.route_status&amp;1)' src='gui_stop' onclick='navit.route_remove_last_waypoint()'><text>Drop last
+ <img cond='navit.waypoints_flag &amp;&amp; (navit.route.route_status&amp;1)' src='gui_stop' onclick='navit.route_remove_last_waypoint()'><text>Drop last
Waypoint</text></img>
- <img cond='navit.waypoints_flag &amp;&amp; (navit.route.route_status&amp;1)' src='gui_stop' onclick='navit.route_remove_next_waypoint()'><text>Drop next
+ <img cond='navit.waypoints_flag &amp;&amp; (navit.route.route_status&amp;1)' src='gui_stop' onclick='navit.route_remove_next_waypoint()'><text>Drop next
Waypoint</text></img>
</a>
<a name='Map Point'><text>Map Point</text>
@@ -170,7 +175,7 @@ Waypoint</text></img>
You can find a list of all the available OSDs items here:
http://wiki.navit-project.org/index.php/OSD -->
<osd enabled="no" type="compass"/>
- <osd enabled="no" type="navigation_next_turn"/>
+ <osd enabled="no" type="navigation_next_turn"/>
<!-- Commands include gui_internal_menu, gui_internal_fullscreen, zoom_in and zoom_out.
Usage of negative values change the button origins. x="0" y="0" specifies the top left, x="-0" y="-0" the bottom right corner.
@@ -178,12 +183,15 @@ Waypoint</text></img>
<osd enabled="no" type="button" x="0" y="0" command="gui.fullscreen=!gui.fullscreen" src="toggle_fullscreen.png"/>
<osd enabled="no" type="button" x="-96" y="0" command="gui.menu(1)" src="menu.png"/>
<osd enabled="no" type="button" x="-96" y="-96" command="zoom_in()" src="zoom_in.png"/>
- <osd enabled="no" type="button" x="0" y="-96" command="zoom_out()" src="zoom_out.png"/>
+ <osd enabled="no" type="button" x="0" y="-96" command="zoom_out()" src="zoom_out.png"/>
+
+ <!-- Traffic -->
+ <traffic type="null"/>
<!-- Vehicle with GPS enabled for gpsd on unix -->
<vehicle name="Local GPS" profilename="car" enabled="yes" active="1" source="gpsd://localhost" gpsd_query="w+xj">
<!-- Vehicle with GPS enabled for direct communication on windows. Remove the line above if you use this. -->
- <!-- <vehicle name="Local GPS" profilename="car" follow="1" enabled="yes" active="1"
+ <!-- <vehicle name="Local GPS" profilename="car" follow="1" enabled="yes" active="1"
source="serial:COM4 baudrate=4800 parity=N data=8 stop=1" > -->
<!-- Navit can write a tracklog in several formats (gpx, nmea or textfile): -->
@@ -285,7 +293,7 @@ Waypoint</text></img>
<roadprofile item_types="street_4_city,ramp" speed="22" route_weight="7" />
<!-- Those types do not appear in maptool.c and therefore are not used ATM -->
<roadprofile item_types="street_3_land,street_4_land" speed="20" route_weight="7" />
- <!--roundabout does not apply to OSMaps -->
+ <!--roundabout does not apply to OSMaps -->
<roadprofile item_types="roundabout" speed="20" route_weight="10"/>
<roadprofile item_types="ferry" speed="40" route_weight="40"/>
</vehicleprofile>
@@ -359,7 +367,7 @@ Waypoint</text></img>
<roadprofile item_types="street_n_lanes" speed="80" route_weight="80"/>
<roadprofile item_types="highway_land" speed="80" route_weight="80"/>
<roadprofile item_types="ramp" speed="30" route_weight="30"/>
- <!--roundabout does not apply to OSMaps -->
+ <!--roundabout does not apply to OSMaps -->
<roadprofile item_types="roundabout" speed="5" route_weight="5"/>
<roadprofile item_types="ferry" speed="40" route_weight="40"/>
</vehicleprofile>
@@ -374,9 +382,11 @@ Waypoint</text></img>
<announce type="street_n_lanes,highway_land" level0="300" level1="1000" level2="2000" unit="m"/>
</navigation>
- <!-- Navit provides speech output in text format.
- If you have a speech synthesizer like festival lite installed, you can get turn by turn directions out of navit. Please set the "cps"-value to how many characters your tts engine approximately speaks per second.
- The default is text output to the shell -->
+ <!--
+ Navit provides speech output in text format.
+ If you have a speech synthesizer like festival lite installed, you can get turn by turn directions out of navit. Please set the "cps"-value to how many characters your tts engine approximately speaks per second.
+ The default is text output to the shell
+ -->
<speech type="cmdline" data="echo 'Fix the speech tag in navit.xml to let navit say:' '%s'" cps="15"/>
<!--
Instead of using a speech synthesizer, navit can also play pre-recorded samples for each word.
@@ -385,7 +395,7 @@ Waypoint</text></img>
<speech type="cmdline" data="aplay -q %s"
sample_dir="/path/to/sampledir" sample_suffix=".wav" flags="1"
vocabulary_name="0" vocabulary_name_systematic="0" vocabulary_distances="0"/>
- -->
+ -->
<!-- You can only have enabled only one mapset at time, but with as much maps enabled as you want -->
@@ -420,6893 +430,15 @@ Waypoint</text></img>
</itemgra>
</layer>
- <layout name="Car" nightlayout="Car-dark" color="#ffefb7" font="Liberation Sans">
-
- <cursor w="57" h="57">
- <itemgra speed_range="-2">
- <polyline color="#00BC00" radius="0" width="4">
- <coord x="0" y="0" />
- </polyline>
- <circle color="#008500" radius="9" width="3">
- <coord x="0" y="0" />
- </circle>
- <circle color="#00BC00" radius="13" width="3">
- <coord x="0" y="0" />
- </circle>
- <circle color="#008500" radius="18" width="3">
- <coord x="0" y="0" />
- </circle>
- </itemgra>
- <itemgra speed_range="3-">
- <polygon color="#008500">
- <coord x="-21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="-21" y="-18" />
- </polygon>
- <polygon color="#00BC00">
- <coord x="21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="21" y="-18" />
- </polygon>
- <polygon color="#009C00">
- <coord x="-21" y="-18" />
- <coord x="0" y="-3" />
- <coord x="0" y="-9" />
- <coord x="-21" y="-18" />
- </polygon>
- <polygon color="#006500">
- <coord x="21" y="-18" />
- <coord x="0" y="-3" />
- <coord x="0" y="-9" />
- <coord x="21" y="-18" />
- </polygon>
- <polyline color="#008500" width="1">
- <coord x="-21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="-21" y="-18" />
- </polyline>
- <polyline color="#008500" width="1">
- <coord x="21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="21" y="-18" />
- </polyline>
- <polyline color="#008500" width="1">
- <coord x="-21" y="-18" />
- <coord x="0" y="-3" />
- <coord x="0" y="-9" />
- <coord x="-21" y="-18" />
- </polyline>
- <polyline color="#008500" width="1">
- <coord x="21" y="-18" />
- <coord x="0" y="-3" />
- <coord x="0" y="-9" />
- <coord x="21" y="-18" />
- </polyline>
- </itemgra>
- </cursor>
-
- <layer name="polygons">
- <itemgra item_types="image" order="0-">
- <image/>
- </itemgra>
- <itemgra item_types="poly_nature_reserve" order="10-">
- <polygon color="#cedec6"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_glacier" order="10-">
- <polygon color="#ddecec"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_town" order="0-">
- <polygon color="#ffc895"/>
- <polyline color="#ebb481"/>
- </itemgra>
- <itemgra item_types="poly_naval_base" order="10-">
- <polygon color="#6a9993"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_airfield" order="10-">
- <polygon color="#ecd3cf"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_university" order="8-">
- <polygon color="#d68fb8"/>
- <polyline color="#881155"/>
- </itemgra>
- <itemgra item_types="poly_college" order="10-">
- <polygon color="#f4f4f4"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_attraction" order="10-">
- <polygon color="#01a36c"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_theme_park" order="10-">
- <polygon color="#01a36c"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_water_park" order="10-">
- <polygon color="#8cc1c8"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_zoo" order="10-">
- <polygon color="#ccbda5"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_depot" order="10-">
- <polygon color="#c2b098"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_railway" order="10-">
- <polygon color="#b3b9c5"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_port" order="10-">
- <polygon color="#8188a0"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_marina" order="10-">
- <polygon color="#aac4d2"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_commercial" order="10-">
- <polygon color="#eaeed3"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_retail" order="10-">
- <polygon color="#d6b690"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_plaza" order="10-">
- <polygon color="#cac4bc"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_battlefield" order="10-">
- <polygon color="#373d1c"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_archaeological_site" order="10-">
- <polygon color="#d9cfb6"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_ruins" order="10-">
- <polygon color="#d9cfb6"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_camp_site" order="10-">
- <polygon color="#339900"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_caravan_site" order="10-">
- <polygon color="#8d9723"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_golf_course" order="10-">
- <polygon color="#419a22"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_marsh" order="10-">
- <polygon color="#553f23"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_fell" order="10-">
- <polygon color="#bbb56b"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_greenfield" order="10-">
- <polygon color="#f1eee8"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_brownfield" order="10-">
- <polygon color="#b6b690"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_heath" order="10-">
- <polygon color="#d6d99f"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_scree" order="10-">
- <polygon color="#eee5dc"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_quarry" order="10-">
- <polygon color="#e4caad"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_landfill" order="10-">
- <polygon color="#999893"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_construction" order="10-">
- <polygon color="#f47216"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_range" order="10-">
- <polygon color="#6d6b63"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_danger_area" order="10-">
- <polygon color="#f2ba1b"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_common" order="10-">
- <polygon color="#7bab36"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_recreation_ground" order="10-">
- <polygon color="#8fa400"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_playground" order="10-">
- <polygon color="#b4c479"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_fishing" order="10-">
- <polygon color="#713907"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_allotments" order="10-">
- <polygon color="#eecfb3"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_garden" order="10-">
- <polygon color="#cfeca8"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_village_green" order="10-">
- <polygon color="#93ac47"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_picnic_site" order="10-">
- <polygon color="#797548"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_wood" order="0-">
- <polygon color="#8ec78d"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_greenhouse" order="10-">
- <polygon color="#f9e8cb"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_orchard" order="10-">
- <polygon color="#9edc90"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_plantnursery" order="10-">
- <polygon color="#addea2"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_farm" order="0-">
- <polygon color="#c7f1a3"/>
- <polyline color="#79c691"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_meadow" order="0-">
- <polygon color="#c7f1a3"/>
- <polyline color="#79c691"/>
- </itemgra>
- <itemgra item_types="poly_water_tiled" order="0-">
- <polygon color="#82c8ea"/>
- </itemgra>
- <itemgra item_types="poly_land" order="0-">
- <polygon color="#ffefb7"/>
- <polyline color="#ffefb7"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_flats,poly_scrub,poly_military_zone,poly_marine,plantation,tundra" order="9-">
- <polygon color="#a0a0a0"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_park" order="0-">
- <polygon color="#7cc334"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_beach" order="0-">
- <polygon color="#fbed66"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_mud" order="0-">
- <polygon color="#96ced4"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="10">
- <polyline color="#d2d2d2" width="3"/>
- <polyline color="#dddddd" width="1"/>
- <polygon color="#dddddd"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="11">
- <polyline color="#d2d2d2" width="5"/>
- <polyline color="#dddddd" width="3"/>
- <polygon color="#dddddd"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="12">
- <polyline color="#d2d2d2" width="8"/>
- <polyline color="#dddddd" width="6"/>
- <polygon color="#dddddd"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="13">
- <polyline color="#d2d2d2" width="9"/>
- <polyline color="#dddddd" width="7"/>
- <polygon color="#dddddd"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="14">
- <polyline color="#d2d2d2" width="13"/>
- <polyline color="#dddddd" width="9"/>
- <polygon color="#dddddd"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="15">
- <polyline color="#d2d2d2" width="18"/>
- <polyline color="#dddddd" width="14"/>
- <polygon color="#dddddd"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="16">
- <polyline color="#d2d2d2" width="21"/>
- <polyline color="#dddddd" width="17"/>
- <polygon color="#dddddd"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="17">
- <polyline color="#d2d2d2" width="25"/>
- <polyline color="#dddddd" width="21"/>
- <polygon color="#dddddd"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="18">
- <polyline color="#d2d2d2" width="40"/>
- <polyline color="#dddddd" width="34"/>
- <polygon color="#dddddd"/>
- </itemgra>
- <itemgra item_types="poly_airport" order="0-">
- <polygon color="#a0a0a0"/>
- </itemgra>
- <itemgra item_types="poly_sport,poly_sports_pitch" order="0-">
- <polygon color="#4af04f"/>
- </itemgra>
- <itemgra item_types="poly_industry,poly_place" order="0-">
- <polygon color="#e6e6e6"/>
- </itemgra>
- <itemgra item_types="poly_service" order="8-18">
- <polygon color="#fefefe"/>
- <polyline color="#d2d2d2" width="1"/>
- </itemgra>
- <itemgra item_types="poly_street_1" order="8-13">
- <polygon color="#ffffff"/>
- <polyline color="#d2d2d2" width="1"/>
- </itemgra>
- <itemgra item_types="poly_street_1" order="14-16">
- <polygon color="#ffffff"/>
- <polyline color="#d2d2d2" width="2"/>
- </itemgra>
- <itemgra item_types="poly_street_1" order="17-18">
- <polygon color="#ffffff"/>
- <polyline color="#d2d2d2" width="3"/>
- </itemgra>
- <itemgra item_types="poly_street_2" order="7-12">
- <polygon color="#ffff00"/>
- <polyline color="#c0c0c0" width="1"/>
- </itemgra>
- <itemgra item_types="poly_street_2" order="13-16">
- <polygon color="#ffff00"/>
- <polyline color="#c0c0c0" width="2"/>
- </itemgra>
- <itemgra item_types="poly_street_2" order="17-18">
- <polygon color="#ffff00"/>
- <polyline color="#c0c0c0" width="3"/>
- </itemgra>
- <itemgra item_types="poly_street_3" order="7-11">
- <polygon color="#ffff00"/>
- <polyline color="#a0a0a0" width="1"/>
- </itemgra>
- <itemgra item_types="poly_street_3" order="12-15">
- <polygon color="#ffff00"/>
- <polyline color="#a0a0a0" width="2"/>
- </itemgra>
- <itemgra item_types="poly_street_3" order="16-18">
- <polygon color="#ffff00"/>
- <polyline color="#a0a0a0" width="3"/>
- </itemgra>
- <itemgra item_types="poly_saltpond" order="10-">
- <polygon color="#d7804a"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_water,poly_basin,poly_reservoir" order="0-">
- <polygon color="#82c8ea"/>
- <polyline color="#5096b8"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="water_line" order="0-">
- <polyline color="#5096b8" width="1"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="water_river" order="4-5">
- <polyline color="#82c8ea" width="1"/>
- </itemgra>
- <itemgra item_types="water_river" order="6">
- <polyline color="#82c8ea" width="2"/>
- </itemgra>
- <itemgra item_types="water_river" order="7">
- <polyline color="#82c8ea" width="3"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="water_river" order="8-9">
- <polyline color="#82c8ea" width="4"/>
- <text text_size="7"/>
- </itemgra>
- <itemgra item_types="water_river" order="10-">
- <polyline color="#82c8ea" width="4"/>
- <text text_size="10"/>
- </itemgra>
- <itemgra item_types="water_canal" order="6">
- <polyline color="#82c8ea" width="1"/>
- </itemgra>
- <itemgra item_types="water_canal" order="7">
- <polyline color="#82c8ea" width="2"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="water_canal" order="8-9">
- <polyline color="#82c8ea" width="3"/>
- <text text_size="7"/>
- </itemgra>
- <itemgra item_types="water_canal" order="10-">
- <polyline color="#82c8ea" width="3"/>
- <text text_size="10"/>
- </itemgra>
- <itemgra item_types="water_stream" order="8-9">
- <polyline color="#82c8ea" width="1"/>
- </itemgra>
- <itemgra item_types="water_stream" order="10-">
- <polyline color="#82c8ea" width="2"/>
- <text text_size="7"/>
- </itemgra>
- <itemgra item_types="water_drain" order="10-">
- <polyline color="#82c8ea" width="1"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_apron" order="0-">
- <polygon color="#d0d0d0"/>
- </itemgra>
- <itemgra item_types="poly_terminal" order="7-">
- <polygon color="#e3c6a6"/>
- </itemgra>
- <itemgra item_types="poly_cemetery" order="1-">
- <polygon color="#bde3cb"/>
- </itemgra>
- <itemgra item_types="poly_car_parking" order="1-">
- <polygon color="#e7cf87"/>
- </itemgra>
- <itemgra item_types="poly_artwork" order="10-">
- <polygon color="#fefbc5"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_sports_stadium" order="10-">
- <polygon color="#6eb85d"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_sports_track" order="10-">
- <polygon color="#b6554e"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_barracks" order="10-">
- <polygon color="#b6a6a6"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_garages" order="10-">
- <polygon color="#deddcc"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_building" order="0-">
- <polygon color="#b6a6a6"/>
- </itemgra>
- <itemgra item_types="rail" order="6-">
- <polyline color="#696969" width="3"/>
- <polyline color="#ffffff" width="1" dash="5,5"/>
- </itemgra>
- <itemgra item_types="ferry" order="5-">
- <polyline color="#000000" width="1" dash="10"/>
- </itemgra>
- <itemgra item_types="border_country" order="0-">
- <polyline color="#b8434e" width="1" dash="10,5,2,5"/>
- </itemgra>
- <itemgra item_types="border_state" order="0-">
- <polyline color="#808080" width="1"/>
- </itemgra>
- </layer>
- <layer name="heightlines">
- <itemgra item_types="height_line_1" order="7">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="height_line_1" order="8-">
- <polyline color="#000000" width="3"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="height_line_2" order="8">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="height_line_2" order="9-">
- <polyline color="#000000" width="2"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="height_line_3" order="9-11">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="height_line_3" order="12-">
- <polyline color="#000000" width="1"/>
- <text text_size="8"/>
- </itemgra>
- </layer>
- <layer name="streets">
- <itemgra item_types="street_route" order="2">
- <polyline color="#0000a0" width="4"/>
- </itemgra>
- <itemgra item_types="street_route" order="3-5">
- <polyline color="#0000a0" width="8"/>
- </itemgra>
- <itemgra item_types="street_route" order="6">
- <polyline color="#0000a0" width="10"/>
- </itemgra>
- <itemgra item_types="street_route" order="7-8">
- <polyline color="#0000a0" width="16"/>
- </itemgra>
- <itemgra item_types="street_route" order="9-10">
- <polyline color="#0000a0" width="20"/>
- </itemgra>
- <itemgra item_types="street_route" order="11">
- <polyline color="#0000a0" width="28"/>
- </itemgra>
- <itemgra item_types="street_route" order="12">
- <polyline color="#0000a0" width="32"/>
- </itemgra>
- <itemgra item_types="street_route" order="13">
- <polyline color="#0000a0" width="52"/>
- </itemgra>
- <itemgra item_types="street_route" order="14">
- <polyline color="#0000a0" width="64"/>
- </itemgra>
- <itemgra item_types="street_route" order="15">
- <polyline color="#0000a0" width="68"/>
- </itemgra>
- <itemgra item_types="street_route" order="16">
- <polyline color="#0000a0" width="132"/>
- </itemgra>
- <itemgra item_types="street_route" order="17">
- <polyline color="#0000a0" width="268"/>
- </itemgra>
- <itemgra item_types="street_route" order="18">
- <polyline color="#0000a0" width="530"/>
- </itemgra>
- <itemgra item_types="selected_line" order="2">
- <polyline color="#ba00b8" width="4"/>
- </itemgra>
- <itemgra item_types="selected_line" order="3-5">
- <polyline color="#ba00b8" width="8"/>
- </itemgra>
- <itemgra item_types="selected_line" order="6">
- <polyline color="#ba00b8" width="10"/>
- </itemgra>
- <itemgra item_types="selected_line" order="7-8">
- <polyline color="#ba00b8" width="16"/>
- </itemgra>
- <itemgra item_types="selected_line" order="9-10">
- <polyline color="#ba00b8" width="20"/>
- </itemgra>
- <itemgra item_types="selected_line" order="11">
- <polyline color="#ba00b8" width="28"/>
- </itemgra>
- <itemgra item_types="selected_line" order="12">
- <polyline color="#ba00b8" width="32"/>
- </itemgra>
- <itemgra item_types="selected_line" order="13">
- <polyline color="#ba00b8" width="52"/>
- </itemgra>
- <itemgra item_types="selected_line" order="14">
- <polyline color="#ba00b8" width="64"/>
- </itemgra>
- <itemgra item_types="selected_line" order="15">
- <polyline color="#ba00b8" width="68"/>
- </itemgra>
- <itemgra item_types="selected_line" order="16">
- <polyline color="#ba00b8" width="132"/>
- </itemgra>
- <itemgra item_types="selected_line" order="17">
- <polyline color="#ba00b8" width="268"/>
- </itemgra>
- <itemgra item_types="selected_line" order="18">
- <polyline color="#ba00b8" width="530"/>
- </itemgra>
- <itemgra item_types="forest_way_1" order="10-">
- <polyline color="#0070c0" width="6"/>
- </itemgra>
- <itemgra item_types="forest_way_2" order="10-">
- <polyline color="#ff0000" width="3"/>
- </itemgra>
- <itemgra item_types="forest_way_3" order="10-">
- <polyline color="#ff0000" width="1" dash="2,4"/>
- </itemgra>
- <itemgra item_types="forest_way_4" order="10-">
- <polyline color="#119a2e" width="1" dash="4,10"/>
- </itemgra>
- <itemgra item_types="street_nopass" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="track_paved" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="track_gravelled,track_grass" order="10-12">
- <polyline color="#800000" width="1" dash="3,6"/>
- </itemgra>
- <itemgra item_types="track_gravelled,track_grass" order="13-14">
- <polyline color="#ffffff" width="4"/>
- <polyline color="#800000" width="1" dash="4,8"/>
- </itemgra>
- <itemgra item_types="track_gravelled,track_grass" order="15-16">
- <polyline color="#ffffff" width="5"/>
- <polyline color="#800000" width="1" dash="5,10"/>
- </itemgra>
- <itemgra item_types="track_gravelled,track_grass" order="17-">
- <polyline color="#ffffff" width="7"/>
- <polyline color="#800000" width="1" dash="7,15"/>
- </itemgra>
- <itemgra item_types="track_unpaved,track_ground,path,hiking,hiking_mountain,hiking_mountain_demanding,hiking_alpine,hiking_alpine_demanding,hiking_alpine_difficult" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="bridleway" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="cycleway" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_novice" order="10-12">
- <polyline color="#00A000" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_novice" order="13-14">
- <polyline color="#00A000" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_novice" order="15-16">
- <polyline color="#00A000" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_novice" order="17-">
- <polyline color="#00A000" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_easy" order="10-12">
- <polyline color="#0000ff" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_easy" order="13-14">
- <polyline color="#0000ff" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_easy" order="15-16">
- <polyline color="#0000ff" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_easy" order="17-">
- <polyline color="#0000ff" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_intermediate" order="10-12">
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_intermediate" order="13-14">
- <polyline color="#ff0000" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_intermediate" order="15-16">
- <polyline color="#ff0000" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_intermediate" order="17-">
- <polyline color="#ff0000" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_advanced" order="10-12">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_advanced" order="13-14">
- <polyline color="#000000" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_advanced" order="15-16">
- <polyline color="#000000" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_advanced" order="17-">
- <polyline color="#000000" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_expert" order="10-12">
- <polyline color="#ffaa00" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_expert" order="13-14">
- <polyline color="#ffaa00" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_expert" order="15-16">
- <polyline color="#ffaa00" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_expert" order="17-">
- <polyline color="#ffaa00" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_freeride" order="10-12">
- <polyline color="#ffff00" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_freeride" order="13-14">
- <polyline color="#ffff00" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_freeride" order="15-16">
- <polyline color="#ffff00" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_freeride" order="17-">
- <polyline color="#ffff00" width="5"/>
- </itemgra>
- <itemgra item_types="lift_cable_car" order="6-">
- <polyline color="#696969" width="1" dash="5"/>
- </itemgra>
- <itemgra item_types="lift_chair" order="6-">
- <polyline color="#696969" width="1" dash="5"/>
- </itemgra>
- <itemgra item_types="lift_drag" order="6-">
- <polyline color="#696969" width="1" dash="5"/>
- </itemgra>
- <itemgra item_types="piste_nordic" order="10-12">
- <polyline color="#0000ff" width="1" dash="3,6" offset="4"/>
- </itemgra>
- <itemgra item_types="piste_nordic" order="13-14">
- <polyline color="#ffffff" width="4" offset="6"/>
- <polyline color="#0000ff" width="1" dash="4,8" offset="6"/>
- </itemgra>
- <itemgra item_types="piste_nordic" order="15-16">
- <polyline color="#ffffff" width="5" offset="7"/>
- <polyline color="#0000ff" width="1" dash="5,10" offset="7"/>
- </itemgra>
- <itemgra item_types="piste_nordic" order="17-">
- <polyline color="#ffffff" width="7" offset="10"/>
- <polyline color="#0000ff" width="1" dash="7,15" offset="10"/>
- </itemgra>
- <itemgra item_types="footway_and_piste_nordic" order="10-12">
- <polyline color="#ff0000" width="1" dash="3,15"/>
- <polyline color="#0000ff" width="1" dash="3,15" offset="9"/>
- </itemgra>
- <itemgra item_types="footway_and_piste_nordic" order="13-14">
- <polyline color="#ffffff" width="4"/>
- <polyline color="#ff0000" width="2"/>
- <polyline color="#0000ff" width="1" dash="4,20" offset="12"/>
- </itemgra>
- <itemgra item_types="footway_and_piste_nordic" order="15-16">
- <polyline color="#ffffff" width="5"/>
- <polyline color="#ff0000" width="3"/>
- <polyline color="#0000ff" width="1" dash="5,25" offset="15"/>
- </itemgra>
- <itemgra item_types="footway_and_piste_nordic" order="17-">
- <polyline color="#ffffff" width="7"/>
- <polyline color="#ff0000" width="5"/>
- <polyline color="#0000ff" width="1" dash="7,37" offset="22"/>
- </itemgra>
- <itemgra item_types="footway" order="10-12">
- <polyline color="#ff0000" width="1" dash="3,6"/>
- </itemgra>
- <itemgra item_types="footway" order="13-14">
- <polyline color="#ffffff" width="4"/>
- <polyline color="#ff0000" width="1" dash="4,8"/>
- </itemgra>
- <itemgra item_types="footway" order="15-16">
- <polyline color="#ffffff" width="5"/>
- <polyline color="#ff0000" width="1" dash="5,10"/>
- </itemgra>
- <itemgra item_types="footway" order="17-">
- <polyline color="#ffffff" width="7"/>
- <polyline color="#ff0000" width="1" dash="7,15"/>
- </itemgra>
- <itemgra item_types="steps" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="10">
- <polyline color="#d2d2d2" width="3"/>
- <polyline color="#dddddd" width="1"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="11">
- <polyline color="#d2d2d2" width="5"/>
- <polyline color="#dddddd" width="3"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="12">
- <polyline color="#d2d2d2" width="8"/>
- <polyline color="#dddddd" width="6"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="13">
- <polyline color="#d2d2d2" width="9"/>
- <polyline color="#dddddd" width="7"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="14">
- <polyline color="#d2d2d2" width="13"/>
- <polyline color="#dddddd" width="9"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="15">
- <polyline color="#d2d2d2" width="18"/>
- <polyline color="#dddddd" width="14"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="16">
- <polyline color="#d2d2d2" width="21"/>
- <polyline color="#dddddd" width="17"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="17">
- <polyline color="#d2d2d2" width="25"/>
- <polyline color="#dddddd" width="21"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="18">
- <polyline color="#d2d2d2" width="40"/>
- <polyline color="#dddddd" width="34"/>
- </itemgra>
- <itemgra item_types="street_service" order="10">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#fefefe" width="2"/>
- </itemgra>
- <itemgra item_types="street_service" order="11">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#fefefe" width="2"/>
- </itemgra>
- <itemgra item_types="street_service" order="12">
- <polyline color="#d2d2d2" width="5"/>
- <polyline color="#fefefe" width="3"/>
- </itemgra>
- <itemgra item_types="street_service" order="13">
- <polyline color="#d2d2d2" width="6"/>
- <polyline color="#fefefe" width="4"/>
- </itemgra>
- <itemgra item_types="street_service" order="14">
- <polyline color="#d2d2d2" width="7"/>
- <polyline color="#fefefe" width="5"/>
- </itemgra>
- <itemgra item_types="street_service" order="15">
- <polyline color="#d2d2d2" width="8"/>
- <polyline color="#fefefe" width="6"/>
- </itemgra>
- <itemgra item_types="street_service" order="16">
- <polyline color="#d2d2d2" width="9"/>
- <polyline color="#fefefe" width="7"/>
- </itemgra>
- <itemgra item_types="street_service" order="17">
- <polyline color="#d2d2d2" width="10"/>
- <polyline color="#fefefe" width="8"/>
- </itemgra>
- <itemgra item_types="street_service" order="18">
- <polyline color="#d2d2d2" width="11"/>
- <polyline color="#fefefe" width="9"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="12">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#fefefe" width="2"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="13">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#fefefe" width="2"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="14">
- <polyline color="#d2d2d2" width="5"/>
- <polyline color="#fefefe" width="3"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="15">
- <polyline color="#d2d2d2" width="6"/>
- <polyline color="#fefefe" width="4"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="16">
- <polyline color="#d2d2d2" width="7"/>
- <polyline color="#fefefe" width="5"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="17">
- <polyline color="#d2d2d2" width="8"/>
- <polyline color="#fefefe" width="6"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="18">
- <polyline color="#d2d2d2" width="9"/>
- <polyline color="#fefefe" width="7"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="10">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#ffffff" width="2"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="11">
- <polyline color="#d2d2d2" width="6"/>
- <polyline color="#ffffff" width="4"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="12">
- <polyline color="#d2d2d2" width="10"/>
- <polyline color="#ffffff" width="8"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="13">
- <polyline color="#d2d2d2" width="11"/>
- <polyline color="#ffffff" width="9"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="14">
- <polyline color="#d2d2d2" width="17"/>
- <polyline color="#ffffff" width="13"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="15">
- <polyline color="#d2d2d2" width="18"/>
- <polyline color="#ffffff" width="14"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="16">
- <polyline color="#d2d2d2" width="30"/>
- <polyline color="#ffffff" width="26"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="17">
- <polyline color="#d2d2d2" width="67"/>
- <polyline color="#ffffff" width="61"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="18">
- <polyline color="#d2d2d2" width="132"/>
- <polyline color="#ffffff" width="126"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="7-8">
- <polyline color="#c0c0c0" width="2"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="9">
- <polyline color="#c0c0c0" width="3"/>
- <polyline color="#ffff00" width="1"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="10">
- <polyline color="#c0c0c0" width="4"/>
- <polyline color="#ffff00" width="2"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="11">
- <polyline color="#c0c0c0" width="5"/>
- <polyline color="#ffff00" width="3"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="12">
- <polyline color="#c0c0c0" width="7"/>
- <polyline color="#ffff00" width="5"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="13">
- <polyline color="#c0c0c0" width="11"/>
- <polyline color="#ffff00" width="8"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="14">
- <polyline color="#c0c0c0" width="14"/>
- <polyline color="#ffff00" width="11"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="15">
- <polyline color="#c0c0c0" width="19"/>
- <polyline color="#ffff00" width="15"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="16">
- <polyline color="#c0c0c0" width="30"/>
- <polyline color="#ffff00" width="26"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="17">
- <polyline color="#c0c0c0" width="63"/>
- <polyline color="#ffff00" width="57"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="18">
- <polyline color="#c0c0c0" width="100"/>
- <polyline color="#ffff00" width="90"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="7-8">
- <polyline color="#a0a0a0" width="3"/>
- <polyline color="#ffff00" width="1"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="9">
- <polyline color="#a0a0a0" width="5"/>
- <polyline color="#ffff00" width="3"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="10">
- <polyline color="#a0a0a0" width="8"/>
- <polyline color="#ffff00" width="6"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="11">
- <polyline color="#a0a0a0" width="9"/>
- <polyline color="#ffff00" width="7"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="12">
- <polyline color="#a0a0a0" width="13"/>
- <polyline color="#ffff00" width="9"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="13">
- <polyline color="#a0a0a0" width="18"/>
- <polyline color="#ffff00" width="14"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="14">
- <polyline color="#a0a0a0" width="21"/>
- <polyline color="#ffff00" width="17"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="15">
- <polyline color="#a0a0a0" width="25"/>
- <polyline color="#ffff00" width="21"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="16">
- <polyline color="#a0a0a0" width="40"/>
- <polyline color="#ffff00" width="34"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="17">
- <polyline color="#a0a0a0" width="79"/>
- <polyline color="#ffff00" width="73"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="18">
- <polyline color="#a0a0a0" width="156"/>
- <polyline color="#ffff00" width="150"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="2-6">
- <polyline color="#404040" width="1"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="7-8">
- <polyline color="#404040" width="3"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="9">
- <polyline color="#000000" width="5"/>
- <polyline color="#ff0000" width="3"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="10">
- <polyline color="#000000" width="6"/>
- <polyline color="#ff0000" width="4"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11">
- <polyline color="#000000" width="9"/>
- <polyline color="#ff0000" width="7"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="12">
- <polyline color="#000000" width="13"/>
- <polyline color="#ff0000" width="9"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="13">
- <polyline color="#000000" width="18"/>
- <polyline color="#ff0000" width="14"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="14">
- <polyline color="#000000" width="21"/>
- <polyline color="#ff0000" width="17"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="15">
- <polyline color="#000000" width="24"/>
- <polyline color="#ff0000" width="20"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="16">
- <polyline color="#000000" width="39"/>
- <polyline color="#ff0000" width="33"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="17">
- <polyline color="#000000" width="78"/>
- <polyline color="#ff0000" width="72"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="18">
- <polyline color="#000000" width="156"/>
- <polyline color="#ff0000" width="150"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="2">
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="3-5">
- <polyline color="#ff0000" width="3"/>
- <polyline color="#ffff00" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="6">
- <polyline color="#ff0000" width="4"/>
- <polyline color="#ffff00" width="2"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="7-8">
- <polyline color="#ff0000" width="7"/>
- <polyline color="#ffff00" width="5"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="9-10">
- <polyline color="#ff0000" width="9"/>
- <polyline color="#ffff00" width="5"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="11">
- <polyline color="#ff0000" width="13"/>
- <polyline color="#ffff00" width="9"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="12">
- <polyline color="#ff0000" width="15"/>
- <polyline color="#ffff00" width="10"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="13">
- <polyline color="#ff0000" width="25"/>
- <polyline color="#ffff00" width="17"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="14">
- <polyline color="#ff0000" width="31"/>
- <polyline color="#ffff00" width="24"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="15">
- <polyline color="#ff0000" width="33"/>
- <polyline color="#ffff00" width="27"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="16">
- <polyline color="#ff0000" width="65"/>
- <polyline color="#ffff00" width="59"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="17">
- <polyline color="#ff0000" width="133"/>
- <polyline color="#ffff00" width="127"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="18">
- <polyline color="#ff0000" width="264"/>
- <polyline color="#ffff00" width="258"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="tracking_0" order="0-">
- <polyline color="#000000" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_10" order="0-">
- <polyline color="#191919" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_20" order="0-">
- <polyline color="#333333" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_30" order="0-">
- <polyline color="#4c4c4c" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_40" order="0-">
- <polyline color="#666666" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_50" order="0-">
- <polyline color="#7f7f7f" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_60" order="0-">
- <polyline color="#999999" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_70" order="0-">
- <polyline color="#b2b2b2" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_80" order="0-">
- <polyline color="#cccccc" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_90" order="0-">
- <polyline color="#e5e5e5" width="3"/>
- </itemgra>
- <itemgra item_types="tracking_100" order="0-">
- <polyline color="#ffffff" width="3"/>
- </itemgra>
- <itemgra item_types="highway_exit_label" order="10-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street" order="10-18">
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp" order="11-18">
- <text text_size="9"/>
- </itemgra>
- <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land,footway" order="12-18">
- <text text_size="9"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="2">
- <polyline color="#ff9000" width="2"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="3-5">
- <polyline color="#ff9000" width="4"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="6">
- <polyline color="#ff9000" width="5"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="7-8">
- <polyline color="#ff9000" width="8"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="9-10">
- <polyline color="#ff9000" width="10"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="11">
- <polyline color="#ff9000" width="14"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="12">
- <polyline color="#ff9000" width="16"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="13">
- <polyline color="#ff9000" width="26"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="14">
- <polyline color="#ff9000" width="32"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="15">
- <polyline color="#ff9000" width="34"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="16">
- <polyline color="#ff9000" width="66"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="17">
- <polyline color="#ff9000" width="134"/>
- </itemgra>
- <itemgra item_types="traffic_distortion" order="18">
- <polyline color="#ff9000" width="265"/>
- </itemgra>
- </layer>
- <layer name="polylines">
- <itemgra item_types="aeroway_taxiway" order="10">
- <polyline color="#989994" width="4"/>
- <polyline color="#d3dbbc" width="2"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="11">
- <polyline color="#989994" width="6"/>
- <polyline color="#d3dbbc" width="4"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="12">
- <polyline color="#989994" width="10"/>
- <polyline color="#d3dbbc" width="8"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="13">
- <polyline color="#989994" width="12"/>
- <polyline color="#d3dbbc" width="9"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="14">
- <polyline color="#989994" width="15"/>
- <polyline color="#d3dbbc" width="13"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="15">
- <polyline color="#989994" width="17"/>
- <polyline color="#d3dbbc" width="14"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="16">
- <polyline color="#989994" width="33"/>
- <polyline color="#d3dbbc" width="26"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="17">
- <polyline color="#989994" width="69"/>
- <polyline color="#d3dbbc" width="61"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="18">
- <polyline color="#989994" width="132"/>
- <polyline color="#d3dbbc" width="126"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="2-6">
- <polyline color="#404040" width="1"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="7-8">
- <polyline color="#404040" width="3"/>
- <polyline color="#d3dbbc" width="1"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="9">
- <polyline color="#6b6f5f" width="5"/>
- <polyline color="#d3dbbc" width="3"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="10">
- <polyline color="#6b6f5f" width="6"/>
- <polyline color="#d3dbbc" width="4"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="11">
- <polyline color="#6b6f5f" width="9"/>
- <polyline color="#d3dbbc" width="7"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="12">
- <polyline color="#6b6f5f" width="13"/>
- <polyline color="#d3dbbc" width="9"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="13">
- <polyline color="#6b6f5f" width="18"/>
- <polyline color="#d3dbbc" width="14"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="14">
- <polyline color="#6b6f5f" width="21"/>
- <polyline color="#d3dbbc" width="17"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="15">
- <polyline color="#6b6f5f" width="24"/>
- <polyline color="#d3dbbc" width="20"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="16">
- <polyline color="#6b6f5f" width="39"/>
- <polyline color="#d3dbbc" width="33"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="17">
- <polyline color="#6b6f5f" width="78"/>
- <polyline color="#d3dbbc" width="72"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="18">
- <polyline color="#6b6f5f" width="156"/>
- <polyline color="#d3dbbc" width="150"/>
- </itemgra>
- <itemgra item_types="rail_tram" order="10-">
- <polyline color="#606060" width="2"/>
- </itemgra>
- </layer>
- <layer name="labels">
- <itemgra item_types="house_number" order="15-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="11-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3" order="10-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="town_label_1e3,place_label" order="10-">
- <circle color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4" order="9-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="town_label_2e3" order="9-">
- <circle color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <itemgra item_types="town_label_5e3,town_label_1e4,town_label_2e4,town_label_5e4" order="9-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5" order="8-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="town_label_2e3" order="8">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6,district_label_1e7" order="7-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="town_label_5e3" order="7-8">
- <circle color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <itemgra item_types="town_label_1e4" order="6-8">
- <circle color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <itemgra item_types="town_label_2e4,town_label_5e4" order="5-8">
- <circle color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="5-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7" order="5-">
- <circle color="#000000" radius="3" text_size="20"/>
- </itemgra>
- <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="3-4">
- <circle color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7" order="3-4">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7" order="0-2">
- <circle color="#000000" radius="3" text_size="10"/>
- </itemgra>
- </layer>
- <layer name="Internal">
- <itemgra item_types="track" order="7-">
- <polyline color="#3f3f3f" width="1"/>
- </itemgra>
- <itemgra item_types="track_tracked" order="7-">
- <polyline color="#3f3fff" width="3"/>
- </itemgra>
- <itemgra item_types="rg_segment" order="12-">
- <polyline color="#FF089C" width="1"/>
- <arrows color="#FF089C" width="1"/>
- <text text_size="15"/>
- </itemgra>
- <itemgra item_types="rg_point" order="12-">
- <circle color="#FF089C" radius="10" text_size="7"/>
- </itemgra>
- <itemgra item_types="nav_left_1" order="0-">
- <icon src="nav_left_1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_left_2" order="0-">
- <icon src="nav_left_2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_left_3" order="0-">
- <icon src="nav_left_3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_right_1" order="0-">
- <icon src="nav_right_1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_right_2" order="0-">
- <icon src="nav_right_2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_right_3" order="0-">
- <icon src="nav_right_3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_straight" order="0-">
- <icon src="nav_straight_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_turnaround_left" order="0-">
- <icon src="nav_turnaround_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_turnaround_right" order="0-">
- <icon src="nav_turnaround_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l1" order="0-">
- <icon src="nav_roundabout_l1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r1" order="0-">
- <icon src="nav_roundabout_r1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l2" order="0-">
- <icon src="nav_roundabout_l2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r2" order="0-">
- <icon src="nav_roundabout_r2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l3" order="0-">
- <icon src="nav_roundabout_l3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r3" order="0-">
- <icon src="nav_roundabout_r3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l4" order="0-">
- <icon src="nav_roundabout_l4_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r4" order="0-">
- <icon src="nav_roundabout_r4_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l5" order="0-">
- <icon src="nav_roundabout_l5_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r5" order="0-">
- <icon src="nav_roundabout_r5_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l6" order="0-">
- <icon src="nav_roundabout_l6_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r6" order="0-">
- <icon src="nav_roundabout_r6_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l7" order="0-">
- <icon src="nav_roundabout_l7_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r7" order="0-">
- <icon src="nav_roundabout_r7_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l8" order="0-">
- <icon src="nav_roundabout_l8_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r8" order="0-">
- <icon src="nav_roundabout_r8_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_keep_left" order="0-">
- <icon src="nav_keep_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_merge_left" order="0-">
- <icon src="nav_merge_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_keep_right" order="0-">
- <icon src="nav_keep_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_merge_right" order="0-">
- <icon src="nav_merge_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_exit_left" order="0-">
- <icon src="nav_exit_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_exit_right" order="0-">
- <icon src="nav_exit_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="route_end" order="0-">
- <icon src="nav_destination_bk.svg" w="32" h="32" x="4" y="30"/>
- </itemgra>
- <itemgra item_types="nav_none" order="0-">
- <icon src="unknown.svg"/>
- </itemgra>
- <itemgra item_types="announcement" order="7-">
- <icon src="gui_sound_32_32.png"/>
- <circle color="#FF089C" radius="10" text_size="7"/>
- </itemgra>
-
- <itemgra item_types="waypoint,route_end" order="2">
- <circle color="#008080" radius="4" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="3-5">
- <circle color="#008080" radius="8" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="6">
- <circle color="#008080" radius="10" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="7-8">
- <circle color="#008080" radius="16" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="9-10">
- <circle color="#008080" radius="20" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="11">
- <circle color="#008080" radius="28" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="12">
- <circle color="#008080" radius="32" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="13">
- <circle color="#008080" radius="52" width="4" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="14">
- <circle color="#008080" radius="64" width="4" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="15">
- <circle color="#008080" radius="68" width="6" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="16">
- <circle color="#008080" radius="132" width="8" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="17">
- <circle color="#008080" radius="268" width="8" text_size="48"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="18">
- <circle color="#008080" radius="530" width="8" text_size="48"/>
- </itemgra>
- </layer>
- <layer name="Unknown" enabled="no">
- <!-- This entry shows all unknow point elements as blue circles -->
- <itemgra item_types="point_unkn" order="9-">
- <circle color="#8080ff" radius="3"/>
- </itemgra>
- <!-- This entry shows all unknown linear elements as blue lines -->
- <itemgra item_types="street_unkn" order="0-">
- <polyline color="#8080ff" width="3"/>
- </itemgra>
- </layer>
- <layer name="POI Symbols">
- <itemgra item_types="mini_roundabout" order="12-">
- <icon src="mini_roundabout.png"/>
- </itemgra>
- <itemgra item_types="turning_circle" order="12-">
- <icon src="mini_roundabout.png"/>
- </itemgra>
- <itemgra item_types="poi_airport" order="5-">
- <icon src="airport.png"/>
- </itemgra>
- <itemgra item_types="town_ghost" order="10-">
- <icon src="ghost_town.xpm"/>
- </itemgra>
- <itemgra item_types="poi_hotel" order="12-">
- <icon src="hotel.png"/>
- </itemgra>
- <itemgra item_types="poi_car_parking" order="11-">
- <icon src="parking.png"/>
- </itemgra>
- <itemgra item_types="poi_car_dealer_parts" order="12-">
- <icon src="car_dealer.png"/>
- </itemgra>
- <itemgra item_types="poi_car_sharing" order="11-">
- <icon src="car_sharing.png"/>
- </itemgra>
- <itemgra item_types="poi_fuel" order="12-">
- <icon src="fuel.png"/>
- </itemgra>
- <itemgra item_types="poi_shopping" order="12-">
- <icon src="shopping.png"/>
- </itemgra>
- <itemgra item_types="poi_attraction" order="11-">
- <icon src="attraction.png"/>
- </itemgra>
- <itemgra item_types="poi_cafe" order="12-">
- <icon src="cafe.png"/>
- </itemgra>
- <itemgra item_types="poi_bar" order="12-">
- <icon src="bar.png"/>
- </itemgra>
- <itemgra item_types="poi_pub" order="12-">
- <icon src="beer.png"/>
- </itemgra>
- <itemgra item_types="poi_bridge" order="12-">
- <icon src="bridge.xpm"/>
- </itemgra>
- <itemgra item_types="highway_exit" order="11-">
- <icon src="exit.png"/>
- </itemgra>
- <itemgra item_types="poi_camp_rv" order="12-">
- <icon src="camping.png"/>
- </itemgra>
- <itemgra item_types="poi_museum_history" order="12-">
- <icon src="museum.png"/>
- </itemgra>
- <itemgra item_types="poi_hospital" order="12-">
- <icon src="hospital.png"/>
- </itemgra>
- <itemgra item_types="poi_dining" order="12-">
- <icon src="restaurant.png"/>
- </itemgra>
- <itemgra item_types="poi_fastfood" order="12-">
- <icon src="fastfood.png"/>
- </itemgra>
- <itemgra item_types="poi_police" order="12-">
- <icon src="police.png"/>
- </itemgra>
- <itemgra item_types="poi_auto_club" order="12-">
- <icon src="auto_club.xpm"/>
- </itemgra>
- <itemgra item_types="poi_autoservice" order="12-">
- <icon src="car_dealer.png"/>
- </itemgra>
- <itemgra item_types="poi_bank" order="12-">
- <icon src="bank.png"/>
- </itemgra>
- <itemgra item_types="poi_atm" order="12-">
- <icon src="atm.png"/>
- </itemgra>
- <itemgra item_types="poi_bay" order="12-">
- <icon src="bay.xpm"/>
- </itemgra>
- <itemgra item_types="poi_bend" order="12-">
- <icon src="bend.xpm"/>
- </itemgra>
- <itemgra item_types="poi_boat_ramp" order="12-">
- <icon src="boat_ramp.png"/>
- </itemgra>
- <itemgra item_types="poi_border_station" order="12-">
- <icon src="border_station.xpm"/>
- </itemgra>
- <itemgra item_types="poi_bowling" order="12-">
- <icon src="bowling.xpm"/>
- </itemgra>
- <itemgra item_types="poi_bus_station" order="11-">
- <icon src="bus.png"/>
- </itemgra>
- <itemgra item_types="poi_bus_stop" order="12-">
- <icon src="bus_stop.png"/>
- </itemgra>
- <itemgra item_types="poi_business_service" order="12-">
- <icon src="bussines_service.xpm"/>
- </itemgra>
- <itemgra item_types="poi_car_rent" order="12-">
- <icon src="car_rent.png"/>
- </itemgra>
- <itemgra item_types="poi_car_wash" order="12-">
- <icon src="car_wash.xpm"/>
- </itemgra>
- <itemgra item_types="poi_casino" order="12-">
- <icon src="casino.png"/>
- </itemgra>
- <itemgra item_types="poi_cemetery" order="12-">
- <icon src="cemetery.xpm"/>
- </itemgra>
- <itemgra item_types="poi_church" order="11-">
- <icon src="church.png"/>
- </itemgra>
- <itemgra item_types="poi_bahai" order="11-">
- <icon src="bahai.png"/>
- </itemgra>
- <itemgra item_types="poi_buddhist" order="11-">
- <icon src="buddhist.png"/>
- </itemgra>
- <itemgra item_types="poi_hindu" order="11-">
- <icon src="hindu.png"/>
- </itemgra>
- <itemgra item_types="poi_islamic" order="11-">
- <icon src="islamic.png"/>
- </itemgra>
- <itemgra item_types="poi_jain" order="11-">
- <icon src="jain.png"/>
- </itemgra>
- <itemgra item_types="poi_jewish" order="11-">
- <icon src="jewish.png"/>
- </itemgra>
- <itemgra item_types="poi_pagan" order="11-">
- <icon src="pagan.png"/>
- </itemgra>
- <itemgra item_types="poi_pastafarian" order="11-">
- <icon src="pastafarian.png"/>
- </itemgra>
- <itemgra item_types="poi_shinto" order="11-">
- <icon src="shinto.png"/>
- </itemgra>
- <itemgra item_types="poi_sikh" order="11-">
- <icon src="sikh.png"/>
- </itemgra>
- <itemgra item_types="poi_taoist" order="11-">
- <icon src="taoist.png"/>
- </itemgra>
- <itemgra item_types="poi_cinema" order="12-">
- <icon src="cinema.png"/>
- </itemgra>
- <itemgra item_types="poi_communication" order="12-">
- <icon src="communication.xpm"/>
- </itemgra>
- <itemgra item_types="poi_concert" order="12-">
- <icon src="concert.xpm"/>
- </itemgra>
- <itemgra item_types="poi_cove" order="12-">
- <icon src="cove.xpm"/>
- </itemgra>
- <itemgra item_types="poi_crossing" order="12-">
- <icon src="crossing.xpm"/>
- </itemgra>
- <itemgra item_types="poi_dam" order="12-">
- <icon src="dam.png"/>
- </itemgra>
- <itemgra item_types="poi_danger_area" order="12-">
- <icon src="danger_16_16.png"/>
- </itemgra>
- <itemgra item_types="poi_danger_sea_wreck" order="12-">
- <icon src="dangerous.xpm"/>
- </itemgra>
- <itemgra item_types="poi_daymark" order="12-">
- <icon src="daymark.png"/>
- </itemgra>
- <itemgra item_types="poi_diving" order="12-">
- <icon src="diving.xpm"/>
- </itemgra>
- <itemgra item_types="poi_drinking_water" order="13-">
- <icon src="drinking_water.png"/>
- </itemgra>
- <itemgra item_types="poi_emergency" order="12-">
- <icon src="emergency.png"/>
- </itemgra>
- <itemgra item_types="poi_fair" order="12-">
- <icon src="fair.xpm"/>
- </itemgra>
- <itemgra item_types="poi_firebrigade" order="12-">
- <icon src="firebrigade.png"/>
- </itemgra>
- <itemgra item_types="poi_fish" order="9-">
- <icon src="fish.xpm"/>
- </itemgra>
- <itemgra item_types="poi_forbidden_area" order="12-">
- <icon src="forbiden_area.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_bicycle" order="12-">
- <icon src="bicycle_shop.png"/>
- </itemgra>
- <itemgra item_types="poi_shop_gps" order="15-">
- <icon src="garmin.xpm"/>
- </itemgra>
- <itemgra item_types="poi_golf" order="12-">
- <icon src="golf.png"/>
- </itemgra>
- <itemgra item_types="poi_government_building" order="12-">
- <icon src="goverment_building.xpm"/>
- </itemgra>
- <itemgra item_types="poi_height" order="12-">
- <icon src="height.xpm"/>
- </itemgra>
- <itemgra item_types="poi_heliport" order="8-">
- <icon src="heliport.png"/>
- </itemgra>
- <itemgra item_types="poi_hotspring" order="12-">
- <icon src="hotspring.xpm"/>
- </itemgra>
- <itemgra item_types="poi_icesport" order="12-">
- <icon src="icesport.xpm"/>
- </itemgra>
- <itemgra item_types="poi_information" order="12-">
- <icon src="information.png"/>
- </itemgra>
- <itemgra item_types="poi_justice" order="12-">
- <icon src="justice.png"/>
- </itemgra>
- <itemgra item_types="poi_landmark" order="11-">
- <icon src="landmark.xpm"/>
- </itemgra>
- <itemgra item_types="poi_levee" order="12-">
- <icon src="levee.xpm"/>
- </itemgra>
- <itemgra item_types="poi_level_crossing" order="11-">
- <icon src="level_crossing.xpm"/>
- </itemgra>
- <itemgra item_types="poi_library" order="12-">
- <icon src="library.png"/>
- </itemgra>
- <itemgra item_types="poi_locale" order="12-">
- <icon src="locale.xpm"/>
- </itemgra>
- <itemgra item_types="poi_loudspeaker" order="12-">
- <icon src="loudspeaker.xpm"/>
- </itemgra>
- <itemgra item_types="poi_mall" order="12-">
- <icon src="mall.xpm"/>
- </itemgra>
- <itemgra item_types="poi_manmade_feature" order="12-">
- <icon src="manmade_feature.xpm"/>
- </itemgra>
- <itemgra item_types="poi_marine" order="12-">
- <icon src="marine.png"/>
- </itemgra>
- <itemgra item_types="poi_marine_type" order="12-">
- <icon src="marine_type.png"/>
- </itemgra>
- <itemgra item_types="poi_mark" order="12-">
- <icon src="mark.png"/>
- </itemgra>
- <itemgra item_types="poi_military" order="11-">
- <icon src="military.png"/>
- </itemgra>
- <itemgra item_types="poi_mine" order="12-">
- <icon src="mine.xpm"/>
- </itemgra>
- <itemgra item_types="poi_nondangerous" order="12-">
- <icon src="nondangerous.xpm"/>
- </itemgra>
- <itemgra item_types="poi_oil_field" order="12-">
- <icon src="oil_field.xpm"/>
- </itemgra>
- <itemgra item_types="poi_peak" order="7-">
- <icon src="peak.png"/>
- </itemgra>
- <itemgra item_types="poi_personal_service" order="12-">
- <icon src="personal_service.xpm"/>
- </itemgra>
- <itemgra item_types="poi_pharmacy" order="12-">
- <icon src="pharmacy.png"/>
- </itemgra>
- <itemgra item_types="poi_post_office,poi_post_box" order="13-">
- <icon src="post.png"/>
- </itemgra>
- <itemgra item_types="poi_public_office" order="12-">
- <icon src="public_office.xpm"/>
- </itemgra>
- <itemgra item_types="poi_rail_halt" order="11-">
- <circle color="#ff0000" radius="3" width="3"/>
- <circle color="#000000" radius="5" width="2" text_size="8"/>
- </itemgra>
- <itemgra item_types="poi_rail_station" order="9-">
- <circle color="#ff0000" radius="3" width="3"/>
- <circle color="#000000" radius="6" width="2" text_size="8"/>
- </itemgra>
- <itemgra item_types="poi_rail_tram_stop" order="10-11">
- <circle color="#ff0000" radius="2" width="2"/>
- </itemgra>
- <itemgra item_types="poi_rail_tram_stop" order="12-">
- <circle color="#ff0000" radius="3" width="3"/>
- <circle color="#606060" radius="5" width="2" text_size="8"/>
- </itemgra>
- <itemgra item_types="poi_repair_service" order="12-">
- <icon src="repair_service.png"/>
- </itemgra>
- <itemgra item_types="poi_resort" order="12-">
- <icon src="resort.png"/>
- </itemgra>
- <itemgra item_types="poi_restaurant" order="12-">
- <icon src="restaurant.png"/>
- </itemgra>
- <itemgra item_types="poi_restricted_area" order="12-">
- <icon src="restricted_area.xpm"/>
- </itemgra>
- <itemgra item_types="poi_restroom" order="13-">
- <icon src="toilets.png"/>
- </itemgra>
- <itemgra item_types="poi_sailing" order="12-">
- <icon src="sailing.xpm"/>
- </itemgra>
- <itemgra item_types="poi_scenic_area" order="12-">
- <icon src="scenic_area.xpm"/>
- </itemgra>
- <itemgra item_types="poi_school" order="12-">
- <icon src="school.png"/>
- </itemgra>
- <itemgra item_types="poi_service" order="12-">
- <icon src="service.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_apparel" order="12-">
- <icon src="shop_apparel.png"/>
- </itemgra>
- <itemgra item_types="poi_shop_computer" order="12-">
- <icon src="shop_computer.png"/>
- </itemgra>
- <itemgra item_types="poi_shop_department" order="12-">
- <icon src="shop_department.png"/>
- </itemgra>
- <itemgra item_types="poi_shop_furniture" order="12-">
- <icon src="shop_furnish.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_grocery" order="12-">
- <icon src="shop_grocery.png"/>
- </itemgra>
- <itemgra item_types="poi_shop_handg" order="12-">
- <icon src="shop_handg.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_merchandise" order="12-">
- <icon src="shop_merchandise.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_retail" order="12-">
- <icon src="shop_retail.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shower" order="13-">
- <icon src="shower.xpm"/>
- </itemgra>
- <itemgra item_types="poi_skiing" order="11-">
- <icon src="skiing.png"/>
- </itemgra>
- <itemgra item_types="poi_social_service" order="12-">
- <icon src="social_service.xpm"/>
- </itemgra>
- <itemgra item_types="poi_sounding" order="12-">
- <icon src="sounding.xpm"/>
- </itemgra>
- <itemgra item_types="poi_sport" order="12-">
- <icon src="sport.xpm"/>
- </itemgra>
- <itemgra item_types="poi_stadium" order="11-">
- <icon src="stadium.png"/>
- </itemgra>
- <itemgra item_types="poi_swimming" order="12-">
- <icon src="swimming.png"/>
- </itemgra>
- <itemgra item_types="poi_telephone" order="13-">
- <icon src="telephone.png"/>
- </itemgra>
- <itemgra item_types="poi_theater" order="12-">
- <icon src="theater.png"/>
- </itemgra>
- <itemgra item_types="poi_tide" order="12-">
- <icon src="tide.xpm"/>
- </itemgra>
- <itemgra item_types="poi_tower" order="13-">
- <icon src="tower.xpm"/>
- </itemgra>
- <itemgra item_types="poi_townhall" order="12-">
- <icon src="townhall.png"/>
- </itemgra>
- <itemgra item_types="poi_trail" order="12-">
- <icon src="trail.xpm"/>
- </itemgra>
- <itemgra item_types="poi_truck_stop" order="12-">
- <icon src="truck_stop.xpm"/>
- </itemgra>
- <itemgra item_types="poi_tunnel" order="12-">
- <icon src="tunnel.xpm"/>
- </itemgra>
- <itemgra item_types="poi_wine" order="12-">
- <icon src="wine.xpm"/>
- </itemgra>
- <itemgra item_types="poi_worship" order="8-">
- <icon src="worship.png"/>
- </itemgra>
- <itemgra item_types="poi_wrecker" order="12-">
- <icon src="wrecker.xpm"/>
- </itemgra>
- <itemgra item_types="poi_zoo" order="9-">
- <icon src="zoo.png"/>
- </itemgra>
- <itemgra item_types="poi_picnic" order="12-">
- <icon src="picnic.png"/>
- </itemgra>
- <itemgra item_types="poi_playground" order="12-">
- <icon src="playground.png"/>
- </itemgra>
- <itemgra item_types="poi_gc_multi" order="12-">
- <icon src="gc_multi.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_tradi" order="12-">
- <icon src="gc_tradi.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_event" order="12-">
- <icon src="gc_event.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_mystery" order="12-">
- <icon src="gc_mystery.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_question" order="12-">
- <icon src="gc_question.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_stages" order="12-">
- <icon src="gc_stages.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_reference" order="12-">
- <icon src="gc_reference.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_webcam" order="12-">
- <icon src="gc_webcam.xpm"/>
- </itemgra>
- <itemgra item_types="traffic_signals" order="13-">
- <icon src="traffic_signals.png"/>
- </itemgra>
- <itemgra item_types="poi_wifi" order="13-">
- <icon src="wifi.png"/>
- </itemgra>
- <itemgra item_types="poi_taxi" order="13-">
- <icon src="taxi.png"/>
- </itemgra>
- <itemgra item_types="poi_image" order="12-">
- <image/>
- </itemgra>
- <!-- I'm not sure if the following stuff should appear in any layout. Maybe portions should only apply to the bicyle layout. -->
- <itemgra item_types="poi_bench" order="13-">
- <icon src="bench.png"/>
- </itemgra>
- <itemgra item_types="poi_biergarten" order="12-">
- <icon src="beer.png"/>
- </itemgra>
- <itemgra item_types="poi_boundary_stone" order="13-">
- <icon src="boundary_stone.png"/>
- </itemgra>
- <itemgra item_types="poi_castle" order="11-">
- <icon src="castle.png"/>
- </itemgra>
- <itemgra item_types="poi_ruins" order="11-">
- <icon src="ruins.png"/>
- </itemgra>
- <itemgra item_types="poi_hunting_stand" order="12-">
- <icon src="hunting_stand.png"/>
- </itemgra>
- <itemgra item_types="poi_memorial" order="12-">
- <icon src="memorial.png"/>
- </itemgra>
- <itemgra item_types="poi_monument" order="12-">
- <icon src="memorial.png"/>
- </itemgra>
- <itemgra item_types="poi_shelter" order="11-">
- <icon src="shelter.png"/>
- </itemgra>
- <itemgra item_types="poi_fountain" order="13-">
- <icon src="fountain.png"/>
- </itemgra>
- <itemgra item_types="poi_potable_water" order="13-">
- <icon src="drinking_water.png"/>
- </itemgra>
- <itemgra item_types="poi_toilets" order="12-">
- <icon src="toilets.png"/>
- </itemgra>
- <itemgra item_types="poi_viewpoint" order="10-">
- <icon src="viewpoint.png"/>
- </itemgra>
- <itemgra item_types="tec_common" order="11-">
- <icon src="tec_common.png"/>
- </itemgra>
- <itemgra item_types="vehicle" order="0-">
- <icon src="gui_vehicle_16_16.png" />
- </itemgra>
- <itemgra item_types="vehicle_pedestrian" order="0-">
- <icon src="gui_vehicle_pedestrian_16_16.png" />
- </itemgra>
- <itemgra item_types="poi_custom0,poi_custom1,poi_custom2,poi_custom3,poi_custom4,poi_custom5,poi_custom6,poi_custom7,poi_custom8,poi_custom9,poi_customa,poi_customb,poi_customc,poi_customd,poi_custome,poi_customf" order="10-">
- <icon src="%s" />
- </itemgra>
- </layer>
- <layer name="POI Labels">
- <itemgra item_types="poi_airport,town_ghost,poi_hotel,poi_car_parking,poi_car_dealer_parts,poi_car_sharing,poi_fuel,poi_shopping,poi_attraction,poi_cafe,poi_bar,poi_pub,highway_exit,poi_camp_rv,poi_museum_history,poi_hospital,poi_dining,poi_fastfood,poi_police,poi_autoservice,poi_bank,poi_atm,poi_bus_station,poi_bus_stop,poi_business_service,poi_car_rent,poi_church,poi_bahai,poi_buddhist,poi_hindu,poi_islamic,poi_jain,poi_jewish,poi_pagan,poi_pastafarian,poi_shinto,poi_sikh,poi_taoist,poi_cinema,poi_concert,poi_drinking_water,poi_emergency,poi_fair,poi_fish,poi_government_building,poi_hotspring,poi_information,poi_justice,poi_landmark,poi_library,poi_mall,poi_manmade_feature,poi_marine,poi_marine_type,poi_mark,poi_oil_field,poi_peak,poi_personal_service,poi_pharmacy,poi_post_office,poi_public_office,poi_rail_halt,poi_rail_station,poi_rail_tram_stop,poi_repair_service,poi_resort,poi_restaurant,poi_restricted_area,poi_sailing,poi_scenic_area,poi_school,poi_service,poi_shop_bicycle,poi_shop_retail,poi_skiing,poi_social_service,poi_sport,poi_stadium,poi_swimming,poi_theater,poi_townhall,poi_trail,poi_truck_stop,poi_tunnel,poi_worship,poi_wrecker,poi_zoo,poi_biergarten,poi_castle,poi_ruins,poi_memorial,poi_monument,poi_shelter,poi_fountain,poi_viewpoint,vehicle" order="14-">
- <circle color="#606060" radius="0" width="0" text_size="10"/>
- </itemgra>
- <itemgra item_types="poi_custom0,poi_custom1,poi_custom2,poi_custom3,poi_custom4,poi_custom5,poi_custom6,poi_custom7,poi_custom8,poi_custom9,poi_customa,poi_customb,poi_customc,poi_customd,poi_custome,poi_customf" order="14-">
- <circle color="#606060" radius="0" width="0" text_size="10"/>
- </itemgra>
- </layer>
- <layer name="Found items" ref="Found items"/>
- </layout>
-
- <layout name="Car-dark" daylayout="Car" color="#011001">
-
- <cursor w="57" h="57">
- <itemgra speed_range="-2">
- <polyline color="#0000BC" radius="0" width="4">
- <coord x="0" y="0" />
- </polyline>
- <circle color="#000085" radius="9" width="3">
- <coord x="0" y="0" />
- </circle>
- <circle color="#0000BC" radius="13" width="3">
- <coord x="0" y="0" />
- </circle>
- <circle color="#000085" radius="18" width="3">
- <coord x="0" y="0" />
- </circle>
- </itemgra>
- <itemgra speed_range="3-">
- <polygon color="#000085">
- <coord x="-21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="-21" y="-18" />
- </polygon>
- <polygon color="#0000BC">
- <coord x="21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="21" y="-18" />
- </polygon>
- <polygon color="#00009C">
- <coord x="-21" y="-18" />
- <coord x="0" y="-3" />
- <coord x="0" y="-9" />
- <coord x="-21" y="-18" />
- </polygon>
- <polygon color="#000065">
- <coord x="21" y="-18" />
- <coord x="0" y="-3" />
- <coord x="0" y="-9" />
- <coord x="21" y="-18" />
- </polygon>
- <polyline color="#000085" width="1">
- <coord x="-21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="-21" y="-18" />
- </polyline>
- <polyline color="#000085" width="1">
- <coord x="21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="21" y="-18" />
- </polyline>
- <polyline color="#000085" width="1">
- <coord x="-21" y="-18" />
- <coord x="0" y="-3" />
- <coord x="0" y="-9" />
- <coord x="-21" y="-18" />
- </polyline>
- <polyline color="#000085" width="1">
- <coord x="21" y="-18" />
- <coord x="0" y="-3" />
- <coord x="0" y="-9" />
- <coord x="21" y="-18" />
- </polyline>
- </itemgra>
- </cursor>
-
- <layer name="polygons"><!-- Colors based on Car layout; R/34 G/8 B/9 -->
- <itemgra item_types="image" order="0-">
- <image/>
- </itemgra>
- <itemgra item_types="poly_nature_reserve" order="10-">
- <polygon color="#061d15"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_glacier" order="10-">
- <polygon color="#071e19"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_town" order="0-">
- <polygon color="#191711"/>
- </itemgra>
- <itemgra item_types="poly_naval_base" order="10-">
- <polygon color="#03140f"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_airfield" order="10-">
- <polygon color="#071b16"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_university" order="8-">
- <polygon color="#140f14"/>
- </itemgra>
- <itemgra item_types="poly_college" order="10-">
- <polygon color="#071f1a"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_attraction" order="10-">
- <polygon color="#00150b"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_theme_park" order="10-">
- <polygon color="#00150b"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_water_park" order="10-">
- <polygon color="#041915"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_zoo" order="10-">
- <polygon color="#061811"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_depot" order="10-">
- <polygon color="#051610"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_railway" order="10-">
- <polygon color="#051815"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_port" order="10-">
- <polygon color="#031111"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_marina" order="10-">
- <polygon color="#051916"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_commercial" order="10-">
- <polygon color="#071f16"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_retail" order="10-">
- <polygon color="#06170f"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_plaza" order="10-">
- <polygon color="#061914"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_battlefield" order="10-">
- <polygon color="#010703"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_archaeological_site" order="10-">
- <polygon color="#061b13"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_ruins" order="10-">
- <polygon color="#061b13"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_camp_site" order="10-">
- <polygon color="#011400"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_caravan_site" order="10-">
- <polygon color="#041303"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_golf_course" order="10-">
- <polygon color="#021403"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_marsh" order="10-">
- <polygon color="#020803"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_fell" order="10-">
- <polygon color="#05170b"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_greenfield" order="10-">
- <polygon color="#071f19"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_brownfield" order="10-">
- <polygon color="#05170f"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_heath" order="10-">
- <polygon color="#061c11"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_scree" order="10-">
- <polygon color="#071d17"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_quarry" order="10-">
- <polygon color="#071a12"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_landfill" order="10-">
- <polygon color="#04130f"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_construction" order="10-">
- <polygon color="#070e02"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_range" order="10-">
- <polygon color="#030d0a"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_danger_area" order="10-">
- <polygon color="#071802"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_common" order="10-">
- <polygon color="#031605"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_recreation_ground" order="10-">
- <polygon color="#041500"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_playground" order="10-">
- <polygon color="#05190d"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_fishing" order="10-">
- <polygon color="#030700"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_allotments" order="10-">
- <polygon color="#071b13"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_garden" order="10-">
- <polygon color="#061e12"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_village_green" order="10-">
- <polygon color="#041607"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_picnic_site" order="10-">
- <polygon color="#030f07"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_wood" order="0-">
- <polygon color="#041a06"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_greenhouse" order="10-">
- <polygon color="#071d16"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_orchard" order="10-">
- <polygon color="#041b10"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_plantnursery" order="10-">
- <polygon color="#051b12"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_farm" order="0-">
- <polygon color="#041a06"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_meadow" order="0-">
- <polygon color="#041a06"/>
- </itemgra>
- <itemgra item_types="poly_land" order="0-">
- <polygon color="#011001"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_flats,poly_scrub,poly_military_zone,poly_marine,plantation,tundra" order="0-">
- <polygon color="#041a06"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_park" order="0-">
- <polygon color="#041a06"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_beach" order="0-">
- <polygon color="#081f0b"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_mud" order="0-">
- <polygon color="#02071d"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="10">
- <polygon color="#202020"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="11">
- <polyline color="#1e0728" width="3"/>
- <polygon color="#202020"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="12">
- <polyline color="#1e0728" width="5"/>
- <polygon color="#202020"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="13">
- <polyline color="#1e0728" width="6"/>
- <polygon color="#202020"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="14">
- <polyline color="#1e0728" width="7"/>
- <polygon color="#202020"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="15">
- <polyline color="#1e0728" width="9"/>
- <polygon color="#202020"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="16">
- <polyline color="#1e0728" width="10"/>
- <polygon color="#202020"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="17">
- <polyline color="#1e0728" width="12"/>
- <polygon color="#202020"/>
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="18">
- <polyline color="#1e0728" width="20"/>
- <polygon color="#202020"/>
- </itemgra>
- <itemgra item_types="poly_airport" order="0-">
- <polygon color="#002e00"/>
- </itemgra>
- <itemgra item_types="poly_sport,poly_sports_pitch" order="0-">
- <polygon color="#0c220c"/>
- </itemgra>
- <itemgra item_types="poly_industry,poly_place" order="0-">
- <polygon color="#111111"/>
- </itemgra>
- <itemgra item_types="poly_service" order="8-18">
- <polygon color="#1a1a1a"/>
- <polyline color="#282828" width="1"/>
- </itemgra>
- <itemgra item_types="poly_street_1" order="8-13">
- <polygon color="#24092f"/>
- </itemgra>
- <itemgra item_types="poly_street_1" order="14-16">
- <polygon color="#24092f"/>
- </itemgra>
- <itemgra item_types="poly_street_1" order="17-18">
- <polygon color="#24092f"/>
- </itemgra>
- <itemgra item_types="poly_street_2" order="7-12">
- <polygon color="#c5c300"/>
- <polyline color="#c0c0c0" width="1"/>
- </itemgra>
- <itemgra item_types="poly_street_2" order="13-16">
- <polygon color="#c5c300"/>
- <polyline color="#c0c0c0" width="2"/>
- </itemgra>
- <itemgra item_types="poly_street_2" order="17-18">
- <polygon color="#c5c300"/>
- <polyline color="#c0c0c0" width="3"/>
- </itemgra>
- <itemgra item_types="poly_street_3" order="7-11">
- <polygon color="#c5c300"/>
- <polyline color="#a0a0a0" width="1"/>
- </itemgra>
- <itemgra item_types="poly_street_3" order="12-15">
- <polygon color="#c5c300"/>
- <polyline color="#a0a0a0" width="2"/>
- </itemgra>
- <itemgra item_types="poly_street_3" order="16-18">
- <polygon color="#c5c300"/>
- <polyline color="#a0a0a0" width="3"/>
- </itemgra>
- <itemgra item_types="poly_saltpond" order="10-">
- <polygon color="#061008"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_water,poly_basin,poly_reservoir" order="0-">
- <polygon color="#010321"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="water_line" order="0-">
- <polyline color="#010321" width="1"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="water_river" order="4-5">
- <polyline color="#010321" width="1"/>
- </itemgra>
- <itemgra item_types="water_river" order="6">
- <polyline color="#010321" width="2"/>
- </itemgra>
- <itemgra item_types="water_river" order="7">
- <polyline color="#010321" width="3"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="water_river" order="8-9">
- <polyline color="#010321" width="4"/>
- <text color="#55c4bd" background_color="#000000" text_size="7"/>
- </itemgra>
- <itemgra item_types="water_river" order="10-">
- <polyline color="#010321" width="4"/>
- <text color="#55c4bd" background_color="#000000" text_size="10"/>
- </itemgra>
- <itemgra item_types="water_canal" order="6">
- <polyline color="#010321" width="1"/>
- </itemgra>
- <itemgra item_types="water_canal" order="7">
- <polyline color="#010321" width="2"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="water_canal" order="8-9">
- <polyline color="#010321" width="3"/>
- <text color="#55c4bd" background_color="#000000" text_size="7"/>
- </itemgra>
- <itemgra item_types="water_canal" order="10-">
- <polyline color="#010321" width="3"/>
- <text color="#55c4bd" background_color="#000000" text_size="10"/>
- </itemgra>
- <itemgra item_types="water_stream" order="8-9">
- <polyline color="#010321" width="1"/>
- </itemgra>
- <itemgra item_types="water_stream" order="10-">
- <polyline color="#010321" width="2"/>
- <text color="#55c4bd" background_color="#000000" text_size="7"/>
- </itemgra>
- <itemgra item_types="water_drain" order="10-">
- <polyline color="#010321" width="1"/>
- <text color="#55c4bd" background_color="#000000" text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_apron" order="0-">
- <polygon color="#041a06"/>
- </itemgra>
- <itemgra item_types="poly_terminal" order="7-">
- <polygon color="#282424"/>
- </itemgra>
- <itemgra item_types="poly_cemetery" order="8-">
- <polygon color="#041a06"/>
- </itemgra>
- <itemgra item_types="poly_car_parking" order="8-">
- <polygon color="#1a170f"/>
- </itemgra>
- <itemgra item_types="poly_artwork" order="10-">
- <polygon color="#082015"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_sports_stadium" order="10-">
- <polygon color="#03180a"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_sports_track" order="10-">
- <polygon color="#050b08"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_barracks" order="10-">
- <polygon color="#051511"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_garages" order="10-">
- <polygon color="#061b16"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_building" order="8-">
- <polygon color="#282424"/>
- </itemgra>
- <itemgra item_types="rail" order="6-8">
- <polyline color="#282828" width="2"/>
- <polyline color="#3d3d3d" dash="1,5" width="1"/>
- </itemgra>
- <itemgra item_types="rail" order="9-">
- <polyline color="#282828" width="3"/>
- <polyline color="#3d3d3d" dash="1,5" width="1"/>
- </itemgra>
- <itemgra item_types="ferry" order="5-">
- <polyline color="#113111" width="1" dash="10"/>
- </itemgra>
- <itemgra item_types="border_country" order="0-">
- <polyline color="#0d0b41" width="1" dash="10,5,2,5"/>
- </itemgra>
- <itemgra item_types="border_state" order="0-">
- <polyline color="#808080" width="1"/>
- </itemgra>
- </layer>
- <layer name="heightlines">
- <itemgra item_types="height_line_1" order="0-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="height_line_2" order="0-">
- <polyline color="#000000" width="2"/>
- </itemgra>
- </layer>
- <layer name="streets">
- <itemgra item_types="street_route" order="2">
- <polyline color="#0000a0" width="4"/>
- </itemgra>
- <itemgra item_types="street_route" order="3-5">
- <polyline color="#0000a0" width="8"/>
- </itemgra>
- <itemgra item_types="street_route" order="6">
- <polyline color="#0000a0" width="10"/>
- </itemgra>
- <itemgra item_types="street_route" order="7-8">
- <polyline color="#0000a0" width="16"/>
- </itemgra>
- <itemgra item_types="street_route" order="9-10">
- <polyline color="#0000a0" width="20"/>
- </itemgra>
- <itemgra item_types="street_route" order="11">
- <polyline color="#0000a0" width="28"/>
- </itemgra>
- <itemgra item_types="street_route" order="12">
- <polyline color="#0000a0" width="32"/>
- </itemgra>
- <itemgra item_types="street_route" order="13">
- <polyline color="#0000a0" width="52"/>
- </itemgra>
- <itemgra item_types="street_route" order="14">
- <polyline color="#0000a0" width="64"/>
- </itemgra>
- <itemgra item_types="street_route" order="15">
- <polyline color="#0000a0" width="68"/>
- </itemgra>
- <itemgra item_types="street_route" order="16">
- <polyline color="#0000a0" width="132"/>
- </itemgra>
- <itemgra item_types="street_route" order="17">
- <polyline color="#0000a0" width="268"/>
- </itemgra>
- <itemgra item_types="street_route" order="18">
- <polyline color="#0000a0" width="530"/>
- </itemgra>
- <itemgra item_types="street_nopass" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="track_paved" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="track_gravelled" order="10-12">
- <polyline color="#800000" width="1" dash="3,6"/>
- </itemgra>
- <itemgra item_types="track_gravelled" order="13-14">
- <polyline color="#3d3d3d" width="4"/>
- <polyline color="#800000" width="1" dash="4,8"/>
- </itemgra>
- <itemgra item_types="track_gravelled" order="15-16">
- <polyline color="#3d3d3d" width="5"/>
- <polyline color="#800000" width="1" dash="5,10"/>
- </itemgra>
- <itemgra item_types="track_gravelled" order="17-">
- <polyline color="#3d3d3d" width="7"/>
- <polyline color="#800000" width="1" dash="7,15"/>
- </itemgra>
- <itemgra item_types="track_unpaved" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="bridleway" order="10-">
- <polyline color="#1e0728" width="1"/>
- </itemgra>
- <itemgra item_types="cycleway" order="10-">
- <polyline color="#1e0728" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_novice" order="10-12">
- <polyline color="#00A000" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_novice" order="13-14">
- <polyline color="#00A000" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_novice" order="15-16">
- <polyline color="#00A000" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_novice" order="17-">
- <polyline color="#00A000" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_easy" order="10-12">
- <polyline color="#0000ff" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_easy" order="13-14">
- <polyline color="#0000ff" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_easy" order="15-16">
- <polyline color="#0000ff" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_easy" order="17-">
- <polyline color="#0000ff" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_intermediate" order="10-12">
- <polyline color="#900000" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_intermediate" order="13-14">
- <polyline color="#900000" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_intermediate" order="15-16">
- <polyline color="#900000" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_intermediate" order="17-">
- <polyline color="#900000" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_advanced" order="10-12">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_advanced" order="13-14">
- <polyline color="#000000" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_advanced" order="15-16">
- <polyline color="#000000" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_advanced" order="17-">
- <polyline color="#000000" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_expert" order="10-12">
- <polyline color="#ffaa00" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_expert" order="13-14">
- <polyline color="#ffaa00" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_expert" order="15-16">
- <polyline color="#ffaa00" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_expert" order="17-">
- <polyline color="#ffaa00" width="5"/>
- </itemgra>
- <itemgra item_types="piste_downhill_freeride" order="10-12">
- <polyline color="#c5c300" width="1"/>
- </itemgra>
- <itemgra item_types="piste_downhill_freeride" order="13-14">
- <polyline color="#c5c300" width="2"/>
- </itemgra>
- <itemgra item_types="piste_downhill_freeride" order="15-16">
- <polyline color="#c5c300" width="3"/>
- </itemgra>
- <itemgra item_types="piste_downhill_freeride" order="17-">
- <polyline color="#c5c300" width="5"/>
- </itemgra>
- <itemgra item_types="lift_cable_car" order="6-">
- <polyline color="#3d3d3d" width="1" dash="5"/>
- </itemgra>
- <itemgra item_types="lift_chair" order="6-">
- <polyline color="#3d3d3d" width="1" dash="5"/>
- </itemgra>
- <itemgra item_types="lift_drag" order="6-">
- <polyline color="#3d3d3d" width="1" dash="5"/>
- </itemgra>
- <itemgra item_types="piste_nordic" order="10-12">
- <polyline color="#0000ff" width="1" dash="3,6"/>
- </itemgra>
- <itemgra item_types="piste_nordic" order="13-14">
- <polyline color="#0000ff" width="2"/>
- <polyline color="#000000" width="1" dash="4,8"/>
- </itemgra>
- <itemgra item_types="piste_nordic" order="15-16">
- <polyline color="#0000ff" width="3"/>
- <polyline color="#000000" width="1" dash="5,10"/>
- </itemgra>
- <itemgra item_types="piste_nordic" order="17-">
- <polyline color="#0000ff" width="5"/>
- <polyline color="#000000" width="1" dash="7,15"/>
- </itemgra>
- <itemgra item_types="footway" order="11-12">
- <polyline color="#4e0000" width="1" dash="3,6"/>
- </itemgra>
- <itemgra item_types="footway" order="13-14">
- <polyline color="#4e0000" width="2"/>
- <polyline color="#000000" width="1" dash="4,8"/>
- </itemgra>
- <itemgra item_types="footway" order="15-16">
- <polyline color="#4e0000" width="3"/>
- <polyline color="#000000" width="1" dash="5,10"/>
- </itemgra>
- <itemgra item_types="footway" order="17-">
- <polyline color="#4e0000" width="5"/>
- <polyline color="#000000" width="1" dash="7,15"/>
- </itemgra>
- <itemgra item_types="steps" order="14-15">
- <polyline color="#4d4e11" width="1"/>
- </itemgra>
- <itemgra item_types="steps" order="16">
- <polyline color="#4d4e11" width="2"/>
- </itemgra>
- <itemgra item_types="steps" order="17-18">
- <polyline color="#4d4e11" width="3"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="10">
- <polyline color="#1e0728" width="1"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="11">
- <polyline color="#1e0728" width="5"/>
- <polyline color="#202020" width="2"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="12">
- <polyline color="#1e0728" width="8"/>
- <polyline color="#202020" width="3"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="13">
- <polyline color="#1e0728" width="9"/>
- <polyline color="#202020" width="4"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="14">
- <polyline color="#1e0728" width="13"/>
- <polyline color="#202020" width="7"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="15">
- <polyline color="#1e0728" width="18"/>
- <polyline color="#202020" width="10"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="16">
- <polyline color="#1e0728" width="21"/>
- <polyline color="#202020" width="13"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="17">
- <polyline color="#1e0728" width="25"/>
- <polyline color="#202020" width="17"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="18">
- <polyline color="#1e0728" width="40"/>
- <polyline color="#202020" width="30"/>
- </itemgra>
- <itemgra item_types="street_service" order="10">
- <polyline color="#2c2c2c" width="2"/>
- </itemgra>
- <itemgra item_types="street_service" order="11">
- <polyline color="#2c2c2c" width="2"/>
- </itemgra>
- <itemgra item_types="street_service" order="12">
- <polyline color="#2c2c2c" width="3"/>
- </itemgra>
- <itemgra item_types="street_service" order="13">
- <polyline color="#2c2c2c" width="4"/>
- </itemgra>
- <itemgra item_types="street_service" order="14">
- <polyline color="#2c2c2c" width="5"/>
- </itemgra>
- <itemgra item_types="street_service" order="15">
- <polyline color="#2c2c2c" width="6"/>
- </itemgra>
- <itemgra item_types="street_service" order="16">
- <polyline color="#2c2c2c" width="7"/>
- </itemgra>
- <itemgra item_types="street_service" order="17">
- <polyline color="#2c2c2c" width="8"/>
- </itemgra>
- <itemgra item_types="street_service" order="18">
- <polyline color="#2c2c2c" width="9"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="12">
- <polyline color="#2c2c2c" width="2"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="13">
- <polyline color="#2c2c2c" width="2"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="14">
- <polyline color="#2c2c2c" width="3"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="15">
- <polyline color="#2c2c2c" width="4"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="16">
- <polyline color="#2c2c2c" width="5"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="17">
- <polyline color="#2c2c2c" width="6"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="18">
- <polyline color="#2c2c2c" width="7"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="10">
- <polyline color="#24092f" width="2"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="11">
- <polyline color="#24092f" width="3"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="12">
- <polyline color="#24092f" width="5"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="13">
- <polyline color="#24092f" width="9"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="14">
- <polyline color="#24092f" width="13"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="15">
- <polyline color="#24092f" width="14"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="16">
- <polyline color="#24092f" width="26"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="17">
- <polyline color="#24092f" width="61"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="18">
- <polyline color="#24092f" width="126"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="8">
- <polyline color="#1d4c19" width="1"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="9">
- <polyline color="#1d4c19" width="1"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="10">
- <polyline color="#1d4c19" width="2"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="11">
- <polyline color="#1d4c19" width="4"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="12">
- <polyline color="#1d4c19" width="7"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="13">
- <polyline color="#1d4c19" width="11"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="14">
- <polyline color="#1d4c19" width="14"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="15">
- <polyline color="#1d4c19" width="17"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="16">
- <polyline color="#1d4c19" width="30"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="17">
- <polyline color="#1d4c19" width="67"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="18">
- <polyline color="#1d4c19" width="138"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="7-8">
- <polyline color="#4d4e11" width="1"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="9">
- <polyline color="#4d4e11" width="2"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="10">
- <polyline color="#4d4e11" width="4"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="11">
- <polyline color="#4d4e11" width="5"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="12">
- <polyline color="#4d4e11" width="7"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="13">
- <polyline color="#4d4e11" width="14"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="14">
- <polyline color="#4d4e11" width="17"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="15">
- <polyline color="#4d4e11" width="21"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="16">
- <polyline color="#4d4e11" width="34"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="17">
- <polyline color="#4d4e11" width="73"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp,roundabout" order="18">
- <polyline color="#4d4e11" width="150"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="2-5">
- <polyline color="#430000" width="1"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="6-8">
- <polyline color="#430000" width="2"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="9">
- <polyline color="#430000" width="3"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="10">
- <polyline color="#430000" width="4"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11">
- <polyline color="#430000" width="7"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="12">
- <polyline color="#430000" width="9"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="13">
- <polyline color="#430000" width="14"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="14">
- <polyline color="#430000" width="17"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="15">
- <polyline color="#430000" width="20"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="16">
- <polyline color="#430000" width="33"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="17">
- <polyline color="#430000" width="72"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="18">
- <polyline color="#430000" width="150"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="2">
- <polyline color="#760000" width="1"/>
- </itemgra>
- <!--1d4c19/0d740d-->
- <itemgra item_types="highway_city,highway_land" order="3-5">
- <polyline color="#640000" width="3"/>
- <polyline color="#0a5c0a" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="6">
- <polyline color="#640000" width="4"/>
- <polyline color="#0a5c0a" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="7-8">
- <polyline color="#640000" width="6"/>
- <polyline color="#005b00" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="9-10">
- <polyline color="#640000" width="8"/>
- <polyline color="#0a5c0a" width="2"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="11">
- <polyline color="#640000" width="12"/>
- <polyline color="#0a5c0a" width="3"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="12">
- <polyline color="#640000" width="13"/>
- <polyline color="#0a5c0a" width="3"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="13">
- <polyline color="#640000" width="17"/>
- <polyline color="#0a5c0a" width="4"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="14">
- <polyline color="#640000" width="24"/>
- <polyline color="#0a5c0a" width="4"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="15">
- <polyline color="#640000" width="27"/>
- <polyline color="#0a5c0a" width="5"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="16">
- <polyline color="#640000" width="59"/>
- <polyline color="#0a5c0a" width="6"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="17">
- <polyline color="#640000" width="127"/>
- <polyline color="#0a5c0a" width="7"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="18">
- <polyline color="#640000" width="258"/>
- <polyline color="#0a5c0a" width="8"/>
- </itemgra>
- <!-- This entry shows all unknown linear elements as blue lines -->
- <!--
- <itemgra item_types="street_unkn" order="0-">
- <polyline color="#8080ff" width="3"/>
- </itemgra>
- -->
- <itemgra item_types="highway_exit_label" order="10-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street" order="10-18">
- <text text_size="8" color="#55c4bd" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp" order="11-18">
- <text text_size="9" color="#55c4bd" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land,footway" order="12-18">
- <text text_size="9" color="#55c4bd" background_color="#000000"/>
- </itemgra>
- </layer>
- <layer name="polylines">
- <itemgra item_types="aeroway_taxiway" order="10">
- <polyline color="#404040" width="4"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="11">
- <polyline color="#404040" width="6"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="12">
- <polyline color="#404040" width="10"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="13">
- <polyline color="#404040" width="12"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="14">
- <polyline color="#404040" width="15"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="15">
- <polyline color="#404040" width="17"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="16">
- <polyline color="#404040" width="33"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="17">
- <polyline color="#404040" width="69"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="18">
- <polyline color="#404040" width="132"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="2-6">
- <polyline color="#404040" width="1"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="7-8">
- <polyline color="#404040" width="3"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="9">
- <polyline color="#404040" width="5"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="10">
- <polyline color="#404040" width="6"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="11">
- <polyline color="#404040" width="9"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="12">
- <polyline color="#404040" width="13"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="13">
- <polyline color="#404040" width="18"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="14">
- <polyline color="#404040" width="21"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="15">
- <polyline color="#404040" width="24"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="16">
- <polyline color="#404040" width="39"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="17">
- <polyline color="#404040" width="78"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="18">
- <polyline color="#404040" width="156"/>
- </itemgra>
- <itemgra item_types="rail_tram,bus_guideway" order="10-">
- <polyline color="#3d3d3d" width="2"/>
- </itemgra>
- </layer>
- <layer name="labels">
- <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="12-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3" order="11-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="town_label_1e3,town_label_2e3,town_label_5e3,place_label" order="10-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4" order="9-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="town_label_1e4,town_label_2e4,town_label_5e4" order="8-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5" order="6-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="4-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6" order="3-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6" order="2-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="town_label_1e7,district_label_1e7" order="1-">
- <circle color="#55c4bd" background_color="#000000" radius="3" text_size="15"/>
- </itemgra>
- </layer>
- <layer name="Internal">
- <itemgra item_types="track" order="3-">
- <polyline color="#3f3f3f" width="1"/>
- </itemgra>
- <itemgra item_types="track_tracked" order="7-">
- <polyline color="#3f3fff" width="3"/>
- </itemgra>
- <itemgra item_types="rg_segment" order="0-">
- <polyline color="#FF089C" width="1"/>
- <arrows color="#FF089C" width="1"/>
- </itemgra>
- <itemgra item_types="rg_point" order="0-">
- <circle color="#FF089C" radius="10" background_color="#000000" text_size="7"/>
- </itemgra>
- <itemgra item_types="nav_left_1" order="0-">
- <icon src="nav_left_1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_left_2" order="0-">
- <icon src="nav_left_2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_left_3" order="0-">
- <icon src="nav_left_3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_right_1" order="0-">
- <icon src="nav_right_1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_right_2" order="0-">
- <icon src="nav_right_2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_right_3" order="0-">
- <icon src="nav_right_3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_straight" order="0-">
- <icon src="nav_straight_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_turnaround_left" order="0-">
- <icon src="nav_turnaround_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_turnaround_right" order="0-">
- <icon src="nav_turnaround_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l1" order="0-">
- <icon src="nav_roundabout_l1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r1" order="0-">
- <icon src="nav_roundabout_r1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l2" order="0-">
- <icon src="nav_roundabout_l2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r2" order="0-">
- <icon src="nav_roundabout_r2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l3" order="0-">
- <icon src="nav_roundabout_l3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r3" order="0-">
- <icon src="nav_roundabout_r3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l4" order="0-">
- <icon src="nav_roundabout_l4_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r4" order="0-">
- <icon src="nav_roundabout_r4_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l5" order="0-">
- <icon src="nav_roundabout_l5_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r5" order="0-">
- <icon src="nav_roundabout_r5_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l6" order="0-">
- <icon src="nav_roundabout_l6_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r6" order="0-">
- <icon src="nav_roundabout_r6_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l7" order="0-">
- <icon src="nav_roundabout_l7_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r7" order="0-">
- <icon src="nav_roundabout_r7_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l8" order="0-">
- <icon src="nav_roundabout_l8_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r8" order="0-">
- <icon src="nav_roundabout_r8_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_keep_left" order="0-">
- <icon src="nav_keep_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_merge_left" order="0-">
- <icon src="nav_merge_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_keep_right" order="0-">
- <icon src="nav_keep_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_merge_right" order="0-">
- <icon src="nav_merge_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_exit_left" order="0-">
- <icon src="nav_exit_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_exit_right" order="0-">
- <icon src="nav_exit_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="route_end" order="0-">
- <icon src="nav_destination_wh.svg" w="32" h="32" x="4" y="30"/>
- </itemgra>
- <itemgra item_types="nav_none" order="0-">
- <icon src="unknown.svg"/>
- </itemgra>
- <itemgra item_types="announcement" order="7-">
- <icon src="gui_sound_32_32.png"/>
- <circle color="#FF089C" radius="10" background_color="#000000" text_size="7"/>
- </itemgra>
-
- <itemgra item_types="waypoint,route_end" order="2">
- <circle color="#00a0a0" radius="4" width="2" background_color="#000000" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="3-5">
- <circle color="#00a0a0" radius="8" width="2" background_color="#000000" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="6">
- <circle color="#00a0a0" radius="10" width="2" background_color="#000000" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="7-8">
- <circle color="#00a0a0" radius="16" width="2" background_color="#000000" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="9-10">
- <circle color="#00a0a0" radius="20" width="4" background_color="#000000" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="11">
- <circle color="#00a0a0" radius="28" width="4" background_color="#000000" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="12">
- <circle color="#00a0a0" radius="32" width="4" background_color="#000000" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="13">
- <circle color="#00a0a0" radius="52" width="4" background_color="#000000" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="14">
- <circle color="#00a0a0" radius="64" width="4" background_color="#000000" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="15">
- <circle color="#00a0a0" radius="68" width="6" background_color="#000000" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="16">
- <circle color="#00a0a0" radius="132" width="8" background_color="#000000" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="17">
- <circle color="#00a0a0" radius="268" width="8" background_color="#000000" text_size="48"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="18">
- <circle color="#00a0a0" radius="530" width="8" background_color="#000000" text_size="48"/>
- </itemgra>
- </layer>
- <layer name="POI Symbols">
- <itemgra item_types="mini_roundabout" order="12-">
- <icon src="mini_roundabout.png"/>
- </itemgra>
- <itemgra item_types="turning_circle" order="12-">
- <icon src="mini_roundabout.png"/>
- </itemgra>
- <itemgra item_types="poi_airport" order="5-">
- <icon src="airport.png"/>
- </itemgra>
- <itemgra item_types="town_ghost" order="0-">
- <icon src="ghost_town.xpm"/>
- </itemgra>
- <itemgra item_types="poi_hotel" order="12-">
- <icon src="hotel.png"/>
- </itemgra>
- <itemgra item_types="poi_car_parking" order="11-">
- <icon src="parking.png"/>
- </itemgra>
- <itemgra item_types="poi_car_sharing" order="11-">
- <icon src="car_sharing.png"/>
- </itemgra>
- <itemgra item_types="poi_car_dealer_parts" order="0-">
- <icon src="car_dealer.png"/>
- </itemgra>
- <itemgra item_types="poi_fuel" order="10-">
- <icon src="fuel.png"/>
- </itemgra>
- <itemgra item_types="poi_shopping" order="10-">
- <icon src="shopping.png"/>
- </itemgra>
- <itemgra item_types="poi_attraction" order="8-">
- <icon src="attraction.png"/>
- </itemgra>
- <itemgra item_types="poi_cafe" order="12-">
- <icon src="cafe.png"/>
- </itemgra>
- <itemgra item_types="poi_bar" order="12-">
- <icon src="bar.png"/>
- </itemgra>
- <itemgra item_types="poi_pub" order="12-">
- <icon src="beer.png"/>
- </itemgra>
- <itemgra item_types="poi_bridge" order="0-">
- <icon src="bridge.xpm"/>
- </itemgra>
- <itemgra item_types="highway_exit" order="11-">
- <icon src="exit.png"/>
- </itemgra>
- <itemgra item_types="poi_camp_rv" order="9-">
- <icon src="camping.png"/>
- </itemgra>
- <itemgra item_types="poi_museum_history" order="12-">
- <icon src="museum.png"/>
- </itemgra>
- <itemgra item_types="poi_hospital" order="12-">
- <icon src="hospital.png"/>
- </itemgra>
- <!-- not really usefull -->
- <!--
- <itemgra item_types="point_unkn" order="0-">
- <circle color="#8080ff" radius="3"/>
- </itemgra>
- -->
- <itemgra item_types="poi_dining" order="12-">
- <icon src="restaurant.png"/>
- </itemgra>
- <itemgra item_types="poi_fastfood" order="12-">
- <icon src="fastfood.png"/>
- </itemgra>
- <itemgra item_types="poi_police" order="12-">
- <icon src="police.png"/>
- </itemgra>
- <itemgra item_types="poi_auto_club" order="0-">
- <icon src="auto_club.xpm"/>
- </itemgra>
- <itemgra item_types="poi_autoservice" order="0-">
- <icon src="car_dealer.png"/>
- </itemgra>
- <itemgra item_types="poi_bank" order="12-">
- <icon src="bank.png"/>
- </itemgra>
- <itemgra item_types="poi_atm" order="12-">
- <icon src="atm.png"/>
- </itemgra>
- <itemgra item_types="poi_bay" order="0-">
- <icon src="bay.xpm"/>
- </itemgra>
- <itemgra item_types="poi_bend" order="0-">
- <icon src="bend.xpm"/>
- </itemgra>
- <itemgra item_types="poi_boat_ramp" order="12-">
- <icon src="boat_ramp.png"/>
- </itemgra>
- <itemgra item_types="poi_border_station" order="0-">
- <icon src="border_station.xpm"/>
- </itemgra>
- <itemgra item_types="poi_bowling" order="0-">
- <icon src="bowling.xpm"/>
- </itemgra>
- <itemgra item_types="poi_bus_station" order="12-">
- <icon src="bus.png"/>
- </itemgra>
- <itemgra item_types="poi_bus_stop" order="12-">
- <icon src="bus_stop.png"/>
- </itemgra>
- <itemgra item_types="poi_business_service" order="0-">
- <icon src="bussines_service.xpm"/>
- </itemgra>
- <itemgra item_types="poi_car_rent" order="11-">
- <icon src="car_rent.png"/>
- </itemgra>
- <itemgra item_types="poi_car_wash" order="12-">
- <icon src="car_wash.xpm"/>
- </itemgra>
- <itemgra item_types="poi_casino" order="11-">
- <icon src="casino.png"/>
- </itemgra>
- <itemgra item_types="poi_cemetery" order="11-">
- <icon src="cemetery.xpm"/>
- </itemgra>
- <itemgra item_types="poi_church" order="11-">
- <icon src="church.png"/>
- </itemgra>
- <itemgra item_types="poi_bahai" order="11-">
- <icon src="bahai.png"/>
- </itemgra>
- <itemgra item_types="poi_buddhist" order="11-">
- <icon src="buddhist.png"/>
- </itemgra>
- <itemgra item_types="poi_hindu" order="11-">
- <icon src="hindu.png"/>
- </itemgra>
- <itemgra item_types="poi_islamic" order="11-">
- <icon src="islamic.png"/>
- </itemgra>
- <itemgra item_types="poi_jain" order="11-">
- <icon src="jain.png"/>
- </itemgra>
- <itemgra item_types="poi_jewish" order="11-">
- <icon src="jewish.png"/>
- </itemgra>
- <itemgra item_types="poi_pagan" order="11-">
- <icon src="pagan.png"/>
- </itemgra>
- <itemgra item_types="poi_pastafarian" order="11-">
- <icon src="pastafarian.png"/>
- </itemgra>
- <itemgra item_types="poi_shinto" order="11-">
- <icon src="shinto.png"/>
- </itemgra>
- <itemgra item_types="poi_sikh" order="11-">
- <icon src="sikh.png"/>
- </itemgra>
- <itemgra item_types="poi_taoist" order="11-">
- <icon src="taoist.png"/>
- </itemgra>
- <itemgra item_types="poi_cinema" order="12-">
- <icon src="cinema.png"/>
- </itemgra>
- <itemgra item_types="poi_communication" order="0-">
- <icon src="communication.xpm"/>
- </itemgra>
- <itemgra item_types="poi_concert" order="0-">
- <icon src="concert.xpm"/>
- </itemgra>
- <itemgra item_types="poi_cove" order="0-">
- <icon src="cove.xpm"/>
- </itemgra>
- <itemgra item_types="poi_crossing" order="0-">
- <icon src="crossing.xpm"/>
- </itemgra>
- <itemgra item_types="poi_dam" order="0-">
- <icon src="dam.png"/>
- </itemgra>
- <itemgra item_types="poi_danger_area" order="12-">
- <icon src="danger_16_16.png"/>
- </itemgra>
- <itemgra item_types="poi_danger_sea_wreck" order="0-">
- <icon src="dangerous.xpm"/>
- </itemgra>
- <itemgra item_types="poi_daymark" order="0-">
- <icon src="daymark.png"/>
- </itemgra>
- <itemgra item_types="poi_diving" order="0-">
- <icon src="diving.xpm"/>
- </itemgra>
- <itemgra item_types="poi_drinking_water" order="0-">
- <icon src="drinking_water.png"/>
- </itemgra>
- <itemgra item_types="poi_emergency" order="0-">
- <icon src="emergency.png"/>
- </itemgra>
- <itemgra item_types="poi_fair" order="0-">
- <icon src="fair.xpm"/>
- </itemgra>
- <itemgra item_types="poi_firebrigade" order="12-">
- <icon src="firebrigade.png"/>
- </itemgra>
- <itemgra item_types="poi_fish" order="0-">
- <icon src="fish.xpm"/>
- </itemgra>
- <itemgra item_types="poi_forbidden_area" order="0-">
- <icon src="forbiden_area.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_gps" order="0-">
- <icon src="garmin.xpm"/>
- </itemgra>
- <itemgra item_types="poi_golf" order="12-">
- <icon src="golf.png"/>
- </itemgra>
- <itemgra item_types="poi_government_building" order="0-">
- <icon src="goverment_building.xpm"/>
- </itemgra>
- <itemgra item_types="poi_height" order="0-">
- <icon src="height.xpm"/>
- </itemgra>
- <itemgra item_types="poi_heliport" order="7-">
- <icon src="heliport.png"/>
- </itemgra>
- <itemgra item_types="poi_hotspring" order="0-">
- <icon src="hotspring.xpm"/>
- </itemgra>
- <itemgra item_types="poi_icesport" order="0-">
- <icon src="icesport.xpm"/>
- </itemgra>
- <itemgra item_types="poi_information" order="12-">
- <icon src="information.png"/>
- </itemgra>
- <itemgra item_types="poi_justice" order="10-">
- <icon src="justice.png"/>
- </itemgra>
- <itemgra item_types="poi_landmark" order="0-">
- <icon src="landmark.png"/>
- </itemgra>
- <itemgra item_types="poi_levee" order="0-">
- <icon src="levee.xpm"/>
- </itemgra>
- <itemgra item_types="poi_level_crossing" order="11-">
- <icon src="level_crossing.xpm"/>
- </itemgra>
- <itemgra item_types="poi_library" order="12-">
- <icon src="library.png"/>
- </itemgra>
- <itemgra item_types="poi_locale" order="0-">
- <icon src="locale.xpm"/>
- </itemgra>
- <itemgra item_types="poi_loudspeaker" order="0-">
- <icon src="loudspeaker.xpm"/>
- </itemgra>
- <itemgra item_types="poi_mall" order="0-">
- <icon src="mall.xpm"/>
- </itemgra>
- <itemgra item_types="poi_manmade_feature" order="0-">
- <icon src="manmade_feature.xpm"/>
- </itemgra>
- <itemgra item_types="poi_marine" order="0-">
- <icon src="marine.png"/>
- </itemgra>
- <itemgra item_types="poi_marine_type" order="0-">
- <icon src="marine_type.png"/>
- </itemgra>
- <itemgra item_types="poi_mark" order="0-">
- <icon src="mark.png"/>
- </itemgra>
- <itemgra item_types="poi_military" order="0-">
- <icon src="military.png"/>
- </itemgra>
- <itemgra item_types="poi_mine" order="0-">
- <icon src="mine.xpm"/>
- </itemgra>
- <itemgra item_types="poi_nondangerous" order="0-">
- <icon src="nondangerous.xpm"/>
- </itemgra>
- <itemgra item_types="poi_oil_field" order="0-">
- <icon src="oil_field.xpm"/>
- </itemgra>
- <itemgra item_types="poi_peak" order="6-">
- <icon src="peak.png"/>
- </itemgra>
- <itemgra item_types="poi_personal_service" order="0-">
- <icon src="personal_service.xpm"/>
- </itemgra>
- <itemgra item_types="poi_pharmacy" order="12-">
- <icon src="pharmacy.png"/>
- </itemgra>
- <itemgra item_types="poi_post_office,poi_post_box" order="13-">
- <icon src="post.png"/>
- </itemgra>
- <itemgra item_types="poi_public_office" order="0-">
- <icon src="public_office.xpm"/>
- </itemgra>
- <itemgra item_types="poi_rail_halt" order="10-">
- <circle color="#000000" radius="3" width="3"/>
- <circle color="#3d3d3d" background_color="#000000" radius="6" width="2" text_size="8"/>
- </itemgra>
- <itemgra item_types="poi_rail_station" order="11-">
- <circle color="#000000" radius="3" width="3"/>
- <circle color="#3d3d3d" background_color="#000000" radius="6" width="2" text_size="8"/>
- </itemgra>
- <itemgra item_types="poi_rail_tram_stop" order="10-11">
- <circle color="#3d3d3d" background_color="#000000" radius="2" width="2"/>
- </itemgra>
- <itemgra item_types="poi_rail_tram_stop" order="12-">
- <circle color="#000000" radius="3" width="3"/>
- <circle color="#3d3d3d" background_color="#000000" radius="6" width="2" text_size="8"/>
- </itemgra>
- <itemgra item_types="poi_repair_service" order="0-">
- <icon src="repair_service.png"/>
- </itemgra>
- <itemgra item_types="poi_resort" order="0-">
- <icon src="resort.png"/>
- </itemgra>
- <itemgra item_types="poi_restaurant" order="12-">
- <icon src="restaurant.png"/>
- </itemgra>
- <itemgra item_types="poi_restricted_area" order="0-">
- <icon src="restricted_area.xpm"/>
- </itemgra>
- <itemgra item_types="poi_restroom" order="13-">
- <icon src="toilets.png"/>
- </itemgra>
- <itemgra item_types="poi_sailing" order="0-">
- <icon src="sailing.xpm"/>
- </itemgra>
- <itemgra item_types="poi_scenic_area" order="0-">
- <icon src="scenic_area.xpm"/>
- </itemgra>
- <itemgra item_types="poi_school" order="12-">
- <icon src="school.png"/>
- </itemgra>
- <itemgra item_types="poi_service" order="0-">
- <icon src="service.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_apparel" order="0-">
- <icon src="shop_apparel.png"/>
- </itemgra>
- <itemgra item_types="poi_shop_computer" order="0-">
- <icon src="shop_computer.png"/>
- </itemgra>
- <itemgra item_types="poi_shop_department" order="0-">
- <icon src="shop_department.png"/>
- </itemgra>
- <itemgra item_types="poi_shop_furniture" order="0-">
- <icon src="shop_furnish.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_grocery" order="0-">
- <icon src="shop_grocery.png"/>
- </itemgra>
- <itemgra item_types="poi_shop_handg" order="0-">
- <icon src="shop_handg.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_merchandise" order="0-">
- <icon src="shop_merchandise.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shop_retail" order="0-">
- <icon src="shop_retail.xpm"/>
- </itemgra>
- <itemgra item_types="poi_shower" order="0-">
- <icon src="shower.xpm"/>
- </itemgra>
- <itemgra item_types="poi_skiing" order="12-">
- <icon src="skiing.png"/>
- </itemgra>
- <itemgra item_types="poi_social_service" order="0-">
- <icon src="social_service.xpm"/>
- </itemgra>
- <itemgra item_types="poi_sounding" order="0-">
- <icon src="sounding.xpm"/>
- </itemgra>
- <itemgra item_types="poi_sport" order="12-">
- <icon src="sport.xpm"/>
- </itemgra>
- <itemgra item_types="poi_stadium" order="0-">
- <icon src="stadium.png"/>
- </itemgra>
- <itemgra item_types="poi_swimming" order="12-">
- <icon src="swimming.png"/>
- </itemgra>
- <itemgra item_types="poi_taxi" order="13-">
- <icon src="taxi.png"/>
- </itemgra>
- <itemgra item_types="poi_telephone" order="13-">
- <icon src="telephone.png"/>
- </itemgra>
- <itemgra item_types="poi_theater" order="12-">
- <icon src="theater.png"/>
- </itemgra>
- <itemgra item_types="poi_tide" order="0-">
- <icon src="tide.xpm"/>
- </itemgra>
- <itemgra item_types="poi_tower" order="13-">
- <icon src="tower.xpm"/>
- </itemgra>
- <itemgra item_types="poi_townhall" order="12-">
- <icon src="townhall.png"/>
- </itemgra>
- <itemgra item_types="poi_trail" order="0-">
- <icon src="trail.xpm"/>
- </itemgra>
- <itemgra item_types="poi_truck_stop" order="0-">
- <icon src="truck_stop.xpm"/>
- </itemgra>
- <itemgra item_types="poi_tunnel" order="0-">
- <icon src="tunnel.xpm"/>
- </itemgra>
- <itemgra item_types="poi_wifi" order="11-">
- <icon src="wifi.png"/>
- </itemgra>
- <itemgra item_types="poi_wine" order="0-">
- <icon src="wine.xpm"/>
- </itemgra>
- <itemgra item_types="poi_worship" order="0-">
- <icon src="worship.png"/>
- </itemgra>
- <itemgra item_types="poi_wrecker" order="0-">
- <icon src="wrecker.xpm"/>
- </itemgra>
- <itemgra item_types="poi_zoo" order="10-">
- <icon src="zoo.png"/>
- </itemgra>
- <itemgra item_types="poi_picnic" order="11-">
- <icon src="picnic.png"/>
- </itemgra>
- <itemgra item_types="poi_playground" order="12-">
- <icon src="playground.png"/>
- </itemgra>
- <itemgra item_types="poi_gc_multi" order="0-">
- <icon src="gc_multi.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_tradi" order="0-">
- <icon src="gc_tradi.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_event" order="0-">
- <icon src="gc_event.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_mystery" order="0-">
- <icon src="gc_mystery.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_question" order="0-">
- <icon src="gc_question.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_stages" order="0-">
- <icon src="gc_stages.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_reference" order="0-">
- <icon src="gc_reference.xpm"/>
- </itemgra>
- <itemgra item_types="poi_gc_webcam" order="0-">
- <icon src="gc_webcam.xpm"/>
- </itemgra>
- <itemgra item_types="traffic_signals" order="13-">
- <icon src="traffic_signals.png"/>
- </itemgra>
- <itemgra item_types="poi_image" order="0-">
- <image/>
- </itemgra>
- <!-- I'm not sure if the following stuff should appear in any layout. Maybe portions should only apply to the bike layout? -->
- <itemgra item_types="poi_bench" order="13-">
- <icon src="bench.png"/>
- </itemgra>
- <itemgra item_types="poi_biergarten" order="12-">
- <icon src="beer.png"/>
- </itemgra>
- <itemgra item_types="poi_boundary_stone" order="13-">
- <icon src="boundary_stone.png"/>
- </itemgra>
- <itemgra item_types="poi_castle" order="12-">
- <icon src="castle.png"/>
- </itemgra>
- <itemgra item_types="poi_hunting_stand" order="13-">
- <icon src="hunting_stand.png"/>
- </itemgra>
- <itemgra item_types="poi_memorial" order="12-">
- <icon src="memorial.png"/>
- </itemgra>
- <itemgra item_types="poi_monument" order="12-">
- <icon src="memorial.png"/>
- </itemgra>
- <itemgra item_types="poi_shelter" order="10-">
- <icon src="shelter.png"/>
- </itemgra>
- <itemgra item_types="poi_fountain" order="12-">
- <icon src="fountain.png"/>
- </itemgra>
- <itemgra item_types="poi_potable_water" order="12-">
- <icon src="drinking_water.png"/>
- </itemgra>
- <itemgra item_types="poi_toilets" order="12-">
- <icon src="toilets.png"/>
- </itemgra>
- <itemgra item_types="poi_viewpoint" order="12-">
- <icon src="viewpoint.png"/>
- </itemgra>
- <itemgra item_types="tec_common" order="11-">
- <icon src="tec_common.png"/>
- </itemgra>
- <itemgra item_types="vehicle" order="0-">
- <icon src="gui_vehicle_16_16.png" />
- </itemgra>
- <itemgra item_types="vehicle_pedestrian" order="0-">
- <icon src="gui_vehicle_pedestrian_16_16.png" />
- </itemgra>
- </layer>
- <layer name="POI Labels">
- <itemgra item_types="poi_airport,town_ghost,poi_hotel,poi_car_parking,poi_car_dealer_parts,poi_fuel,poi_shopping,poi_attraction,poi_cafe,poi_bar,poi_pub,highway_exit,poi_camp_rv,poi_museum_history,poi_hospital,poi_dining,poi_fastfood,poi_police,poi_autoservice,poi_bank,poi_atm,poi_bus_station,poi_bus_stop,poi_business_service,poi_car_rent,poi_car_sharing,poi_church,poi_bahai,poi_buddhist,poi_hindu,poi_islamic,poi_jain,poi_jewish,poi_pagan,poi_pastafarian,poi_shinto,poi_sikh,poi_taoist,poi_cinema,poi_concert,poi_drinking_water,poi_emergency,poi_fair,poi_fish,poi_government_building,poi_hotspring,poi_information,poi_justice,poi_landmark,poi_library,poi_mall,poi_manmade_feature,poi_marine,poi_marine_type,poi_mark,poi_oil_field,poi_peak,poi_personal_service,poi_pharmacy,poi_post_office,poi_public_office,poi_rail_halt,poi_rail_station,poi_rail_tram_stop,poi_repair_service,poi_resort,poi_restaurant,poi_restricted_area,poi_sailing,poi_scenic_area,poi_school,poi_service,poi_shop_retail,poi_skiing,poi_social_service,poi_sport,poi_stadium,poi_swimming,poi_theater,poi_townhall,poi_trail,poi_truck_stop,poi_tunnel,poi_worship,poi_wrecker,poi_zoo,poi_biergarten,poi_castle,poi_ruins,poi_memorial,poi_monument,poi_shelter,poi_fountain,poi_viewpoint,vehicle" order="14-">
- <circle color="#606060" background_color="#000000" radius="0" width="0" text_size="10"/>
- </itemgra>
- </layer>
- <layer name="Found items" ref="Found items"/>
- </layout>
-
- <layout name="Car-Android" color="#fef9ee" font="Liberation Sans">
- <cursor w="57" h="57">
- <itemgra speed_range="-2">
- <polyline color="#00BC00" radius="0" width="4">
- <coord x="0" y="0" />
- </polyline>
- <circle color="#008500" radius="9" width="3">
- <coord x="0" y="0" />
- </circle>
- <circle color="#00BC00" radius="13" width="3">
- <coord x="0" y="0" />
- </circle>
- <circle color="#008500" radius="18" width="3">
- <coord x="0" y="0" />
- </circle>
- </itemgra>
- <itemgra speed_range="3-">
- <polygon color="#00000066">
- <coord x="-21" y="-27" />
- <coord x="0" y="12" />
- <coord x="21" y="-27" />
- <coord x="0" y="-12" />
- <coord x="-21" y="-27" />
- </polygon>
- <polygon color="#008500">
- <coord x="-21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="-21" y="-18" />
- </polygon>
- <polygon color="#00BC00">
- <coord x="21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="21" y="-18" />
- </polygon>
- <polyline color="#008500" width="1">
- <coord x="-21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="-21" y="-18" />
- </polyline>
- <polyline color="#008500" width="1">
- <coord x="21" y="-18" />
- <coord x="0" y="21" />
- <coord x="0" y="-3" />
- <coord x="21" y="-18" />
- </polyline>
- </itemgra>
- </cursor>
- <layer name="polygons">
- <itemgra item_types="poly_wood" order="13-">
- <polygon color="#8ec78d" />
- <text text_size="5" />
- </itemgra>
- <itemgra item_types="poly_water_tiled">
- <polygon color="#82c8ea" />
- </itemgra>
- <itemgra item_types="poly_water" order="10-">
- <polygon color="#82c8ea" />
- <polyline color="#5096b8" />
- <text text_size="5" />
- </itemgra>
- <itemgra item_types="poly_flats,poly_scrub,poly_military_zone,poly_marine,plantation,tundra"
- order="14-">
- <polygon color="#a0a0a0" />
- <text text_size="5" />
- </itemgra>
- <itemgra item_types="poly_park" order="14-">
- <polygon color="#7cc334" />
- <text text_size="5" />
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="14">
- <polyline color="#d2d2d2" width="13" />
- <polyline color="#dddddd" width="9" />
- <polygon color="#dddddd" />
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="15">
- <polyline color="#d2d2d2" width="18" />
- <polyline color="#dddddd" width="14" />
- <polygon color="#dddddd" />
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="16">
- <polyline color="#d2d2d2" width="21" />
- <polyline color="#dddddd" width="17" />
- <polygon color="#dddddd" />
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="17">
- <polyline color="#d2d2d2" width="25" />
- <polyline color="#dddddd" width="21" />
- <polygon color="#dddddd" />
- </itemgra>
- <itemgra item_types="poly_pedestrian" order="18">
- <polyline color="#d2d2d2" width="40" />
- <polyline color="#dddddd" width="34" />
- <polygon color="#dddddd" />
- </itemgra>
- <itemgra item_types="poly_airport" order="5-">
- <polygon color="#a0a0a0" />
- </itemgra>
- <itemgra item_types="water_river" order="6-7">
- <polyline color="#82c8ea" width="3" />
- </itemgra>
- <itemgra item_types="water_river" order="8-9">
- <polyline color="#82c8ea" width="4" />
- </itemgra>
- <itemgra item_types="water_river" order="10-">
- <polyline color="#82c8ea" width="4" />
- <text text_size="10" />
- </itemgra>
- <itemgra item_types="water_canal" order="13-">
- <polyline color="#82c8ea" width="3" />
- <text text_size="10" />
- </itemgra>
- <itemgra item_types="water_stream" order="13-">
- <polyline color="#82c8ea" width="2" />
- <text text_size="7" />
- </itemgra>
- <itemgra item_types="water_drain" order="14-">
- <polyline color="#82c8ea" width="1" />
- <text text_size="5" />
- </itemgra>
- <itemgra item_types="poly_apron" order="13-">
- <polygon color="#d0d0d0" />
- </itemgra>
- <itemgra item_types="poly_terminal" order="14-">
- <polygon color="#e3c6a6" />
- </itemgra>
- <itemgra item_types="poly_car_parking" order="15-">
- <polygon color="#e7cf87" />
- </itemgra>
- <itemgra item_types="poly_building" order="14-">
- <polygon color="#b6a6a6" />
- </itemgra>
- <itemgra item_types="rail" order="13-">
- <polyline color="#696969" width="3" />
- <polyline color="#ffffff" width="1" dash="5,5" />
- </itemgra>
- <itemgra item_types="ferry" order="14-">
- <polyline color="#000000" width="1" dash="10" />
- </itemgra>
- <itemgra item_types="border_country" order="0-">
- <polyline color="#808080" width="1" dash="10,5,2,5"/>
- </itemgra>
- <itemgra item_types="border_state" order="0-">
- <polyline color="#808080" width="4"/>
- </itemgra>
- </layer>
- <layer name="streets">
- <itemgra item_types="street_route" order="2">
- <polyline color="#69e068" width="8" />
- </itemgra>
- <itemgra item_types="street_route" order="3-5">
- <polyline color="#69e068" width="10" />
- </itemgra>
- <itemgra item_types="street_route" order="6">
- <polyline color="#69e068" width="12" />
- </itemgra>
- <itemgra item_types="street_route" order="7-8">
- <polyline color="#69e068" width="16" />
- </itemgra>
- <itemgra item_types="street_route" order="9-10">
- <polyline color="#69e068" width="20" />
- </itemgra>
- <itemgra item_types="street_route" order="11">
- <polyline color="#69e068" width="28" />
- </itemgra>
- <itemgra item_types="street_route" order="12">
- <polyline color="#69e068" width="32" />
- </itemgra>
- <itemgra item_types="street_route" order="13">
- <polyline color="#69e068" width="52" />
- </itemgra>
- <itemgra item_types="street_route" order="14">
- <polyline color="#69e068" width="64" />
- </itemgra>
- <itemgra item_types="street_route" order="15">
- <polyline color="#69e068" width="68" />
- </itemgra>
- <itemgra item_types="street_route" order="16">
- <polyline color="#69e068" width="132" />
- </itemgra>
- <itemgra item_types="street_route" order="17">
- <polyline color="#69e068" width="268" />
- </itemgra>
- <itemgra item_types="street_route" order="18">
- <polyline color="#69e068" width="530" />
- </itemgra>
- <itemgra item_types="selected_line" order="2">
- <polyline color="#ba00b8" width="4" />
- </itemgra>
- <itemgra item_types="selected_line" order="3-5">
- <polyline color="#ba00b8" width="8" />
- </itemgra>
- <itemgra item_types="selected_line" order="6">
- <polyline color="#ba00b8" width="10" />
- </itemgra>
- <itemgra item_types="selected_line" order="7-8">
- <polyline color="#ba00b8" width="16" />
- </itemgra>
- <itemgra item_types="selected_line" order="9-10">
- <polyline color="#ba00b8" width="20" />
- </itemgra>
- <itemgra item_types="selected_line" order="11">
- <polyline color="#ba00b8" width="28" />
- </itemgra>
- <itemgra item_types="selected_line" order="12">
- <polyline color="#ba00b8" width="32" />
- </itemgra>
- <itemgra item_types="selected_line" order="13">
- <polyline color="#ba00b8" width="52" />
- </itemgra>
- <itemgra item_types="selected_line" order="14">
- <polyline color="#ba00b8" width="64" />
- </itemgra>
- <itemgra item_types="selected_line" order="15">
- <polyline color="#ba00b8" width="68" />
- </itemgra>
- <itemgra item_types="selected_line" order="16">
- <polyline color="#ba00b8" width="132" />
- </itemgra>
- <itemgra item_types="selected_line" order="17">
- <polyline color="#ba00b8" width="268" />
- </itemgra>
- <itemgra item_types="selected_line" order="18">
- <polyline color="#ba00b8" width="530" />
- </itemgra>
- <itemgra item_types="forest_way_1" order="14-">
- <polyline color="#0070c0" width="6" />
- </itemgra>
- <itemgra item_types="forest_way_2" order="14-">
- <polyline color="#ff0000" width="3" />
- </itemgra>
- <itemgra item_types="forest_way_3" order="14-">
- <polyline color="#ff0000" width="1" dash="2,4" />
- </itemgra>
- <itemgra item_types="forest_way_4" order="14-">
- <polyline color="#119a2e" width="1" dash="4,10" />
- </itemgra>
- <itemgra item_types="street_nopass" order="14-">
- <polyline color="#000000" width="1" />
- </itemgra>
- <itemgra item_types="track_paved" order="14-">
- <polyline color="#000000" width="1" />
- </itemgra>
- <itemgra item_types="track_gravelled" order="14">
- <polyline color="#ffffff" width="4"/>
- <polyline color="#800000" width="1" dash="4,8" />
- </itemgra>
- <itemgra item_types="track_gravelled" order="15-16">
- <polyline color="#ffffff" width="5"/>
- <polyline color="#800000" width="1" dash="5,10" />
- </itemgra>
- <itemgra item_types="track_gravelled" order="17-">
- <polyline color="#ffffff" width="7"/>
- <polyline color="#800000" width="1" dash="7,15" />
- </itemgra>
- <itemgra item_types="track_unpaved" order="14-">
- <polyline color="#000000" width="1" />
- </itemgra>
- <itemgra item_types="bridleway" order="14-">
- <polyline color="#000000" width="1" />
- </itemgra>
- <itemgra item_types="cycleway" order="14-">
- <polyline color="#000000" width="1" />
- </itemgra>
- <itemgra item_types="lift_cable_car" order="15-">
- <polyline color="#696969" width="1" dash="5" />
- </itemgra>
- <itemgra item_types="lift_chair" order="15-">
- <polyline color="#696969" width="1" dash="5" />
- </itemgra>
- <itemgra item_types="lift_drag" order="15-">
- <polyline color="#696969" width="1" dash="5" />
- </itemgra>
- <itemgra item_types="footway" order="15-16">
- <polyline color="#ffffff" width="5"/>
- <polyline color="#ff0000" width="1" dash="5,10" />
- </itemgra>
- <itemgra item_types="footway" order="17-">
- <polyline color="#ffffff" width="7"/>
- <polyline color="#ff0000" width="1" dash="7,15" />
- </itemgra>
- <itemgra item_types="steps" order="15-">
- <polyline color="#000000" width="1" />
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street"
- order="14">
- <polyline color="#d2d2d2" width="13" />
- <polyline color="#dddddd" width="9" />
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street"
- order="15">
- <polyline color="#d2d2d2" width="18" />
- <polyline color="#dddddd" width="14" />
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street"
- order="16">
- <polyline color="#d2d2d2" width="21" />
- <polyline color="#dddddd" width="17" />
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street"
- order="17">
- <polyline color="#d2d2d2" width="25" />
- <polyline color="#dddddd" width="21" />
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street"
- order="18">
- <polyline color="#d2d2d2" width="40" />
- <polyline color="#dddddd" width="34" />
- </itemgra>
- <itemgra item_types="street_service" order="14">
- <polyline color="#d2d2d2" width="7" />
- <polyline color="#fefefe" width="5" />
- </itemgra>
- <itemgra item_types="street_service" order="15">
- <polyline color="#d2d2d2" width="8" />
- <polyline color="#fefefe" width="6" />
- </itemgra>
- <itemgra item_types="street_service" order="16">
- <polyline color="#d2d2d2" width="9" />
- <polyline color="#fefefe" width="7" />
- </itemgra>
- <itemgra item_types="street_service" order="17">
- <polyline color="#d2d2d2" width="10" />
- <polyline color="#fefefe" width="8" />
- </itemgra>
- <itemgra item_types="street_service" order="18">
- <polyline color="#d2d2d2" width="11" />
- <polyline color="#fefefe" width="9" />
- </itemgra>
- <itemgra item_types="street_parking_lane" order="15">
- <polyline color="#d2d2d2" width="6" />
- <polyline color="#fefefe" width="4" />
- </itemgra>
- <itemgra item_types="street_parking_lane" order="16">
- <polyline color="#d2d2d2" width="7" />
- <polyline color="#fefefe" width="5" />
- </itemgra>
- <itemgra item_types="street_parking_lane" order="17">
- <polyline color="#d2d2d2" width="8" />
- <polyline color="#fefefe" width="6" />
- </itemgra>
- <itemgra item_types="street_parking_lane" order="18">
- <polyline color="#d2d2d2" width="9" />
- <polyline color="#fefefe" width="7" />
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land"
- order="12">
- <polyline color="#d2d2d2" width="1" />
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land"
- order="13-14">
- <polyline color="#d2d2d2" width="17" />
- <polyline color="#ffffff" width="13" />
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land"
- order="15">
- <polyline color="#d2d2d2" width="18" />
- <polyline color="#ffffff" width="14" />
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land"
- order="16">
- <polyline color="#d2d2d2" width="30" />
- <polyline color="#ffffff" width="26" />
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land"
- order="17">
- <polyline color="#d2d2d2" width="67" />
- <polyline color="#ffffff" width="61" />
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land"
- order="18">
- <polyline color="#d2d2d2" width="132" />
- <polyline color="#ffffff" width="126" />
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp"
- order="11-12">
- <polyline color="#c0c0c0" width="9" />
- <polyline color="#fefc8c" width="7" />
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp"
- order="13-14">
- <polyline color="#c0c0c0" width="13" />
- <polyline color="#fefc8c" width="11" />
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp"
- order="15">
- <polyline color="#c0c0c0" width="19" />
- <polyline color="#fefc8c" width="15" />
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp"
- order="16">
- <polyline color="#c0c0c0" width="30" />
- <polyline color="#fefc8c" width="26" />
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp"
- order="17">
- <polyline color="#c0c0c0" width="63" />
- <polyline color="#fefc8c" width="57" />
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp"
- order="18">
- <polyline color="#c0c0c0" width="100" />
- <polyline color="#fefc8c" width="90" />
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout"
- order="11-12">
- <polyline color="#a0a0a0" width="9" />
- <polyline color="#fefc8c" width="7" />
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout"
- order="13-14">
- <polyline color="#a0a0a0" width="21" />
- <polyline color="#fefc8c" width="17" />
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout"
- order="15">
- <polyline color="#a0a0a0" width="25" />
- <polyline color="#fefc8c" width="21" />
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout"
- order="16">
- <polyline color="#a0a0a0" width="40" />
- <polyline color="#fefc8c" width="34" />
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout"
- order="17">
- <polyline color="#a0a0a0" width="79" />
- <polyline color="#fefc8c" width="73" />
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout"
- order="18">
- <polyline color="#a0a0a0" width="156" />
- <polyline color="#fefc8c" width="150" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="2-6">
- <polyline color="#f8dc79" width="4" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="7-8">
- <polyline color="#f8dc79" width="4" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="9">
- <polyline color="#f8dc79" width="5" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="10">
- <polyline color="#f8dc79" width="6" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="11">
- <polyline color="#000000" width="9" />
- <polyline color="#f8dc79" width="7" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="12">
- <polyline color="#000000" width="13" />
- <polyline color="#f8dc79" width="9" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="13">
- <polyline color="#000000" width="18" />
- <polyline color="#f8dc79" width="14" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="14">
- <polyline color="#000000" width="21" />
- <polyline color="#f8dc79" width="17" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="15">
- <polyline color="#000000" width="24" />
- <polyline color="#f8dc79" width="20" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="16">
- <polyline color="#000000" width="39" />
- <polyline color="#f8dc79" width="33" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="17">
- <polyline color="#000000" width="78" />
- <polyline color="#f8dc79" width="72" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes"
- order="18">
- <polyline color="#000000" width="156" />
- <polyline color="#f8dc79" width="150" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land"
- order="0-1">
- <polyline color="#fc843b" width="1" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="2">
- <polyline color="#fc843b" width="3" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land"
- order="3-5">
- <polyline color="#fc843b" width="6" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="6">
- <polyline color="#fc843b" width="6" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land"
- order="7-8">
- <polyline color="#fc843b" width="6" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="9">
- <polyline color="#fc843b" width="7" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="10">
- <polyline color="#fc843b" width="9" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="11">
- <polyline color="#a8aab3" width="13" />
- <polyline color="#fc843b" width="9" />
- <polyline color="#a8aab3" width="1" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="12">
- <polyline color="#a8aab3" width="15" />
- <polyline color="#fc843b" width="10" />
- <polyline color="#a8aab3" width="1" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="13">
- <polyline color="#a8aab3" width="25" />
- <polyline color="#fc843b" width="17" />
- <polyline color="#a8aab3" width="1" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="14">
- <polyline color="#a8aab3" width="31" />
- <polyline color="#fc843b" width="24" />
- <polyline color="#a8aab3" width="1" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="15">
- <polyline color="#a8aab3" width="33" />
- <polyline color="#fc843b" width="27" />
- <polyline color="#a8aab3" width="1" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="16">
- <polyline color="#a8aab3" width="65" />
- <polyline color="#fc843b" width="59" />
- <polyline color="#a8aab3" width="1" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="17">
- <polyline color="#a8aab3" width="133" />
- <polyline color="#fc843b" width="127" />
- <polyline color="#a8aab3" width="1" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="18">
- <polyline color="#a8aab3" width="264" />
- <polyline color="#fc843b" width="258" />
- <polyline color="#a8aab3" width="1" />
- </itemgra>
- <itemgra item_types="highway_exit_label" order="13-">
- <circle color="#000000" radius="3" text_size="7" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street"
- order="13-18">
- <text text_size="8" />
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp"
- order="13-18">
- <text text_size="9" />
- </itemgra>
- <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land,footway"
- order="13-18">
- <text text_size="9" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="7-8">
- <polyline color="#ff9000" width="8" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="9-10">
- <polyline color="#ff9000" width="10" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="11">
- <polyline color="#ff9000" width="14" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="12">
- <polyline color="#ff9000" width="16" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="13">
- <polyline color="#ff9000" width="26" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="14">
- <polyline color="#ff9000" width="32" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="15">
- <polyline color="#ff9000" width="34" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="16">
- <polyline color="#ff9000" width="66" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="17">
- <polyline color="#ff9000" width="134" />
- </itemgra>
- <itemgra item_types="traffic_distortion" order="18">
- <polyline color="#ff9000" width="265" />
- </itemgra>
- </layer>
- <layer name="polylines">
- <itemgra item_types="rail_tram" order="13-">
- <polyline color="#606060" width="2" />
- </itemgra>
- </layer>
- <layer name="labels">
- <itemgra item_types="house_number" order="15-">
- <circle color="#000000" radius="3" text_size="7" />
- </itemgra>
- <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2"
- order="13-">
- <circle color="#000000" radius="3" text_size="7" />
- </itemgra>
- <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3"
- order="12-">
- <circle color="#000000" radius="3" text_size="7" />
- </itemgra>
- <itemgra item_types="town_label_1e3,place_label"
- order="10-">
- <circle color="#000000" radius="3" text_size="10" />
- </itemgra>
- <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4"
- order="11-">
- <circle color="#000000" radius="3" text_size="7" />
- </itemgra>
- <itemgra item_types="town_label_2e3" order="11-">
- <circle color="#000000" radius="3" text_size="10" />
- </itemgra>
- <itemgra item_types="town_label_5e3,town_label_1e4,town_label_2e4,town_label_5e4"
- order="11-">
- <circle color="#000000" radius="3" text_size="15" />
- </itemgra>
- <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5"
- order="10-">
- <circle color="#000000" radius="3" text_size="7" />
- </itemgra>
- <itemgra item_types="town_label_2e3" order="10">
- <circle color="#000000" radius="3" text_size="7" />
- </itemgra>
- <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6,district_label_1e7"
- order="9-">
- <circle color="#000000" radius="3" text_size="7" />
- </itemgra>
- <itemgra item_types="town_label_5e3" order="9-10">
- <circle color="#000000" radius="3" text_size="10" />
- </itemgra>
- <itemgra item_types="town_label_1e4" order="8-9">
- <circle color="#000000" radius="3" text_size="10" />
- </itemgra>
- <itemgra item_types="town_label_2e4,town_label_5e4"
- order="7-8">
- <circle color="#000000" radius="3" text_size="10" />
- </itemgra>
- <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5"
- order="5-">
- <circle color="#000000" radius="3" text_size="15" />
- </itemgra>
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7"
- order="5-">
- <circle color="#000000" radius="3" text_size="20" />
- </itemgra>
- <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5"
- order="4">
- <circle color="#000000" radius="3" text_size="10" />
- </itemgra>
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7"
- order="4">
- <circle color="#000000" radius="3" text_size="15" />
- </itemgra>
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7"
- order="0-3">
- <circle color="#000000" radius="3" text_size="10" />
- </itemgra>
- </layer>
- <layer name="Internal">
- <itemgra item_types="track" order="7-">
- <polyline color="#3f3f3f" width="1" />
- </itemgra>
- <itemgra item_types="track_tracked" order="7-">
- <polyline color="#3f3fff" width="3" />
- </itemgra>
- <itemgra item_types="rg_segment" order="12-">
- <polyline color="#FF089C" width="1" />
- <arrows color="#FF089C" width="1" />
- </itemgra>
- <itemgra item_types="rg_point" order="12-">
- <circle color="#FF089C" radius="10" text_size="7" />
- </itemgra>
- <itemgra item_types="nav_left_1" order="0-">
- <icon src="nav_left_1_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_left_2" order="0-">
- <icon src="nav_left_2_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_left_3" order="0-">
- <icon src="nav_left_3_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_right_1" order="0-">
- <icon src="nav_right_1_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_right_2" order="0-">
- <icon src="nav_right_2_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_right_3" order="0-">
- <icon src="nav_right_3_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_straight" order="0-">
- <icon src="nav_straight_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_turnaround_left" order="0-">
- <icon src="nav_turnaround_left_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_turnaround_right" order="0-">
- <icon src="nav_turnaround_right_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_l1" order="0-">
- <icon src="nav_roundabout_l1_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_r1" order="0-">
- <icon src="nav_roundabout_r1_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_l2" order="0-">
- <icon src="nav_roundabout_l2_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_r2" order="0-">
- <icon src="nav_roundabout_r2_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_l3" order="0-">
- <icon src="nav_roundabout_l3_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_r3" order="0-">
- <icon src="nav_roundabout_r3_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_l4" order="0-">
- <icon src="nav_roundabout_l4_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_r4" order="0-">
- <icon src="nav_roundabout_r4_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_l5" order="0-">
- <icon src="nav_roundabout_l5_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_r5" order="0-">
- <icon src="nav_roundabout_r5_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_l6" order="0-">
- <icon src="nav_roundabout_l6_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_r6" order="0-">
- <icon src="nav_roundabout_r6_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_l7" order="0-">
- <icon src="nav_roundabout_l7_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_r7" order="0-">
- <icon src="nav_roundabout_r7_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_l8" order="0-">
- <icon src="nav_roundabout_l8_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_roundabout_r8" order="0-">
- <icon src="nav_roundabout_r8_bk.png" w="32" h="32" />
- </itemgra>
- <itemgra item_types="nav_keep_left" order="0-">
- <icon src="nav_keep_left_bk.png" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_merge_left" order="0-">
- <icon src="nav_merge_left_bk.png" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_keep_right" order="0-">
- <icon src="nav_keep_right_bk.png" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_merge_right" order="0-">
- <icon src="nav_merge_right_bk.png" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_exit_left" order="0-">
- <icon src="nav_exit_left_bk.png" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_exit_right" order="0-">
- <icon src="nav_exit_right_bk.png" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="route_end" order="0-">
- <icon src="nav_destination_bk.png" w="32" h="32" x="4" y="30"/>
- </itemgra>
-
- <itemgra item_types="waypoint,route_end" order="2">
- <circle color="#000000" radius="4" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="3-5">
- <circle color="#000000" radius="8" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="6">
- <circle color="#000000" radius="10" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="7-8">
- <circle color="#000000" radius="16" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="9-10">
- <circle color="#000000" radius="20" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="11">
- <circle color="#000000" radius="28" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="12">
- <circle color="#000000" radius="32" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="13">
- <circle color="#000000" radius="52" width="4" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="14">
- <circle color="#000000" radius="64" width="4" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="15">
- <circle color="#000000" radius="68" width="6" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="16">
- <circle color="#000000" radius="132" width="8" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="17">
- <circle color="#000000" radius="268" width="8" text_size="48"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="18">
- <circle color="#000000" radius="530" width="8" text_size="48"/>
- </itemgra>
-
- <itemgra item_types="nav_none" order="0-">
- <icon src="unknown.png" />
- </itemgra>
- <itemgra item_types="announcement" order="7-">
- <icon src="gui_sound_32_32.png" />
- <circle color="#FF089C" radius="10" text_size="7" />
- </itemgra>
- </layer>
- <layer name="POI Symbols" active="1">
- <itemgra item_types="mini_roundabout" order="12-">
- <icon src="mini_roundabout.png" />
- </itemgra>
- <itemgra item_types="turning_circle" order="12-">
- <icon src="mini_roundabout.png" />
- </itemgra>
- <itemgra item_types="poi_airport" order="6-">
- <icon src="airport.png" />
- </itemgra>
- <itemgra item_types="poi_fuel" order="12-">
- <icon src="fuel.png" />
- </itemgra>
- <itemgra item_types="poi_bridge" order="12-">
- <icon src="bridge.png" />
- </itemgra>
- <itemgra item_types="highway_exit" order="12-">
- <icon src="exit.png" />
- </itemgra>
- <itemgra item_types="poi_auto_club" order="13-">
- <icon src="auto_club.png" />
- </itemgra>
- <itemgra item_types="poi_bank" order="13-">
- <icon src="bank.png" />
- </itemgra>
- <itemgra item_types="poi_atm" order="13-">
- <icon src="atm.png"/>
- </itemgra>
- <itemgra item_types="poi_danger_area" order="13-">
- <icon src="danger_16_16.png" />
- </itemgra>
- <itemgra item_types="poi_forbidden_area" order="13-">
- <icon src="forbiden_area.png" />
- </itemgra>
- <itemgra item_types="poi_tunnel" order="12-">
- <icon src="tunnel.png" />
- </itemgra>
- <itemgra item_types="traffic_signals" order="14-">
- <icon src="traffic_signals.png" />
- </itemgra>
- </layer>
- <layer name="POI Labels" active="1">
- <itemgra item_types="poi_airport,town_ghost,poi_hotel,poi_car_parking,poi_car_dealer_parts,poi_fuel,poi_shopping,poi_attraction,poi_cafe,poi_bar,poi_pub,highway_exit,poi_camp_rv,poi_museum_history,poi_hospital,poi_dining,poi_fastfood,poi_police,poi_autoservice,poi_bank,poi_atm,poi_bus_station,poi_bus_stop,poi_business_service,poi_car_rent,poi_church,poi_bahai,poi_buddhist,poi_hindu,poi_islamic,poi_jain,poi_jewish,poi_pagan,poi_pastafarian,poi_shinto,poi_sikh,poi_taoist,poi_cinema,poi_concert,poi_drinking_water,poi_emergency,poi_fair,poi_fish,poi_government_building,poi_hotspring,poi_information,poi_justice,poi_landmark,poi_library,poi_mall,poi_manmade_feature,poi_marine,poi_marine_type,poi_mark,poi_oil_field,poi_peak,poi_personal_service,poi_pharmacy,poi_post_office,poi_public_office,poi_rail_halt,poi_rail_station,poi_rail_tram_stop,poi_repair_service,poi_resort,poi_restaurant,poi_restricted_area,poi_sailing,poi_scenic_area,poi_school,poi_service,poi_shop_retail,poi_skiing,poi_social_service,poi_sport,poi_stadium,poi_swimming,poi_theater,poi_townhall,poi_trail,poi_truck_stop,poi_tunnel,poi_worship,poi_wrecker,poi_zoo,poi_biergarten,poi_castle,poi_ruins,poi_memorial,poi_monument,poi_shelter,poi_fountain,poi_viewpoint,vehicle"
- order="15-">
- <circle color="#606060" radius="0" width="0"
- text_size="10" />
- </itemgra>
- </layer>
- <layer name="Android-POI-Icons-full" active="0">
- <itemgra item_types="mini_roundabout" order="12-">
- <icon src="mini_roundabout.png" />
- </itemgra>
- <itemgra item_types="turning_circle" order="12-">
- <icon src="mini_roundabout.png" />
- </itemgra>
- <itemgra item_types="poi_airport" order="5-">
- <icon src="airport.png" />
- </itemgra>
- <itemgra item_types="town_ghost" order="10-">
- <icon src="ghost_town.png" />
- </itemgra>
- <itemgra item_types="poi_hotel" order="12-">
- <icon src="hotel.png" />
- </itemgra>
- <itemgra item_types="poi_car_parking" order="11-">
- <icon src="parking.png" />
- </itemgra>
- <itemgra item_types="poi_car_dealer_parts" order="12-">
- <icon src="car_dealer.png" />
- </itemgra>
- <itemgra item_types="poi_fuel" order="12-">
- <icon src="fuel.png" />
- </itemgra>
- <itemgra item_types="poi_shopping" order="12-">
- <icon src="shopping.png" />
- </itemgra>
- <itemgra item_types="poi_attraction" order="11-">
- <icon src="attraction.png" />
- </itemgra>
- <itemgra item_types="poi_cafe" order="12-">
- <icon src="cafe.png" />
- </itemgra>
- <itemgra item_types="poi_bar" order="12-">
- <icon src="bar.png" />
- </itemgra>
- <itemgra item_types="poi_pub" order="12-">
- <icon src="beer.png" />
- </itemgra>
- <itemgra item_types="poi_bridge" order="12-">
- <icon src="bridge.png" />
- </itemgra>
- <itemgra item_types="highway_exit" order="11-">
- <icon src="exit.png" />
- </itemgra>
- <itemgra item_types="poi_camp_rv" order="12-">
- <icon src="camping.png" />
- </itemgra>
- <itemgra item_types="poi_museum_history" order="12-">
- <icon src="museum.png" />
- </itemgra>
- <itemgra item_types="poi_hospital" order="12-">
- <icon src="hospital.png" />
- </itemgra>
- <itemgra item_types="poi_dining" order="12-">
- <icon src="restaurant.png"/>
- </itemgra>
- <itemgra item_types="poi_fastfood" order="12-">
- <icon src="fastfood.png" />
- </itemgra>
- <itemgra item_types="poi_police" order="12-">
- <icon src="police.png" />
- </itemgra>
- <itemgra item_types="poi_auto_club" order="12-">
- <icon src="auto_club.png" />
- </itemgra>
- <itemgra item_types="poi_autoservice" order="12-">
- <icon src="car_dealer.png" />
- </itemgra>
- <itemgra item_types="poi_bank" order="12-">
- <icon src="bank.png" />
- </itemgra>
- <itemgra item_types="poi_atm" order="12-">
- <icon src="atm.png"/>
- </itemgra>
- <itemgra item_types="poi_bay" order="12-">
- <icon src="bay.png" />
- </itemgra>
- <itemgra item_types="poi_bend" order="12-">
- <icon src="bend.png" />
- </itemgra>
- <itemgra item_types="poi_boat_ramp" order="12-">
- <icon src="boat_ramp.png" />
- </itemgra>
- <itemgra item_types="poi_border_station" order="12-">
- <icon src="border_station.png" />
- </itemgra>
- <itemgra item_types="poi_bowling" order="12-">
- <icon src="bowling.png" />
- </itemgra>
- <itemgra item_types="poi_bus_station" order="11-">
- <icon src="bus.png" />
- </itemgra>
- <itemgra item_types="poi_bus_stop" order="12-">
- <icon src="bus_stop.png" />
- </itemgra>
- <itemgra item_types="poi_business_service" order="12-">
- <icon src="bussines_service.png" />
- </itemgra>
- <itemgra item_types="poi_car_rent" order="12-">
- <icon src="car_rent.png" />
- </itemgra>
- <itemgra item_types="poi_car_sharing" order="11-">
- <icon src="car_sharing.png"/>
- </itemgra>
- <itemgra item_types="poi_car_wash" order="12-">
- <icon src="car_wash.png" />
- </itemgra>
- <itemgra item_types="poi_casino" order="12-">
- <icon src="casino.png" />
- </itemgra>
- <itemgra item_types="poi_cemetery" order="12-">
- <icon src="cemetery.xpm" />
- </itemgra>
- <itemgra item_types="poi_church" order="11-">
- <icon src="church.png" />
- </itemgra>
- <itemgra item_types="poi_bahai" order="11-">
- <icon src="bahai.png"/>
- </itemgra>
- <itemgra item_types="poi_buddhist" order="11-">
- <icon src="buddhist.png"/>
- </itemgra>
- <itemgra item_types="poi_hindu" order="11-">
- <icon src="hindu.png"/>
- </itemgra>
- <itemgra item_types="poi_islamic" order="11-">
- <icon src="islamic.png"/>
- </itemgra>
- <itemgra item_types="poi_jain" order="11-">
- <icon src="jain.png"/>
- </itemgra>
- <itemgra item_types="poi_jewish" order="11-">
- <icon src="jewish.png"/>
- </itemgra>
- <itemgra item_types="poi_pagan" order="11-">
- <icon src="pagan.png"/>
- </itemgra>
- <itemgra item_types="poi_pastafarian" order="11-">
- <icon src="pastafarian.png"/>
- </itemgra>
- <itemgra item_types="poi_shinto" order="11-">
- <icon src="shinto.png"/>
- </itemgra>
- <itemgra item_types="poi_sikh" order="11-">
- <icon src="sikh.png"/>
- </itemgra>
- <itemgra item_types="poi_taoist" order="11-">
- <icon src="taoist.png"/>
- </itemgra>
- <itemgra item_types="poi_cinema" order="12-">
- <icon src="cinema.png" />
- </itemgra>
- <itemgra item_types="poi_communication" order="12-">
- <icon src="communication.png" />
- </itemgra>
- <itemgra item_types="poi_concert" order="12-">
- <icon src="concert.png" />
- </itemgra>
- <itemgra item_types="poi_cove" order="12-">
- <icon src="cove.png" />
- </itemgra>
- <itemgra item_types="poi_crossing" order="12-">
- <icon src="crossing.png" />
- </itemgra>
- <itemgra item_types="poi_dam" order="12-">
- <icon src="dam.png" />
- </itemgra>
- <itemgra item_types="poi_danger_area" order="12-">
- <icon src="danger_16_16.png" />
- </itemgra>
- <itemgra item_types="poi_danger_sea_wreck" order="12-">
- <icon src="dangerous.png" />
- </itemgra>
- <itemgra item_types="poi_daymark" order="12-">
- <icon src="daymark.png" />
- </itemgra>
- <itemgra item_types="poi_diving" order="12-">
- <icon src="diving.png" />
- </itemgra>
- <itemgra item_types="poi_drinking_water" order="13-">
- <icon src="drinking_water.png" />
- </itemgra>
- <itemgra item_types="poi_emergency" order="12-">
- <icon src="emergency.png" />
- </itemgra>
- <itemgra item_types="poi_fair" order="12-">
- <icon src="fair.png" />
- </itemgra>
- <itemgra item_types="poi_firebrigade" order="12-">
- <icon src="firebrigade.png" />
- </itemgra>
- <itemgra item_types="poi_fish" order="9-">
- <icon src="fish.png" />
- </itemgra>
- <itemgra item_types="poi_forbidden_area" order="12-">
- <icon src="forbiden_area.png" />
- </itemgra>
- <itemgra item_types="poi_shop_gps" order="15-">
- <icon src="garmin.png" />
- </itemgra>
- <itemgra item_types="poi_golf" order="12-">
- <icon src="golf.png" />
- </itemgra>
- <itemgra item_types="poi_government_building" order="12-">
- <icon src="goverment_building.png" />
- </itemgra>
- <itemgra item_types="poi_height" order="12-">
- <icon src="height.png" />
- </itemgra>
- <itemgra item_types="poi_heliport" order="8-">
- <icon src="heliport.png" />
- </itemgra>
- <itemgra item_types="poi_hotspring" order="12-">
- <icon src="hotspring.png" />
- </itemgra>
- <itemgra item_types="poi_icesport" order="12-">
- <icon src="icesport.png" />
- </itemgra>
- <itemgra item_types="poi_information" order="12-">
- <icon src="information.png" />
- </itemgra>
- <itemgra item_types="poi_justice" order="12-">
- <icon src="justice.png" />
- </itemgra>
- <itemgra item_types="poi_landmark" order="11-">
- <icon src="landmark.png" />
- </itemgra>
- <itemgra item_types="poi_levee" order="12-">
- <icon src="levee.png" />
- </itemgra>
- <itemgra item_types="poi_level_crossing" order="11-">
- <icon src="level_crossing.xpm" />
- </itemgra>
- <itemgra item_types="poi_library" order="12-">
- <icon src="library.png" />
- </itemgra>
- <itemgra item_types="poi_locale" order="12-">
- <icon src="locale.png" />
- </itemgra>
- <itemgra item_types="poi_loudspeaker" order="12-">
- <icon src="loudspeaker.png" />
- </itemgra>
- <itemgra item_types="poi_mall" order="12-">
- <icon src="mall.png" />
- </itemgra>
- <itemgra item_types="poi_manmade_feature" order="12-">
- <icon src="manmade_feature.png" />
- </itemgra>
- <itemgra item_types="poi_marine" order="12-">
- <icon src="marine.png" />
- </itemgra>
- <itemgra item_types="poi_marine_type" order="12-">
- <icon src="marine_type.png" />
- </itemgra>
- <itemgra item_types="poi_mark" order="12-">
- <icon src="mark.png" />
- </itemgra>
- <itemgra item_types="poi_military" order="11-">
- <icon src="military.png" />
- </itemgra>
- <itemgra item_types="poi_mine" order="12-">
- <icon src="mine.png" />
- </itemgra>
- <itemgra item_types="poi_nondangerous" order="12-">
- <icon src="nondangerous.png" />
- </itemgra>
- <itemgra item_types="poi_oil_field" order="12-">
- <icon src="oil_field.png" />
- </itemgra>
- <itemgra item_types="poi_peak" order="7-">
- <icon src="peak.png" />
- </itemgra>
- <itemgra item_types="poi_personal_service" order="12-">
- <icon src="personal_service.png" />
- </itemgra>
- <itemgra item_types="poi_pharmacy" order="12-">
- <icon src="pharmacy.png" />
- </itemgra>
- <itemgra item_types="poi_post_office,poi_post_box"
- order="13-">
- <icon src="post.png" />
- </itemgra>
- <itemgra item_types="poi_public_office" order="12-">
- <icon src="public_office.png" />
- </itemgra>
- <itemgra item_types="poi_rail_halt" order="11-">
- <circle color="#ff0000" radius="3" width="3" />
- <circle color="#000000" radius="5" width="2"
- text_size="8" />
- </itemgra>
- <itemgra item_types="poi_rail_station" order="9-">
- <circle color="#ff0000" radius="3" width="3" />
- <circle color="#000000" radius="6" width="2"
- text_size="8" />
- </itemgra>
- <itemgra item_types="poi_rail_tram_stop" order="10-11">
- <circle color="#ff0000" radius="2" width="2" />
- </itemgra>
- <itemgra item_types="poi_rail_tram_stop" order="12-">
- <circle color="#ff0000" radius="3" width="3" />
- <circle color="#606060" radius="5" width="2"
- text_size="8" />
- </itemgra>
- <itemgra item_types="poi_repair_service" order="12-">
- <icon src="repair_service.png" />
- </itemgra>
- <itemgra item_types="poi_resort" order="12-">
- <icon src="resort.png" />
- </itemgra>
- <itemgra item_types="poi_restaurant" order="12-">
- <icon src="restaurant.png" />
- </itemgra>
- <itemgra item_types="poi_restricted_area" order="12-">
- <icon src="restricted_area.png" />
- </itemgra>
- <itemgra item_types="poi_restroom" order="13-">
- <icon src="toilets.png"/>
- </itemgra>
- <itemgra item_types="poi_sailing" order="12-">
- <icon src="sailing.png" />
- </itemgra>
- <itemgra item_types="poi_scenic_area" order="12-">
- <icon src="scenic_area.png" />
- </itemgra>
- <itemgra item_types="poi_school" order="12-">
- <icon src="school.png" />
- </itemgra>
- <itemgra item_types="poi_service" order="12-">
- <icon src="service.png" />
- </itemgra>
- <itemgra item_types="poi_shop_apparel" order="12-">
- <icon src="shop_apparel.png" />
- </itemgra>
- <itemgra item_types="poi_shop_bicycle" order="12-">
- <icon src="bicycle_shop.png" />
- </itemgra>
- <itemgra item_types="poi_shop_computer" order="12-">
- <icon src="shop_computer.png" />
- </itemgra>
- <itemgra item_types="poi_shop_department" order="12-">
- <icon src="shop_department.png" />
- </itemgra>
- <itemgra item_types="poi_shop_furniture" order="12-">
- <icon src="shop_furnish.png" />
- </itemgra>
- <itemgra item_types="poi_shop_grocery" order="12-">
- <icon src="shop_grocery.png" />
- </itemgra>
- <itemgra item_types="poi_shop_handg" order="12-">
- <icon src="shop_handg.png" />
- </itemgra>
- <itemgra item_types="poi_shop_merchandise" order="12-">
- <icon src="shop_merchandise.png" />
- </itemgra>
- <itemgra item_types="poi_shop_retail" order="12-">
- <icon src="shop_retail.png" />
- </itemgra>
- <itemgra item_types="poi_shower" order="13-">
- <icon src="shower.png" />
- </itemgra>
- <itemgra item_types="poi_skiing" order="11-">
- <icon src="skiing.png" />
- </itemgra>
- <itemgra item_types="poi_social_service" order="12-">
- <icon src="social_service.png" />
- </itemgra>
- <itemgra item_types="poi_sounding" order="12-">
- <icon src="sounding.png" />
- </itemgra>
- <itemgra item_types="poi_sport" order="12-">
- <icon src="sport.png" />
- </itemgra>
- <itemgra item_types="poi_stadium" order="11-">
- <icon src="stadium.png" />
- </itemgra>
- <itemgra item_types="poi_swimming" order="12-">
- <icon src="swimming.png" />
- </itemgra>
- <itemgra item_types="poi_telephone" order="13-">
- <icon src="telephone.png" />
- </itemgra>
- <itemgra item_types="poi_theater" order="12-">
- <icon src="theater.png" />
- </itemgra>
- <itemgra item_types="poi_tide" order="12-">
- <icon src="tide.png" />
- </itemgra>
- <itemgra item_types="poi_tower" order="13-">
- <icon src="tower.xpm" />
- </itemgra>
- <itemgra item_types="poi_townhall" order="12-">
- <icon src="townhall.png" />
- </itemgra>
- <itemgra item_types="poi_trail" order="12-">
- <icon src="trail.png" />
- </itemgra>
- <itemgra item_types="poi_truck_stop" order="12-">
- <icon src="truck_stop.png" />
- </itemgra>
- <itemgra item_types="poi_tunnel" order="12-">
- <icon src="tunnel.png" />
- </itemgra>
- <itemgra item_types="poi_wine" order="12-">
- <icon src="wine.png" />
- </itemgra>
- <itemgra item_types="poi_worship" order="8-">
- <icon src="worship.png" />
- </itemgra>
- <itemgra item_types="poi_wrecker" order="12-">
- <icon src="wrecker.png" />
- </itemgra>
- <itemgra item_types="poi_zoo" order="9-">
- <icon src="zoo.png" />
- </itemgra>
- <itemgra item_types="poi_picnic" order="12-">
- <icon src="picnic.png" />
- </itemgra>
- <itemgra item_types="poi_playground" order="12-">
- <icon src="playground.png"/>
- </itemgra>
- <itemgra item_types="poi_gc_multi" order="12-">
- <icon src="gc_multi.xpm" />
- </itemgra>
- <itemgra item_types="poi_gc_tradi" order="12-">
- <icon src="gc_tradi.xpm" />
- </itemgra>
- <itemgra item_types="poi_gc_event" order="12-">
- <icon src="gc_event.xpm" />
- </itemgra>
- <itemgra item_types="poi_gc_mystery" order="12-">
- <icon src="gc_mystery.xpm" />
- </itemgra>
- <itemgra item_types="poi_gc_question" order="12-">
- <icon src="gc_question.xpm" />
- </itemgra>
- <itemgra item_types="poi_gc_stages" order="12-">
- <icon src="gc_stages.xpm" />
- </itemgra>
- <itemgra item_types="poi_gc_reference" order="12-">
- <icon src="gc_reference.xpm" />
- </itemgra>
- <itemgra item_types="poi_gc_webcam" order="12-">
- <icon src="gc_webcam.xpm" />
- </itemgra>
- <itemgra item_types="traffic_signals" order="13-">
- <icon src="traffic_signals.png" />
- </itemgra>
- <itemgra item_types="poi_wifi" order="13-">
- <icon src="wifi.png" />
- </itemgra>
- <itemgra item_types="poi_image" order="12-">
- <image />
- </itemgra>
- <itemgra item_types="poi_bench" order="13-">
- <icon src="bench.png" />
- </itemgra>
- <itemgra item_types="poi_biergarten" order="12-">
- <icon src="biergarten.png" />
- </itemgra>
- <itemgra item_types="poi_boundary_stone" order="13-">
- <icon src="boundary_stone.png" />
- </itemgra>
- <itemgra item_types="poi_castle" order="11-">
- <icon src="castle.png" />
- </itemgra>
- <itemgra item_types="poi_ruins" order="11-">
- <icon src="ruins.png" />
- </itemgra>
- <itemgra item_types="poi_hunting_stand" order="12-">
- <icon src="hunting_stand.png" />
- </itemgra>
- <itemgra item_types="poi_memorial" order="12-">
- <icon src="memorial.png" />
- </itemgra>
- <itemgra item_types="poi_monument" order="12-">
- <icon src="memorial.png" />
- </itemgra>
- <itemgra item_types="poi_shelter" order="11-">
- <icon src="shelter.png" />
- </itemgra>
- <itemgra item_types="poi_fountain" order="13-">
- <icon src="fountain.png" />
- </itemgra>
- <itemgra item_types="poi_potable_water" order="13-">
- <icon src="drinking_water.png"/>
- </itemgra>
- <itemgra item_types="poi_toilets" order="12-">
- <icon src="toilets.png" />
- </itemgra>
- <itemgra item_types="poi_viewpoint" order="10-">
- <icon src="viewpoint.png" />
- </itemgra>
- <itemgra item_types="tec_common" order="11-">
- <icon src="tec_common.png"/>
- </itemgra>
- <itemgra item_types="vehicle" order="0-">
- <icon src="gui_vehicle_16_16.png" />
- </itemgra>
- <itemgra item_types="vehicle_pedestrian" order="0-">
- <icon src="gui_vehicle_pedestrian_16_16.png" />
- </itemgra>
- <itemgra item_types="poi_custom0,poi_custom1,poi_custom2,poi_custom3,poi_custom4,poi_custom5,poi_custom6,poi_custom7,poi_custom8,poi_custom9,poi_customa,poi_customb,poi_customc,poi_customd,poi_custome,poi_customf"
- order="10-">
- <icon src="%s" />
- </itemgra>
- </layer>
- <layer name="Android-POI-Labels-full" active="0">
- <itemgra item_types="poi_airport,town_ghost,poi_hotel,poi_car_parking,poi_car_dealer_parts,poi_car_sharing,poi_fuel,poi_shopping,poi_attraction,poi_cafe,poi_bar,poi_pub,highway_exit,poi_camp_rv,poi_museum_history,poi_hospital,poi_dining,poi_fastfood,poi_police,poi_autoservice,poi_bank,poi_atm,poi_bus_station,poi_bus_stop,poi_business_service,poi_car_rent,poi_church,poi_bahai,poi_buddhist,poi_hindu,poi_islamic,poi_jain,poi_jewish,poi_pagan,poi_pastafarian,poi_shinto,poi_sikh,poi_taoist,poi_cinema,poi_concert,poi_drinking_water,poi_emergency,poi_fair,poi_fish,poi_government_building,poi_hotspring,poi_information,poi_justice,poi_landmark,poi_library,poi_mall,poi_manmade_feature,poi_marine,poi_marine_type,poi_mark,poi_oil_field,poi_peak,poi_personal_service,poi_pharmacy,poi_post_office,poi_public_office,poi_rail_halt,poi_rail_station,poi_rail_tram_stop,poi_repair_service,poi_resort,poi_restaurant,poi_restricted_area,poi_sailing,poi_scenic_area,poi_shop_bicycle,poi_school,poi_service,poi_shop_retail,poi_skiing,poi_social_service,poi_sport,poi_stadium,poi_swimming,poi_theater,poi_townhall,poi_trail,poi_truck_stop,poi_tunnel,poi_worship,poi_wrecker,poi_zoo,poi_biergarten,poi_castle,poi_ruins,poi_memorial,poi_monument,poi_shelter,poi_fountain,poi_viewpoint,vehicle"
- order="14-">
- <circle color="#606060" radius="0" width="0"
- text_size="10" />
- </itemgra>
- <itemgra item_types="poi_custom0,poi_custom1,poi_custom2,poi_custom3,poi_custom4,poi_custom5,poi_custom6,poi_custom7,poi_custom8,poi_custom9,poi_customa,poi_customb,poi_customc,poi_customd,poi_custome,poi_customf"
- order="14-">
- <circle color="#606060" radius="0" width="0"
- text_size="10" />
- </itemgra>
- </layer>
- <layer name="Found items" ref="Found items"/>
- </layout>
-
- <layout name="Car-simple" color="#839ea9">
- <layer name="polygon">
- <itemgra item_types="poly_town" order="8-">
- <polygon color="#6b8091"/>
- </itemgra>
- </layer>
- <layer name="streets">
- <itemgra item_types="water_line" order="11-">
- <polyline width="3" color="#5e71a7" />
- </itemgra>
- <itemgra item_types="rail" order="9-">
- <polyline width="4" color="#a4bac8" />
- <polyline width="1" color="#e0e0e0" dash="4,6"/>
- </itemgra>
- <itemgra item_types="street_1_city,street_1_land" order="12-">
- <polyline width="5" color="#516170"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="12-">
- <polyline width="7" color="#516170"/>
- </itemgra>
- <itemgra item_types="street_1_city,street_1_land" order="11">
- <polyline width="3" color="#516170"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="9-11">
- <polyline width="5" color="#516170"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="11-">
- <polyline width="9" color="#516170" />
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="8-10">
- <polyline width="7" color="#516170" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11-">
- <polyline width="9" color="#516170" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="8-10">
- <polyline width="7" color="#516170" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="6-7">
- <polyline width="3" color="#516170" />
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="4-">
- <polyline width="9" color="#516170" />
- </itemgra>
-
- <itemgra item_types="street_route" >
- <polyline width="11" color="#516170" />
- </itemgra>
-
- <itemgra item_types="street_1_city,street_1_land" order="12-">
- <polyline width="3" color="#a4bac8" />
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="12-">
- <polyline width="5" color="#90a3af" />
- </itemgra>
- <itemgra item_types="street_1_city,street_1_land" order="11">
- <polyline width="1" color="#a4bac8" />
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="9-11">
- <polyline width="3" color="#90a3af" />
- </itemgra>
-
- <itemgra item_types="street_3_city,street_3_land,ramp" order="11-">
- <polyline width="6" color="#a4bac8" />
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="8-10">
- <polyline width="4" color="#a4bac8" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11-">
- <polyline width="6" color="#c7e1f2" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="8-10">
- <polyline width="4" color="#c7e1f2" />
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="6-7">
- <polyline width="1" color="#c7e1f2" />
- </itemgra>
-
- <itemgra item_types="highway_city,highway_land" order="4-">
- <polyline width="3" color="#c0e1ff" />
- </itemgra>
-
- <itemgra item_types="street_route" >
- <polyline width="9" color="#ffffff" />
- </itemgra>
-
- <itemgra item_types="waypoint,route_end" >
- <circle color="#000000" radius="8" width="2" text_size="24"/>
- </itemgra>
- </layer>
- <layer name="labels">
- <itemgra item_types="water_line" order="11-">
- <text text_size="16" color="#0000ff" />
- </itemgra>
- <itemgra item_types="street_1_city,street_2_city,street_3_city,street_4_city,highway_city,street_1_land,street_2_land,street_3_land,street_4_land,street_n_lanes,highway_land,living_street,footway">
- <text text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="10-">
- <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="town_label_1e3,town_label_2e3,district_label_1e3,district_label_2e3" order="9-">
- <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="town_label_5e3,district_label_5e3" order="8-">
- <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="town_label_1e4,district_label_1e4" order="7-">
- <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="town_label_2e4,district_label_2e4" order="6-">
- <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="town_label_5e4,town_label_1e5,district_label_5e4,district_label_1e5" order="5-">
- <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="town_label_2e5,district_label_2e5" order="4-">
- <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
- <itemgra item_types="town_label_5e5,district_label_5e5" order="2-">
- <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
-
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6,town_label_1e7,district_label_1e6,district_label_2e6,district_label_5e6,district_label_1e7">
- <circle radius="3" text_size="16" color="#ffffff" background_color="#000000"/>
- </itemgra>
- </layer>
- <layer name="Found items" ref="Found items"/>
- </layout>
-
- <layout name="Bike" color="#ffefb7" font="Liberation Sans">
-
- <cursor w="26" h="26">
- <itemgra>
- <circle color="#0000ff" radius="24" width="2">
- <coord x="0" y="0"/>
- </circle>
- </itemgra>
- <itemgra speed_range="-2">
- <polyline color="#0000ff" width="2">
- <coord x="0" y="0"/>
- <coord x="0" y="0"/>
- </polyline>
- </itemgra>
- <itemgra speed_range="3-">
- <polyline color="#0000ff" width="2">
- <coord x="-7" y="-10"/>
- <coord x="0" y="12"/>
- <coord x="7" y="-10"/>
- </polyline>
- </itemgra>
- </cursor>
-
- <layer name="Landuse">
- <itemgra item_types="image" order="0-">
- <image/>
- </itemgra>
- <itemgra item_types="poly_wood" order="0-">
- <polygon color="#8ec78d"/>
- </itemgra>
- <itemgra item_types="poly_town" order="0-">
- <polygon color="#ffc895"/>
- <polyline color="#ebb481"/>
- </itemgra>
- <itemgra item_types="poly_park" order="0-">
- <polygon color="#7cc334"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_water" order="0-">
- <polygon color="#82c8ea"/>
- <polyline color="#5096b8"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_land" order="0-">
- <polygon color="#ffefb7"/>
- <polyline color="#ffefb7"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_airport" order="0-">
- <polygon color="#a0a0a0"/>
- </itemgra>
- <itemgra item_types="poly_sport" order="0-">
- <polygon color="#ff8c00"/>
- </itemgra>
- <itemgra item_types="poly_industry,poly_place,poly_railway" order="0-">
- <polygon color="#e6e6e6"/>
- </itemgra>
- <itemgra item_types="poly_commercial" order="0-">
- <polygon color="#fff8dc"/>
- </itemgra>
- <itemgra item_types="poly_industry,poly_building,poly_place,poly_brownfield,poly_greenfield,poly_construction,poly_railway" order="0-">
- <polygon color="#ecd8ff"/>
- </itemgra>
- <itemgra item_types="poly_farm" order="0-">
- <polygon color="#c7f1a3"/>
- <polyline color="#79c691"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_meadow" order="0-">
- <polygon color="#c7f1a3"/>
- <polyline color="#79c691"/>
- </itemgra>
- <itemgra item_types="poly_scree,poly_scrub,poly_fell,poly_heath" order="0-">
- <polygon color="#c7f1a3"/>
- <polyline color="#79c691"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_marsh,poly_mud,poly_quarry" order="0-">
- <polygon color="#DEB887"/>
- <polyline color="#DEB887"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_allotments,poly_playground,poly_village_green,poly_recreation_ground,poly_common,poly_garden" order="0-">
- <polygon color="#c7f1a3"/>
- <polyline color="#79c691"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_ruins" order="0-">
- <polygon color="#b6a6a6"/>
- </itemgra>
- <itemgra item_types="poly_apron" order="0-">
- <polygon color="#d0d0d0"/>
- </itemgra>
- <itemgra item_types="poly_terminal" order="7-">
- <polygon color="#e3c6a6"/>
- </itemgra>
- <itemgra item_types="poly_cemetery" order="1-">
- <polygon color="#bde3cb"/>
- </itemgra>
- <itemgra item_types="poly_car_parking" order="1-">
- <polygon color="#d2d2d2"/>
- </itemgra>
- <itemgra item_types="poly_building" order="0-">
- <polygon color="#ff6347"/>
- </itemgra>
- </layer>
- <layer name="Contour Lines">
- <itemgra item_types="height_line_1" order="8">
- <polyline color="#A9A9A9" width="1"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="height_line_1" order="9">
- <polyline color="#A9A9A9" width="2"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="height_line_2" order="9">
- <polyline color="#A9A9A9" width="1"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="height_line_1" order="10-">
- <polyline color="#A9A9A9" width="3"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="height_line_2" order="10-">
- <polyline color="#A9A9A9" width="2"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="height_line_3" order="10-">
- <polyline color="#A9A9A9" width="1"/>
- </itemgra>
- </layer>
- <!-- "Contour Lines" -->
-
- <layer name="Barriers">
- <itemgra item_types="ditch" order="8-">
- <polyline color="#B8860B" width="1"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="hedge" order="8-">
- <polyline color="#90EE90" width="1"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="fence" order="8-">
- <polyline color="#808080" width="1"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="wall" order="8-">
- <polyline color="#808080" width="1"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="retaining_wall" order="8-">
- <polyline color="#808080" width="1"/>
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="city_wall" order="8-">
- <polyline color="#CD5C5C" width="1"/>
- <text text_size="8"/>
- </itemgra>
- </layer>
- <!-- "Barriers" -->
-
- <layer name="Waterways">
- <itemgra item_types="water_line" order="0-">
- <polyline color="#82c8ea" width="2"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="water_river" order="0-">
- <polyline color="#82c8ea" width="4"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="water_canal" order="0-">
- <polyline color="#82c8ea" width="3"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="water_stream" order="0-">
- <polyline color="#82c8ea" width="2"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="water_drain" order="0-">
- <polyline color="#82c8ea" width="1"/>
- <text text_size="5"/>
- </itemgra>
- </layer>
- <layer name="Borders">
- <itemgra item_types="border_state" order="0-5">
- <polyline color="#778899" width="3"/>
- <polyline color="#ffefb7" dash="3,2,1,3" width="1"/>
- </itemgra>
- <itemgra item_types="border_country" order="0-5">
- <polyline color="#778899" width="2"/>
- <polyline color="#ffefb7" dash="3,2,1,3" width="1"/>
- </itemgra>
- <itemgra item_types="border_state" order="6-11">
- <polyline color="#778899" width="3"/>
- <polyline color="#ffefb7" dash="6,6,1,6" width="1"/>
- </itemgra>
- <itemgra item_types="border_country" order="6-11">
- <polyline color="#778899" width="2"/>
- <polyline color="#ffefb7" dash="6,6,1,6" width="1"/>
- </itemgra>
- <itemgra item_types="border_state" order="12-20">
- <polyline color="#778899" width="3"/>
- <polyline color="#ffefb7" dash="10,10,2,10" width="1"/>
- </itemgra>
- <itemgra item_types="border_country" order="12-20">
- <polyline color="#778899" width="2"/>
- <polyline color="#ffefb7" dash="10,10,2,10" width="1"/>
- </itemgra>
- </layer>
- <layer name="Current Route">
- <itemgra item_types="street_route" order="2">
- <polyline color="#FF00FF" width="4"/>
- </itemgra>
- <itemgra item_types="street_route" order="3-5">
- <polyline color="#FF00FF" width="8"/>
- </itemgra>
- <itemgra item_types="street_route" order="6">
- <polyline color="#FF00FF" width="10"/>
- </itemgra>
- <itemgra item_types="street_route" order="7-8">
- <polyline color="#FF00FF" width="16"/>
- </itemgra>
- <itemgra item_types="street_route" order="9-10">
- <polyline color="#FF00FF" width="20"/>
- </itemgra>
- <itemgra item_types="street_route" order="11">
- <polyline color="#FF00FF" width="28"/>
- </itemgra>
- <itemgra item_types="street_route" order="12">
- <polyline color="#FF00FF" width="32"/>
- </itemgra>
- <itemgra item_types="street_route" order="13">
- <polyline color="#FF00FF" width="52"/>
- </itemgra>
- <itemgra item_types="street_route" order="14">
- <polyline color="#FF00FF" width="64"/>
- </itemgra>
- <itemgra item_types="street_route" order="15">
- <polyline color="#FF00FF" width="68"/>
- </itemgra>
- <itemgra item_types="street_route" order="16">
- <polyline color="#FF00FF" width="132"/>
- </itemgra>
- <itemgra item_types="street_route" order="17">
- <polyline color="#FF00FF" width="268"/>
- </itemgra>
- <itemgra item_types="street_route" order="18">
- <polyline color="#FF00FF" width="530"/>
- </itemgra>
- </layer>
- <layer name="Ways and Paths">
- <itemgra item_types="powerline" order="12-">
- <polyline color="#778899" width="1"/>
- <polyline color="#778899" dash="1,80" width="5"/>
- </itemgra>
- <itemgra item_types="street_nopass" order="10-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="track_paved" order="8-">
- <polyline color="#d2d2d2" width="5"/>
- <polyline color="#fefefe" width="3"/>
- </itemgra>
- <itemgra item_types="track_gravelled" order="9-">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#fefefe" width="2"/>
- </itemgra>
- <itemgra item_types="track_unpaved" order="10-">
- <polyline color="#d2d2d2" width="3"/>
- <polyline color="#fefefe" width="1"/>
- </itemgra>
- <itemgra item_types="track_ground" order="11-">
- <polyline color="#d2d2d2" width="3"/>
- <polyline color="#fefefe" width="1" dash="6,6"/>
- </itemgra>
- <itemgra item_types="track_grass" order="12-">
- <polyline color="#fefefe" width="2"/>
- <polyline color="#ffefb7" width="1" dash="6,6"/>
- </itemgra>
- <itemgra item_types="bridleway" order="10-">
- <polyline color="#8b4513" width="3"/>
- <polyline color="#f4a460" width="1"/>
- </itemgra>
- <itemgra item_types="cycleway" order="10-">
- <polyline color="#006400" width="4"/>
- <polyline color="#3cb371" width="2"/>
- </itemgra>
- <itemgra item_types="footway" order="12-">
- <polyline color="#8b4513" width="3"/>
- <polyline color="#CD853F" width="1"/>
- </itemgra>
- <itemgra item_types="steps" order="12-">
- <polyline color="#8b4513" width="3"/>
- <polyline color="#F4A460" width="1" dash="6,4"/>
- </itemgra>
- <itemgra item_types="path" order="11-">
- <polyline color="#8b4513" width="3"/>
- <polyline color="#ffefb7" width="1" dash="2,4"/>
- </itemgra>
- <itemgra item_types="hiking" order="11-">
- <polyline color="#8b4513" width="2"/>
- <polyline color="#ffefb7" width="1" dash="4,4"/>
- </itemgra>
- <itemgra item_types="hiking_mountain" order="11-">
- <polyline color="#8b4513" width="2"/>
- <polyline color="#ffefb7" width="1" dash="6,4"/>
- </itemgra>
- <itemgra item_types="hiking_mountain_demanding" order="13-">
- <polyline color="#8b4513" width="2"/>
- <polyline color="#ffefb7" width="1" dash="8,4"/>
- </itemgra>
- <itemgra item_types="hiking_alpine" order="13-">
- <polyline color="#8b4513" width="1" dash="10,4"/>
- </itemgra>
- <itemgra item_types="hiking_alpine_demanding" order="14-">
- <polyline color="#8b4513" width="1" dash="12,4"/>
- </itemgra>
- <itemgra item_types="hiking_alpine_difficult" order="14-">
- <polyline color="#8b4513" width="1" dash="14,4"/>
- </itemgra>
- </layer>
- <layer name="Streets">
- <itemgra item_types="poly_pedestrian,poly_plaza" order="0-">
- <polygon color="#d2d2d2"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="10">
- <polyline color="#d2d2d2" width="3"/>
- <polyline color="#dddddd" width="1"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="11">
- <polyline color="#d2d2d2" width="5"/>
- <polyline color="#dddddd" width="3"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="12">
- <polyline color="#d2d2d2" width="8"/>
- <polyline color="#dddddd" width="6"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="13">
- <polyline color="#d2d2d2" width="9"/>
- <polyline color="#dddddd" width="7"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="14">
- <polyline color="#d2d2d2" width="13"/>
- <polyline color="#dddddd" width="9"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="15">
- <polyline color="#d2d2d2" width="18"/>
- <polyline color="#dddddd" width="14"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="16">
- <polyline color="#d2d2d2" width="21"/>
- <polyline color="#dddddd" width="17"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="17">
- <polyline color="#d2d2d2" width="25"/>
- <polyline color="#dddddd" width="21"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="18">
- <polyline color="#d2d2d2" width="40"/>
- <polyline color="#dddddd" width="34"/>
- </itemgra>
- <itemgra item_types="street_service" order="9">
- <polyline color="#d2d2d2" width="2"/>
- <polyline color="#fefefe" width="1"/>
- </itemgra>
- <itemgra item_types="street_service" order="10">
- <polyline color="#d2d2d2" width="3"/>
- <polyline color="#fefefe" width="2"/>
- </itemgra>
- <itemgra item_types="street_service" order="11">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#fefefe" width="2"/>
- </itemgra>
- <itemgra item_types="street_service" order="12">
- <polyline color="#d2d2d2" width="5"/>
- <polyline color="#fefefe" width="3"/>
- </itemgra>
- <itemgra item_types="street_service" order="13">
- <polyline color="#d2d2d2" width="6"/>
- <polyline color="#fefefe" width="4"/>
- </itemgra>
- <itemgra item_types="street_service" order="14">
- <polyline color="#d2d2d2" width="7"/>
- <polyline color="#fefefe" width="5"/>
- </itemgra>
- <itemgra item_types="street_service" order="15">
- <polyline color="#d2d2d2" width="8"/>
- <polyline color="#fefefe" width="6"/>
- </itemgra>
- <itemgra item_types="street_service" order="16">
- <polyline color="#d2d2d2" width="9"/>
- <polyline color="#fefefe" width="7"/>
- </itemgra>
- <itemgra item_types="street_service" order="17">
- <polyline color="#d2d2d2" width="10"/>
- <polyline color="#fefefe" width="8"/>
- </itemgra>
- <itemgra item_types="street_service" order="18">
- <polyline color="#d2d2d2" width="11"/>
- <polyline color="#fefefe" width="9"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="12">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#fefefe" width="2"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="13">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#fefefe" width="2"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="14">
- <polyline color="#d2d2d2" width="5"/>
- <polyline color="#fefefe" width="3"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="15">
- <polyline color="#d2d2d2" width="6"/>
- <polyline color="#fefefe" width="4"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="16">
- <polyline color="#d2d2d2" width="7"/>
- <polyline color="#fefefe" width="5"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="17">
- <polyline color="#d2d2d2" width="8"/>
- <polyline color="#fefefe" width="6"/>
- </itemgra>
- <itemgra item_types="street_parking_lane" order="18">
- <polyline color="#d2d2d2" width="9"/>
- <polyline color="#fefefe" width="7"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="8-10">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#ffffff" width="2"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="11">
- <polyline color="#d2d2d2" width="6"/>
- <polyline color="#ffffff" width="4"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="12">
- <polyline color="#d2d2d2" width="10"/>
- <polyline color="#ffffff" width="8"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="13">
- <polyline color="#d2d2d2" width="12"/>
- <polyline color="#ffffff" width="9"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="14">
- <polyline color="#d2d2d2" width="15"/>
- <polyline color="#ffffff" width="13"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="15">
- <polyline color="#d2d2d2" width="17"/>
- <polyline color="#ffffff" width="14"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="16">
- <polyline color="#d2d2d2" width="33"/>
- <polyline color="#ffffff" width="26"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="17">
- <polyline color="#d2d2d2" width="69"/>
- <polyline color="#ffffff" width="61"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="18">
- <polyline color="#d2d2d2" width="132"/>
- <polyline color="#ffffff" width="126"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="7-8">
- <polyline color="#c0c0c0" width="2"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="9">
- <polyline color="#c0c0c0" width="3"/>
- <polyline color="#ffff00" width="1"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="10">
- <polyline color="#c0c0c0" width="4"/>
- <polyline color="#ffff00" width="2"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="11">
- <polyline color="#c0c0c0" width="5"/>
- <polyline color="#ffff00" width="3"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="12">
- <polyline color="#c0c0c0" width="7"/>
- <polyline color="#ffff00" width="5"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="13">
- <polyline color="#c0c0c0" width="11"/>
- <polyline color="#ffff00" width="8"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="14">
- <polyline color="#c0c0c0" width="14"/>
- <polyline color="#ffff00" width="11"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="15">
- <polyline color="#c0c0c0" width="19"/>
- <polyline color="#ffff00" width="15"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="16">
- <polyline color="#c0c0c0" width="30"/>
- <polyline color="#ffff00" width="26"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="17">
- <polyline color="#c0c0c0" width="63"/>
- <polyline color="#ffff00" width="57"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,ramp" order="18">
- <polyline color="#c0c0c0" width="100"/>
- <polyline color="#ffff00" width="90"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="7-8">
- <polyline color="#a0a0a0" width="3"/>
- <polyline color="#ffff00" width="1"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="9">
- <polyline color="#a0a0a0" width="5"/>
- <polyline color="#ffff00" width="3"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="10">
- <polyline color="#a0a0a0" width="8"/>
- <polyline color="#ffff00" width="6"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="11">
- <polyline color="#a0a0a0" width="9"/>
- <polyline color="#ffff00" width="7"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="12">
- <polyline color="#a0a0a0" width="13"/>
- <polyline color="#ffff00" width="9"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="13">
- <polyline color="#a0a0a0" width="18"/>
- <polyline color="#ffff00" width="14"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="14">
- <polyline color="#a0a0a0" width="21"/>
- <polyline color="#ffff00" width="17"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="15">
- <polyline color="#a0a0a0" width="25"/>
- <polyline color="#ffff00" width="21"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="16">
- <polyline color="#a0a0a0" width="40"/>
- <polyline color="#ffff00" width="34"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="17">
- <polyline color="#a0a0a0" width="79"/>
- <polyline color="#ffff00" width="73"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,roundabout" order="18">
- <polyline color="#a0a0a0" width="156"/>
- <polyline color="#ffff00" width="150"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="2-6">
- <polyline color="#404040" width="1"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="7-8">
- <polyline color="#404040" width="3"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="9">
- <polyline color="#000000" width="5"/>
- <polyline color="#ff0000" width="3"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="10">
- <polyline color="#000000" width="6"/>
- <polyline color="#ff0000" width="4"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11">
- <polyline color="#000000" width="9"/>
- <polyline color="#ff0000" width="7"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="12">
- <polyline color="#000000" width="13"/>
- <polyline color="#ff0000" width="9"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="13">
- <polyline color="#000000" width="18"/>
- <polyline color="#ff0000" width="14"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="14">
- <polyline color="#000000" width="21"/>
- <polyline color="#ff0000" width="17"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="15">
- <polyline color="#000000" width="24"/>
- <polyline color="#ff0000" width="20"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="16">
- <polyline color="#000000" width="39"/>
- <polyline color="#ff0000" width="33"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="17">
- <polyline color="#000000" width="78"/>
- <polyline color="#ff0000" width="72"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="18">
- <polyline color="#000000" width="156"/>
- <polyline color="#ff0000" width="150"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="2">
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="3-5">
- <polyline color="#ff0000" width="3"/>
- <polyline color="#ffff00" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="6">
- <polyline color="#ff0000" width="4"/>
- <polyline color="#ffff00" width="2"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="7-8">
- <polyline color="#ff0000" width="7"/>
- <polyline color="#ffff00" width="5"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="9-10">
- <polyline color="#ff0000" width="9"/>
- <polyline color="#ffff00" width="5"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="11">
- <polyline color="#ff0000" width="13"/>
- <polyline color="#ffff00" width="9"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="12">
- <polyline color="#ff0000" width="15"/>
- <polyline color="#ffff00" width="10"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="13">
- <polyline color="#ff0000" width="25"/>
- <polyline color="#ffff00" width="17"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="14">
- <polyline color="#ff0000" width="31"/>
- <polyline color="#ffff00" width="24"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="15">
- <polyline color="#ff0000" width="33"/>
- <polyline color="#ffff00" width="27"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="16">
- <polyline color="#ff0000" width="65"/>
- <polyline color="#ffff00" width="59"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="17">
- <polyline color="#ff0000" width="133"/>
- <polyline color="#ffff00" width="127"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="18">
- <polyline color="#ff0000" width="264"/>
- <polyline color="#ffff00" width="258"/>
- <polyline color="#ff0000" width="1"/>
- </itemgra>
- </layer>
- <layer name="Aerialways">
- <itemgra item_types="aeroway_taxiway" order="10">
- <polyline color="#989994" width="4"/>
- <polyline color="#d3dbbc" width="2"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="11">
- <polyline color="#989994" width="6"/>
- <polyline color="#d3dbbc" width="4"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="12">
- <polyline color="#989994" width="10"/>
- <polyline color="#d3dbbc" width="8"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="13">
- <polyline color="#989994" width="12"/>
- <polyline color="#d3dbbc" width="9"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="14">
- <polyline color="#989994" width="15"/>
- <polyline color="#d3dbbc" width="13"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="15">
- <polyline color="#989994" width="17"/>
- <polyline color="#d3dbbc" width="14"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="16">
- <polyline color="#989994" width="33"/>
- <polyline color="#d3dbbc" width="26"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="17">
- <polyline color="#989994" width="69"/>
- <polyline color="#d3dbbc" width="61"/>
- </itemgra>
- <itemgra item_types="aeroway_taxiway" order="18">
- <polyline color="#989994" width="132"/>
- <polyline color="#d3dbbc" width="126"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="2-6">
- <polyline color="#404040" width="1"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="7-8">
- <polyline color="#404040" width="3"/>
- <polyline color="#d3dbbc" width="1"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="9">
- <polyline color="#6b6f5f" width="5"/>
- <polyline color="#d3dbbc" width="3"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="10">
- <polyline color="#6b6f5f" width="6"/>
- <polyline color="#d3dbbc" width="4"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="11">
- <polyline color="#6b6f5f" width="9"/>
- <polyline color="#d3dbbc" width="7"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="12">
- <polyline color="#6b6f5f" width="13"/>
- <polyline color="#d3dbbc" width="9"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="13">
- <polyline color="#6b6f5f" width="18"/>
- <polyline color="#d3dbbc" width="14"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="14">
- <polyline color="#6b6f5f" width="21"/>
- <polyline color="#d3dbbc" width="17"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="15">
- <polyline color="#6b6f5f" width="24"/>
- <polyline color="#d3dbbc" width="20"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="16">
- <polyline color="#6b6f5f" width="39"/>
- <polyline color="#d3dbbc" width="33"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="17">
- <polyline color="#6b6f5f" width="78"/>
- <polyline color="#d3dbbc" width="72"/>
- </itemgra>
- <itemgra item_types="aeroway_runway" order="18">
- <polyline color="#6b6f5f" width="156"/>
- <polyline color="#d3dbbc" width="150"/>
- </itemgra>
- </layer>
- <layer name="Railways">
- <itemgra item_types="rail" order="6-9">
- <polyline color="#696969" width="4"/>
- <polyline color="#FFFFFF" dash="2,5" width="1"/>
- </itemgra>
- <itemgra item_types="rail_narrow_gauge" order="6-9">
- <polyline color="#696969" width="4"/>
- <polyline color="#FFFFFF" dash="2,5" width="1"/>
- </itemgra>
- <itemgra item_types="rail" order="10-13">
- <polyline color="#696969" width="6"/>
- <polyline color="#FFFFFF" dash="3,8" width="1"/>
- </itemgra>
- <itemgra item_types="rail_narrow_gauge" order="10-13">
- <polyline color="#696969" width="6"/>
- <polyline color="#FFFFFF" dash="3,8" width="1"/>
- </itemgra>
- <itemgra item_types="rail" order="14-18">
- <polyline color="#696969" width="8"/>
- <polyline color="#FFFFFF" dash="4,12" width="1"/>
- </itemgra>
- <itemgra item_types="rail_narrow_gauge" order="14-18">
- <polyline color="#696969" width="8"/>
- <polyline color="#FFFFFF" dash="4,12" width="1"/>
- </itemgra>
- <itemgra item_types="rail_light" order="10-13">
- <polyline color="#696969" width="4"/>
- <polyline color="#FFFFFF" dash="2,5" width="1"/>
- </itemgra>
- <itemgra item_types="rail_light" order="14-18">
- <polyline color="#696969" width="6"/>
- <polyline color="#FFFFFF" dash="4,8" width="1"/>
- </itemgra>
- <itemgra item_types="rail_subway" order="8-">
- <polyline color="#696969" width="2"/>
- <polyline color="#FFFFFF" dash="5,5" width="1"/>
- </itemgra>
- <itemgra item_types="rail_mono" order="10-">
- <polyline color="#696969" width="2"/>
- </itemgra>
- <itemgra item_types="rail_tram,bus_guideway" order="10-">
- <polyline color="#696969" width="2"/>
- </itemgra>
- <itemgra item_types="rail_preserved" order="10-">
- <polyline color="#696969" width="1" dash="7"/>
- </itemgra>
- <itemgra item_types="rail_disused" order="12-">
- <polyline color="#d3d3d3" width="1" dash="10"/>
- </itemgra>
- <itemgra item_types="rail_abandoned" order="12-">
- <polyline color="#f5f5f5" width="1" dash="10"/>
- </itemgra>
- <itemgra item_types="lift_cable_car" order="10-">
- <polyline color="#778899" width="5"/>
- <polyline color="#ffefb7" dash="1,40" width="1"/>
- </itemgra>
- <itemgra item_types="lift_chair" order="10-">
- <polyline color="#778899" width="5"/>
- <polyline color="#ffefb7" dash="1,40" width="1"/>
- </itemgra>
- <itemgra item_types="lift_drag" order="10-">
- <polyline color="#778899" width="5"/>
- <polyline color="#ffefb7" dash="1,40" width="1"/>
- </itemgra>
- <itemgra item_types="ferry" order="5-">
- <polyline color="#000000" width="3"/>
- <polyline color="#ffefb7" width="1" dash="5"/>
- </itemgra>
- <itemgra item_types="track" order="3-">
- <polyline color="#3f3f3f" width="1"/>
- </itemgra>
- </layer>
- <layer name="Internal">
- <itemgra item_types="track" order="7-">
- <polyline color="#3f3f3f" width="1"/>
- </itemgra>
- <itemgra item_types="track_tracked" order="7-">
- <polyline color="#3f3fff" width="3"/>
- </itemgra>
- <itemgra item_types="rg_segment" order="12-">
- <polyline color="#FF089C" width="1"/>
- <arrows color="#FF089C" width="1"/>
- </itemgra>
- <itemgra item_types="rg_point" order="12-">
- <circle color="#FF089C" radius="10" text_size="7"/>
- </itemgra>
- <itemgra item_types="nav_left_1" order="0-">
- <icon src="nav_left_1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_left_2" order="0-">
- <icon src="nav_left_2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_left_3" order="0-">
- <icon src="nav_left_3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_right_1" order="0-">
- <icon src="nav_right_1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_right_2" order="0-">
- <icon src="nav_right_2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_right_3" order="0-">
- <icon src="nav_right_3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_straight" order="0-">
- <icon src="nav_straight_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_turnaround_left" order="0-">
- <icon src="nav_turnaround_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_turnaround_right" order="0-">
- <icon src="nav_turnaround_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l1" order="0-">
- <icon src="nav_roundabout_l1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r1" order="0-">
- <icon src="nav_roundabout_r1_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l2" order="0-">
- <icon src="nav_roundabout_l2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r2" order="0-">
- <icon src="nav_roundabout_r2_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l3" order="0-">
- <icon src="nav_roundabout_l3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r3" order="0-">
- <icon src="nav_roundabout_r3_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l4" order="0-">
- <icon src="nav_roundabout_l4_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r4" order="0-">
- <icon src="nav_roundabout_r4_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l5" order="0-">
- <icon src="nav_roundabout_l5_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r5" order="0-">
- <icon src="nav_roundabout_r5_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l6" order="0-">
- <icon src="nav_roundabout_l6_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r6" order="0-">
- <icon src="nav_roundabout_r6_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l7" order="0-">
- <icon src="nav_roundabout_l7_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r7" order="0-">
- <icon src="nav_roundabout_r7_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_l8" order="0-">
- <icon src="nav_roundabout_l8_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_roundabout_r8" order="0-">
- <icon src="nav_roundabout_r8_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_keep_left" order="0-">
- <icon src="nav_keep_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_merge_left" order="0-">
- <icon src="nav_merge_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_keep_right" order="0-">
- <icon src="nav_keep_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_merge_right" order="0-">
- <icon src="nav_merge_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_exit_left" order="0-">
- <icon src="nav_exit_left_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="nav_exit_right" order="0-">
- <icon src="nav_exit_right_bk.svg" w="32" h="32"/>
- </itemgra>
- <itemgra item_types="route_end" order="0-">
- <icon src="nav_destination_bk.svg" w="32" h="32" x="4" y="30"/>
- </itemgra>
-
- <itemgra item_types="waypoint,route_end" order="2">
- <circle color="#000000" radius="4" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="3-5">
- <circle color="#000000" radius="8" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="6">
- <circle color="#000000" radius="10" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="7-8">
- <circle color="#000000" radius="16" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="9-10">
- <circle color="#000000" radius="20" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="11">
- <circle color="#000000" radius="28" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="12">
- <circle color="#000000" radius="32" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="13">
- <circle color="#000000" radius="52" width="4" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="14">
- <circle color="#000000" radius="64" width="4" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="15">
- <circle color="#000000" radius="68" width="6" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="16">
- <circle color="#000000" radius="132" width="8" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="17">
- <circle color="#000000" radius="268" width="8" text_size="48"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="18">
- <circle color="#000000" radius="530" width="8" text_size="48"/>
- </itemgra>
-
- <itemgra item_types="nav_none" order="0-">
- <icon src="unknown.svg"/>
- </itemgra>
- <itemgra item_types="announcement" order="7-">
- <icon src="gui_sound_32_32.png"/>
- <circle color="#FF089C" radius="10" text_size="7"/>
- </itemgra>
- </layer>
- <layer name="Street Labels">
- <itemgra item_types="highway_exit_label" order="10-">
- <circle color="#000000" radius="3" text_size="12"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street" order="10-18">
- <text text_size="8"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp" order="11-18">
- <text text_size="9"/>
- </itemgra>
- <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land" order="12-18">
- <text text_size="9"/>
- </itemgra>
- <itemgra item_types="track,track_paved,track_gravelled,track_unpaved,track_ground,track_grass" order="12-18">
- <text text_size="9"/>
- </itemgra>
- <itemgra item_types="bridleway,cycleway,footway,steps,path" order="12-18">
- <text text_size="9"/>
- </itemgra>
- <itemgra item_types="hiking,hiking_mountain,hiking_mountain_demanding,hiking_alpine,hiking_alpine_demanding,hiking_alpine_difficult" order="12-18">
- <text text_size="9"/>
- </itemgra>
- </layer>
- <layer name="Unknown Elements">
- <!-- This entry shows all unknown linear elements as blue lines -->
- <!--
- <itemgra item_types="street_unkn" order="0-">
- <polyline color="#8080ff" width="3"/>
- </itemgra>
- -->
- </layer>
- <layer name="Place Labels">
- <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="12-">
- <circle color="#000000" radius="3" text_size="12"/>
- </itemgra>
- <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3" order="9-">
- <circle color="#000000" radius="3" text_size="12"/>
- </itemgra>
- <itemgra item_types="town_label_1e3,town_label_2e3,town_label_5e3,place_label" order="9-">
- <circle color="#000000" radius="3" text_size="12"/>
- </itemgra>
- <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4" order="7-">
- <circle color="#000000" radius="3" text_size="12"/>
- </itemgra>
- <itemgra item_types="town_label_1e4,town_label_2e4,town_label_5e4" order="7-">
- <circle color="#000000" radius="3" text_size="12"/>
- </itemgra>
- <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5" order="5-">
- <circle color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="5-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6" order="3-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6" order="3-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="town_label_1e7,district_label_1e7" order="1-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- </layer>
-
- <xi:include xpointer="xpointer(/config/navit/layout[@name='Car']/layer[@name='POI Symbols'])"/>
- <!--<xi:include xpointer="xpointer(/config/navit/layout[@name='Car']/layer[@name='POI Labels'])"/> -->
-
- <!-- "Bicycle POIs" -->
- <layer name="Bicycle POI Symbols">
- <itemgra item_types="poi_bicycle_parking" order="12-">
- <icon src="bicycle_parking.png"/>
- </itemgra>
- <itemgra item_types="poi_bicycle_rental" order="11-">
- <icon src="bicycle_rental.png"/>
- </itemgra>
- </layer>
- <layer name="Bicycle POI Labels">
- <itemgra item_types="poi_bicycle_parking,poi_bicycle_rental" order="14-">
- <circle color="#606060" radius="0" width="0" text_size="10"/>
- </itemgra>
- </layer>
- <layer name="Found items" ref="Found items"/>
- </layout>
-
- <layout name="T@H" font="Liberation Sans">
-
- <cursor w="26" h="26">
- <itemgra>
- <circle color="#0000ff" radius="24" width="2">
- <coord x="0" y="0"/>
- </circle>
- </itemgra>
- <itemgra speed_range="-2">
- <polyline color="#0000ff" width="2">
- <coord x="0" y="0"/>
- <coord x="0" y="0"/>
- </polyline>
- </itemgra>
- <itemgra speed_range="3-">
- <polyline color="#0000ff" width="2">
- <coord x="-7" y="-10"/>
- <coord x="0" y="12"/>
- <coord x="7" y="-10"/>
- </polyline>
- </itemgra>
- </cursor>
-
- <layer name="sea" details="0">
- <!-- landuse=forest -->
- <itemgra item_types="poly_wood" order="0-">
- <polygon color="#72bf81"/>
- </itemgra>
- <itemgra item_types="poly_flats,poly_scrub,poly_military_zone,poly_marine,plantation,tundra" order="0-">
- <polygon color="#a0a0a0"/>
- <text text_size="5"/>
- </itemgra>
- <!-- landuse=residential -->
- <itemgra item_types="poly_town" order="0-">
- <polygon color="#f2f2f2"/>
- </itemgra>
- <!-- natural=water -->
- <itemgra item_types="poly_water" order="0-">
- <polygon color="#b5d6f1"/>
- <polyline color="#b5d6f1"/>
- <text text_size="8"/>
- </itemgra>
- <!-- leisure=park -->
- <itemgra item_types="poly_park" order="0-">
- <polygon color="#c7f1a3"/>
- <polyline color="#79c691"/>
- <text text_size="5"/>
- </itemgra>
- <itemgra item_types="poly_airport" order="0-">
- <polygon color="#a0a0a0"/>
- </itemgra>
- <itemgra item_types="poly_sport" order="0-">
- <polygon color="#4af04f"/>
- </itemgra>
- <!-- landuse=industrial -->
- <itemgra item_types="poly_industry,poly_building,poly_place" order="0-">
- <polygon color="#ecd8ff"/>
- </itemgra>
- <!-- waterway=stream -->
- <itemgra item_types="water_line" order="0-4">
- <polyline color="#b5d6f1" width="1"/>
- <text text_size="8"/>
- </itemgra>
- <!-- railway=subway -->
- <itemgra item_types="rail" order="6">
- <polyline color="#aaaaaa" width="1"/>
- </itemgra>
- <itemgra item_types="rail" order="7-8">
- <polyline color="#aaaaaa" width="2"/>
- </itemgra>
- <itemgra item_types="rail" order="9-">
- <polyline color="#aaaaaa" width="6"/>
- </itemgra>
- <itemgra item_types="ferry" order="5-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="border_country" order="0-">
- <polyline color="#b8434e" width="1"/>
- </itemgra>
- <itemgra item_types="border_state" order="0-">
- <polyline color="#808080" width="1"/>
- </itemgra>
- <itemgra item_types="height_line_1" order="0-">
- <polyline color="#000000" width="1"/>
- </itemgra>
- <itemgra item_types="height_line_2" order="0-">
- <polyline color="#000000" width="2"/>
- </itemgra>
- <!-- routing -->
- <itemgra item_types="street_route" order="2">
- <polyline color="#0000a0" width="4"/>
- </itemgra>
- <itemgra item_types="street_route" order="3-5">
- <polyline color="#0000a0" width="8"/>
- </itemgra>
- <itemgra item_types="street_route" order="6">
- <polyline color="#0000a0" width="10"/>
- </itemgra>
- <itemgra item_types="street_route" order="7-8">
- <polyline color="#0000a0" width="16"/>
- </itemgra>
- <itemgra item_types="street_route" order="9-10">
- <polyline color="#0000a0" width="20"/>
- </itemgra>
- <itemgra item_types="street_route" order="11">
- <polyline color="#0000a0" width="28"/>
- </itemgra>
- <itemgra item_types="street_route" order="12">
- <polyline color="#0000a0" width="32"/>
- </itemgra>
- <itemgra item_types="street_route" order="13">
- <polyline color="#0000a0" width="52"/>
- </itemgra>
- <itemgra item_types="street_route" order="14">
- <polyline color="#0000a0" width="64"/>
- </itemgra>
- <itemgra item_types="street_route" order="15">
- <polyline color="#0000a0" width="68"/>
- </itemgra>
- <itemgra item_types="street_route" order="16">
- <polyline color="#0000a0" width="132"/>
- </itemgra>
- <itemgra item_types="street_route" order="17">
- <polyline color="#0000a0" width="268"/>
- </itemgra>
- <itemgra item_types="street_route" order="18">
- <polyline color="#0000a0" width="530"/>
- </itemgra>
- <!-- highway=service,footway, ,... -->
- <itemgra item_types="street_pedestrian,living_street" order="10">
- <polyline color="#d2d2d2" width="3"/>
- <polyline color="#dddddd" width="1"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="11">
- <polyline color="#d2d2d2" width="5"/>
- <polyline color="#dddddd" width="3"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="12">
- <polyline color="#d2d2d2" width="8"/>
- <polyline color="#dddddd" width="6"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="13">
- <polyline color="#d2d2d2" width="9"/>
- <polyline color="#dddddd" width="7"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="14">
- <polyline color="#d2d2d2" width="13"/>
- <polyline color="#dddddd" width="9"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="15">
- <polyline color="#d2d2d2" width="18"/>
- <polyline color="#dddddd" width="14"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="16">
- <polyline color="#d2d2d2" width="21"/>
- <polyline color="#dddddd" width="17"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="17">
- <polyline color="#d2d2d2" width="25"/>
- <polyline color="#dddddd" width="21"/>
- </itemgra>
- <itemgra item_types="street_pedestrian,living_street" order="18">
- <polyline color="#d2d2d2" width="40"/>
- <polyline color="#dddddd" width="34"/>
- </itemgra>
- <itemgra item_types="street_nopass" order="10">
- <polyline color="#efeaa0" width="1"/>
- </itemgra>
- <itemgra item_types="street_nopass" order="11-12">
- <polyline color="#efeaa0" width="2"/>
- </itemgra>
- <itemgra item_types="street_nopass" order="13-">
- <polyline color="#efeaa0" width="4"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="10">
- <polyline color="#d2d2d2" width="4"/>
- <polyline color="#ffffff" width="2"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="11">
- <polyline color="#d2d2d2" width="6"/>
- <polyline color="#ffffff" width="4"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="12">
- <polyline color="#d2d2d2" width="10"/>
- <polyline color="#ffffff" width="8"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="13">
- <polyline color="#d2d2d2" width="12"/>
- <polyline color="#ffffff" width="9"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="14">
- <polyline color="#d2d2d2" width="15"/>
- <polyline color="#ffffff" width="13"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="15">
- <polyline color="#d2d2d2" width="17"/>
- <polyline color="#ffffff" width="14"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="16">
- <polyline color="#d2d2d2" width="33"/>
- <polyline color="#ffffff" width="26"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="17">
- <polyline color="#d2d2d2" width="69"/>
- <polyline color="#ffffff" width="61"/>
- </itemgra>
- <itemgra item_types="street_0,street_1_city,street_1_land" order="18">
- <polyline color="#d2d2d2" width="132"/>
- <polyline color="#ffffff" width="126"/>
- </itemgra>
- <!-- highway=tertiary -->
- <itemgra item_types="street_2_city,street_2_land" order="7-8">
- <polyline color="#c4c4c4" width="2"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="9">
- <polyline color="#c4c4c4" width="4"/>
- <polyline color="#f7f496" width="2"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="10">
- <polyline color="#c4c4c4" width="6"/>
- <polyline color="#f7f496" width="4"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="11">
- <polyline color="#c4c4c4" width="8"/>
- <polyline color="#f7f496" width="6"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="12">
- <polyline color="#c4c4c4" width="12"/>
- <polyline color="#f7f496" width="9"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="13">
- <polyline color="#c4c4c4" width="15"/>
- <polyline color="#f7f496" width="11"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="14">
- <polyline color="#c4c4c4" width="18"/>
- <polyline color="#f7f496" width="14"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="15">
- <polyline color="#c4c4c4" width="21"/>
- <polyline color="#f7f496" width="17"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="16">
- <polyline color="#c4c4c4" width="35"/>
- <polyline color="#f7f496" width="30"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="17">
- <polyline color="#c4c4c4" width="73"/>
- <polyline color="#f7f496" width="67"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land" order="18">
- <polyline color="#c4c4c4" width="144"/>
- <polyline color="#f7f496" width="138"/>
- </itemgra>
- <!-- highway=secondary -->
- <itemgra item_types="street_3_city,street_3_land,ramp" order="7">
- <polyline color="#fdbf6f" width="1"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="8">
- <polyline color="#000000" width="2"/>
- <polyline color="#fdbf6f" width="1"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="9">
- <polyline color="#000000" width="5"/>
- <polyline color="#fdbf6f" width="3"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="10">
- <polyline color="#000000" width="8"/>
- <polyline color="#fdbf6f" width="6"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="11">
- <polyline color="#000000" width="9"/>
- <polyline color="#fdbf6f" width="7"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="12">
- <polyline color="#000000" width="11"/>
- <polyline color="#fdbf6f" width="9"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="13">
- <polyline color="#000000" width="16"/>
- <polyline color="#fdbf6f" width="14"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="14">
- <polyline color="#000000" width="19"/>
- <polyline color="#fdbf6f" width="17"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="15">
- <polyline color="#000000" width="23"/>
- <polyline color="#fdbf6f" width="21"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="16">
- <polyline color="#000000" width="36"/>
- <polyline color="#fdbf6f" width="34"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="17">
- <polyline color="#000000" width="75"/>
- <polyline color="#fdbf6f" width="73"/>
- </itemgra>
- <itemgra item_types="street_3_city,street_3_land,ramp" order="18">
- <polyline color="#000000" width="152"/>
- <polyline color="#fdbf6f" width="150"/>
- </itemgra>
- <!-- highway=primary -->
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="2-6">
- <polyline color="#e46d71" width="1"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="7-8">
- <polyline color="#e46d71" width="3"/>
- <polyline color="#e46d71" width="1"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="9">
- <polyline color="#e46d71" width="5"/>
- <polyline color="#e46d71" width="3"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="10">
- <polyline color="#e46d71" width="6"/>
- <polyline color="#e46d71" width="4"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="11">
- <polyline color="#e46d71" width="9"/>
- <polyline color="#e46d71" width="7"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="12">
- <polyline color="#e46d71" width="13"/>
- <polyline color="#e46d71" width="9"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="13">
- <polyline color="#e46d71" width="18"/>
- <polyline color="#e46d71" width="14"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="14">
- <polyline color="#e46d71" width="21"/>
- <polyline color="#e46d71" width="17"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="15">
- <polyline color="#e46d71" width="24"/>
- <polyline color="#e46d71" width="20"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="16">
- <polyline color="#e46d71" width="39"/>
- <polyline color="#e46d71" width="33"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="17">
- <polyline color="#e46d71" width="78"/>
- <polyline color="#e46d71" width="72"/>
- </itemgra>
- <itemgra item_types="street_4_city,street_4_land,street_n_lanes" order="18">
- <polyline color="#e46d71" width="156"/>
- <polyline color="#e46d71" width="150"/>
- </itemgra>
- <!-- highway=motorway -->
- <itemgra item_types="highway_city,highway_land" order="2">
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="3-5">
- <polyline color="#87908a" width="3"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="6">
- <polyline color="#87908a" width="4"/>
- <polyline color="#809bc0" width="2"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="7-8">
- <polyline color="#87908a" width="7"/>
- <polyline color="#809bc0" width="5"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="9-10">
- <polyline color="#87908a" width="9"/>
- <polyline color="#809bc0" width="5"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="11">
- <polyline color="#87908a" width="13"/>
- <polyline color="#809bc0" width="9"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="12">
- <polyline color="#87908a" width="15"/>
- <polyline color="#809bc0" width="10"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="13">
- <polyline color="#87908a" width="25"/>
- <polyline color="#809bc0" width="17"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="14">
- <polyline color="#87908a" width="31"/>
- <polyline color="#809bc0" width="24"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="15">
- <polyline color="#87908a" width="33"/>
- <polyline color="#809bc0" width="27"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="16">
- <polyline color="#87908a" width="65"/>
- <polyline color="#809bc0" width="59"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="17">
- <polyline color="#87908a" width="133"/>
- <polyline color="#809bc0" width="127"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_city,highway_land" order="18">
- <polyline color="#87908a" width="264"/>
- <polyline color="#809bc0" width="258"/>
- <polyline color="#809bc0" width="1"/>
- </itemgra>
- <itemgra item_types="highway_exit_label" order="10-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <!-- highway=primary (font)-->
- <itemgra item_types="highway_city,highway_land,street_4_city,street_4_land,street_n_lanes,living_street" order="10-18">
- <text text_size="9"/>
- </itemgra>
- <itemgra item_types="street_2_city,street_2_land,street_3_city,street_3_land,ramp" order="11-18">
- <text text_size="9"/>
- </itemgra>
- <itemgra item_types="street_nopass,street_0,street_1_city,street_1_land,footway" order="12-18">
- <text text_size="9"/>
- </itemgra>
- <!-- place=suburb -->
- <itemgra item_types="town_label,district_label,town_label_0e0,town_label_1e0,town_label_2e0,town_label_5e0,town_label_1e1,town_label_2e1,town_label_5e1,town_label_1e2,town_label_2e2,town_label_5e2,district_label_0e0,district_label_1e0,district_label_2e0,district_label_5e0,district_label_1e1,district_label_2e1,district_label_5e1,district_label_1e2,district_label_2e2,district_label_5e2" order="9-">
- <circle color="#000000" radius="3" text_size="9"/>
- </itemgra>
- <itemgra item_types="district_label_1e3,district_label_2e3,district_label_5e3" order="11-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="town_label_1e3,town_label_2e3,town_label_5e3,place_label" order="10-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="district_label_1e4,district_label_2e4,district_label_5e4" order="9-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="town_label_1e4,town_label_2e4,town_label_5e4" order="8-">
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="district_label_1e5,district_label_2e5,district_label_5e5" order="6-">
- <circle color="#000000" radius="3" text_size="10"/>
- </itemgra>
- <!-- place=city -->
- <itemgra item_types="town_label_1e5,town_label_2e5,town_label_5e5" order="4-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="district_label_1e6,district_label_2e6,district_label_5e6" order="3-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="town_label_1e6,town_label_2e6,town_label_5e6" order="2-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="town_label_1e7,district_label_1e7" order="1-">
- <circle color="#000000" radius="3" text_size="15"/>
- </itemgra>
- <itemgra item_types="rg_point" order="0-">
- <circle color="#FF089C" radius="10"/>
- </itemgra>
-
- <itemgra item_types="waypoint,route_end" order="2">
- <circle color="#008080" radius="4" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="3-5">
- <circle color="#008080" radius="8" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="6">
- <circle color="#008080" radius="10" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="7-8">
- <circle color="#008080" radius="16" width="2" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="9-10">
- <circle color="#008080" radius="20" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="11">
- <circle color="#008080" radius="28" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="12">
- <circle color="#008080" radius="32" width="4" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="13">
- <circle color="#008080" radius="52" width="4" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="14">
- <circle color="#008080" radius="64" width="4" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="15">
- <circle color="#008080" radius="68" width="6" text_size="24"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="16">
- <circle color="#008080" radius="132" width="8" text_size="32"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="17">
- <circle color="#008080" radius="268" width="8" text_size="48"/>
- </itemgra>
- <itemgra item_types="waypoint,route_end" order="18">
- <circle color="#008080" radius="530" width="8" text_size="48"/>
- </itemgra>
-
- <!-- !!!!...POIs...!!!! -->
- <!-- amenity=bank -->
- <itemgra item_types="poi_bank" order="14-">
- <icon src="bank.png"/>
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <itemgra item_types="poi_atm" order="12-">
- <icon src="atm.png"/>
- </itemgra>
- <!-- amenity=fuel -->
- <itemgra item_types="poi_fuel" order="14-">
- <icon src="fuel.png"/>
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <!-- amenity=hospitalg -->
- <itemgra item_types="poi_hospital" order="14-">
- <icon src="hospital.png"/>
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <!-- amenity=parking -->
- <itemgra item_types="poi_car_parking" order="14-">
- <icon src="parking.png"/>
- </itemgra>
- <!-- amenity=police -->
- <itemgra item_types="poi_police" order="14-">
- <icon src="police.png"/>
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <!-- amenity=restaurant -->
- <itemgra item_types="poi_restaurant" order="14-">
- <icon src="restaurant.png"/>
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <!-- leisure=golf_curse -->
- <itemgra item_types="poi_golf" order="14-">
- <icon src="golf.png"/>
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- <!-- tourism=hotel -->
- <itemgra item_types="poi_hotel" order="14-">
- <icon src="hotel.png"/>
- <circle color="#000000" radius="3" text_size="7"/>
- </itemgra>
- </layer>
- <layer name="Found items" ref="Found items"/>
- </layout>
+ <!--
+ Layouts are defined in their own specific XML files and are included below (one file per layout, all files matching the wildcard expression below will be used)
+ The layout files describe the appearance of maps on the screen (colors, width, text fonts and sizes for each type of element to draw)
+ One layout is a specifid theme. At runtime, the user can select only one layout at a time (by choosing the corresponding theme from its name tag defined in the layout XML file).
+ If two layouts with the same name are included, the first one takes precedence.
+ In the list below, we use the user-defined layouts first (in $NAVIT_USER_DATADIR), they take precedence. Being next in the list, the default layouts (in $NAVIT_SHAREDIR) will only be used if there is no user-defined layout that was already defined with the same name.
+ -->
+ <xi:include href="$NAVIT_USER_DATADIR/navit_layout_*.xml"/>
+ <xi:include href="$NAVIT_SHAREDIR/navit_layout_*.xml"/>
<layout name="Route">
<layer name="streets">
<itemgra item_types="street_route_occluded" order="0-">
diff --git a/navit/osd.c b/navit/osd.c
index a0c9183d1..8b548b044 100644
--- a/navit/osd.c
+++ b/navit/osd.c
@@ -32,143 +32,126 @@
struct osd {
- NAVIT_OBJECT
- struct osd_methods meth;
- struct osd_priv *priv;
+ NAVIT_OBJECT
+ struct osd_methods meth;
+ struct osd_priv *priv;
};
-int
-osd_set_methods(struct osd_methods *in, int in_size, struct osd_methods *out)
-{
- return navit_object_set_methods(in, in_size, out, sizeof(struct osd_methods));
+int osd_set_methods(struct osd_methods *in, int in_size, struct osd_methods *out) {
+ return navit_object_set_methods(in, in_size, out, sizeof(struct osd_methods));
}
struct osd *
-osd_new(struct attr *parent, struct attr **attrs)
-{
- struct osd *o;
- struct osd_priv *(*new)(struct navit *nav, struct osd_methods *meth, struct attr **attrs);
- struct attr *type=attr_search(attrs, NULL, attr_type),cbl;
-
- if (! type)
- return NULL;
- new=plugin_get_category_osd(type->u.str);
- if (! new) {
- dbg(lvl_error, "invalid OSD type '%s'\n", type->u.str);
- return NULL;
- }
- o=g_new0(struct osd, 1);
- o->attrs=attr_list_dup(attrs);
- cbl.type=attr_callback_list;
- cbl.u.callback_list=callback_list_new();
- o->attrs=attr_generic_prepend_attr(o->attrs, &cbl);
-
- o->priv=new(parent->u.navit, &o->meth, o->attrs);
- if (o->priv) {
- o->func=&osd_func;
- navit_object_ref((struct navit_object *)o);
- } else {
- attr_list_free(o->attrs);
- g_free(o);
- o=NULL;
- }
- dbg(lvl_debug,"new osd %p\n",o);
- return o;
+osd_new(struct attr *parent, struct attr **attrs) {
+ struct osd *o;
+ struct osd_priv *(*new)(struct navit *nav, struct osd_methods *meth, struct attr **attrs);
+ struct attr *type=attr_search(attrs, NULL, attr_type),cbl;
+
+ if (! type)
+ return NULL;
+ new=plugin_get_category_osd(type->u.str);
+ if (! new) {
+ dbg(lvl_error, "invalid OSD type '%s'", type->u.str);
+ return NULL;
+ }
+ o=g_new0(struct osd, 1);
+ o->attrs=attr_list_dup(attrs);
+ cbl.type=attr_callback_list;
+ cbl.u.callback_list=callback_list_new();
+ o->attrs=attr_generic_prepend_attr(o->attrs, &cbl);
+
+ o->priv=new(parent->u.navit, &o->meth, o->attrs);
+ if (o->priv) {
+ o->func=&osd_func;
+ navit_object_ref((struct navit_object *)o);
+ } else {
+ attr_list_free(o->attrs);
+ g_free(o);
+ o=NULL;
+ }
+ dbg(lvl_debug,"new osd %p",o);
+ return o;
}
-int
-osd_get_attr(struct osd *osd, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- int ret=0;
- if(osd && osd->meth.get_attr)
- /* values for ret: -1: Not possible, 0: Ignored by driver, 1 valid */
- ret=osd->meth.get_attr(osd->priv, type, attr);
- if (ret == -1)
- return 0;
- if (ret > 0)
- return 1;
- return navit_object_get_attr((struct navit_object *)osd, type, attr, iter);
+int osd_get_attr(struct osd *osd, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ int ret=0;
+ if(osd && osd->meth.get_attr)
+ /* values for ret: -1: Not possible, 0: Ignored by driver, 1 valid */
+ ret=osd->meth.get_attr(osd->priv, type, attr);
+ if (ret == -1)
+ return 0;
+ if (ret > 0)
+ return 1;
+ return navit_object_get_attr((struct navit_object *)osd, type, attr, iter);
}
-int
-osd_set_attr(struct osd *osd, struct attr* attr)
-{
- int ret=0;
- if(osd && osd->meth.set_attr)
- /* values for ret: -1: Not possible, 0: Ignored by driver, 1 set and store, 2 set, don't store */
- ret=osd->meth.set_attr(osd->priv, attr);
- if (ret == -1)
- return 0;
- if (ret == 2)
- return 1;
- return navit_object_set_attr((struct navit_object *)osd, attr);
+int osd_set_attr(struct osd *osd, struct attr* attr) {
+ int ret=0;
+ if(osd && osd->meth.set_attr)
+ /* values for ret: -1: Not possible, 0: Ignored by driver, 1 set and store, 2 set, don't store */
+ ret=osd->meth.set_attr(osd->priv, attr);
+ if (ret == -1)
+ return 0;
+ if (ret == 2)
+ return 1;
+ return navit_object_set_attr((struct navit_object *)osd, attr);
}
-static void
-osd_destroy(struct osd *osd)
-{
- if (!osd)
- return;
- if (osd->meth.destroy)
- osd->meth.destroy(osd->priv);
- attr_list_free(osd->attrs);
- g_free(osd);
+static void osd_destroy(struct osd *osd) {
+ if (!osd)
+ return;
+ if (osd->meth.destroy)
+ osd->meth.destroy(osd->priv);
+ attr_list_free(osd->attrs);
+ g_free(osd);
}
-void
-osd_wrap_point(struct point *p, struct navit *nav)
-{
- if (p->x < 0)
- p->x += navit_get_width(nav);
- if (p->y < 0)
- p->y += navit_get_height(nav);
+void osd_wrap_point(struct point *p, struct navit *nav) {
+ if (p->x < 0)
+ p->x += navit_get_width(nav);
+ if (p->y < 0)
+ p->y += navit_get_height(nav);
}
-static void
-osd_evaluate_command(struct osd_item *this, struct navit *nav)
-{
- struct attr navit;
- navit.type=attr_navit;
- navit.u.navit=nav;
- dbg(lvl_debug, "calling command '%s'\n", this->command);
- command_evaluate(&navit, this->command);
+static void osd_evaluate_command(struct osd_item *this, struct navit *nav) {
+ struct attr navit;
+ navit.type=attr_navit;
+ navit.u.navit=nav;
+ dbg(lvl_debug, "calling command '%s'", this->command);
+ command_evaluate(&navit, this->command);
}
-void
-osd_std_click(struct osd_item *this, struct navit *nav, int pressed, int button, struct point *p)
-{
- int click_is_outside_item;
- struct point bp = this->p;
- if (!this->command || !this->command[0])
- return;
- osd_wrap_point(&bp, nav);
- click_is_outside_item = p->x < bp.x || p->y < bp.y || p->x > bp.x + this->w || p->y > bp.y + this->h;
- if ((click_is_outside_item || !this->configured) && !this->pressed)
- return;
- if (button != 1)
- return;
- if (!!pressed == !!this->pressed)
- return;
- if (navit_ignore_button(nav))
- return;
- this->pressed = pressed;
- if (pressed && this->command)
- osd_evaluate_command(this, nav);
+void osd_std_click(struct osd_item *this, struct navit *nav, int pressed, int button, struct point *p) {
+ int click_is_outside_item;
+ struct point bp = this->p;
+ if (!this->command || !this->command[0])
+ return;
+ osd_wrap_point(&bp, nav);
+ click_is_outside_item = p->x < bp.x || p->y < bp.y || p->x > bp.x + this->w || p->y > bp.y + this->h;
+ if ((click_is_outside_item || !this->configured) && !this->pressed)
+ return;
+ if (button != 1)
+ return;
+ if (!!pressed == !!this->pressed)
+ return;
+ if (navit_ignore_button(nav))
+ return;
+ this->pressed = pressed;
+ if (pressed && this->command)
+ osd_evaluate_command(this, nav);
}
-void
-osd_std_resize(struct osd_item *item)
-{
- graphics_overlay_resize(item->gr, &item->p, item->w, item->h, 1);
+void osd_std_resize(struct osd_item *item) {
+ graphics_overlay_resize(item->gr, &item->p, item->w, item->h, 1);
}
-
+
/**
* @brief Calculates the size and position of an OSD item.
*
* If the geometry of the OSD item is specified relative to screen dimensions,
* this function will set its absolute dimensions accordingly. If relative width
- * or relative height is set to 0% (int value is equal to ATTR_REL_RELSHIFT),
+ * or relative height is set to 0% (int value is equal to ATTR_REL_RELSHIFT),
* object width (height) is not changed here, for button and image osds it means
* to derive values from the underlying image.
*
@@ -184,45 +167,43 @@ osd_std_resize(struct osd_item *item)
* @param w Available screen width in pixels
* @param h Available screen height in pixels
*/
-void
-osd_std_calculate_sizes(struct osd_item *item, int w, int h)
-{
- struct padding *padding = NULL;
-
- if (item->gr) {
- padding = graphics_get_data(item->gr, "padding");
- if (padding) {
- dbg(lvl_debug, "Got padding=%p for item=%p (item->gr=%p): left=%d top=%d right=%d bottom=%d\n",
- padding, item, item->gr, padding->left, padding->top, padding->right, padding->bottom);
- } else {
- dbg(lvl_debug, "Got padding=%p for item=%p (item->gr=%p)\n",
- padding, item, item->gr);
- }
- } else
- dbg(lvl_warning, "cannot get padding for item=%p: item->gr is NULL\n", item);
-
- /* reduce w and h by total padding in the respective dimension */
- if (padding) {
- w -= (padding->left + padding->right);
- h -= (padding->top + padding->bottom);
- }
-
- if(item->rel_w!=ATTR_REL_RELSHIFT)
- item->w=attr_rel2real(item->rel_w, w, 1);
- if(item->w<0)
- item->w=0;
- if(item->rel_h!=ATTR_REL_RELSHIFT)
- item->h=attr_rel2real(item->rel_h, h, 1);
- if(item->h<0)
- item->h=0;
- item->p.x=attr_rel2real(item->rel_x, w, 1);
- item->p.y=attr_rel2real(item->rel_y, h, 1);
-
- /* add left and top padding to item->p */
- if (padding) {
- item->p.x += padding->left;
- item->p.y += padding->top;
- }
+void osd_std_calculate_sizes(struct osd_item *item, int w, int h) {
+ struct padding *padding = NULL;
+
+ if (item->gr) {
+ padding = graphics_get_data(item->gr, "padding");
+ if (padding) {
+ dbg(lvl_debug, "Got padding=%p for item=%p (item->gr=%p): left=%d top=%d right=%d bottom=%d",
+ padding, item, item->gr, padding->left, padding->top, padding->right, padding->bottom);
+ } else {
+ dbg(lvl_debug, "Got padding=%p for item=%p (item->gr=%p)",
+ padding, item, item->gr);
+ }
+ } else
+ dbg(lvl_warning, "cannot get padding for item=%p: item->gr is NULL", item);
+
+ /* reduce w and h by total padding in the respective dimension */
+ if (padding) {
+ w -= (padding->left + padding->right);
+ h -= (padding->top + padding->bottom);
+ }
+
+ if(item->rel_w!=ATTR_REL_RELSHIFT)
+ item->w=attr_rel2real(item->rel_w, w, 1);
+ if(item->w<0)
+ item->w=0;
+ if(item->rel_h!=ATTR_REL_RELSHIFT)
+ item->h=attr_rel2real(item->rel_h, h, 1);
+ if(item->h<0)
+ item->h=0;
+ item->p.x=attr_rel2real(item->rel_x, w, 1);
+ item->p.y=attr_rel2real(item->rel_y, h, 1);
+
+ /* add left and top padding to item->p */
+ if (padding) {
+ item->p.x += padding->left;
+ item->p.y += padding->top;
+ }
}
/**
@@ -238,38 +219,34 @@ osd_std_calculate_sizes(struct osd_item *item, int w, int h)
* @param h Available screen height in pixels (the height that corresponds to
* 100%)
*/
-static void
-osd_std_calculate_sizes_and_redraw(struct osd_item *item, struct osd_priv *priv, int w, int h)
-{
- struct attr vehicle_attr;
-
- osd_std_calculate_sizes(item, w, h);
-
- osd_std_resize(item);
- item->do_draw=1;
- if (item->meth.draw) {
- if (navit_get_attr(item->navit, attr_vehicle, &vehicle_attr, NULL)) {
- item->meth.draw(priv, item->navit, vehicle_attr.u.vehicle);
- item->do_draw=0;
- }
- }
+static void osd_std_calculate_sizes_and_redraw(struct osd_item *item, struct osd_priv *priv, int w, int h) {
+ struct attr vehicle_attr;
+
+ osd_std_calculate_sizes(item, w, h);
+
+ osd_std_resize(item);
+ item->do_draw=1;
+ if (item->meth.draw) {
+ if (navit_get_attr(item->navit, attr_vehicle, &vehicle_attr, NULL)) {
+ item->meth.draw(priv, item->navit, vehicle_attr.u.vehicle);
+ item->do_draw=0;
+ }
+ }
}
-static void
-osd_std_keypress(struct osd_item *item, struct navit *nav, char *key)
-{
+static void osd_std_keypress(struct osd_item *item, struct navit *nav, char *key) {
#if 0
- int i;
- dbg(lvl_debug,"key=%s\n",key);
- for (i = 0 ; i < strlen(key) ; i++) {
- dbg(lvl_debug,"key:0x%02x\n",key[i]);
- }
- for (i = 0 ; i < strlen(item->accesskey) ; i++) {
- dbg(lvl_debug,"accesskey:0x%02x\n",item->accesskey[i]);
- }
+ int i;
+ dbg(lvl_debug,"key=%s",key);
+ for (i = 0 ; i < strlen(key) ; i++) {
+ dbg(lvl_debug,"key:0x%02x",key[i]);
+ }
+ for (i = 0 ; i < strlen(item->accesskey) ; i++) {
+ dbg(lvl_debug,"accesskey:0x%02x",item->accesskey[i]);
+ }
#endif
- if ( ! graphics_is_disabled(item->gr) && item->accesskey && key && !strcmp(key, item->accesskey))
- osd_evaluate_command(item, nav);
+ if ( ! graphics_is_disabled(item->gr) && item->accesskey && key && !strcmp(key, item->accesskey))
+ osd_evaluate_command(item, nav);
}
/**
@@ -284,148 +261,139 @@ osd_std_keypress(struct osd_item *item, struct navit *nav, char *key)
* @param item The OSD item to reconfigure
* @param cs The command to evaluate
*/
-static void
-osd_std_reconfigure(struct osd_item *item, struct command_saved *cs)
-{
- char *err = NULL; /* Error description */
-
- dbg(lvl_debug, "enter, item=%p, cs=%p\n", item, cs);
- if (!command_saved_error(cs)) {
- item->configured = !! command_saved_get_int(cs);
- if (item->gr && !(item->flags & 16))
- graphics_overlay_disable(item->gr, !item->configured);
- } else {
- err = command_error_to_text(command_saved_error(cs));
- dbg(lvl_error, "Error in saved command: %s, cs=%p.\n", err, cs);
- g_free(err);
- }
+static void osd_std_reconfigure(struct osd_item *item, struct command_saved *cs) {
+ char *err = NULL; /* Error description */
+
+ dbg(lvl_debug, "enter, item=%p, cs=%p", item, cs);
+ if (!command_saved_error(cs)) {
+ item->configured = !! command_saved_get_int(cs);
+ if (item->gr && !(item->flags & DISABLE_OVERLAY))
+ graphics_overlay_disable(item->gr, !item->configured);
+ } else {
+ err = command_error_to_text(command_saved_error(cs));
+ dbg(lvl_error, "Error in saved command: %s, cs=%p.", err, cs);
+ g_free(err);
+ }
}
-void
-osd_set_std_attr(struct attr **attrs, struct osd_item *item, int flags)
-{
- struct attr *attr;
-
- item->flags=flags;
- item->osd_configuration=-1;
- item->color_fg.r = 0xffff;
- item->color_fg.g = 0xffff;
- item->color_fg.b = 0xffff;
- item->color_fg.a = 0xffff;
- item->text_color.r = 0xffff;
- item->text_color.g = 0xffff;
- item->text_color.b = 0xffff;
- item->text_color.a = 0xffff;
- if (flags & 1) {
- item->color_bg.r = 0x0808;
- item->color_bg.g = 0x0808;
- item->color_bg.b = 0xf8f8;
- item->color_bg.a = 0x0000;
- } else {
- item->color_bg.r = 0x0;
- item->color_bg.g = 0x0;
- item->color_bg.b = 0x0;
- item->color_bg.a = 0x5fff;
- }
-
- attr=attr_search(attrs, NULL, attr_osd_configuration);
- if (attr)
- item->osd_configuration = attr->u.num;
-
- attr=attr_search(attrs, NULL, attr_enable_expression);
- if (attr) {
- item->enable_cs = command_saved_new(attr->u.str, item->navit, NULL, 0);
- }
-
- attr = attr_search(attrs, NULL, attr_w);
- if (attr) {
- item->rel_w = attr->u.num;
- }
-
- attr = attr_search(attrs, NULL, attr_h);
- if (attr) {
- item->rel_h = attr->u.num;
- }
-
- attr = attr_search(attrs, NULL, attr_x);
- if (attr) {
- item->rel_x = attr->u.num;
- }
-
- attr = attr_search(attrs, NULL, attr_y);
- if (attr) {
- item->rel_y = attr->u.num;
- }
-
- attr = attr_search(attrs, NULL, attr_font_size);
- if (attr)
- item->font_size = attr->u.num;
-
- attr=attr_search(attrs, NULL, attr_background_color);
- if (attr)
- item->color_bg=*attr->u.color;
- attr = attr_search(attrs, NULL, attr_command);
- if (attr)
- item->command = g_strdup(attr->u.str);
- attr=attr_search(attrs, NULL, attr_text_color);
- if (attr)
- item->text_color=*attr->u.color;
- attr=attr_search(attrs, NULL, attr_foreground_color);
- if (attr)
- item->color_fg=*attr->u.color;
- attr=attr_search(attrs, NULL, attr_accesskey);
- if (attr)
- item->accesskey = g_strdup(attr->u.str);
- attr=attr_search(attrs, NULL, attr_font);
- if (attr)
- item->font_name = g_strdup(attr->u.str);
+void osd_set_std_attr(struct attr **attrs, struct osd_item *item, int flags) {
+ struct attr *attr;
+ item->flags=flags;
+ item->osd_configuration=-1;
+ item->color_fg.r = 0xffff;
+ item->color_fg.g = 0xffff;
+ item->color_fg.b = 0xffff;
+ item->color_fg.a = 0xffff;
+ item->text_color.r = 0xffff;
+ item->text_color.g = 0xffff;
+ item->text_color.b = 0xffff;
+ item->text_color.a = 0xffff;
+
+ if (flags & TRANSPARENT_BG) {
+ item->color_bg.r = 0x0808;
+ item->color_bg.g = 0x0808;
+ item->color_bg.b = 0xf8f8;
+ item->color_bg.a = 0x0000;
+ } else {
+ item->color_bg.r = 0x0;
+ item->color_bg.g = 0x0;
+ item->color_bg.b = 0x0;
+ item->color_bg.a = 0x9fff;
+ }
+
+ attr=attr_search(attrs, NULL, attr_osd_configuration);
+ if (attr)
+ item->osd_configuration = attr->u.num;
+
+ attr=attr_search(attrs, NULL, attr_enable_expression);
+ if (attr) {
+ item->enable_cs = command_saved_new(attr->u.str, item->navit, NULL, 0);
+ }
+
+ attr = attr_search(attrs, NULL, attr_w);
+ if (attr) {
+ item->rel_w = attr->u.num;
+ }
+
+ attr = attr_search(attrs, NULL, attr_h);
+ if (attr) {
+ item->rel_h = attr->u.num;
+ }
+
+ attr = attr_search(attrs, NULL, attr_x);
+ if (attr) {
+ item->rel_x = attr->u.num;
+ }
+
+ attr = attr_search(attrs, NULL, attr_y);
+ if (attr) {
+ item->rel_y = attr->u.num;
+ }
+
+ attr = attr_search(attrs, NULL, attr_font_size);
+ if (attr)
+ item->font_size = attr->u.num;
+
+ attr=attr_search(attrs, NULL, attr_background_color);
+ if (attr)
+ item->color_bg=*attr->u.color;
+ attr = attr_search(attrs, NULL, attr_command);
+ if (attr)
+ item->command = g_strdup(attr->u.str);
+ attr=attr_search(attrs, NULL, attr_text_color);
+ if (attr)
+ item->text_color=*attr->u.color;
+ attr=attr_search(attrs, NULL, attr_foreground_color);
+ if (attr)
+ item->color_fg=*attr->u.color;
+ attr=attr_search(attrs, NULL, attr_accesskey);
+ if (attr)
+ item->accesskey = g_strdup(attr->u.str);
+ attr=attr_search(attrs, NULL, attr_font);
+ if (attr)
+ item->font_name = g_strdup(attr->u.str);
}
-void
-osd_std_config(struct osd_item *item, struct navit *navit)
-{
- struct attr attr;
- char *err = NULL; /* Error description */
-
- dbg(lvl_debug, "enter, item=%p, enable_cs=%p\n", item, item->enable_cs);
- if (item->enable_cs) {
- item->reconfig_cb = callback_new_1(callback_cast(osd_std_reconfigure), item);
- command_saved_set_cb(item->enable_cs, item->reconfig_cb);
-
- if (!command_saved_error(item->enable_cs)) {
- item->configured = !! command_saved_get_int(item->enable_cs);
- } else {
- err = command_error_to_text(command_saved_error(item->enable_cs));
- dbg(lvl_error, "Error in saved command: %s, item=%p.\n", err, item);
- g_free(err);
- }
- } else {
- if (!navit_get_attr(navit, attr_osd_configuration, &attr, NULL))
- attr.u.num=-1;
- item->configured = !!(attr.u.num & item->osd_configuration);
- }
- if (item->gr && !(item->flags & 16))
- graphics_overlay_disable(item->gr, !item->configured);
+void osd_std_config(struct osd_item *item, struct navit *navit) {
+ struct attr attr;
+ char *err = NULL; /* Error description */
+
+ dbg(lvl_debug, "enter, item=%p, enable_cs=%p", item, item->enable_cs);
+ if (item->enable_cs) {
+ item->reconfig_cb = callback_new_1(callback_cast(osd_std_reconfigure), item);
+ command_saved_set_cb(item->enable_cs, item->reconfig_cb);
+
+ if (!command_saved_error(item->enable_cs)) {
+ item->configured = !! command_saved_get_int(item->enable_cs);
+ } else {
+ err = command_error_to_text(command_saved_error(item->enable_cs));
+ dbg(lvl_error, "Error in saved command: %s, item=%p.", err, item);
+ g_free(err);
+ }
+ } else {
+ if (!navit_get_attr(navit, attr_osd_configuration, &attr, NULL))
+ attr.u.num=-1;
+ item->configured = !!(attr.u.num & item->osd_configuration);
+ }
+
+ if (item->gr && !(item->flags & DISABLE_OVERLAY))
+ graphics_overlay_disable(item->gr, !item->configured);
}
-void
-osd_set_std_config(struct navit *nav, struct osd_item *item)
-{
- dbg(lvl_debug, "enter, item=%p\n", item);
- item->cb = callback_new_attr_2(callback_cast(osd_std_config), attr_osd_configuration, item, nav);
- navit_add_callback(nav, item->cb);
- osd_std_config(item, nav);
+void osd_set_std_config(struct navit *nav, struct osd_item *item) {
+ dbg(lvl_debug, "enter, item=%p", item);
+ item->cb = callback_new_attr_2(callback_cast(osd_std_config), attr_osd_configuration, item, nav);
+ navit_add_callback(nav, item->cb);
+ osd_std_config(item, nav);
}
-void
-osd_set_keypress(struct navit *nav, struct osd_item *item)
-{
- struct graphics *navit_gr = navit_get_graphics(nav);
- dbg(lvl_info,"accesskey %s\n",item->accesskey);
- if (item->accesskey) {
- item->keypress_cb=callback_new_attr_2(callback_cast(osd_std_keypress), attr_keypress, item, nav);
- graphics_add_callback(navit_gr, item->keypress_cb);
- }
+void osd_set_keypress(struct navit *nav, struct osd_item *item) {
+ struct graphics *navit_gr = navit_get_graphics(nav);
+ dbg(lvl_info,"accesskey %s",item->accesskey);
+ if (item->accesskey) {
+ item->keypress_cb=callback_new_attr_2(callback_cast(osd_std_keypress), attr_keypress, item, nav);
+ graphics_add_callback(navit_gr, item->keypress_cb);
+ }
}
/**
@@ -438,78 +406,74 @@ osd_set_keypress(struct navit *nav, struct osd_item *item)
* @param item The OSD item
* @param priv The `struct osd_priv` for the OSD item
*/
-void
-osd_set_std_graphic(struct navit *nav, struct osd_item *item, struct osd_priv *priv)
-{
- struct graphics *navit_gr;
- int w, h;
- struct padding *padding = NULL;
-
- navit_gr = navit_get_graphics(nav);
- w = navit_get_width(nav);
- h = navit_get_height(nav);
-
- padding = graphics_get_data(navit_gr, "padding");
-
- if (padding) {
- dbg(lvl_debug, "Got padding=%p for item=%p: left=%d top=%d right=%d bottom=%d\n",
- padding, item, padding->left, padding->top, padding->right, padding->bottom);
- w -= (padding->left + padding->right);
- h -= (padding->top + padding->bottom);
- } else
- dbg(lvl_debug, "Padding is NULL\n");
-
- osd_std_calculate_sizes(item, w, h);
-
- if (padding) {
- item->p.x += padding->left;
- item->p.y += padding->top;
- }
-
- item->gr = graphics_overlay_new(navit_gr, &item->p, item->w, item->h, 1);
-
- item->graphic_bg = graphics_gc_new(item->gr);
- graphics_gc_set_foreground(item->graphic_bg, &item->color_bg);
- graphics_background_gc(item->gr, item->graphic_bg);
-
- item->graphic_fg = graphics_gc_new(item->gr);
- graphics_gc_set_foreground(item->graphic_fg, &item->color_fg);
-
- if (item->flags & 2) {
- item->font = graphics_named_font_new(item->gr, item->font_name, item->font_size, 1);
- item->graphic_fg_text = graphics_gc_new(item->gr);
- graphics_gc_set_foreground(item->graphic_fg_text, &item->text_color);
- }
-
- osd_set_std_config(nav, item);
-
- item->resize_cb = callback_new_attr_2(callback_cast(osd_std_calculate_sizes_and_redraw), attr_resize, item, priv);
- graphics_add_callback(navit_gr, item->resize_cb);
- osd_set_keypress(nav, item);
+void osd_set_std_graphic(struct navit *nav, struct osd_item *item, struct osd_priv *priv) {
+ struct graphics *navit_gr;
+ int w, h;
+ struct padding *padding = NULL;
+
+ navit_gr = navit_get_graphics(nav);
+ w = navit_get_width(nav);
+ h = navit_get_height(nav);
+
+ padding = graphics_get_data(navit_gr, "padding");
+
+ if (padding) {
+ dbg(lvl_debug, "Got padding=%p for item=%p: left=%d top=%d right=%d bottom=%d",
+ padding, item, padding->left, padding->top, padding->right, padding->bottom);
+ w -= (padding->left + padding->right);
+ h -= (padding->top + padding->bottom);
+ } else
+ dbg(lvl_debug, "Padding is NULL");
+
+ osd_std_calculate_sizes(item, w, h);
+
+ if (padding) {
+ item->p.x += padding->left;
+ item->p.y += padding->top;
+ }
+
+ item->gr = graphics_overlay_new(navit_gr, &item->p, item->w, item->h, 1);
+
+ item->graphic_bg = graphics_gc_new(item->gr);
+ graphics_gc_set_foreground(item->graphic_bg, &item->color_bg);
+ graphics_background_gc(item->gr, item->graphic_bg);
+
+ item->graphic_fg = graphics_gc_new(item->gr);
+ graphics_gc_set_foreground(item->graphic_fg, &item->color_fg);
+
+ if (item->flags & ITEM_HAS_TEXT) {
+ item->font = graphics_named_font_new(item->gr, item->font_name, item->font_size, 1);
+ item->graphic_fg_text = graphics_gc_new(item->gr);
+ graphics_gc_set_foreground(item->graphic_fg_text, &item->text_color);
+ }
+
+ osd_set_std_config(nav, item);
+
+ item->resize_cb = callback_new_attr_2(callback_cast(osd_std_calculate_sizes_and_redraw), attr_resize, item, priv);
+ graphics_add_callback(navit_gr, item->resize_cb);
+ osd_set_keypress(nav, item);
}
-void
-osd_fill_with_bgcolor(struct osd_item *item)
-{
- struct point p[1];
- graphics_draw_mode(item->gr, draw_mode_begin);
- p[0].x=0;
- p[0].y=0;
- graphics_draw_rectangle(item->gr, item->graphic_bg, p, item->w, item->h);
+void osd_fill_with_bgcolor(struct osd_item *item) {
+ struct point p[1];
+ graphics_draw_mode(item->gr, draw_mode_begin);
+ p[0].x=0;
+ p[0].y=0;
+ graphics_draw_rectangle(item->gr, item->graphic_bg, p, item->w, item->h);
}
struct object_func osd_func = {
- attr_osd,
- (object_func_new)osd_new,
- (object_func_get_attr)osd_get_attr,
- (object_func_iter_new)navit_object_attr_iter_new,
- (object_func_iter_destroy)navit_object_attr_iter_destroy,
- (object_func_set_attr)osd_set_attr,
- (object_func_add_attr)navit_object_add_attr,
- (object_func_remove_attr)navit_object_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)osd_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_osd,
+ (object_func_new)osd_new,
+ (object_func_get_attr)osd_get_attr,
+ (object_func_iter_new)navit_object_attr_iter_new,
+ (object_func_iter_destroy)navit_object_attr_iter_destroy,
+ (object_func_set_attr)osd_set_attr,
+ (object_func_add_attr)navit_object_add_attr,
+ (object_func_remove_attr)navit_object_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)osd_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/osd.h b/navit/osd.h
index 38fa0e5ff..8694bcd05 100644
--- a/navit/osd.h
+++ b/navit/osd.h
@@ -23,6 +23,10 @@
struct osd_priv;
struct attr;
+#define TRANSPARENT_BG 1
+#define ITEM_HAS_TEXT 2
+#define DISABLE_OVERLAY 4
+
struct osd_methods {
void (*osd_destroy)(struct osd_priv *osd);
int (*set_attr)(struct osd_priv *osd, struct attr* attr);
diff --git a/navit/osd/core/osd_core.c b/navit/osd/core/osd_core.c
index d336d36f6..e1329ffe2 100644
--- a/navit/osd/core/osd_core.c
+++ b/navit/osd/core/osd_core.c
@@ -64,26 +64,26 @@
#endif
#ifdef _MSC_VER
-static double round(double x)
-{
- if (x >= 0.0)
- return floor(x + 0.5);
- else
- return ceil(x - 0.5);
+static double round(double x) {
+ if (x >= 0.0)
+ return floor(x + 0.5);
+ else
+ return ceil(x - 0.5);
}
#endif /* MSC_VER */
struct osd_priv_common {
- struct osd_item osd_item;
- struct osd_priv *data;
- int (*spec_set_attr_func)(struct osd_priv_common *opc, struct attr* attr);
+ struct osd_item osd_item;
+ struct osd_priv *data;
+ int (*spec_set_attr_func)(struct osd_priv_common *opc, struct attr* attr);
};
struct odometer;
int set_std_osd_attr(struct osd_priv *priv, struct attr*the_attr);
static void osd_odometer_reset(struct osd_priv_common *opc, int flags);
-static void osd_cmd_odometer_reset(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid);
+static void osd_cmd_odometer_reset(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid);
static void osd_odometer_draw(struct osd_priv_common *opc, struct navit *nav, struct vehicle *v);
static struct osd_text_item * oti_new(struct osd_text_item * parent);
int osd_button_set_attr(struct osd_priv_common *opc, struct attr* attr);
@@ -92,50 +92,147 @@ static int b_commandtable_added = 0;
struct compass {
- int width;
- struct graphics_gc *green;
- struct callback *click_cb;
+ int width; /*!< Width of the compass in pixels */
+ struct color destination_dir_color; /*!< Color definition of the destination direction arrow */
+ struct color north_color; /*!< Color definition of north handle of the compass */
+ struct graphics_gc *destination_dir_gc; /*!< graphics_gc context used to draw the destination direction arrow */
+ struct graphics_gc *north_gc; /*!< graphics_gc context used to draw the north handle of the compass */
+ struct callback *click_cb; /*!< A callback to execute when clicking on the compass */
};
-static void
-transform_rotate(struct point *center, int angle, struct point *p,
- int count)
-{
- int i, x, y;
- double dx, dy;
- for (i = 0; i < count; i++) {
- dx = sin(M_PI * angle / 180.0);
- dy = cos(M_PI * angle / 180.0);
- x = dy * p->x - dx * p->y;
- y = dx * p->x + dy * p->y;
-
- p->x = center->x + x;
- p->y = center->y + y;
- p++;
- }
-}
-
-static void
-handle(struct graphics *gr, struct graphics_gc *gc, struct point *p, int r,
- int dir)
-{
- struct point ph[3];
- int l = r * 0.4;
-
- ph[0].x = 0;
- ph[0].y = r;
- ph[1].x = 0;
- ph[1].y = -r;
- transform_rotate(p, dir, ph, 2);
- graphics_draw_lines(gr, gc, ph, 2);
- ph[0].x = -l;
- ph[0].y = -r + l;
- ph[1].x = 0;
- ph[1].y = -r;
- ph[2].x = l;
- ph[2].y = -r + l;
- transform_rotate(p, dir, ph, 3);
- graphics_draw_lines(gr, gc, ph, 3);
+/**
+ * @brief Rotate a group of points around a @p center
+ * @param center The coordinates of the center of the rotation to apply
+ * @param angle The angle of the rotation
+ * @param[in,out] p An array of points to rotate
+ * @param count The number of points stored inside @p p
+ */
+static void transform_rotate(struct point *center, int angle, struct point *p,
+ int count) {
+ int i, x, y;
+ double dx, dy;
+ for (i = 0; i < count; i++) {
+ dx = sin(M_PI * angle / 180.0);
+ dy = cos(M_PI * angle / 180.0);
+ x = dy * p->x - dx * p->y;
+ y = dx * p->x + dy * p->y;
+
+ p->x = center->x + x;
+ p->y = center->y + y;
+ p++;
+ }
+}
+
+/**
+ * @brief Move a group of points in a direction (adding @p dx and @p dy to their x and y coordinates)
+ * @param dx The shift to perform to the x axis
+ * @param dy The shift to perform to the y axis
+ * @param[in,out] p An array of points to move
+ * @param count The number of points stored inside @p p
+ */
+static void transform_move(int dx, int dy, struct point *p,
+ int count) {
+ int i;
+ for (i = 0; i < count; i++) {
+ p->x += dx;
+ p->y += dy;
+ p++;
+ }
+}
+
+/**
+ * @brief Draw a compass handle of length @p r, centered at point @p p, pointing to direction @p dir
+ *
+ * @param gr The graphics instance on which to draw
+ * @param gc_n The color to use for the north half of the compass
+ * @param gc_s The color to use for the south half of the compass
+ * @param p The center of the compass
+ * @param r The radius of the compass (around the center point @p p)
+ * @param dir The direction the compass points to (0 being up, value is in degrees counter-clockwise)
+ */
+static void draw_compass(struct graphics *gr, struct graphics_gc *gc_n, struct graphics_gc *gc_s, struct point *p,
+ int r,
+ int dir) {
+ struct point ph[3];
+ int wh[3] = { 1, 1, 1 }; /* Width of each line of the polygon to draw */
+ int l = r * 0.25;
+
+ ph[0].x = -l;
+ ph[0].y = 0;
+ ph[1].x = 0;
+ ph[1].y = -r;
+ ph[2].x = l;
+ ph[2].y = 0;
+ transform_rotate(p, dir, ph, 3); /* Rotate to the correct direction */
+ graphics_draw_polygon_clipped(gr, gc_n, ph, 3); /* Draw north half */
+
+ ph[0].x = -l;
+ ph[0].y = 0;
+ ph[1].x = 0;
+ ph[1].y = r;
+ ph[2].x = l;
+ ph[2].y = 0;
+ transform_rotate(p, dir, ph, 3); /* Rotate to the correct direction */
+ graphics_draw_polyline_clipped(gr, gc_s, ph, 3, wh, 0); /* Draw south half */
+}
+
+/**
+ * @brief Draw an arrow of length @p r, centered at point @p p, with color @p gc, pointing to direction @p dir
+ *
+ * @param gr The graphics instance on which to draw
+ * @param gc The color to draw the arrow
+ * @param p The center of the compass
+ * @param r The radius of the compass (around the center point @p p)
+ * @param dir The direction the arrow points to (0 being up, value is in degrees counter-clockwise)
+ */
+static void draw_handle(struct graphics *gr, struct graphics_gc *gc, struct point *p, int r,
+ int dir) {
+ struct point ph[6];
+ int l = r * 0.4;
+ int s = l * 0.4;
+
+ ph[0].x = 0; /* Compute details for the body of the arrow */
+ ph[0].y = r - l;
+ ph[1].x = 0;
+ ph[1].y = -r;
+ transform_rotate(p, dir, ph, 2); /* Rotate to the correct direction */
+ graphics_draw_lines(gr, gc, ph, 2); /* Draw the body */
+
+ ph[0].x = -l; /* Compute details for the head of the arrow */
+ ph[0].y = -r + l;
+ ph[1].x = 0;
+ ph[1].y = -r;
+ ph[2].x = l;
+ ph[2].y = -r + l;
+ transform_rotate(p, dir, ph, 3); /* Rotate to the correct direction */
+ graphics_draw_lines(gr, gc, ph, 3); /* Draw the head */
+
+ ph[0].x = -s; /* Compute details for the tail of the arrow */
+ ph[0].y = r - l + s;
+ ph[1].x = 0;
+ ph[1].y = r - l;
+ ph[2].x = s;
+ ph[2].y = r - l + s;
+ ph[3]=ph[0]; /* Save these 3 points for future re-use */
+ ph[4]=ph[1];
+ ph[5]=ph[2];
+ transform_rotate(p, dir, ph, 3); /* Rotate to the correct direction */
+ graphics_draw_lines(gr, gc, ph, 3); /* Draw the tail */
+ ph[0]=ph[3]; /* Restore saved points */
+ ph[1]=ph[4];
+ ph[2]=ph[5];
+ transform_move(0, s, ph, 3);
+ ph[3]=ph[0]; /* Save these 3 points for future re-use */
+ ph[4]=ph[1];
+ ph[5]=ph[2];
+ transform_rotate(p, dir, ph, 3); /* Rotate to the correct direction */
+ graphics_draw_lines(gr, gc, ph, 3); /* Draw the tail */
+ ph[0]=ph[3]; /* Restore saved points */
+ ph[1]=ph[4];
+ ph[2]=ph[5];
+ transform_move(0, s, ph, 3);
+ transform_rotate(p, dir, ph, 3); /* Rotate to the correct direction */
+ graphics_draw_lines(gr, gc, ph, 3); /* Draw the tail */
}
/**
@@ -145,30 +242,28 @@ handle(struct graphics *gr, struct graphics_gc *gc, struct point *p, int r,
* * @param sep separator character to be inserted between distance value and unit
* * @returns a pointer to a string containing the formatted distance
* */
-static char *
-format_distance(double distance, char *sep, int imperial)
-{
- if (imperial){
- distance *= FEET_PER_METER;
- if(distance <= 500){
- return g_strdup_printf("%.0f%sft", round(distance / 10) * 10, sep);
- } else {
- return g_strdup_printf("%.1f%smi", distance / FEET_PER_MILE, sep);
- }
- } else {
- if (distance >= 10000)
- return g_strdup_printf("%.0f%skm", distance / 1000, sep);
- else if (distance >= 1000)
- return g_strdup_printf("%.1f%skm", distance / 1000, sep);
- else if (distance >= 300)
- return g_strdup_printf("%.0f%sm", round(distance / 25) * 25, sep);
- else if (distance >= 50)
- return g_strdup_printf("%.0f%sm", round(distance / 10) * 10, sep);
- else if (distance >= 10)
- return g_strdup_printf("%.0f%sm", distance, sep);
- else
- return g_strdup_printf("%.1f%sm", distance, sep);
- }
+static char *format_distance(double distance, char *sep, int imperial) {
+ if (imperial) {
+ distance *= FEET_PER_METER;
+ if(distance <= 500) {
+ return g_strdup_printf("%.0f%sft", round(distance / 10) * 10, sep);
+ } else {
+ return g_strdup_printf("%.1f%smi", distance / FEET_PER_MILE, sep);
+ }
+ } else {
+ if (distance >= 10000)
+ return g_strdup_printf("%.0f%skm", distance / 1000, sep);
+ else if (distance >= 1000)
+ return g_strdup_printf("%.1f%skm", distance / 1000, sep);
+ else if (distance >= 300)
+ return g_strdup_printf("%.0f%sm", round(distance / 25) * 25, sep);
+ else if (distance >= 50)
+ return g_strdup_printf("%.0f%sm", round(distance / 10) * 10, sep);
+ else if (distance >= 10)
+ return g_strdup_printf("%.0f%sm", distance, sep);
+ else
+ return g_strdup_printf("%.1f%sm", distance, sep);
+ }
}
/**
@@ -178,13 +273,11 @@ format_distance(double distance, char *sep, int imperial)
* * @param days days
* * @returns a pointer to a string containing the formatted time
* */
-static char *
-format_time(struct tm *tm, int days)
-{
- if (days)
- return g_strdup_printf("%d+%02d:%02d", days, tm->tm_hour, tm->tm_min);
- else
- return g_strdup_printf("%02d:%02d", tm->tm_hour, tm->tm_min);
+static char *format_time(struct tm *tm, int days) {
+ if (days)
+ return g_strdup_printf("%d+%02d:%02d", days, tm->tm_hour, tm->tm_min);
+ else
+ return g_strdup_printf("%02d:%02d", tm->tm_hour, tm->tm_min);
}
/**
@@ -194,287 +287,268 @@ format_time(struct tm *tm, int days)
* * @param sep separator character to be inserted between speed value and unit
* * @returns a pointer to a string containing the formatted speed
* */
-static char *
-format_speed(double speed, char *sep, char *format, int imperial)
-{
- char *unit="km/h";
- if (imperial) {
- speed = speed*1000*FEET_PER_METER/FEET_PER_MILE;
- unit="mph";
- }
- if (!format || !strcmp(format,"named"))
- return g_strdup_printf((speed < 10) ? "%.1f%s%s":"%.0f%s%s", speed, sep, unit);
- else if (!strcmp(format,"value") || !strcmp(format,"unit")) {
- if (!strcmp(format,"value"))
- return g_strdup_printf((speed < 10) ? "%.1f":"%.0f", speed);
- else
- return g_strdup(unit);
- }
- return g_strdup("");
-}
-
-static char *
-format_float_0(double num)
-{
- return g_strdup_printf("%.0f", num);
-}
-
-int set_std_osd_attr(struct osd_priv *priv, struct attr*the_attr)
-{
- struct osd_priv_common *opc=(struct osd_priv_common *)priv;
- if(opc && the_attr && ATTR_IS_INT(the_attr->type)) {
- int attr_set=0;
- if(attr_w == the_attr->type) {
- opc->osd_item.rel_w = the_attr->u.num;
- attr_set=1;
- }
- else if(attr_h == the_attr->type) {
- opc->osd_item.rel_h = the_attr->u.num;
- attr_set=1;
- }
- else if(attr_x == the_attr->type) {
- opc->osd_item.rel_x = the_attr->u.num;
- attr_set=1;
- }
- else if(attr_y == the_attr->type) {
- opc->osd_item.rel_y = the_attr->u.num;
- attr_set=1;
- }
- else if(attr_font_size == the_attr->type) {
- opc->osd_item.font_size = the_attr->u.num;
- attr_set=1;
- }
- if(attr_set && opc->osd_item.gr) {
- osd_std_calculate_sizes(&opc->osd_item, navit_get_width(opc->osd_item.navit), navit_get_height(opc->osd_item.navit));
- osd_std_resize(&opc->osd_item);
- return 1;
- }
- }
- if(opc->spec_set_attr_func) {
- opc->spec_set_attr_func(opc, the_attr);
- }
- return 0;
+static char *format_speed(double speed, char *sep, char *format, int imperial) {
+ char *unit="km/h";
+ if (imperial) {
+ speed = speed*1000*FEET_PER_METER/FEET_PER_MILE;
+ unit="mph";
+ }
+ if (!format || !strcmp(format,"named"))
+ return g_strdup_printf((speed < 10) ? "%.1f%s%s":"%.0f%s%s", speed, sep, unit);
+ else if (!strcmp(format,"value") || !strcmp(format,"unit")) {
+ if (!strcmp(format,"value"))
+ return g_strdup_printf((speed < 10) ? "%.1f":"%.0f", speed);
+ else
+ return g_strdup(unit);
+ }
+ return g_strdup("");
+}
+
+static char *format_float_0(double num) {
+ return g_strdup_printf("%.0f", num);
+}
+
+int set_std_osd_attr(struct osd_priv *priv, struct attr*the_attr) {
+ struct osd_priv_common *opc=(struct osd_priv_common *)priv;
+ if(opc && the_attr && ATTR_IS_INT(the_attr->type)) {
+ int attr_set=0;
+ if(attr_w == the_attr->type) {
+ opc->osd_item.rel_w = the_attr->u.num;
+ attr_set=1;
+ } else if(attr_h == the_attr->type) {
+ opc->osd_item.rel_h = the_attr->u.num;
+ attr_set=1;
+ } else if(attr_x == the_attr->type) {
+ opc->osd_item.rel_x = the_attr->u.num;
+ attr_set=1;
+ } else if(attr_y == the_attr->type) {
+ opc->osd_item.rel_y = the_attr->u.num;
+ attr_set=1;
+ } else if(attr_font_size == the_attr->type) {
+ opc->osd_item.font_size = the_attr->u.num;
+ attr_set=1;
+ }
+ if(attr_set && opc->osd_item.gr) {
+ osd_std_calculate_sizes(&opc->osd_item, navit_get_width(opc->osd_item.navit), navit_get_height(opc->osd_item.navit));
+ osd_std_resize(&opc->osd_item);
+ return 1;
+ }
+ }
+ if(opc->spec_set_attr_func) {
+ opc->spec_set_attr_func(opc, the_attr);
+ }
+ return 0;
}
struct route_guard {
- int coord_num;
- struct coord *coords;
- double min_dist; //distance treshold, exceeding this distance will trigger announcement
- double max_dist; //out of range distance, farther than this distance no warning will be given
- char*item_name;
- char*map_name;
- int warned;
- double last_time;
- int update_period;
- struct color active_color;
- struct graphics_gc *red;
- int width;
+ int coord_num;
+ struct coord *coords;
+ double min_dist; //distance treshold, exceeding this distance will trigger announcement
+ double max_dist; //out of range distance, farther than this distance no warning will be given
+ char*item_name;
+ char*map_name;
+ int warned;
+ double last_time;
+ int update_period;
+ struct color active_color;
+ struct graphics_gc *red;
+ int width;
};
-static void osd_route_guard_draw(struct osd_priv_common *opc, struct navit *nav, struct vehicle *v)
-{
- int i=0;
- struct vehicle* curr_vehicle = v;
- struct attr position_attr, vehicle_attr, imperial_attr;
- struct coord curr_coord;
- struct route_guard *this = (struct route_guard *)opc->data;
- double curr_time;
- struct timeval tv;
- struct point p;
- struct point bbox[4];
- char* dist_str;
- struct graphics_gc *curr_color;
- int imperial=0;
- double min_dist;
-
- //do not execute for each gps update
- gettimeofday(&tv,NULL);
- curr_time = (double)(tv.tv_usec)/1000000.0+tv.tv_sec;
- if ( this->last_time+this->update_period > curr_time) {
- return;
- }
- this->last_time = curr_time;
- if(nav) {
- navit_get_attr(nav, attr_vehicle, &vehicle_attr, NULL);
- if (vehicle_attr.u.vehicle) {
- curr_vehicle = vehicle_attr.u.vehicle;
- }
- if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL)) {
- imperial=imperial_attr.u.num;
- }
- }
-
- if(0==curr_vehicle)
- return;
-
- if(!vehicle_get_attr(curr_vehicle, attr_position_coord_geo,&position_attr, NULL)) {
- return;
- }
- transform_from_geo(projection_mg, position_attr.u.coord_geo, &curr_coord);
-
- min_dist = 1000000;
- //calculate min dist
- if(this->coord_num > 1) {
- double scale = transform_scale(curr_coord.y);
- for( i=1 ; i<this->coord_num ; ++i ) {
- struct coord proj_coord;
- double curr_dist;
- transform_distance_line_sq(&this->coords[i-1], &this->coords[i], &curr_coord, &proj_coord);
- curr_dist = transform_distance(projection_mg, &proj_coord, &curr_coord);
- curr_dist /= scale;
- if (curr_dist<min_dist) {
- min_dist = curr_dist;
- }
- }
- if ( this->warned == 0 && this->min_dist < min_dist && min_dist < this->max_dist) {
- navit_say(nav, _("Return to route!"));
- this->warned = 1;
- } else if( min_dist < this->min_dist ) {
- this->warned = 0;
- }
- }
- osd_fill_with_bgcolor(&opc->osd_item);
-
- dist_str = format_distance(min_dist, "", imperial);
-
- graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, dist_str, 0x10000, 0, bbox, 0);
- p.x=(opc->osd_item.w-bbox[2].x)/2;
- p.y = opc->osd_item.h-opc->osd_item.h/10;
-
- curr_color = (this->min_dist < min_dist && min_dist < this->max_dist) ? this->red : opc->osd_item.graphic_fg;
- graphics_draw_text(opc->osd_item.gr, curr_color, NULL, opc->osd_item.font, dist_str, &p, 0x10000, 0);
-
- g_free(dist_str);
-
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
-}
-
-static void
-osd_route_guard_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct color red_color={0xffff,0x0000,0x0000,0xffff};
- struct route_guard *this = (struct route_guard *)opc->data;
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- //load coord data
- if (this->map_name && this->item_name) {
- struct mapset* ms;
- struct map_rect *mr;
- struct mapset_handle *msh;
- struct map *map = NULL;
- struct item *item = NULL;
- if(!(ms=navit_get_mapset(nav))) {
- return;
- }
- msh=mapset_open(ms);
- while ((map=mapset_next(msh, 1))) {
- struct attr attr;
- if(map_get_attr(map, attr_name, &attr, NULL)) {
- if( ! strcmp(this->map_name, attr.u.str) ) {
- mr=map_rect_new(map, NULL);
- if (mr) {
- while ((item=map_rect_get_item(mr))) {
- struct attr item_attr;
- if(item_attr_get(item, attr_name, &item_attr)) {
- if (!strcmp(item_attr.u.str,this->item_name)) {
- //item found, get coords
- struct coord c;
- this->coord_num=0;
- while (item_coord_get(item,&c,1)) {
- this->coords = g_renew(struct coord,this->coords,this->coord_num+1);
- this->coords[this->coord_num] = c;
- ++this->coord_num;
- }
- }
- }
- }
- }
- } else {
- continue;
- }
- } else {
- continue;
- }
- }
- mapset_close(msh);
- }
-
- this->red = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->red, &red_color);
- graphics_gc_set_linewidth(this->red, this->width);
-
- opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
- //setup draw callback
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_route_guard_draw), attr_position_coord_geo, opc));
-}
-
-static void
-osd_route_guard_destroy(struct osd_priv_common *opc)
-{
- struct route_guard *this = (struct route_guard *)opc->data;
- g_free(this->coords);
-}
-
-static struct osd_priv *
-osd_route_guard_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct route_guard *this = g_new0(struct route_guard, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = 120;
- opc->osd_item.rel_y = 20;
- opc->osd_item.rel_w = 60;
- opc->osd_item.rel_h = 80;
- opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_route_guard_draw);
- meth->set_attr = set_std_osd_attr;
- osd_set_std_attr(attrs, &opc->osd_item, 2);
-
- attr = attr_search(attrs, NULL, attr_min_dist);
- if (attr) {
- this->min_dist = attr->u.num;
- }
- else
- this->min_dist = 30; //default tolerance is 30m
-
- attr = attr_search(attrs, NULL, attr_max_dist);
- if (attr) {
- this->max_dist = attr->u.num;
- }
- else
- this->max_dist = 500; //default
-
- attr = attr_search(attrs, NULL, attr_item_name);
- if (attr) {
- this->item_name = g_strdup(attr->u.str);
- }
- else
- this->item_name = NULL;
-
- attr = attr_search(attrs, NULL, attr_map_name);
- if (attr) {
- this->map_name = g_strdup(attr->u.str);
- }
- else
- this->map_name = NULL;
-
- attr = attr_search(attrs, NULL, attr_update_period);
- this->update_period=attr ? attr->u.num : 10;
-
- attr = attr_search(attrs, NULL, attr_width);
- this->width=attr ? attr->u.num : 2;
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_route_guard_init), attr_graphics_ready, opc));
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_route_guard_destroy), attr_destroy, opc));
-
- return (struct osd_priv *) opc;
+static void osd_route_guard_draw(struct osd_priv_common *opc, struct navit *nav, struct vehicle *v) {
+ int i=0;
+ struct vehicle* curr_vehicle = v;
+ struct attr position_attr, vehicle_attr, imperial_attr;
+ struct coord curr_coord;
+ struct route_guard *this = (struct route_guard *)opc->data;
+ double curr_time;
+ struct timeval tv;
+ struct point p;
+ struct point bbox[4];
+ char* dist_str;
+ struct graphics_gc *curr_color;
+ int imperial=0;
+ double min_dist;
+
+ //do not execute for each gps update
+ gettimeofday(&tv,NULL);
+ curr_time = (double)(tv.tv_usec)/1000000.0+tv.tv_sec;
+ if ( this->last_time+this->update_period > curr_time) {
+ return;
+ }
+ this->last_time = curr_time;
+ if(nav) {
+ navit_get_attr(nav, attr_vehicle, &vehicle_attr, NULL);
+ if (vehicle_attr.u.vehicle) {
+ curr_vehicle = vehicle_attr.u.vehicle;
+ }
+ if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL)) {
+ imperial=imperial_attr.u.num;
+ }
+ }
+
+ if(0==curr_vehicle)
+ return;
+
+ if(!vehicle_get_attr(curr_vehicle, attr_position_coord_geo,&position_attr, NULL)) {
+ return;
+ }
+ transform_from_geo(projection_mg, position_attr.u.coord_geo, &curr_coord);
+
+ min_dist = 1000000;
+ //calculate min dist
+ if(this->coord_num > 1) {
+ double scale = transform_scale(curr_coord.y);
+ for( i=1 ; i<this->coord_num ; ++i ) {
+ struct coord proj_coord;
+ double curr_dist;
+ transform_distance_line_sq(&this->coords[i-1], &this->coords[i], &curr_coord, &proj_coord);
+ curr_dist = transform_distance(projection_mg, &proj_coord, &curr_coord);
+ curr_dist /= scale;
+ if (curr_dist<min_dist) {
+ min_dist = curr_dist;
+ }
+ }
+ if ( this->warned == 0 && this->min_dist < min_dist && min_dist < this->max_dist) {
+ navit_say(nav, _("Return to route!"));
+ this->warned = 1;
+ } else if( min_dist < this->min_dist ) {
+ this->warned = 0;
+ }
+ }
+ osd_fill_with_bgcolor(&opc->osd_item);
+
+ dist_str = format_distance(min_dist, "", imperial);
+
+ graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, dist_str, 0x10000, 0, bbox, 0);
+ p.x=(opc->osd_item.w-bbox[2].x)/2;
+ p.y = opc->osd_item.h-opc->osd_item.h/10;
+
+ curr_color = (this->min_dist < min_dist && min_dist < this->max_dist) ? this->red : opc->osd_item.graphic_fg;
+ graphics_draw_text(opc->osd_item.gr, curr_color, NULL, opc->osd_item.font, dist_str, &p, 0x10000, 0);
+
+ g_free(dist_str);
+
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+}
+
+static void osd_route_guard_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct color red_color= {0xffff,0x0000,0x0000,0xffff};
+ struct route_guard *this = (struct route_guard *)opc->data;
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+ //load coord data
+ if (this->map_name && this->item_name) {
+ struct mapset* ms;
+ struct map_rect *mr;
+ struct mapset_handle *msh;
+ struct map *map = NULL;
+ struct item *item = NULL;
+ if(!(ms=navit_get_mapset(nav))) {
+ return;
+ }
+ msh=mapset_open(ms);
+ while ((map=mapset_next(msh, 1))) {
+ struct attr attr;
+ if(map_get_attr(map, attr_name, &attr, NULL)) {
+ if( ! strcmp(this->map_name, attr.u.str) ) {
+ mr=map_rect_new(map, NULL);
+ if (mr) {
+ while ((item=map_rect_get_item(mr))) {
+ struct attr item_attr;
+ if(item_attr_get(item, attr_name, &item_attr)) {
+ if (!strcmp(item_attr.u.str,this->item_name)) {
+ //item found, get coords
+ struct coord c;
+ this->coord_num=0;
+ while (item_coord_get(item,&c,1)) {
+ this->coords = g_renew(struct coord,this->coords,this->coord_num+1);
+ this->coords[this->coord_num] = c;
+ ++this->coord_num;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ continue;
+ }
+ } else {
+ continue;
+ }
+ }
+ mapset_close(msh);
+ }
+
+ this->red = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->red, &red_color);
+ graphics_gc_set_linewidth(this->red, this->width);
+
+ opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
+
+ //setup draw callback
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_route_guard_draw), attr_position_coord_geo, opc));
+}
+
+static void osd_route_guard_destroy(struct osd_priv_common *opc) {
+ struct route_guard *this = (struct route_guard *)opc->data;
+ g_free(this->coords);
+}
+
+static struct osd_priv *osd_route_guard_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct route_guard *this = g_new0(struct route_guard, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = 120;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
+ opc->osd_item.navit = nav;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_route_guard_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ osd_set_std_attr(attrs, &opc->osd_item, ITEM_HAS_TEXT);
+
+ attr = attr_search(attrs, NULL, attr_min_dist);
+ if (attr) {
+ this->min_dist = attr->u.num;
+ } else
+ this->min_dist = 30; //default tolerance is 30m
+
+ attr = attr_search(attrs, NULL, attr_max_dist);
+ if (attr) {
+ this->max_dist = attr->u.num;
+ } else
+ this->max_dist = 500; //default
+
+ attr = attr_search(attrs, NULL, attr_item_name);
+ if (attr) {
+ this->item_name = g_strdup(attr->u.str);
+ } else
+ this->item_name = NULL;
+
+ attr = attr_search(attrs, NULL, attr_map_name);
+ if (attr) {
+ this->map_name = g_strdup(attr->u.str);
+ } else
+ this->map_name = NULL;
+
+ attr = attr_search(attrs, NULL, attr_update_period);
+ this->update_period=attr ? attr->u.num : 10;
+
+ attr = attr_search(attrs, NULL, attr_width);
+ this->width=attr ? attr->u.num : 2;
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_route_guard_init), attr_graphics_ready, opc));
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_route_guard_destroy), attr_destroy, opc));
+
+ return (struct osd_priv *) opc;
}
@@ -482,164 +556,159 @@ static int odometers_saved = 0;
static GList* odometer_list = NULL;
static struct command_table commands[] = {
- {"odometer_reset",command_cast(osd_cmd_odometer_reset)},
+ {"odometer_reset",command_cast(osd_cmd_odometer_reset)},
};
struct odometer {
- int width;
- struct graphics_gc *orange;
- struct callback *click_cb;
- char *text; //text of label attribute for this osd
- char *name; //unique name of the odometer (needed for handling multiple odometers persistently)
- struct color idle_color; //text color when counter is idle
- int align;
- int bDisableReset;
- int bAutoStart;
- int bActive; //counting or not
- int autosave_period; //autosave period in seconds
- double sum_dist; //sum of distance ofprevious intervals in meters
- double sum_time; //sum of time of previous intervals in seconds (needed for avg spd calculation)
- double time_all;
- double last_click_time; //time of last click (for double click handling)
- double last_start_time; //time of last start of counting
- double last_update_time; //time of last position update
- struct coord last_coord;
- double last_speed;
- double max_speed;
- double acceleration;
+ int width;
+ struct graphics_gc *orange;
+ struct callback *click_cb;
+ char *text; //text of label attribute for this osd
+ char *name; //unique name of the odometer (needed for handling multiple odometers persistently)
+ struct color idle_color; //text color when counter is idle
+ int align;
+ int bDisableReset;
+ int bAutoStart;
+ int bActive; //counting or not
+ int autosave_period; //autosave period in seconds
+ double sum_dist; //sum of distance ofprevious intervals in meters
+ double sum_time; //sum of time of previous intervals in seconds (needed for avg spd calculation)
+ double time_all;
+ double last_click_time; //time of last click (for double click handling)
+ double last_start_time; //time of last start of counting
+ double last_update_time; //time of last position update
+ struct coord last_coord;
+ double last_speed;
+ double max_speed;
+ double acceleration;
};
-static void
-osd_cmd_odometer_reset(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) {
- GList* list = odometer_list;
- while(list) {
+static void osd_cmd_odometer_reset(struct navit *this, char *function, struct attr **in, struct attr ***out,
+ int *valid) {
+ if (in && in[0] && ATTR_IS_STRING(in[0]->type) && in[0]->u.str) {
+ GList* list = odometer_list;
+ while(list) {
if(!strcmp(((struct odometer*)((struct osd_priv_common *)(list->data))->data)->name,in[0]->u.str)) {
- osd_odometer_reset(list->data,3);
- osd_odometer_draw(list->data,this,NULL);
+ osd_odometer_reset(list->data,3);
+ osd_odometer_draw(list->data,this,NULL);
}
list = g_list_next(list);
- }
- }
+ }
+ }
}
-static char*
-str_replace(char*output, char*input, char*pattern, char*replacement)
-{
- char *pos;
- char *pos2;
- if (!output || !input || !pattern || !replacement) {
+static char* str_replace(char*output, char*input, char*pattern, char*replacement) {
+ char *pos;
+ char *pos2;
+ if (!output || !input || !pattern || !replacement) {
+ return NULL;
+ }
+ if(!strcmp(pattern,"")) {
+ return input;
+ }
+
+ pos = &input[0];
+ pos2 = &input[0];
+ output[0] = 0;
+ while ( (pos2=strstr(pos,pattern)) ) {
+ strncat(output,pos,pos2-pos);
+ strcat(output,replacement);
+ pos = pos2 + strlen(pattern);
+ }
+ strcat(output,pos);
return NULL;
- }
- if(!strcmp(pattern,"")) {
- return input;
- }
-
- pos = &input[0];
- pos2 = &input[0];
- output[0] = 0;
- while ( (pos2=strstr(pos,pattern)) ) {
- strncat(output,pos,pos2-pos);
- strcat(output,replacement);
- pos = pos2 + strlen(pattern);
- }
- strcat(output,pos);
- return NULL;
}
/*
* save current odometer state to string
*/
-static char *osd_odometer_to_string(struct odometer *this_)
-{
- return g_strdup_printf("odometer %s %lf %lf %d %lf\n",this_->name,this_->sum_dist,this_->time_all,this_->bActive,this_->max_speed);
+static char *osd_odometer_to_string(struct odometer *this_) {
+ return g_strdup_printf("odometer %s %lf %lf %d %lf\n",this_->name,this_->sum_dist,this_->time_all,this_->bActive,
+ this_->max_speed);
}
/*
* load current odometer state from string
*/
-static void osd_odometer_from_string(struct odometer *this_, char*str)
-{
- char* tok;
- char* name_str;
- char* sum_dist_str;
- char* sum_time_str;
- char* active_str;
- char* max_spd_str;
- tok = strtok(str, " ");
- if( !tok || strcmp("odometer",tok)) {
- return;
- }
- name_str = g_strdup(strtok(NULL, " "));
- if(!name_str) {
- return;
- }
- sum_dist_str = g_strdup(strtok(NULL, " "));
- if(!sum_dist_str) {
- g_free(name_str);
- return;
- }
- sum_time_str = g_strdup(strtok(NULL, " "));
- if(!sum_time_str) {
- g_free(name_str);
- g_free(sum_dist_str);
- return;
- }
- active_str = g_strdup(strtok(NULL, " "));
- if(!active_str) {
- g_free(name_str);
- g_free(sum_dist_str);
- g_free(sum_time_str);
- return;
- }
- max_spd_str = g_strdup(strtok(NULL, " "));
- if(!max_spd_str) {
- g_free(name_str);
+static void osd_odometer_from_string(struct odometer *this_, char*str) {
+ char* tok;
+ char* name_str;
+ char* sum_dist_str;
+ char* sum_time_str;
+ char* active_str;
+ char* max_spd_str;
+ tok = strtok(str, " ");
+ if( !tok || strcmp("odometer",tok)) {
+ return;
+ }
+ name_str = g_strdup(strtok(NULL, " "));
+ if(!name_str) {
+ return;
+ }
+ sum_dist_str = g_strdup(strtok(NULL, " "));
+ if(!sum_dist_str) {
+ g_free(name_str);
+ return;
+ }
+ sum_time_str = g_strdup(strtok(NULL, " "));
+ if(!sum_time_str) {
+ g_free(name_str);
+ g_free(sum_dist_str);
+ return;
+ }
+ active_str = g_strdup(strtok(NULL, " "));
+ if(!active_str) {
+ g_free(name_str);
+ g_free(sum_dist_str);
+ g_free(sum_time_str);
+ return;
+ }
+ max_spd_str = g_strdup(strtok(NULL, " "));
+ if(!max_spd_str) {
+ g_free(name_str);
+ g_free(sum_dist_str);
+ g_free(sum_time_str);
+ g_free(active_str);
+ return;
+ }
+
+ this_->name = name_str;
+ this_->sum_dist = atof(sum_dist_str);
+ this_->sum_time = atof(sum_time_str);
+ this_->bActive = atoi(active_str);
+ this_->max_speed = atof(max_spd_str);
+ this_->last_coord.x = -1;
+ g_free(active_str);
g_free(sum_dist_str);
g_free(sum_time_str);
- g_free(active_str);
- return;
- }
-
- this_->name = name_str;
- this_->sum_dist = atof(sum_dist_str);
- this_->sum_time = atof(sum_time_str);
- this_->bActive = atoi(active_str);
- this_->max_speed = atof(max_spd_str);
- this_->last_coord.x = -1;
- g_free(active_str);
- g_free(sum_dist_str);
- g_free(sum_time_str);
- g_free(max_spd_str);
-}
-
-static void draw_multiline_osd_text(char *buffer,struct osd_item *osd_item, struct graphics_gc *curr_color)
-{
- gchar**bufvec = g_strsplit(buffer,"\n",0);
- struct point p, bbox[4];
- //count strings
- int strnum = 0;
- gchar**pch = bufvec;
- while(*pch) {
- ++strnum;
- ++pch;
- }
-
- if(0<strnum) {
- int dh = osd_item->h / strnum;
-
- pch = bufvec;
- p.y = 0;
- while (*pch) {
- graphics_get_text_bbox(osd_item->gr, osd_item->font, *pch, 0x10000, 0, bbox, 0);
- p.x=(osd_item->w-bbox[2].x)/2;
- p.y += dh;
- graphics_draw_text(osd_item->gr, curr_color, NULL, osd_item->font, *pch, &p, 0x10000, 0);
- ++pch;
+ g_free(max_spd_str);
+}
+
+static void draw_multiline_osd_text(char *buffer,struct osd_item *osd_item, struct graphics_gc *curr_color) {
+ gchar**bufvec = g_strsplit(buffer,"\n",0);
+ struct point p, bbox[4];
+ //count strings
+ int strnum = 0;
+ gchar**pch = bufvec;
+ while(*pch) {
+ ++strnum;
+ ++pch;
}
- }
- g_free(bufvec);
+
+ if(0<strnum) {
+ int dh = osd_item->h / strnum;
+
+ pch = bufvec;
+ p.y = 0;
+ while (*pch) {
+ graphics_get_text_bbox(osd_item->gr, osd_item->font, *pch, 0x10000, 0, bbox, 0);
+ p.x=(osd_item->w-bbox[2].x)/2;
+ p.y += dh;
+ graphics_draw_text(osd_item->gr, curr_color, NULL, osd_item->font, *pch, &p, 0x10000, 0);
+ ++pch;
+ }
+ }
+ g_free(bufvec);
}
/**
@@ -651,872 +720,855 @@ static void draw_multiline_osd_text(char *buffer,struct osd_item *osd_item, stru
* * @param curr_color the color in which the osd text should be visible (defaults to osd_items foreground color)
* * @returns nothing
* */
-static void draw_aligned_osd_text(char *buffer, int align, struct osd_item *osd_item, struct graphics_gc *curr_color)
-{
-
- int height=osd_item->font_size*13/256;
- int yspacing=height/2;
- int xspacing=height/4;
- char *next, *last;
- struct point p, p2[4];
- int lines;
- int do_draw = osd_item->do_draw;
-
- osd_fill_with_bgcolor(osd_item);
- lines=0;
- next=buffer;
- last=buffer;
- while ((next=strstr(next, "\\n"))) {
- last = next;
- lines++;
- next++;
- }
-
- while (*last) {
- if (! g_ascii_isspace(*last)) {
- lines++;
- break;
- }
- last++;
- }
-
- dbg(lvl_debug,"align=%d\n", align);
- switch (align & 51) {
- case 1:
- p.y=0;
- break;
- case 2:
- p.y=(osd_item->h-lines*(height+yspacing)-yspacing);
- break;
- case 16: // Grow from top to bottom
- p.y = 0;
- if (lines != 0) {
- osd_item->h = (lines-1) * (height+yspacing) + height;
- } else {
- osd_item->h = 0;
- }
-
- if (do_draw) {
- osd_std_resize(osd_item);
- }
- default:
- p.y=(osd_item->h-lines*(height+yspacing)-yspacing)/2;
- }
-
- while (buffer) {
- next=strstr(buffer, "\\n");
- if (next) {
- *next='\0';
- next+=2;
- }
- graphics_get_text_bbox(osd_item->gr,
- osd_item->font,
- buffer, 0x10000,
- 0x0, p2, 0);
- switch (align & 12) {
- case 4:
- p.x=xspacing;
- break;
- case 8:
- p.x=osd_item->w-(p2[2].x-p2[0].x)-xspacing;
- break;
- default:
- p.x = ((p2[0].x - p2[2].x) / 2) + (osd_item->w / 2);
- }
- p.y += height+yspacing;
- graphics_draw_text(osd_item->gr,
- curr_color?curr_color:osd_item->graphic_fg_text,
- NULL, osd_item->font,
- buffer, &p, 0x10000,
- 0);
- buffer=next;
-
- graphics_draw_mode(osd_item->gr, draw_mode_end);
-
- }
-
-}
-
-
-static void osd_odometer_draw(struct osd_priv_common *opc, struct navit *nav, struct vehicle *v)
-{
- struct odometer *this = (struct odometer *)opc->data;
-
- struct coord curr_coord;
- struct graphics_gc *curr_color;
-
- char *dist_buffer=0;
- char *spd_buffer=0;
- char *max_spd_buffer=0;
- char *time_buffer = 0;
- char *acc_buffer = 0;
- struct attr position_attr,vehicle_attr,imperial_attr,speed_attr;
- enum projection pro;
- struct vehicle* curr_vehicle = v;
- double spd = 0;
- double curr_spd = 0;
-
- int remainder;
- int days;
- int hours;
- int mins;
- int secs;
- int imperial=0;
-
- char buffer [256+1]="";
- char buffer2[256+1]="";
-
- if(nav) {
- if (navit_get_attr(nav, attr_vehicle, &vehicle_attr, NULL))
- curr_vehicle=vehicle_attr.u.vehicle;
- if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL))
- imperial=imperial_attr.u.num;
- }
+static void draw_aligned_osd_text(char *buffer, int align, struct osd_item *osd_item, struct graphics_gc *curr_color) {
+
+ int height=osd_item->font_size*13/256;
+ int yspacing=height/2;
+ int xspacing=height/4;
+ char *next, *last;
+ struct point p, p2[4];
+ int lines;
+ int do_draw = osd_item->do_draw;
+
+ osd_fill_with_bgcolor(osd_item);
+ lines=0;
+ next=buffer;
+ last=buffer;
+ while ((next=strstr(next, "\\n"))) {
+ last = next;
+ lines++;
+ next++;
+ }
+
+ while (*last) {
+ if (! g_ascii_isspace(*last)) {
+ lines++;
+ break;
+ }
+ last++;
+ }
- if(0==curr_vehicle)
- return;
+ dbg(lvl_debug,"align=%d", align);
+ switch (align & 51) {
+ case 1:
+ p.y=0;
+ break;
+ case 2:
+ p.y=(osd_item->h-lines*(height+yspacing)-yspacing);
+ break;
+ case 16: // Grow from top to bottom
+ p.y = 0;
+ if (lines != 0) {
+ osd_item->h = (lines-1) * (height+yspacing) + height;
+ } else {
+ osd_item->h = 0;
+ }
- osd_fill_with_bgcolor(&opc->osd_item);
- if(this->bActive) {
- if(!vehicle_get_attr(curr_vehicle, attr_position_coord_geo,&position_attr, NULL)) {
- return;
- }
- pro = projection_mg;//position_attr.u.pcoord->pro;
- transform_from_geo(pro, position_attr.u.coord_geo, &curr_coord);
-
- if (this->last_coord.x != -1 ) {
- const double cStepDistLimit = 10000;
- struct timeval tv;
- double curr_time;
- double dt;
- double dCurrDist = 0;
-
- gettimeofday(&tv,NULL);
- curr_time = (double)(tv.tv_usec)/1000000.0+tv.tv_sec;
- //we have valid previous position
- dt = curr_time-this->last_update_time;
- dCurrDist = transform_distance(pro, &curr_coord, &this->last_coord);
- if(dCurrDist<=cStepDistLimit) {
- this->sum_dist += dCurrDist;
- }
- this->time_all = curr_time-this->last_click_time+this->sum_time;
- spd = 3.6*(double)this->sum_dist/(double)this->time_all;
- if(dt != 0) {
- if (curr_coord.x!=this->last_coord.x || curr_coord.y!=this->last_coord.y) {
- if(vehicle_get_attr(curr_vehicle, attr_position_speed,&speed_attr, NULL)) {
- double dv;
- curr_spd = *speed_attr.u.numd;
- dv = (curr_spd-this->last_speed)/3.6; //speed difference in m/sec
- this->acceleration = dv/dt;
- this->last_speed = curr_spd;
- this->last_update_time = curr_time;
- }
- }
- }
- this->max_speed = (curr_spd<=this->max_speed) ? this->max_speed : curr_spd;
- }
- this->last_coord = curr_coord;
- }
-
- dist_buffer = format_distance(this->sum_dist,"",imperial);
- spd_buffer = format_speed(spd,"","value",imperial);
- max_spd_buffer = format_speed(this->max_speed,"","value",imperial);
- acc_buffer = g_strdup_printf("%.3f m/s2",this->acceleration);
- remainder = (int)this->time_all;
- days = remainder / (24*60*60);
- remainder = remainder % (24*60*60);
- hours = remainder / (60*60);
- remainder = remainder % (60*60);
- mins = remainder / (60);
- remainder = remainder % (60);
- secs = remainder;
- if(0<days) {
- time_buffer = g_strdup_printf("%02dd %02d:%02d:%02d",days,hours,mins,secs);
- }
- else {
- time_buffer = g_strdup_printf("%02d:%02d:%02d",hours,mins,secs);
- }
-
- buffer [0] = 0;
- buffer2[0] = 0;
- if(this->text) {
- str_replace(buffer,this->text,"${avg_spd}",spd_buffer);
- str_replace(buffer2,buffer,"${distance}",dist_buffer);
- str_replace(buffer,buffer2,"${time}",time_buffer);
- str_replace(buffer2,buffer,"${acceleration}",acc_buffer);
- str_replace(buffer,buffer2,"${max_spd}",max_spd_buffer);
- }
- g_free(time_buffer);
-
- curr_color = this->bActive?opc->osd_item.graphic_fg:this->orange;
-
- draw_aligned_osd_text(buffer, this->align, &opc->osd_item, curr_color);
- g_free(dist_buffer);
- g_free(spd_buffer);
- g_free(max_spd_buffer);
- g_free(acc_buffer);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
-}
-
-
-static void
-osd_odometer_reset(struct osd_priv_common *opc, int flags)
-{
- struct odometer *this = (struct odometer *)opc->data;
-
- if(!this->bDisableReset || (flags & 1)) {
- if (!(flags & 2))
- this->bActive = 0;
+ if (do_draw) {
+ osd_std_resize(osd_item);
+ }
+ default:
+ p.y=(osd_item->h-lines*(height+yspacing)-yspacing)/2;
+ }
+
+ while (buffer) {
+ next=strstr(buffer, "\\n");
+ if (next) {
+ *next='\0';
+ next+=2;
+ }
+ graphics_get_text_bbox(osd_item->gr,
+ osd_item->font,
+ buffer, 0x10000,
+ 0x0, p2, 0);
+ switch (align & 12) {
+ case 4:
+ p.x=xspacing;
+ break;
+ case 8:
+ p.x=osd_item->w-(p2[2].x-p2[0].x)-xspacing;
+ break;
+ default:
+ p.x = ((p2[0].x - p2[2].x) / 2) + (osd_item->w / 2);
+ }
+ p.y += height+yspacing;
+ graphics_draw_text(osd_item->gr,
+ curr_color?curr_color:osd_item->graphic_fg_text,
+ NULL, osd_item->font,
+ buffer, &p, 0x10000,
+ 0);
+ buffer=next;
+
+ graphics_draw_mode(osd_item->gr, draw_mode_end);
+
+ }
+
+}
+
+
+static void osd_odometer_draw(struct osd_priv_common *opc, struct navit *nav, struct vehicle *v) {
+ struct odometer *this = (struct odometer *)opc->data;
+
+ struct coord curr_coord;
+ struct graphics_gc *curr_color;
+
+ char *dist_buffer=0;
+ char *spd_buffer=0;
+ char *max_spd_buffer=0;
+ char *time_buffer = 0;
+ char *acc_buffer = 0;
+ struct attr position_attr,vehicle_attr,imperial_attr,speed_attr;
+ enum projection pro;
+ struct vehicle* curr_vehicle = v;
+ double spd = 0;
+ double curr_spd = 0;
+
+ int remainder;
+ int days;
+ int hours;
+ int mins;
+ int secs;
+ int imperial=0;
+
+ char buffer [256+1]="";
+ char buffer2[256+1]="";
+
+ if(nav) {
+ if (navit_get_attr(nav, attr_vehicle, &vehicle_attr, NULL))
+ curr_vehicle=vehicle_attr.u.vehicle;
+ if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL))
+ imperial=imperial_attr.u.num;
+ }
+
+ if(0==curr_vehicle)
+ return;
+
+ osd_fill_with_bgcolor(&opc->osd_item);
+ if(this->bActive) {
+ if(!vehicle_get_attr(curr_vehicle, attr_position_coord_geo,&position_attr, NULL)) {
+ return;
+ }
+ pro = projection_mg;//position_attr.u.pcoord->pro;
+ transform_from_geo(pro, position_attr.u.coord_geo, &curr_coord);
+
+ if (this->last_coord.x != -1 ) {
+ const double cStepDistLimit = 10000;
+ struct timeval tv;
+ double curr_time;
+ double dt;
+ double dCurrDist = 0;
+
+ gettimeofday(&tv,NULL);
+ curr_time = (double)(tv.tv_usec)/1000000.0+tv.tv_sec;
+ //we have valid previous position
+ dt = curr_time-this->last_update_time;
+ dCurrDist = transform_distance(pro, &curr_coord, &this->last_coord);
+ if(dCurrDist<=cStepDistLimit) {
+ this->sum_dist += dCurrDist;
+ }
+ this->time_all = curr_time-this->last_click_time+this->sum_time;
+ spd = 3.6*(double)this->sum_dist/(double)this->time_all;
+ if(dt != 0) {
+ if (curr_coord.x!=this->last_coord.x || curr_coord.y!=this->last_coord.y) {
+ if(vehicle_get_attr(curr_vehicle, attr_position_speed,&speed_attr, NULL)) {
+ double dv;
+ curr_spd = *speed_attr.u.numd;
+ dv = (curr_spd-this->last_speed)/3.6; //speed difference in m/sec
+ this->acceleration = dv/dt;
+ this->last_speed = curr_spd;
+ this->last_update_time = curr_time;
+ }
+ }
+ }
+ this->max_speed = (curr_spd<=this->max_speed) ? this->max_speed : curr_spd;
+ }
+ this->last_coord = curr_coord;
+ }
+
+ dist_buffer = format_distance(this->sum_dist,"",imperial);
+ spd_buffer = format_speed(spd,"","value",imperial);
+ max_spd_buffer = format_speed(this->max_speed,"","value",imperial);
+ acc_buffer = g_strdup_printf("%.3f m/s2",this->acceleration);
+ remainder = (int)this->time_all;
+ days = remainder / (24*60*60);
+ remainder = remainder % (24*60*60);
+ hours = remainder / (60*60);
+ remainder = remainder % (60*60);
+ mins = remainder / (60);
+ remainder = remainder % (60);
+ secs = remainder;
+ if(0<days) {
+ time_buffer = g_strdup_printf("%02dd %02d:%02d:%02d",days,hours,mins,secs);
+ } else {
+ time_buffer = g_strdup_printf("%02d:%02d:%02d",hours,mins,secs);
+ }
+
+ buffer [0] = 0;
+ buffer2[0] = 0;
+ if(this->text) {
+ str_replace(buffer,this->text,"${avg_spd}",spd_buffer);
+ str_replace(buffer2,buffer,"${distance}",dist_buffer);
+ str_replace(buffer,buffer2,"${time}",time_buffer);
+ str_replace(buffer2,buffer,"${acceleration}",acc_buffer);
+ str_replace(buffer,buffer2,"${max_spd}",max_spd_buffer);
+ }
+ g_free(time_buffer);
+
+ curr_color = this->bActive?opc->osd_item.graphic_fg:this->orange;
+
+ draw_aligned_osd_text(buffer, this->align, &opc->osd_item, curr_color);
+ g_free(dist_buffer);
+ g_free(spd_buffer);
+ g_free(max_spd_buffer);
+ g_free(acc_buffer);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+}
+
+
+static void osd_odometer_reset(struct osd_priv_common *opc, int flags) {
+ struct odometer *this = (struct odometer *)opc->data;
+
+ if(!this->bDisableReset || (flags & 1)) {
+ if (!(flags & 2))
+ this->bActive = 0;
+ this->sum_dist = 0;
+ this->sum_time = 0;
+ this->max_speed = 0;
+ this->last_start_time = 0;
+ this->last_coord.x = -1;
+ this->last_coord.y = -1;
+ }
+}
+
+static void osd_odometer_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button,
+ struct point *p) {
+ struct odometer *this = (struct odometer *)opc->data;
+
+ struct point bp = opc->osd_item.p;
+ struct timeval tv;
+ double curr_time;
+ const double double_click_timewin = .5;
+ osd_wrap_point(&bp, nav);
+ if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h
+ || !opc->osd_item.configured ) && !opc->osd_item.pressed)
+ return;
+ if (button != 1)
+ return;
+ if (navit_ignore_button(nav))
+ return;
+ if (!!pressed == !!opc->osd_item.pressed)
+ return;
+
+ gettimeofday(&tv,NULL);
+ curr_time = (double)(tv.tv_usec)/1000000.0+tv.tv_sec;
+
+ if (pressed) { //single click handling
+ if(this->bActive) { //being stopped
+ this->last_coord.x = -1;
+ this->last_coord.y = -1;
+ this->sum_time += curr_time-this->last_click_time;
+ }
+
+ this->bActive ^= 1; //toggle active flag
+
+ if (curr_time-double_click_timewin <= this->last_click_time) { //double click handling
+ osd_odometer_reset(opc,0);
+ }
+
+ this->last_click_time = curr_time;
+
+ osd_odometer_draw(opc, nav,NULL);
+ }
+}
+
+
+static int osd_odometer_save(struct navit* nav) {
+ //save odometers that are persistent(ie have name)
+ FILE*f;
+ GList* list = odometer_list;
+ char* fn = g_strdup_printf("%s/odometer.txt",navit_get_user_data_directory(TRUE));
+ f = fopen(fn,"w+");
+ g_free(fn);
+ if(!f) {
+ return TRUE;
+ }
+ while (list) {
+ if(((struct odometer*)((struct osd_priv_common *)(list->data))->data)->name) {
+ char*odo_str = osd_odometer_to_string((struct odometer*)((struct osd_priv_common *)(list->data))->data);
+ fprintf(f,"%s",odo_str);
+ g_free(odo_str);
+ }
+ list = g_list_next(list);
+ }
+ fclose(f);
+ return TRUE;
+}
+
+
+static void osd_odometer_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct odometer *this = (struct odometer *)opc->data;
+
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+
+ this->orange = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->orange, &this->idle_color);
+ graphics_gc_set_linewidth(this->orange, this->width);
+
+ opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
+
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_draw), attr_position_coord_geo, opc));
+
+ navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_odometer_click), attr_button, opc));
+
+ if(this->autosave_period>0) {
+ event_add_timeout(this->autosave_period*1000, 1, callback_new_1(callback_cast(osd_odometer_save), NULL));
+ }
+
+ if(this->bAutoStart) {
+ this->bActive = 1;
+ }
+ osd_odometer_draw(opc, nav, NULL);
+}
+
+static void osd_odometer_destroy(struct navit* nav) {
+ if(!odometers_saved) {
+ odometers_saved = 1;
+ osd_odometer_save(NULL);
+ }
+}
+
+static struct osd_priv *osd_odometer_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ FILE* f;
+ char* fn;
+
+ struct odometer *this = g_new0(struct odometer, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+ struct color orange_color= {0xffff,0xa5a5,0x0000,0xffff};
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = 120;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
+ opc->osd_item.navit = nav;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_odometer_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ this->bActive = 0; //do not count on init
this->sum_dist = 0;
- this->sum_time = 0;
this->max_speed = 0;
- this->last_start_time = 0;
+ this->last_click_time = time(0);
this->last_coord.x = -1;
this->last_coord.y = -1;
- }
+
+ attr = attr_search(attrs, NULL, attr_label);
+ //FIXME find some way to free text!!!!
+ if (attr) {
+ this->text = g_strdup(attr->u.str);
+ } else
+ this->text = NULL;
+
+ attr = attr_search(attrs, NULL, attr_name);
+ //FIXME find some way to free text!!!!
+ if (attr) {
+ this->name = g_strdup(attr->u.str);
+ } else
+ this->name = NULL;
+
+ attr = attr_search(attrs, NULL, attr_disable_reset);
+ if (attr)
+ this->bDisableReset = attr->u.num;
+ else
+ this->bDisableReset = 0;
+
+ attr = attr_search(attrs, NULL, attr_autostart);
+ if (attr)
+ this->bAutoStart = attr->u.num;
+ else
+ this->bAutoStart = 0;
+ attr = attr_search(attrs, NULL, attr_autosave_period);
+ if (attr)
+ this->autosave_period = attr->u.num;
+ else
+ this->autosave_period = -1; //disabled by default
+
+ attr = attr_search(attrs, NULL, attr_align);
+ if (attr)
+ this->align=attr->u.num;
+
+ osd_set_std_attr(attrs, &opc->osd_item, ITEM_HAS_TEXT);
+ attr = attr_search(attrs, NULL, attr_width);
+ this->width=attr ? attr->u.num : 2;
+ attr = attr_search(attrs, NULL, attr_idle_color);
+ this->idle_color=attr ? *attr->u.color : orange_color; // text idle_color defaults to orange
+
+ this->last_coord.x = -1;
+ this->last_coord.y = -1;
+ this->sum_dist = 0.0;
+
+ //load state from file
+ fn = g_strdup_printf("%s/odometer.txt",navit_get_user_data_directory(FALSE));
+ f = fopen(fn,"r+");
+
+ if(f) {
+ g_free(fn);
+
+ while(!feof(f)) {
+ char str[128];
+ char *line;
+ if(fgets(str,128,f)) {
+ char *tok;
+ line = g_strdup(str);
+ tok = strtok(str," ");
+ if(!strcmp(tok,"odometer")) {
+ tok = strtok(NULL," ");
+ if(this->name && tok && !strcmp(this->name,tok)) {
+ osd_odometer_from_string(this,line);
+ }
+ }
+ g_free(line);
+ }
+ }
+ fclose(f);
+ }
+
+ if(b_commandtable_added == 0) {
+ navit_command_add_table(nav, commands, sizeof(commands)/sizeof(struct command_table));
+ b_commandtable_added = 1;
+ }
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_init), attr_graphics_ready, opc));
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_destroy), attr_destroy, nav));
+ odometer_list = g_list_append(odometer_list, opc);
+
+ return (struct osd_priv *) opc;
}
-static void
-osd_odometer_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button, struct point *p)
-{
- struct odometer *this = (struct odometer *)opc->data;
-
- struct point bp = opc->osd_item.p;
- struct timeval tv;
- double curr_time;
- const double double_click_timewin = .5;
- osd_wrap_point(&bp, nav);
- if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h || !opc->osd_item.configured ) && !opc->osd_item.pressed)
- return;
- if (button != 1)
- return;
- if (navit_ignore_button(nav))
- return;
- if (!!pressed == !!opc->osd_item.pressed)
- return;
-
- gettimeofday(&tv,NULL);
- curr_time = (double)(tv.tv_usec)/1000000.0+tv.tv_sec;
-
- if (pressed) { //single click handling
- if(this->bActive) { //being stopped
- this->last_coord.x = -1;
- this->last_coord.y = -1;
- this->sum_time += curr_time-this->last_click_time;
- }
-
- this->bActive ^= 1; //toggle active flag
-
- if (curr_time-double_click_timewin <= this->last_click_time) { //double click handling
- osd_odometer_reset(opc,0);
- }
-
- this->last_click_time = curr_time;
-
- osd_odometer_draw(opc, nav,NULL);
- }
-}
-
-
-static int
-osd_odometer_save(struct navit* nav)
-{
- //save odometers that are persistent(ie have name)
- FILE*f;
- GList* list = odometer_list;
- char* fn = g_strdup_printf("%s/odometer.txt",navit_get_user_data_directory(TRUE));
- f = fopen(fn,"w+");
- g_free(fn);
- if(!f) {
- return TRUE;
- }
- while (list) {
- if(((struct odometer*)((struct osd_priv_common *)(list->data))->data)->name) {
- char*odo_str = osd_odometer_to_string((struct odometer*)((struct osd_priv_common *)(list->data))->data);
- fprintf(f,"%s",odo_str);
- g_free(odo_str);
- }
- list = g_list_next(list);
- }
- fclose(f);
- return TRUE;
-}
-
-
-static void
-osd_odometer_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct odometer *this = (struct odometer *)opc->data;
-
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
-
- this->orange = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->orange, &this->idle_color);
- graphics_gc_set_linewidth(this->orange, this->width);
-
- opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_draw), attr_position_coord_geo, opc));
-
- navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_odometer_click), attr_button, opc));
-
- if(this->autosave_period>0) {
- event_add_timeout(this->autosave_period*1000, 1, callback_new_1(callback_cast(osd_odometer_save), NULL));
- }
-
- if(this->bAutoStart) {
- this->bActive = 1;
- }
- osd_odometer_draw(opc, nav, NULL);
-}
-
-static void
-osd_odometer_destroy(struct navit* nav)
-{
- if(!odometers_saved) {
- odometers_saved = 1;
- osd_odometer_save(NULL);
- }
-}
-
-static struct osd_priv *
-osd_odometer_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- FILE* f;
- char* fn;
-
- struct odometer *this = g_new0(struct odometer, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
- struct color orange_color={0xffff,0xa5a5,0x0000,0xffff};
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = 120;
- opc->osd_item.rel_y = 20;
- opc->osd_item.rel_w = 60;
- opc->osd_item.rel_h = 80;
- opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_odometer_draw);
- meth->set_attr = set_std_osd_attr;
-
- this->bActive = 0; //do not count on init
- this->sum_dist = 0;
- this->max_speed = 0;
- this->last_click_time = time(0);
- this->last_coord.x = -1;
- this->last_coord.y = -1;
-
- attr = attr_search(attrs, NULL, attr_label);
- //FIXME find some way to free text!!!!
- if (attr) {
- this->text = g_strdup(attr->u.str);
- }
- else
- this->text = NULL;
-
- attr = attr_search(attrs, NULL, attr_name);
- //FIXME find some way to free text!!!!
- if (attr) {
- this->name = g_strdup(attr->u.str);
- }
- else
- this->name = NULL;
-
- attr = attr_search(attrs, NULL, attr_disable_reset);
- if (attr)
- this->bDisableReset = attr->u.num;
- else
- this->bDisableReset = 0;
-
- attr = attr_search(attrs, NULL, attr_autostart);
- if (attr)
- this->bAutoStart = attr->u.num;
- else
- this->bAutoStart = 0;
- attr = attr_search(attrs, NULL, attr_autosave_period);
- if (attr)
- this->autosave_period = attr->u.num;
- else
- this->autosave_period = -1; //disabled by default
-
- attr = attr_search(attrs, NULL, attr_align);
- if (attr)
- this->align=attr->u.num;
-
- osd_set_std_attr(attrs, &opc->osd_item, 2);
- attr = attr_search(attrs, NULL, attr_width);
- this->width=attr ? attr->u.num : 2;
- attr = attr_search(attrs, NULL, attr_idle_color);
- this->idle_color=attr ? *attr->u.color : orange_color; // text idle_color defaults to orange
-
- this->last_coord.x = -1;
- this->last_coord.y = -1;
- this->sum_dist = 0.0;
-
- //load state from file
- fn = g_strdup_printf("%s/odometer.txt",navit_get_user_data_directory(FALSE));
- f = fopen(fn,"r+");
-
- if(f) {
- g_free(fn);
-
- while(!feof(f)) {
- char str[128];
- char *line;
- if(fgets(str,128,f))
- {
- char *tok;
- line = g_strdup(str);
- tok = strtok(str," ");
- if(!strcmp(tok,"odometer")) {
- tok = strtok(NULL," ");
- if(this->name && tok && !strcmp(this->name,tok)) {
- osd_odometer_from_string(this,line);
- }
- }
- g_free(line);
- }
- }
- fclose(f);
- }
-
- if(b_commandtable_added == 0) {
- navit_command_add_table(nav, commands, sizeof(commands)/sizeof(struct command_table));
- b_commandtable_added = 1;
- }
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_init), attr_graphics_ready, opc));
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_destroy), attr_destroy, nav));
- odometer_list = g_list_append(odometer_list, opc);
-
- return (struct osd_priv *) opc;
-}
-
-
+
struct cmd_interface {
- int width;
- struct graphics_gc *orange;
- int update_period; //in sec
- char* text;
- struct graphics_image *img;
- char*img_filename;
- char* command;
- int bReserved;
+ int width;
+ struct graphics_gc *orange;
+ int update_period; //in sec
+ char* text;
+ struct graphics_image *img;
+ char*img_filename;
+ char* command;
+ int bReserved;
};
-
-static void
-osd_cmd_interface_draw(struct osd_priv_common *opc, struct navit *nav,
- struct vehicle *v)
-{
- struct cmd_interface *this = (struct cmd_interface *)opc->data;
-
- struct point p;
- struct point bbox[4];
- struct graphics_gc *curr_color;
- struct attr navit;
- p.x = 0;
- p.y = 0;
- navit.type=attr_navit;
- navit.u.navit = opc->osd_item.navit;
-
- if(0==this->bReserved) {
- this->bReserved = 1;
- command_evaluate(&navit, this->command);
- this->bReserved = 0;
- }
-
- osd_fill_with_bgcolor(&opc->osd_item);
-
- //display image
- if(this->img) {
- graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, this->img);
- }
-
- //display text
- graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, this->text, 0x10000, 0, bbox, 0);
- p.x=(opc->osd_item.w-bbox[2].x)/2;
- p.y = opc->osd_item.h-opc->osd_item.h/10;
- curr_color = opc->osd_item.graphic_fg;
- if(this->text)
- draw_multiline_osd_text(this->text,&opc->osd_item, curr_color);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
-}
-
-
-
-static void
-osd_cmd_interface_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct cmd_interface *this = (struct cmd_interface *)opc->data;
-
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
-
- opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
-
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
- if(this->update_period>0) {
- event_add_timeout(this->update_period*1000, 1, callback_new_1(callback_cast(osd_cmd_interface_draw), opc));
- }
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast (osd_std_click), attr_button, &opc->osd_item));
-
- this->text = g_strdup("");
-}
-
-static int
-osd_cmd_interface_set_attr(struct osd_priv_common *opc, struct attr* attr)
-{
- struct cmd_interface *this_ = (struct cmd_interface *)opc->data;
-
- if(NULL==attr || NULL==this_) {
- return 0;
- }
-
- if(attr->type == attr_status_text) {
- if(this_->text) {
- g_free(this_->text);
- }
- if(attr->u.str) {
- this_->text = g_strdup(attr->u.str);
- }
- return 1;
- }
- if(attr->type == attr_src) {
- if(attr->u.str) {
- if((!this_->img_filename) || strcmp(this_->img_filename, graphics_icon_path(attr->u.str))) {
- //destroy old img, create new image
- if(this_->img) {
- graphics_image_free(opc->osd_item.gr, this_->img);
- }
- if(this_->img_filename) {
- g_free(this_->img_filename);
- }
- this_->img_filename = graphics_icon_path(attr->u.str);
- this_->img = graphics_image_new(opc->osd_item.gr, this_->img_filename);
- }
- }
- return 1;
- }
- return 0;
-}
-
-
-static struct osd_priv *
-osd_cmd_interface_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct cmd_interface *this = g_new0(struct cmd_interface, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = 120;
- opc->osd_item.rel_y = 20;
- opc->osd_item.rel_w = 60;
- opc->osd_item.rel_h = 80;
- opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_cmd_interface_draw);
- opc->spec_set_attr_func = osd_cmd_interface_set_attr;
- meth->set_attr = set_std_osd_attr;
+static void osd_cmd_interface_draw(struct osd_priv_common *opc, struct navit *nav,
+ struct vehicle *v) {
+ struct cmd_interface *this = (struct cmd_interface *)opc->data;
+
+ struct point p;
+ struct point bbox[4];
+ struct graphics_gc *curr_color;
+ struct attr navit;
+ p.x = 0;
+ p.y = 0;
+ navit.type=attr_navit;
+ navit.u.navit = opc->osd_item.navit;
+
+ if(0==this->bReserved) {
+ this->bReserved = 1;
+ command_evaluate(&navit, this->command);
+ this->bReserved = 0;
+ }
+
+ osd_fill_with_bgcolor(&opc->osd_item);
+
+ //display image
+ if(this->img) {
+ graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, this->img);
+ }
+
+ //display text
+ graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, this->text, 0x10000, 0, bbox, 0);
+ p.x=(opc->osd_item.w-bbox[2].x)/2;
+ p.y = opc->osd_item.h-opc->osd_item.h/10;
+ curr_color = opc->osd_item.graphic_fg;
+ if(this->text)
+ draw_multiline_osd_text(this->text,&opc->osd_item, curr_color);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+}
+
+
+
+static void osd_cmd_interface_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct cmd_interface *this = (struct cmd_interface *)opc->data;
+
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+
+ opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
+
+
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
+
+ if(this->update_period>0) {
+ event_add_timeout(this->update_period*1000, 1, callback_new_1(callback_cast(osd_cmd_interface_draw), opc));
+ }
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast (osd_std_click), attr_button, &opc->osd_item));
+
+ this->text = g_strdup("");
+}
+
+static int osd_cmd_interface_set_attr(struct osd_priv_common *opc, struct attr* attr) {
+ struct cmd_interface *this_ = (struct cmd_interface *)opc->data;
+
+ if(NULL==attr || NULL==this_) {
+ return 0;
+ }
- osd_set_std_attr(attrs, &opc->osd_item, 2);
+ if(attr->type == attr_status_text) {
+ if(this_->text) {
+ g_free(this_->text);
+ }
+ if(attr->u.str) {
+ this_->text = g_strdup(attr->u.str);
+ }
+ return 1;
+ }
+ if(attr->type == attr_src) {
+ if(attr->u.str) {
+ if((!this_->img_filename) || strcmp(this_->img_filename, graphics_icon_path(attr->u.str))) {
+ //destroy old img, create new image
+ if(this_->img) {
+ graphics_image_free(opc->osd_item.gr, this_->img);
+ }
+ if(this_->img_filename) {
+ g_free(this_->img_filename);
+ }
+ this_->img_filename = graphics_icon_path(attr->u.str);
+ this_->img = graphics_image_new(opc->osd_item.gr, this_->img_filename);
+ }
+ }
+ return 1;
+ }
+ return 0;
+}
+
+
+static struct osd_priv *osd_cmd_interface_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct cmd_interface *this = g_new0(struct cmd_interface, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
- attr = attr_search(attrs, NULL, attr_width);
- this->width=attr ? attr->u.num : 2;
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = 120;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
+ opc->osd_item.navit = nav;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_cmd_interface_draw);
- attr = attr_search(attrs, NULL, attr_update_period);
- this->update_period=attr ? attr->u.num : 5; //default update period is 5 seconds
+ opc->spec_set_attr_func = osd_cmd_interface_set_attr;
+ meth->set_attr = set_std_osd_attr;
- attr = attr_search(attrs, NULL, attr_command);
- this->command = attr ? g_strdup(attr->u.str) : g_strdup("");
+ osd_set_std_attr(attrs, &opc->osd_item, ITEM_HAS_TEXT);
- if(b_commandtable_added == 0) {
- navit_command_add_table(nav, commands, sizeof(commands)/sizeof(struct command_table));
- b_commandtable_added = 1;
- }
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_cmd_interface_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
+ attr = attr_search(attrs, NULL, attr_width);
+ this->width=attr ? attr->u.num : 2;
+
+ attr = attr_search(attrs, NULL, attr_update_period);
+ this->update_period=attr ? attr->u.num : 5; //default update period is 5 seconds
+
+ attr = attr_search(attrs, NULL, attr_command);
+ this->command = attr ? g_strdup(attr->u.str) : g_strdup("");
+
+ if(b_commandtable_added == 0) {
+ navit_command_add_table(nav, commands, sizeof(commands)/sizeof(struct command_table));
+ b_commandtable_added = 1;
+ }
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_cmd_interface_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
}
struct stopwatch {
- int width;
- struct graphics_gc *orange;
- struct callback *click_cb;
- struct color idle_color; //text color when counter is idle
-
- int bDisableReset;
- int bActive; //counting or not
- time_t current_base_time; //base time of currently measured time interval
- time_t sum_time; //sum of previous time intervals (except current intervals)
- time_t last_click_time; //time of last click (for double click handling)
+ int width;
+ struct graphics_gc *orange;
+ struct callback *click_cb;
+ struct color idle_color; //text color when counter is idle
+
+ int bDisableReset;
+ int bActive; //counting or not
+ time_t current_base_time; //base time of currently measured time interval
+ time_t sum_time; //sum of previous time intervals (except current intervals)
+ time_t last_click_time; //time of last click (for double click handling)
};
-static void
-osd_stopwatch_draw(struct osd_priv_common *opc, struct navit *nav,
- struct vehicle *v)
-{
- struct stopwatch *this = (struct stopwatch *)opc->data;
+static void osd_stopwatch_draw(struct osd_priv_common *opc, struct navit *nav,
+ struct vehicle *v) {
+ struct stopwatch *this = (struct stopwatch *)opc->data;
+
+ struct graphics_gc *curr_color;
+ char buffer[32]="00:00:00";
+ struct point p;
+ struct point bbox[4];
+ time_t total_sec,total_min,total_hours,total_days;
+ total_sec = this->sum_time;
+
+ osd_fill_with_bgcolor(&opc->osd_item);
+
+ if(this->bActive) {
+ total_sec += time(0)-this->current_base_time;
+ }
+
+ total_min = total_sec/60;
+ total_hours = total_min/60;
+ total_days = total_hours/24;
+
+ if (total_days==0) {
+ g_snprintf(buffer,32,"%02d:%02d:%02d", (int)total_hours%24, (int)total_min%60, (int)total_sec%60);
+ } else {
+ g_snprintf(buffer,32,"%02dd %02d:%02d:%02d",
+ (int)total_days, (int)total_hours%24, (int)total_min%60, (int)total_sec%60);
+ }
+
+ graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
+ p.x=(opc->osd_item.w-bbox[2].x)/2;
+ p.y = opc->osd_item.h-opc->osd_item.h/10;
+
+ curr_color = this->bActive?opc->osd_item.graphic_fg:this->orange;
+ graphics_draw_text(opc->osd_item.gr, curr_color, NULL, opc->osd_item.font, buffer, &p, 0x10000, 0);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+}
+
+
+static void osd_stopwatch_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button,
+ struct point *p) {
+ struct stopwatch *this = (struct stopwatch *)opc->data;
+
+ struct point bp = opc->osd_item.p;
+ osd_wrap_point(&bp, nav);
+ if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h
+ || !opc->osd_item.configured ) && !opc->osd_item.pressed)
+ return;
+ if (button != 1)
+ return;
+ if (navit_ignore_button(nav))
+ return;
+ if (!!pressed == !!opc->osd_item.pressed)
+ return;
+
+ if (pressed) { //single click handling
+
+ if(this->bActive) {
+ this->sum_time += time(0)-this->current_base_time;
+ this->current_base_time = 0;
+ } else {
+ this->current_base_time = time(0);
+ }
+
+ this->bActive ^= 1; //toggle active flag
+
+ if (this->last_click_time == time(0) && !this->bDisableReset) { //double click handling
+ this->bActive = 0;
+ this->current_base_time = 0;
+ this->sum_time = 0;
+ }
+
+ this->last_click_time = time(0);
+ }
+
+ osd_stopwatch_draw(opc, nav,NULL);
+}
+
+
+static void osd_stopwatch_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct stopwatch *this = (struct stopwatch *)opc->data;
+
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+
+ this->orange = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->orange, &this->idle_color);
+ graphics_gc_set_linewidth(this->orange, this->width);
+
+ opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
- struct graphics_gc *curr_color;
- char buffer[32]="00:00:00";
- struct point p;
- struct point bbox[4];
- time_t total_sec,total_min,total_hours,total_days;
- total_sec = this->sum_time;
- osd_fill_with_bgcolor(&opc->osd_item);
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
- if(this->bActive) {
- total_sec += time(0)-this->current_base_time;
- }
+ event_add_timeout(500, 1, callback_new_1(callback_cast(osd_stopwatch_draw), opc));
+
+ navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_stopwatch_click), attr_button, opc));
+
+ osd_stopwatch_draw(opc, nav, NULL);
+}
+
+static struct osd_priv *osd_stopwatch_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct stopwatch *this = g_new0(struct stopwatch, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+ struct color orange_color= {0xffff,0xa5a5,0x0000,0xffff};
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = 120;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
+ opc->osd_item.navit = nav;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_stopwatch_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ this->bActive = 0; //do not count on init
+ this->current_base_time = 0;
+ this->sum_time = 0;
+ this->last_click_time = 0;
+
+ osd_set_std_attr(attrs, &opc->osd_item, ITEM_HAS_TEXT);
+ attr = attr_search(attrs, NULL, attr_width);
+ this->width=attr ? attr->u.num : 2;
+ attr = attr_search(attrs, NULL, attr_idle_color);
+ this->idle_color=attr ? *attr->u.color : orange_color; // text idle_color defaults to orange
+ attr = attr_search(attrs, NULL, attr_disable_reset);
+ if (attr)
+ this->bDisableReset = attr->u.num;
+ else
+ this->bDisableReset = 0;
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_stopwatch_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
+}
+
+/**
+ * @brief Draw the compass on the OSD (includes north and destination direction)
+ *
+ * @param opc A contextual private data pointer (see struct osd_priv_common)
+ * @param nav The global navit object
+ * @param v The current vehicle
+ */
+static void osd_compass_draw(struct osd_priv_common *opc, struct navit *nav,
+ struct vehicle *v) {
+ struct compass *this = (struct compass *)opc->data;
- total_min = total_sec/60;
- total_hours = total_min/60;
- total_days = total_hours/24;
+ struct point p,bbox[4];
+ struct attr attr_dir, destination_attr, position_attr, imperial_attr;
+ double dir, vdir = 0;
+ char *buffer;
+ struct coord c1, c2;
+ enum projection pro;
+ int imperial=0;
- if (total_days==0) {
- g_snprintf(buffer,32,"%02d:%02d:%02d", (int)total_hours%24, (int)total_min%60, (int)total_sec%60);
- } else {
- g_snprintf(buffer,32,"%02dd %02d:%02d:%02d",
- (int)total_days, (int)total_hours%24, (int)total_min%60, (int)total_sec%60);
- }
+ if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL))
+ imperial=imperial_attr.u.num;
- graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
- p.x=(opc->osd_item.w-bbox[2].x)/2;
- p.y = opc->osd_item.h-opc->osd_item.h/10;
+ osd_fill_with_bgcolor(&opc->osd_item);
+ p.x = opc->osd_item.w/2;
+ p.y = opc->osd_item.w/2;
+ graphics_draw_circle(opc->osd_item.gr,
+ opc->osd_item.graphic_fg, &p, opc->osd_item.w*5/6);
+ if (v) {
+ if (vehicle_get_attr(v, attr_position_direction, &attr_dir, NULL)) {
+ vdir = *attr_dir.u.numd;
+ draw_compass(opc->osd_item.gr, this->north_gc, opc->osd_item.graphic_fg, &p, opc->osd_item.w/3,
+ -vdir); /* Draw a compass */
+ }
- curr_color = this->bActive?opc->osd_item.graphic_fg:this->orange;
- graphics_draw_text(opc->osd_item.gr, curr_color, NULL, opc->osd_item.font, buffer, &p, 0x10000, 0);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ if (navit_get_attr(nav, attr_destination, &destination_attr, NULL)
+ && vehicle_get_attr(v, attr_position_coord_geo,&position_attr, NULL)) {
+ pro = destination_attr.u.pcoord->pro;
+ transform_from_geo(pro, position_attr.u.coord_geo, &c1);
+ c2.x = destination_attr.u.pcoord->x;
+ c2.y = destination_attr.u.pcoord->y;
+ dir = atan2(c2.x - c1.x, c2.y - c1.y) * 180.0 / M_PI;
+ dir -= vdir;
+ draw_handle(opc->osd_item.gr, this->destination_dir_gc, &p, opc->osd_item.w/3,
+ dir); /* Draw the green arrow pointing to the destination */
+ buffer=format_distance(transform_distance(pro, &c1, &c2),"",imperial);
+ graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
+ p.x=(opc->osd_item.w-bbox[2].x)/2;
+ p.y = opc->osd_item.h-opc->osd_item.h/10;
+ graphics_draw_text(opc->osd_item.gr, this->destination_dir_gc, NULL, opc->osd_item.font, buffer, &p, 0x10000, 0);
+ g_free(buffer);
+ }
+ }
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
}
-static void
-osd_stopwatch_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button, struct point *p)
-{
- struct stopwatch *this = (struct stopwatch *)opc->data;
-
- struct point bp = opc->osd_item.p;
- osd_wrap_point(&bp, nav);
- if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h || !opc->osd_item.configured ) && !opc->osd_item.pressed)
- return;
- if (button != 1)
- return;
- if (navit_ignore_button(nav))
- return;
- if (!!pressed == !!opc->osd_item.pressed)
- return;
- if (pressed) { //single click handling
+static void osd_compass_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct compass *this = (struct compass *)opc->data;
+
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+
+ this->destination_dir_gc = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->destination_dir_gc, &this->destination_dir_color);
+ graphics_gc_set_linewidth(this->destination_dir_gc, this->width);
+
+ this->north_gc = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->north_gc, &this->north_color);
+ graphics_gc_set_linewidth(this->north_gc, this->width);
- if(this->bActive) {
- this->sum_time += time(0)-this->current_base_time;
- this->current_base_time = 0;
- } else {
- this->current_base_time = time(0);
- }
+ opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
- this->bActive ^= 1; //toggle active flag
-
- if (this->last_click_time == time(0) && !this->bDisableReset) { //double click handling
- this->bActive = 0;
- this->current_base_time = 0;
- this->sum_time = 0;
- }
-
- this->last_click_time = time(0);
- }
-
- osd_stopwatch_draw(opc, nav,NULL);
-}
-
-
-static void
-osd_stopwatch_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct stopwatch *this = (struct stopwatch *)opc->data;
-
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
-
- this->orange = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->orange, &this->idle_color);
- graphics_gc_set_linewidth(this->orange, this->width);
-
- opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
-
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
- event_add_timeout(500, 1, callback_new_1(callback_cast(osd_stopwatch_draw), opc));
-
- navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_stopwatch_click), attr_button, opc));
-
- osd_stopwatch_draw(opc, nav, NULL);
-}
-
-static struct osd_priv *
-osd_stopwatch_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct stopwatch *this = g_new0(struct stopwatch, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
- struct color orange_color={0xffff,0xa5a5,0x0000,0xffff};
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = 120;
- opc->osd_item.rel_y = 20;
- opc->osd_item.rel_w = 60;
- opc->osd_item.rel_h = 80;
- opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_stopwatch_draw);
- meth->set_attr = set_std_osd_attr;
-
- this->bActive = 0; //do not count on init
- this->current_base_time = 0;
- this->sum_time = 0;
- this->last_click_time = 0;
-
- osd_set_std_attr(attrs, &opc->osd_item, 2);
- attr = attr_search(attrs, NULL, attr_width);
- this->width=attr ? attr->u.num : 2;
- attr = attr_search(attrs, NULL, attr_idle_color);
- this->idle_color=attr ? *attr->u.color : orange_color; // text idle_color defaults to orange
- attr = attr_search(attrs, NULL, attr_disable_reset);
- if (attr)
- this->bDisableReset = attr->u.num;
- else
- this->bDisableReset = 0;
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_stopwatch_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
-}
-
-
-static void
-osd_compass_draw(struct osd_priv_common *opc, struct navit *nav,
- struct vehicle *v)
-{
- struct compass *this = (struct compass *)opc->data;
-
- struct point p,bbox[4];
- struct attr attr_dir, destination_attr, position_attr, imperial_attr;
- double dir, vdir = 0;
- char *buffer;
- struct coord c1, c2;
- enum projection pro;
- int imperial=0;
-
- if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL))
- imperial=imperial_attr.u.num;
-
- osd_fill_with_bgcolor(&opc->osd_item);
- p.x = opc->osd_item.w/2;
- p.y = opc->osd_item.w/2;
- graphics_draw_circle(opc->osd_item.gr,
- opc->osd_item.graphic_fg, &p, opc->osd_item.w*5/6);
- if (v) {
- if (vehicle_get_attr(v, attr_position_direction, &attr_dir, NULL)) {
- vdir = *attr_dir.u.numd;
- handle(opc->osd_item.gr, opc->osd_item.graphic_fg, &p, opc->osd_item.w/3, -vdir);
- }
-
- if (navit_get_attr(nav, attr_destination, &destination_attr, NULL)
- && vehicle_get_attr(v, attr_position_coord_geo,&position_attr, NULL)) {
- pro = destination_attr.u.pcoord->pro;
- transform_from_geo(pro, position_attr.u.coord_geo, &c1);
- c2.x = destination_attr.u.pcoord->x;
- c2.y = destination_attr.u.pcoord->y;
- dir = atan2(c2.x - c1.x, c2.y - c1.y) * 180.0 / M_PI;
- dir -= vdir;
- handle(opc->osd_item.gr, this->green, &p, opc->osd_item.w/3, dir);
- buffer=format_distance(transform_distance(pro, &c1, &c2),"",imperial);
- graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
- p.x=(opc->osd_item.w-bbox[2].x)/2;
- p.y = opc->osd_item.h-opc->osd_item.h/10;
- graphics_draw_text(opc->osd_item.gr, this->green, NULL, opc->osd_item.font, buffer, &p, 0x10000, 0);
- g_free(buffer);
- }
- }
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
-}
-
-
-
-static void
-osd_compass_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct color c;
-
- struct compass *this = (struct compass *)opc->data;
-
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
-
- this->green = graphics_gc_new(opc->osd_item.gr);
- c.r = 0;
- c.g = 65535;
- c.b = 0;
- c.a = 65535;
- graphics_gc_set_foreground(this->green, &c);
- graphics_gc_set_linewidth(this->green, this->width);
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_draw), attr_position_coord_geo, opc));
- if (opc->osd_item.command)
- navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_std_click), attr_button, &opc->osd_item));
-
- osd_compass_draw(opc, nav, NULL);
-}
-
-static struct osd_priv *
-osd_compass_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct compass *this = g_new0(struct compass, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = 20;
- opc->osd_item.rel_y = 20;
- opc->osd_item.rel_w = 60;
- opc->osd_item.rel_h = 80;
- opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_compass_draw);
- meth->set_attr = set_std_osd_attr;
- osd_set_std_attr(attrs, &opc->osd_item, 2);
- attr = attr_search(attrs, NULL, attr_width);
- this->width=attr ? attr->u.num : 2;
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_draw), attr_position_coord_geo, opc));
+ if (opc->osd_item.command)
+ navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_std_click), attr_button,
+ &opc->osd_item));
+
+ osd_compass_draw(opc, nav, NULL);
+}
+
+static struct osd_priv *osd_compass_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct compass *this = g_new0(struct compass, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+ struct color green_color= {0x0400,0xffff,0x1000,0xffff};
+ struct color red_color= {0xffff,0x0400,0x0400,0xffff};
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 80;
+ opc->osd_item.navit = nav;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_compass_draw);
+ meth->set_attr = set_std_osd_attr;
+ osd_set_std_attr(attrs, &opc->osd_item, ITEM_HAS_TEXT);
+ attr = attr_search(attrs, NULL, attr_width);
+ this->width=attr ? attr->u.num : 2;
+ attr = attr_search(attrs, NULL, attr_destination_dir_color);
+ this->destination_dir_color=attr ? *attr->u.color :
+ green_color; /* Pick destination color from configuration, default to green if unspecified */
+ attr = attr_search(attrs, NULL, attr_north_color);
+ this->north_color=attr ? *attr->u.color :
+ red_color; /* Pick north handle color from configuration, default to red if unspecified */
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
}
struct osd_button {
- int use_overlay;
- /* FIXME: do we need navit_init_cb? It is set in two places but never read.
- * osd_button_new sets it to osd_button_init (init callback), and
- * osd_button_init sets it to osd_std_click (click callback). */
- struct callback *draw_cb,*navit_init_cb;
- struct graphics_image *img;
- char *src_dir,*src;
+ int use_overlay;
+ /* FIXME: do we need navit_init_cb? It is set in two places but never read.
+ * osd_button_new sets it to osd_button_init (init callback), and
+ * osd_button_init sets it to osd_std_click (click callback). */
+ struct callback *draw_cb,*navit_init_cb;
+ struct graphics_image *img;
+ char *src_dir,*src;
};
@@ -1534,277 +1586,265 @@ struct osd_button {
* @param opc The OSD item
* @param img The image displayed by the item
*/
-static void
-osd_button_adjust_sizes(struct osd_priv_common *opc, struct graphics_image *img)
-{
- if(opc->osd_item.rel_w==ATTR_REL_RELSHIFT)
- opc->osd_item.w=img->width;
- if(opc->osd_item.rel_h==ATTR_REL_RELSHIFT)
- opc->osd_item.h=img->height;
-}
-
-static void
-osd_button_draw(struct osd_priv_common *opc, struct navit *nav)
-{
- struct osd_button *this = (struct osd_button *)opc->data;
-
- // FIXME: Do we need this check?
- if(navit_get_blocked(nav)&1)
- return;
-
- struct point p;
-
- if (this->use_overlay) {
- struct graphics_image *img;
- img=graphics_image_new_scaled(opc->osd_item.gr, this->src, opc->osd_item.w, opc->osd_item.h);
- osd_button_adjust_sizes(opc, img);
- p.x=(opc->osd_item.w-img->width)/2;
- p.y=(opc->osd_item.h-img->height)/2;
- osd_fill_with_bgcolor(&opc->osd_item);
- graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
- graphics_image_free(opc->osd_item.gr, img);
- } else {
- struct graphics *gra;
- gra = navit_get_graphics(nav);
- this->img = graphics_image_new_scaled(gra, this->src, opc->osd_item.w, opc->osd_item.h);
-
- if (!this->img) {
- dbg(lvl_warning, "failed to load '%s'\n", this->src);
- return;
- }
-
- osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav));
- osd_button_adjust_sizes(opc, this->img);
-
- p = opc->osd_item.p;
- p.x+=(opc->osd_item.w-this->img->width)/2;
- p.y+=(opc->osd_item.h-this->img->height)/2;
-
- if (!opc->osd_item.configured)
- return;
-
- graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, this->img);
- }
-}
-
-static void
-osd_button_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct osd_button *this = (struct osd_button *)opc->data;
-
- struct graphics *gra = navit_get_graphics(nav);
-
- /* translate properties to real size */
- osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav));
- /* most graphics plugins cannot accept w=0 or h=0. They require special w=-1 or h=-1 for "no size"*/
- if((opc->osd_item.w <= 0) || (opc->osd_item.h <=0))
- {
- opc->osd_item.w = -1;
- opc->osd_item.h = -1;
- }
- dbg(lvl_debug, "enter\n");
- dbg(lvl_debug, "Get: %s, %d, %d, %d, %d\n", this->src, opc->osd_item.rel_w, opc->osd_item.rel_h, opc->osd_item.w, opc->osd_item.h);
- this->img = graphics_image_new_scaled(gra, this->src, opc->osd_item.w, opc->osd_item.h);
- if (!this->img) {
- dbg(lvl_warning, "failed to load '%s'\n", this->src);
- return;
- }
- else
- {
- dbg(lvl_debug,"Got %s: %d, %d\n", this->src, this->img->width, this->img->height);
- }
- osd_button_adjust_sizes(opc, this->img);
- if (this->use_overlay) {
- struct graphics_image *img;
- struct point p;
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- img=graphics_image_new_scaled(opc->osd_item.gr, this->src, opc->osd_item.w, opc->osd_item.h);
- p.x=(opc->osd_item.w-this->img->width)/2;
- p.y=(opc->osd_item.h-this->img->height)/2;
- osd_fill_with_bgcolor(&opc->osd_item);
- graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
- graphics_image_free(opc->osd_item.gr, img);
- } else {
- osd_set_std_config(nav, &opc->osd_item);
- osd_set_keypress(nav, &opc->osd_item);
- opc->osd_item.gr=gra;
- opc->osd_item.graphic_bg=graphics_gc_new(opc->osd_item.gr);
- graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_button_draw), attr_postdraw, opc, nav));
- }
- navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_std_click), attr_button, &opc->osd_item));
- osd_button_draw(opc,nav);
-}
-
-static char *
-osd_button_icon_path(struct osd_button *this_, char *src)
-{
- if (!this_->src_dir)
- return graphics_icon_path(src);
- return g_strdup_printf("%s%s%s", this_->src_dir, G_DIR_SEPARATOR_S, src);
-}
-
-int
-osd_button_set_attr(struct osd_priv_common *opc, struct attr* attr)
-{
- struct osd_button *this_ = (struct osd_button *)opc->data;
-
- if(NULL==attr || NULL==this_) {
- return 0;
- }
- if(attr->type == attr_src) {
- struct navit *nav;
- struct graphics *gra;
- if(this_->src) {
- g_free(this_->src);
- }
- if(attr->u.str) {
- this_->src = osd_button_icon_path(this_, attr->u.str);
- }
- nav = opc->osd_item.navit;
- gra = navit_get_graphics(nav);
- this_->img = graphics_image_new_scaled(gra, this_->src, opc->osd_item.w, opc->osd_item.h);
- if (!this_->img) {
- dbg(lvl_warning, "failed to load '%s'\n", this_->src);
- return 0;
- }
-
- if(navit_get_blocked(nav)&1)
- return 1;
-
- osd_button_draw(opc,nav);
- navit_draw(opc->osd_item.navit);
- return 1;
- }
- return 0;
-}
-
-
-
-static struct osd_priv *
-osd_button_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct osd_button *this = g_new0(struct osd_button, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.navit = nav;
- opc->osd_item.meth.draw = osd_draw_cast(osd_button_draw);
- /*Value of 0% is stored in relative attributes as ATTR_REL_RELSHIFT, we use this value as "width/height unset" flag */
- opc->osd_item.rel_w = ATTR_REL_RELSHIFT;
- opc->osd_item.rel_h = ATTR_REL_RELSHIFT;
-
- meth->set_attr = set_std_osd_attr;
- opc->spec_set_attr_func = osd_button_set_attr;
-
- attr=attr_search(attrs, NULL, attr_use_overlay);
- if (attr)
- this->use_overlay=attr->u.num;
- osd_set_std_attr(attrs, &opc->osd_item, this->use_overlay ? 1:(1|16));
-
- if (!opc->osd_item.command) {
- dbg(lvl_error, "no command\n");
- goto error;
- }
- attr = attr_search(attrs, NULL, attr_src_dir);
- if (attr)
- this->src_dir=graphics_icon_path(attr->u.str);
- else
- this->src_dir=NULL;
- attr = attr_search(attrs, NULL, attr_src);
- if (!attr) {
- dbg(lvl_error, "no src\n");
- goto error;
- }
-
- this->src = osd_button_icon_path(this, attr->u.str);
-
- navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_button_init), attr_graphics_ready, opc));
-
- if(b_commandtable_added == 0) {
- navit_command_add_table(nav, commands, sizeof(commands)/sizeof(struct command_table));
- b_commandtable_added = 1;
- }
-
- return (struct osd_priv *) opc;
- error:
- g_free(this);
- g_free(opc);
- return NULL;
-}
-
-static void
-osd_image_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct osd_button *this = (struct osd_button *)opc->data;
-
- struct graphics *gra = navit_get_graphics(nav);
- dbg(lvl_debug, "enter\n");
- this->img = graphics_image_new(gra, this->src);
- if (!this->img) {
- dbg(lvl_warning, "failed to load '%s'\n", this->src);
- return;
- }
- osd_button_adjust_sizes(opc, this->img);
- if (this->use_overlay) {
- struct graphics_image *img;
- struct point p;
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- img=graphics_image_new(opc->osd_item.gr, this->src);
- p.x=(opc->osd_item.w-this->img->width)/2;
- p.y=(opc->osd_item.h-this->img->height)/2;
- osd_fill_with_bgcolor(&opc->osd_item);
- graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
- graphics_image_free(opc->osd_item.gr, img);
- } else {
- opc->osd_item.configured=1;
- opc->osd_item.gr=gra;
- opc->osd_item.graphic_bg=graphics_gc_new(opc->osd_item.gr);
- graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_button_draw), attr_postdraw, opc, nav));
- }
- osd_button_draw(opc,nav);
-}
-
-static struct osd_priv *
-osd_image_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct osd_button *this = g_new0(struct osd_button, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.navit = nav;
- opc->osd_item.meth.draw = osd_draw_cast(osd_button_draw);
- /*Value of 0% is stored in relative attributes as ATTR_REL_RELSHIFT, we use this value as "width/height unset" flag */
- opc->osd_item.rel_w = ATTR_REL_RELSHIFT;
- opc->osd_item.rel_h = ATTR_REL_RELSHIFT;
- meth->set_attr = set_std_osd_attr;
- opc->spec_set_attr_func = osd_button_set_attr;
-
- osd_set_std_attr(attrs, &opc->osd_item, 1);
-
- attr=attr_search(attrs, NULL, attr_use_overlay);
- if (attr)
- this->use_overlay=attr->u.num;
- attr = attr_search(attrs, NULL, attr_src);
- if (!attr) {
- dbg(lvl_error, "no src\n");
- goto error;
- }
-
- this->src = graphics_icon_path(attr->u.str);
-
- navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_image_init), attr_graphics_ready, opc));
-
- return (struct osd_priv *) opc;
- error:
- g_free(opc);
- g_free(this);
- return NULL;
+static void osd_button_adjust_sizes(struct osd_priv_common *opc, struct graphics_image *img) {
+ if(opc->osd_item.rel_w==ATTR_REL_RELSHIFT)
+ opc->osd_item.w=img->width;
+ if(opc->osd_item.rel_h==ATTR_REL_RELSHIFT)
+ opc->osd_item.h=img->height;
+}
+
+static void osd_button_draw(struct osd_priv_common *opc, struct navit *nav) {
+ struct osd_button *this = (struct osd_button *)opc->data;
+
+ // FIXME: Do we need this check?
+ if(navit_get_blocked(nav)&1)
+ return;
+
+ struct point p;
+
+ if (this->use_overlay) {
+ struct graphics_image *img;
+ img=graphics_image_new_scaled(opc->osd_item.gr, this->src, opc->osd_item.w, opc->osd_item.h);
+ osd_button_adjust_sizes(opc, img);
+ p.x=(opc->osd_item.w-img->width)/2;
+ p.y=(opc->osd_item.h-img->height)/2;
+ osd_fill_with_bgcolor(&opc->osd_item);
+ graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
+ graphics_image_free(opc->osd_item.gr, img);
+ } else {
+ struct graphics *gra;
+ gra = navit_get_graphics(nav);
+ this->img = graphics_image_new_scaled(gra, this->src, opc->osd_item.w, opc->osd_item.h);
+
+ if (!this->img) {
+ dbg(lvl_warning, "failed to load '%s'", this->src);
+ return;
+ }
+
+ osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav));
+ osd_button_adjust_sizes(opc, this->img);
+
+ p = opc->osd_item.p;
+ p.x+=(opc->osd_item.w-this->img->width)/2;
+ p.y+=(opc->osd_item.h-this->img->height)/2;
+
+ if (!opc->osd_item.configured)
+ return;
+
+ graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, this->img);
+ }
+}
+
+static void osd_button_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct osd_button *this = (struct osd_button *)opc->data;
+
+ struct graphics *gra = navit_get_graphics(nav);
+
+ /* translate properties to real size */
+ osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav));
+ /* most graphics plugins cannot accept w=0 or h=0. They require special w=-1 or h=-1 for "no size"*/
+ if((opc->osd_item.w <= 0) || (opc->osd_item.h <=0)) {
+ opc->osd_item.w = -1;
+ opc->osd_item.h = -1;
+ }
+ dbg(lvl_debug, "enter");
+ dbg(lvl_debug, "Get: %s, %d, %d, %d, %d", this->src, opc->osd_item.rel_w, opc->osd_item.rel_h, opc->osd_item.w,
+ opc->osd_item.h);
+ this->img = graphics_image_new_scaled(gra, this->src, opc->osd_item.w, opc->osd_item.h);
+ if (!this->img) {
+ dbg(lvl_warning, "failed to load '%s'", this->src);
+ return;
+ } else {
+ dbg(lvl_debug,"Got %s: %d, %d", this->src, this->img->width, this->img->height);
+ }
+ osd_button_adjust_sizes(opc, this->img);
+ if (this->use_overlay) {
+ struct graphics_image *img;
+ struct point p;
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+ img=graphics_image_new_scaled(opc->osd_item.gr, this->src, opc->osd_item.w, opc->osd_item.h);
+ p.x=(opc->osd_item.w-this->img->width)/2;
+ p.y=(opc->osd_item.h-this->img->height)/2;
+ osd_fill_with_bgcolor(&opc->osd_item);
+ graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ graphics_image_free(opc->osd_item.gr, img);
+ } else {
+ osd_set_std_config(nav, &opc->osd_item);
+ osd_set_keypress(nav, &opc->osd_item);
+ opc->osd_item.gr=gra;
+ opc->osd_item.graphic_bg=graphics_gc_new(opc->osd_item.gr);
+ graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_button_draw), attr_postdraw, opc, nav));
+ }
+ navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_std_click), attr_button,
+ &opc->osd_item));
+ osd_button_draw(opc,nav);
+}
+
+static char *osd_button_icon_path(struct osd_button *this_, char *src) {
+ if (!this_->src_dir)
+ return graphics_icon_path(src);
+ return g_strdup_printf("%s%s%s", this_->src_dir, G_DIR_SEPARATOR_S, src);
+}
+
+int osd_button_set_attr(struct osd_priv_common *opc, struct attr* attr) {
+ struct osd_button *this_ = (struct osd_button *)opc->data;
+
+ if(NULL==attr || NULL==this_) {
+ return 0;
+ }
+ if(attr->type == attr_src) {
+ struct navit *nav;
+ struct graphics *gra;
+ if(this_->src) {
+ g_free(this_->src);
+ }
+ if(attr->u.str) {
+ this_->src = osd_button_icon_path(this_, attr->u.str);
+ }
+ nav = opc->osd_item.navit;
+ gra = navit_get_graphics(nav);
+ this_->img = graphics_image_new_scaled(gra, this_->src, opc->osd_item.w, opc->osd_item.h);
+ if (!this_->img) {
+ dbg(lvl_warning, "failed to load '%s'", this_->src);
+ return 0;
+ }
+
+ if(navit_get_blocked(nav)&1)
+ return 1;
+
+ osd_button_draw(opc,nav);
+ navit_draw(opc->osd_item.navit);
+ return 1;
+ }
+ return 0;
+}
+
+
+
+static struct osd_priv *osd_button_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct osd_button *this = g_new0(struct osd_button, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+
+ opc->data = (void*)this;
+ opc->osd_item.navit = nav;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_button_draw);
+ /*Value of 0% is stored in relative attributes as ATTR_REL_RELSHIFT, we use this value as "width/height unset" flag */
+ opc->osd_item.rel_w = ATTR_REL_RELSHIFT;
+ opc->osd_item.rel_h = ATTR_REL_RELSHIFT;
+
+ meth->set_attr = set_std_osd_attr;
+ opc->spec_set_attr_func = osd_button_set_attr;
+
+ attr=attr_search(attrs, NULL, attr_use_overlay);
+ if (attr)
+ this->use_overlay=attr->u.num;
+
+ osd_set_std_attr(attrs, &opc->osd_item, this->use_overlay ? TRANSPARENT_BG:(TRANSPARENT_BG|DISABLE_OVERLAY));
+
+ if (!opc->osd_item.command) {
+ dbg(lvl_error, "no command");
+ goto error;
+ }
+ attr = attr_search(attrs, NULL, attr_src_dir);
+ if (attr)
+ this->src_dir=graphics_icon_path(attr->u.str);
+ else
+ this->src_dir=NULL;
+ attr = attr_search(attrs, NULL, attr_src);
+ if (!attr) {
+ dbg(lvl_error, "no src");
+ goto error;
+ }
+
+ this->src = osd_button_icon_path(this, attr->u.str);
+
+ navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_button_init), attr_graphics_ready,
+ opc));
+
+ if(b_commandtable_added == 0) {
+ navit_command_add_table(nav, commands, sizeof(commands)/sizeof(struct command_table));
+ b_commandtable_added = 1;
+ }
+
+ return (struct osd_priv *) opc;
+error:
+ g_free(this);
+ g_free(opc);
+ return NULL;
+}
+
+static void osd_image_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct osd_button *this = (struct osd_button *)opc->data;
+
+ struct graphics *gra = navit_get_graphics(nav);
+ dbg(lvl_debug, "enter");
+ this->img = graphics_image_new(gra, this->src);
+ if (!this->img) {
+ dbg(lvl_warning, "failed to load '%s'", this->src);
+ return;
+ }
+ osd_button_adjust_sizes(opc, this->img);
+ if (this->use_overlay) {
+ struct graphics_image *img;
+ struct point p;
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+ img=graphics_image_new(opc->osd_item.gr, this->src);
+ p.x=(opc->osd_item.w-this->img->width)/2;
+ p.y=(opc->osd_item.h-this->img->height)/2;
+ osd_fill_with_bgcolor(&opc->osd_item);
+ graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ graphics_image_free(opc->osd_item.gr, img);
+ } else {
+ osd_set_std_config(nav, &opc->osd_item);
+ opc->osd_item.gr=gra;
+ opc->osd_item.graphic_bg=graphics_gc_new(opc->osd_item.gr);
+ graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_button_draw), attr_postdraw, opc, nav));
+ }
+ osd_button_draw(opc,nav);
+}
+
+static struct osd_priv *osd_image_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct osd_button *this = g_new0(struct osd_button, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+
+ opc->data = (void*)this;
+ opc->osd_item.navit = nav;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_button_draw);
+ /*Value of 0% is stored in relative attributes as ATTR_REL_RELSHIFT, we use this value as "width/height unset" flag */
+ opc->osd_item.rel_w = ATTR_REL_RELSHIFT;
+ opc->osd_item.rel_h = ATTR_REL_RELSHIFT;
+ meth->set_attr = set_std_osd_attr;
+ opc->spec_set_attr_func = osd_button_set_attr;
+
+ attr=attr_search(attrs, NULL, attr_use_overlay);
+ if (attr)
+ this->use_overlay=attr->u.num;
+
+
+ osd_set_std_attr(attrs, &opc->osd_item, this->use_overlay ? TRANSPARENT_BG:(TRANSPARENT_BG|DISABLE_OVERLAY));
+
+ attr = attr_search(attrs, NULL, attr_src);
+ if (!attr) {
+ dbg(lvl_error, "no src");
+ goto error;
+ }
+
+ this->src = graphics_icon_path(attr->u.str);
+
+ navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_image_init), attr_graphics_ready,
+ opc));
+
+ return (struct osd_priv *) opc;
+error:
+ g_free(opc);
+ g_free(this);
+ return NULL;
}
@@ -1812,10 +1852,10 @@ osd_image_new(struct navit *nav, struct osd_methods *meth,
* Internal data for {@code navigation_status} OSD.
*/
struct navigation_status {
- char *icon_src; /**< Source for icon, with a placeholder */
- int icon_h;
- int icon_w;
- int last_status; /**< Last status displayed.
+ char *icon_src; /**< Source for icon, with a placeholder */
+ int icon_h;
+ int icon_w;
+ int last_status; /**< Last status displayed.
Apart from the usual values of {@code nav_status}, -2 is used to
indicate we have not yet received a status. */
};
@@ -1832,61 +1872,61 @@ struct navigation_status {
* @param status The status of the navigation engine (the value of the {@code nav_status} attribute)
*/
static void osd_navigation_status_draw_do(struct osd_priv_common *opc, int status) {
- struct navigation_status *this = (struct navigation_status *)opc->data;
- struct point p;
- int do_draw = opc->osd_item.do_draw;
- struct graphics_image *gr_image;
- char *image;
-
- /* When we're routing, the status will flip from 4 (routing) to 3 (recalculating) and back on
- * every position update. This hack prevents unnecessary (and even undesirable) updates.
- */
- int status2 = (status == 3) ? 4 : status;
-
-
- if ((status2 != this->last_status) && (status2 != status_invalid)) {
- this->last_status = status2;
- do_draw = 1;
- }
-
- if (do_draw) {
- osd_fill_with_bgcolor(&opc->osd_item);
- image = g_strdup_printf(this->icon_src, nav_status_to_text(status2));
- dbg(lvl_debug, "image=%s\n", image);
- gr_image =
- graphics_image_new_scaled(opc->osd_item.gr,
- image, this->icon_w,
- this->icon_h);
- if (!gr_image) {
- dbg(lvl_error,"failed to load %s in %dx%d\n",image,this->icon_w,this->icon_h);
- g_free(image);
- image = graphics_icon_path("unknown.png");
- gr_image =
- graphics_image_new_scaled(opc->
- osd_item.gr,
- image,
- this->icon_w,
- this->
- icon_h);
- }
- dbg(lvl_debug, "gr_image=%p\n", gr_image);
- if (gr_image) {
- p.x =
- (opc->osd_item.w -
- gr_image->width) / 2;
- p.y =
- (opc->osd_item.h -
- gr_image->height) / 2;
- graphics_draw_image(opc->osd_item.gr,
- opc->osd_item.
- graphic_fg, &p,
- gr_image);
- graphics_image_free(opc->osd_item.gr,
- gr_image);
- }
- g_free(image);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
- }
+ struct navigation_status *this = (struct navigation_status *)opc->data;
+ struct point p;
+ int do_draw = opc->osd_item.do_draw;
+ struct graphics_image *gr_image;
+ char *image;
+
+ /* When we're routing, the status will flip from 4 (routing) to 3 (recalculating) and back on
+ * every position update. This hack prevents unnecessary (and even undesirable) updates.
+ */
+ int status2 = (status == 3) ? 4 : status;
+
+
+ if ((status2 != this->last_status) && (status2 != status_invalid)) {
+ this->last_status = status2;
+ do_draw = 1;
+ }
+
+ if (do_draw) {
+ osd_fill_with_bgcolor(&opc->osd_item);
+ image = g_strdup_printf(this->icon_src, nav_status_to_text(status2));
+ dbg(lvl_debug, "image=%s", image);
+ gr_image =
+ graphics_image_new_scaled(opc->osd_item.gr,
+ image, this->icon_w,
+ this->icon_h);
+ if (!gr_image) {
+ dbg(lvl_error,"failed to load %s in %dx%d",image,this->icon_w,this->icon_h);
+ g_free(image);
+ image = graphics_icon_path("unknown.png");
+ gr_image =
+ graphics_image_new_scaled(opc->
+ osd_item.gr,
+ image,
+ this->icon_w,
+ this->
+ icon_h);
+ }
+ dbg(lvl_debug, "gr_image=%p", gr_image);
+ if (gr_image) {
+ p.x =
+ (opc->osd_item.w -
+ gr_image->width) / 2;
+ p.y =
+ (opc->osd_item.h -
+ gr_image->height) / 2;
+ graphics_draw_image(opc->osd_item.gr,
+ opc->osd_item.
+ graphic_fg, &p,
+ gr_image);
+ graphics_image_free(opc->osd_item.gr,
+ gr_image);
+ }
+ g_free(image);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ }
}
@@ -1901,15 +1941,15 @@ static void osd_navigation_status_draw_do(struct osd_priv_common *opc, int statu
* @param v The vehicle (not used but part of the prototype)
*/
static void osd_navigation_status_draw(struct osd_priv *osd, struct navit *navit, struct vehicle *v) {
- struct navigation *nav = NULL;
- struct attr attr;
+ struct navigation *nav = NULL;
+ struct attr attr;
- if (navit)
- nav = navit_get_navigation(navit);
- if (nav) {
- if (navigation_get_attr(nav, attr_nav_status, &attr, NULL))
- osd_navigation_status_draw_do((struct osd_priv_common *) osd, attr.u.num);
- }
+ if (navit)
+ nav = navit_get_navigation(navit);
+ if (nav) {
+ if (navigation_get_attr(nav, attr_nav_status, &attr, NULL))
+ osd_navigation_status_draw_do((struct osd_priv_common *) osd, attr.u.num);
+ }
}
@@ -1924,21 +1964,21 @@ static void osd_navigation_status_draw(struct osd_priv *osd, struct navit *navit
* @param navit The navit instance
*/
static void osd_navigation_status_init(struct osd_priv_common *opc, struct navit *navit) {
- struct navigation *nav = NULL;
- struct attr attr;
+ struct navigation *nav = NULL;
+ struct attr attr;
- dbg(lvl_debug, "enter, opc=%p\n", opc);
- osd_set_std_graphic(navit, &opc->osd_item, (struct osd_priv *)opc);
- if (navit)
- nav = navit_get_navigation(navit);
- if (nav) {
- navigation_register_callback(nav, attr_nav_status, callback_new_attr_1(callback_cast(osd_navigation_status_draw_do), attr_nav_status, opc));
- if (navigation_get_attr(nav, attr_nav_status, &attr, NULL))
- osd_navigation_status_draw_do(opc, attr.u.num);
- }
- else
- dbg(lvl_error, "navigation instance is NULL, OSD will never update\n");
- //navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item)); // FIXME do we need this?
+ dbg(lvl_debug, "enter, opc=%p", opc);
+ osd_set_std_graphic(navit, &opc->osd_item, (struct osd_priv *)opc);
+ if (navit)
+ nav = navit_get_navigation(navit);
+ if (nav) {
+ navigation_register_callback(nav, attr_nav_status, callback_new_attr_1(callback_cast(osd_navigation_status_draw_do),
+ attr_nav_status, opc));
+ if (navigation_get_attr(nav, attr_nav_status, &attr, NULL))
+ osd_navigation_status_draw_do(opc, attr.u.num);
+ } else
+ dbg(lvl_error, "navigation instance is NULL, OSD will never update");
+ //navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item)); // FIXME do we need this?
}
@@ -1957,325 +1997,308 @@ static void osd_navigation_status_init(struct osd_priv_common *opc, struct navit
* @param attrs The attributes for the new OSD
*/
static struct osd_priv *osd_navigation_status_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs) {
- struct navigation_status *this = g_new0(struct navigation_status, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = 20;
- opc->osd_item.rel_y = -80;
- opc->osd_item.rel_w = 70;
- opc->osd_item.navit = nav;
- opc->osd_item.rel_h = 70;
- opc->osd_item.font_size = 200; // FIXME may not be needed
- opc->osd_item.meth.draw = osd_draw_cast(osd_navigation_status_draw);
- meth->set_attr = set_std_osd_attr;
- osd_set_std_attr(attrs, &opc->osd_item, 0);
-
- this->icon_w = -1;
- this->icon_h = -1;
- this->last_status = status_invalid;
-
- attr = attr_search(attrs, NULL, attr_icon_w);
- if (attr)
- this->icon_w = attr->u.num;
-
- attr = attr_search(attrs, NULL, attr_icon_h);
- if (attr)
- this->icon_h = attr->u.num;
-
- attr = attr_search(attrs, NULL, attr_icon_src);
- if (attr) {
- struct file_wordexp *we;
- char **array;
- we = file_wordexp_new(attr->u.str);
- array = file_wordexp_get_array(we);
- this->icon_src = graphics_icon_path(array[0]);
- file_wordexp_destroy(we);
- } else {
- this->icon_src = graphics_icon_path("%s_wh.svg");
- }
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_navigation_status_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
+ struct navigation_status *this = g_new0(struct navigation_status, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = -80;
+ opc->osd_item.rel_w = 70;
+ opc->osd_item.navit = nav;
+ opc->osd_item.rel_h = 70;
+ opc->osd_item.font_size = 200; // FIXME may not be needed
+ opc->osd_item.meth.draw = osd_draw_cast(osd_navigation_status_draw);
+ meth->set_attr = set_std_osd_attr;
+ osd_set_std_attr(attrs, &opc->osd_item, 0);
+
+ this->icon_w = -1;
+ this->icon_h = -1;
+ this->last_status = status_invalid;
+
+ attr = attr_search(attrs, NULL, attr_icon_w);
+ if (attr)
+ this->icon_w = attr->u.num;
+
+ attr = attr_search(attrs, NULL, attr_icon_h);
+ if (attr)
+ this->icon_h = attr->u.num;
+
+ attr = attr_search(attrs, NULL, attr_icon_src);
+ if (attr) {
+ struct file_wordexp *we;
+ char **array;
+ we = file_wordexp_new(attr->u.str);
+ array = file_wordexp_get_array(we);
+ this->icon_src = graphics_icon_path(array[0]);
+ file_wordexp_destroy(we);
+ } else {
+ this->icon_src = graphics_icon_path("%s_wh.svg");
+ }
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_navigation_status_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
}
struct nav_next_turn {
- char *test_text;
- char *icon_src;
- int icon_h, icon_w, active;
- char *last_name;
- int level;
+ char *test_text;
+ char *icon_src;
+ int icon_h, icon_w, active;
+ char *last_name;
+ int level;
};
-static void
-osd_nav_next_turn_draw(struct osd_priv_common *opc, struct navit *navit,
- struct vehicle *v)
-{
- struct nav_next_turn *this = (struct nav_next_turn *)opc->data;
-
- struct point p;
- int do_draw = opc->osd_item.do_draw;
- struct navigation *nav = NULL;
- struct map *map = NULL;
- struct map_rect *mr = NULL;
- struct item *item = NULL;
- struct graphics_image *gr_image;
- char *image;
- char *name = "unknown";
- int level = this->level;
-
- if (navit)
- nav = navit_get_navigation(navit);
- if (nav)
- map = navigation_get_map(nav);
- if (map)
- mr = map_rect_new(map, NULL);
- if (mr)
- while ((item = map_rect_get_item(mr))
- && (item->type == type_nav_position || item->type == type_nav_none || level-- > 0));
- if (item) {
- name = item_to_name(item->type);
- dbg(lvl_debug, "name=%s\n", name);
- if (this->active != 1 || this->last_name != name) {
- this->active = 1;
- this->last_name = name;
- do_draw = 1;
- }
- } else {
- if (this->active != 0) {
- this->active = 0;
- do_draw = 1;
- }
- }
- if (mr)
- map_rect_destroy(mr);
-
- if (do_draw) {
- osd_fill_with_bgcolor(&opc->osd_item);
- if (this->active) {
- image = g_strdup_printf(this->icon_src, name);
- dbg(lvl_debug, "image=%s\n", image);
- gr_image =
- graphics_image_new_scaled(opc->osd_item.gr,
- image, this->icon_w,
- this->icon_h);
- if (!gr_image) {
- dbg(lvl_error,"failed to load %s in %dx%d\n",image,this->icon_w,this->icon_h);
- g_free(image);
- image = graphics_icon_path("unknown.png");
- gr_image =
- graphics_image_new_scaled(opc->
- osd_item.gr,
- image,
- this->icon_w,
- this->
- icon_h);
- }
- dbg(lvl_debug, "gr_image=%p\n", gr_image);
- if (gr_image) {
- p.x =
- (opc->osd_item.w -
- gr_image->width) / 2;
- p.y =
- (opc->osd_item.h -
- gr_image->height) / 2;
- graphics_draw_image(opc->osd_item.gr,
- opc->osd_item.
- graphic_fg, &p,
- gr_image);
- graphics_image_free(opc->osd_item.gr,
- gr_image);
- }
- g_free(image);
- }
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
- }
-}
-
-static void
-osd_nav_next_turn_init(struct osd_priv_common *opc, struct navit *nav)
-{
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_next_turn_draw), attr_position_coord_geo, opc));
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item));
- osd_nav_next_turn_draw(opc, nav, NULL);
-}
-
-static struct osd_priv *
-osd_nav_next_turn_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct nav_next_turn *this = g_new0(struct nav_next_turn, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = 20;
- opc->osd_item.rel_y = -80;
- opc->osd_item.rel_w = 70;
- opc->osd_item.navit = nav;
- opc->osd_item.rel_h = 70;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_nav_next_turn_draw);
- meth->set_attr = set_std_osd_attr;
- osd_set_std_attr(attrs, &opc->osd_item, 0);
-
- this->icon_w = -1;
- this->icon_h = -1;
- this->active = -1;
- this->level = 0;
-
- attr = attr_search(attrs, NULL, attr_icon_w);
- if (attr)
- this->icon_w = attr->u.num;
-
- attr = attr_search(attrs, NULL, attr_icon_h);
- if (attr)
- this->icon_h = attr->u.num;
-
- attr = attr_search(attrs, NULL, attr_icon_src);
- if (attr) {
- struct file_wordexp *we;
- char **array;
- we = file_wordexp_new(attr->u.str);
- array = file_wordexp_get_array(we);
- this->icon_src = graphics_icon_path(array[0]);
- file_wordexp_destroy(we);
- } else {
- this->icon_src = graphics_icon_path("%s_wh.svg");
- }
-
- attr = attr_search(attrs, NULL, attr_level);
- if (attr)
- this->level=attr->u.num;
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_next_turn_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
-}
-
-struct nav_toggle_announcer
-{
- int w,h;
- /* FIXME this is actually the click callback, which is set once but never read. Do we need this? */
- struct callback *navit_init_cb;
- char *icon_src;
- int icon_h, icon_w, active, last_state;
+static void osd_nav_next_turn_draw(struct osd_priv_common *opc, struct navit *navit,
+ struct vehicle *v) {
+ struct nav_next_turn *this = (struct nav_next_turn *)opc->data;
+
+ struct point p;
+ int do_draw = opc->osd_item.do_draw;
+ struct navigation *nav = NULL;
+ struct map *map = NULL;
+ struct map_rect *mr = NULL;
+ struct item *item = NULL;
+ struct graphics_image *gr_image;
+ char *image;
+ char *name = "unknown";
+ int level = this->level;
+
+ if (navit)
+ nav = navit_get_navigation(navit);
+ if (nav)
+ map = navigation_get_map(nav);
+ if (map)
+ mr = map_rect_new(map, NULL);
+ if (mr)
+ while ((item = map_rect_get_item(mr))
+ && (item->type == type_nav_position || item->type == type_nav_none || level-- > 0));
+ if (item) {
+ name = item_to_name(item->type);
+ dbg(lvl_debug, "name=%s", name);
+ if (this->active != 1 || this->last_name != name) {
+ this->active = 1;
+ this->last_name = name;
+ do_draw = 1;
+ }
+ } else {
+ if (this->active != 0) {
+ this->active = 0;
+ do_draw = 1;
+ }
+ }
+ if (mr)
+ map_rect_destroy(mr);
+
+ if (do_draw) {
+ osd_fill_with_bgcolor(&opc->osd_item);
+ if (this->active) {
+ image = g_strdup_printf(this->icon_src, name);
+ dbg(lvl_debug, "image=%s", image);
+ gr_image =
+ graphics_image_new_scaled(opc->osd_item.gr,
+ image, this->icon_w,
+ this->icon_h);
+ if (!gr_image) {
+ dbg(lvl_error,"failed to load %s in %dx%d",image,this->icon_w,this->icon_h);
+ g_free(image);
+ image = graphics_icon_path("unknown.png");
+ gr_image =
+ graphics_image_new_scaled(opc->
+ osd_item.gr,
+ image,
+ this->icon_w,
+ this->
+ icon_h);
+ }
+ dbg(lvl_debug, "gr_image=%p", gr_image);
+ if (gr_image) {
+ p.x =
+ (opc->osd_item.w -
+ gr_image->width) / 2;
+ p.y =
+ (opc->osd_item.h -
+ gr_image->height) / 2;
+ graphics_draw_image(opc->osd_item.gr,
+ opc->osd_item.
+ graphic_fg, &p,
+ gr_image);
+ graphics_image_free(opc->osd_item.gr,
+ gr_image);
+ }
+ g_free(image);
+ }
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ }
+}
+
+static void osd_nav_next_turn_init(struct osd_priv_common *opc, struct navit *nav) {
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_next_turn_draw), attr_position_coord_geo, opc));
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item));
+ osd_nav_next_turn_draw(opc, nav, NULL);
+}
+
+static struct osd_priv *osd_nav_next_turn_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct nav_next_turn *this = g_new0(struct nav_next_turn, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = -80;
+ opc->osd_item.rel_w = 70;
+ opc->osd_item.navit = nav;
+ opc->osd_item.rel_h = 70;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_nav_next_turn_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ osd_set_std_attr(attrs, &opc->osd_item, 0);
+
+ this->icon_w = -1;
+ this->icon_h = -1;
+ this->active = -1;
+ this->level = 0;
+
+ attr = attr_search(attrs, NULL, attr_icon_w);
+ if (attr)
+ this->icon_w = attr->u.num;
+
+ attr = attr_search(attrs, NULL, attr_icon_h);
+ if (attr)
+ this->icon_h = attr->u.num;
+
+ attr = attr_search(attrs, NULL, attr_icon_src);
+ if (attr) {
+ struct file_wordexp *we;
+ char **array;
+ we = file_wordexp_new(attr->u.str);
+ array = file_wordexp_get_array(we);
+ this->icon_src = graphics_icon_path(array[0]);
+ file_wordexp_destroy(we);
+ } else {
+ this->icon_src = graphics_icon_path("%s_wh.svg");
+ }
+
+ attr = attr_search(attrs, NULL, attr_level);
+ if (attr)
+ this->level=attr->u.num;
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_next_turn_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
+}
+
+struct nav_toggle_announcer {
+ int w,h;
+ /* FIXME this is actually the click callback, which is set once but never read. Do we need this? */
+ struct callback *navit_init_cb;
+ char *icon_src;
+ int active, last_state;
};
-static void
-osd_nav_toggle_announcer_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v)
-{
- struct nav_toggle_announcer *this = (struct nav_toggle_announcer *)opc->data;
-
- struct point p;
- int do_draw = opc->osd_item.do_draw;
- struct graphics_image *gr_image;
- char *path;
- char *gui_sound_off = "gui_sound_off";
- char *gui_sound_on = "gui_sound";
+static void osd_nav_toggle_announcer_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v) {
+ struct nav_toggle_announcer *this = (struct nav_toggle_announcer *)opc->data;
+
+ struct point p;
+ int do_draw = opc->osd_item.do_draw;
+ struct graphics_image *gr_image;
+ char *path;
+ char *sound_off = "sound_off";
+ char *sound_on = "sound_on";
struct attr attr, speechattr;
- if (!navit_get_attr(navit, attr_speech, &speechattr, NULL))
- {
- dbg(lvl_error, "No speech plugin available, toggle_announcer disabled.\n");
+ if (!navit_get_attr(navit, attr_speech, &speechattr, NULL)) {
+ dbg(lvl_error, "No speech plugin available, toggle_announcer disabled.");
return;
}
if (!speech_get_attr(speechattr.u.speech, attr_active, &attr, NULL))
attr.u.num = 1;
this->active = attr.u.num;
- if(this->active != this->last_state)
- {
+ if(this->active != this->last_state) {
this->last_state = this->active;
do_draw = 1;
}
- if (do_draw)
- {
- graphics_draw_mode(opc->osd_item.gr, draw_mode_begin);
- p.x = 0;
- p.y = 0;
- graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, opc->osd_item.w, opc->osd_item.h);
+ if (do_draw) {
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_begin);
+ p.x = 0;
+ p.y = 0;
+ graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, opc->osd_item.w, opc->osd_item.h);
- if (this->active)
- path = g_strdup_printf(this->icon_src, gui_sound_on);
+ if (this->active)
+ path = g_strdup_printf(this->icon_src, sound_on);
else
- path = g_strdup_printf(this->icon_src, gui_sound_off);
-
- gr_image = graphics_image_new_scaled(opc->osd_item.gr, path, this->icon_w, this->icon_h);
- if (!gr_image)
- {
+ path = g_strdup_printf(this->icon_src, sound_off);
+
+ gr_image = graphics_image_new_scaled(opc->osd_item.gr, path, opc->osd_item.w, opc->osd_item.h);
+ if (!gr_image) {
g_free(path);
path = graphics_icon_path("unknown.png");
- gr_image = graphics_image_new_scaled(opc->osd_item.gr, path, this->icon_w, this->icon_h);
+ gr_image = graphics_image_new_scaled(opc->osd_item.gr, path, opc->osd_item.w, opc->osd_item.h);
}
-
- dbg(lvl_debug, "gr_image=%p\n", gr_image);
-
- if (gr_image)
- {
+
+ dbg(lvl_debug, "gr_image=%p", gr_image);
+
+ if (gr_image) {
p.x = (opc->osd_item.w - gr_image->width) / 2;
p.y = (opc->osd_item.h - gr_image->height) / 2;
graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_fg, &p, gr_image);
graphics_image_free(opc->osd_item.gr, gr_image);
}
-
- g_free(path);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
- }
-}
-
-static void
-osd_nav_toggle_announcer_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct nav_toggle_announcer *this = (struct nav_toggle_announcer *)opc->data;
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_toggle_announcer_draw), attr_speech, opc));
- navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item));
- osd_nav_toggle_announcer_draw(opc, nav, NULL);
+ g_free(path);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ }
}
-static struct osd_priv *
-osd_nav_toggle_announcer_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs)
-{
- struct nav_toggle_announcer *this = g_new0(struct nav_toggle_announcer, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
- char *command = "announcer_toggle()";
-
- opc->data = (void*)this;
- opc->osd_item.rel_w = 48;
- opc->osd_item.rel_h = 48;
- opc->osd_item.rel_x = -64;
- opc->osd_item.rel_y = 76;
- opc->osd_item.navit = nav;
- opc->osd_item.meth.draw = osd_draw_cast(osd_nav_toggle_announcer_draw);
- meth->set_attr = set_std_osd_attr;
-
- osd_set_std_attr(attrs, &opc->osd_item, 0);
-
- this->icon_w = -1;
- this->icon_h = -1;
- this->last_state = -1;
-
- attr = attr_search(attrs, NULL, attr_icon_src);
- if (attr) {
- struct file_wordexp *we;
- char **array;
- we = file_wordexp_new(attr->u.str);
- array = file_wordexp_get_array(we);
- this->icon_src = g_strdup(array[0]);
- file_wordexp_destroy(we);
- } else
- this->icon_src = graphics_icon_path("%s_32.xpm");
+static void osd_nav_toggle_announcer_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct nav_toggle_announcer *this = (struct nav_toggle_announcer *)opc->data;
+
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_toggle_announcer_draw), attr_speech, opc));
+ navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast(osd_std_click), attr_button,
+ &opc->osd_item));
+ osd_nav_toggle_announcer_draw(opc, nav, NULL);
+}
+
+static struct osd_priv *osd_nav_toggle_announcer_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs) {
+ struct nav_toggle_announcer *this = g_new0(struct nav_toggle_announcer, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+ char *command = "announcer_toggle()";
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_w = 48;
+ opc->osd_item.rel_h = 48;
+ opc->osd_item.rel_x = -64;
+ opc->osd_item.rel_y = 76;
+ opc->osd_item.navit = nav;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_nav_toggle_announcer_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ osd_set_std_attr(attrs, &opc->osd_item, 0);
+ opc->osd_item.color_bg.a = 0x0000;
+
+ this->last_state = -1;
+
+ attr = attr_search(attrs, NULL, attr_icon_src);
+ if (attr) {
+ struct file_wordexp *we;
+ char **array;
+ we = file_wordexp_new(attr->u.str);
+ array = file_wordexp_get_array(we);
+ this->icon_src = graphics_icon_path(array[0]);
+ file_wordexp_destroy(we);
+ } else
+ this->icon_src = graphics_icon_path("%s");
- opc->osd_item.command = g_strdup(command);
+ opc->osd_item.command = g_strdup(command);
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_toggle_announcer_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_toggle_announcer_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
}
enum osd_speed_warner_eAnnounceState {eNoWarn=0,eWarningTold=1};
@@ -2285,325 +2308,307 @@ char*camdir_t_strs[] = {"All dir.","UNI-dir","BI-dir"};
enum cam_dir_t {CAMDIR_ALL=0, CAMDIR_ONE, CAMDIR_TWO};
struct osd_speed_cam_entry {
- double lon;
- double lat;
- enum camera_t cam_type;
- int speed_limit;
- enum cam_dir_t cam_dir;
- int direction;
+ double lon;
+ double lat;
+ enum camera_t cam_type;
+ int speed_limit;
+ enum cam_dir_t cam_dir;
+ int direction;
};
struct osd_speed_cam {
- int width;
- int flags;
- struct graphics_gc *orange;
- struct graphics_gc *red;
- struct color idle_color;
-
- int announce_on;
- enum osd_speed_warner_eAnnounceState announce_state;
- char *text; //text of label attribute for this osd
+ int width;
+ int flags;
+ struct graphics_gc *orange;
+ struct graphics_gc *red;
+ struct color idle_color;
+
+ int announce_on;
+ enum osd_speed_warner_eAnnounceState announce_state;
+ char *text; //text of label attribute for this osd
};
-static double
-angle_diff(int firstAngle,int secondAngle)
-{
- double difference = secondAngle - firstAngle;
- while (difference < -180) difference += 360;
- while (difference > 180) difference -= 360;
- return difference;
-}
-
-static void
-osd_speed_cam_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v)
-{
- struct osd_speed_cam *this_ = (struct osd_speed_cam *)opc->data;
-
- struct attr position_attr,vehicle_attr,imperial_attr;
- struct point bbox[4];
- struct attr speed_attr;
- struct vehicle* curr_vehicle = v;
- struct coord curr_coord;
- struct coord cam_coord;
- struct mapset* ms;
-
- double dCurrDist = -1;
- int dir_idx = -1;
- int dir = -1;
- int spd = -1;
- int idx = -1;
- double speed = -1;
- int bFound = 0;
-
- int dst=2000;
- int dstsq=dst*dst;
- struct map_selection sel;
- struct map_rect *mr;
- struct mapset_handle *msh;
- struct map *map;
- struct item *item;
-
- struct attr attr_dir;
- struct graphics_gc *curr_color;
- int ret_attr = 0;
- int imperial=0;
-
- if (navit_get_attr(navit, attr_imperial, &imperial_attr, NULL))
- imperial=imperial_attr.u.num;
-
-
- if(navit) {
- navit_get_attr(navit, attr_vehicle, &vehicle_attr, NULL);
- }
- else {
- return;
- }
- if (vehicle_attr.u.vehicle) {
- curr_vehicle = vehicle_attr.u.vehicle;
- }
-
- if(0==curr_vehicle)
- return;
-
- if(!(ms=navit_get_mapset(navit))) {
- return;
- }
-
- ret_attr = vehicle_get_attr(curr_vehicle, attr_position_coord_geo,&position_attr, NULL);
- if(0==ret_attr) {
- return;
- }
-
- transform_from_geo(projection_mg, position_attr.u.coord_geo, &curr_coord);
-
- sel.next=NULL;
- sel.order=18;
- sel.range.min=type_tec_common;
- sel.range.max=type_tec_common;
- sel.u.c_rect.lu.x=curr_coord.x-dst;
- sel.u.c_rect.lu.y=curr_coord.y+dst;
- sel.u.c_rect.rl.x=curr_coord.x+dst;
- sel.u.c_rect.rl.y=curr_coord.y-dst;
-
- msh=mapset_open(ms);
- while ((map=mapset_next(msh, 1))) {
- struct attr attr;
- if(map_get_attr(map, attr_type, &attr, NULL)) {
- if( strcmp("csv", attr.u.str) && strcmp("binfile", attr.u.str)) {
- continue;
- }
- }
- else {
- continue;
- }
- mr=map_rect_new(map, &sel);
- if (!mr)
- continue;
- while ((item=map_rect_get_item(mr))) {
- struct coord cn;
- if (item->type == type_tec_common && item_coord_get(item, &cn, 1)) {
- int dist=transform_distance_sq(&cn, &curr_coord);
- if (dist < dstsq) {
- struct attr tec_attr;
- bFound = 1;
- dstsq=dist;
- dCurrDist = sqrt(dist);
- cam_coord = cn;
- idx = -1;
- if(item_attr_get(item,attr_tec_type,&tec_attr)) {
- idx = tec_attr.u.num;
- }
- dir_idx = -1;
- if(item_attr_get(item,attr_tec_dirtype,&tec_attr)) {
- dir_idx = tec_attr.u.num;
- }
- dir= 0;
- if(item_attr_get(item,attr_tec_direction,&tec_attr)) {
- dir = tec_attr.u.num;
- }
- spd= 0;
- if(item_attr_get(item,attr_maxspeed,&tec_attr)) {
- spd = tec_attr.u.num;
- }
- }
- }
- }
- map_rect_destroy(mr);
- }
- mapset_close(msh);
-
- if(bFound && (idx==-1 || this_->flags & (1<<(idx-1))) ) {
- dCurrDist = transform_distance(projection_mg, &curr_coord, &cam_coord);
- ret_attr = vehicle_get_attr(curr_vehicle,attr_position_speed,&speed_attr, NULL);
+static double angle_diff(int firstAngle,int secondAngle) {
+ double difference = secondAngle - firstAngle;
+ while (difference < -180) difference += 360;
+ while (difference > 180) difference -= 360;
+ return difference;
+}
+
+static void osd_speed_cam_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v) {
+ struct osd_speed_cam *this_ = (struct osd_speed_cam *)opc->data;
+
+ struct attr position_attr,vehicle_attr,imperial_attr;
+ struct point bbox[4];
+ struct attr speed_attr;
+ struct vehicle* curr_vehicle = v;
+ struct coord curr_coord;
+ struct coord cam_coord;
+ struct mapset* ms;
+
+ double dCurrDist = -1;
+ int dir_idx = -1;
+ int dir = -1;
+ int spd = -1;
+ int idx = -1;
+ double speed = -1;
+ int bFound = 0;
+
+ int dst=2000;
+ int dstsq=dst*dst;
+ struct map_selection sel;
+ struct map_rect *mr;
+ struct mapset_handle *msh;
+ struct map *map;
+ struct item *item;
+
+ struct attr attr_dir;
+ struct graphics_gc *curr_color;
+ int ret_attr = 0;
+ int imperial=0;
+
+ if (navit_get_attr(navit, attr_imperial, &imperial_attr, NULL))
+ imperial=imperial_attr.u.num;
+
+
+ if(navit) {
+ navit_get_attr(navit, attr_vehicle, &vehicle_attr, NULL);
+ } else {
+ return;
+ }
+ if (vehicle_attr.u.vehicle) {
+ curr_vehicle = vehicle_attr.u.vehicle;
+ }
+
+ if(0==curr_vehicle)
+ return;
+
+ if(!(ms=navit_get_mapset(navit))) {
+ return;
+ }
+
+ ret_attr = vehicle_get_attr(curr_vehicle, attr_position_coord_geo,&position_attr, NULL);
if(0==ret_attr) {
- graphics_overlay_disable(opc->osd_item.gr,1);
- return;
- }
- if (opc->osd_item.configured) {
- graphics_overlay_disable(opc->osd_item.gr,0);
- }
- speed = *speed_attr.u.numd;
- if(dCurrDist <= speed*750.0/130.0) { //at speed 130 distance limit is 750m
- if(this_->announce_state==eNoWarn && this_->announce_on) {
- this_->announce_state=eWarningTold; //warning told
- navit_say(navit, _("Look out! Camera!"));
- }
- }
- else {
- this_->announce_state=eNoWarn;
- }
-
- if(this_->text) {
- char buffer [256]="";
- char buffer2[256]="";
- char dir_str[16];
- char spd_str[16];
- buffer [0] = 0;
- buffer2[0] = 0;
-
- osd_fill_with_bgcolor(&opc->osd_item);
-
- str_replace(buffer,this_->text,"${distance}",format_distance(dCurrDist,"",imperial));
- str_replace(buffer2,buffer,"${camera_type}",(0<=idx && idx<=CAM_TRAFFIPAX)?camera_t_strs[idx]:"");
- str_replace(buffer,buffer2,"${camera_dir}",(0<=dir_idx && dir_idx<=CAMDIR_TWO)?camdir_t_strs[dir_idx]:"");
- sprintf(dir_str,"%d",dir);
- sprintf(spd_str,"%d",spd);
- str_replace(buffer2,buffer,"${direction}",dir_str);
- str_replace(buffer,buffer2,"${speed_limit}",spd_str);
-
- graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
- curr_color = this_->orange;
- //tolerance is +-20 degrees
- if(
- dir_idx==CAMDIR_ONE &&
- dCurrDist <= speed*750.0/130.0 &&
- vehicle_get_attr(v, attr_position_direction, &attr_dir, NULL) &&
- fabs(angle_diff(dir,*attr_dir.u.numd))<=20 ) {
- curr_color = this_->red;
- }
- //tolerance is +-20 degrees in both directions
- else if(
- dir_idx==CAMDIR_TWO &&
- dCurrDist <= speed*750.0/130.0 &&
- vehicle_get_attr(v, attr_position_direction, &attr_dir, NULL) &&
- (fabs(angle_diff(dir,*attr_dir.u.numd))<=20 || fabs(angle_diff(dir+180,*attr_dir.u.numd))<=20 )) {
- curr_color = this_->red;
- }
- else if(dCurrDist <= speed*750.0/130.0) {
- curr_color = this_->red;
- }
- draw_multiline_osd_text(buffer,&opc->osd_item, curr_color);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
- }
- }
- else {
- graphics_overlay_disable(opc->osd_item.gr,1);
- }
-}
-
-static void
-osd_speed_cam_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct osd_speed_cam *this = (struct osd_speed_cam *)opc->data;
-
- struct color red_color={0xffff,0x0000,0x0000,0xffff};
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
-
- this->red = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->red, &red_color);
- graphics_gc_set_linewidth(this->red, this->width);
-
- this->orange = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->orange, &this->idle_color);
- graphics_gc_set_linewidth(this->orange, this->width);
-
- opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
-
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_cam_draw), attr_position_coord_geo, opc));
-
-}
-
-static struct osd_priv *
-osd_speed_cam_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs)
-{
-
- struct color default_color={0xffff,0xa5a5,0x0000,0xffff};
-
- struct osd_speed_cam *this = g_new0(struct osd_speed_cam, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.p.x = 120;
- opc->osd_item.p.y = 20;
- opc->osd_item.w = 60;
- opc->osd_item.h = 80;
- opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_speed_cam_draw);
- meth->set_attr = set_std_osd_attr;
-
- osd_set_std_attr(attrs, &opc->osd_item, 2);
- attr = attr_search(attrs, NULL, attr_width);
- this->width=attr ? attr->u.num : 2;
- attr = attr_search(attrs, NULL, attr_idle_color);
- this->idle_color=attr ? *attr->u.color : default_color; // text idle_color defaults to orange
-
- attr = attr_search(attrs, NULL, attr_label);
- if (attr) {
- this->text = g_strdup(attr->u.str);
- }
- else
- this->text = NULL;
-
- attr = attr_search(attrs, NULL, attr_announce_on);
- if (attr) {
- this->announce_on = attr->u.num;
- }
- else {
- this->announce_on = 1; //announce by default
- }
-
- attr = attr_search(attrs, NULL, attr_flags);
- if (attr) {
- this->flags = attr->u.num;
- }
- else {
- this->flags = -1; //every cam type is on by default
- }
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_cam_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
+ return;
+ }
+
+ transform_from_geo(projection_mg, position_attr.u.coord_geo, &curr_coord);
+
+ sel.next=NULL;
+ sel.order=18;
+ sel.range.min=type_tec_common;
+ sel.range.max=type_tec_common;
+ sel.u.c_rect.lu.x=curr_coord.x-dst;
+ sel.u.c_rect.lu.y=curr_coord.y+dst;
+ sel.u.c_rect.rl.x=curr_coord.x+dst;
+ sel.u.c_rect.rl.y=curr_coord.y-dst;
+
+ msh=mapset_open(ms);
+ while ((map=mapset_next(msh, 1))) {
+ struct attr attr;
+ if(map_get_attr(map, attr_type, &attr, NULL)) {
+ if( strcmp("csv", attr.u.str) && strcmp("binfile", attr.u.str)) {
+ continue;
+ }
+ } else {
+ continue;
+ }
+ mr=map_rect_new(map, &sel);
+ if (!mr)
+ continue;
+ while ((item=map_rect_get_item(mr))) {
+ struct coord cn;
+ if (item->type == type_tec_common && item_coord_get(item, &cn, 1)) {
+ int dist=transform_distance_sq(&cn, &curr_coord);
+ if (dist < dstsq) {
+ struct attr tec_attr;
+ bFound = 1;
+ dstsq=dist;
+ dCurrDist = sqrt(dist);
+ cam_coord = cn;
+ idx = -1;
+ if(item_attr_get(item,attr_tec_type,&tec_attr)) {
+ idx = tec_attr.u.num;
+ }
+ dir_idx = -1;
+ if(item_attr_get(item,attr_tec_dirtype,&tec_attr)) {
+ dir_idx = tec_attr.u.num;
+ }
+ dir= 0;
+ if(item_attr_get(item,attr_tec_direction,&tec_attr)) {
+ dir = tec_attr.u.num;
+ }
+ spd= 0;
+ if(item_attr_get(item,attr_maxspeed,&tec_attr)) {
+ spd = tec_attr.u.num;
+ }
+ }
+ }
+ }
+ map_rect_destroy(mr);
+ }
+ mapset_close(msh);
+
+ if(bFound && (idx==-1 || this_->flags & (1<<(idx-1))) ) {
+ dCurrDist = transform_distance(projection_mg, &curr_coord, &cam_coord);
+ ret_attr = vehicle_get_attr(curr_vehicle,attr_position_speed,&speed_attr, NULL);
+ if(0==ret_attr) {
+ graphics_overlay_disable(opc->osd_item.gr,1);
+ return;
+ }
+ if (opc->osd_item.configured) {
+ graphics_overlay_disable(opc->osd_item.gr,0);
+ }
+ speed = *speed_attr.u.numd;
+ if(dCurrDist <= speed*750.0/130.0) { //at speed 130 distance limit is 750m
+ if(this_->announce_state==eNoWarn && this_->announce_on) {
+ this_->announce_state=eWarningTold; //warning told
+ navit_say(navit, _("Look out! Camera!"));
+ }
+ } else {
+ this_->announce_state=eNoWarn;
+ }
+
+ if(this_->text) {
+ char buffer [256]="";
+ char buffer2[256]="";
+ char dir_str[16];
+ char spd_str[16];
+ buffer [0] = 0;
+ buffer2[0] = 0;
+
+ osd_fill_with_bgcolor(&opc->osd_item);
+
+ str_replace(buffer,this_->text,"${distance}",format_distance(dCurrDist,"",imperial));
+ str_replace(buffer2,buffer,"${camera_type}",(0<=idx && idx<=CAM_TRAFFIPAX)?camera_t_strs[idx]:"");
+ str_replace(buffer,buffer2,"${camera_dir}",(0<=dir_idx && dir_idx<=CAMDIR_TWO)?camdir_t_strs[dir_idx]:"");
+ sprintf(dir_str,"%d",dir);
+ sprintf(spd_str,"%d",spd);
+ str_replace(buffer2,buffer,"${direction}",dir_str);
+ str_replace(buffer,buffer2,"${speed_limit}",spd_str);
+
+ graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
+ curr_color = this_->orange;
+ //tolerance is +-20 degrees
+ if(
+ dir_idx==CAMDIR_ONE &&
+ dCurrDist <= speed*750.0/130.0 &&
+ vehicle_get_attr(v, attr_position_direction, &attr_dir, NULL) &&
+ fabs(angle_diff(dir,*attr_dir.u.numd))<=20 ) {
+ curr_color = this_->red;
+ }
+ //tolerance is +-20 degrees in both directions
+ else if(
+ dir_idx==CAMDIR_TWO &&
+ dCurrDist <= speed*750.0/130.0 &&
+ vehicle_get_attr(v, attr_position_direction, &attr_dir, NULL) &&
+ (fabs(angle_diff(dir,*attr_dir.u.numd))<=20 || fabs(angle_diff(dir+180,*attr_dir.u.numd))<=20 )) {
+ curr_color = this_->red;
+ } else if(dCurrDist <= speed*750.0/130.0) {
+ curr_color = this_->red;
+ }
+ draw_multiline_osd_text(buffer,&opc->osd_item, curr_color);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ }
+ } else {
+ graphics_overlay_disable(opc->osd_item.gr,1);
+ }
+}
+
+static void osd_speed_cam_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct osd_speed_cam *this = (struct osd_speed_cam *)opc->data;
+
+ struct color red_color= {0xffff,0x0000,0x0000,0xffff};
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+
+ this->red = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->red, &red_color);
+ graphics_gc_set_linewidth(this->red, this->width);
+
+ this->orange = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->orange, &this->idle_color);
+ graphics_gc_set_linewidth(this->orange, this->width);
+
+ opc->osd_item.graphic_fg = graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(opc->osd_item.graphic_fg, &opc->osd_item.text_color);
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
+
+
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->width);
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_cam_draw), attr_position_coord_geo, opc));
+
+}
+
+static struct osd_priv *osd_speed_cam_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs) {
+
+ struct color default_color= {0xffff,0xa5a5,0x0000,0xffff};
+
+ struct osd_speed_cam *this = g_new0(struct osd_speed_cam, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+
+ opc->data = (void*)this;
+ opc->osd_item.p.x = 120;
+ opc->osd_item.p.y = 20;
+ opc->osd_item.w = 60;
+ opc->osd_item.h = 80;
+ opc->osd_item.navit = nav;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_speed_cam_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ osd_set_std_attr(attrs, &opc->osd_item, ITEM_HAS_TEXT);
+ attr = attr_search(attrs, NULL, attr_width);
+ this->width=attr ? attr->u.num : 2;
+ attr = attr_search(attrs, NULL, attr_idle_color);
+ this->idle_color=attr ? *attr->u.color : default_color; // text idle_color defaults to orange
+
+ attr = attr_search(attrs, NULL, attr_label);
+ if (attr) {
+ this->text = g_strdup(attr->u.str);
+ } else
+ this->text = NULL;
+
+ attr = attr_search(attrs, NULL, attr_announce_on);
+ if (attr) {
+ this->announce_on = attr->u.num;
+ } else {
+ this->announce_on = 1; //announce by default
+ }
+
+ attr = attr_search(attrs, NULL, attr_flags);
+ if (attr) {
+ this->flags = attr->u.num;
+ } else {
+ this->flags = -1; //every cam type is on by default
+ }
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_cam_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
}
struct osd_speed_warner {
- struct graphics_gc *red;
- struct graphics_gc *green;
- struct graphics_gc *grey;
- struct graphics_gc *black;
- int width;
- int active;
- int d;
- double speed_exceed_limit_offset;
- double speed_exceed_limit_percent;
- int announce_on;
- enum osd_speed_warner_eAnnounceState announce_state;
- int bTextOnly;
- struct graphics_image *img_active,*img_passive,*img_off;
- char* label_str;
- int timeout;
- int wait_before_warn;
- struct callback *click_cb;
+ struct graphics_gc *red;
+ struct graphics_gc *green;
+ struct graphics_gc *grey;
+ struct graphics_gc *black;
+ int width;
+ int active;
+ int d;
+ double speed_exceed_limit_offset;
+ double speed_exceed_limit_percent;
+ int announce_on;
+ enum osd_speed_warner_eAnnounceState announce_state;
+ int bTextOnly;
+ struct graphics_image *img_active,*img_passive,*img_off;
+ char* label_str;
+ int timeout;
+ int wait_before_warn;
+ struct callback *click_cb;
};
-static void
-osd_speed_warner_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v)
-{
+static void osd_speed_warner_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v) {
struct osd_speed_warner *this = (struct osd_speed_warner *)opc->data;
struct point p,bbox[4];
@@ -2635,15 +2640,15 @@ osd_speed_warner_draw(struct osd_priv_common *opc, struct navit *navit, struct v
item=tracking_get_current_item(tracking);
- if(navit) {
- if (navit_get_attr(navit, attr_imperial, &imperial_attr, NULL))
- imperial=imperial_attr.u.num;
- }
+ if(navit) {
+ if (navit_get_attr(navit, attr_imperial, &imperial_attr, NULL))
+ imperial=imperial_attr.u.num;
+ }
flags=tracking_get_current_flags(tracking);
if (flags && (*flags & AF_SPEED_LIMIT) && tracking_get_attr(tracking, attr_maxspeed, &maxspeed_attr, NULL)) {
routespeed = maxspeed_attr.u.num;
- osm_data = 1;
+ osm_data = 1;
}
if (routespeed == -1) {
struct vehicleprofile *prof=navit_get_vehicleprofile(navit);
@@ -2660,29 +2665,28 @@ osd_speed_warner_draw(struct osd_priv_common *opc, struct navit *navit, struct v
if( -1 != tracking_speed && -1 != routespeed ) {
char*routespeed_str = format_speed(routespeed,"","value",imperial);
g_snprintf(text,16,"%s%s",osm_data ? "" : "~",routespeed_str);
- g_free(routespeed_str);
+ g_free(routespeed_str);
if( this->speed_exceed_limit_offset+routespeed<tracking_speed &&
- (100.0+this->speed_exceed_limit_percent)/100.0*routespeed<tracking_speed ) {
+ (100.0+this->speed_exceed_limit_percent)/100.0*routespeed<tracking_speed ) {
if(this->announce_state==eNoWarn && this->announce_on) {
- if(this->wait_before_warn>0){
- this->wait_before_warn--;
- }else{
- this->announce_state=eWarningTold; //warning told
- navit_say(navit,_("Please decrease your speed"));
+ if(this->wait_before_warn>0) {
+ this->wait_before_warn--;
+ } else {
+ this->announce_state=eWarningTold; //warning told
+ navit_say(navit,_("Please decrease your speed"));
}
}
- }else{
- /* reset speed warning */
- this->wait_before_warn = this->timeout;
+ } else {
+ /* reset speed warning */
+ this->wait_before_warn = this->timeout;
}
if( tracking_speed <= routespeed ) {
this->announce_state=eNoWarn; //no warning
osd_color = this->green;
- img = this->img_passive;
- }
- else {
+ img = this->img_passive;
+ } else {
osd_color = this->red;
- img = this->img_active;
+ img = this->img_active;
}
} else {
osd_color = this-> grey;
@@ -2696,159 +2700,155 @@ osd_speed_warner_draw(struct osd_priv_common *opc, struct navit *navit, struct v
this->announce_state = eNoWarn;
}
if(this->img_active && this->img_passive && this->img_off) {
- struct point p;
- p.x=(opc->osd_item.w-img->width)/2;
- p.y=(opc->osd_item.h-img->height)/2;
- graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
- }
- else if(0==this->bTextOnly) {
- graphics_draw_circle(opc->osd_item.gr, osd_color, &p, this->d-this->width*2 );
+ struct point p;
+ p.x=(opc->osd_item.w-img->width)/2;
+ p.y=(opc->osd_item.h-img->height)/2;
+ graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
+ } else if(0==this->bTextOnly) {
+ graphics_draw_circle(opc->osd_item.gr, osd_color, &p, this->d-this->width*2 );
}
- graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, text, 0x10000, 0, bbox, 0);
- p.x=(opc->osd_item.w-bbox[2].x)/2;
- p.y=(opc->osd_item.h+bbox[2].y)/2-bbox[2].y;
- graphics_draw_text(opc->osd_item.gr, osd_color, NULL, opc->osd_item.font, text, &p, 0x10000, 0);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, text, 0x10000, 0, bbox, 0);
+ p.x=(opc->osd_item.w-bbox[2].x)/2;
+ p.y=(opc->osd_item.h+bbox[2].y)/2-bbox[2].y;
+ graphics_draw_text(opc->osd_item.gr, osd_color, NULL, opc->osd_item.font, text, &p, 0x10000, 0);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
}
-static void
-osd_speed_warner_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button, struct point *p)
-{
+static void osd_speed_warner_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button,
+ struct point *p) {
struct osd_speed_warner *this = (struct osd_speed_warner *)opc->data;
struct point bp = opc->osd_item.p;
osd_wrap_point(&bp, nav);
- if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h || !opc->osd_item.configured ) && !opc->osd_item.pressed)
- return;
+ if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h
+ || !opc->osd_item.configured ) && !opc->osd_item.pressed)
+ return;
if (button != 1)
- return;
+ return;
if (navit_ignore_button(nav))
- return;
+ return;
if (!!pressed == !!opc->osd_item.pressed)
- return;
+ return;
this->active = !this->active;
- osd_speed_warner_draw(opc, nav, NULL);
+ osd_speed_warner_draw(opc, nav, NULL);
}
-static void
-osd_speed_warner_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct osd_speed_warner *this = (struct osd_speed_warner *)opc->data;
+static void osd_speed_warner_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct osd_speed_warner *this = (struct osd_speed_warner *)opc->data;
- struct color red_color={0xffff,0,0,0xffff};
- struct color green_color={0,0xffff,0,0xffff};
- struct color grey_color={0x8888,0x8888,0x8888,0x8888};
- struct color black_color={0x1111,0x1111,0x1111,0x9999};
+ struct color red_color= {0xffff,0,0,0xffff};
+ struct color green_color= {0,0xffff,0,0xffff};
+ struct color grey_color= {0x8888,0x8888,0x8888,0x8888};
+ struct color black_color= {0x1111,0x1111,0x1111,0x9999};
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_warner_draw), attr_position_coord_geo, opc));
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_warner_draw), attr_position_coord_geo, opc));
navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_speed_warner_click), attr_button, opc));
- this->d=opc->osd_item.w;
- if (opc->osd_item.h < this->d)
- this->d=opc->osd_item.h;
- this->width=this->d/10;
- this->wait_before_warn = this->timeout;
- if(this->label_str && !strncmp("images:",this->label_str,7)) {
- char *tok1=NULL, *tok2=NULL, *tok3=NULL;
- strtok(this->label_str,":");
- tok1 = strtok(NULL,":");
- if(tok1) {
+ this->d=opc->osd_item.w;
+ if (opc->osd_item.h < this->d)
+ this->d=opc->osd_item.h;
+ this->width=this->d/10;
+ this->wait_before_warn = this->timeout;
+ if(this->label_str && !strncmp("images:",this->label_str,7)) {
+ char *tok1=NULL, *tok2=NULL, *tok3=NULL;
+ strtok(this->label_str,":");
+ tok1 = strtok(NULL,":");
+ if(tok1) {
tok2 = strtok(NULL,":");
- }
- if(tok1 && tok2) {
+ }
+ if(tok1 && tok2) {
tok3 = strtok(NULL,":");
- }
- if(tok1 && tok2 && tok3) {
- tok1 = graphics_icon_path(tok1);
- tok2 = graphics_icon_path(tok2);
- tok3 = graphics_icon_path(tok3);
+ }
+ if(tok1 && tok2 && tok3) {
+ tok1 = graphics_icon_path(tok1);
+ tok2 = graphics_icon_path(tok2);
+ tok3 = graphics_icon_path(tok3);
this->img_active = graphics_image_new(opc->osd_item.gr, tok1);
this->img_passive = graphics_image_new(opc->osd_item.gr, tok2);
this->img_off = graphics_image_new(opc->osd_item.gr, tok3);
- g_free(tok1);
- g_free(tok2);
- g_free(tok3);
- }
- }
-
- g_free(this->label_str);
- this->label_str = NULL;
-
- graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->d/2-2 /*-this->width*/ );
-
- this->red=graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->red, &red_color);
- graphics_gc_set_linewidth(this->red, this->width);
-
- this->green=graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->green, &green_color);
- graphics_gc_set_linewidth(this->green, this->width-2);
-
- this->grey=graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->grey, &grey_color);
- graphics_gc_set_linewidth(this->grey, this->width);
-
- this->black=graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->black, &black_color);
- graphics_gc_set_linewidth(this->black, this->width);
-
- osd_speed_warner_draw(opc, nav, NULL);
-}
-
-static struct osd_priv *
-osd_speed_warner_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs)
-{
- struct osd_speed_warner *this=g_new0(struct osd_speed_warner, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.rel_x=-80;
- opc->osd_item.rel_y=20;
- opc->osd_item.rel_w=60;
- opc->osd_item.rel_h=60;
- opc->osd_item.navit = nav;
- this->active=-1;
- opc->osd_item.meth.draw = osd_draw_cast(osd_speed_warner_draw);
- meth->set_attr = set_std_osd_attr;
-
- attr = attr_search(attrs, NULL, attr_speed_exceed_limit_offset);
- if (attr) {
- this->speed_exceed_limit_offset = attr->u.num;
- } else
- this->speed_exceed_limit_offset = 15; //by default 15 km/h
-
- attr = attr_search(attrs, NULL, attr_speed_exceed_limit_percent);
- if (attr) {
- this->speed_exceed_limit_percent = attr->u.num;
+ g_free(tok1);
+ g_free(tok2);
+ g_free(tok3);
+ }
+ }
+
+ g_free(this->label_str);
+ this->label_str = NULL;
+
+ graphics_gc_set_linewidth(opc->osd_item.graphic_fg, this->d/2-2 /*-this->width*/ );
+
+ this->red=graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->red, &red_color);
+ graphics_gc_set_linewidth(this->red, this->width);
+
+ this->green=graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->green, &green_color);
+ graphics_gc_set_linewidth(this->green, this->width-2);
+
+ this->grey=graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->grey, &grey_color);
+ graphics_gc_set_linewidth(this->grey, this->width);
+
+ this->black=graphics_gc_new(opc->osd_item.gr);
+ graphics_gc_set_foreground(this->black, &black_color);
+ graphics_gc_set_linewidth(this->black, this->width);
+
+ osd_speed_warner_draw(opc, nav, NULL);
+}
+
+static struct osd_priv *osd_speed_warner_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs) {
+ struct osd_speed_warner *this=g_new0(struct osd_speed_warner, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_x=-80;
+ opc->osd_item.rel_y=20;
+ opc->osd_item.rel_w=60;
+ opc->osd_item.rel_h=60;
+ opc->osd_item.navit = nav;
+ this->active=-1;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_speed_warner_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ attr = attr_search(attrs, NULL, attr_speed_exceed_limit_offset);
+ if (attr) {
+ this->speed_exceed_limit_offset = attr->u.num;
+ } else
+ this->speed_exceed_limit_offset = 15; //by default 15 km/h
+
+ attr = attr_search(attrs, NULL, attr_speed_exceed_limit_percent);
+ if (attr) {
+ this->speed_exceed_limit_percent = attr->u.num;
} else
- this->speed_exceed_limit_percent = 10; //by default factor of 1.1
+ this->speed_exceed_limit_percent = 10; //by default factor of 1.1
- this->bTextOnly = 0; //by default display graphics also
- attr = attr_search(attrs, NULL, attr_label);
- if (attr) {
- this->label_str = g_strdup(attr->u.str);
- if (!strcmp("text_only",attr->u.str)) {
+ this->bTextOnly = 0; //by default display graphics also
+ attr = attr_search(attrs, NULL, attr_label);
+ if (attr) {
+ this->label_str = g_strdup(attr->u.str);
+ if (!strcmp("text_only",attr->u.str)) {
this->bTextOnly = 1;
- }
- }
- attr = attr_search(attrs, NULL, attr_timeout);
- if (attr)
- this->timeout = attr->u.num;
- else
- this->timeout = 10; // 10s timeout by default
-
- attr = attr_search(attrs, NULL, attr_announce_on);
- if (attr)
- this->announce_on = attr->u.num;
- else
- this->announce_on = 1; //announce by default
- osd_set_std_attr(attrs, &opc->osd_item, 2);
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_warner_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
+ }
+ }
+ attr = attr_search(attrs, NULL, attr_timeout);
+ if (attr)
+ this->timeout = attr->u.num;
+ else
+ this->timeout = 10; // 10s timeout by default
+
+ attr = attr_search(attrs, NULL, attr_announce_on);
+ if (attr)
+ this->announce_on = attr->u.num;
+ else
+ this->announce_on = 1; //announce by default
+
+ osd_set_std_attr(attrs, &opc->osd_item, ITEM_HAS_TEXT);
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_warner_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
}
struct osd_text_item {
@@ -2864,11 +2864,11 @@ struct osd_text_item {
};
struct osd_text {
- int active;
- char *text;
- int align;
- char *last;
- struct osd_text_item *items;
+ int active;
+ char *text;
+ int align;
+ char *last;
+ struct osd_text_item *items;
};
@@ -2876,160 +2876,131 @@ struct osd_text {
* @brief Formats a text attribute
*
* Returns the formatted current value of an attribute as a string
- *
+ *
* @param attr The attribute to be formatted
* @param format A string specifying how to format the attribute. Allowed format strings depend on the attribute; this member can be NULL.
* @param imperial True to convert values to imperial, false to return metric values
* @returns The formatted value
*/
-static char *
-osd_text_format_attr(struct attr *attr, char *format, int imperial)
-{
- struct tm tm, text_tm, text_tm0;
- time_t textt;
- int days=0;
- char buffer[1024];
-
- switch (attr->type) {
- case attr_position_speed:
- return format_speed(*attr->u.numd,"",format,imperial);
- case attr_position_height:
- case attr_position_direction:
- return format_float_0(*attr->u.numd);
- case attr_position_magnetic_direction:
- return g_strdup_printf("%ld",attr->u.num);
- case attr_position_coord_geo:
- if ((!format) || (!strcmp(format,"pos_degminsec")))
- {
- coord_format(attr->u.coord_geo->lat,attr->u.coord_geo->lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- else if (!strcmp(format,"pos_degmin"))
- {
- coord_format(attr->u.coord_geo->lat,attr->u.coord_geo->lng,DEGREES_MINUTES,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- else if (!strcmp(format,"pos_deg"))
- {
- coord_format(attr->u.coord_geo->lat,attr->u.coord_geo->lng,DEGREES_DECIMAL,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- else if (!strcmp(format,"lat_degminsec"))
- {
- coord_format(attr->u.coord_geo->lat,360,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- else if (!strcmp(format,"lat_degmin"))
- {
- coord_format(attr->u.coord_geo->lat,360,DEGREES_MINUTES,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- else if (!strcmp(format,"lat_deg"))
- {
- coord_format(attr->u.coord_geo->lat,360,DEGREES_DECIMAL,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- else if (!strcmp(format,"lng_degminsec"))
- {
- coord_format(360,attr->u.coord_geo->lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- else if (!strcmp(format,"lng_degmin"))
- {
- coord_format(360,attr->u.coord_geo->lng,DEGREES_MINUTES,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- else if (!strcmp(format,"lng_deg"))
- {
- coord_format(360,attr->u.coord_geo->lng,DEGREES_DECIMAL,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- else
- { // fall back to pos_degminsec
- coord_format(attr->u.coord_geo->lat,attr->u.coord_geo->lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
- return g_strdup(buffer);
- }
- case attr_destination_time:
- if (!format || (strcmp(format,"arrival") && strcmp(format,"remaining")))
- break;
- textt = time(NULL);
- tm = *localtime(&textt);
- if (!strcmp(format,"remaining")) {
- textt-=tm.tm_hour*3600+tm.tm_min*60+tm.tm_sec;
- tm = *localtime(&textt);
- }
- textt += attr->u.num / 10;
- text_tm = *localtime(&textt);
- if (tm.tm_year != text_tm.tm_year || tm.tm_mon != text_tm.tm_mon || tm.tm_mday != text_tm.tm_mday) {
- text_tm0 = text_tm;
- text_tm0.tm_sec = 0;
- text_tm0.tm_min = 0;
- text_tm0.tm_hour = 0;
- tm.tm_sec = 0;
- tm.tm_min = 0;
- tm.tm_hour = 0;
- days = (mktime(&text_tm0) - mktime(&tm) + 43200) / 86400;
- }
- return format_time(&text_tm, days);
- case attr_length:
- case attr_destination_length:
- if (!format)
- break;
- if (!strcmp(format,"named"))
- return format_distance(attr->u.num,"",imperial);
- if (!strcmp(format,"value") || !strcmp(format,"unit")) {
- char *ret,*tmp=format_distance(attr->u.num," ",imperial);
- char *pos=strchr(tmp,' ');
- if (! pos)
- return tmp;
- *pos++='\0';
- if (!strcmp(format,"value"))
- return tmp;
- ret=g_strdup(pos);
- g_free(tmp);
- return ret;
- }
- case attr_position_time_iso8601:
- if ((!format) || (!strcmp(format,"iso8601")))
- {
- break;
- }
- else
- {
- if (strstr(format, "local;") == format)
- {
- textt = iso8601_to_secs(attr->u.str);
- memcpy ((void *) &tm, (void *) localtime(&textt), sizeof(tm));
- strftime(buffer, sizeof(buffer), (char *)(format + 6), &tm);
- }
- else if ((sscanf(format, "%*c%2d:%2d;", &(text_tm.tm_hour), &(text_tm.tm_min)) == 2) && (strchr("+-", format[0])))
- {
- if (strchr("-", format[0]))
- {
- textt = iso8601_to_secs(attr->u.str) - text_tm.tm_hour * 3600 - text_tm.tm_min * 60;
- }
- else
- {
- textt = iso8601_to_secs(attr->u.str) + text_tm.tm_hour * 3600 + text_tm.tm_min * 60;
- }
- memcpy ((void *) &tm, (void *) gmtime(&textt), sizeof(tm));
- strftime(buffer, sizeof(buffer), &format[strcspn(format, ";") + 1], &tm);
- }
- else
- {
- sscanf(attr->u.str, "%4d-%2d-%2dT%2d:%2d:%2d", &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday), &(tm.tm_hour), &(tm.tm_min), &(tm.tm_sec));
- // the tm structure definition is kinda weird and needs some extra voodoo
- tm.tm_year-=1900; tm.tm_mon--;
- // get weekday and day of the year
- mktime(&tm);
- strftime(buffer, sizeof(buffer), format, &tm);
- }
- return g_strdup(buffer);
- }
- default:
- break;
- }
- return attr_to_text(attr, NULL, 1);
+static char *osd_text_format_attr(struct attr *attr, char *format, int imperial) {
+ struct tm tm, text_tm, text_tm0;
+ time_t textt;
+ int days=0;
+ char buffer[1024];
+
+ switch (attr->type) {
+ case attr_position_speed:
+ return format_speed(*attr->u.numd,"",format,imperial);
+ case attr_position_height:
+ case attr_position_direction:
+ return format_float_0(*attr->u.numd);
+ case attr_position_magnetic_direction:
+ return g_strdup_printf("%ld",attr->u.num);
+ case attr_position_coord_geo:
+ if ((!format) || (!strcmp(format,"pos_degminsec"))) {
+ coord_format(attr->u.coord_geo->lat,attr->u.coord_geo->lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ } else if (!strcmp(format,"pos_degmin")) {
+ coord_format(attr->u.coord_geo->lat,attr->u.coord_geo->lng,DEGREES_MINUTES,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ } else if (!strcmp(format,"pos_deg")) {
+ coord_format(attr->u.coord_geo->lat,attr->u.coord_geo->lng,DEGREES_DECIMAL,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ } else if (!strcmp(format,"lat_degminsec")) {
+ coord_format(attr->u.coord_geo->lat,360,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ } else if (!strcmp(format,"lat_degmin")) {
+ coord_format(attr->u.coord_geo->lat,360,DEGREES_MINUTES,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ } else if (!strcmp(format,"lat_deg")) {
+ coord_format(attr->u.coord_geo->lat,360,DEGREES_DECIMAL,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ } else if (!strcmp(format,"lng_degminsec")) {
+ coord_format(360,attr->u.coord_geo->lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ } else if (!strcmp(format,"lng_degmin")) {
+ coord_format(360,attr->u.coord_geo->lng,DEGREES_MINUTES,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ } else if (!strcmp(format,"lng_deg")) {
+ coord_format(360,attr->u.coord_geo->lng,DEGREES_DECIMAL,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ } else {
+ // fall back to pos_degminsec
+ coord_format(attr->u.coord_geo->lat,attr->u.coord_geo->lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
+ return g_strdup(buffer);
+ }
+ case attr_destination_time:
+ if (!format || (strcmp(format,"arrival") && strcmp(format,"remaining")))
+ break;
+ textt = time(NULL);
+ tm = *localtime(&textt);
+ if (!strcmp(format,"remaining")) {
+ textt-=tm.tm_hour*3600+tm.tm_min*60+tm.tm_sec;
+ tm = *localtime(&textt);
+ }
+ textt += attr->u.num / 10;
+ text_tm = *localtime(&textt);
+ if (tm.tm_year != text_tm.tm_year || tm.tm_mon != text_tm.tm_mon || tm.tm_mday != text_tm.tm_mday) {
+ text_tm0 = text_tm;
+ text_tm0.tm_sec = 0;
+ text_tm0.tm_min = 0;
+ text_tm0.tm_hour = 0;
+ tm.tm_sec = 0;
+ tm.tm_min = 0;
+ tm.tm_hour = 0;
+ days = (mktime(&text_tm0) - mktime(&tm) + 43200) / 86400;
+ }
+ return format_time(&text_tm, days);
+ case attr_length:
+ case attr_destination_length:
+ if (!format)
+ break;
+ if (!strcmp(format,"named"))
+ return format_distance(attr->u.num,"",imperial);
+ if (!strcmp(format,"value") || !strcmp(format,"unit")) {
+ char *ret,*tmp=format_distance(attr->u.num," ",imperial);
+ char *pos=strchr(tmp,' ');
+ if (! pos)
+ return tmp;
+ *pos++='\0';
+ if (!strcmp(format,"value"))
+ return tmp;
+ ret=g_strdup(pos);
+ g_free(tmp);
+ return ret;
+ }
+ case attr_position_time_iso8601:
+ if ((!format) || (!strcmp(format,"iso8601"))) {
+ break;
+ } else {
+ if (strstr(format, "local;") == format) {
+ textt = iso8601_to_secs(attr->u.str);
+ memcpy ((void *) &tm, (void *) localtime(&textt), sizeof(tm));
+ strftime(buffer, sizeof(buffer), (char *)(format + 6), &tm);
+ } else if ((sscanf(format, "%*c%2d:%2d;", &(text_tm.tm_hour), &(text_tm.tm_min)) == 2) && (strchr("+-", format[0]))) {
+ if (strchr("-", format[0])) {
+ textt = iso8601_to_secs(attr->u.str) - text_tm.tm_hour * 3600 - text_tm.tm_min * 60;
+ } else {
+ textt = iso8601_to_secs(attr->u.str) + text_tm.tm_hour * 3600 + text_tm.tm_min * 60;
+ }
+ memcpy ((void *) &tm, (void *) gmtime(&textt), sizeof(tm));
+ strftime(buffer, sizeof(buffer), &format[strcspn(format, ";") + 1], &tm);
+ } else {
+ sscanf(attr->u.str, "%4d-%2d-%2dT%2d:%2d:%2d", &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday), &(tm.tm_hour), &(tm.tm_min),
+ &(tm.tm_sec));
+ // the tm structure definition is kinda weird and needs some extra voodoo
+ tm.tm_year-=1900;
+ tm.tm_mon--;
+ // get weekday and day of the year
+ mktime(&tm);
+ strftime(buffer, sizeof(buffer), format, &tm);
+ }
+ return g_strdup(buffer);
+ }
+ default:
+ break;
+ }
+ return attr_to_text(attr, NULL, 1);
}
/**
@@ -3045,276 +3016,270 @@ osd_text_format_attr(struct attr *attr, char *format, int imperial)
* fails (index with missing closed bracket or passing a null pointer as index argument when an index
* was encountered), the return value is NULL
*/
-static char *
-osd_text_split(char *in, char **index)
-{
- char *pos;
- int len;
- if (index)
- *index=NULL;
- len=strcspn(in,"[.");
- in+=len;
- switch (in[0]) {
- case '\0':
- return in;
- case '.':
- *in++='\0';
- return in;
- case '[':
- if (!index)
- return NULL;
- *in++='\0';
- *index=in;
- pos=strchr(in,']');
- if (pos) {
- *pos++='\0';
- if (*pos == '.') {
- *pos++='\0';
- }
- return pos;
- }
- return NULL;
- }
- return NULL;
-}
-
-static void
-osd_text_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v)
-{
- struct osd_text *this = (struct osd_text *)opc->data;
- struct point p, p2[4];
- char *str,*last,*next,*value,*absbegin;
- int do_draw = opc->osd_item.do_draw;
- struct attr attr, vehicle_attr, maxspeed_attr, imperial_attr;
- struct navigation *nav = NULL;
- struct tracking *tracking = NULL;
- struct map *nav_map = NULL;
- struct map_rect *nav_mr = NULL;
- struct item *item;
- struct osd_text_item *oti;
- int offset,lines;
- int height=opc->osd_item.font_size*13/256;
- int yspacing=height/2;
- int xspacing=height/4;
- int imperial=0;
-
- if (navit_get_attr(navit, attr_imperial, &imperial_attr, NULL))
- imperial=imperial_attr.u.num;
-
- vehicle_attr.u.vehicle=NULL;
- oti=this->items;
- str=NULL;
-
- while (oti) {
- item=NULL;
- value=NULL;
-
- if (oti->static_text) {
- value=g_strdup(oti->text);
- } else if (oti->section == attr_navigation) {
- if (navit && !nav)
- nav = navit_get_navigation(navit);
- if (nav && !nav_map)
- nav_map = navigation_get_map(nav);
- if (nav_map )
- nav_mr = map_rect_new(nav_map, NULL);
- if (nav_mr)
- item = map_rect_get_item(nav_mr);
-
- offset=oti->offset;
- while (item) {
- if (item->type == type_nav_none)
- item=map_rect_get_item(nav_mr);
- else if (!offset)
- break;
- else {
- offset--;
- item=map_rect_get_item(nav_mr);
- }
- }
-
- if (item) {
- dbg(lvl_debug,"name %s\n", item_to_name(item->type));
- dbg(lvl_debug,"type %s\n", attr_to_name(oti->attr_typ));
- if (item_attr_get(item, oti->attr_typ, &attr))
- value=osd_text_format_attr(&attr, oti->format, imperial);
- }
- if (nav_mr)
- map_rect_destroy(nav_mr);
- } else if (oti->section == attr_vehicle) {
- if (navit && !vehicle_attr.u.vehicle) {
- navit_get_attr(navit, attr_vehicle, &vehicle_attr, NULL);
- }
- if (vehicle_attr.u.vehicle) {
- if (vehicle_get_attr(vehicle_attr.u.vehicle, oti->attr_typ, &attr, NULL)) {
- value=osd_text_format_attr(&attr, oti->format, imperial);
- }
- }
- } else if (oti->section == attr_tracking) {
- if (navit) {
- tracking = navit_get_tracking(navit);
- }
- if (tracking) {
- item=tracking_get_current_item(tracking);
- if (item && (oti->attr_typ == attr_speed)) {
- double routespeed = -1;
- int *flags=tracking_get_current_flags(tracking);
- if (flags && (*flags & AF_SPEED_LIMIT) && tracking_get_attr(tracking, attr_maxspeed, &maxspeed_attr, NULL)) {
- routespeed = maxspeed_attr.u.num;
- }
- if (routespeed == -1) {
- struct vehicleprofile *prof=navit_get_vehicleprofile(navit);
- struct roadprofile *rprof=NULL;
- if (prof)
- rprof=vehicleprofile_get_roadprofile(prof, item->type);
- if (rprof) {
- routespeed=rprof->speed;
- }
- }
-
- value = format_speed(routespeed,"", oti->format, imperial);
- } else if (item) {
- if (tracking_get_attr(tracking, oti->attr_typ, &attr, NULL))
- value=osd_text_format_attr(&attr, oti->format, imperial);
- }
- }
-
- } else if (oti->section == attr_navit) {
- if (oti->attr_typ == attr_message) {
- struct message *msg;
- int len,offset;
- char *tmp;
-
- msg = navit_get_messages(navit);
- len = 0;
- while (msg) {
- len+= strlen(msg->text) + 2;
-
- msg = msg->next;
- }
-
- value = g_malloc(len +1);
-
- msg = navit_get_messages(navit);
- offset = 0;
- while (msg) {
- tmp = g_stpcpy((value+offset), msg->text);
- g_stpcpy(tmp, "\\n");
- offset += strlen(msg->text) + 2;
-
- msg = msg->next;
- }
-
- value[len] = '\0';
- }
- }
-
- next=g_strdup_printf("%s%s",str ? str:"",value ? value:" ");
- if (value)
- g_free(value);
- if (str)
- g_free(str);
- str=next;
- oti=oti->next;
- }
-
- if ( !this->last || !str || strcmp(this->last, str) ) {
- do_draw=1;
- if (this->last)
- g_free(this->last);
- this->last = g_strdup(str);
- }
-
- absbegin=str;
-
- if (do_draw) {
- osd_fill_with_bgcolor(&opc->osd_item);
- if (str) {
- lines=0;
- next=str;
- last=str;
- while ((next=strstr(next, "\\n"))) {
- last = next;
- lines++;
- next++;
- }
-
- while (*last) {
- if (! g_ascii_isspace(*last)) {
- lines++;
- break;
- }
- last++;
- }
-
- dbg(lvl_debug,"this->align=%d\n", this->align);
- switch (this->align & 51) {
- case 1:
- p.y=0;
- break;
- case 2:
- p.y=(opc->osd_item.h-lines*(height+yspacing)-yspacing);
- break;
- case 16: // Grow from top to bottom
- p.y = 0;
- if (lines != 0) {
- opc->osd_item.h = (lines-1) * (height+yspacing) + height;
- } else {
- opc->osd_item.h = 0;
- }
-
- if (do_draw) {
- osd_std_resize(&opc->osd_item);
- }
- default:
- p.y=(opc->osd_item.h-lines*(height+yspacing)-yspacing)/2;
- }
-
- while (str) {
- next=strstr(str, "\\n");
- if (next) {
- *next='\0';
- next+=2;
- }
- graphics_get_text_bbox(opc->osd_item.gr,
- opc->osd_item.font,
- str, 0x10000,
- 0x0, p2, 0);
- switch (this->align & 12) {
- case 4:
- p.x=xspacing;
- break;
- case 8:
- p.x=opc->osd_item.w-(p2[2].x-p2[0].x)-xspacing;
- break;
- default:
- p.x = ((p2[0].x - p2[2].x) / 2) + (opc->osd_item.w / 2);
- }
- p.y += height+yspacing;
- graphics_draw_text(opc->osd_item.gr,
- opc->osd_item.graphic_fg_text,
- NULL, opc->osd_item.font,
- str, &p, 0x10000,
- 0);
- str=next;
- }
- }
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
- }
- g_free(absbegin);
+static char *osd_text_split(char *in, char **index) {
+ char *pos;
+ int len;
+ if (index)
+ *index=NULL;
+ len=strcspn(in,"[.");
+ in+=len;
+ switch (in[0]) {
+ case '\0':
+ return in;
+ case '.':
+ *in++='\0';
+ return in;
+ case '[':
+ if (!index)
+ return NULL;
+ *in++='\0';
+ *index=in;
+ pos=strchr(in,']');
+ if (pos) {
+ *pos++='\0';
+ if (*pos == '.') {
+ *pos++='\0';
+ }
+ return pos;
+ }
+ return NULL;
+ }
+ return NULL;
+}
+
+static void osd_text_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v) {
+ struct osd_text *this = (struct osd_text *)opc->data;
+ struct point p, p2[4];
+ char *str,*last,*next,*value,*absbegin;
+ int do_draw = opc->osd_item.do_draw;
+ struct attr attr, vehicle_attr, maxspeed_attr, imperial_attr;
+ struct navigation *nav = NULL;
+ struct tracking *tracking = NULL;
+ struct map *nav_map = NULL;
+ struct map_rect *nav_mr = NULL;
+ struct item *item;
+ struct osd_text_item *oti;
+ int offset,lines;
+ int height=opc->osd_item.font_size*13/256;
+ int yspacing=height/2;
+ int xspacing=height/4;
+ int imperial=0;
+
+ if (navit_get_attr(navit, attr_imperial, &imperial_attr, NULL))
+ imperial=imperial_attr.u.num;
+
+ vehicle_attr.u.vehicle=NULL;
+ oti=this->items;
+ str=NULL;
+
+ while (oti) {
+ item=NULL;
+ value=NULL;
+
+ if (oti->static_text) {
+ value=g_strdup(oti->text);
+ } else if (oti->section == attr_navigation) {
+ if (navit && !nav)
+ nav = navit_get_navigation(navit);
+ if (nav && !nav_map)
+ nav_map = navigation_get_map(nav);
+ if (nav_map )
+ nav_mr = map_rect_new(nav_map, NULL);
+ if (nav_mr)
+ item = map_rect_get_item(nav_mr);
+
+ offset=oti->offset;
+ while (item) {
+ if (item->type == type_nav_none)
+ item=map_rect_get_item(nav_mr);
+ else if (!offset)
+ break;
+ else {
+ offset--;
+ item=map_rect_get_item(nav_mr);
+ }
+ }
+
+ if (item) {
+ dbg(lvl_debug,"name %s", item_to_name(item->type));
+ dbg(lvl_debug,"type %s", attr_to_name(oti->attr_typ));
+ if (item_attr_get(item, oti->attr_typ, &attr))
+ value=osd_text_format_attr(&attr, oti->format, imperial);
+ }
+ if (nav_mr)
+ map_rect_destroy(nav_mr);
+ } else if (oti->section == attr_vehicle) {
+ if (navit && !vehicle_attr.u.vehicle) {
+ navit_get_attr(navit, attr_vehicle, &vehicle_attr, NULL);
+ }
+ if (vehicle_attr.u.vehicle) {
+ if (vehicle_get_attr(vehicle_attr.u.vehicle, oti->attr_typ, &attr, NULL)) {
+ value=osd_text_format_attr(&attr, oti->format, imperial);
+ }
+ }
+ } else if (oti->section == attr_tracking) {
+ if (navit) {
+ tracking = navit_get_tracking(navit);
+ }
+ if (tracking) {
+ item=tracking_get_current_item(tracking);
+ if (item && (oti->attr_typ == attr_speed)) {
+ double routespeed = -1;
+ int *flags=tracking_get_current_flags(tracking);
+ if (flags && (*flags & AF_SPEED_LIMIT) && tracking_get_attr(tracking, attr_maxspeed, &maxspeed_attr, NULL)) {
+ routespeed = maxspeed_attr.u.num;
+ }
+ if (routespeed == -1) {
+ struct vehicleprofile *prof=navit_get_vehicleprofile(navit);
+ struct roadprofile *rprof=NULL;
+ if (prof)
+ rprof=vehicleprofile_get_roadprofile(prof, item->type);
+ if (rprof) {
+ routespeed=rprof->speed;
+ }
+ }
+
+ value = format_speed(routespeed,"", oti->format, imperial);
+ } else if (item) {
+ if (tracking_get_attr(tracking, oti->attr_typ, &attr, NULL))
+ value=osd_text_format_attr(&attr, oti->format, imperial);
+ }
+ }
+
+ } else if (oti->section == attr_navit) {
+ if (oti->attr_typ == attr_message) {
+ struct message *msg;
+ int len,offset;
+ char *tmp;
+
+ msg = navit_get_messages(navit);
+ len = 0;
+ while (msg) {
+ len+= strlen(msg->text) + 2;
+
+ msg = msg->next;
+ }
+
+ value = g_malloc(len +1);
+
+ msg = navit_get_messages(navit);
+ offset = 0;
+ while (msg) {
+ tmp = g_stpcpy((value+offset), msg->text);
+ g_stpcpy(tmp, "\\n");
+ offset += strlen(msg->text) + 2;
+
+ msg = msg->next;
+ }
+
+ value[len] = '\0';
+ }
+ }
+
+ next=g_strdup_printf("%s%s",str ? str:"",value ? value:" ");
+ if (value)
+ g_free(value);
+ if (str)
+ g_free(str);
+ str=next;
+ oti=oti->next;
+ }
+
+ if ( !this->last || !str || strcmp(this->last, str) ) {
+ do_draw=1;
+ if (this->last)
+ g_free(this->last);
+ this->last = g_strdup(str);
+ }
+
+ absbegin=str;
+
+ if (do_draw) {
+ osd_fill_with_bgcolor(&opc->osd_item);
+ if (str) {
+ lines=0;
+ next=str;
+ last=str;
+ while ((next=strstr(next, "\\n"))) {
+ last = next;
+ lines++;
+ next++;
+ }
+
+ while (*last) {
+ if (! g_ascii_isspace(*last)) {
+ lines++;
+ break;
+ }
+ last++;
+ }
+
+ dbg(lvl_debug,"this->align=%d", this->align);
+ switch (this->align & 51) {
+ case 1:
+ p.y=0;
+ break;
+ case 2:
+ p.y=(opc->osd_item.h-lines*(height+yspacing)-yspacing);
+ break;
+ case 16: // Grow from top to bottom
+ p.y = 0;
+ if (lines != 0) {
+ opc->osd_item.h = (lines-1) * (height+yspacing) + height;
+ } else {
+ opc->osd_item.h = 0;
+ }
+
+ if (do_draw) {
+ osd_std_resize(&opc->osd_item);
+ }
+ default:
+ p.y=(opc->osd_item.h-lines*(height+yspacing)-yspacing)/2;
+ }
+
+ while (str) {
+ next=strstr(str, "\\n");
+ if (next) {
+ *next='\0';
+ next+=2;
+ }
+ graphics_get_text_bbox(opc->osd_item.gr,
+ opc->osd_item.font,
+ str, 0x10000,
+ 0x0, p2, 0);
+ switch (this->align & 12) {
+ case 4:
+ p.x=xspacing;
+ break;
+ case 8:
+ p.x=opc->osd_item.w-(p2[2].x-p2[0].x)-xspacing;
+ break;
+ default:
+ p.x = ((p2[0].x - p2[2].x) / 2) + (opc->osd_item.w / 2);
+ }
+ p.y += height+yspacing;
+ graphics_draw_text(opc->osd_item.gr,
+ opc->osd_item.graphic_fg_text,
+ NULL, opc->osd_item.font,
+ str, &p, 0x10000,
+ 0);
+ str=next;
+ }
+ }
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ }
+ g_free(absbegin);
}
/**
* @brief Creates a new osd_text_item and inserts it into a linked list
- *
+ *
* @param parent The preceding {@code osd_text_item} in the list. If NULL, the new item becomes the root
* element of a new list
* @returns The new {@code osd_text_item}
*/
-static struct osd_text_item *
-oti_new(struct osd_text_item * parent)
-{
+static struct osd_text_item *oti_new(struct osd_text_item * parent) {
struct osd_text_item *this;
this=g_new0(struct osd_text_item, 1);
this->prev=parent;
@@ -3334,687 +3299,654 @@ oti_new(struct osd_text_item * parent)
*
* This function parses the label string (as specified in the XML file) for a text type OSD element
* into attributes and static text.
- *
+ *
* @param opc The {@code struct osd_priv_common} for the OSD element. {@code opc->data->items} will
* receive a pointer to a list of {@code osd_text_item} structures.
* @param nav The navit structure
*/
-static void
-osd_text_prepare(struct osd_priv_common *opc, struct navit *nav)
-{
- struct osd_text *this = (struct osd_text *)opc->data;
+static void osd_text_prepare(struct osd_priv_common *opc, struct navit *nav) {
+ struct osd_text *this = (struct osd_text *)opc->data;
+
+ char *absbegin,*str,*start,*end,*key,*subkey,*index;
+ struct osd_text_item *oti;
+
+ oti=NULL;
+ str=g_strdup(this->text);
+ absbegin=str;
+
+ while ((start=strstr(str, "${"))) {
+
+ *start='\0';
+ start+=2;
+
+ // find plain text before
+ if (start!=str) {
+ oti = oti_new(oti);
+ oti->static_text=1;
+ oti->text=g_strdup(str);
+
+ }
+
+ end=strstr(start,"}");
+ if (! end)
+ break;
+
+ *end++='\0';
+ key=start;
+
+ subkey=osd_text_split(key,NULL);
+
+ oti = oti_new(oti);
+ oti->section=attr_from_name(key);
+
+ if (( oti->section == attr_navigation ||
+ oti->section == attr_tracking) && subkey) {
+ key=osd_text_split(subkey,&index);
+
+ if (index)
+ oti->offset=atoi(index);
+
+ subkey=osd_text_split(key,&index);
+
+ if (!strcmp(key,"route_speed")) {
+ oti->attr_typ=attr_speed;
+ } else {
+ oti->attr_typ=attr_from_name(key);
+ }
+ oti->format = g_strdup(index);
+
+ } else if ((oti->section == attr_vehicle || oti->section == attr_navit) && subkey) {
+ key=osd_text_split(subkey,&index);
+ if (!strcmp(subkey,"messages")) {
+ oti->attr_typ=attr_message;
+ } else {
+ oti->attr_typ=attr_from_name(subkey);
+ }
+ oti->format = g_strdup(index);
+ }
+
+ switch(oti->attr_typ) {
+ default:
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_text_draw), attr_position_coord_geo, opc));
+ break;
+ }
+
+ str=(end);
+ }
+
+ if(*str!='\0') {
+ oti = oti_new(oti);
+ oti->static_text=1;
+ oti->text=g_strdup(str);
+ }
+
+ if (oti)
+ this->items=oti->root;
+ else
+ this->items=NULL;
+
+ g_free(absbegin);
+
+}
+
+static void osd_text_init(struct osd_priv_common *opc, struct navit *nav) {
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item));
+ osd_text_prepare(opc,nav);
+ osd_text_draw(opc, nav, NULL);
+
+}
+
+static int osd_text_set_attr(struct osd_priv_common *opc, struct attr* attr) {
+ struct osd_text *this_ = (struct osd_text *)opc->data;
- char *absbegin,*str,*start,*end,*key,*subkey,*index;
- struct osd_text_item *oti;
+ if(NULL==attr || NULL==this_) {
+ return 0;
+ }
+ if(attr->type == attr_label) {
+ struct navit *nav=opc->osd_item.navit;
- oti=NULL;
- str=g_strdup(this->text);
- absbegin=str;
+ if(this_->text)
+ g_free(this_->text);
- while ((start=strstr(str, "${"))) {
+ if(attr->u.str)
+ this_->text = g_strdup(attr->u.str);
+ else
+ this_->text=g_strdup("");
- *start='\0';
- start+=2;
+ osd_text_prepare(opc,nav);
- // find plain text before
- if (start!=str) {
- oti = oti_new(oti);
- oti->static_text=1;
- oti->text=g_strdup(str);
+ if(navit_get_blocked(nav)&1)
+ return 1;
- }
-
- end=strstr(start,"}");
- if (! end)
- break;
+ osd_text_draw(opc,nav,NULL);
+ navit_draw(opc->osd_item.navit);
+ return 1;
+ }
+ return 0;
+}
- *end++='\0';
- key=start;
- subkey=osd_text_split(key,NULL);
+static struct osd_priv *osd_text_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct osd_text *this = g_new0(struct osd_text, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
- oti = oti_new(oti);
- oti->section=attr_from_name(key);
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = -80;
+ opc->osd_item.rel_y = 20;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 20;
+ opc->osd_item.navit = nav;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_text_draw);
+ meth->set_attr = set_std_osd_attr;
+ opc->spec_set_attr_func = osd_text_set_attr;
+ osd_set_std_attr(attrs, &opc->osd_item, ITEM_HAS_TEXT);
- if (( oti->section == attr_navigation ||
- oti->section == attr_tracking) && subkey) {
- key=osd_text_split(subkey,&index);
-
- if (index)
- oti->offset=atoi(index);
-
- subkey=osd_text_split(key,&index);
-
- if (!strcmp(key,"route_speed")) {
- oti->attr_typ=attr_speed;
- } else {
- oti->attr_typ=attr_from_name(key);
- }
- oti->format = g_strdup(index);
-
- } else if ((oti->section == attr_vehicle || oti->section == attr_navit) && subkey) {
- key=osd_text_split(subkey,&index);
- if (!strcmp(subkey,"messages")) {
- oti->attr_typ=attr_message;
- } else {
- oti->attr_typ=attr_from_name(subkey);
- }
- oti->format = g_strdup(index);
- }
-
- switch(oti->attr_typ) {
- default:
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_text_draw), attr_position_coord_geo, opc));
- break;
- }
-
- str=(end);
- }
-
- if(*str!='\0'){
- oti = oti_new(oti);
- oti->static_text=1;
- oti->text=g_strdup(str);
- }
-
- if (oti)
- this->items=oti->root;
- else
- this->items=NULL;
-
- g_free(absbegin);
-
-}
-
-static void
-osd_text_init(struct osd_priv_common *opc, struct navit *nav)
-{
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item));
- osd_text_prepare(opc,nav);
- osd_text_draw(opc, nav, NULL);
-
-}
-
-static int
-osd_text_set_attr(struct osd_priv_common *opc, struct attr* attr)
-{
- struct osd_text *this_ = (struct osd_text *)opc->data;
-
- if(NULL==attr || NULL==this_) {
- return 0;
- }
- if(attr->type == attr_label) {
- struct navit *nav=opc->osd_item.navit;
-
- if(this_->text)
- g_free(this_->text);
-
- if(attr->u.str)
- this_->text = g_strdup(attr->u.str);
- else
- this_->text=g_strdup("");
-
- osd_text_prepare(opc,nav);
-
- if(navit_get_blocked(nav)&1)
- return 1;
-
- osd_text_draw(opc,nav,NULL);
- navit_draw(opc->osd_item.navit);
- return 1;
- }
- return 0;
-}
-
-
-static struct osd_priv *
-osd_text_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct osd_text *this = g_new0(struct osd_text, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = -80;
- opc->osd_item.rel_y = 20;
- opc->osd_item.rel_w = 60;
- opc->osd_item.rel_h = 20;
- opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_text_draw);
- meth->set_attr = set_std_osd_attr;
- opc->spec_set_attr_func = osd_text_set_attr;
- osd_set_std_attr(attrs, &opc->osd_item, 2);
-
- this->active = -1;
- this->last = NULL;
-
- attr = attr_search(attrs, NULL, attr_label);
- if (attr)
- this->text = g_strdup(attr->u.str);
- else
- this->text = NULL;
- attr = attr_search(attrs, NULL, attr_align);
- if (attr)
- this->align=attr->u.num;
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_text_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
+ this->active = -1;
+ this->last = NULL;
+
+ attr = attr_search(attrs, NULL, attr_label);
+ if (attr)
+ this->text = g_strdup(attr->u.str);
+ else
+ this->text = NULL;
+ attr = attr_search(attrs, NULL, attr_align);
+ if (attr)
+ this->align=attr->u.num;
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_text_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
}
struct gps_status {
- char *icon_src;
- int icon_h, icon_w, active;
- int strength;
+ char *icon_src;
+ int icon_h, icon_w, active;
+ int strength;
};
-static void
-osd_gps_status_draw(struct osd_priv_common *opc, struct navit *navit,
- struct vehicle *v)
-{
- struct gps_status *this = (struct gps_status *)opc->data;
-
- struct point p;
- int do_draw = opc->osd_item.do_draw;
- struct graphics_image *gr_image;
- char *image;
- struct attr attr, vehicle_attr;
- int strength=-1;
-
- if (navit && navit_get_attr(navit, attr_vehicle, &vehicle_attr, NULL)) {
- if (vehicle_get_attr(vehicle_attr.u.vehicle, attr_position_fix_type, &attr, NULL)) {
- switch(attr.u.num) {
- case 1:
- case 2:
- strength=2;
- if (vehicle_get_attr(vehicle_attr.u.vehicle, attr_position_sats_used, &attr, NULL)) {
- dbg(lvl_debug,"num=%ld\n", attr.u.num);
- if (attr.u.num >= 3)
- strength=attr.u.num-1;
- if (strength > 5)
- strength=5;
- if (strength > 3) {
- if (vehicle_get_attr(vehicle_attr.u.vehicle, attr_position_hdop, &attr, NULL)) {
- if (*attr.u.numd > 2.0 && strength > 4)
- strength=4;
- if (*attr.u.numd > 4.0 && strength > 3)
- strength=3;
- }
- }
- }
- break;
- default:
- strength=1;
- }
- }
- }
- if (this->strength != strength) {
- this->strength=strength;
- do_draw=1;
- }
- if (do_draw) {
- osd_fill_with_bgcolor(&opc->osd_item);
- if (this->active) {
- image = g_strdup_printf(this->icon_src, strength);
- gr_image = graphics_image_new_scaled(opc->osd_item.gr, image, this->icon_w, this->icon_h);
- if (gr_image) {
- p.x = (opc->osd_item.w - gr_image->width) / 2;
- p.y = (opc->osd_item.h - gr_image->height) / 2;
- graphics_draw_image(opc->osd_item.gr, opc->osd_item. graphic_fg, &p, gr_image);
- graphics_image_free(opc->osd_item.gr, gr_image);
- }
- g_free(image);
- }
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
- }
-}
-
-static void
-osd_gps_status_init(struct osd_priv_common *opc, struct navit *nav)
-{
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_coord_geo, opc));
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_fix_type, opc));
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_sats_used, opc));
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_hdop, opc));
- osd_gps_status_draw(opc, nav, NULL);
-}
-
-static struct osd_priv *
-osd_gps_status_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct gps_status *this = g_new0(struct gps_status, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = 20;
- opc->osd_item.rel_y = -80;
- opc->osd_item.rel_w = 60;
- opc->osd_item.navit = nav;
- opc->osd_item.rel_h = 40;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_gps_status_draw);
- meth->set_attr = set_std_osd_attr;
- osd_set_std_attr(attrs, &opc->osd_item, 0);
-
- this->icon_w = -1;
- this->icon_h = -1;
- this->active = -1;
- this->strength = -2;
-
- attr = attr_search(attrs, NULL, attr_icon_w);
- if (attr)
- this->icon_w = attr->u.num;
-
- attr = attr_search(attrs, NULL, attr_icon_h);
- if (attr)
- this->icon_h = attr->u.num;
-
- attr = attr_search(attrs, NULL, attr_icon_src);
- if (attr) {
- struct file_wordexp *we;
- char **array;
- we = file_wordexp_new(attr->u.str);
- array = file_wordexp_get_array(we);
- this->icon_src = g_strdup(array[0]);
- file_wordexp_destroy(we);
- } else
- this->icon_src = graphics_icon_path("gui_strength_%d_32_32.png");
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
+static void osd_gps_status_draw(struct osd_priv_common *opc, struct navit *navit,
+ struct vehicle *v) {
+ struct gps_status *this = (struct gps_status *)opc->data;
+
+ struct point p;
+ int do_draw = opc->osd_item.do_draw;
+ struct graphics_image *gr_image;
+ char *image;
+ struct attr attr, vehicle_attr;
+ int strength=-1;
+
+ if (navit && navit_get_attr(navit, attr_vehicle, &vehicle_attr, NULL)) {
+ if (vehicle_get_attr(vehicle_attr.u.vehicle, attr_position_fix_type, &attr, NULL)) {
+ switch(attr.u.num) {
+ case 1:
+ case 2:
+ strength=2;
+ if (vehicle_get_attr(vehicle_attr.u.vehicle, attr_position_sats_used, &attr, NULL)) {
+ dbg(lvl_debug,"num=%ld", attr.u.num);
+ if (attr.u.num >= 3)
+ strength=attr.u.num-1;
+ if (strength > 5)
+ strength=5;
+ if (strength > 3) {
+ if (vehicle_get_attr(vehicle_attr.u.vehicle, attr_position_hdop, &attr, NULL)) {
+ if (*attr.u.numd > 2.0 && strength > 4)
+ strength=4;
+ if (*attr.u.numd > 4.0 && strength > 3)
+ strength=3;
+ }
+ }
+ }
+ break;
+ default:
+ strength=1;
+ }
+ }
+ }
+ if (this->strength != strength) {
+ this->strength=strength;
+ do_draw=1;
+ }
+ if (do_draw) {
+ osd_fill_with_bgcolor(&opc->osd_item);
+ if (this->active) {
+ image = g_strdup_printf(this->icon_src, strength);
+ gr_image = graphics_image_new_scaled(opc->osd_item.gr, image, this->icon_w, this->icon_h);
+ if (gr_image) {
+ p.x = (opc->osd_item.w - gr_image->width) / 2;
+ p.y = (opc->osd_item.h - gr_image->height) / 2;
+ graphics_draw_image(opc->osd_item.gr, opc->osd_item. graphic_fg, &p, gr_image);
+ graphics_image_free(opc->osd_item.gr, gr_image);
+ }
+ g_free(image);
+ }
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+ }
+}
+
+static void osd_gps_status_init(struct osd_priv_common *opc, struct navit *nav) {
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_coord_geo, opc));
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_fix_type, opc));
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_sats_used, opc));
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_hdop, opc));
+ osd_gps_status_draw(opc, nav, NULL);
+}
+
+static struct osd_priv *osd_gps_status_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct gps_status *this = g_new0(struct gps_status, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = -80;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.navit = nav;
+ opc->osd_item.rel_h = 40;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_gps_status_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ osd_set_std_attr(attrs, &opc->osd_item, 0);
+
+ this->icon_w = -1;
+ this->icon_h = -1;
+ this->active = -1;
+ this->strength = -2;
+
+ attr = attr_search(attrs, NULL, attr_icon_w);
+ if (attr)
+ this->icon_w = attr->u.num;
+
+ attr = attr_search(attrs, NULL, attr_icon_h);
+ if (attr)
+ this->icon_h = attr->u.num;
+
+ attr = attr_search(attrs, NULL, attr_icon_src);
+ if (attr) {
+ struct file_wordexp *we;
+ char **array;
+ we = file_wordexp_new(attr->u.str);
+ array = file_wordexp_get_array(we);
+ this->icon_src = g_strdup(array[0]);
+ file_wordexp_destroy(we);
+ } else
+ this->icon_src = graphics_icon_path("gui_strength_%d_32_32.png");
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
}
struct volume {
- char *icon_src;
- int icon_h, icon_w, active;
- int strength;
- struct callback *click_cb;
+ char *icon_src;
+ int icon_h, icon_w, active;
+ int strength;
+ struct callback *click_cb;
};
-static void
-osd_volume_draw(struct osd_priv_common *opc, struct navit *navit)
-{
- struct volume *this = (struct volume *)opc->data;
-
- struct point p;
- struct graphics_image *gr_image;
- char *image;
-
- osd_fill_with_bgcolor(&opc->osd_item);
- if (this->active) {
- image = g_strdup_printf(this->icon_src, this->strength);
- gr_image = graphics_image_new_scaled(opc->osd_item.gr, image, this->icon_w, this->icon_h);
- if (gr_image) {
- p.x = (opc->osd_item.w - gr_image->width) / 2;
- p.y = (opc->osd_item.h - gr_image->height) / 2;
- graphics_draw_image(opc->osd_item.gr, opc->osd_item. graphic_fg, &p, gr_image);
- graphics_image_free(opc->osd_item.gr, gr_image);
- }
- g_free(image);
- }
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
-}
-
-static void
-osd_volume_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button, struct point *p)
-{
- struct volume *this = (struct volume *)opc->data;
-
- struct point bp = opc->osd_item.p;
- if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h) && !opc->osd_item.pressed)
- return;
- navit_ignore_button(nav);
- if (pressed) {
- if (p->y - bp.y < opc->osd_item.h/2)
- this->strength++;
- else
- this->strength--;
- if (this->strength < 0)
- this->strength=0;
- if (this->strength > 5)
- this->strength=5;
- osd_volume_draw(opc, nav);
- }
-}
-static void
-osd_volume_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct volume *this = (struct volume *)opc->data;
-
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_volume_click), attr_button, opc));
- osd_volume_draw(opc, nav);
-}
-
-static struct osd_priv *
-osd_volume_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct volume *this = g_new0(struct volume, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
- opc->osd_item.rel_x = 20;
- opc->osd_item.rel_y = -80;
- opc->osd_item.rel_w = 60;
- opc->osd_item.rel_h = 40;
- opc->osd_item.navit = nav;
- opc->osd_item.font_size = 200;
- opc->osd_item.meth.draw = osd_draw_cast(osd_volume_draw);
- meth->set_attr = set_std_osd_attr;
- osd_set_std_attr(attrs, &opc->osd_item, 0);
-
- this->icon_w = -1;
- this->icon_h = -1;
- this->active = -1;
- this->strength = -1;
-
- attr = attr_search(attrs, NULL, attr_icon_w);
- if (attr)
- this->icon_w = attr->u.num;
-
- attr = attr_search(attrs, NULL, attr_icon_h);
- if (attr)
- this->icon_h = attr->u.num;
-
- attr = attr_search(attrs, NULL, attr_icon_src);
- if (attr) {
- struct file_wordexp *we;
- char **array;
- we = file_wordexp_new(attr->u.str);
- array = file_wordexp_get_array(we);
- this->icon_src = g_strdup(array[0]);
- file_wordexp_destroy(we);
- } else
- this->icon_src = graphics_icon_path("gui_strength_%d_32_32.png");
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_volume_init), attr_graphics_ready, opc));
- return (struct osd_priv *) opc;
+static void osd_volume_draw(struct osd_priv_common *opc, struct navit *navit) {
+ struct volume *this = (struct volume *)opc->data;
+
+ struct point p;
+ struct graphics_image *gr_image;
+ char *image;
+
+ osd_fill_with_bgcolor(&opc->osd_item);
+ if (this->active) {
+ image = g_strdup_printf(this->icon_src, this->strength);
+ gr_image = graphics_image_new_scaled(opc->osd_item.gr, image, this->icon_w, this->icon_h);
+ if (gr_image) {
+ p.x = (opc->osd_item.w - gr_image->width) / 2;
+ p.y = (opc->osd_item.h - gr_image->height) / 2;
+ graphics_draw_image(opc->osd_item.gr, opc->osd_item. graphic_fg, &p, gr_image);
+ graphics_image_free(opc->osd_item.gr, gr_image);
+ }
+ g_free(image);
+ }
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+}
+
+static void osd_volume_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button, struct point *p) {
+ struct volume *this = (struct volume *)opc->data;
+
+ struct point bp = opc->osd_item.p;
+ if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h)
+ && !opc->osd_item.pressed)
+ return;
+ navit_ignore_button(nav);
+ if (pressed) {
+ if (p->y - bp.y < opc->osd_item.h/2)
+ this->strength++;
+ else
+ this->strength--;
+ if (this->strength < 0)
+ this->strength=0;
+ if (this->strength > 5)
+ this->strength=5;
+ osd_volume_draw(opc, nav);
+ }
+}
+static void osd_volume_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct volume *this = (struct volume *)opc->data;
+
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+ navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_volume_click), attr_button, opc));
+ osd_volume_draw(opc, nav);
+}
+
+static struct osd_priv *osd_volume_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct volume *this = g_new0(struct volume, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ struct attr *attr;
+
+ opc->data = (void*)this;
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = -80;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 40;
+ opc->osd_item.navit = nav;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_volume_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ osd_set_std_attr(attrs, &opc->osd_item, 0);
+
+ this->icon_w = -1;
+ this->icon_h = -1;
+ this->active = -1;
+ this->strength = -1;
+
+ attr = attr_search(attrs, NULL, attr_icon_w);
+ if (attr)
+ this->icon_w = attr->u.num;
+
+ attr = attr_search(attrs, NULL, attr_icon_h);
+ if (attr)
+ this->icon_h = attr->u.num;
+
+ attr = attr_search(attrs, NULL, attr_icon_src);
+ if (attr) {
+ struct file_wordexp *we;
+ char **array;
+ we = file_wordexp_new(attr->u.str);
+ array = file_wordexp_get_array(we);
+ this->icon_src = g_strdup(array[0]);
+ file_wordexp_destroy(we);
+ } else
+ this->icon_src = graphics_icon_path("gui_strength_%d_32_32.png");
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_volume_init), attr_graphics_ready, opc));
+ return (struct osd_priv *) opc;
}
struct osd_scale {
- int use_overlay;
- struct callback *draw_cb,*navit_init_cb;
- struct graphics_gc *black;
+ int use_overlay;
+ struct callback *draw_cb,*navit_init_cb;
+ struct graphics_gc *black;
};
-static int
-round_to_nice_value(double value)
-{
- double nearest_power_of10,mantissa;
- nearest_power_of10=pow(10,floor(log10(value)));
- mantissa=value/nearest_power_of10;
- if (mantissa >= 5)
- mantissa=5;
- else if (mantissa >= 2)
- mantissa=2;
- else
- mantissa=1;
- return mantissa*nearest_power_of10;
-}
-
-static void
-osd_scale_draw(struct osd_priv_common *opc, struct navit *nav)
-{
- struct osd_scale *this = (struct osd_scale *)opc->data;
-
- struct point item_pos,scale_line_start,scale_line_end;
- struct point p[10],bbox[4];
- struct attr transformation,imperial_attr;
- int scale_x_offset,scale_length_on_map,scale_length_pixels;
- double distance_on_map;
- char *text;
- int width_reduced;
- int imperial=0;
-
- osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav));
-
- width_reduced=opc->osd_item.w*9/10;
-
- if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL))
- imperial=imperial_attr.u.num;
-
- if (!navit_get_attr(nav, attr_transformation, &transformation, NULL))
- return;
- if (this->use_overlay) {
- graphics_draw_mode(opc->osd_item.gr, draw_mode_begin);
- item_pos.x=0;
- item_pos.y=0;
- graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_bg, &item_pos, opc->osd_item.w, opc->osd_item.h);
- } else {
- item_pos=opc->osd_item.p;
- }
- scale_line_start=item_pos;
- scale_line_start.y+=opc->osd_item.h/2;
- scale_line_start.x+=(opc->osd_item.w-width_reduced)/2;
- scale_line_end=scale_line_start;
- scale_line_end.x+=width_reduced;
-
- distance_on_map=transform_pixels_to_map_distance(transformation.u.transformation, width_reduced);
- scale_length_on_map=round_to_nice_value(distance_on_map);
- scale_length_pixels=scale_length_on_map/distance_on_map*width_reduced;
- scale_x_offset=(opc->osd_item.w-scale_length_pixels) / 2;
-
- p[0]=scale_line_start;
- p[1]=scale_line_end;
- p[0].x+=scale_x_offset;
- p[1].x-=scale_x_offset;
- p[2]=p[0];
- p[3]=p[0];
- p[2].y-=opc->osd_item.h/10;
- p[3].y+=opc->osd_item.h/10;
- p[4]=p[1];
- p[5]=p[1];
- p[4].y-=opc->osd_item.h/10;
- p[5].y+=opc->osd_item.h/10;
- p[6]=p[2];
- p[6].x-=2;
- p[6].y-=2;
- p[7]=p[0];
- p[7].y-=2;
- p[8]=p[4];
- p[8].x-=2;
- p[8].y-=2;
- graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg, p+6, 4,opc->osd_item.h/5+4);
- graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg, p+7, p[1].x-p[0].x, 4);
- graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg, p+8, 4,opc->osd_item.h/5+4);
- graphics_draw_lines(opc->osd_item.gr, this->black, p, 2);
- graphics_draw_lines(opc->osd_item.gr, this->black, p+2, 2);
- graphics_draw_lines(opc->osd_item.gr, this->black, p+4, 2);
- text=format_distance(scale_length_on_map, "", imperial);
- graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, text, 0x10000, 0, bbox, 0);
- p[0].x=(opc->osd_item.w-bbox[2].x)/2+item_pos.x;
- p[0].y=item_pos.y+opc->osd_item.h-opc->osd_item.h/10;
- graphics_draw_text(opc->osd_item.gr, this->black, opc->osd_item.graphic_fg, opc->osd_item.font, text, &p[0], 0x10000, 0);
- g_free(text);
- if (this->use_overlay)
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
-}
-
-static void
-osd_scale_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct osd_scale *this = (struct osd_scale *)opc->data;
-
- struct color color_black={COLOR_BLACK_};
- struct graphics *gra = navit_get_graphics(nav);
- dbg(lvl_debug, "enter\n");
- if (this->use_overlay) {
- osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
- } else {
- opc->osd_item.configured=1;
- opc->osd_item.gr=gra;
- opc->osd_item.font = graphics_font_new(opc->osd_item.gr, opc->osd_item.font_size, 1);
- opc->osd_item.graphic_fg=graphics_gc_new(opc->osd_item.gr);
- }
- this->black=graphics_gc_new(opc->osd_item.gr);
- graphics_gc_set_foreground(this->black, &color_black);
- graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_scale_draw), attr_postdraw, opc, nav));
- if (navit_get_ready(nav) == 3)
- osd_scale_draw(opc, nav);
-}
-
-static struct osd_priv *
-osd_scale_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct osd_scale *this = g_new0(struct osd_scale, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- struct attr *attr;
-
- opc->data = (void*)this;
-
- opc->osd_item.navit = nav;
- opc->osd_item.meth.draw = osd_draw_cast(osd_scale_draw);
- meth->set_attr = set_std_osd_attr;
-
- osd_set_std_attr(attrs, &opc->osd_item, 3);
-
- attr=attr_search(attrs, NULL, attr_use_overlay);
- if (attr)
- this->use_overlay=attr->u.num;
-
- navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_scale_init), attr_graphics_ready, opc));
-
- return (struct osd_priv *) opc;
+static int round_to_nice_value(double value) {
+ double nearest_power_of10,mantissa;
+ nearest_power_of10=pow(10,floor(log10(value)));
+ mantissa=value/nearest_power_of10;
+ if (mantissa >= 5)
+ mantissa=5;
+ else if (mantissa >= 2)
+ mantissa=2;
+ else
+ mantissa=1;
+ return mantissa*nearest_power_of10;
+}
+
+static void osd_scale_draw(struct osd_priv_common *opc, struct navit *nav) {
+ struct osd_scale *this = (struct osd_scale *)opc->data;
+
+ struct point item_pos,scale_line_start,scale_line_end;
+ struct point p[10],bbox[4];
+ struct attr transformation,imperial_attr;
+ int scale_x_offset,scale_length_on_map,scale_length_pixels;
+ double distance_on_map;
+ char *text;
+ int width_reduced;
+ int imperial=0;
+
+ osd_std_calculate_sizes(&opc->osd_item, navit_get_width(nav), navit_get_height(nav));
+
+ width_reduced=opc->osd_item.w*9/10;
+
+ if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL))
+ imperial=imperial_attr.u.num;
+
+ if (!navit_get_attr(nav, attr_transformation, &transformation, NULL))
+ return;
+
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_begin);
+ item_pos.x=0;
+ item_pos.y=0;
+ graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_bg, &item_pos, opc->osd_item.w, opc->osd_item.h);
+
+ scale_line_start=item_pos;
+ scale_line_start.y+=opc->osd_item.h/2;
+ scale_line_start.x+=(opc->osd_item.w-width_reduced)/2;
+ scale_line_end=scale_line_start;
+ scale_line_end.x+=width_reduced;
+
+ distance_on_map=transform_pixels_to_map_distance(transformation.u.transformation, width_reduced);
+ scale_length_on_map=round_to_nice_value(distance_on_map);
+ scale_length_pixels=scale_length_on_map/distance_on_map*width_reduced;
+ scale_x_offset=(opc->osd_item.w-scale_length_pixels) / 2;
+
+ p[0]=scale_line_start;
+ p[1]=scale_line_end;
+ p[0].x+=scale_x_offset;
+ p[1].x-=scale_x_offset;
+ p[2]=p[0];
+ p[3]=p[0];
+ p[2].y-=opc->osd_item.h/10;
+ p[3].y+=opc->osd_item.h/10;
+ p[4]=p[1];
+ p[5]=p[1];
+ p[4].y-=opc->osd_item.h/10;
+ p[5].y+=opc->osd_item.h/10;
+ p[6]=p[2];
+ p[6].x-=2;
+ p[6].y-=2;
+ p[7]=p[0];
+ p[7].y-=2;
+ p[8]=p[4];
+ p[8].x-=2;
+ p[8].y-=2;
+ graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg, p+6, 4,opc->osd_item.h/5+4);
+ graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg, p+7, p[1].x-p[0].x, 4);
+ graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg, p+8, 4,opc->osd_item.h/5+4);
+ graphics_draw_lines(opc->osd_item.gr, opc->osd_item.graphic_fg_text, p, 2);
+ graphics_draw_lines(opc->osd_item.gr, opc->osd_item.graphic_fg_text, p+2, 2);
+ graphics_draw_lines(opc->osd_item.gr, opc->osd_item.graphic_fg_text, p+4, 2);
+ text=format_distance(scale_length_on_map, "", imperial);
+ graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, text, 0x10000, 0, bbox, 0);
+ p[0].x=(opc->osd_item.w-bbox[2].x)/2+item_pos.x;
+ p[0].y=item_pos.y+opc->osd_item.h-opc->osd_item.h/10;
+ graphics_draw_text(opc->osd_item.gr, opc->osd_item.graphic_fg_text, opc->osd_item.graphic_fg, opc->osd_item.font, text,
+ &p[0], 0x10000, 0);
+ g_free(text);
+ if (this->use_overlay)
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+}
+
+static void osd_scale_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct osd_scale *this = (struct osd_scale *)opc->data;
+
+ struct graphics *gra = navit_get_graphics(nav);
+
+ struct color transparent = {0,0,0,0};
+
+ opc->osd_item.color_fg.r = 0xffff-opc->osd_item.text_color.r;
+ opc->osd_item.color_fg.g = 0xffff-opc->osd_item.text_color.g;
+ opc->osd_item.color_fg.b = 0xffff-opc->osd_item.text_color.b;
+ opc->osd_item.color_fg.a = 0xffff-opc->osd_item.text_color.a;
+
+
+ if(COLOR_IS_SAME(opc->osd_item.color_fg, transparent)) {
+ opc->osd_item.color_fg.r = 0x1111;
+ opc->osd_item.color_fg.g = 0x1111;
+ opc->osd_item.color_fg.b = 0x1111;
+ opc->osd_item.color_fg.a = 0x1111;
+ }
+
+ osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
+
+ graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_scale_draw), attr_postdraw, opc, nav));
+ if (navit_get_ready(nav) == 3)
+ osd_scale_draw(opc, nav);
+}
+
+static struct osd_priv *osd_scale_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct osd_scale *this = g_new0(struct osd_scale, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+
+ opc->data = (void*)this;
+ opc->osd_item.font_size = 200;
+ opc->osd_item.navit = nav;
+ opc->osd_item.meth.draw = osd_draw_cast(osd_scale_draw);
+ meth->set_attr = set_std_osd_attr;
+
+ osd_set_std_attr(attrs, &opc->osd_item, TRANSPARENT_BG | ITEM_HAS_TEXT);
+
+ navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_scale_init), attr_graphics_ready,
+ opc));
+
+ return (struct osd_priv *) opc;
}
struct auxmap {
- struct displaylist *displaylist;
- struct transformation *ntrans;
- struct transformation *trans;
- struct layout *layout;
- struct callback *postdraw_cb;
- struct graphics_gc *red;
- struct navit *nav;
+ struct displaylist *displaylist;
+ struct transformation *ntrans;
+ struct transformation *trans;
+ struct layout *layout;
+ struct callback *postdraw_cb;
+ struct graphics_gc *red;
+ struct navit *nav;
};
-static void
-osd_auxmap_draw(struct osd_priv_common *opc)
-{
- struct auxmap *this = (struct auxmap *)opc->data;
-
- int d=10;
- struct point p;
- struct attr mapset;
-
- if (!opc->osd_item.configured)
- return;
- if (!navit_get_attr(this->nav, attr_mapset, &mapset, NULL) || !mapset.u.mapset)
- return;
- p.x=opc->osd_item.w/2;
- p.y=opc->osd_item.h/2;
-
- if (opc->osd_item.rel_h || opc->osd_item.rel_w) {
- struct map_selection sel;
- memset(&sel, 0, sizeof(sel));
- sel.u.p_rect.rl.x=opc->osd_item.w;
- sel.u.p_rect.rl.y=opc->osd_item.h;
- dbg(lvl_debug,"osd_auxmap_draw: sel.u.p_rect.rl=(%d, %d)\n", opc->osd_item.w, opc->osd_item.h);
- transform_set_screen_selection(this->trans, &sel);
- graphics_set_rect(opc->osd_item.gr, &sel.u.p_rect);
- }
-
- transform_set_center(this->trans, transform_get_center(this->ntrans));
- transform_set_scale(this->trans, 64);
- transform_set_yaw(this->trans, transform_get_yaw(this->ntrans));
- transform_setup_source_rect(this->trans);
- transform_set_projection(this->trans, transform_get_projection(this->ntrans));
+static void osd_auxmap_draw(struct osd_priv_common *opc) {
+ struct auxmap *this = (struct auxmap *)opc->data;
+
+ int d=10;
+ struct point p;
+ struct attr mapset;
+
+ if (!opc->osd_item.configured)
+ return;
+ if (!navit_get_attr(this->nav, attr_mapset, &mapset, NULL) || !mapset.u.mapset)
+ return;
+ p.x=opc->osd_item.w/2;
+ p.y=opc->osd_item.h/2;
+
+ if (opc->osd_item.rel_h || opc->osd_item.rel_w) {
+ struct map_selection sel;
+ memset(&sel, 0, sizeof(sel));
+ sel.u.p_rect.rl.x=opc->osd_item.w;
+ sel.u.p_rect.rl.y=opc->osd_item.h;
+ dbg(lvl_debug,"osd_auxmap_draw: sel.u.p_rect.rl=(%d, %d)", opc->osd_item.w, opc->osd_item.h);
+ transform_set_screen_selection(this->trans, &sel);
+ graphics_set_rect(opc->osd_item.gr, &sel.u.p_rect);
+ }
+
+ transform_set_center(this->trans, transform_get_center(this->ntrans));
+ transform_set_scale(this->trans, 64);
+ transform_set_yaw(this->trans, transform_get_yaw(this->ntrans));
+ transform_setup_source_rect(this->trans);
+ transform_set_projection(this->trans, transform_get_projection(this->ntrans));
#if 0
- graphics_displaylist_draw(opc->osd_item.gr, this->displaylist, this->trans, this->layout, 4);
+ graphics_displaylist_draw(opc->osd_item.gr, this->displaylist, this->trans, this->layout, 4);
#endif
- graphics_draw(opc->osd_item.gr, this->displaylist, mapset.u.mapset, this->trans, this->layout, 0, NULL, 1);
- graphics_draw_circle(opc->osd_item.gr, this->red, &p, d);
- graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
-
-}
-
-static void
-osd_auxmap_init(struct osd_priv_common *opc, struct navit *nav)
-{
- struct auxmap *this = (struct auxmap *)opc->data;
-
- struct graphics *gra;
- struct attr attr;
- struct map_selection sel;
- struct pcoord center={ projection_mg, 0, 0};
- struct color red={0xffff,0x0,0x0,0xffff};
-
- this->nav=nav;
- if (! navit_get_attr(nav, attr_graphics, &attr, NULL))
- return;
- gra=attr.u.graphics;
- graphics_add_callback(gra, callback_new_attr_1(callback_cast(osd_auxmap_draw), attr_postdraw, opc));
- if (! navit_get_attr(nav, attr_transformation, &attr, NULL))
- return;
- this->ntrans=attr.u.transformation;
- if (! navit_get_attr(nav, attr_displaylist, &attr, NULL))
- return;
- this->displaylist=attr.u.displaylist;
- if (! navit_get_attr(nav, attr_layout, &attr, NULL))
- return;
- this->layout=attr.u.layout;
- osd_set_std_graphic(nav, &opc->osd_item, NULL);
- graphics_init(opc->osd_item.gr);
- this->red=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->red,&red);
- graphics_gc_set_linewidth(this->red,3);
- memset(&sel, 0, sizeof(sel));
- sel.u.p_rect.rl.x=opc->osd_item.w;
- sel.u.p_rect.rl.y=opc->osd_item.h;
- this->trans=transform_new(&center, 16, 0);
- transform_set_screen_selection(this->trans, &sel);
- graphics_set_rect(opc->osd_item.gr, &sel.u.p_rect);
+ graphics_draw(opc->osd_item.gr, this->displaylist, mapset.u.mapset, this->trans, this->layout, 0, NULL, 1);
+ graphics_draw_circle(opc->osd_item.gr, this->red, &p, d);
+ graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
+
+}
+
+static void osd_auxmap_init(struct osd_priv_common *opc, struct navit *nav) {
+ struct auxmap *this = (struct auxmap *)opc->data;
+
+ struct graphics *gra;
+ struct attr attr;
+ struct map_selection sel;
+ struct pcoord center= { projection_mg, 0, 0};
+ struct color red= {0xffff,0x0,0x0,0xffff};
+
+ this->nav=nav;
+ if (! navit_get_attr(nav, attr_graphics, &attr, NULL))
+ return;
+ gra=attr.u.graphics;
+ graphics_add_callback(gra, callback_new_attr_1(callback_cast(osd_auxmap_draw), attr_postdraw, opc));
+ if (! navit_get_attr(nav, attr_transformation, &attr, NULL))
+ return;
+ this->ntrans=attr.u.transformation;
+ if (! navit_get_attr(nav, attr_displaylist, &attr, NULL))
+ return;
+ this->displaylist=attr.u.displaylist;
+ if (! navit_get_attr(nav, attr_layout, &attr, NULL))
+ return;
+ this->layout=attr.u.layout;
+ osd_set_std_graphic(nav, &opc->osd_item, NULL);
+ graphics_init(opc->osd_item.gr);
+ this->red=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->red,&red);
+ graphics_gc_set_linewidth(this->red,3);
+ memset(&sel, 0, sizeof(sel));
+ sel.u.p_rect.rl.x=opc->osd_item.w;
+ sel.u.p_rect.rl.y=opc->osd_item.h;
+ this->trans=transform_new(&center, 16, 0);
+ transform_set_screen_selection(this->trans, &sel);
+ graphics_set_rect(opc->osd_item.gr, &sel.u.p_rect);
#if 0
- osd_auxmap_draw(opc, nav);
+ osd_auxmap_draw(opc, nav);
#endif
}
-static struct osd_priv *
-osd_auxmap_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs)
-{
- struct auxmap *this = g_new0(struct auxmap, 1);
- struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
- opc->data = (void*)this;
-
- opc->osd_item.rel_x = 20;
- opc->osd_item.rel_y = -80;
- opc->osd_item.rel_w = 60;
- opc->osd_item.rel_h = 40;
- opc->osd_item.font_size = 200;
- meth->set_attr = set_std_osd_attr;
- osd_set_std_attr(attrs, &opc->osd_item, 0);
-
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_auxmap_init), attr_navit, opc));
- return (struct osd_priv *) opc;
-}
-
-
-void
-plugin_init(void)
-{
- plugin_register_category_osd("compass", osd_compass_new);
- plugin_register_category_osd("navigation_next_turn", osd_nav_next_turn_new);
- plugin_register_category_osd("button", osd_button_new);
- plugin_register_category_osd("toggle_announcer", osd_nav_toggle_announcer_new);
- plugin_register_category_osd("speed_warner", osd_speed_warner_new);
- plugin_register_category_osd("speed_cam", osd_speed_cam_new);
- plugin_register_category_osd("text", osd_text_new);
- plugin_register_category_osd("gps_status", osd_gps_status_new);
- plugin_register_category_osd("volume", osd_volume_new);
- plugin_register_category_osd("scale", osd_scale_new);
- plugin_register_category_osd("image", osd_image_new);
- plugin_register_category_osd("stopwatch", osd_stopwatch_new);
- plugin_register_category_osd("odometer", osd_odometer_new);
- plugin_register_category_osd("auxmap", osd_auxmap_new);
- plugin_register_category_osd("cmd_interface", osd_cmd_interface_new);
- plugin_register_category_osd("route_guard", osd_route_guard_new);
- plugin_register_category_osd("navigation_status", osd_navigation_status_new);
+static struct osd_priv *osd_auxmap_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs) {
+ struct auxmap *this = g_new0(struct auxmap, 1);
+ struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
+ opc->data = (void*)this;
+
+ opc->osd_item.rel_x = 20;
+ opc->osd_item.rel_y = -80;
+ opc->osd_item.rel_w = 60;
+ opc->osd_item.rel_h = 40;
+ opc->osd_item.font_size = 200;
+ meth->set_attr = set_std_osd_attr;
+
+ osd_set_std_attr(attrs, &opc->osd_item, 0);
+
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_auxmap_init), attr_navit, opc));
+ return (struct osd_priv *) opc;
+}
+
+
+void plugin_init(void) {
+ plugin_register_category_osd("compass", osd_compass_new);
+ plugin_register_category_osd("navigation_next_turn", osd_nav_next_turn_new);
+ plugin_register_category_osd("button", osd_button_new);
+ plugin_register_category_osd("toggle_announcer", osd_nav_toggle_announcer_new);
+ plugin_register_category_osd("speed_warner", osd_speed_warner_new);
+ plugin_register_category_osd("speed_cam", osd_speed_cam_new);
+ plugin_register_category_osd("text", osd_text_new);
+ plugin_register_category_osd("gps_status", osd_gps_status_new);
+ plugin_register_category_osd("volume", osd_volume_new);
+ plugin_register_category_osd("scale", osd_scale_new);
+ plugin_register_category_osd("image", osd_image_new);
+ plugin_register_category_osd("stopwatch", osd_stopwatch_new);
+ plugin_register_category_osd("odometer", osd_odometer_new);
+ plugin_register_category_osd("auxmap", osd_auxmap_new);
+ plugin_register_category_osd("cmd_interface", osd_cmd_interface_new);
+ plugin_register_category_osd("route_guard", osd_route_guard_new);
+ plugin_register_category_osd("navigation_status", osd_navigation_status_new);
}
diff --git a/navit/param.c b/navit/param.c
index fbf14b316..b49e03a56 100644
--- a/navit/param.c
+++ b/navit/param.c
@@ -22,49 +22,41 @@
#include <stdlib.h>
#include "param.h"
-void
-param_add_string(const char *name, const char *value, struct param_list **param, int *count)
-{
- char *param_name;
- char *param_value;
- if (*count > 0) {
- param_name=malloc(strlen(value)+strlen(name)+2);
- param_value=param_name+strlen(name)+1;
- strcpy(param_name, name);
- strcpy(param_value, value);
- (*param)->name=param_name;
- (*param)->value=param_value;
+void param_add_string(const char *name, const char *value, struct param_list **param, int *count) {
+ char *param_name;
+ char *param_value;
+ if (*count > 0) {
+ param_name=malloc(strlen(value)+strlen(name)+2);
+ param_value=param_name+strlen(name)+1;
+ strcpy(param_name, name);
+ strcpy(param_value, value);
+ (*param)->name=param_name;
+ (*param)->value=param_value;
+
+ (*count)--;
+ (*param)++;
+ }
- (*count)--;
- (*param)++;
- }
-
}
-void
-param_add_dec(const char *name, unsigned long value, struct param_list **param, int *count)
-{
- char buffer[1024];
- sprintf(buffer, "%ld", value);
- param_add_string(name, buffer, param, count);
+void param_add_dec(const char *name, unsigned long value, struct param_list **param, int *count) {
+ char buffer[1024];
+ sprintf(buffer, "%ld", value);
+ param_add_string(name, buffer, param, count);
}
-void
-param_add_hex(const char *name, unsigned long value, struct param_list **param, int *count)
-{
- char buffer[1024];
- sprintf(buffer, "0x%lx", value);
- param_add_string(name, buffer, param, count);
+void param_add_hex(const char *name, unsigned long value, struct param_list **param, int *count) {
+ char buffer[1024];
+ sprintf(buffer, "0x%lx", value);
+ param_add_string(name, buffer, param, count);
}
-void
-param_add_hex_sig(const char *name, long value, struct param_list **param, int *count)
-{
- char buffer[1024];
- if (value < 0)
- sprintf(buffer, "-0x%lx", -value);
- else
- sprintf(buffer, "0x%lx", value);
- param_add_string(name, buffer, param, count);
+void param_add_hex_sig(const char *name, long value, struct param_list **param, int *count) {
+ char buffer[1024];
+ if (value < 0)
+ sprintf(buffer, "-0x%lx", -value);
+ else
+ sprintf(buffer, "0x%lx", value);
+ param_add_string(name, buffer, param, count);
}
diff --git a/navit/phrase.c b/navit/phrase.c
index 9c7edaaa7..9fb5bc701 100644
--- a/navit/phrase.c
+++ b/navit/phrase.c
@@ -25,29 +25,26 @@
#include "speech.h"
#include "phrase.h"
-void
-phrase_route_calc(void *speech)
-{
+void phrase_route_calc(void *speech) {
#if 0
- if (! speech)
- return;
- speech_say(speech,"Die Route wird berechnet\n");
+ if (! speech)
+ return;
+ speech_say(speech,"Die Route wird berechnet\n");
#endif
}
-void
-phrase_route_calculated(void *speech, void *route)
-{
+void phrase_route_calculated(void *speech, void *route) {
#if 0
- struct tm *eta;
+ struct tm *eta;
#endif
- if (! speech)
- return;
+ if (! speech)
+ return;
#if 0 /* FIXME */
- eta=route_get_eta(route);
+ eta=route_get_eta(route);
- speech_sayf(speech,"Die Route wurde berechnet, geschätzte Ankunftszeit %d Uhr %d Entfernung %4.0f Kilometer", eta->tm_hour,eta->tm_min,route_get_len(route)/1000);
+ speech_sayf(speech,"Die Route wurde berechnet, geschätzte Ankunftszeit %d Uhr %d Entfernung %4.0f Kilometer",
+ eta->tm_hour,eta->tm_min,route_get_len(route)/1000);
#endif
}
diff --git a/navit/plugin.c b/navit/plugin.c
index 8c61bc9b7..82fcc61c5 100644
--- a/navit/plugin.c
+++ b/navit/plugin.c
@@ -1,4 +1,4 @@
-/**
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -38,15 +38,20 @@
#include "item.h"
#include "debug.h"
+/**
+ * @defgroup plugins
+ * @brief A interface to handle all plugins inside navit
+ *
+ * @{
+ */
+
#ifdef USE_PLUGINS
#ifndef HAVE_GMODULE
typedef void * GModule;
#define G_MODULE_BIND_LOCAL 1
#define G_MODULE_BIND_LAZY 2
-static int
-g_module_supported(void)
-{
- return 1;
+static int g_module_supported(void) {
+ return 1;
}
#ifdef HAVE_API_WIN32_BASE
@@ -54,382 +59,336 @@ g_module_supported(void)
static DWORD last_error;
static char errormsg[64];
-static void *
-g_module_open(char *name, int flags)
-{
- HINSTANCE handle;
- int len=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, 0, 0);
- wchar_t filename[len];
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, filename, len) ;
-
- handle = LoadLibraryW (filename);
- if (!handle)
- last_error=GetLastError();
- return handle;
+static void *g_module_open(char *name, int flags) {
+ HINSTANCE handle;
+ int len=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, 0, 0);
+ wchar_t filename[len];
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, filename, len) ;
+
+ handle = LoadLibraryW (filename);
+ if (!handle)
+ last_error=GetLastError();
+ return handle;
}
-static char *
-g_module_error(void)
-{
- sprintf(errormsg,"dll error %d",(int)last_error);
- return errormsg;
+static char *g_module_error(void) {
+ sprintf(errormsg,"dll error %d",(int)last_error);
+ return errormsg;
}
-static int
-g_module_symbol(GModule *handle, char *symbol, gpointer *addr)
-{
+static int g_module_symbol(GModule *handle, char *symbol, gpointer *addr) {
#ifdef HAVE_API_WIN32_CE
- int len=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, symbol, -1, 0, 0);
- wchar_t wsymbol[len+1];
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, symbol, -1, wsymbol, len) ;
- *addr=GetProcAddress ((HANDLE)handle, wsymbol);
+ int len=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, symbol, -1, 0, 0);
+ wchar_t wsymbol[len+1];
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, symbol, -1, wsymbol, len) ;
+ *addr=GetProcAddress ((HANDLE)handle, wsymbol);
#else
- *addr=GetProcAddress ((HANDLE)handle, symbol);
+ *addr=GetProcAddress ((HANDLE)handle, symbol);
#endif
- if (*addr)
- return 1;
- last_error=GetLastError();
- return 0;
+ if (*addr)
+ return 1;
+ last_error=GetLastError();
+ return 0;
}
-static void
-g_module_close(GModule *handle)
-{
- FreeLibrary((HANDLE)handle);
+static void g_module_close(GModule *handle) {
+ FreeLibrary((HANDLE)handle);
}
#else
-static void *
-g_module_open(char *name, int flags)
-{
- return dlopen(name,
- (flags & G_MODULE_BIND_LAZY ? RTLD_LAZY : RTLD_NOW) |
- (flags & G_MODULE_BIND_LOCAL ? RTLD_LOCAL : RTLD_GLOBAL));
+static void *g_module_open(char *name, int flags) {
+ return dlopen(name,
+ (flags & G_MODULE_BIND_LAZY ? RTLD_LAZY : RTLD_NOW) |
+ (flags & G_MODULE_BIND_LOCAL ? RTLD_LOCAL : RTLD_GLOBAL));
}
-static char *
-g_module_error(void)
-{
- return dlerror();
+static char *g_module_error(void) {
+ return dlerror();
}
-static int
-g_module_symbol(GModule *handle, char *symbol, gpointer *addr)
-{
- *addr=dlsym(handle, symbol);
- return (*addr != NULL);
+static int g_module_symbol(GModule *handle, char *symbol, gpointer *addr) {
+ *addr=dlsym(handle, symbol);
+ return (*addr != NULL);
}
-static void
-g_module_close(GModule *handle)
-{
- dlclose(handle);
+static void g_module_close(GModule *handle) {
+ dlclose(handle);
}
#endif
#endif
#endif
struct plugin {
- int active;
- int lazy;
- int ondemand;
- char *name;
+ int active;
+ int lazy;
+ int ondemand;
+ char *name;
#ifdef USE_PLUGINS
- GModule *mod;
+ GModule *mod;
#endif
- void (*init)(void);
+ void (*init)(void);
};
struct plugins {
- GHashTable *hash;
- GList *list;
+ GHashTable *hash;
+ GList *list;
} *pls;
-static struct plugin *
-plugin_new_from_path(char *plugin)
-{
+static struct plugin *plugin_new_from_path(char *plugin) {
#ifdef USE_PLUGINS
- struct plugin *ret;
- if (! g_module_supported()) {
- return NULL;
- }
- ret=g_new0(struct plugin, 1);
- ret->name=g_strdup(plugin);
- return ret;
+ struct plugin *ret;
+ if (! g_module_supported()) {
+ return NULL;
+ }
+ ret=g_new0(struct plugin, 1);
+ ret->name=g_strdup(plugin);
+ return ret;
#else
- return NULL;
+ return NULL;
#endif
}
-int
-plugin_load(struct plugin *pl)
-{
+int plugin_load(struct plugin *pl) {
#ifdef USE_PLUGINS
- gpointer init;
-
- GModule *mod;
-
- if (pl->mod) {
- dbg(lvl_debug,"'%s' already loaded, returning\n", pl->name);
- return 1;
- }
- mod=g_module_open(pl->name, G_MODULE_BIND_LOCAL | (pl->lazy ? G_MODULE_BIND_LAZY : 0));
- if (! mod) {
- dbg(lvl_error,"can't load '%s', Error '%s'\n", pl->name, g_module_error());
- return 0;
- }
- if (!g_module_symbol(mod, "plugin_init", &init)) {
- dbg(lvl_error,"can't load '%s', plugin_init not found\n", pl->name);
- g_module_close(mod);
- return 0;
- } else {
- dbg(lvl_debug, "loaded module %s\n", pl->name);
- pl->mod=mod;
- pl->init=init;
- }
- return 1;
+ gpointer init;
+
+ GModule *mod;
+
+ if (pl->mod) {
+ dbg(lvl_debug,"'%s' already loaded, returning", pl->name);
+ return 1;
+ }
+ mod=g_module_open(pl->name, G_MODULE_BIND_LOCAL | (pl->lazy ? G_MODULE_BIND_LAZY : 0));
+ if (! mod) {
+ dbg(lvl_error,"can't load '%s', Error '%s'", pl->name, g_module_error());
+ return 0;
+ }
+ if (!g_module_symbol(mod, "plugin_init", &init)) {
+ dbg(lvl_error,"can't load '%s', plugin_init not found", pl->name);
+ g_module_close(mod);
+ return 0;
+ } else {
+ dbg(lvl_debug, "loaded module %s", pl->name);
+ pl->mod=mod;
+ pl->init=init;
+ }
+ return 1;
#else
- return 0;
+ return 0;
#endif
}
-char *
-plugin_get_name(struct plugin *pl)
-{
- return pl->name;
+char *plugin_get_name(struct plugin *pl) {
+ return pl->name;
}
-int
-plugin_get_active(struct plugin *pl)
-{
- return pl->active;
+int plugin_get_active(struct plugin *pl) {
+ return pl->active;
}
-void
-plugin_set_active(struct plugin *pl, int active)
-{
- pl->active=active;
+void plugin_set_active(struct plugin *pl, int active) {
+ pl->active=active;
}
-void
-plugin_set_lazy(struct plugin *pl, int lazy)
-{
- pl->lazy=lazy;
+void plugin_set_lazy(struct plugin *pl, int lazy) {
+ pl->lazy=lazy;
}
#ifdef USE_PLUGINS
-static int
-plugin_get_ondemand(struct plugin *pl)
-{
- return pl->ondemand;
+static int plugin_get_ondemand(struct plugin *pl) {
+ return pl->ondemand;
}
#endif
-static void
-plugin_set_ondemand(struct plugin *pl, int ondemand)
-{
- pl->ondemand=ondemand;
+static void plugin_set_ondemand(struct plugin *pl, int ondemand) {
+ pl->ondemand=ondemand;
}
-void
-plugin_call_init(struct plugin *pl)
-{
- pl->init();
+void plugin_call_init(struct plugin *pl) {
+ pl->init();
}
-void
-plugin_unload(struct plugin *pl)
-{
+void plugin_unload(struct plugin *pl) {
#ifdef USE_PLUGINS
- g_module_close(pl->mod);
- pl->mod=NULL;
+ g_module_close(pl->mod);
+ pl->mod=NULL;
#endif
}
-void
-plugin_destroy(struct plugin *pl)
-{
- g_free(pl);
+void plugin_destroy(struct plugin *pl) {
+ g_free(pl);
}
struct plugins *
-plugins_new(void)
-{
- struct plugins *ret=g_new0(struct plugins, 1);
- ret->hash=g_hash_table_new(g_str_hash, g_str_equal);
- pls=ret;
- return ret;
+plugins_new(void) {
+ struct plugins *ret=g_new0(struct plugins, 1);
+ ret->hash=g_hash_table_new(g_str_hash, g_str_equal);
+ pls=ret;
+ return ret;
}
struct plugin *
plugin_new(struct attr *parent, struct attr **attrs) {
#ifdef USE_PLUGINS
- struct attr *path_attr, *attr;
- struct file_wordexp *we;
- int active=1; // default active
- int lazy=0, ondemand=0;
- int i, count;
- char **array;
- char *name;
- struct plugin *pl=NULL;
- struct plugins *pls=NULL;
-
- if (parent)
- pls=parent->u.plugins;
-
- if (! (path_attr=attr_search(attrs, NULL, attr_path))) {
- dbg(lvl_error,"missing path\n");
- return NULL;
- }
- if ( (attr=attr_search(attrs, NULL, attr_active))) {
- active=attr->u.num;
- }
- if ( (attr=attr_search(attrs, NULL, attr_lazy))) {
- lazy=attr->u.num;
- }
- if ( (attr=attr_search(attrs, NULL, attr_ondemand))) {
- ondemand=attr->u.num;
- }
- dbg(lvl_debug, "path=\"%s\", active=%d, lazy=%d, ondemand=%d\n",path_attr->u.str, active, lazy, ondemand);
-
- we=file_wordexp_new(path_attr->u.str);
- count=file_wordexp_get_count(we);
- array=file_wordexp_get_array(we);
- dbg(lvl_info,"expanded to %d words\n",count);
- if (count != 1 || file_exists(array[0])) {
- for (i = 0 ; i < count ; i++) {
- name=array[i];
- dbg(lvl_info,"found plugin module file [%d]: '%s'\n", i, name);
- if (! (pls && (pl=g_hash_table_lookup(pls->hash, name)))) {
- pl=plugin_new_from_path(name);
- if (! pl) {
- dbg(lvl_error,"failed to create plugin from file '%s'\n", name);
- continue;
- }
- if (pls) {
- g_hash_table_insert(pls->hash, plugin_get_name(pl), pl);
- pls->list=g_list_append(pls->list, pl);
- }
- } else {
- if (pls) {
- pls->list=g_list_remove(pls->list, pl);
- pls->list=g_list_append(pls->list, pl);
- }
- }
- plugin_set_active(pl, active);
- plugin_set_lazy(pl, lazy);
- plugin_set_ondemand(pl, ondemand);
- if (!pls && active) {
- if (!plugin_load(pl))
- plugin_set_active(pl, 0);
- else
- plugin_call_init(pl);
- }
- }
- }
- file_wordexp_destroy(we);
- return pl;
+ struct attr *path_attr, *attr;
+ struct file_wordexp *we;
+ int active=1; // default active
+ int lazy=0, ondemand=0;
+ int i, count;
+ char **array;
+ char *name;
+ struct plugin *pl=NULL;
+ struct plugins *pls=NULL;
+
+ if (parent)
+ pls=parent->u.plugins;
+
+ if (! (path_attr=attr_search(attrs, NULL, attr_path))) {
+ dbg(lvl_error,"missing path");
+ return NULL;
+ }
+ if ( (attr=attr_search(attrs, NULL, attr_active))) {
+ active=attr->u.num;
+ }
+ if ( (attr=attr_search(attrs, NULL, attr_lazy))) {
+ lazy=attr->u.num;
+ }
+ if ( (attr=attr_search(attrs, NULL, attr_ondemand))) {
+ ondemand=attr->u.num;
+ }
+ dbg(lvl_debug, "path=\"%s\", active=%d, lazy=%d, ondemand=%d",path_attr->u.str, active, lazy, ondemand);
+
+ we=file_wordexp_new(path_attr->u.str);
+ count=file_wordexp_get_count(we);
+ array=file_wordexp_get_array(we);
+ dbg(lvl_info,"expanded to %d words",count);
+ if (count != 1 || file_exists(array[0])) {
+ for (i = 0 ; i < count ; i++) {
+ name=array[i];
+ dbg(lvl_info,"found plugin module file [%d]: '%s'", i, name);
+ if (! (pls && (pl=g_hash_table_lookup(pls->hash, name)))) {
+ pl=plugin_new_from_path(name);
+ if (! pl) {
+ dbg(lvl_error,"failed to create plugin from file '%s'", name);
+ continue;
+ }
+ if (pls) {
+ g_hash_table_insert(pls->hash, plugin_get_name(pl), pl);
+ pls->list=g_list_append(pls->list, pl);
+ }
+ } else {
+ if (pls) {
+ pls->list=g_list_remove(pls->list, pl);
+ pls->list=g_list_append(pls->list, pl);
+ }
+ }
+ plugin_set_active(pl, active);
+ plugin_set_lazy(pl, lazy);
+ plugin_set_ondemand(pl, ondemand);
+ if (!pls && active) {
+ if (!plugin_load(pl))
+ plugin_set_active(pl, 0);
+ else
+ plugin_call_init(pl);
+ }
+ }
+ }
+ file_wordexp_destroy(we);
+ return pl;
#else
return 0;
#endif
}
-void
-plugins_init(struct plugins *pls)
-{
+void plugins_init(struct plugins *pls) {
#ifdef USE_PLUGINS
- struct plugin *pl;
- GList *l;
-
- l=pls->list;
- if (l){
- while (l) {
- pl=l->data;
- if (! plugin_get_ondemand(pl)) {
- if (plugin_get_active(pl))
- if (!plugin_load(pl))
- plugin_set_active(pl, 0);
- if (plugin_get_active(pl))
- plugin_call_init(pl);
- }
- l=g_list_next(l);
- }
- } else {
- dbg(lvl_error, "Warning: No plugins found. Is Navit installed correctly?\n");
- }
+ struct plugin *pl;
+ GList *l;
+
+ l=pls->list;
+ if (l) {
+ while (l) {
+ pl=l->data;
+ if (! plugin_get_ondemand(pl)) {
+ if (plugin_get_active(pl))
+ if (!plugin_load(pl))
+ plugin_set_active(pl, 0);
+ if (plugin_get_active(pl))
+ plugin_call_init(pl);
+ }
+ l=g_list_next(l);
+ }
+ } else {
+ dbg(lvl_error, "Warning: No plugins found. Is Navit installed correctly?");
+ }
#endif
}
-void
-plugins_destroy(struct plugins *pls)
-{
- GList *l;
- struct plugin *pl;
-
- l=pls->list;
- while (l) {
- pl=l->data;
- plugin_unload(pl);
- plugin_destroy(pl);
- }
- g_list_free(pls->list);
- g_hash_table_destroy(pls->hash);
- g_free(pls);
+void plugins_destroy(struct plugins *pls) {
+ GList *l;
+ struct plugin *pl;
+
+ l=pls->list;
+ while (l) {
+ pl=l->data;
+ plugin_unload(pl);
+ plugin_destroy(pl);
+ }
+ g_list_free(pls->list);
+ g_hash_table_destroy(pls->hash);
+ g_free(pls);
}
-static void *
-find_by_name(enum plugin_category category, const char *name)
-{
- GList *name_list=plugin_categories[category];
- while (name_list) {
- struct name_val *nv=name_list->data;
- if (!g_ascii_strcasecmp(nv->name, name))
- return nv->val;
- name_list=g_list_next(name_list);
- }
- return NULL;
+static void *find_by_name(enum plugin_category category, const char *name) {
+ GList *name_list=plugin_categories[category];
+ while (name_list) {
+ struct name_val *nv=name_list->data;
+ if (!g_ascii_strcasecmp(nv->name, name))
+ return nv->val;
+ name_list=g_list_next(name_list);
+ }
+ return NULL;
}
-void *
-plugin_get_category(enum plugin_category category, const char *category_name, const char *name)
-{
- GList *plugin_list;
- struct plugin *pl;
- char *mod_name, *filename=NULL, *corename=NULL;
- void *result=NULL;
-
- dbg(lvl_debug, "category=\"%s\", name=\"%s\"\n", category_name, name);
-
- if ((result=find_by_name(category, name))) {
- return result;
- }
- if (!pls)
- return NULL;
- plugin_list=pls->list;
- filename=g_strjoin("", "lib", category_name, "_", name, NULL);
- corename=g_strjoin("", "lib", category_name, "_", "core", NULL);
- while (plugin_list) {
- pl=plugin_list->data;
- if ((mod_name=g_strrstr(pl->name, "/")))
- mod_name++;
- else
- mod_name=pl->name;
- if (!g_ascii_strncasecmp(mod_name, filename, strlen(filename)) || !g_ascii_strncasecmp(mod_name, corename, strlen(corename))) {
- dbg(lvl_debug, "Loading module \"%s\"\n",pl->name) ;
- if (plugin_get_active(pl))
- if (!plugin_load(pl))
- plugin_set_active(pl, 0);
- if (plugin_get_active(pl))
- plugin_call_init(pl);
- if ((result=find_by_name(category, name))) {
- g_free(filename);
- g_free(corename);
- return result;
- }
- }
- plugin_list=g_list_next(plugin_list);
- }
- g_free(filename);
- g_free(corename);
- return NULL;
+void *plugin_get_category(enum plugin_category category, const char *category_name, const char *name) {
+ GList *plugin_list;
+ struct plugin *pl;
+ char *mod_name, *filename=NULL, *corename=NULL;
+ void *result=NULL;
+
+ dbg(lvl_debug, "category=\"%s\", name=\"%s\"", category_name, name);
+
+ if ((result=find_by_name(category, name))) {
+ return result;
+ }
+ if (!pls)
+ return NULL;
+ plugin_list=pls->list;
+ filename=g_strjoin("", "lib", category_name, "_", name, NULL);
+ corename=g_strjoin("", "lib", category_name, "_", "core", NULL);
+ while (plugin_list) {
+ pl=plugin_list->data;
+ if ((mod_name=g_strrstr(pl->name, "/")))
+ mod_name++;
+ else
+ mod_name=pl->name;
+ if (!g_ascii_strncasecmp(mod_name, filename, strlen(filename))
+ || !g_ascii_strncasecmp(mod_name, corename, strlen(corename))) {
+ dbg(lvl_debug, "Loading module \"%s\"",pl->name) ;
+ if (plugin_get_active(pl))
+ if (!plugin_load(pl))
+ plugin_set_active(pl, 0);
+ if (plugin_get_active(pl))
+ plugin_call_init(pl);
+ if ((result=find_by_name(category, name))) {
+ g_free(filename);
+ g_free(corename);
+ return result;
+ }
+ }
+ plugin_list=g_list_next(plugin_list);
+ }
+ g_free(filename);
+ g_free(corename);
+ return NULL;
}
diff --git a/navit/plugin.h b/navit/plugin.h
index 8a9fba0d7..05c390e33 100644
--- a/navit/plugin.h
+++ b/navit/plugin.h
@@ -49,6 +49,8 @@ enum plugin_category {
plugin_category_event,
/** Category for plugins which load fonts. */
plugin_category_font,
+ /** Category for plugins which retrieve traffic information. */
+ plugin_category_traffic,
/** Category for plugins which play audio */
plugin_category_audio,
/** Dummy for last entry. */
@@ -77,22 +79,22 @@ plugin_register_##name(PLUGIN_PROTO((*func),__VA_ARGS__)) \
{ \
if (plugin_##name##_func) \
(*plugin_##name##_func)(__VA_ARGS__); \
-}
+}
#define PLUGIN_FUNC1(name,t1,p1) \
PLUGIN_PROTO((*plugin_##name##_func),t1 p1); \
void plugin_call_##name(t1 p1) PLUGIN_CALL(name,p1) \
-PLUGIN_REGISTER(name,t1 p1)
+PLUGIN_REGISTER(name,t1 p1)
#define PLUGIN_FUNC3(name,t1,p1,t2,p2,t3,p3) \
PLUGIN_PROTO((*plugin_##name##_func),t1 p1,t2 p2,t3 p3); \
void plugin_call_##name(t1 p1,t2 p2, t3 p3) PLUGIN_CALL(name,p1,p2,p3) \
-PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3)
+PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3)
#define PLUGIN_FUNC4(name,t1,p1,t2,p2,t3,p3,t4,p4) \
PLUGIN_PROTO((*plugin_##name##_func),t1 p1,t2 p2,t3 p3,t4 p4); \
void plugin_call_##name(t1 p1,t2 p2, t3 p3, t4 p4) PLUGIN_CALL(name,p1,p2,p3,p4) \
-PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3,t4 p4)
+PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3,t4 p4)
struct name_val {
char *name;
@@ -118,7 +120,7 @@ void * \
plugin_get_category_##category(const char *name) \
{ \
return plugin_get_category(plugin_category_##category, #category, name); \
-}
+}
#else
#define PLUGIN_FUNC1(name,t1,p1) \
diff --git a/navit/plugin/j1850/j1850.c b/navit/plugin/j1850/j1850.c
index e6aede5fb..9ec608ba4 100644
--- a/navit/plugin/j1850/j1850.c
+++ b/navit/plugin/j1850/j1850.c
@@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
-/*
+/*
This plugin implements a small subset of the SAE j1850 protocal used in some cars.
So far the code assumes that it is run on Linux. It allows Navit to read the steering
wheel inputs and some metrics like RPM or the fuel tank level
@@ -105,14 +105,12 @@ void rand_str(char *dest, size_t length) {
* Write the cmd to the serial port
*
*/
-void write_to_serial_port(unsigned char *cmd, int device)
-{
- int n_written = 0;
- do {
+void write_to_serial_port(unsigned char *cmd, int device) {
+ int n_written = 0;
+ do {
n_written += write( device, &cmd[n_written], 1 );
- }
- while (cmd[n_written-1] != '\r' && n_written > 0);
- dbg(lvl_info,"sent %s to the serial port\n",cmd);
+ } while (cmd[n_written-1] != '\r' && n_written > 0);
+ dbg(lvl_info,"sent %s to the serial port",cmd);
}
/**
@@ -122,15 +120,13 @@ void write_to_serial_port(unsigned char *cmd, int device)
* @return nothing
*
* This is the main function of this plugin. It is called when navit is idle,
- * and performs the initialization of the obd device if needed, then reads
- * one char each time it is called, and puts this char in a buffer. When it
+ * and performs the initialization of the obd device if needed, then reads
+ * one char each time it is called, and puts this char in a buffer. When it
* reads an EOL character, the buffer is parsed, and the appropriate action is
* taken. The buffer is then cleared and we start over.
*
*/
-static void
-j1850_idle(struct j1850 *j1850)
-{
+static void j1850_idle(struct j1850 *j1850) {
int n; // used to keep track of the numbers of char read from the device
int value; // used to convert the ascii char to an int
char buf = '\0'; // the buffer where we store the char read from the device
@@ -150,16 +146,14 @@ j1850_idle(struct j1850 *j1850)
};
// Make sure we sent all init commands before trying to read
- if ( init_string[j1850->init_string_index])
- {
- dbg(lvl_info,"Sending next init command : %s\n",init_string[j1850->init_string_index]);
- if (j1850->device > 0 ){
+ if ( init_string[j1850->init_string_index]) {
+ dbg(lvl_info,"Sending next init command : %s",init_string[j1850->init_string_index]);
+ if (j1850->device > 0 ) {
write_to_serial_port(init_string[j1850->init_string_index++],j1850->device);
}
// Did we reach the last init command?
- if ( !init_string[j1850->init_string_index])
- {
+ if ( !init_string[j1850->init_string_index]) {
// if yes, switch to idle read instead of timed read
event_remove_timeout(j1850->idle);
j1850->idle=event_add_idle(125, j1850->callback);
@@ -170,68 +164,68 @@ j1850_idle(struct j1850 *j1850)
navit.u.navit=j1850->nav;
// If not connected, generate random messages for debugging purpose
- if (j1850->device < 0 ){
- rand_str(j1850->message,8);
- return;
+ if (j1850->device < 0 ) {
+ rand_str(j1850->message,8);
+ return;
}
-
+
n = read( j1850->device, &buf, 1 );
if(n == -1) {
- dbg(lvl_debug,"x\n");
+ dbg(lvl_debug,"x");
} else if (n==0) {
- dbg(lvl_debug,".\n");
+ dbg(lvl_debug,".");
} else {
if( buf == 13 ) {
gettimeofday(&tv, NULL);
unsigned long long millisecondsSinceEpoch =
(unsigned long long)(tv.tv_sec) * 1000 +
(unsigned long long)(tv.tv_usec) / 1000;
-
+
j1850->message[j1850->index]='\0';
FILE *fp;
fp = fopen(j1850->filename,"a");
fprintf(fp, "%llu,%s\n", millisecondsSinceEpoch, j1850->message);
- fclose(fp);
+ fclose(fp);
strncpy(header, j1850->message, 2);
header[2]='\0';
if( strncmp(header,"10",2)==0 ) {
- char * w1 = strndup(j1850->message+2, 2);
- char * w2 = strndup(j1850->message+4, 2);
- char * w3 = strndup(j1850->message+6, 2);
- j1850->engine_rpm = ((int)strtol(w1, NULL, 16) ) / 4 ;
- j1850->trans_rpm = ((int)strtol(w2, NULL, 16) ) / 4 ;
- j1850->map = (int)strtol(w3, NULL, 16);
+ char * w1 = strndup(j1850->message+2, 2);
+ char * w2 = strndup(j1850->message+4, 2);
+ char * w3 = strndup(j1850->message+6, 2);
+ j1850->engine_rpm = ((int)strtol(w1, NULL, 16) ) / 4 ;
+ j1850->trans_rpm = ((int)strtol(w2, NULL, 16) ) / 4 ;
+ j1850->map = (int)strtol(w3, NULL, 16);
} else if( strncmp(header,"3D",2)==0 ) {
if (strcmp(j1850->message, "3D110000EE") == 0) {
// noise
} else if (strcmp(j1850->message, "3D1120009B") == 0) {
- dbg(lvl_error,"L1\n");
+ dbg(lvl_error,"L1");
command_evaluate(&navit, "gui.spotify_volume_up()" );
} else if (strcmp(j1850->message, "3D110080C8") == 0) {
- dbg(lvl_error,"L2\n");
+ dbg(lvl_error,"L2");
command_evaluate(&navit, "gui.spotify_volume_toggle()" );
} else if (strcmp(j1850->message, "3D1110005A") == 0) {
- dbg(lvl_error,"L3\n");
+ dbg(lvl_error,"L3");
command_evaluate(&navit, "gui.spotify_volume_down()" );
} else if (strcmp(j1850->message, "3D110400C3") == 0) {
- dbg(lvl_error,"R1\n");
+ dbg(lvl_error,"R1");
command_evaluate(&navit, "gui.spotify_next_track()" );
} else if (strcmp(j1850->message, "3D110002D4") == 0) {
- dbg(lvl_error,"R2\n");
+ dbg(lvl_error,"R2");
command_evaluate(&navit, "gui.spotify_toggle()" );
} else if (strcmp(j1850->message, "3D11020076") == 0) {
- dbg(lvl_error,"R3\n");
+ dbg(lvl_error,"R3");
command_evaluate(&navit, "gui.spotify_previous_track()" );
} else {
- dbg(lvl_error,"Got button from %s\n", j1850->message);
+ dbg(lvl_error,"Got button from %s", j1850->message);
}
} else if( strncmp(header,"72",2)==0 ) {
- char * data=strndup(j1850->message+2, 8);
- j1850->odo=((int)strtol(data, NULL, 16) )/8000;
+ char * data=strndup(j1850->message+2, 8);
+ j1850->odo=((int)strtol(data, NULL, 16) )/8000;
} else if( strncmp(header,"90",2)==0 ) {
} else if( strncmp(header,"A4",2)==0 ) {
- char * w1 =strndup(j1850->message+2, 4);
- j1850->tank_level = ((int)strtol(w1, NULL, 16) ) / 4 ;
+ char * w1 =strndup(j1850->message+2, 4);
+ j1850->tank_level = ((int)strtol(w1, NULL, 16) ) / 4 ;
} else {
// printf(" ascii: %i [%s] with header [%s]\n",buf, response, header);
}
@@ -240,7 +234,7 @@ j1850_idle(struct j1850 *j1850)
j1850->index=0;
} else {
value=buf-48;
- if(value==-16 || buf == 10 ){
+ if(value==-16 || buf == 10 ) {
//space and newline, discard
return;
} else if (value>16) {
@@ -257,12 +251,12 @@ j1850_idle(struct j1850 *j1850)
j1850->index++;
}
// printf("{%c:%i}", buf,value);
- }
- }
+ }
+ }
}
/**
- * @brief Draws the j1850 OSD
+ * @brief Draws the j1850 OSD
* @param[in] j1850 - the j1850 struct containing the state of the plugin
* nav - the navit object
* v - the vehicle object
@@ -272,10 +266,8 @@ j1850_idle(struct j1850 *j1850)
* Draws the j1850 OSD. Currently it only displays the last parsed message
*
*/
-static void
-osd_j1850_draw(struct j1850 *this, struct navit *nav,
- struct vehicle *v)
-{
+static void osd_j1850_draw(struct j1850 *this, struct navit *nav,
+ struct vehicle *v) {
osd_std_draw(&this->osd_item);
struct point p, bbox[4];
@@ -300,13 +292,11 @@ osd_j1850_draw(struct j1850 *this, struct navit *nav,
* Initialize the j1850 OSD
*
*/
-static void
-osd_j1850_init(struct j1850 *this, struct navit *nav)
-{
+static void osd_j1850_init(struct j1850 *this, struct navit *nav) {
struct color c;
osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
-
+
// Used when debugging or when the device is offline
this->orange = graphics_gc_new(this->osd_item.gr);
c.r = 0xFFFF;
@@ -344,13 +334,11 @@ osd_j1850_init(struct j1850 *this, struct navit *nav)
* Sends 'cmd' and reads the reply from the device
*
*/
-void send_and_read(unsigned char *cmd, int USB)
-{
+void send_and_read(unsigned char *cmd, int USB) {
int n_written = 0;
do {
n_written += write( USB, &cmd[n_written], 1 );
- }
- while (cmd[n_written-1] != '\r' && n_written > 0);
+ } while (cmd[n_written-1] != '\r' && n_written > 0);
int n = 0;
char buf = '\0';
@@ -358,25 +346,23 @@ void send_and_read(unsigned char *cmd, int USB)
/* Whole response*/
char response[255];
- do
- {
- n = read( USB, &buf, 1 );
- if(n == -1) {
+ do {
+ n = read( USB, &buf, 1 );
+ if(n == -1) {
dbg(lvl_debug,"x");
- } else if (n==0) {
+ } else if (n==0) {
dbg(lvl_debug,".");
- } else {
+ } else {
dbg(lvl_debug,"[%s]", &buf);
- }
- }
- while( buf != '\r' && n > 0);
+ }
+ } while( buf != '\r' && n > 0);
if (n < 0) {
- dbg(lvl_error,"Read error\n");
+ dbg(lvl_error,"Read error");
} else if (n == 0) {
- dbg(lvl_error,"Nothing to read?\n");
+ dbg(lvl_error,"Nothing to read?");
} else {
- dbg(lvl_error,"Response : \n");
+ dbg(lvl_error,"Response : ");
}
}
@@ -389,62 +375,57 @@ void send_and_read(unsigned char *cmd, int USB)
* Opens the serial port and saves state to the j1850 object
*
*/
-void
-j1850_init_serial_port(struct j1850 *j1850)
-{
- j1850->callback=callback_new_1(callback_cast(j1850_idle), j1850);
- // Fixme : we should read the device path from the config file
- j1850->device = open( "/dev/ttyUSB0", O_RDWR| O_NOCTTY );
- if ( j1850->device < 0 )
- {
- dbg(lvl_error,"Can't open port\n");
- j1850->idle=event_add_timeout(100, 1, j1850->callback);
- return;
- }
-
- struct termios tty;
- struct termios tty_old;
- memset (&tty, 0, sizeof tty);
-
- /* Error Handling */
- if ( tcgetattr ( j1850->device, &tty ) != 0 )
- {
- dbg(lvl_error,"Error\n");
- return;
- }
-
- /* Save old tty parameters */
- tty_old = tty;
-
- /* Set Baud Rate */
- cfsetospeed (&tty, (speed_t)B115200);
- cfsetispeed (&tty, (speed_t)B115200);
-
- /* Setting other Port Stuff */
- tty.c_cflag &= ~PARENB; // Make 8n1
- tty.c_cflag &= ~CSTOPB;
- tty.c_cflag &= ~CSIZE;
- tty.c_cflag |= CS8;
-
- tty.c_cflag &= ~CRTSCTS; // no flow control
- tty.c_cc[VMIN] = 1; // read doesn't block
- tty.c_cc[VTIME] = 10; // 0.5 seconds read timeout
- tty.c_cflag |= CREAD | CLOCAL; // turn on READ & ignore ctrl lines
-
- /* Make raw */
- cfmakeraw(&tty);
-
- /* Flush Port, then applies attributes */
- tcflush( j1850->device, TCIFLUSH );
- if ( tcsetattr ( j1850->device, TCSANOW, &tty ) != 0)
- {
- dbg(lvl_error,"Flush error\n");
- return;
- }
-
- dbg(lvl_error,"Port init ok\n");
- // For the init part, we want to wait 1sec before each init string
- j1850->idle=event_add_timeout(1000, 1, j1850->callback);
+void j1850_init_serial_port(struct j1850 *j1850) {
+ j1850->callback=callback_new_1(callback_cast(j1850_idle), j1850);
+ // Fixme : we should read the device path from the config file
+ j1850->device = open( "/dev/ttyUSB0", O_RDWR| O_NOCTTY );
+ if ( j1850->device < 0 ) {
+ dbg(lvl_error,"Can't open port");
+ j1850->idle=event_add_timeout(100, 1, j1850->callback);
+ return;
+ }
+
+ struct termios tty;
+ struct termios tty_old;
+ memset (&tty, 0, sizeof tty);
+
+ /* Error Handling */
+ if ( tcgetattr ( j1850->device, &tty ) != 0 ) {
+ dbg(lvl_error,"Error");
+ return;
+ }
+
+ /* Save old tty parameters */
+ tty_old = tty;
+
+ /* Set Baud Rate */
+ cfsetospeed (&tty, (speed_t)B115200);
+ cfsetispeed (&tty, (speed_t)B115200);
+
+ /* Setting other Port Stuff */
+ tty.c_cflag &= ~PARENB; // Make 8n1
+ tty.c_cflag &= ~CSTOPB;
+ tty.c_cflag &= ~CSIZE;
+ tty.c_cflag |= CS8;
+
+ tty.c_cflag &= ~CRTSCTS; // no flow control
+ tty.c_cc[VMIN] = 1; // read doesn't block
+ tty.c_cc[VTIME] = 10; // 0.5 seconds read timeout
+ tty.c_cflag |= CREAD | CLOCAL; // turn on READ & ignore ctrl lines
+
+ /* Make raw */
+ cfmakeraw(&tty);
+
+ /* Flush Port, then applies attributes */
+ tcflush( j1850->device, TCIFLUSH );
+ if ( tcsetattr ( j1850->device, TCSANOW, &tty ) != 0) {
+ dbg(lvl_error,"Flush error");
+ return;
+ }
+
+ dbg(lvl_error,"Port init ok");
+ // For the init part, we want to wait 1sec before each init string
+ j1850->idle=event_add_timeout(1000, 1, j1850->callback);
}
/**
@@ -458,16 +439,14 @@ j1850_init_serial_port(struct j1850 *j1850)
* Creates the j1850 OSD and set some default properties
*
*/
-static struct osd_priv *
-osd_j1850_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
+static struct osd_priv *osd_j1850_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
struct j1850 *this=g_new0(struct j1850, 1);
this->nav=nav;
time_t current_time = time(NULL);
// FIXME : make sure that the directory we log to exists!
this->filename=g_strdup_printf("/home/navit/.navit/obd/%ld.log",(long)current_time);
- dbg(lvl_error,"Will log to %s\n", this->filename);
+ dbg(lvl_error,"Will log to %s", this->filename);
this->init_string_index=0;
struct attr *attr;
this->osd_item.p.x = 120;
@@ -493,11 +472,9 @@ osd_j1850_new(struct navit *nav, struct osd_methods *meth,
* The plugin entry point
*
*/
-void
-plugin_init(void)
-{
- struct attr callback,navit;
- struct attr_iter *iter;
+void plugin_init(void) {
+ struct attr callback,navit;
+ struct attr_iter *iter;
- plugin_register_category_osd("j1850", osd_j1850_new);
+ plugin_register_category_osd("j1850", osd_j1850_new);
}
diff --git a/navit/plugin/pedestrian/pedestrian.c b/navit/plugin/pedestrian/pedestrian.c
index 7e5a4361d..a0407c873 100644
--- a/navit/plugin/pedestrian/pedestrian.c
+++ b/navit/plugin/pedestrian/pedestrian.c
@@ -61,9 +61,9 @@ static struct map *global_map;
int orientation,orientation_old;
struct pedestrian {
- struct navit *nav;
- int w,h;
- int yaw;
+ struct navit *nav;
+ int w,h;
+ int yaw;
} pedestrian_data;
int sensors_locked;
@@ -72,404 +72,423 @@ struct attr initial_layout, main_layout;
struct rocket {
- struct navit *navit;
- struct layout *layout;
- struct graphics *gra;
- struct transformation *trans;
- struct displaylist *dl;
- struct mapset *ms;
- int a,g,t,hog,v,vscale;
- struct callback *callback;
- struct event_idle *idle;
+ struct navit *navit;
+ struct layout *layout;
+ struct graphics *gra;
+ struct transformation *trans;
+ struct displaylist *dl;
+ struct mapset *ms;
+ int a,g,t,hog,v,vscale;
+ struct callback *callback;
+ struct event_idle *idle;
};
-static void
-pedestrian_rocket_idle(struct rocket *rocket)
-{
- struct attr follow;
- follow.type=attr_follow;
- follow.u.num=100;
- transform_set_hog(rocket->trans, rocket->hog);
- graphics_displaylist_draw(rocket->gra, rocket->dl, rocket->trans, rocket->layout, 0);
- rocket->v+=rocket->a-rocket->g;
- dbg(lvl_debug,"enter v=%d\n",rocket->v);
- if (rocket->t > 0)
- rocket->t--;
- else
- rocket->a=0;
- rocket->hog+=rocket->v/rocket->vscale;
- dbg(lvl_debug,"hog=%d\n",rocket->hog);
- if (rocket->hog < 0) {
- transform_set_hog(rocket->trans, 0);
- transform_set_order_base(rocket->trans, 14);
- transform_set_scale(rocket->trans, transform_get_scale(rocket->trans));
- graphics_overlay_disable(rocket->gra, 0);
- navit_draw(rocket->navit);
- follow.u.num=1;
- event_remove_idle(rocket->idle);
- rocket->idle=NULL;
- sensors_locked=0;
- }
- navit_set_attr(rocket->navit, &follow);
+static void pedestrian_rocket_idle(struct rocket *rocket) {
+ struct attr follow;
+ follow.type=attr_follow;
+ follow.u.num=100;
+ transform_set_hog(rocket->trans, rocket->hog);
+ graphics_displaylist_draw(rocket->gra, rocket->dl, rocket->trans, rocket->layout, 0);
+ rocket->v+=rocket->a-rocket->g;
+ dbg(lvl_debug,"enter v=%d",rocket->v);
+ if (rocket->t > 0)
+ rocket->t--;
+ else
+ rocket->a=0;
+ rocket->hog+=rocket->v/rocket->vscale;
+ dbg(lvl_debug,"hog=%d",rocket->hog);
+ if (rocket->hog < 0) {
+ transform_set_hog(rocket->trans, 0);
+ transform_set_order_base(rocket->trans, 14);
+ transform_set_scale(rocket->trans, transform_get_scale(rocket->trans));
+ graphics_overlay_disable(rocket->gra, 0);
+ navit_draw(rocket->navit);
+ follow.u.num=1;
+ event_remove_idle(rocket->idle);
+ rocket->idle=NULL;
+ sensors_locked=0;
+ }
+ navit_set_attr(rocket->navit, &follow);
}
-static void
-pedestrian_cmd_pedestrian_rocket(struct rocket *rocket)
-{
- struct attr attr;
- int max=0;
+static void pedestrian_cmd_pedestrian_rocket(struct rocket *rocket) {
+ struct attr attr;
+ int max=0;
#if 0
- int i,step=10;
+ int i,step=10;
#endif
- rocket->a=2;
- rocket->g=1;
- rocket->t=100;
- rocket->hog=0;
- rocket->v=0;
- rocket->vscale=10;
- if (! navit_get_attr(rocket->navit, attr_graphics, &attr, NULL))
- return;
- rocket->gra=attr.u.graphics;
- if (! navit_get_attr(rocket->navit, attr_transformation, &attr, NULL))
- return;
- rocket->trans=attr.u.transformation;
- if (! navit_get_attr(rocket->navit, attr_displaylist, &attr, NULL))
- return;
- rocket->dl=attr.u.displaylist;
- if (! navit_get_attr(rocket->navit, attr_mapset, &attr, NULL))
- return;
- rocket->ms=attr.u.mapset;
- transform_set_hog(rocket->trans, max);
- transform_set_order_base(rocket->trans, 14);
- transform_set_scale(rocket->trans, transform_get_scale(rocket->trans));
- transform_setup_source_rect(rocket->trans);
- graphics_overlay_disable(rocket->gra, 1);
- graphics_draw(rocket->gra, rocket->dl, rocket->ms, rocket->trans, rocket->layout, 0, NULL, 0);
- sensors_locked=1;
- if (!rocket->idle)
- rocket->idle=event_add_idle(50, rocket->callback);
+ rocket->a=2;
+ rocket->g=1;
+ rocket->t=100;
+ rocket->hog=0;
+ rocket->v=0;
+ rocket->vscale=10;
+ if (! navit_get_attr(rocket->navit, attr_graphics, &attr, NULL))
+ return;
+ rocket->gra=attr.u.graphics;
+ if (! navit_get_attr(rocket->navit, attr_transformation, &attr, NULL))
+ return;
+ rocket->trans=attr.u.transformation;
+ if (! navit_get_attr(rocket->navit, attr_displaylist, &attr, NULL))
+ return;
+ rocket->dl=attr.u.displaylist;
+ if (! navit_get_attr(rocket->navit, attr_mapset, &attr, NULL))
+ return;
+ rocket->ms=attr.u.mapset;
+ transform_set_hog(rocket->trans, max);
+ transform_set_order_base(rocket->trans, 14);
+ transform_set_scale(rocket->trans, transform_get_scale(rocket->trans));
+ transform_setup_source_rect(rocket->trans);
+ graphics_overlay_disable(rocket->gra, 1);
+ graphics_draw(rocket->gra, rocket->dl, rocket->ms, rocket->trans, rocket->layout, 0, NULL, 0);
+ sensors_locked=1;
+ if (!rocket->idle)
+ rocket->idle=event_add_idle(50, rocket->callback);
#if 0
- while (hog >= 0) {
- transform_set_hog(trans, hog);
+ while (hog >= 0) {
+ transform_set_hog(trans, hog);
#if 0
- graphics_draw(gra, dl, ms, trans, layout, 0, NULL);
+ graphics_draw(gra, dl, ms, trans, layout, 0, NULL);
#else
- graphics_displaylist_draw(gra, dl, trans, layout, 0);
+ graphics_displaylist_draw(gra, dl, trans, layout, 0);
#endif
- v=v+a-g;
- if (t > 0)
- t--;
- else
- a=0;
- hog=hog+v/vscale;
- }
+ v=v+a-g;
+ if (t > 0)
+ t--;
+ else
+ a=0;
+ hog=hog+v/vscale;
+ }
#if 0
- for (i = 0 ; i < max ; i+=step) {
- transform_set_hog(trans, i);
- graphics_displaylist_draw(gra, dl, trans, layout, 0);
- }
- for (i = max ; i >= 0 ; i-=step) {
- transform_set_hog(trans, i);
- graphics_displaylist_draw(gra, dl, trans, layout, 0);
- }
+ for (i = 0 ; i < max ; i+=step) {
+ transform_set_hog(trans, i);
+ graphics_displaylist_draw(gra, dl, trans, layout, 0);
+ }
+ for (i = max ; i >= 0 ; i-=step) {
+ transform_set_hog(trans, i);
+ graphics_displaylist_draw(gra, dl, trans, layout, 0);
+ }
#endif
#endif
}
static struct command_table commands[] = {
- {"pedestrian_rocket",command_cast(pedestrian_cmd_pedestrian_rocket)},
+ {"pedestrian_rocket",command_cast(pedestrian_cmd_pedestrian_rocket)},
};
-static void
-osd_rocket_init(struct navit *nav)
-{
- struct rocket *rocket=g_new0(struct rocket, 1);
- struct attr attr;
- rocket->navit=nav;
- rocket->callback=callback_new_1(callback_cast(pedestrian_rocket_idle), rocket);
- if (navit_get_attr(nav, attr_layout, &attr, NULL))
- rocket->layout=attr.u.layout;
- if (navit_get_attr(nav, attr_callback_list, &attr, NULL)) {
- dbg(lvl_debug,"ok\n");
- command_add_table(attr.u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), rocket);
- }
+static void osd_rocket_init(struct navit *nav) {
+ struct rocket *rocket=g_new0(struct rocket, 1);
+ struct attr attr;
+ rocket->navit=nav;
+ rocket->callback=callback_new_1(callback_cast(pedestrian_rocket_idle), rocket);
+ if (navit_get_attr(nav, attr_layout, &attr, NULL))
+ rocket->layout=attr.u.layout;
+ if (navit_get_attr(nav, attr_callback_list, &attr, NULL)) {
+ dbg(lvl_debug,"ok");
+ command_add_table(attr.u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), rocket);
+ }
}
struct marker {
- struct cursor *cursor;
+ struct cursor *cursor;
};
-static void
-osd_marker_draw(struct marker *this, struct navit *nav)
-{
+static void osd_marker_draw(struct marker *this, struct navit *nav) {
#if 0
- struct attr graphics;
- struct point p;
- dbg(lvl_debug,"enter\n");
- if (!navit_get_attr(nav, attr_graphics, &graphics, NULL))
- return;
- p.x=40;
- p.y=50;
- cursor_draw(this->cursor, graphics.u.graphics, &p, 0, 45, 0);
+ struct attr graphics;
+ struct point p;
+ dbg(lvl_debug,"enter");
+ if (!navit_get_attr(nav, attr_graphics, &graphics, NULL))
+ return;
+ p.x=40;
+ p.y=50;
+ cursor_draw(this->cursor, graphics.u.graphics, &p, 0, 45, 0);
#endif
}
-static void
-osd_marker_init(struct marker *this, struct navit *nav)
-{
- struct attr cursor;
- struct attr itemgra,polygon,polygoncoord1,polygoncoord2,polygoncoord3;
- struct attr *color=attr_new_from_text("color","#ff0000");
-
- cursor=(struct attr){attr_cursor, {(void *)cursor_new(NULL, (struct attr *[]){
- &(struct attr){attr_w,{(void *)26}},
- &(struct attr){attr_h,{(void *)26}},
- NULL})}};
- itemgra=(struct attr){attr_itemgra, {(void *)itemgra_new(&cursor, (struct attr *[]){
- NULL})}};
- cursor_add_attr(cursor.u.cursor, &itemgra);
- polygon=(struct attr){attr_polygon, {(void *)polygon_new(&itemgra, (struct attr *[]){
- color,
- &(struct attr){attr_width,{(void *)2}},
- NULL})}};
- itemgra_add_attr(itemgra.u.itemgra, &polygon);
- polygoncoord1=(struct attr){attr_coord, {(void *)coord_new_from_attrs(&polygon, (struct attr *[]){
- &(struct attr){attr_x,{(void *)-7}},
- &(struct attr){attr_y,{(void *)-10}},
- NULL})}};
- element_add_attr(polygon.u.element, &polygoncoord1);
- polygoncoord2=(struct attr){attr_coord, {(void *)coord_new_from_attrs(&polygon, (struct attr *[]){
- &(struct attr){attr_x,{(void *)0}},
- &(struct attr){attr_y,{(void *)12}},
- NULL})}};
- element_add_attr(polygon.u.element, &polygoncoord2);
- polygoncoord3=(struct attr){attr_coord, {(void *)coord_new_from_attrs(&polygon, (struct attr *[]){
- &(struct attr){attr_x,{(void *)7}},
- &(struct attr){attr_y,{(void *)-10}},
- NULL})}};
- element_add_attr(polygon.u.element, &polygoncoord3);
- attr_free(color);
- this->cursor=cursor.u.cursor;
- osd_marker_draw(this, nav);
+static void osd_marker_init(struct marker *this, struct navit *nav) {
+ struct attr cursor;
+ struct attr itemgra,polygon,polygoncoord1,polygoncoord2,polygoncoord3;
+ struct attr *color=attr_new_from_text("color","#ff0000");
+
+ cursor=(struct attr) {
+ attr_cursor, {(void *)cursor_new(NULL, (struct attr *[]) {
+ &(struct attr) {
+ attr_w, {(void *)26}
+ },
+ &(struct attr) {
+ attr_h, {(void *)26}
+ },
+ NULL
+ })
+ }
+ };
+ itemgra=(struct attr) {
+ attr_itemgra, {(void *)itemgra_new(&cursor, (struct attr *[]) {
+ NULL
+ })
+ }
+ };
+ cursor_add_attr(cursor.u.cursor, &itemgra);
+ polygon=(struct attr) {
+ attr_polygon, {(void *)polygon_new(&itemgra, (struct attr *[]) {
+ color,
+ &(struct attr) {
+ attr_width, {(void *)2}
+ },
+ NULL
+ })
+ }
+ };
+ itemgra_add_attr(itemgra.u.itemgra, &polygon);
+ polygoncoord1=(struct attr) {
+ attr_coord, {(void *)coord_new_from_attrs(&polygon, (struct attr *[]) {
+ &(struct attr) {
+ attr_x, {(void *)-7}
+ },
+ &(struct attr) {
+ attr_y, {(void *)-10}
+ },
+ NULL
+ })
+ }
+ };
+ element_add_attr(polygon.u.element, &polygoncoord1);
+ polygoncoord2=(struct attr) {
+ attr_coord, {(void *)coord_new_from_attrs(&polygon, (struct attr *[]) {
+ &(struct attr) {
+ attr_x, {(void *)0}
+ },
+ &(struct attr) {
+ attr_y, {(void *)12}
+ },
+ NULL
+ })
+ }
+ };
+ element_add_attr(polygon.u.element, &polygoncoord2);
+ polygoncoord3=(struct attr) {
+ attr_coord, {(void *)coord_new_from_attrs(&polygon, (struct attr *[]) {
+ &(struct attr) {
+ attr_x, {(void *)7}
+ },
+ &(struct attr) {
+ attr_y, {(void *)-10}
+ },
+ NULL
+ })
+ }
+ };
+ element_add_attr(polygon.u.element, &polygoncoord3);
+ attr_free(color);
+ this->cursor=cursor.u.cursor;
+ osd_marker_draw(this, nav);
}
-static struct osd_priv *
-osd_marker_new(struct navit *nav, struct osd_methods *meth,
- struct attr **attrs)
-{
- struct marker *this = g_new0(struct marker, 1);
- navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_marker_init), attr_navit, this));
- return (struct osd_priv *) this;
+static struct osd_priv *osd_marker_new(struct navit *nav, struct osd_methods *meth,
+ struct attr **attrs) {
+ struct marker *this = g_new0(struct marker, 1);
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_marker_init), attr_navit, this));
+ return (struct osd_priv *) this;
}
struct map_priv {
- struct navit *navit;
+ struct navit *navit;
};
struct map_rect_priv {
- struct map_priv *mpriv;
- struct item item;
- struct map_rect *route_map_rect;
- struct item *route_item;
- struct street_data *sd;
- struct coord c0;
- struct coord c_base;
- int checked;
- int idx_base;
- int idx_next;
- int idx;
- int first,last;
- int route_item_done;
- struct coord c_out;
- struct coord c_next;
- struct coord c_next_base;
- struct coord lseg[2];
- struct coord lseg_base[2];
- int lseg_done;
- int lseg_done_base;
+ struct map_priv *mpriv;
+ struct item item;
+ struct map_rect *route_map_rect;
+ struct item *route_item;
+ struct street_data *sd;
+ struct coord c0;
+ struct coord c_base;
+ int checked;
+ int idx_base;
+ int idx_next;
+ int idx;
+ int first,last;
+ int route_item_done;
+ struct coord c_out;
+ struct coord c_next;
+ struct coord c_next_base;
+ struct coord lseg[2];
+ struct coord lseg_base[2];
+ int lseg_done;
+ int lseg_done_base;
};
-static int
-map_route_occluded_bbox(struct map *map, struct coord_rect *bbox)
-{
- struct coord c[128];
- struct coord_rect r;
- int i,first=1,ccount;
- struct map_rect *map_rect=map_rect_new(map, NULL);
- struct item *item;
- while ((item=map_rect_get_item(map_rect))) {
- ccount=item_coord_get(item, c, 128);
- if (ccount && first) {
- r.lu=c[0];
- r.rl=c[0];
- first=0;
- }
- for (i = 0 ; i < ccount ; i++)
- coord_rect_extend(&r, &c[i]);
- }
- map_rect_destroy(map_rect);
- if (first)
- return 0;
- *bbox=r;
- return 1;
+static int map_route_occluded_bbox(struct map *map, struct coord_rect *bbox) {
+ struct coord c[128];
+ struct coord_rect r;
+ int i,first=1,ccount;
+ struct map_rect *map_rect=map_rect_new(map, NULL);
+ struct item *item;
+ while ((item=map_rect_get_item(map_rect))) {
+ ccount=item_coord_get(item, c, 128);
+ if (ccount && first) {
+ r.lu=c[0];
+ r.rl=c[0];
+ first=0;
+ }
+ for (i = 0 ; i < ccount ; i++)
+ coord_rect_extend(&r, &c[i]);
+ }
+ map_rect_destroy(map_rect);
+ if (first)
+ return 0;
+ *bbox=r;
+ return 1;
}
static struct building {
- struct street_data *sd;
- struct coord left,right;
- struct building *next;
+ struct street_data *sd;
+ struct coord left,right;
+ struct building *next;
} *buildings;
-static void
-map_route_occluded_buildings_free(void)
-{
- struct building *next,*b=buildings;
- while (b) {
- street_data_free(b->sd);
- next=b->next;
- g_free(b);
- b=next;
- }
- buildings=NULL;
+static void map_route_occluded_buildings_free(void) {
+ struct building *next,*b=buildings;
+ while (b) {
+ street_data_free(b->sd);
+ next=b->next;
+ g_free(b);
+ b=next;
+ }
+ buildings=NULL;
}
-static void
-map_route_occluded_get_buildings(struct mapset *mapset, struct coord_rect *r)
-{
- struct mapset_handle *msh=mapset_open(mapset);
- struct map *map;
- struct map_selection sel;
- struct map_rect *mr;
- struct item *item;
- struct building *b;
- sel.next=NULL;
- sel.u.c_rect=*r;
- sel.order=18;
- sel.range.min=type_poly_building;
- sel.range.max=type_poly_building;
-
- map_route_occluded_buildings_free();
- while ((map = mapset_next(msh, 1))) {
- mr=map_rect_new(map, &sel);
- while ((item = map_rect_get_item(mr))) {
- if (item->type == type_poly_building) {
+static void map_route_occluded_get_buildings(struct mapset *mapset, struct coord_rect *r) {
+ struct mapset_handle *msh=mapset_open(mapset);
+ struct map *map;
+ struct map_selection sel;
+ struct map_rect *mr;
+ struct item *item;
+ struct building *b;
+ sel.next=NULL;
+ sel.u.c_rect=*r;
+ sel.order=18;
+ sel.range.min=type_poly_building;
+ sel.range.max=type_poly_building;
+
+ map_route_occluded_buildings_free();
+ while ((map = mapset_next(msh, 1))) {
+ mr=map_rect_new(map, &sel);
+ while ((item = map_rect_get_item(mr))) {
+ if (item->type == type_poly_building) {
#if 0
- if (item->id_hi != 0x1 || item->id_lo != 0x1f69)
- continue;
+ if (item->id_hi != 0x1 || item->id_lo != 0x1f69)
+ continue;
#endif
-#if 0
- if (item->id_hi != 0x8)
- continue;
+#if 0
+ if (item->id_hi != 0x8)
+ continue;
#if 1
- if (item->id_lo != 0x2b3e0 && item->id_lo != 0x2ae7a && item->id_lo != 0x2af1a && item->id_lo != 0x2b348 && item->id_lo != 0x18bb5 && item->id_lo != 0x18ce5 && item->id_lo != 0x18a85)
-#else
- if (item->id_lo != 0x18bb5 && item->id_lo != 0x18ce5 && item->id_lo != 0x18a85)
+ if (item->id_lo != 0x2b3e0 && item->id_lo != 0x2ae7a && item->id_lo != 0x2af1a && item->id_lo != 0x2b348
+ && item->id_lo != 0x18bb5 && item->id_lo != 0x18ce5 && item->id_lo != 0x18a85)
+#else
+ if (item->id_lo != 0x18bb5 && item->id_lo != 0x18ce5 && item->id_lo != 0x18a85)
#endif
- continue;
-#endif
- b=g_new(struct building, 1);
- b->sd=street_get_data(item);
- b->next=buildings;
- buildings=b;
- }
- }
- map_rect_destroy(mr);
- }
+ continue;
+#endif
+ b=g_new(struct building, 1);
+ b->sd=street_get_data(item);
+ b->next=buildings;
+ buildings=b;
+ }
+ }
+ map_rect_destroy(mr);
+ }
}
FILE *debug,*debug2;
/* < 0 left, > 0 right */
-static int
-side(struct coord *l0, struct coord *l1, struct coord *p)
-{
- int dxl=l1->x-l0->x;
- int dyl=l1->y-l0->y;
- int dxp=p->x-l0->x;
- int dyp=p->y-l0->y;
-
- return dxp*dyl-dyp*dxl;
+static int side(struct coord *l0, struct coord *l1, struct coord *p) {
+ int dxl=l1->x-l0->x;
+ int dyl=l1->y-l0->y;
+ int dxp=p->x-l0->x;
+ int dyp=p->y-l0->y;
+
+ return dxp*dyl-dyp*dxl;
}
-static void
-map_route_occluded_check_buildings(struct coord *c0)
-{
- struct building *b=buildings;
- dbg(lvl_debug,"enter\n");
- int i,count;
- struct coord *c;
-#if 1
- FILE *bdebug,*bldebug;
- bdebug=fopen("tstb.txt","w");
- bldebug=fopen("tstbl.txt","w");
+static void map_route_occluded_check_buildings(struct coord *c0) {
+ struct building *b=buildings;
+ dbg(lvl_debug,"enter");
+ int i,count;
+ struct coord *c;
+#if 1
+ FILE *bdebug,*bldebug;
+ bdebug=fopen("tstb.txt","w");
+ bldebug=fopen("tstbl.txt","w");
+#endif
+ while (b) {
+ c=b->sd->c;
+ count=b->sd->count;
+ if (c[count-1].x == c[0].x && c[count-1].y == c[0].y) {
+#if 0
+ dbg(lvl_debug,"closed");
+#endif
+ count--;
+ }
+ for (i = 0 ; i < count ; i++) {
+ if (!i || side(c0, &b->left, &c[i]) < 0)
+ b->left=c[i];
+ if (!i || side(c0, &b->right, &c[i]) > 0)
+ b->right=c[i];
+ }
+#if 1
+ if (bdebug) {
+ fprintf(bdebug,"0x%x 0x%x type=poi_hospital\n", b->left.x, b->left.y);
+ fprintf(bdebug,"0x%x 0x%x type=poi_hospital\n", b->right.x, b->right.y);
+ }
+ if (bldebug) {
+ fprintf(bldebug,"type=street_nopass\n");
+ fprintf(bldebug,"0x%x 0x%x\n", c0->x, c0->y);
+ fprintf(bldebug,"0x%x 0x%x\n", c0->x+(b->left.x-c0->x)*10, c0->y+(b->left.y-c0->y)*10);
+ fprintf(bldebug,"type=street_nopass\n");
+ fprintf(bldebug,"0x%x 0x%x\n", c0->x, c0->y);
+ fprintf(bldebug,"0x%x 0x%x\n", c0->x+(b->right.x-c0->x)*10, c0->y+(b->right.y-c0->y)*10);
+ }
+#endif
+ b=b->next;
+ }
+#if 1
+ if (bdebug)
+ fclose(bdebug);
+ if (bldebug)
+ fclose(bldebug);
#endif
- while (b) {
- c=b->sd->c;
- count=b->sd->count;
- if (c[count-1].x == c[0].x && c[count-1].y == c[0].y) {
-#if 0
- dbg(lvl_debug,"closed\n");
-#endif
- count--;
- }
- for (i = 0 ; i < count ; i++) {
- if (!i || side(c0, &b->left, &c[i]) < 0)
- b->left=c[i];
- if (!i || side(c0, &b->right, &c[i]) > 0)
- b->right=c[i];
- }
-#if 1
- if (bdebug) {
- fprintf(bdebug,"0x%x 0x%x type=poi_hospital\n", b->left.x, b->left.y);
- fprintf(bdebug,"0x%x 0x%x type=poi_hospital\n", b->right.x, b->right.y);
- }
- if (bldebug) {
- fprintf(bldebug,"type=street_nopass\n");
- fprintf(bldebug,"0x%x 0x%x\n", c0->x, c0->y);
- fprintf(bldebug,"0x%x 0x%x\n", c0->x+(b->left.x-c0->x)*10, c0->y+(b->left.y-c0->y)*10);
- fprintf(bldebug,"type=street_nopass\n");
- fprintf(bldebug,"0x%x 0x%x\n", c0->x, c0->y);
- fprintf(bldebug,"0x%x 0x%x\n", c0->x+(b->right.x-c0->x)*10, c0->y+(b->right.y-c0->y)*10);
- }
-#endif
- b=b->next;
- }
-#if 1
- if (bdebug)
- fclose(bdebug);
- if (bldebug)
- fclose(bldebug);
-#endif
}
-static int
-intersect(struct coord *p1, struct coord *p2, struct coord *p3, struct coord *p4, struct coord *i)
-{
- double num=(p4->x-p3->x)*(p1->y-p3->y)-(p4->y-p3->y)*(p1->x-p3->x);
- double den=(p4->y-p3->y)*(p2->x-p1->x)-(p4->x-p3->x)*(p2->y-p1->y);
- if (num < 0 && den < 0) {
- num=-num;
- den=-den;
- }
- dbg(lvl_debug,"num=%f den=%f\n", num, den);
- if (i) {
- i->x=p1->x+(num/den)*(p2->x-p1->x)+0.5;
- i->y=p1->y+(num/den)*(p2->y-p1->y)+0.5;
- dbg(lvl_debug,"i=0x%x,0x%x\n", i->x, i->y);
- if (debug2)
- fprintf(debug2, "0x%x 0x%x type=town_label_5e3\n", i->x, i->y);
- }
- if (num < 0 || den < 0)
- return -1;
- if (num > den)
- return 257;
- return 256*num/den;
+static int intersect(struct coord *p1, struct coord *p2, struct coord *p3, struct coord *p4, struct coord *i) {
+ double num=(p4->x-p3->x)*(p1->y-p3->y)-(p4->y-p3->y)*(p1->x-p3->x);
+ double den=(p4->y-p3->y)*(p2->x-p1->x)-(p4->x-p3->x)*(p2->y-p1->y);
+ if (num < 0 && den < 0) {
+ num=-num;
+ den=-den;
+ }
+ dbg(lvl_debug,"num=%f den=%f", num, den);
+ if (i) {
+ i->x=p1->x+(num/den)*(p2->x-p1->x)+0.5;
+ i->y=p1->y+(num/den)*(p2->y-p1->y)+0.5;
+ dbg(lvl_debug,"i=0x%x,0x%x", i->x, i->y);
+ if (debug2)
+ fprintf(debug2, "0x%x 0x%x type=town_label_5e3\n", i->x, i->y);
+ }
+ if (num < 0 || den < 0)
+ return -1;
+ if (num > den)
+ return 257;
+ return 256*num/den;
}
/* return
@@ -482,631 +501,592 @@ intersect(struct coord *p1, struct coord *p2, struct coord *p3, struct coord *p4
/* #define DEBUG_VISIBLE */
-static int
-is_visible_line(struct coord *c0, struct coord *c1, struct coord *c2)
-{
- int res,ret=0;
- struct building *b=buildings;
- struct coord cn;
-#ifdef DEBUG_VISIBLE
- dbg(lvl_debug,"enter\n");
-#endif
- while (b) {
- if (side(&b->left, &b->right, c1) < 0 || side(&b->left, &b->right, c2) < 0) {
-#ifdef DEBUG_VISIBLE
- dbg(lvl_debug,"sides left: start %d end %d right: start %d end %d\n", side(c0, &b->left, c1), side(c0, &b->left, c2), side(c0, &b->right, c1), side(c0, &b->right, c2));
-#endif
- for (;;) {
- if (side(c0, &b->left, c1) <= 0) {
- if (side(c0, &b->left, c2) > 0) {
-#ifdef DEBUG_VISIBLE
- dbg(lvl_debug,"visible: start is left of left corner and end is right of left corner, clipping end\n");
-#endif
- res=intersect(c0, &b->left, c1, c2, &cn);
- if (res < 256)
- break;
- if (c1->x != cn.x || c1->y != cn.y) {
- *c2=cn;
- ret|=2;
- break;
- }
- } else
- break;
- }
- if (side(c0, &b->right, c1) >= 0) {
- if (side(c0, &b->right, c2) < 0) {
-#ifdef DEBUG_VISIBLE
- dbg(lvl_debug,"visible: start is right of right corner and end is left of right corner, clipping end\n");
-#endif
- res=intersect(c0, &b->right, c1, c2, &cn);
- if (res < 256)
- break;
- if (c1->x != cn.x || c1->y != cn.y) {
- *c2=cn;
- ret|=2;
- break;
- }
- } else
- break;
- }
- if (side(c0, &b->left, c2) <= 0) {
- if (side(c0, &b->left, c1) > 0) {
-#ifdef DEBUG_VISIBLE
- dbg(lvl_debug,"visible: end is left of left corner and start is right of left corner, clipping start\n");
-#endif
- res=intersect(c0, &b->left, c1, c2, &cn);
- if (res < 256)
- break;
- if (c2->x != cn.x || c2->y != cn.y) {
- *c1=cn;
- ret|=1;
- break;
- }
- } else
- break;
- }
- if (side(c0, &b->right, c2) >= 0) {
- if (side(c0, &b->right, c1) < 0) {
-#ifdef DEBUG_VISIBLE
- dbg(lvl_debug,"visible: end is right of right corner and start is left of right corner, clipping start\n");
-#endif
- res=intersect(c0, &b->right, c1, c2, &cn);
- if (res < 256)
- break;
- if (c2->x != cn.x || c2->y != cn.y) {
- *c1=cn;
- ret|=1;
- break;
- }
- } else
- break;
- }
-#ifdef DEBUG_VISIBLE
- dbg(lvl_debug,"visible: not visible\n");
-#endif
- return 4;
- }
- }
- b=b->next;
- }
-#ifdef DEBUG_VISIBLE
- dbg(lvl_debug,"return %d\n",ret);
-#endif
- return ret;
+static int is_visible_line(struct coord *c0, struct coord *c1, struct coord *c2) {
+ int res,ret=0;
+ struct building *b=buildings;
+ struct coord cn;
+#ifdef DEBUG_VISIBLE
+ dbg(lvl_debug,"enter");
+#endif
+ while (b) {
+ if (side(&b->left, &b->right, c1) < 0 || side(&b->left, &b->right, c2) < 0) {
+#ifdef DEBUG_VISIBLE
+ dbg(lvl_debug,"sides left: start %d end %d right: start %d end %d", side(c0, &b->left, c1), side(c0, &b->left, c2),
+ side(c0, &b->right, c1), side(c0, &b->right, c2));
+#endif
+ for (;;) {
+ if (side(c0, &b->left, c1) <= 0) {
+ if (side(c0, &b->left, c2) > 0) {
+#ifdef DEBUG_VISIBLE
+ dbg(lvl_debug,"visible: start is left of left corner and end is right of left corner, clipping end");
+#endif
+ res=intersect(c0, &b->left, c1, c2, &cn);
+ if (res < 256)
+ break;
+ if (c1->x != cn.x || c1->y != cn.y) {
+ *c2=cn;
+ ret|=2;
+ break;
+ }
+ } else
+ break;
+ }
+ if (side(c0, &b->right, c1) >= 0) {
+ if (side(c0, &b->right, c2) < 0) {
+#ifdef DEBUG_VISIBLE
+ dbg(lvl_debug,"visible: start is right of right corner and end is left of right corner, clipping end");
+#endif
+ res=intersect(c0, &b->right, c1, c2, &cn);
+ if (res < 256)
+ break;
+ if (c1->x != cn.x || c1->y != cn.y) {
+ *c2=cn;
+ ret|=2;
+ break;
+ }
+ } else
+ break;
+ }
+ if (side(c0, &b->left, c2) <= 0) {
+ if (side(c0, &b->left, c1) > 0) {
+#ifdef DEBUG_VISIBLE
+ dbg(lvl_debug,"visible: end is left of left corner and start is right of left corner, clipping start");
+#endif
+ res=intersect(c0, &b->left, c1, c2, &cn);
+ if (res < 256)
+ break;
+ if (c2->x != cn.x || c2->y != cn.y) {
+ *c1=cn;
+ ret|=1;
+ break;
+ }
+ } else
+ break;
+ }
+ if (side(c0, &b->right, c2) >= 0) {
+ if (side(c0, &b->right, c1) < 0) {
+#ifdef DEBUG_VISIBLE
+ dbg(lvl_debug,"visible: end is right of right corner and start is left of right corner, clipping start");
+#endif
+ res=intersect(c0, &b->right, c1, c2, &cn);
+ if (res < 256)
+ break;
+ if (c2->x != cn.x || c2->y != cn.y) {
+ *c1=cn;
+ ret|=1;
+ break;
+ }
+ } else
+ break;
+ }
+#ifdef DEBUG_VISIBLE
+ dbg(lvl_debug,"visible: not visible");
+#endif
+ return 4;
+ }
+ }
+ b=b->next;
+ }
+#ifdef DEBUG_VISIBLE
+ dbg(lvl_debug,"return %d",ret);
+#endif
+ return ret;
}
-static void
-map_route_occluded_coord_rewind(void *priv_data)
-{
- struct map_rect_priv *mr = priv_data;
- dbg(lvl_debug,"enter\n");
- mr->idx=mr->idx_base;
- mr->first=1;
- mr->lseg_done=mr->lseg_done_base;
- mr->c_next=mr->c_next_base;
- mr->lseg[0]=mr->lseg_base[0];
- mr->lseg[1]=mr->lseg_base[1];
- mr->last=0;
- item_coord_rewind(mr->route_item);
+static void map_route_occluded_coord_rewind(void *priv_data) {
+ struct map_rect_priv *mr = priv_data;
+ dbg(lvl_debug,"enter");
+ mr->idx=mr->idx_base;
+ mr->first=1;
+ mr->lseg_done=mr->lseg_done_base;
+ mr->c_next=mr->c_next_base;
+ mr->lseg[0]=mr->lseg_base[0];
+ mr->lseg[1]=mr->lseg_base[1];
+ mr->last=0;
+ item_coord_rewind(mr->route_item);
}
-static void
-map_route_occluded_attr_rewind(void *priv_data)
-{
- struct map_rect_priv *mr=priv_data;
- dbg(lvl_debug,"enter\n");
- item_attr_rewind(mr->route_item);
+static void map_route_occluded_attr_rewind(void *priv_data) {
+ struct map_rect_priv *mr=priv_data;
+ dbg(lvl_debug,"enter");
+ item_attr_rewind(mr->route_item);
}
-static int
-map_route_occluded_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr=priv_data;
- dbg(lvl_debug,"enter\n");
- return item_attr_get(mr->route_item, attr_type, attr);
+static int map_route_occluded_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr=priv_data;
+ dbg(lvl_debug,"enter");
+ return item_attr_get(mr->route_item, attr_type, attr);
}
-static int
-coord_next(struct map_rect_priv *mr, struct coord *c)
-{
- if (mr->idx >= mr->sd->count)
- return 1;
- *c=mr->sd->c[mr->idx++];
- return 0;
+static int coord_next(struct map_rect_priv *mr, struct coord *c) {
+ if (mr->idx >= mr->sd->count)
+ return 1;
+ *c=mr->sd->c[mr->idx++];
+ return 0;
}
-#define DEBUG_COORD_GET
-static int
-map_route_occluded_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr=priv_data;
- struct coord l0,l1;
- int vis,ret=0;
- char buffer[4096];
+#define DEBUG_COORD_GET
+static int map_route_occluded_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr=priv_data;
+ struct coord l0,l1;
+ int vis,ret=0;
+ char buffer[4096];
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"enter\n");
-#endif
- dbg_assert(count >= 2);
- if (! mr->checked) {
- mr->c0=mr->sd->c[0];
- map_route_occluded_check_buildings(&mr->c0);
- mr->checked=1;
- }
- while (ret < count && !mr->last) {
+ dbg(lvl_debug,"enter");
+#endif
+ dbg_assert(count >= 2);
+ if (! mr->checked) {
+ mr->c0=mr->sd->c[0];
+ map_route_occluded_check_buildings(&mr->c0);
+ mr->checked=1;
+ }
+ while (ret < count && !mr->last) {
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"coord first %d lseg_done %d\n",mr->first,mr->lseg_done);
-#endif
- if (mr->lseg_done) {
+ dbg(lvl_debug,"coord first %d lseg_done %d",mr->first,mr->lseg_done);
+#endif
+ if (mr->lseg_done) {
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"loading %d of %d from id_lo %d\n", mr->idx, mr->sd->count, mr->sd->item.id_lo);
-#endif
- if (!mr->idx) {
- if (coord_next(mr, &mr->lseg[0])) {
- mr->route_item_done=1;
- mr->last=1;
- mr->idx_base=mr->idx=0;
- break;
- }
- mr->first=1;
- } else
- mr->lseg[0]=mr->lseg[1];
- if (coord_next(mr, &mr->lseg[1])) {
- mr->route_item_done=1;
- mr->last=1;
- mr->idx_base=mr->idx=0;
- break;
- }
- mr->c_next=mr->lseg[0];
- mr->lseg_done=0;
- }
- l0=mr->c_next;
- l1=mr->lseg[1];
+ dbg(lvl_debug,"loading %d of %d from id_lo %d", mr->idx, mr->sd->count, mr->sd->item.id_lo);
+#endif
+ if (!mr->idx) {
+ if (coord_next(mr, &mr->lseg[0])) {
+ mr->route_item_done=1;
+ mr->last=1;
+ mr->idx_base=mr->idx=0;
+ break;
+ }
+ mr->first=1;
+ } else
+ mr->lseg[0]=mr->lseg[1];
+ if (coord_next(mr, &mr->lseg[1])) {
+ mr->route_item_done=1;
+ mr->last=1;
+ mr->idx_base=mr->idx=0;
+ break;
+ }
+ mr->c_next=mr->lseg[0];
+ mr->lseg_done=0;
+ }
+ l0=mr->c_next;
+ l1=mr->lseg[1];
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"line (0x%x,0x%x)-(0x%x,0x%x)\n", l0.x,l0.y,l1.x,l1.y);
-#endif
- vis=is_visible_line(&mr->c0, &l0, &l1);
- if (debug) {
- fprintf(debug,"type=tracking_%d debug=\"%s\"\n",vis*20,buffer);
- fprintf(debug,"0x%x 0x%x\n", l0.x, l0.y);
- fprintf(debug,"0x%x 0x%x\n", l1.x, l1.y);
- }
+ dbg(lvl_debug,"line (0x%x,0x%x)-(0x%x,0x%x)", l0.x,l0.y,l1.x,l1.y);
+#endif
+ vis=is_visible_line(&mr->c0, &l0, &l1);
+ if (debug) {
+ fprintf(debug,"type=tracking_%d debug=\"%s\"\n",vis*20,buffer);
+ fprintf(debug,"0x%x 0x%x\n", l0.x, l0.y);
+ fprintf(debug,"0x%x 0x%x\n", l1.x, l1.y);
+ }
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"vis=%d line (0x%x,0x%x)-(0x%x,0x%x)\n", vis, l0.x,l0.y,l1.x,l1.y);
-#endif
- mr->idx_base=mr->idx;
- mr->c_next_base=mr->c_next;
- mr->lseg_base[0]=mr->lseg[0];
- mr->lseg_base[1]=mr->lseg[1];
- mr->lseg_done_base=mr->lseg_done;
- switch (vis) {
- case 0:
- mr->c_next_base=mr->c_next;
+ dbg(lvl_debug,"vis=%d line (0x%x,0x%x)-(0x%x,0x%x)", vis, l0.x,l0.y,l1.x,l1.y);
+#endif
+ mr->idx_base=mr->idx;
+ mr->c_next_base=mr->c_next;
+ mr->lseg_base[0]=mr->lseg[0];
+ mr->lseg_base[1]=mr->lseg[1];
+ mr->lseg_done_base=mr->lseg_done;
+ switch (vis) {
+ case 0:
+ mr->c_next_base=mr->c_next;
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"out 0x%x,0x%x\n", l0.x, l1.y);
-#endif
- c[ret++]=l0;
+ dbg(lvl_debug,"out 0x%x,0x%x", l0.x, l1.y);
+#endif
+ c[ret++]=l0;
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"out 0x%x,0x%x\n", l1.x, l1.y);
-#endif
- c[ret++]=l1;
- mr->lseg_done_base=mr->lseg_done=1;
- mr->last=1;
- break;
- case 1:
+ dbg(lvl_debug,"out 0x%x,0x%x", l1.x, l1.y);
+#endif
+ c[ret++]=l1;
+ mr->lseg_done_base=mr->lseg_done=1;
+ mr->last=1;
+ break;
+ case 1:
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"begin clipped\n");
- dbg(lvl_debug,"out 0x%x,0x%x\n", l0.x, l1.y);
-#endif
- c[ret++]=l0;
+ dbg(lvl_debug,"begin clipped");
+ dbg(lvl_debug,"out 0x%x,0x%x", l0.x, l1.y);
+#endif
+ c[ret++]=l0;
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"out 0x%x,0x%x\n", l1.x, l1.y);
-#endif
- c[ret++]=l1;
- mr->c_next_base=mr->c_next=l1;
- mr->last=1;
- break;
- case 2:
+ dbg(lvl_debug,"out 0x%x,0x%x", l1.x, l1.y);
+#endif
+ c[ret++]=l1;
+ mr->c_next_base=mr->c_next=l1;
+ mr->last=1;
+ break;
+ case 2:
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"end clipped\n");
-#endif
- mr->c_next_base=mr->c_next;
+ dbg(lvl_debug,"end clipped");
+#endif
+ mr->c_next_base=mr->c_next;
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"out 0x%x,0x%x\n", l0.x, l1.y);
-#endif
- c[ret++]=l0;
+ dbg(lvl_debug,"out 0x%x,0x%x", l0.x, l1.y);
+#endif
+ c[ret++]=l0;
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"out 0x%x,0x%x\n", l1.x, l1.y);
-#endif
- c[ret++]=l1;
- mr->c_next_base=mr->c_next=l1;
- mr->last=1;
- break;
- case 3:
+ dbg(lvl_debug,"out 0x%x,0x%x", l1.x, l1.y);
+#endif
+ c[ret++]=l1;
+ mr->c_next_base=mr->c_next=l1;
+ mr->last=1;
+ break;
+ case 3:
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"both clipped\n");
-#endif
- mr->c_next_base=mr->c_next;
+ dbg(lvl_debug,"both clipped");
+#endif
+ mr->c_next_base=mr->c_next;
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"out 0x%x,0x%x\n", l0.x, l1.y);
-#endif
- c[ret++]=l0;
+ dbg(lvl_debug,"out 0x%x,0x%x", l0.x, l1.y);
+#endif
+ c[ret++]=l0;
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"out 0x%x,0x%x\n", l1.x, l1.y);
-#endif
- c[ret++]=l1;
- mr->c_next_base=mr->c_next=l1;
- mr->last=1;
- break;
- case 4:
- mr->last=1;
- mr->lseg_done_base=mr->lseg_done=1;
- break;
-
-#if 0
- case 2:
- dbg(lvl_debug,"visible up to 0x%x,0x%x\n",l1.x,l1.y);
- if (mr->first) {
- mr->first=0;
- c[ret++]=mr->c_out;
- dbg(lvl_debug,"out 0x%x,0x%x\n", mr->c_out.x, mr->c_out.y);
- }
- c[ret++]=mr->c_out=l1;
- dbg(lvl_debug,"out 0x%x,0x%x\n", l1.x, l1.y);
- mr->last=1;
- mr->route_item_done=1;
- break;
- case 1:
- case 3:
- case 4:
- dbg(lvl_debug,"invisible\n");
- mr->c_out=l1;
- mr->idx++;
- mr->last=1;
- mr->route_item_done=1;
- break;
- }
- if (!vis)
- break;
-#endif
- }
- }
+ dbg(lvl_debug,"out 0x%x,0x%x", l1.x, l1.y);
+#endif
+ c[ret++]=l1;
+ mr->c_next_base=mr->c_next=l1;
+ mr->last=1;
+ break;
+ case 4:
+ mr->last=1;
+ mr->lseg_done_base=mr->lseg_done=1;
+ break;
+
+#if 0
+ case 2:
+ dbg(lvl_debug,"visible up to 0x%x,0x%x",l1.x,l1.y);
+ if (mr->first) {
+ mr->first=0;
+ c[ret++]=mr->c_out;
+ dbg(lvl_debug,"out 0x%x,0x%x", mr->c_out.x, mr->c_out.y);
+ }
+ c[ret++]=mr->c_out=l1;
+ dbg(lvl_debug,"out 0x%x,0x%x", l1.x, l1.y);
+ mr->last=1;
+ mr->route_item_done=1;
+ break;
+ case 1:
+ case 3:
+ case 4:
+ dbg(lvl_debug,"invisible");
+ mr->c_out=l1;
+ mr->idx++;
+ mr->last=1;
+ mr->route_item_done=1;
+ break;
+ }
+ if (!vis)
+ break;
+#endif
+ }
+}
#ifdef DEBUG_COORD_GET
- dbg(lvl_debug,"ret=%d last=%d\n", ret, mr->last);
-#endif
- return ret;
+dbg(lvl_debug,"ret=%d last=%d", ret, mr->last);
+#endif
+return ret;
}
static struct item_methods methods_route_occluded_item = {
- map_route_occluded_coord_rewind,
- map_route_occluded_coord_get,
- map_route_occluded_attr_rewind,
- map_route_occluded_attr_get,
+ map_route_occluded_coord_rewind,
+ map_route_occluded_coord_get,
+ map_route_occluded_attr_rewind,
+ map_route_occluded_attr_get,
};
-static void
-map_route_occluded_destroy(struct map_priv *priv)
-{
- g_free(priv);
+static void map_route_occluded_destroy(struct map_priv *priv) {
+ g_free(priv);
}
static int no_recurse;
-static struct map_rect_priv *
-map_route_occluded_rect_new(struct map_priv *priv, struct map_selection *sel)
-{
- struct map_rect_priv * mr;
- struct attr route;
- struct attr route_map;
- struct map_rect *route_map_rect;
- struct coord_rect r;
- if (!navit_get_attr(priv->navit, attr_route, &route, NULL)) {
- dbg(lvl_debug,"no route in navit\n");
- return NULL;
- }
- if (!route_get_attr(route.u.route, attr_map, &route_map, NULL)) {
- dbg(lvl_debug,"no map in route\n");
- return NULL;
- }
- route_map_rect=map_rect_new(route_map.u.map, sel);
- if (!route_map_rect) {
- dbg(lvl_debug,"no route map rect\n");
- return NULL;
- }
- map_dump_file(route_map.u.map, "route.txt");
- mr=g_new0(struct map_rect_priv, 1);
- mr->route_map_rect=route_map_rect;
- mr->mpriv = priv;
- mr->item.priv_data = mr;
- mr->item.meth = &methods_route_occluded_item;
- mr->item.id_lo = -1;
- mr->route_item_done=1;
- mr->lseg_done_base=1;
- mr->last=1;
- if (!no_recurse && map_route_occluded_bbox(route_map.u.map, &r)) {
- struct attr mapset;
- no_recurse++;
- if (navit_get_attr(mr->mpriv->navit, attr_mapset, &mapset, NULL))
- map_route_occluded_get_buildings(mapset.u.mapset, &r);
- debug=fopen("tst.txt","w");
- debug2=fopen("tstp.txt","w");
- no_recurse--;
- }
- return mr;
+static struct map_rect_priv *map_route_occluded_rect_new(struct map_priv *priv, struct map_selection *sel) {
+ struct map_rect_priv * mr;
+ struct attr route;
+ struct attr route_map;
+ struct map_rect *route_map_rect;
+ struct coord_rect r;
+ if (!navit_get_attr(priv->navit, attr_route, &route, NULL)) {
+ dbg(lvl_debug,"no route in navit");
+ return NULL;
+ }
+ if (!route_get_attr(route.u.route, attr_map, &route_map, NULL)) {
+ dbg(lvl_debug,"no map in route");
+ return NULL;
+ }
+ route_map_rect=map_rect_new(route_map.u.map, sel);
+ if (!route_map_rect) {
+ dbg(lvl_debug,"no route map rect");
+ return NULL;
+ }
+ map_dump_file(route_map.u.map, "route.txt");
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->route_map_rect=route_map_rect;
+ mr->mpriv = priv;
+ mr->item.priv_data = mr;
+ mr->item.meth = &methods_route_occluded_item;
+ mr->item.id_lo = -1;
+ mr->route_item_done=1;
+ mr->lseg_done_base=1;
+ mr->last=1;
+ if (!no_recurse && map_route_occluded_bbox(route_map.u.map, &r)) {
+ struct attr mapset;
+ no_recurse++;
+ if (navit_get_attr(mr->mpriv->navit, attr_mapset, &mapset, NULL))
+ map_route_occluded_get_buildings(mapset.u.mapset, &r);
+ debug=fopen("tst.txt","w");
+ debug2=fopen("tstp.txt","w");
+ no_recurse--;
+ }
+ return mr;
}
-static void
-map_route_occluded_rect_destroy(struct map_rect_priv *mr)
-{
- map_rect_destroy(mr->route_map_rect);
- street_data_free(mr->sd);
- g_free(mr);
- if (!no_recurse) {
- if (debug) {
- fclose(debug);
- debug=NULL;
- }
- if (debug2) {
- fclose(debug2);
- debug2=NULL;
- }
- }
+static void map_route_occluded_rect_destroy(struct map_rect_priv *mr) {
+ map_rect_destroy(mr->route_map_rect);
+ street_data_free(mr->sd);
+ g_free(mr);
+ if (!no_recurse) {
+ if (debug) {
+ fclose(debug);
+ debug=NULL;
+ }
+ if (debug2) {
+ fclose(debug2);
+ debug2=NULL;
+ }
+ }
#if 0
- static int in_dump;
- if (! in_dump) {
- in_dump=1;
- map_dump_file(global_map,"route.txt");
- in_dump=0;
- }
+ static int in_dump;
+ if (! in_dump) {
+ in_dump=1;
+ map_dump_file(global_map,"route.txt");
+ in_dump=0;
+ }
#endif
}
-static struct item *
-map_route_occluded_get_item(struct map_rect_priv *mr)
-{
- dbg(lvl_debug,"enter last=%d\n",mr->last);
- while (!mr->last) {
- struct coord c[128];
- map_route_occluded_coord_get(mr, c, 128);
- }
- if (mr->route_item_done) {
- dbg(lvl_debug,"next route item\n");
- do {
- mr->route_item=map_rect_get_item(mr->route_map_rect);
- } while (mr->route_item && mr->route_item->type != type_street_route);
- dbg(lvl_debug,"item %p\n", mr->route_item);
- if (!mr->route_item)
- return NULL;
- mr->item.type=type_street_route_occluded;
- street_data_free(mr->sd);
- mr->sd=street_get_data(mr->route_item);
- mr->route_item_done=0;
- }
- mr->item.id_lo++;
-#if 0
- if (mr->item.id_lo > 20)
- return NULL;
-#endif
- map_route_occluded_coord_rewind(mr);
- dbg(lvl_debug,"type %s\n", item_to_name(mr->route_item->type));
- return &mr->item;
+static struct item *map_route_occluded_get_item(struct map_rect_priv *mr) {
+ dbg(lvl_debug,"enter last=%d",mr->last);
+ while (!mr->last) {
+ struct coord c[128];
+ map_route_occluded_coord_get(mr, c, 128);
+ }
+ if (mr->route_item_done) {
+ dbg(lvl_debug,"next route item");
+ do {
+ mr->route_item=map_rect_get_item(mr->route_map_rect);
+ } while (mr->route_item && mr->route_item->type != type_street_route);
+ dbg(lvl_debug,"item %p", mr->route_item);
+ if (!mr->route_item)
+ return NULL;
+ mr->item.type=type_street_route_occluded;
+ street_data_free(mr->sd);
+ mr->sd=street_get_data(mr->route_item);
+ mr->route_item_done=0;
+ }
+ mr->item.id_lo++;
+#if 0
+ if (mr->item.id_lo > 20)
+ return NULL;
+#endif
+ map_route_occluded_coord_rewind(mr);
+ dbg(lvl_debug,"type %s", item_to_name(mr->route_item->type));
+ return &mr->item;
}
-static struct item *
-map_route_occluded_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- struct item *ret=NULL;
- while (id_lo-- > 0)
- ret=map_route_occluded_get_item(mr);
- return ret;
+static struct item *map_route_occluded_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ struct item *ret=NULL;
+ while (id_lo-- > 0)
+ ret=map_route_occluded_get_item(mr);
+ return ret;
}
static struct map_methods map_route_occluded_methods = {
- projection_mg,
- "utf-8",
- map_route_occluded_destroy,
- map_route_occluded_rect_new,
- map_route_occluded_rect_destroy,
- map_route_occluded_get_item,
- map_route_occluded_get_item_byid,
- NULL,
- NULL,
- NULL,
+ projection_mg,
+ "utf-8",
+ map_route_occluded_destroy,
+ map_route_occluded_rect_new,
+ map_route_occluded_rect_destroy,
+ map_route_occluded_get_item,
+ map_route_occluded_get_item_byid,
+ NULL,
+ NULL,
+ NULL,
};
-static struct map_priv *
-map_route_occluded_new(struct map_methods *meth, struct attr **attrs)
-{
- struct map_priv *ret;
- struct attr *navit;
- dbg(lvl_debug,"enter\n");
- navit=attr_search(attrs, NULL, attr_navit);
- if (! navit)
- return NULL;
- ret=g_new0(struct map_priv, 1);
- *meth=map_route_occluded_methods;
- ret->navit=navit->u.navit;
- dbg(lvl_debug,"m=%p navit=%p\n", ret, ret->navit);
- return ret;
+static struct map_priv *map_route_occluded_new(struct map_methods *meth, struct attr **attrs) {
+ struct map_priv *ret;
+ struct attr *navit;
+ dbg(lvl_debug,"enter");
+ navit=attr_search(attrs, NULL, attr_navit);
+ if (! navit)
+ return NULL;
+ ret=g_new0(struct map_priv, 1);
+ *meth=map_route_occluded_methods;
+ ret->navit=navit->u.navit;
+ dbg(lvl_debug,"m=%p navit=%p", ret, ret->navit);
+ return ret;
}
-static void
-pedestrian_graphics_resize(struct graphics *gra, int w, int h)
-{
+static void pedestrian_graphics_resize(struct graphics *gra, int w, int h) {
#ifndef HAVE_API_ANDROID
- static int done;
- if (!done) {
- int id=(int)graphics_get_data(gra, "xwindow_id");
- char buffer[1024];
- sprintf(buffer,"testxv %d &",id);
- system(buffer);
- done=1;
- }
+ static int done;
+ if (!done) {
+ int id=(int)graphics_get_data(gra, "xwindow_id");
+ char buffer[1024];
+ sprintf(buffer,"testxv %d &",id);
+ system(buffer);
+ done=1;
+ }
#endif
- pedestrian_data.w=w;
- pedestrian_data.h=h;
+ pedestrian_data.w=w;
+ pedestrian_data.h=h;
}
-static void
-pedestrian_draw_arrow(struct graphics *gra, char *name, int x, int y)
-{
- char *src=graphics_icon_path(name);
- struct graphics_image *img=graphics_image_new(gra, src);
- struct graphics_gc *gc=graphics_gc_new(gra);
- struct color col={0xffff,0xffff,0xffff,0xffff};
- struct point p;
- graphics_gc_set_foreground(gc, &col);
- p.x=x;
- p.y=y;
- graphics_draw_image(gra, gc, &p, img);
- graphics_image_free(gra, img);
- graphics_gc_destroy(gc);
- g_free(src);
+static void pedestrian_draw_arrow(struct graphics *gra, char *name, int x, int y) {
+ char *src=graphics_icon_path(name);
+ struct graphics_image *img=graphics_image_new(gra, src);
+ struct graphics_gc *gc=graphics_gc_new(gra);
+ struct color col= {0xffff,0xffff,0xffff,0xffff};
+ struct point p;
+ graphics_gc_set_foreground(gc, &col);
+ p.x=x;
+ p.y=y;
+ graphics_draw_image(gra, gc, &p, img);
+ graphics_image_free(gra, img);
+ graphics_gc_destroy(gc);
+ g_free(src);
}
-static void
-pedestrian_draw_arrows(struct graphics *gra)
-{
- struct attr route, route_map;
- struct map_rect *route_map_rect;
- struct item *item;
-
- if (orientation == 2)
- return;
- if (!navit_get_attr(pedestrian_data.nav, attr_route, &route, NULL)) {
- dbg(lvl_debug,"no route in navit\n");
- return;
- }
- if (!route_get_attr(route.u.route, attr_map, &route_map, NULL)) {
- dbg(lvl_debug,"no map in route\n");
- return;
- }
- route_map_rect=map_rect_new(route_map.u.map, NULL);
- if (!route_map_rect) {
- dbg(lvl_debug,"no route map rect\n");
- return;
- }
- while ((item=map_rect_get_item(route_map_rect))) {
- if (item->type == type_street_route) {
- struct coord c[2];
- if (item_coord_get(item, c, 2) == 2) {
- struct coord *center=transform_get_center(navit_get_trans(pedestrian_data.nav));
- int angle=transform_get_angle_delta(center, &c[1], 0);
- angle-=pedestrian_data.yaw;
- if (angle < 0)
- angle+=360;
- if (angle >= 360)
- angle-=360;
- if (angle > 180 && angle < 350)
- pedestrian_draw_arrow(gra,"gui_arrow_left_32_32.png",0,pedestrian_data.h/2-16);
- if (angle > 10 && angle <= 180)
- pedestrian_draw_arrow(gra,"gui_arrow_right_32_32.png",pedestrian_data.w-32,pedestrian_data.h/2-16);
- }
- break;
- }
- }
- map_rect_destroy(route_map_rect);
+static void pedestrian_draw_arrows(struct graphics *gra) {
+ struct attr route, route_map;
+ struct map_rect *route_map_rect;
+ struct item *item;
+
+ if (orientation == 2)
+ return;
+ if (!navit_get_attr(pedestrian_data.nav, attr_route, &route, NULL)) {
+ dbg(lvl_debug,"no route in navit");
+ return;
+ }
+ if (!route_get_attr(route.u.route, attr_map, &route_map, NULL)) {
+ dbg(lvl_debug,"no map in route");
+ return;
+ }
+ route_map_rect=map_rect_new(route_map.u.map, NULL);
+ if (!route_map_rect) {
+ dbg(lvl_debug,"no route map rect");
+ return;
+ }
+ while ((item=map_rect_get_item(route_map_rect))) {
+ if (item->type == type_street_route) {
+ struct coord c[2];
+ if (item_coord_get(item, c, 2) == 2) {
+ struct coord *center=transform_get_center(navit_get_trans(pedestrian_data.nav));
+ int angle=transform_get_angle_delta(center, &c[1], 0);
+ angle-=pedestrian_data.yaw;
+ if (angle < 0)
+ angle+=360;
+ if (angle >= 360)
+ angle-=360;
+ if (angle > 180 && angle < 350)
+ pedestrian_draw_arrow(gra,"gui_arrow_left_32_32.png",0,pedestrian_data.h/2-16);
+ if (angle > 10 && angle <= 180)
+ pedestrian_draw_arrow(gra,"gui_arrow_right_32_32.png",pedestrian_data.w-32,pedestrian_data.h/2-16);
+ }
+ break;
+ }
+ }
+ map_rect_destroy(route_map_rect);
}
-static void
-pedestrian_graphics_postdraw(struct graphics *gra)
-{
+static void pedestrian_graphics_postdraw(struct graphics *gra) {
#if 0
- struct graphics_gc * gc = graphics_gc_new(gra);
- struct point p;
- struct color c = {0xadad,0xd8d8,0xe6e6,0xffff};
- p.x=0;
- p.y=0;
- graphics_gc_set_foreground(gc, &c);
- graphics_draw_rectangle(gra, gc, &p, 1000, 200);
- graphics_gc_destroy(gc);
+ struct graphics_gc * gc = graphics_gc_new(gra);
+ struct point p;
+ struct color c = {0xadad,0xd8d8,0xe6e6,0xffff};
+ p.x=0;
+ p.y=0;
+ graphics_gc_set_foreground(gc, &c);
+ graphics_draw_rectangle(gra, gc, &p, 1000, 200);
+ graphics_gc_destroy(gc);
#endif
- pedestrian_draw_arrows(gra);
+ pedestrian_draw_arrows(gra);
}
#ifndef HAVE_API_ANDROID
struct tilt_data {
- int len,axis;
- char buffer[32];
+ int len,axis;
+ char buffer[32];
};
-void
-pedestrian_write_tilt(int fd, int axis)
-{
- char *buffer="01";
- int ret;
+void pedestrian_write_tilt(int fd, int axis) {
+ char *buffer="01";
+ int ret;
- ret=write(fd, buffer+axis, 1);
- if (ret != 2) {
- dbg(lvl_debug,"ret=%d\n",ret);
- }
+ ret=write(fd, buffer+axis, 1);
+ if (ret != 2) {
+ dbg(lvl_debug,"ret=%d",ret);
+ }
}
-void
-pedestrian_read_tilt(int fd, struct navit *nav, struct tilt_data *data)
-{
- int val,ret,maxlen=3;
- ret=read(fd, data->buffer+data->len, maxlen-data->len);
- if (ret > 0) {
- data->len+=ret;
- data->buffer[data->len]='\0';
- }
- if (data->len == 3) {
- struct attr attr;
- sscanf(data->buffer,"%02x",&val);
- data->len=0;
- if (navit_get_attr(nav, attr_transformation, &attr, NULL)) {
- struct transformation *trans=attr.u.transformation;
- dbg(lvl_debug,"ok axis=%d val=0x%x\n", data->axis, val);
- if (data->axis != 1) {
- transform_set_pitch(trans, 90+(val-0x80));
- } else {
- transform_set_roll(trans, 0x80-val);
- }
- }
- data->axis=1-data->axis;
-
-#if 0
- pedestrian_write_tilt(fd, data->axis);
+void pedestrian_read_tilt(int fd, struct navit *nav, struct tilt_data *data) {
+ int val,ret,maxlen=3;
+ ret=read(fd, data->buffer+data->len, maxlen-data->len);
+ if (ret > 0) {
+ data->len+=ret;
+ data->buffer[data->len]='\0';
+ }
+ if (data->len == 3) {
+ struct attr attr;
+ sscanf(data->buffer,"%02x",&val);
+ data->len=0;
+ if (navit_get_attr(nav, attr_transformation, &attr, NULL)) {
+ struct transformation *trans=attr.u.transformation;
+ dbg(lvl_debug,"ok axis=%d val=0x%x", data->axis, val);
+ if (data->axis != 1) {
+ transform_set_pitch(trans, 90+(val-0x80));
+ } else {
+ transform_set_roll(trans, 0x80-val);
+ }
+ }
+ data->axis=1-data->axis;
+
+#if 0
+ pedestrian_write_tilt(fd, data->axis);
#endif
- }
+ }
}
-void
-pedestrian_write_tilt_timer(int fd, struct tilt_data *data)
-{
- pedestrian_write_tilt(fd, data->axis);
+void pedestrian_write_tilt_timer(int fd, struct tilt_data *data) {
+ pedestrian_write_tilt(fd, data->axis);
}
-void
-pedestrian_setup_tilt(struct navit *nav)
-{
- int fd,on=1;
- struct termios t;
- struct callback *cb,*cbt;
- struct tilt_data *data=g_new0(struct tilt_data, 1);
- char buffer[32];
- fd=open("/dev/tiltsensor",O_RDWR);
- if (fd == -1) {
- dbg(lvl_error,"Failed to set up tilt sensor, error %d\n",errno);
- return;
- }
- tcgetattr(fd, &t);
- cfmakeraw(&t);
- cfsetspeed(&t, B19200);
- tcsetattr(fd, TCSANOW, &t);
- ioctl(fd, FIONBIO, &on);
- cb=callback_new_3(callback_cast(pedestrian_read_tilt), fd, nav, data);
- cbt=callback_new_2(callback_cast(pedestrian_write_tilt_timer), fd, data);
- event_add_watch(fd, event_watch_cond_read, cb);
- event_add_timeout(300, 1, cbt);
- read(fd, buffer, 32);
+void pedestrian_setup_tilt(struct navit *nav) {
+ int fd,on=1;
+ struct termios t;
+ struct callback *cb,*cbt;
+ struct tilt_data *data=g_new0(struct tilt_data, 1);
+ char buffer[32];
+ fd=open("/dev/tiltsensor",O_RDWR);
+ if (fd == -1) {
+ dbg(lvl_error,"Failed to set up tilt sensor, error %d",errno);
+ return;
+ }
+ tcgetattr(fd, &t);
+ cfmakeraw(&t);
+ cfsetspeed(&t, B19200);
+ tcsetattr(fd, TCSANOW, &t);
+ ioctl(fd, FIONBIO, &on);
+ cb=callback_new_3(callback_cast(pedestrian_read_tilt), fd, nav, data);
+ cbt=callback_new_2(callback_cast(pedestrian_write_tilt_timer), fd, data);
+ event_add_watch(fd, event_watch_cond_read, cb);
+ event_add_timeout(300, 1, cbt);
+ read(fd, buffer, 32);
#if 0
- pedestrian_write_tilt(fd, 0);
+ pedestrian_write_tilt(fd, 0);
#endif
}
@@ -1115,267 +1095,264 @@ pedestrian_setup_tilt(struct navit *nav)
float sensors[2][3];
-static void
-android_sensors(struct navit *nav, int sensor, float *x, float *y, float *z)
-{
- float yaw=0,pitch=0;
- struct attr attr;
- sensors[sensor-1][0]=*x;
- sensors[sensor-1][1]=*y;
- sensors[sensor-1][2]=*z;
- if (sensors_locked)
- return;
- dbg(lvl_debug,"enter %d %f %f %f\n",sensor,*x,*y,*z);
- if (sensor == 1) {
- if (*x > 7.5)
- orientation=1; /* landscape */
- if (*y > 7.5)
- orientation=0; /* portrait */
- if (*z > 7.5)
- orientation=2; /* flat */
- dbg(lvl_debug,"orientation=%d\n",orientation);
- }
- if ((orientation_old == 2) != (orientation == 2)) {
- struct attr attr, flags_graphics, osd_configuration;
- navit_set_attr(nav, orientation == 2 ? &initial_layout:&main_layout);
- navit_get_attr(nav, attr_transformation, &attr, NULL);
- transform_set_scale(attr.u.transformation, orientation == 2 ? 64:16);
- flags_graphics.type=attr_flags_graphics;
- flags_graphics.u.num=orientation == 2 ? 0:10;
- navit_set_attr(nav, &flags_graphics);
- osd_configuration.type=attr_osd_configuration;
- osd_configuration.u.num=orientation == 2 ? 1:2;
- navit_set_attr(nav, &osd_configuration);
- }
- orientation_old=orientation;
- switch (orientation) {
- case 2:
- if (sensor == 2) {
- yaw=atan2f(-*y,-*x)*180/M_PI+180;
- }
- pitch=0;
- break;
- case 1:
- if (sensor == 1) {
- pitch=atan2f(*x,*z)*180/M_PI;
- }
- if (sensor == 2) {
- yaw=atan2f(-*y,*z)*180/M_PI+180;
- }
- break;
- case 0:
- if (sensor == 1) {
- pitch=atan2f(*y,*z)*180/M_PI;
- }
- if (sensor == 2) {
- yaw=atan2f(*x,*z)*180/M_PI+180;
- }
- break;
- }
- if (navit_get_attr(nav, attr_transformation, &attr, NULL)) {
- struct transformation *trans=attr.u.transformation;
- if (sensor == 1) {
- if (orientation != 2)
- pitch+=2.0;
- transform_set_pitch(trans, (int)pitch);
- dbg(lvl_debug,"pich %d %f\n",orientation,pitch);
- } else {
- struct attr attr;
- attr.type=attr_orientation;
- attr.u.num=yaw-1.0;
- if (attr.u.num < 0)
- attr.u.num+=360;
- pedestrian_data.yaw=attr.u.num;
- navit_set_attr(nav, &attr);
- dbg(lvl_debug,"yaw %d %f\n",orientation,yaw);
- if (orientation == 2)
- navit_set_center_cursor(nav, 1, 0);
- }
- }
+static void android_sensors(struct navit *nav, int sensor, float *x, float *y, float *z) {
+ float yaw=0,pitch=0;
+ struct attr attr;
+ sensors[sensor-1][0]=*x;
+ sensors[sensor-1][1]=*y;
+ sensors[sensor-1][2]=*z;
+ if (sensors_locked)
+ return;
+ dbg(lvl_debug,"enter %d %f %f %f",sensor,*x,*y,*z);
+ if (sensor == 1) {
+ if (*x > 7.5)
+ orientation=1; /* landscape */
+ if (*y > 7.5)
+ orientation=0; /* portrait */
+ if (*z > 7.5)
+ orientation=2; /* flat */
+ dbg(lvl_debug,"orientation=%d",orientation);
+ }
+ if ((orientation_old == 2) != (orientation == 2)) {
+ struct attr attr, flags_graphics, osd_configuration;
+ navit_set_attr(nav, orientation == 2 ? &initial_layout:&main_layout);
+ navit_get_attr(nav, attr_transformation, &attr, NULL);
+ transform_set_scale(attr.u.transformation, orientation == 2 ? 64:16);
+ flags_graphics.type=attr_flags_graphics;
+ flags_graphics.u.num=orientation == 2 ? 0:10;
+ navit_set_attr(nav, &flags_graphics);
+ osd_configuration.type=attr_osd_configuration;
+ osd_configuration.u.num=orientation == 2 ? 1:2;
+ navit_set_attr(nav, &osd_configuration);
+ }
+ orientation_old=orientation;
+ switch (orientation) {
+ case 2:
+ if (sensor == 2) {
+ yaw=atan2f(-*y,-*x)*180/M_PI+180;
+ }
+ pitch=0;
+ break;
+ case 1:
+ if (sensor == 1) {
+ pitch=atan2f(*x,*z)*180/M_PI;
+ }
+ if (sensor == 2) {
+ yaw=atan2f(-*y,*z)*180/M_PI+180;
+ }
+ break;
+ case 0:
+ if (sensor == 1) {
+ pitch=atan2f(*y,*z)*180/M_PI;
+ }
+ if (sensor == 2) {
+ yaw=atan2f(*x,*z)*180/M_PI+180;
+ }
+ break;
+ }
+ if (navit_get_attr(nav, attr_transformation, &attr, NULL)) {
+ struct transformation *trans=attr.u.transformation;
+ if (sensor == 1) {
+ if (orientation != 2)
+ pitch+=2.0;
+ transform_set_pitch(trans, (int)pitch);
+ dbg(lvl_debug,"pich %d %f",orientation,pitch);
+ } else {
+ struct attr attr;
+ attr.type=attr_orientation;
+ attr.u.num=yaw-1.0;
+ if (attr.u.num < 0)
+ attr.u.num+=360;
+ pedestrian_data.yaw=attr.u.num;
+ navit_set_attr(nav, &attr);
+ dbg(lvl_debug,"yaw %d %f",orientation,yaw);
+ if (orientation == 2)
+ navit_set_center_cursor(nav, 1, 0);
+ }
+ }
}
#endif
-static void
-pedestrian_log(char **logstr)
-{
+static void pedestrian_log(char **logstr) {
#ifdef HAVE_API_ANDROID
- char *tag=g_strdup_printf(
- "\t\t<navit:compass:x>%f</navit:compass:x>\n"
- "\t\t<navit:compass:y>%f</navit:compass:y>\n"
- "\t\t<navit:compass:z>%f</navit:compass:z>\n"
- "\t\t<navit:accel:x>%f</navit:accel:x>\n"
- "\t\t<navit:accel:y>%f</navit:accel:y>\n"
- "\t\t<navit:accel:z>%f</navit:accel:z>\n",
- sensors[0][0],sensors[0][1],sensors[0][2],
- sensors[1][0],sensors[1][1],sensors[1][2]);
- vehicle_log_gpx_add_tag(tag, logstr);
+ char *tag=g_strdup_printf(
+ "\t\t<navit:compass:x>%f</navit:compass:x>\n"
+ "\t\t<navit:compass:y>%f</navit:compass:y>\n"
+ "\t\t<navit:compass:z>%f</navit:compass:z>\n"
+ "\t\t<navit:accel:x>%f</navit:accel:x>\n"
+ "\t\t<navit:accel:y>%f</navit:accel:y>\n"
+ "\t\t<navit:accel:z>%f</navit:accel:z>\n",
+ sensors[0][0],sensors[0][1],sensors[0][2],
+ sensors[1][0],sensors[1][1],sensors[1][2]);
+ vehicle_log_gpx_add_tag(tag, logstr);
#endif
}
#ifdef DEMO
-static void
-vehicle_changed(struct vehicle *v, struct transformation *trans)
-{
- struct attr attr;
- if (vehicle_get_attr(v, attr_position_direction, &attr, NULL)) {
- int dir=(int)(*attr.u.numd);
- dbg(lvl_debug,"enter %d\n",dir);
- transform_set_pitch(trans, 90);
- transform_set_yaw(trans, dir);
- }
+static void vehicle_changed(struct vehicle *v, struct transformation *trans) {
+ struct attr attr;
+ if (vehicle_get_attr(v, attr_position_direction, &attr, NULL)) {
+ int dir=(int)(*attr.u.numd);
+ dbg(lvl_debug,"enter %d",dir);
+ transform_set_pitch(trans, 90);
+ transform_set_yaw(trans, dir);
+ }
}
#endif
-static void
-pedestrian_navit_init(struct navit *nav)
-{
- struct attr route;
- struct attr route_map;
- struct attr map;
- struct attr mapset;
- struct attr graphics,attr,flags_graphics;
- struct transformation *trans;
- struct attr_iter *iter;
+static void pedestrian_navit_init(struct navit *nav) {
+ struct attr route;
+ struct attr route_map;
+ struct attr map;
+ struct attr mapset;
+ struct attr graphics,attr,flags_graphics;
+ struct transformation *trans;
+ struct attr_iter *iter;
#ifdef HAVE_API_ANDROID
- struct callback *cb;
- jclass navitsensorsclass;
- jmethodID cid;
- jobject navitsensors;
-
- dbg(lvl_debug,"enter\n");
- if (android_find_class_global("org/navitproject/navit/NavitSensors", &navitsensorsclass)) {
- dbg(lvl_debug,"class found\n");
- cid = (*jnienv)->GetMethodID(jnienv, navitsensorsclass, "<init>", "(Landroid/content/Context;I)V");
- dbg(lvl_debug,"cid=%p\n",cid);
- if (cid) {
- cb=callback_new_1(callback_cast(android_sensors), nav);
- navitsensors=(*jnienv)->NewObject(jnienv, navitsensorsclass, cid, android_activity, cb);
- dbg(lvl_debug,"object=%p\n",navitsensors);
- if (navitsensors)
- navitsensors = (*jnienv)->NewGlobalRef(jnienv, navitsensors);
- }
- }
+ struct callback *cb;
+ jclass navitsensorsclass;
+ jmethodID cid;
+ jobject navitsensors;
+
+ dbg(lvl_debug,"enter");
+ if (android_find_class_global("org/navitproject/navit/NavitSensors", &navitsensorsclass)) {
+ dbg(lvl_debug,"class found");
+ cid = (*jnienv)->GetMethodID(jnienv, navitsensorsclass, "<init>", "(Landroid/content/Context;I)V");
+ dbg(lvl_debug,"cid=%p",cid);
+ if (cid) {
+ cb=callback_new_1(callback_cast(android_sensors), nav);
+ navitsensors=(*jnienv)->NewObject(jnienv, navitsensorsclass, cid, android_application, cb);
+ dbg(lvl_debug,"object=%p",navitsensors);
+ if (navitsensors)
+ navitsensors = (*jnienv)->NewGlobalRef(jnienv, navitsensors);
+ }
+ }
#endif
- pedestrian_data.nav=nav;
- flags_graphics.type=attr_flags_graphics;
- flags_graphics.u.num=10;
- navit_set_attr(nav, &flags_graphics);
- if (navit_get_attr(nav, attr_graphics, &graphics, NULL)) {
- struct attr attr;
- struct callback *cb=callback_new_attr_1(callback_cast(pedestrian_graphics_resize),attr_resize,graphics.u.graphics);
- graphics_add_callback(graphics.u.graphics, cb);
- cb=callback_new_attr_1(callback_cast(pedestrian_graphics_postdraw),attr_postdraw,graphics.u.graphics);
- graphics_add_callback(graphics.u.graphics, cb);
- attr.type=attr_use_camera;
- attr.u.num=1;
- graphics_set_attr(graphics.u.graphics, &attr);
- }
- osd_rocket_init(nav);
+ pedestrian_data.nav=nav;
+ flags_graphics.type=attr_flags_graphics;
+ flags_graphics.u.num=10;
+ navit_set_attr(nav, &flags_graphics);
+ if (navit_get_attr(nav, attr_graphics, &graphics, NULL)) {
+ struct attr attr;
+ struct callback *cb=callback_new_attr_1(callback_cast(pedestrian_graphics_resize),attr_resize,graphics.u.graphics);
+ graphics_add_callback(graphics.u.graphics, cb);
+ cb=callback_new_attr_1(callback_cast(pedestrian_graphics_postdraw),attr_postdraw,graphics.u.graphics);
+ graphics_add_callback(graphics.u.graphics, cb);
+ attr.type=attr_use_camera;
+ attr.u.num=1;
+ graphics_set_attr(graphics.u.graphics, &attr);
+ }
+ osd_rocket_init(nav);
#if 1
#ifndef HAVE_API_ANDROID
- pedestrian_setup_tilt(nav);
+ pedestrian_setup_tilt(nav);
#endif
- trans=navit_get_trans(nav);
- transform_set_pitch(trans, 90);
- transform_set_roll(trans, 0);
- transform_set_hog(trans, 2);
- transform_set_distance(trans, 0);
- transform_set_scales(trans, 750, 620, 32 << 8);
- if (!navit_get_attr(nav, attr_route, &route, NULL))
- return;
- if (!route_get_attr(route.u.route, attr_map, &route_map, NULL))
- return;
- dbg(lvl_debug,"enter 1\n");
+ trans=navit_get_trans(nav);
+ transform_set_pitch(trans, 90);
+ transform_set_roll(trans, 0);
+ transform_set_hog(trans, 2);
+ transform_set_distance(trans, 0);
+ transform_set_scales(trans, 750, 620, 32 << 8);
+ if (!navit_get_attr(nav, attr_route, &route, NULL))
+ return;
+ if (!route_get_attr(route.u.route, attr_map, &route_map, NULL))
+ return;
+ dbg(lvl_debug,"enter 1");
#if 0
- struct attr active;
- active.type=attr_active;
- active.u.num=0;
- if (!map_set_attr(route_map.u.map, &active))
- return;
- dbg(lvl_debug,"enter 2\n");
+ struct attr active;
+ active.type=attr_active;
+ active.u.num=0;
+ if (!map_set_attr(route_map.u.map, &active))
+ return;
+ dbg(lvl_debug,"enter 2");
#endif
- if (!navit_get_attr(nav, attr_mapset, &mapset, NULL))
- return;
- map.type=attr_map;
- map.u.map=map_new(NULL, (struct attr*[]){
- &(struct attr){attr_type,{"route_occluded"}},
- &(struct attr){attr_data,{""}},
- &(struct attr){attr_description,{"Occluded Route"}},
- &(struct attr){attr_navit,{(void *)nav}},
- NULL});
- global_map=map.u.map;
- mapset_add_attr(mapset.u.mapset, &map);
+ if (!navit_get_attr(nav, attr_mapset, &mapset, NULL))
+ return;
+ map.type=attr_map;
+ map.u.map=map_new(NULL, (struct attr*[]) {
+ &(struct attr) {
+ attr_type, {"route_occluded"}
+ },
+ &(struct attr) {
+ attr_data, {""}
+ },
+ &(struct attr) {
+ attr_description, {"Occluded Route"}
+ },
+ &(struct attr) {
+ attr_navit, {(void *)nav}
+ },
+ NULL
+ });
+ global_map=map.u.map;
+ mapset_add_attr(mapset.u.mapset, &map);
#if 0
- map=route_get_attr(route, attr_map);
+ map=route_get_attr(route, attr_map);
#endif
#endif
- transform_set_scale(trans, 16);
- navit_get_attr(nav, attr_layout, &initial_layout, NULL);
- iter=navit_attr_iter_new();
- while(navit_get_attr(nav, attr_layout, &attr, iter)) {
- if (!strcmp(attr.u.layout->name, "Route")) {
- dbg(lvl_debug,"found %s\n",attr_to_name(attr.type));
- main_layout=attr;
+ transform_set_scale(trans, 16);
+ navit_get_attr(nav, attr_layout, &initial_layout, NULL);
+ iter=navit_attr_iter_new();
+ while(navit_get_attr(nav, attr_layout, &attr, iter)) {
+ if (!strcmp(attr.u.layout->name, "Route")) {
+ dbg(lvl_debug,"found %s",attr_to_name(attr.type));
+ main_layout=attr;
#if 1
- navit_set_attr(nav, &attr);
+ navit_set_attr(nav, &attr);
#endif
- break;
- }
- }
- navit_attr_iter_destroy(iter);
- if (navit_get_attr(nav, attr_vehicle, &attr, NULL)) {
- struct attr cbattr;
- cbattr.u.callback=callback_new_attr_0(callback_cast(pedestrian_log), attr_log_gpx);
- cbattr.type=attr_callback;
- vehicle_add_attr(attr.u.vehicle, &cbattr);
+ break;
+ }
+ }
+ navit_attr_iter_destroy(iter);
+ if (navit_get_attr(nav, attr_vehicle, &attr, NULL)) {
+ struct attr cbattr;
+ cbattr.u.callback=callback_new_attr_0(callback_cast(pedestrian_log), attr_log_gpx);
+ cbattr.type=attr_callback;
+ vehicle_add_attr(attr.u.vehicle, &cbattr);
#ifdef DEMO
- cbattr.u.callback=callback_new_attr_2(callback_cast(vehicle_changed), attr_position_coord_geo, attr.u.vehicle, trans);
- cbattr.type=attr_callback;
- vehicle_add_attr(attr.u.vehicle, &cbattr);
+ cbattr.u.callback=callback_new_attr_2(callback_cast(vehicle_changed), attr_position_coord_geo, attr.u.vehicle, trans);
+ cbattr.type=attr_callback;
+ vehicle_add_attr(attr.u.vehicle, &cbattr);
#endif
- }
+ }
}
-static void
-pedestrian_navit(struct navit *nav, int add)
-{
- dbg(lvl_debug,"enter\n");
- struct attr callback;
- if (add) {
- callback.type=attr_callback;
- callback.u.callback=callback_new_attr_0(callback_cast(pedestrian_navit_init), attr_navit);
- navit_add_attr(nav, &callback);
- }
+static void pedestrian_navit(struct navit *nav, int add) {
+ dbg(lvl_debug,"enter");
+ struct attr callback;
+ if (add) {
+ callback.type=attr_callback;
+ callback.u.callback=callback_new_attr_0(callback_cast(pedestrian_navit_init), attr_navit);
+ navit_add_attr(nav, &callback);
+ }
}
-void
-plugin_init(void)
-{
- struct attr callback,navit;
- struct attr_iter *iter;
+void plugin_init(void) {
+ struct attr callback,navit;
+ struct attr_iter *iter;
#ifdef HAVE_API_ANDROID
- jclass ActivityClass;
- jmethodID Activity_setRequestedOrientation;
-
- if (!android_find_class_global("android/app/Activity", &ActivityClass))
- dbg(lvl_error,"failed to get class android/app/Activity\n");
- Activity_setRequestedOrientation = (*jnienv)->GetMethodID(jnienv, ActivityClass, "setRequestedOrientation", "(I)V");
- if (Activity_setRequestedOrientation == NULL)
- dbg(lvl_error,"failed to get method setRequestedOrientation from android/app/Activity\n");
- (*jnienv)->CallVoidMethod(jnienv, android_activity, Activity_setRequestedOrientation, 0);
+ jclass ActivityClass;
+ jmethodID Activity_setRequestedOrientation;
+
+ if (!android_find_class_global("android/app/Activity", &ActivityClass))
+ dbg(lvl_error,"failed to get class android/app/Activity");
+ Activity_setRequestedOrientation = (*jnienv)->GetMethodID(jnienv, ActivityClass, "setRequestedOrientation", "(I)V");
+ if (Activity_setRequestedOrientation == NULL)
+ dbg(lvl_error,"failed to get method setRequestedOrientation from android/app/Activity");
+ (*jnienv)->CallVoidMethod(jnienv, android_activity, Activity_setRequestedOrientation, 0);
#endif
-
- plugin_register_category_osd("marker", osd_marker_new);
- plugin_register_category_map("route_occluded", map_route_occluded_new);
- callback.type=attr_callback;
- callback.u.callback=callback_new_attr_0(callback_cast(pedestrian_navit), attr_navit);
- config_add_attr(config, &callback);
- iter=config_attr_iter_new();
- while (config_get_attr(config, attr_navit, &navit, iter))
- pedestrian_navit_init(navit.u.navit);
- config_attr_iter_destroy(iter);
+
+ plugin_register_category_osd("marker", osd_marker_new);
+ plugin_register_category_map("route_occluded", map_route_occluded_new);
+ callback.type=attr_callback;
+ callback.u.callback=callback_new_attr_0(callback_cast(pedestrian_navit), attr_navit);
+ config_add_attr(config, &callback);
+ iter=config_attr_iter_new();
+ while (config_get_attr(config, attr_navit, &navit, iter))
+ pedestrian_navit_init(navit.u.navit);
+ config_attr_iter_destroy(iter);
}
diff --git a/navit/plugin_def.h b/navit/plugin_def.h
index 3ccf1eec3..d342340ab 100644
--- a/navit/plugin_def.h
+++ b/navit/plugin_def.h
@@ -32,3 +32,4 @@ PLUGIN_CATEGORY(vehicle, (struct vehicle_methods *meth, struct callback_list *cb
PLUGIN_CATEGORY(event, (struct event_methods *meth))
PLUGIN_CATEGORY(audio, (struct audio_methods *meth, struct callback_list * cbl, struct attr **attrs, struct attr *parent))
PLUGIN_CATEGORY(font, (void *meth))
+PLUGIN_CATEGORY(traffic, (struct navit *nav, struct traffic_methods *meth, struct attr **attrs, struct callback_list *cbl))
diff --git a/navit/popup.c b/navit/popup.c
index 71b82b1d9..49f379853 100644
--- a/navit/popup.c
+++ b/navit/popup.c
@@ -44,395 +44,361 @@
#include "bookmarks.h"
#if 0
-static void
-popup_set_no_passing(struct popup_item *item, void *param)
-{
+static void popup_set_no_passing(struct popup_item *item, void *param) {
#if 0
- struct display_list *l=param;
- struct segment *seg=(struct segment *)(l->data);
- struct street_str *str=(struct street_str *)(seg->data[0]);
- char log[256];
- int segid=str->segid;
- if (segid < 0)
- segid=-segid;
-
- sprintf(log,"Attributes Street 0x%x updated: limit=0x%x(0x%x)", segid, 0x33, str->limit);
- str->limit=0x33;
- log_write(log, seg->blk_inf.file, str, sizeof(*str));
+ struct display_list *l=param;
+ struct segment *seg=(struct segment *)(l->data);
+ struct street_str *str=(struct street_str *)(seg->data[0]);
+ char log[256];
+ int segid=str->segid;
+ if (segid < 0)
+ segid=-segid;
+
+ sprintf(log,"Attributes Street 0x%x updated: limit=0x%x(0x%x)", segid, 0x33, str->limit);
+ str->limit=0x33;
+ log_write(log, seg->blk_inf.file, str, sizeof(*str));
#endif
}
#endif
-static void
-popup_traffic_distortion(struct item *item, char *attr)
-{
- /* add the configuration directory to the name of the file to use */
- char *dist_filename = g_strjoin(NULL, navit_get_user_data_directory(TRUE),
- "/distortion.txt", NULL);
- if (dist_filename) /* if we built the filename */
- {
- FILE *map=fopen(dist_filename,"a");
- if (map) /* if the file was opened */
- {
- struct coord c;
- struct map_rect *mr;
- fprintf(map,"type=traffic_distortion %s\n",attr);
- mr=map_rect_new(item->map,NULL);
- item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- while (item_coord_get(item, &c, 1)) {
- fprintf(map,"0x%x 0x%x\n",c.x,c.y);
- }
- fclose(map);
- }
- else
- {
- dbg(lvl_error,"could not open file for distortions !!");
-
- } /* else - if (map) */
- g_free(dist_filename); /* free the file name */
- } /* if (dist_filename) */
+static void popup_traffic_distortion(struct item *item, char *attr) {
+ /* add the configuration directory to the name of the file to use */
+ char *dist_filename = g_strjoin(NULL, navit_get_user_data_directory(TRUE),
+ "/distortion.txt", NULL);
+ if (dist_filename) { /* if we built the filename */
+ FILE *map=fopen(dist_filename,"a");
+ if (map) { /* if the file was opened */
+ struct coord c;
+ struct map_rect *mr;
+ fprintf(map,"type=traffic_distortion %s\n",attr);
+ mr=map_rect_new(item->map,NULL);
+ item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ while (item_coord_get(item, &c, 1)) {
+ fprintf(map,"0x%x 0x%x\n",c.x,c.y);
+ }
+ fclose(map);
+ } else {
+ dbg(lvl_error,"could not open file for distortions !!");
+
+ } /* else - if (map) */
+ g_free(dist_filename); /* free the file name */
+ } /* if (dist_filename) */
} /* end: popup_traffic_distortion(..) */
-
-static void
-popup_traffic_distortion_blocked(struct item *item)
-{
- dbg(lvl_debug,"item=%p\n",item);
- popup_traffic_distortion(item, "maxspeed=0");
+
+static void popup_traffic_distortion_blocked(struct item *item) {
+ dbg(lvl_debug,"item=%p",item);
+ popup_traffic_distortion(item, "maxspeed=0");
}
-static void
-popup_traffic_distortion_speed(struct item *item, int maxspeed)
-{
- char buffer[256];
- sprintf(buffer,"maxspeed=%d",maxspeed);
- popup_traffic_distortion(item,buffer);
+static void popup_traffic_distortion_speed(struct item *item, int maxspeed) {
+ char buffer[256];
+ sprintf(buffer,"maxspeed=%d",maxspeed);
+ popup_traffic_distortion(item,buffer);
}
-static void
-popup_traffic_distortion_delay(struct item *item, int delay)
-{
- char buffer[256];
- sprintf(buffer,"delay=%d",delay*600);
- popup_traffic_distortion(item,buffer);
+static void popup_traffic_distortion_delay(struct item *item, int delay) {
+ char buffer[256];
+ sprintf(buffer,"delay=%d",delay*600);
+ popup_traffic_distortion(item,buffer);
}
-static void
-popup_set_destination(struct navit *nav, struct pcoord *pc)
-{
- struct coord c;
- struct coord_geo g;
- char buffer[1024];
- char buffer_geo[1024];
- c.x = pc->x;
- c.y = pc->y;
- transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g);
- coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo));
- sprintf(buffer,"Map Point %s", buffer_geo);
- navit_set_destination(nav, pc, buffer, 1);
+static void popup_set_destination(struct navit *nav, struct pcoord *pc) {
+ struct coord c;
+ struct coord_geo g;
+ char buffer[1024];
+ char buffer_geo[1024];
+ c.x = pc->x;
+ c.y = pc->y;
+ transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g);
+ coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo));
+ sprintf(buffer,"Map Point %s", buffer_geo);
+ navit_set_destination(nav, pc, buffer, 1);
}
-void
-popup_set_visitbefore(struct navit *nav, struct pcoord *pc,int visitbefore)
-{
- struct pcoord *dst;
- char buffer[1024];
- int i, dstcount_new;
- sprintf(buffer, _("Waypoint %d"), visitbefore+1);
- dstcount_new=navit_get_destination_count(nav)+1;
- dst=g_alloca(dstcount_new*sizeof(struct pcoord));
- navit_get_destinations(nav,dst,dstcount_new);
- for (i=dstcount_new-1;i>visitbefore;i--){
- dst[i]=dst[i-1];
- }
- dst[visitbefore]=*pc;
- navit_add_destination_description(nav,pc,buffer);
- navit_set_destinations(nav, dst, dstcount_new, buffer, 1);
+void popup_set_visitbefore(struct navit *nav, struct pcoord *pc,int visitbefore) {
+ struct pcoord *dst;
+ char buffer[1024];
+ int i, dstcount_new;
+ sprintf(buffer, _("Waypoint %d"), visitbefore+1);
+ dstcount_new=navit_get_destination_count(nav)+1;
+ dst=g_alloca(dstcount_new*sizeof(struct pcoord));
+ navit_get_destinations(nav,dst,dstcount_new);
+ for (i=dstcount_new-1; i>visitbefore; i--) {
+ dst[i]=dst[i-1];
+ }
+ dst[visitbefore]=*pc;
+ navit_add_destination_description(nav,pc,buffer);
+ navit_set_destinations(nav, dst, dstcount_new, buffer, 1);
}
-static void
-popup_set_bookmark(struct navit *nav, struct pcoord *pc)
-{
+static void popup_set_bookmark(struct navit *nav, struct pcoord *pc) {
struct attr attr;
- struct coord c;
- struct coord_geo g;
- char buffer[1024];
- char buffer_geo[1024];
- c.x = pc->x;
- c.y = pc->y;
- transform_to_geo(pc->pro, &c, &g);
- coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo));
- sprintf(buffer,"Map Point %s", buffer_geo);
- if (!gui_add_bookmark(navit_get_gui(nav), pc, buffer)) {
+ struct coord c;
+ struct coord_geo g;
+ char buffer[1024];
+ char buffer_geo[1024];
+ c.x = pc->x;
+ c.y = pc->y;
+ transform_to_geo(pc->pro, &c, &g);
+ coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo));
+ sprintf(buffer,"Map Point %s", buffer_geo);
+ if (!gui_add_bookmark(navit_get_gui(nav), pc, buffer)) {
navit_get_attr(nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, pc, buffer);
+ bookmarks_add_bookmark(attr.u.bookmarks, pc, buffer);
}
}
extern void *vehicle;
-static void
-popup_set_position(struct navit *nav, struct pcoord *pc)
-{
- dbg(lvl_debug,"%p %p\n", nav, pc);
- navit_set_position(nav, pc);
+static void popup_set_position(struct navit *nav, struct pcoord *pc) {
+ dbg(lvl_debug,"%p %p", nav, pc);
+ navit_set_position(nav, pc);
}
#if 0
-static void
-popup_break_crossing(struct display_list *l)
-{
- struct segment *seg=(struct segment *)(l->data);
- struct street_str *str=(struct street_str *)(seg->data[0]);
- char log[256];
- int segid=str->segid;
- if (segid < 0)
- segid=-segid;
-
- sprintf(log,"Coordinates Street 0x%x updated: limit=0x%x(0x%x)", segid, 0x33, str->limit);
- str->limit=0x33;
- log_write(log, seg->blk_inf.file, str, sizeof(*str));
+static void popup_break_crossing(struct display_list *l) {
+ struct segment *seg=(struct segment *)(l->data);
+ struct street_str *str=(struct street_str *)(seg->data[0]);
+ char log[256];
+ int segid=str->segid;
+ if (segid < 0)
+ segid=-segid;
+
+ sprintf(log,"Coordinates Street 0x%x updated: limit=0x%x(0x%x)", segid, 0x33, str->limit);
+ str->limit=0x33;
+ log_write(log, seg->blk_inf.file, str, sizeof(*str));
}
#endif
#define popup_printf(menu, type, ...) popup_printf_cb(menu, type, NULL, __VA_ARGS__)
-static void *
-popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char *fmt, ...)
-{
- gchar *str,*us;
- int usc=0;
- va_list ap;
- void *ret;
-
- va_start(ap, fmt);
- str=g_strdup_vprintf(fmt, ap);
- dbg(lvl_debug,"%s\n", str);
- us=str;
- while (*us) {
- if (*us == '_')
- usc++;
- us++;
- }
- if (usc) {
- gchar *str2=g_malloc(strlen(str)+usc+1);
- gchar *us2=str2;
- us=str;
- while (*us) {
- if (*us == '_')
- *us2++=*us;
- *us2++=*us++;
- }
- *us2='\0';
- g_free(str);
- str=str2;
- }
- ret=menu_add(menu, str, type, cb);
- va_end(ap);
- g_free(str);
- return ret;
+static void *popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char *fmt, ...) {
+ gchar *str,*us;
+ int usc=0;
+ va_list ap;
+ void *ret;
+
+ va_start(ap, fmt);
+ str=g_strdup_vprintf(fmt, ap);
+ dbg(lvl_debug,"%s", str);
+ us=str;
+ while (*us) {
+ if (*us == '_')
+ usc++;
+ us++;
+ }
+ if (usc) {
+ gchar *str2=g_malloc(strlen(str)+usc+1);
+ gchar *us2=str2;
+ us=str;
+ while (*us) {
+ if (*us == '_')
+ *us2++=*us;
+ *us2++=*us++;
+ }
+ *us2='\0';
+ g_free(str);
+ str=str2;
+ }
+ ret=menu_add(menu, str, type, cb);
+ va_end(ap);
+ g_free(str);
+ return ret;
}
-static void
-popup_show_visitbefore(struct navit *nav,struct pcoord *pc, void *menu)
-{
- void *menuvisitbefore;
- char buffer[100];
- int i, dstcount;
- dstcount=navit_get_destination_count(nav);
- if (dstcount>=1){
- menuvisitbefore=popup_printf(menu, menu_type_submenu, _("Visit before..."));
- for (i=0;i<dstcount;i++){
- sprintf(buffer,_("Waypoint %d"),i+1);
- popup_printf_cb(menuvisitbefore, menu_type_menu, callback_new_3(callback_cast(popup_set_visitbefore), nav, pc,i), buffer);
- }
- }
+static void popup_show_visitbefore(struct navit *nav,struct pcoord *pc, void *menu) {
+ void *menuvisitbefore;
+ char buffer[100];
+ int i, dstcount;
+ dstcount=navit_get_destination_count(nav);
+ if (dstcount>=1) {
+ menuvisitbefore=popup_printf(menu, menu_type_submenu, _("Visit before..."));
+ for (i=0; i<dstcount; i++) {
+ sprintf(buffer,_("Waypoint %d"),i+1);
+ popup_printf_cb(menuvisitbefore, menu_type_menu, callback_new_3(callback_cast(popup_set_visitbefore), nav, pc,i),
+ buffer);
+ }
+ }
}
-static void
-popup_show_attr_val(struct map *map, void *menu, struct attr *attr)
-{
- char *attr_name=attr_to_name(attr->type);
- char *str;
+static void popup_show_attr_val(struct map *map, void *menu, struct attr *attr) {
+ char *attr_name=attr_to_name(attr->type);
+ char *str;
- str=attr_to_text(attr, map, 1);
- popup_printf(menu, menu_type_menu, "%s: %s", attr_name, str);
- g_free(str);
+ str=attr_to_text(attr, map, 1);
+ popup_printf(menu, menu_type_menu, "%s: %s", attr_name, str);
+ g_free(str);
}
#if 0
-static void
-popup_show_attr(void *menu, struct item *item, enum attr_type attr_type)
-{
- struct attr attr;
- memset(&attr, 0, sizeof(attr));
- attr.type=attr_type;
- if (item_attr_get(item, attr_type, &attr))
- popup_show_attr_val(menu, &attr);
+static void popup_show_attr(void *menu, struct item *item, enum attr_type attr_type) {
+ struct attr attr;
+ memset(&attr, 0, sizeof(attr));
+ attr.type=attr_type;
+ if (item_attr_get(item, attr_type, &attr))
+ popup_show_attr_val(menu, &attr);
}
#endif
-static void
-popup_show_attrs(struct map *map, void *menu, struct item *item)
-{
+static void popup_show_attrs(struct map *map, void *menu, struct item *item) {
#if 0
- popup_show_attr(menu, item, attr_debug);
- popup_show_attr(menu, item, attr_address);
- popup_show_attr(menu, item, attr_phone);
- popup_show_attr(menu, item, attr_phone);
- popup_show_attr(menu, item, attr_entry_fee);
- popup_show_attr(menu, item, attr_open_hours);
+ popup_show_attr(menu, item, attr_debug);
+ popup_show_attr(menu, item, attr_address);
+ popup_show_attr(menu, item, attr_phone);
+ popup_show_attr(menu, item, attr_phone);
+ popup_show_attr(menu, item, attr_entry_fee);
+ popup_show_attr(menu, item, attr_open_hours);
#else
- struct attr attr;
- for (;;) {
- memset(&attr, 0, sizeof(attr));
- if (item_attr_get(item, attr_any, &attr))
- popup_show_attr_val(map, menu, &attr);
- else
- break;
- }
-
+ struct attr attr;
+ for (;;) {
+ memset(&attr, 0, sizeof(attr));
+ if (item_attr_get(item, attr_any, &attr))
+ popup_show_attr_val(map, menu, &attr);
+ else
+ break;
+ }
+
#endif
}
-static void
-popup_item_dump(struct item *item)
-{
- struct map_rect *mr;
- mr=map_rect_new(item->map,NULL);
- item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- dbg(lvl_debug,"item=%p\n",item);
- item_dump_filedesc(item,item->map,stdout);
- map_rect_destroy(mr);
+static void popup_item_dump(struct item *item) {
+ struct map_rect *mr;
+ mr=map_rect_new(item->map,NULL);
+ item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ dbg(lvl_debug,"item=%p",item);
+ item_dump_filedesc(item,item->map,stdout);
+ map_rect_destroy(mr);
}
-static void
-popup_show_item(struct navit *nav, void *popup, struct displayitem *di)
-{
- struct map_rect *mr;
- void *menu, *menu_item, *menu_dist;
- char *label;
- struct item *item,*diitem;
- int count;
-
- label=graphics_displayitem_get_label(di);
- diitem=graphics_displayitem_get_item(di);
- count=graphics_displayitem_get_coord_count(di);
-
- dbg_assert(diitem);
-
- if (label)
- menu=popup_printf(popup, menu_type_submenu, "%s '%s' (%d coords)", item_to_name(diitem->type), label, count);
- else
- menu=popup_printf(popup, menu_type_submenu, "%s (%d coords)", item_to_name(diitem->type), count);
- menu_item=popup_printf(menu, menu_type_submenu, "Item");
- popup_printf(menu_item, menu_type_menu, "type: 0x%x", diitem->type);
- popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", diitem->id_hi, diitem->id_lo);
- if (diitem->map) {
- struct attr type,data;
- if (!map_get_attr(diitem->map, attr_type, &type, NULL))
- type.u.str="";
- if (!map_get_attr(diitem->map, attr_data, &data, NULL))
- data.u.str="";
- popup_printf(menu_item, menu_type_menu, "map: %s:%s", type.u.str, data.u.str);
- }
- if (diitem->map) {
- mr=map_rect_new(diitem->map,NULL);
- item=map_rect_get_item_byid(mr, diitem->id_hi, diitem->id_lo);
- dbg(lvl_debug,"item=%p\n", item);
- if (item) {
- popup_show_attrs(item->map, menu_item, item);
- popup_printf_cb(menu_item, menu_type_menu, callback_new_1(callback_cast(popup_item_dump), diitem), "Dump");
- if (item->type < type_line) {
- struct coord co;
- struct pcoord *c;
- if (item_coord_get(item, &co, 1)) {
- c=g_new(struct pcoord, 1);
- c->pro = transform_get_projection(navit_get_trans(nav));
- c->x = co.x;
- c->y = co.y;
- popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, c), _("Set as position"));
- popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, c), _("Set as destination"));
- popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, c), _("Add as bookmark"));
- }
- }
- }
- map_rect_destroy(mr);
- } else {
- popup_printf(menu, menu_type_menu, "(No map)");
- }
- if (item_get_default_flags(diitem->type)) {
- int speeds[]={5,10,20,30,40,50,60,70,80,90,100};
- int delays[]={1,2,3,5,10,15,20,30,45,60,75,90,120,150,180,240,300};
- int i;
- menu_dist=popup_printf(menu, menu_type_submenu, "Traffic distortion");
- popup_printf_cb(menu_dist, menu_type_menu, callback_new_1(callback_cast(popup_traffic_distortion_blocked), diitem), "Blocked");
- menu_item=popup_printf(menu_dist, menu_type_submenu,"Max speed");
- for (i = 0 ; i < sizeof(speeds)/sizeof(int); i++) {
- popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_traffic_distortion_speed), diitem, speeds[i]), "%d km/h",speeds[i]);
- }
- menu_item=popup_printf(menu_dist, menu_type_submenu,"Delay");
- for (i = 0 ; i < sizeof(delays)/sizeof(int); i++) {
- popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_traffic_distortion_delay), diitem, delays[i]*600), "%d min",delays[i]);
- }
- }
+static void popup_show_item(struct navit *nav, void *popup, struct displayitem *di) {
+ struct map_rect *mr;
+ void *menu, *menu_item, *menu_dist;
+ char *label;
+ struct item *item,*diitem;
+ int count;
+
+ label=graphics_displayitem_get_label(di);
+ diitem=graphics_displayitem_get_item(di);
+ count=graphics_displayitem_get_coord_count(di);
+
+ dbg_assert(diitem);
+
+ if (label)
+ menu=popup_printf(popup, menu_type_submenu, "%s '%s' (%d coords)", item_to_name(diitem->type), label, count);
+ else
+ menu=popup_printf(popup, menu_type_submenu, "%s (%d coords)", item_to_name(diitem->type), count);
+ menu_item=popup_printf(menu, menu_type_submenu, "Item");
+ popup_printf(menu_item, menu_type_menu, "type: 0x%x", diitem->type);
+ popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", diitem->id_hi, diitem->id_lo);
+ if (diitem->map) {
+ struct attr type,data;
+ if (!map_get_attr(diitem->map, attr_type, &type, NULL))
+ type.u.str="";
+ if (!map_get_attr(diitem->map, attr_data, &data, NULL))
+ data.u.str="";
+ popup_printf(menu_item, menu_type_menu, "map: %s:%s", type.u.str, data.u.str);
+ }
+ if (diitem->map) {
+ mr=map_rect_new(diitem->map,NULL);
+ item=map_rect_get_item_byid(mr, diitem->id_hi, diitem->id_lo);
+ dbg(lvl_debug,"item=%p", item);
+ if (item) {
+ popup_show_attrs(item->map, menu_item, item);
+ popup_printf_cb(menu_item, menu_type_menu, callback_new_1(callback_cast(popup_item_dump), diitem), "Dump");
+ if (item->type < type_line) {
+ struct coord co;
+ struct pcoord *c;
+ if (item_coord_get(item, &co, 1)) {
+ c=g_new(struct pcoord, 1);
+ c->pro = transform_get_projection(navit_get_trans(nav));
+ c->x = co.x;
+ c->y = co.y;
+ popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, c),
+ _("Set as position"));
+ popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, c),
+ _("Set as destination"));
+ popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, c),
+ _("Add as bookmark"));
+ }
+ }
+ }
+ map_rect_destroy(mr);
+ } else {
+ popup_printf(menu, menu_type_menu, "(No map)");
+ }
+ if (item_get_default_flags(diitem->type)) {
+ int speeds[]= {5,10,20,30,40,50,60,70,80,90,100};
+ int delays[]= {1,2,3,5,10,15,20,30,45,60,75,90,120,150,180,240,300};
+ int i;
+ menu_dist=popup_printf(menu, menu_type_submenu, "Traffic distortion");
+ popup_printf_cb(menu_dist, menu_type_menu, callback_new_1(callback_cast(popup_traffic_distortion_blocked), diitem),
+ "Blocked");
+ menu_item=popup_printf(menu_dist, menu_type_submenu,"Max speed");
+ for (i = 0 ; i < sizeof(speeds)/sizeof(int); i++) {
+ popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_traffic_distortion_speed), diitem,
+ speeds[i]), "%d km/h",speeds[i]);
+ }
+ menu_item=popup_printf(menu_dist, menu_type_submenu,"Delay");
+ for (i = 0 ; i < sizeof(delays)/sizeof(int); i++) {
+ popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_traffic_distortion_delay), diitem,
+ delays[i]*600), "%d min",delays[i]);
+ }
+ }
}
-static void
-popup_display(struct navit *nav, void *popup, struct point *p)
-{
- struct displaylist_handle *dlh;
- struct displaylist *display;
- struct displayitem *di;
-
- display=navit_get_displaylist(nav);
- dlh=graphics_displaylist_open(display);
- while ((di=graphics_displaylist_next(dlh))) {
- if (graphics_displayitem_within_dist(display, di, p, 5)) {
- popup_show_item(nav, popup, di);
- }
- }
- graphics_displaylist_close(dlh);
+static void popup_display(struct navit *nav, void *popup, struct point *p) {
+ struct displaylist_handle *dlh;
+ struct displaylist *display;
+ struct displayitem *di;
+
+ display=navit_get_displaylist(nav);
+ dlh=graphics_displaylist_open(display);
+ while ((di=graphics_displaylist_next(dlh))) {
+ if (graphics_displayitem_within_dist(display, di, p, 5)) {
+ popup_show_item(nav, popup, di);
+ }
+ }
+ graphics_displaylist_close(dlh);
}
static struct pcoord c;
-void
-popup(struct navit *nav, int button, struct point *p)
-{
- void *popup,*men;
- char buffer[1024];
- struct coord_geo g;
- struct coord co;
-
- popup=gui_popup_new(navit_get_gui(nav));
- if (! popup)
- return;
- transform_reverse(navit_get_trans(nav), p, &co);
- men=popup_printf(popup, menu_type_submenu, _("Point 0x%x 0x%x"), co.x, co.y);
- popup_printf(men, menu_type_menu, _("Screen coord : %d %d"), p->x, p->y);
- transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &g);
- coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
- popup_printf(men, menu_type_menu, "%s", buffer);
- popup_printf(men, menu_type_menu, "%f %f", g.lat, g.lng);
- dbg(lvl_debug,"%p %p\n", nav, &c);
- c.pro = transform_get_projection(navit_get_trans(nav));
- c.x = co.x;
- c.y = co.y;
- popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, &c), _("Set as position"));
- popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, &c), _("Set as destination"));
- popup_show_visitbefore(nav,&c,men);
- popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, &c), _("Add as bookmark"));
- popup_display(nav, popup, p);
- menu_popup(popup);
+void popup(struct navit *nav, int button, struct point *p) {
+ void *popup,*men;
+ char buffer[1024];
+ struct coord_geo g;
+ struct coord co;
+
+ popup=gui_popup_new(navit_get_gui(nav));
+ if (! popup)
+ return;
+ transform_reverse(navit_get_trans(nav), p, &co);
+ men=popup_printf(popup, menu_type_submenu, _("Point 0x%x 0x%x"), co.x, co.y);
+ popup_printf(men, menu_type_menu, _("Screen coord : %d %d"), p->x, p->y);
+ transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &g);
+ coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
+ popup_printf(men, menu_type_menu, "%s", buffer);
+ popup_printf(men, menu_type_menu, "%f %f", g.lat, g.lng);
+ dbg(lvl_debug,"%p %p", nav, &c);
+ c.pro = transform_get_projection(navit_get_trans(nav));
+ c.x = co.x;
+ c.y = co.y;
+ popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, &c), _("Set as position"));
+ popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, &c),
+ _("Set as destination"));
+ popup_show_visitbefore(nav,&c,men);
+ popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, &c), _("Add as bookmark"));
+ popup_display(nav, popup, p);
+ menu_popup(popup);
}
diff --git a/navit/profile.c b/navit/profile.c
index 564a63096..d1645377f 100644
--- a/navit/profile.c
+++ b/navit/profile.c
@@ -53,35 +53,33 @@
* parameters as varargs. May be NULL; then no message is printed, and all timers with the
* same or higher level are reset.
*/
-void
-profile_timer(int level, const char *module, const char *function, const char *fmt, ...)
-{
+void profile_timer(int level, const char *module, const char *function, const char *fmt, ...) {
#ifndef _MSC_VER
- va_list ap;
- static struct timeval last[PROFILE_LEVEL_MAX+1];
- struct timeval curr;
- double msec;
- char buffer[strlen(module)+20];
+ va_list ap;
+ static struct timeval last[PROFILE_LEVEL_MAX+1];
+ struct timeval curr;
+ double msec;
+ char buffer[strlen(module)+20];
- if (level < 0)
- level=0;
- if (level > PROFILE_LEVEL_MAX)
- level=PROFILE_LEVEL_MAX;
- if (fmt) {
- gettimeofday(&curr, NULL);
- msec=(curr.tv_usec-last[level].tv_usec)/((double)1000)+
- (curr.tv_sec-last[level].tv_sec)*1000;
-
- sprintf(buffer, "profile:%s", module);
- va_start(ap, fmt);
- debug_vprintf(lvl_debug, buffer, strlen(buffer), function, strlen(function), 1, fmt, ap);
- va_end(ap);
- debug_printf(lvl_debug, buffer, strlen(buffer), function, strlen(function), 0, " %7.1f ms\n", msec);
- gettimeofday(&last[level], NULL);
- } else {
- gettimeofday(&curr, NULL);
- while (level <= PROFILE_LEVEL_MAX)
- last[level++]=curr;
- }
+ if (level < 0)
+ level=0;
+ if (level > PROFILE_LEVEL_MAX)
+ level=PROFILE_LEVEL_MAX;
+ if (fmt) {
+ gettimeofday(&curr, NULL);
+ msec=(curr.tv_usec-last[level].tv_usec)/((double)1000)+
+ (curr.tv_sec-last[level].tv_sec)*1000;
+
+ sprintf(buffer, "profile:%s", module);
+ va_start(ap, fmt);
+ debug_vprintf(lvl_debug, buffer, strlen(buffer), function, strlen(function), 1, fmt, ap);
+ va_end(ap);
+ debug_printf(lvl_debug, buffer, strlen(buffer), function, strlen(function), 0, " %7.1f ms\n", msec);
+ gettimeofday(&last[level], NULL);
+ } else {
+ gettimeofday(&curr, NULL);
+ while (level <= PROFILE_LEVEL_MAX)
+ last[level++]=curr;
+ }
#endif /*_MSC_VER*/
}
diff --git a/navit/profile_option.c b/navit/profile_option.c
index 8a1049068..307c9de0d 100644
--- a/navit/profile_option.c
+++ b/navit/profile_option.c
@@ -22,41 +22,36 @@
#include "debug.h"
#include "xmlconfig.h"
-struct profile_option
-{
- NAVIT_OBJECT
+struct profile_option {
+ NAVIT_OBJECT
};
-static struct profile_option *
-profile_option_new(struct attr *parent, struct attr **attrs)
-{
- struct profile_option *po=g_new0(struct profile_option, 1);
- po->func=&profile_option_func;
- navit_object_ref((struct navit_object *)po);
- po->attrs=attr_list_dup(attrs);
- dbg(lvl_debug,"return %p\n",po);
- return po;
+static struct profile_option *profile_option_new(struct attr *parent, struct attr **attrs) {
+ struct profile_option *po=g_new0(struct profile_option, 1);
+ po->func=&profile_option_func;
+ navit_object_ref((struct navit_object *)po);
+ po->attrs=attr_list_dup(attrs);
+ dbg(lvl_debug,"return %p",po);
+ return po;
}
-static void
-profile_option_destroy(struct profile_option *po)
-{
- attr_list_free(po->attrs);
- g_free(po);
+static void profile_option_destroy(struct profile_option *po) {
+ attr_list_free(po->attrs);
+ g_free(po);
}
struct object_func profile_option_func = {
- attr_profile_option,
- (object_func_new)profile_option_new,
- (object_func_get_attr)navit_object_get_attr,
- (object_func_iter_new)navit_object_attr_iter_new,
- (object_func_iter_destroy)navit_object_attr_iter_destroy,
- (object_func_set_attr)navit_object_set_attr,
- (object_func_add_attr)navit_object_add_attr,
- (object_func_remove_attr)navit_object_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)profile_option_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_profile_option,
+ (object_func_new)profile_option_new,
+ (object_func_get_attr)navit_object_get_attr,
+ (object_func_iter_new)navit_object_attr_iter_new,
+ (object_func_iter_destroy)navit_object_attr_iter_destroy,
+ (object_func_set_attr)navit_object_set_attr,
+ (object_func_add_attr)navit_object_add_attr,
+ (object_func_remove_attr)navit_object_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)profile_option_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/projection.c b/navit/projection.c
index d916689ee..512a4d888 100644
--- a/navit/projection.c
+++ b/navit/projection.c
@@ -24,30 +24,28 @@
#include "projection.h"
struct projection_name {
- enum projection projection;
- char *name;
+ enum projection projection;
+ char *name;
};
-struct projection_name projection_names[]={
- {projection_none, ""},
- {projection_mg, "mg"},
- {projection_garmin, "garmin"},
- {projection_utm, "utm"},
+struct projection_name projection_names[]= {
+ {projection_none, ""},
+ {projection_mg, "mg"},
+ {projection_garmin, "garmin"},
+ {projection_utm, "utm"},
};
-static int
-utmref_letter(char l)
-{
- if (l < 'a' || l == 'i' || l == 'o')
- return -1;
- if (l < 'i')
- return l-'a';
- if (l < 'o')
- return l-'a'-1;
- if (l <= 'z')
- return l-'a'-2;
- return -1;
+static int utmref_letter(char l) {
+ if (l < 'a' || l == 'i' || l == 'o')
+ return -1;
+ if (l < 'i')
+ return l-'a';
+ if (l < 'o')
+ return l-'a'-1;
+ if (l <= 'z')
+ return l-'a'-2;
+ return -1;
}
/**
@@ -57,57 +55,53 @@ utmref_letter(char l)
* @utm_offset Only for UTM projections: Used to return the offset for the UTM projection
* @returns projection, or projection_none if no projection could be determined
*/
-enum projection
-projection_from_name(const char *name, struct coord *utm_offset)
-{
- int i;
- int zone,baserow;
- char ns,zone_field,square_x,square_y;
+enum projection projection_from_name(const char *name, struct coord *utm_offset) {
+ int i;
+ int zone,baserow;
+ char ns,zone_field,square_x,square_y;
- for (i=0 ; i < sizeof(projection_names)/sizeof(struct projection_name) ; i++) {
- if (! strcmp(projection_names[i].name, name))
- return projection_names[i].projection;
- }
- if (utm_offset) {
- if (sscanf(name,"utm%d%c",&zone,&ns) == 2 && zone > 0 && zone <= 60 && (ns == 'n' || ns == 's')) {
- utm_offset->x=zone*1000000;
- utm_offset->y=(ns == 's' ? -10000000:0);
- return projection_utm;
- }
- if (sscanf(name,"utmref%d%c%c%c",&zone,&zone_field,&square_x,&square_y)) {
- i=utmref_letter(zone_field);
- if (i < 2 || i > 21) {
- dbg(lvl_error,"invalid zone field '%c' in '%s'\n",zone_field,name);
- return projection_none;
- }
- i-=12;
- dbg(lvl_debug,"zone_field %d\n",i);
- baserow=i*887.6/100;
- utm_offset->x=zone*1000000;
- i=utmref_letter(square_x);
- utm_offset->x+=((i%8)+1)*100000;
- i=utmref_letter(square_y);
- dbg(lvl_debug,"baserow %d\n",baserow);
- if (!(zone % 2))
- i-=5;
- dbg(lvl_debug,"i=%d\n",i);
- i=(i-baserow+100)%20+baserow;
- utm_offset->y=i*100000;
- return projection_utm;
- }
- }
- return projection_none;
+ for (i=0 ; i < sizeof(projection_names)/sizeof(struct projection_name) ; i++) {
+ if (! strcmp(projection_names[i].name, name))
+ return projection_names[i].projection;
+ }
+ if (utm_offset) {
+ if (sscanf(name,"utm%d%c",&zone,&ns) == 2 && zone > 0 && zone <= 60 && (ns == 'n' || ns == 's')) {
+ utm_offset->x=zone*1000000;
+ utm_offset->y=(ns == 's' ? -10000000:0);
+ return projection_utm;
+ }
+ if (sscanf(name,"utmref%d%c%c%c",&zone,&zone_field,&square_x,&square_y)) {
+ i=utmref_letter(zone_field);
+ if (i < 2 || i > 21) {
+ dbg(lvl_error,"invalid zone field '%c' in '%s'",zone_field,name);
+ return projection_none;
+ }
+ i-=12;
+ dbg(lvl_debug,"zone_field %d",i);
+ baserow=i*887.6/100;
+ utm_offset->x=zone*1000000;
+ i=utmref_letter(square_x);
+ utm_offset->x+=((i%8)+1)*100000;
+ i=utmref_letter(square_y);
+ dbg(lvl_debug,"baserow %d",baserow);
+ if (!(zone % 2))
+ i-=5;
+ dbg(lvl_debug,"i=%d",i);
+ i=(i-baserow+100)%20+baserow;
+ utm_offset->y=i*100000;
+ return projection_utm;
+ }
+ }
+ return projection_none;
}
-char *
-projection_to_name(enum projection proj)
-{
- int i;
+char *projection_to_name(enum projection proj) {
+ int i;
- for (i=0 ; i < sizeof(projection_names)/sizeof(struct projection_name) ; i++) {
- if (projection_names[i].projection == proj)
- return projection_names[i].name;
- }
- return NULL;
+ for (i=0 ; i < sizeof(projection_names)/sizeof(struct projection_name) ; i++) {
+ if (projection_names[i].projection == proj)
+ return projection_names[i].name;
+ }
+ return NULL;
}
diff --git a/navit/roadprofile.c b/navit/roadprofile.c
index 1cda16130..81033d46d 100644
--- a/navit/roadprofile.c
+++ b/navit/roadprofile.c
@@ -23,109 +23,91 @@
#include "xmlconfig.h"
#include "roadprofile.h"
-static void
-roadprofile_set_attr_do(struct roadprofile *this, struct attr *attr)
-{
- switch (attr->type) {
- case attr_speed:
- this->speed=attr->u.num;
- break;
- case attr_maxspeed:
- this->maxspeed=attr->u.num;
- break;
- case attr_route_weight:
- this->route_weight=attr->u.num;
- break;
- default:
- break;
- }
+static void roadprofile_set_attr_do(struct roadprofile *this, struct attr *attr) {
+ switch (attr->type) {
+ case attr_speed:
+ this->speed=attr->u.num;
+ break;
+ case attr_maxspeed:
+ this->maxspeed=attr->u.num;
+ break;
+ case attr_route_weight:
+ this->route_weight=attr->u.num;
+ break;
+ default:
+ break;
+ }
}
struct roadprofile *
-roadprofile_new(struct attr *parent, struct attr **attrs)
-{
- struct roadprofile *this_;
- struct attr **attr;
- this_=g_new0(struct roadprofile, 1);
- this_->func=&roadprofile_func;
- navit_object_ref((struct navit_object *)this_);
+roadprofile_new(struct attr *parent, struct attr **attrs) {
+ struct roadprofile *this_;
+ struct attr **attr;
+ this_=g_new0(struct roadprofile, 1);
+ this_->func=&roadprofile_func;
+ navit_object_ref((struct navit_object *)this_);
- this_->attrs=attr_list_dup(attrs);
- for (attr=attrs;*attr; attr++)
- roadprofile_set_attr_do(this_, *attr);
- return this_;
+ this_->attrs=attr_list_dup(attrs);
+ for (attr=attrs; *attr; attr++)
+ roadprofile_set_attr_do(this_, *attr);
+ return this_;
}
-int
-roadprofile_get_attr(struct roadprofile *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+int roadprofile_get_attr(struct roadprofile *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
}
-int
-roadprofile_set_attr(struct roadprofile *this_, struct attr *attr)
-{
- roadprofile_set_attr_do(this_, attr);
- this_->attrs=attr_generic_set_attr(this_->attrs, attr);
- return 1;
+int roadprofile_set_attr(struct roadprofile *this_, struct attr *attr) {
+ roadprofile_set_attr_do(this_, attr);
+ this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+ return 1;
}
-int
-roadprofile_add_attr(struct roadprofile *this_, struct attr *attr)
-{
- this_->attrs=attr_generic_add_attr(this_->attrs, attr);
- return 1;
+int roadprofile_add_attr(struct roadprofile *this_, struct attr *attr) {
+ this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+ return 1;
}
-int
-roadprofile_remove_attr(struct roadprofile *this_, struct attr *attr)
-{
- this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
- return 1;
+int roadprofile_remove_attr(struct roadprofile *this_, struct attr *attr) {
+ this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
+ return 1;
}
struct attr_iter *
-roadprofile_attr_iter_new(void)
-{
- return (struct attr_iter *)g_new0(void *,1);
+roadprofile_attr_iter_new(void) {
+ return (struct attr_iter *)g_new0(void *,1);
}
-void
-roadprofile_attr_iter_destroy(struct attr_iter *iter)
-{
- g_free(iter);
+void roadprofile_attr_iter_destroy(struct attr_iter *iter) {
+ g_free(iter);
}
-static struct roadprofile *
-roadprofile_dup(struct roadprofile *this_)
-{
- struct roadprofile *ret=g_new(struct roadprofile, 1);
- *ret=*this_;
- ret->refcount=1;
- ret->attrs=attr_list_dup(this_->attrs);
- return ret;
+static struct roadprofile *roadprofile_dup(struct roadprofile *this_) {
+ struct roadprofile *ret=g_new(struct roadprofile, 1);
+ *ret=*this_;
+ ret->refcount=1;
+ ret->attrs=attr_list_dup(this_->attrs);
+ return ret;
}
-static void
-roadprofile_destroy(struct roadprofile *this_)
-{
- attr_list_free(this_->attrs);
- g_free(this_);
+static void roadprofile_destroy(struct roadprofile *this_) {
+ attr_list_free(this_->attrs);
+ g_free(this_);
}
struct object_func roadprofile_func = {
- attr_roadprofile,
- (object_func_new)roadprofile_new,
- (object_func_get_attr)roadprofile_get_attr,
- (object_func_iter_new)roadprofile_attr_iter_new,
- (object_func_iter_destroy)roadprofile_attr_iter_destroy,
- (object_func_set_attr)roadprofile_set_attr,
- (object_func_add_attr)roadprofile_add_attr,
- (object_func_remove_attr)roadprofile_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)roadprofile_destroy,
- (object_func_dup)roadprofile_dup,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_roadprofile,
+ (object_func_new)roadprofile_new,
+ (object_func_get_attr)roadprofile_get_attr,
+ (object_func_iter_new)roadprofile_attr_iter_new,
+ (object_func_iter_destroy)roadprofile_attr_iter_destroy,
+ (object_func_set_attr)roadprofile_set_attr,
+ (object_func_add_attr)roadprofile_add_attr,
+ (object_func_remove_attr)roadprofile_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)roadprofile_destroy,
+ (object_func_dup)roadprofile_dup,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/route.c b/navit/route.c
index 364bd390c..3633abc6a 100644
--- a/navit/route.c
+++ b/navit/route.c
@@ -1,6 +1,6 @@
/**
* Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
+ * Copyright (C) 2005-2018 Navit Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -23,31 +23,68 @@
* Routing uses segments, points and items. Items are items from the map: Streets, highways, etc.
* Segments represent such items, or parts of it. Generally, a segment is a driveable path. An item
* can be represented by more than one segment - in that case it is "segmented". Each segment has an
- * "offset" associated, that indicates at which position in a segmented item this segment is - a
+ * "offset" associated, that indicates at which position in a segmented item this segment is - a
* segment representing a not-segmented item always has the offset 1.
* A point is located at the end of segments, often connecting several segments.
- *
+ *
* The code in this file will make navit find a route between a position and a destination.
* It accomplishes this by first building a "route graph". This graph contains segments and
* points.
*
- * After building this graph in route_graph_build(), the function route_graph_flood() assigns every
- * point and segment a "value" which represents the "costs" of traveling from this point to the
- * destination. This is done by Dijkstra's algorithm.
- *
- * When the graph is built a "route path" is created, which is a path in this graph from a given
- * position to the destination determined at time of building the graph.
+ * Routing now relies on the Lifelong Planning A* (LPA*) algorithm, which builds upon the A* algorithm but allows for
+ * partial updates after the cost of some segments has changed. (With A*, one would need to recalculate the entire
+ * route graph from scratch.) A*, in turn, is an extension of the Dijkstra algorithm, with the added improvement that
+ * A* introduces a heuristic (essentially, a lower boundary for the yet-to-be-calculated remainder of the route from a
+ * given point onwards) and chooses the next point to analyze based on the sum of its cost and its heuristic, where
+ * Dijkstra uses simply the cost of the node. This makes A* more efficient than Dijkstra in some scenarios. (Navit,
+ * however, is not one of them, as we currently analyze only a subset of the entire map, and calculating the heuristic
+ * for each node turned out to cost more than it saved in tests.)
+ *
+ * Wikipedia has articles on all three algorithms; refer to these for an in-depth discussion of the algorithms.
+ *
+ * If the heuristic is assumed to be zero in all cases, A* behaves exactly as Dijkstra would. Similarly, LPA* behaves
+ * identically to A* if all segment costs are known prior to route calculation and do not change once route calculation
+ * has started.
+ *
+ * Earlier versions of Navit used Dijkstra for routing. This was upgraded to LPA* when the traffic module was
+ * introduced, as it became necessary to do fast partial recalculations of the route when the traffic situation
+ * changes. Navit’s LPA* implementation differs from the canonical implementation in two important ways:
+ *
+ * \li The heuristic is not used (or assumed to be zero), for the reasons discussed above. However, this is not set in
+ * stone and can be revisited if we find using a heuristic provides a true benefit.
+ * \li Since the destination point may be off-road, Navit may initialize the route graph with multiple candidates for
+ * the destination point, each of which will get a nonzero cost (which may still decrease if routing later determines
+ * that it is cheaper to route from that candidate point to a different candidate point).
+ *
+ * The cost of a node is always the cost to reach the destination, and route calculation is done “backwards”, i.e.
+ * starting at the destination and working its way to the current position (or previous waypoint). This is mandatory
+ * in LPA*, while A* and Dijkstra can also work from the start to the destination. The latter is found in most textbook
+ * descriptions of these algorithms. Navit has always calculated routes from destination to start, even with Dijkstra,
+ * as this made it easier to react to changes in the vehicle position (the start of the route).
+ *
+ * A route graph first needs to be built with `route_graph_build()`, which fetches the segments from the map. Next
+ * `route_graph_init()` is called to initialize the destination point candidates. Then
+ * `route_graph_compute_shortest_path()` is called to assign a `value` to each node, which represents the cost of
+ * traveling from this point to the destination. Each point is also assigned a “next segment” to take in order to reach
+ * the destination from this point. Eventually a “route path” is created, i.e. the sequence of segments from the
+ * current position to the destination are extracted from the route graph and turn instructions are added where
+ * necessary.
+ *
+ * When segment costs change, `route_graph_point_update()` is called for each end point which may have changed. Then
+ * `route_graph_compute_shortest_path()` is called to update parts of the route which may have changed, and finally the
+ * route path is recreated. This is used by the traffic module when traffic reports change the cost of individual
+ * segments.
+ *
+ * A completely new route can be created from an existing graph, which happens e.g. between sections of a route when
+ * waypoints are used. This is done by calling `route_graph_reset()`, which resets all nodes to their initial state.
+ * Then `route_graph_init()` is called, followed by `route_graph_compute_shortest_path()` and eventually creation of
+ * the route path.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
-#if 0
-#include <assert.h>
-#include <unistd.h>
-#include <sys/time.h>
-#endif
#include "navit_nls.h"
#include "glib_slice.h"
#include "config.h"
@@ -60,6 +97,7 @@
#include "xmlconfig.h"
#include "map.h"
#include "mapset.h"
+#include "route_protected.h"
#include "route.h"
#include "track.h"
#include "transform.h"
@@ -73,96 +111,17 @@
#include "debug.h"
struct map_priv {
- struct route *route;
+ struct route *route;
};
int debug_route=0;
-/**
- * @brief A point in the route graph
- *
- * This represents a point in the route graph. A point usually connects two or more segments,
- * but there are also points which don't do that (e.g. at the end of a dead-end).
- */
-struct route_graph_point {
- struct route_graph_point *hash_next; /**< Pointer to a chained hashlist of all route_graph_points with this hash */
- struct route_graph_segment *start; /**< Pointer to a list of segments of which this point is the start. The links
- * of this linked-list are in route_graph_segment->start_next.*/
- struct route_graph_segment *end; /**< Pointer to a list of segments of which this pointer is the end. The links
- * of this linked-list are in route_graph_segment->end_next. */
- struct route_graph_segment *seg; /**< Pointer to the segment one should use to reach the destination at
- * least costs */
- struct fibheap_el *el; /**< When this point is put on a Fibonacci heap, this is a pointer
- * to this point's heap-element */
- int value; /**< The cost at which one can reach the destination from this point on.
- * {@code INT_MAX} indicates that the destination is unreachable from this
- * point, or that this point has not yet been examined. */
- struct coord c; /**< Coordinates of this point */
- int flags; /**< Flags for this point (eg traffic distortion) */
-};
-
-#define RP_TRAFFIC_DISTORTION 1
-#define RP_TURN_RESTRICTION 2
-#define RP_TURN_RESTRICTION_RESOLVED 4
-
-/**
- * @brief A segment in the route graph or path
- *
- * This is a segment in the route graph or path. A segment represents a driveable way.
- */
-
-struct route_segment_data {
- struct item item; /**< The item (e.g. street) that this segment represents. */
- int flags;
- int len; /**< Length of this segment, in meters */
- /*NOTE: After a segment, various fields may follow, depending on what flags are set. Order of fields:
- 1.) maxspeed Maximum allowed speed on this segment. Present if AF_SPEED_LIMIT is set.
- 2.) offset If the item is segmented (i.e. represented by more than one segment), this
- indicates the position of this segment in the item. Present if AF_SEGMENTED is set.
- */
-};
-
-
-struct size_weight_limit {
- int width;
- int length;
- int height;
- int weight;
- int axle_weight;
-};
#define RSD_OFFSET(x) *((int *)route_segment_data_field_pos((x), attr_offset))
-#define RSD_MAXSPEED(x) *((int *)route_segment_data_field_pos((x), attr_maxspeed))
#define RSD_SIZE_WEIGHT(x) *((struct size_weight_limit *)route_segment_data_field_pos((x), attr_vehicle_width))
#define RSD_DANGEROUS_GOODS(x) *((int *)route_segment_data_field_pos((x), attr_vehicle_dangerous_goods))
-struct route_graph_segment_data {
- struct item *item;
- int offset;
- int flags;
- int len;
- int maxspeed;
- struct size_weight_limit size_weight;
- int dangerous_goods;
-};
-
-/**
- * @brief A segment in the route graph
- *
- * This is a segment in the route graph. A segment represents a driveable way.
- */
-struct route_graph_segment {
- struct route_graph_segment *next; /**< Linked-list pointer to a list of all route_graph_segments */
- struct route_graph_segment *start_next; /**< Pointer to the next element in the list of segments that start at the
- * same point. Start of this list is in route_graph_point->start. */
- struct route_graph_segment *end_next; /**< Pointer to the next element in the list of segments that end at the
- * same point. Start of this list is in route_graph_point->end. */
- struct route_graph_point *start; /**< Pointer to the point this segment starts at. */
- struct route_graph_point *end; /**< Pointer to the point this segment ends at. */
- struct route_segment_data data; /**< The segment data */
-};
-
/**
* @brief A traffic distortion
*
@@ -174,10 +133,10 @@ struct route_graph_segment {
* at the same time, they are cumulative.
*/
struct route_traffic_distortion {
- int maxspeed; /**< Maximum speed possible in km/h. Use {@code INT_MAX} to
+ int maxspeed; /**< Maximum speed possible in km/h. Use {@code INT_MAX} to
leave the speed unchanged, or 0 to mark the segment as
impassable. */
- int delay; /**< Delay in tenths of seconds (0 for no delay) */
+ int delay; /**< Delay in tenths of seconds (0 for no delay) */
};
/**
@@ -186,14 +145,14 @@ struct route_traffic_distortion {
* This is a segment in the route path.
*/
struct route_path_segment {
- struct route_path_segment *next; /**< Pointer to the next segment in the path */
- struct route_segment_data *data; /**< The segment data */
- int direction; /**< Order in which the coordinates are ordered. >0 means "First
- * coordinate of the segment is the first coordinate of the item", <=0
+ struct route_path_segment *next; /**< Pointer to the next segment in the path */
+ struct route_segment_data *data; /**< The segment data */
+ int direction; /**< Order in which the coordinates are ordered. >0 means "First
+ * coordinate of the segment is the first coordinate of the item", <=0
* means reverse. */
- unsigned ncoords; /**< How many coordinates does this segment have? */
- struct coord c[0]; /**< Pointer to the ncoords coordinates of this segment */
- /* WARNING: There will be coordinates following here, so do not create new fields after c! */
+ unsigned ncoords; /**< How many coordinates does this segment have? */
+ struct coord c[0]; /**< Pointer to the ncoords coordinates of this segment */
+ /* WARNING: There will be coordinates following here, so do not create new fields after c! */
};
/**
@@ -202,16 +161,16 @@ struct route_path_segment {
* This struct usually represents a destination or position
*/
struct route_info {
- struct coord c; /**< The actual destination / position */
- struct coord lp; /**< The nearest point on a street to c */
- int pos; /**< The position of lp within the coords of the street */
- int lenpos; /**< Distance between lp and the end of the street */
- int lenneg; /**< Distance between lp and the start of the street */
- int lenextra; /**< Distance between lp and c */
- int percent; /**< ratio of lenneg to lenght of whole street in percent */
- struct street_data *street; /**< The street lp is on */
- int street_direction; /**< Direction of vehicle on street -1 = Negative direction, 1 = Positive direction, 0 = Unknown */
- int dir; /**< Direction to take when following the route -1 = Negative direction, 1 = Positive direction */
+ struct coord c; /**< The actual destination / position */
+ struct coord lp; /**< The nearest point on a street to c */
+ int pos; /**< The position of lp within the coords of the street */
+ int lenpos; /**< Distance between lp and the end of the street */
+ int lenneg; /**< Distance between lp and the start of the street */
+ int lenextra; /**< Distance between lp and c */
+ int percent; /**< ratio of lenneg to lenght of whole street in percent */
+ struct street_data *street; /**< The street lp is on */
+ int street_direction; /**< Direction of vehicle on street -1 = Negative direction, 1 = Positive direction, 0 = Unknown */
+ int dir; /**< Direction to take when following the route -1 = Negative direction, 1 = Positive direction */
};
/**
@@ -221,68 +180,46 @@ struct route_info {
* destination) to the next destination.
*/
struct route_path {
- int in_use; /**< The path is in use and can not be updated */
- int update_required; /**< The path needs to be updated after it is no longer in use */
- int updated; /**< The path has only been updated */
- int path_time; /**< Time to pass the path */
- int path_len; /**< Length of the path */
- struct route_path_segment *path; /**< The first segment in the path, i.e. the segment one should
+ int in_use; /**< The path is in use and can not be updated */
+ int update_required; /**< The path needs to be updated after it is no longer in use */
+ int updated; /**< The path has only been updated */
+ int path_time; /**< Time to pass the path */
+ int path_len; /**< Length of the path */
+ struct route_path_segment *path; /**< The first segment in the path, i.e. the segment one should
* drive in next */
- struct route_path_segment *path_last; /**< The last segment in the path */
- /* XXX: path_hash is not necessery now */
- struct item_hash *path_hash; /**< A hashtable of all the items represented by this route's segements */
- struct route_path *next; /**< Next route path in case of intermediate destinations */
+ struct route_path_segment *path_last; /**< The last segment in the path */
+ /* XXX: path_hash is not necessery now */
+ struct item_hash *path_hash; /**< A hashtable of all the items represented by this route's segements */
+ struct route_path *next; /**< Next route path in case of intermediate destinations */
};
/**
* @brief A complete route
- *
+ *
* This struct holds all information about a route.
*/
struct route {
- NAVIT_OBJECT
- struct mapset *ms; /**< The mapset this route is built upon */
- enum route_path_flags flags;
- struct route_info *pos; /**< Current position within this route */
- GList *destinations; /**< Destinations of the route */
- int reached_destinations_count; /**< Used as base to calculate waypoint numbers */
- struct route_info *current_dst; /**< Current destination */
-
- struct route_graph *graph; /**< Pointer to the route graph */
- struct route_path *path2; /**< Pointer to the route path */
- struct map *map;
- struct map *graph_map;
- struct callback * route_graph_done_cb ; /**< Callback when route graph is done */
- struct callback * route_graph_flood_done_cb ; /**< Callback when route graph flooding is done */
- struct callback_list *cbl2; /**< Callback list to call when route changes */
- int destination_distance; /**< Distance to the destination at which the destination is considered "reached" */
- struct vehicleprofile *vehicleprofile; /**< Routing preferences */
- int route_status; /**< Route Status */
- int link_path; /**< Link paths over multiple waypoints together */
- struct pcoord pc;
- struct vehicle *v;
-};
-
-/**
- * @brief A complete route graph
- *
- * The route graph holds all routable segments along with the connections between them and the cost of
- * each segment.
- */
-struct route_graph {
- int busy; /**< The graph is being built */
- struct map_selection *sel; /**< The rectangle selection for the graph */
- struct mapset_handle *h; /**< Handle to the mapset */
- struct map *m; /**< Pointer to the currently active map */
- struct map_rect *mr; /**< Pointer to the currently active map rectangle */
- struct vehicleprofile *vehicleprofile; /**< The vehicle profile */
- struct callback *idle_cb; /**< Idle callback to process the graph */
- struct callback *done_cb; /**< Callback when graph is done */
- struct event_idle *idle_ev; /**< The pointer to the idle event */
- struct route_graph_segment *route_segments; /**< Pointer to the first route_graph_segment in the linked list of all segments */
- struct route_graph_segment *avoid_seg;
-#define HASH_SIZE 8192
- struct route_graph_point *hash[HASH_SIZE]; /**< A hashtable containing all route_graph_points in this graph */
+ NAVIT_OBJECT
+ struct mapset *ms; /**< The mapset this route is built upon */
+ enum route_path_flags flags;
+ struct route_info *pos; /**< Current position within this route */
+ GList *destinations; /**< Destinations of the route */
+ int reached_destinations_count; /**< Used as base to calculate waypoint numbers */
+ struct route_info *current_dst; /**< Current destination */
+
+ struct route_graph *graph; /**< Pointer to the route graph */
+ struct route_path *path2; /**< Pointer to the route path */
+ struct map *map; /**< The map containing the route path */
+ struct map *graph_map; /**< The map containing the route graph */
+ struct callback * route_graph_done_cb ; /**< Callback when route graph is done */
+ struct callback * route_graph_flood_done_cb ; /**< Callback when route graph flooding is done */
+ struct callback_list *cbl2; /**< Callback list to call when route changes */
+ int destination_distance; /**< Distance to the destination at which the destination is considered "reached" */
+ struct vehicleprofile *vehicleprofile; /**< Routing preferences */
+ int route_status; /**< Route Status */
+ int link_path; /**< Link paths over multiple waypoints together */
+ struct pcoord pc;
+ struct vehicle *v;
};
#define HASHCOORD(c) ((((c)->x +(c)->y) * 2654435761UL) & (HASH_SIZE-1))
@@ -294,27 +231,36 @@ struct route_graph {
* route graph point. Use this with the rp_iterator_* functions.
*/
struct route_graph_point_iterator {
- struct route_graph_point *p; /**< The route graph point whose segments should be iterated */
- int end; /**< Indicates if we have finished iterating through the "start" segments */
- struct route_graph_segment *next; /**< The next segment to be returned */
+ struct route_graph_point *p; /**< The route graph point whose segments should be iterated */
+ int end; /**< Indicates if we have finished iterating through the "start" segments */
+ struct route_graph_segment *next; /**< The next segment to be returned */
};
struct attr_iter {
- union {
- GList *list;
- } u;
+ union {
+ GList *list;
+ } u;
};
-static struct route_info * route_find_nearest_street(struct vehicleprofile *vehicleprofile, struct mapset *ms, struct pcoord *c);
-static struct route_graph_point *route_graph_get_point(struct route_graph *this, struct coord *c);
+static struct route_info * route_find_nearest_street(struct vehicleprofile *vehicleprofile, struct mapset *ms,
+ struct pcoord *c);
static void route_graph_update(struct route *this, struct callback *cb, int async);
-static void route_graph_build_done(struct route_graph *rg, int cancel);
-static struct route_path *route_path_new(struct route_graph *this, struct route_path *oldpath, struct route_info *pos, struct route_info *dst, struct vehicleprofile *profile);
-static void route_process_street_graph(struct route_graph *this, struct item *item, struct vehicleprofile *profile);
+static struct route_path *route_path_new(struct route_graph *this, struct route_path *oldpath, struct route_info *pos,
+ struct route_info *dst, struct vehicleprofile *profile);
+static void route_graph_add_street(struct route_graph *this, struct item *item, struct vehicleprofile *profile);
static void route_graph_destroy(struct route_graph *this);
static void route_path_update(struct route *this, int cancel, int async);
-static int route_time_seg(struct vehicleprofile *profile, struct route_segment_data *over, struct route_traffic_distortion *dist);
-static void route_graph_flood(struct route_graph *this, struct route_info *dst, struct vehicleprofile *profile, struct callback *cb);
+static int route_time_seg(struct vehicleprofile *profile, struct route_segment_data *over,
+ struct route_traffic_distortion *dist);
+static void route_graph_compute_shortest_path(struct route_graph * graph, struct vehicleprofile * profile,
+ struct callback *cb);
+static int route_graph_is_path_computed(struct route_graph *this_);
+static struct route_graph_segment *route_graph_get_segment(struct route_graph *graph, struct street_data *sd,
+ struct route_graph_segment *last);
+static int route_value_seg(struct vehicleprofile *profile, struct route_graph_point *from,
+ struct route_graph_segment *over,
+ int dir);
+static void route_graph_init(struct route_graph *this, struct route_info *dst, struct vehicleprofile *profile);
static void route_graph_reset(struct route_graph *this);
@@ -324,20 +270,19 @@ static void route_graph_reset(struct route_graph *this);
* @param route The route to return the projection for
* @return The projection used for this route
*/
-static enum projection route_projection(struct route *route)
-{
- struct street_data *street;
- struct route_info *dst=route_get_dst(route);
- if (!route->pos && !dst)
- return projection_none;
- street = route->pos ? route->pos->street : dst->street;
- if (!street || !street->item.map)
- return projection_none;
- return map_projection(street->item.map);
+static enum projection route_projection(struct route *route) {
+ struct street_data *street;
+ struct route_info *dst=route_get_dst(route);
+ if (!route->pos && !dst)
+ return projection_none;
+ street = route->pos ? route->pos->street : dst->street;
+ if (!street || !street->item.map)
+ return projection_none;
+ return map_projection(street->item.map);
}
/**
- * @brief Creates a new graph point iterator
+ * @brief Creates a new graph point iterator
*
* This function creates a new route graph point iterator, that can be used to
* iterate through all segments connected to the point.
@@ -345,21 +290,19 @@ static enum projection route_projection(struct route *route)
* @param p The route graph point to create the iterator from
* @return A new iterator.
*/
-static struct route_graph_point_iterator
-rp_iterator_new(struct route_graph_point *p)
-{
- struct route_graph_point_iterator it;
-
- it.p = p;
- if (p->start) {
- it.next = p->start;
- it.end = 0;
- } else {
- it.next = p->end;
- it.end = 1;
- }
-
- return it;
+static struct route_graph_point_iterator rp_iterator_new(struct route_graph_point *p) {
+ struct route_graph_point_iterator it;
+
+ it.p = p;
+ if (p->start) {
+ it.next = p->start;
+ it.end = 0;
+ } else {
+ it.next = p->end;
+ it.end = 1;
+ }
+
+ return it;
}
/**
@@ -369,27 +312,26 @@ rp_iterator_new(struct route_graph_point *p)
* @return The next segment or NULL if there are no more segments
*/
static struct route_graph_segment
-*rp_iterator_next(struct route_graph_point_iterator *it)
-{
- struct route_graph_segment *ret;
-
- ret = it->next;
- if (!ret) {
- return NULL;
- }
-
- if (!it->end) {
- if (ret->start_next) {
- it->next = ret->start_next;
- } else {
- it->next = it->p->end;
- it->end = 1;
- }
- } else {
- it->next = ret->end_next;
- }
-
- return ret;
+*rp_iterator_next(struct route_graph_point_iterator *it) {
+ struct route_graph_segment *ret;
+
+ ret = it->next;
+ if (!ret) {
+ return NULL;
+ }
+
+ if (!it->end) {
+ if (ret->start_next) {
+ it->next = ret->start_next;
+ } else {
+ it->next = it->p->end;
+ it->end = 1;
+ }
+ } else {
+ it->next = ret->end_next;
+ }
+
+ return ret;
}
/**
@@ -398,43 +340,38 @@ static struct route_graph_segment
* @param it The route graph point iterator to be checked
* @return 1 if the last segment returned comes from the end of the route graph point, 0 otherwise
*/
-static int
-rp_iterator_end(struct route_graph_point_iterator *it) {
- if (it->end && (it->next != it->p->end)) {
- return 1;
- } else {
- return 0;
- }
-}
-
-static void
-route_path_get_distances(struct route_path *path, struct coord *c, int count, int *distances)
-{
- int i;
- for (i = 0 ; i < count ; i++)
- distances[i]=INT_MAX;
- while (path) {
- struct route_path_segment *seg=path->path;
- while (seg) {
- for (i = 0 ; i < count ; i++) {
- int dist=transform_distance_polyline_sq(seg->c, seg->ncoords, &c[i], NULL, NULL);
- if (dist < distances[i])
- distances[i]=dist;
- }
- seg=seg->next;
- }
- path=path->next;
- }
- for (i = 0 ; i < count ; i++) {
- if (distances[i] != INT_MAX)
- distances[i]=sqrt(distances[i]);
- }
-}
-
-void
-route_get_distances(struct route *this, struct coord *c, int count, int *distances)
-{
- return route_path_get_distances(this->path2, c, count, distances);
+static int rp_iterator_end(struct route_graph_point_iterator *it) {
+ if (it->end && (it->next != it->p->end)) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+static void route_path_get_distances(struct route_path *path, struct coord *c, int count, int *distances) {
+ int i;
+ for (i = 0 ; i < count ; i++)
+ distances[i]=INT_MAX;
+ while (path) {
+ struct route_path_segment *seg=path->path;
+ while (seg) {
+ for (i = 0 ; i < count ; i++) {
+ int dist=transform_distance_polyline_sq(seg->c, seg->ncoords, &c[i], NULL, NULL);
+ if (dist < distances[i])
+ distances[i]=dist;
+ }
+ seg=seg->next;
+ }
+ path=path->next;
+ }
+ for (i = 0 ; i < count ; i++) {
+ if (distances[i] != INT_MAX)
+ distances[i]=sqrt(distances[i]);
+ }
+}
+
+void route_get_distances(struct route *this, struct coord *c, int count, int *distances) {
+ return route_path_get_distances(this->path2, c, count, distances);
}
/**
@@ -442,30 +379,28 @@ route_get_distances(struct route *this, struct coord *c, int count, int *distanc
*
* @param this The route_path to be destroyed
*/
-static void
-route_path_destroy(struct route_path *this, int recurse)
-{
- struct route_path_segment *c,*n;
- struct route_path *next;
- while (this) {
- next=this->next;
- if (this->path_hash) {
- item_hash_destroy(this->path_hash);
- this->path_hash=NULL;
- }
- c=this->path;
- while (c) {
- n=c->next;
- g_free(c);
- c=n;
- }
- this->in_use--;
- if (!this->in_use)
- g_free(this);
- if (!recurse)
- break;
- this=next;
- }
+static void route_path_destroy(struct route_path *this, int recurse) {
+ struct route_path_segment *c,*n;
+ struct route_path *next;
+ while (this) {
+ next=this->next;
+ if (this->path_hash) {
+ item_hash_destroy(this->path_hash);
+ this->path_hash=NULL;
+ }
+ c=this->path;
+ while (c) {
+ n=c->next;
+ g_free(c);
+ c=n;
+ }
+ this->in_use--;
+ if (!this->in_use)
+ g_free(this);
+ if (!recurse)
+ break;
+ this=next;
+ }
}
/**
@@ -475,22 +410,21 @@ route_path_destroy(struct route_path *this, int recurse)
* @return The newly created route
*/
struct route *
-route_new(struct attr *parent, struct attr **attrs)
-{
- struct route *this=g_new0(struct route, 1);
- struct attr dest_attr;
+route_new(struct attr *parent, struct attr **attrs) {
+ struct route *this=g_new0(struct route, 1);
+ struct attr dest_attr;
- this->func=&route_func;
- navit_object_ref((struct navit_object *)this);
+ this->func=&route_func;
+ navit_object_ref((struct navit_object *)this);
- if (attr_generic_get_attr(attrs, NULL, attr_destination_distance, &dest_attr, NULL)) {
- this->destination_distance = dest_attr.u.num;
- } else {
- this->destination_distance = 50; // Default value
- }
- this->cbl2=callback_list_new();
+ if (attr_generic_get_attr(attrs, NULL, attr_destination_distance, &dest_attr, NULL)) {
+ this->destination_distance = dest_attr.u.num;
+ } else {
+ this->destination_distance = 50; // Default value
+ }
+ this->cbl2=callback_list_new();
- return this;
+ return this;
}
/**
@@ -500,18 +434,17 @@ route_new(struct attr *parent, struct attr **attrs)
*/
struct route *
-route_dup(struct route *orig)
-{
- struct route *this=g_new0(struct route, 1);
- this->func=&route_func;
- navit_object_ref((struct navit_object *)this);
- this->cbl2=callback_list_new();
- this->destination_distance=orig->destination_distance;
- this->ms=orig->ms;
- this->flags=orig->flags;
- this->vehicleprofile=orig->vehicleprofile;
-
- return this;
+route_dup(struct route *orig) {
+ struct route *this=g_new0(struct route, 1);
+ this->func=&route_func;
+ navit_object_ref((struct navit_object *)this);
+ this->cbl2=callback_list_new();
+ this->destination_distance=orig->destination_distance;
+ this->ms=orig->ms;
+ this->flags=orig->flags;
+ this->vehicleprofile=orig->vehicleprofile;
+
+ return this;
}
/**
@@ -525,68 +458,67 @@ route_dup(struct route *orig)
* @param origin Used internally, set to NULL
* @return 1 If a roundabout was detected, 0 otherwise
*/
-static int
-route_check_roundabout(struct route_graph_segment *seg, int level, int direction, struct route_graph_segment *origin)
-{
- struct route_graph_point_iterator it,it2;
- struct route_graph_segment *cur;
- int count=0;
-
- if (!level) {
- return 0;
- }
- if (!direction && !(seg->data.flags & AF_ONEWAY)) {
- return 0;
- }
- if (direction && !(seg->data.flags & AF_ONEWAYREV)) {
- return 0;
- }
- if (seg->data.flags & AF_ROUNDABOUT_VALID)
- return 0;
-
- if (!origin) {
- origin = seg;
- }
-
- if (!direction) {
- it = rp_iterator_new(seg->end);
- } else {
- it = rp_iterator_new(seg->start);
- }
- it2=it;
-
- while ((cur = rp_iterator_next(&it2)))
- count++;
-
- if (count > 3)
- return 0;
- cur = rp_iterator_next(&it);
- while (cur) {
- if (cur == seg) {
- cur = rp_iterator_next(&it);
- continue;
- }
-
- if (cur->data.item.type != origin->data.item.type) {
- // This street is of another type, can't be part of the roundabout
- cur = rp_iterator_next(&it);
- continue;
- }
-
- if (cur == origin) {
- seg->data.flags |= AF_ROUNDABOUT;
- return 1;
- }
-
- if (route_check_roundabout(cur, (level-1), rp_iterator_end(&it), origin)) {
- seg->data.flags |= AF_ROUNDABOUT;
- return 1;
- }
-
- cur = rp_iterator_next(&it);
- }
-
- return 0;
+static int route_check_roundabout(struct route_graph_segment *seg, int level, int direction,
+ struct route_graph_segment *origin) {
+ struct route_graph_point_iterator it,it2;
+ struct route_graph_segment *cur;
+ int count=0;
+
+ if (!level) {
+ return 0;
+ }
+ if (!direction && !(seg->data.flags & AF_ONEWAY)) {
+ return 0;
+ }
+ if (direction && !(seg->data.flags & AF_ONEWAYREV)) {
+ return 0;
+ }
+ if (seg->data.flags & AF_ROUNDABOUT_VALID)
+ return 0;
+
+ if (!origin) {
+ origin = seg;
+ }
+
+ if (!direction) {
+ it = rp_iterator_new(seg->end);
+ } else {
+ it = rp_iterator_new(seg->start);
+ }
+ it2=it;
+
+ while ((cur = rp_iterator_next(&it2)))
+ count++;
+
+ if (count > 3)
+ return 0;
+ cur = rp_iterator_next(&it);
+ while (cur) {
+ if (cur == seg) {
+ cur = rp_iterator_next(&it);
+ continue;
+ }
+
+ if (cur->data.item.type != origin->data.item.type) {
+ // This street is of another type, can't be part of the roundabout
+ cur = rp_iterator_next(&it);
+ continue;
+ }
+
+ if (cur == origin) {
+ seg->data.flags |= AF_ROUNDABOUT;
+ return 1;
+ }
+
+ if (route_check_roundabout(cur, (level-1), rp_iterator_end(&it), origin)) {
+ seg->data.flags |= AF_ROUNDABOUT;
+ return 1;
+ }
+
+ cur = rp_iterator_next(&it);
+ }
+
+ return 0;
}
/**
@@ -595,10 +527,8 @@ route_check_roundabout(struct route_graph_segment *seg, int level, int direction
* @param this The route to set the mapset for
* @param ms The mapset to set for this route
*/
-void
-route_set_mapset(struct route *this, struct mapset *ms)
-{
- this->ms=ms;
+void route_set_mapset(struct route *this, struct mapset *ms) {
+ this->ms=ms;
}
/**
@@ -608,17 +538,15 @@ route_set_mapset(struct route *this, struct mapset *ms)
* @param prof The vehicle profile
*/
-void
-route_set_profile(struct route *this, struct vehicleprofile *prof)
-{
- if (this->vehicleprofile != prof) {
- int dest_count = g_list_length(this->destinations);
- struct pcoord *pc;
- this->vehicleprofile = prof;
- pc = g_alloca(dest_count*sizeof(struct pcoord));
- route_get_destinations(this, pc, dest_count);
- route_set_destinations(this, pc, dest_count, 1);
- }
+void route_set_profile(struct route *this, struct vehicleprofile *prof) {
+ if (this->vehicleprofile != prof) {
+ int dest_count = g_list_length(this->destinations);
+ struct pcoord *pc;
+ this->vehicleprofile = prof;
+ pc = g_alloca(dest_count*sizeof(struct pcoord));
+ route_get_destinations(this, pc, dest_count);
+ route_set_destinations(this, pc, dest_count, 1);
+ }
}
/**
@@ -628,9 +556,8 @@ route_set_profile(struct route *this, struct vehicleprofile *prof)
* @return The mapset of the route passed
*/
struct mapset *
-route_get_mapset(struct route *this)
-{
- return this->ms;
+route_get_mapset(struct route *this) {
+ return this->ms;
}
/**
@@ -640,9 +567,8 @@ route_get_mapset(struct route *this)
* @return The position within the route passed
*/
struct route_info *
-route_get_pos(struct route *this)
-{
- return this->pos;
+route_get_pos(struct route *this) {
+ return this->pos;
}
/**
@@ -652,13 +578,12 @@ route_get_pos(struct route *this)
* @return The destination of the route passed
*/
struct route_info *
-route_get_dst(struct route *this)
-{
- struct route_info *dst=NULL;
+route_get_dst(struct route *this) {
+ struct route_info *dst=NULL;
- if (this->destinations)
- dst=g_list_last(this->destinations)->data;
- return dst;
+ if (this->destinations)
+ dst=g_list_last(this->destinations)->data;
+ return dst;
}
/**
@@ -667,42 +592,36 @@ route_get_dst(struct route *this)
* @param this The route to check
* @return True if the path is calculated, false if not
*/
-int
-route_get_path_set(struct route *this)
-{
- return this->path2 != NULL;
+int route_get_path_set(struct route *this) {
+ return this->path2 != NULL;
}
/**
* @brief Checks if the route passed contains a certain item within the route path
*
* This function checks if a certain items exists in the path that navit will guide
- * the user to his destination. It does *not* check if this item exists in the route
+ * the user to his destination. It does *not* check if this item exists in the route
* graph!
*
* @param this The route to check for this item
* @param item The item to search for
* @return True if the item was found, false if the item was not found or the route was not calculated
*/
-int
-route_contains(struct route *this, struct item *item)
-{
- if (! this->path2 || !this->path2->path_hash)
- return 0;
- if (item_hash_lookup(this->path2->path_hash, item))
- return 1;
- if (! this->pos || !this->pos->street)
- return 0;
- return item_is_equal(this->pos->street->item, *item);
+int route_contains(struct route *this, struct item *item) {
+ if (! this->path2 || !this->path2->path_hash)
+ return 0;
+ if (item_hash_lookup(this->path2->path_hash, item))
+ return 1;
+ if (! this->pos || !this->pos->street)
+ return 0;
+ return item_is_equal(this->pos->street->item, *item);
}
-static struct route_info *
-route_next_destination(struct route *this)
-{
- if (!this->destinations)
- return NULL;
- return this->destinations->data;
+static struct route_info *route_next_destination(struct route *this) {
+ if (!this->destinations)
+ return NULL;
+ return this->destinations->data;
}
/**
@@ -711,46 +630,44 @@ route_next_destination(struct route *this)
* @param this The route to be checked
* @return True if the destination is "reached", false otherwise.
*/
-int
-route_destination_reached(struct route *this)
-{
- struct street_data *sd = NULL;
- enum projection pro;
- struct route_info *dst=route_next_destination(this);
-
- if (!this->pos)
- return 0;
- if (!dst)
- return 0;
-
- sd = this->pos->street;
-
- if (!this->path2) {
- return 0;
- }
-
- if (!item_is_equal(this->pos->street->item, dst->street->item)) {
- return 0;
- }
-
- if ((sd->flags & AF_ONEWAY) && (this->pos->lenneg >= dst->lenneg)) { // We would have to drive against the one-way road
- return 0;
- }
- if ((sd->flags & AF_ONEWAYREV) && (this->pos->lenpos >= dst->lenpos)) {
- return 0;
- }
- pro=route_projection(this);
- if (pro == projection_none)
- return 0;
-
- if (transform_distance(pro, &this->pos->c, &dst->lp) > this->destination_distance) {
- return 0;
- }
-
- if (g_list_next(this->destinations))
- return 1;
- else
- return 2;
+int route_destination_reached(struct route *this) {
+ struct street_data *sd = NULL;
+ enum projection pro;
+ struct route_info *dst=route_next_destination(this);
+
+ if (!this->pos)
+ return 0;
+ if (!dst)
+ return 0;
+
+ sd = this->pos->street;
+
+ if (!this->path2) {
+ return 0;
+ }
+
+ if (!item_is_equal(this->pos->street->item, dst->street->item)) {
+ return 0;
+ }
+
+ if ((sd->flags & AF_ONEWAY) && (this->pos->lenneg >= dst->lenneg)) { // We would have to drive against the one-way road
+ return 0;
+ }
+ if ((sd->flags & AF_ONEWAYREV) && (this->pos->lenpos >= dst->lenpos)) {
+ return 0;
+ }
+ pro=route_projection(this);
+ if (pro == projection_none)
+ return 0;
+
+ if (transform_distance(pro, &this->pos->c, &dst->lp) > this->destination_distance) {
+ return 0;
+ }
+
+ if (g_list_next(this->destinations))
+ return 1;
+ else
+ return 2;
}
/**
@@ -763,16 +680,14 @@ route_destination_reached(struct route *this)
* @param this The route object
* @return The previous destination or current position, see description
*/
-static struct route_info *
-route_previous_destination(struct route *this)
-{
- GList *l=g_list_find(this->destinations, this->current_dst);
- if (!l)
- return this->pos;
- l=g_list_previous(l);
- if (!l)
- return this->pos;
- return l->data;
+static struct route_info *route_previous_destination(struct route *this) {
+ GList *l=g_list_find(this->destinations, this->current_dst);
+ if (!l)
+ return this->pos;
+ l=g_list_previous(l);
+ if (!l)
+ return this->pos;
+ return l->data;
}
/**
@@ -788,63 +703,62 @@ route_previous_destination(struct route *this)
* @param new_graph FIXME Whether the route graph has been rebuilt from scratch
*/
/* FIXME Should we rename this function to route_graph_flood_done, in order to avoid confusion? */
-static void
-route_path_update_done(struct route *this, int new_graph)
-{
- struct route_path *oldpath=this->path2;
- struct attr route_status;
- struct route_info *prev_dst; /* previous destination or current position */
- route_status.type=attr_route_status;
- if (this->path2 && (this->path2->in_use>1)) {
- this->path2->update_required=1+new_graph;
- return;
- }
- route_status.u.num=route_status_building_path;
- route_set_attr(this, &route_status);
- prev_dst=route_previous_destination(this);
- if (this->link_path) {
- this->path2=route_path_new(this->graph, NULL, prev_dst, this->current_dst, this->vehicleprofile);
- if (this->path2)
- this->path2->next=oldpath;
- else
- route_path_destroy(oldpath,0);
- } else {
- this->path2=route_path_new(this->graph, oldpath, prev_dst, this->current_dst, this->vehicleprofile);
- if (oldpath && this->path2) {
- this->path2->next=oldpath->next;
- route_path_destroy(oldpath,0);
- }
- }
- if (this->path2) {
- struct route_path_segment *seg=this->path2->path;
- int path_time=0,path_len=0;
- while (seg) {
- /* FIXME */
- int seg_time=route_time_seg(this->vehicleprofile, seg->data, NULL);
- if (seg_time == INT_MAX) {
- dbg(lvl_debug,"error\n");
- } else
- path_time+=seg_time;
- path_len+=seg->data->len;
- seg=seg->next;
- }
- this->path2->path_time=path_time;
- this->path2->path_len=path_len;
- if (prev_dst != this->pos) {
- this->link_path=1;
- this->current_dst=prev_dst;
- route_graph_reset(this->graph);
- route_graph_flood(this->graph, this->current_dst, this->vehicleprofile, this->route_graph_flood_done_cb);
- return;
- }
- if (!new_graph && this->path2->updated)
- route_status.u.num=route_status_path_done_incremental;
- else
- route_status.u.num=route_status_path_done_new;
- } else
- route_status.u.num=route_status_not_found;
- this->link_path=0;
- route_set_attr(this, &route_status);
+static void route_path_update_done(struct route *this, int new_graph) {
+ struct route_path *oldpath=this->path2;
+ struct attr route_status;
+ struct route_info *prev_dst; /* previous destination or current position */
+ route_status.type=attr_route_status;
+ if (this->path2 && (this->path2->in_use>1)) {
+ this->path2->update_required=1+new_graph;
+ return;
+ }
+ route_status.u.num=route_status_building_path;
+ route_set_attr(this, &route_status);
+ prev_dst=route_previous_destination(this);
+ if (this->link_path) {
+ this->path2=route_path_new(this->graph, NULL, prev_dst, this->current_dst, this->vehicleprofile);
+ if (this->path2)
+ this->path2->next=oldpath;
+ else
+ route_path_destroy(oldpath,0);
+ } else {
+ this->path2=route_path_new(this->graph, oldpath, prev_dst, this->current_dst, this->vehicleprofile);
+ if (oldpath && this->path2) {
+ this->path2->next=oldpath->next;
+ route_path_destroy(oldpath,0);
+ }
+ }
+ if (this->path2) {
+ struct route_path_segment *seg=this->path2->path;
+ int path_time=0,path_len=0;
+ while (seg) {
+ /* FIXME */
+ int seg_time=route_time_seg(this->vehicleprofile, seg->data, NULL);
+ if (seg_time == INT_MAX) {
+ dbg(lvl_debug,"error");
+ } else
+ path_time+=seg_time;
+ path_len+=seg->data->len;
+ seg=seg->next;
+ }
+ this->path2->path_time=path_time;
+ this->path2->path_len=path_len;
+ if (prev_dst != this->pos) {
+ this->link_path=1;
+ this->current_dst=prev_dst;
+ route_graph_reset(this->graph);
+ route_graph_init(this->graph, this->current_dst, this->vehicleprofile);
+ route_graph_compute_shortest_path(this->graph, this->vehicleprofile, this->route_graph_flood_done_cb);
+ return;
+ }
+ if (!new_graph && this->path2->updated)
+ route_status.u.num=route_status_path_done_incremental;
+ else
+ route_status.u.num=route_status_path_done_new;
+ } else
+ route_status.u.num=route_status_not_found;
+ this->link_path=0;
+ route_set_attr(this, &route_status);
}
/**
@@ -859,50 +773,48 @@ route_path_update_done(struct route *this, int new_graph)
* <li>{@code route_path_flag_async}: Perform operations asynchronously</li>
* <li>{@code route_path_flag_no_rebuild}: Do not rebuild the route graph</li>
* </ul>
- *
+ *
* These flags will be stored in the {@code flags} member of the route object.
*
- * @attention For this to work the route graph has to be destroyed if the route's
+ * @attention For this to work the route graph has to be destroyed if the route's
* @attention destination is changed somewhere!
*
* @param this The route to update
* @param flags Flags to control the behavior of this function, see description
*/
-static void
-route_path_update_flags(struct route *this, enum route_path_flags flags)
-{
- dbg(lvl_debug,"enter %d\n", flags);
- this->flags = flags;
- if (! this->pos || ! this->destinations) {
- dbg(lvl_debug,"destroy\n");
- route_path_destroy(this->path2,1);
- this->path2 = NULL;
- return;
- }
- if (flags & route_path_flag_cancel) {
- route_graph_destroy(this->graph);
- this->graph=NULL;
- }
- /* the graph is destroyed when setting the destination */
- if (this->graph) {
- if (this->graph->busy) {
- dbg(lvl_debug,"busy building graph\n");
- return;
- }
- // we can try to update
- dbg(lvl_debug,"try update\n");
- route_path_update_done(this, 0);
- } else {
- route_path_destroy(this->path2,1);
- this->path2 = NULL;
- }
- if (!this->graph || (!this->path2 && !(flags & route_path_flag_no_rebuild))) {
- dbg(lvl_debug,"rebuild graph %p %p\n",this->graph,this->path2);
- if (! this->route_graph_flood_done_cb)
- this->route_graph_flood_done_cb=callback_new_2(callback_cast(route_path_update_done), this, (long)1);
- dbg(lvl_debug,"route_graph_update\n");
- route_graph_update(this, this->route_graph_flood_done_cb, !!(flags & route_path_flag_async));
- }
+static void route_path_update_flags(struct route *this, enum route_path_flags flags) {
+ dbg(lvl_debug,"enter %d", flags);
+ this->flags = flags;
+ if (! this->pos || ! this->destinations) {
+ dbg(lvl_debug,"destroy");
+ route_path_destroy(this->path2,1);
+ this->path2 = NULL;
+ return;
+ }
+ if (flags & route_path_flag_cancel) {
+ route_graph_destroy(this->graph);
+ this->graph=NULL;
+ }
+ /* the graph is destroyed when setting the destination */
+ if (this->graph) {
+ if (this->graph->busy) {
+ dbg(lvl_debug,"busy building graph");
+ return;
+ }
+ // we can try to update
+ dbg(lvl_debug,"try update");
+ route_path_update_done(this, 0);
+ } else {
+ route_path_destroy(this->path2,1);
+ this->path2 = NULL;
+ }
+ if (!this->graph || (!this->path2 && !(flags & route_path_flag_no_rebuild))) {
+ dbg(lvl_debug,"rebuild graph %p %p",this->graph,this->path2);
+ if (! this->route_graph_flood_done_cb)
+ this->route_graph_flood_done_cb=callback_new_2(callback_cast(route_path_update_done), this, (long)1);
+ dbg(lvl_debug,"route_graph_update");
+ route_graph_update(this, this->route_graph_flood_done_cb, !!(flags & route_path_flag_async));
+ }
}
/**
@@ -914,33 +826,29 @@ route_path_update_flags(struct route *this, enum route_path_flags flags)
* @param cancel If true, cancel navigation, clear route graph and route path
* @param async If true, perform processing asynchronously
*/
-static void
-route_path_update(struct route *this, int cancel, int async)
-{
- enum route_path_flags flags=(cancel ? route_path_flag_cancel:0)|(async ? route_path_flag_async:0);
- route_path_update_flags(this, flags);
+static void route_path_update(struct route *this, int cancel, int async) {
+ enum route_path_flags flags=(cancel ? route_path_flag_cancel:0)|(async ? route_path_flag_async:0);
+ route_path_update_flags(this, flags);
}
-/**
+/**
* @brief This will calculate all the distances stored in a route_info
*
* @param ri The route_info to calculate the distances for
* @param pro The projection used for this route
*/
-static void
-route_info_distances(struct route_info *ri, enum projection pro)
-{
- int npos=ri->pos+1;
- struct street_data *sd=ri->street;
- /* 0 1 2 X 3 4 5 6 pos=2 npos=3 count=7 0,1,2 3,4,5,6*/
- ri->lenextra=transform_distance(pro, &ri->lp, &ri->c);
- ri->lenneg=transform_polyline_length(pro, sd->c, npos)+transform_distance(pro, &sd->c[ri->pos], &ri->lp);
- ri->lenpos=transform_polyline_length(pro, sd->c+npos, sd->count-npos)+transform_distance(pro, &sd->c[npos], &ri->lp);
- if (ri->lenneg || ri->lenpos)
- ri->percent=(ri->lenneg*100)/(ri->lenneg+ri->lenpos);
- else
- ri->percent=50;
+static void route_info_distances(struct route_info *ri, enum projection pro) {
+ int npos=ri->pos+1;
+ struct street_data *sd=ri->street;
+ /* 0 1 2 X 3 4 5 6 pos=2 npos=3 count=7 0,1,2 3,4,5,6*/
+ ri->lenextra=transform_distance(pro, &ri->lp, &ri->c);
+ ri->lenneg=transform_polyline_length(pro, sd->c, npos)+transform_distance(pro, &sd->c[ri->pos], &ri->lp);
+ ri->lenpos=transform_polyline_length(pro, sd->c+npos, sd->count-npos)+transform_distance(pro, &sd->c[npos], &ri->lp);
+ if (ri->lenneg || ri->lenpos)
+ ri->percent=(ri->lenneg*100)/(ri->lenneg+ri->lenpos);
+ else
+ ri->percent=50;
}
/**
@@ -954,22 +862,20 @@ route_info_distances(struct route_info *ri, enum projection pro)
* @param flags Flags to use for building the graph
*/
-static int
-route_set_position_flags(struct route *this, struct pcoord *pos, enum route_path_flags flags)
-{
- if (this->pos)
- route_info_free(this->pos);
- this->pos=NULL;
- this->pos=route_find_nearest_street(this->vehicleprofile, this->ms, pos);
+static int route_set_position_flags(struct route *this, struct pcoord *pos, enum route_path_flags flags) {
+ if (this->pos)
+ route_info_free(this->pos);
+ this->pos=NULL;
+ this->pos=route_find_nearest_street(this->vehicleprofile, this->ms, pos);
- // If there is no nearest street, bail out.
- if (!this->pos) return 0;
+ // If there is no nearest street, bail out.
+ if (!this->pos) return 0;
- this->pos->street_direction=0;
- dbg(lvl_debug,"this->pos=%p\n", this->pos);
- route_info_distances(this->pos, pos->pro);
- route_path_update_flags(this, flags);
- return 1;
+ this->pos->street_direction=0;
+ dbg(lvl_debug,"this->pos=%p", this->pos);
+ route_info_distances(this->pos, pos->pro);
+ route_path_update_flags(this, flags);
+ return 1;
}
/**
@@ -981,10 +887,8 @@ route_set_position_flags(struct route *this, struct pcoord *pos, enum route_path
* @param this The route to set the position of
* @param pos Coordinates to set as position
*/
-void
-route_set_position(struct route *this, struct pcoord *pos)
-{
- route_set_position_flags(this, pos, route_path_flag_async);
+void route_set_position(struct route *this, struct pcoord *pos) {
+ route_set_position_flags(this, pos, route_path_flag_async);
}
/**
@@ -993,39 +897,41 @@ route_set_position(struct route *this, struct pcoord *pos)
* @param this The route to set the current position of
* @param tracking The tracking to get the coordinates from
*/
-void
-route_set_position_from_tracking(struct route *this, struct tracking *tracking, enum projection pro)
-{
- struct coord *c;
- struct route_info *ret;
- struct street_data *sd;
-
- dbg(lvl_info,"enter\n");
- c=tracking_get_pos(tracking);
- ret=g_new0(struct route_info, 1);
- if (!ret) {
- printf("%s:Out of memory\n", __FUNCTION__);
- return;
- }
- if (this->pos)
- route_info_free(this->pos);
- this->pos=NULL;
- ret->c=*c;
- ret->lp=*c;
- ret->pos=tracking_get_segment_pos(tracking);
- ret->street_direction=tracking_get_street_direction(tracking);
- sd=tracking_get_street_data(tracking);
- if (sd) {
- ret->street=street_data_dup(sd);
- route_info_distances(ret, pro);
- }
- dbg(lvl_debug,"position 0x%x,0x%x item 0x%x,0x%x direction %d pos %d lenpos %d lenneg %d\n",c->x,c->y,sd?sd->item.id_hi:0,sd?sd->item.id_lo:0,ret->street_direction,ret->pos,ret->lenpos,ret->lenneg);
- dbg(lvl_debug,"c->x=0x%x, c->y=0x%x pos=%d item=(0x%x,0x%x)\n", c->x, c->y, ret->pos, ret->street?ret->street->item.id_hi:0, ret->street?ret->street->item.id_lo:0);
- dbg(lvl_debug,"street 0=(0x%x,0x%x) %d=(0x%x,0x%x)\n", ret->street?ret->street->c[0].x:0, ret->street?ret->street->c[0].y:0, ret->street?ret->street->count-1:0, ret->street?ret->street->c[ret->street->count-1].x:0, ret->street?ret->street->c[ret->street->count-1].y:0);
- this->pos=ret;
- if (this->destinations)
- route_path_update(this, 0, 1);
- dbg(lvl_info,"ret\n");
+void route_set_position_from_tracking(struct route *this, struct tracking *tracking, enum projection pro) {
+ struct coord *c;
+ struct route_info *ret;
+ struct street_data *sd;
+
+ dbg(lvl_info,"enter");
+ c=tracking_get_pos(tracking);
+ ret=g_new0(struct route_info, 1);
+ if (!ret) {
+ printf("%s:Out of memory\n", __FUNCTION__);
+ return;
+ }
+ if (this->pos)
+ route_info_free(this->pos);
+ this->pos=NULL;
+ ret->c=*c;
+ ret->lp=*c;
+ ret->pos=tracking_get_segment_pos(tracking);
+ ret->street_direction=tracking_get_street_direction(tracking);
+ sd=tracking_get_street_data(tracking);
+ if (sd) {
+ ret->street=street_data_dup(sd);
+ route_info_distances(ret, pro);
+ }
+ dbg(lvl_debug,"position 0x%x,0x%x item 0x%x,0x%x direction %d pos %d lenpos %d lenneg %d",c->x,c->y,sd?sd->item.id_hi:0,
+ sd?sd->item.id_lo:0,ret->street_direction,ret->pos,ret->lenpos,ret->lenneg);
+ dbg(lvl_debug,"c->x=0x%x, c->y=0x%x pos=%d item=(0x%x,0x%x)", c->x, c->y, ret->pos,
+ ret->street?ret->street->item.id_hi:0, ret->street?ret->street->item.id_lo:0);
+ dbg(lvl_debug,"street 0=(0x%x,0x%x) %d=(0x%x,0x%x)", ret->street?ret->street->c[0].x:0,
+ ret->street?ret->street->c[0].y:0, ret->street?ret->street->count-1:0,
+ ret->street?ret->street->c[ret->street->count-1].x:0, ret->street?ret->street->c[ret->street->count-1].y:0);
+ this->pos=ret;
+ if (this->destinations)
+ route_path_update(this, 0, 1);
+ dbg(lvl_info,"ret");
}
/* Used for debuging of route_rect, what routing sees */
@@ -1035,106 +941,102 @@ struct map_selection *route_selection;
* @brief Returns a single map selection
*/
struct map_selection *
-route_rect(int order, struct coord *c1, struct coord *c2, int rel, int abs)
-{
- int dx,dy,sx=1,sy=1,d,m;
- struct map_selection *sel=g_new(struct map_selection, 1);
- if (!sel) {
- printf("%s:Out of memory\n", __FUNCTION__);
- return sel;
- }
- sel->order=order;
- sel->range.min=route_item_first;
- sel->range.max=route_item_last;
- dbg(lvl_debug,"%p %p\n", c1, c2);
- dx=c1->x-c2->x;
- dy=c1->y-c2->y;
- if (dx < 0) {
- sx=-1;
- sel->u.c_rect.lu.x=c1->x;
- sel->u.c_rect.rl.x=c2->x;
- } else {
- sel->u.c_rect.lu.x=c2->x;
- sel->u.c_rect.rl.x=c1->x;
- }
- if (dy < 0) {
- sy=-1;
- sel->u.c_rect.lu.y=c2->y;
- sel->u.c_rect.rl.y=c1->y;
- } else {
- sel->u.c_rect.lu.y=c1->y;
- sel->u.c_rect.rl.y=c2->y;
- }
- if (dx*sx > dy*sy)
- d=dx*sx;
- else
- d=dy*sy;
- m=d*rel/100+abs;
- sel->u.c_rect.lu.x-=m;
- sel->u.c_rect.rl.x+=m;
- sel->u.c_rect.lu.y+=m;
- sel->u.c_rect.rl.y-=m;
- sel->next=NULL;
- return sel;
+route_rect(int order, struct coord *c1, struct coord *c2, int rel, int abs) {
+ int dx,dy,sx=1,sy=1,d,m;
+ struct map_selection *sel=g_new(struct map_selection, 1);
+ if (!sel) {
+ printf("%s:Out of memory\n", __FUNCTION__);
+ return sel;
+ }
+ sel->order=order;
+ sel->range.min=route_item_first;
+ sel->range.max=route_item_last;
+ dbg(lvl_debug,"%p %p", c1, c2);
+ dx=c1->x-c2->x;
+ dy=c1->y-c2->y;
+ if (dx < 0) {
+ sx=-1;
+ sel->u.c_rect.lu.x=c1->x;
+ sel->u.c_rect.rl.x=c2->x;
+ } else {
+ sel->u.c_rect.lu.x=c2->x;
+ sel->u.c_rect.rl.x=c1->x;
+ }
+ if (dy < 0) {
+ sy=-1;
+ sel->u.c_rect.lu.y=c2->y;
+ sel->u.c_rect.rl.y=c1->y;
+ } else {
+ sel->u.c_rect.lu.y=c1->y;
+ sel->u.c_rect.rl.y=c2->y;
+ }
+ if (dx*sx > dy*sy)
+ d=dx*sx;
+ else
+ d=dy*sy;
+ m=d*rel/100+abs;
+ sel->u.c_rect.lu.x-=m;
+ sel->u.c_rect.rl.x+=m;
+ sel->u.c_rect.lu.y+=m;
+ sel->u.c_rect.rl.y-=m;
+ sel->next=NULL;
+ return sel;
}
/**
* @brief Appends a map selection to the selection list. Selection list may be NULL.
*/
-static struct map_selection *
-route_rect_add(struct map_selection *sel, int order, struct coord *c1, struct coord *c2, int rel, int abs)
-{
- struct map_selection *ret;
- ret=route_rect(order, c1, c2, rel, abs);
- ret->next=sel;
- return ret;
+static struct map_selection *route_rect_add(struct map_selection *sel, int order, struct coord *c1, struct coord *c2,
+ int rel, int abs) {
+ struct map_selection *ret;
+ ret=route_rect(order, c1, c2, rel, abs);
+ ret->next=sel;
+ return ret;
}
/**
* @brief Returns a list of map selections useable to create a route graph
*
* Returns a list of map selections useable to get a map rect from which items can be
- * retrieved to build a route graph.
+ * retrieved to build a route graph.
*
* @param c Array containing route points, including start, intermediate and destination ones.
- * @param count number of route points
- * @param proifle vehicleprofile
+ * @param count number of route points
+ * @param proifle vehicleprofile
*/
-static struct map_selection *
-route_calc_selection(struct coord *c, int count, struct vehicleprofile *profile)
-{
- struct map_selection *ret=NULL;
- int i;
- struct coord_rect r;
- char *depth, *str, *tok;
-
- if (!count)
- return NULL;
- r.lu=c[0];
- r.rl=c[0];
- for (i = 1 ; i < count ; i++)
- coord_rect_extend(&r, &c[i]);
-
- depth=profile->route_depth;
- if (!depth)
- depth="4:25%,8:40000,18:10000";
- depth=str=g_strdup(depth);
-
- while((tok=strtok(str,","))!=NULL) {
- int order=0, dist=0;
- sscanf(tok,"%d:%d",&order,&dist);
- if(strchr(tok,'%'))
- ret=route_rect_add(ret, order, &r.lu, &r.rl, dist, 0);
- else
- for (i = 0 ; i < count ; i++) {
- ret=route_rect_add(ret, order, &c[i], &c[i], 0, dist);
- }
- str=NULL;
- }
-
- g_free(depth);
-
- return ret;
+static struct map_selection *route_calc_selection(struct coord *c, int count, struct vehicleprofile *profile) {
+ struct map_selection *ret=NULL;
+ int i;
+ struct coord_rect r;
+ char *depth, *str, *tok;
+
+ if (!count)
+ return NULL;
+ r.lu=c[0];
+ r.rl=c[0];
+ for (i = 1 ; i < count ; i++)
+ coord_rect_extend(&r, &c[i]);
+
+ depth=profile->route_depth;
+ if (!depth)
+ depth="4:25%,8:40000,18:10000";
+ depth=str=g_strdup(depth);
+
+ while((tok=strtok(str,","))!=NULL) {
+ int order=0, dist=0;
+ sscanf(tok,"%d:%d",&order,&dist);
+ if(strchr(tok,'%'))
+ ret=route_rect_add(ret, order, &r.lu, &r.rl, dist, 0);
+ else
+ for (i = 0 ; i < count ; i++) {
+ ret=route_rect_add(ret, order, &c[i], &c[i], 0, dist);
+ }
+ str=NULL;
+ }
+
+ g_free(depth);
+
+ return ret;
}
/**
@@ -1142,24 +1044,20 @@ route_calc_selection(struct coord *c, int count, struct vehicleprofile *profile)
*
* @param sel Start of the list to be destroyed
*/
-static void
-route_free_selection(struct map_selection *sel)
-{
- struct map_selection *next;
- while (sel) {
- next=sel->next;
- g_free(sel);
- sel=next;
- }
+static void route_free_selection(struct map_selection *sel) {
+ struct map_selection *next;
+ while (sel) {
+ next=sel->next;
+ g_free(sel);
+ sel=next;
+ }
}
-static void
-route_clear_destinations(struct route *this_)
-{
- g_list_foreach(this_->destinations, (GFunc)route_info_free, NULL);
- g_list_free(this_->destinations);
- this_->destinations=NULL;
+static void route_clear_destinations(struct route *this_) {
+ g_list_foreach(this_->destinations, (GFunc)route_info_free, NULL);
+ g_list_free(this_->destinations);
+ this_->destinations=NULL;
}
/**
@@ -1175,56 +1073,52 @@ route_clear_destinations(struct route *this_)
* @param async If set, do routing asynchronously
*/
-void
-route_set_destinations(struct route *this, struct pcoord *dst, int count, int async)
-{
- struct attr route_status;
- struct route_info *dsti;
- int i;
- route_status.type=attr_route_status;
-
- profile(0,NULL);
- route_clear_destinations(this);
- if (dst && count) {
- for (i = 0 ; i < count ; i++) {
- dsti=route_find_nearest_street(this->vehicleprofile, this->ms, &dst[i]);
- if(dsti) {
- route_info_distances(dsti, dst->pro);
- this->destinations=g_list_append(this->destinations, dsti);
- }
- }
- route_status.u.num=route_status_destination_set;
- } else {
- this->reached_destinations_count=0;
- route_status.u.num=route_status_no_destination;
- }
- callback_list_call_attr_1(this->cbl2, attr_destination, this);
- route_set_attr(this, &route_status);
- profile(1,"find_nearest_street");
-
- /* The graph has to be destroyed and set to NULL, otherwise route_path_update() doesn't work */
- route_graph_destroy(this->graph);
- this->graph=NULL;
- this->current_dst=route_get_dst(this);
- route_path_update(this, 1, async);
- profile(0,"end");
-}
-
-int
-route_get_destinations(struct route *this, struct pcoord *pc, int count)
-{
- int ret=0;
- GList *l=this->destinations;
- while (l && ret < count) {
- struct route_info *dst=l->data;
- pc->x=dst->c.x;
- pc->y=dst->c.y;
- pc->pro=projection_mg; /* FIXME */
- pc++;
- ret++;
- l=g_list_next(l);
- }
- return ret;
+void route_set_destinations(struct route *this, struct pcoord *dst, int count, int async) {
+ struct attr route_status;
+ struct route_info *dsti;
+ int i;
+ route_status.type=attr_route_status;
+
+ profile(0,NULL);
+ route_clear_destinations(this);
+ if (dst && count) {
+ for (i = 0 ; i < count ; i++) {
+ dsti=route_find_nearest_street(this->vehicleprofile, this->ms, &dst[i]);
+ if(dsti) {
+ route_info_distances(dsti, dst->pro);
+ this->destinations=g_list_append(this->destinations, dsti);
+ }
+ }
+ route_status.u.num=route_status_destination_set;
+ } else {
+ this->reached_destinations_count=0;
+ route_status.u.num=route_status_no_destination;
+ }
+ callback_list_call_attr_1(this->cbl2, attr_destination, this);
+ route_set_attr(this, &route_status);
+ profile(1,"find_nearest_street");
+
+ /* The graph has to be destroyed and set to NULL, otherwise route_path_update() doesn't work */
+ route_graph_destroy(this->graph);
+ this->graph=NULL;
+ this->current_dst=route_get_dst(this);
+ route_path_update(this, 1, async);
+ profile(0,"end");
+}
+
+int route_get_destinations(struct route *this, struct pcoord *pc, int count) {
+ int ret=0;
+ GList *l=this->destinations;
+ while (l && ret < count) {
+ struct route_info *dst=l->data;
+ pc->x=dst->c.x;
+ pc->y=dst->c.y;
+ pc->pro=projection_mg; /* FIXME */
+ pc++;
+ ret++;
+ l=g_list_next(l);
+ }
+ return ret;
}
/**
@@ -1233,10 +1127,8 @@ route_get_destinations(struct route *this, struct pcoord *pc, int count)
* @param this The route instance
* @return destination count for the route
*/
-int
-route_get_destination_count(struct route *this)
-{
- return g_list_length(this->destinations);
+int route_get_destination_count(struct route *this) {
+ return g_list_length(this->destinations);
}
/**
@@ -1246,55 +1138,53 @@ route_get_destination_count(struct route *this)
* @param n The nth waypoint
* @return The description
*/
-char*
-route_get_destination_description(struct route *this, int n)
-{
- struct route_info *dst;
- struct map_rect *mr=NULL;
- struct item *item;
- struct attr attr;
- char *type=NULL;
- char *label=NULL;
- char *desc=NULL;
-
- if(!this->destinations)
- return NULL;
-
- dst=g_list_nth_data(this->destinations,n);
- mr=map_rect_new(dst->street->item.map, NULL);
- item = map_rect_get_item_byid(mr, dst->street->item.id_hi, dst->street->item.id_lo);
-
- type=g_strdup(item_to_name(dst->street->item.type));
-
- while(item_attr_get(item, attr_any, &attr)) {
- if (attr.type==attr_street_name_systematic ){
- g_free(type);
- type=attr_to_text(&attr, item->map, 1);
- } else if (attr.type==attr_label){
- g_free(label);
- label=attr_to_text(&attr, item->map, 1);
- } else if (attr.type==attr_osm_wayid && !label){
- char *tmp=attr_to_text(&attr, item->map, 1);
- label=g_strdup_printf("WayID %s", tmp);
- g_free(tmp);
- }
- }
-
- if(!label && !type) {
- desc=g_strdup(_("unknown street"));
- } else if (!label || strcmp(type, label)==0){
- desc=g_strdup(type);
- } else {
- desc=g_strdup_printf("%s %s", type, label);
- }
-
- g_free(label);
- g_free(type);
-
- if (mr)
- map_rect_destroy(mr);
-
- return desc;
+char* route_get_destination_description(struct route *this, int n) {
+ struct route_info *dst;
+ struct map_rect *mr=NULL;
+ struct item *item;
+ struct attr attr;
+ char *type=NULL;
+ char *label=NULL;
+ char *desc=NULL;
+
+ if(!this->destinations)
+ return NULL;
+
+ dst=g_list_nth_data(this->destinations,n);
+ mr=map_rect_new(dst->street->item.map, NULL);
+ item = map_rect_get_item_byid(mr, dst->street->item.id_hi, dst->street->item.id_lo);
+
+ type=g_strdup(item_to_name(dst->street->item.type));
+
+ while(item_attr_get(item, attr_any, &attr)) {
+ if (attr.type==attr_street_name_systematic ) {
+ g_free(type);
+ type=attr_to_text(&attr, item->map, 1);
+ } else if (attr.type==attr_label) {
+ g_free(label);
+ label=attr_to_text(&attr, item->map, 1);
+ } else if (attr.type==attr_osm_wayid && !label) {
+ char *tmp=attr_to_text(&attr, item->map, 1);
+ label=g_strdup_printf("WayID %s", tmp);
+ g_free(tmp);
+ }
+ }
+
+ if(!label && !type) {
+ desc=g_strdup(_("unknown street"));
+ } else if (!label || strcmp(type, label)==0) {
+ desc=g_strdup(type);
+ } else {
+ desc=g_strdup_printf("%s %s", type, label);
+ }
+
+ g_free(label);
+ g_free(type);
+
+ if (mr)
+ map_rect_destroy(mr);
+
+ return desc;
}
/**
@@ -1305,10 +1195,8 @@ route_get_destination_description(struct route *this, int n)
* @param async Set to 1 to do route calculation asynchronously
* @return nothing
*/
-void
-route_set_destination(struct route *this, struct pcoord *dst, int async)
-{
- route_set_destinations(this, dst, dst?1:0, async);
+void route_set_destination(struct route *this, struct pcoord *dst, int async) {
+ route_set_destinations(this, dst, dst?1:0, async);
}
/**
@@ -1316,29 +1204,27 @@ route_set_destination(struct route *this, struct pcoord *dst, int async)
*
* This appends a waypoint to the current route, targetting the street
* nearest to the coordinates passed, and updates the route.
- *
+ *
* @param this The route to set the destination for
* @param dst Coordinates of the new waypoint
* @param async: If set, do routing asynchronously
*/
-void
-route_append_destination(struct route *this, struct pcoord *dst, int async)
-{
- if (dst){
- struct route_info *dsti;
- dsti=route_find_nearest_street(this->vehicleprofile, this->ms, &dst[0]);
- if(dsti) {
- route_info_distances(dsti, dst->pro);
- this->destinations=g_list_append(this->destinations, dsti);
- }
- /* The graph has to be destroyed and set to NULL, otherwise route_path_update() doesn't work */
- route_graph_destroy(this->graph);
- this->graph=NULL;
- this->current_dst=route_get_dst(this);
- route_path_update(this, 1, async);
- }else{
- route_set_destinations(this, NULL, 0, async);
- }
+void route_append_destination(struct route *this, struct pcoord *dst, int async) {
+ if (dst) {
+ struct route_info *dsti;
+ dsti=route_find_nearest_street(this->vehicleprofile, this->ms, &dst[0]);
+ if(dsti) {
+ route_info_distances(dsti, dst->pro);
+ this->destinations=g_list_append(this->destinations, dsti);
+ }
+ /* The graph has to be destroyed and set to NULL, otherwise route_path_update() doesn't work */
+ route_graph_destroy(this->graph);
+ this->graph=NULL;
+ this->current_dst=route_get_dst(this);
+ route_path_update(this, 1, async);
+ } else {
+ route_set_destinations(this, NULL, 0, async);
+ }
}
/**
@@ -1348,39 +1234,36 @@ route_append_destination(struct route *this, struct pcoord *dst, int async)
* @param n The waypoint to remove
* @return nothing
*/
-void
-route_remove_nth_waypoint(struct route *this, int n)
-{
- struct route_info *ri=g_list_nth_data(this->destinations, n);
- this->destinations=g_list_remove(this->destinations,ri);
- route_info_free(ri);
- /* The graph has to be destroyed and set to NULL, otherwise route_path_update() doesn't work */
- route_graph_destroy(this->graph);
- this->graph=NULL;
- this->current_dst=route_get_dst(this);
- route_path_update(this, 1, 1);
-}
-
-void
-route_remove_waypoint(struct route *this)
-{
- if (this->path2) {
- struct route_path *path = this->path2;
- struct route_info *ri = this->destinations->data;
- this->destinations = g_list_remove(this->destinations, ri);
- route_info_free(ri);
- this->path2 = this->path2->next;
- route_path_destroy(path, 0);
- if (!this->destinations) {
- this->route_status=route_status_no_destination;
- this->reached_destinations_count=0;
- return;
- }
- this->reached_destinations_count++;
- route_graph_reset(this->graph);
- this->current_dst = this->destinations->data;
- route_graph_flood(this->graph, this->current_dst, this->vehicleprofile, this->route_graph_flood_done_cb);
- }
+void route_remove_nth_waypoint(struct route *this, int n) {
+ struct route_info *ri=g_list_nth_data(this->destinations, n);
+ this->destinations=g_list_remove(this->destinations,ri);
+ route_info_free(ri);
+ /* The graph has to be destroyed and set to NULL, otherwise route_path_update() doesn't work */
+ route_graph_destroy(this->graph);
+ this->graph=NULL;
+ this->current_dst=route_get_dst(this);
+ route_path_update(this, 1, 1);
+}
+
+void route_remove_waypoint(struct route *this) {
+ if (this->path2) {
+ struct route_path *path = this->path2;
+ struct route_info *ri = this->destinations->data;
+ this->destinations = g_list_remove(this->destinations, ri);
+ route_info_free(ri);
+ this->path2 = this->path2->next;
+ route_path_destroy(path, 0);
+ if (!this->destinations) {
+ this->route_status=route_status_no_destination;
+ this->reached_destinations_count=0;
+ return;
+ }
+ this->reached_destinations_count++;
+ route_graph_reset(this->graph);
+ this->current_dst = this->destinations->data;
+ route_graph_init(this->graph, this->current_dst, this->vehicleprofile);
+ route_graph_compute_shortest_path(this->graph, this->vehicleprofile, this->route_graph_flood_done_cb);
+ }
}
/**
@@ -1392,22 +1275,21 @@ route_remove_waypoint(struct route *this)
* or {@code NULL} to return the first point
* @return The point at the specified coordinates or NULL if not found
*/
-static struct route_graph_point *
-route_graph_get_point_next(struct route_graph *this, struct coord *c, struct route_graph_point *last)
-{
- struct route_graph_point *p;
- int seen=0,hashval=HASHCOORD(c);
- p=this->hash[hashval];
- while (p) {
- if (p->c.x == c->x && p->c.y == c->y) {
- if (!last || seen)
- return p;
- if (p == last)
- seen=1;
- }
- p=p->hash_next;
- }
- return NULL;
+struct route_graph_point *route_graph_get_point_next(struct route_graph *this, struct coord *c,
+ struct route_graph_point *last) {
+ struct route_graph_point *p;
+ int seen=0,hashval=HASHCOORD(c);
+ p=this->hash[hashval];
+ while (p) {
+ if (p->c.x == c->x && p->c.y == c->y) {
+ if (!last || seen)
+ return p;
+ if (p == last)
+ seen=1;
+ }
+ p=p->hash_next;
+ }
+ return NULL;
}
/**
@@ -1417,31 +1299,27 @@ route_graph_get_point_next(struct route_graph *this, struct coord *c, struct rou
* @param c Coordinates to search for
* @return The point at the specified coordinates or NULL if not found
*/
-static struct route_graph_point *
-route_graph_get_point(struct route_graph *this, struct coord *c)
-{
- return route_graph_get_point_next(this, c, NULL);
+struct route_graph_point * route_graph_get_point(struct route_graph *this, struct coord *c) {
+ return route_graph_get_point_next(this, c, NULL);
}
/**
- * @brief Gets the last route_graph_point with the specified coordinates
+ * @brief Gets the last route_graph_point with the specified coordinates
*
* @param this The route in which to search
* @param c Coordinates to search for
* @return The point at the specified coordinates or NULL if not found
*/
-static struct route_graph_point *
-route_graph_get_point_last(struct route_graph *this, struct coord *c)
-{
- struct route_graph_point *p,*ret=NULL;
- int hashval=HASHCOORD(c);
- p=this->hash[hashval];
- while (p) {
- if (p->c.x == c->x && p->c.y == c->y)
- ret=p;
- p=p->hash_next;
- }
- return ret;
+static struct route_graph_point *route_graph_get_point_last(struct route_graph *this, struct coord *c) {
+ struct route_graph_point *p,*ret=NULL;
+ int hashval=HASHCOORD(c);
+ p=this->hash[hashval];
+ while (p) {
+ if (p->c.x == c->x && p->c.y == c->y)
+ ret=p;
+ p=p->hash_next;
+ }
+ return ret;
}
@@ -1454,21 +1332,20 @@ route_graph_get_point_last(struct route_graph *this, struct coord *c)
* @return The point created
*/
-static struct route_graph_point *
-route_graph_point_new(struct route_graph *this, struct coord *f)
-{
- int hashval;
- struct route_graph_point *p;
-
- hashval=HASHCOORD(f);
- if (debug_route)
- printf("p (0x%x,0x%x)\n", f->x, f->y);
- p=g_slice_new0(struct route_graph_point);
- p->hash_next=this->hash[hashval];
- this->hash[hashval]=p;
- p->value=INT_MAX;
- p->c=*f;
- return p;
+static struct route_graph_point *route_graph_point_new(struct route_graph *this, struct coord *f) {
+ int hashval;
+ struct route_graph_point *p;
+
+ hashval=HASHCOORD(f);
+ if (debug_route)
+ printf("p (0x%x,0x%x)\n", f->x, f->y);
+ p=g_slice_new0(struct route_graph_point);
+ p->hash_next=this->hash[hashval];
+ this->hash[hashval]=p;
+ p->value=INT_MAX;
+ p->dst_val = INT_MAX;
+ p->c=*f;
+ return p;
}
/**
@@ -1484,15 +1361,13 @@ route_graph_point_new(struct route_graph *this, struct coord *f)
* @param f The coordinates at which the point should be inserted
* @return The point inserted or NULL on failure
*/
-static struct route_graph_point *
-route_graph_add_point(struct route_graph *this, struct coord *f)
-{
- struct route_graph_point *p;
+struct route_graph_point * route_graph_add_point(struct route_graph *this, struct coord *f) {
+ struct route_graph_point *p;
- p=route_graph_get_point(this,f);
- if (!p)
- p=route_graph_point_new(this,f);
- return p;
+ p=route_graph_get_point(this,f);
+ if (!p)
+ p=route_graph_point_new(this,f);
+ return p;
}
/**
@@ -1500,49 +1375,99 @@ route_graph_add_point(struct route_graph *this, struct coord *f)
*
* @param this The route graph to delete all points from
*/
-static void
-route_graph_free_points(struct route_graph *this)
-{
- struct route_graph_point *curr,*next;
- int i;
- for (i = 0 ; i < HASH_SIZE ; i++) {
- curr=this->hash[i];
- while (curr) {
- next=curr->hash_next;
- g_slice_free(struct route_graph_point, curr);
- curr=next;
- }
- this->hash[i]=NULL;
- }
+void route_graph_free_points(struct route_graph *this) {
+ struct route_graph_point *curr,*next;
+ int i;
+ for (i = 0 ; i < HASH_SIZE ; i++) {
+ curr=this->hash[i];
+ while (curr) {
+ next=curr->hash_next;
+ g_slice_free(struct route_graph_point, curr);
+ curr=next;
+ }
+ this->hash[i]=NULL;
+ }
+}
+
+/**
+ * @brief Initializes potential destination nodes.
+ *
+ * This method is normally called after building a fresh route graph, or resetting an existing one. It iterates over
+ * all potential destination nodes (i.e. all nodes which are part of the destination’s street) and initializes them:
+ * The `dst_val` and `rhs` values are set according to their cost to reach the destination.
+ *
+ * @param this The route graph to initialize
+ * @param dst The destination of the route
+ * @param profile The vehicle profile to use for routing. This determines which ways are passable
+ * and how their costs are calculated.
+ */
+static void route_graph_init(struct route_graph *this, struct route_info *dst, struct vehicleprofile *profile) {
+ struct route_graph_segment *s = NULL;
+ int val;
+
+ while ((s = route_graph_get_segment(this, dst->street, s))) {
+ val = route_value_seg(profile, NULL, s, -1);
+ if (val != INT_MAX) {
+ val = val*(100-dst->percent)/100;
+ s->end->seg = s;
+ s->end->dst_seg = s;
+ s->end->rhs = val;
+ s->end->dst_val = val;
+ s->end->el = fh_insertkey(this->heap, MIN(s->end->rhs, s->end->value), s->end);
+ }
+ val = route_value_seg(profile, NULL, s, 1);
+ if (val != INT_MAX) {
+ val = val*dst->percent/100;
+ s->start->seg = s;
+ s->start->dst_seg = s;
+ s->start->rhs = val;
+ s->start->dst_val = val;
+ s->start->el = fh_insertkey(this->heap, MIN(s->start->rhs, s->start->value), s->start);
+ }
+ }
}
/**
* @brief Resets all nodes
*
* This iterates through all the points in the route graph, resetting them to their initial state.
- * The {@code value} member of each point (cost to reach the destination) is reset to
- * {@code INT_MAX}, the {@code seg} member (cheapest way to destination) is reset to {@code NULL}
- * and the {@code el} member (pointer to element in Fibonacci heap) is also reset to {@code NULL}.
+ * The `value` (cost to reach the destination via `seg`) and `dst_val` (cost to destination if this point is the last
+ * in the route) members of each point are reset to`INT_MAX`, the `seg` member (cheapest way to destination) is reset
+ * to `NULL` and the `el` member (pointer to element in Fibonacci heap) is also reset to `NULL`.
+ *
+ * The Fibonacci heap is also cleared. Inconsistencies between `el` and Fibonacci heap membership are handled
+ * gracefully, i.e. `el` is reset even if it is invalid, and points are removed from the heap regardless of their `el`
+ * value.
+ *
+ * After this method returns, the caller should call
+ * {@link route_graph_init(struct route_graph *, struct route_info *, struct vehicleprofile *)} to initialize potential
+ * end points. After that a route can be calculated.
*
* References to elements of the route graph which were obtained prior to calling this function
* remain valid after it returns.
*
* @param this The route graph to reset
*/
-static void
-route_graph_reset(struct route_graph *this)
-{
- struct route_graph_point *curr;
- int i;
- for (i = 0 ; i < HASH_SIZE ; i++) {
- curr=this->hash[i];
- while (curr) {
- curr->value=INT_MAX;
- curr->seg=NULL;
- curr->el=NULL;
- curr=curr->hash_next;
- }
- }
+static void route_graph_reset(struct route_graph *this) {
+ struct route_graph_point *curr;
+ int i;
+
+ for (i = 0 ; i < HASH_SIZE ; i++) {
+ curr=this->hash[i];
+ while (curr) {
+ curr->value=INT_MAX;
+ curr->dst_val = INT_MAX;
+ curr->rhs = INT_MAX;
+ curr->seg=NULL;
+ curr->dst_seg = NULL;
+ curr->el=NULL;
+ curr=curr->hash_next;
+ }
+ }
+
+ while (fh_extractmin(this->heap)) {
+ // no operation, just remove all items (`el` has already been reset)
+ }
}
/**
@@ -1555,34 +1480,32 @@ route_graph_reset(struct route_graph *this)
* @param type Type of the field that should be returned
* @return A pointer to a field of a certain type, or NULL if no such field is present
*/
-static void *
-route_segment_data_field_pos(struct route_segment_data *seg, enum attr_type type)
-{
- unsigned char *ptr;
-
- ptr = ((unsigned char*)seg) + sizeof(struct route_segment_data);
-
- if (seg->flags & AF_SPEED_LIMIT) {
- if (type == attr_maxspeed)
- return (void*)ptr;
- ptr += sizeof(int);
- }
- if (seg->flags & AF_SEGMENTED) {
- if (type == attr_offset)
- return (void*)ptr;
- ptr += sizeof(int);
- }
- if (seg->flags & AF_SIZE_OR_WEIGHT_LIMIT) {
- if (type == attr_vehicle_width)
- return (void*)ptr;
- ptr += sizeof(struct size_weight_limit);
- }
- if (seg->flags & AF_DANGEROUS_GOODS) {
- if (type == attr_vehicle_dangerous_goods)
- return (void*)ptr;
- ptr += sizeof(int);
- }
- return NULL;
+void * route_segment_data_field_pos(struct route_segment_data *seg, enum attr_type type) {
+ unsigned char *ptr;
+
+ ptr = ((unsigned char*)seg) + sizeof(struct route_segment_data);
+
+ if (seg->flags & AF_SPEED_LIMIT) {
+ if (type == attr_maxspeed)
+ return (void*)ptr;
+ ptr += sizeof(int);
+ }
+ if (seg->flags & AF_SEGMENTED) {
+ if (type == attr_offset)
+ return (void*)ptr;
+ ptr += sizeof(int);
+ }
+ if (seg->flags & AF_SIZE_OR_WEIGHT_LIMIT) {
+ if (type == attr_vehicle_width)
+ return (void*)ptr;
+ ptr += sizeof(struct size_weight_limit);
+ }
+ if (seg->flags & AF_DANGEROUS_GOODS) {
+ if (type == attr_vehicle_dangerous_goods)
+ return (void*)ptr;
+ ptr += sizeof(int);
+ }
+ return NULL;
}
/**
@@ -1591,46 +1514,48 @@ route_segment_data_field_pos(struct route_segment_data *seg, enum attr_type type
* @param flags The flags of the route_segment_data
*/
-static int
-route_segment_data_size(int flags)
-{
- int ret=sizeof(struct route_segment_data);
- if (flags & AF_SPEED_LIMIT)
- ret+=sizeof(int);
- if (flags & AF_SEGMENTED)
- ret+=sizeof(int);
- if (flags & AF_SIZE_OR_WEIGHT_LIMIT)
- ret+=sizeof(struct size_weight_limit);
- if (flags & AF_DANGEROUS_GOODS)
- ret+=sizeof(int);
- return ret;
-}
-
-
-static int
-route_graph_segment_is_duplicate(struct route_graph_point *start, struct route_graph_segment_data *data)
-{
- struct route_graph_segment *s;
- s=start->start;
- while (s) {
- if (item_is_equal(*data->item, s->data.item)) {
- if (data->flags & AF_SEGMENTED) {
- if (RSD_OFFSET(&s->data) == data->offset) {
- return 1;
- }
- } else
- return 1;
- }
- s=s->start_next;
- }
- return 0;
+static int route_segment_data_size(int flags) {
+ int ret=sizeof(struct route_segment_data);
+ if (flags & AF_SPEED_LIMIT)
+ ret+=sizeof(int);
+ if (flags & AF_SEGMENTED)
+ ret+=sizeof(int);
+ if (flags & AF_SIZE_OR_WEIGHT_LIMIT)
+ ret+=sizeof(struct size_weight_limit);
+ if (flags & AF_DANGEROUS_GOODS)
+ ret+=sizeof(int);
+ return ret;
}
+
/**
- * @brief Inserts a new segment into the route graph
+ * @brief Checks if the route graph already contains a particular segment.
+ *
+ * This function compares the item IDs of both segments. If the item is segmented, the segment offset is
+ * also compared.
*
- * This function performs a check if a segment for the item specified already exists, and inserts
- * a new segment representing this item if it does not.
+ * @param start The starting point of the segment
+ * @param data The data for the segment
+ */
+int route_graph_segment_is_duplicate(struct route_graph_point *start, struct route_graph_segment_data *data) {
+ struct route_graph_segment *s;
+ s=start->start;
+ while (s) {
+ if (item_is_equal(*data->item, s->data.item)) {
+ if (data->flags & AF_SEGMENTED) {
+ if (RSD_OFFSET(&s->data) == data->offset) {
+ return 1;
+ }
+ } else
+ return 1;
+ }
+ s=s->start_next;
+ }
+ return 0;
+}
+
+/**
+ * @brief Inserts a new segment into the route graph
*
* @param this The route graph to insert the segment into
* @param start The graph point which should be connected to the start of this segment
@@ -1641,88 +1566,42 @@ route_graph_segment_is_duplicate(struct route_graph_point *start, struct route_g
* @param offset If the item passed in "item" is segmented (i.e. divided into several segments), this indicates the position of this segment within the item
* @param maxspeed The maximum speed allowed on this segment in km/h. -1 if not known.
*/
-static void
-route_graph_add_segment(struct route_graph *this, struct route_graph_point *start,
- struct route_graph_point *end, struct route_graph_segment_data *data)
-{
- struct route_graph_segment *s;
- int size;
-
- size = sizeof(struct route_graph_segment)-sizeof(struct route_segment_data)+route_segment_data_size(data->flags);
- s = g_slice_alloc0(size);
- if (!s) {
- printf("%s:Out of memory\n", __FUNCTION__);
- return;
- }
- s->start=start;
- s->start_next=start->start;
- start->start=s;
- s->end=end;
- s->end_next=end->end;
- end->end=s;
- dbg_assert(data->len >= 0);
- s->data.len=data->len;
- s->data.item=*data->item;
- s->data.flags=data->flags;
-
- if (data->flags & AF_SPEED_LIMIT)
- RSD_MAXSPEED(&s->data)=data->maxspeed;
- if (data->flags & AF_SEGMENTED)
- RSD_OFFSET(&s->data)=data->offset;
- if (data->flags & AF_SIZE_OR_WEIGHT_LIMIT)
- RSD_SIZE_WEIGHT(&s->data)=data->size_weight;
- if (data->flags & AF_DANGEROUS_GOODS)
- RSD_DANGEROUS_GOODS(&s->data)=data->dangerous_goods;
-
- s->next=this->route_segments;
- this->route_segments=s;
- if (debug_route)
- printf("l (0x%x,0x%x)-(0x%x,0x%x)\n", start->c.x, start->c.y, end->c.x, end->c.y);
-}
-
-/**
- * @brief Gets all the coordinates of an item
- *
- * This will get all the coordinates of the item i and return them in c,
- * up to max coordinates. Additionally it is possible to limit the coordinates
- * returned to all the coordinates of the item between the two coordinates
- * start end end.
- *
- * @important Make sure that whatever c points to has enough memory allocated
- * @important to hold max coordinates!
- *
- * @param i The item to get the coordinates of
- * @param c Pointer to memory allocated for holding the coordinates
- * @param max Maximum number of coordinates to return
- * @param start First coordinate to get
- * @param end Last coordinate to get
- * @return The number of coordinates returned
- */
-static int get_item_seg_coords(struct item *i, struct coord *c, int max,
- struct coord *start, struct coord *end)
-{
- struct map_rect *mr;
- struct item *item;
- int rc = 0, p = 0;
- struct coord c1;
- mr=map_rect_new(i->map, NULL);
- if (!mr)
- return 0;
- item = map_rect_get_item_byid(mr, i->id_hi, i->id_lo);
- if (item) {
- rc = item_coord_get(item, &c1, 1);
- while (rc && (c1.x != start->x || c1.y != start->y)) {
- rc = item_coord_get(item, &c1, 1);
- }
- while (rc && p < max) {
- c[p++] = c1;
- if (c1.x == end->x && c1.y == end->y)
- break;
- rc = item_coord_get(item, &c1, 1);
- }
- }
- map_rect_destroy(mr);
- return p;
+void route_graph_add_segment(struct route_graph *this, struct route_graph_point *start,
+ struct route_graph_point *end, struct route_graph_segment_data *data) {
+ struct route_graph_segment *s;
+ int size;
+
+ size = sizeof(struct route_graph_segment)-sizeof(struct route_segment_data)+route_segment_data_size(data->flags);
+ s = g_slice_alloc0(size);
+ if (!s) {
+ printf("%s:Out of memory\n", __FUNCTION__);
+ return;
+ }
+ s->start=start;
+ s->start_next=start->start;
+ start->start=s;
+ s->end=end;
+ s->end_next=end->end;
+ end->end=s;
+ dbg_assert(data->len >= 0);
+ s->data.len=data->len;
+ s->data.item=*data->item;
+ s->data.flags=data->flags;
+ s->data.score = data->score;
+
+ if (data->flags & AF_SPEED_LIMIT)
+ RSD_MAXSPEED(&s->data)=data->maxspeed;
+ if (data->flags & AF_SEGMENTED)
+ RSD_OFFSET(&s->data)=data->offset;
+ if (data->flags & AF_SIZE_OR_WEIGHT_LIMIT)
+ RSD_SIZE_WEIGHT(&s->data)=data->size_weight;
+ if (data->flags & AF_DANGEROUS_GOODS)
+ RSD_DANGEROUS_GOODS(&s->data)=data->dangerous_goods;
+
+ s->next=this->route_segments;
+ this->route_segments=s;
+ if (debug_route)
+ printf("l (0x%x,0x%x)-(0x%x,0x%x)\n", start->c.x, start->c.y, end->c.x, end->c.y);
}
/**
@@ -1733,35 +1612,33 @@ static int get_item_seg_coords(struct item *i, struct coord *c, int max,
* @param offset Offset of the segment within the item to remove. If the item is not segmented this should be 1.
* @return The segment removed
*/
-static struct route_path_segment *
-route_extract_segment_from_path(struct route_path *path, struct item *item,
- int offset)
-{
- int soffset;
- struct route_path_segment *sp = NULL, *s;
- s = path->path;
- while (s) {
- if (item_is_equal(s->data->item,*item)) {
- if (s->data->flags & AF_SEGMENTED)
- soffset=RSD_OFFSET(s->data);
- else
- soffset=1;
- if (soffset == offset) {
- if (sp) {
- sp->next = s->next;
- break;
- } else {
- path->path = s->next;
- break;
- }
- }
- }
- sp = s;
- s = s->next;
- }
- if (s)
- item_hash_remove(path->path_hash, item);
- return s;
+static struct route_path_segment *route_extract_segment_from_path(struct route_path *path, struct item *item,
+ int offset) {
+ int soffset;
+ struct route_path_segment *sp = NULL, *s;
+ s = path->path;
+ while (s) {
+ if (item_is_equal(s->data->item,*item)) {
+ if (s->data->flags & AF_SEGMENTED)
+ soffset=RSD_OFFSET(s->data);
+ else
+ soffset=1;
+ if (soffset == offset) {
+ if (sp) {
+ sp->next = s->next;
+ break;
+ } else {
+ path->path = s->next;
+ break;
+ }
+ }
+ }
+ sp = s;
+ s = s->next;
+ }
+ if (s)
+ item_hash_remove(path->path_hash, item);
+ return s;
}
/**
@@ -1770,14 +1647,12 @@ route_extract_segment_from_path(struct route_path *path, struct item *item,
* @param this The path to add the segment to
* @param segment The segment to add
*/
-static void
-route_path_add_segment(struct route_path *this, struct route_path_segment *segment)
-{
- if (!this->path)
- this->path=segment;
- if (this->path_last)
- this->path_last->next=segment;
- this->path_last=segment;
+static void route_path_add_segment(struct route_path *this, struct route_path_segment *segment) {
+ if (!this->path)
+ this->path=segment;
+ if (this->path_last)
+ this->path_last->next=segment;
+ this->path_last=segment;
}
/**
@@ -1790,35 +1665,31 @@ route_path_add_segment(struct route_path *this, struct route_path_segment *segme
* @param end coordinate to add to the end of the item. If none should be added, make this NULL.
* @param len The length of the item
*/
-static void
-route_path_add_line(struct route_path *this, struct coord *start, struct coord *end, int len)
-{
- int ccnt=2;
- struct route_path_segment *segment;
- int seg_size,seg_dat_size;
-
- dbg(lvl_debug,"line from 0x%x,0x%x-0x%x,0x%x\n", start->x, start->y, end->x, end->y);
- seg_size=sizeof(*segment) + sizeof(struct coord) * ccnt;
- seg_dat_size=sizeof(struct route_segment_data);
- segment=g_malloc0(seg_size + seg_dat_size);
- segment->data=(struct route_segment_data *)((char *)segment+seg_size);
- segment->ncoords=ccnt;
- segment->direction=0;
- segment->c[0]=*start;
- segment->c[1]=*end;
- segment->data->len=len;
- route_path_add_segment(this, segment);
+static void route_path_add_line(struct route_path *this, struct coord *start, struct coord *end, int len) {
+ int ccnt=2;
+ struct route_path_segment *segment;
+ int seg_size,seg_dat_size;
+
+ dbg(lvl_debug,"line from 0x%x,0x%x-0x%x,0x%x", start->x, start->y, end->x, end->y);
+ seg_size=sizeof(*segment) + sizeof(struct coord) * ccnt;
+ seg_dat_size=sizeof(struct route_segment_data);
+ segment=g_malloc0(seg_size + seg_dat_size);
+ segment->data=(struct route_segment_data *)((char *)segment+seg_size);
+ segment->ncoords=ccnt;
+ segment->direction=0;
+ segment->c[0]=*start;
+ segment->c[1]=*end;
+ segment->data->len=len;
+ route_path_add_segment(this, segment);
}
/**
- * @brief Inserts a new item into the path
- *
- * This function does almost the same as "route_path_add_item()", but identifies
- * the item to add by a segment from the route graph. Another difference is that it "copies" the
- * segment from the route graph, i.e. if the item is segmented, only the segment passed in rgs will
- * be added to the route path, not all segments of the item.
- *
- * The function can be sped up by passing an old path already containing this segment in oldpath -
+ * @brief Inserts a new segment into the path
+ *
+ * This function adds a new segment to the route path. The segment is copied from the route graph. If
+ * `rgs` is part of a segmented item, only `rgs` will be added to the route path, not the other segments.
+ *
+ * The function can be sped up by passing an old path already containing this segment in oldpath -
* the segment will then be extracted from this old path. Please note that in this case the direction
* parameter has no effect.
*
@@ -1830,117 +1701,117 @@ route_path_add_line(struct route_path *this, struct coord *start, struct coord *
* @param dst Information about end point if this is the last segment
*/
-static int
-route_path_add_item_from_graph(struct route_path *this, struct route_path *oldpath, struct route_graph_segment *rgs, int dir, struct route_info *pos, struct route_info *dst)
-{
- struct route_path_segment *segment=NULL;
- int i, ccnt, extra=0, ret=0;
- struct coord *c,*cd,ca[2048];
- int offset=1;
- int seg_size,seg_dat_size;
- int len=rgs->data.len;
- if (rgs->data.flags & AF_SEGMENTED)
- offset=RSD_OFFSET(&rgs->data);
-
- dbg(lvl_debug,"enter (0x%x,0x%x) dir=%d pos=%p dst=%p\n", rgs->data.item.id_hi, rgs->data.item.id_lo, dir, pos, dst);
- if (oldpath) {
- segment=item_hash_lookup(oldpath->path_hash, &rgs->data.item);
- if (segment && segment->direction == dir) {
- segment = route_extract_segment_from_path(oldpath, &rgs->data.item, offset);
- if (segment) {
- ret=1;
- if (!pos)
- goto linkold;
- }
- g_free(segment);
- }
- }
-
- if (pos) {
- if (dst) {
- extra=2;
- if (dst->lenneg >= pos->lenneg) {
- dir=1;
- ccnt=dst->pos-pos->pos;
- c=pos->street->c+pos->pos+1;
- len=dst->lenneg-pos->lenneg;
- } else {
- dir=-1;
- ccnt=pos->pos-dst->pos;
- c=pos->street->c+dst->pos+1;
- len=pos->lenneg-dst->lenneg;
- }
- } else {
- extra=1;
- dbg(lvl_debug,"pos dir=%d\n", dir);
- dbg(lvl_debug,"pos pos=%d\n", pos->pos);
- dbg(lvl_debug,"pos count=%d\n", pos->street->count);
- if (dir > 0) {
- c=pos->street->c+pos->pos+1;
- ccnt=pos->street->count-pos->pos-1;
- len=pos->lenpos;
- } else {
- c=pos->street->c;
- ccnt=pos->pos+1;
- len=pos->lenneg;
- }
- }
- pos->dir=dir;
- } else if (dst) {
- extra=1;
- dbg(lvl_debug,"dst dir=%d\n", dir);
- dbg(lvl_debug,"dst pos=%d\n", dst->pos);
- if (dir > 0) {
- c=dst->street->c;
- ccnt=dst->pos+1;
- len=dst->lenneg;
- } else {
- c=dst->street->c+dst->pos+1;
- ccnt=dst->street->count-dst->pos-1;
- len=dst->lenpos;
- }
- } else {
- ccnt=get_item_seg_coords(&rgs->data.item, ca, 2047, &rgs->start->c, &rgs->end->c);
- c=ca;
- }
- seg_size=sizeof(*segment) + sizeof(struct coord) * (ccnt + extra);
- seg_dat_size=route_segment_data_size(rgs->data.flags);
- segment=g_malloc0(seg_size + seg_dat_size);
- segment->data=(struct route_segment_data *)((char *)segment+seg_size);
- segment->direction=dir;
- cd=segment->c;
- if (pos && (c[0].x != pos->lp.x || c[0].y != pos->lp.y))
- *cd++=pos->lp;
- if (dir < 0)
- c+=ccnt-1;
- for (i = 0 ; i < ccnt ; i++) {
- *cd++=*c;
- c+=dir;
- }
- segment->ncoords+=ccnt;
- if (dst && (cd[-1].x != dst->lp.x || cd[-1].y != dst->lp.y))
- *cd++=dst->lp;
- segment->ncoords=cd-segment->c;
- if (segment->ncoords <= 1) {
- g_free(segment);
- return 1;
- }
-
- /* We check if the route graph segment is part of a roundabout here, because this
- * only matters for route graph segments which form parts of the route path */
- if (!(rgs->data.flags & AF_ROUNDABOUT)) { // We identified this roundabout earlier
- route_check_roundabout(rgs, 13, (dir < 1), NULL);
- }
-
- memcpy(segment->data, &rgs->data, seg_dat_size);
+static int route_path_add_item_from_graph(struct route_path *this, struct route_path *oldpath,
+ struct route_graph_segment *rgs,
+ int dir, struct route_info *pos, struct route_info *dst) {
+ struct route_path_segment *segment=NULL;
+ int i, ccnt, extra=0, ret=0;
+ struct coord *c,*cd,ca[2048];
+ int offset=1;
+ int seg_size,seg_dat_size;
+ int len=rgs->data.len;
+ if (rgs->data.flags & AF_SEGMENTED)
+ offset=RSD_OFFSET(&rgs->data);
+
+ dbg(lvl_debug,"enter (0x%x,0x%x) dir=%d pos=%p dst=%p", rgs->data.item.id_hi, rgs->data.item.id_lo, dir, pos, dst);
+ if (oldpath) {
+ segment=item_hash_lookup(oldpath->path_hash, &rgs->data.item);
+ if (segment && segment->direction == dir) {
+ segment = route_extract_segment_from_path(oldpath, &rgs->data.item, offset);
+ if (segment) {
+ ret=1;
+ if (!pos)
+ goto linkold;
+ }
+ g_free(segment);
+ }
+ }
+
+ if (pos) {
+ if (dst) {
+ extra=2;
+ if (dst->lenneg >= pos->lenneg) {
+ dir=1;
+ ccnt=dst->pos-pos->pos;
+ c=pos->street->c+pos->pos+1;
+ len=dst->lenneg-pos->lenneg;
+ } else {
+ dir=-1;
+ ccnt=pos->pos-dst->pos;
+ c=pos->street->c+dst->pos+1;
+ len=pos->lenneg-dst->lenneg;
+ }
+ } else {
+ extra=1;
+ dbg(lvl_debug,"pos dir=%d", dir);
+ dbg(lvl_debug,"pos pos=%d", pos->pos);
+ dbg(lvl_debug,"pos count=%d", pos->street->count);
+ if (dir > 0) {
+ c=pos->street->c+pos->pos+1;
+ ccnt=pos->street->count-pos->pos-1;
+ len=pos->lenpos;
+ } else {
+ c=pos->street->c;
+ ccnt=pos->pos+1;
+ len=pos->lenneg;
+ }
+ }
+ pos->dir=dir;
+ } else if (dst) {
+ extra=1;
+ dbg(lvl_debug,"dst dir=%d", dir);
+ dbg(lvl_debug,"dst pos=%d", dst->pos);
+ if (dir > 0) {
+ c=dst->street->c;
+ ccnt=dst->pos+1;
+ len=dst->lenneg;
+ } else {
+ c=dst->street->c+dst->pos+1;
+ ccnt=dst->street->count-dst->pos-1;
+ len=dst->lenpos;
+ }
+ } else {
+ ccnt=item_coord_get_within_range(&rgs->data.item, ca, 2047, &rgs->start->c, &rgs->end->c);
+ c=ca;
+ }
+ seg_size=sizeof(*segment) + sizeof(struct coord) * (ccnt + extra);
+ seg_dat_size=route_segment_data_size(rgs->data.flags);
+ segment=g_malloc0(seg_size + seg_dat_size);
+ segment->data=(struct route_segment_data *)((char *)segment+seg_size);
+ segment->direction=dir;
+ cd=segment->c;
+ if (pos && (c[0].x != pos->lp.x || c[0].y != pos->lp.y))
+ *cd++=pos->lp;
+ if (dir < 0)
+ c+=ccnt-1;
+ for (i = 0 ; i < ccnt ; i++) {
+ *cd++=*c;
+ c+=dir;
+ }
+ segment->ncoords+=ccnt;
+ if (dst && (cd[-1].x != dst->lp.x || cd[-1].y != dst->lp.y))
+ *cd++=dst->lp;
+ segment->ncoords=cd-segment->c;
+ if (segment->ncoords <= 1) {
+ g_free(segment);
+ return 1;
+ }
+
+ /* We check if the route graph segment is part of a roundabout here, because this
+ * only matters for route graph segments which form parts of the route path */
+ if (!(rgs->data.flags & AF_ROUNDABOUT)) { // We identified this roundabout earlier
+ route_check_roundabout(rgs, 13, (dir < 1), NULL);
+ }
+
+ memcpy(segment->data, &rgs->data, seg_dat_size);
linkold:
- segment->data->len=len;
- segment->next=NULL;
- item_hash_insert(this->path_hash, &rgs->data.item, segment);
+ segment->data->len=len;
+ segment->next=NULL;
+ item_hash_insert(this->path_hash, &rgs->data.item, segment);
- route_path_add_segment(this, segment);
+ route_path_add_segment(this, segment);
- return ret;
+ return ret;
}
/**
@@ -1948,35 +1819,32 @@ linkold:
*
* @param this The graph to destroy all segments from
*/
-static void
-route_graph_free_segments(struct route_graph *this)
-{
- struct route_graph_segment *curr,*next;
- int size;
- curr=this->route_segments;
- while (curr) {
- next=curr->next;
- size = sizeof(struct route_graph_segment)-sizeof(struct route_segment_data)+route_segment_data_size(curr->data.flags);
- g_slice_free1(size, curr);
- curr=next;
- }
- this->route_segments=NULL;
+void route_graph_free_segments(struct route_graph *this) {
+ struct route_graph_segment *curr,*next;
+ int size;
+ curr=this->route_segments;
+ while (curr) {
+ next=curr->next;
+ size = sizeof(struct route_graph_segment)-sizeof(struct route_segment_data)+route_segment_data_size(curr->data.flags);
+ g_slice_free1(size, curr);
+ curr=next;
+ }
+ this->route_segments=NULL;
}
/**
* @brief Destroys a route graph
- *
+ *
* @param this The route graph to be destroyed
*/
-static void
-route_graph_destroy(struct route_graph *this)
-{
- if (this) {
- route_graph_build_done(this, 1);
- route_graph_free_points(this);
- route_graph_free_segments(this);
- g_free(this);
- }
+static void route_graph_destroy(struct route_graph *this) {
+ if (this) {
+ route_graph_build_done(this, 1);
+ route_graph_free_points(this);
+ route_graph_free_segments(this);
+ fh_deleteheap(this->heap);
+ g_free(this);
+ }
}
/**
@@ -2003,44 +1871,43 @@ route_graph_destroy(struct route_graph *this)
* @param dist A traffic distortion if applicable, or {@code NULL}
* @return The estimated speed in km/h, or 0 if the segment is impassable
*/
-static int
-route_seg_speed(struct vehicleprofile *profile, struct route_segment_data *over, struct route_traffic_distortion *dist)
-{
- struct roadprofile *roadprofile=vehicleprofile_get_roadprofile(profile, over->item.type);
- int speed,maxspeed;
- if (!roadprofile || !roadprofile->route_weight)
- return 0;
- speed=roadprofile->route_weight;
- if (profile->maxspeed_handling != maxspeed_ignore) {
- if (over->flags & AF_SPEED_LIMIT) {
- maxspeed=RSD_MAXSPEED(over);
- if (profile->maxspeed_handling == maxspeed_enforce)
- speed=maxspeed;
- } else
- maxspeed=INT_MAX;
- if (dist && maxspeed > dist->maxspeed)
- maxspeed=dist->maxspeed;
- if (maxspeed != INT_MAX && (profile->maxspeed_handling != maxspeed_restrict || maxspeed < speed))
- speed=maxspeed;
- }
- if (over->flags & AF_DANGEROUS_GOODS) {
- if (profile->dangerous_goods & RSD_DANGEROUS_GOODS(over))
- return 0;
- }
- if (over->flags & AF_SIZE_OR_WEIGHT_LIMIT) {
- struct size_weight_limit *size_weight=&RSD_SIZE_WEIGHT(over);
- if (size_weight->width != -1 && profile->width != -1 && profile->width > size_weight->width)
- return 0;
- if (size_weight->height != -1 && profile->height != -1 && profile->height > size_weight->height)
- return 0;
- if (size_weight->length != -1 && profile->length != -1 && profile->length > size_weight->length)
- return 0;
- if (size_weight->weight != -1 && profile->weight != -1 && profile->weight > size_weight->weight)
- return 0;
- if (size_weight->axle_weight != -1 && profile->axle_weight != -1 && profile->axle_weight > size_weight->axle_weight)
- return 0;
- }
- return speed;
+static int route_seg_speed(struct vehicleprofile *profile, struct route_segment_data *over,
+ struct route_traffic_distortion *dist) {
+ struct roadprofile *roadprofile=vehicleprofile_get_roadprofile(profile, over->item.type);
+ int speed,maxspeed;
+ if (!roadprofile || !roadprofile->route_weight)
+ return 0;
+ speed=roadprofile->route_weight;
+ if (profile->maxspeed_handling != maxspeed_ignore) {
+ if (over->flags & AF_SPEED_LIMIT) {
+ maxspeed=RSD_MAXSPEED(over);
+ if (profile->maxspeed_handling == maxspeed_enforce)
+ speed=maxspeed;
+ } else
+ maxspeed=INT_MAX;
+ if (dist && maxspeed > dist->maxspeed)
+ maxspeed=dist->maxspeed;
+ if (maxspeed != INT_MAX && (profile->maxspeed_handling != maxspeed_restrict || maxspeed < speed))
+ speed=maxspeed;
+ }
+ if (over->flags & AF_DANGEROUS_GOODS) {
+ if (profile->dangerous_goods & RSD_DANGEROUS_GOODS(over))
+ return 0;
+ }
+ if (over->flags & AF_SIZE_OR_WEIGHT_LIMIT) {
+ struct size_weight_limit *size_weight=&RSD_SIZE_WEIGHT(over);
+ if (size_weight->width != -1 && profile->width != -1 && profile->width > size_weight->width)
+ return 0;
+ if (size_weight->height != -1 && profile->height != -1 && profile->height > size_weight->height)
+ return 0;
+ if (size_weight->length != -1 && profile->length != -1 && profile->length > size_weight->length)
+ return 0;
+ if (size_weight->weight != -1 && profile->weight != -1 && profile->weight > size_weight->weight)
+ return 0;
+ if (size_weight->axle_weight != -1 && profile->axle_weight != -1 && profile->axle_weight > size_weight->axle_weight)
+ return 0;
+ }
+ return speed;
}
/**
@@ -2056,228 +1923,542 @@ route_seg_speed(struct vehicleprofile *profile, struct route_segment_data *over,
* @return The time needed in tenths of seconds
*/
-static int
-route_time_seg(struct vehicleprofile *profile, struct route_segment_data *over, struct route_traffic_distortion *dist)
-{
- int speed=route_seg_speed(profile, over, dist);
- if (!speed)
- return INT_MAX;
- return over->len*36/speed+(dist ? dist->delay : 0);
+static int route_time_seg(struct vehicleprofile *profile, struct route_segment_data *over,
+ struct route_traffic_distortion *dist) {
+ int speed=route_seg_speed(profile, over, dist);
+ if (!speed)
+ return INT_MAX;
+ return over->len*36/speed+(dist ? dist->delay : 0);
}
/**
* @brief Returns the traffic distortion for a segment.
*
+ * If multiple traffic distortions match a segment, the return value will report the lowest speed limit
+ * and greatest delay of all matching segments.
+ *
* @param seg The segment for which the traffic distortion is to be returned
- * @param ret Points to a {@code struct route_traffic_distortion}, whose members will be filled
+ * @param dir The direction of `seg` for which to return traffic distortions. Positive values indicate
+ * travel in the direction of the segment, negative values indicate travel against it.
+ * @param profile The current vehicle profile
+ * @param ret Points to a {@code struct route_traffic_distortion}, whose members will be filled with the
+ * distortion data
*
* @return true if a traffic distortion was found, 0 if not
*/
-static int
-route_get_traffic_distortion(struct route_graph_segment *seg, struct route_traffic_distortion *ret)
-{
- struct route_graph_point *start=seg->start;
- struct route_graph_point *end=seg->end;
- struct route_graph_segment *tmp,*found=NULL;
- tmp=start->start;
- while (tmp && !found) {
- if (tmp->data.item.type == type_traffic_distortion && tmp->start == start && tmp->end == end)
- found=tmp;
- tmp=tmp->start_next;
- }
- tmp=start->end;
- while (tmp && !found) {
- if (tmp->data.item.type == type_traffic_distortion && tmp->end == start && tmp->start == end)
- found=tmp;
- tmp=tmp->end_next;
- }
- if (found) {
- ret->delay=found->data.len;
- if (found->data.flags & AF_SPEED_LIMIT)
- ret->maxspeed=RSD_MAXSPEED(&found->data);
- else
- ret->maxspeed=INT_MAX;
- return 1;
- }
- return 0;
-}
-
-static int
-route_through_traffic_allowed(struct vehicleprofile *profile, struct route_graph_segment *seg)
-{
- return (seg->data.flags & AF_THROUGH_TRAFFIC_LIMIT) == 0;
+static int route_get_traffic_distortion(struct route_graph_segment *seg, int dir, struct vehicleprofile *profile,
+ struct route_traffic_distortion *ret) {
+ struct route_graph_point *start=seg->start;
+ struct route_graph_point *end=seg->end;
+ struct route_graph_segment *tmp,*found=NULL;
+ struct route_traffic_distortion result;
+
+ if (!dir) {
+ dbg(lvl_warning, "dir is zero, assuming positive");
+ dir = 1;
+ }
+
+ result.delay = 0;
+ result.maxspeed = INT_MAX;
+
+ for (tmp = start->start; tmp; tmp = tmp->start_next) {
+ if (tmp->data.item.type == type_traffic_distortion && tmp->start == start && tmp->end == end) {
+ if ((tmp->data.flags & (dir > 0 ? profile->flags_forward_mask : profile->flags_reverse_mask)) != profile->flags)
+ continue;
+ if (tmp->data.len > result.delay)
+ result.delay = tmp->data.len;
+ if ((tmp->data.flags & AF_SPEED_LIMIT) && (RSD_MAXSPEED(&tmp->data) < result.maxspeed))
+ result.maxspeed = RSD_MAXSPEED(&tmp->data);
+ found=tmp;
+ }
+ }
+ for (tmp = start->end; tmp; tmp = tmp->end_next) {
+ if (tmp->data.item.type == type_traffic_distortion && tmp->end == start && tmp->start == end) {
+ if ((tmp->data.flags & (dir < 0 ? profile->flags_forward_mask : profile->flags_reverse_mask)) != profile->flags)
+ continue;
+ if (tmp->data.len > result.delay)
+ result.delay = tmp->data.len;
+ if ((tmp->data.flags & AF_SPEED_LIMIT) && (RSD_MAXSPEED(&tmp->data) < result.maxspeed))
+ result.maxspeed = RSD_MAXSPEED(&tmp->data);
+ found=tmp;
+ }
+ }
+ if (found) {
+ ret->delay = result.delay;
+ ret->maxspeed = result.maxspeed;
+ return 1;
+ }
+ return 0;
+}
+
+static int route_through_traffic_allowed(struct vehicleprofile *profile, struct route_graph_segment *seg) {
+ return (seg->data.flags & AF_THROUGH_TRAFFIC_LIMIT) == 0;
}
/**
- * @brief Returns the "cost" of driving from point {@code from} along segment {@code over} in direction {@code dir}
+ * @brief Returns the "cost" of traveling along segment `over` in direction `dir`
*
* Cost is relative to time, indicated in tenths of seconds.
*
- * This function considers traffic distortions as well as penalties. If the segment is impassable
- * due to traffic distortions or restrictions, {@code INT_MAX} is returned in order to prevent use
- * of this segment for routing.
+ * This function considers traffic distortions as well as penalties. If the segment is impassable due to traffic
+ * distortions or restrictions, `INT_MAX` is returned in order to prevent use of this segment for routing.
+ *
+ * If `from` is specified, it must be the point at which we leave the segment (`over->end` if `dir` is positive,
+ * `over->start` if `dir` is negative); anything else will produce invalid results. If `from` is non-NULL, additional
+ * checks are done on `from->seg` (the next segment to follow after `over`):
+ * \li If `from->seg` equals `over` (indicating that, after traversing `over` in direction `dir`, we would immediately
+ * traverse it again in the opposite direction), `INT_MAX` is returned.
+ * \li If `over` loops back to itself (i.e. its `start` and `end` members are equal), `INT_MAX` is returned.
+ * \li Otherwise, if `over` does not allow through traffic but `from->seg` does, the through traffic penalty of the
+ * vehicle profile (`profile`) is applied.
*
* @param profile The routing preferences
- * @param from The point where we are starting
+ * @param from The point currently being visited (or NULL), see description
* @param over The segment we are using
- * @param dir The direction of segment which we are driving. Positive values indicate we are
- * traveling in the direction of the segment, negative values indicate we are traveling against
- * that direction. Values of +2 or -2 cause the function to ignore traffic distortions.
+ * @param dir The direction of segment which we are traveling. Positive values indicate we are traveling in the
+ * direction of the segment (from `over->start` to `over->end`), negative values indicate we are traveling in the
+ * opposite direction. Values of +2 or -2 cause the function to ignore traffic distortions.
*
* @return The "cost" needed to travel along the segment
- */
-
-static int
-route_value_seg(struct vehicleprofile *profile, struct route_graph_point *from, struct route_graph_segment *over, int dir)
-{
- int ret;
- struct route_traffic_distortion dist,*distp=NULL;
-#if 0
- dbg(lvl_debug,"flags 0x%x mask 0x%x flags 0x%x\n", over->flags, dir >= 0 ? profile->flags_forward_mask : profile->flags_reverse_mask, profile->flags);
-#endif
- if ((over->data.flags & (dir >= 0 ? profile->flags_forward_mask : profile->flags_reverse_mask)) != profile->flags)
- return INT_MAX;
- if (dir > 0 && (over->start->flags & RP_TURN_RESTRICTION))
- return INT_MAX;
- if (dir < 0 && (over->end->flags & RP_TURN_RESTRICTION))
- return INT_MAX;
- if (from && from->seg == over)
- return INT_MAX;
- if ((over->start->flags & RP_TRAFFIC_DISTORTION) && (over->end->flags & RP_TRAFFIC_DISTORTION) &&
- route_get_traffic_distortion(over, &dist) && dir != 2 && dir != -2) {
- distp=&dist;
- }
- ret=route_time_seg(profile, &over->data, distp);
- if (ret == INT_MAX)
- return ret;
- if (!route_through_traffic_allowed(profile, over) && from && route_through_traffic_allowed(profile, from->seg))
- ret+=profile->through_traffic_penalty;
- return ret;
-}
-
-static int
-route_graph_segment_match(struct route_graph_segment *s1, struct route_graph_segment *s2)
-{
- if (!s1 || !s2)
- return 0;
- return (s1->start->c.x == s2->start->c.x && s1->start->c.y == s2->start->c.y &&
- s1->end->c.x == s2->end->c.x && s1->end->c.y == s2->end->c.y);
+ */
+/* FIXME `from` as a name is highly misleading, find a better one */
+static int route_value_seg(struct vehicleprofile *profile, struct route_graph_point *from,
+ struct route_graph_segment *over,
+ int dir) {
+ int ret;
+ struct route_traffic_distortion dist,*distp=NULL;
+ if (!dir) {
+ dbg(lvl_warning, "dir is zero, assuming positive");
+ dir = 1;
+ }
+ if (from && (over->start == over->end))
+ return INT_MAX;
+ if ((over->data.flags & (dir >= 0 ? profile->flags_forward_mask : profile->flags_reverse_mask)) != profile->flags)
+ return INT_MAX;
+ if (dir > 0 && (over->start->flags & RP_TURN_RESTRICTION))
+ return INT_MAX;
+ if (dir < 0 && (over->end->flags & RP_TURN_RESTRICTION))
+ return INT_MAX;
+ if (from && from->seg == over)
+ return INT_MAX;
+ if (over->data.item.type == type_traffic_distortion)
+ return INT_MAX;
+ if ((over->start->flags & RP_TRAFFIC_DISTORTION) && (over->end->flags & RP_TRAFFIC_DISTORTION) &&
+ route_get_traffic_distortion(over, dir, profile, &dist) && dir != 2 && dir != -2) {
+ /* we have a traffic distortion */
+ distp=&dist;
+ }
+ ret=route_time_seg(profile, &over->data, distp);
+ if (ret == INT_MAX)
+ return ret;
+ if (!route_through_traffic_allowed(profile, over) && from && from->seg
+ && route_through_traffic_allowed(profile, from->seg))
+ ret+=profile->through_traffic_penalty;
+ return ret;
+}
+
+/**
+ * @brief Whether two route graph segments match.
+ *
+ * Two segments match if both start and end at the exact same points. Other points are not considered.
+ *
+ * @param s1 The first segment
+ * @param s2 The second segment
+ * @return true if both segments match, false if not
+ */
+static int route_graph_segment_match(struct route_graph_segment *s1, struct route_graph_segment *s2) {
+ if (!s1 || !s2)
+ return 0;
+ return (s1->start->c.x == s2->start->c.x && s1->start->c.y == s2->start->c.y &&
+ s1->end->c.x == s2->end->c.x && s1->end->c.y == s2->end->c.y);
+}
+
+/**
+ * @brief Adds two route values with protection against integer overflows.
+ *
+ * Unlike regular addition, this function is safe to use if one of the two arguments is `INT_MAX`
+ * (which Navit uses to express that a segment cannot be traversed or a point cannot be reached):
+ * If any of the two arguments is `INT_MAX`, then `INT_MAX` is returned; else the sum of the two
+ * arguments is returned.
+ *
+ * Note that this currently does not cover cases in which both arguments are less than `INT_MAX` but add
+ * up to `val1 + val2 >= INT_MAX`. With Navit’s internal cost definition, `INT_MAX` (2^31) is equivalent
+ * to approximately 7 years, making this unlikely to become a real issue.
+ */
+static int route_value_add(int val1, int val2) {
+ if (val1 == INT_MAX)
+ return INT_MAX;
+ if (val2 == INT_MAX)
+ return INT_MAX;
+ return val1 + val2;
+}
+
+/**
+ * @brief Updates the lookahead value of a point in the route graph and updates its heap membership.
+ *
+ * This recalculates the lookahead value (the `rhs` member) of point `p`, based on the `value` of each neighbor and the
+ * cost to reach that neighbor. If the resulting `p->rhs` differs from `p->value`, `p` is inserted into `heap` using
+ * the lower of the two as its key (if `p` is already a member of `heap`, its key is changed accordingly). If the
+ * resulting `p->rhs` is equal to `p->value` and `p` is a member of `heap`, it is removed.
+ *
+ * This is part of a modified LPA* implementation.
+ *
+ * @param profile The vehicle profile to use for routing. This determines which ways are passable and how their costs
+ * are calculated.
+ * @param p The point to evaluate
+ * @param heap The heap
+ */
+static void route_graph_point_update(struct vehicleprofile *profile, struct route_graph_point * p,
+ struct fibheap * heap) {
+ struct route_graph_segment *s = NULL;
+ int new, val;
+
+ p->rhs = p->dst_val;
+ p->seg = p->dst_seg;
+
+ for (s = p->start; s; s = s->start_next) { /* Iterate over all the segments leading away from our point */
+ val = route_value_seg(profile, s->end, s, 1);
+ if (val != INT_MAX && s->end->seg && item_is_equal(s->data.item, s->end->seg->data.item)) {
+ if (profile->turn_around_penalty2)
+ val += profile->turn_around_penalty2;
+ else
+ val = INT_MAX;
+ }
+ if (val != INT_MAX) {
+ new = route_value_add(val, s->end->value);
+ if (new < p->rhs) {
+ p->rhs = new;
+ p->seg = s;
+ }
+ }
+ }
+
+ for (s = p->end; s; s = s->end_next) { /* Iterate over all the segments leading towards our point */
+ val = route_value_seg(profile, s->start, s, -1);
+ if (val != INT_MAX && s->start->seg && item_is_equal(s->data.item, s->start->seg->data.item)) {
+ if (profile->turn_around_penalty2)
+ val += profile->turn_around_penalty2;
+ else
+ val = INT_MAX;
+ }
+ if (val != INT_MAX) {
+ new = route_value_add(val, s->start->value);
+ if (new < p->rhs) {
+ p->rhs = new;
+ p->seg = s;
+ }
+ }
+ }
+
+ if (p->el) {
+ /* Due to a limitation of the Fibonacci heap implementation, which causes fh_replacekey() to fail if the new
+ * key is greater than the current one, we always remove the point from the heap (and, if locally inconsistent,
+ * re-add it afterwards). */
+ fh_delete(heap, p->el);
+ p->el = NULL;
+ }
+
+ if (p->rhs != p->value)
+ /* The point is locally inconsistent, add (or re-add) it to the heap */
+ p->el = fh_insertkey(heap, MIN(p->rhs, p->value), p);
+}
+
+/**
+ * @brief Expands (i.e. calculates the costs for) the points on the route graph’s heap.
+ *
+ * This calculates the cost for every point on the route graph’s heap, as well as any neighbors affected by the cost
+ * change, and sets the next segment.
+ *
+ * This is part of a modified LPA* implementation.
+ *
+ * @param graph The route graph
+ * @param profile The vehicle profile to use for routing. This determines which ways are passable and how their costs
+ * are calculated.
+ * @param cb The callback function to call when flooding is complete (can be NULL)
+ */
+static void route_graph_compute_shortest_path(struct route_graph * graph, struct vehicleprofile * profile,
+ struct callback *cb) {
+ struct route_graph_point *p_min;
+ struct route_graph_segment *s = NULL;
+
+ while (!route_graph_is_path_computed(graph) && (p_min = fh_extractmin(graph->heap))) {
+ p_min->el = NULL;
+ if (p_min->value > p_min->rhs)
+ /* cost has decreased, update point value */
+ p_min->value = p_min->rhs;
+ else {
+ /* cost has increased, re-evaluate */
+ p_min->value = INT_MAX;
+ route_graph_point_update(profile, p_min, graph->heap);
+ }
+
+ /* in any case, update rhs of predecessors (nodes from which we can reach p_min via a single segment) */
+ for (s = p_min->start; s; s = s->start_next)
+ if ((s->start == s->end) || (s->data.item.type < route_item_first) || (s->data.item.type > route_item_last))
+ continue;
+ else if (route_value_seg(profile, NULL, s, -2) != INT_MAX)
+ route_graph_point_update(profile, s->end, graph->heap);
+ for (s = p_min->end; s; s = s->end_next)
+ if ((s->start == s->end) || (s->data.item.type < route_item_first) || (s->data.item.type > route_item_last))
+ continue;
+ else if (route_value_seg(profile, NULL, s, 2) != INT_MAX)
+ route_graph_point_update(profile, s->start, graph->heap);
+ }
+ if (cb)
+ callback_call_0(cb);
}
/**
* @brief Sets or clears a traffic distortion for a segment.
*
- * This sets or clears a delay. It cannot be used to set speed.
+ * This sets a delay (setting speed is not supported) or clears an existing traffic distortion.
+ * Note that, although setting a speed is not supported, calling this function with a delay of 0
+ * will also clear an existing speed constraint.
*
* @param this The route graph
* @param seg The segment to which the traffic distortion applies
- * @param delay Delay in tenths of a second
+ * @param delay Delay in tenths of a second, or 0 to clear an existing traffic distortion
*/
-static void
-route_graph_set_traffic_distortion(struct route_graph *this, struct route_graph_segment *seg, int delay)
-{
- struct route_graph_point *start=NULL;
- struct route_graph_segment *s;
-
- while ((start=route_graph_get_point_next(this, &seg->start->c, start))) {
- s=start->start;
- while (s) {
- if (route_graph_segment_match(s, seg)) {
- if (s->data.item.type != type_none && s->data.item.type != type_traffic_distortion && delay) {
- struct route_graph_segment_data data;
- struct item item;
- memset(&data, 0, sizeof(data));
- memset(&item, 0, sizeof(item));
- item.type=type_traffic_distortion;
- data.item=&item;
- data.len=delay;
- s->start->flags |= RP_TRAFFIC_DISTORTION;
- s->end->flags |= RP_TRAFFIC_DISTORTION;
- route_graph_add_segment(this, s->start, s->end, &data);
- } else if (s->data.item.type == type_traffic_distortion && !delay) {
- s->data.item.type = type_none;
- }
- }
- s=s->start_next;
- }
- }
+static void route_graph_set_traffic_distortion(struct route_graph *this, struct route_graph_segment *seg, int delay) {
+ struct route_graph_point *start=NULL;
+ struct route_graph_segment *s;
+
+ while ((start=route_graph_get_point_next(this, &seg->start->c, start))) {
+ s=start->start;
+ while (s) {
+ if (route_graph_segment_match(s, seg)) {
+ if (s->data.item.type != type_none && s->data.item.type != type_traffic_distortion && delay) {
+ struct route_graph_segment_data data;
+ struct item item;
+ memset(&data, 0, sizeof(data));
+ memset(&item, 0, sizeof(item));
+ item.type=type_traffic_distortion;
+ data.item=&item;
+ data.len=delay;
+ data.flags = seg->data.flags & AF_DISTORTIONMASK;
+ s->start->flags |= RP_TRAFFIC_DISTORTION;
+ s->end->flags |= RP_TRAFFIC_DISTORTION;
+ route_graph_add_segment(this, s->start, s->end, &data);
+ } else if (s->data.item.type == type_traffic_distortion && !delay) {
+ s->data.item.type = type_none;
+ }
+ }
+ s=s->start_next;
+ }
+ }
}
/**
- * @brief Adds a route distortion item to the route graph
+ * @brief Adds a traffic distortion item to the route graph
*
* @param this The route graph to add to
- * @param item The item to add
+ * @param profile The vehicle profile to use for cost calculations
+ * @param item The item to add, must be of {@code type_traffic_distortion}
+ * @param update Whether to update the point (true for LPA*, false for Dijkstra)
+ */
+static void route_graph_add_traffic_distortion(struct route_graph *this, struct vehicleprofile *profile,
+ struct item *item, int update) {
+ struct route_graph_point *s_pnt,*e_pnt;
+ struct coord c,l;
+ struct attr flags_attr, delay_attr, maxspeed_attr;
+ struct route_graph_segment_data data;
+
+ data.item=item;
+ data.len=0;
+ data.offset=1;
+ data.maxspeed = INT_MAX;
+
+ item_attr_rewind(item);
+ if (item_attr_get(item, attr_flags, &flags_attr))
+ data.flags = flags_attr.u.num & AF_DISTORTIONMASK;
+ else
+ data.flags = 0;
+
+ item_coord_rewind(item);
+ if (item_coord_get(item, &l, 1)) {
+ s_pnt=route_graph_add_point(this,&l);
+ while (item_coord_get(item, &c, 1)) {
+ l=c;
+ }
+ e_pnt=route_graph_add_point(this,&l);
+ s_pnt->flags |= RP_TRAFFIC_DISTORTION;
+ e_pnt->flags |= RP_TRAFFIC_DISTORTION;
+ if (item_attr_get(item, attr_maxspeed, &maxspeed_attr)) {
+ data.flags |= AF_SPEED_LIMIT;
+ data.maxspeed=maxspeed_attr.u.num;
+ }
+ if (item_attr_get(item, attr_delay, &delay_attr))
+ data.len=delay_attr.u.num;
+ route_graph_add_segment(this, s_pnt, e_pnt, &data);
+ if (update) {
+ if (!(data.flags & AF_ONEWAYREV))
+ route_graph_point_update(profile, s_pnt, this->heap);
+ if (!(data.flags & AF_ONEWAY))
+ route_graph_point_update(profile, e_pnt, this->heap);
+ }
+ }
+}
+
+/**
+ * @brief Removes a traffic distortion item from the route graph
+ *
+ * Removing a traffic distortion which is not in the graph is a no-op.
+ *
+ * @param this The route graph to remove from
+ * @param profile The vehicle profile to use for cost calculations
+ * @param item The item to remove, must be of {@code type_traffic_distortion}
+ */
+static void route_graph_remove_traffic_distortion(struct route_graph *this, struct vehicleprofile *profile,
+ struct item *item) {
+ struct route_graph_point *s_pnt = NULL, *e_pnt = NULL;
+ struct coord c, l;
+ struct route_graph_segment *curr;
+
+ item_coord_rewind(item);
+ if (item_coord_get(item, &l, 1)) {
+ s_pnt = route_graph_get_point(this, &l);
+ while (item_coord_get(item, &c, 1))
+ l = c;
+ e_pnt = route_graph_get_point(this, &l);
+ }
+ if (s_pnt && e_pnt) {
+#if 1
+ curr = s_pnt->start;
+ s_pnt->flags &= ~RP_TRAFFIC_DISTORTION;
+ for (curr = s_pnt->start; curr; curr = curr->start_next) {
+ if ((curr->end == e_pnt) && item_is_equal(curr->data.item, *item))
+ curr->data.item.type = type_none;
+ else if (curr->data.item.type == type_traffic_distortion)
+ s_pnt->flags |= RP_TRAFFIC_DISTORTION;
+ }
+
+ e_pnt->flags &= ~RP_TRAFFIC_DISTORTION;
+ for (curr = e_pnt->end; curr; curr = curr->end_next)
+ if (curr->data.item.type == type_traffic_distortion)
+ e_pnt->flags |= RP_TRAFFIC_DISTORTION;
+#else
+ struct route_graph_segment *found = NULL, *prev;
+ /* this frees up memory but is slower */
+ /* remove from global list */
+ curr = this->route_segments;
+ prev = NULL;
+ while (curr && !found) {
+ if ((curr->start == s_pnt) && (curr->end == e_pnt) && (curr->data.item == item)) {
+ if (prev)
+ prev->next = curr->next;
+ else
+ this->route_segments = curr->next;
+ found = curr;
+ } else {
+ prev = curr;
+ curr = prev->next;
+ }
+ }
+
+ if (!found)
+ return;
+
+ /* remove from s_pnt list */
+ curr = s_pnt->start;
+ prev = NULL;
+ s_pnt->flags &= ~RP_TRAFFIC_DISTORTION;
+ while (curr) {
+ if (curr == found) {
+ if (prev)
+ prev->start_next = curr->start_next;
+ else
+ s_pnt->start = curr->start_next;
+ } else {
+ if (curr->data.item.type == type_traffic_distortion)
+ s_pnt->flags |= RP_TRAFFIC_DISTORTION;
+ prev = curr;
+ }
+ curr = prev->start_next;
+ }
+
+ /* remove from e_pnt list */
+ curr = e_pnt->end;
+ prev = NULL;
+ e_pnt->flags &= ~RP_TRAFFIC_DISTORTION;
+ while (curr) {
+ if (curr == found) {
+ if (prev)
+ prev->end_next = curr->end_next;
+ else
+ s_pnt->end = curr->end_next;
+ } else {
+ if (curr->data.item.type == type_traffic_distortion)
+ e_pnt->flags |= RP_TRAFFIC_DISTORTION;
+ prev = curr;
+ }
+ curr = prev->end_next;
+ }
+
+ size = sizeof(struct route_graph_segment) - sizeof(struct route_segment_data)
+ + route_segment_data_size(found->data.flags);
+ g_slice_free1(size, found);
+#endif
+
+ /* TODO figure out if we need to update both points */
+ route_graph_point_update(profile, s_pnt, this->heap);
+ route_graph_point_update(profile, e_pnt, this->heap);
+ }
+}
+
+/**
+ * @brief Changes a traffic distortion item in the route graph
+ *
+ * Attempting to change an idem which is not in the route graph will add it.
+ *
+ * @param this The route graph to change
+ * @param profile The vehicle profile to use for cost calculations
+ * @param item The item to change, must be of {@code type_traffic_distortion}
*/
-static void
-route_process_traffic_distortion(struct route_graph *this, struct item *item)
-{
- struct route_graph_point *s_pnt,*e_pnt;
- struct coord c,l;
- struct attr delay_attr, maxspeed_attr;
- struct route_graph_segment_data data;
-
- data.item=item;
- data.len=0;
- data.flags=0;
- data.offset=1;
- data.maxspeed = INT_MAX;
-
- if (item_coord_get(item, &l, 1)) {
- s_pnt=route_graph_add_point(this,&l);
- while (item_coord_get(item, &c, 1)) {
- l=c;
- }
- e_pnt=route_graph_add_point(this,&l);
- s_pnt->flags |= RP_TRAFFIC_DISTORTION;
- e_pnt->flags |= RP_TRAFFIC_DISTORTION;
- if (item_attr_get(item, attr_maxspeed, &maxspeed_attr)) {
- data.flags |= AF_SPEED_LIMIT;
- data.maxspeed=maxspeed_attr.u.num;
- }
- if (item_attr_get(item, attr_delay, &delay_attr))
- data.len=delay_attr.u.num;
- route_graph_add_segment(this, s_pnt, e_pnt, &data);
- }
+static void route_graph_change_traffic_distortion(struct route_graph *this, struct vehicleprofile *profile,
+ struct item *item) {
+ /* TODO is there a more elegant way of doing this? */
+ route_graph_remove_traffic_distortion(this, profile, item);
+ route_graph_add_traffic_distortion(this, profile, item, 1);
}
/**
* @brief Adds a turn restriction item to the route graph
*
* @param this The route graph to add to
- * @param item The item to add
+ * @param item The item to add, must be of `type_street_turn_restriction_no` or `type_street_turn_restriction_only`
*/
-static void
-route_process_turn_restriction(struct route_graph *this, struct item *item)
-{
- struct route_graph_point *pnt[4];
- struct coord c[5];
- int i,count;
- struct route_graph_segment_data data;
-
- count=item_coord_get(item, c, 5);
- if (count != 3 && count != 4) {
- dbg(lvl_debug,"wrong count %d\n",count);
- return;
- }
- if (count == 4)
- return;
- for (i = 0 ; i < count ; i++)
- pnt[i]=route_graph_add_point(this,&c[i]);
- dbg(lvl_debug,"%s: (0x%x,0x%x)-(0x%x,0x%x)-(0x%x,0x%x) %p-%p-%p\n",item_to_name(item->type),c[0].x,c[0].y,c[1].x,c[1].y,c[2].x,c[2].y,pnt[0],pnt[1],pnt[2]);
- data.item=item;
- data.flags=0;
- data.len=0;
- route_graph_add_segment(this, pnt[0], pnt[1], &data);
- route_graph_add_segment(this, pnt[1], pnt[2], &data);
+void route_graph_add_turn_restriction(struct route_graph *this, struct item *item) {
+ struct route_graph_point *pnt[4];
+ struct coord c[5];
+ int i,count;
+ struct route_graph_segment_data data;
+
+ item_coord_rewind(item);
+ count=item_coord_get(item, c, 5);
+ if (count != 3 && count != 4) {
+ dbg(lvl_debug,"wrong count %d",count);
+ return;
+ }
+ if (count == 4)
+ return;
+ for (i = 0 ; i < count ; i++)
+ pnt[i]=route_graph_add_point(this,&c[i]);
+ dbg(lvl_debug,"%s: (0x%x,0x%x)-(0x%x,0x%x)-(0x%x,0x%x) %p-%p-%p",item_to_name(item->type),c[0].x,c[0].y,c[1].x,c[1].y,
+ c[2].x,c[2].y,pnt[0],pnt[1],pnt[2]);
+ data.item=item;
+ data.flags=0;
+ data.len=0;
+ data.score = 0;
+ route_graph_add_segment(this, pnt[0], pnt[1], &data);
+ route_graph_add_segment(this, pnt[1], pnt[2], &data);
#if 1
- if (count == 4) {
- pnt[1]->flags |= RP_TURN_RESTRICTION;
- pnt[2]->flags |= RP_TURN_RESTRICTION;
- route_graph_add_segment(this, pnt[2], pnt[3], &data);
- } else
- pnt[1]->flags |= RP_TURN_RESTRICTION;
-#endif
+ if (count == 4) {
+ pnt[1]->flags |= RP_TURN_RESTRICTION;
+ pnt[2]->flags |= RP_TURN_RESTRICTION;
+ route_graph_add_segment(this, pnt[2], pnt[3], &data);
+ } else
+ pnt[1]->flags |= RP_TURN_RESTRICTION;
+#endif
}
/**
@@ -2290,116 +2471,111 @@ route_process_turn_restriction(struct route_graph *this, struct item *item)
* @param item The item to add
* @param profile The vehicle profile currently in use
*/
-static void
-route_process_street_graph(struct route_graph *this, struct item *item, struct vehicleprofile *profile)
-{
+static void route_graph_add_street(struct route_graph *this, struct item *item, struct vehicleprofile *profile) {
#ifdef AVOID_FLOAT
- int len=0;
+ int len=0;
#else
- double len=0;
+ double len=0;
#endif
- int segmented = 0;
- struct roadprofile *roadp;
- struct route_graph_point *s_pnt,*e_pnt; /* Start and end point */
- struct coord c,l; /* Current and previous point */
- struct attr attr;
- struct route_graph_segment_data data;
- data.flags=0;
- data.offset=1;
- data.maxspeed=-1;
- data.item=item;
-
- roadp = vehicleprofile_get_roadprofile(profile, item->type);
- if (!roadp) {
- /* Don't include any roads that don't have a road profile in our vehicle profile */
- return;
- }
-
- if (item_coord_get(item, &l, 1)) {
- int default_flags_value=AF_ALL;
- int *default_flags=item_get_default_flags(item->type);
- if (! default_flags)
- default_flags=&default_flags_value;
- if (item_attr_get(item, attr_flags, &attr)) {
- data.flags = attr.u.num;
- if (data.flags & AF_SEGMENTED)
- segmented = 1;
- } else
- data.flags = *default_flags;
-
-
- if (data.flags & AF_SPEED_LIMIT) {
- if (item_attr_get(item, attr_maxspeed, &attr))
- data.maxspeed = attr.u.num;
- }
- if (data.flags & AF_DANGEROUS_GOODS) {
- if (item_attr_get(item, attr_vehicle_dangerous_goods, &attr))
- data.dangerous_goods = attr.u.num;
- else
- data.flags &= ~AF_DANGEROUS_GOODS;
- }
- if (data.flags & AF_SIZE_OR_WEIGHT_LIMIT) {
- if (item_attr_get(item, attr_vehicle_width, &attr))
- data.size_weight.width=attr.u.num;
- else
- data.size_weight.width=-1;
- if (item_attr_get(item, attr_vehicle_height, &attr))
- data.size_weight.height=attr.u.num;
- else
- data.size_weight.height=-1;
- if (item_attr_get(item, attr_vehicle_length, &attr))
- data.size_weight.length=attr.u.num;
- else
- data.size_weight.length=-1;
- if (item_attr_get(item, attr_vehicle_weight, &attr))
- data.size_weight.weight=attr.u.num;
- else
- data.size_weight.weight=-1;
- if (item_attr_get(item, attr_vehicle_axle_weight, &attr))
- data.size_weight.axle_weight=attr.u.num;
- else
- data.size_weight.axle_weight=-1;
- }
-
- s_pnt=route_graph_add_point(this,&l);
- if (!segmented) {
- while (item_coord_get(item, &c, 1)) {
- len+=transform_distance(map_projection(item->map), &l, &c);
- l=c;
- }
- e_pnt=route_graph_add_point(this,&l);
- dbg_assert(len >= 0);
- data.len=len;
- if (!route_graph_segment_is_duplicate(s_pnt, &data))
- route_graph_add_segment(this, s_pnt, e_pnt, &data);
- } else {
- int isseg,rc;
- int sc = 0;
- do {
- isseg = item_coord_is_node(item);
- rc = item_coord_get(item, &c, 1);
- if (rc) {
- len+=transform_distance(map_projection(item->map), &l, &c);
- l=c;
- if (isseg) {
- e_pnt=route_graph_add_point(this,&l);
- data.len=len;
- if (!route_graph_segment_is_duplicate(s_pnt, &data))
- route_graph_add_segment(this, s_pnt, e_pnt, &data);
- data.offset++;
- s_pnt=route_graph_add_point(this,&l);
- len = 0;
- }
- }
- } while(rc);
- e_pnt=route_graph_add_point(this,&l);
- dbg_assert(len >= 0);
- sc++;
- data.len=len;
- if (!route_graph_segment_is_duplicate(s_pnt, &data))
- route_graph_add_segment(this, s_pnt, e_pnt, &data);
- }
- }
+ int segmented = 0;
+ struct roadprofile *roadp;
+ int default_flags_value = AF_ALL;
+ int *default_flags;
+ struct route_graph_point *s_pnt,*e_pnt; /* Start and end point */
+ struct coord c,l; /* Current and previous point */
+ struct attr attr;
+ struct route_graph_segment_data data;
+ data.flags=0;
+ data.offset=1;
+ data.maxspeed=-1;
+ data.item=item;
+
+ roadp = vehicleprofile_get_roadprofile(profile, item->type);
+ if (!roadp) {
+ /* Don't include any roads that don't have a road profile in our vehicle profile */
+ return;
+ }
+
+ item_coord_rewind(item);
+ if (item_coord_get(item, &l, 1)) {
+ if (!(default_flags = item_get_default_flags(item->type)))
+ default_flags = &default_flags_value;
+ if (item_attr_get(item, attr_flags, &attr)) {
+ data.flags = attr.u.num;
+ segmented = (data.flags & AF_SEGMENTED);
+ } else
+ data.flags = *default_flags;
+
+ if ((data.flags & AF_SPEED_LIMIT) && (item_attr_get(item, attr_maxspeed, &attr)))
+ data.maxspeed = attr.u.num;
+ if (data.flags & AF_DANGEROUS_GOODS) {
+ if (item_attr_get(item, attr_vehicle_dangerous_goods, &attr))
+ data.dangerous_goods = attr.u.num;
+ else
+ data.flags &= ~AF_DANGEROUS_GOODS;
+ }
+ if (data.flags & AF_SIZE_OR_WEIGHT_LIMIT) {
+ if (item_attr_get(item, attr_vehicle_width, &attr))
+ data.size_weight.width=attr.u.num;
+ else
+ data.size_weight.width=-1;
+ if (item_attr_get(item, attr_vehicle_height, &attr))
+ data.size_weight.height=attr.u.num;
+ else
+ data.size_weight.height=-1;
+ if (item_attr_get(item, attr_vehicle_length, &attr))
+ data.size_weight.length=attr.u.num;
+ else
+ data.size_weight.length=-1;
+ if (item_attr_get(item, attr_vehicle_weight, &attr))
+ data.size_weight.weight=attr.u.num;
+ else
+ data.size_weight.weight=-1;
+ if (item_attr_get(item, attr_vehicle_axle_weight, &attr))
+ data.size_weight.axle_weight=attr.u.num;
+ else
+ data.size_weight.axle_weight=-1;
+ }
+
+ s_pnt=route_graph_add_point(this,&l);
+ if (!segmented) {
+ while (item_coord_get(item, &c, 1)) {
+ len+=transform_distance(map_projection(item->map), &l, &c);
+ l=c;
+ }
+ e_pnt=route_graph_add_point(this,&l);
+ dbg_assert(len >= 0);
+ data.len=len;
+ if (!route_graph_segment_is_duplicate(s_pnt, &data))
+ route_graph_add_segment(this, s_pnt, e_pnt, &data);
+ } else {
+ int isseg,rc;
+ int sc = 0;
+ do {
+ isseg = item_coord_is_node(item);
+ rc = item_coord_get(item, &c, 1);
+ if (rc) {
+ len+=transform_distance(map_projection(item->map), &l, &c);
+ l=c;
+ if (isseg) {
+ e_pnt=route_graph_add_point(this,&l);
+ data.len=len;
+ if (!route_graph_segment_is_duplicate(s_pnt, &data))
+ route_graph_add_segment(this, s_pnt, e_pnt, &data);
+ data.offset++;
+ s_pnt=route_graph_add_point(this,&l);
+ len = 0;
+ }
+ }
+ } while(rc);
+ e_pnt=route_graph_add_point(this,&l);
+ dbg_assert(len >= 0);
+ sc++;
+ data.len=len;
+ if (!route_graph_segment_is_duplicate(s_pnt, &data))
+ route_graph_add_segment(this, s_pnt, e_pnt, &data);
+ }
+ }
}
/**
@@ -2412,154 +2588,109 @@ route_process_street_graph(struct route_graph *this, struct item *item, struct v
*
* @return The route graph segment, or {@code NULL} if none was found.
*/
-static struct route_graph_segment *
-route_graph_get_segment(struct route_graph *graph, struct street_data *sd, struct route_graph_segment *last)
-{
- struct route_graph_point *start=NULL;
- struct route_graph_segment *s;
- int seen=0;
-
- while ((start=route_graph_get_point_next(graph, &sd->c[0], start))) {
- s=start->start;
- while (s) {
- if (item_is_equal(sd->item, s->data.item)) {
- if (!last || seen)
- return s;
- if (last == s)
- seen=1;
- }
- s=s->start_next;
- }
- }
- return NULL;
+static struct route_graph_segment *route_graph_get_segment(struct route_graph *graph, struct street_data *sd,
+ struct route_graph_segment *last) {
+ struct route_graph_point *start=NULL;
+ struct route_graph_segment *s;
+ int seen=0;
+
+ while ((start=route_graph_get_point_next(graph, &sd->c[0], start))) {
+ s=start->start;
+ while (s) {
+ if (item_is_equal(sd->item, s->data.item)) {
+ if (!last || seen)
+ return s;
+ if (last == s)
+ seen=1;
+ }
+ s=s->start_next;
+ }
+ }
+ return NULL;
}
/**
- * @brief Calculates the routing costs for each point
+ * @brief Whether cost (re)calculation of route graph points has reached the start point
*
- * This function is the heart of routing. It assigns each point in the route graph a
- * cost at which one can reach the destination from this point on. Additionally it assigns
- * each point a segment one should follow from this point on to reach the destination at the
- * stated costs.
- *
- * This function uses Dijkstra's algorithm to do the routing. To understand it you should have a look
- * at this algorithm.
+ * This method serves as the exit criterion for cost calculation in our LPA* implementation. When it returns true, it
+ * means that calculation of node cost has proceeded far enough to determine the cost of, and cheapest path from, the
+ * start point.
*
- * References to elements of the route graph which were obtained prior to calling this function
- * remain valid after it returns.
+ * The current implementation returns true only when the heap is empty, i.e. all points have been calculated. This is
+ * not optimal in terms of efficiency, as the cost of the start point and the cheapest path from there no longer
+ * change during the last few cycles. Future versions may report true before the heap is completely empty, as soon as
+ * the cost of the start point and the cheapest path are final. However, this needs to be considered for recalculations
+ * which happen when the vehicle leaves the cheapest path: right now, any point in the route graph has its final cost
+ * and cheapest path, thus no recalculation is needed if the vehicle leaves the cheapest path. In the future, however,
+ * a (partial) recalculation may be needed if the vehicle deviates from the cheapest path.
*
- * @param this_ The route graph to flood
- * @param dst The destination of the route
- * @param profile The vehicle profile to use for routing. This determines which ways are passable
- * and how their costs are calculated.
- * @param cb The callback function to call when flooding is complete
+ * @param this_ The route graph
+ *
+ * @return true if calculation is complete, false if not
+ */
+static int route_graph_is_path_computed(struct route_graph *this_) {
+ /* TODO refine exit criterion */
+ if (!fh_min(this_->heap))
+ return 1;
+ else
+ return 0;
+}
+
+/**
+ * @brief Triggers partial recalculation of the route, based on the existing route graph.
+ *
+ * This is currently used when traffic distortions have been added, changed or removed. Future versions may also use
+ * it if the current position has changed to a portion of the route graph which has not been flooded (which is
+ * currently not necessary because the route graph is always flooded completely).
+ *
+ * This tends to be faster than full recalculation, as only a subset of all points in the graph needs to be evaluated.
+ *
+ * If segment costs have changed (as is the case with traffic distortions), all affected segments must have been added
+ * to, removed from or updated in the route graph before this method is called.
+ *
+ * After recalculation, the route path is updated.
+ *
+ * The function uses a modified LPA* algorithm for recalculations. Most modifications were made for compatibility with
+ * the algorithm used for the initial routing:
+ * \li The `value` of a node represents the cost to reach the destination and thus decreases along the route
+ * (eliminating the need for recalculations as the vehicle moves within the route graph)
+ * \li The heuristic is always assumed to be zero (which would turn A* into Dijkstra, the basis of the main routing
+ * algorithm, and makes our keys one-dimensional)
+ * \li Currently, each pass evaluates all locally inconsistent points, leaving an empty heap at the end (though this
+ * may change in the future).
+ *
+ * @param this_ The route
*/
-static void
-route_graph_flood(struct route_graph *this, struct route_info *dst, struct vehicleprofile *profile, struct callback *cb)
-{
- struct route_graph_point *p_min;
- struct route_graph_segment *s=NULL;
- int min,new,val;
- struct fibheap *heap; /* This heap will hold all points with "temporarily" calculated costs */
-
- heap = fh_makekeyheap();
-
- while ((s=route_graph_get_segment(this, dst->street, s))) {
- val=route_value_seg(profile, NULL, s, -1);
- if (val != INT_MAX) {
- val=val*(100-dst->percent)/100;
- s->end->seg=s;
- s->end->value=val;
- s->end->el=fh_insertkey(heap, s->end->value, s->end);
- }
- val=route_value_seg(profile, NULL, s, 1);
- if (val != INT_MAX) {
- val=val*dst->percent/100;
- s->start->seg=s;
- s->start->value=val;
- s->start->el=fh_insertkey(heap, s->start->value, s->start);
- }
- }
- for (;;) {
- p_min=fh_extractmin(heap); /* Starting Dijkstra by selecting the point with the minimum costs on the heap */
- if (! p_min) /* There are no more points with temporarily calculated costs, Dijkstra has finished */
- break;
- min=p_min->value;
- if (debug_route)
- printf("extract p=%p free el=%p min=%d, 0x%x, 0x%x\n", p_min, p_min->el, min, p_min->c.x, p_min->c.y);
- p_min->el=NULL; /* This point is permanently calculated now, we've taken it out of the heap */
- s=p_min->start;
- while (s) { /* Iterating all the segments leading away from our point to update the points at their ends */
- val=route_value_seg(profile, p_min, s, -1);
- if (val != INT_MAX && item_is_equal(s->data.item,p_min->seg->data.item)) {
- if (profile->turn_around_penalty2)
- val+=profile->turn_around_penalty2;
- else
- val=INT_MAX;
- }
- if (val != INT_MAX) {
- new=min+val;
- if (debug_route)
- printf("begin %d len %d vs %d (0x%x,0x%x)\n",new,val,s->end->value, s->end->c.x, s->end->c.y);
- if (new < s->end->value) { /* We've found a less costly way to reach the end of s, update it */
- s->end->value=new;
- s->end->seg=s;
- if (! s->end->el) {
- if (debug_route)
- printf("insert_end p=%p el=%p val=%d ", s->end, s->end->el, s->end->value);
- s->end->el=fh_insertkey(heap, new, s->end);
- if (debug_route)
- printf("el new=%p\n", s->end->el);
- }
- else {
- if (debug_route)
- printf("replace_end p=%p el=%p val=%d\n", s->end, s->end->el, s->end->value);
- fh_replacekey(heap, s->end->el, new);
- }
- }
- if (debug_route)
- printf("\n");
- }
- s=s->start_next;
- }
- s=p_min->end;
- while (s) { /* Doing the same as above with the segments leading towards our point */
- val=route_value_seg(profile, p_min, s, 1);
- if (val != INT_MAX && item_is_equal(s->data.item,p_min->seg->data.item)) {
- if (profile->turn_around_penalty2)
- val+=profile->turn_around_penalty2;
- else
- val=INT_MAX;
- }
- if (val != INT_MAX) {
- new=min+val;
- if (debug_route)
- printf("end %d len %d vs %d (0x%x,0x%x)\n",new,val,s->start->value,s->start->c.x, s->start->c.y);
- if (new < s->start->value) {
- s->start->value=new;
- s->start->seg=s;
- if (! s->start->el) {
- if (debug_route)
- printf("insert_start p=%p el=%p val=%d ", s->start, s->start->el, s->start->value);
- s->start->el=fh_insertkey(heap, new, s->start);
- if (debug_route)
- printf("el new=%p\n", s->start->el);
- }
- else {
- if (debug_route)
- printf("replace_start p=%p el=%p val=%d\n", s->start, s->start->el, s->start->value);
- fh_replacekey(heap, s->start->el, new);
- }
- }
- if (debug_route)
- printf("\n");
- }
- s=s->end_next;
- }
- }
- fh_deleteheap(heap);
- callback_call_0(cb);
- dbg(lvl_debug,"return\n");
+/* TODO This is absolutely not thread-safe and will wreak havoc if run concurrently with route_graph_flood(). This is
+ * not an issue as long as the two never overlap: Currently both this function and route_graph_flood() run without
+ * interruption until they finish, and are both on the main thread. If that changes, we need to revisit this. */
+void route_recalculate_partial(struct route *this_) {
+ struct attr route_status;
+
+ /* do nothing if we don’t have a route graph */
+ if (!route_has_graph(this_))
+ return;
+
+ /* if the route graph is still being built, it will be calculated from scratch after that, nothing to do here */
+ if (this_->graph->busy)
+ return;
+
+ /* exit if there is no need to recalculate */
+ if (route_graph_is_path_computed(this_->graph))
+ return;
+
+ route_status.type = attr_route_status;
+
+ route_status.u.num = route_status_building_graph;
+ route_set_attr(this_, &route_status);
+
+ printf("Expanding points which have changed\n");
+
+ route_graph_compute_shortest_path(this_->graph, this_->vehicleprofile, NULL);
+
+ printf("Point expansion complete, recalculating route path\n");
+
+ route_path_update_done(this_, 0);
}
/**
@@ -2574,18 +2705,17 @@ route_graph_flood(struct route_graph *this, struct route_info *dst, struct vehic
* @param dir Not used
* @return The new path
*/
-static struct route_path *
-route_path_new_offroad(struct route_graph *this, struct route_info *pos, struct route_info *dst)
-{
- struct route_path *ret;
+static struct route_path *route_path_new_offroad(struct route_graph *this, struct route_info *pos,
+ struct route_info *dst) {
+ struct route_path *ret;
- ret=g_new0(struct route_path, 1);
- ret->in_use=1;
- ret->path_hash=item_hash_new();
- route_path_add_line(ret, &pos->c, &dst->c, pos->lenextra+dst->lenextra);
- ret->updated=1;
+ ret=g_new0(struct route_path, 1);
+ ret->in_use=1;
+ ret->path_hash=item_hash_new();
+ route_path_add_line(ret, &pos->c, &dst->c, pos->lenextra+dst->lenextra);
+ ret->updated=1;
- return ret;
+ return ret;
}
/**
@@ -2598,56 +2728,55 @@ route_path_new_offroad(struct route_graph *this, struct route_info *pos, struct
* @param dist The distance in meters
* @return The coordinate where the user will be in that distance
*/
-struct coord
-route_get_coord_dist(struct route *this_, int dist)
-{
- int d,l,i,len;
- int dx,dy;
- double frac;
- struct route_path_segment *cur;
- struct coord ret;
- enum projection pro=route_projection(this_);
- struct route_info *dst=route_get_dst(this_);
-
- d = dist;
-
- if (!this_->path2 || pro == projection_none) {
- return this_->pos->c;
- }
-
- ret = this_->pos->c;
- cur = this_->path2->path;
- while (cur) {
- if (cur->data->len < d) {
- d -= cur->data->len;
- } else {
- for (i=0; i < (cur->ncoords-1); i++) {
- l = d;
- len = (int)transform_polyline_length(pro, (cur->c + i), 2);
- d -= len;
- if (d <= 0) {
- // We interpolate a bit here...
- frac = (double)l / len;
-
- dx = (cur->c + i + 1)->x - (cur->c + i)->x;
- dy = (cur->c + i + 1)->y - (cur->c + i)->y;
-
- ret.x = (cur->c + i)->x + (frac * dx);
- ret.y = (cur->c + i)->y + (frac * dy);
- return ret;
- }
- }
- return cur->c[(cur->ncoords-1)];
- }
- cur = cur->next;
- }
-
- return dst->c;
+struct coord
+route_get_coord_dist(struct route *this_, int dist) {
+ int d,l,i,len;
+ int dx,dy;
+ double frac;
+ struct route_path_segment *cur;
+ struct coord ret;
+ enum projection pro=route_projection(this_);
+ struct route_info *dst=route_get_dst(this_);
+
+ d = dist;
+
+ if (!this_->path2 || pro == projection_none) {
+ return this_->pos->c;
+ }
+
+ ret = this_->pos->c;
+ cur = this_->path2->path;
+ while (cur) {
+ if (cur->data->len < d) {
+ d -= cur->data->len;
+ } else {
+ for (i=0; i < (cur->ncoords-1); i++) {
+ l = d;
+ len = (int)transform_polyline_length(pro, (cur->c + i), 2);
+ d -= len;
+ if (d <= 0) {
+ // We interpolate a bit here...
+ frac = (double)l / len;
+
+ dx = (cur->c + i + 1)->x - (cur->c + i)->x;
+ dy = (cur->c + i + 1)->y - (cur->c + i)->y;
+
+ ret.x = (cur->c + i)->x + (frac * dx);
+ ret.y = (cur->c + i)->y + (frac * dy);
+ return ret;
+ }
+ }
+ return cur->c[(cur->ncoords-1)];
+ }
+ cur = cur->next;
+ }
+
+ return dst->c;
}
/**
* @brief Creates a new route path
- *
+ *
* This creates a new non-trivial route. It therefore needs the routing information created by route_graph_flood, so
* make sure to run route_graph_flood() after changing the destination before using this function.
*
@@ -2658,341 +2787,344 @@ route_get_coord_dist(struct route *this_, int dist)
* @param preferences The routing preferences
* @return The new route path
*/
-static struct route_path *
-route_path_new(struct route_graph *this, struct route_path *oldpath, struct route_info *pos, struct route_info *dst, struct vehicleprofile *profile)
-{
- struct route_graph_segment *s=NULL,*s1=NULL,*s2=NULL; /* candidate segments for cheapest path */
- struct route_graph_point *start; /* point at which the next segment starts, i.e. up to which the path is complete */
- struct route_info *posinfo, *dstinfo; /* same as pos and dst, but NULL if not part of current segment */
- int segs=0,dir; /* number of segments added to graph, direction of first segment */
- int val1=INT_MAX,val2=INT_MAX; /* total cost for s1 and s2, respectively */
- int val,val1_new,val2_new;
- struct route_path *ret;
-
- if (! pos->street || ! dst->street) {
- dbg(lvl_error,"pos or dest not set\n");
- return NULL;
- }
-
- if (profile->mode == 2 || (profile->mode == 0 && pos->lenextra + dst->lenextra > transform_distance(map_projection(pos->street->item.map), &pos->c, &dst->c)))
- return route_path_new_offroad(this, pos, dst);
- while ((s=route_graph_get_segment(this, pos->street, s))) {
- val=route_value_seg(profile, NULL, s, 2);
- if (val != INT_MAX && s->end->value != INT_MAX) {
- val=val*(100-pos->percent)/100;
- dbg(lvl_debug,"val1 %d\n",val);
- if (route_graph_segment_match(s,this->avoid_seg) && pos->street_direction < 0)
- val+=profile->turn_around_penalty;
- dbg(lvl_debug,"val1 %d\n",val);
- val1_new=s->end->value+val;
- dbg(lvl_debug,"val1 +%d=%d\n",s->end->value,val1_new);
- if (val1_new < val1) {
- val1=val1_new;
- s1=s;
- }
- }
- val=route_value_seg(profile, NULL, s, -2);
- if (val != INT_MAX && s->start->value != INT_MAX) {
- val=val*pos->percent/100;
- dbg(lvl_debug,"val2 %d\n",val);
- if (route_graph_segment_match(s,this->avoid_seg) && pos->street_direction > 0)
- val+=profile->turn_around_penalty;
- dbg(lvl_debug,"val2 %d\n",val);
- val2_new=s->start->value+val;
- dbg(lvl_debug,"val2 +%d=%d\n",s->start->value,val2_new);
- if (val2_new < val2) {
- val2=val2_new;
- s2=s;
- }
- }
- }
- if (val1 == INT_MAX && val2 == INT_MAX) {
- dbg(lvl_error,"no route found, pos blocked\n");
- return NULL;
- }
- if (val1 == val2) {
- val1=s1->end->value;
- val2=s2->start->value;
- }
- if (val1 < val2) {
- start=s1->start;
- s=s1;
- dir=1;
- } else {
- start=s2->end;
- s=s2;
- dir=-1;
- }
- if (pos->street_direction && dir != pos->street_direction && profile->turn_around_penalty) {
- if (!route_graph_segment_match(this->avoid_seg,s)) {
- dbg(lvl_debug,"avoid current segment\n");
- if (this->avoid_seg)
- route_graph_set_traffic_distortion(this, this->avoid_seg, 0);
- this->avoid_seg=s;
- route_graph_set_traffic_distortion(this, this->avoid_seg, profile->turn_around_penalty);
- route_graph_reset(this);
- route_graph_flood(this, dst, profile, NULL);
- return route_path_new(this, oldpath, pos, dst, profile);
- }
- }
- ret=g_new0(struct route_path, 1);
- ret->in_use=1;
- ret->updated=1;
- if (pos->lenextra)
- route_path_add_line(ret, &pos->c, &pos->lp, pos->lenextra);
- ret->path_hash=item_hash_new();
- dstinfo=NULL;
- posinfo=pos;
- while (s && !dstinfo) { /* following start->seg, which indicates the least costly way to reach our destination */
- segs++;
-#if 0
- printf("start->value=%d 0x%x,0x%x\n", start->value, start->c.x, start->c.y);
-#endif
- if (s->start == start) {
- if (item_is_equal(s->data.item, dst->street->item) && (s->end->seg == s || !posinfo))
- dstinfo=dst;
- if (!route_path_add_item_from_graph(ret, oldpath, s, 1, posinfo, dstinfo))
- ret->updated=0;
- start=s->end;
- } else {
- if (item_is_equal(s->data.item, dst->street->item) && (s->start->seg == s || !posinfo))
- dstinfo=dst;
- if (!route_path_add_item_from_graph(ret, oldpath, s, -1, posinfo, dstinfo))
- ret->updated=0;
- start=s->start;
- }
- posinfo=NULL;
- s=start->seg;
- }
- if (dst->lenextra)
- route_path_add_line(ret, &dst->lp, &dst->c, dst->lenextra);
- dbg(lvl_debug, "%d segments\n", segs);
- return ret;
-}
-
-static int
-route_graph_build_next_map(struct route_graph *rg)
-{
- do {
- rg->m=mapset_next(rg->h, 2);
- if (! rg->m)
- return 0;
- map_rect_destroy(rg->mr);
- rg->mr=map_rect_new(rg->m, rg->sel);
- } while (!rg->mr);
-
- return 1;
-}
-
-
-static int
-is_turn_allowed(struct route_graph_point *p, struct route_graph_segment *from, struct route_graph_segment *to)
-{
- struct route_graph_point *prev,*next;
- struct route_graph_segment *tmp1,*tmp2;
- if (item_is_equal(from->data.item, to->data.item))
- return 0;
- if (from->start == p)
- prev=from->end;
- else
- prev=from->start;
- if (to->start == p)
- next=to->end;
- else
- next=to->start;
- tmp1=p->end;
- while (tmp1) {
- if (tmp1->start->c.x == prev->c.x && tmp1->start->c.y == prev->c.y &&
- (tmp1->data.item.type == type_street_turn_restriction_no ||
- tmp1->data.item.type == type_street_turn_restriction_only)) {
- tmp2=p->start;
- dbg(lvl_debug,"found %s (0x%x,0x%x) (0x%x,0x%x)-(0x%x,0x%x) %p-%p\n",item_to_name(tmp1->data.item.type),tmp1->data.item.id_hi,tmp1->data.item.id_lo,tmp1->start->c.x,tmp1->start->c.y,tmp1->end->c.x,tmp1->end->c.y,tmp1->start,tmp1->end);
- while (tmp2) {
- dbg(lvl_debug,"compare %s (0x%x,0x%x) (0x%x,0x%x)-(0x%x,0x%x) %p-%p\n",item_to_name(tmp2->data.item.type),tmp2->data.item.id_hi,tmp2->data.item.id_lo,tmp2->start->c.x,tmp2->start->c.y,tmp2->end->c.x,tmp2->end->c.y,tmp2->start,tmp2->end);
- if (item_is_equal(tmp1->data.item, tmp2->data.item))
- break;
- tmp2=tmp2->start_next;
- }
- dbg(lvl_debug,"tmp2=%p\n",tmp2);
- if (tmp2) {
- dbg(lvl_debug,"%s tmp2->end=%p next=%p\n",item_to_name(tmp1->data.item.type),tmp2->end,next);
- }
- if (tmp1->data.item.type == type_street_turn_restriction_no && tmp2 && tmp2->end->c.x == next->c.x && tmp2->end->c.y == next->c.y) {
- dbg(lvl_debug,"from 0x%x,0x%x over 0x%x,0x%x to 0x%x,0x%x not allowed (no)\n",prev->c.x,prev->c.y,p->c.x,p->c.y,next->c.x,next->c.y);
- return 0;
- }
- if (tmp1->data.item.type == type_street_turn_restriction_only && tmp2 && (tmp2->end->c.x != next->c.x || tmp2->end->c.y != next->c.y)) {
- dbg(lvl_debug,"from 0x%x,0x%x over 0x%x,0x%x to 0x%x,0x%x not allowed (only)\n",prev->c.x,prev->c.y,p->c.x,p->c.y,next->c.x,next->c.y);
- return 0;
- }
- }
- tmp1=tmp1->end_next;
- }
- dbg(lvl_debug,"from 0x%x,0x%x over 0x%x,0x%x to 0x%x,0x%x allowed\n",prev->c.x,prev->c.y,p->c.x,p->c.y,next->c.x,next->c.y);
- return 1;
-}
-
-static void
-route_graph_clone_segment(struct route_graph *this, struct route_graph_segment *s, struct route_graph_point *start, struct route_graph_point *end, int flags)
-{
- struct route_graph_segment_data data;
- data.item=&s->data.item;
- data.offset=1;
- data.flags=s->data.flags|flags;
- data.len=s->data.len+1;
- data.maxspeed=-1;
- data.dangerous_goods=0;
- if (s->data.flags & AF_SPEED_LIMIT)
- data.maxspeed=RSD_MAXSPEED(&s->data);
- if (s->data.flags & AF_SEGMENTED)
- data.offset=RSD_OFFSET(&s->data);
- dbg(lvl_debug,"cloning segment from %p (0x%x,0x%x) to %p (0x%x,0x%x)\n",start,start->c.x,start->c.y, end, end->c.x, end->c.y);
- route_graph_add_segment(this, start, end, &data);
-}
-
-static void
-route_graph_process_restriction_segment(struct route_graph *this, struct route_graph_point *p, struct route_graph_segment *s, int dir)
-{
- struct route_graph_segment *tmp;
- struct route_graph_point *pn;
- struct coord c=p->c;
- int dx=0;
- int dy=0;
- c.x+=dx;
- c.y+=dy;
- dbg(lvl_debug,"From %s %d,%d\n",item_to_name(s->data.item.type),dx,dy);
- pn=route_graph_point_new(this, &c);
- if (dir > 0) { /* going away */
- dbg(lvl_debug,"other 0x%x,0x%x\n",s->end->c.x,s->end->c.y);
- if (s->data.flags & AF_ONEWAY) {
- dbg(lvl_debug,"Not possible\n");
- return;
- }
- route_graph_clone_segment(this, s, pn, s->end, AF_ONEWAYREV);
- } else { /* coming in */
- dbg(lvl_debug,"other 0x%x,0x%x\n",s->start->c.x,s->start->c.y);
- if (s->data.flags & AF_ONEWAYREV) {
- dbg(lvl_debug,"Not possible\n");
- return;
- }
- route_graph_clone_segment(this, s, s->start, pn, AF_ONEWAY);
- }
- tmp=p->start;
- while (tmp) {
- if (tmp != s && tmp->data.item.type != type_street_turn_restriction_no &&
- tmp->data.item.type != type_street_turn_restriction_only &&
- !(tmp->data.flags & AF_ONEWAYREV) && is_turn_allowed(p, s, tmp)) {
- route_graph_clone_segment(this, tmp, pn, tmp->end, AF_ONEWAY);
- dbg(lvl_debug,"To start %s\n",item_to_name(tmp->data.item.type));
- }
- tmp=tmp->start_next;
- }
- tmp=p->end;
- while (tmp) {
- if (tmp != s && tmp->data.item.type != type_street_turn_restriction_no &&
- tmp->data.item.type != type_street_turn_restriction_only &&
- !(tmp->data.flags & AF_ONEWAY) && is_turn_allowed(p, s, tmp)) {
- route_graph_clone_segment(this, tmp, tmp->start, pn, AF_ONEWAYREV);
- dbg(lvl_debug,"To end %s\n",item_to_name(tmp->data.item.type));
- }
- tmp=tmp->end_next;
- }
-}
-
-static void
-route_graph_process_restriction_point(struct route_graph *this, struct route_graph_point *p)
-{
- struct route_graph_segment *tmp;
- tmp=p->start;
- dbg(lvl_debug,"node 0x%x,0x%x\n",p->c.x,p->c.y);
- while (tmp) {
- if (tmp->data.item.type != type_street_turn_restriction_no &&
- tmp->data.item.type != type_street_turn_restriction_only)
- route_graph_process_restriction_segment(this, p, tmp, 1);
- tmp=tmp->start_next;
- }
- tmp=p->end;
- while (tmp) {
- if (tmp->data.item.type != type_street_turn_restriction_no &&
- tmp->data.item.type != type_street_turn_restriction_only)
- route_graph_process_restriction_segment(this, p, tmp, -1);
- tmp=tmp->end_next;
- }
- p->flags |= RP_TURN_RESTRICTION_RESOLVED;
-}
-
-static void
-route_graph_process_restrictions(struct route_graph *this)
-{
- struct route_graph_point *curr;
- int i;
- dbg(lvl_debug,"enter\n");
- for (i = 0 ; i < HASH_SIZE ; i++) {
- curr=this->hash[i];
- while (curr) {
- if (curr->flags & RP_TURN_RESTRICTION)
- route_graph_process_restriction_point(this, curr);
- curr=curr->hash_next;
- }
- }
+static struct route_path *route_path_new(struct route_graph *this, struct route_path *oldpath, struct route_info *pos,
+ struct route_info *dst,
+ struct vehicleprofile *profile) {
+ struct route_graph_segment *s=NULL,*s1=NULL,*s2=NULL; /* candidate segments for cheapest path */
+ struct route_graph_point *start; /* point at which the next segment starts, i.e. up to which the path is complete */
+ struct route_info *posinfo, *dstinfo; /* same as pos and dst, but NULL if not part of current segment */
+ int segs=0,dir; /* number of segments added to graph, direction of first segment */
+ int val1=INT_MAX,val2=INT_MAX; /* total cost for s1 and s2, respectively */
+ int val,val1_new,val2_new;
+ struct route_path *ret;
+
+ if (! pos->street || ! dst->street) {
+ dbg(lvl_error,"pos or dest not set");
+ return NULL;
+ }
+
+ if (profile->mode == 2 || (profile->mode == 0
+ && pos->lenextra + dst->lenextra > transform_distance(map_projection(pos->street->item.map), &pos->c, &dst->c)))
+ return route_path_new_offroad(this, pos, dst);
+ while ((s=route_graph_get_segment(this, pos->street, s))) {
+ val=route_value_seg(profile, NULL, s, 2);
+ if (val != INT_MAX && s->end->value != INT_MAX) {
+ val=val*(100-pos->percent)/100;
+ dbg(lvl_debug,"val1 %d",val);
+ if (route_graph_segment_match(s,this->avoid_seg) && pos->street_direction < 0)
+ val+=profile->turn_around_penalty;
+ dbg(lvl_debug,"val1 %d",val);
+ val1_new=s->end->value+val;
+ dbg(lvl_debug,"val1 +%d=%d",s->end->value,val1_new);
+ if (val1_new < val1) {
+ val1=val1_new;
+ s1=s;
+ }
+ }
+ val=route_value_seg(profile, NULL, s, -2);
+ if (val != INT_MAX && s->start->value != INT_MAX) {
+ val=val*pos->percent/100;
+ dbg(lvl_debug,"val2 %d",val);
+ if (route_graph_segment_match(s,this->avoid_seg) && pos->street_direction > 0)
+ val+=profile->turn_around_penalty;
+ dbg(lvl_debug,"val2 %d",val);
+ val2_new=s->start->value+val;
+ dbg(lvl_debug,"val2 +%d=%d",s->start->value,val2_new);
+ if (val2_new < val2) {
+ val2=val2_new;
+ s2=s;
+ }
+ }
+ }
+ if (val1 == INT_MAX && val2 == INT_MAX) {
+ dbg(lvl_error,"no route found, pos blocked");
+ return NULL;
+ }
+ if (val1 == val2) {
+ val1=s1->end->value;
+ val2=s2->start->value;
+ }
+ if (val1 < val2) {
+ start=s1->start;
+ s=s1;
+ dir=1;
+ } else {
+ start=s2->end;
+ s=s2;
+ dir=-1;
+ }
+ if (pos->street_direction && dir != pos->street_direction && profile->turn_around_penalty) {
+ if (!route_graph_segment_match(this->avoid_seg,s)) {
+ dbg(lvl_debug,"avoid current segment");
+ if (this->avoid_seg)
+ route_graph_set_traffic_distortion(this, this->avoid_seg, 0);
+ this->avoid_seg=s;
+ route_graph_set_traffic_distortion(this, this->avoid_seg, profile->turn_around_penalty);
+ route_graph_reset(this);
+ route_graph_init(this, dst, profile);
+ route_graph_compute_shortest_path(this, profile, NULL);
+ return route_path_new(this, oldpath, pos, dst, profile);
+ }
+ }
+ ret=g_new0(struct route_path, 1);
+ ret->in_use=1;
+ ret->updated=1;
+ if (pos->lenextra)
+ route_path_add_line(ret, &pos->c, &pos->lp, pos->lenextra);
+ ret->path_hash=item_hash_new();
+ dstinfo=NULL;
+ posinfo=pos;
+ while (s && !dstinfo) { /* following start->seg, which indicates the least costly way to reach our destination */
+ segs++;
+ if (s->start == start) {
+ if (item_is_equal(s->data.item, dst->street->item) && (s->end->seg == s || !posinfo))
+ dstinfo=dst;
+ if (!route_path_add_item_from_graph(ret, oldpath, s, 1, posinfo, dstinfo))
+ ret->updated=0;
+ start=s->end;
+ } else {
+ if (item_is_equal(s->data.item, dst->street->item) && (s->start->seg == s || !posinfo))
+ dstinfo=dst;
+ if (!route_path_add_item_from_graph(ret, oldpath, s, -1, posinfo, dstinfo))
+ ret->updated=0;
+ start=s->start;
+ }
+ posinfo=NULL;
+ s=start->seg;
+ }
+ if (dst->lenextra)
+ route_path_add_line(ret, &dst->lp, &dst->c, dst->lenextra);
+ dbg(lvl_debug, "%d segments", segs);
+ return ret;
+}
+
+static int route_graph_build_next_map(struct route_graph *rg) {
+ do {
+ rg->m=mapset_next(rg->h, 2);
+ if (! rg->m)
+ return 0;
+ map_rect_destroy(rg->mr);
+ rg->mr=map_rect_new(rg->m, rg->sel);
+ } while (!rg->mr);
+
+ return 1;
+}
+
+
+static int is_turn_allowed(struct route_graph_point *p, struct route_graph_segment *from,
+ struct route_graph_segment *to) {
+ struct route_graph_point *prev,*next;
+ struct route_graph_segment *tmp1,*tmp2;
+ if (item_is_equal(from->data.item, to->data.item))
+ return 0;
+ if (from->start == p)
+ prev=from->end;
+ else
+ prev=from->start;
+ if (to->start == p)
+ next=to->end;
+ else
+ next=to->start;
+ tmp1=p->end;
+ while (tmp1) {
+ if (tmp1->start->c.x == prev->c.x && tmp1->start->c.y == prev->c.y &&
+ (tmp1->data.item.type == type_street_turn_restriction_no ||
+ tmp1->data.item.type == type_street_turn_restriction_only)) {
+ tmp2=p->start;
+ dbg(lvl_debug,"found %s (0x%x,0x%x) (0x%x,0x%x)-(0x%x,0x%x) %p-%p",item_to_name(tmp1->data.item.type),
+ tmp1->data.item.id_hi,tmp1->data.item.id_lo,tmp1->start->c.x,tmp1->start->c.y,tmp1->end->c.x,tmp1->end->c.y,tmp1->start,
+ tmp1->end);
+ while (tmp2) {
+ dbg(lvl_debug,"compare %s (0x%x,0x%x) (0x%x,0x%x)-(0x%x,0x%x) %p-%p",item_to_name(tmp2->data.item.type),
+ tmp2->data.item.id_hi,tmp2->data.item.id_lo,tmp2->start->c.x,tmp2->start->c.y,tmp2->end->c.x,tmp2->end->c.y,tmp2->start,
+ tmp2->end);
+ if (item_is_equal(tmp1->data.item, tmp2->data.item))
+ break;
+ tmp2=tmp2->start_next;
+ }
+ dbg(lvl_debug,"tmp2=%p",tmp2);
+ if (tmp2) {
+ dbg(lvl_debug,"%s tmp2->end=%p next=%p",item_to_name(tmp1->data.item.type),tmp2->end,next);
+ }
+ if (tmp1->data.item.type == type_street_turn_restriction_no && tmp2 && tmp2->end->c.x == next->c.x
+ && tmp2->end->c.y == next->c.y) {
+ dbg(lvl_debug,"from 0x%x,0x%x over 0x%x,0x%x to 0x%x,0x%x not allowed (no)",prev->c.x,prev->c.y,p->c.x,p->c.y,next->c.x,
+ next->c.y);
+ return 0;
+ }
+ if (tmp1->data.item.type == type_street_turn_restriction_only && tmp2 && (tmp2->end->c.x != next->c.x
+ || tmp2->end->c.y != next->c.y)) {
+ dbg(lvl_debug,"from 0x%x,0x%x over 0x%x,0x%x to 0x%x,0x%x not allowed (only)",prev->c.x,prev->c.y,p->c.x,p->c.y,
+ next->c.x,next->c.y);
+ return 0;
+ }
+ }
+ tmp1=tmp1->end_next;
+ }
+ dbg(lvl_debug,"from 0x%x,0x%x over 0x%x,0x%x to 0x%x,0x%x allowed",prev->c.x,prev->c.y,p->c.x,p->c.y,next->c.x,
+ next->c.y);
+ return 1;
+}
+
+static void route_graph_clone_segment(struct route_graph *this, struct route_graph_segment *s,
+ struct route_graph_point *start,
+ struct route_graph_point *end, int flags) {
+ struct route_graph_segment_data data;
+ data.item=&s->data.item;
+ data.offset=1;
+ data.flags=s->data.flags|flags;
+ data.len=s->data.len+1;
+ data.maxspeed=-1;
+ data.dangerous_goods=0;
+ data.score = s->data.score;
+ if (s->data.flags & AF_SPEED_LIMIT)
+ data.maxspeed=RSD_MAXSPEED(&s->data);
+ if (s->data.flags & AF_SEGMENTED)
+ data.offset=RSD_OFFSET(&s->data);
+ dbg(lvl_debug,"cloning segment from %p (0x%x,0x%x) to %p (0x%x,0x%x)",start,start->c.x,start->c.y, end, end->c.x,
+ end->c.y);
+ route_graph_add_segment(this, start, end, &data);
+}
+
+static void route_graph_process_restriction_segment(struct route_graph *this, struct route_graph_point *p,
+ struct route_graph_segment *s, int dir) {
+ struct route_graph_segment *tmp;
+ struct route_graph_point *pn;
+ struct coord c=p->c;
+ int dx=0;
+ int dy=0;
+ c.x+=dx;
+ c.y+=dy;
+ dbg(lvl_debug,"From %s %d,%d",item_to_name(s->data.item.type),dx,dy);
+ pn=route_graph_point_new(this, &c);
+ if (dir > 0) { /* going away */
+ dbg(lvl_debug,"other 0x%x,0x%x",s->end->c.x,s->end->c.y);
+ if (s->data.flags & AF_ONEWAY) {
+ dbg(lvl_debug,"Not possible");
+ return;
+ }
+ route_graph_clone_segment(this, s, pn, s->end, AF_ONEWAYREV);
+ } else { /* coming in */
+ dbg(lvl_debug,"other 0x%x,0x%x",s->start->c.x,s->start->c.y);
+ if (s->data.flags & AF_ONEWAYREV) {
+ dbg(lvl_debug,"Not possible");
+ return;
+ }
+ route_graph_clone_segment(this, s, s->start, pn, AF_ONEWAY);
+ }
+ tmp=p->start;
+ while (tmp) {
+ if (tmp != s && tmp->data.item.type != type_street_turn_restriction_no &&
+ tmp->data.item.type != type_street_turn_restriction_only &&
+ !(tmp->data.flags & AF_ONEWAYREV) && is_turn_allowed(p, s, tmp)) {
+ route_graph_clone_segment(this, tmp, pn, tmp->end, AF_ONEWAY);
+ dbg(lvl_debug,"To start %s",item_to_name(tmp->data.item.type));
+ }
+ tmp=tmp->start_next;
+ }
+ tmp=p->end;
+ while (tmp) {
+ if (tmp != s && tmp->data.item.type != type_street_turn_restriction_no &&
+ tmp->data.item.type != type_street_turn_restriction_only &&
+ !(tmp->data.flags & AF_ONEWAY) && is_turn_allowed(p, s, tmp)) {
+ route_graph_clone_segment(this, tmp, tmp->start, pn, AF_ONEWAYREV);
+ dbg(lvl_debug,"To end %s",item_to_name(tmp->data.item.type));
+ }
+ tmp=tmp->end_next;
+ }
+}
+
+static void route_graph_process_restriction_point(struct route_graph *this, struct route_graph_point *p) {
+ struct route_graph_segment *tmp;
+ tmp=p->start;
+ dbg(lvl_debug,"node 0x%x,0x%x",p->c.x,p->c.y);
+ while (tmp) {
+ if (tmp->data.item.type != type_street_turn_restriction_no &&
+ tmp->data.item.type != type_street_turn_restriction_only)
+ route_graph_process_restriction_segment(this, p, tmp, 1);
+ tmp=tmp->start_next;
+ }
+ tmp=p->end;
+ while (tmp) {
+ if (tmp->data.item.type != type_street_turn_restriction_no &&
+ tmp->data.item.type != type_street_turn_restriction_only)
+ route_graph_process_restriction_segment(this, p, tmp, -1);
+ tmp=tmp->end_next;
+ }
+ p->flags |= RP_TURN_RESTRICTION_RESOLVED;
+}
+
+static void route_graph_process_restrictions(struct route_graph *this) {
+ struct route_graph_point *curr;
+ int i;
+ dbg(lvl_debug,"enter");
+ for (i = 0 ; i < HASH_SIZE ; i++) {
+ curr=this->hash[i];
+ while (curr) {
+ if (curr->flags & RP_TURN_RESTRICTION)
+ route_graph_process_restriction_point(this, curr);
+ curr=curr->hash_next;
+ }
+ }
}
/**
* @brief Releases all resources needed to build the route graph.
*
- * If {@code cancel} is false, this function will start processing restrictions and ultimately call
- * the route graph's {@code done_cb} callback.
+ * If `cancel` is false, this function will start processing restrictions and ultimately call the route
+ * graph's `done_cb` callback.
+ *
+ * The traffic module will always call this method with `cancel` set to true, as it does not process
+ * restrictions and has no callback. Inside the routing module, `cancel` will be true if, and only if,
+ * navigation has been aborted.
*
* @param rg Points to the route graph
* @param cancel True if the process was aborted before completing, false if it completed normally
*/
-static void
-route_graph_build_done(struct route_graph *rg, int cancel)
-{
- dbg(lvl_debug,"cancel=%d\n",cancel);
- if (rg->idle_ev)
- event_remove_idle(rg->idle_ev);
- if (rg->idle_cb)
- callback_destroy(rg->idle_cb);
- map_rect_destroy(rg->mr);
- mapset_close(rg->h);
- route_free_selection(rg->sel);
- rg->idle_ev=NULL;
- rg->idle_cb=NULL;
- rg->mr=NULL;
- rg->h=NULL;
- rg->sel=NULL;
- if (! cancel) {
- route_graph_process_restrictions(rg);
- callback_call_0(rg->done_cb);
- }
- rg->busy=0;
-}
-
-static void
-route_graph_build_idle(struct route_graph *rg, struct vehicleprofile *profile)
-{
- int count=1000;
- struct item *item;
-
- while (count > 0) {
- for (;;) {
- item=map_rect_get_item(rg->mr);
- if (item)
- break;
- if (!route_graph_build_next_map(rg)) {
- route_graph_build_done(rg, 0);
- return;
- }
- }
- if (item->type == type_traffic_distortion)
- route_process_traffic_distortion(rg, item);
- else if (item->type == type_street_turn_restriction_no || item->type == type_street_turn_restriction_only)
- route_process_turn_restriction(rg, item);
- else
- route_process_street_graph(rg, item, profile);
- count--;
- }
+void route_graph_build_done(struct route_graph *rg, int cancel) {
+ dbg(lvl_debug,"cancel=%d",cancel);
+ if (rg->idle_ev)
+ event_remove_idle(rg->idle_ev);
+ if (rg->idle_cb)
+ callback_destroy(rg->idle_cb);
+ map_rect_destroy(rg->mr);
+ mapset_close(rg->h);
+ route_free_selection(rg->sel);
+ rg->idle_ev=NULL;
+ rg->idle_cb=NULL;
+ rg->mr=NULL;
+ rg->h=NULL;
+ rg->sel=NULL;
+ if (! cancel) {
+ route_graph_process_restrictions(rg);
+ if (rg->done_cb)
+ callback_call_0(rg->done_cb);
+ }
+ rg->busy=0;
+}
+
+static void route_graph_build_idle(struct route_graph *rg, struct vehicleprofile *profile) {
+ int count=1000;
+ struct item *item;
+
+ while (count > 0) {
+ for (;;) {
+ item=map_rect_get_item(rg->mr);
+ if (item)
+ break;
+ if (!route_graph_build_next_map(rg)) {
+ route_graph_build_done(rg, 0);
+ return;
+ }
+ }
+ if (item->type == type_traffic_distortion)
+ route_graph_add_traffic_distortion(rg, profile, item, 0);
+ else if (item->type == type_street_turn_restriction_no || item->type == type_street_turn_restriction_only)
+ route_graph_add_turn_restriction(rg, item);
+ else
+ route_graph_add_street(rg, item, profile);
+ count--;
+ }
}
/**
@@ -3013,32 +3145,32 @@ route_graph_build_idle(struct route_graph *rg, struct vehicleprofile *profile)
* @return The new route graph.
*/
// FIXME documentation does not match argument list
-static struct route_graph *
-route_graph_build(struct mapset *ms, struct coord *c, int count, struct callback *done_cb, int async, struct vehicleprofile *profile)
-{
- struct route_graph *ret=g_new0(struct route_graph, 1);
-
- dbg(lvl_debug,"enter\n");
-
- ret->sel=route_calc_selection(c, count, profile);
- ret->h=mapset_open(ms);
- ret->done_cb=done_cb;
- ret->busy=1;
- if (route_graph_build_next_map(ret)) {
- if (async) {
- ret->idle_cb=callback_new_2(callback_cast(route_graph_build_idle), ret, profile);
- ret->idle_ev=event_add_idle(50, ret->idle_cb);
- }
- } else
- route_graph_build_done(ret, 0);
-
- return ret;
+static struct route_graph *route_graph_build(struct mapset *ms, struct coord *c, int count, struct callback *done_cb,
+ int async,
+ struct vehicleprofile *profile) {
+ struct route_graph *ret=g_new0(struct route_graph, 1);
+
+ dbg(lvl_debug,"enter");
+
+ ret->sel=route_calc_selection(c, count, profile);
+ ret->h=mapset_open(ms);
+ ret->done_cb=done_cb;
+ ret->busy=1;
+ ret->heap = fh_makekeyheap();
+ if (route_graph_build_next_map(ret)) {
+ if (async) {
+ ret->idle_cb=callback_new_2(callback_cast(route_graph_build_idle), ret, profile);
+ ret->idle_ev=event_add_idle(50, ret->idle_cb);
+ }
+ } else
+ route_graph_build_done(ret, 0);
+
+ return ret;
}
-static void
-route_graph_update_done(struct route *this, struct callback *cb)
-{
- route_graph_flood(this->graph, this->current_dst, this->vehicleprofile, cb);
+static void route_graph_update_done(struct route *this, struct callback *cb) {
+ route_graph_init(this->graph, this->current_dst, this->vehicleprofile);
+ route_graph_compute_shortest_path(this->graph, this->vehicleprofile, cb);
}
/**
@@ -3046,38 +3178,36 @@ route_graph_update_done(struct route *this, struct callback *cb)
*
* This updates the route graph after settings in the route have changed. It also
* adds routing information afterwards by calling route_graph_flood().
- *
+ *
* @param this The route to update the graph for
* @param cb The callback function to call when the route graph update is complete (used only in asynchronous mode)
* @param async Set to nonzero in order to update the route graph asynchronously
*/
-static void
-route_graph_update(struct route *this, struct callback *cb, int async)
-{
- struct attr route_status;
- struct coord *c=g_alloca(sizeof(struct coord)*(1+g_list_length(this->destinations)));
- int i=0;
- GList *tmp;
-
- route_status.type=attr_route_status;
- route_graph_destroy(this->graph);
- this->graph=NULL;
- callback_destroy(this->route_graph_done_cb);
- this->route_graph_done_cb=callback_new_2(callback_cast(route_graph_update_done), this, cb);
- route_status.u.num=route_status_building_graph;
- route_set_attr(this, &route_status);
- c[i++]=this->pos->c;
- tmp=this->destinations;
- while (tmp) {
- struct route_info *dst=tmp->data;
- c[i++]=dst->c;
- tmp=g_list_next(tmp);
- }
- this->graph=route_graph_build(this->ms, c, i, this->route_graph_done_cb, async, this->vehicleprofile);
- if (! async) {
- while (this->graph->busy)
- route_graph_build_idle(this->graph, this->vehicleprofile);
- }
+static void route_graph_update(struct route *this, struct callback *cb, int async) {
+ struct attr route_status;
+ struct coord *c=g_alloca(sizeof(struct coord)*(1+g_list_length(this->destinations)));
+ int i=0;
+ GList *tmp;
+
+ route_status.type=attr_route_status;
+ route_graph_destroy(this->graph);
+ this->graph=NULL;
+ callback_destroy(this->route_graph_done_cb);
+ this->route_graph_done_cb=callback_new_2(callback_cast(route_graph_update_done), this, cb);
+ route_status.u.num=route_status_building_graph;
+ route_set_attr(this, &route_status);
+ c[i++]=this->pos->c;
+ tmp=this->destinations;
+ while (tmp) {
+ struct route_info *dst=tmp->data;
+ c[i++]=dst->c;
+ tmp=g_list_next(tmp);
+ }
+ this->graph=route_graph_build(this->ms, c, i, this->route_graph_done_cb, async, this->vehicleprofile);
+ if (! async) {
+ while (this->graph->busy)
+ route_graph_build_idle(this->graph, this->vehicleprofile);
+ }
}
/**
@@ -3087,67 +3217,65 @@ route_graph_update(struct route *this, struct callback *cb, int async)
* @return Street data for the item
*/
struct street_data *
-street_get_data (struct item *item)
-{
- int count=0,*flags;
- struct street_data *ret = NULL, *ret1;
- struct attr flags_attr, maxspeed_attr;
- const int step = 128;
- int c;
-
- do {
- ret1=g_realloc(ret, sizeof(struct street_data)+(count+step)*sizeof(struct coord));
- if (!ret1) {
- if (ret)
- g_free(ret);
- return NULL;
- }
- ret = ret1;
- c = item_coord_get(item, &ret->c[count], step);
- count += c;
- } while (c && c == step);
-
- ret1=g_realloc(ret, sizeof(struct street_data)+count*sizeof(struct coord));
- if (ret1)
- ret = ret1;
- ret->item=*item;
- ret->count=count;
- if (item_attr_get(item, attr_flags, &flags_attr))
- ret->flags=flags_attr.u.num;
- else {
- flags=item_get_default_flags(item->type);
- if (flags)
- ret->flags=*flags;
- else
- ret->flags=0;
- }
-
- ret->maxspeed = -1;
- if (ret->flags & AF_SPEED_LIMIT) {
- if (item_attr_get(item, attr_maxspeed, &maxspeed_attr)) {
- ret->maxspeed = maxspeed_attr.u.num;
- }
- }
-
- return ret;
+street_get_data (struct item *item) {
+ int count=0,*flags;
+ struct street_data *ret = NULL, *ret1;
+ struct attr flags_attr, maxspeed_attr;
+ const int step = 128;
+ int c;
+
+ do {
+ ret1=g_realloc(ret, sizeof(struct street_data)+(count+step)*sizeof(struct coord));
+ if (!ret1) {
+ if (ret)
+ g_free(ret);
+ return NULL;
+ }
+ ret = ret1;
+ c = item_coord_get(item, &ret->c[count], step);
+ count += c;
+ } while (c && c == step);
+
+ ret1=g_realloc(ret, sizeof(struct street_data)+count*sizeof(struct coord));
+ if (ret1)
+ ret = ret1;
+ ret->item=*item;
+ ret->count=count;
+ if (item_attr_get(item, attr_flags, &flags_attr))
+ ret->flags=flags_attr.u.num;
+ else {
+ flags=item_get_default_flags(item->type);
+ if (flags)
+ ret->flags=*flags;
+ else
+ ret->flags=0;
+ }
+
+ ret->maxspeed = -1;
+ if (ret->flags & AF_SPEED_LIMIT) {
+ if (item_attr_get(item, attr_maxspeed, &maxspeed_attr)) {
+ ret->maxspeed = maxspeed_attr.u.num;
+ }
+ }
+
+ return ret;
}
/**
* @brief Copies street data
- *
+ *
* @param orig The street data to copy
* @return The copied street data
- */
+ */
struct street_data *
-street_data_dup(struct street_data *orig)
-{
- struct street_data *ret;
- int size=sizeof(struct street_data)+orig->count*sizeof(struct coord);
+street_data_dup(struct street_data *orig) {
+ struct street_data *ret;
+ int size=sizeof(struct street_data)+orig->count*sizeof(struct coord);
- ret=g_malloc(size);
- memcpy(ret, orig, size);
+ ret=g_malloc(size);
+ memcpy(ret, orig, size);
- return ret;
+ return ret;
}
/**
@@ -3155,10 +3283,8 @@ street_data_dup(struct street_data *orig)
*
* @param sd Street data to be freed
*/
-void
-street_data_free(struct street_data *sd)
-{
- g_free(sd);
+void street_data_free(struct street_data *sd) {
+ g_free(sd);
}
/**
@@ -3168,82 +3294,81 @@ street_data_free(struct street_data *sd)
* @param pc The coordinate to find a street nearby
* @return The nearest street
*/
-static struct route_info *
-route_find_nearest_street(struct vehicleprofile *vehicleprofile, struct mapset *ms, struct pcoord *pc)
-{
- struct route_info *ret=NULL;
- int max_dist=1000;
- struct map_selection *sel;
- int dist,mindist=0,pos;
- struct mapset_handle *h;
- struct map *m;
- struct map_rect *mr;
- struct item *item;
- struct coord lp;
- struct street_data *sd;
- struct coord c;
- struct coord_geo g;
-
- if(!vehicleprofile)
- return NULL;
-
- ret=g_new0(struct route_info, 1);
- mindist = INT_MAX;
-
- h=mapset_open(ms);
- while ((m=mapset_next(h,2))) {
- c.x = pc->x;
- c.y = pc->y;
- if (map_projection(m) != pc->pro) {
- transform_to_geo(pc->pro, &c, &g);
- transform_from_geo(map_projection(m), &g, &c);
- }
- sel = route_rect(18, &c, &c, 0, max_dist);
- if (!sel)
- continue;
- mr=map_rect_new(m, sel);
- if (!mr) {
- map_selection_destroy(sel);
- continue;
- }
- while ((item=map_rect_get_item(mr))) {
- if (item_get_default_flags(item->type)) {
- sd=street_get_data(item);
- if (!sd)
- continue;
- dist=transform_distance_polyline_sq(sd->c, sd->count, &c, &lp, &pos);
- if (dist < mindist && (
- (sd->flags & vehicleprofile->flags_forward_mask) == vehicleprofile->flags ||
- (sd->flags & vehicleprofile->flags_reverse_mask) == vehicleprofile->flags)) {
- mindist = dist;
- if (ret->street) {
- street_data_free(ret->street);
- }
- ret->c=c;
- ret->lp=lp;
- ret->pos=pos;
- ret->street=sd;
- dbg(lvl_debug,"dist=%d id 0x%x 0x%x pos=%d\n", dist, item->id_hi, item->id_lo, pos);
- } else {
- street_data_free(sd);
- }
- }
- }
- map_selection_destroy(sel);
- map_rect_destroy(mr);
- }
- mapset_close(h);
-
- if (!ret->street || mindist > max_dist*max_dist) {
- if (ret->street) {
- street_data_free(ret->street);
- dbg(lvl_debug,"Much too far %d > %d\n", mindist, max_dist);
- }
- g_free(ret);
- ret = NULL;
- }
-
- return ret;
+static struct route_info *route_find_nearest_street(struct vehicleprofile *vehicleprofile, struct mapset *ms,
+ struct pcoord *pc) {
+ struct route_info *ret=NULL;
+ int max_dist=1000;
+ struct map_selection *sel;
+ int dist,mindist=0,pos;
+ struct mapset_handle *h;
+ struct map *m;
+ struct map_rect *mr;
+ struct item *item;
+ struct coord lp;
+ struct street_data *sd;
+ struct coord c;
+ struct coord_geo g;
+
+ if(!vehicleprofile)
+ return NULL;
+
+ ret=g_new0(struct route_info, 1);
+ mindist = INT_MAX;
+
+ h=mapset_open(ms);
+ while ((m=mapset_next(h,2))) {
+ c.x = pc->x;
+ c.y = pc->y;
+ if (map_projection(m) != pc->pro) {
+ transform_to_geo(pc->pro, &c, &g);
+ transform_from_geo(map_projection(m), &g, &c);
+ }
+ sel = route_rect(18, &c, &c, 0, max_dist);
+ if (!sel)
+ continue;
+ mr=map_rect_new(m, sel);
+ if (!mr) {
+ map_selection_destroy(sel);
+ continue;
+ }
+ while ((item=map_rect_get_item(mr))) {
+ if (item_get_default_flags(item->type)) {
+ sd=street_get_data(item);
+ if (!sd)
+ continue;
+ dist=transform_distance_polyline_sq(sd->c, sd->count, &c, &lp, &pos);
+ if (dist < mindist && (
+ (sd->flags & vehicleprofile->flags_forward_mask) == vehicleprofile->flags ||
+ (sd->flags & vehicleprofile->flags_reverse_mask) == vehicleprofile->flags)) {
+ mindist = dist;
+ if (ret->street) {
+ street_data_free(ret->street);
+ }
+ ret->c=c;
+ ret->lp=lp;
+ ret->pos=pos;
+ ret->street=sd;
+ dbg(lvl_debug,"dist=%d id 0x%x 0x%x pos=%d", dist, item->id_hi, item->id_lo, pos);
+ } else {
+ street_data_free(sd);
+ }
+ }
+ }
+ map_selection_destroy(sel);
+ map_rect_destroy(mr);
+ }
+ mapset_close(h);
+
+ if (!ret->street || mindist > max_dist*max_dist) {
+ if (ret->street) {
+ street_data_free(ret->street);
+ dbg(lvl_debug,"Much too far %d > %d", mindist, max_dist);
+ }
+ g_free(ret);
+ ret = NULL;
+ }
+
+ return ret;
}
/**
@@ -3251,356 +3376,325 @@ route_find_nearest_street(struct vehicleprofile *vehicleprofile, struct mapset *
*
* @param info The route info to be destroyed
*/
-void
-route_info_free(struct route_info *inf)
-{
- if (!inf)
- return;
- if (inf->street)
- street_data_free(inf->street);
- g_free(inf);
+void route_info_free(struct route_info *inf) {
+ if (!inf)
+ return;
+ if (inf->street)
+ street_data_free(inf->street);
+ g_free(inf);
}
#include "point.h"
/**
- * @brief Returns street data for a route info
+ * @brief Returns street data for a route info
*
* @param rinf The route info to return the street data for
* @return Street data for the route info
*/
struct street_data *
-route_info_street(struct route_info *rinf)
-{
- return rinf->street;
-}
-
-#if 0
-struct route_crossings *
-route_crossings_get(struct route *this, struct coord *c)
-{
- struct route_point *pnt;
- struct route_segment *seg;
- int crossings=0;
- struct route_crossings *ret;
-
- pnt=route_graph_get_point(this, c);
- seg=pnt->start;
- while (seg) {
- printf("start: 0x%x 0x%x\n", seg->item.id_hi, seg->item.id_lo);
- crossings++;
- seg=seg->start_next;
- }
- seg=pnt->end;
- while (seg) {
- printf("end: 0x%x 0x%x\n", seg->item.id_hi, seg->item.id_lo);
- crossings++;
- seg=seg->end_next;
- }
- ret=g_malloc(sizeof(struct route_crossings)+crossings*sizeof(struct route_crossing));
- ret->count=crossings;
- return ret;
+route_info_street(struct route_info *rinf) {
+ return rinf->street;
}
-#endif
+/**
+ * @brief Implementation-specific map rect data
+ */
struct map_rect_priv {
- struct route_info_handle *ri;
- enum attr_type attr_next;
- int pos;
- struct map_priv *mpriv;
- struct item item;
- unsigned int last_coord;
- struct route_path *path;
- struct route_path_segment *seg,*seg_next;
- struct route_graph_point *point;
- struct route_graph_segment *rseg;
- char *str;
- int hash_bucket;
- struct coord *coord_sel; /**< Set this to a coordinate if you want to filter for just a single route graph point */
- struct route_graph_point_iterator it;
- /* Pointer to current waypoint element of route->destinations */
- GList *dest;
+ struct route_info_handle *ri;
+ enum attr_type attr_next;
+ int pos;
+ struct map_priv *mpriv; /**< The map to which this map rect refers */
+ struct item item; /**< The current item, i.e. the last item returned by the `map_rect_get_item` method */
+ unsigned int last_coord;
+ struct route_path *path;
+ struct route_path_segment *seg,*seg_next;
+ struct route_graph_point *point;
+ struct route_graph_segment *rseg;
+ char *str;
+ int hash_bucket;
+ struct coord *coord_sel; /**< Set this to a coordinate if you want to filter for just a single route graph point */
+ struct route_graph_point_iterator it;
+ /* Pointer to current waypoint element of route->destinations */
+ GList *dest;
};
-static void
-rm_coord_rewind(void *priv_data)
-{
- struct map_rect_priv *mr = priv_data;
- mr->last_coord = 0;
-}
-
-static void
-rm_attr_rewind(void *priv_data)
-{
- struct map_rect_priv *mr = priv_data;
- mr->attr_next = attr_street_item;
-}
-
-static int
-rm_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr = priv_data;
- struct route_path_segment *seg=mr->seg;
- struct route *route=mr->mpriv->route;
- if (mr->item.type != type_street_route && mr->item.type != type_waypoint && mr->item.type != type_route_end)
- return 0;
- attr->type=attr_type;
- switch (attr_type) {
- case attr_any:
- while (mr->attr_next != attr_none) {
- if (rm_attr_get(priv_data, mr->attr_next, attr))
- return 1;
- }
- return 0;
- case attr_maxspeed:
- mr->attr_next = attr_street_item;
- if (seg && seg->data->flags & AF_SPEED_LIMIT) {
- attr->u.num=RSD_MAXSPEED(seg->data);
-
- } else {
- return 0;
- }
- return 1;
- case attr_street_item:
- mr->attr_next=attr_direction;
- if (seg && seg->data->item.map)
- attr->u.item=&seg->data->item;
- else
- return 0;
- return 1;
- case attr_direction:
- mr->attr_next=attr_route;
- if (seg)
- attr->u.num=seg->direction;
- else
- return 0;
- return 1;
- case attr_route:
- mr->attr_next=attr_length;
- attr->u.route = mr->mpriv->route;
- return 1;
- case attr_length:
- mr->attr_next=attr_time;
- if (seg)
- attr->u.num=seg->data->len;
- else
- return 0;
- return 1;
- case attr_time:
- mr->attr_next=attr_speed;
- if (seg)
- attr->u.num=route_time_seg(route->vehicleprofile, seg->data, NULL);
- else
- return 0;
- return 1;
- case attr_speed:
- mr->attr_next=attr_label;
- if (seg)
- attr->u.num=route_seg_speed(route->vehicleprofile, seg->data, NULL);
- else
- return 0;
- return 1;
- case attr_label:
- mr->attr_next=attr_none;
- if(mr->item.type==type_waypoint || mr->item.type == type_route_end) {
- if(mr->str)
- g_free(mr->str);
- mr->str=g_strdup_printf("%d",route->reached_destinations_count+g_list_position(route->destinations,mr->dest)+1);
- attr->u.str=mr->str;
- return 1;
- }
- return 0;
- default:
- mr->attr_next=attr_none;
- attr->type=attr_none;
- return 0;
- }
- return 0;
-}
-
-static int
-rm_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr = priv_data;
- struct route_path_segment *seg = mr->seg;
- int i,rc=0;
- struct route *r = mr->mpriv->route;
- enum projection pro = route_projection(r);
-
- if (pro == projection_none)
- return 0;
- if (mr->item.type == type_route_start || mr->item.type == type_route_start_reverse || mr->item.type == type_route_end || mr->item.type == type_waypoint ) {
- if (! count || mr->last_coord)
- return 0;
- mr->last_coord=1;
- if (mr->item.type == type_route_start || mr->item.type == type_route_start_reverse)
- c[0]=r->pos->c;
- else if (mr->item.type == type_waypoint) {
- c[0]=((struct route_info *)mr->dest->data)->c;
- } else { /*type_route_end*/
- c[0]=route_get_dst(r)->c;
- }
- return 1;
- }
- if (! seg)
- return 0;
- for (i=0; i < count; i++) {
- if (mr->last_coord >= seg->ncoords)
- break;
- if (i >= seg->ncoords)
- break;
- if (pro != projection_mg)
- transform_from_to(&seg->c[mr->last_coord++], pro,
- &c[i],projection_mg);
- else
- c[i] = seg->c[mr->last_coord++];
- rc++;
- }
- dbg(lvl_debug,"return %d\n",rc);
- return rc;
+static void rm_coord_rewind(void *priv_data) {
+ struct map_rect_priv *mr = priv_data;
+ mr->last_coord = 0;
+}
+
+static void rm_attr_rewind(void *priv_data) {
+ struct map_rect_priv *mr = priv_data;
+ mr->attr_next = attr_street_item;
+}
+
+static int rm_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr = priv_data;
+ struct route_path_segment *seg=mr->seg;
+ struct route *route=mr->mpriv->route;
+ if (mr->item.type != type_street_route && mr->item.type != type_waypoint && mr->item.type != type_route_end)
+ return 0;
+ attr->type=attr_type;
+ switch (attr_type) {
+ case attr_any:
+ while (mr->attr_next != attr_none) {
+ if (rm_attr_get(priv_data, mr->attr_next, attr))
+ return 1;
+ }
+ return 0;
+ case attr_maxspeed:
+ mr->attr_next = attr_street_item;
+ if (seg && (seg->data->flags & AF_SPEED_LIMIT)) {
+ attr->u.num=RSD_MAXSPEED(seg->data);
+
+ } else {
+ return 0;
+ }
+ return 1;
+ case attr_street_item:
+ mr->attr_next=attr_direction;
+ if (seg && seg->data->item.map)
+ attr->u.item=&seg->data->item;
+ else
+ return 0;
+ return 1;
+ case attr_direction:
+ mr->attr_next=attr_route;
+ if (seg)
+ attr->u.num=seg->direction;
+ else
+ return 0;
+ return 1;
+ case attr_route:
+ mr->attr_next=attr_length;
+ attr->u.route = mr->mpriv->route;
+ return 1;
+ case attr_length:
+ mr->attr_next=attr_time;
+ if (seg)
+ attr->u.num=seg->data->len;
+ else
+ return 0;
+ return 1;
+ case attr_time:
+ /* TODO This ignores access flags on traffic distortions, but the attribute does not seem
+ * to be used anywhere */
+ mr->attr_next=attr_speed;
+ if (seg)
+ attr->u.num=route_time_seg(route->vehicleprofile, seg->data, NULL);
+ else
+ return 0;
+ return 1;
+ case attr_speed:
+ /* TODO This ignores access flags on traffic distortions, but the attribute does not seem
+ * to be used anywhere */
+ mr->attr_next=attr_label;
+ if (seg)
+ attr->u.num=route_seg_speed(route->vehicleprofile, seg->data, NULL);
+ else
+ return 0;
+ return 1;
+ case attr_label:
+ mr->attr_next=attr_none;
+ if(mr->item.type==type_waypoint || mr->item.type == type_route_end) {
+ if(mr->str)
+ g_free(mr->str);
+ /* Build the text displayed close to the destination cursor.
+ * It will contain the sequence number of the waypoint (1, 2...) */
+ mr->str=g_strdup_printf("%d",route->reached_destinations_count+g_list_position(route->destinations,mr->dest)+1);
+ attr->u.str=mr->str;
+ return 1;
+ }
+ return 0;
+ default:
+ mr->attr_next=attr_none;
+ attr->type=attr_none;
+ return 0;
+ }
+ return 0;
+}
+
+static int rm_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr = priv_data;
+ struct route_path_segment *seg = mr->seg;
+ int i,rc=0;
+ struct route *r = mr->mpriv->route;
+ enum projection pro = route_projection(r);
+
+ if (pro == projection_none)
+ return 0;
+ if (mr->item.type == type_route_start || mr->item.type == type_route_start_reverse || mr->item.type == type_route_end
+ || mr->item.type == type_waypoint ) {
+ if (! count || mr->last_coord)
+ return 0;
+ mr->last_coord=1;
+ if (mr->item.type == type_route_start || mr->item.type == type_route_start_reverse)
+ c[0]=r->pos->c;
+ else if (mr->item.type == type_waypoint) {
+ c[0]=((struct route_info *)mr->dest->data)->c;
+ } else { /*type_route_end*/
+ c[0]=route_get_dst(r)->c;
+ }
+ return 1;
+ }
+ if (! seg)
+ return 0;
+ for (i=0; i < count; i++) {
+ if (mr->last_coord >= seg->ncoords)
+ break;
+ if (i >= seg->ncoords)
+ break;
+ if (pro != projection_mg)
+ transform_from_to(&seg->c[mr->last_coord++], pro,
+ &c[i],projection_mg);
+ else
+ c[i] = seg->c[mr->last_coord++];
+ rc++;
+ }
+ dbg(lvl_debug,"return %d",rc);
+ return rc;
}
static struct item_methods methods_route_item = {
- rm_coord_rewind,
- rm_coord_get,
- rm_attr_rewind,
- rm_attr_get,
+ rm_coord_rewind,
+ rm_coord_get,
+ rm_attr_rewind,
+ rm_attr_get,
};
-static void
-rp_attr_rewind(void *priv_data)
-{
- struct map_rect_priv *mr = priv_data;
- mr->attr_next = attr_label;
-}
-
-static int
-rp_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *mr = priv_data;
- struct route_graph_point *p = mr->point;
- struct route_graph_segment *seg = mr->rseg;
- struct route *route=mr->mpriv->route;
-
- attr->type=attr_type;
- switch (attr_type) {
- case attr_any: // works only with rg_points for now
- while (mr->attr_next != attr_none) {
- dbg(lvl_debug,"querying %s\n", attr_to_name(mr->attr_next));
- if (rp_attr_get(priv_data, mr->attr_next, attr))
- return 1;
- }
- return 0;
- case attr_maxspeed:
- mr->attr_next = attr_label;
- if (mr->item.type != type_rg_segment)
- return 0;
- if (seg && (seg->data.flags & AF_SPEED_LIMIT)) {
- attr->type = attr_maxspeed;
- attr->u.num=RSD_MAXSPEED(&seg->data);
- return 1;
- } else {
- return 0;
- }
- case attr_label:
- mr->attr_next=attr_street_item;
- attr->type = attr_label;
- if (mr->str)
- g_free(mr->str);
- if (mr->item.type == type_rg_point) {
- if (p->value != INT_MAX)
- mr->str=g_strdup_printf("%d", p->value);
- else
- mr->str=g_strdup("-");
- } else {
- int len=seg->data.len;
- int speed=route_seg_speed(route->vehicleprofile, &seg->data, NULL);
- int time=route_time_seg(route->vehicleprofile, &seg->data, NULL);
- if (speed)
- mr->str=g_strdup_printf("%dm %dkm/h %d.%ds",len,speed,time/10,time%10);
- else if (len)
- mr->str=g_strdup_printf("%dm",len);
- else {
- mr->str=NULL;
- return 0;
- }
- }
- attr->u.str = mr->str;
- return 1;
- case attr_street_item:
- mr->attr_next=attr_flags;
- if (mr->item.type != type_rg_segment)
- return 0;
- if (seg && seg->data.item.map)
- attr->u.item=&seg->data.item;
- else
- return 0;
- return 1;
- case attr_flags:
- mr->attr_next = attr_direction;
- if (mr->item.type != type_rg_segment)
- return 0;
- if (seg) {
- attr->u.num = seg->data.flags;
- } else {
- return 0;
- }
- return 1;
- case attr_direction:
- mr->attr_next = attr_debug;
- // This only works if the map has been opened at a single point, and in that case indicates if the
- // segment returned last is connected to this point via its start (1) or its end (-1)
- if (!mr->coord_sel || (mr->item.type != type_rg_segment))
- return 0;
- if (seg->start == mr->point) {
- attr->u.num=1;
- } else if (seg->end == mr->point) {
- attr->u.num=-1;
- } else {
- return 0;
- }
- return 1;
- case attr_debug:
- mr->attr_next=attr_none;
- if (mr->str)
- g_free(mr->str);
- mr->str=NULL;
- switch (mr->item.type) {
- case type_rg_point:
- {
- struct route_graph_segment *tmp;
- int start=0;
- int end=0;
- tmp=p->start;
- while (tmp) {
- start++;
- tmp=tmp->start_next;
- }
- tmp=p->end;
- while (tmp) {
- end++;
- tmp=tmp->end_next;
- }
- mr->str=g_strdup_printf("%d %d %p (0x%x,0x%x)", start, end, p, p->c.x, p->c.y);
- attr->u.str = mr->str;
- }
- return 1;
- case type_rg_segment:
- if (! seg)
- return 0;
- mr->str=g_strdup_printf("len %d time %d start %p end %p",seg->data.len, route_time_seg(route->vehicleprofile, &seg->data, NULL), seg->start, seg->end);
- attr->u.str = mr->str;
- return 1;
- default:
- return 0;
- }
- default:
- mr->attr_next=attr_none;
- attr->type=attr_none;
- return 0;
- }
+static void rp_attr_rewind(void *priv_data) {
+ struct map_rect_priv *mr = priv_data;
+ mr->attr_next = attr_label;
+}
+
+static int rp_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *mr = priv_data;
+ struct route_graph_point *p = mr->point;
+ struct route_graph_segment *seg = mr->rseg;
+ struct route *route=mr->mpriv->route;
+
+ attr->type=attr_type;
+ switch (attr_type) {
+ case attr_any: // works only with rg_points for now
+ while (mr->attr_next != attr_none) {
+ dbg(lvl_debug,"querying %s", attr_to_name(mr->attr_next));
+ if (rp_attr_get(priv_data, mr->attr_next, attr))
+ return 1;
+ }
+ return 0;
+ case attr_maxspeed:
+ mr->attr_next = attr_label;
+ if (mr->item.type != type_rg_segment)
+ return 0;
+ if (seg && (seg->data.flags & AF_SPEED_LIMIT)) {
+ attr->type = attr_maxspeed;
+ attr->u.num=RSD_MAXSPEED(&seg->data);
+ return 1;
+ } else {
+ return 0;
+ }
+ case attr_label:
+ mr->attr_next=attr_street_item;
+ attr->type = attr_label;
+ if (mr->str)
+ g_free(mr->str);
+ if (mr->item.type == type_rg_point) {
+ if (p->value != INT_MAX)
+ mr->str=g_strdup_printf("%d", p->value);
+ else
+ mr->str=g_strdup("-");
+ } else {
+ int len=seg->data.len;
+ int speed=route_seg_speed(route->vehicleprofile, &seg->data, NULL);
+ int time=route_time_seg(route->vehicleprofile, &seg->data, NULL);
+ if (speed)
+ mr->str=g_strdup_printf("%dm %dkm/h %d.%ds",len,speed,time/10,time%10);
+ else if (len)
+ mr->str=g_strdup_printf("%dm",len);
+ else {
+ mr->str=NULL;
+ return 0;
+ }
+ }
+ attr->u.str = mr->str;
+ return 1;
+ case attr_street_item:
+ mr->attr_next=attr_flags;
+ if (mr->item.type != type_rg_segment)
+ return 0;
+ if (seg && seg->data.item.map)
+ attr->u.item=&seg->data.item;
+ else
+ return 0;
+ return 1;
+ case attr_flags:
+ mr->attr_next = attr_direction;
+ if (mr->item.type != type_rg_segment)
+ return 0;
+ if (seg) {
+ attr->u.num = seg->data.flags;
+ } else {
+ return 0;
+ }
+ return 1;
+ case attr_direction:
+ mr->attr_next = attr_debug;
+ // This only works if the map has been opened at a single point, and in that case indicates if the
+ // segment returned last is connected to this point via its start (1) or its end (-1)
+ if (!mr->coord_sel || (mr->item.type != type_rg_segment))
+ return 0;
+ if (seg->start == mr->point) {
+ attr->u.num=1;
+ } else if (seg->end == mr->point) {
+ attr->u.num=-1;
+ } else {
+ return 0;
+ }
+ return 1;
+ case attr_debug:
+ mr->attr_next=attr_none;
+ if (mr->str)
+ g_free(mr->str);
+ mr->str=NULL;
+ switch (mr->item.type) {
+ case type_rg_point: {
+ struct route_graph_segment *tmp;
+ int start=0;
+ int end=0;
+ tmp=p->start;
+ while (tmp) {
+ start++;
+ tmp=tmp->start_next;
+ }
+ tmp=p->end;
+ while (tmp) {
+ end++;
+ tmp=tmp->end_next;
+ }
+ mr->str=g_strdup_printf("%d %d %p (0x%x,0x%x)", start, end, p, p->c.x, p->c.y);
+ attr->u.str = mr->str;
+ }
+ return 1;
+ case type_rg_segment:
+ if (! seg)
+ return 0;
+ mr->str=g_strdup_printf("len %d time %d start %p end %p",seg->data.len, route_time_seg(route->vehicleprofile,
+ &seg->data, NULL), seg->start, seg->end);
+ attr->u.str = mr->str;
+ return 1;
+ break;
+ default:
+ return 0;
+ }
+ break;
+ default:
+ mr->attr_next=attr_none;
+ attr->type=attr_none;
+ return 0;
+ }
}
/**
@@ -3611,101 +3705,83 @@ rp_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
* @param count How many coordinates to get at a max?
* @return The number of coordinates retrieved
*/
-static int
-rp_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *mr = priv_data;
- struct route_graph_point *p = mr->point;
- struct route_graph_segment *seg = mr->rseg;
- int rc = 0,i,dir;
- struct route *r = mr->mpriv->route;
- enum projection pro = route_projection(r);
-
- if (pro == projection_none)
- return 0;
- for (i=0; i < count; i++) {
- if (mr->item.type == type_rg_point) {
- if (mr->last_coord >= 1)
- break;
- if (pro != projection_mg)
- transform_from_to(&p->c, pro,
- &c[i],projection_mg);
- else
- c[i] = p->c;
- } else {
- if (mr->last_coord >= 2)
- break;
- dir=0;
- if (seg->end->seg == seg)
- dir=1;
- if (mr->last_coord)
- dir=1-dir;
- if (dir) {
- if (pro != projection_mg)
- transform_from_to(&seg->end->c, pro,
- &c[i],projection_mg);
- else
- c[i] = seg->end->c;
- } else {
- if (pro != projection_mg)
- transform_from_to(&seg->start->c, pro,
- &c[i],projection_mg);
- else
- c[i] = seg->start->c;
- }
- }
- mr->last_coord++;
- rc++;
- }
- return rc;
+static int rp_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *mr = priv_data;
+ struct route_graph_point *p = mr->point;
+ struct route_graph_segment *seg = mr->rseg;
+ int rc = 0,i,dir;
+ struct route *r = mr->mpriv->route;
+ enum projection pro = route_projection(r);
+
+ if (pro == projection_none)
+ return 0;
+ for (i=0; i < count; i++) {
+ if (mr->item.type == type_rg_point) {
+ if (mr->last_coord >= 1)
+ break;
+ if (pro != projection_mg)
+ transform_from_to(&p->c, pro,
+ &c[i],projection_mg);
+ else
+ c[i] = p->c;
+ } else {
+ if (mr->last_coord >= 2)
+ break;
+ dir=0;
+ if (seg->end->seg == seg)
+ dir=1;
+ if (mr->last_coord)
+ dir=1-dir;
+ if (dir) {
+ if (pro != projection_mg)
+ transform_from_to(&seg->end->c, pro,
+ &c[i],projection_mg);
+ else
+ c[i] = seg->end->c;
+ } else {
+ if (pro != projection_mg)
+ transform_from_to(&seg->start->c, pro,
+ &c[i],projection_mg);
+ else
+ c[i] = seg->start->c;
+ }
+ }
+ mr->last_coord++;
+ rc++;
+ }
+ return rc;
}
static struct item_methods methods_point_item = {
- rm_coord_rewind,
- rp_coord_get,
- rp_attr_rewind,
- rp_attr_get,
+ rm_coord_rewind,
+ rp_coord_get,
+ rp_attr_rewind,
+ rp_attr_get,
};
-static void
-rp_destroy(struct map_priv *priv)
-{
- g_free(priv);
+static void rp_destroy(struct map_priv *priv) {
+ g_free(priv);
}
-static void
-rm_destroy(struct map_priv *priv)
-{
- g_free(priv);
+static void rm_destroy(struct map_priv *priv) {
+ g_free(priv);
}
-static struct map_rect_priv *
-rm_rect_new(struct map_priv *priv, struct map_selection *sel)
-{
- struct map_rect_priv * mr;
- dbg(lvl_debug,"enter\n");
-#if 0
- if (! route_get_pos(priv->route))
- return NULL;
- if (! route_get_dst(priv->route))
- return NULL;
-#endif
-#if 0
- if (! priv->route->path2)
- return NULL;
-#endif
- mr=g_new0(struct map_rect_priv, 1);
- mr->mpriv = priv;
- mr->item.priv_data = mr;
- mr->item.type = type_none;
- mr->item.meth = &methods_route_item;
- if (priv->route->path2) {
- mr->path=priv->route->path2;
- mr->seg_next=mr->path->path;
- mr->path->in_use++;
- } else
- mr->seg_next=NULL;
- return mr;
+static struct map_rect_priv *rm_rect_new(struct map_priv *priv, struct map_selection *sel) {
+ struct map_rect_priv * mr;
+ dbg(lvl_debug,"enter");
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->mpriv = priv;
+ mr->item.priv_data = mr;
+ mr->item.type = type_none;
+ mr->item.meth = &methods_route_item;
+ if (priv->route->path2) {
+ mr->path=priv->route->path2;
+ mr->seg_next=mr->path->path;
+ mr->path->in_use++;
+ } else
+ mr->seg_next=NULL;
+ return mr;
}
/**
@@ -3714,7 +3790,7 @@ rm_rect_new(struct map_priv *priv, struct map_selection *sel)
* This function opens a new map rectangle on the route graph's map.
* The "sel" parameter enables you to only search for a single route graph
* point on this map (or exactly: open a map rectangle that only contains
- * this one point). To do this, pass here a single map selection, whose
+ * this one point). To do this, pass here a single map selection, whose
* c_rect has both coordinates set to the same point. Otherwise this parameter
* has no effect.
*
@@ -3722,283 +3798,291 @@ rm_rect_new(struct map_priv *priv, struct map_selection *sel)
* @param sel Here it's possible to specify a point for which to search. Please read the function's description.
* @return A new map rect's private data
*/
-static struct map_rect_priv *
-rp_rect_new(struct map_priv *priv, struct map_selection *sel)
-{
- struct map_rect_priv * mr;
-
- dbg(lvl_debug,"enter\n");
- if (! priv->route->graph)
- return NULL;
- mr=g_new0(struct map_rect_priv, 1);
- mr->mpriv = priv;
- mr->item.priv_data = mr;
- mr->item.type = type_rg_point;
- mr->item.meth = &methods_point_item;
- if (sel) {
- if ((sel->u.c_rect.lu.x == sel->u.c_rect.rl.x) && (sel->u.c_rect.lu.y == sel->u.c_rect.rl.y)) {
- mr->coord_sel = g_malloc(sizeof(struct coord));
- *(mr->coord_sel) = sel->u.c_rect.lu;
- }
- }
- return mr;
-}
-
-static void
-rm_rect_destroy(struct map_rect_priv *mr)
-{
- if (mr->str)
- g_free(mr->str);
- if (mr->coord_sel) {
- g_free(mr->coord_sel);
- }
- if (mr->path) {
- mr->path->in_use--;
- if (mr->path->update_required && (mr->path->in_use==1) && (mr->mpriv->route->route_status & ~route_status_destination_set))
- route_path_update_done(mr->mpriv->route, mr->path->update_required-1);
- else if (!mr->path->in_use)
- g_free(mr->path);
- }
-
- g_free(mr);
-}
-
-static struct item *
-rp_get_item(struct map_rect_priv *mr)
-{
- struct route *r = mr->mpriv->route;
- struct route_graph_point *p = mr->point;
- struct route_graph_segment *seg = mr->rseg;
-
- if (mr->item.type == type_rg_point) {
- if (mr->coord_sel) {
- // We are supposed to return only the point at one specified coordinate...
- if (!p) {
- p = route_graph_get_point_last(r->graph, mr->coord_sel);
- if (!p) {
- mr->point = NULL; // This indicates that no point has been found
- } else {
- mr->it = rp_iterator_new(p);
- }
- } else {
- p = NULL;
- }
- } else {
- if (!p) {
- mr->hash_bucket=0;
- p = r->graph->hash[0];
- } else
- p=p->hash_next;
- while (!p) {
- mr->hash_bucket++;
- if (mr->hash_bucket >= HASH_SIZE)
- break;
- p = r->graph->hash[mr->hash_bucket];
- }
- }
- if (p) {
- mr->point = p;
- mr->item.id_lo++;
- rm_coord_rewind(mr);
- rp_attr_rewind(mr);
- return &mr->item;
- } else
- mr->item.type = type_rg_segment;
- }
-
-
- if (mr->coord_sel) {
- if (!mr->point) { /* This means that no point has been found */
- return NULL;
- }
- seg = rp_iterator_next(&(mr->it));
- } else {
- if (!seg)
- seg=r->graph->route_segments;
- else
- seg=seg->next;
- }
-
- if (seg) {
- mr->rseg = seg;
- mr->item.id_lo++;
- rm_coord_rewind(mr);
- rp_attr_rewind(mr);
- return &mr->item;
- }
- return NULL;
-
-}
-
-static struct item *
-rp_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- struct item *ret=NULL;
- while (id_lo-- > 0)
- ret=rp_get_item(mr);
- return ret;
-}
-
-
-static struct item *
-rm_get_item(struct map_rect_priv *mr)
-{
- struct route *route=mr->mpriv->route;
- void *id=0;
-
- switch (mr->item.type) {
- case type_none:
- if (route->pos && route->pos->street_direction && route->pos->street_direction != route->pos->dir)
- mr->item.type=type_route_start_reverse;
- else
- mr->item.type=type_route_start;
- if (route->pos) {
- id=route->pos;
- break;
- }
-
- case type_route_start:
- case type_route_start_reverse:
- mr->seg=NULL;
- mr->dest=mr->mpriv->route->destinations;
- default:
- if (mr->item.type == type_waypoint)
- mr->dest=g_list_next(mr->dest);
- mr->item.type=type_street_route;
- mr->seg=mr->seg_next;
- if (!mr->seg && mr->path && mr->path->next) {
- struct route_path *p=NULL;
- mr->path->in_use--;
- if (!mr->path->in_use)
- p=mr->path;
- mr->path=mr->path->next;
- mr->path->in_use++;
- mr->seg=mr->path->path;
- if (p)
- g_free(p);
- if (mr->dest) {
- id=mr->dest;
- mr->item.type=type_waypoint;
- mr->seg_next=mr->seg;
- break;
- }
- }
- if (mr->seg) {
- mr->seg_next=mr->seg->next;
- id=mr->seg;
- break;
- }
- if (mr->dest && g_list_next(mr->dest)) {
- id=mr->dest;
- mr->item.type=type_waypoint;
- break;
- }
- mr->item.type=type_route_end;
- id=&(mr->mpriv->route->destinations);
- if (mr->mpriv->route->destinations)
- break;
- case type_route_end:
- return NULL;
- }
- mr->last_coord = 0;
- item_id_from_ptr(&mr->item,id);
- rm_attr_rewind(mr);
- return &mr->item;
-}
-
-static struct item *
-rm_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo)
-{
- struct item *ret=NULL;
- do {
- ret=rm_get_item(mr);
- } while (ret && (ret->id_lo!=id_lo || ret->id_hi!=id_hi));
- return ret;
+static struct map_rect_priv *rp_rect_new(struct map_priv *priv, struct map_selection *sel) {
+ struct map_rect_priv * mr;
+
+ dbg(lvl_debug,"enter");
+ if (! priv->route->graph)
+ return NULL;
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->mpriv = priv;
+ mr->item.priv_data = mr;
+ mr->item.type = type_rg_point;
+ mr->item.meth = &methods_point_item;
+ if (sel) {
+ if ((sel->u.c_rect.lu.x == sel->u.c_rect.rl.x) && (sel->u.c_rect.lu.y == sel->u.c_rect.rl.y)) {
+ mr->coord_sel = g_malloc(sizeof(struct coord));
+ *(mr->coord_sel) = sel->u.c_rect.lu;
+ }
+ }
+ return mr;
+}
+
+static void rm_rect_destroy(struct map_rect_priv *mr) {
+ if (mr->str)
+ g_free(mr->str);
+ if (mr->coord_sel) {
+ g_free(mr->coord_sel);
+ }
+ if (mr->path) {
+ mr->path->in_use--;
+ if (mr->path->update_required && (mr->path->in_use==1)
+ && (mr->mpriv->route->route_status & ~route_status_destination_set))
+ route_path_update_done(mr->mpriv->route, mr->path->update_required-1);
+ else if (!mr->path->in_use)
+ g_free(mr->path);
+ }
+
+ g_free(mr);
+}
+
+static struct item *rp_get_item(struct map_rect_priv *mr) {
+ struct route *r = mr->mpriv->route;
+ struct route_graph_point *p = mr->point;
+ struct route_graph_segment *seg = mr->rseg;
+
+ if (mr->item.type == type_rg_point) {
+ if (mr->coord_sel) {
+ // We are supposed to return only the point at one specified coordinate...
+ if (!p) {
+ p = route_graph_get_point_last(r->graph, mr->coord_sel);
+ if (!p) {
+ mr->point = NULL; // This indicates that no point has been found
+ } else {
+ mr->it = rp_iterator_new(p);
+ }
+ } else {
+ p = NULL;
+ }
+ } else {
+ if (!p) {
+ mr->hash_bucket=0;
+ p = r->graph->hash[0];
+ } else
+ p=p->hash_next;
+ while (!p) {
+ mr->hash_bucket++;
+ if (mr->hash_bucket >= HASH_SIZE)
+ break;
+ p = r->graph->hash[mr->hash_bucket];
+ }
+ }
+ if (p) {
+ mr->point = p;
+ mr->item.id_lo++;
+ rm_coord_rewind(mr);
+ rp_attr_rewind(mr);
+ return &mr->item;
+ } else
+ mr->item.type = type_rg_segment;
+ }
+
+
+ if (mr->coord_sel) {
+ if (!mr->point) { /* This means that no point has been found */
+ return NULL;
+ }
+ seg = rp_iterator_next(&(mr->it));
+ } else {
+ if (!seg)
+ seg=r->graph->route_segments;
+ else
+ seg=seg->next;
+ }
+
+ if (seg) {
+ mr->rseg = seg;
+ mr->item.id_lo++;
+ rm_coord_rewind(mr);
+ rp_attr_rewind(mr);
+ return &mr->item;
+ }
+ return NULL;
+
+}
+
+static struct item *rp_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ struct item *ret=NULL;
+ while (id_lo-- > 0)
+ ret=rp_get_item(mr);
+ return ret;
+}
+
+
+static struct item *rm_get_item(struct map_rect_priv *mr) {
+ struct route *route=mr->mpriv->route;
+ void *id=0;
+
+ switch (mr->item.type) {
+ case type_none:
+ if (route->pos && route->pos->street_direction && route->pos->street_direction != route->pos->dir)
+ mr->item.type=type_route_start_reverse;
+ else
+ mr->item.type=type_route_start;
+ if (route->pos) {
+ id=route->pos;
+ break;
+ }
+ /* FALLTHRU */
+
+ case type_route_start:
+ case type_route_start_reverse:
+ mr->seg=NULL;
+ mr->dest=mr->mpriv->route->destinations;
+ /* FALLTHRU */
+ default:
+ if (mr->item.type == type_waypoint)
+ mr->dest=g_list_next(mr->dest);
+ mr->item.type=type_street_route;
+ mr->seg=mr->seg_next;
+ if (!mr->seg && mr->path && mr->path->next) {
+ struct route_path *p=NULL;
+ mr->path->in_use--;
+ if (!mr->path->in_use)
+ p=mr->path;
+ mr->path=mr->path->next;
+ mr->path->in_use++;
+ mr->seg=mr->path->path;
+ if (p)
+ g_free(p);
+ if (mr->dest) {
+ id=mr->dest;
+ mr->item.type=type_waypoint;
+ mr->seg_next=mr->seg;
+ break;
+ }
+ }
+ if (mr->seg) {
+ mr->seg_next=mr->seg->next;
+ id=mr->seg;
+ break;
+ }
+ if (mr->dest && g_list_next(mr->dest)) {
+ id=mr->dest;
+ mr->item.type=type_waypoint;
+ break;
+ }
+ mr->item.type=type_route_end;
+ id=&(mr->mpriv->route->destinations);
+ if (mr->mpriv->route->destinations)
+ break;
+ /* FALLTHRU */
+ case type_route_end:
+ return NULL;
+ }
+ mr->last_coord = 0;
+ item_id_from_ptr(&mr->item,id);
+ rm_attr_rewind(mr);
+ return &mr->item;
+}
+
+static struct item *rm_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ struct item *ret=NULL;
+ do {
+ ret=rm_get_item(mr);
+ } while (ret && (ret->id_lo!=id_lo || ret->id_hi!=id_hi));
+ return ret;
}
static struct map_methods route_meth = {
- projection_mg,
- "utf-8",
- rm_destroy,
- rm_rect_new,
- rm_rect_destroy,
- rm_get_item,
- rm_get_item_byid,
- NULL,
- NULL,
- NULL,
+ projection_mg,
+ "utf-8",
+ rm_destroy,
+ rm_rect_new,
+ rm_rect_destroy,
+ rm_get_item,
+ rm_get_item_byid,
+ NULL,
+ NULL,
+ NULL,
};
static struct map_methods route_graph_meth = {
- projection_mg,
- "utf-8",
- rp_destroy,
- rp_rect_new,
- rm_rect_destroy,
- rp_get_item,
- rp_get_item_byid,
- NULL,
- NULL,
- NULL,
+ projection_mg,
+ "utf-8",
+ rp_destroy,
+ rp_rect_new,
+ rm_rect_destroy,
+ rp_get_item,
+ rp_get_item_byid,
+ NULL,
+ NULL,
+ NULL,
};
-static struct map_priv *
-route_map_new_helper(struct map_methods *meth, struct attr **attrs, int graph)
-{
- struct map_priv *ret;
- struct attr *route_attr;
-
- route_attr=attr_search(attrs, NULL, attr_route);
- if (! route_attr)
- return NULL;
- ret=g_new0(struct map_priv, 1);
- if (graph)
- *meth=route_graph_meth;
- else
- *meth=route_meth;
- ret->route=route_attr->u.route;
-
- return ret;
-}
-
-static struct map_priv *
-route_map_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- return route_map_new_helper(meth, attrs, 0);
-}
-
-static struct map_priv *
-route_graph_map_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- return route_map_new_helper(meth, attrs, 1);
-}
-
-static struct map *
-route_get_map_helper(struct route *this_, struct map **map, char *type, char *description)
-{
- struct attr *attrs[5];
- struct attr a_type,navigation,data,a_description;
- a_type.type=attr_type;
- a_type.u.str=type;
- navigation.type=attr_route;
- navigation.u.route=this_;
- data.type=attr_data;
- data.u.str="";
- a_description.type=attr_description;
- a_description.u.str=description;
-
- attrs[0]=&a_type;
- attrs[1]=&navigation;
- attrs[2]=&data;
- attrs[3]=&a_description;
- attrs[4]=NULL;
-
- if (! *map) {
- *map=map_new(NULL, attrs);
- navit_object_ref((struct navit_object *)*map);
- }
-
- return *map;
+static struct map_priv *route_map_new_helper(struct map_methods *meth, struct attr **attrs, int graph) {
+ struct map_priv *ret;
+ struct attr *route_attr;
+
+ route_attr=attr_search(attrs, NULL, attr_route);
+ if (! route_attr)
+ return NULL;
+ ret=g_new0(struct map_priv, 1);
+ if (graph)
+ *meth=route_graph_meth;
+ else
+ *meth=route_meth;
+ ret->route=route_attr->u.route;
+
+ return ret;
+}
+
+static struct map_priv *route_map_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ return route_map_new_helper(meth, attrs, 0);
+}
+
+static struct map_priv *route_graph_map_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ return route_map_new_helper(meth, attrs, 1);
+}
+
+static struct map *route_get_map_helper(struct route *this_, struct map **map, char *type, char *description) {
+ struct attr *attrs[5];
+ struct attr a_type,navigation,data,a_description;
+ a_type.type=attr_type;
+ a_type.u.str=type;
+ navigation.type=attr_route;
+ navigation.u.route=this_;
+ data.type=attr_data;
+ data.u.str="";
+ a_description.type=attr_description;
+ a_description.u.str=description;
+
+ attrs[0]=&a_type;
+ attrs[1]=&navigation;
+ attrs[2]=&data;
+ attrs[3]=&a_description;
+ attrs[4]=NULL;
+
+ if (! *map) {
+ *map=map_new(NULL, attrs);
+ navit_object_ref((struct navit_object *)*map);
+ }
+
+ return *map;
+}
+
+/**
+ * @brief Adds a traffic distortion item to the route
+ *
+ * @param this_ The route
+ * @param item The item to add, must be of {@code type_traffic_distortion}
+ */
+void route_add_traffic_distortion(struct route *this_, struct item *item) {
+ if (route_has_graph(this_))
+ route_graph_add_traffic_distortion(this_->graph, this_->vehicleprofile, item, 1);
+}
+
+/**
+ * @brief Changes a traffic distortion item on the route
+ *
+ * Attempting to change an idem which is not in the route graph will add it.
+ *
+ * @param this_ The route
+ * @param item The item to change, must be of {@code type_traffic_distortion}
+ */
+void route_change_traffic_distortion(struct route *this_, struct item *item) {
+ if (route_has_graph(this_))
+ route_graph_change_traffic_distortion(this_->graph, this_->vehicleprofile, item);
}
/**
@@ -4012,9 +4096,8 @@ route_get_map_helper(struct route *this_, struct map **map, char *type, char *de
* @return A new map containing the route path
*/
struct map *
-route_get_map(struct route *this_)
-{
- return route_get_map_helper(this_, &this_->map, "route","Route");
+route_get_map(struct route *this_) {
+ return route_get_map_helper(this_, &this_->map, "route","Route");
}
@@ -4029,9 +4112,8 @@ route_get_map(struct route *this_)
* @return A new map containing the route graph
*/
struct map *
-route_get_graph_map(struct route *this_)
-{
- return route_get_map_helper(this_, &this_->graph_map, "route_graph","Route Graph");
+route_get_graph_map(struct route *this_) {
+ return route_get_map_helper(this_, &this_->graph_map, "route_graph","Route Graph");
}
@@ -4039,7 +4121,16 @@ route_get_graph_map(struct route *this_)
* @brief Returns the flags for the route.
*/
enum route_path_flags route_get_flags(struct route *this_) {
- return this_->flags;
+ return this_->flags;
+}
+
+/**
+ * @brief Retrieves the route graph.
+ *
+ * @return The route graph, or NULL if the route has no valid graph
+ */
+struct route_graph * route_get_graph(struct route *this_) {
+ return this_->graph;
}
/**
@@ -4047,204 +4138,201 @@ enum route_path_flags route_get_flags(struct route *this_) {
*
* @return True if the route has a graph, false if not.
*/
-int
-route_has_graph(struct route *this_) {
- return (this_->graph != NULL);
-}
-
-void
-route_set_projection(struct route *this_, enum projection pro)
-{
-}
-
-int
-route_set_attr(struct route *this_, struct attr *attr)
-{
- int attr_updated=0;
- switch (attr->type) {
- case attr_route_status:
- attr_updated = (this_->route_status != attr->u.num);
- this_->route_status = attr->u.num;
- break;
- case attr_destination:
- route_set_destination(this_, attr->u.pcoord, 1);
- return 1;
- case attr_position:
- route_set_position_flags(this_, attr->u.pcoord, route_path_flag_async);
- return 1;
- case attr_position_test:
- return route_set_position_flags(this_, attr->u.pcoord, route_path_flag_no_rebuild);
- case attr_vehicle:
- attr_updated = (this_->v != attr->u.vehicle);
- this_->v=attr->u.vehicle;
- if (attr_updated) {
- struct attr g;
- struct pcoord pc;
- struct coord c;
- if (vehicle_get_attr(this_->v, attr_position_coord_geo, &g, NULL)) {
- pc.pro=projection_mg;
- transform_from_geo(projection_mg, g.u.coord_geo, &c);
- pc.x=c.x;
- pc.y=c.y;
- route_set_position(this_, &pc);
- }
- }
- break;
- default:
- dbg(lvl_error,"unsupported attribute: %s\n",attr_to_name(attr->type));
- return 0;
- }
- if (attr_updated)
- callback_list_call_attr_2(this_->cbl2, attr->type, this_, attr);
- return 1;
-}
-
-int
-route_add_attr(struct route *this_, struct attr *attr)
-{
- switch (attr->type) {
- case attr_callback:
- callback_list_add(this_->cbl2, attr->u.callback);
- return 1;
- default:
- return 0;
- }
-}
-
-int
-route_remove_attr(struct route *this_, struct attr *attr)
-{
- dbg(lvl_debug,"enter\n");
- switch (attr->type) {
- case attr_callback:
- callback_list_remove(this_->cbl2, attr->u.callback);
- return 1;
- case attr_vehicle:
- this_->v=NULL;
- return 1;
- default:
- return 0;
- }
-}
-
-int
-route_get_attr(struct route *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- int ret=1;
- switch (type) {
- case attr_map:
- attr->u.map=route_get_map(this_);
- ret=(attr->u.map != NULL);
- break;
- case attr_destination:
- if (this_->destinations) {
- struct route_info *dst;
- if (iter) {
- if (iter->u.list) {
- iter->u.list=g_list_next(iter->u.list);
- } else {
- iter->u.list=this_->destinations;
- }
- if (!iter->u.list) {
- return 0;
- }
- dst = (struct route_info*)iter->u.list->data;
- } else { //No iter handling
- dst=route_get_dst(this_);
- }
- attr->u.pcoord=&this_->pc;
- this_->pc.pro=projection_mg; /* fixme */
- this_->pc.x=dst->c.x;
- this_->pc.y=dst->c.y;
- } else
- ret=0;
- break;
- case attr_vehicle:
- attr->u.vehicle=this_->v;
- ret=(this_->v != NULL);
- dbg(lvl_debug,"get vehicle %p\n",this_->v);
- break;
- case attr_vehicleprofile:
- attr->u.vehicleprofile=this_->vehicleprofile;
- ret=(this_->vehicleprofile != NULL);
- break;
- case attr_route_status:
- attr->u.num=this_->route_status;
- break;
- case attr_destination_time:
- if (this_->path2 && (this_->route_status == route_status_path_done_new || this_->route_status == route_status_path_done_incremental)) {
- struct route_path *path=this_->path2;
- attr->u.num=0;
- while (path) {
- attr->u.num+=path->path_time;
- path=path->next;
- }
- dbg(lvl_debug,"path_time %ld\n",attr->u.num);
- } else
- ret=0;
- break;
- case attr_destination_length:
- if (this_->path2 && (this_->route_status == route_status_path_done_new || this_->route_status == route_status_path_done_incremental)) {
- struct route_path *path=this_->path2;
- attr->u.num=0;
- while (path) {
- attr->u.num+=path->path_len;
- path=path->next;
- }
- } else
- ret=0;
- break;
- default:
- return 0;
- }
- attr->type=type;
- return ret;
+int route_has_graph(struct route *this_) {
+ return (this_->graph != NULL);
+}
+
+/**
+ * @brief Removes a traffic distortion item from the route
+ *
+ * Removing a traffic distortion which is not in the route graph is a no-op.
+ *
+ * @param this_ The route
+ * @param item The item to remove, must be of {@code type_traffic_distortion}
+ */
+void route_remove_traffic_distortion(struct route *this_, struct item *item) {
+ if (route_has_graph(this_))
+ route_graph_remove_traffic_distortion(this_->graph, this_->vehicleprofile, item);
+}
+
+void route_set_projection(struct route *this_, enum projection pro) {
+}
+
+int route_set_attr(struct route *this_, struct attr *attr) {
+ int attr_updated=0;
+ switch (attr->type) {
+ case attr_route_status:
+ attr_updated = (this_->route_status != attr->u.num);
+ this_->route_status = attr->u.num;
+ break;
+ case attr_destination:
+ route_set_destination(this_, attr->u.pcoord, 1);
+ return 1;
+ case attr_position:
+ route_set_position_flags(this_, attr->u.pcoord, route_path_flag_async);
+ return 1;
+ case attr_position_test:
+ return route_set_position_flags(this_, attr->u.pcoord, route_path_flag_no_rebuild);
+ case attr_vehicle:
+ attr_updated = (this_->v != attr->u.vehicle);
+ this_->v=attr->u.vehicle;
+ if (attr_updated) {
+ struct attr g;
+ struct pcoord pc;
+ struct coord c;
+ if (vehicle_get_attr(this_->v, attr_position_coord_geo, &g, NULL)) {
+ pc.pro=projection_mg;
+ transform_from_geo(projection_mg, g.u.coord_geo, &c);
+ pc.x=c.x;
+ pc.y=c.y;
+ route_set_position(this_, &pc);
+ }
+ }
+ break;
+ default:
+ dbg(lvl_error,"unsupported attribute: %s",attr_to_name(attr->type));
+ return 0;
+ }
+ if (attr_updated)
+ callback_list_call_attr_2(this_->cbl2, attr->type, this_, attr);
+ return 1;
+}
+
+int route_add_attr(struct route *this_, struct attr *attr) {
+ switch (attr->type) {
+ case attr_callback:
+ callback_list_add(this_->cbl2, attr->u.callback);
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+int route_remove_attr(struct route *this_, struct attr *attr) {
+ dbg(lvl_debug,"enter");
+ switch (attr->type) {
+ case attr_callback:
+ callback_list_remove(this_->cbl2, attr->u.callback);
+ return 1;
+ case attr_vehicle:
+ this_->v=NULL;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+int route_get_attr(struct route *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ int ret=1;
+ switch (type) {
+ case attr_map:
+ attr->u.map=route_get_map(this_);
+ ret=(attr->u.map != NULL);
+ break;
+ case attr_destination:
+ if (this_->destinations) {
+ struct route_info *dst;
+ if (iter) {
+ if (iter->u.list) {
+ iter->u.list=g_list_next(iter->u.list);
+ } else {
+ iter->u.list=this_->destinations;
+ }
+ if (!iter->u.list) {
+ return 0;
+ }
+ dst = (struct route_info*)iter->u.list->data;
+ } else { //No iter handling
+ dst=route_get_dst(this_);
+ }
+ attr->u.pcoord=&this_->pc;
+ this_->pc.pro=projection_mg; /* fixme */
+ this_->pc.x=dst->c.x;
+ this_->pc.y=dst->c.y;
+ } else
+ ret=0;
+ break;
+ case attr_vehicle:
+ attr->u.vehicle=this_->v;
+ ret=(this_->v != NULL);
+ dbg(lvl_debug,"get vehicle %p",this_->v);
+ break;
+ case attr_vehicleprofile:
+ attr->u.vehicleprofile=this_->vehicleprofile;
+ ret=(this_->vehicleprofile != NULL);
+ break;
+ case attr_route_status:
+ attr->u.num=this_->route_status;
+ break;
+ case attr_destination_time:
+ if (this_->path2 && (this_->route_status == route_status_path_done_new
+ || this_->route_status == route_status_path_done_incremental)) {
+ struct route_path *path=this_->path2;
+ attr->u.num=0;
+ while (path) {
+ attr->u.num+=path->path_time;
+ path=path->next;
+ }
+ dbg(lvl_debug,"path_time %ld",attr->u.num);
+ } else
+ ret=0;
+ break;
+ case attr_destination_length:
+ if (this_->path2 && (this_->route_status == route_status_path_done_new
+ || this_->route_status == route_status_path_done_incremental)) {
+ struct route_path *path=this_->path2;
+ attr->u.num=0;
+ while (path) {
+ attr->u.num+=path->path_len;
+ path=path->next;
+ }
+ } else
+ ret=0;
+ break;
+ default:
+ return 0;
+ }
+ attr->type=type;
+ return ret;
}
struct attr_iter *
-route_attr_iter_new(void)
-{
- return g_new0(struct attr_iter, 1);
+route_attr_iter_new(void) {
+ return g_new0(struct attr_iter, 1);
}
-void
-route_attr_iter_destroy(struct attr_iter *iter)
-{
- g_free(iter);
+void route_attr_iter_destroy(struct attr_iter *iter) {
+ g_free(iter);
}
-void
-route_init(void)
-{
- plugin_register_category_map("route", route_map_new);
- plugin_register_category_map("route_graph", route_graph_map_new);
+void route_init(void) {
+ plugin_register_category_map("route", route_map_new);
+ plugin_register_category_map("route_graph", route_graph_map_new);
}
-void
-route_destroy(struct route *this_)
-{
- this_->refcount++; /* avoid recursion */
- route_path_destroy(this_->path2,1);
- route_graph_destroy(this_->graph);
- route_clear_destinations(this_);
- route_info_free(this_->pos);
- map_destroy(this_->map);
- map_destroy(this_->graph_map);
- g_free(this_);
+void route_destroy(struct route *this_) {
+ this_->refcount++; /* avoid recursion */
+ route_path_destroy(this_->path2,1);
+ route_graph_destroy(this_->graph);
+ route_clear_destinations(this_);
+ route_info_free(this_->pos);
+ map_destroy(this_->map);
+ map_destroy(this_->graph_map);
+ g_free(this_);
}
struct object_func route_func = {
- attr_route,
- (object_func_new)route_new,
- (object_func_get_attr)route_get_attr,
- (object_func_iter_new)NULL,
- (object_func_iter_destroy)NULL,
- (object_func_set_attr)route_set_attr,
- (object_func_add_attr)route_add_attr,
- (object_func_remove_attr)route_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)route_destroy,
- (object_func_dup)route_dup,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_route,
+ (object_func_new)route_new,
+ (object_func_get_attr)route_get_attr,
+ (object_func_iter_new)NULL,
+ (object_func_iter_destroy)NULL,
+ (object_func_set_attr)route_set_attr,
+ (object_func_add_attr)route_add_attr,
+ (object_func_remove_attr)route_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)route_destroy,
+ (object_func_dup)route_dup,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/route.h b/navit/route.h
index 5f55f804c..9a5ee35cb 100644
--- a/navit/route.h
+++ b/navit/route.h
@@ -18,7 +18,7 @@
*/
/** @file
- *
+ *
* @brief Contains exported code for route.c
*
* This file contains code that works together with route.c and that is exported to
diff --git a/navit/route_protected.h b/navit/route_protected.h
new file mode 100644
index 000000000..9b7bf62f6
--- /dev/null
+++ b/navit/route_protected.h
@@ -0,0 +1,184 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * @file route_private.h
+ *
+ * @brief Contains protected exports for route.c
+ *
+ * This file contains code that is exported by route.c. Unlike the exports in route.h, exports in this
+ * file are intended only for use by modules which are closely related to routing. They are not part of
+ * the public route API.
+ */
+
+#ifndef NAVIT_ROUTE_PROTECTED_H
+#define NAVIT_ROUTE_PROTECTED_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define RP_TRAFFIC_DISTORTION 1
+#define RP_TURN_RESTRICTION 2
+#define RP_TURN_RESTRICTION_RESOLVED 4
+
+#define RSD_MAXSPEED(x) *((int *)route_segment_data_field_pos((x), attr_maxspeed))
+
+/**
+ * @brief A point in the route graph
+ *
+ * This represents a point in the route graph. A point usually connects two or more segments,
+ * but there are also points which don't do that (e.g. at the end of a dead-end).
+ */
+struct route_graph_point {
+ struct route_graph_point *hash_next; /**< Pointer to a chained hashlist of all route_graph_points with this hash */
+ struct route_graph_segment *start; /**< Pointer to a list of segments of which this point is the start. The links
+ * of this linked-list are in route_graph_segment->start_next.*/
+ struct route_graph_segment *end; /**< Pointer to a list of segments of which this pointer is the end. The links
+ * of this linked-list are in route_graph_segment->end_next. */
+ struct route_graph_segment *seg; /**< Pointer to the segment one should use to reach the destination at
+ * least costs */
+ struct fibheap_el *el; /**< When this point is put on a Fibonacci heap, this is a pointer
+ * to this point's heap element */
+ int value; /**< The cost at which one can reach the destination from this point on.
+ * {@code INT_MAX} indicates that the destination is unreachable from this
+ * point, or that this point has not yet been examined. */
+ int rhs; /**< Lookahead value based on neighbors’ `value`; used for recalculation and
+ * equal to `value` after the route graph has been flooded. */
+ int dst_val; /**< For points close to the destination, this is the cost of the point if it
+ * is the last in the graph; `INT_MAX` for all other points. */
+ struct route_graph_segment *dst_seg; /**< For points close to the destination, this is the segment over which the
+ * destination can be reached directly */
+ struct coord c; /**< Coordinates of this point */
+ int flags; /**< Flags for this point (e.g. traffic distortion) */
+};
+
+/**
+ * @brief A segment in the route graph or path
+ *
+ * This is a segment in the route graph or path. A segment represents a driveable way.
+ */
+struct route_segment_data {
+ struct item item; /**< The item (e.g. street) that this segment represents. */
+ int flags; /**< Flags e.g. for access, restrictions, segmentation or roundabouts. */
+ int len; /**< Length of this segment, in meters */
+ int score; /**< Used by the traffic module to give preference to some
+ * segments over others */
+ /*NOTE: After a segment, various fields may follow, depending on what flags are set. Order of fields:
+ 1.) maxspeed Maximum allowed speed on this segment. Present if AF_SPEED_LIMIT is set.
+ 2.) offset If the item is segmented (i.e. represented by more than one segment), this
+ indicates the position of this segment in the item. Present if AF_SEGMENTED is set.
+ */
+};
+
+/**
+ * @brief Size and weight limits for a route segment
+ */
+struct size_weight_limit {
+ int width;
+ int length;
+ int height;
+ int weight;
+ int axle_weight;
+};
+
+/**
+ * @brief Data for a segment in the route graph
+ */
+struct route_graph_segment_data {
+ struct item *item; /**< The item which this segment is part of */
+ int offset; /**< If the item passed in "item" is segmented (i.e. divided
+ * into several segments), this indicates the position of
+ * this segment within the item */
+ int flags; /**< Flags for this segment */
+ int len; /**< The length of this segment */
+ int maxspeed; /**< The maximum speed allowed on this segment in km/h,
+ * -1 if not known */
+ struct size_weight_limit size_weight; /**< Size and weight limits for this segment */
+ int dangerous_goods;
+ int score; /**< Used by the traffic module to give preference to some
+ * segments over others */
+};
+
+/**
+ * @brief A segment in the route graph
+ *
+ * This is a segment in the route graph. A segment represents a driveable way.
+ */
+struct route_graph_segment {
+ struct route_graph_segment *next; /**< Linked-list pointer to a list of all route_graph_segments */
+ struct route_graph_segment *start_next; /**< Pointer to the next element in the list of segments that start at the
+ * same point. Start of this list is in route_graph_point->start. */
+ struct route_graph_segment *end_next; /**< Pointer to the next element in the list of segments that end at the
+ * same point. Start of this list is in route_graph_point->end. */
+ struct route_graph_point *start; /**< Pointer to the point this segment starts at. */
+ struct route_graph_point *end; /**< Pointer to the point this segment ends at. */
+ struct route_segment_data data; /**< The segment data */
+};
+
+/**
+ * @brief A complete route graph
+ *
+ * The route graph holds all routable segments along with the connections between them and the cost of
+ * each segment.
+ */
+struct route_graph {
+ int busy; /**< The graph is being built */
+ struct map_selection *sel; /**< The rectangle selection for the graph */
+ struct mapset_handle *h; /**< Handle to the mapset */
+ struct map *m; /**< Pointer to the currently active map */
+ struct map_rect *mr; /**< Pointer to the currently active map rectangle */
+ struct vehicleprofile *vehicleprofile; /**< The vehicle profile */
+ struct callback *idle_cb; /**< Idle callback to process the graph */
+ struct callback *done_cb; /**< Callback when graph is done */
+ struct event_idle *idle_ev; /**< The pointer to the idle event */
+ struct route_graph_segment *route_segments; /**< Pointer to the first route_graph_segment in the linked list of all segments */
+ struct route_graph_segment *avoid_seg;
+ struct fibheap *heap; /**< Priority queue for points to be expanded */
+#define HASH_SIZE 8192
+ struct route_graph_point *hash[HASH_SIZE]; /**< A hashtable containing all route_graph_points in this graph */
+};
+
+
+/* prototypes */
+struct route_graph * route_get_graph(struct route *this_);
+void route_add_traffic_distortion(struct route *this_, struct item *item);
+void route_remove_traffic_distortion(struct route *this_, struct item *item);
+void route_change_traffic_distortion(struct route *this_, struct item *item);
+struct route_graph_point * route_graph_add_point(struct route_graph *this, struct coord *f);
+void route_graph_add_turn_restriction(struct route_graph *this, struct item *item);
+void route_graph_free_points(struct route_graph *this);
+struct route_graph_point *route_graph_get_point(struct route_graph *this, struct coord *c);
+struct route_graph_point *route_graph_get_point_next(struct route_graph *this, struct coord *c,
+ struct route_graph_point *last);
+void route_graph_add_segment(struct route_graph *this, struct route_graph_point *start,
+ struct route_graph_point *end, struct route_graph_segment_data *data);
+int route_graph_segment_is_duplicate(struct route_graph_point *start, struct route_graph_segment_data *data);
+void route_graph_free_segments(struct route_graph *this);
+void route_graph_build_done(struct route_graph *rg, int cancel);
+void route_recalculate_partial(struct route *this_);
+void * route_segment_data_field_pos(struct route_segment_data *seg, enum attr_type type);
+/* end of prototypes */
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/navit/script.c b/navit/script.c
index 2c6719cdc..dfc071caa 100644
--- a/navit/script.c
+++ b/navit/script.c
@@ -25,89 +25,80 @@
#include "command.h"
#include "xmlconfig.h"
-struct script
-{
- NAVIT_OBJECT
- struct attr parent;
- struct callback *cb;
- struct event_timeout *timeout;
- struct command_saved *cs;
+struct script {
+ NAVIT_OBJECT
+ struct attr parent;
+ struct callback *cb;
+ struct event_timeout *timeout;
+ struct command_saved *cs;
};
-static void
-script_run(struct script *scr)
-{
- struct attr *xml_text=attr_search(scr->attrs, NULL, attr_xml_text);
- int error;
- if (!xml_text || !xml_text->u.str) {
- dbg(lvl_error,"no text\n");
- return;
- }
- dbg(lvl_debug,"running '%s'\n",xml_text->u.str);
- command_evaluate_to_void(&scr->parent, xml_text->u.str, &error);
+static void script_run(struct script *scr) {
+ struct attr *xml_text=attr_search(scr->attrs, NULL, attr_xml_text);
+ int error;
+ if (!xml_text || !xml_text->u.str) {
+ dbg(lvl_error,"no text");
+ return;
+ }
+ dbg(lvl_debug,"running '%s'",xml_text->u.str);
+ command_evaluate_to_void(&scr->parent, xml_text->u.str, &error);
}
-static int
-script_set_attr_int(struct script *scr, struct attr *attr)
-{
- switch (attr->type) {
- case attr_refresh_cond:
- dbg(lvl_debug,"refresh_cond\n");
- if (scr->cs)
- command_saved_destroy(scr->cs);
- scr->cs=command_saved_attr_new(attr->u.str, &scr->parent, scr->cb, 0);
- return 1;
- case attr_update_period:
- if (scr->timeout)
- event_remove_timeout(scr->timeout);
- scr->timeout=event_add_timeout(attr->u.num, 1, scr->cb);
- return 1;
- default:
- return 0;
- }
+static int script_set_attr_int(struct script *scr, struct attr *attr) {
+ switch (attr->type) {
+ case attr_refresh_cond:
+ dbg(lvl_debug,"refresh_cond");
+ if (scr->cs)
+ command_saved_destroy(scr->cs);
+ scr->cs=command_saved_attr_new(attr->u.str, &scr->parent, scr->cb, 0);
+ return 1;
+ case attr_update_period:
+ if (scr->timeout)
+ event_remove_timeout(scr->timeout);
+ scr->timeout=event_add_timeout(attr->u.num, 1, scr->cb);
+ return 1;
+ default:
+ return 0;
+ }
}
-static struct script *
-script_new(struct attr *parent, struct attr **attrs)
-{
- struct script *scr=g_new0(struct script, 1);
- scr->func=&script_func;
- navit_object_ref((struct navit_object *)scr);
- scr->attrs=attr_list_dup(attrs);
- attrs=scr->attrs;
- scr->cb=callback_new_1(callback_cast(script_run), scr);
- scr->parent=*parent;
- while (attrs && *attrs)
- script_set_attr_int(scr, *attrs++);
- dbg(lvl_debug,"return %p\n",scr);
- return scr;
+static struct script *script_new(struct attr *parent, struct attr **attrs) {
+ struct script *scr=g_new0(struct script, 1);
+ scr->func=&script_func;
+ navit_object_ref((struct navit_object *)scr);
+ scr->attrs=attr_list_dup(attrs);
+ attrs=scr->attrs;
+ scr->cb=callback_new_1(callback_cast(script_run), scr);
+ scr->parent=*parent;
+ while (attrs && *attrs)
+ script_set_attr_int(scr, *attrs++);
+ dbg(lvl_debug,"return %p",scr);
+ return scr;
}
-static void
-script_destroy(struct script *scr)
-{
- dbg(lvl_debug,"enter %p\n",scr);
- if (scr->timeout)
- event_remove_timeout(scr->timeout);
- if (scr->cs)
- command_saved_destroy(scr->cs);
- callback_destroy(scr->cb);
- attr_list_free(scr->attrs);
- g_free(scr);
+static void script_destroy(struct script *scr) {
+ dbg(lvl_debug,"enter %p",scr);
+ if (scr->timeout)
+ event_remove_timeout(scr->timeout);
+ if (scr->cs)
+ command_saved_destroy(scr->cs);
+ callback_destroy(scr->cb);
+ attr_list_free(scr->attrs);
+ g_free(scr);
}
struct object_func script_func = {
- attr_script,
- (object_func_new)script_new,
- (object_func_get_attr)navit_object_get_attr,
- (object_func_iter_new)navit_object_attr_iter_new,
- (object_func_iter_destroy)navit_object_attr_iter_destroy,
- (object_func_set_attr)navit_object_set_attr,
- (object_func_add_attr)navit_object_add_attr,
- (object_func_remove_attr)navit_object_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)script_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_script,
+ (object_func_new)script_new,
+ (object_func_get_attr)navit_object_get_attr,
+ (object_func_iter_new)navit_object_attr_iter_new,
+ (object_func_iter_destroy)navit_object_attr_iter_destroy,
+ (object_func_set_attr)navit_object_set_attr,
+ (object_func_add_attr)navit_object_add_attr,
+ (object_func_remove_attr)navit_object_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)script_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/script/cabify.sh b/navit/script/cabify.sh
index 4536ff330..ea6dba4b4 100755
--- a/navit/script/cabify.sh
+++ b/navit/script/cabify.sh
@@ -27,8 +27,8 @@ else
fi
[ "$2" != "" ] && SRCDIR="$2"
[ "$3" != "" ] && BASEDIR="$3"
-if [ "$4" != "" ];
-then
+if [ "$4" != "" ];
+then
NAVITXML="$4"
else
NAVITXML=""
@@ -42,16 +42,16 @@ echo "PocketPc dir: $BASEDIR"
echo -n > $CABLIST.$$
-for i in `ls $SRCDIR/locale/*/*/*.mo`
+for i in $SRCDIR/locale/*/*/*.mo
do
- bn="`basename "$i"`"
+ bn=$(basename "$i")
d=${i##$SRCDIR/}
echo "$i $BASEDIR/$d" >> $CABLIST.$$
done
for i in $SRCDIR/navit/icons/*.xpm
do
- bn="`basename "$i"`"
+ bn=$(basename "$i")
echo "$i $BASEDIR/icons/" >> $CABLIST.$$
done
@@ -64,17 +64,17 @@ if [ "$MAPSDIR" != "" ]
then
for i in $MAPSDIR/*.bin
do
- bn="`basename "$i"`"
+ bn=$(basename "$i")
echo "$i $BASEDIR/maps/$bn" >> $CABLIST.$$
done
for i in $MAPSDIR/*.txt
do
- bn="`basename "$i"`"
+ bn=$(basename "$i")
echo "$i $BASEDIR/maps/$bn" >> $CABLIST.$$
done
for i in $MAPSDIR/*.img
do
- bn="`basename "$i"`"
+ bn=$(basename "$i")
echo "$i $BASEDIR/maps/$bn" >> $CABLIST.$$
done
fi
diff --git a/navit/script/check_itemdef b/navit/script/check_itemdef
deleted file mode 100755
index 61ea1cb29..000000000
--- a/navit/script/check_itemdef
+++ /dev/null
@@ -1,42 +0,0 @@
-#! /bin/sh
-function check_item_def
-{
- grep -q "[(,]$1)" ../item_def.h || echo "$1 missing"
-}
-
-function check_item_xml
-{
- grep -q "^$1\$" check.$$ || echo "$1 will not be rendered"
-}
-
-
-awk '/<layout name="Car"/,/<\/layout/ { if (/<itemgra/) {print $0} }' < ../navit.xml | sed 's/.*item_types="\([^"]*\)".*/\1/' | tr "," "\012" | sort -u >check.$$
-echo item_def.h
-grep "^ITEM" ../item_def.h | sed -e "s/ITEM(\(.*\))/\1/" -e "s/ITEM2([^,]*,\(.*\))/\1/" |
-while read -r x
-do
- check_item_xml "$x"
-done
-
-rm -f check.$$
-echo maptool.c
-egrep '^ "[nw] +[^ ]+ +[^ ]+' ../maptool.c | sed "s/.* //" | sort -u |
-while read -r x
-do
- check_item_def "${x%%\\n\"}"
-done
-
-echo "navit.xml"
-grep '<itemgra item_types="' <../navit.xml | cut -d \" -f 2 | tr "," "\012" |
-while read -r x
-do
- check_item_def "$x"
-done
-
-echo "garmintypes.txt"
-grep "^[0-9]" ../map/garmin/garmintypes.txt | sed -e 's/[A-Z][A-Z]*, //' -e 's/.*= \([^,]*\),.*/\1/' | sort -u |
-while read -r x
-do
- check_item_def "$x"
-done
-
diff --git a/navit/script/download_index.html b/navit/script/download_index.html
index fed33e179..ca5a7d48f 100644
--- a/navit/script/download_index.html
+++ b/navit/script/download_index.html
@@ -1,145 +1,145 @@
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Planet Extraction</title>
- <style type="text/css">
- html, body {
- margin: 0;
- padding: 1em;
- font: 0.9em Verdana, Arial, sans serif;
- }
- input, select, textarea {
- font: 1em Verdana, Arial, sans serif;
- }
- .input {
- border: none;
- width: 100px;
- }
- .bbox {
- font-size: 12px;
- color: #000;
- background-color: #fff;
- width: 300px;
- border: 1px solid gray;
- }
- .button {
- width: 200px;
- height: 50px;
- font-weight: bold;
- }
- #map {
- float: left;
- width: 500px;
- height: 500px;
- border: 1px solid gray;
- }
- #controls {
- float: left;
-
- }
- </style>
- <script src="http://openlayers.org/dev/lib/OpenLayers.js"></script>
- <script type="text/javascript">
- var map, polygonControl, polygonLayer, bbox_set;
-
- OpenLayers.Util.onImageLoadErrorColor = "transparent";
- function init(){
- map = new OpenLayers.Map('map');
-
- var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
- "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
-
- polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
-
- map.addLayers([wmsLayer, polygonLayer]);
- map.addControl(new OpenLayers.Control.LayerSwitcher());
- map.addControl(new OpenLayers.Control.MousePosition());
-
- polyOptions = {sides: 4, irregular: true};
- polygonControl = new OpenLayers.Control.DrawFeature(polygonLayer,
- OpenLayers.Handler.RegularPolygon,
- {handlerOptions: polyOptions});
- //alert(polygonControl);
-
- map.addControl(polygonControl);
-
- polygonControl.featureAdded=featureInsert;
-
- map.setCenter(new OpenLayers.LonLat(0, 0), 3);
-
- document.getElementById('noneToggle').checked = true;
- //document.getElementById('irregularToggle').checked = false;
-
- //var polyOptions = {sides: 4, irregular: true};
- //polygonControl.handler.setOptions(polyOptions);
- }
-
- function featureInsert(feature){
- var old=[];
- for (var i = 0; i < polygonLayer.features.length; i++) {
- if (polygonLayer.features[i] != feature) {
- old.push(polygonLayer.features[i]);
- }
- }
- polygonLayer.destroyFeatures(old);
-
- var bounds = feature.geometry.getBounds();
-
- document.form.bounds_top.value = bounds.top;
- document.form.bounds_right.value = bounds.right;
- document.form.bounds_btm.value = bounds.bottom;
- document.form.bounds_left.value = bounds.left;
- bbox_set=true;
- }
- function download() {
- var bbox = document.form.bounds_left.value + "," +
- document.form.bounds_btm.value + "," +
- document.form.bounds_right.value + "," +
- document.form.bounds_top.value;
- if (bbox_set) {
- location.href="http://maps.navit-project.org/api/map?bbox=" + bbox;
- } else {
- alert("Please select a bounding box first\n");
- }
- }
- function setOptions(options) {
- polygonControl.handler.setOptions(options);
- }
- function setSize(fraction) {
- var radius = fraction * map.getExtent().getHeight();
- polygonControl.handler.setOptions({radius: radius,
- angle: 0});
- }
- </script>
- </head>
- <body onload="init()">
- <h2>Planet extract</h2>
- <div id="map"></div>
- <div id="controls">
- <ul style="list-style:none;"><b>Map Controls</b>
- <li>
- <input type="radio" name="type"
- value="none" id="noneToggle"
- onclick="polygonControl.deactivate()"
- checked="checked" />
- <label for="noneToggle">navigate</label>
- </li>
- <li>
- <input type="radio" name="type"
- value="polygon" id="polygonToggle"
- onclick="polygonControl.activate()" />
- <label for="polygonToggle">select</label>
- </li>
- </ul>
- <ul style="list-style:none"><b>Fetch box</b>
- <form name="form">
- <li>Top Right: <input type="text" name="bounds_top" class="input">,
- <input type="text" name="bounds_right" class="input"></li>
- <li>Bottom left: <input type="text" name="bounds_btm" class="input">,
- <input type="text" name="bounds_left" class="input"></li>
- </form>
- <li>&nbsp;</li>
- <li><input type="button" class="button" value="Get map!" onclick="javascript:download()"></li>
- </ul>
- </div>
- </body>
-</html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Planet Extraction</title>
+ <style type="text/css">
+ html, body {
+ margin: 0;
+ padding: 1em;
+ font: 0.9em Verdana, Arial, sans serif;
+ }
+ input, select, textarea {
+ font: 1em Verdana, Arial, sans serif;
+ }
+ .input {
+ border: none;
+ width: 100px;
+ }
+ .bbox {
+ font-size: 12px;
+ color: #000;
+ background-color: #fff;
+ width: 300px;
+ border: 1px solid gray;
+ }
+ .button {
+ width: 200px;
+ height: 50px;
+ font-weight: bold;
+ }
+ #map {
+ float: left;
+ width: 500px;
+ height: 500px;
+ border: 1px solid gray;
+ }
+ #controls {
+ float: left;
+
+ }
+ </style>
+ <script src="http://openlayers.org/dev/lib/OpenLayers.js"></script>
+ <script type="text/javascript">
+ var map, polygonControl, polygonLayer, bbox_set;
+
+ OpenLayers.Util.onImageLoadErrorColor = "transparent";
+ function init(){
+ map = new OpenLayers.Map('map');
+
+ var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
+ "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
+
+ polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
+
+ map.addLayers([wmsLayer, polygonLayer]);
+ map.addControl(new OpenLayers.Control.LayerSwitcher());
+ map.addControl(new OpenLayers.Control.MousePosition());
+
+ polyOptions = {sides: 4, irregular: true};
+ polygonControl = new OpenLayers.Control.DrawFeature(polygonLayer,
+ OpenLayers.Handler.RegularPolygon,
+ {handlerOptions: polyOptions});
+ //alert(polygonControl);
+
+ map.addControl(polygonControl);
+
+ polygonControl.featureAdded=featureInsert;
+
+ map.setCenter(new OpenLayers.LonLat(0, 0), 3);
+
+ document.getElementById('noneToggle').checked = true;
+ //document.getElementById('irregularToggle').checked = false;
+
+ //var polyOptions = {sides: 4, irregular: true};
+ //polygonControl.handler.setOptions(polyOptions);
+ }
+
+ function featureInsert(feature){
+ var old=[];
+ for (var i = 0; i < polygonLayer.features.length; i++) {
+ if (polygonLayer.features[i] != feature) {
+ old.push(polygonLayer.features[i]);
+ }
+ }
+ polygonLayer.destroyFeatures(old);
+
+ var bounds = feature.geometry.getBounds();
+
+ document.form.bounds_top.value = bounds.top;
+ document.form.bounds_right.value = bounds.right;
+ document.form.bounds_btm.value = bounds.bottom;
+ document.form.bounds_left.value = bounds.left;
+ bbox_set=true;
+ }
+ function download() {
+ var bbox = document.form.bounds_left.value + "," +
+ document.form.bounds_btm.value + "," +
+ document.form.bounds_right.value + "," +
+ document.form.bounds_top.value;
+ if (bbox_set) {
+ location.href="http://maps.navit-project.org/api/map?bbox=" + bbox;
+ } else {
+ alert("Please select a bounding box first\n");
+ }
+ }
+ function setOptions(options) {
+ polygonControl.handler.setOptions(options);
+ }
+ function setSize(fraction) {
+ var radius = fraction * map.getExtent().getHeight();
+ polygonControl.handler.setOptions({radius: radius,
+ angle: 0});
+ }
+ </script>
+ </head>
+ <body onload="init()">
+ <h2>Planet extract</h2>
+ <div id="map"></div>
+ <div id="controls">
+ <ul style="list-style:none;"><b>Map Controls</b>
+ <li>
+ <input type="radio" name="type"
+ value="none" id="noneToggle"
+ onclick="polygonControl.deactivate()"
+ checked="checked" />
+ <label for="noneToggle">navigate</label>
+ </li>
+ <li>
+ <input type="radio" name="type"
+ value="polygon" id="polygonToggle"
+ onclick="polygonControl.activate()" />
+ <label for="polygonToggle">select</label>
+ </li>
+ </ul>
+ <ul style="list-style:none"><b>Fetch box</b>
+ <form name="form">
+ <li>Top Right: <input type="text" name="bounds_top" class="input">,
+ <input type="text" name="bounds_right" class="input"></li>
+ <li>Bottom left: <input type="text" name="bounds_btm" class="input">,
+ <input type="text" name="bounds_left" class="input"></li>
+ </form>
+ <li>&nbsp;</li>
+ <li><input type="button" class="button" value="Get map!" onclick="javascript:download()"></li>
+ </ul>
+ </div>
+ </body>
+</html>
diff --git a/navit/script/gensvg b/navit/script/gensvg
index b7a4241c9..6225051d8 100755
--- a/navit/script/gensvg
+++ b/navit/script/gensvg
@@ -2,7 +2,7 @@
makearrow()
{
-cat <<EOT
+cat <<EOT
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:svg="http://www.w3.org/2000/svg"
@@ -233,14 +233,14 @@ do
xl2=14
yl2=32
long1=$longa
- ;;
+ ;;
315)
xa0=23.54
ya0=23.54
xl2=19.3
yl2=19.3
long1=$longa
- ;;
+ ;;
esac
long2=$((1-long1))
filename="nav_roundabout_${letter}${st}_$col.svg"
@@ -249,7 +249,7 @@ do
done
filename="nav_straight_$col.svg"
xl0=32
- xl1=32
+ xl1=32
yl1=32
xcc0=32
ycc0=10
diff --git a/navit/script/geotag b/navit/script/geotag
index e025cbc61..608f6c269 100755
--- a/navit/script/geotag
+++ b/navit/script/geotag
@@ -9,10 +9,10 @@ case $order in
;;
12|13)
size=4000
- ;;
+ ;;
14|15)
size=16000
- ;;
+ ;;
16|17|18|19)
size=64000
;;
diff --git a/navit/script/gps_emu b/navit/script/gps_emu
index f2eef3e50..73ddbc54f 100755
--- a/navit/script/gps_emu
+++ b/navit/script/gps_emu
@@ -1,15 +1,15 @@
#! /bin/bash
function send_data
{
- trap send_data SIGPIPE
+ trap send_data SIGPIPE
while read line
do
case $line in
\$GPVTG*)
echo "$line"
- sleep 1
+ sleep 1
;;
- *)
+ *)
echo "$line"
;;
esac
diff --git a/navit/script/gps_emu2 b/navit/script/gps_emu2
index e9e79b42a..b4a66e526 100755
--- a/navit/script/gps_emu2
+++ b/navit/script/gps_emu2
@@ -21,8 +21,8 @@ while (read(FILE,$record,64))
if ($mode == 3) {
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($timestampl);
- $datestring=sprintf("%02d.%02d.%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec);
+ ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($timestampl);
+ $datestring=sprintf("%02d.%02d.%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec);
$long_dir="E";
$lat_dir="N";
if ($longitude < 0) {
@@ -42,5 +42,5 @@ while (read(FILE,$record,64))
printf("\$GPVTG,%s,T,,M,,N,%s,K,*6A\n",$direction,$speed*1.852);
printf(STDERR "\$GPGGA,%02d%02d%02d,%s,%s,%s,%s,1,%d,%s,%s,M,,,,0000*0C\n",$hour,$min,$sec,$lat_gps,$lat_dir,$long_gps,$long_dir,$sats,$hdop,$altitude);
sleep(1);
- }
+ }
}
diff --git a/navit/script/itemgra.pl b/navit/script/itemgra.pl
index bbe02b000..54a08225c 100755
--- a/navit/script/itemgra.pl
+++ b/navit/script/itemgra.pl
@@ -1,25 +1,69 @@
#! /usr/bin/perl
+
+# This script parses the XML config file and checks if known itemgra elements are defined or not in each layout
+# Run ./itemgra.pl 2>/dev/null to get only the result without parsing information messages
my $layout;
my $type,$types;
+my $garmintypes;
my $order,$orders,@orders;
my @layouts;
-open(IN,"../navit.xml");
-while (<IN>) {
- if (/<layout name="([^"]*)"/) {
- $layout=$1;
- push(@layouts,$layout);
- }
- if (/<itemgra item_types="([^"]*)"/) {
- $types=$1;
- if (/order="([^"]*)"/) {
- $order=$1;
- foreach $type (split(",",$types)) {
- $result->{$type}->{$layout}->{$order}=1;
+my $input_stream;
+my @input_stream_stack;
+my $current_filename = "../navit_shipped.xml";
+if (!open($input_stream,$current_filename)) {
+ print(STDERR "Failed to open \"" . $current_filename . "\"\n");
+ exit(1);
+}
+while(defined($input_stream)) {
+ #printf("%d input streams in file recursion stack. Current input stream is " . $input_stream . "\n", $#input_stream_stack+1);
+ while (<$input_stream>) {
+ #print($_);
+ if (/<layout name="([^"]*)"/) {
+ $layout=$1;
+ push(@layouts,$layout);
+ }
+ if (/<xi:include href="([^"]*)"/) {
+ my $xml_include_file;
+ $xml_include_file=$1;
+ if ($xml_include_file =~ /^[\/\$]/) { # PATH is absolute or starts with a variable... do not modify PATH
+ }
+ $xml_include_file =~ s@^@../@; # Make PATH relative to ../ (navit XML config is in parent
+ if ($xml_include_file =~ /.*maps\/\*\.xml$/) { # Skip mapsets that use wildcards
+ }
+ else {
+ push(@input_stream_stack, $input_stream);
+ $input_stream = undef;
+ print(STDERR "Opening included file \"" . $xml_include_file . "\"\n");
+ if (!open($input_stream, $xml_include_file)) {
+ $xml_include_file =~ s/\.xml$/_shipped.xml/; # If file does not exist, try suffixing the filename with _shipped
+ print(SDTERR "Opening included file \"" . $xml_include_file . "\"\n");
+ if (!open($input_stream, $xml_include_file)) {
+ print(STDERR "Failed to open \"" . $xml_include_file . "\"\n");
+ exit(1);
+ }
+ }
+ $current_filename = $xml_include_file;
+ #printf("%d input streams in file recursion stack. Current input stream is " . $input_stream . "\n", $#input_stream_stack+1);
+ next;
+ }
+ }
+ if (/<itemgra item_types="([^"]*)"/) {
+ $types=$1;
+ if (/order="([^"]*)"/) {
+ $order=$1;
+ print(STDERR "Order $order found in \"" . $current_filename . "\"\n");
+ foreach $type (split(",",$types)) {
+ $result->{$type}->{$layout}->{$order}=1;
+ }
}
}
}
+ close($input_stream);
+ $input_stream = pop(@input_stream_stack);
+ #print("Popped input stream " . $input_stream . "\n");
}
-close(IN);
+print(STDERR "Finished parsing navit XML config\n");
+print(STDERR "Parsing item_def.h\n");
open(IN,"../item_def.h");
while (<IN>) {
if (/^ITEM2\([^,]*,(.*)\)/) {
@@ -32,13 +76,26 @@ while (<IN>) {
}
}
close(IN);
+print(STDERR "Parsing ../map/garmin/garmintypes.txt\n");
+open(IN,"../map/garmin/garmintypes.txt");
+while (<IN>) {
+ if (/^[0-9][^=]*=\s*([^,]*),.*$/) {
+ $type=$1;
+ print("Garmintype: " . $type . "\n");
+ $garmintypes->{$type}->{"none"}=1;
+ }
+}
+close(IN);
+
+print(STDERR "Outputting results\n");
my $typefmt="%-30s";
my $layoutfmt="%10s";
printf($typefmt,"");
foreach $layout (@layouts) {
printf($layoutfmt,$layout);
}
-printf("\n");
+print("\n");
+# Check which map items defined in ../item_def.h are actually handled by each layout
foreach $type (sort keys %$result) {
$marker="";
if (!$result->{$type}->{"none"}) {
@@ -55,3 +112,10 @@ foreach $type (sort keys %$result) {
}
printf("\n");
}
+
+print("Analysis on ../map/garmin/garmintypes.txt:\n");
+foreach $type (sort keys %$garmintypes) {
+ if (!$result->{$type}->{"none"}) {
+ print($type . " exists in garmintypes.txt and missing in itemdef.h\n");
+ }
+} \ No newline at end of file
diff --git a/navit/script/mapExtract.class.php b/navit/script/mapExtract.class.php
index f5c4bbbc3..da6a5a5d4 100644
--- a/navit/script/mapExtract.class.php
+++ b/navit/script/mapExtract.class.php
@@ -1,76 +1,76 @@
<?php
class mapExtract {
-
+
var $input_fd;
var $output_fd;
var $fetchBbox;
-
+
var $formats;
var $worldBbox;
-
+
function mapExtract() {
$formats = array();
-
+
$formats['ziphpack'] = "lssssslLLSS";
- $formats['zipheader'] = "l" . "ziplocsig"; # Signature (is always the same)
- $formats['zipheader'] .= "/s" . "zipver"; # zip version needed
- $formats['zipheader'] .= "/s" . "zipgenfld";# type of os that generated the file
- $formats['zipheader'] .= "/s" . "zipmthd"; #
- $formats['zipheader'] .= "/s" . "ziptime"; # time
- $formats['zipheader'] .= "/s" . "zipdate"; # date
- $formats['zipheader'] .= "/l" . "zipcrc"; # crc checksum
- $formats['zipheader'] .= "/L" . "zipsize"; # data size
- $formats['zipheader'] .= "/L" . "zipuncmp"; # uncompressed size
- $formats['zipheader'] .= "/S" . "zipfnln"; # length of filename
- $formats['zipheader'] .= "/S" . "zipxtraln";# length of extra data (always 0)
-
+ $formats['zipheader'] = "lziplocsig"; # Signature (is always the same)
+ $formats['zipheader'] .= "/szipver"; # zip version needed
+ $formats['zipheader'] .= "/szipgenfld";# type of os that generated the file
+ $formats['zipheader'] .= "/szipmthd"; #
+ $formats['zipheader'] .= "/sziptime"; # time
+ $formats['zipheader'] .= "/szipdate"; # date
+ $formats['zipheader'] .= "/lzipcrc"; # crc checksum
+ $formats['zipheader'] .= "/Lzipsize"; # data size
+ $formats['zipheader'] .= "/Lzipuncmp"; # uncompressed size
+ $formats['zipheader'] .= "/Szipfnln"; # length of filename
+ $formats['zipheader'] .= "/Szipxtraln";# length of extra data (always 0)
+
$formats['zipcdpack'] = "iccccssssiIISSSSSII";
$formats['zipcd'] = "".
- "i" . "zipcensig/".
- "c" . "zipcver/".
- "c" . "zipcos/".
- "c" . "zipcvxt/".
- "c" . "zipcexos/".
- "s" . "zipcflg/".
- "s" . "zipcmthd/".
- "s" . "ziptim/".
- "s" . "zipdat/".
- "i" . "zipccrc/".
- "I" . "zipcsiz/".
- "I" . "zipcunc/".
- "S" . "zipcfnl/".
- "S" . "zipcxtl/".
- "S" . "zipccml/".
- "S" . "zipdsk/".
- "S" . "zipint/".
- "I" . "zipext/".
- "I" . "zipofst";
-
+ "izipcensig/".
+ "czipcver/".
+ "czipcos/".
+ "czipcvxt/".
+ "czipcexos/".
+ "szipcflg/".
+ "szipcmthd/".
+ "sziptim/".
+ "szipdat/".
+ "izipccrc/".
+ "Izipcsiz/".
+ "Izipcunc/".
+ "Szipcfnl/".
+ "Szipcxtl/".
+ "Szipccml/".
+ "Szipdsk/".
+ "Szipint/".
+ "Izipext/".
+ "Izipofst";
+
$formats['zipeocpack'] = "iSSSSIIs";
$formats['zipeoc'] = "".
- "i" . "zipesig/".
- "S" . "zipedsk/".
- "S" . "zipecen/".
- "S" . "zipenum/".
- "S" . "zipecenn/".
- "I" . "zipecsz/".
- "I" . "zipeofst/".
- "s" . "zipecoml/".
-
+ "izipesig/".
+ "Szipedsk/".
+ "Szipecen/".
+ "Szipenum/".
+ "Szipecenn/".
+ "Izipecsz/".
+ "Izipeofst/".
+ "szipecoml/";
+
$world_bbox = array();
$world_bbox['l']['x'] = -20000000;
$world_bbox['l']['y'] = -20000000;
$world_bbox['h']['x'] = 20000000;
$world_bbox['h']['y'] = 20000000;
-
+
$this->formats = $formats;
$this->worldBbox = $world_bbox;
}
-
-
+
+
function process() {
-
+
if (!is_array($this->fetchBbox)) {
return "Fetch box not set";
}
@@ -85,10 +85,10 @@ class mapExtract {
$offset = 0;
$zipcd_data = '';
$report = array();
-
+
/**
* Read through zipheaders
- *
+ *
*/
for(;;) {
$buffer = fread($this->input_fd, 30);
@@ -98,20 +98,20 @@ class mapExtract {
if ($tileinfo['ziplocsig'] != 0x4034b50)
break;
-
+
if ($tileinfo['zipfnln'] <= 0)
break;
-
+
$filename = fread($this->input_fd, $tileinfo['zipfnln']);
$done=false;
-
+
$r = $this->worldBbox;
-
- $len=strlen($filename);
+
+ $len=strlen($filename);
for ($i=0 ; $i < $len ; $i++) {
$c['x'] = floor( ($r['l']['x'] + $r['h']['x'])/2 );
$c['y'] = floor( ($r['l']['y'] + $r['h']['y'])/2 );
-
+
switch($filename[$i]) {
case 'a':
$r['l']['x'] = $c['x'];
@@ -135,27 +135,27 @@ class mapExtract {
if ($done)
break;
}
- # print "zipsize=" . $tileinfo['zipsize'];
+ # print "zipsize=" . $tileinfo['zipsize'];
$tilecontent = fread($this->input_fd, $tileinfo['zipsize']);
-
- # print "tile $filename";
+
+ # print "tile $filename";
/* Area inside box, save it! */
if ($this->contains_bbox($r)) {
$report['added_areas']++;
-
+
$zipheader = $buffer;
# print " in\n";
-
+
/* Area outside of box, set zipcontent=0 */
} else {
# print " out\n";
$report['excluded_areas']++;
-
+
$tileinfo['zipmthd'] = $tileinfo['zipcrc'] = $tileinfo
['zipsize'] = $tileinfo['zipuncmp'] = 0;
$zipheader = $tileinfo;
$tilecontent = '';
- $zipheader = pack($this->formats['ziphpack'],
+ $zipheader = pack($this->formats['ziphpack'],
$tileinfo['ziplocsig'],
$tileinfo['zipver'],
$tileinfo['zipgenfld'],
@@ -169,9 +169,9 @@ class mapExtract {
$tileinfo['zipxtraln']
);
}
-
+
$put = $zipheader.$filename.$tilecontent;
-
+
/* Zip directory */
$zipcd_data .= pack($this->formats['zipcdpack'],
0x02014b50,
@@ -194,17 +194,17 @@ class mapExtract {
0x00,
$offset
) . $filename;
-
+
fwrite($this->output_fd, $put);
$offset += strlen($put);
$filecount += 1;
}
-
+
fwrite($this->output_fd, $zipcd_data);
$ecsz = strlen($zipcd_data);
-
+
/* Zip central directory */
- $zip_eoc = pack($this->formats['zipeocpack'],
+ $zip_eoc = pack($this->formats['zipeocpack'],
0x06054b50, #zipesig;
0, #zipedsk;
0, #zipecen;
@@ -215,11 +215,11 @@ class mapExtract {
0 #zipecoml;
);
fwrite($this->output_fd, $zip_eoc);
-
-
+
+
return null;
}
-
+
function setBbox($sx,$sy,$ex,$ey) {
if ($ex<$sx)
return false;
@@ -235,7 +235,7 @@ class mapExtract {
function setInputFD($fd) {
$this->input_fd=$fd;
}
-
+
function setOutput($file) {
$this->output_fd=fopen($file,'w');
}
@@ -243,8 +243,8 @@ class mapExtract {
function setOutputFD($fd) {
$this->output_fd=$fd;
}
-
-
+
+
function contains_bbox(&$r) {
$c =& $this->fetchBbox;
if ($c['l']['x'] > $r['h']['x'])
@@ -255,14 +255,14 @@ class mapExtract {
return false;
elseif ($c['h']['y'] < $r['l']['y'])
return false;
- else
+ else
return true;
}
-
+
function getmercator($sx,$sy,$ex,$ey) {
$sx = $sx*6371000.0*M_PI/180;
$sy = log(tan(M_PI_4+$sy*M_PI/360))*6371000.0;
-
+
$ex = $ex*6371000.0*M_PI/180;
$ey = log(tan(M_PI_4+$ey*M_PI/360))*6371000.0;
return array(
@@ -276,7 +276,7 @@ class mapExtract {
)
);
}
-
+
}
diff --git a/navit/script/map_index.php b/navit/script/map_index.php
index 57fd0d054..050d5fc76 100644
--- a/navit/script/map_index.php
+++ b/navit/script/map_index.php
@@ -4,7 +4,7 @@
$bbox=split(',',urldecode($HTTP_GET_VARS['bbox']));
if (count($bbox) == 4) {
$mapextract = new mapExtract();
- $mapextract->setBbox($bbox[0], $bbox[1], $bbox[2], $bbox[3]);
+ $mapextract->setBbox($bbox[0], $bbox[1], $bbox[2], $bbox[3]);
$fp=fopen('php://output','w');
$mapextract->setInput('../../planet.bin');
$mapextract->setOutputFD($fp);
@@ -13,7 +13,7 @@
else
header('Content-Type: application/octet-stream');
$name='osm_bbox_';
- $name.=round($bbox[0],1) . ',' . round($bbox[1],1) . ',';
+ $name.=round($bbox[0],1) . ',' . round($bbox[1],1) . ',';
$name.=round($bbox[2],1) . ',' . round($bbox[3],1);
$name.='.bin';
header("Content-disposition: attachment; filename=\"$name\"");
@@ -37,6 +37,6 @@
$urlf=$url . "?bbox=$bbox";
echo "$area <a href='$urlf'>$urlf</a><br />\n";
}
-
+
}
?>
diff --git a/navit/script/mapextract.php b/navit/script/mapextract.php
index 004b63caf..84ca21b22 100644
--- a/navit/script/mapextract.php
+++ b/navit/script/mapextract.php
@@ -1,225 +1,225 @@
-#!/usr/local/bin/php &#8211;q
-<?php
-function getmercator($sx,$sy,$ex,$ey) {
-
- $sx = $sx*6371000.0*M_PI/180;
- $sy = log(tan(M_PI_4+$sy*M_PI/360))*6371000.0;
-
- $ex = $ex*6371000.0*M_PI/180;
- $ey = log(tan(M_PI_4+$ey*M_PI/360))*6371000.0;
-
- return array(
- 'l' => array(
- 'x' => $sx,
- 'y' => $sy
- ),
- 'h' => array(
- 'x' => $ex,
- 'y' => $ey
- )
- );
-
-}
-function contains_bbox($c, &$r) {
- if ($c['l']['x'] > $r['h']['x'])
- return false;
- elseif ($c['h']['x'] < $r['l']['x'])
- return false;
- elseif ($c['l']['y'] > $r['h']['y'])
- return false;
- elseif ($c['h']['y'] < $r['l']['y'])
- return false;
- else
- return true;
-}
-
-$fetch_bbox = getmercator(11.3, 47.9, 11.4, 48.0);
-
-$files = array();
-$files['input'] = '/home/burner/carputer/navit/src/maps/osm_bbox_11.3,47.9,11.7,48.2.bin';
-$files['output'] = 'myarea.bin';
-
-$formats = array();
-$formats['ziphpack'] = "lssssslLLSS";
-$formats['zipheader'] = "l" . "ziplocsig"; # Signature (is always the same)
-$formats['zipheader'] .= "/s" . "zipver"; # zip version needed
-$formats['zipheader'] .= "/s" . "zipgenfld";# type of os that generated the file
-$formats['zipheader'] .= "/s" . "zipmthd"; #
-$formats['zipheader'] .= "/s" . "ziptime"; # time
-$formats['zipheader'] .= "/s" . "zipdate"; # date
-$formats['zipheader'] .= "/l" . "zipcrc"; # crc checksum
-$formats['zipheader'] .= "/L" . "zipsize"; # data size
-$formats['zipheader'] .= "/L" . "zipuncmp"; # uncompressed size
-$formats['zipheader'] .= "/S" . "zipfnln"; # length of filename
-$formats['zipheader'] .= "/S" . "zipxtraln";# length of extra data (always 0)
-
-$formats['zipcd'] = "".
- "i" . "zipcensig/".
- "c" . "zipcver/".
- "c" . "zipcos/".
- "c" . "zipcvxt/".
- "c" . "zipcexos/".
- "s" . "zipcflg/".
- "s" . "zipcmthd/".
- "s" . "ziptim/".
- "s" . "zipdat/".
- "i" . "zipccrc/".
- "I" . "zipcsiz/".
- "I" . "zipcunc/".
- "S" . "zipcfnl/".
- "S" . "zipcxtl/".
- "S" . "zipccml/".
- "S" . "zipdsk/".
- "S" . "zipint/".
- "I" . "zipext/".
- "I" . "zipofst/".
-$formats['zipcdpack'] = "iccccssssiIISSSSSII";
-
-$formats['zipcontent'] = "i5x/i5y/ii";
-
-$world_bbox = array();
-$world_bbox['l']['x'] = -20000000;
-$world_bbox['l']['y'] = -20000000;
-$world_bbox['h']['x'] = 20000000;
-$world_bbox['h']['y'] = 20000000;
-
-$fp = fopen($files['input'], 'r');
-$sp = fopen($files['output'], 'w');
-
-$files = array();
-$offset = 0;
-
-/**
- * Read through zipheaders
- *
- */
-while (!feof($fp)) {
-
- $buffer = fread($fp, 30);
- $tileinfo = unpack($formats['zipheader'], $buffer);
-
- if ($tileinfo['zipfnln'] <= 0)
- break;
-
- $filename = fread($fp, $tileinfo['zipfnln']);
- $x=0;
- $done=false;
-
- $r = $world_bbox;
-
- while (!$done) {
- $c['x'] = floor( ($r['l']['x'] + $r['h']['x'])/2 );
- $c['y'] = floor( ($r['l']['y'] + $r['h']['y'])/2 );
-
- switch($filename[$x]) {
- case 'a':
- $r['l']['x'] = $c['x'];
- $r['l']['y'] = $c['y'];
- break;
- case 'b':
- $r['h']['x'] = $c['x'];
- $r['l']['y'] = $c['y'];
- break;
- case 'c':
- $r['l']['x'] = $c['x'];
- $r['h']['y'] = $c['y'];
- break;
- case 'd':
- $r['h']['x'] = $c['x'];
- $r['h']['y'] = $c['y'];
- break;
- default:
- $done=true;
- }
- $x++;
- }
-
- $tilecontent = fread($fp, $tileinfo['zipsize']);
-
- /* Area inside box, save it! */
- if (contains_bbox($fetch_bbox, $r)) {
- #echo "In box. ";
- #echo $filename . " ";
- $zipheader = $buffer;
- #echo "\n";
-
- /* Area outside of box, set zipcontent=0 */
- } else {
- $tileinfo['zipmthd'] = $tileinfo['zipcrc'] = $tileinfo['zipsize'] = $tileinfo['zipuncmp'] = 0;
- #echo "Out of box";
- $zipheader = $tileinfo;
- $tilecontent = '';
- $zipheader = pack($formats['ziphpack'],
- $tileinfo['ziplocsig'],
- $tileinfo['zipver'],
- $tileinfo['zipgenfld'],
- $tileinfo['zipmthd'],
- $tileinfo['ziptime'],
- $tileinfo['zipdate'],
- $tileinfo['zipcrc'],
- $tileinfo['zipsize'],
- $tileinfo['zipuncmp'],
- $tileinfo['zipfnln'],
- $tileinfo['zipxtraln']
- );
- }
-
- $put = $zipheader.$filename.$tilecontent;
- $files[$filename]['header'] = $tileinfo;
- $files[$filename]['size'] = strlen($put);
-
- $zipcd = array();
- $zipcd['zipcensig'] = 0x02014b50;
- $zipcd['zipcver'] = $tileinfo['zipver'];
- $zipcd['zipcos'] = 0x00;
- $zipcd['zipcvxt'] = 0x0a;
- $zipcd['zipcexos'] = 0x00;
- $zipcd['zipcflg'] = 0x00;
- $zipcd['zipcmthd'] = $tileinfo['zipmthd'];
- $zipcd['ziptim'] = $tileinfo['ziptime'];
- $zipcd['zipdat'] = $tileinfo['zipdate'];
- $zipcd['zipccrc'] = $tileinfo['zipcrc'];
- $zipcd['zipcsiz'] = $tileinfo['zipsize'];
- $zipcd['zipcunc'] = $tileinfo['zipuncmp'];
- $zipcd['zipcfnl'] = $tileinfo['zipfnln'];
- $zipcd['zipcxtl'] = 0x00;
- $zipcd['zipccml'] = 0x00;
- $zipcd['zipdsk'] = 0x00;
- $zipcd['zipint'] = 0x00;
- $zipcd['zipext'] = 0x00;
- $zipcd['zipofst'] = $offset;
-
- $zipcd_data .= pack($formats['zipcdpack'],
- $zipcd['zipcensig'],
- $zipcd['zipcver'],
- $zipcd['zipcos'],
- $zipcd['zipcvxt'],
- $zipcd['zipcexos'],
- $zipcd['zipcflg'],
- $zipcd['zipcmthd'],
- $zipcd['ziptim'],
- $zipcd['zipdat'],
- $zipcd['zipccrc'],
- $zipcd['zipcsiz'],
- $zipcd['zipcunc'],
- $zipcd['zipcfnl'],
- $zipcd['zipcxtl'],
- $zipcd['zipccml'],
- $zipcd['zipdsk'],
- $zipcd['zipint'],
- $zipcd['zipext'],
- $zipcd['zipofst']
- ) . $filename;
-
-
- fwrite($sp, $put);
- $offset += strlen($put);
-
-}
-
-fwrite($sp, $zipcd_data);
-
-fclose($fp);
-fclose($sp);
-
-?>
+#!/usr/local/bin/php &#8211;q
+<?php
+function getmercator($sx,$sy,$ex,$ey) {
+
+ $sx = $sx*6371000.0*M_PI/180;
+ $sy = log(tan(M_PI_4+$sy*M_PI/360))*6371000.0;
+
+ $ex = $ex*6371000.0*M_PI/180;
+ $ey = log(tan(M_PI_4+$ey*M_PI/360))*6371000.0;
+
+ return array(
+ 'l' => array(
+ 'x' => $sx,
+ 'y' => $sy
+ ),
+ 'h' => array(
+ 'x' => $ex,
+ 'y' => $ey
+ )
+ );
+
+}
+function contains_bbox($c, &$r) {
+ if ($c['l']['x'] > $r['h']['x'])
+ return false;
+ elseif ($c['h']['x'] < $r['l']['x'])
+ return false;
+ elseif ($c['l']['y'] > $r['h']['y'])
+ return false;
+ elseif ($c['h']['y'] < $r['l']['y'])
+ return false;
+ else
+ return true;
+}
+
+$fetch_bbox = getmercator(11.3, 47.9, 11.4, 48.0);
+
+$files = array();
+$files['input'] = '/home/burner/carputer/navit/src/maps/osm_bbox_11.3,47.9,11.7,48.2.bin';
+$files['output'] = 'myarea.bin';
+
+$formats = array();
+$formats['ziphpack'] = "lssssslLLSS";
+$formats['zipheader'] = "lziplocsig"; # Signature (is always the same)
+$formats['zipheader'] .= "/szipver"; # zip version needed
+$formats['zipheader'] .= "/szipgenfld";# type of os that generated the file
+$formats['zipheader'] .= "/szipmthd"; #
+$formats['zipheader'] .= "/sziptime"; # time
+$formats['zipheader'] .= "/szipdate"; # date
+$formats['zipheader'] .= "/lzipcrc"; # crc checksum
+$formats['zipheader'] .= "/Lzipsize"; # data size
+$formats['zipheader'] .= "/Lzipuncmp"; # uncompressed size
+$formats['zipheader'] .= "/Szipfnln"; # length of filename
+$formats['zipheader'] .= "/Szipxtraln";# length of extra data (always 0)
+
+$formats['zipcd'] = "".
+ "izipcensig/".
+ "czipcver/".
+ "czipcos/".
+ "czipcvxt/".
+ "czipcexos/".
+ "szipcflg/".
+ "szipcmthd/".
+ "sziptim/".
+ "szipdat/".
+ "izipccrc/".
+ "Izipcsiz/".
+ "Izipcunc/".
+ "Szipcfnl/".
+ "Szipcxtl/".
+ "Szipccml/".
+ "Szipdsk/".
+ "Szipint/".
+ "Izipext/".
+ "Izipofst/";
+$formats['zipcdpack'] = "iccccssssiIISSSSSII";
+
+$formats['zipcontent'] = "i5x/i5y/ii";
+
+$world_bbox = array();
+$world_bbox['l']['x'] = -20000000;
+$world_bbox['l']['y'] = -20000000;
+$world_bbox['h']['x'] = 20000000;
+$world_bbox['h']['y'] = 20000000;
+
+$fp = fopen($files['input'], 'r');
+$sp = fopen($files['output'], 'w');
+
+$files = array();
+$offset = 0;
+
+/**
+ * Read through zipheaders
+ *
+ */
+while (!feof($fp)) {
+
+ $buffer = fread($fp, 30);
+ $tileinfo = unpack($formats['zipheader'], $buffer);
+
+ if ($tileinfo['zipfnln'] <= 0)
+ break;
+
+ $filename = fread($fp, $tileinfo['zipfnln']);
+ $x=0;
+ $done=false;
+
+ $r = $world_bbox;
+
+ while (!$done) {
+ $c['x'] = floor( ($r['l']['x'] + $r['h']['x'])/2 );
+ $c['y'] = floor( ($r['l']['y'] + $r['h']['y'])/2 );
+
+ switch($filename[$x]) {
+ case 'a':
+ $r['l']['x'] = $c['x'];
+ $r['l']['y'] = $c['y'];
+ break;
+ case 'b':
+ $r['h']['x'] = $c['x'];
+ $r['l']['y'] = $c['y'];
+ break;
+ case 'c':
+ $r['l']['x'] = $c['x'];
+ $r['h']['y'] = $c['y'];
+ break;
+ case 'd':
+ $r['h']['x'] = $c['x'];
+ $r['h']['y'] = $c['y'];
+ break;
+ default:
+ $done=true;
+ }
+ $x++;
+ }
+
+ $tilecontent = fread($fp, $tileinfo['zipsize']);
+
+ /* Area inside box, save it! */
+ if (contains_bbox($fetch_bbox, $r)) {
+ #echo "In box. ";
+ #echo $filename . " ";
+ $zipheader = $buffer;
+ #echo "\n";
+
+ /* Area outside of box, set zipcontent=0 */
+ } else {
+ $tileinfo['zipmthd'] = $tileinfo['zipcrc'] = $tileinfo['zipsize'] = $tileinfo['zipuncmp'] = 0;
+ #echo "Out of box";
+ $zipheader = $tileinfo;
+ $tilecontent = '';
+ $zipheader = pack($formats['ziphpack'],
+ $tileinfo['ziplocsig'],
+ $tileinfo['zipver'],
+ $tileinfo['zipgenfld'],
+ $tileinfo['zipmthd'],
+ $tileinfo['ziptime'],
+ $tileinfo['zipdate'],
+ $tileinfo['zipcrc'],
+ $tileinfo['zipsize'],
+ $tileinfo['zipuncmp'],
+ $tileinfo['zipfnln'],
+ $tileinfo['zipxtraln']
+ );
+ }
+
+ $put = $zipheader.$filename.$tilecontent;
+ $files[$filename]['header'] = $tileinfo;
+ $files[$filename]['size'] = strlen($put);
+
+ $zipcd = array();
+ $zipcd['zipcensig'] = 0x02014b50;
+ $zipcd['zipcver'] = $tileinfo['zipver'];
+ $zipcd['zipcos'] = 0x00;
+ $zipcd['zipcvxt'] = 0x0a;
+ $zipcd['zipcexos'] = 0x00;
+ $zipcd['zipcflg'] = 0x00;
+ $zipcd['zipcmthd'] = $tileinfo['zipmthd'];
+ $zipcd['ziptim'] = $tileinfo['ziptime'];
+ $zipcd['zipdat'] = $tileinfo['zipdate'];
+ $zipcd['zipccrc'] = $tileinfo['zipcrc'];
+ $zipcd['zipcsiz'] = $tileinfo['zipsize'];
+ $zipcd['zipcunc'] = $tileinfo['zipuncmp'];
+ $zipcd['zipcfnl'] = $tileinfo['zipfnln'];
+ $zipcd['zipcxtl'] = 0x00;
+ $zipcd['zipccml'] = 0x00;
+ $zipcd['zipdsk'] = 0x00;
+ $zipcd['zipint'] = 0x00;
+ $zipcd['zipext'] = 0x00;
+ $zipcd['zipofst'] = $offset;
+
+ $zipcd_data .= pack($formats['zipcdpack'],
+ $zipcd['zipcensig'],
+ $zipcd['zipcver'],
+ $zipcd['zipcos'],
+ $zipcd['zipcvxt'],
+ $zipcd['zipcexos'],
+ $zipcd['zipcflg'],
+ $zipcd['zipcmthd'],
+ $zipcd['ziptim'],
+ $zipcd['zipdat'],
+ $zipcd['zipccrc'],
+ $zipcd['zipcsiz'],
+ $zipcd['zipcunc'],
+ $zipcd['zipcfnl'],
+ $zipcd['zipcxtl'],
+ $zipcd['zipccml'],
+ $zipcd['zipdsk'],
+ $zipcd['zipint'],
+ $zipcd['zipext'],
+ $zipcd['zipofst']
+ ) . $filename;
+
+
+ fwrite($sp, $put);
+ $offset += strlen($put);
+
+}
+
+fwrite($sp, $zipcd_data);
+
+fclose($fp);
+fclose($sp);
+
+?>
diff --git a/navit/script/osm/Geo/OSM/APIClientV4.pm b/navit/script/osm/Geo/OSM/APIClientV4.pm
index 26b8ec5fc..d5a267e1c 100644
--- a/navit/script/osm/Geo/OSM/APIClientV4.pm
+++ b/navit/script/osm/Geo/OSM/APIClientV4.pm
@@ -22,10 +22,10 @@ use POSIX qw(sigprocmask);
sub new
{
my( $class, %attr ) = @_;
-
+
my $obj = bless {}, $class;
- my $url = $attr{api};
+ my $url = $attr{api};
if( not defined $url )
{
croak "Did not specify aip url";
@@ -34,7 +34,7 @@ sub new
$url =~ s,/$,,; # Strip trailing slash
$obj->{url} = $url;
$obj->{client} = new LWP::UserAgent(agent => 'Geo::OSM::APIClientV4', timeout => 1200);
-
+
if( defined $attr{username} and defined $attr{password} )
{
if( $obj->{url} =~ m,http://([\w.]+)/, )
@@ -44,7 +44,7 @@ sub new
my $encoded = MIME::Base64::encode_base64("$attr{username}:$attr{password}","");
$obj->{client}->default_header( "Authorization", "Basic $encoded" );
}
-
+
$obj->{reader} = init Geo::OSM::OsmReader( sub { _process($obj,@_) } );
return $obj;
}
@@ -62,7 +62,7 @@ sub _process
if( ref $obj->{buffer} eq "CODE" )
{ $obj->{buffer}->($ent); return }
die "Internal error: don't know what to do with buffer $obj->{buffer}";
-}
+}
# Utility function to handle the temporary blocking of signals in a way that
# works with exception handling.
@@ -104,18 +104,18 @@ sub create
$ent->set_id($oldid);
my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/create";
$req->content($content);
-
+
# print $req->as_string;
-
+
my $res = $self->_request($req);
-
+
# print $res->as_string;
if( $res->code == 200 )
{
return $res->content
}
-
+
$self->{last_error} = $res;
return undef;
}
@@ -126,11 +126,11 @@ sub modify
my $content = encode("utf-8", $ent->full_xml);
my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/".$ent->id();
$req->content($content);
-
+
# print $req->as_string;
-
+
my $res = $self->_request($req);
-
+
return $ent->id() if $res->code == 200;
$self->{last_error} = $res;
return undef;
@@ -142,11 +142,11 @@ sub delete
my $content = encode("utf-8", $ent->full_xml);
my $req = new HTTP::Request DELETE => $self->{url}."/".$ent->type()."/".$ent->id();
# $req->content($content);
-
+
# print $req->as_string;
-
+
my $res = $self->_request($req);
-
+
return $ent->id() if $res->code == 200;
$self->{last_error} = $res;
return undef;
@@ -157,9 +157,9 @@ sub get($$)
my $self = shift;
my $type = shift;
my $id = shift;
-
+
my $req = new HTTP::Request GET => $self->{url}."/$type/$id";
-
+
my $res = $self->_request($req);
if( $res->code != 200 )
@@ -167,7 +167,7 @@ sub get($$)
$self->{last_error} = $res;
return undef;
}
-
+
my @res;
$self->{buffer} = \@res;
$self->{reader}->parse($res->content);
@@ -176,7 +176,7 @@ sub get($$)
{
die "Unexpected response for get_$type [".$res->content()."]\n";
}
-
+
return $res[0];
}
@@ -203,9 +203,9 @@ sub map($$$$)
{
my $self = shift;
my @bbox = @_;
-
+
my $req = new HTTP::Request GET => $self->{url}."/map?bbox=$bbox[0],$bbox[1],$bbox[2],$bbox[3]";
-
+
my $res = $self->_request($req);
if( $res->code != 200 )
@@ -213,12 +213,12 @@ sub map($$$$)
$self->{last_error} = $res;
return undef;
}
-
+
my @res;
$self->{buffer} = \@res;
$self->{reader}->parse($res->content);
undef $self->{buffer};
-
+
return \@res;
}
diff --git a/navit/script/osm/Geo/OSM/APIClientV5.pm b/navit/script/osm/Geo/OSM/APIClientV5.pm
index 5bee097de..39cc124d9 100644
--- a/navit/script/osm/Geo/OSM/APIClientV5.pm
+++ b/navit/script/osm/Geo/OSM/APIClientV5.pm
@@ -24,10 +24,10 @@ use Socket qw(inet_ntoa);
sub new
{
my( $class, %attr ) = @_;
-
+
my $obj = bless {}, $class;
- my $url = $attr{api};
+ my $url = $attr{api};
if( not defined $url )
{
croak "Did not specify api url";
@@ -36,13 +36,13 @@ sub new
$url =~ s,/$,,; # Strip trailing slash
$obj->{url} = URI->new($url);
$obj->{client} = new LWP::UserAgent(agent => 'Geo::OSM::APIClientV5', timeout => 1200);
-
+
if( defined $attr{username} and defined $attr{password} )
{
my $encoded = MIME::Base64::encode_base64("$attr{username}:$attr{password}","");
$obj->{client}->default_header( "Authorization", "Basic $encoded" );
}
-
+
# We had the problem of the client doing a DNS lookup each request. To
# solve this we do a gethostbyname now and store that in the URI.
{
@@ -57,7 +57,7 @@ sub new
}
# Hack to avoid protocol lookups each time
@LWP::Protocol::http::EXTRA_SOCK_OPTS = ( 'Proto' => 6 );
-
+
$obj->{reader} = init Geo::OSM::OsmReader( sub { _process($obj,@_) } );
return $obj;
}
@@ -75,7 +75,7 @@ sub _process
if( ref $obj->{buffer} eq "CODE" )
{ $obj->{buffer}->($ent); return }
die "Internal error: don't know what to do with buffer $obj->{buffer}";
-}
+}
# Utility function to handle the temporary blocking of signals in a way that
# works with exception handling.
@@ -121,18 +121,18 @@ sub create($)
$ent->set_id($oldid);
my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/create";
$req->content($content);
-
+
# print $req->as_string;
-
+
my $res = $self->_request($req);
-
+
# print $res->as_string;
if( $res->code == 200 )
{
return $res->content
}
-
+
$self->{last_error} = $res;
return undef;
}
@@ -143,11 +143,11 @@ sub modify($)
my $content = encode("utf-8", $ent->full_xml);
my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/".$ent->id();
$req->content($content);
-
+
# print $req->as_string;
-
+
my $res = $self->_request($req);
-
+
return $ent->id() if $res->code == 200;
$self->{last_error} = $res;
return undef;
@@ -159,11 +159,11 @@ sub delete($)
my $content = encode("utf-8", $ent->full_xml);
my $req = new HTTP::Request DELETE => $self->{url}."/".$ent->type()."/".$ent->id();
# $req->content($content);
-
+
# print $req->as_string;
-
+
my $res = $self->_request($req);
-
+
return $ent->id() if $res->code == 200;
$self->{last_error} = $res;
return undef;
@@ -175,12 +175,12 @@ sub get($$)
my $type = shift;
my $id = shift;
my $extra = shift;
-
+
$extra = "/".$extra if (defined $extra);
$extra = "" if not defined $extra;
my $req = new HTTP::Request GET => $self->{url}."/$type/$id$extra";
-
+
my $res = $self->_request($req);
if( $res->code != 200 )
@@ -188,7 +188,7 @@ sub get($$)
$self->{last_error} = $res;
return undef;
}
-
+
my @res;
$self->{buffer} = \@res;
$self->{reader}->parse($res->content);
@@ -215,7 +215,7 @@ sub resurrect($$)
if (defined $ret || !defined $self->{last_error} || ($self->{last_error}->code != 410)) {
return $ret;
}
-
+
my @ents = $self->get($type, $id, 'history');
# we want the last _visible_ one
my $ent = $ents[-2];
@@ -270,9 +270,9 @@ sub get_subtype($$)
my $type = shift;
my $id = shift;
my $subtype = shift;
-
+
my $req = new HTTP::Request GET => $self->{url}."/$type/$id/$subtype";
-
+
my $res = $self->_request($req);
if( $res->code != 200 )
@@ -280,7 +280,7 @@ sub get_subtype($$)
$self->{last_error} = $res;
return undef;
}
-
+
my @res;
$self->{buffer} = \@res;
$self->{reader}->parse($res->content);
@@ -289,7 +289,7 @@ sub get_subtype($$)
{
die "Unexpected response for get_subtype($type,$id,$subtype) [".$res->content()."]\n";
}
-
+
return \@res;
}
@@ -297,7 +297,7 @@ sub get_node_ways($)
{
my $self = shift;
my $id = shift;
-
+
return $self->get_subtype("node",$id,"ways");
}
@@ -305,9 +305,9 @@ sub map($$$$)
{
my $self = shift;
my @bbox = @_;
-
+
my $req = new HTTP::Request GET => $self->{url}."/map?bbox=$bbox[0],$bbox[1],$bbox[2],$bbox[3]";
-
+
my $res = $self->_request($req);
if( $res->code != 200 )
@@ -315,12 +315,12 @@ sub map($$$$)
$self->{last_error} = $res;
return undef;
}
-
+
my @res;
$self->{buffer} = \@res;
$self->{reader}->parse($res->content);
undef $self->{buffer};
-
+
return \@res;
}
diff --git a/navit/script/osm/Geo/OSM/APIClientV6.pm b/navit/script/osm/Geo/OSM/APIClientV6.pm
index d659ac14c..304564be5 100644
--- a/navit/script/osm/Geo/OSM/APIClientV6.pm
+++ b/navit/script/osm/Geo/OSM/APIClientV6.pm
@@ -24,10 +24,10 @@ use Socket qw(inet_ntoa);
sub new
{
my( $class, %attr ) = @_;
-
+
my $obj = bless {}, $class;
- my $url = $attr{api};
+ my $url = $attr{api};
if( not defined $url )
{
croak "Did not specify api url";
@@ -36,13 +36,13 @@ sub new
$url =~ s,/$,,; # Strip trailing slash
$obj->{url} = URI->new($url);
$obj->{client} = new LWP::UserAgent(agent => 'Geo::OSM::APIClientV6', timeout => 1200);
-
+
if( defined $attr{username} and defined $attr{password} )
{
my $encoded = MIME::Base64::encode_base64("$attr{username}:$attr{password}","");
$obj->{client}->default_header( "Authorization", "Basic $encoded" );
}
-
+
# We had the problem of the client doing a DNS lookup each request. To
# solve this we do a gethostbyname now and store that in the URI.
{
@@ -57,7 +57,7 @@ sub new
}
# Hack to avoid protocol lookups each time
@LWP::Protocol::http::EXTRA_SOCK_OPTS = ( 'Proto' => 6 );
-
+
$obj->{reader} = init Geo::OSM::OsmReader( sub { _process($obj,@_) } );
return $obj;
}
@@ -75,7 +75,7 @@ sub _process
if( ref $obj->{buffer} eq "CODE" )
{ $obj->{buffer}->($ent); return }
die "Internal error: don't know what to do with buffer $obj->{buffer}";
-}
+}
# Utility function to handle the temporary blocking of signals in a way that
# works with exception handling.
@@ -125,11 +125,11 @@ sub create_changeset
$self->{changeset}=$res->content;
return 1;
}
-
+
$self->{last_error} = $res;
$self->{changeset}=undef;
return 0;
-
+
}
sub close_changeset
@@ -144,7 +144,7 @@ sub close_changeset
return 1;
}
return 0;
-
+
}
sub create($)
@@ -156,18 +156,18 @@ sub create($)
$ent->set_id($oldid);
my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/create";
$req->content($content);
-
+
# print $req->as_string;
-
+
my $res = $self->_request($req);
-
+
# print $res->as_string;
if( $res->code == 200 )
{
return $res->content
}
-
+
$self->{last_error} = $res;
return undef;
}
@@ -179,11 +179,11 @@ sub modify($)
my $content = encode("utf-8", $ent->full_xml);
my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/".$ent->id();
$req->content($content);
-
+
# print $req->as_string;
-
+
my $res = $self->_request($req);
-
+
return $ent->id() if $res->code == 200;
$self->{last_error} = $res;
return undef;
@@ -196,11 +196,11 @@ sub delete($)
my $content = encode("utf-8", $ent->full_xml);
my $req = new HTTP::Request DELETE => $self->{url}."/".$ent->type()."/".$ent->id();
$req->content($content);
-
+
# print $req->as_string;
-
+
my $res = $self->_request($req);
-
+
return $ent->id() if $res->code == 200;
$self->{last_error} = $res;
return undef;
@@ -212,12 +212,12 @@ sub get($$)
my $type = shift;
my $id = shift;
my $extra = shift;
-
+
$extra = "/".$extra if (defined $extra);
$extra = "" if not defined $extra;
my $req = new HTTP::Request GET => $self->{url}."/$type/$id$extra";
-
+
my $res = $self->_request($req);
if( $res->code != 200 )
@@ -225,7 +225,7 @@ sub get($$)
$self->{last_error} = $res;
return undef;
}
-
+
my @res;
$self->{buffer} = \@res;
$self->{reader}->parse($res->content);
@@ -252,7 +252,7 @@ sub resurrect($$)
if (defined $ret || !defined $self->{last_error} || ($self->{last_error}->code != 410)) {
return $ret;
}
-
+
my @ents = $self->get($type, $id, 'history');
# we want the last _visible_ one
my $ent = $ents[-2];
@@ -307,9 +307,9 @@ sub get_subtype($$)
my $type = shift;
my $id = shift;
my $subtype = shift;
-
+
my $req = new HTTP::Request GET => $self->{url}."/$type/$id/$subtype";
-
+
my $res = $self->_request($req);
if( $res->code != 200 )
@@ -317,7 +317,7 @@ sub get_subtype($$)
$self->{last_error} = $res;
return undef;
}
-
+
my @res;
$self->{buffer} = \@res;
$self->{reader}->parse($res->content);
@@ -326,7 +326,7 @@ sub get_subtype($$)
{
die "Unexpected response for get_subtype($type,$id,$subtype) [".$res->content()."]\n";
}
-
+
return \@res;
}
@@ -334,7 +334,7 @@ sub get_node_ways($)
{
my $self = shift;
my $id = shift;
-
+
return $self->get_subtype("node",$id,"ways");
}
@@ -342,9 +342,9 @@ sub map($$$$)
{
my $self = shift;
my @bbox = @_;
-
+
my $req = new HTTP::Request GET => $self->{url}."/map?bbox=$bbox[0],$bbox[1],$bbox[2],$bbox[3]";
-
+
my $res = $self->_request($req);
if( $res->code != 200 )
@@ -352,12 +352,12 @@ sub map($$$$)
$self->{last_error} = $res;
return undef;
}
-
+
my @res;
$self->{buffer} = \@res;
$self->{reader}->parse($res->content);
undef $self->{buffer};
-
+
return \@res;
}
diff --git a/navit/script/osm/Geo/OSM/EntitiesV3.pm b/navit/script/osm/Geo/OSM/EntitiesV3.pm
index 2708463c7..0e0581af4 100644
--- a/navit/script/osm/Geo/OSM/EntitiesV3.pm
+++ b/navit/script/osm/Geo/OSM/EntitiesV3.pm
@@ -67,9 +67,9 @@ sub tag_xml
{
my ($self,$writer) = @_;
my @a = @{$self->{tags}};
-
+
my $str = "";
-
+
while( my($k,$v) = splice @a, 0, 2 )
{
$writer->emptyTag( "tag", 'k' => $k, 'v' => $v );
@@ -83,9 +83,9 @@ sub set_id
my($self,$id) = @_;
if( not defined $id )
- { $id = $_ID-- }
+ { $id = $_ID-- }
$self->{id} = $id;
-}
+}
sub id
{
@@ -120,14 +120,14 @@ our @ISA = qw(Geo::OSM::Entity);
sub new
{
my($class, $attr, $tags, $segs) = @_;
-
+
my $obj = bless $class->SUPER::_new(), $class;
-
+
$obj->set_tags($tags);
$obj->set_segs($segs);
$obj->set_id($attr->{id} );
$obj->set_timestamp( $attr->{timestamp} );
-
+
return $obj;
}
@@ -168,11 +168,11 @@ sub map
my $incomplete = 0;
my ($new_id) = $mapper->map('way',$self->id); # Determine mapped ID
# It is ok for the new_id to be incomplete; it may be a create request
-
+
my @new_segs = map { [ $mapper->map('segment',$_) ] } @{$self->segs};
map { $incomplete |= $_->[1] } @new_segs;
# incomplete tracks if any of the segs are incomplete
-
+
my $new_ent = new Geo::OSM::Way( {id=>$new_id, timestamp=>$self->timestamp}, $self->tags, [map {$_->[0]} @new_segs] );
return($new_ent,$incomplete);
}
@@ -183,15 +183,15 @@ our @ISA = qw(Geo::OSM::Entity);
sub new
{
my($class, $attr, $tags) = @_;
-
+
my $obj = bless $class->SUPER::_new(), $class;
-
+
$obj->set_tags($tags);
$obj->set_id($attr->{id} );
$obj->set_timestamp( $attr->{timestamp} );
$obj->{from} = $attr->{from};
$obj->{to} = $attr->{to};
-
+
return $obj;
}
@@ -242,15 +242,15 @@ our @ISA = qw(Geo::OSM::Entity);
sub new
{
my($class, $attr, $tags) = @_;
-
+
my $obj = bless $class->SUPER::_new(), $class;
-
+
$obj->set_tags($tags);
$obj->set_id($attr->{id} );
$obj->set_timestamp( $attr->{timestamp} );
$obj->{lon} = $attr->{lon};
$obj->{lat} = $attr->{lat};
-
+
return $obj;
}
@@ -277,7 +277,7 @@ sub xml
my $self = shift;
my $str = "";
my $writer = $self->_get_writer(\$str);
-
+
$writer->startTag( "node", id => $self->id, lat => $self->lat, lon => $self->lon, timestamp => $self->timestamp );
$self->tag_xml( $writer );
$writer->endTag( "node" );
diff --git a/navit/script/osm/Geo/OSM/EntitiesV5.pm b/navit/script/osm/Geo/OSM/EntitiesV5.pm
index 625ff6b03..fa9116daa 100644
--- a/navit/script/osm/Geo/OSM/EntitiesV5.pm
+++ b/navit/script/osm/Geo/OSM/EntitiesV5.pm
@@ -67,9 +67,9 @@ sub tag_xml
{
my ($self,$writer) = @_;
my @a = @{$self->{tags}};
-
+
my $str = "";
-
+
while( my($k,$v) = splice @a, 0, 2 )
{
$writer->emptyTag( "tag", 'k' => $k, 'v' => $v );
@@ -83,9 +83,9 @@ sub set_id
my($self,$id) = @_;
if( not defined $id )
- { $id = $_ID-- }
+ { $id = $_ID-- }
$self->{id} = $id;
-}
+}
sub id
{
@@ -121,14 +121,14 @@ use Carp;
sub new
{
my($class, $attr, $tags, $nodes) = @_;
-
+
my $obj = bless $class->SUPER::_new(), $class;
-
+
$obj->set_tags($tags);
$obj->set_nodes($nodes);
$obj->set_id($attr->{id} );
$obj->set_timestamp( $attr->{timestamp} );
-
+
return $obj;
}
@@ -175,11 +175,11 @@ sub map
my $incomplete = 0;
my ($new_id) = $mapper->map('way',$self->id); # Determine mapped ID
# It is ok for the new_id to be incomplete; it may be a create request
-
+
my @new_nodes = map { [ $mapper->map('node',$_) ] } @{$self->nodes};
map { $incomplete |= $_->[1] } @new_nodes;
# incomplete tracks if any of the segs are incomplete
-
+
my $new_ent = new Geo::OSM::Way( {id=>$new_id, timestamp=>$self->timestamp}, $self->tags, [map {$_->[0]} @new_nodes] );
return($new_ent,$incomplete);
}
@@ -204,7 +204,7 @@ sub new
{ $arg = { type => $arg->[0], ref => $arg->[1], role => $arg->[2] } }
}
if( ref($arg) eq "HASH" )
- {
+ {
if( ref $arg->{ref} )
{ $arg = [ $arg->{ref}->type, $arg->{ref}->id, $arg->{role} ] }
else
@@ -217,7 +217,7 @@ sub new
croak "Bad member id '$arg->[1]'"
unless $arg->[1] =~ /^-?\d+$/;
$arg->[2] ||= "";
-
+
return bless $arg, $class;
}
@@ -249,14 +249,14 @@ our @ISA = qw(Geo::OSM::Entity);
sub new
{
my($class, $attr, $tags, $members) = @_;
-
+
my $obj = bless $class->SUPER::_new(), $class;
-
+
$obj->set_tags($tags);
$obj->set_members($members);
$obj->set_id($attr->{id} );
$obj->set_timestamp( $attr->{timestamp} );
-
+
return $obj;
}
@@ -298,7 +298,7 @@ sub map
{
my($self,$mapper) = @_;
my $incomplete = 0;
-
+
my ($new_id) = $mapper->map('relation',$self->id);
my @new_members = map { [ $_->map($mapper) ] } @{$self->members};
map { $incomplete |= $_->[1] } @new_members;
@@ -314,9 +314,9 @@ our @ISA = qw(Geo::OSM::Entity);
sub new
{
my($class, $attr, $tags) = @_;
-
+
my $obj = bless $class->SUPER::_new(), $class;
-
+
$obj->set_tags($tags);
$obj->set_id($attr->{id} );
$obj->set_timestamp( $attr->{timestamp} );
@@ -327,7 +327,7 @@ sub new
}
$obj->{lon} = $attr->{lon};
$obj->{lat} = $attr->{lat};
-
+
return $obj;
}
@@ -354,7 +354,7 @@ sub xml
my $self = shift;
my $str = "";
my $writer = $self->_get_writer(\$str);
-
+
$writer->startTag( "node", id => $self->id, lat => $self->lat, lon => $self->lon, timestamp => $self->timestamp );
$self->tag_xml( $writer );
$writer->endTag( "node" );
diff --git a/navit/script/osm/Geo/OSM/EntitiesV6.pm b/navit/script/osm/Geo/OSM/EntitiesV6.pm
index 8747c17f0..4a9b49cbb 100644
--- a/navit/script/osm/Geo/OSM/EntitiesV6.pm
+++ b/navit/script/osm/Geo/OSM/EntitiesV6.pm
@@ -67,9 +67,9 @@ sub tag_xml
{
my ($self,$writer) = @_;
my @a = @{$self->{tags}};
-
+
my $str = "";
-
+
while( my($k,$v) = splice @a, 0, 2 )
{
$writer->emptyTag( "tag", 'k' => $k, 'v' => $v );
@@ -83,9 +83,9 @@ sub set_id
my($self,$id) = @_;
if( not defined $id )
- { $id = $_ID-- }
+ { $id = $_ID-- }
$self->{id} = $id;
-}
+}
sub id
{
@@ -143,16 +143,16 @@ use Carp;
sub new
{
my($class, $attr, $tags, $nodes) = @_;
-
+
my $obj = bless $class->SUPER::_new(), $class;
-
+
$obj->set_tags($tags);
$obj->set_nodes($nodes);
$obj->set_id($attr->{id} );
$obj->set_timestamp( $attr->{timestamp} );
$obj->set_changeset( $attr->{changeset} );
$obj->set_version( $attr->{version} );
-
+
return $obj;
}
@@ -199,11 +199,11 @@ sub map
my $incomplete = 0;
my ($new_id) = $mapper->map('way',$self->id); # Determine mapped ID
# It is ok for the new_id to be incomplete; it may be a create request
-
+
my @new_nodes = map { [ $mapper->map('node',$_) ] } @{$self->nodes};
map { $incomplete |= $_->[1] } @new_nodes;
# incomplete tracks if any of the segs are incomplete
-
+
my $new_ent = new Geo::OSM::Way( {id=>$new_id, timestamp=>$self->timestamp}, $self->tags, [map {$_->[0]} @new_nodes] );
return($new_ent,$incomplete);
}
@@ -228,7 +228,7 @@ sub new
{ $arg = { type => $arg->[0], ref => $arg->[1], role => $arg->[2] } }
}
if( ref($arg) eq "HASH" )
- {
+ {
if( ref $arg->{ref} )
{ $arg = [ $arg->{ref}->type, $arg->{ref}->id, $arg->{role} ] }
else
@@ -241,7 +241,7 @@ sub new
croak "Bad member id '$arg->[1]'"
unless $arg->[1] =~ /^-?\d+$/;
$arg->[2] ||= "";
-
+
return bless $arg, $class;
}
@@ -273,16 +273,16 @@ our @ISA = qw(Geo::OSM::Entity);
sub new
{
my($class, $attr, $tags, $members) = @_;
-
+
my $obj = bless $class->SUPER::_new(), $class;
-
+
$obj->set_tags($tags);
$obj->set_members($members);
$obj->set_id($attr->{id} );
$obj->set_timestamp( $attr->{timestamp} );
$obj->set_changeset( $attr->{changeset} );
$obj->set_version( $attr->{version} );
-
+
return $obj;
}
@@ -324,7 +324,7 @@ sub map
{
my($self,$mapper) = @_;
my $incomplete = 0;
-
+
my ($new_id) = $mapper->map('relation',$self->id);
my @new_members = map { [ $_->map($mapper) ] } @{$self->members};
map { $incomplete |= $_->[1] } @new_members;
@@ -341,9 +341,9 @@ our @ISA = qw(Geo::OSM::Entity);
sub new
{
my($class, $attr, $tags) = @_;
-
+
my $obj = bless $class->SUPER::_new(), $class;
-
+
$obj->set_tags($tags);
$obj->set_id($attr->{id} );
$obj->set_timestamp( $attr->{timestamp} );
@@ -356,7 +356,7 @@ sub new
}
$obj->{lon} = $attr->{lon};
$obj->{lat} = $attr->{lat};
-
+
return $obj;
}
@@ -383,7 +383,7 @@ sub xml
my $self = shift;
my $str = "";
my $writer = $self->_get_writer(\$str);
-
+
$writer->startTag( "node", id => $self->id, lat => $self->lat, lon => $self->lon, timestamp => $self->timestamp, changeset => $self->changeset, version => $self->version);
$self->tag_xml( $writer );
$writer->endTag( "node" );
diff --git a/navit/script/osm/Geo/OSM/MapFeatures.pm b/navit/script/osm/Geo/OSM/MapFeatures.pm
index c4ae62f89..473ff20de 100644
--- a/navit/script/osm/Geo/OSM/MapFeatures.pm
+++ b/navit/script/osm/Geo/OSM/MapFeatures.pm
@@ -49,7 +49,7 @@ sub load($;$){
return;
}
my $self = XMLin($fh);
-
+
if (not $self) {
print STDERR "WARNING: Could not parse osm data from $filename\n";
return;
@@ -61,7 +61,7 @@ sub load($;$){
#warn Dumper(\$self->{rule});
#warn Dumper(keys %{$self});
#warn Dumper(%{$self});
-
+
bless($self,$class);
return $self;
}
@@ -97,7 +97,7 @@ sub load_icons($$){
last;
}
}
-
+
if ( ! $rule->{png} ) {
warn "missing $img\n";
}
@@ -139,7 +139,7 @@ sub get_icons($$$){
my $condition = $rule->{condition};
# print STDERR "condition: $condition->{k}=$condition->{v}\n";
- if ( defined ( $attr{scale_max}) &&
+ if ( defined ( $attr{scale_max}) &&
$scale > $attr{scale_max}) {
next;
}
@@ -150,7 +150,7 @@ sub get_icons($$$){
print STDERR "get_icon() image: $img\t";
$png = $rule->{png};
}
-
+
return $png if $png;
}
return undef;
diff --git a/navit/script/osm/Geo/OSM/OsmChangeReaderV3.pm b/navit/script/osm/Geo/OSM/OsmChangeReaderV3.pm
index 65103a36e..ff99e4043 100644
--- a/navit/script/osm/Geo/OSM/OsmChangeReaderV3.pm
+++ b/navit/script/osm/Geo/OSM/OsmChangeReaderV3.pm
@@ -32,7 +32,7 @@ use constant FILETYPE_OSMCHANGE => 1;
use constant FILETYPE_OSM => 2;
sub new
-{
+{
my $obj = bless{}, shift;
my $proc = shift;
my $prog = shift;
@@ -46,7 +46,7 @@ sub new
# With this initialiser, your process will get called with instantiated objects rather than useless details
sub init
-{
+{
my $obj = bless{}, shift;
my $proc = shift;
my $prog = shift;
@@ -61,12 +61,12 @@ sub init
sub _process
{
my($self, $command, $entity, $attr, $tags, $segs) = @_;
-
+
if( defined $self->{oldproc} )
{
return $self->{oldproc}->($command, $entity, $attr, $tags, $segs);
}
-
+
my $ent;
if( $entity eq "node" )
{
@@ -90,7 +90,7 @@ sub load{
$self->{filetype} = FILETYPE_UNKNOWN;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
my $fh = data_open($file_name);
@@ -120,7 +120,7 @@ sub parse($)
my ($self, $string) = @_;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
$self->{input_length} = length($string);
@@ -145,7 +145,7 @@ sub parse($)
# Function is called whenever an XML tag is started
sub DoStart
{
-#print @_,"\n";
+#print @_,"\n";
my ($self, $Expat, $Name, %Attr) = @_;
if( $self->{filetype} == FILETYPE_UNKNOWN )
@@ -161,7 +161,7 @@ sub DoStart
} elsif($Name eq "osm"){
$self->{state} = STATE_EXPECT_ENTITY;
$self->{filetype} = FILETYPE_OSM;
-
+
if( $Attr{version} ne "0.3" and $Attr{version} ne "0.4" )
{ die "OsmChangeReaderV3 can only read 0.3 and 0.4 files, found '$Attr{version}'\n" }
} else {
@@ -284,7 +284,7 @@ OsmChangeReaderV3 - Module for reading OpenStreetMap V3 Change XML data files
my $OSM = new Geo::OSM::OsmChangeReader(\&process);
$OSM->load("Data/changes.osc");
-
+
sub process
{
my($OSM, $command, $entity, $attr, $tags, $segs) = @_;
diff --git a/navit/script/osm/Geo/OSM/OsmChangeReaderV5.pm b/navit/script/osm/Geo/OSM/OsmChangeReaderV5.pm
index fdc65e1a9..50dfeea6d 100644
--- a/navit/script/osm/Geo/OSM/OsmChangeReaderV5.pm
+++ b/navit/script/osm/Geo/OSM/OsmChangeReaderV5.pm
@@ -33,7 +33,7 @@ use constant FILETYPE_OSM => 2;
# With this initialiser, your process will get called with instantiated objects
sub init
-{
+{
my $obj = bless{}, shift;
my $proc = shift;
my $prog = shift;
@@ -48,12 +48,12 @@ sub init
sub _process
{
my($self, $command, $entity, $attr, $tags, $members) = @_;
-
+
if( defined $self->{oldproc} )
{
return $self->{oldproc}->($command, $entity, $attr, $tags, $members);
}
-
+
my $ent;
if( $entity eq "node" )
{
@@ -77,7 +77,7 @@ sub load{
$self->{filetype} = FILETYPE_UNKNOWN;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
my $fh = data_open($file_name);
@@ -107,7 +107,7 @@ sub parse($)
my ($self, $string) = @_;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
$self->{input_length} = length($string);
@@ -132,7 +132,7 @@ sub parse($)
# Function is called whenever an XML tag is started
sub DoStart
{
-#print @_,"\n";
+#print @_,"\n";
my ($self, $Expat, $Name, %Attr) = @_;
if( $self->{filetype} == FILETYPE_UNKNOWN )
@@ -148,7 +148,7 @@ sub DoStart
} elsif($Name eq "osm"){
$self->{state} = STATE_EXPECT_ENTITY;
$self->{filetype} = FILETYPE_OSM;
-
+
if( $Attr{version} ne "0.5" )
{ die "OsmChangeReaderV3 can only read 0.5 files, found '$Attr{version}'\n" }
} else {
@@ -276,7 +276,7 @@ OsmChangeReaderV5 - Module for reading OpenStreetMap V5 Change XML data files
my $OSM = new Geo::OSM::OsmChangeReader(\&process);
$OSM->load("Data/changes.osc");
-
+
sub process
{
my($OSM, $command, $entity) = @_;
diff --git a/navit/script/osm/Geo/OSM/OsmChangeReaderV6.pm b/navit/script/osm/Geo/OSM/OsmChangeReaderV6.pm
index e67397829..4e312f519 100644
--- a/navit/script/osm/Geo/OSM/OsmChangeReaderV6.pm
+++ b/navit/script/osm/Geo/OSM/OsmChangeReaderV6.pm
@@ -33,7 +33,7 @@ use constant FILETYPE_OSM => 2;
# With this initialiser, your process will get called with instantiated objects
sub init
-{
+{
my $obj = bless{}, shift;
my $proc = shift;
my $prog = shift;
@@ -48,12 +48,12 @@ sub init
sub _process
{
my($self, $command, $entity, $attr, $tags, $members) = @_;
-
+
if( defined $self->{oldproc} )
{
return $self->{oldproc}->($command, $entity, $attr, $tags, $members);
}
-
+
my $ent;
if( $entity eq "node" )
{
@@ -77,7 +77,7 @@ sub load{
$self->{filetype} = FILETYPE_UNKNOWN;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
my $fh = data_open($file_name);
@@ -107,7 +107,7 @@ sub parse($)
my ($self, $string) = @_;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
$self->{input_length} = length($string);
@@ -132,7 +132,7 @@ sub parse($)
# Function is called whenever an XML tag is started
sub DoStart
{
-#print @_,"\n";
+#print @_,"\n";
my ($self, $Expat, $Name, %Attr) = @_;
if( $self->{filetype} == FILETYPE_UNKNOWN )
@@ -148,7 +148,7 @@ sub DoStart
} elsif($Name eq "osm"){
$self->{state} = STATE_EXPECT_ENTITY;
$self->{filetype} = FILETYPE_OSM;
-
+
if( $Attr{version} ne "0.6" )
{ die "OsmChangeReaderV6 can only read 0.6 files, found '$Attr{version}'\n" }
} else {
@@ -276,7 +276,7 @@ OsmChangeReaderV6 - Module for reading OpenStreetMap V6 Change XML data files
my $OSM = new Geo::OSM::OsmChangeReader(\&process);
$OSM->load("Data/changes.osc");
-
+
sub process
{
my($OSM, $command, $entity) = @_;
diff --git a/navit/script/osm/Geo/OSM/OsmReaderV3.pm b/navit/script/osm/Geo/OSM/OsmReaderV3.pm
index b01963470..6cc64b899 100644
--- a/navit/script/osm/Geo/OSM/OsmReaderV3.pm
+++ b/navit/script/osm/Geo/OSM/OsmReaderV3.pm
@@ -26,7 +26,7 @@ use constant STATE_EXPECT_BODY => 4;
# With this initialiser, your process will get called with instantiated objects
sub init
-{
+{
my $obj = bless{}, shift;
my $proc = shift;
my $prog = shift;
@@ -41,7 +41,7 @@ sub init
sub _process
{
my($self, $entity, $attr, $tags, $members) = @_;
-
+
my $ent;
if( $entity eq "node" )
{
@@ -65,7 +65,7 @@ sub load($)
my ($self, $file_name) = @_;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
my $fh = data_open($file_name);
@@ -94,7 +94,7 @@ sub parse($)
my ($self, $string) = @_;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
$self->{input_length} = length($string);
@@ -119,14 +119,14 @@ sub parse($)
# Function is called whenever an XML tag is started
sub DoStart
{
-#print @_,"\n";
+#print @_,"\n";
my ($self, $Expat, $Name, %Attr) = @_;
if( $self->{state} == STATE_INIT )
{
if($Name eq "osm"){
$self->{state} = STATE_EXPECT_ENTITY;
-
+
if( $Attr{version} ne "0.3" and $Attr{version} ne "0.4")
{ die "OsmReaderV5 can only read 0.3 or 0.4 files, found '$Attr{version}'\n" }
} else {
@@ -206,7 +206,7 @@ OsmReaderV3 - Module for reading OpenStreetMap V3 XML data files
my $OSM = new Geo::OSM::OsmReader(\&process);
$OSM->load("Data/changes.osc");
-
+
sub process
{
my($OSM, $entity) = @_;
diff --git a/navit/script/osm/Geo/OSM/OsmReaderV5.pm b/navit/script/osm/Geo/OSM/OsmReaderV5.pm
index 37a477b1a..315e4dddf 100644
--- a/navit/script/osm/Geo/OSM/OsmReaderV5.pm
+++ b/navit/script/osm/Geo/OSM/OsmReaderV5.pm
@@ -26,7 +26,7 @@ use constant STATE_EXPECT_BODY => 4;
# With this initialiser, your process will get called with instantiated objects
sub init
-{
+{
my $obj = bless{}, shift;
my $proc = shift;
my $prog = shift;
@@ -41,7 +41,7 @@ sub init
sub _process
{
my($self, $entity, $attr, $tags, $members) = @_;
-
+
my $ent;
if( $entity eq "node" )
{
@@ -65,7 +65,7 @@ sub load($)
my ($self, $file_name) = @_;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
my $fh = data_open($file_name);
@@ -94,7 +94,7 @@ sub parse($)
my ($self, $string) = @_;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
$self->{input_length} = length($string);
@@ -119,14 +119,14 @@ sub parse($)
# Function is called whenever an XML tag is started
sub DoStart
{
-#print @_,"\n";
+#print @_,"\n";
my ($self, $Expat, $Name, %Attr) = @_;
if( $self->{state} == STATE_INIT )
{
if($Name eq "osm"){
$self->{state} = STATE_EXPECT_ENTITY;
-
+
if( $Attr{version} ne "0.5" )
{ die "OsmReaderV5 can only read 0.5 files, found '$Attr{version}'\n" }
} else {
@@ -209,7 +209,7 @@ OsmReaderV5 - Module for reading OpenStreetMap V5 XML data files
my $OSM = new Geo::OSM::OsmReader(\&process);
$OSM->load("Data/changes.osc");
-
+
sub process
{
my($OSM, $entity) = @_;
diff --git a/navit/script/osm/Geo/OSM/OsmReaderV6.pm b/navit/script/osm/Geo/OSM/OsmReaderV6.pm
index 4f6a683d2..7ad3c736a 100644
--- a/navit/script/osm/Geo/OSM/OsmReaderV6.pm
+++ b/navit/script/osm/Geo/OSM/OsmReaderV6.pm
@@ -26,7 +26,7 @@ use constant STATE_EXPECT_BODY => 4;
# With this initialiser, your process will get called with instantiated objects
sub init
-{
+{
my $obj = bless{}, shift;
my $proc = shift;
my $prog = shift;
@@ -41,7 +41,7 @@ sub init
sub _process
{
my($self, $entity, $attr, $tags, $members) = @_;
-
+
my $ent;
if( $entity eq "node" )
{
@@ -65,7 +65,7 @@ sub load($)
my ($self, $file_name) = @_;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
my $fh = data_open($file_name);
@@ -94,7 +94,7 @@ sub parse($)
my ($self, $string) = @_;
$self->{state} = STATE_INIT;
-
+
my $start_time = time();
my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}});
$self->{input_length} = length($string);
@@ -119,14 +119,14 @@ sub parse($)
# Function is called whenever an XML tag is started
sub DoStart
{
-#print @_,"\n";
+#print @_,"\n";
my ($self, $Expat, $Name, %Attr) = @_;
if( $self->{state} == STATE_INIT )
{
if($Name eq "osm"){
$self->{state} = STATE_EXPECT_ENTITY;
-
+
if( $Attr{version} ne "0.6" )
{ die "OsmReaderV6 can only read 0.6 files, found '$Attr{version}'\n" }
} else {
@@ -209,7 +209,7 @@ OsmReaderV6 - Module for reading OpenStreetMap V6 XML data files
my $OSM = new Geo::OSM::OsmReader(\&process);
$OSM->load("Data/changes.osc");
-
+
sub process
{
my($OSM, $entity) = @_;
diff --git a/navit/script/osm/Geo/OSM/OsmXML.pm b/navit/script/osm/Geo/OSM/OsmXML.pm
index 60f458db7..f37d269c3 100644
--- a/navit/script/osm/Geo/OSM/OsmXML.pm
+++ b/navit/script/osm/Geo/OSM/OsmXML.pm
@@ -51,7 +51,7 @@ sub bounds(){
sub DoStart()
{
my ($Expat, $Name, %Attr) = @_;
-
+
if($Name eq "node"){
undef %OsmXML::Tags;
%OsmXML::MainAttr = %Attr;
@@ -97,7 +97,7 @@ sub DoEnd(){
$OsmXML::Ways{$ID}{"segments"} = join(",",@OsmXML::WaySegments);
foreach(keys(%OsmXML::Tags)){
$OsmXML::Ways{$ID}{$_} = $OsmXML::Tags{$_};
- }
+ }
}
}
@@ -118,16 +118,16 @@ OsmXML - Module for reading OpenStreetMap XML data files
$OSM = new OsmXML();
$OSM->load("Data/nottingham.osm");
-
+
foreach $Way(%OsmXML::Ways){
@Segments = split(/,/, $Way->{"segments"});
-
+
foreach $SegmentID(@Segments){
$Segment = $OsmXML::Segments{$SegmentID};
-
+
$Node1 = $OsmXML::Nodes{$Segment->{"from"}};
$Node2 = $OsmXML::Nodes{$Segment->{"to"}};
-
+
printf "Node at %f,%f, named %s, is a %s",
$Node2->{"lat"},
$Node2->{"lon"},
diff --git a/navit/script/osm/Geo/OSM/Planet.pm b/navit/script/osm/Geo/OSM/Planet.pm
index bedfdffc8..260b96b5f 100644
--- a/navit/script/osm/Geo/OSM/Planet.pm
+++ b/navit/script/osm/Geo/OSM/Planet.pm
@@ -64,10 +64,10 @@ my $estimations = {
};
# ------------------------------------------------------------------
-# This routine estimates the maximum id for way,elem,seg,...
+# This routine estimates the maximum id for way,elem,seg,...
# The values are taken from older planet.osm Files
# So they mostly are a little bit to low
-# ARGS:
+# ARGS:
# $type: line|way|tag|...
# RETURNS:
# $result: number of estimated max_id
@@ -81,10 +81,10 @@ sub estimated_max_id($){
}
# ------------------------------------------------------------------
-# This routine estimates the maximim number of elements for way,elem,seg,...
+# This routine estimates the maximim number of elements for way,elem,seg,...
# The values are taken from older planet.osm Files
# So they mostly are a little bit to low
-# ARGS:
+# ARGS:
# $type: line|way|tag|...
# RETURNS:
# $result: number of estimated elements
@@ -112,7 +112,7 @@ sub osm_dir() {
chomp $home;
$home = "/home/$home";
}
-
+
$dir = "$home/osm";
return $dir;
}
@@ -144,22 +144,22 @@ sub sort_unique(@){
}
return @erg
}
-
+
# ------------------------------------------------------------------
# mirror the newest planet.osm File to
# ~/osm/planet/planet.osm.bz2
-# and the resulting
+# and the resulting
# Filename is returned
#
-# the file is -----NO LONGER--- Sanitized afterwards
+# the file is -----NO LONGER--- Sanitized afterwards
sub mirror_planet(){
my $planet_server="http://planet.openstreetmap.org";
my $url = "$planet_server";
my $mirror_dir=planet_dir();
mkdir_if_needed( $mirror_dir );
-
+
my $current_file;
if ( !$Utils::LWP::Utils::NO_MIRROR ) {
# Get Index.html of Planet.osm.org
@@ -194,11 +194,11 @@ sub mirror_planet(){
print STDERR "Existing Files: \n\t".join("\n\t",@files)."\n";
}
$current_file = $files[0];
-
+
if ( $DEBUG) {
- print STDERR "Choosen File: $current_file\n";
+ print STDERR "Chosen File: $current_file\n";
}
-
+
return undef unless $current_file;
# $current_file = UTF8sanitize($current_file);
@@ -220,7 +220,7 @@ sub mirror_planet(){
# ~/osm/planet/planet-07XXXX-a.osm.bz2
# If a recent enought Version is found in ~/osm/planet/
# nothing is done, but the filename of the file is returned
-# if the routine finds an uncompressed up to date Version
+# if the routine finds an uncompressed up to date Version
# ~/osm/planet/planet-07XXXX-a.osm
# this Filename is returned.
sub UTF8sanitize($){
@@ -259,7 +259,7 @@ sub UTF8sanitize($){
print "Command: $cmd" if $DEBUG || $VERBOSE;
my $result = `$cmd`;
print $result if $DEBUG || $VERBOSE;
-
+
print "Sanitized $filename " if $DEBUG || $VERBOSE;
print_time($start_time);
@@ -279,7 +279,7 @@ sub UTF8sanitize($){
}
# ------------------------------------------------------------------
-# find a file in the current Perl Search path. For now this was the
+# find a file in the current Perl Search path. For now this was the
# easiest solution to find programms like UTF8Sanitize
# ARGS: relative filename (relative to @INC-path
# RETURNS: Absolute path to file
@@ -295,7 +295,7 @@ sub find_file_in_perl_path($){
last;
};
}
-
+
print "find_file_in_perl_path($file): --> $found_file\n" if $DEBUG;
return $found_file;
}
diff --git a/navit/script/osm/Geo/OSM/SegmentList.pm b/navit/script/osm/Geo/OSM/SegmentList.pm
index 0de35ebf5..8523173ce 100644
--- a/navit/script/osm/Geo/OSM/SegmentList.pm
+++ b/navit/script/osm/Geo/OSM/SegmentList.pm
@@ -54,7 +54,7 @@ sub load_segment_list($;$){
my $osm_filename = "${path}/csv/osm-segments.csv";
$osm_filename =~ s,\~/,$home/,;
printf STDERR "check $osm_filename for loading\n" if $DEBUG;
-
+
die "Cannot open $osm_filename\n" unless -s $osm_filename;
$osm_segments = Geo::OSM::SegmentList::LoadOSM_segment_csv($osm_filename, $bounds);
};
@@ -111,7 +111,7 @@ sub LoadOSM_segment_csv($;$){
$main::dont_write_osm_storable=1 || $check_bounds;
$main::dont_read_osm_storable=1;
- if ( -s "$filename.storable" &&
+ if ( -s "$filename.storable" &&
! file_needs_re_generation($filename,"$filename.storable")
&& ! $main::dont_read_osm_storable ) {
# later we should compare if the file also is newer than the source
@@ -178,7 +178,7 @@ sub LoadOSM_segment_csv($;$){
# -------------------------------------------------------
# Load the segment list from postgis
# Args: {lat_min=> .., lat_max => ..., lon_min => .., lon_max => .. }
-# This is a test to see if we can handle all segments of the world
+# This is a test to see if we can handle all segments of the world
# with reasonable query times
sub LoadOSM_segment_postgis($;$){
my $bounds = shift;
@@ -192,7 +192,7 @@ sub LoadOSM_segment_postgis($;$){
my $sth;
use DBI;
-
+
my $dbname="gis";
my $dbhost="/var/run/postgresql";
my $dbh = DBI->connect("dbi:Pg:dbname=$dbname;host=$dbhost", "", "", {AutoCommit => 0});
@@ -205,7 +205,7 @@ sub LoadOSM_segment_postgis($;$){
# WHERE the_geom && setsrid('BOX(47.36 21.40,51.185 21.53)'::box2d, 42102)
# WHERE GeomFromText('POINT(25.3 25.40)', 42102) && the_geom \
# AND distance(the_geom, GeomFromText('POINT(25.7 5.3)', 42102)) = 0
- # WHERE distance(the_geom, setsrid('BOX(4.36 2.3,1.5 2.8)'::box2d, 42102)) = 0
+ # WHERE distance(the_geom, setsrid('BOX(4.36 2.3,1.5 2.8)'::box2d, 42102)) = 0
# WHERE the_point && setsrid('BOX(295149 2315499, 465992 2163790)'::box2d, -1)
##############################
@@ -223,12 +223,12 @@ sub LoadOSM_segment_postgis($;$){
my $polygon_text=sprintf("POLYGON((%.5f %.5f,%.5f %.5f,%.5f %.5f,%.5f %.5f,%.5f %.5f))",
$bounds->{lat_min}-0.1 , $bounds->{lon_min}-0.1,
- $bounds->{lat_max}+0.1 , $bounds->{lon_min}-0.1 ,
- $bounds->{lat_max}+0.1 , $bounds->{lon_max}+0.1 ,
- $bounds->{lat_min}-0.1 , $bounds->{lon_max}+0.1 ,
+ $bounds->{lat_max}+0.1 , $bounds->{lon_min}-0.1 ,
+ $bounds->{lat_max}+0.1 , $bounds->{lon_max}+0.1 ,
+ $bounds->{lat_min}-0.1 , $bounds->{lon_max}+0.1 ,
$bounds->{lat_min}-0.1 , $bounds->{lon_min}-0.1);
my $polygon="transform(GeomFromText('$polygon_text',${SRID_WGS84}),$SRID_OSM)";
-
+
my $select = "select osm_id,highway,name from planet_osm_line where highway is not null and way && ".
" $polygon ".
"limit 5;";
@@ -240,9 +240,9 @@ sub LoadOSM_segment_postgis($;$){
}
printf STDERR "---------------------------------------------------------------\n" if $DEBUG || $VERBOSE;
-
+
# $select = "SELECT name ,astext(way),$distance FROM planet_osm_roads WHERE $distance < 500 order by $distance;";
-
+
#SELECT * FROM planet_osm_roads WHERE way in ?",
#$select = "SELECT name FROM planet_osm_roads WHERE distance(way,GeomFromText('POINT(856371.58 6683083.41)', 3395)) < 1000;";
# my $distance="distance(way, GeomFromText('POINT(856371.58 6683083.41)', 3395))";
@@ -277,7 +277,7 @@ sub LoadOSM_segment_postgis($;$){
}
printf STDERR "---------------------------------------------------------------\n" if $DEBUG || $VERBOSE;
-
+
my $count=0;
my $count_read=0;
while ( @row = $sth->fetchrow_array ) {
@@ -359,7 +359,7 @@ my $from_node=0;
sub DoStart()
{
my ($Expat, $Name, %Attr) = @_;
-
+
if($Name eq "node"){
undef %Tags;
%MainAttr = %Attr;
@@ -389,7 +389,7 @@ sub DoStart()
my $to_node = $Attr{"ref"};
if ( $from_node &&
defined($Nodes{$from_node}) &&
- defined($Nodes{$to_node})
+ defined($Nodes{$to_node})
) {
my ($lat1,$lon1)=split(",",$Nodes{$from_node});
my ($lat2,$lon2)=split(",",$Nodes{$to_node});
@@ -407,12 +407,12 @@ sub DoStart()
sub DoEnd(){
my ($Expat, $Element) = @_;
my $ID = $MainAttr{"id"};
-
+
if($Element eq "node"){
my $node={};
$node->{"lat"} = $MainAttr{"lat"};
$node->{"lon"} = $MainAttr{"lon"};
-
+
if ( $AREA_FILTER->inside($node) ) {
$Nodes{$ID} = sprintf("%f,%f",$MainAttr{lat}, $MainAttr{lon});
foreach(keys(%Tags)){
@@ -452,16 +452,16 @@ sub read_osm_file($;$) { # Insert Segments from osm File
print("Reading OSM Segment from File $filename\n") if $VERBOSE || $DEBUG;
if ( file_needs_re_generation($filename,"$filename.storable")) {
print "$filename: ".(-s $filename)." Bytes\n" if $DEBUG;
-
+
print STDERR "Parsing file: $filename\n" if $DEBUG;
my $p = new XML::Parser( Handlers => {
- Start => \&DoStart,
- End => \&DoEnd,
+ Start => \&DoStart,
+ End => \&DoEnd,
Char => \&DoChar,
},
ErrorContext => 10,
);
-
+
my $fh = data_open($filename);
if (not $fh) {
print STDERR "WARNING: Could not open osm data from $filename\n";
@@ -476,7 +476,7 @@ sub read_osm_file($;$) { # Insert Segments from osm File
return;
}
#warn Dumper(\$read_osm_segments);
- Storable_save($filename,$read_osm_segments);
+ Storable_save($filename,$read_osm_segments);
} else {
$read_osm_segments=Storable_load($filename);
}
diff --git a/navit/script/osm/Geo/OSM/Tracks2OSM.pm b/navit/script/osm/Geo/OSM/Tracks2OSM.pm
index 4016f8c02..87302abc9 100644
--- a/navit/script/osm/Geo/OSM/Tracks2OSM.pm
+++ b/navit/script/osm/Geo/OSM/Tracks2OSM.pm
@@ -33,7 +33,7 @@ sub create_node($$) {
my $osm_nodes = shift;
my $elem = shift;
- printf STDERR "create_node(): lat or lon undefined : $elem->{lat},$elem->{lon} ".Dumper(\$elem)."\n"
+ printf STDERR "create_node(): lat or lon undefined : $elem->{lat},$elem->{lon} ".Dumper(\$elem)."\n"
unless defined($elem->{lat}) && defined($elem->{lon}) ;
my $id=0;
@@ -95,7 +95,7 @@ sub tracks2osm($){
};
for my $elem ( @{$track} ) {
my $node_id = $elem->{node_id} || create_node($osm_nodes,$elem);
-
+
# -------------------------------------------- Add to Way
push(@{$osm_ways->{$osm_way_number}->{nd}},$node_id);
$count_valid_points_for_ways++;
diff --git a/navit/script/osm/Geo/OSM/Upload.pm b/navit/script/osm/Geo/OSM/Upload.pm
index da18e97ec..7cd4de8cc 100644
--- a/navit/script/osm/Geo/OSM/Upload.pm
+++ b/navit/script/osm/Geo/OSM/Upload.pm
@@ -24,12 +24,12 @@ sub tempfiles(){
sub uploadWay(){
my ($self, $Tags, @Segments) = @_;
$Tags .= sprintf("<tag k=\"created_by\" v=\"%s\"/>", $self->{UserAgent});
-
+
my $Segments = "";
foreach $Segment(@Segments){
$Segments .= "<seg id=\"$Segment\"/>";
}
-
+
my $Way = "<way id=\"0\">$Segments$Tags</way>";
my $OSM = "<osm version=\"0.3\">$Way</osm>";
my $data = "<?xml version=\"1.0\"?>\n$OSM";
@@ -42,45 +42,45 @@ sub uploadWay(){
sub uploadSegment(){
my ($self, $Node1,$Node2,$Tags) = @_;
$Tags .= sprintf("<tag k=\"created_by\" v=\"%s\"/>", $self->{UserAgent});
-
+
my $Segment = sprintf("<segment id=\"0\" from=\"%d\" to=\"%d\">$Tags</segment>", $Node1,$Node2);
my $OSM = "<osm version=\"0.3\">$Segment</osm>";
my $data = "<?xml version=\"1.0\"?>\n$OSM";
my $path = "segment/0";
my ($response, $http_code) = $self->upload($data, $path);
-
-
+
+
return($response);
}
sub uploadNode(){
my ($self, $Lat, $Long, $Tags) = @_;
$Tags .= sprintf("<tag k=\"created_by\" v=\"%s\"/>", $self->{UserAgent});
-
+
my $Node = sprintf("<node id=\"0\" lon=\"%f\" lat=\"%f\">$Tags</node>", $Long, $Lat);
my $OSM = "<osm version=\"0.3\">$Node</osm>";
my $data = "<?xml version=\"1.0\"?>\n$OSM";
my $path = "node/0";
my ($response, $http_code) = $self->upload($data, $path);
-
+
return($response);
}
sub upload(){
my($self, $data, $path) = @_;
-
+
my $curl = new WWW::Curl::easy;
my $login = sprintf("%s:%s", $self->{Username}, $self->{Password});
-
+
open(my $FileToSend, ">", $self->{file1});
print $FileToSend $data;
close $FileToSend;
-
- my $url = "http://www.openstreetmap.org/api/0.3/$path";
-
+
+ my $url = "http://www.openstreetmap.org/api/0.3/$path";
+
open(my $TxFile, "<", $self->{file1});
open(my $RxFile, ">",$self->{file2});
$curl->setopt(CURLOPT_URL,$url);
@@ -91,20 +91,20 @@ sub upload(){
$curl->setopt(CURLOPT_INFILE,$TxFile);
$curl->setopt(CURLOPT_INFILESIZE, -s $self->{file1});
$curl->setopt(CURLOPT_FILE, $RxFile);
-
+
$curl->perform();
my $http_code = $curl->getinfo(CURLINFO_HTTP_CODE);
my $err = $curl->errbuf;
$curl->close();
close $TxFile;
close $RxFile;
-
+
open(my $ResponseFile, "<", $self->{file2});
my $response = int(<$ResponseFile>);
close $ResponseFile;
-
+
print "Code $http_code\n" if($http_code != 200);
-
+
return($response, $http_code);
}
diff --git a/navit/script/osm/Geo/OSM/Write.pm b/navit/script/osm/Geo/OSM/Write.pm
index 463c2d0cd..68c093b35 100644
--- a/navit/script/osm/Geo/OSM/Write.pm
+++ b/navit/script/osm/Geo/OSM/Write.pm
@@ -22,7 +22,7 @@ use Utils::Math;
# ------------------------------------------------------------------
sub tags2osm($){
my $obj = shift;
-
+
my $erg = "";
for my $k ( keys %{$obj->{tag}} ) {
my $v = $obj->{tag}{$k};
@@ -73,10 +73,10 @@ sub write_osm_file($$) { # Write an osm File
print $fh "<osm version=\'0.5\' generator=\'".$osm->{tool}."\'>\n";
if ( defined ( $osm->{bounds} ) ) {
my $bounds = $osm->{bounds};
- my $bounds_sting = "$bounds->{lat_min},$bounds->{lon_min},$bounds->{lat_max},$bounds->{lon_max}";
+ my $bounds_sting = "$bounds->{lat_min},$bounds->{lon_min},$bounds->{lat_max},$bounds->{lon_max}";
# -90,-180,90,180
print $fh " <bound box=\"$bounds_sting\" origin=\"OSM-perl-writer\" />\n";
-
+
}
# --- Nodes
@@ -90,9 +90,9 @@ sub write_osm_file($$) { # Write an osm File
next;
}
print $fh " <node id=\'$node_id\' ";
- print $fh " timestamp=\'".$node->{timestamp}."\' "
+ print $fh " timestamp=\'".$node->{timestamp}."\' "
if defined $node->{timestamp};
- print $fh " changeset=\'".$node->{changeset}."\' "
+ print $fh " changeset=\'".$node->{changeset}."\' "
if defined $node->{changeset};
print $fh " lat=\'$lat\' ";
print $fh " lon=\'$lon\' ";
@@ -109,10 +109,10 @@ sub write_osm_file($$) { # Write an osm File
next unless scalar( @{$way->{nd}} )>1;
print $fh " <way id=\'$way_id\'";
- print $fh " timestamp=\'".$way->{timestamp}."\'"
+ print $fh " timestamp=\'".$way->{timestamp}."\'"
if defined $way->{timestamp};
print $fh ">";
-
+
for my $way_nd ( @{$way->{nd}} ) {
next unless $way_nd;
print $fh " <nd ref=\'$way_nd\' />\n";
@@ -120,7 +120,7 @@ sub write_osm_file($$) { # Write an osm File
print $fh tags2osm($way);
print $fh " </way>\n";
$count_ways++;
-
+
}
print $fh "</osm>\n";
diff --git a/navit/script/osm/border_follower.pl b/navit/script/osm/border_follower.pl
index 3a5b31167..2ce699798 100755
--- a/navit/script/osm/border_follower.pl
+++ b/navit/script/osm/border_follower.pl
@@ -122,10 +122,10 @@ do {
}
}
if ($count == 0) {
- error "No connection"
- } else {
+ error "No connection"
+ } else {
if ($count > 1) {
- error "Multiple connections ($count)"
+ error "Multiple connections ($count)"
} else {
$path="$path $wayid";
}
diff --git a/navit/script/wiki2def b/navit/script/wiki2def
index bbbbb5ba2..901f6d05e 100755
--- a/navit/script/wiki2def
+++ b/navit/script/wiki2def
@@ -29,9 +29,9 @@ EOT
done
type="n"
wget -O - "http://wiki.navit-project.org/index.php/Item_def.h?action=edit" |
-awk '/<textarea/,/<\/textarea/ { print $0 }' |
+awk '/<textarea/,/<\/textarea/ { print $0 }' |
grep "^| " |
-sed -e 's/^| *//' -e 's/ *$//' -e 's/ *|/|/g' -e 's/| */|/g' -e 's/||/|/g' |
+sed -e 's/^| *//' -e 's/ *$//' -e 's/ *|/|/g' -e 's/| */|/g' -e 's/||/|/g' |
while read id item description osmtags dummy
do
if [[ "$id" == colspan=* ]]
diff --git a/navit/search.c b/navit/search.c
index 139feef58..c875f56b1 100644
--- a/navit/search.c
+++ b/navit/search.c
@@ -48,46 +48,42 @@ static void search_list_street_destroy(struct search_list_street *this_);
static void search_list_house_number_destroy(struct search_list_house_number *this_);
struct search_list_level {
- struct mapset *ms;
- struct search_list_common *parent;
- struct attr *attr;
- int partial;
- int selected;
- struct mapset_search *search;
- GHashTable *hash;
- GList *list,*curr,*last;
+ struct mapset *ms;
+ struct search_list_common *parent;
+ struct attr *attr;
+ int partial;
+ int selected;
+ struct mapset_search *search;
+ GHashTable *hash;
+ GList *list,*curr,*last;
};
struct search_list {
- struct mapset *ms;
- struct item *item;
- int level;
- struct search_list_level levels[4];
- struct search_list_result result;
- struct search_list_result last_result;
- int last_result_valid;
- char *postal;
- struct house_number_interpolation inter;
- int use_address_results;
- GList *address_results,*address_results_pos;
+ struct mapset *ms;
+ struct item *item;
+ int level;
+ struct search_list_level levels[4];
+ struct search_list_result result;
+ struct search_list_result last_result;
+ int last_result_valid;
+ char *postal;
+ struct house_number_interpolation inter;
+ int use_address_results;
+ GList *address_results,*address_results_pos;
};
-static guint
-search_item_hash_hash(gconstpointer key)
-{
- const struct item *itm=key;
- gconstpointer hashkey=(gconstpointer)GINT_TO_POINTER(itm->id_hi^itm->id_lo);
- return g_direct_hash(hashkey);
+static guint search_item_hash_hash(gconstpointer key) {
+ const struct item *itm=key;
+ gconstpointer hashkey=(gconstpointer)GINT_TO_POINTER(itm->id_hi^itm->id_lo);
+ return g_direct_hash(hashkey);
}
-static gboolean
-search_item_hash_equal(gconstpointer a, gconstpointer b)
-{
- const struct item *itm_a=a;
- const struct item *itm_b=b;
- if (item_is_equal_id(*itm_a, *itm_b))
- return TRUE;
- return FALSE;
+static gboolean search_item_hash_equal(gconstpointer a, gconstpointer b) {
+ const struct item *itm_a=a;
+ const struct item *itm_b=b;
+ if (item_is_equal_id(*itm_a, *itm_b))
+ return TRUE;
+ return FALSE;
}
/**
@@ -97,14 +93,13 @@ search_item_hash_equal(gconstpointer a, gconstpointer b)
* @returns new search_list
*/
struct search_list *
-search_list_new(struct mapset *ms)
-{
- struct search_list *ret;
+search_list_new(struct mapset *ms) {
+ struct search_list *ret;
- ret=g_new0(struct search_list, 1);
- ret->ms=ms;
+ ret=g_new0(struct search_list, 1);
+ ret->ms=ms;
- return ret;
+ return ret;
}
static void search_list_search_free(struct search_list *sl, int level);
@@ -114,226 +109,210 @@ static void search_list_search_free(struct search_list *sl, int level);
* @param attr_type attribute value
* @return corresponding search list level (country=0, town=1, ...)
*/
-int
-search_list_level(enum attr_type attr_type)
-{
- switch(attr_type) {
- case attr_country_all:
- case attr_country_id:
- case attr_country_iso2:
- case attr_country_iso3:
- case attr_country_car:
- case attr_country_name:
- return 0;
- case attr_town_postal:
- return 1;
- case attr_town_name:
- case attr_district_name:
- case attr_town_or_district_name:
- return 1;
- case attr_street_name:
- return 2;
- case attr_house_number:
- return 3;
- case attr_postal:
- return -1;
- default:
- dbg(lvl_error,"unknown search '%s'\n",attr_to_name(attr_type));
- return -1;
- }
-}
-
-static char *
-search_fix_spaces(char *str)
-{
- int i;
- int len=strlen(str);
- char c,*s,*d,*ret=g_strdup(str);
-
- for (i = 0 ; i < len ; i++) {
- if (ret[i] == ',' || ret[i] == ',' || ret[i] == '/')
- ret[i]=' ';
- }
- s=ret;
- d=ret;
- len=0;
- do {
- c=*s++;
- if (c != ' ' || len != 0) {
- *d++=c;
- len++;
- }
- while (c == ' ' && *s == ' ')
- s++;
- if (c == ' ' && *s == '\0') {
- d--;
- len--;
- }
- } while (c);
- return ret;
+int search_list_level(enum attr_type attr_type) {
+ switch(attr_type) {
+ case attr_country_all:
+ case attr_country_id:
+ case attr_country_iso2:
+ case attr_country_iso3:
+ case attr_country_car:
+ case attr_country_name:
+ return 0;
+ case attr_town_postal:
+ return 1;
+ case attr_town_name:
+ case attr_district_name:
+ case attr_town_or_district_name:
+ return 1;
+ case attr_street_name:
+ return 2;
+ case attr_house_number:
+ return 3;
+ case attr_postal:
+ return -1;
+ default:
+ dbg(lvl_error,"unknown search '%s'",attr_to_name(attr_type));
+ return -1;
+ }
+}
+
+static char *search_fix_spaces(char *str) {
+ int i;
+ int len=strlen(str);
+ char c,*s,*d,*ret=g_strdup(str);
+
+ for (i = 0 ; i < len ; i++) {
+ if (ret[i] == ',' || ret[i] == ',' || ret[i] == '/')
+ ret[i]=' ';
+ }
+ s=ret;
+ d=ret;
+ len=0;
+ do {
+ c=*s++;
+ if (c != ' ' || len != 0) {
+ *d++=c;
+ len++;
+ }
+ while (c == ' ' && *s == ' ')
+ s++;
+ if (c == ' ' && *s == '\0') {
+ d--;
+ len--;
+ }
+ } while (c);
+ return ret;
}
struct phrase {
- char *start;
- char *end;
- int wordcount;
+ char *start;
+ char *end;
+ int wordcount;
};
-static GList *
-search_split_phrases(char *str)
-{
- char *s,*d;
- int wordcount=0;
- GList *ret=NULL;
- s=str;
- do {
- d=s;
- wordcount=0;
- do {
- d++;
- if (*d == ' ' || *d == '\0') {
- struct phrase *phrase=g_new(struct phrase, 1);
- phrase->start=s;
- phrase->end=d;
- phrase->wordcount=++wordcount;
- ret=g_list_append(ret, phrase);
- }
- } while (*d != '\0');
- do {
- s++;
- if (*s == ' ') {
- s++;
- break;
- }
- } while (*s != '\0');
- } while (*s != '\0');
- return ret;
-}
-
-static char *
-search_phrase_str(struct phrase *p)
-{
- int len=p->end-p->start;
- char *ret=g_malloc(len+1);
- strncpy(ret, p->start, len);
- ret[len]='\0';
- return ret;
-}
-
-static int
-search_phrase_used(struct phrase *p, GList *used_phrases)
-{
- while (used_phrases) {
- struct phrase *pu=used_phrases->data;
- dbg(lvl_debug,"'%s'-'%s' vs '%s'-'%s'\n",p->start,p->end,pu->start,pu->end);
- if (p->start < pu->end && p->end > pu->start)
- return 1;
- dbg(lvl_debug,"unused\n");
- used_phrases=g_list_next(used_phrases);
- }
- return 0;
-}
-
-static gint
-search_by_address_compare(gconstpointer a, gconstpointer b)
-{
- const struct search_list_result *slra=a;
- const struct search_list_result *slrb=b;
- return slrb->id-slra->id;
-}
-
-
-static GList *
-search_by_address_attr(GList *results, struct search_list *sl, GList *phrases, GList *exclude, enum attr_type attr_type, int wordcount)
-{
- GList *tmp=phrases;
- struct attr attr;
- attr.type=attr_type;
- while (tmp) {
- if (!search_phrase_used(tmp->data, exclude)) {
- struct phrase *p=tmp->data;
- int count=0,wordcount_all=wordcount+p->wordcount;
- struct search_list_result *slr;
- attr.u.str=search_phrase_str(p);
- dbg(lvl_debug,"%s phrase '%s'\n",attr_to_name(attr_type),attr.u.str);
- search_list_search(sl, &attr, 0);
- while ((slr=search_list_get_result(sl))) {
- if (attr_type != attr_country_all) {
- struct search_list_result *slrd=search_list_result_dup(slr);
- slrd->id=wordcount_all;
- results=g_list_insert_sorted(results, slrd, search_by_address_compare);
- }
- count++;
- }
- dbg(lvl_debug,"%d results wordcount %d\n",count,wordcount_all);
- if (count) {
- GList *used=g_list_prepend(g_list_copy(exclude), tmp->data);
- enum attr_type new_attr_type=attr_none;
- switch (attr_type) {
- case attr_country_all:
- new_attr_type=attr_town_or_district_name;
- break;
- case attr_town_or_district_name:
- new_attr_type=attr_street_name;
- break;
- case attr_street_name:
- new_attr_type=attr_house_number;
- break;
- default:
- break;
- }
- if (new_attr_type != attr_none)
- results=search_by_address_attr(results, sl, phrases, used, new_attr_type, wordcount_all);
- g_list_free(used);
- }
- g_free(attr.u.str);
- }
- tmp=g_list_next(tmp);
- }
- return results;
-}
-
-static void
-search_by_address(struct search_list *this_, char *addr)
-{
- char *str=search_fix_spaces(addr);
- GList *tmp,*phrases=search_split_phrases(str);
- struct search_list *sl=search_list_new(this_->ms);
- this_->address_results=search_by_address_attr(NULL, sl, phrases, NULL, attr_country_all, 0);
- this_->address_results_pos=this_->address_results;
- search_list_destroy(sl);
- tmp=phrases;
- while (tmp) {
- g_free(tmp->data);
- tmp=g_list_next(tmp);
- }
- g_list_free(phrases);
- // TODO: Looks like we should g_free(str) here. But this is
- // currently dead code, so no way to test it.
-}
-
-static void
-search_address_results_free(struct search_list *this_)
-{
- GList *tmp;
- tmp=this_->address_results;
- while (tmp) {
- struct search_list_result *slr=tmp->data;
- if (slr->country)
- search_list_country_destroy(slr->country);
- if (slr->town)
- search_list_town_destroy(slr->town);
- if (slr->street)
- search_list_street_destroy(slr->street);
- if (slr->house_number)
- search_list_house_number_destroy(slr->house_number);
- if (slr->c)
- g_free(slr->c);
- g_free(slr);
- tmp=g_list_next(tmp);
- }
- g_list_free(this_->address_results);
- this_->address_results=this_->address_results_pos=NULL;
+static GList *search_split_phrases(char *str) {
+ char *s,*d;
+ int wordcount=0;
+ GList *ret=NULL;
+ s=str;
+ do {
+ d=s;
+ wordcount=0;
+ do {
+ d++;
+ if (*d == ' ' || *d == '\0') {
+ struct phrase *phrase=g_new(struct phrase, 1);
+ phrase->start=s;
+ phrase->end=d;
+ phrase->wordcount=++wordcount;
+ ret=g_list_append(ret, phrase);
+ }
+ } while (*d != '\0');
+ do {
+ s++;
+ if (*s == ' ') {
+ s++;
+ break;
+ }
+ } while (*s != '\0');
+ } while (*s != '\0');
+ return ret;
+}
+
+static char *search_phrase_str(struct phrase *p) {
+ int len=p->end-p->start;
+ char *ret=g_malloc(len+1);
+ strncpy(ret, p->start, len);
+ ret[len]='\0';
+ return ret;
+}
+
+static int search_phrase_used(struct phrase *p, GList *used_phrases) {
+ while (used_phrases) {
+ struct phrase *pu=used_phrases->data;
+ dbg(lvl_debug,"'%s'-'%s' vs '%s'-'%s'",p->start,p->end,pu->start,pu->end);
+ if (p->start < pu->end && p->end > pu->start)
+ return 1;
+ dbg(lvl_debug,"unused");
+ used_phrases=g_list_next(used_phrases);
+ }
+ return 0;
+}
+
+static gint search_by_address_compare(gconstpointer a, gconstpointer b) {
+ const struct search_list_result *slra=a;
+ const struct search_list_result *slrb=b;
+ return slrb->id-slra->id;
+}
+
+
+static GList *search_by_address_attr(GList *results, struct search_list *sl, GList *phrases, GList *exclude,
+ enum attr_type attr_type,
+ int wordcount) {
+ GList *tmp=phrases;
+ struct attr attr;
+ attr.type=attr_type;
+ while (tmp) {
+ if (!search_phrase_used(tmp->data, exclude)) {
+ struct phrase *p=tmp->data;
+ int count=0,wordcount_all=wordcount+p->wordcount;
+ struct search_list_result *slr;
+ attr.u.str=search_phrase_str(p);
+ dbg(lvl_debug,"%s phrase '%s'",attr_to_name(attr_type),attr.u.str);
+ search_list_search(sl, &attr, 0);
+ while ((slr=search_list_get_result(sl))) {
+ if (attr_type != attr_country_all) {
+ struct search_list_result *slrd=search_list_result_dup(slr);
+ slrd->id=wordcount_all;
+ results=g_list_insert_sorted(results, slrd, search_by_address_compare);
+ }
+ count++;
+ }
+ dbg(lvl_debug,"%d results wordcount %d",count,wordcount_all);
+ if (count) {
+ GList *used=g_list_prepend(g_list_copy(exclude), tmp->data);
+ enum attr_type new_attr_type=attr_none;
+ switch (attr_type) {
+ case attr_country_all:
+ new_attr_type=attr_town_or_district_name;
+ break;
+ case attr_town_or_district_name:
+ new_attr_type=attr_street_name;
+ break;
+ case attr_street_name:
+ new_attr_type=attr_house_number;
+ break;
+ default:
+ break;
+ }
+ if (new_attr_type != attr_none)
+ results=search_by_address_attr(results, sl, phrases, used, new_attr_type, wordcount_all);
+ g_list_free(used);
+ }
+ g_free(attr.u.str);
+ }
+ tmp=g_list_next(tmp);
+ }
+ return results;
+}
+
+static void search_by_address(struct search_list *this_, char *addr) {
+ char *str=search_fix_spaces(addr);
+ GList *tmp,*phrases=search_split_phrases(str);
+ struct search_list *sl=search_list_new(this_->ms);
+ this_->address_results=search_by_address_attr(NULL, sl, phrases, NULL, attr_country_all, 0);
+ this_->address_results_pos=this_->address_results;
+ search_list_destroy(sl);
+ tmp=phrases;
+ while (tmp) {
+ g_free(tmp->data);
+ tmp=g_list_next(tmp);
+ }
+ g_list_free(phrases);
+ // TODO: Looks like we should g_free(str) here. But this is
+ // currently dead code, so no way to test it.
+}
+
+static void search_address_results_free(struct search_list *this_) {
+ GList *tmp;
+ tmp=this_->address_results;
+ while (tmp) {
+ struct search_list_result *slr=tmp->data;
+ if (slr->country)
+ search_list_country_destroy(slr->country);
+ if (slr->town)
+ search_list_town_destroy(slr->town);
+ if (slr->street)
+ search_list_street_destroy(slr->street);
+ if (slr->house_number)
+ search_list_house_number_destroy(slr->house_number);
+ if (slr->c)
+ g_free(slr->c);
+ g_free(slr);
+ tmp=g_list_next(tmp);
+ }
+ g_list_free(this_->address_results);
+ this_->address_results=this_->address_results_pos=NULL;
}
/**
@@ -343,499 +322,450 @@ search_address_results_free(struct search_list *this_)
* @param search_attr attributes to use for the search
* @param partial do partial search? (1=yes,0=no)
*/
-void
-search_list_search(struct search_list *this_, struct attr *search_attr, int partial)
-{
- struct search_list_level *le;
- int level;
- dbg(lvl_info,"Starting search for '=%s' of type %s\n", search_attr->u.str, attr_to_name(search_attr->type));
- search_address_results_free(this_);
- if (search_attr->type == attr_address) {
- search_by_address(this_, search_attr->u.str);
- this_->use_address_results=1;
- return;
- }
- this_->use_address_results=0;
- level=search_list_level(search_attr->type);
- this_->item=NULL;
- house_number_interpolation_clear_all(&this_->inter);
- if (level != -1) {
- this_->result.id=0;
- this_->level=level;
- le=&this_->levels[level];
- search_list_search_free(this_, level);
- le->attr=attr_dup(search_attr);
- le->partial=partial;
- if (level > 0) {
- le=&this_->levels[level-1];
- le->curr=le->list;
- }
- } else if (search_attr->type == attr_postal) {
- g_free(this_->postal);
- this_->postal=g_strdup(search_attr->u.str);
- }
+void search_list_search(struct search_list *this_, struct attr *search_attr, int partial) {
+ struct search_list_level *le;
+ int level;
+ dbg(lvl_info,"Starting search for '=%s' of type %s", search_attr->u.str, attr_to_name(search_attr->type));
+ search_address_results_free(this_);
+ if (search_attr->type == attr_address) {
+ search_by_address(this_, search_attr->u.str);
+ this_->use_address_results=1;
+ return;
+ }
+ this_->use_address_results=0;
+ level=search_list_level(search_attr->type);
+ this_->item=NULL;
+ house_number_interpolation_clear_all(&this_->inter);
+ if (level != -1) {
+ this_->result.id=0;
+ this_->level=level;
+ le=&this_->levels[level];
+ search_list_search_free(this_, level);
+ le->attr=attr_dup(search_attr);
+ le->partial=partial;
+ if (level > 0) {
+ le=&this_->levels[level-1];
+ le->curr=le->list;
+ }
+ } else if (search_attr->type == attr_postal) {
+ g_free(this_->postal);
+ this_->postal=g_strdup(search_attr->u.str);
+ }
}
struct search_list_common *
-search_list_select(struct search_list *this_, enum attr_type attr_type, int id, int mode)
-{
- int level;
- int num;
- struct search_list_level *le;
- struct search_list_common *slc;
- GList *curr;
-
- level = search_list_level(attr_type);
- if (level < 0)
- return NULL;
- le=&this_->levels[level];
- curr=le->list;
- if (mode > 0 || !id)
- le->selected=mode;
- //dbg(lvl_debug,"enter level=%d %d %d %p\n", level, id, mode, curr);
- num = 0;
- while (curr) {
- num++;
- if (! id || num == id) {
- slc=curr->data;
- slc->selected=mode;
- if (id) {
- le->last=curr;
- //dbg(lvl_debug,"found\n");
- return slc;
- }
- }
- curr=g_list_next(curr);
- }
- //dbg(lvl_debug,"not found\n");
- return NULL;
-}
-
-static void
-search_list_common_addattr(struct attr* attr,struct search_list_common *common)
-{
-
- common->attrs=attr_generic_prepend_attr(common->attrs,attr);
- switch(attr->type) {
- case attr_town_name:
- common->town_name=common->attrs[0]->u.str;
- break;
- case attr_county_name:
- common->county_name=common->attrs[0]->u.str;
- break;
- case attr_district_name:
- common->district_name=common->attrs[0]->u.str;
- break;
- case attr_postal:
- common->postal=common->attrs[0]->u.str;
- break;
- case attr_town_postal:
- if(!common->postal)
- common->postal=common->attrs[0]->u.str;
- break;
- case attr_postal_mask:
- common->postal_mask=common->attrs[0]->u.str;
- break;
- default:
- break;
- }
-}
-
-static void
-search_list_common_new(struct item *item, struct search_list_common *common)
-{
- struct attr attr;
- int i;
- enum attr_type common_attrs[]={
- attr_state_name,
- attr_county_name,
- attr_municipality_name,
- attr_town_name,
- attr_district_name,
- attr_postal,
- attr_town_postal,
- attr_postal_mask,
- attr_none
- };
-
- common->town_name=NULL;
- common->district_name=NULL;
- common->county_name=NULL;
- common->postal=NULL;
- common->postal_mask=NULL;
- common->attrs=NULL;
-
- for(i=0;common_attrs[i];i++) {
- if (item_attr_get(item, common_attrs[i], &attr)) {
- struct attr at;
- at.type=attr.type;
- at.u.str=map_convert_string(item->map, attr.u.str);
- search_list_common_addattr(&at,common);
- map_convert_free(at.u.str);
- }
- }
-}
-
-static void
-search_list_common_dup(struct search_list_common *src, struct search_list_common *dst)
-{
- int i;
-
- if(dst->attrs) {
- for(i=0;dst->attrs[i];i++)
- search_list_common_addattr(src->attrs[i],dst);
- }
-
- if (src->c) {
- dst->c=g_new(struct pcoord, 1);
- *dst->c=*src->c;
- } else
- dst->c=NULL;
-}
-
-static void
-search_list_common_destroy(struct search_list_common *common)
-{
- g_free(common->c);
- attr_list_free(common->attrs);
-
- common->town_name=NULL;
- common->district_name=NULL;
- common->county_name=NULL;
- common->postal=NULL;
- common->postal_mask=NULL;
- common->c=NULL;
- common->attrs=NULL;
-}
-
-static struct search_list_country *
-search_list_country_new(struct item *item)
-{
- struct search_list_country *ret=g_new0(struct search_list_country, 1);
- struct attr attr;
-
- ret->common.item=ret->common.unique=*item;
- if (item_attr_get(item, attr_country_car, &attr))
- ret->car=g_strdup(attr.u.str);
- if (item_attr_get(item, attr_country_iso2, &attr)) {
+search_list_select(struct search_list *this_, enum attr_type attr_type, int id, int mode) {
+ int level;
+ int num;
+ struct search_list_level *le;
+ struct search_list_common *slc;
+ GList *curr;
+
+ level = search_list_level(attr_type);
+ if (level < 0)
+ return NULL;
+ le=&this_->levels[level];
+ curr=le->list;
+ if (mode > 0 || !id)
+ le->selected=mode;
+ //dbg(lvl_debug,"enter level=%d %d %d %p", level, id, mode, curr);
+ num = 0;
+ while (curr) {
+ num++;
+ if (! id || num == id) {
+ slc=curr->data;
+ slc->selected=mode;
+ if (id) {
+ le->last=curr;
+ //dbg(lvl_debug,"found");
+ return slc;
+ }
+ }
+ curr=g_list_next(curr);
+ }
+ //dbg(lvl_debug,"not found");
+ return NULL;
+}
+
+static void search_list_common_addattr(struct attr* attr,struct search_list_common *common) {
+
+ common->attrs=attr_generic_prepend_attr(common->attrs,attr);
+ switch(attr->type) {
+ case attr_town_name:
+ common->town_name=common->attrs[0]->u.str;
+ break;
+ case attr_county_name:
+ common->county_name=common->attrs[0]->u.str;
+ break;
+ case attr_district_name:
+ common->district_name=common->attrs[0]->u.str;
+ break;
+ case attr_postal:
+ common->postal=common->attrs[0]->u.str;
+ break;
+ case attr_town_postal:
+ if(!common->postal)
+ common->postal=common->attrs[0]->u.str;
+ break;
+ case attr_postal_mask:
+ common->postal_mask=common->attrs[0]->u.str;
+ break;
+ default:
+ break;
+ }
+}
+
+static void search_list_common_new(struct item *item, struct search_list_common *common) {
+ struct attr attr;
+ int i;
+ enum attr_type common_attrs[]= {
+ attr_state_name,
+ attr_county_name,
+ attr_municipality_name,
+ attr_town_name,
+ attr_district_name,
+ attr_postal,
+ attr_town_postal,
+ attr_postal_mask,
+ attr_none
+ };
+
+ common->town_name=NULL;
+ common->district_name=NULL;
+ common->county_name=NULL;
+ common->postal=NULL;
+ common->postal_mask=NULL;
+ common->attrs=NULL;
+
+ for(i=0; common_attrs[i]; i++) {
+ if (item_attr_get(item, common_attrs[i], &attr)) {
+ struct attr at;
+ at.type=attr.type;
+ at.u.str=map_convert_string(item->map, attr.u.str);
+ search_list_common_addattr(&at,common);
+ map_convert_free(at.u.str);
+ }
+ }
+}
+
+static void search_list_common_dup(struct search_list_common *src, struct search_list_common *dst) {
+ int i;
+
+ if(dst->attrs) {
+ for(i=0; dst->attrs[i]; i++)
+ search_list_common_addattr(src->attrs[i],dst);
+ }
+
+ if (src->c) {
+ dst->c=g_new(struct pcoord, 1);
+ *dst->c=*src->c;
+ } else
+ dst->c=NULL;
+}
+
+static void search_list_common_destroy(struct search_list_common *common) {
+ g_free(common->c);
+ attr_list_free(common->attrs);
+
+ common->town_name=NULL;
+ common->district_name=NULL;
+ common->county_name=NULL;
+ common->postal=NULL;
+ common->postal_mask=NULL;
+ common->c=NULL;
+ common->attrs=NULL;
+}
+
+static struct search_list_country *search_list_country_new(struct item *item) {
+ struct search_list_country *ret=g_new0(struct search_list_country, 1);
+ struct attr attr;
+
+ ret->common.item=ret->common.unique=*item;
+ if (item_attr_get(item, attr_country_car, &attr))
+ ret->car=g_strdup(attr.u.str);
+ if (item_attr_get(item, attr_country_iso2, &attr)) {
#ifdef HAVE_API_ANDROID
- ret->iso2=g_malloc(strlen(attr.u.str)+1);
- strtolower(ret->iso2, attr.u.str);
+ ret->iso2=g_malloc(strlen(attr.u.str)+1);
+ strtolower(ret->iso2, attr.u.str);
#else
- ret->iso2=g_strdup(attr.u.str);
+ ret->iso2=g_strdup(attr.u.str);
#endif
- ret->flag=g_strdup_printf("country_%s", ret->iso2);
- }
- if (item_attr_get(item, attr_country_iso3, &attr))
- ret->iso3=g_strdup(attr.u.str);
- if (item_attr_get(item, attr_country_name, &attr))
- ret->name=g_strdup(attr.u.str);
- return ret;
-}
-
-static struct search_list_country *
-search_list_country_dup(struct search_list_country *this_)
-{
- struct search_list_country *ret=g_new(struct search_list_country, 1);
- ret->car=g_strdup(this_->car);
- ret->iso2=g_strdup(this_->iso2);
- ret->iso3=g_strdup(this_->iso3);
- ret->flag=g_strdup(this_->flag);
- ret->name=g_strdup(this_->name);
- return ret;
-}
-
-static void
-search_list_country_destroy(struct search_list_country *this_)
-{
- g_free(this_->car);
- g_free(this_->iso2);
- g_free(this_->iso3);
- g_free(this_->flag);
- g_free(this_->name);
- g_free(this_);
-}
-
-static struct search_list_town *
-search_list_town_new(struct item *item)
-{
- struct search_list_town *ret=g_new0(struct search_list_town, 1);
- struct attr attr;
- struct coord c;
-
- ret->itemt=*item;
- ret->common.item=ret->common.unique=*item;
- if (item_attr_get(item, attr_town_streets_item, &attr)) {
- dbg(lvl_debug,"town_assoc 0x%x 0x%x\n", attr.u.item->id_hi, attr.u.item->id_lo);
- ret->common.unique=*attr.u.item;
- }
- search_list_common_new(item, &ret->common);
- if (item_attr_get(item, attr_county_name, &attr))
- ret->county=map_convert_string(item->map,attr.u.str);
- else
- ret->county=NULL;
- if (item_coord_get(item, &c, 1)) {
- ret->common.c=g_new(struct pcoord, 1);
- ret->common.c->x=c.x;
- ret->common.c->y=c.y;
- ret->common.c->pro = map_projection(item->map);
- }
- return ret;
-}
-
-static struct search_list_town *
-search_list_town_dup(struct search_list_town *this_)
-{
- struct search_list_town *ret=g_new0(struct search_list_town, 1);
- ret->county=map_convert_dup(this_->county);
- search_list_common_dup(&this_->common, &ret->common);
- return ret;
-}
-
-static void
-search_list_town_destroy(struct search_list_town *this_)
-{
- map_convert_free(this_->county);
- search_list_common_destroy(&this_->common);
- g_free(this_);
-}
-
-
-static struct search_list_street *
-search_list_street_new(struct item *item)
-{
- struct search_list_street *ret=g_new0(struct search_list_street, 1);
- struct attr attr;
- struct coord p[1024];
- struct coord c;
- int count;
-
- ret->common.item=ret->common.unique=*item;
- if (item_attr_get(item, attr_street_name, &attr))
- ret->name=map_convert_string(item->map, attr.u.str);
- else
- ret->name=NULL;
- search_list_common_new(item, &ret->common);
- count=item_coord_get(item, p, sizeof(p)/sizeof(*p));
- if (count) {
- geom_line_middle(p,count,&c);
- ret->common.c=g_new(struct pcoord, 1);
- ret->common.c->x=c.x;
- ret->common.c->y=c.y;
- ret->common.c->pro = map_projection(item->map);
- }
- return ret;
-}
-
-static struct search_list_street *
-search_list_street_dup(struct search_list_street *this_)
-{
- struct search_list_street *ret=g_new0(struct search_list_street, 1);
- ret->name=map_convert_dup(this_->name);
- search_list_common_dup(&this_->common, &ret->common);
- return ret;
-}
-
-static void
-search_list_street_destroy(struct search_list_street *this_)
-{
- map_convert_free(this_->name);
- search_list_common_destroy(&this_->common);
- g_free(this_);
-}
-
-static struct search_list_house_number *
-search_list_house_number_new(struct item *item, struct house_number_interpolation *inter, char *inter_match, int inter_partial)
-{
- struct search_list_house_number *ret=g_new0(struct search_list_house_number, 1);
- struct attr attr;
- char *house_number=NULL;
-
- ret->common.item=ret->common.unique=*item;
- if (item_attr_get(item, attr_house_number, &attr)) {
- house_number=attr.u.str;
- } else {
- ret->house_number_interpolation=1;
- memset(&ret->common.unique, 0, sizeof(ret->common.unique));
- house_number=search_next_interpolated_house_number(item, inter, inter_match, inter_partial);
- }
- if (!house_number) {
- g_free(ret);
- return NULL;
- }
- ret->house_number=map_convert_string(item->map, house_number);
- search_list_common_new(item, &ret->common);
- ret->common.c=search_house_number_coordinate(item, ret->house_number_interpolation?inter:NULL);
- return ret;
-}
-
-static struct search_list_house_number *
-search_list_house_number_dup(struct search_list_house_number *this_)
-{
- struct search_list_house_number *ret=g_new0(struct search_list_house_number, 1);
- ret->house_number=map_convert_dup(this_->house_number);
- search_list_common_dup(&this_->common, &ret->common);
- return ret;
-}
-
-static void
-search_list_house_number_destroy(struct search_list_house_number *this_)
-{
- map_convert_free(this_->house_number);
- search_list_common_destroy(&this_->common);
- g_free(this_);
-}
-
-static void
-search_list_result_destroy(int level, void *p)
-{
- switch (level) {
- case 0:
- search_list_country_destroy(p);
- break;
- case 1:
- search_list_town_destroy(p);
- break;
- case 2:
- search_list_street_destroy(p);
- break;
- case 3:
- search_list_house_number_destroy(p);
- break;
- }
-}
-
-static struct search_list_result *
-search_list_result_dup(struct search_list_result *slr)
-{
- struct search_list_result *ret=g_new0(struct search_list_result, 1);
- ret->id=slr->id;
- if (slr->c) {
- ret->c=g_new(struct pcoord, 1);
- *ret->c=*slr->c;
- }
- if (slr->country)
- ret->country=search_list_country_dup(slr->country);
- if (slr->town)
- ret->town=search_list_town_dup(slr->town);
- if (slr->street)
- ret->street=search_list_street_dup(slr->street);
- if (slr->house_number)
- ret->house_number=search_list_house_number_dup(slr->house_number);
- return ret;
-}
-
-static void
-search_list_search_free(struct search_list *sl, int level)
-{
- struct search_list_level *le=&sl->levels[level];
- GList *next,*curr;
- if (le->search)
- {
- mapset_search_destroy(le->search);
- le->search=NULL;
- }
+ ret->flag=g_strdup_printf("country_%s", ret->iso2);
+ }
+ if (item_attr_get(item, attr_country_iso3, &attr))
+ ret->iso3=g_strdup(attr.u.str);
+ if (item_attr_get(item, attr_country_name, &attr))
+ ret->name=g_strdup(attr.u.str);
+ return ret;
+}
+
+static struct search_list_country *search_list_country_dup(struct search_list_country *this_) {
+ struct search_list_country *ret=g_new(struct search_list_country, 1);
+ ret->car=g_strdup(this_->car);
+ ret->iso2=g_strdup(this_->iso2);
+ ret->iso3=g_strdup(this_->iso3);
+ ret->flag=g_strdup(this_->flag);
+ ret->name=g_strdup(this_->name);
+ return ret;
+}
+
+static void search_list_country_destroy(struct search_list_country *this_) {
+ g_free(this_->car);
+ g_free(this_->iso2);
+ g_free(this_->iso3);
+ g_free(this_->flag);
+ g_free(this_->name);
+ g_free(this_);
+}
+
+static struct search_list_town *search_list_town_new(struct item *item) {
+ struct search_list_town *ret=g_new0(struct search_list_town, 1);
+ struct attr attr;
+ struct coord c;
+
+ ret->itemt=*item;
+ ret->common.item=ret->common.unique=*item;
+ if (item_attr_get(item, attr_town_streets_item, &attr)) {
+ dbg(lvl_debug,"town_assoc 0x%x 0x%x", attr.u.item->id_hi, attr.u.item->id_lo);
+ ret->common.unique=*attr.u.item;
+ }
+ search_list_common_new(item, &ret->common);
+ if (item_attr_get(item, attr_county_name, &attr))
+ ret->county=map_convert_string(item->map,attr.u.str);
+ else
+ ret->county=NULL;
+ if (item_coord_get(item, &c, 1)) {
+ ret->common.c=g_new(struct pcoord, 1);
+ ret->common.c->x=c.x;
+ ret->common.c->y=c.y;
+ ret->common.c->pro = map_projection(item->map);
+ }
+ return ret;
+}
+
+static struct search_list_town *search_list_town_dup(struct search_list_town *this_) {
+ struct search_list_town *ret=g_new0(struct search_list_town, 1);
+ ret->county=map_convert_dup(this_->county);
+ search_list_common_dup(&this_->common, &ret->common);
+ return ret;
+}
+
+static void search_list_town_destroy(struct search_list_town *this_) {
+ map_convert_free(this_->county);
+ search_list_common_destroy(&this_->common);
+ g_free(this_);
+}
+
+
+static struct search_list_street *search_list_street_new(struct item *item) {
+ struct search_list_street *ret=g_new0(struct search_list_street, 1);
+ struct attr attr;
+ struct coord p[1024];
+ struct coord c;
+ int count;
+
+ ret->common.item=ret->common.unique=*item;
+ if (item_attr_get(item, attr_street_name, &attr))
+ ret->name=map_convert_string(item->map, attr.u.str);
+ else
+ ret->name=NULL;
+ search_list_common_new(item, &ret->common);
+ count=item_coord_get(item, p, sizeof(p)/sizeof(*p));
+ if (count) {
+ geom_line_middle(p,count,&c);
+ ret->common.c=g_new(struct pcoord, 1);
+ ret->common.c->x=c.x;
+ ret->common.c->y=c.y;
+ ret->common.c->pro = map_projection(item->map);
+ }
+ return ret;
+}
+
+static struct search_list_street *search_list_street_dup(struct search_list_street *this_) {
+ struct search_list_street *ret=g_new0(struct search_list_street, 1);
+ ret->name=map_convert_dup(this_->name);
+ search_list_common_dup(&this_->common, &ret->common);
+ return ret;
+}
+
+static void search_list_street_destroy(struct search_list_street *this_) {
+ map_convert_free(this_->name);
+ search_list_common_destroy(&this_->common);
+ g_free(this_);
+}
+
+static struct search_list_house_number *search_list_house_number_new(struct item *item,
+ struct house_number_interpolation *inter, char *inter_match,
+ int inter_partial) {
+ struct search_list_house_number *ret=g_new0(struct search_list_house_number, 1);
+ struct attr attr;
+ char *house_number=NULL;
+
+ ret->common.item=ret->common.unique=*item;
+ if (item_attr_get(item, attr_house_number, &attr)) {
+ house_number=attr.u.str;
+ } else {
+ ret->house_number_interpolation=1;
+ memset(&ret->common.unique, 0, sizeof(ret->common.unique));
+ house_number=search_next_interpolated_house_number(item, inter, inter_match, inter_partial);
+ }
+ if (!house_number) {
+ g_free(ret);
+ return NULL;
+ }
+ ret->house_number=map_convert_string(item->map, house_number);
+ search_list_common_new(item, &ret->common);
+ ret->common.c=search_house_number_coordinate(item, ret->house_number_interpolation?inter:NULL);
+ return ret;
+}
+
+static struct search_list_house_number *search_list_house_number_dup(struct search_list_house_number *this_) {
+ struct search_list_house_number *ret=g_new0(struct search_list_house_number, 1);
+ ret->house_number=map_convert_dup(this_->house_number);
+ search_list_common_dup(&this_->common, &ret->common);
+ return ret;
+}
+
+static void search_list_house_number_destroy(struct search_list_house_number *this_) {
+ map_convert_free(this_->house_number);
+ search_list_common_destroy(&this_->common);
+ g_free(this_);
+}
+
+static void search_list_result_destroy(int level, void *p) {
+ switch (level) {
+ case 0:
+ search_list_country_destroy(p);
+ break;
+ case 1:
+ search_list_town_destroy(p);
+ break;
+ case 2:
+ search_list_street_destroy(p);
+ break;
+ case 3:
+ search_list_house_number_destroy(p);
+ break;
+ }
+}
+
+static struct search_list_result *search_list_result_dup(struct search_list_result *slr) {
+ struct search_list_result *ret=g_new0(struct search_list_result, 1);
+ ret->id=slr->id;
+ if (slr->c) {
+ ret->c=g_new(struct pcoord, 1);
+ *ret->c=*slr->c;
+ }
+ if (slr->country)
+ ret->country=search_list_country_dup(slr->country);
+ if (slr->town)
+ ret->town=search_list_town_dup(slr->town);
+ if (slr->street)
+ ret->street=search_list_street_dup(slr->street);
+ if (slr->house_number)
+ ret->house_number=search_list_house_number_dup(slr->house_number);
+ return ret;
+}
+
+static void search_list_search_free(struct search_list *sl, int level) {
+ struct search_list_level *le=&sl->levels[level];
+ GList *next,*curr;
+ if (le->search) {
+ mapset_search_destroy(le->search);
+ le->search=NULL;
+ }
#if 0 /* FIXME */
- if (le->hash) {
- g_hash_table_destroy(le->hash);
- le->hash=NULL;
- }
+ if (le->hash) {
+ g_hash_table_destroy(le->hash);
+ le->hash=NULL;
+ }
#endif
- curr=le->list;
- while (curr)
- {
- search_list_result_destroy(level, curr->data);
- next=g_list_next(curr);
- curr=next;
- }
- attr_free(le->attr);
- g_list_free(le->list);
- le->list=NULL;
- le->curr=NULL;
- le->last=NULL;
-}
-
-char *
-search_postal_merge(char *mask, char *new)
-{
- int i;
- char *ret=NULL;
- dbg(lvl_debug,"enter %s %s\n", mask, new);
- if (!new)
- return NULL;
- if (!mask)
- return g_strdup(new);
- i=0;
- while (mask[i] && new[i]) {
- if (mask[i] != '.' && mask[i] != new[i])
- break;
- i++;
-
- }
- if (mask[i]) {
- ret=g_strdup(mask);
- while (mask[i])
- ret[i++]='.';
- }
- dbg(lvl_debug,"merged %s with %s as %s\n", mask, new, ret);
- return ret;
-}
-
-char *
-search_postal_merge_replace(char *mask, char *new)
-{
- char *ret=search_postal_merge(mask, new);
- if (!ret)
- return mask;
- g_free(mask);
- return ret;
-}
-
-
-static int
-postal_match(char *postal, char *mask)
-{
- for (;;) {
- if ((*postal != *mask) && (*mask != '.'))
- return 0;
- if (!*postal) {
- if (!*mask)
- return 1;
- else
- return 0;
- }
- postal++;
- mask++;
- }
-}
-
-static int
-search_add_result(struct search_list_level *le, struct search_list_common *slc)
-{
- struct search_list_common *slo;
- char *merged;
- int unique=0;
- if (slc->unique.type || slc->unique.id_hi || slc->unique.id_lo)
- unique=1;
- if (unique)
- slo=g_hash_table_lookup(le->hash, &slc->unique);
- else
- slo=NULL;
- if (!slo) {
- if (unique)
- g_hash_table_insert(le->hash, &slc->unique, slc);
- if (slc->postal && !slc->postal_mask) {
- slc->postal_mask=g_strdup(slc->postal);
- }
- le->list=g_list_append(le->list, slc);
- return 1;
- }
- merged=search_postal_merge(slo->postal_mask, slc->postal);
- if (merged) {
- g_free(slo->postal_mask);
- slo->postal_mask=merged;
- }
- return 0;
+ curr=le->list;
+ while (curr) {
+ search_list_result_destroy(level, curr->data);
+ next=g_list_next(curr);
+ curr=next;
+ }
+ attr_free(le->attr);
+ g_list_free(le->list);
+ le->list=NULL;
+ le->curr=NULL;
+ le->last=NULL;
+}
+
+char *search_postal_merge(char *mask, char *new) {
+ int i;
+ char *ret=NULL;
+ dbg(lvl_debug,"enter %s %s", mask, new);
+ if (!new)
+ return NULL;
+ if (!mask)
+ return g_strdup(new);
+ i=0;
+ while (mask[i] && new[i]) {
+ if (mask[i] != '.' && mask[i] != new[i])
+ break;
+ i++;
+
+ }
+ if (mask[i]) {
+ ret=g_strdup(mask);
+ while (mask[i])
+ ret[i++]='.';
+ }
+ dbg(lvl_debug,"merged %s with %s as %s", mask, new, ret);
+ return ret;
+}
+
+char *search_postal_merge_replace(char *mask, char *new) {
+ char *ret=search_postal_merge(mask, new);
+ if (!ret)
+ return mask;
+ g_free(mask);
+ return ret;
+}
+
+
+static int postal_match(char *postal, char *mask) {
+ for (;;) {
+ if ((*postal != *mask) && (*mask != '.'))
+ return 0;
+ if (!*postal) {
+ if (!*mask)
+ return 1;
+ else
+ return 0;
+ }
+ postal++;
+ mask++;
+ }
+}
+
+static int search_add_result(struct search_list_level *le, struct search_list_common *slc) {
+ struct search_list_common *slo;
+ char *merged;
+ int unique=0;
+ if (slc->unique.type || slc->unique.id_hi || slc->unique.id_lo)
+ unique=1;
+ if (unique)
+ slo=g_hash_table_lookup(le->hash, &slc->unique);
+ else
+ slo=NULL;
+ if (!slo) {
+ if (unique)
+ g_hash_table_insert(le->hash, &slc->unique, slc);
+ if (slc->postal && !slc->postal_mask) {
+ slc->postal_mask=g_strdup(slc->postal);
+ }
+ le->list=g_list_append(le->list, slc);
+ return 1;
+ }
+ merged=search_postal_merge(slo->postal_mask, slc->postal);
+ if (merged) {
+ g_free(slo->postal_mask);
+ slo->postal_mask=merged;
+ }
+ return 0;
}
/**
@@ -845,206 +775,184 @@ search_add_result(struct search_list_level *le, struct search_list_common *slc)
* @return next result
*/
struct search_list_result *
-search_list_get_result(struct search_list *this_)
-{
- struct search_list_level *le,*leu;
- int level=this_->level;
- struct attr attr2;
- int has_street_name=0;
-
- if (this_->use_address_results) {
- struct search_list_result *ret=NULL;
- if (this_->address_results_pos) {
- ret=this_->address_results_pos->data;
- this_->address_results_pos=g_list_next(this_->address_results_pos);
- }
- return ret;
- }
-
- //dbg(lvl_debug,"enter\n");
- le=&this_->levels[level];
- //dbg(lvl_debug,"le=%p\n", le);
- for (;;)
- {
- //dbg(lvl_debug,"le->search=%p\n", le->search);
- if (! le->search)
- {
- //dbg(lvl_debug,"partial=%d level=%d\n", le->partial, level);
- if (! level)
- le->parent=NULL;
- else
- {
- leu=&this_->levels[level-1];
- //dbg(lvl_debug,"leu->curr=%p\n", leu->curr);
- for (;;)
- {
- //dbg(lvl_debug,"*********########");
-
- struct search_list_common *slc;
- if (! leu->curr)
- {
- return NULL;
- }
- le->parent=leu->curr->data;
- leu->last=leu->curr;
- leu->curr=g_list_next(leu->curr);
- slc=(struct search_list_common *)(le->parent);
- if (!slc)
- break;
- if (slc->selected == leu->selected)
- break;
- }
- }
- if (le->parent)
- {
- //dbg(lvl_debug,"mapset_search_new with item(%d,%d)\n", le->parent->item.id_hi, le->parent->item.id_lo);
- }
- //dbg(lvl_debug,"############## attr=%s\n", attr_to_name(le->attr->type));
- le->search=mapset_search_new(this_->ms, &le->parent->item, le->attr, le->partial);
- le->hash=g_hash_table_new(search_item_hash_hash, search_item_hash_equal);
- }
- //dbg(lvl_debug,"le->search=%p\n", le->search);
- if (!this_->item)
- {
- //dbg(lvl_debug,"sssss 1");
- this_->item=mapset_search_get_item(le->search);
- //dbg(lvl_debug,"sssss 1 %p\n",this_->item);
- }
- if (this_->item)
- {
- void *p=NULL;
- //dbg(lvl_debug,"id_hi=%d id_lo=%d\n", this_->item->id_hi, this_->item->id_lo);
- if (this_->postal)
- {
- struct attr postal;
- if (item_attr_get(this_->item, attr_postal_mask, &postal)) {
- if (!postal_match(this_->postal, postal.u.str))
- continue;
- } else if (item_attr_get(this_->item, attr_postal, &postal)) {
- if (strcmp(this_->postal, postal.u.str))
- continue;
- }
- }
- this_->result.country=NULL;
- this_->result.town=NULL;
- this_->result.street=NULL;
- this_->result.c=NULL;
- //dbg(lvl_debug,"case x LEVEL start %d\n",level);
- switch (level)
- {
- case 0:
- //dbg(lvl_debug,"case 0 COUNTRY");
- p=search_list_country_new(this_->item);
- this_->result.country=p;
- this_->result.country->common.parent=NULL;
- this_->result.town=NULL;
- this_->result.street=NULL;
- this_->result.house_number=NULL;
- this_->item=NULL;
- break;
- case 1:
- //dbg(lvl_debug,"case 1 TOWN");
- p=search_list_town_new(this_->item);
- this_->result.town=p;
- this_->result.town->common.parent=this_->levels[0].last->data;
- this_->result.country=this_->result.town->common.parent;
- this_->result.c=this_->result.town->common.c;
- this_->result.street=NULL;
- this_->result.house_number=NULL;
- this_->item=NULL;
- break;
- case 2:
- //dbg(lvl_debug,"case 2 STREET");
- p=search_list_street_new(this_->item);
- this_->result.street=p;
- this_->result.street->common.parent=this_->levels[1].last->data;
- this_->result.town=this_->result.street->common.parent;
- this_->result.country=this_->result.town->common.parent;
- this_->result.c=this_->result.street->common.c;
- this_->result.house_number=NULL;
- this_->item=NULL;
- break;
- case 3:
- dbg(lvl_debug,"case 3 HOUSENUMBER\n");
- has_street_name=0;
-
- // if this housenumber has a streetname tag, set the name now
- if (item_attr_get(this_->item, attr_street_name, &attr2))
- {
- dbg(lvl_debug,"streetname: %s\n",attr2.u.str);
- has_street_name=1;
- }
-
- p=search_list_house_number_new(this_->item, &this_->inter, le->attr->u.str, le->partial);
- if (!p)
- {
- house_number_interpolation_clear_all(&this_->inter);
- this_->item=NULL;
- continue;
- }
-
- this_->result.house_number=p;
- if (!this_->result.house_number->house_number_interpolation)
- {
- this_->item=NULL;
- } else {
- dbg(lvl_debug,"interpolation!\n");
- }
-
- if(le->parent && has_street_name) {
- struct search_list_street *street=this_->levels[level-1].last->data;
- if(navit_utf8_strcasecmp(street->name, attr2.u.str)) {
- search_list_house_number_destroy(p);
- //this_->item=NULL;
- continue;
- }
- }
-
-
- this_->result.house_number->common.parent=this_->levels[2].last->data;
- this_->result.street=this_->result.house_number->common.parent;
- this_->result.town=this_->result.street->common.parent;
- this_->result.country=this_->result.town->common.parent;
- this_->result.c=this_->result.house_number->common.c;
+search_list_get_result(struct search_list *this_) {
+ struct search_list_level *le,*leu;
+ int level=this_->level;
+ struct attr attr2;
+ int has_street_name=0;
+
+ if (this_->use_address_results) {
+ struct search_list_result *ret=NULL;
+ if (this_->address_results_pos) {
+ ret=this_->address_results_pos->data;
+ this_->address_results_pos=g_list_next(this_->address_results_pos);
+ }
+ return ret;
+ }
+
+ //dbg(lvl_debug,"enter");
+ le=&this_->levels[level];
+ //dbg(lvl_debug,"le=%p", le);
+ for (;;) {
+ //dbg(lvl_debug,"le->search=%p", le->search);
+ if (! le->search) {
+ //dbg(lvl_debug,"partial=%d level=%d", le->partial, level);
+ if (! level)
+ le->parent=NULL;
+ else {
+ leu=&this_->levels[level-1];
+ //dbg(lvl_debug,"leu->curr=%p", leu->curr);
+ for (;;) {
+ //dbg(lvl_debug,"*********########");
+
+ struct search_list_common *slc;
+ if (! leu->curr) {
+ return NULL;
+ }
+ le->parent=leu->curr->data;
+ leu->last=leu->curr;
+ leu->curr=g_list_next(leu->curr);
+ slc=(struct search_list_common *)(le->parent);
+ if (!slc)
+ break;
+ if (slc->selected == leu->selected)
+ break;
+ }
+ }
+ if (le->parent) {
+ //dbg(lvl_debug,"mapset_search_new with item(%d,%d)", le->parent->item.id_hi, le->parent->item.id_lo);
+ }
+ //dbg(lvl_debug,"############## attr=%s", attr_to_name(le->attr->type));
+ le->search=mapset_search_new(this_->ms, &le->parent->item, le->attr, le->partial);
+ le->hash=g_hash_table_new(search_item_hash_hash, search_item_hash_equal);
+ }
+ //dbg(lvl_debug,"le->search=%p", le->search);
+ if (!this_->item) {
+ //dbg(lvl_debug,"sssss 1");
+ this_->item=mapset_search_get_item(le->search);
+ //dbg(lvl_debug,"sssss 1 %p",this_->item);
+ }
+ if (this_->item) {
+ void *p=NULL;
+ //dbg(lvl_debug,"id_hi=%d id_lo=%d", this_->item->id_hi, this_->item->id_lo);
+ if (this_->postal) {
+ struct attr postal;
+ if (item_attr_get(this_->item, attr_postal_mask, &postal)) {
+ if (!postal_match(this_->postal, postal.u.str))
+ continue;
+ } else if (item_attr_get(this_->item, attr_postal, &postal)) {
+ if (strcmp(this_->postal, postal.u.str))
+ continue;
+ }
+ }
+ this_->result.country=NULL;
+ this_->result.town=NULL;
+ this_->result.street=NULL;
+ this_->result.c=NULL;
+ //dbg(lvl_debug,"case x LEVEL start %d",level);
+ switch (level) {
+ case 0:
+ //dbg(lvl_debug,"case 0 COUNTRY");
+ p=search_list_country_new(this_->item);
+ this_->result.country=p;
+ this_->result.country->common.parent=NULL;
+ this_->result.town=NULL;
+ this_->result.street=NULL;
+ this_->result.house_number=NULL;
+ this_->item=NULL;
+ break;
+ case 1:
+ //dbg(lvl_debug,"case 1 TOWN");
+ p=search_list_town_new(this_->item);
+ this_->result.town=p;
+ this_->result.town->common.parent=this_->levels[0].last->data;
+ this_->result.country=this_->result.town->common.parent;
+ this_->result.c=this_->result.town->common.c;
+ this_->result.street=NULL;
+ this_->result.house_number=NULL;
+ this_->item=NULL;
+ break;
+ case 2:
+ //dbg(lvl_debug,"case 2 STREET");
+ p=search_list_street_new(this_->item);
+ this_->result.street=p;
+ this_->result.street->common.parent=this_->levels[1].last->data;
+ this_->result.town=this_->result.street->common.parent;
+ this_->result.country=this_->result.town->common.parent;
+ this_->result.c=this_->result.street->common.c;
+ this_->result.house_number=NULL;
+ this_->item=NULL;
+ break;
+ case 3:
+ dbg(lvl_debug,"case 3 HOUSENUMBER");
+ has_street_name=0;
+
+ // if this housenumber has a streetname tag, set the name now
+ if (item_attr_get(this_->item, attr_street_name, &attr2)) {
+ dbg(lvl_debug,"streetname: %s",attr2.u.str);
+ has_street_name=1;
+ }
+
+ p=search_list_house_number_new(this_->item, &this_->inter, le->attr->u.str, le->partial);
+ if (!p) {
+ house_number_interpolation_clear_all(&this_->inter);
+ this_->item=NULL;
+ continue;
+ }
+
+ this_->result.house_number=p;
+ if (!this_->result.house_number->house_number_interpolation) {
+ this_->item=NULL;
+ } else {
+ dbg(lvl_debug,"interpolation!");
+ }
+
+ if(le->parent && has_street_name) {
+ struct search_list_street *street=this_->levels[level-1].last->data;
+ if(navit_utf8_strcasecmp(street->name, attr2.u.str)) {
+ search_list_house_number_destroy(p);
+ //this_->item=NULL;
+ continue;
+ }
+ }
+
+
+ this_->result.house_number->common.parent=this_->levels[2].last->data;
+ this_->result.street=this_->result.house_number->common.parent;
+ this_->result.town=this_->result.street->common.parent;
+ this_->result.country=this_->result.town->common.parent;
+ this_->result.c=this_->result.house_number->common.c;
#if 0
- if(!has_street_name) {
- static struct search_list_street null_street;
- this_->result.street=&null_street;
- }
+ if(!has_street_name) {
+ static struct search_list_street null_street;
+ this_->result.street=&null_street;
+ }
#endif
- }
- if (p)
- {
- if (search_add_result(le, p))
- {
- this_->result.id++;
- return &this_->result;
- }
- else
- {
- search_list_result_destroy(level, p);
- }
- }
- } else {
- mapset_search_destroy(le->search);
- le->search=NULL;
- g_hash_table_destroy(le->hash);
- if (! level)
- break;
- }
- }
- return NULL;
-}
-
-void
-search_list_destroy(struct search_list *this_)
-{
- g_free(this_->postal);
- g_free(this_);
-}
-
-void
-search_init(void)
-{
+ }
+ if (p) {
+ if (search_add_result(le, p)) {
+ this_->result.id++;
+ return &this_->result;
+ } else {
+ search_list_result_destroy(level, p);
+ }
+ }
+ } else {
+ mapset_search_destroy(le->search);
+ le->search=NULL;
+ g_hash_table_destroy(le->hash);
+ if (! level)
+ break;
+ }
+ }
+ return NULL;
+}
+
+void search_list_destroy(struct search_list *this_) {
+ g_free(this_->postal);
+ g_free(this_);
+}
+
+void search_init(void) {
}
diff --git a/navit/search_houseno_interpol.c b/navit/search_houseno_interpol.c
index 604fcf93c..b08bfacea 100644
--- a/navit/search_houseno_interpol.c
+++ b/navit/search_houseno_interpol.c
@@ -37,9 +37,9 @@
#include "search_houseno_interpol.h"
struct hn_interpol_attr {
- enum attr_type house_number_interpol_attr;
- int interpol_increment;
- enum include_end_nodes include_end_nodes;
+ enum attr_type house_number_interpol_attr;
+ int interpol_increment;
+ enum include_end_nodes include_end_nodes;
};
#define house_number_interpol_attr_END -1
@@ -48,204 +48,191 @@ struct hn_interpol_attr {
* along with interpolation information.
*/
struct hn_interpol_attr house_number_interpol_attrs[] = {
- { attr_house_number_left, 1, end_nodes_yes },
- { attr_house_number_left_odd, 2, end_nodes_yes },
- { attr_house_number_left_even, 2, end_nodes_yes },
- { attr_house_number_right, 1, end_nodes_yes },
- { attr_house_number_right_odd, 2, end_nodes_yes },
- { attr_house_number_right_even, 2, end_nodes_yes },
- { attr_house_number_interpolation_no_ends_incrmt_1, 1, end_nodes_no },
- { attr_house_number_interpolation_no_ends_incrmt_2, 2, end_nodes_no },
- { house_number_interpol_attr_END, -1, -1 },
+ { attr_house_number_left, 1, end_nodes_yes },
+ { attr_house_number_left_odd, 2, end_nodes_yes },
+ { attr_house_number_left_even, 2, end_nodes_yes },
+ { attr_house_number_right, 1, end_nodes_yes },
+ { attr_house_number_right_odd, 2, end_nodes_yes },
+ { attr_house_number_right_even, 2, end_nodes_yes },
+ { attr_house_number_interpolation_no_ends_incrmt_1, 1, end_nodes_no },
+ { attr_house_number_interpolation_no_ends_incrmt_2, 2, end_nodes_no },
+ { house_number_interpol_attr_END, -1, -1 },
};
-void
-house_number_interpolation_clear_current(struct house_number_interpolation *inter)
-{
- g_free(inter->first);
- g_free(inter->last);
- g_free(inter->curr);
- inter->first=inter->last=inter->curr=NULL;
- inter->increment=inter->include_end_nodes=-1;
+void house_number_interpolation_clear_current(struct house_number_interpolation *inter) {
+ g_free(inter->first);
+ g_free(inter->last);
+ g_free(inter->curr);
+ inter->first=inter->last=inter->curr=NULL;
+ inter->increment=inter->include_end_nodes=-1;
}
-void
-house_number_interpolation_clear_all(struct house_number_interpolation *inter)
-{
- inter->curr_interpol_attr_idx=0;
- house_number_interpolation_clear_current(inter);
+void house_number_interpolation_clear_all(struct house_number_interpolation *inter) {
+ inter->curr_interpol_attr_idx=0;
+ house_number_interpolation_clear_current(inter);
}
-static char *
-search_next_house_number_curr_interpol_with_ends(struct house_number_interpolation *inter)
-{
- dbg(lvl_debug,"interpolate %s-%s %s\n",inter->first,inter->last,inter->curr);
- if (!inter->first || !inter->last)
- return NULL;
- if (!inter->curr)
- inter->curr=g_strdup(inter->first);
- else {
- if (strcmp(inter->curr, inter->last)) {
- int next=atoi(inter->curr)+(inter->increment);
- g_free(inter->curr);
- if (next == atoi(inter->last))
- inter->curr=g_strdup(inter->last);
- else
- inter->curr=g_strdup_printf("%d",next);
- } else {
- g_free(inter->curr);
- inter->curr=NULL;
- }
- }
- dbg(lvl_debug,"interpolate result %s\n",inter->curr);
- return inter->curr;
+static char *search_next_house_number_curr_interpol_with_ends(struct house_number_interpolation *inter) {
+ dbg(lvl_debug,"interpolate %s-%s %s",inter->first,inter->last,inter->curr);
+ if (!inter->first || !inter->last)
+ return NULL;
+ if (!inter->curr)
+ inter->curr=g_strdup(inter->first);
+ else {
+ if (strcmp(inter->curr, inter->last)) {
+ int next=atoi(inter->curr)+(inter->increment);
+ g_free(inter->curr);
+ if (next == atoi(inter->last))
+ inter->curr=g_strdup(inter->last);
+ else
+ inter->curr=g_strdup_printf("%d",next);
+ } else {
+ g_free(inter->curr);
+ inter->curr=NULL;
+ }
+ }
+ dbg(lvl_debug,"interpolate result %s",inter->curr);
+ return inter->curr;
}
-static int
-house_number_is_end_number(char* house_number, struct house_number_interpolation *inter) {
- return ( (!strcmp(house_number, inter->first))
- || (!strcmp(house_number, inter->last)) );
+static int house_number_is_end_number(char* house_number, struct house_number_interpolation *inter) {
+ return ( (!strcmp(house_number, inter->first))
+ || (!strcmp(house_number, inter->last)) );
}
-static char *
-search_next_house_number_curr_interpol(struct house_number_interpolation *inter)
-{
- char* hn=NULL;
- switch (inter->include_end_nodes) {
- case end_nodes_yes:
- hn=search_next_house_number_curr_interpol_with_ends(inter);
- break;
- case end_nodes_no:
- do {
- hn=search_next_house_number_curr_interpol_with_ends(inter);
- } while (hn!=NULL && house_number_is_end_number(hn, inter));
- break;
- }
- return hn;
+static char *search_next_house_number_curr_interpol(struct house_number_interpolation *inter) {
+ char* hn=NULL;
+ switch (inter->include_end_nodes) {
+ case end_nodes_yes:
+ hn=search_next_house_number_curr_interpol_with_ends(inter);
+ break;
+ case end_nodes_no:
+ do {
+ hn=search_next_house_number_curr_interpol_with_ends(inter);
+ } while (hn!=NULL && house_number_is_end_number(hn, inter));
+ break;
+ }
+ return hn;
}
-static void
-search_house_number_interpolation_split(char *str, struct house_number_interpolation *inter)
-{
- char *pos=strchr(str,'-');
- char *first,*last;
- int len;
- if (!pos) {
- inter->first=g_strdup(str);
- inter->last=g_strdup(str);
- inter->rev=0;
- return;
- }
- len=pos-str;
- first=g_malloc(len+1);
- strncpy(first, str, len);
- first[len]='\0';
- last=g_strdup(pos+1);
- dbg(lvl_debug,"%s = %s - %s\n",str, first, last);
- if (atoi(first) > atoi(last)) {
- inter->first=last;
- inter->last=first;
- inter->rev=1;
- } else {
- inter->first=first;
- inter->last=last;
- inter->rev=0;
- }
+static void search_house_number_interpolation_split(char *str, struct house_number_interpolation *inter) {
+ char *pos=strchr(str,'-');
+ char *first,*last;
+ int len;
+ if (!pos) {
+ inter->first=g_strdup(str);
+ inter->last=g_strdup(str);
+ inter->rev=0;
+ return;
+ }
+ len=pos-str;
+ first=g_malloc(len+1);
+ strncpy(first, str, len);
+ first[len]='\0';
+ last=g_strdup(pos+1);
+ dbg(lvl_debug,"%s = %s - %s",str, first, last);
+ if (atoi(first) > atoi(last)) {
+ inter->first=last;
+ inter->last=first;
+ inter->rev=1;
+ } else {
+ inter->first=first;
+ inter->last=last;
+ inter->rev=0;
+ }
}
struct pcoord *
-search_house_number_coordinate(struct item *item, struct house_number_interpolation *inter)
-{
- struct pcoord *ret=g_new(struct pcoord, 1);
- ret->pro = map_projection(item->map);
- dbg(lvl_debug,"%s\n",item_to_name(item->type));
- if (!inter) {
- struct coord c;
- if (item_coord_get(item, &c, 1)) {
- ret->x=c.x;
- ret->y=c.y;
- } else {
- g_free(ret);
- ret=NULL;
- }
- } else {
- int count,max=1024;
- int hn_pos,hn_length;
- int inter_increment=inter->increment;
- struct coord *c=g_alloca(sizeof(struct coord)*max);
- item_coord_rewind(item);
- count=item_coord_get(item, c, max);
- hn_length=atoi(inter->last)-atoi(inter->first);
- if (inter->rev)
- hn_pos=atoi(inter->last)-atoi(inter->curr);
- else
- hn_pos=atoi(inter->curr)-atoi(inter->first);
- if (count) {
- int i,distance_sum=0,hn_distance;
- int *distances=g_alloca(sizeof(int)*(count-1));
- dbg(lvl_debug,"count=%d hn_length=%d hn_pos=%d (%s of %s-%s)\n",count,hn_length,hn_pos,inter->curr,inter->first,inter->last);
- if (!hn_length) {
- hn_length=2;
- hn_pos=1;
- }
- if (count == max)
- dbg(lvl_error,"coordinate overflow\n");
- for (i = 0 ; i < count-1 ; i++) {
- distances[i]=navit_sqrt(transform_distance_sq(&c[i],&c[i+1]));
- distance_sum+=distances[i];
- dbg(lvl_debug,"distance[%d]=%d\n",i,distances[i]);
- }
- dbg(lvl_debug,"sum=%d\n",distance_sum);
+search_house_number_coordinate(struct item *item, struct house_number_interpolation *inter) {
+ struct pcoord *ret=g_new(struct pcoord, 1);
+ ret->pro = map_projection(item->map);
+ dbg(lvl_debug,"%s",item_to_name(item->type));
+ if (!inter) {
+ struct coord c;
+ if (item_coord_get(item, &c, 1)) {
+ ret->x=c.x;
+ ret->y=c.y;
+ } else {
+ g_free(ret);
+ ret=NULL;
+ }
+ } else {
+ int count,max=1024;
+ int hn_pos,hn_length;
+ int inter_increment=inter->increment;
+ struct coord *c=g_alloca(sizeof(struct coord)*max);
+ item_coord_rewind(item);
+ count=item_coord_get(item, c, max);
+ hn_length=atoi(inter->last)-atoi(inter->first);
+ if (inter->rev)
+ hn_pos=atoi(inter->last)-atoi(inter->curr);
+ else
+ hn_pos=atoi(inter->curr)-atoi(inter->first);
+ if (count) {
+ int i,distance_sum=0,hn_distance;
+ int *distances=g_alloca(sizeof(int)*(count-1));
+ dbg(lvl_debug,"count=%d hn_length=%d hn_pos=%d (%s of %s-%s)",count,hn_length,hn_pos,inter->curr,inter->first,
+ inter->last);
+ if (!hn_length) {
+ hn_length=2;
+ hn_pos=1;
+ }
+ if (count == max)
+ dbg(lvl_error,"coordinate overflow");
+ for (i = 0 ; i < count-1 ; i++) {
+ distances[i]=navit_sqrt(transform_distance_sq(&c[i],&c[i+1]));
+ distance_sum+=distances[i];
+ dbg(lvl_debug,"distance[%d]=%d",i,distances[i]);
+ }
+ dbg(lvl_debug,"sum=%d",distance_sum);
#if 0
- hn_distance=distance_sum*hn_pos/hn_length;
+ hn_distance=distance_sum*hn_pos/hn_length;
#else
- hn_distance=(distance_sum*hn_pos+distance_sum*inter_increment/2)/(hn_length+inter_increment);
+ hn_distance=(distance_sum*hn_pos+distance_sum*inter_increment/2)/(hn_length+inter_increment);
#endif
- dbg(lvl_debug,"hn_distance=%d\n",hn_distance);
- i=0;
- while (i < count-1 && hn_distance > distances[i])
- hn_distance-=distances[i++];
- dbg(lvl_debug,"remaining distance=%d from %d\n",hn_distance,distances[i]);
- ret->x=(c[i+1].x-c[i].x)*hn_distance/distances[i]+c[i].x;
- ret->y=(c[i+1].y-c[i].y)*hn_distance/distances[i]+c[i].y;
- }
- }
- return ret;
+ dbg(lvl_debug,"hn_distance=%d",hn_distance);
+ i=0;
+ while (i < count-1 && hn_distance > distances[i])
+ hn_distance-=distances[i++];
+ dbg(lvl_debug,"remaining distance=%d from %d",hn_distance,distances[i]);
+ ret->x=(c[i+1].x-c[i].x)*hn_distance/distances[i]+c[i].x;
+ ret->y=(c[i+1].y-c[i].y)*hn_distance/distances[i]+c[i].y;
+ }
+ }
+ return ret;
}
-static int
-search_match(char *str, char *search, int partial)
-{
- if (!partial)
- return (!g_ascii_strcasecmp(str, search));
- else
- return (!g_ascii_strncasecmp(str, search, strlen(search)));
+static int search_match(char *str, char *search, int partial) {
+ if (!partial)
+ return (!g_ascii_strcasecmp(str, search));
+ else
+ return (!g_ascii_strncasecmp(str, search, strlen(search)));
}
-char *
-search_next_interpolated_house_number(struct item *item, struct house_number_interpolation *inter, char *inter_match, int inter_partial)
-{
- while (1) {
- char *hn;
- struct attr attr;
- struct hn_interpol_attr curr_interpol_attr;
- while((hn=search_next_house_number_curr_interpol(inter))){
- if (search_match(hn, inter_match, inter_partial)) {
- return map_convert_string(item->map, hn);
- }
- }
+char *search_next_interpolated_house_number(struct item *item, struct house_number_interpolation *inter,
+ char *inter_match,
+ int inter_partial) {
+ while (1) {
+ char *hn;
+ struct attr attr;
+ struct hn_interpol_attr curr_interpol_attr;
+ while((hn=search_next_house_number_curr_interpol(inter))) {
+ if (search_match(hn, inter_match, inter_partial)) {
+ return map_convert_string(item->map, hn);
+ }
+ }
- house_number_interpolation_clear_current(inter);
- curr_interpol_attr=house_number_interpol_attrs[inter->curr_interpol_attr_idx];
- if (curr_interpol_attr.house_number_interpol_attr==house_number_interpol_attr_END) {
- return NULL;
- }
- if (item_attr_get(item, curr_interpol_attr.house_number_interpol_attr, &attr)) {
- search_house_number_interpolation_split(attr.u.str, inter);
- inter->increment=curr_interpol_attr.interpol_increment;
- inter->include_end_nodes=curr_interpol_attr.include_end_nodes;
- }
- inter->curr_interpol_attr_idx++;
- }
+ house_number_interpolation_clear_current(inter);
+ curr_interpol_attr=house_number_interpol_attrs[inter->curr_interpol_attr_idx];
+ if (curr_interpol_attr.house_number_interpol_attr==house_number_interpol_attr_END) {
+ return NULL;
+ }
+ if (item_attr_get(item, curr_interpol_attr.house_number_interpol_attr, &attr)) {
+ search_house_number_interpolation_split(attr.u.str, inter);
+ inter->increment=curr_interpol_attr.interpol_increment;
+ inter->include_end_nodes=curr_interpol_attr.include_end_nodes;
+ }
+ inter->curr_interpol_attr_idx++;
+ }
}
diff --git a/navit/speech.c b/navit/speech.c
index cabd998dc..fa560635c 100644
--- a/navit/speech.c
+++ b/navit/speech.c
@@ -26,63 +26,58 @@
#include "xmlconfig.h"
struct speech {
- NAVIT_OBJECT;
- struct speech_priv *priv;
- struct speech_methods meth;
+ NAVIT_OBJECT;
+ struct speech_priv *priv;
+ struct speech_methods meth;
};
struct speech *
-speech_new(struct attr *parent, struct attr **attrs)
-{
- struct speech *this_;
- struct speech_priv *(*speech_new)(struct speech_methods *meth, struct attr **attrs, struct attr *parent);
- struct attr *attr;
-
- attr=attr_search(attrs, NULL, attr_type);
- if (! attr) {
- dbg(lvl_error,"type missing\n");
- return NULL;
- }
- dbg(lvl_debug,"type='%s'\n", attr->u.str);
- speech_new=plugin_get_category_speech(attr->u.str);
- dbg(lvl_debug,"new=%p\n", speech_new);
- if (! speech_new) {
- dbg(lvl_error,"wrong type '%s'\n", attr->u.str);
- return NULL;
- }
- this_=(struct speech *)navit_object_new(attrs, &speech_func, sizeof(struct speech));
- this_->priv=speech_new(&this_->meth, this_->attrs, parent);
- dbg(lvl_debug, "say=%p\n", this_->meth.say);
- dbg(lvl_debug,"priv=%p\n", this_->priv);
- if (! this_->priv) {
- speech_destroy(this_);
- return NULL;
- }
- dbg(lvl_debug,"return %p\n", this_);
-
- return this_;
+speech_new(struct attr *parent, struct attr **attrs) {
+ struct speech *this_;
+ struct speech_priv *(*speech_new)(struct speech_methods *meth, struct attr **attrs, struct attr *parent);
+ struct attr *attr;
+
+ attr=attr_search(attrs, NULL, attr_type);
+ if (! attr) {
+ dbg(lvl_error,"type missing");
+ return NULL;
+ }
+ dbg(lvl_debug,"type='%s'", attr->u.str);
+ speech_new=plugin_get_category_speech(attr->u.str);
+ dbg(lvl_debug,"new=%p", speech_new);
+ if (! speech_new) {
+ dbg(lvl_error,"wrong type '%s'", attr->u.str);
+ return NULL;
+ }
+ this_=(struct speech *)navit_object_new(attrs, &speech_func, sizeof(struct speech));
+ this_->priv=speech_new(&this_->meth, this_->attrs, parent);
+ dbg(lvl_debug, "say=%p", this_->meth.say);
+ dbg(lvl_debug,"priv=%p", this_->priv);
+ if (! this_->priv) {
+ speech_destroy(this_);
+ return NULL;
+ }
+ dbg(lvl_debug,"return %p", this_);
+
+ return this_;
}
-void
-speech_destroy(struct speech *this_)
-{
- if (this_->priv)
- this_->meth.destroy(this_->priv);
- navit_object_destroy((struct navit_object *)this_);
+void speech_destroy(struct speech *this_) {
+ if (this_->priv)
+ this_->meth.destroy(this_->priv);
+ navit_object_destroy((struct navit_object *)this_);
}
-int
-speech_say(struct speech *this_, const char *text)
-{
- dbg(lvl_debug, "this_=%p text='%s' calling %p\n", this_, text, this_->meth.say);
- return (this_->meth.say)(this_->priv, text);
+int speech_say(struct speech *this_, const char *text) {
+ dbg(lvl_debug, "this_=%p text='%s' calling %p", this_, text, this_->meth.say);
+ return (this_->meth.say)(this_->priv, text);
}
struct attr active=ATTR_INT(active, 1);
-struct attr *speech_default_attrs[]={
- &active,
- NULL,
+struct attr *speech_default_attrs[]= {
+ &active,
+ NULL,
};
/**
@@ -95,10 +90,8 @@ struct attr *speech_default_attrs[]={
* @return True if the attribute type was found, false if not
*/
-int
-speech_get_attr(struct speech *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- return attr_generic_get_attr(this_->attrs, speech_default_attrs, type, attr, iter);
+int speech_get_attr(struct speech *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ return attr_generic_get_attr(this_->attrs, speech_default_attrs, type, attr, iter);
}
/**
@@ -112,19 +105,17 @@ speech_get_attr(struct speech *this_, enum attr_type type, struct attr *attr, st
* @param str The string that should be estimated
* @return Time in tenth of seconds or -1 on error
*/
-int
-speech_estimate_duration(struct speech *this_, char *str)
-{
- int count;
- struct attr cps_attr;
-
- if (!speech_get_attr(this_,attr_cps,&cps_attr,NULL)) {
- return -1;
- }
-
- count = strlen(str);
-
- return (count * 10) / cps_attr.u.num;
+int speech_estimate_duration(struct speech *this_, char *str) {
+ int count;
+ struct attr cps_attr;
+
+ if (!speech_get_attr(this_,attr_cps,&cps_attr,NULL)) {
+ return -1;
+ }
+
+ count = strlen(str);
+
+ return (count * 10) / cps_attr.u.num;
}
/**
@@ -139,27 +130,25 @@ speech_estimate_duration(struct speech *this_, char *str)
* @return True if the attr could be set, false otherwise
*/
-int
-speech_set_attr(struct speech *this_, struct attr *attr)
-{
- this_->attrs=attr_generic_set_attr(this_->attrs, attr);
- //callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
- return 1;
+int speech_set_attr(struct speech *this_, struct attr *attr) {
+ this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+ //callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr);
+ return 1;
}
struct object_func speech_func = {
- attr_speech,
- (object_func_new)speech_new,
- (object_func_get_attr)speech_get_attr,
- (object_func_iter_new)navit_object_attr_iter_new,
- (object_func_iter_destroy)navit_object_attr_iter_destroy,
- (object_func_set_attr)speech_set_attr,
- (object_func_add_attr)navit_object_add_attr,
- (object_func_remove_attr)navit_object_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)speech_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_speech,
+ (object_func_new)speech_new,
+ (object_func_get_attr)speech_get_attr,
+ (object_func_iter_new)navit_object_attr_iter_new,
+ (object_func_iter_destroy)navit_object_attr_iter_destroy,
+ (object_func_set_attr)speech_set_attr,
+ (object_func_add_attr)navit_object_add_attr,
+ (object_func_remove_attr)navit_object_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)speech_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/speech/android/speech_android.c b/navit/speech/android/speech_android.c
index 2b3f2612c..fb0574166 100644
--- a/navit/speech/android/speech_android.c
+++ b/navit/speech/android/speech_android.c
@@ -27,123 +27,87 @@
#include "speech.h"
struct speech_priv {
- jclass NavitSpeechClass;
- jobject NavitSpeech;
- jmethodID NavitSpeech_say;
- int flags;
+ jclass NavitSpeechClass;
+ jobject NavitSpeech;
+ jmethodID NavitSpeech_say;
+ int flags;
};
-static int
-speech_android_say(struct speech_priv *this, const char *text)
-{
- char *str=g_strdup(text);
- jstring string;
- int i;
+static int speech_android_say(struct speech_priv *this, const char *text) {
+ char *str=g_strdup(text);
+ jstring string;
+ char *tok = str;
- if (this->flags & 2) {
- for (i = 0 ; i < strlen(str) ; i++) {
- if (str[i] == 0xc3 && str[i+1] == 0x84) {
- str[i]='A';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0x96) {
- str[i]='O';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0x9c) {
- str[i]='U';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0xa4) {
- str[i]='a';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0xb6) {
- str[i]='o';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0xbc) {
- str[i]='u';
- str[i+1]='e';
- }
- if (str[i] == 0xc3 && str[i+1] == 0x9f) {
- str[i]='s';
- str[i+1]='s';
- }
- }
- }
- string = (*jnienv)->NewStringUTF(jnienv, str);
- dbg(lvl_debug,"enter %s\n",str);
- (*jnienv)->CallVoidMethod(jnienv, this->NavitSpeech, this->NavitSpeech_say, string);
- (*jnienv)->DeleteLocalRef(jnienv, string);
- g_free(str);
+ /* Replace hyphens with white spaces, or some Android speech SDK will pronounce "hyphen" */
+ while (*tok) {
+ if (*tok=='-')
+ *tok=' ';
+ tok++;
+ }
- return 1;
+ string = (*jnienv)->NewStringUTF(jnienv, str);
+ dbg(lvl_debug,"enter %s",str);
+ (*jnienv)->CallVoidMethod(jnienv, this->NavitSpeech, this->NavitSpeech_say, string);
+ (*jnienv)->DeleteLocalRef(jnienv, string);
+ g_free(str);
+
+ return 1;
}
-static void
-speech_android_destroy(struct speech_priv *this) {
- g_free(this);
+static void speech_android_destroy(struct speech_priv *this) {
+ g_free(this);
}
static struct speech_methods speech_android_meth = {
- speech_android_destroy,
- speech_android_say,
+ speech_android_destroy,
+ speech_android_say,
};
-static int
-speech_android_init(struct speech_priv *ret)
-{
- jmethodID cid;
- char *class="org/navitproject/navit/NavitSpeech2";
-
- if (ret->flags & 1)
- class="org/navitproject/navit/NavitSpeech";
+static int speech_android_init(struct speech_priv *ret) {
+ jmethodID cid;
+ char *class="org/navitproject/navit/NavitSpeech2";
- if (!android_find_class_global(class, &ret->NavitSpeechClass)) {
- dbg(lvl_error,"No class found\n");
- return 0;
- }
- dbg(lvl_debug,"at 3\n");
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitSpeechClass, "<init>", "(Lorg/navitproject/navit/Navit;)V");
- if (cid == NULL) {
- dbg(lvl_error,"no method found\n");
- return 0; /* exception thrown */
- }
- if (!android_find_method(ret->NavitSpeechClass, "say", "(Ljava/lang/String;)V", &ret->NavitSpeech_say))
- return 0;
- dbg(lvl_debug,"at 4 android_activity=%p\n",android_activity);
- ret->NavitSpeech=(*jnienv)->NewObject(jnienv, ret->NavitSpeechClass, cid, android_activity);
- dbg(lvl_debug,"result=%p\n",ret->NavitSpeech);
- if (!ret->NavitSpeech)
- return 0;
- if (ret->NavitSpeech)
- ret->NavitSpeech = (*jnienv)->NewGlobalRef(jnienv, ret->NavitSpeech);
- return 1;
+ if (!android_find_class_global(class, &ret->NavitSpeechClass)) {
+ dbg(lvl_error,"No class found");
+ return 0;
+ }
+ dbg(lvl_debug,"at 3");
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitSpeechClass, "<init>", "(Lorg/navitproject/navit/Navit;)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no method found");
+ return 0; /* exception thrown */
+ }
+ if (!android_find_method(ret->NavitSpeechClass, "say", "(Ljava/lang/String;)V", &ret->NavitSpeech_say))
+ return 0;
+ dbg(lvl_debug,"at 4 android_activity=%p",android_activity);
+ ret->NavitSpeech=(*jnienv)->NewObject(jnienv, ret->NavitSpeechClass, cid, android_activity);
+ dbg(lvl_debug,"result=%p",ret->NavitSpeech);
+ if (!ret->NavitSpeech)
+ return 0;
+ if (ret->NavitSpeech)
+ ret->NavitSpeech = (*jnienv)->NewGlobalRef(jnienv, ret->NavitSpeech);
+ return 1;
}
-static struct speech_priv *
-speech_android_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
- struct speech_priv *this;
- struct attr *flags;
- *meth=speech_android_meth;
- this=g_new0(struct speech_priv,1);
- if (android_version < 4)
- this->flags=3;
- if (!speech_android_init(this)) {
- dbg(lvl_error,"Failed to init speech %p\n",this->NavitSpeechClass);
- g_free(this);
- this=NULL;
- }
- if ((flags = attr_search(attrs, NULL, attr_flags)))
- this->flags=flags->u.num;
-
- return this;
+static struct speech_priv *speech_android_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
+ struct speech_priv *this;
+ struct attr *flags;
+ *meth=speech_android_meth;
+ this=g_new0(struct speech_priv,1);
+ if (android_version < 4)
+ this->flags=3;
+ if (!speech_android_init(this)) {
+ dbg(lvl_error,"Failed to init speech %p",this->NavitSpeechClass);
+ g_free(this);
+ this=NULL;
+ }
+ if ((flags = attr_search(attrs, NULL, attr_flags)))
+ this->flags=flags->u.num;
+
+ return this;
}
-void
-plugin_init(void)
-{
- plugin_register_category_speech("android", speech_android_new);
+void plugin_init(void) {
+ plugin_register_category_speech("android", speech_android_new);
}
diff --git a/navit/speech/cmdline/speech_cmdline.c b/navit/speech/cmdline/speech_cmdline.c
index 490811ce5..11537e570 100644
--- a/navit/speech/cmdline/speech_cmdline.c
+++ b/navit/speech/cmdline/speech_cmdline.c
@@ -38,228 +38,210 @@
#endif
-static char *urldecode(char *str)
-{
- char *ret=g_strdup(str);
- char *src=ret;
- char *dst=ret;
- while (*src) {
- if (*src == '%') {
- int val;
- if (sscanf(src+1,"%02x",&val)) {
- src+=2;
- *dst++=val;
- }
- src++;
- } else
- *dst++=*src++;
- }
- *dst++='\0';
- return ret;
+static char *urldecode(char *str) {
+ char *ret=g_strdup(str);
+ char *src=ret;
+ char *dst=ret;
+ while (*src) {
+ if (*src == '%') {
+ int val;
+ if (sscanf(src+1,"%02x",&val)) {
+ src+=2;
+ *dst++=val;
+ }
+ src++;
+ } else
+ *dst++=*src++;
+ }
+ *dst++='\0';
+ return ret;
}
-static GList *
-speech_cmdline_search(GList *samples, int suffix_len, const char *text, int decode)
-{
- GList *loop_samples=samples,*result=NULL,*recursion_result;
- int shortest_result_length=INT_MAX;
- dbg(lvl_debug,"searching samples for text: '%s'\n",text);
- while (loop_samples) {
- char *sample_name=loop_samples->data;
- int sample_name_len;
- if (decode)
- sample_name=urldecode(sample_name);
- sample_name_len=strlen(sample_name)-suffix_len;
- // TODO: Here we compare UTF-8 text with a filename.
- // It's unclear how a case-insensitive comparison should work
- // in general, so for now we only do it for ASCII text.
- if (!g_ascii_strncasecmp(text, sample_name, sample_name_len)) {
- const char *remaining_text=text+sample_name_len;
- while (*remaining_text == ' ' || *remaining_text == ',')
- remaining_text++;
- dbg(lvl_debug,"sample '%s' matched; remaining text: '%s'\n",sample_name,remaining_text);
- if (*remaining_text) {
- recursion_result=speech_cmdline_search(samples, suffix_len, remaining_text, decode);
- if (recursion_result && g_list_length(recursion_result) < shortest_result_length) {
- g_list_free(result);
- result=recursion_result;
- result=g_list_prepend(result, loop_samples->data);
- shortest_result_length=g_list_length(result);
- } else {
- dbg(lvl_debug,"no (shorter) result found for remaining text '%s', "
- "trying next sample\n", remaining_text);
- g_list_free(recursion_result);
- }
- } else {
- g_list_free(result);
- result=g_list_prepend(NULL, loop_samples->data);
- break;
- }
- }
- if (decode)
- g_free(sample_name);
- loop_samples=g_list_next(loop_samples);
- }
- return result;
+static GList *speech_cmdline_search(GList *samples, int suffix_len, const char *text, int decode) {
+ GList *loop_samples=samples,*result=NULL,*recursion_result;
+ int shortest_result_length=INT_MAX;
+ dbg(lvl_debug,"searching samples for text: '%s'",text);
+ while (loop_samples) {
+ char *sample_name=loop_samples->data;
+ int sample_name_len;
+ if (decode)
+ sample_name=urldecode(sample_name);
+ sample_name_len=strlen(sample_name)-suffix_len;
+ // TODO: Here we compare UTF-8 text with a filename.
+ // It's unclear how a case-insensitive comparison should work
+ // in general, so for now we only do it for ASCII text.
+ if (!g_ascii_strncasecmp(text, sample_name, sample_name_len)) {
+ const char *remaining_text=text+sample_name_len;
+ while (*remaining_text == ' ' || *remaining_text == ',')
+ remaining_text++;
+ dbg(lvl_debug,"sample '%s' matched; remaining text: '%s'",sample_name,remaining_text);
+ if (*remaining_text) {
+ recursion_result=speech_cmdline_search(samples, suffix_len, remaining_text, decode);
+ if (recursion_result && g_list_length(recursion_result) < shortest_result_length) {
+ g_list_free(result);
+ result=recursion_result;
+ result=g_list_prepend(result, loop_samples->data);
+ shortest_result_length=g_list_length(result);
+ } else {
+ dbg(lvl_debug,"no (shorter) result found for remaining text '%s', "
+ "trying next sample\n", remaining_text);
+ g_list_free(recursion_result);
+ }
+ } else {
+ g_list_free(result);
+ result=g_list_prepend(NULL, loop_samples->data);
+ break;
+ }
+ }
+ if (decode)
+ g_free(sample_name);
+ loop_samples=g_list_next(loop_samples);
+ }
+ return result;
}
-#if 0
-
- r=search(l, strlen(path)+1, suffix_len, argv[1]);
- while (r) {
- printf("%s/%s\n",path,r->data);
- r=g_list_next(r);
- }
- return 0;
-#endif
struct speech_priv {
- char *cmdline;
- char *sample_dir;
- char *sample_suffix;
- int flags;
- GList *samples;
- struct spawn_process_info *spi;
+ char *cmdline;
+ char *sample_dir;
+ char *sample_suffix;
+ int flags;
+ GList *samples;
+ struct spawn_process_info *spi;
};
-static int
-speechd_say(struct speech_priv *this, const char *text)
-{
- char **cmdv=g_strsplit(this->cmdline," ", -1);
- int variable_arg_no=-1;
- GList *argl=NULL;
- guint listlen;
- int samplesmode=0;
- int i;
-
- for(i=0;cmdv[i];i++)
- if(strchr(cmdv[i],'%')) {
- variable_arg_no=i;
- break;
- }
-
- if (this->sample_dir && this->sample_suffix) {
- argl=speech_cmdline_search(this->samples, strlen(this->sample_suffix), text, !!(this->flags & 1));
- samplesmode=1;
- listlen=g_list_length(argl);
- dbg(lvl_debug,"For text: '%s', found %d samples.\n",text,listlen);
- if (!listlen){
- dbg(lvl_error,"No matching samples found. Cannot speak text: '%s'\n",text);
- }
- } else {
- listlen=1;
- }
- if(listlen>0) {
- dbg(lvl_debug,"Speaking text '%s'\n",text);
- int argc;
- char**argv;
- int j;
- int cmdvlen=g_strv_length(cmdv);
- argc=cmdvlen + listlen - (variable_arg_no>0?1:0);
- argv=g_new(char *,argc+1);
- if(variable_arg_no==-1) {
- argv[cmdvlen]=g_strdup("%s");
- variable_arg_no=cmdvlen;
- }
-
- for(i=0,j=0;j<argc;) {
- if( i==variable_arg_no ) {
- if (samplesmode) {
- GList *l=argl;
- while(l) {
- char *new_arg;
- new_arg=g_strdup_printf("%s/%s",this->sample_dir,(char *)l->data);
- dbg(lvl_debug,"new_arg %s\n",new_arg);
- argv[j++]=g_strdup_printf(cmdv[i],new_arg);
- g_free(new_arg);
- l=g_list_next(l);
- }
- } else {
- argv[j++]=g_strdup_printf(cmdv[i],text);
- }
- i++;
- } else {
- argv[j++]=g_strdup(cmdv[i++]);
- }
- }
- argv[j]=NULL;
- if (argl)
- // No need to free data elements here as they are
- // still referenced from this->samples
- g_list_free(argl);
+static int speechd_say(struct speech_priv *this, const char *text) {
+ char **cmdv=g_strsplit(this->cmdline," ", -1);
+ int variable_arg_no=-1;
+ GList *argl=NULL;
+ guint listlen;
+ int samplesmode=0;
+ int i;
+
+ for(i=0; cmdv[i]; i++)
+ if(strchr(cmdv[i],'%')) {
+ variable_arg_no=i;
+ break;
+ }
+
+ if (this->sample_dir && this->sample_suffix) {
+ argl=speech_cmdline_search(this->samples, strlen(this->sample_suffix), text, !!(this->flags & 1));
+ samplesmode=1;
+ listlen=g_list_length(argl);
+ dbg(lvl_debug,"For text: '%s', found %d samples.",text,listlen);
+ if (!listlen) {
+ dbg(lvl_error,"No matching samples found. Cannot speak text: '%s'",text);
+ }
+ } else {
+ listlen=1;
+ }
+ if(listlen>0) {
+ dbg(lvl_debug,"Speaking text '%s'",text);
+ int argc;
+ char**argv;
+ int j;
+ int cmdvlen=g_strv_length(cmdv);
+ argc=cmdvlen + listlen - (variable_arg_no>0?1:0);
+ argv=g_new(char *,argc+1);
+ if(variable_arg_no==-1) {
+ argv[cmdvlen]=g_strdup("%s");
+ variable_arg_no=cmdvlen;
+ }
+
+ for(i=0,j=0; j<argc;) {
+ if( i==variable_arg_no ) {
+ if (samplesmode) {
+ GList *l=argl;
+ while(l) {
+ char *new_arg;
+ new_arg=g_strdup_printf("%s/%s",this->sample_dir,(char *)l->data);
+ dbg(lvl_debug,"new_arg %s",new_arg);
+ argv[j++]=g_strdup_printf(cmdv[i],new_arg);
+ g_free(new_arg);
+ l=g_list_next(l);
+ }
+ } else {
+ argv[j++]=g_strdup_printf(cmdv[i],text);
+ }
+ i++;
+ } else {
+ argv[j++]=g_strdup(cmdv[i++]);
+ }
+ }
+ argv[j]=NULL;
+ if (argl)
+ // No need to free data elements here as they are
+ // still referenced from this->samples
+ g_list_free(argl);
- if(this->spi) {
- spawn_process_check_status(this->spi,1); // Block until previous spawned speech process is terminated.
- spawn_process_info_free(this->spi);
- }
- this->spi=spawn_process(argv);
- g_strfreev(argv);
- }
- g_strfreev(cmdv);
- return 0;
+ if(this->spi) {
+ spawn_process_check_status(this->spi,1); // Block until previous spawned speech process is terminated.
+ spawn_process_info_free(this->spi);
+ }
+ this->spi=spawn_process(argv);
+ g_strfreev(argv);
+ }
+ g_strfreev(cmdv);
+ return 0;
}
-static void
-speechd_destroy(struct speech_priv *this) {
- GList *l=this->samples;
- g_free(this->cmdline);
- g_free(this->sample_dir);
- g_free(this->sample_suffix);
- while(l) {
- g_free(l->data);
- }
- g_list_free(this->samples);
- if(this->spi)
- spawn_process_info_free(this->spi);
- g_free(this);
+static void speechd_destroy(struct speech_priv *this) {
+ GList *l=this->samples;
+ g_free(this->cmdline);
+ g_free(this->sample_dir);
+ g_free(this->sample_suffix);
+ while(l) {
+ g_free(l->data);
+ }
+ g_list_free(this->samples);
+ if(this->spi)
+ spawn_process_info_free(this->spi);
+ g_free(this);
}
static struct speech_methods speechd_meth = {
- speechd_destroy,
- speechd_say,
+ speechd_destroy,
+ speechd_say,
};
-static struct speech_priv *
-speechd_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
- struct speech_priv *this;
- struct attr *attr;
- attr=attr_search(attrs, NULL, attr_data);
- if (! attr)
- return NULL;
- this=g_new0(struct speech_priv,1);
- this->cmdline=g_strdup(attr->u.str);
- if ((attr=attr_search(attrs, NULL, attr_sample_dir)))
- this->sample_dir=g_strdup(attr->u.str);
- if ((attr=attr_search(attrs, NULL, attr_sample_suffix)))
- this->sample_suffix=g_strdup(attr->u.str);
- if ((attr=attr_search(attrs, NULL, attr_flags)))
- this->flags=attr->u.num;
- if (this->sample_dir && this->sample_suffix) {
- void *handle=file_opendir(this->sample_dir);
- if (!handle) {
- dbg(lvl_error,"Cannot read sample directory contents: %s", this->sample_dir);
- return NULL;
- }
- char *name;
- int suffix_len=strlen(this->sample_suffix);
- while((name=file_readdir(handle))) {
- int len=strlen(name);
- if (len > suffix_len) {
- if (!strcmp(name+len-suffix_len, this->sample_suffix)) {
- dbg(lvl_debug,"found %s\n",name);
- this->samples=g_list_prepend(this->samples, g_strdup(name));
- }
- }
- }
- file_closedir(handle);
- }
- *meth=speechd_meth;
- return this;
+static struct speech_priv *speechd_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
+ struct speech_priv *this;
+ struct attr *attr;
+ attr=attr_search(attrs, NULL, attr_data);
+ if (! attr)
+ return NULL;
+ this=g_new0(struct speech_priv,1);
+ this->cmdline=g_strdup(attr->u.str);
+ if ((attr=attr_search(attrs, NULL, attr_sample_dir)))
+ this->sample_dir=g_strdup(attr->u.str);
+ if ((attr=attr_search(attrs, NULL, attr_sample_suffix)))
+ this->sample_suffix=g_strdup(attr->u.str);
+ if ((attr=attr_search(attrs, NULL, attr_flags)))
+ this->flags=attr->u.num;
+ if (this->sample_dir && this->sample_suffix) {
+ void *handle=file_opendir(this->sample_dir);
+ if (!handle) {
+ dbg(lvl_error,"Cannot read sample directory contents: %s", this->sample_dir);
+ return NULL;
+ }
+ char *name;
+ int suffix_len=strlen(this->sample_suffix);
+ while((name=file_readdir(handle))) {
+ int len=strlen(name);
+ if (len > suffix_len) {
+ if (!strcmp(name+len-suffix_len, this->sample_suffix)) {
+ dbg(lvl_debug,"found %s",name);
+ this->samples=g_list_prepend(this->samples, g_strdup(name));
+ }
+ }
+ }
+ file_closedir(handle);
+ }
+ *meth=speechd_meth;
+ return this;
}
-void
-plugin_init(void)
-{
- plugin_register_category_speech("cmdline", speechd_new);
+void plugin_init(void) {
+ plugin_register_category_speech("cmdline", speechd_new);
}
diff --git a/navit/speech/dbus/CMakeLists.txt b/navit/speech/dbus/CMakeLists.txt
index 87413018a..c2e32eb8c 100644
--- a/navit/speech/dbus/CMakeLists.txt
+++ b/navit/speech/dbus/CMakeLists.txt
@@ -1 +1 @@
-module_add_library(speech_dbus speech_dbus.c)
+module_add_library(speech_dbus speech_dbus.c)
diff --git a/navit/speech/dbus/speech_dbus.c b/navit/speech/dbus/speech_dbus.c
index 0fdfb71ab..a3d60620c 100644
--- a/navit/speech/dbus/speech_dbus.c
+++ b/navit/speech/dbus/speech_dbus.c
@@ -28,50 +28,44 @@
#include "speech.h"
struct speech_priv {
- struct navit *nav;
+ struct navit *nav;
};
-static int
-speech_dbus_say(struct speech_priv *this, const char *text)
-{
- struct attr attr1,attr2,cb,*attr_list[3];
- int valid=0;
- attr1.type=attr_type;
- attr1.u.str="speech";
- attr2.type=attr_data;
- attr2.u.str=(char *)text;
- attr_list[0]=&attr1;
- attr_list[1]=&attr2;
- attr_list[2]=NULL;
- if (navit_get_attr(this->nav, attr_callback_list, &cb, NULL))
- callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
- return 0;
+static int speech_dbus_say(struct speech_priv *this, const char *text) {
+ struct attr attr1,attr2,cb,*attr_list[3];
+ int valid=0;
+ attr1.type=attr_type;
+ attr1.u.str="speech";
+ attr2.type=attr_data;
+ attr2.u.str=(char *)text;
+ attr_list[0]=&attr1;
+ attr_list[1]=&attr2;
+ attr_list[2]=NULL;
+ if (navit_get_attr(this->nav, attr_callback_list, &cb, NULL))
+ callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
+ return 0;
}
-static void
-speech_dbus_destroy(struct speech_priv *this) {
- g_free(this);
+static void speech_dbus_destroy(struct speech_priv *this) {
+ g_free(this);
}
static struct speech_methods speech_dbus_meth = {
- speech_dbus_destroy,
- speech_dbus_say,
+ speech_dbus_destroy,
+ speech_dbus_say,
};
-static struct speech_priv *
-speech_dbus_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
- struct speech_priv *this;
- if (!parent || parent->type != attr_navit)
- return NULL;
- this=g_new(struct speech_priv,1);
- this->nav=parent->u.navit;
- *meth=speech_dbus_meth;
- return this;
+static struct speech_priv *speech_dbus_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
+ struct speech_priv *this;
+ if (!parent || parent->type != attr_navit)
+ return NULL;
+ this=g_new(struct speech_priv,1);
+ this->nav=parent->u.navit;
+ *meth=speech_dbus_meth;
+ return this;
}
-void
-plugin_init(void)
-{
- plugin_register_category_speech("dbus", speech_dbus_new);
+void plugin_init(void) {
+ plugin_register_category_speech("dbus", speech_dbus_new);
}
diff --git a/navit/speech/espeak/speak.c b/navit/speech/espeak/speak.c
index 329a05d01..1aebcf318 100644
--- a/navit/speech/espeak/speak.c
+++ b/navit/speech/espeak/speak.c
@@ -56,287 +56,247 @@ int (* uri_callback)(int, const char *, const char *) = NULL;
int (* phoneme_callback)(const char *) = NULL;
FILE *f_wave = NULL;
-int GetFileLength(const char *filename)
-{
- struct stat statbuf;
+int GetFileLength(const char *filename) {
+ struct stat statbuf;
- if(stat(filename,&statbuf) != 0)
- return(0);
+ if(stat(filename,&statbuf) != 0)
+ return(0);
- if((statbuf.st_mode & S_IFMT) == S_IFDIR)
- return(-2); // a directory
+ if((statbuf.st_mode & S_IFMT) == S_IFDIR)
+ return(-2); // a directory
- return(statbuf.st_size);
+ return(statbuf.st_size);
}
-void MarkerEvent(int type, unsigned int char_position, int value, unsigned char *out_ptr)
-{
+void MarkerEvent(int type, unsigned int char_position, int value, int value2, unsigned char *out_ptr){
}
-char *Alloc(int size)
-{
- return g_malloc(size);
+char *Alloc(int size) {
+ return g_malloc(size);
}
-void Free(void *ptr)
-{
- g_free(ptr);
+void Free(void *ptr) {
+ g_free(ptr);
}
// --------------------------------------------------------------------
-enum speech_messages
-{
- msg_say = WM_USER,
- msg_exit
+enum speech_messages {
+ msg_say = WM_USER,
+ msg_exit
};
-enum speech_state
-{
- state_available,
- state_speaking_phase_1,
- state_speaking_phase_2,
- state_speaking_phase_3
+enum speech_state {
+ state_available,
+ state_speaking_phase_1,
+ state_speaking_phase_2,
+ state_speaking_phase_3
};
struct speech_priv {
- GList *free_buffers;
- HWAVEOUT h_wave_out;
- enum speech_state state;
- GList *phrases;
- HWND h_queue;
- HANDLE h_message_thread;
+ GList *free_buffers;
+ HWAVEOUT h_wave_out;
+ enum speech_state state;
+ GList *phrases;
+ HWND h_queue;
+ HANDLE h_message_thread;
};
-static void waveout_close(struct speech_priv* sp_priv)
-{
- waveOutClose(sp_priv->h_wave_out);
+static void waveout_close(struct speech_priv* sp_priv) {
+ waveOutClose(sp_priv->h_wave_out);
}
-static BOOL waveout_open(struct speech_priv* sp_priv)
-{
- MMRESULT result = 0;
-
- HWAVEOUT hwo;
- static WAVEFORMATEX wmTemp;
- wmTemp.wFormatTag = WAVE_FORMAT_PCM;
- wmTemp.nChannels = 1;
- wmTemp.nSamplesPerSec = 22050;
- wmTemp.wBitsPerSample = 16;
- wmTemp.nBlockAlign = wmTemp.nChannels * wmTemp.wBitsPerSample / 8;
- wmTemp.nAvgBytesPerSec = wmTemp.nSamplesPerSec * wmTemp.nBlockAlign;
- wmTemp.cbSize = 0;
- result = waveOutOpen(&hwo, (UINT) WAVE_MAPPER, &wmTemp, (DWORD)sp_priv->h_queue, (DWORD)sp_priv, CALLBACK_WINDOW);
- sp_priv->h_wave_out = hwo;
-
- return (result==MMSYSERR_NOERROR);
+static BOOL waveout_open(struct speech_priv* sp_priv) {
+ MMRESULT result = 0;
+
+ HWAVEOUT hwo;
+ static WAVEFORMATEX wmTemp;
+ wmTemp.wFormatTag = WAVE_FORMAT_PCM;
+ wmTemp.nChannels = 1;
+ wmTemp.nSamplesPerSec = 22050;
+ wmTemp.wBitsPerSample = 16;
+ wmTemp.nBlockAlign = wmTemp.nChannels * wmTemp.wBitsPerSample / 8;
+ wmTemp.nAvgBytesPerSec = wmTemp.nSamplesPerSec * wmTemp.nBlockAlign;
+ wmTemp.cbSize = 0;
+ result = waveOutOpen(&hwo, (UINT) WAVE_MAPPER, &wmTemp, (DWORD)sp_priv->h_queue, (DWORD)sp_priv, CALLBACK_WINDOW);
+ sp_priv->h_wave_out = hwo;
+
+ return (result==MMSYSERR_NOERROR);
}
-static int wave_out(struct speech_priv* sp_priv)
-{
- int isDone;
+static int wave_out(struct speech_priv* sp_priv) {
+ int isDone;
- WAVEHDR *WaveHeader = g_list_first(sp_priv->free_buffers)->data;
- sp_priv->free_buffers = g_list_remove(sp_priv->free_buffers, WaveHeader);
+ WAVEHDR *WaveHeader = g_list_first(sp_priv->free_buffers)->data;
+ sp_priv->free_buffers = g_list_remove(sp_priv->free_buffers, WaveHeader);
- out_ptr = out_start = WaveHeader->lpData;
- out_end = WaveHeader->lpData + WaveHeader->dwBufferLength;
+ out_ptr = out_start = WaveHeader->lpData;
+ out_end = WaveHeader->lpData + WaveHeader->dwBufferLength;
- isDone = WavegenFill(0);
+ isDone = WavegenFill(0);
- if ( out_ptr < out_end )
- {
- memset ( out_ptr, 0, out_end - out_ptr );
- }
- waveOutWrite(sp_priv->h_wave_out, WaveHeader, sizeof(WAVEHDR));
+ if ( out_ptr < out_end ) {
+ memset ( out_ptr, 0, out_end - out_ptr );
+ }
+ waveOutWrite(sp_priv->h_wave_out, WaveHeader, sizeof(WAVEHDR));
- return isDone;
+ return isDone;
}
-static BOOL initialise(void)
-{
- int param;
- int result;
-
- WavegenInit(22050,0); // 22050
- if((result = LoadPhData()) != 1)
- {
- if(result == -1)
- {
- dbg(lvl_error, "Failed to load espeak-data\n");
- return FALSE;
- }
- else
- dbg(lvl_error, "Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home);
- }
- LoadConfig();
- SetVoiceStack(NULL);
- SynthesizeInit();
-
- for(param=0; param<N_SPEECH_PARAM; param++)
- param_stack[0].parameter[param] = param_defaults[param];
-
- return TRUE;
+static BOOL initialise(void) {
+ int param;
+ int result;
+
+ WavegenInit(22050,0); // 22050
+ if((result = LoadPhData(NULL)) != 1) {
+ if(result == -1) {
+ dbg(lvl_error, "Failed to load espeak-data");
+ return FALSE;
+ } else
+ dbg(lvl_error, "Wrong version of espeak-data 0x%x (expects 0x%x) at %s",result,version_phdata,path_home);
+ }
+ LoadConfig();
+ SetVoiceStack(NULL, "");
+ SynthesizeInit();
+
+ for(param=0; param<N_SPEECH_PARAM; param++)
+ param_stack[0].parameter[param] = param_defaults[param];
+
+ return TRUE;
}
-static void fill_buffer(struct speech_priv *this)
-{
- while ( this->free_buffers && this->state != state_speaking_phase_3 )
- {
- if(Generate(phoneme_list,&n_phoneme_list,1)==0)
- {
- if (!SpeakNextClause(NULL,NULL,1))
- {
- this->state = state_speaking_phase_2;
- }
- }
-
- if ( wave_out(this)!= 0 && this->state == state_speaking_phase_2)
- {
- this->state = state_speaking_phase_3;
- }
- }
+static void fill_buffer(struct speech_priv *this) {
+ while ( this->free_buffers && this->state != state_speaking_phase_3 ) {
+ if(Generate(phoneme_list,&n_phoneme_list,1)==0) {
+ if (!SpeakNextClause(NULL,NULL,1)) {
+ this->state = state_speaking_phase_2;
+ }
+ }
+
+ if ( wave_out(this)!= 0 && this->state == state_speaking_phase_2) {
+ this->state = state_speaking_phase_3;
+ }
+ }
}
-static void start_speaking(struct speech_priv* sp_priv)
-{
- char *phrase = g_list_first(sp_priv->phrases)->data;
+static void start_speaking(struct speech_priv* sp_priv) {
+ char *phrase = g_list_first(sp_priv->phrases)->data;
- sp_priv->state = state_speaking_phase_1;
+ sp_priv->state = state_speaking_phase_1;
- SpeakNextClause(NULL, phrase,0);
- wave_out(sp_priv);
- fill_buffer(sp_priv);
+ SpeakNextClause(NULL, phrase,0);
+ wave_out(sp_priv);
+ fill_buffer(sp_priv);
}
-static LRESULT CALLBACK speech_message_handler( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
-{
- dbg(lvl_debug, "message_handler called\n");
-
- switch (uMsg)
- {
- case msg_say:
- {
- struct speech_priv* sp_priv = (struct speech_priv*)wParam;
- sp_priv->phrases = g_list_append(sp_priv->phrases, (char*)lParam);
-
- if ( sp_priv->state == state_available )
- {
- start_speaking(sp_priv);
- }
-
- }
- break;
- case MM_WOM_DONE:
- {
- WAVEHDR *WaveHeader = (WAVEHDR *)lParam;
- struct speech_priv* sp_priv;
- dbg(lvl_info, "Wave buffer done\n");
-
- sp_priv = (struct speech_priv*)WaveHeader->dwUser;
- sp_priv->free_buffers = g_list_append(sp_priv->free_buffers, WaveHeader);
-
- if ( sp_priv->state != state_speaking_phase_3)
- {
- fill_buffer(sp_priv);
- }
- else if ( g_list_length(sp_priv->free_buffers) == BUFFERS && sp_priv->state == state_speaking_phase_3 )
- {
- // remove the spoken phrase from the list
- char *phrase = g_list_first(sp_priv->phrases)->data;
- g_free( phrase );
- sp_priv->phrases = g_list_remove(sp_priv->phrases, phrase);
-
- if ( sp_priv->phrases )
- {
- start_speaking(sp_priv);
- }
- else
- {
- sp_priv->state = state_available;
- }
- }
- }
- break;
- case msg_exit:
- ExitThread(0);
- break;
-
- default:
- break;
-
- }
-
- return TRUE;
+static LRESULT CALLBACK speech_message_handler( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
+ dbg(lvl_debug, "message_handler called");
+
+ switch (uMsg) {
+ case msg_say: {
+ struct speech_priv* sp_priv = (struct speech_priv*)wParam;
+ sp_priv->phrases = g_list_append(sp_priv->phrases, (char*)lParam);
+
+ if ( sp_priv->state == state_available ) {
+ start_speaking(sp_priv);
+ }
+
+ }
+ break;
+ case MM_WOM_DONE: {
+ WAVEHDR *WaveHeader = (WAVEHDR *)lParam;
+ struct speech_priv* sp_priv;
+ dbg(lvl_info, "Wave buffer done");
+
+ sp_priv = (struct speech_priv*)WaveHeader->dwUser;
+ sp_priv->free_buffers = g_list_append(sp_priv->free_buffers, WaveHeader);
+
+ if ( sp_priv->state != state_speaking_phase_3) {
+ fill_buffer(sp_priv);
+ } else if ( g_list_length(sp_priv->free_buffers) == BUFFERS && sp_priv->state == state_speaking_phase_3 ) {
+ // remove the spoken phrase from the list
+ char *phrase = g_list_first(sp_priv->phrases)->data;
+ g_free( phrase );
+ sp_priv->phrases = g_list_remove(sp_priv->phrases, phrase);
+
+ if ( sp_priv->phrases ) {
+ start_speaking(sp_priv);
+ } else {
+ sp_priv->state = state_available;
+ }
+ }
+ }
+ break;
+ case msg_exit:
+ ExitThread(0);
+ break;
+
+ default:
+ break;
+
+ }
+
+ return TRUE;
}
-static void speech_message_dispatcher( struct speech_priv * sp_priv)
-{
- BOOL bRet;
- MSG msg;
+static void speech_message_dispatcher( struct speech_priv * sp_priv) {
+ BOOL bRet;
+ MSG msg;
- while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
- {
- if (bRet == -1)
- {
- dbg(lvl_error, "Error getting message from queue\n");
+ while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) {
+ if (bRet == -1) {
+ dbg(lvl_error, "Error getting message from queue");
break;
- }
- else
- {
+ } else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
-static void create_buffers(struct speech_priv *sp_priv)
-{
- int buffer_counter;
- char *buffer_head;
+static void create_buffers(struct speech_priv *sp_priv) {
+ int buffer_counter;
+ char *buffer_head;
SYSTEM_INFO system_info;
GetSystemInfo (&system_info);
- buffer_head = VirtualAlloc(0, system_info.dwPageSize * BUFFERS, MEM_RESERVE, PAGE_NOACCESS);
+ buffer_head = VirtualAlloc(0, system_info.dwPageSize * BUFFERS, MEM_RESERVE, PAGE_NOACCESS);
- for (buffer_counter = 0; buffer_counter < BUFFERS; buffer_counter++)
- {
- WAVEHDR *WaveHeader = g_new0(WAVEHDR, 1);
+ for (buffer_counter = 0; buffer_counter < BUFFERS; buffer_counter++) {
+ WAVEHDR *WaveHeader = g_new0(WAVEHDR, 1);
- WaveHeader->dwBufferLength = system_info.dwPageSize;
- WaveHeader->lpData = (char *)VirtualAlloc(buffer_head, WaveHeader->dwBufferLength, MEM_COMMIT, PAGE_READWRITE);
- buffer_head += WaveHeader->dwBufferLength;
+ WaveHeader->dwBufferLength = system_info.dwPageSize;
+ WaveHeader->lpData = (char *)VirtualAlloc(buffer_head, WaveHeader->dwBufferLength, MEM_COMMIT, PAGE_READWRITE);
+ buffer_head += WaveHeader->dwBufferLength;
- WaveHeader->dwUser = (DWORD)sp_priv;
- waveOutPrepareHeader(sp_priv->h_wave_out, WaveHeader, sizeof(WAVEHDR));
+ WaveHeader->dwUser = (DWORD)sp_priv;
+ waveOutPrepareHeader(sp_priv->h_wave_out, WaveHeader, sizeof(WAVEHDR));
- sp_priv->free_buffers = g_list_append( sp_priv->free_buffers, WaveHeader );
- }
+ sp_priv->free_buffers = g_list_append( sp_priv->free_buffers, WaveHeader );
+ }
}
-static DWORD startThread( LPVOID sp_priv)
-{
- struct speech_priv *this = (struct speech_priv *) sp_priv;
- // Create message queue
- TCHAR *g_szClassName = TEXT("SpeechQueue");
+static DWORD startThread( LPVOID sp_priv) {
+ struct speech_priv *this = (struct speech_priv *) sp_priv;
+ // Create message queue
+ TCHAR *g_szClassName = TEXT("SpeechQueue");
WNDCLASS wc;
HWND hwnd;
- HWND hWndParent;
+ HWND hWndParent;
- memset(&wc, 0 , sizeof(WNDCLASS));
+ memset(&wc, 0, sizeof(WNDCLASS));
wc.lpfnWndProc = speech_message_handler;
wc.hInstance = GetModuleHandle(NULL);
wc.lpszClassName = g_szClassName;
- if (!RegisterClass(&wc))
- {
- dbg(lvl_error, "Window registration for message queue failed\n");
+ if (!RegisterClass(&wc)) {
+ dbg(lvl_error, "Window registration for message queue failed");
return 1;
}
@@ -347,172 +307,158 @@ static DWORD startThread( LPVOID sp_priv)
// create a message only window
hwnd = CreateWindow(
- g_szClassName,
- TEXT("Navit"),
- 0,
- 0,
- 0,
- 0,
- 0,
- hWndParent,
- NULL,
- GetModuleHandle(NULL),
- NULL);
-
- if (hwnd == NULL)
- {
- dbg(lvl_error, "Window creation failed: %d\n", GetLastError());
+ g_szClassName,
+ TEXT("Navit"),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ hWndParent,
+ NULL,
+ GetModuleHandle(NULL),
+ NULL);
+
+ if (hwnd == NULL) {
+ dbg(lvl_error, "Window creation failed: %d", GetLastError());
return 1;
}
this->h_queue = hwnd;
- this->phrases = NULL;
- this->state = state_available;
+ this->phrases = NULL;
+ this->state = state_available;
- if(!waveout_open(this))
- {
- dbg(lvl_error, "Can't open wave output\n");
- return 1;
- }
+ if(!waveout_open(this)) {
+ dbg(lvl_error, "Can't open wave output");
+ return 1;
+ }
- this->free_buffers = NULL;
- create_buffers(this);
+ this->free_buffers = NULL;
+ create_buffers(this);
- speech_message_dispatcher(this);
+ speech_message_dispatcher(this);
return 0;
}
-static int
-espeak_say(struct speech_priv *this, const char *text)
-{
- char *phrase = g_strdup(text);
- dbg(lvl_debug, "Speak: '%s'\n", text);
+static int espeak_say(struct speech_priv *this, const char *text) {
+ char *phrase = g_strdup(text);
+ dbg(lvl_debug, "Speak: '%s'", text);
- if (!PostMessage(this->h_queue, msg_say, (WPARAM)this, (LPARAM)phrase))
- {
- dbg(lvl_error, "PostThreadMessage 'say' failed\n");
- }
+ if (!PostMessage(this->h_queue, msg_say, (WPARAM)this, (LPARAM)phrase)) {
+ dbg(lvl_error, "PostThreadMessage 'say' failed");
+ }
- return 0;
+ return 0;
}
-static void free_list(gpointer pointer, gpointer this )
-{
- if ( this )
- {
- struct speech_priv *sp_priv = (struct speech_priv *)this;
- WAVEHDR *WaveHeader = (WAVEHDR *)pointer;
-
- waveOutUnprepareHeader(sp_priv->h_wave_out, WaveHeader, sizeof(WAVEHDR));
- VirtualFree(WaveHeader->lpData, WaveHeader->dwBufferLength, MEM_DECOMMIT);
- }
- g_free(pointer);
+static void free_list(gpointer pointer, gpointer this ) {
+ if ( this ) {
+ struct speech_priv *sp_priv = (struct speech_priv *)this;
+ WAVEHDR *WaveHeader = (WAVEHDR *)pointer;
+
+ waveOutUnprepareHeader(sp_priv->h_wave_out, WaveHeader, sizeof(WAVEHDR));
+ VirtualFree(WaveHeader->lpData, WaveHeader->dwBufferLength, MEM_DECOMMIT);
+ }
+ g_free(pointer);
}
-static void
-espeak_destroy(struct speech_priv *this)
-{
- g_list_foreach( this->free_buffers, free_list, (gpointer)this );
- g_list_free( this->free_buffers );
+static void espeak_destroy(struct speech_priv *this) {
+ g_list_foreach( this->free_buffers, free_list, (gpointer)this );
+ g_list_free( this->free_buffers );
- g_list_foreach( this->phrases, free_list, 0 );
- g_list_free(this->phrases);
+ g_list_foreach( this->phrases, free_list, 0 );
+ g_list_free(this->phrases);
- waveout_close(this);
- g_free(this);
+ waveout_close(this);
+ g_free(this);
}
static struct speech_methods espeak_meth = {
- espeak_destroy,
- espeak_say,
+ espeak_destroy,
+ espeak_say,
};
-static struct speech_priv *
-espeak_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
- struct speech_priv *this = NULL;
- struct attr *path;
- struct attr *language;
- char *lang_str=NULL;
-
- path=attr_search(attrs, NULL, attr_path);
- if (path)
- strcpy(path_home,path->u.str);
- else
- sprintf(path_home,"%s/espeak-data",getenv("NAVIT_SHAREDIR"));
- dbg(lvl_debug,"path_home set to %s\n",path_home);
-
- if ( !initialise() )
- {
- return NULL;
- }
-
- language=attr_search(attrs, NULL, attr_language);
- if ( language ) {
- lang_str=g_strdup(language->u.str);
- } else {
- char *lang_env=getenv("LANG");
-
- if (lang_env) {
- char *country,*lang,*lang_full;
- char *file1;
- char *file2;
- lang_full=g_strdup(lang_env);
- strtolower(lang_full,lang_env);
- lang=g_strdup(lang_full);
- country=strchr(lang_full,'_');
- if (country) {
- lang[country-lang_full]='\0';
- *country++='-';
- }
- file1=g_strdup_printf("%s/voices/%s",path_home,lang_full);
- file2=g_strdup_printf("%s/voices/%s/%s",path_home,lang,lang_full);
- dbg(lvl_debug,"Testing %s and %s\n",file1,file2);
- if (file_exists(file1) || file_exists(file2))
- lang_str=g_strdup(lang_full);
- else
- lang_str=g_strdup(lang);
- dbg(lvl_debug,"Language full %s lang %s result %s\n",lang_full,lang,lang_str);
- g_free(lang_full);
- g_free(lang);
- g_free(file1);
- g_free(file2);
- }
- }
- if(lang_str && SetVoiceByName(lang_str) != EE_OK)
- {
- dbg(lvl_error, "Error setting language to: '%s',falling back to default\n", lang_str);
- g_free(lang_str);
- lang_str=NULL;
- }
- if(!lang_str && SetVoiceByName("default") != EE_OK) {
- dbg(lvl_error, "Error setting language to default\n");
- }
-
-
- SetParameter(espeakRATE,170,0);
- SetParameter(espeakVOLUME,100,0);
- SetParameter(espeakCAPITALS,option_capitals,0);
- SetParameter(espeakPUNCTUATION,option_punctuation,0);
- SetParameter(espeakWORDGAP,0,0);
+static struct speech_priv *espeak_new(struct speech_methods *meth, struct attr **attrs, struct attr *parent) {
+ struct speech_priv *this = NULL;
+ struct attr *path;
+ struct attr *language;
+ char *lang_str=NULL;
+
+ path=attr_search(attrs, NULL, attr_path);
+ if (path)
+ strcpy(path_home,path->u.str);
+ else
+ sprintf(path_home,"%s/espeak-data",getenv("NAVIT_SHAREDIR"));
+ dbg(lvl_debug,"path_home set to %s",path_home);
+
+ if ( !initialise() ) {
+ return NULL;
+ }
+
+ language=attr_search(attrs, NULL, attr_language);
+ if ( language ) {
+ lang_str=g_strdup(language->u.str);
+ } else {
+ char *lang_env=getenv("LANG");
+
+ if (lang_env) {
+ char *country,*lang,*lang_full;
+ char *file1;
+ char *file2;
+ lang_full=g_strdup(lang_env);
+ strtolower(lang_full,lang_env);
+ lang=g_strdup(lang_full);
+ country=strchr(lang_full,'_');
+ if (country) {
+ lang[country-lang_full]='\0';
+ *country++='-';
+ }
+ file1=g_strdup_printf("%s/voices/%s",path_home,lang_full);
+ file2=g_strdup_printf("%s/voices/%s/%s",path_home,lang,lang_full);
+ dbg(lvl_debug,"Testing %s and %s",file1,file2);
+ if (file_exists(file1) || file_exists(file2))
+ lang_str=g_strdup(lang_full);
+ else
+ lang_str=g_strdup(lang);
+ dbg(lvl_debug,"Language full %s lang %s result %s",lang_full,lang,lang_str);
+ g_free(lang_full);
+ g_free(lang);
+ g_free(file1);
+ g_free(file2);
+ }
+ }
+ if(lang_str && SetVoiceByName(lang_str) != EE_OK) {
+ dbg(lvl_error, "Error setting language to: '%s',falling back to default", lang_str);
+ g_free(lang_str);
+ lang_str=NULL;
+ }
+ if(!lang_str && SetVoiceByName("default") != EE_OK) {
+ dbg(lvl_error, "Error setting language to default");
+ }
+
+
+ SetParameter(espeakRATE,170,0);
+ SetParameter(espeakVOLUME,100,0);
+ SetParameter(espeakCAPITALS,option_capitals,0);
+ SetParameter(espeakPUNCTUATION,option_punctuation,0);
+ SetParameter(espeakWORDGAP,0,0);
// if(pitch_adjustment != 50)
// {
// SetParameter(espeakPITCH,pitch_adjustment,0);
// }
- DoVoiceChange(voice);
+ DoVoiceChange(voice);
- this=g_new(struct speech_priv,1);
- this->h_message_thread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)startThread, (PVOID)this, 0, NULL);
+ this=g_new(struct speech_priv,1);
+ this->h_message_thread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)startThread, (PVOID)this, 0, NULL);
- *meth=espeak_meth;
+ *meth=espeak_meth;
- return this;
+ return this;
}
-void
-plugin_init(void)
-{
- plugin_register_category_speech("espeak", espeak_new);
+void plugin_init(void) {
+ plugin_register_category_speech("espeak", espeak_new);
}
diff --git a/navit/speech/iphone/speech_iphone.m b/navit/speech/iphone/speech_iphone.m
index c77b6fbc2..571f6784b 100644
--- a/navit/speech/iphone/speech_iphone.m
+++ b/navit/speech/iphone/speech_iphone.m
@@ -30,18 +30,18 @@ struct speech_priv {
VSSpeechSynthesizer *speech;
};
-static int
+static int
speech_iphone_say(struct speech_priv *this, const char *text)
{
- dbg(0,"enter %s\n",text);
+ dbg(0,"enter %s",text);
NSString *s=[[NSString alloc]initWithUTF8String: text];
[this->speech startSpeakingString:s toURL:nil];
[s release];
- dbg(0,"ok\n");
+ dbg(0,"ok");
return 1;
}
-static void
+static void
speech_iphone_destroy(struct speech_priv *this)
{
[this->speech release];
@@ -60,7 +60,7 @@ speech_iphone_new(struct speech_methods *meth, struct attr **attrs, struct attr
*meth=speech_iphone_meth;
this=g_new0(struct speech_priv,1);
this->speech=[[NSClassFromString(@"VSSpeechSynthesizer") alloc] init];
- dbg(0,"this->speech=%p\n",this->speech);
+ dbg(0,"this->speech=%p",this->speech);
[this->speech setRate:(float)1.0];
return this;
}
@@ -69,6 +69,6 @@ speech_iphone_new(struct speech_methods *meth, struct attr **attrs, struct attr
void
plugin_init(void)
{
- dbg(0,"enter\n");
+ dbg(0,"enter");
plugin_register_category_speech("iphone", speech_iphone_new);
}
diff --git a/navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp b/navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp
index da2c6b3e1..a5e488391 100644
--- a/navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp
+++ b/navit/speech/qt5_espeak/Qt5EspeakAudioOut.cpp
@@ -23,8 +23,7 @@ extern "C" {
#include "debug.h"
}
-Qt5EspeakAudioOut::Qt5EspeakAudioOut(int samplerate, const char* category)
-{
+Qt5EspeakAudioOut::Qt5EspeakAudioOut(int samplerate, const char* category) {
data = new QByteArray();
buffer = new QBuffer(data);
buffer->open(QIODevice::ReadWrite);
@@ -41,31 +40,30 @@ Qt5EspeakAudioOut::Qt5EspeakAudioOut(int samplerate, const char* category)
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format)) {
dbg(lvl_error,
- "Raw audio format not supported by backend, cannot play audio.\n");
+ "Raw audio format not supported by backend, cannot play audio.");
return;
}
audio = new QAudioOutput(format, this);
/* try to set a rather huge buffer size in order to avoid chopping due to
- * event loop
- * not getting idle. Drawing may take just too long time. This hopefully
- * removes the
- * need to do multi threading with all its problems. May be a problem on
- * systems with
- * really low memory.*/
+ * event loop
+ * not getting idle. Drawing may take just too long time. This hopefully
+ * removes the
+ * need to do multi threading with all its problems. May be a problem on
+ * systems with
+ * really low memory.*/
audio->setBufferSize((samplerate * 1 /*ch*/ * 2 /*samplezize*/) * 5 /*seconds*/);
- dbg(lvl_debug, "Buffer size is: %d\n", audio->bufferSize());
+ dbg(lvl_debug, "Buffer size is: %d", audio->bufferSize());
if (category != NULL)
audio->setCategory(QString(category));
connect(audio, SIGNAL(stateChanged(QAudio::State)), this,
- SLOT(handleStateChanged(QAudio::State)));
+ SLOT(handleStateChanged(QAudio::State)));
/* to cope with resume coming from other thread (of libespeak)*/
connect(this, SIGNAL(call_resume(int)), this, SLOT(resume(int)));
}
-Qt5EspeakAudioOut::~Qt5EspeakAudioOut()
-{
+Qt5EspeakAudioOut::~Qt5EspeakAudioOut() {
delete (audio);
audio = NULL;
delete (buffer);
@@ -74,9 +72,8 @@ Qt5EspeakAudioOut::~Qt5EspeakAudioOut()
data = NULL;
}
-void Qt5EspeakAudioOut::handleStateChanged(QAudio::State newState)
-{
- dbg(lvl_debug, "Enter %d\n", newState);
+void Qt5EspeakAudioOut::handleStateChanged(QAudio::State newState) {
+ dbg(lvl_debug, "Enter %d", newState);
switch (newState) {
case QAudio::ActiveState:
break;
@@ -88,21 +85,19 @@ void Qt5EspeakAudioOut::handleStateChanged(QAudio::State newState)
/*remove all data that was already read*/
data->remove(0, buffer->pos());
buffer->seek(0);
- dbg(lvl_debug, "Size %d\n", data->size());
+ dbg(lvl_debug, "Size %d", data->size());
break;
}
}
-void Qt5EspeakAudioOut::resume(int state)
-{
- dbg(lvl_debug, "Enter %d\n", state);
+void Qt5EspeakAudioOut::resume(int state) {
+ dbg(lvl_debug, "Enter %d", state);
if (audio->state() != QAudio::ActiveState)
audio->start(buffer);
}
-void Qt5EspeakAudioOut::addSamples(short* wav, int numsamples)
-{
- dbg(lvl_debug, "Enter (%d samples)\n", numsamples);
+void Qt5EspeakAudioOut::addSamples(short* wav, int numsamples) {
+ dbg(lvl_debug, "Enter (%d samples)", numsamples);
/*remove all data that was already read (if any)*/
data->remove(0, buffer->pos());
@@ -110,7 +105,7 @@ void Qt5EspeakAudioOut::addSamples(short* wav, int numsamples)
if (numsamples > 0) {
data->append((const char*)wav, numsamples * sizeof(short));
- dbg(lvl_debug, "%ld samples in buffer\n",
+ dbg(lvl_debug, "%ld samples in buffer",
(long int)(buffer->size() / sizeof(short)));
emit call_resume(numsamples);
}
diff --git a/navit/speech/qt5_espeak/qt5_espeak.cpp b/navit/speech/qt5_espeak/qt5_espeak.cpp
index 8d108eae6..a0372ff39 100755
--- a/navit/speech/qt5_espeak/qt5_espeak.cpp
+++ b/navit/speech/qt5_espeak/qt5_espeak.cpp
@@ -56,10 +56,9 @@ struct speech_priv {
};
/* callback from espeak to transfer generated samples */
-int qt5_espeak_SynthCallback(short* wav, int numsamples, espeak_EVENT* events)
-{
+int qt5_espeak_SynthCallback(short* wav, int numsamples, espeak_EVENT* events) {
struct speech_priv* pr = NULL;
- dbg(lvl_debug, "Callback %d samples\n", numsamples);
+ dbg(lvl_debug, "Callback %d samples", numsamples);
if (events != NULL)
pr = (struct speech_priv*)events->user_data;
if ((pr != NULL) && (pr->audio != NULL)) {
@@ -72,9 +71,7 @@ int qt5_espeak_SynthCallback(short* wav, int numsamples, espeak_EVENT* events)
}
/* set up espeak */
-static bool
-qt5_espeak_init_espeak(struct speech_priv* sr, struct attr** attrs)
-{
+static bool qt5_espeak_init_espeak(struct speech_priv* sr, struct attr** attrs) {
struct attr* path;
/* prepare espeak library path home */
@@ -86,12 +83,12 @@ qt5_espeak_init_espeak(struct speech_priv* sr, struct attr** attrs)
sr->path_home = g_strdup_printf("%s", getenv("NAVIT_SHAREDIR"));
#else
/* since no path was given by config, we don't know the path to external
- * espeak data.
- * so give NULL to use default path */
+ * espeak data.
+ * so give NULL to use default path */
sr->path_home = NULL;
#endif
}
- dbg(lvl_debug, "path_home set to %s\n", sr->path_home);
+ dbg(lvl_debug, "path_home set to %s", sr->path_home);
#if INTERNAL_ESPEAK
/*internal espeak is configured to support only synchronous modes */
sr->sample_rate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS, BUFFERLENGTH, sr->path_home, 0);
@@ -101,19 +98,17 @@ qt5_espeak_init_espeak(struct speech_priv* sr, struct attr** attrs)
sr->sample_rate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS, BUFFERLENGTH, sr->path_home, 0);
#endif
if (sr->sample_rate == EE_INTERNAL_ERROR) {
- dbg(lvl_error, "Init failed %d\n", sr->sample_rate);
+ dbg(lvl_error, "Init failed %d", sr->sample_rate);
return 1;
}
- dbg(lvl_error, "Sample rate is %d\n", sr->sample_rate);
+ dbg(lvl_error, "Sample rate is %d", sr->sample_rate);
espeak_SetSynthCallback(qt5_espeak_SynthCallback);
return TRUE;
}
/* set language to espeak */
-static bool
-qt5_espeak_init_language(struct speech_priv* pr, struct attr** attrs)
-{
+static bool qt5_espeak_init_language(struct speech_priv* pr, struct attr** attrs) {
struct attr* language;
gchar* lang_str = NULL;
espeak_ERROR error;
@@ -132,13 +127,13 @@ qt5_espeak_init_language(struct speech_priv* pr, struct attr** attrs)
strtolower(lang_str, lang_env);
/* extract language code from LANG environment */
- dbg(lvl_debug, "%s\n", lang_str);
+ dbg(lvl_debug, "%s", lang_str);
country = strchr(lang_str, '_');
- dbg(lvl_debug, "%s\n", country);
+ dbg(lvl_debug, "%s", country);
if (country) {
lang_str[country - lang_str] = '\0';
}
- dbg(lvl_debug, "espeak lang: %s\n", lang_str);
+ dbg(lvl_debug, "espeak lang: %s", lang_str);
}
}
/*TODO (golden water tap): expose all those values as attrs */
@@ -152,16 +147,14 @@ qt5_espeak_init_language(struct speech_priv* pr, struct attr** attrs)
if (lang_str != NULL)
g_free(lang_str);
if (error != EE_OK) {
- dbg(lvl_error, "Unable to set Language\n");
+ dbg(lvl_error, "Unable to set Language");
return false;
}
return true;
}
/* init audio system */
-static bool
-qt5_espeak_init_audio(struct speech_priv* sr, const char* category)
-{
+static bool qt5_espeak_init_audio(struct speech_priv* sr, const char* category) {
try {
sr->audio = new Qt5EspeakAudioOut(sr->sample_rate, category);
} catch (void* exception) {
@@ -175,24 +168,20 @@ qt5_espeak_init_audio(struct speech_priv* sr, const char* category)
* sr - private handle
* text - new (utf8) text
*/
-static int
-qt5_espeak_say(struct speech_priv* sr, const char* text)
-{
+static int qt5_espeak_say(struct speech_priv* sr, const char* text) {
espeak_ERROR error;
- dbg(lvl_debug, "Say \"%s\"\n", text);
+ dbg(lvl_debug, "Say \"%s\"", text);
error = espeak_Synth(text, strlen(text), 0, POS_CHARACTER, 0,
- espeakCHARS_UTF8, NULL, sr);
+ espeakCHARS_UTF8, NULL, sr);
if (error != EE_OK)
- dbg(lvl_error, "Unable to speak! error == %d\n", error);
+ dbg(lvl_error, "Unable to speak! error == %d", error);
return 0;
}
/* destructor */
-static void
-qt5_espeak_destroy(struct speech_priv* sr)
-{
- dbg(lvl_debug, "Enter\n");
+static void qt5_espeak_destroy(struct speech_priv* sr) {
+ dbg(lvl_debug, "Enter");
if (sr->path_home != NULL)
g_free(sr->path_home);
@@ -210,12 +199,10 @@ static struct speech_methods qt5_espeak_meth = {
* attr - get decoded attributes from config
* parent - get parent attributes from config
*/
-static struct speech_priv*
-qt5_espeak_new(struct speech_methods* meth, struct attr** attrs,
- struct attr* parent)
-{
+static struct speech_priv* qt5_espeak_new(struct speech_methods* meth, struct attr** attrs,
+ struct attr* parent) {
struct speech_priv* sr = NULL;
- dbg(lvl_debug, "Enter\n");
+ dbg(lvl_debug, "Enter");
/* allocate handle */
sr = g_new0(struct speech_priv, 1);
@@ -229,24 +216,23 @@ qt5_espeak_new(struct speech_methods* meth, struct attr** attrs,
/* init espeak library */
if (!(sr->espeak_ok = qt5_espeak_init_espeak(sr, attrs))) {
- dbg(lvl_error, "Unable to initialize espeak library\n");
+ dbg(lvl_error, "Unable to initialize espeak library");
}
/* init espeak voice and language */
if (!(sr->espeak_ok = qt5_espeak_init_language(sr, attrs))) {
- dbg(lvl_error, "Unable to initialize espeak language\n");
+ dbg(lvl_error, "Unable to initialize espeak language");
}
/* init qt5 audio using default category*/
if (!(sr->audio_ok = qt5_espeak_init_audio(sr, NULL))) {
- dbg(lvl_error, "Unable to initialize audio\n");
+ dbg(lvl_error, "Unable to initialize audio");
}
return sr;
}
/* initialize this as plugin */
-void plugin_init(void)
-{
- dbg(lvl_debug, "Enter\n");
+void plugin_init(void) {
+ dbg(lvl_debug, "Enter");
plugin_register_category_speech("qt5_espeak", qt5_espeak_new);
}
diff --git a/navit/speech/speech_dispatcher/speech_speech_dispatcher.c b/navit/speech/speech_dispatcher/speech_speech_dispatcher.c
index d22b3f795..c7b38a26d 100644
--- a/navit/speech/speech_dispatcher/speech_speech_dispatcher.c
+++ b/navit/speech/speech_dispatcher/speech_speech_dispatcher.c
@@ -32,50 +32,45 @@
#include "speech.h"
struct speech_priv {
- SPDConnection *conn;
+ SPDConnection *conn;
};
-static int
-speechd_say(struct speech_priv *this, const char *text) {
- int err;
+static int speechd_say(struct speech_priv *this, const char *text) {
+ int err;
- err = spd_sayf(this->conn, SPD_MESSAGE, text);
- if (err != 1)
- return 1;
- return 0;
+ err = spd_sayf(this->conn, SPD_MESSAGE, text);
+ if (err != 1)
+ return 1;
+ return 0;
}
-static void
-speechd_destroy(struct speech_priv *this) {
- spd_close(this->conn);
- g_free(this);
+static void speechd_destroy(struct speech_priv *this) {
+ spd_close(this->conn);
+ g_free(this);
}
static struct speech_methods speechd_meth = {
- speechd_destroy,
- speechd_say,
+ speechd_destroy,
+ speechd_say,
};
-static struct speech_priv *
-speechd_new(struct speech_methods *meth, struct attr **attrs, struct attr *attr) {
- struct speech_priv *this;
- SPDConnection *conn;
+static struct speech_priv *speechd_new(struct speech_methods *meth, struct attr **attrs, struct attr *attr) {
+ struct speech_priv *this;
+ SPDConnection *conn;
- conn = spd_open("navit","main",NULL,SPD_MODE_SINGLE);
- if (! conn)
- return NULL;
- this=g_new(struct speech_priv,1);
- if (this) {
- this->conn=conn;
- *meth=speechd_meth;
- spd_set_punctuation(conn, SPD_PUNCT_NONE);
- }
- return this;
+ conn = spd_open("navit","main",NULL,SPD_MODE_SINGLE);
+ if (! conn)
+ return NULL;
+ this=g_new(struct speech_priv,1);
+ if (this) {
+ this->conn=conn;
+ *meth=speechd_meth;
+ spd_set_punctuation(conn, SPD_PUNCT_NONE);
+ }
+ return this;
}
-void
-plugin_init(void)
-{
- plugin_register_category_speech("speech_dispatcher", speechd_new);
+void plugin_init(void) {
+ plugin_register_category_speech("speech_dispatcher", speechd_new);
}
diff --git a/navit/start.c b/navit/start.c
index 35bdce0a0..f236dc62a 100644
--- a/navit/start.c
+++ b/navit/start.c
@@ -19,8 +19,6 @@
#include "start_real.h"
-int
-main(int argc, char **argv)
-{
- return main_real(argc, argv);
+int main(int argc, char **argv) {
+ return main_real(argc, argv);
}
diff --git a/navit/start_apple.m b/navit/start_apple.m
index 356d34408..114fd4bbe 100644
--- a/navit/start_apple.m
+++ b/navit/start_apple.m
@@ -28,9 +28,9 @@ main(int argc, char **argv)
int ret;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *appFolderPath = [[NSBundle mainBundle] resourcePath];
- NSString *locale = [[NSLocale currentLocale] localeIdentifier];
+ NSString *locale = [[NSLocale currentLocale] localeIdentifier];
char *lang=g_strdup_printf("%s.UTF-8",[locale UTF8String]);
- dbg(0,"lang %s\n",lang);
+ dbg(0,"lang %s",lang);
setenv("LANG",lang,0);
setlocale(LC_ALL, NULL);
@@ -40,7 +40,7 @@ main(int argc, char **argv)
argv[0]=g_strdup_printf("%s/bin/navit",s);
setenv("NAVIT_USER_DATADIR",user,0);
- dbg(0,"calling main_real\n");
+ dbg(0,"calling main_real");
ret=main_real(argc, argv);
g_free(argv[0]);
g_free(user);
diff --git a/navit/start_real.c b/navit/start_real.c
index 16e0d5edb..ad990d874 100644
--- a/navit/start_real.c
+++ b/navit/start_real.c
@@ -27,7 +27,6 @@
#include <XGetopt.h>
#endif
#include "config_.h"
-#include "version.h"
#include "item.h"
#include "coord.h"
#include "main.h"
@@ -46,25 +45,23 @@
#include "atom.h"
#include "command.h"
#include "geom.h"
+#include "traffic.h"
#ifdef HAVE_API_WIN32_CE
#include <windows.h>
#include <winbase.h>
#endif
-char *version=PACKAGE_VERSION"+git:"GIT_VERSION""NAVIT_VARIANT;
int main_argc;
char * const* main_argv;
-static void
-print_usage(void)
-{
- printf("%s",_("navit usage:\n"
- "navit [options] [configfile]\n"
- "\t-c <file>: use <file> as config file, instead of using the default file.\n"
- "\t-d <n>: set the global debug output level to <n> (0=error, 1=warning, 2=info, 3=debug).\n"
- "\tSettings from config file will still take effect where they set a higher level.\n"
- "\t-h: print this usage info and exit.\n"
- "\t-v: print the version and exit.\n"));
+static void print_usage(void) {
+ printf("%s",_("navit usage:\n"
+ "navit [options] [configfile]\n"
+ "\t-c <file>: use <file> as config file, instead of using the default file.\n"
+ "\t-d <n>: set the global debug output level to <n> (0=error, 1=warning, 2=info, 3=debug).\n"
+ "\tSettings from config file will still take effect where they set a higher level.\n"
+ "\t-h: print this usage info and exit.\n"
+ "\t-v: print the version and exit.\n"));
}
@@ -72,173 +69,174 @@ print_usage(void)
extern void builtin_init(void);
#endif /* USE_PLUGINS*/
-int main_real(int argc, char * const* argv)
-{
- xmlerror *error = NULL;
- char *config_file = NULL, *command=NULL, *startup_file=NULL;
- int opt;
- char *cp;
- struct attr navit, conf;
+int main_real(int argc, char * const* argv) {
+ xmlerror *error = NULL;
+ char *config_file = NULL, *command=NULL, *startup_file=NULL;
+ int opt;
+ char *cp;
+ struct attr navit, conf;
- GList *list = NULL, *li;
- main_argc=argc;
- main_argv=argv;
+ GList *list = NULL, *li;
+ main_argc=argc;
+ main_argv=argv;
#ifdef HAVE_GLIB
- event_glib_init();
+ event_glib_init();
#else
- _g_slice_thread_init_nomessage();
+ _g_slice_thread_init_nomessage();
#endif
- atom_init();
- main_init(argv[0]);
- navit_nls_main_init();
- debug_init(argv[0]);
+ atom_init();
+ main_init(argv[0]);
+ navit_nls_main_init();
+ debug_init(argv[0]);
- cp = getenv("NAVIT_LOGFILE");
- if (cp) {
- debug_set_logfile(cp);
- }
+ cp = getenv("NAVIT_LOGFILE");
+ if (cp) {
+ debug_set_logfile(cp);
+ }
#ifdef HAVE_API_WIN32_CE
- else {
- debug_set_logfile("/Storage Card/navit.log");
- }
+ else {
+ debug_set_logfile("/Storage Card/navit.log");
+ }
#endif
- file_init();
+ file_init();
#ifndef USE_PLUGINS
- builtin_init();
+ builtin_init();
#endif
- route_init();
- navigation_init();
- tracking_init();
- search_init();
- linguistics_init();
- geom_init();
- config_file=NULL;
+ route_init();
+ navigation_init();
+ tracking_init();
+ search_init();
+ linguistics_init();
+ geom_init();
+ traffic_init();
+ config_file=NULL;
#ifdef HAVE_GETOPT_H
- opterr=0; //don't bomb out on errors.
+ opterr=0; //don't bomb out on errors.
#endif /* _MSC_VER */
- /* ingore iphone command line argument */
- if (argc == 2 && !strcmp(argv[1],"-RegisterForSystemEvents"))
- argc=1;
- if (argc > 1) {
- /* Don't forget to update the manpage if you modify theses options */
- while((opt = getopt(argc, argv, ":hvc:d:e:s:")) != -1) {
- switch(opt) {
- case 'h':
- print_usage();
- exit(0);
- break;
- case 'v':
- printf("%s %s\n", "navit", version);
- exit(0);
- break;
- case 'c':
- printf("config file n is set to `%s'\n", optarg);
- config_file = optarg;
- break;
- case 'd':
- debug_set_global_level(atoi(optarg), 1);
- break;
- case 'e':
- command=optarg;
- break;
- case 's':
- startup_file=optarg;
- break;
+ /* ingore iphone command line argument */
+ if (argc == 2 && !strcmp(argv[1],"-RegisterForSystemEvents"))
+ argc=1;
+ if (argc > 1) {
+ /* Don't forget to update the manpage if you modify theses options */
+ while((opt = getopt(argc, argv, ":hvc:d:e:s:")) != -1) {
+ switch(opt) {
+ case 'h':
+ print_usage();
+ exit(0);
+ break;
+ case 'v':
+ printf("%s %s\n", "navit", NAVIT_VERSION);
+ exit(0);
+ break;
+ case 'c':
+ printf("config file n is set to `%s'\n", optarg);
+ config_file = optarg;
+ break;
+ case 'd':
+ debug_set_global_level(atoi(optarg), 1);
+ break;
+ case 'e':
+ command=optarg;
+ break;
+ case 's':
+ startup_file=optarg;
+ break;
#ifdef HAVE_GETOPT_H
- case ':':
- fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt);
- print_usage();
- exit(2);
- break;
- case '?':
- fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt);
- print_usage();
- exit(3);
+ case ':':
+ fprintf(stderr, "navit: Error - Option `%c' needs a value\n", optopt);
+ print_usage();
+ exit(2);
+ break;
+ case '?':
+ fprintf(stderr, "navit: Error - No such option: `%c'\n", optopt);
+ print_usage();
+ exit(3);
#endif
- }
- }
- // use 1st cmd line option that is left for the config file
- if (optind < argc) config_file = argv[optind];
- }
+ }
+ }
+ // use 1st cmd line option that is left for the config file
+ if (optind < argc) config_file = argv[optind];
+ }
- // if config file is explicitely given only look for it, otherwise try std paths
- if (config_file) {
- list = g_list_append(list,g_strdup(config_file));
- } else {
- list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_USER_DATADIR"), "/navit.xml" , NULL));
- list = g_list_append(list,g_strdup("navit.xml.local"));
- list = g_list_append(list,g_strdup("navit.xml"));
- list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml.local" , NULL));
- list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml" , NULL));
+ // if config file is explicitely given only look for it, otherwise try std paths
+ if (config_file) {
+ list = g_list_append(list,g_strdup(config_file));
+ } else {
+ list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_USER_DATADIR"), "/navit.xml", NULL));
+ list = g_list_append(list,g_strdup("navit.xml.local"));
+ list = g_list_append(list,g_strdup("navit.xml"));
+ list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml.local", NULL));
+ list = g_list_append(list,g_strjoin(NULL,getenv("NAVIT_SHAREDIR"), "/navit.xml", NULL));
#ifndef _WIN32
- list = g_list_append(list,g_strdup("/etc/navit/navit.xml"));
+ list = g_list_append(list,g_strdup("/etc/navit/navit.xml"));
#endif
- }
- li = list;
- for (;;) {
- if (li == NULL) {
- // We have not found an existing config file from all possibilities
- dbg(lvl_error, "%s", _("No config file navit.xml, navit.xml.local found\n"));
- return 4;
- }
+ }
+ li = list;
+ for (;;) {
+ if (li == NULL) {
+ // We have not found an existing config file from all possibilities
+ dbg(lvl_error, "%s", _("No config file navit.xml, navit.xml.local found"));
+ return 4;
+ }
// Try the next config file possibility from the list
- config_file = li->data;
- dbg(lvl_debug,"trying %s\n",config_file);
- if (file_exists(config_file)) {
- break;
- }
- g_free(config_file);
- li = g_list_next(li);
- }
+ config_file = li->data;
+ dbg(lvl_debug,"trying %s",config_file);
+ if (file_exists(config_file)) {
+ break;
+ }
+ g_free(config_file);
+ li = g_list_next(li);
+ }
- dbg(lvl_debug,"Loading %s\n",config_file);
- if (!config_load(config_file, &error)) {
- dbg(lvl_error, _("Error parsing config file '%s': %s\n"), config_file, error ? error->message : "");
- } else {
- dbg(lvl_info, _("Using config file '%s'\n"), config_file);
- }
- if (! config) {
- dbg(lvl_error, _("Error: No configuration found in config file '%s'\n"), config_file);
+ dbg(lvl_debug,"Loading config from '%s'",config_file);
+ if (!config_load(config_file, &error)) {
+ dbg(lvl_error, _("Error parsing config file '%s': %s"), config_file, error ? error->message : "");
+ } else {
+ dbg(lvl_info, _("Using config file '%s'"), config_file);
+ }
+ if (! config) {
+ dbg(lvl_error, _("Error: No configuration found in config file '%s'"), config_file);
+ }
+ while (li) {
+ g_free(li->data);
+ li = g_list_next(li);
+ }
+ g_list_free(list);
+ if (! (config && config_get_attr(config, attr_navit, &navit, NULL))) {
+ dbg(lvl_error, "%s", _("Internal initialization failed, exiting. Check previous error messages."));
+ exit(5);
+ }
+ main_update_default_layout(navit.u.navit);
+ conf.type=attr_config;
+ conf.u.config=config;
+ if (startup_file) {
+ FILE *f = fopen(startup_file,"r");
+ if (f) {
+ char buffer[4096];
+ int fclose_ret;
+ while(fgets(buffer, sizeof(buffer), f)) {
+ command_evaluate(&conf, buffer);
+ }
+ fclose_ret = fclose(f);
+ if (fclose_ret != 0) {
+ dbg(lvl_error, "Could not close the specified startup file: %s", startup_file);
+ }
+ } else {
+ dbg(lvl_error, "Could not open the specified startup file: %s", startup_file);
}
- while (li) {
- g_free(li->data);
- li = g_list_next(li);
- }
- g_list_free(list);
- if (! (config && config_get_attr(config, attr_navit, &navit, NULL))) {
- dbg(lvl_error, "%s", _("Internal initialization failed, exiting. Check previous error messages.\n"));
- exit(5);
- }
- conf.type=attr_config;
- conf.u.config=config;
- if (startup_file) {
- FILE *f = fopen(startup_file,"r");
- if (f) {
- char buffer[4096];
- int fclose_ret;
- while(fgets(buffer, sizeof(buffer), f)) {
- command_evaluate(&conf, buffer);
- }
- fclose_ret = fclose(f);
- if (fclose_ret != 0) {
- dbg(lvl_error, "Could not close the specified startup file: %s\n", startup_file);
- }
- } else {
- dbg(lvl_error, "Could not open the specified startup file: %s", startup_file);
- }
- }
- if (command) {
- command_evaluate(&conf, command);
- }
- event_main_loop_run();
+ }
+ if (command) {
+ command_evaluate(&conf, command);
+ }
+ event_main_loop_run();
- /* TODO: Android actually has no event loop, so we can't free all allocated resources here. Have to find better place to
- * free all allocations on program exit. And don't forget to free all the stuff allocated in the code above.
- */
+ /* TODO: Android actually has no event loop, so we can't free all allocated resources here. Have to find better place to
+ * free all allocations on program exit. And don't forget to free all the stuff allocated in the code above.
+ */
#ifndef HAVE_API_ANDROID
- linguistics_free();
- debug_finished();
+ linguistics_free();
+ debug_finished();
#endif
- return 0;
+ return 0;
}
diff --git a/navit/start_real.h b/navit/start_real.h
index 898251433..3228e1a36 100644
--- a/navit/start_real.h
+++ b/navit/start_real.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef NAVIT_MAIN_REAL_H
-#define NAVIT_MAIN_REAL_H
+#ifndef NAVIT_MAIN_REAL_H
+#define NAVIT_MAIN_REAL_H
int main_real(int argc, char * const* argv);
diff --git a/navit/startonce.sh b/navit/startonce.sh
index d0bfafdcc..3e27d77f0 100755
--- a/navit/startonce.sh
+++ b/navit/startonce.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
# This script is part of navit, a navigation system.
# It can be used to make sure that navit is only started
@@ -22,7 +22,7 @@ NAVIT="./navit"
function check_wmctrl()
{
which wmctrl > /dev/null
-
+
if [ $? -ne 0 ] ; then
echo "I need the 'wmctrl' program. Exit."
exit 1
@@ -33,7 +33,7 @@ function start_navit()
{
if [ "x" != "x$CONFIG" ] ; then
$NAVIT -c $CONFIG &
- else
+ else
$NAVIT &
fi
@@ -58,12 +58,12 @@ function start_navit()
function check_navit()
{
if [ -f $PIDFILE ] ; then
- pid=`cat $PIDFILE`
+ pid=$(cat $PIDFILE)
kill -0 $pid 2>/dev/null
if [ $? -eq 0 ] ; then
echo "Bringing Navit to front"
- winid=`wmctrl -l -p | grep -e "^[^:blank:]*[:blank:]*[^:blank:]*[:blank:]*$pid[:blank:]*" | sed 's/ .*//'`
+ winid=$(wmctrl -l -p | grep -e "^[^:blank:]*[:blank:]*[^:blank:]*[:blank:]*$pid[:blank:]*" | sed 's/ .*//')
wmctrl -i -R $winid
exit 0
diff --git a/navit/sunriset.c b/navit/sunriset.c
index 122d14b32..1b1b51929 100644
--- a/navit/sunriset.c
+++ b/navit/sunriset.c
@@ -53,55 +53,55 @@ int __sunriset__( int year, int month, int day, double lon, double lat,
/* */
/**********************************************************************/
{
- double d, /* Days since 2000 Jan 0.0 (negative before) */
- sr, /* Solar distance, astronomical units */
- sRA, /* Sun's Right Ascension */
- sdec, /* Sun's declination */
- sradius, /* Sun's apparent radius */
- t, /* Diurnal arc */
- tsouth, /* Time when Sun is at south */
- sidtime; /* Local sidereal time */
-
- int rc = 0; /* Return cde from function - usually 0 */
-
- /* Compute d of 12h local mean solar time */
- d = days_since_2000_Jan_0(year,month,day) + 0.5 - lon/360.0;
-
- /* Compute local sideral time of this moment */
- sidtime = revolution( GMST0(d) + 180.0 + lon );
-
- /* Compute Sun's RA + Decl at this moment */
- sun_RA_dec( d, &sRA, &sdec, &sr );
-
- /* Compute time when Sun is at south - in hours UT */
- tsouth = 12.0 - rev180(sidtime - sRA)/15.0;
-
- /* Compute the Sun's apparent radius, degrees */
- sradius = 0.2666 / sr;
-
- /* Do correction to upper limb, if necessary */
- if ( upper_limb )
- altit -= sradius;
-
- /* Compute the diurnal arc that the Sun traverses to reach */
- /* the specified altitide altit: */
- {
- double cost;
- cost = ( sind(altit) - sind(lat) * sind(sdec) ) /
- ( cosd(lat) * cosd(sdec) );
- if ( cost >= 1.0 )
- rc = -1, t = 0.0; /* Sun always below altit */
- else if ( cost <= -1.0 )
- rc = +1, t = 12.0; /* Sun always above altit */
- else
- t = acosd(cost)/15.0; /* The diurnal arc, hours */
- }
-
- /* Store rise and set times - in hours UT */
- *trise = tsouth - t;
- *tset = tsouth + t;
-
- return rc;
+ double d, /* Days since 2000 Jan 0.0 (negative before) */
+ sr, /* Solar distance, astronomical units */
+ sRA, /* Sun's Right Ascension */
+ sdec, /* Sun's declination */
+ sradius, /* Sun's apparent radius */
+ t, /* Diurnal arc */
+ tsouth, /* Time when Sun is at south */
+ sidtime; /* Local sidereal time */
+
+ int rc = 0; /* Return cde from function - usually 0 */
+
+ /* Compute d of 12h local mean solar time */
+ d = days_since_2000_Jan_0(year,month,day) + 0.5 - lon/360.0;
+
+ /* Compute local sideral time of this moment */
+ sidtime = revolution( GMST0(d) + 180.0 + lon );
+
+ /* Compute Sun's RA + Decl at this moment */
+ sun_RA_dec( d, &sRA, &sdec, &sr );
+
+ /* Compute time when Sun is at south - in hours UT */
+ tsouth = 12.0 - rev180(sidtime - sRA)/15.0;
+
+ /* Compute the Sun's apparent radius, degrees */
+ sradius = 0.2666 / sr;
+
+ /* Do correction to upper limb, if necessary */
+ if ( upper_limb )
+ altit -= sradius;
+
+ /* Compute the diurnal arc that the Sun traverses to reach */
+ /* the specified altitide altit: */
+ {
+ double cost;
+ cost = ( sind(altit) - sind(lat) * sind(sdec) ) /
+ ( cosd(lat) * cosd(sdec) );
+ if ( cost >= 1.0 )
+ rc = -1, t = 0.0; /* Sun always below altit */
+ else if ( cost <= -1.0 )
+ rc = +1, t = 12.0; /* Sun always above altit */
+ else
+ t = acosd(cost)/15.0; /* The diurnal arc, hours */
+ }
+
+ /* Store rise and set times - in hours UT */
+ *trise = tsouth - t;
+ *tset = tsouth + t;
+
+ return rc;
} /* __sunriset__ */
@@ -127,48 +127,48 @@ double __daylen__( int year, int month, int day, double lon, double lat,
/* and to zero when computing day+twilight length. */
/**********************************************************************/
{
- double d, /* Days since 2000 Jan 0.0 (negative before) */
- obl_ecl, /* Obliquity (inclination) of Earth's axis */
- sr, /* Solar distance, astronomical units */
- slon, /* True solar longitude */
- sin_sdecl, /* Sine of Sun's declination */
- cos_sdecl, /* Cosine of Sun's declination */
- sradius, /* Sun's apparent radius */
- t; /* Diurnal arc */
-
- /* Compute d of 12h local mean solar time */
- d = days_since_2000_Jan_0(year,month,day) + 0.5 - lon/360.0;
-
- /* Compute obliquity of ecliptic (inclination of Earth's axis) */
- obl_ecl = 23.4393 - 3.563E-7 * d;
-
- /* Compute Sun's position */
- sunpos( d, &slon, &sr );
-
- /* Compute sine and cosine of Sun's declination */
- sin_sdecl = sind(obl_ecl) * sind(slon);
- cos_sdecl = sqrt( 1.0 - sin_sdecl * sin_sdecl );
-
- /* Compute the Sun's apparent radius, degrees */
- sradius = 0.2666 / sr;
-
- /* Do correction to upper limb, if necessary */
- if ( upper_limb )
- altit -= sradius;
-
- /* Compute the diurnal arc that the Sun traverses to reach */
- /* the specified altitide altit: */
- {
- double cost;
- cost = ( sind(altit) - sind(lat) * sin_sdecl ) /
- ( cosd(lat) * cos_sdecl );
- if ( cost >= 1.0 )
- t = 0.0; /* Sun always below altit */
- else if ( cost <= -1.0 )
- t = 24.0; /* Sun always above altit */
- else t = (2.0/15.0) * acosd(cost); /* The diurnal arc, hours */
- }
- return t;
+ double d, /* Days since 2000 Jan 0.0 (negative before) */
+ obl_ecl, /* Obliquity (inclination) of Earth's axis */
+ sr, /* Solar distance, astronomical units */
+ slon, /* True solar longitude */
+ sin_sdecl, /* Sine of Sun's declination */
+ cos_sdecl, /* Cosine of Sun's declination */
+ sradius, /* Sun's apparent radius */
+ t; /* Diurnal arc */
+
+ /* Compute d of 12h local mean solar time */
+ d = days_since_2000_Jan_0(year,month,day) + 0.5 - lon/360.0;
+
+ /* Compute obliquity of ecliptic (inclination of Earth's axis) */
+ obl_ecl = 23.4393 - 3.563E-7 * d;
+
+ /* Compute Sun's position */
+ sunpos( d, &slon, &sr );
+
+ /* Compute sine and cosine of Sun's declination */
+ sin_sdecl = sind(obl_ecl) * sind(slon);
+ cos_sdecl = sqrt( 1.0 - sin_sdecl * sin_sdecl );
+
+ /* Compute the Sun's apparent radius, degrees */
+ sradius = 0.2666 / sr;
+
+ /* Do correction to upper limb, if necessary */
+ if ( upper_limb )
+ altit -= sradius;
+
+ /* Compute the diurnal arc that the Sun traverses to reach */
+ /* the specified altitide altit: */
+ {
+ double cost;
+ cost = ( sind(altit) - sind(lat) * sin_sdecl ) /
+ ( cosd(lat) * cos_sdecl );
+ if ( cost >= 1.0 )
+ t = 0.0; /* Sun always below altit */
+ else if ( cost <= -1.0 )
+ t = 24.0; /* Sun always above altit */
+ else t = (2.0/15.0) * acosd(cost); /* The diurnal arc, hours */
+ }
+ return t;
} /* __daylen__ */
@@ -182,56 +182,55 @@ void sunpos( double d, double *lon, double *r )
/* computed, since it's always very near 0. */
/******************************************************/
{
- double M, /* Mean anomaly of the Sun */
- w, /* Mean longitude of perihelion */
- /* Note: Sun's mean longitude = M + w */
- e, /* Eccentricity of Earth's orbit */
- E, /* Eccentric anomaly */
- x, y, /* x, y coordinates in orbit */
- v; /* True anomaly */
-
- /* Compute mean elements */
- M = revolution( 356.0470 + 0.9856002585 * d );
- w = 282.9404 + 4.70935E-5 * d;
- e = 0.016709 - 1.151E-9 * d;
-
- /* Compute true longitude and radius vector */
- E = M + e * RADEG * sind(M) * ( 1.0 + e * cosd(M) );
- x = cosd(E) - e;
- y = sqrt( 1.0 - e*e ) * sind(E);
- *r = sqrt( x*x + y*y ); /* Solar distance */
- v = atan2d( y, x ); /* True anomaly */
- *lon = v + w; /* True solar longitude */
- if ( *lon >= 360.0 )
- *lon -= 360.0; /* Make it 0..360 degrees */
+ double M, /* Mean anomaly of the Sun */
+ w, /* Mean longitude of perihelion */
+ /* Note: Sun's mean longitude = M + w */
+ e, /* Eccentricity of Earth's orbit */
+ E, /* Eccentric anomaly */
+ x, y, /* x, y coordinates in orbit */
+ v; /* True anomaly */
+
+ /* Compute mean elements */
+ M = revolution( 356.0470 + 0.9856002585 * d );
+ w = 282.9404 + 4.70935E-5 * d;
+ e = 0.016709 - 1.151E-9 * d;
+
+ /* Compute true longitude and radius vector */
+ E = M + e * RADEG * sind(M) * ( 1.0 + e * cosd(M) );
+ x = cosd(E) - e;
+ y = sqrt( 1.0 - e*e ) * sind(E);
+ *r = sqrt( x*x + y*y ); /* Solar distance */
+ v = atan2d( y, x ); /* True anomaly */
+ *lon = v + w; /* True solar longitude */
+ if ( *lon >= 360.0 )
+ *lon -= 360.0; /* Make it 0..360 degrees */
}
-void sun_RA_dec( double d, double *RA, double *dec, double *r )
-{
- double lon, obl_ecl;
- double xs, ys;
- double xe, ye, ze;
-
- /* Compute Sun's ecliptical coordinates */
- sunpos( d, &lon, r );
-
- /* Compute ecliptic rectangular coordinates */
- xs = *r * cosd(lon);
- ys = *r * sind(lon);
- /* No zs, because the Sun is always in the ecliptic plane! */
-
- /* Compute obliquity of ecliptic (inclination of Earth's axis) */
- obl_ecl = 23.4393 - 3.563E-7 * d;
-
- /* Convert to equatorial rectangular coordinates - x is unchanged */
- xe = xs;
- ye = ys * cosd(obl_ecl);
- ze = ys * sind(obl_ecl);
-
- /* Convert to spherical coordinates */
- *RA = atan2d( ye, xe );
- *dec = atan2d( ze, sqrt(xe*xe + ye*ye) );
-
+void sun_RA_dec( double d, double *RA, double *dec, double *r ) {
+ double lon, obl_ecl;
+ double xs, ys;
+ double xe, ye, ze;
+
+ /* Compute Sun's ecliptical coordinates */
+ sunpos( d, &lon, r );
+
+ /* Compute ecliptic rectangular coordinates */
+ xs = *r * cosd(lon);
+ ys = *r * sind(lon);
+ /* No zs, because the Sun is always in the ecliptic plane! */
+
+ /* Compute obliquity of ecliptic (inclination of Earth's axis) */
+ obl_ecl = 23.4393 - 3.563E-7 * d;
+
+ /* Convert to equatorial rectangular coordinates - x is unchanged */
+ xe = xs;
+ ye = ys * cosd(obl_ecl);
+ ze = ys * sind(obl_ecl);
+
+ /* Convert to spherical coordinates */
+ *RA = atan2d( ye, xe );
+ *dec = atan2d( ze, sqrt(xe*xe + ye*ye) );
+
} /* sun_RA_dec */
@@ -248,7 +247,7 @@ double revolution( double x )
/* Reduce angle to within 0..360 degrees */
/*****************************************/
{
- return( x - 360.0 * floor( x * INV360 ) );
+ return( x - 360.0 * floor( x * INV360 ) );
} /* revolution */
double rev180( double x )
@@ -256,7 +255,7 @@ double rev180( double x )
/* Reduce angle to within -180..+180 degrees */
/*********************************************/
{
- return( x - 360.0 * floor( x * INV360 + 0.5 ) );
+ return( x - 360.0 * floor( x * INV360 + 0.5 ) );
} /* revolution */
@@ -286,15 +285,14 @@ double rev180( double x )
/* */
/*******************************************************************/
-double GMST0( double d )
-{
- double sidtim0;
- /* Sidtime at 0h UT = L (Sun's mean longitude) + 180.0 degr */
- /* L = M + w, as defined in sunpos(). Since I'm too lazy to */
- /* add these numbers, I'll let the C compiler do it for me. */
- /* Any decent C compiler will add the constants at compile */
- /* time, imposing no runtime or code overhead. */
- sidtim0 = revolution( ( 180.0 + 356.0470 + 282.9404 ) +
+double GMST0( double d ) {
+ double sidtim0;
+ /* Sidtime at 0h UT = L (Sun's mean longitude) + 180.0 degr */
+ /* L = M + w, as defined in sunpos(). Since I'm too lazy to */
+ /* add these numbers, I'll let the C compiler do it for me. */
+ /* Any decent C compiler will add the constants at compile */
+ /* time, imposing no runtime or code overhead. */
+ sidtim0 = revolution( ( 180.0 + 356.0470 + 282.9404 ) +
( 0.9856002585 + 4.70935E-5 ) * d );
- return sidtim0;
+ return sidtim0;
} /* GMST0 */
diff --git a/navit/sunriset.h b/navit/sunriset.h
index 36a770935..60ad4fa76 100644
--- a/navit/sunriset.h
+++ b/navit/sunriset.h
@@ -8,7 +8,7 @@ extern long int timezone_offset;
#define MINUTES(h) ((int)(60*(h-floor(h))))
#ifndef ABS
-#define ABS(x) ((x)<0?-(x):(x))
+#define ABS(x) ((x)<0?-(x):(x))
#endif
/* A macro to compute the number of days elapsed since 2000 Jan 0.0 */
diff --git a/navit/support/espeak/CMakeLists.txt b/navit/support/espeak/CMakeLists.txt
index 6a20511e7..c358f712e 100644
--- a/navit/support/espeak/CMakeLists.txt
+++ b/navit/support/espeak/CMakeLists.txt
@@ -2,8 +2,11 @@
if(INTERNAL_ESPEAK_COMPLETE)
set(ESPEAK_LIBRARY_ADDITIONAL speak_lib.c)
endif()
-supportlib_add_library(support_espeak compiledict.c dictionary.c intonation.c readclause.c setlengths.c
- numbers.c synth_mbrola.c synthdata.c synthesize.c translate.c tr_languages.c voices.c wavegen.c
- phonemelist.c klatt.c speak_init.c ${ESPEAK_LIBRARY_ADDITIONAL})
+supportlib_add_library(support_espeak compiledict.c dictionary.c espeak_command.c fifo.c klatt.c
+ numbers.c readclause.c sonic.c synthesize.c translate.c voices.c wavegen.c wave_sada.c
+ debug.c espeak.c event.c intonation.c mbrowrap.c phonemelist.c setlengths.c
+ synthdata.c synth_mbrola.c tr_languages.c wave.c wave_pulse.c ${ESPEAK_LIBRARY_ADDITIONAL})
+
+# speak.c
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/espeak-data DESTINATION ${SHARE_DIR} PATTERN ".svn" EXCLUDE)
diff --git a/navit/support/espeak/compiledict.c b/navit/support/espeak/compiledict.c
index a2b7865f9..af798ade2 100755..100644
--- a/navit/support/espeak/compiledict.c
+++ b/navit/support/espeak/compiledict.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -30,29 +30,48 @@
#include "phoneme.h"
#include "synthesize.h"
#include "translate.h"
-
-//#define OPT_FORMAT // format the text and write formatted copy to Log file
-//#define OUTPUT_FORMAT
+#include "dictionary.h"
+#include "compiledict.h"
extern void Write4Bytes(FILE *f, int value);
-int HashDictionary(const char *string);
static FILE *f_log = NULL;
extern char *dir_dictionary;
+extern char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes
+
static int linenum;
static int error_count;
-static int transpose_offset; // transpose character range for LookupDictList()
-static int transpose_min;
-static int transpose_max;
static int text_mode = 0;
static int debug_flag = 0;
+static int error_need_dictionary = 0;
static int hash_counts[N_HASH_DICT];
static char *hash_chains[N_HASH_DICT];
static char letterGroupsDefined[N_LETTER_GROUPS];
-#define __cdecl
+MNEM_TAB mnem_rules[] = {
+ {"unpr", DOLLAR_UNPR},
+ {"noprefix", DOLLAR_NOPREFIX}, // rule fails if a prefix has been removed
+ {"list", DOLLAR_LIST}, // a pronunciation is given in the *_list file
+
+ {"w_alt1", 0x11},
+ {"w_alt2", 0x12},
+ {"w_alt3", 0x13},
+ {"w_alt4", 0x14},
+ {"w_alt5", 0x15},
+ {"w_alt6", 0x16},
+ {"w_alt", 0x11}, // note: put longer names before their sub-strings
+
+ {"p_alt1", 0x21},
+ {"p_alt2", 0x22},
+ {"p_alt3", 0x23},
+ {"p_alt4", 0x24},
+ {"p_alt5", 0x25},
+ {"p_alt6", 0x26},
+ {"p_alt", 0x21},
+ {NULL, -1}
+};
MNEM_TAB mnem_flags[] = {
// these in the first group put a value in bits0-3 of dictionary_flags
@@ -74,40 +93,50 @@ MNEM_TAB mnem_flags[] = {
// these set the corresponding numbered bit if dictionary_flags
- {"$pause", 8}, /* ensure pause before this word */
- {"$only", 9}, /* only match on this word without suffix */
- {"$onlys", 10}, /* only match with none, or with 's' suffix */
- {"$strend", 11}, /* full stress if at end of clause */
- {"$strend2", 12}, /* full stress if at end of clause, or only followed by unstressed */
- {"$unstressend",13}, /* reduce stress at end of clause */
- {"$atend", 14}, /* use this pronunciation if at end of clause */
-
- {"$dot", 16}, /* ignore '.' after this word (abbreviation) */
- {"$abbrev", 17}, /* use this pronuciation rather than split into letters */
- {"$stem", 18}, // must have a suffix
+ {"$pause", 8}, // ensure pause before this word
+ {"$strend", 9}, // full stress if at end of clause
+ {"$strend2", 10}, // full stress if at end of clause, or only followed by unstressed
+ {"$unstressend",11}, // reduce stress at end of clause
+ {"$abbrev", 13}, // use this pronuciation rather than split into letters
// language specific
- {"$double", 19}, // IT double the initial consonant of next word
- {"$alt", 20}, // use alternative pronunciation
- {"$alt2", 21},
-
+ {"$double", 14}, // IT double the initial consonant of next word
+ {"$alt", 15}, // use alternative pronunciation
+ {"$alt1", 15}, // synonym for $alt
+ {"$alt2", 16},
+ {"$alt3", 17},
+ {"$alt4", 18},
+ {"$alt5", 19},
+ {"$alt6", 20},
+
+ {"$combine", 23}, // Combine with the next word
+
+ {"$dot", 24}, // ignore '.' after this word (abbreviation)
+ {"$hasdot", 25}, // use this pronunciation if there is a dot after the word
{"$max3", 27}, // limit to 3 repetitions
{"$brk", 28}, // a shorter $pause
{"$text", 29}, // word translates to replcement text, not phonemes
// flags in dictionary word 2
- {"$verbf", 0x20}, /* verb follows */
- {"$verbsf", 0x21}, /* verb follows, allow -s suffix */
- {"$nounf", 0x22}, /* noun follows */
- {"$pastf", 0x23}, /* past tense follows */
- {"$verb", 0x24}, /* use this pronunciation when its a verb */
- {"$noun", 0x25}, /* use this pronunciation when its a noun */
- {"$past", 0x26}, /* use this pronunciation when its past tense */
- {"$verbextend",0x28}, /* extend influence of 'verb follows' */
- {"$capital", 0x29}, /* use this pronunciation if initial letter is upper case */
- {"$allcaps", 0x2a}, /* use this pronunciation if initial letter is upper case */
+ {"$verbf", 0x20}, // verb follows
+ {"$verbsf", 0x21}, // verb follows, allow -s suffix
+ {"$nounf", 0x22}, // noun follows
+ {"$pastf", 0x23}, // past tense follows
+ {"$verb", 0x24}, // use this pronunciation when its a verb
+ {"$noun", 0x25}, // use this pronunciation when its a noun
+ {"$past", 0x26}, // use this pronunciation when its past tense
+ {"$verbextend",0x28}, // extend influence of 'verb follows'
+ {"$capital", 0x29}, // use this pronunciation if initial letter is upper case
+ {"$allcaps", 0x2a}, // use this pronunciation if initial letter is upper case
{"$accent", 0x2b}, // character name is base-character name + accent name
+ {"$sentence",0x2d}, // only if this clause is a sentence (i.e. terminator is {. ? !} not {, ; :}
+ {"$only", 0x2e}, // only match on this word without suffix
+ {"$onlys", 0x2f}, // only match with none, or with 's' suffix
+ {"$stem", 0x30}, // must have a suffix
+ {"$atend", 0x31}, // use this pronunciation if at end of clause
+ {"$atstart", 0x32}, // use this pronunciation at start of clause
+ {"$native", 0x33}, // not if we've switched translators
// doesn't set dictionary_flags
{"$?", 100}, // conditional rule, followed by byte giving the condition number
@@ -124,6 +153,7 @@ typedef struct {
char name[LEN_GROUP_NAME+1];
unsigned int start;
unsigned int length;
+ int group3_ix;
} RGROUP;
@@ -138,27 +168,6 @@ int isspace2(unsigned int c)
}
-static const char *LookupMnem2(MNEM_TAB *table, int value)
-{//=======================================================
- while(table->mnem != NULL)
- {
- if(table->value == value)
- return(table->mnem);
- table++;
- }
- return("");
-}
-
-
-char *print_dictionary_flags(unsigned int *flags)
-{//==============================================
- static char buf[20];
-
- sprintf(buf,"%s 0x%x/%x",LookupMnem2(mnem_flags,(flags[0] & 0xf)+0x40), flags[0], flags[1]);
- return(buf);
-}
-
-
static FILE *fopen_log(const char *fname,const char *access)
{//==================================================
@@ -174,20 +183,226 @@ static FILE *fopen_log(const char *fname,const char *access)
}
-#ifdef OPT_FORMAT
-static const char *lookup_mnem(MNEM_TAB *table, int value)
-//========================================================
+static const char *LookupMnemName(MNEM_TAB *table, const int value)
+//==========================================================
/* Lookup a mnemonic string in a table, return its name */
{
- while(table->mnem != NULL)
- {
- if(table->value==value)
- return(table->mnem);
- table++;
- }
- return("??"); /* not found */
-} /* end of mnem */
-#endif
+ while(table->mnem != NULL)
+ {
+ if(table->value==value)
+ return(table->mnem);
+ table++;
+ }
+ return(""); /* not found */
+} /* end of LookupMnemValue */
+
+
+void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len)
+{//========================================================================
+ int stress;
+ int ix;
+ const char *name;
+ int len;
+ int total = 0;
+
+ buf[0] = 0;
+ if((stress = flags[0] & 0xf) != 0)
+ {
+ sprintf(buf, "%s", LookupMnemName(mnem_flags, stress + 0x40));
+ total = strlen(buf);
+ buf += total;
+ }
+
+ for(ix=8; ix<64; ix++)
+ {
+ if(((ix < 30) && (flags[0] & (1 << ix))) || ((ix >= 0x20) && (flags[1] & (1 << (ix-0x20)))))
+ {
+ name = LookupMnemName(mnem_flags, ix);
+ len = strlen(name) + 1;
+ total += len;
+ if(total >= buf_len)
+ continue;
+ sprintf(buf, " %s", name);
+ buf += len;
+ }
+ }
+}
+
+
+
+
+char *DecodeRule(const char *group_chars, int group_length, char *rule, int control)
+{//=================================================================================
+ /* Convert compiled match template to ascii */
+
+ unsigned char rb;
+ unsigned char c;
+ char *p;
+ char *p_end;
+ int ix;
+ int match_type;
+ int finished=0;
+ int value;
+ int linenum=0;
+ int flags;
+ int suffix_char;
+ int condition_num=0;
+ int at_start = 0;
+ const char *name;
+ char buf[200];
+ char buf_pre[200];
+ char suffix[20];
+ static char output[80];
+
+ static char symbols[] =
+ {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
+ '&','%','+','#','S','D','Z','A','L','!',' ','@','?','J','N','K','V','?','T','X','?','W'
+ };
+
+ static char symbols_lg[] = {'A','B','C','H','F','G','Y'};
+
+ match_type = 0;
+ buf_pre[0] = 0;
+
+ for(ix=0; ix<group_length; ix++)
+ {
+ buf[ix] = group_chars[ix];
+ }
+ buf[ix] = 0;
+
+ p = &buf[strlen(buf)];
+ while(!finished)
+ {
+ rb = *rule++;
+
+ if(rb <= RULE_LINENUM)
+ {
+ switch(rb)
+ {
+ case 0:
+ case RULE_PHONEMES:
+ finished=1;
+ break;
+ case RULE_PRE_ATSTART:
+ at_start = 1; // drop through to next case
+ case RULE_PRE:
+ match_type = RULE_PRE;
+ *p = 0;
+ p = buf_pre;
+ break;
+ case RULE_POST:
+ match_type = RULE_POST;
+ *p = 0;
+ strcat(buf," (");
+ p = &buf[strlen(buf)];
+ break;
+ case RULE_PH_COMMON:
+ break;
+ case RULE_CONDITION:
+ /* conditional rule, next byte gives condition number */
+ condition_num = *rule++;
+ break;
+ case RULE_LINENUM:
+ value = (rule[1] & 0xff) - 1;
+ linenum = (rule[0] & 0xff) - 1 + (value * 255);
+ rule+=2;
+ break;
+ }
+ continue;
+ }
+
+ if(rb == RULE_DOLLAR)
+ {
+ value = *rule++ & 0xff;
+ if((value != 0x01) || (control & FLAG_UNPRON_TEST))
+ {
+ // TODO write the string backwards if in RULE_PRE
+ p[0] = '$';
+ name = LookupMnemName(mnem_rules, value);
+ strcpy(&p[1],name);
+ p += (strlen(name)+1);
+ }
+ c = ' ';
+ }
+ else if(rb == RULE_ENDING)
+ {
+ static const char *flag_chars = "eipvdfq tba ";
+ flags = ((rule[0] & 0x7f)<< 8) + (rule[1] & 0x7f);
+ suffix_char = 'S';
+ if(flags & (SUFX_P >> 8))
+ suffix_char = 'P';
+ sprintf(suffix,"%c%d",suffix_char,rule[2] & 0x7f);
+ rule += 3;
+ for(ix=0; ix<9; ix++)
+ {
+ if(flags & 1)
+ sprintf(&suffix[strlen(suffix)],"%c",flag_chars[ix]);
+ flags = (flags >> 1);
+ }
+ strcpy(p,suffix);
+ p += strlen(suffix);
+ c = ' ';
+ }
+ else if(rb == RULE_LETTERGP)
+ {
+ c = symbols_lg[*rule++ - 'A'];
+ }
+ else if(rb == RULE_LETTERGP2)
+ {
+ value = *rule++ - 'A';
+ p[0] = 'L';
+ p[1] = (value / 10) + '0';
+ c = (value % 10) + '0';
+
+ if(match_type == RULE_PRE)
+ {
+ p[0] = c;
+ c = 'L';
+ }
+ p+=2;
+ }
+ else if(rb <= RULE_LAST_RULE)
+ c = symbols[rb];
+ else if(rb == RULE_SPACE)
+ c = '_';
+ else
+ c = rb;
+ *p++ = c;
+ }
+ *p = 0;
+
+ p = output;
+ p_end = p + sizeof(output) - 1;
+
+ if(linenum > 0)
+ {
+ sprintf(p,"%5d:\t",linenum);
+ p += 7;
+ }
+ if(condition_num > 0)
+ {
+ sprintf(p,"?%d ",condition_num);
+ p = &p[strlen(p)];
+ }
+ if(((ix = strlen(buf_pre)) > 0) || at_start)
+ {
+ if(at_start)
+ *p++ = '_';
+ while((--ix >= 0) && (p < p_end-3))
+ *p++ = buf_pre[ix];
+ *p++ = ')';
+ *p++ = ' ';
+ }
+ *p = 0;
+
+ buf[p_end - p] = 0; // prevent overflow in output[]
+ strcat(p,buf);
+ ix = strlen(output);
+ while(ix < 8)
+ output[ix++]=' ';
+ output[ix]=0;
+ return(output);
+} /* end of DecodeRule */
@@ -202,34 +417,30 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
unsigned int ix;
int step;
unsigned int n_flag_codes = 0;
+ int flagnum;
int flag_offset;
int length;
int multiple_words = 0;
int multiple_numeric_hyphen = 0;
char *multiple_string = NULL;
char *multiple_string_end = NULL;
-
+
int len_word;
int len_phonetic;
int text_not_phonemes; // this word specifies replacement text, not phonemes
unsigned int wc;
int all_upper_case;
-
+
char *mnemptr;
- char *comment;
unsigned char flag_codes[100];
char encoded_ph[200];
- unsigned char bad_phoneme[4];
-static char nullstring[] = {0};
+ char bad_phoneme_str[4];
+ int bad_phoneme;
+ static char nullstring[] = {0};
- comment = NULL;
text_not_phonemes = 0;
phonetic = word = nullstring;
-if(memcmp(linebuf,"_-",2)==0)
-{
-step=1; // TEST
-}
p = linebuf;
// while(isspace2(*p)) p++;
@@ -250,12 +461,12 @@ step=1; // TEST
#endif
step = 0;
-
+
c = 0;
while(c != '\n')
{
c = *p;
-
+
if((c == '?') && (step==0))
{
// conditional rule, allow only if the numbered condition is set for the voice
@@ -270,12 +481,12 @@ step=1; // TEST
}
ix = 0;
- if(isdigit(*p))
+ if(IsDigit09(*p))
{
ix += (*p-'0');
p++;
}
- if(isdigit(*p))
+ if(IsDigit09(*p))
{
ix = ix*10 + (*p-'0');
p++;
@@ -283,34 +494,32 @@ step=1; // TEST
flag_codes[n_flag_codes++] = ix + flag_offset;
c = *p;
}
-
+
if((c == '$') && isalnum(p[1]))
{
/* read keyword parameter */
mnemptr = p;
while(!isspace2(c = *p)) p++;
*p = 0;
-
- ix = LookupMnem(mnem_flags,mnemptr);
- if(ix > 0)
+
+ flagnum = LookupMnem(mnem_flags,mnemptr);
+ if(flagnum > 0)
{
- if(ix == 200)
+ if(flagnum == 200)
{
text_mode = 1;
}
- else
- if(ix == 201)
+ else if(flagnum == 201)
{
text_mode = 0;
}
- else
- if(ix == BITNUM_FLAG_TEXTMODE)
+ else if(flagnum == BITNUM_FLAG_TEXTMODE)
{
text_not_phonemes = 1;
}
else
{
- flag_codes[n_flag_codes++] = ix;
+ flag_codes[n_flag_codes++] = flagnum;
}
}
else
@@ -319,13 +528,12 @@ step=1; // TEST
error_count++;
}
}
-
+
if((c == '/') && (p[1] == '/') && (multiple_words==0))
{
c = '\n'; /* "//" treat comment as end of line */
- comment = p;
}
-
+
switch(step)
{
case 0:
@@ -335,22 +543,21 @@ step=1; // TEST
word = p+1;
step = 1;
}
- else
- if(!isspace2(c))
+ else if(!isspace2(c))
{
word = p;
step = 1;
}
break;
-
+
case 1:
- if((c == '-') && (word[0] != '_'))
+ if((c == '-') && multiple_words)
{
- if(isdigit(word[0]))
+ if(IsDigit09(word[0]))
{
multiple_numeric_hyphen = 1;
}
- else
+// else // ???
{
flag_codes[n_flag_codes++] = BITNUM_FLAG_HYPHENATED;
}
@@ -370,12 +577,20 @@ step=1; // TEST
step = 3;
}
}
- else
- if((c == ')') && multiple_words)
+ else if(c == ')')
{
- p[0] = 0;
- step = 3;
- multiple_words = 0;
+ if(multiple_words)
+ {
+ p[0] = 0;
+ multiple_words = 0;
+ step = 3;
+ }
+ else if(word[0] != '_')
+ {
+ fprintf(f_log, "%5d: Missing '('\n", linenum);
+ error_count++;
+ step = 3;
+ }
}
break;
@@ -384,15 +599,14 @@ step=1; // TEST
{
multiple_words++;
}
- else
- if(c == ')')
+ else if(c == ')')
{
p[0] = ' '; // terminate extra string
multiple_string_end = p+1;
step = 3;
}
break;
-
+
case 3:
if(!isspace2(c))
{
@@ -400,7 +614,7 @@ step=1; // TEST
step = 4;
}
break;
-
+
case 4:
if(isspace2(c))
{
@@ -408,68 +622,83 @@ step=1; // TEST
step = 5;
}
break;
-
+
case 5:
break;
}
p++;
}
-
+
if(word[0] == 0)
{
-#ifdef OPT_FORMAT
- if(comment != NULL)
- fprintf(f_log,"%s",comment);
- else
- fputc('\n',f_log);
-#endif
return(0); /* blank line */
}
if(text_mode)
text_not_phonemes = 1;
- if(text_not_phonemes != translator->langopts.textmode)
- {
- flag_codes[n_flag_codes++] = BITNUM_FLAG_TEXTMODE;
- }
-
if(text_not_phonemes)
{
- // this is replacement text, so don't encode as phonemes. Restrict the length of the replacement word
- strncpy0(encoded_ph,phonetic,N_WORD_BYTES-4);
+ if(word[0] == '_')
+ {
+ // This is a special word, used by eSpeak. Translate this into phonemes now
+ strcat(phonetic, " "); // need a space to indicate word-boundary
+
+ // PROBLEM vowel reductions are not applied to the translated phonemes
+ // condition rules are not applied
+ TranslateWord(translator,phonetic,0,NULL,NULL);
+ text_not_phonemes = 0;
+ strncpy0(encoded_ph, word_phonemes, N_WORD_BYTES-4);
+
+ if((word_phonemes[0] == 0) && (error_need_dictionary < 3))
+ {
+ // the dictionary was not loaded, we need a second attempt
+ error_need_dictionary++;
+ fprintf(f_log,"%5d: Need to compile dictionary again\n",linenum);
+ }
+ {
+//char decoded_phonemes[128];
+//DecodePhonemes(word_phonemes,decoded_phonemes);
+//printf("Translator %x %s [%s] [%s]\n",translator->translator_name,word,phonetic,decoded_phonemes);
+ }
+ }
+ else
+ {
+ // this is replacement text, so don't encode as phonemes. Restrict the length of the replacement word
+ strncpy0(encoded_ph,phonetic,N_WORD_BYTES-4);
+ }
}
else
{
- EncodePhonemes(phonetic,encoded_ph,bad_phoneme);
+ EncodePhonemes(phonetic,encoded_ph,&bad_phoneme);
if(strchr(encoded_ph,phonSWITCH) != 0)
{
flag_codes[n_flag_codes++] = BITNUM_FLAG_ONLY_S; // don't match on suffixes (except 's') when switching languages
}
// check for errors in the phonemes codes
- for(ix=0; ix<sizeof(encoded_ph); ix++)
+ if(bad_phoneme != 0)
{
- c = encoded_ph[ix];
- if(c == 0) break;
-
- if(c == 255)
- {
- /* unrecognised phoneme, report error */
- fprintf(f_log,"%5d: Bad phoneme [%c] (0x%x) in: %s %s\n",linenum,bad_phoneme[0],bad_phoneme[0],word,phonetic);
- error_count++;
- }
+ // unrecognised phoneme, report error
+ bad_phoneme_str[utf8_out(bad_phoneme, bad_phoneme_str)] = 0;
+ fprintf(f_log,"%5d: Bad phoneme [%s] (U+%x) in: %s %s\n",linenum,bad_phoneme_str,bad_phoneme,word,phonetic);
+ error_count++;
}
}
+ if(text_not_phonemes != translator->langopts.textmode)
+ {
+ flag_codes[n_flag_codes++] = BITNUM_FLAG_TEXTMODE;
+ }
+
+
if(sscanf(word,"U+%x",&wc) == 1)
{
// Character code
ix = utf8_out(wc, word);
word[ix] = 0;
}
- else
- if(word[0] != '_')
+ else if(word[0] != '_')
{
// convert to lower case, and note if the word is all-capitals
int c2;
@@ -483,9 +712,9 @@ step=1; // TEST
ix = utf8_in(&c2,p);
if(c2 == 0)
break;
- if(iswupper(c2))
+ if(iswupper2(c2))
{
- utf8_out(towlower(c2),p);
+ utf8_out(towlower2(c2),p);
}
else
{
@@ -501,14 +730,14 @@ step=1; // TEST
len_word = strlen(word);
- if(transpose_offset > 0)
+ if(translator->transpose_min > 0)
{
- len_word = TransposeAlphabet(word, transpose_offset, transpose_min, transpose_max);
+ len_word = TransposeAlphabet(translator, word);
}
*hash = HashDictionary(word);
len_phonetic = strlen(encoded_ph);
-
+
dict_line[1] = len_word; // bit 6 indicates whether the word has been compressed
len_word &= 0x3f;
@@ -525,7 +754,7 @@ step=1; // TEST
length = len_word + len_phonetic + 3;
strcpy(&dict_line[(len_word)+2],encoded_ph);
}
-
+
for(ix=0; ix<n_flag_codes; ix++)
{
dict_line[ix+length] = flag_codes[ix];
@@ -537,16 +766,15 @@ step=1; // TEST
if(multiple_words > 10)
{
fprintf(f_log,"%5d: Two many parts in a multi-word entry: %d\n",linenum,multiple_words);
+ error_count++;
}
else
{
- dict_line[length++] = 80 + multiple_words + multiple_numeric_hyphen; // if numeric, count a hyphen as an extra word
+ dict_line[length++] = 80 + multiple_words;
ix = multiple_string_end - multiple_string;
if(multiple_numeric_hyphen)
{
- // the first part is numeric, so keep the hyphen to match on
- dict_line[length++] = '-';
- dict_line[length++] = ' ';
+ dict_line[length++] = ' '; // ???
}
memcpy(&dict_line[length],multiple_string,ix);
length += ix;
@@ -554,35 +782,6 @@ step=1; // TEST
}
dict_line[0] = length;
-#ifdef OPT_FORMAT
- spaces = 16;
- for(ix=0; ix<n_flag_codes; ix++)
- {
- if(flag_codes[ix] >= 100)
- {
- fprintf(f_log,"?%d ",flag_codes[ix]-100);
- spaces -= 3;
- }
- }
-
- fprintf(f_log,"%s",word);
- spaces -= strlen(word);
- DecodePhonemes(encoded_ph,decoded_ph);
- while(spaces-- > 0) fputc(' ',f_log);
- spaces += (14 - strlen(decoded_ph));
-
- fprintf(f_log," %s",decoded_ph);
- while(spaces-- > 0) fputc(' ',f_log);
- for(ix=0; ix<n_flag_codes; ix++)
- {
- if(flag_codes[ix] < 100)
- fprintf(f_log," %s",lookup_mnem(mnem_flags,flag_codes[ix]));
- }
- if(comment != NULL)
- fprintf(f_log," %s",comment);
- else
- fputc('\n',f_log);
-#endif
return(length);
} /* end of compile_line */
@@ -630,12 +829,12 @@ static void compile_dictlist_end(FILE *f_out)
fflush(f_log);
#endif
}
-
+
for(hash=0; hash<N_HASH_DICT; hash++)
{
p = hash_chains[hash];
hash_counts[hash] = (int)ftell(f_out);
-
+
while(p != NULL)
{
length = *(p+sizeof(char *));
@@ -658,17 +857,22 @@ static int compile_dictlist_file(const char *path, const char* filename)
char buf[200];
char fname[sizeof(path_home)+45];
char dict_line[128];
-
+
text_mode = 0;
- sprintf(fname,"%s%s",path,filename);
+ // try with and without '.txt' extension
+ sprintf(fname,"%s%s.txt",path,filename);
if((f_in = fopen(fname,"r")) == NULL)
- return(-1);
+ {
+ sprintf(fname,"%s%s",path,filename);
+ if((f_in = fopen(fname,"r")) == NULL)
+ return(-1);
+ }
fprintf(f_log,"Compiling: '%s'\n",fname);
linenum=0;
-
+
while(fgets(buf,sizeof(buf),f_in) != NULL)
{
linenum++;
@@ -677,7 +881,7 @@ static int compile_dictlist_file(const char *path, const char* filename)
if(length == 0) continue; /* blank line */
hash_counts[hash]++;
-
+
p = (char *)malloc(length+sizeof(char *));
if(p == NULL)
{
@@ -688,13 +892,13 @@ static int compile_dictlist_file(const char *path, const char* filename)
}
break;
}
-
+
memcpy(p,&hash_chains[hash],sizeof(char *));
hash_chains[hash] = p;
memcpy(p+sizeof(char *),dict_line,length);
count++;
}
-
+
fprintf(f_log,"\t%d entries\n",count);
fclose(f_in);
return(0);
@@ -708,13 +912,26 @@ static char rule_post[80];
static char rule_match[80];
static char rule_phonemes[80];
static char group_name[LEN_GROUP_NAME+1];
+static int group3_ix;
#define N_RULES 2000 // max rules for each group
-static void copy_rule_string(char *string, int *state)
-{//===================================================
+static int isHexDigit(int c)
+{
+ if((c >= '0') && (c <= '9'))
+ return(c - '0');
+ if((c >= 'a') && (c <= 'f'))
+ return(c - 'a' + 10);
+ if((c >= 'A') && (c <= 'F'))
+ return(c - 'A' + 10);
+ return(-1);
+}
+
+
+static void copy_rule_string(char *string, int *state_out)
+{//=======================================================
// state 0: conditional, 1=pre, 2=match, 3=post, 4=phonemes
static char *outbuf[5] = {rule_cond, rule_pre, rule_match, rule_post, rule_phonemes};
static int next_state[5] = {2,2,4,4,4};
@@ -723,14 +940,18 @@ static void copy_rule_string(char *string, int *state)
int ix;
int len;
char c;
+ int c2, c3;
int sxflags;
int value;
int literal;
+ int hexdigit_input = 0;
+ int state = *state_out;
+ MNEM_TAB *mr;
if(string[0] == 0) return;
- output = outbuf[*state];
- if(*state==4)
+ output = outbuf[state];
+ if(state==4)
{
// append to any previous phoneme string, i.e. allow spaces in the phoneme string
len = strlen(rule_phonemes);
@@ -739,24 +960,44 @@ static void copy_rule_string(char *string, int *state)
output = &rule_phonemes[len];
}
sxflags = 0x808000; // to ensure non-zero bytes
-
+
for(p=string,ix=0;;)
{
literal = 0;
c = *p++;
+ if((c == '0') && (p[0] == 'x') && (isHexDigit(p[1]) >= 0) && (isHexDigit(p[2]) >= 0))
+ {
+ hexdigit_input = 1;
+ c = p[1];
+ p+= 2;
+ }
if(c == '\\')
{
c = *p++; // treat next character literally
+//#ifdef deleted
if((c >= '0') && (c <= '3') && (p[0] >= '0') && (p[0] <= '7') && (p[1] >= '0') && (p[1] <= '7'))
{
// character code given by 3 digit octal value;
c = (c-'0')*64 + (p[0]-'0')*8 + (p[1]-'0');
p += 2;
}
+//endif
literal = 1;
}
-
- if(((*state)==1) || ((*state)==3))
+ if(hexdigit_input)
+ {
+ if(((c2 = isHexDigit(c)) >= 0) && ((c3 = isHexDigit(p[0])) >= 0))
+ {
+ c = c2 * 16 + c3;
+ literal = 1;
+ p++;
+ }
+ else
+ {
+ hexdigit_input = 0;
+ }
+ }
+ if((state==1) || (state==3))
{
// replace special characters (note: 'E' is reserved for a replaced silent 'e')
if(literal == 0)
@@ -776,7 +1017,7 @@ static void copy_rule_string(char *string, int *state)
case 'H':
case 'F':
case 'G':
- if((*state) == 1)
+ if(state == 1)
{
// pre-rule, put the number before the RULE_LETTERGP;
output[ix++] = lettergp_letters[c-'A'] + 'A';
@@ -822,7 +1063,8 @@ static void copy_rule_string(char *string, int *state)
c = RULE_CAPITAL;
break;
case 'T':
- c = RULE_ALT1;
+ output[ix++] = RULE_DOLLAR;
+ c = 0x11;
break;
case 'W':
c = RULE_SPELLING;
@@ -830,6 +1072,9 @@ static void copy_rule_string(char *string, int *state)
case 'X':
c = RULE_NOVOWELS;
break;
+ case 'J':
+ c = RULE_SKIPCHARS;
+ break;
case 'L':
// expect two digits
c = *p++ - '0';
@@ -841,14 +1086,13 @@ static void copy_rule_string(char *string, int *state)
fprintf(f_log,"%5d: Expected 2 digits after 'L'\n",linenum);
error_count++;
}
- else
- if((c <= 0) || (c >= N_LETTER_GROUPS) || (letterGroupsDefined[(int)c] == 0))
+ else if((c <= 0) || (c >= N_LETTER_GROUPS) || (letterGroupsDefined[(int)c] == 0))
{
fprintf(f_log,"%5d: Letter group L%.2d not defined\n",linenum,c);
error_count++;
}
c += 'A';
- if((*state) == 1)
+ if(state == 1)
{
// pre-rule, put the group number before the RULE_LETTERGP command
output[ix++] = c;
@@ -860,10 +1104,40 @@ static void copy_rule_string(char *string, int *state)
}
break;
- case '$': // obsolete, replaced by S
- fprintf(f_log,"%5d: $ now not allowed, use S for suffix",linenum);
+ case '$':
+ value = 0;
+ mr = mnem_rules;
+ while(mr->mnem != NULL)
+ {
+ len = strlen(mr->mnem);
+ if(memcmp(p, mr->mnem, len) == 0)
+ {
+ value = mr->value;
+ p += len;
+ break;
+ }
+ mr++;
+ }
+
+ if(state == 1)
+ {
+ // pre-rule, put the number before the RULE_DOLLAR
+ output[ix++] = value;
+ c = RULE_DOLLAR;
+ }
+ else
+ {
+ output[ix++] = RULE_DOLLAR;
+ c = value;
+ }
+
+ if(value == 0)
+ {
+ fprintf(f_log,"%5d: $ command not recognized\n",linenum);
error_count++;
+ }
break;
+
case 'P':
sxflags |= SUFX_P; // Prefix, now drop through to Suffix
case 'S':
@@ -900,8 +1174,14 @@ static void copy_rule_string(char *string, int *state)
case 'b':
sxflags |= SUFX_B;
break;
+ case 'a':
+ sxflags |= SUFX_A;
+ break;
+ case 'm':
+ sxflags |= SUFX_M;
+ break;
default:
- if(isdigit(c))
+ if(IsDigit09(c))
value = (value*10) + (c - '0');
break;
}
@@ -918,7 +1198,7 @@ static void copy_rule_string(char *string, int *state)
if(c == 0) break;
}
- *state = next_state[*state];
+ *state_out = next_state[state];
} // end of copy_rule_string
@@ -932,12 +1212,13 @@ static char *compile_rule(char *input)
char *prule;
int len;
int len_name;
+ int start;
int state=2;
int finish=0;
- int pre_bracket=0;
char buf[80];
char output[150];
- unsigned char bad_phoneme[4];
+ int bad_phoneme;
+ char bad_phoneme_str[4];
buf[0]=0;
rule_cond[0]=0;
@@ -947,7 +1228,7 @@ static char *compile_rule(char *input)
rule_phonemes[0]=0;
p = buf;
-
+
for(ix=0; finish==0; ix++)
{
c = input[ix];
@@ -957,19 +1238,23 @@ static char *compile_rule(char *input)
case ')': // end of prefix section
*p = 0;
state = 1;
- pre_bracket = 1;
copy_rule_string(buf,&state);
p = buf;
break;
-
+
case '(': // start of suffix section
*p = 0;
state = 2;
copy_rule_string(buf,&state);
state = 3;
p = buf;
+ if(input[ix+1] == ' ')
+ {
+ fprintf(f_log,"%5d: Syntax error. Space after (\n",linenum);
+ error_count++;
+ }
break;
-
+
case '\n': // end of line
case '\r':
case 0: // end of line
@@ -977,14 +1262,14 @@ static char *compile_rule(char *input)
copy_rule_string(buf,&state);
finish=1;
break;
-
+
case '\t': // end of section section
case ' ':
*p = 0;
copy_rule_string(buf,&state);
p = buf;
break;
-
+
case '?':
if(state==2)
state=0;
@@ -997,27 +1282,30 @@ static char *compile_rule(char *input)
break;
}
}
-
+
if(strcmp(rule_match,"$group")==0)
strcpy(rule_match,group_name);
if(rule_match[0]==0)
- return(NULL);
-
- EncodePhonemes(rule_phonemes,buf,bad_phoneme);
- for(ix=0;; ix++)
{
- if((c = buf[ix])==0) break;
- if(c==255)
+ if(rule_post[0] != 0)
{
- fprintf(f_log,"%5d: Bad phoneme [%c] in %s",linenum,bad_phoneme[0],input);
+ fprintf(f_log,"%5d: Syntax error\n",linenum);
error_count++;
- break;
}
+ return(NULL);
+ }
+
+ EncodePhonemes(rule_phonemes,buf,&bad_phoneme);
+ if(bad_phoneme != 0)
+ {
+ bad_phoneme_str[utf8_out(bad_phoneme, bad_phoneme_str)] = 0;
+ fprintf(f_log,"%5d: Bad phoneme [%s] (U+%x) in: %s\n",linenum,bad_phoneme_str,bad_phoneme,input);
+ error_count++;
}
strcpy(output,buf);
len = strlen(buf)+1;
-
+
len_name = strlen(group_name);
if((len_name > 0) && (memcmp(rule_match,group_name,len_name) != 0))
{
@@ -1070,9 +1358,21 @@ static char *compile_rule(char *input)
}
if(rule_pre[0] != 0)
{
- output[len++] = RULE_PRE;
+ start = 0;
+ if(rule_pre[0] == RULE_SPACE)
+ {
+ // omit '_' at the beginning of the pre-string and imply it by using RULE_PRE_ATSTART
+ c = RULE_PRE_ATSTART;
+ start = 1;
+ }
+ else
+ {
+ c = RULE_PRE;
+ }
+ output[len++] = c;
+
// output PRE string in reverse order
- for(ix = strlen(rule_pre)-1; ix>=0; ix--)
+ for(ix = strlen(rule_pre)-1; ix>=start; ix--)
output[len++] = rule_pre[ix];
}
@@ -1089,21 +1389,24 @@ static char *compile_rule(char *input)
static int __cdecl string_sorter(char **a, char **b)
-{//=================================================
+{//===========================================
char *pa, *pb;
int ix;
- if((ix = strcmp(pa = *a,pb = *b)) != 0)
- return(ix);
+ if((ix = strcmp(pa = *a,pb = *b)) != 0)
+ return(ix);
pa += (strlen(pa)+1);
pb += (strlen(pb)+1);
- return(strcmp(pa,pb));
+ return(strcmp(pa,pb));
} /* end of string_sorter */
static int __cdecl rgroup_sorter(RGROUP *a, RGROUP *b)
{//===================================================
+// Sort long names before short names
int ix;
+ ix = strlen(b->name) - strlen(a->name);
+ if(ix != 0) return(ix);
ix = strcmp(a->name,b->name);
if(ix != 0) return(ix);
return(a->start-b->start);
@@ -1135,7 +1438,7 @@ static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name)
len1 = strlen(p) + 1;
p = &p[len1];
len2 = strlen(p);
-
+
rule_match[0]=0;
rule_pre[0]=0;
rule_post[0]=0;
@@ -1173,7 +1476,7 @@ static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name)
}
}
*pout = 0;
-
+
spaces = 12;
if(condition > 0)
{
@@ -1185,19 +1488,19 @@ static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name)
if(rule_pre[0] != 0)
{
p = buf;
- for(ix=strlen(rule_pre)-1;ix>=0;ix--)
+ for(ix=strlen(rule_pre)-1; ix>=0; ix--)
*p++ = rule_pre[ix];
sprintf(p,") ");
spaces -= strlen(buf);
for(ix=0; ix<spaces; ix++)
- fputc(' ',f_out);
+ fputc(' ',f_out);
fprintf(f_out,"%s",buf);
spaces = 0;
}
-
+
for(ix=0; ix<spaces; ix++)
fputc(' ',f_out);
-
+
spaces = 14;
sprintf(buf," %s ",rule_match);
if(rule_post[0] != 0)
@@ -1294,12 +1597,12 @@ static int compile_lettergroup(char *input, FILE *f_out)
int length;
int max_length = 0;
- #define N_LETTERGP_ITEMS 200
+#define N_LETTERGP_ITEMS 200
char *items[N_LETTERGP_ITEMS];
char item_length[N_LETTERGP_ITEMS];
p = input;
- if(!isdigit(p[0]) || !isdigit(p[1]))
+ if(!IsDigit09(p[0]) || !IsDigit09(p[1]))
{
fprintf(f_log,"%5d: Expected 2 digits after '.L'\n",linenum);
error_count++;
@@ -1336,6 +1639,7 @@ static int compile_lettergroup(char *input, FILE *f_out)
items[n_items] = p_start = p;
while((*p & 0xff) > ' ')
{
+ if (*p == '_') *p = ' '; // allow '_' for word break
p++;
}
*p++ = 0;
@@ -1375,16 +1679,18 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
int n_rules=0;
int count=0;
int different;
+ int wc;
const char *prev_rgroup_name;
unsigned int char_code;
int compile_mode=0;
char *buf;
- char buf1[200];
+ char buf1[500];
char *rules[N_RULES];
int n_rgroups = 0;
+ int n_groups3 = 0;
RGROUP rgroup[N_RULE_GROUP2];
-
+
linenum = 0;
group_name[0] = 0;
@@ -1400,7 +1706,7 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
if((p = (unsigned char *)strstr(buf,"//")) != NULL)
*p = 0;
- if(buf[0] == '\r') buf++; // ignore extra \r in \r\n
+ if(buf[0] == '\r') buf++; // ignore extra \r in \r\n
}
if((buf == NULL) || (buf[0] == '.'))
@@ -1410,6 +1716,7 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
if(n_rules > 0)
{
strcpy(rgroup[n_rgroups].name,group_name);
+ rgroup[n_rgroups].group3_ix = group3_ix;
rgroup[n_rgroups].start = ftell(f_temp);
output_rule_group(f_temp,n_rules,rules,group_name);
rgroup[n_rgroups].length = ftell(f_temp) - rgroup[n_rgroups].start;
@@ -1455,12 +1762,13 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
while((*p > ' ') && (ix < LEN_GROUP_NAME))
group_name[ix++] = *p++;
group_name[ix]=0;
-
+ group3_ix = 0;
+
if(sscanf(group_name,"0x%x",&char_code)==1)
{
// group character is given as a character code (max 16 bits)
p = (unsigned char *)group_name;
-
+
if(char_code > 0x100)
{
*p++ = (char_code >> 8);
@@ -1468,22 +1776,33 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
*p++ = char_code;
*p = 0;
}
-
- if(strlen(group_name) > 2)
+ else
+ {
+ if(translator->letter_bits_offset > 0)
+ {
+ utf8_in(&wc, group_name);
+ if(((ix = (wc - translator->letter_bits_offset)) >= 0) && (ix < 128))
+ {
+ group3_ix = ix+1; // not zero
+ }
+ }
+ }
+
+ if((group3_ix == 0) && (strlen(group_name) > 2))
{
if(utf8_in(&c,group_name) < 2)
{
fprintf(f_log,"%5d: Group name longer than 2 bytes (UTF8)",linenum);
error_count++;
}
-
+
group_name[2] = 0;
}
}
continue;
}
-
+
switch(compile_mode)
{
case 1: // .group
@@ -1495,37 +1814,37 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
break;
case 2: // .replace
+ {
+ int replace1;
+ int replace2;
+ char *p;
+
+ p = buf;
+ replace1 = 0;
+ replace2 = 0;
+ while(isspace2(*p)) p++;
+ ix = 0;
+ while((unsigned char)(*p) > 0x20) // not space or zero-byte
{
- int replace1;
- int replace2;
- char *p;
-
- p = buf;
- replace1 = 0;
- replace2 = 0;
- while(isspace2(*p)) p++;
- ix = 0;
- while((unsigned char)(*p) > 0x20) // not space or zero-byte
- {
- p += utf8_in(&c,p);
- replace1 += (c << ix);
- ix += 16;
- }
- while(isspace2(*p)) p++;
- ix = 0;
- while((unsigned char)(*p) > 0x20)
- {
- p += utf8_in(&c,p);
- replace2 += (c << ix);
- ix += 16;
- }
- if(replace1 != 0)
- {
- Write4Bytes(f_out,replace1); // write as little-endian
- Write4Bytes(f_out,replace2); // if big-endian, reverse the bytes in LoadDictionary()
- }
+ p += utf8_in(&c,p);
+ replace1 += (c << ix);
+ ix += 16;
}
- break;
+ while(isspace2(*p)) p++;
+ ix = 0;
+ while((unsigned char)(*p) > 0x20)
+ {
+ p += utf8_in(&c,p);
+ replace2 += (c << ix);
+ ix += 16;
+ }
+ if(replace1 != 0)
+ {
+ Write4Bytes(f_out,replace1); // write as little-endian
+ Write4Bytes(f_out,replace2); // if big-endian, reverse the bytes in LoadDictionary()
+ }
+ }
+ break;
}
}
fclose(f_temp);
@@ -1547,7 +1866,17 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
if(gp > 0)
fputc(RULE_GROUP_END,f_out);
fputc(RULE_GROUP_START,f_out);
- fprintf(f_out, prev_rgroup_name = rgroup[gp].name);
+
+ if(rgroup[gp].group3_ix != 0)
+ {
+ n_groups3++;
+ fputc(1,f_out);
+ fputc(rgroup[gp].group3_ix, f_out);
+ }
+ else
+ {
+ fprintf(f_out, "%s", prev_rgroup_name = rgroup[gp].name);
+ }
fputc(0,f_out);
}
@@ -1565,11 +1894,11 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
fputc(0,f_out);
fclose(f_temp);
-#if 0
+#ifndef _WIN32
remove(fname_temp);
#endif
- fprintf(f_log,"\t%d rules, %d groups\n\n",count,n_rgroups);
+ fprintf(f_log,"\t%d rules, %d groups (%d)\n\n",count,n_rgroups,n_groups3);
return(0);
} // end of compile_dictrules
@@ -1590,6 +1919,7 @@ int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, cha
char path[sizeof(path_home)+40]; // path_dsource+20
error_count = 0;
+ error_need_dictionary = 0;
memset(letterGroupsDefined,0,sizeof(letterGroupsDefined));
debug_flag = flags & 1;
@@ -1602,36 +1932,29 @@ int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, cha
if(f_log == NULL)
f_log = stderr;
+ // try with and without '.txt' extension
sprintf(path,"%s%s_",dsource,dict_name);
- sprintf(fname_in,"%srules",path);
- f_in = fopen_log(fname_in,"r");
- if(f_in == NULL)
+ sprintf(fname_in,"%srules.txt",path);
+ if((f_in = fopen(fname_in,"r")) == NULL)
{
- if(fname_err)
- strcpy(fname_err,fname_in);
- return(-1);
+ sprintf(fname_in,"%srules",path);
+ if((f_in = fopen_log(fname_in,"r")) == NULL)
+ {
+ if(fname_err)
+ strcpy(fname_err,fname_in);
+ return(-1);
+ }
}
sprintf(fname_out,"%s%c%s_dict",path_home,PATHSEP,dict_name);
if((f_out = fopen_log(fname_out,"wb+")) == NULL)
{
if(fname_err)
- strcpy(fname_err,fname_in);
+ strcpy(fname_err,fname_out);
return(-1);
}
sprintf(fname_temp,"%s%ctemp",path_home,PATHSEP);
- transpose_offset = 0;
-
- if(strcmp(dict_name,"ru") == 0)
- {
- // transpose cyrillic alphabet from unicode to iso8859-5
-// transpose_offset = 0x430-0xd0;
- transpose_offset = 0x42f; // range 0x01 to 0x22
- transpose_min = 0x430;
- transpose_max = 0x451;
- }
-
value = N_HASH_DICT;
Write4Bytes(f_out,value);
Write4Bytes(f_out,offset_rules);
@@ -1651,10 +1974,10 @@ int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, cha
compile_dictlist_file(path,"list");
}
compile_dictlist_file(path,"extra");
-
+
compile_dictlist_end(f_out);
offset_rules = ftell(f_out);
-
+
fprintf(f_log,"Compiling: '%s'\n",fname_in);
compile_dictrules(f_in,f_out,fname_temp);
@@ -1663,6 +1986,7 @@ int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, cha
fseek(f_out,4,SEEK_SET);
Write4Bytes(f_out,offset_rules);
fclose(f_out);
+ fflush(f_log);
LoadDictionary(translator, dict_name, 0);
diff --git a/navit/support/espeak/compiledict.h b/navit/support/espeak/compiledict.h
new file mode 100644
index 000000000..089115b37
--- /dev/null
+++ b/navit/support/espeak/compiledict.h
@@ -0,0 +1,20 @@
+/***************************************************************************
+ * Copyright (C) 2005 to 2010 by Jonathan Duddington *
+ * email: jonsd@users.sourceforge.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, see: *
+ * <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len);
+char *DecodeRule(const char *group_chars, int group_length, char *rule, int control);
diff --git a/navit/support/espeak/debug.h b/navit/support/espeak/debug.h
index c3fb9c920..199b2eb87 100644
--- a/navit/support/espeak/debug.h
+++ b/navit/support/espeak/debug.h
@@ -13,7 +13,7 @@ extern void debug_time(const char* text);
#else
-#ifdef PLATFORM_WINDOWS
+#ifdef NO_VARIADIC_MACROS
#define SHOW(format) // VC6 doesn't allow "..."
#else
#define SHOW(format,...)
diff --git a/navit/support/espeak/dictionary.c b/navit/support/espeak/dictionary.c
index d7dd3dc65..bfdbaae43 100755..100644
--- a/navit/support/espeak/dictionary.c
+++ b/navit/support/espeak/dictionary.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -19,8 +19,6 @@
#include "StdAfx.h"
-#define LOG_TRANSLATE
-
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
@@ -34,62 +32,65 @@
#include "phoneme.h"
#include "synthesize.h"
#include "translate.h"
-
+#include "dictionary.h"
+#include "compiledict.h"
int dictionary_skipwords;
char dictionary_name[40];
-extern char *print_dictionary_flags(unsigned int *flags);
-
// accented characters which indicate (in some languages) the start of a separate syllable
//static const unsigned short diereses_list[7] = {L'ä',L'ë',L'ï',L'ö',L'ü',L'ÿ',0};
static const unsigned short diereses_list[7] = {0xe4,0xeb,0xef,0xf6,0xfc,0xff,0};
// convert characters to an approximate 7 bit ascii equivalent
-// used for checking for vowels
-static unsigned char remove_accent[] = {
-'a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i', // 0c0
-'d','n','o','o','o','o','o', 0, 'o','u','u','u','u','y','t','s', // 0d0
-'a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i', // 0e0
-'d','n','o','o','o','o','o', 0 ,'o','u','u','u','u','y','t','y', // 0f0
-
-'a','a','a','a','a','a','c','c','c','c','c','c','c','c','d','d', // 100
-'d','d','e','e','e','e','e','e','e','e','e','e','g','g','g','g', // 110
-'g','g','g','g','h','h','h','h','i','i','i','i','i','i','i','i', // 120
-'i','i','i','i','j','j','k','k','k','l','l','l','l','l','l','l', // 130
-'l','l','l','n','n','n','n','n','n','n','n','n','o','o','o','o', // 140
-'o','o','o','o','r','r','r','r','r','r','s','s','s','s','s','s', // 150
-'s','s','t','t','t','t','t','t','u','u','u','u','u','u','u','u', // 160
-'u','u','u','u','w','w','y','y','y','z','z','z','z','z','z','s', // 170
-'b','b','b','b', 0, 0, 'o','c','c','d','d','d','d','d','e','e', // 180
-'e','f','f','g','g','h','i','i','k','k','l','l','m','n','n','o', // 190
-'o','o','o','o','p','p','y', 0, 0, 's','s','t','t','t','t','u', // 1a0
-'u','u','v','y','y','z','z','z','z','z','z','z', 0, 0, 0, 'w', // 1b0
-'t','t','t','k','d','d','d','l','l','l','n','n','n','a','a','i', // 1c0
-'i','o','o','u','u','u','u','u','u','u','u','u','u','e','a','a', // 1d0
-'a','a','a','a','g','g','g','g','k','k','o','o','o','o','z','z', // 1e0
-'j','d','d','d','g','g','w','w','n','n','a','a','a','a','o','o', // 1f0
-
-'a','a','a','a','e','e','e','e','i','i','i','i','o','o','o','o', // 200
-'r','r','r','r','u','u','u','u','s','s','t','t','y','y','h','h', // 210
-'n','d','o','o','z','z','a','a','e','e','o','o','o','o','o','o', // 220
-'o','o','y','y','l','n','t','j','d','q','a','c','c','l','t','s', // 230
-'z', 0 };
+// used for checking for vowels (up to 0x259=schwa)
+#define N_REMOVE_ACCENT 0x25e
+static unsigned char remove_accent[N_REMOVE_ACCENT] = {
+ 'a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i', // 0c0
+ 'd','n','o','o','o','o','o', 0, 'o','u','u','u','u','y','t','s', // 0d0
+ 'a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i', // 0e0
+ 'd','n','o','o','o','o','o', 0 ,'o','u','u','u','u','y','t','y', // 0f0
+
+ 'a','a','a','a','a','a','c','c','c','c','c','c','c','c','d','d', // 100
+ 'd','d','e','e','e','e','e','e','e','e','e','e','g','g','g','g', // 110
+ 'g','g','g','g','h','h','h','h','i','i','i','i','i','i','i','i', // 120
+ 'i','i','i','i','j','j','k','k','k','l','l','l','l','l','l','l', // 130
+ 'l','l','l','n','n','n','n','n','n','n','n','n','o','o','o','o', // 140
+ 'o','o','o','o','r','r','r','r','r','r','s','s','s','s','s','s', // 150
+ 's','s','t','t','t','t','t','t','u','u','u','u','u','u','u','u', // 160
+ 'u','u','u','u','w','w','y','y','y','z','z','z','z','z','z','s', // 170
+ 'b','b','b','b', 0, 0, 'o','c','c','d','d','d','d','d','e','e', // 180
+ 'e','f','f','g','g','h','i','i','k','k','l','l','m','n','n','o', // 190
+ 'o','o','o','o','p','p','y', 0, 0, 's','s','t','t','t','t','u', // 1a0
+ 'u','u','v','y','y','z','z','z','z','z','z','z', 0, 0, 0, 'w', // 1b0
+ 't','t','t','k','d','d','d','l','l','l','n','n','n','a','a','i', // 1c0
+ 'i','o','o','u','u','u','u','u','u','u','u','u','u','e','a','a', // 1d0
+ 'a','a','a','a','g','g','g','g','k','k','o','o','o','o','z','z', // 1e0
+ 'j','d','d','d','g','g','w','w','n','n','a','a','a','a','o','o', // 1f0
+
+ 'a','a','a','a','e','e','e','e','i','i','i','i','o','o','o','o', // 200
+ 'r','r','r','r','u','u','u','u','s','s','t','t','y','y','h','h', // 210
+ 'n','d','o','o','z','z','a','a','e','e','o','o','o','o','o','o', // 220
+ 'o','o','y','y','l','n','t','j','d','q','a','c','c','l','t','s', // 230
+ 'z', 0, 0, 'b','u','v','e','e','j','j','q','q','r','r','y','y', // 240
+ 'a','a','a','b','o','c','d','d','e','e','e','e','e','e'
+};
+
void strncpy0(char *to,const char *from, int size)
-{//===============================================
- // strcpy with limit, ensures a zero terminator
+{//===================================================
+// strcpy with limit, ensures a zero terminator
strncpy(to,from,size);
to[size-1] = 0;
}
-static int reverse_word_bytes(int word)
-{//=============================
- // reverse the order of bytes from little-endian to big-endian
+int Reverse4Bytes(int word)
+{//==========================
+// reverse the order of bytes from little-endian to big-endian
#ifdef ARCH_BIG
int ix;
int word2 = 0;
@@ -106,8 +107,8 @@ static int reverse_word_bytes(int word)
}
-int LookupMnem(MNEM_TAB *table, char *string)
-{//==========================================
+int LookupMnem(MNEM_TAB *table, const char *string)
+{//==================================================
while(table->mnem != NULL)
{
if(strcmp(string,table->mnem)==0)
@@ -118,7 +119,6 @@ int LookupMnem(MNEM_TAB *table, char *string)
}
-
//=============================================================================================
// Read pronunciation rules and pronunciation lookup dictionary
//
@@ -127,9 +127,9 @@ int LookupMnem(MNEM_TAB *table, char *string)
static void InitGroups(Translator *tr)
{//===================================
-/* Called after dictionary 1 is loaded, to set up table of entry points for translation rule chains
- for single-letters and two-letter combinations
-*/
+// Called after dictionary 1 is loaded, to set up table of entry points for translation rule chains
+// for single-letters and two-letter combinations
+
int ix;
char *p;
@@ -146,6 +146,7 @@ static void InitGroups(Translator *tr)
tr->groups2_start[ix]=255; // indicates "not set"
}
memset(tr->letterGroups,0,sizeof(tr->letterGroups));
+ memset(tr->groups3,0,sizeof(tr->groups3));
p = tr->data_dictrules;
while(*p != 0)
@@ -159,7 +160,7 @@ static void InitGroups(Translator *tr)
if(p[0] == RULE_REPLACEMENTS)
{
- pw = (unsigned int *)(((long)p+4) & ~3); // advance to next word boundary
+ pw = (unsigned int *)(((long64)p+4) & ~3); // advance to next word boundary
tr->langopts.replace_chars = pw;
while(pw[0] != 0)
{
@@ -171,9 +172,9 @@ static void InitGroups(Translator *tr)
pw = (unsigned int *)(tr->langopts.replace_chars);
while(*pw != 0)
{
- *pw = reverse_word_bytes(*pw);
+ *pw = Reverse4Bytes(*pw);
pw++;
- *pw = reverse_word_bytes(*pw);
+ *pw = Reverse4Bytes(*pw);
pw++;
}
#endif
@@ -194,25 +195,29 @@ static void InitGroups(Translator *tr)
len = strlen(p);
p_name = p;
c = p_name[0];
-
+ c2 = p_name[1];
+
p += (len+1);
if(len == 1)
{
tr->groups1[c] = p;
}
- else
- if(len == 0)
+ else if(len == 0)
{
tr->groups1[0] = p;
}
+ else if(c == 1)
+ {
+ // index by offset from letter base
+ tr->groups3[c2 - 1] = p;
+ }
else
{
if(tr->groups2_start[c] == 255)
tr->groups2_start[c] = tr->n_groups2;
-
+
tr->groups2_count[c]++;
tr->groups2[tr->n_groups2] = p;
- c2 = p_name[1];
tr->groups2_name[tr->n_groups2++] = (c + (c2 << 8));
}
}
@@ -240,9 +245,7 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
char fname[sizeof(path_home)+20];
strcpy(dictionary_name,name); // currently loaded dictionary name
-
- if(no_error) // don't load dictionary, just set the dictionary_name
- return(1);
+ strcpy(tr->dictionary_name, name);
// Load a pronunciation data file into memory
// bytes 0-3: offset to rules data
@@ -250,6 +253,12 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
sprintf(fname,"%s%c%s_dict",path_home,PATHSEP,name);
size = GetFileLength(fname);
+ if(tr->data_dictlist != NULL)
+ {
+ Free(tr->data_dictlist);
+ tr->data_dictlist = NULL;
+ }
+
f = fopen(fname,"rb");
if((f == NULL) || (size <= 0))
{
@@ -260,16 +269,13 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
return(1);
}
- if(tr->data_dictlist != NULL)
- Free(tr->data_dictlist);
-
tr->data_dictlist = Alloc(size);
- fread(tr->data_dictlist,size,1,f);
+ size = fread(tr->data_dictlist,1,size,f);
fclose(f);
pw = (int *)(tr->data_dictlist);
- length = reverse_word_bytes(pw[1]);
+ length = Reverse4Bytes(pw[1]);
if(size <= (N_HASH_DICT + sizeof(int)*2))
{
@@ -277,20 +283,16 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
return(2);
}
- if((reverse_word_bytes(pw[0]) != N_HASH_DICT) ||
- (length <= 0) || (length > 0x8000000))
+ if((Reverse4Bytes(pw[0]) != N_HASH_DICT) ||
+ (length <= 0) || (length > 0x8000000))
{
- fprintf(stderr,"Bad data: '%s' (%x length=%x)\n",fname,reverse_word_bytes(pw[0]),length);
+ fprintf(stderr,"Bad data: '%s' (%x length=%x)\n",fname,Reverse4Bytes(pw[0]),length);
return(2);
}
tr->data_dictrules = &(tr->data_dictlist[length]);
// set up indices into data_dictrules
InitGroups(tr);
- if(tr->groups1[0] == NULL)
- {
- fprintf(stderr,"Error in %s_rules, no default rule group\n",name);
- }
// set up hash table for data_dictlist
p = &(tr->data_dictlist[8]);
@@ -305,6 +307,11 @@ int LoadDictionary(Translator *tr, const char *name, int no_error)
p++; // skip over the zero which terminates the list for this hash value
}
+ if((tr->dict_min_size > 0) && (size < (unsigned int)tr->dict_min_size))
+ {
+ fprintf(stderr, "Full dictionary is not installed for '%s'\n", name);
+ }
+
return(0);
} // end of LoadDictionary
@@ -315,18 +322,18 @@ int HashDictionary(const char *string)
This is used to access the dictionary_2 word-lookup dictionary
*/
{
- int c;
+ int c;
int chars=0;
- int hash=0;
+ int hash=0;
- while((c = (*string++ & 0xff)) != 0)
- {
- hash = hash * 8 + c;
- hash = (hash & 0x3ff) ^ (hash >> 8); /* exclusive or */
+ while((c = (*string++ & 0xff)) != 0)
+ {
+ hash = hash * 8 + c;
+ hash = (hash & 0x3ff) ^ (hash >> 8); /* exclusive or */
chars++;
- }
+ }
- return((hash+chars) & 0x3ff); // a 10 bit hash code
+ return((hash+chars) & 0x3ff); // a 10 bit hash code
} // end of HashDictionary
@@ -338,12 +345,12 @@ int HashDictionary(const char *string)
-char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
-/*********************************************************************/
+const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme)
+/******************************************************************/
/* Translate a phoneme string from ascii mnemonics to internal phoneme numbers,
from 'p' up to next blank .
Returns advanced 'p'
- outptr contains encoded phonemes, unrecognised phonemes are encoded as 255
+ outptr contains encoded phonemes, unrecognized phoneme stops the encoding
bad_phoneme must point to char array of length 2 of more
*/
{
@@ -355,7 +362,8 @@ char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
int consumed;
unsigned int mnemonic_word;
- bad_phoneme[0] = 0;
+ if(bad_phoneme != NULL)
+ *bad_phoneme = 0;
// skip initial blanks
while(isspace(*p))
@@ -376,7 +384,7 @@ char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
if((c = p[1]) == '|')
{
// treat double || as a word-break symbol, drop through
- // to the default case with c = '|'
+ // to the default case with c = '|'
}
else
{
@@ -401,11 +409,11 @@ char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
mnemonic_word = phoneme_tab[ix]->mnemonic;
while(((c = p[count]) > ' ') && (count < 4) &&
- (c == ((mnemonic_word >> (count*8)) & 0xff)))
+ (c == ((mnemonic_word >> (count*8)) & 0xff)))
count++;
if((count > max) &&
- ((count == 4) || (((mnemonic_word >> (count*8)) & 0xff)==0)))
+ ((count == 4) || (((mnemonic_word >> (count*8)) & 0xff)==0)))
{
max = count;
max_ph = phoneme_tab[ix]->code;
@@ -414,9 +422,13 @@ char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
if(max_ph == 0)
{
- max_ph = 255; /* not recognised */
- bad_phoneme[0] = *p;
- bad_phoneme[1] = 0;
+ // not recognised, report and ignore
+ if(bad_phoneme != NULL)
+ {
+ utf8_in(bad_phoneme, p);
+ }
+ *outptr++ = 0;
+ return(p+1);
}
if(max <= 0)
@@ -458,23 +470,23 @@ char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
void DecodePhonemes(const char *inptr, char *outptr)
-//==================================================
+{//==================================================
// Translate from internal phoneme codes into phoneme mnemonics
-{
unsigned char phcode;
unsigned char c;
unsigned int mnem;
PHONEME_TAB *ph;
static const char *stress_chars = "==,,'* ";
+ sprintf(outptr,"* ");
while((phcode = *inptr++) > 0)
{
if(phcode == 255)
continue; /* indicates unrecognised phoneme */
if((ph = phoneme_tab[phcode]) == NULL)
continue;
-
- if((ph->type == phSTRESS) && (ph->std_length <= 4) && (ph->spect == 0))
+
+ if((ph->type == phSTRESS) && (ph->std_length <= 4) && (ph->program == 0))
{
if(ph->std_length > 1)
*outptr++ = stress_chars[ph->std_length];
@@ -483,7 +495,7 @@ void DecodePhonemes(const char *inptr, char *outptr)
{
mnem = ph->mnemonic;
- while((c = (mnem & 0xff)) != 0)
+ while((c = (mnem & 0xff)) != 0)
{
*outptr++ = c;
mnem = mnem >> 8;
@@ -501,85 +513,273 @@ void DecodePhonemes(const char *inptr, char *outptr)
} // end of DecodePhonemes
+// using Kirschenbaum to IPA translation, ascii 0x20 to 0x7f
+unsigned short ipa1[96] = {
+ 0x20,0x21,0x22,0x2b0,0x24,0x25,0x0e6,0x2c8,0x28,0x29,0x27e,0x2b,0x2cc,0x2d,0x2e,0x2f,
+ 0x252,0x31,0x32,0x25c,0x34,0x35,0x36,0x37,0x275,0x39,0x2d0,0x2b2,0x3c,0x3d,0x3e,0x294,
+ 0x259,0x251,0x3b2,0xe7,0xf0,0x25b,0x46,0x262,0x127,0x26a,0x25f,0x4b,0x26b,0x271,0x14b,0x254,
+ 0x3a6,0x263,0x280,0x283,0x3b8,0x28a,0x28c,0x153,0x3c7,0xf8,0x292,0x32a,0x5c,0x5d,0x5e,0x5f,
+ 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x261,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
+ 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x303,0x7f
+};
-static void WriteMnemonic(char *phon_out, int *ix, int mnem)
-{//=========================================================
- unsigned char c;
+#define N_PHON_OUT 500 // realloc increment
+static char *phon_out_buf = NULL; // passes the result of GetTranslatedPhonemeString()
+static int phon_out_size = 0;
+
+
+char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int use_ipa, int *flags)
+{//===================================================================================================
+ int c;
+ int mnem;
+ int len;
+ int first;
+ int ix = 0;
+ char *p;
+ PHONEME_DATA phdata;
+
+ if(ph->code == phonEND_WORD)
+ {
+ // ignore
+ phon_out[0] = 0;
+ return(phon_out);
+ }
+
+ if(ph->code == phonSWITCH)
+ {
+ // the tone_ph field contains a phoneme table number
+ p = phoneme_tab_list[plist->tone_ph].name;
+ sprintf(phon_out, "(%s)", p);
+ return(phon_out + strlen(phon_out));
+ }
+
+ if(use_ipa)
+ {
+ // has an ipa name been defined for this phoneme ?
+ phdata.ipa_string[0] = 0;
+
+ if(plist == NULL)
+ {
+ InterpretPhoneme2(ph->code, &phdata);
+ }
+ else
+ {
+ InterpretPhoneme(NULL, 0, plist, &phdata, NULL);
+ }
+
+ p = phdata.ipa_string;
+ if(*p == 0x20)
+ {
+ // indicates no name for this phoneme
+ *phon_out = 0;
+ return(phon_out);
+ }
+ if((*p != 0) && ((*p & 0xff) < 0x20))
+ {
+ // name starts with a flags byte
+ if(flags != NULL)
+ *flags = *p;
+ p++;
+ }
+
+ len = strlen(p);
+ if(len > 0)
+ {
+ strcpy(phon_out, p);
+ phon_out += len;
+ *phon_out = 0;
+ return(phon_out);
+ }
+ }
- while((c = mnem & 0xff) != 0)
+ first = 1;
+ for(mnem = ph->mnemonic; (c = mnem & 0xff) != 0; mnem = mnem >> 8)
{
if((c == '/') && (option_phoneme_variants==0))
break; // discard phoneme variant indicator
- phon_out[(*ix)++]= c;
- // phon_out[phon_out_ix++]= ipa1[c];
- mnem = mnem >> 8;
+
+ if(use_ipa)
+ {
+ // convert from ascii to ipa
+ if(first && (c == '_'))
+ break; // don't show pause phonemes
+
+ if((c == '#') && (ph->type == phVOWEL))
+ break; // # is subscript-h, but only for consonants
+
+ // ignore digits after the first character
+ if(!first && IsDigit09(c))
+ continue;
+
+ if((c >= 0x20) && (c < 128))
+ c = ipa1[c-0x20];
+
+ ix += utf8_out(c, &phon_out[ix]);
+ }
+ else
+ {
+ phon_out[ix++]= c;
+ }
+ first = 0;
}
-}
+ phon_out = &phon_out[ix];
+ *phon_out = 0;
+ return(phon_out);
+} // end of WritePhMnemonic
-void GetTranslatedPhonemeString(char *phon_out, int n_phon_out)
-{//============================================================
-/* Can be called after a clause has been translated into phonemes, in order
- to display the clause in phoneme mnemonic form.
-*/
+
+const char *GetTranslatedPhonemeString(int phoneme_mode)
+{//=======================================================
+ /* Called after a clause has been translated into phonemes, in order
+ to display the clause in phoneme mnemonic form.
+
+ phoneme_mode bits 0-3: 0=only phoneme names, 1=ties, 2=ZWJ, 3=underscore separator
+ bit 4: 0=eSpeak phoneme names, 1=IPA
+ */
int ix;
+ unsigned int len;
int phon_out_ix=0;
int stress;
+ int c;
char *p;
+ char *buf;
+ int count;
+ int flags;
+ int use_ipa;
+ int use_tie;
+ int separate_phonemes = 0;
+ char phon_buf[30];
+ char phon_buf2[30];
PHONEME_LIST *plist;
-
+
static const char *stress_chars = "==,,''";
+ static const int char_tie[] = {0x0361, 0x200d}; // combining-double-inverted-breve, zero-width-joiner
+
+ use_ipa = phoneme_mode & 0x10;
+ use_tie = phoneme_mode & 0x0f;
+
+ if(phon_out_buf == NULL)
+ {
+ phon_out_size = N_PHON_OUT;
+ if((phon_out_buf = (char *)realloc(phon_out_buf, phon_out_size)) == NULL)
+ {
+ phon_out_size = 0;
+ return("");
+ }
+ }
+
+ if(use_tie >= 3)
+ {
+ // separate individual phonemes with underscores
+ separate_phonemes = '_';
+ use_tie = 0;
+ }
- if(phon_out != NULL)
+
+ for(ix=1; ix<(n_phoneme_list-2); ix++)
{
- for(ix=1; ix<(n_phoneme_list-2) && (phon_out_ix < (n_phon_out - 6)); ix++)
+ buf = phon_buf;
+
+ plist = &phoneme_list[ix];
+
+ WritePhMnemonic(phon_buf2, plist->ph, plist, use_ipa, &flags);
+ if(plist->newword)
+ *buf++ = ' ';
+ else
{
- plist = &phoneme_list[ix];
- if(plist->newword)
- phon_out[phon_out_ix++] = ' ';
+ if((separate_phonemes != 0) && (ix > 1))
+ {
+ utf8_in(&c, phon_buf2);
+ if((c < 0x2b0) || (c > 0x36f)) // not if the phoneme starts with a superscript letter
+ {
+ *buf++ = separate_phonemes;
+ }
+ }
+ }
- if(plist->synthflags & SFLAG_SYLLABLE)
+ if(plist->synthflags & SFLAG_SYLLABLE)
+ {
+ if((stress = plist->stresslevel) > 1)
{
- if((stress = plist->stresslevel) > 1)
+ c = 0;
+ if(stress > 5) stress = 5;
+
+ if(use_ipa)
+ {
+ c = 0x2cc; // ipa, secondary stress
+ if(stress > 3)
+ c = 0x02c8; // ipa, primary stress
+ }
+ else
+ {
+ c = stress_chars[stress];
+ }
+
+ if(c != 0)
{
- if(stress > 5) stress = 5;
- phon_out[phon_out_ix++] = stress_chars[stress];
+ buf += utf8_out(c, buf);
+// if(separate_phonemes)
+// *buf++ = separate_phonemes;
}
}
- WriteMnemonic(phon_out, &phon_out_ix, plist->ph->mnemonic);
+ }
+ flags = 0;
+ count = 0;
+ for(p=phon_buf2; *p != 0;)
+ {
+ p += utf8_in(&c, p);
+ if(use_tie > 0)
+ {
+ // look for non-inital alphabetic character, but not diacritic, superscript etc.
+ if((count>0) && !(flags & (1 << (count-1))) && ((c < 0x2b0) || (c > 0x36f)) && iswalpha2(c))
+ {
+ buf += utf8_out(char_tie[use_tie-1], buf);
+ }
+ }
+ buf += utf8_out(c, buf);
+ count++;
+ }
+
+ if(plist->ph->code != phonSWITCH)
+ {
if(plist->synthflags & SFLAG_LENGTHEN)
{
- WriteMnemonic(phon_out, &phon_out_ix, phoneme_tab[phonLENGTHEN]->mnemonic);
+ buf = WritePhMnemonic(buf, phoneme_tab[phonLENGTHEN], NULL, use_ipa, NULL);
}
if((plist->synthflags & SFLAG_SYLLABLE) && (plist->type != phVOWEL))
{
// syllablic consonant
- WriteMnemonic(phon_out, &phon_out_ix, phoneme_tab[phonSYLLABIC]->mnemonic);
+ buf = WritePhMnemonic(buf, phoneme_tab[phonSYLLABIC], NULL, use_ipa, NULL);
}
- if(plist->ph->code == phonSWITCH)
+ if(plist->tone_ph > 0)
{
- // the tone_ph field contains a phoneme table number
- p = phoneme_tab_list[plist->tone_ph].name;
- while(*p != 0)
- {
- phon_out[phon_out_ix++] = *p++;
- }
- phon_out[phon_out_ix++] = ' ';
+ buf = WritePhMnemonic(buf, phoneme_tab[plist->tone_ph], NULL, use_ipa, NULL);
}
- else
- if(plist->tone_ph > 0)
+ }
+
+ len = buf - phon_buf;
+ if((phon_out_ix + len) >= phon_out_size)
+ {
+ // enlarge the phoneme buffer
+ phon_out_size = phon_out_ix + len + N_PHON_OUT;
+ if((phon_out_buf = (char *)realloc(phon_out_buf, phon_out_size)) == NULL)
{
- WriteMnemonic(phon_out, &phon_out_ix, phoneme_tab[plist->tone_ph]->mnemonic);
+ phon_out_size = 0;
+ return("");
}
}
-
- if(phon_out_ix >= n_phon_out)
- phon_out_ix = n_phon_out - 1;
- phon_out[phon_out_ix] = 0;
+
+ phon_buf[len] = 0;
+ strcpy(&phon_out_buf[phon_out_ix], phon_buf);
+ phon_out_ix += len;
}
+ phon_out_buf[phon_out_ix] = 0;
+
+ return(phon_out_buf);
} // end of GetTranslatedPhonemeString
@@ -593,7 +793,7 @@ void GetTranslatedPhonemeString(char *phon_out, int n_phon_out)
static int IsLetterGroup(Translator *tr, char *word, int group, int pre)
{//=====================================================================
- // match the word against a list of utf-8 strings
+// match the word against a list of utf-8 strings
char *p;
char *w;
int len=0;
@@ -613,7 +813,7 @@ static int IsLetterGroup(Translator *tr, char *word, int group, int pre)
{
w = word;
}
- while(*p == *w)
+ while((*p == *w) && (*w != 0))
{
w++;
p++;
@@ -647,137 +847,63 @@ static int IsLetter(Translator *tr, int letter, int group)
if(tr->letter_bits_offset > 0)
{
- if(((letter2 = (letter - tr->letter_bits_offset)) > 0) && (letter2 < 0x80))
- letter = letter2;
+ if(((letter2 = (letter - tr->letter_bits_offset)) > 0) && (letter2 < 0x100))
+ letter = letter2;
else
return(0);
}
else
{
- if((letter >= 0xc0) && (letter <= 0x241))
+ if((letter >= 0xc0) && (letter < N_REMOVE_ACCENT))
return(tr->letter_bits[remove_accent[letter-0xc0]] & (1L << group));
}
- if((letter >= 0) && (letter < 0x80))
+ if((letter >= 0) && (letter < 0x100))
return(tr->letter_bits[letter] & (1L << group));
return(0);
}
-static int IsVowel(Translator *tr, int letter)
-{//===========================================
- return(IsLetter(tr, letter, 0));
+int IsVowel(Translator *tr, int letter)
+{//====================================
+ return(IsLetter(tr, letter, LETTERGP_VOWEL2));
}
-static int Unpronouncable_en(Translator *tr, char *word)
-{//=====================================================
-/* Determines whether a word in 'unpronouncable', i.e. whether it should
- be spoken as individual letters.
-
- This function is language specific.
-*/
-
+static int Unpronouncable2(Translator *tr, char *word)
+{//===================================================
int c;
- int vowel_posn=9;
- int index;
- int count;
- int ix;
- int apostrophe=0;
-
- static unsigned char initials_bitmap[86] = {
- 0x00, 0x00, 0x00, 0x00, 0x22, 0x08, 0x00, 0x88, // 0
- 0x20, 0x24, 0x20, 0x80, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x28, 0x08, 0x00, 0x88, 0x22, 0x04, 0x00, // 16
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x88, 0x22, 0x04, 0x00, 0x02, 0x00, 0x04, // 32
- 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x28, 0x8a, 0x03, 0x00, 0x00, 0x40, 0x00, // 48
- 0x02, 0x00, 0x41, 0xca, 0xbb, 0x06, 0x20, 0x80,
- 0x91, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, // 64
- 0x08, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x22, 0x00, 0x01, 0x00, };
-
-
- // words which we pass through to the dictionary, even though they look unpronouncable
- static const char *exceptions[] = {
- "'s ", "st ","nd ","rd ","th ",NULL };
-
- if((*word == ' ') || (*word == 0))
- return(0);
-
- for(ix=0; exceptions[ix] != NULL; ix++)
- {
- // Seemingly uncpronouncable words, but to be looked in the dictionary rules instead
- if(memcmp(word,exceptions[ix],3)==0)
- return(0);
- }
-
- index=0;
- count=0;
- for(;;)
- {
- index += utf8_in(&c,&word[index]);
- count++;
-
- if((c==0) || (c==' '))
- break;
-
- if(IsVowel(tr, c) || (c == 'y'))
- {
- vowel_posn = count;
- break;
- }
-
- if(c == '\'')
- apostrophe = 1;
- else
- if(!IsAlpha(c))
- return(0); // letter (not vowel) outside Latin character range or apostrophe, abort test
- }
- if((vowel_posn > 5) || ((word[0]!='s') && (vowel_posn > 4)))
- return(1); // no vowel, or no vowel in first four letters
-
- /* there is at least one vowel, is the initial letter combination valid ? */
-
- if(vowel_posn < 3)
- return(0); /* vowel in first two letters, OK */
-
- if(apostrophe)
- return(0); // first two letters not a-z, abort test
-
- index = (word[0]-'a') * 26 + (word[1]-'a');
- if(initials_bitmap[index >> 3] & (1L << (index & 7)))
- return(0);
- else
- return(1); /****/
-} /* end of Unpronounceable */
-
-
+ int end_flags;
+ char ph_buf[N_WORD_PHONEMES];
+
+ ph_buf[0] = 0;
+ c = word[-1];
+ word[-1] = ' '; // ensure there is a space before the "word"
+ end_flags = TranslateRules(tr, word, ph_buf, sizeof(ph_buf), NULL, FLAG_UNPRON_TEST, NULL);
+ word[-1] = c;
+ if((end_flags == 0) || (end_flags & SUFX_UNPRON))
+ return(1);
+ return(0);
+}
-int Unpronouncable(Translator *tr, char *word)
-{//===========================================
-/* Determines whether a word in 'unpronouncable', i.e. whether it should
- be spoken as individual letters.
+int Unpronouncable(Translator *tr, char *word, int posn)
+{//=====================================================
+ /* Determines whether a word in 'unpronouncable', i.e. whether it should
+ be spoken as individual letters.
- This function may be language specific. This is a generic version.
-*/
+ This function may be language specific. This is a generic version.
+ */
int c;
int c1=0;
int vowel_posn=9;
int index;
int count;
- int apostrophe=0;
-
- if(tr->translator_name == L('e','n'))
- {
- return(Unpronouncable_en(tr,word));
- }
+ ALPHABET *alphabet;
utf8_in(&c,word);
if((tr->letter_bits_offset > 0) && (c < 0x241))
@@ -786,10 +912,16 @@ int Unpronouncable(Translator *tr, char *word)
return(0); // so we can re-translate the word as English
}
+ if(((alphabet = AlphabetFromChar(c)) != NULL) && (alphabet->offset != tr->letter_bits_offset))
+ {
+ // Character is not in our alphabet
+ return(0);
+ }
+
if(tr->langopts.param[LOPT_UNPRONOUNCABLE] == 1)
return(0);
- if((*word == ' ') || (*word == 0))
+ if(((c = *word) == ' ') || (c == 0) || (c == '\''))
return(0);
index = 0;
@@ -800,9 +932,18 @@ int Unpronouncable(Translator *tr, char *word)
if((c==0) || (c==' '))
break;
+ if((c=='\'') && ((count > 1) || (posn > 0)))
+ break; // "tv'" but not "l'"
+
if(count==0)
c1 = c;
- count++;
+
+ if((c == '\'') && (tr->langopts.param[LOPT_UNPRONOUNCABLE] == 3))
+ {
+ // don't count apostrophe
+ }
+ else
+ count++;
if(IsVowel(tr, c))
{
@@ -810,23 +951,23 @@ int Unpronouncable(Translator *tr, char *word)
break;
}
- if(c == '\'')
- apostrophe = 1;
- else
- if(!iswalpha(c))
- return(0); // letter (not vowel) outside a-z range or apostrophe, abort test
+ if((c != '\'') && !iswalpha2(c))
+ return(0);
}
- if((vowel_posn < 9) && (tr->langopts.param[LOPT_UNPRONOUNCABLE] == 2))
- return(0); // option means allow any word with a vowel
+ if((vowel_posn > 2) && (tr->langopts.param[LOPT_UNPRONOUNCABLE] == 2))
+ {
+ // Lookup unpronounable rules in *_rules
+ return(Unpronouncable2(tr, word));
+ }
if(c1 == tr->langopts.param[LOPT_UNPRONOUNCABLE])
vowel_posn--; // disregard this as the initial letter when counting
if(vowel_posn > (tr->langopts.max_initial_consonants+1))
- return(1); // no vowel, or no vowel in first four letters
+ return(1); // no vowel, or no vowel in first few letters
-return(0);
+ return(0);
} /* end of Unpronounceable */
@@ -839,26 +980,26 @@ return(0);
-static int GetVowelStress(Translator *tr, unsigned char *phonemes, unsigned char *vowel_stress, int *vowel_count, int *stressed_syllable, int control)
-{//====================================================================================================================================================
+static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char *vowel_stress, int *vowel_count, int *stressed_syllable, int control)
+{//=================================================================================================================================================
// control = 1, set stress to 1 for forced unstressed vowels
unsigned char phcode;
PHONEME_TAB *ph;
unsigned char *ph_out = phonemes;
int count = 1;
- int max_stress = 0;
+ int max_stress = -1;
int ix;
int j;
- int stress = 0;
+ int stress = -1;
int primary_posn = 0;
- vowel_stress[0] = 0;
+ vowel_stress[0] = 1;
while(((phcode = *phonemes++) != 0) && (count < (N_WORD_PHONEMES/2)-1))
{
if((ph = phoneme_tab[phcode]) == NULL)
continue;
- if((ph->type == phSTRESS) && (ph->spect == 0))
+ if((ph->type == phSTRESS) && (ph->program == 0))
{
/* stress marker, use this for the following vowel */
@@ -868,7 +1009,7 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, unsigned char
j = count - 1;
while((j > 0) && (*stressed_syllable == 0) && (vowel_stress[j] < 4))
{
- if(vowel_stress[j] != 1)
+ if((vowel_stress[j] != 0) && (vowel_stress[j] != 1))
{
// don't promote a phoneme which must be unstressed
vowel_stress[j] = 4;
@@ -878,7 +1019,7 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, unsigned char
max_stress = 4;
primary_posn = j;
}
-
+
/* reduce any preceding primary stress markers */
for(ix=1; ix<j; ix++)
{
@@ -912,14 +1053,13 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, unsigned char
max_stress = stress;
}
- if((stress == 0) && (control & 1) && (ph->phflags & phUNSTRESSED))
+ if((stress < 0) && (control & 1) && (ph->phflags & phUNSTRESSED))
vowel_stress[count] = 1; /* weak vowel, must be unstressed */
count++;
- stress = 0;
+ stress = -1;
}
- else
- if(phcode == phonSYLLABIC)
+ else if(phcode == phonSYLLABIC)
{
// previous consonant phoneme is syllablic
vowel_stress[count] = (char)stress;
@@ -929,7 +1069,7 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, unsigned char
*ph_out++ = phcode;
}
- vowel_stress[count] = 0;
+ vowel_stress[count] = 1;
*ph_out = 0;
/* has the position of the primary stress been specified by $1, $2, etc? */
@@ -950,8 +1090,8 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, unsigned char
{
if(vowel_stress[ix] == 4)
{
- if(tr->langopts.stress_flags & 0x20000)
- vowel_stress[ix] = 0;
+ if(tr->langopts.stress_flags & S_PRIORITY_STRESS)
+ vowel_stress[ix] = 1;
else
vowel_stress[ix] = 3;
}
@@ -972,8 +1112,9 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, unsigned char
-static char stress_phonemes[] = {phonSTRESS_U, phonSTRESS_D, phonSTRESS_2, phonSTRESS_3,
- phonSTRESS_P, phonSTRESS_P2, phonSTRESS_TONIC};
+static char stress_phonemes[] = {phonSTRESS_D, phonSTRESS_U, phonSTRESS_2, phonSTRESS_3,
+ phonSTRESS_P, phonSTRESS_P2, phonSTRESS_TONIC
+ };
void ChangeWordStress(Translator *tr, char *word, int new_stress)
@@ -984,7 +1125,7 @@ void ChangeWordStress(Translator *tr, char *word, int new_stress)
int vowel_count; // num of vowels + 1
int stressed_syllable=0; // position of stressed syllable
unsigned char phonetic[N_WORD_PHONEMES];
- unsigned char vowel_stress[N_WORD_PHONEMES/2];
+ signed char vowel_stress[N_WORD_PHONEMES/2];
strcpy((char *)phonetic,word);
max_stress = GetVowelStress(tr, phonetic, vowel_stress, &vowel_count, &stressed_syllable, 0);
@@ -1018,8 +1159,8 @@ void ChangeWordStress(Translator *tr, char *word, int new_stress)
{
if((phoneme_tab[*p]->type == phVOWEL) && !(phoneme_tab[*p]->phflags & phNONSYLLABIC))
{
- if(vowel_stress[ix] != 0)
- *word++ = stress_phonemes[vowel_stress[ix]];
+ if((vowel_stress[ix] == 0) || (vowel_stress[ix] > 1))
+ *word++ = stress_phonemes[(unsigned char)vowel_stress[ix]];
ix++;
}
@@ -1030,17 +1171,19 @@ void ChangeWordStress(Translator *tr, char *word, int new_stress)
-void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress)
-{//=========================================================================================================
+void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int control)
+{//=====================================================================================================
/* Guess stress pattern of word. This is language specific
+ 'output' is used for input and output
+
'dictionary_flags' has bits 0-3 position of stressed vowel (if > 0)
- or unstressed (if == 7) or syllables 1 and 2 (if == 6)
- bits 8... dictionary flags
+ or unstressed (if == 7) or syllables 1 and 2 (if == 6)
+ bits 8... dictionary flags
If 'tonic' is set (>= 0), replace highest stress by this value.
- Parameter used for input and output
+ control: bit 0 This is an individual symbol, not a word
*/
unsigned char phcode;
@@ -1059,13 +1202,15 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
int final_ph;
int final_ph2;
int mnem;
- int mnem2;
- int post_tonic;
+// int post_tonic; // currently not used
int opt_length;
int done;
int stressflags;
+ int dflags = 0;
+ int first_primary;
+ int long_vowel;
- unsigned char vowel_stress[N_WORD_PHONEMES/2];
+ signed char vowel_stress[N_WORD_PHONEMES/2];
char syllable_weight[N_WORD_PHONEMES/2];
char vowel_length[N_WORD_PHONEMES/2];
unsigned char phonetic[N_WORD_PHONEMES];
@@ -1082,6 +1227,9 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
stressflags = tr->langopts.stress_flags;
+ if(dictionary_flags != NULL)
+ dflags = dictionary_flags[0];
+
/* copy input string into internal buffer */
for(ix=0; ix<N_WORD_PHONEMES; ix++)
{
@@ -1098,22 +1246,19 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
max_output = output + (N_WORD_PHONEMES-3); /* check for overrun */
- // any stress position marked in the xx_list dictionary ?
- stressed_syllable = (*dictionary_flags) & 0x7;
- if((*dictionary_flags) & 0x8)
+ // any stress position marked in the xx_list dictionary ?
+ stressed_syllable = dflags & 0x7;
+ if(dflags & 0x8)
{
// this indicates a word without a primary stress
- stressed_syllable = (*dictionary_flags) & 0x3;
+ stressed_syllable = dflags & 0x3;
unstressed_word = 1;
}
max_stress = GetVowelStress(tr, phonetic, vowel_stress, &vowel_count, &stressed_syllable, 1);
-
- if((max_stress == 0) && (tr->langopts.stress_flags & 1) && (vowel_count == 2))
+ if((max_stress < 0) && dictionary_flags)
{
- // option: don't stress monosyllables except at end-of-clause
- vowel_stress[1] = 1;
- (*dictionary_flags) |= FLAG_STRESS_END2;
+ max_stress = 0;
}
// heavy or light syllables
@@ -1146,12 +1291,13 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
ix++;
}
}
-
+
+
switch(tr->langopts.stress_rule)
{
case 8:
- // stress on first syllable, unless it is a light syllable
- if(syllable_weight[1] > 0)
+ // stress on first syllable, unless it is a light syllable followed by a heavy syllable
+ if((syllable_weight[1] > 0) || (syllable_weight[2] == 0))
break;
// else drop through to case 1
case 1:
@@ -1167,6 +1313,17 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
break;
+ case 10: // penultimate, but final if only 1 or 2 syllables
+ if(stressed_syllable == 0)
+ {
+ if(vowel_count < 4)
+ {
+ vowel_stress[vowel_count - 1] = 4;
+ max_stress = 4;
+ break;
+ }
+ }
+ // drop through to next case
case 2:
// a language with stress on penultimate vowel
@@ -1179,33 +1336,40 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
{
stressed_syllable = vowel_count - 2;
- if(stressflags & 0x300)
+ if(stressflags & (S_FINAL_SPANISH | S_FINAL_STRESS_C))
{
// LANG=Spanish, stress on last vowel if the word ends in a consonant other than 'n' or 's'
if(phoneme_tab[final_ph]->type != phVOWEL)
{
- if(stressflags & 0x100)
+ if(stressflags & S_FINAL_STRESS_C)
{
stressed_syllable = vowel_count - 1;
}
else
{
mnem = phoneme_tab[final_ph]->mnemonic;
- mnem2 = phoneme_tab[final_ph2]->mnemonic;
- if((mnem == 's') && (mnem2 == 'n'))
+ if(tr->translator_name == L('a','n'))
{
- // -ns stress remains on penultimate syllable
+ if(((mnem != 's') && (mnem !='n')) || phoneme_tab[final_ph2]->type != phVOWEL)
+ stressed_syllable = vowel_count - 1; // stress on last syllable
}
else
- if(((mnem != 'n') && (mnem != 's')) || (phoneme_tab[final_ph2]->type != phVOWEL))
{
- stressed_syllable = vowel_count - 1;
+ if((mnem == 's') && (phoneme_tab[final_ph2]->type == phNASAL))
+ {
+ // -ns stress remains on penultimate syllable
+ }
+ else if(((phoneme_tab[final_ph]->type != phNASAL) && (mnem != 's')) || (phoneme_tab[final_ph2]->type != phVOWEL))
+ {
+ stressed_syllable = vowel_count - 1;
+ }
}
}
}
}
- if(stressflags & 0x80000)
+
+ if(stressflags & S_FINAL_LONG)
{
// stress on last syllable if it has a long vowel, but previous syllable has a short vowel
if(vowel_length[vowel_count - 1] > vowel_length[vowel_count - 2])
@@ -1214,7 +1378,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
}
- if(vowel_stress[stressed_syllable] == 1)
+ if((vowel_stress[stressed_syllable] == 0) || (vowel_stress[stressed_syllable] == 1))
{
// but this vowel is explicitly marked as unstressed
if(stressed_syllable > 1)
@@ -1229,7 +1393,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
// only set the stress if it's not already marked explicitly
- if(vowel_stress[stressed_syllable] == 0)
+ if(vowel_stress[stressed_syllable] < 0)
{
// don't stress if next and prev syllables are stressed
if((vowel_stress[stressed_syllable-1] < 4) || (vowel_stress[stressed_syllable+1] < 4))
@@ -1238,24 +1402,23 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
break;
- case 3:
+ case 3:
// stress on last vowel
if(stressed_syllable == 0)
{
/* no explicit stress - stress the final vowel */
stressed_syllable = vowel_count - 1;
- if(max_stress == 0)
+
+ while(stressed_syllable > 0)
{
- while(stressed_syllable > 0)
+ // find the last vowel which is not unstressed
+ if(vowel_stress[stressed_syllable] < 0)
{
- if(vowel_stress[stressed_syllable] == 0)
- {
- vowel_stress[stressed_syllable] = 4;
- break;
- }
- else
- stressed_syllable--;
+ vowel_stress[stressed_syllable] = 4;
+ break;
}
+ else
+ stressed_syllable--;
}
max_stress = 4;
}
@@ -1290,8 +1453,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
{
if(phoneme_tab[final_ph]->type == phVOWEL)
stressed_syllable = guess_ru_v[vowel_count];
- else
- if(phoneme_tab[final_ph]->type == phSTOP)
+ else if(phoneme_tab[final_ph]->type == phSTOP)
stressed_syllable = guess_ru_t[vowel_count];
else
stressed_syllable = guess_ru[vowel_count];
@@ -1306,17 +1468,17 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
{
int wt;
int max_weight = -1;
- int prev_stressed;
+// int prev_stressed;
// find the heaviest syllable, excluding the final syllable
for(ix = 1; ix < (vowel_count-1); ix++)
{
- if(vowel_stress[ix] == 0)
+ if(vowel_stress[ix] < 0)
{
if((wt = syllable_weight[ix]) >= max_weight)
{
max_weight = wt;
- prev_stressed = stressed_syllable;
+// prev_stressed = stressed_syllable;
stressed_syllable = ix;
}
}
@@ -1327,8 +1489,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
// the only double=heavy syllable is the final syllable, so stress this
stressed_syllable = vowel_count-1;
}
- else
- if(max_weight <= 0)
+ else if(max_weight <= 0)
{
// all syllables, exclusing the last, are light. Stress the first syllable
stressed_syllable = 1;
@@ -1339,7 +1500,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
break;
- case 7: // LANG=tr, the last syllable for any vowel markes explicitly as unstressed
+ case 7: // LANG=tr, the last syllable for any vowel marked explicitly as unstressed
if(stressed_syllable == 0)
{
stressed_syllable = vowel_count - 1;
@@ -1359,10 +1520,54 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
case 9: // mark all as stressed
for(ix=1; ix<vowel_count; ix++)
{
- if(vowel_stress[ix] == 0)
+ if(vowel_stress[ix] < 0)
vowel_stress[ix] = 4;
}
break;
+
+ case 12: // LANG=kl (Greenlandic)
+ long_vowel = 0;
+ for(ix=1; ix < vowel_count; ix++)
+ {
+ if(vowel_stress[ix] == 4)
+ vowel_stress[ix] = 3; // change marked stress (consonant clusters) to secondary (except the last)
+
+ if(vowel_length[ix] > 0)
+ {
+ long_vowel = ix;
+ vowel_stress[ix] = 3; // give secondary stress to all long vowels
+ }
+ }
+
+ // 'stressed_syllable' gives the last marked stress
+ if(stressed_syllable == 0)
+ {
+ // no marked stress, choose the last long vowel
+ if(long_vowel > 0)
+ stressed_syllable = long_vowel;
+ else
+ {
+ // no long vowels or consonant clusters
+ if(vowel_count > 5)
+ stressed_syllable = vowel_count - 3; // more than 4 syllables
+ else
+ stressed_syllable = vowel_count - 1;
+ }
+ }
+ vowel_stress[stressed_syllable] = 4;
+ max_stress = 4;
+ break;
+
+ case 13: // LANG=ml, 1st unless 1st vowel is short and 2nd is long
+ if(stressed_syllable == 0)
+ {
+ stressed_syllable = 1;
+ if((vowel_length[1] == 0) && (vowel_count > 2) && (vowel_length[2] > 0))
+ stressed_syllable = 2;
+ vowel_stress[stressed_syllable] = 4;
+ max_stress = 4;
+ }
+ break;
}
/* now guess the complete stress pattern */
@@ -1372,50 +1577,51 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
stress = 3;
- if((stressflags & 0x1000) && (vowel_count == 2))
+ if(unstressed_word == 0)
{
- // Two syllable word, if one syllable has primary stress, then give the other secondary stress
- if(vowel_stress[1] == 4)
- vowel_stress[2] = 3;
- if(vowel_stress[2] == 4)
- vowel_stress[1] = 3;
- }
-#if deleted
- if((stressflags & 0x2000) && (vowel_stress[1] == 0))
- {
- // If there is only one syllable before the primary stress, give it a secondary stress
- if((vowel_count > 2) && (vowel_stress[2] >= 4))
+ if((stressflags & S_2_SYL_2) && (vowel_count == 3))
+ {
+ // Two syllable word, if one syllable has primary stress, then give the other secondary stress
+ if(vowel_stress[1] == 4)
+ vowel_stress[2] = 3;
+ if(vowel_stress[2] == 4)
+ vowel_stress[1] = 3;
+ }
+
+ if((stressflags & S_INITIAL_2) && (vowel_stress[1] < 0))
{
- vowel_stress[1] = 3;
+ // If there is only one syllable before the primary stress, give it a secondary stress
+ if((vowel_count > 3) && (vowel_stress[2] >= 4))
+ {
+ vowel_stress[1] = 3;
+ }
}
}
-#endif
done = 0;
+ first_primary = 0;
for(v=1; v<vowel_count; v++)
{
- if(vowel_stress[v] == 0)
+ if(vowel_stress[v] < 0)
{
- if((stressflags & 0x10) && (stress < 4) && (v == vowel_count-1))
+ if((stressflags & S_FINAL_NO_2) && (stress < 4) && (v == vowel_count-1))
{
// flag: don't give secondary stress to final vowel
}
- else
- if((stressflags & 0x8000) && (done == 0))
+ else if((stressflags & 0x8000) && (done == 0))
{
vowel_stress[v] = (char)stress;
done =1;
stress = 3; /* use secondary stress for remaining syllables */
}
- else
- if((vowel_stress[v-1] <= 1) && ((vowel_stress[v+1] <= 1) || ((stress == 4) && (vowel_stress[v+1] <= 2))))
+ else if((vowel_stress[v-1] <= 1) && ((vowel_stress[v+1] <= 1) || ((stress == 4) && (vowel_stress[v+1] <= 2))))
{
/* trochaic: give stress to vowel surrounded by unstressed vowels */
- if((stress == 3) && (stressflags & 0x20))
+ if((stress == 3) && (stressflags & S_NO_AUTO_2))
continue; // don't use secondary stress
- if((v > 1) && (stressflags & 0x40) && (syllable_weight[v]==0) && (syllable_weight[v+1]>0))
+ if((v > 1) && (stressflags & S_2_TO_HEAVY) && (syllable_weight[v]==0) && (syllable_weight[v+1]>0))
{
// don't put secondary stress on a light syllable which is followed by a heavy syllable
continue;
@@ -1428,6 +1634,17 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
stress = 3; /* use secondary stress for remaining syllables */
}
}
+
+ if(vowel_stress[v] >= 4)
+ {
+ if(first_primary == 0)
+ first_primary = v;
+ else if(stressflags & S_FIRST_PRIMARY)
+ {
+ // reduce primary stresses after the first to secondary
+ vowel_stress[v] = 3;
+ }
+ }
}
if((unstressed_word) && (tonic < 0))
@@ -1464,11 +1681,14 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
p = phonetic;
v = 1;
- if((ph = phoneme_tab[*p]) != NULL)
+ if(!(control & 1) && ((ph = phoneme_tab[*p]) != NULL))
{
- if(ph->type == phSTRESS)
- ph = phoneme_tab[p[1]];
+ while((ph->type == phSTRESS) || (*p == phonEND_WORD))
+ {
+ p++;
+ ph = phoneme_tab[p[0]];
+ }
#ifdef deleted
int gap = tr->langopts.word_gap & 0x700;
@@ -1479,23 +1699,23 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
else
#endif
- if((tr->langopts.vowel_pause & 0x30) && (ph->type == phVOWEL))
- {
- // word starts with a vowel
-
- if((tr->langopts.vowel_pause & 0x20) && (vowel_stress[1] >= 4))
+ if((tr->langopts.vowel_pause & 0x30) && (ph->type == phVOWEL))
{
+ // word starts with a vowel
+
+ if((tr->langopts.vowel_pause & 0x20) && (vowel_stress[1] >= 4))
+ {
*output++ = phonPAUSE_NOLINK; // not to be replaced by link
+ }
+ else
+ {
+ *output++ = phonPAUSE_VSHORT; // break, but no pause
+ }
}
- else
- {
- *output++ = phonPAUSE_VSHORT; // break, but no pause
- }
- }
}
p = phonetic;
- post_tonic = 0;
+// post_tonic = 0;
while(((phcode = *p++) != 0) && (output < max_output))
{
if((ph = phoneme_tab[phcode]) == NULL)
@@ -1508,49 +1728,46 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
{
tr->prev_last_stress = 0;
}
- else
- if(((ph->type == phVOWEL) && !(ph->phflags & phNONSYLLABIC)) || (*p == phonSYLLABIC))
+ else if(((ph->type == phVOWEL) && !(ph->phflags & phNONSYLLABIC)) || (*p == phonSYLLABIC))
{
// a vowel, or a consonant followed by a syllabic consonant marker
v_stress = vowel_stress[v];
tr->prev_last_stress = v_stress;
- if(vowel_stress[v-1] >= max_stress)
- post_tonic = 1;
+// if(vowel_stress[v-1] >= max_stress)
+// post_tonic = 1;
if(v_stress <= 1)
{
- if((v > 1) && (max_stress >= 4) && (stressflags & 4) && (v == (vowel_count-1)))
+ if((v > 1) && (max_stress >= 2) && (stressflags & S_FINAL_DIM) && (v == (vowel_count-1)))
{
// option: mark unstressed final syllable as diminished
- v_stress = 1;
+ v_stress = 0;
}
- else
- if((stressflags & 2) || (v == 1) || (v == (vowel_count-1)))
+ else if((stressflags & S_NO_DIM) || (v == 1) || (v == (vowel_count-1)))
{
// first or last syllable, or option 'don't set diminished stress'
- v_stress = 0;
+ v_stress = 1;
}
- else
- if((v == (vowel_count-2)) && (vowel_stress[vowel_count-1] <= 1))
+ else if((v == (vowel_count-2)) && (vowel_stress[vowel_count-1] <= 1))
{
// penultimate syllable, followed by an unstressed final syllable
- v_stress = 0;
+ v_stress = 1;
}
else
{
// unstressed syllable within a word
- if((vowel_stress[v-1] != 1) || ((stressflags & 0x10000) == 0))
+ if((vowel_stress[v-1] < 0) || ((stressflags & S_MID_DIM) == 0))
{
- v_stress = 1; /* change from 0 (unstressed) to 1 (diminished stress) */
+ v_stress = 0; /* change to 0 (diminished stress) */
vowel_stress[v] = v_stress;
}
}
}
- if(v_stress > 0)
- *output++ = stress_phonemes[v_stress]; // mark stress of all vowels except 0 (unstressed)
+ if((v_stress == 0) || (v_stress > 1))
+ *output++ = stress_phonemes[v_stress]; // mark stress of all vowels except 1 (unstressed)
if(vowel_stress[v] > max_stress)
@@ -1569,8 +1786,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
if(v != max_stress_posn)
shorten = 1;
}
- else
- if(v_stress < 4)
+ else if(v_stress < 4)
{
// only allow lengthen indicator if stress >= 4.
shorten = 1;
@@ -1598,6 +1814,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
}
*output++ = 0;
+ return;
} /* end of SetWordStress */
@@ -1609,153 +1826,6 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
//=============================================================================================
-#ifdef LOG_TRANSLATE
-static char *DecodeRule(const char *group, char *rule)
-{//==================================================
-/* Convert compiled match template to ascii */
-
- unsigned char rb;
- unsigned char c;
- char *p;
- int ix;
- int match_type;
- int finished=0;
- int value;
- int linenum=0;
- int flags;
- int suffix_char;
- int condition_num=0;
- char buf[60];
- char buf_pre[60];
- char suffix[20];
- static char output[60];
-
- static char symbols[] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',
- '@','&','%','+','#','S','D','Z','A','L',' ',' ',' ',' ',' ','N','K','V',' ','T','X','?','W'};
-
- static char symbols_lg[] = {'A','B','C','H','F','G','Y'};
-
- match_type = 0;
- buf_pre[0] = 0;
- strcpy(buf,group);
- p = &buf[strlen(buf)];
- while(!finished)
- {
- rb = *rule++;
-
- if(rb <= RULE_LINENUM)
- {
- switch(rb)
- {
- case 0:
- case RULE_PHONEMES:
- finished=1;
- break;
- case RULE_PRE:
- match_type = RULE_PRE;
- *p = 0;
- p = buf_pre;
- break;
- case RULE_POST:
- match_type = RULE_POST;
- *p = 0;
- strcat(buf," (");
- p = &buf[strlen(buf)];
- break;
- case RULE_PH_COMMON:
- break;
- case RULE_CONDITION:
- /* conditional rule, next byte gives condition number */
- condition_num = *rule++;
- break;
- case RULE_LINENUM:
- value = (rule[1] & 0xff) - 1;
- linenum = (rule[0] & 0xff) - 1 + (value * 255);
- rule+=2;
- break;
- }
- continue;
- }
-
- if(rb == RULE_ENDING)
- {
- static const char *flag_chars = "ei vtfq t";
- flags = ((rule[0] & 0x7f)<< 8) + (rule[1] & 0x7f);
- suffix_char = 'S';
- if(flags & (SUFX_P >> 8))
- suffix_char = 'P';
- sprintf(suffix,"%c%d",suffix_char,rule[2] & 0x7f);
- rule += 3;
- for(ix=0;ix<9;ix++)
- {
- if(flags & 1)
- sprintf(&suffix[strlen(suffix)],"%c",flag_chars[ix]);
- flags = (flags >> 1);
- }
- strcpy(p,suffix);
- p += strlen(suffix);
- c = ' ';
- }
- else
- if(rb == RULE_LETTERGP)
- {
- c = symbols_lg[*rule++ - 'A'];
- }
- else
- if(rb == RULE_LETTERGP2)
- {
- value = *rule++ - 'A';
- p[0] = 'L';
- p[1] = (value / 10) + '0';
- c = (value % 10) + '0';
-
- if(match_type == RULE_PRE)
- {
- p[0] = c;
- c = 'L';
- }
- p+=2;
- }
- else
- if(rb <= RULE_LAST_RULE)
- c = symbols[rb];
- else
- if(rb == RULE_SPACE)
- c = '_';
- else
- c = rb;
- *p++ = c;
- }
- *p = 0;
-
- p = output;
- if(linenum > 0)
- {
- sprintf(p,"%5d:\t",linenum);
- p += 7;
- }
- if(condition_num > 0)
- {
- sprintf(p,"?%d ",condition_num);
- p = &p[strlen(p)];
- }
- if((ix = strlen(buf_pre)) > 0)
- {
- while(--ix >= 0)
- *p++ = buf_pre[ix];
- *p++ = ')';
- *p++ = ' ';
- }
- *p = 0;
- strcat(p,buf);
- ix = strlen(output);
- while(ix < 8)
- output[ix++]=' ';
- output[ix]=0;
- return(output);
-} /* end of decode_match */
-#endif
-
void AppendPhonemes(Translator *tr, char *string, int size, const char *ph)
@@ -1763,7 +1833,7 @@ void AppendPhonemes(Translator *tr, char *string, int size, const char *ph)
/* Add new phoneme string "ph" to "string"
Keeps count of the number of vowel phonemes in the word, and whether these
can be stressed syllables. These values can be used in translation rules
-*/
+*/
const char *p;
unsigned char c;
int unstress_mark;
@@ -1792,7 +1862,7 @@ void AppendPhonemes(Translator *tr, char *string, int size, const char *ph)
if(phoneme_tab[c]->type == phVOWEL)
{
if(((phoneme_tab[c]->phflags & phUNSTRESSED) == 0) &&
- (unstress_mark == 0))
+ (unstress_mark == 0))
{
tr->word_stressed_count++;
}
@@ -1801,15 +1871,15 @@ void AppendPhonemes(Translator *tr, char *string, int size, const char *ph)
}
}
}
-
+
if(string != NULL)
strcat(string,ph);
} /* end of AppendPhonemes */
-static void MatchRule(Translator *tr, char *word[], const char *group, char *rule, MatchRecord *match_out, int word_flags, int dict_flags)
-{//=======================================================================================================================================
+static void MatchRule(Translator *tr, char *word[], char *word_start, int group_length, char *rule, MatchRecord *match_out, int word_flags, int dict_flags)
+{//========================================================================================================================================================
/* Checks a specified word against dictionary rules.
Returns with phoneme code string, or NULL if no match found.
@@ -1836,11 +1906,12 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
char *rule_start; /* start of current match template */
char *p;
+ int ix;
int match_type; /* left, right, or consume */
int failed;
+ int unpron_ignore;
int consumed; /* number of letters consumed from input */
- int count; /* count through rules in the group */
int syllable_count;
int vowel;
int letter_group;
@@ -1849,17 +1920,21 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
int lg_pts;
int n_bytes;
int add_points;
+ int command;
+ int check_atstart;
+ unsigned int *flags;
MatchRecord match;
static MatchRecord best;
int total_consumed; /* letters consumed for best match */
- int group_length;
unsigned char condition_num;
char *common_phonemes; /* common to a group of entries */
+ char *group_chars;
+ char word_buf[N_WORD_BYTES];
-
+ group_chars = *word;
if(rule == NULL)
{
@@ -1870,7 +1945,6 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
total_consumed = 0;
- count = 0;
common_phonemes = NULL;
match_type = 0;
@@ -1879,27 +1953,27 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
best.end_type = 0;
best.del_fwd = NULL;
- group_length = strlen(group);
-
/* search through dictionary rules */
while(rule[0] != RULE_GROUP_END)
{
+ unpron_ignore = word_flags & FLAG_UNPRON_TEST;
match_type=0;
consumed = 0;
letter = 0;
distance_right= -6; /* used to reduce points for matches further away the current letter */
distance_left= -2;
- count++;
+ check_atstart = 0;
match.points = 1;
match.end_type = 0;
match.del_fwd = NULL;
-
+
pre_ptr = *word;
post_ptr = *word + group_length;
/* work through next rule until end, or until no-match proved */
rule_start = rule;
+
failed = 0;
while(!failed)
{
@@ -1917,6 +1991,8 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
{
if(rb == RULE_CONDITION)
match.phonemes++; // skip over condition number
+ if(rb == RULE_LINENUM)
+ match.phonemes += 2; // skip over line number
}
}
else
@@ -1926,9 +2002,24 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
rule--; // so we are still pointing at the 0
failed=2; // matched OK
break;
+
+ case RULE_PRE_ATSTART: // pre rule with implied 'start of word'
+ check_atstart = 1;
+ unpron_ignore = 0;
+ match_type = RULE_PRE;
+ break;
+
case RULE_PRE:
match_type = RULE_PRE;
+ if(word_flags & FLAG_UNPRON_TEST)
+ {
+ // checking the start of the word for unpronouncable character sequences, only
+ // consider rules which explicitly match the start of a word
+ // Note: Those rules now use RULE_PRE_ATSTART
+ failed = 1;
+ }
break;
+
case RULE_POST:
match_type = RULE_POST;
break;
@@ -1942,7 +2033,7 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
case RULE_CONDITION:
/* conditional rule, next byte gives condition number */
condition_num = *rule++;
-
+
if(condition_num >= 32)
{
// allow the rule only if the condition number is NOT set
@@ -1977,7 +2068,8 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
if((letter == rb) || ((letter==(unsigned char)REPLACED_E) && (rb=='e')))
{
- add_points = 21;
+ if((letter & 0xc0) != 0x80)
+ add_points = 21; // don't add point for non-initial UTF-8 bytes
consumed++;
}
else
@@ -2022,13 +2114,15 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
break;
case RULE_NOTVOWEL:
- if(!IsLetter(tr, letter_w,0))
+ if(IsLetter(tr, letter_w, 0) || ((letter_w == ' ') && (word_flags & FLAG_SUFFIX_VOWEL)))
+ {
+ failed = 1;
+ }
+ else
{
add_points = (20-distance_right);
post_ptr += letter_xbytes;
}
- else
- failed = 1;
break;
case RULE_DIGIT:
@@ -2037,8 +2131,7 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
add_points = (20-distance_right);
post_ptr += letter_xbytes;
}
- else
- if(tr->langopts.tone_numbers)
+ else if(tr->langopts.tone_numbers)
{
// also match if there is no digit
add_points = (20-distance_right);
@@ -2047,9 +2140,9 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
else
failed = 1;
break;
-
+
case RULE_NONALPHA:
- if(!iswalpha(letter_w))
+ if(!iswalpha2(letter_w))
{
add_points = (21-distance_right);
post_ptr += letter_xbytes;
@@ -2065,11 +2158,45 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
failed = 1;
break;
- case RULE_ALT1:
- if(dict_flags & FLAG_ALT_TRANS)
- add_points = 1;
- else
- failed = 1;
+ case RULE_DOLLAR:
+ command = *rule++;
+ if(command == DOLLAR_UNPR)
+ {
+ match.end_type = SUFX_UNPRON; // $unpron
+ }
+ else if(command == DOLLAR_NOPREFIX) // $noprefix
+ {
+ if(word_flags & FLAG_PREFIX_REMOVED)
+ failed = 1; // a prefix has been removed
+ else
+ add_points = 1;
+ }
+ else if((command & 0xf0) == 0x10)
+ {
+ // $w_alt
+ if(dict_flags & (1 << (BITNUM_FLAG_ALT + (command & 0xf))))
+ add_points = 23;
+ else
+ failed = 1;
+ }
+ else if(((command & 0xf0) == 0x20) || (command == DOLLAR_LIST))
+ {
+ // $list or $p_alt
+ // make a copy of the word up to the post-match characters
+ ix = *word - word_start + consumed + group_length + 1;
+ memcpy(word_buf, word_start-1, ix);
+ word_buf[ix] = ' ';
+ word_buf[ix+1] = 0;
+ LookupFlags(tr, &word_buf[1], &flags);
+
+ if((command == DOLLAR_LIST) && (flags[0] & FLAG_FOUND) && !(flags[1] & FLAG_ONLY))
+ add_points = 23;
+ else
+ if(flags[0] & (1 << (BITNUM_FLAG_ALT + (command & 0xf))))
+ add_points = 23;
+ else
+ failed = 1;
+ }
break;
case '-':
@@ -2082,58 +2209,80 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
break;
case RULE_SYLLABLE:
- {
- /* more than specified number of vowel letters to the right */
- char *p = post_ptr + letter_xbytes;
+ {
+ /* more than specified number of vowel letters to the right */
+ char *p = post_ptr + letter_xbytes;
+ int vowel_count=0;
- syllable_count = 1;
- while(*rule == RULE_SYLLABLE)
- {
- rule++;
- syllable_count+=1; /* number of syllables to match */
- }
- vowel = 0;
- while(letter_w != RULE_SPACE)
+ syllable_count = 1;
+ while(*rule == RULE_SYLLABLE)
+ {
+ rule++;
+ syllable_count+=1; /* number of syllables to match */
+ }
+ vowel = 0;
+ while(letter_w != RULE_SPACE)
+ {
+ if((vowel==0) && IsLetter(tr, letter_w,LETTERGP_VOWEL2))
{
- if((vowel==0) && IsLetter(tr, letter_w,LETTERGP_VOWEL2))
- {
- // this is counting vowels which are separated by non-vowels
- syllable_count--;
- }
- vowel = IsLetter(tr, letter_w,LETTERGP_VOWEL2);
- p += utf8_in(&letter_w,p);
+ // this is counting vowels which are separated by non-vowel letters
+ vowel_count++;
}
- if(syllable_count <= 0)
- add_points = (19-distance_right);
- else
- failed = 1;
+ vowel = IsLetter(tr, letter_w,LETTERGP_VOWEL2);
+ p += utf8_in(&letter_w,p);
}
- break;
+ if(syllable_count <= vowel_count)
+ add_points = (18+syllable_count-distance_right);
+ else
+ failed = 1;
+ }
+ break;
case RULE_NOVOWELS:
+ {
+ char *p = post_ptr + letter_xbytes;
+ while(letter_w != RULE_SPACE)
{
- char *p = post_ptr + letter_xbytes;
- while(letter_w != RULE_SPACE)
+ if(IsLetter(tr, letter_w,LETTERGP_VOWEL2))
{
- if(IsLetter(tr, letter_w,LETTERGP_VOWEL2))
- {
- failed = 1;
- break;
- }
- p += utf8_in(&letter_w,p);
+ failed = 1;
+ break;
}
- if(!failed)
- add_points = (19-distance_right);
+ p += utf8_in(&letter_w,p);
}
- break;
+ if(!failed)
+ add_points = (19-distance_right);
+ }
+ break;
+
+ case RULE_SKIPCHARS:
+ {
+ // Used for lang=Tamil, used to match on the next word after an unknown word ending
+ // only look until the end of the word (including the end-of-word marker)
+ // Jx means 'skip characters until x', where 'x' may be '_' for 'end of word'
+ char *p = post_ptr + letter_xbytes;
+ char *p2 = p;
+ int rule_w; // skip characters until this
+ utf8_in(&rule_w,rule);
+ while((letter_w != rule_w) && (letter_w != RULE_SPACE))
+ {
+ p2 = p;
+ p += utf8_in(&letter_w,p);
+ }
+ if(letter_w == rule_w)
+ {
+ post_ptr = p2;
+ }
+ }
+ break;
case RULE_INC_SCORE:
add_points = 20; // force an increase in points
break;
case RULE_DEL_FWD:
- // find the next 'e' in the word and replace by ''
- for(p = *word + group_length; *p != ' '; p++)
+ // find the next 'e' in the word and replace by 'E'
+ for(p = *word + group_length; p < post_ptr; p++)
{
if(*p == 'e')
{
@@ -2144,10 +2293,20 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
break;
case RULE_ENDING:
+ {
+ int end_type;
// next 3 bytes are a (non-zero) ending type. 2 bytes of flags + suffix length
- match.end_type = (rule[0] << 16) + ((rule[1] & 0x7f) << 8) + (rule[2] & 0x7f);
- rule += 3;
- break;
+ end_type = (rule[0] << 16) + ((rule[1] & 0x7f) << 8) + (rule[2] & 0x7f);
+
+ if((tr->word_vowel_count == 0) && !(end_type & SUFX_P) && (tr->langopts.param[LOPT_SUFFIX] & 1))
+ failed = 1; // don't match a suffix rule if there are no previous syllables (needed for lang=tr).
+ else
+ {
+ match.end_type = end_type;
+ rule += 3;
+ }
+ }
+ break;
case RULE_NO_SUFFIX:
if(word_flags & FLAG_SUFFIX_REMOVED)
@@ -2159,10 +2318,11 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
default:
if(letter == rb)
{
- if(letter == RULE_SPACE)
- add_points = (21-distance_right);
- else
+ if((letter & 0xc0) != 0x80)
+ {
+ // not for non-initial UTF-8 bytes
add_points = (21-distance_right);
+ }
}
else
failed = 1;
@@ -2237,7 +2397,7 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
break;
case RULE_NONALPHA:
- if(!iswalpha(letter_w))
+ if(!iswalpha2(letter_w))
{
add_points = (21-distance_right);
pre_ptr -= letter_xbytes;
@@ -2246,6 +2406,28 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
failed = 1;
break;
+ case RULE_DOLLAR:
+ command = *rule++;
+ if((command==DOLLAR_LIST) || ((command & 0xf0) == 0x20))
+ {
+ // $list or $p_alt
+ // make a copy of the word up to the current character
+ ix = *word - word_start + 1;
+ memcpy(word_buf, word_start-1, ix);
+ word_buf[ix] = ' ';
+ word_buf[ix+1] = 0;
+ LookupFlags(tr, &word_buf[1], &flags);
+
+ if((command==DOLLAR_LIST) && (flags[0] & FLAG_FOUND) && !(flags[1] & FLAG_ONLY))
+ add_points = 23;
+ else
+ if(flags[0] & (1 << (BITNUM_FLAG_ALT + (command & 0xf))))
+ add_points = 23;
+ else
+ failed = 1;
+ }
+ break;
+
case RULE_SYLLABLE:
/* more than specified number of vowels to the left */
syllable_count = 1;
@@ -2255,7 +2437,7 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
syllable_count++; /* number of syllables to match */
}
if(syllable_count <= tr->word_vowel_count)
- add_points = (19-distance_left);
+ add_points = (18+syllable_count-distance_left);
else
failed = 1;
break;
@@ -2268,21 +2450,21 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
break;
case RULE_NOVOWELS:
+ {
+ char *p = pre_ptr - letter_xbytes - 1;
+ while(letter_w != RULE_SPACE)
{
- char *p = pre_ptr - letter_xbytes - 1;
- while(letter_w != RULE_SPACE)
+ if(IsLetter(tr, letter_w,LETTERGP_VOWEL2))
{
- if(IsLetter(tr, letter_w,LETTERGP_VOWEL2))
- {
- failed = 1;
- break;
- }
- p -= utf8_in2(&letter_w,p,1);
+ failed = 1;
+ break;
}
- if(!failed)
- add_points = 3;
+ p -= utf8_in2(&letter_w,p,1);
}
- break;
+ if(!failed)
+ add_points = 3;
+ }
+ break;
case RULE_IFVERB:
if(tr->expect_verb)
@@ -2327,7 +2509,13 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
if(letter == RULE_SPACE)
add_points = 4;
else
- add_points = (21-distance_left);
+ {
+ if((letter & 0xc0) != 0x80)
+ {
+ // not for non-initial UTF-8 bytes
+ add_points = (21-distance_left);
+ }
+ }
}
else
failed = 1;
@@ -2340,44 +2528,45 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
match.points += add_points;
}
- if(failed == 2)
+ if((failed == 2) && (unpron_ignore == 0))
{
- /* matched OK, is this better than the last best match ? */
- if(match.points >= best.points)
+ // do we also need to check for 'start of word' ?
+ if((check_atstart==0) || (pre_ptr[-1] == ' '))
{
- memcpy(&best,&match,sizeof(match));
- total_consumed = consumed;
- }
+ if(check_atstart)
+ match.points += 4;
-#ifdef LOG_TRANSLATE
- if((option_phonemes == 2) && (match.points > 0) && ((word_flags & FLAG_NO_TRACE) == 0))
- {
- // show each rule that matches, and it's points score
- int pts;
- char decoded_phonemes[80];
+ /* matched OK, is this better than the last best match ? */
+ if(match.points >= best.points)
+ {
+ memcpy(&best,&match,sizeof(match));
+ total_consumed = consumed;
+ }
- // note: 'count' contains the rule number, if we want to include it
- pts = match.points;
- if(group_length > 1)
- pts += 35; // to account for an extra letter matching
- DecodePhonemes(match.phonemes,decoded_phonemes);
- fprintf(f_trans,"%3d\t%s [%s]\n",pts,DecodeRule(group,rule_start),decoded_phonemes);
+ if((option_phonemes == 2) && (match.points > 0) && ((word_flags & FLAG_NO_TRACE) == 0))
+ {
+ // show each rule that matches, and it's points score
+ int pts;
+ char decoded_phonemes[80];
+
+ pts = match.points;
+ if(group_length > 1)
+ pts += 35; // to account for an extra letter matching
+ DecodePhonemes(match.phonemes,decoded_phonemes);
+ fprintf(f_trans,"%3d\t%s [%s]\n",pts,DecodeRule(group_chars, group_length, rule_start, word_flags), decoded_phonemes);
+ }
}
-#endif
-
}
/* skip phoneme string to reach start of next template */
while(*rule++ != 0);
}
-#ifdef LOG_TRANSLATE
if((option_phonemes == 2) && ((word_flags & FLAG_NO_TRACE)==0))
{
if(group_length <= 1)
fprintf(f_trans,"\n");
}
-#endif
/* advance input data pointer */
total_consumed += group_length;
@@ -2396,13 +2585,12 @@ static void MatchRule(Translator *tr, char *word[], const char *group, char *rul
int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, char *end_phonemes, int word_flags, unsigned int *dict_flags)
{//=====================================================================================================================================
-/* Translate a word bounded by space characters
- Append the result to 'phonemes' and any standard prefix/suffix in 'end_phonemes' */
+ /* Translate a word bounded by space characters
+ Append the result to 'phonemes' and any standard prefix/suffix in 'end_phonemes' */
unsigned char c, c2;
unsigned int c12;
int wc=0;
- int wc_prev;
int wc_bytes;
char *p2; /* copy of p for use in double letter chain match */
int found;
@@ -2414,6 +2602,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
int ix;
unsigned int digit_count=0;
char *p;
+ ALPHABET *alphabet;
int dict_flags0=0;
MatchRecord match1;
MatchRecord match2;
@@ -2421,8 +2610,6 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
char word_copy[N_WORD_BYTES];
static const char str_pause[2] = {phonPAUSE_NOLINK,0};
- char group_name[4];
-
if(tr->data_dictrules == NULL)
return(0);
@@ -2439,31 +2626,31 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
word_copy[ix] = 0;
-#ifdef LOG_TRANSLATE
if((option_phonemes == 2) && ((word_flags & FLAG_NO_TRACE)==0))
{
char wordbuf[120];
- int ix;
+ unsigned int ix;
- for(ix=0; ((c = p_start[ix]) != ' ') && (c != 0); ix++)
+ for(ix=0; ((c = p_start[ix]) != ' ') && (c != 0) && (ix < (sizeof(wordbuf)-1)); ix++)
{
wordbuf[ix] = c;
}
wordbuf[ix] = 0;
- fprintf(f_trans,"Translate '%s'\n",wordbuf);
+ if(word_flags & FLAG_UNPRON_TEST)
+ fprintf(f_trans,"Unpronouncable? '%s'\n",wordbuf);
+ else
+ fprintf(f_trans,"Translate '%s'\n",wordbuf);
}
-#endif
p = p_start;
tr->word_vowel_count = 0;
tr->word_stressed_count = 0;
-
+
if(end_phonemes != NULL)
end_phonemes[0] = 0;
-
+
while(((c = *p) != ' ') && (c != 0))
{
- wc_prev = wc;
wc_bytes = utf8_in(&wc,p);
if(IsAlpha(wc))
any_alpha++;
@@ -2472,14 +2659,14 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
if(IsDigit(wc) && ((tr->langopts.tone_numbers == 0) || !any_alpha))
{
// lookup the number in *_list not *_rules
- char string[8];
- char buf[40];
+ char string[8];
+ char buf[40];
string[0] = '_';
memcpy(&string[1],p,wc_bytes);
string[1+wc_bytes] = 0;
Lookup(tr, string,buf);
if(++digit_count >= 2)
- {
+ {
strcat(buf,str_pause);
digit_count=0;
}
@@ -2491,13 +2678,22 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
{
digit_count = 0;
found = 0;
-
- if(n > 0)
+
+ if(((ix = wc - tr->letter_bits_offset) >= 0) && (ix < 128))
+ {
+ if(tr->groups3[ix] != NULL)
+ {
+ MatchRule(tr, &p, p_start, wc_bytes, tr->groups3[ix], &match1, word_flags, dict_flags0);
+ found = 1;
+ }
+ }
+
+ if(!found && (n > 0))
{
/* there are some 2 byte chains for this initial letter */
c2 = p[1];
c12 = c + (c2 << 8); /* 2 characters */
-
+
g1 = tr->groups2_start[c];
for(g=g1; g < (g1+n); g++)
{
@@ -2505,17 +2701,13 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
{
found = 1;
- group_name[0] = c;
- group_name[1] = c2;
- group_name[2] = 0;
p2 = p;
- MatchRule(tr, &p2, group_name, tr->groups2[g], &match2, word_flags, dict_flags0);
+ MatchRule(tr, &p2, p_start, 2, tr->groups2[g], &match2, word_flags, dict_flags0);
if(match2.points > 0)
match2.points += 35; /* to acount for 2 letters matching */
/* now see whether single letter chain gives a better match ? */
- group_name[1] = 0;
- MatchRule(tr, &p, group_name, tr->groups1[c], &match1, word_flags, dict_flags0);
+ MatchRule(tr, &p, p_start, 1, tr->groups1[c], &match1, word_flags, dict_flags0);
if(match2.points >= match1.points)
{
@@ -2526,19 +2718,16 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
}
}
}
-
+
if(!found)
{
/* alphabetic, single letter chain */
- group_name[0] = c;
- group_name[1] = 0;
-
if(tr->groups1[c] != NULL)
- MatchRule(tr, &p, group_name, tr->groups1[c], &match1, word_flags, dict_flags0);
+ MatchRule(tr, &p, p_start, 1, tr->groups1[c], &match1, word_flags, dict_flags0);
else
{
// no group for this letter, use default group
- MatchRule(tr, &p, "", tr->groups1[0], &match1, word_flags, dict_flags0);
+ MatchRule(tr, &p, p_start, 0, tr->groups1[0], &match1, word_flags, dict_flags0);
if((match1.points == 0) && ((option_sayas & 0x10) == 0))
{
@@ -2547,7 +2736,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
if(tr->letter_bits_offset > 0)
{
// not a Latin alphabet, switch to the default Latin alphabet language
- if((letter <= 0x241) && iswalpha(letter))
+ if((letter <= 0x241) && iswalpha2(letter))
{
sprintf(phonemes,"%c%s",phonSWITCH,tr->langopts.ascii_language);
return(0);
@@ -2564,14 +2753,19 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
#endif
// is it a bracket ?
+ if(letter == 0xe000+'(')
+ {
+ if(pre_pause < tr->langopts.param2[LOPT_BRACKET_PAUSE])
+ pre_pause = tr->langopts.param2[LOPT_BRACKET_PAUSE]; // a bracket, aleady spoken by AnnouncePunctuation()
+ }
if(IsBracket(letter))
{
- if(pre_pause < 4)
- pre_pause = 4;
+ if(pre_pause < tr->langopts.param[LOPT_BRACKET_PAUSE])
+ pre_pause = tr->langopts.param[LOPT_BRACKET_PAUSE];
}
// no match, try removing the accent and re-translating the word
- if((letter >= 0xc0) && (letter <= 0x241) && ((ix = remove_accent[letter-0xc0]) != 0))
+ if((letter >= 0xc0) && (letter < N_REMOVE_ACCENT) && ((ix = remove_accent[letter-0xc0]) != 0))
{
// within range of the remove_accent table
if((p[-2] != ' ') || (p[n] != ' '))
@@ -2581,14 +2775,14 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
p[-1] = ix;
while((p[0] = p[n]) != ' ') p++;
while(n-- > 0) *p++ = ' '; // replacement character must be no longer than original
-
+
if(tr->langopts.param[LOPT_DIERESES] && (lookupwchar(diereses_list,letter) > 0))
{
// vowel with dieresis, replace and continue from this point
p = p2;
continue;
}
-
+
phonemes[0] = 0; // delete any phonemes which have been produced so far
p = p_start;
tr->word_vowel_count = 0;
@@ -2596,15 +2790,20 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
continue; // start again at the beginning of the word
}
}
- else
- if((letter >= 0x3200) && (letter < 0xa700) && (end_phonemes != NULL))
+
+ if(((alphabet = AlphabetFromChar(letter)) != NULL) && (alphabet->offset != tr->letter_bits_offset))
{
- // ideograms
- // outside the range of the accent table, speak the unknown symbol sound
- Lookup(tr, "_??", ph_buf);
- match1.phonemes = ph_buf;
- match1.points = 1;
- p += (wc_bytes-1);
+ if(tr->langopts.alt_alphabet == alphabet->offset)
+ {
+ sprintf(phonemes,"%c%s",phonSWITCH, WordToString2(tr->langopts.alt_alphabet_lang));
+ return(0);
+ }
+ if(alphabet->flags & AL_WORDS)
+ {
+ // switch to the nominated language for this alphabet
+ sprintf(phonemes,"%c%s",phonSWITCH, WordToString2(alphabet->language));
+ return(0);
+ }
}
}
}
@@ -2615,8 +2814,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
{
// combining accent inside a word, ignore
}
- else
- if(IsAlpha(wc))
+ else if(IsAlpha(wc))
{
if((any_alpha > 1) || (p[wc_bytes-1] > ' '))
{
@@ -2629,7 +2827,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
}
else
{
- LookupLetter(tr, wc, -1, ph_buf);
+ LookupLetter(tr, wc, -1, ph_buf, 0);
if(ph_buf[0])
{
match1.phonemes = ph_buf;
@@ -2647,16 +2845,27 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
if(match1.phonemes == NULL)
match1.phonemes = "";
-
+
if(match1.points > 0)
{
+ if(word_flags & FLAG_UNPRON_TEST)
+ return(match1.end_type | 1);
+
+#ifdef deleted
+// ?? allow $unpr while translating rules, not just on initial FLAG_UNPRON_TEST
+ if((match1.end_type & SUFX_UNPRON) && !(word_flags & FLAG_SUFFIX_REMOVED))
+ return(match1.end_type);
+#endif
+
if((match1.phonemes[0] == phonSWITCH) && ((word_flags & FLAG_DONT_SWITCH_TRANSLATOR)==0))
{
// an instruction to switch language, return immediately so we can re-translate
strcpy(phonemes,match1.phonemes);
return(0);
}
-
+
+ match1.end_type &= ~SUFX_UNPRON;
+
if((match1.end_type != 0) && (end_phonemes != NULL))
{
/* a standard ending has been found, re-translate the word without it */
@@ -2682,8 +2891,6 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
}
}
- // any language specific changes ?
- ApplySpecialAttribute(tr,phonemes,dict_flags0);
memcpy(p_start,word_copy,strlen(word_copy));
return(0);
@@ -2692,16 +2899,15 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags)
{//========================================================================
- // apply after the translation is complete
+// apply after the translation is complete
int ix;
int len;
char *p;
len = strlen(phonemes);
- switch(tr->translator_name)
+ if(tr->langopts.param[LOPT_ALT] & 2)
{
- case L('i','t'):
for(ix=0; ix<(len-1); ix++)
{
if(phonemes[ix] == phonSTRESS_P)
@@ -2724,62 +2930,10 @@ void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags)
break;
}
}
- break;
}
} // end of ApplySpecialAttribute2
-void ApplySpecialAttribute(Translator *tr, char *phonemes, int dict_flags)
-{//=======================================================================
-// Amend the translated phonemes according to an attribute which is specific for the language.
- int len;
- int ix;
- char *p_end;
- int phoneme_1;
-
- if((dict_flags & (FLAG_ALT_TRANS | FLAG_ALT2_TRANS)) == 0)
- return;
-
- len = strlen(phonemes);
- p_end = &phonemes[len-1];
-
- switch(tr->translator_name)
- {
- case L('d','e'):
- if(p_end[0] == PhonemeCode2('i',':'))
- {
- // words ends in ['i:], change to [=I@]
- p_end[-1] = phonSTRESS_PREV;
- p_end[0] = PhonemeCode('I');
- p_end[1] = phonSCHWA;
- p_end[2] = 0;
- }
- break;
-
- case L('p','t'):
- phoneme_1 = PhonemeCode('o');
- for(ix=0; ix<(len-1); ix++)
- {
- if(phonemes[ix] == phoneme_1)
- {
- phonemes[ix] = PhonemeCode('O');
- break;
- }
- }
- break;
-
- case L('r','o'):
- if(p_end[0] == PhonemeCode('j'))
- {
- // word end in [j], change to ['i]
- p_end[0] = phonSTRESS_P;
- p_end[1] = PhonemeCode('i');
- p_end[2] = 0;
- }
- break;
- }
-} // end of ApplySpecialAttribute
-
//=============================================================================================
@@ -2788,70 +2942,69 @@ void ApplySpecialAttribute(Translator *tr, char *phonemes, int dict_flags)
// special properties, such as pronounce as unstressed
//=============================================================================================
-// common letter pairs, encode these as a single byte
-static const short pairs_ru[] = {
-0x010c, // ла 21052 0x23
-0x010e, // на 18400
-0x0113, // та 14254
-0x0301, // ав 31083
-0x030f, // ов 13420
-0x060e, // не 21798
-0x0611, // ре 19458
-0x0903, // ви 16226
-0x0b01, // ак 14456
-0x0b0f, // ок 17836
-0x0c01, // ал 13324
-0x0c09, // ил 16877
-0x0e01, // ан 15359
-0x0e06, // ен 13543 0x30
-0x0e09, // ин 17168
-0x0e0e, // нн 15973
-0x0e0f, // он 22373
-0x0e1c, // ын 15052
-0x0f03, // во 24947
-0x0f11, // ро 13552
-0x0f12, // со 16368
-0x100f, // оп 19054
-0x1011, // рп 17067
-0x1101, // ар 23967
-0x1106, // ер 18795
-0x1109, // ир 13797
-0x110f, // ор 21737
-0x1213, // тс 25076
-0x1220, // яс 14310
-0x7fff};
-//0x040f ог 12976
-//0x1306 ет 12826
-//0x0f0d мо 12688
-
-
-int TransposeAlphabet(char *text, int offset, int min, int max)
-{//============================================================
+
+int TransposeAlphabet(Translator *tr, char *text)
+{//==============================================
// transpose cyrillic alphabet (for example) into ascii (single byte) character codes
// return: number of bytes, bit 6: 1=used compression
int c;
int c2;
int ix;
+ int offset;
+ int min;
+ int max;
+ const char *map;
char *p = text;
- char *p2 = text;
+ char *p2;
int all_alpha=1;
int bits;
int acc;
+ int pairs_start;
+ const short *pairs_list;
+ int bufix;
+ char buf[N_WORD_BYTES+1];
+
+
+ offset = tr->transpose_min - 1;
+ min = tr->transpose_min;
+ max = tr->transpose_max;
+ map = tr->transpose_map;
+ pairs_start = max - min + 2;
+
+ bufix = 0;
do {
p += utf8_in(&c,p);
- if((c >= min) && (c <= max))
- {
- *p2++ = c - offset;
- }
- else
if(c != 0)
{
- p2 += utf8_out(c,p2);
- all_alpha=0;
+ if((c >= min) && (c <= max))
+ {
+ if(map == NULL)
+ {
+ buf[bufix++] = c - offset;
+ }
+ else
+ {
+ // get the code from the transpose map
+ if(map[c - min] > 0)
+ {
+ buf[bufix++] = map[c - min];
+ }
+ else
+ {
+ all_alpha=0;
+ break;
+ }
+ }
+ }
+ else
+ {
+ all_alpha=0;
+ break;
+ }
}
- } while (c != 0);
- *p2 = 0;
+ } while ((c != 0) && (bufix < N_WORD_BYTES));
+ buf[bufix] = 0;
if(all_alpha)
{
@@ -2859,19 +3012,22 @@ int TransposeAlphabet(char *text, int offset, int min, int max)
acc=0;
bits=0;
- p = text;
- p2 = text;
+ p = buf;
+ p2 = buf;
while((c = *p++) != 0)
{
- c2 = c + (*p << 8);
- for(ix=0; c2 >= pairs_ru[ix]; ix++)
+ if((pairs_list = tr->frequent_pairs) != NULL)
{
- if(c2 == pairs_ru[ix])
+ c2 = c + (*p << 8);
+ for(ix=0; c2 >= pairs_list[ix]; ix++)
{
- // found an encoding for a 2-character pair
- c = ix + 0x23; // 2-character codes start at 0x23
- p++;
- break;
+ if(c2 == pairs_list[ix])
+ {
+ // found an encoding for a 2-character pair
+ c = ix + pairs_start; // 2-character codes start after the single letter codes
+ p++;
+ break;
+ }
}
}
acc = (acc << 6) + (c & 0x3f);
@@ -2880,7 +3036,7 @@ int TransposeAlphabet(char *text, int offset, int min, int max)
if(bits >= 8)
{
bits -= 8;
- *p2++ = (acc >> bits);
+ *p2++ = (acc >> bits);
}
}
if(bits > 0)
@@ -2888,16 +3044,21 @@ int TransposeAlphabet(char *text, int offset, int min, int max)
*p2++ = (acc << (8-bits));
}
*p2 = 0;
- return((p2 - text) | 0x40); // bit 6 indicates compressed characters
+ ix = p2 - buf;
+ memcpy(text, buf, ix);
+ return(ix | 0x40); // bit 6 indicates compressed characters
+ }
+ else
+ {
+ return(strlen(text));
}
- return(p2 - text);
} // end of TransposeAlphabet
static const char *LookupDict2(Translator *tr, const char *word, const char *word2,
- char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab)
+ char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab)
//=====================================================================================
/* Find an entry in the word_dict file for a specified word.
Returns NULL if no match, else returns 'word_end'
@@ -2923,21 +3084,25 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
int no_phonemes;
int skipwords;
int ix;
+ int c;
const char *word_end;
const char *word1;
int wflags = 0;
- char word_buf[N_WORD_BYTES];
+ int lookup_symbol;
+ char word_buf[N_WORD_BYTES+1];
+ char dict_flags_buf[80];
if(wtab != NULL)
{
wflags = wtab->flags;
}
+ lookup_symbol = flags[1] & FLAG_LOOKUP_SYMBOL;
word1 = word;
- if(tr->transpose_offset > 0)
+ if(tr->transpose_min > 0)
{
- strcpy(word_buf,word);
- wlen = TransposeAlphabet(word_buf, tr->transpose_offset, tr->transpose_min, tr->transpose_max);
+ strncpy0(word_buf,word, N_WORD_BYTES);
+ wlen = TransposeAlphabet(tr, word_buf); // bit 6 indicates compressed characters
word = word_buf;
}
else
@@ -3011,8 +3176,7 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
condition_failed = 1;
}
}
- else
- if(flag > 80)
+ else if(flag > 80)
{
// flags 81 to 90 match more than one word
// This comes after the other flags
@@ -3020,11 +3184,16 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
skipwords = flag - 80;
// don't use the contraction if any of the words are emphasized
- for(ix=0; ix <= skipwords; ix++)
+ // or has an embedded command, such as MARK
+ if(wtab != NULL)
{
- if(wflags & FLAG_EMPHASIZED2)
+ for(ix=0; ix <= skipwords; ix++)
{
- condition_failed = 1;
+ if(wtab[ix].flags & FLAG_EMPHASIZED2)
+// if(((wflags2 = wtab[ix].flags) & FLAG_EMPHASIZED2) || ((ix > 0) && (wflags2 & FLAG_EMBEDDED)))
+ {
+ condition_failed = 1;
+ }
}
}
@@ -3042,16 +3211,14 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
p = next;
word_end = word2 + n_chars;
}
- else
- if(flag > 64)
+ else if(flag > 64)
{
// stressed syllable information, put in bits 0-3
dictionary_flags = (dictionary_flags & ~0xf) | (flag & 0xf);
if((flag & 0xc) == 0xc)
dictionary_flags |= FLAG_STRESS_END;
}
- else
- if(flag >= 32)
+ else if(flag >= 32)
{
dictionary_flags2 |= (1L << (flag-32));
}
@@ -3070,20 +3237,20 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
if((end_flags & FLAG_SUFX)==0)
{
// no suffix has been removed
- if(dictionary_flags & FLAG_STEM)
+ if(dictionary_flags2 & FLAG_STEM)
continue; // this word must have a suffix
}
- if((end_flags & SUFX_P) && (dictionary_flags & (FLAG_ONLY | FLAG_ONLY_S)))
+ if((end_flags & SUFX_P) && (dictionary_flags2 & (FLAG_ONLY | FLAG_ONLY_S)))
continue; // $only or $onlys, don't match if a prefix has been removed
if(end_flags & FLAG_SUFX)
{
// a suffix was removed from the word
- if(dictionary_flags & FLAG_ONLY)
+ if(dictionary_flags2 & FLAG_ONLY)
continue; // no match if any suffix
- if((dictionary_flags & FLAG_ONLY_S) && ((end_flags & FLAG_SUFX_S)==0))
+ if((dictionary_flags2 & FLAG_ONLY_S) && ((end_flags & FLAG_SUFX_S)==0))
{
// only a 's' suffix allowed, but the suffix wasn't 's'
continue;
@@ -3111,10 +3278,27 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
continue;
}
}
+ if(dictionary_flags & FLAG_NEEDS_DOT)
+ {
+ if(!(wflags & FLAG_HAS_DOT))
+ continue;
+ }
+
+ if((dictionary_flags2 & FLAG_ATEND) && (word_end < translator->clause_end) && (lookup_symbol==0))
+ {
+ // only use this pronunciation if it's the last word of the clause, or called from Lookup()
+ continue;
+ }
+
+ if((dictionary_flags2 & FLAG_ATSTART) && !(wtab->flags & FLAG_FIRST_WORD))
+ {
+ // only use this pronunciation if it's the first word of a clause
+ continue;
+ }
- if((dictionary_flags & FLAG_ATEND) && (word_end < tr->clause_end))
+ if((dictionary_flags2 & FLAG_SENTENCE) && !(translator->clause_terminator & CLAUSE_BIT_SENTENCE))
{
- // only use this pronunciation if it's the last word of the clause
+ // only if this clause is a sentence , i.e. terminator is {. ? !} not {, : :}
continue;
}
@@ -3125,6 +3309,11 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
if(tr->expect_verb || (tr->expect_verb_s && (end_flags & FLAG_SUFX_S)))
{
// OK, we are expecting a verb
+ if((tr->translator_name == L('e','n')) && (tr->prev_dict_flags[0] & FLAG_ALT6_TRANS) && (end_flags & FLAG_SUFX_S))
+ {
+ // lang=en, don't use verb form after 'to' if the word has 's' suffix
+ continue;
+ }
}
else
{
@@ -3144,13 +3333,24 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
}
if(dictionary_flags2 & FLAG_NOUN)
{
- if(!tr->expect_noun)
+ if((!tr->expect_noun) || (end_flags & SUFX_V))
{
/* don't use the 'noun' pronunciation unless we are
expecting a noun */
continue;
}
}
+ if(dictionary_flags2 & FLAG_NATIVE)
+ {
+ if(tr != translator)
+ continue; // don't use if we've switched translators
+ }
+ if(dictionary_flags & FLAG_ALT2_TRANS)
+ {
+ // language specific
+ if((tr->translator_name == L('h','u')) && !(tr->prev_dict_flags[0] & FLAG_ALT_TRANS))
+ continue;
+ }
if(flags != NULL)
{
@@ -3162,23 +3362,21 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
{
if(option_phonemes == 2)
{
- fprintf(f_trans,"Flags: %s %s\n",word1,print_dictionary_flags(flags));
+ print_dictionary_flags(flags, dict_flags_buf, sizeof(dict_flags_buf));
+ fprintf(f_trans,"Flags: %s %s\n", word1, dict_flags_buf);
}
return(0); // no phoneme translation found here, only flags. So use rules
}
if(flags != NULL)
flags[0] |= FLAG_FOUND; // this flag indicates word was found in dictionary
-
+
if(option_phonemes == 2)
{
- unsigned int flags1 = 0;
char ph_decoded[N_WORD_PHONEMES];
int textmode;
DecodePhonemes(phonetic,ph_decoded);
- if(flags != NULL)
- flags1 = flags[0];
if((dictionary_flags & FLAG_TEXTMODE) == 0)
textmode = 0;
@@ -3188,9 +3386,28 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
if(textmode == translator->langopts.textmode)
{
// only show this line if the word translates to phonemes, not replacement text
- fprintf(f_trans,"Found: %s [%s] %s\n",word1,ph_decoded,print_dictionary_flags(flags));
+ if((dictionary_flags & FLAG_SKIPWORDS) && (wtab != NULL))
+ {
+ // matched more than one word
+ // (check for wtab prevents showing RULE_SPELLING byte when speaking individual letters)
+ memcpy(word_buf,word2,word_end-word2);
+ word_buf[word_end-word2-1] = 0;
+ fprintf(f_trans,"Found: '%s %s\n",word1,word_buf);
+ }
+ else
+ {
+ fprintf(f_trans,"Found: '%s",word1);
+ }
+ print_dictionary_flags(flags, dict_flags_buf, sizeof(dict_flags_buf));
+ fprintf(f_trans,"' [%s] %s\n", ph_decoded,dict_flags_buf);
}
}
+
+ ix = utf8_in(&c, word);
+ if((word[ix] == 0) && !IsAlpha(c))
+ {
+ flags[0] |= FLAG_MAX3;
+ }
return(word_end);
}
@@ -3249,16 +3466,21 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
}
}
- for(length=0; length<N_WORD_BYTES; length++)
+ for(length=0; length<(N_WORD_BYTES-1); length++)
{
if(((c = *word1++)==0) || (c == ' '))
break;
+
+ if((c=='.') && (length > 0) && (IsDigit09(word[length-1])))
+ break; // needed for lang=hu, eg. "december 2.-ig"
+
word[length] = c;
}
word[length] = 0;
found = LookupDict2(tr, word, word1, ph_out, flags, end_flags, wtab);
+
if(flags[0] & FLAG_MAX3)
{
if(strcmp(ph_out, tr->phonemes_repeat) == 0)
@@ -3294,17 +3516,16 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
if(found == 0)
{
ph_out[0] = 0;
-
+
// try modifications to find a recognised word
-
+
if((end_flags & FLAG_SUFX_E_ADDED) && (word[length-1] == 'e'))
{
// try removing an 'e' which has been added by RemoveEnding
word[length-1] = 0;
found = LookupDict2(tr, word, word1, ph_out, flags, end_flags, wtab);
}
- else
- if((end_flags & SUFX_D) && (word[length-1] == word[length-2]))
+ else if((end_flags & SUFX_D) && (word[length-1] == word[length-2]))
{
// try removing a double letter
word[length-1] = 0;
@@ -3340,6 +3561,10 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
fprintf(f_trans,"Replace: %s %s\n",word,*wordptr);
}
}
+ else
+ {
+// flags[0] &= ~FLAG_SKIPWORDS; // check lang=hu január 21.-ig (error: suffix repeated ??)
+ }
ph_out[0] = 0;
return(0);
@@ -3353,12 +3578,44 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
} // end of LookupDictList
+extern char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes
int Lookup(Translator *tr, const char *word, char *ph_out)
{//===================================================
- unsigned int flags[2]={0,0};
- char* word1 = (char *)word;
- return(LookupDictList(tr, &word1, ph_out, flags, 0, NULL));
+ int found;
+ unsigned int flags[2];
+ int say_as;
+ char *word1 = (char *)word;
+ char text[80];
+
+ flags[0] = 0;
+ flags[1] = FLAG_LOOKUP_SYMBOL;
+ found = LookupDictList(tr, &word1, ph_out, flags, FLAG_ALLOW_TEXTMODE, NULL);
+
+ if(flags[0] & FLAG_TEXTMODE)
+ {
+ say_as = option_sayas;
+ option_sayas = 0; // don't speak replacement word as letter names
+ text[0] = 0;
+ strncpy0(&(text[1]), word1, sizeof(text)-2);
+ found = TranslateWord(tr, &text[1], 0, NULL, NULL);
+ strcpy(ph_out, word_phonemes);
+ option_sayas = say_as;
+ }
+ return(found);
+}
+
+
+int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out)
+{//===========================================================================
+ char buf[100];
+ static unsigned int flags[2];
+ char *word1 = (char *)word;
+
+ flags[0] = flags[1] = 0;
+ LookupDictList(tr, &word1, buf, flags, 0, NULL);
+ *flags_out = flags;
+ return(flags[0]);
}
@@ -3367,27 +3624,30 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
{//========================================================================
/* Removes a standard suffix from a word, once it has been indicated by the dictionary rules.
end_type: bits 0-6 number of letters
- bits 8-14 suffix flags
+ bits 8-14 suffix flags
word_copy: make a copy of the original word
This routine is language specific. In English it deals with reversing y->i and e-dropping
that were done when the suffix was added to the original word.
*/
-
+
int i;
char *word_end;
int len_ending;
int end_flags;
const char *p;
int len;
- static char ending[12];
-
+ char ending[50];
+
// these lists are language specific, but are only relevent if the 'e' suffix flag is used
static const char *add_e_exceptions[] = {
- "ion", NULL };
+ "ion", NULL
+ };
static const char *add_e_additions[] = {
- "c", "rs", "ir", "ur", "ath", "ns", "lu", NULL };
+// "c", "rs", "ir", "ur", "ath", "ns", "lu", NULL };
+ "c", "rs", "ir", "ur", "ath", "ns", "u", NULL
+ };
for(word_end = word; *word_end != ' '; word_end++)
{
@@ -3396,11 +3656,15 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
*word_end = 'e';
}
i = word_end - word;
- memcpy(word_copy,word,i);
- word_copy[i] = 0;
+
+ if(word_copy != NULL)
+ {
+ memcpy(word_copy,word,i);
+ word_copy[i] = 0;
+ }
// look for multibyte characters to increase the number of bytes to remove
- for(len_ending = i = (end_type & 0x3f); i>0 ;i--) // num.of characters of the suffix
+ for(len_ending = i = (end_type & 0x3f); i>0 ; i--) // num.of characters of the suffix
{
word_end--;
while((*word_end & 0xc0) == 0x80)
@@ -3409,9 +3673,9 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
len_ending++;
}
}
-
+
// remove bytes from the end of the word and replace them by spaces
- for(i=0; i<len_ending; i++)
+ for(i=0; (i<len_ending) && (i < (int)sizeof(ending)-1); i++)
{
ending[i] = word_end[i];
word_end[i] = ' ';
@@ -3420,57 +3684,73 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
word_end--; /* now pointing at last character of stem */
end_flags = (end_type & 0xfff0) | FLAG_SUFX;
-
+
/* add an 'e' to the stem if appropriate,
if stem ends in vowel+consonant
or stem ends in 'c' (add 'e' to soften it) */
-
+
if(end_type & SUFX_I)
{
if(word_end[0] == 'i')
word_end[0] = 'y';
}
-
+
if(end_type & SUFX_E)
{
- // add 'e' to end of stem
- if(IsLetter(tr, word_end[-1],LETTERGP_VOWEL2) && IsLetter(tr, word_end[0],1))
+ if(tr->translator_name == L('n','l'))
{
- // vowel(incl.'y') + hard.consonant
-
- for(i=0; (p = add_e_exceptions[i]) != NULL; i++)
+ if(((word_end[0] & 0x80) == 0) && ((word_end[-1] & 0x80) == 0) && IsVowel(tr, word_end[-1]) && IsLetter(tr, word_end[0], LETTERGP_C) && !IsVowel(tr, word_end[-2]))
{
- len = strlen(p);
- if(memcmp(p,&word_end[1-len],len)==0)
- {
- break;
- }
+ //double the vowel before the (ascii) final consonant
+ word_end[1] = word_end[0];
+ word_end[0] = word_end[-1];
+ word_end[2] = ' ';
}
- if(p == NULL)
- end_flags |= FLAG_SUFX_E_ADDED; // no exception found
}
- else
+ else if(tr->translator_name == L('e','n'))
{
- for(i=0; (p = add_e_additions[i]) != NULL; i++)
+ // add 'e' to end of stem
+ if(IsLetter(tr, word_end[-1],LETTERGP_VOWEL2) && IsLetter(tr, word_end[0],1))
{
- len = strlen(p);
- if(memcmp(p,&word_end[1-len],len)==0)
+ // vowel(incl.'y') + hard.consonant
+
+ for(i=0; (p = add_e_exceptions[i]) != NULL; i++)
{
- end_flags |= FLAG_SUFX_E_ADDED;
- break;
+ len = strlen(p);
+ if(memcmp(p,&word_end[1-len],len)==0)
+ {
+ break;
+ }
+ }
+ if(p == NULL)
+ end_flags |= FLAG_SUFX_E_ADDED; // no exception found
+ }
+ else
+ {
+ for(i=0; (p = add_e_additions[i]) != NULL; i++)
+ {
+ len = strlen(p);
+ if(memcmp(p,&word_end[1-len],len)==0)
+ {
+ end_flags |= FLAG_SUFX_E_ADDED;
+ break;
+ }
}
}
}
+ else if(tr->langopts.suffix_add_e != 0)
+ {
+ end_flags |= FLAG_SUFX_E_ADDED;
+ }
if(end_flags & FLAG_SUFX_E_ADDED)
{
- word_end[1] = 'e';
-#ifdef LOG_TRANSLATE
-if(option_phonemes == 2)
-{
- fprintf(f_trans,"add e\n");
-}
-#endif
+ utf8_out(tr->langopts.suffix_add_e, &word_end[1]);
+
+ if(option_phonemes == 2)
+ {
+ fprintf(f_trans,"add e\n");
+ }
}
}
@@ -3481,10 +3761,12 @@ if(option_phonemes == 2)
if((strcmp(ending,"s")==0) || (strcmp(ending,"es")==0))
end_flags |= FLAG_SUFX_S;
- if(strcmp(ending,"'s")==0)
+// if(strcmp(ending,"'s")==0)
+ if(ending[0] == '\'')
end_flags &= ~FLAG_SUFX; // don't consider 's as an added suffix
return(end_flags);
} /* end of RemoveEnding */
+
diff --git a/navit/support/espeak/dictionary.h b/navit/support/espeak/dictionary.h
new file mode 100644
index 000000000..53a5d7c7a
--- /dev/null
+++ b/navit/support/espeak/dictionary.h
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (C) 2005 to 2010 by Jonathan Duddington *
+ * email: jonsd@users.sourceforge.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, see: *
+ * <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+int HashDictionary(const char *string);
diff --git a/navit/support/espeak/espeak-data/af_dict b/navit/support/espeak/espeak-data/af_dict
index 7819c9fe0..d9afc14a0 100644
--- a/navit/support/espeak/espeak-data/af_dict
+++ b/navit/support/espeak/espeak-data/af_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/am_dict b/navit/support/espeak/espeak-data/am_dict
new file mode 100644
index 000000000..0e8a62ce9
--- /dev/null
+++ b/navit/support/espeak/espeak-data/am_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/an_dict b/navit/support/espeak/espeak-data/an_dict
new file mode 100644
index 000000000..f716d6226
--- /dev/null
+++ b/navit/support/espeak/espeak-data/an_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/as_dict b/navit/support/espeak/espeak-data/as_dict
new file mode 100644
index 000000000..1a04accda
--- /dev/null
+++ b/navit/support/espeak/espeak-data/as_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/az_dict b/navit/support/espeak/espeak-data/az_dict
new file mode 100644
index 000000000..e49c57a67
--- /dev/null
+++ b/navit/support/espeak/espeak-data/az_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/bg_dict b/navit/support/espeak/espeak-data/bg_dict
new file mode 100644
index 000000000..79a49c66c
--- /dev/null
+++ b/navit/support/espeak/espeak-data/bg_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/bn_dict b/navit/support/espeak/espeak-data/bn_dict
new file mode 100644
index 000000000..b6fd7f820
--- /dev/null
+++ b/navit/support/espeak/espeak-data/bn_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ca_dict b/navit/support/espeak/espeak-data/ca_dict
index b9a4ea43a..bfb99080c 100644
--- a/navit/support/espeak/espeak-data/ca_dict
+++ b/navit/support/espeak/espeak-data/ca_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/config b/navit/support/espeak/espeak-data/config
deleted file mode 100755
index be1b6246a..000000000
--- a/navit/support/espeak/espeak-data/config
+++ /dev/null
@@ -1,9 +0,0 @@
-//pa_device 7
-
-// play a sound for punctuation, rather than speak its name
-//soundicon _( /usr/share/sounds/sound-icons/left-round-bracket
-//soundicon _) /usr/share/sounds/sound-icons/right-round-bracket
-//soundicon _[ /usr/share/sounds/sound-icons/left-square-bracket
-//soundicon _] /usr/share/sounds/sound-icons/right-square-bracket
-//soundicon _{ /usr/share/sounds/sound-icons/left-brace
-//soundicon _} /usr/share/sounds/sound-icons/right-brace
diff --git a/navit/support/espeak/espeak-data/cs_dict b/navit/support/espeak/espeak-data/cs_dict
index 3391b98b2..7a1dca12b 100644
--- a/navit/support/espeak/espeak-data/cs_dict
+++ b/navit/support/espeak/espeak-data/cs_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/cy_dict b/navit/support/espeak/espeak-data/cy_dict
index 13a768030..ee4be2ecd 100644
--- a/navit/support/espeak/espeak-data/cy_dict
+++ b/navit/support/espeak/espeak-data/cy_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/da_dict b/navit/support/espeak/espeak-data/da_dict
index 75ccbd670..e362944bb 100644
--- a/navit/support/espeak/espeak-data/da_dict
+++ b/navit/support/espeak/espeak-data/da_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/de_dict b/navit/support/espeak/espeak-data/de_dict
index 988f4c31b..bc800be2a 100644
--- a/navit/support/espeak/espeak-data/de_dict
+++ b/navit/support/espeak/espeak-data/de_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/el_dict b/navit/support/espeak/espeak-data/el_dict
index a6ab63dee..7059f393e 100644
--- a/navit/support/espeak/espeak-data/el_dict
+++ b/navit/support/espeak/espeak-data/el_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/en_dict b/navit/support/espeak/espeak-data/en_dict
index d15b0e9ab..b363a4cc7 100644
--- a/navit/support/espeak/espeak-data/en_dict
+++ b/navit/support/espeak/espeak-data/en_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/eo_dict b/navit/support/espeak/espeak-data/eo_dict
index 155523963..1f75c9c86 100644
--- a/navit/support/espeak/espeak-data/eo_dict
+++ b/navit/support/espeak/espeak-data/eo_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/es_dict b/navit/support/espeak/espeak-data/es_dict
index 203da2639..8e2669aa9 100644
--- a/navit/support/espeak/espeak-data/es_dict
+++ b/navit/support/espeak/espeak-data/es_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/et_dict b/navit/support/espeak/espeak-data/et_dict
new file mode 100644
index 000000000..36501b23e
--- /dev/null
+++ b/navit/support/espeak/espeak-data/et_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/eu_dict b/navit/support/espeak/espeak-data/eu_dict
new file mode 100644
index 000000000..7b4a788df
--- /dev/null
+++ b/navit/support/espeak/espeak-data/eu_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/fa_dict b/navit/support/espeak/espeak-data/fa_dict
new file mode 100644
index 000000000..82d8a6934
--- /dev/null
+++ b/navit/support/espeak/espeak-data/fa_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/fi_dict b/navit/support/espeak/espeak-data/fi_dict
index a08d45a6f..17bf66ed8 100644
--- a/navit/support/espeak/espeak-data/fi_dict
+++ b/navit/support/espeak/espeak-data/fi_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/fr_dict b/navit/support/espeak/espeak-data/fr_dict
index e66708e04..c4551e5cb 100644
--- a/navit/support/espeak/espeak-data/fr_dict
+++ b/navit/support/espeak/espeak-data/fr_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ga_dict b/navit/support/espeak/espeak-data/ga_dict
new file mode 100644
index 000000000..f8b912cb0
--- /dev/null
+++ b/navit/support/espeak/espeak-data/ga_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/gd_dict b/navit/support/espeak/espeak-data/gd_dict
new file mode 100644
index 000000000..a048417aa
--- /dev/null
+++ b/navit/support/espeak/espeak-data/gd_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/grc_dict b/navit/support/espeak/espeak-data/grc_dict
index 0aeab45e0..b69e75513 100644
--- a/navit/support/espeak/espeak-data/grc_dict
+++ b/navit/support/espeak/espeak-data/grc_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/gu_dict b/navit/support/espeak/espeak-data/gu_dict
new file mode 100644
index 000000000..25a6c5567
--- /dev/null
+++ b/navit/support/espeak/espeak-data/gu_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/hbs_dict b/navit/support/espeak/espeak-data/hbs_dict
index 91ee7ba4b..827b44df9 100644
--- a/navit/support/espeak/espeak-data/hbs_dict
+++ b/navit/support/espeak/espeak-data/hbs_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/hi_dict b/navit/support/espeak/espeak-data/hi_dict
index 388d3f246..bad7d779c 100644
--- a/navit/support/espeak/espeak-data/hi_dict
+++ b/navit/support/espeak/espeak-data/hi_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/hu_dict b/navit/support/espeak/espeak-data/hu_dict
index 5a1f21165..6c16dbe12 100644
--- a/navit/support/espeak/espeak-data/hu_dict
+++ b/navit/support/espeak/espeak-data/hu_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/hy_dict b/navit/support/espeak/espeak-data/hy_dict
index 18c3e2027..39c321e7a 100644
--- a/navit/support/espeak/espeak-data/hy_dict
+++ b/navit/support/espeak/espeak-data/hy_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/id_dict b/navit/support/espeak/espeak-data/id_dict
index 3c9967ce8..5bd43b735 100644
--- a/navit/support/espeak/espeak-data/id_dict
+++ b/navit/support/espeak/espeak-data/id_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/intonations b/navit/support/espeak/espeak-data/intonations
new file mode 100644
index 000000000..f1e31ce9e
--- /dev/null
+++ b/navit/support/espeak/espeak-data/intonations
Binary files differ
diff --git a/navit/support/espeak/espeak-data/is_dict b/navit/support/espeak/espeak-data/is_dict
index 10cf846f8..477ef7eca 100644
--- a/navit/support/espeak/espeak-data/is_dict
+++ b/navit/support/espeak/espeak-data/is_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/it_dict b/navit/support/espeak/espeak-data/it_dict
index 40cf952a2..5b431044c 100644
--- a/navit/support/espeak/espeak-data/it_dict
+++ b/navit/support/espeak/espeak-data/it_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/jbo_dict b/navit/support/espeak/espeak-data/jbo_dict
index f7ebcf454..ac2a95282 100644
--- a/navit/support/espeak/espeak-data/jbo_dict
+++ b/navit/support/espeak/espeak-data/jbo_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ka_dict b/navit/support/espeak/espeak-data/ka_dict
new file mode 100644
index 000000000..0cf221e0c
--- /dev/null
+++ b/navit/support/espeak/espeak-data/ka_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/kl_dict b/navit/support/espeak/espeak-data/kl_dict
new file mode 100644
index 000000000..e3031a055
--- /dev/null
+++ b/navit/support/espeak/espeak-data/kl_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/kn_dict b/navit/support/espeak/espeak-data/kn_dict
new file mode 100644
index 000000000..f750d90c3
--- /dev/null
+++ b/navit/support/espeak/espeak-data/kn_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ko_dict b/navit/support/espeak/espeak-data/ko_dict
new file mode 100644
index 000000000..d7c3c8a1d
--- /dev/null
+++ b/navit/support/espeak/espeak-data/ko_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ku_dict b/navit/support/espeak/espeak-data/ku_dict
index 18d285845..17ee6f1d3 100644
--- a/navit/support/espeak/espeak-data/ku_dict
+++ b/navit/support/espeak/espeak-data/ku_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/la_dict b/navit/support/espeak/espeak-data/la_dict
index 3ef82f832..9faecc466 100644
--- a/navit/support/espeak/espeak-data/la_dict
+++ b/navit/support/espeak/espeak-data/la_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/lfn_dict b/navit/support/espeak/espeak-data/lfn_dict
new file mode 100644
index 000000000..6f2445e2f
--- /dev/null
+++ b/navit/support/espeak/espeak-data/lfn_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/lt_dict b/navit/support/espeak/espeak-data/lt_dict
new file mode 100644
index 000000000..1e2daa7cf
--- /dev/null
+++ b/navit/support/espeak/espeak-data/lt_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/lv_dict b/navit/support/espeak/espeak-data/lv_dict
index 3ecb61b51..158cf7baf 100644
--- a/navit/support/espeak/espeak-data/lv_dict
+++ b/navit/support/espeak/espeak-data/lv_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/af1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/af1_phtrans
index fc9ad0179..a87ec4ccd 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/af1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/af1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/cr1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/cr1_phtrans
index 15e2c4988..064669eaf 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/cr1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/cr1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/de2_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/de2_phtrans
index c5af1a7c4..804a0d401 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/de2_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/de2_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/de4_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/de4_phtrans
index b10fc8441..e626a582b 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/de4_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/de4_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/de6_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/de6_phtrans
index 4cb62d9c2..2aa70f4c4 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/de6_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/de6_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ee1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ee1_phtrans
new file mode 100644
index 000000000..32c569a2d
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/ee1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/en1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/en1_phtrans
index c847d1703..c32db3968 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/en1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/en1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/es_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/es_phtrans
index b959f92c1..958799c61 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/es_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/es_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/fr1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/fr1_phtrans
index 1a242b36f..dc0fcef7e 100644..100755
--- a/navit/support/espeak/espeak-data/mbrola_ph/fr1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/fr1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/gr2_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/gr2_phtrans
index b3775abbd..e7dca3af2 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/gr2_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/gr2_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/hn1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/hn1_phtrans
new file mode 100644
index 000000000..b2560ce77
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/hn1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/hu1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/hu1_phtrans
index 26dad49a0..eb661d3ab 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/hu1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/hu1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ic1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ic1_phtrans
new file mode 100644
index 000000000..978ec49ed
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/ic1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/id1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/id1_phtrans
index 452de8c8a..bd4b90cb0 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/id1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/id1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/in1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/in1_phtrans
index 7f4631899..cf1c58956 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/in1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/in1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ir1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ir1_phtrans
new file mode 100644
index 000000000..671873e7a
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/ir1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/it3_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/it3_phtrans
index 6d826477b..c9174cf0a 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/it3_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/it3_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/lt1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/lt1_phtrans
new file mode 100644
index 000000000..1066dfbc1
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/lt1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/lt2_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/lt2_phtrans
new file mode 100644
index 000000000..1066dfbc1
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/lt2_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/mx1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/mx1_phtrans
new file mode 100644
index 000000000..3b3e6f37f
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/mx1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/mx2_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/mx2_phtrans
new file mode 100644
index 000000000..a9bbb0f60
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/mx2_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/nl_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/nl_phtrans
index d982c1845..1edb05ae5 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/nl_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/nl_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/pl1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/pl1_phtrans
index 9d4e50fd7..5c3583da4 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/pl1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/pl1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/pt1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/pt1_phtrans
index c5172f7b3..f101c661f 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/pt1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/pt1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ptbr4_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ptbr4_phtrans
index 0b94de719..25bfdbf47 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/ptbr4_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/ptbr4_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ptbr_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ptbr_phtrans
index a1dbba000..f11ad8703 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/ptbr_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/ptbr_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ro1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ro1_phtrans
index 4aeaf54ec..4dec15997 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/ro1_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/ro1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/sv2_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/sv2_phtrans
index ae119d86e..805608fbc 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/sv2_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/sv2_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/sv_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/sv_phtrans
index bb556eb28..fcd75c4d3 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/sv_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/sv_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/tr1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/tr1_phtrans
new file mode 100644
index 000000000..0d6fa2a91
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/tr1_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/us3_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/us3_phtrans
index 449b419ac..90607e183 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/us3_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/us3_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/us_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/us_phtrans
index bdeef5d1a..f0af93348 100644
--- a/navit/support/espeak/espeak-data/mbrola_ph/us_phtrans
+++ b/navit/support/espeak/espeak-data/mbrola_ph/us_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/vz_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/vz_phtrans
new file mode 100644
index 000000000..0df524f08
--- /dev/null
+++ b/navit/support/espeak/espeak-data/mbrola_ph/vz_phtrans
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mk_dict b/navit/support/espeak/espeak-data/mk_dict
index a6cf3dc53..a682135e8 100644
--- a/navit/support/espeak/espeak-data/mk_dict
+++ b/navit/support/espeak/espeak-data/mk_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ml_dict b/navit/support/espeak/espeak-data/ml_dict
new file mode 100644
index 000000000..4d7f6523f
--- /dev/null
+++ b/navit/support/espeak/espeak-data/ml_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ms_dict b/navit/support/espeak/espeak-data/ms_dict
new file mode 100644
index 000000000..8a3b0364b
--- /dev/null
+++ b/navit/support/espeak/espeak-data/ms_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/nci_dict b/navit/support/espeak/espeak-data/nci_dict
new file mode 100644
index 000000000..34ff50deb
--- /dev/null
+++ b/navit/support/espeak/espeak-data/nci_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ne_dict b/navit/support/espeak/espeak-data/ne_dict
new file mode 100644
index 000000000..b55060251
--- /dev/null
+++ b/navit/support/espeak/espeak-data/ne_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/nl_dict b/navit/support/espeak/espeak-data/nl_dict
index f286bee90..7a8996443 100644
--- a/navit/support/espeak/espeak-data/nl_dict
+++ b/navit/support/espeak/espeak-data/nl_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/no_dict b/navit/support/espeak/espeak-data/no_dict
index 4f8f84f0d..aaf03015e 100644
--- a/navit/support/espeak/espeak-data/no_dict
+++ b/navit/support/espeak/espeak-data/no_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/or_dict b/navit/support/espeak/espeak-data/or_dict
new file mode 100644
index 000000000..1d023bb86
--- /dev/null
+++ b/navit/support/espeak/espeak-data/or_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/pa_dict b/navit/support/espeak/espeak-data/pa_dict
new file mode 100644
index 000000000..dc1bcdb34
--- /dev/null
+++ b/navit/support/espeak/espeak-data/pa_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/pap_dict b/navit/support/espeak/espeak-data/pap_dict
index 11eb4b515..b39bfe873 100644
--- a/navit/support/espeak/espeak-data/pap_dict
+++ b/navit/support/espeak/espeak-data/pap_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/phondata b/navit/support/espeak/espeak-data/phondata
index d46417ed0..2ccaf6817 100644
--- a/navit/support/espeak/espeak-data/phondata
+++ b/navit/support/espeak/espeak-data/phondata
Binary files differ
diff --git a/navit/support/espeak/espeak-data/phondata-manifest b/navit/support/espeak/espeak-data/phondata-manifest
index 4197d142d..f798b59bb 100644
--- a/navit/support/espeak/espeak-data/phondata-manifest
+++ b/navit/support/espeak/espeak-data/phondata-manifest
@@ -5,725 +5,837 @@
# S - A SPECT_SEQ structure
# W - A wavefile segment
# E - An envelope
+# Q - Phoneme equivalence tables
#
# Address is the displacement within phondata of this item
#
# Address Data file
# ------- ---------
-W 0x00004 ustop/null
-S 0x00154 vowel/@
-S 0x00218 vowel/@-
-W 0x002dc ustop/percus10
-S 0x004e8 j/j@
-S 0x005ec j2/j2@
-S 0x006b0 w/w@
-S 0x00774 l/l@
-S 0x00838 l^/j2@
-S 0x008fc r/r@
-S 0x009c0 r2/r2@
-S 0x00a84 m/m@
-S 0x00b88 n/n@
-S 0x00c8c nn/nn@
-S 0x00d50 n^/n^@
-S 0x00ed4 l/L1_@L
-S 0x00fd8 l/L2_@L
-S 0x010dc l/l_@
-S 0x011a0 l/xl
-S 0x01224 w/xw
-S 0x012a8 j/xj
-S 0x0132c r/xr
-S 0x013b0 r3/r_@
-S 0x01474 j/ja
-S 0x01578 j2/j2a
-S 0x0163c w/wa
-S 0x01700 l/la
-S 0x01784 l^/j2a
-S 0x01848 r/ra
-S 0x0190c r2/r2a
-S 0x019d0 m/ma
-S 0x01ad4 n/na
-S 0x01bd8 nn/nna
-S 0x01c9c n^/n^a
-S 0x01de0 l/L1_aL
-S 0x01ee4 l/L2_aL
-S 0x01fe8 l/l_a
-S 0x020ac r3/r_a
-S 0x02170 j/je
-S 0x02274 j2/j2e
-S 0x02338 w/we
-S 0x023fc l/le
-S 0x02480 l^/j2e
-S 0x02544 r/re
-S 0x02608 r2/r2e
-S 0x0270c m/me
-S 0x02810 n/ne
-S 0x02914 nn/nne
-S 0x029d8 n^/n^e
-S 0x02b5c l/L1_eL
-S 0x02c20 l/L2_eL
-S 0x02ce4 l/l_e
-S 0x02d68 r3/r_e
-S 0x02e2c j/ji
-S 0x02ef0 j2/j2i
-S 0x02fb4 w/wi
-S 0x03078 l/li
-S 0x0313c l^/j2i
-S 0x03200 r/ri
-S 0x032c4 r2/r2i
-S 0x03388 m/mi
-S 0x034cc n/ni
-S 0x035d0 nn/nni
-S 0x03694 n^/n^i
-S 0x03818 l/L1_iL
-S 0x0391c l/L2_iL
-S 0x03a20 l/l_i
-S 0x03ae4 nn/inn
-S 0x03ba8 j2/xj2
-S 0x03c2c r3/r_i
-S 0x03cf0 j/jo
-S 0x03e34 j2/j2o
-S 0x03f38 w/wo
-S 0x03ffc l/lo
-S 0x04100 l^/j2o
-S 0x04204 r/ro
-S 0x042c8 r2/r2o
-S 0x0438c m/mo
-S 0x04490 n/no
-S 0x04594 nn/nno
-S 0x04658 n^/n^o
-S 0x0481c l/L1_oL
-S 0x04960 l/L2_oL
-S 0x04aa4 l/l_o
-S 0x04ba8 r3/r_o
-S 0x04c6c j/ju
-S 0x04d30 j2/j2u
-S 0x04df4 w/wu
-S 0x04eb8 l/lu
-S 0x04f7c l^/j2u
-S 0x05080 r/ru
-S 0x05144 r2/r2u
-S 0x05208 m/mu
-S 0x0530c n/nu
-S 0x05410 nn/nnu
-S 0x054d4 n^/n^u
-S 0x05658 l/L1_uL
-S 0x0575c l/L2_uL
-S 0x05860 l/l_u
-S 0x05924 r3/r_u
-S 0x059e8 r/r
-S 0x05aac r/_r
-S 0x05b70 r/tr
-S 0x05bf4 r/r_
-S 0x05d38 r3/r_
-W 0x05dbc r3/rx
-S 0x07114 r3/r_n
-S 0x07198 r/rr
-S 0x0725c r/trr
-S 0x07320 r2/_r2
-S 0x073e4 r3/r_trill2
-W 0x074a8 r3/r_trill2.wav
-S 0x07bb4 r3/r_trill
-W 0x07cb8 r3/r_trill.wav
-W 0x08724 r3/r_trill3.wav
-S 0x08b68 r3/r_uvl
-W 0x08c6c r3/r_uvl.wav
-S 0x09b74 l/l
-S 0x09bf8 l/_l
-S 0x09cbc l/tl
-S 0x09d40 l/l_long
-S 0x09dc4 l/l_
-S 0x09e48 l^/l^
-S 0x09f4c l^/_l^
-S 0x0a050 w/w
-S 0x0a0d4 w/_w
-S 0x0a198 w/w_
-S 0x0a25c w/iw_
-S 0x0a320 j/_j
-S 0x0a3a4 j/j_
-S 0x0a468 j2/_j2
-S 0x0a4ec m/_m
-S 0x0a570 m/m_
-S 0x0a634 m/mj
-S 0x0a6f8 n/_n
-S 0x0a77c n/n_
-S 0x0a840 n/nj
-S 0x0a904 n/_nr
-S 0x0a988 n/nr_
-S 0x0aa4c n^/_n^
-S 0x0aad0 n^/n^_
-S 0x0ac14 nn/_nn
-S 0x0ac98 nn/nn_
-S 0x0ad5c nn/nnj
-S 0x0ade0 r3/@tap
-S 0x0af24 r3/@tap2
-S 0x0b068 r3/@tap_rfx
-S 0x0b1ac b/b
-W 0x0b2b0 x/b
-S 0x0b414 b/b_
-W 0x0b4d8 x/b_
-S 0x0b8f0 b/ba
-S 0x0b9f4 b/b@
-S 0x0baf8 b/be
-S 0x0bbfc b/bi
-S 0x0bd00 b/bo
-S 0x0be04 b/bu
-S 0x0bf08 b/b@2
-S 0x0c00c b/xb
-S 0x0c0d0 d/d
-W 0x0c194 x/d
-S 0x0c3b0 d/d_
-W 0x0c474 x/d_
-S 0x0c89c d/dr
-S 0x0c920 d/xd
-W 0x0c9e4 x/d_dnt
-S 0x0ccc8 d/tap3
-S 0x0cdcc d/tap1
-S 0x0ce90 dzh/dzh
-W 0x0cf54 x/dzh
-S 0x0d360 dzh/dzh_
-W 0x0d424 x/dzh_
-S 0x0de5c dzh/xdzh
-W 0x0df20 x/dz_pzd
-S 0x0e380 dzh/dz_pzd
-S 0x0e444 dzh/dz_pzd_
-S 0x0e508 dzh/xdz_pzd
-S 0x0e5cc g/g
-W 0x0e690 x/g2
-S 0x0e918 g/g_
-W 0x0e9dc x/g_
-S 0x0ed9c g/xg
-S 0x0ee60 g2/g
-W 0x0ef24 x/g2_
-S 0x0f2e4 g2/g_
-S 0x0f3a8 g2/xg
-S 0x0f46c voc/bh
-W 0x0f530 vocw/v
-S 0x0fe30 voc/v_
-S 0x0fef4 voc/v
-S 0x0fff8 voc/vj
-S 0x100fc voc/dh
-W 0x101c0 vocw/dh
-S 0x10ac8 voc/dh_
-S 0x10b8c voc/z
-W 0x10c50 ufric/s_
-S 0x11704 voc/z_
-S 0x117c8 voc/zh
-W 0x1188c vocw/zh
-S 0x121f4 voc/zh_
-W 0x122b8 vocw/zh_rfx
-S 0x12b48 voc/z_pzd
-W 0x12c0c ufric/s_pzd
-S 0x13544 voc/z_pzd_
-W 0x13608 ufric/s_pzd_
-W 0x1410c ufric/sh_pzd
-W 0x14a40 ufric/sh_pzd_
-S 0x15508 voc/j
-W 0x1560c ufric/ch
-S 0x15d24 voc/Q
-W 0x15de8 vocw/Q
-S 0x165f4 voc/Q_
-W 0x166b8 vocw/Q_
-S 0x16ec4 voc/Q_ulv
-W 0x16fc8 ufric/xx
-W 0x17ac4 ustop/p
-W 0x17e34 ustop/p_
-W 0x18644 ustop/pr
-W 0x18a8c ustop/p_unasp
-W 0x18db8 ustop/pl
-W 0x191b0 ustop/t
-W 0x195e4 ustop/t_
-W 0x19aa4 ustop/t_dnt
-W 0x19eb4 ustop/tr
-W 0x1a614 ustop/t_hi
-W 0x1a9b0 ustop/tsh
-W 0x1aff0 ustop/tsh_
-W 0x1b930 ustop/ts_pzd
-W 0x1c034 ustop/c
-W 0x1c2e4 ustop/t_pzd
-W 0x1c730 ustop/k
-W 0x1cc04 ustop/k_
-W 0x1d0c0 ustop/kr
-W 0x1d700 ustop/k_unasp
-W 0x1dbd4 ustop/kl
-W 0x1e204 ustop/ki
-W 0x1e7cc ustop/q
-W 0x1e938 ustop/q_u
-W 0x1ea58 ufric/f
-W 0x1f248 ufric/f_
-W 0x1fd18 ufric/th
-W 0x205b0 ufric/th_
-W 0x20e30 ufric/s
-W 0x215d0 ufric/s!
-W 0x21e80 ufric/sh
-W 0x22830 ufric/sh_
-W 0x232e0 ufric/sh_rfx
-W 0x23c7c ufric/ll
-W 0x246c0 ufric/ch_
-W 0x24fe8 ufric/x_hr
-W 0x258fc ufric/x
-W 0x26260 h/h_
-W 0x2690c h/h@
-W 0x26e60 h/ha
-W 0x274dc h/he
-W 0x27b70 h/hi
-W 0x28108 h/ho
-W 0x287c4 h/hu
-S 0x28ee8 vowel/a_2
-S 0x28fec vowel/a#
-S 0x290f0 vowel/e
-S 0x291f4 vowel/ee_1
-S 0x29338 vowel/i
-S 0x2943c vowel/o
-S 0x29580 vowel/oo_4
-S 0x29684 vowel/u_bck
-S 0x29788 vowel/uu_2
-S 0x2988c vowel/y
-S 0x299d0 vowel/y#
-S 0x29ad4 vdiph/au_4
-S 0x29c58 vdiph/eu
-S 0x29d9c vdiph2/iu
-S 0x29f20 vdiph/ai
-S 0x2a064 vdiph/ei
-S 0x2a1a8 vdiph/eei
-S 0x2a32c vdiph/oi
-S 0x2a4f0 vdiph/ui
-S 0x2a634 w/w2
-W 0x2a6f8 ustop/p_unasp_
-W 0x2a834 ustop/ts
-W 0x2b290 ustop/ts_
-W 0x2bbf0 ustop/t_dnt2
-S 0x2be48 vwl_en/@L
-S 0x2bf0c vowel/a
-S 0x2c010 vowel/a#_3
-S 0x2c0d4 vowel/ee_2
-S 0x2c1d8 vowel/ii_4
-S 0x2c2dc vowel/ii_en
-S 0x2c3a0 vowel/0
-S 0x2c4a4 vowel/V_2
-S 0x2c5a8 vowel/uu
-S 0x2c6ac vowel/aa_2
-S 0x2c830 vowel/3_en
-S 0x2c974 vowel/i_en
-S 0x2cab8 w/wi2
-S 0x2cbbc vowel/oo_en
-S 0x2cd00 vdiph2/uw_2
-S 0x2ce44 vwl_en/u_L
-S 0x2cf88 vdiph/au
-S 0x2d10c vdiph/@u_en
-S 0x2d290 vdiph/ai_2
-S 0x2d454 vdiph/ooi
-S 0x2d618 vdiph2/ii@
-S 0x2d79c vdiph2/uu@
-S 0x2d8e0 vwl_en/aI@
-S 0x2daa4 vwl_en/aU@
-S 0x2dc28 vowelr/V_r
-S 0x2dd6c vowelr/V3_r
-S 0x2deb0 vnasal/aa_n2
-S 0x2dff4 vnasal/ee_n
-S 0x2e138 vnasal/oo_n
-S 0x2e23c vowel/oe
-S 0x2e300 vowel/@_fr
-S 0x2e3c4 vowel/ee
-S 0x2e4c8 vowel/ii
-S 0x2e5cc vowel/e_3
-S 0x2e6d0 vowel/0_2
-S 0x2e7d4 vowel/o-_2
-S 0x2e8d8 vowel/aa_5
-S 0x2ea1c vwl_en_n/aa_5
-S 0x2eb60 vowel/3_2
-S 0x2eca4 vowel/oo_1
-S 0x2ede8 vwl_en_n/O@
-S 0x2eeec vdiph2/uw_4
-S 0x2f030 vdiph/eeu_3
-S 0x2f174 vdiph/ae_2
-S 0x2f2f8 vdiph2/ee@
-S 0x2f43c vdiph2/i@
-S 0x2f600 vwl_en_us/3_us
-S 0x2f704 vowel/@_4
-S 0x2f7c8 vowel/@_low2
-S 0x2f88c vwl_en_us/a
-S 0x2f990 vnasal/ee_n2
-S 0x2fad4 vwl_en_us/ee
-S 0x2fbd8 vowel/ii#_3
-S 0x2fcdc vowel/ii_final
-S 0x2fde0 vowel/aa_8
-S 0x2fee4 vwl_en_us/oor
-S 0x30028 vowel/V_6
-S 0x3012c vowel/8_2
-S 0x30230 vwl_en_us/ar
-S 0x30374 vwl_en_us/3_us2
-S 0x304b8 vowel/0_3
-S 0x305bc vwl_en_us/or
-S 0x30700 vowel/aa#
-S 0x30804 vdiph2/uw
-S 0x30948 vdiph/aoo
-S 0x30a8c vdiph/8u
-S 0x30bd0 vdiph/aae
-S 0x30d54 vdiph2/ei_4
-S 0x30e98 vdiph/ooi_4
-S 0x30fdc vwl_en_us/er
-S 0x31120 vwl_en_us/ir
-S 0x31264 vwl_en_us/ur
-S 0x313a8 vwl_en_us/ai@
-S 0x3152c d/tap2
-S 0x315f0 d/x_tap
-S 0x316b4 vowel/@_3
-S 0x31778 vowel/V
-S 0x3187c vowel/a_3
-S 0x31980 vowel/e_e
-S 0x31a84 vowel/e#
-S 0x31b88 vowel/e_5
-S 0x31c8c vowel/oo_2
-S 0x31d90 vowel/V_4
-S 0x31e94 vowel/u#_4
-S 0x31f98 vowelr/aa_r
-S 0x3215c vdiph2/e@
-S 0x322a0 vowel/i_5
-S 0x323a4 vowel/oo
-S 0x324a8 vowelr/oo_r
-S 0x325ac vowelr/o_r
-S 0x32730 vowel/u#
-S 0x32834 vdiph/au#
-S 0x32978 vowel/o_3
-S 0x32a7c vdiph/ai_7
-S 0x32c00 vwl_en/aI@_2
-S 0x32d84 vwl_en/@L_2
-S 0x32e88 vowel/e_2
-S 0x32f8c vdiph/0i_2
-S 0x33110 vowelr/i_r
-S 0x33254 vdiph2/u#@
-S 0x33398 vowel/@_low
-S 0x3345c vowel/&
-S 0x33560 vowel/e_mid
-S 0x33664 vowel/V_3
-S 0x33728 vowel/o-_3
-S 0x3382c vwl_en_rp/aa
-S 0x33970 vowel/3_3
-S 0x33ab4 vowel/u_fnt
-S 0x33bb8 vdiph/au_3
-S 0x33d3c vdiph/@u_2
-S 0x33e80 vdiph/ai_6
-S 0x34044 vdiph2/ei_2
-S 0x34188 vdiph/ooi_3
-S 0x3430c vdiph2/ee@_2
-S 0x34450 vwl_en_rp/i@
-S 0x345d4 vowel/o_mid
-S 0x346d8 vwl_en_rp/aU@
-S 0x3485c vowel/ii_6
-S 0x34920 vdiph2/ei_3
-S 0x34a64 vdiph/@u
-S 0x34ba8 vdiph/Vu_2
-S 0x34d2c vdiph/@i_3
-S 0x34e70 vdiph2/i@_2
-S 0x34ff4 vwl_en/ooi@
-S 0x351b8 vowel/@_fnt
-S 0x352bc vowel/uu_bck
-S 0x353c0 vowel/i_fnt
-S 0x354c4 vdiph2/o_oo
-S 0x35608 vowel/u
-S 0x3570c vdiph/aau_2
-S 0x35850 vdiph2/ie
-S 0x35994 vwl_af/@
-S 0x35a58 vwl_af/r@
-S 0x35b1c vowel/e_mid2
-S 0x35c20 vwl_af/I
-S 0x35ce4 vowel/oo_3
-S 0x35da8 vowel/uu_3
-S 0x35e6c vowel/ee_3
-S 0x35f30 l/L_eL_af
-S 0x35ff4 vowel/aa_3
-S 0x360f8 vdiph/i@_2
-S 0x3627c vowel/i_3
-S 0x36380 vdiph2/o@
-S 0x36504 vowel/y_3
-S 0x36608 vdiph2/iu_3
-S 0x367cc vdiph/Vu
-S 0x36950 vdiph/ai_4
-S 0x36ad4 vdiph/aai_2
-S 0x36c98 vdiph/@i_2
-S 0x36ddc vdiph/ooi_2
-S 0x36f60 vdiph/oi_2
-S 0x37124 vdiph/ui_2
-S 0x372a8 vdiph/y#y_2
-S 0x3742c vdiph2/y#@
-S 0x37570 vnasal/aa_n3
-S 0x376b4 vnasal/e_n
-S 0x377b8 vnasal/o_n2
-W 0x378fc ufric/x2
-S 0x38254 vowel/ii_3
-S 0x38358 vowel/ii#
-S 0x3845c vowel/i#
-S 0x38560 vowel/o_2
-S 0x386a4 vdiph2/iu_4
-S 0x387e8 vdiph/ui_3
-S 0x3896c vowel/aa_6
-S 0x38ab0 vowel/i_2
-S 0x38bb4 vdiph/ai_5
-S 0x38cf8 vowel/yy_4
-S 0x38dfc l/l_3
-S 0x38e80 j/_j_short
-S 0x38f04 vdiph/eei_2
-S 0x39048 vowelr/r-voc
-S 0x3918c vwl_hi/l-voc
-S 0x39290 vowel/i_4
-S 0x39394 vowel/aa_9
-S 0x39498 vowel/u_2
-S 0x3959c vowel/uu_4
-S 0x396a0 vdiph/aai_3
-S 0x39824 vdiph/&i
-S 0x39968 vdiph/y#i
-S 0x39aac vdiph/ui_4
-S 0x39bf0 vdiph/yi
-S 0x39d34 vdiph/aau
-S 0x39eb8 vdiph/ou
-S 0x39ffc vdiph/eu_2
-S 0x3a140 vdiph2/iu_2
-S 0x3a2c4 vdiph/&y
-S 0x3a408 vdiph/eey
-S 0x3a54c vdiph/y#y
-S 0x3a690 vdiph2/iy
-S 0x3a7d4 vdiph2/uo
-S 0x3a918 vdiph2/y-y#
-S 0x3aa5c r3/r_trill_short
-W 0x3ab60 ufric/s_continue
-W 0x3b310 h/hu_fi
-S 0x3bc00 vwl_fr/tr
-S 0x3bc84 vwl_fr/@R5
-S 0x3bd48 vowel/@_hgh
-S 0x3be0c vwl_fr/r_@
-S 0x3bed0 vowel/a_6
-S 0x3bfd4 vwl_fr/r_a
-S 0x3c058 vowel/e_8
-S 0x3c15c vwl_fr/r_e
-S 0x3c220 vwl_fr/r_i
-S 0x3c2e4 vwl_fr/r_o
-S 0x3c3a8 vowel/u_bck2
-S 0x3c4ac vwl_fr/r_u
-S 0x3c570 vowel/y_2
-S 0x3c6b4 l/l_y
-S 0x3c778 vwl_fr/r_y
-S 0x3c83c vowel/@_5
-S 0x3c900 vwl_fr/r_@2
-S 0x3c984 vwl_fr/w_a
-S 0x3cac8 vdiph/yi_fr
-S 0x3cc4c vnasal/aa_n4
-S 0x3cd90 vwl_fr/r_a~
-S 0x3ce14 vnasal/W_n
-S 0x3cf58 vowel/a_en
-S 0x3d05c vwl_fr/r
-S 0x3d0e0 r3/r_2
-W 0x3d164 ustop/t_short
-S 0x3d3a8 vowel/yy
-S 0x3d4ac vdiph/ae
-S 0x3d5f0 vowel/aa
-S 0x3d6f4 vwl_fr/@R2
-S 0x3d7f8 vowel/@_bck
-S 0x3d8fc vowel/i_6
-S 0x3da00 vdiph/ee-e
-S 0x3db44 vnasal/i_n2
-S 0x3dc48 vnasal/aa_n
-S 0x3dd8c vnasal/V_n
-S 0x3de90 vnasal/oo_n2
-S 0x3dfd4 vnasal/o_n
-S 0x3e118 vnasal/u_n
-S 0x3e21c vdiph/aau_3
-S 0x3e3a0 l^/l_rfx
-S 0x3e464 voc/v#
-S 0x3e568 voc/v#_
-W 0x3e62c ustop/p_asp
-S 0x3eb30 d/xd3
-W 0x3ebf4 ustop/ts_pzd2
-W 0x3ef28 ustop/ts_pzd_
-W 0x3f3ec ustop/k_asp
-S 0x3faf0 vowel/a_5
-S 0x3fbf4 vowel/u#_3
-S 0x3fcf8 vowel/u#_2
-S 0x3fdfc vowel/y#_2
-S 0x3ff00 vowel/8_7
-S 0x40004 vdiph/aai
-S 0x40188 vdiph2/uaa
-S 0x4030c vdiph2/ie_2
-W 0x40450 ustop/ts2
-S 0x40920 vowel/o_5
-S 0x40a24 vowel/o_6
-S 0x40ae8 vowel/aa_7
-S 0x40bec vdiph/y#y_3
-S 0x40cf0 vdiph/Vu_3
-S 0x40e74 vdiph2/yu
-S 0x40ff8 voc/Q_less
-W 0x410bc vocw/Q2
-W 0x41988 ufric/sx_sv
-S 0x421d0 vowel/a#_2
-S 0x422d4 vowel/ee#
-S 0x423d8 vowel/i_7
-S 0x424dc vowel/oo_5
-S 0x425e0 vowel/ii#_2
-S 0x426e4 vnasal/ee_u_n
-S 0x42868 vnasal/oo_n3
-W 0x429ec x/d_pzd
-S 0x42e00 d/xd_pzd
-S 0x42ec4 d/xdz
-S 0x42f88 vowel/ee_6
-S 0x4304c vdiph/ou_2
-S 0x43190 vdiph/eei_3
-W 0x432d4 r3/rz_cs
-S 0x43d80 voc/zh_2
-S 0x43e44 vdiph/oou
-W 0x43f88 ufric/sh3
-W 0x4491c ustop/tsh2
-W 0x45028 ustop/ts_pzd3
-S 0x456a8 dzh/dzh2
-W 0x4576c ustop/t_sr
-S 0x45aa4 d/d_dnt
-W 0x45b68 ufric/x_sr
-W 0x463e8 ufric/ch_sr
-W 0x46fc8 ufric/sh_pzd2
-W 0x47b18 ustop/ts_sr
-W 0x482d4 ustop/tsh_sr
-S 0x48bec vwl_ru/ii-
-S 0x48cb0 vwl_ro/mi
-S 0x48df4 vwl_ru/i
-S 0x48ef8 vwl_ru/ii#
-S 0x48fbc vwl_ru/i#
-S 0x490c0 vwl_ru/ii
-S 0x491c4 vwl_ru/e
-S 0x492c8 vwl_ru/E#
-S 0x493cc vwl_ru/E@
-S 0x494d0 vwl_ru/a
-S 0x495d4 vwl_ru/o
-S 0x496d8 vwl_ru/oo
-S 0x4979c vwl_ru/u
-S 0x498a0 vwl_ru/u#
-S 0x499e4 vwl_ru/u#u
-S 0x49b28 vwl_ru/8
-S 0x49bec vwl_ru/ee
-S 0x49d30 vwl_ru/ju
-S 0x49e34 vwl_ru/ja
-S 0x49fb8 vwl_ru/aa
-S 0x4a0bc r3/r_ru2
-W 0x4a1c0 r3/r_ru
-S 0x4a4c4 vowel/ii_5
-S 0x4a5c8 vdiph/eeu_2
-S 0x4a70c d/tap4
-S 0x4a810 voc/v2
-S 0x4a8d4 vnasal/i_n
-S 0x4a9d8 vnasal/a#_n
-S 0x4aadc vnasal/a#u_n
-S 0x4ac20 vnasal/oi_n
-S 0x4ade4 vdiph/0i
-S 0x4afa8 vdiph/eeu
-S 0x4b0ec vowel/i#_5
-S 0x4b1f0 vowel/u_6
-S 0x4b2f4 vwl_fr/@R
-S 0x4b3f8 vwl_ro/ii-
-S 0x4b4bc vwl_ro/li
-S 0x4b5c0 vwl_ro/ni
-S 0x4b6c4 vowel/o-_4
-S 0x4b7c8 vdiph/@u_3
-S 0x4b94c vdiph/ii
-S 0x4bb10 vdiph/i#i
-S 0x4bc54 vdiph2/uw_3
-S 0x4bd98 vdiph2/ea
-S 0x4bedc vdiph2/eo
-S 0x4c060 vdiph2/e[u
-S 0x4c1a4 vdiph2/oa
-S 0x4c2e8 d/tap
-S 0x4c3ac d/tap_i
-S 0x4c470 vowel/a_4
-S 0x4c574 vowel/ee#_2
-S 0x4c678 vowel/y_5
-S 0x4c7bc vowel/yy_3
-S 0x4c8c0 vowel/oe_4
-S 0x4c984 vowel/aa_4
-S 0x4ca88 vwl_sv/r_sv3
-S 0x4cc8c vowel/y_4
-S 0x4cd90 vowel/oe_2
-S 0x4ce94 vwl_no/y#
-S 0x4cf98 vwl_no/&
-S 0x4d09c vwl_no/u#
-S 0x4d1a0 vwl_no/u#2
-S 0x4d2e4 vdiph/ai_3
-S 0x4d428 vwl_no/y#y
-S 0x4d56c vwl_no/au-
-S 0x4d730 vowel/y##
-S 0x4d834 vowel/y#_3
-S 0x4d938 vdiph/ou_3
-S 0x4da3c vdiph/y#i_2
-S 0x4db80 m/m#_
-S 0x4dc84 n/n#_
-S 0x4dd88 n^/n^#_
-S 0x4de8c nn/nn#_
-W 0x4df90 ufric/tl#
-S 0x4e8f8 r3/r#_
-E 0x4e97c envelope/p_level
-E 0x4e9fc envelope/p_fall
-E 0x4ea7c envelope/p_rise
-E 0x4eafc envelope/p_fallrise
-E 0x4eb7c envelope/p_214
-E 0x4ebfc envelope/vi_5amp
-E 0x4ec7c envelope/p_512
-E 0x4ecfc envelope/vi_6amp
-S 0x4ed7c vowel/u_7
-S 0x4ee80 vowel/u#_5
-S 0x4ef84 vowel/@_2
-S 0x4f088 vdiph/&i_3
-S 0x4f20c vdiph/@i
-S 0x4f350 vdiph/u-i
-S 0x4f494 vdiph/aau_4
-S 0x4f618 vdiph2/ii@_3
-S 0x4f79c l/l_vi
-S 0x4f8a0 vwl_zh/ang
-S 0x4faa4 vwl_zh/aang
-S 0x4fce8 vdiph/au_2
-S 0x4fe6c vwl_zh/eng
-S 0x50070 vwl_zh/ing
-S 0x502b4 vwl_zh/ng
-S 0x503f8 vwl_zh/oeng
-S 0x505bc vwl_zh/ong
-S 0x50740 vwl_zh/ung
-S 0x508c4 vowel/8_3
-E 0x509c8 envelope/i_risefall
-W 0x50a48 ustop/t_unasp2
-S 0x50b54 n/n_long_
-W 0x50c18 ustop/k_unasp_
-W 0x50ed4 ustop/tsh_pzd_unasp
-W 0x51724 ustop/tsh_pzd
-W 0x52264 ustop/ts_unasp
-W 0x52adc ustop/ts_rfx_unasp
-W 0x536c8 ustop/ts_rfx
-S 0x543a8 nn/nn2_
-S 0x5446c vwl_zh/a_n
-S 0x54570 vwl_zh/aau
-S 0x546b4 vowel/ii_2
-S 0x54778 vowel/i#_7
-S 0x5487c vowel/i#_6
-S 0x54980 vwl_zh/iaa
-S 0x54ac4 vwl_zh/iaau
-S 0x54c48 vwl_zh/ie
-S 0x54d8c vdiph2/iioo
-S 0x54ed0 vwl_zh/iou
-S 0x55054 vowel/8
-S 0x55158 vwl_zh/uaa
-S 0x5529c vwl_zh/uai
-S 0x55420 vwl_zh/uei
-S 0x555a4 vwl_zh/uo
-S 0x55728 vwl_zh/y&
-S 0x5586c vwl_zh/yee
-S 0x559b0 vdiph2/y@
-S 0x55af4 vowel/u_5
-S 0x55bf8 vnasal/m-
-S 0x55cfc vnasal/n-
-S 0x55e00 vnasal/nn-
-S 0x55f04 vowel/u#_7
-S 0x56008 vowel/8_5
-S 0x5610c vowel/o_7
-S 0x56210 vowel/uu#
-S 0x56314 vowel/8_6
-S 0x56418 vowel/ee_4
-S 0x5651c vdiph2/ye
-S 0x56660 l/l_front_
-S 0x567a4 l/l_front
-S 0x568a8 l/l_4
-S 0x5696c vwl_fr/@R3
-S 0x56a30 vwl_fr/@R4
-S 0x56af4 r/a_
+W 0x00008 ustop/null
+S 0x00158 vowel/@
+S 0x0021c vowel/@-
+S 0x002e0 vowel/a
+S 0x003e4 vowel/e
+S 0x004e8 vowel/i
+S 0x005ec vowel/oo
+S 0x006f0 vowel/u
+S 0x007f4 klatt/m-syl
+S 0x00978 m/m-syl
+S 0x00afc klatt/n-syl
+S 0x00c40 n/n-syl
+S 0x00d84 nn/nn-syl
+W 0x00ec8 ustop/percus10
+S 0x010d4 vowelr/r-voc
+S 0x01218 vwl_hi/l-voc
+S 0x0131c r/r@
+S 0x013e0 r/ra
+S 0x014a4 r/re
+S 0x01568 r/ri
+S 0x0162c r/ro
+S 0x016f0 r/ru
+S 0x017b4 r/xr
+S 0x01838 r/_r
+S 0x018fc r/tr
+S 0x01980 r/r
+S 0x01a44 r3/r_n
+W 0x01ac8 r3/rx
+S 0x02e20 r/trr
+S 0x02ee4 r/rr
+S 0x02fa8 r3/r_
+S 0x0302c r3/r_trill2
+W 0x030f0 r3/r_trill2.wav
+S 0x037fc r3/r_trill
+W 0x03900 r3/r_trill.wav
+W 0x0436c r3/r_trill3.wav
+S 0x047b0 r3/r_uvl
+W 0x048b4 r3/r_uvl.wav
+S 0x057bc l/l@
+S 0x05880 l/la
+S 0x05904 l/le
+S 0x05988 l/li
+S 0x05a4c l/lo
+S 0x05b50 l/lu
+S 0x05c14 l/L1_@L
+S 0x05d18 l/L1_aL
+S 0x05e1c l/L1_eL
+S 0x05ee0 l/L1_iL
+S 0x05fe4 l/L1_oL
+S 0x06128 l/L1_uL
+S 0x0622c l/l_
+S 0x062b0 l/xl
+S 0x06334 l/_l
+S 0x063f8 l/tl
+S 0x0647c l/l_long
+S 0x06500 l/l
+S 0x06584 l/L2_eL
+S 0x06648 l/L2_uL
+S 0x0674c l/L2_@L
+S 0x06850 l/L2_aL
+S 0x06954 l/L2_iL
+S 0x06a58 l/L2_oL
+S 0x06b9c l/l_@
+S 0x06c20 l/l_a
+S 0x06ca4 l/l_e
+S 0x06d28 l/l_i
+S 0x06dec l/l_o
+S 0x06eb0 l/l_u
+S 0x06f34 l^/j2@
+S 0x06ff8 l^/j2a
+S 0x070bc l^/j2e
+S 0x07180 l^/j2i
+S 0x07244 l^/j2o
+S 0x07348 l^/j2u
+S 0x0744c l^/_l^
+S 0x07550 l^/l^
+S 0x07654 l^/l_rfx
+S 0x07718 ll/xll
+S 0x077dc ll/_ll
+S 0x078e0 ll/ll
+S 0x079a4 w/w@
+S 0x07a68 w/wa
+S 0x07b2c w/we
+S 0x07bf0 w/wi
+S 0x07cb4 w/wo
+S 0x07d78 w/wu
+S 0x07e3c w/xw
+S 0x07ec0 w/w
+S 0x07f44 w/_w
+S 0x08008 w/iw_
+S 0x0810c w/w_
+S 0x081d0 j/j@
+S 0x082d4 j/ja
+S 0x083d8 j/je
+S 0x084dc j/ji
+S 0x085a0 j/jo
+S 0x086e4 j/ju
+S 0x087a8 j/xj
+S 0x0882c j/_j
+S 0x088b0 j/j_
+S 0x08974 j2/j2@
+S 0x08a38 j2/j2a
+S 0x08afc j2/j2e
+S 0x08bc0 j2/j2i
+S 0x08c84 j2/j2o
+S 0x08d88 j2/j2u
+S 0x08e4c j2/xj2
+S 0x08ed0 j2/_j2
+S 0x08f54 klatt/m_
+S 0x09058 klatt/m
+S 0x0915c m/m@
+S 0x09260 m/ma
+S 0x09364 m/me
+S 0x09468 m/mi
+S 0x095ac m/mo
+S 0x096b0 m/mu
+S 0x097b4 m/mj
+S 0x09878 m/_m
+S 0x098fc m/m_
+S 0x099c0 klatt/n
+S 0x09ac4 n/n@
+S 0x09bc8 n/na
+S 0x09ccc n/ne
+S 0x09dd0 n/ni
+S 0x09ed4 n/no
+S 0x09fd8 n/nu
+S 0x0a0dc n/nj
+S 0x0a1a0 n/_n
+S 0x0a224 n/n_
+S 0x0a2e8 klatt/nr
+S 0x0a3ec n/nr@
+S 0x0a4f0 n/nra
+S 0x0a5f4 n/nre
+S 0x0a6f8 n/nri
+S 0x0a7fc n/nro
+S 0x0a900 n/nru
+S 0x0aa04 n/_nr
+S 0x0aa88 n/nr_
+S 0x0ab4c klatt/n^@
+S 0x0abd0 klatt/n^
+S 0x0acd4 n^/n^@
+S 0x0ae58 n^/n^a
+S 0x0af9c n^/n^e
+S 0x0b120 n^/n^i
+S 0x0b2a4 n^/n^o
+S 0x0b468 n^/n^u
+S 0x0b5ec n^/_n^
+S 0x0b670 n^/n^_
+S 0x0b7b4 klatt/nn_
+S 0x0b8b8 klatt/nn
+S 0x0b9bc nn/nn@
+S 0x0ba80 nn/nna
+S 0x0bb44 nn/nne
+S 0x0bc08 nn/nni
+S 0x0bccc nn/nno
+S 0x0bd90 nn/nnu
+S 0x0be54 nn/inn
+S 0x0bf18 nn/nnj
+S 0x0bf9c nn/_nn
+S 0x0c020 nn/nn_
+S 0x0c0e4 r3/@tap2
+S 0x0c228 r3/@tap
+S 0x0c36c d/tap1
+S 0x0c430 d/tap3
+S 0x0c534 d/dr
+S 0x0c5b8 r3/@tap_rfx_
+S 0x0c6fc r3/@tap_rfx
+S 0x0c840 b/xb
+S 0x0c904 klatt/b
+W 0x0c9c8 x/b_
+W 0x0cde0 x/b
+S 0x0cf44 b/b_
+S 0x0d008 b/b@2
+S 0x0d10c b/b@
+S 0x0d210 b/ba
+S 0x0d314 b/be
+S 0x0d418 b/bi
+S 0x0d51c b/bo
+S 0x0d620 b/bu
+S 0x0d724 b/b
+S 0x0d828 d/xd
+S 0x0d8ec d/d_
+W 0x0d9b0 x/d_
+S 0x0ddd8 d/d
+W 0x0de9c x/d
+W 0x0e0b8 x/d_dnt
+S 0x0e39c dzh/xdzh
+S 0x0e460 dzh/dzh_
+W 0x0e524 x/dzh_
+S 0x0ef5c dzh/dzh
+W 0x0f020 x/dzh
+W 0x0f42c x/dz_pzd
+S 0x0f88c dzh/xdz_pzd
+S 0x0f950 klatt/dz_pzd_
+S 0x0fa14 klatt/dz_pzd
+S 0x0fad8 dzh/dz_pzd_
+S 0x0fb9c dzh/dz_pzd
+S 0x0fc60 g/xg
+S 0x0fd24 g/g_
+W 0x0fde8 x/g_
+S 0x101a8 g/g
+W 0x1026c x/g2
+S 0x104f4 klatt/v_
+W 0x105b8 vocw/v
+S 0x10eb8 klatt/bh
+S 0x10f7c voc/v_
+S 0x11040 voc/bh
+S 0x11104 klatt/v
+S 0x111c8 voc/v
+S 0x112cc voc/v#_
+S 0x11390 voc/v#
+S 0x11494 voc/dh_
+W 0x11558 vocw/dh
+S 0x11e60 voc/dh
+S 0x11f24 voc/z_
+W 0x11fe8 ufric/s_
+S 0x12a9c voc/z
+S 0x12b60 klatt/zh_
+W 0x12c24 vocw/zh
+S 0x1358c klatt/zh
+S 0x13650 voc/zh_
+S 0x13714 voc/zh
+W 0x137d8 vocw/zh_rfx
+S 0x14068 voc/z_pzd_
+W 0x1412c ufric/s_pzd_
+S 0x14c30 voc/z_pzd
+W 0x14cf4 ufric/s_pzd
+W 0x1562c ufric/sh_pzd_
+W 0x160f4 ufric/sh_pzd
+S 0x16a28 voc/j
+W 0x16b2c ufric/ch
+S 0x17244 klatt/qqh_
+W 0x17308 vocw/Q_
+S 0x17b14 klatt/qqh
+W 0x17bd8 vocw/Q
+S 0x183e4 voc/Q_
+S 0x184a8 voc/Q
+S 0x1856c voc/Q_ulv
+W 0x18670 ufric/xx
+W 0x1916c ustop/p_
+W 0x1997c ustop/pr
+W 0x19dc4 ustop/p_unasp
+W 0x1a0f0 ustop/pl
+W 0x1a4e8 ustop/p
+W 0x1a858 ustop/t_
+W 0x1ad18 ustop/tr
+W 0x1b478 ustop/t_dnt
+W 0x1b888 ustop/t
+W 0x1bcbc ustop/t_hi
+W 0x1bf88 ustop/tsh_
+W 0x1c8c8 ustop/tsh
+W 0x1cf08 ustop/ts_pzd
+W 0x1d60c ustop/t_pzd
+W 0x1da58 ustop/c
+W 0x1dd08 ustop/k_
+W 0x1e1c4 ustop/kr
+W 0x1e804 ustop/ki
+W 0x1edcc ustop/kl
+W 0x1f3fc ustop/k_unasp
+W 0x1f8d0 ustop/k
+W 0x1fda4 ustop/q
+W 0x1ff10 ustop/q_u
+W 0x20030 ufric/f_
+W 0x20b00 ufric/f
+W 0x212f0 ufric/th_
+W 0x21b70 ufric/th
+W 0x22408 ufric/s!
+W 0x22cb8 ufric/s
+W 0x23458 ufric/sh_
+W 0x23f08 ufric/sh
+W 0x248b8 ufric/sh_rfx
+W 0x25254 ufric/l#
+W 0x25c98 ufric/ch_
+W 0x265c0 ufric/x_
+W 0x2711c ufric/x_hr
+W 0x27a30 h/h@
+W 0x27f84 h/ha
+W 0x28600 h/he
+W 0x28c94 h/hi
+W 0x2922c h/ho
+W 0x298e8 h/hu
+W 0x2a00c h/h_
+W 0x2a6b8 ustop/ts_
+W 0x2b018 ustop/ts
+S 0x2ba74 d/xdz
+W 0x2bb38 ustop/p_unasp_
+W 0x2bc74 ustop/p_asp
+W 0x2c178 ustop/t_short
+W 0x2c3bc ustop/ts_pzd_
+W 0x2c880 ustop/ts_pzd2
+W 0x2cbb4 ustop/k_asp
+W 0x2d2b8 ustop/k_asp_e
+W 0x2da20 ustop/k_asp_a
+W 0x2e2a4 ufric/s_continue
+S 0x2ea54 vowel/a#
+S 0x2eb58 vowel/a_2
+S 0x2ec5c vowel/ee_1
+S 0x2eda0 vowel/o
+S 0x2eee4 vowel/oo_4
+S 0x2efe8 vowel/u_bck
+S 0x2f0ec vowel/uu_2
+S 0x2f1f0 vowel/y
+S 0x2f334 vowel/y#
+S 0x2f438 vdiph/au_4
+S 0x2f5bc vdiph/eu
+S 0x2f700 vdiph2/iu
+S 0x2f884 vdiph/ai
+S 0x2f9c8 vdiph/ei
+S 0x2fb0c vdiph/eei
+S 0x2fc90 vdiph/oi
+S 0x2fe54 vdiph/ui
+S 0x2ff98 w/w2
+W 0x3005c ustop/t_dnt2
+S 0x302b4 klatt/x_tap
+S 0x30378 klatt/tap2
+S 0x3043c d/x_tap
+S 0x30500 d/tap2
+W 0x305c4 x/g2_
+S 0x30984 r2/r2@
+S 0x30a48 r2/r2a
+S 0x30b0c r2/r2e
+S 0x30c10 r2/r2i
+S 0x30cd4 r2/r2o
+S 0x30d98 r2/r2u
+S 0x30e5c vowel/@_6
+S 0x30f60 vwl_en/@L
+S 0x31024 vowel/a_8
+S 0x31128 vowel/a#_3
+S 0x3122c vowel/ee_5
+S 0x31330 vowel/ii_2
+S 0x31434 vowel/ii_4
+S 0x31538 vowel/ii_7
+S 0x3163c vowel/0
+S 0x31740 vowel/V_2
+S 0x31844 vowel/uu
+S 0x31948 vowel/aa_2
+S 0x31acc vowel/3_en
+S 0x31c10 w/wi2
+S 0x31d14 vowel/i_en
+S 0x31e58 vowel/oo_en
+S 0x31f9c vwl_en/u_L
+S 0x320e0 vdiph2/uw_2
+S 0x32224 vdiph/au
+S 0x323a8 vdiph/@u_en
+S 0x3252c vdiph/ai_2
+S 0x326f0 vdiph/ooi
+S 0x328b4 vdiph2/ii@
+S 0x32a38 vdiph2/8@
+S 0x32b7c vdiph2/uu@
+S 0x32d00 vwl_en/aI@
+S 0x32ec4 vwl_en/aU@
+S 0x33048 vowelr/V_r
+S 0x3318c vowelr/V3_r
+S 0x332d0 vnasal/aa_n2
+S 0x33414 vnasal/oo_n2
+S 0x33558 vowel/@_3
+S 0x3361c vowel/@_fr
+S 0x336e0 vowel/ee
+S 0x337e4 vowel/ii
+S 0x338e8 vowel/e_2
+S 0x339ec vowel/0_2
+S 0x33af0 vowel/o-_2
+S 0x33bf4 vowel/aa_5
+S 0x33d38 vowel/3_2
+S 0x33e7c vowel/oo_1
+S 0x33fc0 vwl_en_n/O@
+S 0x340c4 vdiph2/uw_4
+S 0x34208 vdiph/eeu_3
+S 0x3434c vdiph/ae_2
+S 0x344d0 vdiph2/ee@
+S 0x34614 vdiph2/i@
+S 0x347d8 vwl_en_us/3_us
+S 0x348dc vowel/@_4
+S 0x349a0 vowel/@_low2
+S 0x34a64 vnasal/ee_n2
+S 0x34ba8 vwl_en_us/a
+S 0x34cac vwl_en_us/ee
+S 0x34db0 vowel/ii#_3
+S 0x34eb4 vowel/ii#
+S 0x34fb8 vowel/ii_final
+S 0x350bc vowel/aa_8
+S 0x351c0 vowel/V_6
+S 0x352c4 vowel/8_2
+S 0x353c8 vwl_en_us/ar
+S 0x3554c vwl_en_us/3_us2
+S 0x35690 vwl_en_us/oor
+S 0x35814 vowel/0_3
+S 0x35918 vwl_en_us/or
+S 0x35a5c vowel/aa#
+S 0x35b60 vdiph2/uw_6
+S 0x35ca4 vdiph/aoo
+S 0x35de8 vdiph/8u
+S 0x35f2c vdiph/aae
+S 0x360b0 vdiph2/ei_4
+S 0x361f4 vdiph/ooi_3
+S 0x36378 vwl_en_us/er
+S 0x364fc vwl_en_us/ir
+S 0x36680 vwl_en_us/ur
+S 0x367c4 vwl_en_us/ai@
+S 0x36948 vwl_en_us/ai3
+S 0x36b0c vwl_en_us/aU@
+S 0x36cd0 vowel/V
+S 0x36dd4 vowel/a_3
+S 0x36ed8 vowel/e_e
+S 0x36fdc vowel/e#
+S 0x370e0 vowel/e_5
+S 0x371e4 vowel/oo_2
+S 0x372e8 vowel/V_4
+S 0x373ec vowel/u#_4
+S 0x374f0 vowelr/aa_r
+S 0x376b4 vowelr/e_r
+S 0x37838 vowel/i_5
+S 0x3793c vowelr/oo_r
+S 0x37a40 vowel/u#
+S 0x37b44 vdiph/au#
+S 0x37c88 vowel/o_3
+S 0x37dcc vwl_en/aI@_2
+S 0x37f50 vdiph/ai_7
+S 0x380d4 vdiph/0i_2
+S 0x38258 vdiph2/e@
+S 0x3839c vowelr/i_r
+S 0x384e0 vdiph2/u#@
+S 0x38624 vwl_en/@L_2
+S 0x38728 vowel/@_low
+S 0x387ec vowel/&
+S 0x388f0 vowel/e_mid
+S 0x389f4 vowel/V_3
+S 0x38af8 vowel/o-_3
+S 0x38bfc vwl_en_rp/aa
+S 0x38d40 vowel/3_3
+S 0x38e84 vowel/uu#_2
+S 0x38f88 vdiph/au_3
+S 0x3910c vdiph/@u_2
+S 0x39250 vdiph/ai_6
+S 0x39414 vdiph2/ei_2
+S 0x39558 vdiph2/ee@_2
+S 0x3969c vwl_en_rp/i@
+S 0x39820 vowel/o_mid
+S 0x39924 vwl_en_rp/aU@
+S 0x39aa8 vowel/ii_6
+S 0x39b6c vdiph2/ei_3
+S 0x39cb0 vdiph/@u
+S 0x39df4 vdiph/Vu_2
+S 0x39f78 vdiph/@i_3
+S 0x3a0bc vdiph2/i@_2
+S 0x3a240 vwl_en/ooi@
+S 0x3a404 vowel/@_fnt
+S 0x3a508 vowel/uu_bck
+S 0x3a60c vowel/i_fnt
+S 0x3a710 vdiph2/o_oo
+S 0x3a854 vdiph/aau_2
+S 0x3a998 vdiph2/ie
+S 0x3aadc vwl_af/r@
+S 0x3aba0 vwl_af/@
+S 0x3ac64 vowel/e_mid2
+S 0x3ad68 vwl_af/I
+S 0x3ae2c vowel/oo_3
+S 0x3aef0 vowel/oe
+S 0x3aff4 vowel/uu_3
+S 0x3b0b8 l/L_eL_af
+S 0x3b17c vowel/ee_3
+S 0x3b240 vowel/aa_3
+S 0x3b344 vdiph/i@_2
+S 0x3b4c8 vowel/i_3
+S 0x3b5cc vdiph2/o@
+S 0x3b750 vowel/y_3
+S 0x3b854 vdiph2/iu_3
+S 0x3ba18 vdiph/Vu
+S 0x3bb9c vdiph/ai_4
+S 0x3bd20 vdiph/aai_2
+S 0x3bee4 vdiph/@i_2
+S 0x3c028 vdiph/ooi_2
+S 0x3c1ec vdiph/oi_2
+S 0x3c3b0 vdiph/ui_2
+S 0x3c534 vdiph/y#y_2
+S 0x3c6b8 vdiph2/y#@
+S 0x3c7fc vnasal/aa_n3
+S 0x3c940 vnasal/e_n
+S 0x3ca44 vnasal/o_n2
+W 0x3cb88 ufric/x2
+S 0x3d4e0 vowel/ee_2
+S 0x3d5e4 vowel/ii_3
+S 0x3d6e8 vowel/i#
+S 0x3d7ec vowel/o_2
+S 0x3d930 vdiph2/iu_4
+S 0x3da74 vdiph/ui_3
+S 0x3dbf8 vowel/a_4
+S 0x3dcfc vdiph/@u_3
+S 0x3de80 vdiph2/u@
+S 0x3e004 vowel/aa_6
+S 0x3e148 vowel/i_2
+S 0x3e24c vdiph/aau_6
+S 0x3e3d0 vdiph/ai_5
+S 0x3e514 vowel/e_8
+S 0x3e618 vowel/yy_4
+S 0x3e71c l/l_3
+S 0x3e7a0 j/_j_short
+S 0x3e824 vdiph2/i@_3
+S 0x3e9a8 vwl_de/uu_@
+S 0x3eaec vnasal/aa_n4
+Q 0x3ec30 de
+S 0x3ec40 vdiph/eei_2
+S 0x3ed84 vowel/i_4
+S 0x3ee88 vowel/aa_9
+S 0x3ef8c vowel/u_2
+S 0x3f090 vowel/uu_4
+S 0x3f194 vdiph/aai_3
+S 0x3f318 vdiph/&i
+S 0x3f45c vdiph/y#i
+S 0x3f5a0 vdiph/ui_4
+S 0x3f6e4 vdiph/yi
+S 0x3f828 vdiph/aau
+S 0x3f9ac vdiph/ou
+S 0x3faf0 vdiph/eu_2
+S 0x3fc34 vdiph2/iu_2
+S 0x3fdb8 vdiph/&y
+S 0x3fefc vdiph/eey
+S 0x40040 vdiph/y#y
+S 0x40184 vdiph2/iy
+S 0x402c8 vdiph2/uo
+S 0x4040c vdiph2/y-y#
+S 0x40550 r3/r_trill_short
+W 0x40654 h/hu_fi
+S 0x40f44 vowel/aa
+S 0x41048 vowel/e_7
+S 0x4114c vowel/ee#_2
+S 0x41250 vowel/i_8
+S 0x41354 vowel/i_7
+S 0x41458 vowel/i#_7
+S 0x4155c vowel/u_bck2
+S 0x41660 vowel/u_bck3
+S 0x41764 vowel/u_5
+S 0x41868 vowel/8_7
+S 0x4196c vowel/8_4
+S 0x41a70 vdiph/@i
+W 0x41bb4 ufric/s_pal
+S 0x42468 d/xd_pzd
+W 0x4252c x/d_pzd
+S 0x42940 vwl_fr/y2r
+S 0x429c4 vwl_fr/e_2r
+S 0x42a48 vwl_fr/aa2r
+S 0x42acc vwl_fr/ee2r
+S 0x42b90 vwl_fr/oo2r
+S 0x42c54 vwl_fr/@2r
+S 0x42cd8 vwl_fr/a2r
+S 0x42d5c vwl_fr/e2r
+S 0x42de0 vwl_fr/i2r
+S 0x42e64 vwl_fr/o2r
+S 0x42ee8 vwl_fr/u2r
+S 0x42f6c vwl_fr/re2
+S 0x42ff0 vwl_fr/r@2
+S 0x43074 vwl_fr/raa
+S 0x430f8 vwl_fr/ree
+S 0x4317c vwl_fr/ry
+S 0x43200 vwl_fr/rw
+S 0x43284 vwl_fr/roo
+S 0x43308 vwl_fr/rj
+S 0x4338c vwl_fr/r@
+S 0x43410 vwl_fr/ra
+S 0x43494 vwl_fr/re
+S 0x43518 vwl_fr/ri
+S 0x4359c vwl_fr/ro
+S 0x43620 vwl_fr/ru
+S 0x436a4 vwl_fr/r
+S 0x43728 vwl_fr/trr
+S 0x437ec vwl_fr/rr
+S 0x43870 vwl_fr/r_@
+S 0x438f4 vwl_fr/r_a
+S 0x43978 vwl_fr/r_e
+S 0x439fc vwl_fr/r_i
+S 0x43a80 vwl_fr/r_o
+S 0x43b04 vwl_fr/r_u
+S 0x43b88 vwl_fr/r_y
+S 0x43c0c vwl_fr/r_n
+S 0x43cd0 vwl_fr/r_
+S 0x43d54 vwl_fr/tr
+S 0x43e58 vwl_fr/br
+S 0x43f5c vwl_fr/lo
+S 0x43fe0 l/l_y
+S 0x44064 vowel/@_hgh
+S 0x44128 vowel/a_7
+S 0x4422c vwl_fr/j
+S 0x44330 vowel/o_8
+S 0x44474 vowel/o_mid2
+S 0x44578 vwl_fr/wa
+S 0x4463c vnasal/W_n
+S 0x44780 vnasal/o_n4
+S 0x448c4 b/xbr
+S 0x44988 b/br
+S 0x44a0c d/xdr
+S 0x44ad0 g/xgr
+S 0x44b94 g/gr
+W 0x44c58 x/g
+S 0x44f18 n/n_long_
+W 0x44fdc ustop/t_short_
+Q 0x45268 fr
+S 0x4531c vnasal/ee_n
+S 0x45460 vowel/yy
+S 0x45564 vdiph/ae
+S 0x456a8 vwl_fr/@R2
+S 0x457ac vowel/o_6
+S 0x458b0 vowel/a#_2
+S 0x459b4 vowel/a#_4
+S 0x45ab8 vdiph/y#y_3
+S 0x45bbc vdiph/ou_4
+S 0x45d00 vdiph2/yu
+S 0x45e84 voc/Q_less
+W 0x45f48 vocw/Q2
+S 0x46814 vowel/@_bck
+S 0x46918 vdiph/ee-e
+S 0x46a5c vowel/a_5
+S 0x46b60 vnasal/i_n2
+S 0x46c64 vnasal/ii_n
+S 0x46d68 vnasal/&_n
+S 0x46e6c vnasal/V_n
+S 0x46f70 vnasal/o_n
+S 0x470b4 vnasal/u_n
+S 0x471b8 vdiph/aau_3
+S 0x4733c d/xd3
+W 0x47400 ustop/th_rfx2
+W 0x47a04 ustop/tsh_unasp
+S 0x47ec4 g2/xg
+W 0x47f88 ustop/percus02
+S 0x482b8 vowel/i_6
+S 0x483bc vowel/&_2
+S 0x484c0 vowel/oo_5
+W 0x485c4 ustop/tsh_unasp2
+S 0x48a0c vdiph/aai
+S 0x48b90 vdiph/Vi
+E 0x48d14 envelope/p_512
+S 0x48d94 vowel/ii_5
+S 0x48e98 vowel/u_6
+S 0x48f9c vowel/u#_3
+S 0x490a0 vdiph/ai_8
+S 0x49224 voc/murmur1
+S 0x49368 vowel/y#_2
+S 0x4946c vowel/e_3
+S 0x49570 vwl_ru/ee
+S 0x496b4 vdiph2/ea
+S 0x497f8 vdiph2/uaa
+S 0x4997c vdiph2/ie_2
+S 0x49ac0 vdiph/ou_2
+S 0x49c04 vdiph/eei_3
+W 0x49d48 ustop/ts2
+S 0x4a218 vowel/ee#
+S 0x4a31c vowel/ii#_2
+S 0x4a420 vnasal/ee_u_n
+S 0x4a5a4 vnasal/oo_n3
+S 0x4a728 vowel/ee_6
+W 0x4a7ec r3/rz_cs
+S 0x4b298 voc/zh_2
+S 0x4b35c vdiph/oou
+W 0x4b4a0 ufric/sh3
+W 0x4be34 ustop/tsh2
+W 0x4c540 ustop/ts_pzd3
+S 0x4cbc0 dzh/dzh2
+W 0x4cc84 ustop/t_sr
+S 0x4cfbc d/d_dnt
+W 0x4d080 ufric/ch_sr
+W 0x4dc60 ufric/x_sr
+W 0x4e4e0 ufric/sh_pzd2
+W 0x4f030 ustop/ts_sr
+W 0x4f7ec ustop/tsh_sr
+W 0x50104 x/g3
+S 0x502ec vwl_ro/mi
+S 0x50430 vwl_ru/ii-
+S 0x504f4 vwl_ru/ii
+S 0x505f8 vwl_ru/ii#
+S 0x506bc vwl_ru/i#
+S 0x507c0 vwl_ru/e
+S 0x508c4 vwl_ru/E#
+S 0x509c8 vwl_ru/E@
+S 0x50acc vwl_ru/o
+S 0x50bd0 vwl_ru/oo
+S 0x50c94 vwl_ru/u
+S 0x50d98 vwl_ru/u#
+S 0x50edc vwl_ru/u#u
+S 0x51020 vwl_ru/8
+S 0x510e4 vwl_ru/ju
+S 0x511e8 vwl_ru/ja
+S 0x5136c vwl_ru/a
+S 0x51470 vwl_ru/aa
+S 0x51574 r3/r_ru2
+W 0x51678 r3/r_ru
+S 0x5197c vowel/y_2
+S 0x51ac0 vdiph/eeu_2
+S 0x51c04 voc/v2
+S 0x51cc8 vowel/a_6
+S 0x51dcc vnasal/i_n
+S 0x51ed0 vnasal/a#_n2
+S 0x51fd4 vnasal/a#_n
+S 0x520d8 vnasal/a#u_n
+S 0x5221c vnasal/oi_n
+S 0x523e0 vdiph/0i
+S 0x525a4 vdiph/eeu
+S 0x526e8 vowel/i#_5
+S 0x527ec vwl_fr/@R
+S 0x528f0 vwl_ro/li
+S 0x529f4 vwl_ro/ni
+S 0x52af8 vwl_ro/ii-
+S 0x52bbc vowel/o-_4
+S 0x52cc0 vdiph/ii
+S 0x52e84 vdiph/i#i
+S 0x52fc8 vdiph2/uw_3
+S 0x5310c vdiph2/eo
+S 0x53290 vdiph2/e_u
+S 0x533d4 vdiph2/oa
+S 0x53518 d/tap_i
+S 0x535dc d/tap
+W 0x536a0 ustop/t_unasp2
+S 0x537ac vowel/y_5
+S 0x538f0 vowel/yy_3
+S 0x539f4 vowel/u#_2
+S 0x53af8 vowel/oe_4
+S 0x53bbc vowel/aa_4
+W 0x53cc0 ufric/sx_sv
+S 0x54508 vowel/y_4
+S 0x5460c vowel/oe_2
+S 0x54710 vwl_no/y#
+S 0x54814 vwl_no/&
+S 0x54918 vwl_no/u#
+S 0x54a1c vwl_no/u#2
+S 0x54b60 vdiph/ai_3
+S 0x54ca4 vwl_no/y#y
+S 0x54de8 vwl_no/au-
+S 0x54fac vowel/y##
+S 0x550b0 vowel/y#_3
+S 0x551b4 vdiph/ou_3
+S 0x552b8 vdiph/y#i_2
+S 0x553fc m/m#_
+S 0x55500 n/n#_
+S 0x55604 n^/n^#_
+S 0x55708 nn/nn#_
+W 0x5580c ufric/tl#
+S 0x56174 r3/r#_
+E 0x561f8 envelope/p_level
+E 0x56278 envelope/p_fall
+E 0x562f8 envelope/p_rise
+E 0x56378 envelope/p_fallrise
+E 0x563f8 envelope/p_214
+E 0x56478 envelope/vi_5amp
+E 0x564f8 envelope/vi_6amp
+S 0x56578 vowel/u#_5
+S 0x5667c vowel/@_2
+S 0x56780 vdiph/&i_2
+S 0x568c4 vdiph/ooi_4
+S 0x56a08 vdiph/u-i
+S 0x56b4c vdiph/aau_4
+S 0x56cd0 vdiph2/ii@_3
+S 0x56e54 vnasal/&u_n
+S 0x56f98 vietnam/oe
+S 0x570dc vietnam/ie_2
+S 0x57220 vowel/u_3
+W 0x57324 vietnam/_c
+S 0x574f0 l/l_vi
+W 0x575f4 vietnam/th
+W 0x57be4 vietnam/tr
+W 0x57ed4 vietnam/dd
+W 0x58478 vietnam/ch
+E 0x589d4 envelope/i_risefall
+S 0x58a54 vietnam/a
+S 0x58b98 vowel/o_5
+S 0x58c9c vwl_zh/ang
+S 0x58ea0 vwl_zh/aang
+S 0x590e4 vdiph/au_2
+S 0x59268 vwl_zh/eng
+S 0x5946c vwl_zh/ing
+S 0x596b0 vwl_zh/ng
+S 0x597f4 vwl_zh/oeng
+S 0x599b8 vwl_zh/ong
+S 0x59b3c vwl_zh/ung
+S 0x59cc0 vowel/8_3
+S 0x59dc4 nn/nn2_
+W 0x59e88 ustop/k_unasp_
+W 0x5a144 ustop/tsh_pzd_unasp
+W 0x5a994 ustop/tsh_pzd
+W 0x5b4d4 ustop/ts_unasp
+W 0x5bd4c ustop/ts_rfx_unasp
+W 0x5c938 ustop/ts_rfx
+S 0x5d618 vwl_zh/a_n
+S 0x5d71c vwl_zh/aau
+S 0x5d860 vowel/i#_6
+S 0x5d964 vwl_zh/iaa
+S 0x5daa8 vwl_zh/iaau
+S 0x5dc2c vwl_zh/ie
+S 0x5dd70 vdiph2/iioo
+S 0x5deb4 vwl_zh/iou
+S 0x5e038 vowel/8
+S 0x5e13c vwl_zh/uaa
+S 0x5e280 vwl_zh/uai
+S 0x5e404 vwl_zh/uei
+S 0x5e588 vwl_zh/uo
+S 0x5e70c vwl_zh/y&
+S 0x5e850 vwl_zh/yee
+S 0x5e994 vdiph2/y@
+S 0x5ead8 vowel/o_4
+W 0x5ebdc ustop/t_hard
+S 0x5ee1c vowel/u#_7
+S 0x5ef20 vowel/8_5
+S 0x5f024 vowel/o_7
+S 0x5f128 vowel/uu#
+S 0x5f22c vowel/8_6
+S 0x5f330 vowel/ee_4
+S 0x5f434 vdiph2/ye
+S 0x5f578 l/l_front_
+S 0x5f6bc l/l_front
+S 0x5f7c0 l/l_4
+S 0x5f884 r/a_
+S 0x5f948 r/aa
+W 0x5fa4c ustop/k_asp_u
+E 0x6027c envelope/i_risefall2
+W 0x602fc ustop/ki_ejc
+W 0x60708 ufric/tlh
+S 0x61c24 vowel/e_6
+S 0x61d28 vowel/&_3
+W 0x61e2c ustop/k_ejc
+S 0x625dc d/dr2
+S 0x626a0 vdiph/@i_4
+S 0x62824 vnasal/ai_n
+S 0x62968 vdiph/a#u
+S 0x62aec vnasal/au_n
+S 0x62c30 vwl_tn/r@
+S 0x62cf4 vwl_tn/@
+S 0x62db8 vwl_tn/I
+S 0x62e7c vdiph2/ii@_2
+S 0x63000 vowel/ii_8
+S 0x63104 vowel/y#_4
+W 0x63208 ustop/t_unasp
diff --git a/navit/support/espeak/espeak-data/phonindex b/navit/support/espeak/espeak-data/phonindex
index 8bed38930..ac5d40fba 100644
--- a/navit/support/espeak/espeak-data/phonindex
+++ b/navit/support/espeak/espeak-data/phonindex
Binary files differ
diff --git a/navit/support/espeak/espeak-data/phontab b/navit/support/espeak/espeak-data/phontab
index c0d3a751d..97fdf16be 100644
--- a/navit/support/espeak/espeak-data/phontab
+++ b/navit/support/espeak/espeak-data/phontab
Binary files differ
diff --git a/navit/support/espeak/espeak-data/pl_dict b/navit/support/espeak/espeak-data/pl_dict
index e46b00b04..192f868bf 100644
--- a/navit/support/espeak/espeak-data/pl_dict
+++ b/navit/support/espeak/espeak-data/pl_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/pt_dict b/navit/support/espeak/espeak-data/pt_dict
index 9ba2a7a78..49d51ceac 100644
--- a/navit/support/espeak/espeak-data/pt_dict
+++ b/navit/support/espeak/espeak-data/pt_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ro_dict b/navit/support/espeak/espeak-data/ro_dict
index b0a72f406..c4d6eacdc 100644
--- a/navit/support/espeak/espeak-data/ro_dict
+++ b/navit/support/espeak/espeak-data/ro_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ru_dict b/navit/support/espeak/espeak-data/ru_dict
index 52d652ccd..edcfe895a 100644
--- a/navit/support/espeak/espeak-data/ru_dict
+++ b/navit/support/espeak/espeak-data/ru_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/si_dict b/navit/support/espeak/espeak-data/si_dict
new file mode 100644
index 000000000..97c7bd12f
--- /dev/null
+++ b/navit/support/espeak/espeak-data/si_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/sk_dict b/navit/support/espeak/espeak-data/sk_dict
index a5d7e7c75..9421432c5 100644
--- a/navit/support/espeak/espeak-data/sk_dict
+++ b/navit/support/espeak/espeak-data/sk_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/sl_dict b/navit/support/espeak/espeak-data/sl_dict
new file mode 100644
index 000000000..a0262a18c
--- /dev/null
+++ b/navit/support/espeak/espeak-data/sl_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/sq_dict b/navit/support/espeak/espeak-data/sq_dict
index aea3d0625..9eb51177f 100644
--- a/navit/support/espeak/espeak-data/sq_dict
+++ b/navit/support/espeak/espeak-data/sq_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/sv_dict b/navit/support/espeak/espeak-data/sv_dict
index 1327d8d0c..ae21dd5d5 100644
--- a/navit/support/espeak/espeak-data/sv_dict
+++ b/navit/support/espeak/espeak-data/sv_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/sw_dict b/navit/support/espeak/espeak-data/sw_dict
index 77e2fd233..0b74a9363 100644
--- a/navit/support/espeak/espeak-data/sw_dict
+++ b/navit/support/espeak/espeak-data/sw_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ta_dict b/navit/support/espeak/espeak-data/ta_dict
index 214e2f4da..033ec9367 100644
--- a/navit/support/espeak/espeak-data/ta_dict
+++ b/navit/support/espeak/espeak-data/ta_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/te_dict b/navit/support/espeak/espeak-data/te_dict
new file mode 100644
index 000000000..cb502f0df
--- /dev/null
+++ b/navit/support/espeak/espeak-data/te_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/tr_dict b/navit/support/espeak/espeak-data/tr_dict
index a3f685047..3bc6fa4ba 100644
--- a/navit/support/espeak/espeak-data/tr_dict
+++ b/navit/support/espeak/espeak-data/tr_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ur_dict b/navit/support/espeak/espeak-data/ur_dict
new file mode 100644
index 000000000..b74d901f7
--- /dev/null
+++ b/navit/support/espeak/espeak-data/ur_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/vi_dict b/navit/support/espeak/espeak-data/vi_dict
index 24a645a03..c2aee44b6 100644
--- a/navit/support/espeak/espeak-data/vi_dict
+++ b/navit/support/espeak/espeak-data/vi_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/voices/!v/f1 b/navit/support/espeak/espeak-data/voices/!v/f1
index 13664a34f..8f03a73a4 100755
--- a/navit/support/espeak/espeak-data/voices/!v/f1
+++ b/navit/support/espeak/espeak-data/voices/!v/f1
@@ -1,9 +1,9 @@
language variant
name female1
-gender female
+gender female 70
-pitch 145 200
-flutter 7
+pitch 140 200
+flutter 8
roughness 4
formant 0 115 80 150
formant 1 120 80 180
@@ -15,4 +15,4 @@ formant 6 105 80 150
formant 7 110 70 150
formant 8 110 70 150
-stressAdd -10 -10 -20 -20 0 0 40 70
+stressAdd -10 -10 -20 -20 0 0 40 60
diff --git a/navit/support/espeak/espeak-data/voices/!v/f2 b/navit/support/espeak/espeak-data/voices/!v/f2
index e92946707..4122d96b3 100755
--- a/navit/support/espeak/espeak-data/voices/!v/f2
+++ b/navit/support/espeak/espeak-data/voices/!v/f2
@@ -18,3 +18,4 @@ formant 8 110 70 150
stressAdd 0 0 -10 -10 0 0 10 40
breath 0 2 3 3 3 3 3 2
echo 140 10
+consonants 125 125
diff --git a/navit/support/espeak/espeak-data/voices/!v/f3 b/navit/support/espeak/espeak-data/voices/!v/f3
index 92a158281..92a158281 100644..100755
--- a/navit/support/espeak/espeak-data/voices/!v/f3
+++ b/navit/support/espeak/espeak-data/voices/!v/f3
diff --git a/navit/support/espeak/espeak-data/voices/!v/f4 b/navit/support/espeak/espeak-data/voices/!v/f4
index 52c5ac935..52c5ac935 100644..100755
--- a/navit/support/espeak/espeak-data/voices/!v/f4
+++ b/navit/support/espeak/espeak-data/voices/!v/f4
diff --git a/navit/support/espeak/espeak-data/voices/!v/f5 b/navit/support/espeak/espeak-data/voices/!v/f5
new file mode 100755
index 000000000..f43b093ec
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/!v/f5
@@ -0,0 +1,23 @@
+language variant
+name female5
+gender female
+
+pitch 160 228
+roughness 0
+
+formant 0 105 80 150
+formant 1 110 80 160
+formant 2 110 70 150
+formant 3 110 70 150
+formant 4 115 80 200
+formant 5 115 80 100
+formant 6 110 70 150
+formant 7 110 70 100
+formant 8 110 70 150
+
+stressAdd 0 0 -10 -10 0 0 10 40
+breath 0 4 6 6 6 6 0 10
+echo 140 10
+voicing 75
+consonants 150 150
+breathw 150 150 200 200 400 400
diff --git a/navit/support/espeak/espeak-data/voices/!v/fast b/navit/support/espeak/espeak-data/voices/!v/fast
deleted file mode 100755
index 30441d7e2..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/fast
+++ /dev/null
@@ -1,11 +0,0 @@
-language variant
-name fast_test
-
-// Try decreasing these values to make eSpeak's fastest speed faster.
-// The 3 parameters affect:
-// pauses,
-// unvoiced consonants,
-// vowels and voiced consonants
-// The default values are: fast 15 72 110
-
-fast_test 15 72 110
diff --git a/navit/support/espeak/espeak-data/voices/!v/klatt b/navit/support/espeak/espeak-data/voices/!v/klatt
new file mode 100755
index 000000000..b739a86e4
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/!v/klatt
@@ -0,0 +1,4 @@
+language variant
+name klatt
+klatt 1
+
diff --git a/navit/support/espeak/espeak-data/voices/!v/klatt2 b/navit/support/espeak/espeak-data/voices/!v/klatt2
new file mode 100755
index 000000000..01477be54
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/!v/klatt2
@@ -0,0 +1,4 @@
+language variant
+name klatt2
+klatt 2
+
diff --git a/navit/support/espeak/espeak-data/voices/!v/klatt3 b/navit/support/espeak/espeak-data/voices/!v/klatt3
new file mode 100755
index 000000000..b1a874be6
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/!v/klatt3
@@ -0,0 +1,4 @@
+language variant
+name klatt3
+klatt 3
+
diff --git a/navit/support/espeak/espeak-data/voices/!v/klatt4 b/navit/support/espeak/espeak-data/voices/!v/klatt4
new file mode 100644
index 000000000..65278087c
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/!v/klatt4
@@ -0,0 +1,4 @@
+language variant
+name klatt4
+klatt 4
+
diff --git a/navit/support/espeak/espeak-data/voices/!v/m1 b/navit/support/espeak/espeak-data/voices/!v/m1
index 57603a885..4cc9a00bf 100755
--- a/navit/support/espeak/espeak-data/voices/!v/m1
+++ b/navit/support/espeak/espeak-data/voices/!v/m1
@@ -2,18 +2,19 @@ language variant
name male1
gender male 70
-pitch 74 109
-flutter 4
+pitch 75 109
+flutter 5
roughness 4
+consonants 80 100
-formant 0 98 95 100
-formant 1 97 95 100
+formant 0 98 100 100
+formant 1 97 100 100
formant 2 97 95 100
-formant 3 97 100 100
-formant 4 97 100 100
-formant 5 105 100 100
-formant 6 95 100 100
+formant 3 97 95 100
+formant 4 97 85 100
+formant 5 105 80 100
+formant 6 95 80 100
formant 7 100 100 100
formant 8 100 100 100
-stressAdd -10 -10 -20 -20 0 0 40 70
+//stressAdd -10 -10 -20 -20 0 0 40 70
diff --git a/navit/support/espeak/espeak-data/voices/!v/m2 b/navit/support/espeak/espeak-data/voices/!v/m2
index c234f4687..c234f4687 100644..100755
--- a/navit/support/espeak/espeak-data/voices/!v/m2
+++ b/navit/support/espeak/espeak-data/voices/!v/m2
diff --git a/navit/support/espeak/espeak-data/voices/!v/m3 b/navit/support/espeak/espeak-data/voices/!v/m3
index 581cd883f..00479dc35 100644..100755
--- a/navit/support/espeak/espeak-data/voices/!v/m3
+++ b/navit/support/espeak/espeak-data/voices/!v/m3
@@ -13,4 +13,5 @@ formant 6 100 100 100
formant 7 100 100 100
formant 8 100 100 100
+consonants 100
stressAdd 10 10 0 0 0 0 -30 -30
diff --git a/navit/support/espeak/espeak-data/voices/!v/m4 b/navit/support/espeak/espeak-data/voices/!v/m4
index 7199341c3..7199341c3 100644..100755
--- a/navit/support/espeak/espeak-data/voices/!v/m4
+++ b/navit/support/espeak/espeak-data/voices/!v/m4
diff --git a/navit/support/espeak/espeak-data/voices/!v/m7 b/navit/support/espeak/espeak-data/voices/!v/m7
index 9a8370622..11b49ed2a 100755
--- a/navit/support/espeak/espeak-data/voices/!v/m7
+++ b/navit/support/espeak/espeak-data/voices/!v/m7
@@ -1,18 +1,17 @@
-language variant
-gender male 35
-name male5
-
-formant 0 120 150 220
-
-formant 1 100 100 100
-formant 2 100 100 100
-formant 3 100 100 100
-
-formant 4 100 80 100
-formant 5 100 100 100
-
-formant 6 80 200 80
-formant 7 80 200 100
-
-pitch 80 118
-tone 600 150 255 50 100 100
+language variant
+name male7
+gender male
+
+pitch 75 125
+
+formant 0 100 125 100
+formant 1 100 90 80
+formant 2 100 70 90
+formant 3 100 60 90
+formant 4 100 60 90
+formant 5 75 50 90
+formant 6 90 50 100
+formant 7 100 50 100
+formant 8 100 50 100
+voicing 155
+
diff --git a/navit/support/espeak/espeak-data/voices/!v/whisperf b/navit/support/espeak/espeak-data/voices/!v/whisperf
new file mode 100755
index 000000000..f239e8a29
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/!v/whisperf
@@ -0,0 +1,24 @@
+language variant
+name female_whisper
+gender female
+
+pitch 160 220
+roughness 3
+
+formant 0 105 0 150
+formant 1 110 40 160
+formant 2 110 70 150
+formant 3 110 70 150
+formant 4 115 80 150
+formant 5 115 80 150
+formant 6 110 70 150
+formant 7 110 70 150
+formant 8 110 70 150
+
+stressAdd 0 0 -10 -10 0 0 10 40
+
+// whisper
+voicing 20
+breath 75 75 50 40 15 10
+breathw 150 150 200 200 400 400
+
diff --git a/navit/support/espeak/espeak-data/voices/asia/fa b/navit/support/espeak/espeak-data/voices/asia/fa
new file mode 100755
index 000000000..60ee250e8
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/fa
@@ -0,0 +1,3 @@
+name persian
+language fa
+
diff --git a/navit/support/espeak/espeak-data/voices/asia/fa-pin b/navit/support/espeak/espeak-data/voices/asia/fa-pin
new file mode 100755
index 000000000..f3adbfca4
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/fa-pin
@@ -0,0 +1,6 @@
+name persian-pinglish
+// Sometimes, Farsi speakers write Farsi words using English characters, particularly in Chat and SMS (texte messages).), called Pinglish
+language fa-pin
+dictrules 1
+phonemes fa
+
diff --git a/navit/support/espeak/espeak-data/voices/asia/hi b/navit/support/espeak/espeak-data/voices/asia/hi
new file mode 100755
index 000000000..2d41b07b3
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/hi
@@ -0,0 +1,3 @@
+name hindi
+language hi
+gender male
diff --git a/navit/support/espeak/espeak-data/voices/hy b/navit/support/espeak/espeak-data/voices/asia/hy
index 6c65e3c68..6c65e3c68 100644..100755
--- a/navit/support/espeak/espeak-data/voices/hy
+++ b/navit/support/espeak/espeak-data/voices/asia/hy
diff --git a/navit/support/espeak/espeak-data/voices/hy-west b/navit/support/espeak/espeak-data/voices/asia/hy-west
index 46317618d..85b3f75b6 100644..100755
--- a/navit/support/espeak/espeak-data/voices/hy-west
+++ b/navit/support/espeak/espeak-data/voices/asia/hy-west
@@ -1,19 +1,22 @@
name armenian-west
-language hy
+language hy-west
+language hy 8
gender male
+dictrules 1
+
// change consonants for West Armenian pronunciation
replace 00 b p#
replace 00 d t#
replace 00 dz ts#
-replace 00 dZ tS
+replace 00 dZ tS#
replace 00 g k#
replace 00 p b
replace 00 t d
replace 00 ts dz
-replace 00 c dZ
+replace 00 tS dZ
replace 00 k g
-replace 00 ** R // ??
-replace 00 r R
+replace 00 R2 R // ??
+
diff --git a/navit/support/espeak/espeak-data/voices/id b/navit/support/espeak/espeak-data/voices/asia/id
index ce800f70b..f35b116af 100755
--- a/navit/support/espeak/espeak-data/voices/id
+++ b/navit/support/espeak/espeak-data/voices/asia/id
@@ -1,4 +1,4 @@
-name indonesian-test
+name indonesian
language id
gender male
diff --git a/navit/support/espeak/espeak-data/voices/asia/ka b/navit/support/espeak/espeak-data/voices/asia/ka
new file mode 100755
index 000000000..6f748b7f6
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/ka
@@ -0,0 +1,2 @@
+name georgian
+language ka
diff --git a/navit/support/espeak/espeak-data/voices/asia/kn b/navit/support/espeak/espeak-data/voices/asia/kn
new file mode 100755
index 000000000..ced1b1fa9
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/kn
@@ -0,0 +1,5 @@
+name kannada
+language kn
+
+intonation 2
+//consonants 80
diff --git a/navit/support/espeak/espeak-data/voices/ku b/navit/support/espeak/espeak-data/voices/asia/ku
index 536957cb8..536957cb8 100755
--- a/navit/support/espeak/espeak-data/voices/ku
+++ b/navit/support/espeak/espeak-data/voices/asia/ku
diff --git a/navit/support/espeak/espeak-data/voices/asia/ml b/navit/support/espeak/espeak-data/voices/asia/ml
new file mode 100755
index 000000000..45bdf8528
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/ml
@@ -0,0 +1,6 @@
+name malayalam
+language ml
+gender male
+
+intonation 2
+//consonants 80
diff --git a/navit/support/espeak/espeak-data/voices/asia/ms b/navit/support/espeak/espeak-data/voices/asia/ms
new file mode 100755
index 000000000..90a38a37c
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/ms
@@ -0,0 +1,17 @@
+// Last updated: 14 October 2010, Jason Ong (jason@portalgroove.com)
+name malay
+language ms
+gender male
+phonemes id
+
+translator id
+
+stressLength 160 200 180 180 0 0 220 240
+stressAmp 16 18 18 18 0 0 22 21
+intonation 3 // Less intonation, and comma does not raise the pitch.
+
+// Nuance - Peninsula Malaysia
+// replace 3 a @ // change 'saya' to 'saye'
+ // (only the last phoneme of a word, only in unstressed syllables)
+
+consonants 80 80
diff --git a/navit/support/espeak/espeak-data/voices/asia/ne b/navit/support/espeak/espeak-data/voices/asia/ne
new file mode 100755
index 000000000..fc8295329
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/ne
@@ -0,0 +1,5 @@
+name nepali
+language ne
+gender male
+
+dictrules 1
diff --git a/navit/support/espeak/espeak-data/voices/asia/pa b/navit/support/espeak/espeak-data/voices/asia/pa
new file mode 100755
index 000000000..4cd585d1d
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/pa
@@ -0,0 +1,2 @@
+name punjabi
+language pa
diff --git a/navit/support/espeak/espeak-data/voices/ta b/navit/support/espeak/espeak-data/voices/asia/ta
index 8848d6820..8848d6820 100755
--- a/navit/support/espeak/espeak-data/voices/ta
+++ b/navit/support/espeak/espeak-data/voices/asia/ta
diff --git a/navit/support/espeak/espeak-data/voices/tr b/navit/support/espeak/espeak-data/voices/asia/tr
index 4f1904e51..4f1904e51 100755
--- a/navit/support/espeak/espeak-data/voices/tr
+++ b/navit/support/espeak/espeak-data/voices/asia/tr
diff --git a/navit/support/espeak/espeak-data/voices/vi b/navit/support/espeak/espeak-data/voices/asia/vi
index 1596e3c77..dbd23b566 100755
--- a/navit/support/espeak/espeak-data/voices/vi
+++ b/navit/support/espeak/espeak-data/voices/asia/vi
@@ -1,4 +1,4 @@
-name vietnam-test
+name vietnam
language vi
gender male
diff --git a/navit/support/espeak/espeak-data/voices/asia/vi-hue b/navit/support/espeak/espeak-data/voices/asia/vi-hue
new file mode 100755
index 000000000..83849f897
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/vi-hue
@@ -0,0 +1,12 @@
+name vietnam_hue
+language vi-hue
+phonemes vi-hue
+dictrules 1
+gender male
+
+words 1
+pitch 82 118 //80 118
+//breath 75 75 60 40 15 10
+ //breathw 150 150 200 200 400 400
+ voicing 90 //18
+ flutter 20
diff --git a/navit/support/espeak/espeak-data/voices/asia/vi-sgn b/navit/support/espeak/espeak-data/voices/asia/vi-sgn
new file mode 100755
index 000000000..07c4a12e2
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/asia/vi-sgn
@@ -0,0 +1,12 @@
+name vietnam_sgn
+language vi-sgn
+phonemes vi-sgn
+dictrules 2
+gender male
+
+words 1
+pitch 82 118 //80 118
+//breath 75 75 60 40 15 10
+ //breathw 150 150 200 200 400 400
+ voicing 90 //18
+ flutter 20
diff --git a/navit/support/espeak/espeak-data/voices/zh b/navit/support/espeak/espeak-data/voices/asia/zh
index 03edde41d..559a64030 100644..100755
--- a/navit/support/espeak/espeak-data/voices/zh
+++ b/navit/support/espeak/espeak-data/voices/asia/zh
@@ -4,6 +4,8 @@ gender male
words 1
pitch 80 118
+dict_min 100000
+
//for some dialects
//[en]: replace ng with n
diff --git a/navit/support/espeak/espeak-data/voices/zh-yue b/navit/support/espeak/espeak-data/voices/asia/zh-yue
index ba8723264..8e2b8a7ed 100755
--- a/navit/support/espeak/espeak-data/voices/zh-yue
+++ b/navit/support/espeak/espeak-data/voices/asia/zh-yue
@@ -1,4 +1,4 @@
-name cantonese-test
+name cantonese
language zh-yue
language yue
language zhy
@@ -12,3 +12,4 @@ gender male
dictrules 1
words 1
+dict_min 10000
diff --git a/navit/support/espeak/espeak-data/voices/da b/navit/support/espeak/espeak-data/voices/da
deleted file mode 100755
index ec9936cc2..000000000
--- a/navit/support/espeak/espeak-data/voices/da
+++ /dev/null
@@ -1,3 +0,0 @@
-name danish-test
-language da
-gender male
diff --git a/navit/support/espeak/espeak-data/voices/en/en b/navit/support/espeak/espeak-data/voices/en
index 43e2ca1fc..84d12dd8c 100755
--- a/navit/support/espeak/espeak-data/voices/en/en
+++ b/navit/support/espeak/espeak-data/voices/en
@@ -1,9 +1,9 @@
name english
+language en-gb 2
language en-uk 2
language en 2
gender male
-//pitch 80 117
+//pitch 80 118
-replace 03 I i
-replace 03 I2 i
+tunes s1 c1 q1 e1
diff --git a/navit/support/espeak/espeak-data/voices/en/en-us b/navit/support/espeak/espeak-data/voices/en-us
index c2656b28c..6846aa8b7 100755
--- a/navit/support/espeak/espeak-data/voices/en/en-us
+++ b/navit/support/espeak/espeak-data/voices/en-us
@@ -5,13 +5,13 @@ language en-r
language en 3
gender male
-phonemes en_us
+phonemes en-us
dictrules 3 6
-option 12 1 // reduce [t]
+option reduce_t 1
-stressLength 145 125 170 170 0 0 265 290
-stressAmp 17 16 20 20 20 22 22 20
+stressLength 140 120 190 170 0 0 255 300
+stressAmp 17 16 19 19 19 19 21 19
replace 03 I i
replace 03 I2 i
-replace 03 @ @/
+
diff --git a/navit/support/espeak/espeak-data/voices/es-la b/navit/support/espeak/espeak-data/voices/es-la
index c326c46f5..4fbacd1bc 100755
--- a/navit/support/espeak/espeak-data/voices/es-la
+++ b/navit/support/espeak/espeak-data/voices/es-la
@@ -1,11 +1,12 @@
-name spanish-latin-american
+name spanish-latin-am
language es-la
language es-mx 6
+language es 6
gender male
-phonemes es_la
+phonemes es-la
dictrules 2
intonation 2
-stressLength 170 200 180 180 0 0 250 280
+stressLength 170 200 230 180 0 0 250 280
replace 00 T s
diff --git a/navit/support/espeak/espeak-data/voices/europe/an b/navit/support/espeak/espeak-data/voices/europe/an
new file mode 100755
index 000000000..7bf245e03
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/europe/an
@@ -0,0 +1,3 @@
+name aragonese
+language an
+gender male
diff --git a/navit/support/espeak/espeak-data/voices/europe/bg b/navit/support/espeak/espeak-data/voices/europe/bg
new file mode 100755
index 000000000..c3842ca78
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/europe/bg
@@ -0,0 +1,5 @@
+name bulgarian
+language bg
+
+stressAmp 13 12 17 17 20 22 22 21
+stressLength 180 170 200 200 200 200 210 220 \ No newline at end of file
diff --git a/navit/support/espeak/espeak-data/voices/bs b/navit/support/espeak/espeak-data/voices/europe/bs
index eadd70732..eadd70732 100755
--- a/navit/support/espeak/espeak-data/voices/bs
+++ b/navit/support/espeak/espeak-data/voices/europe/bs
diff --git a/navit/support/espeak/espeak-data/voices/ca b/navit/support/espeak/espeak-data/voices/europe/ca
index dc51396ce..dc51396ce 100644..100755
--- a/navit/support/espeak/espeak-data/voices/ca
+++ b/navit/support/espeak/espeak-data/voices/europe/ca
diff --git a/navit/support/espeak/espeak-data/voices/cs b/navit/support/espeak/espeak-data/voices/europe/cs
index 1c2992dd5..1c2992dd5 100755
--- a/navit/support/espeak/espeak-data/voices/cs
+++ b/navit/support/espeak/espeak-data/voices/europe/cs
diff --git a/navit/support/espeak/espeak-data/voices/cy b/navit/support/espeak/espeak-data/voices/europe/cy
index 2991e99d1..30abd9432 100755
--- a/navit/support/espeak/espeak-data/voices/cy
+++ b/navit/support/espeak/espeak-data/voices/europe/cy
@@ -1,5 +1,5 @@
language cy
-name welsh-test
+name welsh
gender male
intonation 4
diff --git a/navit/support/espeak/espeak-data/voices/europe/da b/navit/support/espeak/espeak-data/voices/europe/da
new file mode 100755
index 000000000..12ce1096a
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/europe/da
@@ -0,0 +1,7 @@
+name danish
+language da
+gender male
+
+tunes s2 c2 q2 e2
+
+
diff --git a/navit/support/espeak/espeak-data/voices/el b/navit/support/espeak/espeak-data/voices/europe/el
index 1e9a757f8..1e9a757f8 100755
--- a/navit/support/espeak/espeak-data/voices/el
+++ b/navit/support/espeak/espeak-data/voices/europe/el
diff --git a/navit/support/espeak/espeak-data/voices/es b/navit/support/espeak/espeak-data/voices/europe/es
index 1a9e53b6e..43c852c8b 100755
--- a/navit/support/espeak/espeak-data/voices/es
+++ b/navit/support/espeak/espeak-data/voices/europe/es
@@ -3,5 +3,5 @@ language es
gender male
dictrules 1
-intonation 3
+//intonation 3
diff --git a/navit/support/espeak/espeak-data/voices/europe/et b/navit/support/espeak/espeak-data/voices/europe/et
new file mode 100755
index 000000000..6caf78ce0
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/europe/et
@@ -0,0 +1,3 @@
+name estonian
+language et
+
diff --git a/navit/support/espeak/espeak-data/voices/fi b/navit/support/espeak/espeak-data/voices/europe/fi
index 6e11c9312..6e11c9312 100755
--- a/navit/support/espeak/espeak-data/voices/fi
+++ b/navit/support/espeak/espeak-data/voices/europe/fi
diff --git a/navit/support/espeak/espeak-data/voices/europe/fr-be b/navit/support/espeak/espeak-data/voices/europe/fr-be
new file mode 100755
index 000000000..4a7418204
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/europe/fr-be
@@ -0,0 +1,9 @@
+name french-Belgium
+language fr-be
+language fr 8
+gender male
+
+dictrules 2
+tunes s3 c3 q3 e3
+
+
diff --git a/navit/support/espeak/espeak-data/voices/europe/ga b/navit/support/espeak/espeak-data/voices/europe/ga
new file mode 100755
index 000000000..30d32e07e
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/europe/ga
@@ -0,0 +1,4 @@
+name irish-gaeilge
+language ga
+
+dictrules 1 // fix for eclipsis
diff --git a/navit/support/espeak/espeak-data/voices/hr b/navit/support/espeak/espeak-data/voices/europe/hr
index d6811d3ae..d6811d3ae 100755
--- a/navit/support/espeak/espeak-data/voices/hr
+++ b/navit/support/espeak/espeak-data/voices/europe/hr
diff --git a/navit/support/espeak/espeak-data/voices/hu b/navit/support/espeak/espeak-data/voices/europe/hu
index ba2bdde41..25d78c05c 100755
--- a/navit/support/espeak/espeak-data/voices/hu
+++ b/navit/support/espeak/espeak-data/voices/europe/hu
@@ -1,3 +1,7 @@
name hungarian
language hu
gender male
+option bracket 0 0
+pitch 81 117
+
+
diff --git a/navit/support/espeak/espeak-data/voices/is b/navit/support/espeak/espeak-data/voices/europe/is
index 9e9c4e747..b8f238345 100755
--- a/navit/support/espeak/espeak-data/voices/is
+++ b/navit/support/espeak/espeak-data/voices/europe/is
@@ -1,4 +1,4 @@
-name icelandic-test
+name icelandic
language is
gender male
diff --git a/navit/support/espeak/espeak-data/voices/it b/navit/support/espeak/espeak-data/voices/europe/it
index 53c2a7048..cf4966c8d 100755
--- a/navit/support/espeak/espeak-data/voices/it
+++ b/navit/support/espeak/espeak-data/voices/europe/it
@@ -1,6 +1,8 @@
+
name italian
language it
gender male
-replace 03 i I
+tunes s4 c4 q4 e4
+replace 03 i I
diff --git a/navit/support/espeak/espeak-data/voices/europe/lt b/navit/support/espeak/espeak-data/voices/europe/lt
new file mode 100755
index 000000000..8295f6b26
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/europe/lt
@@ -0,0 +1,5 @@
+
+name lithuanian
+language lt
+gender male
+
diff --git a/navit/support/espeak/espeak-data/voices/lv b/navit/support/espeak/espeak-data/voices/europe/lv
index 0278ea213..0278ea213 100755
--- a/navit/support/espeak/espeak-data/voices/lv
+++ b/navit/support/espeak/espeak-data/voices/europe/lv
diff --git a/navit/support/espeak/espeak-data/voices/mk b/navit/support/espeak/espeak-data/voices/europe/mk
index 4607dd079..47a8398c9 100755
--- a/navit/support/espeak/espeak-data/voices/mk
+++ b/navit/support/espeak/espeak-data/voices/europe/mk
@@ -1,4 +1,4 @@
-name macedonian-test
+name macedonian
language mk
gender male
diff --git a/navit/support/espeak/espeak-data/voices/nl b/navit/support/espeak/espeak-data/voices/europe/nl
index 6a8d5efd8..beef33fa3 100755
--- a/navit/support/espeak/espeak-data/voices/nl
+++ b/navit/support/espeak/espeak-data/voices/europe/nl
@@ -1,3 +1,3 @@
language nl
-name dutch-test
+name dutch
gender male
diff --git a/navit/support/espeak/espeak-data/voices/no b/navit/support/espeak/espeak-data/voices/europe/no
index 77b60b963..a90c7b725 100755
--- a/navit/support/espeak/espeak-data/voices/no
+++ b/navit/support/espeak/espeak-data/voices/europe/no
@@ -1,4 +1,4 @@
-name norwegian-test
+name norwegian
language no
language nb
gender male
diff --git a/navit/support/espeak/espeak-data/voices/pl b/navit/support/espeak/espeak-data/voices/europe/pl
index 8fc65d4ba..8fc65d4ba 100755
--- a/navit/support/espeak/espeak-data/voices/pl
+++ b/navit/support/espeak/espeak-data/voices/europe/pl
diff --git a/navit/support/espeak/espeak-data/voices/pt-pt b/navit/support/espeak/espeak-data/voices/europe/pt-pt
index e23915f39..43cb971c4 100755
--- a/navit/support/espeak/espeak-data/voices/pt-pt
+++ b/navit/support/espeak/espeak-data/voices/europe/pt-pt
@@ -1,7 +1,8 @@
name portugal
language pt-pt
+language pt 6
gender male
-phonemes pt_pt
+phonemes pt-pt
dictrules 1
intonation 2
diff --git a/navit/support/espeak/espeak-data/voices/ro b/navit/support/espeak/espeak-data/voices/europe/ro
index d8ecd252c..d8ecd252c 100755
--- a/navit/support/espeak/espeak-data/voices/ro
+++ b/navit/support/espeak/espeak-data/voices/europe/ro
diff --git a/navit/support/espeak/espeak-data/voices/ru b/navit/support/espeak/espeak-data/voices/europe/ru
index 238c69126..4136ab21c 100755
--- a/navit/support/espeak/espeak-data/voices/ru
+++ b/navit/support/espeak/espeak-data/voices/europe/ru
@@ -1,6 +1,7 @@
-name russian_test
+name russian
language ru
gender male
replace 03 a a#
+dict_min 20000
diff --git a/navit/support/espeak/espeak-data/voices/sk b/navit/support/espeak/espeak-data/voices/europe/sk
index 026363f6a..026363f6a 100755
--- a/navit/support/espeak/espeak-data/voices/sk
+++ b/navit/support/espeak/espeak-data/voices/europe/sk
diff --git a/navit/support/espeak/espeak-data/voices/sq b/navit/support/espeak/espeak-data/voices/europe/sq
index d0b729579..d0b729579 100644..100755
--- a/navit/support/espeak/espeak-data/voices/sq
+++ b/navit/support/espeak/espeak-data/voices/europe/sq
diff --git a/navit/support/espeak/espeak-data/voices/sr b/navit/support/espeak/espeak-data/voices/europe/sr
index a7a8223db..a7a8223db 100644..100755
--- a/navit/support/espeak/espeak-data/voices/sr
+++ b/navit/support/espeak/espeak-data/voices/europe/sr
diff --git a/navit/support/espeak/espeak-data/voices/sv b/navit/support/espeak/espeak-data/voices/europe/sv
index df70f4387..df70f4387 100755
--- a/navit/support/espeak/espeak-data/voices/sv
+++ b/navit/support/espeak/espeak-data/voices/europe/sv
diff --git a/navit/support/espeak/espeak-data/voices/fr b/navit/support/espeak/espeak-data/voices/fr
index 973073161..a0b4986ec 100755
--- a/navit/support/espeak/espeak-data/voices/fr
+++ b/navit/support/espeak/espeak-data/voices/fr
@@ -1,7 +1,7 @@
-language fr
name french
+language fr-fr
+language fr
gender male
dictrules 1
-intonation 3
-
+tunes s3 c3 q3 e3
diff --git a/navit/support/espeak/espeak-data/voices/fr-be b/navit/support/espeak/espeak-data/voices/fr-be
deleted file mode 100755
index cba9b2757..000000000
--- a/navit/support/espeak/espeak-data/voices/fr-be
+++ /dev/null
@@ -1,7 +0,0 @@
-language fr-be
-name french (Belgium)
-gender male
-
-dictrules 2
-intonation 3
-
diff --git a/navit/support/espeak/espeak-data/voices/hi b/navit/support/espeak/espeak-data/voices/hi
deleted file mode 100755
index de4786c94..000000000
--- a/navit/support/espeak/espeak-data/voices/hi
+++ /dev/null
@@ -1,9 +0,0 @@
-name hindi-test
-language hi
-gender male
-
-translator hi
-phonemes hi
-dictionary hi
-
-dictrules 1
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-br1 b/navit/support/espeak/espeak-data/voices/mb/mb-br1
index ba7c42cc4..370a5ea13 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-br1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-br1
@@ -1,7 +1,9 @@
language pt 7
name brazil-mbrola-1
gender male
+
pitch 82 117
+voicing 80
dictrules 2 3 4
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-br3 b/navit/support/espeak/espeak-data/voices/mb/mb-br3
index 8479e658e..0cf9daa53 100644..100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-br3
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-br3
@@ -1,9 +1,10 @@
language pt 7
name brazil-mbrola-3
gender male
-pitch 82 117
+pitch 80 120
dictrules 2 3 4
+voicing 120
mbrola br3 ptbr_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-br4 b/navit/support/espeak/espeak-data/voices/mb/mb-br4
index d3d772007..1cc596d85 100644..100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-br4
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-br4
@@ -1,7 +1,9 @@
language pt 7
name brazil-mbrola-4
gender female
+
pitch 140 220
+voicing 80
dictrules 2 3 4
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-cr1 b/navit/support/espeak/espeak-data/voices/mb/mb-cr1
index 9b280bf8b..1f0ab08a0 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-cr1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-cr1
@@ -5,5 +5,6 @@ gender male
dictionary hbs
dictrules 1
+voicing 150
pitch 82 117
mbrola cr1 cr1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de2 b/navit/support/espeak/espeak-data/voices/mb/mb-de2
index c0a5475ec..39e3c4343 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de2
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-de2
@@ -1,6 +1,7 @@
name german-mbrola-2
language de 6
gender male
+voicing 80
mbrola de2 de2_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de3 b/navit/support/espeak/espeak-data/voices/mb/mb-de3
new file mode 100755
index 000000000..d2ff8dd71
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-de3
@@ -0,0 +1,8 @@
+name german-mbrola-3
+language de 6
+gender female
+voicing 80
+pitch 140 220
+
+mbrola de3 de2_phtrans
+
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de4 b/navit/support/espeak/espeak-data/voices/mb/mb-de4
index 31bd479a3..abd8713da 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de4
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-de4
@@ -2,5 +2,7 @@ name german-mbrola-4
language de 6
gender male
+voicing 130
+
mbrola de4 de4_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de4-en b/navit/support/espeak/espeak-data/voices/mb/mb-de4-en
index 8fd4a63a1..5980fbf06 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de4-en
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-de4-en
@@ -2,5 +2,7 @@ name en-german
language en 9
gender male
+voicing 130
+
mbrola de4 de4_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de5-en b/navit/support/espeak/espeak-data/voices/mb/mb-de5-en
index e416c6dc5..e30a0257b 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de5-en
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-de5-en
@@ -1,5 +1,5 @@
name en-german-5
-language en
+language en 9
gender female
pitch 140 220
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de6 b/navit/support/espeak/espeak-data/voices/mb/mb-de6
index 35a4a3fc5..35a4a3fc5 100644..100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de6
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-de6
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de6-grc b/navit/support/espeak/espeak-data/voices/mb/mb-de6-grc
index a6e0f46bb..a6e0f46bb 100644..100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de6-grc
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-de6-grc
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de7 b/navit/support/espeak/espeak-data/voices/mb/mb-de7
index aa80edaad..d51583c86 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de7
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-de7
@@ -2,6 +2,7 @@ name german-mbrola-7
language de 7
gender female
+voicing 150
pitch 140 220
mbrola de7 de6_phtrans 22050
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-ee1 b/navit/support/espeak/espeak-data/voices/mb/mb-ee1
new file mode 100755
index 000000000..4d62a5b17
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-ee1
@@ -0,0 +1,8 @@
+name estonian-mbrola
+language et
+gender male
+
+pitch 75 125
+voicing 80
+mbrola ee1 ee1_phtrans
+
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-en1 b/navit/support/espeak/espeak-data/voices/mb/mb-en1
index fc60f4167..8de8e01ca 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-en1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-en1
@@ -3,5 +3,6 @@ language en-uk 3
language en 2
gender male
+voicing 150
pitch 82 117
mbrola en1 en1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-es1 b/navit/support/espeak/espeak-data/voices/mb/mb-es1
index d59fe7952..d5ffea2d1 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-es1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-es1
@@ -4,4 +4,5 @@ gender male
pitch 82 117
mbrola es1 es_phtrans
+voicing 120
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-es2 b/navit/support/espeak/espeak-data/voices/mb/mb-es2
index 42de58882..d38fa08d8 100644..100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-es2
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-es2
@@ -3,5 +3,5 @@ name spanish-mbrola-2
gender male
pitch 82 117
-mbrola es2 es_phtrans
+mbrola es2 es_phtrans 22050
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-fr1 b/navit/support/espeak/espeak-data/voices/mb/mb-fr1
index 7cbdab338..046515271 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-fr1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-fr1
@@ -5,5 +5,7 @@ gender male
dictrules 1
stressLength 180 180 180 180 0 0 220 220
pitch 82 117
+voicing 70
+
mbrola fr1 fr1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-fr1-en b/navit/support/espeak/espeak-data/voices/mb/mb-fr1-en
index 366653147..47cb1825b 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-fr1-en
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-fr1-en
@@ -4,5 +4,6 @@ gender male
dictrules 1
pitch 82 117
+voicing 70
mbrola fr1 fr1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-fr4 b/navit/support/espeak/espeak-data/voices/mb/mb-fr4
index c276bec0d..8e3c3921a 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-fr4
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-fr4
@@ -4,5 +4,6 @@ gender female
dictrules 1
pitch 140 220
+voicing 90
mbrola fr1 fr1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-fr4-en b/navit/support/espeak/espeak-data/voices/mb/mb-fr4-en
index b8f782946..8126770b4 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-fr4-en
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-fr4-en
@@ -4,5 +4,6 @@ gender female
dictrules 1
pitch 140 220
+voicing 90
mbrola fr1 fr1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-gr2 b/navit/support/espeak/espeak-data/voices/mb/mb-gr2
index 30dea8920..92d2f20fc 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-gr2
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-gr2
@@ -3,4 +3,5 @@ language el 7
gender male
pitch 82 117
+voicing 65
mbrola gr2 gr2_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-gr2-en b/navit/support/espeak/espeak-data/voices/mb/mb-gr2-en
index b48b1788b..c9bd20d1e 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-gr2-en
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-gr2-en
@@ -1,6 +1,7 @@
name en-greek
-language en 7
+language en 9
gender male
pitch 82 117
+voicing 65
mbrola gr2 gr2_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-hu1 b/navit/support/espeak/espeak-data/voices/mb/mb-hu1
index b8519559d..195ea330a 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-hu1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-hu1
@@ -3,4 +3,5 @@ language hu 7
gender female
pitch 140 220
+voicing 160
mbrola hu1 hu1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-hu1-en b/navit/support/espeak/espeak-data/voices/mb/mb-hu1-en
index 73ac62a4a..28ce3754d 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-hu1-en
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-hu1-en
@@ -3,4 +3,5 @@ language en 10
gender female
pitch 140 220
+voicing 160
mbrola hu1 hu1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-ic1 b/navit/support/espeak/espeak-data/voices/mb/mb-ic1
new file mode 100755
index 000000000..b08b53a23
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-ic1
@@ -0,0 +1,7 @@
+name mbrola-icelandic
+language is 6
+gender male
+
+voicing 180
+mbrola ic1 ic1_phtrans
+
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-id1 b/navit/support/espeak/espeak-data/voices/mb/mb-id1
index b86f59306..aa57c3159 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-id1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-id1
@@ -3,5 +3,6 @@ language id 7
gender male
pitch 82 117
+voicing 120
mbrola id1 id1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-ir1 b/navit/support/espeak/espeak-data/voices/mb/mb-ir1
new file mode 100755
index 000000000..c47d2079b
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-ir1
@@ -0,0 +1,22 @@
+name persian-mb-ir1
+language fa
+gender male
+phonemes fa
+mbrola ir1 ir1_phtrans
+
+// "speed 82" adjust default speed of "mb-ir1" with eSpeak "fa".
+speed 82
+// Please don't change this value. It's result of several tests.
+
+// "voicing 125" adjust output volume of "mb-ir1" with eSpeak "fa".
+voicing 125
+// Please don't change this value. It's result of several tests.
+
+// "pitch 82 118" adjust default pitch of "mb-ir1" like other male voices.
+pitch 82 118
+// Please don't change this value. The result male voice is good and natural.
+
+// If you want use Pinglish instead of English for reading, just delete // from start of next line.
+// dictrules 1
+// "dictrules 1" read English text as Pinglish (Persian text that written with English alphabets).
+
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-ir2 b/navit/support/espeak/espeak-data/voices/mb/mb-ir2
new file mode 100755
index 000000000..819bfa566
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-ir2
@@ -0,0 +1,22 @@
+name persian-mb-ir2
+language fa
+gender female
+phonemes fa
+mbrola ir2 ir1_phtrans 22050
+
+// "speed 78" adjust default speed of "mb-ir2" with eSpeak "fa".
+speed 78
+// Please don't change this value. It's result of several tests.
+
+// "voicing 150" adjust output volume of "mb-ir2" with eSpeak "fa".
+voicing 150
+// Please don't change this value. It's result of several tests.
+
+// "pitch 140 220" adjust default pitch of "mb-ir2" like other female voices.
+pitch 140 220
+// Please don't change this value. The result female voice is good and natural.
+
+// If you want use Pinglish instead of English for reading, just delete // from start of next line.
+// dictrules 1
+// "dictrules 1" read English text as Pinglish (Persian text that written with English alphabets).
+
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-it3 b/navit/support/espeak/espeak-data/voices/mb/mb-it3
index 00e88867c..89f7dcd4f 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-it3
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-it3
@@ -3,6 +3,7 @@ language it 7
gender male
pitch 82 117
+voicing 65
mbrola it3 it3_phtrans
replace 03 i I // final unstressed "i"
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-it4 b/navit/support/espeak/espeak-data/voices/mb/mb-it4
index f2130ba4f..cb3a6ffbe 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-it4
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-it4
@@ -3,6 +3,7 @@ language it 7
gender female
pitch 140 220
+voicing 60
mbrola it4 it3_phtrans
replace 03 i I // final unstressed "i"
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-mx1 b/navit/support/espeak/espeak-data/voices/mb/mb-mx1
new file mode 100755
index 000000000..99b723c31
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-mx1
@@ -0,0 +1,10 @@
+language es-mx 7
+language es 8
+name mexican-mbrola-1
+gender male
+pitch 82 117
+
+mbrola mx1 mx1_phtrans
+
+replace 00 T s
+
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-mx2 b/navit/support/espeak/espeak-data/voices/mb/mb-mx2
new file mode 100755
index 000000000..f46f0be1f
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-mx2
@@ -0,0 +1,10 @@
+language es-mx 7
+language es 8
+name mexican-mbrola-2
+gender male
+pitch 82 117
+
+mbrola mx2 mx2_phtrans
+
+replace 00 T s
+
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-nl2 b/navit/support/espeak/espeak-data/voices/mb/mb-nl2
index fc377156b..273f98b61 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-nl2
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-nl2
@@ -3,5 +3,7 @@ name dutch-mbrola-2
gender male
pitch 82 117
+voicing 130
+
mbrola nl2 nl_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-nl2-en b/navit/support/espeak/espeak-data/voices/mb/mb-nl2-en
index 0c2d13a65..ad0ac4063 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-nl2-en
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-nl2-en
@@ -3,5 +3,7 @@ name en-dutch
gender male
pitch 82 117
+voicing 130
+
mbrola nl2 nl_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-pl1 b/navit/support/espeak/espeak-data/voices/mb/mb-pl1
index 4e2b9d23e..cedeb46bb 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-pl1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-pl1
@@ -3,4 +3,5 @@ language pl 7
gender female
pitch 140 220
+voicing 120
mbrola pl1 pl1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-pt1 b/navit/support/espeak/espeak-data/voices/mb/mb-pt1
index ebd92ffb3..a2168959b 100644..100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-pt1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-pt1
@@ -1,9 +1,10 @@
language pt 7
name portugal-mbrola-1
gender female
-pitch 140 220
+pitch 145 240
dictrules 1
+voicing 70
mbrola pt1 pt1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-sw1 b/navit/support/espeak/espeak-data/voices/mb/mb-sw1
index 4c6239268..57ee32a92 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-sw1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-sw1
@@ -3,5 +3,7 @@ language sv 7
gender male
pitch 82 117
+voicing 120
+
mbrola sw1 sv_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-sw1-en b/navit/support/espeak/espeak-data/voices/mb/mb-sw1-en
index 52692c385..627af2fbb 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-sw1-en
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-sw1-en
@@ -3,5 +3,7 @@ language en 11
gender male
pitch 82 117
+voicing 120
+
mbrola sw1 sv_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-sw2 b/navit/support/espeak/espeak-data/voices/mb/mb-sw2
index c632e263c..55cfa0d74 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-sw2
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-sw2
@@ -3,5 +3,7 @@ language sv 8
gender female
pitch 140 220
+voicing 130
+
mbrola sw2 sv2_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-sw2-en b/navit/support/espeak/espeak-data/voices/mb/mb-sw2-en
index f2033dc11..015cc9c03 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-sw2-en
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-sw2-en
@@ -1,7 +1,9 @@
name en-swedish-f
-language en
+language en 10
gender female
pitch 140 220
+voicing 130
+
mbrola sw2 sv2_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-tr1 b/navit/support/espeak/espeak-data/voices/mb/mb-tr1
new file mode 100755
index 000000000..97a337d34
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-tr1
@@ -0,0 +1,7 @@
+name turkish-mbrola-1
+language tr 7
+gender male
+
+mbrola tr1 tr1_phtrans
+dictrules 1
+
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-tr2 b/navit/support/espeak/espeak-data/voices/mb/mb-tr2
new file mode 100755
index 000000000..1dfbf9532
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-tr2
@@ -0,0 +1,10 @@
+name turkish-mbrola-1
+language tr 7
+gender female
+
+pitch 160 230
+voicing 170
+
+mbrola tr2 tr1_phtrans
+dictrules 1
+
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-us1 b/navit/support/espeak/espeak-data/voices/mb/mb-us1
index c62589be7..3dd75260a 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-us1
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-us1
@@ -3,7 +3,7 @@ language en-us
language en 8
gender female
-phonemes en_us
+phonemes en-us
dictrules 3 6
stressLength 170 135 205 205 0 0 245 275
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-us2 b/navit/support/espeak/espeak-data/voices/mb/mb-us2
index d94fce5a4..de799f065 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-us2
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-us2
@@ -3,10 +3,11 @@ language en-us
language en 7
gender male
-phonemes en_us
+phonemes en-us
dictrules 3 6
stressLength 170 135 205 205 0 0 245 275
pitch 82 117
+voicing 80
mbrola us2 us_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-us3 b/navit/support/espeak/espeak-data/voices/mb/mb-us3
index 645e1b7d0..c538b134f 100755
--- a/navit/support/espeak/espeak-data/voices/mb/mb-us3
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-us3
@@ -3,10 +3,11 @@ language en-us
language en 8
gender male
-phonemes en_us
+phonemes en-us
dictrules 3 6
stressLength 170 135 205 205 0 0 245 275
+voicing 150
pitch 82 117
mbrola us3 us3_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-vz1 b/navit/support/espeak/espeak-data/voices/mb/mb-vz1
new file mode 100755
index 000000000..d64a9e5aa
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/mb/mb-vz1
@@ -0,0 +1,11 @@
+language es-vz 7
+language es 8
+name venezuala-mbrola-1
+gender male
+pitch 82 117
+
+mbrola vz1 vz_phtrans
+
+dictrules 3
+replace 00 T s
+voicing 200
diff --git a/navit/support/espeak/espeak-data/voices/af b/navit/support/espeak/espeak-data/voices/other/af
index bcbb2a005..bcbb2a005 100755
--- a/navit/support/espeak/espeak-data/voices/af
+++ b/navit/support/espeak/espeak-data/voices/other/af
diff --git a/navit/support/espeak/espeak-data/voices/en/en-n b/navit/support/espeak/espeak-data/voices/other/en-n
index 933311dad..755bf5f7d 100755
--- a/navit/support/espeak/espeak-data/voices/en/en-n
+++ b/navit/support/espeak/espeak-data/voices/other/en-n
@@ -1,14 +1,15 @@
-name lancashire
+name english-north
language en-uk-north
language en-uk 3
+language en 5
gender male
-phonemes en_n
+phonemes en-n
stressLength 160 150 180 180 220 220 290 290
replace 00 i@3 i@
replace 03 N n
-//replace 03 I i
-//replace 03 I2 i
+replace 03 i I2
+
diff --git a/navit/support/espeak/espeak-data/voices/en/en-rp b/navit/support/espeak/espeak-data/voices/other/en-rp
index 3489f28ad..abc1dbcbf 100755
--- a/navit/support/espeak/espeak-data/voices/en/en-rp
+++ b/navit/support/espeak/espeak-data/voices/other/en-rp
@@ -1,12 +1,13 @@
name english_rp
language en-uk-rp
language en-uk 4
+language en 5
gender male
-phonemes en_rp
+phonemes en-rp
replace 00 o@ O@
replace 00 i@3 i@
replace 03 I i
replace 03 I2 i
-replace 03 @ a2
-replace 03 3 a2
+replace 03 @ a#
+replace 03 3 a#
diff --git a/navit/support/espeak/espeak-data/voices/en/en-sc b/navit/support/espeak/espeak-data/voices/other/en-sc
index e16ae25a8..e0783ec3b 100755
--- a/navit/support/espeak/espeak-data/voices/en/en-sc
+++ b/navit/support/espeak/espeak-data/voices/other/en-sc
@@ -3,7 +3,7 @@ language en-sc
language en 4
gender male
-phonemes en_sc
+phonemes en-sc
dictrules 5 6 7
stressLength 180 130 200 200 0 0 250 270
diff --git a/navit/support/espeak/espeak-data/voices/en/en-wi b/navit/support/espeak/espeak-data/voices/other/en-wi
index 28a42a563..302538de6 100755
--- a/navit/support/espeak/espeak-data/voices/en/en-wi
+++ b/navit/support/espeak/espeak-data/voices/other/en-wi
@@ -1,9 +1,10 @@
name en-westindies
language en-wi
language en-uk 4
+language en 10
gender male
-phonemes en_wi
+phonemes en-wi
dictrules 8
stressLength 175 175 175 175 220 220 250 290
@@ -11,8 +12,8 @@ replace 00 D d
replace 00 T t[
replace 00 U@ o@
replace 00 i@3 i@
-replace 03 @ a2
-replace 03 3 a2
+replace 03 @ a#
+replace 03 3 a#
replace 03 N n
formant 1 98 100 100
diff --git a/navit/support/espeak/espeak-data/voices/en/en-wm b/navit/support/espeak/espeak-data/voices/other/en-wm
index aa82f88fb..33ff4fe41 100755
--- a/navit/support/espeak/espeak-data/voices/en/en-wm
+++ b/navit/support/espeak/espeak-data/voices/other/en-wm
@@ -1,8 +1,10 @@
name english_wmids
language en-uk-wmids
+language en-uk 9
+language en 9
gender male
-phonemes en_wm
+phonemes en-wm
replace 00 h NULL
replace 00 o@ O@
diff --git a/navit/support/espeak/espeak-data/voices/eo b/navit/support/espeak/espeak-data/voices/other/eo
index 36a4bff65..be18c0a7b 100755
--- a/navit/support/espeak/espeak-data/voices/eo
+++ b/navit/support/espeak/espeak-data/voices/other/eo
@@ -1,3 +1,5 @@
name esperanto
language eo
gender male
+
+apostrophe 2
diff --git a/navit/support/espeak/espeak-data/voices/test/grc b/navit/support/espeak/espeak-data/voices/other/grc
index ffa942063..ffa942063 100755
--- a/navit/support/espeak/espeak-data/voices/test/grc
+++ b/navit/support/espeak/espeak-data/voices/other/grc
diff --git a/navit/support/espeak/espeak-data/voices/other/jbo b/navit/support/espeak/espeak-data/voices/other/jbo
new file mode 100755
index 000000000..f43ef84fa
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/other/jbo
@@ -0,0 +1,4 @@
+name lojban
+language jbo
+
+speed 80 // speed adjustment, percentage
diff --git a/navit/support/espeak/espeak-data/voices/la b/navit/support/espeak/espeak-data/voices/other/la
index f3e97b523..f3e97b523 100644..100755
--- a/navit/support/espeak/espeak-data/voices/la
+++ b/navit/support/espeak/espeak-data/voices/other/la
diff --git a/navit/support/espeak/espeak-data/voices/other/lfn b/navit/support/espeak/espeak-data/voices/other/lfn
new file mode 100755
index 000000000..5c814a121
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/other/lfn
@@ -0,0 +1,6 @@
+name lingua_franca_nova
+language lfn
+gender male
+
+phonemes base2
+l_unpronouncable 0
diff --git a/navit/support/espeak/espeak-data/voices/sw b/navit/support/espeak/espeak-data/voices/other/sw
index cf584b7dd..57db0e57d 100755
--- a/navit/support/espeak/espeak-data/voices/sw
+++ b/navit/support/espeak/espeak-data/voices/other/sw
@@ -1,4 +1,4 @@
-name swahihi-test
+name swahili-test
language sw
gender male
diff --git a/navit/support/espeak/espeak-data/voices/pt b/navit/support/espeak/espeak-data/voices/pt
index 53cb31446..10d62711a 100755
--- a/navit/support/espeak/espeak-data/voices/pt
+++ b/navit/support/espeak/espeak-data/voices/pt
@@ -1,7 +1,8 @@
name brazil
-language pt
language pt-br
+language pt
gender male
dictrules 2
+stressLength 200 115 230 230 0 0 250 270
diff --git a/navit/support/espeak/espeak-data/voices/test/am b/navit/support/espeak/espeak-data/voices/test/am
new file mode 100755
index 000000000..729d1f07e
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/am
@@ -0,0 +1,3 @@
+name amharic-test
+language am
+
diff --git a/navit/support/espeak/espeak-data/voices/test/as b/navit/support/espeak/espeak-data/voices/test/as
new file mode 100755
index 000000000..109f92c82
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/as
@@ -0,0 +1,4 @@
+name assamese-test
+language as
+
+ \ No newline at end of file
diff --git a/navit/support/espeak/espeak-data/voices/test/az b/navit/support/espeak/espeak-data/voices/test/az
new file mode 100755
index 000000000..6fdf38274
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/az
@@ -0,0 +1,3 @@
+name azerbaijani-test
+language az
+
diff --git a/navit/support/espeak/espeak-data/voices/test/bn b/navit/support/espeak/espeak-data/voices/test/bn
new file mode 100755
index 000000000..e1e569fbe
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/bn
@@ -0,0 +1,3 @@
+name bengali-test
+language bn
+gender male
diff --git a/navit/support/espeak/espeak-data/voices/test/eu b/navit/support/espeak/espeak-data/voices/test/eu
new file mode 100755
index 000000000..35ada0cf4
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/eu
@@ -0,0 +1,3 @@
+name basque-test
+language eu
+
diff --git a/navit/support/espeak/espeak-data/voices/test/gd b/navit/support/espeak/espeak-data/voices/test/gd
new file mode 100644
index 000000000..9f8ed6123
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/gd
@@ -0,0 +1,3 @@
+name scottish-gaelic-test
+language gd
+
diff --git a/navit/support/espeak/espeak-data/voices/test/gu b/navit/support/espeak/espeak-data/voices/test/gu
new file mode 100755
index 000000000..4d983c68d
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/gu
@@ -0,0 +1,3 @@
+name gujarati-test
+language gu
+
diff --git a/navit/support/espeak/espeak-data/voices/test/jbo b/navit/support/espeak/espeak-data/voices/test/jbo
deleted file mode 100644
index ebab1a875..000000000
--- a/navit/support/espeak/espeak-data/voices/test/jbo
+++ /dev/null
@@ -1,3 +0,0 @@
-name lojban
-language jbo
-
diff --git a/navit/support/espeak/espeak-data/voices/test/kl b/navit/support/espeak/espeak-data/voices/test/kl
new file mode 100755
index 000000000..1ee5f0b5f
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/kl
@@ -0,0 +1,3 @@
+name greenlandic
+language kl
+
diff --git a/navit/support/espeak/espeak-data/voices/test/ko b/navit/support/espeak/espeak-data/voices/test/ko
new file mode 100755
index 000000000..d9330a8ff
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/ko
@@ -0,0 +1,6 @@
+name korean-test
+language ko
+gender male
+pitch 80 118
+intonation 2
+
diff --git a/navit/support/espeak/espeak-data/voices/test/nci b/navit/support/espeak/espeak-data/voices/test/nci
new file mode 100755
index 000000000..6ce7eee49
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/nci
@@ -0,0 +1,7 @@
+name nahuatl-classical
+language nci
+gender male
+
+intonation 3
+stressrule 2
+stressLength 190 190 200 200 0 0 220 240
diff --git a/navit/support/espeak/espeak-data/voices/test/or b/navit/support/espeak/espeak-data/voices/test/or
new file mode 100755
index 000000000..b3dec7161
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/or
@@ -0,0 +1,2 @@
+name oriya-test
+language or
diff --git a/navit/support/espeak/espeak-data/voices/test/pap b/navit/support/espeak/espeak-data/voices/test/pap
index 3b105a7fb..3b105a7fb 100644..100755
--- a/navit/support/espeak/espeak-data/voices/test/pap
+++ b/navit/support/espeak/espeak-data/voices/test/pap
diff --git a/navit/support/espeak/espeak-data/voices/test/si b/navit/support/espeak/espeak-data/voices/test/si
new file mode 100755
index 000000000..87d564d67
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/si
@@ -0,0 +1,4 @@
+name sinhala-test
+language si
+
+intonation 2
diff --git a/navit/support/espeak/espeak-data/voices/test/sl b/navit/support/espeak/espeak-data/voices/test/sl
new file mode 100755
index 000000000..6044e9d04
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/sl
@@ -0,0 +1,3 @@
+name slovenian-test
+language sl
+ \ No newline at end of file
diff --git a/navit/support/espeak/espeak-data/voices/test/te b/navit/support/espeak/espeak-data/voices/test/te
new file mode 100755
index 000000000..c23078a86
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/te
@@ -0,0 +1,5 @@
+name telugu-test
+language te
+
+intonation 2
+//consonants 80
diff --git a/navit/support/espeak/espeak-data/voices/test/ur b/navit/support/espeak/espeak-data/voices/test/ur
new file mode 100755
index 000000000..d4d113c4c
--- /dev/null
+++ b/navit/support/espeak/espeak-data/voices/test/ur
@@ -0,0 +1,5 @@
+name urdu-test
+language ur
+
+stressrule 6
+
diff --git a/navit/support/espeak/espeak-data/zh_dict b/navit/support/espeak/espeak-data/zh_dict
index 0b611f845..29db8608e 100644
--- a/navit/support/espeak/espeak-data/zh_dict
+++ b/navit/support/espeak/espeak-data/zh_dict
Binary files differ
diff --git a/navit/support/espeak/espeak-data/zhy_dict b/navit/support/espeak/espeak-data/zhy_dict
index 4ad9e7c21..e4f85571a 100644
--- a/navit/support/espeak/espeak-data/zhy_dict
+++ b/navit/support/espeak/espeak-data/zhy_dict
Binary files differ
diff --git a/navit/support/espeak/espeak.c b/navit/support/espeak/espeak.c
index 7997d0673..028650272 100644
--- a/navit/support/espeak/espeak.c
+++ b/navit/support/espeak/espeak.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2006 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -20,10 +20,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
+#ifndef NEED_GETOPT
#include <getopt.h>
+#include <stdbool.h> //for "true"
+#endif
#include <time.h>
#include <sys/stat.h>
+#include "speech.h"
#include "speak_lib.h"
// This version of the command-line speak program uses the
@@ -32,51 +37,55 @@
static const char *help_text =
-"\nspeak [options] [\"<words>\"]\n\n"
+"\nespeak [options] [\"<words>\"]\n\n"
"-f <text file> Text file to speak\n"
"--stdin Read text input from stdin instead of a file\n\n"
-"If neither -f nor --stdin, <words> are spoken, or if none then text is\n"
-"spoken from stdin, each line separately.\n\n"
+"If neither -f nor --stdin, then <words> are spoken, or if none then text\n"
+"is spoken from stdin, each line separately.\n\n"
"-a <integer>\n"
"\t Amplitude, 0 to 200, default is 100\n"
"-g <integer>\n"
"\t Word gap. Pause between words, units of 10mS at the default speed\n"
+"-k <integer>\n"
+"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
+"\t higher values indicate a pitch increase (try -k20).\n"
"-l <integer>\n"
"\t Line length. If not zero (which is the default), consider\n"
"\t lines less than this length as end-of-clause\n"
"-p <integer>\n"
"\t Pitch adjustment, 0 to 99, default is 50\n"
"-s <integer>\n"
-"\t Speed in words per minute, 80 to 390, default is 170\n"
+"\t Speed in words per minute, 80 to 450, default is 175\n"
"-v <voice name>\n"
"\t Use voice file of this name from espeak-data/voices\n"
"-w <wave file name>\n"
-"\t Write output to this WAV file, rather than speaking it directly\n"
+"\t Write speech to this WAV file, rather than speaking it directly\n"
"-b\t Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit \n"
"-m\t Interpret SSML markup, and ignore other < > tags\n"
"-q\t Quiet, don't produce any speech (may be useful with -x)\n"
"-x\t Write phoneme mnemonics to stdout\n"
"-X\t Write phonemes mnemonics and translation trace to stdout\n"
"-z\t No final sentence pause at the end of the text\n"
-"--stdout Write speech output to stdout\n"
"--compile=<voice name>\n"
-"\t Compile the pronunciation rules and dictionary in the current\n"
-"\t directory. =<voice name> is optional and specifies which language\n"
+"\t Compile pronunciation rules and dictionary from the current\n"
+"\t directory. <voice name> specifies the language\n"
+"--ipa Write phonemes to stdout using International Phonetic Alphabet\n"
+"\t --ipa=1 Use ties, --ipa=2 Use ZWJ, --ipa=3 Separate with _\n"
"--path=\"<path>\"\n"
"\t Specifies the directory containing the espeak-data directory\n"
+"--pho Write mbrola phoneme data (.pho) to stdout or to the file in --phonout\n"
"--phonout=\"<filename>\"\n"
-"\t Write output from -x -X commands and mbrola phoneme data to this file\n"
+"\t Write phoneme output from -x -X --ipa and --pho to this file\n"
"--punct=\"<characters>\"\n"
"\t Speak the names of punctuation characters during speaking. If\n"
"\t =<characters> is omitted, all punctuation is spoken.\n"
"--split=\"<minutes>\"\n"
"\t Starts a new WAV file every <minutes>. Used with -w\n"
+"--stdout Write speech output to stdout\n"
+"--version Shows version number and date, and location of espeak-data\n"
"--voices=<language>\n"
"\t List the available voices for the specified language.\n"
-"\t If <language> is omitted, then list all voices.\n"
-"-k <integer>\n"
-"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
-"\t higher values = a pitch increase (try -k20).\n";
+"\t If <language> is omitted, then list all voices.\n";
@@ -85,6 +94,7 @@ int samplerate;
int quiet = 0;
unsigned int samples_total = 0;
unsigned int samples_split = 0;
+unsigned int samples_split_seconds = 0;
unsigned int wavefile_count = 0;
FILE *f_wavfile = NULL;
@@ -116,20 +126,22 @@ void strncpy0(char *dest, const char *source, int size)
}
-void DisplayVoices(FILE *f_out, char *language)
+static void DisplayVoices(FILE *f_out, char *language)
{//============================================
int ix;
const char *p;
int len;
int count;
- int scores = 0;
+ int c;
+ int j;
const espeak_VOICE *v;
const char *lang_name;
char age_buf[12];
+ char buf[80];
const espeak_VOICE **voices;
espeak_VOICE voice_select;
- static char genders[4] = {' ','M','F',' '};
+ static char genders[4] = {'-','M','F','-'};
if((language != NULL) && (language[0] != 0))
{
@@ -139,14 +151,13 @@ void DisplayVoices(FILE *f_out, char *language)
voice_select.gender = 0;
voice_select.name = NULL;
voices = espeak_ListVoices(&voice_select);
- scores = 1;
}
else
{
voices = espeak_ListVoices(NULL);
}
- fprintf(f_out,"Pty Language Age/Gender VoiceName File Other Langs\n");
+ fprintf(f_out,"Pty Language Age/Gender VoiceName File Other Languages\n");
for(ix=0; (v = voices[ix]) != NULL; ix++)
{
@@ -164,8 +175,16 @@ void DisplayVoices(FILE *f_out, char *language)
if(count==0)
{
- fprintf(f_out,"%2d %-12s%s%c %-17s %-11s ",
- p[0],lang_name,age_buf,genders[v->gender],v->name,v->identifier);
+ for(j=0; j < sizeof(buf); j++)
+ {
+ // replace spaces in the name
+ if((c = v->name[j]) == ' ')
+ c = '_';
+ if((buf[j] = c) == 0)
+ break;
+ }
+ fprintf(f_out,"%2d %-12s%s%c %-20s %-13s ",
+ p[0],lang_name,age_buf,genders[v->gender],buf,v->identifier);
}
else
{
@@ -174,8 +193,6 @@ void DisplayVoices(FILE *f_out, char *language)
count++;
p += len+2;
}
-// if(scores)
-// fprintf(f_out,"%3d ",v->score);
fputc('\n',f_out);
}
} // end of DisplayVoices
@@ -197,7 +214,7 @@ static void Write4Bytes(FILE *f, int value)
-int OpenWavFile(char *path, int rate)
+static int OpenWavFile(char *path, int rate)
//===================================
{
static unsigned char wave_hdr[44] = {
@@ -208,28 +225,34 @@ int OpenWavFile(char *path, int rate)
if(path == NULL)
return(2);
- if(path[0] == 0)
- return(0);
-
- if(strcmp(path,"stdout")==0)
- f_wavfile = stdout;
- else
- f_wavfile = fopen(path,"wb");
+ while(isspace(*path)) path++;
- if(f_wavfile != NULL)
+ f_wavfile = NULL;
+ if(path[0] != 0)
{
- fwrite(wave_hdr,1,24,f_wavfile);
- Write4Bytes(f_wavfile,rate);
- Write4Bytes(f_wavfile,rate * 2);
- fwrite(&wave_hdr[32],1,12,f_wavfile);
- return(0);
+ if(strcmp(path,"stdout")==0)
+ f_wavfile = stdout;
+ else
+ f_wavfile = fopen(path,"wb");
+ }
+
+ if(f_wavfile == NULL)
+ {
+ fprintf(stderr,"Can't write to: '%s'\n",path);
+ return(1);
}
- return(1);
+
+
+ fwrite(wave_hdr,1,24,f_wavfile);
+ Write4Bytes(f_wavfile,rate);
+ Write4Bytes(f_wavfile,rate * 2);
+ fwrite(&wave_hdr[32],1,12,f_wavfile);
+ return(0);
} // end of OpenWavFile
-static void CloseWavFile()
+static void CloseWavFile(void)
//========================
{
unsigned int pos;
@@ -264,25 +287,40 @@ static int SynthCallback(short *wav, int numsamples, espeak_EVENT *events)
return(0);
}
- if(samples_split > 0)
+ while(events->type != 0)
{
- // start a new WAV file when this limit is reached, at the next sentence boundary
- while(events->type != 0)
+ if(events->type == espeakEVENT_SAMPLERATE)
{
- if((events->type == espeakEVENT_SENTENCE) && (samples_total > samples_split))
+ samplerate = events->id.number;
+ samples_split = samples_split_seconds * samplerate;
+ }
+ else
+ if(events->type == espeakEVENT_SENTENCE)
+ {
+ // start a new WAV file when the limit is reached, at this sentence boundary
+ if((samples_split > 0) && (samples_total > samples_split))
{
CloseWavFile();
samples_total = 0;
+ wavefile_count++;
}
- events++;
}
+ events++;
}
if(f_wavfile == NULL)
{
- sprintf(fname,"%s_%.2d%s",wavefile,++wavefile_count,filetype);
- if(OpenWavFile(fname, samplerate) != 0)
- return(1);
+ if(samples_split > 0)
+ {
+ sprintf(fname,"%s_%.2d%s",wavefile,wavefile_count+1,filetype);
+ if(OpenWavFile(fname, samplerate) != 0)
+ return(1);
+ }
+ else
+ {
+ if(OpenWavFile(wavefile, samplerate) != 0)
+ return(1);
+ }
}
if(numsamples > 0)
@@ -294,6 +332,32 @@ static int SynthCallback(short *wav, int numsamples, espeak_EVENT *events)
}
+static void PrintVersion(void)
+{//=======================
+ const char *version;
+ const char *path_data;
+ espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS, 0, NULL, espeakINITIALIZE_DONT_EXIT);
+ version = espeak_Info(&path_data);
+ printf("eSpeak text-to-speech: %s Data at: %s\n", version, path_data);
+}
+
+
+
+#ifdef NEED_GETOPT
+ struct option {
+ char *name;
+ int has_arg;
+ int *flag;
+ int val;
+ };
+ int optind;
+ static int optional_argument;
+ static const char *arg_opts = "abfgklpsvw"; // which options have arguments
+ static char *opt_string="";
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+#endif
int main (int argc, char **argv)
//==============================
@@ -315,7 +379,10 @@ int main (int argc, char **argv)
{"stdout", no_argument, 0, 0x105},
{"split", optional_argument, 0, 0x106},
{"path", required_argument, 0, 0x107},
- {"phonout", required_argument, 0, 0x108},
+ {"phonout", required_argument, 0, 0x108},
+ {"pho", no_argument, 0, 0x109},
+ {"ipa", optional_argument, 0, 0x10a},
+ {"version", no_argument, 0, 0x10b},
{0, 0, 0, 0}
};
@@ -330,6 +397,7 @@ int main (int argc, char **argv)
int option_index = 0;
int c;
int ix;
+ char *optarg2;
int value;
int flag_stdin = 0;
int flag_compile = 0;
@@ -342,25 +410,78 @@ int main (int argc, char **argv)
int wordgap = -1;
int option_capitals = -1;
int option_punctuation = -1;
- int option_phonemes = -1;
+ int option_phonemes = 0;
+ int option_mbrola_phonemes = 0;
int option_linelength = 0;
int option_waveout = 0;
espeak_VOICE voice_select;
char filename[200];
char voicename[40];
- char voice_mbrola[20];
- char dictname[40];
#define N_PUNCTLIST 100
wchar_t option_punctlist[N_PUNCTLIST];
voicename[0] = 0;
- voice_mbrola[0] = 0;
- dictname[0] = 0;
wavefile[0] = 0;
filename[0] = 0;
option_punctlist[0] = 0;
+#ifdef NEED_GETOPT
+ optind = 1;
+ opt_string = "";
+ while(optind < argc)
+ {
+ int len;
+ char *p;
+
+ if((c = *opt_string) == 0)
+ {
+ opt_string = argv[optind];
+ if(opt_string[0] != '-')
+ break;
+
+ optind++;
+ opt_string++;
+ c = *opt_string;
+ }
+ opt_string++;
+ p = optarg2 = opt_string;
+
+ if(c == '-')
+ {
+ if(p[0] == 0)
+ break; // -- means don't interpret further - as commands
+
+ opt_string="";
+ for(ix=0; ;ix++)
+ {
+ if(long_options[ix].name == 0)
+ break;
+ len = strlen(long_options[ix].name);
+ if(memcmp(long_options[ix].name,p,len)==0)
+ {
+ c = long_options[ix].val;
+ optarg2 = NULL;
+
+ if((long_options[ix].has_arg != 0) && (p[len]=='='))
+ {
+ optarg2 = &p[len+1];
+ }
+ break;
+ }
+ }
+ }
+ else
+ if(strchr(arg_opts,c) != NULL)
+ {
+ opt_string="";
+ if(optarg2[0]==0)
+ {
+ // the option's value is in the next argument
+ optarg2 = argv[optind++];
+ }
+ }
+#else
while(true)
{
c = getopt_long (argc, argv, "a:b:f:g:hk:l:mp:qs:v:w:xXz",
@@ -369,12 +490,14 @@ int main (int argc, char **argv)
/* Detect the end of the options. */
if (c == -1)
break;
+ optarg2 = optarg;
+#endif
switch (c)
{
case 'b':
// input character encoding, 8bit, 16bit, UTF8
- if((sscanf(optarg,"%d",&value) == 1) && (value <= 4))
+ if((sscanf(optarg2,"%d",&value) == 1) && (value <= 4))
synth_flags |= value;
else
synth_flags |= espeakCHARS_8BIT;
@@ -382,12 +505,13 @@ int main (int argc, char **argv)
case 'h':
printf("\n");
- printf("eSpeak text-to-speech: %s\n%s",espeak_Info(),help_text);
+ PrintVersion();
+ printf("%s", help_text);
exit(0);
break;
case 'k':
- option_capitals = atoi(optarg);
+ option_capitals = atoi(optarg2);
break;
case 'x':
@@ -403,7 +527,7 @@ int main (int argc, char **argv)
break;
case 'p':
- pitch = atoi(optarg);
+ pitch = atoi(optarg2);
break;
case 'q':
@@ -411,32 +535,32 @@ int main (int argc, char **argv)
break;
case 'f':
- strncpy0(filename,optarg,sizeof(filename));
+ strncpy0(filename,optarg2,sizeof(filename));
break;
case 'l':
- option_linelength = atoi(optarg);
+ option_linelength = atoi(optarg2);
break;
case 'a':
- volume = atoi(optarg);
+ volume = atoi(optarg2);
break;
case 's':
- speed = atoi(optarg);
+ speed = atoi(optarg2);
break;
case 'g':
- wordgap = atoi(optarg);
+ wordgap = atoi(optarg2);
break;
case 'v':
- strncpy0(voicename,optarg,sizeof(voicename));
+ strncpy0(voicename,optarg2,sizeof(voicename));
break;
case 'w':
option_waveout = 1;
- strncpy0(wavefile,optarg,sizeof(filename));
+ strncpy0(wavefile,optarg2,sizeof(filename));
break;
case 'z': // remove pause from the end of a sentence
@@ -454,17 +578,17 @@ int main (int argc, char **argv)
case 0x101: // --compile-debug
case 0x102: // --compile
- strncpy0(voicename,optarg,sizeof(voicename));
+ strncpy0(voicename,optarg2,sizeof(voicename));
flag_compile = c;
quiet = 1;
break;
case 0x103: // --punct
option_punctuation = 1;
- if(optarg != NULL)
+ if(optarg2 != NULL)
{
ix = 0;
- while((ix < N_PUNCTLIST) && ((option_punctlist[ix] = optarg[ix]) != 0)) ix++;
+ while((ix < N_PUNCTLIST) && ((option_punctlist[ix] = optarg2[ix]) != 0)) ix++;
option_punctlist[N_PUNCTLIST-1] = 0;
option_punctuation = 2;
}
@@ -472,27 +596,50 @@ int main (int argc, char **argv)
case 0x104: // --voices
espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,data_path,0);
- DisplayVoices(stdout,optarg);
+ DisplayVoices(stdout,optarg2);
exit(0);
case 0x106: // -- split
- if(optarg == NULL)
- samples_split = 30; // default 30 minutes
+ if(optarg2 == NULL)
+ samples_split_seconds = 30 * 60; // default 30 minutes
else
- samples_split = atoi(optarg);
+ samples_split_seconds = atoi(optarg2) * 60;
break;
case 0x107: // --path
- data_path = optarg;
+ data_path = optarg2;
break;
case 0x108: // --phonout
- if((f_phonemes_out = fopen(optarg,"w")) == NULL)
+ if((f_phonemes_out = fopen(optarg2,"w")) == NULL)
+ {
+ fprintf(stderr,"Can't write to: %s\n",optarg2);
+ }
+ break;
+
+ case 0x109: // --pho
+ option_mbrola_phonemes = 16;
+ break;
+
+ case 0x10a: // --ipa
+ option_phonemes = 3;
+ if(optarg2 != NULL)
{
- fprintf(stderr,"Can't write to: %s\n",optarg);
+ value = -1;
+ sscanf(optarg2,"%d",&value);
+ if((value<0) || (value>3))
+ {
+ fprintf(stderr,"Bad value for -ipa=\n");
+ value = 0;
+ }
+ option_phonemes += value;
}
break;
+ case 0x10b: // -version
+ PrintVersion();
+ exit(0);
+
default:
exit(0);
}
@@ -503,7 +650,7 @@ int main (int argc, char **argv)
{
// writing to a file (or no output), we can use synchronous mode
samplerate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,data_path,0);
- samples_split = (samplerate * samples_split) * 60;
+ samples_split = samplerate * samples_split_seconds;
espeak_SetSynthCallback(SynthCallback);
if(samples_split)
@@ -516,12 +663,6 @@ int main (int argc, char **argv)
*extn = 0;
}
}
- else
- if(option_waveout)
- {
- if(OpenWavFile(wavefile,samplerate) != 0)
- exit(4);
- }
}
else
{
@@ -568,7 +709,7 @@ int main (int argc, char **argv)
espeak_SetParameter(espeakLINELENGTH,option_linelength,0);
if(option_punctuation == 2)
espeak_SetPunctuationList(option_punctlist);
- espeak_SetPhonemeTrace(option_phonemes,f_phonemes_out);
+ espeak_SetPhonemeTrace(option_phonemes | option_mbrola_phonemes,f_phonemes_out);
if(filename[0]==0)
{
@@ -651,13 +792,18 @@ int main (int argc, char **argv)
exit(3);
}
- fread(p_text,1,filesize,f_text);
+ if(fread(p_text,1,filesize,f_text) <= 0)
+ fprintf(stderr, "unable to read from file\n");
p_text[filesize]=0;
espeak_Synth(p_text,filesize+1,0,POS_CHARACTER,0,synth_flags,NULL,NULL);
fclose(f_text);
}
- espeak_Synchronize();
+ if(espeak_Synchronize() != EE_OK)
+ {
+ fprintf(stderr, "espeak_Synchronize() failed, maybe error when opening output device\n");
+ exit(4);
+ }
if(f_phonemes_out != stdout)
fclose(f_phonemes_out); // needed for WinCE
diff --git a/navit/support/espeak/espeak_command.c b/navit/support/espeak/espeak_command.c
index 1b59333c1..d8460c75a 100644
--- a/navit/support/espeak/espeak_command.c
+++ b/navit/support/espeak/espeak_command.c
@@ -46,14 +46,14 @@ t_espeak_command* create_espeak_text(const void *text, size_t size, unsigned int
{
goto text_error;
}
-
- a_text = malloc( size );
+
+ a_text = malloc( size+1 );
if (!a_text)
{
goto text_error;
}
memcpy(a_text, text, size);
-
+
a_command->type = ET_TEXT;
a_command->state = CS_UNDEFINED;
data = &(a_command->u.my_text);
@@ -102,7 +102,7 @@ t_espeak_command* create_espeak_terminated_msg(unsigned int unique_identifier, v
{
goto msg_error;
}
-
+
a_command->type = ET_TERMINATED_MSG;
a_command->state = CS_UNDEFINED;
data = &(a_command->u.my_terminated_msg);
@@ -234,7 +234,7 @@ t_espeak_command* create_espeak_char(wchar_t character, void* user_data)
{
goto char_error;
}
-
+
a_command->type = ET_CHAR;
a_command->state = CS_UNDEFINED;
a_command->u.my_char.user_data = user_data;
@@ -270,11 +270,11 @@ t_espeak_command* create_espeak_parameter(espeak_PARAMETER parameter, int value,
{
goto param_error;
}
-
+
a_command->type = ET_PARAMETER;
a_command->state = CS_UNDEFINED;
data = &(a_command->u.my_param);
- data->parameter = parameter;
+ data->parameter = parameter;
data->value = value;
data->relative = relative;
a_error=0;
@@ -308,7 +308,7 @@ t_espeak_command* create_espeak_punctuation_list(const wchar_t *punctlist)
{
goto list_error;
}
-
+
a_command->type = ET_PUNCTUATION_LIST;
a_command->state = CS_UNDEFINED;
@@ -350,7 +350,7 @@ t_espeak_command* create_espeak_voice_name(const char *name)
{
goto name_error;
}
-
+
a_command->type = ET_VOICE_NAME;
a_command->state = CS_UNDEFINED;
a_command->u.my_voice_name = strdup( name);
@@ -381,7 +381,7 @@ t_espeak_command* create_espeak_voice_spec(espeak_VOICE *voice)
{
goto spec_error;
}
-
+
a_command->type = ET_VOICE_SPEC;
a_command->state = CS_UNDEFINED;
{
@@ -451,11 +451,11 @@ int delete_espeak_command( t_espeak_command* the_command)
break;
case ET_TERMINATED_MSG:
- {
+ {
// if the terminated msg is pending,
- // it must be processed here for informing the calling program
+ // it must be processed here for informing the calling program
// that its message is finished.
- // This can be important for cleaning the related user data.
+ // This can be important for cleaning the related user data.
t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg);
if (the_command->state == CS_PENDING)
{
@@ -491,7 +491,7 @@ int delete_espeak_command( t_espeak_command* the_command)
free((void*)(the_command->u.my_voice_name));
}
break;
-
+
case ET_VOICE_SPEC:
{
espeak_VOICE* data = &(the_command->u.my_voice_spec);
@@ -542,23 +542,23 @@ void process_espeak_command( t_espeak_command* the_command)
case ET_TEXT:
{
t_espeak_text* data = &(the_command->u.my_text);
- sync_espeak_Synth( data->unique_identifier, data->text, data->size,
- data->position, data->position_type,
- data->end_position, data->flags, data->user_data);
+ sync_espeak_Synth( data->unique_identifier, data->text, data->size,
+ data->position, data->position_type,
+ data->end_position, data->flags, data->user_data);
}
break;
case ET_MARK:
{
t_espeak_mark* data = &(the_command->u.my_mark);
- sync_espeak_Synth_Mark( data->unique_identifier, data->text, data->size,
- data->index_mark, data->end_position, data->flags,
+ sync_espeak_Synth_Mark( data->unique_identifier, data->text, data->size,
+ data->index_mark, data->end_position, data->flags,
data->user_data);
}
break;
case ET_TERMINATED_MSG:
- {
+ {
t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg);
sync_espeak_terminated_msg( data->unique_identifier, data->user_data);
}
@@ -645,7 +645,7 @@ void display_espeak_command( t_espeak_command* the_command)
case ET_KEY:
{
- const char* data = the_command->u.my_key;
+ const char* data = the_command->u.my_key.key_name;
SHOW("display_espeak_command > (0x%x) KEY=%c\n", the_command, data);
}
break;
@@ -654,15 +654,15 @@ void display_espeak_command( t_espeak_command* the_command)
{
t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg);
- SHOW("display_espeak_command > (0x%x) TERMINATED_MSG uid=%d, user_data=0x%x, state=%d\n",
- the_command, data->unique_identifier, data->user_data,
+ SHOW("display_espeak_command > (0x%x) TERMINATED_MSG uid=%d, user_data=0x%x, state=%d\n",
+ the_command, data->unique_identifier, data->user_data,
the_command->state);
}
break;
case ET_CHAR:
{
- const wchar_t data = the_command->u.my_char;
+ const wchar_t data = the_command->u.my_char.character;
SHOW("display_espeak_command > (0x%x) CHAR=%c\n", the_command, (char)data);
}
break;
@@ -670,7 +670,7 @@ void display_espeak_command( t_espeak_command* the_command)
case ET_PARAMETER:
{
t_espeak_parameter* data = &(the_command->u.my_param);
- SHOW("display_espeak_command > (0x%x) PARAMETER=%d, value=%d, relative=%d\n",
+ SHOW("display_espeak_command > (0x%x) PARAMETER=%d, value=%d, relative=%d\n",
the_command, data->parameter, data->value, data->relative);
}
break;
diff --git a/navit/support/espeak/espeak_command.h b/navit/support/espeak/espeak_command.h
index b2664be6a..5a6592f39 100644
--- a/navit/support/espeak/espeak_command.h
+++ b/navit/support/espeak/espeak_command.h
@@ -19,7 +19,7 @@ enum t_espeak_type
ET_TERMINATED_MSG
};
-typedef struct
+typedef struct
{
unsigned int unique_identifier;
void* text;
@@ -31,7 +31,7 @@ typedef struct
void* user_data;
} t_espeak_text;
-typedef struct
+typedef struct
{
unsigned int unique_identifier;
void* text;
@@ -42,53 +42,53 @@ typedef struct
void* user_data;
} t_espeak_mark;
-typedef struct
+typedef struct
{
unsigned int unique_identifier;
void* user_data;
- wchar_t character;
+ wchar_t character;
} t_espeak_character;
-typedef struct
+typedef struct
{
unsigned int unique_identifier;
void* user_data;
- const char* key_name;
+ const char* key_name;
} t_espeak_key;
-typedef struct
+typedef struct
{
unsigned int unique_identifier;
void* user_data;
} t_espeak_terminated_msg;
-typedef struct
+typedef struct
{
- espeak_PARAMETER parameter;
- int value;
+ espeak_PARAMETER parameter;
+ int value;
int relative;
} t_espeak_parameter;
-enum t_command_state
+enum t_command_state
{
CS_UNDEFINED, // The command has just been created
CS_PENDING, // stored in the fifo
CS_PROCESSED // processed
};
-typedef struct
+typedef struct
{
enum t_espeak_type type;
- enum t_command_state state;
+ enum t_command_state state;
union command
{
- t_espeak_text my_text;
- t_espeak_mark my_mark;
- t_espeak_key my_key;
- t_espeak_character my_char;
+ t_espeak_text my_text;
+ t_espeak_mark my_mark;
+ t_espeak_key my_key;
+ t_espeak_character my_char;
t_espeak_parameter my_param;
const wchar_t* my_punctuation_list;
const char *my_voice_name;
@@ -123,11 +123,11 @@ int delete_espeak_command( t_espeak_command* the_command);
void display_espeak_command(t_espeak_command* the_command);
-espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, size_t size,
- unsigned int position, espeak_POSITION_TYPE position_type,
+espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, size_t size,
+ unsigned int position, espeak_POSITION_TYPE position_type,
unsigned int end_position, unsigned int flags, void* user_data);
-espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size,
- const char *index_mark, unsigned int end_position,
+espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size,
+ const char *index_mark, unsigned int end_position,
unsigned int flags, void* user_data);
void sync_espeak_Key(const char *key);
void sync_espeak_Char(wchar_t character);
diff --git a/navit/support/espeak/event.c b/navit/support/espeak/event.c
index cc696272d..f41c65950 100644
--- a/navit/support/espeak/event.c
+++ b/navit/support/espeak/event.c
@@ -24,7 +24,9 @@
//<includes
+#ifndef PLATFORM_WINDOWS
#include <unistd.h>
+#endif
#include <assert.h>
#include <string.h>
#include <stdlib.h>
@@ -41,20 +43,21 @@
//<decls and function prototypes
-// my_mutex: protects my_thread_is_talking,
+// my_mutex: protects my_thread_is_talking,
static pthread_mutex_t my_mutex;
static sem_t my_sem_start_is_required;
static sem_t my_sem_stop_is_required;
static sem_t my_sem_stop_is_acknowledged;
// my_thread: polls the audio duration and compares it to the duration of the first event.
static pthread_t my_thread;
+static bool thread_inited;
static t_espeak_callback* my_callback = NULL;
static int my_event_is_running=0;
enum {MIN_TIMEOUT_IN_MS=10,
ACTIVITY_TIMEOUT=50, // in ms, check that the stream is active
- MAX_ACTIVITY_CHECK=6
+ MAX_ACTIVITY_CHECK=6
};
@@ -94,17 +97,17 @@ void event_init(void)
assert(-1 != sem_init(&my_sem_stop_is_required, 0, 0));
assert(-1 != sem_init(&my_sem_stop_is_acknowledged, 0, 0));
- pthread_attr_t a_attrib;
- if (pthread_attr_init (& a_attrib)
- || pthread_attr_setdetachstate(&a_attrib, PTHREAD_CREATE_JOINABLE)
- || pthread_create( &my_thread,
- & a_attrib,
- polling_thread,
- (void*)NULL))
- {
- assert(0);
- }
-
+ pthread_attr_t a_attrib;
+
+ if (pthread_attr_init (&a_attrib) == 0
+ && pthread_attr_setdetachstate(&a_attrib, PTHREAD_CREATE_JOINABLE) == 0)
+ {
+ thread_inited = (0 == pthread_create(&my_thread,
+ &a_attrib,
+ polling_thread,
+ (void*)NULL));
+ }
+ assert(thread_inited);
pthread_attr_destroy(&a_attrib);
}
//>
@@ -127,7 +130,10 @@ ENTER("event_display");
"MARK",
"PLAY",
"END",
- "MSG_TERMINATED"
+ "MSG_TERMINATED",
+ "PHONEME",
+ "SAMPLERATE",
+ "??"
};
SHOW("event_display > event=0x%x\n",event);
@@ -147,17 +153,17 @@ ENTER("event_display");
static espeak_EVENT* event_copy (espeak_EVENT* event)
{
ENTER("event_copy");
-
+
if (event==NULL)
{
return NULL;
}
-
+
espeak_EVENT* a_event=(espeak_EVENT*)malloc(sizeof(espeak_EVENT));
if (a_event)
{
memcpy(a_event, event, sizeof(espeak_EVENT));
-
+
switch(event->type)
{
case espeakEVENT_MARK:
@@ -167,14 +173,14 @@ static espeak_EVENT* event_copy (espeak_EVENT* event)
a_event->id.name = strdup(event->id.name);
}
break;
-
+
default:
break;
}
}
-
+
event_display(a_event);
-
+
return a_event;
}
@@ -288,7 +294,7 @@ ENTER("event_declare");
return EE_INTERNAL_ERROR;
}
- int a_status = pthread_mutex_lock(&my_mutex);
+ int a_status = pthread_mutex_lock(&my_mutex);
espeak_ERROR a_error = EE_OK;
if (!a_status)
@@ -310,7 +316,7 @@ ENTER("event_declare");
//
// if (!a_status && !my_event_is_running && (a_error == EE_OK))
// {
-// // quit when command is actually started
+// // quit when command is actually started
// // (for possible forthcoming 'end of command' checks)
SHOW_TIME("event_declare > post my_sem_start_is_required\n");
sem_post(&my_sem_start_is_required);
@@ -386,28 +392,32 @@ static int sleep_until_timeout_or_stop_request(uint32_t time_in_ms)
ENTER("sleep_until_timeout_or_stop_request");
int a_stop_is_required=0;
- struct timespec ts, to;
+ struct timespec ts;
struct timeval tv;
int err=0;
clock_gettime2( &ts);
+
+#ifdef DEBUG_ENABLED
+ struct timespec to;
to.tv_sec = ts.tv_sec;
to.tv_nsec = ts.tv_nsec;
+#endif
add_time_in_ms( &ts, time_in_ms);
- SHOW("polling_thread > sleep_until_timeout_or_stop_request > start sem_timedwait from %d.%09lu to %d.%09lu \n",
+ SHOW("polling_thread > sleep_until_timeout_or_stop_request > start sem_timedwait from %d.%09lu to %d.%09lu \n",
to.tv_sec, to.tv_nsec,
ts.tv_sec, ts.tv_nsec);
- while ((err = sem_timedwait(&my_sem_stop_is_required, &ts)) == -1
+ while ((err = sem_timedwait(&my_sem_stop_is_required, &ts)) == -1
&& errno == EINTR)
{
continue; // Restart when interrupted by handler
}
assert (gettimeofday(&tv, NULL) != -1);
- SHOW("polling_thread > sleep_until_timeout_or_stop_request > stop sem_timedwait %d.%09lu \n",
+ SHOW("polling_thread > sleep_until_timeout_or_stop_request > stop sem_timedwait %d.%09lu \n",
tv.tv_sec, tv.tv_usec*1000);
if (err == 0)
@@ -421,7 +431,7 @@ ENTER("sleep_until_timeout_or_stop_request");
//>
//<get_remaining_time
// Asked for the time interval required for reaching the sample.
-// If the stream is opened but the audio samples are not played,
+// If the stream is opened but the audio samples are not played,
// a timeout is started.
static int get_remaining_time(uint32_t sample, uint32_t* time_in_ms, int* stop_is_required)
@@ -445,18 +455,18 @@ ENTER("get_remaining_time");
// stream opened but not active
//
- // Several possible states:
- // * the stream is opened but not yet started:
+ // Several possible states:
+ // * the stream is opened but not yet started:
//
// wait for the start of stream
//
- // * some samples have already been played,
+ // * some samples have already been played,
// ** the end of stream is reached
// ** or there is an underrun
- //
+ //
// wait for the close of stream
- *stop_is_required = sleep_until_timeout_or_stop_request( ACTIVITY_TIMEOUT);
+ *stop_is_required = sleep_until_timeout_or_stop_request( ACTIVITY_TIMEOUT);
}
return err;
@@ -496,8 +506,8 @@ ENTER("polling_thread");
SHOW_TIME("polling_thread > unlocked\n");
a_stop_is_required=0;
- a_status = sem_getvalue(&my_sem_stop_is_required, &a_stop_is_required);
- if ((a_status==0) && a_stop_is_required)
+ a_status = sem_getvalue(&my_sem_stop_is_required, &a_stop_is_required); // NOTE: may set a_stop_is_required to -1
+ if ((a_status==0) && (a_stop_is_required > 0))
{
SHOW("polling_thread > stop required (%d)\n", __LINE__);
while(0 == sem_trywait(&my_sem_stop_is_required))
@@ -510,27 +520,27 @@ ENTER("polling_thread");
}
// In this loop, my_event_is_running = 1
- while (head && !a_stop_is_required)
+ while (head && (a_stop_is_required <= 0))
{
SHOW_TIME("polling_thread > check head\n");
while(0 == sem_trywait(&my_sem_start_is_required))
{
};
-
+
espeak_EVENT* event = (espeak_EVENT*)(head->data);
assert(event);
-
+
uint32_t time_in_ms = 0;
-
- int err = get_remaining_time((uint32_t)event->sample,
- &time_in_ms,
+
+ int err = get_remaining_time((uint32_t)event->sample,
+ &time_in_ms,
&a_stop_is_required);
- if (a_stop_is_required)
+ if (a_stop_is_required > 0)
{
break;
}
else if (err != 0)
- {
+ {
// No available time: the event is deleted.
SHOW("polling_thread > %s\n","audio device down");
a_status = pthread_mutex_lock(&my_mutex);
@@ -544,22 +554,22 @@ ENTER("polling_thread");
if (my_callback)
{
event_notify(event);
- // the user_data (and the type) are cleaned to be sure
+ // the user_data (and the type) are cleaned to be sure
// that MSG_TERMINATED is called twice (at delete time too).
event->type=espeakEVENT_LIST_TERMINATED;
event->user_data=NULL;
}
-
+
a_status = pthread_mutex_lock(&my_mutex);
SHOW_TIME("polling_thread > locked\n");
event_delete( (espeak_EVENT*)pop());
a_status = pthread_mutex_unlock(&my_mutex);
SHOW_TIME("polling_thread > unlocked\n");
-
+
a_stop_is_required=0;
a_status = sem_getvalue(&my_sem_stop_is_required, &a_stop_is_required);
-
- if ((a_status==0) && a_stop_is_required)
+
+ if ((a_status==0) && (a_stop_is_required > 0))
{
SHOW("polling_thread > stop required (%d)\n", __LINE__);
while(0 == sem_trywait(&my_sem_stop_is_required))
@@ -576,17 +586,17 @@ ENTER("polling_thread");
a_stop_is_required = sleep_until_timeout_or_stop_request(time_in_ms);
}
}
-
+
a_status = pthread_mutex_lock(&my_mutex);
SHOW_TIME("polling_thread > locked\n");
-
+
SHOW_TIME("polling_thread > my_event_is_running = 0\n");
my_event_is_running = 0;
-
- if(!a_stop_is_required)
+
+ if(a_stop_is_required <= 0)
{
a_status = sem_getvalue(&my_sem_stop_is_required, &a_stop_is_required);
- if ((a_status==0) && a_stop_is_required)
+ if ((a_status==0) && (a_stop_is_required > 0))
{
SHOW("polling_thread > stop required (%d)\n", __LINE__);
while(0 == sem_trywait(&my_sem_stop_is_required))
@@ -602,8 +612,8 @@ ENTER("polling_thread");
a_status = pthread_mutex_unlock(&my_mutex);
SHOW_TIME("polling_thread > unlocked\n");
- if (a_stop_is_required)
- {
+ if (a_stop_is_required > 0)
+ {
SHOW("polling_thread > %s\n","stop required!");
// no mutex required since the stop command is synchronous
// and waiting for my_sem_stop_is_acknowledged
@@ -639,13 +649,13 @@ static espeak_ERROR push(void* the_data)
SHOW("event > push > %s\n", "EE_BUFFER_FULL");
return EE_BUFFER_FULL;
}
-
+
node *n = (node *)malloc(sizeof(node));
if (n == NULL)
{
return EE_INTERNAL_ERROR;
}
-
+
if (head == NULL)
{
head = n;
@@ -656,13 +666,13 @@ static espeak_ERROR push(void* the_data)
tail->next = n;
tail = n;
}
-
+
tail->next = NULL;
tail->data = the_data;
-
+
node_counter++;
SHOW("event > push > counter=%d (uid=%d)\n",node_counter,((espeak_EVENT*)the_data)->unique_identifier);
-
+
return EE_OK;
}
@@ -670,9 +680,9 @@ static void* pop()
{
ENTER("event > pop");
void* the_data = NULL;
-
+
assert((!head && !tail) || (head && tail));
-
+
if (head != NULL)
{
node* n = head;
@@ -682,12 +692,12 @@ static void* pop()
node_counter--;
SHOW("event > pop > event=0x%x (counter=%d, uid=%d)\n",the_data, node_counter,((espeak_EVENT*)the_data)->unique_identifier);
}
-
+
if(head == NULL)
{
tail = NULL;
}
-
+
return the_data;
}
@@ -695,10 +705,10 @@ static void* pop()
static void init()
{
ENTER("event > init");
-
+
while (event_delete( (espeak_EVENT*)pop() ))
{}
-
+
node_counter = 0;
}
@@ -707,8 +717,8 @@ static void init()
void event_terminate()
{
ENTER("event_terminate");
-
- if (my_thread)
+
+ if (thread_inited)
{
pthread_cancel(my_thread);
pthread_join(my_thread,NULL);
@@ -717,6 +727,7 @@ ENTER("event_terminate");
sem_destroy(&my_sem_stop_is_required);
sem_destroy(&my_sem_stop_is_acknowledged);
init(); // purge event
+ thread_inited = 0;
}
}
diff --git a/navit/support/espeak/event.h b/navit/support/espeak/event.h
index c9ee482b0..b158d5eb3 100644
--- a/navit/support/espeak/event.h
+++ b/navit/support/espeak/event.h
@@ -34,7 +34,7 @@ void event_set_callback(t_espeak_callback* cb);
//
// Return: EE_OK: operation achieved
// EE_INTERNAL_ERROR.
-espeak_ERROR event_clear_all ();
+espeak_ERROR event_clear_all (void);
// Declare a future event
//
@@ -46,6 +46,6 @@ espeak_ERROR event_declare (espeak_EVENT* event);
// Terminate the event component.
// Last function to be called.
-void event_terminate();
+void event_terminate(void);
#endif
diff --git a/navit/support/espeak/fifo.c b/navit/support/espeak/fifo.c
index 95d5ab1ed..97c0fb9cc 100644
--- a/navit/support/espeak/fifo.c
+++ b/navit/support/espeak/fifo.c
@@ -24,7 +24,9 @@
//<includes
+#ifndef PLATFORM_WINDOWS
#include <unistd.h>
+#endif
#include <assert.h>
#include <string.h>
#include <stdlib.h>
@@ -43,7 +45,7 @@
//>
//<decls and function prototypes
-// my_mutex: protects my_thread_is_talking,
+// my_mutex: protects my_thread_is_talking,
// my_stop_is_required, and the command fifo
static pthread_mutex_t my_mutex;
static int my_command_is_running = 0;
@@ -51,7 +53,7 @@ static int my_stop_is_required = 0;
// + fifo
//
-// my_thread: reads commands from the fifo, and runs them.
+// my_thread: reads commands from the fifo, and runs them.
static pthread_t my_thread;
static sem_t my_sem_start_is_required;
static sem_t my_sem_stop_is_acknowledged;
@@ -60,7 +62,7 @@ static void* say_thread(void*);
static espeak_ERROR push(t_espeak_command* the_command);
static t_espeak_command* pop();
-static void init();
+static void init(int process_parameters);
static int node_counter=0;
enum {MAX_NODE_COUNTER=400,
INACTIVITY_TIMEOUT=50, // in ms, check that the stream is inactive
@@ -75,17 +77,17 @@ void fifo_init()
// security
pthread_mutex_init( &my_mutex, (const pthread_mutexattr_t *)NULL);
- init();
+ init(0);
assert(-1 != sem_init(&my_sem_start_is_required, 0, 0));
assert(-1 != sem_init(&my_sem_stop_is_acknowledged, 0, 0));
- pthread_attr_t a_attrib;
+ pthread_attr_t a_attrib;
if (pthread_attr_init (& a_attrib)
|| pthread_attr_setdetachstate(&a_attrib, PTHREAD_CREATE_JOINABLE)
- || pthread_create( &my_thread,
- & a_attrib,
- say_thread,
+ || pthread_create( &my_thread,
+ & a_attrib,
+ say_thread,
(void*)NULL))
{
assert(0);
@@ -107,8 +109,8 @@ void fifo_init()
espeak_ERROR fifo_add_command (t_espeak_command* the_command)
{
ENTER("fifo_add_command");
-
- int a_status = pthread_mutex_lock(&my_mutex);
+
+ int a_status = pthread_mutex_lock(&my_mutex);
espeak_ERROR a_error = EE_OK;
if (!a_status)
@@ -121,12 +123,12 @@ espeak_ERROR fifo_add_command (t_espeak_command* the_command)
if (!a_status && !my_command_is_running && (a_error == EE_OK))
{
- // quit when command is actually started
+ // quit when command is actually started
// (for possible forthcoming 'end of command' checks)
SHOW_TIME("fifo_add_command > post my_sem_start_is_required\n");
sem_post(&my_sem_start_is_required);
int val=1;
- while (val)
+ while (val > 0)
{
usleep(50000); // TBD: event?
sem_getvalue(&my_sem_start_is_required, &val);
@@ -148,8 +150,8 @@ espeak_ERROR fifo_add_command (t_espeak_command* the_command)
espeak_ERROR fifo_add_commands (t_espeak_command* command1, t_espeak_command* command2)
{
ENTER("fifo_add_command");
-
- int a_status = pthread_mutex_lock(&my_mutex);
+
+ int a_status = pthread_mutex_lock(&my_mutex);
espeak_ERROR a_error = EE_OK;
if (!a_status)
@@ -172,12 +174,12 @@ espeak_ERROR fifo_add_commands (t_espeak_command* command1, t_espeak_command* co
if (!a_status && !my_command_is_running && (a_error == EE_OK))
{
- // quit when one command is actually started
+ // quit when one command is actually started
// (for possible forthcoming 'end of command' checks)
SHOW_TIME("fifo_add_command > post my_sem_start_is_required\n");
sem_post(&my_sem_start_is_required);
int val=1;
- while (val)
+ while (val > 0)
{
usleep(50000); // TBD: event?
sem_getvalue(&my_sem_start_is_required, &val);
@@ -275,54 +277,58 @@ static int sleep_until_start_request_or_inactivity()
int a_start_is_required=0;
// Wait for the start request (my_sem_start_is_required).
- // Besides this, if the audio stream is still busy,
- // check from time to time its end.
- // The end of the stream is confirmed by several checks
+ // Besides this, if the audio stream is still busy,
+ // check from time to time its end.
+ // The end of the stream is confirmed by several checks
// for filtering underflow.
//
int i=0;
- while((i<= MAX_INACTIVITY_CHECK) && !a_start_is_required)
- {
- if (wave_is_busy( NULL) )
+ while((i<= MAX_INACTIVITY_CHECK) && !a_start_is_required)
{
- i = 0;
- }
+ if (wave_is_busy( NULL) )
+ {
+ i = 0;
+ }
else
- {
- i++;
- }
+ {
+ i++;
+ }
- int err=0;
- struct timespec ts, to;
- struct timeval tv;
-
- clock_gettime2( &ts);
- to.tv_sec = ts.tv_sec;
- to.tv_nsec = ts.tv_nsec;
-
- add_time_in_ms( &ts, INACTIVITY_TIMEOUT);
-
- SHOW("fifo > sleep_until_start_request_or_inactivity > start sem_timedwait (start_is_required) from %d.%09lu to %d.%09lu \n",
- to.tv_sec, to.tv_nsec,
- ts.tv_sec, ts.tv_nsec);
-
- while ((err = sem_timedwait(&my_sem_start_is_required, &ts)) == -1
- && errno == EINTR)
- {
- continue;
- }
-
- assert (gettimeofday(&tv, NULL) != -1);
- SHOW("fifo > sleep_until_start_request_or_inactivity > stop sem_timedwait (start_is_required, err=%d) %d.%09lu \n", err,
- tv.tv_sec, tv.tv_usec*1000);
-
- if (err==0)
- {
- a_start_is_required = 1;
+ int err=0;
+ struct timespec ts;
+ struct timeval tv;
+
+ clock_gettime2( &ts);
+
+#ifdef DEBUG_ENABLED
+ struct timespec to;
+ to.tv_sec = ts.tv_sec;
+ to.tv_nsec = ts.tv_nsec;
+#endif
+
+ add_time_in_ms( &ts, INACTIVITY_TIMEOUT);
+
+ SHOW("fifo > sleep_until_start_request_or_inactivity > start sem_timedwait (start_is_required) from %d.%09lu to %d.%09lu \n",
+ to.tv_sec, to.tv_nsec,
+ ts.tv_sec, ts.tv_nsec);
+
+ while ((err = sem_timedwait(&my_sem_start_is_required, &ts)) == -1
+ && errno == EINTR)
+ {
+ continue;
+ }
+
+ assert (gettimeofday(&tv, NULL) != -1);
+ SHOW("fifo > sleep_until_start_request_or_inactivity > stop sem_timedwait (start_is_required, err=%d) %d.%09lu \n", err,
+ tv.tv_sec, tv.tv_usec*1000);
+
+ if (err==0)
+ {
+ a_start_is_required = 1;
+ }
}
- }
- SHOW_TIME("fifo > sleep_until_start_request_or_inactivity > LEAVE");
- return a_start_is_required;
+ SHOW_TIME("fifo > sleep_until_start_request_or_inactivity > LEAVE");
+ return a_start_is_required;
}
//>
@@ -332,8 +338,8 @@ static void close_stream()
{
SHOW_TIME("fifo > close_stream > ENTER\n");
- // Warning: a wave_close can be already required by
- // an external command (espeak_Cancel + fifo_stop), if so:
+ // Warning: a wave_close can be already required by
+ // an external command (espeak_Cancel + fifo_stop), if so:
// my_stop_is_required = 1;
int a_status = pthread_mutex_lock(&my_mutex);
@@ -355,7 +361,7 @@ static void close_stream()
a_stop_is_required = my_stop_is_required;
a_status = pthread_mutex_unlock(&my_mutex);
-
+
if (a_stop_is_required)
{
// acknowledge the stop request
@@ -434,7 +440,7 @@ static void* say_thread(void*)
};
if (my_stop_is_required)
- {
+ {
SHOW_TIME("say_thread > my_command_is_running = 0\n");
my_command_is_running = 0;
}
@@ -450,26 +456,26 @@ static void* say_thread(void*)
}
if (my_stop_is_required)
- {
+ {
// no mutex required since the stop command is synchronous
// and waiting for my_sem_stop_is_acknowledged
- init();
+ init(1);
// purge start semaphore
SHOW_TIME("say_thread > purge my_sem_start_is_required\n");
while(0==sem_trywait(&my_sem_start_is_required))
{
};
-
+
// acknowledge the stop request
SHOW_TIME("say_thread > post my_sem_stop_is_acknowledged\n");
int a_status = sem_post(&my_sem_stop_is_acknowledged);
assert( a_status != -1);
}
// and wait for the next start
- SHOW_TIME("say_thread > wait for my_sem_start_is_required\n");
+ SHOW_TIME("say_thread > wait for my_sem_start_is_required\n");
}
-
+
return NULL;
}
@@ -513,7 +519,7 @@ static espeak_ERROR push(t_espeak_command* the_command)
{
return EE_INTERNAL_ERROR;
}
-
+
if (head == NULL)
{
head = n;
@@ -524,7 +530,7 @@ static espeak_ERROR push(t_espeak_command* the_command)
tail->next = n;
tail = n;
}
-
+
tail->next = NULL;
tail->data = the_command;
@@ -560,19 +566,29 @@ static t_espeak_command* pop()
}
display_espeak_command(the_command);
-
+
return the_command;
}
-static void init()
+static void init(int process_parameters)
{
- ENTER("fifo > init");
- while (delete_espeak_command( pop() ))
- {}
- node_counter = 0;
+ // Changed by Tyler Spivey 30.Nov.2011
+ t_espeak_command *c = NULL;
+ ENTER("fifo > init");
+ c = pop();
+ while (c != NULL) {
+ if (process_parameters && (c->type == ET_PARAMETER || c->type == ET_VOICE_NAME || c->type == ET_VOICE_SPEC))
+ {
+ process_espeak_command(c);
+ }
+ delete_espeak_command(c);
+ c = pop();
+ }
+ node_counter = 0;
}
+
//>
//<fifo_init
void fifo_terminate()
@@ -585,7 +601,7 @@ void fifo_terminate()
sem_destroy(&my_sem_start_is_required);
sem_destroy(&my_sem_stop_is_acknowledged);
- init(); // purge fifo
+ init(0); // purge fifo
}
#endif
diff --git a/navit/support/espeak/fifo.h b/navit/support/espeak/fifo.h
index b3699ff9b..0077d5db6 100644
--- a/navit/support/espeak/fifo.h
+++ b/navit/support/espeak/fifo.h
@@ -9,7 +9,7 @@
// Initialize the fifo component.
// First function to be called.
-void fifo_init();
+void fifo_init(void);
// Add an espeak command.
//
@@ -36,15 +36,15 @@ espeak_ERROR fifo_add_commands (t_espeak_command* c1, t_espeak_command* c2);
// The current running command must be stopped and the awaiting commands are cleared.
// Return: EE_OK: operation achieved
// EE_INTERNAL_ERROR.
-espeak_ERROR fifo_stop ();
+espeak_ERROR fifo_stop (void);
// Is there a running command?
// Returns 1 if yes; 0 otherwise.
-int fifo_is_busy ();
+int fifo_is_busy (void);
// Terminate the fifo component.
// Last function to be called.
-void fifo_terminate();
+void fifo_terminate(void);
// Indicates if the running command is still enabled.
//
@@ -53,6 +53,6 @@ void fifo_terminate();
// stopping speech as soon as a cancel command is applied.
//
// Returns 1 if yes, or 0 otherwise.
-int fifo_is_command_enabled();
+int fifo_is_command_enabled(void);
#endif
diff --git a/navit/support/espeak/intonation.c b/navit/support/espeak/intonation.c
index 61b2ff282..04d72a9c8 100755..100644
--- a/navit/support/espeak/intonation.c
+++ b/navit/support/espeak/intonation.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <wctype.h>
#include "speak_lib.h"
@@ -45,8 +46,8 @@ typedef struct {
char env;
char flags; //bit 0=pitch rising, bit1=emnphasized, bit2=end of clause
char nextph_type;
- short pitch1;
- short pitch2;
+ unsigned char pitch1;
+ unsigned char pitch2;
} SYLLABLE;
static SYLLABLE *syllable_tab;
@@ -61,10 +62,10 @@ static int tone_pitch_env; /* used to return pitch envelope */
#define PITCHfall 0
-#define PITCHrise 1
-#define PITCHfrise 2 // and 3 must be for the varient preceded by 'r'
-#define PITCHfrise2 4 // and 5 must be the 'r' variant
-#define PITCHrisefall 6
+#define PITCHrise 2
+#define PITCHfrise 4 // and 3 must be for the variant preceded by 'r'
+#define PITCHfrise2 6 // and 5 must be the 'r' variant
+#define PITCHrisefall 8
/* 0 fall */
unsigned char env_fall[128] = {
@@ -191,9 +192,9 @@ static unsigned char env_risefallrise[128] = {
-unsigned char *envelope_data[18] = {
- env_fall,
- env_rise,
+unsigned char *envelope_data[N_ENVELOPE_DATA] = {
+ env_fall, env_fall,
+ env_rise, env_rise,
env_frise, env_r_frise,
env_frise2, env_r_frise2,
env_risefall, env_risefall,
@@ -206,18 +207,17 @@ unsigned char *envelope_data[18] = {
};
-/* all pitches given in Hz above pitch_base */
+
+/* indexed by stress */
+static int min_drop[] = {6,7,9,9,20,20,20,25};
// pitch change during the main part of the clause
-static int drops_0[8] = {0x400,0x400,0x700,0x700,0x700,0xa00,0x1800,0x0e00};
-//static int drops_1[8] = {0x400,0x400,0x600,0x600,0xc00,0xc00,0x0e00,0x0e00};
-//static int drops_2[8] = {0x400,0x400,0x600,0x600,-0x800,0xc00,0x0e00,0x0e00};
+static int drops_0[8] = {9,9,16,16,16,23,55,32};
-static short oflow[] = {0, 20, 12, 4, 0};
-static short oflow_emf[] = {5, 24, 15, 10, 5};
-static short oflow_less[] = {3, 19, 12, 7, 2};
-// static short oflow_test2[] = {20, 0, 20, 0, 20};
-// static short back_emf[] = {35, 32, 0};
+// overflow table values are 64ths of the body pitch range (between body_start and body_end)
+static signed char oflow[] = {0, 40, 24, 8, 0};
+static signed char oflow_emf[] = {10, 52, 32, 20, 10};
+static signed char oflow_less[] = {6, 38, 24, 14, 4};
#define N_TONE_HEAD_TABLE 13
@@ -235,8 +235,8 @@ typedef struct {
unsigned char body_max_steps;
char body_lower_u;
- char n_overflow;
- short *overflow;
+ unsigned char n_overflow;
+ signed char *overflow;
} TONE_HEAD;
@@ -259,38 +259,38 @@ typedef struct {
#define T_EMPH 1
static TONE_HEAD tone_head_table[N_TONE_HEAD_TABLE] = {
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 0 statement
- {20, 25, 34, 20, drops_0, 3, 3, 5, oflow}, // 1 comma
- {20, 25, 34, 20, drops_0, 3, 3, 5, oflow}, // 2 question
- {20, 25, 36, 22, drops_0, 3, 4, 5, oflow_emf}, // 3 exclamation
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 4 statement, emphatic
- {20, 25, 32, 24, drops_0, 4, 3, 5, oflow_less}, // 5 statement, less intonation
- {20, 25, 32, 24, drops_0, 4, 3, 5, oflow_less}, // 6 comma, less intonation
- {20, 25, 32, 24, drops_0, 4, 3, 5, oflow_less}, // 7 comma, less intonation, less rise
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 8 pitch raises at end of sentence
- {20, 25, 34, 20, drops_0, 3, 3, 5, oflow}, // 9 comma
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 10 question
- {15, 18, 18, 14, drops_0, 3, 3, 5, oflow_less}, // 11 test
- {20, 25, 24, 22, drops_0, 3, 3, 5, oflow_less}, // 12 test
+ {46, 57, 78, 50, drops_0, 3, 7, 5, oflow}, // 0 statement
+ {46, 57, 78, 46, drops_0, 3, 7, 5, oflow}, // 1 comma
+ {46, 57, 78, 46, drops_0, 3, 7, 5, oflow}, // 2 question
+ {46, 57, 90, 50, drops_0, 3, 9, 5, oflow_emf}, // 3 exclamation
+ {46, 57, 78, 50, drops_0, 3, 7, 5, oflow}, // 4 statement, emphatic
+ {46, 57, 74, 55, drops_0, 4, 7, 5, oflow_less}, // 5 statement, less intonation
+ {46, 57, 74, 55, drops_0, 4, 7, 5, oflow_less}, // 6 comma, less intonation
+ {46, 57, 74, 55, drops_0, 4, 7, 5, oflow_less}, // 7 comma, less intonation, less rise
+ {46, 57, 78, 50, drops_0, 3, 7, 5, oflow}, // 8 pitch raises at end of sentence
+ {46, 57, 78, 46, drops_0, 3, 7, 5, oflow}, // 9 comma
+ {46, 57, 78, 50, drops_0, 3, 7, 5, oflow}, // 10 question
+ {34, 41, 41, 32, drops_0, 3, 7, 5, oflow_less}, // 11 test
+ {46, 57, 55, 50, drops_0, 3, 7, 5, oflow_less}, // 12 test
};
static TONE_NUCLEUS tone_nucleus_table[N_TONE_NUCLEUS_TABLE] = {
- {PITCHfall, 30, 5, PITCHfall, 32, 9, NULL, 12, 7, 0}, // 0 statement
- {PITCHfrise, 35, 8, PITCHfrise2, 35,10, NULL, 15, 23, 0}, // 1 comma
- {PITCHfrise, 39,10, PITCHfrise2, 36,10, NULL, 15, 28, 0}, // 2 question
-// {PITCHfall, 41, 4, PITCHfall, 41,27, NULL, 16, 4, T_EMPH}, // 3 exclamation
- {PITCHfall, 41, 4, PITCHfall, 41,35, NULL, 35, 4, T_EMPH}, // 3 exclamation
- {PITCHfall, 38, 2, PITCHfall, 42,30, NULL, 15, 5, 0}, // 4 statement, emphatic
- {PITCHfall, 28, 5, PITCHfall, 28, 9, NULL, 12, 7, 0}, // 5 statement, less intonation
- {PITCHfrise, 30, 8, PITCHfrise2, 30,10, NULL, 13, 20, 0}, // 6 comma, less intonation
- {PITCHfrise2, 28, 7, PITCHfall, 29,14, NULL, 14, 8, 0}, // 7 comma, less intonation, less rise
- {PITCHrise, 30,20, PITCHfall, 19,14, NULL, 20, 26, 0}, // 8 pitch raises at end of sentence
- {PITCHfrise, 35,11, PITCHfrise2, 32,10, NULL, 19, 24, 0}, // 9 comma
- {PITCHfrise, 39,15, PITCHfall, 28,14, NULL, 20, 36, 0}, // 10 question
- {PITCHfall, 28, 6, PITCHfall, 28,10, NULL, 12, 6, 0}, // 11 test
- {PITCHfall, 35, 9, PITCHfall, 35,12, NULL, 16, 10, 0}, // 12 test
+ {PITCHfall, 64, 8, PITCHfall, 70,18, NULL, 24, 12, 0}, // 0 statement
+ {PITCHfrise, 80,18, PITCHfrise2, 78,22, NULL, 34, 52, 0}, // 1 comma
+ {PITCHfrise, 88,22, PITCHfrise2, 82,22, NULL, 34, 64, 0}, // 2 question
+ {PITCHfall, 92, 8, PITCHfall, 92,80, NULL, 76, 8, T_EMPH}, // 3 exclamation
+
+ {PITCHfall, 86, 4, PITCHfall, 94,66, NULL, 34, 10, 0}, // 4 statement, emphatic
+ {PITCHfall, 62,10, PITCHfall, 62,20, NULL, 28, 16, 0}, // 5 statement, less intonation
+ {PITCHfrise, 68,18, PITCHfrise2, 68,22, NULL, 30, 44, 0}, // 6 comma, less intonation
+ {PITCHfrise2, 64,16, PITCHfall, 66,32, NULL, 32, 18, 0}, // 7 comma, less intonation, less rise
+ {PITCHrise, 68,46, PITCHfall, 42,32, NULL, 46, 58, 0}, // 8 pitch raises at end of sentence
+ {PITCHfrise, 78,24, PITCHfrise2, 72,22, NULL, 42, 52, 0}, // 9 comma
+ {PITCHfrise, 88,34, PITCHfall, 64,32, NULL, 46, 82, 0}, // 10 question
+ {PITCHfall, 56,12, PITCHfall, 56,20, NULL, 24, 12, 0}, // 11 test
+ {PITCHfall, 70,18, PITCHfall, 70,24, NULL, 32, 20, 0}, // 12 test
};
-
+
/* index by 0=. 1=, 2=?, 3=! 4=none, 5=emphasized */
@@ -306,11 +306,8 @@ unsigned char punctuation_to_tone[INTONATION_TYPES][PUNCT_INTONATIONS] = {
};
-
-/* indexed by stress */
-static int min_drop[] = {0x300,0x300,0x400,0x400,0x900,0x900,0x900,0xb00};
-
-
+int n_tunes = 0;
+TUNE *tunes = NULL;
#define SECONDARY 3
@@ -341,7 +338,7 @@ static void count_pitch_vowels(int start, int end, int clause_end)
number_body = 0;
number_tail = 0; /* number between tonic syllable and next primary */
last_primary = -1;
-
+
for(ix=start; ix<end; ix++)
{
stress = syllable_tab[ix].stress; /* marked stress level */
@@ -419,20 +416,17 @@ static int count_increments(int ix, int end_ix, int min_stress)
+
static void set_pitch(SYLLABLE *syl, int base, int drop)
/******************************************************/
-// Set the pitch of a vowel in syllable_tab. Base & drop are Hz * 256
+// Set the pitch of a vowel in syllable_tab
{
int pitch1, pitch2;
int flags = 0;
- /* adjust experimentally */
- int pitch_range2 = 148;
- int pitch_base2 = 72;
-
if(base < 0) base = 0;
- pitch2 = ((base * pitch_range2 ) >> 15) + pitch_base2;
+ pitch2 = base;
if(drop < 0)
{
@@ -440,10 +434,12 @@ static void set_pitch(SYLLABLE *syl, int base, int drop)
drop = -drop;
}
- pitch1 = pitch2 + ((drop * pitch_range2) >> 15);
+ pitch1 = pitch2 + drop;
+ if(pitch1 < 0)
+ pitch1 = 0;
- if(pitch1 > 511) pitch1 = 511;
- if(pitch2 > 511) pitch2 = 511;
+ if(pitch1 > 254) pitch1 = 254;
+ if(pitch2 > 254) pitch2 = 254;
syl->pitch1 = pitch1;
syl->pitch2 = pitch2;
@@ -451,6 +447,164 @@ static void set_pitch(SYLLABLE *syl, int base, int drop)
} /* end of set_pitch */
+static int CountUnstressed(int start, int end, int limit)
+{//======================================================
+ int ix;
+
+ for(ix=start; ix <= end; ix++)
+ {
+ if(syllable_tab[ix].stress >= limit)
+ break;
+ }
+ return(ix - start);
+}
+
+static int SetHeadIntonation(TUNE *tune, int syl_ix, int end_ix, int control)
+{//==========================================================================
+ int stress;
+ SYLLABLE *syl;
+ int ix;
+ int pitch=0;
+ int increment=0;
+ int n_steps=0;
+ int stage; // onset, head, last
+ int initial;
+ int overflow_ix=0;
+ int pitch_range;
+ int pitch_range_abs;
+ int *drops;
+ int n_unstressed=0;
+ int unstressed_ix=0;
+ int unstressed_inc;
+ int used_onset = 0;
+ int head_final = end_ix;
+int secondary=2; // 2
+
+ pitch_range = (tune->head_end - tune->head_start) << 8;
+ pitch_range_abs = abs(pitch_range);
+ drops = drops_0; // this should be controled by tune->head_drops
+ initial = 1;
+
+ stage = 0;
+ if(tune->onset == 255)
+ stage = 1; // no onset specified
+
+ if(tune->head_last != 255)
+ {
+ // find the last primary stress in the body
+ for(ix = end_ix-1; ix >= syl_ix; ix--)
+ {
+ if(syllable_tab[ix].stress >= 4)
+ {
+ head_final = ix;
+ break;
+ }
+ }
+ }
+
+ while(syl_ix < end_ix)
+ {
+ syl = &syllable_tab[syl_ix];
+ stress = syl->stress;
+
+ if(initial || (stress >= 4))
+ {
+ // a primary stress
+
+ if((initial) || (stress == 5))
+ {
+ initial = 0;
+ overflow_ix = 0;
+
+ if(tune->onset == 255)
+ {
+ n_steps = count_increments(syl_ix, head_final, 4);
+ pitch = tune->head_start << 8;
+ }
+ else
+ {
+ // a pitch has been specified for the onset syllable, don't include it in the pitch incrementing
+ n_steps = count_increments(syl_ix+1, head_final, 4);
+ pitch = tune->onset << 8;
+ used_onset = 1;
+ }
+
+ if(n_steps > tune->head_max_steps)
+ n_steps = tune->head_max_steps;
+
+ if(n_steps > 1)
+ {
+ increment = pitch_range / (n_steps -1);
+ }
+ else
+ increment = 0;
+
+ }
+ else
+ if(syl_ix == head_final)
+ {
+ // a pitch has been specified for the last primary stress before the nucleus
+ pitch = tune->head_last << 8;
+ stage = 2;
+ }
+ else
+ {
+ if(used_onset)
+ {
+ stage = 1;
+ used_onset = 0;
+ pitch = tune->head_start << 8;
+ n_steps++;
+ }
+ else
+ if(n_steps > 0)
+ pitch += increment;
+ else
+ {
+ pitch = (tune->head_end << 8) + (pitch_range_abs * tune->head_extend[overflow_ix++])/64;
+ if(overflow_ix >= tune->n_head_extend)
+ {
+ overflow_ix = 0;
+ }
+ }
+ }
+
+ n_steps--;
+ }
+
+ if(stress >= PRIMARY)
+ {
+ n_unstressed = CountUnstressed(syl_ix+1, end_ix, secondary);
+ unstressed_ix = 0;
+ syl->stress = PRIMARY_STRESSED;
+ syl->env = tune->stressed_env;
+ set_pitch(syl,(pitch >> 8), tune->stressed_drop);
+ }
+ else
+ if(stress >= secondary)
+ {
+ n_unstressed = CountUnstressed(syl_ix+1, end_ix, secondary);
+ unstressed_ix = 0;
+ set_pitch(syl,(pitch >> 8),drops[stress]);
+ }
+ else
+ {
+ if(n_unstressed > 1)
+ unstressed_inc = (tune->unstr_end[stage] - tune->unstr_start[stage]) / (n_unstressed - 1);
+ else
+ unstressed_inc = 0;
+
+ set_pitch(syl, (pitch >> 8) + tune->unstr_start[stage] + (unstressed_inc * unstressed_ix), drops[stress]);
+ unstressed_ix++;
+ }
+
+ syl_ix++;
+ }
+ return(syl_ix);
+
+} // end of SetBodyIntonation
+
+
static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *tn, int min_stress, int continuing)
/**********************************************************************************************/
@@ -466,13 +620,17 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
int initial;
int overflow=0;
int n_overflow;
+ int pitch_range;
+ int pitch_range_abs;
int *drops;
- short *overflow_tab;
+ signed char *overflow_tab;
SYLLABLE *syl;
- static short continue_tab[5] = {-13, 16, 10, 4, 0};
+ static signed char continue_tab[5] = {-26, 32, 20, 8, 0};
drops = th->body_drops;
+ pitch_range = (th->body_end - th->body_start) << 8;
+ pitch_range_abs = abs(pitch_range);
if(continuing)
{
@@ -480,8 +638,7 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
overflow = 0;
n_overflow = 5;
overflow_tab = continue_tab;
- increment = (th->body_end - th->body_start) << 8;
- increment = increment / (th->body_max_steps -1);
+ increment = pitch_range / (th->body_max_steps -1);
}
else
{
@@ -513,8 +670,7 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
if(n_steps > 1)
{
- increment = (th->body_end - th->body_start) << 8;
- increment = increment / (n_steps -1);
+ increment = pitch_range / (n_steps -1);
}
else
increment = 0;
@@ -527,7 +683,7 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
pitch += increment;
else
{
- pitch = (th->body_end << 8) - (increment * overflow_tab[overflow++])/16;
+ pitch = (th->body_end << 8) + (pitch_range_abs * overflow_tab[overflow++])/64;
if(overflow >= n_overflow)
{
overflow = 0;
@@ -541,27 +697,27 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
n_primary--;
if((tn->backwards) && (n_primary < 2))
{
- pitch = tn->backwards[n_primary] << 8;
+ pitch = tn->backwards[n_primary] << 8;
}
}
if(stress >= PRIMARY)
{
syl->stress = PRIMARY_STRESSED;
- set_pitch(syl,pitch,drops[stress]);
+ set_pitch(syl,(pitch >> 8),drops[stress]);
}
else
if(stress >= SECONDARY)
{
- set_pitch(syl,pitch,drops[stress]);
+ set_pitch(syl,(pitch >> 8),drops[stress]);
}
else
{
/* unstressed, drop pitch if preceded by PRIMARY */
if((syllable_tab[ix-1].stress & 0x3f) >= SECONDARY)
- set_pitch(syl,pitch - (th->body_lower_u << 8), drops[stress]);
+ set_pitch(syl,(pitch >> 8) - th->body_lower_u, drops[stress]);
else
- set_pitch(syl,pitch,drops[stress]);
+ set_pitch(syl,(pitch >> 8),drops[stress]);
}
ix++;
@@ -571,13 +727,12 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
+static void SetPitchGradient(int start_ix, int end_ix, int start_pitch, int end_pitch)
+{//====================================================================================
+// Set a linear pitch change over a number of syllables.
+// Used for pre-head, unstressed syllables in the body, and the tail
-
-static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int min_stress)
-/****************************************************************************************/
-/* Linear pitch rise/fall, change pitch at min_stress or stronger
- Used for pre-head and tail */
-{
+ int ix;
int stress;
int pitch;
int increment;
@@ -585,54 +740,112 @@ static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int m
int drop;
SYLLABLE *syl;
- if(ix >= end_ix)
- return(ix);
-
- n_increments = count_increments(ix,end_ix,min_stress);
- increment = (end_p - start_p) << 8;
-
+ increment = (end_pitch - start_pitch) << 8;
+ n_increments = end_ix - start_ix;
+
+ if(n_increments <= 0)
+ return;
+
if(n_increments > 1)
{
increment = increment / n_increments;
}
-
- pitch = start_p << 8;
- while(ix < end_ix)
+ pitch = start_pitch << 8;
+
+ for(ix=start_ix; ix < end_ix; ix++)
{
syl = &syllable_tab[ix];
stress = syl->stress;
if(increment > 0)
{
- set_pitch(syl,pitch,-increment);
+ set_pitch(syl,(pitch >> 8),-(increment >> 8));
pitch += increment;
}
else
{
- drop = -increment;
+ drop = -(increment >> 8);
if(drop < min_drop[stress])
drop = min_drop[stress];
pitch += increment;
- if(drop > 0x900)
- drop = 0x900;
- set_pitch(syl, pitch, drop);
+ if(drop > 18)
+ drop = 18;
+ set_pitch(syl, (pitch >> 8), drop);
}
-
- ix++;
}
- return(ix);
-} /* end of calc_pitch_segment2 */
+} // end of SetPitchGradient
+static int calc_pitches2(int start, int end, int tune_number)
+//============================================================
+// Calculate pitch values for the vowels in this tone group
+{
+ int ix;
+ TUNE *tune;
+ int drop;
+ tune = &tunes[tune_number];
+ ix = start;
+ /* vowels before the first primary stress */
+ /******************************************/
+
+ SetPitchGradient(ix, ix+number_pre, tune->prehead_start, tune->prehead_end);
+ ix += number_pre;
+
+ /* body of tonic segment */
+ /*************************/
-static int calc_pitches(int start, int end, int head_tone, int nucleus_tone)
-//===========================================================================
+ if(option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE)
+ {
+ tone_posn = tone_posn2; // put tone on the penultimate stressed word
+ }
+ ix = SetHeadIntonation(tune, ix, tone_posn, 0);
+
+ if(no_tonic)
+ return(0);
+
+ /* tonic syllable */
+ /******************/
+
+// if(tn->flags & T_EMPH)
+// {
+// syllable_tab[ix].flags |= SYL_EMPHASIS;
+// }
+
+ if(number_tail == 0)
+ {
+ tone_pitch_env = tune->nucleus0_env;
+ drop = tune->nucleus0_max - tune->nucleus0_min;
+ set_pitch(&syllable_tab[ix++],tune->nucleus0_min, drop);
+ }
+ else
+ {
+ tone_pitch_env = tune->nucleus1_env;
+ drop = tune->nucleus1_max - tune->nucleus1_min;
+ set_pitch(&syllable_tab[ix++],tune->nucleus1_min, drop);
+ }
+
+ syllable_tab[tone_posn].env = tone_pitch_env;
+ if(syllable_tab[tone_posn].stress == PRIMARY)
+ syllable_tab[tone_posn].stress = PRIMARY_STRESSED;
+
+ /* tail, after the tonic syllable */
+ /**********************************/
+
+ SetPitchGradient(ix, end, tune->tail_start, tune->tail_end);
+
+ return(tone_pitch_env);
+} /* end of calc_pitches2 */
+
+
+
+static int calc_pitches(int control, int start, int end, int tune_number)
+//========================================================================
// Calculate pitch values for the vowels in this tone group
{
int ix;
@@ -641,36 +854,40 @@ static int calc_pitches(int start, int end, int head_tone, int nucleus_tone)
int drop;
int continuing = 0;
+ if(control == 0)
+ {
+ return(calc_pitches2(start, end, tune_number));
+ }
+
if(start > 0)
continuing = 1;
- th = &tone_head_table[head_tone];
- tn = &tone_nucleus_table[nucleus_tone];
+ th = &tone_head_table[tune_number];
+ tn = &tone_nucleus_table[tune_number];
ix = start;
/* vowels before the first primary stress */
/******************************************/
- if(number_pre > 0)
- {
- ix = calc_pitch_segment2(ix, ix+number_pre, th->pre_start, th->pre_end, 0);
- }
+ SetPitchGradient(ix, ix+number_pre, th->pre_start, th->pre_end);
+ ix += number_pre;
/* body of tonic segment */
/*************************/
if(option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE)
{
- tone_posn = tone_posn2; // put tone on the penultimate stressed word
+ tone_posn = tone_posn2; // put tone on the penultimate stressed word
}
ix = calc_pitch_segment(ix,tone_posn, th, tn, PRIMARY, continuing);
-
+// ix = SetBodyIntonation(&tunes[0], ix, tone_posn, 0);
+
if(no_tonic)
return(0);
/* tonic syllable */
/******************/
-
+
if(tn->flags & T_EMPH)
{
syllable_tab[ix].flags |= SYL_EMPHASIS;
@@ -680,13 +897,13 @@ static int calc_pitches(int start, int end, int head_tone, int nucleus_tone)
{
tone_pitch_env = tn->pitch_env0;
drop = tn->tonic_max0 - tn->tonic_min0;
- set_pitch(&syllable_tab[ix++],tn->tonic_min0 << 8,drop << 8);
+ set_pitch(&syllable_tab[ix++],tn->tonic_min0, drop);
}
else
{
tone_pitch_env = tn->pitch_env1;
drop = tn->tonic_max1 - tn->tonic_min1;
- set_pitch(&syllable_tab[ix++],tn->tonic_min1 << 8,drop << 8);
+ set_pitch(&syllable_tab[ix++],tn->tonic_min1, drop);
}
syllable_tab[tone_posn].env = tone_pitch_env;
@@ -695,8 +912,8 @@ static int calc_pitches(int start, int end, int head_tone, int nucleus_tone)
/* tail, after the tonic syllable */
/**********************************/
-
- calc_pitch_segment2(ix, end, tn->tail_start, tn->tail_end, 0);
+
+ SetPitchGradient(ix, end, tn->tail_start, tn->tail_end);
return(tone_pitch_env);
} /* end of calc_pitches */
@@ -720,7 +937,7 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
PHONEME_TAB *tph;
PHONEME_TAB *prev_tph; // forget across word boundary
PHONEME_TAB *prevw_tph; // remember across word boundary
- PHONEME_TAB *prev2_tph; // 2 tones previous
+// PHONEME_TAB *prev2_tph; // 2 tones previous
PHONEME_LIST *prev_p;
int pitch_adjust = 0; // pitch gradient through the clause - inital value
@@ -728,8 +945,6 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
int pitch_low = 0; // until it drops to this
int pitch_high = 0; // then reset to this
- p = &phoneme_list[0];
-
// count number of stressed syllables
p = &phoneme_list[0];
for(ix=0; ix<n_phoneme_list; ix++, p++)
@@ -822,7 +1037,7 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
if(tph->mnemonic == 0x343132) // [214]
prev_p->tone_ph = PhonemeCode2('3','5');
else
- prev_p->tone_ph = PhonemeCode2('2','1');
+ prev_p->tone_ph = PhonemeCode2('2','1');
}
if((prev_tph->mnemonic == 0x3135) && (tph->mnemonic == 0x3135)) // [51] + [51]
{
@@ -840,12 +1055,12 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
p->tone_ph = PhonemeCode2('4','4');
// tone 5 is unstressed (shorter)
- p->stresslevel = 1; // diminished stress
+ p->stresslevel = 0; // diminished stress
}
}
prev_p = p;
- prev2_tph = prevw_tph;
+// prev2_tph = prevw_tph;
prevw_tph = prev_tph = tph;
pause = 0;
}
@@ -859,7 +1074,7 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
{
tone_ph = p->tone_ph;
- if(p->stresslevel != 1) // TEST, consider all syllables as stressed
+ if(p->stresslevel != 0) // TEST, consider all syllables as stressed
{
if(ix == final_stressed)
{
@@ -900,7 +1115,9 @@ void CalcPitches(Translator *tr, int clause_type)
int n_st;
int option;
int group_tone;
+#ifdef deleted
int group_tone_emph;
+#endif
int group_tone_comma;
int ph_start=0;
int st_start;
@@ -951,11 +1168,24 @@ void CalcPitches(Translator *tr, int clause_type)
option = tr->langopts.intonation_group;
if(option >= INTONATION_TYPES)
- option = 0;
+ option = 1;
- group_tone = tr->punct_to_tone[option][clause_type];
- group_tone_emph = tr->punct_to_tone[option][5]; // emphatic form of statement
- group_tone_comma = tr->punct_to_tone[option][1]; // emphatic form of statement
+ if(option == 0)
+ {
+ group_tone = tr->langopts.tunes[clause_type];
+#ifdef deleted
+ group_tone_emph = tr->langopts.tunes[5];
+#endif
+ group_tone_comma = tr->langopts.tunes[1];
+ }
+ else
+ {
+ group_tone = tr->punct_to_tone[option][clause_type];
+#ifdef deleted
+ group_tone_emph = tr->punct_to_tone[option][5]; // emphatic form of statement
+#endif
+ group_tone_comma = tr->punct_to_tone[option][1]; // emphatic form of statement
+ }
if(clause_type == 4)
no_tonic = 1; /* incomplete clause, used for abbreviations such as Mr. Dr. Mrs. */
@@ -1023,9 +1253,23 @@ void CalcPitches(Translator *tr, int clause_type)
count_pitch_vowels(st_start, ix, n_st);
if((ix < n_st) || (clause_type == 0))
- calc_pitches(st_start, ix, group_tone_emph, group_tone_emph); // split into > 1 tone groups, use emphatic tone
+ {
+ calc_pitches(option, st_start, ix, group_tone); // split into > 1 tone groups
+
+ if((clause_type==1) || (clause_type==2))
+ group_tone = tr->langopts.tunes[1]; // , or ? remainder has comma-tone
+ else
+ group_tone = tr->langopts.tunes[0]; // . or ! remainder has statement tone
+ }
+ else
+ calc_pitches(option, st_start, ix, group_tone);
+
+#ifdef deleted
+ if((ix < n_st) || (clause_type == 0))
+ calc_pitches(option, st_start, ix, group_tone_emph); // split into > 1 tone groups, use emphatic tone
else
- calc_pitches(st_start, ix, group_tone, group_tone);
+ calc_pitches(option, st_start, ix, group_tone);
+#endif
st_start = ix;
}
@@ -1034,7 +1278,7 @@ void CalcPitches(Translator *tr, int clause_type)
// end of clause after this syllable, indicated by a phonPAUSE_CLAUSE phoneme
st_clause_end = st_ix+1;
count_pitch_vowels(st_start, st_clause_end, st_clause_end);
- calc_pitches(st_start, st_clause_end, group_tone_comma, group_tone_comma);
+ calc_pitches(option, st_start, st_clause_end, group_tone_comma);
st_start = st_clause_end;
}
}
@@ -1042,28 +1286,23 @@ void CalcPitches(Translator *tr, int clause_type)
if(st_start < st_ix)
{
count_pitch_vowels(st_start, st_ix, n_st);
- calc_pitches(st_start, st_ix, group_tone, group_tone);
+ calc_pitches(option, st_start, st_ix, group_tone);
}
-
+
// unpack pitch data
st_ix=0;
for(ix=ph_start; ix < ph_end; ix++)
{
p = &phoneme_list[ix];
p->stresslevel = syllable_tab[st_ix].stress;
-
+
if(p->synthflags & SFLAG_SYLLABLE)
{
syl = &syllable_tab[st_ix];
- x = syl->pitch1 - 72;
- if(x < 0) x = 0;
- p->pitch1 = x;
-
- x = syl->pitch2 - 72;
- if(x < 0) x = 0;
- p->pitch2 = x;
+ p->pitch1 = syl->pitch1;
+ p->pitch2 = syl->pitch2;
p->env = PITCHfall;
if(syl->flags & SYL_RISE)
@@ -1094,11 +1333,11 @@ if(p->tone_ph)
{
p->stresslevel |= 8; // emphasized
}
-
+
st_ix++;
}
}
-} // end of Translator::CalcPitches
+} // end of CalcPitches
+
-
diff --git a/navit/support/espeak/klatt.c b/navit/support/espeak/klatt.c
index 8cdbf782b..c191534a5 100644
--- a/navit/support/espeak/klatt.c
+++ b/navit/support/espeak/klatt.c
@@ -22,7 +22,7 @@
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
-// See URL: ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/klatt.3.04.tar.gz
+// See URL: ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/klatt.3.04.tar.gz
#include "StdAfx.h"
@@ -58,19 +58,69 @@ static int sample_count;
/* function prototypes for functions private to this file */
static void flutter(klatt_frame_ptr);
-static double sampled_source (void);
+static double sampled_source (int);
static double impulsive_source (void);
static double natural_source (void);
-static void pitch_synch_par_reset (klatt_frame_ptr);
+static void pitch_synch_par_reset (klatt_frame_ptr);
static double gen_noise (double);
static double DBtoLIN (long);
-static void frame_init (klatt_frame_ptr);
+static void frame_init (klatt_frame_ptr);
static void setabc (long,long,resonator_ptr);
static void setzeroabc (long,long,resonator_ptr);
static klatt_frame_t kt_frame;
static klatt_global_t kt_globals;
+#define NUMBER_OF_SAMPLES 100
+
+static int scale_wav_tab[] = {45,38,45,45,55}; // scale output from different voicing sources
+
+// For testing, this can be overwritten in KlattInit()
+ static short natural_samples2[256]= {
+ 2583, 2516, 2450, 2384, 2319, 2254, 2191, 2127,
+ 2067, 2005, 1946, 1890, 1832, 1779, 1726, 1675,
+ 1626, 1579, 1533, 1491, 1449, 1409, 1372, 1336,
+ 1302, 1271, 1239, 1211, 1184, 1158, 1134, 1111,
+ 1089, 1069, 1049, 1031, 1013, 996, 980, 965,
+ 950, 936, 921, 909, 895, 881, 869, 855,
+ 843, 830, 818, 804, 792, 779, 766, 754,
+ 740, 728, 715, 702, 689, 676, 663, 651,
+ 637, 626, 612, 601, 588, 576, 564, 552,
+ 540, 530, 517, 507, 496, 485, 475, 464,
+ 454, 443, 434, 424, 414, 404, 394, 385,
+ 375, 366, 355, 347, 336, 328, 317, 308,
+ 299, 288, 280, 269, 260, 250, 240, 231,
+ 220, 212, 200, 192, 181, 172, 161, 152,
+ 142, 133, 123, 113, 105, 94, 86, 76,
+ 67, 57, 49, 39, 30, 22, 11, 4,
+ -5, -14, -23, -32, -41, -50, -60, -69,
+ -78, -87, -96, -107, -115, -126, -134, -144,
+ -154, -164, -174, -183, -193, -203, -213, -222,
+ -233, -242, -252, -262, -271, -281, -291, -301,
+ -310, -320, -330, -339, -349, -357, -368, -377,
+ -387, -397, -406, -417, -426, -436, -446, -456,
+ -467, -477, -487, -499, -509, -521, -532, -543,
+ -555, -567, -579, -591, -603, -616, -628, -641,
+ -653, -666, -679, -692, -705, -717, -732, -743,
+ -758, -769, -783, -795, -808, -820, -834, -845,
+ -860, -872, -885, -898, -911, -926, -939, -955,
+ -968, -986, -999, -1018, -1034, -1054, -1072, -1094,
+ -1115, -1138, -1162, -1188, -1215, -1244, -1274, -1307,
+ -1340, -1377, -1415, -1453, -1496, -1538, -1584, -1631,
+ -1680, -1732, -1783, -1839, -1894, -1952, -2010, -2072,
+ -2133, -2196, -2260, -2325, -2390, -2456, -2522, -2589,
+};
+ static short natural_samples[100]=
+ {
+ -310,-400,530,356,224,89,23,-10,-58,-16,461,599,536,701,770,
+ 605,497,461,560,404,110,224,131,104,-97,155,278,-154,-1165,
+ -598,737,125,-592,41,11,-247,-10,65,92,80,-304,71,167,-1,122,
+ 233,161,-43,278,479,485,407,266,650,134,80,236,68,260,269,179,
+ 53,140,275,293,296,104,257,152,311,182,263,245,125,314,140,44,
+ 203,230,-235,-286,23,107,92,-91,38,464,443,176,98,-784,-2449,
+ -1891,-1045,-1600,-1462,-1384,-1261,-949,-730
+ };
+
/*
function RESONATOR
@@ -81,7 +131,7 @@ is stored in the globals structure.
static double resonator(resonator_ptr r, double input)
{
double x;
-
+
x = (double) ((double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2);
r->p2 = (double)r->p1;
r->p1 = (double)x;
@@ -92,11 +142,11 @@ static double resonator(resonator_ptr r, double input)
static double resonator2(resonator_ptr r, double input)
{
double x;
-
+
x = (double) ((double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2);
r->p2 = (double)r->p1;
r->p1 = (double)x;
-
+
r->a += r->a_inc;
r->b += r->b_inc;
r->c += r->c_inc;
@@ -105,13 +155,13 @@ static double resonator2(resonator_ptr r, double input)
-/*
+/*
function ANTIRESONATOR
-This is a generic anti-resonator function. The code is the same as resonator
-except that a,b,c need to be set with setzeroabc() and we save inputs in
+This is a generic anti-resonator function. The code is the same as resonator
+except that a,b,c need to be set with setzeroabc() and we save inputs in
p1/p2 rather than outputs. There is currently only one of these - "rnz"
-Output = (rnz.a * input) + (rnz.b * oldin1) + (rnz.c * oldin2)
+Output = (rnz.a * input) + (rnz.b * oldin1) + (rnz.c * oldin2)
*/
#ifdef deleted
@@ -129,7 +179,7 @@ static double antiresonator2(resonator_ptr r, double input)
register double x = (double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2;
r->p2 = (double)r->p1;
r->p1 = (double)input;
-
+
r->a += r->a_inc;
r->b += r->b_inc;
r->c += r->c_inc;
@@ -143,7 +193,7 @@ function FLUTTER
This function adds F0 flutter, as specified in:
-"Analysis, synthesis and perception of voice quality variations among
+"Analysis, synthesis and perception of voice quality variations among
female and male talkers" D.H. Klatt and L.C. Klatt JASA 87(2) February 1990.
Flutter is added by applying a quasi-random element constructed from three
@@ -155,7 +205,7 @@ static void flutter(klatt_frame_ptr frame)
static int time_count;
double delta_f0;
double fla,flb,flc,fld,fle;
-
+
fla = (double) kt_globals.f0_flutter / 50;
flb = (double) kt_globals.original_f0 / 100;
// flc = sin(2*PI*12.7*time_count);
@@ -178,7 +228,7 @@ Allows the use of a glottal excitation waveform sampled from a real
voice.
*/
-static double sampled_source()
+static double sampled_source(int source_num)
{
int itemp;
double ftemp;
@@ -187,23 +237,35 @@ static double sampled_source()
int current_value;
int next_value;
double temp_diff;
-
+ short *samples;
+
+ if(source_num == 0)
+ {
+ samples = natural_samples;
+ kt_globals.num_samples = 100;
+ }
+ else
+ {
+ samples = natural_samples2;
+ kt_globals.num_samples = 256;
+ }
+
if(kt_globals.T0!=0)
{
ftemp = (double) kt_globals.nper;
ftemp = ftemp / kt_globals.T0;
ftemp = ftemp * kt_globals.num_samples;
itemp = (int) ftemp;
-
+
temp_diff = ftemp - (double) itemp;
-
- current_value = kt_globals.natural_samples[itemp];
- next_value = kt_globals.natural_samples[itemp+1];
-
+
+ current_value = samples[itemp];
+ next_value = samples[itemp+1];
+
diff_value = (double) next_value - (double) current_value;
diff_value = diff_value * temp_diff;
-
- result = kt_globals.natural_samples[itemp] + diff_value;
+
+ result = samples[itemp] + diff_value;
result = result * kt_globals.sample_factor;
}
else
@@ -216,16 +278,17 @@ static double sampled_source()
-/*
+/*
function PARWAVE
Converts synthesis parameters to a waveform.
*/
-static int parwave(klatt_frame_ptr frame)
+static int parwave(klatt_frame_ptr frame)
{
double temp;
+ int value;
double outbypas;
double out;
long n4;
@@ -241,23 +304,22 @@ static int parwave(klatt_frame_ptr frame)
static double sourc;
int ix;
- frame_init(frame); /* get parameters for next frame of speech */
-
flutter(frame); /* add f0 flutter */
-#ifdef deleted
+#ifdef LOG_FRAMES
+if(option_log_frames)
{
FILE *f;
- f=fopen("klatt_log","a");
- fprintf(f,"%4dhz %2dAV %4d %3d, %4d %3d, %4d %3d, %4d %3d, %4d, %3d, %4d %3d TLT=%2d\n",frame->F0hz10,frame->AVdb,
- frame->F1hz,frame->B1hz,frame->F2hz,frame->B2hz,frame->F3hz,frame->B3hz,frame->F4hz,frame->B4hz,frame->F5hz,frame->B5hz,frame->F6hz,frame->B6hz,frame->TLTdb);
+ f=fopen("log-klatt","a");
+ fprintf(f,"%4dhz %2dAV %4d %3d, %4d %3d, %4d %3d, %4d %3d, %4d, %3d, FNZ=%3d TLT=%2d\n",frame->F0hz10,frame->AVdb,
+ frame->Fhz[1],frame->Bhz[1],frame->Fhz[2],frame->Bhz[2],frame->Fhz[3],frame->Bhz[3],frame->Fhz[4],frame->Bhz[4],frame->Fhz[5],frame->Bhz[5],frame->Fhz[0],frame->TLTdb);
fclose(f);
}
#endif
/* MAIN LOOP, for each output sample of current frame: */
- for (kt_globals.ns=0; kt_globals.ns<kt_globals.nspfr; kt_globals.ns++)
+ for (kt_globals.ns=0; kt_globals.ns<kt_globals.nspfr; kt_globals.ns++)
{
/* Get low-passed random number for aspiration and frication noise */
noise = gen_noise(noise);
@@ -266,22 +328,22 @@ static int parwave(klatt_frame_ptr frame)
Amplitude modulate noise (reduce noise amplitude during
second half of glottal period) if voicing simultaneously present.
*/
-
- if (kt_globals.nper > kt_globals.nmod)
+
+ if (kt_globals.nper > kt_globals.nmod)
{
noise *= (double) 0.5;
}
-
+
/* Compute frication noise */
frics = kt_globals.amp_frica * noise;
-
+
/*
- Compute voicing waveform. Run glottal source simulation at 4
- times normal sample rate to minimize quantization noise in
+ Compute voicing waveform. Run glottal source simulation at 4
+ times normal sample rate to minimize quantization noise in
period of female voice.
*/
-
- for (n4=0; n4<4; n4++)
+
+ for (n4=0; n4<4; n4++)
{
switch(kt_globals.glsource)
{
@@ -289,64 +351,67 @@ static int parwave(klatt_frame_ptr frame)
voice = impulsive_source();
break;
case NATURAL:
- voice = natural_source();
+ voice = natural_source();
break;
case SAMPLED:
- voice = sampled_source();
+ voice = sampled_source(0);
+ break;
+ case SAMPLED2:
+ voice = sampled_source(1);
break;
}
-
+
/* Reset period when counter 'nper' reaches T0 */
- if (kt_globals.nper >= kt_globals.T0)
+ if (kt_globals.nper >= kt_globals.T0)
{
kt_globals.nper = 0;
pitch_synch_par_reset(frame);
}
-
+
/*
Low-pass filter voicing waveform before downsampling from 4*samrate
- to samrate samples/sec. Resonator f=.09*samrate, bw=.06*samrate
+ to samrate samples/sec. Resonator f=.09*samrate, bw=.06*samrate
*/
-
+
voice = resonator(&(kt_globals.rsn[RLP]),voice);
-
+
/* Increment counter that keeps track of 4*samrate samples per sec */
kt_globals.nper++;
}
-
+
/*
Tilt spectrum of voicing source down by soft low-pass filtering, amount
of tilt determined by TLTdb
*/
-
+
voice = (voice * kt_globals.onemd) + (vlast * kt_globals.decay);
vlast = voice;
-
- /*
- Add breathiness during glottal open phase. Amount of breathiness
- determined by parameter Aturb Use nrand rather than noise because
- noise is low-passed.
+
+ /*
+ Add breathiness during glottal open phase. Amount of breathiness
+ determined by parameter Aturb Use nrand rather than noise because
+ noise is low-passed.
*/
-
-
- if (kt_globals.nper < kt_globals.nopen)
+
+
+ if (kt_globals.nper < kt_globals.nopen)
{
voice += kt_globals.amp_breth * kt_globals.nrand;
}
-
+
/* Set amplitude of voicing */
glotout = kt_globals.amp_voice * voice;
par_glotout = kt_globals.par_amp_voice * voice;
-
+
/* Compute aspiration amplitude and add to voicing source */
aspiration = kt_globals.amp_aspir * noise;
glotout += aspiration;
-
+
par_glotout += aspiration;
-
- /*
+
+ /*
Cascade vocal tract, excited by laryngeal sources.
- Nasal antiresonator, then formants FNP, F5, F4, F3, F2, F1
+ Nasal antiresonator, then formants FNP, F5, F4, F3, F2, F1
*/
out=0;
@@ -363,20 +428,20 @@ static int parwave(klatt_frame_ptr frame)
casc_next_in = resonator2(&(kt_globals.rsn[R2c]),casc_next_in);
out = resonator2(&(kt_globals.rsn[R1c]),casc_next_in);
}
-
+
/* Excite parallel F1 and FNP by voicing waveform */
sourc = par_glotout; /* Source is voicing plus aspiration */
/*
- Standard parallel vocal tract Formants F6,F5,F4,F3,F2,
- outputs added with alternating sign. Sound source for other
- parallel resonators is frication plus first difference of
- voicing waveform.
+ Standard parallel vocal tract Formants F6,F5,F4,F3,F2,
+ outputs added with alternating sign. Sound source for other
+ parallel resonators is frication plus first difference of
+ voicing waveform.
*/
-
+
out += resonator(&(kt_globals.rsn[R1p]),sourc);
out += resonator(&(kt_globals.rsn[Rnpp]),sourc);
-
+
sourc = frics + par_glotout - glotlast;
glotlast = par_glotout;
@@ -384,14 +449,14 @@ static int parwave(klatt_frame_ptr frame)
{
out = resonator(&(kt_globals.rsn[ix]),sourc) - out;
}
-
+
outbypas = kt_globals.amp_bypas * sourc;
-
+
out = outbypas - out;
#ifdef deleted
// for testing
- if (kt_globals.outsl != 0)
+ if (kt_globals.outsl != 0)
{
switch(kt_globals.outsl)
{
@@ -401,7 +466,7 @@ static int parwave(klatt_frame_ptr frame)
case 2:
out = aspiration;
break;
- case 3:
+ case 3:
out = frics;
break;
case 4:
@@ -421,7 +486,7 @@ static int parwave(klatt_frame_ptr frame)
#endif
out = resonator(&(kt_globals.rsn[Rout]),out);
- temp = (out * wdata.amplitude * kt_globals.amp_gain0) ; /* Convert back to integer */
+ temp = (int)(out * wdata.amplitude * kt_globals.amp_gain0) ; /* Convert back to integer */
// mix with a recorded WAV if required for this phoneme
@@ -429,7 +494,7 @@ static int parwave(klatt_frame_ptr frame)
int z2;
signed char c;
int sample;
-
+
z2 = 0;
if(wdata.mix_wavefile_ix < wdata.n_mix_wavefile)
{
@@ -458,18 +523,27 @@ static int parwave(klatt_frame_ptr frame)
temp = (temp * kt_globals.fadeout) / 64;
}
- if (temp < -32768.0)
+ value = (int)temp + ((echo_buf[echo_tail++]*echo_amp) >> 8);
+ if(echo_tail >= N_ECHO_BUF)
+ echo_tail=0;
+
+ if (value < -32768)
{
- temp = -32768.0;
+ value = -32768;
}
-
- if (temp > 32767.0)
+
+ if (value > 32767)
{
- temp = 32767.0;
+ value = 32767;
}
-
- *out_ptr++ = (int)(temp); // **JSD
- *out_ptr++ = (int)(temp) >> 8;
+
+ *out_ptr++ = value;
+ *out_ptr++ = value >> 8;
+
+ echo_buf[echo_head++] = value;
+ if(echo_head >= N_ECHO_BUF)
+ echo_head = 0;
+
sample_count++;
if(out_ptr >= out_end)
{
@@ -482,47 +556,52 @@ static int parwave(klatt_frame_ptr frame)
-/*
-function PARWAVE_INIT
-
-Initialises all parameters used in parwave, sets resonator internal memory
-to zero.
-*/
-static void reset_resonators()
+void KlattReset(int control)
{
int r_ix;
- for(r_ix=0; r_ix < N_RSN; r_ix++)
+ if(control == 2)
+ {
+ //Full reset
+ kt_globals.FLPhz = (950 * kt_globals.samrate) / 10000;
+ kt_globals.BLPhz = (630 * kt_globals.samrate) / 10000;
+ kt_globals.minus_pi_t = -PI / kt_globals.samrate;
+ kt_globals.two_pi_t = -2.0 * kt_globals.minus_pi_t;
+ setabc(kt_globals.FLPhz,kt_globals.BLPhz,&(kt_globals.rsn[RLP]));
+
+ }
+
+ if(control > 0)
+ {
+ kt_globals.nper = 0;
+ kt_globals.T0 = 0;
+ kt_globals.nopen = 0;
+ kt_globals.nmod = 0;
+
+ for(r_ix=RGL; r_ix < N_RSN; r_ix++)
+ {
+ kt_globals.rsn[r_ix].p1 = 0;
+ kt_globals.rsn[r_ix].p2 = 0;
+ }
+
+ }
+
+ for(r_ix=0; r_ix <= R6p; r_ix++)
{
kt_globals.rsn[r_ix].p1 = 0;
kt_globals.rsn[r_ix].p2 = 0;
}
}
-static void parwave_init()
-{
- kt_globals.FLPhz = (950 * kt_globals.samrate) / 10000;
- kt_globals.BLPhz = (630 * kt_globals.samrate) / 10000;
- kt_globals.minus_pi_t = -PI / kt_globals.samrate;
- kt_globals.two_pi_t = -2.0 * kt_globals.minus_pi_t;
- setabc(kt_globals.FLPhz,kt_globals.BLPhz,&(kt_globals.rsn[RLP]));
- kt_globals.nper = 0;
- kt_globals.T0 = 0;
- kt_globals.nopen = 0;
- kt_globals.nmod = 0;
-
- reset_resonators();
-}
-
-/*
+/*
function FRAME_INIT
Use parameters from the input frame to set up resonator coefficients.
*/
-static void frame_init(klatt_frame_ptr frame)
+static void frame_init(klatt_frame_ptr frame)
{
double amp_par[7];
static double amp_par_factor[7] = {0.6, 0.4, 0.15, 0.06, 0.04, 0.022, 0.03};
@@ -530,13 +609,13 @@ static void frame_init(klatt_frame_ptr frame)
int ix;
kt_globals.original_f0 = frame->F0hz10 / 10;
-
+
frame->AVdb_tmp = frame->AVdb - 7;
if (frame->AVdb_tmp < 0)
{
frame->AVdb_tmp = 0;
}
-
+
kt_globals.amp_aspir = DBtoLIN(frame->ASP) * 0.05;
kt_globals.amp_frica = DBtoLIN(frame->AF) * 0.25;
kt_globals.par_amp_voice = DBtoLIN(frame->AVpdb);
@@ -549,14 +628,14 @@ static void frame_init(klatt_frame_ptr frame)
}
Gain0_tmp = frame->Gain0 - 3;
- if (Gain0_tmp <= 0)
+ if (Gain0_tmp <= 0)
{
Gain0_tmp = 57;
}
kt_globals.amp_gain0 = DBtoLIN(Gain0_tmp) / kt_globals.scale_wav;
-
+
/* Set coefficients of variable cascade resonators */
- for(ix=0; ix<=8; ix++)
+ for(ix=1; ix<=9; ix++)
{
// formants 1 to 8, plus nasal pole
setabc(frame->Fhz[ix],frame->Bhz[ix],&(kt_globals.rsn[ix]));
@@ -564,7 +643,7 @@ static void frame_init(klatt_frame_ptr frame)
if(ix <= 5)
{
setabc(frame->Fhz_next[ix],frame->Bhz_next[ix],&(kt_globals.rsn_next[ix]));
-
+
kt_globals.rsn[ix].a_inc = (kt_globals.rsn_next[ix].a - kt_globals.rsn[ix].a) / 64.0;
kt_globals.rsn[ix].b_inc = (kt_globals.rsn_next[ix].b - kt_globals.rsn[ix].b) / 64.0;
kt_globals.rsn[ix].c_inc = (kt_globals.rsn_next[ix].c - kt_globals.rsn[ix].c) / 64.0;
@@ -578,19 +657,19 @@ static void frame_init(klatt_frame_ptr frame)
kt_globals.rsn[F_NZ].b_inc = (kt_globals.rsn_next[F_NZ].b - kt_globals.rsn[F_NZ].b) / 64.0;
kt_globals.rsn[F_NZ].c_inc = (kt_globals.rsn_next[F_NZ].c - kt_globals.rsn[F_NZ].c) / 64.0;
-
+
/* Set coefficients of parallel resonators, and amplitude of outputs */
-
+
for(ix=0; ix<=6; ix++)
{
setabc(frame->Fhz[ix],frame->Bphz[ix],&(kt_globals.rsn[Rparallel+ix]));
kt_globals.rsn[Rparallel+ix].a *= amp_par[ix];
}
-
+
/* output low-pass filter */
-
+
setabc((long)0.0,(long)(kt_globals.samrate/2),&(kt_globals.rsn[Rout]));
-
+
}
@@ -598,27 +677,27 @@ static void frame_init(klatt_frame_ptr frame)
/*
function IMPULSIVE_SOURCE
-Generate a low pass filtered train of impulses as an approximation of
-a natural excitation waveform. Low-pass filter the differentiated impulse
-with a critically-damped second-order filter, time constant proportional
+Generate a low pass filtered train of impulses as an approximation of
+a natural excitation waveform. Low-pass filter the differentiated impulse
+with a critically-damped second-order filter, time constant proportional
to Kopen.
*/
-static double impulsive_source()
+static double impulsive_source()
{
static double doublet[] = {0.0,13000000.0,-13000000.0};
static double vwave;
-
- if (kt_globals.nper < 3)
+
+ if (kt_globals.nper < 3)
{
vwave = doublet[kt_globals.nper];
}
- else
+ else
{
vwave = 0.0;
}
-
+
return(resonator(&(kt_globals.rsn[RGL]),vwave));
}
@@ -631,20 +710,20 @@ Vwave is the differentiated glottal flow waveform, there is a weak
spectral zero around 800 Hz, magic constants a,b reset pitch synchronously.
*/
-static double natural_source()
+static double natural_source()
{
double lgtemp;
static double vwave;
-
- if (kt_globals.nper < kt_globals.nopen)
+
+ if (kt_globals.nper < kt_globals.nopen)
{
kt_globals.pulse_shape_a -= kt_globals.pulse_shape_b;
vwave += kt_globals.pulse_shape_a;
lgtemp=vwave * 0.028;
-
+
return(lgtemp);
}
- else
+ else
{
vwave = 0.0;
return(0.0);
@@ -678,125 +757,125 @@ Assume voicing waveform V(t) has form: k1 t**2 - k2 t**3
potion of the voicing cycle "nopen".
Let integral of dV/dt have no net dc flow --> a = (b * nopen) / 3
-
+
Let maximum of dUg(n)/dn be constant --> b = gain / (nopen * nopen)
meaning as nopen gets bigger, V has bigger peak proportional to n
Thus, to generate the table below for 40 <= nopen <= 263:
-
+
B0[nopen - 40] = 1920000 / (nopen * nopen)
*/
-static void pitch_synch_par_reset(klatt_frame_ptr frame)
+static void pitch_synch_par_reset(klatt_frame_ptr frame)
{
long temp;
double temp1;
static long skew;
- static short B0[224] =
+ static short B0[224] =
{
1200,1142,1088,1038, 991, 948, 907, 869, 833, 799, 768, 738, 710, 683, 658,
634, 612, 590, 570, 551, 533, 515, 499, 483, 468, 454, 440, 427, 415, 403,
391, 380, 370, 360, 350, 341, 332, 323, 315, 307, 300, 292, 285, 278, 272,
265, 259, 253, 247, 242, 237, 231, 226, 221, 217, 212, 208, 204, 199, 195,
192, 188, 184, 180, 177, 174, 170, 167, 164, 161, 158, 155, 153, 150, 147,
- 145, 142, 140, 137, 135, 133, 131, 128, 126, 124, 122, 120, 119, 117, 115,
+ 145, 142, 140, 137, 135, 133, 131, 128, 126, 124, 122, 120, 119, 117, 115,
113,111, 110, 108, 106, 105, 103, 102, 100, 99, 97, 96, 95, 93, 92, 91, 90,
88, 87, 86, 85, 84, 83, 82, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 71,
- 70, 69, 68, 68, 67, 66, 65, 64, 64, 63, 62, 61, 61, 60, 59, 59, 58, 57,
+ 70, 69, 68, 68, 67, 66, 65, 64, 64, 63, 62, 61, 61, 60, 59, 59, 58, 57,
57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50, 49, 49, 48, 48,
47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 41, 41, 40, 40,
39, 39, 38, 38, 38, 38, 37, 37, 36, 36, 36, 36, 35, 35, 35, 35, 34, 34,33,
33, 33, 33, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, 29,
28, 28, 28, 28, 27, 27
};
-
- if (frame->F0hz10 > 0)
+
+ if (frame->F0hz10 > 0)
{
/* T0 is 4* the number of samples in one pitch period */
-
+
kt_globals.T0 = (40 * kt_globals.samrate) / frame->F0hz10;
-
-
+
+
kt_globals.amp_voice = DBtoLIN(frame->AVdb_tmp);
-
+
/* Duration of period before amplitude modulation */
-
+
kt_globals.nmod = kt_globals.T0;
- if (frame->AVdb_tmp > 0)
+ if (frame->AVdb_tmp > 0)
{
kt_globals.nmod >>= 1;
}
-
+
/* Breathiness of voicing waveform */
-
+
kt_globals.amp_breth = DBtoLIN(frame->Aturb) * 0.1;
-
+
/* Set open phase of glottal period where 40 <= open phase <= 263 */
-
+
kt_globals.nopen = 4 * frame->Kopen;
-
+
if ((kt_globals.glsource == IMPULSIVE) && (kt_globals.nopen > 263))
{
kt_globals.nopen = 263;
}
-
- if (kt_globals.nopen >= (kt_globals.T0-1))
+
+ if (kt_globals.nopen >= (kt_globals.T0-1))
{
// printf("Warning: glottal open period cannot exceed T0, truncated\n");
kt_globals.nopen = kt_globals.T0 - 2;
}
-
- if (kt_globals.nopen < 40)
+
+ if (kt_globals.nopen < 40)
{
/* F0 max = 1000 Hz */
// printf("Warning: minimum glottal open period is 10 samples.\n");
// printf("truncated, nopen = %d\n",kt_globals.nopen);
kt_globals.nopen = 40;
}
-
-
+
+
/* Reset a & b, which determine shape of "natural" glottal waveform */
-
+
kt_globals.pulse_shape_b = B0[kt_globals.nopen-40];
kt_globals.pulse_shape_a = (kt_globals.pulse_shape_b * kt_globals.nopen) * 0.333;
-
+
/* Reset width of "impulsive" glottal pulse */
-
+
temp = kt_globals.samrate / kt_globals.nopen;
-
+
setabc((long)0,temp,&(kt_globals.rsn[RGL]));
-
+
/* Make gain at F1 about constant */
-
+
temp1 = kt_globals.nopen *.00833;
kt_globals.rsn[RGL].a *= temp1 * temp1;
-
+
/*
Truncate skewness so as not to exceed duration of closed phase
of glottal period.
*/
-
-
+
+
temp = kt_globals.T0 - kt_globals.nopen;
- if (frame->Kskew > temp)
+ if (frame->Kskew > temp)
{
// printf("Kskew duration=%d > glottal closed period=%d, truncate\n", frame->Kskew, kt_globals.T0 - kt_globals.nopen);
frame->Kskew = temp;
}
- if (skew >= 0)
+ if (skew >= 0)
{
skew = frame->Kskew;
}
- else
+ else
{
skew = - frame->Kskew;
}
-
+
/* Add skewness to closed portion of voicing period */
kt_globals.T0 = kt_globals.T0 + skew;
skew = - skew;
}
- else
+ else
{
kt_globals.T0 = 4; /* Default for f0 undefined */
kt_globals.amp_voice = 0.0;
@@ -805,20 +884,20 @@ static void pitch_synch_par_reset(klatt_frame_ptr frame)
kt_globals.pulse_shape_a = 0.0;
kt_globals.pulse_shape_b = 0.0;
}
-
+
/* Reset these pars pitch synchronously or at update rate if f0=0 */
-
- if ((kt_globals.T0 != 4) || (kt_globals.ns == 0))
+
+ if ((kt_globals.T0 != 4) || (kt_globals.ns == 0))
{
/* Set one-pole low-pass filter that tilts glottal source */
-
+
kt_globals.decay = (0.033 * frame->TLTdb);
-
- if (kt_globals.decay > 0.0)
+
+ if (kt_globals.decay > 0.0)
{
kt_globals.onemd = 1.0 - kt_globals.decay;
}
- else
+ else
{
kt_globals.onemd = 1.0;
}
@@ -830,7 +909,7 @@ static void pitch_synch_par_reset(klatt_frame_ptr frame)
/*
function SETABC
-Convert formant freqencies and bandwidth into resonator difference
+Convert formant freqencies and bandwidth into resonator difference
equation constants.
*/
@@ -839,18 +918,18 @@ static void setabc(long int f, long int bw, resonator_ptr rp)
{
double r;
double arg;
-
+
/* Let r = exp(-pi bw t) */
arg = kt_globals.minus_pi_t * bw;
r = exp(arg);
-
+
/* Let c = -r**2 */
rp->c = -(r * r);
-
+
/* Let b = r * 2*cos(2 pi f t) */
arg = kt_globals.two_pi_t * f;
rp->b = r * cos(arg) * 2.0;
-
+
/* Let a = 1.0 - b - c */
rp->a = 1.0 - rp->b - rp->c;
}
@@ -859,7 +938,7 @@ static void setabc(long int f, long int bw, resonator_ptr rp)
/*
function SETZEROABC
-Convert formant freqencies and bandwidth into anti-resonator difference
+Convert formant freqencies and bandwidth into anti-resonator difference
equation constants.
*/
@@ -867,56 +946,62 @@ static void setzeroabc(long int f, long int bw, resonator_ptr rp)
{
double r;
double arg;
-
+
f = -f;
-
- if(f>=0)
- {
- f = -1;
- }
-
+
+//NOTE, changes made 30.09.2011 for Reece Dunn <msclrhd@googlemail.com>
+// fix a sound spike when f=0
+
/* First compute ordinary resonator coefficients */
/* Let r = exp(-pi bw t) */
arg = kt_globals.minus_pi_t * bw;
r = exp(arg);
-
+
/* Let c = -r**2 */
rp->c = -(r * r);
-
+
/* Let b = r * 2*cos(2 pi f t) */
arg = kt_globals.two_pi_t * f;
rp->b = r * cos(arg) * 2.;
-
+
/* Let a = 1.0 - b - c */
rp->a = 1.0 - rp->b - rp->c;
-
+
/* Now convert to antiresonator coefficients (a'=1/a, b'=b/a, c'=c/a) */
- rp->a = 1.0 / rp->a;
- rp->c *= -rp->a;
- rp->b *= -rp->a;
+ /* If f == 0 then rp->a gets set to 0 which makes a'=1/a set a', b' and c' to
+ * INF, causing an audible sound spike when triggered (e.g. apiration with the
+ * nasal register set to f=0, bw=0).
+ */
+ if (rp->a != 0)
+ {
+ /* Now convert to antiresonator coefficients (a'=1/a, b'=b/a, c'=c/a) */
+ rp->a = 1.0 / rp->a;
+ rp->c *= -rp->a;
+ rp->b *= -rp->a;
+ }
}
-/*
+/*
function GEN_NOISE
-Random number generator (return a number between -8191 and +8191)
-Noise spectrum is tilted down by soft low-pass filter having a pole near
-the origin in the z-plane, i.e. output = input + (0.75 * lastoutput)
+Random number generator (return a number between -8191 and +8191)
+Noise spectrum is tilted down by soft low-pass filter having a pole near
+the origin in the z-plane, i.e. output = input + (0.75 * lastoutput)
*/
-static double gen_noise(double noise)
+static double gen_noise(double noise)
{
long temp;
static double nlast;
-
+
temp = (long) getrandom(-8191,8191);
kt_globals.nrand = (long) temp;
-
+
noise = kt_globals.nrand + (0.75 * nlast);
nlast = noise;
-
+
return(noise);
}
@@ -933,16 +1018,16 @@ Conversion table, db to linear, 87 dB --> 32767
81 dB --> 16384 (6 dB down = 0.5)
...
0 dB --> 0
-
+
The just noticeable difference for a change in intensity of a vowel
is approximately 1 dB. Thus all amplitudes are quantized to 1 dB
steps.
*/
-static double DBtoLIN(long dB)
+static double DBtoLIN(long dB)
{
- static short amptable[88] =
+ static short amptable[88] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7,
8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 25, 28, 32,
@@ -953,12 +1038,12 @@ static double DBtoLIN(long dB)
4096, 4547, 5104, 5751, 6488, 7291, 8192, 9093, 10207,
11502, 12976, 14582, 16384, 18350, 20644, 23429,
26214, 29491, 32767 };
-
+
if ((dB < 0) || (dB > 87))
{
return(0);
}
-
+
return((double)(amptable[dB]) * 0.001);
}
@@ -973,15 +1058,15 @@ static int klattp[N_KLATTP];
static double klattp1[N_KLATTP];
static double klattp_inc[N_KLATTP];
-static int scale_wav_tab[] = {45,38,45,45}; // scale output from different voicing sources
-int Wavegen_Klatt(int resume)
+static int Wavegen_Klatt(int resume)
{//==========================
int pk;
int x;
int ix;
+ int fade;
if(resume==0)
{
@@ -1005,7 +1090,7 @@ int Wavegen_Klatt(int resume)
}
for(ix=1; ix < 7; ix++)
{
- kt_frame.Ap[ix] = 0;
+ kt_frame.Ap[ix] = peaks[ix].ap;
}
kt_frame.AVdb = klattp[KLATT_AV];
@@ -1035,7 +1120,7 @@ int Wavegen_Klatt(int resume)
for(ix=0; ix < N_KLATTP; ix++)
{
klattp1[ix] += klattp_inc[ix];
- klattp[ix] = (int)(klattp1[ix]);
+ klattp[ix] = (int)klattp1[ix];
}
for(ix=0; ix<=6; ix++)
@@ -1057,22 +1142,37 @@ int Wavegen_Klatt(int resume)
if(kt_globals.nspfr > STEPSIZE)
kt_globals.nspfr = STEPSIZE;
+ frame_init(&kt_frame); /* get parameters for next frame of speech */
+
if(parwave(&kt_frame) == 1)
{
- return(1);
+ return(1); // output buffer is full
}
}
- if(end_wave == 1)
+ if(end_wave > 0)
{
+#ifdef deleted
+ if(end_wave == 2)
+ {
+ fade = (kt_globals.T0 - kt_globals.nper)/4; // samples until end of current cycle
+ if(fade < 64)
+ fade = 64;
+ }
+ else
+#endif
+ {
+ fade = 64; // not followd by formant synthesis
+ }
+
// fade out to avoid a click
- kt_globals.fadeout = 64;
+ kt_globals.fadeout = fade;
end_wave = 0;
- sample_count -= 64;
- kt_globals.nspfr = 64;
+ sample_count -= fade;
+ kt_globals.nspfr = fade;
if(parwave(&kt_frame) == 1)
{
- return(1);
+ return(1); // output buffer is full
}
}
@@ -1080,17 +1180,18 @@ int Wavegen_Klatt(int resume)
}
-void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v, int control)
+static void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v, int control)
{//===========================================================================================
int ix;
DOUBLEX next;
int qix;
int cmd;
+ frame_t *fr3;
static frame_t prev_fr;
if(wvoice != NULL)
{
- if((wvoice->klattv[0] > 0) && (wvoice->klattv[0] <=3 ))
+ if((wvoice->klattv[0] > 0) && (wvoice->klattv[0] <=4 ))
{
kt_globals.glsource = wvoice->klattv[0];
kt_globals.scale_wav = scale_wav_tab[kt_globals.glsource];
@@ -1110,11 +1211,22 @@ void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v
{
if(qix >= N_WCMDQ) qix = 0;
if(qix == wcmdq_tail) break;
-
+
cmd = wcmdq[qix][0];
if(cmd==WCMD_KLATT)
{
end_wave = 0; // next wave generation is from another spectrum
+
+ fr3 = (frame_t *)wcmdq[qix][2];
+ for(ix=1; ix<6; ix++)
+ {
+ if(fr3->ffreq[ix] != fr2->ffreq[ix])
+ {
+ // there is a discontinuity in formants
+ end_wave = 2;
+ break;
+ }
+ }
break;
}
if((cmd==WCMD_WAVE) || (cmd==WCMD_PAUSE))
@@ -1122,47 +1234,44 @@ void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v
}
}
+#ifdef LOG_FRAMES
+if(option_log_frames)
{
-//FILE *f;
-//f=fopen("klatt_log","a");
-//fprintf(f,"len %4d (%3d %4d %4d) (%3d %4d %4d)\n",length,fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3],fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3]);
-//fclose(f);
+ FILE *f_log;
+ f_log=fopen("log-espeakedit","a");
+ if(f_log != NULL)
+ {
+ fprintf(f_log,"K %3dmS %3d %3d %4d %4d %4d %4d (%2d) to %3d %3d %4d %4d %4d %4d (%2d)\n",length*1000/samplerate,
+ fr1->klattp[KLATT_FNZ]*2,fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3],fr1->ffreq[4],fr1->ffreq[5], fr1->klattp[KLATT_AV],
+ fr2->klattp[KLATT_FNZ]*2,fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3],fr1->ffreq[4],fr1->ffreq[5], fr2->klattp[KLATT_AV] );
+ fclose(f_log);
+ }
+ f_log=fopen("log-klatt","a");
+ if(f_log != NULL)
+ {
+ fprintf(f_log,"K %3dmS %3d %3d %4d %4d (%2d) to %3d %3d %4d %4d (%2d)\n",length*1000/samplerate,
+ fr1->klattp[KLATT_FNZ]*2,fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3], fr1->klattp[KLATT_AV],
+ fr2->klattp[KLATT_FNZ]*2,fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3], fr2->klattp[KLATT_AV] );
+
+ fclose(f_log);
+ }
}
+#endif
if(control & 1)
{
- if(wdata.prev_was_synth == 0)
- {
- // A break, not following on from another synthesized sound.
- // Reset the synthesizer
- //reset_resonators(&kt_globals);
- parwave_init();
- }
- else
+ for(ix=1; ix<6; ix++)
{
- if((prev_fr.ffreq[1] != fr1->ffreq[1]) || (prev_fr.ffreq[2] != fr1->ffreq[2]))
+ if(prev_fr.ffreq[ix] != fr1->ffreq[ix])
{
-
- // fade out to avoid a click, but only up to the end of output buffer
- ix = (out_end - out_ptr)/2;
- if(ix > 64)
- ix = 64;
- kt_globals.fadeout = ix;
- kt_globals.nspfr = ix;
- parwave(&kt_frame);
-
- //reset_resonators(&kt_globals);
- parwave_init();
+ // Discontinuity in formants.
+ // end_wave was set in SetSynth_Klatt() to fade out the previous frame
+ KlattReset(0);
+ break;
}
}
- wdata.prev_was_synth = 1;
memcpy(&prev_fr,fr2,sizeof(prev_fr));
}
- if(fr2->frflags & FRFLAG_BREAK)
- {
-// fr2 = fr1;
-// reset_resonators(&kt_globals);
- }
for(ix=0; ix<N_KLATTP; ix++)
{
@@ -1187,7 +1296,7 @@ void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v
for(ix=1; ix < 6; ix++)
{
peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix];
- peaks[ix].freq = (int)(peaks[ix].freq1);
+ peaks[ix].freq = (int)peaks[ix].freq1;
next = (fr2->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix];
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * STEPSIZE) / length;
@@ -1195,7 +1304,7 @@ void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v
{
// klatt bandwidth for f1, f2, f3 (others are fixed)
peaks[ix].bw1 = fr1->bw[ix] * 2;
- peaks[ix].bw = (int)(peaks[ix].bw1);
+ peaks[ix].bw = (int)peaks[ix].bw1;
next = fr2->bw[ix] * 2;
peaks[ix].bw_inc = ((next - peaks[ix].bw1) * STEPSIZE) / length;
}
@@ -1203,8 +1312,14 @@ void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v
// nasal zero frequency
peaks[0].freq1 = fr1->klattp[KLATT_FNZ] * 2;
- peaks[0].freq = (int)(peaks[0].freq1);
+ if(peaks[0].freq1 == 0)
+ peaks[0].freq1 = kt_frame.Fhz[F_NP]; // if no nasal zero, set it to same freq as nasal pole
+
+ peaks[0].freq = (int)peaks[0].freq1;
next = fr2->klattp[KLATT_FNZ] * 2;
+ if(next == 0)
+ next = kt_frame.Fhz[F_NP];
+
peaks[0].freq_inc = ((next - peaks[0].freq1) * STEPSIZE) / length;
peaks[0].bw1 = 89;
@@ -1217,13 +1332,13 @@ void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v
for(ix=1; ix < 7; ix++)
{
peaks[ix].bp1 = fr1->klatt_bp[ix] * 4; // parallel bandwidth
- peaks[ix].bp = (int)(peaks[ix].bp1);
- next = fr2->klatt_bp[ix] * 2;
+ peaks[ix].bp = (int)peaks[ix].bp1;
+ next = fr2->klatt_bp[ix] * 4;
peaks[ix].bp_inc = ((next - peaks[ix].bp1) * STEPSIZE) / length;
peaks[ix].ap1 = fr1->klatt_ap[ix]; // parallal amplitude
- peaks[ix].ap = (int)(peaks[ix].ap1);
- next = fr2->klatt_ap[ix] * 2;
+ peaks[ix].ap = (int)peaks[ix].ap1;
+ next = fr2->klatt_ap[ix];
peaks[ix].ap_inc = ((next - peaks[ix].ap1) * STEPSIZE) / length;
}
}
@@ -1242,18 +1357,7 @@ int Wavegen_Klatt2(int length, int modulation, int resume, frame_t *fr1, frame_t
void KlattInit()
{
-#define NUMBER_OF_SAMPLES 100
- static short natural_samples[NUMBER_OF_SAMPLES]=
- {
- -310,-400,530,356,224,89,23,-10,-58,-16,461,599,536,701,770,
- 605,497,461,560,404,110,224,131,104,-97,155,278,-154,-1165,
- -598,737,125,-592,41,11,-247,-10,65,92,80,-304,71,167,-1,122,
- 233,161,-43,278,479,485,407,266,650,134,80,236,68,260,269,179,
- 53,140,275,293,296,104,257,152,311,182,263,245,125,314,140,44,
- 203,230,-235,-286,23,107,92,-91,38,464,443,176,98,-784,-2449,
- -1891,-1045,-1600,-1462,-1384,-1261,-949,-730
- };
static short formant_hz[10] = {280,688,1064,2806,3260,3700,6500,7000,8000,280};
static short bandwidth[10] = {89,160,70,160,200,200,500,500,500,89};
static short parallel_amp[10] = { 0,59,59,59,59,59,59,0,0,0};
@@ -1261,6 +1365,12 @@ void KlattInit()
int ix;
+for(ix=0; ix<256; ix++)
+{
+ // TEST: Overwrite natural_samples2
+ // sawtooth wave
+// natural_samples2[ix] = (128-ix) * 20;
+}
sample_count=0;
kt_globals.synthesis_model = CASCADE_PARALLEL;
@@ -1275,7 +1385,7 @@ void KlattInit()
kt_globals.outsl = 0;
kt_globals.f0_flutter = 20;
- parwave_init();
+ KlattReset(2);
// set default values for frame parameters
for(ix=0; ix<=9; ix++)
@@ -1297,7 +1407,7 @@ void KlattInit()
kt_frame.Kskew = 0;
kt_frame.AB = 0;
kt_frame.AVpdb = 0;
- kt_frame.Gain0 = 60; // 62
+ kt_frame.Gain0 = 62; // 60
} // end of KlattInit
#endif // INCLUDE_KLATT
diff --git a/navit/support/espeak/klatt.h b/navit/support/espeak/klatt.h
index 5583b178a..e4448e4a1 100644
--- a/navit/support/espeak/klatt.h
+++ b/navit/support/espeak/klatt.h
@@ -1,11 +1,12 @@
#define CASCADE_PARALLEL 1 /* Type of synthesis model */
-#define ALL_PARALLEL 2
+#define ALL_PARALLEL 2
#define IMPULSIVE 1 /* Type of voicing source */
#define NATURAL 2
#define SAMPLED 3
+#define SAMPLED2 4
#define PI 3.1415927
@@ -68,7 +69,7 @@ typedef struct
int scale_wav; // depends on the voicing source
#define N_RSN 20
-#define Rnpc 0
+#define Rnz 0 // nasal zero, anti-resonator
#define R1c 1
#define R2c 2
#define R3c 3
@@ -77,7 +78,7 @@ typedef struct
#define R6c 6
#define R7c 7
#define R8c 8
-#define Rnz 9
+#define Rnpc 9 // nasal pole
#define Rparallel 10
#define Rnpp 10
@@ -96,7 +97,7 @@ typedef struct
resonator_t rsn_next[N_RSN];
} klatt_global_t, *klatt_global_ptr;
-
+
/* Structure for Klatt Parameters */
#define F_NZ 0 // nasal zero formant
@@ -111,25 +112,25 @@ typedef struct
typedef struct
{
- long F0hz10; /* Voicing fund freq in Hz */
- long AVdb; /* Amp of voicing in dB, 0 to 70 */
+ int F0hz10; /* Voicing fund freq in Hz */
+ int AVdb; /* Amp of voicing in dB, 0 to 70 */
int Fhz[10]; // formant Hz, F_NZ to F6 to F_NP
int Bhz[10];
int Ap[10]; /* Amp of parallel formants in dB, 0 to 80 */
int Bphz[10]; /* Parallel formants bw in Hz, 40 to 1000 */
- long ASP; /* Amp of aspiration in dB, 0 to 70 */
- long Kopen; /* # of samples in open period, 10 to 65 */
- long Aturb; /* Breathiness in voicing, 0 to 80 */
- long TLTdb; /* Voicing spectral tilt in dB, 0 to 24 */
- long AF; /* Amp of frication in dB, 0 to 80 */
- long Kskew; /* Skewness of alternate periods, 0 to 40 in sample#/2 */
+ int ASP; /* Amp of aspiration in dB, 0 to 70 */
+ int Kopen; /* # of samples in open period, 10 to 65 */
+ int Aturb; /* Breathiness in voicing, 0 to 80 */
+ int TLTdb; /* Voicing spectral tilt in dB, 0 to 24 */
+ int AF; /* Amp of frication in dB, 0 to 80 */
+ int Kskew; /* Skewness of alternate periods, 0 to 40 in sample#/2 */
- long AB; /* Amp of bypass fric. in dB, 0 to 80 */
- long AVpdb; /* Amp of voicing, par in dB, 0 to 70 */
- long Gain0; /* Overall gain, 60 dB is unity, 0 to 60 */
+ int AB; /* Amp of bypass fric. in dB, 0 to 80 */
+ int AVpdb; /* Amp of voicing, par in dB, 0 to 70 */
+ int Gain0; /* Overall gain, 60 dB is unity, 0 to 60 */
- long AVdb_tmp; //copy of AVdb, which is changed within parwave()
+ int AVdb_tmp; //copy of AVdb, which is changed within parwave()
int Fhz_next[10]; // Fhz for the next chunk, so we can do interpolation of resonator (a,b,c) parameters
int Bhz_next[10];
} klatt_frame_t, *klatt_frame_ptr;
diff --git a/navit/support/espeak/mbrolib.h b/navit/support/espeak/mbrolib.h
deleted file mode 100644
index 0616b464b..000000000
--- a/navit/support/espeak/mbrolib.h
+++ /dev/null
@@ -1,205 +0,0 @@
-#ifndef MBROLIB_H
-#define MBROLIB_H
-
-/*
- * mbrolib: mbrola wrapper.
- *
- * Copyright (C) 2007 Gilles Casse <gcasse@oralux.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* < types */
-
-/** Parameters */
-
-typedef struct {
- int ignore_error; /* 1=Ignore any fatal error or unknown diphone */
- char comment_char; /* Comment character */
- float volume_ratio; /* Volume ratio */
- float frequency_ratio; /* Applied to pitch points */
- float time_ratio; /* Applied to phone durations */
-} mbrolib_parameter;
-
-
-/** Returned errors */
-
-typedef enum {
- MBROLIB_OK=0,
- MBROLIB_DATABASE_NOT_INSTALLED,
- MBROLIB_INVAL,
- MBROLIB_OUT_OF_MEMORY,
- MBROLIB_OUT_OF_RANGE,
- MBROLIB_READ_ERROR,
- MBROLIB_WRITE_ERROR
-} MBROLIB_ERROR;
-
-
-
-/** Gender */
-
-typedef enum {
- MBROLIB_FEMALE,
- MBROLIB_MALE
-} MBROLIB_GENDER;
-
-
-
-/** Voice descriptor */
-
-typedef struct {
- char *name; /* name (for example: "en1") */
- char *filename; /* database pathname (for example: "/usr/share/mbrola/voices/en1) */
- int rate; /* database sample rate */
- MBROLIB_GENDER gender;
- const char *language; /* Language and optional dialect qualifier in ascii (e.g. en, fr_ca). */
-} mbrolib_voice;
-
-/* > */
-
-
-/** Initialization, returns a new handle.
- First function.
-
- @param the_sample_rate: output rate in Hz (for example 22050). If 0, keep the original database rate.
-
- @return handle (or NULL if error).
-*/
-void* mbrolib_init( int sample_rate);
-typedef void* (t_mbrolib_init)(int);
-
-
-/** Returns the list of the installed mbrola databases.
- The databases are searched according to the MBROLA_PATH environment variable if set,
- or under a default path otherwise (see MBROLA_PATH in mbrolib.c).
-
- An array of voices is returned. The last item is set to NULL.
- The caller must not free the returned items or the array.
-
- @param the_handle previously given by mbrolib_init.
-
- @return An array of voices.
-*/
-const mbrolib_voice ** mbrolib_list_voices( void* the_handle);
-typedef const mbrolib_voice ** (t_mbrolib_list_voices)(void*);
-
-
-
-/** Set voice
-
- @param the_handle.
-
- @param the_database (for example, "en1").
-
- @return error code (MBROLIB_OK, MBROLIB_DATABASE_NOT_INSTALLED, MBROLIB_INVAL).
-
-*/
-MBROLIB_ERROR mbrolib_set_voice( void* the_handle, const char* the_name);
-typedef MBROLIB_ERROR (t_mbrolib_set_voice)( void*, const char*);
-
-
-
-/** Get the current database parameters.
- The caller supplies a pointer to an already allocated structure.
-
- @param the_handle previously given by mbrolib_init.
-
- @param the_parameters: pointer to the structure.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL).
-*/
-MBROLIB_ERROR mbrolib_get_parameter(void* the_handle, mbrolib_parameter* the_parameter);
-typedef MBROLIB_ERROR (t_mbrolib_get_parameter)(void*, mbrolib_parameter*);
-
-
-
-/** Set the database parameters using the supplied data.
-
- @param the_handle previously given by mbrolib_init.
-
- @param the_parameters: pointer to the wished parameters.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL).
-*/
-MBROLIB_ERROR mbrolib_set_parameter(void* the_handle, const mbrolib_parameter* the_parameter);
-typedef MBROLIB_ERROR (t_mbrolib_set_parameter)(void*, const mbrolib_parameter*);
-
-
-
-/** Write the mbrola phonemes in the internal buffer.
-
- @param the_handle.
-
- @param the_mbrola_phonemes.
-
- @param the_size in bytes.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL, MBROLIB_WRITE_ERROR, MBROLIB_READ_ERROR).
-*/
-MBROLIB_ERROR mbrolib_write(void* the_handle, const char* the_mbrola_phonemes, size_t the_size);
-typedef MBROLIB_ERROR (t_mbrolib_write)(void*, const char*, size_t);
-
-
-
-/** Read n bytes of the output samples.
-
- @param the_handle.
-
- @param the_samples (raw audio data, 16bits, mono).
-
- @param the_size max number of int16 to read.
-
- @param the_size number of int16 read.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL, MBROLIB_READ_ERROR).
-
-*/
-MBROLIB_ERROR mbrolib_read(void* the_handle, short* the_samples, int the_max_size, int* the_read_size);
-typedef MBROLIB_ERROR (t_mbrolib_read)(void*, short*, int, int*);
-
-
-
-/** Flush
-
- @param the_handle.
-
-*/
-void mbrolib_flush(void* the_handle);
-typedef void (t_mbrolib_flush)(void*);
-
-
-
-/** Release the handle
-
- @param the_handle.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL).
-
-*/
-MBROLIB_ERROR mbrolib_terminate(void* the_handle);
-typedef MBROLIB_ERROR (t_mbrolib_terminate)(void*);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/navit/support/espeak/mbrowrap.c b/navit/support/espeak/mbrowrap.c
new file mode 100644
index 000000000..9aef6d242
--- /dev/null
+++ b/navit/support/espeak/mbrowrap.c
@@ -0,0 +1,613 @@
+/*
+ * mbrowrap -- A wrapper library around the mbrola binary
+ * providing a subset of the API from the Windows mbrola DLL.
+ *
+ * Copyright (C) 2010 by Nicolas Pitre <nico@fluxnic.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include "speech.h"
+#ifdef INCLUDE_MBROLA
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "mbrowrap.h"
+
+
+/*
+ * mbrola instance parameters
+ */
+
+enum mbr_state {
+ MBR_INACTIVE = 0,
+ MBR_IDLE,
+ MBR_NEWDATA,
+ MBR_AUDIO,
+ MBR_WEDGED
+};
+
+static enum mbr_state mbr_state;
+
+static char *mbr_voice_path;
+static int mbr_cmd_fd, mbr_audio_fd, mbr_error_fd, mbr_proc_stat;
+static pid_t mbr_pid;
+static int mbr_samplerate;
+static float mbr_volume = 1.0;
+static char mbr_errorbuf[160];
+
+struct datablock {
+ struct datablock *next;
+ int done;
+ int size;
+ char buffer[1]; /* 1 or more, dynamically allocated */
+};
+
+static struct datablock *mbr_pending_data_head, *mbr_pending_data_tail;
+
+/*
+ * Private support code.
+ */
+
+static void mbro_log(const char *msg, ...)
+{
+ va_list params;
+
+ va_start(params, msg);
+ vfprintf(stderr, msg, params);
+ fputc('\n', stderr);
+ va_end(params);
+}
+
+static void err(const char *errmsg, ...)
+{
+ va_list params;
+
+ va_start(params, errmsg);
+ vsnprintf(mbr_errorbuf, sizeof(mbr_errorbuf), errmsg, params);
+ va_end(params);
+ mbro_log("mbrowrap error: %s", mbr_errorbuf);
+}
+
+static int create_pipes(int p1[2], int p2[2], int p3[2])
+{
+ int error;
+
+ if (pipe(p1) != -1) {
+ if (pipe(p2) != -1) {
+ if (pipe(p3) != -1) {
+ return 0;
+ } else
+ error = errno;
+ close(p2[0]);
+ close(p2[1]);
+ } else
+ error = errno;
+ close(p1[0]);
+ close(p1[1]);
+ } else
+ error = errno;
+
+ err("pipe(): %s", strerror(error));
+ return -1;
+}
+
+static void close_pipes(int p1[2], int p2[2], int p3[2])
+{
+ close(p1[0]);
+ close(p1[1]);
+ close(p2[0]);
+ close(p2[1]);
+ close(p3[0]);
+ close(p3[1]);
+}
+
+static int start_mbrola(const char *voice_path)
+{
+ int error, p_stdin[2], p_stdout[2], p_stderr[2];
+ ssize_t written;
+ char charbuf[20];
+
+ if (mbr_state != MBR_INACTIVE) {
+ err("mbrola init request when already initialized");
+ return -1;
+ }
+
+ error = create_pipes(p_stdin, p_stdout, p_stderr);
+ if (error)
+ return -1;
+
+ mbr_pid = fork();
+
+ if (mbr_pid == -1) {
+ error = errno;
+ close_pipes(p_stdin, p_stdout, p_stderr);
+ err("fork(): %s", strerror(error));
+ return -1;
+ }
+
+ if (mbr_pid == 0) {
+ int i;
+
+ if (dup2(p_stdin[0], 0) == -1 ||
+ dup2(p_stdout[1], 1) == -1 ||
+ dup2(p_stderr[1], 2) == -1) {
+ snprintf(mbr_errorbuf, sizeof(mbr_errorbuf),
+ "dup2(): %s\n", strerror(errno));
+ written = write(p_stderr[1], mbr_errorbuf, strlen(mbr_errorbuf));
+ (void)written; // suppress 'variable not used' warning
+ _exit(1);
+ }
+
+ for (i = p_stderr[1]; i > 2; i--)
+ close(i);
+ signal(SIGHUP, SIG_IGN);
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+
+ snprintf(charbuf, sizeof(charbuf), "%g", mbr_volume);
+ execlp("mbrola", "mbrola", "-e", "-v", charbuf,
+ voice_path, "-", "-.wav", (char *)NULL);
+ /* if execution reaches this point then the exec() failed */
+ snprintf(mbr_errorbuf, sizeof(mbr_errorbuf),
+ "mbrola: %s\n", strerror(errno));
+ written = write(2, mbr_errorbuf, strlen(mbr_errorbuf));
+ (void)written; // suppress 'variable not used' warning
+ _exit(1);
+ }
+
+ snprintf(charbuf, sizeof(charbuf), "/proc/%d/stat", mbr_pid);
+ mbr_proc_stat = open(charbuf, O_RDONLY);
+ if (mbr_proc_stat == -1) {
+ error = errno;
+ close_pipes(p_stdin, p_stdout, p_stderr);
+ waitpid(mbr_pid, NULL, 0);
+ mbr_pid = 0;
+ err("/proc is unaccessible: %s", strerror(error));
+ return -1;
+ }
+
+ signal(SIGPIPE, SIG_IGN);
+
+ if (fcntl(p_stdin[1], F_SETFL, O_NONBLOCK) == -1 ||
+ fcntl(p_stdout[0], F_SETFL, O_NONBLOCK) == -1 ||
+ fcntl(p_stderr[0], F_SETFL, O_NONBLOCK) == -1) {
+ error = errno;
+ close_pipes(p_stdin, p_stdout, p_stderr);
+ waitpid(mbr_pid, NULL, 0);
+ mbr_pid = 0;
+ err("fcntl(): %s", strerror(error));
+ return -1;
+ }
+
+ mbr_cmd_fd = p_stdin[1];
+ mbr_audio_fd = p_stdout[0];
+ mbr_error_fd = p_stderr[0];
+ close(p_stdin[0]);
+ close(p_stdout[1]);
+ close(p_stderr[1]);
+
+ mbr_state = MBR_IDLE;
+ return 0;
+}
+
+static void stop_mbrola(void)
+{
+ if (mbr_state == MBR_INACTIVE)
+ return;
+ close(mbr_proc_stat);
+ close(mbr_cmd_fd);
+ close(mbr_audio_fd);
+ close(mbr_error_fd);
+ if (mbr_pid) {
+ kill(mbr_pid, SIGTERM);
+ waitpid(mbr_pid, NULL, 0);
+ mbr_pid = 0;
+ }
+ mbr_state = MBR_INACTIVE;
+}
+
+static void free_pending_data(void)
+{
+ struct datablock *p, *head = mbr_pending_data_head;
+ while (head) {
+ p = head;
+ head = head->next;
+ free(p);
+ }
+ mbr_pending_data_head = NULL;
+ mbr_pending_data_tail = NULL;
+}
+
+static int mbrola_died(void)
+{
+ pid_t pid;
+ int status, len;
+ const char *msg;
+ char msgbuf[80];
+
+ pid = waitpid(mbr_pid, &status, WNOHANG);
+ if (!pid) {
+ msg = "mbrola closed stderr and did not exit";
+ } else if (pid != mbr_pid) {
+ msg = "waitpid() is confused";
+ } else {
+ mbr_pid = 0;
+ if (WIFSIGNALED(status)) {
+ int sig = WTERMSIG(status);
+ snprintf(msgbuf, sizeof(msgbuf),
+ "mbrola died by signal %d", sig);
+ msg = msgbuf;
+ } else if (WIFEXITED(status)) {
+ int exst = WEXITSTATUS(status);
+ snprintf(msgbuf, sizeof(msgbuf),
+ "mbrola exited with status %d", exst);
+ msg = msgbuf;
+ } else {
+ msg = "mbrola died and wait status is weird";
+ }
+ }
+
+ mbro_log("mbrowrap error: %s", msg);
+
+ len = strlen(mbr_errorbuf);
+ if (!len)
+ snprintf(mbr_errorbuf, sizeof(mbr_errorbuf), "%s", msg);
+ else
+ snprintf(mbr_errorbuf + len, sizeof(mbr_errorbuf) - len,
+ ", (%s)", msg);
+ return -1;
+}
+
+static int mbrola_has_errors(void)
+{
+ int result;
+ char buffer[256];
+ char *buf_ptr, *lf;
+
+ buf_ptr = buffer;
+ for (;;) {
+ result = read(mbr_error_fd, buf_ptr,
+ sizeof(buffer) - (buf_ptr - buffer) - 1);
+ if (result == -1) {
+ if (errno == EAGAIN)
+ return 0;
+ err("read(error): %s", strerror(errno));
+ return -1;
+ }
+
+ if (result == 0) {
+ /* EOF on stderr, assume mbrola died. */
+ return mbrola_died();
+ }
+
+ buf_ptr[result] = 0;
+
+ for (; (lf = strchr(buf_ptr, '\n')); buf_ptr = lf + 1) {
+ /* inhibit the reset signal messages */
+ if (strncmp(buf_ptr, "Got a reset signal", 18) == 0 ||
+ strncmp(buf_ptr, "Input Flush Signal", 18) == 0)
+ continue;
+ *lf = 0;
+ mbro_log("mbrola: %s", buf_ptr);
+ /* is this the last line? */
+ if (lf == &buf_ptr[result - 1]) {
+ snprintf(mbr_errorbuf, sizeof(mbr_errorbuf),
+ "%s", buf_ptr);
+ /* don't consider this fatal at this point */
+ return 0;
+ }
+ }
+
+ memmove(buffer, buf_ptr, result);
+ buf_ptr = buffer + result;
+ }
+}
+
+static int send_to_mbrola(const char *cmd)
+{
+ ssize_t result;
+ int len;
+
+ if (!mbr_pid)
+ return -1;
+
+ len = strlen(cmd);
+ result = write(mbr_cmd_fd, cmd, len);
+
+ if (result == -1) {
+ int error = errno;
+ if (error == EPIPE && mbrola_has_errors()) {
+ return -1;
+ } else if (error == EAGAIN) {
+ result = 0;
+ } else {
+ err("write(): %s", strerror(error));
+ return -1;
+ }
+ }
+
+ if (result != len) {
+ struct datablock *data;
+ data = (struct datablock *)malloc(sizeof(*data) + len - result);
+ if (data) {
+ data->next = NULL;
+ data->done = 0;
+ data->size = len - result;
+ memcpy(data->buffer, cmd + result, len - result);
+ result = len;
+ if (!mbr_pending_data_head)
+ mbr_pending_data_head = data;
+ else
+ mbr_pending_data_tail->next = data;
+ mbr_pending_data_tail = data;
+ }
+ }
+
+ return result;
+}
+
+static int mbrola_is_idle(void)
+{
+ char *p;
+ char buffer[20]; /* looking for "12345 (mbrola) S" so 20 is plenty*/
+
+ /* look in /proc to determine if mbrola is still running or sleeping */
+ if (lseek(mbr_proc_stat, 0, SEEK_SET) != 0)
+ return 0;
+ if (read(mbr_proc_stat, buffer, sizeof(buffer)) != sizeof(buffer))
+ return 0;
+ p = (char *)memchr(buffer, ')', sizeof(buffer));
+ if (!p || (unsigned)(p - buffer) >= sizeof(buffer) - 2)
+ return 0;
+ return (p[1] == ' ' && p[2] == 'S');
+}
+
+static ssize_t receive_from_mbrola(void *buffer, size_t bufsize)
+{
+ int result, wait = 1;
+ size_t cursize = 0;
+
+ if (!mbr_pid)
+ return -1;
+
+ do {
+ struct pollfd pollfd[3];
+ nfds_t nfds = 0;
+ int idle;
+
+ pollfd[0].fd = mbr_audio_fd;
+ pollfd[0].events = POLLIN;
+ nfds++;
+
+ pollfd[1].fd = mbr_error_fd;
+ pollfd[1].events = POLLIN;
+ nfds++;
+
+ if (mbr_pending_data_head) {
+ pollfd[2].fd = mbr_cmd_fd;
+ pollfd[2].events = POLLOUT;
+ nfds++;
+ }
+
+ idle = mbrola_is_idle();
+ result = poll(pollfd, nfds, idle ? 0 : wait);
+ if (result == -1) {
+ err("poll(): %s", strerror(errno));
+ return -1;
+ }
+ if (result == 0) {
+ if (idle) {
+ mbr_state = MBR_IDLE;
+ break;
+ } else {
+ if (wait >= 5000 * (4-1)/4) {
+ mbr_state = MBR_WEDGED;
+ err("mbrola process is stalled");
+ break;
+ } else {
+ wait *= 4;
+ continue;
+ }
+ }
+ }
+ wait = 1;
+
+ if (pollfd[1].revents && mbrola_has_errors())
+ return -1;
+
+ if (mbr_pending_data_head && pollfd[2].revents) {
+ struct datablock *head = mbr_pending_data_head;
+ char *data = head->buffer + head->done;
+ int left = head->size - head->done;
+ result = write(mbr_cmd_fd, data, left);
+ if (result == -1) {
+ int error = errno;
+ if (error == EPIPE && mbrola_has_errors())
+ return -1;
+ err("write(): %s", strerror(error));
+ return -1;
+ }
+ if (result != left) {
+ head->done += result;
+ } else {
+ mbr_pending_data_head = head->next;
+ free(head);
+ if (!mbr_pending_data_head)
+ mbr_pending_data_tail = NULL;
+ else
+ continue;
+ }
+ }
+
+ if (pollfd[0].revents) {
+ char *curpos = (char *)buffer + cursize;
+ size_t space = bufsize - cursize;
+ ssize_t obtained = read(mbr_audio_fd, curpos, space);
+ if (obtained == -1) {
+ err("read(): %s", strerror(errno));
+ return -1;
+ }
+ cursize += obtained;
+ mbr_state = MBR_AUDIO;
+ }
+ } while (cursize < bufsize);
+
+ return cursize;
+}
+
+/*
+ * API functions.
+ */
+
+int init_MBR(const char *voice_path)
+{
+ int error, result;
+ unsigned char wavhdr[45];
+
+ error = start_mbrola(voice_path);
+ if (error)
+ return -1;
+
+ result = send_to_mbrola("#\n");
+ if (result != 2) {
+ stop_mbrola();
+ return -1;
+ }
+
+ /* we should actually be getting only 44 bytes */
+ result = receive_from_mbrola(wavhdr, 45);
+ if (result != 44) {
+ if (result >= 0)
+ err("unable to get .wav header from mbrola");
+ stop_mbrola();
+ return -1;
+ }
+
+ /* parse wavhdr to get mbrola voice samplerate */
+ if (memcmp(wavhdr, "RIFF", 4) != 0 ||
+ memcmp(wavhdr+8, "WAVEfmt ", 8) != 0) {
+ err("mbrola did not return a .wav header");
+ stop_mbrola();
+ return -1;
+ }
+ mbr_samplerate = wavhdr[24] + (wavhdr[25]<<8) +
+ (wavhdr[26]<<16) + (wavhdr[27]<<24);
+ //mbro_log("mbrowrap: voice samplerate = %d", mbr_samplerate);
+
+ /* remember the voice path for setVolumeRatio_MBR() */
+ if (mbr_voice_path != voice_path) {
+ free(mbr_voice_path);
+ mbr_voice_path = strdup(voice_path);
+ }
+
+ return 0;
+}
+
+void close_MBR(void)
+{
+ stop_mbrola();
+ free_pending_data();
+ free(mbr_voice_path);
+ mbr_voice_path = NULL;
+ mbr_volume = 1.0;
+}
+
+int reset_MBR()
+{
+ int result, success = 1;
+ char dummybuf[4096];
+
+ if (mbr_state == MBR_IDLE)
+ return 1;
+ if (!mbr_pid)
+ return 0;
+ if (kill(mbr_pid, SIGUSR1) == -1)
+ success = 0;
+ free_pending_data();
+ result = write(mbr_cmd_fd, "\n#\n", 3);
+ if (result != 3)
+ success = 0;
+ do {
+ result = read(mbr_audio_fd, dummybuf, sizeof(dummybuf));
+ } while (result > 0);
+ if (result != -1 || errno != EAGAIN)
+ success = 0;
+ if (!mbrola_has_errors() && success)
+ mbr_state = MBR_IDLE;
+ return success;
+}
+
+int read_MBR(void *buffer, int nb_samples)
+{
+ int result = receive_from_mbrola(buffer, nb_samples * 2);
+ if (result > 0)
+ result /= 2;
+ return result;
+}
+
+int write_MBR(const char *data)
+{
+ mbr_state = MBR_NEWDATA;
+ return send_to_mbrola(data);
+}
+
+int flush_MBR(void)
+{
+ return send_to_mbrola("\n#\n") == 3;
+}
+
+int getFreq_MBR(void)
+{
+ return mbr_samplerate;
+}
+
+void setVolumeRatio_MBR(float value)
+{
+ if (value == mbr_volume)
+ return;
+ mbr_volume = value;
+ if (mbr_state != MBR_IDLE)
+ return;
+ /*
+ * We have no choice but to kill and restart mbrola with
+ * the new argument here.
+ */
+ stop_mbrola();
+ init_MBR(mbr_voice_path);
+}
+
+int lastErrorStr_MBR(char *buffer, int bufsize)
+{
+ int result;
+ if (mbr_pid)
+ mbrola_has_errors();
+ result = snprintf(buffer, bufsize, "%s", mbr_errorbuf);
+ return result >= bufsize ? (bufsize - 1) : result;
+}
+
+void resetError_MBR(void)
+{
+ mbr_errorbuf[0] = 0;
+}
+
+#endif // INCLUDE_MBROLA
diff --git a/navit/support/espeak/mbrowrap.h b/navit/support/espeak/mbrowrap.h
new file mode 100644
index 000000000..c55028cf4
--- /dev/null
+++ b/navit/support/espeak/mbrowrap.h
@@ -0,0 +1,108 @@
+/*
+ * mbrowrap -- A wrapper library around the mbrola binary
+ * providing a subset of the API from the Windows mbrola DLL.
+ *
+ * Copyright (C) 2010 by Nicolas Pitre <nico@fluxnic.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef MBROWRAP_H
+#define MBROWRAP_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*
+ * Initialize mbrola. The 'voice_path' argument must contain the
+ * path and file name to the mbrola voice database to be used. Returned
+ * value is 0 on success, or an error code otherwise (currently only -1
+ * is returned. If not successful, lastErrorStr_MBR() will provide the
+ * error reason. If this is successful, then close_MBR() must be called
+ * before init_MBR() can be called again.
+ */
+int init_MBR(const char *voice_path);
+
+/*
+ * Stop mbrola and release any resources. It is necessary to call
+ * this after a successful call to init_MBR() before init_MBR() can be
+ * called again.
+ */
+void close_MBR(void);
+
+/*
+ * Stop any ongoing processing and flush all buffers. After this call
+ * any synthesis request will start afresh. A non-zero value is returned
+ * on success, or 0 on failure. If not successful, lastErrorStr_MBR() will
+ * provide the error reason.
+ */
+int reset_MBR(void);
+
+/*
+ * Return at most 'nb_samples' audio samples into 'buffer'. The returned
+ * value is the actual number of samples returned, or -1 on error.
+ * If not successful, lastErrorStr_MBR() will provide the error reason.
+ * Samples are always 16-bit little endian.
+ */
+int read_MBR(void *buffer, int nb_samples);
+
+/*
+ * Write a NULL terminated string of phoneme in the input buffer.
+ * Return the number of chars actually written, or -1 on error.
+ * If not successful, lastErrorStr_MBR() will provide the error reason.
+ */
+int write_MBR(const char *data);
+
+/*
+ * Send a flush command to the mbrola input stream.
+ * This is currently similar to write_MBR("#\n"). Return 1 on success
+ * or 0 on failure. If not successful, lastErrorStr_MBR() will provide
+ * the error reason.
+ */
+int flush_MBR(void);
+
+/*
+ * Return the audio sample frequency of the used voice database.
+ */
+int getFreq_MBR(void);
+
+/*
+ * Overall volume.
+ */
+void setVolumeRatio_MBR(float value);
+
+/*
+ * Copy into 'buffer' at most 'bufsize' bytes from the latest error
+ * message. This may also contain non-fatal errors from mbrola. The
+ * returned value is the actual number of bytes copied. When no error
+ * message is pending then an empty string is returned. Consecutive
+ * calls to lastErrorStr_MBR() will return the same message unless it
+ * is explicitly cleared with resetError_MBR().
+ */
+int lastErrorStr_MBR(char *buffer, int bufsize);
+
+/*
+ * Clear any pending error message.
+ */
+void resetError_MBR(void);
+
+/*
+ * Tolerance to missing diphones (always active so this is ignored)
+ */
+static inline void setNoError_MBR(int no_error) { }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/navit/support/espeak/numbers.c b/navit/support/espeak/numbers.c
index 9c74eaca3..0289ab4ec 100644
--- a/navit/support/espeak/numbers.c
+++ b/navit/support/espeak/numbers.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <ctype.h>
+#include <stdbool.h> //for bool type
#include <stdlib.h>
#include <string.h>
@@ -65,37 +66,43 @@
#define M_MIDDLE_DOT M_DOT_ABOVE // duplicate of M_DOT_ABOVE
#define M_IMPLOSIVE M_HOOK
+static int n_digit_lookup;
+static char *digit_lookup;
+static int speak_missing_thousands;
+static int number_control;
+
+
typedef struct {
-const char *name;
-int flags;
+ const char *name;
+ int flags;
} ACCENTS;
// these are tokens to look up in the *_list file.
static ACCENTS accents_tab[] = {
-{"_lig", 1},
-{"_smc", 1}, // smallcap
-{"_tur", 1}, // turned
-{"_rev", 1}, // reversed
-{"_crl", 0}, // curl
-
-{"_acu", 0}, // acute
-{"_brv", 0}, // breve
-{"_hac", 0}, // caron/hacek
-{"_ced", 0}, // cedilla
-{"_cir", 0}, // circumflex
-{"_dia", 0}, // diaeresis
-{"_ac2", 0}, // double acute
-{"_dot", 0}, // dot
-{"_grv", 0}, // grave
-{"_mcn", 0}, // macron
-{"_ogo", 0}, // ogonek
-{"_rng", 0}, // ring
-{"_stk", 0}, // stroke
-{"_tld", 0}, // tilde
-
-{"_bar", 0}, // bar
-{"_rfx", 0}, // retroflex
-{"_hok", 0}, // hook
+ {"_lig", 1},
+ {"_smc", 1}, // smallcap
+ {"_tur", 1}, // turned
+ {"_rev", 1}, // reversed
+ {"_crl", 0}, // curl
+
+ {"_acu", 0}, // acute
+ {"_brv", 0}, // breve
+ {"_hac", 0}, // caron/hacek
+ {"_ced", 0}, // cedilla
+ {"_cir", 0}, // circumflex
+ {"_dia", 0}, // diaeresis
+ {"_ac2", 0}, // double acute
+ {"_dot", 0}, // dot
+ {"_grv", 0}, // grave
+ {"_mcn", 0}, // macron
+ {"_ogo", 0}, // ogonek
+ {"_rng", 0}, // ring
+ {"_stk", 0}, // stroke
+ {"_tld", 0}, // tilde
+
+ {"_bar", 0}, // bar
+ {"_rfx", 0}, // retroflex
+ {"_hok", 0}, // hook
};
@@ -121,270 +128,271 @@ static ACCENTS accents_tab[] = {
static const short non_ascii_tab[] = {
- 0, 0x3b1, 0x259, 0x25b, 0x3b3, 0x3b9, 0x153, 0x3c9,
-0x3c6, 0x283, 0x3c5, 0x292, 0x294, 0x27e };
+ 0, 0x3b1, 0x259, 0x25b, 0x3b3, 0x3b9, 0x153, 0x3c9,
+ 0x3c6, 0x283, 0x3c5, 0x292, 0x294, 0x27e
+};
// characters U+00e0 to U+017f
static const unsigned short letter_accents_0e0[] = {
-LETTER('a',M_GRAVE,0), // U+00e0
-LETTER('a',M_ACUTE,0),
-LETTER('a',M_CIRCUMFLEX,0),
-LETTER('a',M_TILDE,0),
-LETTER('a',M_DIAERESIS,0),
-LETTER('a',M_RING,0),
-LIGATURE('a','e',0),
-LETTER('c',M_CEDILLA,0),
-LETTER('e',M_GRAVE,0),
-LETTER('e',M_ACUTE,0),
-LETTER('e',M_CIRCUMFLEX,0),
-LETTER('e',M_DIAERESIS,0),
-LETTER('i',M_GRAVE,0),
-LETTER('i',M_ACUTE,0),
-LETTER('i',M_CIRCUMFLEX,0),
-LETTER('i',M_DIAERESIS,0),
-LETTER('d',M_NAME,0), // eth // U+00f0
-LETTER('n',M_TILDE,0),
-LETTER('o',M_GRAVE,0),
-LETTER('o',M_ACUTE,0),
-LETTER('o',M_CIRCUMFLEX,0),
-LETTER('o',M_TILDE,0),
-LETTER('o',M_DIAERESIS,0),
-0, // division sign
-LETTER('o',M_STROKE,0),
-LETTER('u',M_GRAVE,0),
-LETTER('u',M_ACUTE,0),
-LETTER('u',M_CIRCUMFLEX,0),
-LETTER('u',M_DIAERESIS,0),
-LETTER('y',M_ACUTE,0),
-LETTER('t',M_NAME,0), // thorn
-LETTER('y',M_DIAERESIS,0),
-CAPITAL, // U+0100
-LETTER('a',M_MACRON,0),
-CAPITAL,
-LETTER('a',M_BREVE,0),
-CAPITAL,
-LETTER('a',M_OGONEK,0),
-CAPITAL,
-LETTER('c',M_ACUTE,0),
-CAPITAL,
-LETTER('c',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('c',M_DOT_ABOVE,0),
-CAPITAL,
-LETTER('c',M_CARON,0),
-CAPITAL,
-LETTER('d',M_CARON,0),
-CAPITAL, // U+0110
-LETTER('d',M_STROKE,0),
-CAPITAL,
-LETTER('e',M_MACRON,0),
-CAPITAL,
-LETTER('e',M_BREVE,0),
-CAPITAL,
-LETTER('e',M_DOT_ABOVE,0),
-CAPITAL,
-LETTER('e',M_OGONEK,0),
-CAPITAL,
-LETTER('e',M_CARON,0),
-CAPITAL,
-LETTER('g',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('g',M_BREVE,0),
-CAPITAL, // U+0120
-LETTER('g',M_DOT_ABOVE,0),
-CAPITAL,
-LETTER('g',M_CEDILLA,0),
-CAPITAL,
-LETTER('h',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('h',M_STROKE,0),
-CAPITAL,
-LETTER('i',M_TILDE,0),
-CAPITAL,
-LETTER('i',M_MACRON,0),
-CAPITAL,
-LETTER('i',M_BREVE,0),
-CAPITAL,
-LETTER('i',M_OGONEK,0),
-CAPITAL, // U+0130
-LETTER('i',M_NAME,0), // dotless i
-CAPITAL,
-LIGATURE('i','j',0),
-CAPITAL,
-LETTER('j',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('k',M_CEDILLA,0),
-LETTER('k',M_NAME,0), // kra
-CAPITAL,
-LETTER('l',M_ACUTE,0),
-CAPITAL,
-LETTER('l',M_CEDILLA,0),
-CAPITAL,
-LETTER('l',M_CARON,0),
-CAPITAL,
-LETTER('l',M_MIDDLE_DOT,0), // U+0140
-CAPITAL,
-LETTER('l',M_STROKE,0),
-CAPITAL,
-LETTER('n',M_ACUTE,0),
-CAPITAL,
-LETTER('n',M_CEDILLA,0),
-CAPITAL,
-LETTER('n',M_CARON,0),
-LETTER('n',M_NAME,0), // apostrophe n
-CAPITAL,
-LETTER('n',M_NAME,0), // eng
-CAPITAL,
-LETTER('o',M_MACRON,0),
-CAPITAL,
-LETTER('o',M_BREVE,0),
-CAPITAL, // U+0150
-LETTER('o',M_DOUBLE_ACUTE,0),
-CAPITAL,
-LIGATURE('o','e',0),
-CAPITAL,
-LETTER('r',M_ACUTE,0),
-CAPITAL,
-LETTER('r',M_CEDILLA,0),
-CAPITAL,
-LETTER('r',M_CARON,0),
-CAPITAL,
-LETTER('s',M_ACUTE,0),
-CAPITAL,
-LETTER('s',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('s',M_CEDILLA,0),
-CAPITAL, // U+0160
-LETTER('s',M_CARON,0),
-CAPITAL,
-LETTER('t',M_CEDILLA,0),
-CAPITAL,
-LETTER('t',M_CARON,0),
-CAPITAL,
-LETTER('t',M_STROKE,0),
-CAPITAL,
-LETTER('u',M_TILDE,0),
-CAPITAL,
-LETTER('u',M_MACRON,0),
-CAPITAL,
-LETTER('u',M_BREVE,0),
-CAPITAL,
-LETTER('u',M_RING,0),
-CAPITAL, // U+0170
-LETTER('u',M_DOUBLE_ACUTE,0),
-CAPITAL,
-LETTER('u',M_OGONEK,0),
-CAPITAL,
-LETTER('w',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('y',M_CIRCUMFLEX,0),
-CAPITAL, // Y-DIAERESIS
-CAPITAL,
-LETTER('z',M_ACUTE,0),
-CAPITAL,
-LETTER('z',M_DOT_ABOVE,0),
-CAPITAL,
-LETTER('z',M_CARON,0),
-LETTER('s',M_NAME,0), // long-s // U+17f
+ LETTER('a',M_GRAVE,0), // U+00e0
+ LETTER('a',M_ACUTE,0),
+ LETTER('a',M_CIRCUMFLEX,0),
+ LETTER('a',M_TILDE,0),
+ LETTER('a',M_DIAERESIS,0),
+ LETTER('a',M_RING,0),
+ LIGATURE('a','e',0),
+ LETTER('c',M_CEDILLA,0),
+ LETTER('e',M_GRAVE,0),
+ LETTER('e',M_ACUTE,0),
+ LETTER('e',M_CIRCUMFLEX,0),
+ LETTER('e',M_DIAERESIS,0),
+ LETTER('i',M_GRAVE,0),
+ LETTER('i',M_ACUTE,0),
+ LETTER('i',M_CIRCUMFLEX,0),
+ LETTER('i',M_DIAERESIS,0),
+ LETTER('d',M_NAME,0), // eth // U+00f0
+ LETTER('n',M_TILDE,0),
+ LETTER('o',M_GRAVE,0),
+ LETTER('o',M_ACUTE,0),
+ LETTER('o',M_CIRCUMFLEX,0),
+ LETTER('o',M_TILDE,0),
+ LETTER('o',M_DIAERESIS,0),
+ 0, // division sign
+ LETTER('o',M_STROKE,0),
+ LETTER('u',M_GRAVE,0),
+ LETTER('u',M_ACUTE,0),
+ LETTER('u',M_CIRCUMFLEX,0),
+ LETTER('u',M_DIAERESIS,0),
+ LETTER('y',M_ACUTE,0),
+ LETTER('t',M_NAME,0), // thorn
+ LETTER('y',M_DIAERESIS,0),
+ CAPITAL, // U+0100
+ LETTER('a',M_MACRON,0),
+ CAPITAL,
+ LETTER('a',M_BREVE,0),
+ CAPITAL,
+ LETTER('a',M_OGONEK,0),
+ CAPITAL,
+ LETTER('c',M_ACUTE,0),
+ CAPITAL,
+ LETTER('c',M_CIRCUMFLEX,0),
+ CAPITAL,
+ LETTER('c',M_DOT_ABOVE,0),
+ CAPITAL,
+ LETTER('c',M_CARON,0),
+ CAPITAL,
+ LETTER('d',M_CARON,0),
+ CAPITAL, // U+0110
+ LETTER('d',M_STROKE,0),
+ CAPITAL,
+ LETTER('e',M_MACRON,0),
+ CAPITAL,
+ LETTER('e',M_BREVE,0),
+ CAPITAL,
+ LETTER('e',M_DOT_ABOVE,0),
+ CAPITAL,
+ LETTER('e',M_OGONEK,0),
+ CAPITAL,
+ LETTER('e',M_CARON,0),
+ CAPITAL,
+ LETTER('g',M_CIRCUMFLEX,0),
+ CAPITAL,
+ LETTER('g',M_BREVE,0),
+ CAPITAL, // U+0120
+ LETTER('g',M_DOT_ABOVE,0),
+ CAPITAL,
+ LETTER('g',M_CEDILLA,0),
+ CAPITAL,
+ LETTER('h',M_CIRCUMFLEX,0),
+ CAPITAL,
+ LETTER('h',M_STROKE,0),
+ CAPITAL,
+ LETTER('i',M_TILDE,0),
+ CAPITAL,
+ LETTER('i',M_MACRON,0),
+ CAPITAL,
+ LETTER('i',M_BREVE,0),
+ CAPITAL,
+ LETTER('i',M_OGONEK,0),
+ CAPITAL, // U+0130
+ LETTER('i',M_NAME,0), // dotless i
+ CAPITAL,
+ LIGATURE('i','j',0),
+ CAPITAL,
+ LETTER('j',M_CIRCUMFLEX,0),
+ CAPITAL,
+ LETTER('k',M_CEDILLA,0),
+ LETTER('k',M_NAME,0), // kra
+ CAPITAL,
+ LETTER('l',M_ACUTE,0),
+ CAPITAL,
+ LETTER('l',M_CEDILLA,0),
+ CAPITAL,
+ LETTER('l',M_CARON,0),
+ CAPITAL,
+ LETTER('l',M_MIDDLE_DOT,0), // U+0140
+ CAPITAL,
+ LETTER('l',M_STROKE,0),
+ CAPITAL,
+ LETTER('n',M_ACUTE,0),
+ CAPITAL,
+ LETTER('n',M_CEDILLA,0),
+ CAPITAL,
+ LETTER('n',M_CARON,0),
+ LETTER('n',M_NAME,0), // apostrophe n
+ CAPITAL,
+ LETTER('n',M_NAME,0), // eng
+ CAPITAL,
+ LETTER('o',M_MACRON,0),
+ CAPITAL,
+ LETTER('o',M_BREVE,0),
+ CAPITAL, // U+0150
+ LETTER('o',M_DOUBLE_ACUTE,0),
+ CAPITAL,
+ LIGATURE('o','e',0),
+ CAPITAL,
+ LETTER('r',M_ACUTE,0),
+ CAPITAL,
+ LETTER('r',M_CEDILLA,0),
+ CAPITAL,
+ LETTER('r',M_CARON,0),
+ CAPITAL,
+ LETTER('s',M_ACUTE,0),
+ CAPITAL,
+ LETTER('s',M_CIRCUMFLEX,0),
+ CAPITAL,
+ LETTER('s',M_CEDILLA,0),
+ CAPITAL, // U+0160
+ LETTER('s',M_CARON,0),
+ CAPITAL,
+ LETTER('t',M_CEDILLA,0),
+ CAPITAL,
+ LETTER('t',M_CARON,0),
+ CAPITAL,
+ LETTER('t',M_STROKE,0),
+ CAPITAL,
+ LETTER('u',M_TILDE,0),
+ CAPITAL,
+ LETTER('u',M_MACRON,0),
+ CAPITAL,
+ LETTER('u',M_BREVE,0),
+ CAPITAL,
+ LETTER('u',M_RING,0),
+ CAPITAL, // U+0170
+ LETTER('u',M_DOUBLE_ACUTE,0),
+ CAPITAL,
+ LETTER('u',M_OGONEK,0),
+ CAPITAL,
+ LETTER('w',M_CIRCUMFLEX,0),
+ CAPITAL,
+ LETTER('y',M_CIRCUMFLEX,0),
+ CAPITAL, // Y-DIAERESIS
+ CAPITAL,
+ LETTER('z',M_ACUTE,0),
+ CAPITAL,
+ LETTER('z',M_DOT_ABOVE,0),
+ CAPITAL,
+ LETTER('z',M_CARON,0),
+ LETTER('s',M_NAME,0), // long-s // U+17f
};
// characters U+0250 to U+029F
static const unsigned short letter_accents_250[] = {
-LETTER('a',M_TURNED,0), // U+250
-LETTER(L_ALPHA,0,0),
-LETTER(L_ALPHA,M_TURNED,0),
-LETTER('b',M_IMPLOSIVE,0),
-0, // open-o
-LETTER('c',M_CURL,0),
-LETTER('d',M_RETROFLEX,0),
-LETTER('d',M_IMPLOSIVE,0),
-LETTER('e',M_REVERSED,0), // U+258
-0, // schwa
-LETTER(L_SCHWA,M_HOOK,0),
-0, // open-e
-LETTER(L_OPEN_E,M_REVERSED,0),
-LETTER(L_OPEN_E,M_HOOK,M_REVERSED),
-0,//LETTER(L_OPEN_E,M_CLOSED,M_REVERSED),
-LETTER('j',M_BAR,0),
-LETTER('g',M_IMPLOSIVE,0), // U+260
-LETTER('g',0,0),
-LETTER('g',M_SMALLCAP,0),
-LETTER(L_GAMMA,0,0),
-0, // ramshorn
-LETTER('h',M_TURNED,0),
-LETTER('h',M_HOOK,0),
-0,//LETTER(L_HENG,M_HOOK,0),
-LETTER('i',M_BAR,0), // U+268
-LETTER(L_IOTA,0,0),
-LETTER('i',M_SMALLCAP,0),
-LETTER('l',M_TILDE,0),
-LETTER('l',M_BAR,0),
-LETTER('l',M_RETROFLEX,0),
-LIGATURE('l','z',0),
-LETTER('m',M_TURNED,0),
-0,//LETTER('m',M_TURNED,M_LEG), // U+270
-LETTER('m',M_HOOK,0),
-0,//LETTER('n',M_LEFTHOOK,0),
-LETTER('n',M_RETROFLEX,0),
-LETTER('n',M_SMALLCAP,0),
-LETTER('o',M_BAR,0),
-LIGATURE('o','e',M_SMALLCAP),
-0,//LETTER(L_OMEGA,M_CLOSED,0),
-LETTER(L_PHI,0,0), // U+278
-LETTER('r',M_TURNED,0),
-0,//LETTER('r',M_TURNED,M_LEG),
-LETTER('r',M_RETROFLEX,M_TURNED),
-0,//LETTER('r',M_LEG,0),
-LETTER('r',M_RETROFLEX,0),
-0, // r-tap
-LETTER(L_RTAP,M_REVERSED,0),
-LETTER('r',M_SMALLCAP,0), // U+280
-LETTER('r',M_TURNED,M_SMALLCAP),
-LETTER('s',M_RETROFLEX,0),
-0, // esh
-0,//LETTER('j',M_BAR,L_IMPLOSIVE),
-LETTER(L_ESH,M_REVERSED,0),
-LETTER(L_ESH,M_CURL,0),
-LETTER('t',M_TURNED,0),
-LETTER('t',M_RETROFLEX,0), // U+288
-LETTER('u',M_BAR,0),
-LETTER(L_UPSILON,0,0),
-LETTER('v',M_HOOK,0),
-LETTER('v',M_TURNED,0),
-LETTER('w',M_TURNED,0),
-LETTER('y',M_TURNED,0),
-LETTER('y',M_SMALLCAP,0),
-LETTER('z',M_RETROFLEX,0), // U+290
-LETTER('z',M_CURL,0),
-0, // ezh
-LETTER(L_EZH,M_CURL,0),
-0, // glottal stop
-LETTER(L_GLOTTAL,M_REVERSED,0),
-LETTER(L_GLOTTAL,M_TURNED,0),
-0,//LETTER('c',M_LONG,0),
-0, // bilabial click // U+298
-LETTER('b',M_SMALLCAP,0),
-0,//LETTER(L_OPEN_E,M_CLOSED,0),
-LETTER('g',M_IMPLOSIVE,M_SMALLCAP),
-LETTER('h',M_SMALLCAP,0),
-LETTER('j',M_CURL,0),
-LETTER('k',M_TURNED,0),
-LETTER('l',M_SMALLCAP,0),
-LETTER('q',M_HOOK,0), // U+2a0
-LETTER(L_GLOTTAL,M_STROKE,0),
-LETTER(L_GLOTTAL,M_STROKE,M_REVERSED),
-LIGATURE('d','z',0),
-0, // dezh
-LIGATURE('d','z',M_CURL),
-LIGATURE('t','s',0),
-0, // tesh
-LIGATURE('t','s',M_CURL),
+ LETTER('a',M_TURNED,0), // U+250
+ LETTER(L_ALPHA,0,0),
+ LETTER(L_ALPHA,M_TURNED,0),
+ LETTER('b',M_IMPLOSIVE,0),
+ 0, // open-o
+ LETTER('c',M_CURL,0),
+ LETTER('d',M_RETROFLEX,0),
+ LETTER('d',M_IMPLOSIVE,0),
+ LETTER('e',M_REVERSED,0), // U+258
+ 0, // schwa
+ LETTER(L_SCHWA,M_HOOK,0),
+ 0, // open-e
+ LETTER(L_OPEN_E,M_REVERSED,0),
+ LETTER(L_OPEN_E,M_HOOK,M_REVERSED),
+ 0,//LETTER(L_OPEN_E,M_CLOSED,M_REVERSED),
+ LETTER('j',M_BAR,0),
+ LETTER('g',M_IMPLOSIVE,0), // U+260
+ LETTER('g',0,0),
+ LETTER('g',M_SMALLCAP,0),
+ LETTER(L_GAMMA,0,0),
+ 0, // ramshorn
+ LETTER('h',M_TURNED,0),
+ LETTER('h',M_HOOK,0),
+ 0,//LETTER(L_HENG,M_HOOK,0),
+ LETTER('i',M_BAR,0), // U+268
+ LETTER(L_IOTA,0,0),
+ LETTER('i',M_SMALLCAP,0),
+ LETTER('l',M_TILDE,0),
+ LETTER('l',M_BAR,0),
+ LETTER('l',M_RETROFLEX,0),
+ LIGATURE('l','z',0),
+ LETTER('m',M_TURNED,0),
+ 0,//LETTER('m',M_TURNED,M_LEG), // U+270
+ LETTER('m',M_HOOK,0),
+ 0,//LETTER('n',M_LEFTHOOK,0),
+ LETTER('n',M_RETROFLEX,0),
+ LETTER('n',M_SMALLCAP,0),
+ LETTER('o',M_BAR,0),
+ LIGATURE('o','e',M_SMALLCAP),
+ 0,//LETTER(L_OMEGA,M_CLOSED,0),
+ LETTER(L_PHI,0,0), // U+278
+ LETTER('r',M_TURNED,0),
+ 0,//LETTER('r',M_TURNED,M_LEG),
+ LETTER('r',M_RETROFLEX,M_TURNED),
+ 0,//LETTER('r',M_LEG,0),
+ LETTER('r',M_RETROFLEX,0),
+ 0, // r-tap
+ LETTER(L_RTAP,M_REVERSED,0),
+ LETTER('r',M_SMALLCAP,0), // U+280
+ LETTER('r',M_TURNED,M_SMALLCAP),
+ LETTER('s',M_RETROFLEX,0),
+ 0, // esh
+ 0,//LETTER('j',M_BAR,L_IMPLOSIVE),
+ LETTER(L_ESH,M_REVERSED,0),
+ LETTER(L_ESH,M_CURL,0),
+ LETTER('t',M_TURNED,0),
+ LETTER('t',M_RETROFLEX,0), // U+288
+ LETTER('u',M_BAR,0),
+ LETTER(L_UPSILON,0,0),
+ LETTER('v',M_HOOK,0),
+ LETTER('v',M_TURNED,0),
+ LETTER('w',M_TURNED,0),
+ LETTER('y',M_TURNED,0),
+ LETTER('y',M_SMALLCAP,0),
+ LETTER('z',M_RETROFLEX,0), // U+290
+ LETTER('z',M_CURL,0),
+ 0, // ezh
+ LETTER(L_EZH,M_CURL,0),
+ 0, // glottal stop
+ LETTER(L_GLOTTAL,M_REVERSED,0),
+ LETTER(L_GLOTTAL,M_TURNED,0),
+ 0,//LETTER('c',M_LONG,0),
+ 0, // bilabial click // U+298
+ LETTER('b',M_SMALLCAP,0),
+ 0,//LETTER(L_OPEN_E,M_CLOSED,0),
+ LETTER('g',M_IMPLOSIVE,M_SMALLCAP),
+ LETTER('h',M_SMALLCAP,0),
+ LETTER('j',M_CURL,0),
+ LETTER('k',M_TURNED,0),
+ LETTER('l',M_SMALLCAP,0),
+ LETTER('q',M_HOOK,0), // U+2a0
+ LETTER(L_GLOTTAL,M_STROKE,0),
+ LETTER(L_GLOTTAL,M_STROKE,M_REVERSED),
+ LIGATURE('d','z',0),
+ 0, // dezh
+ LIGATURE('d','z',M_CURL),
+ LIGATURE('t','s',0),
+ 0, // tesh
+ LIGATURE('t','s',M_CURL),
};
static int LookupLetter2(Translator *tr, unsigned int letter, char *ph_buf)
-{//========================================================================
+{ //========================================================================
int len;
char single_letter[10];
@@ -425,11 +433,10 @@ void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf)
{
accent_data = letter_accents_0e0[letter - 0xe0];
}
- else
- if((letter >= 0x250) && (letter <= 0x2a8))
+ else if((letter >= 0x250) && (letter <= 0x2a8))
{
accent_data = letter_accents_250[letter - 0x250];
- }
+ }
if(accent_data != 0)
{
@@ -479,8 +486,7 @@ void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf)
{
if(accent1 == 0)
strcpy(ph_buf, ph_letter1);
- else
- if((tr->langopts.accents & 1) || (accents_tab[accent1].flags & 1))
+ else if((tr->langopts.accents & 1) || (accents_tab[accent1].flags & 1))
sprintf(ph_buf,"%s%c%c%s", ph_accent1, phonPAUSE_VSHORT, phonSTRESS_P, ph_letter1);
else
sprintf(ph_buf,"%c%s%c%s%c", phonSTRESS_2, ph_letter1, phonPAUSE_VSHORT, ph_accent1, phonPAUSE_VSHORT);
@@ -492,15 +498,14 @@ void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf)
-void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf1)
-{//=================================================================================
+void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf1, int control)
+{//==============================================================================================
+// control, bit 0: not the first letter of a word
+
int len;
- unsigned char *p;
static char single_letter[10] = {0,0};
- char ph_stress[2];
unsigned int dict_flags[2];
char ph_buf3[40];
- char *ptr;
ph_buf1[0] = 0;
len = utf8_out(letter,&single_letter[2]);
@@ -540,14 +545,13 @@ void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_b
if(next_byte != ' ')
next_byte = RULE_SPELLING;
- single_letter[3+len] = next_byte; // follow by space-space if the end of the word, or space-0x31
+ single_letter[3+len] = next_byte; // follow by space-space if the end of the word, or space-31
single_letter[1] = '_';
// if the $accent flag is set for this letter, use the accents table (below)
dict_flags[1] = 0;
- ptr = &single_letter[1];
-
+
if(Lookup(tr, &single_letter[1], ph_buf3) == 0)
{
single_letter[1] = ' ';
@@ -562,48 +566,170 @@ void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_b
LookupAccentedLetter(tr, letter, ph_buf3);
}
- if(ph_buf3[0] == 0)
+ strcpy(ph_buf1, ph_buf3);
+ if((ph_buf1[0] == 0) || (ph_buf1[0] == phonSWITCH))
{
- ph_buf1[0] = 0;
return;
}
- if(ph_buf3[0] == phonSWITCH)
+
+ dict_flags[0] = 0;
+ dict_flags[1] = 0;
+ SetWordStress(tr, ph_buf1, dict_flags, -1, control & 1);
+
+} // end of LookupLetter
+
+
+// unicode ranges for non-ascii digits 0-9
+static const int number_ranges[] = {
+ 0x660, 0x6f0, // arabic
+ 0x966, 0x9e6, 0xa66, 0xae6, 0xb66, 0xbe6, 0xc66, 0xce6, 0xd66, // indic
+ 0xe50, 0xed0, 0xf20, 0x1040, 0x1090,
+ 0 }; // these must be in ascending order
+
+
+static int NonAsciiNumber(int letter)
+{//============================
+// Change non-ascii digit into ascii digit '0' to '9', (or -1 if not)
+ const int *p;
+ int base;
+
+ for(p=number_ranges; (base = *p) != 0; p++)
{
- strcpy(ph_buf1,ph_buf3);
- return;
+ if(letter < base)
+ break; // not found
+ if(letter < (base+10))
+ return(letter-base+'0');
}
- // at a stress marker at the start of the letter name, unless one is already marked
- ph_stress[0] = phonSTRESS_P;
- ph_stress[1] = 0;
+ return(-1);
+}
+
+#define L_SUB 0x4000 // subscript
+#define L_SUP 0x8000 // superscript
+
+static const char *modifiers[] = {NULL, "_sub", "_sup", NULL};
+
+// this list must be in ascending order
+static unsigned short derived_letters[] = {
+ 0x00aa, 'a'+L_SUP,
+ 0x00b2, '2'+L_SUP,
+ 0x00b3, '3'+L_SUP,
+ 0x00b9, '1'+L_SUP,
+ 0x00ba, 'o'+L_SUP,
+ 0x02b0, 'h'+L_SUP,
+ 0x02b1, 0x266+L_SUP,
+ 0x02b2, 'j'+L_SUP,
+ 0x02b3, 'r'+L_SUP,
+ 0x02b4, 0x279+L_SUP,
+ 0x02b5, 0x27b+L_SUP,
+ 0x02b6, 0x281+L_SUP,
+ 0x02b7, 'w'+L_SUP,
+ 0x02b8, 'y'+L_SUP,
+ 0x02c0, 0x294+L_SUP,
+ 0x02c1, 0x295+L_SUP,
+ 0x02e0, 0x263+L_SUP,
+ 0x02e1, 'l'+L_SUP,
+ 0x02e2, 's'+L_SUP,
+ 0x02e3, 'x'+L_SUP,
+ 0x2070, '0'+L_SUP,
+ 0x2071, 'i'+L_SUP,
+ 0x2074, '4'+L_SUP,
+ 0x2075, '5'+L_SUP,
+ 0x2076, '6'+L_SUP,
+ 0x2077, '7'+L_SUP,
+ 0x2078, '8'+L_SUP,
+ 0x2079, '9'+L_SUP,
+ 0x207a, '+'+L_SUP,
+ 0x207b, '-'+L_SUP,
+ 0x207c, '='+L_SUP,
+ 0x207d, '('+L_SUP,
+ 0x207e, ')'+L_SUP,
+ 0x207f, 'n'+L_SUP,
+ 0x2080, '0'+L_SUB,
+ 0x2081, '1'+L_SUB,
+ 0x2082, '2'+L_SUB,
+ 0x2083, '3'+L_SUB,
+ 0x2084, '4'+L_SUB,
+ 0x2085, '5'+L_SUB,
+ 0x2086, '6'+L_SUB,
+ 0x2087, '7'+L_SUB,
+ 0x2088, '8'+L_SUB,
+ 0x2089, '9'+L_SUB,
+ 0x208a, '+'+L_SUB,
+ 0x208b, '-'+L_SUB,
+ 0x208c, '='+L_SUB,
+ 0x208d, '('+L_SUB,
+ 0x208e, ')'+L_SUB,
+ 0x2090, 'a'+L_SUB,
+ 0x2091, 'e'+L_SUB,
+ 0x2092, 'o'+L_SUB,
+ 0x2093, 'x'+L_SUB,
+ 0x2094, 0x259+L_SUB,
+ 0x2095, 'h'+L_SUB,
+ 0x2096, 'k'+L_SUB,
+ 0x2097, 'l'+L_SUB,
+ 0x2098, 'm'+L_SUB,
+ 0x2099, 'n'+L_SUB,
+ 0x209a, 'p'+L_SUB,
+ 0x209b, 's'+L_SUB,
+ 0x209c, 't'+L_SUB,
+ 0,0};
+
+
+static const char *hex_letters[] = {"'e:j","b'i:","s'i:","d'i:","'i:","'ef"}; // names, using phonemes available to all languages
+
+
+int IsSuperscript(int letter)
+{//===========================
+// is this a subscript or superscript letter ?
+ int ix;
+ int c;
- for(p=(unsigned char *)ph_buf3; *p != 0; p++)
+ for(ix=0; (c = derived_letters[ix]) != 0; ix+=2)
{
- if(phoneme_tab[*p]->type == phSTRESS)
- ph_stress[0] = 0; // stress is already marked
+ if(c > letter)
+ break;
+ if(c == letter)
+ return(derived_letters[ix+1]);
}
- sprintf(ph_buf1,"%s%s",ph_stress,ph_buf3);
+ return(0);
}
-int TranslateLetter(Translator *tr, char *word, char *phonemes, int control, int word_length)
-{//======================================================================================
+int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
+{//=========================================================================
// get pronunciation for an isolated letter
// return number of bytes used by the letter
-// control 2=say-as glyphs, 3-say-as chars
+// control bit 0: a non-initial letter in a word
+// bit 1: say 'capital'
+// bit 2: say character code for unknown letters
+
int n_bytes;
int letter;
int len;
- int save_option_phonemes;
+ int ix;
+ int c;
char *p2;
char *pbuf;
- char capital[20];
- char ph_buf[60];
- char ph_buf2[60];
- char hexbuf[6];
+ const char *modifier;
+ ALPHABET *alphabet;
+ int al_offset;
+ int al_flags;
+ int language;
+ int number;
+ int phontab_1;
+ int speak_letter_number;
+ char capital[30];
+ char ph_buf[80];
+ char ph_buf2[80];
+ char ph_alphabet[80];
+ char hexbuf[12];
+ static char pause_string[] = {phonPAUSE, 0};
ph_buf[0] = 0;
+ ph_alphabet[0] = 0;
capital[0] = 0;
+ phontab_1 = translator->phoneme_tab_ix;
n_bytes = utf8_in(&letter,word);
@@ -612,17 +738,45 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control, int
letter &= 0xff; // uncode private usage area
}
- if(control > 2)
+ if(control & 2)
{
// include CAPITAL information
- if(iswupper(letter))
+ if(iswupper2(letter))
{
Lookup(tr, "_cap", capital);
}
}
letter = towlower2(letter);
+ LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1);
- LookupLetter(tr, letter, word[n_bytes], ph_buf);
+ if(ph_buf[0] == 0)
+ {
+ // is this a subscript or superscript letter ?
+ if((c = IsSuperscript(letter)) != 0)
+ {
+ letter = c & 0x3fff;
+ if((control & 4 ) && ((modifier = modifiers[c >> 14]) != NULL))
+ {
+ // don't say "superscript" during normal text reading
+ Lookup(tr, modifier, capital);
+ if(capital[0] == 0)
+ {
+ capital[2] = SetTranslator2("en"); // overwrites previous contents of translator2
+ Lookup(translator2, modifier, &capital[3]);
+ if(capital[3] != 0)
+ {
+ capital[0] = phonPAUSE;
+ capital[1] = phonSWITCH;
+ len = strlen(&capital[3]);
+ capital[len+3] = phonSWITCH;
+ capital[len+4] = phontab_1;
+ capital[len+5] = 0;
+ }
+ }
+ }
+ }
+ LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1);
+ }
if(ph_buf[0] == phonSWITCH)
{
@@ -630,51 +784,206 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control, int
return(0);
}
- if((ph_buf[0] == 0) && (tr->translator_name != L('e','n')))
+
+ if((ph_buf[0] == 0) && ((number = NonAsciiNumber(letter)) > 0))
{
- // speak as English, check whether there is a translation for this character
- SetTranslator2("en");
- save_option_phonemes = option_phonemes;
- option_phonemes = 0;
- LookupLetter(translator2, letter, word[n_bytes], ph_buf);
- SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
- option_phonemes = save_option_phonemes;
+ // convert a non-ascii number to 0-9
+ LookupLetter(tr, number, 0, ph_buf, control & 1);
+ }
+
+ al_offset = 0;
+ al_flags = 0;
+ if((alphabet = AlphabetFromChar(letter)) != NULL)
+ {
+ al_offset = alphabet->offset;
+ al_flags = alphabet->flags;
+ }
- if(ph_buf[0] != 0)
+ if(alphabet != current_alphabet)
+ {
+ // speak the name of the alphabet
+ current_alphabet = alphabet;
+ if((alphabet != NULL) && !(al_flags & AL_DONT_NAME) && (al_offset != translator->letter_bits_offset))
{
- sprintf(phonemes,"%cen",phonSWITCH);
- return(0);
+ if((al_flags & AL_DONT_NAME) || (al_offset == translator->langopts.alt_alphabet) || (al_offset == translator->langopts.our_alphabet))
+ {
+ // don't say the alphabet name
+ }
+ else
+ {
+ ph_buf2[0] = 0;
+ if(Lookup(translator, alphabet->name, ph_alphabet) == 0) // the original language for the current voice
+ {
+ // Can't find the local name for this alphabet, use the English name
+ ph_alphabet[2] = SetTranslator2("en"); // overwrites previous contents of translator2
+ Lookup(translator2, alphabet->name, ph_buf2);
+ }
+ else if(translator != tr)
+ {
+ phontab_1 = tr->phoneme_tab_ix;
+ strcpy(ph_buf2, ph_alphabet);
+ ph_alphabet[2] = translator->phoneme_tab_ix;
+ }
+
+ if(ph_buf2[0] != 0)
+ {
+ // we used a different language for the alphabet name (now in ph_buf2)
+ ph_alphabet[0] = phonPAUSE;
+ ph_alphabet[1] = phonSWITCH;
+ strcpy(&ph_alphabet[3], ph_buf2);
+ len = strlen(ph_buf2) + 3;
+ ph_alphabet[len] = phonSWITCH;
+ ph_alphabet[len+1] = phontab_1;
+ ph_alphabet[len+2] = 0;
+ }
+ }
}
}
+
+// caution: SetWordStress() etc don't expect phonSWITCH + phoneme table number
+
if(ph_buf[0] == 0)
{
- // character name not found
- if(iswalpha(letter))
- Lookup(tr, "_?A", ph_buf);
+ if((al_offset != 0) && (al_offset == translator->langopts.alt_alphabet))
+ language = translator->langopts.alt_alphabet_lang;
+ else
+ if((alphabet != NULL) && (alphabet->language != 0) && !(al_flags & AL_NOT_LETTERS))
+ language = alphabet->language;
+ else
+ language = L('e','n');
- if((ph_buf[0]==0) && !iswspace(letter))
- Lookup(tr, "_??", ph_buf);
+ if((language != tr->translator_name) || (language == L('k','o')))
+ {
+ char *p3;
+ int initial, code;
+ char hangul_buf[12];
+
+ // speak in the language for this alphabet (or English)
+ ph_buf[2] = SetTranslator2(WordToString2(language));
+
+ if(translator2 != NULL)
+ {
+ if(((code = letter - 0xac00) >= 0) && (letter <= 0xd7af))
+ {
+ // Special case for Korean letters.
+ // break a syllable hangul into 2 or 3 individual jamo
+
+ hangul_buf[0] = ' ';
+ p3 = &hangul_buf[1];
+ if((initial = (code/28)/21) != 11)
+ {
+ p3 += utf8_out(initial + 0x1100, p3);
+ }
+ utf8_out(((code/28) % 21) + 0x1161, p3); // medial
+ utf8_out((code % 28) + 0x11a7, &p3[3]); // final
+ p3[6] = ' ';
+ p3[7] = 0;
+ ph_buf[3] = 0;
+ TranslateRules(translator2, &hangul_buf[1], &ph_buf[3], sizeof(ph_buf)-3, NULL, 0, NULL);
+ SetWordStress(translator2, &ph_buf[3], NULL, -1, 0);
+ }
+ else
+ {
+ LookupLetter(translator2, letter, word[n_bytes], &ph_buf[3], control & 1);
+ }
+
+ if(ph_buf[3] == phonSWITCH)
+ {
+ // another level of language change
+ ph_buf[2] = SetTranslator2(&ph_buf[4]);
+ LookupLetter(translator2, letter, word[n_bytes], &ph_buf[3], control & 1);
+ }
+
+ SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
- if(ph_buf[0] != 0)
+ if(ph_buf[3] != 0)
+ {
+ ph_buf[0] = phonPAUSE;
+ ph_buf[1] = phonSWITCH;
+ len = strlen(&ph_buf[3]) + 3;
+ ph_buf[len] = phonSWITCH; // switch back
+ ph_buf[len+1] = tr->phoneme_tab_ix;
+ ph_buf[len+2] = 0;
+ }
+ }
+ }
+ }
+
+ if(ph_buf[0] == 0)
+ {
+ // character name not found
+
+ if(ph_buf[0]== 0)
{
- // speak the hexadecimal number of the character code
- sprintf(hexbuf,"%x",letter);
- pbuf = ph_buf;
- for(p2 = hexbuf; *p2 != 0; p2++)
+ speak_letter_number = 1;
+ if(!(al_flags & AL_NO_SYMBOL))
+ {
+ if(iswalpha2(letter))
+ Lookup(translator, "_?A", ph_buf);
+
+ if((ph_buf[0]==0) && !iswspace(letter))
+ Lookup(translator, "_??", ph_buf);
+
+ if(ph_buf[0] == 0)
+ {
+ EncodePhonemes("l'et@", ph_buf, NULL);
+ }
+ }
+
+ if(!(control & 4) && (al_flags & AL_NOT_CODE))
+ {
+ // don't speak the character code number, unless we want full details of this character
+ speak_letter_number = 0;
+ }
+
+// if((ph_alphabet[0] != 0) && speak_letter_number)
+// ph_buf[0] = 0; // don't speak "letter" if we speak alphabet name
+
+ if(speak_letter_number)
{
- pbuf += strlen(pbuf);
- *pbuf++ = phonPAUSE_VSHORT;
- LookupLetter(tr, *p2, 0, pbuf);
+ if(al_offset == 0x2800)
+ {
+ // braille dots symbol, list the numbered dots
+ p2 = hexbuf;
+ for(ix=0; ix<8; ix++)
+ {
+ if(letter & (1 << ix))
+ {
+ *p2++ = '1'+ix;
+ }
+ }
+ *p2 = 0;
+ }
+ else
+ {
+ // speak the hexadecimal number of the character code
+ sprintf(hexbuf,"%x",letter);
+ }
+
+ pbuf = ph_buf;
+ for(p2 = hexbuf; *p2 != 0; p2++)
+ {
+ pbuf += strlen(pbuf);
+ *pbuf++ = phonPAUSE_VSHORT;
+ LookupLetter(translator, *p2, 0, pbuf, 1);
+ if(((pbuf[0] == 0) || (pbuf[0]==phonSWITCH)) && (*p2 >= 'a'))
+ {
+ // This language has no translation for 'a' to 'f', speak English names using base phonemes
+ EncodePhonemes(hex_letters[*p2 - 'a'], pbuf, NULL);
+ }
+ }
+ strcat(pbuf, pause_string);
}
}
}
len = strlen(phonemes);
- if(tr->langopts.accents & 2)
- sprintf(ph_buf2,"%c%s%s",0xff,ph_buf,capital);
+
+ if(tr->langopts.accents & 2) // 'capital' before or after the word ?
+ sprintf(ph_buf2,"%c%s%s%s",0xff,ph_alphabet,ph_buf,capital);
else
- sprintf(ph_buf2,"%c%s%s",0xff,capital,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
+ sprintf(ph_buf2,"%c%s%s%s",0xff,ph_alphabet,capital,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
if((len + strlen(ph_buf2)) < N_WORD_PHONEMES)
{
strcpy(&phonemes[len],ph_buf2);
@@ -690,23 +999,25 @@ void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars)
int ix;
unsigned int c;
int n_stress=0;
+ int prev = 0;
int count;
unsigned char buf[N_WORD_PHONEMES];
for(ix=0; (c = phonemes[ix]) != 0; ix++)
{
- if(c == phonSTRESS_P)
+ if((c == phonSTRESS_P) && (prev != phonSWITCH))
{
n_stress++;
}
- buf[ix] = c;
+ buf[ix] = prev = c;
}
buf[ix] = 0;
count = 0;
+ prev = 0;
for(ix=0; (c = buf[ix]) != 0; ix++)
{
- if((c == phonSTRESS_P) && (n_chars > 1))
+ if((c == phonSTRESS_P) && (n_chars > 1) && (prev != phonSWITCH))
{
count++;
@@ -725,8 +1036,7 @@ void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars)
}
}
}
- else
- if(c == 0xff)
+ else if(c == 0xff)
{
if((control < 2) || (ix==0))
continue; // don't insert pauses
@@ -734,11 +1044,11 @@ void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars)
if(control == 4)
c = phonPAUSE; // pause after each character
if(((count % 3) == 0) || (control > 2))
- c = phonPAUSE_SHORT; // pause following a primary stress
+ c = phonPAUSE_NOLINK; // pause following a primary stress
else
- continue; // remove marker
+ c = phonPAUSE_VSHORT;
}
- *phonemes++ = c;
+ *phonemes++ = prev = c;
}
if(control >= 2)
*phonemes++ = phonPAUSE_NOLINK;
@@ -750,9 +1060,86 @@ void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars)
// Numbers
static char ph_ordinal2[12];
+static char ph_ordinal2x[12];
+
+
+static int CheckDotOrdinal(Translator *tr, char *word, char *word_end, WORD_TAB *wtab, int roman)
+{//==============================================================================================
+
+ int ordinal = 0;
+ int c2;
+ int nextflags;
+
+ if((tr->langopts.numbers & NUM_ORDINAL_DOT) && ((word_end[0] == '.') || (wtab[0].flags & FLAG_HAS_DOT)) && !(wtab[1].flags & FLAG_NOSPACE))
+ {
+ if(roman || !(wtab[1].flags & FLAG_FIRST_UPPER))
+ {
+ if(word_end[0] == '.')
+ utf8_in(&c2, &word_end[2]);
+ else
+ utf8_in(&c2, &word_end[0]);
+
+ if((word_end[0] != 0) && (word_end[1] != 0) && ((c2 == 0) || (wtab[0].flags & FLAG_COMMA_AFTER) || IsAlpha(c2)))
+ {
+ // ordinal number is indicated by dot after the number
+ // but not if the next word starts with an upper-case letter
+ // (c2 == 0) is for cases such as, "2.,"
+ ordinal = 2;
+ if(word_end[0] == '.')
+ word_end[0] = ' ';
+
+ if((roman==0) && (tr->translator_name == L('h','u')))
+ {
+ // lang=hu don't treat dot as ordinal indicator if the next word is a month name ($alt). It may have a suffix.
+ nextflags = 0;
+ if(IsAlpha(c2))
+ {
+ nextflags = TranslateWord(tr, &word_end[2], 0, NULL, NULL);
+ }
+
+ if((tr->prev_dict_flags[0] & FLAG_ALT_TRANS) && ((c2 == 0) || (wtab[0].flags & FLAG_COMMA_AFTER) || iswdigit(c2)))
+ ordinal = 0; // TEST 09.02.10
+
+ if(nextflags & FLAG_ALT_TRANS)
+ ordinal = 0;
-int TranslateRoman(Translator *tr, char *word, char *ph_out)
-{//=====================================================
+ if(nextflags & FLAG_ALT3_TRANS)
+ {
+ if(word[-2] == '-')
+ ordinal = 0; // eg. december 2-5. között
+
+ if(tr->prev_dict_flags[0] & (FLAG_ALT_TRANS | FLAG_ALT3_TRANS))
+ ordinal = 0x22;
+ }
+ }
+ }
+ }
+ }
+ return(ordinal);
+} // end of CheckDotOrdinal
+
+
+static int hu_number_e(const char *word, int thousandplex, int value)
+{//==================================================================
+// lang-hu: variant form of numbers when followed by hyphen and a suffix starting with 'a' or 'e' (but not a, e, az, ez, azt, ezt, att. ett
+
+ if((word[0] == 'a') || (word[0] == 'e'))
+ {
+ if((word[1] == ' ') || (word[1] == 'z') || ((word[1] == 't') && (word[2] == 't')))
+ return(0);
+
+ if(((thousandplex==1) || ((value % 1000) == 0)) && (word[1] == 'l'))
+ return(0); // 1000-el
+
+ return(1);
+ }
+ return(0);
+} // end of hu_numnber_e
+
+
+
+int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
+{//=========================================================================
int c;
char *p;
const char *p2;
@@ -761,17 +1148,30 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out)
int value;
int subtract;
int repeat = 0;
- unsigned int flags;
+ int n_digits = 0;
+ char *word_start;
+ int num_control = 0;
+ unsigned int flags[2];
char ph_roman[30];
char number_chars[N_WORD_BYTES];
static const char *roman_numbers = "ixcmvld";
static int roman_values[] = {1,10,100,1000,5,50,500};
-
+
acc = 0;
prev = 0;
subtract = 0x7fff;
+ ph_out[0] = 0;
+ flags[0] = 0;
+ flags[1] = 0;
+
+ if(((tr->langopts.numbers & NUM_ROMAN_CAPITALS) && !(wtab[0].flags & FLAG_ALL_UPPER)) || IsDigit09(word[-2]))
+ return(0); // not '2xx'
+ if(word[1] == ' ')
+ return(0); // only one letter, don't speak as a Roman Number
+
+ word_start = word;
while((c = *word++) != ' ')
{
if((p2 = strchr(roman_numbers,c)) == NULL)
@@ -799,253 +1199,512 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out)
subtract = prev;
value -= subtract;
}
- else
- if(value >= subtract)
+ else if(value >= subtract)
return(0);
else
acc += prev;
prev = value;
+ n_digits++;
}
+
+ if(IsDigit09(word[0]))
+ return(0); // eg. 'xx2'
+
acc += prev;
- if(acc < 2)
+ if(acc < tr->langopts.min_roman)
return(0);
if(acc > tr->langopts.max_roman)
return(0);
+
Lookup(tr, "_roman",ph_roman); // precede by "roman" if _rom is defined in *_list
p = &ph_out[0];
if((tr->langopts.numbers & NUM_ROMAN_AFTER) == 0)
{
strcpy(ph_out,ph_roman);
- p = &ph_out[strlen(ph_out)];
+ p = &ph_out[strlen(ph_roman)];
}
- sprintf(number_chars," %d ",acc);
- TranslateNumber(tr, &number_chars[1], p, &flags, 0);
+ sprintf(number_chars," %d %s ",acc, tr->langopts.roman_suffix);
+
+ if(word[0] == '.')
+ {
+ // dot has not been removed. This implies that there was no space after it
+ return(0);
+ }
+
+ if(CheckDotOrdinal(tr, word_start, word, wtab, 1))
+ wtab[0].flags |= FLAG_ORDINAL;
+
+ if(tr->langopts.numbers & NUM_ROMAN_ORDINAL)
+ {
+ if(tr->translator_name == L('h','u'))
+ {
+ if(!(wtab[0].flags & FLAG_ORDINAL))
+ {
+ if((wtab[0].flags & FLAG_HYPHEN_AFTER) && hu_number_e(word, 0, acc))
+ {
+ // should use the 'e' form of the number
+ num_control |= 1;
+ }
+ else
+ return(0);
+ }
+ }
+ else
+ {
+ wtab[0].flags |= FLAG_ORDINAL;
+ }
+ }
+
+ tr->prev_dict_flags[0] = 0;
+ tr->prev_dict_flags[1] = 0;
+ TranslateNumber(tr, &number_chars[2], p, flags, wtab, num_control);
if(tr->langopts.numbers & NUM_ROMAN_AFTER)
strcat(ph_out,ph_roman);
+
return(1);
} // end of TranslateRoman
static const char *M_Variant(int value)
{//====================================
- // returns M, or perhaps MA for some cases
-
- if((translator->langopts.numbers2 & 0x100) && (value >= 2) && (value <= 4))
- return("0MA"); // Czech, Slovak
- else
- if(((value % 100) < 10) || ((value % 100) > 20)) // but not teens, 10 to 19
+ // returns M, or perhaps MA or MB for some cases
+
+ int teens = 0;
+
+ if(((value % 100) > 10) && ((value % 100) < 20))
+ teens = 1;
+
+ switch((translator->langopts.numbers2 >> 6) & 0x7)
{
- if ((translator->langopts.numbers2 & 0x40) &&
- ((value % 10)>=2) &&
- ((value % 10)<=4))
- {
- // for Polish language - two forms of plural!
+ case 1: // lang=ru use singular for xx1 except for x11
+ if((teens == 0) && ((value % 10) == 1))
+ return("1M");
+ break;
+
+ case 2: // lang=cs,sk
+ if((value >= 2) && (value <= 4))
return("0MA");
- }
+ break;
+
+ case 3: // lang=pl
+ if((teens == 0) && (((value % 10) >= 2) && ((value % 10) <= 4)))
+ return("0MA");
+ break;
+
+ case 4: // lang=lt
+ if((teens == 1) || ((value % 10) == 0))
+ return("0MB");
+ if((value % 10) == 1)
+ return("0MA");
+ break;
- if((translator->langopts.numbers2 & 0x80) &&
- ((value % 10)==1))
+ case 5: // lang=bs,hr,sr
+ if(teens == 0)
{
- return("1MA");
+ if((value % 10) == 1)
+ return("1M");
+ if(((value % 10) >= 2) && ((value % 10) <= 4))
+ return("0MA");
}
-
+ break;
}
return("0M");
}
-static int LookupThousands(Translator *tr, int value, int thousandplex, char *ph_out)
-{//==================================================================================
+static int LookupThousands(Translator *tr, int value, int thousandplex, int thousands_exact, char *ph_out)
+{//=======================================================================================================
+// thousands_exact: bit 0 no hundreds,tens,or units, bit 1 ordinal numberr
int found;
+ int found_value=0;
char string[12];
char ph_of[12];
char ph_thousands[40];
+ char ph_buf[40];
ph_of[0] = 0;
- // first look fora match with the exact value of thousands
- sprintf(string,"_%dM%d",value,thousandplex);
+ // first look for a match with the exact value of thousands
+ if(value > 0)
+ {
+ if(thousands_exact & 1)
+ {
+ if(thousands_exact & 2)
+ {
+ // ordinal number
+ sprintf(string,"_%dM%do",value,thousandplex);
+ found_value = Lookup(tr, string, ph_thousands);
+ }
+ if((!found_value) & (number_control & 1))
+ {
+ // look for the 'e' variant
+ sprintf(string,"_%dM%de",value,thousandplex);
+ found_value = Lookup(tr, string, ph_thousands);
+ }
+ if(!found_value)
+ {
+ // is there a different pronunciation if there are no hundreds,tens,or units ? (LANG=ta)
+ sprintf(string,"_%dM%dx",value,thousandplex);
+ found_value = Lookup(tr, string, ph_thousands);
+ }
+ }
+ if(found_value == 0)
+ {
+ sprintf(string,"_%dM%d",value,thousandplex);
+ found_value = Lookup(tr, string, ph_thousands);
+ }
+ }
- if((found = Lookup(tr, string, ph_thousands)) == 0)
+ if(found_value == 0)
{
- if((value % 100) >= 20)
+ if((value % 100) >= 20)
{
Lookup(tr, "_0of", ph_of);
}
- sprintf(string,"_%s%d",M_Variant(value),thousandplex);
-
- if(Lookup(tr, string, ph_thousands) == 0)
+ found = 0;
+ if(thousands_exact & 1)
+ {
+ if(thousands_exact & 2)
+ {
+ // ordinal number
+ sprintf(string,"_%s%do",M_Variant(value), thousandplex);
+ found = Lookup(tr, string, ph_thousands);
+ }
+ if(!found && (number_control & 1))
+ {
+ // look for the 'e' variant
+ sprintf(string,"_%s%de",M_Variant(value), thousandplex);
+ found = Lookup(tr, string, ph_thousands);
+ }
+ if(!found)
+ {
+ // is there a different pronunciation if there are no hundreds,tens,or units ?
+ sprintf(string,"_%s%dx",M_Variant(value), thousandplex);
+ found = Lookup(tr, string, ph_thousands);
+ }
+ }
+ if(found == 0)
{
- // repeat "thousand" if higher order names are not available
- sprintf(string,"_%dM1",value);
- if((found = Lookup(tr, string, ph_thousands)) == 0)
- Lookup(tr, "_0M1", ph_thousands);
+ sprintf(string,"_%s%d",M_Variant(value), thousandplex);
+
+ if(Lookup(tr, string, ph_thousands) == 0)
+ {
+ if(thousandplex > 3)
+ {
+ sprintf(string,"_0M%d", thousandplex-1);
+ if(Lookup(tr, string, ph_buf) == 0)
+ {
+ // say "millions" if this name is not available and neither is the next lower
+ Lookup(tr, "_0M2", ph_thousands);
+ speak_missing_thousands = 3;
+ }
+ }
+ if(ph_thousands[0] == 0)
+ {
+ // repeat "thousand" if higher order names are not available
+ sprintf(string,"_%dM1",value);
+ if((found_value = Lookup(tr, string, ph_thousands)) == 0)
+ Lookup(tr, "_0M1", ph_thousands);
+ speak_missing_thousands = 2;
+ }
+ }
}
}
sprintf(ph_out,"%s%s",ph_of,ph_thousands);
- return(found);
-}
+
+ if((value == 1) && (thousandplex == 1) && (tr->langopts.numbers & NUM_OMIT_1_THOUSAND))
+ return(1);
+
+ return(found_value);
+} // end f LookupThousands
-static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
-{//========================================================================
+static int LookupNum2(Translator *tr, int value, int thousandplex, const int control, char *ph_out)
+{//=============================================================================
// Lookup a 2 digit number
-// control bit 0: tens and units (use special form of '1')
-// control bit 1: ordinal number
-// control bit 2: use feminine form of '2'
-// control bit 3: speak zero tens
+// control bit 0: ordinal number
+// control bit 1: final tens and units (not number of thousands) (use special form of '1', LANG=de "eins")
+// control bit 2: tens and units only, no higher digits
+// control bit 3: use feminine form of '2' (for thousands
+// control bit 4: speak zero tens
+// control bit 5: variant of ordinal number (lang=hu)
+// bit 8 followed by decimal fraction
+// bit 9: use #f form for both tens and units (lang=ml)
int found;
int ix;
int units;
+ int tens;
+ int is_ordinal;
int used_and=0;
int found_ordinal = 0;
int next_phtype;
+ int ord_type = 'o';
char string[12]; // for looking up entries in *_list
char ph_ordinal[20];
char ph_tens[50];
char ph_digits[50];
char ph_and[12];
- // is there a special pronunciation for this 2-digit number
+ units = value % 10;
+ tens = value / 10;
+
found = 0;
ph_ordinal[0] = 0;
+ ph_tens[0] = 0;
+ ph_digits[0] = 0;
+ ph_and[0] = 0;
- if(control & 4)
- {
- sprintf(string,"_%df",value);
- found = Lookup(tr, string, ph_digits);
- }
- if(control & 2)
- {
- strcpy(ph_ordinal, ph_ordinal2);
-
- sprintf(string,"_%do",value);
- if((found = Lookup(tr, string, ph_digits)) != 0)
- {
- found_ordinal = 1;
- }
- }
-
- if(found == 0)
+ if(control & 0x20)
{
- if((value == 1) && (control & 1))
- {
- if(Lookup(tr, "_1a", ph_out) != 0)
- return(0);
- }
- sprintf(string,"_%d",value);
- found = Lookup(tr, string, ph_digits);
+ ord_type = 'q';
}
- // no, speak as tens+units
+ is_ordinal = control & 1;
- if((control & 8) && (value < 10))
+ if((control & 2) && (n_digit_lookup == 2))
{
- // speak leading zero
- Lookup(tr, "_0", ph_tens);
+ // pronunciation of the final 2 digits has already been found
+ strcpy(ph_out, digit_lookup);
}
else
{
- if(found)
- {
- ph_tens[0] = 0;
- }
- else
+ if(digit_lookup[0] == 0)
{
- units = (value % 10);
-
- if((control & 2) && ((units == 0) || (tr->langopts.numbers & 0x10)))
+ // is there a special pronunciation for this 2-digit number
+ if(control & 8)
{
- sprintf(string,"_%dXo",value / 10);
- if(Lookup(tr, string, ph_tens) != 0)
+ // is there a feminine or thousands-variant form?
+ sprintf(string,"_%dfx",value);
+ if((found = Lookup(tr, string, ph_digits)) == 0)
{
- found_ordinal = 1;
+ sprintf(string,"_%df",value);
+ found = Lookup(tr, string, ph_digits);
}
}
- if(found_ordinal == 0)
+ else if(is_ordinal)
{
- sprintf(string,"_%dX",value / 10);
- Lookup(tr, string, ph_tens);
- }
+ strcpy(ph_ordinal, ph_ordinal2);
- if((ph_tens[0] == 0) && (tr->langopts.numbers & NUM_VIGESIMAL))
- {
- // tens not found, (for example) 73 is 60+13
- units = (value % 20);
- sprintf(string,"_%dX",(value / 10) & 0xfe);
- Lookup(tr, string, ph_tens);
+ if(control & 4)
+ {
+ sprintf(string,"_%d%cx",value,ord_type); // LANG=hu, special word for 1. 2. when there are no higher digits
+ if((found = Lookup(tr, string, ph_digits)) != 0)
+ {
+ if(ph_ordinal2x[0] != 0)
+ strcpy(ph_ordinal, ph_ordinal2x); // alternate pronunciation (lang=an)
+ }
+ }
+ if(found == 0)
+ {
+ sprintf(string,"_%d%c",value,ord_type);
+ found = Lookup(tr, string, ph_digits);
+ }
+ found_ordinal = found;
}
- ph_digits[0] = 0;
- if(units > 0)
- {
- found = 0;
- if(control & 4)
+ if(found == 0)
+ {
+ if(control & 2)
{
- // is there a variant form of this number?
- sprintf(string,"_%df",units);
+ // the final tens and units of a number
+ if(number_control & 1)
+ {
+ // look for 'e' variant
+ sprintf(string,"_%de",value);
+ found = Lookup(tr, string, ph_digits);
+ }
+ }
+ else
+ {
+ // followed by hundreds or thousands etc
+ if((tr->langopts.numbers2 & NUM2_ORDINAL_AND_THOUSANDS) && (thousandplex <= 1))
+ sprintf(string, "_%do", value); // LANG=TA
+ else
+ sprintf(string, "_%da", value);
found = Lookup(tr, string, ph_digits);
}
- if((control & 2) && ((tr->langopts.numbers & 0x10) == 0))
+
+ if(!found)
{
- // ordinal
- sprintf(string,"_%do",units);
- if((found = Lookup(tr, string, ph_digits)) != 0)
+ if((is_ordinal) && (tr->langopts.numbers2 & NUM2_NO_TEEN_ORDINALS))
+ {
+ // don't use numbers 10-99 to make ordinals, always use _1Xo etc (lang=pt)
+ }
+ else
+ {
+ sprintf(string,"_%d",value);
+ found = Lookup(tr, string, ph_digits);
+ }
+ }
+ }
+ }
+
+ // no, speak as tens+units
+
+ if((control & 0x10) && (value < 10))
+ {
+ // speak leading zero
+ Lookup(tr, "_0", ph_tens);
+ }
+ else
+ {
+ if(found)
+ {
+ ph_tens[0] = 0;
+ }
+ else
+ {
+
+ if(is_ordinal)
+ {
+ sprintf(string,"_%dX%c", tens, ord_type);
+ if(Lookup(tr, string, ph_tens) != 0)
{
found_ordinal = 1;
+
+ if((units != 0) && (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))
+ {
+ // Use the ordinal form of tens as well as units. Add the ordinal ending
+ strcat(ph_tens, ph_ordinal2);
+ }
}
}
- if(found == 0)
+ if(found_ordinal == 0)
+ {
+ if(control & 0x200)
+ sprintf(string, "_%dXf", tens);
+ else
+ sprintf(string,"_%dX", tens);
+ Lookup(tr, string, ph_tens);
+ }
+
+ if((ph_tens[0] == 0) && (tr->langopts.numbers & NUM_VIGESIMAL))
{
- sprintf(string,"_%d",units);
- Lookup(tr, string, ph_digits);
+ // tens not found, (for example) 73 is 60+13
+ units = (value % 20);
+ sprintf(string,"_%dX", tens & 0xfe);
+ Lookup(tr, string, ph_tens);
+ }
+
+ ph_digits[0] = 0;
+ if(units > 0)
+ {
+ found = 0;
+
+ if((control & 2) && (digit_lookup[0] != 0))
+ {
+ // we have an entry for this digit (possibly together with the next word)
+ strcpy(ph_digits, digit_lookup);
+ found_ordinal = 1;
+ ph_ordinal[0] = 0;
+ }
+ else
+ {
+ if(control & 8)
+ {
+ // is there a variant form of this number?
+ sprintf(string,"_%df",units);
+ found = Lookup(tr, string, ph_digits);
+ }
+ if((is_ordinal) && ((tr->langopts.numbers & NUM_SWAP_TENS) == 0))
+ {
+ // ordinal
+ sprintf(string,"_%d%c",units,ord_type);
+ if((found = Lookup(tr, string, ph_digits)) != 0)
+ {
+ found_ordinal = 1;
+ }
+ }
+ if(found == 0)
+ {
+ if((number_control & 1) && (control & 2))
+ {
+ // look for 'e' variant
+ sprintf(string,"_%de",units);
+ found = Lookup(tr, string, ph_digits);
+ }
+ else if(((control & 2) == 0) || ((tr->langopts.numbers & NUM_SWAP_TENS) != 0))
+ {
+ // followed by hundreds or thousands (or tens)
+ if((tr->langopts.numbers2 & NUM2_ORDINAL_AND_THOUSANDS) && (thousandplex <= 1))
+ sprintf(string, "_%do", units); // LANG=TA, only for 100s, 1000s
+ else
+ sprintf(string, "_%da", units);
+ found = Lookup(tr, string, ph_digits);
+ }
+ }
+ if(found == 0)
+ {
+ sprintf(string,"_%d",units);
+ Lookup(tr, string, ph_digits);
+ }
+ }
}
}
}
- }
- if((control & 2) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
- {
- if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & 0x10)))
- Lookup(tr, "_ord20", ph_ordinal);
- if(ph_ordinal[0] == 0)
- Lookup(tr, "_ord", ph_ordinal);
- }
+ if((is_ordinal) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
+ {
+ if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & NUM_SWAP_TENS)))
+ Lookup(tr, "_ord20", ph_ordinal);
+ if(ph_ordinal[0] == 0)
+ Lookup(tr, "_ord", ph_ordinal);
+ }
- if((tr->langopts.numbers & 0x30) && (ph_tens[0] != 0) && (ph_digits[0] != 0))
- {
- Lookup(tr, "_0and", ph_and);
- if(tr->langopts.numbers & 0x10)
- sprintf(ph_out,"%s%s%s%s",ph_digits, ph_and, ph_tens, ph_ordinal);
+ if((tr->langopts.numbers & (NUM_SWAP_TENS | NUM_AND_UNITS)) && (ph_tens[0] != 0) && (ph_digits[0] != 0))
+ {
+ Lookup(tr, "_0and", ph_and);
+
+ if((is_ordinal) && (tr->langopts.numbers2 & NUM2_ORDINAL_NO_AND))
+ ph_and[0] = 0;
+
+ if(tr->langopts.numbers & NUM_SWAP_TENS)
+ sprintf(ph_out,"%s%s%s%s",ph_digits, ph_and, ph_tens, ph_ordinal);
+ else
+ sprintf(ph_out,"%s%s%s%s",ph_tens, ph_and, ph_digits, ph_ordinal);
+ used_and = 1;
+ }
else
- sprintf(ph_out,"%s%s%s%s",ph_tens, ph_and, ph_digits, ph_ordinal);
- used_and = 1;
+ {
+ if(tr->langopts.numbers & NUM_SINGLE_VOWEL)
+ {
+ // remove vowel from the end of tens if units starts with a vowel (LANG=Italian)
+ if(((ix = strlen(ph_tens)-1) >= 0) && (ph_digits[0] != 0))
+ {
+ if((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS)
+ next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type;
+
+ if((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL))
+ ph_tens[ix] = 0;
+ }
+ }
+ sprintf(ph_out,"%s%s%s",ph_tens, ph_digits, ph_ordinal);
+ }
}
- else
+
+ if(tr->langopts.numbers & NUM_SINGLE_STRESS_L)
{
- if(tr->langopts.numbers & 0x200)
+ // only one primary stress, on the first part (tens)
+ found = 0;
+ for(ix=0; ix < (signed)strlen(ph_out); ix++)
{
- // remove vowel from the end of tens if units starts with a vowel (LANG=Italian)
- if(((ix = strlen(ph_tens)-1) >= 0) && (ph_digits[0] != 0))
+ if(ph_out[ix] == phonSTRESS_P)
{
- if((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS)
- next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type;
-
- if((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL))
- ph_tens[ix] = 0;
+ if(found)
+ ph_out[ix] = phonSTRESS_3;
+ else
+ found = 1;
}
}
- sprintf(ph_out,"%s%s%s",ph_tens, ph_digits, ph_ordinal);
}
-
- if(tr->langopts.numbers & 0x100)
+ else if(tr->langopts.numbers & NUM_SINGLE_STRESS)
{
// only one primary stress
found = 0;
@@ -1069,9 +1728,18 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
// Translate a 3 digit number
// control bit 0, previous thousands
// bit 1, ordinal number
+// bit 5 variant form of ordinal number
+// bit 8 followed by decimal fraction
int found;
int hundreds;
+ int tensunits;
int x;
+ int ix;
+ int exact;
+ int ordinal;
+ int tplex;
+ int say_zero_hundred=0;
+ int say_one_hundred;
char string[12]; // for looking up entries in **_list
char buf1[100];
char buf2[100];
@@ -1081,59 +1749,87 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
char ph_thousands[50];
char ph_hundred_and[12];
char ph_thousand_and[12];
-
+
+ ordinal = control & 0x22;
hundreds = value / 100;
+ tensunits = value % 100;
buf1[0] = 0;
- if(hundreds > 0)
+ ph_thousands[0] = 0;
+ ph_thousand_and[0] = 0;
+
+ if((tr->langopts.numbers & NUM_ZERO_HUNDRED) && ((control & 1) || (hundreds >= 10)))
{
- ph_thousands[0] = 0;
- ph_thousand_and[0] = 0;
+ say_zero_hundred = 1; // lang=vi
+ }
+ if((hundreds > 0) || say_zero_hundred)
+ {
found = 0;
- if((control & 2) && ((value % 100) == 0))
+ if(ordinal && (tensunits == 0))
{
// ordinal number, with no tens or units
found = Lookup(tr, "_0Co", ph_100);
}
if(found == 0)
{
- Lookup(tr, "_0C", ph_100);
+ if(tensunits==0)
+ {
+ // special form for exact hundreds?
+ found = Lookup(tr, "_0C0", ph_100);
+ }
+ if(!found)
+ {
+ Lookup(tr, "_0C", ph_100);
+ }
}
- if(((tr->langopts.numbers & 0x0800) != 0) && (hundreds == 19))
+ if(((tr->langopts.numbers & NUM_1900) != 0) && (hundreds == 19))
{
// speak numbers such as 1984 as years: nineteen-eighty-four
// ph_100[0] = 0; // don't say "hundred", we also need to surpess "and"
}
- else
- if(hundreds >= 10)
+ else if(hundreds >= 10)
{
ph_digits[0] = 0;
- if(LookupThousands(tr, hundreds / 10, thousandplex+1, ph_10T) == 0)
+ exact = 0;
+ if ((value % 1000) == 0)
+ exact = 1;
+
+ tplex = thousandplex+1;
+ if(tr->langopts.numbers2 & NUM2_MYRIADS)
+ {
+ tplex = 0;
+ }
+
+ if(LookupThousands(tr, hundreds / 10, tplex, exact | ordinal, ph_10T) == 0)
{
x = 0;
- if(tr->langopts.numbers2 & (1 << (thousandplex+1)))
- x = 4;
- LookupNum2(tr, hundreds/10, x, ph_digits);
+ if(tr->langopts.numbers2 & (1 << tplex))
+ x = 8; // use variant (feminine) for before thousands and millions
+ if(tr->translator_name == L('m','l'))
+ x = 0x208;
+ LookupNum2(tr, hundreds/10, thousandplex, x, ph_digits);
}
if(tr->langopts.numbers2 & 0x200)
- sprintf(ph_thousands,"%s%s%c",ph_10T,ph_digits,phonPAUSE_NOLINK); // say "thousands" before its number, not after
+ sprintf(ph_thousands,"%s%c%s%c",ph_10T,phonEND_WORD,ph_digits,phonEND_WORD); // say "thousands" before its number, not after
else
- sprintf(ph_thousands,"%s%s%c",ph_digits,ph_10T,phonPAUSE_NOLINK);
+ sprintf(ph_thousands,"%s%c%s%c",ph_digits,phonEND_WORD,ph_10T,phonEND_WORD);
hundreds %= 10;
- if(hundreds == 0)
+ if((hundreds == 0) && (say_zero_hundred == 0))
ph_100[0] = 0;
suppress_null = 1;
+ control |= 1;
}
ph_digits[0] = 0;
- if(hundreds > 0)
+
+ if((hundreds > 0) || say_zero_hundred)
{
- if((tr->langopts.numbers & 0x100000) && ((control & 1) || (ph_thousands[0] != 0)))
+ if((tr->langopts.numbers & NUM_AND_HUNDRED) && ((control & 1) || (ph_thousands[0] != 0)))
{
Lookup(tr, "_0and", ph_thousand_and);
}
@@ -1141,26 +1837,64 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
suppress_null = 1;
found = 0;
- if((value % 1000) == 100)
- {
- // is there a special pronunciation for exactly 100 ?
- found = Lookup(tr, "_1C0", ph_digits);
- }
- if(!found)
+ if((ordinal)
+ && ((tensunits == 0) || (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL)))
{
- sprintf(string,"_%dC",hundreds);
- found = Lookup(tr, string, ph_digits); // is there a specific pronunciation for n-hundred ?
+ // ordinal number
+ sprintf(string, "_%dCo", hundreds);
+ found = Lookup(tr, string, ph_digits);
+
+ if((tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL) && (tensunits > 0))
+ {
+ // Use ordinal form of hundreds, as well as for tens and units
+ // Add ordinal suffix to the hundreds
+ strcat(ph_digits, ph_ordinal2);
+ }
}
- if(found)
+ if((hundreds == 0) && say_zero_hundred)
{
- ph_100[0] = 0;
+ Lookup(tr, "_0", ph_digits);
}
else
{
- if((hundreds > 1) || ((tr->langopts.numbers & 0x400) == 0))
+ if((hundreds==1) && (tr->langopts.numbers2 & NUM2_OMIT_1_HUNDRED_ONLY) && ((control & 1)==0))
+ {
+ // only look for special 100 if there are previous thousands
+ }
+ else
+ {
+ if((!found) && (tensunits == 0))
+ {
+ // is there a special pronunciation for exactly n00 ?
+ sprintf(string,"_%dC0",hundreds);
+ found = Lookup(tr, string, ph_digits);
+ }
+
+ if(!found)
+ {
+ sprintf(string,"_%dC",hundreds);
+ found = Lookup(tr, string, ph_digits); // is there a specific pronunciation for n-hundred ?
+ }
+ }
+
+ if(found)
+ {
+ ph_100[0] = 0;
+ }
+ else
{
- LookupNum2(tr, hundreds, 0, ph_digits);
+ say_one_hundred = 1;
+ if(hundreds == 1)
+ {
+ if((tr->langopts.numbers & NUM_OMIT_1_HUNDRED) != 0)
+ say_one_hundred = 0;
+ }
+
+ if(say_one_hundred != 0)
+ {
+ LookupNum2(tr, hundreds, thousandplex, 0, ph_digits);
+ }
}
}
}
@@ -1169,104 +1903,195 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
}
ph_hundred_and[0] = 0;
- if((tr->langopts.numbers & 0x40) && ((value % 100) != 0))
+ if(tensunits > 0)
{
- if((value > 100) || ((control & 1) && (thousandplex==0)))
+ if((control & 2) && (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))
{
- Lookup(tr, "_0and", ph_hundred_and);
+ // Don't use "and" if we apply ordinal to both hundreds and units
+ }
+ else
+ {
+ if((value > 100) || ((control & 1) && (thousandplex==0)))
+ {
+ if((tr->langopts.numbers & NUM_HUNDRED_AND) || ((tr->langopts.numbers & NUM_HUNDRED_AND_DIGIT) && (tensunits < 10)))
+ {
+ Lookup(tr, "_0and", ph_hundred_and);
+ }
+ }
+ if((tr->langopts.numbers & NUM_THOUSAND_AND) && (hundreds == 0) && ((control & 1) || (ph_thousands[0] != 0)))
+ {
+ Lookup(tr, "_0and", ph_hundred_and);
+ }
}
}
buf2[0] = 0;
- value = value % 100;
- if((value != 0) || (suppress_null == 0))
+ if((tensunits != 0) || (suppress_null == 0))
{
x = 0;
if(thousandplex==0)
{
- x = 1; // allow "eins" for 1 rather than "ein"
- if(control & 2)
+ x = 2; // allow "eins" for 1 rather than "ein"
+ if(ordinal)
x = 3; // ordinal number
+ if((value < 100) && !(control & 1))
+ x |= 4; // tens and units only, no higher digits
+ if(ordinal & 0x20)
+ x |= 0x20; // variant form of ordinal number
}
else
{
if(tr->langopts.numbers2 & (1 << thousandplex))
- x = 4; // use variant (feminine) for before thousands and millions
+ x = 8; // use variant (feminine) for before thousands and millions
+ }
+
+ if((tr->translator_name == L('m','l')) && (thousandplex == 1))
+ {
+ x |= 0x208; // use #f form for both tens and units
}
- if(LookupNum2(tr, value, x, buf2) != 0)
+ if(LookupNum2(tr, tensunits, thousandplex, x | (control & 0x100), buf2) != 0)
{
- if(tr->langopts.numbers & 0x80)
+ if(tr->langopts.numbers & NUM_SINGLE_AND)
ph_hundred_and[0] = 0; // don't put 'and' after 'hundred' if there's 'and' between tens and units
}
}
+ else
+ {
+ if(ph_ordinal2[0] != 0)
+ {
+ ix = strlen(buf1);
+ if((ix > 0) && (buf1[ix-1] == phonPAUSE_SHORT))
+ buf1[ix-1] = 0; // remove pause before addding ordinal suffix
+ strcpy(buf2, ph_ordinal2);
+ }
+ }
- sprintf(ph_out,"%s%s%s",buf1,ph_hundred_and,buf2);
+ sprintf(ph_out,"%s%s%c%s",buf1,ph_hundred_and,phonEND_WORD,buf2);
return(0);
} // end of LookupNum3
-static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned int *flags, int wflags)
-{//====================================================================================================
+static bool CheckThousandsGroup(char *word, int group_len)
+{//================================================
+// Is this a group of 3 digits which looks like a thousands group?
+ int ix;
+
+ if(IsDigit09(word[group_len]) || IsDigit09(-1))
+ return(false);
+
+ for(ix=0; ix < group_len; ix++)
+ {
+ if(!IsDigit09(word[ix]))
+ return(false);
+ }
+ return(true);
+}
+
+
+static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control)
+{//=====================================================================================================================
// Number translation with various options
// the "word" may be up to 4 digits
// "words" of 3 digits may be preceded by another number "word" for thousands or millions
int n_digits;
int value;
- unsigned int ix;
+ int ix;
+ int digix;
unsigned char c;
int suppress_null = 0;
int decimal_point = 0;
int thousandplex = 0;
+ int thousands_exact = 1;
int thousands_inc = 0;
int prev_thousands = 0;
int ordinal = 0;
int this_value;
- static int prev_value;
int decimal_count;
int max_decimal_count;
int decimal_mode;
- int hyphen;
+ int suffix_ix;
+ int skipwords = 0;
+ int group_len;
+ int len;
char *p;
- char string[20]; // for looking up entries in **_list
+ char string[32]; // for looking up entries in **_list
char buf1[100];
char ph_append[50];
char ph_buf[200];
char ph_buf2[50];
- char suffix[20];
+ char ph_zeros[50];
+ char suffix[30]; // string[] must be long enough for sizeof(suffix)+2
+ char buf_digit_lookup[50];
static const char str_pause[2] = {phonPAUSE_NOLINK,0};
*flags = 0;
+ n_digit_lookup = 0;
+ buf_digit_lookup[0] = 0;
+ digit_lookup = buf_digit_lookup;
+ number_control = control;
- for(ix=0; isdigit(word[ix]); ix++) ;
+ for(ix=0; IsDigit09(word[ix]); ix++) ;
n_digits = ix;
value = this_value = atoi(word);
+ group_len = 3;
+ if(tr->langopts.numbers2 & NUM2_MYRIADS)
+ group_len = 4;
+
+ // is there a previous thousands part (as a previous "word") ?
+ if((n_digits == group_len) && (word[-2] == tr->langopts.thousands_sep) && IsDigit09(word[-3]))
+ {
+ prev_thousands = 1;
+ }
+ else if((tr->langopts.thousands_sep == ' ') || (tr->langopts.numbers & NUM_ALLOW_SPACE))
+ {
+ // thousands groups can be separated by spaces
+ if((n_digits == 3) && !(wtab->flags & FLAG_MULTIPLE_SPACES) && IsDigit09(word[-2]))
+ {
+ prev_thousands = 1;
+ }
+ }
+ if(prev_thousands == 0)
+ {
+ speak_missing_thousands = 0;
+ }
+
ph_ordinal2[0] = 0;
- if((tr->langopts.numbers & 0x10000) && (word[ix] == '.') && !isdigit(word[ix+2]))
+ ph_zeros[0] = 0;
+
+ if(prev_thousands || (word[0] != '0'))
{
- // ordinal number is indicated by dot after the number
- ordinal = 2;
- word[ix] = ' ';
+ // don't check for ordinal if the number has a leading zero
+ if((ordinal = CheckDotOrdinal(tr, word, &word[ix], wtab, 0)) != 0)
+ {
+// dot_ordinal = 1;
+ }
}
- else
+
+ if((word[ix] == '.') && !IsDigit09(word[ix+1]) && !IsDigit09(word[ix+2]) && !(wtab[1].flags & FLAG_NOSPACE))
{
+ // remove dot unless followed by another number
+ word[ix] = 0;
+ }
+
+ if((ordinal == 0) || (tr->translator_name == L('h','u')))
+ {
+// NOTE lang=hu, allow both dot and ordinal suffix, eg. "december 21.-én"
// look for an ordinal number suffix after the number
ix++;
- hyphen = 0;
p = suffix;
- if(word[ix] == '-')
+ if(wtab[0].flags & FLAG_HYPHEN_AFTER)
{
*p++ = '-';
- hyphen = 1;
- ix += 2;
+ ix++;
}
- while((word[ix] != 0) && (word[ix] != ' ') && (ix < (sizeof(suffix)-1)))
+ while((word[ix] != 0) && (word[ix] != ' ') && (ix < (int)(sizeof(suffix)-1)))
{
*p++ = word[ix++];
}
@@ -1274,64 +2099,85 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
if(suffix[0] != 0)
{
- sprintf(string,"_0%s",suffix);
- if(Lookup(tr, string, ph_ordinal2))
+ if((tr->langopts.ordinal_indicator != NULL) && (strcmp(suffix, tr->langopts.ordinal_indicator) == 0))
{
- // this is an ordinal suffix
ordinal = 2;
- flags[0] |= FLAG_SKIPWORDS;
- dictionary_skipwords = 1 + hyphen;
+ }
+ else if(!IsDigit09(suffix[0])) // not _#9 (tab)
+ {
+ sprintf(string,"_#%s",suffix);
+ if(Lookup(tr, string, ph_ordinal2))
+ {
+ // this is an ordinal suffix
+ ordinal = 2;
+ flags[0] |= FLAG_SKIPWORDS;
+ skipwords = 1;
+ sprintf(string,"_x#%s",suffix);
+ Lookup(tr, string, ph_ordinal2x); // is there an alternate pronunciation?
+ }
}
}
}
+ if(wtab[0].flags & FLAG_ORDINAL)
+ ordinal = 2;
+
ph_append[0] = 0;
ph_buf2[0] = 0;
- // is there a previous thousands part (as a previous "word") ?
- if((n_digits == 3) && (word[-2] == tr->langopts.thousands_sep) && isdigit(word[-3]))
- {
- prev_thousands = 1;
- }
- else
- if((tr->langopts.thousands_sep == ' ') || (tr->langopts.numbers & 0x1000))
- {
- // thousands groups can be separated by spaces
- if((n_digits == 3) && isdigit(word[-2]))
- {
- prev_thousands = 1;
- }
- }
if((word[0] == '0') && (prev_thousands == 0) && (word[1] != ' ') && (word[1] != tr->langopts.decimal_sep))
{
- if((n_digits == 2) && (word[3] == ':') && isdigit(word[5]) && isspace(word[7]))
+ if((n_digits == 2) && (word[3] == ':') && IsDigit09(word[5]) && isspace(word[7]))
{
// looks like a time 02:30, omit the leading zero
}
else
{
- return(0); // number string with leading zero, speak as individual digits
+ if(n_digits > 3)
+ {
+ flags[0] &= ~FLAG_SKIPWORDS;
+ return(0); // long number string with leading zero, speak as individual digits
+ }
+
+ // speak leading zeros
+ for(ix=0; (word[ix] == '0') && (ix < (n_digits-1)); ix++)
+ {
+ Lookup(tr, "_0", &ph_zeros[strlen(ph_zeros)]);
+ }
}
}
- if((tr->langopts.numbers & 0x1000) && (word[n_digits] == ' '))
+ if((tr->langopts.numbers & NUM_ALLOW_SPACE) && (word[n_digits] == ' '))
thousands_inc = 1;
- else
- if(word[n_digits] == tr->langopts.thousands_sep)
+ else if(word[n_digits] == tr->langopts.thousands_sep)
thousands_inc = 2;
+ suffix_ix = n_digits+2;
if(thousands_inc > 0)
{
// if the following "words" are three-digit groups, count them and add
// a "thousand"/"million" suffix to this one
+ digix = n_digits + thousands_inc;
- ix = n_digits + thousands_inc;
- while(isdigit(word[ix]) && isdigit(word[ix+1]) && isdigit(word[ix+2]))
+ while(((wtab[thousandplex+1].flags & FLAG_MULTIPLE_SPACES) == 0) && CheckThousandsGroup(&word[digix], group_len))
{
+ for(ix=0; ix<group_len; ix++)
+ {
+ if(word[digix+ix] != '0')
+ {
+ thousands_exact = 0;
+ break;
+ }
+ }
+
thousandplex++;
- if(word[ix+3] == tr->langopts.thousands_sep)
- ix += (3 + thousands_inc);
+ digix += group_len;
+ if((word[digix] == tr->langopts.thousands_sep) || ((tr->langopts.numbers & NUM_ALLOW_SPACE) && (word[digix] == ' ')))
+ {
+ suffix_ix = digix+2;
+ digix += thousands_inc;
+ }
else
break;
}
@@ -1342,20 +2188,29 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
suppress_null = 1;
}
- if((word[n_digits] == tr->langopts.decimal_sep) && isdigit(word[n_digits+1]))
+ if(tr->translator_name == L('h','u'))
+ {
+ // variant form of numbers when followed by hyphen and a suffix starting with 'a' or 'e' (but not a, e, az, ez, azt, ezt
+ if((wtab[thousandplex].flags & FLAG_HYPHEN_AFTER) && (thousands_exact==1) && hu_number_e(&word[suffix_ix], thousandplex, value))
+ {
+ number_control |= 1; // use _1e variant of number
+ }
+ }
+
+ if((word[n_digits] == tr->langopts.decimal_sep) && IsDigit09(word[n_digits+1]))
{
// this "word" ends with a decimal point
Lookup(tr, "_dpt", ph_append);
- decimal_point = 1;
+ decimal_point = 0x100;
}
- else
- if(suppress_null == 0)
+ else if(suppress_null == 0)
{
if(thousands_inc > 0)
{
- if((thousandplex > 0) && (value < 1000))
+ if(thousandplex > 0)
+// if((thousandplex > 0) && (value < 1000))
{
- if((suppress_null == 0) && (LookupThousands(tr,value,thousandplex,ph_append)))
+ if((suppress_null == 0) && (LookupThousands(tr,value,thousandplex, thousands_exact, ph_append)))
{
// found an exact match for N thousand
value = 0;
@@ -1365,27 +2220,85 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
}
}
else
- if((thousandplex > 1) && prev_thousands && (prev_value > 0))
- {
- sprintf(string,"_%s%d",M_Variant(value),thousandplex+1);
- if(Lookup(tr, string, buf1)==0)
+
+ if(speak_missing_thousands == 1)
{
// speak this thousandplex if there was no word for the previous thousandplex
- sprintf(string,"_0M%d",thousandplex);
- Lookup(tr, string, ph_append);
+ sprintf(string,"_0M%d",thousandplex+1);
+ if(Lookup(tr, string, buf1)==0)
+ {
+ sprintf(string,"_0M%d",thousandplex);
+ Lookup(tr, string, ph_append);
+ }
}
- }
if((ph_append[0] == 0) && (word[n_digits] == '.') && (thousandplex == 0))
{
Lookup(tr, "_.", ph_append);
}
- LookupNum3(tr, value, ph_buf, suppress_null, thousandplex, prev_thousands | ordinal);
+ if(thousandplex == 0)
+ {
+ char *p2;
+ // look for combinations of the number with the next word
+ p = word;
+ while(IsDigit09(p[1])) p++; // just use the last digit
+ if(IsDigit09(p[-1]))
+ {
+ p2 = p - 1;
+ if(LookupDictList(tr, &p2, buf_digit_lookup, flags, FLAG_SUFX, wtab)) // lookup 2 digits
+ {
+ n_digit_lookup = 2;
+ }
+ }
+
+// if((buf_digit_lookup[0] == 0) && (*p != '0') && (dot_ordinal==0))
+ if((buf_digit_lookup[0] == 0) && (*p != '0'))
+ {
+ // LANG=hu ?
+ // not found, lookup only the last digit (?? but not if dot-ordinal has been found)
+ if(LookupDictList(tr, &p, buf_digit_lookup, flags, FLAG_SUFX, wtab)) // don't match '0', or entries with $only
+ {
+ n_digit_lookup = 1;
+ }
+ }
+
+ if(prev_thousands == 0)
+ {
+ if((decimal_point == 0) && (ordinal == 0))
+ {
+ // Look for special pronunciation for this number in isolation (LANG=kl)
+ sprintf(string, "_%dn", value);
+ if(Lookup(tr, string, ph_out))
+ {
+ return(1);
+ }
+ }
+
+ if(tr->langopts.numbers2 & NUM2_PERCENT_BEFORE)
+ {
+ // LANG=si, say "percent" before the number
+ p2 = word;
+ while((*p2 != ' ') && (*p2 != 0))
+ {
+ p2++;
+ }
+ if(p2[1] == '%')
+ {
+ Lookup(tr, "%", ph_out);
+ ph_out += strlen(ph_out);
+ p2[1] = ' ';
+ }
+ }
+ }
+
+ }
+
+ LookupNum3(tr, value, ph_buf, suppress_null, thousandplex, prev_thousands | ordinal | decimal_point);
if((thousandplex > 0) && (tr->langopts.numbers2 & 0x200))
- sprintf(ph_out,"%s%s%s",ph_append,ph_buf2,ph_buf); // say "thousands" before its number
+ sprintf(ph_out,"%s%s%c%s%s",ph_zeros,ph_append,phonEND_WORD,ph_buf2,ph_buf); // say "thousands" before its number
else
- sprintf(ph_out,"%s%s%s",ph_buf2,ph_buf,ph_append);
+ sprintf(ph_out,"%s%s%s%c%s",ph_zeros,ph_buf2,ph_buf,phonEND_WORD,ph_append);
while(decimal_point)
@@ -1393,17 +2306,17 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
n_digits++;
decimal_count = 0;
- while(isdigit(word[n_digits+decimal_count]))
+ while(IsDigit09(word[n_digits+decimal_count]))
decimal_count++;
- if(decimal_count > 1)
+// if(decimal_count > 1)
{
max_decimal_count = 2;
switch(decimal_mode = (tr->langopts.numbers & 0xe000))
{
- case 0x8000:
+ case NUM_DFRACTION_4:
max_decimal_count = 5;
- case 0x4000:
+ case NUM_DFRACTION_2:
// French/Polish decimal fraction
while(word[n_digits] == '0')
{
@@ -1412,7 +2325,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
decimal_count--;
n_digits++;
}
- if((decimal_count <= max_decimal_count) && isdigit(word[n_digits]))
+ if((decimal_count <= max_decimal_count) && IsDigit09(word[n_digits]))
{
LookupNum3(tr, atoi(&word[n_digits]), buf1, 0,0,0);
strcat(ph_out,buf1);
@@ -1420,50 +2333,63 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
}
break;
- case 0x2000:
- case 0xa000:
- // Italian decimal fractions
- if(decimal_count <= 4)
+ case NUM_DFRACTION_1: // italian, say "hundredths" if leading zero
+ case NUM_DFRACTION_5: // hungarian, always say "tenths" etc.
+ case NUM_DFRACTION_6: // kazakh, always say "tenths" etc, before the decimal fraction
+ LookupNum3(tr, atoi(&word[n_digits]), ph_buf, 0,0,0);
+ if((word[n_digits]=='0') || (decimal_mode != NUM_DFRACTION_1))
{
- LookupNum3(tr, atoi(&word[n_digits]), ph_buf, 0,0,0);
- if((word[n_digits]=='0') || (decimal_mode == 0xa000))
- {
- // decimal part has leading zeros, so add a "hundredths" or "thousandths" suffix
- sprintf(string,"_0Z%d",decimal_count);
- if(Lookup(tr, string, buf1) == 0)
- break; // revert to speaking single digits
+ // decimal part has leading zeros, so add a "hundredths" or "thousandths" suffix
+ sprintf(string,"_0Z%d",decimal_count);
+ if(Lookup(tr, string, buf1) == 0)
+ break; // revert to speaking single digits
- strcat(ph_buf,buf1);
- }
- strcat(ph_out,ph_buf);
- n_digits += decimal_count;
+ if(decimal_mode == NUM_DFRACTION_6)
+ strcat(ph_out, buf1);
+ else
+ strcat(ph_buf, buf1);
}
+ strcat(ph_out,ph_buf);
+ n_digits += decimal_count;
break;
- case 0x6000:
+ case NUM_DFRACTION_3:
// Romanian decimal fractions
if((decimal_count <= 4) && (word[n_digits] != '0'))
{
- LookupNum3(tr, atoi(&word[n_digits]), buf1, 0,0,0);
- strcat(ph_out,buf1);
- n_digits += decimal_count;
+ LookupNum3(tr, atoi(&word[n_digits]), buf1, 0,0,0);
+ strcat(ph_out,buf1);
+ n_digits += decimal_count;
}
break;
+
+ case NUM_DFRACTION_7:
+ // alternative form of decimal fraction digits, except the final digit
+ while(decimal_count-- > 1)
+ {
+ sprintf(string,"_%cd", word[n_digits]);
+ if(Lookup(tr, string, buf1) == 0)
+ break;
+ n_digits++;
+ strcat(ph_out, buf1);
+ }
}
}
- while(isdigit(c = word[n_digits]) && (strlen(ph_out) < (N_WORD_PHONEMES - 10)))
+ while(IsDigit09(c = word[n_digits]) && (strlen(ph_out) < (N_WORD_PHONEMES - 10)))
{
+ // speak any remaining decimal fraction digits individually
value = word[n_digits++] - '0';
- LookupNum2(tr, value, 1, buf1);
- strcat(ph_out,buf1);
+ LookupNum2(tr, value, 0, 2, buf1);
+ len = strlen(ph_out);
+ sprintf(&ph_out[len],"%c%s", phonEND_WORD, buf1);
}
// something after the decimal part ?
if(Lookup(tr, "_dpt2", buf1))
strcat(ph_out,buf1);
- if((c == tr->langopts.decimal_sep) && isdigit(word[n_digits+1]))
+ if((c == tr->langopts.decimal_sep) && IsDigit09(word[n_digits+1]))
{
Lookup(tr, "_dpt", buf1);
strcat(ph_out,buf1);
@@ -1483,25 +2409,30 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
if((tr->langopts.numbers & NUM_NOPAUSE) && (next_char == ' '))
utf8_in(&next_char,p);
- if(!iswalpha(next_char))
+ if(!iswalpha2(next_char) && (thousands_exact==0))
+// if(!iswalpha2(next_char) && !((wtab[thousandplex].flags & FLAG_HYPHEN_AFTER) && (thousands_exact != 0)))
strcat(ph_out,str_pause); // don't add pause for 100s, 6th, etc.
}
*flags |= FLAG_FOUND;
- prev_value = this_value;
+ speak_missing_thousands--;
+
+ if(skipwords)
+ dictionary_skipwords = skipwords;
return(1);
} // end of TranslateNumber_1
-int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, int wflags)
-{//============================================================================================
- if(option_sayas == SAYAS_DIGITS1)
+int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control)
+{//=============================================================================================================
+ if((option_sayas == SAYAS_DIGITS1) || (wtab[0].flags & FLAG_INDIVIDUAL_DIGITS))
return(0); // speak digits individually
- if((tr->langopts.numbers & 0x3) == 1)
- return(TranslateNumber_1(tr, word1, ph_out, flags, wflags));
-
+ if(tr->langopts.numbers != 0)
+ {
+ return(TranslateNumber_1(tr, word1, ph_out, flags, wtab, control));
+ }
return(0);
} // end of TranslateNumber
diff --git a/navit/support/espeak/phoneme.h b/navit/support/espeak/phoneme.h
index 596f457ef..9a2e13913 100755..100644
--- a/navit/support/espeak/phoneme.h
+++ b/navit/support/espeak/phoneme.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2010 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -35,7 +35,8 @@
// phoneme properties
-// bits 16-19 give place of articulation (not currently used)
+// bits 16-19 give place of articulation
+#define phARTICULATION 0xf0000
#define phWAVE 0x01
#define phUNSTRESSED 0x02
#define phFORTIS 0x08
@@ -45,22 +46,20 @@
#define phTRILL 0x80
#define phVOWEL2 0x100 // liquid that is considered a vowel
#define phPALATAL 0x200
-#define phAPPENDPH 0x2000 // always insert another phoneme (link_out) after this one
+#define phSINGLE_INSTN 0x1000 // this phoneme has a single instruction program, with an implicit Return
#define phBRKAFTER 0x4000 // [*] add a post-pause
-#define phBEFOREPAUSE 0x8000 // replace with the link_out phoneme if the next phoneme is a pause
-#define phALTERNATIVE 0x1c00 // bits 10,11,12 specifying use of alternative_ph
-#define phBEFOREVOWEL 0x0000
-#define phBEFOREVOWELPAUSE 0x0400
-#define phBEFORENOTVOWEL 0x0c00
-#define phBEFORENOTVOWEL2 0x1000
-#define phSWITCHVOICING 0x0800
-#define phBEFORE_R 0x1400
-
-#define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
+#define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
#define phLONG 0x200000
#define phLENGTHENSTOP 0x400000 // make the pre-pause slightly longer
-#define phRHOTIC 0x800000
+#define phRHOTIC 0x800000 // bit 23
+#define phNOPAUSE 0x1000000
+#define phPREVOICE 0x2000000 // for voiced stops
+
+#define phFLAG1 0x10000000
+#define phFLAG2 0x20000000
+#define phFLAG3 0x40000000
+#define phLOCAL 0x80000000 // used during compilation
// fixed phoneme code numbers, these can be used from the program code
#define phonCONTROL 1
@@ -78,7 +77,6 @@
#define phonSCHWA 13
#define phonSCHWA_SHORT 14
#define phonEND_WORD 15
-#define phonSONORANT 16
#define phonDEFAULTTONE 17
#define phonCAPITAL 18
#define phonGLOTTALSTOP 19
@@ -90,11 +88,13 @@
#define phonT_REDUCED 25
#define phonSTRESS_TONIC 26
#define phonPAUSE_CLAUSE 27
+#define phonVOWELTYPES 28 // 28 to 33
extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long, glottalstop
// place of articulation
#define phPLACE 0xf0000
+#define phPLACE_blb 0x10000
#define phPLACE_pla 0x60000
#define N_PHONEME_TABS 100 // number of phoneme tables
@@ -102,29 +102,22 @@ extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long,
#define N_PHONEME_TAB_NAME 32 // must be multiple of 4
// main table of phonemes, index by phoneme number (1-254)
-typedef struct {
- unsigned int mnemonic; // 1st char is in the l.s.byte
- unsigned int phflags; // bits 28-30 reduce_to level, bits 16-19 place of articulation
- // bits 10-11 alternative ph control
- unsigned short std_length; // for vowels, in mS; for phSTRESS, the stress/tone type
- unsigned short spect;
- unsigned short before;
- unsigned short after;
-
- unsigned char code; // the phoneme number
- unsigned char type; // phVOWEL, phPAUSE, phSTOP etc
+typedef struct {
+ unsigned int mnemonic; // Up to 4 characters. The first char is in the l.s.byte
+ unsigned int phflags; // bits 16-19 place of articulation
+ unsigned short program; // index into phondata file
+ unsigned char code; // the phoneme number
+ unsigned char type; // phVOWEL, phPAUSE, phSTOP etc
unsigned char start_type;
unsigned char end_type;
-
- unsigned char length_mod; // a length_mod group number, used to access length_mod_tab
- unsigned char reduce_to; // change to this phoneme if unstressed
- unsigned char alternative_ph; // change to this phoneme if a vowel follows/doesn't follow
- unsigned char link_out; // insert linking phoneme if a vowel follows
-
+ unsigned char std_length; // for vowels, in mS/2; for phSTRESS phonemes, this is the stress/tone type
+ unsigned char length_mod; // a length_mod group number, used to access length_mod_tab
+
} PHONEME_TAB;
+
// Several phoneme tables may be loaded into memory. phoneme_tab points to
// one for the current voice
extern int n_phoneme_tab;
@@ -136,7 +129,8 @@ typedef struct {
char name[N_PHONEME_TAB_NAME];
PHONEME_TAB *phoneme_tab_ptr;
int n_phonemes;
- int includes; // also include the phonemes from this other phoneme table
+ int includes; // also include the phonemes from this other phoneme table
+ int equivalence_tables; // lists of equivalent phonemes to match other languages, byte index into phondata
} PHONEME_TAB_LIST;
@@ -153,13 +147,21 @@ extern int n_replace_phonemes;
extern REPLACE_PHONEMES replace_phonemes[N_REPLACE_PHONEMES];
-#define PH(c1,c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name
+// Table of phoneme programs and lengths. Used by MakeVowelLists
+typedef struct {
+ unsigned int addr;
+ unsigned int length;
+} PHONEME_PROG_LOG;
+
+
+
+#define PH(c1,c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name
#define PH3(c1,c2,c3) (c3<<16)+(c2<<8)+c1
#define PhonemeCode2(c1,c2) PhonemeCode((c2<<8)+c1)
int LookupPhonemeString(const char *string);
int PhonemeCode(unsigned int mnem);
-char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme);
+const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme);
void DecodePhonemes(const char *inptr, char *outptr);
extern const char *WordToString(unsigned int word);
diff --git a/navit/support/espeak/phonemelist.c b/navit/support/espeak/phonemelist.c
index d663e2e94..07d6fd3d7 100755..100644
--- a/navit/support/espeak/phonemelist.c
+++ b/navit/support/espeak/phonemelist.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -38,20 +38,8 @@ extern PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes
-static int ChangePhonemes(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
-{//=================================================================================================================
-// Called for each phoneme in the phoneme list, to allow a language to make changes
-// ph The current phoneme
-
- if(tr->translator_name == L('r','u'))
- return(ChangePhonemes_ru(tr, phlist, n_ph, index, ph, ch));
-
- return(0);
-}
-
-
-static int SubstitutePhonemes(Translator *tr, PHONEME_LIST2 *plist_out)
-{//====================================================================
+static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
+{//===================================================================
// Copy the phonemes list and perform any substitutions that are required for the
// current voice
int ix;
@@ -59,113 +47,47 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST2 *plist_out)
int replace_flags;
int n_plist_out = 0;
int word_end;
- int max_stress = -1;
- int switched_language = 0;
- int max_stress_posn=0;
- int n_syllables = 0;
- int syllable = 0;
- int syllable_stressed = 0;
PHONEME_LIST2 *plist2;
- PHONEME_LIST2 *pl;
PHONEME_TAB *next=NULL;
for(ix=0; (ix < n_ph_list2) && (n_plist_out < N_PHONEME_LIST); ix++)
{
plist2 = &ph_list2[ix];
- if(plist2->phcode == phonSWITCH)
- switched_language ^= 1;
-
// don't do any substitution if the language has been temporarily changed
- if(switched_language == 0)
+ if(!(plist2->synthflags & SFLAG_SWITCHED_LANG))
{
if(ix < (n_ph_list2 -1))
next = phoneme_tab[ph_list2[ix+1].phcode];
-
+
word_end = 0;
if((plist2+1)->sourceix || ((next != 0) && (next->type == phPAUSE)))
word_end = 1; // this phoneme is the end of a word
-
- if(tr->langopts.phoneme_change != 0)
- {
- // this language does changes to phonemes after translation
- int flags;
- CHANGEPH ch;
- if(plist2->sourceix)
- {
- // start of a word, find the stressed vowel
- syllable = 0;
- syllable_stressed = 0;
- n_syllables = 0;
-
- max_stress = -1;
- max_stress_posn = ix;
- for(k=ix; k < n_ph_list2; k++)
- {
- if(((pl = &ph_list2[k])->sourceix != 0) && (k > ix))
- break;
-
- pl->stress &= 0xf;
-
- if(phoneme_tab[pl->phcode]->type == phVOWEL)
- {
- n_syllables++;
-
- if(pl->stress > max_stress)
- {
- syllable_stressed = n_syllables;
- max_stress = pl->stress;
- max_stress_posn = k;
- }
- }
- }
- }
- if(phoneme_tab[plist2->phcode]->type == phVOWEL)
- {
- syllable++;
- }
-
- // make any language specific changes
- flags = 0;
- if(ix == max_stress_posn)
- flags |= 2;
- if(ix > max_stress_posn)
- flags |= 4;
- if(ph_list2[ix].synthflags & SFLAG_DICTIONARY)
- flags |= 8;
- ch.flags = flags | word_end;
-
- ch.stress = plist2->stress;
- ch.stress_highest = max_stress;
- ch.n_vowels = n_syllables;
- ch.vowel_this = syllable;
- ch.vowel_stressed = syllable_stressed;
-
- ChangePhonemes(tr, ph_list2, n_ph_list2, ix, phoneme_tab[ph_list2[ix].phcode], &ch);
- }
-
// check whether a Voice has specified that we should replace this phoneme
for(k=0; k<n_replace_phonemes; k++)
{
if(plist2->phcode == replace_phonemes[k].old_ph)
{
replace_flags = replace_phonemes[k].type;
-
+
if((replace_flags & 1) && (word_end == 0))
continue; // this replacement only occurs at the end of a word
-
- if((replace_flags & 2) && ((plist2->stress & 0x7) > 3))
+
+ if((replace_flags & 2) && ((plist2->stresslevel & 0x7) > 3))
continue; // this replacement doesn't occur in stressed syllables
-
+
+ if((replace_flags & 4) && (plist2->sourceix == 0))
+ continue; // this replacement only occurs at the start of a word
+
// substitute the replacement phoneme
plist2->phcode = replace_phonemes[k].new_ph;
- if((plist2->stress > 1) && (phoneme_tab[plist2->phcode]->phflags & phUNSTRESSED))
- plist2->stress = 0; // the replacement must be unstressed
+ if((plist2->stresslevel > 1) && (phoneme_tab[plist2->phcode]->phflags & phUNSTRESSED))
+ plist2->stresslevel = 0; // the replacement must be unstressed
break;
}
}
-
+
if(plist2->phcode == 0)
{
continue; // phoneme has been replaced by NULL, so don't copy it
@@ -173,7 +95,10 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST2 *plist_out)
}
// copy phoneme into the output list
- memcpy(&plist_out[n_plist_out++],plist2,sizeof(PHONEME_LIST2));
+ memcpy(&plist_out[n_plist_out],plist2,sizeof(PHONEME_LIST2));
+ plist_out[n_plist_out].ph = phoneme_tab[plist2->phcode];
+ plist_out[n_plist_out].type = plist_out[n_plist_out].ph->type;
+ n_plist_out++;
}
return(n_plist_out);
} // end of SubstitutePhonemes
@@ -188,22 +113,30 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
int insert_ph = 0;
PHONEME_LIST *phlist;
PHONEME_TAB *ph;
- PHONEME_TAB *prev, *next, *next2;
+ PHONEME_TAB *next, *next2;
int unstress_count = 0;
int word_stress = 0;
- int switched_language = 0;
+ int current_phoneme_tab;
int max_stress;
int voicing;
int regression;
int end_sourceix;
int alternative;
- int first_vowel=0; // first vowel in a word
- PHONEME_LIST2 ph_list3[N_PHONEME_LIST];
+ int delete_count;
+ int word_start;
+ int inserted;
+ int deleted;
+ PHONEME_DATA phdata;
- static PHONEME_LIST2 ph_list2_null = {0,0,0,0,0};
- PHONEME_LIST2 *plist2 = &ph_list2_null;
- PHONEME_LIST2 *plist2_inserted = NULL;
+ int n_ph_list3;
+ PHONEME_LIST *plist3;
+ PHONEME_LIST *plist3_inserted = NULL;
+ PHONEME_LIST ph_list3[N_PHONEME_LIST];
+ PHONEME_LIST2 *plist2;
+ WORD_PH_DATA worddata;
+
+ memset(&worddata, 0, sizeof(worddata));
plist2 = ph_list2;
phlist = phoneme_list;
end_sourceix = plist2[n_ph_list2-1].sourceix;
@@ -212,9 +145,9 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
max_stress = 0;
for(j = n_ph_list2-3; j>=0; j--)
{
- // start with the last phoneme (before the terminating pauses) and move forwards
- if((plist2[j].stress & 0x7f) > max_stress)
- max_stress = plist2[j].stress & 0x7f;
+ // start with the last phoneme (before the terminating pauses) and move backwards
+ if((plist2[j].stresslevel & 0x7f) > max_stress)
+ max_stress = plist2[j].stresslevel & 0x7f;
if(plist2[j].sourceix != 0)
break;
}
@@ -225,10 +158,10 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
{
if(plist2[j].synthflags & SFLAG_PROMOTE_STRESS) // dictionary flags indicated that this stress can be promoted
{
- plist2[j].stress = 4; // promote to stressed
+ plist2[j].stresslevel = 4; // promote to stressed
break;
}
- if(plist2[j].stress >= 4)
+ if(plist2[j].stresslevel >= 4)
{
// found a stressed syllable, so stop looking
break;
@@ -236,11 +169,48 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
}
}
+ // look for switch of phoneme tables
+ delete_count = 0;
+ current_phoneme_tab = tr->phoneme_tab_ix;
+ for(j = 0; j < n_ph_list2; j++)
+ {
+ if(current_phoneme_tab != tr->phoneme_tab_ix)
+ {
+ plist2[j].synthflags |= SFLAG_SWITCHED_LANG;
+ }
+
+ if(delete_count > 0)
+ {
+ memcpy(&plist2[j-delete_count], &plist2[j], sizeof(plist2[0]));
+ }
+
+ if(plist2[j].phcode == phonSWITCH)
+ {
+ if((!(plist2[j].synthflags & SFLAG_EMBEDDED)) && (
+ (plist2[j].tone_ph == current_phoneme_tab) ||
+ (plist2[j+1].phcode == phonSWITCH) ||
+ ((plist2[j+1].phcode == phonPAUSE) && (plist2[j+2].phcode == phonSWITCH))
+ ))
+ {
+ // delete this phonSWITCH if it's switching to the current phoneme table, or
+ // delete this phonSWITCH if its followed by another phonSWITCH
+ delete_count++;
+ }
+ else
+ {
+ current_phoneme_tab = plist2[j].tone_ph;
+ }
+ }
+
+ }
+ n_ph_list2 -= delete_count;
+
if((regression = tr->langopts.param[LOPT_REGRESSIVE_VOICING]) != 0)
{
// set consonant clusters to all voiced or all unvoiced
// Regressive
int type;
+ int stop_propagation = 0;
voicing = 0;
for(j=n_ph_list2-1; j>=0; j--)
@@ -249,43 +219,48 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
if(ph == NULL)
continue;
- if(ph->code == phonSWITCH)
- switched_language ^= 1;
- if(switched_language)
+ if(plist2[j].synthflags & SFLAG_SWITCHED_LANG)
+ {
+ stop_propagation = 0;
+ voicing = 0;
+ if(regression & 0x100)
+ voicing = 1; // word-end devoicing
continue;
+ }
type = ph->type;
if(regression & 0x2)
{
- // LANG=Russian, [v] amd [v;] don't cause regression, or [R^]
- if((ph->mnemonic == 'v') || (ph->mnemonic == ((';'<<8)+'v')) || ((ph->mnemonic & 0xff)== 'R'))
- type = phLIQUID;
+ // [v] amd [v;] don't cause regression, or [R^]
+ if(((ph->mnemonic & 0xff) == 'v') || ((ph->mnemonic & 0xff)== 'R'))
+ {
+ stop_propagation = 1;
+ if(regression & 0x10)
+ voicing = 0;
+ }
}
if((type==phSTOP) || type==(phFRICATIVE))
{
- if(voicing==0)
+ if((voicing==0) && (regression & 0xf))
{
voicing = 1;
}
- else
- if((voicing==2) && ((ph->phflags & phALTERNATIVE)==phSWITCHVOICING))
+ else if((voicing==2) && (ph->end_type != 0)) // use end_type field for voicing_switch for consonants
{
- plist2[j].phcode = ph->alternative_ph; // change to voiced equivalent
+ plist2[j].phcode = ph->end_type; // change to voiced equivalent
}
}
- else
- if((type==phVSTOP) || type==(phVFRICATIVE))
+ else if((type==phVSTOP) || type==(phVFRICATIVE))
{
- if(voicing==0)
+ if((voicing==0) && (regression & 0xf))
{
voicing = 2;
}
- else
- if((voicing==1) && ((ph->phflags & phALTERNATIVE)==phSWITCHVOICING))
+ else if((voicing==1) && (ph->end_type != 0))
{
- plist2[j].phcode = ph->alternative_ph; // change to unvoiced equivalent
+ plist2[j].phcode = ph->end_type; // change to unvoiced equivalent
}
}
else
@@ -301,234 +276,257 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
voicing = 0;
}
}
- if((regression & 0x4) && (plist2[j].sourceix))
+ if(stop_propagation)
{
- // stop propagation at a word boundary
voicing = 0;
+ stop_propagation = 0;
+ }
+
+ if(plist2[j].sourceix)
+ {
+ if(regression & 0x04)
+ {
+ // stop propagation at a word boundary
+ voicing = 0;
+ }
+ if(regression & 0x100)
+ {
+ // devoice word-final consonants, unless propagating voiced
+ if(voicing == 0)
+ {
+ voicing = 1;
+ }
+ }
}
}
}
- n_ph_list2 = SubstitutePhonemes(tr,ph_list3) - 2;
+ n_ph_list3 = SubstitutePhonemes(tr,ph_list3) - 2;
+
+ for(j=0; (j < n_ph_list3) && (ix < N_PHONEME_LIST-3);)
+ {
+ if(ph_list3[j].sourceix)
+ {
+ // start of a word
+ int k;
+ int nextw;
+ word_stress = 0;
+
+ // find the highest stress level in this word
+ for(nextw=j; nextw < n_ph_list3;)
+ {
+ if(ph_list3[nextw].stresslevel > word_stress)
+ word_stress = ph_list3[nextw].stresslevel;
+
+ nextw++;
+ if(ph_list3[nextw].sourceix)
+ break; // start of the next word
+ }
+ for(k=j; k<nextw; k++)
+ {
+ ph_list3[k].wordstress = word_stress;
+ }
+ j = nextw;
+ }
+ else
+ {
+ j++;
+ }
+ }
// transfer all the phonemes of the clause into phoneme_list
ph = phoneme_tab[phonPAUSE];
- switched_language = 0;
+ ph_list3[0].ph = ph;
+ word_start = 1;
- for(j=0; insert_ph || ((j < n_ph_list2) && (ix < N_PHONEME_LIST-3)); j++)
+ for(j=0; insert_ph || ((j < n_ph_list3) && (ix < N_PHONEME_LIST-3)); j++)
{
- prev = ph;
-
- plist2 = &ph_list3[j];
+ plist3 = &ph_list3[j];
+ inserted = 0;
+ deleted = 0;
if(insert_ph != 0)
{
// we have a (linking) phoneme which we need to insert here
- next = phoneme_tab[plist2->phcode]; // this phoneme, i.e. after the insert
+ next = phoneme_tab[plist3->phcode]; // this phoneme, i.e. after the insert
// re-use the previous entry for the inserted phoneme.
- // That's OK because we don't look backwards from plist2
+ // That's OK because we don't look backwards from plist3 *** but CountVowelPosition() and isAfterStress does !!!
j--;
- plist2 = plist2_inserted = &ph_list3[j];
- memset(plist2, 0, sizeof(*plist2));
- plist2->phcode = insert_ph;
+ plist3 = plist3_inserted = &ph_list3[j];
+ if(j > 0)
+ {
+ // move all previous phonemes in the word back one place
+ int k;
+ if(word_start > 0)
+ {
+ k = word_start;
+ word_start--;
+ }
+ else
+ {
+ k = 2; // No more space, don't loose the start of word mark at ph_list2[word_start]
+ }
+ for(; k<=j; k++)
+ memcpy(&ph_list3[k-1], &ph_list3[k], sizeof(*plist3));
+ }
+ memset(&plist3[0], 0, sizeof(*plist3));
+ plist3->phcode = insert_ph;
ph = phoneme_tab[insert_ph];
+ plist3->ph = ph;
insert_ph = 0;
+ inserted = 1; // don't insert the same phoneme repeatedly
}
else
{
// otherwise get the next phoneme from the list
- ph = phoneme_tab[plist2->phcode];
+ if(plist3->sourceix != 0)
+ word_start = j;
- if(plist2->phcode == phonSWITCH)
- {
- // change phoneme table
- SelectPhonemeTable(plist2->tone_number);
- switched_language ^= SFLAG_SWITCHED_LANG;
- }
- next = phoneme_tab[(plist2+1)->phcode]; // the phoneme after this one
- }
+ ph = phoneme_tab[plist3->phcode];
+ plist3[0].ph = ph;
- if(plist2->sourceix)
- {
- // start of a word
- int k;
- word_stress = 0;
- first_vowel = 1;
-
- // find the highest stress level in this word
- for(k=j+1; k < n_ph_list2; k++)
+ if(plist3->phcode == phonSWITCH)
{
- if(ph_list3[k].sourceix)
- break; // start of the next word
-
- if(ph_list3[k].stress > word_stress)
- word_stress = ph_list3[k].stress;
+ // change phoneme table
+ SelectPhonemeTable(plist3->tone_ph);
}
+ next = phoneme_tab[plist3[1].phcode]; // the phoneme after this one
+ plist3[1].ph = next;
}
if(ph == NULL) continue;
- if(ph->type == phVOWEL)
- {
- // check for consecutive unstressed syllables
- if(plist2->stress == 0)
- {
- // an unstressed vowel
- unstress_count++;
- if((unstress_count > 1) && ((unstress_count & 1)==0))
- {
- // in a sequence of unstressed syllables, reduce alternate syllables to 'diminished'
- // stress. But not for the last phoneme of a stressed word
- if((tr->langopts.stress_flags & 0x2) || ((word_stress > 3) && ((plist2+1)->sourceix!=0)))
- {
- // An unstressed final vowel of a stressed word
- unstress_count=1; // try again for next syllable
- }
- else
- {
- plist2->stress = 1; // change stress to 'diminished'
- }
- }
- }
- else
- {
- unstress_count = 0;
- }
- }
-
- alternative = 0;
-
- if(ph->alternative_ph > 0)
- {
- switch(ph->phflags & phALTERNATIVE)
- {
- // This phoneme changes if vowel follows, or doesn't follow, depending on its phNOTFOLLOWS flag
- case phBEFORENOTVOWEL:
- if(next->type != phVOWEL)
- alternative = ph->alternative_ph;
- break;
-
- case phBEFORENOTVOWEL2: // LANG=tr
- if(((plist2+1)->sourceix != 0) ||
- ((next->type != phVOWEL) && ((phoneme_tab[(plist2+2)->phcode]->type != phVOWEL) || ((plist2+2)->sourceix != 0))))
- {
- alternative = ph->alternative_ph;
- }
- break;
-
- case phBEFOREVOWELPAUSE:
- if((next->type == phVOWEL) || (next->type == phPAUSE))
- alternative = ph->alternative_ph;
- break;
-
- case phBEFOREVOWEL:
- if(next->type == phVOWEL)
- alternative = ph->alternative_ph;
- break;
+ InterpretPhoneme(tr, 0x100, plist3, &phdata, &worddata);
- case phBEFORE_R:
- if(next->phflags & phRHOTIC)
- {
- alternative = ph->alternative_ph;
- }
- break;
- }
- }
- if(ph->phflags & phBEFOREPAUSE)
+ if((alternative = phdata.pd_param[pd_CHANGE_NEXTPHONEME]) > 0)
{
- if(next->type == phPAUSE)
- alternative = ph->link_out; // replace with the link_out phoneme
+ ph_list3[j+1].ph = phoneme_tab[alternative];
+ ph_list3[j+1].phcode = alternative;
+ ph_list3[j+1].type = phoneme_tab[alternative]->type;
+ next = phoneme_tab[alternative];
}
- if(alternative == 1)
- continue; // NULL phoneme, discard
-
- if(alternative > 1)
+ if(((alternative = phdata.pd_param[pd_INSERTPHONEME]) > 0) && (inserted == 0))
{
+ // PROBLEM: if we insert a phoneme before a vowel then we loose the stress.
PHONEME_TAB *ph2;
ph2 = ph;
+
+ insert_ph = plist3->phcode;
ph = phoneme_tab[alternative];
+ plist3->ph = ph;
+ plist3->phcode = alternative;
if(ph->type == phVOWEL)
{
- plist2->synthflags |= SFLAG_SYLLABLE;
+ plist3->synthflags |= SFLAG_SYLLABLE;
if(ph2->type != phVOWEL)
- plist2->stress = 0; // change from non-vowel to vowel, make sure it's unstressed
+ plist3->stresslevel = 0; // change from non-vowel to vowel, make sure it's unstressed
}
else
- plist2->synthflags &= ~SFLAG_SYLLABLE;
- }
+ plist3->synthflags &= ~SFLAG_SYLLABLE;
- if(tr->langopts.param[LOPT_REDUCE_T])
- {
- if((ph->mnemonic == 't') && (plist2->sourceix == 0) && ((prev->type == phVOWEL) || (prev->mnemonic == 'n')))
- {
- if(((plist2+1)->sourceix == 0) && ((plist2+1)->stress < 3) && (next->type == phVOWEL))
- {
- ph = phoneme_tab[phonT_REDUCED];
- }
- }
+ // re-interpret the changed phoneme
+ // But it doesn't obey a second ChangePhoneme()
+ InterpretPhoneme(tr, 0x100, plist3, &phdata, &worddata);
}
-
- while((ph->reduce_to != 0) && (!(plist2->synthflags & SFLAG_DICTIONARY) || (tr->langopts.param[LOPT_REDUCE] & 1)))
+ if((alternative = phdata.pd_param[pd_CHANGEPHONEME]) > 0)
{
- int reduce_level;
- int stress_level;
- int reduce = 0;
-
- reduce_level = (ph->phflags >> 28) & 7;
+ PHONEME_TAB *ph2;
+ ph2 = ph;
+ ph = phoneme_tab[alternative];
+ plist3->ph = ph;
+ plist3->phcode = alternative;
- if(ph->type == phVOWEL)
+ if(alternative == 1)
{
- stress_level = plist2->stress;
+ deleted = 1; // NULL phoneme, discard
}
else
{
- // consonant, get stress from the following vowel
- if(next->type == phVOWEL)
- stress_level = (plist2+1)->stress;
+ if(ph->type == phVOWEL)
+ {
+ plist3->synthflags |= SFLAG_SYLLABLE;
+ if(ph2->type != phVOWEL)
+ plist3->stresslevel = 0; // change from non-vowel to vowel, make sure it's unstressed
+ }
else
- break;
- }
+ plist3->synthflags &= ~SFLAG_SYLLABLE;
- if((stress_level == 1) && (first_vowel))
- stress_level = 0; // ignore 'dimished' stress on first syllable
-
- if(stress_level == 1)
- reduce = 1; // stress = 'reduced'
+ // re-interpret the changed phoneme
+ // But it doesn't obey a second ChangePhoneme()
+ InterpretPhoneme(tr, 0x100, plist3, &phdata, &worddata);
+ }
+ }
- if(stress_level < reduce_level)
- reduce =1;
+ if((ph->type == phVOWEL) && (deleted == 0))
+ {
+ PHONEME_LIST *p;
- if((word_stress < 4) && (tr->langopts.param[LOPT_REDUCE] & 0x2) && (stress_level >= word_stress))
+ // Check for consecutive unstressed syllables, even across word boundaries.
+ // Do this after changing phonemes according to stress level.
+ if(plist3->stresslevel <= 1)
{
- // don't reduce the most stressed syllable in an unstressed word
- reduce = 0;
- }
+ // an unstressed vowel
+ unstress_count++;
- if(reduce)
- ph = phoneme_tab[ph->reduce_to];
+ if(tr->langopts.stress_flags & 0x08)
+ {
+ // change sequences of consecutive unstressed vowels in unstressed words to diminished stress (TEST)
+ for(p=plist3+1; p->type != phPAUSE; p++)
+ {
+ if(p->type == phVOWEL)
+ {
+ if(p->stresslevel <= 1)
+ {
+ if(plist3->wordstress < 4)
+ plist3->stresslevel = 0;
+ if(p->wordstress < 4)
+ p->stresslevel = 0;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ if((unstress_count > 1) && ((unstress_count & 1)==0))
+ {
+ // in a sequence of unstressed syllables, reduce alternate syllables to 'diminished'
+ // stress. But not for the last phoneme of a stressed word
+ if((tr->langopts.stress_flags & S_NO_DIM) || ((word_stress > 3) && ((plist3+1)->sourceix!=0)))
+ {
+ // An unstressed final vowel of a stressed word
+ unstress_count=1; // try again for next syllable
+ }
+ else
+ {
+ plist3->stresslevel = 0; // change stress to 'diminished'
+ }
+ }
+ }
+ }
else
- break;
+ {
+ unstress_count = 0;
+ }
}
- if(ph->type == phVOWEL)
- first_vowel = 0;
-
- if((plist2+1)->synthflags & SFLAG_LENGTHEN)
+ if((plist3+1)->synthflags & SFLAG_LENGTHEN)
{
static char types_double[] = {phFRICATIVE,phVFRICATIVE,phNASAL,phLIQUID,0};
- if(strchr(types_double,next->type))
+ if((j > 0) && (strchr(types_double,next->type)))
{
// lengthen this consonant by doubling it
+ // BUT, can't insert a phoneme at position plist3[0] because it crashes PrevPh()
insert_ph = next->code;
- (plist2+1)->synthflags ^= SFLAG_LENGTHEN;
+ (plist3+1)->synthflags ^= SFLAG_LENGTHEN;
}
}
- if((plist2+1)->sourceix != 0)
+ if((plist3+1)->sourceix != 0)
{
int x;
@@ -551,7 +549,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
else
insert_ph = phonPAUSE_VSHORT;
}
-
+
if((ph->type == phVOWEL) && ((x = tr->langopts.vowel_pause & 0x03) != 0))
{
// adjacent vowels over a word boundary
@@ -560,8 +558,8 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
else
insert_ph = phonPAUSE_VSHORT;
}
-
- if(((plist2+1)->stress >= 4) && (tr->langopts.vowel_pause & 0x100))
+
+ if(((plist3+1)->stresslevel >= 4) && (tr->langopts.vowel_pause & 0x100))
{
// pause before a words which starts with a stressed vowel
insert_ph = phonPAUSE_SHORT;
@@ -569,7 +567,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
}
}
- if(plist2 != plist2_inserted)
+ if((plist3 != plist3_inserted) && (ix > 0))
{
if((x = (tr->langopts.word_gap & 0x7)) != 0)
{
@@ -586,33 +584,12 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
}
}
- next2 = phoneme_tab[(plist2+2)->phcode];
+ next2 = phoneme_tab[plist3[2].phcode];
+ plist3[2].ph = next2;
- if((insert_ph == 0) && (ph->link_out != 0) && !(ph->phflags & phBEFOREPAUSE) && (((plist2+1)->synthflags & SFLAG_EMBEDDED)==0))
+ if((insert_ph == 0) && (phdata.pd_param[pd_APPENDPHONEME] != 0))
{
- if(ph->phflags & phAPPENDPH)
- {
- // always append the specified phoneme, unless it already is the next phoneme
- if((ph->link_out != (plist2+1)->phcode) && (next->type == phVOWEL))
-// if(ph->link_out != (plist2+1)->phcode)
- {
- insert_ph = ph->link_out;
- }
- }
- else
- if(((tr->langopts.word_gap & 8)==0) || ((plist2+1)->sourceix == 0))
- {
- // This phoneme can be linked to a following vowel by inserting a linking phoneme
- if(next->type == phVOWEL)
- insert_ph = ph->link_out;
- else
- if(next->code == phonPAUSE_SHORT)
- {
- // Pause followed by Vowel, replace the Short Pause with the linking phoneme,
- if(next2->type == phVOWEL)
- (plist2+1)->phcode = ph->link_out; // replace pause by linking phoneme
- }
- }
+ insert_ph = phdata.pd_param[pd_APPENDPHONEME];
}
if(ph->phflags & phVOICED)
@@ -623,62 +600,70 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
// not yet implemented
}
- phlist[ix].ph = ph;
- phlist[ix].type = ph->type;
- phlist[ix].env = PITCHfall; // default, can be changed in the "intonation" module
- phlist[ix].synthflags = plist2->synthflags | switched_language;
- phlist[ix].stresslevel = plist2->stress & 0xf;
- phlist[ix].tone_ph = plist2->tone_number;
- phlist[ix].sourceix = 0;
-
- if(plist2->sourceix != 0)
+ if(deleted == 0)
{
- phlist[ix].sourceix = plist2->sourceix;
- phlist[ix].newword = 1; // this phoneme is the start of a word
+ phlist[ix].ph = ph;
+ phlist[ix].type = ph->type;
+ phlist[ix].env = PITCHfall; // default, can be changed in the "intonation" module
+ phlist[ix].synthflags = plist3->synthflags;
+ phlist[ix].stresslevel = plist3->stresslevel & 0xf;
+ phlist[ix].wordstress = plist3->wordstress;
+ phlist[ix].tone_ph = plist3->tone_ph;
+ phlist[ix].sourceix = 0;
+ phlist[ix].phcode = ph->code;
+
+ if(plist3->sourceix != 0)
+ {
+ phlist[ix].sourceix = plist3->sourceix;
+ phlist[ix].newword = 1; // this phoneme is the start of a word
- if(start_sentence)
+ if(start_sentence)
+ {
+ phlist[ix].newword = 5; // start of sentence + start of word
+ start_sentence = 0;
+ }
+ }
+ else
{
- phlist[ix].newword = 5; // start of sentence + start of word
- start_sentence = 0;
+ phlist[ix].newword = 0;
}
- }
- else
- {
- phlist[ix].newword = 0;
- }
- phlist[ix].length = ph->std_length;
- if((ph->code == phonPAUSE_LONG) && (option_wordgap > 0))
- {
- phlist[ix].ph = phoneme_tab[phonPAUSE_SHORT];
- phlist[ix].length = option_wordgap*14; // 10mS per unit at the default speed
- }
+ // phlist[ix].length = ph->std_length;
+ phlist[ix].length = phdata.pd_param[i_SET_LENGTH]*2;
+ if((ph->code == phonPAUSE_LONG) && (option_wordgap > 0) && (plist3[1].sourceix != 0))
+ {
+ phlist[ix].ph = phoneme_tab[phonPAUSE_SHORT];
+ phlist[ix].length = option_wordgap*14; // 10mS per unit at the default speed
+ }
- if(ph->type==phVOWEL || ph->type==phLIQUID || ph->type==phNASAL || ph->type==phVSTOP || ph->type==phVFRICATIVE)
- {
- phlist[ix].length = 128; // length_mod
- phlist[ix].env = PITCHfall;
- }
+ if(ph->type==phVOWEL || ph->type==phLIQUID || ph->type==phNASAL || ph->type==phVSTOP || ph->type==phVFRICATIVE || (ph->phflags & phPREVOICE))
+ {
+ phlist[ix].length = 128; // length_mod
+ phlist[ix].env = PITCHfall;
+ }
- phlist[ix].prepause = 0;
- phlist[ix].amp = 20; // default, will be changed later
- phlist[ix].pitch1 = 0x400;
- phlist[ix].pitch2 = 0x400;
- ix++;
+ phlist[ix].prepause = 0;
+ phlist[ix].amp = 20; // default, will be changed later
+ phlist[ix].pitch1 = 255;
+ phlist[ix].pitch2 = 255;
+ ix++;
+ }
}
phlist[ix].newword = 2; // end of clause
- phlist[ix].type = phPAUSE; // terminate with 2 Pause phonemes
+ phlist[ix].phcode = phonPAUSE;
+ phlist[ix].type = phPAUSE; // terminate with 2 Pause phonemes
phlist[ix].length = post_pause; // length of the pause, depends on the punctuation
phlist[ix].sourceix = end_sourceix;
phlist[ix].synthflags = 0;
+ phlist[ix++].ph = phoneme_tab[phonPAUSE];
- phlist[ix++].ph = phoneme_tab[phonPAUSE];
- phlist[ix].type = phPAUSE;
+ phlist[ix].phcode = phonPAUSE;
+ phlist[ix].type = phPAUSE;
phlist[ix].length = 0;
phlist[ix].sourceix=0;
phlist[ix].synthflags = 0;
- phlist[ix++].ph = phoneme_tab[phonPAUSE_SHORT];
+ phlist[ix++].ph = phoneme_tab[phonPAUSE_SHORT];
n_phoneme_list = ix;
} // end of MakePhonemeList
diff --git a/navit/support/espeak/portaudio.h b/navit/support/espeak/portaudio.h
index 2ab8e02a4..2ab8e02a4 100755..100644
--- a/navit/support/espeak/portaudio.h
+++ b/navit/support/espeak/portaudio.h
diff --git a/navit/support/espeak/portaudio18.h b/navit/support/espeak/portaudio18.h
index 2ab8e02a4..2ab8e02a4 100755..100644
--- a/navit/support/espeak/portaudio18.h
+++ b/navit/support/espeak/portaudio18.h
diff --git a/navit/support/espeak/readclause.c b/navit/support/espeak/readclause.c
index b8d302a27..172ebad15 100644
--- a/navit/support/espeak/readclause.c
+++ b/navit/support/espeak/readclause.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -41,7 +41,7 @@
#include <locale.h>
#define N_XML_BUF 256
-#define double(x) ((double)(x))
+
static const char *xmlbase = ""; // base URL from <speak>
static int namedata_ix=0;
@@ -58,20 +58,21 @@ static const char *ungot_word = NULL;
static int end_of_input;
static int ignore_text=0; // set during <sub> ... </sub> to ignore text which has been replaced by an alias
+static int audio_text=0; // set during <audio> ... </audio>
static int clear_skipping_text = 0; // next clause should clear the skipping_text flag
int count_characters = 0;
static int sayas_mode;
+static int sayas_start;
static int ssml_ignore_l_angle = 0;
-static const char *punct_stop = ".:!?"; // pitch fall if followed by space
-static const char *punct_close = ")]}>;'\""; // always pitch fall unless followed by alnum
-
// alter tone for announce punctuation or capitals
-static const char *tone_punct_on = "\0016T"; // add reverberation, lower pitch
-static const char *tone_punct_off = "\001T";
+//static const char *tone_punct_on = "\0016T"; // add reverberation, lower pitch
+//static const char *tone_punct_off = "\001T\001P";
// punctuations symbols that can end a clause
static const unsigned short punct_chars[] = {',','.','?','!',':',';',
+ 0x00a1, // inverted exclamation
+ 0x00bf, // inverted question
0x2013, // en-dash
0x2014, // em-dash
0x2026, // elipsis
@@ -86,6 +87,15 @@ static const unsigned short punct_chars[] = {',','.','?','!',':',';',
0x055e, // Armenian question
0x055b, // Armenian emphasis mark
+ 0x060c, // Arabic ,
+ 0x061b, // Arabic ;
+ 0x061f, // Arabic ?
+ 0x06d4, // Arabic .
+
+ 0x0df4, // Singhalese Kunddaliya
+ 0x0f0d, // Tibet Shad
+ 0x0f0e,
+
0x1362, // Ethiopic period
0x1363,
0x1364,
@@ -93,6 +103,7 @@ static const unsigned short punct_chars[] = {',','.','?','!',':',';',
0x1366,
0x1367,
0x1368,
+ 0x10fb, // Georgian paragraph
0x3001, // ideograph comma
0x3002, // ideograph period
@@ -103,7 +114,7 @@ static const unsigned short punct_chars[] = {',','.','?','!',':',';',
0xff1a, // fullwidth colon
0xff1b, // fullwidth semicolon
0xff1f, // fullwidth question mark
-
+
0};
@@ -111,19 +122,30 @@ static const unsigned short punct_chars[] = {',','.','?','!',':',';',
// bits 0-7 pause x 10mS, bits 12-14 intonation type, bit 15 don't need following space or bracket
static const unsigned int punct_attributes [] = { 0,
CLAUSE_COMMA, CLAUSE_PERIOD, CLAUSE_QUESTION, CLAUSE_EXCLAMATION, CLAUSE_COLON, CLAUSE_SEMICOLON,
+ CLAUSE_SEMICOLON | 0x8000, // inverted exclamation
+ CLAUSE_SEMICOLON | 0x8000, // inverted question
CLAUSE_SEMICOLON, // en-dash
CLAUSE_SEMICOLON, // em-dash
- CLAUSE_SEMICOLON, // elipsis
+ CLAUSE_SEMICOLON | PUNCT_SAY_NAME | 0x8000, // elipsis
CLAUSE_QUESTION, // Greek question mark
CLAUSE_SEMICOLON, // Greek semicolon
- CLAUSE_PERIOD+0x8000, // Devanagari Danda (fullstop)
+ CLAUSE_PERIOD | 0x8000, // Devanagari Danda (fullstop)
- CLAUSE_PERIOD+0x8000, // Armenian period
+ CLAUSE_PERIOD | 0x8000, // Armenian period
CLAUSE_COMMA, // Armenian comma
- CLAUSE_EXCLAMATION + PUNCT_IN_WORD, // Armenian exclamation
- CLAUSE_QUESTION + PUNCT_IN_WORD, // Armenian question
- CLAUSE_PERIOD + PUNCT_IN_WORD, // Armenian emphasis mark
+ CLAUSE_EXCLAMATION | PUNCT_IN_WORD, // Armenian exclamation
+ CLAUSE_QUESTION | PUNCT_IN_WORD, // Armenian question
+ CLAUSE_PERIOD | PUNCT_IN_WORD, // Armenian emphasis mark
+
+ CLAUSE_COMMA, // Arabic ,
+ CLAUSE_SEMICOLON, // Arabic ;
+ CLAUSE_QUESTION, // Arabic question mark
+ CLAUSE_PERIOD, // Arabic full stop
+
+ CLAUSE_PERIOD+0x8000, // Singhalese period
+ CLAUSE_PERIOD+0x8000, // Tibet period
+ CLAUSE_PARAGRAPH,
CLAUSE_PERIOD, // Ethiopic period
CLAUSE_COMMA, // Ethiopic comma
@@ -131,7 +153,8 @@ static const unsigned int punct_attributes [] = { 0,
CLAUSE_COLON, // Ethiopic colon
CLAUSE_COLON, // Ethiopic preface colon
CLAUSE_QUESTION, // Ethiopic question mark
- CLAUSE_PERIOD, // Ethiopic paragraph
+ CLAUSE_PARAGRAPH, // Ethiopic paragraph
+ CLAUSE_PARAGRAPH, // Georgian paragraph
CLAUSE_COMMA+0x8000, // ideograph comma
CLAUSE_PERIOD+0x8000, // ideograph period
@@ -151,7 +174,7 @@ static const unsigned int punct_attributes [] = { 0,
// frame 0 is for the defaults, before any ssml tags.
typedef struct {
int tag_type;
- int voice_variant;
+ int voice_variant_number;
int voice_gender;
int voice_age;
char voice_name[40];
@@ -162,6 +185,8 @@ typedef struct {
static int n_ssml_stack;
static SSML_STACK ssml_stack[N_SSML_STACK];
+static espeak_VOICE base_voice;
+static char base_voice_variant_name[40] = {0};
static char current_voice_id[40] = {0};
@@ -170,10 +195,11 @@ static int n_param_stack;
PARAM_STACK param_stack[N_PARAM_STACK];
static int speech_parameters[N_SPEECH_PARAM]; // current values, from param_stack
+int saved_parameters[N_SPEECH_PARAM]; //Parameters saved on synthesis start
const int param_defaults[N_SPEECH_PARAM] = {
0, // silence (internal use)
- 170, // rate wpm
+ 175, // rate wpm
100, // volume
50, // pitch
50, // range
@@ -190,49 +216,90 @@ const int param_defaults[N_SPEECH_PARAM] = {
};
-#ifdef NEED_WCHAR_FUNCTIONS
+// additional Latin characters beyond the ascii character set
+#define MAX_WALPHA 0x24f
+// indexed by character - 0x80
+// 0=not alphabetic, 0xff=lower case, 0xfe=no case, 0xfd=use wchar_tolower
+// other=value to add to upper case to convert to lower case
+static unsigned char walpha_tab[MAX_WALPHA-0x7f] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 080
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 090
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xfe, 0, 0, 0, 0, 0, // 0a0
+ 0, 0, 0, 0, 0, 0xff, 0, 0, 0, 0, 0xfe, 0, 0, 0, 0, 0, // 0b0
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, // 0c0
+ 32, 32, 32, 32, 32, 32, 32, 0, 32, 32, 32, 32, 32, 32, 32, 0xff, // 0d0
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0e0
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // 0f0
+ 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 100
+ 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 110
+ 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 120
+ 0xfd, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 0xfe, 1, 0xff, 1, 0xff, 1, 0xff, 1, // 130
+ 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 0xfe, 1, 0xff, 1, 0xff, 1, 0xff, // 140
+ 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 150
+ 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 160
+ 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 0xfd, 1, 0xff, 1, 0xff, 1, 0xff, 0xff, // 170
+ 0xff, 210, 1, 0xff, 1, 0xff, 206, 1, 0xff, 205, 205, 1, 0xff, 0xfe, 79, 202, // 180
+ 203, 1, 0xff, 205, 207, 0xff, 211, 209, 1, 0xff, 0xff, 0xfe, 211, 213, 0xff, 214, // 190
+ 1, 0xff, 1, 0xff, 1, 0xff, 218, 1, 0xff, 218, 0xfe, 0xfe, 1, 0xff, 218, 1, // 1a0
+ 0xff, 217, 217, 1, 0xff, 1, 0xff, 219, 1, 0xff, 0xfe, 0xfe, 1, 0xff, 0xfe, 0xff, // 1b0
+ 0xfe, 0xfe, 0xfe, 0xfe, 2, 0xff, 0xff, 2, 0xff, 0xff, 2, 0xff, 0xff, 1, 0xff, 1, // 1c0
+ 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 0xff, 1, 0xff, // 1d0
+ 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 1e0
+ 0xfe, 2, 0xff, 0xff, 1, 0xff, 0xfd, 0xfd, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 1f0
+ 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 200
+ 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 210
+ 0xfd, 0xfe, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, // 220
+ 1, 0xff, 1, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfd, 1, 0xff, 0xfd, 0xfd, 0xfe, // 230
+ 0xfe, 1, 0xff, 0xfd, 69, 71, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff, 1, 0xff}; // 240
+
+static const short wchar_tolower[] = {
+ 0x130, 0x069,
+ 0x178, 0x0ff,
+ 0x1f6, 0x195,
+ 0x1f7, 0x1bf,
+ 0x220, 0x19e,
+ 0x23a, 0x2c65,
+ 0x23d, 0x19a,
+ 0x23e, 0x2c66,
+ 0x243, 0x180,
+ 0,0 };
+
+static const short wchar_toupper[] = {
+ 0x0b5, 0x39c,
+ 0x0df, 0x0df,
+ 0x0ff, 0x178,
+ 0x131, 0x049,
+ 0x17f, 0x053,
+ 0x180, 0x243,
+ 0x195, 0x1f6,
+ 0x19a, 0x23d,
+ 0x19e, 0x220,
+ 0x1bf, 0x1f7,
+ 0x1c6, 0x1c4,
+ 0x1c9, 0x1c7,
+ 0x1cc, 0x1ca,
+ 0x1dd, 0x18e,
+ 0x1f3, 0x1f1,
+ 0,0 };
-// additional Latin characters beyond the Latin1 character set
-#define MAX_WALPHA 0x233
-// indexed by character - 0x100
-// 0=not alphabetic, 0xff=lower case, other=value to add to upper case to convert to lower case
-static unsigned char walpha_tab[MAX_WALPHA-0xff] = {
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 100
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 110
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 120
- 0xff,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, 1,0xff, 1,0xff, 1,0xff, 1, // 130
- 0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, 1,0xff, 1,0xff, 1,0xff, // 140
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 150
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 160
- 1,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, // 170
- 0xff, 210, 1,0xff, 1,0xff, 206, 1,0xff, 205, 205, 1,0xff,0xff, 79, 202, // 180
- 203, 1,0xff, 205, 207,0xff, 211, 209, 1,0xff,0xff,0xff, 211, 213,0xff, 214, // 190
- 1,0xff, 1,0xff, 1,0xff, 218, 1,0xff, 218,0xff,0xff, 1,0xff, 218, 1, // 1a0
- 0xff, 217, 217, 1,0xff, 1,0xff, 219, 1,0xff,0xff,0xff, 1,0xff,0xff,0xff, // 1b0
- 0xff,0xff,0xff,0xff, 2, 1,0xff, 2, 1,0xff, 2, 1,0xff, 1,0xff, 1, // 1c0
- 0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, 1,0xff, // 1d0
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 1e0
- 0xff, 2, 1,0xff, 1,0xff,0xff,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 1f0
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 200
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 210
- 0xff, 0, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 220
- 1,0xff, 1,0xff }; // 230
+
+#ifdef NEED_WCHAR_FUNCTIONS
// use ctype.h functions for Latin1 (character < 0x100)
int iswalpha(int c)
{
- if(c < 0x100)
+ if(c < 0x80)
return(isalpha(c));
if((c > 0x3040) && (c <= 0xa700))
return(1); // japanese, chinese characters
if(c > MAX_WALPHA)
return(0);
- return(walpha_tab[c-0x100]);
+ return(walpha_tab[c-0x80]);
}
int iswdigit(int c)
{
- if(c < 0x100)
+ if(c < 0x80)
return(isdigit(c));
return(0);
}
@@ -247,44 +314,67 @@ int iswalnum(int c)
int towlower(int c)
{
int x;
- if(c < 0x100)
+ int ix;
+
+ if(c < 0x80)
return(tolower(c));
- if((c > MAX_WALPHA) || ((x = walpha_tab[c-0x100])==0xff))
- return(c); // already lower case
+
+ if((c > MAX_WALPHA) || ((x = walpha_tab[c-0x80]) >= 0xfe))
+ return(c);
+
+ if(x == 0xfd)
+ {
+ // special cases, lookup translation table
+ for(ix=0; wchar_tolower[ix] != 0; ix+=2)
+ {
+ if(wchar_tolower[ix] == c)
+ return(wchar_tolower[ix+1]);
+ }
+ }
return(c + x); // convert to lower case
}
int towupper(int c)
{
- // check whether the previous character code is the upper-case equivalent of this character
- if(tolower(c-1) == c)
- return(c-1); // yes, use it
+ int ix;
+ // check whether a previous character code is the upper-case equivalent of this character
+ if(towlower(c-32) == c)
+ return(c-32); // yes, use it
+ if(towlower(c-1) == c)
+ return(c-1);
+ for(ix=0; wchar_toupper[ix] != 0; ix+=2)
+ {
+ if(wchar_toupper[ix] == c)
+ return(wchar_toupper[ix+1]);
+ }
return(c); // no
}
int iswupper(int c)
{
int x;
- if(c < 0x100)
+ if(c < 0x80)
return(isupper(c));
- if(((c > MAX_WALPHA) || (x = walpha_tab[c-0x100])==0) || (x == 0xff))
+ if(((c > MAX_WALPHA) || (x = walpha_tab[c-0x80])==0) || (x == 0xff))
return(0);
return(1);
}
int iswlower(int c)
{
- if(c < 0x100)
+ if(c < 0x80)
return(islower(c));
- if((c > MAX_WALPHA) || (walpha_tab[c-0x100] != 0xff))
+ if((c > MAX_WALPHA) || (walpha_tab[c-0x80] != 0xff))
return(0);
return(1);
}
int iswspace(int c)
{
- if(c < 0x100)
+ if(c < 0x80)
return(isspace(c));
+ if(c == 0xa0)
+ return(1);
return(0);
}
@@ -336,19 +426,105 @@ float wcstod(const wchar_t *str, wchar_t **tailptr)
}
#endif
+
+// use internal data for iswalpha up to U+024F
+// iswalpha() on Windows is unreliable (U+AA, U+BA).
+int iswalpha2(int c)
+{
+ if(c < 0x80)
+ return(isalpha(c));
+ if((c > 0x3040) && (c <= 0xa700))
+ return(1); // japanese, chinese characters
+ if(c > MAX_WALPHA)
+ return(iswalpha(c));
+ return(walpha_tab[c-0x80]);
+}
+
+int iswlower2(int c)
+{
+ if(c < 0x80)
+ return(islower(c));
+ if(c > MAX_WALPHA)
+ return(iswlower(c));
+ if(walpha_tab[c-0x80] == 0xff)
+ return(1);
+ return(0);
+}
+
+int iswupper2(int c)
+{
+ int x;
+ if(c < 0x80)
+ return(isupper(c));
+ if(c > MAX_WALPHA)
+ return(iswupper(c));
+ if(((x = walpha_tab[c-0x80]) > 0) && (x < 0xfe))
+ return(1);
+ return(0);
+}
+
int towlower2(unsigned int c)
{
+ int x;
+ int ix;
+
// check for non-standard upper to lower case conversions
if(c == 'I')
{
- if(translator->translator_name == L('t','r'))
+ if(translator->langopts.dotless_i)
{
c = 0x131; // I -> ı
}
}
- return(towlower(c));
+
+ if(c < 0x80)
+ return(tolower(c));
+
+ if(c > MAX_WALPHA)
+ return(towlower(c));
+
+ if((x = walpha_tab[c-0x80]) >= 0xfe)
+ return(c); // this is not an upper case letter
+
+ if(x == 0xfd)
+ {
+ // special cases, lookup translation table
+ for(ix=0; wchar_tolower[ix] != 0; ix+=2)
+ {
+ if(wchar_tolower[ix] == (int)c)
+ return(wchar_tolower[ix+1]);
+ }
+ }
+ return(c + x); // convert to lower case
+}
+
+int towupper2(unsigned int c)
+{
+ int ix;
+ if(c > MAX_WALPHA)
+ return(towupper(c));
+
+ // check whether a previous character code is the upper-case equivalent of this character
+ if(towlower2(c-32) == (int)c)
+ return(c-32); // yes, use it
+ if(towlower2(c-1) == (int)c)
+ return(c-1);
+ for(ix=0; wchar_toupper[ix] != 0; ix+=2)
+ {
+ if(wchar_toupper[ix] == (int)c)
+ return(wchar_toupper[ix+1]);
+ }
+ return(c); // no
}
+static int IsRomanU(unsigned int c)
+{//================================
+ if((c=='I') || (c=='V') || (c=='X') || (c=='L'))
+ return(1);
+ return(0);
+}
+
+
static void GetC_unget(int c)
{//==========================
// This is only called with UTF8 input, not wchar input
@@ -411,7 +587,7 @@ static int GetC_get(void)
end_of_input = 1;
return(0);
}
-
+
if(!end_of_input)
{
if(option_multibyte == espeakCHARS_16BIT)
@@ -438,10 +614,8 @@ static int GetC(void)
int cbuf[4];
int ix;
int n_bytes;
- unsigned char m;
static int ungot2 = 0;
static const unsigned char mask[4] = {0xff,0x1f,0x0f,0x07};
- static const unsigned char mask2[4] = {0,0x80,0x20,0x30};
if((c1 = ungot_char) != 0)
{
@@ -482,7 +656,6 @@ static int GetC(void)
if((ix = n_bytes) > 0)
{
c = c1 & mask[ix];
- m = mask2[ix];
while(ix > 0)
{
if((c2 = cbuf[ix] = GetC_get()) == 0)
@@ -501,7 +674,6 @@ static int GetC(void)
GetC_unget(c2);
break;
}
- m = 0x80;
c = (c << 6) + (c2 & 0x3f);
ix--;
}
@@ -530,8 +702,8 @@ static void UngetC(int c)
}
-static const char *WordToString2(unsigned int word)
-{//================================================
+const char *WordToString2(unsigned int word)
+{//============================================
// Convert a language mnemonic word into a string
int ix;
static char buf[5];
@@ -555,20 +727,20 @@ static const char *LookupSpecial(Translator *tr, const char *string, char* text_
char phonemes2[55];
char *string1 = (char *)string;
+ flags[0] = flags[1] = 0;
if(LookupDictList(tr,&string1,phonemes,flags,0,NULL))
{
- SetWordStress(tr, phonemes, &flags[0], -1, 0);
+ SetWordStress(tr, phonemes, flags, -1, 0);
DecodePhonemes(phonemes,phonemes2);
- sprintf(text_out,"[[%s]]",phonemes2);
- option_phoneme_input |= 2;
+ sprintf(text_out,"[\002%s]]",phonemes2);
return(text_out);
}
return(NULL);
}
-static const char *LookupCharName(Translator *tr, int c)
-{//=====================================================
+static const char *LookupCharName(Translator *tr, int c, int only)
+{//===============================================================
// Find the phoneme string (in ascii) to speak the name of character c
// Used for punctuation characters and symbols
@@ -589,20 +761,28 @@ static const char *LookupCharName(Translator *tr, int c)
ix = utf8_out(c,&single_letter[2]);
single_letter[2+ix]=0;
- string = &single_letter[1];
- if(LookupDictList(tr, &string, phonemes, flags, 0, NULL) == 0)
+ if(only)
{
- // try _* then *
string = &single_letter[2];
+ LookupDictList(tr, &string, phonemes, flags, 0, NULL);
+ }
+ else
+ {
+ string = &single_letter[1];
if(LookupDictList(tr, &string, phonemes, flags, 0, NULL) == 0)
{
- // now try the rules
- single_letter[1] = ' ';
- TranslateRules(tr, &single_letter[2], phonemes, sizeof(phonemes), NULL,0,NULL);
+ // try _* then *
+ string = &single_letter[2];
+ if(LookupDictList(tr, &string, phonemes, flags, 0, NULL) == 0)
+ {
+ // now try the rules
+ single_letter[1] = ' ';
+ TranslateRules(tr, &single_letter[2], phonemes, sizeof(phonemes), NULL,0,NULL);
+ }
}
}
- if((phonemes[0] == 0) && (tr->translator_name != L('e','n')))
+ if((only==0) && ((phonemes[0] == 0) || (phonemes[0] == phonSWITCH)) && (tr->translator_name != L('e','n')))
{
// not found, try English
SetTranslator2("en");
@@ -627,23 +807,22 @@ static const char *LookupCharName(Translator *tr, int c)
{
if(lang_name)
{
- SetWordStress(translator2, phonemes, &flags[0], -1, 0);
+ SetWordStress(translator2, phonemes, flags, -1, 0);
DecodePhonemes(phonemes,phonemes2);
- sprintf(buf,"[[_^_%s %s _^_%s]]","en",phonemes2,WordToString2(tr->translator_name));
+ sprintf(buf,"[\002_^_%s %s _^_%s]]","en",phonemes2,WordToString2(tr->translator_name));
SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
}
else
{
- SetWordStress(tr, phonemes, &flags[0], -1, 0);
+ SetWordStress(tr, phonemes, flags, -1, 0);
DecodePhonemes(phonemes,phonemes2);
- sprintf(buf,"[[%s]] ",phonemes2);
+ sprintf(buf,"[\002%s]] ",phonemes2);
}
- option_phoneme_input |= 2;
}
else
+ if(only == 0)
{
- strcpy(buf,"[[(X1)(X1)(X1)]]");
- option_phoneme_input |= 2;
+ strcpy(buf,"[\002(X1)(X1)(X1)]]");
}
return(buf);
@@ -691,12 +870,13 @@ static int LoadSoundFile(const char *fname, int index)
}
f = NULL;
+
+#ifndef _WIN32
#ifdef PLATFORM_POSIX
if((f = fopen(fname,"rb")) != NULL)
{
int ix;
int fd_temp;
- const char *resample;
int header[3];
char command[sizeof(fname2)+sizeof(fname2)+40];
@@ -710,17 +890,11 @@ static int LoadSoundFile(const char *fname, int index)
fclose(f);
f = NULL;
- if(header[2] == samplerate)
- resample = "";
- else
- resample = "polyphase";
-
strcpy(fname_temp,"/tmp/espeakXXXXXX");
if((fd_temp = mkstemp(fname_temp)) >= 0)
{
close(fd_temp);
-// sprintf(fname_temp,"%s.wav",tmpnam(NULL));
- sprintf(command,"sox \"%s\" -r %d -w -s -c1 %s %s\n", fname, samplerate, fname_temp, resample);
+ sprintf(command,"sox \"%s\" -r %d -c1 -t wav %s\n", fname, samplerate, fname_temp);
if(system(command) == 0)
{
fname = fname_temp;
@@ -729,13 +903,14 @@ static int LoadSoundFile(const char *fname, int index)
}
}
#endif
+#endif
if(f == NULL)
{
f = fopen(fname,"rb");
if(f == NULL)
{
- fprintf(stderr,"Can't read temp file: %s\n",fname);
+// fprintf(stderr,"Can't read temp file: %s\n",fname);
return(3);
}
}
@@ -747,9 +922,9 @@ static int LoadSoundFile(const char *fname, int index)
fclose(f);
return(4);
}
- fread(p,length,1,f);
+ length = fread(p,1,length,f);
fclose(f);
-#if 0
+#ifndef _WIN32
remove(fname_temp);
#endif
@@ -810,57 +985,92 @@ static int LoadSoundFile2(const char *fname)
-static int AnnouncePunctuation(Translator *tr, int c1, int c2, char *buf, int bufix)
-{//=================================================================================
+static int AnnouncePunctuation(Translator *tr, int c1, int *c2_ptr, char *output, int *bufix, int end_clause)
+{//=============================================================================================================
// announce punctuation names
// c1: the punctuation character
// c2: the following character
int punct_count;
- const char *punctname;
- int found = 0;
+ const char *punctname = NULL;
int soundicon;
- char *p;
+ int attributes;
+ int short_pause;
+ int c2;
+ int len;
+ int bufix1;
+ char buf[200];
+ char buf2[80];
+ char ph_buf[30];
+
+ c2 = *c2_ptr;
+ buf[0] = 0;
if((soundicon = LookupSoundicon(c1)) >= 0)
{
// add an embedded command to play the soundicon
- sprintf(&buf[bufix],"\001%dI ",soundicon);
+ sprintf(buf,"\001%dI ",soundicon);
UngetC(c2);
- found = 1;
}
else
- if((punctname = LookupCharName(tr, c1)) != NULL)
{
- found = 1;
- if(bufix==0)
+ if((c1 == '.') && (end_clause) && (c2 != '.'))
+ {
+ if(LookupSpecial(tr, "_.p", ph_buf))
+ {
+ punctname = ph_buf; // use word for 'period' instead of 'dot'
+ }
+ }
+ if(punctname == NULL)
+ {
+ punctname = LookupCharName(tr, c1, 0);
+ }
+
+ if(punctname == NULL)
+ return(-1);
+
+ if((*bufix==0) || (end_clause ==0) || (tr->langopts.param[LOPT_ANNOUNCE_PUNCT] & 2))
{
punct_count=1;
- while(c2 == c1)
+ while((c2 == c1) && (c1 != '<')) // don't eat extra '<', it can miss XML tags
{
punct_count++;
c2 = GetC();
}
- UngetC(c2);
+ *c2_ptr = c2;
+ if(end_clause)
+ {
+ UngetC(c2);
+ }
- p = &buf[bufix];
if(punct_count==1)
{
- sprintf(p,"%s %s %s",tone_punct_on,punctname,tone_punct_off);
+// sprintf(buf,"%s %s %s",tone_punct_on,punctname,tone_punct_off);
+ sprintf(buf," %s",punctname); // we need the space before punctname, to ensure it doesn't merge with the previous word (eg. "2.-a")
}
else
if(punct_count < 4)
{
- sprintf(p,"\001+10S%s",tone_punct_on);
+ buf[0] = 0;
+ if(embedded_value[EMBED_S] < 300)
+ sprintf(buf,"\001+10S"); // Speak punctuation name faster, unless we are already speaking fast. It would upset Sonic SpeedUp
+
while(punct_count-- > 0)
- sprintf(buf,"%s %s",buf,punctname);
- sprintf(p,"%s %s\001-10S",buf,tone_punct_off);
+ {
+ sprintf(buf2," %s",punctname);
+ strcat(buf, buf2);
+ }
+
+ if(embedded_value[EMBED_S] < 300)
+ {
+ sprintf(buf2," \001-10S");
+ strcat(buf, buf2);
+ }
}
else
{
- sprintf(p,"%s %s %d %s %s",
- tone_punct_on,punctname,punct_count,punctname,tone_punct_off);
- return(CLAUSE_COMMA);
+ sprintf(buf," %s %d %s",
+ punctname,punct_count,punctname);
}
}
else
@@ -873,24 +1083,39 @@ static int AnnouncePunctuation(Translator *tr, int c1, int c2, char *buf, int bu
ssml_ignore_l_angle = c1; // this was &lt; which was converted to <, don't pick it up again as <
}
ungot_char2 = c1;
- buf[bufix] = ' ';
- buf[bufix+1] = 0;
+ buf[0] = ' ';
+ buf[1] = 0;
}
}
- if(found == 0)
+ bufix1 = *bufix;
+ len = strlen(buf);
+ strcpy(&output[*bufix],buf);
+ *bufix += len;
+
+ if(end_clause==0)
return(-1);
if(c1 == '-')
return(CLAUSE_NONE); // no pause
- if(bufix > 0)
- return(CLAUSE_SHORTCOMMA);
- if((strchr_w(punct_close,c1) != NULL) && !iswalnum(c2))
- return(CLAUSE_SHORTFALL+4);
- if(iswspace(c2) && strchr_w(punct_stop,c1)!=NULL)
- return(punct_attributes[lookupwchar(punct_chars,c1)]);
-
- return(CLAUSE_SHORTCOMMA);
+
+ attributes = punct_attributes[lookupwchar(punct_chars,c1)];
+
+ short_pause = CLAUSE_SHORTFALL;
+ if((attributes & CLAUSE_BITS_INTONATION) == 0x1000)
+ short_pause = CLAUSE_SHORTCOMMA;
+
+ if((bufix1 > 0) && !(tr->langopts.param[LOPT_ANNOUNCE_PUNCT] & 2))
+ {
+ if((attributes & ~0x8000) == CLAUSE_SEMICOLON)
+ return(CLAUSE_SHORTFALL);
+ return(short_pause);
+ }
+
+ if(attributes & CLAUSE_BIT_SENTENCE)
+ return(attributes);
+
+ return(short_pause);
} // end of AnnouncePunctuation
#define SSML_SPEAK 1
@@ -908,10 +1133,11 @@ static int AnnouncePunctuation(Translator *tr, int c1, int c2, char *buf, int bu
#define SSML_BREAK 13
#define SSML_IGNORE_TEXT 14
#define HTML_BREAK 15
-#define SSML_CLOSE 0x10 // for a closing tag, OR this with the tag type
+#define HTML_NOSPACE 16 // don't insert a space for this element, so it doesn't break a word
+#define SSML_CLOSE 0x20 // for a closing tag, OR this with the tag type
// these tags have no effect if they are self-closing, eg. <voice />
-static char ignore_if_self_closing[] = {0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0};
+static char ignore_if_self_closing[] = {0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,0,0};
static MNEM_TAB ssmltags[] = {
@@ -932,6 +1158,7 @@ static MNEM_TAB ssmltags[] = {
{"br", HTML_BREAK},
{"li", HTML_BREAK},
+ {"dd", HTML_BREAK},
{"img", HTML_BREAK},
{"td", HTML_BREAK},
{"h1", SSML_PARAGRAPH},
@@ -941,29 +1168,37 @@ static MNEM_TAB ssmltags[] = {
{"hr", SSML_PARAGRAPH},
{"script", SSML_IGNORE_TEXT},
{"style", SSML_IGNORE_TEXT},
+ {"font", HTML_NOSPACE},
+ {"b", HTML_NOSPACE},
+ {"i", HTML_NOSPACE},
+ {"strong", HTML_NOSPACE},
+ {"em", HTML_NOSPACE},
+ {"code", HTML_NOSPACE},
{NULL,0}};
-static const char *VoiceFromStack()
+static const char *VoiceFromStack(void)
{//================================
// Use the voice properties from the SSML stack to choose a voice, and switch
// to that voice if it's not the current voice
int ix;
+ const char *p;
SSML_STACK *sp;
const char *v_id;
int voice_name_specified;
int voice_found;
espeak_VOICE voice_select;
- char voice_name[40];
+ static char voice_name[40];
char language[40];
+ char buf[80];
strcpy(voice_name,ssml_stack[0].voice_name);
strcpy(language,ssml_stack[0].language);
voice_select.age = ssml_stack[0].voice_age;
voice_select.gender = ssml_stack[0].voice_gender;
- voice_select.variant = ssml_stack[0].voice_variant;
+ voice_select.variant = ssml_stack[0].voice_variant_number;
voice_select.identifier = NULL;
for(ix=0; ix<n_ssml_stack; ix++)
@@ -983,15 +1218,32 @@ static const char *VoiceFromStack()
if(sp->language[0] != 0)
{
strcpy(language, sp->language);
+
+ // is this language provided by the base voice?
+ p = base_voice.languages;
+ while(*p++ != 0)
+ {
+ if(strcmp(p, language) == 0)
+ {
+ // yes, change the language to the main language of the base voice
+ strcpy(language, &base_voice.languages[1]);
+ break;
+ }
+ p += (strlen(p) + 1);
+ }
+
if(voice_name_specified == 0)
voice_name[0] = 0; // forget a previous voice name if a language is specified
}
if(sp->voice_gender != 0)
+ {
voice_select.gender = sp->voice_gender;
+ }
+
if(sp->voice_age != 0)
voice_select.age = sp->voice_age;
- if(sp->voice_variant != 0)
- voice_select.variant = sp->voice_variant;
+ if(sp->voice_variant_number != 0)
+ voice_select.variant = sp->voice_variant_number;
}
voice_select.name = voice_name;
@@ -999,6 +1251,14 @@ static const char *VoiceFromStack()
v_id = SelectVoice(&voice_select, &voice_found);
if(v_id == NULL)
return("default");
+
+ if((strchr(v_id, '+') == NULL) && ((voice_select.gender == 0) || (voice_select.gender == base_voice.gender)) && (base_voice_variant_name[0] != 0))
+ {
+ // a voice variant has not been selected, use the original voice variant
+ sprintf(buf, "%s+%s", v_id, base_voice_variant_name);
+ strncpy0(voice_name, buf, sizeof(voice_name));
+ return(voice_name);
+ }
return(v_id);
} // end of VoiceFromStack
@@ -1012,7 +1272,7 @@ static void ProcessParamStack(char *outbuf, int *outix)
int value;
char buf[20];
int new_parameters[N_SPEECH_PARAM];
- static char cmd_letter[N_SPEECH_PARAM] = {0, 'S','A','P','R', 0, 0, 0, 0, 0, 0, 0, 'F'}; // embedded command letters
+ static char cmd_letter[N_SPEECH_PARAM] = {0, 'S','A','P','R', 0, 'C', 0, 0, 0, 0, 0, 'F'}; // embedded command letters
for(param=0; param<N_SPEECH_PARAM; param++)
@@ -1054,7 +1314,7 @@ static void ProcessParamStack(char *outbuf, int *outix)
speech_parameters[param] = new_parameters[param];
strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
+ *outix += strlen(buf);
}
}
} // end of ProcessParamStack
@@ -1126,7 +1386,7 @@ static wchar_t *GetSsmlAttribute(wchar_t *pw, const char *name)
while(iswspace(*pw)) pw++;
if(*pw == '=') pw++;
while(iswspace(*pw)) pw++;
- if(*pw == '"')
+ if((*pw == '"') || (*pw == '\'')) // allow single-quotes ?
return(pw+1);
else
return(empty);
@@ -1141,14 +1401,14 @@ static wchar_t *GetSsmlAttribute(wchar_t *pw, const char *name)
static int attrcmp(const wchar_t *string1, const char *string2)
{//============================================================
int ix;
-
+
if(string1 == NULL)
return(1);
for(ix=0; (string1[ix] == string2[ix]) && (string1[ix] != 0); ix++)
{
}
- if((string1[ix]=='"') && (string2[ix]==0))
+ if(((string1[ix]=='"') || (string1[ix]=='\'')) && (string2[ix]==0))
return(0);
return(1);
}
@@ -1171,10 +1431,10 @@ static int attrnumber(const wchar_t *pw, int default_value, int type)
{//==================================================================
int value = 0;
- if((pw == NULL) || !isdigit(*pw))
+ if((pw == NULL) || !IsDigit09(*pw))
return(default_value);
- while(isdigit(*pw))
+ while(IsDigit09(*pw))
{
value = value*10 + *pw++ - '0';
}
@@ -1217,7 +1477,7 @@ static int attr_prosody_value(int param_type, const wchar_t *pw, int *value_out)
{//=============================================================================
int sign = 0;
wchar_t *tail;
- float value;
+ double value;
while(iswspace(*pw)) pw++;
if(*pw == '+')
@@ -1227,10 +1487,10 @@ static int attr_prosody_value(int param_type, const wchar_t *pw, int *value_out)
}
if(*pw == '-')
{
- pw++;
+ pw++;
sign = -1;
}
- value = (float)wcstod(pw,&tail);
+ value = (double)wcstod(pw,&tail);
if(tail == pw)
{
// failed to find a number, return 100%
@@ -1248,16 +1508,23 @@ static int attr_prosody_value(int param_type, const wchar_t *pw, int *value_out)
if((tail[0]=='s') && (tail[1]=='t'))
{
+#ifdef PLATFORM_RISCOS
+ *value_out = 100;
+#else
double x;
// convert from semitones to a frequency percentage
- x = pow(double(2.0),double((value*sign)/12)) * 100;
+ x = pow((double)2.0,(double)((value*sign)/12)) * 100;
*value_out = (int)x;
+#endif
return(2); // percentage
}
if(param_type == espeakRATE)
{
- *value_out = (int)(value * 100);
+ if(sign == 0)
+ *value_out = (int)(value * 100);
+ else
+ *value_out = 100 + (int)(sign * value * 100);
return(2); // percentage
}
@@ -1266,7 +1533,7 @@ static int attr_prosody_value(int param_type, const wchar_t *pw, int *value_out)
} // end of attr_prosody_value
-int AddNameData(const char *name, int wide)
+static int AddNameData(const char *name, int wide)
{//========================================
// Add the name to the namedata and return its position
// (Used by the Windows SAPI wrapper)
@@ -1287,11 +1554,12 @@ int AddNameData(const char *name, int wide)
if(namedata_ix+len >= n_namedata)
{
// allocate more space for marker names
- if((vp = realloc(namedata, namedata_ix+len + 300)) == NULL)
+ if((vp = realloc(namedata, namedata_ix+len + 1000)) == NULL)
return(-1); // failed to allocate, original data is unchanged but ignore this new name
+// !!! Bug?? If the allocated data shifts position, then pointers given to user application will be invalid
namedata = (char *)vp;
- n_namedata = namedata_ix+len + 300;
+ n_namedata = namedata_ix+len + 1000;
}
memcpy(&namedata[ix = namedata_ix],name,len);
namedata_ix += len;
@@ -1299,8 +1567,8 @@ int AddNameData(const char *name, int wide)
} // end of AddNameData
-void SetVoiceStack(espeak_VOICE *v)
-{//================================
+void SetVoiceStack(espeak_VOICE *v, const char *variant_name)
+{//==========================================================
SSML_STACK *sp;
sp = &ssml_stack[0];
@@ -1312,10 +1580,15 @@ void SetVoiceStack(espeak_VOICE *v)
if(v->languages != NULL)
strcpy(sp->language,v->languages);
if(v->name != NULL)
- strcpy(sp->voice_name,v->name);
- sp->voice_variant = v->variant;
+ strncpy0(sp->voice_name, v->name, sizeof(sp->voice_name));
+ sp->voice_variant_number = v->variant;
sp->voice_age = v->age;
sp->voice_gender = v->gender;
+
+ if(memcmp(variant_name, "!v", 2) == 0)
+ variant_name += 3;// strip variant directory name, !v plus PATHSEP
+ strncpy0(base_voice_variant_name, variant_name, sizeof(base_voice_variant_name));
+ memcpy(&base_voice, &current_voice_selected, sizeof(base_voice));
}
@@ -1332,6 +1605,7 @@ static int GetVoiceAttributes(wchar_t *pw, int tag_type)
wchar_t *name;
wchar_t *age;
wchar_t *variant;
+ int value;
const char *new_voice_id;
SSML_STACK *ssml_sp;
@@ -1369,15 +1643,17 @@ static int GetVoiceAttributes(wchar_t *pw, int tag_type)
age = GetSsmlAttribute(pw,"age");
gender = GetSsmlAttribute(pw,"gender");
}
-
+
if((tag_type != SSML_VOICE) && (lang==NULL))
return(0); // <s> or <p> without language spec, nothing to do
-
+
ssml_sp = &ssml_stack[n_ssml_stack++];
attrcopy_utf8(ssml_sp->language,lang,sizeof(ssml_sp->language));
attrcopy_utf8(ssml_sp->voice_name,name,sizeof(ssml_sp->voice_name));
- ssml_sp->voice_variant = attrnumber(variant,1,0)-1;
+ if((value = attrnumber(variant,1,0)) > 0)
+ value--; // variant='0' and variant='1' the same
+ ssml_sp->voice_variant_number = value;
ssml_sp->voice_age = attrnumber(age,0,0);
ssml_sp->voice_gender = attrlookup(gender,mnem_gender);
ssml_sp->tag_type = tag_type;
@@ -1415,8 +1691,8 @@ static void SetProsodyParameter(int param_type, wchar_t *attr1, PARAM_STACK *sp)
{"x-slow",60},
{"slow",80},
{"medium",100},
- {"fast",120},
- {"x-fast",150},
+ {"fast",125},
+ {"x-fast",160},
{NULL, -1}};
static const MNEM_TAB mnem_pitch[] = {
@@ -1467,6 +1743,31 @@ static void SetProsodyParameter(int param_type, wchar_t *attr1, PARAM_STACK *sp)
} // end of SetProsodyParemeter
+static int ReplaceKeyName(char *outbuf, int index, int *outix)
+{//===========================================================
+// Replace some key-names by single characters, so they can be pronounced in different languages
+ static MNEM_TAB keynames[] = {
+ {"space ",0xe020},
+ {"tab ", 0xe009},
+ {"underscore ", 0xe05f},
+ {"double-quote ", '"'},
+ {NULL, 0}};
+
+ int ix;
+ int letter;
+ char *p;
+
+ p = &outbuf[index];
+
+ if((letter = LookupMnem(keynames, p)) != 0)
+ {
+ ix = utf8_out(letter, p);
+ *outix = index + ix;
+ return(letter);
+ }
+ return(0);
+}
+
static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outbuf, int self_closing)
{//==================================================================================================
@@ -1483,7 +1784,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
int voice_change_flag;
wchar_t *px;
wchar_t *attr1;
- wchar_t *attr2;
+ wchar_t *attr2;
wchar_t *attr3;
int terminator;
char *uri;
@@ -1532,6 +1833,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
{"reduced",2},
{"moderate",3},
{"strong",4},
+ {"x-strong",5},
{NULL,-1}};
static const char *prosody_attr[5] = {
@@ -1546,19 +1848,29 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
tag_name[ix] = 0;
px = &xml_buf[ix]; // the tag's attributes
-
+
if(tag_name[0] == '/')
{
- tag_type = LookupMnem(ssmltags,&tag_name[1]) + SSML_CLOSE; // closing tag
+ // closing tag
+ if((tag_type = LookupMnem(ssmltags,&tag_name[1])) != HTML_NOSPACE)
+ {
+ outbuf[(*outix)++] = ' ';
+ }
+ tag_type += SSML_CLOSE;
}
else
{
- tag_type = LookupMnem(ssmltags,tag_name);
+ if((tag_type = LookupMnem(ssmltags,tag_name)) != HTML_NOSPACE)
+ {
+ // separate SSML tags from the previous word (but not HMTL tags such as <b> <font> which can occur inside a word)
+ outbuf[(*outix)++] = ' ';
+ }
if(self_closing && ignore_if_self_closing[tag_type])
return(0);
}
+
voice_change_flag = 0;
terminator = CLAUSE_NONE;
ssml_sp = &ssml_stack[n_ssml_stack-1];
@@ -1610,14 +1922,16 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
if(translator->langopts.tone_language == 1)
{
- static unsigned char emphasis_to_pitch_range[] = {50,50,40,70,90,90};
- static unsigned char emphasis_to_volume[] = {100,100,70,110,140,140};
+ static unsigned char emphasis_to_pitch_range[] = {50,50,40,70,90,100};
+ static unsigned char emphasis_to_volume[] = {100,100,70,110,135,150};
// tone language (eg.Chinese) do emphasis by increasing the pitch range.
sp->parameter[espeakRANGE] = emphasis_to_pitch_range[value];
sp->parameter[espeakVOLUME] = emphasis_to_volume[value];
}
else
{
+ static unsigned char emphasis_to_volume2[] = {100,100,75,100,120,150};
+ sp->parameter[espeakVOLUME] = emphasis_to_volume2[value];
sp->parameter[espeakEMPHASIS] = value;
}
ProcessParamStack(outbuf, outix);
@@ -1650,12 +1964,19 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
sprintf(buf,"%c%dY",CTRL_EMBEDDED,value);
strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
+ *outix += strlen(buf);
+ sayas_start = *outix;
sayas_mode = value; // punctuation doesn't end clause during SAY-AS
break;
case SSML_SAYAS + SSML_CLOSE:
+ if(sayas_mode == SAYAS_KEY)
+ {
+ outbuf[*outix] = 0;
+ ReplaceKeyName(outbuf, sayas_start, outix);
+ }
+
outbuf[(*outix)++] = CTRL_EMBEDDED;
outbuf[(*outix)++] = 'Y';
sayas_mode = 0;
@@ -1666,7 +1987,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
{
// use the alias rather than the text
ignore_text = 1;
- (*outix) += attrcopy_utf8(&outbuf[*outix],attr1,n_outbuf-*outix);
+ *outix += attrcopy_utf8(&outbuf[*outix],attr1,n_outbuf-*outix);
}
break;
@@ -1697,7 +2018,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
{
sprintf(buf,"%c%dM",CTRL_EMBEDDED,index);
strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
+ *outix += strlen(buf);
}
}
break;
@@ -1725,7 +2046,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
{
sprintf(buf,"%c%dI",CTRL_EMBEDDED,index);
strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
+ *outix += strlen(buf);
sp->parameter[espeakSILENCE] = 1;
}
}
@@ -1738,7 +2059,7 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
{
sprintf(buf,"%c%dU",CTRL_EMBEDDED,index);
strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
+ *outix += strlen(buf);
sp->parameter[espeakSILENCE] = 1;
}
}
@@ -1748,10 +2069,13 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
if(self_closing)
PopParamStack(tag_type, outbuf, outix);
+ else
+ audio_text = 1;
return(CLAUSE_NONE);
case SSML_AUDIO + SSML_CLOSE:
PopParamStack(tag_type, outbuf, outix);
+ audio_text = 0;
return(CLAUSE_NONE);
case SSML_BREAK:
@@ -1766,14 +2090,20 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
{
// adjust prepause on the following word
sprintf(&outbuf[*outix],"%c%dB",CTRL_EMBEDDED,value);
- (*outix) += 3;
+ *outix += 3;
terminator = 0;
}
value = break_value[value];
}
if((attr2 = GetSsmlAttribute(px,"time")) != NULL)
{
- value = (attrnumber(attr2,0,1) * 25) / speed.speed_factor1; // compensate for speaking speed to keep constant pause length
+ value2 = attrnumber(attr2,0,1); // pause in mS
+
+ // compensate for speaking speed to keep constant pause length, see function PauseLength()
+ // 'value' here is x 10mS
+ value = (value2 * 256) / (speed.clause_pause_factor * 10);
+ if(value < 200)
+ value = (value2 * 256) / (speed.pause_factor * 10);
if(terminator == 0)
terminator = CLAUSE_NONE;
@@ -1781,7 +2111,13 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
if(terminator)
{
if(value > 0xfff)
- value = 0xfff;
+ {
+ // scale down the value and set a scaling indicator bit
+ value = value / 32;
+ if(value > 0xfff)
+ value = 0xfff;
+ terminator |= CLAUSE_PAUSE_LONG;
+ }
return(terminator + value);
}
break;
@@ -1873,9 +2209,18 @@ terminator=0; // ?? Sentence intonation, but no pause ??
} // end of ProcessSsmlTag
+static void RemoveChar(char *p)
+{//=======================
+// Replace a UTF-8 character by spaces
+ int c;
+
+ memset(p, ' ', utf8_in(&c, p));
+} // end of RemoveChar
+
+
static MNEM_TAB xml_char_mnemonics[] = {
{"gt",'>'},
- {"lt",'<'},
+ {"lt", 0xe000 + '<'}, // private usage area, to avoid confusion with XML tag
{"amp", '&'},
{"quot", '"'},
{"nbsp", ' '},
@@ -1883,8 +2228,8 @@ static MNEM_TAB xml_char_mnemonics[] = {
{NULL,-1}};
-int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type)
-{//=============================================================================================================
+int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change)
+{//=================================================================================================================================
/* Find the end of the current clause.
Write the clause into buf
@@ -1899,6 +2244,8 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
int c1=' '; // current character
int c2; // next character
int cprev=' '; // previous character
+ int cprev2=' ';
+ int c_next;
int parag;
int ix = 0;
int j;
@@ -1911,9 +2258,12 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
int found;
int any_alnum = 0;
int self_closing;
- int punct_data;
+ int punct_data = 0;
+ int is_end_clause;
+ int announced_punctuation = 0;
int stressed_word = 0;
- const char *p;
+ int end_clause_after_tag = 0;
+ int end_clause_index = 0;
wchar_t xml_buf[N_XML_BUF+1];
#define N_XML_BUF2 20
@@ -1927,10 +2277,12 @@ int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix
clear_skipping_text = 0;
}
+ tr->phonemes_repeat_count = 0;
tr->clause_upper_count = 0;
tr->clause_lower_count = 0;
end_of_input = 0;
*tone_type = 0;
+ *voice_change = 0;
f_input = f_in; // for GetC etc
@@ -1960,7 +2312,7 @@ f_input = f_in; // for GetC etc
return(CLAUSE_EOF);
}
- if((skip_characters > 0) && (count_characters > skip_characters))
+ if((skip_characters > 0) && (count_characters >= skip_characters))
{
// reached the specified start position
// don't break a word
@@ -1971,6 +2323,7 @@ f_input = f_in; // for GetC etc
}
}
+ cprev2 = cprev;
cprev = c1;
c1 = c2;
@@ -2064,8 +2417,19 @@ f_input = f_in; // for GetC etc
c2 = ' ';
}
else
- if((c2 == '/') || iswalpha(c2))
+ if((c2 == '/') || iswalpha2(c2))
{
+ // check for space in the output buffer for embedded commands produced by the SSML tag
+ if(ix > (n_buf - 20))
+ {
+ // Perhaps not enough room, end the clause before the SSML tag
+ UngetC(c2);
+ ungot_char2 = c1;
+ buf[ix] = ' ';
+ buf[ix+1] = 0;
+ return(CLAUSE_NONE);
+ }
+
// SSML Tag
n_xml_buf = 0;
c1 = c2;
@@ -2076,9 +2440,7 @@ f_input = f_in; // for GetC etc
}
xml_buf[n_xml_buf] = 0;
c2 = ' ';
-
- buf[ix++] = ' ';
-
+
self_closing = 0;
if(xml_buf[n_xml_buf-1] == '/')
{
@@ -2086,26 +2448,25 @@ f_input = f_in; // for GetC etc
xml_buf[n_xml_buf-1] = ' ';
self_closing = 1;
}
-
- terminator = ProcessSsmlTag(xml_buf,buf,ix,n_buf,self_closing);
-
+
+ terminator = ProcessSsmlTag(xml_buf,buf,&ix,n_buf,self_closing);
+
if(terminator != 0)
{
+ if(end_clause_after_tag)
+ ix = end_clause_index;
+
buf[ix] = ' ';
buf[ix++] = 0;
-
+
if(terminator & CLAUSE_BIT_VOICE)
{
- // a change in voice, write the new voice name to the end of the buf
- p = current_voice_id;
- while((*p != 0) && (ix < (n_buf-1)))
- {
- buf[ix++] = *p++;
- }
- buf[ix++] = 0;
+ strcpy(voice_change, current_voice_id);
}
return(terminator);
}
+ c1 = ' ';
+ c2 = GetC();
continue;
}
}
@@ -2180,6 +2541,16 @@ f_input = f_in; // for GetC etc
linelength++;
+ if((j = lookupwchar2(tr->chars_ignore,c1)) != 0)
+ {
+ if(j == 1)
+ {
+ // ignore this character (eg. zero-width-non-joiner U+200C)
+ continue;
+ }
+ c1 = j; // replace the character
+ }
+
if(iswalnum(c1))
any_alnum = 1;
else
@@ -2192,10 +2563,13 @@ f_input = f_in; // for GetC etc
c2 = ' ';
}
+ if(c1 == 0xf0b)
+ c1 = ' '; // Tibet inter-syllabic mark, ?? replace by space ??
+
if(iswspace(c1))
{
char *p_word;
-
+
if(tr->translator_name == 0x6a626f)
{
// language jbo : lojban
@@ -2215,18 +2589,27 @@ f_input = f_in; // for GetC etc
}
}
}
+
+ if(c1 == 0xd4d)
+ {
+ // Malayalam virama, check if next character is Zero-width-joiner
+ if(c2 == 0x200d)
+ {
+ c1 = 0xd4e; // use this unofficial code for chillu-virama
+ }
+ }
}
- if(iswupper(c1))
+ if(iswupper2(c1))
{
tr->clause_upper_count++;
- if((option_capitals == 2) && (sayas_mode == 0) && !iswupper(cprev))
+ if((option_capitals == 2) && (sayas_mode == 0) && !iswupper2(cprev))
{
char text_buf[40];
char text_buf2[30];
if(LookupSpecial(tr, "_cap", text_buf2) != NULL)
{
- sprintf(text_buf,"%s%s%s",tone_punct_on,text_buf2,tone_punct_off);
+ sprintf(text_buf,"%s",text_buf2);
j = strlen(text_buf);
if((ix + j) < n_buf)
{
@@ -2237,7 +2620,7 @@ f_input = f_in; // for GetC etc
}
}
else
- if(iswalpha(c1))
+ if(iswalpha2(c1))
tr->clause_lower_count++;
if(option_phoneme_input)
@@ -2268,6 +2651,10 @@ f_input = f_in; // for GetC etc
// 2nd newline, assume paragraph
UngetC(c2);
+ if(end_clause_after_tag)
+ {
+ RemoveChar(&buf[end_clause_index]); // delete clause-end punctiation
+ }
buf[ix] = ' ';
buf[ix+1] = 0;
if(parag > 3)
@@ -2288,88 +2675,231 @@ if(option_ssml) parag=1;
linelength = 0;
}
- if(option_punctuation && (phoneme_mode==0) && (sayas_mode==0) && iswpunct(c1))
+ announced_punctuation = 0;
+
+ if((phoneme_mode==0) && (sayas_mode==0))
{
- // option is set to explicitly speak punctuation characters
- // if a list of allowed punctuation has been set up, check whether the character is in it
- if((option_punctuation == 1) || (wcschr(option_punctlist,c1) != NULL))
+ is_end_clause = 0;
+
+ if(end_clause_after_tag)
{
- if((terminator = AnnouncePunctuation(tr, c1, c2, buf, ix)) >= 0)
- return(terminator);
+ // Because of an xml tag, we are waiting for the
+ // next non-blank character to decide whether to end the clause
+ // i.e. is dot followed by an upper-case letter?
+
+ if(!iswspace(c1))
+ {
+ if(!IsAlpha(c1) || !iswlower2(c1))
+// if(iswdigit(c1) || (IsAlpha(c1) && !iswlower2(c1)))
+ {
+ UngetC(c2);
+ ungot_char2 = c1;
+ buf[end_clause_index] = ' '; // delete the end-clause punctuation
+ buf[end_clause_index+1] = 0;
+ return(end_clause_after_tag);
+ }
+ end_clause_after_tag = 0;
+ }
}
- }
- if((phoneme_mode==0) && (sayas_mode==0) && ((punct = lookupwchar(punct_chars,c1)) != 0))
- {
- punct_data = punct_attributes[punct];
+ if((c1 == '.') && (c2 == '.'))
+ {
+ while((c_next = GetC()) == '.')
+ {
+ // 3 or more dots, replace by elipsis
+ c1 = 0x2026;
+ c2 = ' ';
+ }
+ if(c1 == 0x2026)
+ c2 = c_next;
+ else
+ UngetC(c_next);
+ }
- if(punct_data & PUNCT_IN_WORD)
+ punct_data = 0;
+ if((punct = lookupwchar(punct_chars,c1)) != 0)
{
- // Armenian punctuation inside a word
- stressed_word = 1;
- *tone_type = punct_data >> 12 & 0xf; // override the end-of-sentence type
- continue;
+ punct_data = punct_attributes[punct];
+
+ if(punct_data & PUNCT_IN_WORD)
+ {
+ // Armenian punctuation inside a word
+ stressed_word = 1;
+ *tone_type = punct_data >> 12 & 0xf; // override the end-of-sentence type
+ continue;
+ }
+
+ if((iswspace(c2) || (punct_data & 0x8000) || IsBracket(c2) || (c2=='?') || Eof() || (c2 == ctrl_embedded))) // don't check for '-' because it prevents recognizing ':-)'
+// if((iswspace(c2) || (punct_data & 0x8000) || IsBracket(c2) || (c2=='?') || (c2=='-') || Eof()))
+ {
+ // note: (c2='?') is for when a smart-quote has been replaced by '?'
+ is_end_clause = 1;
+ }
}
- if((iswspace(c2) || (punct_data & 0x8000) || IsBracket(c2) || (c2=='?') || (c2=='-') || Eof()))
+ // don't announce punctuation for the alternative text inside inside <audio> ... </audio>
+ if(c1 == 0xe000+'<') c1 = '<';
+ if(option_punctuation && iswpunct(c1) && (audio_text == 0))
{
- // note: (c2='?') is for when a smart-quote has been replaced by '?'
- buf[ix] = ' ';
- buf[ix+1] = 0;
-
- if((c1 == '.') && (cprev == '.'))
+ // option is set to explicitly speak punctuation characters
+ // if a list of allowed punctuation has been set up, check whether the character is in it
+ if((option_punctuation == 1) || (wcschr(option_punctlist,c1) != NULL))
{
- c1 = 0x2026;
- punct = 9; // elipsis
+ tr->phonemes_repeat_count = 0;
+ if((terminator = AnnouncePunctuation(tr, c1, &c2, buf, &ix, is_end_clause)) >= 0)
+ return(terminator);
+ announced_punctuation = c1;
}
-
+ }
+
+ if((punct_data & PUNCT_SAY_NAME) && (announced_punctuation == 0))
+ {
+ // used for elipsis (and 3 dots) if a pronunciation for elipsis is given in *_list
+ char *p2;
+
+ p2 = &buf[ix];
+ sprintf(p2,"%s",LookupCharName(tr, c1, 1));
+ if(p2[0] != 0)
+ {
+ ix += strlen(p2);
+ announced_punctuation = c1;
+ punct_data = punct_data & ~CLAUSE_BITS_INTONATION; // change intonation type to 0 (full-stop)
+ }
+ }
+
+ if(is_end_clause)
+ {
nl_count = 0;
- while(!Eof() && iswspace(c2))
+ c_next = c2;
+
+ if(iswspace(c_next))
{
- if(c2 == '\n')
- nl_count++;
- c2 = GetC(); // skip past space(s)
+ while(!Eof() && iswspace(c_next))
+ {
+ if(c_next == '\n')
+ nl_count++;
+ c_next = GetC(); // skip past space(s)
+ }
}
- if(!Eof())
+
+ if((c1 == '.') && (nl_count < 2))
{
- UngetC(c2);
+ punct_data |= CLAUSE_DOT;
}
-
- if((nl_count==0) && (c1 == '.'))
+
+ if(nl_count==0)
{
- if(iswdigit(cprev) && (tr->langopts.numbers & 0x10000) && islower(c2))
+ if((c1 == ',') && (cprev == '.') && (tr->translator_name == L('h','u')) && iswdigit(cprev2) && (iswdigit(c_next) || (iswlower2(c_next))))
+ {
+ // lang=hu, fix for ordinal numbers, eg: "december 2., szerda", ignore ',' after ordinal number
+ c1 = CHAR_COMMA_BREAK;
+ is_end_clause = 0;
+ }
+
+ if(c1 == '.')
+ {
+ if((tr->langopts.numbers & NUM_ORDINAL_DOT) &&
+ (iswdigit(cprev) || (IsRomanU(cprev) && (IsRomanU(cprev2) || iswspace(cprev2))))) // lang=hu
+ {
+ // dot after a number indicates an ordinal number
+ if(!iswdigit(cprev))
+ {
+ is_end_clause = 0; // Roman number followed by dot
+ }
+ else
+ {
+ if (iswlower2(c_next) || (c_next=='-')) // hyphen is needed for lang-hu (eg. 2.-kal)
+ is_end_clause = 0; // only if followed by lower-case, (or if there is a XML tag)
+ }
+ }
+ else
+ if(c_next == '\'')
+ {
+ is_end_clause = 0; // eg. u.s.a.'s
+ }
+ if(iswlower2(c_next))
+ {
+ // next word has no capital letter, this dot is probably from an abbreviation
+// c1 = ' ';
+ is_end_clause = 0;
+ }
+ if(any_alnum==0)
+ {
+ // no letters or digits yet, so probably not a sentence terminator
+ // Here, dot is followed by space or bracket
+ c1 = ' ';
+ is_end_clause = 0;
+ }
+ }
+ else
{
- // dot after a number indicates an ordinal number
- c2 = '.';
- continue;
+ if(any_alnum==0)
+ {
+ // no letters or digits yet, so probably not a sentence terminator
+ is_end_clause = 0;
+ }
}
- if(iswlower(c2))
+
+ if(is_end_clause && (c1 == '.') && (c_next == '<') && option_ssml)
{
- c2 = ' ';
- continue; // next word has no capital letter, this dot is probably from an abbreviation
+ // wait until after the end of the xml tag, then look for upper-case letter
+ is_end_clause = 0;
+ end_clause_index = ix;
+ end_clause_after_tag = punct_data;
}
- if(any_alnum==0)
+ }
+
+ if(is_end_clause)
+ {
+ UngetC(c_next);
+ buf[ix] = ' ';
+ buf[ix+1] = 0;
+
+ if(iswdigit(cprev) && !IsAlpha(c_next)) // ????
{
- c2 = ' '; // no letters or digits yet, so probably not a sentence terminator
- continue;
+ punct_data &= ~CLAUSE_DOT;
}
+ if(nl_count > 1)
+ {
+ if((punct_data == CLAUSE_QUESTION) || (punct_data == CLAUSE_EXCLAMATION))
+ return(punct_data + 35); // with a longer pause
+ return(CLAUSE_PARAGRAPH);
+ }
+ return(punct_data); // only recognise punctuation if followed by a blank or bracket/quote
}
-
- punct_data = punct_attributes[punct];
- if(nl_count > 1)
+ else
{
- if((punct_data == CLAUSE_QUESTION) || (punct_data == CLAUSE_EXCLAMATION))
- return(punct_data + 35); // with a longer pause
- return(CLAUSE_PARAGRAPH);
+ if(!Eof())
+ {
+ if(iswspace(c2))
+ UngetC(c_next);
+ }
}
- return(punct_data); // only recognise punctuation if followed by a blank or bracket/quote
}
}
if(speech_parameters[espeakSILENCE]==1)
continue;
+ if(c1 == announced_punctuation)
+ {
+ // This character has already been announced, so delete it so that it isn't spoken a second time.
+ // Unless it's a hyphen or apostrophe (which is used by TranslateClause() )
+ if(IsBracket(c1))
+ {
+ c1 = 0xe000 + '('; // Unicode private useage area. So TranslateRules() knows the bracket name has been spoken
+ }
+ else
+ if(c1 != '-')
+ {
+ c1 = ' ';
+ }
+ }
+
j = ix+1;
+
+ if(c1 == 0xe000 + '<') c1 = '<';
+
ix += utf8_out(c1,&buf[ix]); // buf[ix++] = c1;
if(!iswspace(c1) && !IsBracket(c1))
{
@@ -2379,10 +2909,11 @@ if(option_ssml) parag=1;
}
*charix_top = ix;
- if(((ix > (n_buf-20)) && !IsAlpha(c1) && !iswdigit(c1)) || (ix >= (n_buf-2)))
+ if(((ix > (n_buf-75)) && !IsAlpha(c1) && !iswdigit(c1)) || (ix >= (n_buf-4)))
{
// clause too long, getting near end of buffer, so break here
// try to break at a word boundary (unless we actually reach the end of buffer).
+ // (n_buf-4) is to allow for 3 bytes of multibyte character plus terminator.
buf[ix] = ' ';
buf[ix+1] = 0;
UngetC(c2);
@@ -2394,6 +2925,10 @@ if(option_ssml) parag=1;
{
ix += utf8_out(CHAR_EMPHASIS, &buf[ix]);
}
+ if(end_clause_after_tag)
+ {
+ RemoveChar(&buf[end_clause_index]); // delete clause-end punctiation
+ }
buf[ix] = ' ';
buf[ix+1] = 0;
return(CLAUSE_EOF); // end of file
@@ -2417,6 +2952,7 @@ void InitText2(void)
int param;
ungot_char = 0;
+ ungot_char2 = 0;
n_ssml_stack =1;
n_param_stack = 1;
@@ -2431,6 +2967,7 @@ void InitText2(void)
current_voice_id[0] = 0;
ignore_text = 0;
+ audio_text = 0;
clear_skipping_text = 0;
count_characters = -1;
sayas_mode = 0;
diff --git a/navit/support/espeak/setlengths.c b/navit/support/espeak/setlengths.c
index ed4421bf9..ca557c888 100755..100644
--- a/navit/support/espeak/setlengths.c
+++ b/navit/support/espeak/setlengths.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2011 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -29,76 +29,103 @@
#include "synthesize.h"
#include "voice.h"
#include "translate.h"
+#include "wavegen.h"
-extern int GetAmplitude(void);
+extern int saved_parameters[];
// convert from words-per-minute to internal speed factor
-static unsigned char speed_lookup[290] = {
- 250, 246, 243, 239, 236, // 80
- 233, 229, 226, 223, 220, // 85
- 217, 214, 211, 208, 205, // 90
- 202, 197, 194, 192, 190, // 95
- 187, 185, 183, 180, 178, // 100
- 176, 174, 172, 170, 168, // 105
- 166, 164, 161, 159, 158, // 110
- 156, 154, 152, 150, 148, // 115
- 146, 145, 143, 141, 137, // 120
- 136, 135, 133, 132, 131, // 125
- 129, 128, 127, 126, 125, // 130
- 124, 122, 121, 120, 119, // 135
- 117, 116, 115, 114, 113, // 140
- 112, 111, 110, 108, 107, // 145
- 106, 105, 104, 103, 102, // 150
- 101, 100, 99, 98, 97, // 155
- 96, 95, 93, 92, 92, // 160
- 91, 90, 89, 89, 88, // 165
- 87, 87, 86, 85, 85, // 170
- 84, 83, 83, 82, 81, // 175
- 80, 80, 79, 78, 78, // 180
- 77, 76, 76, 75, 73, // 185
- 72, 72, 71, 71, 70, // 190
- 70, 69, 69, 68, 67, // 195
- 67, 66, 66, 65, 65, // 200
- 64, 64, 63, 63, 62, // 205
- 62, 61, 60, 60, 59, // 210
- 59, 58, 58, 57, 57, // 215
- 56, 56, 55, 55, 55, // 220
- 54, 54, 53, 53, 52, // 225
- 52, 51, 51, 50, 50, // 230
- 49, 49, 49, 48, 48, // 235
- 47, 47, 46, 46, 46, // 240
- 45, 45, 44, 44, 43, // 245
- 43, 43, 42, 42, 41, // 250
- 41, 41, 40, 40, 39, // 255
- 39, 39, 38, 38, 38, // 260
- 37, 37, 37, 36, 36, // 265
- 35, 35, 35, 34, 34, // 270
- 34, 33, 33, 33, 32, // 275
- 32, 32, 32, 31, 31, // 280
- 31, 30, 30, 30, 29, // 285
- 29, 29, 29, 28, 28, // 290
- 28, 28, 27, 27, 27, // 295
- 26, 26, 26, 26, 25, // 300
- 25, 25, 22, 22, 22, // 305
- 22, 22, 22, 22, 22, // 310
- 21, 21, 21, 21, 21, // 315
- 21, 20, 20, 20, 20, // 320
- 20, 15, 15, 15, 15, // 325
- 15, 15, 15, 15, 16, // 330
- 16, 16, 16, 15, 15, // 335
- 15, 15, 15, 15, 15, // 340
- 15, 17, 17, 16, 16, // 345
- 15, 15, 14, 14, 13, // 350
- 13, 12, 12, 11, 11, // 355
- 10, 10, 9, 8, 8, // 360
- 7, 6, 5, 5, 4, // 365
+// Use this to calibrate speed for wpm 80-350
+static unsigned char speed_lookup[] = {
+ 255, 255, 255, 255, 255, // 80
+ 253, 249, 245, 242, 238, // 85
+ 235, 232, 228, 225, 222, // 90
+ 218, 216, 213, 210, 207, // 95
+ 204, 201, 198, 196, 193, // 100
+ 191, 188, 186, 183, 181, // 105
+ 179, 176, 174, 172, 169, // 110
+ 168, 165, 163, 161, 159, // 115
+ 158, 155, 153, 152, 150, // 120
+ 148, 146, 145, 143, 141, // 125
+ 139, 137, 136, 135, 133, // 130
+ 131, 130, 129, 127, 126, // 135
+ 124, 123, 122, 120, 119, // 140
+ 118, 117, 115, 114, 113, // 145
+ 112, 111, 110, 109, 107, // 150
+ 106, 105, 104, 103, 102, // 155
+ 101, 100, 99, 98, 97, // 160
+ 96, 95, 94, 93, 92, // 165
+ 91, 90, 89, 89, 88, // 170
+ 87, 86, 85, 84, 83, // 175
+ 82, 82, 81, 80, 80, // 180
+ 79, 78, 77, 76, 76, // 185
+ 75, 75, 74, 73, 72, // 190
+ 71, 71, 70, 69, 69, // 195
+ 68, 67, 67, 66, 66, // 200
+ 65, 64, 64, 63, 62, // 205
+ 62, 61, 61, 60, 59, // 210
+ 59, 58, 58, 57, 57, // 215
+ 56, 56, 55, 54, 54, // 220
+ 53, 53, 52, 52, 52, // 225
+ 51, 50, 50, 49, 49, // 230
+ 48, 48, 47, 47, 46, // 235
+ 46, 46, 45, 45, 44, // 240
+ 44, 44, 43, 43, 42, // 245
+ 41, 40, 40, 40, 39, // 250
+ 39, 39, 38, 38, 38, // 255
+ 37, 37, 37, 36, 36, // 260
+ 35, 35, 35, 35, 34, // 265
+ 34, 34, 33, 33, 33, // 270
+ 32, 32, 31, 31, 31, // 275
+ 30, 30, 30, 29, 29, // 280
+ 29, 29, 28, 28, 27, // 285
+ 27, 27, 27, 26, 26, // 290
+ 26, 26, 25, 25, 25, // 295
+ 24, 24, 24, 24, 23, // 300
+ 23, 23, 23, 22, 22, // 305
+ 22, 21, 21, 21, 21, // 310
+ 20, 20, 20, 20, 19, // 315
+ 19, 19, 18, 18, 17, // 320
+ 17, 17, 16, 16, 16, // 325
+ 16, 16, 16, 15, 15, // 330
+ 15, 15, 14, 14, 14, // 335
+ 13, 13, 13, 12, 12, // 340
+ 12, 12, 11, 11, 11, // 345
+ 11, 10, 10, 10, 9, // 350
+ 9, 9, 8, 8, 8, // 355
};
-// speed_factor2 adjustments for speeds 370 to 390
-static unsigned char faster[] = {
-114,112,110,109,107,105,104,102,100,98, // 370-379
-96,94,92,90,88,85,83,80,78,75,72 }; //380-390
+
+// speed_factor1 adjustments for speeds 350 to 374: pauses
+static unsigned char pause_factor_350[] = {
+22,22,22,22,22,22,22,21,21,21, // 350
+21,20,20,19,19,18,17,16,15,15, // 360
+15,15,15,15,15}; // 370
+
+// wav_factor adjustments for speeds 350 to 450
+// Use this to calibrate speed for wpm 350-450
+static unsigned char wav_factor_350[] = {
+ 120, 121, 120, 119, 119, // 350
+ 118, 118, 117, 116, 116, // 355
+ 115, 114, 113, 112, 112, // 360
+ 111, 111, 110, 109, 108, // 365
+ 107, 106, 106, 104, 103, // 370
+ 103, 102, 102, 102, 101, // 375
+ 101, 99, 98, 98, 97, // 380
+ 96, 96, 95, 94, 93, // 385
+ 91, 90, 91, 90, 89, // 390
+ 88, 86, 85, 86, 85, // 395
+ 85, 84, 82, 81, 80, // 400
+ 79, 77, 78, 78, 76, // 405
+ 77, 75, 75, 74, 73, // 410
+ 71, 72, 70, 69, 69, // 415
+ 69, 67, 65, 64, 63, // 420
+ 63, 63, 61, 61, 59, // 425
+ 59, 59, 58, 56, 57, // 430
+ 58, 56, 54, 53, 52, // 435
+ 52, 53, 52, 52, 50, // 440
+ 48, 47, 47, 45, 46, // 445
+ 45}; // 450
static int speed1 = 130;
static int speed2 = 121;
@@ -106,22 +133,96 @@ static int speed3 = 118;
+//#define TEST_SPEED
+
+#ifdef INCLUDE_SONIC
+
void SetSpeed(int control)
{//=======================
int x;
int s1;
int wpm;
int wpm2;
+ int wpm_value;
+ double sonic;
+
+ speed.loud_consonants = 0;
+ speed.min_sample_len = 450;
+ speed.lenmod_factor = 110; // controls the effect of FRFLAG_LEN_MOD reduce length change
+ speed.lenmod2_factor = 100;
+ speed.min_pause = 5;
wpm = embedded_value[EMBED_S];
if(control == 2)
wpm = embedded_value[EMBED_S2];
- wpm2 = wpm;
- if(wpm > 369) wpm = 369;
- if(wpm < 80) wpm = 80;
+ wpm_value = wpm;
+
+ if(voice->speed_percent > 0)
+ {
+ wpm = (wpm * voice->speed_percent)/100;
+ }
+
+ if(control & 2)
+ {
+ DoSonicSpeed(1 * 1024);
+ }
+ if((wpm_value > 450) || ((wpm_value > speed.fast_settings[0]) && (wpm > 350)))
+ {
+ wpm2 = wpm;
+ wpm = 175;
+
+ // set special eSpeak speed parameters for Sonic use
+ // The eSpeak output will be speeded up by at least x2
+ x = 73;
+ if(control & 1)
+ {
+ speed1 = (x * voice->speedf1)/256;
+ speed2 = (x * voice->speedf2)/256;
+ speed3 = (x * voice->speedf3)/256;
+ }
+ if(control & 2)
+ {
+ sonic = ((double)wpm2)/wpm;
+ DoSonicSpeed((int)(sonic * 1024));
+ speed.pause_factor = 85;
+ speed.clause_pause_factor = 80;
+ speed.min_pause = 22;
+ speed.min_sample_len = 450*2;
+ speed.wav_factor = 211;
+ speed.lenmod_factor = 210;
+ speed.lenmod2_factor = 170;
+ }
+ return;
+ }
+
- x = speed_lookup[wpm-80];
+#ifdef TEST_SPEED
+ if(wpm > 1000)
+ {
+ // TESTING
+// test = wpm / 1000;
+ wpm = wpm % 1000;
+ }
+#endif
+
+ if(wpm > 450)
+ wpm = 450;
+
+ if(wpm > 360)
+ {
+ speed.loud_consonants = (wpm - 360) / 8;
+ }
+
+ wpm2 = wpm;
+ if(wpm > 359) wpm2 = 359;
+ if(wpm < 80) wpm2 = 80;
+ x = speed_lookup[wpm2-80];
+
+ if(wpm >= 380)
+ x = 7;
+ if(wpm >= 400)
+ x = 6;
if(control & 1)
{
@@ -130,45 +231,232 @@ void SetSpeed(int control)
speed1 = (x * voice->speedf1)/256;
speed2 = (x * voice->speedf2)/256;
speed3 = (x * voice->speedf3)/256;
+
+ if(x <= 7)
+ {
+ speed1 = x;
+ speed2 = speed3 = x - 1;
+ }
}
if(control & 2)
{
// these are used in synthesis file
+
+ if(wpm > 350)
+ {
+ speed.lenmod_factor = 85 - (wpm - 350) / 3;
+ speed.lenmod2_factor = 60 - (wpm - 350) / 8;
+ }
+ else
+ if(wpm > 250)
+ {
+ speed.lenmod_factor = 110 - (wpm - 250)/4;
+ speed.lenmod2_factor = 110 - (wpm - 250)/2;
+ }
+
s1 = (x * voice->speedf1)/256;
- speed.speed_factor1 = (256 * s1)/115; // full speed adjustment, used for pause length
-if(speed.speed_factor1 < 15)
- speed.speed_factor1 = 15;
+
if(wpm >= 170)
-// speed_factor2 = 100 + (166*s1)/128; // reduced speed adjustment, used for playing recorded sounds
- speed.speed_factor2 = 110 + (150*s1)/128; // reduced speed adjustment, used for playing recorded sounds
+ speed.wav_factor = 110 + (150*s1)/128; // reduced speed adjustment, used for playing recorded sounds
+ else
+ speed.wav_factor = 128 + (128*s1)/130; // = 215 at 170 wpm
+
+ if(wpm >= 350)
+ {
+ speed.wav_factor = wav_factor_350[wpm-350];
+ }
+
+ if(wpm >= 390)
+ {
+ speed.min_sample_len = 450 - (wpm - 400)/2;
+ if(wpm > 440)
+ speed.min_sample_len = 420 - (wpm - 440);
+ }
+
+// adjust for different sample rates
+speed.min_sample_len = (speed.min_sample_len * samplerate_native) / 22050;
+
+ speed.pause_factor = (256 * s1)/115; // full speed adjustment, used for pause length
+ speed.clause_pause_factor = 0;
+
+ if(wpm > 430)
+ {
+ speed.pause_factor = 12;
+// speed.clause_pause_factor = 15;
+ }
else
- speed.speed_factor2 = 128 + (128*s1)/130; // = 215 at 170 wpm
+ if(wpm > 400)
+ {
+ speed.pause_factor = 13;
+// speed.clause_pause_factor = 15;
+ }
+ else
+ if(wpm > 374)
+ {
+ speed.pause_factor = 14;
+ }
+ else
+ if(wpm > 350)
+ {
+ speed.pause_factor = pause_factor_350[wpm - 350];
+ }
- if(wpm2 > 369)
+ if(speed.clause_pause_factor == 0)
{
- if(wpm2 > 390)
- wpm2 = 390;
- speed.speed_factor2 = faster[wpm2 - 370];
+ // restrict the reduction of pauses between clauses
+ if((speed.clause_pause_factor = speed.pause_factor) < 16)
+ speed.clause_pause_factor = 16;
}
}
+#ifdef TEST_SPEED
+//if(control==3)
+printf("%3d: speedf %d %d %d pause=%d %d wav=%d lenmod=%d %d\n",wpm,speed1,speed2,speed3, speed.pause_factor,speed.clause_pause_factor, speed.wav_factor,speed.lenmod_factor,speed.lenmod2_factor);
+#endif
+} // end of SetSpeed
+
+#else // not using sonic speed-up
+
+void SetSpeed(int control)
+{//=======================
+// This is the earlier version of SetSpeed() before sonic speed-up was added
+ int x;
+ int s1;
+ int wpm;
+ int wpm2;
+
+ speed.loud_consonants = 0;
speed.min_sample_len = 450;
- speed.speed_factor3 = 110; // controls the effect of FRFLAG_LEN_MOD reduce length change
+ speed.lenmod_factor = 110; // controls the effect of FRFLAG_LEN_MOD reduce length change
+ speed.lenmod2_factor = 100;
+
+ wpm = embedded_value[EMBED_S];
+ if(control == 2)
+ wpm = embedded_value[EMBED_S2];
- if(wpm2 >= 370)
+#ifdef TEST_SPEED
+ if(wpm > 1000)
{
// TESTING
- // use experimental fast settings if they have been specified in the Voice
- if(speed.fast_settings[0] > 0)
- speed.speed_factor1 = speed.fast_settings[0];
- if(speed.fast_settings[1] > 0)
- speed.speed_factor2 = speed.fast_settings[1];
- if(speed.fast_settings[2] > 0)
- speed.speed_factor3 = speed.fast_settings[2];
+ test = wpm / 1000;
+ wpm = wpm % 1000;
}
+#endif
+
+ if(voice->speed_percent > 0)
+ {
+ wpm = (wpm * voice->speed_percent)/100;
+ }
+ if(wpm > 450)
+ wpm = 450;
+
+ if(wpm > 360)
+ {
+ speed.loud_consonants = (wpm - 360) / 8;
+ }
+
+ wpm2 = wpm;
+ if(wpm > 359) wpm2 = 359;
+ if(wpm < 80) wpm2 = 80;
+ x = speed_lookup[wpm2-80];
+
+ if(wpm >= 380)
+ x = 7;
+ if(wpm >= 400)
+ x = 6;
+
+ if(control & 1)
+ {
+ // set speed factors for different syllable positions within a word
+ // these are used in CalcLengths()
+ speed1 = (x * voice->speedf1)/256;
+ speed2 = (x * voice->speedf2)/256;
+ speed3 = (x * voice->speedf3)/256;
+
+ if(x <= 7)
+ {
+ speed1 = x;
+ speed2 = speed3 = x - 1;
+ }
+ }
+
+ if(control & 2)
+ {
+ // these are used in synthesis file
+
+ if(wpm > 350)
+ {
+ speed.lenmod_factor = 85 - (wpm - 350) / 3;
+ speed.lenmod2_factor = 60 - (wpm - 350) / 8;
+ }
+ else
+ if(wpm > 250)
+ {
+ speed.lenmod_factor = 110 - (wpm - 250)/4;
+ speed.lenmod2_factor = 110 - (wpm - 250)/2;
+ }
+
+ s1 = (x * voice->speedf1)/256;
+
+ if(wpm >= 170)
+ speed.wav_factor = 110 + (150*s1)/128; // reduced speed adjustment, used for playing recorded sounds
+ else
+ speed.wav_factor = 128 + (128*s1)/130; // = 215 at 170 wpm
+
+ if(wpm >= 350)
+ {
+ speed.wav_factor = wav_factor_350[wpm-350];
+ }
+
+ if(wpm >= 390)
+ {
+ speed.min_sample_len = 450 - (wpm - 400)/2;
+ if(wpm > 440)
+ speed.min_sample_len = 420 - (wpm - 440);
+ }
+
+ speed.pause_factor = (256 * s1)/115; // full speed adjustment, used for pause length
+ speed.clause_pause_factor = 0;
+
+ if(wpm > 430)
+ {
+ speed.pause_factor = 12;
+// speed.clause_pause_factor = 15;
+ }
+ else
+ if(wpm > 400)
+ {
+ speed.pause_factor = 13;
+// speed.clause_pause_factor = 15;
+ }
+ else
+ if(wpm > 374)
+ {
+ speed.pause_factor = 14;
+ }
+ else
+ if(wpm > 350)
+ {
+ speed.pause_factor = pause_factor_350[wpm - 350];
+ }
+
+ if(speed.clause_pause_factor == 0)
+ {
+ // restrict the reduction of pauses between clauses
+ if((speed.clause_pause_factor = speed.pause_factor) < 16)
+ speed.clause_pause_factor = 16;
+ }
+ }
+
+#ifdef TEST_SPEED
+//if(control==3)
+printf("%3d: speedf %d %d %d pause=%d %d wav=%d lenmod=%d %d\n",wpm,speed1,speed2,speed3, speed.pause_factor,speed.clause_pause_factor, speed.wav_factor,speed.lenmod_factor,speed.lenmod2_factor);
+#endif
} // end of SetSpeed
+#endif // of INCLUDE_SONIC
+
#ifdef deleted
void SetAmplitude(int amp)
@@ -177,7 +465,7 @@ void SetAmplitude(int amp)
if((amp >= 0) && (amp <= 20))
{
- option_amplitude = (amplitude_factor[amp] * 480)/256;
+ option_amplitude = (amplitude_factor[amp] * 480)/256;
}
}
#endif
@@ -201,6 +489,7 @@ void SetParameter(int parameter, int value, int relative)
}
}
param_stack[0].parameter[parameter] = new_value;
+ saved_parameters[parameter] = new_value;
switch(parameter)
{
@@ -285,14 +574,17 @@ void CalcLengths(Translator *tr)
int last_pitch = 0;
int pitch_start;
int length_mod;
+ int next2type;
int len;
int env2;
int end_of_clause;
int embedded_ix = 0;
int min_drop;
+ int pitch1;
int emphasized;
int tone_mod;
unsigned char *pitch_env=NULL;
+ PHONEME_DATA phdata_tone;
for(ix=1; ix<n_phoneme_list; ix++)
{
@@ -317,14 +609,14 @@ void CalcLengths(Translator *tr)
case phPAUSE:
last_pitch = 0;
break;
-
+
case phSTOP:
last_pitch = 0;
if(prev->type == phFRICATIVE)
- p->prepause = 20;
+ p->prepause = 25;
else
if((more_syllables > 0) || (stress < 4))
- p->prepause = 40;
+ p->prepause = 48;
else
p->prepause = 60;
@@ -342,13 +634,17 @@ void CalcLengths(Translator *tr)
break;
case phVFRICATIVE:
- if(next->type==phVOWEL)
- {
- pre_voiced = 1;
- } // drop through
case phFRICATIVE:
if(p->newword)
- p->prepause = 15;
+ {
+ if((prev->type == phVOWEL) && (p->ph->phflags & phNOPAUSE))
+ {
+ }
+ else
+ {
+ p->prepause = 15;
+ }
+ }
if(next->type==phPAUSE && prev->type==phNASAL && !(p->ph->phflags&phFORTIS))
p->prepause = 25;
@@ -356,6 +652,9 @@ void CalcLengths(Translator *tr)
if(prev->ph->phflags & phBRKAFTER)
p->prepause = 30;
+ if((tr->langopts.word_gap & 0x10) && (p->newword))
+ p->prepause = 30;
+
if((p->ph->phflags & phSIBILANT) && next->type==phSTOP && !next->newword)
{
if(prev->type == phVOWEL)
@@ -366,9 +665,17 @@ void CalcLengths(Translator *tr)
else
p->length = 256;
- if((tr->langopts.word_gap & 0x10) && (p->newword))
- p->prepause = 30;
-
+ if(type == phVFRICATIVE)
+ {
+ if(next->type==phVOWEL)
+ {
+ pre_voiced = 1;
+ }
+ if((prev->type==phVOWEL) || (prev->type == phLIQUID))
+ {
+ p->length = (255 + prev->length)/2;
+ }
+ }
break;
case phVSTOP:
@@ -382,8 +689,19 @@ void CalcLengths(Translator *tr)
p->prepause = 40;
- if((prev->type == phPAUSE) || (prev->type == phVOWEL)) // || (prev->ph->mnemonic == ('/'*256+'r')))
- p->prepause = 0;
+ if(prev->type == phVOWEL)
+ {
+ p->prepause = 0; // use murmur instead to link from the preceding vowel
+ }
+ else
+ if(prev->type == phPAUSE)
+ {
+ // reduce by the length of the preceding pause
+ if(prev->length < p->prepause)
+ p->prepause -= prev->length;
+ else
+ p->prepause = 0;
+ }
else
if(p->newword==0)
{
@@ -403,16 +721,19 @@ void CalcLengths(Translator *tr)
case phLIQUID:
case phNASAL:
- p->amp = tr->stress_amps[1]; // unless changed later
+ p->amp = tr->stress_amps[0]; // unless changed later
p->length = 256; // TEMPORARY
min_drop = 0;
-
+
if(p->newword)
{
if(prev->type==phLIQUID)
p->prepause = 25;
if(prev->type==phVOWEL)
- p->prepause = 12;
+ {
+ if(!(p->ph->phflags & phNOPAUSE))
+ p->prepause = 12;
+ }
}
if(next->type==phVOWEL)
@@ -420,43 +741,44 @@ void CalcLengths(Translator *tr)
pre_sonorant = 1;
}
else
- if((prev->type==phVOWEL) || (prev->type == phLIQUID))
{
- p->length = prev->length;
p->pitch2 = last_pitch;
- if(p->pitch2 < 7)
- p->pitch2 = 7;
- p->pitch1 = p->pitch2 - 8;
- p->env = PITCHfall;
- pre_voiced = 0;
-
- if(p->type == phLIQUID)
- {
- p->length = speed1;
-//p->pitch1 = p->pitch2 - 20; // post vocalic [r/]
- }
- if(next->type == phVSTOP)
+ if((prev->type==phVOWEL) || (prev->type == phLIQUID))
{
- p->length = (p->length * 160)/100;
- }
- if(next->type == phVFRICATIVE)
- {
- p->length = (p->length * 120)/100;
+ p->length = prev->length;
+
+ if(p->type == phLIQUID)
+ {
+ p->length = speed1;
+ }
+
+ if(next->type == phVSTOP)
+ {
+ p->length = (p->length * 160)/100;
+ }
+ if(next->type == phVFRICATIVE)
+ {
+ p->length = (p->length * 120)/100;
+ }
}
- }
- else
- {
- p->pitch2 = last_pitch;
- for(ix2=ix; ix2<n_phoneme_list; ix2++)
+ else
{
- if(phoneme_list[ix2].type == phVOWEL)
+ for(ix2=ix; ix2<n_phoneme_list; ix2++)
{
- p->pitch2 = phoneme_list[ix2].pitch2;
- break;
+ if(phoneme_list[ix2].type == phVOWEL)
+ {
+ p->pitch2 = phoneme_list[ix2].pitch2;
+ break;
+ }
}
}
- p->pitch1 = p->pitch2-8;
+
+ p->pitch1 = p->pitch2-16;
+ if(p->pitch2 < 16)
+ {
+ p->pitch1 = 0;
+ }
p->env = PITCHfall;
pre_voiced = 0;
}
@@ -469,6 +791,10 @@ void CalcLengths(Translator *tr)
if(stress > 7) stress = 7;
+if(stress <= 1)
+{
+ stress = stress ^ 1; // swap diminished and unstressed (until we swap stress_amps,stress_lengths in tr_languages)
+}
if(pre_sonorant)
p->amp = tr->stress_amps[stress]-1;
else
@@ -512,9 +838,17 @@ void CalcLengths(Translator *tr)
next3 = &phoneme_list[ix+4];
}
+ next2type = next2->ph->length_mod;
if(more_syllables==0)
{
- len = tr->langopts.length_mods0[next2->ph->length_mod *10+ next->ph->length_mod];
+ if(next->newword || next2->newword)
+ {
+ // don't use 2nd phoneme over a word boundary, unless it's a pause
+ if(next2type != 1)
+ next2type = 0;
+ }
+
+ len = tr->langopts.length_mods0[next2type *10+ next->ph->length_mod];
if((next->newword) && (tr->langopts.word_gap & 0x20))
{
@@ -526,7 +860,7 @@ void CalcLengths(Translator *tr)
}
else
{
- length_mod = tr->langopts.length_mods[next2->ph->length_mod *10+ next->ph->length_mod];
+ length_mod = tr->langopts.length_mods[next2type *10+ next->ph->length_mod];
if((next->type == phNASAL) && (next2->type == phSTOP || next2->type == phVSTOP) && (next3->ph->phflags & phFORTIS))
length_mod -= 15;
@@ -548,20 +882,20 @@ void CalcLengths(Translator *tr)
if(stress >= 7)
{
// tonic syllable, include a constant component so it doesn't decrease directly with speed
- length_mod += 20;
+ length_mod += tr->langopts.lengthen_tonic;
if(emphasized)
- length_mod += 10;
+ length_mod += (tr->langopts.lengthen_tonic/2);
}
else
if(emphasized)
{
- length_mod += 20;
+ length_mod += tr->langopts.lengthen_tonic;
}
-
+
if((len = tr->stress_lengths[stress]) == 0)
len = tr->stress_lengths[6];
- length_mod = (length_mod * len)/128;
+ length_mod = length_mod * len;
if(p->tone_ph != 0)
{
@@ -572,30 +906,45 @@ void CalcLengths(Translator *tr)
}
}
- if(end_of_clause == 2)
+
+ if((end_of_clause == 2) && !(tr->langopts.stress_flags & S_NO_EOC_LENGTHEN))
{
// this is the last syllable in the clause, lengthen it - more for short vowels
- len = p->ph->std_length;
- if(tr->langopts.stress_flags & 0x40000)
+ len = (p->ph->std_length * 2);
+ if(tr->langopts.stress_flags & S_EO_CLAUSE1)
len=200; // don't lengthen short vowels more than long vowels at end-of-clause
length_mod = length_mod * (256 + (280 - len)/3)/256;
}
+ if(length_mod > tr->langopts.max_lengthmod*speed1)
+ {
+ //limit the vowel length adjustment for some languages
+ length_mod = (tr->langopts.max_lengthmod*speed1);
+ }
+
+ length_mod = length_mod / 128;
+
if(p->type != phVOWEL)
{
length_mod = 256; // syllabic consonant
- min_drop = 8;
+ min_drop = 16;
}
p->length = length_mod;
+ if(p->env >= (N_ENVELOPE_DATA-1))
+ {
+ fprintf(stderr,"espeak: Bad intonation data\n");
+ p->env = 0;
+ }
+
// pre-vocalic part
// set last-pitch
- env2 = p->env;
- if(env2 > 1) env2++; // version for use with preceding semi-vowel
+ env2 = p->env + 1; // version for use with preceding semi-vowel
if(p->tone_ph != 0)
{
- pitch_env = LookupEnvelope(phoneme_tab[p->tone_ph]->spect);
+ InterpretPhoneme2(p->tone_ph, &phdata_tone);
+ pitch_env = GetEnvelope(phdata_tone.pitch_env);
}
else
{
@@ -607,11 +956,11 @@ if(p->type != phVOWEL)
if(pre_sonorant || pre_voiced)
{
// set pitch for pre-vocalic part
- if(pitch_start == 1024)
+ if(pitch_start == 255)
last_pitch = pitch_start; // pitch is not set
- if(pitch_start - last_pitch > 8) // was 9
- last_pitch = pitch_start - 8;
+ if(pitch_start - last_pitch > 16)
+ last_pitch = pitch_start - 16;
prev->pitch1 = last_pitch;
prev->pitch2 = pitch_start;
@@ -636,11 +985,11 @@ if(p->type != phVOWEL)
next->synthflags &= ~SFLAG_SEQCONTINUE;
if(next->type == phNASAL && next2->type != phVOWEL)
next->synthflags |= SFLAG_SEQCONTINUE;
-
+
if(next->type == phLIQUID)
{
next->synthflags |= SFLAG_SEQCONTINUE;
-
+
if(next2->type == phVOWEL)
{
next->synthflags &= ~SFLAG_SEQCONTINUE;
@@ -658,9 +1007,10 @@ if(p->type != phVOWEL)
if((min_drop > 0) && ((p->pitch2 - p->pitch1) < min_drop))
{
- p->pitch1 = p->pitch2 - min_drop;
- if(p->pitch1 < 0)
- p->pitch1 = 0;
+ pitch1 = p->pitch2 - min_drop;
+ if(pitch1 < 0)
+ pitch1 = 0;
+ p->pitch1 = pitch1;
}
last_pitch = p->pitch1 + ((p->pitch2-p->pitch1)*envelope_data[p->env][127])/256;
diff --git a/navit/support/espeak/sintab.h b/navit/support/espeak/sintab.h
index 08fc18f31..08fc18f31 100755..100644
--- a/navit/support/espeak/sintab.h
+++ b/navit/support/espeak/sintab.h
diff --git a/navit/support/espeak/sonic.c b/navit/support/espeak/sonic.c
new file mode 100644
index 000000000..0627dee2c
--- /dev/null
+++ b/navit/support/espeak/sonic.c
@@ -0,0 +1,974 @@
+/* Sonic library
+ Copyright 2010
+ Bill Cox
+ This file is part of the Sonic Library.
+
+ The Sonic Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "StdAfx.h"
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "speech.h"
+#include "sonic.h"
+#ifdef INCLUDE_SONIC
+
+struct sonicStreamStruct {
+ short *inputBuffer;
+ short *outputBuffer;
+ short *pitchBuffer;
+ short *downSampleBuffer;
+ float speed;
+ float volume;
+ float pitch;
+ int numChannels;
+ int inputBufferSize;
+ int pitchBufferSize;
+ int outputBufferSize;
+ int numInputSamples;
+ int numOutputSamples;
+ int numPitchSamples;
+ int minPeriod;
+ int maxPeriod;
+ int maxRequired;
+ int remainingInputToCopy;
+ int sampleRate;
+ int prevPeriod;
+ int prevMaxDiff;
+ int prevMinDiff;
+};
+
+#if 0
+/* Just used for debugging */
+static void sonicMSG(char *format, ...)
+{
+ char buffer[4096];
+ va_list ap;
+ FILE *file;
+
+ va_start(ap, format);
+ vsprintf((char *)buffer, (char *)format, ap);
+ va_end(ap);
+ file=fopen("/tmp/sonic.log", "a");
+ fprintf(file, "%s", buffer);
+ fclose(file);
+}
+#endif
+
+/* Scale the samples by the factor. */
+static void scaleSamples(
+ short *samples,
+ int numSamples,
+ float volume)
+{
+ int fixedPointVolume = volume*4096.0f;
+ int value;
+
+ while(numSamples--) {
+ value = (*samples*fixedPointVolume) >> 12;
+ if(value > 32767) {
+ value = 32767;
+ } else if(value < -32767) {
+ value = -32767;
+ }
+ *samples++ = value;
+ }
+}
+
+/* Get the speed of the stream. */
+float sonicGetSpeed(
+ sonicStream stream)
+{
+ return stream->speed;
+}
+
+/* Set the speed of the stream. */
+void sonicSetSpeed(
+ sonicStream stream,
+ float speed)
+{
+ stream->speed = speed;
+}
+
+/* Get the pitch of the stream. */
+float sonicGetPitch(
+ sonicStream stream)
+{
+ return stream->pitch;
+}
+
+/* Set the pitch of the stream. */
+void sonicSetPitch(
+ sonicStream stream,
+ float pitch)
+{
+ stream->pitch = pitch;
+}
+
+/* Get the scaling factor of the stream. */
+float sonicGetVolume(
+ sonicStream stream)
+{
+ return stream->volume;
+}
+
+/* Set the scaling factor of the stream. */
+void sonicSetVolume(
+ sonicStream stream,
+ float volume)
+{
+ stream->volume = volume;
+}
+
+/* Get the sample rate of the stream. */
+int sonicGetSampleRate(
+ sonicStream stream)
+{
+ return stream->sampleRate;
+}
+
+/* Get the number of channels. */
+int sonicGetNumChannels(
+ sonicStream stream)
+{
+ return stream->numChannels;
+}
+
+/* Destroy the sonic stream. */
+void sonicDestroyStream(
+ sonicStream stream)
+{
+ if(stream->inputBuffer != NULL) {
+ free(stream->inputBuffer);
+ }
+ if(stream->outputBuffer != NULL) {
+ free(stream->outputBuffer);
+ }
+ if(stream->pitchBuffer != NULL) {
+ free(stream->pitchBuffer);
+ }
+ if(stream->downSampleBuffer != NULL) {
+ free(stream->downSampleBuffer);
+ }
+ free(stream);
+}
+
+/* Create a sonic stream. Return NULL only if we are out of memory and cannot
+ allocate the stream. */
+sonicStream sonicCreateStream(
+ int sampleRate,
+ int numChannels)
+{
+ sonicStream stream = (sonicStream)calloc(1, sizeof(struct sonicStreamStruct));
+ int minPeriod = sampleRate/SONIC_MAX_PITCH;
+ int maxPeriod = sampleRate/SONIC_MIN_PITCH;
+ int maxRequired = 2*maxPeriod;
+
+ if(stream == NULL) {
+ return NULL;
+ }
+ stream->inputBufferSize = maxRequired;
+ stream->inputBuffer = (short *)calloc(maxRequired, sizeof(short)*numChannels);
+ if(stream->inputBuffer == NULL) {
+ sonicDestroyStream(stream);
+ return NULL;
+ }
+ stream->outputBufferSize = maxRequired;
+ stream->outputBuffer = (short *)calloc(maxRequired, sizeof(short)*numChannels);
+ if(stream->outputBuffer == NULL) {
+ sonicDestroyStream(stream);
+ return NULL;
+ }
+ stream->pitchBufferSize = maxRequired;
+ stream->pitchBuffer = (short *)calloc(maxRequired, sizeof(short)*numChannels);
+ if(stream->pitchBuffer == NULL) {
+ sonicDestroyStream(stream);
+ return NULL;
+ }
+ stream->downSampleBuffer = (short *)calloc(maxRequired, sizeof(short));
+ stream->speed = 1.0f;
+ stream->pitch = 1.0f;
+ stream->volume = 1.0f;
+ stream->sampleRate = sampleRate;
+ stream->numChannels = numChannels;
+ stream->minPeriod = minPeriod;
+ stream->maxPeriod = maxPeriod;
+ stream->maxRequired = maxRequired;
+ return stream;
+}
+
+/* Enlarge the output buffer if needed. */
+static int enlargeOutputBufferIfNeeded(
+ sonicStream stream,
+ int numSamples)
+{
+ if(stream->numOutputSamples + numSamples > stream->outputBufferSize) {
+ stream->outputBufferSize += (stream->outputBufferSize >> 1) + numSamples;
+ stream->outputBuffer = (short *)realloc(stream->outputBuffer,
+ stream->outputBufferSize*sizeof(short)*stream->numChannels);
+ if(stream->outputBuffer == NULL) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+/* Enlarge the input buffer if needed. */
+static int enlargeInputBufferIfNeeded(
+ sonicStream stream,
+ int numSamples)
+{
+ if(stream->numInputSamples + numSamples > stream->inputBufferSize) {
+ stream->inputBufferSize += (stream->inputBufferSize >> 1) + numSamples;
+ stream->inputBuffer = (short *)realloc(stream->inputBuffer,
+ stream->inputBufferSize*sizeof(short)*stream->numChannels);
+ if(stream->inputBuffer == NULL) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+/* Add the input samples to the input buffer. */
+static int addFloatSamplesToInputBuffer(
+ sonicStream stream,
+ float *samples,
+ int numSamples)
+{
+ short *buffer;
+ int count = numSamples*stream->numChannels;
+
+ if(numSamples == 0) {
+ return 1;
+ }
+ if(!enlargeInputBufferIfNeeded(stream, numSamples)) {
+ return 0;
+ }
+ buffer = stream->inputBuffer + stream->numInputSamples*stream->numChannels;
+ while(count--) {
+ *buffer++ = (*samples++)*32767.0f;
+ }
+ stream->numInputSamples += numSamples;
+ return 1;
+}
+
+/* Add the input samples to the input buffer. */
+static int addShortSamplesToInputBuffer(
+ sonicStream stream,
+ short *samples,
+ int numSamples)
+{
+ if(numSamples == 0) {
+ return 1;
+ }
+ if(!enlargeInputBufferIfNeeded(stream, numSamples)) {
+ return 0;
+ }
+ memcpy(stream->inputBuffer + stream->numInputSamples*stream->numChannels, samples,
+ numSamples*sizeof(short)*stream->numChannels);
+ stream->numInputSamples += numSamples;
+ return 1;
+}
+
+/* Add the input samples to the input buffer. */
+static int addUnsignedCharSamplesToInputBuffer(
+ sonicStream stream,
+ unsigned char *samples,
+ int numSamples)
+{
+ short *buffer;
+ int count = numSamples*stream->numChannels;
+
+ if(numSamples == 0) {
+ return 1;
+ }
+ if(!enlargeInputBufferIfNeeded(stream, numSamples)) {
+ return 0;
+ }
+ buffer = stream->inputBuffer + stream->numInputSamples*stream->numChannels;
+ while(count--) {
+ *buffer++ = (*samples++ - 128) << 8;
+ }
+ stream->numInputSamples += numSamples;
+ return 1;
+}
+
+/* Remove input samples that we have already processed. */
+static void removeInputSamples(
+ sonicStream stream,
+ int position)
+{
+ int remainingSamples = stream->numInputSamples - position;
+
+ if(remainingSamples > 0) {
+ memmove(stream->inputBuffer, stream->inputBuffer + position*stream->numChannels,
+ remainingSamples*sizeof(short)*stream->numChannels);
+ }
+ stream->numInputSamples = remainingSamples;
+}
+
+/* Just copy from the array to the output buffer */
+static int copyToOutput(
+ sonicStream stream,
+ short *samples,
+ int numSamples)
+{
+ if(!enlargeOutputBufferIfNeeded(stream, numSamples)) {
+ return 0;
+ }
+ memcpy(stream->outputBuffer + stream->numOutputSamples*stream->numChannels,
+ samples, numSamples*sizeof(short)*stream->numChannels);
+ stream->numOutputSamples += numSamples;
+ return numSamples;
+}
+
+/* Just copy from the input buffer to the output buffer. Return 0 if we fail to
+ resize the output buffer. Otherwise, return numSamples */
+static int copyInputToOutput(
+ sonicStream stream,
+ int position)
+{
+ int numSamples = stream->remainingInputToCopy;
+
+ if(numSamples > stream->maxRequired) {
+ numSamples = stream->maxRequired;
+ }
+ if(!copyToOutput(stream, stream->inputBuffer + position*stream->numChannels,
+ numSamples)) {
+ return 0;
+ }
+ stream->remainingInputToCopy -= numSamples;
+ return numSamples;
+}
+
+/* Read data out of the stream. Sometimes no data will be available, and zero
+ is returned, which is not an error condition. */
+int sonicReadFloatFromStream(
+ sonicStream stream,
+ float *samples,
+ int maxSamples)
+{
+ int numSamples = stream->numOutputSamples;
+ int remainingSamples = 0;
+ short *buffer;
+ int count;
+
+ if(numSamples == 0) {
+ return 0;
+ }
+ if(numSamples > maxSamples) {
+ remainingSamples = numSamples - maxSamples;
+ numSamples = maxSamples;
+ }
+ buffer = stream->outputBuffer;
+ count = numSamples*stream->numChannels;
+ while(count--) {
+ *samples++ = (*buffer++)/32767.0f;
+ }
+ if(remainingSamples > 0) {
+ memmove(stream->outputBuffer, stream->outputBuffer + numSamples*stream->numChannels,
+ remainingSamples*sizeof(short)*stream->numChannels);
+ }
+ stream->numOutputSamples = remainingSamples;
+ return numSamples;
+}
+
+/* Read short data out of the stream. Sometimes no data will be available, and zero
+ is returned, which is not an error condition. */
+int sonicReadShortFromStream(
+ sonicStream stream,
+ short *samples,
+ int maxSamples)
+{
+ int numSamples = stream->numOutputSamples;
+ int remainingSamples = 0;
+
+ if(numSamples == 0) {
+ return 0;
+ }
+ if(numSamples > maxSamples) {
+ remainingSamples = numSamples - maxSamples;
+ numSamples = maxSamples;
+ }
+ memcpy(samples, stream->outputBuffer, numSamples*sizeof(short)*stream->numChannels);
+ if(remainingSamples > 0) {
+ memmove(stream->outputBuffer, stream->outputBuffer + numSamples*stream->numChannels,
+ remainingSamples*sizeof(short)*stream->numChannels);
+ }
+ stream->numOutputSamples = remainingSamples;
+ return numSamples;
+}
+
+/* Read unsigned char data out of the stream. Sometimes no data will be available, and zero
+ is returned, which is not an error condition. */
+int sonicReadUnsignedCharFromStream(
+ sonicStream stream,
+ unsigned char *samples,
+ int maxSamples)
+{
+ int numSamples = stream->numOutputSamples;
+ int remainingSamples = 0;
+ short *buffer;
+ int count;
+
+ if(numSamples == 0) {
+ return 0;
+ }
+ if(numSamples > maxSamples) {
+ remainingSamples = numSamples - maxSamples;
+ numSamples = maxSamples;
+ }
+ buffer = stream->outputBuffer;
+ count = numSamples*stream->numChannels;
+ while(count--) {
+ *samples++ = (char)((*buffer++) >> 8) + 128;
+ }
+ if(remainingSamples > 0) {
+ memmove(stream->outputBuffer, stream->outputBuffer + numSamples*stream->numChannels,
+ remainingSamples*sizeof(short)*stream->numChannels);
+ }
+ stream->numOutputSamples = remainingSamples;
+ return numSamples;
+}
+
+/* Force the sonic stream to generate output using whatever data it currently
+ has. No extra delay will be added to the output, but flushing in the middle of
+ words could introduce distortion. */
+int sonicFlushStream(
+ sonicStream stream)
+{
+ int maxRequired = stream->maxRequired;
+ int numSamples = stream->numInputSamples;
+ int remainingSpace, numOutputSamples, expectedSamples;
+
+ if(numSamples == 0) {
+ return 1;
+ }
+ if(numSamples >= maxRequired && !sonicWriteShortToStream(stream, NULL, 0)) {
+ return 0;
+ }
+ numSamples = stream->numInputSamples; /* Now numSamples < maxRequired */
+ if(numSamples == 0) {
+ return 1;
+ }
+ remainingSpace = maxRequired - numSamples;
+ memset(stream->inputBuffer + numSamples*stream->numChannels, 0,
+ remainingSpace*sizeof(short)*stream->numChannels);
+ stream->numInputSamples = maxRequired;
+ numOutputSamples = stream->numOutputSamples;
+ if(!sonicWriteShortToStream(stream, NULL, 0)) {
+ return 0;
+ }
+ /* Throw away any extra samples we generated due to the silence we added */
+ expectedSamples = (int)(numSamples*stream->speed + 0.5);
+ if(stream->numOutputSamples > numOutputSamples + expectedSamples) {
+ stream->numOutputSamples = numOutputSamples + expectedSamples;
+ }
+ return 1;
+}
+
+/* Return the number of samples in the output buffer */
+int sonicSamplesAvailable(
+ sonicStream stream)
+{
+ return stream->numOutputSamples;
+}
+
+/* If skip is greater than one, average skip samples togther and write them to
+ the down-sample buffer. If numChannels is greater than one, mix the channels
+ together as we down sample. */
+static void downSampleInput(
+ sonicStream stream,
+ short *samples,
+ int skip)
+{
+ int numSamples = stream->maxRequired/skip;
+ int samplesPerValue = stream->numChannels*skip;
+ int i, j;
+ int value;
+ short *downSamples = stream->downSampleBuffer;
+
+ for(i = 0; i < numSamples; i++) {
+ value = 0;
+ for(j = 0; j < samplesPerValue; j++) {
+ value += *samples++;
+ }
+ value /= samplesPerValue;
+ *downSamples++ = value;
+ }
+}
+
+/* Find the best frequency match in the range, and given a sample skip multiple.
+ For now, just find the pitch of the first channel. */
+static int findPitchPeriodInRange(
+ short *samples,
+ int minPeriod,
+ int maxPeriod,
+ int *retMinDiff,
+ int *retMaxDiff)
+{
+ int period, bestPeriod = 0;
+ short *s, *p, sVal, pVal;
+ unsigned long diff, minDiff = 1, maxDiff = 0;
+ int i;
+
+ for(period = minPeriod; period <= maxPeriod; period++) {
+ diff = 0;
+ s = samples;
+ p = samples + period;
+ for(i = 0; i < period; i++) {
+ sVal = *s++;
+ pVal = *p++;
+ diff += sVal >= pVal? (unsigned short)(sVal - pVal) :
+ (unsigned short)(pVal - sVal);
+ }
+ /* Note that the highest number of samples we add into diff will be less
+ than 256, since we skip samples. Thus, diff is a 24 bit number, and
+ we can safely multiply by numSamples without overflow */
+ if(diff*bestPeriod < minDiff*period) {
+ minDiff = diff;
+ bestPeriod = period;
+ }
+ if(diff*bestPeriod > maxDiff*period) {
+ maxDiff = diff;
+ }
+ }
+ *retMinDiff = minDiff;
+ *retMaxDiff = maxDiff;
+ return bestPeriod;
+}
+
+/* At abrupt ends of voiced words, we can have pitch periods that are better
+ aproximated by the previous pitch period estimate. Try to detect this case. */
+static int prevPeriodBetter(
+ sonicStream stream,
+ int period,
+ int minDiff,
+ int maxDiff)
+{
+ if(maxDiff*3/2 < stream->prevMaxDiff && (maxDiff*3.0f)*stream->prevMinDiff <
+ (float)stream->prevMaxDiff*minDiff*2) {
+ return 1;
+ }
+ return 0;
+}
+
+/* Find the pitch period. This is a critical step, and we may have to try
+ multiple ways to get a good answer. This version uses AMDF. To improve
+ speed, we down sample by an integer factor get in the 11KHz range, and then
+ do it again with a narrower frequency range without down sampling */
+static int findPitchPeriod(
+ sonicStream stream,
+ short *samples)
+{
+ int minPeriod = stream->minPeriod;
+ int maxPeriod = stream->maxPeriod;
+ int sampleRate = stream->sampleRate;
+ int minDiff, maxDiff, retPeriod;
+ int skip = 1;
+ int period;
+
+ if(sampleRate > SONIC_AMDF_FREQ) {
+ skip = sampleRate/SONIC_AMDF_FREQ;
+ }
+ if(stream->numChannels == 1 && skip == 1) {
+ period = findPitchPeriodInRange(samples, minPeriod, maxPeriod, &minDiff, &maxDiff);
+ } else {
+ downSampleInput(stream, samples, skip);
+ period = findPitchPeriodInRange(stream->downSampleBuffer, minPeriod/skip,
+ maxPeriod/skip, &minDiff, &maxDiff);
+ if(skip != 1) {
+ period *= skip;
+ minPeriod = period - (skip << 2);
+ maxPeriod = period + (skip << 2);
+ if(minPeriod < stream->minPeriod) {
+ minPeriod = stream->minPeriod;
+ }
+ if(maxPeriod > stream->maxPeriod) {
+ maxPeriod = stream->maxPeriod;
+ }
+ if(stream->numChannels == 1) {
+ period = findPitchPeriodInRange(samples, minPeriod, maxPeriod,
+ &minDiff, &maxDiff);
+ } else {
+ downSampleInput(stream, samples, 1);
+ period = findPitchPeriodInRange(stream->downSampleBuffer, minPeriod,
+ maxPeriod, &minDiff, &maxDiff);
+ }
+ }
+ }
+ if(prevPeriodBetter(stream, period, minDiff, maxDiff)) {
+ retPeriod = stream->prevPeriod;
+ } else {
+ retPeriod = period;
+ }
+ stream->prevMinDiff = minDiff;
+ stream->prevMaxDiff = maxDiff;
+ stream->prevPeriod = period;
+ return retPeriod;
+}
+
+/* Overlap two sound segments, ramp the volume of one down, while ramping the
+ other one from zero up, and add them, storing the result at the output. */
+static void overlapAdd(
+ int numSamples,
+ int numChannels,
+ short *out,
+ short *rampDown,
+ short *rampUp)
+{
+ short *o, *u, *d;
+ int i, t;
+
+ for(i = 0; i < numChannels; i++) {
+ o = out + i;
+ u = rampUp + i;
+ d = rampDown + i;
+ for(t = 0; t < numSamples; t++) {
+ *o = (*d*(numSamples - t) + *u*t)/numSamples;
+ o += numChannels;
+ d += numChannels;
+ u += numChannels;
+ }
+ }
+}
+
+/* Overlap two sound segments, ramp the volume of one down, while ramping the
+ other one from zero up, and add them, storing the result at the output. */
+static void overlapAddWithSeparation(
+ int numSamples,
+ int numChannels,
+ int separation,
+ short *out,
+ short *rampDown,
+ short *rampUp)
+{
+ short *o, *u, *d;
+ int i, t;
+
+ for(i = 0; i < numChannels; i++) {
+ o = out + i;
+ u = rampUp + i;
+ d = rampDown + i;
+ for(t = 0; t < numSamples + separation; t++) {
+ if(t < separation) {
+ *o = *d*(numSamples - t)/numSamples;
+ d += numChannels;
+ } else if(t < numSamples) {
+ *o = (*d*(numSamples - t) + *u*(t - separation))/numSamples;
+ d += numChannels;
+ u += numChannels;
+ } else {
+ *o = *u*(t - separation)/numSamples;
+ u += numChannels;
+ }
+ o += numChannels;
+ }
+ }
+}
+
+/* Just move the new samples in the output buffer to the pitch bufer */
+static int moveNewSamplesToPitchBuffer(
+ sonicStream stream,
+ int originalNumOutputSamples)
+{
+ int numSamples = stream->numOutputSamples - originalNumOutputSamples;
+ int numChannels = stream->numChannels;
+
+ if(stream->numPitchSamples + numSamples > stream->pitchBufferSize) {
+ stream->pitchBufferSize += (stream->pitchBufferSize >> 1) + numSamples;
+ stream->pitchBuffer = (short *)realloc(stream->pitchBuffer,
+ stream->pitchBufferSize*sizeof(short)*numChannels);
+ if(stream->pitchBuffer == NULL) {
+ return 0;
+ }
+ }
+ memcpy(stream->pitchBuffer + stream->numPitchSamples*numChannels,
+ stream->outputBuffer + originalNumOutputSamples*numChannels,
+ numSamples*sizeof(short)*numChannels);
+ stream->numOutputSamples = originalNumOutputSamples;
+ stream->numPitchSamples += numSamples;
+ return 1;
+}
+
+/* Remove processed samples from the pitch buffer. */
+static void removePitchSamples(
+ sonicStream stream,
+ int numSamples)
+{
+ int numChannels = stream->numChannels;
+ short *source = stream->pitchBuffer + numSamples*numChannels;
+
+ if(numSamples == 0) {
+ return;
+ }
+ if(numSamples != stream->numPitchSamples) {
+ memmove(stream->pitchBuffer, source, (stream->numPitchSamples -
+ numSamples)*sizeof(short)*numChannels);
+ }
+ stream->numPitchSamples -= numSamples;
+}
+
+/* Change the pitch. The latency this introduces could be reduced by looking at
+ past samples to determine pitch, rather than future. */
+static int adjustPitch(
+ sonicStream stream,
+ int originalNumOutputSamples)
+{
+ float pitch = stream->pitch;
+ int numChannels = stream->numChannels;
+ int period, newPeriod, separation;
+ int position = 0;
+ short *out, *rampDown, *rampUp;
+
+ if(stream->numOutputSamples == originalNumOutputSamples) {
+ return 1;
+ }
+ if(!moveNewSamplesToPitchBuffer(stream, originalNumOutputSamples)) {
+ return 0;
+ }
+ while(stream->numPitchSamples - position >= stream->maxRequired) {
+ period = findPitchPeriod(stream, stream->pitchBuffer + position*numChannels);
+ newPeriod = period/pitch;
+ if(!enlargeOutputBufferIfNeeded(stream, newPeriod)) {
+ return 0;
+ }
+ out = stream->outputBuffer + stream->numOutputSamples*numChannels;
+ if(pitch >= 1.0f) {
+ rampDown = stream->pitchBuffer + position*numChannels;
+ rampUp = stream->pitchBuffer + (position + period - newPeriod)*numChannels;
+ overlapAdd(newPeriod, numChannels, out, rampDown, rampUp);
+ } else {
+ rampDown = stream->pitchBuffer + position*numChannels;
+ rampUp = stream->pitchBuffer + position*numChannels;
+ separation = newPeriod - period;
+ overlapAddWithSeparation(period, numChannels, separation, out, rampDown, rampUp);
+ }
+ stream->numOutputSamples += newPeriod;
+ position += period;
+ }
+ removePitchSamples(stream, position);
+ return 1;
+}
+
+/* Skip over a pitch period, and copy period/speed samples to the output */
+static int skipPitchPeriod(
+ sonicStream stream,
+ short *samples,
+ float speed,
+ int period)
+{
+ long newSamples;
+ int numChannels = stream->numChannels;
+
+ if(speed >= 2.0f) {
+ newSamples = period/(speed - 1.0f);
+ } else if(speed > 1.0f) {
+ newSamples = period;
+ stream->remainingInputToCopy = period*(2.0f - speed)/(speed - 1.0f);
+ }
+ if(!enlargeOutputBufferIfNeeded(stream, newSamples)) {
+ return 0;
+ }
+ overlapAdd(newSamples, numChannels, stream->outputBuffer +
+ stream->numOutputSamples*numChannels, samples, samples + period*numChannels);
+ stream->numOutputSamples += newSamples;
+ return newSamples;
+}
+
+/* Insert a pitch period, and determine how much input to copy directly. */
+static int insertPitchPeriod(
+ sonicStream stream,
+ short *samples,
+ float speed,
+ int period)
+{
+ long newSamples;
+ short *out;
+ int numChannels = stream->numChannels;
+
+ if(speed < 0.5f) {
+ newSamples = period*speed/(1.0f - speed);
+ } else {
+ newSamples = period;
+ stream->remainingInputToCopy = period*(2.0f*speed - 1.0f)/(1.0f - speed);
+ }
+ if(!enlargeOutputBufferIfNeeded(stream, period + newSamples)) {
+ return 0;
+ }
+ out = stream->outputBuffer + stream->numOutputSamples*numChannels;
+ memcpy(out, samples, period*sizeof(short)*numChannels);
+ out = stream->outputBuffer + (stream->numOutputSamples + period)*numChannels;
+ overlapAdd(newSamples, numChannels, out, samples + period*numChannels, samples);
+ stream->numOutputSamples += period + newSamples;
+ return newSamples;
+}
+
+/* Resample as many pitch periods as we have buffered on the input. Return 0 if
+ we fail to resize an input or output buffer. Also scale the output by the volume. */
+static int changeSpeed(
+ sonicStream stream,
+ float speed)
+{
+ short *samples;
+ int numSamples = stream->numInputSamples;
+ int position = 0, period, newSamples;
+ int maxRequired = stream->maxRequired;
+
+ if(stream->numInputSamples < maxRequired) {
+ return 1;
+ }
+ do {
+ if(stream->remainingInputToCopy > 0) {
+ newSamples = copyInputToOutput(stream, position);
+ position += newSamples;
+ } else {
+ samples = stream->inputBuffer + position*stream->numChannels;
+ period = findPitchPeriod(stream, samples);
+ if(speed > 1.0) {
+ newSamples = skipPitchPeriod(stream, samples, speed, period);
+ position += period + newSamples;
+ } else {
+ newSamples = insertPitchPeriod(stream, samples, speed, period);
+ position += newSamples;
+ }
+ }
+ if(newSamples == 0) {
+ return 0; /* Failed to resize output buffer */
+ }
+ } while(position + maxRequired <= numSamples);
+ removeInputSamples(stream, position);
+ return 1;
+}
+
+/* Resample as many pitch periods as we have buffered on the input. Return 0 if
+ we fail to resize an input or output buffer. Also scale the output by the volume. */
+static int processStreamInput(
+ sonicStream stream)
+{
+ int originalNumOutputSamples = stream->numOutputSamples;
+ float speed = stream->speed/stream->pitch;
+
+ if(speed > 1.00001 || speed < 0.99999) {
+ changeSpeed(stream, speed);
+ } else {
+ if(!copyToOutput(stream, stream->inputBuffer, stream->numInputSamples)) {
+ return 0;
+ }
+ stream->numInputSamples = 0;
+ }
+ if(stream->pitch != 1.0f) {
+ if(!adjustPitch(stream, originalNumOutputSamples)) {
+ return 0;
+ }
+ }
+ if(stream->volume != 1.0f) {
+ /* Adjust output volume. */
+ scaleSamples(stream->outputBuffer + originalNumOutputSamples*stream->numChannels,
+ (stream->numOutputSamples - originalNumOutputSamples)*stream->numChannels,
+ stream->volume);
+ }
+ return 1;
+}
+
+/* Write floating point data to the input buffer and process it. */
+int sonicWriteFloatToStream(
+ sonicStream stream,
+ float *samples,
+ int numSamples)
+{
+ if(!addFloatSamplesToInputBuffer(stream, samples, numSamples)) {
+ return 0;
+ }
+ return processStreamInput(stream);
+}
+
+/* Simple wrapper around sonicWriteFloatToStream that does the short to float
+ conversion for you. */
+int sonicWriteShortToStream(
+ sonicStream stream,
+ short *samples,
+ int numSamples)
+{
+ if(!addShortSamplesToInputBuffer(stream, samples, numSamples)) {
+ return 0;
+ }
+ return processStreamInput(stream);
+}
+
+/* Simple wrapper around sonicWriteFloatToStream that does the unsigned char to float
+ conversion for you. */
+int sonicWriteUnsignedCharToStream(
+ sonicStream stream,
+ unsigned char *samples,
+ int numSamples)
+{
+ if(!addUnsignedCharSamplesToInputBuffer(stream, samples, numSamples)) {
+ return 0;
+ }
+ return processStreamInput(stream);
+}
+
+/* This is a non-stream oriented interface to just change the speed of a sound sample */
+int sonicChangeFloatSpeed(
+ float *samples,
+ int numSamples,
+ float speed,
+ float pitch,
+ float volume,
+ int sampleRate,
+ int numChannels)
+{
+ sonicStream stream = sonicCreateStream(sampleRate, numChannels);
+
+ sonicSetSpeed(stream, speed);
+ sonicSetPitch(stream, pitch);
+ sonicSetVolume(stream, volume);
+ sonicWriteFloatToStream(stream, samples, numSamples);
+ sonicFlushStream(stream);
+ numSamples = sonicSamplesAvailable(stream);
+ sonicReadFloatFromStream(stream, samples, numSamples);
+ sonicDestroyStream(stream);
+ return numSamples;
+}
+
+/* This is a non-stream oriented interface to just change the speed of a sound sample */
+int sonicChangeShortSpeed(
+ short *samples,
+ int numSamples,
+ float speed,
+ float pitch,
+ float volume,
+ int sampleRate,
+ int numChannels)
+{
+ sonicStream stream = sonicCreateStream(sampleRate, numChannels);
+
+ sonicSetSpeed(stream, speed);
+ sonicSetPitch(stream, pitch);
+ sonicSetVolume(stream, volume);
+ sonicWriteShortToStream(stream, samples, numSamples);
+ sonicFlushStream(stream);
+ numSamples = sonicSamplesAvailable(stream);
+ sonicReadShortFromStream(stream, samples, numSamples);
+ sonicDestroyStream(stream);
+ return numSamples;
+}
+#endif // INCLUDE_SONIC
diff --git a/navit/support/espeak/sonic.h b/navit/support/espeak/sonic.h
new file mode 100644
index 000000000..0afe7f85f
--- /dev/null
+++ b/navit/support/espeak/sonic.h
@@ -0,0 +1,138 @@
+/* Sonic library
+ Copyright 2010
+ Bill Cox
+ This file is part of the Sonic Library.
+
+ The Sonic Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/*
+The Sonic Library implements Pitch Based Resampling, which is a new algorithm
+invented by Bill Cox for the specific purpose of speeding up speech by high
+factors at high quality. It generates smooth speech at speed up factors as high
+as 6X, possibly more. It is also capable of slowing down speech, and generates
+high quality results regardless of the speed up or slow down factor. For
+speeding up speech by 2X or more, the following equation is used:
+
+ newSamples = period/(speed - 1.0)
+ scale = 1.0/newSamples;
+
+where period is the current pitch period, determined using AMDF or any other
+pitch estimator, and speed is the speedup factor. If the current position in
+the input stream is pointed to by "samples", and the current output stream
+position is pointed to by "out", then newSamples number of samples can be
+generated with:
+
+ out[t] = (samples[t]*(newSamples - t) + samples[t + period]*t)/newSamples;
+
+where t = 0 to newSamples - 1.
+
+For speed factors < 2X, an algorithm similar to PICOLA is used. The above
+algorithm is first used to double the speed of one pitch period. Then, enough
+input is directly copied from the input to the output to achieve the desired
+speed up facter, where 1.0 < speed < 2.0. The amount of data copied is derived:
+
+ speed = (2*period + length)/(period + length)
+ speed*length + speed*period = 2*period + length
+ length(speed - 1) = 2*period - speed*period
+ length = period*(2 - speed)/(speed - 1)
+
+For slowing down speech where 0.5 < speed < 1.0, a pitch period is inserted into
+the output twice, and length of input is copied from the input to the output
+until the output desired speed is reached. The length of data copied is:
+
+ length = period*(speed - 0.5)/(1 - speed)
+
+For slow down factors between 0.5 and 0.5, no data is copied, and an algorithm
+similar to high speed factors is used.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* This specifies the range of voice pitches we try to match.
+ Note that if we go lower than 65, we could overflow in findPitchInRange */
+#define SONIC_MIN_PITCH 65
+#define SONIC_MAX_PITCH 400
+
+/* These are used to down-sample some inputs to improve speed */
+#define SONIC_AMDF_FREQ 4000
+
+struct sonicStreamStruct;
+typedef struct sonicStreamStruct *sonicStream;
+
+/* For all of the following functions, numChannels is multiplied by numSamples
+ to determine the actual number of values read or returned. */
+
+/* Create a sonic stream. Return NULL only if we are out of memory and cannot
+ allocate the stream. Set numChannels to 1 for mono, and 2 for stereo. */
+sonicStream sonicCreateStream(int sampleRate, int numChannels);
+/* Destroy the sonic stream. */
+void sonicDestroyStream(sonicStream stream);
+/* Use this to write floating point data to be speed up or down into the stream.
+ Values must be between -1 and 1. Return 0 if memory realloc failed, otherwise 1 */
+int sonicWriteFloatToStream(sonicStream stream, float *samples, int numSamples);
+/* Use this to write 16-bit data to be speed up or down into the stream.
+ Return 0 if memory realloc failed, otherwise 1 */
+int sonicWriteShortToStream(sonicStream stream, short *samples, int numSamples);
+/* Use this to write 8-bit unsigned data to be speed up or down into the stream.
+ Return 0 if memory realloc failed, otherwise 1 */
+int sonicWriteUnsignedCharToStream(sonicStream stream, unsigned char *samples, int numSamples);
+/* Use this to read floating point data out of the stream. Sometimes no data
+ will be available, and zero is returned, which is not an error condition. */
+int sonicReadFloatFromStream(sonicStream stream, float *samples, int maxSamples);
+/* Use this to read 16-bit data out of the stream. Sometimes no data will
+ be available, and zero is returned, which is not an error condition. */
+int sonicReadShortFromStream(sonicStream stream, short *samples, int maxSamples);
+/* Use this to read 8-bit unsigned data out of the stream. Sometimes no data will
+ be available, and zero is returned, which is not an error condition. */
+int sonicReadUnsignedCharFromStream(sonicStream stream, unsigned char *samples, int maxSamples);
+/* Force the sonic stream to generate output using whatever data it currently
+ has. No extra delay will be added to the output, but flushing in the middle of
+ words could introduce distortion. */
+int sonicFlushStream(sonicStream stream);
+/* Return the number of samples in the output buffer */
+int sonicSamplesAvailable(sonicStream stream);
+/* Get the speed of the stream. */
+float sonicGetSpeed(sonicStream stream);
+/* Set the speed of the stream. */
+void sonicSetSpeed(sonicStream stream, float speed);
+/* Get the pitch of the stream. */
+float sonicGetPitch(sonicStream stream);
+/* Set the pitch of the stream. */
+void sonicSetPitch(sonicStream stream, float pitch);
+/* Get the scaling factor of the stream. */
+float sonicGetVolume(sonicStream stream);
+/* Set the scaling factor of the stream. */
+void sonicSetVolume(sonicStream stream, float volume);
+/* Get the sample rate of the stream. */
+int sonicGetSampleRate(sonicStream stream);
+/* Get the number of channels. */
+int sonicGetNumChannels(sonicStream stream);
+/* This is a non-stream oriented interface to just change the speed of a sound
+ sample. It works in-place on the sample array, so there must be at least
+ speed*numSamples available space in the array. Returns the new number of samples. */
+int sonicChangeFloatSpeed(float *samples, int numSamples, float speed, float pitch,
+ float volume, int sampleRate, int numChannels);
+/* This is a non-stream oriented interface to just change the speed of a sound
+ sample. It works in-place on the sample array, so there must be at least
+ speed*numSamples available space in the array. Returns the new number of samples. */
+int sonicChangeShortSpeed(short *samples, int numSamples, float speed, float pitch,
+ float volume, int sampleRate, int numChannels);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/navit/support/espeak/speak.c b/navit/support/espeak/speak.c
index ab33a867b..afd9dfafd 100755..100644
--- a/navit/support/espeak/speak.c
+++ b/navit/support/espeak/speak.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -24,9 +24,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#ifndef PLATFORM_DOS
#ifdef PLATFORM_WINDOWS
+#include <fcntl.h>
+#include <io.h>
#include <windows.h>
#include <winreg.h>
#else
@@ -36,6 +39,7 @@
#ifndef NEED_GETOPT
#include <getopt.h>
+#include <stdbool.h> // for "true"
#endif
#include <time.h>
#include <signal.h>
@@ -69,48 +73,52 @@ static const char *help_text =
"\nspeak [options] [\"<words>\"]\n\n"
"-f <text file> Text file to speak\n"
"--stdin Read text input from stdin instead of a file\n\n"
-"If neither -f nor --stdin, <words> are spoken, or if none then text is\n"
-"spoken from stdin, each line separately.\n\n"
+"If neither -f nor --stdin, then <words> are spoken, or if none then text\n"
+"is spoken from stdin, each line separately.\n\n"
"-a <integer>\n"
"\t Amplitude, 0 to 200, default is 100\n"
"-g <integer>\n"
"\t Word gap. Pause between words, units of 10mS at the default speed\n"
+"-k <integer>\n"
+"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
+"\t higher values indicate a pitch increase (try -k20).\n"
"-l <integer>\n"
"\t Line length. If not zero (which is the default), consider\n"
"\t lines less than this length as end-of-clause\n"
"-p <integer>\n"
"\t Pitch adjustment, 0 to 99, default is 50\n"
"-s <integer>\n"
-"\t Speed in words per minute 80 to 390, default is 170\n"
+"\t Speed in words per minute, 80 to 450, default is 175\n"
"-v <voice name>\n"
"\t Use voice file of this name from espeak-data/voices\n"
"-w <wave file name>\n"
-"\t Write output to this WAV file, rather than speaking it directly\n"
+"\t Write speech to this WAV file, rather than speaking it directly\n"
"-b\t Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit \n"
"-m\t Interpret SSML markup, and ignore other < > tags\n"
"-q\t Quiet, don't produce any speech (may be useful with -x)\n"
"-x\t Write phoneme mnemonics to stdout\n"
"-X\t Write phonemes mnemonics and translation trace to stdout\n"
"-z\t No final sentence pause at the end of the text\n"
-"--stdout Write speech output to stdout\n"
"--compile=<voice name>\n"
-"\t Compile the pronunciation rules and dictionary in the current\n"
-"\t directory. =<voice name> is optional and specifies which language\n"
+"\t Compile pronunciation rules and dictionary from the current\n"
+"\t directory. <voice name> specifies the language\n"
+"--ipa Write phonemes to stdout using International Phonetic Alphabet\n"
+"\t --ipa=1 Use ties, --ipa=2 Use ZWJ, --ipa=3 Separate with _\n"
"--path=\"<path>\"\n"
"\t Specifies the directory containing the espeak-data directory\n"
+"--pho Write mbrola phoneme data (.pho) to stdout or to the file in --phonout\n"
"--phonout=\"<filename>\"\n"
-"\t Write output from -x -X commands and mbrola phoneme data to this file\n"
+"\t Write phoneme output from -x -X --ipa and --pho to this file\n"
"--punct=\"<characters>\"\n"
"\t Speak the names of punctuation characters during speaking. If\n"
"\t =<characters> is omitted, all punctuation is spoken.\n"
"--split=\"<minutes>\"\n"
"\t Starts a new WAV file every <minutes>. Used with -w\n"
+"--stdout Write speech output to stdout\n"
+"--version Shows version number and date, and location of espeak-data\n"
"--voices=<language>\n"
"\t List the available voices for the specified language.\n"
-"\t If <language> is omitted, then list all voices.\n"
-"-k <integer>\n"
-"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
-"\t higher values = a pitch increase (try -k20).\n";
+"\t If <language> is omitted, then list all voices.\n";
void DisplayVoices(FILE *f_out, char *language);
@@ -155,14 +163,16 @@ void DisplayVoices(FILE *f_out, char *language)
const char *p;
int len;
int count;
- int scores = 0;
+ int c;
+ int j;
const espeak_VOICE *v;
const char *lang_name;
char age_buf[12];
+ char buf[80];
const espeak_VOICE **voices;
espeak_VOICE voice_select;
- static char genders[4] = {' ','M','F',' '};
+ static char genders[4] = {'-','M','F','-'};
if((language != NULL) && (language[0] != 0))
{
@@ -172,14 +182,13 @@ void DisplayVoices(FILE *f_out, char *language)
voice_select.gender = 0;
voice_select.name = NULL;
voices = espeak_ListVoices(&voice_select);
- scores = 1;
}
else
{
voices = espeak_ListVoices(NULL);
}
- fprintf(f_out,"Pty Language Age/Gender VoiceName File Other Langs\n");
+ fprintf(f_out,"Pty Language Age/Gender VoiceName File Other Languages\n");
for(ix=0; (v = voices[ix]) != NULL; ix++)
{
@@ -197,8 +206,16 @@ void DisplayVoices(FILE *f_out, char *language)
if(count==0)
{
- fprintf(f_out,"%2d %-12s%s%c %-17s %-11s ",
- p[0],lang_name,age_buf,genders[v->gender],v->name,v->identifier);
+ for(j=0; j < sizeof(buf); j++)
+ {
+ // replace spaces in the name
+ if((c = v->name[j]) == ' ')
+ c = '_';
+ if((buf[j] = c) == 0)
+ break;
+ }
+ fprintf(f_out,"%2d %-12s%s%c %-20s %-13s ",
+ p[0],lang_name,age_buf,genders[v->gender],buf,v->identifier);
}
else
{
@@ -207,14 +224,14 @@ void DisplayVoices(FILE *f_out, char *language)
count++;
p += len+2;
}
-// if(scores)
-// fprintf(f_out,"%3d ",v->score);
fputc('\n',f_out);
}
} // end of DisplayVoices
-
+void WVoiceChanged(voice_t *wvoice)
+{
+}
static int OpenWaveFile(const char *path, int rate)
//=================================================
@@ -229,10 +246,22 @@ static int OpenWaveFile(const char *path, int rate)
if(path == NULL)
return(2);
- if(strcmp(path,"stdout")==0)
- f_wave = stdout;
- else
- f_wave = fopen(path,"wb");
+ while(isspace(*path)) path++;
+
+ f_wave = NULL;
+ if(path[0] != 0)
+ {
+ if(strcmp(path,"stdout")==0)
+ {
+#ifdef PLATFORM_WINDOWS
+// prevent Windows adding 0x0d before 0x0a bytes
+ _setmode(_fileno(stdout), _O_BINARY);
+#endif
+ f_wave = stdout;
+ }
+ else
+ f_wave = fopen(path,"wb");
+ }
if(f_wave != NULL)
{
@@ -274,7 +303,7 @@ static void CloseWaveFile()
-void MarkerEvent(int type, unsigned int char_position, int value, unsigned char *out_ptr)
+void MarkerEvent(int type, unsigned int char_position, int value, int value2, unsigned char *out_ptr)
{//======================================================================================
// Do nothing in the command-line version.
if(type == 2)
@@ -285,7 +314,7 @@ void MarkerEvent(int type, unsigned int char_position, int value, unsigned char
static int WavegenFile(void)
{//=========================
int finished;
- unsigned char wav_outbuf[512];
+ unsigned char wav_outbuf[1024];
char fname[210];
out_ptr = out_start = wav_outbuf;
@@ -340,14 +369,12 @@ static void init_path(char *argv0, char *path_specified)
char *env;
unsigned char buf[sizeof(path_home)-12];
-#if 0
if(((env = getenv("ESPEAK_DATA_PATH")) != NULL) && ((strlen(env)+12) < sizeof(path_home)))
{
sprintf(path_home,"%s\\espeak-data",env);
if(GetFileLength(path_home) == -2)
return; // an espeak-data directory exists in the directory specified by environment variable
}
-#endif
strcpy(path_home,argv0);
if((p = strrchr(path_home,'\\')) != NULL)
@@ -370,16 +397,13 @@ static void init_path(char *argv0, char *path_specified)
strcpy(path_home,PATH_ESPEAK_DATA);
#else
char *env;
-#if 0
if((env = getenv("ESPEAK_DATA_PATH")) != NULL)
{
snprintf(path_home,sizeof(path_home),"%s/espeak-data",env);
if(GetFileLength(path_home) == -2)
return; // an espeak-data directory exists
}
-#endif
-#if 0
snprintf(path_home,sizeof(path_home),"%s/espeak-data",getenv("HOME"));
if(access(path_home,R_OK) != 0)
{
@@ -387,7 +411,6 @@ static void init_path(char *argv0, char *path_specified)
}
#endif
#endif
-#endif
}
@@ -395,6 +418,7 @@ static int initialise(void)
{//========================
int param;
int result;
+ int srate = 22050; // default sample rate
// It seems that the wctype functions don't work until the locale has been set
// to something other than the default "C". Then, not only Latin1 but also the
@@ -402,18 +426,15 @@ static int initialise(void)
#ifdef PLATFORM_RISCOS
setlocale(LC_CTYPE,"ISO8859-1");
#else
-#if 0
if(setlocale(LC_CTYPE,"en_US.UTF-8") == NULL)
{
if(setlocale(LC_CTYPE,"UTF-8") == NULL)
setlocale(LC_CTYPE,"");
}
#endif
-#endif
- WavegenInit(22050,0); // 22050
- if((result = LoadPhData()) != 1)
+ if((result = LoadPhData(&srate)) != 1)
{
if(result == -1)
{
@@ -423,8 +444,9 @@ static int initialise(void)
else
fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home);
}
+ WavegenInit(srate,0);
LoadConfig();
- SetVoiceStack(NULL);
+ SetVoiceStack(NULL, "");
SynthesizeInit();
for(param=0; param<N_SPEECH_PARAM; param++)
@@ -436,14 +458,16 @@ static int initialise(void)
static void StopSpeak(int unused)
{//==============================
-// signal(SIGINT,SIG_IGN);
+ signal(SIGINT,SIG_IGN);
// DEBUG
// printf("\n*** Interrupting speech output (use Ctrl-D to actually quit).\n");
fflush(stdout);
SpeakNextClause(NULL,NULL,5);
-// signal(SIGINT,StopSpeak);
+ signal(SIGINT,StopSpeak);
} // end of StopSpeak()
+
+
#ifdef NEED_GETOPT
struct option {
char *name;
@@ -480,7 +504,10 @@ int main (int argc, char **argv)
{"stdout", no_argument, 0, 0x105},
{"split", optional_argument, 0, 0x106},
{"path", required_argument, 0, 0x107},
- {"phonout", required_argument, 0, 0x108},
+ {"phonout", required_argument, 0, 0x108},
+ {"pho", no_argument, 0, 0x109},
+ {"ipa", optional_argument, 0, 0x10a},
+ {"version", no_argument, 0, 0x10b},
{0, 0, 0, 0}
};
@@ -493,7 +520,7 @@ int main (int argc, char **argv)
int option_index = 0;
int c;
int value;
- int speed=170;
+ int speed=175;
int ix;
char *optarg2;
int amp = 100; // default
@@ -505,11 +532,9 @@ int main (int argc, char **argv)
espeak_VOICE voice_select;
char filename[200];
char voicename[40];
- char dictname[40];
voicename[0] = 0;
mbrola_name[0] = 0;
- dictname[0] = 0;
wavefile[0] = 0;
filename[0] = 0;
option_linelength = 0;
@@ -544,6 +569,9 @@ int main (int argc, char **argv)
if(c == '-')
{
+ if(p[0] == 0)
+ break; // -- means don't interpret further - as commands
+
opt_string="";
for(ix=0; ;ix++)
{
@@ -574,7 +602,7 @@ int main (int argc, char **argv)
}
}
#else
- while(1)
+ while(true)
{
c = getopt_long (argc, argv, "a:b:f:g:hk:l:p:qs:v:w:xXmz", // NOTE: also change arg_opts to indicate which commands have a numeric value
long_options, &option_index);
@@ -595,9 +623,9 @@ int main (int argc, char **argv)
break;
case 'h':
- printf("\nspeak text-to-speech: %s\n%s",version_string,help_text);
+ init_path(argv[0],data_path);
+ printf("\nspeak text-to-speech: %s Data at: %s\n%s",version_string,path_home,help_text);
exit(0);
- break;
case 'k':
option_capitals = atoi(optarg2);
@@ -710,6 +738,30 @@ int main (int argc, char **argv)
}
break;
+ case 0x109: // --pho
+ option_mbrola_phonemes = 16;
+ break;
+
+ case 0x10a: // --ipa
+ option_phonemes = 3;
+ if(optarg2 != NULL)
+ {
+ value = -1;
+ sscanf(optarg2,"%d",&value);
+ if((value<0) || (value>3))
+ {
+ fprintf(stderr,"Bad value for -ipa=\n");
+ value = 0;
+ }
+ option_phonemes += value;
+ }
+ break;
+
+ case 0x10b: // --version
+ init_path(argv[0],data_path);
+ printf("speak text-to-speech: %s Data at: %s\n",version_string,path_home);
+ exit(0);
+
default:
exit(0);
}
@@ -718,11 +770,22 @@ int main (int argc, char **argv)
init_path(argv[0],data_path);
initialise();
+ if(voicename[0] == 0)
+ strcpy(voicename,"default");
- if(flag_compile)
+ if(SetVoiceByName(voicename) != EE_OK)
{
- LoadVoice(voicename,5);
+ memset(&voice_select,0,sizeof(voice_select));
+ voice_select.languages = voicename;
+ if(SetVoiceByProperties(&voice_select) != EE_OK)
+ {
+ fprintf(stderr,"%svoice '%s'\n",err_load,voicename);
+ exit(2);
+ }
+ }
+ if(flag_compile)
+ {
#ifdef PLATFORM_DOS
char path_dsource[sizeof(path_home)+20];
strcpy(path_dsource,path_home);
@@ -744,20 +807,6 @@ int main (int argc, char **argv)
}
- if(voicename[0] == 0)
- strcpy(voicename,"default");
-
- if(SetVoiceByName(voicename) != EE_OK)
- {
- memset(&voice_select,0,sizeof(voice_select));
- voice_select.languages = voicename;
- if(SetVoiceByProperties(&voice_select) != EE_OK)
- {
- fprintf(stderr,"%svoice '%s'\n",err_load,voicename);
- exit(2);
- }
- }
-
SetParameter(espeakRATE,speed,0);
SetParameter(espeakVOLUME,amp,0);
SetParameter(espeakCAPITALS,option_capitals,0);
diff --git a/navit/support/espeak/speak_init.c b/navit/support/espeak/speak_init.c
deleted file mode 100644
index 06a34235f..000000000
--- a/navit/support/espeak/speak_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "../../plugin.h"
-
-void
-plugin_init(void)
-{
-}
diff --git a/navit/support/espeak/speak_lib.c b/navit/support/espeak/speak_lib.c
index 85c1b39a3..99269c42f 100644
--- a/navit/support/espeak/speak_lib.c
+++ b/navit/support/espeak/speak_lib.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -32,8 +32,11 @@
#include <sys/stat.h>
#ifdef PLATFORM_WINDOWS
+#include <fcntl.h>
+#include <io.h>
#include <windows.h>
-#else
+#include <winreg.h>
+#else /* PLATFORM_POSIX */
#include <unistd.h>
#endif
@@ -48,8 +51,9 @@
#include "event.h"
#include "wave.h"
+#define double(x) ((double)(x))
+
unsigned char *outbuf=NULL;
-extern espeak_VOICE voice_selected;
espeak_EVENT *event_list=NULL;
int event_list_ix=0;
@@ -61,11 +65,23 @@ static unsigned int my_unique_identifier=0;
static void* my_user_data=NULL;
static espeak_AUDIO_OUTPUT my_mode=AUDIO_OUTPUT_SYNCHRONOUS;
static int synchronous_mode = 1;
+static int out_samplerate = 0;
+static int voice_samplerate = 22050;
+static espeak_ERROR err = EE_OK;
+
t_espeak_callback* synth_callback = NULL;
int (* uri_callback)(int, const char *, const char *) = NULL;
int (* phoneme_callback)(const char *) = NULL;
char path_home[N_PATH_HOME]; // this is the espeak-data directory
+extern int saved_parameters[N_SPEECH_PARAM]; //Parameters saved on synthesis start
+
+
+void WVoiceChanged(voice_t *wvoice)
+{//=================================
+// Voice change in wavegen
+ voice_samplerate = wvoice->samplerate;
+}
#ifdef USE_ASYNC
@@ -73,12 +89,12 @@ char path_home[N_PATH_HOME]; // this is the espeak-data directory
static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
{//======================================================================
ENTER("dispatch_audio");
-
+
int a_wave_can_be_played = fifo_is_command_enabled();
-
+
#ifdef DEBUG_ENABLED
- SHOW("*** dispatch_audio > uid=%d, [write=%p (%d bytes)], sample=%d, a_wave_can_be_played = %d\n",
- (event) ? event->unique_identifier : 0, wave_test_get_write_buffer(), 2*length,
+ SHOW("*** dispatch_audio > uid=%d, [write=%p (%d bytes)], sample=%d, a_wave_can_be_played = %d\n",
+ (event) ? event->unique_identifier : 0, wave_test_get_write_buffer(), 2*length,
(event) ? event->sample : 0,
a_wave_can_be_played);
#endif
@@ -87,6 +103,36 @@ static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
{
case AUDIO_OUTPUT_PLAYBACK:
{
+ int event_type=0;
+ if(event)
+ {
+ event_type = event->type;
+ }
+
+ if(event_type == espeakEVENT_SAMPLERATE)
+ {
+ voice_samplerate = event->id.number;
+
+ if(out_samplerate != voice_samplerate)
+ {
+ if(out_samplerate != 0)
+ {
+ // sound was previously open with a different sample rate
+ wave_close(my_audio);
+ sleep(1);
+ }
+ out_samplerate = voice_samplerate;
+ if(!wave_init(voice_samplerate))
+ {
+ err = EE_INTERNAL_ERROR;
+ return(-1);
+ }
+ wave_set_callback_is_output_enabled( fifo_is_command_enabled);
+ my_audio = wave_open("alsa");
+ event_init();
+ }
+ }
+
if (outbuf && length && a_wave_can_be_played)
{
wave_write (my_audio, (char*)outbuf, 2*length);
@@ -95,8 +141,8 @@ static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
while(a_wave_can_be_played) {
// TBD: some event are filtered here but some insight might be given
// TBD: in synthesise.cpp for avoiding to create WORDs with size=0.
- // TBD: For example sentence "or ALT)." returns three words
- // "or", "ALT" and "".
+ // TBD: For example sentence "or ALT)." returns three words
+ // "or", "ALT" and "".
// TBD: the last one has its size=0.
if (event && (event->type == espeakEVENT_WORD) && (event->length==0))
{
@@ -133,7 +179,7 @@ static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
SHOW_TIME("LEAVE dispatch_audio\n");
- return (a_wave_can_be_played==0); // 1 = stop synthesis
+ return (a_wave_can_be_played==0); // 1 = stop synthesis, -1 = error
}
@@ -144,12 +190,12 @@ static int create_events(short* outbuf, int length, espeak_EVENT* event, uint32_
int i=0;
// The audio data are written to the output device.
- // The list of events in event_list (index: event_list_ix) is read:
+ // The list of events in event_list (index: event_list_ix) is read:
// Each event is declared to the "event" object which stores them internally.
// The event object is responsible of calling the external callback
// as soon as the relevant audio sample is played.
- do
+ do
{ // for each event
espeak_EVENT* event;
if (event_list_ix == 0)
@@ -175,7 +221,7 @@ static int create_events(short* outbuf, int length, espeak_EVENT* event, uint32_
}
-int sync_espeak_terminated_msg( uint unique_identifier, void* user_data)
+int sync_espeak_terminated_msg( uint32_t unique_identifier, void* user_data)
{//=====================================================================
ENTER("sync_espeak_terminated_msg");
@@ -192,7 +238,7 @@ int sync_espeak_terminated_msg( uint unique_identifier, void* user_data)
if (my_mode==AUDIO_OUTPUT_PLAYBACK)
{
- while(1)
+ while(1)
{
espeak_ERROR a_error = event_declare(event_list);
if (a_error != EE_BUFFER_FULL)
@@ -222,17 +268,13 @@ static void select_output(espeak_AUDIO_OUTPUT output_type)
my_audio = NULL;
synchronous_mode = 1;
option_waveout = 1; // inhibit portaudio callback from wavegen.cpp
+ out_samplerate = 0;
switch(my_mode)
{
case AUDIO_OUTPUT_PLAYBACK:
+ // wave_init() is now called just before the first wave_write()
synchronous_mode = 0;
-#ifdef USE_ASYNC
- wave_init();
- wave_set_callback_is_output_enabled( fifo_is_command_enabled);
- my_audio = wave_open("alsa");
- event_init();
-#endif
break;
case AUDIO_OUTPUT_RETRIEVAL:
@@ -255,14 +297,14 @@ static void select_output(espeak_AUDIO_OUTPUT output_type)
int GetFileLength(const char *filename)
{//====================================
struct stat statbuf;
-
+
if(stat(filename,&statbuf) != 0)
return(0);
-
+
if((statbuf.st_mode & S_IFMT) == S_IFDIR)
// if(S_ISDIR(statbuf.st_mode))
return(-2); // a directory
-
+
return(statbuf.st_size);
} // end of GetFileLength
@@ -302,7 +344,7 @@ static void init_path(const char *path)
{
sprintf(path_home,"%s/espeak-data",env);
if(GetFileLength(path_home) == -2)
- return; // an espeak-data directory exists
+ return; // an espeak-data directory exists
}
buf[0] = 0;
@@ -327,7 +369,7 @@ static void init_path(const char *path)
{
snprintf(path_home,sizeof(path_home),"%s/espeak-data",env);
if(GetFileLength(path_home) == -2)
- return; // an espeak-data directory exists
+ return; // an espeak-data directory exists
}
snprintf(path_home,sizeof(path_home),"%s/espeak-data",getenv("HOME"));
@@ -338,26 +380,32 @@ static void init_path(const char *path)
#endif
}
-static int initialise(void)
-{//========================
+static int initialise(int control)
+{//===============================
int param;
int result;
+ int srate = 22050; // default sample rate 22050 Hz
+ err = EE_OK;
LoadConfig();
- WavegenInit(22050,0); // 22050
- if((result = LoadPhData()) != 1)
+
+ if((result = LoadPhData(&srate)) != 1) // reads sample rate from espeak-data/phontab
{
if(result == -1)
{
fprintf(stderr,"Failed to load espeak-data\n");
- exit(1);
+ if((control & espeakINITIALIZE_DONT_EXIT) == 0)
+ {
+ exit(1);
+ }
}
else
fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home);
}
+ WavegenInit(srate,0);
- memset(&voice_selected,0,sizeof(voice_selected));
- SetVoiceStack(NULL);
+ memset(&current_voice_selected,0,sizeof(current_voice_selected));
+ SetVoiceStack(NULL, "");
SynthesizeInit();
InitNamedata();
@@ -454,6 +502,8 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text,
{
#ifdef USE_ASYNC
finished = create_events((short *)outbuf, length, event_list, a_write_pos);
+ if(finished < 0)
+ return EE_INTERNAL_ERROR;
length = 0; // the wave data are played once.
#endif
}
@@ -483,7 +533,8 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text,
#ifdef USE_ASYNC
if (my_mode==AUDIO_OUTPUT_PLAYBACK)
{
- dispatch_audio(NULL, 0, NULL); // TBD: test case
+ if(dispatch_audio(NULL, 0, NULL) < 0) // TBD: test case
+ return err = EE_INTERNAL_ERROR;
}
else
{
@@ -496,8 +547,8 @@ static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text,
}
}
}
- }
- return(EE_OK);
+ }
+ return(EE_OK);
} // end of Synthesize
#ifdef DEBUG_ENABLED
@@ -507,31 +558,35 @@ static const char* label[] = {
"SENTENCE",
"MARK",
"PLAY",
- "END"};
+ "END",
+ "MSG_TERMINATED",
+ "PHONEME",
+ "SAMPLERATE",
+ "??" };
#endif
-void MarkerEvent(int type, unsigned int char_position, int value, unsigned char *out_ptr)
-{//======================================================================================
- // type: 1=word, 2=sentence, 3=named mark, 4=play audio, 5=end
+void MarkerEvent(int type, unsigned int char_position, int value, int value2, unsigned char *out_ptr)
+{//==================================================================================================
+ // type: 1=word, 2=sentence, 3=named mark, 4=play audio, 5=end, 7=phoneme
ENTER("MarkerEvent");
espeak_EVENT *ep;
double time;
-
+
if((event_list == NULL) || (event_list_ix >= (n_event_list-2)))
return;
-
+
ep = &event_list[event_list_ix++];
ep->type = (espeak_EVENT_TYPE)type;
ep->unique_identifier = my_unique_identifier;
ep->user_data = my_user_data;
ep->text_position = char_position & 0xffffff;
ep->length = char_position >> 24;
-
- time = ((double)(count_samples + mbrola_delay + (out_ptr - out_start)/2)*1000.0)/samplerate;
- ep->audio_position = (int)(time);
+
+ time = (double(count_samples + mbrola_delay + (out_ptr - out_start)/2)*1000.0)/samplerate;
+ ep->audio_position = ((int)(time));
ep->sample = (count_samples + mbrola_delay + (out_ptr - out_start)/2);
-
+
#ifdef DEBUG_ENABLED
SHOW("MarkerEvent > count_samples=%d, out_ptr=%x, out_start=0x%x\n",count_samples, out_ptr, out_start);
SHOW("*** MarkerEvent > type=%s, uid=%d, text_pos=%d, length=%d, audio_position=%d, sample=%d\n",
@@ -542,53 +597,69 @@ void MarkerEvent(int type, unsigned int char_position, int value, unsigned char
if((type == espeakEVENT_MARK) || (type == espeakEVENT_PLAY))
ep->id.name = &namedata[value];
else
+//#ifdef deleted
+// temporarily removed, don't introduce until after eSpeak version 1.46.02
+ if(type == espeakEVENT_PHONEME)
+ {
+ int *p;
+ p = (int *)(ep->id.string);
+ p[0] = value;
+ p[1] = value2;
+ }
+ else
+//#endif
+ {
ep->id.number = value;
+ }
} // end of MarkerEvent
-espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, size_t size,
- unsigned int position, espeak_POSITION_TYPE position_type,
+espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, size_t size,
+ unsigned int position, espeak_POSITION_TYPE position_type,
unsigned int end_position, unsigned int flags, void* user_data)
{//===========================================================================
-
+ int i;
#ifdef DEBUG_ENABLED
ENTER("sync_espeak_Synth");
SHOW("sync_espeak_Synth > position=%d, position_type=%d, end_position=%d, flags=%d, user_data=0x%x, text=%s\n", position, position_type, end_position, flags, user_data, text);
#endif
espeak_ERROR aStatus;
-
+
InitText(flags);
my_unique_identifier = unique_identifier;
my_user_data = user_data;
-
+
+ for (i=0; i < N_SPEECH_PARAM; i++)
+ saved_parameters[i] = param_stack[0].parameter[i];
+
switch(position_type)
{
case POS_CHARACTER:
skip_characters = position;
break;
-
+
case POS_WORD:
skip_words = position;
break;
-
+
case POS_SENTENCE:
skip_sentences = position;
break;
-
+
}
if(skip_characters || skip_words || skip_sentences)
skipping_text = 1;
-
+
end_character_position = end_position;
-
+
aStatus = Synthesize(unique_identifier, text, flags);
#ifdef USE_ASYNC
wave_flush(my_audio);
#endif
-
+
SHOW_TIME("LEAVE sync_espeak_Synth");
return aStatus;
} // end of sync_espeak_Synth
@@ -596,29 +667,29 @@ espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text,
-espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size,
- const char *index_mark, unsigned int end_position,
+espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size,
+ const char *index_mark, unsigned int end_position,
unsigned int flags, void* user_data)
{//=========================================================================
espeak_ERROR aStatus;
-
+
InitText(flags);
-
+
my_unique_identifier = unique_identifier;
my_user_data = user_data;
-
+
if(index_mark != NULL)
{
strncpy0(skip_marker, index_mark, sizeof(skip_marker));
skipping_text = 1;
}
-
+
end_character_position = end_position;
-
-
+
+
aStatus = Synthesize(unique_identifier, text, flags | espeakSSML);
SHOW_TIME("LEAVE sync_espeak_Synth_Mark");
-
+
return (aStatus);
} // end of sync_espeak_Synth_Mark
@@ -650,7 +721,7 @@ void sync_espeak_Char(wchar_t character)
char buf[80];
my_unique_identifier = 0;
my_user_data = NULL;
-
+
sprintf(buf,"<say-as interpret-as=\"tts:char\">&#%d;</say-as>",character);
Synthesize(0, buf,espeakSSML);
}
@@ -662,9 +733,13 @@ void sync_espeak_SetPunctuationList(const wchar_t *punctlist)
// Set the list of punctuation which are spoken for "some".
my_unique_identifier = 0;
my_user_data = NULL;
-
- wcsncpy(option_punctlist, punctlist, N_PUNCTLIST);
- option_punctlist[N_PUNCTLIST-1] = 0;
+
+ option_punctlist[0] = 0;
+ if(punctlist != NULL)
+ {
+ wcsncpy(option_punctlist, punctlist, N_PUNCTLIST);
+ option_punctlist[N_PUNCTLIST-1] = 0;
+ }
} // end of sync_espeak_SetPunctuationList
@@ -688,11 +763,12 @@ ESPEAK_API void espeak_SetUriCallback(int (* UriCallback)(int, const char*, cons
uri_callback = UriCallback;
}
-
+#if 0
ESPEAK_API void espeak_SetPhonemeCallback(int (* PhonemeCallback)(const char*))
{//===========================================================================
phoneme_callback = PhonemeCallback;
}
+#endif
ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path, int options)
{//=============================================================================================================
@@ -705,46 +781,55 @@ ENTER("espeak_Initialize");
#ifdef PLATFORM_RISCOS
setlocale(LC_CTYPE,"ISO8859-1");
#else
- if(setlocale(LC_CTYPE,"en_US.UTF-8") == NULL)
+ if(setlocale(LC_CTYPE,"C.UTF-8") == NULL)
{
if(setlocale(LC_CTYPE,"UTF-8") == NULL)
- setlocale(LC_CTYPE,"");
+ if(setlocale(LC_CTYPE,"en_US.UTF-8") == NULL)
+ setlocale(LC_CTYPE,"");
}
#endif
-
+
init_path(path);
- initialise();
+ initialise(options);
select_output(output_type);
-
+
+ if(f_logespeak)
+ {
+ fprintf(f_logespeak,"INIT mode %d options 0x%x\n",output_type,options);
+ }
+
// buflength is in mS, allocate 2 bytes per sample
- if(buf_length == 0)
+ if((buf_length == 0) || (output_type == AUDIO_OUTPUT_PLAYBACK) || (output_type == AUDIO_OUTPUT_SYNCH_PLAYBACK))
buf_length = 200;
+
outbuf_size = (buf_length * samplerate)/500;
outbuf = (unsigned char*)realloc(outbuf,outbuf_size);
if((out_start = outbuf) == NULL)
return(EE_INTERNAL_ERROR);
-
+
// allocate space for event list. Allow 200 events per second.
// Add a constant to allow for very small buf_length
n_event_list = (buf_length*200)/1000 + 20;
if((event_list = (espeak_EVENT *)realloc(event_list,sizeof(espeak_EVENT) * n_event_list)) == NULL)
return(EE_INTERNAL_ERROR);
-
+
option_phonemes = 0;
- option_phoneme_events = (options & 1);
+ option_mbrola_phonemes = 0;
+ option_phoneme_events = (options & (espeakINITIALIZE_PHONEME_EVENTS | espeakINITIALIZE_PHONEME_IPA));
+
+ VoiceReset(0);
+// SetVoiceByName("default");
- SetVoiceByName("default");
-
for(param=0; param<N_SPEECH_PARAM; param++)
- param_stack[0].parameter[param] = param_defaults[param];
-
- SetParameter(espeakRATE,170,0);
+ param_stack[0].parameter[param] = saved_parameters[param] = param_defaults[param];
+
+ SetParameter(espeakRATE,175,0);
SetParameter(espeakVOLUME,100,0);
SetParameter(espeakCAPITALS,option_capitals,0);
SetParameter(espeakPUNCTUATION,option_punctuation,0);
SetParameter(espeakWORDGAP,0,0);
- DoVoiceChange(voice);
-
+// DoVoiceChange(voice);
+
#ifdef USE_ASYNC
fifo_init();
#endif
@@ -754,10 +839,10 @@ ENTER("espeak_Initialize");
-ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
- unsigned int position,
+ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
+ unsigned int position,
espeak_POSITION_TYPE position_type,
- unsigned int end_position, unsigned int flags,
+ unsigned int end_position, unsigned int flags,
unsigned int* unique_identifier, void* user_data)
{//=====================================================================================
#ifdef DEBUG_ENABLED
@@ -765,6 +850,12 @@ ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
SHOW("espeak_Synth > position=%d, position_type=%d, end_position=%d, flags=%d, user_data=0x%x, text=%s\n", position, position_type, end_position, flags, user_data, text);
#endif
+ if(f_logespeak)
+ {
+ fprintf(f_logespeak,"\nSYNTH posn %d %d %d flags 0x%x\n%s\n",position,end_position,position_type,flags, (const char *)text);
+ fflush(f_logespeak);
+ }
+
espeak_ERROR a_error=EE_INTERNAL_ERROR;
static unsigned int temp_identifier;
@@ -812,10 +903,10 @@ ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
-ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size,
- const char *index_mark,
- unsigned int end_position,
- unsigned int flags,
+ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size,
+ const char *index_mark,
+ unsigned int end_position,
+ unsigned int flags,
unsigned int* unique_identifier,
void* user_data)
{//=========================================================================
@@ -827,6 +918,12 @@ ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size,
espeak_ERROR a_error=EE_OK;
static unsigned int temp_identifier;
+ if(f_logespeak)
+ {
+ fprintf(f_logespeak,"\nSYNTH MARK %s posn %d flags 0x%x\n%s\n",index_mark,end_position,flags, (const char *)text);
+ }
+
+
if (unique_identifier == NULL)
{
unique_identifier = &temp_identifier;
@@ -840,15 +937,15 @@ ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size,
#ifdef USE_ASYNC
// Create the mark command
- t_espeak_command* c1 = create_espeak_mark(text, size, index_mark, end_position,
+ t_espeak_command* c1 = create_espeak_mark(text, size, index_mark, end_position,
flags, user_data);
-
+
// Retrieve the unique identifier
*unique_identifier = c1->u.my_mark.unique_identifier;
-
+
// Create the "terminated msg" command (same uid)
t_espeak_command* c2 = create_espeak_terminated_msg(*unique_identifier, user_data);
-
+
// Try to add these 2 commands (single transaction)
if (c1 && c2)
{
@@ -877,6 +974,11 @@ ESPEAK_API espeak_ERROR espeak_Key(const char *key)
ENTER("espeak_Key");
// symbolic name, symbolicname_character - is there a system resource of symbolicnames per language
+ if(f_logespeak)
+ {
+ fprintf(f_logespeak,"\nKEY %s\n",key);
+ }
+
espeak_ERROR a_error = EE_OK;
if(synchronous_mode)
@@ -903,6 +1005,11 @@ ESPEAK_API espeak_ERROR espeak_Char(wchar_t character)
ENTER("espeak_Char");
// is there a system resource of character names per language?
+ if(f_logespeak)
+ {
+ fprintf(f_logespeak,"\nCHAR U+%x\n",character);
+ }
+
#ifdef USE_ASYNC
espeak_ERROR a_error;
@@ -999,6 +1106,10 @@ ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int valu
{//=============================================================================================
ENTER("espeak_SetParameter");
+ if(f_logespeak)
+ {
+ fprintf(f_logespeak,"SETPARAM %d %d %d\n",parameter,value,relative);
+ }
#ifdef USE_ASYNC
espeak_ERROR a_error;
@@ -1055,18 +1166,34 @@ ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream)
{//============================================================
ENTER("espeak_SetPhonemes");
/* Controls the output of phoneme symbols for the text
- value=0 No phoneme output (default)
- value=1 Output the translated phoneme symbols for the text
- value=2 as (1), but also output a trace of how the translation was done (matching rules and list entries)
+ bits 0-3:
+ value=0 No phoneme output (default)
+ value=1 Output the translated phoneme symbols for the text
+ value=2 as (1), but also output a trace of how the translation was done (matching rules and list entries)
+ value=3 as (1), but produces IPA phoneme names rather than ascii
+ bit 4: produce mbrola pho data
*/
- option_phonemes = value;
+ option_phonemes = value & 7;
+ option_mbrola_phonemes = value & 16;
f_trans = stream;
if(stream == NULL)
f_trans = stderr;
-
+
} // end of espeak_SetPhonemes
+ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, int phonememode)
+{//=================================================================================================
+ /* phoneme_mode bits 0-3: 0=only phoneme names, 1=ties, 2=ZWJ, 3=underscore separator
+ bits 4-7: 0=eSpeak phoneme names, 1=IPA
+ */
+
+ option_multibyte = textmode & 7;
+ *textptr = TranslateClause(translator, NULL, *textptr, NULL, NULL);
+ return(GetTranslatedPhonemeString(phonememode));
+}
+
+
ESPEAK_API void espeak_CompileDictionary(const char *path, FILE *log, int flags)
{//=============================================================================
ENTER("espeak_CompileDictionary");
@@ -1076,6 +1203,7 @@ ESPEAK_API void espeak_CompileDictionary(const char *path, FILE *log, int flags)
ESPEAK_API espeak_ERROR espeak_Cancel(void)
{//===============================
+ int i;
#ifdef USE_ASYNC
ENTER("espeak_Cancel");
fifo_stop();
@@ -1088,6 +1216,10 @@ ESPEAK_API espeak_ERROR espeak_Cancel(void)
SHOW_TIME("espeak_Cancel > LEAVE");
#endif
embedded_value[EMBED_T] = 0; // reset echo for pronunciation announcements
+
+ for (i=0; i < N_SPEECH_PARAM; i++)
+ SetParameter(i, saved_parameters[i], 0);
+
return EE_OK;
} // end of espeak_Cancel
@@ -1108,6 +1240,7 @@ ESPEAK_API int espeak_IsPlaying(void)
ESPEAK_API espeak_ERROR espeak_Synchronize(void)
{//=============================================
+ espeak_ERROR berr = err;
#ifdef USE_ASYNC
SHOW_TIME("espeak_Synchronize > ENTER");
while (espeak_IsPlaying())
@@ -1115,12 +1248,13 @@ ESPEAK_API espeak_ERROR espeak_Synchronize(void)
usleep(20000);
}
#endif
+ err = EE_OK;
SHOW_TIME("espeak_Synchronize > LEAVE");
- return EE_OK;
+ return berr;
} // end of espeak_Synchronize
-
-extern void FreePhData(void);
+#include "synthdata.h"
+#include "voices.h"
ESPEAK_API espeak_ERROR espeak_Terminate(void)
{//===========================================
@@ -1134,6 +1268,7 @@ ESPEAK_API espeak_ERROR espeak_Terminate(void)
{
wave_close(my_audio);
wave_terminate();
+ out_samplerate = 0;
}
#endif
@@ -1142,15 +1277,26 @@ ESPEAK_API espeak_ERROR espeak_Terminate(void)
Free(outbuf);
outbuf = NULL;
FreePhData();
+ FreeVoiceList();
+
+ if(f_logespeak)
+ {
+ fclose(f_logespeak);
+ f_logespeak = NULL;
+ }
return EE_OK;
} // end of espeak_Terminate
-ESPEAK_API const char *espeak_Info(void)
-{//=======================================
+ESPEAK_API const char *espeak_Info(const char **ptr)
+{//=================================================
+ if(ptr != NULL)
+ {
+ *ptr = path_home;
+ }
return(version_string);
}
#pragma GCC visibility pop
-
+
diff --git a/navit/support/espeak/speak_lib.h b/navit/support/espeak/speak_lib.h
index 25c24c173..f33e03136 100644
--- a/navit/support/espeak/speak_lib.h
+++ b/navit/support/espeak/speak_lib.h
@@ -1,7 +1,7 @@
#ifndef SPEAK_LIB_H
#define SPEAK_LIB_H
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2012 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -26,8 +26,15 @@
/*************************************************************/
#include <stdio.h>
-#include <wchar.h>
-#define ESPEAK_API_REVISION 5
+#include <stddef.h>
+
+#ifdef __WIN32__
+#define ESPEAK_API __declspec(dllexport)
+#else
+#define ESPEAK_API
+#endif
+
+#define ESPEAK_API_REVISION 9
/*
Revision 2
Added parameter "options" to eSpeakInitialize()
@@ -40,21 +47,41 @@ Revision 4
Revision 5
Added espeakCHARS_16BIT
+
+Revision 6
+ Added macros: espeakRATE_MINIMUM, espeakRATE_MAXIMUM, espeakRATE_NORMAL
+
+Revision 7 24.Dec.2011
+ Changed espeak_EVENT structure to add id.string[] for phoneme mnemonics.
+ Added espeakINITIALIZE_PHONEME_IPA option for espeak_Initialize() to report phonemes as IPA names.
+
+Revision 8 26.Apr.2013
+ Added function espeak_TextToPhonemes().
+
+Revision 9 30.May.2013
+ Changed function espeak_TextToPhonemes().
+
*/
/********************/
/* Initialization */
/********************/
+// values for 'value' in espeak_SetParameter(espeakRATE, value, 0), nominally in words-per-minute
+#define espeakRATE_MINIMUM 80
+#define espeakRATE_MAXIMUM 450
+#define espeakRATE_NORMAL 175
+
typedef enum {
espeakEVENT_LIST_TERMINATED = 0, // Retrieval mode: terminates the event list.
espeakEVENT_WORD = 1, // Start of word
- espeakEVENT_SENTENCE, // Start of sentence
- espeakEVENT_MARK, // Mark
- espeakEVENT_PLAY, // Audio element
- espeakEVENT_END, // End of sentence or clause
- espeakEVENT_MSG_TERMINATED, // End of message
- espeakEVENT_PHONEME // Phoneme, if enabled in espeak_Initialize()
+ espeakEVENT_SENTENCE = 2, // Start of sentence
+ espeakEVENT_MARK = 3, // Mark
+ espeakEVENT_PLAY = 4, // Audio element
+ espeakEVENT_END = 5, // End of sentence or clause
+ espeakEVENT_MSG_TERMINATED = 6, // End of message
+ espeakEVENT_PHONEME = 7, // Phoneme, if enabled in espeak_Initialize()
+ espeakEVENT_SAMPLERATE = 8 // internal use, set sample rate
} espeak_EVENT_TYPE;
@@ -68,11 +95,12 @@ typedef struct {
int sample; // sample id (internal use)
void* user_data; // pointer supplied by the calling program
union {
- int number; // used for WORD and SENTENCE events. For PHONEME events this is the phoneme mnemonic.
+ int number; // used for WORD and SENTENCE events.
const char *name; // used for MARK and PLAY events. UTF8 string
+ char string[8]; // used for phoneme names (UTF8). Terminated by a zero byte unless the name needs the full 8 bytes.
} id;
} espeak_EVENT;
-/*
+/*
When a message is supplied to espeak_synth, the request is buffered and espeak_synth returns. When the message is really processed, the callback function will be repetedly called.
@@ -80,16 +108,16 @@ typedef struct {
In PLAYBACK mode, the callback function is called as soon as an event happens.
- For example suppose that the following message is supplied to espeak_Synth:
+ For example suppose that the following message is supplied to espeak_Synth:
"hello, hello."
* Once processed in RETRIEVAL mode, it could lead to 3 calls of the callback function :
** Block 1:
- <audio data> +
+ <audio data> +
List of events: SENTENCE + WORD + LIST_TERMINATED
-
+
** Block 2:
<audio data> +
List of events: WORD + END + LIST_TERMINATED
@@ -126,11 +154,11 @@ typedef enum {
typedef enum {
/* PLAYBACK mode: plays the audio data, supplies events to the calling program*/
- AUDIO_OUTPUT_PLAYBACK,
+ AUDIO_OUTPUT_PLAYBACK,
/* RETRIEVAL mode: supplies audio data and events to the calling program */
AUDIO_OUTPUT_RETRIEVAL,
-
+
/* SYNCHRONOUS mode: as RETRIEVAL but doesn't return until synthesis is completed */
AUDIO_OUTPUT_SYNCHRONOUS,
@@ -147,20 +175,26 @@ typedef enum {
EE_NOT_FOUND=2
} espeak_ERROR;
+#define espeakINITIALIZE_PHONEME_EVENTS 0x0001
+#define espeakINITIALIZE_PHONEME_IPA 0x0002
+#define espeakINITIALIZE_DONT_EXIT 0x8000
#ifdef __cplusplus
extern "C"
#endif
-int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, const char *path, int options);
+ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, const char *path, int options);
/* Must be called before any synthesis functions are called.
output: the audio data can either be played by eSpeak or passed back by the SynthCallback function.
buflength: The length in mS of sound buffers passed to the SynthCallback function.
+ Value=0 gives a default of 200mS.
+ This paramater is only used for AUDIO_OUTPUT_RETRIEVAL and AUDIO_OUTPUT_SYNCHRONOUS modes.
path: The directory which contains the espeak-data directory, or NULL for the default location.
- options: bit 0: 1=allow espeakEVENT_PHONEME events.
-
+ options: bit 0: 1=allow espeakEVENT_PHONEME events.
+ bit 1: 1= espeakEVENT_PHONEME events give IPA phoneme names, not eSpeak phoneme names
+ bit 15: 1=don't exit if espeak_data is not found (used for --help)
Returns: sample rate in Hz, or -1 (EE_INTERNAL_ERROR).
*/
@@ -170,10 +204,10 @@ typedef int (t_espeak_callback)(short*, int, espeak_EVENT*);
#ifdef __cplusplus
extern "C"
#endif
-void espeak_SetSynthCallback(t_espeak_callback* SynthCallback);
+ESPEAK_API void espeak_SetSynthCallback(t_espeak_callback* SynthCallback);
/* Must be called before any synthesis functions are called.
This specifies a function in the calling program which is called when a buffer of
- speech sound data has been produced.
+ speech sound data has been produced.
The callback function is of the form:
@@ -198,7 +232,7 @@ int SynthCallback(short *wav, int numsamples, espeak_EVENT *events);
#ifdef __cplusplus
extern "C"
#endif
-void espeak_SetUriCallback(int (*UriCallback)(int, const char*, const char*));
+ESPEAK_API void espeak_SetUriCallback(int (*UriCallback)(int, const char*, const char*));
/* This function may be called before synthesis functions are used, in order to deal with
<audio> tags. It specifies a callback function which is called when an <audio> element is
encountered and allows the calling program to indicate whether the sound file which
@@ -239,7 +273,7 @@ int UriCallback(int type, const char *uri, const char *base);
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_Synth(const void *text,
+ESPEAK_API espeak_ERROR espeak_Synth(const void *text,
size_t size,
unsigned int position,
espeak_POSITION_TYPE position_type,
@@ -262,7 +296,7 @@ espeak_ERROR espeak_Synth(const void *text,
start of the text.
position_type: Determines whether "position" is a number of characters, words, or sentences.
- Values:
+ Values:
end_position: If set, this gives a character position at which speaking will stop. A value
of zero indicates no end position.
@@ -273,6 +307,7 @@ espeak_ERROR espeak_Synth(const void *text,
espeakCHARS_8BIT The 8 bit ISO-8859 character set for the particular language.
espeakCHARS_AUTO 8 bit or UTF8 (this is the default)
espeakCHARS_WCHAR Wide characters (wchar_t)
+ espeakCHARS_16BIT 16 bit characters.
espeakSSML Elements within < > are treated as SSML elements, or if not recognised are ignored.
@@ -281,13 +316,16 @@ espeak_ERROR espeak_Synth(const void *text,
espeakENDPAUSE If set then a sentence pause is added at the end of the text. If not set then
this pause is suppressed.
- unique_identifier: message identifier; helpful for identifying later
- data supplied to the callback.
+ unique_identifier: This must be either NULL, or point to an integer variable to
+ which eSpeak writes a message identifier number.
+ eSpeak includes this number in espeak_EVENT messages which are the result of
+ this call of espeak_Synth().
- user_data: pointer which will be passed to the callback function.
+ user_data: a pointer (or NULL) which will be passed to the callback function in
+ espeak_EVENT messages.
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
+ Return: EE_OK: operation achieved
+ EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -295,7 +333,7 @@ espeak_ERROR espeak_Synth(const void *text,
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_Synth_Mark(const void *text,
+ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text,
size_t size,
const char *index_mark,
unsigned int end_position,
@@ -310,8 +348,8 @@ espeak_ERROR espeak_Synth_Mark(const void *text,
For the other parameters, see espeak_Synth()
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
+ Return: EE_OK: operation achieved
+ EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -319,13 +357,13 @@ espeak_ERROR espeak_Synth_Mark(const void *text,
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_Key(const char *key_name);
+ESPEAK_API espeak_ERROR espeak_Key(const char *key_name);
/* Speak the name of a keyboard key.
If key_name is a single character, it speaks the name of the character.
Otherwise, it speaks key_name as a text string.
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
+ Return: EE_OK: operation achieved
+ EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -333,11 +371,11 @@ espeak_ERROR espeak_Key(const char *key_name);
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_Char(wchar_t character);
-/* Speak the name of the given character
+ESPEAK_API espeak_ERROR espeak_Char(wchar_t character);
+/* Speak the name of the given character
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
+ Return: EE_OK: operation achieved
+ EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -378,22 +416,23 @@ typedef enum {
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int relative);
+ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int relative);
/* Sets the value of the specified parameter.
relative=0 Sets the absolute value of the parameter.
relative=1 Sets a relative value of the parameter.
parameter:
- espeakRATE: speaking speed in word per minute.
+ espeakRATE: speaking speed in word per minute. Values 80 to 450.
- espeakVOLUME: volume in range 0-100 0=silence
+ espeakVOLUME: volume in range 0-200 or more.
+ 0=silence, 100=normal full volume, greater values may produce amplitude compression or distortion
espeakPITCH: base pitch, range 0-100. 50=normal
espeakRANGE: pitch range, range 0-100. 0-monotone, 50=normal
espeakPUNCTUATION: which punctuation characters to announce:
- value in espeak_PUNCT_TYPE (none, all, some),
+ value in espeak_PUNCT_TYPE (none, all, some),
see espeak_GetParameter() to specify which characters are announced.
espeakCAPITALS: announce capital letters by:
@@ -405,8 +444,8 @@ espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int rela
espeakWORDGAP: pause between words, units of 10mS (at the default speed)
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
+ Return: EE_OK: operation achieved
+ EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -414,7 +453,7 @@ espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int rela
#ifdef __cplusplus
extern "C"
#endif
-int espeak_GetParameter(espeak_PARAMETER parameter, int current);
+ESPEAK_API int espeak_GetParameter(espeak_PARAMETER parameter, int current);
/* current=0 Returns the default value of the specified parameter.
current=1 Returns the current value of the specified parameter, as set by SetParameter()
*/
@@ -422,14 +461,14 @@ int espeak_GetParameter(espeak_PARAMETER parameter, int current);
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist);
+ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist);
/* Specified a list of punctuation characters whose names are to be spoken when the
value of the Punctuation parameter is set to "some".
punctlist: A list of character codes, terminated by a zero character.
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
+ Return: EE_OK: operation achieved
+ EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -437,11 +476,12 @@ espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist);
#ifdef __cplusplus
extern "C"
#endif
-void espeak_SetPhonemeTrace(int value, FILE *stream);
+ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream);
/* Controls the output of phoneme symbols for the text
value=0 No phoneme output (default)
value=1 Output the translated phoneme symbols for the text
value=2 as (1), but also output a trace of how the translation was done (matching rules and list entries)
+ value=3 as (1), but produces IPA rather than ascii phoneme names
stream output stream for the phoneme symbols (and trace). If stream=NULL then it uses stdout.
*/
@@ -449,7 +489,38 @@ void espeak_SetPhonemeTrace(int value, FILE *stream);
#ifdef __cplusplus
extern "C"
#endif
-void espeak_CompileDictionary(const char *path, FILE *log, int flags);
+ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, int phonememode);
+/* Translates text into phonemes. Call espeak_SetVoiceByName() first, to select a language.
+
+ It returns a pointer to a character string which contains the phonemes for the text up to
+ end of a sentence, or comma, semicolon, colon, or similar punctuation.
+
+ textptr: The address of a pointer to the input text which is terminated by a zero character.
+ On return, the pointer has been advanced past the text which has been translated, or else set
+ to NULL to indicate that the end of the text has been reached.
+
+ textmode: Type of character codes, one of:
+ espeakCHARS_UTF8 UTF8 encoding
+ espeakCHARS_8BIT The 8 bit ISO-8859 character set for the particular language.
+ espeakCHARS_AUTO 8 bit or UTF8 (this is the default)
+ espeakCHARS_WCHAR Wide characters (wchar_t)
+ espeakCHARS_16BIT 16 bit characters.
+
+ phonememode: bits0-3:
+ 0= just phonemes.
+ 1= include ties (U+361) for phoneme names of more than one letter.
+ 2= include zero-width-joiner for phoneme names of more than one letter.
+ 3= separate phonemes with underscore characters.
+
+ bits 4-7:
+ 0= eSpeak's ascii phoneme names.
+ 1= International Phonetic Alphabet (as UTF-8 characters).
+*/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+ESPEAK_API void espeak_CompileDictionary(const char *path, FILE *log, int flags);
/* Compile pronunciation dictionary for a language which corresponds to the currently
selected voice. The required voice should be selected before calling this function.
@@ -473,7 +544,7 @@ typedef struct {
unsigned char gender; // 0=none 1=male, 2=female,
unsigned char age; // 0=not specified, or age in years
unsigned char variant; // only used when passed as a parameter to espeak_SetVoiceByProperties
- unsigned char xx1; // for internal use
+ unsigned char xx1; // for internal use
int score; // for internal use
void *spare; // for internal use
} espeak_VOICE;
@@ -502,24 +573,24 @@ typedef struct {
#ifdef __cplusplus
extern "C"
#endif
-const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec);
+ESPEAK_API const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec);
/* Reads the voice files from espeak-data/voices and creates an array of espeak_VOICE pointers.
The list is terminated by a NULL pointer
If voice_spec is NULL then all voices are listed.
- If voice spec is give, then only the voices which are compatible with the voice_spec
+ If voice spec is given, then only the voices which are compatible with the voice_spec
are listed, and they are listed in preference order.
*/
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_SetVoiceByName(const char *name);
+ESPEAK_API espeak_ERROR espeak_SetVoiceByName(const char *name);
/* Searches for a voice with a matching "name" field. Language is not considered.
"name" is a UTF8 string.
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
+ Return: EE_OK: operation achieved
+ EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -527,7 +598,7 @@ espeak_ERROR espeak_SetVoiceByName(const char *name);
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_spec);
+ESPEAK_API espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_spec);
/* An espeak_VOICE structure is used to pass criteria to select a voice. Any of the following
fields may be set:
@@ -547,7 +618,7 @@ espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_spec);
#ifdef __cplusplus
extern "C"
#endif
-espeak_VOICE *espeak_GetCurrentVoice(void);
+ESPEAK_API espeak_VOICE *espeak_GetCurrentVoice(void);
/* Returns the espeak_VOICE data for the currently selected voice.
This is not affected by temporary voice changes caused by SSML elements such as <voice> and <s>
*/
@@ -555,12 +626,12 @@ espeak_VOICE *espeak_GetCurrentVoice(void);
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_Cancel(void);
+ESPEAK_API espeak_ERROR espeak_Cancel(void);
/* Stop immediately synthesis and audio output of the current text. When this
function returns, the audio output is fully stopped and the synthesizer is ready to
synthesize a new message.
- Return: EE_OK: operation achieved
+ Return: EE_OK: operation achieved
EE_INTERNAL_ERROR.
*/
@@ -568,25 +639,25 @@ espeak_ERROR espeak_Cancel(void);
#ifdef __cplusplus
extern "C"
#endif
-int espeak_IsPlaying(void);
+ESPEAK_API int espeak_IsPlaying(void);
/* Returns 1 if audio is played, 0 otherwise.
*/
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_Synchronize(void);
+ESPEAK_API espeak_ERROR espeak_Synchronize(void);
/* This function returns when all data have been spoken.
- Return: EE_OK: operation achieved
+ Return: EE_OK: operation achieved
EE_INTERNAL_ERROR.
*/
#ifdef __cplusplus
extern "C"
#endif
-espeak_ERROR espeak_Terminate(void);
+ESPEAK_API espeak_ERROR espeak_Terminate(void);
/* last function to be called.
- Return: EE_OK: operation achieved
+ Return: EE_OK: operation achieved
EE_INTERNAL_ERROR.
*/
@@ -594,8 +665,8 @@ espeak_ERROR espeak_Terminate(void);
#ifdef __cplusplus
extern "C"
#endif
-const char *espeak_Info(void);
+ESPEAK_API const char *espeak_Info(const char **path_data);
/* Returns the version number string.
- The parameter is for future use, and should be set to NULL
+ path_data returns the path to espeak_data
*/
#endif
diff --git a/navit/support/espeak/speech.h b/navit/support/espeak/speech.h
index 9673b0c8b..cb3887ec0 100755..100644
--- a/navit/support/espeak/speech.h
+++ b/navit/support/espeak/speech.h
@@ -17,27 +17,39 @@
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
+#ifndef SPEECH_H
+#define SPEECH_H
#include <sys/types.h>
// conditional compilation options
#define INCLUDE_KLATT
+//#define INCLUDE_MBROLA
+#define INCLUDE_SONIC
#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
#define ARCH_BIG
#endif
-/* #define PLATFORM_POSIX */
+#ifdef __QNX__
+#define NEED_GETOPT
+#define NO_VARIADIC_MACROS
+#endif
+
+
+#define PLATFORM_POSIX
#define PATHSEP '/'
// USE_PORTAUDIO or USE_PULSEAUDIO are now defined in the makefile
//#define USE_PORTAUDIO
//#define USE_PULSEAUDIO
#define USE_NANOSLEEP
+#ifndef __cdecl
+#define __cdecl
+#endif
//#define ESPEAK_API extern "C"
#ifdef LIBRARY
#define USE_ASYNC
-//#define USE_MBROLA_LIB
#endif
#ifdef _ESPEAKEDIT
@@ -54,7 +66,7 @@
typedef unsigned short USHORT;
typedef unsigned char UCHAR;
typedef double DOUBLEX;
-
+typedef unsigned long long64; // use this for conversion between pointers and integers
@@ -62,19 +74,13 @@ typedef struct {
const char *mnem;
int value;
} MNEM_TAB;
-int LookupMnem(MNEM_TAB *table, char *string);
+int LookupMnem(MNEM_TAB *table, const char *string);
#ifdef PLATFORM_WINDOWS
-#define N_PATH_HOME 220
-#define ESPEAK_API
-#else
-#define N_PATH_HOME 150
-#ifdef __cplusplus
-#define ESPEAK_API extern "C"
+#define N_PATH_HOME 230
#else
-#define ESPEAK_API
-#endif
+#define N_PATH_HOME 160
#endif
extern char path_home[N_PATH_HOME]; // this is the espeak-data directory
@@ -84,3 +90,4 @@ int GetFileLength(const char *filename);
char *Alloc(int size);
void Free(void *ptr);
+#endif // SPEECH_H
diff --git a/navit/support/espeak/synth_mbrola.c b/navit/support/espeak/synth_mbrola.c
index 1055f549f..3d58c350e 100755..100644
--- a/navit/support/espeak/synth_mbrola.c
+++ b/navit/support/espeak/synth_mbrola.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -17,6 +17,8 @@
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
+
+
#include "StdAfx.h"
#include <stdio.h>
@@ -33,17 +35,16 @@
#include "translate.h"
#include "voice.h"
-extern int Read4Bytes(FILE *f);
-extern void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pitch_range);
+int option_mbrola_phonemes;
-#ifdef USE_MBROLA_LIB
+#ifdef INCLUDE_MBROLA
+#include "wavegen.h"
extern unsigned char *outbuf;
#ifndef PLATFORM_WINDOWS
-#include "mbrolib.h"
-void * mb_handle;
+#include "mbrowrap.h"
#else
#include <windows.h>
@@ -64,7 +65,7 @@ PROCVV reset_MBR;
PROCIV lastError_MBR;
PROCVCI lastErrorStr_MBR;
PROCVI setNoError_MBR;
-PROCVI setFreq_MBR;
+PROCIV getFreq_MBR;
PROCVF setVolumeRatio_MBR;
@@ -75,9 +76,9 @@ HINSTANCE hinstDllMBR = NULL;
BOOL load_MBR()
{
if(hinstDllMBR != NULL)
- return TRUE; // already loaded
+ return TRUE; // already loaded
- if (!(hinstDllMBR=LoadLibraryA("mbrola.dll")))
+ if ((hinstDllMBR=LoadLibraryA("mbrola.dll")) == 0)
return FALSE;
init_MBR =(PROCIC) GetProcAddress(hinstDllMBR,"init_MBR");
write_MBR =(PROCIC) GetProcAddress(hinstDllMBR,"write_MBR");
@@ -103,14 +104,11 @@ void unload_MBR()
}
#endif // windows
-#endif // USE_MBROLA_LIB
static MBROLA_TAB *mbrola_tab = NULL;
static int mbrola_control = 0;
-
-
-
+static int mbr_name_prefix = 0;
espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int srate)
{//===================================================================================
@@ -124,6 +122,7 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
mbrola_name[0] = 0;
mbrola_delay = 0;
+ mbr_name_prefix = 0;
if(mbrola_voice == NULL)
{
@@ -133,37 +132,50 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
}
sprintf(path,"%s/mbrola/%s",path_home,mbrola_voice);
-#ifdef USE_MBROLA_LIB
+#ifdef PLATFORM_POSIX
+ // if not found, then also look in
+ // usr/share/mbrola/xx, /usr/share/mbrola/xx/xx, /usr/share/mbrola/voices/xx
+ if(GetFileLength(path) <= 0)
+ {
+ sprintf(path,"/usr/share/mbrola/%s",mbrola_voice);
+
+ if(GetFileLength(path) <= 0)
+ {
+ sprintf(path,"/usr/share/mbrola/%s/%s",mbrola_voice,mbrola_voice);
+
+ if(GetFileLength(path) <= 0)
+ {
+ sprintf(path,"/usr/share/mbrola/voices/%s",mbrola_voice);
+ }
+ }
+ }
+ close_MBR();
+#endif
#ifdef PLATFORM_WINDOWS
if(load_MBR() == FALSE) // load mbrola.dll
- return(EE_INTERNAL_ERROR);
+ {
+ fprintf(stderr, "Can't load mbrola.dll\n");
+ return(EE_INTERNAL_ERROR);
+ }
+#endif
if(init_MBR(path) != 0) // initialise the required mbrola voice
return(EE_NOT_FOUND);
setNoError_MBR(1); // don't stop on phoneme errors
-#else
- mb_handle = mbrolib_init(srate);
- mbrolib_parameter m_parameters;
-
- if(mb_handle == NULL)
- return(EE_INTERNAL_ERROR);
-
- MBROLIB_ERROR a_status = mbrolib_set_voice(mb_handle, mbrola_voice);
- if(a_status != MBROLIB_OK)
- return(EE_NOT_FOUND);
-#endif // not windows
-#endif // USE_MBROLA_LIB
// read eSpeak's mbrola phoneme translation data, eg. en1_phtrans
sprintf(path,"%s/mbrola_ph/%s",path_home,phtrans);
size = GetFileLength(path);
- if((f_in = fopen(path,"r")) == NULL)
+ if((f_in = fopen(path,"rb")) == NULL) {
+ close_MBR();
return(EE_NOT_FOUND);
+ }
if((mbrola_tab = (MBROLA_TAB *)realloc(mbrola_tab,size)) == NULL)
{
fclose(f_in);
+ close_MBR();
return(EE_INTERNAL_ERROR);
}
@@ -173,29 +185,19 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
{
*pw++ = Read4Bytes(f_in);
}
- fread(mbrola_tab,size,1,f_in);
+ size = fread(mbrola_tab,1,size,f_in);
fclose(f_in);
-
-#ifdef USE_MBROLA_LIB
-#ifdef PLATFORM_WINDOWS
setVolumeRatio_MBR((float)(mbrola_control & 0xff) /16.0f);
-#else
- mbrolib_get_parameter(mb_handle,&m_parameters);
- m_parameters.ignore_error = 1;
- m_parameters.volume_ratio = (float)(mbrola_control & 0xff) /16.0;
- mbrolib_set_parameter(mb_handle,&m_parameters);
-#endif // not windows
-#endif // USE_MBROLA_LIB
-
- option_quiet = 1;
+// srate = getFreq_MBR();
samplerate = srate;
if(srate == 22050)
SetParameter(espeakVOICETYPE,0,0);
else
SetParameter(espeakVOICETYPE,1,0);
strcpy(mbrola_name,mbrola_voice);
- mbrola_delay = 3800; // improve synchronization of events
+// mbrola_delay = 3800; // improve synchronization of events
+ mbrola_delay = 1000; // improve synchronization of events
return(EE_OK);
} // end of LoadMbrolaTable
@@ -204,16 +206,24 @@ static int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev
{//==========================================================================================================================================
// Look up a phoneme in the mbrola phoneme name translation table
// It may give none, 1, or 2 mbrola phonemes
- int mnem = ph->mnemonic;
MBROLA_TAB *pr;
PHONEME_TAB *other_ph;
int found = 0;
+ static int mnem;
// control
// bit 0 skip the next phoneme
// bit 1 match this and Previous phoneme
// bit 2 only at the start of a word
// bit 3 don't match two phonemes across a word boundary
+ // bit 4 add this phoneme name as a prefix to the next phoneme name (used for de4 phoneme prefix '?')
+ // bit 5 only in stressed syllable
+ // bit 6 only at the end of a word
+
+ *name2=0;
+ *split=0;
+ *control=0;
+ mnem = ph->mnemonic;
pr = mbrola_tab;
while(pr->name != 0)
@@ -248,20 +258,36 @@ static int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev
if((pr->control & 4) && (plist->newword == 0)) // only at start of word
found = 0;
+ if((pr->control & 0x40) && (plist[1].newword == 0)) // only at the end of a word
+ found = 0;
+
+ if((pr->control & 0x20) && (plist->stresslevel < plist->wordstress))
+ found = 0; // only in stressed syllables
+
if(found)
{
*name2 = pr->mbr_name2;
*split = pr->percent;
*control = pr->control;
- return(pr->mbr_name);
+
+ if(pr->control & 0x10)
+ {
+ mbr_name_prefix = pr->mbr_name;
+ return(0);
+ }
+ mnem = pr->mbr_name;
+ break;
}
}
pr++;
}
- *name2=0;
- *split=0;
- *control=0;
+
+ if(mbr_name_prefix != 0)
+ {
+ mnem = (mnem << 8) | (mbr_name_prefix & 0xff);
+ }
+ mbr_name_prefix = 0;
return(mnem);
}
@@ -383,155 +409,10 @@ static char *WritePitch(int env, int pitch1, int pitch2, int split, int final)
} // end of WritePitch
-#ifdef USE_MBROLA_LIB
-
-static void MbrolaMarker(int type, int char_posn, int length, int value)
-{//=====================================================================
-
- MarkerEvent(type,(char_posn & 0xffffff) | (length << 24),value,outbuf);
-
-}
-
-
-static void MbrolaEmbedded(int &embix, int sourceix)
-{//=================================================
- // There were embedded commands in the text at this point
- unsigned int word; // bit 7=last command for this word, bits 5,6 sign, bits 0-4 command
- unsigned int value;
- int command;
- int sign=0;
-
- do {
- word = embedded_list[embix++];
- value = word >> 8;
- command = word & 0x1f;
-
- if((word & 0x60) == 0x60)
- sign = -1;
- else
- if((word & 0x60) == 0x40)
- sign = 1;
-
- if(command < N_EMBEDDED_VALUES)
- {
- if(sign == 0)
- embedded_value[command] = value;
- else
- embedded_value[command] += (value * sign);
- }
-
- switch(command & 0x1f)
- {
- case EMBED_M: // named marker
- MbrolaMarker(espeakEVENT_MARK, (sourceix & 0x7ff) + clause_start_char, 0, value);
- break;
- }
- } while ((word & 0x80) == 0);
-}
-
-
-#ifdef PLATFORM_WINDOWS
-static int MbrolaSynth(char *p_mbrola)
-{//===================================
-// p_mbrola is a string of mbrola pho lines - Windows
- int len;
- int finished;
- int result=0;
-
- if(synth_callback == NULL)
- return(1);
-
- if(p_mbrola == NULL)
- flush_MBR();
- else
- result = write_MBR(p_mbrola);
-
-
- finished = 0;
- while(!finished && ((len = read_MBR((short *)outbuf, outbuf_size/2)) > 0))
- {
- out_ptr = outbuf + len*2;
-
- if(event_list)
- {
- event_list[event_list_ix].type = espeakEVENT_LIST_TERMINATED; // indicates end of event list
- event_list[event_list_ix].user_data = 0;
- }
- count_samples += len;
- finished = synth_callback((short *)outbuf, len, event_list);
- event_list_ix=0;
- }
-
- if(finished)
- {
- // cancelled by user, discard any unused mbrola speech
- flush_MBR();
- while((len = read_MBR((short *)outbuf, outbuf_size/2)) > 0);
- }
- return(finished);
-} // end of SynthMbrola
-#else
-
-static int MbrolaSynth(char *p_mbrola)
-{//===================================
-// p_mbrola is a string of mbrola pho lines - Linux
-
-// This is wrong
-// It must be called from WavegenFill()
-
- int len;
- int finished;
- int result=0;
-
- if(synth_callback == NULL)
- return(1);
-
- if(p_mbrola == NULL)
- mbrolib_flush(mb_handle);
- else
- result = mbrolib_write(mb_handle,p_mbrola,strlen(p_mbrola));
-
-
- finished = 0;
- while(!finished && (mbrolib_read(mb_handle, (short *)out_ptr, (out_end - out_ptr)/2, &len) == MBROLIB_OK))
- {
- if(len == 0)
- break;
-
- out_ptr += (len*2);
-
- if(event_list)
- {
- event_list[event_list_ix].type = espeakEVENT_LIST_TERMINATED; // indicates end of event list
- event_list[event_list_ix].user_data = 0;
- }
- count_samples += len;
- finished = synth_callback((short *)outbuf, len, event_list);
- event_list_ix=0;
- }
-
- if(finished)
- {
- // cancelled by user, discard any unused mbrola speech
- mbrolib_flush(mb_handle);
- while(mbrolib_read(mb_handle, (short *)outbuf, outbuf_size/2, &len) == MBROLIB_OK)
- {
- if(len == 0)
- break;
- }
- }
- return(finished);
-} // end of SynthMbrola
-#endif // not windows
-#endif // USE_MBROLA_LIB
-
-
-
-void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola)
-{//======================================================================
+int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbrola)
+{//=================================================================================
// Generate a mbrola pho file
unsigned int name;
- int phix;
int len;
int len1;
PHONEME_TAB *ph;
@@ -539,7 +420,8 @@ void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola)
PHONEME_TAB *ph_prev;
PHONEME_LIST *p;
PHONEME_LIST *next;
- PHONEME_LIST *prev;
+ PHONEME_DATA phdata;
+ FMT_PARAMS fmtp;
int pause = 0;
int released;
int name2;
@@ -547,75 +429,76 @@ void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola)
int done;
int len_percent;
const char *final_pitch;
- char buf[80];
+ char *ptr;
char mbr_buf[120];
-#ifdef USE_MBROLA_LIB
- int embedded_ix=0;
- int word_count=0;
+ static int phix;
+ static int embedded_ix;
+ static int word_count;
- event_list_ix = 0;
- out_ptr = outbuf;
-#ifdef PLATFORM_WINDOWS
- setNoError_MBR(1); // don't stop on phoneme errors
-#endif
-#else
-// fprintf(f_mbrola,";; v=%.2f\n",(float)(mbrola_control & 0xff)/16.0); // ;; v= has no effect on mbrola
-#endif
+ if (!resume) {
+ phix = 1;
+ embedded_ix = 0;
+ word_count = 0;
+ }
- for(phix=1; phix < n_phonemes; phix++)
+ while (phix < n_phonemes)
{
- mbr_buf[0] = 0;
+ if (WcmdqFree() < MIN_WCMDQ)
+ return 1;
+
+ ptr = mbr_buf;
p = &plist[phix];
next = &plist[phix+1];
- prev = &plist[phix-1];
ph = p->ph;
ph_prev = plist[phix-1].ph;
ph_next = plist[phix+1].ph;
-#ifdef USE_MBROLA_LIB
if(p->synthflags & SFLAG_EMBEDDED)
{
- MbrolaEmbedded(embedded_ix, p->sourceix);
+ DoEmbedded(&embedded_ix, p->sourceix);
}
- if(p->newword & 4)
- MbrolaMarker(espeakEVENT_SENTENCE, (p->sourceix & 0x7ff) + clause_start_char, 0, count_sentences);
+ if(p->newword & 4)
+ DoMarker(espeakEVENT_SENTENCE, (p->sourceix & 0x7ff) + clause_start_char, 0, count_sentences);
if(p->newword & 1)
- MbrolaMarker(espeakEVENT_WORD, (p->sourceix & 0x7ff) + clause_start_char, p->sourceix >> 11, clause_start_word + word_count++);
-#endif
+ DoMarker(espeakEVENT_WORD, (p->sourceix & 0x7ff) + clause_start_char, p->sourceix >> 11, clause_start_word + word_count++);
name = GetMbrName(p,ph,ph_prev,ph_next,&name2,&len_percent,&control);
if(control & 1)
phix++;
- if(name == 0)
+ if(name == 0) {
+ phix++;
continue; // ignore this phoneme
+ }
if((ph->type == phPAUSE) && (name == ph->mnemonic))
{
// a pause phoneme, which has not been changed by the translation
name = '_';
- len = (p->length * speed.speed_factor1)/256;
+ len = (p->length * speed.pause_factor)/256;
// if(len == 0) continue;
if(len == 0)
len = 1;
}
else
- len = (80 * speed.speed_factor2)/256;
+ len = (80 * speed.wav_factor)/256;
-#ifdef USE_MBROLA_LIB
- MbrolaMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, ph->mnemonic);
-#endif
+ if(ph->code != phonEND_WORD)
+ {
+ char phoneme_name[16];
+ WritePhMnemonic(phoneme_name, p->ph, p, option_phoneme_events & espeakINITIALIZE_PHONEME_IPA, NULL);
+ DoPhonemeMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, phoneme_name);
+ }
- sprintf(buf,"%s\t",WordToString(name));
- strcat(mbr_buf,buf);
+ ptr += sprintf(ptr,"%s\t",WordToString(name));
if(name2 == '_')
{
// add a pause after this phoneme
- pause = PauseLength(len_percent,0);
+ pause = len_percent;
name2 = 0;
}
@@ -635,17 +518,19 @@ void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola)
if(name2 == 0)
{
- sprintf(buf,"%d\t%s", len, WritePitch(p->env,p->pitch1,p->pitch2,0,0));
- strcat(mbr_buf,buf);
+ char *pitch = WritePitch(p->env,p->pitch1,p->pitch2,0,0);
+ ptr += sprintf(ptr,"%d\t%s", len, pitch);
}
else
{
+ char *pitch;
+
+ pitch = WritePitch(p->env,p->pitch1,p->pitch2,len_percent,0);
len1 = (len * len_percent)/100;
- sprintf(buf,"%d\t%s", len1, WritePitch(p->env,p->pitch1,p->pitch2,len_percent,0));
- strcat(mbr_buf,buf);
+ ptr += sprintf(ptr,"%d\t%s", len1, pitch);
- sprintf(buf,"%s\t%d\t%s", WordToString(name2), len-len1, WritePitch(p->env,p->pitch1,p->pitch2,-len_percent,0));
- strcat(mbr_buf,buf);
+ pitch = WritePitch(p->env,p->pitch1,p->pitch2,-len_percent,0);
+ ptr += sprintf(ptr,"%s\t%d\t%s", WordToString(name2), len-len1, pitch);
}
done = 1;
break;
@@ -655,23 +540,25 @@ void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola)
if(next->type==phVOWEL) released = 1;
if(next->type==phLIQUID && !next->newword) released = 1;
- if(released)
- len = DoSample(p->ph,next->ph,2,0,-1);
- else
- len = DoSample(p->ph,phoneme_tab[phonPAUSE],2,0,-1);
+ if(released == 0)
+ p->synthflags |= SFLAG_NEXT_PAUSE;
+ InterpretPhoneme(NULL, 0, p, &phdata, NULL);
+ len = DoSample3(&phdata, 0, -1);
+
len = (len * 1000)/samplerate; // convert to mS
len += PauseLength(p->prepause,1);
break;
case phVSTOP:
- len = (80 * speed.speed_factor2)/256;
+ len = (80 * speed.wav_factor)/256;
break;
case phFRICATIVE:
len = 0;
+ InterpretPhoneme(NULL, 0, p, &phdata, NULL);
if(p->synthflags & SFLAG_LENGTHEN)
- len = DoSample(ph,ph_next,2,p->length,-1); // play it twice for [s:] etc.
- len += DoSample(ph,ph_next,2,p->length,-1);
+ len = DoSample3(&phdata, p->length, -1); // play it twice for [s:] etc.
+ len += DoSample3(&phdata, p->length, -1);
len = (len * 1000)/samplerate; // convert to mS
break;
@@ -679,7 +566,11 @@ void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola)
case phNASAL:
if(next->type != phVOWEL)
{
- len = DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,-1);
+ memset(&fmtp, 0, sizeof(fmtp));
+ InterpretPhoneme(NULL, 0, p, &phdata, NULL);
+ fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
+ len = DoSpect2(p->ph, 0, &fmtp, p, -1);
+// len = DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,-1);
len = (len * 1000)/samplerate;
if(next->type == phPAUSE)
len += 50;
@@ -701,60 +592,139 @@ void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola)
if(name2 != 0)
{
len1 = (len * len_percent)/100;
- sprintf(buf,"%d\n%s\t",len1,WordToString(name2));
- strcat(mbr_buf,buf);
+ ptr += sprintf(ptr,"%d\n%s\t",len1,WordToString(name2));
len -= len1;
}
- sprintf(buf,"%d%s\n",len,final_pitch);
- strcat(mbr_buf,buf);
+ ptr += sprintf(ptr,"%d%s\n",len,final_pitch);
}
if(pause)
{
- sprintf(buf,"_ \t%d\n",PauseLength(pause,0));
- strcat(mbr_buf,buf);
+ len += PauseLength(pause,0);
+ ptr += sprintf(ptr,"_ \t%d\n",PauseLength(pause,0));
pause = 0;
}
if(f_mbrola)
{
- fwrite(mbr_buf,1,strlen(mbr_buf),f_mbrola); // write .pho to a file
+ fwrite(mbr_buf,1,(ptr-mbr_buf),f_mbrola); // write .pho to a file
}
else
{
-#ifdef USE_MBROLA_LIB
- if(MbrolaSynth(mbr_buf) != 0)
- return;
-#endif
+ int res = write_MBR(mbr_buf);
+ if (res < 0)
+ return 0; /* don't get stuck on error */
+ if (res == 0)
+ return 1;
+ wcmdq[wcmdq_tail][0] = WCMD_MBROLA_DATA;
+ wcmdq[wcmdq_tail][1] = len;
+ WcmdqInc();
}
+
+ phix++;
}
-#ifdef USE_MBROLA_LIB
- MbrolaSynth(NULL);
-#endif
+ if(!f_mbrola)
+ {
+ flush_MBR();
+
+ // flush the mbrola output buffer
+ wcmdq[wcmdq_tail][0] = WCMD_MBROLA_DATA;
+ wcmdq[wcmdq_tail][1] = 500;
+ WcmdqInc();
+ }
+
+ return 0;
} // end of MbrolaTranslate
-#ifdef TEST_MBROLA
+int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
+{//==================================================================
+ FILE *f_mbrola = NULL;
-static PHONEME_LIST mbrola_phlist;
-static int mbrola_n_ph;
-static int mbrola_phix;
+ if(*n_ph == 0)
+ return(0);
+ if(option_mbrola_phonemes)
+ {
+ // send mbrola data to a file, not to the mbrola library
+ f_mbrola = f_trans;
+ }
-int MbrolaFill(int fill_zeros)
-{//===========================
+ int again = MbrolaTranslate(phoneme_list, *n_ph, resume, f_mbrola);
+ if (!again)
+ *n_ph = 0;
+ return again;
}
-int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
-{//==================================================================
- if(resume == 0)
+
+int MbrolaFill(int length, int resume, int amplitude)
+{//==================================================
+// Read audio data from Mbrola (length is in millisecs)
+
+ static int n_samples;
+ int req_samples, result;
+ int ix;
+ short value16;
+ int value;
+
+ if (!resume)
+ n_samples = samplerate * length / 1000;
+
+ req_samples = (out_end - out_ptr)/2;
+ if (req_samples > n_samples)
+ req_samples = n_samples;
+ result = read_MBR((short *)out_ptr, req_samples);
+ if (result <= 0)
+ return 0;
+
+ for(ix=0; ix < result; ix++)
{
- mbrola_phlist = phoneme_list;
- mbrola_n_ph = n_ph;
- mbrola_phix = 0;
+ value16 = out_ptr[0] + (out_ptr[1] << 8);
+ value = value16 * amplitude;
+ value = value / 40; // adjust this constant to give a suitable amplitude for mbrola voices
+ if(value > 0x7fff)
+ value = 0x7fff;
+ if(value < -0x8000)
+ value = 0x8000;
+ out_ptr[0] = value;
+ out_ptr[1] = value >> 8;
+ out_ptr += 2;
}
+ n_samples -= result;
+ return n_samples ? 1 : 0;
+}
- resume(0); // finished phoneme list
+
+void MbrolaReset(void)
+{//===================
+// Reset the Mbrola engine and flush the pending audio
+
+ reset_MBR();
}
-#endif
+
+#else // INCLUDE_MBROLA
+
+// mbrola interface is not compiled, provide dummy functions.
+
+espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int srate)
+{
+ return(EE_INTERNAL_ERROR);
+}
+
+int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
+{
+ return(0);
+}
+
+int MbrolaFill(int length, int resume, int amplitude)
+{
+ return(0);
+}
+
+void MbrolaReset(void)
+{
+}
+
+
+#endif // INCLUDE_MBROLA
diff --git a/navit/support/espeak/synthdata.c b/navit/support/espeak/synthdata.c
index 4f8234beb..4508bab92 100755..100644
--- a/navit/support/espeak/synthdata.c
+++ b/navit/support/espeak/synthdata.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
+#include <stdbool.h>
#include <wctype.h>
#include <string.h>
@@ -35,10 +36,14 @@
#include "translate.h"
#include "wave.h"
-const char *version_string = "1.41.01 25.Aug.09";
-const int version_phdata = 0x014100;
+#include "synthdata.h"
+
+const char *version_string = "1.48.03 04.Mar.14";
+const int version_phdata = 0x014801;
int option_device_number = -1;
+FILE *f_logespeak = NULL;
+int logging_type;
// copy the current phoneme table into here
int n_phoneme_tab;
@@ -46,8 +51,8 @@ int current_phoneme_table;
PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
unsigned char phoneme_tab_flags[N_PHONEME_TAB]; // bit 0: not inherited
-static unsigned int *phoneme_index=NULL;
-char *spects_data=NULL;
+USHORT *phoneme_index=NULL;
+char *phondata_ptr=NULL;
unsigned char *wavefile_data=NULL;
static unsigned char *phoneme_tab_data = NULL;
@@ -65,12 +70,12 @@ int vowel_transition[4];
int vowel_transition0;
int vowel_transition1;
-int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsigned int data2, PHONEME_TAB *other_ph, int which);
+extern int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsigned int data2, PHONEME_TAB *other_ph, int which);
-static char *ReadPhFile(void *ptr, const char *fname)
-{//==================================================
+static char *ReadPhFile(void *ptr, const char *fname, int *size)
+{//=============================================================
FILE *f_in;
char *p;
unsigned int length;
@@ -78,7 +83,7 @@ static char *ReadPhFile(void *ptr, const char *fname)
sprintf(buf,"%s%c%s",path_home,PATHSEP,fname);
length = GetFileLength(buf);
-
+
if((f_in = fopen(buf,"rb")) == NULL)
{
fprintf(stderr,"Can't read data file: '%s'\n",buf);
@@ -87,7 +92,7 @@ static char *ReadPhFile(void *ptr, const char *fname)
if(ptr != NULL)
Free(ptr);
-
+
if((p = Alloc(length)) == NULL)
{
fclose(f_in);
@@ -100,31 +105,41 @@ static char *ReadPhFile(void *ptr, const char *fname)
}
fclose(f_in);
+ if(size != NULL)
+ *size = length;
return(p);
} // end of ReadPhFile
-int LoadPhData()
-{//=============
+int LoadPhData(int *srate)
+{//========================
int ix;
int n_phonemes;
int version;
int result = 1;
+ int length;
+ int rate;
unsigned char *p;
+ int *pw;
- if((phoneme_tab_data = (unsigned char *)ReadPhFile((void *)(phoneme_tab_data),"phontab")) == NULL)
+ if((phoneme_tab_data = (unsigned char *)ReadPhFile((void *)(phoneme_tab_data),"phontab",NULL)) == NULL)
return(-1);
- if((phoneme_index = (unsigned int *)ReadPhFile((void *)(phoneme_index),"phonindex")) == NULL)
+ if((phoneme_index = (USHORT *)ReadPhFile((void *)(phoneme_index),"phonindex",NULL)) == NULL)
return(-1);
- if((spects_data = ReadPhFile((void *)(spects_data),"phondata")) == NULL)
+ if((phondata_ptr = ReadPhFile((void *)(phondata_ptr),"phondata",NULL)) == NULL)
return(-1);
- wavefile_data = (unsigned char *)spects_data;
+ if((tunes = (TUNE *)ReadPhFile((void *)(tunes),"intonations",&length)) == NULL)
+ return(-1);
+ wavefile_data = (unsigned char *)phondata_ptr;
+ n_tunes = length / sizeof(TUNE);
- // read the version number from the first 4 bytes of phondata
- version = 0;
+ // read the version number and sample rate from the first 8 bytes of phondata
+ version = 0; // bytes 0-3, version number
+ rate = 0; // bytes 4-7, sample rate
for(ix=0; ix<4; ix++)
{
version += (wavefile_data[ix] << (ix*8));
+ rate += (wavefile_data[ix+4] << (ix*8));
}
if(version != version_phdata)
@@ -142,7 +157,9 @@ int LoadPhData()
n_phonemes = p[0];
phoneme_tab_list[ix].n_phonemes = p[0];
phoneme_tab_list[ix].includes = p[1];
- p += 4;
+ pw = (int *)p;
+ phoneme_tab_list[ix].equivalence_tables = Reverse4Bytes(pw[1]);
+ p += 8;
memcpy(phoneme_tab_list[ix].name,p,N_PHONEME_TAB_NAME);
p += N_PHONEME_TAB_NAME;
phoneme_tab_list[ix].phoneme_tab_ptr = (PHONEME_TAB *)p;
@@ -152,6 +169,10 @@ int LoadPhData()
if(phoneme_tab_number >= n_phoneme_tables)
phoneme_tab_number = 0;
+ if(srate != NULL)
+ {
+ *srate = rate;
+ }
return(result);
} // end of LoadPhData
@@ -160,10 +181,12 @@ void FreePhData(void)
{//==================
Free(phoneme_tab_data);
Free(phoneme_index);
- Free(spects_data);
+ Free(phondata_ptr);
+ Free(tunes);
phoneme_tab_data=NULL;
phoneme_index=NULL;
- spects_data=NULL;
+ phondata_ptr=NULL;
+ tunes=NULL;
}
@@ -202,172 +225,9 @@ int LookupPhonemeString(const char *string)
-static unsigned int LookupSound2(int index, unsigned int other_phcode, int control)
-{//================================================================================
-// control=1 get formant transition data only
- unsigned int code;
- unsigned int value, value2;
-
- while((value = phoneme_index[index++]) != 0)
- {
- if((code = (value & 0xff)) == other_phcode)
- {
- while(((value2 = phoneme_index[index]) != 0) && ((value2 & 0xff) < 8))
- {
- switch(value2 & 0xff)
- {
- case 0:
- // next entry is a wavefile to be played along with the synthesis
- if(control==0)
- {
- wavefile_ix = value2 >> 8;
- }
- break;
- case 1:
- if(control==0)
- {
- seq_len_adjust = value2 >> 8;
- }
- break;
- case 2:
- if(control==0)
- {
- seq_len_adjust = value2 >> 8;
- seq_len_adjust = -seq_len_adjust;
- }
- break;
- case 3:
- if(control==0)
- {
- wavefile_amp = value2 >> 8;
- }
- break;
- case 4:
- // formant transition data, 2 words
- vowel_transition[0] = value2 >> 8;
- vowel_transition[1] = phoneme_index[index++ + 1];
- break;
- case 5:
- // formant transition data, 2 words
- vowel_transition[2] = value2 >> 8;
- vowel_transition[3] = phoneme_index[index++ + 1];
- break;
- }
- index++;
- }
- return(value >> 8);
- }
- else
- if((code == 4) || (code == 5))
- {
- // formant transition data, ignore next word of data
- index++;
- }
- }
- return(3); // not found
-} // end of LookupSound2
-
-
-unsigned int LookupSound(PHONEME_TAB *this_ph, PHONEME_TAB *other_ph, int which, int *match_level, int control)
-{//============================================================================================================
- // follows, 1 other_ph preceeds this_ph, 2 other_ph follows this_ph
- // control: 1= get formant transition data only
- int spect_list;
- int spect_list2;
- int s_list;
- unsigned char virtual_ph;
- int result;
- int level=0;
- unsigned int other_code;
- unsigned int other_virtual;
-
- if(control==0)
- {
- wavefile_ix = 0;
- wavefile_amp = 32;
- seq_len_adjust = 0;
- }
- memset(vowel_transition,0,sizeof(vowel_transition));
-
- other_code = other_ph->code;
- if(phoneme_tab[other_code]->type == phPAUSE)
- other_code = phonPAUSE_SHORT; // use this version of Pause for matching
-
- if(which==1)
- {
- spect_list = this_ph->after;
- virtual_ph = this_ph->start_type;
- spect_list2 = phoneme_tab[virtual_ph]->after;
- other_virtual = other_ph->end_type;
- }
- else
- {
- spect_list = this_ph->before;
- virtual_ph = this_ph->end_type;
- spect_list2 = phoneme_tab[virtual_ph]->before;
- other_virtual = other_ph->start_type;
- }
-
- result = 3;
- // look for ph1-ph2 combination
- if((s_list = spect_list) != 0)
- {
- if((result = LookupSound2(s_list,other_code,control)) != 3)
- {
- level = 2;
- }
- else
- if(other_virtual != 0)
- {
- if((result = LookupSound2(spect_list,other_virtual,control)) != 3)
- {
- level = 1;
- }
- }
- }
- // not found, look in a virtual phoneme if one is given for this phoneme
- if((result==3) && (virtual_ph != 0) && ((s_list = spect_list2) != 0))
- {
- if((result = LookupSound2(s_list,other_code,control)) != 3)
- {
- level = 1;
- }
- else
- if(other_virtual != 0)
- {
- if((result = LookupSound2(spect_list2,other_virtual,control)) != 3)
- {
- level = 1;
- }
- }
- }
-
- if(match_level != NULL)
- *match_level = level;
-
- if(result==0)
- return(0); // NULL was given in the phoneme source
-
- // note: values = 1 indicates use the default for this phoneme, even though we found a match
- // which set a secondary reference
- if(result >= 4)
- {
- // values 1-3 can be used for special codes
- // 1 = DFT from the phoneme source file
- return(result);
- }
-
- // no match found for other_ph, return the default
- return(LookupSound2(this_ph->spect,phonPAUSE,control));
-
-} // end of LookupSound
-
-
-
-frameref_t *LookupSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph,
- int which, int *match_level, int *n_frames, PHONEME_LIST *plist)
-{//=========================================================================================================
+frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, int *n_frames, PHONEME_LIST *plist)
+{//===================================================================================================================
int ix;
int nf;
int nf1;
@@ -378,19 +238,10 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB
int length_factor;
SPECT_SEQ *seq, *seq2;
SPECT_SEQK *seqk, *seqk2;
- PHONEME_TAB *next2_ph;
frame_t *frame;
static frameref_t frames_buf[N_SEQ_FRAMES];
-
- PHONEME_TAB *other_ph;
- if(which == 1)
- other_ph = prev_ph;
- else
- other_ph = next_ph;
- if((ix = LookupSound(this_ph,other_ph,which,match_level,0)) < 4)
- return(NULL);
- seq = (SPECT_SEQ *)(&spects_data[ix]);
+ seq = (SPECT_SEQ *)(&phondata_ptr[fmt_params->fmt_addr]);
seqk = (SPECT_SEQK *)seq;
nf = seq->n_frames;
@@ -398,8 +249,8 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB
if(nf >= N_SEQ_FRAMES)
nf = N_SEQ_FRAMES - 1;
+ seq_len_adjust = fmt_params->fmt2_lenadj + fmt_params->fmt_length;
seq_break = 0;
- length1 = 0;
for(ix=0; ix<nf; ix++)
{
@@ -427,50 +278,25 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB
nf -= seq_break;
}
}
-
+
// do we need to modify a frame for blending with a consonant?
- if(this_ph->type == phVOWEL)
+ if((this_ph->type == phVOWEL) && (fmt_params->fmt2_addr == 0) && (fmt_params->use_vowelin))
{
- if((which==2) && ((frames[nf-1].frflags & FRFLAG_BREAK) == 0))
- {
- // lookup formant transition for the following phoneme
-
- if((*match_level == 0) || (next_ph->type == phNASAL))
- {
- LookupSound(next_ph,this_ph,1,NULL,1);
- seq_len_adjust += FormantTransition2(frames,&nf,vowel_transition[2],vowel_transition[3],next_ph,which);
- }
- else
- if(next_ph->phflags == phVOWEL2)
- {
- // not really a consonant, rather a coloured vowel
- if(LookupSound(next_ph,this_ph,1,NULL,1) == 0)
- {
- next2_ph = plist[2].ph;
- LookupSound(next2_ph,next_ph,1,NULL,1);
- seq_len_adjust += FormantTransition2(frames,&nf,vowel_transition[2],vowel_transition[3],next2_ph,which);
- }
- }
- }
- else
- {
- if(*match_level == 0)
- seq_len_adjust = FormantTransition2(frames,&nf,vowel_transition0,vowel_transition1,prev_ph,which);
- }
+ seq_len_adjust += FormantTransition2(frames,&nf,fmt_params->transition0,fmt_params->transition1,NULL,which);
}
+ length1 = 0;
nf1 = nf - 1;
for(ix=0; ix<nf1; ix++)
length1 += frames[ix].length;
-
- if((wavefile_ix != 0) && ((wavefile_ix & 0x800000)==0))
+ if(fmt_params->fmt2_addr != 0)
{
// a secondary reference has been returned, which is not a wavefile
// add these spectra to the main sequence
- seq2 = (SPECT_SEQ *)(&spects_data[wavefile_ix]);
+ seq2 = (SPECT_SEQ *)(&phondata_ptr[fmt_params->fmt2_addr]);
seqk2 = (SPECT_SEQK *)seq2;
-
+
// first frame of the addition just sets the length of the last frame of the main seq
nf--;
for(ix=0; ix<seq2->n_frames; ix++)
@@ -490,25 +316,25 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB
}
wavefile_ix = 0;
}
-
- if((this_ph->type == phVOWEL) && (length1 > 0))
+
+ if(length1 > 0)
{
if(which==2)
{
// adjust the length of the main part to match the standard length specified for the vowel
// less the front part of the vowel and any added suffix
-
- length_std = this_ph->std_length + seq_len_adjust - 45;
+
+ length_std = fmt_params->std_length + seq_len_adjust - 45;
if(length_std < 10)
length_std = 10;
if(plist->synthflags & SFLAG_LENGTHEN)
- length_std += phoneme_tab[phonLENGTHEN]->std_length; // phoneme was followed by an extra : symbol
+ length_std += (phoneme_tab[phonLENGTHEN]->std_length * 2); // phoneme was followed by an extra : symbol
// can adjust vowel length for stressed syllables here
length_factor = (length_std * 256)/ length1;
-
+
for(ix=0; ix<nf1; ix++)
{
frames[ix].length = (frames[ix].length * length_factor)/256;
@@ -516,22 +342,29 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB
}
else
{
- // front of a vowel
- if(*match_level == 0)
+ if(which == 1)
{
- // allow very short vowels to have shorter front parts
- if(this_ph->std_length < 130)
- frames[0].length = (frames[0].length * this_ph->std_length)/130;
+ // front of a vowel
+ if(fmt_params->fmt_control == 1)
+ {
+ // This is the default start of a vowel.
+ // Allow very short vowels to have shorter front parts
+ if(fmt_params->std_length < 130)
+ frames[0].length = (frames[0].length * fmt_params->std_length)/130;
+ }
}
-
- if(seq_len_adjust != 0)
+ else
{
- length_std = 0;
- for(ix=0; ix<nf1; ix++)
+ //not a vowel
+ if(fmt_params->std_length > 0)
{
- length_std += frames[ix].length;
+ seq_len_adjust += (fmt_params->std_length - length1);
}
- length_factor = ((length_std + seq_len_adjust) * 256)/length_std;
+ }
+
+ if(seq_len_adjust != 0)
+ {
+ length_factor = ((length1 + seq_len_adjust) * 256)/length1;
for(ix=0; ix<nf1; ix++)
{
frames[ix].length = (frames[ix].length * length_factor)/256;
@@ -539,17 +372,21 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB
}
}
}
-
+
*n_frames = nf;
return(frames);
} // end of LookupSpect
-unsigned char *LookupEnvelope(int ix)
-{//================================
- if(ix==0)
- return(NULL);
- return((unsigned char *)&spects_data[phoneme_index[ix]]);
+
+unsigned char *GetEnvelope(int index)
+{//==================================
+ if(index==0)
+ {
+ fprintf(stderr,"espeak: No envelope\n");
+ return(envelope_data[0]); // not found, use a default envelope
+ }
+ return((unsigned char *)&phondata_ptr[index]);
}
@@ -640,6 +477,8 @@ void LoadConfig(void)
char *p;
char string[200];
+ logging_type = 0;
+
for(ix=0; ix<N_SOUNDICON_SLOTS; ix++)
{
soundicon_tab[ix].filename = NULL;
@@ -654,6 +493,14 @@ void LoadConfig(void)
while(fgets(buf,sizeof(buf),f)!=NULL)
{
+ if(buf[0] == '/') continue;
+
+ if(memcmp(buf,"log",3)==0)
+ {
+ if(sscanf(&buf[4],"%d %s",&logging_type,string)==2)
+ f_logespeak = fopen(string,"w");
+ }
+ else
if(memcmp(buf,"tone",4)==0)
{
ReadTonePoints(&buf[5],tone_points);
@@ -661,7 +508,7 @@ void LoadConfig(void)
else
if(memcmp(buf,"pa_device",9)==0)
{
- sscanf(&buf[7],"%d",&option_device_number);
+ sscanf(&buf[10],"%d",&option_device_number);
}
else
if(memcmp(buf,"soundicon",9)==0)
@@ -680,3 +527,764 @@ void LoadConfig(void)
fclose(f);
} // end of LoadConfig
+
+
+
+PHONEME_DATA this_ph_data;
+
+
+static void InvalidInstn(PHONEME_TAB *ph, int instn)
+{//====================================================
+ fprintf(stderr,"Invalid instruction %.4x for phoneme '%s'\n", instn, WordToString(ph->mnemonic));
+}
+
+
+static bool StressCondition(Translator *tr, PHONEME_LIST *plist, int condition, int control)
+{//========================================================================================
+// condition:
+// 0 if diminished, 1 if unstressed, 2 if not stressed, 3 if stressed, 4 if max stress
+
+ int stress_level;
+ PHONEME_LIST *pl;
+ static int condition_level[4] = {1,2,4,15};
+
+ if(phoneme_tab[plist[0].phcode]->type == phVOWEL)
+ {
+ pl = plist;
+ }
+ else
+ {
+ // consonant, get stress from the following vowel
+ if(phoneme_tab[plist[1].phcode]->type == phVOWEL)
+ {
+ pl = &plist[1];
+ }
+ else
+ return(false); // no stress elevel for this consonant
+ }
+
+ stress_level = pl->stresslevel & 0xf;
+
+ if(tr != NULL)
+ {
+ if((control & 1) && (plist->synthflags & SFLAG_DICTIONARY) && ((tr->langopts.param[LOPT_REDUCE] & 1)==0))
+ {
+ // change phoneme. Don't change phonemes which are given for the word in the dictionary.
+ return(false);
+ }
+
+ if((tr->langopts.param[LOPT_REDUCE] & 0x2) && (stress_level >= pl->wordstress))
+ {
+ // treat the most stressed syllable in an unstressed word as stressed
+ stress_level = 4;
+ }
+ }
+
+ if(condition == 4)
+ {
+ return(stress_level >= pl->wordstress);
+ }
+
+ if(condition == 3)
+ {
+ // if stressed
+ if(stress_level > 3)
+ return(true);
+ }
+ else
+ {
+ if(stress_level < condition_level[condition])
+ return(true);
+ }
+ return(false);
+
+} // end of StressCondition
+
+
+static int CountVowelPosition(PHONEME_LIST *plist)
+{//===============================================
+ int count = 0;
+
+ for(;;)
+ {
+ if(plist->ph->type == phVOWEL)
+ count++;
+ if(plist->sourceix != 0)
+ break;
+ plist--;
+ }
+ return(count);
+} // end of CoundVowelPosition
+
+
+static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, USHORT *p_prog, WORD_PH_DATA *worddata)
+{//========================================================================================================================
+ int which;
+ int ix;
+ unsigned int data;
+ int instn;
+ int instn2;
+ int count;
+ PHONEME_TAB *ph;
+ PHONEME_LIST *plist_this;
+
+ // instruction: 2xxx, 3xxx
+
+ // bits 8-10 = 0 to 5, which phoneme, =6 the 'which' information is in the next instruction.
+ // bit 11 = 0, bits 0-7 are a phoneme code
+ // bit 11 = 1, bits 5-7 type of data, bits 0-4 data value
+
+ // bits 8-10 = 7, other conditions
+
+ instn = (*p_prog) & 0xfff;
+ data = instn & 0xff;
+ instn2 = instn >> 8;
+
+ if(instn2 < 14)
+ {
+ plist_this = plist;
+ which = (instn2) % 7;
+
+ if(which==6)
+ {
+ // the 'which' code is in the next instruction
+ p_prog++;
+ which = (*p_prog);
+ }
+
+ if(which==4)
+ {
+ // nextPhW not word boundary
+ if(plist[1].sourceix)
+ return(false);
+ }
+ if(which==5)
+ {
+ // prevPhW, not word boundary
+ if(plist[0].sourceix)
+ return(false);
+ }
+ if(which==6)
+ {
+ // next2PhW, not word boundary
+ if(plist[1].sourceix || plist[2].sourceix)
+ return(false);
+ }
+
+
+ switch(which)
+ {
+ case 0: // prevPh
+ case 5: // prevPhW
+ plist--;
+ break;
+
+ case 1: // thisPh
+ break;
+
+ case 2: // nextPh
+ case 4: // nextPhW
+ plist++;
+ break;
+
+ case 3: // next2Ph
+ case 6: // next2PhW
+ plist += 2;
+ break;
+
+ case 7:
+ // nextVowel, not word boundary
+ for(which=1;;which++)
+ {
+ if(plist[which].sourceix)
+ return(false);
+ if(phoneme_tab[plist[which].phcode]->type == phVOWEL)
+ {
+ plist = &plist[which];
+ break;
+ }
+ }
+ break;
+
+ case 8: // prevVowel in this word
+ if((worddata==NULL) || (worddata->prev_vowel.ph == NULL))
+ return(false); // no previous vowel
+ plist = &(worddata->prev_vowel);
+ break;
+
+ case 9: // next3PhW
+ for(ix=1; ix<=3; ix++)
+ {
+ if(plist[ix].sourceix)
+ return(false);
+ }
+ plist = &plist[3];
+ break;
+
+ case 10: // prev2PhW
+ if((plist[0].sourceix) || (plist[-1].sourceix))
+ return(false);
+ plist-=2;
+ break;
+ }
+
+ if((which == 0) || (which == 5))
+ {
+ if(plist->phcode == 1)
+ {
+ // This is a NULL phoneme, a phoneme has been deleted so look at the previous phoneme
+ plist--;
+ }
+ }
+
+ if(control & 0x100)
+ {
+ // "change phonemes" pass
+ plist->ph = phoneme_tab[plist->phcode];
+ }
+ ph = plist->ph;
+
+ if(instn2 < 7)
+ {
+ // 'data' is a phoneme number
+ if((phoneme_tab[data]->mnemonic == ph->mnemonic) == true)
+ return(true);
+ if((which == 0) && (ph->type == phVOWEL))
+ return(data == ph->end_type); // prevPh() match on end_type
+ return(data == ph->start_type); // thisPh() or nextPh(), match on start_type
+ }
+
+ data = instn & 0x1f;
+
+ switch(instn & 0xe0)
+ {
+ case 0x00:
+ // phoneme type, vowel, nasal, fricative, etc
+ return(ph->type == data);
+ break;
+
+ case 0x20:
+ // place of articulation
+ return(((ph->phflags >> 16) & 0xf) == data);
+ break;
+
+ case 0x40:
+ // is a bit set in phoneme flags
+ return((ph->phflags & (1 << data)) != 0);
+ break;
+
+ case 0x80:
+ switch(data)
+ {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ return(StressCondition(tr, plist, data, 0));
+
+ case 5: // isBreak, Either pause phoneme, or (stop/vstop/vfric not followed by vowel or (liquid in same word))
+ return((ph->type == phPAUSE) || (plist_this->synthflags & SFLAG_NEXT_PAUSE));
+
+ case 6: // isWordStart
+ return(plist->sourceix != 0);
+
+ case 7: // notWordStart
+ return(plist->sourceix == 0);
+
+ case 8: // isWordEnd
+ return(plist[1].sourceix || (plist[1].ph->type == phPAUSE));
+ break;
+
+ case 9: // isAfterStress
+ if(plist->sourceix != 0)
+ return(false);
+ do {
+ plist--;
+ if((plist->stresslevel & 0xf) >= 4)
+ return(true);
+
+ } while (plist->sourceix == 0);
+ break;
+
+ case 10: // isNotVowel
+ return(ph->type != phVOWEL);
+
+ case 11: // isFinalVowel
+ for(;;)
+ {
+ plist++;
+ plist->ph = phoneme_tab[plist->phcode];
+ if(plist->sourceix != 0)
+ return(true); // start of next word, without finding another vowel
+ if(plist->ph->type == phVOWEL)
+ return(false);
+ }
+ break;
+
+ case 12: // isVoiced
+ return((ph->type == phVOWEL) || (ph->type == phLIQUID) || (ph->phflags & phVOICED));
+
+ case 13: // isFirstVowel
+ return(CountVowelPosition(plist)==1);
+
+ case 14: // isSecondVowel
+ return(CountVowelPosition(plist)==2);
+
+ case 15: // isSeqFlag1
+ // is this preceded by a sequence if 1 or more vowels which have 'flag1' ? (lang=hi)
+ if(plist->sourceix != 0)
+ return(false); // this is the first phoneme in the word, so no.
+
+ count = 0;
+ for(;;)
+ {
+ plist--;
+ if(plist->ph->type == phVOWEL)
+ {
+ if(plist->ph->phflags & phFLAG1)
+ count++;
+ else
+ break; // stop when we find a vowel without flag1
+ }
+ if(plist->sourceix != 0)
+ break;
+ }
+ return(count > 0);
+
+ case 0x10: // isTranslationGiven
+ return((plist->synthflags & SFLAG_DICTIONARY) != 0);
+ }
+ break;
+
+ }
+ return(false);
+ }
+ else
+ if(instn2 == 0xf)
+ {
+ // Other conditions
+ switch(data)
+ {
+ case 1: // PreVoicing
+ return(control & 1);
+ case 2: // KlattSynth
+ return(voice->klattv[0] != 0);
+ case 3: // MbrolaSynth
+ return(mbrola_name[0] != 0);
+ }
+ }
+ return(false);
+} // end of InterpretCondition
+
+
+static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT **p_prog, int instn_type)
+{//========================================================================================================
+ USHORT *prog;
+ int voweltype;
+ signed char x;
+
+ if(instn_type == 2)
+ {
+ phdata->pd_control |= pd_FORNEXTPH;
+ voweltype = plist[1].ph->start_type; // SwitchNextVowelType
+ }
+ else
+ {
+ voweltype = plist[-1].ph->end_type; // SwitchPrevVowelType
+ }
+
+ voweltype -= phonVOWELTYPES;
+ if((voweltype >= 0) && (voweltype < 6))
+ {
+ prog = *p_prog + voweltype*2;
+ phdata->sound_addr[instn_type] = (((prog[1] & 0xf) << 16) + prog[2]) * 4;
+ x = (prog[1] >> 4) & 0xff;
+ phdata->sound_param[instn_type] = x; // sign extend
+ }
+
+ *p_prog += 12;
+} // end of SwitchVowelType
+
+
+int NumInstnWords(USHORT *prog)
+{//============================
+ int instn;
+ int instn2;
+ int instn_type;
+ int n;
+ int type2;
+ static const char n_words[16] = {0,1,0,0,1,1,0,1,1,2,4,0,0,0,0,0};
+
+ instn = *prog;
+ instn_type = instn >> 12;
+ if((n = n_words[instn_type]) > 0)
+ return(n);
+
+ switch(instn_type)
+ {
+ case 0:
+ if(((instn & 0xf00) >> 8) == i_IPA_NAME)
+ {
+ n = ((instn & 0xff) + 1) / 2;
+ return(n+1);
+ }
+ return(1);;
+
+ case 6:
+ type2 = (instn & 0xf00) >> 9;
+ if((type2 == 5) || (type2 == 6))
+ return(12); // switch on vowel type
+ return(1);
+
+ case 2:
+ case 3:
+ // a condition, check for a 2-word instruction
+ if(((n = instn & 0x0f00) == 0x600) || (n == 0x0d00))
+ return(2);
+ return(1);
+
+ default:
+ // instn_type 11 to 15, 2 words
+ instn2 = prog[2];
+ if((instn2 >> 12) == 0xf)
+ {
+ // This instruction is followed by addWav(), 2 more words
+ return(4);
+ }
+ if(instn2 == i_CONTINUE)
+ {
+ return(3);
+ }
+ return(2);
+ }
+} // end of NumInstnWords
+
+
+
+void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata, WORD_PH_DATA *worddata)
+{//===================================================================================================================
+// control:
+//bit 0: PreVoicing
+//bit 8: change phonemes
+ PHONEME_TAB *ph;
+ USHORT *prog;
+ USHORT instn;
+ int instn2;
+ int or_flag;
+ bool truth;
+ bool truth2;
+ int data;
+ int end_flag;
+ int ix;
+ signed char param_sc;
+
+ #define N_RETURN 10
+ int n_return=0;
+ USHORT *return_addr[N_RETURN]; // return address stack
+
+ ph = plist->ph;
+
+ if((worddata != NULL) && (plist->sourceix))
+ {
+ // start of a word, reset word data
+ worddata->prev_vowel.ph = NULL;
+ }
+
+ memset(phdata, 0, sizeof(PHONEME_DATA));
+ phdata->pd_param[i_SET_LENGTH] = ph->std_length;
+ phdata->pd_param[i_LENGTH_MOD] = ph->length_mod;
+
+ if(ph->program == 0)
+ {
+ return;
+ }
+
+ end_flag = 0;
+
+ for(prog = &phoneme_index[ph->program]; end_flag != 1; prog++)
+ {
+ instn = *prog;
+ instn2 = (instn >> 8) & 0xf;
+ or_flag = 0;
+
+ switch(instn >> 12)
+ {
+ case 0: // 0xxx
+ data = instn & 0xff;
+
+ if(instn2 == 0)
+ {
+ // instructions with no operand
+ switch(data)
+ {
+ case i_RETURN:
+ end_flag = 1;
+ break;
+
+ case i_CONTINUE:
+ break;
+
+ default:
+ InvalidInstn(ph,instn);
+ break;
+ }
+ }
+ else
+ if(instn2 == i_APPEND_IFNEXTVOWEL)
+ {
+ if(phoneme_tab[plist[1].phcode]->type == phVOWEL)
+ phdata->pd_param[i_APPEND_PHONEME] = data;
+ }
+ else
+ if(instn2 == i_ADD_LENGTH)
+ {
+ if(data & 0x80)
+ {
+ // a negative value, do sign extension
+ data = -(0x100 - data);
+ }
+ phdata->pd_param[i_SET_LENGTH] += data;
+ }
+ else
+ if(instn2 == i_IPA_NAME)
+ {
+ // followed by utf-8 characters, 2 per instn word
+ for(ix=0; (ix < data) && (ix < 16); ix += 2)
+ {
+ prog++;
+ phdata->ipa_string[ix] = prog[0] >> 8;
+ phdata->ipa_string[ix+1] = prog[0] & 0xff;
+ }
+ phdata->ipa_string[ix] = 0;
+ }
+ else
+ if(instn2 < N_PHONEME_DATA_PARAM)
+ {
+ if(instn2 == i_CHANGE_PHONEME2)
+ {
+ phdata->pd_param[i_CHANGE_PHONEME] = data; // also set ChangePhoneme
+ }
+ phdata->pd_param[instn2] = data;
+ if((instn2 == i_CHANGE_PHONEME) && (control & 0x100))
+ {
+ // found ChangePhoneme() in PhonemeList mode, exit
+ end_flag = 1;
+ }
+ }
+ else
+ {
+ InvalidInstn(ph,instn);
+ }
+ break;
+
+ case 1:
+ if(tr == NULL)
+ break; // ignore if in synthesis stage
+
+ if(instn2 < 8)
+ {
+ // ChangeIf
+ if(StressCondition(tr, plist, instn2 & 7, 1) == true)
+ {
+ phdata->pd_param[i_CHANGE_PHONEME] = instn & 0xff;
+ end_flag = 1; // change phoneme, exit
+ }
+ }
+ break;
+
+ case 2:
+ case 3:
+ // conditions
+ or_flag = 0;
+ truth = true;
+ while((instn & 0xe000) == 0x2000)
+ {
+ // process a sequence of conditions, using boolean accumulator
+ truth2 = InterpretCondition(tr, control, plist, prog, worddata);
+ prog += NumInstnWords(prog);
+ if(*prog == i_NOT)
+ {
+ truth2 = truth2 ^ 1;
+ prog++;
+ }
+
+ if(or_flag)
+ truth = truth || truth2;
+ else
+ truth = truth && truth2;
+ or_flag = instn & 0x1000;
+ instn = *prog;
+ }
+
+ if(truth == false)
+ {
+ if((instn & 0xf800) == i_JUMP_FALSE)
+ {
+ prog += instn & 0xff;
+ }
+ else
+ {
+ // instruction after a condition is not JUMP_FALSE, so skip the instruction.
+ prog += NumInstnWords(prog);
+ if((prog[0] & 0xfe00) == 0x6000)
+ prog++; // and skip ELSE jump
+ }
+ }
+ prog--;
+ break;
+
+ case 6:
+ // JUMP
+ switch(instn2 >> 1)
+ {
+ case 0:
+ prog += (instn & 0xff) - 1;
+ break;
+
+ case 4:
+ // conditional jumps should have been processed in the Condition section
+ break;
+
+ case 5: // NexttVowelStarts
+ SwitchOnVowelType(plist, phdata, &prog, 2);
+ break;
+
+ case 6: // PrevVowelTypeEndings
+ SwitchOnVowelType(plist, phdata, &prog, 3);
+ break;
+ }
+ break;
+
+ case 9:
+ data = ((instn & 0xf) << 16) + prog[1];
+ prog++;
+ switch(instn2)
+ {
+ case 1:
+ // call a procedure or another phoneme
+ if(n_return < N_RETURN)
+ {
+ return_addr[n_return++] = prog;
+ prog = &phoneme_index[data] - 1;
+ }
+ break;
+
+ case 2:
+ // pitch envelope
+ phdata->pitch_env = data;
+ break;
+
+ case 3:
+ // amplitude envelope
+ phdata->amp_env = data;
+ break;
+ }
+ break;
+
+ case 10: // Vowelin, Vowelout
+ if(instn2 == 1)
+ ix = 0;
+ else
+ ix = 2;
+
+ phdata->vowel_transition[ix] = ((prog[0] & 0xff) << 16) + prog[1];
+ phdata->vowel_transition[ix+1] = (prog[2] << 16) + prog[3];
+ prog += 3;
+ break;
+
+ case 11: // FMT
+ case 12: // WAV
+ case 13: // VowelStart
+ case 14: // VowelEnd
+ case 15: // addWav
+ instn2 = (instn >> 12) - 11;
+ phdata->sound_addr[instn2] = ((instn & 0xf) << 18) + (prog[1] << 2);
+ param_sc = phdata->sound_param[instn2] = (instn >> 4) & 0xff;
+ prog++;
+
+ if(prog[1] != i_CONTINUE)
+ {
+ if(instn2 < 2)
+ {
+ // FMT() and WAV() imply Return
+ end_flag = 1;
+ if((prog[1] >> 12) == 0xf)
+ {
+ // Return after the following addWav()
+ end_flag = 2;
+ }
+ }
+ else
+ if(instn2 ==pd_ADDWAV)
+ {
+ // addWav(), return if previous instruction was FMT() or WAV()
+ end_flag--;
+ }
+
+ if((instn2 == pd_VWLSTART) || (instn2 == pd_VWLEND))
+ {
+ // VowelStart or VowelEnding.
+ phdata->sound_param[instn2] = param_sc; // sign extend
+ }
+ }
+ break;
+
+ default:
+ InvalidInstn(ph,instn);
+ break;
+ }
+
+ if(ph->phflags & phSINGLE_INSTN)
+ {
+ end_flag = 1; // this phoneme has a one-instruction program, with an implicit Return
+ }
+
+ if((end_flag == 1) && (n_return > 0))
+ {
+ // return from called procedure or phoneme
+ end_flag = 0;
+ prog = return_addr[--n_return];
+ }
+ }
+
+ if((worddata != NULL) && (plist->type == phVOWEL))
+ {
+ memcpy(&worddata->prev_vowel, &plist[0], sizeof(PHONEME_LIST));
+ }
+
+#ifdef _ESPEAKEDIT
+ plist->std_length = phdata->pd_param[i_SET_LENGTH];
+ if(phdata->sound_addr[0] != 0)
+ {
+ plist->phontab_addr = phdata->sound_addr[0]; // FMT address
+ plist->sound_param = phdata->sound_param[0];
+ }
+ else
+ {
+ plist->phontab_addr = phdata->sound_addr[1]; // WAV address
+ plist->sound_param = phdata->sound_param[1];
+ }
+#endif
+} // end of InterpretPhoneme
+
+
+void InterpretPhoneme2(int phcode, PHONEME_DATA *phdata)
+{//=====================================================
+// Examine the program of a single isolated phoneme
+ int ix;
+ PHONEME_LIST plist[4];
+ memset(plist, 0, sizeof(plist));
+
+ for(ix=0; ix<4; ix++)
+ {
+ plist[ix].phcode = phonPAUSE;
+ plist[ix].ph = phoneme_tab[phonPAUSE];
+ }
+
+ plist[1].phcode = phcode;
+ plist[1].ph = phoneme_tab[phcode];
+ plist[2].sourceix = 1;
+
+ InterpretPhoneme(NULL, 0, &plist[1], phdata, NULL);
+} // end of InterpretPhoneme2
diff --git a/navit/support/espeak/synthdata.h b/navit/support/espeak/synthdata.h
new file mode 100644
index 000000000..052ef81b2
--- /dev/null
+++ b/navit/support/espeak/synthdata.h
@@ -0,0 +1,20 @@
+/***************************************************************************
+ * Copyright (C) 2005 to 2010 by Jonathan Duddington *
+ * email: jonsd@users.sourceforge.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, see: *
+ * <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+void FreePhData(void);
diff --git a/navit/support/espeak/synthesize.c b/navit/support/espeak/synthesize.c
index 3a48b1d72..d28634bfc 100755..100644
--- a/navit/support/espeak/synthesize.c
+++ b/navit/support/espeak/synthesize.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -40,7 +40,7 @@ static void SmoothSpect(void);
// list of phonemes in a clause
int n_phoneme_list=0;
-PHONEME_LIST phoneme_list[N_PHONEME_LIST];
+PHONEME_LIST phoneme_list[N_PHONEME_LIST+1];
int mbrola_delay;
char mbrola_name[20];
@@ -54,6 +54,7 @@ static int last_wcmdq;
static int pitch_length;
static int amp_length;
static int modn_flags;
+static int fmt_amplitude=0;
static int syllable_start;
static int syllable_end;
@@ -69,7 +70,7 @@ SOUND_ICON soundicon_tab[N_SOUNDICON_TAB];
#define VOWEL_FRONT_LENGTH 50
-#define long(x) ((long)(x))
+
// a dummy phoneme_list entry which looks like a pause
static PHONEME_LIST next_pause;
@@ -81,7 +82,7 @@ const char *WordToString(unsigned int word)
int ix;
static char buf[5];
- for(ix=0; ix<3; ix++)
+ for(ix=0; ix<4; ix++)
buf[ix] = word >> (ix*8);
buf[4] = 0;
return(buf);
@@ -135,13 +136,13 @@ static void EndPitch(int voice_break)
syllable_centre = -1;
memset(vowel_transition,0,sizeof(vowel_transition));
}
-} // end of Synthesize::EndPitch
+} // end of EndPitch
static void DoAmplitude(int amp, unsigned char *amp_env)
{//=====================================================
- long *q;
+ long64 *q;
last_amp_cmd = wcmdq_tail;
amp_length = 0; // total length of vowel with this amplitude envelope
@@ -149,24 +150,24 @@ static void DoAmplitude(int amp, unsigned char *amp_env)
q = wcmdq[wcmdq_tail];
q[0] = WCMD_AMPLITUDE;
q[1] = 0; // fill in later from amp_length
- q[2] = (long)amp_env;
+ q[2] = (long64)amp_env;
q[3] = amp;
WcmdqInc();
-} // end of Synthesize::DoAmplitude
+} // end of DoAmplitude
static void DoPitch(unsigned char *env, int pitch1, int pitch2)
{//============================================================
- long *q;
+ long64 *q;
EndPitch(0);
- if(pitch1 == 1024)
+ if(pitch1 == 255)
{
// pitch was not set
- pitch1 = 24;
- pitch2 = 33;
+ pitch1 = 55;
+ pitch2 = 76;
env = envelope_data[PITCHfall];
}
last_pitch_cmd = wcmdq_tail;
@@ -178,141 +179,272 @@ static void DoPitch(unsigned char *env, int pitch1, int pitch2)
q = wcmdq[wcmdq_tail];
q[0] = WCMD_PITCH;
q[1] = 0; // length, fill in later from pitch_length
- q[2] = (long)env;
+ q[2] = (long64)env;
q[3] = (pitch1 << 16) + pitch2;
WcmdqInc();
-} // end of Synthesize::DoPitch
+} // end of DoPitch
int PauseLength(int pause, int control)
{//====================================
- int len;
+ unsigned int len;
if(control == 0)
- len = (pause * speed.speed_factor1)/256;
+ {
+ if(pause >= 200)
+ len = (pause * speed.clause_pause_factor)/256;
+ else
+ len = (pause * speed.pause_factor)/256;
+ }
else
- len = (pause * speed.speed_factor2)/256;
+ len = (pause * speed.wav_factor)/256;
- if(len < 5) len = 5; // mS, limit the amount to which pauses can be shortened
+ if(len < speed.min_pause)
+ {
+ len = speed.min_pause; // mS, limit the amount to which pauses can be shortened
+ }
return(len);
}
static void DoPause(int length, int control)
{//=========================================
+// length in nominal mS
// control = 1, less shortening at fast speeds
- int len;
+ unsigned int len;
+ int srate2;
- len = PauseLength(length, control);
+ if(length == 0)
+ len = 0;
+ else
+ {
+ len = PauseLength(length, control);
- len = (len * samplerate) / 1000; // convert from mS to number of samples
+ if(len < 90000)
+ {
+ len = (len * samplerate) / 1000; // convert from mS to number of samples
+ }
+ else
+ {
+ srate2 = samplerate / 25; // avoid overflow
+ len = (len * srate2) / 40;
+ }
+ }
EndPitch(1);
wcmdq[wcmdq_tail][0] = WCMD_PAUSE;
wcmdq[wcmdq_tail][1] = len;
WcmdqInc();
last_frame = NULL;
-} // end of Synthesize::DoPause
+
+ if(fmt_amplitude != 0)
+ {
+ wcmdq[wcmdq_tail][0] = WCMD_FMT_AMPLITUDE;
+ wcmdq[wcmdq_tail][1] = fmt_amplitude = 0;
+ WcmdqInc();
+ }
+} // end of DoPause
extern int seq_len_adjust; // temporary fix to advance the start point for playing the wav sample
-static int DoSample2(int index, int which, int length_mod, int amp)
-{//================================================================
+static int DoSample2(int index, int which, int std_length, int control, int length_mod, int amp)
+{//=============================================================================================
int length;
- int length1;
- int format;
+ int wav_length;
+ int wav_scale;
int min_length;
- int start=0;
- long *q;
+ int x;
+ int len4;
+ long64 *q;
unsigned char *p;
index = index & 0x7fffff;
p = &wavefile_data[index];
- format = p[2];
- length1 = (p[1] * 256);
- length1 += p[0]; // length in bytes
+ wav_scale = p[2];
+ wav_length = (p[1] * 256);
+ wav_length += p[0]; // length in bytes
+
+ if(wav_length == 0)
+ return(0);
+
+ min_length = speed.min_sample_len;
- if(seq_len_adjust > 0)
+ if(wav_scale==0)
+ min_length *= 2; // 16 bit samples
+ else
{
- start = (seq_len_adjust * samplerate)/1000;
- if(format == 0)
- start *= 2;
- length1 -= start;
- index += start;
+ // increase consonant amplitude at high speeds, depending on the peak consonant amplitude
+// x = ((35 - wav_scale) * speed.loud_consonants);
+// if(x < 0) x = 0;
+// wav_scale = (wav_scale * (x+256))/256;
}
+ if(std_length > 0)
+ {
+ std_length = (std_length * samplerate)/1000;
+ if(wav_scale == 0)
+ std_length *= 2;
- if(length_mod > 0)
- length = (length1 * length_mod) / 256;
+ x = (min_length * std_length)/wav_length;
+ if(x > min_length)
+ min_length = x;
+ }
else
- length = length1;
+ {
+ // no length specified, use the length of the stored sound
+ std_length = wav_length;
+ }
+ if(length_mod > 0)
+ {
+ std_length = (std_length * length_mod)/256;
+ }
- length = (length * speed.speed_factor2)/256;
- min_length = speed.min_sample_len;
- if(format==0)
- min_length *= 2;
+ length = (std_length * speed.wav_factor)/256;
+
+ if(control & pd_DONTLENGTHEN)
+ {
+ // this option is used for Stops, with short noise bursts.
+ // Don't change their length much.
+ if(length > std_length)
+ {
+ // don't let length exceed std_length
+ length = std_length;
+ }
+ else
+ {
+ // reduce the reduction in length
+// length = (length + std_length)/2;
+ }
+ }
if(length < min_length)
length = min_length;
- if(length > length1)
- length = length1; // don't exceed wavefile length
- if(format==0)
- length /= 2; // 2 byte samples
+ if(wav_scale == 0)
+ {
+ // 16 bit samples
+ length /= 2;
+ wav_length /= 2;
+ }
+
+ if(amp < 0)
+ return(length);
+ len4 = wav_length / 4;
index += 4;
- if(amp >= 0)
+ if(which & 0x100)
{
+ // mix this with synthesised wave
last_wcmdq = wcmdq_tail;
q = wcmdq[wcmdq_tail];
- if(which & 0x100)
- q[0] = WCMD_WAVE2; // mix this with synthesised wave
- else
- q[0] = WCMD_WAVE;
+ q[0] = WCMD_WAVE2;
+ q[1] = length | (wav_length << 16); // length in samples
+ q[2] = (long64)(&wavefile_data[index]);
+ q[3] = wav_scale + (amp << 8);
+ WcmdqInc();
+ return(length);
+ }
+
+ if(length > wav_length)
+ {
+ x = len4*3;
+ length -= x;
+ }
+ else
+ {
+ x = length;
+ length = 0;
+ }
+
+ last_wcmdq = wcmdq_tail;
+ q = wcmdq[wcmdq_tail];
+ q[0] = WCMD_WAVE;
+ q[1] = x; // length in samples
+ q[2] = (long64)(&wavefile_data[index]);
+ q[3] = wav_scale + (amp << 8);
+ WcmdqInc();
+
+
+ while(length > len4*3)
+ {
+ x = len4;
+ if(wav_scale == 0)
+ x *= 2;
+
+ last_wcmdq = wcmdq_tail;
+ q = wcmdq[wcmdq_tail];
+ q[0] = WCMD_WAVE;
+ q[1] = len4*2; // length in samples
+ q[2] = (long64)(&wavefile_data[index+x]);
+ q[3] = wav_scale + (amp << 8);
+ WcmdqInc();
+
+ length -= len4*2;
+ }
+
+ if(length > 0)
+ {
+ x = wav_length - length;
+ if(wav_scale == 0)
+ x *= 2;
+ last_wcmdq = wcmdq_tail;
+ q = wcmdq[wcmdq_tail];
+ q[0] = WCMD_WAVE;
q[1] = length; // length in samples
- q[2] = long(&wavefile_data[index]);
- q[3] = format + (amp << 8);
+ q[2] = (long64)(&wavefile_data[index+x]);
+ q[3] = wav_scale + (amp << 8);
WcmdqInc();
}
+
return(length);
-} // end of Synthesize::DoSample2
+} // end of DoSample2
-int DoSample(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int length_mod, int amp)
-{//====================== ==========================================================
- int index;
- int match_level;
- int amp2;
- int result;
+int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp)
+{//=========================================================
+ int amp2;
+ int len;
EndPitch(1);
- index = LookupSound(ph1,ph2,which & 0xff,&match_level,0);
- if((index & 0x800000) == 0)
- return(0); // not wavefile data
-
- amp2 = wavefile_amp;
- if(amp != 0)
- amp2 = (amp * wavefile_amp)/20;
if(amp == -1)
+ {
+ // just get the length, don't produce sound
amp2 = amp;
+ }
+ else
+ {
+ amp2 = phdata->sound_param[pd_WAV];
+ if(amp2 == 0)
+ amp2 = 100;
+ amp2 = (amp2 * 32)/100;
+ }
- result = DoSample2(index,which,length_mod,amp2);
+ seq_len_adjust=0;
+
+ if(phdata->sound_addr[pd_WAV] == 0)
+ {
+ len = 0;
+ }
+ else
+ {
+ len = DoSample2(phdata->sound_addr[pd_WAV], 2, phdata->pd_param[pd_LENGTHMOD]*2, phdata->pd_control, length_mod, amp2);
+ }
last_frame = NULL;
- return(result);
-} // end of Synthesize::DoSample
+ return(len);
+} // end of DoSample3
-static frame_t *AllocFrame()
+static frame_t *AllocFrame(void)
{//=========================
// Allocate a temporary spectrum frame for the wavegen queue. Use a pool which is big
// enough to use a round-robin without checks.
@@ -361,7 +493,7 @@ static void set_frame_rms(frame_t *fr, int new_rms)
}
return;
}
-
+
if(fr->rms == 0) return; // check for divide by zero
x = (new_rms * 64)/fr->rms;
if(x >= 200) x = 199;
@@ -385,7 +517,7 @@ static void formants_reduce_hf(frame_t *fr, int level)
if(voice->klattv[0])
return;
-
+
for(ix=2; ix < 8; ix++)
{
x = fr->fheight[ix] * level;
@@ -472,7 +604,7 @@ static void AdjustFormants(frame_t *fr, int target, int min, int max, int f1_adj
fr->ffreq[1] += x;
fr->ffreq[0] += x;
}
- formants_reduce_hf(fr,hf_reduce);
+ formants_reduce_hf(fr,hf_reduce);
}
@@ -535,7 +667,7 @@ static short vcolouring[N_VCOLOUR][5] = {
// fprintf(stderr,"FMT%d %3s %3d-%3d f1=%d f2=%4d %4d %4d f3=%4d %3d\n",
// which,WordToString(other_ph->mnemonic),len,rms,f1,f2,f2_min,f2_max,f3_adj,f3_amp);
- if(other_ph->mnemonic == '?')
+ if((other_ph != NULL) && (other_ph->mnemonic == '?'))
flags |= 8;
if(which == 1)
@@ -546,14 +678,15 @@ static short vcolouring[N_VCOLOUR][5] = {
seq[0].length = VOWEL_FRONT_LENGTH;
if(len > 0)
seq[0].length = len;
- seq[0].frflags |= FRFLAG_LEN_MOD; // reduce length modification
- fr->frflags |= FRFLAG_LEN_MOD;
+ seq[0].frflags |= FRFLAG_LEN_MOD2; // reduce length modification
+ fr->frflags |= FRFLAG_LEN_MOD2;
next_rms = seq[1].frame->rms;
if(voice->klattv[0])
{
- fr->klattp[KLATT_AV] = 53; // reduce the amplituide of the start of a vowel
+// fr->klattp[KLATT_AV] = 53; // reduce the amplituide of the start of a vowel
+ fr->klattp[KLATT_AV] = seq[1].frame->klattp[KLATT_AV] - 4;
}
if(f2 != 0)
{
@@ -594,7 +727,7 @@ if(voice->klattv[0])
fr = CopyFrame(seq[*n_frames-1].frame,0);
seq[*n_frames-1].frame = fr;
rms = RMS_GLOTTAL1;
-
+
// degree of glottal-stop effect depends on closeness of vowel (indicated by f1 freq)
modn_flags = 0x400 + (VowelCloseness(fr) << 8);
}
@@ -603,7 +736,7 @@ if(voice->klattv[0])
fr = DuplicateLastFrame(seq,(*n_frames)++,len);
if(len > 36)
seq_len_adjust += (len - 36);
-
+
if(f2 != 0)
{
AdjustFormants(fr, f2, f2_min, f2_max, f1, f3_adj, f3_amp, flags);
@@ -614,11 +747,11 @@ if(voice->klattv[0])
if((vcolour > 0) && (vcolour <= N_VCOLOUR))
{
- for(ix=0; ix<*n_frames; ix++)
+ for(ix=0; ix < *n_frames; ix++)
{
fr = CopyFrame(seq[ix].frame,0);
seq[ix].frame = fr;
-
+
for(formant=1; formant<=5; formant++)
{
int x;
@@ -639,7 +772,7 @@ if(voice->klattv[0])
}
if(flags & 0x40)
- DoPause(12,0); // add a short pause after the consonant
+ DoPause(20,0); // add a short pause after the consonant
if(flags & 16)
return(len);
@@ -652,7 +785,7 @@ static void SmoothSpect(void)
{//==========================
// Limit the rate of frequence change of formants, to reduce chirping
- long *q;
+ long64 *q;
frame_t *frame;
frame_t *frame2;
frame_t *frame1;
@@ -694,7 +827,7 @@ static void SmoothSpect(void)
frame1 = (frame_t *)q[3];
if(frame1 == frame)
{
- q[3] = (long)frame2;
+ q[3] = (long64)frame2;
frame1 = frame2;
}
else
@@ -742,7 +875,7 @@ static void SmoothSpect(void)
modified = 1;
}
frame2->ffreq[pk] = frame1->ffreq[pk] + allowed;
- q[2] = (long)frame2;
+ q[2] = (long64)frame2;
}
else
if(diff < -allowed)
@@ -753,7 +886,7 @@ static void SmoothSpect(void)
modified = 1;
}
frame2->ffreq[pk] = frame1->ffreq[pk] - allowed;
- q[2] = (long)frame2;
+ q[2] = (long64)frame2;
}
}
}
@@ -784,7 +917,7 @@ static void SmoothSpect(void)
{
if(frame1 == frame)
{
- q[2] = (long)frame2;
+ q[2] = (long64)frame2;
frame1 = frame2;
}
else
@@ -826,7 +959,7 @@ static void SmoothSpect(void)
modified = 1;
}
frame2->ffreq[pk] = frame1->ffreq[pk] + allowed;
- q[3] = (long)frame2;
+ q[3] = (long64)frame2;
}
else
if(diff < -allowed)
@@ -837,7 +970,7 @@ static void SmoothSpect(void)
modified = 1;
}
frame2->ffreq[pk] = frame1->ffreq[pk] - allowed;
- q[3] = (long)frame2;
+ q[3] = (long64)frame2;
}
}
}
@@ -860,10 +993,10 @@ static void StartSyllable(void)
}
-int DoSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph,
- int which, PHONEME_LIST *plist, int modulation)
-{//===================================================================================
- // which 1 start of phoneme, 2 body and end
+
+int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_LIST *plist, int modulation)
+{//========================================================================================================
+ // which: 0 not a vowel, 1 start of vowel, 2 body and end of vowel
// length_mod: 256 = 100%
// modulation: -1 = don't write to wcmdq
@@ -874,25 +1007,35 @@ int DoSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph,
frame_t *frame2;
frame_t *fr;
int ix;
- long *q;
+ long64 *q;
int len;
- int match_level;
int frame_length;
- int frame1_length;
- int frame2_length;
int length_factor;
int length_mod;
+ int length_sum;
+ int length_min;
int total_len = 0;
static int wave_flag = 0;
int wcmd_spect = WCMD_SPECT;
+ int frame_lengths[N_SEQ_FRAMES];
+
+ if(fmt_params->fmt_addr == 0)
+ return(0);
length_mod = plist->length;
if(length_mod==0) length_mod=256;
+ length_min = (samplerate/70); // greater than one cycle at low pitch (Hz)
+ if(which==2)
+ {
+ if((translator->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] > 0) && ((this_ph->std_length >= translator->langopts.param[LOPT_LONG_VOWEL_THRESHOLD]) || (plist->synthflags & SFLAG_LENGTHEN) || (this_ph->phflags & phLONG)))
+ length_min *= 2; // ensure long vowels are longer
+ }
+
if(which==1)
{
// limit the shortening of sonorants before shortened (eg. unstressed vowels)
- if((this_ph->type==phLIQUID) || (prev_ph->type==phLIQUID) || (prev_ph->type==phNASAL))
+ if((this_ph->type==phLIQUID) || (plist[-1].type==phLIQUID) || (plist[-1].type==phNASAL))
{
if(length_mod < (len = translator->langopts.param[LOPT_SONORANT_MIN]))
{
@@ -902,15 +1045,30 @@ if(which==1)
}
modn_flags = 0;
- frames = LookupSpect(this_ph,prev_ph,next_ph,which,&match_level,&n_frames, plist);
+ frames = LookupSpect(this_ph, which, fmt_params, &n_frames, plist);
if(frames == NULL)
return(0); // not found
+ if(fmt_params->fmt_amp != fmt_amplitude)
+ {
+ // an amplitude adjustment is specified for this sequence
+ q = wcmdq[wcmdq_tail];
+ q[0] = WCMD_FMT_AMPLITUDE;
+ q[1] = fmt_amplitude = fmt_params->fmt_amp;
+ WcmdqInc();
+ }
+
frame1 = frames[0].frame;
- frame1_length = frames[0].length;
if(voice->klattv[0])
wcmd_spect = WCMD_KLATT;
+ wavefile_ix = fmt_params->wav_addr;
+
+ if(fmt_params->wav_amp == 0)
+ wavefile_amp = 32;
+ else
+ wavefile_amp = (fmt_params->wav_amp * 32)/100;
+
if(wavefile_ix == 0)
{
if(wave_flag)
@@ -935,7 +1093,7 @@ if(which==1)
&& !(last_frame->frflags & FRFLAG_BREAK))
{
// last frame of previous sequence was zero-length, replace with first of this sequence
- wcmdq[last_wcmdq][3] = (long)frame1;
+ wcmdq[last_wcmdq][3] = (long64)frame1;
if(last_frame->frflags & FRFLAG_BREAK_LF)
{
@@ -947,7 +1105,7 @@ if(which==1)
fr->ffreq[ix] = last_frame->ffreq[ix];
fr->fheight[ix] = last_frame->fheight[ix];
}
- wcmdq[last_wcmdq][3] = (long)fr;
+ wcmdq[last_wcmdq][3] = (long64)fr;
}
}
}
@@ -960,29 +1118,50 @@ if(which==1)
syllable_centre = wcmdq_tail;
}
- frame_length = frame1_length;
+ length_sum = 0;
+ for(frameix=1; frameix < n_frames; frameix++)
+ {
+ length_factor = length_mod;
+ if(frames[frameix-1].frflags & FRFLAG_LEN_MOD) // reduce effect of length mod
+ {
+ length_factor = (length_mod*(256-speed.lenmod_factor) + 256*speed.lenmod_factor)/256;
+ }
+ else
+ if(frames[frameix-1].frflags & FRFLAG_LEN_MOD2) // reduce effect of length mod, used for the start of a vowel
+ {
+ length_factor = (length_mod*(256-speed.lenmod2_factor) + 256*speed.lenmod2_factor)/256;
+ }
+
+ frame_length = frames[frameix-1].length;
+ len = (frame_length * samplerate)/1000;
+ len = (len * length_factor)/256;
+ length_sum += len;
+ frame_lengths[frameix] = len;
+ }
+
+ if((length_sum > 0) && (length_sum < length_min))
+ {
+ // lengthen, so that the sequence is greater than one cycle at low pitch
+ for(frameix=1; frameix < n_frames; frameix++)
+ {
+ frame_lengths[frameix] = (frame_lengths[frameix] * length_min) / length_sum;
+ }
+ }
+
for(frameix=1; frameix<n_frames; frameix++)
{
frame2 = frames[frameix].frame;
- frame2_length = frames[frameix].length;
- if((wavefile_ix != 0) && ((frame1->frflags & FRFLAG_DEFER_WAV)==0))
+ if((fmt_params->wav_addr != 0) && ((frame1->frflags & FRFLAG_DEFER_WAV)==0))
{
// there is a wave file to play along with this synthesis
seq_len_adjust = 0;
- DoSample2(wavefile_ix,which+0x100,0,wavefile_amp);
+ DoSample2(fmt_params->wav_addr, which+0x100, 0, fmt_params->fmt_control, 0, wavefile_amp);
wave_flag = 1;
wavefile_ix = 0;
+ fmt_params->wav_addr = 0;
}
- length_factor = length_mod;
- if(frame1->frflags & FRFLAG_LEN_MOD) // reduce effect of length mod
- {
- length_factor = (length_mod*(256-speed.speed_factor3) + 256*speed.speed_factor3)/256;
- }
- len = (frame_length * samplerate)/1000;
- len = (len * length_factor)/256;
-
if(modulation >= 0)
{
if(frame1->frflags & FRFLAG_MODULATE)
@@ -993,13 +1172,13 @@ if(which==1)
modulation |= modn_flags; // before or after a glottal stop
}
+ len = frame_lengths[frameix];
pitch_length += len;
amp_length += len;
- if(frame_length < 2)
+ if(len == 0)
{
last_frame = NULL;
- frame_length = frame2_length;
frame1 = frame2;
}
else
@@ -1011,31 +1190,72 @@ if(which==1)
q = wcmdq[wcmdq_tail];
q[0] = wcmd_spect;
q[1] = len + (modulation << 16);
- q[2] = long(frame1);
- q[3] = long(frame2);
-
+ q[2] = (long64)frame1;
+ q[3] = (long64)frame2;
+
WcmdqInc();
}
last_frame = frame1 = frame2;
- frame_length = frame2_length;
total_len += len;
}
}
+
+ if((which != 1) && (fmt_amplitude != 0))
+ {
+ q = wcmdq[wcmdq_tail];
+ q[0] = WCMD_FMT_AMPLITUDE;
+ q[1] = fmt_amplitude = 0;
+ WcmdqInc();
+ }
+
+
return(total_len);
-} // end of Synthesize::DoSpect
+} // end of DoSpect
-static void DoMarker(int type, int char_posn, int length, int value)
-{//=================================================================
+
+
+void DoMarker(int type, int char_posn, int length, int value)
+{//==========================================================
// This could be used to return an index to the word currently being spoken
// Type 1=word, 2=sentence, 3=named marker, 4=play audio, 5=end
- wcmdq[wcmdq_tail][0] = WCMD_MARKER;
- wcmdq[wcmdq_tail][1] = type;
- wcmdq[wcmdq_tail][2] = (char_posn & 0xffffff) | (length << 24);
- wcmdq[wcmdq_tail][3] = value;
- WcmdqInc();
+ if(WcmdqFree() > 5)
+ {
+ wcmdq[wcmdq_tail][0] = WCMD_MARKER + (type << 8);
+ wcmdq[wcmdq_tail][1] = (char_posn & 0xffffff) | (length << 24);
+ wcmdq[wcmdq_tail][2] = value;
+ WcmdqInc();
+ }
+} // end of DoMarker
+
+
+void DoPhonemeMarker(int type, int char_posn, int length, char *name)
+{//==================================================================
+// This could be used to return an index to the word currently being spoken
+// Type 7=phoneme
+ int *p;
+
+ if(WcmdqFree() > 5)
+ {
+ wcmdq[wcmdq_tail][0] = WCMD_MARKER + (type << 8);
+ wcmdq[wcmdq_tail][1] = (char_posn & 0xffffff) | (length << 24);
+ p = (int *)name;
+ wcmdq[wcmdq_tail][2] = p[0]; // up to 8 bytes of UTF8 characters
+ wcmdq[wcmdq_tail][3] = p[1];
+ WcmdqInc();
+ }
+} // end of DoMarker
+
-} // end of Synthesize::DoMarker
+#ifdef INCLUDE_SONIC
+void DoSonicSpeed(int value)
+{//=========================
+// value, multiplier * 1024
+ wcmdq[wcmdq_tail][0] = WCMD_SONIC_SPEED;
+ wcmdq[wcmdq_tail][1] = value;
+ WcmdqInc();
+} // end of DoSonicSpeed
+#endif
void DoVoiceChange(voice_t *v)
@@ -1046,23 +1266,28 @@ void DoVoiceChange(voice_t *v)
v2 = (voice_t *)malloc(sizeof(voice_t));
memcpy(v2,v,sizeof(voice_t));
wcmdq[wcmdq_tail][0] = WCMD_VOICE;
- wcmdq[wcmdq_tail][1] = (long)(v2);
+ wcmdq[wcmdq_tail][2] = (long64)v2;
WcmdqInc();
}
-static void DoEmbedded(int *embix, int sourceix)
-{//=============================================
+void DoEmbedded(int *embix, int sourceix)
+{//======================================
// There were embedded commands in the text at this point
unsigned int word; // bit 7=last command for this word, bits 5,6 sign, bits 0-4 command
unsigned int value;
int command;
do {
- word = embedded_list[(*embix)++];
+ word = embedded_list[*embix];
value = word >> 8;
command = word & 0x7f;
+ if(command == 0)
+ return; // error
+
+ (*embix)++;
+
switch(command & 0x1f)
{
case EMBED_S: // speed
@@ -1078,7 +1303,7 @@ static void DoEmbedded(int *embix, int sourceix)
DoPause(10,0); // ensure a break in the speech
wcmdq[wcmdq_tail][0] = WCMD_WAVE;
wcmdq[wcmdq_tail][1] = soundicon_tab[value].length;
- wcmdq[wcmdq_tail][2] = (long)soundicon_tab[value].data + 44; // skip WAV header
+ wcmdq[wcmdq_tail][2] = (long64)soundicon_tab[value].data + 44; // skip WAV header
wcmdq[wcmdq_tail][3] = 0x1500; // 16 bit data, amp=21
WcmdqInc();
}
@@ -1123,17 +1348,27 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
unsigned char *pitch_env=NULL;
unsigned char *amp_env;
PHONEME_TAB *ph;
- PHONEME_TAB *prev_ph;
+ int use_ipa=0;
+ int done_phoneme_marker;
+ char phoneme_name[16];
static int sourceix=0;
-#ifdef TEST_MBROLA
- if(mbrola_name[0] != 0)
- return(MbrolaGenerate(phoneme_list,n_ph,resume));
-#endif
+ PHONEME_DATA phdata;
+ PHONEME_DATA phdata_prev;
+ PHONEME_DATA phdata_next;
+ PHONEME_DATA phdata_tone;
+ FMT_PARAMS fmtp;
+ static WORD_PH_DATA worddata;
if(option_quiet)
return(0);
+ if(option_phoneme_events & espeakINITIALIZE_PHONEME_IPA)
+ use_ipa = 1;
+
+ if(mbrola_name[0] != 0)
+ return(MbrolaGenerate(phoneme_list,n_ph,resume));
+
if(resume == 0)
{
ix = 1;
@@ -1148,19 +1383,21 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
syllable_centre = -1;
last_pitch_cmd = -1;
memset(vowel_transition,0,sizeof(vowel_transition));
+ memset(&worddata, 0, sizeof(worddata));
+ DoPause(0,0); // isolate from the previous clause
}
- while(ix < (*n_ph))
+ while((ix < (*n_ph)) && (ix < N_PHONEME_LIST-2))
{
p = &phoneme_list[ix];
if(p->type == phPAUSE)
- free_min = 5;
+ free_min = 10;
else
if(p->type != phVOWEL)
- free_min = 10; // we need less Q space for non-vowels, and we need to generate phonemes after a vowel so that the pitch_length is filled in
+ free_min = 15; // we need less Q space for non-vowels, and we need to generate phonemes after a vowel so that the pitch_length is filled in
else
- free_min = MIN_WCMDQ; // 22
+ free_min = MIN_WCMDQ; // 25
if(WcmdqFree() <= free_min)
return(1); // wait
@@ -1176,8 +1413,14 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
if(p->newword)
{
- if(translator->langopts.param[LOPT_WORD_MERGE] == 0)
+ if(((p->type == phVOWEL) && (translator->langopts.param[LOPT_WORD_MERGE] & 1)) ||
+ (p->ph->phflags & phNOPAUSE))
+ {
+ }
+ else
+ {
last_frame = NULL;
+ }
sourceix = (p->sourceix & 0x7ff) + clause_start_char;
@@ -1188,44 +1431,91 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
// DoMarker(espeakEVENT_END, count_characters, 0, count_sentences); // end of clause
if(p->newword & 1)
- DoMarker(espeakEVENT_WORD, sourceix, p->sourceix >> 11, clause_start_word + word_count++);
+ DoMarker(espeakEVENT_WORD, sourceix, p->sourceix >> 11, clause_start_word + word_count++); // NOTE, this count doesn't include multiple-word pronunciations in *_list. eg (of a)
}
EndAmplitude();
- if(p->prepause > 0)
+ if((p->prepause > 0) && !(p->ph->phflags & phPREVOICE))
DoPause(p->prepause,1);
- if(option_phoneme_events && (p->type != phVOWEL))
+ done_phoneme_marker = 0;
+ if(option_phoneme_events && (p->ph->code != phonEND_WORD))
{
- // Note, for vowels, do the phoneme event after the vowel-start
- DoMarker(espeakEVENT_PHONEME, sourceix, 0, p->ph->mnemonic);
+ if((p->type == phVOWEL) && (prev->type==phLIQUID || prev->type==phNASAL))
+ {
+ // For vowels following a liquid or nasal, do the phoneme event after the vowel-start
+ }
+ else
+ {
+ WritePhMnemonic(phoneme_name, p->ph, p, use_ipa, NULL);
+ DoPhonemeMarker(espeakEVENT_PHONEME, sourceix, 0, phoneme_name);
+ done_phoneme_marker = 1;
+ }
}
switch(p->type)
{
case phPAUSE:
DoPause(p->length,0);
+#ifdef _ESPEAKEDIT
+ p->std_length = p->ph->std_length;
+#endif
break;
case phSTOP:
released = 0;
- if(next->type==phVOWEL) released = 1;
- if(next->type==phLIQUID && !next->newword) released = 1;
-
- if(released)
- DoSample(p->ph,next->ph,2,0,0);
+ ph = p->ph;
+ if(next->type==phVOWEL)
+ {
+ released = 1;
+ }
else
- DoSample(p->ph,phoneme_tab[phonPAUSE],2,0,0);
+ if(!next->newword)
+ {
+ if(next->type==phLIQUID) released = 1;
+// if(((p->ph->phflags & phPLACE) == phPLACE_blb) && (next->ph->phflags & phSIBILANT)) released = 1;
+ }
+ if(released == 0)
+ p->synthflags |= SFLAG_NEXT_PAUSE;
+
+ if(ph->phflags & phPREVOICE)
+ {
+ // a period of voicing before the release
+ memset(&fmtp, 0, sizeof(fmtp));
+ InterpretPhoneme(NULL, 0x01, p, &phdata, &worddata);
+ fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
+ fmtp.fmt_amp = phdata.sound_param[pd_FMT];
+
+ if(last_pitch_cmd < 0)
+ {
+ DoAmplitude(next->amp,NULL);
+ DoPitch(envelope_data[p->env],next->pitch1,next->pitch2);
+ }
+
+ DoSpect2(ph, 0, &fmtp, p, 0);
+ }
+
+ InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
+ phdata.pd_control |= pd_DONTLENGTHEN;
+ DoSample3(&phdata, 0, 0);
break;
case phFRICATIVE:
+ InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
+
if(p->synthflags & SFLAG_LENGTHEN)
- DoSample(p->ph,next->ph,2,p->length,0); // play it twice for [s:] etc.
- DoSample(p->ph,next->ph,2,p->length,0);
+ {
+ DoSample3(&phdata, p->length, 0); // play it twice for [s:] etc.
+ }
+ DoSample3(&phdata, p->length, 0);
break;
case phVSTOP:
+ ph = p->ph;
+ memset(&fmtp, 0, sizeof(fmtp));
+ fmtp.fmt_control = pd_DONTLENGTHEN;
+
pre_voiced = 0;
if(next->type==phVOWEL)
{
@@ -1249,14 +1539,18 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
}
}
- if((prev->type==phVOWEL) || (prev->ph->phflags & phVOWEL2))
+ if((prev->type==phVOWEL) || (prev->ph->phflags & phVOWEL2) || (ph->phflags & phPREVOICE))
{
// a period of voicing before the release
- DoSpect(p->ph,phoneme_tab[phonSCHWA],next->ph,1,p,0);
+ InterpretPhoneme(NULL, 0x01, p, &phdata, &worddata);
+ fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
+ fmtp.fmt_amp = phdata.sound_param[pd_FMT];
+
+ DoSpect2(ph, 0, &fmtp, p, 0);
if(p->synthflags & SFLAG_LENGTHEN)
{
- DoPause(20,0);
- DoSpect(p->ph,phoneme_tab[phonSCHWA],next->ph,1,p,0);
+ DoPause(25,1);
+ DoSpect2(ph, 0, &fmtp, p, 0);
}
}
else
@@ -1271,15 +1565,24 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
{
// followed by a vowel, or liquid + vowel
StartSyllable();
- DoSpect(p->ph,prev->ph,next->ph,2,p,0);
}
else
{
-// if((prev->type != phVOWEL) && ((prev->ph->phflags & phVOICED)==0) && ((next->ph->phflags & phVOICED)==0))
-// DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE_SHORT],2,p,0);
-// else
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
-// DoSpect(p->ph,prev->ph,next->ph,2,p,0);
+ p->synthflags |= SFLAG_NEXT_PAUSE;
+ }
+ InterpretPhoneme(NULL,0, p, &phdata, &worddata);
+ fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
+ fmtp.fmt_amp = phdata.sound_param[pd_FMT];
+ fmtp.wav_addr = phdata.sound_addr[pd_ADDWAV];
+ fmtp.wav_amp = phdata.sound_param[pd_ADDWAV];
+ DoSpect2(ph, 0, &fmtp, p, 0);
+
+ if((p->newword == 0) && (next2->newword == 0))
+ {
+ if(next->type == phVFRICATIVE)
+ DoPause(20,0);
+ if(next->type == phFRICATIVE)
+ DoPause(12,0);
}
break;
@@ -1304,22 +1607,29 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
}
}
- if((next->type==phVOWEL) || ((next->type==phLIQUID)) && (next->newword==0)) // ?? test 14.Aug.2007
+ if((next->type==phVOWEL) || ((next->type==phLIQUID) && (next->newword==0))) // ?? test 14.Aug.2007
{
StartSyllable();
- if(p->synthflags & SFLAG_LENGTHEN)
- DoSpect(p->ph,prev->ph,next->ph,2,p,0);
- DoSpect(p->ph,prev->ph,next->ph,2,p,0);
}
else
{
- if(p->synthflags & SFLAG_LENGTHEN)
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
+ p->synthflags |= SFLAG_NEXT_PAUSE;
}
+ InterpretPhoneme(NULL,0, p, &phdata, &worddata);
+ memset(&fmtp, 0, sizeof(fmtp));
+ fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
+ fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
+ fmtp.fmt_amp = phdata.sound_param[pd_FMT];
+ fmtp.wav_addr = phdata.sound_addr[pd_ADDWAV];
+ fmtp.wav_amp = phdata.sound_param[pd_ADDWAV];
+
+ if(p->synthflags & SFLAG_LENGTHEN)
+ DoSpect2(p->ph, 0, &fmtp, p, 0);
+ DoSpect2(p->ph, 0, &fmtp, p, 0);
break;
case phNASAL:
+ memset(&fmtp, 0, sizeof(fmtp));
if(!(p->synthflags & SFLAG_SEQCONTINUE))
{
DoAmplitude(p->amp,NULL);
@@ -1331,37 +1641,36 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
last_frame = NULL;
}
+ InterpretPhoneme(NULL,0, p, &phdata, &worddata);
+ fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
+ fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
+ fmtp.fmt_amp = phdata.sound_param[pd_FMT];
+
if(next->type==phVOWEL)
{
StartSyllable();
- DoSpect(p->ph,prev->ph,next->ph,1,p,0);
+ DoSpect2(p->ph, 0, &fmtp, p, 0);
}
else
if(prev->type==phVOWEL && (p->synthflags & SFLAG_SEQCONTINUE))
{
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
+ DoSpect2(p->ph, 0, &fmtp, p, 0);
}
else
{
last_frame = NULL; // only for nasal ?
- if(next->type == phLIQUID)
- DoSpect(p->ph,prev->ph,phoneme_tab[phonSONORANT],2,p,0);
- else
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
+ DoSpect2(p->ph, 0, &fmtp, p, 0);
last_frame = NULL;
}
break;
case phLIQUID:
+ memset(&fmtp, 0, sizeof(fmtp));
modulation = 0;
if(p->ph->phflags & phTRILL)
modulation = 5;
- prev_ph = prev->ph;
-// if(p->newword)
-// prev_ph = phoneme_tab[phonPAUSE]; // pronounce fully at the start of a word
-
if(!(p->synthflags & SFLAG_SEQCONTINUE))
{
DoAmplitude(p->amp,NULL);
@@ -1376,17 +1685,14 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
if(next->type==phVOWEL)
{
StartSyllable();
- DoSpect(p->ph,prev_ph,next->ph,1,p,modulation); // (,)r
- }
- else
- if(prev->type==phVOWEL && (p->synthflags & SFLAG_SEQCONTINUE))
- {
- DoSpect(p->ph,prev_ph,next->ph,1,p,modulation);
- }
- else
- {
- DoSpect(p->ph,prev_ph,next->ph,1,p,modulation);
}
+ InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
+ fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
+ fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
+ fmtp.fmt_amp = phdata.sound_param[pd_FMT];
+ fmtp.wav_addr = phdata.sound_addr[pd_ADDWAV];
+ fmtp.wav_amp = phdata.sound_param[pd_ADDWAV];
+ DoSpect2(p->ph, 0, &fmtp, p, modulation);
break;
@@ -1394,16 +1700,48 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
ph = p->ph;
stress = p->stresslevel & 0xf;
- // vowel transition from the preceding phoneme
- vowel_transition0 = vowel_transition[0];
- vowel_transition1 = vowel_transition[1];
+ memset(&fmtp, 0, sizeof(fmtp));
+
+ InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
+ fmtp.std_length = phdata.pd_param[i_SET_LENGTH] * 2;
+
+ if(((fmtp.fmt_addr = phdata.sound_addr[pd_VWLSTART]) != 0) && ((phdata.pd_control & pd_FORNEXTPH) == 0))
+ {
+ // a vowel start has been specified by the Vowel program
+ fmtp.fmt_length = phdata.sound_param[pd_VWLSTART];
+ }
+ else
+ if(prev->type != phPAUSE)
+ {
+ // check the previous phoneme
+ InterpretPhoneme(NULL, 0, prev, &phdata_prev, NULL);
+ if((fmtp.fmt_addr = phdata_prev.sound_addr[pd_VWLSTART]) != 0)
+ {
+ // a vowel start has been specified by the Vowel program
+ fmtp.fmt2_lenadj = phdata_prev.sound_param[pd_VWLSTART];
+ }
+ fmtp.transition0 = phdata_prev.vowel_transition[0];
+ fmtp.transition1 = phdata_prev.vowel_transition[1];
+ }
+
+ if(fmtp.fmt_addr == 0)
+ {
+ // use the default start for this vowel
+ fmtp.use_vowelin = 1;
+ fmtp.fmt_control = 1;
+ fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
+ }
+
+ fmtp.fmt_amp = phdata.sound_param[pd_FMT];
pitch_env = envelope_data[p->env];
amp_env = NULL;
if(p->tone_ph != 0)
{
- pitch_env = LookupEnvelope(phoneme_tab[p->tone_ph]->spect);
- amp_env = LookupEnvelope(phoneme_tab[p->tone_ph]->after);
+ InterpretPhoneme2(p->tone_ph, &phdata_tone);
+ pitch_env = GetEnvelope(phdata_tone.pitch_env);
+ if(phdata_tone.amp_env > 0)
+ amp_env = GetEnvelope(phdata_tone.amp_env);
}
StartSyllable();
@@ -1419,13 +1757,13 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
{
DoAmplitude(p->amp,amp_env);
DoPitch(pitch_env,p->pitch1,p->pitch2); // don't use prevocalic rising tone
- DoSpect(ph,prev->ph,next->ph,1,p,modulation);
+ DoSpect2(ph, 1, &fmtp, p, modulation);
}
else
if(prev->type==phLIQUID || prev->type==phNASAL)
{
DoAmplitude(p->amp,amp_env);
- DoSpect(ph,prev->ph,next->ph,1,p,modulation); // continue with pre-vocalic rising tone
+ DoSpect2(ph, 1, &fmtp, p, modulation); // continue with pre-vocalic rising tone
DoPitch(pitch_env,p->pitch1,p->pitch2);
}
else
@@ -1436,17 +1774,42 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
DoPitch(pitch_env,p->pitch1,p->pitch2);
}
- DoSpect(ph,prev->ph,next->ph,1,p,modulation);
+ DoSpect2(ph, 1, &fmtp, p, modulation);
+ }
+
+ if((option_phoneme_events) && (done_phoneme_marker == 0))
+ {
+ WritePhMnemonic(phoneme_name, p->ph, p, use_ipa, NULL);
+ DoPhonemeMarker(espeakEVENT_PHONEME, sourceix, 0, phoneme_name);
}
- if(option_phoneme_events)
+ fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
+ fmtp.fmt_amp = phdata.sound_param[pd_FMT];
+ fmtp.transition0 = 0;
+ fmtp.transition1 = 0;
+
+ if((fmtp.fmt2_addr = phdata.sound_addr[pd_VWLEND]) != 0)
{
- DoMarker(espeakEVENT_PHONEME, sourceix, 0, p->ph->mnemonic);
+ fmtp.fmt2_lenadj = phdata.sound_param[pd_VWLEND];
}
+ else
+ if(next->type != phPAUSE)
+ {
+ fmtp.fmt2_lenadj = 0;
+ InterpretPhoneme(NULL, 0, next, &phdata_next, NULL);
- DoSpect(p->ph,prev->ph,next->ph,2,p,modulation);
+ fmtp.use_vowelin = 1;
+ fmtp.transition0 = phdata_next.vowel_transition[2]; // always do vowel_transition, even if ph_VWLEND ?? consider [N]
+ fmtp.transition1 = phdata_next.vowel_transition[3];
+
+ if((fmtp.fmt2_addr = phdata_next.sound_addr[pd_VWLEND]) != 0)
+ {
+ fmtp.fmt2_lenadj = phdata_next.sound_param[pd_VWLEND];
+ }
+ }
+
+ DoSpect2(ph, 2, &fmtp, p, modulation);
- memset(vowel_transition,0,sizeof(vowel_transition));
break;
}
ix++;
@@ -1512,6 +1875,7 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
char *voice_change;
static FILE *f_text=NULL;
static const void *p_text=NULL;
+ const char *phon_out;
if(control == 4)
{
@@ -1534,7 +1898,6 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
n_phoneme_list = 0;
WcmdqStop();
- embedded_value[EMBED_T] = 0;
return(0);
}
@@ -1599,20 +1962,21 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
CalcPitches(translator, clause_tone);
CalcLengths(translator);
- GetTranslatedPhonemeString(translator->phon_out,sizeof(translator->phon_out));
- if(option_phonemes > 0)
+ if((option_phonemes > 0) || (phoneme_callback != NULL))
{
- fprintf(f_trans,"%s\n",translator->phon_out);
+ int phoneme_mode = 0;
+ if(option_phonemes >= 3)
+ phoneme_mode = 0x10 + option_phonemes-3; // 0x10=ipa, 0x11=ipa with tie, 0x12=ipa with ZWJ, 0x13=ipa with separators
- if(!iswalpha(0x010d))
+ phon_out = GetTranslatedPhonemeString(phoneme_mode);
+ if(option_phonemes > 0)
{
- // check that c-caron is recognized as an alphabetic character
- fprintf(stderr,"Warning: Accented letters are not recognized, eg: U+010D\nSet LC_CTYPE to a UTF-8 locale\n");
+ fprintf(f_trans,"%s\n",phon_out);
+ }
+ if(phoneme_callback != NULL)
+ {
+ phoneme_callback(phon_out);
}
- }
- if(phoneme_callback != NULL)
- {
- phoneme_callback(translator->phon_out);
}
@@ -1622,20 +1986,6 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
return(1);
}
- if(mbrola_name[0] != 0)
- {
-#ifdef USE_MBROLA_LIB
- MbrolaTranslate(phoneme_list,n_phoneme_list,NULL);
-#else
- {
- FILE *f_mbrola;
- if((f_mbrola = f_trans) == stderr)
- f_mbrola = stdout;
- MbrolaTranslate(phoneme_list,n_phoneme_list,f_mbrola);
- }
-#endif
- }
-
Generate(phoneme_list,&n_phoneme_list,0);
WavegenOpenSound();
diff --git a/navit/support/espeak/synthesize.h b/navit/support/espeak/synthesize.h
index 193b93297..7bc234c8d 100755..100644
--- a/navit/support/espeak/synthesize.h
+++ b/navit/support/espeak/synthesize.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -17,6 +17,8 @@
* <http://www.gnu.org/licenses/>. *
***************************************************************************/
+#define espeakINITIALIZE_PHONEME_IPA 0x0002 // move this to speak_lib.h, after eSpeak version 1.46.02
+
#define N_PHONEME_LIST 1000 // enough for source[N_TR_SOURCE] full of text, else it will truncate
@@ -24,9 +26,6 @@
#define N_SEQ_FRAMES 25 // max frames in a spectrum sequence (real max is ablut 8)
#define STEPSIZE 64 // 2.9mS at 22 kHz sample rate
-#define PITCHfall 0
-#define PITCHrise 1
-
// flags set for frames within a spectrum sequence
#define FRFLAG_KLATT 0x01 // this frame includes extra data for Klatt synthesizer
#define FRFLAG_VOWEL_CENTRE 0x02 // centre point of vowel
@@ -37,6 +36,7 @@
#define FRFLAG_FORMANT_RATE 0x20 // Flag5 allow increased rate of change of formant freq
#define FRFLAG_MODULATE 0x40 // Flag6 modulate amplitude of some cycles to give trill
#define FRFLAG_DEFER_WAV 0x80 // Flag7 defer mixing WAV until the next frame
+#define FRFLAG_LEN_MOD2 0x4000 // reduce effect of length adjustment, used for the start of a vowel
#define FRFLAG_COPIED 0x8000 // This frame has been copied into temporary rw memory
#define SFLAG_SEQCONTINUE 0x01 // a liquid or nasal after a vowel, but not followed by a vowel
@@ -47,13 +47,16 @@
#define SFLAG_SWITCHED_LANG 0x20 // this word uses phonemes from a different language
#define SFLAG_PROMOTE_STRESS 0x40 // this unstressed word can be promoted to stressed
+#define SFLAG_PREV_PAUSE 0x1000 // consider previous phoneme as pause
+#define SFLAG_NEXT_PAUSE 0x2000 // consider next phoneme as pause
+
// embedded command numbers
#define EMBED_P 1 // pitch
#define EMBED_S 2 // speed (used in setlengths)
#define EMBED_A 3 // amplitude/volume
#define EMBED_R 4 // pitch range/expression
#define EMBED_H 5 // echo/reverberation
-#define EMBED_T 6 // different tone for announcing punctuation
+#define EMBED_T 6 // different tone for announcing punctuation (not used)
#define EMBED_I 7 // sound icon
#define EMBED_S2 8 // speed (used in synthesize)
#define EMBED_Y 9 // say-as commands
@@ -61,13 +64,15 @@
#define EMBED_U 11 // audio uri
#define EMBED_B 12 // break
#define EMBED_F 13 // emphasis
+#define EMBED_C 14 // capital letter indication
-#define N_EMBEDDED_VALUES 14
+#define N_EMBEDDED_VALUES 15
extern int embedded_value[N_EMBEDDED_VALUES];
extern int embedded_default[N_EMBEDDED_VALUES];
#define N_PEAKS 9
+#define N_PEAKS2 9 // plus Notch and Fill (not yet implemented)
#define N_MARKERS 8
#define N_KLATTP 10 // this affects the phoneme data file format
@@ -87,7 +92,7 @@ extern int embedded_default[N_EMBEDDED_VALUES];
-typedef struct { // 44 bytes
+typedef struct { // 64 bytes
short frflags;
short ffreq[7];
unsigned char length;
@@ -100,8 +105,10 @@ typedef struct { // 44 bytes
unsigned char klattp2[5]; // continuation of klattp[], Avp, Fric, FricBP, Turb
unsigned char klatt_ap[7]; // Klatt parallel amplitude
unsigned char klatt_bp[7]; // Klatt parallel bandwidth /2
+ unsigned char spare; // pad to multiple of 4 bytes
} frame_t; // with extra Klatt parameters for parallel resonators
+
typedef struct { // 44 bytes
short frflags;
short ffreq[7];
@@ -112,32 +119,7 @@ typedef struct { // 44 bytes
unsigned char fright[3]; // width/4 f0-2
unsigned char bw[4]; // Klatt bandwidth BNZ /2, f1,f2,f3
unsigned char klattp[5]; // AV, FNZ, Tilt, Aspr, Skew
-} frame_t2; // TESTING
-
-
-#ifdef deleted
-typedef struct {
- short frflags;
- unsigned char length;
- unsigned char rms;
- short ffreq[9];
- unsigned char fheight[9];
- unsigned char fwidth[6]; // width/4
- unsigned char fright[6]; // width/4
- unsigned char fwidth6, fright6;
- unsigned char klattp[N_KLATTP];
-} frame_t;
-
-typedef struct { // 43 bytes
- short frflags;
- unsigned char length;
- unsigned char rms;
- short ffreq[9];
- unsigned char fheight[9];
- unsigned char fwidth[6]; // width/4
- unsigned char fright[6]; // width/4
-} frame_t2; // the original, without Klatt additions, used for file "phondata"
-#endif
+} frame_t2; // without the extra Klatt parameters
@@ -170,10 +152,12 @@ int n_mix_wavefile; // length in bytes
int mix_wave_scale; // 0=2 byte samples
int mix_wave_amp;
int mix_wavefile_ix;
+int mix_wavefile_max; // length of available WAV data (in bytes)
+int mix_wavefile_offset;
int amplitude;
int amplitude_v;
-int prev_was_synth; // previous sound was synthesized (not a played wave or pause)
+int amplitude_fmt; // percentage amplitude adjustment for formant synthesis
} WGEN_DATA;
@@ -189,14 +173,14 @@ typedef struct {
typedef struct {
short length_total; // not used
unsigned char n_frames;
- unsigned char flags;
+ unsigned char sqflags;
frame_t2 frame[N_SEQ_FRAMES]; // max. frames in a spectrum sequence
} SPECT_SEQ; // sequence of espeak formant frames
typedef struct {
short length_total; // not used
unsigned char n_frames;
- unsigned char flags;
+ unsigned char sqflags;
frame_t frame[N_SEQ_FRAMES]; // max. frames in a spectrum sequence
} SPECT_SEQK; // sequence of klatt formants frames
@@ -207,24 +191,176 @@ typedef struct {
frame_t *frame;
} frameref_t;
+// a clause translated into phoneme codes (first stage)
+typedef struct {
+ unsigned short synthflags; // NOTE Put shorts on 32bit boundaries, because of RISC OS compiler bug?
+ unsigned char phcode;
+ unsigned char stresslevel;
+ unsigned short sourceix; // ix into the original source text string, only set at the start of a word
+ unsigned char wordstress; // the highest level stress in this word
+ unsigned char tone_ph; // tone phoneme to use with this vowel
+} PHONEME_LIST2;
+
typedef struct {
+// The first section is a copy of PHONEME_LIST2
+ unsigned short synthflags;
+ unsigned char phcode;
+ unsigned char stresslevel;
+ unsigned short sourceix; // ix into the original source text string, only set at the start of a word
+ unsigned char wordstress; // the highest level stress in this word
+ unsigned char tone_ph; // tone phoneme to use with this vowel
+
PHONEME_TAB *ph;
+ unsigned int length; // length_mod
unsigned char env; // pitch envelope number
- unsigned char stresslevel;
unsigned char type;
unsigned char prepause;
+ unsigned char postpause;
unsigned char amp;
- unsigned char tone_ph; // tone phoneme to use with this vowel
unsigned char newword; // bit 0=start of word, bit 1=end of clause, bit 2=start of sentence
- unsigned char synthflags;
- short length; // length_mod
- short pitch1; // pitch, 0-4095 within the Voice's pitch range
- short pitch2;
- unsigned short sourceix; // ix into the original source text string, only set at the start of a word
+ unsigned char pitch1;
+ unsigned char pitch2;
+#ifdef _ESPEAKEDIT
+ unsigned char std_length;
+ unsigned int phontab_addr;
+ int sound_param;
+#endif
} PHONEME_LIST;
+#define pd_FMT 0
+#define pd_WAV 1
+#define pd_VWLSTART 2
+#define pd_VWLEND 3
+#define pd_ADDWAV 4
+
+#define N_PHONEME_DATA_PARAM 16
+#define pd_INSERTPHONEME i_INSERT_PHONEME
+#define pd_APPENDPHONEME i_APPEND_PHONEME
+#define pd_CHANGEPHONEME i_CHANGE_PHONEME
+#define pd_CHANGE_NEXTPHONEME i_REPLACE_NEXT_PHONEME
+#define pd_LENGTHMOD i_SET_LENGTH
+
+#define pd_FORNEXTPH 0x2
+#define pd_DONTLENGTHEN 0x4
+#define pd_REDUCELENGTHCHANGE 0x8
+typedef struct {
+ int pd_control;
+ int pd_param[N_PHONEME_DATA_PARAM]; // set from group 0 instructions
+ int sound_addr[5];
+ int sound_param[5];
+ int vowel_transition[4];
+ int pitch_env;
+ int amp_env;
+ char ipa_string[18];
+} PHONEME_DATA;
+
+
+typedef struct {
+ int fmt_control;
+ int use_vowelin;
+ int fmt_addr;
+ int fmt_length;
+ int fmt_amp;
+ int fmt2_addr;
+ int fmt2_lenadj;
+ int wav_addr;
+ int wav_amp;
+ int transition0;
+ int transition1;
+ int std_length;
+} FMT_PARAMS;
+
+typedef struct {
+ PHONEME_LIST prev_vowel;
+} WORD_PH_DATA;
+
+// instructions
+
+#define i_RETURN 0x0001
+#define i_CONTINUE 0x0002
+#define i_NOT 0x0003
+
+// Group 0 instrcutions with 8 bit operand. These values go into bits 8-15 of the instruction
+#define i_CHANGE_PHONEME 0x01
+#define i_REPLACE_NEXT_PHONEME 0x02
+#define i_INSERT_PHONEME 0x03
+#define i_APPEND_PHONEME 0x04
+#define i_APPEND_IFNEXTVOWEL 0x05
+#define i_VOICING_SWITCH 0x06
+#define i_PAUSE_BEFORE 0x07
+#define i_PAUSE_AFTER 0x08
+#define i_LENGTH_MOD 0x09
+#define i_SET_LENGTH 0x0a
+#define i_LONG_LENGTH 0x0b
+#define i_CHANGE_PHONEME2 0x0c // not yet used
+#define i_IPA_NAME 0x0d
+
+#define i_CHANGE_IF 0x10 // 0x10 to 0x14
+
+#define i_ADD_LENGTH 0x0c
+
+
+// conditions and jumps
+#define i_CONDITION 0x2000
+#define i_OR 0x1000 // added to i_CONDITION
+
+#define i_JUMP 0x6000
+#define i_JUMP_FALSE 0x6800
+#define i_SWITCH_NEXTVOWEL 0x6a00
+#define i_SWITCH_PREVVOWEL 0x6c00
+#define MAX_JUMP 255 // max jump distance
+
+// multi-word instructions
+#define i_CALLPH 0x9100
+#define i_PITCHENV 0x9200
+#define i_AMPENV 0x9300
+#define i_VOWELIN 0xa100
+#define i_VOWELOUT 0xa200
+#define i_FMT 0xb000
+#define i_WAV 0xc000
+#define i_VWLSTART 0xd000
+#define i_VWLENDING 0xe000
+#define i_WAVADD 0xf000
+
+// conditions
+#define i_isDiminished 0x80
+#define i_isUnstressed 0x81
+#define i_isNotStressed 0x82
+#define i_isStressed 0x83
+#define i_isMaxStress 0x84
+
+#define i_isBreak 0x85
+#define i_isWordStart 0x86
+#define i_notWordStart 0x87
+#define i_isWordEnd 0x88
+#define i_isAfterStress 0x89
+#define i_isNotVowel 0x8a
+#define i_isFinalVowel 0x8b
+#define i_isVoiced 0x8c
+#define i_isFirstVowel 0x8d
+#define i_isSecondVowel 0x8e
+#define i_isSeqFlag1 0x8f
+#define i_IsTranslationGiven 0x90
+
+
+// place of articulation
+#define i_isVel 0x28
+
+// phflags
+#define i_isSibilant 0x45 // bit 5 in phflags
+#define i_isPalatal 0x49 // bit 9 in phflags
+#define i_isLong 0x55 // bit 21 in phflags
+#define i_isRhotic 0x57 // bit 23 in phflags
+#define i_isFlag1 0x5c
+#define i_isFlag2 0x5d
+#define i_isFlag3 0x5e
+
+#define i_StressLevel 0x800
+
+
+
typedef struct {
int name;
int length;
@@ -242,20 +378,71 @@ typedef struct {
} MBROLA_TAB;
typedef struct {
- int speed_factor1;
- int speed_factor2;
- int speed_factor3;
+ int pause_factor;
+ int clause_pause_factor;
+ unsigned int min_pause;
+ int wav_factor;
+ int lenmod_factor;
+ int lenmod2_factor;
int min_sample_len;
+ int loud_consonants;
int fast_settings[8];
} SPEED_FACTORS;
+typedef struct {
+ char name[12];
+ unsigned char flags[4];
+ signed char head_extend[8];
+
+ unsigned char prehead_start;
+ unsigned char prehead_end;
+ unsigned char stressed_env;
+ unsigned char stressed_drop;
+ unsigned char secondary_drop;
+ unsigned char unstressed_shape;
+
+ unsigned char onset;
+ unsigned char head_start;
+ unsigned char head_end;
+ unsigned char head_last;
+
+ unsigned char head_max_steps;
+ unsigned char n_head_extend;
+
+ signed char unstr_start[3]; // for: onset, head, last
+ signed char unstr_end[3];
+
+ unsigned char nucleus0_env; // pitch envelope, tonic syllable is at end, no tail
+ unsigned char nucleus0_max;
+ unsigned char nucleus0_min;
+
+ unsigned char nucleus1_env; // when followed by a tail
+ unsigned char nucleus1_max;
+ unsigned char nucleus1_min;
+ unsigned char tail_start;
+ unsigned char tail_end;
+
+ unsigned char split_nucleus_env;
+ unsigned char split_nucleus_max;
+ unsigned char split_nucleus_min;
+ unsigned char split_tail_start;
+ unsigned char split_tail_end;
+ unsigned char split_tune;
+
+ unsigned char spare[8];
+ int spare2; // the struct length should be a multiple of 4 bytes
+} TUNE;
+
+extern int n_tunes;
+extern TUNE *tunes;
+
// phoneme table
extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
// list of phonemes in a clause
extern int n_phoneme_list;
-extern PHONEME_LIST phoneme_list[N_PHONEME_LIST];
+extern PHONEME_LIST phoneme_list[N_PHONEME_LIST+1];
extern unsigned int embedded_list[];
extern unsigned char env_fall[128];
@@ -278,27 +465,31 @@ extern unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1];
#define WCMD_MARKER 10
#define WCMD_VOICE 11
#define WCMD_EMBEDDED 12
+#define WCMD_MBROLA_DATA 13
+#define WCMD_FMT_AMPLITUDE 14
+#define WCMD_SONIC_SPEED 15
+
-#define N_WCMDQ 160
-#define MIN_WCMDQ 22 // need this many free entries before adding new phoneme
+#define N_WCMDQ 170
+#define MIN_WCMDQ 25 // need this many free entries before adding new phoneme
-extern long wcmdq[N_WCMDQ][4];
+extern long64 wcmdq[N_WCMDQ][4];
extern int wcmdq_head;
extern int wcmdq_tail;
// from Wavegen file
-int WcmdqFree();
-void WcmdqStop();
-int WcmdqUsed();
-void WcmdqInc();
-int WavegenOpenSound();
-int WavegenCloseSound();
-int WavegenInitSound();
+int WcmdqFree(void);
+void WcmdqStop(void);
+int WcmdqUsed(void);
+void WcmdqInc(void);
+int WavegenOpenSound(void);
+int WavegenCloseSound(void);
+int WavegenInitSound(void);
void WavegenInit(int rate, int wavemult_fact);
float polint(float xa[],float ya[],int n,float x);
int WavegenFill(int fill_zeros);
-void MarkerEvent(int type, unsigned int char_position, int value, unsigned char *out_ptr);
+void MarkerEvent(int type, unsigned int char_position, int value, int value2, unsigned char *out_ptr);
extern unsigned char *wavefile_data;
@@ -312,15 +503,21 @@ extern int wavefile_amp2;
extern int vowel_transition[4];
extern int vowel_transition0, vowel_transition1;
+#define N_ECHO_BUF 5500 // max of 250mS at 22050 Hz
+extern int echo_head;
+extern int echo_tail;
+extern int echo_amp;
+extern short echo_buf[N_ECHO_BUF];
+
extern int mbrola_delay;
extern char mbrola_name[20];
// from synthdata file
unsigned int LookupSound(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int *match_level, int control);
-frameref_t *LookupSpect(PHONEME_TAB *ph1, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph, int which, int *match_level, int *n_frames, PHONEME_LIST *plist);
+frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, int *n_frames, PHONEME_LIST *plist);
unsigned char *LookupEnvelope(int ix);
-int LoadPhData();
+int LoadPhData(int *srate);
void SynthesizeInit(void);
int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume);
@@ -335,10 +532,16 @@ int SelectPhonemeTableName(const char *name);
void Write4Bytes(FILE *f, int value);
int Read4Bytes(FILE *f);
+int Reverse4Bytes(int word);
int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, char *err_name,int flags);
-extern unsigned char *envelope_data[18];
+#define ENV_LEN 128 // length of pitch envelopes
+#define PITCHfall 0 // standard pitch envelopes
+#define PITCHrise 2
+#define N_ENVELOPE_DATA 20
+extern unsigned char *envelope_data[N_ENVELOPE_DATA];
+
extern int formant_rate[]; // max rate of change of each formant
extern SPEED_FACTORS speed;
@@ -353,6 +556,7 @@ extern t_espeak_callback* synth_callback;
extern int option_log_frames;
extern const char *version_string;
extern const int version_phdata;
+extern double sonicSpeed;
#define N_SOUNDICON_TAB 80 // total entries in soundicon_tab
#define N_SOUNDICON_SLOTS 4 // number of slots reserved for dynamic loading of audio files
@@ -363,15 +567,24 @@ espeak_ERROR SetVoiceByName(const char *name);
espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector);
espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int srate);
void SetParameter(int parameter, int value, int relative);
-void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola);
-//int MbrolaSynth(char *p_mbrola);
-int DoSample(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int length_mod, int amp);
-int DoSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph,
- int which, PHONEME_LIST *plist, int modulation);
+int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbrola);
+int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume);
+int MbrolaFill(int length, int resume, int amplitude);
+void MbrolaReset(void);
+void DoEmbedded(int *embix, int sourceix);
+void DoMarker(int type, int char_posn, int length, int value);
+void DoPhonemeMarker(int type, int char_posn, int length, char *name);
+int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp);
+int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_LIST *plist, int modulation);
int PauseLength(int pause, int control);
int LookupPhonemeTable(const char *name);
+unsigned char *GetEnvelope(int index);
+int NumInstnWords(USHORT *prog);
void InitBreath(void);
-void KlattInit();
+void KlattInit(void);
+void KlattReset(int control);
int Wavegen_Klatt2(int length, int modulation, int resume, frame_t *fr1, frame_t *fr2);
+void DoSonicSpeed(int value);
+int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsigned int data2, PHONEME_TAB *other_ph, int which);
diff --git a/navit/support/espeak/tr_languages.c b/navit/support/espeak/tr_languages.c
index 83d1c8041..b1913f205 100644
--- a/navit/support/espeak/tr_languages.c
+++ b/navit/support/espeak/tr_languages.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -39,22 +39,109 @@
#define L_qa 0x716100
#define L_grc 0x677263 // grc Ancient Greek
#define L_jbo 0x6a626f // jbo Lojban
-#define L_pap 0x706170 // pap Papiamento
+#define L_mni 0x6d6e69 // mni Manipuri
+#define L_pap 0x706170 // pap Papiamento]
+#define L_qvi 0x717669 // qvi Kichwa
+#define L_shs 0x736873 // shs Shuswap / Secwepemctsin
#define L_zhy 0x7a6879 // zhy
// start of unicode pages for character sets
-#define OFFSET_GREEK 0x380
+#define OFFSET_GREEK 0x380
#define OFFSET_CYRILLIC 0x420
#define OFFSET_ARMENIAN 0x530
+#define OFFSET_HEBREW 0x590
+#define OFFSET_ARABIC 0x600
+#define OFFSET_THAANA 0x780 // Divehi/Maldives
#define OFFSET_DEVANAGARI 0x900
-#define OFFSET_BENGALI 0x980
-#define OFFSET_TAMIL 0xb80
-#define OFFSET_KANNADA 0xc80
+#define OFFSET_BENGALI 0x980
+#define OFFSET_GURMUKHI 0xa00
+#define OFFSET_GUJARATI 0xa80
+#define OFFSET_ORIYA 0xb00
+#define OFFSET_TAMIL 0xb80
+#define OFFSET_TELUGU 0xc00
+#define OFFSET_KANNADA 0xc80
#define OFFSET_MALAYALAM 0xd00
-#define OFFSET_KOREAN 0x1100
+#define OFFSET_SINHALA 0x0d80
+#define OFFSET_THAI 0x0e00
+#define OFFSET_LAO 0x0e80
+#define OFFSET_TIBET 0x0f00
+#define OFFSET_MYANMAR 0x1000
+#define OFFSET_GEORGIAN 0x10a0
+#define OFFSET_KOREAN 0x1100
+#define OFFSET_ETHIOPIC 0x1200
+
+
+// character ranges must be listed in ascending order
+ALPHABET alphabets [] = {
+ {"_el", OFFSET_GREEK, 0x380, 0x3ff, L('e','l'), AL_DONT_NAME | AL_NOT_LETTERS},
+ {"_cyr", OFFSET_CYRILLIC, 0x400, 0x52f, 0, 0},
+ {"_hy", OFFSET_ARMENIAN, 0x530, 0x58f, L('h','y'), AL_WORDS},
+ {"_he", OFFSET_HEBREW, 0x590, 0x5ff, 0, 0},
+ {"_ar", OFFSET_ARABIC, 0x600, 0x6ff, 0, 0},
+ {"_dv", OFFSET_THAANA, 0x780, 0x7bf, 0, 0},
+ {"_hi", OFFSET_DEVANAGARI, 0x900, 0x97f,L('h','i'), AL_WORDS},
+ {"_bn", OFFSET_BENGALI, 0x0980, 0x9ff, L('b','n'), AL_WORDS},
+ {"_gur", OFFSET_GURMUKHI, 0xa00, 0xa7f, L('p','a'), AL_WORDS},
+ {"_gu", OFFSET_GUJARATI, 0xa80, 0xaff, L('g','u'), AL_WORDS},
+ {"_or", OFFSET_ORIYA, 0xb00, 0xb7f, 0, 0},
+ {"_ta", OFFSET_TAMIL, 0xb80, 0xbff, L('t','a'), AL_WORDS},
+ {"_te", OFFSET_TELUGU, 0xc00, 0xc7f, L('t','e'), 0},
+ {"_kn", OFFSET_KANNADA, 0xc80, 0xcff, L('k','n'), AL_WORDS},
+ {"_ml", OFFSET_MALAYALAM,0xd00, 0xd7f, L('m','l'), AL_WORDS},
+ {"_si", OFFSET_SINHALA, 0xd80, 0xdff, L('s','i'), AL_WORDS},
+ {"_th", OFFSET_THAI, 0xe00, 0xe7f, 0, 0},
+ {"_lo", OFFSET_LAO, 0xe80, 0xeff, 0, 0},
+ {"_ti", OFFSET_TIBET, 0xf00, 0xfff, 0, 0},
+ {"_my", OFFSET_MYANMAR, 0x1000,0x109f, 0, 0},
+ {"_ka", OFFSET_GEORGIAN, 0x10a0,0x10ff, L('k','a'), AL_WORDS},
+ {"_ko", OFFSET_KOREAN, 0x1100,0x11ff, L('k','o'), AL_WORDS},
+ {"_eth", OFFSET_ETHIOPIC, 0x1200,0x139f, 0, 0},
+ {"_braille", 0x2800, 0x2800,0x28ff, 0, AL_NO_SYMBOL},
+ {"_ja", 0x3040, 0x3040,0x30ff, 0, AL_NOT_CODE},
+ {"_zh", 0x3100, 0x3100,0x9fff, 0, AL_NOT_CODE},
+ {"_ko", 0xa700, 0xa700,0xd7ff, L('k','o'), AL_NOT_CODE | AL_WORDS},
+ {NULL, 0, 0, 0, 0, 0}
+};
+
+
+ALPHABET *AlphabetFromName(const char *name)
+{//==========================================
+ ALPHABET *alphabet;
+
+ for(alphabet=alphabets; alphabet->name != NULL; alphabet++)
+ {
+ if(strcmp(name, &alphabet->name[1]) == 0)
+ return(alphabet);
+ }
+ return(NULL);
+}
+
+
+ALPHABET *AlphabetFromChar(int c)
+{//===============================
+ // Find the alphabet from a character.
+ ALPHABET *alphabet = alphabets;
+
+ while(alphabet->name != NULL)
+ {
+ if(c <= alphabet->range_max)
+ {
+ if(c >= alphabet->range_min)
+ return(alphabet);
+ else
+ break;
+ }
+ alphabet++;
+ }
+ return(NULL);
+}
+
+
static void Translator_Russian(Translator *tr);
+
+
static void SetLetterVowel(Translator *tr, int c)
{//==============================================
tr->letter_bits[c] = (tr->letter_bits[c] & 0x40) | 0x81; // keep value for group 6 (front vowels e,i,y)
@@ -78,7 +165,7 @@ static void SetLetterBits(Translator *tr, int group, const char *string)
{//=====================================================================
int bits;
unsigned char c;
-
+
bits = (1L << group);
while((c = *string++) != 0)
tr->letter_bits[c] |= bits;
@@ -96,15 +183,58 @@ static void SetLetterBitsRange(Translator *tr, int group, int first, int last)
}
}
+// ignore these characters
+static const unsigned short chars_ignore_default[] = {
+ 0xad, 1, // soft hyphen
+ 0x200c, 1, // zero width non-joiner
+ 0x200d, 1, // zero width joiner
+ 0, 0 };
+
+// alternatively, ignore characters but allow zero-width-non-joiner (lang-fa)
+static const unsigned short chars_ignore_zwnj_hyphen[] = {
+ 0xad, 1, // soft hyphen
+ 0x640, 1, // igniore Arabic Tatweel (lang=FA)
+ 0x200c, '-', // zero width non-joiner, replace with hyphen
+ 0x200d, 1, // zero width joiner
+ 0, 0 };
+
+//const char string_ordinal[] = {0xc2,0xba,0}; // masculine ordinal character, UTF-8
+const char string_ordinal[] = "\xc2\xba"; // masculine ordinal character, UTF-8
+
static Translator* NewTranslator(void)
{//===================================
Translator *tr;
int ix;
- static const unsigned char stress_amps2[] = {17,17, 20,20, 20,22, 22,20 };
+ static const unsigned char stress_amps2[] = {18,18, 20,20, 20,22, 22,20 };
static const short stress_lengths2[8] = {182,140, 220,220, 220,240, 260,280};
static const wchar_t empty_wstring[1] = {0};
static const wchar_t punct_in_word[2] = {'\'', 0}; // allow hyphen within words
+ static const unsigned char default_tunes[6] = {0, 1, 2, 3, 0, 0};
+
+// Translates character codes in the range transpose_min to transpose_max to
+// a number in the range 1 to 63. 0 indicates there is no translation.
+// Used up to 57 (max of 63)
+static const char transpose_map_latin[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x60
+16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, // 0x70
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0
+27, 28, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 0, 37, 38, 0, // 0xe0
+ 0, 0, 0, 39, 0, 0, 40, 0, 41, 0, 42, 0, 43, 0, 0, 0, // 0xf0
+ 0, 0, 0, 44, 0, 45, 0, 46, 0, 0, 0, 0, 0, 47, 0, 0, // 0x100
+ 0, 48, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, // 0x110
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x120
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x130
+ 0, 0, 50, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x140
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, // 0x150
+ 0, 53, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x160
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 56, 0, 57, 0, // 0x170
+};
tr = (Translator *)Alloc(sizeof(Translator));
if(tr == NULL)
@@ -112,18 +242,23 @@ static Translator* NewTranslator(void)
tr->charset_a0 = charsets[1]; // ISO-8859-1, this is for when the input is not utf8
dictionary_name[0] = 0;
+ tr->dictionary_name[0] = 0;
tr->dict_condition=0;
+ tr->dict_min_size = 0;
tr->data_dictrules = NULL; // language_1 translation rules file
tr->data_dictlist = NULL; // language_2 dictionary lookup file
- tr->transpose_offset = 0;
+ tr->transpose_min = 0x60;
+ tr->transpose_max = 0x17f;
+ tr->transpose_map = transpose_map_latin;
+ tr->frequent_pairs = NULL;
// only need lower case
tr->letter_bits_offset = 0;
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
memset(tr->letter_groups,0,sizeof(tr->letter_groups));
- // 0-5 sets of characters matched by A B C E F G in pronunciation rules
+ // 0-6 sets of characters matched by A B C H F G Y in pronunciation rules
// these may be set differently for different languages
SetLetterBits(tr,0,"aeiou"); // A vowels, except y
SetLetterBits(tr,1,"bcdfgjklmnpqstvxz"); // B hard consonants, excluding h,r,w
@@ -137,6 +272,7 @@ static Translator* NewTranslator(void)
tr->char_plus_apostrophe = empty_wstring;
tr->punct_within_word = punct_in_word;
+ tr->chars_ignore = chars_ignore_default;
for(ix=0; ix<8; ix++)
{
@@ -145,16 +281,23 @@ static Translator* NewTranslator(void)
tr->stress_lengths[ix] = stress_lengths2[ix];
}
memset(&(tr->langopts),0,sizeof(tr->langopts));
+ tr->langopts.max_lengthmod = 500;
+ tr->langopts.lengthen_tonic = 20;
- tr->langopts.stress_rule = 2;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.unstressed_wd1 = 1;
tr->langopts.unstressed_wd2 = 3;
tr->langopts.param[LOPT_SONORANT_MIN] = 95;
+ tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 190/2;
tr->langopts.param[LOPT_MAXAMP_EOC] = 19;
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 's'; // don't count this character at start of word
+ tr->langopts.param[LOPT_BRACKET_PAUSE] = 4; // pause at bracket
+ tr->langopts.param2[LOPT_BRACKET_PAUSE] = 2; // pauses when announcing bracket names
tr->langopts.max_initial_consonants = 3;
tr->langopts.replace_chars = NULL;
- tr->langopts.ascii_language = ""; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
+ tr->langopts.ascii_language[0] = 0; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
+ tr->langopts.alt_alphabet_lang = L('e','n');
+ tr->langopts.roman_suffix = "";
SetLengthMods(tr,201);
// tr->langopts.length_mods = length_mods_en;
@@ -163,16 +306,59 @@ static Translator* NewTranslator(void)
tr->langopts.long_stop = 100;
tr->langopts.max_roman = 49;
+ tr->langopts.min_roman = 2;
tr->langopts.thousands_sep = ',';
tr->langopts.decimal_sep = '.';
+ tr->langopts.break_numbers = BREAK_THOUSANDS; // 1000, 1000,000 1,000,000 etc
+ tr->langopts.max_digits = 14;
memcpy(tr->punct_to_tone, punctuation_to_tone, sizeof(tr->punct_to_tone));
+ memcpy(tr->langopts.tunes, default_tunes, sizeof(tr->langopts.tunes));
+
return(tr);
}
-
-static const unsigned int replace_cyrillic_latin[] =
+// common letter pairs, encode these as a single byte
+// 2 bytes, using the transposed character codes
+static const short pairs_ru[] = {
+0x010c, // ла 21052 0x23
+0x010e, // на 18400
+0x0113, // та 14254
+0x0301, // ав 31083
+0x030f, // ов 13420
+0x060e, // не 21798
+0x0611, // ре 19458
+0x0903, // ви 16226
+0x0b01, // ак 14456
+0x0b0f, // ок 17836
+0x0c01, // ал 13324
+0x0c09, // ил 16877
+0x0e01, // ан 15359
+0x0e06, // ен 13543 0x30
+0x0e09, // ин 17168
+0x0e0e, // нн 15973
+0x0e0f, // он 22373
+0x0e1c, // ын 15052
+0x0f03, // во 24947
+0x0f11, // ро 13552
+0x0f12, // со 16368
+0x100f, // оп 19054
+0x1011, // рп 17067
+0x1101, // ар 23967
+0x1106, // ер 18795
+0x1109, // ир 13797
+0x110f, // ор 21737
+0x1213, // тс 25076
+0x1220, // яс 14310
+0x7fff};
+//0x040f ог 12976
+//0x1306 ет 12826
+//0x0f0d мо 12688
+
+
+
+static const unsigned int replace_cyrillic_latin[] =
{0x430,'a',
0x431,'b',
0x446,'c',
@@ -209,25 +395,63 @@ static const unsigned int replace_cyrillic_latin[] =
0}; // ѓ ѕ ќ
-void SetIndicLetters(Translator *tr)
+static const unsigned char ru_vowels[] = {0x10,0x15,0x31,0x18,0x1e,0x23,0x2b,0x2d,0x2e,0x2f, 0xb9,0xc9,0x91,0x8f,0x36,0}; //also kazakh
+static const unsigned char ru_consonants[] = {0x11,0x12,0x13,0x14,0x16,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2c, 0x73,0x7b,0x83,0x9b,0};
+
+static void SetCyrillicLetters(Translator *tr)
+{//===========================================
+ // character codes offset by 0x420
+ static const char ru_soft[] = {0x2c,0x19,0x27,0x29,0}; // letter group B [k ts; s;]
+ static const char ru_hard[] = {0x2a,0x16,0x26,0x28,0}; // letter group H [S Z ts]
+ static const char ru_nothard[] = {0x11,0x12,0x13,0x14,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x27,0x29,0x2c,0};
+ static const char ru_voiced[] = {0x11,0x12,0x13,0x14,0x16,0x17,0}; // letter group G (voiced obstruents)
+ static const char ru_ivowels[] = {0x2c,0x2e,0x2f,0x31,0}; // letter group Y (iotated vowels & soft-sign)
+ tr->charset_a0 = charsets[18]; // KOI8-R
+ tr->transpose_min = 0x430; // convert cyrillic from unicode into range 0x01 to 0x22
+ tr->transpose_max = 0x451;
+ tr->transpose_map = NULL;
+ tr->frequent_pairs = pairs_ru;
+
+ tr->letter_bits_offset = OFFSET_CYRILLIC;
+ memset(tr->letter_bits,0,sizeof(tr->letter_bits));
+ SetLetterBits(tr,LETTERGP_A,(char *)ru_vowels);
+ SetLetterBits(tr,LETTERGP_B,ru_soft);
+ SetLetterBits(tr,LETTERGP_C,(char *)ru_consonants);
+ SetLetterBits(tr,LETTERGP_H,ru_hard);
+ SetLetterBits(tr,LETTERGP_F,ru_nothard);
+ SetLetterBits(tr,LETTERGP_G,ru_voiced);
+ SetLetterBits(tr,LETTERGP_Y,ru_ivowels);
+ SetLetterBits(tr,LETTERGP_VOWEL2,(char *)ru_vowels);
+} // end of SetCyrillicLetters
+
+
+static void SetIndicLetters(Translator *tr)
{//=================================
// Set letter types for Indic scripts, Devanagari, Tamill, etc
- static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f};
+ static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,0x7b,0x7c,0x7e,0x7f,0};
+ static const char dev_vowels2[] = {0x60,0x61, 0x55,0x56,0x57,0x62,0x63,0}; // non-consecutive vowels and vowel-signs
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
- SetLetterBitsRange(tr,LETTERGP_A,0x04,0x14); // vowel letters only
+ SetLetterBitsRange(tr,LETTERGP_A,0x04,0x14); // vowel letters
+ SetLetterBitsRange(tr,LETTERGP_A,0x3e,0x4d); // + vowel signs, and virama
+ SetLetterBits(tr,LETTERGP_A, dev_vowels2); // + extra vowels and vowel signs
+
SetLetterBitsRange(tr,LETTERGP_B,0x3e,0x4d); // vowel signs, and virama
+ SetLetterBits(tr,LETTERGP_B, dev_vowels2); // + extra vowels and vowel signs
SetLetterBitsRange(tr,LETTERGP_C,0x15,0x39); // the main consonant range
SetLetterBits(tr,LETTERGP_C,dev_consonants2); // + additional consonants
SetLetterBitsRange(tr,LETTERGP_Y,0x04,0x14); // vowel letters
SetLetterBitsRange(tr,LETTERGP_Y,0x3e,0x4c); // + vowel signs
+ SetLetterBits(tr,LETTERGP_Y, dev_vowels2); // + extra vowels and vowel signs
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+ tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4d; //virama
}
-void SetupTranslator(Translator *tr, const short *lengths, const unsigned char *amps)
+
+static void SetupTranslator(Translator *tr, const short *lengths, const unsigned char *amps)
{//==================================================================================
if(lengths != NULL)
memcpy(tr->stress_lengths,lengths,sizeof(tr->stress_lengths));
@@ -241,15 +465,26 @@ Translator *SelectTranslator(const char *name)
int name2 = 0;
Translator *tr;
- static const unsigned char stress_amps_sk[8] = {17,17, 20,20, 20,22, 22,21 };
+ static const short stress_lengths_equal[8] = {230, 230, 230, 230, 0, 0, 230, 230};
+ static const unsigned char stress_amps_equal[8] = {19,19, 19,19, 19,19, 19,19 };
+
+ static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 190, 240};
+ static const unsigned char stress_amps_fr[8] = {18,16, 18,18, 18,18, 18,18 };
+
+ static const unsigned char stress_amps_sk[8] = {17,16, 20,20, 20,22, 22,21 };
static const short stress_lengths_sk[8] = {190,190, 210,210, 0,0, 210,210};
+ static const short stress_lengths_ta[8] = {200, 200, 210, 210, 0, 0, 230, 230};
+ static const short stress_lengths_ta2[8] = {230, 230, 240, 240, 0, 0, 260, 260};
+ static const unsigned char stress_amps_ta[8] = {18,18, 18,18, 20,20, 22,22 };
+
+ tr = NewTranslator();
+ strcpy(tr->dictionary_name, name);
+
// convert name string into a word of up to 4 characters, for the switch()
while(*name != 0)
name2 = (name2 << 8) + *name++;
- tr = NewTranslator();
-
switch(name2)
{
case L('a','f'):
@@ -257,18 +492,53 @@ Translator *SelectTranslator(const char *name)
static const short stress_lengths_af[8] = {170,140, 220,220, 0, 0, 250,270};
SetupTranslator(tr,stress_lengths_af,NULL);
- tr->langopts.stress_rule = 0;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.vowel_pause = 0x30;
tr->langopts.param[LOPT_DIERESES] = 1;
tr->langopts.param[LOPT_PREFIXES] = 1;
SetLetterVowel(tr,'y'); // add 'y' to vowels
-
- tr->langopts.numbers = 0x8d1 + NUM_ROMAN;
+
+ tr->langopts.numbers = NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_SINGLE_AND | NUM_ROMAN | NUM_1900;
tr->langopts.accents = 1;
}
break;
+ case L('a','m'): // Amharic, Ethiopia
+ {
+ SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
+ tr->letter_bits_offset = OFFSET_ETHIOPIC;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM; // don't use secondary stress
+ tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+ tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
+ }
+ break;
+
+
+ case L('a','r'): // Arabic
+ tr->letter_bits_offset = OFFSET_ARABIC;
+ tr->langopts.numbers = NUM_SWAP_TENS | NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED | NUM_THOUSAND_AND | NUM_OMIT_1_THOUSAND;
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+ break;
+
+ case L('b','g'): //Bulgarian
+ {
+ SetCyrillicLetters(tr);
+ SetLetterVowel(tr,0x2a);
+ tr->charset_a0 = charsets[5]; // ISO-8859-5
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
+ tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x107; // devoice at end of word, and change voicing to match a following consonant (except v)
+ tr->langopts.param[LOPT_REDUCE] = 2;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_SINGLE_AND | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS ;
+ tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
+ }
+ break;
+
case L('b','n'): // Bengali
+ case L('a','s'): // Assamese
+ case L_mni: // Manipuri (temporary placement - it's not indo-european)
{
static const short stress_lengths_bn[8] = {180, 180, 210, 210, 0, 0, 230, 240};
static const unsigned char stress_amps_bn[8] = {18,18, 18,18, 20,20, 22,22 };
@@ -276,14 +546,28 @@ Translator *SelectTranslator(const char *name)
SetupTranslator(tr,stress_lengths_bn,stress_amps_bn);
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable
tr->letter_bits_offset = OFFSET_BENGALI;
SetIndicLetters(tr); // call this after setting OFFSET_BENGALI
+ SetLetterBitsRange(tr,LETTERGP_B,0x01,0x01); // candranindu
SetLetterBitsRange(tr,LETTERGP_F,0x3e,0x4c); // vowel signs, but not virama
- tr->langopts.numbers = 0x1;
- tr->langopts.numbers2 = NUM2_100000;
+ tr->langopts.numbers = NUM_SWAP_TENS;
+ tr->langopts.break_numbers = 0x24924aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
+ }
+ break;
+
+ case L('b','o'): // Tibet
+ {
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->letter_bits_offset = OFFSET_TIBET;
+ SetLetterBitsRange(tr,LETTERGP_A,0x71,0x7d); // vowel signs
+ SetLetterBitsRange(tr,LETTERGP_B,0x71,0x81); // vowel signs and subjoined letters
+ SetLetterBitsRange(tr,LETTERGP_B,0x90,0xbc);
+ SetLetterBitsRange(tr,LETTERGP_C,0x40,0x6c); // consonant letters (not subjoined)
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+ tr->langopts.numbers = 1;
}
break;
@@ -296,16 +580,16 @@ Translator *SelectTranslator(const char *name)
tr->charset_a0 = charsets[14]; // ISO-8859-14
// tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 2;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
// tr->langopts.intonation_group = 4;
// 'diminished' is an unstressed final syllable
- tr->langopts.stress_flags = 0x6 | 0x10;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
- tr->langopts.numbers = 0x401;
+ tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
SetLetterVowel(tr,'w'); // add letter to vowels and remove from consonants
SetLetterVowel(tr,'y');
@@ -314,27 +598,47 @@ Translator *SelectTranslator(const char *name)
case L('d','a'): // Danish
{
- static const short stress_lengths_da[8] = {160,140, 200,200, 0,0, 220,210};
+ static const short stress_lengths_da[8] = {160,140, 200,200, 0,0, 220,230};
SetupTranslator(tr,stress_lengths_da,NULL);
- tr->langopts.stress_rule = 0;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.param[LOPT_PREFIXES] = 1;
SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x10c59;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
}
break;
case L('d','e'):
{
- static const short stress_lengths_de[8] = {150,130, 200,200, 0, 0, 260,275};
- tr->langopts.stress_rule = 0;
+ static const short stress_lengths_de[8] = {150,130, 200,200, 0, 0, 270,270};
+ static const unsigned char stress_amps_de[] = {20,20, 20,20, 20,22, 22,20 };
+ SetupTranslator(tr, stress_lengths_de, stress_amps_de);
+ tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.word_gap = 0x8; // don't use linking phonemes
tr->langopts.vowel_pause = 0x30;
tr->langopts.param[LOPT_PREFIXES] = 1;
- memcpy(tr->stress_lengths,stress_lengths_de,sizeof(tr->stress_lengths));
-
- tr->langopts.numbers = 0x11419 + NUM_ROMAN;
+ tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
+ tr->langopts.param[LOPT_LONG_VOWEL_THRESHOLD] = 175/2;
+
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
+// tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ALLOW_SPACE | NUM_ORDINAL_DOT | NUM_ROMAN;
SetLetterVowel(tr,'y');
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use de_rules for unpronouncable rules
+ }
+ break;
+
+ case L('d','v'): // Divehi (Maldives)
+ {
+ SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+ tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
+ tr->letter_bits_offset = OFFSET_THAANA;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable
+ SetLetterBitsRange(tr,LETTERGP_B,0x26,0x30); // vowel signs, and virama
+ tr->langopts.break_numbers = 0x14a8; // 1000, 100,000 10,000,000
+ tr->langopts.numbers = 1;
}
break;
@@ -343,9 +647,13 @@ Translator *SelectTranslator(const char *name)
static const short stress_lengths_en[8] = {182,140, 220,220, 0,0, 248,275};
SetupTranslator(tr,stress_lengths_en,NULL);
- tr->langopts.stress_rule = 0;
- tr->langopts.numbers = 0x841 + NUM_ROMAN;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = 0x08;
+ tr->langopts.numbers = NUM_HUNDRED_AND | NUM_ROMAN | NUM_1900;
tr->langopts.param[LOPT_COMBINE_WORDS] = 2; // allow "mc" to cmbine with the following word
+ tr->langopts.suffix_add_e = 'e';
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use en_rules for unpronouncable rules
+ SetLetterBits(tr,6,"aeiouy"); // Group Y: vowels, including y
}
break;
@@ -357,10 +665,10 @@ Translator *SelectTranslator(const char *name)
// character codes offset by 0x380
static const char el_vowels[] = {0x10,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x35,0x37,0x39,0x3f,0x45,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0};
- static const char el_fvowels[] = {0x2d,0x2e,0x2f,0x35,0x37,0x39,0x45,0x4d,0}; // ε η ι υ έ ή ί ύ
- static const char el_voiceless[]= {0x38,0x3a,0x3e,0x40,0x42,0x43,0x44,0x46,0x47,0}; // θ κ ξ π ς σ τ φ χ
+ static const char el_fvowels[] = {0x2d,0x2e,0x2f,0x35,0x37,0x39,0x45,0x4d,0}; // ε η ι υ έ ή ί ύ _
+ static const char el_voiceless[]= {0x38,0x3a,0x3e,0x40,0x42,0x43,0x44,0x46,0x47,0}; // θ κ ξ π ς σ τ φ χ _
static const char el_consonants[]={0x32,0x33,0x34,0x36,0x38,0x3a,0x3b,0x3c,0x3d,0x3e,0x40,0x41,0x42,0x43,0x44,0x46,0x47,0x48,0};
- static const wchar_t el_char_apostrophe[] = {0x3c3,0}; // σ
+ static const wchar_t el_char_apostrophe[] = {0x3c3,0}; // σ _
SetupTranslator(tr,stress_lengths_el,stress_amps_el);
@@ -370,19 +678,20 @@ Translator *SelectTranslator(const char *name)
tr->letter_bits_offset = OFFSET_GREEK;
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
SetLetterBits(tr,LETTERGP_A,el_vowels);
+ SetLetterBits(tr,LETTERGP_VOWEL2,el_vowels);
SetLetterBits(tr,LETTERGP_B,el_voiceless);
SetLetterBits(tr,LETTERGP_C,el_consonants);
- SetLetterBits(tr,LETTERGP_Y,el_fvowels); // front vowels: ε η ι υ
+ SetLetterBits(tr,LETTERGP_Y,el_fvowels); // front vowels: ε η ι υ _
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY; // mark unstressed final syllables as diminished
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
- tr->langopts.numbers = 0x109;
- tr->langopts.numbers2 = 0x2; // variant form of numbers before thousands
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA;
+ tr->langopts.numbers2 = 0x2 | NUM2_MULTIPLE_ORDINAL | NUM2_ORDINAL_NO_AND; // variant form of numbers before thousands
if(name2 == L_grc)
{
@@ -394,74 +703,120 @@ Translator *SelectTranslator(const char *name)
case L('e','o'):
{
- static const short stress_lengths_eo[8] = {145, 145, 230, 170, 0, 0, 360, 370};
+ static const short stress_lengths_eo[8] = {150, 150, 230, 180, 0, 0, 300, 320};
static const unsigned char stress_amps_eo[] = {16,14, 20,20, 20,22, 22,21 };
static const wchar_t eo_char_apostrophe[2] = {'l',0};
-
+
SetupTranslator(tr,stress_lengths_eo,stress_amps_eo);
tr->charset_a0 = charsets[3]; // ISO-8859-3
tr->char_plus_apostrophe = eo_char_apostrophe;
- tr->langopts.word_gap = 1;
+// tr->langopts.word_gap = 1;
tr->langopts.vowel_pause = 2;
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x6 | 0x10;
- tr->langopts.unstressed_wd1 = 3;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
+// tr->langopts.unstressed_wd1 = 3;
tr->langopts.unstressed_wd2 = 2;
- tr->langopts.numbers = 0x1409 + NUM_ROMAN;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_ALLOW_SPACE | NUM_ROMAN;
}
break;
case L('e','s'): // Spanish
+ case L('a','n'): // Aragonese
case L('c','a'): // Catalan
case L_pap: // Papiamento
{
- static const short stress_lengths_es[8] = {180, 210, 190, 190, 0, 0, 230, 260};
-// static const short stress_lengths_es[8] = {170, 200, 180, 180, 0, 0, 220, 250};
+ static const short stress_lengths_es[8] = {180, 190, 230, 180, 0, 0, 240, 270};
static const unsigned char stress_amps_es[8] = {16,12, 18,18, 20,20, 20,20 }; // 'diminished' is used to mark a quieter, final unstressed syllable
static const wchar_t ca_punct_within_word[] = {'\'',0xb7,0}; // ca: allow middle-dot within word
SetupTranslator(tr,stress_lengths_es,stress_amps_es);
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 2;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
// stress last syllable if it doesn't end in vowel or "s" or "n"
// 'diminished' is an unstressed final syllable
- tr->langopts.stress_flags = 0x200 | 0x6 | 0x10;
+ tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
- tr->langopts.numbers = 0x529 + NUM_ROMAN + NUM_ROMAN_AFTER;
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ROMAN | NUM_ROMAN_AFTER;
+ tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_ORDINAL_NO_AND;
if(name2 == L('c','a'))
{
+ // stress last syllable unless word ends with a vowel
tr->punct_within_word = ca_punct_within_word;
- tr->langopts.stress_flags = 0x200 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
+ tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2;
+ }
+ else
+ if(name2 == L('a','n'))
+ {
+ tr->langopts.stress_flags = S_FINAL_SPANISH | S_FINAL_DIM_ONLY | S_FINAL_NO_2;
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ROMAN | NUM_ROMAN_ORDINAL;
+ tr->langopts.numbers2 = NUM2_ORDINAL_NO_AND;
+ tr->langopts.roman_suffix = string_ordinal;
}
else
if(name2 == L_pap)
{
- tr->langopts.stress_flags = 0x100 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
+ // stress last syllable unless word ends with a vowel
+ tr->langopts.stress_flags = S_FINAL_STRESS_C | S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2;
+ }
+ else
+ {
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 2; // use es_rules for unpronouncable rules
}
}
break;
-
case L('e','u'): // basque
{
static const short stress_lengths_eu[8] = {200, 200, 200, 200, 0, 0, 210, 230}; // very weak stress
static const unsigned char stress_amps_eu[8] = {16,16, 18,18, 18,18, 18,18 };
SetupTranslator(tr,stress_lengths_eu,stress_amps_eu);
- tr->langopts.stress_rule = 1; // ?? second syllable ??
- tr->langopts.numbers = 0x569 + NUM_VIGESIMAL;
+ tr->langopts.stress_rule = STRESSPOSN_2L; // ?? second syllable ??
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_VIGESIMAL;
+ }
+ break;
+
+
+ case L('f','a'): // Farsi
+ {
+ // Convert characters in the range 0x620 to 0x6cc to the range 1 to 63.
+ // 0 indicates no translation for this character
+ static const char transpose_map_fa[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x620
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0, // 0x630
+ 0, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, // 0x640
+ 42, 43, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x650
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x660
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, // 0x670
+ 0, 0, 0, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x680
+ 0, 0, 0, 0, 0, 0, 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, // 0x690
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 0, 0, 0, 0, 49, // 0x6a0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x6b0
+ 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51 }; // 0x6c0
+ tr->transpose_min = 0x620;
+ tr->transpose_max = 0x6cc;
+ tr->transpose_map = transpose_map_fa;
+ tr->letter_bits_offset = OFFSET_ARABIC;
+
+ tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND;
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+
+ tr->chars_ignore = chars_ignore_zwnj_hyphen; // replace ZWNJ by hyphen
}
break;
+ case L('e','t'): // Estonian
+ tr->charset_a0 = charsets[4]; // ISO-8859-4
+ // drop through to Finnish
case L('f','i'): // Finnish
{
static const unsigned char stress_amps_fi[8] = {18,16, 22,22, 20,22, 22,22 };
@@ -469,12 +824,12 @@ Translator *SelectTranslator(const char *name)
SetupTranslator(tr,stress_lengths_fi,stress_amps_fi);
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x56; // move secondary stress from light to a following heavy syllable
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_2_TO_HEAVY; // move secondary stress from light to a following heavy syllable
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
tr->langopts.long_stop = 130;
- tr->langopts.numbers = 0x1009;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA + NUM_ALLOW_SPACE;
SetLetterVowel(tr,'y');
// tr->langopts.max_initial_consonants = 2; // BUT foreign words may have 3
tr->langopts.spelling_stress = 1;
@@ -482,32 +837,37 @@ Translator *SelectTranslator(const char *name)
}
break;
-
case L('f','r'): // french
{
- static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 235, 240};
- static const unsigned char stress_amps_fr[8] = {18,16, 20,20, 20,22, 22,21 };
-
SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
- tr->langopts.stress_rule = 3; // stress on final syllable
- tr->langopts.stress_flags = 0x0024; // don't use secondary stress
+ tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
+ tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM; // don't use secondary stress
tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables
+ tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
+ tr->langopts.accents = 2; // Say "Capital" after the letter.
- tr->langopts.numbers = 0x1509 + 0x8000 + (NUM_NOPAUSE | NUM_ROMAN | NUM_VIGESIMAL);
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_AFTER | NUM_VIGESIMAL | NUM_DFRACTION_4;
SetLetterVowel(tr,'y');
}
break;
-#ifdef deleted
- case L('g','a'): // Irish Gaelic
+ case L('g','a'): // irish
+ case L('g','d'): // scots gaelic
{
- tr->langopts.stress_rule = 1;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_NO_AUTO_2; // don't use secondary stress
+ tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND;
+ tr->langopts.accents = 2; // 'capital' after letter name
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 3; // don't count apostrophe
+ tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove [:] phoneme from non-stressed syllables (Lang=gd)
}
break;
-#endif
case L('h','i'): // Hindi
case L('n','e'): // Nepali
+ case L('o','r'): // Oriya
+ case L('p','a'): // Punjabi
+ case L('g','u'): // Gujarati
{
static const short stress_lengths_hi[8] = {190, 190, 210, 210, 0, 0, 230, 250};
static const unsigned char stress_amps_hi[8] = {17,14, 20,19, 20,22, 22,21 };
@@ -517,10 +877,35 @@ Translator *SelectTranslator(const char *name)
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
- tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
- tr->langopts.numbers = 0x011;
- tr->langopts.numbers2 = NUM2_100000;
+ tr->langopts.stress_flags = S_MID_DIM | S_FINAL_DIM; // use 'diminished' for unstressed final syllable
+ tr->langopts.numbers = NUM_SWAP_TENS;
+ tr->langopts.break_numbers = 0x14aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
tr->letter_bits_offset = OFFSET_DEVANAGARI;
+
+ if(name2 == L('p','a'))
+ {
+ tr->letter_bits_offset = OFFSET_GURMUKHI;
+ }
+ else
+ if(name2 == L('g','u'))
+ {
+SetupTranslator(tr,stress_lengths_equal,stress_amps_equal);
+ tr->letter_bits_offset = OFFSET_GUJARATI;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ }
+ else
+ if(name2 == L('n','e'))
+ {
+SetupTranslator(tr,stress_lengths_equal,stress_amps_equal);
+ tr->langopts.break_numbers = 0x2aaaa8;
+ tr->langopts.max_digits = 22;
+ tr->langopts.numbers2 |= NUM2_ENGLISH_NUMERALS;
+ }
+ else
+ if(name2 == L('o','r'))
+ {
+ tr->letter_bits_offset = OFFSET_ORIYA;
+ }
SetIndicLetters(tr);
}
break;
@@ -534,22 +919,25 @@ Translator *SelectTranslator(const char *name)
static const short stress_lengths_hr[8] = {180,160, 200,200, 0,0, 220,230};
static const short stress_lengths_sr[8] = {160,150, 200,200, 0,0, 250,260};
+ strcpy(tr->dictionary_name, "hbs");
+
if(name2 == L('s','r'))
SetupTranslator(tr,stress_lengths_sr,stress_amps_hr);
else
SetupTranslator(tr,stress_lengths_hr,stress_amps_hr);
tr->charset_a0 = charsets[2]; // ISO-8859-2
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x10;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_FINAL_NO_2;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
tr->langopts.max_initial_consonants = 5;
tr->langopts.spelling_stress = 1;
tr->langopts.accents = 1;
- tr->langopts.numbers = 0x140d + 0x4000 + NUM_ROMAN_UC;
- tr->langopts.numbers2 = 0x4a; // variant numbers before thousands,milliards
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_DECIMAL_COMMA | NUM_THOUS_SPACE | NUM_DFRACTION_2 | NUM_ROMAN_CAPITALS;
+ tr->langopts.numbers2 = 0xa + NUM2_THOUSANDS_VAR5; // variant numbers before thousands,milliards
tr->langopts.replace_chars = replace_cyrillic_latin;
+ tr->langopts.our_alphabet = OFFSET_CYRILLIC; // don't say "cyrillic" before letter names
SetLetterVowel(tr,'y');
SetLetterVowel(tr,'r');
@@ -557,6 +945,14 @@ Translator *SelectTranslator(const char *name)
break;
+ case L('h','t'): // Haitian Creole
+// memcpy(tr->stress_lengths,stress_lengths_fr,sizeof(tr->stress_lengths));
+ tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
+ tr->langopts.stress_flags = S_NO_AUTO_2 | S_FINAL_DIM; // don't use secondary stress
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_OMIT_1_HUNDRED | NUM_NOPAUSE | NUM_ROMAN | NUM_VIGESIMAL | NUM_DFRACTION_4;
+ break;
+
+
case L('h','u'): // Hungarian
{
static const unsigned char stress_amps_hu[8] = {17,17, 19,19, 20,22, 22,21 };
@@ -566,14 +962,17 @@ Translator *SelectTranslator(const char *name)
tr->charset_a0 = charsets[2]; // ISO-8859-2
tr->langopts.vowel_pause = 0x20;
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x8036;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_NO_AUTO_2 | 0x8000 | S_HYPEN_UNSTRESS;
tr->langopts.unstressed_wd1 = 2;
-// tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x4; // don't propagate over word boundaries
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
- tr->langopts.param[LOPT_COMBINE_WORDS] = 99; // combine some prepositions with the following word
+ tr->langopts.param[LOPT_ANNOUNCE_PUNCT] = 2; // don't break clause before announcing . ? !
- tr->langopts.numbers = 0x1009 + 0xa000 + NUM_ROMAN + 0x10000;
+ tr->langopts.numbers = NUM_DFRACTION_5 | NUM_ALLOW_SPACE | NUM_ROMAN | NUM_ROMAN_ORDINAL | NUM_ROMAN_CAPITALS | NUM_ORDINAL_DOT | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND;
+ tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
+ tr->langopts.decimal_sep = ',';
+ tr->langopts.max_roman = 899;
+ tr->langopts.min_roman = 1;
SetLetterVowel(tr,'y');
tr->langopts.spelling_stress = 1;
SetLengthMods(tr,3); // all equal
@@ -585,30 +984,35 @@ SetLengthMods(tr,3); // all equal
static const short stress_lengths_hy[8] = {250, 200, 250, 250, 0, 0, 250, 250};
static const char hy_vowels[] = {0x31, 0x35, 0x37, 0x38, 0x3b, 0x48, 0x55, 0};
static const char hy_consonants[] = {0x32,0x33,0x34,0x36,0x39,0x3a,0x3c,0x3d,0x3e,0x3f,
- 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x56,0};
+ 0x40,0x41,0x42,0x43,0x44, 0x46,0x47,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x56,0};
+ static const char hy_consonants2[] = {0x45,0};
SetupTranslator(tr,stress_lengths_hy,NULL);
- tr->langopts.stress_rule = 3; // default stress on final syllable
+ tr->langopts.stress_rule = STRESSPOSN_1R; // default stress on final syllable
tr->letter_bits_offset = OFFSET_ARMENIAN;
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
SetLetterBits(tr,LETTERGP_A,hy_vowels);
+ SetLetterBits(tr,LETTERGP_VOWEL2,hy_vowels);
+ SetLetterBits(tr,LETTERGP_B,hy_consonants); // not including 'j'
SetLetterBits(tr,LETTERGP_C,hy_consonants);
+ SetLetterBits(tr,LETTERGP_C,hy_consonants2); // add 'j'
tr->langopts.max_initial_consonants = 6;
- tr->langopts.numbers = 0x409;
-// tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED;
+ // tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
}
break;
case L('i','d'): // Indonesian
+ case L('m','s'): // Malay
{
static const short stress_lengths_id[8] = {160, 200, 180, 180, 0, 0, 220, 240};
static const unsigned char stress_amps_id[8] = {16,18, 18,18, 20,22, 22,21 };
SetupTranslator(tr,stress_lengths_id,stress_amps_id);
- tr->langopts.stress_rule = 2;
- tr->langopts.numbers = 0x1009 + NUM_ROMAN;
- tr->langopts.stress_flags = 0x6 | 0x10;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_ROMAN;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.accents = 2; // "capital" after letter name
}
break;
@@ -619,8 +1023,8 @@ SetLengthMods(tr,3); // all equal
static const wchar_t is_lettergroup_B[] = {'c','f','h','k','p','t','x',0xfe,0}; // voiceless conants, including 'þ' ?? 's'
SetupTranslator(tr,stress_lengths_is,NULL);
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x10;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_FINAL_NO_2;
tr->langopts.param[LOPT_IT_LENGTHEN] = 0x11; // remove lengthen indicator from unstressed vowels
tr->langopts.param[LOPT_REDUCE] = 2;
@@ -629,7 +1033,7 @@ SetLengthMods(tr,3); // all equal
SetLetterBits(tr,3,"jvr"); // Letter group H
tr->letter_groups[1] = is_lettergroup_B;
SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x8e9;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SINGLE_AND | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_1900;
tr->langopts.numbers2 = 0x2;
}
break;
@@ -642,17 +1046,17 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_it,stress_amps_it);
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x10 | 0x20000;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_FINAL_NO_2 | S_PRIORITY_STRESS;
tr->langopts.vowel_pause = 1;
tr->langopts.unstressed_wd1 = 2;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_IT_LENGTHEN] = 2; // remove lengthen indicator from unstressed or non-penultimate syllables
- tr->langopts.param[LOPT_IT_DOUBLING] = 2; // double the first consonant if the previous word ends in a stressed vowel
+ tr->langopts.param[LOPT_IT_DOUBLING] = 1; // double the first consonant if the previous word ends in a stressed vowel (changed to =1, 23.01.2014 - only use if prev.word has $double)
tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
tr->langopts.param[LOPT_REDUCE] = 1; // reduce vowels even if phonemes are specified in it_list
tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
- tr->langopts.numbers = 0x2709 + NUM_ROMAN;
+ tr->langopts.numbers = NUM_SINGLE_VOWEL | NUM_OMIT_1_HUNDRED |NUM_DECIMAL_COMMA | NUM_ROMAN | NUM_DFRACTION_1 | NUM_ROMAN_CAPITALS | NUM_ROMAN_AFTER;
tr->langopts.accents = 2; // Say "Capital" after the letter.
SetLetterVowel(tr,'y');
}
@@ -664,12 +1068,71 @@ SetLengthMods(tr,3); // all equal
static const wchar_t jbo_punct_within_word[] = {'.',',','\'',0x2c8,0}; // allow period and comma within a word, also stress marker (from LOPT_CAPS_IN_WORD)
SetupTranslator(tr,stress_lengths_jbo,NULL);
- tr->langopts.stress_rule = 2;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
tr->langopts.vowel_pause = 0x20c; // pause before a word which starts with a vowel, or after a word which ends in a consonant
// tr->langopts.word_gap = 1;
tr->punct_within_word = jbo_punct_within_word;
tr->langopts.param[LOPT_CAPS_IN_WORD] = 2; // capitals indicate stressed syllables
SetLetterVowel(tr,'y');
+ tr->langopts.max_lengthmod = 368;
+ }
+ break;
+
+ case L('k','a'): // Georgian
+ {
+ // character codes offset by 0x1080
+ static const char ka_vowels[] = {0x30,0x34,0x38,0x3d,0x43,0x55,0x57,0};
+ static const char ka_consonants[] =
+ {0x31,0x32,0x33,0x35,0x36,0x37,0x39,0x3a,0x3b,0x3c,0x3e,0x3f,0x40,0x41,0x42,0x44,
+ 0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x56,0};
+ SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
+ memset(tr->letter_bits,0,sizeof(tr->letter_bits));
+ SetLetterBits(tr,LETTERGP_A,ka_vowels);
+ SetLetterBits(tr,LETTERGP_C,ka_consonants);
+ SetLetterBits(tr,LETTERGP_VOWEL2,ka_vowels);
+
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_FINAL_NO_2;
+ tr->letter_bits_offset = OFFSET_GEORGIAN;
+// tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+ tr->langopts.max_initial_consonants = 7;
+ tr->langopts.numbers = NUM_VIGESIMAL | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED |NUM_OMIT_1_THOUSAND | NUM_DFRACTION_5 | NUM_ROMAN;
+
+ tr->langopts.alt_alphabet = OFFSET_CYRILLIC;
+ tr->langopts.alt_alphabet_lang = L('r','u');
+ }
+ break;
+
+ case L('k','k'): // Kazakh
+ {
+ static const unsigned char stress_amps_tr[8] = {18,16, 20,21, 20,21, 21,20 };
+ static const short stress_lengths_tr[8] = {190,180, 230,230, 0,0, 250,250};
+
+ tr->letter_bits_offset = OFFSET_CYRILLIC;
+ memset(tr->letter_bits,0,sizeof(tr->letter_bits));
+ SetLetterBits(tr,LETTERGP_A,(char *)ru_vowels);
+ SetLetterBits(tr,LETTERGP_C,(char *)ru_consonants);
+ SetLetterBits(tr,LETTERGP_VOWEL2,(char *)ru_vowels);
+
+ SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
+
+ tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
+ tr->langopts.stress_flags = S_NO_AUTO_2 + S_NO_EOC_LENGTHEN; //no automatic secondary stress, don't lengthen at end-of-clause
+ tr->langopts.lengthen_tonic = 0;
+ tr->langopts.param[LOPT_SUFFIX] = 1;
+
+ tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_6 ;
+ tr->langopts.max_initial_consonants = 2;
+SetLengthMods(tr,3); // all equal
+ }
+ break;
+
+ case L('k','l'): // Greenlandic
+ {
+ SetupTranslator(tr,stress_lengths_equal,stress_amps_equal);
+ tr->langopts.stress_rule = 12;
+ tr->langopts.stress_flags = S_NO_AUTO_2;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
}
break;
@@ -679,6 +1142,7 @@ SetLengthMods(tr,3); // all equal
static const unsigned char ko_voiced[] = {0x02,0x05,0x06,0xab,0xaf,0xb7,0xbc,0}; // voiced consonants, l,m,n,N
tr->letter_bits_offset = OFFSET_KOREAN;
+ tr->langopts.our_alphabet = 0xa700;
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
SetLetterBitsRange(tr,LETTERGP_A,0x61,0x75);
SetLetterBits(tr,LETTERGP_Y,ko_ivowels);
@@ -686,7 +1150,10 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = 8; // ?? 1st syllable if it is heavy, else 2nd syllable
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
- tr->langopts.numbers = 0x0401;
+ tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
+ tr->langopts.numbers2 = NUM2_MYRIADS;
+ tr->langopts.break_numbers = 0x1111110;
+ tr->langopts.max_digits = 20;
}
break;
@@ -700,7 +1167,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
- tr->langopts.numbers = 0x100461;
+ tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_AND_HUNDRED;
tr->langopts.max_initial_consonants = 2;
}
break;
@@ -708,12 +1175,26 @@ SetLengthMods(tr,3); // all equal
case L('l','a'): //Latin
{
tr->charset_a0 = charsets[4]; // ISO-8859-4, includes a,e,i,o,u-macron
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x20;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_NO_AUTO_2;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_DIERESES] = 1;
- tr->langopts.numbers = 0x1 + NUM_ROMAN;
+ tr->langopts.numbers = NUM_ROMAN;
+ tr->langopts.max_roman = 5000;
+ }
+ break;
+
+ case L('l','t'): // Lithuanian
+ {
+ tr->charset_a0 = charsets[4]; // ISO-8859-4
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_NO_AUTO_2;
+ tr->langopts.unstressed_wd1 = 0;
+ tr->langopts.unstressed_wd2 = 2;
+ tr->langopts.param[LOPT_DIERESES] = 1;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
+ tr->langopts.numbers2 = NUM2_THOUSANDS_VAR4;
tr->langopts.max_roman = 5000;
}
break;
@@ -725,11 +1206,11 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_lv,stress_amps_lv);
- tr->langopts.stress_rule = 0;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.spelling_stress = 1;
tr->charset_a0 = charsets[4]; // ISO-8859-4
- tr->langopts.numbers = 0x409 + 0x8000 + 0x10000;
- tr->langopts.stress_flags = 0x16 + 0x40000;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_EO_CLAUSE1;
}
break;
@@ -742,38 +1223,50 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_mk,stress_amps_mk);
tr->charset_a0 = charsets[5]; // ISO-8859-5
- tr->letter_groups[0] = vowels_cyrillic;
+ tr->letter_groups[0] = tr->letter_groups[7] = vowels_cyrillic;
+ tr->letter_bits_offset = OFFSET_CYRILLIC;
- tr->langopts.stress_rule = 4; // antipenultimate
- tr->langopts.numbers = 0x0429 + 0x4000;
+ tr->langopts.stress_rule = STRESSPOSN_3R; // antipenultimate
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
tr->langopts.numbers2 = 0x8a; // variant numbers before thousands,milliards
}
break;
+ case L('m','t'): // Maltese
+ {
+ tr->charset_a0 = charsets[3]; // ISO-8859-3
+ tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
+ tr->langopts.stress_rule = STRESSPOSN_2R; // penultimate
+ tr->langopts.numbers = 1;
+ }
+ break;
case L('n','l'): // Dutch
{
static const short stress_lengths_nl[8] = {160,135, 210,210, 0, 0, 260,280};
- tr->langopts.stress_rule = 0;
- tr->langopts.vowel_pause = 1;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.vowel_pause = 0x30; // ??
tr->langopts.param[LOPT_DIERESES] = 1;
tr->langopts.param[LOPT_PREFIXES] = 1;
+ tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x100; // devoice at end of word
SetLetterVowel(tr,'y');
-
- tr->langopts.numbers = 0x11c19;
+
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
+ tr->langopts.ordinal_indicator = "e";
+ tr->langopts.stress_flags = S_FIRST_PRIMARY;
memcpy(tr->stress_lengths,stress_lengths_nl,sizeof(tr->stress_lengths));
}
break;
case L('n','o'): // Norwegian
{
- static const short stress_lengths_no[8] = {160,140, 200,200, 0,0, 220,210};
+ static const short stress_lengths_no[8] = {160,140, 200,200, 0,0, 220,230};
SetupTranslator(tr,stress_lengths_no,NULL);
- tr->langopts.stress_rule = 0;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x11849;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_ALLOW_SPACE | NUM_1900 | NUM_ORDINAL_DOT;
}
break;
@@ -783,8 +1276,8 @@ SetLengthMods(tr,3); // all equal
static const short stress_lengths_om[8] = {200,200, 200,200, 0,0, 200,200};
SetupTranslator(tr,stress_lengths_om,stress_amps_om);
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x16 + 0x80000;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | 0x80000;
}
break;
@@ -796,12 +1289,12 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_pl,stress_amps_pl);
tr->charset_a0 = charsets[2]; // ISO-8859-2
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
- tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x8;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY; // mark unstressed final syllables as diminished
+ tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x9;
tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
- tr->langopts.numbers=0x1009 + 0x4000;
- tr->langopts.numbers2=0x40;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_2;
+ tr->langopts.numbers2 = NUM2_THOUSANDS_VAR3;
tr->langopts.param[LOPT_COMBINE_WORDS] = 4 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable (and 2-syllable) words (marked with $alt)
SetLetterVowel(tr,'y');
}
@@ -809,18 +1302,22 @@ SetLengthMods(tr,3); // all equal
case L('p','t'): // Portuguese
{
- static const short stress_lengths_pt[8] = {180, 125, 210, 210, 0, 0, 270, 295};
- static const unsigned char stress_amps_pt[8] = {16,13, 19,19, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
+ static const short stress_lengths_pt[8] = {170, 115, 210, 240, 0, 0, 260, 280};
+ static const unsigned char stress_amps_pt[8] = {16,11, 19,21, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
SetupTranslator(tr,stress_lengths_pt,stress_amps_pt);
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 3; // stress on final syllable
- tr->langopts.stress_flags = 0x6 | 0x10 | 0x20000;
- tr->langopts.numbers = 0x069 + 0x4000 + NUM_ROMAN;
+ tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_INITIAL_2 | S_PRIORITY_STRESS;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_DFRACTION_2 | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_ROMAN_CAPITALS;
+ tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_NO_TEEN_ORDINALS | NUM2_ORDINAL_NO_AND;
+ tr->langopts.max_roman = 5000;
SetLetterVowel(tr,'y');
ResetLetterBits(tr,0x2);
SetLetterBits(tr,1,"bcdfgjkmnpqstvxz"); // B hard consonants, excluding h,l,r,w,y
+ tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
+ tr->langopts.accents = 2; // 'capital' after letter name
}
break;
@@ -831,11 +1328,11 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_ro,stress_amps_ro);
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x100 + 0x6;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_FINAL_STRESS_C + S_FINAL_DIM_ONLY;
tr->charset_a0 = charsets[2]; // ISO-8859-2
- tr->langopts.numbers = 0x1029+0x6000 + NUM_ROMAN;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_3 | NUM_AND_UNITS | NUM_ROMAN;
tr->langopts.numbers2 = 0x1e; // variant numbers before all thousandplex
}
break;
@@ -846,11 +1343,11 @@ SetLengthMods(tr,3); // all equal
case L('r','w'): // Kiryarwanda
{
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x16;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
-
- tr->langopts.numbers = 0x61 + 0x100000 + 0x4000;
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words. Need to allow "bw'" prefix
+ tr->langopts.numbers = NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_2 | NUM_AND_HUNDRED;
tr->langopts.numbers2 = 0x200; // say "thousands" before its number
}
break;
@@ -863,16 +1360,16 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_sk,stress_amps_sk);
tr->charset_a0 = charsets[2]; // ISO-8859-2
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x16;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
tr->langopts.max_initial_consonants = 5;
tr->langopts.spelling_stress = 1;
tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
- tr->langopts.numbers = 0x0401 + 0x4000 + NUM_ROMAN;
- tr->langopts.numbers2 = 0x100;
- tr->langopts.thousands_sep = 0; //no thousands separator
+ tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ROMAN;
+ tr->langopts.numbers2 = NUM2_THOUSANDS_VAR2;
+ tr->langopts.thousands_sep = STRESSPOSN_1L; //no thousands separator
tr->langopts.decimal_sep = ',';
if(name2 == L('c','s'))
@@ -887,6 +1384,47 @@ SetLengthMods(tr,3); // all equal
}
break;
+ case L('s','i'): // Sinhala
+ {
+ SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
+ tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
+
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
+ tr->langopts.spelling_stress = 1;
+
+ tr->letter_bits_offset = OFFSET_SINHALA;
+ memset(tr->letter_bits,0,sizeof(tr->letter_bits));
+ SetLetterBitsRange(tr,LETTERGP_A,0x05,0x16); // vowel letters
+ SetLetterBitsRange(tr,LETTERGP_A,0x4a,0x73); // + vowel signs, and virama
+
+ SetLetterBitsRange(tr,LETTERGP_B,0x4a,0x73); // vowel signs, and virama
+
+ SetLetterBitsRange(tr,LETTERGP_C,0x1a,0x46); // the main consonant range
+
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+ tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4a; //virama
+ tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_SINGLE_STRESS_L | NUM_DFRACTION_7;
+ tr->langopts.numbers2 = NUM2_PERCENT_BEFORE;
+ tr->langopts.break_numbers = 0x14aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
+ }
+ break;
+
+ case L('s','l'): // Slovenian
+ tr->charset_a0 = charsets[2]; // ISO-8859-2
+ tr->langopts.stress_rule = STRESSPOSN_2R; // Temporary
+ tr->langopts.stress_flags = S_NO_AUTO_2;
+ tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x103;
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x76; // [v] don't count this character at start of word
+ tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
+ tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables
+ tr->letter_bits['r'] |= 0x80; // add 'r' to letter group 7, vowels for Unpronouncable test
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_SWAP_TENS | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ORDINAL_DOT | NUM_ROMAN;
+ tr->langopts.numbers2 = 0x100; // plural forms of millions etc
+ tr->langopts.thousands_sep = ' '; // don't allow dot as thousands separator
+ tr->langopts.replace_chars = replace_cyrillic_latin;
+ break;
+
case L('s','q'): // Albanian
{
static const short stress_lengths_sq[8] = {150, 150, 180, 180, 0, 0, 300, 300};
@@ -894,10 +1432,10 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_sq,stress_amps_sq);
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x16 + 0x100;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2 | S_FINAL_STRESS_C;
SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x69 + 0x8000;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_DFRACTION_4;
tr->langopts.accents = 2; // "capital" after letter name
}
break;
@@ -909,14 +1447,15 @@ SetLengthMods(tr,3); // all equal
static const short stress_lengths_sv[8] = {160,135, 220,220, 0,0, 250,280};
SetupTranslator(tr,stress_lengths_sv,stress_amps_sv);
- tr->langopts.stress_rule = 0;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x1909;
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_1900;
tr->langopts.accents = 1;
}
break;
case L('s','w'): // Swahili
+ case L('t','n'): // Setswana
{
static const short stress_lengths_sw[8] = {160, 170, 200, 200, 0, 0, 320, 340};
static const unsigned char stress_amps_sw[] = {16,12, 19,19, 20,22, 22,21 };
@@ -925,29 +1464,39 @@ SetLengthMods(tr,3); // all equal
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.vowel_pause = 1;
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x6 | 0x10;
+ tr->langopts.stress_rule = STRESSPOSN_2R;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2;
+ tr->langopts.max_initial_consonants = 4; // for example: mwngi
+
- tr->langopts.numbers = 0x4e1;
- tr->langopts.numbers2 = NUM2_100000a;
+ tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_SINGLE_AND | NUM_OMIT_1_HUNDRED;
+ tr->langopts.break_numbers = 0x49249268; // for languages which have numbers for 100,000 and 1,000,000
}
break;
case L('t','a'): // Tamil
- case L('m','l'): // Malayalam
case L('k','n'): // Kannada
+ case L('m','l'): // Malayalam
case L('m','r'): // Marathi
+ case L('t','e'): // Telugu
{
- static const short stress_lengths_ta[8] = {200, 200, 210, 210, 0, 0, 230, 230};
- static const unsigned char stress_amps_ta[8] = {18,18, 18,18, 20,20, 22,22 };
-
- SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
+ SetupTranslator(tr,stress_lengths_ta2, stress_amps_ta);
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
- tr->letter_bits_offset = OFFSET_TAMIL;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.stress_flags = S_FINAL_DIM_ONLY | S_FINAL_NO_2; // use 'diminished' for unstressed final syllable
+ tr->langopts.spelling_stress = 1;
+ tr->langopts.break_numbers = 0x14a8; // 1000, 100,000 10,000,000
+ if(name2 == L('t','a'))
+ {
+ SetupTranslator(tr,stress_lengths_ta, NULL);
+ tr->letter_bits_offset = OFFSET_TAMIL;
+ tr->langopts.numbers = NUM_OMIT_1_THOUSAND ;
+ tr->langopts.numbers2 = NUM2_ORDINAL_AND_THOUSANDS;
+ tr->langopts.param[LOPT_WORD_MERGE] = 1; // don't break vowels betwen words
+ }
+ else
if(name2 == L('m','r'))
{
tr->letter_bits_offset = OFFSET_DEVANAGARI;
@@ -955,17 +1504,27 @@ SetLengthMods(tr,3); // all equal
else
if(name2 == L('m','l'))
{
+ static const short stress_lengths_ml[8] = {180, 160, 240, 240, 0, 0, 260, 260};
+ SetupTranslator(tr,stress_lengths_ml, stress_amps_equal);
tr->letter_bits_offset = OFFSET_MALAYALAM;
+ tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_OMIT_1_HUNDRED;
+ tr->langopts.numbers2 = NUM2_OMIT_1_HUNDRED_ONLY;
+ tr->langopts.stress_rule = 13; // 1st syllable, unless 1st vowel is short and 2nd is long
}
else
if(name2 == L('k','n'))
{
tr->letter_bits_offset = OFFSET_KANNADA;
tr->langopts.numbers = 0x1;
- tr->langopts.numbers2 = NUM2_100000;
}
- tr->langopts.param[LOPT_WORD_MERGE] = 1; // don't break vowels betwen words
+ else
+ if(name2 == L('t','e'))
+ {
+ tr->letter_bits_offset = OFFSET_TELUGU;
+ tr->langopts.numbers = 0x1;
+ }
SetIndicLetters(tr); // call this after setting OFFSET_
+ SetLetterBitsRange(tr,LETTERGP_B,0x4e,0x4e); // chillu-virama (unofficial)
}
break;
@@ -978,7 +1537,7 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_th,stress_amps_th);
tr->langopts.stress_rule = 0; // stress on final syllable of a "word"
- tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
+ tr->langopts.stress_flags = S_NO_DIM; // don't automatically set diminished stress (may be set in the intonation module)
tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
// tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
@@ -988,21 +1547,58 @@ SetLengthMods(tr,3); // all equal
#endif
case L('t','r'): // Turkish
+ case L('a','z'): // Azerbaijan
{
- static const unsigned char stress_amps_tr[8] = {18,18, 20,20, 20,22, 22,21 };
- static const short stress_lengths_tr[8] = {190,190, 190,190, 0,0, 250,270};
+ static const unsigned char stress_amps_tr[8] = {18,16, 20,21, 20,21, 21,20 };
+ static const short stress_lengths_tr[8] = {190,180, 200,230, 0,0, 240,250};
SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
- tr->langopts.stress_flags = 0x20; //no automatic secondary stress
+ tr->langopts.stress_flags = S_NO_AUTO_2; //no automatic secondary stress
+ tr->langopts.dotless_i = 1;
+ tr->langopts.param[LOPT_SUFFIX] = 1;
- tr->langopts.numbers = 0x1509 + 0x4000;
+ if(name2 == L('a','z'))
+ {
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
+ }
+ else
+ {
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_2;
+ }
tr->langopts.max_initial_consonants = 2;
}
break;
+ case L('t','t'): // Tatar
+ {
+ SetCyrillicLetters(tr);
+ SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
+ tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
+ tr->langopts.stress_flags = S_NO_AUTO_2; //no automatic secondary stress
+ tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_4;
+ }
+ break;
+
+ case L('u','k'): // Ukrainian
+ {
+ SetCyrillicLetters(tr);
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
+ }
+ break;
+
+ case L('u','r'): // Urdu
+ case L('s','d'): // Sindhi
+ {
+ tr->letter_bits_offset = OFFSET_ARABIC;
+ tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
+ tr->langopts.numbers = NUM_SWAP_TENS;
+ tr->langopts.break_numbers = 0x52a8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
+ }
+ break;
+
case L('v','i'): // Vietnamese
{
static const short stress_lengths_vi[8] = {150, 150, 180, 180, 210, 230, 230, 240};
@@ -1019,22 +1615,27 @@ SetLengthMods(tr,3); // all equal
0x1a1, 0x1edd, 0x1edb, 0x1edf, 0x1ee1, 0x1ee3, // ơ
0x75, 0xf9, 0xfa, 0x1ee7, 0x169, 0x1ee5, // u
0x1b0, 0x1eeb, 0x1ee9, 0x1eed, 0x1eef, 0x1ef1, // ư
- 0x79, 0x1ef3, 0xfd, 0x1ef7, 0x1ef9, 0x1e, 0 }; // y
+ 0x79, 0x1ef3, 0xfd, 0x1ef7, 0x1ef9, 0x1ef5, 0 }; // y
SetupTranslator(tr,stress_lengths_vi,stress_amps_vi);
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 0;
+ tr->langopts.stress_rule = STRESSPOSN_1L;
tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
// tr->langopts.vowel_pause = 4;
- tr->letter_groups[0] = vowels_vi;
+ tr->letter_groups[0] = tr->letter_groups[7] = vowels_vi;
tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
tr->langopts.unstressed_wd1 = 2;
- tr->langopts.numbers = 0x0049 + 0x8000;
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_HUNDRED_AND_DIGIT | NUM_DFRACTION_4 | NUM_ZERO_HUNDRED;
}
break;
+ case L('w','o'):
+ tr->langopts.stress_rule = STRESSPOSN_1L;
+ tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_SINGLE_STRESS;
+ break;
+
case L('z','h'):
case L_zhy:
{
@@ -1043,13 +1644,14 @@ SetLengthMods(tr,3); // all equal
SetupTranslator(tr,stress_lengths_zh,stress_amps_zh);
- tr->langopts.stress_rule = 3; // stress on final syllable of a "word"
- tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
+ tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable of a "word"
+ tr->langopts.stress_flags = S_NO_DIM; // don't automatically set diminished stress (may be set in the intonation module)
tr->langopts.vowel_pause = 0;
tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
tr->langopts.ideographs = 1;
+ tr->langopts.our_alphabet = 0x3100;
tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
if(name2 == L('z','h'))
{
@@ -1066,66 +1668,48 @@ SetLengthMods(tr,3); // all equal
tr->translator_name = name2;
- if(tr->langopts.numbers & 0x8)
+ ProcessLanguageOptions(&tr->langopts);
+ return(tr);
+} // end of SelectTranslator
+
+
+void ProcessLanguageOptions(LANGUAGE_OPTIONS *langopts)
+{//=====================================================
+ if(langopts->numbers & NUM_DECIMAL_COMMA)
{
// use . and ; for thousands and decimal separators
- tr->langopts.thousands_sep = '.';
- tr->langopts.decimal_sep = ',';
+ langopts->thousands_sep = '.';
+ langopts->decimal_sep = ',';
}
- if(tr->langopts.numbers & 0x4)
+ if(langopts->numbers & NUM_THOUS_SPACE)
{
- tr->langopts.thousands_sep = 0; // don't allow thousands separator, except space
+ langopts->thousands_sep = 0; // don't allow thousands separator, except space
}
- return(tr);
-} // end of SelectTranslator
-
-
+}
//**********************************************************************************************************
+
static void Translator_Russian(Translator *tr)
{//===========================================
static const unsigned char stress_amps_ru[] = {16,16, 18,18, 20,24, 24,22 };
static const short stress_lengths_ru[8] = {150,140, 220,220, 0,0, 260,280};
-
-
- // character codes offset by 0x420
- static const char ru_vowels[] = {0x10,0x15,0x31,0x18,0x1e,0x23,0x2b,0x2d,0x2e,0x2f,0};
- static const char ru_consonants[] = {0x11,0x12,0x13,0x14,0x16,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2c,0};
- static const char ru_soft[] = {0x2c,0x19,0x27,0x29,0}; // letter group B [k ts; s;]
- static const char ru_hard[] = {0x2a,0x16,0x26,0x28,0}; // letter group H [S Z ts]
- static const char ru_nothard[] = {0x11,0x12,0x13,0x14,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x27,0x29,0x2c,0};
- static const char ru_voiced[] = {0x11,0x12,0x13,0x14,0x16,0x17,0}; // letter group G (voiced obstruents)
- static const char ru_ivowels[] = {0x2c,0x15,0x31,0x18,0x2e,0x2f,0}; // letter group Y (iotated vowels & soft-sign)
+ static const char ru_ivowels2[] = {0x2c,0x15,0x18,0x2e,0x2f,0}; // add more vowels to letter group Y (iotated vowels & soft-sign)
SetupTranslator(tr,stress_lengths_ru,stress_amps_ru);
-
- tr->charset_a0 = charsets[18]; // KOI8-R
- tr->transpose_offset = 0x42f; // convert cyrillic from unicode into range 0x01 to 0x22
- tr->transpose_min = 0x430;
- tr->transpose_max = 0x451;
-
- tr->letter_bits_offset = OFFSET_CYRILLIC;
- memset(tr->letter_bits,0,sizeof(tr->letter_bits));
- SetLetterBits(tr,0,ru_vowels);
- SetLetterBits(tr,1,ru_soft);
- SetLetterBits(tr,2,ru_consonants);
- SetLetterBits(tr,3,ru_hard);
- SetLetterBits(tr,4,ru_nothard);
- SetLetterBits(tr,5,ru_voiced);
- SetLetterBits(tr,6,ru_ivowels);
- SetLetterBits(tr,7,ru_vowels);
+ SetCyrillicLetters(tr);
+ SetLetterBits(tr,6,ru_ivowels2);
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 1;
tr->langopts.param[LOPT_REDUCE] = 2;
tr->langopts.stress_rule = 5;
- tr->langopts.stress_flags = 0x0020; // waas 0x1010
+ tr->langopts.stress_flags = S_NO_AUTO_2;
- tr->langopts.numbers = 0x0409;
- tr->langopts.numbers2 = 0xc2; // variant numbers before thousands
+ tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
+ tr->langopts.numbers2 = 0x2 + NUM2_THOUSANDS_VAR1; // variant numbers before thousands
tr->langopts.phoneme_change = 1;
tr->langopts.testing = 2;
@@ -1145,8 +1729,9 @@ typedef struct {
*/
-#define RUSSIAN2
+
#ifdef RUSSIAN2
+// This is now done in the phoneme data, ph_russian
int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
{//=============================================================================================================
@@ -1155,8 +1740,6 @@ int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index
int variant;
int vowelix;
- int stressed;
- int soft;
PHONEME_TAB *prev, *next;
if(ch->flags & 8)
@@ -1179,7 +1762,7 @@ PH('V','#'),PH('I','3'),PH('I','2'),PH('E','3')};
/*2*/ {'o', '8', '8', 'o', '8', '8'}, // O
/*3*/ {'i', 'I', 'i', 'a', 'I', 'a'}, // I Uses 3,4,5 columns.
/*4*/ {'i', PH('I','#'), 'i', 'i', PH('I','#'), 'i'}, // I#
- /*5*/ {'E', PH('E','#'), 'E', 'e', PH('E','#'), 'e'}, // E#
+ /*5*/ {'E', PH('E','#'), 'E', 'e', PH('E','#'), 'e'}, // E#
/*6*/ {'E', PH('E','2'), 'E', 'e', PH('E','2'), 'e'}, // E2 Uses 3,4,5 columns.
/*7*/ {PH('j','a'), 'V', PH('j','a'), 'A', 'V', 'A'}, // V#
/*8*/ {PH('j','a'), 'I', PH('j','a'), 'e', 'I', 'e'}, // I3 Uses 3,4,5 columns.
@@ -1216,8 +1799,8 @@ PH('V','#'),PH('I','3'),PH('I','2'),PH('E','3')};
}
// do we need a variant of this vowel, depending on the stress and adjacent phonemes ?
variant = -1;
- stressed = ch->flags & 2;
- soft=prev->phflags & phPALATAL;
+ int stressed = ch->flags & 2;
+ int soft=prev->phflags & phPALATAL;
if (soft && stressed)
variant = 2; else
@@ -1240,96 +1823,6 @@ PH('V','#'),PH('I','3'),PH('I','2'),PH('E','3')};
return(0);
}
-#else
-
-
-int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
-{//=============================================================================================================
-// Called for each phoneme in the phoneme list, to allow a language to make changes
-// flags: bit 0=1 last phoneme in a word
-// bit 1=1 this is the highest stressed vowel in the current word
-// bit 2=1 after the highest stressed vowel in the current word
-// bit 3=1 the phonemes were specified explicitly, or found from an entry in the xx_list dictionary
-// ph The current phoneme
-
- int variant;
- int vowelix;
- PHONEME_TAB *prev, *next;
-
- if(ch->flags & 8)
- return(0); // full phoneme translation has already been given
-
- // Russian vowel softening and reduction rules
- if(ph->type == phVOWEL)
- {
- #define N_VOWELS_RU 7
- static unsigned char vowels_ru[N_VOWELS_RU] = {'a','A','o','E','i','u','y'};
-
- // each line gives: soft, reduced, soft-reduced, post-tonic
- static unsigned short vowel_replace[N_VOWELS_RU][4] = {
- {'&', 'V', 'I', 'V'}, // a
- {'&', 'V', 'I', 'V'}, // A
- {'8', 'V', 'I', 'V'}, // o
- {'e', 'I', 'I', 'I'}, // E
- {'i', 'I', 'I', 'I'}, // i
- {'u'+('"'<<8), 'U', 'U', 'U'}, // u
- {'y', 'Y', 'Y', 'Y'}}; // y
-
- prev = phoneme_tab[phlist[index-1].phcode];
- next = phoneme_tab[phlist[index+1].phcode];
-
-if(prev->mnemonic == 'j')
- return(0);
-
- // lookup the vowel name to get an index into the vowel_replace[] table
- for(vowelix=0; vowelix<N_VOWELS_RU; vowelix++)
- {
- if(vowels_ru[vowelix] == ph->mnemonic)
- break;
- }
- if(vowelix == N_VOWELS_RU)
- return(0);
-
- // do we need a variant of this vowel, depending on the stress and adjacent phonemes ?
- variant = -1;
- if(ch->flags & 2)
- {
- // a stressed vowel
- if((prev->phflags & phPALATAL) && ((next->phflags & phPALATAL) || phoneme_tab[phlist[index+2].phcode]->mnemonic == ';'))
- {
- // between two palatal consonants, use the soft variant
- variant = 0;
- }
- }
- else
- {
- // an unstressed vowel
- if(prev->phflags & phPALATAL)
- {
- variant = 2; // unstressed soft
- }
- else
- if((ph->mnemonic == 'o') && ((prev->phflags & phPLACE) == phPLACE_pla))
- {
- variant = 2; // unstressed soft ([o] vowel following: ш ж
- }
- else
- if(ch->flags & 4)
- {
- variant = 3; // post tonic
- }
- else
- {
- variant = 1; // unstressed
- }
- }
- if(variant >= 0)
- {
- phlist[index].phcode = PhonemeCode(vowel_replace[vowelix][variant]);
- }
- }
- return(0);
-}
#endif
diff --git a/navit/support/espeak/translate.c b/navit/support/espeak/translate.c
index 4891644cd..890fa31ba 100755..100644
--- a/navit/support/espeak/translate.c
+++ b/navit/support/espeak/translate.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -75,17 +75,23 @@ static int embedded_flag = 0; // there are embedded commands to be applied to
static int prev_clause_pause=0;
static int max_clause_pause = 0;
+static int any_stressed_words;
int pre_pause;
+ALPHABET *current_alphabet;
// these were previously in translator class
+#ifdef PLATFORM_WINDOWS
+char word_phonemes[N_WORD_PHONEMES*2]; // longer, because snprint() is not available
+#else
char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes
+#endif
int n_ph_list2;
PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes
-wchar_t option_punctlist[N_PUNCTLIST]={0};
+wchar_t option_punctlist[N_PUNCTLIST]= {0};
char ctrl_embedded = '\001'; // to allow an alternative CTRL for embedded commands
int option_multibyte=espeakCHARS_AUTO; // 0=auto, 1=utf8, 2=8bit, 3=wchar, 4=16bit
@@ -98,7 +104,6 @@ static int embedded_read;
unsigned int embedded_list[N_EMBEDDED_LIST];
// the source text of a single clause (UTF8 bytes)
-#define N_TR_SOURCE 700
static char source[N_TR_SOURCE+40]; // extra space for embedded command & voice change info at end
int n_replace_phonemes;
@@ -107,168 +112,170 @@ REPLACE_PHONEMES replace_phonemes[N_REPLACE_PHONEMES];
// brackets, also 0x2014 to 0x021f which don't need to be in this list
static const unsigned short brackets[] = {
-'(',')','[',']','{','}','<','>','"','\'','`',
-0xab,0xbb, // double angle brackets
-0x300a,0x300b, // double angle brackets (ideograph)
-0};
+ '(',')','[',']','{','}','<','>','"','\'','`',
+ 0xab,0xbb, // double angle brackets
+ 0x300a,0x300b, // double angle brackets (ideograph)
+ 0xe000+'<', // private usage area
+ 0
+};
// other characters which break a word, but don't produce a pause
static const unsigned short breaks[] = {'_', 0};
// treat these characters as spaces, in addition to iswspace()
-static const wchar_t chars_space[] = {0x2500,0}; // box drawing horiz
+// static const wchar_t chars_space[] = {0x2500,0x2501,0}; // box drawing horiz
// Translate character codes 0xA0 to 0xFF into their unicode values
// ISO_8859_1 is set as default
static const unsigned short ISO_8859_1[0x60] = {
- 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, // a0
- 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, // a8
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, // b0
- 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, // b8
- 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
- 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df, // d8
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
- 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0
- 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff, // f8
+ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, // a0
+ 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, // a8
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, // b0
+ 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, // b8
+ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
+ 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0
+ 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df, // d8
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
+ 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0
+ 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff, // f8
};
static const unsigned short ISO_8859_2[0x60] = {
- 0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7, // a0
- 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b, // a8
- 0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7, // b0
- 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, // b8
- 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, // c0
- 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, // c8
- 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, // d0
- 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, // d8
- 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, // e0
- 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, // e8
- 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, // f0
- 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, // f8
+ 0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7, // a0
+ 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b, // a8
+ 0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7, // b0
+ 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, // b8
+ 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, // c0
+ 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, // c8
+ 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, // d0
+ 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, // d8
+ 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, // e0
+ 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, // e8
+ 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, // f0
+ 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, // f8
};
static const unsigned short ISO_8859_3[0x60] = {
- 0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0x0000, 0x0124, 0x00a7, // a0
- 0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0x0000, 0x017b, // a8
- 0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7, // b0
- 0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0x0000, 0x017c, // b8
- 0x00c0, 0x00c1, 0x00c2, 0x0000, 0x00c4, 0x010a, 0x0108, 0x00c7, // c0
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
- 0x0000, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7, // d0
- 0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df, // d8
- 0x00e0, 0x00e1, 0x00e2, 0x0000, 0x00e4, 0x010b, 0x0109, 0x00e7, // e0
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
- 0x0000, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7, // f0
- 0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9, // f8
+ 0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0x0000, 0x0124, 0x00a7, // a0
+ 0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0x0000, 0x017b, // a8
+ 0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7, // b0
+ 0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0x0000, 0x017c, // b8
+ 0x00c0, 0x00c1, 0x00c2, 0x0000, 0x00c4, 0x010a, 0x0108, 0x00c7, // c0
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
+ 0x0000, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7, // d0
+ 0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df, // d8
+ 0x00e0, 0x00e1, 0x00e2, 0x0000, 0x00e4, 0x010b, 0x0109, 0x00e7, // e0
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
+ 0x0000, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7, // f0
+ 0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9, // f8
};
static const unsigned short ISO_8859_4[0x60] = {
- 0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7, // a0
- 0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af, // a8
- 0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7, // b0
- 0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b, // b8
- 0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e, // c0
- 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a, // c8
- 0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0
- 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df, // d8
- 0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f, // e0
- 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b, // e8
- 0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0
- 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9, // f8
+ 0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7, // a0
+ 0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af, // a8
+ 0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7, // b0
+ 0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b, // b8
+ 0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e, // c0
+ 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a, // c8
+ 0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0
+ 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df, // d8
+ 0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f, // e0
+ 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b, // e8
+ 0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0
+ 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9, // f8
};
static const unsigned short ISO_8859_5[0x60] = {
- 0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, // a0 Cyrillic
- 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f, // a8
- 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, // b0
- 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, // b8
- 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, // c0
- 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, // c8
- 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, // d0
- 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, // d8
- 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, // e0
- 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, // e8
- 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, // f0
- 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f, // f8
+ 0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, // a0 Cyrillic
+ 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f, // a8
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, // b0
+ 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, // b8
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, // c0
+ 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, // c8
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, // d0
+ 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, // d8
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, // e0
+ 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, // e8
+ 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, // f0
+ 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f, // f8
};
static const unsigned short ISO_8859_7[0x60] = {
- 0x00a0, 0x2018, 0x2019, 0x00a3, 0x20ac, 0x20af, 0x00a6, 0x00a7, // a0 Greek
- 0x00a8, 0x00a9, 0x037a, 0x00ab, 0x00ac, 0x00ad, 0x0000, 0x2015, // a8
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7, // b0
- 0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f, // b8
- 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, // c0
- 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, // c8
- 0x03a0, 0x03a1, 0x0000, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, // d0
- 0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af, // d8
- 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, // e0
- 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, // e8
- 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, // f0
- 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000, // f8
+ 0x00a0, 0x2018, 0x2019, 0x00a3, 0x20ac, 0x20af, 0x00a6, 0x00a7, // a0 Greek
+ 0x00a8, 0x00a9, 0x037a, 0x00ab, 0x00ac, 0x00ad, 0x0000, 0x2015, // a8
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7, // b0
+ 0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f, // b8
+ 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, // c0
+ 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, // c8
+ 0x03a0, 0x03a1, 0x0000, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, // d0
+ 0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af, // d8
+ 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, // e0
+ 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, // e8
+ 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, // f0
+ 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000, // f8
};
static const unsigned short ISO_8859_9[0x60] = {
- 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, // a0
- 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, // a8
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, // b0
- 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, // b8
- 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
- 0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df, // d8
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
- 0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0
- 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff, // f8
+ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, // a0
+ 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, // a8
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, // b0
+ 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, // b8
+ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
+ 0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0
+ 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df, // d8
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
+ 0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0
+ 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff, // f8
};
static const unsigned short ISO_8859_14[0x60] = {
- 0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7, // a0 Welsh
- 0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178, // a8
- 0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56, // b0
- 0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61, // b8
- 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
- 0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a, // d0
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df, // d8
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
- 0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b, // f0
- 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff, // f8
+ 0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7, // a0 Welsh
+ 0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178, // a8
+ 0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56, // b0
+ 0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61, // b8
+ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
+ 0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a, // d0
+ 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df, // d8
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
+ 0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b, // f0
+ 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff, // f8
};
static const unsigned short KOI8_R[0x60] = {
- 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556, // a0 Russian
- 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e, // a8
- 0x255f, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565, // b0
- 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x00a9, // b8
- 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, // c0
- 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, // c8
- 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, // d0
- 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, // d8
- 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, // e0
- 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, // e8
- 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, // f0
- 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a, // f8
+ 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556, // a0 Russian
+ 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e, // a8
+ 0x255f, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565, // b0
+ 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x00a9, // b8
+ 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, // c0
+ 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, // c8
+ 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, // d0
+ 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, // d8
+ 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, // e0
+ 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, // e8
+ 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, // f0
+ 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a, // f8
};
static const unsigned short ISCII[0x60] = {
- 0x0020, 0x0901, 0x0902, 0x0903, 0x0905, 0x0906, 0x0907, 0x0908, // a0
- 0x0909, 0x090a, 0x090b, 0x090e, 0x090f, 0x0910, 0x090d, 0x0912, // a8
- 0x0913, 0x0914, 0x0911, 0x0915, 0x0916, 0x0917, 0x0918, 0x0919, // b0
- 0x091a, 0x091b, 0x091c, 0x091d, 0x091e, 0x091f, 0x0920, 0x0921, // b8
- 0x0922, 0x0923, 0x0924, 0x0925, 0x0926, 0x0927, 0x0928, 0x0929, // c0
- 0x092a, 0x092b, 0x092c, 0x092d, 0x092e, 0x092f, 0x095f, 0x0930, // c8
- 0x0931, 0x0932, 0x0933, 0x0934, 0x0935, 0x0936, 0x0937, 0x0938, // d0
- 0x0939, 0x0020, 0x093e, 0x093f, 0x0940, 0x0941, 0x0942, 0x0943, // d8
- 0x0946, 0x0947, 0x0948, 0x0945, 0x094a, 0x094b, 0x094c, 0x0949, // e0
- 0x094d, 0x093c, 0x0964, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // e8
- 0x0020, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, // f0
- 0x0037, 0x0038, 0x0039, 0x20, 0x20, 0x20, 0x20, 0x20, // f8
+ 0x0020, 0x0901, 0x0902, 0x0903, 0x0905, 0x0906, 0x0907, 0x0908, // a0
+ 0x0909, 0x090a, 0x090b, 0x090e, 0x090f, 0x0910, 0x090d, 0x0912, // a8
+ 0x0913, 0x0914, 0x0911, 0x0915, 0x0916, 0x0917, 0x0918, 0x0919, // b0
+ 0x091a, 0x091b, 0x091c, 0x091d, 0x091e, 0x091f, 0x0920, 0x0921, // b8
+ 0x0922, 0x0923, 0x0924, 0x0925, 0x0926, 0x0927, 0x0928, 0x0929, // c0
+ 0x092a, 0x092b, 0x092c, 0x092d, 0x092e, 0x092f, 0x095f, 0x0930, // c8
+ 0x0931, 0x0932, 0x0933, 0x0934, 0x0935, 0x0936, 0x0937, 0x0938, // d0
+ 0x0939, 0x0020, 0x093e, 0x093f, 0x0940, 0x0941, 0x0942, 0x0943, // d8
+ 0x0946, 0x0947, 0x0948, 0x0945, 0x094a, 0x094b, 0x094c, 0x0949, // e0
+ 0x094d, 0x093c, 0x0964, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // e8
+ 0x0020, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, // f0
+ 0x0037, 0x0038, 0x0039, 0x20, 0x20, 0x20, 0x20, 0x20, // f8
};
const unsigned short *charsets[N_CHARSETS] = {
@@ -291,7 +298,8 @@ const unsigned short *charsets[N_CHARSETS] = {
ISO_8859_1,
ISO_8859_1,
KOI8_R, // 18
- ISCII };
+ ISCII
+};
// Tables of the relative lengths of vowels, depending on the
// type of the two phonemes that follow
@@ -299,7 +307,7 @@ const unsigned short *charsets[N_CHARSETS] = {
// use this table if vowel is not the last in the word
static unsigned char length_mods_en[100] = {
-/* a , t s n d z r N <- next */
+ /* a , t s n d z r N <- next */
100,120,100,105,100,110,110,100, 95, 100, /* a <- next2 */
105,120,105,110,125,130,135,115,125, 100, /* , */
105,120, 75,100, 75,105,120, 85, 75, 100, /* t */
@@ -309,11 +317,12 @@ static unsigned char length_mods_en[100] = {
105,120,100,105,105,122,125,110,105, 100, /* z */
105,120,100,105,105,122,125,110,105, 100, /* r */
105,120, 95,105,100,115,120,110,100, 100, /* N */
- 100,120,100,100,100,100,100,100,100, 100 }; // SPARE
+ 100,120,100,100,100,100,100,100,100, 100
+}; // SPARE
// as above, but for the last syllable in a word
static unsigned char length_mods_en0[100] = {
-/* a , t s n d z r N <- next */
+ /* a , t s n d z r N <- next */
100,150,100,105,110,115,110,110,110, 100, /* a <- next2 */
105,150,105,110,125,135,140,115,135, 100, /* , */
105,150, 90,105, 90,122,135,100, 90, 100, /* t */
@@ -323,31 +332,33 @@ static unsigned char length_mods_en0[100] = {
105,150,100,105,110,122,125,115,110, 100, /* z */
105,150,100,105,105,122,135,120,105, 100, /* r */
105,150,100,105,105,115,135,110,105, 100, /* N */
- 100,100,100,100,100,100,100,100,100, 100 }; // SPARE
+ 100,100,100,100,100,100,100,100,100, 100
+}; // SPARE
static unsigned char length_mods_equal[100] = {
-/* a , t s n d z r N <- next */
- 110,110,110,110,110,110,110,110,110, 110, /* a <- next2 */
- 110,110,110,110,110,110,110,110,110, 110, /* , */
- 110,110,110,110,110,110,110,110,110, 110, /* t */
- 110,110,110,110,110,110,110,110,110, 110, /* s */
- 110,110,110,110,110,110,110,110,110, 110, /* n */
- 110,110,110,110,110,110,110,110,110, 110, /* d */
- 110,110,110,110,110,110,110,110,110, 110, /* z */
- 110,110,110,110,110,110,110,110,110, 110, /* r */
- 110,110,110,110,110,110,110,110,110, 110, /* N */
- 110,110,110,110,110,110,110,110,110, 110 }; // SPARE
+ /* a , t s n d z r N <- next */
+ 110,120,100,110,110,110,110,110,110, 110, /* a <- next2 */
+ 110,120,100,110,110,110,110,110,110, 110, /* , */
+ 110,120,100,110,100,110,110,110,100, 110, /* t */
+ 110,120,100,110,110,110,110,110,110, 110, /* s */
+ 110,120,100,110,110,110,110,110,110, 110, /* n */
+ 110,120,100,110,110,110,110,110,110, 110, /* d */
+ 110,120,100,110,110,110,110,110,110, 110, /* z */
+ 110,120,100,110,110,110,110,110,110, 110, /* r */
+ 110,120,100,110,110,110,110,110,110, 110, /* N */
+ 110,120,100,110,110,110,110,110,110, 110
+}; // SPARE
static unsigned char *length_mod_tabs[6] = {
- length_mods_en,
- length_mods_en, // 1
- length_mods_en0, // 2
- length_mods_equal, // 3
- length_mods_equal, // 4
- length_mods_equal // 5
- };
+ length_mods_en,
+ length_mods_en, // 1
+ length_mods_en0, // 2
+ length_mods_equal, // 3
+ length_mods_equal, // 4
+ length_mods_equal // 5
+};
void SetLengthMods(Translator *tr, int value)
@@ -362,35 +373,67 @@ void SetLengthMods(Translator *tr, int value)
}
+
int IsAlpha(unsigned int c)
{//========================
// Replacement for iswalph() which also checks for some in-word symbols
- if(iswalpha(c))
+ static const unsigned short extra_indic_alphas[] = {
+ 0xa70,0xa71, // Gurmukhi: tippi, addak
+ 0
+ };
+
+ if(iswalpha2(c))
return(1);
+ if(c < 0x300)
+ return(0);
+
if((c >= 0x901) && (c <= 0xdf7))
{
// Indic scripts: Devanagari, Tamil, etc
if((c & 0x7f) < 0x64)
return(1);
+ if(lookupwchar(extra_indic_alphas, c) != 0)
+ return(1);
+ if((c >= 0xd7a) && (c <= 0xd7f))
+ return(1); // malaytalam chillu characters
+
return(0);
}
+ if((c >= 0x5b0) && (c <= 0x5c2))
+ return(1); // Hebrew vowel marks
+
+ if(c == 0x0605)
+ return(1);
+
+ if((c == 0x670) || ((c >= 0x64b) && (c <= 0x65e)))
+ return(1); // arabic vowel marks
+
if((c >= 0x300) && (c <= 0x36f))
return(1); // combining accents
+ if((c >= 0x780) && (c <= 0x7b1))
+ return(1); // taani/divehi (maldives)
+
+ if((c >= 0xf40) && (c <= 0xfbc))
+ return(1); // tibetan
+
if((c >= 0x1100) && (c <= 0x11ff))
return(1); //Korean jamo
+ if((c >= 0x2800) && (c <= 0x28ff))
+ return(1); // braille
+
if((c > 0x3040) && (c <= 0xa700))
return(1); // Chinese/Japanese. Should never get here, but Mac OS 10.4's iswalpha seems to be broken, so just make sure
return(0);
}
-static int IsDigit09(unsigned int c)
-{//=========================
+int IsDigit09(unsigned int c)
+{//============================
if((c >= '0') && (c <= '9'))
return(1);
return(0);
@@ -407,12 +450,16 @@ int IsDigit(unsigned int c)
return(0);
}
-int IsSpace(unsigned int c)
+static int IsSpace(unsigned int c)
{//========================
if(c == 0)
return(0);
- if(wcschr(chars_space,c))
- return(1);
+ if((c >= 0x2500) && (c < 0x25a0))
+ return(1); // box drawing characters
+ if((c >= 0xfff9) && (c <= 0xffff))
+ return(1); // unicode specials
+// if(wcschr(chars_space,c))
+// return(1);
return(iswspace(c));
}
@@ -438,6 +485,22 @@ int lookupwchar(const unsigned short *list,int c)
return(0);
}
+
+int lookupwchar2(const unsigned short *list,int c)
+{//==============================================
+// Replace character c by another character.
+// Returns 0 = not found, 1 = delete character
+ int ix;
+
+ for(ix=0; list[ix] != 0; ix+=2)
+ {
+ if(list[ix] == c)
+ return(list[ix+1]);
+ }
+ return(0);
+}
+
+
int IsBracket(int c)
{//=================
if((c >= 0x2014) && (c <= 0x201f))
@@ -467,8 +530,7 @@ int utf8_out(unsigned int c, char *buf)
}
if(c < 0x0800)
n_bytes = 1;
- else
- if(c < 0x10000)
+ else if(c < 0x10000)
n_bytes = 2;
else
n_bytes = 3;
@@ -500,7 +562,7 @@ int utf8_nbytes(const char *buf)
int utf8_in2(int *c, const char *buf, int backwards)
{//=================================================
-// Read a unicode characater from a UTF8 string
+// Read a unicode characater from a UTF8 string
// Returns the number of UTF8 bytes used.
// backwards: set if we are moving backwards through the UTF8 string
int c1;
@@ -524,11 +586,9 @@ int utf8_in2(int *c, const char *buf, int backwards)
{
if((c1 & 0xe0) == 0xc0)
n_bytes = 1;
- else
- if((c1 & 0xf0) == 0xe0)
+ else if((c1 & 0xf0) == 0xe0)
n_bytes = 2;
- else
- if((c1 & 0xf8) == 0xf0)
+ else if((c1 & 0xf8) == 0xf0)
n_bytes = 3;
c1 &= mask[n_bytes];
@@ -544,7 +604,7 @@ int utf8_in2(int *c, const char *buf, int backwards)
int utf8_in(int *c, const char *buf)
{//=================================
-// Read a unicode characater from a UTF8 string
+// Read a unicode characater from a UTF8 string
// Returns the number of UTF8 bytes used.
return(utf8_in2(c,buf,0));
}
@@ -558,45 +618,250 @@ char *strchr_w(const char *s, int c)
return(strchr((char *)s,c)); // (char *) is needed for Borland compiler
}
+#if 0
+static int IsAllUpper(const char *word)
+{//=============================
+ int c;
+ while((*word != 0) && !isspace2(*word))
+ {
+ word += utf8_in(&c, word);
+ if(!iswupper2(c))
+ return(0);
+ }
+ return(1);
+}
+#endif
+
+static char *SpeakIndividualLetters(Translator *tr, char *word, char *phonemes, int spell_word)
+{//============================================================================================
+ int posn = 0;
+ int capitals = 0;
+ int non_initial = 0;
+
+ if(spell_word > 2)
+ capitals = 2; // speak 'capital'
+ if(spell_word > 1)
+ capitals |= 4; // speak charater code for unknown letters
+
+ while((*word != ' ') && (*word != 0))
+ {
+ word += TranslateLetter(tr, word, phonemes, capitals | non_initial);
+ posn++;
+ non_initial = 1;
+ if(phonemes[0] == phonSWITCH)
+ {
+ // change to another language in order to translate this word
+ strcpy(word_phonemes,phonemes);
+ return(NULL);
+ }
+ }
+ SetSpellingStress(tr,phonemes,spell_word,posn);
+ return(word);
+} // end of SpeakIndividualLetters
+
+
+
+static int CheckDottedAbbrev(char *word1, WORD_TAB *wtab)
+{//=====================================================
+ int wc;
+ int count = 0;
+ int nbytes;
+ int ok;
+ int ix;
+ char *word;
+ char *wbuf;
+ char word_buf[80];
+
+ word = word1;
+ wbuf = word_buf;
+ ix = 0;
+
+ for(;;)
+ {
+ ok = 0;
+ nbytes = utf8_in(&wc, word);
+ if((word[nbytes] == ' ') && IsAlpha(wc))
+ {
+ if(word[nbytes+1] == '.')
+ {
+ if(word[nbytes+2] == ' ')
+ ok = 1;
+ else if(word[nbytes+2] =='\'')
+ {
+ nbytes += 2; // delete the final dot (eg. u.s.a.'s)
+ ok = 2;
+ }
+ }
+ else if((count > 0) && (word[nbytes] == ' '))
+ ok = 2;
+ }
+
+ if(ok == 0)
+ break;
+
+ for(ix=0; ix < nbytes; ix++)
+ *wbuf++ = word[ix];
+
+ count++;
+
+ if(ok == 2)
+ {
+ word += nbytes;
+ break;
+ }
+
+ word += (nbytes + 3);
+ }
+
+ if(count > 1)
+ {
+ ix = wbuf - word_buf;
+ memcpy(word1, word_buf, ix);
+ while(&word1[ix] < word)
+ word1[ix++] = ' ';
+ dictionary_skipwords = (count - 1)*2;
+ }
+ return(count);
+} // end of CheckDottedAbbrev
+
+
+extern char *phondata_ptr;
+
+static int ChangeEquivalentPhonemes(Translator *tr, int lang2, char *phonemes)
+{//====================================================================
+// tr: the original language
+// lang2: phoneme table number for the temporary language
+// phonemes: the phonemes to be replaced
+
+ int ix;
+ int len;
+ char phon;
+ char *p;
+ unsigned char *pb;
+ char *eqlist;
+ char *p_out;
+ char *p_in;
+ int remove_stress = 0;
+ char phonbuf[N_WORD_PHONEMES];
+
+ // has a phoneme equivalence table been specified for thus language pair?
+ if((ix = phoneme_tab_list[tr->phoneme_tab_ix].equivalence_tables) == 0)
+ return(0);
+
+ pb = (unsigned char *)&phondata_ptr[ix];
+
+ for(;;)
+ {
+ if(pb[0] == 0)
+ return(0); // table not found
+
+ if(pb[0] == lang2)
+ break;
+
+ len = (pb[2] << 8) + pb[3]; // size of this table in words
+ pb += (len * 4);
+ }
+ remove_stress = pb[1];
+
+ if(option_phonemes == 2)
+ {
+ DecodePhonemes(phonemes, phonbuf);
+ fprintf(f_trans,"(%s) %s -> (%s) ", phoneme_tab_list[lang2].name, phonbuf, phoneme_tab_list[tr->phoneme_tab_ix].name);
+ }
+
+ p_in = phonemes;
+ eqlist = (char *)&pb[8];
+ p_out = phonbuf;
+
+ while((phon = *p_in++) != 0)
+ {
+ if(remove_stress && ((phon & 0xff) < phonSTRESS_PREV))
+ continue; // remove stress marks
+
+ // is there a translation for this phoneme code?
+ p = eqlist;
+ while(*p != 0)
+ {
+ len = strlen(&p[1]);
+ if(*p == phon)
+ {
+ strcpy(p_out, &p[1]);
+ p_out += len;
+ break;
+ }
+ p += (len + 2);
+ }
+ if(*p == 0)
+ {
+ // no translation found
+ *p_out++ = phon;
+ }
+ }
+ *p_out = 0;
+
+ if(remove_stress)
+ {
+ SetWordStress(tr, phonbuf, NULL, -1, 0);
+ }
+
+ strcpy(phonemes, phonbuf);
+
+ if(option_phonemes == 2)
+ {
+ SelectPhonemeTable(tr->phoneme_tab_ix);
+ DecodePhonemes(phonemes, phonbuf);
+ fprintf(f_trans,"%s\n\n", phonbuf);
+ }
+ return(1);
+} // end of ChangeEquivalentPhonemes
+
-int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
-{//===========================================================================
+int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wtab, char *word_out)
+{//==================================================================================================
// word1 is terminated by space (0x20) character
- int length;
+ char *word1;
int word_length;
int ix;
- int posn;
+ char *p;
int pfix;
int n_chars;
unsigned int dictionary_flags[2];
unsigned int dictionary_flags2[2];
int end_type=0;
+ int end_type1=0;
int prefix_type=0;
+ int prefix_stress;
char *wordx;
char phonemes[N_WORD_PHONEMES];
- char *ph_limit;
- char *phonemes_ptr;
+ char phonemes2[N_WORD_PHONEMES];
char prefix_phonemes[N_WORD_PHONEMES];
+ char unpron_phonemes[N_WORD_PHONEMES];
char end_phonemes[N_WORD_PHONEMES];
+ char end_phonemes2[N_WORD_PHONEMES];
char word_copy[N_WORD_BYTES];
- char prefix_chars[N_WORD_BYTES];
+ char word_copy2[N_WORD_BYTES];
+ int word_copy_length;
+ char prefix_chars[0x3f + 2];
int found=0;
- int end_flags;
- char c_temp; // save a character byte while we temporarily replace it with space
+ int end_flags;
+ int c_temp; // save a character byte while we temporarily replace it with space
int first_char;
int last_char = 0;
- int unpron_length;
int add_plural_suffix = 0;
int prefix_flags = 0;
+ int more_suffixes;
int confirm_prefix;
int spell_word;
int stress_bits;
int emphasize_allcaps = 0;
- int wflags = wtab->flags;
- int wmark = wtab->wmark;
+ int wflags;
+ int wmark;
+ int was_unpronouncable = 0;
+ int loopcount;
+ WORD_TAB wtab_null[8];
// translate these to get pronunciations of plural 's' suffix (different forms depending on
// the preceding letter
@@ -604,18 +869,37 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
static char word_iz[4] = {0,'i','z',0};
static char word_ss[4] = {0,'s','s',0};
+ if(wtab == NULL)
+ {
+ memset(wtab_null, 0, sizeof(wtab_null));
+ wtab = wtab_null;
+ }
+ wflags = wtab->flags;
+ wmark = wtab->wmark;
+
dictionary_flags[0] = 0;
dictionary_flags[1] = 0;
dictionary_flags2[0] = 0;
dictionary_flags2[1] = 0;
dictionary_skipwords = 0;
+ phonemes[0] = 0;
+ unpron_phonemes[0] = 0;
prefix_phonemes[0] = 0;
end_phonemes[0] = 0;
- ph_limit = &phonemes[N_WORD_PHONEMES];
+
+ if(tr->data_dictlist == NULL)
+ {
+ // dictionary is not loaded
+ word_phonemes[0] = 0;
+ return(0);
+ }
// count the length of the word
+ word1 = word_start;
+ if(*word1 == ' ') word1++; // possibly a dot was replaced by space: $dot
wordx = word1;
+
utf8_in(&first_char,wordx);
word_length = 0;
while((*wordx != 0) && (*wordx != ' '))
@@ -624,15 +908,36 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
word_length++;
}
- // try an initial lookup in the dictionary list, we may find a pronunciation specified, or
- // we may just find some flags
+ word_copy_length = wordx - word_start;
+ if(word_copy_length >= N_WORD_BYTES)
+ word_copy_length = N_WORD_BYTES-1;
+ memcpy(word_copy2, word_start, word_copy_length);
+
spell_word = 0;
+
+ if((word_length == 1) && (wflags & FLAG_TRANSLATOR2))
+ {
+ // retranslating a 1-character word using a different language, say its name
+ utf8_in(&c_temp, wordx+1); // the next character
+ if(!IsAlpha(c_temp) || (AlphabetFromChar(last_char) != AlphabetFromChar(c_temp)))
+ spell_word = 1;
+ }
+
if(option_sayas == SAYAS_KEY)
{
if(word_length == 1)
spell_word = 4;
+ else
+ {
+ // is there a translation for this keyname ?
+ word1--;
+ *word1 = '_'; // prefix keyname with '_'
+ found = LookupDictList(tr, &word1, phonemes, dictionary_flags, 0, wtab);
+ }
}
+ // try an initial lookup in the dictionary list, we may find a pronunciation specified, or
+ // we may just find some flags
if(option_sayas & 0x10)
{
// SAYAS_CHAR, SAYAS_GYLPH, or SAYAS_SINGLE_CHAR
@@ -640,9 +945,20 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
}
else
{
- found = LookupDictList(tr, &word1, phonemes, dictionary_flags, FLAG_ALLOW_TEXTMODE, wtab); // the original word
+ if(!found)
+ found = LookupDictList(tr, &word1, phonemes, dictionary_flags, FLAG_ALLOW_TEXTMODE, wtab); // the original word
+
+
+ if((dictionary_flags[0] & (FLAG_ALLOW_DOT || FLAG_NEEDS_DOT)) && (wordx[1] == '.'))
+ {
+ wordx[1] = ' '; // remove a Dot after this word
+ }
+
if(dictionary_flags[0] & FLAG_TEXTMODE)
{
+ if(word_out != NULL)
+ strcpy(word_out, word1);
+
first_char = word1[0];
stress_bits = dictionary_flags[0] & 0x7f;
found = LookupDictList(tr, &word1, phonemes, dictionary_flags2, 0, wtab); // the text replacement
@@ -657,8 +973,7 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
}
}
}
- else
- if((found==0) && (dictionary_flags[0] & FLAG_SKIPWORDS))
+ else if((found==0) && (dictionary_flags[0] & FLAG_SKIPWORDS) && !(dictionary_flags[0] & FLAG_ABBREV))
{
// grouped words, but no translation. Join the words with hyphens.
wordx = word1;
@@ -674,6 +989,20 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
}
}
+ if((word_length == 1) && (dictionary_skipwords == 0))
+ {
+ // is this a series of single letters separated by dots?
+ if(CheckDottedAbbrev(word1, wtab))
+ {
+ dictionary_flags[0] = 0;
+ dictionary_flags[1] = 0;
+ spell_word = 1;
+ if(dictionary_skipwords)
+ dictionary_flags[0] = FLAG_SKIPWORDS;
+ }
+ }
+
+
// if textmode, LookupDictList() replaces word1 by the new text and returns found=0
if(phonemes[0] == phonSWITCH)
@@ -683,48 +1012,58 @@ int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
return(0);
}
-if((wmark > 0) && (wmark < 8))
-{
- // the stressed syllable has been specified in the text (TESTING)
- dictionary_flags[0] = (dictionary_flags[0] & ~0xf) | wmark;
-}
+ if((wmark > 0) && (wmark < 8))
+ {
+ // the stressed syllable has been specified in the text (TESTING)
+ dictionary_flags[0] = (dictionary_flags[0] & ~0xf) | wmark;
+ }
if(!found && (dictionary_flags[0] & FLAG_ABBREV))
{
// the word has $abbrev flag, but no pronunciation specified. Speak as individual letters
spell_word = 1;
}
-
+
if(!found && iswdigit(first_char))
{
Lookup(tr,"_0lang",word_phonemes);
if(word_phonemes[0] == phonSWITCH)
return(0);
- found = TranslateNumber(tr,word1,phonemes,dictionary_flags,wflags);
+ if((tr->langopts.numbers2 & NUM2_ENGLISH_NUMERALS) && !(wtab->flags & FLAG_CHAR_REPLACED))
+ {
+ // for this language, speak English numerals (0-9) with the English voice
+ sprintf(word_phonemes,"%c",phonSWITCH);
+ return(0);
+ }
+
+ found = TranslateNumber(tr, word1, phonemes, dictionary_flags, wtab, 0);
}
- if(!found & ((wflags & FLAG_UPPERS) != FLAG_FIRST_UPPER))
+ if(!found && ((wflags & FLAG_UPPERS) != FLAG_FIRST_UPPER))
{
// either all upper or all lower case
- if((tr->langopts.numbers & NUM_ROMAN) || ((tr->langopts.numbers & NUM_ROMAN_UC) && (wflags & FLAG_ALL_UPPER)))
+ if((tr->langopts.numbers & NUM_ROMAN) || ((tr->langopts.numbers & NUM_ROMAN_CAPITALS) && (wflags & FLAG_ALL_UPPER)))
{
- if((found = TranslateRoman(tr, word1, phonemes)) != 0)
- dictionary_flags[0] |= FLAG_ABBREV; // prevent emphasis if capitals
+ if((wflags & FLAG_LAST_WORD) || !(wtab[1].flags & FLAG_NOSPACE))
+ {
+ // don't use Roman number if this word is not separated from the next word (eg. "XLTest")
+ if((found = TranslateRoman(tr, word1, phonemes, wtab)) != 0)
+ dictionary_flags[0] |= FLAG_ABBREV; // prevent emphasis if capitals
+ }
}
}
- if((wflags & FLAG_ALL_UPPER) && (word_length > 1)&& iswalpha(first_char))
+ if((wflags & FLAG_ALL_UPPER) && (word_length > 1)&& iswalpha2(first_char))
{
if((option_tone_flags & OPTION_EMPHASIZE_ALLCAPS) && !(dictionary_flags[0] & FLAG_ABBREV))
{
// emphasize words which are in capitals
emphasize_allcaps = FLAG_EMPHASIZED;
}
- else
- if(!found && !(dictionary_flags[0] & FLAG_SKIPWORDS) && (word_length<4) && (tr->clause_lower_count > 3)
- && (tr->clause_upper_count <= tr->clause_lower_count))
+ else if(!found && !(dictionary_flags[0] & FLAG_SKIPWORDS) && (word_length<4) && (tr->clause_lower_count > 3)
+ && (tr->clause_upper_count <= tr->clause_lower_count))
{
// An upper case word in a lower case clause. This could be an abbreviation.
spell_word = 1;
@@ -735,53 +1074,62 @@ if((wmark > 0) && (wmark < 8))
if(spell_word > 0)
{
// Speak as individual letters
- wordx = word1;
- posn = 0;
phonemes[0] = 0;
end_type = 0;
- while(*wordx != ' ')
+ if(SpeakIndividualLetters(tr, word1, phonemes, spell_word) == NULL)
{
- wordx += TranslateLetter(tr,wordx, phonemes,spell_word, word_length);
- posn++;
+ if(word_length > 1)
+ return(FLAG_SPELLWORD); // a mixture of languages, retranslate as individual letters, separated by spaces
if(phonemes[0] == phonSWITCH)
{
- // change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
- if(word_length > 1)
- return(FLAG_SPELLWORD); // a mixture of languages, retranslate as individual letters, separated by spaces
- return(0);
+// problem with espeak -vbg "b.c.d.e.f"
}
+ return(0);
}
- SetSpellingStress(tr,phonemes,spell_word,posn);
+ strcpy(word_phonemes, phonemes);
+ if(wflags & FLAG_TRANSLATOR2)
+ return(0);
+ return(dictionary_flags[0] & FLAG_SKIPWORDS); // for "b.c.d"
}
- else
- if(found == 0)
+ else if(found == 0)
{
+ int posn;
+ int non_initial;
+ int length;
// word's pronunciation is not given in the dictionary list, although
// dictionary_flags may have ben set there
posn = 0;
+ non_initial = 0;
length = 999;
wordx = word1;
- while(((length < 3) && (length > 0))|| (word_length > 1 && Unpronouncable(tr,wordx)))
+ while(((length < 3) && (length > 0))|| (word_length > 1 && Unpronouncable(tr, wordx, posn)))
{
- char *p;
// This word looks "unpronouncable", so speak letters individually until we
// find a remainder that we can pronounce.
+ was_unpronouncable = FLAG_WAS_UNPRONOUNCABLE;
emphasize_allcaps = 0;
- wordx += TranslateLetter(tr,wordx,phonemes,0, word_length);
+
+ if(wordx[0] == '\'')
+ break;
+
+ if(posn > 0)
+ non_initial = 1;
+
+ wordx += TranslateLetter(tr, wordx, unpron_phonemes, non_initial);
posn++;
- if(phonemes[0] == phonSWITCH)
+ if(unpron_phonemes[0] == phonSWITCH)
{
// change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
- if(strcmp(&phonemes[1],"en")==0)
- return(FLAG_SPELLWORD); // _^_en must have been set in TranslateLetter(), not *_rules
+ strcpy(word_phonemes,unpron_phonemes);
+ if(strcmp(&unpron_phonemes[1],"en")==0)
+ return(FLAG_SPELLWORD); // _^_en must have been set in TranslateLetter(), not *_rules which uses only _^_
return(0);
}
+#ifdef deleted
p = &wordx[word_length-3]; // this looks wrong. Doesn't consider multi-byte chars.
if(memcmp(p,"'s ",3) == 0)
{
@@ -791,19 +1139,22 @@ if((wmark > 0) && (wmark < 8))
p[1] = ' ';
last_char = p[-1];
}
-
+#endif
length=0;
while(wordx[length] != ' ') length++;
- if(length > 0)
- wordx[-1] = ' '; // prevent this affecting the pronunciation of the pronuncable part
}
- SetSpellingStress(tr,phonemes,0,posn);
+ SetSpellingStress(tr,unpron_phonemes,0,posn);
// anything left ?
if(*wordx != ' ')
{
+ if((unpron_phonemes[0] != 0) && (wordx[0] != '\''))
+ {
+ // letters which have been spoken individually from affecting the pronunciation of the pronuncable part
+ wordx[-1] = ' ';
+ }
+
// Translate the stem
- unpron_length = strlen(phonemes);
end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, wflags, dictionary_flags);
if(phonemes[0] == phonSWITCH)
@@ -813,27 +1164,31 @@ if((wmark > 0) && (wmark < 8))
return(0);
}
+#ifdef deleted
+// ?? allow $unpr while translating rules, not just on initial FLAG_UNPRON_TEST
+if(end_type & SUFX_UNPRON)
+{
+ phonemes[0] = 0; // discard and retranslate as individual letters
+ SpeakIndividualLetters(tr, wordx, phonemes, 0);
+ strcpy(word_phonemes, phonemes);
+ return(0);
+}
+#endif
+
if((phonemes[0] == 0) && (end_phonemes[0] == 0))
{
int wc;
// characters not recognised, speak them individually
-
+ // ?? should we say super/sub-script numbers and letters here?
utf8_in(&wc, wordx);
- if((word_length == 1) && IsAlpha(wc))
+ if((word_length == 1) && (IsAlpha(wc) || IsSuperscript(wc)))
{
- posn = 0;
- while((*wordx != ' ') && (*wordx != 0))
+ if((wordx = SpeakIndividualLetters(tr, wordx, phonemes, spell_word)) == NULL)
{
- wordx += TranslateLetter(tr,wordx, phonemes, 4, word_length);
- posn++;
- if(phonemes[0] == phonSWITCH)
- {
- // change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
- return(0);
- }
+ return(0);
}
- SetSpellingStress(tr,phonemes,spell_word,posn);
+ strcpy(word_phonemes, phonemes);
+ return(0);
}
}
@@ -841,14 +1196,13 @@ if((wmark > 0) && (wmark < 8))
found = 0;
confirm_prefix = 1;
- while(end_type & SUFX_P)
+ for (loopcount = 0; (loopcount < 50) && (end_type & SUFX_P); loopcount++)
{
// Found a standard prefix, remove it and retranslate
-
+ // loopcount guards against an endless loop
if(confirm_prefix && !(end_type & SUFX_B))
{
int end2;
- char phonemes2[N_WORD_PHONEMES];
char end_phonemes2[N_WORD_PHONEMES];
// remove any standard suffix and confirm that the prefix is still recognised
@@ -903,7 +1257,7 @@ if((wmark > 0) && (wmark < 8))
for(ix=0; ix < n_chars; ix++) // num. of bytes to remove
{
prefix_chars[pfix++] = *wordx++;
-
+
if((prefix_type & SUFX_B) && (ix == (n_chars-1)))
{
prefix_chars[pfix-1] = 0; // discard the last character of the prefix, this is the separator character
@@ -914,23 +1268,30 @@ if((wmark > 0) && (wmark < 8))
c_temp = wordx[-1];
wordx[-1] = ' ';
confirm_prefix = 1;
+ wflags |= FLAG_PREFIX_REMOVED;
if(prefix_type & SUFX_B)
{
-// SUFX_B is used for Turkish, tr_rules contains "(Pb£
- // retranslate the prefix part
+// SUFX_B is used for Turkish, tr_rules contains " ' (Pb"
+ // examine the prefix part
char *wordpf;
char prefix_phonemes2[12];
strncpy0(prefix_phonemes2,end_phonemes,sizeof(prefix_phonemes2));
wordpf = &prefix_chars[1];
- found = LookupDictList(tr, &wordpf, phonemes, dictionary_flags, SUFX_P, wtab); // without prefix
- if(found == 0)
+ strcpy(prefix_phonemes, phonemes);
+
+ // look for stress marker or $abbrev
+ found = LookupDictList(tr, &wordpf, phonemes, dictionary_flags, 0, wtab);
+ if(found)
{
- end_type = TranslateRules(tr, wordpf, phonemes, N_WORD_PHONEMES, end_phonemes, 0, dictionary_flags);
- sprintf(prefix_phonemes,"%s%s%s",phonemes,end_phonemes,prefix_phonemes2);
+ strcpy(prefix_phonemes, phonemes);
+ }
+ if(dictionary_flags[0] & FLAG_ABBREV)
+ {
+ prefix_phonemes[0] = 0;
+ SpeakIndividualLetters(tr, wordpf, prefix_phonemes, 1);
}
- prefix_flags = 1;
}
else
{
@@ -949,7 +1310,7 @@ if((wmark > 0) && (wmark < 8))
prefix_flags = 1;
if(found == 0)
{
- end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, 0, dictionary_flags);
+ end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, wflags & (FLAG_HYPHEN_AFTER | FLAG_PREFIX_REMOVED), dictionary_flags);
if(phonemes[0] == phonSWITCH)
{
@@ -961,85 +1322,129 @@ if((wmark > 0) && (wmark < 8))
}
}
+
+
+
if((end_type != 0) && !(end_type & SUFX_P))
{
-char phonemes2[N_WORD_PHONEMES];
-strcpy(phonemes2,phonemes);
+ end_type1 = end_type;
+ strcpy(phonemes2,phonemes);
// The word has a standard ending, re-translate without this ending
end_flags = RemoveEnding(tr, wordx, end_type, word_copy);
+ more_suffixes = 1;
- phonemes_ptr = &phonemes[unpron_length];
- phonemes_ptr[0] = 0;
-
- if(prefix_phonemes[0] != 0)
+ while(more_suffixes)
{
- // lookup the stem without the prefix removed
- wordx[-1] = c_temp;
- found = LookupDictList(tr, &word1, phonemes_ptr, dictionary_flags2, end_flags, wtab); // include prefix, but not suffix
- wordx[-1] = ' ';
- if(dictionary_flags[0]==0)
- {
- dictionary_flags[0] = dictionary_flags2[0];
- dictionary_flags[1] = dictionary_flags2[1];
- }
- if(found)
- prefix_phonemes[0] = 0; // matched whole word, don't need prefix now
+ more_suffixes = 0;
+ phonemes[0] = 0;
- if((found==0) && (dictionary_flags2[0] != 0))
- prefix_flags = 1;
- }
- if(found == 0)
- {
- found = LookupDictList(tr, &wordx, phonemes_ptr, dictionary_flags2, end_flags, wtab); // without prefix and suffix
- if(phonemes_ptr[0] == phonSWITCH)
+ if(prefix_phonemes[0] != 0)
{
- // change to another language in order to translate this word
- memcpy(wordx,word_copy,strlen(word_copy));
- strcpy(word_phonemes,phonemes_ptr);
- return(0);
- }
- if(dictionary_flags[0]==0)
- {
- dictionary_flags[0] = dictionary_flags2[0];
- dictionary_flags[1] = dictionary_flags2[1];
- }
- }
- if(found == 0)
- {
- if(end_type & SUFX_Q)
- {
- // don't retranslate, use the original lookup result
- strcpy(phonemes,phonemes2);
+ // lookup the stem without the prefix removed
+ wordx[-1] = c_temp;
+ found = LookupDictList(tr, &word1, phonemes, dictionary_flags2, end_flags, wtab); // include prefix, but not suffix
+ wordx[-1] = ' ';
+ if(phonemes[0] == phonSWITCH)
+ {
+ // change to another language in order to translate this word
+ memcpy(wordx,word_copy,strlen(word_copy));
+ strcpy(word_phonemes,phonemes);
+ return(0);
+ }
+ if(dictionary_flags[0]==0)
+ {
+ dictionary_flags[0] = dictionary_flags2[0];
+ dictionary_flags[1] = dictionary_flags2[1];
+ }
+ if(found)
+ prefix_phonemes[0] = 0; // matched whole word, don't need prefix now
- // language specific changes
- ApplySpecialAttribute(tr,phonemes,dictionary_flags[0]);
+ if((found==0) && (dictionary_flags2[0] != 0))
+ prefix_flags = 1;
}
- else
+ if(found == 0)
{
- if(end_flags & FLAG_SUFX)
- TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL,wflags | FLAG_SUFFIX_REMOVED, dictionary_flags);
- else
- TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL,wflags,dictionary_flags);
-
+ found = LookupDictList(tr, &wordx, phonemes, dictionary_flags2, end_flags, wtab); // without prefix and suffix
if(phonemes[0] == phonSWITCH)
{
// change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
memcpy(wordx,word_copy,strlen(word_copy));
- wordx[-1] = c_temp;
+ strcpy(word_phonemes,phonemes);
return(0);
}
+
+ if(dictionary_flags2[0] & FLAG_ABBREV)
+ {
+ // Removing the suffix leaves a word which should be spoken as individual letters
+ // Not yet implemented
+ }
+ if(dictionary_flags[0]==0)
+ {
+ dictionary_flags[0] = dictionary_flags2[0];
+ dictionary_flags[1] = dictionary_flags2[1];
+ }
+ }
+ if(found == 0)
+ {
+ if(end_type & SUFX_Q)
+ {
+ // don't retranslate, use the original lookup result
+ strcpy(phonemes,phonemes2);
+ }
+ else
+ {
+ if(end_flags & FLAG_SUFX)
+ wflags |= FLAG_SUFFIX_REMOVED;
+ if(end_type & SUFX_A)
+ wflags |= FLAG_SUFFIX_VOWEL;
+
+ if(end_type & SUFX_M)
+ {
+ // allow more suffixes before this suffix
+ strcpy(end_phonemes2, end_phonemes);
+ end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, wflags, dictionary_flags);
+ strcat(end_phonemes, end_phonemes2); // add the phonemes for the previous suffixes after this one
+
+ if((end_type != 0) && !(end_type & SUFX_P))
+ {
+ // there is another suffix
+ end_flags = RemoveEnding(tr, wordx, end_type, NULL);
+ more_suffixes = 1;
+ }
+ }
+ else
+ {
+ // don't remove any previous suffix
+ TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL, wflags, dictionary_flags);
+ end_type = 0;
+ }
+
+ if(phonemes[0] == phonSWITCH)
+ {
+ // change to another language in order to translate this word
+ strcpy(word_phonemes,phonemes);
+ memcpy(wordx,word_copy,strlen(word_copy));
+ wordx[-1] = c_temp;
+ return(0);
+ }
+ }
}
}
- if((end_type & SUFX_T) == 0)
+
+ if((end_type1 & SUFX_T) == 0)
{
// the default is to add the suffix and then determine the word's stress pattern
AppendPhonemes(tr,phonemes, N_WORD_PHONEMES, end_phonemes);
end_phonemes[0] = 0;
}
+ memcpy(wordx,word_copy,strlen(word_copy));
}
+
+
+
+
wordx[-1] = c_temp;
}
}
@@ -1049,8 +1454,7 @@ strcpy(phonemes2,phonemes);
// s or 's suffix, append [s], [z] or [Iz] depending on previous letter
if(last_char == 'f')
TranslateRules(tr, &word_ss[1], phonemes, N_WORD_PHONEMES, NULL, 0, NULL);
- else
- if((last_char==0) || (strchr_w("hsx",last_char)==NULL))
+ else if((last_char==0) || (strchr_w("hsx",last_char)==NULL))
TranslateRules(tr, &word_zz[1], phonemes, N_WORD_PHONEMES, NULL, 0, NULL);
else
TranslateRules(tr, &word_iz[1], phonemes, N_WORD_PHONEMES, NULL, 0, NULL);
@@ -1061,15 +1465,21 @@ strcpy(phonemes2,phonemes);
/* determine stress pattern for this word */
/******************************************/
- /* NOTE: this also adds a single PAUSE if the previous word ended
- in a primary stress, and this one starts with one */
- if(prefix_flags || (strchr(prefix_phonemes,phonSTRESS_P)!=NULL))
+ prefix_stress = 0;
+ for(p = prefix_phonemes; *p != 0; p++)
+ {
+ if((*p == phonSTRESS_P) || (*p == phonSTRESS_P2))
+ {
+ prefix_stress = *p;
+ }
+ }
+ if(prefix_flags || (prefix_stress != 0))
{
if((tr->langopts.param[LOPT_PREFIXES]) || (prefix_type & SUFX_T))
{
char *p;
// German, keep a secondary stress on the stem
- SetWordStress(tr, phonemes, &dictionary_flags[0], 3, 0);
+ SetWordStress(tr, phonemes, dictionary_flags, 3, 0);
// reduce all but the first primary stress
ix=0;
@@ -1083,32 +1493,46 @@ strcpy(phonemes2,phonemes);
*p = phonSTRESS_3;
}
}
- strcpy(word_phonemes,prefix_phonemes);
- strcat(word_phonemes,phonemes);
- SetWordStress(tr, word_phonemes, &dictionary_flags[0], -1, 0);
+#ifdef PLATFORM_WINDOWS
+ sprintf(word_phonemes, "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
+#else
+ snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
+#endif
+ word_phonemes[N_WORD_PHONEMES-1] = 0;
+ SetWordStress(tr, word_phonemes, dictionary_flags, -1, 0);
}
else
{
// stress position affects the whole word, including prefix
- strcpy(word_phonemes,prefix_phonemes);
- strcat(word_phonemes,phonemes);
- SetWordStress(tr, word_phonemes, &dictionary_flags[0], -1, tr->prev_last_stress);
+#ifdef PLATFORM_WINDOWS
+ sprintf(word_phonemes, "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
+#else
+ snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
+#endif
+ word_phonemes[N_WORD_PHONEMES-1] = 0;
+ SetWordStress(tr, word_phonemes, dictionary_flags, -1, 0);
}
}
else
{
if(prefix_phonemes[0] == 0)
- SetWordStress(tr, phonemes, &dictionary_flags[0], -1, tr->prev_last_stress);
+ SetWordStress(tr, phonemes, dictionary_flags, -1, 0);
else
- SetWordStress(tr, phonemes, &dictionary_flags[0], -1, 0);
- strcpy(word_phonemes,prefix_phonemes);
- strcat(word_phonemes,phonemes);
+ SetWordStress(tr, phonemes, dictionary_flags, -1, 0);
+#ifdef PLATFORM_WINDOWS
+ sprintf(word_phonemes, "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
+#else
+ snprintf(word_phonemes, sizeof(word_phonemes), "%s%s%s", unpron_phonemes, prefix_phonemes, phonemes);
+#endif
+ word_phonemes[N_WORD_PHONEMES-1] = 0;
}
if(end_phonemes[0] != 0)
{
// a suffix had the SUFX_T option set, add the suffix after the stress pattern has been determined
- strcat(word_phonemes,end_phonemes);
+ ix = strlen(word_phonemes);
+ end_phonemes[N_WORD_PHONEMES-1-ix] = 0; // ensure no buffer overflow
+ strcpy(&word_phonemes[ix], end_phonemes);
}
if(wflags & FLAG_LAST_WORD)
@@ -1118,7 +1542,26 @@ strcpy(phonemes2,phonemes);
dictionary_flags[0] &= ~FLAG_PAUSE1;
}
- if(wflags & FLAG_EMPHASIZED2)
+#ifdef deleted
+// but it causes problems if these are not a person name
+ if(tr->translator_name == L('h','u'))
+ {
+ // lang=hu, If the last two words of a clause have capital letters (eg. a person name), unstress the last word.
+ if((wflags & (FLAG_LAST_WORD | FLAG_FIRST_UPPER | FLAG_ALL_UPPER | FLAG_FIRST_WORD)) == (FLAG_LAST_WORD | FLAG_FIRST_UPPER))
+ {
+ if(((wtab[-1].flags & (FLAG_FIRST_UPPER | FLAG_ALL_UPPER)) == FLAG_FIRST_UPPER) && ((tr->clause_terminator != 0x90028) || (wflags & FLAG_HAS_DOT)))
+ {
+ ChangeWordStress(tr,word_phonemes,3);
+ }
+ }
+ }
+#endif
+
+ if((wflags & FLAG_HYPHEN) && (tr->langopts.stress_flags & S_HYPEN_UNSTRESS))
+ {
+ ChangeWordStress(tr,word_phonemes,3);
+ }
+ else if(wflags & FLAG_EMPHASIZED2)
{
// A word is indicated in the source text as stressed
// Give it stress level 6 (for the intonation module)
@@ -1127,20 +1570,19 @@ strcpy(phonemes2,phonemes);
if(wflags & FLAG_EMPHASIZED)
dictionary_flags[0] |= FLAG_PAUSE1; // precede by short pause
}
- else
- if(wtab[dictionary_skipwords].flags & FLAG_LAST_WORD)
+ else if(wtab[dictionary_skipwords].flags & FLAG_LAST_WORD)
{
// the word has attribute to stress or unstress when at end of clause
if(dictionary_flags[0] & (FLAG_STRESS_END | FLAG_STRESS_END2))
ChangeWordStress(tr,word_phonemes,4);
- else
- if(dictionary_flags[0] & FLAG_UNSTRESS_END)
+ else if((dictionary_flags[0] & FLAG_UNSTRESS_END) && (any_stressed_words))
ChangeWordStress(tr,word_phonemes,3);
}
+
// dictionary flags for this word give a clue about which alternative pronunciations of
// following words to use.
- if(end_type & SUFX_F)
+ if(end_type1 & SUFX_F)
{
// expect a verb form, with or without -s suffix
tr->expect_verb = 2;
@@ -1154,16 +1596,14 @@ strcpy(phonemes2,phonemes);
tr->expect_verb = 0;
tr->expect_noun = 0;
}
- else
- if(dictionary_flags[1] & FLAG_VERBF)
+ else if(dictionary_flags[1] & FLAG_VERBF)
{
/* expect a verb in the next word */
tr->expect_verb = 2;
tr->expect_verb_s = 0; /* verb won't have -s suffix */
tr->expect_noun = 0;
}
- else
- if(dictionary_flags[1] & FLAG_VERBSF)
+ else if(dictionary_flags[1] & FLAG_VERBSF)
{
// expect a verb, must have a -s suffix
tr->expect_verb = 0;
@@ -1171,8 +1611,7 @@ strcpy(phonemes2,phonemes);
tr->expect_past = 0;
tr->expect_noun = 0;
}
- else
- if(dictionary_flags[1] & FLAG_NOUNF)
+ else if(dictionary_flags[1] & FLAG_NOUNF)
{
/* not expecting a verb next */
tr->expect_noun = 2;
@@ -1196,11 +1635,11 @@ strcpy(phonemes2,phonemes);
tr->expect_past--;
}
- if((word_length == 1) && iswalpha(first_char) && (first_char != 'i'))
+ if((word_length == 1) && (tr->translator_name == L('e','n')) && iswalpha2(first_char) && (first_char != 'i'))
{
// English Specific !!!!
// any single letter before a dot is an abbreviation, except 'I'
- dictionary_flags[0] |= FLAG_DOT;
+ dictionary_flags[0] |= FLAG_ALLOW_DOT;
}
if((tr->langopts.param[LOPT_ALT] & 2) && ((dictionary_flags[0] & (FLAG_ALT_TRANS | FLAG_ALT2_TRANS)) != 0))
@@ -1208,6 +1647,8 @@ strcpy(phonemes2,phonemes);
ApplySpecialAttribute2(tr,word_phonemes,dictionary_flags[0]);
}
+ dictionary_flags[0] |= was_unpronouncable;
+ memcpy(word_start, word_copy2, word_copy_length);
return(dictionary_flags[0]);
} // end of TranslateWord
@@ -1216,8 +1657,8 @@ strcpy(phonemes2,phonemes);
static void SetPlist2(PHONEME_LIST2 *p, unsigned char phcode)
{//==========================================================
p->phcode = phcode;
- p->stress = 0;
- p->tone_number = 0;
+ p->stresslevel = 0;
+ p->tone_ph = 0;
p->synthflags = embedded_flag;
p->sourceix = 0;
embedded_flag = 0;
@@ -1236,12 +1677,63 @@ static int CountSyllables(unsigned char *phonemes)
}
+static void Word_EmbeddedCmd(void)
+{//====================
+// Process embedded commands for emphasis, sayas, and break
+ int embedded_cmd;
+ int value;
+
+ do
+ {
+ embedded_cmd = embedded_list[embedded_read++];
+ value = embedded_cmd >> 8;
+
+ switch(embedded_cmd & 0x1f)
+ {
+ case EMBED_Y:
+ option_sayas = value;
+ break;
+
+ case EMBED_F:
+ option_emphasis = value;
+ break;
+
+ case EMBED_B:
+ // break command
+ if(value == 0)
+ pre_pause = 0; // break=none
+ else
+ pre_pause += value;
+ break;
+ }
+ } while(((embedded_cmd & 0x80) == 0) && (embedded_read < embedded_ix));
+} // end of Word_EmbeddedCmd
+
+
int SetTranslator2(const char *new_language)
{//=========================================
// Set translator2 to a second language
int new_phoneme_tab;
+ const char *new_phtab_name;
+ int bitmap;
+ int dialect = 0;
- if((new_phoneme_tab = SelectPhonemeTableName(new_language)) >= 0)
+ new_phtab_name = new_language;
+ if((bitmap = translator->langopts.dict_dialect) != 0)
+ {
+ if((bitmap & (1 << DICTDIALECT_EN_US)) && (strcmp(new_language, "en") == 0))
+ {
+ new_phtab_name = "en-us";
+ dialect = DICTDIALECT_EN_US;
+ }
+ if((bitmap & (1 << DICTDIALECT_ES_LA)) && (strcmp(new_language, "es") == 0))
+ {
+ new_phtab_name = "es-la";
+ dialect = DICTDIALECT_ES_LA;
+ }
+ }
+
+ if((new_phoneme_tab = SelectPhonemeTableName(new_phtab_name)) >= 0)
{
if((translator2 != NULL) && (strcmp(new_language,translator2_language) != 0))
{
@@ -1255,14 +1747,30 @@ int SetTranslator2(const char *new_language)
translator2 = SelectTranslator(new_language);
strcpy(translator2_language,new_language);
- if(LoadDictionary(translator2, new_language, 0) != 0)
+ if(LoadDictionary(translator2, translator2->dictionary_name, 0) != 0)
{
SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
new_phoneme_tab = -1;
translator2_language[0] = 0;
}
+ else
+ {
+ if(dialect == DICTDIALECT_EN_US)
+ {
+ // en-us
+ translator2->dict_condition = 0x48; // bits 3, 6
+ translator2->langopts.param[LOPT_REDUCE_T] = 1;
+ }
+ if(dialect == DICTDIALECT_ES_LA)
+ {
+ translator2->dict_condition = 0x04; // bit 2
+ }
+ }
+ translator2->phoneme_tab_ix = new_phoneme_tab;
}
}
+ if(translator2 != NULL)
+ translator2->phonemes_repeat[0] = 0;
return(new_phoneme_tab);
} // end of SetTranslator2
@@ -1276,8 +1784,6 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
int next_tone=0;
unsigned char *p;
int srcix;
- int embedded_cmd;
- int value;
int found_dict_flag;
unsigned char ph_code;
PHONEME_LIST2 *plist2;
@@ -1293,10 +1799,23 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
int ix;
int sylimit; // max. number of syllables in a word to be combined with a preceding preposition
const char *new_language;
- unsigned char bad_phoneme[4];
+ int bad_phoneme;
int word_flags;
int word_copy_len;
char word_copy[N_WORD_BYTES+1];
+ char word_replaced[N_WORD_BYTES+1];
+ char old_dictionary_name[40];
+
+ if((f_logespeak != NULL) && (logging_type & 8))
+ {
+ fprintf(f_logespeak,"WORD: flg=%.5x len=%d '",wtab->flags,wtab->length);
+ for(ix=0; ix<40; ix++)
+ {
+ if(word[ix]==0) break;
+ fputc(word[ix], f_logespeak);
+ }
+ fprintf(f_logespeak,"'\n");
+ }
len = wtab->length;
if(len > 31) len = 31;
@@ -1305,37 +1824,26 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
word_flags = wtab[0].flags;
if(word_flags & FLAG_EMBEDDED)
{
+ wtab[0].flags &= ~FLAG_EMBEDDED; // clear it in case we call TranslateWord2() again for the same word
embedded_flag = SFLAG_EMBEDDED;
- do
- {
- embedded_cmd = embedded_list[embedded_read++];
- value = embedded_cmd >> 8;
-
- switch(embedded_cmd & 0x1f)
- {
- case EMBED_Y:
- option_sayas = value;
- break;
-
- case EMBED_F:
- option_emphasis = value;
- break;
-
- case EMBED_B:
- // break command
- if(value == 0)
- pre_pause = 0; // break=none
- else
- pre_pause += value;
- break;
- }
- } while((embedded_cmd & 0x80) == 0);
+ Word_EmbeddedCmd();
}
- if(word[0] == 0)
+ if((word[0] == 0) || (word_flags & FLAG_DELETE_WORD))
{
- // nothing to translate
+ // nothing to translate. Add a dummy phoneme to carry any embedded commands
+ if(embedded_flag)
+ {
+ ph_list2[n_ph_list2].phcode = phonEND_WORD;
+ ph_list2[n_ph_list2].stresslevel = 0;
+ ph_list2[n_ph_list2].wordstress = 0;
+ ph_list2[n_ph_list2].tone_ph = 0;
+ ph_list2[n_ph_list2].synthflags = embedded_flag;
+ ph_list2[n_ph_list2].sourceix = 0;
+ n_ph_list2++;
+ embedded_flag = 0;
+ }
word_phonemes[0] = 0;
return(0);
}
@@ -1397,7 +1905,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
}
else
{
- EncodePhonemes(word,word_phonemes,bad_phoneme);
+ EncodePhonemes(word,word_phonemes,&bad_phoneme);
}
flags = FLAG_FOUND;
}
@@ -1408,7 +1916,8 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
while(((c2 = word_copy[ix] = word[ix]) != ' ') && (c2 != 0) && (ix < N_WORD_BYTES)) ix++;
word_copy_len = ix;
- flags = TranslateWord(translator, word, next_pause, wtab);
+ word_replaced[2] = 0;
+ flags = TranslateWord(translator, word, next_pause, wtab, &word_replaced[2]);
if(flags & FLAG_SPELLWORD)
{
@@ -1417,86 +1926,116 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
return(flags);
}
- if((flags & FLAG_ALT2_TRANS) && ((sylimit = tr->langopts.param[LOPT_COMBINE_WORDS]) > 0))
+ if((flags & FLAG_COMBINE) && !(wtab[1].flags & FLAG_PHONEMES))
{
char *p2;
int ok = 1;
- int flags2;
+ unsigned int flags2[2];
int c_word2;
char ph_buf[N_WORD_PHONEMES];
+ flags2[0] = 0;
+ sylimit = tr->langopts.param[LOPT_COMBINE_WORDS];
+
// LANG=cs,sk
// combine a preposition with the following word
p2 = word;
while(*p2 != ' ') p2++;
utf8_in(&c_word2, p2+1); // first character of the next word;
- if(!iswalpha(c_word2))
+ if(!iswalpha2(c_word2))
{
ok =0;
}
if(ok != 0)
{
+ strcpy(ph_buf,word_phonemes);
+
+ flags2[0] = TranslateWord(translator, p2+1, 0, wtab+1, NULL);
+ if((flags2[0] & FLAG_WAS_UNPRONOUNCABLE) || (word_phonemes[0] == phonSWITCH))
+ ok = 0;
+
if(sylimit & 0x100)
{
// only if the second word has $alt attribute
- strcpy(ph_buf,word_phonemes);
- flags2 = TranslateWord(translator, p2+1, 0, wtab+1);
- if((flags2 & FLAG_ALT_TRANS) == 0)
+ if((flags2[0] & FLAG_ALT_TRANS) == 0)
{
ok = 0;
- strcpy(word_phonemes,ph_buf);
}
}
-
+
if((sylimit & 0x200) && ((wtab+1)->flags & FLAG_LAST_WORD))
{
// not if the next word is end-of-sentence
ok = 0;
}
+
+ if(ok == 0)
+ {
+ strcpy(word_phonemes,ph_buf);
+ }
}
if(ok)
{
*p2 = '-'; // replace next space by hyphen
- flags = TranslateWord(translator, word, next_pause, wtab); // translate the combined word
- if(CountSyllables(p) > (sylimit & 0xf))
+ wtab[0].flags &= ~FLAG_ALL_UPPER; // prevent it being considered an abbreviation
+ flags = TranslateWord(translator, word, next_pause, wtab, NULL); // translate the combined word
+ if((sylimit > 0) && (CountSyllables(p) > (sylimit & 0x1f)))
{
// revert to separate words
*p2 = ' ';
- flags = TranslateWord(translator, word, next_pause, wtab);
+ flags = TranslateWord(translator, word, next_pause, wtab, NULL);
}
else
{
+ if(flags == 0)
+ flags = flags2[0]; // no flags for the combined word, so use flags from the second word eg. lang-hu "nem december 7-e"
flags |= FLAG_SKIPWORDS;
dictionary_skipwords = 1;
}
}
}
- if(p[0] == phonSWITCH)
+ if(p[0]==phonSWITCH)
{
- // this word uses a different language
- memcpy(word, word_copy, word_copy_len);
+ int switch_attempt;
+ strcpy(old_dictionary_name, dictionary_name);
+ for(switch_attempt=0; switch_attempt < 2; switch_attempt++)
+ {
+ // this word uses a different language
+ memcpy(word, word_copy, word_copy_len);
- new_language = (char *)(&p[1]);
- if(new_language[0]==0)
- new_language = "en";
+ new_language = (char *)(&p[1]);
+ if(new_language[0]==0)
+ new_language = "en";
- switch_phonemes = SetTranslator2(new_language);
+ switch_phonemes = SetTranslator2(new_language);
- if(switch_phonemes >= 0)
- {
- // re-translate the word using the new translator
- flags = TranslateWord(translator2, word, next_pause, wtab);
-// strcpy((char *)p,translator2->word_phonemes);
- if(p[0] == phonSWITCH)
+ if(switch_phonemes >= 0)
{
- // the second translator doesn't want to process this word
- switch_phonemes = -1;
+ // re-translate the word using the new translator
+ wtab[0].flags |= FLAG_TRANSLATOR2;
+ if(word_replaced[2] != 0)
+ {
+ word_replaced[0] = 0; // byte before the start of the word
+ word_replaced[1] = ' ';
+ flags = TranslateWord(translator2, &word_replaced[1], next_pause, wtab, NULL);
+ }
+ else
+ flags = TranslateWord(translator2, word, next_pause, wtab, &word_replaced[2]);
}
+
+ if(p[0] != phonSWITCH)
+ break;
}
+
+ // strcpy((char *)p,translator2->word_phonemes);
+
+ if(p[0] == phonSWITCH)
+ return(FLAG_SPELLWORD);
+
if(switch_phonemes < 0)
{
// language code is not recognised or 2nd translator won't translate it
@@ -1504,6 +2043,24 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
p[1] = phonSCHWA;
p[2] = 0;
}
+
+// ?? Option to convert from language2 phonemes to the equivalent language1 phonemes
+// ?? Option to set the word-stress according to language1 rules eg. lang=fr)
+ if(ChangeEquivalentPhonemes(tr, switch_phonemes, (char *)p))
+ {
+ // Phonemes have been converted from the foreign language to the native language
+ switch_phonemes = -1;
+ }
+
+ if(switch_phonemes == -1)
+ {
+ strcpy(dictionary_name, old_dictionary_name);
+ SelectPhonemeTable(voice->phoneme_tab_ix);
+
+ // leave switch_phonemes set, but use the original phoneme table number.
+ // This will suppress LOPT_REGRESSIVE_VOICING
+ switch_phonemes = voice->phoneme_tab_ix; // original phoneme table
+ }
}
if(!(word_flags & FLAG_HYPHEN))
@@ -1513,7 +2070,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
if(pre_pause < 1)
pre_pause = 1;
}
- if((flags & FLAG_PREPAUSE) && ((word_flags && FLAG_LAST_WORD) == 0) && (tr->prepause_timeout == 0))
+ if((flags & FLAG_PREPAUSE) && !(word_flags && (FLAG_LAST_WORD | FLAG_FIRST_WORD)) && !(wtab[-1].flags & FLAG_FIRST_WORD) && (tr->prepause_timeout == 0))
{
// the word is marked in the dictionary list with $pause
if(pre_pause < 4) pre_pause = 4;
@@ -1525,14 +2082,13 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
pre_pause = 1;
}
- plist2 = &ph_list2[n_ph_list2];
stress = 0;
- next_stress = 0;
+ next_stress = 1;
srcix = 0;
max_stress = -1;
found_dict_flag = 0;
- if(flags & FLAG_FOUND)
+ if((flags & FLAG_FOUND) && !(flags & FLAG_TEXTMODE))
found_dict_flag = SFLAG_DICTIONARY;
while((pre_pause > 0) && (n_ph_list2 < N_PHONEME_LIST-4))
@@ -1550,8 +2106,10 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
pre_pause--;
}
tr->end_stressed_vowel = 0; // forget about the previous word
- tr->prev_dict_flags = 0;
+ tr->prev_dict_flags[0] = 0;
+ tr->prev_dict_flags[1] = 0;
}
+ plist2 = &ph_list2[n_ph_list2];
if((option_capitals==1) && (word_flags & FLAG_FIRST_UPPER))
{
@@ -1567,15 +2125,42 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
if(switch_phonemes >= 0)
{
- // this word uses a different phoneme table
- SetPlist2(&ph_list2[n_ph_list2],phonSWITCH);
- ph_list2[n_ph_list2++].tone_number = switch_phonemes; // temporary phoneme table number
+ if((p[0] == phonPAUSE) && (p[1] == phonSWITCH))
+ {
+ // the new word starts with a phoneme table switch, so there's no need to switch before it.
+ if(ph_list2[n_ph_list2-1].phcode == phonSWITCH)
+ {
+ //previous phoneme is also a phonSWITCH, delete it
+ n_ph_list2--;
+ }
+ }
+ else
+ {
+ // this word uses a different phoneme table
+ if(ph_list2[n_ph_list2-1].phcode == phonSWITCH)
+ {
+ //previous phoneme is also a phonSWITCH, just change its phoneme table number
+ n_ph_list2--;
+ }
+ else
+ {
+ SetPlist2(&ph_list2[n_ph_list2],phonSWITCH);
+ }
+ ph_list2[n_ph_list2++].tone_ph = switch_phonemes; // temporary phoneme table number
+ }
}
// remove initial pause from a word if it follows a hyphen
if((word_flags & FLAG_HYPHEN) && (phoneme_tab[*p]->type == phPAUSE))
p++;
+ if((p[0] == 0) && (embedded_flag))
+ {
+ // no phonemes. Insert a very short pause to carry an embedded command
+ p[0] = phonPAUSE_VSHORT;
+ p[1] = 0;
+ }
+
while(((ph_code = *p++) != 0) && (n_ph_list2 < N_PHONEME_LIST-4))
{
if(ph_code == 255)
@@ -1588,23 +2173,24 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
{
ph_list2[n_ph_list2].phcode = ph_code;
ph_list2[n_ph_list2].sourceix = 0;
- ph_list2[n_ph_list2].synthflags = embedded_flag;
- ph_list2[n_ph_list2++].tone_number = *p++;
+ ph_list2[n_ph_list2].synthflags = 0;
+ ph_list2[n_ph_list2++].tone_ph = *p;
+ SelectPhonemeTable(*p);
+ p++;
}
- else
- if(ph->type == phSTRESS)
+ else if(ph->type == phSTRESS)
{
// don't add stress phonemes codes to the list, but give their stress
// value to the next vowel phoneme
// std_length is used to hold stress number or (if >10) a tone number for a tone language
- if(ph->spect == 0)
+ if(ph->program == 0)
next_stress = ph->std_length;
else
{
// for tone languages, the tone number for a syllable follows the vowel
if(prev_vowel >= 0)
{
- ph_list2[prev_vowel].tone_number = ph_code;
+ ph_list2[prev_vowel].tone_ph = ph_code;
}
else
{
@@ -1612,31 +2198,27 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
}
}
}
- else
- if(ph_code == phonSYLLABIC)
+ else if(ph_code == phonSYLLABIC)
{
// mark the previous phoneme as a syllabic consonant
prev_vowel = n_ph_list2-1;
ph_list2[prev_vowel].synthflags |= SFLAG_SYLLABLE;
- ph_list2[prev_vowel].stress = next_stress;
+ ph_list2[prev_vowel].stresslevel = next_stress;
}
- else
- if(ph_code == phonLENGTHEN)
+ else if(ph_code == phonLENGTHEN)
{
ph_list2[n_ph_list2-1].synthflags |= SFLAG_LENGTHEN;
}
- else
- if(ph_code == phonEND_WORD)
+ else if(ph_code == phonEND_WORD)
{
// a || symbol in a phoneme string was used to indicate a word boundary
// Don't add this phoneme to the list, but make sure the next phoneme has
// a newword indication
srcix = source_ix+1;
}
- else
- if(ph_code == phonX1)
+ else if(ph_code == phonX1)
{
- // a language specific action
+ // a language specific action
if(tr->langopts.param[LOPT_IT_DOUBLING])
{
flags |= FLAG_DOUBLING;
@@ -1645,7 +2227,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
else
{
ph_list2[n_ph_list2].phcode = ph_code;
- ph_list2[n_ph_list2].tone_number = 0;
+ ph_list2[n_ph_list2].tone_ph = 0;
ph_list2[n_ph_list2].synthflags = embedded_flag | found_dict_flag;
embedded_flag = 0;
ph_list2[n_ph_list2].sourceix = srcix;
@@ -1654,10 +2236,15 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
if(ph->type == phVOWEL)
{
stress = next_stress;
- next_stress = 0;
+ next_stress = 1; // default is 'unstressed'
+
+ if(stress >= 4)
+ {
+ any_stressed_words = 1;
+ }
if((prev_vowel >= 0) && (n_ph_list2-1) != prev_vowel)
- ph_list2[n_ph_list2-1].stress = stress; // set stress for previous consonant
+ ph_list2[n_ph_list2-1].stresslevel = stress; // set stress for previous consonant
ph_list2[n_ph_list2].synthflags |= SFLAG_SYLLABLE;
prev_vowel = n_ph_list2;
@@ -1669,7 +2256,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
}
if(next_tone != 0)
{
- ph_list2[n_ph_list2].tone_number = next_tone;
+ ph_list2[n_ph_list2].tone_ph = next_tone;
next_tone=0;
}
}
@@ -1677,8 +2264,8 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
{
if(first_phoneme && tr->langopts.param[LOPT_IT_DOUBLING])
{
- if(((tr->prev_dict_flags & FLAG_DOUBLING) && (tr->langopts.param[LOPT_IT_DOUBLING] & 1)) ||
- (tr->end_stressed_vowel && (tr->langopts.param[LOPT_IT_DOUBLING] & 2)))
+ if(((tr->prev_dict_flags[0] & FLAG_DOUBLING) && (tr->langopts.param[LOPT_IT_DOUBLING] & 1)) ||
+ (tr->end_stressed_vowel && (tr->langopts.param[LOPT_IT_DOUBLING] & 2)))
{
// italian, double the initial consonant if the previous word ends with a
// stressed vowel, or is marked with a flag
@@ -1687,11 +2274,17 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
}
}
- ph_list2[n_ph_list2].stress = stress;
+ ph_list2[n_ph_list2].stresslevel = stress;
n_ph_list2++;
first_phoneme = 0;
}
}
+
+ if(word_flags & FLAG_COMMA_AFTER)
+ {
+ SetPlist2(&ph_list2[n_ph_list2++],phonPAUSE_CLAUSE);
+ }
+
// don't set new-word if there is a hyphen before it
if((word_flags & FLAG_HYPHEN) == 0)
{
@@ -1707,9 +2300,10 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
if(switch_phonemes >= 0)
{
// this word uses a different phoneme table, now switch back
+ strcpy(dictionary_name, old_dictionary_name);
SelectPhonemeTable(voice->phoneme_tab_ix);
SetPlist2(&ph_list2[n_ph_list2],phonSWITCH);
- ph_list2[n_ph_list2++].tone_number = voice->phoneme_tab_ix; // original phoneme table number
+ ph_list2[n_ph_list2++].tone_ph = voice->phoneme_tab_ix; // original phoneme table number
}
@@ -1726,14 +2320,14 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
ph_list2[max_stress_ix].synthflags |= SFLAG_PROMOTE_STRESS;
}
- tr->prev_dict_flags = flags;
+ tr->prev_dict_flags[0] = flags;
return(flags);
} // end of TranslateWord2
-static int EmbeddedCommand(unsigned int *source_index)
-{//===================================================
+static int EmbeddedCommand(unsigned int *source_index_out)
+{//=======================================================
// An embedded command to change the pitch, volume, etc.
// returns number of commands added to embedded_list
@@ -1744,28 +2338,28 @@ static int EmbeddedCommand(unsigned int *source_index)
unsigned char c;
char *p;
int cmd;
+ int source_index = *source_index_out;
- c = source[*source_index];
+ c = source[source_index];
if(c == '+')
{
sign = 0x40;
- (*source_index)++;
+ source_index++;
}
- else
- if(c == '-')
+ else if(c == '-')
{
sign = 0x60;
- (*source_index)++;
+ source_index++;
}
- if(isdigit(source[*source_index]))
+ if(IsDigit09(source[source_index]))
{
- value = atoi(&source[*source_index]);
- while(isdigit(source[*source_index]))
+ value = atoi(&source[source_index]);
+ while(IsDigit09(source[source_index]))
source_index++;
}
- c = source[(*source_index)++];
+ c = source[source_index++];
if(embedded_ix >= (N_EMBEDDED_LIST - 2))
return(0); // list is full
@@ -1792,12 +2386,13 @@ static int EmbeddedCommand(unsigned int *source_index)
}
embedded_list[embedded_ix++] = cmd + sign + (value << 8);
+ *source_index_out = source_index;
return(1);
} // end of EmbeddedCommand
-static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, int *insert)
+static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, int *insert, int *wordflags)
{//=========================================================================================
int ix;
unsigned int word;
@@ -1818,9 +2413,9 @@ static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in,
// there is a list of character codes to be substituted with alternative codes
- if(iswupper(c_lower = c))
+ if(iswupper2(c_lower = c))
{
- c_lower = towlower(c);
+ c_lower = towlower2(c);
upper_case = 1;
}
@@ -1834,7 +2429,7 @@ static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in,
new_c = replace_chars[ix+1];
break;
}
- if((word >> 16) == (unsigned int)towlower(next_in))
+ if((word >> 16) == (unsigned int)towlower2(next_in))
{
new_c = replace_chars[ix+1];
ignore_next = 1;
@@ -1851,20 +2446,22 @@ static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in,
// there is a second character to be inserted
// don't convert the case of the second character unless the next letter is also upper case
c2 = new_c >> 16;
- if(upper_case && iswupper(next_in))
- c2 = towupper(c2);
+ if(upper_case && iswupper2(next_in))
+ c2 = towupper2(c2);
*insert = c2;
new_c &= 0xffff;
}
if(upper_case)
- new_c = towupper(new_c);
+ new_c = towupper2(new_c);
+
+ *wordflags |= FLAG_CHAR_REPLACED;
return(new_c);
}
-static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert)
+static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert, int *wordflags)
{//================================================================================================================
// To allow language specific examination and replacement of characters
@@ -1875,64 +2472,101 @@ static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c,
int next2;
static const unsigned char hangul_compatibility[0x34] = {
- 0, 0x00,0x01,0xaa,0x02,0xac,0xad,0x03,
- 0x04,0x05,0xb0,0xb1,0xb2,0xb3,0xb4,0xb4,
- 0xb6,0x06,0x07,0x08,0xb9,0x09,0x0a,0xbc,
- 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x61,
- 0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,
- 0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,
- 0x72,0x73,0x74,0x75 };
+ 0, 0x00,0x01,0xaa,0x02,0xac,0xad,0x03,
+ 0x04,0x05,0xb0,0xb1,0xb2,0xb3,0xb4,0xb4,
+ 0xb6,0x06,0x07,0x08,0xb9,0x09,0x0a,0xbc,
+ 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x61,
+ 0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,
+ 0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,
+ 0x72,0x73,0x74,0x75
+ };
+
+ // check for Korean Hangul letters
+ if(((code = c - 0xac00) >= 0) && (c <= 0xd7af))
+ {
+ // break a syllable hangul into 2 or 3 individual jamo
+ initial = (code/28)/21;
+ medial = (code/28) % 21;
+ final = code % 28;
+
+ if(initial == 11)
+ {
+ // null initial
+ c = medial + 0x1161;
+ if(final > 0)
+ *insert = final + 0x11a7;
+ }
+ else
+ {
+ // extact the initial and insert the remainder with a null initial
+ c = initial + 0x1100;
+ *insert = (11*28*21) + (medial*28) + final + 0xac00;
+ }
+ return(c);
+ }
+ else if(((code = c - 0x3130) >= 0) && (code < 0x34))
+ {
+ // Hangul compatibility jamo
+ return(hangul_compatibility[code] + 0x1100);
+ }
switch(tr->translator_name)
{
case L('a','f'):
- // look for 'n and replace by a special character (unicode: schwa)
+ case L('n','l'):
+ // look for 'n and replace by a special character (unicode: schwa)
- utf8_in(&next2, &ptr[1]);
- if(!iswalpha(prev_in))
+ if(!iswalpha2(prev_in))
{
- if((c == '\'') && (next_in == 'n') && IsSpace(next2))
+ utf8_in(&next2, &ptr[1]);
+
+ if((c == '\'') && IsSpace(next2))
{
- // n preceded by either apostrophe or U2019 "right single quotation mark"
- ptr[0] = ' '; // delete the n
- return(0x0259); // replace ' by unicode schwa character
+ if((next_in == 'n') && (tr->translator_name == L('a','f')))
+ {
+ // n preceded by either apostrophe or U2019 "right single quotation mark"
+ ptr[0] = ' '; // delete the n
+ return(0x0259); // replace ' by unicode schwa character
+ }
+ if((next_in == 'n') || (next_in == 't'))
+ {
+ // Dutch, [@n] and [@t]
+ return(0x0259); // replace ' by unicode schwa character
+ }
}
}
break;
+ }
+ return(SubstituteChar(tr, c, next_in, insert, wordflags));
+}
- case L('k','o'):
- if(((code = c - 0xac00) >= 0) && (c <= 0xd7af))
+
+static const char *UCase_ga[] = {"bp","bhf","dt","gc","hA","mb","nd","ng","ts","tA","nA",NULL};
+
+static int UpperCaseInWord(Translator *tr, char *word, int c)
+{//=====================================================
+ int ix;
+ int len;
+ const char *p;
+
+ if(tr->translator_name == L('g','a'))
+ {
+ // Irish
+ for(ix=0; ; ix++)
{
- // break a syllable hangul into 2 or 3 individual jamo
- initial = (code/28)/21;
- medial = (code/28) % 21;
- final = code % 28;
+ if((p = UCase_ga[ix]) == NULL)
+ break;
- if(initial == 11)
- {
- // null initial
- c = medial + 0x1161;
- if(final > 0)
- *insert = final + 0x11a7;
- }
- else
+ len = strlen(p);
+ if((word[-len]==' ') && (memcmp(&word[-len+1], p, len-1) == 0))
{
- // extact the initial and insert the remainder with a null initial
- c = initial + 0x1100;
- *insert = (11*28*21) + (medial*28) + final + 0xac00;
+ if((c == p[len-1]) || ((p[len-1]=='A') && IsVowel(tr, c)))
+ return(1);
}
- return(c);
}
- else
- if(((code = c - 0x3130) >= 0) && (code < 0x34))
- {
- // Hangul compatibility jamo
- return(hangul_compatibility[code] + 0x1100);
- }
- break;
}
- return(SubstituteChar(tr,c,next_in,insert));
+ return(0);
}
@@ -1943,11 +2577,13 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
int cc;
unsigned int source_index=0;
unsigned int prev_source_index=0;
+ int source_index_word=0;
int prev_in;
int prev_out=' ';
int prev_out2;
- int prev_in2=0;
+ int prev_in_save=0;
int next_in;
+ int next_in_nbytes;
int char_inserted=0;
int clause_pause;
int pre_pause_add=0;
@@ -1959,6 +2595,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
int dict_flags = 0; // returned from dictionary lookup
int word_flags; // set here
int next_word_flags;
+ int new_sentence2;
int embedded_count = 0;
int letter_count = 0;
int space_inserted = 0;
@@ -1972,6 +2609,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
short charix[N_TR_SOURCE+4];
WORD_TAB words[N_CLAUSE_WORDS];
+ static char voice_change_name[40];
int word_count=0; // index into words
char sbuf[N_TR_SOURCE];
@@ -1980,13 +2618,18 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
int tone;
int tone2;
+ if(tr==NULL)
+ {
+ return(NULL);
+ }
+
p_textinput = (unsigned char *)vp_input;
p_wchar_input = (wchar_t *)vp_input;
embedded_ix = 0;
embedded_read = 0;
- option_phoneme_input &= ~2; // clear bit 1 (temporary indication)
pre_pause = 0;
+ any_stressed_words = 0;
if((clause_start_char = count_characters) < 0)
clause_start_char = 0;
@@ -1994,14 +2637,27 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
for(ix=0; ix<N_TR_SOURCE; ix++)
charix[ix] = 0;
- terminator = ReadClause(tr, f_text, source, charix, &charix_top, N_TR_SOURCE, &tone2);
+ terminator = ReadClause(tr, f_text, source, charix, &charix_top, N_TR_SOURCE, &tone2, voice_change_name);
+
+ if((f_logespeak != NULL) && (logging_type & 4))
+ {
+ fprintf(f_logespeak,"CLAUSE %x:\n",terminator);
+ for(p=source; *p != 0; p++)
+ fputc(*p, f_logespeak);
+ fprintf(f_logespeak,"ENDCLAUSE\n");
+ fflush(f_logespeak);
+ }
+ p = source;
charix[charix_top+1] = 0;
charix[charix_top+2] = 0x7fff;
charix[charix_top+3] = 0;
clause_pause = (terminator & 0xfff) * 10; // mS
- tone = (terminator >> 12) & 0xf;
+ if(terminator & CLAUSE_PAUSE_LONG)
+ clause_pause = clause_pause * 32 ; // pause value is *320mS not *10mS
+
+ tone = (terminator >> 12) & 0x7;
if(tone2 != 0)
{
// override the tone type
@@ -2023,15 +2679,19 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
if(clause_pause < 0)
clause_pause = 0;
- terminator &= ~CLAUSE_BIT_SENTENCE; // clear sentence bit
+ if(new_sentence)
+ terminator |= CLAUSE_BIT_SENTENCE; // carry forward an end-of-sentence indicator
max_clause_pause += clause_pause;
+ new_sentence2 = 0;
}
else
{
max_clause_pause = clause_pause;
+ new_sentence2 = new_sentence;
}
+ tr->clause_terminator = terminator;
- if(new_sentence)
+ if(new_sentence2)
{
count_sentences++;
if(skip_sentences > 0)
@@ -2054,7 +2714,8 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
tr->expect_verb_s=0;
tr->phonemes_repeat_count = 0;
tr->end_stressed_vowel=0;
- tr->prev_dict_flags = 0;
+ tr->prev_dict_flags[0] = 0;
+ tr->prev_dict_flags[1] = 0;
word_count = 0;
single_quoted = 0;
@@ -2071,7 +2732,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
words[0].flags = 0;
finished = 0;
- for(j=0; charix[j]==0; j++);
+ for(j=0; charix[j]<=0; j++);
words[0].sourceix = charix[j];
k = 0;
while(charix[j] != 0)
@@ -2093,13 +2754,12 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
prev_out = 'a';
}
- if(prev_in2 != 0)
+ if(prev_in_save != 0)
{
- prev_in = prev_in2;
- prev_in2 = 0;
+ prev_in = prev_in_save;
+ prev_in_save = 0;
}
- else
- if(source_index > 0)
+ else if(source_index > 0)
{
utf8_in2(&prev_in,&source[source_index-1],1); // prev_in = source[source_index-1];
}
@@ -2116,7 +2776,13 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
source_index += utf8_in(&cc,&source[source_index]); // cc = source[source_index++];
c = cc;
}
- utf8_in(&next_in,&source[source_index]);
+ next_in_nbytes = utf8_in(&next_in,&source[source_index]);
+
+ if(c == 0)
+ {
+ finished = 1;
+ c = ' ';
+ }
if((c == CTRL_EMBEDDED) || (c == ctrl_embedded))
{
@@ -2126,13 +2792,13 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
if(prev_in != ' ')
{
c = ' ';
- prev_in2 = c;
+ prev_in_save = c;
source_index--;
}
else
{
embedded_count += EmbeddedCommand(&source_index);
- prev_in2 = prev_in;
+ prev_in_save = prev_in;
// replace the embedded command by spaces
memset(&source[srcix],' ',source_index-srcix);
source_index = srcix;
@@ -2140,15 +2806,14 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
}
}
- if(option_sayas2 == SAYAS_KEY)
+ if((option_sayas2 == SAYAS_KEY) && (c != ' '))
{
- if(((c == '_') || (c == '-')) && IsAlpha(prev_in))
- {
- c = ' ';
- }
+ if((prev_in == ' ') && (next_in == ' '))
+ option_sayas2 = SAYAS_SINGLE_CHARS; // single character, speak its name
c = towlower2(c);
}
+
if(phoneme_mode)
{
all_upper_case = FLAG_PHONEMES;
@@ -2160,8 +2825,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
c = ' ';
}
}
- else
- if((option_sayas2 & 0xf0) == SAYAS_DIGITS)
+ else if((option_sayas2 & 0xf0) == SAYAS_DIGITS)
{
if(iswdigit(c))
{
@@ -2184,8 +2848,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
}
}
}
- else
- if((option_sayas2 & 0x30) == 0)
+ else if((option_sayas2 & 0x10) == 0)
{
// speak as words
@@ -2199,9 +2862,9 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
#endif
if((c == 0x92) || (c == 0xb4) || (c == 0x2019) || (c == 0x2032))
- c = '\''; // 'microsoft' quote or sexed closing single quote, or prime - possibly used as apostrophe
+ c = '\''; // 'microsoft' quote or sexed closing single quote, or prime - possibly used as apostrophe
- if((c == '?') && IsAlpha(prev_out) && IsAlpha(next_in))
+ if(((c == 0x2018) || (c == '?')) && IsAlpha(prev_out) && IsAlpha(next_in))
{
// ? between two letters may be a smart-quote replaced by ?
c = '\'';
@@ -2214,7 +2877,13 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
word_flags |= FLAG_FOCUS;
}
- c = TranslateChar(tr, &source[source_index], prev_in,c, next_in, &char_inserted); // optional language specific function
+ if(c == CHAR_COMMA_BREAK)
+ {
+ c = ' ';
+ word_flags |= FLAG_COMMA_AFTER;
+ }
+
+ c = TranslateChar(tr, &source[source_index], prev_in,c, next_in, &char_inserted, &word_flags); // optional language specific function
if(c == 8)
continue; // ignore this character
@@ -2240,7 +2909,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
if(iswdigit(prev_out))
{
- if(!iswdigit(c) && (c != '.') && (c != ','))
+ if(!iswdigit(c) && (c != '.') && (c != ',') && (c != ' '))
{
c = ' '; // terminate digit string with a space
space_inserted = 1;
@@ -2254,19 +2923,17 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
}
- if((c == '[') && (next_in == '[') && option_phoneme_input)
+ if(c == '[')
{
- phoneme_mode = FLAG_PHONEMES;
- source_index++;
- continue;
+ if((next_in == '\002') || ((next_in == '[') && option_phoneme_input))
+ {
+ // "[\002" is used internally to start phoneme mode
+ phoneme_mode = FLAG_PHONEMES;
+ source_index++;
+ continue;
+ }
}
- if(c == 0)
- {
- finished = 1;
- c = ' ';
- }
- else
if(IsAlpha(c))
{
if(!IsAlpha(prev_out) || (tr->langopts.ideographs && ((c > 0x3040) || (prev_out > 0x3040))))
@@ -2279,10 +2946,15 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
// start of word, insert space if not one there already
c = ' ';
space_inserted = 1;
+
+ if(!IsBracket(prev_out)) // ?? perhaps only set FLAG_NOSPACE for . - / (hyphenated words, URLs, etc)
+ {
+ next_word_flags |= FLAG_NOSPACE;
+ }
}
else
{
- if(iswupper(c))
+ if(iswupper2(c))
word_flags |= FLAG_FIRST_UPPER;
if((prev_out == ' ') && iswdigit(sbuf[ix-2]) && !iswdigit(prev_in))
@@ -2295,9 +2967,29 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
}
- letter_count++;
+ if(c != ' ')
+ {
+ letter_count++;
+
+ if(tr->letter_bits_offset > 0)
+ {
+ if(((c < 0x250) && (prev_out >= tr->letter_bits_offset)) ||
+ ((c >= tr->letter_bits_offset) && (letter_count > 1) && (prev_out < 0x250)))
+ {
+ // Don't mix native and Latin characters in the same word
+ // Break into separate words
+ if(IsAlpha(prev_out))
+ {
+ c = ' ';
+ space_inserted = 1;
+ word_flags |= FLAG_HYPHEN_AFTER;
+ next_word_flags |= FLAG_HYPHEN;
+ }
+ }
+ }
+ }
- if(iswupper(c))
+ if(iswupper2(c))
{
c = towlower2(c);
@@ -2312,20 +3004,40 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
else
{
- if(iswlower(prev_in))
+ if(iswlower2(prev_in))
{
- c = ' '; // lower case followed by upper case, treat as new word
- space_inserted = 1;
- prev_in2 = c;
+ // lower case followed by upper case in a word
+ if(UpperCaseInWord(tr, &sbuf[ix], c) == 1)
+ {
+ // convert to lower case and continue
+ c = towlower2(c);
+ }
+ else
+ {
+ c = ' '; // lower case followed by upper case, treat as new word
+ space_inserted = 1;
+ prev_in_save = c;
+ // next_word_flags |= FLAG_NOSPACE; // problem: prevents FLAG_HAS_DOT being set
+ }
}
- else
- if((c != ' ') && iswupper(prev_in) && iswlower(next_in) &&
- (memcmp(&source[source_index],"s ",2) != 0)) // ENGLISH specific plural
+ else if((c != ' ') && iswupper2(prev_in) && iswlower2(next_in))
{
- c = ' '; // change from upper to lower case, start new word at the last uppercase
- space_inserted = 1;
- prev_in2 = c;
- next_word_flags |= FLAG_NOSPACE;
+ int next2_in;
+ utf8_in(&next2_in,&source[source_index + next_in_nbytes]);
+
+ if((tr->translator_name == L('n','l')) && (letter_count==2) && (c == 'j') && (prev_in == 'I'))
+ {
+ // Dutch words may capitalise initial IJ, don't split
+ }
+ else
+ if(IsAlpha(next2_in))
+ {
+ // changing from upper to lower case, start new word at the last uppercase, if 3 or more letters
+ c = ' ';
+ space_inserted = 1;
+ prev_in_save = c;
+ next_word_flags |= FLAG_NOSPACE;
+ }
}
}
}
@@ -2348,49 +3060,78 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
all_upper_case = 0;
}
}
- else
- if(c=='-')
+ else if(c=='-')
{
- if(IsAlpha(prev_in) && IsAlpha(next_in))
+ if(!IsSpace(prev_in) && IsAlpha(next_in))
{
- // '-' between two letters is a hyphen, treat as a space
- word_flags |= FLAG_HYPHEN;
- words[word_count-1].flags |= FLAG_HYPHEN_AFTER;
- c = ' ';
+ if(prev_out != ' ')
+ {
+ // previous 'word' not yet ended (not alpha or numeric), start new word now.
+ c = ' ';
+ space_inserted = 1;
+ }
+ else
+ {
+ // '-' between two letters is a hyphen, treat as a space
+ word_flags |= FLAG_HYPHEN;
+ if(word_count > 0)
+ words[word_count-1].flags |= FLAG_HYPHEN_AFTER;
+ c = ' ';
+ }
}
- else
- if((prev_in==' ') && (next_in==' '))
+ else if((prev_in==' ') && (next_in==' '))
{
// ' - ' dash between two spaces, treat as pause
c = ' ';
pre_pause_add = 4;
}
- else
- if(next_in=='-')
+ else if(next_in=='-')
{
// double hyphen, treat as pause
source_index++;
c = ' ';
pre_pause_add = 4;
}
- else
- if((prev_out == ' ') && IsAlpha(sbuf[ix-2]) && !IsAlpha(prev_in))
+ else if((prev_out == ' ') && IsAlpha(prev_out2) && !IsAlpha(prev_in))
{
// insert extra space between a word + space + hyphen, to distinguish 'a -2' from 'a-2'
sbuf[ix++] = ' ';
words[word_count].start++;
}
}
- else
- if(c == '\'')
+ else if(c == '.')
{
- if(iswalnum(prev_in) && IsAlpha(next_in))
+ if(prev_out == '.')
+ {
+ // multiple dots, separate by spaces. Note >3 dots has been replaced by elipsis
+ c = ' ';
+ space_inserted = 1;
+ }
+ else if((word_count > 0) && !(words[word_count-1].flags & FLAG_NOSPACE) && IsAlpha(prev_in))
{
- // between two letters, consider apostrophe as part of the word
+ // dot after a word, with space following, probably an abbreviation
+ words[word_count-1].flags |= FLAG_HAS_DOT;
+
+ if(IsSpace(next_in) || (next_in == '-'))
+ c = ' '; // remove the dot if it's followed by a space or hyphen, so that it's not pronounced
+ }
+ }
+ else if(c == '\'')
+ {
+ if(((prev_in == '.') || iswalnum(prev_in)) && IsAlpha(next_in))
+ {
+ // between two letters, or in an abbreviation (eg. u.s.a.'s). Consider the apostrophe as part of the word
single_quoted = 0;
}
- else
- if((wcschr(tr->char_plus_apostrophe,prev_in) != 0) && (prev_out2 == ' '))
+ else if((tr->langopts.param[LOPT_APOSTROPHE] & 1) && IsAlpha(next_in))
+ {
+ single_quoted = 0; // apostrophe at start of word is part of the word
+ }
+ else if((tr->langopts.param[LOPT_APOSTROPHE] & 2) && IsAlpha(prev_in))
+ {
+ single_quoted = 0; // apostrophe at end of word is part of the word
+ }
+ else if((wcschr(tr->char_plus_apostrophe,prev_in) != 0) && (prev_out2 == ' '))
{
// consider single character plus apostrophe as a word
single_quoted = 0;
@@ -2421,62 +3162,76 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
else
#ifdef deleted
// Brackets are now recognised in TranslateRules()
- if(IsBracket(c))
- {
- pre_pause_add = 4;
- c = ' ';
- }
- else
-#endif
- if(lookupwchar(breaks,c) != 0)
- {
- c = ' '; // various characters to treat as space
- }
- else
- if(iswdigit(c))
- {
- if(tr->langopts.tone_numbers && IsAlpha(prev_out) && !IsDigit(next_in))
+ if(IsBracket(c))
{
+ pre_pause_add = 4;
+ c = ' ';
}
else
- if((prev_out != ' ') && !iswdigit(prev_out))
- {
- if((prev_out != tr->langopts.decimal_sep) || ((decimal_sep_count > 0) && (tr->langopts.decimal_sep == ',')))
+#endif
+ if(lookupwchar(breaks,c) != 0)
{
- c = ' ';
- space_inserted = 1;
+ c = ' '; // various characters to treat as space
}
- else
+ else if(iswdigit(c))
{
- decimal_sep_count = 1;
+ if(tr->langopts.tone_numbers && IsAlpha(prev_out) && !IsDigit(next_in))
+ {
+ }
+ else if((prev_out != ' ') && !iswdigit(prev_out))
+ {
+ if((prev_out != tr->langopts.decimal_sep) || ((decimal_sep_count > 0) && (tr->langopts.decimal_sep == ',')))
+ {
+ c = ' ';
+ space_inserted = 1;
+ }
+ else
+ {
+ decimal_sep_count = 1;
+ }
+ }
+ else if((prev_out == ' ') && IsAlpha(prev_out2) && !IsAlpha(prev_in))
+ {
+ // insert extra space between a word and a number, to distinguish 'a 2' from 'a2'
+ sbuf[ix++] = ' ';
+ words[word_count].start++;
+ }
}
- }
- else
- if((prev_out == ' ') && IsAlpha(sbuf[ix-2]) && !IsAlpha(prev_in))
- {
- // insert extra space between a word and a number, to distinguish 'a 2' from 'a2'
- sbuf[ix++] = ' ';
- words[word_count].start++;
- }
- }
}
if(IsSpace(c))
{
if(prev_out == ' ')
{
+ word_flags |= FLAG_MULTIPLE_SPACES;
continue; // multiple spaces
}
+ if((cc == 0x09) || (cc == 0x0a))
+ {
+ next_word_flags |= FLAG_MULTIPLE_SPACES; // tab or newline, not a simple space
+ }
+
if(space_inserted)
{
- words[word_count].length = source_index - words[word_count].sourceix;
+ // count the number of characters since the start of the word
+ j = 0;
+ k = source_index - 1;
+ while((k >= source_index_word) && (charix[k] != 0))
+ {
+ if(charix[k] > 0) // don't count initial bytes of multi-byte character
+ j++;
+ k--;
+ }
+ words[word_count].length = j;
}
+ source_index_word = source_index;
+
// end of 'word'
sbuf[ix++] = ' ';
- if((ix > words[word_count].start) && (word_count < N_CLAUSE_WORDS-1))
+ if((word_count < N_CLAUSE_WORDS-1) && (ix > words[word_count].start))
{
if(embedded_count > 0)
{
@@ -2533,7 +3288,8 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
else
{
- ix += utf8_out(c,&sbuf[ix]); // sbuf[ix++] = c;
+ if((ix < (N_TR_SOURCE - 4)))
+ ix += utf8_out(c,&sbuf[ix]); // sbuf[ix++] = c;
}
if(pre_pause_add > pre_pause)
pre_pause = pre_pause_add;
@@ -2543,7 +3299,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
if((word_count==0) && (embedded_count > 0))
{
// add a null 'word' to carry the embedded command flag
- embedded_list[embedded_ix-1] |= 0x80;
+ embedded_list[embedded_ix-1] |= 0x80;
words[word_count].flags |= FLAG_EMBEDDED;
word_count = 1;
}
@@ -2553,20 +3309,28 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
words[0].pre_pause = 0; // don't add extra pause at beginning of clause
words[word_count].pre_pause = 8;
if(word_count > 0)
- words[word_count-1].flags |= FLAG_LAST_WORD;
+ {
+ ix = word_count-1;
+ while((ix > 0) && (IsBracket(sbuf[words[ix].start])))
+ ix--; // the last word is a bracket, mark the previous word as last
+ words[ix].flags |= FLAG_LAST_WORD;
+
+ // FLAG_NOSPACE check to avoid recognizing .mr -mr
+ if((terminator & CLAUSE_DOT) && !(words[word_count-1].flags & FLAG_NOSPACE))
+ words[word_count-1].flags |= FLAG_HAS_DOT;
+ }
words[0].flags |= FLAG_FIRST_WORD;
- for(ix=0; ix<word_count; ix++)
+
+ for(ix=0; ix < word_count; ix++)
{
int nx;
int c_temp;
char *pn;
char *pw;
- static unsigned int break_numbers1 = 0x49249248;
- static unsigned int break_numbers2 = 0x24924aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
- static unsigned int break_numbers3 = 0x49249268; // for languages which have numbers for 100,000 and 1,000,000
- unsigned int break_numbers;
- char number_buf[80];
+ int nw;
+ char number_buf[150];
+ WORD_TAB num_wtab[50]; // copy of 'words', when splitting numbers into parts
// start speaking at a specified word position in the text?
count_words++;
@@ -2579,22 +3343,23 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
if(skipping_text)
continue;
+ current_alphabet = NULL;
// digits should have been converted to Latin alphabet ('0' to '9')
word = pw = &sbuf[words[ix].start];
- if(iswdigit(word[0]) && (tr->langopts.numbers2 & NUM2_100000))
+ if(iswdigit(word[0]) && (tr->langopts.break_numbers != BREAK_THOUSANDS))
{
// Languages with 100000 numbers. Remove thousands separators so that we can insert them again later
pn = number_buf;
- while(pn < &number_buf[sizeof(number_buf)-3])
+ while(pn < &number_buf[sizeof(number_buf)-20])
{
if(iswdigit(*pw))
{
*pn++ = *pw++;
}
- else
- if((*pw == tr->langopts.thousands_sep) && (pw[1] == ' ') && iswdigit(pw[2]))
+ else if((*pw == tr->langopts.thousands_sep) && (pw[1] == ' ')
+ && iswdigit(pw[2]) && (pw[3] != ' ') && (pw[4] != ' ')) // don't allow only 1 or 2 digits in the final part
{
pw += 2;
ix++; // skip "word"
@@ -2613,65 +3378,75 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
for(n_digits=0; iswdigit(word[n_digits]); n_digits++); // count consecutive digits
- if((n_digits > 4) && (word[0] != '0'))
+ if(n_digits > 4)
{
// word is entirely digits, insert commas and break into 3 digit "words"
number_buf[0] = ' ';
pn = &number_buf[1];
nx = n_digits;
+ nw = 0;
- if((tr->langopts.numbers2 & NUM2_100000a) == NUM2_100000a)
- break_numbers = break_numbers3;
- else
- if(tr->langopts.numbers2 & NUM2_100000)
- break_numbers = break_numbers2;
- else
- break_numbers = break_numbers1;
+ if((n_digits > tr->langopts.max_digits) || (word[0] == '0'))
+ words[ix].flags |= FLAG_INDIVIDUAL_DIGITS;
- while(pn < &number_buf[sizeof(number_buf)-3])
+ while(pn < &number_buf[sizeof(number_buf)-20])
{
- if(!isdigit(c = *pw++) && (c != tr->langopts.decimal_sep))
+ if(!IsDigit09(c = *pw++) && (c != tr->langopts.decimal_sep))
break;
*pn++ = c;
- if((--nx > 0) && (break_numbers & (1 << nx)))
+ nx--;
+ if((nx > 0) && (tr->langopts.break_numbers & (1 << nx)))
{
+ memcpy(&num_wtab[nw++], &words[ix], sizeof(WORD_TAB)); // copy the 'words' entry for each word of numbers
+
if(tr->langopts.thousands_sep != ' ')
{
*pn++ = tr->langopts.thousands_sep;
}
*pn++ = ' ';
- if(break_numbers & (1 << (nx-1)))
- {
- // the next group only has 1 digits (i.e. NUM2_10000), make it three
- *pn++ = '0';
- *pn++ = '0';
- }
- if(break_numbers & (1 << (nx-2)))
+
+ if((words[ix].flags & FLAG_INDIVIDUAL_DIGITS) == 0)
{
- // the next group only has 2 digits (i.e. NUM2_10000), make it three
- *pn++ = '0';
+ if(tr->langopts.break_numbers & (1 << (nx-1)))
+ {
+ // the next group only has 1 digits, make it three
+ *pn++ = '0';
+ *pn++ = '0';
+ }
+ if(tr->langopts.break_numbers & (1 << (nx-2)))
+ {
+ // the next group only has 2 digits (eg. Indian languages), make it three
+ *pn++ = '0';
+ }
}
}
}
- word = pw;
+ pw--;
+ memcpy(&num_wtab[nw], &words[ix], sizeof(WORD_TAB)*2); // the original number word, and the word after it
- // include the next few characters, in case there are an ordinal indicator
- pn[0] = ' ';
- memcpy(pn+1, pw, 8);
- pn[8] = 0;
+ for(j=1; j<=nw; j++)
+ {
+ num_wtab[j].flags &= ~(FLAG_MULTIPLE_SPACES | FLAG_EMBEDDED); // don't use these flags for subsequent parts when splitting a number
+ }
+
+ // include the next few characters, in case there are an ordinal indicator or other suffix
+ memcpy(pn, pw, 16);
+ pn[16] = 0;
+ nw = 0;
for(pw = &number_buf[1]; pw < pn;)
{
- dict_flags = TranslateWord2(tr, pw, &words[ix], words[ix].pre_pause,0 );
+ // keep wflags for each part, for FLAG_HYPHEN_AFTER
+ dict_flags = TranslateWord2(tr, pw, &num_wtab[nw++], words[ix].pre_pause,0 );
while(*pw++ != ' ');
words[ix].pre_pause = 0;
- words[ix].flags = 0;
}
}
else
{
pre_pause = 0;
+
dict_flags = TranslateWord2(tr, word, &words[ix], words[ix].pre_pause, words[ix+1].pre_pause);
if(pre_pause > words[ix+1].pre_pause)
@@ -2693,7 +3468,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
}
}
- if((dict_flags & FLAG_DOT) && (ix == word_count-1) && (terminator == CLAUSE_PERIOD))
+ if((dict_flags & (FLAG_ALLOW_DOT | FLAG_NEEDS_DOT)) && (ix == word_count - 1 - dictionary_skipwords) && (terminator & CLAUSE_DOT))
{
// probably an abbreviation such as Mr. or B. rather than end of sentence
clause_pause = 10;
@@ -2703,17 +3478,28 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
if(dict_flags & FLAG_SKIPWORDS)
{
- ix += dictionary_skipwords; // dictionary indicates skip next word(s)
+ // dictionary indicates skip next word(s)
+ while(dictionary_skipwords > 0)
+ {
+ words[ix+dictionary_skipwords].flags |= FLAG_DELETE_WORD;
+ dictionary_skipwords--;
+ }
}
}
+ if(embedded_read < embedded_ix)
+ {
+ // any embedded commands not yet processed?
+ Word_EmbeddedCmd();
+ }
+
for(ix=0; ix<2; ix++)
{
// terminate the clause with 2 PAUSE phonemes
PHONEME_LIST2 *p2;
p2 = &ph_list2[n_ph_list2 + ix];
p2->phcode = phonPAUSE;
- p2->stress = 0;
+ p2->stresslevel = 0;
p2->sourceix = source_index;
p2->synthflags = 0;
}
@@ -2728,18 +3514,22 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
clause_pause = 10;
}
- MakePhonemeList(tr, clause_pause, new_sentence);
+ MakePhonemeList(tr, clause_pause, new_sentence2);
+ phoneme_list[N_PHONEME_LIST].ph = NULL; // recognize end of phoneme_list array, in Generate()
+ phoneme_list[N_PHONEME_LIST].sourceix = 1;
if(embedded_count) // ???? is this needed
{
phoneme_list[n_phoneme_list-2].synthflags = SFLAG_EMBEDDED;
embedded_list[embedded_ix-1] |= 0x80;
+ embedded_list[embedded_ix] = 0x80;
}
prev_clause_pause = clause_pause;
- *tone_out = tone;
+ if(tone_out != NULL)
+ *tone_out = tone;
new_sentence = 0;
if(terminator & CLAUSE_BIT_SENTENCE)
@@ -2752,7 +3542,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
{
// return new voice name if an embedded voice change command terminated the clause
if(terminator & CLAUSE_BIT_VOICE)
- *voice_change = &source[source_index];
+ *voice_change = voice_change_name;
else
*voice_change = NULL;
}
diff --git a/navit/support/espeak/translate.h b/navit/support/espeak/translate.h
index 0556bf280..fe25b191d 100755..100644
--- a/navit/support/espeak/translate.h
+++ b/navit/support/espeak/translate.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -18,18 +18,21 @@
***************************************************************************/
-#define L(c1,c2) (c1<<8)+c2 // combine two characters into an integer for translator name
+#define L(c1,c2) (c1<<8)+c2 // combine two characters into an integer for translator name
#define CTRL_EMBEDDED 0x01 // control character at the start of an embedded command
#define REPLACED_E 'E' // 'e' replaced by silent e
-#define N_WORD_PHONEMES 160 // max phonemes in a word
+#define N_WORD_PHONEMES 200 // max phonemes in a word
#define N_WORD_BYTES 160 // max bytes for the UTF8 characters in a word
#define N_CLAUSE_WORDS 300 // max words in a clause
+#define N_TR_SOURCE 800 // the source text of a single clause (UTF8 bytes)
+
+
#define N_RULE_GROUP2 120 // max num of two-letter rule chains
#define N_HASH_DICT 1024
#define N_CHARSETS 20
-#define N_LETTER_GROUPS 26
+#define N_LETTER_GROUPS 95 // maximum is 127-32
/* dictionary flags, word 1 */
@@ -37,25 +40,25 @@
#define FLAG_SKIPWORDS 0x80
#define FLAG_PREPAUSE 0x100
-#define FLAG_ONLY 0x200
-#define FLAG_ONLY_S 0x400
-#define BITNUM_FLAG_ONLY 9 // bit 9 is set
-#define BITNUM_FLAG_ONLY_S 10 // bit 10 is set
-
-#define FLAG_STRESS_END 0x800 /* full stress if at end of clause */
-#define FLAG_STRESS_END2 0x1000 /* full stress if at end of clause, or only followed by unstressed */
-#define FLAG_UNSTRESS_END 0x2000 /* reduce stress at end of clause */
-#define FLAG_ATEND 0x4000 /* use this pronunciation if at end of clause */
-#define FLAG_SPELLWORD 0x8000 // re-translate the word as individual letters, separated by spaces
-
-#define FLAG_DOT 0x10000 /* ignore '.' after word (abbreviation) */
-#define FLAG_ABBREV 0x20000 // spell as letters, even with a vowel, OR use specified pronunciation rather than split into letters
-#define FLAG_STEM 0x40000 // must have a suffix
-
-#define FLAG_DOUBLING 0x80000 // doubles the following consonant
-#define FLAG_ALT_TRANS 0x100000 // language specific
-#define FLAG_ALT2_TRANS 0x200000 // language specific
-
+#define FLAG_STRESS_END 0x200 // full stress if at end of clause
+#define FLAG_STRESS_END2 0x400 // full stress if at end of clause, or only followed by unstressed
+#define FLAG_UNSTRESS_END 0x800 // reduce stress at end of clause
+#define FLAG_SPELLWORD 0x1000 // re-translate the word as individual letters, separated by spaces
+#define FLAG_ABBREV 0x2000 // spell as letters, even with a vowel, OR use specified pronunciation rather than split into letters
+#define FLAG_DOUBLING 0x4000 // doubles the following consonant
+
+#define BITNUM_FLAG_ALT 14 // bit number of FLAG_ALT_TRANS - 1
+#define FLAG_ALT_TRANS 0x8000 // language specific
+#define FLAG_ALT2_TRANS 0x10000 // language specific
+#define FLAG_ALT3_TRANS 0x20000 // language specific
+#define FLAG_ALT4_TRANS 0x40000 // language specific
+#define FLAG_ALT5_TRANS 0x80000 // language specific
+#define FLAG_ALT6_TRANS 0x100000 // language specific
+
+#define FLAG_COMBINE 0x800000 // combine with the next word
+#define FLAG_ALLOW_DOT 0x01000000 // ignore '.' after word (abbreviation)
+#define FLAG_NEEDS_DOT 0x02000000 // only if the word is followed by a dot
+#define FLAG_WAS_UNPRONOUNCABLE 0x04000000 // the unpronounceable routine was used
#define FLAG_MAX3 0x08000000 // limit to 3 repeats
#define FLAG_PAUSE1 0x10000000 // shorter prepause
#define FLAG_TEXTMODE 0x20000000 // word translates to replacement text, not phonemes
@@ -75,10 +78,21 @@
#define FLAG_VERB_EXT 0x100 /* extend the 'verb follows' */
#define FLAG_CAPITAL 0x200 /* pronunciation if initial letter is upper case */
#define FLAG_ALLCAPS 0x400 // only if the word is all capitals
-#define BITNUM_FLAG_ALLCAPS 0x2a
#define FLAG_ACCENT 0x800 // character name is base-character name + accent name
#define FLAG_HYPHENATED 0x1000 // multiple-words, but needs hyphen between parts 1 and 2
+#define FLAG_SENTENCE 0x2000 // only if the clause is a sentence
+#define FLAG_ONLY 0x4000
+#define FLAG_ONLY_S 0x8000
+#define FLAG_STEM 0x10000 // must have a suffix
+#define FLAG_ATEND 0x20000 // use this pronunciation if at end of clause
+#define FLAG_ATSTART 0x40000 // use this pronunciation if at start of clause
+#define FLAG_NATIVE 0x80000 // not if we've switched translators
+#define FLAG_LOOKUP_SYMBOL 0x40000000 // to indicate called from Lookup()
+
+#define BITNUM_FLAG_ALLCAPS 0x2a
#define BITNUM_FLAG_HYPHENATED 0x2c
+#define BITNUM_FLAG_ONLY 0x2e
+#define BITNUM_FLAG_ONLY_S 0x2f
// wordflags, flags in source word
@@ -98,20 +112,37 @@
#define FLAG_DONT_SWITCH_TRANSLATOR 0x1000
#define FLAG_SUFFIX_REMOVED 0x2000
#define FLAG_HYPHEN_AFTER 0x4000
+#define FLAG_ORDINAL 0x8000 // passed to TranslateNumber() to indicate an ordinal number
+#define FLAG_HAS_DOT 0x10000 // dot after this word
+#define FLAG_COMMA_AFTER 0x20000 // comma after this word
+#define FLAG_MULTIPLE_SPACES 0x40000 // word is preceded by multiple spaces, newline, or tab
+#define FLAG_INDIVIDUAL_DIGITS 0x80000 // speak number as individual digits
+#define FLAG_DELETE_WORD 0x100000 // don't speak this word, it has been spoken as part of the previous word
+#define FLAG_CHAR_REPLACED 0x200000 // characters have been replaced by .replace in the *_rules
+#define FLAG_TRANSLATOR2 0x400000 // retranslating using a different language
+#define FLAG_PREFIX_REMOVED 0x800000 // a prefix has been removed from this word
+
+#define FLAG_SUFFIX_VOWEL 0x08000000 // remember an initial vowel from the suffix
+#define FLAG_NO_TRACE 0x10000000 // passed to TranslateRules() to suppress dictionary lookup printout
+#define FLAG_NO_PREFIX 0x20000000
+#define FLAG_UNPRON_TEST 0x80000000 // do unpronounability test on the beginning of the word
-#define FLAG_NO_TRACE 0x10000 // passed to TranslateRules() to suppress dictionary lookup printout
-#define FLAG_NO_PREFIX 0x20000
// prefix/suffix flags (bits 8 to 14, bits 16 to 22) don't use 0x8000, 0x800000
#define SUFX_E 0x0100 // e may have been added
#define SUFX_I 0x0200 // y may have been changed to i
#define SUFX_P 0x0400 // prefix
#define SUFX_V 0x0800 // suffix means use the verb form pronunciation
-#define SUFX_D 0x1000 // previous letter may have been doubles
+#define SUFX_D 0x1000 // previous letter may have been doubled
#define SUFX_F 0x2000 // verb follows
#define SUFX_Q 0x4000 // don't retranslate
#define SUFX_T 0x10000 // don't affect the stress position in the stem
#define SUFX_B 0x20000 // break, this character breaks the word into stem and suffix (used with SUFX_P)
+#define SUFX_A 0x40000 // remember that the suffix starts with a vowel
+#define SUFX_M 0x80000 // bit 19, allow multiple suffixes
+
+#define SUFX_UNPRON 0x8000 // used to return $unpron flag from *_rules
+
#define FLAG_ALLOW_TEXTMODE 0x02 // allow dictionary to translate to text rather than phonemes
#define FLAG_SUFX 0x04
@@ -127,29 +158,36 @@
#define RULE_CONDITION 5 // followed by condition number (byte)
#define RULE_GROUP_START 6
#define RULE_GROUP_END 7
-#define RULE_LINENUM 8 // next 2 bytes give a line number, for debugging purposes
+#define RULE_PRE_ATSTART 8 // as RULE_PRE but also match with 'start of word'
+#define RULE_LINENUM 9 // next 2 bytes give a line number, for debugging purposes
#define RULE_SPACE 32 // ascii space
-#define RULE_SYLLABLE 9
-#define RULE_STRESSED 10
-#define RULE_DOUBLE 11
-#define RULE_INC_SCORE 12
-#define RULE_DEL_FWD 13
-#define RULE_ENDING 14
+#define RULE_SYLLABLE 21 // @
+#define RULE_STRESSED 10 // &
+#define RULE_DOUBLE 11 // %
+#define RULE_INC_SCORE 12 // +
+#define RULE_DEL_FWD 13 // #
+#define RULE_ENDING 14 // S
#define RULE_DIGIT 15 // D digit
#define RULE_NONALPHA 16 // Z non-alpha
#define RULE_LETTERGP 17 // A B C H F G Y letter group number
#define RULE_LETTERGP2 18 // L + letter group number
-#define RULE_CAPITAL 19 // word starts with a capital letter
+#define RULE_CAPITAL 19 // ! word starts with a capital letter
#define RULE_REPLACEMENTS 20 // section for character replacements
+#define RULE_SKIPCHARS 23 // J
#define RULE_NO_SUFFIX 24 // N
#define RULE_NOTVOWEL 25 // K
#define RULE_IFVERB 26 // V
-#define RULE_ALT1 28 // T word has $alt attribute
+#define RULE_DOLLAR 28 // $ commands
#define RULE_NOVOWELS 29 // X no vowels up to word boundary
#define RULE_SPELLING 31 // W while spelling letter-by-letter
#define RULE_LAST_RULE 31
+#define DOLLAR_UNPR 0x01
+#define DOLLAR_NOPREFIX 0x02
+#define DOLLAR_LIST 0x03
+
+
#define LETTERGP_A 0
#define LETTERGP_B 1
#define LETTERGP_C 2
@@ -161,30 +199,37 @@
// Punctuation types returned by ReadClause()
-// bits 0-7 pause x 10mS, bits 12-14 intonation type,
+// bits 0-11 pause x 10mS
+// bits12-14 intonation type
+// bit 15- don't need space after the punctuation
// bit 19=sentence, bit 18=clause, bits 17=voice change
// bit 16 used to distinguish otherwise identical types
// bit 20= punctuation character can be inside a word (Armenian)
+// bit 21= speak the name of the punctuation character
+// bit 22= dot after the last word
+// bit 23= pause is x 320mS (not x 10mS)
+
#define CLAUSE_BIT_SENTENCE 0x80000
+#define CLAUSE_BIT_CLAUSE 0x40000
#define CLAUSE_BIT_VOICE 0x20000
+#define CLAUSE_BITS_INTONATION 0x7000
#define PUNCT_IN_WORD 0x100000
-
-#define CLAUSE_NONE 0 + 0x04000
-#define CLAUSE_PARAGRAPH 70 + 0x80000
-#define CLAUSE_EOF 35 + 0x90000
-#define CLAUSE_VOICE 0 + 0x24000
-#define CLAUSE_PERIOD 35 + 0x80000
-#define CLAUSE_COMMA 20 + 0x41000
-#define CLAUSE_SHORTCOMMA 4 + 0x41000
-#define CLAUSE_SHORTFALL 4 + 0x40000
-#define CLAUSE_QUESTION 35 + 0x82000
-#define CLAUSE_EXCLAMATION 40 + 0x83000
-#define CLAUSE_COLON 30 + 0x40000
-#ifdef PLATFORM_RISCOS
-#define CLAUSE_SEMICOLON 30 + 0x40000
-#else
-#define CLAUSE_SEMICOLON 30 + 0x41000
-#endif
+#define PUNCT_SAY_NAME 0x200000
+#define CLAUSE_DOT 0x400000
+#define CLAUSE_PAUSE_LONG 0x800000
+
+#define CLAUSE_NONE ( 0 + 0x04000)
+#define CLAUSE_PARAGRAPH (70 + 0x80000)
+#define CLAUSE_EOF (40 + 0x90000)
+#define CLAUSE_VOICE ( 0 + 0x24000)
+#define CLAUSE_PERIOD (40 + 0x80000)
+#define CLAUSE_COMMA (20 + 0x41000)
+#define CLAUSE_SHORTCOMMA ( 4 + 0x41000)
+#define CLAUSE_SHORTFALL ( 4 + 0x40000)
+#define CLAUSE_QUESTION (40 + 0x82000)
+#define CLAUSE_EXCLAMATION (45 + 0x83000)
+#define CLAUSE_COLON (30 + 0x40000)
+#define CLAUSE_SEMICOLON (30 + 0x41000)
#define SAYAS_CHARS 0x12
#define SAYAS_GLYPHS 0x13
@@ -194,6 +239,7 @@
#define SAYAS_DIGITS1 0xc1
#define CHAR_EMPHASIS 0x0530 // this is an unused character code
+#define CHAR_COMMA_BREAK 0x0557 // unused character code
// Rule:
// [4] [match] [1 pre] [2 post] [3 phonemes] 0
@@ -203,32 +249,23 @@
typedef const char * constcharptr;
typedef struct {
- int points;
+ int points;
const char *phonemes;
- int end_type;
+ int end_type;
char *del_fwd;
} MatchRecord;
-
+
// used to mark words with the source[] buffer
typedef struct{
+ unsigned int flags;
unsigned short start;
- unsigned short sourceix;
- unsigned short flags;
unsigned char pre_pause;
unsigned char wmark;
+ unsigned short sourceix;
unsigned char length;
} WORD_TAB;
-// a clause translated into phoneme codes (first stage)
-typedef struct {
- unsigned char phcode;
- unsigned char stress;
- unsigned char tone_number;
- unsigned char synthflags;
- unsigned short sourceix;
-} PHONEME_LIST2;
-
typedef struct {
int type;
@@ -239,8 +276,25 @@ extern PARAM_STACK param_stack[];
extern const int param_defaults[N_SPEECH_PARAM];
-
-#define N_LOPTS 16
+typedef struct {
+ const char *name;
+ int offset;
+ unsigned short range_min, range_max;
+ int language;
+ int flags;
+} ALPHABET;
+
+extern ALPHABET alphabets[];
+extern ALPHABET *current_alphabet;
+// alphabet flags
+#define AL_DONT_NAME 0x01 // don't speak the alphabet name
+#define AL_NOT_LETTERS 0x02 // don't use the language for speaking letters
+#define AL_WORDS 0x04 // use the language to speak words
+#define AL_NOT_CODE 0x08 // don't speak the character code
+#define AL_NO_SYMBOL 0x10 // don't repeat "symbol" or "character"
+
+
+#define N_LOPTS 21
#define LOPT_DIERESES 1
// 1=remove [:] from unstressed syllables, 2= remove from unstressed or non-penultimate syllables
// bit 4=0, if stress < 4, bit 4=1, if not the highest stress in the word
@@ -250,9 +304,12 @@ extern const int param_defaults[N_SPEECH_PARAM];
#define LOPT_PREFIXES 3
// non-zero, change voiced/unoiced to match last consonant in a cluster
- // bit 1=LANG=ru, don't propagate over [v]
+ // bit 0=use regressive voicing
+ // bit 1=LANG=cz,bg don't propagate over [v]
// bit 2=don't propagate acress word boundaries
// bit 3=LANG=pl, propagate over liquids and nasals
+ // bit 4=LANG=cz,sk don't progagate to [v]
+ // bit 8=devoice word-final consonants
#define LOPT_REGRESSIVE_VOICING 4
// 0=default, 1=no check, other allow this character as an extra initial letter (default is 's')
@@ -264,7 +321,7 @@ extern const int param_defaults[N_SPEECH_PARAM];
// increase this to prevent sonorants being shortened before shortened (eg. unstressed) vowels
#define LOPT_SONORANT_MIN 7
- // don't break vowels at word boundary
+ // bit 0: don't break vowels at word boundary
#define LOPT_WORD_MERGE 8
// max. amplitude for vowel at the end of a clause
@@ -292,8 +349,33 @@ extern const int param_defaults[N_SPEECH_PARAM];
#define LOPT_IT_DOUBLING 14
// Call ApplySpecialAttributes() if $alt or $alt2 is set for a word
+ // bit 1: stressed syllable: $alt change [e],[o] to [E],[O], $alt2 change [E],[O] to [e],[o]
#define LOPT_ALT 15
+ // pause for bracket (default=4), pause when annoucing bracket names (default=2)
+#define LOPT_BRACKET_PAUSE 16
+
+ // bit 1, don't break clause before annoucning . ? !
+#define LOPT_ANNOUNCE_PUNCT 17
+
+ // recognize long vowels (0 = don't recognize)
+#define LOPT_LONG_VOWEL_THRESHOLD 18
+
+ // bit 0: Don't allow suffices if there is no previous syllable
+#define LOPT_SUFFIX 19
+
+ // bit 0 Apostrophe at start of word is part of the word
+ // bit 1 Apostrophe at end of word is part of the word
+#define LOPT_APOSTROPHE 20
+
+
+// stress_rule
+#define STRESSPOSN_1L 0 // 1st syllable
+#define STRESSPOSN_2L 1 // 2nd syllable
+#define STRESSPOSN_2R 2 // penultimate
+#define STRESSPOSN_1R 3 // final syllable
+#define STRESSPOSN_3R 4 // antipenultimate
+
typedef struct {
// bits0-2 separate words with (1=pause_vshort, 2=pause_short, 3=pause, 4=pause_long 5=[?] phonemme)
@@ -304,34 +386,99 @@ typedef struct {
int vowel_pause;
int stress_rule; // 1=first syllable, 2=penultimate, 3=last
-// bit0=don't stress monosyllables, except at end of clause
+#define S_NO_DIM 0x02
+#define S_FINAL_DIM 0x04
+#define S_FINAL_DIM_ONLY 0x06
// bit1=don't set diminished stress,
// bit2=mark unstressed final syllables as diminished
+
+// bit3=set consecutive unstressed syllables in unstressed words to diminished, but not in stressed words
+
+#define S_FINAL_NO_2 0x10
// bit4=don't allow secondary stress on last syllable
+
+#define S_NO_AUTO_2 0x20
// bit5-don't use automatic secondary stress
+
+#define S_2_TO_HEAVY 0x40
// bit6=light syllable followed by heavy, move secondary stress to the heavy syllable. LANG=Finnish
+
+#define S_FIRST_PRIMARY 0x80
+// bit7=if more than one primary stress, make the subsequent primaries to secondary stress
+
+#define S_FINAL_STRESS_C 0x100
// bit8=stress last syllable if it doesn't end in a vowel
+
+#define S_FINAL_SPANISH 0x200
// bit9=stress last syllable if it doesn't end in vowel or "s" or "n" LANG=Spanish
+
+#define S_2_SYL_2 0x1000
// bit12= In a 2-syllable word, if one has primary stress then give the other secondary stress
+
+#define S_INITIAL_2 0x2000
// bit13= If there is only one syllable before the primary stress, give it a secondary stress
-// bit15= Give stress to the first unstressed syllable
-// bit16= Don't diminish consecutive syllables within a word.
+
+#define S_MID_DIM 0x10000
+// bit 16= Set (not first or last) syllables to diminished stress
+
+#define S_PRIORITY_STRESS 0x20000
// bit17= "priority" stress reduces other primary stress to "unstressed" not "secondary"
+
+#define S_EO_CLAUSE1 0x40000
// bit18= don't lengthen short vowels more than long vowels at end-of-clause
+
+#define S_FINAL_LONG 0x80000
// bit19=stress on final syllable if it has a long vowel, but previous syllable has a short vowel
- int stress_flags;
+
+#define S_HYPEN_UNSTRESS 0x100000
+// bit20= hyphenated words, 2nd part is unstressed
+
+#define S_NO_EOC_LENGTHEN 0x200000
+// bit21= don't lengthen vowels at end-of-clause
+
+// bit15= Give stress to the first unstressed syllable
+
+
+ int stress_flags;
int unstressed_wd1; // stress for $u word of 1 syllable
int unstressed_wd2; // stress for $u word of >1 syllable
int param[N_LOPTS];
+ int param2[N_LOPTS];
unsigned char *length_mods;
unsigned char *length_mods0;
-#define NUM_ROMAN 0x20000
-#define NUM_ROMAN_UC 0x40000
-#define NUM_NOPAUSE 0x80000
-#define NUM_ROMAN_AFTER 0x200000
-#define NUM_VIGESIMAL 0x400000
+#define NUM_THOUS_SPACE 0x4
+#define NUM_DECIMAL_COMMA 0x8
+#define NUM_SWAP_TENS 0x10
+#define NUM_AND_UNITS 0x20
+#define NUM_HUNDRED_AND 0x40
+#define NUM_SINGLE_AND 0x80
+#define NUM_SINGLE_STRESS 0x100
+#define NUM_SINGLE_VOWEL 0x200
+#define NUM_OMIT_1_HUNDRED 0x400
+#define NUM_1900 0x800
+#define NUM_ALLOW_SPACE 0x1000
+#define NUM_DFRACTION_1 0x2000
+#define NUM_DFRACTION_2 0x4000
+#define NUM_DFRACTION_3 0x6000
+#define NUM_DFRACTION_4 0x8000
+#define NUM_DFRACTION_5 0xa000
+#define NUM_DFRACTION_6 0xc000
+#define NUM_DFRACTION_7 0xe000 // lang=si, alternative form of number for decimal fraction digits (except the last)
+#define NUM_ORDINAL_DOT 0x10000
+#define NUM_NOPAUSE 0x20000
+#define NUM_AND_HUNDRED 0x40000
+#define NUM_THOUSAND_AND 0x80000
+#define NUM_VIGESIMAL 0x100000
+#define NUM_OMIT_1_THOUSAND 0x200000
+#define NUM_ZERO_HUNDRED 0x400000
+#define NUM_HUNDRED_AND_DIGIT 0x800000
+#define NUM_ROMAN 0x1000000
+#define NUM_ROMAN_CAPITALS 0x2000000
+#define NUM_ROMAN_AFTER 0x4000000
+#define NUM_ROMAN_ORDINAL 0x8000000
+#define NUM_SINGLE_STRESS_L 0x10000000
// bits0-1=which numbers routine to use.
// bit2= thousands separator must be space
@@ -346,35 +493,66 @@ typedef struct {
// bit11=say 19** as nineteen hundred
// bit12=allow space as thousands separator (in addition to langopts.thousands_sep)
// bits13-15 post-decimal-digits 0=single digits, 1=(LANG=it) 2=(LANG=pl) 3=(LANG=ro)
- // bit16=dot after number indicates ordinal
- // bit17=recognize roman numbers
- // bit18=Roman numbers only if upper case
- // bit19=don't add pause after a number
- // bit20='and' before hundreds
- // bit21= say "roman" after the number, not before
- // bit22= vigesimal number, if tens are not found
+
+ // bit16= dot after number indicates ordinal
+ // bit17= don't add pause after a number
+ // bit18= 'and' before hundreds
+ // bit19= 'and' after thousands if there are no hundreds
+ // bit20= vigesimal number, if tens are not found
+ // bit21= omit "one" before "thousand"
+ // bit22= say "zero" before hundred
+ // bit23= add "and" after hundreds and thousands, only if there are digits and no tens
+
+ // bit24= recognize roman numbers
+ // bit25= Roman numbers only if upper case
+ // bit26= say "roman" after the number, not before
+ // bit27= Roman numbers are ordinal numbers
+ // bit28= only one primary stress in tens+units (on the tens)
int numbers;
-#define NUM2_100000 0x800 // numbers for 100,000 and 10,000,000
-#define NUM2_100000a 0xc00 // numbers for 100,000 and 1,000,000
+#define NUM2_THOUSANDS_VAR1 0x40
+#define NUM2_THOUSANDS_VAR2 0x80
+#define NUM2_THOUSANDS_VAR3 0xc0
+#define NUM2_THOUSANDS_VAR4 0x100
+#define NUM2_THOUSANDS_VAR5 0x140
+
+#define NUM2_ORDINAL_NO_AND 0x800
+#define NUM2_MULTIPLE_ORDINAL 0x1000
+#define NUM2_NO_TEEN_ORDINALS 0x2000
+#define NUM2_MYRIADS 0x4000
+#define NUM2_ENGLISH_NUMERALS 0x8000
+#define NUM2_PERCENT_BEFORE 0x10000
+#define NUM2_OMIT_1_HUNDRED_ONLY 0x20000
+#define NUM2_ORDINAL_AND_THOUSANDS 0x40000
// bits 1-4 use variant form of numbers before thousands,millions,etc.
- // bit6=(LANG=pl) two forms of plural, M or MA
- // bit7=(LANG-ru) use MB for 1 thousand, million, etc
- // bit8=(LANG=cs,sk) two forms of plural, M or MA
+ // bits 6-8 use different forms of thousand, million, etc (M MA MB)
// bit9=(LANG=rw) say "thousand" and "million" before its number, not after
- // bit10=(LANG=sw) special word for 100,000 and 1,000,000
- // bit11=(LANG=hi) special word for 100,000 and 10,000,000
+ // bit11=(LANG=es,an) don't say 'and' between tens and units for ordinal numbers
+ // bit12=(LANG=el,es) use ordinal form of hundreds and tens as well as units
+ // bit13=(LANG=pt) don't use 11-19 numbers to make ordinals
+ // bit14=(LANG=ko) use myriads (groups of 4 digits) not thousands (groups of 3)
+ // bit15=(LANG=ne) speak (non-replaced) English numerals in English
+ // bit16=(LANG=si) say "%" before the number
+ // bit17=(LANG=ml) omit "one" before hundred only if there are no previous digits
+ // bit18=(LANG=ta) same variant for ordinals and thousands (#o = #a)
int numbers2;
+#define BREAK_THOUSANDS 0x49249248
+ int break_numbers; // which digits to break the number into thousands, millions, etc (Hindi has 100,000 not 1,000,000)
int max_roman;
+ int min_roman;
int thousands_sep;
int decimal_sep;
+ int max_digits; // max number of digits which can be spoken as an integer number (rather than individual digits)
+ const char *ordinal_indicator; // UTF-8 string
+ const char *roman_suffix; // add this (ordinal) suffix to Roman numbers (LANG=an)
// bit 0, accent name before the letter name, bit 1 "capital" after letter name
int accents;
int tone_language; // 1=tone language
int intonation_group;
+ unsigned char tunes[6];
int long_stop; // extra mS pause for a lengthened stop
int phoneme_change; // TEST, change phonemes, after translation
char max_initial_consonants;
@@ -382,10 +560,21 @@ typedef struct {
char tone_numbers;
char ideographs; // treat as separate words
char textmode; // the meaning of FLAG_TEXTMODE is reversed (to save data when *_list file is compiled)
+ char dotless_i; // uses letter U+0131
int testing; // testing options: bit 1= specify stressed syllable in the form: "outdoor/2"
int listx; // compile *_listx after *list
const unsigned int *replace_chars; // characters to be substitutes
- const char *ascii_language; // switch to this language for Latin characters
+ char ascii_language[8]; // switch to this language for Latin characters
+ int our_alphabet; // offset for main alphabet (if not set in letter_bits_offset)
+ int alt_alphabet; // offset for another language to recognize
+ int alt_alphabet_lang; // language for the alt_alphabet
+ int max_lengthmod;
+ int lengthen_tonic; // lengthen the tonic syllable
+ int suffix_add_e; // replace a suffix (which has the SUFX_E flag) with this character
+
+#define DICTDIALECT_EN_US 1 // bit number
+#define DICTDIALECT_ES_LA 2
+ int dict_dialect; // bitmap, use a dialect for foreign words
} LANGUAGE_OPTIONS;
@@ -401,30 +590,29 @@ typedef struct {
-#define NUM_SEP_DOT 0x0008 // . , for thousands and decimal separator
-#define NUM_SEP_SPACE 0x1000 // allow space as thousands separator (in addition to langopts.thousands_sep)
-#define NUM_DEC_IT 0x2000 // (LANG=it) speak post-decimal-point digits as a combined number not as single digits
-
-typedef struct Translator
-{//=============
+typedef struct
+{//===========
LANGUAGE_OPTIONS langopts;
int translator_name;
- int transpose_offset;
int transpose_max;
int transpose_min;
+ const char *transpose_map;
+ char dictionary_name[40];
- char phon_out[300];
char phonemes_repeat[20];
- int phonemes_repeat_count;
+ int phonemes_repeat_count;
+ int phoneme_tab_ix;
unsigned char stress_amps[8];
unsigned char stress_amps_r[8];
short stress_lengths[8];
int dict_condition; // conditional apply some pronunciation rules and dict.lookups
+ int dict_min_size;
const unsigned short *charset_a0; // unicodes for characters 0xa0 to oxff
const wchar_t *char_plus_apostrophe; // single chars + apostrophe treated as words
const wchar_t *punct_within_word; // allow these punctuation characters within words
+ const unsigned short *chars_ignore;
// holds properties of characters: vowel, consonant, etc for pronunciation rules
unsigned char letter_bits[256];
@@ -443,16 +631,17 @@ typedef struct Translator
// groups1 and groups2 are indexes into data_dictrules, set up by InitGroups()
// the two-letter rules for each letter must be consecutive in the language_rules source
-
+
char *groups1[256]; // translation rule lists, index by single letter
+ char *groups3[128]; // index by offset letter
char *groups2[N_RULE_GROUP2]; // translation rule lists, indexed by two-letter pairs
unsigned int groups2_name[N_RULE_GROUP2]; // the two letter pairs for groups2[]
int n_groups2; // number of groups2[] entries used
-
+
unsigned char groups2_count[256]; // number of 2 letter groups for this initial letter
unsigned char groups2_start[256]; // index into groups2
-
-
+ const short *frequent_pairs; // list of frequent pairs of letters, for use in compressed *_list
+
int expect_verb;
int expect_past; // expect past tense
int expect_verb_s;
@@ -462,14 +651,15 @@ typedef struct Translator
int word_vowel_count; // number of vowels so far
int word_stressed_count; // number of vowels so far which could be stressed
-
+
int clause_upper_count; // number of upper case letters in the clause
int clause_lower_count; // number of lower case letters in the clause
int prepause_timeout;
int end_stressed_vowel; // word ends with stressed vowel
- int prev_dict_flags; // dictionary flags from previous word
-} Translator; // end of class Translator
+ int prev_dict_flags[2]; // dictionary flags from previous word
+ int clause_terminator;
+} Translator;
extern int option_tone2;
@@ -479,6 +669,7 @@ extern int option_tone_flags;
extern int option_waveout;
extern int option_quiet;
extern int option_phonemes;
+extern int option_mbrola_phonemes;
extern int option_phoneme_events;
extern int option_linelength; // treat lines shorter than this as end-of-clause
extern int option_multibyte;
@@ -513,8 +704,8 @@ extern char skip_marker[N_MARKER_LENGTH];
extern wchar_t option_punctlist[N_PUNCTLIST]; // which punctuation characters to announce
extern unsigned char punctuation_to_tone[INTONATION_TYPES][PUNCT_INTONATIONS];
-extern struct Translator *translator;
-extern struct Translator *translator2;
+extern Translator *translator;
+extern Translator *translator2;
extern const unsigned short *charsets[N_CHARSETS];
extern char dictionary_name[40];
extern char ctrl_embedded; // to allow an alternative CTRL for embedded commands
@@ -524,15 +715,16 @@ extern int dictionary_skipwords;
extern int (* uri_callback)(int, const char *, const char *);
extern int (* phoneme_callback)(const char *);
-extern void SetLengthMods(struct Translator *tr, int value);
+extern void SetLengthMods(Translator *tr, int value);
void LoadConfig(void);
-int TransposeAlphabet(char *text, int offset, int min, int max);
+int TransposeAlphabet(Translator *tr, char *text);
int utf8_in(int *c, const char *buf);
int utf8_in2(int *c, const char *buf, int backwards);
int utf8_out(unsigned int c, char *buf);
int utf8_nbytes(const char *buf);
int lookupwchar(const unsigned short *list,int c);
+int lookupwchar2(const unsigned short *list,int c);
int Eof(void);
char *strchr_w(const char *s, int c);
int IsBracket(int c);
@@ -540,23 +732,35 @@ void InitNamedata(void);
void InitText(int flags);
void InitText2(void);
int IsDigit(unsigned int c);
+int IsDigit09(unsigned int c);
int IsAlpha(unsigned int c);
+int IsVowel(Translator *tr, int c);
+int IsSuperscript(int letter);
+int iswalpha2(int c);
int isspace2(unsigned int c);
+int iswlower2(int c);
+int iswupper2(int c);
int towlower2(unsigned int c);
-void GetTranslatedPhonemeString(char *phon_out, int n_phon_out);
+int towupper2(unsigned int c);
+const char *GetTranslatedPhonemeString(int phoneme_mode);
+const char *WordToString2(unsigned int word);
+ALPHABET *AlphabetFromChar(int c);
+ALPHABET *AlphabetFromName(const char *name);
-struct Translator *SelectTranslator(const char *name);
+Translator *SelectTranslator(const char *name);
int SetTranslator2(const char *name);
-void DeleteTranslator(struct Translator *tr);
-int Lookup(struct Translator *tr, const char *word, char *ph_out);
+void DeleteTranslator(Translator *tr);
+void ProcessLanguageOptions(LANGUAGE_OPTIONS *langopts);
+int Lookup(Translator *tr, const char *word, char *ph_out);
+int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out);
-int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, int wflags);
-int TranslateRoman(Translator *tr, char *word, char *ph_out);
+int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control);
+int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab);
void ChangeWordStress(Translator *tr, char *word, int new_stress);
void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars);
-int TranslateLetter(Translator *tr, char *letter, char *phonemes, int control, int word_length);
-void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf);
+int TranslateLetter(Translator *tr, char *letter, char *phonemes, int control);
+void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf, int control);
void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf);
int LoadDictionary(Translator *tr, const char *name, int no_error);
@@ -564,7 +768,6 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
void MakePhonemeList(Translator *tr, int post_pause, int new_sentence);
int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch);
-void ApplySpecialAttribute(Translator *tr, char *phonemes, int dict_flags);
void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags);
void AppendPhonemes(Translator *tr, char *string, int size, const char *ph);
@@ -572,13 +775,18 @@ void CalcLengths(Translator *tr);
void CalcPitches(Translator *tr, int clause_tone);
int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy);
-int Unpronouncable(Translator *tr, char *word);
+int Unpronouncable(Translator *tr, char *word, int posn);
void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress);
int TranslateRules(Translator *tr, char *p, char *phonemes, int size, char *end_phonemes, int end_flags, unsigned int *dict_flags);
-int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab);
+int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab, char *word_out);
void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *tone, char **voice_change);
-int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type);
+int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change);
-void SetVoiceStack(espeak_VOICE *v);
+void SetVoiceStack(espeak_VOICE *v, const char *variant_name);
+void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata, WORD_PH_DATA *worddata);
+void InterpretPhoneme2(int phcode, PHONEME_DATA *phdata);
+char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int use_ipa, int *flags);
extern FILE *f_trans; // for logging
+extern FILE *f_logespeak;
+extern int logging_type; // from config file
diff --git a/navit/support/espeak/voice.h b/navit/support/espeak/voice.h
index ab69fa128..36be098f1 100644
--- a/navit/support/espeak/voice.h
+++ b/navit/support/espeak/voice.h
@@ -21,15 +21,17 @@
typedef struct {
char v_name[40];
+ char language_name[20];
int phoneme_tab_ix; // phoneme table number
int pitch_base; // Hz<<12
int pitch_range; // standard = 0x1000
-
+
int speedf1;
int speedf2;
int speedf3;
+ int speed_percent; // adjust the WPM speed by this percentage
int flutter;
int roughness;
int echo_delay;
@@ -40,6 +42,7 @@ typedef struct {
int formant_factor; // adjust nominal formant frequencies by this because of the voice's pitch (256ths)
int consonant_amp; // amplitude of unvoiced consonants
int consonant_ampv; // amplitude of the noise component of voiced consonants
+ int samplerate;
int klattv[8];
// parameters used by Wavegen
@@ -67,6 +70,7 @@ typedef struct {
// percentages shown to user, ix=N_PEAKS means ALL peaks
extern USHORT voice_pcnt[N_PEAKS+1][3];
+extern espeak_VOICE current_voice_selected;
extern voice_t *voice;
extern int tone_points[12];
@@ -76,6 +80,8 @@ espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name);
voice_t *LoadVoice(const char *voice_name, int control);
voice_t *LoadVoiceVariant(const char *voice_name, int variant);
void DoVoiceChange(voice_t *v);
+void WVoiceChanged(voice_t *wvoice);
void WavegenSetVoice(voice_t *v);
void ReadTonePoints(char *string, int *tone_pts);
+void VoiceReset(int control);
diff --git a/navit/support/espeak/voices.c b/navit/support/espeak/voices.c
index a7bd3f5a0..c0279af9f 100755..100644
--- a/navit/support/espeak/voices.c
+++ b/navit/support/espeak/voices.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2014 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -42,15 +42,14 @@
#include "voice.h"
#include "translate.h"
-#define int(x) ((int)(x))
-#define double(x) ((double)(x))
-#define __cdecl
+#include "voices.h"
MNEM_TAB genders [] = {
{"unknown", 0},
{"male", 1},
{"female", 2},
- {NULL, 0 }};
+ {NULL, 0 }
+};
int tone_points[12] = {600,170, 1200,135, 2000,110, 3000,110, -1,0};
//int tone_points[12] = {250,200, 400,170, 600,170, 1200,135, 2000,110, -1,0};
@@ -64,12 +63,12 @@ int formant_rate[9]; // values adjusted for actual sample rate
#define DEFAULT_LANGUAGE_PRIORITY 5
-#define N_VOICES_LIST 150
+#define N_VOICES_LIST 250
static int n_voices_list = 0;
static espeak_VOICE *voices_list[N_VOICES_LIST];
static int len_path_voices;
-espeak_VOICE voice_selected;
+espeak_VOICE current_voice_selected;
enum {
@@ -95,11 +94,13 @@ enum {
// these override defaults set by the translator
V_WORDGAP,
V_INTONATION,
+ V_TUNES,
V_STRESSLENGTH,
V_STRESSAMP,
V_STRESSADD,
V_DICTRULES,
V_STRESSRULE,
+ V_STRESSOPT,
V_CHARSET,
V_NUMBERS,
V_OPTION,
@@ -107,6 +108,10 @@ enum {
V_MBROLA,
V_KLATT,
V_FAST,
+ V_SPEED,
+ V_DICTMIN,
+ V_ALPHABET2,
+ V_DICTDIALECT,
// these need a phoneme table to have been specified
V_REPLACE,
@@ -115,12 +120,13 @@ enum {
-typedef struct {
- const char *mnem;
- int data;
-} keywtab_t;
+static MNEM_TAB options_tab[] = {
+ {"reduce_t", LOPT_REDUCE_T},
+ {"bracket", LOPT_BRACKET_PAUSE},
+ {NULL, -1}
+};
-static keywtab_t keyword_tab[] = {
+static MNEM_TAB keyword_tab[] = {
{"name", V_NAME},
{"language", V_LANGUAGE},
{"gender", V_GENDER},
@@ -128,14 +134,16 @@ static keywtab_t keyword_tab[] = {
{"formant", V_FORMANT},
{"pitch", V_PITCH},
{"phonemes", V_PHONEMES},
- {"translator", V_TRANSLATOR},
+ {"translator", V_TRANSLATOR},
{"dictionary", V_DICTIONARY},
{"stressLength", V_STRESSLENGTH},
{"stressAmp", V_STRESSAMP},
{"stressAdd", V_STRESSADD},
{"intonation", V_INTONATION},
+ {"tunes", V_TUNES},
{"dictrules", V_DICTRULES},
{"stressrule", V_STRESSRULE},
+ {"stressopt", V_STRESSOPT},
{"charset", V_CHARSET},
{"replace", V_REPLACE},
{"words", V_WORDGAP},
@@ -152,7 +160,11 @@ static keywtab_t keyword_tab[] = {
{"mbrola", V_MBROLA},
{"consonants", V_CONSONANTS},
{"klatt", V_KLATT},
- {"fast_test", V_FAST},
+ {"fast_test2", V_FAST},
+ {"speed", V_SPEED},
+ {"dict_min", V_DICTMIN},
+ {"alphabet2", V_ALPHABET2},
+ {"dictdialect", V_DICTDIALECT},
// these just set a value in langopts.param[]
{"l_dieresis", 0x100+LOPT_DIERESES},
@@ -162,11 +174,20 @@ static keywtab_t keyword_tab[] = {
{"l_unpronouncable", 0x100+LOPT_UNPRONOUNCABLE},
{"l_sonorant_min", 0x100+LOPT_SONORANT_MIN},
{"l_length_mods", 0x100+LOPT_LENGTH_MODS},
- {NULL, 0} };
+ {"apostrophe", 0x100+LOPT_APOSTROPHE},
+ {NULL, 0}
+};
+
+static MNEM_TAB dict_dialects[] = {
+ {"en-us", DICTDIALECT_EN_US},
+ {"es-la", DICTDIALECT_ES_LA},
+ {NULL, 0}
+};
+
#define N_VOICE_VARIANTS 12
const char variants_either[N_VOICE_VARIANTS] = {1,2,12,3,13,4,14,5,11,0};
-const char variants_male[N_VOICE_VARIANTS] = {1,2,3,4,5,0};
+const char variants_male[N_VOICE_VARIANTS] = {1,2,3,4,5,6,0};
const char variants_female[N_VOICE_VARIANTS] = {11,12,13,14,0};
const char *variant_lists[3] = {variants_either, variants_male, variants_female};
@@ -183,6 +204,12 @@ static char *fgets_strip(char *buf, int size, FILE *f_in)
if(fgets(buf,size,f_in) == NULL)
return(NULL);
+ if(buf[0] == '#')
+ {
+ buf[0] = 0;
+ return(buf);
+ }
+
len = strlen(buf);
while((--len > 0) && isspace(buf[len]))
buf[len] = 0;
@@ -194,6 +221,20 @@ static char *fgets_strip(char *buf, int size, FILE *f_in)
}
+static int LookupTune(const char *name)
+{//====================================
+ int ix;
+
+ for(ix=0; ix<n_tunes; ix++)
+ {
+ if(strcmp(name, tunes[ix].name) == 0)
+ return(ix);
+ }
+ return(-1);
+} // end of LookupTune
+
+
+
static void SetToneAdjust(voice_t *voice, int *tone_pts)
{//=====================================================
int ix;
@@ -217,11 +258,11 @@ static void SetToneAdjust(voice_t *voice, int *tone_pts)
height2 = tone_pts[pt+1];
if((freq2 - freq1) > 0)
{
- rate = double(height2-height1)/(freq2-freq1);
+ rate = (double)(height2-height1)/(freq2-freq1);
for(ix=freq1; ix<freq2; ix++)
{
- y = height1 + int(rate * (ix-freq1));
+ y = height1 + (int)(rate * (ix-freq1));
if(y > 255)
y = 255;
voice->tone_adjust[ix] = y;
@@ -242,9 +283,9 @@ void ReadTonePoints(char *string, int *tone_pts)
tone_pts[ix] = -1;
sscanf(string,"%d %d %d %d %d %d %d %d %d %d",
- &tone_pts[0],&tone_pts[1],&tone_pts[2],&tone_pts[3],
- &tone_pts[4],&tone_pts[5],&tone_pts[6],&tone_pts[7],
- &tone_pts[8],&tone_pts[9]);
+ &tone_pts[0],&tone_pts[1],&tone_pts[2],&tone_pts[3],
+ &tone_pts[4],&tone_pts[5],&tone_pts[6],&tone_pts[7],
+ &tone_pts[8],&tone_pts[9]);
}
@@ -269,7 +310,7 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*lea
espeak_VOICE *voice_data;
int priority;
int age;
- int n_variants = 3; // default, number of variants of this voice before using another voice
+ int n_variants = 4; // default, number of variants of this voice before using another voice
int gender;
#ifdef PLATFORM_WINDOWS
@@ -298,8 +339,7 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*lea
while(isspace(*p)) p++;
strncpy0(vname,p,sizeof(vname));
}
- else
- if(memcmp(linebuf,"language",8)==0)
+ else if(memcmp(linebuf,"language",8)==0)
{
priority = DEFAULT_LANGUAGE_PRIORITY;
vlanguage[0] = 0;
@@ -316,13 +356,11 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*lea
n_languages++;
}
}
- else
- if(memcmp(linebuf,"gender",6)==0)
+ else if(memcmp(linebuf,"gender",6)==0)
{
sscanf(&linebuf[6],"%s %d",vgender,&age);
}
- else
- if(memcmp(linebuf,"variants",8)==0)
+ else if(memcmp(linebuf,"variants",8)==0)
{
sscanf(&linebuf[8],"%d",&n_variants);
}
@@ -369,29 +407,38 @@ void VoiceReset(int tone_only)
// Set voice to the default values
int pk;
- static unsigned char default_heights[N_PEAKS] = {128,128,120,120,110,110,128,128,128};
- static unsigned char default_widths[N_PEAKS] = {128,128,128,160,171,171,128,128,128};
+ static unsigned char default_heights[N_PEAKS] = {130,128,120,116,100,100,128,128,128}; // changed for v.1.47
+ static unsigned char default_widths[N_PEAKS] = {140,128,128,160,171,171,128,128,128};
+// static unsigned char default_heights[N_PEAKS] = {128,128,120,120,110,110,128,128,128}; // previous version
+// static unsigned char default_widths[N_PEAKS] = {128,128,128,160,171,171,128,128,128};
static int breath_widths[N_PEAKS] = {0,200,200,400,400,400,600,600,600};
- // default is: pitch 82,118
-// voice->pitch_base = 0x49000; // default, 73 << 12;
-// voice->pitch_range = 0x0f30; // default = 0x1000
+ // default is: pitch 80,118
voice->pitch_base = 0x47000;
- voice->pitch_range = 3996;
+ voice->pitch_range = 4104;
+
+// default is: pitch 80,117
+// voice->pitch_base = 0x47000;
+// voice->pitch_range = 3996;
voice->formant_factor = 256;
+ voice->speed_percent = 100;
voice->echo_delay = 0;
voice->echo_amp = 0;
voice->flutter = 64;
voice->n_harmonic_peaks = 5;
voice->peak_shape = 0;
voice->voicing = 64;
- voice->consonant_amp = 100;
+ voice->consonant_amp = 90; // change from 100 to 90 for v.1.47
voice->consonant_ampv = 100;
+ voice->samplerate = samplerate_native;
memset(voice->klattv,0,sizeof(voice->klattv));
- memset(speed.fast_settings,0,sizeof(speed.fast_settings));
+
+ speed.fast_settings[0] = 450;
+ speed.fast_settings[1] = 800;
+ speed.fast_settings[2] = 175;
#ifdef PLATFORM_RISCOS
voice->roughness = 1;
@@ -412,13 +459,12 @@ void VoiceReset(int tone_only)
// adjust formant smoothing depending on sample rate
formant_rate[pk] = (formant_rate_22050[pk] * 22050)/samplerate;
}
- voice->height[2] = 240; // reduce F2 slightly
// This table provides the opportunity for tone control.
// Adjustment of harmonic amplitudes, steps of 8Hz
// value of 128 means no change
// memset(voice->tone_adjust,128,sizeof(voice->tone_adjust));
-SetToneAdjust(voice,tone_points);
+ SetToneAdjust(voice,tone_points);
// default values of speed factors
voice->speedf1 = 256;
@@ -452,11 +498,11 @@ static void VoiceFormant(char *p)
return;
if(freq >= 0)
- voice->freq[formant] = int(freq * 2.56001);
+ voice->freq[formant] = (int)(freq * 2.56001);
if(height >= 0)
- voice->height[formant] = int(height * 2.56001);
+ voice->height[formant] = (int)(height * 2.56001);
if(width >= 0)
- voice->width[formant] = int(width * 2.56001);
+ voice->width[formant] = (int)(width * 2.56001);
voice->freqadd[formant] = freqadd;
}
@@ -490,8 +536,24 @@ static void PhonemeReplacement(int type, char *p)
static int Read8Numbers(char *data_in,int *data)
{//=============================================
// Read 8 integer numbers
+ memset(data, 0, 8+sizeof(int));
return(sscanf(data_in,"%d %d %d %d %d %d %d %d",
- &data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7]));
+ &data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7]));
+}
+
+
+static unsigned int StringToWord2(const char *string)
+{//======================================================
+// Convert a language name string to a word such as L('e','n')
+ int ix;
+ int c;
+ unsigned int value = 0;
+
+ for(ix=0; (ix<4) && ((c = string[ix]) != 0); ix++)
+ {
+ value = (value << 8) | (c & 0xff);
+ }
+ return(value);
}
@@ -503,13 +565,12 @@ voice_t *LoadVoice(const char *vname, int control)
// bit 4 1 = vname = full path
FILE *f_voice = NULL;
- keywtab_t *k;
char *p;
int key;
int ix;
int n;
int value;
- int error = 0;
+ int value2;
int langix = 0;
int tone_only = control & 2;
int language_set = 0;
@@ -527,26 +588,35 @@ voice_t *LoadVoice(const char *vname, int control)
char translator_name[40];
char new_dictionary[40];
char phonemes_name[40];
+ char option_name[40];
const char *language_type;
- char buf[200];
+ char buf[sizeof(path_home)+30];
char path_voices[sizeof(path_home)+12];
- char langname[4];
+ int dict_min = 0;
int stress_amps[8];
int stress_lengths[8];
int stress_add[8];
+ char names[8][40];
+ char name1[40];
+ char name2[80];
+ const char *voice_dir;
int pitch1;
int pitch2;
- static char voice_identifier[40]; // file name for voice_selected
- static char voice_name[40]; // voice name for voice_selected
- static char voice_languages[100]; // list of languages and priorities for voice_selected
+ static char voice_identifier[40]; // file name for current_voice_selected
+ static char voice_name[40]; // voice name for current_voice_selected
+ static char voice_languages[100]; // list of languages and priorities for current_voice_selected
- strcpy(voicename,vname);
- if(voicename[0]==0)
- strcpy(voicename,"default");
+ // which directory to look for a named voice. List of voice names, must end in a space.
+ static const char *voices_asia =
+ "az bn fa fa-pin hi hy hy-west id ka kn ku ml ms ne pa ta te tr vi vi-hue vi-sgn zh zh-yue ";
+ static const char *voices_europe =
+ "an bg bs ca cs cy da de el en en-us es et fi fr fr-be ga hr hu is it lt lv mk nl no pl pt-pt ro ru sk sq sr sv ";
+
+ strncpy0(voicename, vname, sizeof(voicename));
if(control & 0x10)
{
strcpy(buf,vname);
@@ -555,21 +625,36 @@ voice_t *LoadVoice(const char *vname, int control)
}
else
{
+ if(voicename[0]==0)
+ strcpy(voicename,"default");
+
sprintf(path_voices,"%s%cvoices%c",path_home,PATHSEP,PATHSEP);
- sprintf(buf,"%s%s",path_voices,voicename);
+ sprintf(buf,"%s%s",path_voices,voicename); // first, look in the main voices directory
if(GetFileLength(buf) <= 0)
{
- // look for the voice in a sub-directory of the language name
- langname[0] = voicename[0];
- langname[1] = voicename[1];
- langname[2] = 0;
- sprintf(buf,"%s%s%c%s",path_voices,langname,PATHSEP,voicename);
-
- if(GetFileLength(buf) <= 0)
+ // then look in the appropriate subdirectory
+ if((voicename[0]=='m') && (voicename[1]=='b'))
+ {
+ voice_dir = "mb"; // mbrola voices
+ }
+ else
{
- // look in "test" sub-directory
- sprintf(buf,"%stest%c%s",path_voices,PATHSEP,voicename);
+ sprintf(name2, "%s ", voicename);
+ if(strstr(voices_europe, voicename) != NULL)
+ voice_dir = "europe";
+ else if(strstr(voices_asia, voicename) != NULL)
+ voice_dir = "asia";
+ else
+ voice_dir = "other";
+
+ sprintf(buf,"%s%s%c%s", path_voices,voice_dir,PATHSEP,voicename);
+
+ if(GetFileLength(buf) <= 0)
+ {
+ // if not found, look in "test" sub-directory
+ sprintf(buf,"%stest%c%s",path_voices,PATHSEP,voicename);
+ }
}
}
}
@@ -604,9 +689,9 @@ voice_t *LoadVoice(const char *vname, int control)
voice_name[0] = 0;
voice_languages[0] = 0;
- voice_selected.identifier = voice_identifier;
- voice_selected.name = voice_name;
- voice_selected.languages = voice_languages;
+ current_voice_selected.identifier = voice_identifier;
+ current_voice_selected.name = voice_name;
+ current_voice_selected.languages = voice_languages;
}
else
{
@@ -631,61 +716,54 @@ voice_t *LoadVoice(const char *vname, int control)
if(buf[0] == 0) continue;
- key = 0;
- for(k=keyword_tab; k->mnem != NULL; k++)
- {
- if(strcmp(buf,k->mnem)==0)
- {
- key = k->data;
- break;
- }
- }
+ key = LookupMnem(keyword_tab, buf);
switch(key)
{
case V_LANGUAGE:
+ {
+ unsigned int len;
+ int priority;
+
+ if(tone_only)
+ break;
+
+ priority = DEFAULT_LANGUAGE_PRIORITY;
+ language_name[0] = 0;
+
+ sscanf(p,"%s %d",language_name,&priority);
+ if(strcmp(language_name,"variant") == 0)
+ break;
+
+ len = strlen(language_name) + 2;
+ // check for space in languages[]
+ if(len < (sizeof(voice_languages)-langix-1))
{
- unsigned int len;
- int priority;
+ voice_languages[langix] = priority;
- if(tone_only)
- break;
-
- priority = DEFAULT_LANGUAGE_PRIORITY;
- language_name[0] = 0;
-
- sscanf(p,"%s %d",language_name,&priority);
- if(strcmp(language_name,"variant") == 0)
- break;
-
- len = strlen(language_name) + 2;
- // check for space in languages[]
- if(len < (sizeof(voice_languages)-langix-1))
- {
- voice_languages[langix] = priority;
-
- strcpy(&voice_languages[langix+1],language_name);
- langix += len;
- }
-
- // only act on the first language line
- if(language_set == 0)
- {
- language_type = strtok(language_name,"-");
- language_set = 1;
- strcpy(translator_name,language_type);
- strcpy(new_dictionary,language_type);
- strcpy(phonemes_name,language_type);
- SelectPhonemeTableName(phonemes_name);
-
- if(new_translator != NULL)
- DeleteTranslator(new_translator);
-
- new_translator = SelectTranslator(translator_name);
- langopts = &new_translator->langopts;
- }
+ strcpy(&voice_languages[langix+1],language_name);
+ langix += len;
}
- break;
+
+ // only act on the first language line
+ if(language_set == 0)
+ {
+ language_type = strtok(language_name,"-");
+ language_set = 1;
+ strcpy(translator_name,language_type);
+ strcpy(new_dictionary,language_type);
+ strcpy(phonemes_name,language_type);
+ SelectPhonemeTableName(phonemes_name);
+
+ if(new_translator != NULL)
+ DeleteTranslator(new_translator);
+
+ new_translator = SelectTranslator(translator_name);
+ langopts = &new_translator->langopts;
+ strncpy0(voice->language_name, language_name, sizeof(voice->language_name));
+ }
+ }
+ break;
case V_NAME:
if(tone_only == 0)
@@ -696,14 +774,14 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_GENDER:
- {
- int age;
- char vgender[80];
- sscanf(p,"%s %d",vgender,&age);
- voice_selected.gender = LookupMnem(genders,vgender);
- voice_selected.age = age;
- }
- break;
+ {
+ int age = 0;
+ char vgender[80];
+ sscanf(p,"%s %d",vgender,&age);
+ current_voice_selected.gender = LookupMnem(genders,vgender);
+ current_voice_selected.age = age;
+ }
+ break;
case V_TRANSLATOR:
if(tone_only) break;
@@ -711,7 +789,7 @@ voice_t *LoadVoice(const char *vname, int control)
sscanf(p,"%s",translator_name);
if(new_translator != NULL)
- DeleteTranslator(new_translator);
+ DeleteTranslator(new_translator);
new_translator = SelectTranslator(translator_name);
langopts = &new_translator->langopts;
@@ -730,16 +808,16 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_PITCH:
- {
- double factor;
- // default is pitch 82 118
- n = sscanf(p,"%d %d",&pitch1,&pitch2);
- voice->pitch_base = (pitch1 - 9) << 12;
- voice->pitch_range = (pitch2 - pitch1) * 108;
- factor = double(pitch1 - 82)/82;
- voice->formant_factor = (int)((1+factor/4) * 256); // nominal formant shift for a different voice pitch
- }
- break;
+ {
+ double factor;
+ // default is pitch 82 118
+ n = sscanf(p,"%d %d",&pitch1,&pitch2);
+ voice->pitch_base = (pitch1 - 9) << 12;
+ voice->pitch_range = (pitch2 - pitch1) * 108;
+ factor = (double)(pitch1 - 82)/82;
+ voice->formant_factor = (int)((1+factor/4) * 256); // nominal formant shift for a different voice pitch
+ }
+ break;
case V_STRESSLENGTH: // stressLength
stress_lengths_set = Read8Numbers(p,stress_lengths);
@@ -759,18 +837,52 @@ voice_t *LoadVoice(const char *vname, int control)
langopts->intonation_group = option_tone_flags & 0xff;
break;
+ case V_TUNES:
+ n = sscanf(p,"%s %s %s %s %s %s",names[0],names[1],names[2],names[3],names[4],names[5]);
+ langopts->intonation_group = 0;
+ for(ix=0; ix<n; ix++)
+ {
+ if(strcmp(names[ix],"NULL")==0)
+ continue;
+
+ if((value = LookupTune(names[ix])) < 0)
+ fprintf(stderr,"Unknown tune '%s'\n",names[ix]);
+ else
+ langopts->tunes[ix] = value;
+ }
+ break;
+
case V_DICTRULES: // conditional dictionary rules and list entries
+ case V_NUMBERS:
+ case V_STRESSOPT:
+ // expect a list of numbers
while(*p != 0)
{
while(isspace(*p)) p++;
n = -1;
- if(((n = atoi(p)) > 0) && (n < 32))
+ if((n = atoi(p)) > 0)
{
p++;
- conditional_rules |= (1 << n);
+ if(n < 32)
+ {
+ if(key==V_DICTRULES)
+ conditional_rules |= (1 << n);
+ else if(key==V_NUMBERS)
+ langopts->numbers |= (1 << n);
+ else if(key==V_STRESSOPT)
+ langopts->stress_flags |= (1 << n);
+ }
+ else
+ {
+ if((key==V_NUMBERS) && (n < 64))
+ langopts->numbers |= (1 << (n-32));
+ else
+ fprintf(stderr,"Bad option number %d\n", n);
+ }
}
while(isalnum(*p)) p++;
}
+ ProcessLanguageOptions(langopts);
break;
case V_REPLACE:
@@ -789,9 +901,9 @@ voice_t *LoadVoice(const char *vname, int control)
case V_STRESSRULE:
sscanf(p,"%d %d %d %d",&langopts->stress_rule,
- &langopts->stress_flags,
- &langopts->unstressed_wd1,
- &langopts->unstressed_wd2);
+ &langopts->stress_flags,
+ &langopts->unstressed_wd1,
+ &langopts->unstressed_wd2);
break;
case V_CHARSET:
@@ -799,15 +911,17 @@ voice_t *LoadVoice(const char *vname, int control)
new_translator->charset_a0 = charsets[value];
break;
- case V_NUMBERS:
- sscanf(p,"%d %d",&langopts->numbers,&langopts->numbers2);
- break;
-
case V_OPTION:
- if(sscanf(p,"%d %d",&ix,&value) == 2)
+ value2 = 0;
+ if(((sscanf(p,"%s %d %d",option_name,&value,&value2) >= 2) && ((ix = LookupMnem(options_tab, option_name)) >= 0)) ||
+ ((sscanf(p,"%d %d %d",&ix,&value,&value2) >= 2) && (ix < N_LOPTS)))
+ {
+ langopts->param[ix] = value;
+ langopts->param2[ix] = value2;
+ }
+ else
{
- if((ix >= 0) && (ix < N_LOPTS))
- langopts->param[ix] = value;
+ fprintf(stderr,"Bad voice option: %s %s\n",buf,p);
}
break;
@@ -841,12 +955,12 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_TONE:
- {
- int tone_data[12];
- ReadTonePoints(p,tone_data);
- SetToneAdjust(voice,tone_data);
- }
- break;
+ {
+ int tone_data[12];
+ ReadTonePoints(p,tone_data);
+ SetToneAdjust(voice,tone_data);
+ }
+ break;
case V_VOICING:
if(sscanf(p,"%d",&value)==1)
@@ -854,33 +968,39 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_BREATH:
- voice->breath[0] = Read8Numbers(p,&voice->breath[1]);
- for(ix=1; ix<8; ix++)
- {
- if(ix % 2)
- voice->breath[ix] = -voice->breath[ix];
- }
+ voice->breath[0] = Read8Numbers(p,&voice->breath[1]);
+ for(ix=1; ix<8; ix++)
+ {
+ if(ix % 2)
+ voice->breath[ix] = -voice->breath[ix];
+ }
break;
case V_BREATHW:
- voice->breathw[0] = Read8Numbers(p,&voice->breathw[1]);
+ voice->breathw[0] = Read8Numbers(p,&voice->breathw[1]);
break;
case V_CONSONANTS:
value = sscanf(p,"%d %d",&voice->consonant_amp, &voice->consonant_ampv);
break;
+ case V_SPEED:
+ sscanf(p,"%d",&voice->speed_percent);
+ break;
+
case V_MBROLA:
- {
- int srate = 16000;
- char name[40];
- char phtrans[40];
+ {
+ int srate = 16000;
- phtrans[0] = 0;
- sscanf(p,"%s %s %d",name,phtrans,&srate);
- LoadMbrolaTable(name,phtrans,srate);
+ name2[0] = 0;
+ sscanf(p,"%s %s %d",name1,name2,&srate);
+ if(LoadMbrolaTable(name1,name2,srate) != EE_OK)
+ {
+ fprintf(stderr,"mbrola voice not found\n");
}
- break;
+ voice->samplerate = srate;
+ }
+ break;
case V_KLATT:
voice->klattv[0] = 1; // default source: IMPULSIVE
@@ -890,7 +1010,48 @@ voice_t *LoadVoice(const char *vname, int control)
case V_FAST:
Read8Numbers(p,speed.fast_settings);
- SetSpeed(2);
+ SetSpeed(3);
+ break;
+
+ case V_DICTMIN:
+ sscanf(p,"%d",&dict_min);
+ break;
+
+ case V_ALPHABET2:
+ {
+ ALPHABET *alphabet;
+ name1[0] = name2[0] = 0;
+ sscanf(p, "%s %s", name1, name2);
+
+ if(strcmp(name1, "latin") == 0)
+ {
+ strncpy0(langopts->ascii_language,name2,sizeof(langopts->ascii_language));
+ }
+ else if((alphabet = AlphabetFromName(name1)) != 0)
+ {
+ langopts->alt_alphabet = alphabet->offset;
+ langopts->alt_alphabet_lang = StringToWord2(name2);
+ }
+ else
+ {
+ fprintf(stderr,"alphabet name '%s' not found\n", name1);
+ }
+ }
+ break;
+
+ case V_DICTDIALECT:
+ // specify a dialect to use for foreign words, eg, en-us for _^_EN
+ if(sscanf(p, "%s", name1) == 1)
+ {
+ if((ix = LookupMnem(dict_dialects, name1)) > 0)
+ {
+ langopts->dict_dialect |= (1 << ix);
+ }
+ else
+ {
+ fprintf(stderr, "dictdialect name '%s' not recognized\n", name1);
+ }
+ }
break;
default:
@@ -914,6 +1075,8 @@ voice_t *LoadVoice(const char *vname, int control)
new_translator = SelectTranslator(translator_name);
}
+ SetSpeed(3); // for speed_percent
+
for(ix=0; ix<N_PEAKS; ix++)
{
voice->freq2[ix] = voice->freq[ix];
@@ -930,9 +1093,12 @@ voice_t *LoadVoice(const char *vname, int control)
if((ix = SelectPhonemeTableName(phonemes_name)) < 0)
{
fprintf(stderr,"Unknown phoneme table: '%s'\n",phonemes_name);
+ ix = 0;
}
voice->phoneme_tab_ix = ix;
- error = LoadDictionary(new_translator, new_dictionary, control & 4);
+ new_translator->phoneme_tab_ix = ix;
+ new_translator->dict_min_size = dict_min;
+ LoadDictionary(new_translator, new_dictionary, control & 4);
if(dictionary_name[0]==0)
return(NULL); // no dictionary loaded
@@ -956,6 +1122,7 @@ voice_t *LoadVoice(const char *vname, int control)
translator = new_translator;
}
+
// relative lengths of different stress syllables
for(ix=0; ix<stress_lengths_set; ix++)
{
@@ -975,37 +1142,39 @@ voice_t *LoadVoice(const char *vname, int control)
} // end of LoadVoice
-static char *ExtractVoiceVariantName(char *vname, int variant_num)
-{//===============================================================
+static char *ExtractVoiceVariantName(char *vname, int variant_num, int add_dir)
+{//===========================================================================
// Remove any voice variant suffix (name or number) from a voice name
// Returns the voice variant name
char *p;
- static char variant_name[20];
+ static char variant_name[40];
char variant_prefix[5];
variant_name[0] = 0;
sprintf(variant_prefix,"!v%c",PATHSEP);
+ if(add_dir == 0)
+ variant_prefix[0] = 0;
if(vname != NULL)
{
if((p = strchr(vname,'+')) != NULL)
{
// The voice name has a +variant suffix
+ variant_num = 0;
*p++ = 0; // delete the suffix from the voice name
- if(isdigit(*p))
+ if(IsDigit09(*p))
{
variant_num = atoi(p); // variant number
}
else
{
// voice variant name, not number
- strcpy(variant_name,variant_prefix);
- strncpy0(&variant_name[3],p,sizeof(variant_name)-3);
- }
+ sprintf(variant_name, "%s%s", variant_prefix, p);
+ }
}
}
-
+
if(variant_num > 0)
{
if(variant_num < 10)
@@ -1029,7 +1198,7 @@ voice_t *LoadVoiceVariant(const char *vname, int variant_num)
char buf[60];
strncpy0(buf,vname,sizeof(buf));
- variant_name = ExtractVoiceVariantName(buf,variant_num);
+ variant_name = ExtractVoiceVariantName(buf,variant_num, 1);
if((v = LoadVoice(buf,0)) == NULL)
return(NULL);
@@ -1087,10 +1256,10 @@ static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int s
p = voice->languages; // list of languages+dialects for which this voice is suitable
- if(strcmp(spec_language,"mbrola")==0)
+ if(spec_n_parts < 0)
{
- // only list mbrola voices
- if(memcmp(voice->identifier,"mb/",3) == 0)
+ // match on the subdirectory
+ if(memcmp(voice->identifier, spec_language, spec_lang_len) == 0)
return(100);
return(0);
}
@@ -1168,15 +1337,14 @@ static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int s
// match on voice name
score += 500;
}
- else
- if(strcmp(voice_spec->name,voice->identifier)==0)
+ else if(strcmp(voice_spec->name,voice->identifier)==0)
{
score += 400;
}
}
if(((voice_spec->gender == 1) || (voice_spec->gender == 2)) &&
- ((voice->gender == 1) || (voice->gender == 2)))
+ ((voice->gender == 1) || (voice->gender == 2)))
{
if(voice_spec->gender == voice->gender)
score += 50;
@@ -1224,6 +1392,7 @@ static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int
int lang_len=0;
espeak_VOICE *vp;
char language[80];
+ char buf[sizeof(path_home)+80];
// count number of parts in the specified language
if((voice_select->languages != NULL) && (voice_select->languages[0] != 0))
@@ -1236,6 +1405,26 @@ static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int
n_parts++;
}
}
+
+ if((n_parts == 1) && (control & 1))
+ {
+ if(strcmp(language, "mbrola") == 0)
+ {
+ language[2] = 0; // truncate to "mb"
+ lang_len = 2;
+ }
+
+ sprintf(buf, "%s/voices/%s", path_home, language);
+ if(GetFileLength(buf) == -2)
+ {
+ // A subdirectory name has been specified. List all the voices in that subdirectory
+ language[lang_len++] = PATHSEP;
+ language[lang_len] = 0;
+ n_parts = -1;
+ }
+
+ }
+
// select those voices which match the specified language
nv = 0;
for(ix=0; ix<n_voices_list; ix++)
@@ -1257,7 +1446,7 @@ static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int
return(0);
// sort the selected voices by their score
- qsort(voices,nv,sizeof(espeak_VOICE *),VoiceScoreSorter);
+ qsort(voices,nv,sizeof(espeak_VOICE *),(int (__cdecl *)(const void *,const void *))VoiceScoreSorter);
return(nv);
} // end of SetVoiceScores
@@ -1265,15 +1454,17 @@ static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int
-espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
-{//=====================================================================
+espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name2)
+{//======================================================================
int ix;
int match_fname = -1;
int match_fname2 = -1;
int match_name = -1;
- const char *id;
+ const char *id; // this is the filename within espeak-data/voices
+ char *variant_name;
int last_part_len;
char last_part[41];
+ char name[40];
if(voices == NULL)
{
@@ -1282,6 +1473,13 @@ espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
voices = voices_list;
}
+ strncpy0(name, name2, sizeof(name));
+ if((variant_name = strchr(name, '+')) != NULL)
+ {
+ *variant_name = 0;
+ variant_name++;
+ }
+
sprintf(last_part,"%c%s",PATHSEP,name);
last_part_len = strlen(last_part);
@@ -1293,14 +1491,16 @@ espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
break;
}
else
- if(strcmp(name,id = voices[ix]->identifier)==0)
{
- match_fname = ix; // matching identifier, use this if no matching name
- }
- else
- if(strcmp(last_part,&id[strlen(id)-last_part_len])==0)
- {
- match_fname2 = ix;
+ id = voices[ix]->identifier;
+ if(strcmp(name, id)==0)
+ {
+ match_fname = ix; // matching identifier, use this if no matching name
+ }
+ else if(strcmp(last_part,&id[strlen(id)-last_part_len])==0)
+ {
+ match_fname2 = ix;
+ }
}
}
@@ -1352,15 +1552,15 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
{
// no language is specified. Get language from the named voice
static char buf[60];
-
+
if(voice_select2.name == NULL)
{
if((voice_select2.name = voice_select2.identifier) == NULL)
voice_select2.name = "default";
}
-
+
strncpy0(buf,voice_select2.name,sizeof(buf));
- variant_name = ExtractVoiceVariantName(buf,0);
+ variant_name = ExtractVoiceVariantName(buf,0,0);
vp = SelectVoiceByName(voices_list,buf);
if(vp != NULL)
@@ -1371,7 +1571,7 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
{
if(variant_name[0] != 0)
{
- sprintf(voice_id,"%s+%s",vp->identifier,&variant_name[3]); // omit the !v/ from variant_name
+ sprintf(voice_id,"%s+%s", vp->identifier, variant_name);
return(voice_id);
}
@@ -1394,8 +1594,7 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
gender = 0;
if((voice_select2.gender == 2) || ((voice_select2.age > 0) && (voice_select2.age < 13)))
gender = 2;
- else
- if(voice_select2.gender == 1)
+ else if(voice_select2.gender == 1)
gender = 1;
#define AGE_OLD 60
@@ -1413,6 +1612,7 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
vp = voices[ix];
// is the main voice the required gender?
skip=0;
+
if((gender != 0) && (vp->gender != gender))
{
skip=1;
@@ -1421,9 +1621,10 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
{
skip=1;
}
+
if(skip==0)
{
- voices2[ix2++] = vp;
+ voices2[ix2++] = vp;
}
for(j=0; (j < vp->xx1) && (n_variants < N_VOICE_VARIANTS);)
@@ -1452,12 +1653,14 @@ char const *SelectVoice(espeak_VOICE *voice_select, int *found)
}
// index the sorted list by the required variant number
+ if(ix2 == 0)
+ return(NULL);
vp = voices2[voice_select2.variant % ix2];
if(vp->variant != 0)
{
- variant_name = ExtractVoiceVariantName(NULL,vp->variant);
- sprintf(voice_id,"%s+%s",vp->identifier,&variant_name[3]);
+ variant_name = ExtractVoiceVariantName(NULL, vp->variant, 0);
+ sprintf(voice_id,"%s+%s", vp->identifier, variant_name);
return(voice_id);
}
@@ -1508,10 +1711,10 @@ static void GetVoices(const char *path)
}
else
{
- // a regular line, add it to the voices list
+ // a regular line, add it to the voices list
if((f_voice = fopen(fname,"r")) == NULL)
continue;
-
+
// pass voice file name within the voices directory
voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, &buf[20]);
fclose(f_voice);
@@ -1524,8 +1727,8 @@ static void GetVoices(const char *path)
}
#else
#ifdef PLATFORM_WINDOWS
- WIN32_FIND_DATAA FindFileData;
- HANDLE hFind = INVALID_HANDLE_VALUE;
+ WIN32_FIND_DATAA FindFileData;
+ HANDLE hFind = INVALID_HANDLE_VALUE;
#undef UNICODE // we need FindFirstFileA() which takes an 8-bit c-string
sprintf(fname,"%s\\*",path);
@@ -1534,29 +1737,33 @@ static void GetVoices(const char *path)
return;
do {
- sprintf(fname,"%s%c%s",path,PATHSEP,FindFileData.cFileName);
-
- ftype = GetFileLength(fname);
+ if(n_voices_list >= (N_VOICES_LIST-2))
+ break; // voices list is full
- if((ftype == -2) && (FindFileData.cFileName[0] != '.'))
+ if(FindFileData.cFileName[0] != '.')
{
- // a sub-sirectory
- GetVoices(fname);
- }
- else
- if(ftype > 0)
- {
- // a regular line, add it to the voices list
- if((f_voice = fopen(fname,"r")) == NULL)
- continue;
-
- // pass voice file name within the voices directory
- voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, FindFileData.cFileName);
- fclose(f_voice);
+ sprintf(fname,"%s%c%s",path,PATHSEP,FindFileData.cFileName);
+ ftype = GetFileLength(fname);
- if(voice_data != NULL)
+ if(ftype == -2)
{
- voices_list[n_voices_list++] = voice_data;
+ // a sub-sirectory
+ GetVoices(fname);
+ }
+ else if(ftype > 0)
+ {
+ // a regular line, add it to the voices list
+ if((f_voice = fopen(fname,"r")) == NULL)
+ continue;
+
+ // pass voice file name within the voices directory
+ voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, FindFileData.cFileName);
+ fclose(f_voice);
+
+ if(voice_data != NULL)
+ {
+ voices_list[n_voices_list++] = voice_data;
+ }
}
}
} while(FindNextFileA(hFind, &FindFileData) != 0);
@@ -1574,22 +1781,24 @@ static void GetVoices(const char *path)
if(n_voices_list >= (N_VOICES_LIST-2))
break; // voices list is full
+ if(ent->d_name[0] == '.')
+ continue;
+
sprintf(fname,"%s%c%s",path,PATHSEP,ent->d_name);
ftype = GetFileLength(fname);
- if((ftype == -2) && (ent->d_name[0] != '.'))
+ if(ftype == -2)
{
// a sub-sirectory
GetVoices(fname);
}
- else
- if(ftype > 0)
+ else if(ftype > 0)
{
- // a regular line, add it to the voices list
+ // a regular line, add it to the voices list
if((f_voice = fopen(fname,"r")) == NULL)
continue;
-
+
// pass voice file name within the voices directory
voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, ent->d_name);
fclose(f_voice);
@@ -1610,15 +1819,23 @@ static void GetVoices(const char *path)
espeak_ERROR SetVoiceByName(const char *name)
{//=========================================
espeak_VOICE *v;
+ int ix;
espeak_VOICE voice_selector;
char *variant_name;
static char buf[60];
strncpy0(buf,name,sizeof(buf));
- variant_name = ExtractVoiceVariantName(buf,0);
+
+ variant_name = ExtractVoiceVariantName(buf, 0, 1);
+
+ for(ix=0; ; ix++)
+ {
+ // convert voice name to lower case (ascii)
+ if((buf[ix] = tolower(buf[ix])) == 0)
+ break;
+ }
memset(&voice_selector,0,sizeof(voice_selector));
-// voice_selector.name = buf;
voice_selector.name = (char *)name; // include variant name in voice stack ??
// first check for a voice with this filename
@@ -1632,7 +1849,8 @@ espeak_ERROR SetVoiceByName(const char *name)
}
DoVoiceChange(voice);
- SetVoiceStack(&voice_selector);
+ voice_selector.languages = voice->language_name;
+ SetVoiceStack(&voice_selector, variant_name);
return(EE_OK);
}
@@ -1648,7 +1866,8 @@ espeak_ERROR SetVoiceByName(const char *name)
LoadVoice(variant_name,2);
}
DoVoiceChange(voice);
- SetVoiceStack(&voice_selector);
+ voice_selector.languages = voice->language_name;
+ SetVoiceStack(&voice_selector, variant_name);
return(EE_OK);
}
}
@@ -1669,12 +1888,25 @@ espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector)
LoadVoiceVariant(voice_id,0);
DoVoiceChange(voice);
- SetVoiceStack(voice_selector);
+ SetVoiceStack(voice_selector, "");
return(EE_OK);
} // end of SetVoiceByProperties
+void FreeVoiceList(void)
+{//=================
+ int ix;
+ for(ix=0; ix<n_voices_list; ix++)
+ {
+ if(voices_list[ix] != NULL)
+ {
+ free(voices_list[ix]);
+ voices_list[ix] = NULL;
+ }
+ }
+ n_voices_list = 0;
+}
//=======================================================================
@@ -1683,32 +1915,40 @@ espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector)
#pragma GCC visibility push(default)
-const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
+ESPEAK_API const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
{//========================================================================
-#ifndef PLATFORM_RISCOS
- int ix;
- int j;
- espeak_VOICE *v;
- static espeak_VOICE *voices[N_VOICES_LIST];
char path_voices[sizeof(path_home)+12];
- // free previous voice list data
- for(ix=0; ix<n_voices_list; ix++)
+#ifdef PLATFORM_RISCOS
+ if(n_voices_list == 0)
{
- if(voices_list[ix] != NULL)
- free(voices_list[ix]);
+ sprintf(path_voices,"%s%cvoices",path_home,PATHSEP);
+ len_path_voices = strlen(path_voices)+1;
+ GetVoices(path_voices);
+ voices_list[n_voices_list] = NULL; // voices list terminator
}
- n_voices_list = 0;
+ return((const espeak_VOICE **)voices_list);
+
+#else
+ int ix;
+ int j;
+ espeak_VOICE *v;
+ static espeak_VOICE **voices = NULL;
+
+ // free previous voice list data
+ FreeVoiceList();
sprintf(path_voices,"%s%cvoices",path_home,PATHSEP);
len_path_voices = strlen(path_voices)+1;
GetVoices(path_voices);
voices_list[n_voices_list] = NULL; // voices list terminator
+ voices = (espeak_VOICE **)realloc(voices, sizeof(espeak_VOICE *)*(n_voices_list+1));
// sort the voices list
- qsort(voices_list,n_voices_list,sizeof(espeak_VOICE *),VoiceNameSorter);
+ qsort(voices_list,n_voices_list,sizeof(espeak_VOICE *),
+ (int (__cdecl *)(const void *,const void *))VoiceNameSorter);
if(voice_spec)
@@ -1718,11 +1958,12 @@ const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
}
else
{
- // list all: omit variant voices and mbrola voices
+ // list all: omit variant voices and mbrola voices and test voices
j = 0;
for(ix=0; (v = voices_list[ix]) != NULL; ix++)
{
- if((v->languages[0] != 0) && (strcmp(&v->languages[1],"variant") != 0) && (memcmp(v->identifier,"mb/",3) != 0))
+ if((v->languages[0] != 0) && (strcmp(&v->languages[1],"variant") != 0)
+ && (memcmp(v->identifier,"mb/",3) != 0) && (memcmp(v->identifier,"test/",5) != 0))
{
voices[j++] = v;
}
@@ -1731,14 +1972,13 @@ const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
}
return((const espeak_VOICE **)voices);
#endif
- return((const espeak_VOICE **)voices_list);
} // end of espeak_ListVoices
-espeak_VOICE *espeak_GetCurrentVoice(void)
+ESPEAK_API espeak_VOICE *espeak_GetCurrentVoice(void)
{//==================================================
- return(&voice_selected);
+ return(&current_voice_selected);
}
#pragma GCC visibility pop
diff --git a/navit/support/espeak/voices.h b/navit/support/espeak/voices.h
new file mode 100644
index 000000000..920de021a
--- /dev/null
+++ b/navit/support/espeak/voices.h
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (C) 2005 to 2010 by Jonathan Duddington *
+ * email: jonsd@users.sourceforge.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, see: *
+ * <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+void FreeVoiceList(void);
diff --git a/navit/support/espeak/wave.c b/navit/support/espeak/wave.c
index 364dcf577..591283665 100755..100644
--- a/navit/support/espeak/wave.c
+++ b/navit/support/espeak/wave.c
@@ -32,7 +32,9 @@
#include <time.h>
#include "portaudio.h"
-#ifndef PLATFORM_WINDOWS
+#ifdef PLATFORM_WINDOWS
+#include <windows.h>
+#else
#include <unistd.h>
#endif
#include "wave.h"
@@ -40,6 +42,15 @@
//<Definitions
+#ifdef NEED_STRUCT_TIMESPEC
+#define HAVE_STRUCT_TIMESPEC 1
+struct timespec {
+ long tv_sec;
+ long tv_nsec;
+};
+#endif /* HAVE_STRUCT_TIMESPEC */
+
+
enum {ONE_BILLION=1000000000};
#ifdef USE_PORTAUDIO
@@ -53,18 +64,161 @@ enum {ONE_BILLION=1000000000};
#endif
+
+
+#ifdef USE_PULSEAUDIO
+// create some wrappers for runtime detection
+
+// checked on wave_init
+static int pulse_running;
+
+// wave.cpp (this file)
+int wave_port_init(int);
+void* wave_port_open(const char* the_api);
+size_t wave_port_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize);
+int wave_port_close(void* theHandler);
+int wave_port_is_busy(void* theHandler);
+void wave_port_terminate();
+uint32_t wave_port_get_read_position(void* theHandler);
+uint32_t wave_port_get_write_position(void* theHandler);
+void wave_port_flush(void* theHandler);
+void wave_port_set_callback_is_output_enabled(t_wave_callback* cb);
+void* wave_port_test_get_write_buffer();
+int wave_port_get_remaining_time(uint32_t sample, uint32_t* time);
+
+// wave_pulse.cpp
+int is_pulse_running();
+int wave_pulse_init(int);
+void* wave_pulse_open(const char* the_api);
+size_t wave_pulse_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize);
+int wave_pulse_close(void* theHandler);
+int wave_pulse_is_busy(void* theHandler);
+void wave_pulse_terminate();
+uint32_t wave_pulse_get_read_position(void* theHandler);
+uint32_t wave_pulse_get_write_position(void* theHandler);
+void wave_pulse_flush(void* theHandler);
+void wave_pulse_set_callback_is_output_enabled(t_wave_callback* cb);
+void* wave_pulse_test_get_write_buffer();
+int wave_pulse_get_remaining_time(uint32_t sample, uint32_t* time);
+
+// wrappers
+int wave_init(int srate) {
+ pulse_running = is_pulse_running();
+
+ if (pulse_running)
+ return wave_pulse_init(srate);
+ else
+ return wave_port_init(srate);
+}
+
+void* wave_open(const char* the_api) {
+ if (pulse_running)
+ return wave_pulse_open(the_api);
+ else
+ return wave_port_open(the_api);
+}
+
+size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {
+ if (pulse_running)
+ return wave_pulse_write(theHandler, theMono16BitsWaveBuffer, theSize);
+ else
+ return wave_port_write(theHandler, theMono16BitsWaveBuffer, theSize);
+}
+
+int wave_close(void* theHandler) {
+ if (pulse_running)
+ return wave_pulse_close(theHandler);
+ else
+ return wave_port_close(theHandler);
+}
+
+int wave_is_busy(void* theHandler) {
+ if (pulse_running)
+ return wave_pulse_is_busy(theHandler);
+ else
+ return wave_port_is_busy(theHandler);
+}
+
+void wave_terminate() {
+ if (pulse_running)
+ wave_pulse_terminate();
+ else
+ wave_port_terminate();
+}
+
+uint32_t wave_get_read_position(void* theHandler) {
+ if (pulse_running)
+ return wave_pulse_get_read_position(theHandler);
+ else
+ return wave_port_get_read_position(theHandler);
+}
+
+uint32_t wave_get_write_position(void* theHandler) {
+ if (pulse_running)
+ return wave_pulse_get_write_position(theHandler);
+ else
+ return wave_port_get_write_position(theHandler);
+}
+
+void wave_flush(void* theHandler) {
+ if (pulse_running)
+ wave_pulse_flush(theHandler);
+ else
+ wave_port_flush(theHandler);
+}
+
+void wave_set_callback_is_output_enabled(t_wave_callback* cb) {
+ if (pulse_running)
+ wave_pulse_set_callback_is_output_enabled(cb);
+ else
+ wave_port_set_callback_is_output_enabled(cb);
+}
+
+void* wave_test_get_write_buffer() {
+ if (pulse_running)
+ return wave_pulse_test_get_write_buffer();
+ else
+ return wave_port_test_get_write_buffer();
+}
+
+int wave_get_remaining_time(uint32_t sample, uint32_t* time)
+{
+ if (pulse_running)
+ return wave_pulse_get_remaining_time(sample, time);
+ else
+ return wave_port_get_remaining_time(sample, time);
+}
+
+// rename functions to be wrapped
+#define wave_init wave_port_init
+#define wave_open wave_port_open
+#define wave_write wave_port_write
+#define wave_close wave_port_close
+#define wave_is_busy wave_port_is_busy
+#define wave_terminate wave_port_terminate
+#define wave_get_read_position wave_port_get_read_position
+#define wave_get_write_position wave_port_get_write_position
+#define wave_flush wave_port_flush
+#define wave_set_callback_is_output_enabled wave_port_set_callback_is_output_enabled
+#define wave_test_get_write_buffer wave_port_test_get_write_buffer
+#define wave_get_remaining_time wave_port_get_remaining_time
+
+#endif // USE_PULSEAUDIO
+
+
static t_wave_callback* my_callback_is_output_enabled=NULL;
#define N_WAV_BUF 10
-#define SAMPLE_RATE 22050
+#define MAX_SAMPLE_RATE 22050
#define FRAMES_PER_BUFFER 512
-#define BUFFER_LENGTH (SAMPLE_RATE*2*sizeof(uint16_t))
-#define THRESHOLD (BUFFER_LENGTH/5)
+#define BUFFER_LENGTH (MAX_SAMPLE_RATE*2*sizeof(uint16_t))
+//#define THRESHOLD (BUFFER_LENGTH/5)
static char myBuffer[BUFFER_LENGTH];
-static char* myRead=NULL;
-static char* myWrite=NULL;
+static char* myRead=NULL;
+static char* myWrite=NULL;
static int out_channels=1;
static int my_stream_could_start=0;
+static int wave_samplerate;
static int mInCallbackFinishedState = false;
#if (USE_PORTAUDIO == 18)
@@ -80,7 +234,7 @@ static PaError pa_init_err=0;
// time measurement
// The read and write position audio stream in the audio stream are measured in ms.
-//
+//
// * When the stream is opened, myReadPosition and myWritePosition are cleared.
// * myWritePosition is updated in wave_write.
// * myReadPosition is updated in pa_callback (+ sample delay).
@@ -132,12 +286,12 @@ static void start_stream()
PaError err;
SHOW_TIME("start_stream");
- my_stream_could_start=0;
+ my_stream_could_start=0;
mInCallbackFinishedState = false;
err = Pa_StartStream(pa_stream);
SHOW("start_stream > Pa_StartStream=%d (%s)\n", err, Pa_GetErrorText(err));
-
+
#if USE_PORTAUDIO == 19
if(err == paStreamIsNotStopped)
{
@@ -168,89 +322,89 @@ static int pa_callback(void *inputBuffer, void *outputBuffer,
PaStreamCallbackFlags flags, void *userData )
#endif
{
- int aResult=0; // paContinue
- char* aWrite = myWrite;
- size_t n = out_channels*sizeof(uint16_t)*framesPerBuffer;
+ int aResult=0; // paContinue
+ char* aWrite = myWrite;
+ size_t n = out_channels*sizeof(uint16_t)*framesPerBuffer;
- myReadPosition += framesPerBuffer;
- SHOW("pa_callback > myReadPosition=%u, framesPerBuffer=%lu (n=0x%x) \n",(int)myReadPosition, framesPerBuffer, n);
+ myReadPosition += framesPerBuffer;
+ SHOW("pa_callback > myReadPosition=%u, framesPerBuffer=%lu (n=0x%x) \n",(int)myReadPosition, framesPerBuffer, n);
- if (aWrite >= myRead)
- {
- if((size_t)(aWrite - myRead) >= n)
- {
- memcpy(outputBuffer, myRead, n);
- myRead += n;
- }
- else
+ if (aWrite >= myRead)
{
- SHOW_TIME("pa_callback > underflow");
- aResult=1; // paComplete;
- mInCallbackFinishedState = true;
- size_t aUsedMem=0;
- aUsedMem = (size_t)(aWrite - myRead);
- if (aUsedMem)
- {
- memcpy(outputBuffer, myRead, aUsedMem);
- }
- char* p = (char*)outputBuffer + aUsedMem;
- memset(p, 0, n - aUsedMem);
- // myReadPosition += aUsedMem/(out_channels*sizeof(uint16_t));
- myRead = aWrite;
- }
- }
- else // myRead > aWrite
- {
- if ((size_t)(myBuffer + BUFFER_LENGTH - myRead) >= n)
- {
- memcpy(outputBuffer, myRead, n);
- myRead += n;
+ if((size_t)(aWrite - myRead) >= n)
+ {
+ memcpy(outputBuffer, myRead, n);
+ myRead += n;
+ }
+ else
+ {
+ SHOW_TIME("pa_callback > underflow");
+ aResult=1; // paComplete;
+ mInCallbackFinishedState = true;
+ size_t aUsedMem=0;
+ aUsedMem = (size_t)(aWrite - myRead);
+ if (aUsedMem)
+ {
+ memcpy(outputBuffer, myRead, aUsedMem);
+ }
+ char* p = (char*)outputBuffer + aUsedMem;
+ memset(p, 0, n - aUsedMem);
+ // myReadPosition += aUsedMem/(out_channels*sizeof(uint16_t));
+ myRead = aWrite;
+ }
}
- else if ((size_t)(aWrite + BUFFER_LENGTH - myRead) >= n)
+ else // myRead > aWrite
{
- int aTopMem = myBuffer + BUFFER_LENGTH - myRead;
- if (aTopMem)
- {
- SHOW("pa_callback > myRead=0x%x, aTopMem=0x%x\n",(int)myRead, (int)aTopMem);
- memcpy(outputBuffer, myRead, aTopMem);
- }
- int aRest = n - aTopMem;
- if (aRest)
- {
- SHOW("pa_callback > myRead=0x%x, aRest=0x%x\n",(int)myRead, (int)aRest);
- char* p = (char*)outputBuffer + aTopMem;
- memcpy(p, myBuffer, aRest);
- }
- myRead = myBuffer + aRest;
- }
- else
- {
- SHOW_TIME("pa_callback > underflow");
- aResult=1; // paComplete;
-
- int aTopMem = myBuffer + BUFFER_LENGTH - myRead;
- if (aTopMem)
- {
- SHOW("pa_callback > myRead=0x%x, aTopMem=0x%x\n",(int)myRead, (int)aTopMem);
- memcpy(outputBuffer, myRead, aTopMem);
- }
- int aRest = aWrite - myBuffer;
- if (aRest)
- {
- SHOW("pa_callback > myRead=0x%x, aRest=0x%x\n",(int)myRead, (int)aRest);
- char* p = (char*)outputBuffer + aTopMem;
- memcpy(p, myBuffer, aRest);
- }
-
- size_t aUsedMem = aTopMem + aRest;
- char* p = (char*)outputBuffer + aUsedMem;
- memset(p, 0, n - aUsedMem);
- // myReadPosition += aUsedMem/(out_channels*sizeof(uint16_t));
- myRead = aWrite;
+ if ((size_t)(myBuffer + BUFFER_LENGTH - myRead) >= n)
+ {
+ memcpy(outputBuffer, myRead, n);
+ myRead += n;
+ }
+ else if ((size_t)(aWrite + BUFFER_LENGTH - myRead) >= n)
+ {
+ int aTopMem = myBuffer + BUFFER_LENGTH - myRead;
+ if (aTopMem)
+ {
+ SHOW("pa_callback > myRead=0x%x, aTopMem=0x%x\n",(int)myRead, (int)aTopMem);
+ memcpy(outputBuffer, myRead, aTopMem);
+ }
+ int aRest = n - aTopMem;
+ if (aRest)
+ {
+ SHOW("pa_callback > myRead=0x%x, aRest=0x%x\n",(int)myRead, (int)aRest);
+ char* p = (char*)outputBuffer + aTopMem;
+ memcpy(p, myBuffer, aRest);
+ }
+ myRead = myBuffer + aRest;
+ }
+ else
+ {
+ SHOW_TIME("pa_callback > underflow");
+ aResult=1; // paComplete;
+
+ int aTopMem = myBuffer + BUFFER_LENGTH - myRead;
+ if (aTopMem)
+ {
+ SHOW("pa_callback > myRead=0x%x, aTopMem=0x%x\n",(int)myRead, (int)aTopMem);
+ memcpy(outputBuffer, myRead, aTopMem);
+ }
+ int aRest = aWrite - myBuffer;
+ if (aRest)
+ {
+ SHOW("pa_callback > myRead=0x%x, aRest=0x%x\n",(int)myRead, (int)aRest);
+ char* p = (char*)outputBuffer + aTopMem;
+ memcpy(p, myBuffer, aRest);
+ }
+
+ size_t aUsedMem = aTopMem + aRest;
+ char* p = (char*)outputBuffer + aUsedMem;
+ memset(p, 0, n - aUsedMem);
+ // myReadPosition += aUsedMem/(out_channels*sizeof(uint16_t));
+ myRead = aWrite;
+ }
}
- }
- SHOW("pa_callback > myRead=%x\n",(int)myRead);
+ SHOW("pa_callback > myRead=%x\n",(int)myRead);
// #if USE_PORTAUDIO == 18
@@ -288,7 +442,7 @@ static int pa_callback(void *inputBuffer, void *outputBuffer,
#endif
- return(aResult);
+ return(aResult);
//#endif
} // end of WaveCallBack
@@ -335,7 +489,7 @@ static int wave_open_sound()
out_channels = 1;
#if USE_PORTAUDIO == 18
- // err = Pa_OpenDefaultStream(&pa_stream,0,1,paInt16,SAMPLE_RATE,FRAMES_PER_BUFFER,N_WAV_BUF,pa_callback,(void *)userdata);
+ // err = Pa_OpenDefaultStream(&pa_stream,0,1,paInt16,wave_samplerate,FRAMES_PER_BUFFER,N_WAV_BUF,pa_callback,(void *)userdata);
PaDeviceID playbackDevice = Pa_GetDefaultOutputDeviceID();
@@ -351,12 +505,12 @@ static int wave_open_sound()
paInt16,
NULL,
/* general parameters */
- SAMPLE_RATE, FRAMES_PER_BUFFER, 0,
+ wave_samplerate, FRAMES_PER_BUFFER, 0,
//paClipOff | paDitherOff,
paNoFlag,
pa_callback, (void *)userdata);
-
- SHOW("wave_open_sound > Pa_OpenDefaultStream(1): err=%d (%s)\n",err, Pa_GetErrorText(err));
+
+ SHOW("wave_open_sound > Pa_OpenDefaultStream(1): err=%d (%s)\n",err, Pa_GetErrorText(err));
if(err == paInvalidChannelCount)
{
@@ -376,12 +530,12 @@ static int wave_open_sound()
paInt16,
NULL,
/* general parameters */
- SAMPLE_RATE, FRAMES_PER_BUFFER, 0,
+ wave_samplerate, FRAMES_PER_BUFFER, 0,
//paClipOff | paDitherOff,
paNoFlag,
pa_callback, (void *)userdata);
// err = Pa_OpenDefaultStream(&pa_stream,0,2,paInt16,
-// SAMPLE_RATE,
+// wave_samplerate,
// FRAMES_PER_BUFFER,
// N_WAV_BUF,pa_callback,(void *)userdata);
SHOW("wave_open_sound > Pa_OpenDefaultStream(2): err=%d (%s)\n",err, Pa_GetErrorText(err));
@@ -395,13 +549,13 @@ static int wave_open_sound()
&pa_stream,
NULL, /* no input */
&myOutputParameters,
- SAMPLE_RATE,
+ wave_samplerate,
framesPerBuffer,
paNoFlag,
// paClipOff | paDitherOff,
pa_callback,
(void *)userdata);
- if ((err!=paNoError)
+ if ((err!=paNoError)
&& (err!=paInvalidChannelCount)) //err==paUnanticipatedHostError
{
fprintf(stderr, "wave_open_sound > Pa_OpenStream : err=%d (%s)\n",err,Pa_GetErrorText(err));
@@ -410,7 +564,7 @@ static int wave_open_sound()
&pa_stream,
NULL, /* no input */
&myOutputParameters,
- SAMPLE_RATE,
+ wave_samplerate,
framesPerBuffer,
paNoFlag,
// paClipOff | paDitherOff,
@@ -427,14 +581,14 @@ static int wave_open_sound()
&pa_stream,
NULL, /* no input */
&myOutputParameters,
- SAMPLE_RATE,
+ wave_samplerate,
framesPerBuffer,
paNoFlag,
// paClipOff | paDitherOff,
pa_callback,
(void *)userdata);
- // err = Pa_OpenDefaultStream(&pa_stream,0,2,paInt16,(double)SAMPLE_RATE,FRAMES_PER_BUFFER,pa_callback,(void *)userdata);
+ // err = Pa_OpenDefaultStream(&pa_stream,0,2,paInt16,(double)wave_samplerate,FRAMES_PER_BUFFER,pa_callback,(void *)userdata);
}
mInCallbackFinishedState = false;
#endif
@@ -457,13 +611,13 @@ static void update_output_parameters(int selectedDevice, const PaDeviceInfo *dev
myOutputParameters.channelCount = 1;
myOutputParameters.sampleFormat = paInt16;
- // Latency greater than 100ms for avoiding glitches
+ // Latency greater than 100ms for avoiding glitches
// (e.g. when moving a window in a graphical desktop)
// deviceInfo = Pa_GetDeviceInfo(selectedDevice);
if (deviceInfo)
{
double aLatency = deviceInfo->defaultLowOutputLatency;
- double aCoeff = round(0.100 / aLatency);
+// double aCoeff = round(0.100 / aLatency);
// myOutputParameters.suggestedLatency = aCoeff * aLatency; // to avoid glitches ?
myOutputParameters.suggestedLatency = aLatency; // for faster response ?
SHOW("Device=%d, myOutputParameters.suggestedLatency=%f, aCoeff=%f\n",
@@ -511,40 +665,40 @@ static void select_device(const char* the_api)
for( i=0; i<numDevices; i++ )
{
deviceInfo = Pa_GetDeviceInfo( i );
-
+
if (deviceInfo == NULL)
{
break;
}
const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
-
+
if (hostInfo && hostInfo->type == paALSA)
- {
+ {
// Check (once) the default output device
if (defaultAlsaIndex == numDevices)
{
defaultAlsaIndex = hostInfo->defaultOutputDevice;
const PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo( defaultAlsaIndex );
update_output_parameters(defaultAlsaIndex, deviceInfo);
- if (Pa_IsFormatSupported(NULL, &myOutputParameters, SAMPLE_RATE) == 0)
+ if (Pa_IsFormatSupported(NULL, &myOutputParameters, wave_samplerate) == 0)
{
- SHOW( "select_device > ALSA (default), name=%s (#%d)\n", deviceInfo->name, defaultAlsaIndex);
+ SHOW( "select_device > ALSA (default), name=%s (#%d)\n", deviceInfo->name, defaultAlsaIndex);
selectedIndex = defaultAlsaIndex;
selectedDeviceInfo = deviceInfo;
break;
}
}
-
- // if the default output device does not match,
- // look for the device with the highest number of output channels
+
+ // if the default output device does not match,
+ // look for the device with the highest number of output channels
SHOW( "select_device > ALSA, i=%d (numDevices=%d)\n", i, numDevices);
-
+
update_output_parameters(i, deviceInfo);
-
- if (Pa_IsFormatSupported(NULL, &myOutputParameters, SAMPLE_RATE) == 0)
+
+ if (Pa_IsFormatSupported(NULL, &myOutputParameters, wave_samplerate) == 0)
{
SHOW( "select_device > ALSA, name=%s (#%d)\n", deviceInfo->name, i);
-
+
if (!selectedDeviceInfo
|| (selectedDeviceInfo->maxOutputChannels < deviceInfo->maxOutputChannels))
{
@@ -560,14 +714,14 @@ static void select_device(const char* the_api)
{
update_output_parameters(selectedIndex, selectedDeviceInfo);
}
- else
+ else
{
i = Pa_GetDefaultOutputDevice();
deviceInfo = Pa_GetDeviceInfo( i );
update_output_parameters(i, deviceInfo);
}
-#endif
+#endif
}
//>
@@ -613,12 +767,13 @@ void wave_set_callback_is_output_enabled(t_wave_callback* cb)
//<wave_init
// TBD: the arg could be "alsa", "oss",...
-void wave_init()
+int wave_init(int srate)
{
ENTER("wave_init");
PaError err;
pa_stream = NULL;
+ wave_samplerate = srate;
mInCallbackFinishedState = false;
init_buffer();
@@ -629,6 +784,7 @@ void wave_init()
{
SHOW_TIME("wave_init > Failed to initialise the PortAudio sound");
}
+ return err == paNoError;
}
//>
@@ -653,18 +809,18 @@ void* wave_open(const char* the_api)
//<copyBuffer
-static size_t copyBuffer(char* dest, char* src, const size_t theSizeInBytes)
-{
+static size_t copyBuffer(char* dest, char* src, const size_t theSizeInBytes)
+{
size_t bytes_written = 0;
unsigned int i = 0;
uint16_t* a_dest = NULL;
uint16_t* a_src = NULL;
-
+
if ((src != NULL) && dest != NULL)
- {
+ {
// copy for one channel (mono)?
if(out_channels==1)
- {
+ {
SHOW("copyBuffer > 1 channel > memcpy %x (%d bytes)\n", (int)myWrite, theSizeInBytes);
memcpy(dest, src, theSizeInBytes);
bytes_written = theSizeInBytes;
@@ -675,7 +831,7 @@ static size_t copyBuffer(char* dest, char* src, const size_t theSizeInBytes)
i = 0;
a_dest = (uint16_t* )dest;
a_src = (uint16_t* )src;
-
+
for(i=0; i<theSizeInBytes/2; i++)
{
a_dest[2*i] = a_src[i];
@@ -684,8 +840,8 @@ static size_t copyBuffer(char* dest, char* src, const size_t theSizeInBytes)
bytes_written = 2*theSizeInBytes;
} // end if(out_channels==1)
} // end if ((src != NULL) && dest != NULL)
-
- return bytes_written;
+
+ return bytes_written;
}
//>
@@ -698,7 +854,7 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
// space in ringbuffer for the sample needed: 1x mono channel but 2x for 1 stereo channel
size_t bytes_to_write = (out_channels==1) ? theSize : theSize*2;
my_stream_could_start = 0;
-
+
if(pa_stream == NULL)
{
SHOW_TIME("wave_write > wave_open_sound\n");
@@ -714,16 +870,16 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
my_stream_could_start = 1;
}
assert(BUFFER_LENGTH >= bytes_to_write);
-
+
if (myWrite >= myBuffer + BUFFER_LENGTH)
{
myWrite = myBuffer;
} // end if (myWrite >= myBuffer + BUFFER_LENGTH)
-
+
size_t aTotalFreeMem=0;
char* aRead = myRead;
SHOW("wave_write > aRead=%x, myWrite=%x\n", (int)aRead, (int)myWrite);
-
+
while (1)
{
if (my_callback_is_output_enabled && (0==my_callback_is_output_enabled()))
@@ -731,9 +887,9 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
SHOW_TIME("wave_write > my_callback_is_output_enabled: no!");
return 0;
}
-
+
aRead = myRead;
-
+
// write pointer is before read pointer?
if (myWrite >= aRead)
{
@@ -743,27 +899,27 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
{
aTotalFreeMem = aRead - myWrite;
} // end if (myWrite >= aRead)
-
+
if (aTotalFreeMem>1)
{
// -1 because myWrite must be different of aRead
// otherwise buffer would be considered as empty
aTotalFreeMem -= 1;
} // end if (aTotalFreeMem>1)
-
+
if (aTotalFreeMem >= bytes_to_write)
{
break;
} // end if (aTotalFreeMem >= bytes_to_write)
-
+
//SHOW_TIME("wave_write > wait");
SHOW("wave_write > wait: aTotalFreeMem=%d\n", aTotalFreeMem);
SHOW("wave_write > aRead=%x, myWrite=%x\n", (int)aRead, (int)myWrite);
usleep(10000);
} // end while (1)
-
+
aRead = myRead;
-
+
// write pointer is ahead the read pointer?
if (myWrite >= aRead)
{
@@ -800,17 +956,17 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
SHOW_TIME("wave_write > myWrite <= aRead");
myWrite += copyBuffer(myWrite, theMono16BitsWaveBuffer, theSize);
} // end if (myWrite >= aRead)
-
+
bytes_written = bytes_to_write;
myWritePosition += theSize/sizeof(uint16_t); // add number of samples
-
+
if (my_stream_could_start && (get_used_mem() >= out_channels * sizeof(uint16_t) * FRAMES_PER_BUFFER))
{
start_stream();
} // end if (my_stream_could_start && (get_used_mem() >= out_channels * sizeof(uint16_t) * FRAMES_PER_BUFFER))
-
+
SHOW_TIME("wave_write > LEAVE");
-
+
return bytes_written;
}
@@ -829,7 +985,7 @@ int wave_close(void* theHandler)
SHOW_TIME("wave_close > LEAVE (NULL stream)");
return 0;
}
-
+
if( Pa_IsStreamStopped( pa_stream ) )
{
SHOW_TIME("wave_close > LEAVE (stopped)");
@@ -841,7 +997,7 @@ int wave_close(void* theHandler)
SHOW_TIME("wave_close > LEAVE (NULL stream)");
return 0;
}
-
+
if( Pa_StreamActive( pa_stream ) == false && mInCallbackFinishedState == false )
{
SHOW_TIME("wave_close > LEAVE (not active)");
@@ -857,20 +1013,20 @@ int wave_close(void* theHandler)
SHOW_TIME("wave_close > LEAVE (stopStreamCount)");
return 0;
}
-
- // Comment from Audacity-1.2.4b adapted to the eSpeak context.
+
+ // Comment from Audacity-1.2.4b adapted to the eSpeak context.
//
// We got here in one of two ways:
//
- // 1. The calling program calls the espeak_Cancel function and we
- // therefore want to stop as quickly as possible.
+ // 1. The calling program calls the espeak_Cancel function and we
+ // therefore want to stop as quickly as possible.
// So we use AbortStream(). If this is
// the case the portaudio stream is still in the Running state
// (see PortAudio state machine docs).
//
// 2. The callback told PortAudio to stop the stream since it had
- // reached the end of the selection.
- // The event polling thread discovered this by noticing that
+ // reached the end of the selection.
+ // The event polling thread discovered this by noticing that
// wave_is_busy() returned false.
// wave_is_busy() (which calls Pa_GetStreamActive()) will not return
// false until all buffers have finished playing, so we can call
@@ -885,7 +1041,7 @@ int wave_close(void* theHandler)
// call StopStream if the callback brought us here, and AbortStream
// if the user brought us here.
//
-
+
#if (USE_PORTAUDIO == 19)
if (pa_stream)
{
@@ -969,14 +1125,14 @@ int wave_is_busy(void* theHandler)
if (pa_stream)
{
#if USE_PORTAUDIO == 18
- active = Pa_StreamActive(pa_stream)
+ active = Pa_StreamActive(pa_stream)
&& (mInCallbackFinishedState == false);
#else
active = Pa_IsStreamActive(pa_stream)
&& (mInCallbackFinishedState == false);
#endif
}
-
+
SHOW("wave_is_busy: %d\n",active);
@@ -1015,7 +1171,7 @@ int wave_get_remaining_time(uint32_t sample, uint32_t* time)
if (!time || !pa_stream)
{
- SHOW("event get_remaining_time> %s\n","audio device not available");
+ SHOW("event get_remaining_time> %s\n","audio device not available");
return -1;
}
@@ -1023,7 +1179,7 @@ int wave_get_remaining_time(uint32_t sample, uint32_t* time)
{
// TBD: take in account time suplied by portaudio V18 API
a_time = sample - myReadPosition;
- a_time = 0.5 + (a_time * 1000.0) / SAMPLE_RATE;
+ a_time = 0.5 + (a_time * 1000.0) / wave_samplerate;
}
else
{
@@ -1050,7 +1206,7 @@ void *wave_test_get_write_buffer()
// notdef USE_PORTAUDIO
-void wave_init() {}
+int wave_init(int srate) {return 1;}
void* wave_open(const char* the_api) {return (void *)1;}
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
int wave_close(void* theHandler) {return 0;}
@@ -1101,7 +1257,7 @@ void add_time_in_ms(struct timespec *ts, int time_in_ms)
{
SHOW("event > add_time_in_ms ns: %d sec %Lu nsec \n", ts->tv_sec, t_ns);
ts->tv_sec += 1;
- t_ns -= ONE_BILLION;
+ t_ns -= ONE_BILLION;
}
ts->tv_nsec = (long int)t_ns;
}
diff --git a/navit/support/espeak/wave.h b/navit/support/espeak/wave.h
index de8bf1ef8..d1b04a3ab 100644
--- a/navit/support/espeak/wave.h
+++ b/navit/support/espeak/wave.h
@@ -1,22 +1,13 @@
#ifndef WAVE_H
#define WAVE_H
-#ifdef _MSC_VER
-
-typedef __int32 int32_t;
-typedef unsigned __int32 uint32_t;
-typedef __int64 int64_t;
-typedef unsigned __int32 uint64_t;
-
-#else
#ifndef PLATFORM_DOS
#include "stdint.h"
#endif
-#endif
extern int option_device_number;
-extern void wave_init();
+extern int wave_init(int samplerate);
// TBD: the arg could be "alsa", "oss",...
extern void* wave_open(const char* the_api);
@@ -24,7 +15,7 @@ extern size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t
extern int wave_close(void* theHandler);
extern void wave_flush(void* theHandler);
extern int wave_is_busy(void* theHandler);
-extern void wave_terminate();
+extern void wave_terminate(void);
extern uint32_t wave_get_read_position(void* theHandler);
extern uint32_t wave_get_write_position(void* theHandler);
@@ -47,6 +38,6 @@ extern void clock_gettime2(struct timespec *ts);
extern void add_time_in_ms(struct timespec *ts, int time_in_ms);
// for tests
-extern void *wave_test_get_write_buffer();
+extern void *wave_test_get_write_buffer(void);
#endif
diff --git a/navit/support/espeak/wave_pulse.c b/navit/support/espeak/wave_pulse.c
index d5fbc8c1e..1bcb593a7 100755..100644
--- a/navit/support/espeak/wave_pulse.c
+++ b/navit/support/espeak/wave_pulse.c
@@ -75,21 +75,52 @@ static t_wave_callback* my_callback_is_output_enabled=NULL;
#define MINREQ 880
#define FRAGSIZE 0
+#ifdef USE_PORTAUDIO
+// rename functions to be wrapped
+#define wave_init wave_pulse_init
+#define wave_open wave_pulse_open
+#define wave_write wave_pulse_write
+#define wave_close wave_pulse_close
+#define wave_is_busy wave_pulse_is_busy
+#define wave_terminate wave_pulse_terminate
+#define wave_get_read_position wave_pulse_get_read_position
+#define wave_get_write_position wave_pulse_get_write_position
+#define wave_flush wave_pulse_flush
+#define wave_set_callback_is_output_enabled wave_pulse_set_callback_is_output_enabled
+#define wave_test_get_write_buffer wave_pulse_test_get_write_buffer
+#define wave_get_remaining_time wave_pulse_get_remaining_time
+
+// check whether we can connect to PulseAudio
+#include <pulse/simple.h>
+int is_pulse_running()
+{
+ pa_sample_spec ss;
+ ss.format = ESPEAK_FORMAT;
+ ss.rate = SAMPLE_RATE;
+ ss.channels = ESPEAK_CHANNEL;
+
+ pa_simple *s = pa_simple_new(NULL, "eSpeak", PA_STREAM_PLAYBACK, NULL, "is_pulse_running", &ss, NULL, NULL, NULL);
+ if (s) {
+ pa_simple_free(s);
+ return 1;
+ } else
+ return 0;
+}
+#endif // USE_PORTAUDIO
+
static pthread_mutex_t pulse_mutex;
static pa_context *context = NULL;
static pa_stream *stream = NULL;
static pa_threaded_mainloop *mainloop = NULL;
-static pa_cvolume volume;
-static int volume_valid = 0;
-
static int do_trigger = 0;
static uint64_t written = 0;
static int time_offset_msec = 0;
static int just_flushed = 0;
static int connected = 0;
+static int wave_samplerate;
#define CHECK_DEAD_GOTO(label, warn) do { \
if (!mainloop || \
@@ -131,20 +162,7 @@ do { \
// SHOW("ti> read_index=0x%lx\n",the_time->read_index);
// }
-
-static void info_cb(struct pa_context *c, const struct pa_sink_input_info *i, int is_last, void *userdata) {
- ENTER(__FUNCTION__);
- assert(c);
-
- if (!i)
- return;
-
- volume = i->volume;
- volume_valid = 1;
-}
-
static void subscribe_cb(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) {
- pa_operation *o;
ENTER(__FUNCTION__);
assert(c);
@@ -154,13 +172,6 @@ static void subscribe_cb(struct pa_context *c, enum pa_subscription_event_type t
(t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE) &&
t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW)))
return;
-
- if (!(o = pa_context_get_sink_input_info(c, index, info_cb, NULL))) {
- SHOW("pa_context_get_sink_input_info() failed: %s\n", pa_strerror(pa_context_errno(c)));
- return;
- }
-
- pa_operation_unref(o);
}
static void context_state_cb(pa_context *c, void *userdata) {
@@ -367,7 +378,7 @@ static void pulse_write(void* ptr, int length) {
SHOW("pulse_write > length=%d\n", length);
- CHECK_CONNECTED();
+ CHECK_CONNECTED_NO_RETVAL();
pa_threaded_mainloop_lock(mainloop);
CHECK_DEAD_GOTO(fail, 1);
@@ -475,18 +486,12 @@ static int pulse_open()
pthread_mutex_init( &pulse_mutex, (const pthread_mutexattr_t *)NULL);
ss.format = ESPEAK_FORMAT;
- ss.rate = SAMPLE_RATE;
+ ss.rate = wave_samplerate;
ss.channels = ESPEAK_CHANNEL;
if (!pa_sample_spec_valid(&ss))
return false;
-/* if (!volume_valid) { */
- pa_cvolume_reset(&volume, ss.channels);
- volume_valid = 1;
-/* } else if (volume.channels != ss.channels) */
-/* pa_cvolume_set(&volume, ss.channels, pa_cvolume_avg(&volume)); */
-
SHOW_TIME("pa_threaded_mainloop_new (call)");
if (!(mainloop = pa_threaded_mainloop_new())) {
SHOW("Failed to allocate main loop\n","");
@@ -539,8 +544,6 @@ static int pulse_open()
pa_stream_set_write_callback(stream, stream_request_cb, NULL);
pa_stream_set_latency_update_callback(stream, stream_latency_update_cb, NULL);
-
-
pa_buffer_attr a_attr;
a_attr.maxlength = MAXLENGTH;
@@ -550,7 +553,7 @@ static int pulse_open()
a_attr.fragsize = 0;
SHOW_TIME("pa_connect_playback");
- if (pa_stream_connect_playback(stream, NULL, &a_attr, (pa_stream_flags_t)(PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE), &volume, NULL) < 0) {
+ if (pa_stream_connect_playback(stream, NULL, &a_attr, (pa_stream_flags_t)(PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE), NULL, NULL) < 0) {
SHOW("Failed to connect stream: %s", pa_strerror(pa_context_errno(context)));
goto unlock_and_fail;
}
@@ -578,44 +581,24 @@ static int pulse_open()
pa_threaded_mainloop_wait(mainloop);
}
- if (!success) {
- SHOW("pa_context_subscribe() failed: %s", pa_strerror(pa_context_errno(context)));
- goto unlock_and_fail;
- }
-
pa_operation_unref(o);
- /* Now request the initial stream info */
- if (!(o = pa_context_get_sink_input_info(context, pa_stream_get_index(stream), info_cb, NULL))) {
- SHOW("pa_context_get_sink_input_info() failed: %s", pa_strerror(pa_context_errno(context)));
+ if (!success) {
+ SHOW("pa_context_subscribe() failed: %s", pa_strerror(pa_context_errno(context)));
goto unlock_and_fail;
}
-
- SHOW_TIME("pa_threaded_mainloop_wait 2");
- while (pa_operation_get_state(o) != PA_OPERATION_DONE) {
- CHECK_DEAD_GOTO(fail, 1);
- pa_threaded_mainloop_wait(mainloop);
- }
-
-/* if (!volume_valid) { */
-/* SHOW("pa_context_get_sink_input_info() failed: %s", pa_strerror(pa_context_errno(context))); */
-/* goto unlock_and_fail; */
-/* } */
do_trigger = 0;
written = 0;
time_offset_msec = 0;
just_flushed = 0;
connected = 1;
- // volume_time_event = NULL;
pa_threaded_mainloop_unlock(mainloop);
SHOW_TIME("pulse_open (ret true)");
- // return true;
return PULSE_OK;
-
unlock_and_fail:
if (o)
@@ -677,13 +660,14 @@ void wave_set_callback_is_output_enabled(t_wave_callback* cb)
//>
//<wave_init
-void wave_init()
+int wave_init(int srate)
{
ENTER("wave_init");
stream = NULL;
+ wave_samplerate = srate;
- pulse_open();
+ return pulse_open() == PULSE_OK;
}
//>
@@ -761,19 +745,32 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
int wave_close(void* theHandler)
{
SHOW_TIME("wave_close > ENTER");
+ static int aStopStreamCount = 0;
- int a_status = pthread_mutex_lock(&pulse_mutex);
- if (a_status) {
- SHOW("Error: pulse_mutex lock=%d (%s)\n", a_status, __FUNCTION__);
- return PULSE_ERROR;
- }
-
- drain();
+ // Avoid race condition by making sure this function only
+ // gets called once at a time
+ aStopStreamCount++;
+ if (aStopStreamCount != 1)
+ {
+ SHOW_TIME("wave_close > LEAVE (stopStreamCount)");
+ return 0;
+ }
- pthread_mutex_unlock(&pulse_mutex);
- SHOW_TIME("wave_close (ret)");
+ int a_status = pthread_mutex_lock(&pulse_mutex);
+ if (a_status)
+ {
+ SHOW("Error: pulse_mutex lock=%d (%s)\n", a_status, __FUNCTION__);
+ aStopStreamCount = 0; // last action
+ return PULSE_ERROR;
+ }
+
+ drain();
+
+ pthread_mutex_unlock(&pulse_mutex);
+ SHOW_TIME("wave_close (ret)");
- return PULSE_OK;
+ aStopStreamCount = 0; // last action
+ return PULSE_OK;
}
//>
@@ -846,7 +843,7 @@ int wave_get_remaining_time(uint32_t sample, uint32_t* time)
{
// TBD: take in account time suplied by portaudio V18 API
a_time = sample - a_timing_info.read_index;
- a_time = 0.5 + (a_time * 1000.0) / SAMPLE_RATE;
+ a_time = 0.5 + (a_time * 1000.0) / wave_samplerate;
}
else
{
@@ -873,7 +870,7 @@ void *wave_test_get_write_buffer()
// notdef USE_PULSEAUDIO
-void wave_init() {}
+int wave_init(return 1;) {}
void* wave_open(const char* the_api) {return (void *)1;}
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
int wave_close(void* theHandler) {return 0;}
@@ -893,8 +890,9 @@ int wave_get_remaining_time(uint32_t sample, uint32_t* time)
return 0;
}
-#endif // of USE_PORTAUDIO
+#endif // of USE_PULSEAUDIO
+#ifndef USE_PORTAUDIO
//>
//<clock_gettime2, add_time_in_ms
@@ -928,6 +926,7 @@ void add_time_in_ms(struct timespec *ts, int time_in_ms)
}
ts->tv_nsec = (long int)t_ns;
}
+#endif // ifndef USE_PORTAUDIO
#endif // USE_ASYNC
diff --git a/navit/support/espeak/wave_sada.c b/navit/support/espeak/wave_sada.c
index c69a4dc99..23d53c778 100755..100644
--- a/navit/support/espeak/wave_sada.c
+++ b/navit/support/espeak/wave_sada.c
@@ -63,6 +63,7 @@ static uint32_t total_samples_skipped;
//
static uint32_t last_play_position=0;
+static uint32_t wave_samplerate;
//>
// wave_init
//
@@ -77,12 +78,14 @@ static uint32_t last_play_position=0;
//
//<wave_init
-void wave_init() {
+int wave_init(int srate) {
ENTER("wave_init");
audio_info_t ainfo;
char *audio_device = NULL;
+ wave_samplerate = srate;
+
audio_device = getenv("AUDIODEV");
if (audio_device != NULL) {
if ((sun_audio_fd = open(audio_device, O_WRONLY)) < 0) {
@@ -101,21 +104,22 @@ void wave_init() {
SHOW("wave_init() sun_audio_fd: %d\n", sun_audio_fd);
if (sun_audio_fd < 0) {
- return;
+ return(0);
}
ioctl(sun_audio_fd, AUDIO_GETINFO, &ainfo);
SHOW("wave_init() play buffer size: %d\n", ainfo.play.buffer_size);
ainfo.play.encoding = AUDIO_ENCODING_LINEAR;
ainfo.play.channels = 1;
- ainfo.play.sample_rate = SAMPLE_RATE;
+ ainfo.play.sample_rate = wave_samplerate;
ainfo.play.precision = SAMPLE_SIZE;
if (ioctl(sun_audio_fd, AUDIO_SETINFO, &ainfo) == -1) {
SHOW("wave_init() failed to set audio params: %s\n", strerror(errno));
close(sun_audio_fd);
- return;
+ return(0);
}
+ return(1);
}
//>
@@ -306,7 +310,11 @@ int wave_close(void* theHandler)
int wave_is_busy(void* theHandler)
{
uint32_t time;
- wave_get_remaining_time(total_samples_sent - 1, &time);
+ if (total_samples_sent >= 1) {
+ wave_get_remaining_time(total_samples_sent - 1, &time);
+ } else {
+ time = 0;
+ }
return time != 0;
}
@@ -516,7 +524,7 @@ int wave_get_remaining_time(uint32_t sample, uint32_t* time)
(actual_index <= ainfo.play.samples)) {
*time = 0;
} else {
- a_time = ((actual_index - ainfo.play.samples) * 1000) / SAMPLE_RATE;
+ a_time = ((actual_index - ainfo.play.samples) * 1000) / wave_samplerate;
*time = (uint32_t) a_time;
}
SHOW("wave_get_remaining_time for %d: %d\n", sample, *time);
@@ -527,7 +535,7 @@ int wave_get_remaining_time(uint32_t sample, uint32_t* time)
#else
// notdef USE_SADA
-void wave_init() {}
+init wave_init() {return 1;}
void* wave_open(const char* the_api) {return (void *)1;}
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
int wave_close(void* theHandler) {return 0;}
diff --git a/navit/support/espeak/wavegen.c b/navit/support/espeak/wavegen.c
index a5467ca1e..057178b70 100755..100644
--- a/navit/support/espeak/wavegen.c
+++ b/navit/support/espeak/wavegen.c
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
+ * Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -28,13 +28,17 @@
#include <math.h>
+
#include "speak_lib.h"
#include "speech.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
-//#undef INCLUDE_KLATT
+#include "wavegen.h"
+#ifdef INCLUDE_SONIC
+#include "sonic.h"
+#endif
#ifdef USE_PORTAUDIO
#include "portaudio.h"
@@ -78,12 +82,11 @@ static wavegen_peaks_t peaks[N_PEAKS];
static int peak_harmonic[N_PEAKS];
static int peak_height[N_PEAKS];
-#define N_ECHO_BUF 5500 // max of 250mS at 22050 Hz
-static int echo_head;
-static int echo_tail;
+int echo_head;
+int echo_tail;
+int echo_amp = 0;
+short echo_buf[N_ECHO_BUF];
static int echo_length = 0; // period (in sample\) to ensure completion of echo at the end of speech, set in WavegenSetEcho()
-static int echo_amp = 0;
-static short echo_buf[N_ECHO_BUF];
static int voicing;
static RESONATOR rbreath[N_PEAKS];
@@ -129,55 +132,31 @@ unsigned char *out_end;
int outbuf_size = 0;
// the queue of operations passed to wavegen from sythesize
-long wcmdq[N_WCMDQ][4];
+long64 wcmdq[N_WCMDQ][4];
int wcmdq_head=0;
int wcmdq_tail=0;
// pitch,speed,
-int embedded_default[N_EMBEDDED_VALUES] = {0,50,170,100,50, 0,0, 0,170,0,0,0,0,0};
-static int embedded_max[N_EMBEDDED_VALUES] = {0,0x7fff,600,300,99,99,99, 0,600,0,0,0,0,4};
+int embedded_default[N_EMBEDDED_VALUES] = {0, 50,175,100,50, 0, 0, 0,175,0,0,0,0,0,0};
+static int embedded_max[N_EMBEDDED_VALUES] = {0,0x7fff,750,300,99,99,99, 0,750,0,0,0,0,4,0};
#define N_CALLBACK_IX N_WAV_BUF-2 // adjust this delay to match display with the currently spoken word
int current_source_index=0;
extern FILE *f_wave;
-
+#ifdef USE_PORTAUDIO
#if (USE_PORTAUDIO == 18)
static PortAudioStream *pa_stream=NULL;
#endif
#if (USE_PORTAUDIO == 19)
static PaStream *pa_stream=NULL;
#endif
+#endif
-/* default pitch envelope, a steady fall */
-#define ENV_LEN 128
-
-#define int(x) (int)(x)
-/*
-unsigned char Pitch_env0[ENV_LEN] = {
- 255,253,251,249,247,245,243,241,239,237,235,233,231,229,227,225,
- 223,221,219,217,215,213,211,209,207,205,203,201,199,197,195,193,
- 191,189,187,185,183,181,179,177,175,173,171,169,167,165,163,161,
- 159,157,155,153,151,149,147,145,143,141,139,137,135,133,131,129,
- 127,125,123,121,119,117,115,113,111,109,107,105,103,101, 99, 97,
- 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65,
- 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33,
- 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1
-};
-*/
-
-/*
-unsigned char Pitch_long[ENV_LEN] = {
- 254,249,250,251,252,253,254,254, 255,255,255,255,254,254,253,252,
- 251,250,249,247,244,242,238,234, 230,225,221,217,213,209,206,203,
- 199,195,191,187,183,179,175,172, 168,165,162,159,156,153,150,148,
- 145,143,140,138,136,134,132,130, 128,126,123,120,117,114,111,107,
- 104,100,96,91, 86,82,77,73, 70,66,63,60, 58,55,53,51,
- 49,47,46,45, 43,42,40,38, 36,34,31,28, 26,24,22,20,
- 18,16,14,12, 11,10,9,8, 8,8,8,8, 9,8,8,8,
- 8,8,7,7, 6,6,6,5, 4,4,3,3, 2,1,1,0
-};
-*/
+#ifdef INCLUDE_SONIC
+static sonicStream sonicSpeedupStream = NULL;
+double sonicSpeed = 1.0;
+#endif
// 1st index=roughness
// 2nd index=modulation_type
@@ -267,7 +246,7 @@ static unsigned char wavemult[N_WAVEMULT] = {
105, 98, 90, 83, 76, 69, 62, 55, 49, 43, 37, 32, 27, 22, 18, 14,
11, 8, 5, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
+
// set from y = pow(2,x) * 128, x=-1 to 1
unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1] = {
@@ -285,12 +264,13 @@ unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1] = {
217,220,223,226,229,232,236,239,
242,246,249,252, 254,255 };
-int WavegenFill(int fill_zeros);
-
#ifdef LOG_FRAMES
-static void LogMarker(int type, int value)
-{//=======================================
+static void LogMarker(int type, int value, int value2)
+{//===================================================
+ char buf[20];
+ int *p;
+
if(option_log_frames == 0)
return;
@@ -300,7 +280,13 @@ static void LogMarker(int type, int value)
if(f_log)
{
if(type == espeakEVENT_PHONEME)
- fprintf(f_log,"Phoneme [%s]\n",WordToString(value));
+ {
+ p = (int *)buf;
+ p[0] = value;
+ p[1] = value2;
+ buf[8] = 0;
+ fprintf(f_log,"Phoneme [%s]\n", buf);
+ }
else
fprintf(f_log,"\n");
fclose(f_log);
@@ -310,17 +296,28 @@ static void LogMarker(int type, int value)
}
#endif
-void WcmdqStop()
+void WcmdqStop(void)
{//=============
wcmdq_head = 0;
wcmdq_tail = 0;
+
+#ifdef INCLUDE_SONIC
+ if(sonicSpeedupStream != NULL)
+ {
+ sonicDestroyStream(sonicSpeedupStream);
+ sonicSpeedupStream = NULL;
+ }
+#endif
+
#ifdef USE_PORTAUDIO
Pa_AbortStream(pa_stream);
#endif
+ if(mbrola_name[0] != 0)
+ MbrolaReset();
}
-int WcmdqFree()
+int WcmdqFree(void)
{//============
int i;
i = wcmdq_head - wcmdq_tail;
@@ -328,19 +325,19 @@ int WcmdqFree()
return(i);
}
-int WcmdqUsed()
+int WcmdqUsed(void)
{//============
return(N_WCMDQ - WcmdqFree());
}
-void WcmdqInc()
+void WcmdqInc(void)
{//============
wcmdq_tail++;
if(wcmdq_tail >= N_WCMDQ) wcmdq_tail=0;
}
-static void WcmdqIncHead()
+static void WcmdqIncHead(void)
{//=======================
wcmdq_head++;
if(wcmdq_head >= N_WCMDQ) wcmdq_head=0;
@@ -350,12 +347,14 @@ static void WcmdqIncHead()
// data points from which to make the presets for pk_shape1 and pk_shape2
#define PEAKSHAPEW 256
+#ifdef deleted
static const float pk_shape_x[2][8] = {
{0,-0.6f, 0.0f, 0.6f, 1.4f, 2.5f, 4.5f, 5.5f},
{0,-0.6f, 0.0f, 0.6f, 1.4f, 2.0f, 4.5f, 5.5f }};
static const float pk_shape_y[2][8] = {
{0, 67, 81, 67, 31, 14, 0, -6} ,
{0, 77, 81, 77, 31, 7, 0, -6 }};
+#endif
unsigned char pk_shape1[PEAKSHAPEW+1] = {
255,254,254,254,254,254,253,253,252,251,251,250,249,248,247,246,
@@ -440,6 +439,10 @@ static int userdata[4];
static PaError pa_init_err=0;
static int out_channels=1;
+unsigned char *outbuffer = NULL;
+int outbuffer_size = 0;
+
+
#if USE_PORTAUDIO == 18
static int WaveCallback(void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer, PaTimestamp outTime, void *userData )
@@ -452,9 +455,30 @@ static int WaveCallback(const void *inputBuffer, void *outputBuffer,
int ix;
int result;
unsigned char *p;
+ unsigned char *out_buf;
+ unsigned char *out_end2;
+ int pa_size;
- out_ptr = out_start = (unsigned char *)outputBuffer;
- out_end = out_ptr + framesPerBuffer*2;
+ pa_size = framesPerBuffer*2;
+
+ // make a buffer 3x size of the portaudio output
+ ix = pa_size*3;
+ if(ix > outbuffer_size)
+ {
+ outbuffer = (unsigned char *)realloc(outbuffer, ix);
+ if(outbuffer == NULL)
+ {
+ fprintf(stderr, "espeak: out of memory\n");
+ }
+ outbuffer_size = ix;
+ out_ptr = NULL;
+ }
+ if(out_ptr == NULL)
+ {
+ out_ptr = out_start = outbuffer;
+ out_end = out_start + outbuffer_size;
+ }
+ out_end2 = &outbuffer[pa_size]; // top of data needed for the portaudio buffer
#ifdef LIBRARY
event_list_ix = 0;
@@ -462,6 +486,24 @@ static int WaveCallback(const void *inputBuffer, void *outputBuffer,
result = WavegenFill(1);
+ // copy from the outbut buffer into the portaudio buffer
+ if(result && (out_ptr > out_end2))
+ {
+ result = 0; // don't end yet, there is more data in the buffer than can fit in portaudio
+ }
+
+ while(out_ptr < out_end2)
+ *out_ptr++ = 0; // fill with zeros up to the size of the portaudio buffer
+
+ memcpy(outputBuffer, outbuffer, pa_size);
+
+ // move the remaining contents of the start of the output buffer
+ for(p = out_end2; p < out_end; p++)
+ {
+ p[-pa_size] = p[0];
+ }
+ out_ptr -= pa_size;
+
#ifdef LIBRARY
count_samples += framesPerBuffer;
if(synth_callback)
@@ -482,14 +524,15 @@ static int WaveCallback(const void *inputBuffer, void *outputBuffer,
{
// swap the order of bytes in each sound sample in the portaudio buffer
int c;
- out_ptr = (unsigned char *)outputBuffer;
- out_end = out_ptr + framesPerBuffer*2;
- while(out_ptr < out_end)
+ unsigned char *buf_end;
+ out_buf = (unsigned char *)outputBuffer;
+ buf_end = out_buf + framesPerBuffer*2;
+ while(out_buf < buf_end)
{
- c = out_ptr[0];
- out_ptr[0] = out_ptr[1];
- out_ptr[1] = c;
- out_ptr += 2;
+ c = out_buf[0];
+ out_buf[0] = out_buf[1];
+ out_buf[1] = c;
+ out_buf += 2;
}
}
#endif
@@ -498,12 +541,12 @@ static int WaveCallback(const void *inputBuffer, void *outputBuffer,
{
// sound output can only do stereo, not mono. Duplicate each sound sample to
// produce 2 channels.
- out_ptr = (unsigned char *)outputBuffer;
+ out_buf = (unsigned char *)outputBuffer;
for(ix=framesPerBuffer-1; ix>=0; ix--)
{
- p = &out_ptr[ix*4];
- p[3] = p[1] = out_ptr[ix*2 + 1];
- p[2] = p[0] = out_ptr[ix*2];
+ p = &out_buf[ix*4];
+ p[3] = p[1] = out_buf[ix*2 + 1];
+ p[2] = p[0] = out_buf[ix*2];
}
}
@@ -553,7 +596,7 @@ static PaError Pa_OpenDefaultStream2( PaStream** stream,
hostApiOutputParameters.device = Pa_GetDefaultOutputDevice();
if( hostApiOutputParameters.device == paNoDevice )
- return paDeviceUnavailable;
+ return paDeviceUnavailable;
hostApiOutputParameters.channelCount = outputChannelCount;
hostApiOutputParameters.sampleFormat = sampleFormat;
@@ -574,7 +617,7 @@ static PaError Pa_OpenDefaultStream2( PaStream** stream,
#endif
-int WavegenOpenSound()
+int WavegenOpenSound(void)
{//===================
PaError err, err2;
PaError active;
@@ -639,7 +682,7 @@ int WavegenOpenSound()
-int WavegenCloseSound()
+int WavegenCloseSound(void)
{//====================
PaError active;
@@ -669,7 +712,7 @@ int WavegenCloseSound()
}
-int WavegenInitSound()
+int WavegenInitSound(void)
{//===================
PaError err;
@@ -687,15 +730,15 @@ int WavegenInitSound()
return(0);
}
#else
-int WavegenOpenSound()
+int WavegenOpenSound(void)
{//===================
return(0);
}
-int WavegenCloseSound()
+int WavegenCloseSound(void)
{//====================
return(0);
}
-int WavegenInitSound()
+int WavegenInitSound(void)
{//===================
return(0);
}
@@ -720,7 +763,7 @@ void WavegenInit(int rate, int wavemult_fact)
max_hval = 0;
wdata.amplitude = 32;
- wdata.prev_was_synth = 0;
+ wdata.amplitude_fmt = 100;
for(ix=0; ix<N_EMBEDDED_VALUES; ix++)
embedded_value[ix] = embedded_default[ix];
@@ -754,6 +797,7 @@ void WavegenInit(int rate, int wavemult_fact)
#ifdef LOG_FRAMES
remove("log-espeakedit");
+remove("log-klatt");
#endif
} // end of WavegenInit
@@ -794,12 +838,6 @@ static void WavegenSetEcho(void)
amp = embedded_value[EMBED_H];
delay = 130;
}
- if(embedded_value[EMBED_T] > 0)
- {
- // announcing punctuation
- amp = embedded_value[EMBED_T] * 8;
- delay = 60;
- }
if(delay == 0)
amp = 0;
@@ -811,7 +849,7 @@ static void WavegenSetEcho(void)
if(amp > 20)
echo_length = echo_head * 2; // perhaps allow 2 echo periods if the echo is loud.
- // echo_amp units are 1/256ths of the amplitude of the original sound.
+ // echo_amp units are 1/256ths of the amplitude of the original sound.
echo_amp = amp;
// compensate (partially) for increase in amplitude due to echo
general_amplitude = GetAmplitude();
@@ -820,7 +858,7 @@ static void WavegenSetEcho(void)
-int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
+static int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
{//============================================================================
// Calculate the amplitude of each harmonics from the formants
// Only for formants 0 to 5
@@ -951,7 +989,7 @@ int h2;
-static void AdvanceParameters()
+static void AdvanceParameters(void)
{//============================
// Called every 64 samples to increment the formant freq, height, and widths
@@ -982,16 +1020,16 @@ static void AdvanceParameters()
for(ix=0; ix <= wvoice->n_harmonic_peaks; ix++)
{
peaks[ix].freq1 += peaks[ix].freq_inc;
- peaks[ix].freq = (int)(peaks[ix].freq1);
+ peaks[ix].freq = (int)peaks[ix].freq1;
peaks[ix].height1 += peaks[ix].height_inc;
- if((peaks[ix].height = (int)(peaks[ix].height1)) < 0)
+ if((peaks[ix].height = (int)peaks[ix].height1) < 0)
peaks[ix].height = 0;
peaks[ix].left1 += peaks[ix].left_inc;
- peaks[ix].left = (int)(peaks[ix].left1);
+ peaks[ix].left = (int)peaks[ix].left1;
if(ix < 3)
{
peaks[ix].right1 += peaks[ix].right_inc;
- peaks[ix].right = (int)(peaks[ix].right1);
+ peaks[ix].right = (int)peaks[ix].right1;
}
else
{
@@ -1004,10 +1042,10 @@ static void AdvanceParameters()
if(ix < 7)
{
peaks[ix].freq1 += peaks[ix].freq_inc;
- peaks[ix].freq = (int)(peaks[ix].freq1);
+ peaks[ix].freq = (int)peaks[ix].freq1;
}
peaks[ix].height1 += peaks[ix].height_inc;
- if((peaks[ix].height = (int)(peaks[ix].height1)) < 0)
+ if((peaks[ix].height = (int)peaks[ix].height1) < 0)
peaks[ix].height = 0;
}
@@ -1086,7 +1124,7 @@ void InitBreath(void)
-static void SetBreath()
+static void SetBreath(void)
{//====================
#ifndef PLATFORM_RISCOS
int pk;
@@ -1123,7 +1161,7 @@ static int ApplyBreath(void)
if((amp = wvoice->breath[ix]) != 0)
{
amp *= (peaks[ix].height >> 14);
- value += (int)(resonator(&rbreath[ix],noise) * amp);
+ value += (int)resonator(&rbreath[ix],noise) * amp;
}
}
#endif
@@ -1132,7 +1170,7 @@ static int ApplyBreath(void)
-int Wavegen()
+static int Wavegen(void)
{//==========
unsigned short waveph;
unsigned short theta;
@@ -1171,7 +1209,8 @@ int Wavegen()
maxh2 = PeaksToHarmspect(peaks, wdata.pitch<<4, hspect[0], 0);
// adjust amplitude to compensate for fewer harmonics at higher pitch
- amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
+// amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
+ amplitude2 = (wdata.amplitude * (wdata.pitch >> 8) * wdata.amplitude_fmt)/(10000 << 3);
// switch sign of harmonics above about 900Hz, to reduce max peak amplitude
h_switch_sign = 890 / (wdata.pitch >> 12);
@@ -1220,11 +1259,12 @@ int Wavegen()
for(pk=wvoice->n_harmonic_peaks+1; pk<N_PEAKS; pk++)
{
// find the nearest harmonic for HF peaks where we don't use shape
- peak_harmonic[pk] = peaks[pk].freq / (wdata.pitch*16);
+ peak_harmonic[pk] = ((peaks[pk].freq / (wdata.pitch*8)) + 1) / 2;
}
// adjust amplitude to compensate for fewer harmonics at higher pitch
- amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
+// amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
+ amplitude2 = (wdata.amplitude * (wdata.pitch >> 8) * wdata.amplitude_fmt)/(10000 << 3);
if(glottal_flag > 0)
{
@@ -1321,12 +1361,12 @@ int Wavegen()
for(h=1; h<=h_switch_sign; h++)
{
- total += ((int)(sin_tab[theta >> 5]) * harmspect[h]);
+ total += ((int)sin_tab[theta >> 5] * harmspect[h]);
theta += waveph;
}
while(h<=maxh)
{
- total -= ((int)(sin_tab[theta >> 5]) * harmspect[h]);
+ total -= ((int)sin_tab[theta >> 5] * harmspect[h]);
theta += waveph;
h++;
}
@@ -1351,17 +1391,20 @@ int Wavegen()
if(wdata.mix_wave_scale == 0)
{
// a 16 bit sample
- c = wdata.mix_wavefile[wdata.mix_wavefile_ix+1];
- sample = wdata.mix_wavefile[wdata.mix_wavefile_ix] + (c * 256);
+ c = wdata.mix_wavefile[wdata.mix_wavefile_ix+wdata.mix_wavefile_offset+1];
+ sample = wdata.mix_wavefile[wdata.mix_wavefile_ix+wdata.mix_wavefile_offset] + (c * 256);
wdata.mix_wavefile_ix += 2;
}
else
{
// a 8 bit sample, scaled
- sample = (signed char)wdata.mix_wavefile[wdata.mix_wavefile_ix++] * wdata.mix_wave_scale;
+ sample = (signed char)wdata.mix_wavefile[wdata.mix_wavefile_offset+wdata.mix_wavefile_ix++] * wdata.mix_wave_scale;
}
z2 = (sample * wdata.amplitude_v) >> 10;
z2 = (z2 * wdata.mix_wave_amp)/32;
+
+ if((wdata.mix_wavefile_ix + wdata.mix_wavefile_offset) >= wdata.mix_wavefile_max) // reached the end of available WAV data
+ wdata.mix_wavefile_offset -= (wdata.mix_wavefile_max*3)/4;
}
z1 = z2 + (((total>>8) * amplitude2) >> 13);
@@ -1406,11 +1449,12 @@ static int PlaySilence(int length, int resume)
static int n_samples;
int value=0;
- if(length == 0)
- return(0);
-
nsamples = 0;
samplecount = 0;
+ wavephase = 0x7fffffff;
+
+ if(length == 0)
+ return(0);
if(resume==0)
n_samples = length;
@@ -1507,14 +1551,38 @@ static int SetWithRange0(int value, int max)
}
+static void SetPitchFormants(void)
+{//===========================
+ int ix;
+ int factor = 256;
+ int pitch_value;
+
+ // adjust formants to give better results for a different voice pitch
+ if((pitch_value = embedded_value[EMBED_P]) > MAX_PITCH_VALUE)
+ pitch_value = MAX_PITCH_VALUE;
+
+ if(pitch_value > 50)
+ {
+ // only adjust if the pitch is higher than normal
+ factor = 256 + (25 * (pitch_value - 50))/50;
+ }
+
+ for(ix=0; ix<=5; ix++)
+ {
+ wvoice->freq[ix] = (wvoice->freq2[ix] * factor)/256;
+ }
+
+ factor = embedded_value[EMBED_T]*3;
+ wvoice->height[0] = (wvoice->height2[0] * (256 - factor*2))/256;
+ wvoice->height[1] = (wvoice->height2[1] * (256 - factor))/256;
+}
+
+
void SetEmbedded(int control, int value)
{//=====================================
// there was an embedded command in the text at this point
int sign=0;
int command;
- int ix;
- int factor;
- int pitch_value;
command = control & 0x1f;
if((control & 0x60) == 0x60)
@@ -1537,25 +1605,14 @@ void SetEmbedded(int control, int value)
case EMBED_T:
WavegenSetEcho(); // and drop through to case P
case EMBED_P:
- // adjust formants to give better results for a different voice pitch
- if((pitch_value = embedded_value[EMBED_P]) > MAX_PITCH_VALUE)
- pitch_value = MAX_PITCH_VALUE;
-
- factor = 256 + (25 * (pitch_value - 50))/50;
- for(ix=0; ix<=5; ix++)
- {
- wvoice->freq[ix] = (wvoice->freq2[ix] * factor)/256;
- }
- factor = embedded_value[EMBED_T]*3;
- wvoice->height[0] = (wvoice->height2[0] * (256 - factor*2))/256;
- wvoice->height[1] = (wvoice->height2[1] * (256 - factor))/256;
+ SetPitchFormants();
break;
case EMBED_A: // amplitude
general_amplitude = GetAmplitude();
break;
- case EMBED_F: // emphasiis
+ case EMBED_F: // emphasis
general_amplitude = GetAmplitude();
break;
@@ -1585,6 +1642,9 @@ void WavegenSetVoice(voice_t *v)
option_harmonic1 = 6;
}
WavegenSetEcho();
+ SetPitchFormants();
+ MarkerEvent(espeakEVENT_SAMPLERATE, 0, wvoice->samplerate, 0, out_ptr);
+// WVoiceChanged(wvoice);
}
@@ -1629,12 +1689,12 @@ void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pit
// compensate for change in pitch when the range is narrowed or widened
base -= (range - voice->pitch_range)*18;
- *pitch_base = base + (pitch1 * range);
- *pitch_range = base + (pitch2 * range) - *pitch_base;
+ *pitch_base = base + (pitch1 * range)/2;
+ *pitch_range = base + (pitch2 * range)/2 - *pitch_base;
}
-void SetPitch(int length, unsigned char *env, int pitch1, int pitch2)
+static void SetPitch(int length, unsigned char *env, int pitch1, int pitch2)
{//==================================================================
// length in samples
@@ -1671,7 +1731,7 @@ if(option_log_frames)
-void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v)
+static void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v)
{//========================================================================
int ix;
DOUBLEX next;
@@ -1692,7 +1752,7 @@ if(option_log_frames)
fprintf(f_log,"%3dmS %3d %3d %4d %4d (%3d %3d %3d %3d) to %3d %3d %4d %4d (%3d %3d %3d %3d)\n",length*1000/samplerate,
fr1->ffreq[0],fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3], fr1->fheight[0],fr1->fheight[1],fr1->fheight[2],fr1->fheight[3],
fr2->ffreq[0],fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3], fr2->fheight[0],fr2->fheight[1],fr2->fheight[2],fr2->fheight[3] );
-
+
fclose(f_log);
f_log=NULL;
}
@@ -1751,27 +1811,27 @@ if(option_log_frames)
if(ix < 7)
{
peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
- peaks[ix].freq = (int)(peaks[ix].freq1);
+ peaks[ix].freq = (int)peaks[ix].freq1;
next = (fr2->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * (STEPSIZE/4)) / length4; // lower headroom for fixed point math
}
peaks[ix].height1 = (fr1->fheight[ix] * v->height[ix]) << 6;
- peaks[ix].height = (int)(peaks[ix].height1);
+ peaks[ix].height = (int)peaks[ix].height1;
next = (fr2->fheight[ix] * v->height[ix]) << 6;
peaks[ix].height_inc = ((next - peaks[ix].height1) * STEPSIZE) / length2;
- if(ix <= wvoice->n_harmonic_peaks)
+ if((ix <= 5) && (ix <= wvoice->n_harmonic_peaks))
{
peaks[ix].left1 = (fr1->fwidth[ix] * v->width[ix]) << 10;
- peaks[ix].left = int(peaks[ix].left1);
+ peaks[ix].left = (int)peaks[ix].left1;
next = (fr2->fwidth[ix] * v->width[ix]) << 10;
peaks[ix].left_inc = ((next - peaks[ix].left1) * STEPSIZE) / length2;
if(ix < 3)
{
peaks[ix].right1 = (fr1->fright[ix] * v->width[ix]) << 10;
- peaks[ix].right = int(peaks[ix].right1);
+ peaks[ix].right = (int)peaks[ix].right1;
next = (fr2->fright[ix] * v->width[ix]) << 10;
peaks[ix].right_inc = ((next - peaks[ix].right1) * STEPSIZE) / length2;
}
@@ -1806,24 +1866,19 @@ void Write4Bytes(FILE *f, int value)
-
-int WavegenFill(int fill_zeros)
+static int WavegenFill2(int fill_zeros)
{//============================
// Pick up next wavegen commands from the queue
// return: 0 output buffer has been filled
// return: 1 input command queue is now empty
- long *q;
+ long64 *q;
int length;
int result;
+ int marker_type;
static int resume=0;
static int echo_complete=0;
-#ifdef TEST_MBROLA
- if(mbrola_name[0] != 0)
- return(MbrolaFill(fill_zeros));
-#endif
-
while(out_ptr < out_end)
{
if(WcmdqUsed() <= 0)
@@ -1848,7 +1903,7 @@ int WavegenFill(int fill_zeros)
q = wcmdq[wcmdq_head];
length = q[1];
- switch(q[0])
+ switch(q[0] & 0xff)
{
case WCMD_PITCH:
SetPitch(length,(unsigned char *)q[2],q[3] >> 16,q[3] & 0xffff);
@@ -1860,14 +1915,19 @@ int WavegenFill(int fill_zeros)
echo_complete -= length;
}
wdata.n_mix_wavefile = 0;
- wdata.prev_was_synth = 0;
+ wdata.amplitude_fmt = 100;
+#ifdef INCLUDE_KLATT
+ KlattReset(1);
+#endif
result = PlaySilence(length,resume);
break;
case WCMD_WAVE:
echo_complete = echo_length;
wdata.n_mix_wavefile = 0;
- wdata.prev_was_synth = 0;
+#ifdef INCLUDE_KLATT
+ KlattReset(1);
+#endif
result = PlayWave(length,resume,(unsigned char*)q[2], q[3] & 0xff, q[3] >> 8);
break;
@@ -1875,11 +1935,15 @@ int WavegenFill(int fill_zeros)
// wave file to be played at the same time as synthesis
wdata.mix_wave_amp = q[3] >> 8;
wdata.mix_wave_scale = q[3] & 0xff;
+ wdata.n_mix_wavefile = (length & 0xffff);
+ wdata.mix_wavefile_max = (length >> 16) & 0xffff;
if(wdata.mix_wave_scale == 0)
- wdata.n_mix_wavefile = length*2;
- else
- wdata.n_mix_wavefile = length;
+ {
+ wdata.n_mix_wavefile *= 2;
+ wdata.mix_wavefile_max *= 2;
+ }
wdata.mix_wavefile_ix = 0;
+ wdata.mix_wavefile_offset = 0;
wdata.mix_wavefile = (unsigned char *)q[2];
break;
@@ -1900,13 +1964,14 @@ int WavegenFill(int fill_zeros)
#endif
case WCMD_MARKER:
- MarkerEvent(q[1],q[2],q[3],out_ptr);
+ marker_type = q[0] >> 8;
+ MarkerEvent(marker_type, q[1],q[2],q[3],out_ptr);
#ifdef LOG_FRAMES
- LogMarker(q[1],q[3]);
+ LogMarker(marker_type, q[2], q[3]);
#endif
- if(q[1] == 1)
+ if(marker_type == 1) // word marker
{
- current_source_index = q[2] & 0xffffff;
+ current_source_index = q[1] & 0xffffff;
}
break;
@@ -1915,13 +1980,28 @@ int WavegenFill(int fill_zeros)
break;
case WCMD_VOICE:
- WavegenSetVoice((voice_t *)q[1]);
- free((voice_t *)q[1]);
+ WavegenSetVoice((voice_t *)q[2]);
+ free((voice_t *)q[2]);
break;
case WCMD_EMBEDDED:
SetEmbedded(q[1],q[2]);
break;
+
+ case WCMD_MBROLA_DATA:
+ result = MbrolaFill(length, resume, (general_amplitude * wvoice->voicing)/64);
+ break;
+
+ case WCMD_FMT_AMPLITUDE:
+ if((wdata.amplitude_fmt = q[1]) == 0)
+ wdata.amplitude_fmt = 100; // percentage, but value=0 means 100%
+ break;
+
+#ifdef INCLUDE_SONIC
+ case WCMD_SONIC_SPEED:
+ sonicSpeed = (double)q[1] / 1024;
+ break;
+#endif
}
if(result==0)
@@ -1936,6 +2016,64 @@ int WavegenFill(int fill_zeros)
}
return(0);
-} // end of WavegenFill
+} // end of WavegenFill2
+#ifdef INCLUDE_SONIC
+/* Speed up the audio samples with libsonic. */
+static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text)
+{//==============================================================================
+ if(length_in >0)
+ {
+ if(sonicSpeedupStream == NULL)
+ {
+ sonicSpeedupStream = sonicCreateStream(22050, 1);
+ }
+ if(sonicGetSpeed(sonicSpeedupStream) != sonicSpeed)
+ {
+ sonicSetSpeed(sonicSpeedupStream, sonicSpeed);
+ }
+
+ sonicWriteShortToStream(sonicSpeedupStream, outbuf, length_in);
+ }
+
+ if(sonicSpeedupStream == NULL)
+ return(0);
+
+ if(end_of_text)
+ {
+ sonicFlushStream(sonicSpeedupStream);
+ }
+ return sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out);
+} // end of SpeedUp
+#endif
+
+
+/* Call WavegenFill2, and then speed up the output samples. */
+int WavegenFill(int fill_zeros)
+{//============================
+ int finished;
+ unsigned char *p_start;
+
+ p_start = out_ptr;
+
+ // fill_zeros is ignored. It is now done in the portaudio callback
+ finished = WavegenFill2(0);
+
+#ifdef INCLUDE_SONIC
+ if(sonicSpeed > 1.0)
+ {
+ int length;
+ int max_length;
+
+ max_length = (out_end - p_start);
+ length = 2*SpeedUp((short *)p_start, (out_ptr-p_start)/2, max_length/2, finished);
+ out_ptr = p_start + length;
+
+ if(length >= max_length)
+ finished = 0; // there may be more data to flush
+ }
+#endif
+ return finished;
+} // end of WavegenFill
+
diff --git a/navit/support/espeak/wavegen.h b/navit/support/espeak/wavegen.h
new file mode 100644
index 000000000..67b816c6d
--- /dev/null
+++ b/navit/support/espeak/wavegen.h
@@ -0,0 +1,21 @@
+/***************************************************************************
+ * Copyright (C) 2005 to 2010 by Jonathan Duddington *
+ * email: jonsd@users.sourceforge.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, see: *
+ * <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pitch_range);
+int GetAmplitude(void);
diff --git a/navit/support/gettext_intl/dcigettext.c b/navit/support/gettext_intl/dcigettext.c
index 9d4e3542e..1b66fba37 100644
--- a/navit/support/gettext_intl/dcigettext.c
+++ b/navit/support/gettext_intl/dcigettext.c
@@ -133,6 +133,11 @@ extern int errno;
# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
#endif
+#if defined(__MINGW32__) && !defined(__MINGW32CE__)
+# define HAVE_MEMPCPY 1
+#endif
+
+
/* @@ end of prolog @@ */
#ifdef _LIBC
@@ -158,7 +163,7 @@ char *getcwd ();
# ifndef HAVE_STPCPY
static char *stpcpy (char *dest, const char *src);
# endif
-# ifndef HAVE_MEMPCPY
+# if !defined(HAVE_MEMPCPY)
static void *mempcpy (void *dest, const void *src, size_t n);
# endif
#endif
diff --git a/navit/support/gettext_intl/localealias.c b/navit/support/gettext_intl/localealias.c
index ee27649af..9078994d4 100644
--- a/navit/support/gettext_intl/localealias.c
+++ b/navit/support/gettext_intl/localealias.c
@@ -88,6 +88,10 @@ char *alloca ();
__libc_lock_define_initialized (static, lock);
#endif
+#if defined(__MINGW32__) && !defined(__MINGW32CE__)
+# define HAVE_MEMPCPY 1
+#endif
+
#ifndef internal_function
# define internal_function
#endif
diff --git a/navit/support/glib/CMakeLists.txt b/navit/support/glib/CMakeLists.txt
index 322d5467e..56d1ae8d3 100644
--- a/navit/support/glib/CMakeLists.txt
+++ b/navit/support/glib/CMakeLists.txt
@@ -1,3 +1,3 @@
supportlib_add_library(support_glib fake.c galiasdef.c gatomic.c gerror.c ghash.c
- glib_init.c glist.c gmem.c gmessages.c gprimes.c gprintf.c gslice.c gslist.c
- gstrfuncs.c gstring.c gutf8.c gutils.c)
+ glib_init.c glist.c gmem.c gmessages.c gprimes.c gprintf.c gslice.c gslist.c
+ gstrfuncs.c gstring.c gutf8.c gutils.c)
diff --git a/navit/support/glib/gutils.c b/navit/support/glib/gutils.c
index 6d3fda447..9a9477f19 100644
--- a/navit/support/glib/gutils.c
+++ b/navit/support/glib/gutils.c
@@ -756,7 +756,6 @@ g_path_get_basename (const gchar *file_name)
return retval;
}
-#if NOT_NEEDED_FOR_NAVIT
/**
* g_path_is_absolute:
* @file_name: a file name.
@@ -785,6 +784,7 @@ g_path_is_absolute (const gchar *file_name)
return FALSE;
}
+#if NOT_NEEDED_FOR_NAVIT
/**
* g_path_skip_root:
* @file_name: a file name.
@@ -851,6 +851,7 @@ g_path_skip_root (const gchar *file_name)
return NULL;
}
+#endif
/**
* g_path_get_dirname:
@@ -952,6 +953,7 @@ g_path_get_dirname (const gchar *file_name)
return base;
}
+#if NOT_NEEDED_FOR_NAVIT
/**
* g_get_current_dir:
*
diff --git a/navit/support/libc/stat.c b/navit/support/libc/stat.c
index 586dcf714..e66a90737 100644
--- a/navit/support/libc/stat.c
+++ b/navit/support/libc/stat.c
@@ -120,13 +120,13 @@ _stat (const char *path, struct _stat *st)
size_t len;
int exec;
- dbg(lvl_debug,"path=%s\n",path);
+ dbg(lvl_debug,"path=%s",path);
mbstowcs (pathw, path, MAX_PATH);
- dbg(lvl_debug,"wide path=%S\n",pathw);
+ dbg(lvl_debug,"wide path=%S",pathw);
if((h = FindFirstFileW (pathw, &fd)) == INVALID_HANDLE_VALUE)
{
DWORD dwError = GetLastError ();
- dbg(lvl_error,"no file\n");
+ dbg(lvl_error,"no file");
if(dwError == ERROR_NO_MORE_FILES)
/* Convert error to something more sensible. */
SetLastError (ERROR_FILE_NOT_FOUND);
@@ -139,7 +139,7 @@ _stat (const char *path, struct _stat *st)
exec = (len >= 4
&& strcasecmp (path + len - 4, ".exe") == 0);
ret = __stat_by_file_info (&sfi, st, exec);
- dbg(lvl_debug,"ret=%d\n",ret);
+ dbg(lvl_debug,"ret=%d",ret);
FindClose (h);
return ret;
}
diff --git a/navit/support/win32/X11/XF86keysym.h b/navit/support/win32/X11/XF86keysym.h
index ff4980457..ee783c2fc 100644
--- a/navit/support/win32/X11/XF86keysym.h
+++ b/navit/support/win32/X11/XF86keysym.h
@@ -1,189 +1,189 @@
-/* $XFree86: xc/include/XF86keysym.h,v 1.16 2003/02/11 02:51:10 dawes Exp $ */
-
-/*
- * XFree86 vendor specific keysyms.
- *
- * The XFree86 keysym range is 0x10080001 - 0x1008FFFF.
- *
- * When adding new entries, the xc/lib/XKeysymDB file should also be
- * updated to make the new entries visible to Xlib.
- */
-
-/*
- * ModeLock
- *
- * This one is old, and not really used any more since XKB offers this
- * functionality.
- */
-
-#define XF86XK_ModeLock 0x1008FF01 /* Mode Switch Lock */
-
-/*
- * Note, 0x1008FF02 - 0x1008FF0F are free and should be used for misc new
- * keysyms that don't fit into any of the groups below.
- *
- * 0x1008FF64, 0x1008FF6F, 0x1008FF71, 0x1008FF83 are no longer used,
- * and should be used first for new keysyms.
- *
- * Check in keysymdef.h for generic symbols before adding new XFree86-specific
- * symbols here.
- */
-
-
-/*
- * Keys found on some "Internet" keyboards.
- */
-#define XF86XK_Standby 0x1008FF10
-#define XF86XK_AudioLowerVolume 0x1008FF11
-#define XF86XK_AudioMute 0x1008FF12
-#define XF86XK_AudioRaiseVolume 0x1008FF13
-#define XF86XK_AudioPlay 0x1008FF14
-#define XF86XK_AudioStop 0x1008FF15
-#define XF86XK_AudioPrev 0x1008FF16
-#define XF86XK_AudioNext 0x1008FF17
-#define XF86XK_HomePage 0x1008FF18
-#define XF86XK_Mail 0x1008FF19
-#define XF86XK_Start 0x1008FF1A
-#define XF86XK_Search 0x1008FF1B
-#define XF86XK_AudioRecord 0x1008FF1C
-
-/* These are sometimes found on PDA's (e.g. Palm, PocketPC or elsewhere) */
-#define XF86XK_Calculator 0x1008FF1D
-#define XF86XK_Memo 0x1008FF1E
-#define XF86XK_ToDoList 0x1008FF1F
-#define XF86XK_Calendar 0x1008FF20
-#define XF86XK_PowerDown 0x1008FF21
-#define XF86XK_ContrastAdjust 0x1008FF22
-#define XF86XK_RockerUp 0x1008FF23
-#define XF86XK_RockerDown 0x1008FF24
-#define XF86XK_RockerEnter 0x1008FF25
-
-/* Some more "Internet" keyboard symbols */
-#define XF86XK_Back 0x1008FF26
-#define XF86XK_Forward 0x1008FF27
-#define XF86XK_Stop 0x1008FF28
-#define XF86XK_Refresh 0x1008FF29
-#define XF86XK_PowerOff 0x1008FF2A
-#define XF86XK_WakeUp 0x1008FF2B
-#define XF86XK_Eject 0x1008FF2C
-#define XF86XK_ScreenSaver 0x1008FF2D
-#define XF86XK_WWW 0x1008FF2E
-#define XF86XK_Sleep 0x1008FF2F
-#define XF86XK_Favorites 0x1008FF30
-#define XF86XK_AudioPause 0x1008FF31
-#define XF86XK_AudioMedia 0x1008FF32
-#define XF86XK_MyComputer 0x1008FF33
-#define XF86XK_VendorHome 0x1008FF34
-#define XF86XK_LightBulb 0x1008FF35
-#define XF86XK_Shop 0x1008FF36
-#define XF86XK_History 0x1008FF37
-#define XF86XK_OpenURL 0x1008FF38
-#define XF86XK_AddFavorite 0x1008FF39
-#define XF86XK_HotLinks 0x1008FF3A
-#define XF86XK_BrightnessAdjust 0x1008FF3B
-#define XF86XK_Finance 0x1008FF3C
-#define XF86XK_Community 0x1008FF3D
-#define XF86XK_AudioRewind 0x1008FF3E
-#define XF86XK_XF86BackForward 0x1008FF3F
-#define XF86XK_Launch0 0x1008FF40
-#define XF86XK_Launch1 0x1008FF41
-#define XF86XK_Launch2 0x1008FF42
-#define XF86XK_Launch3 0x1008FF43
-#define XF86XK_Launch4 0x1008FF44
-#define XF86XK_Launch5 0x1008FF45
-#define XF86XK_Launch6 0x1008FF46
-#define XF86XK_Launch7 0x1008FF47
-#define XF86XK_Launch8 0x1008FF48
-#define XF86XK_Launch9 0x1008FF49
-#define XF86XK_LaunchA 0x1008FF4A
-#define XF86XK_LaunchB 0x1008FF4B
-#define XF86XK_LaunchC 0x1008FF4C
-#define XF86XK_LaunchD 0x1008FF4D
-#define XF86XK_LaunchE 0x1008FF4E
-#define XF86XK_LaunchF 0x1008FF4F
-
-#define XF86XK_ApplicationLeft 0x1008FF50
-#define XF86XK_ApplicationRight 0x1008FF51
-#define XF86XK_Book 0x1008FF52
-#define XF86XK_CD 0x1008FF53
-#define XF86XK_Calculater 0x1008FF54
-#define XF86XK_Clear 0x1008FF55
-#define XF86XK_Close 0x1008FF56
-#define XF86XK_Copy 0x1008FF57
-#define XF86XK_Cut 0x1008FF58
-#define XF86XK_Display 0x1008FF59
-#define XF86XK_DOS 0x1008FF5A
-#define XF86XK_Documents 0x1008FF5B
-#define XF86XK_Excel 0x1008FF5C
-#define XF86XK_Explorer 0x1008FF5D
-#define XF86XK_Game 0x1008FF5E
-#define XF86XK_Go 0x1008FF5F
-#define XF86XK_iTouch 0x1008FF60
-#define XF86XK_LogOff 0x1008FF61
-#define XF86XK_Market 0x1008FF62
-#define XF86XK_Meeting 0x1008FF63
-#define XF86XK_MenuKB 0x1008FF65
-#define XF86XK_MenuPB 0x1008FF66
-#define XF86XK_MySites 0x1008FF67
-#define XF86XK_New 0x1008FF68
-#define XF86XK_News 0x1008FF69
-#define XF86XK_OfficeHome 0x1008FF6A
-#define XF86XK_Open 0x1008FF6B
-#define XF86XK_Option 0x1008FF6C
-#define XF86XK_Paste 0x1008FF6D
-#define XF86XK_Phone 0x1008FF6E
-#define XF86XK_Q 0x1008FF70
-#define XF86XK_Reply 0x1008FF72
-#define XF86XK_Reload 0x1008FF73
-#define XF86XK_RotateWindows 0x1008FF74
-#define XF86XK_RotationPB 0x1008FF75
-#define XF86XK_RotationKB 0x1008FF76
-#define XF86XK_Save 0x1008FF77
-#define XF86XK_ScrollUp 0x1008FF78
-#define XF86XK_ScrollDown 0x1008FF79
-#define XF86XK_ScrollClick 0x1008FF7A
-#define XF86XK_Send 0x1008FF7B
-#define XF86XK_Spell 0x1008FF7C
-#define XF86XK_SplitScreen 0x1008FF7D
-#define XF86XK_Support 0x1008FF7E
-#define XF86XK_TaskPane 0x1008FF7F
-#define XF86XK_Terminal 0x1008FF80
-#define XF86XK_Tools 0x1008FF81
-#define XF86XK_Travel 0x1008FF82
-#define XF86XK_UserPB 0x1008FF84
-#define XF86XK_User1KB 0x1008FF85
-#define XF86XK_User2KB 0x1008FF86
-#define XF86XK_Video 0x1008FF87
-#define XF86XK_WheelButton 0x1008FF88
-#define XF86XK_Word 0x1008FF89
-#define XF86XK_Xfer 0x1008FF8A
-#define XF86XK_ZoomIn 0x1008FF8B
-#define XF86XK_ZoomOut 0x1008FF8C
-
-#define XF86XK_Away 0x1008FF8D
-#define XF86XK_Messenger 0x1008FF8E
-#define XF86XK_WebCam 0x1008FF8F
-#define XF86XK_MailForward 0x1008FF90
-#define XF86XK_Pictures 0x1008FF91
-#define XF86XK_Music 0x1008FF92
-
-/* Keys for special action keys (hot keys) */
-#define XF86XK_Switch_VT_1 0x1008FE01
-#define XF86XK_Switch_VT_2 0x1008FE02
-#define XF86XK_Switch_VT_3 0x1008FE03
-#define XF86XK_Switch_VT_4 0x1008FE04
-#define XF86XK_Switch_VT_5 0x1008FE05
-#define XF86XK_Switch_VT_6 0x1008FE06
-#define XF86XK_Switch_VT_7 0x1008FE07
-#define XF86XK_Switch_VT_8 0x1008FE08
-#define XF86XK_Switch_VT_9 0x1008FE09
-#define XF86XK_Switch_VT_10 0x1008FE0A
-#define XF86XK_Switch_VT_11 0x1008FE0B
-#define XF86XK_Switch_VT_12 0x1008FE0C
-
-#define XF86XK_Ungrab 0x1008FE20
-#define XF86XK_ClearGrab 0x1008FE21
-#define XF86XK_Next_VMode 0x1008FE22
-#define XF86XK_Prev_VMode 0x1008FE23
-
-
+/* $XFree86: xc/include/XF86keysym.h,v 1.16 2003/02/11 02:51:10 dawes Exp $ */
+
+/*
+ * XFree86 vendor specific keysyms.
+ *
+ * The XFree86 keysym range is 0x10080001 - 0x1008FFFF.
+ *
+ * When adding new entries, the xc/lib/XKeysymDB file should also be
+ * updated to make the new entries visible to Xlib.
+ */
+
+/*
+ * ModeLock
+ *
+ * This one is old, and not really used any more since XKB offers this
+ * functionality.
+ */
+
+#define XF86XK_ModeLock 0x1008FF01 /* Mode Switch Lock */
+
+/*
+ * Note, 0x1008FF02 - 0x1008FF0F are free and should be used for misc new
+ * keysyms that don't fit into any of the groups below.
+ *
+ * 0x1008FF64, 0x1008FF6F, 0x1008FF71, 0x1008FF83 are no longer used,
+ * and should be used first for new keysyms.
+ *
+ * Check in keysymdef.h for generic symbols before adding new XFree86-specific
+ * symbols here.
+ */
+
+
+/*
+ * Keys found on some "Internet" keyboards.
+ */
+#define XF86XK_Standby 0x1008FF10
+#define XF86XK_AudioLowerVolume 0x1008FF11
+#define XF86XK_AudioMute 0x1008FF12
+#define XF86XK_AudioRaiseVolume 0x1008FF13
+#define XF86XK_AudioPlay 0x1008FF14
+#define XF86XK_AudioStop 0x1008FF15
+#define XF86XK_AudioPrev 0x1008FF16
+#define XF86XK_AudioNext 0x1008FF17
+#define XF86XK_HomePage 0x1008FF18
+#define XF86XK_Mail 0x1008FF19
+#define XF86XK_Start 0x1008FF1A
+#define XF86XK_Search 0x1008FF1B
+#define XF86XK_AudioRecord 0x1008FF1C
+
+/* These are sometimes found on PDA's (e.g. Palm, PocketPC or elsewhere) */
+#define XF86XK_Calculator 0x1008FF1D
+#define XF86XK_Memo 0x1008FF1E
+#define XF86XK_ToDoList 0x1008FF1F
+#define XF86XK_Calendar 0x1008FF20
+#define XF86XK_PowerDown 0x1008FF21
+#define XF86XK_ContrastAdjust 0x1008FF22
+#define XF86XK_RockerUp 0x1008FF23
+#define XF86XK_RockerDown 0x1008FF24
+#define XF86XK_RockerEnter 0x1008FF25
+
+/* Some more "Internet" keyboard symbols */
+#define XF86XK_Back 0x1008FF26
+#define XF86XK_Forward 0x1008FF27
+#define XF86XK_Stop 0x1008FF28
+#define XF86XK_Refresh 0x1008FF29
+#define XF86XK_PowerOff 0x1008FF2A
+#define XF86XK_WakeUp 0x1008FF2B
+#define XF86XK_Eject 0x1008FF2C
+#define XF86XK_ScreenSaver 0x1008FF2D
+#define XF86XK_WWW 0x1008FF2E
+#define XF86XK_Sleep 0x1008FF2F
+#define XF86XK_Favorites 0x1008FF30
+#define XF86XK_AudioPause 0x1008FF31
+#define XF86XK_AudioMedia 0x1008FF32
+#define XF86XK_MyComputer 0x1008FF33
+#define XF86XK_VendorHome 0x1008FF34
+#define XF86XK_LightBulb 0x1008FF35
+#define XF86XK_Shop 0x1008FF36
+#define XF86XK_History 0x1008FF37
+#define XF86XK_OpenURL 0x1008FF38
+#define XF86XK_AddFavorite 0x1008FF39
+#define XF86XK_HotLinks 0x1008FF3A
+#define XF86XK_BrightnessAdjust 0x1008FF3B
+#define XF86XK_Finance 0x1008FF3C
+#define XF86XK_Community 0x1008FF3D
+#define XF86XK_AudioRewind 0x1008FF3E
+#define XF86XK_XF86BackForward 0x1008FF3F
+#define XF86XK_Launch0 0x1008FF40
+#define XF86XK_Launch1 0x1008FF41
+#define XF86XK_Launch2 0x1008FF42
+#define XF86XK_Launch3 0x1008FF43
+#define XF86XK_Launch4 0x1008FF44
+#define XF86XK_Launch5 0x1008FF45
+#define XF86XK_Launch6 0x1008FF46
+#define XF86XK_Launch7 0x1008FF47
+#define XF86XK_Launch8 0x1008FF48
+#define XF86XK_Launch9 0x1008FF49
+#define XF86XK_LaunchA 0x1008FF4A
+#define XF86XK_LaunchB 0x1008FF4B
+#define XF86XK_LaunchC 0x1008FF4C
+#define XF86XK_LaunchD 0x1008FF4D
+#define XF86XK_LaunchE 0x1008FF4E
+#define XF86XK_LaunchF 0x1008FF4F
+
+#define XF86XK_ApplicationLeft 0x1008FF50
+#define XF86XK_ApplicationRight 0x1008FF51
+#define XF86XK_Book 0x1008FF52
+#define XF86XK_CD 0x1008FF53
+#define XF86XK_Calculater 0x1008FF54
+#define XF86XK_Clear 0x1008FF55
+#define XF86XK_Close 0x1008FF56
+#define XF86XK_Copy 0x1008FF57
+#define XF86XK_Cut 0x1008FF58
+#define XF86XK_Display 0x1008FF59
+#define XF86XK_DOS 0x1008FF5A
+#define XF86XK_Documents 0x1008FF5B
+#define XF86XK_Excel 0x1008FF5C
+#define XF86XK_Explorer 0x1008FF5D
+#define XF86XK_Game 0x1008FF5E
+#define XF86XK_Go 0x1008FF5F
+#define XF86XK_iTouch 0x1008FF60
+#define XF86XK_LogOff 0x1008FF61
+#define XF86XK_Market 0x1008FF62
+#define XF86XK_Meeting 0x1008FF63
+#define XF86XK_MenuKB 0x1008FF65
+#define XF86XK_MenuPB 0x1008FF66
+#define XF86XK_MySites 0x1008FF67
+#define XF86XK_New 0x1008FF68
+#define XF86XK_News 0x1008FF69
+#define XF86XK_OfficeHome 0x1008FF6A
+#define XF86XK_Open 0x1008FF6B
+#define XF86XK_Option 0x1008FF6C
+#define XF86XK_Paste 0x1008FF6D
+#define XF86XK_Phone 0x1008FF6E
+#define XF86XK_Q 0x1008FF70
+#define XF86XK_Reply 0x1008FF72
+#define XF86XK_Reload 0x1008FF73
+#define XF86XK_RotateWindows 0x1008FF74
+#define XF86XK_RotationPB 0x1008FF75
+#define XF86XK_RotationKB 0x1008FF76
+#define XF86XK_Save 0x1008FF77
+#define XF86XK_ScrollUp 0x1008FF78
+#define XF86XK_ScrollDown 0x1008FF79
+#define XF86XK_ScrollClick 0x1008FF7A
+#define XF86XK_Send 0x1008FF7B
+#define XF86XK_Spell 0x1008FF7C
+#define XF86XK_SplitScreen 0x1008FF7D
+#define XF86XK_Support 0x1008FF7E
+#define XF86XK_TaskPane 0x1008FF7F
+#define XF86XK_Terminal 0x1008FF80
+#define XF86XK_Tools 0x1008FF81
+#define XF86XK_Travel 0x1008FF82
+#define XF86XK_UserPB 0x1008FF84
+#define XF86XK_User1KB 0x1008FF85
+#define XF86XK_User2KB 0x1008FF86
+#define XF86XK_Video 0x1008FF87
+#define XF86XK_WheelButton 0x1008FF88
+#define XF86XK_Word 0x1008FF89
+#define XF86XK_Xfer 0x1008FF8A
+#define XF86XK_ZoomIn 0x1008FF8B
+#define XF86XK_ZoomOut 0x1008FF8C
+
+#define XF86XK_Away 0x1008FF8D
+#define XF86XK_Messenger 0x1008FF8E
+#define XF86XK_WebCam 0x1008FF8F
+#define XF86XK_MailForward 0x1008FF90
+#define XF86XK_Pictures 0x1008FF91
+#define XF86XK_Music 0x1008FF92
+
+/* Keys for special action keys (hot keys) */
+#define XF86XK_Switch_VT_1 0x1008FE01
+#define XF86XK_Switch_VT_2 0x1008FE02
+#define XF86XK_Switch_VT_3 0x1008FE03
+#define XF86XK_Switch_VT_4 0x1008FE04
+#define XF86XK_Switch_VT_5 0x1008FE05
+#define XF86XK_Switch_VT_6 0x1008FE06
+#define XF86XK_Switch_VT_7 0x1008FE07
+#define XF86XK_Switch_VT_8 0x1008FE08
+#define XF86XK_Switch_VT_9 0x1008FE09
+#define XF86XK_Switch_VT_10 0x1008FE0A
+#define XF86XK_Switch_VT_11 0x1008FE0B
+#define XF86XK_Switch_VT_12 0x1008FE0C
+
+#define XF86XK_Ungrab 0x1008FE20
+#define XF86XK_ClearGrab 0x1008FE21
+#define XF86XK_Next_VMode 0x1008FE22
+#define XF86XK_Prev_VMode 0x1008FE23
+
+
diff --git a/navit/support/win32/addwinsock.c b/navit/support/win32/addwinsock.c
index 63ae968d5..55f8d2167 100644
--- a/navit/support/win32/addwinsock.c
+++ b/navit/support/win32/addwinsock.c
@@ -1,8 +1,8 @@
-#include "addwinsock.h"
-
-int inet_aton(const char *cp, struct in_addr *inp)
-{
- unsigned long addr = inet_addr(cp);
- inp->S_un.S_addr = addr;
- return addr != -1;
-}
+#include "addwinsock.h"
+
+int inet_aton(const char *cp, struct in_addr *inp)
+{
+ unsigned long addr = inet_addr(cp);
+ inp->S_un.S_addr = addr;
+ return addr != -1;
+}
diff --git a/navit/support/win32/addwinsock.h b/navit/support/win32/addwinsock.h
index 49dfdc0cb..f55aceaf1 100644
--- a/navit/support/win32/addwinsock.h
+++ b/navit/support/win32/addwinsock.h
@@ -1,8 +1,8 @@
-#ifndef ADD_WINSOCK
-#define ADD_WINSOCK
-
-#include <winsock2.h>
-
-int inet_aton(const char *cp, struct in_addr *inp);
-
-#endif
+#ifndef ADD_WINSOCK
+#define ADD_WINSOCK
+
+#include <winsock2.h>
+
+int inet_aton(const char *cp, struct in_addr *inp);
+
+#endif
diff --git a/navit/support/win32/serial_io.c b/navit/support/win32/serial_io.c
index 2eba8ece1..56966bcf7 100644
--- a/navit/support/win32/serial_io.c
+++ b/navit/support/win32/serial_io.c
@@ -51,7 +51,7 @@ int serial_io_init( const char* port, const char* strsettings )
0,
NULL
);
- dbg(lvl_warning, "return (fd) : '-1' : serial_io_init error : '%s'\n", lpMsgBuf);
+ dbg(lvl_warning, "return (fd) : '-1' : serial_io_init error : '%s'", lpMsgBuf);
LocalFree( lpMsgBuf ); // Free the buffer.
return -1;
@@ -72,7 +72,7 @@ int serial_io_init( const char* port, const char* strsettings )
SetCommTimeouts(hCom, &sCT);
- dbg(lvl_debug, "serial_io_init return (fd) : '%d'\n", (int)hCom);
+ dbg(lvl_debug, "serial_io_init return (fd) : '%d'", (int)hCom);
return (int)hCom;
}
@@ -94,12 +94,12 @@ int serial_io_init( const char* port, const char* strsettings )
int serial_io_read( int fd, char * buffer, int buffer_size )
{
DWORD dwBytesIn = 0;
- dbg(lvl_debug, "serial_io_read fd = %d buffer_size = %d\n", fd, buffer_size);
+ dbg(lvl_debug, "serial_io_read fd = %d buffer_size = %d", fd, buffer_size);
if (fd <= 0)
{
- dbg(lvl_debug, "serial_io_read return (dwBytesIn) : '0'\n");
+ dbg(lvl_debug, "serial_io_read return (dwBytesIn) : '0'");
*buffer = 0;
return 0;
}
@@ -117,11 +117,11 @@ int serial_io_read( int fd, char * buffer, int buffer_size )
}
if (dwBytesIn > 0)
{
- dbg(lvl_debug,"GPS < %s\n",buffer );
+ dbg(lvl_debug,"GPS < %s",buffer );
}
buffer[buffer_size - 1] = 0;
- dbg(lvl_info, "serial_io_read return (dwBytesIn) : '%d'\n", dwBytesIn);
+ dbg(lvl_info, "serial_io_read return (dwBytesIn) : '%d'", dwBytesIn);
return dwBytesIn;
}
@@ -139,7 +139,7 @@ int serial_io_read( int fd, char * buffer, int buffer_size )
int serial_io_write(int fd, const char * buffer)
{
DWORD dwBytesOut = 0;
- dbg(lvl_debug, "serial_io_write fd = %d buffer = '%s'\n",fd, buffer);
+ dbg(lvl_debug, "serial_io_write fd = %d buffer = '%s'",fd, buffer);
WriteFile((HANDLE)fd, buffer, strlen(buffer), &dwBytesOut, NULL);
@@ -157,7 +157,7 @@ int serial_io_write(int fd, const char * buffer)
**/
void serial_io_shutdown(int fd )
{
- dbg(lvl_debug, "serial_io_shutdown fd = %d\n",fd);
+ dbg(lvl_debug, "serial_io_shutdown fd = %d",fd);
if (fd > 0)
{
diff --git a/navit/support/wordexp/glob.c b/navit/support/wordexp/glob.c
index 8337367dd..fabceb6f2 100644
--- a/navit/support/wordexp/glob.c
+++ b/navit/support/wordexp/glob.c
@@ -130,7 +130,7 @@ glob_recursive(const char *path1, const char *path2, const char *pattern, int fl
strcat(path, "/");
strcat(path, path2);
if (!strlen(pattern)) {
- dbg(lvl_debug,"found %s\n",path);
+ dbg(lvl_debug,"found %s",path);
pglob->gl_pathv=realloc(pglob->gl_pathv, (pglob->gl_pathc+1)*sizeof(char *));
if (!pglob->gl_pathv) {
pglob->gl_pathc=0;
@@ -139,7 +139,7 @@ glob_recursive(const char *path1, const char *path2, const char *pattern, int fl
pglob->gl_pathv[pglob->gl_pathc++]=path;
return 0;
}
- dbg(lvl_debug,"searching for %s in %s\n",pattern,path);
+ dbg(lvl_debug,"searching for %s in %s",pattern,path);
flen=strcspn(pattern,"/");
next=pattern+flen;
if (*next == '/')
@@ -150,7 +150,7 @@ glob_recursive(const char *path1, const char *path2, const char *pattern, int fl
if (glob_requires_match(fname, 0)) {
DIR *dh;
struct dirent *de;
- dbg(lvl_debug,"in dir %s search for %s\n",path,fname);
+ dbg(lvl_debug,"in dir %s search for %s",path,fname);
dh=opendir(path);
if (dh) {
while ((de=readdir(dh))) {
diff --git a/navit/support/xgetopt/XGetopt.c b/navit/support/xgetopt/XGetopt.c
index d6174d826..60bc0f474 100644
--- a/navit/support/xgetopt/XGetopt.c
+++ b/navit/support/xgetopt/XGetopt.c
@@ -1,216 +1,216 @@
-// XGetopt.cpp Version 1.2
-//
-// Author: Hans Dietrich
-// hdietrich2@hotmail.com
-//
-// Description:
-// XGetopt.cpp implements getopt(), a function to parse command lines.
-//
-// History
-// Version 1.2 - 2003 May 17
-// - Added Unicode support
-//
-// Version 1.1 - 2002 March 10
-// - Added example to XGetopt.cpp module header
-//
-// This software is released into the public domain.
-// You are free to use it in any way you like.
-//
-// This software is provided "as is" with no expressed
-// or implied warranty. I accept no liability for any
-// damage or loss of business that this software may cause.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-// if you are not using precompiled headers then include these lines:
-#include <windows.h>
-#include <stdio.h>
-///////////////////////////////////////////////////////////////////////////////
-
-
-#include "XGetopt.h"
-
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// X G e t o p t . c p p
-//
-//
-// NAME
-// getopt -- parse command line options
-//
-// SYNOPSIS
-// int getopt(int argc, char *argv[], char *optstring)
-//
-// extern char *optarg;
-// extern int optind;
-//
-// DESCRIPTION
-// The getopt() function parses the command line arguments. Its
-// arguments argc and argv are the argument count and array as
-// passed into the application on program invocation. In the case
-// of Visual C++ programs, argc and argv are available via the
-// variables __argc and __argv (double underscores), respectively.
-// getopt returns the next option letter in argv that matches a
-// letter in optstring. (Note: Unicode programs should use
-// __targv instead of __argv. Also, all character and string
-// literals should be enclosed in _T( ) ).
-//
-// optstring is a string of recognized option letters; if a letter
-// is followed by a colon, the option is expected to have an argument
-// that may or may not be separated from it by white space. optarg
-// is set to point to the start of the option argument on return from
-// getopt.
-//
-// Option letters may be combined, e.g., "-ab" is equivalent to
-// "-a -b". Option letters are case sensitive.
-//
-// getopt places in the external variable optind the argv index
-// of the next argument to be processed. optind is initialized
-// to 0 before the first call to getopt.
-//
-// When all options have been processed (i.e., up to the first
-// non-option argument), getopt returns EOF, optarg will point
-// to the argument, and optind will be set to the argv index of
-// the argument. If there are no non-option arguments, optarg
-// will be set to NULL.
-//
-// The special option "--" may be used to delimit the end of the
-// options; EOF will be returned, and "--" (and everything after it)
-// will be skipped.
-//
-// RETURN VALUE
-// For option letters contained in the string optstring, getopt
-// will return the option letter. getopt returns a question mark (?)
-// when it encounters an option letter not included in optstring.
-// EOF is returned when processing is finished.
-//
-// BUGS
-// 1) Long options are not supported.
-// 2) The GNU double-colon extension is not supported.
-// 3) The environment variable POSIXLY_CORRECT is not supported.
-// 4) The + syntax is not supported.
-// 5) The automatic permutation of arguments is not supported.
-// 6) This implementation of getopt() returns EOF if an error is
-// encountered, instead of -1 as the latest standard requires.
-//
-// EXAMPLE
-// BOOL CMyApp::ProcessCommandLine(int argc, char *argv[])
-// {
-// int c;
-//
-// while ((c = getopt(argc, argv, "aBn:")) != EOF)
-// {
-// switch (c)
-// {
-// case 'a':
-// TRACE("option a\n");
-// //
-// // set some flag here
-// //
-// break;
-//
-// case 'B':
-// TRACE( "option B\n");
-// //
-// // set some other flag here
-// //
-// break;
-//
-// case 'n':
-// TRACE("option n: value=%d\n", atoi(optarg));
-// //
-// // do something with value here
-// //
-// break;
-//
-// case '?':
-// TRACE("ERROR: illegal option %s\n", argv[optind-1]);
-// return FALSE;
-// break;
-//
-// default:
-// TRACE("WARNING: no handler for option %c\n", c);
-// return FALSE;
-// break;
-// }
-// }
-// //
-// // check for non-option args here
-// //
-// return TRUE;
-// }
-//
-///////////////////////////////////////////////////////////////////////////////
-
-char *optarg; // global argument pointer
-int optind = 0; // global argv index
-
-int getopt(int argc, char *argv[], char *optstring)
-{
- static char *next = NULL;
- char c;
- char *cp;
-
- if (optind == 0)
- next = NULL;
-
- optarg = NULL;
-
- if (next == NULL || *next == '\0')
- {
- if (optind == 0)
- optind++;
-
- if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
- {
- optarg = NULL;
- if (optind < argc)
- optarg = argv[optind];
- return EOF;
- }
-
- if (strcmp(argv[optind], "--") == 0)
- {
- optind++;
- optarg = NULL;
- if (optind < argc)
- optarg = argv[optind];
- return EOF;
- }
-
- next = argv[optind];
- next++; // skip past -
- optind++;
- }
-
- c = *next++;
- cp = strchr(optstring, c);
-
- if (cp == NULL || c == ':')
- return '?';
-
- cp++;
- if (*cp == ':')
- {
- if (*next != '\0')
- {
- optarg = next;
- next = NULL;
- }
- else if (optind < argc)
- {
- optarg = argv[optind];
- optind++;
- }
- else
- {
- return '?';
- }
- }
-
- return c;
-}
+// XGetopt.cpp Version 1.2
+//
+// Author: Hans Dietrich
+// hdietrich2@hotmail.com
+//
+// Description:
+// XGetopt.cpp implements getopt(), a function to parse command lines.
+//
+// History
+// Version 1.2 - 2003 May 17
+// - Added Unicode support
+//
+// Version 1.1 - 2002 March 10
+// - Added example to XGetopt.cpp module header
+//
+// This software is released into the public domain.
+// You are free to use it in any way you like.
+//
+// This software is provided "as is" with no expressed
+// or implied warranty. I accept no liability for any
+// damage or loss of business that this software may cause.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+// if you are not using precompiled headers then include these lines:
+#include <windows.h>
+#include <stdio.h>
+///////////////////////////////////////////////////////////////////////////////
+
+
+#include "XGetopt.h"
+
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// X G e t o p t . c p p
+//
+//
+// NAME
+// getopt -- parse command line options
+//
+// SYNOPSIS
+// int getopt(int argc, char *argv[], char *optstring)
+//
+// extern char *optarg;
+// extern int optind;
+//
+// DESCRIPTION
+// The getopt() function parses the command line arguments. Its
+// arguments argc and argv are the argument count and array as
+// passed into the application on program invocation. In the case
+// of Visual C++ programs, argc and argv are available via the
+// variables __argc and __argv (double underscores), respectively.
+// getopt returns the next option letter in argv that matches a
+// letter in optstring. (Note: Unicode programs should use
+// __targv instead of __argv. Also, all character and string
+// literals should be enclosed in _T( ) ).
+//
+// optstring is a string of recognized option letters; if a letter
+// is followed by a colon, the option is expected to have an argument
+// that may or may not be separated from it by white space. optarg
+// is set to point to the start of the option argument on return from
+// getopt.
+//
+// Option letters may be combined, e.g., "-ab" is equivalent to
+// "-a -b". Option letters are case sensitive.
+//
+// getopt places in the external variable optind the argv index
+// of the next argument to be processed. optind is initialized
+// to 0 before the first call to getopt.
+//
+// When all options have been processed (i.e., up to the first
+// non-option argument), getopt returns EOF, optarg will point
+// to the argument, and optind will be set to the argv index of
+// the argument. If there are no non-option arguments, optarg
+// will be set to NULL.
+//
+// The special option "--" may be used to delimit the end of the
+// options; EOF will be returned, and "--" (and everything after it)
+// will be skipped.
+//
+// RETURN VALUE
+// For option letters contained in the string optstring, getopt
+// will return the option letter. getopt returns a question mark (?)
+// when it encounters an option letter not included in optstring.
+// EOF is returned when processing is finished.
+//
+// BUGS
+// 1) Long options are not supported.
+// 2) The GNU double-colon extension is not supported.
+// 3) The environment variable POSIXLY_CORRECT is not supported.
+// 4) The + syntax is not supported.
+// 5) The automatic permutation of arguments is not supported.
+// 6) This implementation of getopt() returns EOF if an error is
+// encountered, instead of -1 as the latest standard requires.
+//
+// EXAMPLE
+// BOOL CMyApp::ProcessCommandLine(int argc, char *argv[])
+// {
+// int c;
+//
+// while ((c = getopt(argc, argv, "aBn:")) != EOF)
+// {
+// switch (c)
+// {
+// case 'a':
+// TRACE("option a\n");
+// //
+// // set some flag here
+// //
+// break;
+//
+// case 'B':
+// TRACE( "option B\n");
+// //
+// // set some other flag here
+// //
+// break;
+//
+// case 'n':
+// TRACE("option n: value=%d\n", atoi(optarg));
+// //
+// // do something with value here
+// //
+// break;
+//
+// case '?':
+// TRACE("ERROR: illegal option %s\n", argv[optind-1]);
+// return FALSE;
+// break;
+//
+// default:
+// TRACE("WARNING: no handler for option %c\n", c);
+// return FALSE;
+// break;
+// }
+// }
+// //
+// // check for non-option args here
+// //
+// return TRUE;
+// }
+//
+///////////////////////////////////////////////////////////////////////////////
+
+char *optarg; // global argument pointer
+int optind = 0; // global argv index
+
+int getopt(int argc, char *argv[], char *optstring)
+{
+ static char *next = NULL;
+ char c;
+ char *cp;
+
+ if (optind == 0)
+ next = NULL;
+
+ optarg = NULL;
+
+ if (next == NULL || *next == '\0')
+ {
+ if (optind == 0)
+ optind++;
+
+ if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
+ {
+ optarg = NULL;
+ if (optind < argc)
+ optarg = argv[optind];
+ return EOF;
+ }
+
+ if (strcmp(argv[optind], "--") == 0)
+ {
+ optind++;
+ optarg = NULL;
+ if (optind < argc)
+ optarg = argv[optind];
+ return EOF;
+ }
+
+ next = argv[optind];
+ next++; // skip past -
+ optind++;
+ }
+
+ c = *next++;
+ cp = strchr(optstring, c);
+
+ if (cp == NULL || c == ':')
+ return '?';
+
+ cp++;
+ if (*cp == ':')
+ {
+ if (*next != '\0')
+ {
+ optarg = next;
+ next = NULL;
+ }
+ else if (optind < argc)
+ {
+ optarg = argv[optind];
+ optind++;
+ }
+ else
+ {
+ return '?';
+ }
+ }
+
+ return c;
+}
diff --git a/navit/support/xgetopt/XGetopt.h b/navit/support/xgetopt/XGetopt.h
index b975026c1..4bf8c8779 100644
--- a/navit/support/xgetopt/XGetopt.h
+++ b/navit/support/xgetopt/XGetopt.h
@@ -1,29 +1,29 @@
-// XGetopt.h Version 1.2
-//
-// Author: Hans Dietrich
-// hdietrich2@hotmail.com
-//
-// This software is released into the public domain.
-// You are free to use it in any way you like.
-//
-// This software is provided "as is" with no expressed
-// or implied warranty. I accept no liability for any
-// damage or loss of business that this software may cause.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef XGETOPT_H
-#define XGETOPT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int optind, opterr;
-extern char *optarg;
-
-int getopt(int argc, char *argv[], char *optstring);
-#ifdef __cplusplus
-}
-#endif
-#endif //XGETOPT_H
+// XGetopt.h Version 1.2
+//
+// Author: Hans Dietrich
+// hdietrich2@hotmail.com
+//
+// This software is released into the public domain.
+// You are free to use it in any way you like.
+//
+// This software is provided "as is" with no expressed
+// or implied warranty. I accept no liability for any
+// damage or loss of business that this software may cause.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef XGETOPT_H
+#define XGETOPT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int optind, opterr;
+extern char *optarg;
+
+int getopt(int argc, char *argv[], char *optstring);
+#ifdef __cplusplus
+}
+#endif
+#endif //XGETOPT_H
diff --git a/navit/tools/asc2navit b/navit/tools/asc2navit
index 77ba4ad15..096f56ded 100755
--- a/navit/tools/asc2navit
+++ b/navit/tools/asc2navit
@@ -38,7 +38,7 @@ my $pipe = open_outputhandle();
# ...feed the pipe...
run();
-# ...and close it properly
+# ...and close it properly
close $pipe;
###############################################################################
@@ -110,7 +110,7 @@ sub determine_filename {
$filename = "$onefile.bin";
$filename = "$onefile.xml" if ($write_osm);
}
-
+
print "$0 writing output to $filename\n";
}
@@ -119,14 +119,14 @@ sub run {
print $pipe '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
print $pipe '<osm version="0.5">' . "\n";
- # set the amenity and
+ # set the amenity and
my @amenities = keys %files;
while (my $amenity = shift @amenities) {
foreach my $file (@{$files{$amenity}}) {
process_file($file);
}
}
-
+
# close the osm file
print $pipe '</osm>';
# and show up some stats
diff --git a/navit/tools/cleanattr.sh b/navit/tools/cleanattr.sh
index 22e561f66..200db5b66 100755
--- a/navit/tools/cleanattr.sh
+++ b/navit/tools/cleanattr.sh
@@ -1,7 +1,7 @@
#!/bin/sh
-# This script scans the navit sources for attributes that
-# remained in attr_def.h but are no longer used.
+# This script scans the navit sources for attributes that
+# remained in attr_def.h but are no longer used.
ATTRFILE=attr_def.h
TMPDIR=/tmp
@@ -28,7 +28,7 @@ if [ $? -ne 0 ] ; then
fi
-ATTRLIST=`grep 'ATTR(.*)' $ATTRFILE | sed 's#^ATTR(##' | sed 's#).*##'`
+ATTRLIST=$(grep 'ATTR(.*)' $ATTRFILE | sed 's#^ATTR(##' | sed 's#).*##')
cp $ATTRFILE $TMPFILE
@@ -37,7 +37,7 @@ for ATTRNAME in $ATTRLIST ; do
grep -rI $ATTR ./* > /dev/null
- if [ $? -ne 0 ] ; then
+ if [ $? -ne 0 ] ; then
echo "Unused attribute: $ATTR"
grep -v "ATTR($ATTRNAME)" $TMPFILE > $TMPFILE2
mv $TMPFILE2 $TMPFILE
diff --git a/navit/tools/gpx2navit_txt/COPYING b/navit/tools/gpx2navit_txt/COPYING
index 514d6c73f..fc2670632 100644
--- a/navit/tools/gpx2navit_txt/COPYING
+++ b/navit/tools/gpx2navit_txt/COPYING
@@ -55,7 +55,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
-
+
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
-
+
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
-
+
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
-
+
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
@@ -278,7 +278,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
-
+
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
diff --git a/navit/tools/gpx2navit_txt/INSTALL b/navit/tools/gpx2navit_txt/INSTALL
index b5dbb9e31..7eae212e3 100644
--- a/navit/tools/gpx2navit_txt/INSTALL
+++ b/navit/tools/gpx2navit_txt/INSTALL
@@ -11,7 +11,7 @@ It's not special. Just type below like others.
./configure
make
- su
+ su
make install
gpx2navit_txt image will be at /usr/local/bin.
diff --git a/navit/tools/gpx2navit_txt/NEWS b/navit/tools/gpx2navit_txt/NEWS
index 7bd167323..d6f88c478 100644
--- a/navit/tools/gpx2navit_txt/NEWS
+++ b/navit/tools/gpx2navit_txt/NEWS
@@ -5,7 +5,7 @@
- Compile warning fixes
by Toshihiro Hiraoka
- Bug fix
-
+
0.68-1
======
by Petter Reinholdtsen
@@ -14,7 +14,7 @@
- RPM package for Vine 3.1
0.68
-====
+====
by Toshihiro Hiraoka
- Change XML parser from libxml2 to expat for big file support
- Remake almost all strucutes.
@@ -27,7 +27,7 @@
- README
- AUTHORS
- Change comment style to javadoc style.
- - Structures flow
+ - Structures flow
- Error code
0.65-1
diff --git a/navit/tools/gpx2navit_txt/README b/navit/tools/gpx2navit_txt/README
index ecb3f995f..d353cb50e 100644
--- a/navit/tools/gpx2navit_txt/README
+++ b/navit/tools/gpx2navit_txt/README
@@ -1,14 +1,14 @@
==============
gpx2navit_txt README
==============
-bodenseepingu
+bodenseepingu
4/01/2008
What's This
===========
gpx2navit_txt is a converter from GPX file to Navit Text map format
-For gpx2navit_txt was the original code from gpx2shp used and modified.
+For gpx2navit_txt was the original code from gpx2shp used and modified.
This is a output of Metro Manila Transit Map Project by JOCV (Japan
Overseas Cooperation Volunteers) program of JICA (Japan International
Cooperation Agency in 2004. It is provided you on GPL2.
@@ -28,7 +28,7 @@ Please try to convert a sample file "pinatest2.gpx" in this archive.
prompt> gpx2navit_txt pinatest2.gpx
prompt> ls
- pinatest2.gpx (source gpx)
+ pinatest2.gpx (source gpx)
pinatest2_meta.txt (meta data may be there)
You can convert only a certain type of data like only waypoint or
@@ -42,7 +42,7 @@ track point using option '-w' (waypoint), '-t' (trackpoint) or '-r'
you can convert it other ways using option '-p'(convert as point) and
'-e' (as edge). The edge file has '_edg' in the filename and the point
file has '_pnt' in the filename.
-
+
prompt> gpx2navit_txt -p -e pinatest2.gpx
- Statistics
@@ -87,14 +87,14 @@ try a example below.
- Length and time units
You can choose any length related units that are supported by proj4
-for attribute table using
- '--length-unit' (for length column, default: m),
- '--time-unit' (for time column, default: sec),
+for attribute table using
+ '--length-unit' (for length column, default: m),
+ '--time-unit' (for time column, default: sec),
'--speed-length-unit' (for speed column, default: km),
'--speed-time-unit' (for speed column, default: hour) and
'--length-ellipsoid' (for length calculation, default: UGS84).
- You can see the supported units by 'geod -lu' and 'geod -le' command.
- Supported time unit are 'sec', 'min', 'hour' and 'day'.
+ You can see the supported units by 'geod -lu' and 'geod -le' command.
+ Supported time unit are 'sec', 'min', 'hour' and 'day'.
- Other futures
There are other futures in gpx2navit_txt. Please check the option list using
diff --git a/navit/tools/gpx2navit_txt/autogen.sh b/navit/tools/gpx2navit_txt/autogen.sh
index ba84850ab..3951daa17 100755
--- a/navit/tools/gpx2navit_txt/autogen.sh
+++ b/navit/tools/gpx2navit_txt/autogen.sh
@@ -1,7 +1,7 @@
#!/bin/sh
for pkg in pkg-config libtool automake aclocal autoreconf:autoconf autopoint:gettext
do
- if ! ${pkg%%:*} --version >/dev/null
+ if ! ${pkg%%:*} --version >/dev/null
then
echo "You need to install ${pkg##*:}"
exit 1
diff --git a/navit/tools/gpx2navit_txt/install-sh b/navit/tools/gpx2navit_txt/install-sh
index 11870f1b0..a06f46705 100755
--- a/navit/tools/gpx2navit_txt/install-sh
+++ b/navit/tools/gpx2navit_txt/install-sh
@@ -115,7 +115,7 @@ fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
-
+
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
@@ -125,7 +125,7 @@ if [ x"$dir_arg" != x ]; then
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
+# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f "$src" ] || [ -d "$src" ]
@@ -135,7 +135,7 @@ else
echo "install: $src does not exist"
exit 1
fi
-
+
if [ x"$dst" = x ]
then
echo "install: no destination specified"
@@ -202,17 +202,17 @@ else
# If we're going to rename the final executable, determine the name now.
- if [ x"$transformarg" = x ]
+ if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
- dstfile=`basename $dst $transformbasename |
+ dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
- if [ x"$dstfile" = x ]
+ if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
@@ -243,7 +243,7 @@ else
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
diff --git a/navit/tools/gpx2navit_txt/man/gpx2navit_txt.1 b/navit/tools/gpx2navit_txt/man/gpx2navit_txt.1
index c04165efb..a0a07495a 100644
--- a/navit/tools/gpx2navit_txt/man/gpx2navit_txt.1
+++ b/navit/tools/gpx2navit_txt/man/gpx2navit_txt.1
@@ -1,103 +1,103 @@
-.\"
+.\"
.TH "gpx2navit_txt" "1" "0.1" "bodenseepingu" ""
.SH "NAME"
gpx2navit_txt \- Convert GPX files to navit txt files
.SH "SYNOPSIS"
gpx2navit_txt [options] [\-o output file] gpxfile
.SH "DESCRIPTION"
-gpx2navit_txt is a converter from GPX file to navit txt file
+gpx2navit_txt is a converter from GPX file to navit txt file
The original gpx2shp was used for that program.
This is a output of Metro Manila Transit Map Project by JOCV (Japan Overseas Cooperation Volunteers) program of JICA (Japan International Cooperation Agency) in 2004. It is provided you on GPL2.
.SH "OPTIONS"
-.TP
+.TP
.B \-o, \-\-output
Sets output basename. The default is (source file name) \- (extention name)
-.TP
+.TP
.B \-w, \-\-waypoints
Converts only waypoints data from a gpx file.
-.TP
+.TP
.B \-t, \-\-trackpoints
Converts only trackpoints data from a gpx file.
-.TP
+.TP
.B \-r, \-\-routes
Converts only routes data from a gpx file.
-.TP
+.TP
.B \-a, \-\-all
Converts all types of data from a gpx file.(default)
-.TP
+.TP
.B \-e, \-\-as\-edge
Makes a separated output by each edges.
-.TP
+.TP
.B \-p, \-\-as\-point
Makes a separated output by each points.
-.TP
+.TP
.B \-s, \-\-stats
Shows simple statistics of the outputs.
-.TP
+.TP
.B \-b, \-\-basic\-columns
Stores only basic data as attribures to reduce memory and storage usage. (ele, name, cmt, type, time, fix, sym and number).
-.TP
+.TP
.B \-L, \-\-no\-length
Removes length column from a waypoint or trackpoint attribute table.
-.TP
+.TP
.B \-S, \-\-no\-speed
Removes speed column from a waypoint or trackpoint attribute table.
-.TP
+.TP
.B \-T, \-\-no\-time
Removes time column from an attribute table.
-.TP
+.TP
.B \-g, \-\-gpxline
Adds line number of GPX file as attribures.
-.TP
+.TP
.B \-f, \-\-fast
Make it faster without any checks.
-.TP
+.TP
.B \-3, \-\-3d
Converts data using 3d format. (It's not compatible for Arcview 3.x.)
-.TP
+.TP
.B \-\-min\-points
Sets path minimum points to convert for noise reduction. Default is 2.
-.TP
+.TP
.B \-\-min\-length
Sets path minimum length to convert for noise reduction. Default is 0.
-.TP
+.TP
.B \-\-min\-time
Sets path minimum time period to convert for noise reduction. Default is 0.
-.TP
+.TP
.B \-\-length\-unit
Sets length unit from m,km,feet,mi and etc. The default is m. You can see the unit list from "geod \-lu" command.
-.TP
+.TP
.B \-\-time\-unit
Sets time unit. The default is sec. You can set from day, hour, min and sec.
-.TP
-.B \-\-speed\-length\-unit
+.TP
+.B \-\-speed\-length\-unit
Sets length unit for speed. The default is km. You can see the unit list from "geod \-lu" command.
-.TP
+.TP
.B \-\-speed\-time\-unit
Sets time unit for speed calulation. Default is hour. You can set from day, hour, min and sec.
-.TP
+.TP
.B \-\-length\-ellipsoid
Sets length ellipsoid like UGS84, clrk66. The default is UGS84. You can see the unit list from "geod \-le" command.
-.TP
+.TP
.B \-\-no\-speed-check
Disables checking the track speed to be non-zero.
-.TP
+.TP
.B \-v, \-\-verbose
Gives many messages.
-.TP
+.TP
.B \-\-version
Shows version.
-.TP
+.TP
.B \-h, \-\-help
Shows this list.
.SH "AUTHORS"
Toshihiro Hiraoka
-.br
+.br
Petter Reinholdtsen
.SH "BUGS or OPINIONS"
Please e\-mail your bugs or opinions to
-.br
+.br
washitoshi at yahoo.co.jp
.SH "SEE ALSO"
diff --git a/navit/tools/gpx2navit_txt/src/elementControl.c b/navit/tools/gpx2navit_txt/src/elementControl.c
index 924e10803..5bd67b2d5 100644
--- a/navit/tools/gpx2navit_txt/src/elementControl.c
+++ b/navit/tools/gpx2navit_txt/src/elementControl.c
@@ -20,73 +20,71 @@
#include "gpx2navit_txt.h"
void startElementControl(parsedata * pdata, const char *element,
- const char **attr);
+ const char **attr);
void endElementControl(parsedata * pdata, const char *element);
/*
* This method controls tag start event.
* It corrects attributes.
*/
-void
-startElementControl(parsedata * pdata, const char *element,
- const char **attr)
-{
+void startElementControl(parsedata * pdata, const char *element,
+ const char **attr) {
int i;
static int isFirstTrk = 1;
static int isFirstRte = 1;
static int isFirstPathpt = 1;
for (i = 0; attr[i]; i += 2) {
- if (!strcmp(attr[i], "lon")) {
- pdata->attr->lon = atof(attr[i + 1]);
- }
- if (!strcmp(attr[i], "lat")) {
- pdata->attr->lat = atof(attr[i + 1]);
- }
- if (!strcmp(attr[i], "minlon")) {
- pdata->attr->minlon = atof(attr[i + 1]);
- }
- if (!strcmp(attr[i], "minlat")) {
- pdata->attr->minlat = atof(attr[i + 1]);
- }
- if (!strcmp(attr[i], "maxlon")) {
- pdata->attr->maxlon = atof(attr[i + 1]);
- }
- if (!strcmp(attr[i], "maxlat")) {
- pdata->attr->maxlat = atof(attr[i + 1]);
- }
- if (!strcmp(attr[i], "author")) {
- strcpy(pdata->attr->author, attr[i + 1]);
- }
+ if (!strcmp(attr[i], "lon")) {
+ pdata->attr->lon = atof(attr[i + 1]);
+ }
+ if (!strcmp(attr[i], "lat")) {
+ pdata->attr->lat = atof(attr[i + 1]);
+ }
+ if (!strcmp(attr[i], "minlon")) {
+ pdata->attr->minlon = atof(attr[i + 1]);
+ }
+ if (!strcmp(attr[i], "minlat")) {
+ pdata->attr->minlat = atof(attr[i + 1]);
+ }
+ if (!strcmp(attr[i], "maxlon")) {
+ pdata->attr->maxlon = atof(attr[i + 1]);
+ }
+ if (!strcmp(attr[i], "maxlat")) {
+ pdata->attr->maxlat = atof(attr[i + 1]);
+ }
+ if (!strcmp(attr[i], "author")) {
+ strcpy(pdata->attr->author, attr[i + 1]);
+ }
}
if (pdata->prop->parseTrk) {
- if (!strcmp(element, "trk")) {
- if (isFirstTrk) {
- isFirstTrk = 0;
- }
- }
- if (!strcmp(element, "trkseg")) {
- isFirstPathpt = 1;
- }
- if (!strcmp(element, "trkpt")) {
- if (isFirstPathpt) {
- initPathAttr(pdata->pattr, pdata->attr);
- isFirstPathpt = 0;
- }
- }
+ if (!strcmp(element, "trk")) {
+ if (isFirstTrk) {
+ isFirstTrk = 0;
+ }
+ }
+ if (!strcmp(element, "trkseg")) {
+ isFirstPathpt = 1;
+ }
+ if (!strcmp(element, "trkpt")) {
+ if (isFirstPathpt) {
+ initPathAttr(pdata->pattr, pdata->attr);
+ isFirstPathpt = 0;
+ }
+ }
}
if (pdata->prop->parseRte) {
- if (!strcmp(element, "rte")) {
- if (isFirstRte) {
- isFirstRte = 0;
- isFirstPathpt = 1;
- }
- }
- if (!strcmp(element, "rtept")) {
- if (isFirstPathpt) {
- initPathAttr(pdata->pattr, pdata->attr);
- isFirstPathpt = 0;
- }
- }
+ if (!strcmp(element, "rte")) {
+ if (isFirstRte) {
+ isFirstRte = 0;
+ isFirstPathpt = 1;
+ }
+ }
+ if (!strcmp(element, "rtept")) {
+ if (isFirstPathpt) {
+ initPathAttr(pdata->pattr, pdata->attr);
+ isFirstPathpt = 0;
+ }
+ }
}
}
@@ -95,151 +93,150 @@ startElementControl(parsedata * pdata, const char *element,
* It corrects char elements when the element tag has some data,
* then start to convert when tag is top level tag like <wpt>.
*/
-void endElementControl(parsedata * pdata, const char *element)
-{
+void endElementControl(parsedata * pdata, const char *element) {
static int isFirstWpt = 1;
static int isFirstTrkAsPoint = 1;
static int isFirstRteAsPoint = 1;
/* common elements */
if (!strcmp(element, "name")) {
- strcpy(pdata->attr->name, pdata->databuf);
+ strcpy(pdata->attr->name, pdata->databuf);
}
if (!strcmp(element, "cmt")) {
- strcpy(pdata->attr->cmt, pdata->databuf);
+ strcpy(pdata->attr->cmt, pdata->databuf);
}
if (!strcmp(element, "desc")) {
- strcpy(pdata->attr->desc, pdata->databuf);
+ strcpy(pdata->attr->desc, pdata->databuf);
}
if (!strcmp(element, "src")) {
- strcpy(pdata->attr->src, pdata->databuf);
+ strcpy(pdata->attr->src, pdata->databuf);
}
if (!strcmp(element, "link")) {
- strcpy(pdata->attr->link, pdata->databuf);
+ strcpy(pdata->attr->link, pdata->databuf);
}
if (!strcmp(element, "type")) {
- strcpy(pdata->attr->type, pdata->databuf);
+ strcpy(pdata->attr->type, pdata->databuf);
}
/* waypoint and metadata elements */
if (!strcmp(element, "time")) {
- strcpy(pdata->attr->time, pdata->databuf);
+ strcpy(pdata->attr->time, pdata->databuf);
}
/* route and track point elements */
if (!strcmp(element, "number")) {
- pdata->attr->number = atoi(pdata->databuf);
+ pdata->attr->number = atoi(pdata->databuf);
}
/* waypoint elements */
if (!strcmp(element, "ele")) {
- pdata->attr->ele = atof(pdata->databuf);
+ pdata->attr->ele = atof(pdata->databuf);
}
if (!strcmp(element, "magvar")) {
- pdata->attr->magvar = atof(pdata->databuf);
+ pdata->attr->magvar = atof(pdata->databuf);
}
if (!strcmp(element, "geoidheight")) {
- pdata->attr->geoidheight = atof(pdata->databuf);
+ pdata->attr->geoidheight = atof(pdata->databuf);
}
if (!strcmp(element, "sym")) {
- strcpy(pdata->attr->sym, pdata->databuf);
+ strcpy(pdata->attr->sym, pdata->databuf);
}
if (!strcmp(element, "fix")) {
- strcpy(pdata->attr->fix, pdata->databuf);
+ strcpy(pdata->attr->fix, pdata->databuf);
}
if (!strcmp(element, "sat")) {
- pdata->attr->sat = atoi(pdata->databuf);
+ pdata->attr->sat = atoi(pdata->databuf);
}
if (!strcmp(element, "hdop")) {
- pdata->attr->hdop = atof(pdata->databuf);
+ pdata->attr->hdop = atof(pdata->databuf);
}
if (!strcmp(element, "vdop")) {
- pdata->attr->vdop = atof(pdata->databuf);
+ pdata->attr->vdop = atof(pdata->databuf);
}
if (!strcmp(element, "pdop")) {
- pdata->attr->pdop = atof(pdata->databuf);
+ pdata->attr->pdop = atof(pdata->databuf);
}
if (!strcmp(element, "ageofdgpsdata")) {
- pdata->attr->ageofdgpsdata = atof(pdata->databuf);
+ pdata->attr->ageofdgpsdata = atof(pdata->databuf);
}
/* metadata elements */
if (!strcmp(element, "author")) {
- strcpy(pdata->attr->author, pdata->databuf);
+ strcpy(pdata->attr->author, pdata->databuf);
}
if (!strcmp(element, "keywords")) {
- strcpy(pdata->attr->keywords, pdata->databuf);
+ strcpy(pdata->attr->keywords, pdata->databuf);
}
if (!strcmp(element, "copyright")) {
- strcpy(pdata->attr->copyright, pdata->databuf);
+ strcpy(pdata->attr->copyright, pdata->databuf);
}
if (!strcmp(element, "year")) {
- pdata->attr->year = atoi(pdata->databuf);
+ pdata->attr->year = atoi(pdata->databuf);
}
if (!strcmp(element, "license")) {
- strcpy(pdata->attr->license, pdata->databuf);
+ strcpy(pdata->attr->license, pdata->databuf);
}
if (!strcmp(element, "bounds")) {
- /* none */
+ /* none */
}
/* top elements */
/* set waypoint data */
if (!strcmp(element, "wpt")) {
- if (pdata->prop->parseWpt) {
- if (isFirstWpt) {
- isFirstWpt = 0;
- }
- //todo
- if (DEBUG) {
- fprintf(stderr,"\neectrl wpt %s %s",
- pdata->attr->desc,pdata->attr->name);
- }
- setWpt(pdata);
- wipeAttr(pdata->attr);
- }
+ if (pdata->prop->parseWpt) {
+ if (isFirstWpt) {
+ isFirstWpt = 0;
+ }
+ //todo
+ if (DEBUG) {
+ fprintf(stderr,"\neectrl wpt %s %s",
+ pdata->attr->desc,pdata->attr->name);
+ }
+ setWpt(pdata);
+ wipeAttr(pdata->attr);
+ }
}
/* set trackpoint data */
if (!strcmp(element, "trkpt")) {
- if (pdata->prop->parseTrk) {
- setPathData(pdata->pattr, pdata->attr);
- if (!pdata->prop->isFast)
- setPathInterval(pdata);
- }
- /* set trackpoint data as point */
- if (pdata->prop->isPoint) {
- if (isFirstTrkAsPoint) {
- isFirstTrkAsPoint = 0;
- }
- setWpt(pdata);
- }
- wipeAttr(pdata->attr);
+ if (pdata->prop->parseTrk) {
+ setPathData(pdata->pattr, pdata->attr);
+ if (!pdata->prop->isFast)
+ setPathInterval(pdata);
+ }
+ /* set trackpoint data as point */
+ if (pdata->prop->isPoint) {
+ if (isFirstTrkAsPoint) {
+ isFirstTrkAsPoint = 0;
+ }
+ setWpt(pdata);
+ }
+ wipeAttr(pdata->attr);
}
/* write trackpoint */
if (!strcmp(element, "trkseg")) {
- if (pdata->prop->parseTrk) {
- setPath( pdata);
- }
+ if (pdata->prop->parseTrk) {
+ setPath( pdata);
+ }
}
/* set route data */
if (!strcmp(element, "rtept")) {
- if (pdata->prop->parseRte) {
- setPathData(pdata->pattr, pdata->attr);
- if (!pdata->prop->isFast)
- setPathInterval(pdata);
- }
- /* set route data as point */
- if (pdata->prop->isPoint) {
- if (isFirstRteAsPoint) {
- isFirstRteAsPoint = 0;
- }
- setWpt( pdata);
- }
- wipeAttr(pdata->attr);
+ if (pdata->prop->parseRte) {
+ setPathData(pdata->pattr, pdata->attr);
+ if (!pdata->prop->isFast)
+ setPathInterval(pdata);
+ }
+ /* set route data as point */
+ if (pdata->prop->isPoint) {
+ if (isFirstRteAsPoint) {
+ isFirstRteAsPoint = 0;
+ }
+ setWpt( pdata);
+ }
+ wipeAttr(pdata->attr);
}
/* write route */
if (!strcmp(element, "rte")) {
- if (pdata->prop->parseRte) {
- setPath( pdata);
- }
+ if (pdata->prop->parseRte) {
+ setPath( pdata);
+ }
}
if (!strcmp(element, "metadata")) {
- setMetadata(pdata);
- wipeAttr(pdata->attr);
+ setMetadata(pdata);
+ wipeAttr(pdata->attr);
}
pdata->bufptr = NULL; //reset bufptr now
}
diff --git a/navit/tools/gpx2navit_txt/src/errorcode.h b/navit/tools/gpx2navit_txt/src/errorcode.h
index f12d6cffd..29636fc1d 100644
--- a/navit/tools/gpx2navit_txt/src/errorcode.h
+++ b/navit/tools/gpx2navit_txt/src/errorcode.h
@@ -34,7 +34,7 @@
#define ERR_ISNOTGPX 31
#define ERR_PARSEERROR 32
/* unit */
-#define ERR_ELLPSUNIT 41
+#define ERR_ELLPSUNIT 41
#define ERR_LENGTHUNIT 42
#define ERR_TIMEUNIT 43
diff --git a/navit/tools/gpx2navit_txt/src/geod_for.c b/navit/tools/gpx2navit_txt/src/geod_for.c
index ebff3bcb4..30fa829e3 100644
--- a/navit/tools/gpx2navit_txt/src/geod_for.c
+++ b/navit/tools/gpx2navit_txt/src/geod_for.c
@@ -26,102 +26,100 @@ static const char SCCSID[] =
# define MERI_TOL 1e-9
static double th1, costh1, sinth1, sina12, cosa12, M, N, c1, c2, D, P, s1;
static int merid, signS;
-void geod_pre(void)
-{
+void geod_pre(void) {
al12 = adjlon(al12); /* reduce to +- 0-PI */
signS = fabs(al12) > HALFPI ? 1 : 0;
th1 = ellipse ? atan(onef * tan(phi1)) : phi1;
costh1 = cos(th1);
sinth1 = sin(th1);
if ((merid = fabs(sina12 = sin(al12)) < MERI_TOL)) {
- sina12 = 0.;
- cosa12 = fabs(al12) < HALFPI ? 1. : -1.;
- M = 0.;
+ sina12 = 0.;
+ cosa12 = fabs(al12) < HALFPI ? 1. : -1.;
+ M = 0.;
} else {
- cosa12 = cos(al12);
- M = costh1 * sina12;
+ cosa12 = cos(al12);
+ M = costh1 * sina12;
}
N = costh1 * cosa12;
if (ellipse) {
- if (merid) {
- c1 = 0.;
- c2 = f4;
- D = 1. - c2;
- D *= D;
- P = c2 / D;
- } else {
- c1 = geod_f * M;
- c2 = f4 * (1. - M * M);
- D = (1. - c2) * (1. - c2 - c1 * M);
- P = (1. + .5 * c1 * M) * c2 / D;
- }
+ if (merid) {
+ c1 = 0.;
+ c2 = f4;
+ D = 1. - c2;
+ D *= D;
+ P = c2 / D;
+ } else {
+ c1 = geod_f * M;
+ c2 = f4 * (1. - M * M);
+ D = (1. - c2) * (1. - c2 - c1 * M);
+ P = (1. + .5 * c1 * M) * c2 / D;
+ }
}
if (merid)
- s1 = HALFPI - th1;
+ s1 = HALFPI - th1;
else {
- s1 = (fabs(M) >= 1.) ? 0. : acos(M);
- s1 = sinth1 / sin(s1);
- s1 = (fabs(s1) >= 1.) ? 0. : acos(s1);
+ s1 = (fabs(M) >= 1.) ? 0. : acos(M);
+ s1 = sinth1 / sin(s1);
+ s1 = (fabs(s1) >= 1.) ? 0. : acos(s1);
}
}
-void geod_for(void)
-{
+void geod_for(void) {
double d, sind, u, V, X, ds, cosds, sinds, ss = 0, de;
if (ellipse) {
- d = geod_S / (D * geod_a);
- if (signS)
- d = -d;
- u = 2. * (s1 - d);
- V = cos(u + d);
- X = c2 * c2 * (sind = sin(d)) * cos(d) * (2. * V * V - 1.);
- ds = d + X - 2. * P * V * (1. - 2. * P * cos(u)) * sind;
- ss = s1 + s1 - ds;
+ d = geod_S / (D * geod_a);
+ if (signS)
+ d = -d;
+ u = 2. * (s1 - d);
+ V = cos(u + d);
+ X = c2 * c2 * (sind = sin(d)) * cos(d) * (2. * V * V - 1.);
+ ds = d + X - 2. * P * V * (1. - 2. * P * cos(u)) * sind;
+ ss = s1 + s1 - ds;
} else {
- ds = geod_S / geod_a;
- if (signS)
- ds = -ds;
+ ds = geod_S / geod_a;
+ if (signS)
+ ds = -ds;
}
cosds = cos(ds);
sinds = sin(ds);
if (signS)
- sinds = -sinds;
+ sinds = -sinds;
al21 = N * cosds - sinth1 * sinds;
if (merid) {
- phi2 = atan(tan(HALFPI + s1 - ds) / onef);
- if (al21 > 0.) {
- al21 = PI;
- if (signS)
- de = PI;
- else {
- phi2 = -phi2;
- de = 0.;
- }
- } else {
- al21 = 0.;
- if (signS) {
- phi2 = -phi2;
- de = 0;
- } else
- de = PI;
- }
+ phi2 = atan(tan(HALFPI + s1 - ds) / onef);
+ if (al21 > 0.) {
+ al21 = PI;
+ if (signS)
+ de = PI;
+ else {
+ phi2 = -phi2;
+ de = 0.;
+ }
+ } else {
+ al21 = 0.;
+ if (signS) {
+ phi2 = -phi2;
+ de = 0;
+ } else
+ de = PI;
+ }
} else {
- al21 = atan(M / al21);
- if (al21 > 0)
- al21 += PI;
- if (al12 < 0.)
- al21 -= PI;
- al21 = adjlon(al21);
- phi2 = atan(-(sinth1 * cosds + N * sinds) * sin(al21) /
- (ellipse ? onef * M : M));
- de = atan2(sinds * sina12,
- (costh1 * cosds - sinth1 * sinds * cosa12));
- if (ellipse) {
- if (signS)
- de += c1 * ((1. - c2) * ds + c2 * sinds * cos(ss));
- else
- de -= c1 * ((1. - c2) * ds - c2 * sinds * cos(ss));
- }
+ al21 = atan(M / al21);
+ if (al21 > 0)
+ al21 += PI;
+ if (al12 < 0.)
+ al21 -= PI;
+ al21 = adjlon(al21);
+ phi2 = atan(-(sinth1 * cosds + N * sinds) * sin(al21) /
+ (ellipse ? onef * M : M));
+ de = atan2(sinds * sina12,
+ (costh1 * cosds - sinth1 * sinds * cosa12));
+ if (ellipse) {
+ if (signS)
+ de += c1 * ((1. - c2) * ds + c2 * sinds * cos(ss));
+ else
+ de -= c1 * ((1. - c2) * ds - c2 * sinds * cos(ss));
+ }
}
lam2 = adjlon(lam1 + de);
}
diff --git a/navit/tools/gpx2navit_txt/src/geod_inv.c b/navit/tools/gpx2navit_txt/src/geod_inv.c
index a54128256..826f4e3fd 100644
--- a/navit/tools/gpx2navit_txt/src/geod_inv.c
+++ b/navit/tools/gpx2navit_txt/src/geod_inv.c
@@ -24,33 +24,32 @@ static const char SCCSID[] =
# include "projects.h"
# include "geodesic.h"
# define DTOL 1e-12
-void geod_inv(void)
-{
+void geod_inv(void) {
double th1,
- th2,
- thm,
- dthm,
- dlamm,
- dlam,
- sindlamm,
- costhm,
- sinthm,
- cosdthm,
- sindthm, L, E, cosd, d, X, Y, T, sind, tandlammp, u, v, D, A, B;
+ th2,
+ thm,
+ dthm,
+ dlamm,
+ dlam,
+ sindlamm,
+ costhm,
+ sinthm,
+ cosdthm,
+ sindthm, L, E, cosd, d, X, Y, T, sind, tandlammp, u, v, D, A, B;
if (ellipse) {
- th1 = atan(onef * tan(phi1));
- th2 = atan(onef * tan(phi2));
+ th1 = atan(onef * tan(phi1));
+ th2 = atan(onef * tan(phi2));
} else {
- th1 = phi1;
- th2 = phi2;
+ th1 = phi1;
+ th2 = phi2;
}
thm = .5 * (th1 + th2);
dthm = .5 * (th2 - th1);
dlamm = .5 * (dlam = adjlon(lam2 - lam1));
if (fabs(dlam) < DTOL && fabs(dthm) < DTOL) {
- al12 = al21 = geod_S = 0.;
- return;
+ al12 = al21 = geod_S = 0.;
+ return;
}
sindlamm = sin(dlamm);
costhm = cos(thm);
@@ -58,32 +57,32 @@ void geod_inv(void)
cosdthm = cos(dthm);
sindthm = sin(dthm);
L = sindthm * sindthm + (cosdthm * cosdthm - sinthm * sinthm)
- * sindlamm * sindlamm;
+ * sindlamm * sindlamm;
d = acos(cosd = 1 - L - L);
if (ellipse) {
- E = cosd + cosd;
- sind = sin(d);
- Y = sinthm * cosdthm;
- Y *= (Y + Y) / (1. - L);
- T = sindthm * costhm;
- T *= (T + T) / L;
- X = Y + T;
- Y -= T;
- T = d / sind;
- D = 4. * T * T;
- A = D * E;
- B = D + D;
- geod_S = geod_a * sind * (T - f4 * (T * X - Y) +
- f64 * (X * (A + (T - .5 * (A - E)) * X) -
- Y * (B + E * Y) + D * X * Y));
- tandlammp = tan(.5 * (dlam - .25 * (Y + Y - E * (4. - X)) *
- (f2 * T + f64 * (32. * T - (20. * T - A)
- * X - (B +
- 4.) * Y)) *
- tan(dlam)));
+ E = cosd + cosd;
+ sind = sin(d);
+ Y = sinthm * cosdthm;
+ Y *= (Y + Y) / (1. - L);
+ T = sindthm * costhm;
+ T *= (T + T) / L;
+ X = Y + T;
+ Y -= T;
+ T = d / sind;
+ D = 4. * T * T;
+ A = D * E;
+ B = D + D;
+ geod_S = geod_a * sind * (T - f4 * (T * X - Y) +
+ f64 * (X * (A + (T - .5 * (A - E)) * X) -
+ Y * (B + E * Y) + D * X * Y));
+ tandlammp = tan(.5 * (dlam - .25 * (Y + Y - E * (4. - X)) *
+ (f2 * T + f64 * (32. * T - (20. * T - A)
+ * X - (B +
+ 4.) * Y)) *
+ tan(dlam)));
} else {
- geod_S = geod_a * d;
- tandlammp = tan(dlamm);
+ geod_S = geod_a * d;
+ tandlammp = tan(dlamm);
}
u = atan2(sindthm, (tandlammp * costhm));
v = atan2(cosdthm, (tandlammp * sinthm));
diff --git a/navit/tools/gpx2navit_txt/src/geod_set.c b/navit/tools/gpx2navit_txt/src/geod_set.c
index 4dc4b1d79..65c6fffaf 100644
--- a/navit/tools/gpx2navit_txt/src/geod_set.c
+++ b/navit/tools/gpx2navit_txt/src/geod_set.c
@@ -29,86 +29,87 @@
#include "projects.h"
#include "geodesic.h"
#include "emess.h"
-void geod_set(int argc, char **argv)
-{
+void geod_set(int argc, char **argv) {
paralist *start = 0, *curr = NULL; /* added NULL */
double es;
char *name;
int i;
-/*
- * put arguments into internal linked list
- */
+ /*
+ * put arguments into internal linked list
+ */
if (argc <= 0)
- emess(1, "no arguments in initialization list");
+ emess(1, "no arguments in initialization list");
for (i = 0; i < argc; ++i)
- if (i)
- curr = curr->next = pj_mkparam(argv[i]);
- else
- start = curr = pj_mkparam(argv[i]);
-/*
- * set elliptical parameters
- */
+ if (i)
+ curr = curr->next = pj_mkparam(argv[i]);
+ else
+ start = curr = pj_mkparam(argv[i]);
+ /*
+ * set elliptical parameters
+ */
if (pj_ell_set(start, &geod_a, &es))
- emess(1, "ellipse setup failure");
-/*
- * set units
- */
+ emess(1, "ellipse setup failure");
+ /*
+ * set units
+ */
if ((name = pj_param(start, "sunits").s)) { /* added parentheses */
- char *s;
+ char *s;
- for (i = 0; (s = pj_units[i].id) && strcmp(name, s); ++i);
- if (!s)
- emess(1, "%s unknown unit conversion id", name);
- fr_meter = 1. / (to_meter = atof(pj_units[i].to_meter));
+ for (i = 0; (s = pj_units[i].id) && strcmp(name, s); ++i);
+ if (!s)
+ emess(1, "%s unknown unit conversion id", name);
+ fr_meter = 1. / (to_meter = atof(pj_units[i].to_meter));
} else
- to_meter = fr_meter = 1.;
+ to_meter = fr_meter = 1.;
if ((ellipse = es != 0.)) { /* added parentheses */
- onef = sqrt(1. - es);
- geod_f = 1 - onef;
- f2 = geod_f / 2;
- f4 = geod_f / 4;
- f64 = geod_f * geod_f / 64;
+ onef = sqrt(1. - es);
+ geod_f = 1 - onef;
+ f2 = geod_f / 2;
+ f4 = geod_f / 4;
+ f64 = geod_f * geod_f / 64;
} else {
- onef = 1.;
- geod_f = f2 = f4 = f64 = 0.;
+ onef = 1.;
+ geod_f = f2 = f4 = f64 = 0.;
}
-/*
- * check if line or arc mode
- */
+ /*
+ * check if line or arc mode
+ */
if (pj_param(start, "tlat_1").i) {
- double del_S;
+ double del_S;
#undef f
- phi1 = pj_param(start, "rlat_1").f;
- lam1 = pj_param(start, "rlon_1").f;
- if (pj_param(start, "tlat_2").i) {
- phi2 = pj_param(start, "rlat_2").f;
- lam2 = pj_param(start, "rlon_2").f;
- geod_inv();
- geod_pre();
- } else if ((geod_S = pj_param(start, "dS").f)) { /* added
- * parentheses
- */
- al12 = pj_param(start, "rA").f;
- geod_pre();
- geod_for();
- } else
- emess(1, "incomplete geodesic/arc info");
- if ((n_alpha = pj_param(start, "in_A").i) > 0) {
- if (!(del_alpha = pj_param(start, "rdel_A").f))
- emess(1, "del azimuth == 0");
- } else if ((del_S = fabs(pj_param(start, "ddel_S").f))) { /* added
- * parentheses
- */
- n_S = geod_S / del_S + .5;
- } else if ((n_S = pj_param(start, "in_S").i) <= 0)
- emess(1, "no interval divisor selected");
+ phi1 = pj_param(start, "rlat_1").f;
+ lam1 = pj_param(start, "rlon_1").f;
+ if (pj_param(start, "tlat_2").i) {
+ phi2 = pj_param(start, "rlat_2").f;
+ lam2 = pj_param(start, "rlon_2").f;
+ geod_inv();
+ geod_pre();
+ } else if ((geod_S = pj_param(start, "dS").f)) {
+ /* added
+ * parentheses
+ */
+ al12 = pj_param(start, "rA").f;
+ geod_pre();
+ geod_for();
+ } else
+ emess(1, "incomplete geodesic/arc info");
+ if ((n_alpha = pj_param(start, "in_A").i) > 0) {
+ if (!(del_alpha = pj_param(start, "rdel_A").f))
+ emess(1, "del azimuth == 0");
+ } else if ((del_S = fabs(pj_param(start, "ddel_S").f))) {
+ /* added
+ * parentheses
+ */
+ n_S = geod_S / del_S + .5;
+ } else if ((n_S = pj_param(start, "in_S").i) <= 0)
+ emess(1, "no interval divisor selected");
}
-/*
- * free up linked list
- */
+ /*
+ * free up linked list
+ */
for (; start; start = curr) {
- curr = start->next;
- pj_dalloc(start);
+ curr = start->next;
+ pj_dalloc(start);
}
}
diff --git a/navit/tools/gpx2navit_txt/src/geodesic.h b/navit/tools/gpx2navit_txt/src/geodesic.h
index 5f818c37a..200f98659 100644
--- a/navit/tools/gpx2navit_txt/src/geodesic.h
+++ b/navit/tools/gpx2navit_txt/src/geodesic.h
@@ -56,10 +56,10 @@ GEOD_EXTERN struct geodesic {
# define f64 GEODESIC.FLAT64
# define ellipse GEODESIC.ELLIPSE
-
+
GEOD_EXTERN int n_alpha, n_S;
GEOD_EXTERN double to_meter, fr_meter, del_alpha;
-
+
void geod_set(int, char **);
void geod_for(void);
void geod_pre(void);
diff --git a/navit/tools/gpx2navit_txt/src/gpx2navit_txt.h b/navit/tools/gpx2navit_txt/src/gpx2navit_txt.h
index 038ca8605..9b37f0031 100644
--- a/navit/tools/gpx2navit_txt/src/gpx2navit_txt.h
+++ b/navit/tools/gpx2navit_txt/src/gpx2navit_txt.h
@@ -150,7 +150,7 @@ typedef struct g2sattr {
} g2sattr;
/**
- * statistics structure
+ * statistics structure
*/
typedef struct g2sstats {
int trkpoints; /** track point total count */
@@ -161,12 +161,12 @@ typedef struct g2sstats {
double rtelength; /** route total length */
int wptpoints; /** way point total count */
int trkunconverted; /** unconverted track path count */
- int rteunconverted; /** unconverted route path count */
+ int rteunconverted; /** unconverted route path count */
} g2sstats;
/**
* cluster of all dbfhandles
- */
+ */
//typedef struct dbfhandles {
// DBFHandle trk; /** for track */
// DBFHandle wpt; /** for waypoint */
@@ -224,7 +224,7 @@ typedef struct g2sprop {
} g2sprop;
/**
- * userdata structure between expat methods
+ * userdata structure between expat methods
*/
typedef struct parsedata {
int depth; /** xml path depth */
diff --git a/navit/tools/gpx2navit_txt/src/main.c b/navit/tools/gpx2navit_txt/src/main.c
index e244957fc..24164abcb 100644
--- a/navit/tools/gpx2navit_txt/src/main.c
+++ b/navit/tools/gpx2navit_txt/src/main.c
@@ -28,8 +28,7 @@ void setOptions(int argc, char **argv, g2sprop * prop);
/**
* Shows a version
*/
-void version(void)
-{
+void version(void) {
fprintf(stdout, "gpx2navit_txt 0.1\n");
fprintf(stdout, "\n");
fprintf(stdout, "by Toshihiro Hiraoka\n");
@@ -39,89 +38,88 @@ void version(void)
/**
* Shows a usage message
*/
-void usage(char **argv)
-{
+void usage(char **argv) {
fprintf(stdout, "Usage: %s gpxfile [options] [-o output basename]\n",
- argv[0]);
+ argv[0]);
fprintf(stdout,
- "-o, --output Sets output basename. The default is (source file\n");
+ "-o, --output Sets output basename. The default is (source file\n");
fprintf(stdout, " name) - (extention name)\n");
fprintf
- (stdout,
- "-w, --waypoints Converts only waypoints data from a gpx file.\n");
+ (stdout,
+ "-w, --waypoints Converts only waypoints data from a gpx file.\n");
fprintf(stdout,
- "-t, --trackpoints Converts only trackpoints data from a gpx file.\n");
+ "-t, --trackpoints Converts only trackpoints data from a gpx file.\n");
fprintf(stdout,
- "-r, --routes Converts only routes data from a gpx file.\n");
+ "-r, --routes Converts only routes data from a gpx file.\n");
fprintf(stdout,
- "-a, --all Converts all types of data from a gpx file.(default)\n");
+ "-a, --all Converts all types of data from a gpx file.(default)\n");
fprintf(stdout,
- "-e, --as-edge Makes a separated output by each edges.\n");
+ "-e, --as-edge Makes a separated output by each edges.\n");
fprintf(stdout,
- "-p, --as-point Makes a separated output by each points.\n");
+ "-p, --as-point Makes a separated output by each points.\n");
fprintf(stdout,
- "-s, --stats Shows simple statistics of the outputs.\n");
+ "-s, --stats Shows simple statistics of the outputs.\n");
fprintf(stdout,
- "-b, --basic-columns Stores only basic data as attribures to \n");
+ "-b, --basic-columns Stores only basic data as attribures to \n");
fprintf(stdout,
- " reduce memory and storage usage.\n");
+ " reduce memory and storage usage.\n");
fprintf(stdout,
- " (ele, name, cmt, type, time, fix, sym and number).\n");
+ " (ele, name, cmt, type, time, fix, sym and number).\n");
fprintf(stdout,
- "-L, --no-length Removes length column from a waypoint or trackpoint\n");
+ "-L, --no-length Removes length column from a waypoint or trackpoint\n");
fprintf(stdout, " attribute table.\n");
fprintf
- (stdout,
- "-S, --no-speed Removes speed column from a waypoint or trackpoint\n");
+ (stdout,
+ "-S, --no-speed Removes speed column from a waypoint or trackpoint\n");
fprintf(stdout, " attribute table.\n");
fprintf
- (stdout,
- "-T, --no-time Removes time column from an attribute table.\n");
+ (stdout,
+ "-T, --no-time Removes time column from an attribute table.\n");
fprintf(stdout,
- "-g, --gpxline Adds line number of GPX file as attribures.\n");
+ "-g, --gpxline Adds line number of GPX file as attribures.\n");
fprintf
- (stdout,
- "-f, --fast Make it faster without any checks.\n");
+ (stdout,
+ "-f, --fast Make it faster without any checks.\n");
fprintf(stdout,
- "-3, --3d Converts data using 3d format. (It's not compatible\n");
+ "-3, --3d Converts data using 3d format. (It's not compatible\n");
fprintf(stdout, " for Arcview 3.x.)\n");
fprintf(stdout,
- " --min-points Sets path minimum points to convert for noise reduction.\n");
+ " --min-points Sets path minimum points to convert for noise reduction.\n");
fprintf(stdout, " Default is 2.\n");
fprintf(stdout,
- " --min-length Sets path minimum length to convert for noise reduction.\n");
+ " --min-length Sets path minimum length to convert for noise reduction.\n");
fprintf(stdout, " Default is 0.\n");
fprintf(stdout,
- " --min-time Sets path minimum time period to convert for noise\n");
+ " --min-time Sets path minimum time period to convert for noise\n");
fprintf(stdout, " reduction.\n");
fprintf(stdout, " Default is 0.\n");
fprintf(stdout,
- " --length-unit Sets length unit from m,km,feet,mi and etc.\n");
+ " --length-unit Sets length unit from m,km,feet,mi and etc.\n");
fprintf(stdout, " The default is m.\n");
fprintf(stdout,
- " You can see the unit list from \"geod -lu\" command.\n");
+ " You can see the unit list from \"geod -lu\" command.\n");
fprintf
- (stdout,
- " --time-unit Sets time unit. The default is sec.\n");
+ (stdout,
+ " --time-unit Sets time unit. The default is sec.\n");
fprintf(stdout,
- " You can set from day, hour, min and sec.\n");
+ " You can set from day, hour, min and sec.\n");
fprintf(stdout,
- " --speed-length-unit Sets length unit for speed.\n");
+ " --speed-length-unit Sets length unit for speed.\n");
fprintf(stdout, " The default is km.\n");
fprintf(stdout,
- " You can see the unit list from \"geod -lu\" command.\n");
+ " You can see the unit list from \"geod -lu\" command.\n");
fprintf(stdout,
- " --speed-time-unit Sets time unit for speed calulation. Default is hour.\n");
+ " --speed-time-unit Sets time unit for speed calulation. Default is hour.\n");
fprintf(stdout,
- " You can set from day, hour, min and sec.\n");
+ " You can set from day, hour, min and sec.\n");
fprintf(stdout,
- " --length-ellipsoid Sets length ellipsoid like UGS84, clrk66. The default is\n");
+ " --length-ellipsoid Sets length ellipsoid like UGS84, clrk66. The default is\n");
fprintf(stdout, " UGS84.\n");
fprintf
- (stdout,
- " You can see the unit list from \"geod -le\" command.\n");
+ (stdout,
+ " You can see the unit list from \"geod -le\" command.\n");
fprintf(stdout,
- " --no-speed-check Disables track check for speed to be non-zero.\n");
+ " --no-speed-check Disables track check for speed to be non-zero.\n");
fprintf(stdout, "-v, --verbose Gives many messages.\n");
fprintf(stdout, " --version Shows version.\n");
fprintf(stdout, "-h, --help Shows this list.\n");
@@ -130,56 +128,55 @@ void usage(char **argv)
/**
* Sets default values to the properties when there is no user setting.
*/
-void setDefault(g2sprop * prop)
-{
+void setDefault(g2sprop * prop) {
char *pargv[2];
int pargc = 2;
char *ellps;
/* if there are no options like -p,-w,-e, sets as -a */
if (!(prop->parseWpt | prop->parseTrk | prop->parseRte)) {
- prop->parseWpt = 1;
- prop->parseTrk = 1;
- prop->parseRte = 1;
+ prop->parseWpt = 1;
+ prop->parseTrk = 1;
+ prop->parseRte = 1;
}
/* if there is no output setting, sets it as [sourcefile name] - ".gpx" */
if (prop->output == NULL) {
- char *dot = strrchr(prop->sourcefile, '.');
- prop->output =
- (char *) malloc(sizeof(char) * strlen(prop->sourcefile) + 1);
- if (0 == strcmp(dot, ".gpx")) {
- int len = dot - prop->sourcefile;
- strncpy(prop->output, prop->sourcefile, len);
- prop->output[len] = 0;
- } else {
- fprintf(stderr,
- "The source file doesn't have .gpx extension.\n");
- exit(ERR_ISNOTGPX);
- }
+ char *dot = strrchr(prop->sourcefile, '.');
+ prop->output =
+ (char *) malloc(sizeof(char) * strlen(prop->sourcefile) + 1);
+ if (0 == strcmp(dot, ".gpx")) {
+ int len = dot - prop->sourcefile;
+ strncpy(prop->output, prop->sourcefile, len);
+ prop->output[len] = 0;
+ } else {
+ fprintf(stderr,
+ "The source file doesn't have .gpx extension.\n");
+ exit(ERR_ISNOTGPX);
+ }
}
/* sets ellipsoid "WGS84" */
if (prop->ellipsoid == NULL) {
- prop->ellipsoid = (char *) malloc(sizeof(char) * 7);
- strcpy(prop->ellipsoid, "WGS84");
+ prop->ellipsoid = (char *) malloc(sizeof(char) * 7);
+ strcpy(prop->ellipsoid, "WGS84");
}
/* sets lengthUnit "m" */
if (prop->lengthUnit == NULL) {
- prop->lengthUnit = (char *) malloc(sizeof(char) * 2);
- strcpy(prop->lengthUnit, "m");
+ prop->lengthUnit = (char *) malloc(sizeof(char) * 2);
+ strcpy(prop->lengthUnit, "m");
}
/* sets timeUnit "sec" */
if (prop->timeUnit == NULL) {
- prop->timeUnit = (char *) malloc(sizeof(char) * 4);
- strcpy(prop->timeUnit, "sec");
+ prop->timeUnit = (char *) malloc(sizeof(char) * 4);
+ strcpy(prop->timeUnit, "sec");
}
/* sets speedLengthUnit "km" */
if (prop->speedLengthUnit == NULL) {
- prop->speedLengthUnit = (char *) malloc(sizeof(char) * 3);
- strcpy(prop->speedLengthUnit, "km");
+ prop->speedLengthUnit = (char *) malloc(sizeof(char) * 3);
+ strcpy(prop->speedLengthUnit, "km");
}
/* sets speedTimeUnit "hour" */
if (prop->speedTimeUnit == NULL) {
- prop->speedTimeUnit = (char *) malloc(sizeof(char) * 5);
- strcpy(prop->speedTimeUnit, "hour");
+ prop->speedTimeUnit = (char *) malloc(sizeof(char) * 5);
+ strcpy(prop->speedTimeUnit, "hour");
}
/* sets ellipsoid setting to geod* programs */
ellps = malloc(sizeof(char) * (strlen(prop->ellipsoid) + 8));
@@ -194,8 +191,8 @@ void setDefault(g2sprop * prop)
prop->speed2sec = checkTimeUnit(prop->speedTimeUnit);
geod_set(pargc, pargv);
if (prop->verbose) {
- printf("source filename:\t%s\n", prop->sourcefile);
- printf("output file base name:\t%s\n", prop->output);
+ printf("source filename:\t%s\n", prop->sourcefile);
+ printf("output file base name:\t%s\n", prop->output);
}
free(ellps);
}
@@ -203,196 +200,195 @@ void setDefault(g2sprop * prop)
/**
* Set options from command arguments
*/
-void setOptions(int argc, char **argv, g2sprop * prop)
-{
+void setOptions(int argc, char **argv, g2sprop * prop) {
int result;
/* option struct for getopt_long */
struct option const long_options[] = {
- {"waypoints", no_argument, 0, 'w'},
- {"trackpoints", no_argument, 0, 't'},
- {"routes", no_argument, 0, 'r'},
- {"output", required_argument, 0, 'o'},
- {"as-edge", no_argument, 0, 'e'},
- {"as-point", no_argument, 0, 'p'},
- {"min-points", required_argument, 0, 'P'},
- {"min-length", required_argument, 0, 'l'},
- {"min-time", required_argument, 0, 'm'},
- {"stats", no_argument, 0, 's'},
- {"basic-columns", no_argument, 0, 'b'},
- {"fast", no_argument, 0, 'f'},
- {"length-unit", required_argument, 0, '4'},
- {"time-unit", required_argument, 0, '8'},
- {"length-ellipsoid", required_argument, 0, '7'},
- {"speed-length-unit", required_argument, 0, '5'},
- {"speed-time-unit", required_argument, 0, '6'},
- {"no-speed", no_argument, 0, 'S'},
- {"no-length", no_argument, 0, 'L'},
- {"no-time", no_argument, 0, 'T'},
- {"verbose", no_argument, 0, 'v'},
- {"gpxline", no_argument, 0, 'g'},
- {"all", no_argument, 0, 'a'},
- {"no-speed-check", no_argument, 0, '9'},
- {"version", no_argument, 0, 'V'},
- {"help", no_argument, 0, '?'},
- {0, no_argument, 0, '0'},
+ {"waypoints", no_argument, 0, 'w'},
+ {"trackpoints", no_argument, 0, 't'},
+ {"routes", no_argument, 0, 'r'},
+ {"output", required_argument, 0, 'o'},
+ {"as-edge", no_argument, 0, 'e'},
+ {"as-point", no_argument, 0, 'p'},
+ {"min-points", required_argument, 0, 'P'},
+ {"min-length", required_argument, 0, 'l'},
+ {"min-time", required_argument, 0, 'm'},
+ {"stats", no_argument, 0, 's'},
+ {"basic-columns", no_argument, 0, 'b'},
+ {"fast", no_argument, 0, 'f'},
+ {"length-unit", required_argument, 0, '4'},
+ {"time-unit", required_argument, 0, '8'},
+ {"length-ellipsoid", required_argument, 0, '7'},
+ {"speed-length-unit", required_argument, 0, '5'},
+ {"speed-time-unit", required_argument, 0, '6'},
+ {"no-speed", no_argument, 0, 'S'},
+ {"no-length", no_argument, 0, 'L'},
+ {"no-time", no_argument, 0, 'T'},
+ {"verbose", no_argument, 0, 'v'},
+ {"gpxline", no_argument, 0, 'g'},
+ {"all", no_argument, 0, 'a'},
+ {"no-speed-check", no_argument, 0, '9'},
+ {"version", no_argument, 0, 'V'},
+ {"help", no_argument, 0, '?'},
+ {0, no_argument, 0, '0'},
};
if (argc <= 1) {
- fprintf(stderr, "There is no argument.\n");
- usage(argv);
- exit(ERR_NOARGS);
+ fprintf(stderr, "There is no argument.\n");
+ usage(argv);
+ exit(ERR_NOARGS);
}
/* set option attributes */
while ((result =
- getopt_long(argc, argv, "3wtrao:epfP:l:m:bS4:5:6:7:8:LTSsvg09",
- long_options, NULL)) != -1) {
- switch (result) {
- case '3': /* 3d output */
- prop->is3d = 1;
- break;
- case 'w': /* converts only waypoint */
- prop->parseWpt = 1;
- break;
- case 't': /* converts only trackpoint */
- prop->parseTrk = 1;
- break;
- case 'r': /* converts only route */
- prop->parseRte = 1;
- break;
- case 'a': /* converts all */
- prop->parseWpt = 1;
- prop->parseTrk = 1;
- prop->parseRte = 1;
- break;
- case 'o': /* sets basename of output file */
- prop->output =
- (char *) malloc(sizeof(char) * strlen(optarg) + 1);
- strcpy(prop->output, optarg);
- break;
- case 'e': /* make output by each edges */
- if (prop->isEdge) {
- fprintf(stderr, "option -e cannot use with -f\n");
- exit(ERR_OPTIONCONFRICT);
- }
- prop->isEdge = 1;
- break;
- case 'p': /* make output by each edges */
- prop->isPoint = 1;
- break;
- case 'f': /* make it faster */
- if (prop->isEdge) {
- fprintf(stderr, "option -f cannot use with -e\n");
- exit(ERR_OPTIONCONFRICT);
- }
- prop->isFast = 1;
- prop->cols->desc = 0;
- prop->cols->src = 0;
- prop->cols->link = 0;
- prop->cols->magvar = 0;
- prop->cols->geoidheight = 0;
- prop->cols->sat = 0;
- prop->cols->hdop = 0;
- prop->cols->vdop = 0;
- prop->cols->pdop = 0;
- prop->cols->ageofdgpsdata = 0;
- prop->cols->dgpsid = 0;
- prop->cols->length = 0;
- prop->cols->interval = 0;
- prop->cols->speed = 0;
- break;
- case 'P': /* sets minimun points as a path */
- prop->minpoints = atoi(optarg);
- break;
- case 'l': /* sets minimun length as a path */
- prop->minlength = atoi(optarg);
- break;
- case 'm': /* sets minimun time as a path */
- prop->mintime = atoi(optarg);
- break;
- case 'b': /* use only some columns */
- prop->cols->desc = 0;
- prop->cols->src = 0;
- prop->cols->link = 0;
- prop->cols->magvar = 0;
- prop->cols->geoidheight = 0;
- prop->cols->sat = 0;
- prop->cols->hdop = 0;
- prop->cols->vdop = 0;
- prop->cols->pdop = 0;
- prop->cols->ageofdgpsdata = 0;
- prop->cols->dgpsid = 0;
- prop->cols->length = 0;
- prop->cols->interval = 0;
- prop->cols->speed = 0;
- break;
- case 'S': /* doesn't make speed column */
- prop->cols->speed = 0;
- break;
- case '4': /* sets length unit */
- prop->lengthUnit = malloc(sizeof(char) * (strlen(optarg) + 1));
- strcpy(prop->lengthUnit, optarg);
- break;
- case '5': /* sets length unit for calculating speed */
- prop->speedLengthUnit =
- malloc(sizeof(char) * (strlen(optarg) + 1));
- strcpy(prop->speedLengthUnit, optarg);
- break;
- case '6': /* sets time unit for calculating speed */
- prop->speedTimeUnit =
- malloc(sizeof(char) * (strlen(optarg) + 1));
- strcpy(prop->speedTimeUnit, optarg);
- break;
- case '7': /* sets ellipsoid for calculating length */
- prop->ellipsoid = malloc(sizeof(char) * (strlen(optarg) + 1));
- strcpy(prop->ellipsoid, optarg);
- break;
- case '8': /* sets time unit */
- prop->timeUnit = malloc(sizeof(char) * (strlen(optarg) + 1));
- strcpy(prop->timeUnit, optarg);
- break;
- case '9': /* disables speed check */
- prop->nospeedcheck=1;
- break;
- case 'L': /* doesn't make length column */
- prop->cols->length = 0;
- break;
- case 'T': /* doesn't make time column */
- prop->cols->interval = 0;
- break;
- case 's': /* shows source file stats */
- prop->needsStats = 1;
- break;
- case 'v': /* verbose mode */
- prop->verbose = 1;
- break;
- case 'V': /* shows version */
- version();
- exit(EXIT_SUCCESS);
- break;
- case 'g': /* adds gpx line number column */
- prop->cols->gpxline = 1;
- break;
- case ':':
- usage(argv);
- exit(ERR_WRONGOPTION);
- break;
- case '0':
- usage(argv);
- exit(ERR_WRONGOPTION);
- break;
- default:
- usage(argv);
- exit(ERR_WRONGOPTION);
- break;
- }
+ getopt_long(argc, argv, "3wtrao:epfP:l:m:bS4:5:6:7:8:LTSsvg09",
+ long_options, NULL)) != -1) {
+ switch (result) {
+ case '3': /* 3d output */
+ prop->is3d = 1;
+ break;
+ case 'w': /* converts only waypoint */
+ prop->parseWpt = 1;
+ break;
+ case 't': /* converts only trackpoint */
+ prop->parseTrk = 1;
+ break;
+ case 'r': /* converts only route */
+ prop->parseRte = 1;
+ break;
+ case 'a': /* converts all */
+ prop->parseWpt = 1;
+ prop->parseTrk = 1;
+ prop->parseRte = 1;
+ break;
+ case 'o': /* sets basename of output file */
+ prop->output =
+ (char *) malloc(sizeof(char) * strlen(optarg) + 1);
+ strcpy(prop->output, optarg);
+ break;
+ case 'e': /* make output by each edges */
+ if (prop->isEdge) {
+ fprintf(stderr, "option -e cannot use with -f\n");
+ exit(ERR_OPTIONCONFRICT);
+ }
+ prop->isEdge = 1;
+ break;
+ case 'p': /* make output by each edges */
+ prop->isPoint = 1;
+ break;
+ case 'f': /* make it faster */
+ if (prop->isEdge) {
+ fprintf(stderr, "option -f cannot use with -e\n");
+ exit(ERR_OPTIONCONFRICT);
+ }
+ prop->isFast = 1;
+ prop->cols->desc = 0;
+ prop->cols->src = 0;
+ prop->cols->link = 0;
+ prop->cols->magvar = 0;
+ prop->cols->geoidheight = 0;
+ prop->cols->sat = 0;
+ prop->cols->hdop = 0;
+ prop->cols->vdop = 0;
+ prop->cols->pdop = 0;
+ prop->cols->ageofdgpsdata = 0;
+ prop->cols->dgpsid = 0;
+ prop->cols->length = 0;
+ prop->cols->interval = 0;
+ prop->cols->speed = 0;
+ break;
+ case 'P': /* sets minimun points as a path */
+ prop->minpoints = atoi(optarg);
+ break;
+ case 'l': /* sets minimun length as a path */
+ prop->minlength = atoi(optarg);
+ break;
+ case 'm': /* sets minimun time as a path */
+ prop->mintime = atoi(optarg);
+ break;
+ case 'b': /* use only some columns */
+ prop->cols->desc = 0;
+ prop->cols->src = 0;
+ prop->cols->link = 0;
+ prop->cols->magvar = 0;
+ prop->cols->geoidheight = 0;
+ prop->cols->sat = 0;
+ prop->cols->hdop = 0;
+ prop->cols->vdop = 0;
+ prop->cols->pdop = 0;
+ prop->cols->ageofdgpsdata = 0;
+ prop->cols->dgpsid = 0;
+ prop->cols->length = 0;
+ prop->cols->interval = 0;
+ prop->cols->speed = 0;
+ break;
+ case 'S': /* doesn't make speed column */
+ prop->cols->speed = 0;
+ break;
+ case '4': /* sets length unit */
+ prop->lengthUnit = malloc(sizeof(char) * (strlen(optarg) + 1));
+ strcpy(prop->lengthUnit, optarg);
+ break;
+ case '5': /* sets length unit for calculating speed */
+ prop->speedLengthUnit =
+ malloc(sizeof(char) * (strlen(optarg) + 1));
+ strcpy(prop->speedLengthUnit, optarg);
+ break;
+ case '6': /* sets time unit for calculating speed */
+ prop->speedTimeUnit =
+ malloc(sizeof(char) * (strlen(optarg) + 1));
+ strcpy(prop->speedTimeUnit, optarg);
+ break;
+ case '7': /* sets ellipsoid for calculating length */
+ prop->ellipsoid = malloc(sizeof(char) * (strlen(optarg) + 1));
+ strcpy(prop->ellipsoid, optarg);
+ break;
+ case '8': /* sets time unit */
+ prop->timeUnit = malloc(sizeof(char) * (strlen(optarg) + 1));
+ strcpy(prop->timeUnit, optarg);
+ break;
+ case '9': /* disables speed check */
+ prop->nospeedcheck=1;
+ break;
+ case 'L': /* doesn't make length column */
+ prop->cols->length = 0;
+ break;
+ case 'T': /* doesn't make time column */
+ prop->cols->interval = 0;
+ break;
+ case 's': /* shows source file stats */
+ prop->needsStats = 1;
+ break;
+ case 'v': /* verbose mode */
+ prop->verbose = 1;
+ break;
+ case 'V': /* shows version */
+ version();
+ exit(EXIT_SUCCESS);
+ break;
+ case 'g': /* adds gpx line number column */
+ prop->cols->gpxline = 1;
+ break;
+ case ':':
+ usage(argv);
+ exit(ERR_WRONGOPTION);
+ break;
+ case '0':
+ usage(argv);
+ exit(ERR_WRONGOPTION);
+ break;
+ default:
+ usage(argv);
+ exit(ERR_WRONGOPTION);
+ break;
+ }
}
/* gets a source file name */
if(argv[optind] == NULL) {
- fprintf(stderr, "There is no gpxfile description.\n");
- usage(argv);
- exit(ERR_WRONGOPTION);
+ fprintf(stderr, "There is no gpxfile description.\n");
+ usage(argv);
+ exit(ERR_WRONGOPTION);
}
prop->sourcefile = malloc(sizeof(char) * (strlen(argv[optind]) + 1));
- /** @note needs to change here to support
+ /** @note needs to change here to support
* a several files convertion */
strcpy(prop->sourcefile, argv[optind]);
setDefault(prop);
@@ -401,14 +397,13 @@ void setOptions(int argc, char **argv, g2sprop * prop)
/**
* Main
*/
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
g2sprop *prop;
prop = createProp();
setOptions(argc, argv, prop);
parseMain(prop);
if (prop->needsStats)
- showStats(prop);
+ showStats(prop);
closeProp(prop);
return (0);
}
diff --git a/navit/tools/gpx2navit_txt/src/misc.c b/navit/tools/gpx2navit_txt/src/misc.c
index fc272e8cb..c34f1ff06 100644
--- a/navit/tools/gpx2navit_txt/src/misc.c
+++ b/navit/tools/gpx2navit_txt/src/misc.c
@@ -37,70 +37,67 @@ void closeParsedata(parsedata * pdata);
/**
* message when fail to write attribute
*/
-void failToWriteAttrRep(int iShape, int col, char *file, int line)
-{
+void failToWriteAttrRep(int iShape, int col, char *file, int line) {
printf("Fail to write a attribute at %s:%i. shapeid:%i col:%i\n", file,
- line, iShape, col);
+ line, iShape, col);
}
/**
* shows short statistics
*/
-void showStats(g2sprop * prop)
-{
+void showStats(g2sprop * prop) {
g2sstats *stats = prop->stats;
double ratio;
if (prop->needsStats) {
- if (prop->parseTrk) {
- if (stats->trkunconverted != 0) {
- ratio =
- (double) stats->trkunconverted / (stats->trkcount +
- stats->
- trkunconverted) *
- 100;
- } else {
- ratio = 0;
- }
- printf("Track Points:\n");
- printf("\ttrack count:\t%i\n", stats->trkcount);
- printf("\tpoint count:\t%i\n", stats->trkpoints);
- if (!prop->isFast) {
- printf("\ttotal length:\t%f\n", stats->trklength);
- printf("\tunconverted:\t%i(%5.2f%%)\n",
- stats->trkunconverted, ratio);
- }
- }
- if (prop->parseRte) {
- if (stats->rteunconverted != 0) {
- ratio =
- (double) stats->rteunconverted / (stats->rtecount +
- stats->
- rteunconverted) *
- 100;
- } else {
- ratio = 0;
- }
- printf("Routes:\n");
- printf("\troute count:\t%i\n", stats->rtecount);
- printf("\tpoint count:\t%i\n", stats->rtepoints);
- if (!prop->isFast) {
- printf("\ttotal length:\t%f\n", stats->rtelength);
- printf("\tunconverted:\t%i(%5.2f%%)\n",
- stats->rteunconverted, ratio);
- }
- }
- if (prop->parseWpt) {
- printf("Waypoints:\n");
- printf("\tpoint count:\t%i\n", stats->wptpoints);
- }
+ if (prop->parseTrk) {
+ if (stats->trkunconverted != 0) {
+ ratio =
+ (double) stats->trkunconverted / (stats->trkcount +
+ stats->
+ trkunconverted) *
+ 100;
+ } else {
+ ratio = 0;
+ }
+ printf("Track Points:\n");
+ printf("\ttrack count:\t%i\n", stats->trkcount);
+ printf("\tpoint count:\t%i\n", stats->trkpoints);
+ if (!prop->isFast) {
+ printf("\ttotal length:\t%f\n", stats->trklength);
+ printf("\tunconverted:\t%i(%5.2f%%)\n",
+ stats->trkunconverted, ratio);
+ }
+ }
+ if (prop->parseRte) {
+ if (stats->rteunconverted != 0) {
+ ratio =
+ (double) stats->rteunconverted / (stats->rtecount +
+ stats->
+ rteunconverted) *
+ 100;
+ } else {
+ ratio = 0;
+ }
+ printf("Routes:\n");
+ printf("\troute count:\t%i\n", stats->rtecount);
+ printf("\tpoint count:\t%i\n", stats->rtepoints);
+ if (!prop->isFast) {
+ printf("\ttotal length:\t%f\n", stats->rtelength);
+ printf("\tunconverted:\t%i(%5.2f%%)\n",
+ stats->rteunconverted, ratio);
+ }
+ }
+ if (prop->parseWpt) {
+ printf("Waypoints:\n");
+ printf("\tpoint count:\t%i\n", stats->wptpoints);
+ }
}
}
/**
- * clears a path attribute structure
+ * clears a path attribute structure
*/
-void wipePathAttr(pathattr * pattr)
-{
+void wipePathAttr(pathattr * pattr) {
pattr->name[0] = '\0';
pattr->cmt[0] = '\0';
pattr->desc[0] = '\0';
@@ -116,10 +113,9 @@ void wipePathAttr(pathattr * pattr)
}
/**
- * creates a new path attribute
+ * creates a new path attribute
*/
-pathattr *createPathAttr(void)
-{
+pathattr *createPathAttr(void) {
pathattr *pattr;
pattr = (pathattr *) malloc(sizeof(pathattr));
wipePathAttr(pattr);
@@ -127,10 +123,9 @@ pathattr *createPathAttr(void)
}
/**
- * clears a element attribute structure
+ * clears a element attribute structure
*/
-void wipeAttr(g2sattr * attr)
-{
+void wipeAttr(g2sattr * attr) {
attr->lon = 0;
attr->lat = 0;
attr->minlon = 0;
@@ -170,8 +165,7 @@ void wipeAttr(g2sattr * attr)
/**
* sets default values to a column properties.
*/
-void setColsDefault(g2scolumns * cols)
-{
+void setColsDefault(g2scolumns * cols) {
cols->name = 1;
cols->cmt = 1;
cols->desc = 1;
@@ -201,8 +195,7 @@ void setColsDefault(g2scolumns * cols)
/**
* creates a column structure
*/
-g2scolumns *createCols(void)
-{
+g2scolumns *createCols(void) {
g2scolumns *cols;
cols = (g2scolumns *) malloc(sizeof(g2scolumns));
setColsDefault(cols);
@@ -212,8 +205,7 @@ g2scolumns *createCols(void)
/**
* creates a element attribute structure.
*/
-g2sattr *createAttr(void)
-{
+g2sattr *createAttr(void) {
g2sattr *attr;
attr = (g2sattr *) malloc(sizeof(g2sattr));
wipeAttr(attr);
@@ -223,8 +215,7 @@ g2sattr *createAttr(void)
/**
* creates a properties structure for gpx2shp
*/
-g2sprop *createProp(void)
-{
+g2sprop *createProp(void) {
g2sprop *prop;
g2sstats *stats;
g2scolumns *cols;
@@ -266,8 +257,7 @@ g2sprop *createProp(void)
/**
* close and free a propertires structure
*/
-void closeProp(g2sprop * prop)
-{
+void closeProp(g2sprop * prop) {
free(prop->stats);
free(prop->sourcefile);
free(prop->ellipsoid);
@@ -317,8 +307,7 @@ void closeProp(g2sprop * prop)
/**
* creates a parse structure
*/
-parsedata *createParsedata(XML_Parser parser, g2sprop * prop)
-{
+parsedata *createParsedata(XML_Parser parser, g2sprop * prop) {
parsedata *pdata = (parsedata *) malloc(sizeof(parsedata));
pdata->fp = NULL;
//shphandles *shps = createShps();
@@ -350,8 +339,7 @@ parsedata *createParsedata(XML_Parser parser, g2sprop * prop)
/*
* close and free resoures
*/
-void closeParsedata(parsedata * pdata)
-{
+void closeParsedata(parsedata * pdata) {
//free(pdata->shps);
//free(pdata->dbfs);
free(pdata->parent);
diff --git a/navit/tools/gpx2navit_txt/src/parser.c b/navit/tools/gpx2navit_txt/src/parser.c
index dc62d71f1..d15a17e55 100644
--- a/navit/tools/gpx2navit_txt/src/parser.c
+++ b/navit/tools/gpx2navit_txt/src/parser.c
@@ -27,8 +27,7 @@ void parseMain(g2sprop * prop);
/**
* a handler to parse charctor data on expat
*/
-void charHandle(void *userdata, const XML_Char * data, int length)
-{
+void charHandle(void *userdata, const XML_Char * data, int length) {
static int bufsize = DATABUFSIZE;
static int string_length = 0;
int new_length;
@@ -36,40 +35,39 @@ void charHandle(void *userdata, const XML_Char * data, int length)
int i;
parsedata *pdata = (parsedata *) userdata;
if (pdata->bufptr == NULL) {
- //start of buffer -->pdata->bufptr set to 0 at endelement
- string_length = 0;
+ //start of buffer -->pdata->bufptr set to 0 at endelement
+ string_length = 0;
begin_copy = 0; //begin to copy after first space
- pdata->bufptr= pdata->databuf;
+ pdata->bufptr= pdata->databuf;
}
new_length = string_length + length + 1; //additonal 0
if (bufsize < new_length) {
- pdata->databuf =
- realloc(pdata->databuf, new_length);
- bufsize = new_length;
- //because of realloc the pointer may have changed
- pdata->bufptr = pdata->databuf + string_length;
+ pdata->databuf =
+ realloc(pdata->databuf, new_length);
+ bufsize = new_length;
+ //because of realloc the pointer may have changed
+ pdata->bufptr = pdata->databuf + string_length;
}
// because expat calls this routine several times on special chars
// we need to do following
// --concat strings until reset (bufptr set to NULL)
// --filter out blank chars at begin of string
- for (i=0; i<length;i++) {
- if (begin_copy || !isspace(data[i])) {
- *pdata->bufptr = data[i];
- pdata->bufptr++;
- string_length ++;
- begin_copy = 1;
- if (DEBUG) fprintf(stderr,"%c",data[i]);
- }
- }
+ for (i=0; i<length; i++) {
+ if (begin_copy || !isspace(data[i])) {
+ *pdata->bufptr = data[i];
+ pdata->bufptr++;
+ string_length ++;
+ begin_copy = 1;
+ if (DEBUG) fprintf(stderr,"%c",data[i]);
+ }
+ }
*pdata->bufptr = '\0';
}
/**
* a handler when a element starts
*/
-void startElement(void *userdata, const char *element, const char **attr)
-{
+void startElement(void *userdata, const char *element, const char **attr) {
parsedata *pdata = (parsedata *) userdata;
pdata->parent = pdata->current;
pdata->current = malloc(sizeof(parent));
@@ -78,14 +76,14 @@ void startElement(void *userdata, const char *element, const char **attr)
pdata->current->parentptr = pdata->parent;
startElementControl(pdata, element, attr);
if (pdata->prop->verbose) {
- int i;
- for (i = 0; i < pdata->depth; i++)
- printf(" ");
- printf("<%s>: ", element);
- for (i = 0; attr[i]; i += 2) {
- printf(" %s='%s'", attr[i], attr[i + 1]);
- }
- printf("\n");
+ int i;
+ for (i = 0; i < pdata->depth; i++)
+ printf(" ");
+ printf("<%s>: ", element);
+ for (i = 0; attr[i]; i += 2) {
+ printf(" %s='%s'", attr[i], attr[i + 1]);
+ }
+ printf("\n");
}
pdata->depth++;
}
@@ -93,16 +91,15 @@ void startElement(void *userdata, const char *element, const char **attr)
/**
* a handler when a element ends
*/
-void endElement(void *userdata, const char *element)
-{
+void endElement(void *userdata, const char *element) {
parsedata *pdata = (parsedata *) userdata;
endElementControl(pdata, element);
pdata->depth--;
if (pdata->prop->verbose) {
- int i;
- for (i = 0; i < pdata->depth; i++)
- printf(" ");
- printf("</%s>:%s\n ", element,pdata->parent->name);
+ int i;
+ for (i = 0; i < pdata->depth; i++)
+ printf(" ");
+ printf("</%s>:%s\n ", element,pdata->parent->name);
}
free(pdata->current->name);
free(pdata->current);
@@ -110,33 +107,31 @@ void endElement(void *userdata, const char *element)
pdata->parent = pdata->parent->parentptr;
}
-void parseMain(g2sprop * prop)
-{
+void parseMain(g2sprop * prop) {
FILE *fp;
char buff[BUFFSIZE];
XML_Parser parser;
parsedata *pdata;
fp = fopen(prop->sourcefile, "r");
if (fp == NULL) {
- fprintf(stderr, "Cannot open gpx file: %s\n", prop->sourcefile);
- exit(ERR_CANNOTOPEN);
+ fprintf(stderr, "Cannot open gpx file: %s\n", prop->sourcefile);
+ exit(ERR_CANNOTOPEN);
}
parser = XML_ParserCreate(NULL);
if (!parser) {
- fprintf(stderr, "Couldn't allocate memory for parser\n");
- exit(ERR_OUTOFMEMORY);
+ fprintf(stderr, "Couldn't allocate memory for parser\n");
+ exit(ERR_OUTOFMEMORY);
}
pdata = createParsedata(parser, prop);
char *output_wpt =
- (char *) malloc(sizeof(char) * (strlen(pdata->prop->output) + 9));
+ (char *) malloc(sizeof(char) * (strlen(pdata->prop->output) + 9));
strcpy(output_wpt, pdata->prop->output);
strcat(output_wpt, "_nav.txt");
pdata->fp = fopen(output_wpt,"w");
- if (pdata->fp == NULL)
- {
- //todo
- fprintf(stderr,"Failure opening File %s for writing",output_wpt);
+ if (pdata->fp == NULL) {
+ //todo
+ fprintf(stderr,"Failure opening File %s for writing",output_wpt);
exit(1);
}
free(output_wpt);
@@ -144,23 +139,23 @@ void parseMain(g2sprop * prop)
XML_SetElementHandler(parser, startElement, endElement);
XML_SetCharacterDataHandler(parser, charHandle);
for (;;) {
- int done;
- int len;
- fgets(buff, BUFFSIZE, fp);
- len = (int) strlen(buff);
- if (ferror(fp)) {
- fprintf(stderr, "Read error file: %s\n", prop->sourcefile);
- exit(ERR_READERROR);
- }
- done = feof(fp);
- if (done)
- break;
- if (!XML_Parse(parser, buff, len, done)) {
- fprintf(stderr, "Parse error at line %d:\n%s\n",
- XML_GetCurrentLineNumber(parser),
- XML_ErrorString(XML_GetErrorCode(parser)));
- exit(ERR_PARSEERROR);
- }
+ int done;
+ int len;
+ fgets(buff, BUFFSIZE, fp);
+ len = (int) strlen(buff);
+ if (ferror(fp)) {
+ fprintf(stderr, "Read error file: %s\n", prop->sourcefile);
+ exit(ERR_READERROR);
+ }
+ done = feof(fp);
+ if (done)
+ break;
+ if (!XML_Parse(parser, buff, len, done)) {
+ fprintf(stderr, "Parse error at line %d:\n%s\n",
+ XML_GetCurrentLineNumber(parser),
+ XML_ErrorString(XML_GetErrorCode(parser)));
+ exit(ERR_PARSEERROR);
+ }
}
fclose(pdata->fp); //close out file
closeParsedata(pdata);
diff --git a/navit/tools/gpx2navit_txt/src/setmeta.c b/navit/tools/gpx2navit_txt/src/setmeta.c
index 86a22f70b..07bd0eab9 100644
--- a/navit/tools/gpx2navit_txt/src/setmeta.c
+++ b/navit/tools/gpx2navit_txt/src/setmeta.c
@@ -22,8 +22,7 @@
/**
* store gpx metadata into text file
*/
-void setMetadata(parsedata * pdata)
-{
+void setMetadata(parsedata * pdata) {
g2sprop *prop = pdata->prop;
g2sattr *attr = pdata->attr;
FILE *metafile;
@@ -32,41 +31,41 @@ void setMetadata(parsedata * pdata)
strcat(output, "_meta.txt");
metafile = fopen(output, "w");
if (metafile == NULL) {
- fprintf(stderr, "Cannot create file: %s\n", output);
- exit(ERR_CREATEFILE);
+ fprintf(stderr, "Cannot create file: %s\n", output);
+ exit(ERR_CREATEFILE);
}
if (attr->name) {
- fprintf(metafile, "name\t%s\n", attr->name);
+ fprintf(metafile, "name\t%s\n", attr->name);
}
if (attr->desc) {
- fprintf(metafile, "description\t%s\n", attr->desc);
+ fprintf(metafile, "description\t%s\n", attr->desc);
}
if (attr->author) {
- fprintf(metafile, "author\t%s\n", attr->author);
+ fprintf(metafile, "author\t%s\n", attr->author);
}
if (attr->copyright) {
- fprintf(metafile, "copyright\t%s\n", attr->copyright);
+ fprintf(metafile, "copyright\t%s\n", attr->copyright);
}
if (attr->link) {
- fprintf(metafile, "link\t%s\n", attr->link);
+ fprintf(metafile, "link\t%s\n", attr->link);
}
if (attr->time) {
- fprintf(metafile, "time\t%s\n", attr->time);
+ fprintf(metafile, "time\t%s\n", attr->time);
}
if (attr->keywords) {
- fprintf(metafile, "keywords\t%s\n", attr->keywords);
+ fprintf(metafile, "keywords\t%s\n", attr->keywords);
}
if (attr->minlat) {
- fprintf(metafile, "min latitude\t%f\n", attr->minlat);
+ fprintf(metafile, "min latitude\t%f\n", attr->minlat);
}
if (attr->minlon) {
- fprintf(metafile, "min longitude\t%f\n", attr->minlon);
+ fprintf(metafile, "min longitude\t%f\n", attr->minlon);
}
if (attr->maxlat) {
- fprintf(metafile, "max latitude\t%f\n", attr->maxlat);
+ fprintf(metafile, "max latitude\t%f\n", attr->maxlat);
}
if (attr->maxlon) {
- fprintf(metafile, "max longitude\t%f\n", attr->maxlon);
+ fprintf(metafile, "max longitude\t%f\n", attr->maxlon);
}
fclose(metafile);
free(output);
diff --git a/navit/tools/gpx2navit_txt/src/setpath.c b/navit/tools/gpx2navit_txt/src/setpath.c
index 3642415a8..6350f4e1f 100644
--- a/navit/tools/gpx2navit_txt/src/setpath.c
+++ b/navit/tools/gpx2navit_txt/src/setpath.c
@@ -21,7 +21,7 @@
void initPathAttr(pathattr * pattr, g2sattr * attr);
void setEdge(parsedata * pdata, double _x, double _y, double _z,
- double length, double interval, double speed);
+ double length, double interval, double speed);
void setPathInterval(parsedata * pdata);
void setPathData(pathattr * pattr, g2sattr * attr);
void countUnconverted(parsedata * pdata);
@@ -34,8 +34,7 @@ void setPath( parsedata * pdata);
/**
* initialize a path attribute
*/
-void initPathAttr(pathattr * pattr, g2sattr * attr)
-{
+void initPathAttr(pathattr * pattr, g2sattr * attr) {
strcpy(pattr->name, attr->name);
strcpy(pattr->cmt, attr->cmt);
strcpy(pattr->desc, attr->desc);
@@ -55,21 +54,20 @@ void initPathAttr(pathattr * pattr, g2sattr * attr)
* set edge data and store it
*/
void setEdge(parsedata * pdata, double _x, double _y, double _z,
- double length, double interval, double speed)
-{
+ double length, double interval, double speed) {
pathattr *pattr = pdata->pattr;
static int isFirstTrkAsEdge = 1;
static int isFirstRteAsEdge = 1;
double x[2], y[2], z[2];
double _length, _interval, _speed;
if (!strcmp(pdata->current->name, "trkpt")) {
- if (isFirstTrkAsEdge) {
- isFirstTrkAsEdge = 0;
- }
+ if (isFirstTrkAsEdge) {
+ isFirstTrkAsEdge = 0;
+ }
} else {
- if (isFirstRteAsEdge) {
- isFirstRteAsEdge = 0;
- }
+ if (isFirstRteAsEdge) {
+ isFirstRteAsEdge = 0;
+ }
}
_length = pattr->length;
_interval = pattr->interval;
@@ -94,8 +92,7 @@ void setEdge(parsedata * pdata, double _x, double _y, double _z,
/**
* sets interval data between two track points
*/
-void setPathInterval(parsedata * pdata)
-{
+void setPathInterval(parsedata * pdata) {
pathattr *pattr = pdata->pattr;
g2sattr *attr = pdata->attr;
g2sprop *prop = pdata->prop;
@@ -105,21 +102,21 @@ void setPathInterval(parsedata * pdata)
double leng = 0;
double spd;
if (pattr->count == 1) {
- strcpy(_t, attr->time);
+ strcpy(_t, attr->time);
} else {
- /* time interval */
- intvl = getTimeInterval(_t, attr->time);
- pattr->interval = pattr->interval + intvl;
- strcpy(_t, attr->time);
- /* length interval */
- leng = getDistance(_x, _y, attr->lon, attr->lat);
- pattr->length = pattr->length + leng;
- /* interval speed */
- spd = getSpeed(leng, intvl, prop->speed2meter, prop->speed2sec);
- /* sets edge data */
- if (prop->isEdge) {
- setEdge(pdata, _x, _y, _z, leng, intvl, spd);
- }
+ /* time interval */
+ intvl = getTimeInterval(_t, attr->time);
+ pattr->interval = pattr->interval + intvl;
+ strcpy(_t, attr->time);
+ /* length interval */
+ leng = getDistance(_x, _y, attr->lon, attr->lat);
+ pattr->length = pattr->length + leng;
+ /* interval speed */
+ spd = getSpeed(leng, intvl, prop->speed2meter, prop->speed2sec);
+ /* sets edge data */
+ if (prop->isEdge) {
+ setEdge(pdata, _x, _y, _z, leng, intvl, spd);
+ }
}
_x = attr->lon;
_y = attr->lat;
@@ -129,16 +126,15 @@ void setPathInterval(parsedata * pdata)
/**
* sets each track point data in array.
*/
-void setPathData(pathattr * pattr, g2sattr * attr)
-{
+void setPathData(pathattr * pattr, g2sattr * attr) {
const int reallocsize = 100;
if (pattr->count == 0) {
- pattr->point = malloc(sizeof(double) * 3 * reallocsize);
+ pattr->point = malloc(sizeof(double) * 3 * reallocsize);
}
if ((pattr->count % reallocsize) == 0) {
- pattr->point = realloc(pattr->point,
- sizeof(double) * 3 * (pattr->count +
- reallocsize));
+ pattr->point = realloc(pattr->point,
+ sizeof(double) * 3 * (pattr->count +
+ reallocsize));
}
pattr->point[pattr->count * 3] = attr->lon;
pattr->point[pattr->count * 3 + 1] = attr->lat;
@@ -149,72 +145,69 @@ void setPathData(pathattr * pattr, g2sattr * attr)
/**
* counts paths that wasn't converted
*/
-void countUnconverted(parsedata * pdata)
-{
+void countUnconverted(parsedata * pdata) {
g2sstats *stats = pdata->prop->stats;
if (!strcmp(pdata->current->name, "trkseg"))
- stats->trkunconverted++;
+ stats->trkunconverted++;
else
- stats->rteunconverted++;
+ stats->rteunconverted++;
}
/**
- * counts paths
+ * counts paths
*/
-void countPath(parsedata * pdata)
-{
+void countPath(parsedata * pdata) {
g2sstats *stats = pdata->prop->stats;
pathattr *pattr = pdata->pattr;
if (!strcmp(pdata->current->name, "trkseg")) {
- stats->trkcount++;
- stats->trklength += pattr->length;
- stats->trkpoints += pattr->count;
+ stats->trkcount++;
+ stats->trklength += pattr->length;
+ stats->trkpoints += pattr->count;
} else {
- stats->rtecount++;
- stats->rtelength += pattr->length;
- stats->rtepoints += pattr->count;
+ stats->rtecount++;
+ stats->rtelength += pattr->length;
+ stats->rtepoints += pattr->count;
}
}
-int checkPath(parsedata * pdata)
-{
+int checkPath(parsedata * pdata) {
pathattr *pattr = pdata->pattr;
g2sprop *prop = pdata->prop;
/* check point count. */
if (pattr->count < prop->minpoints) {
- fprintf
- (stderr,
- "gpx2navit_txt:%s:%i track was not converted because of less then %d points. \n",
- prop->sourcefile, XML_GetCurrentLineNumber(pdata->parser),
- prop->minpoints);
- countUnconverted(pdata);
- return 0;
- /* check path length */
+ fprintf
+ (stderr,
+ "gpx2navit_txt:%s:%i track was not converted because of less then %d points. \n",
+ prop->sourcefile, XML_GetCurrentLineNumber(pdata->parser),
+ prop->minpoints);
+ countUnconverted(pdata);
+ return 0;
+ /* check path length */
} else if (pattr->length < prop->minlength * prop->length2meter) {
- fprintf
- (stderr,
- "gpx2navit_txt:%s:%i track was not converted because it is shorter than %dm.\n",
- prop->sourcefile, XML_GetCurrentLineNumber(pdata->parser),
- prop->minlength);
- countUnconverted(pdata);
- return 0;
- /* check path time */
+ fprintf
+ (stderr,
+ "gpx2navit_txt:%s:%i track was not converted because it is shorter than %dm.\n",
+ prop->sourcefile, XML_GetCurrentLineNumber(pdata->parser),
+ prop->minlength);
+ countUnconverted(pdata);
+ return 0;
+ /* check path time */
} else if (pattr->interval < prop->mintime * prop->time2sec) {
- fprintf
- (stderr,
- "gpx2navit_txt:%s:%i track was not converted because it is shorter than %d sed.\n",
- prop->sourcefile, XML_GetCurrentLineNumber(pdata->parser),
- prop->mintime);
- countUnconverted(pdata);
- return 0;
- /* check path speed */
+ fprintf
+ (stderr,
+ "gpx2navit_txt:%s:%i track was not converted because it is shorter than %d sed.\n",
+ prop->sourcefile, XML_GetCurrentLineNumber(pdata->parser),
+ prop->mintime);
+ countUnconverted(pdata);
+ return 0;
+ /* check path speed */
} else if (!prop->nospeedcheck && pattr->speed == .0) {
- fprintf
- (stderr,
- "gpx2navit_txt:%s:%i track was not converted because no move recorded. Use --no-speed-check option to bypass this check.\n",
- prop->sourcefile, XML_GetCurrentLineNumber(pdata->parser));
- countUnconverted(pdata);
- return 0;
+ fprintf
+ (stderr,
+ "gpx2navit_txt:%s:%i track was not converted because no move recorded. Use --no-speed-check option to bypass this check.\n",
+ prop->sourcefile, XML_GetCurrentLineNumber(pdata->parser));
+ countUnconverted(pdata);
+ return 0;
}
return 1;
}
@@ -222,39 +215,38 @@ int checkPath(parsedata * pdata)
/**
* saves path data into files.
*/
-void setPath( parsedata * pdata)
-{
+void setPath( parsedata * pdata) {
pathattr *pattr = pdata->pattr;
g2sprop *prop = pdata->prop;
int isOk = 0;
pattr->speed =
- getSpeed(pattr->length, pattr->interval, prop->speed2meter,
- prop->speed2sec);
+ getSpeed(pattr->length, pattr->interval, prop->speed2meter,
+ prop->speed2sec);
if (prop->isFast) {
- isOk = 1;
+ isOk = 1;
} else {
- isOk = checkPath(pdata);
+ isOk = checkPath(pdata);
}
if (isOk) {
- double x[pattr->count];
- double y[pattr->count];
- double z[pattr->count];
- int i;
- fprintf(pdata->fp,"type=track label=\"%s\" desc=\"%s\" type=\"%s\"\ length=\"%5.3f\" count=\"%5d\"\n"
- ,pdata->pattr->name,pdata->pattr->desc,
- pdata->pattr->type,pdata->pattr->length,
- pdata->pattr->count);
-
- for (i = 0; i < pattr->count; i++) {
- x[i] = pattr->point[i * 3];
- y[i] = pattr->point[i * 3 + 1];
- z[i] = pattr->point[i * 3 + 2];
- fprintf(pdata->fp,"%3.6f %4.6f\n",x[i],y[i]);
- }
- if (pdata->prop->is3d) {
- } else {
- }
- countPath(pdata);
+ double x[pattr->count];
+ double y[pattr->count];
+ double z[pattr->count];
+ int i;
+ fprintf(pdata->fp,"type=track label=\"%s\" desc=\"%s\" type=\"%s\"\ length=\"%5.3f\" count=\"%5d\"\n"
+ ,pdata->pattr->name,pdata->pattr->desc,
+ pdata->pattr->type,pdata->pattr->length,
+ pdata->pattr->count);
+
+ for (i = 0; i < pattr->count; i++) {
+ x[i] = pattr->point[i * 3];
+ y[i] = pattr->point[i * 3 + 1];
+ z[i] = pattr->point[i * 3 + 2];
+ fprintf(pdata->fp,"%3.6f %4.6f\n",x[i],y[i]);
+ }
+ if (pdata->prop->is3d) {
+ } else {
+ }
+ countPath(pdata);
}
free(pattr->point);
}
diff --git a/navit/tools/gpx2navit_txt/src/setwpt.c b/navit/tools/gpx2navit_txt/src/setwpt.c
index 3fc04f71b..24768caa1 100644
--- a/navit/tools/gpx2navit_txt/src/setwpt.c
+++ b/navit/tools/gpx2navit_txt/src/setwpt.c
@@ -24,46 +24,45 @@ void setWpt(parsedata * pdata);
/**
* save point objects in *_wpt or *_pnt file
*/
-void setWpt( parsedata * pdata)
-{
+void setWpt( parsedata * pdata) {
double x[1], y[1], z[1];
x[0] = pdata->attr->lon;
y[0] = pdata->attr->lat;
z[0] = pdata->attr->ele;
if (pdata->prop->is3d) {
- //nothing at the moment
+ //nothing at the moment
} else {
- //do not know if i will change something here
+ //do not know if i will change something here
}
// Write attributes to file first line waypoint-info, second line coords
char poi_type[20]="poi_attraction";
if (!strcmp(pdata->attr->type,"Geocache|Traditional Cache"))
- strcpy(poi_type,"poi_gc_tradi");
+ strcpy(poi_type,"poi_gc_tradi");
if (!strcmp(pdata->attr->type,"Geocache|Multi-cache"))
- strcpy(poi_type,"poi_gc_multi");
+ strcpy(poi_type,"poi_gc_multi");
if (!strcmp(pdata->attr->type,"Geocache|Unknown Cache"))
- strcpy(poi_type,"poi_gc_mystery");
+ strcpy(poi_type,"poi_gc_mystery");
if (!strcmp(pdata->attr->type,"Geocache|Event Cache"))
- strcpy(poi_type,"poi_gc_event");
+ strcpy(poi_type,"poi_gc_event");
if (!strcmp(pdata->attr->type,"Geocache")) //for OC
- strcpy(poi_type,"poi_gc_tradi");
- if (!strcmp(pdata->attr->type,"Waypoint|Parking Area"))
- strcpy(poi_type,"poi_car_parking");
- if (!strcmp(pdata->attr->type,"Waypoint|Question to Answer"))
- strcpy(poi_type,"poi_gc_question");
- if (!strcmp(pdata->attr->type,"Waypoint|Reference Point"))
- strcpy(poi_type,"poi_gc_reference");
- if (!strcmp(pdata->attr->type,"Waypoint|Stages of a Multicache"))
- strcpy(poi_type,"poi_gc_stages");
+ strcpy(poi_type,"poi_gc_tradi");
+ if (!strcmp(pdata->attr->type,"Waypoint|Parking Area"))
+ strcpy(poi_type,"poi_car_parking");
+ if (!strcmp(pdata->attr->type,"Waypoint|Question to Answer"))
+ strcpy(poi_type,"poi_gc_question");
+ if (!strcmp(pdata->attr->type,"Waypoint|Reference Point"))
+ strcpy(poi_type,"poi_gc_reference");
+ if (!strcmp(pdata->attr->type,"Waypoint|Stages of a Multicache"))
+ strcpy(poi_type,"poi_gc_stages");
//generate the file
fprintf(pdata->fp,"type=%s label=\"%s\" description=\"%s\" gc_type=\"%s\"\n",
- poi_type,pdata->attr->name,pdata->attr->desc,pdata->attr->type);
+ poi_type,pdata->attr->name,pdata->attr->desc,pdata->attr->type);
fprintf(pdata->fp,"%3.6f %4.6f\n",x[0],y[0]);
//writeWptAttribute(hDBF, pdata, iShape);
if (!strcmp(pdata->current->name, "wpt")) {
- pdata->prop->stats->wptpoints++;
+ pdata->prop->stats->wptpoints++;
}
return;
}
diff --git a/navit/tools/gpx2navit_txt/src/utils.c b/navit/tools/gpx2navit_txt/src/utils.c
index 4a215fd9d..11fae97d1 100644
--- a/navit/tools/gpx2navit_txt/src/utils.c
+++ b/navit/tools/gpx2navit_txt/src/utils.c
@@ -32,86 +32,82 @@ double getDistance(double _x, double _y, double x, double y);
// todo void closeDbfFiles(dbfhandles * dbfs);
void *myMallocRep(size_t size, const char *fileName, int line);
-void checkEllpsUnit(char *unit)
-{
-/*
- * checks ellipse unit can be used by proj4
- */
+void checkEllpsUnit(char *unit) {
+ /*
+ * checks ellipse unit can be used by proj4
+ */
int isOK = 0;
struct PJ_ELLPS *el; /* project.h of proj4 */
for (el = pj_ellps; el->id; ++el) {
- if (!strcmp(el->id, unit)) {
- isOK = 1;
- }
+ if (!strcmp(el->id, unit)) {
+ isOK = 1;
+ }
}
if (!isOK) {
- fputs
- ("The ellipse argument is not correct or supported by libproj\n",
- stderr);
- fputs("You can choose the argument from a list below.\n\n",
- stderr);
- for (el = pj_ellps; el->id; el++) {
- printf("%10s\t%s\n", el->id, el->name);
- }
- exit(ERR_ELLPSUNIT);
+ fputs
+ ("The ellipse argument is not correct or supported by libproj\n",
+ stderr);
+ fputs("You can choose the argument from a list below.\n\n",
+ stderr);
+ for (el = pj_ellps; el->id; el++) {
+ printf("%10s\t%s\n", el->id, el->name);
+ }
+ exit(ERR_ELLPSUNIT);
}
}
-double checkLengthUnit(char *unit)
-{
-/*
- * checks length unit can be used by proj4
- * then returns unit value to meter
- */
+double checkLengthUnit(char *unit) {
+ /*
+ * checks length unit can be used by proj4
+ * then returns unit value to meter
+ */
int isOK = 0;
double to_meter = 0;
struct PJ_UNITS *ut; /* project.h of proj4 */
for (ut = pj_units; ut->id; ut++) {
- if (!strcmp(ut->id, unit)) {
- isOK = 1;
- to_meter = atof(ut->to_meter);
- }
+ if (!strcmp(ut->id, unit)) {
+ isOK = 1;
+ to_meter = atof(ut->to_meter);
+ }
}
if (!isOK) {
- fputs
- ("The length unit argument is not correct or supported by libproj.\n",
- stderr);
- fputs("You can choose the argument from a list below.\n\n",
- stderr);
- for (ut = pj_units; ut->id; ut++) {
- printf("%s\t%s\n", ut->id, ut->name);
- }
- exit(ERR_LENGTHUNIT);
+ fputs
+ ("The length unit argument is not correct or supported by libproj.\n",
+ stderr);
+ fputs("You can choose the argument from a list below.\n\n",
+ stderr);
+ for (ut = pj_units; ut->id; ut++) {
+ printf("%s\t%s\n", ut->id, ut->name);
+ }
+ exit(ERR_LENGTHUNIT);
}
return to_meter;
}
-int checkTimeUnit(char *unit)
-{
+int checkTimeUnit(char *unit) {
char *u[8] = { "sec", "s", "min", "m", "hour", "h", "day", "d" };
int p[8] = { 1, 1, 60, 60, 3600, 3600, 86400, 86400 };
int i, to_sec = 0;
for (i = 0; i < 8; i++) {
- if (!strcmp(u[i], unit)) {
- to_sec = p[i];
- }
+ if (!strcmp(u[i], unit)) {
+ to_sec = p[i];
+ }
}
if (!to_sec) {
- fputs("The time unit argument is not correct.\n", stderr);
- fputs("You can choose the argument from sec, min, hour or day.\n",
- stderr);
- exit(ERR_TIMEUNIT);
+ fputs("The time unit argument is not correct.\n", stderr);
+ fputs("You can choose the argument from sec, min, hour or day.\n",
+ stderr);
+ exit(ERR_TIMEUNIT);
}
return to_sec;
}
-double getTimeInterval(char *_t, char *t)
-{
-/*
- * Returns a time interval between _t and t.
- * The arguments should be "YYYY-MM-DDThh:mm:ssZ" (xml schema
- * datetime format without time zone) format.
- */
+double getTimeInterval(char *_t, char *t) {
+ /*
+ * Returns a time interval between _t and t.
+ * The arguments should be "YYYY-MM-DDThh:mm:ssZ" (xml schema
+ * datetime format without time zone) format.
+ */
double ti;
struct tm _tt;
struct tm tt;
@@ -119,11 +115,11 @@ double getTimeInterval(char *_t, char *t)
memset(&_tt, 0, sizeof(_tt));
memset(&tt, 0, sizeof(tt));
sscanf(_t, "%d-%d-%dT%d:%d:%dZ", &_tt.tm_year, &_tt.tm_mon,
- &_tt.tm_mday, &_tt.tm_hour, &_tt.tm_min, &_tt.tm_sec);
+ &_tt.tm_mday, &_tt.tm_hour, &_tt.tm_min, &_tt.tm_sec);
_tt.tm_year -= 1900;
_tt.tm_mon -= 1;
sscanf(t, "%d-%d-%dT%d:%d:%d", &tt.tm_year, &tt.tm_mon, &tt.tm_mday,
- &tt.tm_hour, &tt.tm_min, &tt.tm_sec);
+ &tt.tm_hour, &tt.tm_min, &tt.tm_sec);
tt.tm_year -= 1900;
tt.tm_mon -= 1;
_tmt = mktime(&_tt);
@@ -132,21 +128,19 @@ double getTimeInterval(char *_t, char *t)
return ti;
}
-double getSpeed(double length, double ti, double to_meter, int to_sec)
-{
-/*
- * Culculates speed from length and time.
- */
+double getSpeed(double length, double ti, double to_meter, int to_sec) {
+ /*
+ * Culculates speed from length and time.
+ */
double speed;
if (!length || !ti)
- speed = 0;
+ speed = 0;
else
- speed = (length / to_meter) / (ti / to_sec);
+ speed = (length / to_meter) / (ti / to_sec);
return speed;
}
-double getDistanceCore(char *p1, char *l1, char *p2, char *l2)
-{
+double getDistanceCore(char *p1, char *l1, char *p2, char *l2) {
/*
* Culculates a geodesic length between two points
* using geod_*.c
@@ -159,8 +153,7 @@ double getDistanceCore(char *p1, char *l1, char *p2, char *l2)
return geod_S;
}
-double getDistance(double _x, double _y, double x, double y)
-{
+double getDistance(double _x, double _y, double x, double y) {
/*
* Culculates a geodesic length between two points
*/
@@ -176,9 +169,9 @@ double getDistance(double _x, double _y, double x, double y)
//todo void closeShpFiles(shphandles * shps)
//{
- /*
- * Closes all SHP files if they opened
- */
+/*
+ * Closes all SHP files if they opened
+ */
// if (shps->wpt)
// SHPClose(shps->wpt);
// if (shps->trk)
@@ -197,9 +190,9 @@ double getDistance(double _x, double _y, double x, double y)
//todo void closeDbfFiles(dbfhandles * dbfs)
//{
- /*
- * Closes all DBF files if they opened
- */
+/*
+ * Closes all DBF files if they opened
+ */
// if (dbfs->wpt)
// DBFClose(dbfs->wpt);
// if (dbfs->trk)
diff --git a/navit/tools/latlon2bookmark/Makefile b/navit/tools/latlon2bookmark/Makefile
index f62cc0bc4..22d3d6257 100644
--- a/navit/tools/latlon2bookmark/Makefile
+++ b/navit/tools/latlon2bookmark/Makefile
@@ -1,5 +1,5 @@
all:
- gcc -l m -o latlon2bookmark latlon2bookmark.c
+ gcc -Wall -o latlon2bookmark latlon2bookmark.c -lm
clean:
rm -f latlon2bookmark
diff --git a/navit/tools/latlon2bookmark/latlon2bookmark.c b/navit/tools/latlon2bookmark/latlon2bookmark.c
index 9f0eff79a..359fabfba 100644
--- a/navit/tools/latlon2bookmark/latlon2bookmark.c
+++ b/navit/tools/latlon2bookmark/latlon2bookmark.c
@@ -1,140 +1,130 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2009 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/**
- * this program is free software, please use it as you like.
- * i am not a programmer, so please have this code reviewed
- * to make sure it has nog bugs or ill side efects.
- * use at your own risk
- * compile it with: gcc -l m -o latlon2bookmark latlon2bookmark.c
- * Credits for this work goes to edje in #navit
-**/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-
-int main( int argc, char **argv )
-{
- char description[256];
- char lngsign[10];
- char latsign[10];
- float lat;
- float lng;
- long intlat;
- long intlng;
- int i;
- int n;
-
- if ( argc < 4 )
- {
- printf("\n");
- printf("This program converts a lat/lon coordinates pair\n");
- printf("into a bookmark you can use with navit.\n");
- printf("This program expects 3 arguments in the following order:\n");
- printf("Lat, Lon and a description\n");
- printf("and will print a bookmark.\n");
- printf("for example: latlon2bookmark 51.980344 4.358005 this is my house \n");
- printf("\n");
- return 1;
- }
-
- lat=atof(argv[1]);
- lng=atof(argv[2]);
-
- /* concatenate all parts of the description string */
- strcpy(description, argv[3]);
- n=0;
- for (i=4; i < argc; i++)
- {
- /* add spaces between the parts of the description */
- if ( i < argc )
- {
- strcat(description, " ");
- }
- strcat(description, argv[i]);
- n=n+1;
- }
-
- if ( lat < -90 )
- {
- printf("\n");
- printf("The first argument must be the lattitude\n");
- printf("and can't be smaller then -90 (southpole)\n");
- printf("\n");
- return 2;
- }
-
- if ( lat > 90 )
- {
- printf("\n");
- printf("The first argument must be the lattitude\n");
- printf("and can't be bigger then 90 (northpole)\n");
- printf("\n");
- return 3;
- }
-
- if ( lng < -180 )
- {
- printf("\n");
- printf("The second argument must be the longitude\n");
- printf("and can't be smaller then -180 (oposite the 0 meridian)\n");
- printf("\n");
- return 4;
- }
-
- if ( lng > 180 )
- {
- printf("\n");
- printf("The first argument must be the longitude\n");
- printf("and can't be bigger then 180 (oposite the 0 meridian)\n");
- printf("\n");
- return 5;
- }
-
- /* convert the longitude to an integer */
- intlng=lng*6371000.0*M_PI/180;
-
- /* aparently if inlng < 0 , inlng needs to be inverted and a - sign used in the output */
- strcpy(lngsign, "0x");
- if ( intlng < 0)
- {
- intlng=(intlng ^ 0xffffffff);
- strcpy(lngsign, "-0x");
- }
-
- /* and the same for the latitude */
- intlat=log(tan(M_PI_4+lat*M_PI/360))*6371000.0;
-
- /* aparently if inlat < 0 , inlat needs to be inverted and a - sign used in the output */
- strcpy(latsign, "0x");
- if ( intlat < 0)
- {
- intlat=(intlat ^ 0xffffffff);
- strcpy(latsign, "-0x");
- }
-
- /* print the bookmark */
- fprintf(stderr,"\n");
- fprintf(stdout,"mg:%s%x %s%x type=bookmark label=\"%s\"\n",lngsign,intlng,latsign,intlat,description);
- fprintf(stderr,"\n");
-
- return 0;
-}
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2009 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * this program is free software, please use it as you like.
+ * i am not a programmer, so please have this code reviewed
+ * to make sure it has nog bugs or ill side efects.
+ * use at your own risk
+ * compile it with: gcc -l m -o latlon2bookmark latlon2bookmark.c
+ * Credits for this work goes to edje in #navit
+**/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+
+int main( int argc, char **argv ) {
+ char description[256];
+ char lngsign[10];
+ char latsign[10];
+ float lat;
+ float lng;
+ long intlat;
+ long intlng;
+ int i;
+ int n;
+
+ if ( argc < 4 ) {
+ printf("\n");
+ printf("This program converts a lat/lon coordinates pair\n");
+ printf("into a bookmark you can use with navit.\n");
+ printf("This program expects 3 arguments in the following order:\n");
+ printf("Lat, Lon and a description\n");
+ printf("and will print a bookmark.\n");
+ printf("for example: latlon2bookmark 51.980344 4.358005 this is my house \n");
+ printf("\n");
+ return 1;
+ }
+
+ lat=atof(argv[1]);
+ lng=atof(argv[2]);
+
+ /* concatenate all parts of the description string */
+ strcpy(description, argv[3]);
+ n=0;
+ for (i=4; i < argc; i++) {
+ /* add spaces between the parts of the description */
+ if ( i < argc ) {
+ strcat(description, " ");
+ }
+ strcat(description, argv[i]);
+ n=n+1;
+ }
+
+ if ( lat < -90 ) {
+ printf("\n");
+ printf("The first argument must be the lattitude\n");
+ printf("and can't be smaller then -90 (southpole)\n");
+ printf("\n");
+ return 2;
+ }
+
+ if ( lat > 90 ) {
+ printf("\n");
+ printf("The first argument must be the lattitude\n");
+ printf("and can't be bigger then 90 (northpole)\n");
+ printf("\n");
+ return 3;
+ }
+
+ if ( lng < -180 ) {
+ printf("\n");
+ printf("The second argument must be the longitude\n");
+ printf("and can't be smaller then -180 (oposite the 0 meridian)\n");
+ printf("\n");
+ return 4;
+ }
+
+ if ( lng > 180 ) {
+ printf("\n");
+ printf("The first argument must be the longitude\n");
+ printf("and can't be bigger then 180 (oposite the 0 meridian)\n");
+ printf("\n");
+ return 5;
+ }
+
+ /* convert the longitude to an integer */
+ intlng=lng*6371000.0*M_PI/180;
+
+ /* aparently if inlng < 0 , inlng needs to be inverted and a - sign used in the output */
+ strcpy(lngsign, "0x");
+ if ( intlng < 0) {
+ intlng=(intlng ^ 0xffffffff);
+ strcpy(lngsign, "-0x");
+ }
+
+ /* and the same for the latitude */
+ intlat=log(tan(M_PI_4+lat*M_PI/360))*6371000.0;
+
+ /* aparently if inlat < 0 , inlat needs to be inverted and a - sign used in the output */
+ strcpy(latsign, "0x");
+ if ( intlat < 0) {
+ intlat=(intlat ^ 0xffffffff);
+ strcpy(latsign, "-0x");
+ }
+
+ /* print the bookmark */
+ fprintf(stderr,"\n");
+ fprintf(stdout,"mg:%s%ld %s%ld type=bookmark label=\"%s\"\n",lngsign,intlng,latsign,intlat,description);
+ fprintf(stderr,"\n");
+
+ return 0;
+}
diff --git a/navit/track.c b/navit/track.c
index 5c16e4261..a197a1ea4 100644
--- a/navit/track.c
+++ b/navit/track.c
@@ -1,6 +1,6 @@
/**
* Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
+ * Copyright (C) 2005-2018 Navit Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -42,11 +42,10 @@
struct object_func tracking_func;
-struct tracking_line
-{
- struct street_data *street;
- struct tracking_line *next;
- int angle[0];
+struct tracking_line {
+ struct street_data *street;
+ struct tracking_line *next;
+ int angle[0];
};
@@ -57,9 +56,9 @@ struct tracking_line
* speeds. This data is used by the CDF.
*/
struct cdf_speed {
- struct cdf_speed *next;
- int speed;
- time_t time;
+ struct cdf_speed *next;
+ int speed;
+ time_t time;
};
/**
@@ -69,70 +68,68 @@ struct cdf_speed {
* cumulative displacement filter.
*/
struct cdf_data {
- int extrapolating;
- int available;
- int first_pos;
- int poscount;
- int hist_size;
- struct cdf_speed *speed_hist;
- struct pcoord *pos_hist;
- int *dir_hist;
- double last_dist;
- struct pcoord last_out;
- int last_dir;
+ int extrapolating;
+ int available;
+ int first_pos;
+ int poscount;
+ int hist_size;
+ struct cdf_speed *speed_hist;
+ struct pcoord *pos_hist;
+ int *dir_hist;
+ double last_dist;
+ struct pcoord last_out;
+ int last_dir;
};
struct tracking {
- NAVIT_OBJECT
- struct callback_list *callback_list;
- struct mapset *ms;
- struct route *rt;
- struct map *map;
- struct vehicle *vehicle;
- struct vehicleprofile *vehicleprofile;
- struct coord last_updated;
- struct tracking_line *lines;
- struct tracking_line *curr_line;
- int pos;
- struct coord curr[2], curr_in, curr_out;
- int curr_angle;
- struct coord last[2], last_in, last_out;
- struct cdf_data cdf;
- struct attr *attr;
- int valid;
- int time;
- double direction, direction_matched;
- double speed;
- int coord_geo_valid;
- struct coord_geo coord_geo;
- enum projection pro;
- int street_direction;
- int no_gps;
- int tunnel;
- int angle_pref;
- int connected_pref;
- int nostop_pref;
- int offroad_limit_pref;
- int route_pref;
- int overspeed_pref;
- int overspeed_percent_pref;
- int tunnel_extrapolation;
+ NAVIT_OBJECT
+ struct callback_list *callback_list;
+ struct mapset *ms;
+ struct route *rt;
+ struct map *map;
+ struct vehicle *vehicle;
+ struct vehicleprofile *vehicleprofile;
+ struct coord last_updated;
+ struct tracking_line *lines;
+ struct tracking_line *curr_line;
+ int pos;
+ struct coord curr[2], curr_in, curr_out;
+ int curr_angle;
+ struct coord last[2], last_in, last_out;
+ struct cdf_data cdf;
+ struct attr *attr;
+ int valid;
+ int time;
+ double direction, direction_matched;
+ double speed;
+ int coord_geo_valid;
+ struct coord_geo coord_geo;
+ enum projection pro;
+ int street_direction;
+ int no_gps;
+ int tunnel;
+ int angle_pref;
+ int connected_pref;
+ int nostop_pref;
+ int offroad_limit_pref;
+ int route_pref;
+ int overspeed_pref;
+ int overspeed_percent_pref;
+ int tunnel_extrapolation;
};
-static void
-tracking_init_cdf(struct cdf_data *cdf, int hist_size)
-{
- cdf->extrapolating = 0;
- cdf->available = 0;
- cdf->poscount = 0;
- cdf->last_dist = 0;
- cdf->hist_size = hist_size;
+static void tracking_init_cdf(struct cdf_data *cdf, int hist_size) {
+ cdf->extrapolating = 0;
+ cdf->available = 0;
+ cdf->poscount = 0;
+ cdf->last_dist = 0;
+ cdf->hist_size = hist_size;
- cdf->pos_hist = g_new0(struct pcoord, hist_size);
- cdf->dir_hist = g_new0(int, hist_size);
+ cdf->pos_hist = g_new0(struct pcoord, hist_size);
+ cdf->dir_hist = g_new0(int, hist_size);
}
// Variables for finetuning the CDF
@@ -140,502 +137,470 @@ tracking_init_cdf(struct cdf_data *cdf, int hist_size)
// Minimum average speed
#define CDF_MINAVG 1.f
// Maximum average speed
-#define CDF_MAXAVG 6.f // only ~ 20 km/h
- // We need a low value here because otherwise we would extrapolate whenever we are not accelerating
+#define CDF_MAXAVG 6.f // only ~ 20 km/h
+// We need a low value here because otherwise we would extrapolate whenever we are not accelerating
// Mininum distance (square of it..), below which we ignore gps updates
#define CDF_MINDIST 49 // 7 meters, I guess this value has to be changed for pedestrians.
#if 0
-static void
-tracking_process_cdf(struct cdf_data *cdf, struct pcoord *pin, struct pcoord *pout, int dirin, int *dirout, int cur_speed, time_t fixtime)
-{
- struct cdf_speed *speed,*sc,*sl;
- double speed_avg;
- int speed_num,i;
-
- if (cdf->hist_size == 0) {
- dbg(lvl_warning,"No CDF.\n");
- *pout = *pin;
- *dirout = dirin;
- return;
- }
-
- speed = g_new0(struct cdf_speed, 1);
- speed->speed = cur_speed;
- speed->time = fixtime;
-
- speed->next = cdf->speed_hist;
- cdf->speed_hist = speed;
-
- sc = speed;
- sl = NULL;
- speed_num = 0;
- speed_avg = 0;
- while (sc && ((fixtime - speed->time) < 4)) { // FIXME static maxtime
- speed_num++;
- speed_avg += sc->speed;
- sl = sc;
- sc = sc->next;
- }
-
- speed_avg /= (double)speed_num;
-
- if (sl) {
- sl->next = NULL;
- }
-
- while (sc) {
- sl = sc->next;
- g_free(sc);
- sc = sl;
- }
-
- if (speed_avg < CDF_MINAVG) {
- speed_avg = CDF_MINAVG;
- } else if (speed_avg > CDF_MAXAVG) {
- speed_avg = CDF_MAXAVG;
- }
-
-
- if (cur_speed >= speed_avg) {
- if (cdf->extrapolating) {
- cdf->poscount = 0;
- cdf->extrapolating = 0;
- }
-
- cdf->first_pos--;
- if (cdf->first_pos < 0) {
- cdf->first_pos = cdf->hist_size - 1;
- }
-
- if (cdf->poscount < cdf->hist_size) {
- cdf->poscount++;
- }
-
- cdf->pos_hist[cdf->first_pos] = *pin;
- cdf->dir_hist[cdf->first_pos] = dirin;
-
- *pout = *pin;
- *dirout = dirin;
- } else if (cdf->poscount > 0) {
-
- double mx,my; // Average position's x and y values
- double sx,sy; // Support vector
- double dx,dy; // Difference between average and current position
- double len; // Length of support vector
- double dist;
-
- mx = my = 0;
- sx = sy = 0;
-
- for (i = 0; i < cdf->poscount; i++) {
- mx += (double)cdf->pos_hist[((cdf->first_pos + i) % cdf->hist_size)].x / cdf->poscount;
- my += (double)cdf->pos_hist[((cdf->first_pos + i) % cdf->hist_size)].y / cdf->poscount;
-
-
- if (i != 0) {
- sx += cdf->pos_hist[((cdf->first_pos + i) % cdf->hist_size)].x - cdf->pos_hist[((cdf->first_pos + i - 1) % cdf->hist_size)].x;
- sy += cdf->pos_hist[((cdf->first_pos + i) % cdf->hist_size)].y - cdf->pos_hist[((cdf->first_pos + i - 1) % cdf->hist_size)].y;
- }
-
- }
-
- if (cdf->poscount > 1) {
- // Normalize the support vector
- len = sqrt(sx * sx + sy * sy);
- sx /= len;
- sy /= len;
-
- // Calculate the new direction
- *dirout = (int)rint(atan(sx / sy) / M_PI * 180 + 180);
- } else {
- // If we only have one position, we can't use differences of positions, but we have to use the reported
- // direction of that position
- sx = sin((double)cdf->dir_hist[cdf->first_pos] / 180 * M_PI);
- sy = cos((double)cdf->dir_hist[cdf->first_pos] / 180 * M_PI);
- *dirout = cdf->dir_hist[cdf->first_pos];
- }
-
-
- dx = pin->x - mx;
- dy = pin->y - my;
- dist = dx * sx + dy * sy;
-
- if (cdf->extrapolating && (dist < cdf->last_dist)) {
- dist = cdf->last_dist;
- }
-
- cdf->last_dist = dist;
- cdf->extrapolating = 1;
-
- pout->x = (int)rint(mx + sx * dist);
- pout->y = (int)rint(my + sy * dist);
- pout->pro = pin->pro;
-
- } else {
- // We should extrapolate, but don't have an old position available
- *pout = *pin;
- *dirout = dirin;
- }
-
- if (cdf->available) {
- int dx,dy;
-
- dx = pout->x - cdf->last_out.x;
- dy = pout->y - cdf->last_out.y;
-
- if ((dx*dx + dy*dy) < CDF_MINDIST) {
- *pout = cdf->last_out;
- *dirout = cdf->last_dir;
- }
- }
-
- cdf->last_out = *pout;
- cdf->last_dir = *dirout;
-
- cdf->available = 1;
-}
+static void tracking_process_cdf(struct cdf_data *cdf, struct pcoord *pin, struct pcoord *pout, int dirin, int *dirout,
+ int cur_speed, time_t fixtime) {
+ struct cdf_speed *speed,*sc,*sl;
+ double speed_avg;
+ int speed_num,i;
+
+ if (cdf->hist_size == 0) {
+ dbg(lvl_warning,"No CDF.");
+ *pout = *pin;
+ *dirout = dirin;
+ return;
+ }
+
+ speed = g_new0(struct cdf_speed, 1);
+ speed->speed = cur_speed;
+ speed->time = fixtime;
+
+ speed->next = cdf->speed_hist;
+ cdf->speed_hist = speed;
+
+ sc = speed;
+ sl = NULL;
+ speed_num = 0;
+ speed_avg = 0;
+ while (sc && ((fixtime - speed->time) < 4)) { // FIXME static maxtime
+ speed_num++;
+ speed_avg += sc->speed;
+ sl = sc;
+ sc = sc->next;
+ }
+
+ speed_avg /= (double)speed_num;
+
+ if (sl) {
+ sl->next = NULL;
+ }
+
+ while (sc) {
+ sl = sc->next;
+ g_free(sc);
+ sc = sl;
+ }
+
+ if (speed_avg < CDF_MINAVG) {
+ speed_avg = CDF_MINAVG;
+ } else if (speed_avg > CDF_MAXAVG) {
+ speed_avg = CDF_MAXAVG;
+ }
+
+
+ if (cur_speed >= speed_avg) {
+ if (cdf->extrapolating) {
+ cdf->poscount = 0;
+ cdf->extrapolating = 0;
+ }
+
+ cdf->first_pos--;
+ if (cdf->first_pos < 0) {
+ cdf->first_pos = cdf->hist_size - 1;
+ }
+
+ if (cdf->poscount < cdf->hist_size) {
+ cdf->poscount++;
+ }
+
+ cdf->pos_hist[cdf->first_pos] = *pin;
+ cdf->dir_hist[cdf->first_pos] = dirin;
+
+ *pout = *pin;
+ *dirout = dirin;
+ } else if (cdf->poscount > 0) {
+
+ double mx,my; // Average position's x and y values
+ double sx,sy; // Support vector
+ double dx,dy; // Difference between average and current position
+ double len; // Length of support vector
+ double dist;
+
+ mx = my = 0;
+ sx = sy = 0;
+
+ for (i = 0; i < cdf->poscount; i++) {
+ mx += (double)cdf->pos_hist[((cdf->first_pos + i) % cdf->hist_size)].x / cdf->poscount;
+ my += (double)cdf->pos_hist[((cdf->first_pos + i) % cdf->hist_size)].y / cdf->poscount;
+
+
+ if (i != 0) {
+ sx += cdf->pos_hist[((cdf->first_pos + i) % cdf->hist_size)].x - cdf->pos_hist[((cdf->first_pos + i - 1) %
+ cdf->hist_size)].x;
+ sy += cdf->pos_hist[((cdf->first_pos + i) % cdf->hist_size)].y - cdf->pos_hist[((cdf->first_pos + i - 1) %
+ cdf->hist_size)].y;
+ }
+
+ }
+
+ if (cdf->poscount > 1) {
+ // Normalize the support vector
+ len = sqrt(sx * sx + sy * sy);
+ sx /= len;
+ sy /= len;
+
+ // Calculate the new direction
+ *dirout = (int)rint(atan(sx / sy) / M_PI * 180 + 180);
+ } else {
+ // If we only have one position, we can't use differences of positions, but we have to use the reported
+ // direction of that position
+ sx = sin((double)cdf->dir_hist[cdf->first_pos] / 180 * M_PI);
+ sy = cos((double)cdf->dir_hist[cdf->first_pos] / 180 * M_PI);
+ *dirout = cdf->dir_hist[cdf->first_pos];
+ }
+
+
+ dx = pin->x - mx;
+ dy = pin->y - my;
+ dist = dx * sx + dy * sy;
+
+ if (cdf->extrapolating && (dist < cdf->last_dist)) {
+ dist = cdf->last_dist;
+ }
+
+ cdf->last_dist = dist;
+ cdf->extrapolating = 1;
+
+ pout->x = (int)rint(mx + sx * dist);
+ pout->y = (int)rint(my + sy * dist);
+ pout->pro = pin->pro;
+
+ } else {
+ // We should extrapolate, but don't have an old position available
+ *pout = *pin;
+ *dirout = dirin;
+ }
+
+ if (cdf->available) {
+ int dx,dy;
+
+ dx = pout->x - cdf->last_out.x;
+ dy = pout->y - cdf->last_out.y;
+
+ if ((dx*dx + dy*dy) < CDF_MINDIST) {
+ *pout = cdf->last_out;
+ *dirout = cdf->last_dir;
+ }
+ }
+
+ cdf->last_out = *pout;
+ cdf->last_dir = *dirout;
+
+ cdf->available = 1;
+}
#endif
-int
-tracking_get_angle(struct tracking *tr)
-{
- return tr->curr_angle;
+int tracking_get_angle(struct tracking *tr) {
+ return tr->curr_angle;
}
struct coord *
-tracking_get_pos(struct tracking *tr)
-{
- return &tr->curr_out;
+tracking_get_pos(struct tracking *tr) {
+ return &tr->curr_out;
}
-int
-tracking_get_street_direction(struct tracking *tr)
-{
- return tr->street_direction;
+int tracking_get_street_direction(struct tracking *tr) {
+ return tr->street_direction;
}
-int
-tracking_get_segment_pos(struct tracking *tr)
-{
- return tr->pos;
+int tracking_get_segment_pos(struct tracking *tr) {
+ return tr->pos;
}
struct street_data *
-tracking_get_street_data(struct tracking *tr)
-{
- if (tr->curr_line)
- return tr->curr_line->street;
- return NULL;
+tracking_get_street_data(struct tracking *tr) {
+ if (tr->curr_line)
+ return tr->curr_line->street;
+ return NULL;
}
-int
-tracking_get_attr(struct tracking *_this, enum attr_type type, struct attr *attr, struct attr_iter *attr_iter)
-{
- struct item *item;
- struct map_rect *mr;
- struct tracking_line *tl;
-
- int result=0;
- dbg(lvl_debug,"enter %s\n",attr_to_name(type));
- if (_this->attr) {
- attr_free(_this->attr);
- _this->attr=NULL;
- }
- attr->type=type;
- switch (type) {
- case attr_position_valid:
- attr->u.num=_this->valid;
- return 1;
- case attr_position_direction:
- attr->u.numd=&_this->direction;
- return 1;
- case attr_position_direction_matched:
- attr->u.numd=&_this->direction_matched;
- return 1;
- case attr_position_speed:
- attr->u.numd=&_this->speed;
- return 1;
- case attr_directed:
- attr->u.num=_this->street_direction;
- return 1;
- case attr_position_coord_geo:
- if (!_this->coord_geo_valid) {
- struct coord c;
- c.x=_this->curr_out.x;
- c.y=_this->curr_out.y;
- transform_to_geo(_this->pro, &c, &_this->coord_geo);
- _this->coord_geo_valid=1;
- }
- attr->u.coord_geo=&_this->coord_geo;
- return 1;
- case attr_current_item:
- if (! _this->curr_line || ! _this->curr_line->street)
- return 0;
- attr->u.item=&_this->curr_line->street->item;
- return 1;
- case attr_street_count:
- attr->u.num=0;
- tl=_this->lines;
- while (tl) {
- attr->u.num++;
- tl=tl->next;
- }
- return 1;
- default:
- if (! _this->curr_line || ! _this->curr_line->street)
- return 0;
- item=&_this->curr_line->street->item;
- mr=map_rect_new(item->map,NULL);
- item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- if (item_attr_get(item, type, attr)) {
- _this->attr=attr_dup(attr);
- *attr=*_this->attr;
- result=1;
- }
- map_rect_destroy(mr);
- return result;
- }
+int tracking_get_attr(struct tracking *_this, enum attr_type type, struct attr *attr, struct attr_iter *attr_iter) {
+ struct item *item;
+ struct map_rect *mr;
+ struct tracking_line *tl;
+
+ int result=0;
+ dbg(lvl_debug,"enter %s",attr_to_name(type));
+ if (_this->attr) {
+ attr_free(_this->attr);
+ _this->attr=NULL;
+ }
+ attr->type=type;
+ switch (type) {
+ case attr_position_valid:
+ attr->u.num=_this->valid;
+ return 1;
+ case attr_position_direction:
+ attr->u.numd=&_this->direction;
+ return 1;
+ case attr_position_direction_matched:
+ attr->u.numd=&_this->direction_matched;
+ return 1;
+ case attr_position_speed:
+ attr->u.numd=&_this->speed;
+ return 1;
+ case attr_directed:
+ attr->u.num=_this->street_direction;
+ return 1;
+ case attr_position_coord_geo:
+ if (!_this->coord_geo_valid) {
+ struct coord c;
+ c.x=_this->curr_out.x;
+ c.y=_this->curr_out.y;
+ transform_to_geo(_this->pro, &c, &_this->coord_geo);
+ _this->coord_geo_valid=1;
+ }
+ attr->u.coord_geo=&_this->coord_geo;
+ return 1;
+ case attr_current_item:
+ if (! _this->curr_line || ! _this->curr_line->street)
+ return 0;
+ attr->u.item=&_this->curr_line->street->item;
+ return 1;
+ case attr_street_count:
+ attr->u.num=0;
+ tl=_this->lines;
+ while (tl) {
+ attr->u.num++;
+ tl=tl->next;
+ }
+ return 1;
+ default:
+ if (! _this->curr_line || ! _this->curr_line->street)
+ return 0;
+ item=&_this->curr_line->street->item;
+ mr=map_rect_new(item->map,NULL);
+ item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
+ if (item_attr_get(item, type, attr)) {
+ _this->attr=attr_dup(attr);
+ *attr=*_this->attr;
+ result=1;
+ }
+ map_rect_destroy(mr);
+ return result;
+ }
}
struct item *
-tracking_get_current_item(struct tracking *_this)
-{
- if (! _this->curr_line || ! _this->curr_line->street)
- return NULL;
- return &_this->curr_line->street->item;
+tracking_get_current_item(struct tracking *_this) {
+ if (! _this->curr_line || ! _this->curr_line->street)
+ return NULL;
+ return &_this->curr_line->street->item;
}
-int *
-tracking_get_current_flags(struct tracking *_this)
-{
- if (! _this->curr_line || ! _this->curr_line->street)
- return NULL;
- return &_this->curr_line->street->flags;
+int *tracking_get_current_flags(struct tracking *_this) {
+ if (! _this->curr_line || ! _this->curr_line->street)
+ return NULL;
+ return &_this->curr_line->street->flags;
}
-static void
-tracking_get_angles(struct tracking_line *tl)
-{
- int i;
- struct street_data *sd=tl->street;
- for (i = 0 ; i < sd->count-1 ; i++)
- tl->angle[i]=transform_get_angle_delta(&sd->c[i], &sd->c[i+1], 0);
+static void tracking_get_angles(struct tracking_line *tl) {
+ int i;
+ struct street_data *sd=tl->street;
+ for (i = 0 ; i < sd->count-1 ; i++)
+ tl->angle[i]=transform_get_angle_delta(&sd->c[i], &sd->c[i+1], 0);
}
-static int
-street_data_within_selection(struct street_data *sd, struct map_selection *sel)
-{
- struct coord_rect r;
- struct map_selection *curr;
- int i;
-
- if (!sel)
- return 1;
- r.lu=sd->c[0];
- r.rl=sd->c[0];
- for (i = 1 ; i < sd->count ; i++) {
- if (r.lu.x > sd->c[i].x)
- r.lu.x=sd->c[i].x;
- if (r.rl.x < sd->c[i].x)
- r.rl.x=sd->c[i].x;
- if (r.rl.y > sd->c[i].y)
- r.rl.y=sd->c[i].y;
- if (r.lu.y < sd->c[i].y)
- r.lu.y=sd->c[i].y;
- }
- curr=sel;
- while (curr) {
- struct coord_rect *sr=&curr->u.c_rect;
- if (r.lu.x <= sr->rl.x && r.rl.x >= sr->lu.x &&
- r.lu.y >= sr->rl.y && r.rl.y <= sr->lu.y)
- return 1;
- curr=curr->next;
- }
- return 0;
+static int street_data_within_selection(struct street_data *sd, struct map_selection *sel) {
+ struct coord_rect r;
+ struct map_selection *curr;
+ int i;
+
+ if (!sel)
+ return 1;
+ r.lu=sd->c[0];
+ r.rl=sd->c[0];
+ for (i = 1 ; i < sd->count ; i++) {
+ if (r.lu.x > sd->c[i].x)
+ r.lu.x=sd->c[i].x;
+ if (r.rl.x < sd->c[i].x)
+ r.rl.x=sd->c[i].x;
+ if (r.rl.y > sd->c[i].y)
+ r.rl.y=sd->c[i].y;
+ if (r.lu.y < sd->c[i].y)
+ r.lu.y=sd->c[i].y;
+ }
+ curr=sel;
+ while (curr) {
+ struct coord_rect *sr=&curr->u.c_rect;
+ if (r.lu.x <= sr->rl.x && r.rl.x >= sr->lu.x &&
+ r.lu.y >= sr->rl.y && r.rl.y <= sr->lu.y)
+ return 1;
+ curr=curr->next;
+ }
+ return 0;
}
-static void
-tracking_doupdate_lines(struct tracking *tr, struct coord *pc, enum projection pro)
-{
- int max_dist=1000;
- struct map_selection *sel;
- struct mapset_handle *h;
- struct map *m;
- struct map_rect *mr;
- struct item *item;
- struct street_data *street;
- struct tracking_line *tl;
- struct coord_geo g;
- struct coord cc;
-
- dbg(lvl_debug,"enter\n");
- h=mapset_open(tr->ms);
- while ((m=mapset_next(h,2))) {
- cc.x = pc->x;
- cc.y = pc->y;
- if (map_projection(m) != pro) {
- transform_to_geo(pro, &cc, &g);
- transform_from_geo(map_projection(m), &g, &cc);
- }
- sel = route_rect(18, &cc, &cc, 0, max_dist);
- mr=map_rect_new(m, sel);
- if (!mr)
- continue;
- while ((item=map_rect_get_item(mr))) {
- if (item_get_default_flags(item->type)) {
- street=street_get_data(item);
- if (street_data_within_selection(street, sel)) {
- tl=g_malloc(sizeof(struct tracking_line)+(street->count-1)*sizeof(int));
- tl->street=street;
- tracking_get_angles(tl);
- tl->next=tr->lines;
- tr->lines=tl;
- } else
- street_data_free(street);
- }
- }
- map_selection_destroy(sel);
- map_rect_destroy(mr);
- }
- mapset_close(h);
- dbg(lvl_debug, "exit\n");
+static void tracking_doupdate_lines(struct tracking *tr, struct coord *pc, enum projection pro) {
+ int max_dist=1000;
+ struct map_selection *sel;
+ struct mapset_handle *h;
+ struct map *m;
+ struct map_rect *mr;
+ struct item *item;
+ struct street_data *street;
+ struct tracking_line *tl;
+ struct coord_geo g;
+ struct coord cc;
+
+ dbg(lvl_debug,"enter");
+ h=mapset_open(tr->ms);
+ while ((m=mapset_next(h,2))) {
+ cc.x = pc->x;
+ cc.y = pc->y;
+ if (map_projection(m) != pro) {
+ transform_to_geo(pro, &cc, &g);
+ transform_from_geo(map_projection(m), &g, &cc);
+ }
+ sel = route_rect(18, &cc, &cc, 0, max_dist);
+ mr=map_rect_new(m, sel);
+ if (!mr)
+ continue;
+ while ((item=map_rect_get_item(mr))) {
+ if (item_get_default_flags(item->type)) {
+ street=street_get_data(item);
+ if (street_data_within_selection(street, sel)) {
+ tl=g_malloc(sizeof(struct tracking_line)+(street->count-1)*sizeof(int));
+ tl->street=street;
+ tracking_get_angles(tl);
+ tl->next=tr->lines;
+ tr->lines=tl;
+ } else
+ street_data_free(street);
+ }
+ }
+ map_selection_destroy(sel);
+ map_rect_destroy(mr);
+ }
+ mapset_close(h);
+ dbg(lvl_debug, "exit");
}
-void
-tracking_flush(struct tracking *tr)
-{
- struct tracking_line *tl=tr->lines,*next;
- dbg(lvl_debug,"enter(tr=%p)\n", tr);
-
- while (tl) {
- next=tl->next;
- street_data_free(tl->street);
- g_free(tl);
- tl=next;
- }
- tr->lines=NULL;
- tr->curr_line = NULL;
+void tracking_flush(struct tracking *tr) {
+ struct tracking_line *tl=tr->lines,*next;
+ dbg(lvl_debug,"enter(tr=%p)", tr);
+
+ while (tl) {
+ next=tl->next;
+ street_data_free(tl->street);
+ g_free(tl);
+ tl=next;
+ }
+ tr->lines=NULL;
+ tr->curr_line = NULL;
}
-static int
-tracking_angle_diff(int a1, int a2, int full)
-{
- int ret=(a1-a2)%full;
- if (ret > full/2)
- ret-=full;
- if (ret < -full/2)
- ret+=full;
- return ret;
+static int tracking_angle_diff(int a1, int a2, int full) {
+ int ret=(a1-a2)%full;
+ if (ret > full/2)
+ ret-=full;
+ if (ret < -full/2)
+ ret+=full;
+ return ret;
}
-static int
-tracking_angle_abs_diff(int a1, int a2, int full)
-{
- int ret=tracking_angle_diff(a1, a2, full);
- if (ret < 0)
- ret=-ret;
- return ret;
+static int tracking_angle_abs_diff(int a1, int a2, int full) {
+ int ret=tracking_angle_diff(a1, a2, full);
+ if (ret < 0)
+ ret=-ret;
+ return ret;
}
-static int
-tracking_angle_delta(struct tracking *tr, int vehicle_angle, int street_angle, int flags)
-{
- int full=180,ret=360,fwd=0,rev=0;
- struct vehicleprofile *profile=tr->vehicleprofile;
-
- if (profile) {
- fwd=((flags & profile->flags_forward_mask) == profile->flags);
- rev=((flags & profile->flags_reverse_mask) == profile->flags);
- }
- if (fwd || rev) {
- if (!fwd || !rev) {
- full=360;
- if (rev)
- street_angle=(street_angle+180)%360;
- }
- ret=tracking_angle_abs_diff(vehicle_angle, street_angle, full);
- }
- return ret*ret;
+static int tracking_angle_delta(struct tracking *tr, int vehicle_angle, int street_angle, int flags) {
+ int full=180,ret=360,fwd=0,rev=0;
+ struct vehicleprofile *profile=tr->vehicleprofile;
+
+ if (profile) {
+ fwd=((flags & profile->flags_forward_mask) == profile->flags);
+ rev=((flags & profile->flags_reverse_mask) == profile->flags);
+ }
+ if (fwd || rev) {
+ if (!fwd || !rev) {
+ full=360;
+ if (rev)
+ street_angle=(street_angle+180)%360;
+ }
+ ret=tracking_angle_abs_diff(vehicle_angle, street_angle, full);
+ }
+ return ret*ret;
}
-static int
-tracking_is_connected(struct tracking *tr, struct coord *c1, struct coord *c2)
-{
- if (c1[0].x == c2[0].x && c1[0].y == c2[0].y)
- return 0;
- if (c1[0].x == c2[1].x && c1[0].y == c2[1].y)
- return 0;
- if (c1[1].x == c2[0].x && c1[1].y == c2[0].y)
- return 0;
- if (c1[1].x == c2[1].x && c1[1].y == c2[1].y)
- return 0;
- return tr->connected_pref;
+static int tracking_is_connected(struct tracking *tr, struct coord *c1, struct coord *c2) {
+ if (c1[0].x == c2[0].x && c1[0].y == c2[0].y)
+ return 0;
+ if (c1[0].x == c2[1].x && c1[0].y == c2[1].y)
+ return 0;
+ if (c1[1].x == c2[0].x && c1[1].y == c2[0].y)
+ return 0;
+ if (c1[1].x == c2[1].x && c1[1].y == c2[1].y)
+ return 0;
+ return tr->connected_pref;
}
-static int
-tracking_is_no_stop(struct tracking *tr, struct coord *c1, struct coord *c2)
-{
- if (c1->x == c2->x && c1->y == c2->y)
- return tr->nostop_pref;
- return 0;
+static int tracking_is_no_stop(struct tracking *tr, struct coord *c1, struct coord *c2) {
+ if (c1->x == c2->x && c1->y == c2->y)
+ return tr->nostop_pref;
+ return 0;
}
-static int
-tracking_is_on_route(struct tracking *tr, struct route *rt, struct item *item)
-{
+static int tracking_is_on_route(struct tracking *tr, struct route *rt, struct item *item) {
#ifdef USE_ROUTING
- if (! rt)
- return 0;
- if (route_contains(rt, item))
- return 0;
- return tr->route_pref;
+ if (! rt)
+ return 0;
+ if (route_contains(rt, item))
+ return 0;
+ return tr->route_pref;
#else
- return 0;
-#endif
+ return 0;
+#endif
}
-static int
-tracking_value(struct tracking *tr, struct tracking_line *t, int offset, struct coord *lpnt, int min, int flags)
-{
- int value=0;
- struct street_data *sd=t->street;
- dbg(lvl_info, "%d: (0x%x,0x%x)-(0x%x,0x%x)\n", offset, sd->c[offset].x, sd->c[offset].y, sd->c[offset+1].x, sd->c[offset+1].y);
- if (flags & 1) {
- struct coord c1, c2, cp;
- c1.x = sd->c[offset].x;
- c1.y = sd->c[offset].y;
- c2.x = sd->c[offset+1].x;
- c2.y = sd->c[offset+1].y;
- cp.x = tr->curr_in.x;
- cp.y = tr->curr_in.y;
- value+=transform_distance_line_sq(&c1, &c2, &cp, lpnt);
- }
- if (value >= min)
- return value;
- if (flags & 2)
- value += tracking_angle_delta(tr, tr->curr_angle, t->angle[offset], sd->flags)*tr->angle_pref>>4;
- if (value >= min)
- return value;
- if ((flags & 4) && tr->connected_pref)
- value += tracking_is_connected(tr, tr->last, &sd->c[offset]);
- if ((flags & 8) && tr->nostop_pref)
- value += tracking_is_no_stop(tr, lpnt, &tr->last_out);
- if (value >= min)
- return value;
- if ((flags & 16) && tr->route_pref)
- value += tracking_is_on_route(tr, tr->rt, &sd->item);
- if ((flags & 32) && tr->overspeed_percent_pref && tr->overspeed_pref ) {
- struct roadprofile *roadprofile=g_hash_table_lookup(tr->vehicleprofile->roadprofile_hash, (void *)t->street->item.type);
- if (roadprofile && tr->speed > roadprofile->speed * tr->overspeed_percent_pref/ 100)
- value += tr->overspeed_pref;
- }
- if ((flags & 64) && !!(sd->flags & AF_UNDERGROUND) != tr->no_gps)
- value+=200;
- return value;
+static int tracking_value(struct tracking *tr, struct tracking_line *t, int offset, struct coord *lpnt, int min,
+ int flags) {
+ int value=0;
+ struct street_data *sd=t->street;
+ dbg(lvl_info, "%d: (0x%x,0x%x)-(0x%x,0x%x)", offset, sd->c[offset].x, sd->c[offset].y, sd->c[offset+1].x,
+ sd->c[offset+1].y);
+ if (flags & 1) {
+ struct coord c1, c2, cp;
+ c1.x = sd->c[offset].x;
+ c1.y = sd->c[offset].y;
+ c2.x = sd->c[offset+1].x;
+ c2.y = sd->c[offset+1].y;
+ cp.x = tr->curr_in.x;
+ cp.y = tr->curr_in.y;
+ value+=transform_distance_line_sq(&c1, &c2, &cp, lpnt);
+ }
+ if (value >= min)
+ return value;
+ if (flags & 2)
+ value += tracking_angle_delta(tr, tr->curr_angle, t->angle[offset], sd->flags)*tr->angle_pref>>4;
+ if (value >= min)
+ return value;
+ if ((flags & 4) && tr->connected_pref)
+ value += tracking_is_connected(tr, tr->last, &sd->c[offset]);
+ if ((flags & 8) && tr->nostop_pref)
+ value += tracking_is_no_stop(tr, lpnt, &tr->last_out);
+ if (value >= min)
+ return value;
+ if ((flags & 16) && tr->route_pref)
+ value += tracking_is_on_route(tr, tr->rt, &sd->item);
+ if ((flags & 32) && tr->overspeed_percent_pref && tr->overspeed_pref ) {
+ struct roadprofile *roadprofile=g_hash_table_lookup(tr->vehicleprofile->roadprofile_hash, (void *)t->street->item.type);
+ if (roadprofile && tr->speed > roadprofile->speed * tr->overspeed_percent_pref/ 100)
+ value += tr->overspeed_pref;
+ }
+ if ((flags & 64) && !!(sd->flags & AF_UNDERGROUND) != tr->no_gps)
+ value+=200;
+ return value;
}
@@ -647,585 +612,547 @@ tracking_value(struct tracking *tr, struct tracking_line *t, int offset, struct
* @param vehicleprofile The vehicle profile to use
* @param pro The projection to use for transformations
*/
-void
-tracking_update(struct tracking *tr, struct vehicle *v, struct vehicleprofile *vehicleprofile, enum projection pro)
-{
- struct tracking_line *t;
- int i,value,min,time;
- struct coord lpnt;
- struct coord cin;
- struct attr valid,speed_attr,direction_attr,coord_geo,lag,time_attr,static_speed,static_distance;
- double speed, direction;
- if (v)
- tr->vehicle=v;
- if (vehicleprofile)
- tr->vehicleprofile=vehicleprofile;
-
- if (! tr->vehicle)
- return;
- if (!vehicle_get_attr(tr->vehicle, attr_position_valid, &valid, NULL))
- valid.u.num=attr_position_valid_valid;
- if (valid.u.num == attr_position_valid_invalid) {
- tr->valid=valid.u.num;
- return;
- }
- if (!vehicle_get_attr(tr->vehicle, attr_position_speed, &speed_attr, NULL) ||
- !vehicle_get_attr(tr->vehicle, attr_position_direction, &direction_attr, NULL) ||
- !vehicle_get_attr(tr->vehicle, attr_position_coord_geo, &coord_geo, NULL) ||
- !vehicle_get_attr(tr->vehicle, attr_position_time_iso8601, &time_attr, NULL)) {
- dbg(lvl_error,"failed to get position data %d %d %d %d\n",
- vehicle_get_attr(tr->vehicle, attr_position_speed, &speed_attr, NULL),
- vehicle_get_attr(tr->vehicle, attr_position_direction, &direction_attr, NULL),
- vehicle_get_attr(tr->vehicle, attr_position_coord_geo, &coord_geo, NULL),
- vehicle_get_attr(tr->vehicle, attr_position_time_iso8601, &time_attr, NULL));
- return;
- }
- if (tr->tunnel_extrapolation) {
- struct attr fix_type;
- if (!vehicle_get_attr(tr->vehicle, attr_position_fix_type, &fix_type, NULL))
- fix_type.u.num=2;
- if (fix_type.u.num) {
- tr->no_gps=0;
- tr->tunnel=0;
- } else
- tr->no_gps=1;
- }
- if (!vehicleprofile_get_attr(vehicleprofile,attr_static_speed,&static_speed,NULL) || !vehicleprofile_get_attr(vehicleprofile,attr_static_distance,&static_distance,NULL)) {
- static_speed.u.num=3;
- static_distance.u.num=10;
- dbg(lvl_debug,"Using defaults for static position detection\n");
- }
- dbg(lvl_info,"Static speed: %ld, static distance: %ld\n",static_speed.u.num, static_distance.u.num);
- time=iso8601_to_secs(time_attr.u.str);
- speed=*speed_attr.u.numd;
- direction=*direction_attr.u.numd;
- tr->valid=attr_position_valid_valid;
- transform_from_geo(pro, coord_geo.u.coord_geo, &tr->curr_in);
- if ((speed < static_speed.u.num && transform_distance(pro, &tr->last_in, &tr->curr_in) < static_distance.u.num )) {
- dbg(lvl_debug,"static speed %f coord 0x%x,0x%x vs 0x%x,0x%x\n",speed,tr->last_in.x,tr->last_in.y, tr->curr_in.x, tr->curr_in.y);
- tr->valid=attr_position_valid_static;
- tr->speed=0;
- return;
- }
- if (tr->tunnel) {
- tr->curr_in=tr->curr_out;
- dbg(lvl_debug,"tunnel extrapolation speed %f dir %f\n",tr->speed,tr->direction);
- dbg(lvl_debug,"old 0x%x,0x%x\n",tr->curr_in.x, tr->curr_in.y);
- speed=tr->speed;
- direction=tr->curr_line->angle[tr->pos];
- transform_project(pro, &tr->curr_in, tr->speed*tr->tunnel_extrapolation/36, tr->direction, &tr->curr_in);
- dbg(lvl_debug,"new 0x%x,0x%x\n",tr->curr_in.x, tr->curr_in.y);
- } else if (vehicle_get_attr(tr->vehicle, attr_lag, &lag, NULL) && lag.u.num > 0) {
- double espeed;
- int edirection;
- if (time-tr->time == 1) {
- dbg(lvl_debug,"extrapolating speed from %f and %f (%f)\n",tr->speed, speed, speed-tr->speed);
- espeed=speed+(speed-tr->speed)*lag.u.num/10;
- dbg(lvl_debug,"extrapolating angle from %f and %f (%d)\n",tr->direction, direction, tracking_angle_diff(direction,tr->direction,360));
- edirection=direction+tracking_angle_diff(direction,tr->direction,360)*lag.u.num/10;
- } else {
- dbg(lvl_debug,"no speed and direction extrapolation\n");
- espeed=speed;
- edirection=direction;
- }
- dbg(lvl_debug,"lag %ld speed %f direction %d\n",lag.u.num,espeed,edirection);
- dbg(lvl_debug,"old 0x%x,0x%x\n",tr->curr_in.x, tr->curr_in.y);
- transform_project(pro, &tr->curr_in, espeed*lag.u.num/36, edirection, &tr->curr_in);
- dbg(lvl_debug,"new 0x%x,0x%x\n",tr->curr_in.x, tr->curr_in.y);
- }
- tr->time=time;
- tr->pro=pro;
-#if 0
-
- tracking_process_cdf(&tr->cdf, pc, &pcf, angle, &anglef, speed, fixtime);
-#endif
- tr->curr_angle=tr->direction=direction;
- tr->speed=speed;
- tr->last_in=tr->curr_in;
- tr->last_out=tr->curr_out;
- tr->last[0]=tr->curr[0];
- tr->last[1]=tr->curr[1];
- if (!tr->lines || transform_distance(pro, &tr->last_updated, &tr->curr_in) > 500) {
- dbg(lvl_debug, "update\n");
- tracking_flush(tr);
- tracking_doupdate_lines(tr, &tr->curr_in, pro);
- tr->last_updated=tr->curr_in;
- dbg(lvl_debug,"update end\n");
- }
-
- tr->street_direction=0;
- t=tr->lines;
- tr->curr_line=NULL;
- min=INT_MAX/2;
- while (t) {
- struct street_data *sd=t->street;
- for (i = 0; i < sd->count-1 ; i++) {
- value=tracking_value(tr,t,i,&lpnt,min,-1);
- if (value < min) {
- struct coord lpnt_tmp;
- int angle_delta=tracking_angle_abs_diff(tr->curr_angle, t->angle[i], 360);
- tr->curr_line=t;
- tr->pos=i;
- tr->curr[0]=sd->c[i];
- tr->curr[1]=sd->c[i+1];
- tr->direction_matched=t->angle[i];
- dbg(lvl_debug,"lpnt.x=0x%x,lpnt.y=0x%x pos=%d %d+%d+%d+%d=%d\n", lpnt.x, lpnt.y, i,
- transform_distance_line_sq(&sd->c[i], &sd->c[i+1], &cin, &lpnt_tmp),
- tracking_angle_delta(tr, tr->curr_angle, t->angle[i], 0)*tr->angle_pref,
- tracking_is_connected(tr, tr->last, &sd->c[i]) ? tr->connected_pref : 0,
- lpnt.x == tr->last_out.x && lpnt.y == tr->last_out.y ? tr->nostop_pref : 0,
- value
- );
- tr->curr_out.x=lpnt.x;
- tr->curr_out.y=lpnt.y;
- tr->coord_geo_valid=0;
- if (angle_delta < 70)
- tr->street_direction=1;
- else if (angle_delta > 110)
- tr->street_direction=-1;
- else
- tr->street_direction=0;
- min=value;
- }
- }
- t=t->next;
- }
- dbg(lvl_debug,"tr->curr_line=%p min=%d\n", tr->curr_line, min);
- if (!tr->curr_line || min > tr->offroad_limit_pref) {
- tr->curr_out=tr->curr_in;
- tr->coord_geo_valid=0;
- tr->street_direction=0;
- }
- if (tr->curr_line && (tr->curr_line->street->flags & AF_UNDERGROUND)) {
- if (tr->no_gps)
- tr->tunnel=1;
- } else if (tr->tunnel) {
- tr->speed=0;
- }
- dbg(lvl_debug,"found 0x%x,0x%x\n", tr->curr_out.x, tr->curr_out.y);
- callback_list_call_attr_0(tr->callback_list, attr_position_coord_geo);
+void tracking_update(struct tracking *tr, struct vehicle *v, struct vehicleprofile *vehicleprofile,
+ enum projection pro) {
+ struct tracking_line *t;
+ int i,value,min,time;
+ struct coord lpnt;
+ struct coord cin;
+ struct attr valid,speed_attr,direction_attr,coord_geo,lag,time_attr,static_speed,static_distance;
+ double speed, direction;
+ if (v)
+ tr->vehicle=v;
+ if (vehicleprofile)
+ tr->vehicleprofile=vehicleprofile;
+
+ if (! tr->vehicle)
+ return;
+ if (!vehicle_get_attr(tr->vehicle, attr_position_valid, &valid, NULL))
+ valid.u.num=attr_position_valid_valid;
+ if (valid.u.num == attr_position_valid_invalid) {
+ tr->valid=valid.u.num;
+ return;
+ }
+ if (!vehicle_get_attr(tr->vehicle, attr_position_speed, &speed_attr, NULL) ||
+ !vehicle_get_attr(tr->vehicle, attr_position_direction, &direction_attr, NULL) ||
+ !vehicle_get_attr(tr->vehicle, attr_position_coord_geo, &coord_geo, NULL)) {
+ dbg(lvl_error,"failed to get position data %d %d %d",
+ vehicle_get_attr(tr->vehicle, attr_position_speed, &speed_attr, NULL),
+ vehicle_get_attr(tr->vehicle, attr_position_direction, &direction_attr, NULL),
+ vehicle_get_attr(tr->vehicle, attr_position_coord_geo, &coord_geo, NULL));
+ return;
+ }
+ if (tr->tunnel_extrapolation) {
+ struct attr fix_type;
+ if (!vehicle_get_attr(tr->vehicle, attr_position_fix_type, &fix_type, NULL))
+ fix_type.u.num=2;
+ if (fix_type.u.num) {
+ tr->no_gps=0;
+ tr->tunnel=0;
+ } else
+ tr->no_gps=1;
+ }
+ if (!vehicleprofile_get_attr(vehicleprofile,attr_static_speed,&static_speed,NULL)
+ || !vehicleprofile_get_attr(vehicleprofile,attr_static_distance,&static_distance,NULL)) {
+ static_speed.u.num=3;
+ static_distance.u.num=10;
+ dbg(lvl_debug,"Using defaults for static position detection");
+ }
+ dbg(lvl_info,"Static speed: %ld, static distance: %ld",static_speed.u.num, static_distance.u.num);
+ speed=*speed_attr.u.numd;
+ direction=*direction_attr.u.numd;
+ tr->valid=attr_position_valid_valid;
+ transform_from_geo(pro, coord_geo.u.coord_geo, &tr->curr_in);
+ if ((speed < static_speed.u.num && transform_distance(pro, &tr->last_in, &tr->curr_in) < static_distance.u.num )) {
+ dbg(lvl_debug,"static speed %f coord 0x%x,0x%x vs 0x%x,0x%x",speed,tr->last_in.x,tr->last_in.y, tr->curr_in.x,
+ tr->curr_in.y);
+ tr->valid=attr_position_valid_static;
+ tr->speed=0;
+ return;
+ }
+ if (tr->tunnel) {
+ tr->curr_in=tr->curr_out;
+ dbg(lvl_debug,"tunnel extrapolation speed %f dir %f",tr->speed,tr->direction);
+ dbg(lvl_debug,"old 0x%x,0x%x",tr->curr_in.x, tr->curr_in.y);
+ speed=tr->speed;
+ direction=tr->curr_line->angle[tr->pos];
+ transform_project(pro, &tr->curr_in, tr->speed*tr->tunnel_extrapolation/36, tr->direction, &tr->curr_in);
+ dbg(lvl_debug,"new 0x%x,0x%x",tr->curr_in.x, tr->curr_in.y);
+ } else if (vehicle_get_attr(tr->vehicle, attr_lag, &lag, NULL) && lag.u.num > 0) {
+ double espeed;
+ time=iso8601_to_secs(time_attr.u.str);
+ int edirection;
+ if (time-tr->time == 1) {
+ dbg(lvl_debug,"extrapolating speed from %f and %f (%f)",tr->speed, speed, speed-tr->speed);
+ espeed=speed+(speed-tr->speed)*lag.u.num/10;
+ dbg(lvl_debug,"extrapolating angle from %f and %f (%d)",tr->direction, direction, tracking_angle_diff(direction,
+ tr->direction,360));
+ edirection=direction+tracking_angle_diff(direction,tr->direction,360)*lag.u.num/10;
+ } else {
+ dbg(lvl_debug,"no speed and direction extrapolation");
+ espeed=speed;
+ edirection=direction;
+ }
+ dbg(lvl_debug,"lag %ld speed %f direction %d",lag.u.num,espeed,edirection);
+ dbg(lvl_debug,"old 0x%x,0x%x",tr->curr_in.x, tr->curr_in.y);
+ transform_project(pro, &tr->curr_in, espeed*lag.u.num/36, edirection, &tr->curr_in);
+ tr->time=time;
+ dbg(lvl_debug,"new 0x%x,0x%x",tr->curr_in.x, tr->curr_in.y);
+ }
+ tr->pro=pro;
+ tr->curr_angle=tr->direction=direction;
+ tr->speed=speed;
+ tr->last_in=tr->curr_in;
+ tr->last_out=tr->curr_out;
+ tr->last[0]=tr->curr[0];
+ tr->last[1]=tr->curr[1];
+ if (!tr->lines || transform_distance(pro, &tr->last_updated, &tr->curr_in) > 500) {
+ dbg(lvl_debug, "update");
+ tracking_flush(tr);
+ tracking_doupdate_lines(tr, &tr->curr_in, pro);
+ tr->last_updated=tr->curr_in;
+ dbg(lvl_debug,"update end");
+ }
+
+ tr->street_direction=0;
+ t=tr->lines;
+ tr->curr_line=NULL;
+ min=INT_MAX/2;
+ while (t) {
+ struct street_data *sd=t->street;
+ for (i = 0; i < sd->count-1 ; i++) {
+ value=tracking_value(tr,t,i,&lpnt,min,-1);
+ if (value < min) {
+ struct coord lpnt_tmp;
+ int angle_delta=tracking_angle_abs_diff(tr->curr_angle, t->angle[i], 360);
+ tr->curr_line=t;
+ tr->pos=i;
+ tr->curr[0]=sd->c[i];
+ tr->curr[1]=sd->c[i+1];
+ tr->direction_matched=t->angle[i];
+ dbg(lvl_debug,"lpnt.x=0x%x,lpnt.y=0x%x pos=%d %d+%d+%d+%d=%d", lpnt.x, lpnt.y, i,
+ transform_distance_line_sq(&sd->c[i], &sd->c[i+1], &cin, &lpnt_tmp),
+ tracking_angle_delta(tr, tr->curr_angle, t->angle[i], 0)*tr->angle_pref,
+ tracking_is_connected(tr, tr->last, &sd->c[i]) ? tr->connected_pref : 0,
+ lpnt.x == tr->last_out.x && lpnt.y == tr->last_out.y ? tr->nostop_pref : 0,
+ value
+ );
+ tr->curr_out.x=lpnt.x;
+ tr->curr_out.y=lpnt.y;
+ tr->coord_geo_valid=0;
+ if (angle_delta < 70)
+ tr->street_direction=1;
+ else if (angle_delta > 110)
+ tr->street_direction=-1;
+ else
+ tr->street_direction=0;
+ min=value;
+ }
+ }
+ t=t->next;
+ }
+ dbg(lvl_debug,"tr->curr_line=%p min=%d", tr->curr_line, min);
+ if (!tr->curr_line || min > tr->offroad_limit_pref) {
+ tr->curr_out=tr->curr_in;
+ tr->coord_geo_valid=0;
+ tr->street_direction=0;
+ }
+ if (tr->curr_line && (tr->curr_line->street->flags & AF_UNDERGROUND)) {
+ if (tr->no_gps)
+ tr->tunnel=1;
+ } else if (tr->tunnel) {
+ tr->speed=0;
+ }
+ dbg(lvl_debug,"found 0x%x,0x%x", tr->curr_out.x, tr->curr_out.y);
+ callback_list_call_attr_0(tr->callback_list, attr_position_coord_geo);
}
-static int
-tracking_set_attr_do(struct tracking *tr, struct attr *attr, int initial)
-{
- switch (attr->type) {
- case attr_angle_pref:
- tr->angle_pref=attr->u.num;
- return 1;
- case attr_connected_pref:
- tr->connected_pref=attr->u.num;
- return 1;
- case attr_nostop_pref:
- tr->nostop_pref=attr->u.num;
- return 1;
- case attr_offroad_limit_pref:
- tr->offroad_limit_pref=attr->u.num;
- return 1;
- case attr_route_pref:
- tr->route_pref=attr->u.num;
- return 1;
- case attr_overspeed_pref:
- tr->overspeed_pref=attr->u.num;
- return 1;
- case attr_overspeed_percent_pref:
- tr->overspeed_percent_pref=attr->u.num;
- return 1;
- case attr_tunnel_extrapolation:
- tr->tunnel_extrapolation=attr->u.num;
- return 1;
- default:
- return 0;
- }
+static int tracking_set_attr_do(struct tracking *tr, struct attr *attr, int initial) {
+ switch (attr->type) {
+ case attr_angle_pref:
+ tr->angle_pref=attr->u.num;
+ return 1;
+ case attr_connected_pref:
+ tr->connected_pref=attr->u.num;
+ return 1;
+ case attr_nostop_pref:
+ tr->nostop_pref=attr->u.num;
+ return 1;
+ case attr_offroad_limit_pref:
+ tr->offroad_limit_pref=attr->u.num;
+ return 1;
+ case attr_route_pref:
+ tr->route_pref=attr->u.num;
+ return 1;
+ case attr_overspeed_pref:
+ tr->overspeed_pref=attr->u.num;
+ return 1;
+ case attr_overspeed_percent_pref:
+ tr->overspeed_percent_pref=attr->u.num;
+ return 1;
+ case attr_tunnel_extrapolation:
+ tr->tunnel_extrapolation=attr->u.num;
+ return 1;
+ default:
+ return 0;
+ }
}
-int
-tracking_set_attr(struct tracking *tr, struct attr *attr)
-{
- return tracking_set_attr_do(tr, attr, 0);
+int tracking_set_attr(struct tracking *tr, struct attr *attr) {
+ return tracking_set_attr_do(tr, attr, 0);
}
-int
-tracking_add_attr(struct tracking *this_, struct attr *attr)
-{
- switch (attr->type) {
- case attr_callback:
- callback_list_add(this_->callback_list, attr->u.callback);
- return 1;
- default:
- return 0;
- }
+int tracking_add_attr(struct tracking *this_, struct attr *attr) {
+ switch (attr->type) {
+ case attr_callback:
+ callback_list_add(this_->callback_list, attr->u.callback);
+ return 1;
+ default:
+ return 0;
+ }
}
-int
-tracking_remove_attr(struct tracking *this_, struct attr *attr)
-{
- switch (attr->type) {
- case attr_callback:
- callback_list_remove(this_->callback_list, attr->u.callback);
- return 1;
- default:
- return 0;
- }
+int tracking_remove_attr(struct tracking *this_, struct attr *attr) {
+ switch (attr->type) {
+ case attr_callback:
+ callback_list_remove(this_->callback_list, attr->u.callback);
+ return 1;
+ default:
+ return 0;
+ }
}
struct object_func tracking_func = {
- attr_trackingo,
- (object_func_new)tracking_new,
- (object_func_get_attr)tracking_get_attr,
- (object_func_iter_new)NULL,
- (object_func_iter_destroy)NULL,
- (object_func_set_attr)tracking_set_attr,
- (object_func_add_attr)tracking_add_attr,
- (object_func_remove_attr)tracking_remove_attr,
- (object_func_init)tracking_init,
- (object_func_destroy)tracking_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_trackingo,
+ (object_func_new)tracking_new,
+ (object_func_get_attr)tracking_get_attr,
+ (object_func_iter_new)NULL,
+ (object_func_iter_destroy)NULL,
+ (object_func_set_attr)tracking_set_attr,
+ (object_func_add_attr)tracking_add_attr,
+ (object_func_remove_attr)tracking_remove_attr,
+ (object_func_init)tracking_init,
+ (object_func_destroy)tracking_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
struct tracking *
-tracking_new(struct attr *parent, struct attr **attrs)
-{
- struct tracking *this=g_new0(struct tracking, 1);
- struct attr hist_size;
- this->func=&tracking_func;
- navit_object_ref((struct navit_object *)this);
- this->angle_pref=10;
- this->connected_pref=10;
- this->nostop_pref=10;
- this->offroad_limit_pref=5000;
- this->route_pref=300;
- this->callback_list=callback_list_new();
-
-
- if (! attr_generic_get_attr(attrs, NULL, attr_cdf_histsize, &hist_size, NULL)) {
- hist_size.u.num = 0;
- }
- if (attrs) {
- for (;*attrs; attrs++)
- tracking_set_attr_do(this, *attrs, 1);
- }
-
- tracking_init_cdf(&this->cdf, hist_size.u.num);
-
- return this;
+tracking_new(struct attr *parent, struct attr **attrs) {
+ struct tracking *this=g_new0(struct tracking, 1);
+ struct attr hist_size;
+ this->func=&tracking_func;
+ navit_object_ref((struct navit_object *)this);
+ this->angle_pref=10;
+ this->connected_pref=10;
+ this->nostop_pref=10;
+ this->offroad_limit_pref=5000;
+ this->route_pref=300;
+ this->callback_list=callback_list_new();
+
+
+ if (! attr_generic_get_attr(attrs, NULL, attr_cdf_histsize, &hist_size, NULL)) {
+ hist_size.u.num = 0;
+ }
+ if (attrs) {
+ for (; *attrs; attrs++)
+ tracking_set_attr_do(this, *attrs, 1);
+ }
+
+ tracking_init_cdf(&this->cdf, hist_size.u.num);
+
+ return this;
}
-void
-tracking_set_mapset(struct tracking *this, struct mapset *ms)
-{
- this->ms=ms;
+void tracking_set_mapset(struct tracking *this, struct mapset *ms) {
+ this->ms=ms;
}
-void
-tracking_set_route(struct tracking *this, struct route *rt)
-{
- this->rt=rt;
+void tracking_set_route(struct tracking *this, struct route *rt) {
+ this->rt=rt;
}
-void
-tracking_destroy(struct tracking *tr)
-{
- if (tr->attr)
- attr_free(tr->attr);
- tracking_flush(tr);
- callback_list_destroy(tr->callback_list);
- g_free(tr);
+void tracking_destroy(struct tracking *tr) {
+ if (tr->attr)
+ attr_free(tr->attr);
+ tracking_flush(tr);
+ callback_list_destroy(tr->callback_list);
+ g_free(tr);
}
struct map *
-tracking_get_map(struct tracking *this_)
-{
- struct attr *attrs[5];
- struct attr type,navigation,data,description;
- type.type=attr_type;
- type.u.str="tracking";
- navigation.type=attr_trackingo;
- navigation.u.tracking=this_;
- data.type=attr_data;
- data.u.str="";
- description.type=attr_description;
- description.u.str="Tracking";
-
- attrs[0]=&type;
- attrs[1]=&navigation;
- attrs[2]=&data;
- attrs[3]=&description;
- attrs[4]=NULL;
- if (! this_->map)
- this_->map=map_new(NULL, attrs);
- return this_->map;
+tracking_get_map(struct tracking *this_) {
+ struct attr *attrs[5];
+ struct attr type,navigation,data,description;
+ type.type=attr_type;
+ type.u.str="tracking";
+ navigation.type=attr_trackingo;
+ navigation.u.tracking=this_;
+ data.type=attr_data;
+ data.u.str="";
+ description.type=attr_description;
+ description.u.str="Tracking";
+
+ attrs[0]=&type;
+ attrs[1]=&navigation;
+ attrs[2]=&data;
+ attrs[3]=&description;
+ attrs[4]=NULL;
+ if (! this_->map)
+ this_->map=map_new(NULL, attrs);
+ return this_->map;
}
struct map_priv {
- struct tracking *tracking;
+ struct tracking *tracking;
};
struct map_rect_priv {
- struct tracking *tracking;
- struct item item;
- struct tracking_line *curr,*next;
- int coord;
- enum attr_type attr_next;
- int ccount;
- int debug_idx;
- char *str;
+ struct tracking *tracking;
+ struct item item;
+ struct tracking_line *curr,*next;
+ int coord;
+ enum attr_type attr_next;
+ int ccount;
+ int debug_idx;
+ char *str;
};
-static void
-tracking_map_item_coord_rewind(void *priv_data)
-{
- struct map_rect_priv *this=priv_data;
- this->ccount=0;
+static void tracking_map_item_coord_rewind(void *priv_data) {
+ struct map_rect_priv *this=priv_data;
+ this->ccount=0;
}
-static int
-tracking_map_item_coord_get(void *priv_data, struct coord *c, int count)
-{
- struct map_rect_priv *this=priv_data;
- enum projection pro;
- int ret=0;
- dbg(lvl_debug,"enter\n");
- while (this->ccount < 2 && count > 0) {
- pro = map_projection(this->curr->street->item.map);
- if (projection_mg != pro) {
- transform_from_to(&this->curr->street->c[this->ccount+this->coord],
- pro,
- c ,projection_mg);
- } else
- *c=this->curr->street->c[this->ccount+this->coord];
- dbg(lvl_debug,"coord %d 0x%x,0x%x\n",this->ccount,c->x,c->y);
- this->ccount++;
- ret++;
- c++;
- count--;
- }
- return ret;
+static int tracking_map_item_coord_get(void *priv_data, struct coord *c, int count) {
+ struct map_rect_priv *this=priv_data;
+ enum projection pro;
+ int ret=0;
+ dbg(lvl_debug,"enter");
+ while (this->ccount < 2 && count > 0) {
+ pro = map_projection(this->curr->street->item.map);
+ if (projection_mg != pro) {
+ transform_from_to(&this->curr->street->c[this->ccount+this->coord],
+ pro,
+ c,projection_mg);
+ } else
+ *c=this->curr->street->c[this->ccount+this->coord];
+ dbg(lvl_debug,"coord %d 0x%x,0x%x",this->ccount,c->x,c->y);
+ this->ccount++;
+ ret++;
+ c++;
+ count--;
+ }
+ return ret;
}
-static void
-tracking_map_item_attr_rewind(void *priv_data)
-{
- struct map_rect_priv *this_=priv_data;
- this_->debug_idx=0;
- this_->attr_next=attr_debug;
+static void tracking_map_item_attr_rewind(void *priv_data) {
+ struct map_rect_priv *this_=priv_data;
+ this_->debug_idx=0;
+ this_->attr_next=attr_debug;
}
-static int
-tracking_map_item_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
-{
- struct map_rect_priv *this_=priv_data;
- struct coord lpnt,*c;
- struct tracking *tr=this_->tracking;
- int value;
- attr->type=attr_type;
-
- if (this_->str) {
- g_free(this_->str);
- this_->str=NULL;
- }
-
- switch(attr_type) {
- case attr_debug:
- switch(this_->debug_idx) {
- case 0:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("overall: %d (limit %d)",tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, -1), tr->offroad_limit_pref);
- return 1;
- case 1:
- this_->debug_idx++;
- c=&this_->curr->street->c[this_->coord];
- value=tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, 1);
- this_->str=attr->u.str=g_strdup_printf("distance: (0x%x,0x%x) from (0x%x,0x%x)-(0x%x,0x%x) at (0x%x,0x%x) %d",
- tr->curr_in.x, tr->curr_in.y,
- c[0].x, c[0].y, c[1].x, c[1].y,
- lpnt.x, lpnt.y, value);
- return 1;
- case 2:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("angle: %d to %d (flags %d) %d",
- tr->curr_angle, this_->curr->angle[this_->coord], this_->curr->street->flags & 3,
- tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, 2));
- return 1;
- case 3:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("connected: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, 4));
- return 1;
- case 4:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("no_stop: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, 8));
- return 1;
- case 5:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("route: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, 16));
- return 1;
- case 6:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("overspeed: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, 32));
- return 1;
- case 7:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("tunnel: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, 64));
- return 1;
- case 8:
- this_->debug_idx++;
- this_->str=attr->u.str=g_strdup_printf("line %p", this_->curr);
- return 1;
- default:
- this_->attr_next=attr_none;
- return 0;
- }
- case attr_any:
- while (this_->attr_next != attr_none) {
- if (tracking_map_item_attr_get(priv_data, this_->attr_next, attr))
- return 1;
- }
- return 0;
- default:
- attr->type=attr_none;
- return 0;
- }
+static int tracking_map_item_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct map_rect_priv *this_=priv_data;
+ struct coord lpnt,*c;
+ struct tracking *tr=this_->tracking;
+ int value;
+ attr->type=attr_type;
+
+ if (this_->str) {
+ g_free(this_->str);
+ this_->str=NULL;
+ }
+
+ switch(attr_type) {
+ case attr_debug:
+ switch(this_->debug_idx) {
+ case 0:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("overall: %d (limit %d)",tracking_value(tr, this_->curr, this_->coord, &lpnt,
+ INT_MAX/2, -1), tr->offroad_limit_pref);
+ return 1;
+ case 1:
+ this_->debug_idx++;
+ c=&this_->curr->street->c[this_->coord];
+ value=tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, 1);
+ this_->str=attr->u.str=g_strdup_printf("distance: (0x%x,0x%x) from (0x%x,0x%x)-(0x%x,0x%x) at (0x%x,0x%x) %d",
+ tr->curr_in.x, tr->curr_in.y,
+ c[0].x, c[0].y, c[1].x, c[1].y,
+ lpnt.x, lpnt.y, value);
+ return 1;
+ case 2:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("angle: %d to %d (flags %d) %d",
+ tr->curr_angle, this_->curr->angle[this_->coord], this_->curr->street->flags & 3,
+ tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2, 2));
+ return 1;
+ case 3:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("connected: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2,
+ 4));
+ return 1;
+ case 4:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("no_stop: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2,
+ 8));
+ return 1;
+ case 5:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("route: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2,
+ 16));
+ return 1;
+ case 6:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("overspeed: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2,
+ 32));
+ return 1;
+ case 7:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("tunnel: %d", tracking_value(tr, this_->curr, this_->coord, &lpnt, INT_MAX/2,
+ 64));
+ return 1;
+ case 8:
+ this_->debug_idx++;
+ this_->str=attr->u.str=g_strdup_printf("line %p", this_->curr);
+ return 1;
+ default:
+ this_->attr_next=attr_none;
+ return 0;
+ }
+ case attr_any:
+ while (this_->attr_next != attr_none) {
+ if (tracking_map_item_attr_get(priv_data, this_->attr_next, attr))
+ return 1;
+ }
+ return 0;
+ default:
+ attr->type=attr_none;
+ return 0;
+ }
}
static struct item_methods tracking_map_item_methods = {
- tracking_map_item_coord_rewind,
- tracking_map_item_coord_get,
- tracking_map_item_attr_rewind,
- tracking_map_item_attr_get,
+ tracking_map_item_coord_rewind,
+ tracking_map_item_coord_get,
+ tracking_map_item_attr_rewind,
+ tracking_map_item_attr_get,
};
-static void
-tracking_map_destroy(struct map_priv *priv)
-{
- g_free(priv);
+static void tracking_map_destroy(struct map_priv *priv) {
+ g_free(priv);
}
-static void
-tracking_map_rect_init(struct map_rect_priv *priv)
-{
- priv->next=priv->tracking->lines;
- priv->curr=NULL;
- priv->coord=0;
- priv->item.id_lo=0;
- priv->item.id_hi=0;
+static void tracking_map_rect_init(struct map_rect_priv *priv) {
+ priv->next=priv->tracking->lines;
+ priv->curr=NULL;
+ priv->coord=0;
+ priv->item.id_lo=0;
+ priv->item.id_hi=0;
}
-static struct map_rect_priv *
-tracking_map_rect_new(struct map_priv *priv, struct map_selection *sel)
-{
- struct tracking *tracking=priv->tracking;
- struct map_rect_priv *ret=g_new0(struct map_rect_priv, 1);
- ret->tracking=tracking;
- tracking_map_rect_init(ret);
- ret->item.meth=&tracking_map_item_methods;
- ret->item.priv_data=ret;
- ret->item.type=type_tracking_100;
- return ret;
+static struct map_rect_priv *tracking_map_rect_new(struct map_priv *priv, struct map_selection *sel) {
+ struct tracking *tracking=priv->tracking;
+ struct map_rect_priv *ret=g_new0(struct map_rect_priv, 1);
+ ret->tracking=tracking;
+ tracking_map_rect_init(ret);
+ ret->item.meth=&tracking_map_item_methods;
+ ret->item.priv_data=ret;
+ ret->item.type=type_tracking_100;
+ return ret;
}
-static void
-tracking_map_rect_destroy(struct map_rect_priv *priv)
-{
- g_free(priv);
+static void tracking_map_rect_destroy(struct map_rect_priv *priv) {
+ g_free(priv);
}
-static struct item *
-tracking_map_get_item(struct map_rect_priv *priv)
-{
- struct item *ret=&priv->item;
- int value;
- struct coord lpnt;
-
- if (!priv->next)
- return NULL;
- if (! priv->curr || priv->coord + 2 >= priv->curr->street->count) {
- priv->curr=priv->next;
- priv->next=priv->curr->next;
- priv->coord=0;
- priv->item.id_lo=0;
- priv->item.id_hi++;
- } else {
- priv->coord++;
- priv->item.id_lo++;
- }
- value=tracking_value(priv->tracking, priv->curr, priv->coord, &lpnt, INT_MAX/2, -1);
- if (value < 64)
- priv->item.type=type_tracking_100;
- else if (value < 128)
- priv->item.type=type_tracking_90;
- else if (value < 256)
- priv->item.type=type_tracking_80;
- else if (value < 512)
- priv->item.type=type_tracking_70;
- else if (value < 1024)
- priv->item.type=type_tracking_60;
- else if (value < 2048)
- priv->item.type=type_tracking_50;
- else if (value < 4096)
- priv->item.type=type_tracking_40;
- else if (value < 8192)
- priv->item.type=type_tracking_30;
- else if (value < 16384)
- priv->item.type=type_tracking_20;
- else if (value < 32768)
- priv->item.type=type_tracking_10;
- else
- priv->item.type=type_tracking_0;
- dbg(lvl_debug,"item %d %d points\n", priv->coord, priv->curr->street->count);
- tracking_map_item_coord_rewind(priv);
- tracking_map_item_attr_rewind(priv);
- return ret;
+static struct item *tracking_map_get_item(struct map_rect_priv *priv) {
+ struct item *ret=&priv->item;
+ int value;
+ struct coord lpnt;
+
+ if (!priv->next)
+ return NULL;
+ if (! priv->curr || priv->coord + 2 >= priv->curr->street->count) {
+ priv->curr=priv->next;
+ priv->next=priv->curr->next;
+ priv->coord=0;
+ priv->item.id_lo=0;
+ priv->item.id_hi++;
+ } else {
+ priv->coord++;
+ priv->item.id_lo++;
+ }
+ value=tracking_value(priv->tracking, priv->curr, priv->coord, &lpnt, INT_MAX/2, -1);
+ if (value < 64)
+ priv->item.type=type_tracking_100;
+ else if (value < 128)
+ priv->item.type=type_tracking_90;
+ else if (value < 256)
+ priv->item.type=type_tracking_80;
+ else if (value < 512)
+ priv->item.type=type_tracking_70;
+ else if (value < 1024)
+ priv->item.type=type_tracking_60;
+ else if (value < 2048)
+ priv->item.type=type_tracking_50;
+ else if (value < 4096)
+ priv->item.type=type_tracking_40;
+ else if (value < 8192)
+ priv->item.type=type_tracking_30;
+ else if (value < 16384)
+ priv->item.type=type_tracking_20;
+ else if (value < 32768)
+ priv->item.type=type_tracking_10;
+ else
+ priv->item.type=type_tracking_0;
+ dbg(lvl_debug,"item %d %d points", priv->coord, priv->curr->street->count);
+ tracking_map_item_coord_rewind(priv);
+ tracking_map_item_attr_rewind(priv);
+ return ret;
}
-static struct item *
-tracking_map_get_item_byid(struct map_rect_priv *priv, int id_hi, int id_lo)
-{
- struct item *ret;
- tracking_map_rect_init(priv);
- while ((ret=tracking_map_get_item(priv))) {
- if (ret->id_hi == id_hi && ret->id_lo == id_lo)
- return ret;
- }
- return NULL;
+static struct item *tracking_map_get_item_byid(struct map_rect_priv *priv, int id_hi, int id_lo) {
+ struct item *ret;
+ tracking_map_rect_init(priv);
+ while ((ret=tracking_map_get_item(priv))) {
+ if (ret->id_hi == id_hi && ret->id_lo == id_lo)
+ return ret;
+ }
+ return NULL;
}
static struct map_methods tracking_map_meth = {
- projection_mg,
- "utf-8",
- tracking_map_destroy,
- tracking_map_rect_new,
- tracking_map_rect_destroy,
- tracking_map_get_item,
- tracking_map_get_item_byid,
- NULL,
- NULL,
- NULL,
+ projection_mg,
+ "utf-8",
+ tracking_map_destroy,
+ tracking_map_rect_new,
+ tracking_map_rect_destroy,
+ tracking_map_get_item,
+ tracking_map_get_item_byid,
+ NULL,
+ NULL,
+ NULL,
};
-static struct map_priv *
-tracking_map_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
-{
- struct map_priv *ret;
- struct attr *tracking_attr;
+static struct map_priv *tracking_map_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *ret;
+ struct attr *tracking_attr;
- tracking_attr=attr_search(attrs, NULL, attr_trackingo);
- if (! tracking_attr)
- return NULL;
- ret=g_new0(struct map_priv, 1);
- *meth=tracking_map_meth;
- ret->tracking=tracking_attr->u.tracking;
+ tracking_attr=attr_search(attrs, NULL, attr_trackingo);
+ if (! tracking_attr)
+ return NULL;
+ ret=g_new0(struct map_priv, 1);
+ *meth=tracking_map_meth;
+ ret->tracking=tracking_attr->u.tracking;
- return ret;
+ return ret;
}
-void
-tracking_init(void)
-{
- plugin_register_category_map("tracking", tracking_map_new);
+void tracking_init(void) {
+ plugin_register_category_map("tracking", tracking_map_new);
}
diff --git a/navit/traffic.c b/navit/traffic.c
new file mode 100644
index 000000000..7a0b74480
--- /dev/null
+++ b/navit/traffic.c
@@ -0,0 +1,5319 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2017 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/** @file
+ * @brief Contains code related to processing traffic messages into map items.
+ *
+ * Currently the only map items supported are traffic distortions. More may be added in the future.
+ *
+ * Traffic distortions are used by Navit to route around traffic problems.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+
+#ifdef _POSIX_C_SOURCE
+#include <sys/types.h>
+#endif
+#include <sys/time.h>
+#include "glib_slice.h"
+#include "config.h"
+#include "navit.h"
+#include "util.h"
+#include "coord.h"
+#include "item.h"
+#include "map.h"
+#include "mapset.h"
+#include "route_protected.h"
+#include "route.h"
+#include "transform.h"
+#include "xmlconfig.h"
+#include "traffic.h"
+#include "plugin.h"
+#include "fib.h"
+#include "event.h"
+#include "callback.h"
+#include "vehicleprofile.h"
+#include "debug.h"
+
+#undef TRAFFIC_DEBUG
+
+/** Flag to indicate new messages have been received */
+#define MESSAGE_UPDATE_MESSAGES 1 << 0
+
+/** Flag to indicate segments have changed */
+#define MESSAGE_UPDATE_SEGMENTS 1 << 1
+
+/** The penalty applied to an off-road link */
+#define PENALTY_OFFROAD 8
+
+/** The penalty applied to segments with non-matching attributes */
+#define PENALTY_SEGMENT_MATCH 4
+
+/** The maximum penalty applied to points with non-matching attributes */
+#define PENALTY_POINT_MATCH 24
+
+/** Flag to indicate expired messages should be purged */
+#define PROCESS_MESSAGES_PURGE_EXPIRED 1 << 0
+
+/** Flag to indicate the message store should not be exported */
+#define PROCESS_MESSAGES_NO_DUMP_STORE 1 << 1
+
+/** The lowest order of items to consider */
+#define ROUTE_ORDER 18
+
+/** The buffer zone around the enclosing rectangle used in route calculations, absolute distance */
+#define ROUTE_RECT_DIST_ABS 1000
+
+/** The buffer zone around the enclosing rectangle used in route calculations, relative to rect size */
+#define ROUTE_RECT_DIST_REL 0
+
+/** Time slice for idle loops, in milliseconds */
+#define TIME_SLICE 40
+
+/**
+ * @brief Private data shared between all traffic instances.
+ */
+struct traffic_shared_priv {
+ GList * messages; /**< Currently active messages */
+ GList * message_queue; /**< Queued messages, waiting to be processed */
+ // TODO messages by ID? In a later phase…
+};
+
+/**
+ * @brief A traffic plugin instance.
+ *
+ * If multiple traffic plugins are loaded, each will have its own `struct traffic` instance.
+ */
+struct traffic {
+ NAVIT_OBJECT
+ struct navit *navit; /**< The navit instance */
+ struct traffic_shared_priv *shared; /**< Private data shared between all instances */
+ struct traffic_priv *priv; /**< Private data used by the plugin */
+ struct traffic_methods meth; /**< Methods implemented by the plugin */
+ struct callback * callback; /**< The callback function for the idle loop */
+ struct event_timeout * timeout; /**< The timeout event that triggers the loop function */
+ struct callback *idle_cb; /**< Idle callback to process new messages */
+ struct event_idle *idle_ev; /**< The pointer to the idle event */
+ struct mapset *ms; /**< The mapset used for routing */
+ struct route *rt; /**< The route to notify of traffic changes */
+ struct map *map; /**< The traffic map, in which traffic distortions are stored */
+};
+
+struct traffic_location_priv {
+ struct coord_geo * sw; /*!< Southwestern corner of rectangle enclosing all points.
+ * Calculated by Navit from the points of the location. */
+ struct coord_geo * ne; /*!< Northeastern corner of rectangle enclosing all points.
+ * Calculated by Navit from the points of the location. */
+};
+
+struct traffic_message_priv {
+ struct item **items; /**< The items for this message in the traffic map */
+};
+
+/**
+ * @brief Private data for the traffic map.
+ *
+ * If multiple traffic plugins are loaded, the map is shared between all of them.
+ */
+struct map_priv {
+ GList * items; /**< The map items */
+ // TODO items by start/end coordinates? In a later phase…
+};
+
+/**
+ * @brief Implementation-specific map rect data
+ */
+struct map_rect_priv {
+ struct map_priv *mpriv; /**< The map to which this map rect refers */
+ struct item *item; /**< The current item, i.e. the last item returned by the `map_rect_get_item` method */
+ GList * next_item; /**< `GList` entry for the next item to be returned by `map_rect_get_item` */
+};
+
+/**
+ * @brief Message-specific map private data
+ *
+ * This structure is needed to handle segments referenced by multiple messages. When a message changes,
+ * is cancelled or expires, the data of the remaining messages is used to determine the new attributes
+ * for the segment.
+ */
+struct item_msg_priv {
+ char * message_id; /**< Message ID for the associated message */
+ int speed; /**< The expected speed in km/h (`INT_MAX` for unlimited, 0 indicates
+ * that the road is closed) */
+ int delay; /**< Expected delay for this segment, in 1/10 s */
+ struct attr ** attrs; /**< Additional attributes to add to the segment */
+};
+
+/**
+ * @brief Implementation-specific item data for traffic map items
+ */
+struct item_priv {
+ struct map_rect_priv * mr; /**< The private data for the map rect from which the item was obtained */
+ struct attr **attrs; /**< The attributes for the item, `NULL`-terminated */
+ struct coord *coords; /**< The coordinates for the item */
+ int coord_count; /**< The number of elements in `coords` */
+ int refcount; /**< How many references to this item exist */
+ GList * message_data; /**< Message-specific data, see `struct item_msg_priv` */
+ struct attr **next_attr; /**< The next attribute of `item` to be returned by the `item_attr_get` method */
+ unsigned int
+ next_coord; /**< The index of the next coordinate of `item` to be returned by the `item_coord_get` method */
+ struct route *rt; /**< The route to which the item has been added */
+};
+
+/**
+ * @brief Data for segments affected by a traffic message.
+ *
+ * Speed can be specified in three different ways:
+ * \li `speed` replaces the maximum speed of the segment, if lower
+ * \li `speed_penalty` subtracts the specified amount from the maximum speed of the segment
+ * \li `speed_factor` is the percentage of the maximum speed of the segment to be assumed
+ *
+ * Where more than one of these values is set, the lowest speed applies.
+ */
+struct seg_data {
+ enum item_type type; /**< The item type; currently only `type_traffic_distortion` is supported */
+ int speed; /**< The expected speed in km/h (`INT_MAX` for unlimited, 0 indicates
+ * that the road is closed) */
+ int speed_penalty; /**< Difference between expected speed and the posted speed limit of
+ * the segment (0 for none); the resulting maximum speed is never
+ * less than 5 km/h */
+ int speed_factor; /**< Expected speed expressed as a percentage of the posted limit (100
+ * for full speed) */
+ int delay; /**< Expected delay for all segments combined, in 1/10 s */
+ enum location_dir dir; /**< Directionality */
+ int flags; /**< Access flags (modes of transportation to which the message applies) */
+ struct attr ** attrs; /**< Additional attributes to add to the segments */
+};
+
+struct point_data {
+ struct route_graph_point * p; /**< The point in the route graph */
+ int score; /**< The attribute matching score */
+};
+
+/**
+ * @brief State for the XML parser.
+ *
+ * Several members of this struct are used to cache traffic data model objects until they can be
+ * incorporated in a message.
+ *
+ * All `struct traffic_point` members are reset to NULL when the `location` member is set. Likewise, the
+ * `si` member is reset to NULL when a new event is added. The `location` and `events` members are reset
+ * to NULL when a message is created.
+ */
+struct xml_state {
+ GList * messages; /**< Messages read so far */
+ GList * tagstack; /**< Currently open tags (order is bottom to top) */
+ int is_valid; /**< Whether `tagstack` represents a hierarchy of elements we recognize */
+ int is_opened; /**< True if we have just opened an element;
+ * false if child elements have been opened and closed since */
+ struct traffic_point * at; /**< The point for a point location, NULL for linear locations. */
+ struct traffic_point * from; /**< The start of a linear location, or a point before `at`. */
+ struct traffic_point * to; /**< The end of a linear location, or a point after `at`. */
+ struct traffic_point * via; /**< A point between `from` and `to`. Required on ring roads
+ * unless `not_via` is used; cannot be used together with `at`. */
+ struct traffic_point * not_via; /**< A point NOT between `from` and `to`. Required on ring roads
+ * unless `via` is used; cannot be used together with `at`. */
+ struct traffic_location * location; /**< The location to which the next message refers. */
+ GList * si; /**< Supplementary information items for the next event. */
+ GList * events; /**< The events for the next message. */
+};
+
+/**
+ * @brief Data for an XML element
+ *
+ * `names` and `values` are always two separate arrays for this struct, regardless of what is indicated by
+ * `XML_ATTR_DISTANCE`.
+ */
+struct xml_element {
+ char * tag_name; /**< The tag name */
+ char ** names; /**< Attribute names */
+ char ** values; /**< Attribute values (indices correspond to `names`) */
+ char * text; /**< Character data (NULL-terminated) */
+};
+
+static struct seg_data * seg_data_new(void);
+static struct item * tm_add_item(struct map *map, enum item_type type, int id_hi, int id_lo,
+ int flags, struct attr **attrs, struct coord *c, int count, char * id);
+#ifdef TRAFFIC_DEBUG
+static void tm_dump_item_to_textfile(struct item * item);
+#endif
+static void tm_destroy(struct map_priv *priv);
+static void tm_coord_rewind(void *priv_data);
+static void tm_item_destroy(struct item * item);
+static struct item * tm_item_ref(struct item * item);
+static struct item * tm_item_unref(struct item * item);
+static void tm_item_update_attrs(struct item * item, struct route * route);
+static int tm_coord_get(void *priv_data, struct coord *c, int count);
+static void tm_attr_rewind(void *priv_data);
+static int tm_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr);
+static int tm_type_set(void *priv_data, enum item_type type);
+static struct route_graph * traffic_location_get_route_graph(struct traffic_location * this_,
+ struct mapset * ms);
+static int traffic_location_match_attributes(struct traffic_location * this_, struct item *item);
+static int traffic_message_add_segments(struct traffic_message * this_, struct mapset * ms, struct seg_data * data,
+ struct map *map, struct route * route);
+static void traffic_location_populate_route_graph(struct traffic_location * this_, struct route_graph * rg,
+ struct mapset * ms);
+static void traffic_dump_messages_to_xml(struct traffic * this_);
+static void traffic_loop(struct traffic * this_);
+static struct traffic * traffic_new(struct attr *parent, struct attr **attrs);
+static int traffic_process_messages_int(struct traffic * this_, int flags);
+static void traffic_message_dump_to_stderr(struct traffic_message * this_);
+static struct seg_data * traffic_message_parse_events(struct traffic_message * this_);
+static struct route_graph_point * traffic_route_flood_graph(struct route_graph * rg, struct seg_data * data,
+ struct coord * c_start, struct coord * c_dst, struct route_graph_point * start_existing);
+
+static struct item_methods methods_traffic_item = {
+ tm_coord_rewind,
+ tm_coord_get,
+ tm_attr_rewind,
+ tm_attr_get,
+ NULL,
+ NULL,
+ NULL,
+ tm_type_set,
+};
+
+/**
+ * @brief Creates a Boolean value from its string representation.
+ *
+ * If the string equals `true`, `yes` or can be parsed to a nonzero integer, the result is true.
+ *
+ * If the string equals `false`, `no` or begins with the digit 0 and returns zero when parsed to an
+ * integer, the result is false.
+ *
+ * If NULL is supplied, or if the string does not match any known value, the result is the default value.
+ *
+ * String comparison is case-insensitive.
+ *
+ * Since true is always represented by a return value of 1, passing a `deflt` other than 0 or 1 allows
+ * the caller to determine if the string could be parsed correctly.
+ *
+ * @param string The string representation
+ * @param deflt The default value to return if `string` is not a valid representation of a Boolean value.
+ *
+ * @return The corresponding `enum event_class`, or `event_class_invalid` if `string` does not match a
+ * known identifier
+ */
+static int boolean_new(const char * string, int deflt) {
+ if (!string)
+ return deflt;
+ if (!g_ascii_strcasecmp(string, "yes") || !g_ascii_strcasecmp(string, "true") || atoi(string))
+ return 1;
+ if (!g_ascii_strcasecmp(string, "no") || !g_ascii_strcasecmp(string, "false") || ((string[0] == '0') && !atoi(string)))
+ return 0;
+ return deflt;
+}
+
+/**
+ * @brief Creates a new `struct seg_data` and initializes it with default values.
+ */
+static struct seg_data * seg_data_new(void) {
+ struct seg_data * ret = g_new0(struct seg_data, 1);
+ ret->type = type_traffic_distortion;
+ ret->speed = INT_MAX;
+ ret->speed_factor = 100;
+ return ret;
+}
+
+/**
+ * @brief Creates a timestamp from its ISO8601 representation.
+ *
+ * @param string The ISO8601 timestamp
+ *
+ * @return The timestamp, or 0 if `string` is NULL.
+ */
+static time_t time_new(char * string) {
+ if (!string)
+ return 0;
+ return iso8601_to_time(string);
+}
+
+/**
+ * @brief Whether two `struct seg_data` contain the same data.
+ *
+ * @return true if `l` and `r` are equal, false if not. Two NULL values are considered equal; a NULL value and a
+ * non-NULL value are not.
+ */
+static int seg_data_equals(struct seg_data * l, struct seg_data * r) {
+ struct attr ** attrs;
+ struct attr * attr;
+
+ if (!l && !r)
+ return 0;
+ else if (!l || !r)
+ return 1;
+ if (l->type != r->type)
+ return 0;
+ if (l->speed != r->speed)
+ return 0;
+ if (l->speed_penalty != r->speed_penalty)
+ return 0;
+ if (l->speed_factor != r->speed_factor)
+ return 0;
+ if (l->delay != r->delay)
+ return 0;
+ if (l->dir != r->dir)
+ return 0;
+ if (l->flags != r->flags)
+ return 0;
+ if (!l->attrs && !r->attrs)
+ return 1;
+ if (!l->attrs || !r->attrs)
+ return 0;
+ /* FIXME this will break if multiple attributes of the same type are present and have different values */
+ for (attrs = l->attrs; attrs; attrs++) {
+ attr = attr_search(r->attrs, NULL, (*attrs)->type);
+ if (!attr || (attr->u.data != (*attrs)->u.data))
+ return 0;
+ }
+ for (attrs = r->attrs; attrs; attrs++) {
+ attr = attr_search(l->attrs, NULL, (*attrs)->type);
+ if (!attr || (attr->u.data != (*attrs)->u.data))
+ return 0;
+ }
+ return 1;
+}
+
+/**
+ * @brief Adds message data to a traffic map item.
+ *
+ * This method checks if the item already has data for the message specified in `msgid`. If so, the
+ * existing data is updated, else a new entry is added.
+ *
+ * Data changes also trigger an update of the affected item’s attributes.
+ *
+ * @param item The item (its `priv_data` member must point to a `struct item_priv`)
+ * @param msgid The message ID
+ * @param speed The maximum speed for the segment (`INT_MAX` if none given)
+ * @param delay The delay for the segment, in tenths of seconds (0 for none)
+ * @param attrs Additional attributes specified by the message
+ * @param route The route affected by the changes
+ *
+ * @return true if data was changed, false if not
+ */
+static int tm_item_add_message_data(struct item * item, char * msgid, int speed, int delay, struct attr ** attrs,
+ struct route * route) {
+ int ret = 0;
+ struct item_priv * priv_data = item->priv_data;
+ GList * msglist;
+ struct item_msg_priv * msgdata;
+
+ for (msglist = priv_data->message_data; msglist; msglist = g_list_next(msglist)) {
+ msgdata = (struct item_msg_priv *) msglist->data;
+ if (!strcmp(msgdata->message_id, msgid))
+ break;
+ }
+
+ if (msglist) {
+ /* we have an existing item, update it */
+ ret |= ((msgdata->speed != speed) || (msgdata->delay != delay));
+ msgdata->speed = speed;
+ msgdata->delay = delay;
+ /* TODO attrs */
+ } else {
+ ret = 1;
+ /* we need to insert a new item */
+ msgdata = g_new0(struct item_msg_priv, 1);
+ msgdata->message_id = g_strdup(msgid);
+ msgdata->speed = speed;
+ msgdata->delay = delay;
+ /* TODO attrs */
+ priv_data->message_data = g_list_append(priv_data->message_data, msgdata);
+ }
+
+ if (ret)
+ tm_item_update_attrs(item, route);
+
+ return ret;
+}
+
+/**
+ * @brief Destroys a traffic map item.
+ *
+ * This function should never be called directly. Instead, be sure to obtain all references by calling
+ * `tm_item_ref()` and destroying them by calling `tm_item_unref()`.
+ *
+ * @param item The item (its `priv_data` member must point to a `struct item_priv`)
+ */
+static void tm_item_destroy(struct item * item) {
+ struct item_priv * priv_data = item->priv_data;
+ GList * msglist;
+ struct item_msg_priv * msgdata;
+
+ attr_list_free(priv_data->attrs);
+ g_free(priv_data->coords);
+
+ for (msglist = priv_data->message_data; msglist; msglist = g_list_remove(msglist, msglist->data)) {
+ msgdata = (struct item_msg_priv *) msglist->data;
+ g_free(msgdata->message_id);
+ attr_list_free(msgdata->attrs);
+ g_free(msgdata);
+ }
+
+ g_free(item->priv_data);
+ g_free(item);
+}
+
+/**
+ * @brief References a traffic map item.
+ *
+ * Storing a reference to a traffic map item should always be done by calling this function, passing the
+ * item as its argument. This will return the item and increase its reference count by one.
+ *
+ * Never store a pointer to a traffic item not obtained via this function. Doing so may have undesired
+ * side effects as the item will not be aware of the reference to it, and the reference may unexpectedly
+ * become invalid, leading to a segmentation fault.
+ *
+ * @param item The item (its `priv_data` member must point to a `struct item_priv`)
+ *
+ * @return The item. `NULL` will be returned if the argument is `NULL` or points to an item whose
+ * `priv_data` member is `NULL`.
+ */
+static struct item * tm_item_ref(struct item * item) {
+ if (!item)
+ return NULL;
+ if (!item->priv_data)
+ return NULL;
+ ((struct item_priv *) item->priv_data)->refcount++;
+ return item;
+}
+
+/**
+ * @brief Unreferences a traffic map item.
+ *
+ * This must be called when destroying a reference to a traffic map item. It will decrease the reference
+ * count of the item by one, and destroy the item if the last reference to is is removed.
+ *
+ * The map itself (and only the map) holds weak references to its items, which are not considered in the
+ * reference count. Consequently, when the reference count reaches zero, the item is also removed from
+ * the map.
+ *
+ * Unreferencing an item with a zero reference count (which is only possible for an item which has never
+ * been referenced since its creation) is equivalent to dropping the last reference, i.e. it will destroy
+ * the item.
+ *
+ * When the last reference is removed (or an item with a zero reference count is unreferenced) and the item’s `rt`
+ * member is set (indicating the route to which the item was added), the item is removed from that route.
+ *
+ * If the unreference operation is successful, this function returns `NULL`. This allows one-line
+ * operations such as:
+ *
+ * {@code some_item = tm_item_unref(some_item);}
+ *
+ * @param item The item (its `priv_data` member must point to a `struct item_priv`)
+ *
+ * @return `NULL` if the item was unreferenced successfully, `item` if it points to an item whose
+ * `priv_data` member is `NULL`.
+ */
+static struct item * tm_item_unref(struct item * item) {
+ struct item_priv * priv_data;
+ struct map_rect * mr;
+ struct item * mapitem;
+ if (!item)
+ return item;
+ if (!item->priv_data)
+ return item;
+ priv_data = (struct item_priv *) item->priv_data;
+ priv_data->refcount--;
+ if (priv_data->refcount <= 0) {
+ if (priv_data->rt)
+ route_remove_traffic_distortion(priv_data->rt, item);
+ mr = map_rect_new(item->map, NULL);
+ do {
+ mapitem = map_rect_get_item(mr);
+ } while (mapitem && (mapitem != item));
+ if (mapitem)
+ item_type_set(mapitem, type_none);
+ map_rect_destroy(mr);
+ tm_item_destroy(item);
+ }
+ return NULL;
+}
+
+/**
+ * @brief Updates the attributes of an item.
+ *
+ * This method must be called after changing the message data associated with an item, i.e. adding,
+ * removing or modifying message data.
+ *
+ * @param item The item
+ * @param route The route affected by the changes
+ */
+static void tm_item_update_attrs(struct item * item, struct route * route) {
+ struct item_priv * priv_data = (struct item_priv *) item->priv_data;
+ GList * msglist;
+ struct item_msg_priv * msgdata;
+ int speed = INT_MAX;
+ int delay = 0;
+ struct attr * attr = NULL;
+ int has_changes = 0;
+
+ for (msglist = priv_data->message_data; msglist; msglist = g_list_next(msglist)) {
+ msgdata = (struct item_msg_priv *) msglist->data;
+ if (msgdata->speed < speed)
+ speed = msgdata->speed;
+ if (msgdata->delay < delay)
+ delay = msgdata->delay;
+ /* TODO attrs */
+ }
+
+ if (!priv_data->attrs)
+ priv_data->attrs = g_new0(struct attr *, 1);
+
+ /* TODO maxspeed vs. delay:
+ * Currently both values are interpreted as being cumulative, which may give erroneous results.
+ * Consider a segment with a length of 1000 m and a maxspeed of 120 km/h, thus having a cost of 30 s.
+ * One message reports a maxspeed of 60 km/h and no delay, increasing the cost to 60 s. A second
+ * message reports no maxspeed but a delay of 30 s, also increasing the cost to 60 s. Both messages
+ * together would be interpreted as reducing the maxspeed to 60 km/h and adding a delay of 30 s,
+ * resulting in a cost of 90 s for the segment.
+ */
+ if (speed < INT_MAX) {
+ attr = attr_search(priv_data->attrs, NULL, attr_maxspeed);
+ if (!attr) {
+ attr = g_new0(struct attr, 1);
+ attr->type = attr_maxspeed;
+ attr->u.num = speed;
+ priv_data->attrs = attr_generic_add_attr(priv_data->attrs, attr);
+ g_free(attr);
+ attr = NULL;
+ has_changes = 1;
+ } else if (speed < attr->u.num) {
+ has_changes = 1;
+ attr->u.num = speed;
+ } else if (speed > attr->u.num) {
+ has_changes = 1;
+ attr->u.num = speed;
+ }
+ } else {
+ while ((attr = attr_search(priv_data->attrs, NULL, attr_maxspeed)))
+ priv_data->attrs = attr_generic_remove_attr(priv_data->attrs, attr);
+ }
+
+ if (delay) {
+ attr = attr_search(priv_data->attrs, NULL, attr_delay);
+ if (!attr) {
+ attr = g_new0(struct attr, 1);
+ attr->type = attr_delay;
+ attr->u.num = delay;
+ priv_data->attrs = attr_generic_add_attr(priv_data->attrs, attr);
+ g_free(attr);
+ attr = NULL;
+ has_changes = 1;
+ } else if (delay > attr->u.num) {
+ has_changes = 1;
+ attr->u.num = delay;
+ } else if (delay < attr->u.num) {
+ has_changes = 1;
+ attr->u.num = delay;
+ }
+ } else {
+ while (1) {
+ attr = attr_search(priv_data->attrs, NULL, attr_delay);
+ if (!attr)
+ break;
+ priv_data->attrs = attr_generic_remove_attr(priv_data->attrs, attr);
+ }
+ }
+
+ if (has_changes) {
+ if (!priv_data->rt) {
+ priv_data->rt = route;
+ route_add_traffic_distortion(priv_data->rt, item);
+ } else
+ route_change_traffic_distortion(priv_data->rt, item);
+ }
+}
+
+/**
+ * @brief Returns an item from the map which matches the supplied data.
+ *
+ * Comparison criteria are as follows:
+ *
+ * \li The item type must match
+ * \li Start and end coordinates must match (inverted coordinates will also match)
+ * \li If `attr_flags` is supplied in `attrs`, the item must have this attribute and the rules listed
+ * below are applied
+ * \li Flags in `AF_ALL` must match
+ * \li Flags in `AF_ONEWAYMASK` must be set either on both sides or neither side
+ * \li If set, flags in `AF_ONEWAYMASK` must effectively match (equal for same direction, inverted for
+ * opposite directions)
+ * \li Other attributes are currently ignored
+ *
+ * This is due to the way different reports for the same segment are handled:
+ *
+ * \li If multiple reports with the same access flags exist, one item is created; speed and delay are
+ * evaluated across all currently active reports in `tm_item_update_attrs()` (lowest speed and longest
+ * delay wins)
+ * \li If multiple reports exist and access flags differ, one item is created for each set of flags;
+ * items are deduplicated in `route_get_traffic_distortion()`
+ *
+ * @param mr A map rectangle in the traffic map
+ * @param type Type of the item
+ * @param attrs The attributes for the item
+ * @param c Points to an array of coordinates for the item
+ * @param count Number of items in `c`
+ */
+static struct item * tm_find_item(struct map_rect *mr, enum item_type type, struct attr **attrs,
+ struct coord *c, int count) {
+ struct item * ret = NULL;
+ struct item * curr;
+ struct item_priv * curr_priv;
+ struct attr wanted_flags_attr, curr_flags_attr;
+
+ while ((curr = map_rect_get_item(mr)) && !ret) {
+ if (curr->type != type)
+ continue;
+ if (attr_generic_get_attr(attrs, NULL, attr_flags, &wanted_flags_attr, NULL)) {
+ if (!item_attr_get(curr, attr_flags, &curr_flags_attr))
+ continue;
+ if ((wanted_flags_attr.u.num & AF_ALL) != (curr_flags_attr.u.num & AF_ALL))
+ continue;
+ continue;
+ } else
+ wanted_flags_attr.type = attr_none;
+ curr_priv = curr->priv_data;
+ if (curr_priv->coords[0].x == c[0].x && curr_priv->coords[0].y == c[0].y
+ && curr_priv->coords[curr_priv->coord_count-1].x == c[count-1].x
+ && curr_priv->coords[curr_priv->coord_count-1].y == c[count-1].y) {
+ if (wanted_flags_attr.type == attr_none) {
+ /* no flag comparison, match */
+ } else if ((wanted_flags_attr.u.num & AF_ONEWAYMASK) != (curr_flags_attr.u.num & AF_ONEWAYMASK))
+ /* different oneway restrictions, no match */
+ continue;
+ ret = curr;
+ } else if (curr_priv->coords[0].x == c[count-1].x
+ && curr_priv->coords[0].y == c[count-1].y
+ && curr_priv->coords[curr_priv->coord_count-1].x == c[0].x
+ && curr_priv->coords[curr_priv->coord_count-1].y == c[0].y) {
+ if (wanted_flags_attr.type == attr_none) {
+ /* no flag comparison, match */
+ } else if (!(wanted_flags_attr.u.num & AF_ONEWAYMASK) && !(curr_flags_attr.u.num & AF_ONEWAYMASK)) {
+ /* two bidirectional distortions, match */
+ } else if (wanted_flags_attr.u.num & curr_flags_attr.u.num & AF_ONEWAYMASK) {
+ /* oneway in opposite directions, no match */
+ continue;
+ } else if ((wanted_flags_attr.u.num ^ AF_ONEWAYMASK) & curr_flags_attr.u.num & AF_ONEWAYMASK) {
+ /* oneway in same direction, match */
+ } else {
+ continue;
+ }
+ ret = curr;
+ }
+ }
+ return ret;
+}
+
+#ifdef TRAFFIC_DEBUG
+/**
+ * @brief Dumps an item to a textfile map.
+ *
+ * This method writes the item to a textfile map named `distortion.txt` in the default data folder.
+ * This map can be added to the active mapset in order for the distortions to be rendered on the map and
+ * considered for routing.
+ *
+ * All data passed to this method is safe to free after the method returns, and doing so is the
+ * responsibility of the caller.
+ *
+ * @param item The item
+ */
+static void tm_dump_item_to_textfile(struct item * item) {
+ struct item_priv * ip = (struct item_priv *) item->priv_data;
+ struct attr **attrs = ip->attrs;
+ struct coord *c = ip->coords;
+ int i;
+ char * attr_text;
+
+ /* add the configuration directory to the name of the file to use */
+ char *dist_filename = g_strjoin(NULL, navit_get_user_data_directory(TRUE),
+ "/distortion.txt", NULL);
+ if (dist_filename) {
+ FILE *map = fopen(dist_filename,"a");
+ if (map) {
+ fprintf(map, "type=%s", item_to_name(item->type));
+ while (*attrs) {
+ attr_text = attr_to_text(*attrs, NULL, 0);
+ /* FIXME this may not work properly for all attribute types */
+ fprintf(map, " %s=%s", attr_to_name((*attrs)->type), attr_text);
+ g_free(attr_text);
+ attrs++;
+ }
+ fprintf(map, "\n");
+
+ for (i = 0; i < ip->coord_count; i++) {
+ fprintf(map,"0x%x 0x%x\n", c[i].x, c[i].y);
+ }
+ fclose(map);
+ } else {
+ dbg(lvl_error,"could not open file for distortions !!");
+
+ } /* else - if (map) */
+ g_free(dist_filename); /* free the file name */
+ } /* if (dist_filename) */
+}
+
+/**
+ * @brief Dumps the traffic map to a textfile map.
+ *
+ * This method writes all items to a textfile map named `distortion.txt` in the default data folder.
+ * This map can be added to the active mapset in order for the distortions to be rendered on the map and
+ * considered for routing.
+ *
+ * @param map The traffic map
+ */
+static void tm_dump_to_textfile(struct map * map) {
+ /* external method, verifies the public API as well as internal structure */
+ struct map_rect * mr;
+ struct item * item;
+
+ mr = map_rect_new(map, NULL);
+ while ((item = map_rect_get_item(mr)))
+ tm_dump_item_to_textfile(item);
+ map_rect_destroy(mr);
+}
+#endif
+
+/**
+ * @brief Adds an item to the map.
+ *
+ * If a matching item is already in the map, that item will be returned.
+ *
+ * All data passed to this method is safe to free after the method returns, and doing so is the
+ * responsibility of the caller.
+ *
+ * @param map The traffic map
+ * @param type Type of the item
+ * @param id_hi First part of the ID of the item (item IDs have two parts)
+ * @param id_lo Second part of the ID of the item
+ * @param flags Flags used as a matching criterion, and added to newly-created items
+ * @param attrs The attributes for the item
+ * @param c Points to an array of coordinates for the item
+ * @param count Number of items in `c`
+ * @param id Message ID for the associated message
+ *
+ * @return The map item
+ */
+static struct item * tm_add_item(struct map *map, enum item_type type, int id_hi, int id_lo,
+ int flags, struct attr **attrs, struct coord *c, int count, char * id) {
+ struct item * ret = NULL;
+ struct item_priv * priv_data;
+ struct map_rect * mr;
+ struct attr ** int_attrs = NULL;
+ struct attr flags_attr;
+
+ flags_attr.type = attr_flags;
+ flags_attr.u.num = flags;
+ int_attrs = attr_generic_set_attr(attr_list_dup(attrs), &flags_attr);
+
+ mr = map_rect_new(map, NULL);
+ ret = tm_find_item(mr, type, int_attrs, c, count);
+ if (!ret) {
+ ret = map_rect_create_item(mr, type);
+ ret->id_hi = id_hi;
+ ret->id_lo = id_lo;
+ ret->map = map;
+ ret->meth = &methods_traffic_item;
+ priv_data = (struct item_priv *) ret->priv_data;
+ priv_data->attrs = int_attrs;
+ priv_data->coords = g_memdup(c, sizeof(struct coord) * count);
+ priv_data->coord_count = count;
+ priv_data->next_attr = int_attrs;
+ priv_data->next_coord = 0;
+ } else if (int_attrs) {
+ /* free up our copy of the attribute list if we’re not attaching it to a new item */
+ attr_list_free(int_attrs);
+ }
+ map_rect_destroy(mr);
+ //tm_dump_item(ret);
+ return ret;
+}
+
+/**
+ * @brief Destroys (closes) the traffic map.
+ *
+ * @param priv The private data for the traffic map instance
+ */
+static void tm_destroy(struct map_priv *priv) {
+ g_free(priv);
+}
+
+/**
+ * @brief Opens a new map rectangle on the traffic map.
+ *
+ * This function opens a new map rectangle on the route graph's map.
+ *
+ * @param priv The traffic graph map's private data
+ * @param sel The map selection (to restrict search to a rectangle, order and/or item types)
+ * @return A new map rect's private data
+ */
+static struct map_rect_priv * tm_rect_new(struct map_priv *priv, struct map_selection *sel) {
+ struct map_rect_priv * mr;
+ dbg(lvl_debug,"enter");
+ mr=g_new0(struct map_rect_priv, 1);
+ mr->mpriv = priv;
+ mr->next_item = priv->items;
+ /* all other pointers are initially NULL */
+ return mr;
+}
+
+/**
+ * @brief Destroys a map rectangle on the traffic map.
+ */
+static void tm_rect_destroy(struct map_rect_priv *mr) {
+ /* just free the map_rect_priv, all its members are pointers to data "owned" by others */
+ g_free(mr);
+}
+
+/**
+ * @brief Returns the next item from the traffic map
+ *
+ * @param mr The map rect to search for items
+ *
+ * @return The next item, or `NULL` if the last item has already been retrieved.
+ */
+static struct item * tm_get_item(struct map_rect_priv *mr) {
+ struct item * ret = NULL;
+ struct item_priv * ip;
+
+ if (mr->item) {
+ ip = (struct item_priv *) mr->item->priv_data;
+ ip->mr = NULL;
+ }
+ if (mr->next_item) {
+ ret = (struct item *) mr->next_item->data;
+ ip = (struct item_priv *) ret->priv_data;
+ ip->mr = mr;
+ tm_attr_rewind(ret->priv_data);
+ tm_coord_rewind(ret->priv_data);
+ mr->next_item = g_list_next(mr->next_item);
+ }
+
+ mr->item = ret;
+ return ret;
+}
+
+/**
+ * @brief Returns the next item with the supplied ID from the traffic map
+ *
+ * @param mr The map rect to search for items
+ * @param id_hi The high-order portion of the ID
+ * @param id_lo The low-order portion of the ID
+ *
+ * @return The next item matching the ID; `NULL` if there are no matching items or the last matching
+ * item has already been retrieved.
+ */
+static struct item * tm_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo) {
+ struct item *ret = NULL;
+ do {
+ ret = tm_get_item(mr);
+ } while (ret && (ret->id_lo != id_lo || ret->id_hi != id_hi));
+ return ret;
+}
+
+/**
+ * @brief Creates a new item of the specified type and inserts it into the map.
+ *
+ * @param mr The map rect in which to create the item
+ * @param type The type of item to create
+ *
+ * @return The new item. The item is of type `type` and has an allocated `priv_data` member; all other
+ * members of both structs are `NULL`.
+ */
+static struct item * tm_rect_create_item(struct map_rect_priv *mr, enum item_type type) {
+ struct map_priv * map_priv = mr->mpriv;
+ struct item * ret = NULL;
+ struct item_priv * priv_data;
+
+ priv_data = g_new0(struct item_priv, 1);
+
+ ret = g_new0(struct item, 1);
+ ret->type = type;
+ ret->priv_data = priv_data;
+ map_priv->items = g_list_append(map_priv->items, ret);
+
+ return ret;
+}
+
+/**
+ * @brief Rewinds the coordinates of the currently selected item.
+ *
+ * After rewinding, the next call to the `tm_coord_get()` will return the first coordinate of the
+ * current item.
+ *
+ * @param priv_data The item's private data
+ */
+static void tm_coord_rewind(void *priv_data) {
+ struct item_priv * ip = priv_data;
+
+ ip->next_coord = 0;
+}
+
+/**
+ * @brief Returns the coordinates of a traffic item.
+ *
+ * @param priv_data The item's private data
+ * @param c Pointer to a `struct coord` array where coordinates will be stored
+ * @param count The maximum number of coordinates to retrieve (must be less than or equal to the number
+ * of items `c` can hold)
+ * @return The number of coordinates retrieved
+ */
+static int tm_coord_get(void *priv_data, struct coord *c, int count) {
+ struct item_priv * ip = priv_data;
+ int ret = count;
+
+ if (!ip)
+ return 0;
+ if (ip->next_coord >= ip->coord_count)
+ return 0;
+ if (ip->next_coord + count > ip->coord_count)
+ ret = ip->coord_count - ip->next_coord;
+ memcpy(c, &ip->coords[ip->next_coord], ret * sizeof(struct coord));
+ ip->next_coord += ret;
+ return ret;
+}
+
+/**
+ * @brief Rewinds the attributes of the currently selected item.
+ *
+ * After rewinding, the next call to `tm_attr_get()` will return the first attribute.
+ *
+ * @param priv_data The item's private data
+ */
+static void tm_attr_rewind(void *priv_data) {
+ struct item_priv * ip = priv_data;
+
+ ip->next_attr = ip->attrs;
+}
+
+/**
+ * @brief Returns the next attribute of a traffic item which matches the specified type.
+ *
+ * @param priv_data The item's private data
+ * @param attr_type The attribute type to retrieve, or `attr_any` to retrieve the next attribute,
+ * regardless of type
+ * @param attr Receives the attribute
+ *
+ * @return True on success, false on failure
+ */
+static int tm_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) {
+ struct item_priv * ip = priv_data;
+ int ret = 0;
+
+ if (!ip->next_attr)
+ return 0;
+ while (*(ip->next_attr) && !ret) {
+ ret = (attr_type == attr_any) || (attr_type == (*(ip->next_attr))->type);
+ if (ret)
+ attr_dup_content(*(ip->next_attr), attr);
+ ip->next_attr++;
+ }
+ return ret;
+}
+
+/**
+ * @brief Sets the type of a traffic item.
+ *
+ * @param priv_data The item's private data
+ * @param type The new type for the item. Setting it to `type_none` deletes the item from the map.
+ *
+ * @return 0 on failure, nonzero on success
+ */
+static int tm_type_set(void *priv_data, enum item_type type) {
+ struct item_priv * ip = priv_data;
+
+ if (!ip->mr || !ip->mr->item || (ip->mr->item->priv_data != priv_data)) {
+ dbg(lvl_error, "this function can only be called for the last item retrieved from its map rect");
+ return 0;
+ }
+
+ if (type == type_none) {
+ /* if we have multiple occurrences of this item in the list, move forward beyond the last one */
+ while (ip->mr->next_item && (ip->mr->next_item->data == ip->mr->item))
+ ip->mr->next_item = g_list_next(ip->mr->next_item);
+
+ /* remove the item from the map and set last retrieved item to NULL */
+ ip->mr->mpriv->items = g_list_remove_all(ip->mr->mpriv->items, ip->mr->item);
+ ip->mr->item = NULL;
+ } else {
+ ip->mr->item->type = type;
+ }
+
+ return 1;
+}
+
+static struct map_methods traffic_map_meth = {
+ projection_mg, /* pro: The projection used for that type of map */
+ "utf-8", /* charset: The charset this map uses. */
+ tm_destroy, /* map_destroy: Destroy ("close") a map. */
+ tm_rect_new, /* map_rect_new: Create a new map rect on the map. */
+ tm_rect_destroy, /* map_rect_destroy: Destroy a map rect */
+ tm_get_item, /* map_rect_get_item: Return the next item from a map rect */
+ tm_get_item_byid, /* map_rect_get_item_byid: Get an item with a specific ID from a map rect, can be NULL */
+ NULL, /* map_search_new: Start a new search on the map, can be NULL */
+ NULL, /* map_search_destroy: Destroy a map search struct, ignored if `map_search_new` is NULL */
+ NULL, /* map_search_get_item: Get the next item of a search on the map */
+ tm_rect_create_item, /* map_rect_create_item: Create a new item in the map */
+ NULL, /* map_get_attr */
+ NULL, /* map_set_attr */
+};
+
+/**
+ * @brief Whether the contents of an event are valid.
+ *
+ * This identifies any malformed events in which mandatory members are not set.
+ *
+ * @return true if the event is valid, false if it is malformed
+ */
+static int traffic_event_is_valid(struct traffic_event * this_) {
+ if (!this_->event_class || !this_->type) {
+ dbg(lvl_debug, "event_class (%d) or type (%d) are unknown", this_->event_class, this_->type);
+ return 0;
+ }
+ switch (this_->event_class) {
+ case event_class_congestion:
+ if ((this_->type < event_congestion_cleared) || (this_->type >= event_delay_clearance)) {
+ dbg(lvl_debug, "illegal type (%d) for event_class_congestion", this_->type);
+ return 0;
+ }
+ break;
+ case event_class_delay:
+ if ((this_->type < event_delay_clearance)
+ || (this_->type >= event_restriction_access_restrictions_lifted)) {
+ dbg(lvl_debug, "illegal type (%d) for event_class_delay", this_->type);
+ return 0;
+ }
+ break;
+ case event_class_restriction:
+ if ((this_->type < event_restriction_access_restrictions_lifted)
+ || (this_->type > event_restriction_speed_limit_lifted)) {
+ dbg(lvl_debug, "illegal type (%d) for event_class_restriction", this_->type);
+ return 0;
+ }
+ break;
+ default:
+ dbg(lvl_debug, "unknown event class %d", this_->event_class);
+ return 0;
+ }
+ if (this_->si_count && !this_->si) {
+ dbg(lvl_debug, "si_count=%d but no supplementary information", this_->si_count);
+ return 0;
+ }
+ /* TODO check SI */
+ return 1;
+}
+
+/**
+ * @brief Determines the degree to which the attributes of a location and a map item match.
+ *
+ * The result of this method is used to match a location to a map item. Its result is a score—the higher
+ * the score, the better the match.
+ *
+ * To calculate the score, all supplied attributes are examined and points are given for each attribute
+ * which is defined for the location. An exact match adds 4 points, a partial match adds 2. Values of 1
+ * and 3 are added where additional granularity is needed. The number of points attained is divided by
+ * the maximum number of points attainable, and the result is returned as a percentage value.
+ *
+ * If no points can be attained (because no attributes which must match are supplied), the score is 100
+ * for any item supplied.
+ *
+ * @param this_ The location
+ * @param item The map item
+ *
+ * @return The score, as a percentage value
+ */
+static int traffic_location_match_attributes(struct traffic_location * this_, struct item *item) {
+ int score = 0;
+ int maxscore = 0;
+ struct attr attr;
+
+ /* road type */
+ if ((this_->road_type != type_line_unspecified)) {
+ maxscore += 400;
+ if (item->type == this_->road_type)
+ score += 400;
+ else
+ switch (this_->road_type) {
+ /* motorway */
+ case type_highway_land:
+ if (item->type == type_highway_city)
+ score += 300;
+ else if (item->type == type_street_n_lanes)
+ score += 200;
+ break;
+ case type_highway_city:
+ if (item->type == type_highway_land)
+ score += 300;
+ else if (item->type == type_street_n_lanes)
+ score += 200;
+ break;
+ /* trunk */
+ case type_street_n_lanes:
+ if ((item->type == type_highway_land) || (item->type == type_highway_city)
+ || (item->type == type_street_4_land)
+ || (item->type == type_street_4_city))
+ score += 200;
+ break;
+ /* primary */
+ case type_street_4_land:
+ if (item->type == type_street_4_city)
+ score += 300;
+ else if ((item->type == type_street_n_lanes)
+ || (item->type == type_street_3_land))
+ score += 200;
+ else if (item->type == type_street_3_city)
+ score += 100;
+ break;
+ case type_street_4_city:
+ if (item->type == type_street_4_land)
+ score += 300;
+ else if ((item->type == type_street_n_lanes)
+ || (item->type == type_street_3_city))
+ score += 200;
+ else if (item->type == type_street_3_land)
+ score += 100;
+ break;
+ /* secondary */
+ case type_street_3_land:
+ if (item->type == type_street_3_city)
+ score += 300;
+ else if ((item->type == type_street_4_land)
+ || (item->type == type_street_2_land))
+ score += 200;
+ else if ((item->type == type_street_4_city)
+ || (item->type == type_street_2_city))
+ score += 100;
+ break;
+ case type_street_3_city:
+ if (item->type == type_street_3_land)
+ score += 300;
+ else if ((item->type == type_street_4_city)
+ || (item->type == type_street_2_city))
+ score += 200;
+ else if ((item->type == type_street_4_land)
+ || (item->type == type_street_2_land))
+ score += 100;
+ break;
+ /* tertiary */
+ case type_street_2_land:
+ if (item->type == type_street_2_city)
+ score += 300;
+ else if (item->type == type_street_3_land)
+ score += 200;
+ else if (item->type == type_street_3_city)
+ score += 100;
+ break;
+ case type_street_2_city:
+ if (item->type == type_street_2_land)
+ score += 300;
+ else if (item->type == type_street_3_city)
+ score += 200;
+ else if (item->type == type_street_3_land)
+ score += 100;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* road_ref */
+ if (this_->road_ref) {
+ maxscore += 400;
+ if (item_attr_get(item, attr_street_name_systematic, &attr))
+ score += (400 * (MAX_MISMATCH - compare_name_systematic(this_->road_ref, attr.u.str))) / MAX_MISMATCH;
+ }
+
+ /* road_name */
+ if (this_->road_name) {
+ maxscore += 200;
+ if (item_attr_get(item, attr_street_name, &attr)) {
+ // TODO crude comparison in need of refinement
+ if (!strcmp(this_->road_name, attr.u.str))
+ score += 200;
+ }
+ }
+
+ // TODO direction
+ // TODO destination
+
+ // TODO ramps
+
+ if (!maxscore)
+ return 100;
+ return (score * 100) / maxscore;
+}
+
+/**
+ * @brief Determines the degree to which the attributes of a point and a map item match.
+ *
+ * The result of this method is used to match a location to a map item. Its result is a score—the higher
+ * the score, the better the match.
+ *
+ * To calculate the score, all supplied attributes are examined and points are given for each attribute
+ * which is defined for the location. An exact match adds 4 points, a partial match adds 2. Values of 1
+ * and 3 are added where additional granularity is needed. The number of points attained is divided by
+ * the maximum number of points attainable, and the result is returned as a percentage value.
+ *
+ * If no points can be attained (because no attributes which must match are supplied), the score is 0
+ * for any item supplied.
+ *
+ * @param this_ The traffic point
+ * @param item The map item
+ *
+ * @return The score, as a percentage value
+ */
+static int traffic_point_match_attributes(struct traffic_point * this_, struct item *item) {
+ int score = 0;
+ int maxscore = 0;
+ struct attr attr;
+
+ /* junction_ref */
+ if (this_->junction_ref) {
+ maxscore += 400;
+ if (item_attr_get(item, attr_ref, &attr))
+ score += (400 * (MAX_MISMATCH - compare_name_systematic(this_->junction_ref, attr.u.str))) / MAX_MISMATCH;
+ }
+
+ /* junction_name */
+ if (this_->junction_name) {
+ if (item_attr_get(item, attr_label, &attr)) {
+ maxscore += 400;
+ // TODO crude comparison in need of refinement
+ if (!strcmp(this_->junction_name, attr.u.str))
+ score += 400;
+ }
+ }
+
+ // TODO tmc_table, point->tmc_id
+
+ if (!maxscore)
+ return 0;
+ return (score * 100) / maxscore;
+}
+
+/**
+ * @brief Determines the degree to which the attributes of a point match those of the segments connecting to it.
+ *
+ * The result of this method is used to match a location to a map item. Its result is a score—the higher the score, the
+ * better the match.
+ *
+ * To calculate the score, this method iterates over all segments which begin or end at `p`. The `junction_name`
+ * member of the location is compared against the name of the segment, and the highest score for any segment is
+ * returned. Currently the name must match completely, resulting in a score of 100, while everything else is considered
+ * a mismatch (with a score of 0). Future versions may introduce support for partial matches, with the score indicating
+ * the quality of the match.
+ *
+ * Segments which are part of the route are treated in a different manner, as the direction in which the segment is
+ * traversed (not the direction of the segment itself) is taken into account, which is needed to govern whether the
+ * matched segment ends up being part of the route or not.
+ *
+ * In some cases, `this_` refers to a point which is actually a segment (such as a bridge or tunnel), which we want to
+ * include in the route. In other cases, `this_` refers to an intersection with another road, and the junction name is
+ * the name of the other road; these segments need to be excluded from the route.
+ *
+ * This is controlled by the `match_start` argument: if true, we are evaluating the start point of a route, else we are
+ * evaluating its end point. To include the matched segment in the route, only the first point (whose `seg` member
+ * points to the segment) will match for the start point, the opposite is true for the end point. To exclude the
+ * matched segment, this logic is reversed.
+ *
+ * A heuristic is in place to distinguish whether or not we want the matched segment included.
+ *
+ * If no points can be attained (because no attributes which must match are supplied), the score is 0 for any point.
+ *
+ * @param this_ The traffic point
+ * @param p The point shared by all segments to examine
+ * @param start The first point of the path
+ * @param match_start True to evaluate for the start point of a route, false for the end point
+ *
+ * @return The score, as a percentage value
+ */
+static int traffic_point_match_segment_attributes(struct traffic_point * this_, struct route_graph_point *p,
+ struct route_graph_point * start, int match_start) {
+
+ /*
+ * Whether we want a match for the route segment starting at p (leading away from it) or the route segment ending
+ * at p (leading towards it).
+ */
+ int want_start_match = match_start;
+
+ /* Iterator for route graph points */
+ struct route_graph_point *p_iter = start;
+
+ /* The predecessor pf `p`in the route graph */
+ struct route_graph_point *p_prev = NULL;
+
+ /*
+ * Whether this_ matches the route segment starting at p (leading away from it), the route segment ending at p
+ * (leading towards it), or an off-route segment connected to p, respectively
+ */
+ int has_start_match = 0, has_end_match = 0, has_offroute_match = 0;
+
+ /* The route segment being examined */
+ struct route_graph_segment *s;
+
+ /* Map rect for retrieving item data */
+ struct map_rect *mr;
+
+ /* The item being examined */
+ struct item * item;
+
+ /* The attribute being examined */
+ struct attr attr;
+
+ /* Name and systematic name for route segments starting and ending at p */
+ char *start_name = NULL, *start_ref = NULL, *end_name = NULL, *end_ref = NULL;
+
+ /* Whether or not the route follows the road (if both are true or both are false, the case is not clear) */
+ int route_follows_road = 0, route_leaves_road = 0;
+
+ if (!this_->junction_name) {
+ /* nothing to compare, score is 0 */
+ dbg(lvl_debug, "p=%p: no junction name, score 0", p);
+ return 0;
+ }
+
+ /* find predecessor of p, if any */
+ while (p_iter && (p_iter != p)) {
+ if (!p_iter->seg) {
+ p_prev = NULL;
+ break;
+ }
+ p_prev = p_iter;
+ if (p_iter == p_iter->seg->start)
+ p_iter = p_iter->seg->end;
+ else
+ p_iter = p_iter->seg->start;
+ }
+
+ if (!p_prev && (p != start)) {
+ /* not a point on the route */
+ dbg(lvl_debug, "p=%p: not on the route, score 0", p);
+ return 0;
+ }
+ /* check if we have a match for the start of a route segment */
+ if (p->seg) {
+ mr = map_rect_new(p->seg->data.item.map, NULL);
+ if ((item = map_rect_get_item_byid(mr, p->seg->data.item.id_hi, p->seg->data.item.id_lo))) {
+ if (item_attr_get(item, attr_street_name, &attr)) {
+ start_name = g_strdup(attr.u.str);
+ // TODO crude comparison in need of refinement
+ if (!strcmp(this_->junction_name, attr.u.str))
+ has_start_match = 1;
+ }
+ if (item_attr_get(item, attr_street_name_systematic, &attr))
+ start_ref = g_strdup(attr.u.str);
+ }
+ map_rect_destroy(mr);
+ }
+
+ /* check if we have a match for the end of a route segment */
+ if (p_prev && p_prev->seg) {
+ mr = map_rect_new(p_prev->seg->data.item.map, NULL);
+ if ((item = map_rect_get_item_byid(mr, p_prev->seg->data.item.id_hi, p_prev->seg->data.item.id_lo))) {
+ if (item_attr_get(item, attr_street_name, &attr)) {
+ end_name = g_strdup(attr.u.str);
+ // TODO crude comparison in need of refinement
+ if (!strcmp(this_->junction_name, attr.u.str))
+ has_end_match = 1;
+ }
+ if (item_attr_get(item, attr_street_name_systematic, &attr))
+ end_ref = g_strdup(attr.u.str);
+ }
+ map_rect_destroy(mr);
+ }
+
+ /*
+ * If we have both a start match and an end match, the point is in the middle of a stretch of road which matches
+ * the junction name. Regardless of whether we want that stretch included in the route or not, a middle point
+ * cannot be an end point.
+ */
+ if (has_start_match && has_end_match) {
+ dbg(lvl_debug, "p=%p: both start and end match, score 0", p);
+ g_free(start_name);
+ g_free(start_ref);
+ g_free(end_name);
+ g_free(end_ref);
+ return 0;
+ }
+
+ if (start_name && end_name)
+ // TODO crude comparison in need of refinement
+ route_follows_road |= !strcmp(start_name, end_name);
+
+ if (start_ref && end_ref)
+ route_follows_road |= !compare_name_systematic(start_ref, end_ref);
+
+ /* check if we have a match for an off-route segment */
+ /* TODO consolidate these two loops, which differ only in their loop statement while the body is identical */
+ for (s = p->start; s && !(has_offroute_match && route_leaves_road); s = s->start_next) {
+ if ((p->seg == s) || (p_prev && (p_prev->seg == s)))
+ /* segments is on the route, skip */
+ continue;
+ mr = map_rect_new(s->data.item.map, NULL);
+ if ((item = map_rect_get_item_byid(mr, s->data.item.id_hi, s->data.item.id_lo))) {
+ if (item_attr_get(item, attr_street_name, &attr)) {
+ // TODO crude comparison in need of refinement
+ if (!strcmp(this_->junction_name, attr.u.str))
+ has_offroute_match = 1;
+ if (start_name)
+ route_leaves_road |= !strcmp(start_name, attr.u.str);
+ if (end_name)
+ route_leaves_road |= !strcmp(end_name, attr.u.str);
+ }
+ if (!route_leaves_road && item_attr_get(item, attr_street_name_systematic, &attr)) {
+ if (start_ref)
+ route_leaves_road |= !compare_name_systematic(start_ref, attr.u.str);
+ if (end_ref)
+ route_leaves_road |= !compare_name_systematic(end_ref, attr.u.str);
+ }
+ }
+ map_rect_destroy(mr);
+ }
+
+ for (s = p->end; s && !(has_offroute_match && route_leaves_road); s = s->end_next) {
+ if ((p->seg == s) || (p_prev && (p_prev->seg == s)))
+ /* segments is on the route, skip */
+ continue;
+ mr = map_rect_new(s->data.item.map, NULL);
+ if ((item = map_rect_get_item_byid(mr, s->data.item.id_hi, s->data.item.id_lo))) {
+ if (item_attr_get(item, attr_street_name, &attr)) {
+ // TODO crude comparison in need of refinement
+ if (!strcmp(this_->junction_name, attr.u.str))
+ has_offroute_match = 1;
+ if (start_name)
+ route_leaves_road |= !strcmp(start_name, attr.u.str);
+ if (end_name)
+ route_leaves_road |= !strcmp(end_name, attr.u.str);
+ }
+ if (!route_leaves_road && item_attr_get(item, attr_street_name_systematic, &attr)) {
+ if (start_ref)
+ route_leaves_road |= !compare_name_systematic(start_ref, attr.u.str);
+ if (end_ref)
+ route_leaves_road |= !compare_name_systematic(end_ref, attr.u.str);
+ }
+ }
+ map_rect_destroy(mr);
+ }
+
+ dbg(lvl_debug,
+ "p=%p: %s %s → %s %s\nhas_offroute_match=%d, has_start_match=%d, has_end_match=%d, route_follows_road=%d, route_leaves_road=%d",
+ p, end_ref, end_name, start_ref, start_name,
+ has_offroute_match, has_start_match, has_end_match, route_follows_road, route_leaves_road);
+
+ g_free(start_name);
+ g_free(start_ref);
+ g_free(end_name);
+ g_free(end_ref);
+
+ if (route_leaves_road && !route_follows_road)
+ want_start_match = !match_start;
+ /* TODO decide how to handle ambiguous situations (both true or both false), currently we include the segment */
+
+ if (has_offroute_match) {
+ if (has_start_match || has_end_match) {
+ /* we cannot have multiple matches in different categories */
+ /* TODO maybe we can: e.g. one segment of the crossing road got added to the route, the other did not */
+ dbg(lvl_debug, "p=%p: both off-route and start/end match, score 0", p);
+ return 0;
+ }
+ } else {
+ if ((want_start_match && !has_start_match) || (!want_start_match && !has_end_match)) {
+ /* no match in requested category */
+ dbg(lvl_debug, "p=%p: no match in requested category, score 0", p);
+ return 0;
+ }
+ }
+
+ dbg(lvl_debug, "p=%p: score 100 (full score)", p);
+ return 100;
+}
+
+/**
+ * @brief Returns the cost of the segment in the given direction.
+ *
+ * The cost is calculated based on the length of the segment and a penalty which depends on the score.
+ * A segment with the maximum score of 100 is not penalized, i.e. its cost is equal to its length. A
+ * segment with a zero score is penalized with a factor of `PENALTY_SEGMENT_MATCH`. For scores in between, a
+ * penalty factor between 1 and `PENALTY_SEGMENT_MATCH` is applied.
+ *
+ * If the segment is impassable in the given direction, the cost is always `INT_MAX`.
+ *
+ * @param over The segment
+ * @param data Data for the segments added to the map
+ * @param dir The direction (positive numbers indicate positive direction)
+ *
+ * @return The cost of the segment
+ */
+static int traffic_route_get_seg_cost(struct route_graph_segment *over, struct seg_data * data, int dir) {
+ if (over->data.flags & (dir >= 0 ? AF_ONEWAYREV : AF_ONEWAY))
+ return INT_MAX;
+ if (dir > 0 && (over->start->flags & RP_TURN_RESTRICTION))
+ return INT_MAX;
+ if (dir < 0 && (over->end->flags & RP_TURN_RESTRICTION))
+ return INT_MAX;
+ if ((over->data.item.type < route_item_first) || (over->data.item.type > route_item_last))
+ return INT_MAX;
+ /* at least a partial match is required for access flags */
+ if (!(over->data.flags & data->flags & AF_ALL))
+ return INT_MAX;
+
+ return over->data.len * (100 - over->data.score) * (PENALTY_SEGMENT_MATCH - 1) / 100 + over->data.len;
+}
+
+/**
+ * @brief Determines the “point triple” for a traffic location.
+ *
+ * Each traffic location is defined by up to three points:
+ * \li a start and end point, and an optional auxiliary point in between
+ * \li a single point, with one or two auxiliary points (one before, one after)
+ * \li a start and end point, and a third point which is outside the location
+ *
+ * This method determines these three points, puts them in the order in which they are encountered and
+ * returns a bit field indicating the end points. If a point in the array is NULL or refers to an
+ * auxiliary point, its corresponding bit is not set. The following values are returned:
+ * \li 2: Point location, the middle point is the actual point
+ * \li 3: Point-to-point location from the first to the second point; the third point is an auxiliary
+ * point outside the location
+ * \li 5: Point-to-point location from the first to the last point; the second point (if not NULL) is an
+ * auxiliary point located in between
+ * \li 6: Point-to-point location from the second to the third point; the first point is an auxiliary
+ * point outside the location
+ *
+ * @param this_ The location
+ * @param coords Points to an array which will receive pointers to the coordinates. The array must be
+ * able to store three pointers.
+ *
+ * @return A bit field indicating the end points for the location
+ */
+static int traffic_location_get_point_triple(struct traffic_location * this_, struct coord_geo ** coords) {
+ /* Which members of coords are the end points */
+ int ret = 0;
+
+ /* Projected coordinates */
+ struct coord c_from, c_to, c_not_via;
+
+ if (this_->at) {
+ coords[0] = this_->from ? &this_->from->coord : NULL;
+ coords[1] = &this_->at->coord;
+ coords[2] = this_->to ? &this_->to->coord : NULL;
+ ret = 1 << 1;
+ } else if (this_->via) {
+ coords[0] = this_->from ? &this_->from->coord : NULL;
+ coords[1] = &this_->via->coord;
+ coords[2] = this_->to ? &this_->to->coord : NULL;
+ ret = (1 << 2) | (1 << 0);
+ } else if (this_->not_via) {
+ /*
+ * If not_via is set, we calculate a route either for not_via-from-to or for from-to-not_via,
+ * then trim the ends. The order of points is determined by the distance between not_via and the
+ * other two points.
+ */
+ if (!this_->from || !this_->to) {
+ coords[0] = NULL;
+ coords[1] = NULL;
+ coords[2] = NULL;
+ return ret;
+ }
+ transform_from_geo(projection_mg, &this_->from->coord, &c_from);
+ transform_from_geo(projection_mg, &this_->to->coord, &c_to);
+ transform_from_geo(projection_mg, &this_->not_via->coord, &c_not_via);
+ if (transform_distance(projection_mg, &c_from, &c_not_via)
+ < transform_distance(projection_mg, &c_to, &c_not_via)) {
+ coords[0] = &this_->not_via->coord;
+ coords[1] = &this_->from->coord;
+ coords[2] = &this_->to->coord;
+ } else {
+ coords[0] = &this_->from->coord;
+ coords[1] = &this_->to->coord;
+ coords[2] = &this_->not_via->coord;
+ }
+ } else {
+ coords[0] = this_->from ? &this_->from->coord : NULL;
+ coords[1] = NULL;
+ coords[2] = this_->to ? &this_->to->coord : NULL;
+ ret = (1 << 2) | (1 << 0);
+ }
+ return ret;
+}
+
+/**
+ * @brief Sets the rectangle enclosing all points of a location
+ *
+ * @param this_ The traffic location
+ * @param coords The point triple, can be NULL
+ */
+static void traffic_location_set_enclosing_rect(struct traffic_location * this_, struct coord_geo ** coords) {
+ struct coord_geo * sw;
+ struct coord_geo * ne;
+ struct coord_geo * int_coords[] = {NULL, NULL, NULL};
+ int i;
+
+ if (this_->priv->sw && this_->priv->ne)
+ return;
+
+ if (!coords) {
+ coords = &int_coords[0];
+ traffic_location_get_point_triple(this_, coords);
+ }
+
+ if (!this_->priv->sw) {
+ sw = g_new0(struct coord_geo, 1);
+ sw->lat = INT_MAX;
+ sw->lng = INT_MAX;
+ for (i = 0; i < 3; i++)
+ if (coords[i]) {
+ if (coords[i]->lat < sw->lat)
+ sw->lat = coords[i]->lat;
+ if (coords[i]->lng < sw->lng)
+ sw->lng = coords[i]->lng;
+ }
+ this_->priv->sw = sw;
+ }
+
+ if (!this_->priv->ne) {
+ ne = g_new0(struct coord_geo, 1);
+ ne->lat = -INT_MAX;
+ ne->lng = -INT_MAX;
+ for (i = 0; i < 3; i++)
+ if (coords[i]) {
+ if (coords[i]->lat > ne->lat)
+ ne->lat = coords[i]->lat;
+ if (coords[i]->lng > ne->lng)
+ ne->lng = coords[i]->lng;
+ }
+ this_->priv->ne = ne;
+ }
+}
+
+/**
+ * @brief Opens a map rectangle around the end points of the traffic location.
+ *
+ * Prior to calling this function, the caller must ensure `rg->m` points to the map to be used, and the enclosing
+ * rectangle for the traffic location has been set (e.g. by calling `traffic_location_set_enclosing_rect()`).
+ *
+ * @param this_ The traffic location
+ * @param rg The route graph
+ *
+ * @return NULL on failure, the map selection on success
+ */
+static struct map_rect * traffic_location_open_map_rect(struct traffic_location * this_, struct route_graph * rg) {
+ /* Corners of the enclosing rectangle, in Mercator coordinates */
+ struct coord c1, c2;
+
+ transform_from_geo(map_projection(rg->m), this_->priv->sw, &c1);
+ transform_from_geo(map_projection(rg->m), this_->priv->ne, &c2);
+
+ rg->sel = route_rect(ROUTE_ORDER, &c1, &c2, ROUTE_RECT_DIST_REL, ROUTE_RECT_DIST_ABS);
+
+ if (!rg->sel)
+ return NULL;
+ rg->mr = map_rect_new(rg->m, rg->sel);
+ if (!rg->mr) {
+ map_selection_destroy(rg->sel);
+ rg->sel = NULL;
+ }
+ return rg->mr;
+}
+
+/**
+ * @brief Populates a route graph.
+ *
+ * This adds all routable segments in the enclosing rectangle of the location (plus a safety margin) to
+ * the route graph.
+ *
+ * @param rg The route graph
+ * @param ms The mapset to read the ramps from
+ */
+static void traffic_location_populate_route_graph(struct traffic_location * this_, struct route_graph * rg,
+ struct mapset * ms) {
+ /* The item being processed */
+ struct item *item;
+
+ /* Mercator coordinates of current and previous point */
+ struct coord c, l;
+
+ /* Data for the route graph segment */
+ struct route_graph_segment_data data;
+
+ /* The length of the current segment */
+#ifdef AVOID_FLOAT
+ int len;
+#else
+ double len;
+#endif
+
+ /* Whether the current item is segmented */
+ int segmented;
+
+ /* Default value assumed for access flags if we cannot get flags for the item, nor for the item type */
+ int default_flags_value = AF_ALL;
+
+ /* Default flags assumed for the current item type */
+ int *default_flags;
+
+ /* Holds an attribute retrieved from the current item */
+ struct attr attr;
+
+ /* Start and end point of the current way or segment */
+ struct route_graph_point *s_pnt, *e_pnt;
+
+ traffic_location_set_enclosing_rect(this_, NULL);
+
+ rg->h = mapset_open(ms);
+
+ while ((rg->m = mapset_next(rg->h, 2))) {
+ if (!traffic_location_open_map_rect(this_, rg))
+ continue;
+ while ((item = map_rect_get_item(rg->mr))) {
+ if (item->type == type_street_turn_restriction_no || item->type == type_street_turn_restriction_only)
+ route_graph_add_turn_restriction(rg, item);
+ else if ((item->type < route_item_first) || (item->type > route_item_last))
+ continue;
+ if (item_get_default_flags(item->type)) {
+
+ item_coord_rewind(item);
+ if (item_coord_get(item, &l, 1)) {
+ data.score = traffic_location_match_attributes(this_, item);
+ data.flags=0;
+ data.offset=1;
+ data.maxspeed=-1;
+ data.item=item;
+ len = 0;
+ segmented = 0;
+
+ if (!(default_flags = item_get_default_flags(item->type)))
+ default_flags = &default_flags_value;
+ if (item_attr_get(item, attr_flags, &attr)) {
+ data.flags = attr.u.num;
+ segmented = (data.flags & AF_SEGMENTED);
+ } else
+ data.flags = *default_flags;
+
+ if ((data.flags & AF_SPEED_LIMIT) && (item_attr_get(item, attr_maxspeed, &attr)))
+ data.maxspeed = attr.u.num;
+
+ /* clear flags we're not copying here */
+ data.flags &= ~(AF_DANGEROUS_GOODS | AF_SIZE_OR_WEIGHT_LIMIT);
+
+ s_pnt = route_graph_add_point(rg, &l);
+
+ if (!segmented) {
+ while (item_coord_get(item, &c, 1)) {
+ len += transform_distance(map_projection(item->map), &l, &c);
+ l = c;
+ }
+ e_pnt = route_graph_add_point(rg, &l);
+ dbg_assert(len >= 0);
+ data.len = len;
+ if (!route_graph_segment_is_duplicate(s_pnt, &data))
+ route_graph_add_segment(rg, s_pnt, e_pnt, &data);
+ } else {
+ int isseg, rc;
+ int sc = 0;
+ do {
+ isseg = item_coord_is_node(item);
+ rc = item_coord_get(item, &c, 1);
+ if (rc) {
+ len += transform_distance(map_projection(item->map), &l, &c);
+ l = c;
+ if (isseg) {
+ e_pnt = route_graph_add_point(rg, &l);
+ data.len = len;
+ if (!route_graph_segment_is_duplicate(s_pnt, &data))
+ route_graph_add_segment(rg, s_pnt, e_pnt, &data);
+ data.offset++;
+ s_pnt = route_graph_add_point(rg, &l);
+ len = 0;
+ }
+ }
+ } while(rc);
+ e_pnt = route_graph_add_point(rg, &l);
+ dbg_assert(len >= 0);
+ sc++;
+ data.len = len;
+ if (!route_graph_segment_is_duplicate(s_pnt, &data))
+ route_graph_add_segment(rg, s_pnt, e_pnt, &data);
+ }
+ }
+ }
+ }
+ map_selection_destroy(rg->sel);
+ rg->sel = NULL;
+ map_rect_destroy(rg->mr);
+ rg->mr = NULL;
+ }
+ route_graph_build_done(rg, 0);
+}
+
+/**
+ * @brief Builds a new route graph for traffic location matching.
+ *
+ * Traffic location matching is done by using a modified routing algorithm to identify the segments
+ * affected by a traffic message.
+ *
+ * @param this_ The location to match to the map
+ * @param ms The mapset to use for the route graph
+ *
+ * @return A route graph. The caller is responsible for destroying the route graph and all related data
+ * when it is no longer needed.
+ */
+static struct route_graph * traffic_location_get_route_graph(struct traffic_location * this_,
+ struct mapset * ms) {
+ struct route_graph *rg;
+
+ traffic_location_set_enclosing_rect(this_, NULL);
+
+ rg = g_new0(struct route_graph, 1);
+
+ rg->done_cb = NULL;
+ rg->busy = 1;
+
+ /* build the route graph */
+ traffic_location_populate_route_graph(this_, rg, ms);
+
+ return rg;
+}
+
+/**
+ * @brief Whether two traffic points are equal.
+ *
+ * Comparison is done solely on coordinates and requires a precise match. This can result in two points
+ * being reported as not equal, even though the locations using these points may translate to the same
+ * segments later.
+ *
+ * @return true if `l` and `r` are equal, false if not
+ */
+static int traffic_point_equals(struct traffic_point * l, struct traffic_point * r) {
+ if (l->coord.lat != r->coord.lat)
+ return 0;
+ if (l->coord.lng != r->coord.lng)
+ return 0;
+ return 1;
+}
+
+/**
+ * @brief Whether two traffic locations are equal.
+ *
+ * Only directionality, the `ramps` member and reference points are considered for comparison; auxiliary
+ * data (such as road names, road types and additional TMC information) is ignored.
+ *
+ * When in doubt, this function errs on the side of inequality, i.e. when equivalence cannot be reliably
+ * determined, the locations will be reported as not equal, even though they may translate to the same
+ * segments later.
+ *
+ * @return true if `l` and `r` are equal, false if not
+ */
+static int traffic_location_equals(struct traffic_location * l, struct traffic_location * r) {
+ /* directionality and ramps must match for locations to be considered equal */
+ if (l->directionality != r->directionality)
+ return 0;
+ if (l->ramps != r->ramps)
+ return 0;
+
+ /* locations must have the same points set to be considered equal */
+ if (!l->from != !r->from)
+ return 0;
+ if (!l->to != !r->to)
+ return 0;
+ if (!l->at != !r->at)
+ return 0;
+ if (!l->via != !r->via)
+ return 0;
+ if (!l->not_via != !r->not_via)
+ return 0;
+
+ /* both locations have the same points set, compare them */
+ if (l->from && !traffic_point_equals(l->from, r->from))
+ return 0;
+ if (l->to && !traffic_point_equals(l->to, r->to))
+ return 0;
+ if (l->at && !traffic_point_equals(l->at, r->at))
+ return 0;
+ if (l->via && !traffic_point_equals(l->via, r->via))
+ return 0;
+ if (l->not_via && !traffic_point_equals(l->not_via, r->not_via))
+ return 0;
+
+ /* No differences found, consider locations equal */
+ return 1;
+}
+
+/**
+ * @brief Determines the path between two reference points in a route graph.
+ *
+ * The reference points `from` and `to` are the beginning and end of the path and do not necessarily
+ * coincide with the `from` and `to` members of the location. For a point location with an auxiliary
+ * point, one will instead be the `at` member of the location; when examining the opposite direction of
+ * a bidirectional location, `from` and `to` will be swapped with respect to the location.
+ *
+ * The coordinates contained in the reference points are typically approximate, i.e. they do not
+ * precisely coincide with a point in the route graph.
+ *
+ * When this function returns, the route graph will be flooded, i.e. every point will have a cost
+ * assigned to it and the `seg` member for each point will be set, indicating the next segment on which
+ * to proceed in order to reach the destination. For the last point in the graph, `seg` will be `NULL`.
+ * Unlike in common routing, the last point will have a nonzero cost if `to` does not coincide with a
+ * point in the route graph.
+ *
+ * The cost of each node represents the cost to reach `to`. The cost is calculated in
+ * `traffic_route_get_seg_cost()` for actual segments, and distance (with a penalty factor) for the
+ * offroad connection from the last point in the graph to `to`.
+ *
+ * To obtain the path, start with the return value. Its `seg` member points to the next segment. Either
+ * the `start` or the `end` value of that segment will coincide with the point currently being examined;
+ * the other of the two is the point at the other end. Repeat this until you reach a point whose `seg`
+ * member is `NULL`.
+ *
+ * This function can be run multiple times against the same route graph but with different reference
+ * points. It is safe to call with `NULL` passed for one or both reference points, in which case `NULL`
+ * will be returned.
+ *
+ * The caller is responsible for freeing up the data structures passed to this function when they are no
+ * longer needed.
+ *
+ * @param rg The route graph
+ * @param data Data for the segments added to the map
+ * @param c_start Start coordinates
+ * @param c_dst Destination coordinates
+ * @param start_existing Start point of an existing route (whose points will not be used)
+ *
+ * @return The point in the route graph at which the path begins, or `NULL` if no path was found.
+ */
+static struct route_graph_point * traffic_route_flood_graph(struct route_graph * rg, struct seg_data * data,
+ struct coord * c_start, struct coord * c_dst, struct route_graph_point * start_existing) {
+ struct route_graph_point * ret;
+
+ int i;
+
+ GList * existing = NULL;
+
+ /* This heap will hold all points with "temporarily" calculated costs */
+ struct fibheap *heap;
+
+ /* Cost of the start position */
+ int start_value;
+
+ /* The point currently being examined */
+ struct route_graph_point *p;
+
+ /* Cost of point being examined, other end of segment being examined, segment */
+ int min, new, val;
+
+ /* The segment currently being examined */
+ struct route_graph_segment *s = NULL;
+
+ if (!c_start || !c_dst)
+ return NULL;
+
+ /* store points of existing route */
+ if (start_existing) {
+ p = start_existing;
+ while (p) {
+ /* Do not exclude the last point (seg==NULL) from the heap as that may result in the existing route not
+ * being joined properly to the new one */
+ if (p->seg)
+ existing = g_list_prepend(existing, p);
+ if (!p->seg)
+ p = NULL;
+ else if (p == p->seg->start)
+ p = p->seg->end;
+ else
+ p = p->seg->start;
+ }
+ }
+
+ /* prime the route graph */
+ heap = fh_makekeyheap();
+
+ start_value = PENALTY_OFFROAD * transform_distance(projection_mg, c_start, c_dst);
+ ret = NULL;
+
+ dbg(lvl_debug, "start flooding route graph, start_value=%d", start_value);
+
+ for (i = 0; i < HASH_SIZE; i++) {
+ p = rg->hash[i];
+ while (p) {
+ if (!g_list_find(existing, p)) {
+ if (!(p->flags & RP_TURN_RESTRICTION)) {
+ p->value = PENALTY_OFFROAD * transform_distance(projection_mg, &p->c, c_dst);
+ p->el = fh_insertkey(heap, p->value, p);
+ } else {
+ /* ignore points which are part of turn restrictions */
+ p->value = INT_MAX;
+ p->el = NULL;
+ }
+ p->seg = NULL;
+ }
+ p = p->hash_next;
+ }
+ }
+
+ /* flood the route graph */
+ for (;;) {
+ p = fh_extractmin(heap); /* Starting Dijkstra by selecting the point with the minimum costs on the heap */
+ if (!p) /* There are no more points with temporarily calculated costs, Dijkstra has finished */
+ break;
+
+ dbg(lvl_debug, "p=%p, value=%d", p, p->value);
+
+ min = p->value;
+ p->el = NULL; /* This point is permanently calculated now, we've taken it out of the heap */
+ s = p->start;
+ while (s) { /* Iterating all the segments leading away from our point to update the points at their ends */
+ val = traffic_route_get_seg_cost(s, data, -1);
+
+ dbg(lvl_debug, " negative segment, val=%d", val);
+
+ if (val != INT_MAX) {
+ new = min + val;
+ if (new < s->end->value) { /* We've found a less costly way to reach the end of s, update it */
+ s->end->value = new;
+ s->end->seg = s;
+ if (!s->end->el) {
+ s->end->el = fh_insertkey(heap, new, s->end);
+ } else {
+ fh_replacekey(heap, s->end->el, new);
+ }
+ new += PENALTY_OFFROAD * transform_distance(projection_mg, &s->end->c, c_start);
+ if (new < start_value) { /* We've found a less costly way from the start point, update */
+ start_value = new;
+ ret = s->end;
+ }
+ }
+ }
+ s = s->start_next;
+ }
+ s = p->end;
+ while (s) { /* Doing the same as above with the segments leading towards our point */
+ val = traffic_route_get_seg_cost(s, data, 1);
+
+ dbg(lvl_debug, " positive segment, val=%d", val);
+
+ if (val != INT_MAX) {
+ new = min + val;
+ if (new < s->start->value) {
+ s->start->value = new;
+ s->start->seg = s;
+ if (!s->start->el) {
+ s->start->el = fh_insertkey(heap, new, s->start);
+ } else {
+ fh_replacekey(heap, s->start->el, new);
+ }
+ new += PENALTY_OFFROAD * transform_distance(projection_mg, &s->start->c, c_start);
+ if (new < start_value) {
+ start_value = new;
+ ret = s->start;
+ }
+ }
+ }
+ s = s->end_next;
+ }
+ }
+
+ fh_deleteheap(heap);
+ g_list_free(existing);
+ return ret;
+}
+
+/**
+ * @brief Extends the route beyond its end point.
+ *
+ * This function follows the road beginning at `end`, stopping at the next junction. It can be called
+ * again on the result, again extending it to the next junction.
+ *
+ * To follow the road, each segment is compared to `last` and the segment whose attributes match it is
+ * chosen, provided such a segment can be determined without ambiguity.
+ *
+ * When the function returns, all points added to the route will have their `seg` member set. To append
+ * the new stretch to the route, set the `seg` member of its last point to the return value. After that,
+ * the extended route can be walked in the usual manner.
+ *
+ * The value of each new point is the value of its predecessor on the route mins the length of the
+ * segment which links the two points. Point values thus continue to decrease along the route, allowing
+ * comparisons or difference calculations to be performed on the extended route. Note that this may
+ * result in points having negative values.
+ *
+ * @param rg The flooded route graph
+ * @param last The last segment in the current route graph (either the `start` or the `end` member of
+ * this segment must be equal to the `end` argument)
+ * @param end The last point of the current route graph (the `seg` member of this point must be NULL)
+ *
+ * @return The next segment in the route, or `NULL` if the route cannot be extended.
+ */
+static struct route_graph_segment * traffic_route_append(struct route_graph *rg,
+ struct route_graph_segment * last, struct route_graph_point * end) {
+ struct route_graph_segment * ret = NULL, * s = last, * s_cmp, * s_next;
+ struct route_graph_point * p = end;
+ int num_seg;
+ int id_match;
+ int is_ambiguous;
+
+ if (!end) {
+ dbg(lvl_error, "end point cannot be NULL");
+ return NULL;
+ }
+ if (end->seg) {
+ dbg(lvl_error, "end point cannot have a next segment");
+ return NULL;
+ }
+
+ if ((end != last->end) && (end != last->start)) {
+ dbg(lvl_error, "last segment must begin or end at end point");
+ return NULL;
+ }
+
+ while (1) {
+ num_seg = 0;
+ id_match = 0;
+ is_ambiguous = 0;
+ s_next = NULL;
+ for (s_cmp = p->start; s_cmp; s_cmp = s_cmp->start_next) {
+ num_seg++;
+ if ((s_cmp == s) || (s_cmp->data.flags & AF_ONEWAYREV) || (s_cmp->end->flags & RP_TURN_RESTRICTION))
+ continue;
+ if (item_is_equal_id(s_cmp->data.item, s->data.item)) {
+ s_next = s_cmp;
+ id_match = 1;
+ } else if ((s_cmp->data.item.type == s->data.item.type) && !id_match && !is_ambiguous) {
+ if (s_next) {
+ s_next = NULL;
+ is_ambiguous = 1;
+ } else
+ s_next = s_cmp;
+ }
+ }
+ for (s_cmp = p->end; s_cmp; s_cmp = s_cmp->end_next) {
+ num_seg++;
+ if ((s_cmp == s) || (s_cmp->data.flags & AF_ONEWAY) || (s_cmp->end->flags & RP_TURN_RESTRICTION))
+ continue;
+ if (item_is_equal_id(s_cmp->data.item, s->data.item)) {
+ s_next = s_cmp;
+ id_match = 1;
+ } else if ((s_cmp->data.item.type == s->data.item.type) && !id_match && !is_ambiguous) {
+ if (s_next) {
+ s_next = NULL;
+ is_ambiguous = 1;
+ } else
+ s_next = s_cmp;
+ }
+ }
+
+ /* cancel if we are past end and have hit a junction */
+ if ((p != end) && (num_seg > 2))
+ break;
+
+ /* update links and move one step further */
+ if (p != end)
+ p->seg = s_next;
+ else
+ ret = s_next;
+ if (s_next) {
+ if (p == s_next->start) {
+ s_next->end->value = p->value - s_next->data.len;
+ p = s_next->end;
+ } else {
+ s_next->start->value = p->value - s_next->data.len;
+ p = s_next->start;
+ }
+ s = s_next;
+ } else
+ break;
+ }
+ p->seg = NULL;
+ dbg(lvl_debug, "return, last=%p, ret=%p", last, ret);
+ return ret;
+}
+
+/**
+ * @brief Extends the route beyond its start point.
+ *
+ * This function follows the road leading towards `start` backwards, stopping at the next junction. It
+ * can be called again on the result, again extending it to the next junction.
+ *
+ * To follow the road, each segment is compared to `start->seg` and the segment whose attributes match
+ * it is chosen, provided such a segment can be determined without ambiguity.
+ *
+ * When the function returns, all points added to the route will have their `seg` member set so the
+ * extended route can be walked in the usual manner.
+ *
+ * @param rg The flooded route graph
+ * @param start The current start of the route
+ *
+ * @return The start of the extended route, or `NULL` if the route cannot be extended (in which case
+ * `start` continues to be the start of the route).
+ */
+static struct route_graph_point * traffic_route_prepend(struct route_graph * rg,
+ struct route_graph_point * start) {
+ struct route_graph_point * ret = start;
+ struct route_graph_segment * s, * s_cmp, * s_prev = NULL;
+ int num_seg;
+ int id_match;
+ int is_ambiguous;
+
+ dbg(lvl_debug, "At %p (%d), start", start, start ? start->value : -1);
+ if (!start)
+ return NULL;
+
+ s = start->seg;
+
+ while (s) {
+ num_seg = 0;
+ id_match = 0;
+ is_ambiguous = 0;
+ for (s_cmp = ret->start; s_cmp; s_cmp = s_cmp->start_next) {
+ num_seg++;
+ if (s_cmp == s)
+ continue;
+ if (s_cmp->data.flags & AF_ONEWAY)
+ continue;
+ if (s_cmp->end->seg != s_cmp)
+ continue;
+ if (item_is_equal_id(s_cmp->data.item, s->data.item)) {
+ s_prev = s_cmp;
+ id_match = 1;
+ } else if ((s_cmp->data.item.type == s->data.item.type) && !id_match && !is_ambiguous) {
+ if (s_prev) {
+ s_prev = NULL;
+ is_ambiguous = 1;
+ } else
+ s_prev = s_cmp;
+ }
+ }
+ for (s_cmp = ret->end; s_cmp; s_cmp = s_cmp->end_next) {
+ num_seg++;
+ if (s_cmp == s)
+ continue;
+ if (s_cmp->data.flags & AF_ONEWAYREV)
+ continue;
+ if (s_cmp->start->seg != s_cmp)
+ continue;
+ if (item_is_equal_id(s_cmp->data.item, s->data.item)) {
+ s_prev = s_cmp;
+ id_match = 1;
+ } else if ((s_cmp->data.item.type == s->data.item.type) && !id_match && !is_ambiguous) {
+ if (s_prev) {
+ s_prev = NULL;
+ is_ambiguous = 1;
+ } else
+ s_prev = s_cmp;
+ }
+ }
+
+ /* cancel if we are past start and ret is a junction */
+ if ((ret != start) && (num_seg > 2))
+ break;
+
+ /* move s and ret one step further and update links */
+ s = s_prev;
+ if (s) {
+ if (ret == s->start) {
+ ret = s->end;
+ dbg(lvl_debug, "At %p (%d -> %d)", ret, ret->value, s->start->value + s->data.len);
+ ret->value = s->start->value + s->data.len;
+ } else {
+ ret = s->start;
+ dbg(lvl_debug, "At %p (%d -> %d)", ret, ret->value, s->end->value + s->data.len);
+ ret->value = s->end->value + s->data.len;
+ }
+ ret->seg = s;
+ s_prev = NULL;
+ }
+ }
+ dbg(lvl_debug, "return, start=%p, ret=%p", start, ret);
+ return ret;
+}
+
+/**
+ * @brief Returns one of the traffic location’s points.
+ *
+ * @param this_ The traffic location
+ * @param point The point of the traffic location to retrieve (0 = from, 1 = at, 2 = to, 16 = start, 17 = end)
+ *
+ * @return The matched points, or NULL if the requested point does not exist
+ */
+static struct traffic_point * traffic_location_get_point(struct traffic_location * this_, int point) {
+ /* The point from the location to match */
+ struct traffic_point * trpoint = NULL;
+
+ switch(point) {
+ case 0:
+ trpoint = this_->from;
+ break;
+ case 1:
+ trpoint = this_->at;
+ break;
+ case 2:
+ trpoint = this_->to;
+ break;
+ case 16:
+ trpoint = this_->from ? this_->from : this_->at;
+ break;
+ case 17:
+ trpoint = this_->to ? this_->to : this_->at;
+ break;
+ default:
+ break;
+ }
+
+ return trpoint;
+}
+
+/**
+ * @brief Compares a given point to the traffic location and returns a score.
+ *
+ * This method obtains all points at coordinates `c` from the map_rect used to build the route graph, compares their
+ * attributes to those supplied with the location, assigns a match score from 0 (no matching attributes) to 100 (all
+ * supplied attributes match) and returns the highest score obtained. If no matching point is found, 0 is returned.
+ *
+ * @param this_ The traffic location
+ * @param p The route graph point to examine for matches
+ * @param point The point of the traffic location to use for matching (0 = from, 1 = at, 2 = to, 16 = start, 17 = end)
+ * @param rg The route graph
+ * @param start The first point of the path
+ * @param match_start True to evaluate for the start point of a route, false for the end point
+ * @param ms The mapset to read the items from
+ *
+ * @return A score from 0 (worst) to 100 (best).
+ */
+static int traffic_location_get_point_match(struct traffic_location * this_, struct route_graph_point * p, int point,
+ struct route_graph * rg, struct route_graph_point * start, int match_start, struct mapset * ms) {
+ int ret = 0;
+
+ /* The point from the location to match */
+ struct traffic_point * trpoint = NULL;
+
+ /* The attribute matching score for the current item */
+ int score;
+
+ trpoint = traffic_location_get_point(this_, point);
+
+ if (!trpoint)
+ return 0;
+
+ /* First examine route graph points and connected segments */
+ score = traffic_point_match_segment_attributes(trpoint, p, start, match_start);
+ if (ret < score)
+ ret = score;
+ return ret;
+}
+
+/**
+ * @brief Returns points from the route graph which match a traffic location.
+ *
+ * This method obtains point items from the map_rect from which the route graph was built and compares
+ * their attributes to those supplied with the location. Each point is assigned a match score, from 0
+ * (no matching attributes) to 100 (all supplied attributes match), and a list of all points with a
+ * nonzero score is returned.
+ *
+ * Points which have no corresponding map item (i.e. points which have no additional attributes) are not included in
+ * the result and must be analyzed separately if needed.
+ *
+ * @param this_ The traffic location
+ * @param point The point of the traffic location to use for matching (0 = from, 1 = at, 2 = to, 16 = start, 17 = end)
+ * @param rg The route graph
+ * @param start The first point of the path
+ * @param match_start True to evaluate for the start point of a route, false for the end point
+ * @param ms The mapset to read the items from
+ *
+ * @return The matched points as a `GList`. The `data` member of each item points to a `struct point_data` for the point.
+ */
+static GList * traffic_location_get_matching_points(struct traffic_location * this_, int point,
+ struct route_graph * rg, struct route_graph_point * start, int match_start, struct mapset * ms) {
+ GList * ret = NULL;
+
+ /* The point from the location to match */
+ struct traffic_point * trpoint = NULL;
+
+ /* The item being processed */
+ struct item *item;
+
+ /* Mercator coordinates of current and previous point */
+ struct coord c;
+
+ /* The corresponding point in the route graph */
+ struct route_graph_point * p;
+
+ /* The attribute matching score for the current item */
+ int score;
+
+ /* Data for the current point */
+ struct point_data * data;
+
+ trpoint = traffic_location_get_point(this_, point);
+
+ if (!trpoint)
+ return NULL;
+
+ traffic_location_set_enclosing_rect(this_, NULL);
+
+ rg->h = mapset_open(ms);
+
+ while ((rg->m = mapset_next(rg->h, 2))) {
+ if (!traffic_location_open_map_rect(this_, rg))
+ continue;
+ while ((item = map_rect_get_item(rg->mr))) {
+ /* exclude non-point items */
+ if ((item->type < type_town_label) || (item->type >= type_line))
+ continue;
+
+ /* exclude items from which we can't obtain a coordinate pair */
+ if (!item_coord_get(item, &c, 1))
+ continue;
+
+ /* exclude items not in the route graph (points with turn restrictions are ignored) */
+ p = route_graph_get_point(rg, &c);
+ while (p && (p->flags & RP_TURN_RESTRICTION))
+ p = route_graph_get_point_next(rg, &c, p);
+ if (!p)
+ continue;
+
+ /* determine score */
+ score = traffic_point_match_attributes(trpoint, item);
+
+ /* exclude items with a zero score */
+ if (!score)
+ continue;
+
+ dbg(lvl_debug, "adding item, score: %d", score);
+
+ do {
+ if (!(p->flags & RP_TURN_RESTRICTION)) {
+ data = g_new0(struct point_data, 1);
+ data->score = score;
+ data->p = p;
+
+ ret = g_list_append(ret, data);
+ }
+ } while ((p = route_graph_get_point_next(rg, &c, p)));
+ }
+ map_selection_destroy(rg->sel);
+ rg->sel = NULL;
+ map_rect_destroy(rg->mr);
+ rg->mr = NULL;
+ }
+ route_graph_build_done(rg, 1);
+
+ return ret;
+}
+
+/**
+ * @brief Whether the contents of a location are valid.
+ *
+ * This identifies any malformed locations in which mandatory members are not set.
+ *
+ * @return true if the locations is valid, false if it is malformed
+ */
+static int traffic_location_is_valid(struct traffic_location * this_) {
+ if (!this_->at && !(this_->from && this_->to))
+ return 0;
+ return 1;
+}
+
+/**
+ * @brief Whether the current point is a candidate for low-res endpoint matching.
+ *
+ * @param this_ The point to examine
+ * @param s_prev The route segment leading to `this_` (NULL for the start point)
+ */
+static int route_graph_point_is_endpoint_candidate(struct route_graph_point *this_,
+ struct route_graph_segment *s_prev) {
+ int ret;
+
+ /* Whether we are at a junction of 3 or more segments */
+ int is_junction;
+
+ /* Segment used for comparison */
+ struct route_graph_segment *s_cmp;
+
+ /* Current segment */
+ struct route_graph_segment *s = this_->seg;
+
+ if (!s_prev || !s)
+ /* the first and last points are always candidates */
+ ret = 1;
+ else
+ /* detect tunnel portals */
+ ret = ((s->data.flags & AF_UNDERGROUND) != (s_prev->data.flags & AF_UNDERGROUND));
+ if (!ret) {
+ /* detect junctions */
+ is_junction = (s && s_prev) ? 0 : -1;
+ for (s_cmp = this_->start; s_cmp; s_cmp = s_cmp->start_next) {
+ if ((s_cmp != s) && (s_cmp != s_prev))
+ is_junction += 1;
+ }
+ for (s_cmp = this_->end; s_cmp; s_cmp = s_cmp->end_next) {
+ if ((s_cmp != s) && (s_cmp != s_prev))
+ is_junction += 1;
+ }
+ ret = (is_junction > 0);
+ }
+ return ret;
+}
+
+/**
+ * @brief Generates segments affected by a traffic message.
+ *
+ * This translates the approximate coordinates in the `from`, `at`, `to`, `via` and `not_via` members of
+ * the location to one or more map segments, using both the raw coordinates and the auxiliary information
+ * contained in the location. Each segment is stored in the map, if not already present, and a link is
+ * stored with the message.
+ *
+ * @param this_ The traffic message
+ * @param ms The mapset to use for matching
+ * @param data Data for the segments added to the map
+ * @param map The traffic map
+ * @param route The route affected by the changes
+ *
+ * @return `true` if the locations were matched successfully, `false` if there was a failure.
+ */
+static int traffic_message_add_segments(struct traffic_message * this_, struct mapset * ms, struct seg_data * data,
+ struct map *map, struct route * route) {
+ int i;
+
+ struct coord_geo * coords[] = {NULL, NULL, NULL};
+ struct coord * pcoords[] = {NULL, NULL, NULL};
+
+ /* How many point pairs coords contains (number of members minus one) */
+ int point_pairs = -1;
+
+ /* Which members of coords are the end points */
+ int endpoints = 0;
+
+ /* The direction (positive or negative) */
+ int dir = 1;
+
+ /* Start point for the route path */
+ struct route_graph_point * p_start = NULL;
+
+ /* Current and previous segment */
+ struct route_graph_segment *s = NULL;
+ struct route_graph_segment *s_prev;
+
+ /* Iterator for the route path */
+ struct route_graph_point *p_iter;
+
+ /* route graph for simplified routing */
+ struct route_graph *rg;
+
+ /* Coordinate count for matched segment */
+ int ccnt;
+
+ /* Coordinates of matched segment and pointer into it, order as read from map */
+ struct coord *c, ca[2048];
+
+ /* Coordinates of matched segment, sorted */
+ struct coord *cd, *cs;
+
+ /* Speed calculated in various ways */
+ int maxspeed, speed, penalized_speed, factor_speed;
+
+ /* Delay for the current segment */
+ int delay;
+
+ /* Number of new segments and existing segments */
+ int count = 0, prev_count;
+
+ /* Length of location */
+ int len;
+
+ /* The message's previous list of items */
+ struct item ** prev_items;
+
+ /* The next item in the message's list of items */
+ struct item ** next_item;
+
+ /* Flags for the next item to add */
+ int flags;
+
+ /* The last item added */
+ struct item * item;
+
+ /* Projected coordinates of start and end points of the actual location
+ * (if at is set, both point to the same coordinates) */
+ struct coord * c_from, * c_to;
+
+ /* Matched points */
+ GList * points;
+ GList * points_iter;
+
+ /* The corresponding point data */
+ struct point_data * pd;
+
+ /* The match score of the current point */
+ int score;
+
+ /* Current and minimum cost to reference point */
+ int val, minval;
+
+ /* Start of extended route */
+ struct route_graph_point * start_new;
+
+ /* Last segment of the route (before extension) */
+ struct route_graph_segment * s_last = NULL;
+
+ /* Aligned points */
+ struct route_graph_point * p_from;
+ struct route_graph_point * p_to;
+
+ dbg(lvl_debug, "*****checkpoint ADD-1");
+ if (!data) {
+ dbg(lvl_error, "no data for segments, aborting");
+ return 0;
+ }
+
+ if (this_->location->ramps != location_ramps_none)
+ /* TODO Ramps, not supported yet */
+ return 0;
+
+ /* Main carriageway */
+
+ dbg(lvl_debug, "*****checkpoint ADD-2");
+ /* get point triple and enclosing rectangle */
+ endpoints = traffic_location_get_point_triple(this_->location, &coords[0]);
+ if (!endpoints) {
+ dbg(lvl_error, "invalid location (mandatory points missing)");
+ return 0;
+ }
+ traffic_location_set_enclosing_rect(this_->location, &coords[0]);
+ for (i = 0; i < 3; i++)
+ if (coords[i]) {
+ pcoords[i] = g_new0(struct coord, 1);
+ transform_from_geo(projection_mg, coords[i], pcoords[i]);
+ point_pairs++;
+ }
+
+ if (this_->location->at && !(this_->location->from || this_->location->to))
+ /* TODO Point location with no auxiliary points, not supported yet */
+ return 0;
+
+ dbg(lvl_debug, "*****checkpoint ADD-3");
+ rg = traffic_location_get_route_graph(this_->location, ms);
+
+ /* transform coordinates */
+ c_from = (endpoints & 4) ? pcoords[0] : pcoords[1];
+ c_to = (endpoints & 1) ? pcoords[2] : pcoords[1];
+
+ /* determine segments */
+ dbg(lvl_debug, "*****checkpoint ADD-4 (loop start)");
+ while (1) { /* once for each direction (loop logic at the end) */
+ dbg(lvl_debug, "*****checkpoint ADD-4.1");
+ if (point_pairs == 1) {
+ if (dir > 0)
+ p_start = traffic_route_flood_graph(rg, data,
+ pcoords[0] ? pcoords[0] : pcoords[1],
+ pcoords[2] ? pcoords[2] : pcoords[1], NULL);
+ else
+ p_start = traffic_route_flood_graph(rg, data,
+ pcoords[2] ? pcoords[2] : pcoords[1],
+ pcoords[0] ? pcoords[0] : pcoords[1], NULL);
+ dbg(lvl_debug, "*****checkpoint ADD-4.1.1");
+ } else if (point_pairs == 2) {
+ /*
+ * If we have more than two points, create the route in two stages (from the first to the second point,
+ * then from the second to the third point) and concatenate them. This could easily be extended to any
+ * number of points, provided they are spaced sufficiently far apart to calculate a route between each pair
+ * of subsequent points.
+ * This will create a kind of “Frankenstein route” in which the cost of points does not decrease
+ * continuously but has an upward leap as we pass the middle point. This is not an issue as long as we do
+ * not do any further processing based on point cost (which we currently don’t).
+ * If the route needs to be extended beyond the start point, this has to be done after the first stage,
+ * as doing so relies on the route graph for that stage.
+ */
+ /* TODO handle cases in which the route goes through the "third" point
+ * (this should not happen; if it does, we need to detect and fix it) */
+ if (dir > 0)
+ p_start = traffic_route_flood_graph(rg, data, pcoords[0], pcoords[1], NULL);
+ else
+ p_start = traffic_route_flood_graph(rg, data, pcoords[2], pcoords[1], NULL);
+ if ((this_->location->fuzziness == location_fuzziness_low_res)
+ || this_->location->at || this_->location->not_via) {
+ /* extend start to next junction */
+ start_new = traffic_route_prepend(rg, p_start);
+ if (start_new)
+ p_start = start_new;
+ }
+ if (dir > 0) {
+ if (!p_start) {
+ /* fallback if calculating the first piece of the route failed */
+ p_start = traffic_route_flood_graph(rg, data, pcoords[1], pcoords[2], NULL);
+ start_new = traffic_route_prepend(rg, p_start);
+ } else
+ traffic_route_flood_graph(rg, data, pcoords[1], pcoords[2], p_start);
+ } else {
+ if (!p_start) {
+ /* fallback if calculating the first piece of the route failed */
+ p_start = traffic_route_flood_graph(rg, data, pcoords[1], pcoords[0], NULL);
+ start_new = traffic_route_prepend(rg, p_start);
+ } else
+ traffic_route_flood_graph(rg, data, pcoords[1], pcoords[0], p_start);
+ }
+ dbg(lvl_debug, "*****checkpoint ADD-4.1.2");
+ }
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.2");
+ /* tweak ends (find the point where the ramp touches the main road) */
+ if ((this_->location->fuzziness == location_fuzziness_low_res)
+ || this_->location->at || this_->location->not_via) {
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.1");
+ /* tweak end point */
+ if (this_->location->at)
+ points = traffic_location_get_matching_points(this_->location, 1, rg, p_start, 0, ms);
+ else if (dir > 0)
+ points = traffic_location_get_matching_points(this_->location, 2, rg, p_start, 0, ms);
+ else
+ points = traffic_location_get_matching_points(this_->location, 0, rg, p_start, 0, ms);
+ if (!p_start) {
+ dbg(lvl_error, "end point not found on map");
+ for (points_iter = points; points_iter; points_iter = g_list_next(points_iter))
+ g_free(points_iter->data);
+ g_list_free(points);
+ route_graph_free_points(rg);
+ route_graph_free_segments(rg);
+ g_free(rg);
+ for (i = 0; i < 3; i++)
+ g_free(pcoords[i]);
+ return 0;
+ }
+ s = p_start ? p_start->seg : NULL;
+ p_iter = p_start;
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.2");
+ /* extend end to next junction */
+ for (s = p_start ? p_start->seg : NULL; s; s = p_iter->seg) {
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.2.1, s=%p, p_iter=%p (%d)", s, p_iter, p_iter ? p_iter->value : INT_MAX);
+ s_last = s;
+ if (s->start == p_iter)
+ p_iter = s->end;
+ else
+ p_iter = s->start;
+ }
+ s = traffic_route_append(rg, s_last, p_iter);
+ p_iter->seg = s;
+
+ s = p_start ? p_start->seg : NULL;
+ s_prev = NULL;
+ p_iter = p_start;
+ minval = INT_MAX;
+ p_to = NULL;
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.3");
+ struct coord_geo wgs;
+ while (p_iter) {
+ transform_to_geo(projection_mg, &(p_iter->c), &wgs);
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.3, p_iter=%p (value=%d)\nhttps://www.openstreetmap.org?mlat=%f&mlon=%f/#map=13",
+ p_iter, p_iter->value, wgs.lat, wgs.lng);
+ if (route_graph_point_is_endpoint_candidate(p_iter, s_prev)) {
+ score = traffic_location_get_point_match(this_->location, p_iter,
+ this_->location->at ? 1 : (dir > 0) ? 2 : 0,
+ rg, p_start, 0, ms);
+ pd = NULL;
+ for (points_iter = points; points_iter && (score < 100); points_iter = g_list_next(points_iter)) {
+ pd = (struct point_data *) points_iter->data;
+ if ((pd->p == p_iter) && (pd->score > score))
+ score = pd->score;
+ }
+ val = transform_distance(projection_mg, &p_iter->c, (dir > 0) ? c_to : c_from);
+ val += (val * (100 - score) * (PENALTY_POINT_MATCH) / 100);
+ if (val < minval) {
+ minval = val;
+ p_to = p_iter;
+ dbg(lvl_debug, "candidate end point found, point %p, value %d (score %d)", p_iter, val, score);
+ }
+ }
+
+ if (!s)
+ p_iter = NULL;
+ else {
+ p_iter = (s->start == p_iter) ? s->end : s->start;
+ s_prev = s;
+ s = p_iter->seg;
+ }
+ }
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.4");
+ for (points_iter = points; points_iter; points_iter = g_list_next(points_iter))
+ g_free(points_iter->data);
+ g_list_free(points);
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.5");
+ /* tweak start point */
+ if (this_->location->at)
+ points = traffic_location_get_matching_points(this_->location, 1, rg, p_start, 1, ms);
+ else if (dir > 0)
+ points = traffic_location_get_matching_points(this_->location, 0, rg, p_start, 1, ms);
+ else
+ points = traffic_location_get_matching_points(this_->location, 2, rg, p_start, 1, ms);
+ s_prev = NULL;
+ minval = INT_MAX;
+ p_from = NULL;
+
+ transform_to_geo(projection_mg, &(p_start->c), &wgs);
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.6, p_start=%p\nhttps://www.openstreetmap.org?mlat=%f&mlon=%f/#map=13",
+ p_start, wgs.lat, wgs.lng);
+ if (point_pairs == 1) {
+ /* extend start to next junction (if we have more than two points, this has already been done) */
+ start_new = traffic_route_prepend(rg, p_start);
+ if (start_new)
+ p_start = start_new;
+ }
+
+ s = p_start ? p_start->seg : NULL;
+ p_iter = p_start;
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.7");
+ while (p_iter) {
+ transform_to_geo(projection_mg, &(p_iter->c), &wgs);
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.7, p_iter=%p (value=%d)\nhttps://www.openstreetmap.org?mlat=%f&mlon=%f/#map=13",
+ p_iter, p_iter->value, wgs.lat, wgs.lng);
+ if (route_graph_point_is_endpoint_candidate(p_iter, s_prev)) {
+ score = traffic_location_get_point_match(this_->location, p_iter,
+ this_->location->at ? 1 : (dir > 0) ? 0 : 2,
+ rg, p_start, 1, ms);
+ pd = NULL;
+ for (points_iter = points; points_iter && (score < 100); points_iter = g_list_next(points_iter)) {
+ pd = (struct point_data *) points_iter->data;
+ if ((pd->p == p_iter) && (pd->score > score))
+ score = pd->score;
+ }
+ val = transform_distance(projection_mg, &p_iter->c, (dir > 0) ? c_from : c_to);
+ /* TODO does attribute matching make sense for the start segment? */
+ val += (val * (100 - score) * (PENALTY_POINT_MATCH) / 100);
+ if (val < minval) {
+ minval = val;
+ p_from = p_iter;
+ dbg(lvl_debug, "candidate start point found, point %p, value %d (score %d)",
+ p_iter, val, score);
+ }
+ }
+
+ if (!s)
+ p_iter = NULL;
+ else {
+ p_iter = (s->start == p_iter) ? s->end : s->start;
+ s_prev = s;
+ s = p_iter->seg;
+ }
+ }
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.8");
+ for (points_iter = points; points_iter; points_iter = g_list_next(points_iter))
+ g_free(points_iter->data);
+ g_list_free(points);
+
+ if (!p_from)
+ p_from = p_start;
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9");
+ /* ensure we have at least one segment */
+ if ((p_from == p_to) || !p_from->seg) {
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.1");
+ p_iter = p_start;
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.2");
+ while (p_iter->seg) {
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.2.1, p_iter=%p, p_iter->seg=%p", p_iter, p_iter ? p_iter->seg : NULL);
+ if (p_iter == p_iter->seg->start) {
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.2.2 (p_iter == p_iter->seg->start)");
+ /* compare to the last point: because p_to may be NULL here, we're comparing to
+ * p_from instead, which at this point is guaranteed to be non-NULL and either
+ * equal to p_to or without a successor, making it the designated end point. */
+ if (p_iter->seg->end == p_from)
+ break;
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.2.3");
+ p_iter = p_iter->seg->end;
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.2.4");
+ } else {
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.2.2 (p_iter != p_iter->seg->start)");
+ if (p_iter->seg->start == p_from)
+ break;
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.2.3");
+ p_iter = p_iter->seg->start;
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.2.4");
+ }
+ }
+ if (p_from->seg) {
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.3, p_from->seg is non-NULL");
+ /* decide between predecessor and successor of the point, based on proximity */
+ p_to = (p_from == p_from->seg->end) ? p_from->seg->start : p_from->seg->end;
+ if (transform_distance(projection_mg, &p_to->c, pcoords[1] ? pcoords[1] : pcoords[2])
+ > transform_distance(projection_mg, &p_iter->c, pcoords[1] ? pcoords[1] : pcoords[2])) {
+ p_to = p_from;
+ p_from = p_iter;
+ }
+ } else {
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.9.3, p_from->seg is NULL");
+ /* p_from has no successor, the segment goes from its predecessor to p_from */
+ p_to = p_from;
+ p_from = p_iter;
+ }
+ }
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.2.10");
+ /* if we have identified a last point, drop everything after it from the path */
+ if (p_to)
+ p_to->seg = NULL;
+
+ /* set first point to be the start point */
+ if (p_from != p_start) {
+ dbg(lvl_debug, "changing p_start from %p to %p", p_start, p_from);
+ }
+ p_start = p_from;
+ }
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.3");
+ /* calculate route */
+ s = p_start ? p_start->seg : NULL;
+ p_iter = p_start;
+
+ if (!s)
+ dbg(lvl_error, "no segments");
+
+ /* count segments and calculate length */
+ prev_count = count;
+ count = 0;
+ len = 0;
+ dbg(lvl_debug, "*****checkpoint ADD-4.4");
+ while (s) {
+ dbg(lvl_debug, "*****checkpoint ADD-4.4.1 (#%d, p_iter=%p, s=%p, next %p)",
+ count, p_iter, s, (s->start == p_iter) ? s->end : s->start);
+ count++;
+ len += s->data.len;
+ if (s->start == p_iter)
+ p_iter = s->end;
+ else
+ p_iter = s->start;
+ s = p_iter->seg;
+ }
+ dbg(lvl_debug, "*****checkpoint ADD-4.5");
+
+ /* add segments */
+
+ s = p_start ? p_start->seg : NULL;
+ p_iter = p_start;
+
+ if (this_->priv->items) {
+ prev_items = this_->priv->items;
+ this_->priv->items = g_new0(struct item *, count + prev_count + 1);
+ memcpy(this_->priv->items, prev_items, sizeof(struct item *) * prev_count);
+ next_item = this_->priv->items + prev_count;
+ g_free(prev_items);
+ } else {
+ this_->priv->items = g_new0(struct item *, count + 1);
+ next_item = this_->priv->items;
+ }
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.6 (loop start)");
+ while (s) {
+ ccnt = item_coord_get_within_range(&s->data.item, ca, 2047, &s->start->c, &s->end->c);
+ c = ca;
+ cs = g_new0(struct coord, ccnt);
+ cd = cs;
+
+ speed = data->speed;
+ if ((data->speed != INT_MAX) || data->speed_penalty || (data->speed_factor != 100)) {
+ if (s->data.flags & AF_SPEED_LIMIT) {
+ maxspeed = RSD_MAXSPEED(&s->data);
+ } else {
+ switch (s->data.item.type) {
+ case type_highway_land:
+ case type_street_n_lanes:
+ maxspeed = 100;
+ break;
+ case type_highway_city:
+ case type_street_4_land:
+ maxspeed = 80;
+ break;
+ case type_street_3_land:
+ maxspeed = 70;
+ break;
+ case type_street_2_land:
+ maxspeed = 65;
+ break;
+ case type_street_1_land:
+ maxspeed = 60;
+ break;
+ case type_street_4_city:
+ maxspeed = 50;
+ break;
+ case type_ramp:
+ case type_street_3_city:
+ case type_street_unkn:
+ maxspeed = 40;
+ break;
+ case type_street_2_city:
+ case type_track_paved:
+ maxspeed = 30;
+ break;
+ case type_track:
+ case type_cycleway:
+ maxspeed = 20;
+ break;
+ case type_roundabout:
+ case type_street_1_city:
+ case type_street_0:
+ case type_living_street:
+ case type_street_service:
+ case type_street_parking_lane:
+ case type_path:
+ case type_track_ground:
+ case type_track_gravelled:
+ case type_track_unpaved:
+ case type_track_grass:
+ case type_bridleway:
+ maxspeed = 10;
+ break;
+ case type_street_pedestrian:
+ case type_footway:
+ case type_steps:
+ maxspeed = 5;
+ break;
+ default:
+ maxspeed = 50;
+ }
+ }
+ penalized_speed = maxspeed - data->speed_penalty;
+ if (penalized_speed < 5)
+ penalized_speed = 5;
+ factor_speed = maxspeed * data->speed_factor / 100;
+ if (speed > penalized_speed)
+ speed = penalized_speed;
+ if (speed > factor_speed)
+ speed = factor_speed;
+ }
+
+ if (data->delay)
+ delay = data->delay * s->data.len / len;
+ else
+ delay = data->delay;
+
+ for (i = 0; i < ccnt; i++) {
+ *cd++ = *c++;
+ }
+
+ if (s->start == p_iter) {
+ /* forward direction */
+ p_iter = s->end;
+ flags = data->flags | (s->data.flags & AF_ONEWAYMASK)
+ | (data->dir == location_dir_one ? AF_ONEWAY : 0);
+ } else {
+ /* backward direction */
+ p_iter = s->start;
+ flags = data->flags | (s->data.flags & AF_ONEWAYMASK)
+ | (data->dir == location_dir_one ? AF_ONEWAYREV : 0);
+ }
+
+
+ item = tm_add_item(map, type_traffic_distortion, s->data.item.id_hi, s->data.item.id_lo, flags, data->attrs, cs, ccnt,
+ this_->id);
+
+ tm_item_add_message_data(item, this_->id, speed, delay, data->attrs, route);
+
+ g_free(cs);
+
+ *next_item = tm_item_ref(item);
+ next_item++;
+
+ s = p_iter->seg;
+ }
+
+ dbg(lvl_debug, "*****checkpoint ADD-4.7");
+ if ((this_->location->directionality == location_dir_one) || (dir < 0))
+ break;
+
+ dir = -1;
+ }
+
+ dbg(lvl_debug, "*****checkpoint ADD-5");
+ route_graph_free_points(rg);
+ route_graph_free_segments(rg);
+ g_free(rg);
+
+ for (i = 0; i < 3; i++)
+ g_free(pcoords[i]);
+
+ dbg(lvl_debug, "*****checkpoint ADD-6");
+ return 1;
+}
+
+/**
+ * @brief Prints a dump of a message to debug output.
+ *
+ * @param this_ The message to dump
+ */
+static void traffic_message_dump_to_stderr(struct traffic_message * this_) {
+ int i, j;
+ char * point_names[5] = {"From", "At", "Via", "Not via", "To"};
+ struct traffic_point * points[5];
+ char * timestamp = NULL;
+
+ if (!this_) {
+ dbg(lvl_debug, "(null)");
+ return;
+ }
+
+ if (this_->location) {
+ points[0] = this_->location->from;
+ points[1] = this_->location->at;
+ points[2] = this_->location->via;
+ points[3] = this_->location->not_via;
+ points[4] = this_->location->to;
+ } else
+ memset(&points, 0, sizeof(struct traffic_point *) * 5);
+
+ dbg(lvl_debug, "id='%s', is_cancellation=%d, is_forecast=%d",
+ this_->id, this_->is_cancellation, this_->is_forecast);
+ if (this_->receive_time) {
+ timestamp = time_to_iso8601(this_->receive_time);
+ dbg(lvl_debug, " First received: %s (%ld)", timestamp, this_->receive_time);
+ g_free(timestamp);
+ }
+ if (this_->update_time) {
+ timestamp = time_to_iso8601(this_->update_time);
+ dbg(lvl_debug, " Last updated: %s (%ld)", timestamp, this_->update_time);
+ g_free(timestamp);
+ }
+ if (this_->start_time) {
+ timestamp = time_to_iso8601(this_->start_time);
+ dbg(lvl_debug, " Start time: %s (%ld)", timestamp, this_->start_time);
+ g_free(timestamp);
+ }
+ if (this_->end_time) {
+ timestamp = time_to_iso8601(this_->end_time);
+ dbg(lvl_debug, " End time: %s (%ld)", timestamp, this_->end_time);
+ g_free(timestamp);
+ }
+ if (this_->expiration_time) {
+ timestamp = time_to_iso8601(this_->expiration_time);
+ dbg(lvl_debug, " Expires: %s (%ld)", timestamp, this_->expiration_time);
+ g_free(timestamp);
+ }
+
+ /* dump replaced message IDs */
+ dbg(lvl_debug, " replaced_count=%d",
+ this_->replaced_count);
+ for (i = 0; i < this_->replaced_count; i++) {
+ dbg(lvl_debug, " Replaces: '%s'", this_->replaces[i]);
+ }
+
+ /* dump location */
+ if (this_->location) {
+ dbg(lvl_debug, " Location: road_type='%s', road_ref='%s', road_name='%s'",
+ item_to_name(this_->location->road_type), this_->location->road_ref,
+ this_->location->road_name);
+ dbg(lvl_debug, " directionality=%d, destination='%s', direction='%s'",
+ this_->location->directionality, this_->location->destination, this_->location->direction);
+ dbg(lvl_debug, " fuzziness=%s, ramps=%s, tmc_table='%s', tmc_direction=%+d",
+ location_fuzziness_to_string(this_->location->fuzziness),
+ location_ramps_to_string(this_->location->ramps), this_->location->tmc_table,
+ this_->location->tmc_direction);
+ for (i = 0; i < 5; i++) {
+ if (points[i]) {
+ dbg(lvl_debug, " %s: lat=%.5f, lng=%.5f",
+ point_names[i], points[i]->coord.lat, points[i]->coord.lng);
+ dbg(lvl_debug, " junction_name='%s', junction_ref='%s', tmc_id='%s'",
+ points[i]->junction_name, points[i]->junction_ref, points[i]->tmc_id);
+ } else {
+ dbg(lvl_debug, " %s: (null)",
+ point_names[i]);
+ }
+ }
+ } else {
+ dbg(lvl_debug, " Location: null");
+ }
+
+ /* dump events */
+ dbg(lvl_debug, " event_count=%d",
+ this_->event_count);
+ for (i = 0; i < this_->event_count; i++) {
+ dbg(lvl_debug, " Event: event_class=%s, type=%s, length=%d m, speed=%d km/h",
+ event_class_to_string(this_->events[i]->event_class),
+ event_type_to_string(this_->events[i]->type),
+ this_->events[i]->length, this_->events[i]->speed);
+ /* TODO quantifier */
+
+ /* dump supplementary information */
+ dbg(lvl_debug, " si_count=%d",
+ this_->events[i]->si_count);
+ for (j = 0; j < this_->events[i]->si_count; j++) {
+ dbg(lvl_debug, " Supplementary Information: si_class=%s, type=%s",
+ si_class_to_string(this_->events[i]->si[j]->si_class),
+ si_type_to_string(this_->events[i]->si[j]->type));
+ /* TODO quantifier */
+ }
+ }
+}
+
+/**
+ * @brief Whether the contents of a message are valid.
+ *
+ * This identifies any malformed messages in which mandatory members are not set.
+ *
+ * @return true if the message is valid, false if it is malformed
+ */
+static int traffic_message_is_valid(struct traffic_message * this_) {
+ int i;
+ int has_valid_events = 0;
+
+ if (!this_->id || !this_->id[0]) {
+ dbg(lvl_debug, "ID is NULL or empty");
+ return 0;
+ }
+ if (!this_->receive_time || !this_->update_time) {
+ dbg(lvl_debug, "receive_time or update_time not supplied");
+ return 0;
+ }
+ if (!this_->is_cancellation) {
+ if (!this_->expiration_time && !this_->end_time) {
+ dbg(lvl_debug, "not a cancellation, but neither expiration_time nor end_time supplied");
+ return 0;
+ }
+ if (!this_->location) {
+ dbg(lvl_debug, "not a cancellation, but no location supplied");
+ return 0;
+ }
+ if (!traffic_location_is_valid(this_->location)) {
+ dbg(lvl_debug, "not a cancellation, but location is invalid");
+ return 0;
+ }
+ if (!this_->event_count || !this_->events) {
+ dbg(lvl_debug, "not a cancellation, but no events supplied");
+ return 0;
+ }
+ for (i = 0; i < this_->event_count; i++)
+ if (this_->events[i])
+ has_valid_events |= traffic_event_is_valid(this_->events[i]);
+ if (!has_valid_events) {
+ dbg(lvl_debug, "not a cancellation, but all events (%d in total) are invalid", this_->event_count);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+/**
+ * @brief Parses the events of a traffic message.
+ *
+ * @param message The message to parse
+ *
+ * @return A `struct seg_data`, or `NULL` if the message contains no usable information
+ */
+static struct seg_data * traffic_message_parse_events(struct traffic_message * this_) {
+ struct seg_data * ret = NULL;
+
+ int i, j;
+ int has_flags = 0;
+ int flags = 0;
+
+ /* Default assumptions, used only if no explicit values are given */
+ int speed = INT_MAX;
+ int speed_penalty = 0;
+ int speed_factor = 100;
+ int delay = 0;
+
+ for (i = 0; i < this_->event_count; i++) {
+ if (this_->events[i]->speed != INT_MAX) {
+ if (!ret)
+ ret = seg_data_new();
+ if (ret->speed > this_->events[i]->speed)
+ ret->speed = this_->events[i]->speed;
+ }
+ if (this_->events[i]->event_class == event_class_congestion) {
+ switch (this_->events[i]->type) {
+ case event_congestion_heavy_traffic:
+ case event_congestion_traffic_building_up:
+ case event_congestion_traffic_heavier_than_normal:
+ case event_congestion_traffic_much_heavier_than_normal:
+ /* Heavy traffic: assume 10 km/h below the posted limit, unless explicitly specified */
+ if ((this_->events[i]->speed == INT_MAX) && (speed_penalty < 10))
+ speed_penalty = 10;
+ break;
+ case event_congestion_slow_traffic:
+ case event_congestion_traffic_congestion:
+ case event_congestion_traffic_problem:
+ /* Slow traffic or unspecified congestion: assume half the posted limit, unless explicitly specified */
+ if ((this_->events[i]->speed == INT_MAX) && (speed_factor > 50))
+ speed_factor = 50;
+ break;
+ case event_congestion_queue:
+ /* Queuing traffic: assume 20 km/h, unless explicitly specified */
+ if ((this_->events[i]->speed == INT_MAX) && (speed > 20))
+ speed = 20;
+ break;
+ case event_congestion_stationary_traffic:
+ case event_congestion_long_queue:
+ /* Stationary traffic or long queues: assume 5 km/h, unless explicitly specified */
+ if ((this_->events[i]->speed == INT_MAX) && (speed > 5))
+ speed = 5;
+ break;
+ default:
+ break;
+ }
+ } else if (this_->events[i]->event_class == event_class_delay) {
+ switch (this_->events[i]->type) {
+ case event_delay_delay:
+ case event_delay_long_delay:
+ /* Delay or long delay: assume 30 minutes, unless explicitly specified */
+ if (this_->events[i]->quantifier) {
+ if (!ret)
+ ret = seg_data_new();
+ if (ret->delay < this_->events[i]->quantifier->u.q_duration)
+ ret->delay = this_->events[i]->quantifier->u.q_duration;
+ } else if (delay < 18000)
+ delay = 18000;
+ break;
+ case event_delay_very_long_delay:
+ /* Very long delay: assume 1 hour, unless explicitly specified */
+ if (this_->events[i]->quantifier) {
+ if (!ret)
+ ret = seg_data_new();
+ if (ret->delay < this_->events[i]->quantifier->u.q_duration)
+ ret->delay = this_->events[i]->quantifier->u.q_duration;
+ } else if (delay < 36000)
+ delay = 36000;
+ break;
+ case event_delay_several_hours:
+ case event_delay_uncertain_duration:
+ /* Delay of several hours or uncertain duration: assume 3 hours */
+ if (delay < 108000)
+ delay = 108000;
+ break;
+ default:
+ break;
+ }
+ } else if (this_->events[i]->event_class == event_class_restriction) {
+ switch (this_->events[i]->type) {
+ case event_restriction_blocked:
+ case event_restriction_blocked_ahead:
+ case event_restriction_carriageway_blocked:
+ case event_restriction_carriageway_closed:
+ case event_restriction_closed:
+ case event_restriction_closed_ahead:
+ if (!ret)
+ ret = seg_data_new();
+ ret->speed = 0;
+ break;
+ case event_restriction_intermittent_closures:
+ case event_restriction_batch_service:
+ case event_restriction_single_alternate_line_traffic:
+ /* Assume 30% of the posted limit for all of these cases */
+ if (speed_factor > 30)
+ speed_factor = 30;
+ break;
+ case event_restriction_lane_blocked:
+ case event_restriction_lane_closed:
+ case event_restriction_reduced_lanes:
+ /* Assume speed is reduced proportionally to number of lanes, and never higher than 80 */
+ speed = 80;
+ /* TODO determine actual numbers of lanes */
+ speed_factor = 67;
+ break;
+ case event_restriction_contraflow:
+ /* Contraflow: assume 80, unless explicitly specified */
+ speed = 80;
+ break;
+ /* restriction_speed_limit is not in the list: either it comes with a maxspeed attribute, which gets
+ * evaluated regardless of the event it comes with, and if it doesn’t come with one, it carries no
+ * useful information. */
+ default:
+ break;
+ }
+ }
+
+ for (j = 0; j < this_->events[i]->si_count; j++) {
+ switch (this_->events[i]->si[j]->type) {
+ case si_vehicle_all:
+ /* For all vehicles */
+ flags |= AF_ALL;
+ has_flags = 1;
+ break;
+ case si_vehicle_bus:
+ /* For buses only */
+ /* TODO what about other (e.g. chartered) buses? */
+ flags |= AF_PUBLIC_BUS;
+ has_flags = 1;
+ break;
+ case si_vehicle_car:
+ /* For cars only */
+ flags |= AF_CAR;
+ has_flags = 1;
+ break;
+ case si_vehicle_car_with_caravan:
+ /* For cars with caravans only */
+ /* TODO no matching flag */
+ has_flags = 1;
+ break;
+ case si_vehicle_car_with_trailer:
+ /* For cars with trailers only */
+ /* TODO no matching flag */
+ has_flags = 1;
+ break;
+ case si_vehicle_hazmat:
+ /* For hazardous loads only */
+ flags |= AF_DANGEROUS_GOODS;
+ has_flags = 1;
+ break;
+ case si_vehicle_hgv:
+ /* For heavy trucks only */
+ flags |= AF_TRANSPORT_TRUCK | AF_DELIVERY_TRUCK;
+ has_flags = 1;
+ break;
+ case si_vehicle_motor:
+ /* For all motor vehicles */
+ flags |= AF_MOTORIZED_FAST | AF_MOPED;
+ has_flags = 1;
+ break;
+ case si_vehicle_with_trailer:
+ /* For vehicles with trailers only */
+ /* TODO no matching flag */
+ has_flags = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ /* if no vehicle type is specified in supplementary information, assume all */
+ if (!has_flags) {
+ if (this_->location->road_type == type_line_unspecified)
+ flags = AF_ALL;
+ else
+ flags = AF_MOTORIZED_FAST | AF_MOPED;
+ }
+
+ if (!ret)
+ ret = seg_data_new();
+
+ /* use implicit values if no explicit ones are given */
+ if ((speed != INT_MAX) || speed_penalty || (speed_factor != 100) || delay) {
+ if (ret->speed == INT_MAX) {
+ ret->speed = speed;
+ ret->speed_penalty = speed_penalty;
+ ret->speed_factor = speed_factor;
+ }
+ if (!ret->delay)
+ ret->delay = delay;
+ }
+
+ ret->dir = this_->location->directionality;
+ ret->flags = flags;
+
+ return ret;
+}
+
+/**
+ * @brief Removes message data from the items associated with a message.
+ *
+ * Removing message data also triggers an update of the affected items’ attributes.
+ *
+ * It is possible to skip items associated with a particular message from being removed by passing that
+ * message as the `new` argument. This is used for message updates, as this function is called after the
+ * items associated with both the old and the new message have already been updated. Skipping items
+ * referenced by `new` ensures that message data is only stripped from items which are no longer being
+ * referenced by the updated message.
+ *
+ * If the IDs of `old` and `new` differ, `new` is ignored.
+ *
+ * @param old The message whose data it so be removed from its associated items
+ * @param new If non-NULL, items referenced by this message will be skipped, see description
+ * @param route The route affected by the changes
+ */
+static void traffic_message_remove_item_data(struct traffic_message * old, struct traffic_message * new,
+ struct route * route) {
+ int i, j;
+ int skip;
+ struct item_priv * ip;
+ GList * msglist;
+ struct item_msg_priv * msgdata;
+
+ if (new && strcmp(old->id, new->id))
+ new = NULL;
+
+ for (i = 0; old->priv->items && old->priv->items[i]; i++) {
+ skip = 0;
+ if (new)
+ for (j = 0; new->priv->items && new->priv->items[j] && !skip; j++)
+ skip |= (old->priv->items[i] == new->priv->items[j]);
+ if (!skip) {
+ ip = (struct item_priv *) old->priv->items[i]->priv_data;
+ for (msglist = ip->message_data; msglist; ) {
+ msgdata = (struct item_msg_priv *) msglist->data;
+ msglist = g_list_next(msglist);
+ if (!strcmp(msgdata->message_id, old->id)) {
+ ip->message_data = g_list_remove(ip->message_data, msgdata);
+ g_free(msgdata->message_id);
+ g_free(msgdata);
+ }
+ }
+ tm_item_update_attrs(old->priv->items[i], route);
+ }
+ }
+}
+
+/**
+ * @brief Ensures the traffic instance points to valid shared data.
+ *
+ * This method first examines all registered traffic instances to see if one of them has the `shared`
+ * member set. If that is the case, the current instance copies the `shared` pointer of the other
+ * instance. Otherwise a new `struct traffic_shared_priv` is created and its address stored in `shared`.
+ *
+ * Calling this method on a traffic instance with a non-NULL `shared` member has no effect.
+ *
+ * @param this_ The traffic instance
+ */
+static void traffic_set_shared(struct traffic *this_) {
+ struct attr_iter *iter;
+ struct attr attr;
+ struct traffic * traffic;
+
+ dbg(lvl_debug, "enter");
+
+ if (!this_->shared) {
+ iter = navit_attr_iter_new();
+ while (navit_get_attr(this_->navit, attr_traffic, &attr, iter)) {
+ traffic = (struct traffic *) attr.u.navit_object;
+ if (traffic->shared)
+ this_->shared = traffic->shared;
+ }
+ navit_attr_iter_destroy(iter);
+ }
+
+ if (!this_->shared) {
+ this_->shared = g_new0(struct traffic_shared_priv, 1);
+ }
+}
+
+/**
+ * @brief Dumps all currently active traffic messages to an XML file.
+ */
+static void traffic_dump_messages_to_xml(struct traffic * this_) {
+ /* add the configuration directory to the name of the file to use */
+ char *traffic_filename = g_strjoin(NULL, navit_get_user_data_directory(TRUE),
+ "/traffic.xml", NULL);
+ GList * msgiter;
+ struct traffic_message * message;
+ char * strval;
+ char * point_names[5] = {"from", "at", "via", "not_via", "to"};
+ struct traffic_point * points[5];
+ int i, j;
+
+ if (traffic_filename) {
+ FILE *f = fopen(traffic_filename,"w");
+ if (f) {
+ fprintf(f, "<navit_messages>\n");
+ for (msgiter = this_->shared->messages; msgiter; msgiter = g_list_next(msgiter)) {
+ message = (struct traffic_message *) msgiter->data;
+ points[0] = message->location->from;
+ points[1] = message->location->at;
+ points[2] = message->location->via;
+ points[3] = message->location->not_via;
+ points[4] = message->location->to;
+
+ strval = time_to_iso8601(message->receive_time);
+ fprintf(f, " <message id=\"%s\" receive_time=\"%s\"", message->id, strval);
+ g_free(strval);
+ strval = time_to_iso8601(message->update_time);
+ fprintf(f, " update_time=\"%s\"", strval);
+ g_free(strval);
+ if (message->start_time) {
+ strval = time_to_iso8601(message->start_time);
+ fprintf(f, " start_time=\"%s\"", strval);
+ g_free(strval);
+ }
+ if (message->end_time) {
+ strval = time_to_iso8601(message->end_time);
+ fprintf(f, " end_time=\"%s\"", strval);
+ g_free(strval);
+ }
+ if (message->expiration_time) {
+ strval = time_to_iso8601(message->expiration_time);
+ fprintf(f, " expiration_time=\"%s\"", strval);
+ g_free(strval);
+ }
+ if (message->is_forecast)
+ fprintf(f, " forecast=\"%d\"", message->is_forecast);
+ fprintf(f, ">\n");
+
+ fprintf(f, " <location directionality=\"%s\"",
+ message->location->directionality == location_dir_one ? "ONE_DIRECTION" : "BOTH_DIRECTIONS");
+ if (message->location->fuzziness)
+ fprintf(f, " fuzziness=\"%s\"", location_fuzziness_to_string(message->location->fuzziness));
+ if (message->location->ramps)
+ fprintf(f, " ramps=\"%s\"", location_ramps_to_string(message->location->ramps));
+ if (message->location->road_type != type_line_unspecified)
+ fprintf(f, " road_class=\"%s\"", item_to_name(message->location->road_type));
+ if (message->location->road_ref)
+ fprintf(f, " road_ref=\"%s\"", message->location->road_ref);
+ if (message->location->road_name)
+ fprintf(f, " road_name=\"%s\"", message->location->road_name);
+ if (message->location->destination)
+ fprintf(f, " destination=\"%s\"", message->location->destination);
+ if (message->location->direction)
+ fprintf(f, " direction=\"%s\"", message->location->direction);
+ if ((message->location->directionality == location_dir_one)
+ && message->location->tmc_direction)
+ fprintf(f, " tmc_direction=\"%+d\"", message->location->tmc_direction);
+ if (message->location->tmc_table)
+ fprintf(f, " tmc_table=\"%s\"", message->location->tmc_table);
+ fprintf(f, ">\n");
+
+ for (i = 0; i < 5; i++)
+ if (points[i]) {
+ fprintf(f, " <%s", point_names[i]);
+ if (points[i]->junction_name)
+ fprintf(f, " junction_name=\"%s\"", points[i]->junction_name);
+ if (points[i]->junction_ref)
+ fprintf(f, " junction_ref=\"%s\"", points[i]->junction_ref);
+ if (points[i]->tmc_id)
+ fprintf(f, " tmc_id=\"%s\"", points[i]->tmc_id);
+ fprintf(f, ">");
+ fprintf(f, "%+f %+f", points[i]->coord.lat, points[i]->coord.lng);
+ fprintf(f, "</%s>\n", point_names[i]);
+ }
+
+ fprintf(f, " </location>\n");
+
+ fprintf(f, " <events>\n");
+ for (i = 0; i < message->event_count; i++) {
+ fprintf(f, " <event class=\"%s\" type=\"%s\"",
+ event_class_to_string(message->events[i]->event_class),
+ event_type_to_string(message->events[i]->type));
+ if (message->events[i]->length >= 0)
+ fprintf(f, " length=\"%d\"", message->events[i]->length);
+ if (message->events[i]->speed != INT_MAX)
+ fprintf(f, " speed=\"%d\"", message->events[i]->speed);
+ /* TODO message->events[i]->quantifier */
+ fprintf(f, ">\n");
+
+ for (j = 0; j < message->events[i]->si_count; j++) {
+ fprintf(f, " <supplementary_info class=\"%s\" type=\"%s\"",
+ si_class_to_string(message->events[i]->si[j]->si_class),
+ si_type_to_string(message->events[i]->si[j]->type));
+ /* TODO message->events[i]->si[j]->quantifier */
+ fprintf(f, "/>\n");
+ }
+
+ fprintf(f, " </event>\n");
+ }
+ fprintf(f, " </events>\n");
+ fprintf(f, " </message>\n");
+ }
+ fprintf(f, "</navit_messages>\n");
+ fclose(f);
+ } else {
+ dbg(lvl_error,"could not open file for traffic messages");
+
+ } /* else - if (f) */
+ g_free(traffic_filename); /* free the file name */
+ } /* if (traffic_filename) */
+}
+
+/**
+ * @brief Processes new traffic messages.
+ *
+ * This is the internal backend for `traffic_process_messages()`. It is also used internally.
+ *
+ * The behavior of this function can be controlled via flags.
+ *
+ * `PROCESS_MESSAGES_PURGE_EXPIRED` causes expired messages to be purged from the message store after
+ * new messages have been processed. It is intended to be used with timer-triggered calls.
+ *
+ * `PROCESS_MESSAGES_NO_DUMP_STORE` prevents saving of the message store to disk, intended to be used
+ * when reading stored message data on startup.
+ *
+ * Traffic messages are always read from `this->shared->message_queue`. It can be empty, which makes sense e.g. when
+ * the `PROCESS_MESSAGES_PURGE_EXPIRED` flag is used, to just purge expired messages.
+ *
+ * @param this_ The traffic instance
+ * @param flags Flags, see description
+ *
+ * @return A combination of flags, `MESSAGE_UPDATE_MESSAGES` indicating that new messages were processed
+ * and `MESSAGE_UPDATE_SEGMENTS` that segments were changed
+ */
+/* TODO what if the update for a still-valid message expires in the past? */
+static int traffic_process_messages_int(struct traffic * this_, int flags) {
+ /* Start and current time */
+ struct timeval start, now;
+
+ /* Current message */
+ struct traffic_message * message;
+
+ /* Return value */
+ int ret = 0;
+
+ /* Number of messages processed so far */
+ int i = 0;
+
+ /* Iterator over messages */
+ GList * msg_iter;
+
+ /* Stored message being compared */
+ struct traffic_message * stored_msg;
+
+ /* Messages to remove */
+ GList * msgs_to_remove = NULL;
+
+ /* Pointer into messages[i]->replaces */
+ char ** replaces;
+
+ /* Attributes for traffic distortions generated from the current traffic message */
+ struct seg_data * data;
+
+ /* Message replaced by the current one whose segments can be reused */
+ struct traffic_message * swap_candidate;
+
+ /* Temporary store for swapping locations and items */
+ struct traffic_location * swap_location;
+ struct item ** swap_items;
+
+ /* Time elapsed since start */
+ double msec = 0;
+
+ if (this_->shared->message_queue)
+ dbg(lvl_debug, "*****enter, %d messages in queue", g_list_length(this_->shared->message_queue));
+
+ gettimeofday(&start, NULL);
+ for (; this_->shared->message_queue && (msec < TIME_SLICE);
+ this_->shared->message_queue = g_list_remove(this_->shared->message_queue, message)) {
+ message = (struct traffic_message *) this_->shared->message_queue->data;
+ i++;
+ if (message->expiration_time < time(NULL)) {
+ dbg(lvl_debug, "message is no longer valid, ignoring");
+ traffic_message_destroy(message);
+ } else {
+ dbg(lvl_debug, "*****checkpoint PROCESS-1, id='%s'", message->id);
+ ret |= MESSAGE_UPDATE_MESSAGES;
+
+ for (msg_iter = this_->shared->messages; msg_iter; msg_iter = g_list_next(msg_iter)) {
+ stored_msg = (struct traffic_message *) msg_iter->data;
+ if (!strcmp(stored_msg->id, message->id))
+ msgs_to_remove = g_list_append(msgs_to_remove, stored_msg);
+ else
+ for (replaces = ((struct traffic_message *) this_->shared->message_queue->data)->replaces; replaces; replaces++)
+ if (!strcmp(stored_msg->id, *replaces) && !g_list_find(msgs_to_remove, message))
+ msgs_to_remove = g_list_append(msgs_to_remove, stored_msg);
+ }
+
+ if (!message->is_cancellation) {
+ dbg(lvl_debug, "*****checkpoint PROCESS-2");
+ /* if the message is not just a cancellation, store it and match it to the map */
+ data = traffic_message_parse_events(message);
+ swap_candidate = NULL;
+
+ dbg(lvl_debug, "*****checkpoint PROCESS-3");
+ /* check if any of the replaced messages has the same location and segment data */
+ for (msg_iter = msgs_to_remove; msg_iter && !swap_candidate; msg_iter = g_list_next(msg_iter)) {
+ stored_msg = (struct traffic_message *) msg_iter->data;
+ if (seg_data_equals(data, traffic_message_parse_events(stored_msg))
+ && traffic_location_equals(message->location, stored_msg->location))
+ swap_candidate = stored_msg;
+ }
+
+ if (swap_candidate) {
+ dbg(lvl_debug, "*****checkpoint PROCESS-4, swap candidate found");
+ /* reuse location and segments if we are replacing a matching message */
+ swap_location = message->location;
+ swap_items = message->priv->items;
+ message->location = swap_candidate->location;
+ message->priv->items = swap_candidate->priv->items;
+ swap_candidate->location = swap_location;
+ swap_candidate->priv->items = swap_items;
+ } else {
+ dbg(lvl_debug, "*****checkpoint PROCESS-4, need to find matching segments");
+ /* else find matching segments from scratch */
+ traffic_message_add_segments(message, this_->ms, data, this_->map, this_->rt);
+ ret |= MESSAGE_UPDATE_SEGMENTS;
+ }
+
+ g_free(data);
+
+ /* store message */
+ this_->shared->messages = g_list_append(this_->shared->messages, message);
+ dbg(lvl_debug, "*****checkpoint PROCESS-5");
+ }
+
+ /* delete replaced messages */
+ if (msgs_to_remove) {
+ dbg(lvl_debug, "*****checkpoint PROCESS (messages to remove, start)");
+ for (msg_iter = msgs_to_remove; msg_iter; msg_iter = g_list_next(msg_iter)) {
+ stored_msg = (struct traffic_message *) msg_iter->data;
+ if (stored_msg->priv->items)
+ ret |= MESSAGE_UPDATE_SEGMENTS;
+ this_->shared->messages = g_list_remove_all(this_->shared->messages, stored_msg);
+ traffic_message_remove_item_data(stored_msg, message, this_->rt);
+ traffic_message_destroy(stored_msg);
+ }
+
+ g_list_free(msgs_to_remove);
+ msgs_to_remove = NULL;
+ dbg(lvl_debug, "*****checkpoint PROCESS (messages to remove, end)");
+ }
+
+ traffic_message_dump_to_stderr(message);
+
+ if (message->is_cancellation)
+ traffic_message_destroy(message);
+
+ dbg(lvl_debug, "*****checkpoint PROCESS-6");
+ }
+ gettimeofday(&now, NULL);
+ msec = (now.tv_usec - start.tv_usec) / ((double)1000) + (now.tv_sec - start.tv_sec) * 1000;
+ }
+
+ if (i)
+ dbg(lvl_debug, "processed %d message(s), %d still in queue", i, g_list_length(this_->shared->message_queue));
+
+ if (this_->shared->message_queue) {
+ /* if we're in the middle of the queue, trigger a redraw (if needed) and exit */
+ if ((ret & MESSAGE_UPDATE_SEGMENTS) && (navit_get_ready(this_->navit) == 3))
+ navit_draw_async(this_->navit, 1);
+ return ret;
+ } else {
+ /* last pass, remove our idle event and callback */
+ if (this_->idle_ev)
+ event_remove_idle(this_->idle_ev);
+ if (this_->idle_cb)
+ callback_destroy(this_->idle_cb);
+ this_->idle_ev = NULL;
+ this_->idle_cb = NULL;
+ }
+
+ if (flags & PROCESS_MESSAGES_PURGE_EXPIRED) {
+ /* find and remove expired messages */
+ for (msg_iter = this_->shared->messages; msg_iter; msg_iter = g_list_next(msg_iter)) {
+ stored_msg = (struct traffic_message *) msg_iter->data;
+ if (stored_msg->expiration_time < time(NULL))
+ msgs_to_remove = g_list_append(msgs_to_remove, stored_msg);
+ }
+
+ if (msgs_to_remove) {
+ for (msg_iter = msgs_to_remove; msg_iter; msg_iter = g_list_next(msg_iter)) {
+ stored_msg = (struct traffic_message *) msg_iter->data;
+ if (stored_msg->priv->items)
+ ret |= MESSAGE_UPDATE_SEGMENTS;
+ this_->shared->messages = g_list_remove_all(this_->shared->messages, stored_msg);
+ traffic_message_remove_item_data(stored_msg, NULL, this_->rt);
+ traffic_message_destroy(stored_msg);
+ }
+
+ dbg(lvl_debug, "%d message(s) expired", g_list_length(msgs_to_remove));
+
+ g_list_free(msgs_to_remove);
+ }
+ }
+
+ if (ret && !(flags & PROCESS_MESSAGES_NO_DUMP_STORE)) {
+#ifdef TRAFFIC_DEBUG
+ /* dump map if messages have been added, deleted or expired */
+ tm_dump_to_textfile(this_->map);
+#endif
+
+ /* dump message store if new messages have been received */
+ traffic_dump_messages_to_xml(this_);
+ }
+
+ /* TODO see comment on route_recalculate_partial about thread-safety */
+ route_recalculate_partial(this_->rt);
+
+ /* trigger redraw if segments have changed */
+ if ((ret & MESSAGE_UPDATE_SEGMENTS) && (navit_get_ready(this_->navit) == 3))
+ navit_draw_async(this_->navit, 1);
+
+ return ret;
+}
+
+/**
+ * @brief The loop function for the traffic module.
+ *
+ * This function polls backends for new messages and processes them by inserting, removing or modifying
+ * traffic distortions and triggering route recalculations as needed.
+ */
+static void traffic_loop(struct traffic * this_) {
+ struct traffic_message ** messages;
+ struct traffic_message ** cur_msg;
+
+ messages = this_->meth.get_messages(this_->priv);
+ for (cur_msg = messages; cur_msg && *cur_msg; cur_msg++)
+ this_->shared->message_queue = g_list_append(this_->shared->message_queue, *cur_msg);
+ g_free(messages);
+
+ /* make sure traffic_process_messages_int runs at least once to ensure purging of expired messages */
+ if (this_->shared->message_queue) {
+ if (this_->idle_ev)
+ event_remove_idle(this_->idle_ev);
+ if (this_->idle_cb)
+ callback_destroy(this_->idle_cb);
+ this_->idle_cb = callback_new_2(callback_cast(traffic_process_messages_int),
+ this_, PROCESS_MESSAGES_PURGE_EXPIRED);
+ this_->idle_ev = event_add_idle(50, this_->idle_cb);
+ } else
+ traffic_process_messages_int(this_, PROCESS_MESSAGES_PURGE_EXPIRED);
+}
+
+/**
+ * @brief Instantiates the traffic plugin
+ *
+ * At a minimum, `attrs` must contain a `type` attribute matching one of the available traffic plugins.
+ *
+ * @param parent The parent, usually the Navit instance
+ * @param attrs The attributes for the plugin
+ *
+ * @return A `traffic` instance.
+ */
+static struct traffic * traffic_new(struct attr *parent, struct attr **attrs) {
+ struct traffic *this_;
+ struct traffic_priv *(*traffic_new)(struct navit *nav, struct traffic_methods *meth,
+ struct attr **attrs, struct callback_list *cbl);
+ struct attr *attr;
+
+ attr = attr_search(attrs, NULL, attr_type);
+ if (!attr) {
+ dbg(lvl_error, "type missing");
+ return NULL;
+ }
+ dbg(lvl_debug, "type='%s'", attr->u.str);
+ traffic_new = plugin_get_category_traffic(attr->u.str);
+ dbg(lvl_debug, "new=%p", traffic_new);
+ if (!traffic_new) {
+ dbg(lvl_error, "wrong type '%s'", attr->u.str);
+ return NULL;
+ }
+ this_ = (struct traffic *) navit_object_new(attrs, &traffic_func, sizeof(struct traffic));
+ if (parent->type == attr_navit)
+ this_->navit = parent->u.navit;
+ else {
+ dbg(lvl_error, "wrong parent type '%s', only navit is permitted", attr_to_name(parent->type));
+ navit_object_destroy((struct navit_object *) this_);
+ return NULL;
+ }
+
+ this_->priv = traffic_new(parent->u.navit, &this_->meth, this_->attrs, NULL);
+ dbg(lvl_debug, "get_messages=%p", this_->meth.get_messages);
+ dbg(lvl_debug, "priv=%p", this_->priv);
+ if (!this_->priv) {
+ dbg(lvl_error, "plugin initialization failed");
+ navit_object_destroy((struct navit_object *) this_);
+ return NULL;
+ }
+ navit_object_ref((struct navit_object *) this_);
+ dbg(lvl_debug,"return %p", this_);
+
+ // TODO do this once and cycle through all plugins
+ this_->callback = callback_new_1(callback_cast(traffic_loop), this_);
+ this_->timeout = event_add_timeout(1000, 1, this_->callback); // TODO make interval configurable
+
+ this_->map = NULL;
+
+ if (!this_->shared)
+ traffic_set_shared(this_);
+
+ return this_;
+}
+
+/**
+ * @brief Creates a new XML element structure.
+ *
+ * Note that the structure of `names` and `values` may differ between XML libraries. Behavior is indicated by the
+ * `XML_ATTR_DISTANCE` constant.
+ *
+ * If `XML_ATTR_DISTANCE == 1`, `names` and `values` are two separate arrays, and `values[n]` is the value that
+ * corresponds to `names[n]`.
+ *
+ * If `XML_ATTR_DISTANCE == 2`, attribute names and values are kept in a single array in which names and values
+ * alternate, names first. In this case, `names` points to the array while `values` points to its second element, i.e.
+ * the first value. In this case, `value` is invalid for an empty array, and dereferencing it may segfault.
+ *
+ * @param tag_name The tag name
+ * @param names Attribute names
+ * @param values Attribute values
+ */
+static struct xml_element * traffic_xml_element_new(const char *tag_name, const char **names,
+ const char **values) {
+ struct xml_element * ret = g_new0(struct xml_element, 1);
+ const char ** in;
+ char ** out;
+
+ ret->tag_name = g_strdup(tag_name);
+ if (names) {
+ ret->names = g_new0(char *, g_strv_length((gchar **) names) / XML_ATTR_DISTANCE + 1);
+ in = names;
+ out = ret->names;
+ while (*in) {
+ *out++ = g_strdup(*in);
+ in += XML_ATTR_DISTANCE;
+ }
+ }
+ /* extra check for mixed name-value array */
+ if (names && *names && values) {
+#if XML_ATTR_DISTANCE == 1
+ ret->values = g_new0(char *, g_strv_length((gchar **) values) + 1);
+#else
+ ret->values = g_new0(char *, g_strv_length((gchar **) values) / XML_ATTR_DISTANCE + 2);
+#endif
+ in = values;
+ out = ret->values;
+ while (*in) {
+ *out++ = g_strdup(*in++);
+#if XML_ATTR_DISTANCE > 1
+ if (*in)
+ in++;
+#endif
+ }
+ }
+ return ret;
+}
+
+/**
+ * @brief Frees up an XML element structure.
+ *
+ * This will free up the memory used by the struct and all its members.
+ */
+static void traffic_xml_element_destroy(struct xml_element * this_) {
+ void ** iter;
+
+ g_free(this_->tag_name);
+ if (this_->names) {
+ for (iter = (void **) this_->names; *iter; iter++)
+ g_free(*iter);
+ g_free(this_->names);
+ }
+ if (this_->values) {
+ for (iter = (void **) this_->values; *iter; iter++)
+ g_free(*iter);
+ g_free(this_->values);
+ }
+ g_free(this_->text);
+ g_free(this_);
+}
+
+/**
+ * @brief Retrieves the value of an XML attribute.
+ *
+ * @param name The name of the attribute to retrieve
+ * @param names All attribute names
+ * @param values Attribute values (indices correspond to `names`)
+ *
+ * @return If `names` contains `name`, the corresponding value is returned, else NULL
+ */
+static char * traffic_xml_get_attr(const char * attr, char ** names, char ** values) {
+ int i;
+ for (i = 0; names[i] && values[i]; i++) {
+ if (!g_ascii_strcasecmp(attr, names[i]))
+ return values[i];
+ }
+ return NULL;
+}
+
+/**
+ * @brief Whether the tag stack represents a hierarchy of elements which is recognized.
+ *
+ * @param state The XML parser state
+ *
+ * @return True if the stack is valid, false if invalid. An empty stack is considered invalid.
+ */
+static int traffic_xml_is_tagstack_valid(struct xml_state * state) {
+ int ret = 0;
+ GList * tagiter;
+ struct xml_element * el, * el_parent;
+
+ for (tagiter = g_list_last(state->tagstack); tagiter; tagiter = g_list_previous(tagiter)) {
+ el = (struct xml_element *) tagiter->data;
+ el_parent = tagiter->next ? tagiter->next->data : NULL;
+
+ if (!g_ascii_strcasecmp(el->tag_name, "navit_messages")
+ || !g_ascii_strcasecmp(el->tag_name, "feed"))
+ ret = !tagiter->next;
+ else if (!g_ascii_strcasecmp((char *) el->tag_name, "message"))
+ ret = (!el_parent
+ || !g_ascii_strcasecmp(el_parent->tag_name, "navit_messages")
+ || !g_ascii_strcasecmp(el_parent->tag_name, "feed"));
+ else if (!g_ascii_strcasecmp(el->tag_name, "events")
+ || !g_ascii_strcasecmp(el->tag_name, "location")
+ || !g_ascii_strcasecmp(el->tag_name, "merge"))
+ ret = (el_parent && !g_ascii_strcasecmp(el_parent->tag_name, "message"));
+ else if (!g_ascii_strcasecmp(el->tag_name, "event"))
+ ret = (el_parent && !g_ascii_strcasecmp(el_parent->tag_name, "events"));
+ else if (!g_ascii_strcasecmp(el->tag_name, "from")
+ || !g_ascii_strcasecmp(el->tag_name, "to")
+ || !g_ascii_strcasecmp(el->tag_name, "at")
+ || !g_ascii_strcasecmp(el->tag_name, "via")
+ || !g_ascii_strcasecmp(el->tag_name, "not_via"))
+ ret = (el_parent && !g_ascii_strcasecmp(el_parent->tag_name, "location"));
+ else if (!g_ascii_strcasecmp(el->tag_name, "supplementary_info"))
+ ret = (el_parent && !g_ascii_strcasecmp(el_parent->tag_name, "event"));
+ else if (!g_ascii_strcasecmp(el->tag_name, "replaces"))
+ ret = (el_parent && !g_ascii_strcasecmp(el_parent->tag_name, "merge"));
+ else
+ ret = 0;
+
+ if (!ret)
+ break;
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Callback function which gets called when an opening tag is encountered.
+ *
+ * @param tag_name The tag name
+ * @param names Attribute names
+ * @param values Attribute values (indices correspond to `names`)
+ * @param data Points to a `struct xml_state` holding parser state
+ */
+static void traffic_xml_start(xml_context *dummy, const char *tag_name, const char **names,
+ const char **values, void *data, GError **error) {
+ struct xml_state * state = (struct xml_state *) data;
+ struct xml_element * el;
+
+ el = traffic_xml_element_new(tag_name, names, values);
+ state->tagstack = g_list_prepend(state->tagstack, el);
+ state->is_opened = 1;
+ state->is_valid = traffic_xml_is_tagstack_valid(state);
+ if (!state->is_valid)
+ return;
+
+ dbg(lvl_debug, "OPEN: %s", tag_name);
+
+ if (!g_ascii_strcasecmp((char *) tag_name, "supplementary_info")) {
+ state->si = g_list_append(state->si, traffic_suppl_info_new(
+ si_class_new(traffic_xml_get_attr("class", el->names, el->values)),
+ si_type_new(traffic_xml_get_attr("type", el->names, el->values)),
+ /* TODO quantifier */
+ NULL));
+ } else if (!g_ascii_strcasecmp((char *) tag_name, "replaces")) {
+ /* TODO */
+ }
+
+ /*
+ * No handling necessary for:
+ *
+ * navit_messages: No attributes, everything handled in children's callbacks
+ * feed: No attributes, everything handled in children's callbacks
+ * message: Everything handled in end callback
+ * events: No attributes, everything handled in children's callbacks
+ * location: Everything handled in end callback
+ * event: Everything handled in end callback
+ * merge: No attributes, everything handled in children's callbacks
+ * from, to, at, via, not_via: Everything handled in end callback
+ */
+}
+
+/**
+ * @brief Callback function which gets called when a closing tag is encountered.
+ *
+ * @param tag_name The tag name
+ * @param data Points to a `struct xml_state` holding parser state
+ */
+static void traffic_xml_end(xml_context *dummy, const char *tag_name, void *data, GError **error) {
+ struct xml_state * state = (struct xml_state *) data;
+ struct xml_element * el = state->tagstack ? (struct xml_element *) state->tagstack->data : NULL;
+ struct traffic_message * message;
+ struct traffic_point ** point = NULL;
+
+ /* Iterator and child element count */
+ int i, count;
+
+ /* Child elements */
+ void ** children = NULL;
+
+ /* Iterator for children in GList */
+ GList * iter;
+
+ /* Some elements we need to check for null */
+ char * tmc_direction;
+ char * length;
+ char * speed;
+
+ /* New traffic event */
+ struct traffic_event * event = NULL;
+
+ float lat, lon;
+
+ if (state->is_valid) {
+ dbg(lvl_debug, " END: %s", tag_name);
+
+ if (!g_ascii_strcasecmp((char *) tag_name, "message")) {
+ count = g_list_length(state->events);
+ if (count) {
+ children = (void **) g_new0(struct traffic_event *, count);
+ iter = state->events;
+ for (i = 0; iter && (i < count); i++) {
+ children[i] = iter->data;
+ iter = g_list_next(iter);
+ }
+ }
+ message = traffic_message_new(traffic_xml_get_attr("id", el->names, el->values),
+ time_new(traffic_xml_get_attr("receive_time", el->names, el->values)),
+ time_new(traffic_xml_get_attr("update_time", el->names, el->values)),
+ time_new(traffic_xml_get_attr("expiration_time", el->names, el->values)),
+ time_new(traffic_xml_get_attr("start_time", el->names, el->values)),
+ time_new(traffic_xml_get_attr("end_time", el->names, el->values)),
+ boolean_new(traffic_xml_get_attr("cancellation", el->names, el->values), 0),
+ boolean_new(traffic_xml_get_attr("forecast", el->names, el->values), 0),
+ /* TODO replaces */
+ 0, NULL,
+ state->location,
+ count,
+ (struct traffic_event **) children);
+ if (!traffic_message_is_valid(message)) {
+ dbg(lvl_error, "malformed message detected, skipping");
+ traffic_message_destroy(message);
+ } else
+ state->messages = g_list_append(state->messages, message);
+ g_free(children);
+ state->location = NULL;
+ g_list_free(state->events);
+ state->events = NULL;
+ /* TODO replaces */
+ } else if (!g_ascii_strcasecmp((char *) tag_name, "location")) {
+ tmc_direction = traffic_xml_get_attr("tmc_direction", el->names, el->values);
+ state->location = traffic_location_new(state->at, state->from,
+ state->to, state->via, state->not_via,
+ traffic_xml_get_attr("destination", el->names, el->values),
+ traffic_xml_get_attr("direction", el->names, el->values),
+ location_dir_new(traffic_xml_get_attr("directionality", el->names, el->values)),
+ location_fuzziness_new(traffic_xml_get_attr("fuzziness", el->names, el->values)),
+ location_ramps_new(traffic_xml_get_attr("ramps", el->names, el->values)),
+ item_type_from_road_type(traffic_xml_get_attr("road_class", el->names, el->values),
+ /* TODO revisit default for road_is_urban */
+ boolean_new(traffic_xml_get_attr("road_is_urban", el->names, el->values), 0)),
+ traffic_xml_get_attr("road_name", el->names, el->values),
+ traffic_xml_get_attr("road_ref", el->names, el->values),
+ traffic_xml_get_attr("tmc_table", el->names, el->values),
+ tmc_direction ? atoi(tmc_direction) : 0);
+ state->from = NULL;
+ state->to = NULL;
+ state->at = NULL;
+ state->via = NULL;
+ state->not_via = NULL;
+ } else if (!g_ascii_strcasecmp((char *) tag_name, "event")) {
+ count = g_list_length(state->si);
+ if (count) {
+ children = (void **) g_new0(struct traffic_suppl_info *, count);
+ iter = state->si;
+ for (i = 0; iter && (i < count); i++) {
+ children[i] = iter->data;
+ iter = g_list_next(iter);
+ }
+ }
+ length = traffic_xml_get_attr("length", el->names, el->values);
+ speed = traffic_xml_get_attr("speed", el->names, el->values);
+ event = traffic_event_new(event_class_new(traffic_xml_get_attr("class", el->names, el->values)),
+ event_type_new(traffic_xml_get_attr("type", el->names, el->values)),
+ length ? atoi(length) : -1,
+ speed ? atoi(speed) : INT_MAX,
+ /* TODO quantifier */
+ NULL,
+ count,
+ (struct traffic_suppl_info **) children);
+ g_free(children);
+ g_list_free(state->si);
+ state->si = NULL;
+ /* TODO preserve unknown (and thus invalid) events if they have maxspeed set */
+ if (!traffic_event_is_valid(event)) {
+ dbg(lvl_debug, "invalid or unknown event detected, skipping");
+ traffic_event_destroy(event);
+ } else
+ state->events = g_list_append(state->events, event);
+ } else if (!g_ascii_strcasecmp((char *) tag_name, "from")) {
+ point = &state->from;
+ } else if (!g_ascii_strcasecmp((char *) tag_name, "to")) {
+ point = &state->to;
+ } else if (!g_ascii_strcasecmp((char *) tag_name, "at")) {
+ point = &state->at;
+ } else if (!g_ascii_strcasecmp((char *) tag_name, "via")) {
+ point = &state->via;
+ } else if (!g_ascii_strcasecmp((char *) tag_name, "not_via")) {
+ point = &state->not_via;
+ }
+
+ /*
+ * No handling necessary for:
+ *
+ * navit_messages: No attributes, everything handled in children's callbacks
+ * feed: No attributes, everything handled in children's callbacks
+ * events: No attributes, everything handled in children's callbacks
+ * merge: No attributes, everything handled in children's callbacks
+ * replaces: Leaf node, handled in start callback
+ * supplementary_info: Leaf node, handled in start callback
+ */
+
+ if (point) {
+ /* we have a location point (from, at, to, via or not_via) to process */
+ if (sscanf(el->text, "%f %f", &lat, &lon) == 2) {
+ *point = traffic_point_new(lon, lat,
+ traffic_xml_get_attr("junction_name", el->names, el->values),
+ traffic_xml_get_attr("junction_ref", el->names, el->values),
+ traffic_xml_get_attr("tmc_id", el->names, el->values));
+ } else {
+ dbg(lvl_error, "%s has no valid lat/lon pair, skipping", tag_name);
+ }
+ }
+ }
+
+ if (el && !g_ascii_strcasecmp(tag_name, el->tag_name)) {
+ traffic_xml_element_destroy(el);
+ state->tagstack = g_list_remove(state->tagstack, state->tagstack->data);
+ }
+ state->is_opened = 0;
+}
+
+/**
+ * @brief Callback function which gets called when character data is encountered.
+ *
+ * @param text The character data (note that the data is not NULL-terminated!)
+ * @param len The number of characters in `text`
+ * @param data Points to a `struct xml_state` holding parser state
+ */
+static void traffic_xml_text(xml_context *dummy, const char *text, gsize len, void *data, GError **error) {
+ struct xml_state * state = (struct xml_state *) data;
+ char * text_sz = g_strndup(text, len);
+ struct xml_element * el = state->tagstack ? (struct xml_element *) state->tagstack->data : NULL;
+
+ dbg(lvl_debug, " TEXT: '%s'", text_sz);
+ if (state->is_valid && state->is_opened) {
+ /* this will work only for leaf nodes, which is not an issue at the moment as the only nodes
+ * with actual text data are leaf nodes */
+ el->text = g_strndup(text, len);
+ }
+ g_free(text_sz);
+}
+
+enum event_class event_class_new(char * string) {
+ if (string) {
+ if (!g_ascii_strcasecmp(string, "CONGESTION"))
+ return event_class_congestion;
+ if (!g_ascii_strcasecmp(string, "DELAY"))
+ return event_class_delay;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION"))
+ return event_class_restriction;
+ }
+ return event_class_invalid;
+}
+
+const char * event_class_to_string(enum event_class this_) {
+ switch (this_) {
+ case event_class_congestion:
+ return "CONGESTION";
+ case event_class_delay:
+ return "DELAY";
+ case event_class_restriction:
+ return "RESTRICTION";
+ default:
+ return "INVALID";
+ }
+}
+
+enum event_type event_type_new(char * string) {
+ if (string) {
+ if (!g_ascii_strcasecmp(string, "CONGESTION_CLEARED"))
+ return event_congestion_cleared;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_FORECAST_WITHDRAWN"))
+ return event_congestion_forecast_withdrawn;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_HEAVY_TRAFFIC"))
+ return event_congestion_heavy_traffic;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_LONG_QUEUE"))
+ return event_congestion_long_queue;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_NONE"))
+ return event_congestion_none;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_NORMAL_TRAFFIC"))
+ return event_congestion_normal_traffic;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_QUEUE"))
+ return event_congestion_queue;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_QUEKE_LIKELY"))
+ return event_congestion_queue_likely;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_SLOW_TRAFFIC"))
+ return event_congestion_slow_traffic;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_STATIONARY_TRAFFIC"))
+ return event_congestion_stationary_traffic;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_STATIONARY_TRAFFIC_LIKELY"))
+ return event_congestion_stationary_traffic_likely;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_TRAFFIC_BUILDING_UP"))
+ return event_congestion_traffic_building_up;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_TRAFFIC_CONGESTION"))
+ return event_congestion_traffic_congestion;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_TRAFFIC_EASING"))
+ return event_congestion_traffic_easing;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_TRAFFIC_FLOWING_FREELY"))
+ return event_congestion_traffic_flowing_freely;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_TRAFFIC_HEAVIER_THAN_NORMAL"))
+ return event_congestion_traffic_heavier_than_normal;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_TRAFFIC_LIGHTER_THAN_NORMAL"))
+ return event_congestion_traffic_lighter_than_normal;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_TRAFFIC_MUCH_HEAVIER_THAN_NORMAL"))
+ return event_congestion_traffic_much_heavier_than_normal;
+ if (!g_ascii_strcasecmp(string, "CONGESTION_TRAFFIC_PROBLEM"))
+ return event_congestion_traffic_problem;
+ if (!g_ascii_strcasecmp(string, "DELAY_CLEARANCE"))
+ return event_delay_clearance;
+ if (!g_ascii_strcasecmp(string, "DELAY_DELAY"))
+ return event_delay_delay;
+ if (!g_ascii_strcasecmp(string, "DELAY_DELAY_POSSIBLE"))
+ return event_delay_delay_possible;
+ if (!g_ascii_strcasecmp(string, "DELAY_FORECAST_WITHDRAWN"))
+ return event_delay_forecast_withdrawn;
+ if (!g_ascii_strcasecmp(string, "DELAY_LONG_DELAY"))
+ return event_delay_long_delay;
+ if (!g_ascii_strcasecmp(string, "DELAY_SEVERAL_HOURS"))
+ return event_delay_several_hours;
+ if (!g_ascii_strcasecmp(string, "DELAY_UNCERTAIN_DURATION"))
+ return event_delay_uncertain_duration;
+ if (!g_ascii_strcasecmp(string, "DELAY_VERY_LONG_DELAY"))
+ return event_delay_very_long_delay;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_ACCESS_RESTRICTIONS_LIFTED"))
+ return event_restriction_access_restrictions_lifted;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_ALL_CARRIAGEWAYS_CLEARED"))
+ return event_restriction_all_carriageways_cleared;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_ALL_CARRIAGEWAYS_REOPENED"))
+ return event_restriction_all_carriageways_reopened;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_BATCH_SERVICE"))
+ return event_restriction_batch_service;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_BLOCKED"))
+ return event_restriction_blocked;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_BLOCKED_AHEAD"))
+ return event_restriction_blocked_ahead;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_CARRIAGEWAY_BLOCKED"))
+ return event_restriction_carriageway_blocked;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_CARRIAGEWAY_CLOSED"))
+ return event_restriction_carriageway_closed;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_CONTRAFLOW"))
+ return event_restriction_contraflow;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_CLOSED"))
+ return event_restriction_closed;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_CLOSED_AHEAD"))
+ return event_restriction_closed_ahead;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_ENTRY_BLOCKED"))
+ return event_restriction_entry_blocked;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_ENTRY_REOPENED"))
+ return event_restriction_entry_reopened;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_INTERMITTENT_CLOSURES"))
+ return event_restriction_intermittent_closures;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_LANE_BLOCKED"))
+ return event_restriction_lane_blocked;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_LANE_CLOSED"))
+ return event_restriction_lane_closed;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_OPEN"))
+ return event_restriction_open;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_RAMP_BLOCKED"))
+ return event_restriction_ramp_blocked;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_RAMP_CLOSED"))
+ return event_restriction_ramp_closed;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_RAMP_REOPENED"))
+ return event_restriction_ramp_reopened;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_REDUCED_LANES"))
+ return event_restriction_reduced_lanes;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_REOPENED"))
+ return event_restriction_reopened;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_ROAD_CLEARED"))
+ return event_restriction_road_cleared;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_SINGLE_ALTERNATE_LINE_TRAFFIC"))
+ return event_restriction_single_alternate_line_traffic;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_SPEED_LIMIT"))
+ return event_restriction_speed_limit;
+ if (!g_ascii_strcasecmp(string, "RESTRICTION_SPEED_LIMIT_LIFTED"))
+ return event_restriction_speed_limit_lifted;
+ }
+ return event_invalid;
+}
+
+const char * event_type_to_string(enum event_type this_) {
+ switch (this_) {
+ case event_congestion_cleared:
+ return "CONGESTION_CLEARED";
+ case event_congestion_forecast_withdrawn:
+ return "CONGESTION_FORECAST_WITHDRAWN";
+ case event_congestion_heavy_traffic:
+ return "CONGESTION_HEAVY_TRAFFIC";
+ case event_congestion_long_queue:
+ return "CONGESTION_LONG_QUEUE";
+ case event_congestion_none:
+ return "CONGESTION_NONE";
+ case event_congestion_normal_traffic:
+ return "CONGESTION_NORMAL_TRAFFIC";
+ case event_congestion_queue:
+ return "CONGESTION_QUEUE";
+ case event_congestion_queue_likely:
+ return "CONGESTION_QUEUE_LIKELY";
+ case event_congestion_slow_traffic:
+ return "CONGESTION_SLOW_TRAFFIC";
+ case event_congestion_stationary_traffic:
+ return "CONGESTION_STATIONARY_TRAFFIC";
+ case event_congestion_stationary_traffic_likely:
+ return "CONGESTION_STATIONARY_TRAFFIC_LIKELY";
+ case event_congestion_traffic_building_up:
+ return "CONGESTION_TRAFFIC_BUILDING_UP";
+ case event_congestion_traffic_congestion:
+ return "CONGESTION_TRAFFIC_CONGESTION";
+ case event_congestion_traffic_easing:
+ return "CONGESTION_TRAFFIC_EASING";
+ case event_congestion_traffic_flowing_freely:
+ return "CONGESTION_TRAFFIC_FLOWING_FREELY";
+ case event_congestion_traffic_heavier_than_normal:
+ return "CONGESTION_TRAFFIC_HEAVIER_THAN_NORMAL";
+ case event_congestion_traffic_lighter_than_normal:
+ return "CONGESTION_TRAFFIC_LIGHTER_THAN_NORMAL";
+ case event_congestion_traffic_much_heavier_than_normal:
+ return "CONGESTION_TRAFFIC_MUCH_HEAVIER_THAN_NORMAL";
+ case event_congestion_traffic_problem:
+ return "CONGESTION_TRAFFIC_PROBLEM";
+ case event_delay_clearance:
+ return "DELAY_CLEARANCE";
+ case event_delay_delay:
+ return "DELAY_DELAY";
+ case event_delay_delay_possible:
+ return "DELAY_DELAY_POSSIBLE";
+ case event_delay_forecast_withdrawn:
+ return "DELAY_FORECAST_WITHDRAWN";
+ case event_delay_long_delay:
+ return "DELAY_LONG_DELAY";
+ case event_delay_several_hours:
+ return "DELAY_SEVERAL_HOURS";
+ case event_delay_uncertain_duration:
+ return "DELAY_UNCERTAIN_DURATION";
+ case event_delay_very_long_delay:
+ return "DELAY_VERY_LONG_DELAY";
+ case event_restriction_access_restrictions_lifted:
+ return "RESTRICTION_ACCESS_RESTRICTIONS_LIFTED";
+ case event_restriction_all_carriageways_cleared:
+ return "RESTRICTION_ALL_CARRIAGEWAYS_CLEARED";
+ case event_restriction_all_carriageways_reopened:
+ return "RESTRICTION_ALL_CARRIAGEWAYS_REOPENED";
+ case event_restriction_batch_service:
+ return "RESTRICTION_BATCH_SERVICE";
+ case event_restriction_blocked:
+ return "RESTRICTION_BLOCKED";
+ case event_restriction_blocked_ahead:
+ return "RESTRICTION_BLOCKED_AHEAD";
+ case event_restriction_carriageway_blocked:
+ return "RESTRICTION_CARRIAGEWAY_BLOCKED";
+ case event_restriction_carriageway_closed:
+ return "RESTRICTION_CARRIAGEWAY_CLOSED";
+ case event_restriction_closed:
+ return "RESTRICTION_CLOSED";
+ case event_restriction_closed_ahead:
+ return "RESTRICTION_CLOSED_AHEAD";
+ case event_restriction_contraflow:
+ return "RESTRICTION_CONTRAFLOW";
+ case event_restriction_entry_blocked:
+ return "RESTRICTION_ENTRY_BLOCKED";
+ case event_restriction_entry_reopened:
+ return "RESTRICTION_ENTRY_REOPENED";
+ case event_restriction_exit_blocked:
+ return "RESTRICTION_EXIT_BLOCKED";
+ case event_restriction_exit_reopened:
+ return "RESTRICTION_EXIT_REOPENED";
+ case event_restriction_intermittent_closures:
+ return "RESTRICTION_INTERMITTENT_CLOSURES";
+ case event_restriction_lane_blocked:
+ return "RESTRICTION_LANE_BLOCKED";
+ case event_restriction_lane_closed:
+ return "RESTRICTION_LANE_CLOSED";
+ case event_restriction_open:
+ return "RESTRICTION_OPEN";
+ case event_restriction_ramp_blocked:
+ return "RESTRICTION_RAMP_BLOCKED";
+ case event_restriction_ramp_closed:
+ return "RESTRICTION_RAMP_CLOSED";
+ case event_restriction_ramp_reopened:
+ return "RESTRICTION_RAMP_REOPENED";
+ case event_restriction_reduced_lanes:
+ return "RESTRICTION_REDUCED_LANES";
+ case event_restriction_reopened:
+ return "RESTRICTION_REOPENED";
+ case event_restriction_road_cleared:
+ return "RESTRICTION_ROAD_CLEARED";
+ case event_restriction_single_alternate_line_traffic:
+ return "RESTRICTION_SINGLE_ALTERNATE_LINE_TRAFFIC";
+ case event_restriction_speed_limit:
+ return "RESTRICTION_SPEED_LIMIT";
+ case event_restriction_speed_limit_lifted:
+ return "RESTRICTION_SPEED_LIMIT_LIFTED";
+ default:
+ return "INVALID";
+ }
+}
+
+enum item_type item_type_from_road_type(char * string, int is_urban) {
+ enum item_type ret = type_line_unspecified;
+
+ if (string) {
+ if (!g_ascii_strcasecmp(string, "MOTORWAY"))
+ return is_urban ? type_highway_city : type_highway_land;
+ if (!g_ascii_strcasecmp(string, "TRUNK"))
+ return type_street_n_lanes;
+ if (!g_ascii_strcasecmp(string, "PRIMARY"))
+ return is_urban ? type_street_4_city : type_street_4_land;
+ if (!g_ascii_strcasecmp(string, "SECONDARY"))
+ return is_urban ? type_street_3_city : type_street_3_land;
+ if (!g_ascii_strcasecmp(string, "TERTIARY"))
+ return is_urban ? type_street_2_city : type_street_2_land;
+
+ ret = item_from_name(string);
+ }
+ if ((ret < route_item_first) || (ret > route_item_last))
+ return type_line_unspecified;
+ return ret;
+}
+
+enum location_dir location_dir_new(char * string) {
+ if (string && !g_ascii_strcasecmp(string, "ONE_DIRECTION"))
+ return location_dir_one;
+ return location_dir_both;
+}
+
+enum location_fuzziness location_fuzziness_new(char * string) {
+ if (string) {
+ if (!g_ascii_strcasecmp(string, "LOW_RES"))
+ return location_fuzziness_low_res;
+ if (!g_ascii_strcasecmp(string, "END_UNKNOWN"))
+ return location_fuzziness_end_unknown;
+ if (!g_ascii_strcasecmp(string, "START_UNKNOWN"))
+ return location_fuzziness_start_unknown;
+ if (!g_ascii_strcasecmp(string, "EXTENT_UNKNOWN"))
+ return location_fuzziness_extent_unknown;
+ }
+ return location_fuzziness_none;
+}
+
+const char * location_fuzziness_to_string(enum location_fuzziness this_) {
+ switch (this_) {
+ case location_fuzziness_low_res:
+ return "LOW_RES";
+ case location_fuzziness_end_unknown:
+ return "END_UNKNOWN";
+ case location_fuzziness_start_unknown:
+ return "START_UNKNOWN";
+ case location_fuzziness_extent_unknown:
+ return "EXTENT_UNKNOWN";
+ default:
+ return NULL;
+ }
+}
+
+enum location_ramps location_ramps_new(char * string) {
+ if (string) {
+ if (!g_ascii_strcasecmp(string, "ALL_RAMPS"))
+ return location_ramps_all;
+ if (!g_ascii_strcasecmp(string, "ENTRY_RAMP"))
+ return location_ramps_entry;
+ if (!g_ascii_strcasecmp(string, "EXIT_RAMP"))
+ return location_ramps_exit;
+ }
+ return location_ramps_none;
+}
+
+const char * location_ramps_to_string(enum location_ramps this_) {
+ switch (this_) {
+ case location_ramps_none:
+ return "NONE";
+ case location_ramps_all:
+ return "ALL_RAMPS";
+ case location_ramps_entry:
+ return "ENTRY_RAMP";
+ case location_ramps_exit:
+ return "EXIT_RAMP";
+ default:
+ return NULL;
+ }
+}
+
+enum si_class si_class_new(char * string) {
+ if (string) {
+ if (!g_ascii_strcasecmp(string, "PLACE"))
+ return si_class_place;
+ if (!g_ascii_strcasecmp(string, "TENDENCY"))
+ return si_class_tendency;
+ if (!g_ascii_strcasecmp(string, "VEHICLE"))
+ return si_class_vehicle;
+ }
+ return si_class_invalid;
+}
+
+const char * si_class_to_string(enum si_class this_) {
+ switch (this_) {
+ case si_class_place:
+ return "PLACE";
+ case si_class_tendency:
+ return "TENDENCY";
+ case si_class_vehicle:
+ return "VEHICLE";
+ default:
+ return "INVALID";
+ }
+}
+
+enum si_type si_type_new(char * string) {
+ if (string) {
+ if (!g_ascii_strcasecmp(string, "S_PLACE_BRIDGE"))
+ return si_place_bridge;
+ if (!g_ascii_strcasecmp(string, "S_PLACE_RAMP"))
+ return si_place_ramp;
+ if (!g_ascii_strcasecmp(string, "S_PLACE_ROADWORKS"))
+ return si_place_roadworks;
+ if (!g_ascii_strcasecmp(string, "S_PLACE_TUNNEL"))
+ return si_place_tunnel;
+ if (!g_ascii_strcasecmp(string, "S_TENDENCY_QUEUE_DECREASING"))
+ return si_tendency_queue_decreasing;
+ if (!g_ascii_strcasecmp(string, "S_TENDENCY_QUEUE_INCREASING"))
+ return si_tendency_queue_increasing;
+ if (!g_ascii_strcasecmp(string, "S_VEHICLE_ALL"))
+ return si_vehicle_all;
+ if (!g_ascii_strcasecmp(string, "S_VEHICLE_BUS"))
+ return si_vehicle_bus;
+ if (!g_ascii_strcasecmp(string, "S_VEHICLE_CAR"))
+ return si_vehicle_car;
+ if (!g_ascii_strcasecmp(string, "S_VEHICLE_CAR_WITH_CARAVAN"))
+ return si_vehicle_car_with_caravan;
+ if (!g_ascii_strcasecmp(string, "S_VEHICLE_CAR_WITH_TRAILER"))
+ return si_vehicle_car_with_trailer;
+ if (!g_ascii_strcasecmp(string, "S_VEHICLE_HAZMAT"))
+ return si_vehicle_hazmat;
+ if (!g_ascii_strcasecmp(string, "S_VEHICLE_HGV"))
+ return si_vehicle_hgv;
+ if (!g_ascii_strcasecmp(string, "S_VEHICLE_MOTOR"))
+ return si_vehicle_motor;
+ if (!g_ascii_strcasecmp(string, "S_VEHICLE_WITH_TRAILER"))
+ return si_vehicle_with_trailer;
+ }
+ return si_invalid;
+}
+
+const char * si_type_to_string(enum si_type this_) {
+ switch (this_) {
+ case si_place_bridge:
+ return "S_PLACE_BRIDGE";
+ case si_place_ramp:
+ return "S_PLACE_RAMP";
+ case si_place_roadworks:
+ return "S_PLACE_ROADWORKS";
+ case si_place_tunnel:
+ return "S_PLACE_TUNNEL";
+ case si_tendency_queue_decreasing:
+ return "S_TENDENCY_QUEUE_DECREASING";
+ case si_tendency_queue_increasing:
+ return "S_TENDENCY_QUEUE_INCREASING";
+ case si_vehicle_all:
+ return "S_VEHICLE_ALL";
+ case si_vehicle_bus:
+ return "S_VEHICLE_BUS";
+ case si_vehicle_car:
+ return "S_VEHICLE_CAR";
+ case si_vehicle_car_with_caravan:
+ return "S_VEHICLE_CAR_WITH_CARAVAN";
+ case si_vehicle_car_with_trailer:
+ return "S_VEHICLE_CAR_WITH_TRAILER";
+ case si_vehicle_hazmat:
+ return "S_VEHICLE_HAZMAT";
+ case si_vehicle_hgv:
+ return "S_VEHICLE_HGV";
+ case si_vehicle_motor:
+ return "S_VEHICLE_MOTOR";
+ case si_vehicle_with_trailer:
+ return "S_VEHICLE_WITH_TRAILER";
+ default:
+ return "INVALID";
+ }
+}
+
+struct traffic_point * traffic_point_new(float lon, float lat, char * junction_name, char * junction_ref,
+ char * tmc_id) {
+ struct traffic_point * ret;
+
+ ret = g_new0(struct traffic_point, 1);
+ ret->coord.lat = lat;
+ ret->coord.lng = lon;
+ ret->junction_name = junction_name ? g_strdup(junction_name) : NULL;
+ ret->junction_ref = junction_ref ? g_strdup(junction_ref) : NULL;
+ ret->tmc_id = tmc_id ? g_strdup(tmc_id) : NULL;
+ return ret;
+}
+
+struct traffic_point * traffic_point_new_short(float lon, float lat) {
+ return traffic_point_new(lon, lat, NULL, NULL, NULL);
+}
+
+void traffic_point_destroy(struct traffic_point * this_) {
+ if (this_->junction_name)
+ g_free(this_->junction_name);
+ if (this_->junction_ref)
+ g_free(this_->junction_ref);
+ if (this_->tmc_id)
+ g_free(this_->tmc_id);
+ g_free(this_);
+}
+
+// TODO split CID/LTN?
+struct traffic_location * traffic_location_new(struct traffic_point * at, struct traffic_point * from,
+ struct traffic_point * to, struct traffic_point * via, struct traffic_point * not_via,
+ char * destination, char * direction, enum location_dir directionality,
+ enum location_fuzziness fuzziness, enum location_ramps ramps, enum item_type road_type,
+ char * road_name, char * road_ref, char * tmc_table, int tmc_direction) {
+ struct traffic_location * ret;
+
+ ret = g_new0(struct traffic_location, 1);
+ ret->at = at;
+ ret->from = from;
+ ret->to = to;
+ ret->via = via;
+ ret->not_via = not_via;
+ ret->destination = destination ? g_strdup(destination) : NULL;
+ ret->direction = direction ? g_strdup(direction) : NULL;
+ ret->directionality = directionality;
+ ret->fuzziness = fuzziness;
+ ret->ramps = ramps;
+ ret->road_type = road_type;
+ ret->road_name = road_name ? g_strdup(road_name) : NULL;
+ ret->road_ref = road_ref ? g_strdup(road_ref) : NULL;
+ ret->tmc_table = tmc_table ? g_strdup(tmc_table) : NULL;
+ ret->tmc_direction = tmc_direction;
+ ret->priv = g_new0(struct traffic_location_priv, 1);
+ ret->priv->sw = NULL;
+ ret->priv->ne = NULL;
+ return ret;
+}
+
+struct traffic_location * traffic_location_new_short(struct traffic_point * at, struct traffic_point * from,
+ struct traffic_point * to, struct traffic_point * via, struct traffic_point * not_via,
+ enum location_dir directionality, enum location_fuzziness fuzziness) {
+ return traffic_location_new(at, from, to, via, not_via, NULL, NULL, directionality, fuzziness,
+ location_ramps_none, type_line_unspecified, NULL, NULL, NULL, 0);
+}
+
+void traffic_location_destroy(struct traffic_location * this_) {
+ if (this_->at)
+ traffic_point_destroy(this_->at);
+ if (this_->from)
+ traffic_point_destroy(this_->from);
+ if (this_->to)
+ traffic_point_destroy(this_->to);
+ if (this_->via)
+ traffic_point_destroy(this_->via);
+ if (this_->not_via)
+ traffic_point_destroy(this_->not_via);
+ if (this_->destination)
+ g_free(this_->destination);
+ if (this_->direction)
+ g_free(this_->direction);
+ if (this_->road_name)
+ g_free(this_->road_name);
+ if (this_->road_ref)
+ g_free(this_->road_ref);
+ if (this_->tmc_table)
+ g_free(this_->tmc_table);
+ if (this_->priv->sw)
+ g_free(this_->priv->sw);
+ if (this_->priv->ne)
+ g_free(this_->priv->ne);
+ g_free(this_->priv);
+ g_free(this_);
+}
+
+struct traffic_suppl_info * traffic_suppl_info_new(enum si_class si_class, enum si_type type,
+ struct quantifier * quantifier) {
+ struct traffic_suppl_info * ret;
+ ret = g_new0(struct traffic_suppl_info, 1);
+ ret->si_class = si_class;
+ ret->type = type;
+ ret->quantifier = quantifier ? g_memdup(quantifier, sizeof(struct quantifier)) : NULL;
+ return ret;
+}
+
+void traffic_suppl_info_destroy(struct traffic_suppl_info * this_) {
+ if (this_->quantifier)
+ g_free(this_->quantifier);
+ g_free(this_);
+}
+
+struct traffic_event * traffic_event_new(enum event_class event_class, enum event_type type,
+ int length, int speed, struct quantifier * quantifier, int si_count, struct traffic_suppl_info ** si) {
+ struct traffic_event * ret;
+
+ ret = g_new0(struct traffic_event, 1);
+ ret->event_class = event_class;
+ ret->type = type;
+ ret->length = length;
+ ret->speed = speed;
+ ret->quantifier = quantifier ? g_memdup(quantifier, sizeof(struct quantifier)) : NULL;
+ if (si_count && si) {
+ ret->si_count = si_count;
+ ret->si = g_memdup(si, sizeof(struct traffic_suppl_info *) * si_count);
+ } else {
+ ret->si_count = 0;
+ ret->si = NULL;
+ }
+ return ret;
+}
+
+struct traffic_event * traffic_event_new_short(enum event_class event_class, enum event_type type) {
+ return traffic_event_new(event_class, type, -1, INT_MAX, NULL, 0, NULL);
+}
+
+void traffic_event_destroy(struct traffic_event * this_) {
+ int i;
+
+ if (this_->quantifier)
+ g_free(this_->quantifier);
+ if (this_->si && this_->si_count) {
+ for (i = 0; i < this_->si_count; i++)
+ traffic_suppl_info_destroy(this_->si[i]);
+ g_free(this_->si);
+ }
+ g_free(this_);
+}
+
+void traffic_event_add_suppl_info(struct traffic_event * this_, struct traffic_suppl_info * si) {
+ struct traffic_suppl_info ** si_new;
+
+ if (this_->si_count && this_->si) {
+ si_new = g_new0(struct traffic_suppl_info *, this_->si_count + 1);
+ memcpy(si_new, this_->si, sizeof(struct traffic_suppl_info *) * this_->si_count);
+ si_new[this_->si_count] = si;
+ g_free(this_->si);
+ this_->si = si_new;
+ this_->si_count++;
+ } else {
+ this_->si = g_new0(struct traffic_suppl_info *, 1);
+ this_->si[0] = si;
+ this_->si_count = 1;
+ }
+}
+
+struct traffic_suppl_info * traffic_event_get_suppl_info(struct traffic_event * this_, int index) {
+ if (this_->si && (index < this_->si_count))
+ return this_->si[index];
+ else
+ return NULL;
+}
+
+struct traffic_message * traffic_message_new(char * id, time_t receive_time, time_t update_time,
+ time_t expiration_time, time_t start_time, time_t end_time, int is_cancellation, int is_forecast,
+ int replaced_count, char ** replaces, struct traffic_location * location, int event_count,
+ struct traffic_event ** events) {
+ struct traffic_message * ret;
+
+ ret = g_new0(struct traffic_message, 1);
+ ret->id = g_strdup(id);
+ ret->receive_time = receive_time;
+ ret->update_time = update_time;
+ ret->expiration_time = expiration_time;
+ ret->start_time = start_time;
+ ret->end_time = end_time;
+ ret->is_cancellation = is_cancellation;
+ ret->is_forecast = is_forecast;
+ if (replaced_count && replaces) {
+ ret->replaced_count = replaced_count;
+ ret->replaces = g_memdup(replaces, sizeof(char *) * replaced_count);
+ } else {
+ ret->replaced_count = 0;
+ ret->replaces = NULL;
+ }
+ ret->location = location;
+ if (event_count && events) {
+ ret->event_count = event_count;
+ ret->events = g_memdup(events, sizeof(struct traffic_event *) * event_count);
+ }
+ ret->priv = g_new0(struct traffic_message_priv, 1);
+ ret->priv->items = NULL;
+ return ret;
+}
+
+struct traffic_message * traffic_message_new_short(char * id, time_t receive_time, time_t update_time,
+ time_t expiration_time, int is_forecast, struct traffic_location * location,
+ int event_count, struct traffic_event ** events) {
+ return traffic_message_new(id, receive_time, update_time, expiration_time, 0, 0, 0,
+ is_forecast, 0, NULL, location, event_count, events);
+}
+
+struct traffic_message * traffic_message_new_single_event(char * id, time_t receive_time, time_t update_time,
+ time_t expiration_time, int is_forecast, struct traffic_location * location,
+ enum event_class event_class, enum event_type type) {
+ struct traffic_event * event;
+ struct traffic_event ** events;
+
+ event = traffic_event_new_short(event_class, type);
+ events = g_new0(struct traffic_event *, 1);
+ events[0] = event;
+ return traffic_message_new_short(id, receive_time, update_time, expiration_time, is_forecast,
+ location, 1, events);
+ g_free(events);
+}
+
+struct traffic_message * traffic_message_new_cancellation(char * id, time_t receive_time, time_t update_time,
+ time_t expiration_time, struct traffic_location * location) {
+ return traffic_message_new(id, receive_time, update_time, expiration_time, 0, 0, 1,
+ 0, 0, NULL, location, 0, NULL);
+}
+
+void traffic_message_destroy(struct traffic_message * this_) {
+ int i;
+ struct item ** items;
+
+ g_free(this_->id);
+ if (this_->replaces) {
+ for (i = 0; i < this_->replaced_count; i++)
+ g_free(this_->replaces[i]);
+ g_free(this_->replaces);
+ }
+ if (this_->location)
+ traffic_location_destroy(this_->location);
+ if (this_->events && this_->event_count) {
+ for (i = 0; i < this_->event_count; i++)
+ traffic_event_destroy(this_->events[i]);
+ g_free(this_->events);
+ }
+ if (this_->priv->items) {
+ for (items = this_->priv->items; *items; items++)
+ *items = tm_item_unref(*items);
+ g_free(this_->priv->items);
+ }
+ g_free(this_->priv);
+ g_free(this_);
+}
+
+void traffic_message_add_event(struct traffic_message * this_, struct traffic_event * event) {
+ struct traffic_event ** events_new;
+
+ events_new = g_new0(struct traffic_event *, this_->event_count + 1);
+ memcpy(events_new, this_->events, sizeof(struct traffic_event *) * this_->event_count);
+ events_new[this_->event_count] = event;
+ g_free(this_->events);
+ this_->events = events_new;
+ this_->event_count++;
+}
+
+struct traffic_event * traffic_message_get_event(struct traffic_message * this_, int index) {
+ if (this_->events && (index < this_->event_count))
+ return this_->events[index];
+ else
+ return NULL;
+}
+
+struct item ** traffic_message_get_items(struct traffic_message * this_) {
+ struct item ** ret;
+ struct item ** in;
+ int i;
+ if (!this_->priv->items) {
+ ret = g_new0(struct item *, 1);
+ return ret;
+ }
+ in = this_->priv->items;
+ for (i = 1; *in; i++)
+ in++;
+ ret = g_new0(struct item *, i);
+ memcpy(ret, this_->priv->items, sizeof(struct item *) * i);
+ return ret;
+}
+
+/**
+ * @brief Registers a new traffic map plugin
+ *
+ * @param meth Receives the map methods
+ * @param attrs The attributes for the map
+ * @param cbl
+ *
+ * @return A pointer to a `map_priv` structure for the map
+ */
+static struct map_priv * traffic_map_new(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) {
+ struct map_priv *ret;
+
+ ret = g_new0(struct map_priv, 1);
+ *meth = traffic_map_meth;
+
+ return ret;
+}
+
+void traffic_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_map("traffic", traffic_map_new);
+}
+
+struct map * traffic_get_map(struct traffic *this_) {
+ struct attr_iter *iter;
+ struct attr *attr;
+ struct traffic * traffic;
+ char * filename;
+ struct traffic_message ** messages;
+ struct traffic_message ** cur_msg;
+
+ if (!this_->map) {
+ /* see if any of the other instances has already created a map */
+ attr = g_new0(struct attr, 1);
+ iter = navit_attr_iter_new();
+ while (navit_get_attr(this_->navit, attr_traffic, attr, iter)) {
+ traffic = (struct traffic *) attr->u.navit_object;
+ if (traffic->map)
+ this_->map = traffic->map;
+ }
+ navit_attr_iter_destroy(iter);
+ g_free(attr);
+ }
+
+ if (!this_->map) {
+ /* no map yet, create a new one */
+ struct attr *attrs[4];
+ struct attr a_type,data,a_description;
+ a_type.type = attr_type;
+ a_type.u.str = "traffic";
+ data.type = attr_data;
+ data.u.str = "";
+ a_description.type = attr_description;
+ a_description.u.str = "Traffic";
+
+ attrs[0] = &a_type;
+ attrs[1] = &data;
+ attrs[2] = &a_description;
+ attrs[3] = NULL;
+
+ this_->map = map_new(NULL, attrs);
+ navit_object_ref((struct navit_object *) this_->map);
+
+ /* populate map with previously stored messages */
+ filename = g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/traffic.xml", NULL);
+ messages = traffic_get_messages_from_xml_file(this_, filename);
+ g_free(filename);
+
+ if (messages) {
+ for (cur_msg = messages; *cur_msg; cur_msg++)
+ this_->shared->message_queue = g_list_append(this_->shared->message_queue, *cur_msg);
+ g_free(messages);
+ if (this_->shared->message_queue) {
+ if (!this_->idle_cb)
+ this_->idle_cb = callback_new_2(callback_cast(traffic_process_messages_int),
+ this_, PROCESS_MESSAGES_NO_DUMP_STORE);
+ if (!this_->idle_ev)
+ this_->idle_ev = event_add_idle(50, this_->idle_cb);
+ }
+ }
+ }
+
+ return this_->map;
+}
+
+/**
+ * @brief Reads previously stored traffic messages from parsed XML data.
+ *
+ * @param state The XML parser state after parsing the XML data
+ *
+ * @return A `NULL`-terminated pointer array. Each element points to one `struct traffic_message`.
+ * `NULL` is returned (rather than an empty pointer array) if there are no messages to report.
+ */
+static struct traffic_message ** traffic_get_messages_from_parsed_xml(struct xml_state * state) {
+ struct traffic_message ** ret = NULL;
+ int i, count;
+ GList * msg_iter;
+
+ count = g_list_length(state->messages);
+ if (count)
+ ret = g_new0(struct traffic_message *, count + 1);
+ msg_iter = state->messages;
+ for (i = 0; i < count; i++) {
+ ret[i] = (struct traffic_message *) msg_iter->data;
+ msg_iter = g_list_next(msg_iter);
+ }
+ g_list_free(state->messages);
+ return ret;
+}
+
+struct traffic_message ** traffic_get_messages_from_xml_file(struct traffic * this_, char * filename) {
+ struct traffic_message ** ret = NULL;
+ struct xml_state state;
+ int read_success = 0;
+
+ if (filename) {
+ memset(&state, 0, sizeof(struct xml_state));
+ read_success = xml_parse_file(filename, &state, traffic_xml_start, traffic_xml_end, traffic_xml_text);
+ if (read_success) {
+ ret = traffic_get_messages_from_parsed_xml(&state);
+ } else {
+ dbg(lvl_error,"could not retrieve stored traffic messages");
+ }
+ } /* if (traffic_filename) */
+ return ret;
+}
+
+struct traffic_message ** traffic_get_messages_from_xml_string(struct traffic * this_, char * xml) {
+ struct traffic_message ** ret = NULL;
+ struct xml_state state;
+ int read_success = 0;
+
+ if (xml) {
+ memset(&state, 0, sizeof(struct xml_state));
+ read_success = xml_parse_text(xml, &state, traffic_xml_start, traffic_xml_end, traffic_xml_text);
+ if (read_success) {
+ ret = traffic_get_messages_from_parsed_xml(&state);
+ } else {
+ dbg(lvl_error,"no data supplied");
+ }
+ } /* if (xml) */
+ return ret;
+}
+
+struct traffic_message ** traffic_get_stored_messages(struct traffic *this_) {
+ struct traffic_message ** ret = g_new0(struct traffic_message *, g_list_length(this_->shared->messages) + 1);
+ struct traffic_message ** out = ret;
+ GList * in = this_->shared->messages;
+
+ while (in) {
+ *out = (struct traffic_message *) in->data;
+ in = g_list_next(in);
+ out++;
+ }
+
+ return ret;
+}
+
+void traffic_process_messages(struct traffic * this_, struct traffic_message ** messages) {
+ struct traffic_message ** cur_msg;
+
+ for (cur_msg = messages; cur_msg && *cur_msg; cur_msg++)
+ this_->shared->message_queue = g_list_append(this_->shared->message_queue, *cur_msg);
+ if (this_->shared->message_queue) {
+ if (this_->idle_ev)
+ event_remove_idle(this_->idle_ev);
+ if (this_->idle_cb)
+ callback_destroy(this_->idle_cb);
+ this_->idle_cb = callback_new_2(callback_cast(traffic_process_messages_int), this_, 0);
+ this_->idle_ev = event_add_idle(50, this_->idle_cb);
+ }
+}
+
+void traffic_set_mapset(struct traffic *this_, struct mapset *ms) {
+ this_->ms = ms;
+}
+
+void traffic_set_route(struct traffic *this_, struct route *rt) {
+ this_->rt = rt;
+}
+
+struct object_func traffic_func = {
+ attr_traffic,
+ (object_func_new)traffic_new,
+ (object_func_get_attr)navit_object_get_attr,
+ (object_func_iter_new)navit_object_attr_iter_new,
+ (object_func_iter_destroy)navit_object_attr_iter_destroy,
+ (object_func_set_attr)navit_object_set_attr,
+ (object_func_add_attr)navit_object_add_attr,
+ (object_func_remove_attr)navit_object_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)navit_object_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
+};
diff --git a/navit/traffic.h b/navit/traffic.h
new file mode 100644
index 000000000..0dd21c7bc
--- /dev/null
+++ b/navit/traffic.h
@@ -0,0 +1,996 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2017 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/** @file
+ *
+ * @brief Contains exported code for traffic.c, the traffic module
+ *
+ * This file contains types and function prototypes exported from the traffic module, which enables
+ * Navit to route around traffic problems.
+ *
+ * The traffic module consists of two parts:
+ *
+ * The traffic core interacts with the Navit core and converts traffic messages into traffic
+ * distortions (future versions may add support for other traffic information).
+ *
+ * The traffic backends obtain traffic information from a source of their choice (e.g. from a TMC
+ * receiver or a network service), translate them into Navit data structures and report them to the
+ * traffic plugin.
+ *
+ * Traffic messages and related structures are considered immutable once created (when information
+ * changes, the old message is replaced with a new one). For this reason, there are very few data
+ * manipulation methods. Those that exist are intended for the creation of new messages rather than
+ * for extensive manipulation.
+ *
+ * As a rule, responsibility for freeing up any `traffic_*` instances normally lies with the
+ * traffic plugin, which frees messages as they expire or are replaced. Since this also frees all child
+ * data structures, traffic backends will seldom need to call any of the destructors. The only case in
+ * which this would be necessary is if a backend has instantiated an object which is not going to be
+ * used (i.e. attached to a parent object or, in the case of `traffic_message`, reported to the
+ * traffic plugin: these need to be freed up manually by calling the destructor of the topmost object in
+ * the hierarchy.
+ *
+ * Any other references passed in functions (including pointer arrays and `quantifier` instances)
+ * must be freed up by the caller. This is safe to do as soon as the function returns.
+ */
+
+#ifndef NAVIT_TRAFFIC_H
+#define NAVIT_TRAFFIC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Classes for events.
+ */
+/* If additional event classes are introduced, traffic_event_is_valid() must be adapted to recognize them. */
+enum event_class {
+ event_class_invalid = 0, /*!< Invalid event which should be ignored */
+ event_class_congestion, /*!< Traffic congestion, typically indicating the approximate speed */
+ event_class_delay, /*!< Delays, typically indicating the amount of extra waiting time */
+ event_class_restriction, /*!< Temporary traffic restrictions, such as road or lane closures or size,
+ * weight or access restrictions */
+};
+
+/**
+ * @brief Event types.
+ */
+/* If additional events are introduced, remember to do the following:
+ * - If the events belong to an existing class, insert them right after the last existing event for that class.
+ * - If the events belong to a new class, insert them at the end of the list.
+ * - Always keep events of the same class together.
+ * - After adding events (of any class) at the end of the list, adapt traffic_event_is_valid() to recognize them. */
+enum event_type {
+ event_invalid = 0, /*!< Invalid event which should be ignored */
+ event_congestion_cleared, /*!< Traffic congestion cleared */
+ event_congestion_forecast_withdrawn, /*!< Traffic congestion forecast withdrawn */
+ event_congestion_heavy_traffic, /*!< Heavy traffic with average speeds of `speed` */
+ event_congestion_long_queue, /*!< Long queues with average speeds of `speed` */
+ event_congestion_none, /*!< No problems to report */
+ event_congestion_normal_traffic, /*!< Traffic has returned to normal */
+ event_congestion_queue, /*!< Queuing traffic with average speeds of `speed` */
+ event_congestion_queue_likely, /*!< Danger of queuing traffic with average speeds
+ * of `speed` */
+ event_congestion_slow_traffic, /*!< Slow traffic with average speeds of `speed` */
+ event_congestion_stationary_traffic, /*!< Stationary traffic (frequent standstills) */
+ event_congestion_stationary_traffic_likely, /*!< Danger of stationary traffic */
+ event_congestion_traffic_building_up, /*!< Traffic building up with average speeds of
+ * `speed` */
+ event_congestion_traffic_congestion, /*!< Traffic congestion with average speeds of
+ * `speed` */
+ event_congestion_traffic_easing, /*!< Traffic easing */
+ event_congestion_traffic_flowing_freely, /*!< Traffic flowing freely with average speeds
+ * of `speed` */
+ event_congestion_traffic_heavier_than_normal, /*!< Traffic heavier than normal with average
+ * speeds of `speed` */
+ event_congestion_traffic_lighter_than_normal, /*!< Traffic lighter than normal with average
+ * speeds of `speed` */
+ event_congestion_traffic_much_heavier_than_normal, /*!< Traffic very much heavier than normal with
+ * average speeds of `speed` (increased density
+ * but no significant decrease in speed) */
+ event_congestion_traffic_problem, /*!< Traffic problem */
+ event_delay_clearance, /*!< Delays cleared */
+ event_delay_delay, /*!< Delays up to `q_timespan` */
+ event_delay_delay_possible, /*!< Delays up to `q_timespan` possible */
+ event_delay_forecast_withdrawn, /*!< Delay forecast withdrawn */
+ event_delay_long_delay, /*!< Long delays up to `q_timespan` */
+ event_delay_several_hours, /*!< Delays of several hours */
+ event_delay_uncertain_duration, /*!< Delays of uncertain duration */
+ event_delay_very_long_delay, /*!< Very long delays up to `q_timespan` */
+ event_restriction_access_restrictions_lifted, /*!< Traffic restrictions lifted: reopened for all
+ * traffic, other restrictions (overtaking etc.)
+ * remain in place */
+ event_restriction_all_carriageways_cleared, /*!< All carriageways cleared */
+ event_restriction_all_carriageways_reopened, /*!< All carriageways reopened */
+ event_restriction_batch_service, /*!< Batch service (to limit the amount of traffic
+ * passing through a section, unlike single
+ * alternate line traffic) */
+ event_restriction_blocked, /*!< Blocked (refers to the entire road; separate
+ * codes exist for blockages of individual lanes
+ * or carriageways) */
+ event_restriction_blocked_ahead, /*!< Blocked ahead (at a point beyond the
+ * indicated location) */
+ event_restriction_carriageway_blocked, /*!< Carriageway blocked (main carriageway, unless
+ * otherwise indicated in supplementary information) */
+ event_restriction_carriageway_closed, /*!< Carriageway closed (main carriageway, unless
+ * otherwise indicated in supplementary information) */
+ event_restriction_contraflow, /*!< Contraflow */
+ event_restriction_closed, /*!< Closed until `q_time` (refers to the entire
+ * road; separate codes exist for closures of
+ * individual lanes or carriageways) */
+ event_restriction_closed_ahead, /*!< Closed ahead (at a point beyond the indicated
+ * location) */
+ event_restriction_entry_blocked, /*!< `q_int` th entry slip road blocked */
+ event_restriction_entry_reopened, /*!< Entry reopened */
+ event_restriction_exit_blocked, /*!< `q_int` th exit slip road blocked */
+ event_restriction_exit_reopened, /*!< Exit reopened */
+ event_restriction_intermittent_closures, /*!< Intermittent short term closures */
+ event_restriction_lane_blocked, /*!< `q_int` lanes blocked */
+ event_restriction_lane_closed, /*!< `q_int` lanes closed */
+ event_restriction_open, /*!< Open */
+ event_restriction_ramp_blocked, /*!< Ramps blocked */
+ event_restriction_ramp_closed, /*!< Ramps closed */
+ event_restriction_ramp_reopened, /*!< Ramps reopened */
+ event_restriction_reduced_lanes, /*!< Carriageway reduced from `q_ints[1]` lanes to `q_int[0]`
+ * lanes (quantifiers are currently not implemented for this
+ * event type) */
+ event_restriction_reopened, /*!< Reopened */
+ event_restriction_road_cleared, /*!< Road cleared */
+ event_restriction_single_alternate_line_traffic, /*!< Single alternate line traffic (because the
+ * affected stretch of road can only be used in
+ * one direction at a time, different from batch
+ * service) */
+ event_restriction_speed_limit, /*!< Speed limit `speed` in force */
+ event_restriction_speed_limit_lifted, /*!< Speed limit lifted */
+};
+
+/**
+ * @brief The directionality of a location.
+ */
+enum location_dir {
+ location_dir_one = 1, /*!< Indicates a unidirectional location. */
+ location_dir_both = 2, /*!< Indicates a bidirectional location. */
+};
+
+/**
+ * @brief The fuzziness of a location.
+ */
+enum location_fuzziness {
+ location_fuzziness_none = 0, /*!< No fuzziness information is given. */
+ location_fuzziness_low_res, /*!< Locations are constrained to a predefined table; the actual
+ * extent of the condition may be shorter than indicated. */
+ location_fuzziness_end_unknown, /*!< The end is unknown, e.g. a traffic jam reported by a driver
+ * who has just entered it. */
+ location_fuzziness_start_unknown, /*!< The start is unknown, e.g. a traffic jam reported by a driver
+ who has just passed the obstruction which caused it. */
+ location_fuzziness_extent_unknown, /*!< Start and end are unknown, e.g. a traffic jam reported by a
+ driver who is in the middle of it. */
+};
+
+/**
+ * @brief Whether a location refers to the main carriageway or the ramps.
+ */
+enum location_ramps {
+ location_ramps_none = 0, /*!< The location refers to the carriageways of the main road. */
+ location_ramps_all, /*!< The location refers to the entry and exit ramps, not the main carriageway. */
+ location_ramps_entry, /*!< The location refers to the entry ramps only, not the main carriageway. */
+ location_ramps_exit, /*!< The location refers to the exit ramps only, not the main carriageway. */
+};
+
+/**
+ * @brief Classes for supplementary information items.
+ */
+enum si_class {
+ si_class_invalid = 0, /*!< Invalid supplementary information item which should be ignored */
+ si_class_place, /*!< Qualifiers specifying the place(s) to which the event refers */
+ si_class_tendency, /*!< Traffic density development */
+ si_class_vehicle, /*!< Specifies categories of vehicles to which the event applies */
+};
+
+/**
+ * @brief Supplementary information types.
+ */
+enum si_type {
+ si_invalid = 0, /*!< Invalid supplementary information item which should be ignored */
+ si_place_bridge, /*!< On bridges */
+ si_place_ramp, /*!< On ramps (entry/exit) */
+ si_place_roadworks, /*!< In the roadworks area */
+ si_place_tunnel, /*!< In tunnels */
+ si_tendency_queue_decreasing, /*!< Traffic queue length decreasing (average rate in optional `q_speed`) */
+ si_tendency_queue_increasing, /*!< Traffic queue length increasing (average rate in optional `q_speed`) */
+ si_vehicle_all, /*!< For all vehicles */
+ si_vehicle_bus, /*!< For buses only (TODO currently supported for public buses only) */
+ si_vehicle_car, /*!< For cars only */
+ si_vehicle_car_with_caravan, /*!< For cars with caravans only (TODO currently not supported) */
+ si_vehicle_car_with_trailer, /*!< For cars with trailers only (TODO currently not supported) */
+ si_vehicle_hazmat, /*!< For hazardous loads only */
+ si_vehicle_hgv, /*!< For heavy trucks only */
+ si_vehicle_motor, /*!< For all motor vehicles */
+ si_vehicle_with_trailer, /*!< For vehicles with trailers only (TODO currently not supported) */
+};
+
+struct traffic_priv;
+struct traffic_location_priv;
+struct traffic_message_priv;
+
+/**
+ * @brief Holds all functions a traffic plugin has to implement to be usable
+ *
+ * This structure holds pointers to a traffic plugin's functions which navit's core will call
+ * to communicate with the plugin.
+ */
+struct traffic_methods {
+ struct traffic_message **(* get_messages)(struct traffic_priv * this_); /**< Retrieves new messages from the traffic plugin */
+};
+
+/**
+ * @brief A point on the road.
+ *
+ * This can either be a point location or an endpoint of a linear location. It specifies a coordinate
+ * pair and can optionally be supplemented with a junction name and/or number where applicable.
+ */
+struct traffic_point {
+ struct coord_geo coord; /*!< The coordinates of this point, as supplied by the source. These may
+ * deviate somewhat from the coordinates on the map. */
+ char * junction_name; /*!< The name of the motorway junction this point refers to. */
+ char * junction_ref; /*!< The reference number of the motorway junction this point refers to. */
+ char * tmc_id; /*!< The TMC identifier of the point, if the location was obtained via TMC.
+ * This can be an LCID (12345) or a combination of an LCID and an offset
+ * (12345+2, i.e. an offset of 2 points in positive direction from 12345).
+ * The offset is typically used with the secondary location in TMC. */
+};
+
+/**
+ * @brief Location data for a traffic message.
+ *
+ * Locations can be either point or linear locations.
+ *
+ * Linear locations are indicated by a pair of points and refer to a stretch of road. The entire
+ * location must be part of the same road, i.e. either the road name or the road reference must be the
+ * same for all affected segments, or all segments must be of the same type and be of a higher order
+ * than any road connecting to them directly.
+ *
+ * Point locations are indicated by a single point, as well as one or two auxiliary points to indicate
+ * direction. Auxiliary points can be omitted if `tmc_table`, `tmc_direction` and
+ * `at->tmc_id` are supplied. However, this will only work if the map has accurate TMC data for
+ * the location, thus it is recommended to supply an auxiliary point nonetheless.
+ *
+ * The order of points is as a driver would encounter them, i.e. first `from`, then `at`,
+ * finally `to`.
+ */
+struct traffic_location {
+ struct traffic_point * at; /*!< The point for a point location, NULL for linear locations. */
+ struct traffic_point * from; /*!< The start of a linear location, or a point before `at`. */
+ struct traffic_point * to; /*!< The end of a linear location, or a point after `at`. */
+ struct traffic_point * via; /*!< A point between `from` and `to`. Required on ring roads
+ * unless `not_via` is used; cannot be used together with `at`. */
+ struct traffic_point * not_via; /*!< A point NOT between `from` and `to`. Required on ring roads
+ * unless `via` is used; cannot be used together with `at`. */
+ char * destination; /*!< A destination, preferably the one given on road signs,
+ * indicating that the message applies only to traffic going in
+ * that direction. Do not use for bidirectional locations. */
+ char * direction; /*!< A compass direction indicating the direction of travel which
+ * this location refers to. Do not use where ambiguous. */
+ enum location_dir directionality; /*!< Indicates whether the message refers to one or both directions
+ * of travel. */
+ enum location_fuzziness fuzziness; /*!< Indicates how precisely the end points are known. */
+ enum location_ramps ramps; /*!< Any value other than `location_ramps_none` implies
+ * that only the specified ramps are affected while the main
+ * road is not. In that case, the `road*` fields refer to
+ * the main road served by the ramp, not the ramp itself. This
+ * is mainly intended for compatibility with TMC, where
+ * junctions with all their ramps are represented by a single
+ * point. Other sources should use coordinate pairs instead. */
+ enum item_type road_type; /*!< The importance of the road within the road network, must be a
+ * road item type. Use `line_unspecified` if not known or
+ * not consistent. */
+ char * road_name; /*!< A road name, if consistent throughout the location. */
+ char * road_ref; /*!< A road number, if consistent throughout the location. */
+ char * tmc_table; /*!< For messages received via TMC, the country identifier (CID)
+ * and location table number (LTN or TABCD) for the location
+ * table to be used for location lookup. The CID is the decimal
+ * number stored in the COUNTRIES and LOCATIONDATASETS tables,
+ * not the hexadecimal code from the PI (known as CCD in TMC). */
+ int tmc_direction; /*!< For messages received via TMC, the direction of the road to
+ * which this message applies (positive or negative). Ignored
+ * for bidirectional messages. */
+ struct traffic_location_priv * priv; /*!< Internal data, not exposed via the API */
+};
+
+/**
+ * @brief A quantifier, which can be used with events and supplementary information.
+ */
+/*
+ * For now, these are various integer types, but other types may be added in the future.
+ */
+struct quantifier {
+ union {
+ int q_duration; /*!< A duration in 1/10 of a second. */
+ int q_int; /*!< An integer. */
+ int q_speed; /*!< A speed in km/h. */
+ unsigned int q_time; /*!< A timestamp in epoch time (seconds elapsed since Jan 1, 1970, 00:00 UTC). */
+ } u;
+};
+
+/**
+ * @brief Extra information supplied with a traffic event.
+ */
+struct traffic_suppl_info {
+ enum si_class si_class; /*!< The supplementary information class (generic category). */
+ enum si_type type; /*!< The supplementary information type, which can be mapped to a
+ * string to be displayed to the user. */
+ struct quantifier * quantifier; /*!< Additional quantifier for supplementary information types
+ * allowing this. Data type and meaning depends on the event type. */
+};
+
+/**
+ * @brief A traffic event.
+ *
+ * An event refers to a condition, its cause or its effect.
+ */
+struct traffic_event {
+ enum event_class event_class; /*!< The event class (generic category). */
+ enum event_type type; /*!< The event type, which can be mapped to a string to be displayed
+ * to the user. */
+ int length; /*!< The length of the affected route in meters. */
+ int speed; /*!< The speed in km/h at which vehicles can expect to pass through the
+ * affected stretch of road (either a temporary speed limit or
+ * average speed in practice, whichever is less), `INT_MAX` if
+ * not set or unknown. */
+ struct quantifier * quantifier; /*!< Additional quantifier for events allowing this. Data type and
+ * meaning depends on the event type. */
+ int si_count; /*!< Number of supplementary information items in `si_count`. */
+ struct traffic_suppl_info ** si; /*!< Points to an array of pointers to supplementary information items. */
+};
+
+/**
+ * @brief A traffic message.
+ *
+ * A message is the atomic element of traffic information, referring to a particular condition at a
+ * given location.
+ *
+ * If no updates are received for a message, it should be discarded after both `expiration_time`
+ * and `end_time` (if specified) have elapsed.
+ */
+struct traffic_message {
+ char * id; /*!< An identifier, which remains stable over the entire lifecycle of the
+ * message. The colon (:) is a reserved character to separate different
+ * levels of source identifiers from each other and from the local
+ * message identifier. */
+ time_t receive_time; /*!< When the message was first received by the source, should be kept
+ * stable across all updates. */
+ time_t update_time; /*!< When the last update to this message was received by the source. */
+ time_t expiration_time; /*!< How long the message should be considered valid.*/
+ time_t start_time; /*!< When the condition is expected to begin (optional, 0 if not set). */
+ time_t end_time; /*!< How long the condition is expected to last (optional, 0 if not set). */
+ int is_cancellation; /*!< If true, this message is a cancellation message, indicating that
+ * existing messages with the same ID should be deleted or no longer
+ * considered current. All other attributes of a cancellation message
+ * should be ignored. */
+ int is_forecast; /*!< If false, the message describes a current situation. If true, it
+ * describes an expected situation in the future. */
+ int replaced_count; /*!< The number of entries in `replaces`. */
+ char ** replaces; /*!< Points to an array of identifiers of messages which the current
+ * message replaces. */
+ struct traffic_location * location; /*!< The location to which this message refers. */
+ int event_count; /*!< The number of events in `events`. */
+ struct traffic_event ** events; /*!< Points to an array of pointers to the events for this message. */
+ struct traffic_message_priv * priv; /*!< Internal data, not exposed via the API */
+};
+
+struct map;
+struct mapset;
+struct traffic;
+
+/**
+ * @brief Creates an event class from its string representation.
+ *
+ * @param string The string representation (case is ignored)
+ *
+ * @return The corresponding `enum event_class`, or `event_class_invalid` if `string` does not match a
+ * known identifier
+ */
+enum event_class event_class_new(char * string);
+
+/**
+ * @brief Translates an event class to its string representation.
+ *
+ * @return The string representation of the event class
+ */
+const char * event_class_to_string(enum event_class this_);
+
+/**
+ * @brief Creates an event type from its string representation.
+ *
+ * @param string The string representation (case is ignored)
+ *
+ * @return The corresponding `enum event_type`, or `event_invalid` if `string` does not match a known
+ * identifier
+ */
+enum event_type event_type_new(char * string);
+
+/**
+ * @brief Translates an event type to its string representation.
+ *
+ * @return The string representation of the event type
+ */
+const char * event_type_to_string(enum event_type this_);
+
+/**
+ * @brief Creates an item type from a road type.
+ *
+ * This is guaranteed to return either a routable type (i.e. `route_item_first <= type <= route_item_last`)
+ * or `type_line_unspecified`. The latter is also returned if `string` refers to a Navit item type which
+ * is not routable.
+ *
+ * @param string A TraFF road type or the string representation of a Navit item type
+ * @param is_urban Whether the road is in a built-up area (ignored if `string` is a Navit item type)
+ *
+ * @return The corresponding `enum item_type`, or `type_line_unspecified` if `string` does not match a
+ * known and routable identifier
+ */
+enum item_type item_type_from_road_type(char * string, int is_urban);
+
+/**
+ * @brief Creates a location directionality from its string representation.
+ *
+ * @param string The string representation (case is ignored)
+ *
+ * @return The corresponding `enum location_dir`, or `location_dir_both` if `string` does
+ * not match a known identifier
+ */
+enum location_dir location_dir_new(char * string);
+
+/**
+ * @brief Creates a location fuzziness from its string representation.
+ *
+ * @param string The string representation (case is ignored)
+ *
+ * @return The corresponding `enum location_fuzziness`, or `location_fuzziness_none` if `string` does
+ * not match a known identifier
+ */
+enum location_fuzziness location_fuzziness_new(char * string);
+
+/**
+ * @brief Translates location fuzziness to its string representation.
+ *
+ * @return The string representation of the location fuzziness, or NULL for `location_fuzziness_none`
+ */
+const char * location_fuzziness_to_string(enum location_fuzziness this_);
+
+/**
+ * @brief Creates an `enum location_ramps` from its string representation.
+ *
+ * @param string The string representation (case is ignored)
+ *
+ * @return The corresponding `enum location_ramps`, or `location_ramps_none` if `string` does
+ * not match a known identifier
+ */
+enum location_ramps location_ramps_new(char * string);
+
+/**
+ * @brief Translates an `enum location_ramps` to its string representation.
+ *
+ * @return The string representation
+ */
+const char * location_ramps_to_string(enum location_ramps this_);
+
+/**
+ * @brief Creates a supplementary information class from its string representation.
+ *
+ * @param string The string representation (case is ignored)
+ *
+ * @return The corresponding `enum si_class`, or `si_class_invalid` if `string` does not match a
+ * known identifier
+ */
+enum si_class si_class_new(char * string);
+
+/**
+ * @brief Translates a supplementary information class to its string representation.
+ *
+ * @return The string representation of the supplementary information class
+ */
+const char * si_class_to_string(enum si_class this_);
+
+/**
+ * @brief Creates a supplementary information type from its string representation.
+ *
+ * @param string The string representation (case is ignored)
+ *
+ * @return The corresponding `enum si_type`, or `si_invalid` if `string` does not match a known
+ * identifier
+ */
+enum si_type si_type_new(char * string);
+
+/**
+ * @brief Translates a supplementary information type to its string representation.
+ *
+ * @return The string representation of the supplementary information type
+ */
+const char * si_type_to_string(enum si_type this_);
+
+/**
+ * @brief Creates a new `traffic_point`.
+ *
+ * It is the responsibility of the caller to destroy all references passed to this function. This can be
+ * done immediately after the function returns.
+ *
+ * @param lon The longitude, as reported by the source, in GPS coordinates
+ * @param lat The latitude, as reported by the source, in GPS coordinates
+ * @param junction_name The name of the motorway junction this point refers to, NULL if not applicable
+ * @param junction_ref The reference number of the motorway junction this point refers to, NULL if not applicable
+ * @param tmc_id The TMC identifier of the point, if the location was obtained via TMC, or NULL if not applicable
+ */
+struct traffic_point * traffic_point_new(float lon, float lat, char * junction_name, char * junction_ref,
+ char * tmc_id);
+
+/**
+ * @brief Creates a new `traffic_point`.
+ *
+ * This is the short version of the constructor, which sets only mandatory members. Other members can be
+ * set after the instance is created.
+ *
+ * @param lon The longitude, as reported by the source, in GPS coordinates
+ * @param lat The latitude, as reported by the source, in GPS coordinates
+ */
+struct traffic_point * traffic_point_new_short(float lon, float lat);
+
+/**
+ * @brief Destroys a `traffic_point`.
+ *
+ * This will release the memory used by the `traffic_point` and all related data.
+ *
+ * A `traffic_point` is usually destroyed together with its parent `traffic_location`, thus
+ * it is usually not necessary to call this destructor directly.
+ *
+ * @param this_ The point
+ */
+void traffic_point_destroy(struct traffic_point * this_);
+
+/**
+ * @brief Creates a new `traffic_location`.
+ *
+ * The `traffic_point` instances are destroyed when the `traffic_location` is destroyed, and
+ * therefore cannot be shared between multiple `traffic_location` instances.
+ *
+ * It is the responsibility of the caller to destroy all other references passed to this function. This
+ * can be done immediately after the function returns.
+ *
+ * If `at` is non-NULL, the location is a point location, and `from` and `to` are
+ * interpreted as auxiliary locations.
+ *
+ * Of `from` and `to`, one is mandatory for a unidirectional point location; both are
+ * mandatory for a linear location.
+ *
+ * `ramps` is mainly intended for compatibility with TMC, where junctions with all their ramps are
+ * represented by a single point. Other sources should use coordinate pairs instead.
+ *
+ * @param at The coordinates for a point location, NULL for a linear location
+ * @param from The start of a linear location, or a point before `at`
+ * @param to The end of a linear location, or a point after `at`
+ * @param via A point between `from` and `to`, needed only on ring roads
+ * @param not_via A point not between `from` and `to`, needed only on ring roads
+ * @param destination A destination, preferably the one given on road signs, indicating that the message
+ * applies only to traffic going in that direction; can be NULL, do not use for bidirectional locations
+ * @param direction A compass direction indicating the direction of travel which this location refers to;
+ * can be NULL, do not use where ambiguous
+ * @param directionality Whether the location is unidirectional or bidirectional
+ * @param fuzziness A precision indicator for `from` and `to`
+ * @param ramps Whether the main carriageway or the ramps are affected
+ * @param road_type The importance of the road within the road network, must be a road item type,
+ * `type_line_unspecified` if not known or not consistent
+ * @param road_name A road name, if consistent throughout the location; NULL if not known or inconsistent
+ * @param road_ref A road number, if consistent throughout the location; NULL if not known or inconsistent
+ * @param tmc_table For messages received via TMC, the CID and LTN; NULL otherwise
+ * @param tmc_direction For messages received via TMC, the direction of the road; ignored for
+ * bidirectional or non-TMC messages
+ */
+// TODO split CID/LTN?
+struct traffic_location * traffic_location_new(struct traffic_point * at, struct traffic_point * from,
+ struct traffic_point * to, struct traffic_point * via, struct traffic_point * not_via,
+ char * destination, char * direction, enum location_dir directionality,
+ enum location_fuzziness fuzziness, enum location_ramps ramps, enum item_type road_type,
+ char * road_name, char * road_ref, char * tmc_table, int tmc_direction);
+
+/**
+ * @brief Creates a new `traffic_location`.
+ *
+ * This is the short version of the constructor, which sets only mandatory members. Other members can be
+ * set after the instance is created.
+ *
+ * The `traffic_point` instances are destroyed when the `traffic_location` is destroyed, and
+ * therefore cannot be shared between multiple `traffic_location` instances.
+ *
+ * If `at` is non-NULL, the location is a point location, and `from` and `to` are
+ * interpreted as auxiliary locations.
+ *
+ * Of `from` and `to`, one is mandatory for a unidirectional point location; both are
+ * mandatory for a linear location.
+ *
+ * @param at The coordinates for a point location, NULL for a linear location
+ * @param from The start of a linear location, or a point before `at`
+ * @param to The end of a linear location, or a point after `at`
+ * @param via A point between `from` and `to`, needed only on ring roads
+ * @param not_via A point not between `from` and `to`, needed only on ring roads
+ * @param directionality Whether the location is unidirectional or bidirectional
+ * @param fuzziness A precision indicator for `from` and `to`
+ */
+struct traffic_location * traffic_location_new_short(struct traffic_point * at, struct traffic_point * from,
+ struct traffic_point * to, struct traffic_point * via, struct traffic_point * not_via,
+ enum location_dir directionality, enum location_fuzziness fuzziness);
+
+/**
+ * @brief Destroys a `traffic_location`.
+ *
+ * This will release the memory used by the `traffic_location` and all related data.
+ *
+ * A `traffic_location` is usually destroyed together with its parent `traffic_message`, thus
+ * it is usually not necessary to call this destructor directly.
+ *
+ * @param this_ The location
+ */
+void traffic_location_destroy(struct traffic_location * this_);
+
+/**
+ * @brief Creates a new `traffic_suppl_info`.
+ *
+ * It is the responsibility of the caller to destroy all references passed to this function. This can be
+ * done immediately after the function returns.
+ *
+ * @param si_class The supplementary information class (generic category)
+ * @param type The supplementary information type, which can be mapped to a string to be displayed to
+ * the user
+ * @param quantifier Additional quantifier for supplementary information types allowing this, or NULL
+ */
+struct traffic_suppl_info * traffic_suppl_info_new(enum si_class si_class, enum si_type type,
+ struct quantifier * quantifier);
+
+/**
+ * @brief Destroys a `traffic_suppl_info`.
+ *
+ * This will release the memory used by the `traffic_suppl_info` and all related data.
+ *
+ * A `traffic_suppl_info` is usually destroyed together with its parent `traffic_event`, thus
+ * it is usually not necessary to call this destructor directly.
+ *
+ * @param this_ The supplementary information item
+ */
+void traffic_suppl_info_destroy(struct traffic_suppl_info * this_);
+
+/**
+ * @brief Creates a new `traffic_event`.
+ *
+ * The `traffic_suppl_info` instances are destroyed when the `traffic_event` is destroyed, and
+ * therefore cannot be shared between multiple `traffic_event` instances.
+ *
+ * It is the responsibility of the caller to destroy all other references passed to this function
+ * (including the `si` buffer but not the `traffic_suppl_info` instances). This can be done
+ * immediately after the function returns.
+ *
+ * @param event_class The event class (generic category)
+ * @param type The event type, which can be mapped to a string to be displayed to the user
+ * @param length The length of the affected route in meters, -1 if not known
+ * @param speed The speed in km/h at which vehicles can expect to pass through the affected stretch of
+ * road (either a temporary speed limit or average speed in practice, whichever is less); INT_MAX if unknown
+ * @param quantifier Additional quantifier for supplementary information types allowing this, or NULL
+ * @param si_count Number of supplementary information items in `si_count`
+ * @param si Points to an array of pointers to supplementary information items
+ */
+struct traffic_event * traffic_event_new(enum event_class event_class, enum event_type type,
+ int length, int speed, struct quantifier * quantifier, int si_count, struct traffic_suppl_info ** si);
+
+/**
+ * @brief Creates a new `traffic_event`.
+ *
+ * This is the short version of the constructor, which sets only mandatory members. Other members can be
+ * set after the instance is created.
+ *
+ * @param event_class The event class (generic category)
+ * @param type The event type, which can be mapped to a string to be displayed to the user
+ */
+struct traffic_event * traffic_event_new_short(enum event_class event_class, enum event_type type);
+
+/**
+ * @brief Destroys a `traffic_event`.
+ *
+ * This will release the memory used by the `traffic_event` and all related data.
+ *
+ * A `traffic_event` is usually destroyed together with its parent `traffic_message`, thus
+ * it is usually not necessary to call this destructor directly.
+ *
+ * @param this_ The event
+ */
+void traffic_event_destroy(struct traffic_event * this_);
+
+/**
+ * @brief Adds a supplementary information item to an event.
+ *
+ * The `traffic_suppl_info` instance is destroyed when the `traffic_event` is destroyed, and
+ * therefore cannot be shared between multiple `traffic_event` instances.
+ *
+ * @param this_ The event
+ * @param si The supplementary information item
+ */
+void traffic_event_add_suppl_info(struct traffic_event * this_, struct traffic_suppl_info * si);
+
+/**
+ * @brief Retrieves a supplementary information item associated with an event.
+ *
+ * @param this_ The event
+ * @param index The index of the supplementary information item, zero-based
+ * @return The supplementary information item at the specified position, or NULL if out of bounds
+ */
+struct traffic_suppl_info * traffic_event_get_suppl_info(struct traffic_event * this_, int index);
+
+/**
+ * @brief Creates a new `traffic_message`.
+ *
+ * The `traffic_event` and `traffic_location` instances are destroyed when the
+ * `traffic_message` is destroyed, and therefore cannot be shared between multiple
+ * `traffic_message` instances.
+ *
+ * It is the responsibility of the caller to destroy all other references passed to this function
+ * (including the `events` buffer but not the `traffic_event` instances). This can be done
+ * immediately after the function returns.
+ *
+ * @param id The message identifier; existing messages with the same identifier will be replaced by the
+ * new message
+ * @param receive_time When the message was first received by the source, should be kept stable across
+ * all updates
+ * @param update_time When the last update to this message was received by the source
+ * @param expiration_time How long the message should be considered valid
+ * @param start_time When the condition is expected to begin (optional, 0 if not set)
+ * @param end_time How long the condition is expected to last (optional, 0 if not set)
+ * @param isCancellation If true, create a cancellation message (existing messages with the same ID
+ * should be deleted or no longer considered current, and all other attributes ignored)
+ * @param isForecast If false, the message describes a current situation; if true, it describes an
+ * expected situation in the future
+ * @param replaced_count The number of entries in `replaces`
+ * @param replaces Points to an array of identifiers of messages which the current message replaces
+ * @param location The location to which this message refers
+ * @param event_count The number of events in `events`
+ * @param events Points to an array of pointers to the events for this message
+ */
+struct traffic_message * traffic_message_new(char * id, time_t receive_time, time_t update_time,
+ time_t expiration_time, time_t start_time, time_t end_time, int is_cancellation, int is_Forecast,
+ int replaced_count, char ** replaces, struct traffic_location * location, int event_count,
+ struct traffic_event ** events);
+
+/**
+ * @brief Creates a new `traffic_message`.
+ *
+ * This is the short version of the constructor, which sets only mandatory members. Other members can be
+ * set after the instance is created.
+ *
+ * The `traffic_event` and `traffic_location` instances are destroyed when the
+ * `traffic_message` is destroyed, and therefore cannot be shared between multiple
+ * `traffic_message` instances.
+ *
+ * It is the responsibility of the caller to destroy all other references passed to this function
+ * (including the `events` buffer but not the `traffic_event` instances). This can be done
+ * immediately after the function returns.
+ *
+ * @param id The message identifier; existing messages with the same identifier will be replaced by the
+ * new message
+ * @param receive_time When the message was first received by the source, should be kept stable across
+ * all updates
+ * @param update_time When the last update to this message was received by the source
+ * @param expiration_time How long the message should be considered valid
+ * @param is_forecast If false, the message describes a current situation; if true, it describes an
+ * expected situation in the future
+ * @param location The location to which this message refers
+ * @param event_count The number of events in `events`
+ * @param events Points to an array of pointers to the events for this message
+ */
+struct traffic_message * traffic_message_new_short(char * id, time_t receive_time, time_t update_time,
+ time_t expiration_time, int is_forecast, struct traffic_location * location,
+ int event_count, struct traffic_event ** events);
+
+/**
+ * @brief Creates a new single-event `traffic_message`.
+ *
+ * This is a convenience constructor, which sets only mandatory members. Other members can be
+ * set after the instance is created.
+ *
+ * The `traffic_location` instances are destroyed when the `traffic_message` is destroyed,
+ * and therefore cannot be shared between multiple `traffic_message` instances.
+ *
+ * It is the responsibility of the caller to destroy all other references passed to this function. This
+ * can be done immediately after the function returns.
+ *
+ * @param id The message identifier; existing messages with the same identifier will be replaced by the
+ * new message
+ * @param receive_time When the message was first received by the source, should be kept stable across
+ * all updates
+ * @param update_time When the last update to this message was received by the source
+ * @param expiration_time How long the message should be considered valid
+ * @param is_forecast If false, the message describes a current situation; if true, it describes an
+ * expected situation in the future
+ * @param location The location to which this message refers
+ * @param event_class The event class (generic category)
+ * @param type The event type, which can be mapped to a string to be displayed to the user
+ */
+struct traffic_message * traffic_message_new_single_event(char * id, time_t receive_time, time_t update_time,
+ time_t expiration_time, int is_forecast, struct traffic_location * location,
+ enum event_class event_class, enum event_type type);
+
+/**
+ * @brief Creates a new cancellation `traffic_message`.
+ *
+ * This is a convenience constructor, which creates a cancellation message, without the need to supply
+ * members which are not required for cancellation messages. Upon receiving a cancellation message,
+ * existing messages with the same ID should be deleted or no longer considered current, and all other
+ * attributes ignored.
+ *
+ * The `traffic_location` instances are destroyed when the `traffic_message` is destroyed,
+ * and therefore cannot be shared between multiple `traffic_message` instances.
+ *
+ * It is the responsibility of the caller to destroy all other references passed to this function. This
+ * can be done immediately after the function returns.
+ *
+ * @param id The message identifier; existing messages with the same identifier will be replaced by the
+ * new message
+ * @param receive_time When the message was first received by the source, should be kept stable across
+ * all updates
+ * @param update_time When the last update to this message was received by the source
+ * @param expiration_time How long the message should be considered valid
+ * @param location The location to which this message refers
+ */
+struct traffic_message * traffic_message_new_cancellation(char * id, time_t receive_time, time_t update_time,
+ time_t expiration_time, struct traffic_location * location);
+
+/**
+ * @brief Destroys a `traffic_message`.
+ *
+ * This will release the memory used by the `traffic_message` and all related data.
+ *
+ * A `traffic_message` is usually destroyed by the traffic plugin, thus it is usually not
+ * necessary to call this destructor directly.
+ *
+ * @param this_ The message
+ */
+void traffic_message_destroy(struct traffic_message * this_);
+
+/**
+ * @brief Adds an event to a message.
+ *
+ * The `traffic_event` instance is destroyed when the `traffic_message` is destroyed, and
+ * therefore cannot be shared between multiple `traffic_message` instances.
+ *
+ * @param this_ The message
+ * @param event The event to add to this message
+ */
+void traffic_message_add_event(struct traffic_message * this_, struct traffic_event * event);
+
+/**
+ * @brief Retrieves an event associated with a message.
+ *
+ * @param this_ The message
+ * @param index The index of the event, zero-based
+ * @return The event at the specified position, or NULL if out of bounds
+ */
+struct traffic_event * traffic_message_get_event(struct traffic_message * this_, int index);
+
+/**
+ * @brief Returns the items associated with a message.
+ *
+ * Note that no map rectangle is required to obtain traffic items. This behavior is particular to traffic items, which
+ * do not rely on a map rectangle. Items obtained from other maps may behave differently.
+ *
+ * @param this_ The message
+ *
+ * @return Items as a NULL-terminated array. The caller is responsible for freeing the array (not its elements) when it
+ * is no longer needed. This method will always return a valid pointer—if no items are associated with the message, an
+ * empty array (with just one single NULL element) will be returned. No particular order is guaranteed for the items.
+ */
+struct item ** traffic_message_get_items(struct traffic_message * this_);
+
+/**
+ * @brief Initializes the traffic plugin.
+ *
+ * This function is called once on startup.
+ */
+void traffic_init(void);
+
+/**
+ * @brief Reads previously stored traffic messages from an XML file.
+ *
+ * @param this_ The traffic instance
+ * @param filename The full path to the XML file to parse
+ *
+ * @return A `NULL`-terminated pointer array. Each element points to one `struct traffic_message`.
+ * `NULL` is returned (rather than an empty pointer array) if there are no messages to report.
+ */
+struct traffic_message ** traffic_get_messages_from_xml_file(struct traffic * this_, char * filename);
+
+/**
+ * @brief Reads traffic messages from an XML string.
+ *
+ * @param this_ The traffic instance
+ * @param filename The XML document to parse, as a string
+ *
+ * @return A `NULL`-terminated pointer array. Each element points to one `struct traffic_message`.
+ * `NULL` is returned (rather than an empty pointer array) if there are no messages to report.
+ */
+struct traffic_message ** traffic_get_messages_from_xml_string(struct traffic * this_, char * xml);
+
+/**
+ * @brief Returns the map for the traffic plugin.
+ *
+ * The map is created by the first traffic plugin loaded. If multiple traffic plugin instances are
+ * active at the same time, they share the map created by the first instance.
+ *
+ * @param this_ The traffic plugin instance
+ *
+ * @return The traffic map
+ */
+struct map * traffic_get_map(struct traffic *this_);
+
+/**
+ * @brief Returns currently active traffic messages.
+ *
+ * If multiple plugin instances are active, this will give the same result for any plugin, as traffic messages are
+ * shared between instances.
+ *
+ * @param this_ The traffic plugin instance
+ *
+ * @return A null-terminated array of traffic messages. The caller is responsible for freeing the array (not its
+ * elements) when it is no longer needed. This method will always return a valid pointer—if the message store is empty,
+ * an empty array (with just one single NULL element) will be returned.
+ */
+struct traffic_message ** traffic_get_stored_messages(struct traffic *this_);
+
+/**
+ * @brief Processes new traffic messages.
+ *
+ * Calling this method delivers new messages in a “push” manner (as opposed to the “pull” fashion of
+ * calling a plugin method).
+ *
+ * Messages which are past their expiration timestamp are skipped, and the flags in the return value
+ * are set only if at least one valid message is found.
+ *
+ * @param this_ The traffic instance
+ * @param messages The new messages
+ */
+void traffic_process_messages(struct traffic * this_, struct traffic_message ** messages);
+
+/**
+ * @brief Sets the mapset for the traffic plugin.
+ *
+ * This sets the mapset from which the segments affected by a traffic report will be retrieved.
+ *
+ * @param this_ The traffic plugin instance
+ * @param ms The mapset
+ */
+void traffic_set_mapset(struct traffic *this_, struct mapset *ms);
+
+/**
+ * @brief Sets the route for the traffic plugin.
+ *
+ * This sets the route which may get notified by the traffic plugin if traffic distortions change.
+ */
+void traffic_set_route(struct traffic *this_, struct route *rt);
+
+/* end of prototypes */
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/navit/traffic/dummy/CMakeLists.txt b/navit/traffic/dummy/CMakeLists.txt
new file mode 100644
index 000000000..83df03b51
--- /dev/null
+++ b/navit/traffic/dummy/CMakeLists.txt
@@ -0,0 +1 @@
+module_add_library(traffic_dummy traffic_dummy.c)
diff --git a/navit/traffic/dummy/traffic_dummy.c b/navit/traffic/dummy/traffic_dummy.c
new file mode 100644
index 000000000..b838752dc
--- /dev/null
+++ b/navit/traffic/dummy/traffic_dummy.c
@@ -0,0 +1,190 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2017 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * @file traffic_dummy.c
+ *
+ * @brief A dummy traffic plugin.
+ *
+ * This is a dummy plugin to test the traffic framework.
+ */
+
+#include <string.h>
+#include <time.h>
+
+#ifdef _POSIX_C_SOURCE
+#include <sys/types.h>
+#endif
+#include "glib_slice.h"
+#include "config.h"
+#include "coord.h"
+#include "item.h"
+#include "xmlconfig.h"
+#include "traffic.h"
+#include "plugin.h"
+#include "debug.h"
+
+/**
+ * @brief Stores information about the plugin instance.
+ */
+struct traffic_priv {
+ struct navit * nav; /*!< The navit instance */
+ int reports_requested; /*!< How many reports have been requested */
+};
+
+struct traffic_message ** traffic_dummy_get_messages(struct traffic_priv * this_);
+
+/**
+ * @brief Returns a dummy traffic report.
+ *
+ * This method will report two messages when first called: The messages indicate queuing traffic on the
+ * A9 Munich–Nuremberg between Neufahrn and Allershausen, and slow traffic on the A96 Lindau–Munich
+ * between Gräfelfing and München-Laim.
+ *
+ * The 10th call will report an update message for the A9 (with a recent timestamp but otherwise the same
+ * data) and a cancellation message for the A96.
+ *
+ * They mimic TMC messages in that coordinates are approximate, TMC identifiers are supplied for the
+ * locations and extra data fields which can be inferred from the TMC location table are filled. The
+ * timestamps indicate a message that has just been received for the first time, i.e. its “first
+ * received” and “last updated” timestamps match and are recent. Expiration is after 20 seconds for
+ * messages in the first feed and 10 seconds for messages in the first feed (far below the lowest
+ * expiration timespan permitted in TMC).
+ *
+ * All other calls to this method will return `NULL`, indicating that there are no messages to report.
+ *
+ * @return A `NULL`-terminated pointer array. Each element points to one `struct traffic_message`.
+ * `NULL` is returned (rather than an empty pointer array) if there are no messages to report.
+ */
+struct traffic_message ** traffic_dummy_get_messages(struct traffic_priv * this_) {
+ struct traffic_message ** messages;
+ struct traffic_point * from;
+ struct traffic_point * to;
+ struct traffic_point * at;
+ struct traffic_point * via;
+ struct traffic_location * location;
+
+ this_->reports_requested++;
+
+ switch (this_->reports_requested) {
+ case 10:
+ messages = g_new0(struct traffic_message *, 6);
+
+ from = traffic_point_new(11.6208, 48.3164, "Neufahrn", "68", "12732-4");
+ to = traffic_point_new(11.5893, 48.429, "Allershausen", "67", "12732");
+ location = traffic_location_new(NULL, from, to, NULL, NULL, "Nürnberg", NULL, location_dir_one,
+ location_fuzziness_low_res, location_ramps_none, type_highway_land, NULL, "A9", "58:1", -1);
+ messages[0] = traffic_message_new_single_event("dummy:A9-68-67", time(NULL), time(NULL),
+ time(NULL) + 86400, 0, location, event_class_congestion, event_congestion_queue);
+
+ from = traffic_point_new(11.4481, 48.1266, "Gräfelfing", "36b", "12961-2");
+ to = traffic_point_new(11.5028, 48.1258, "München-Laim", "38", "12961");
+ location = traffic_location_new(NULL, from, to, NULL, NULL, "München", NULL, location_dir_one,
+ location_fuzziness_low_res, location_ramps_none, type_highway_land, NULL, "A96", "58:1", -1);
+ messages[1] = traffic_message_new_single_event("dummy:A96-36b-38", time(NULL), time(NULL),
+ time(NULL) + 86400, 0, location, event_class_congestion, event_congestion_slow_traffic);
+
+ from = traffic_point_new(11.6143, 48.15255, "Effnertunnel", NULL, "60922");
+ to = traffic_point_new(11.53225, 48.13255, "Trappentreutunnel", NULL, "35333");
+ via = traffic_point_new(11.5728, 48.178, "Petueltunnel", NULL, "29829");
+ location = traffic_location_new(NULL, from, to, via, NULL, NULL, NULL, location_dir_one,
+ location_fuzziness_low_res, location_ramps_none, type_line_unspecified, NULL, "B2R", "58:1", 1);
+ messages[2] = traffic_message_new_single_event("dummy:B2R-N", time(NULL), time(NULL),
+ time(NULL) + 86400, 0, location, event_class_congestion, event_congestion_slow_traffic);
+
+ from = traffic_point_new(11.6143, 48.15255, "Effnertunnel", NULL, "60922");
+ to = traffic_point_new(11.53225, 48.13255, "Trappentreutunnel", NULL, "35333");
+ via = traffic_point_new(11.55085, 48.11225, "Brudermühltunnel", NULL, "35329");
+ location = traffic_location_new(NULL, from, to, via, NULL, NULL, NULL, location_dir_one,
+ location_fuzziness_low_res, location_ramps_none, type_line_unspecified, NULL, "B2R", "58:1", -1);
+ messages[3] = traffic_message_new_single_event("dummy:B2R-S", time(NULL), time(NULL),
+ time(NULL) + 86400, 0, location, event_class_congestion, event_congestion_slow_traffic);
+
+ from = traffic_point_new(11.6208, 48.3164, "Neufahrn", "68", "12727+5");
+ at = traffic_point_new(11.6405, 48.2435, "Garching-Süd", "71", "12727");
+ location = traffic_location_new(at, from, NULL, NULL, NULL, NULL, NULL, location_dir_one,
+ location_fuzziness_low_res, location_ramps_none, type_highway_land, NULL, "A9", "58:1", 1);
+ messages[4] = traffic_message_new_single_event("dummy:A9-71-S", time(NULL), time(NULL),
+ time(NULL) + 86400, 0, location, event_class_congestion, event_congestion_slow_traffic);
+ break;
+
+ case 20:
+ messages = g_new0(struct traffic_message *, 4);
+
+ from = traffic_point_new(11.6208, 48.3164, "Neufahrn", "68", "12732-4");
+ to = traffic_point_new(11.5893, 48.429, "Allershausen", "67", "12732");
+ location = traffic_location_new(NULL, from, to, NULL, NULL, "Nürnberg", NULL, location_dir_one,
+ location_fuzziness_low_res, location_ramps_none, type_highway_land, NULL, "A9", "58:1", -1);
+ messages[0] = traffic_message_new_single_event("dummy:A9-68-67", time(NULL) - 10, time(NULL),
+ time(NULL) + 10, 0, location, event_class_congestion, event_congestion_queue);
+
+ from = traffic_point_new(11.4481, 48.1266, "Gräfelfing", "36b", "12961-2");
+ to = traffic_point_new(11.5028, 48.1258, "München-Laim", "38", "12961");
+ location = traffic_location_new(NULL, from, to, NULL, NULL, "München", NULL, location_dir_one,
+ location_fuzziness_low_res, location_ramps_none, type_highway_land, NULL, "A96", "58:1", -1);
+ messages[1] = traffic_message_new_cancellation("dummy:A96-36b-38", time(NULL) - 10, time(NULL),
+ time(NULL) + 10, location);
+ break;
+
+ default:
+ return NULL;
+ }
+
+ return messages;
+}
+
+/**
+ * @brief The methods implemented by this plugin
+ */
+static struct traffic_methods traffic_dummy_meth = {
+ traffic_dummy_get_messages,
+};
+
+/**
+ * @brief Registers a new dummy traffic plugin
+ *
+ * @param nav The navit instance
+ * @param meth Receives the traffic methods
+ * @param attrs The attributes for the map
+ * @param cbl
+ *
+ * @return A pointer to a `traffic_priv` structure for the plugin instance
+ */
+static struct traffic_priv * traffic_dummy_new(struct navit *nav, struct traffic_methods *meth,
+ struct attr **attrs, struct callback_list *cbl) {
+ struct traffic_priv *ret;
+
+ dbg(lvl_debug, "enter");
+
+ ret = g_new0(struct traffic_priv, 1);
+ *meth = traffic_dummy_meth;
+
+ return ret;
+}
+
+/**
+ * @brief Initializes the traffic plugin.
+ *
+ * This function is called once on startup.
+ */
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+
+ plugin_register_category_traffic("dummy", traffic_dummy_new);
+}
diff --git a/navit/traffic/null/CMakeLists.txt b/navit/traffic/null/CMakeLists.txt
new file mode 100644
index 000000000..c5edbe691
--- /dev/null
+++ b/navit/traffic/null/CMakeLists.txt
@@ -0,0 +1 @@
+module_add_library(traffic_null traffic_null.c)
diff --git a/navit/traffic/null/traffic_null.c b/navit/traffic/null/traffic_null.c
new file mode 100644
index 000000000..94546a666
--- /dev/null
+++ b/navit/traffic/null/traffic_null.c
@@ -0,0 +1,101 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2017 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * @file traffic_null.c
+ *
+ * @brief A null traffic plugin.
+ *
+ * This plugin was mainly designed to test the traffic framework. It acts like a traffic plugin but will
+ * never report any messages. This allows us to have the full traffic functionality without having an
+ * actual source for traffic messages; useful for injecting messages via DBus.
+ */
+
+#include <string.h>
+#include <time.h>
+
+#ifdef _POSIX_C_SOURCE
+#include <sys/types.h>
+#endif
+#include "glib_slice.h"
+#include "config.h"
+#include "coord.h"
+#include "item.h"
+#include "xmlconfig.h"
+#include "traffic.h"
+#include "plugin.h"
+#include "debug.h"
+
+/**
+ * @brief Stores information about the plugin instance.
+ */
+struct traffic_priv {
+ struct navit * nav; /*!< The navit instance */
+};
+
+struct traffic_message ** traffic_null_get_messages(struct traffic_priv * this_);
+
+/**
+ * @brief Returns an empty traffic report.
+ *
+ * @return Always `NULL`
+ */
+struct traffic_message ** traffic_null_get_messages(struct traffic_priv * this_) {
+ return NULL;
+}
+
+/**
+ * @brief The methods implemented by this plugin
+ */
+static struct traffic_methods traffic_null_meth = {
+ traffic_null_get_messages,
+};
+
+/**
+ * @brief Registers a new null traffic plugin
+ *
+ * @param nav The navit instance
+ * @param meth Receives the traffic methods
+ * @param attrs The attributes for the map
+ * @param cbl
+ *
+ * @return A pointer to a `traffic_priv` structure for the plugin instance
+ */
+static struct traffic_priv * traffic_null_new(struct navit *nav, struct traffic_methods *meth,
+ struct attr **attrs, struct callback_list *cbl) {
+ struct traffic_priv *ret;
+
+ dbg(lvl_debug, "enter");
+
+ ret = g_new0(struct traffic_priv, 1);
+ *meth = traffic_null_meth;
+
+ return ret;
+}
+
+/**
+ * @brief Initializes the traffic plugin.
+ *
+ * This function is called once on startup.
+ */
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+
+ plugin_register_category_traffic("null", traffic_null_new);
+}
diff --git a/navit/traffic/traff_android/CMakeLists.txt b/navit/traffic/traff_android/CMakeLists.txt
new file mode 100644
index 000000000..5e5f06df1
--- /dev/null
+++ b/navit/traffic/traff_android/CMakeLists.txt
@@ -0,0 +1 @@
+module_add_library(traffic_traff_android traffic_traff_android.c)
diff --git a/navit/traffic/traff_android/traffic_traff_android.c b/navit/traffic/traff_android/traffic_traff_android.c
new file mode 100644
index 000000000..91d408777
--- /dev/null
+++ b/navit/traffic/traff_android/traffic_traff_android.c
@@ -0,0 +1,173 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2018 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * @file traffic_traff_android.c
+ *
+ * @brief The TraFF plugin for Android
+ *
+ * This plugin receives TraFF feeds via Android broadcasts.
+ */
+
+#include <string.h>
+#include <time.h>
+
+#ifdef _POSIX_C_SOURCE
+#include <sys/types.h>
+#endif
+#include "glib_slice.h"
+#include "config.h"
+#include "item.h"
+#include "attr.h"
+#include "coord.h"
+#include "xmlconfig.h"
+#include "android.h"
+#include "traffic.h"
+#include "plugin.h"
+#include "callback.h"
+#include "debug.h"
+
+/**
+ * @brief Stores information about the plugin instance.
+ */
+struct traffic_priv {
+ struct navit * nav; /**< The navit instance */
+ struct callback * cbid; /**< The callback function for TraFF feeds **/
+ jclass NavitTraffClass; /**< The `NavitTraff` class */
+ jobject NavitTraff; /**< An instance of `NavitTraff` */
+};
+
+struct traffic_message ** traffic_traff_android_get_messages(struct traffic_priv * this_);
+
+/**
+ * @brief Returns an empty traffic report.
+ *
+ * @return Always `NULL`
+ */
+struct traffic_message ** traffic_traff_android_get_messages(struct traffic_priv * this_) {
+ return NULL;
+}
+
+/**
+ * @brief The methods implemented by this plugin
+ */
+static struct traffic_methods traffic_traff_android_meth = {
+ traffic_traff_android_get_messages,
+};
+
+
+/**
+ * @brief Called when a new TraFF feed is received.
+ *
+ * @param this_ Private data for the module instance
+ * @param feed Feed data in string form
+ */
+static void traffic_traff_android_on_feed_received(struct traffic_priv * this_, char * feed) {
+ struct attr * attr;
+ struct attr_iter * a_iter;
+ struct traffic * traffic = NULL;
+ struct traffic_message ** messages;
+
+ dbg(lvl_debug, "enter");
+ attr = g_new0(struct attr, 1);
+ a_iter = navit_attr_iter_new();
+ if (navit_get_attr(this_->nav, attr_traffic, attr, a_iter))
+ traffic = (struct traffic *) attr->u.navit_object;
+ navit_attr_iter_destroy(a_iter);
+ g_free(attr);
+
+ if (!traffic) {
+ dbg(lvl_error, "failed to obtain traffic instance");
+ return;
+ }
+
+ dbg(lvl_debug, "processing traffic feed:\n%s", feed);
+ messages = traffic_get_messages_from_xml_string(traffic, feed);
+ if (messages) {
+ dbg(lvl_debug, "got messages from feed, processing");
+ traffic_process_messages(traffic, messages);
+ g_free(messages);
+ }
+}
+
+
+/**
+ * @brief Initializes a traff_android plugin
+ *
+ * @return True on success, false on failure
+ */
+static int traffic_traff_android_init(struct traffic_priv * this_) {
+ jmethodID cid;
+
+ if (!android_find_class_global("org/navitproject/navit/NavitTraff", &this_->NavitTraffClass))
+ return 0;
+ cid = (*jnienv)->GetMethodID(jnienv, this_->NavitTraffClass, "<init>", "(Landroid/content/Context;I)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no method found");
+ return 0; /* exception thrown */
+ }
+ this_->NavitTraff=(*jnienv)->NewObject(jnienv, this_->NavitTraffClass, cid, android_application,
+ (int) this_->cbid);
+ dbg(lvl_debug,"result=%p", this_->NavitTraff);
+ if (!this_->NavitTraff)
+ return 0;
+ if (this_->NavitTraff)
+ this_->NavitTraff = (*jnienv)->NewGlobalRef(jnienv, this_->NavitTraff);
+
+ return 1;
+}
+
+
+/**
+ * @brief Registers a new traff_android traffic plugin
+ *
+ * @param nav The navit instance
+ * @param meth Receives the traffic methods
+ * @param attrs The attributes for the map
+ * @param cbl
+ *
+ * @return A pointer to a `traffic_priv` structure for the plugin instance
+ */
+static struct traffic_priv * traffic_traff_android_new(struct navit *nav, struct traffic_methods *meth,
+ struct attr **attrs, struct callback_list *cbl) {
+ struct traffic_priv *ret;
+
+ dbg(lvl_debug, "enter");
+
+ ret = g_new0(struct traffic_priv, 1);
+ ret->nav = nav;
+ ret->cbid = callback_new_1(callback_cast(traffic_traff_android_on_feed_received), ret);
+ /* TODO populate members, if any */
+ *meth = traffic_traff_android_meth;
+
+ traffic_traff_android_init(ret);
+
+ return ret;
+}
+
+/**
+ * @brief Initializes the traffic plugin.
+ *
+ * This function is called once on startup.
+ */
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+
+ plugin_register_category_traffic("traff_android", traffic_traff_android_new);
+}
diff --git a/navit/transform.c b/navit/transform.c
index 1c6eeae67..4c0cb68b1 100644
--- a/navit/transform.c
+++ b/navit/transform.c
@@ -62,33 +62,33 @@
* @brief The parameters needed to transform a map for display.
*/
struct transformation {
- int yaw; /* Rotation angle */
- int pitch;
- int ddd; /* 3d mode/isometric view active? (0/1) */
- int m00,m01,m02; /* 3d transformation matrix */
- int m10,m11,m12;
- int m20,m21,m22;
- int xscale,yscale,wscale;
- int xscale3d,yscale3d,wscale3d;
+ int yaw; /* Rotation angle */
+ int pitch;
+ int ddd; /* 3d mode/isometric view active? (0/1) */
+ int m00,m01,m02; /* 3d transformation matrix */
+ int m10,m11,m12;
+ int m20,m21,m22;
+ int xscale,yscale,wscale;
+ int xscale3d,yscale3d,wscale3d;
#ifdef ENABLE_ROLL
- int roll;
- int hog;
+ int roll;
+ int hog;
#endif
- navit_float im00,im01,im02; /* inverse 3d transformation matrix */
- navit_float im10,im11,im12;
- navit_float im20,im21,im22;
- struct map_selection *map_sel;
- struct map_selection *screen_sel;
- struct point screen_center;
- int screen_dist;
- int offx,offy,offz;
- int znear,zfar;
- struct coord map_center; /* Center of source rectangle */
- enum projection pro;
- navit_float scale; /* Scale factor */
- int scale_shift;
- int order;
- int order_base;
+ navit_float im00,im01,im02; /* inverse 3d transformation matrix */
+ navit_float im10,im11,im12;
+ navit_float im20,im21,im22;
+ struct map_selection *map_sel;
+ struct map_selection *screen_sel;
+ struct point screen_center;
+ int screen_dist;
+ int offx,offy,offz;
+ int znear,zfar;
+ struct coord map_center; /* Center of source rectangle */
+ enum projection pro;
+ navit_float scale; /* Scale factor */
+ int scale_shift;
+ int order;
+ int order_base;
};
#ifdef ENABLE_ROLL
@@ -97,254 +97,229 @@ struct transformation {
#define HOG(t) 0
#endif
-static void
-transform_set_screen_dist(struct transformation *t, int dist)
-{
- t->screen_dist=dist;
- t->xscale3d=dist;
- t->yscale3d=dist;
- t->wscale3d=dist << POST_SHIFT;
-}
-
-static void
-transform_setup_matrix(struct transformation *t)
-{
- navit_float det;
- navit_float fac;
- navit_float yawc=navit_cos(-M_PI*t->yaw/180);
- navit_float yaws=navit_sin(-M_PI*t->yaw/180);
- navit_float pitchc=navit_cos(-M_PI*t->pitch/180);
- navit_float pitchs=navit_sin(-M_PI*t->pitch/180);
-#ifdef ENABLE_ROLL
- navit_float rollc=navit_cos(M_PI*t->roll/180);
- navit_float rolls=navit_sin(M_PI*t->roll/180);
+static void transform_set_screen_dist(struct transformation *t, int dist) {
+ t->screen_dist=dist;
+ t->xscale3d=dist;
+ t->yscale3d=dist;
+ t->wscale3d=dist << POST_SHIFT;
+}
+
+static void transform_setup_matrix(struct transformation *t) {
+ navit_float det;
+ navit_float fac;
+ navit_float yawc=navit_cos(-M_PI*t->yaw/180);
+ navit_float yaws=navit_sin(-M_PI*t->yaw/180);
+ navit_float pitchc=navit_cos(-M_PI*t->pitch/180);
+ navit_float pitchs=navit_sin(-M_PI*t->pitch/180);
+#ifdef ENABLE_ROLL
+ navit_float rollc=navit_cos(M_PI*t->roll/180);
+ navit_float rolls=navit_sin(M_PI*t->roll/180);
#else
- navit_float rollc=1;
- navit_float rolls=0;
+ navit_float rollc=1;
+ navit_float rolls=0;
#endif
- int scale=t->scale;
- int order_dir=-1;
-
- dbg(lvl_debug,"yaw=%d pitch=%d center=0x%x,0x%x\n", t->yaw, t->pitch, t->map_center.x, t->map_center.y);
- t->znear=1 << POST_SHIFT;
- t->zfar=300*t->znear;
- t->scale_shift=0;
- t->order=t->order_base;
- if (t->scale >= 1) {
- scale=t->scale;
- } else {
- scale=1.0/t->scale;
- order_dir=1;
- }
- while (scale > 1) {
- if (order_dir < 0)
- t->scale_shift++;
- t->order+=order_dir;
- scale >>= 1;
- }
- fac=(1 << POST_SHIFT) * (1 << t->scale_shift) / t->scale;
- dbg(lvl_debug,"scale_shift=%d order=%d scale=%f fac=%f\n", t->scale_shift, t->order,t->scale,fac);
-
- t->m00=rollc*yawc*fac;
- t->m01=rollc*yaws*fac;
- t->m02=-rolls*fac;
- t->m10=(pitchs*rolls*yawc-pitchc*yaws)*(-fac);
- t->m11=(pitchs*rolls*yaws+pitchc*yawc)*(-fac);
- t->m12=pitchs*rollc*(-fac);
- t->m20=(pitchc*rolls*yawc+pitchs*yaws)*fac;
- t->m21=(pitchc*rolls*yaws-pitchs*yawc)*fac;
- t->m22=pitchc*rollc*fac;
-
- t->offx=t->screen_center.x;
- t->offy=t->screen_center.y;
- if (t->pitch) {
- t->ddd=1;
- t->offz=t->screen_dist;
- dbg(lvl_debug,"near %d far %d\n",t->znear,t->zfar);
- t->xscale=t->xscale3d;
- t->yscale=t->yscale3d;
- t->wscale=t->wscale3d;
- } else {
- t->ddd=0;
- t->offz=0;
- t->xscale=1;
- t->yscale=1;
- t->wscale=1;
- }
- det=(navit_float)t->m00*(navit_float)t->m11*(navit_float)t->m22+
- (navit_float)t->m01*(navit_float)t->m12*(navit_float)t->m20+
- (navit_float)t->m02*(navit_float)t->m10*(navit_float)t->m21-
- (navit_float)t->m02*(navit_float)t->m11*(navit_float)t->m20-
- (navit_float)t->m01*(navit_float)t->m10*(navit_float)t->m22-
- (navit_float)t->m00*(navit_float)t->m12*(navit_float)t->m21;
-
- t->im00=(t->m11*t->m22-t->m12*t->m21)/det;
- t->im01=(t->m02*t->m21-t->m01*t->m22)/det;
- t->im02=(t->m01*t->m12-t->m02*t->m11)/det;
- t->im10=(t->m12*t->m20-t->m10*t->m22)/det;
- t->im11=(t->m00*t->m22-t->m02*t->m20)/det;
- t->im12=(t->m02*t->m10-t->m00*t->m12)/det;
- t->im20=(t->m10*t->m21-t->m11*t->m20)/det;
- t->im21=(t->m01*t->m20-t->m00*t->m21)/det;
- t->im22=(t->m00*t->m11-t->m01*t->m10)/det;
+ int scale=t->scale;
+ int order_dir=-1;
+
+ dbg(lvl_debug,"yaw=%d pitch=%d center=0x%x,0x%x", t->yaw, t->pitch, t->map_center.x, t->map_center.y);
+ t->znear=1 << POST_SHIFT;
+ t->zfar=300*t->znear;
+ t->scale_shift=0;
+ t->order=t->order_base;
+ if (t->scale >= 1) {
+ scale=t->scale;
+ } else {
+ scale=1.0/t->scale;
+ order_dir=1;
+ }
+ while (scale > 1) {
+ if (order_dir < 0)
+ t->scale_shift++;
+ t->order+=order_dir;
+ scale >>= 1;
+ }
+ fac=(1 << POST_SHIFT) * (1 << t->scale_shift) / t->scale;
+ dbg(lvl_debug,"scale_shift=%d order=%d scale=%f fac=%f", t->scale_shift, t->order,t->scale,fac);
+
+ t->m00=rollc*yawc*fac;
+ t->m01=rollc*yaws*fac;
+ t->m02=-rolls*fac;
+ t->m10=(pitchs*rolls*yawc-pitchc*yaws)*(-fac);
+ t->m11=(pitchs*rolls*yaws+pitchc*yawc)*(-fac);
+ t->m12=pitchs*rollc*(-fac);
+ t->m20=(pitchc*rolls*yawc+pitchs*yaws)*fac;
+ t->m21=(pitchc*rolls*yaws-pitchs*yawc)*fac;
+ t->m22=pitchc*rollc*fac;
+
+ t->offx=t->screen_center.x;
+ t->offy=t->screen_center.y;
+ if (t->pitch) {
+ t->ddd=1;
+ t->offz=t->screen_dist;
+ dbg(lvl_debug,"near %d far %d",t->znear,t->zfar);
+ t->xscale=t->xscale3d;
+ t->yscale=t->yscale3d;
+ t->wscale=t->wscale3d;
+ } else {
+ t->ddd=0;
+ t->offz=0;
+ t->xscale=1;
+ t->yscale=1;
+ t->wscale=1;
+ }
+ det=(navit_float)t->m00*(navit_float)t->m11*(navit_float)t->m22+
+ (navit_float)t->m01*(navit_float)t->m12*(navit_float)t->m20+
+ (navit_float)t->m02*(navit_float)t->m10*(navit_float)t->m21-
+ (navit_float)t->m02*(navit_float)t->m11*(navit_float)t->m20-
+ (navit_float)t->m01*(navit_float)t->m10*(navit_float)t->m22-
+ (navit_float)t->m00*(navit_float)t->m12*(navit_float)t->m21;
+
+ t->im00=(t->m11*t->m22-t->m12*t->m21)/det;
+ t->im01=(t->m02*t->m21-t->m01*t->m22)/det;
+ t->im02=(t->m01*t->m12-t->m02*t->m11)/det;
+ t->im10=(t->m12*t->m20-t->m10*t->m22)/det;
+ t->im11=(t->m00*t->m22-t->m02*t->m20)/det;
+ t->im12=(t->m02*t->m10-t->m00*t->m12)/det;
+ t->im20=(t->m10*t->m21-t->m11*t->m20)/det;
+ t->im21=(t->m01*t->m20-t->m00*t->m21)/det;
+ t->im22=(t->m00*t->m11-t->m01*t->m10)/det;
}
struct transformation *
-transform_new(struct pcoord *center, int scale, int yaw)
-{
- struct transformation *this_;
-
- this_=g_new0(struct transformation, 1);
- transform_set_screen_dist(this_, 100);
- this_->order_base=14;
- this_->pro=center->pro;
- this_->map_center.x=center->x;
- this_->map_center.y=center->y;
- this_->scale=scale/16.0;
- transform_set_yaw(this_, yaw);
- return this_;
-}
-
-int
-transform_get_hog(struct transformation *this_)
-{
- return HOG(*this_);
-}
-
-void
-transform_set_hog(struct transformation *this_, int hog)
-{
+transform_new(struct pcoord *center, int scale, int yaw) {
+ struct transformation *this_;
+
+ this_=g_new0(struct transformation, 1);
+ transform_set_screen_dist(this_, 100);
+ this_->order_base=14;
+ this_->pro=center->pro;
+ this_->map_center.x=center->x;
+ this_->map_center.y=center->y;
+ this_->scale=scale/16.0;
+ transform_set_yaw(this_, yaw);
+ return this_;
+}
+
+int transform_get_hog(struct transformation *this_) {
+ return HOG(*this_);
+}
+
+void transform_set_hog(struct transformation *this_, int hog) {
#ifdef ENABLE_ROLL
- this_->hog=hog;
+ this_->hog=hog;
#else
- dbg(lvl_error,"not supported\n");
+ dbg(lvl_error,"not supported");
#endif
}
-int
-transform_get_attr(struct transformation *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- switch (type) {
+int transform_get_attr(struct transformation *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ switch (type) {
#ifdef ENABLE_ROLL
- case attr_hog:
- attr->u.num=this_->hog;
- break;
+ case attr_hog:
+ attr->u.num=this_->hog;
+ break;
#endif
- default:
- return 0;
- }
- attr->type=type;
- return 1;
+ default:
+ return 0;
+ }
+ attr->type=type;
+ return 1;
}
-int
-transform_set_attr(struct transformation *this_, struct attr *attr)
-{
- switch (attr->type) {
+int transform_set_attr(struct transformation *this_, struct attr *attr) {
+ switch (attr->type) {
#ifdef ENABLE_ROLL
- case attr_hog:
- this_->hog=attr->u.num;
- return 1;
+ case attr_hog:
+ this_->hog=attr->u.num;
+ return 1;
#endif
- default:
- return 0;
- }
+ default:
+ return 0;
+ }
}
-int
-transformation_get_order_base(struct transformation *this_)
-{
- return this_->order_base;
+int transformation_get_order_base(struct transformation *this_) {
+ return this_->order_base;
}
-void
-transform_set_order_base(struct transformation *this_, int order_base)
-{
- this_->order_base=order_base;
+void transform_set_order_base(struct transformation *this_, int order_base) {
+ this_->order_base=order_base;
}
struct transformation *
-transform_dup(struct transformation *t)
-{
- struct transformation *ret=g_new0(struct transformation, 1);
- *ret=*t;
- ret->map_sel=map_selection_dup(t->map_sel);
- ret->screen_sel=map_selection_dup(t->screen_sel);
- return ret;
+transform_dup(struct transformation *t) {
+ struct transformation *ret=g_new0(struct transformation, 1);
+ *ret=*t;
+ ret->map_sel=map_selection_dup(t->map_sel);
+ ret->screen_sel=map_selection_dup(t->screen_sel);
+ return ret;
}
static const navit_float gar2geo_units = 360.0/(1<<24);
static const navit_float geo2gar_units = 1/(360.0/(1<<24));
-void
-transform_to_geo(enum projection pro, struct coord *c, struct coord_geo *g)
-{
- int x,y,northern,zone;
- switch (pro) {
- case projection_mg:
- g->lng=c->x/6371000.0/M_PI*180;
- g->lat=navit_atan(exp(c->y/6371000.0))/M_PI*360-90;
- break;
- case projection_garmin:
- g->lng=c->x*gar2geo_units;
- g->lat=c->y*gar2geo_units;
- break;
- case projection_utm:
- x=c->x;
- y=c->y;
- northern=y >= 0;
- if (!northern) {
- y+=10000000;
- }
- zone=(x/1000000);
- x=x%1000000;
- transform_utm_to_geo(x, y, zone, northern, g);
- break;
- default:
- break;
- }
-}
-
-void
-transform_from_geo(enum projection pro, struct coord_geo *g, struct coord *c)
-{
- switch (pro) {
- case projection_mg:
- c->x=g->lng*6371000.0*M_PI/180;
- c->y=log(navit_tan(M_PI_4+g->lat*M_PI/360))*6371000.0;
- break;
- case projection_garmin:
- c->x=g->lng*geo2gar_units;
- c->y=g->lat*geo2gar_units;
- break;
- default:
- break;
- }
-}
-
-void
-transform_from_to_count(struct coord *cfrom, enum projection from, struct coord *cto, enum projection to, int count)
-{
- struct coord_geo g;
- int i;
-
- for (i = 0 ; i < count ; i++) {
- transform_to_geo(from, cfrom, &g);
- transform_from_geo(to, &g, cto);
- cfrom++;
- cto++;
- }
-}
-
-void
-transform_from_to(struct coord *cfrom, enum projection from, struct coord *cto, enum projection to)
-{
- struct coord_geo g;
- transform_to_geo(from, cfrom, &g);
- transform_from_geo(to, &g, cto);
+void transform_to_geo(enum projection pro, struct coord *c, struct coord_geo *g) {
+ int x,y,northern,zone;
+ switch (pro) {
+ case projection_mg:
+ g->lng=c->x/6371000.0/M_PI*180;
+ g->lat=navit_atan(exp(c->y/6371000.0))/M_PI*360-90;
+ break;
+ case projection_garmin:
+ g->lng=c->x*gar2geo_units;
+ g->lat=c->y*gar2geo_units;
+ break;
+ case projection_utm:
+ x=c->x;
+ y=c->y;
+ northern=y >= 0;
+ if (!northern) {
+ y+=10000000;
+ }
+ zone=(x/1000000);
+ x=x%1000000;
+ transform_utm_to_geo(x, y, zone, northern, g);
+ break;
+ default:
+ break;
+ }
+}
+
+void transform_from_geo(enum projection pro, struct coord_geo *g, struct coord *c) {
+ switch (pro) {
+ case projection_mg:
+ c->x=g->lng*6371000.0*M_PI/180;
+ c->y=log(navit_tan(M_PI_4+g->lat*M_PI/360))*6371000.0;
+ break;
+ case projection_garmin:
+ c->x=g->lng*geo2gar_units;
+ c->y=g->lat*geo2gar_units;
+ break;
+ default:
+ break;
+ }
+}
+
+void transform_from_to_count(struct coord *cfrom, enum projection from, struct coord *cto, enum projection to,
+ int count) {
+ struct coord_geo g;
+ int i;
+
+ for (i = 0 ; i < count ; i++) {
+ transform_to_geo(from, cfrom, &g);
+ transform_from_geo(to, &g, cto);
+ cfrom++;
+ cto++;
+ }
+}
+
+void transform_from_to(struct coord *cfrom, enum projection from, struct coord *cto, enum projection to) {
+ struct coord_geo g;
+ transform_to_geo(from, cfrom, &g);
+ transform_from_geo(to, &g, cto);
}
@@ -359,14 +334,12 @@ transform_from_to(struct coord *cfrom, enum projection from, struct coord *cto,
* @param b Semi-minor axis of the ellipsoid
* @param cart Points to a structure that will receive the Cartesian coordinates
*/
-void
-transform_geo_to_cart(struct coord_geo *geo, navit_float a, navit_float b, struct coord_geo_cart *cart)
-{
- navit_float n,ee=1-b*b/(a*a);
- n = a/sqrtf(1-ee*navit_sin(geo->lat)*navit_sin(geo->lat));
- cart->x=n*navit_cos(geo->lat)*navit_cos(geo->lng);
- cart->y=n*navit_cos(geo->lat)*navit_sin(geo->lng);
- cart->z=n*(1-ee)*navit_sin(geo->lat);
+void transform_geo_to_cart(struct coord_geo *geo, navit_float a, navit_float b, struct coord_geo_cart *cart) {
+ navit_float n,ee=1-b*b/(a*a);
+ n = a/sqrtf(1-ee*navit_sin(geo->lat)*navit_sin(geo->lat));
+ cart->x=n*navit_cos(geo->lat)*navit_cos(geo->lng);
+ cart->y=n*navit_cos(geo->lat)*navit_sin(geo->lng);
+ cart->z=n*(1-ee)*navit_sin(geo->lat);
}
@@ -381,23 +354,19 @@ transform_geo_to_cart(struct coord_geo *geo, navit_float a, navit_float b, struc
* @param b Semi-minor axis of the ellipsoid
* @param geo Points to a structure that will receive the geodetic coordinates
*/
-void
-transform_cart_to_geo(struct coord_geo_cart *cart, navit_float a, navit_float b, struct coord_geo *geo)
-{
- navit_float lat,lati,n,ee=1-b*b/(a*a), lng = navit_tan(cart->y/cart->x);
-
- lat = navit_tan(cart->z / navit_sqrt((cart->x * cart->x) + (cart->y * cart->y)));
- do
- {
- lati = lat;
-
- n = a / navit_sqrt(1-ee*navit_sin(lat)*navit_sin(lat));
- lat = navit_atan((cart->z + ee * n * navit_sin(lat)) / navit_sqrt(cart->x * cart->x + cart->y * cart->y));
- }
- while (fabs(lat - lati) >= 0.000000000000001);
+void transform_cart_to_geo(struct coord_geo_cart *cart, navit_float a, navit_float b, struct coord_geo *geo) {
+ navit_float lat,lati,n,ee=1-b*b/(a*a), lng = navit_tan(cart->y/cart->x);
+
+ lat = navit_tan(cart->z / navit_sqrt((cart->x * cart->x) + (cart->y * cart->y)));
+ do {
+ lati = lat;
+
+ n = a / navit_sqrt(1-ee*navit_sin(lat)*navit_sin(lat));
+ lat = navit_atan((cart->z + ee * n * navit_sin(lat)) / navit_sqrt(cart->x * cart->x + cart->y * cart->y));
+ } while (fabs(lat - lati) >= 0.000000000000001);
- geo->lng=lng/M_PI*180;
- geo->lat=lat/M_PI*180;
+ geo->lng=lng/M_PI*180;
+ geo->lat=lat/M_PI*180;
}
@@ -408,617 +377,550 @@ transform_cart_to_geo(struct coord_geo_cart *cart, navit_float a, navit_float b,
*
* @author Chuck Gantz- chuck.gantz@globalstar.com
*/
-void
-transform_utm_to_geo(const double UTMEasting, const double UTMNorthing, int ZoneNumber, int NorthernHemisphere, struct coord_geo *geo)
-{
-//East Longitudes are positive, West longitudes are negative.
+void transform_utm_to_geo(const double UTMEasting, const double UTMNorthing, int ZoneNumber, int NorthernHemisphere,
+ struct coord_geo *geo) {
+//East Longitudes are positive, West longitudes are negative.
//North latitudes are positive, South latitudes are negative
-//Lat and Long are in decimal degrees.
-
- double Lat, Long;
- double k0 = 0.99960000000000004;
- double a = 6378137;
- double eccSquared = 0.0066943799999999998;
- double eccPrimeSquared;
- double e1 = (1-sqrt(1-eccSquared))/(1+sqrt(1-eccSquared));
- double N1, T1, C1, R1, D, M;
- double LongOrigin;
- double mu, phi1Rad;
- double x, y;
- double rad2deg = 180/M_PI;
-
- x = UTMEasting - 500000.0; //remove 500,000 meter offset for longitude
- y = UTMNorthing;
-
- if (!NorthernHemisphere) {
- y -= 10000000.0;//remove 10,000,000 meter offset used for southern hemisphere
- }
-
- LongOrigin = (ZoneNumber - 1)*6 - 180 + 3; //+3 puts origin in middle of zone
-
- eccPrimeSquared = (eccSquared)/(1-eccSquared);
-
- M = y / k0;
- mu = M/(a*(1-eccSquared/4-3*eccSquared*eccSquared/64-5*eccSquared*eccSquared*eccSquared/256));
- phi1Rad = mu + (3*e1/2-27*e1*e1*e1/32)*sin(2*mu)
- + (21*e1*e1/16-55*e1*e1*e1*e1/32)*sin(4*mu)
- +(151*e1*e1*e1/96)*sin(6*mu);
-
- N1 = a/sqrt(1-eccSquared*sin(phi1Rad)*sin(phi1Rad));
- T1 = tan(phi1Rad)*tan(phi1Rad);
- C1 = eccPrimeSquared*cos(phi1Rad)*cos(phi1Rad);
- R1 = a*(1-eccSquared)/pow(1-eccSquared*sin(phi1Rad)*sin(phi1Rad), 1.5);
- D = x/(N1*k0);
-
- Lat = phi1Rad - (N1*tan(phi1Rad)/R1)*(D*D/2-(5+3*T1+10*C1-4*C1*C1-9*eccPrimeSquared)*D*D*D*D/24
- +(61+90*T1+298*C1+45*T1*T1-252*eccPrimeSquared-3*C1*C1)*D*D*D*D*D*D/720);
- Lat = Lat * rad2deg;
-
- Long = (D-(1+2*T1+C1)*D*D*D/6+(5-2*C1+28*T1-3*C1*C1+8*eccPrimeSquared+24*T1*T1)
- *D*D*D*D*D/120)/cos(phi1Rad);
- Long = LongOrigin + Long * rad2deg;
-
- geo->lat=Lat;
- geo->lng=Long;
-}
-
-static struct coord
-transform_correct_projection(struct transformation *t, enum projection required_projection, struct coord c)
-{
- struct coord result;
- struct coord_geo g;
- if (required_projection == t->pro) {
- result=c;
- } else {
- transform_to_geo(required_projection, &c, &g);
- transform_from_geo(t->pro, &g, &result);
- }
- return result;
-}
-
-static struct coord
-transform_shift_by_center_and_scale(struct transformation *t, struct coord c)
-{
- struct coord result;
- result.x = c.x - t->map_center.x;
- result.y = c.y - t->map_center.y;
- result.x >>= t->scale_shift;
- result.y >>= t->scale_shift;
- return result;
+//Lat and Long are in decimal degrees.
+
+ double Lat, Long;
+ double k0 = 0.99960000000000004;
+ double a = 6378137;
+ double eccSquared = 0.0066943799999999998;
+ double eccPrimeSquared;
+ double e1 = (1-sqrt(1-eccSquared))/(1+sqrt(1-eccSquared));
+ double N1, T1, C1, R1, D, M;
+ double LongOrigin;
+ double mu, phi1Rad;
+ double x, y;
+ double rad2deg = 180/M_PI;
+
+ x = UTMEasting - 500000.0; //remove 500,000 meter offset for longitude
+ y = UTMNorthing;
+
+ if (!NorthernHemisphere) {
+ y -= 10000000.0;//remove 10,000,000 meter offset used for southern hemisphere
+ }
+
+ LongOrigin = (ZoneNumber - 1)*6 - 180 + 3; //+3 puts origin in middle of zone
+
+ eccPrimeSquared = (eccSquared)/(1-eccSquared);
+
+ M = y / k0;
+ mu = M/(a*(1-eccSquared/4-3*eccSquared*eccSquared/64-5*eccSquared*eccSquared*eccSquared/256));
+ phi1Rad = mu + (3*e1/2-27*e1*e1*e1/32)*sin(2*mu)
+ + (21*e1*e1/16-55*e1*e1*e1*e1/32)*sin(4*mu)
+ +(151*e1*e1*e1/96)*sin(6*mu);
+
+ N1 = a/sqrt(1-eccSquared*sin(phi1Rad)*sin(phi1Rad));
+ T1 = tan(phi1Rad)*tan(phi1Rad);
+ C1 = eccPrimeSquared*cos(phi1Rad)*cos(phi1Rad);
+ R1 = a*(1-eccSquared)/pow(1-eccSquared*sin(phi1Rad)*sin(phi1Rad), 1.5);
+ D = x/(N1*k0);
+
+ Lat = phi1Rad - (N1*tan(phi1Rad)/R1)*(D*D/2-(5+3*T1+10*C1-4*C1*C1-9*eccPrimeSquared)*D*D*D*D/24
+ +(61+90*T1+298*C1+45*T1*T1-252*eccPrimeSquared-3*C1*C1)*D*D*D*D*D*D/720);
+ Lat = Lat * rad2deg;
+
+ Long = (D-(1+2*T1+C1)*D*D*D/6+(5-2*C1+28*T1-3*C1*C1+8*eccPrimeSquared+24*T1*T1)
+ *D*D*D*D*D/120)/cos(phi1Rad);
+ Long = LongOrigin + Long * rad2deg;
+
+ geo->lat=Lat;
+ geo->lng=Long;
+}
+
+static struct coord transform_correct_projection(struct transformation *t, enum projection required_projection,
+ struct coord c) {
+ struct coord result;
+ struct coord_geo g;
+ if (required_projection == t->pro) {
+ result=c;
+ } else {
+ transform_to_geo(required_projection, &c, &g);
+ transform_from_geo(t->pro, &g, &result);
+ }
+ return result;
+}
+
+static struct coord transform_shift_by_center_and_scale(struct transformation *t, struct coord c) {
+ struct coord result;
+ result.x = c.x - t->map_center.x;
+ result.y = c.y - t->map_center.y;
+ result.x >>= t->scale_shift;
+ result.y >>= t->scale_shift;
+ return result;
}
struct coord_3d {
- int x;
- int y;
- int z;
+ int x;
+ int y;
+ int z;
};
-static struct coord_3d
-transform_rotate(struct transformation *t, struct coord c)
-{
- struct coord_3d result;
- result.x=c.x*t->m00+c.y*t->m01+HOG(*t)*t->m02;
- result.y=c.x*t->m10+c.y*t->m11+HOG(*t)*t->m12;
- result.z=(c.x*t->m20+c.y*t->m21+HOG(*t)*t->m22);
- result.z+=t->offz << POST_SHIFT;
- dbg(lvl_debug, "result: (%d,%d,%d)\n", result.x,result.y,result.z);
- return result;
-}
-
-static struct coord_3d
-transform_z_clip(struct coord_3d c, struct coord_3d c_old, int zlimit)
-{
- struct coord_3d result;
- float clip_factor = ((float)zlimit-c.z)/(c_old.z-c.z);
- dbg(lvl_debug,"in (%d,%d,%d) - (%d,%d,%d)\n", c.x,c.y,c.z, c_old.x,c_old.y,c_old.z);
- result.x=c.x+(c_old.x-c.x)*clip_factor;
- result.y=c.y+(c_old.y-c.y)*clip_factor;
- result.z=zlimit;
- dbg(lvl_debug,"clip result: (%d,%d,%d)\n", result.x, result.y, result.z);
- return result;
-}
-
-static struct point
-transform_project_onto_view_plane(struct transformation *t, struct coord_3d c)
-{
- struct point result;
-#if 0
- dbg(lvl_debug,"z=%d\n",c.z);
-#endif
- result.x = (long long)c.x*t->xscale/c.z;
- result.y = (long long)c.y*t->yscale/c.z;
- return result;
+static struct coord_3d transform_rotate(struct transformation *t, struct coord c) {
+ struct coord_3d result;
+ result.x=c.x*t->m00+c.y*t->m01+HOG(*t)*t->m02;
+ result.y=c.x*t->m10+c.y*t->m11+HOG(*t)*t->m12;
+ result.z=(c.x*t->m20+c.y*t->m21+HOG(*t)*t->m22);
+ result.z+=t->offz << POST_SHIFT;
+ dbg(lvl_debug, "result: (%d,%d,%d)", result.x,result.y,result.z);
+ return result;
}
-static int
-transform_points_too_close(struct point screen_point, struct point screen_point_old, int mindist)
-{
- if (!mindist){
- return 0;
- }
- // approximation of Euclidean distance
- return (abs(screen_point.x - screen_point_old.x) +
- abs(screen_point.y - screen_point_old.y)) < mindist;
-}
-
-struct z_clip_result{
- struct coord_3d clipped_coord;
- int visible;
- int process_coord_again;
- int skip_coord;
-};
+static struct coord_3d transform_z_clip(struct coord_3d c, struct coord_3d c_old, int zlimit) {
+ struct coord_3d result;
+ float clip_factor = ((float)zlimit-c.z)/(c_old.z-c.z);
+ dbg(lvl_debug,"in (%d,%d,%d) - (%d,%d,%d)", c.x,c.y,c.z, c_old.x,c_old.y,c_old.z);
+ result.x=c.x+(c_old.x-c.x)*clip_factor;
+ result.y=c.y+(c_old.y-c.y)*clip_factor;
+ result.z=zlimit;
+ dbg(lvl_debug,"clip result: (%d,%d,%d)", result.x, result.y, result.z);
+ return result;
+}
-static struct z_clip_result
-transform_z_clip_if_necessary(struct coord_3d coord, int zlimit, struct z_clip_result clip_result_old)
-{
- int visibility_changed;
- struct z_clip_result clip_result={{0,0}, 0, 0, 0};
- clip_result.visible=(coord.z < zlimit ? 0:1);
- visibility_changed=(clip_result_old.visible != -1)&&(clip_result.visible != clip_result_old.visible);
- if (visibility_changed) {
- clip_result.clipped_coord=transform_z_clip(coord, clip_result_old.clipped_coord, zlimit);
- } else {
- clip_result.clipped_coord=coord;
- }
- if (clip_result.visible && visibility_changed){
- // line was clipped, but current point
- // is visible -> process it again
- clip_result.process_coord_again=1;
- }else if (!clip_result.visible && !visibility_changed){
- clip_result.skip_coord=1;
- }
- return clip_result;
-}
-
-int
-transform(struct transformation *t, enum projection required_projection, struct coord *input,
- struct point *result, int count, int mindist, int width, int *width_result)
-{
- struct coord projected_coord, shifted_coord;
- struct coord_3d rotated_coord;
- struct point screen_point;
- int zlimit=t->znear;
- struct z_clip_result clip_result, clip_result_old={{0,0}, -1, 0, 0};
- int i,result_idx = 0,result_idx_last=0;
- dbg(lvl_debug,"count=%d\n", count);
- for (i=0; i < count; i++) {
- dbg(lvl_debug, "input coord %d: (%d, %d)\n", i, input[i].x, input[i].y);
-#if 0 /* doesn't work as wanted */
- if (i && input[i].x == input[0].x && input[i].y == input[0].y && result_idx && !width_result) {
- result[result_idx++]=result[0];
- continue;
- }
-#endif
- projected_coord = transform_correct_projection(t, required_projection, input[i]);
- shifted_coord = transform_shift_by_center_and_scale(t, projected_coord);
- rotated_coord = transform_rotate(t, shifted_coord);
-
- if (t->ddd) {
- clip_result=transform_z_clip_if_necessary(rotated_coord, zlimit, clip_result_old);
- clip_result_old=clip_result;
- if(clip_result.process_coord_again){
- i--;
- } else if (clip_result.skip_coord){
- continue;
- }
+static struct point transform_project_onto_view_plane(struct transformation *t, struct coord_3d c) {
+ struct point result;
#if 0
- clip_result.clipped_coord.z=2000000;
+ dbg(lvl_debug,"z=%d",c.z);
#endif
- screen_point = transform_project_onto_view_plane(t, clip_result.clipped_coord);
- } else {
- screen_point.x = rotated_coord.x>>POST_SHIFT;
- screen_point.y = rotated_coord.y>>POST_SHIFT;
- }
- screen_point.x+=t->offx;
- screen_point.y+=t->offy;
- dbg(lvl_debug,"result: (%d, %d)\n", screen_point.x, screen_point.y);
-
- if (i != 0 && i != count-1 &&
- (input[i+1].x != input[0].x || input[i+1].y != input[0].y)) {
- if (transform_points_too_close(screen_point, result[result_idx_last], mindist)){
- continue;
- }
- }
- result[result_idx]=screen_point;
- if (width_result) {
- if (t->ddd) {
- dbg(lvl_debug,"width %d * %d / %d\n",width,t->wscale,clip_result.clipped_coord.z);
- width_result[result_idx]=width*t->wscale/clip_result.clipped_coord.z;
- } else
- width_result[result_idx]=width;
- }
- result_idx_last=result_idx;
- result_idx++;
- }
- return result_idx;
-}
-
-static void
-transform_apply_inverse_matrix(struct transformation *t, struct coord_geo_cart *in, struct coord_geo_cart *out)
-{
- out->x=in->x*t->im00+in->y*t->im01+in->z*t->im02;
- out->y=in->x*t->im10+in->y*t->im11+in->z*t->im12;
- out->z=in->x*t->im20+in->y*t->im21+in->z*t->im22;
+ result.x = (long long)c.x*t->xscale/c.z;
+ result.y = (long long)c.y*t->yscale/c.z;
+ return result;
}
-static int
-transform_zplane_intersection(struct coord_geo_cart *p1, struct coord_geo_cart *p2, navit_float z, struct coord_geo_cart *result)
-{
- navit_float dividend=z-p1->z;
- navit_float divisor=p2->z-p1->z;
- navit_float q;
- if (!divisor) {
- if (dividend)
- return 0; /* no intersection */
- else
- return 3; /* identical planes */
- }
- q=dividend/divisor;
- result->x=p1->x+q*(p2->x-p1->x);
- result->y=p1->y+q*(p2->y-p1->y);
- result->z=z;
- if (q >= 0 && q <= 1)
- return 1; /* intersection within [p1,p2] */
- return 2; /* intersection without [p1,p2] */
-}
-
-static void
-transform_screen_to_3d(struct transformation *t, struct point *p, navit_float z, struct coord_geo_cart *cg)
-{
- double xc,yc;
- double offz=t->offz << POST_SHIFT;
- xc=p->x - t->offx;
- yc=p->y - t->offy;
- cg->x=xc*z/t->xscale;
- cg->y=yc*z/t->yscale;
- cg->z=z-offz;
-}
-
-static int
-transform_reverse_near_far(struct transformation *t, struct point *p, struct coord *c, int near, int far)
-{
- double xc,yc;
- dbg(lvl_debug,"%d,%d\n",p->x,p->y);
- if (t->ddd) {
- struct coord_geo_cart nearc,farc,nears,fars,intersection;
- transform_screen_to_3d(t, p, near, &nearc);
- transform_screen_to_3d(t, p, far, &farc);
- transform_apply_inverse_matrix(t, &nearc, &nears);
- transform_apply_inverse_matrix(t, &farc, &fars);
- if (transform_zplane_intersection(&nears, &fars, HOG(*t), &intersection) != 1)
- return 0;
- xc=intersection.x;
- yc=intersection.y;
- } else {
- double xcn,ycn;
- xcn=p->x - t->offx;
- ycn=p->y - t->offy;
- xc=(xcn*t->im00+ycn*t->im01)*(1 << POST_SHIFT);
- yc=(xcn*t->im10+ycn*t->im11)*(1 << POST_SHIFT);
- }
- c->x=xc*(1 << t->scale_shift)+t->map_center.x;
- c->y=yc*(1 << t->scale_shift)+t->map_center.y;
- return 1;
-}
-
-int
-transform_reverse(struct transformation *t, struct point *p, struct coord *c)
-{
- return transform_reverse_near_far(t, p, c, t->znear, t->zfar);
-}
-
-double
-transform_pixels_to_map_distance(struct transformation *transformation, int pixels)
-{
- struct point line_in_map_center[2];
- struct coord c[2];
- struct point screen_center=transformation->screen_center;
- // Generally, the scale will not be the same across the map
- // (for example with Mercator projection), so calculate the
- // conversion in the screen center for a reasonable average value.
- line_in_map_center[0].x=screen_center.x-pixels/2;
- line_in_map_center[1].x=screen_center.x+pixels/2;
- line_in_map_center[0].y=screen_center.y;
- line_in_map_center[1].y=screen_center.y;
- transform_reverse(transformation, &line_in_map_center[0], &c[0]);
- transform_reverse(transformation, &line_in_map_center[1], &c[1]);
- return transform_distance(transform_get_projection(transformation), &c[0], &c[1]);
-}
-
-enum projection
-transform_get_projection(struct transformation *this_)
-{
- return this_->pro;
-}
-
-void
-transform_set_projection(struct transformation *this_, enum projection pro)
-{
- this_->pro=pro;
+static int transform_points_too_close(struct point screen_point, struct point screen_point_old, int mindist) {
+ if (!mindist) {
+ return 0;
+ }
+ // approximation of Euclidean distance
+ return (abs(screen_point.x - screen_point_old.x) +
+ abs(screen_point.y - screen_point_old.y)) < mindist;
}
-static int
-min4(int v1,int v2, int v3, int v4)
-{
- int res=v1;
- if (v2 < res)
- res=v2;
- if (v3 < res)
- res=v3;
- if (v4 < res)
- res=v4;
- return res;
-}
+struct z_clip_result {
+ struct coord_3d clipped_coord;
+ int visible;
+ int process_coord_again;
+ int skip_coord;
+};
-static int
-max4(int v1,int v2, int v3, int v4)
-{
- int res=v1;
- if (v2 > res)
- res=v2;
- if (v3 > res)
- res=v3;
- if (v4 > res)
- res=v4;
- return res;
+static struct z_clip_result transform_z_clip_if_necessary(struct coord_3d coord, int zlimit,
+ struct z_clip_result clip_result_old) {
+ int visibility_changed;
+ struct z_clip_result clip_result= {{0,0}, 0, 0, 0};
+ clip_result.visible=(coord.z < zlimit ? 0:1);
+ visibility_changed=(clip_result_old.visible != -1)&&(clip_result.visible != clip_result_old.visible);
+ if (visibility_changed) {
+ clip_result.clipped_coord=transform_z_clip(coord, clip_result_old.clipped_coord, zlimit);
+ } else {
+ clip_result.clipped_coord=coord;
+ }
+ if (clip_result.visible && visibility_changed) {
+ // line was clipped, but current point
+ // is visible -> process it again
+ clip_result.process_coord_again=1;
+ } else if (!clip_result.visible && !visibility_changed) {
+ clip_result.skip_coord=1;
+ }
+ return clip_result;
+}
+
+int transform(struct transformation *t, enum projection required_projection, struct coord *input,
+ struct point *result, int count, int mindist, int width, int *width_result) {
+ struct coord projected_coord, shifted_coord;
+ struct coord_3d rotated_coord;
+ struct point screen_point;
+ int zlimit=t->znear;
+ struct z_clip_result clip_result, clip_result_old= {{0,0}, -1, 0, 0};
+ int i,result_idx = 0,result_idx_last=0;
+ dbg(lvl_debug,"count=%d", count);
+ for (i=0; i < count; i++) {
+ dbg(lvl_debug, "input coord %d: (%d, %d)", i, input[i].x, input[i].y);
+#if 0 /* doesn't work as wanted */
+ if (i && input[i].x == input[0].x && input[i].y == input[0].y && result_idx && !width_result) {
+ result[result_idx++]=result[0];
+ continue;
+ }
+#endif
+ projected_coord = transform_correct_projection(t, required_projection, input[i]);
+ shifted_coord = transform_shift_by_center_and_scale(t, projected_coord);
+ rotated_coord = transform_rotate(t, shifted_coord);
+
+ if (t->ddd) {
+ clip_result=transform_z_clip_if_necessary(rotated_coord, zlimit, clip_result_old);
+ clip_result_old=clip_result;
+ if(clip_result.process_coord_again) {
+ i--;
+ } else if (clip_result.skip_coord) {
+ continue;
+ }
+#if 0
+ clip_result.clipped_coord.z=2000000;
+#endif
+ screen_point = transform_project_onto_view_plane(t, clip_result.clipped_coord);
+ } else {
+ screen_point.x = rotated_coord.x>>POST_SHIFT;
+ screen_point.y = rotated_coord.y>>POST_SHIFT;
+ }
+ screen_point.x+=t->offx;
+ screen_point.y+=t->offy;
+ dbg(lvl_debug,"result: (%d, %d)", screen_point.x, screen_point.y);
+
+ if (i != 0 && i != count-1 &&
+ (input[i+1].x != input[0].x || input[i+1].y != input[0].y)) {
+ if (transform_points_too_close(screen_point, result[result_idx_last], mindist)) {
+ continue;
+ }
+ }
+ result[result_idx]=screen_point;
+ if (width_result) {
+ if (t->ddd) {
+ dbg(lvl_debug,"width %d * %d / %d",width,t->wscale,clip_result.clipped_coord.z);
+ width_result[result_idx]=width*t->wscale/clip_result.clipped_coord.z;
+ } else
+ width_result[result_idx]=width;
+ }
+ result_idx_last=result_idx;
+ result_idx++;
+ }
+ return result_idx;
+}
+
+static void transform_apply_inverse_matrix(struct transformation *t, struct coord_geo_cart *in,
+ struct coord_geo_cart *out) {
+ out->x=in->x*t->im00+in->y*t->im01+in->z*t->im02;
+ out->y=in->x*t->im10+in->y*t->im11+in->z*t->im12;
+ out->z=in->x*t->im20+in->y*t->im21+in->z*t->im22;
+}
+
+static int transform_zplane_intersection(struct coord_geo_cart *p1, struct coord_geo_cart *p2, navit_float z,
+ struct coord_geo_cart *result) {
+ navit_float dividend=z-p1->z;
+ navit_float divisor=p2->z-p1->z;
+ navit_float q;
+ if (!divisor) {
+ if (dividend)
+ return 0; /* no intersection */
+ else
+ return 3; /* identical planes */
+ }
+ q=dividend/divisor;
+ result->x=p1->x+q*(p2->x-p1->x);
+ result->y=p1->y+q*(p2->y-p1->y);
+ result->z=z;
+ if (q >= 0 && q <= 1)
+ return 1; /* intersection within [p1,p2] */
+ return 2; /* intersection without [p1,p2] */
+}
+
+static void transform_screen_to_3d(struct transformation *t, struct point *p, navit_float z,
+ struct coord_geo_cart *cg) {
+ double xc,yc;
+ double offz=t->offz << POST_SHIFT;
+ xc=p->x - t->offx;
+ yc=p->y - t->offy;
+ cg->x=xc*z/t->xscale;
+ cg->y=yc*z/t->yscale;
+ cg->z=z-offz;
+}
+
+static int transform_reverse_near_far(struct transformation *t, struct point *p, struct coord *c, int near, int far) {
+ double xc,yc;
+ dbg(lvl_debug,"%d,%d",p->x,p->y);
+ if (t->ddd) {
+ struct coord_geo_cart nearc,farc,nears,fars,intersection;
+ transform_screen_to_3d(t, p, near, &nearc);
+ transform_screen_to_3d(t, p, far, &farc);
+ transform_apply_inverse_matrix(t, &nearc, &nears);
+ transform_apply_inverse_matrix(t, &farc, &fars);
+ if (transform_zplane_intersection(&nears, &fars, HOG(*t), &intersection) != 1)
+ return 0;
+ xc=intersection.x;
+ yc=intersection.y;
+ } else {
+ double xcn,ycn;
+ xcn=p->x - t->offx;
+ ycn=p->y - t->offy;
+ xc=(xcn*t->im00+ycn*t->im01)*(1 << POST_SHIFT);
+ yc=(xcn*t->im10+ycn*t->im11)*(1 << POST_SHIFT);
+ }
+ c->x=xc*(1 << t->scale_shift)+t->map_center.x;
+ c->y=yc*(1 << t->scale_shift)+t->map_center.y;
+ return 1;
+}
+
+int transform_reverse(struct transformation *t, struct point *p, struct coord *c) {
+ return transform_reverse_near_far(t, p, c, t->znear, t->zfar);
+}
+
+double transform_pixels_to_map_distance(struct transformation *transformation, int pixels) {
+ struct point line_in_map_center[2];
+ struct coord c[2];
+ struct point screen_center=transformation->screen_center;
+ // Generally, the scale will not be the same across the map
+ // (for example with Mercator projection), so calculate the
+ // conversion in the screen center for a reasonable average value.
+ line_in_map_center[0].x=screen_center.x-pixels/2;
+ line_in_map_center[1].x=screen_center.x+pixels/2;
+ line_in_map_center[0].y=screen_center.y;
+ line_in_map_center[1].y=screen_center.y;
+ transform_reverse(transformation, &line_in_map_center[0], &c[0]);
+ transform_reverse(transformation, &line_in_map_center[1], &c[1]);
+ return transform_distance(transform_get_projection(transformation), &c[0], &c[1]);
+}
+
+enum projection transform_get_projection(struct transformation *this_) {
+ return this_->pro;
+}
+
+void transform_set_projection(struct transformation *this_, enum projection pro) {
+ this_->pro=pro;
+}
+
+static int min4(int v1,int v2, int v3, int v4) {
+ int res=v1;
+ if (v2 < res)
+ res=v2;
+ if (v3 < res)
+ res=v3;
+ if (v4 < res)
+ res=v4;
+ return res;
+}
+
+static int max4(int v1,int v2, int v3, int v4) {
+ int res=v1;
+ if (v2 > res)
+ res=v2;
+ if (v3 > res)
+ res=v3;
+ if (v4 > res)
+ res=v4;
+ return res;
}
struct map_selection *
-transform_get_selection(struct transformation *this_, enum projection pro, int order)
-{
-
- struct map_selection *ret,*curri,*curro;
- struct coord_geo g;
-
- ret=map_selection_dup(this_->map_sel);
- curri=this_->map_sel;
- curro=ret;
- while (curri) {
- if (this_->pro != pro) {
- transform_to_geo(this_->pro, &curri->u.c_rect.lu, &g);
- transform_from_geo(pro, &g, &curro->u.c_rect.lu);
- dbg(lvl_debug,"%f,%f", g.lat, g.lng);
- transform_to_geo(this_->pro, &curri->u.c_rect.rl, &g);
- transform_from_geo(pro, &g, &curro->u.c_rect.rl);
- dbg(lvl_debug,": - %f,%f\n", g.lat, g.lng);
- }
- dbg(lvl_debug,"transform rect for %d is %d,%d - %d,%d\n", pro, curro->u.c_rect.lu.x, curro->u.c_rect.lu.y, curro->u.c_rect.rl.x, curro->u.c_rect.rl.y);
- curro->order+=order;
+transform_get_selection(struct transformation *this_, enum projection pro, int order) {
+
+ struct map_selection *ret,*curri,*curro;
+ struct coord_geo g;
+
+ ret=map_selection_dup(this_->map_sel);
+ curri=this_->map_sel;
+ curro=ret;
+ while (curri) {
+ if (this_->pro != pro) {
+ transform_to_geo(this_->pro, &curri->u.c_rect.lu, &g);
+ transform_from_geo(pro, &g, &curro->u.c_rect.lu);
+ dbg(lvl_debug,"%f,%f", g.lat, g.lng);
+ transform_to_geo(this_->pro, &curri->u.c_rect.rl, &g);
+ transform_from_geo(pro, &g, &curro->u.c_rect.rl);
+ dbg(lvl_debug,": - %f,%f", g.lat, g.lng);
+ }
+ dbg(lvl_debug,"transform rect for %d is %d,%d - %d,%d", pro, curro->u.c_rect.lu.x, curro->u.c_rect.lu.y,
+ curro->u.c_rect.rl.x, curro->u.c_rect.rl.y);
+ curro->order+=order;
#if 0
- curro->u.c_rect.lu.x-=500;
- curro->u.c_rect.lu.y+=500;
- curro->u.c_rect.rl.x+=500;
- curro->u.c_rect.rl.y-=500;
+ curro->u.c_rect.lu.x-=500;
+ curro->u.c_rect.lu.y+=500;
+ curro->u.c_rect.rl.x+=500;
+ curro->u.c_rect.rl.y-=500;
#endif
- curro->range=item_range_all;
- curri=curri->next;
- curro=curro->next;
- }
- return ret;
+ curro->range=item_range_all;
+ curri=curri->next;
+ curro=curro->next;
+ }
+ return ret;
}
struct coord *
-transform_center(struct transformation *this_)
-{
- return &this_->map_center;
+transform_center(struct transformation *this_) {
+ return &this_->map_center;
}
struct coord *
-transform_get_center(struct transformation *this_)
-{
- return &this_->map_center;
+transform_get_center(struct transformation *this_) {
+ return &this_->map_center;
}
-void
-transform_set_center(struct transformation *this_, struct coord *c)
-{
- this_->map_center=*c;
+void transform_set_center(struct transformation *this_, struct coord *c) {
+ this_->map_center=*c;
}
-void
-transform_set_yaw(struct transformation *t,int yaw)
-{
- t->yaw=yaw;
- transform_setup_matrix(t);
+void transform_set_yaw(struct transformation *t,int yaw) {
+ t->yaw=yaw;
+ transform_setup_matrix(t);
}
-int
-transform_get_yaw(struct transformation *this_)
-{
- return this_->yaw;
+int transform_get_yaw(struct transformation *this_) {
+ return this_->yaw;
}
-void
-transform_set_pitch(struct transformation *this_,int pitch)
-{
- this_->pitch=pitch;
- transform_setup_matrix(this_);
+void transform_set_pitch(struct transformation *this_,int pitch) {
+ this_->pitch=pitch;
+ transform_setup_matrix(this_);
}
-int
-transform_get_pitch(struct transformation *this_)
-{
- return this_->pitch;
+int transform_get_pitch(struct transformation *this_) {
+ return this_->pitch;
}
-void
-transform_set_roll(struct transformation *this_,int roll)
-{
+void transform_set_roll(struct transformation *this_,int roll) {
#ifdef ENABLE_ROLL
- this_->roll=roll;
- transform_setup_matrix(this_);
+ this_->roll=roll;
+ transform_setup_matrix(this_);
#else
- dbg(lvl_error,"not supported\n");
+ dbg(lvl_error,"not supported");
#endif
}
-int
-transform_get_roll(struct transformation *this_)
-{
+int transform_get_roll(struct transformation *this_) {
#ifdef ENABLE_ROLL
- return this_->roll;
+ return this_->roll;
#else
- return 0;
+ return 0;
#endif
}
-void
-transform_set_distance(struct transformation *this_,int distance)
-{
- transform_set_screen_dist(this_, distance);
- transform_setup_matrix(this_);
-}
-
-int
-transform_get_distance(struct transformation *this_)
-{
- return this_->screen_dist;
-}
-
-void
-transform_set_scales(struct transformation *this_, int xscale, int yscale, int wscale)
-{
- this_->xscale3d=xscale;
- this_->yscale3d=yscale;
- this_->wscale3d=wscale;
-}
-
-void
-transform_set_screen_selection(struct transformation *t, struct map_selection *sel)
-{
- map_selection_destroy(t->screen_sel);
- t->screen_sel=map_selection_dup(sel);
- if (sel) {
- t->screen_center.x=(sel->u.p_rect.rl.x-sel->u.p_rect.lu.x)/2;
- t->screen_center.y=(sel->u.p_rect.rl.y-sel->u.p_rect.lu.y)/2;
- transform_setup_matrix(t);
- }
-}
-
-void
-transform_set_screen_center(struct transformation *t, struct point *p)
-{
- t->screen_center=*p;
-}
-
-void
-transform_get_size(struct transformation *t, int *width, int *height)
-{
- struct point_rect *r;
- if (t->screen_sel) {
- r=&t->screen_sel->u.p_rect;
- *width=r->rl.x-r->lu.x;
- *height=r->rl.y-r->lu.y;
- }
-}
-
-void
-transform_setup_source_rect(struct transformation *t)
-{
- int i;
- struct coord screen[4];
- struct point screen_pnt[4];
- struct point_rect *pr;
- struct map_selection *ms,*msm,*next,**msm_last;
- ms=t->map_sel;
- while (ms) {
- next=ms->next;
- g_free(ms);
- ms=next;
- }
- t->map_sel=NULL;
- msm_last=&t->map_sel;
- ms=t->screen_sel;
- while (ms) {
- msm=g_new0(struct map_selection, 1);
- *msm=*ms;
- pr=&ms->u.p_rect;
- screen_pnt[0].x=pr->lu.x; /* left upper */
- screen_pnt[0].y=pr->lu.y;
- screen_pnt[1].x=pr->rl.x; /* right upper */
- screen_pnt[1].y=pr->lu.y;
- screen_pnt[2].x=pr->rl.x; /* right lower */
- screen_pnt[2].y=pr->rl.y;
- screen_pnt[3].x=pr->lu.x; /* left lower */
- screen_pnt[3].y=pr->rl.y;
- if (t->ddd) {
- struct coord_geo_cart tmp,cg[8];
- struct coord c;
- int valid=0;
- unsigned char edgenodes[]={
- 0,1,
- 1,2,
- 2,3,
- 3,0,
- 4,5,
- 5,6,
- 6,7,
- 7,4,
- 0,4,
- 1,5,
- 2,6,
- 3,7};
- for (i = 0 ; i < 8 ; i++) {
- transform_screen_to_3d(t, &screen_pnt[i%4], (i >= 4 ? t->zfar:t->znear), &tmp);
- transform_apply_inverse_matrix(t, &tmp, &cg[i]);
- }
- msm->u.c_rect.lu.x=0;
- msm->u.c_rect.lu.y=0;
- msm->u.c_rect.rl.x=0;
- msm->u.c_rect.rl.y=0;
- for (i = 0 ; i < 12 ; i++) {
- if (transform_zplane_intersection(&cg[edgenodes[i*2]], &cg[edgenodes[i*2+1]], HOG(*t), &tmp) == 1) {
- c.x=tmp.x*(1 << t->scale_shift)+t->map_center.x;
- c.y=tmp.y*(1 << t->scale_shift)+t->map_center.y;
- dbg(lvl_debug,"intersection with edge %d at 0x%x,0x%x\n",i,c.x,c.y);
- if (valid)
- coord_rect_extend(&msm->u.c_rect, &c);
- else {
- msm->u.c_rect.lu=c;
- msm->u.c_rect.rl=c;
- valid=1;
- }
- dbg(lvl_debug,"rect 0x%x,0x%x - 0x%x,0x%x\n",msm->u.c_rect.lu.x,msm->u.c_rect.lu.y,msm->u.c_rect.rl.x,msm->u.c_rect.rl.y);
- }
- }
- } else {
- for (i = 0 ; i < 4 ; i++) {
- transform_reverse(t, &screen_pnt[i], &screen[i]);
- dbg(lvl_debug,"map(%d) %d,%d=0x%x,0x%x\n", i,screen_pnt[i].x, screen_pnt[i].y, screen[i].x, screen[i].y);
- }
- msm->u.c_rect.lu.x=min4(screen[0].x,screen[1].x,screen[2].x,screen[3].x);
- msm->u.c_rect.rl.x=max4(screen[0].x,screen[1].x,screen[2].x,screen[3].x);
- msm->u.c_rect.rl.y=min4(screen[0].y,screen[1].y,screen[2].y,screen[3].y);
- msm->u.c_rect.lu.y=max4(screen[0].y,screen[1].y,screen[2].y,screen[3].y);
- }
- dbg(lvl_debug,"%dx%d\n", msm->u.c_rect.rl.x-msm->u.c_rect.lu.x,
- msm->u.c_rect.lu.y-msm->u.c_rect.rl.y);
- *msm_last=msm;
- msm_last=&msm->next;
- ms=ms->next;
- }
-}
-
-long
-transform_get_scale(struct transformation *t)
-{
- return (int)(t->scale*16);
-}
-
-void
-transform_set_scale(struct transformation *t, long scale)
-{
- t->scale=scale/16.0;
- transform_setup_matrix(t);
-}
-
-
-int
-transform_get_order(struct transformation *t)
-{
- dbg(lvl_debug,"order %d\n", t->order);
- return t->order;
+void transform_set_distance(struct transformation *this_,int distance) {
+ transform_set_screen_dist(this_, distance);
+ transform_setup_matrix(this_);
+}
+
+int transform_get_distance(struct transformation *this_) {
+ return this_->screen_dist;
+}
+
+void transform_set_scales(struct transformation *this_, int xscale, int yscale, int wscale) {
+ this_->xscale3d=xscale;
+ this_->yscale3d=yscale;
+ this_->wscale3d=wscale;
+}
+
+void transform_set_screen_selection(struct transformation *t, struct map_selection *sel) {
+ map_selection_destroy(t->screen_sel);
+ t->screen_sel=map_selection_dup(sel);
+ if (sel) {
+ t->screen_center.x=(sel->u.p_rect.rl.x-sel->u.p_rect.lu.x)/2;
+ t->screen_center.y=(sel->u.p_rect.rl.y-sel->u.p_rect.lu.y)/2;
+ transform_setup_matrix(t);
+ }
+}
+
+void transform_set_screen_center(struct transformation *t, struct point *p) {
+ t->screen_center=*p;
+}
+
+void transform_get_size(struct transformation *t, int *width, int *height) {
+ struct point_rect *r;
+ if (t->screen_sel) {
+ r=&t->screen_sel->u.p_rect;
+ *width=r->rl.x-r->lu.x;
+ *height=r->rl.y-r->lu.y;
+ }
+}
+
+void transform_setup_source_rect(struct transformation *t) {
+ int i;
+ struct coord screen[4];
+ struct point screen_pnt[4];
+ struct point_rect *pr;
+ struct map_selection *ms,*msm,*next,**msm_last;
+ ms=t->map_sel;
+ while (ms) {
+ next=ms->next;
+ g_free(ms);
+ ms=next;
+ }
+ t->map_sel=NULL;
+ msm_last=&t->map_sel;
+ ms=t->screen_sel;
+ while (ms) {
+ msm=g_new0(struct map_selection, 1);
+ *msm=*ms;
+ pr=&ms->u.p_rect;
+ screen_pnt[0].x=pr->lu.x; /* left upper */
+ screen_pnt[0].y=pr->lu.y;
+ screen_pnt[1].x=pr->rl.x; /* right upper */
+ screen_pnt[1].y=pr->lu.y;
+ screen_pnt[2].x=pr->rl.x; /* right lower */
+ screen_pnt[2].y=pr->rl.y;
+ screen_pnt[3].x=pr->lu.x; /* left lower */
+ screen_pnt[3].y=pr->rl.y;
+ if (t->ddd) {
+ struct coord_geo_cart tmp,cg[8];
+ struct coord c;
+ int valid=0;
+ unsigned char edgenodes[]= {
+ 0,1,
+ 1,2,
+ 2,3,
+ 3,0,
+ 4,5,
+ 5,6,
+ 6,7,
+ 7,4,
+ 0,4,
+ 1,5,
+ 2,6,
+ 3,7
+ };
+ for (i = 0 ; i < 8 ; i++) {
+ transform_screen_to_3d(t, &screen_pnt[i%4], (i >= 4 ? t->zfar:t->znear), &tmp);
+ transform_apply_inverse_matrix(t, &tmp, &cg[i]);
+ }
+ msm->u.c_rect.lu.x=0;
+ msm->u.c_rect.lu.y=0;
+ msm->u.c_rect.rl.x=0;
+ msm->u.c_rect.rl.y=0;
+ for (i = 0 ; i < 12 ; i++) {
+ if (transform_zplane_intersection(&cg[edgenodes[i*2]], &cg[edgenodes[i*2+1]], HOG(*t), &tmp) == 1) {
+ c.x=tmp.x*(1 << t->scale_shift)+t->map_center.x;
+ c.y=tmp.y*(1 << t->scale_shift)+t->map_center.y;
+ dbg(lvl_debug,"intersection with edge %d at 0x%x,0x%x",i,c.x,c.y);
+ if (valid)
+ coord_rect_extend(&msm->u.c_rect, &c);
+ else {
+ msm->u.c_rect.lu=c;
+ msm->u.c_rect.rl=c;
+ valid=1;
+ }
+ dbg(lvl_debug,"rect 0x%x,0x%x - 0x%x,0x%x",msm->u.c_rect.lu.x,msm->u.c_rect.lu.y,msm->u.c_rect.rl.x,msm->u.c_rect.rl.y);
+ }
+ }
+ } else {
+ for (i = 0 ; i < 4 ; i++) {
+ transform_reverse(t, &screen_pnt[i], &screen[i]);
+ dbg(lvl_debug,"map(%d) %d,%d=0x%x,0x%x", i,screen_pnt[i].x, screen_pnt[i].y, screen[i].x, screen[i].y);
+ }
+ msm->u.c_rect.lu.x=min4(screen[0].x,screen[1].x,screen[2].x,screen[3].x);
+ msm->u.c_rect.rl.x=max4(screen[0].x,screen[1].x,screen[2].x,screen[3].x);
+ msm->u.c_rect.rl.y=min4(screen[0].y,screen[1].y,screen[2].y,screen[3].y);
+ msm->u.c_rect.lu.y=max4(screen[0].y,screen[1].y,screen[2].y,screen[3].y);
+ }
+ dbg(lvl_debug,"%dx%d", msm->u.c_rect.rl.x-msm->u.c_rect.lu.x,
+ msm->u.c_rect.lu.y-msm->u.c_rect.rl.y);
+ *msm_last=msm;
+ msm_last=&msm->next;
+ ms=ms->next;
+ }
+}
+
+long transform_get_scale(struct transformation *t) {
+ return (int)(t->scale*16);
+}
+
+void transform_set_scale(struct transformation *t, long scale) {
+ t->scale=scale/16.0;
+ transform_setup_matrix(t);
+}
+
+
+int transform_get_order(struct transformation *t) {
+ dbg(lvl_debug,"order %d", t->order);
+ return t->order;
}
@@ -1027,395 +929,403 @@ transform_get_order(struct transformation *t)
#define GC2RAD(c) ((c) * TWOPI/(1<<24))
#define minf(a,b) ((a) < (b) ? (a) : (b))
-static double
-transform_distance_garmin(struct coord *c1, struct coord *c2)
-{
+static double transform_distance_garmin(struct coord *c1, struct coord *c2) {
#ifdef USE_HALVESINE
- static const int earth_radius = 6371*1000; //m change accordingly
+ static const int earth_radius = 6371*1000; //m change accordingly
// static const int earth_radius = 3960; //miles
-
+
//Point 1 cords
- navit_float lat1 = GC2RAD(c1->y);
- navit_float long1 = GC2RAD(c1->x);
+ navit_float lat1 = GC2RAD(c1->y);
+ navit_float long1 = GC2RAD(c1->x);
//Point 2 cords
- navit_float lat2 = GC2RAD(c2->y);
- navit_float long2 = GC2RAD(c2->x);
+ navit_float lat2 = GC2RAD(c2->y);
+ navit_float long2 = GC2RAD(c2->x);
//Haversine Formula
- navit_float dlong = long2-long1;
- navit_float dlat = lat2-lat1;
-
- navit_float sinlat = navit_sin(dlat/2);
- navit_float sinlong = navit_sin(dlong/2);
-
- navit_float a=(sinlat*sinlat)+navit_cos(lat1)*navit_cos(lat2)*(sinlong*sinlong);
- navit_float c=2*navit_asin(minf(1,navit_sqrt(a)));
+ navit_float dlong = long2-long1;
+ navit_float dlat = lat2-lat1;
+
+ navit_float sinlat = navit_sin(dlat/2);
+ navit_float sinlong = navit_sin(dlong/2);
+
+ navit_float a=(sinlat*sinlat)+navit_cos(lat1)*navit_cos(lat2)*(sinlong*sinlong);
+ navit_float c=2*navit_asin(minf(1,navit_sqrt(a)));
#ifdef AVOID_FLOAT
- return round(earth_radius*c);
+ return round(earth_radius*c);
#else
- return earth_radius*c;
+ return earth_radius*c;
#endif
#else
#define GMETER 2.3887499999999999
- navit_float dx,dy;
- dx=c1->x-c2->x;
- dy=c1->y-c2->y;
- return navit_sqrt(dx*dx+dy*dy)*GMETER;
+ navit_float dx,dy;
+ dx=c1->x-c2->x;
+ dy=c1->y-c2->y;
+ return navit_sqrt(dx*dx+dy*dy)*GMETER;
#undef GMETER
#endif
}
-double
-transform_scale(int y)
-{
- struct coord c;
- struct coord_geo g;
- c.x=0;
- c.y=y;
- transform_to_geo(projection_mg, &c, &g);
- return 1/navit_cos(g.lat/180*M_PI);
+double transform_scale(int y) {
+ struct coord c;
+ struct coord_geo g;
+ c.x=0;
+ c.y=y;
+ transform_to_geo(projection_mg, &c, &g);
+ return 1/navit_cos(g.lat/180*M_PI);
}
#ifdef AVOID_FLOAT
static int
-tab_sqrt[]={14142,13379,12806,12364,12018,11741,11517,11333,11180,11051,10943,10850,10770,10701,10640,10587,10540,10499,10462,10429,10400,10373,10349,10327,10307,10289,10273,10257,10243,10231,10219,10208};
+tab_sqrt[]= {14142,13379,12806,12364,12018,11741,11517,11333,11180,11051,10943,10850,10770,10701,10640,10587,10540,10499,10462,10429,10400,10373,10349,10327,10307,10289,10273,10257,10243,10231,10219,10208};
static int tab_int_step = 0x20000;
-static int tab_int_scale[]={10000,10002,10008,10019,10033,10052,10076,10103,10135,10171,10212,10257,10306,10359,10417,10479,10546,10617,10693,10773,10858,10947,11041,11140,11243,11352,11465,11582,11705,11833,11965,12103,12246,12394,12547,12706,12870,13039,13214,13395,13581,13773,13971,14174,14384,14600,14822,15050,15285,15526,15774,16028,16289,16557,16832,17114,17404,17700,18005,18316,18636,18964,19299,19643,19995,20355,20724,21102,21489,21885,22290,22705,23129,23563,24007,24461,24926,25401,25886,26383,26891};
-
-int transform_int_scale(int y)
-{
- int i,size = sizeof(tab_int_scale)/sizeof(int);
- if (y < 0)
- y=-y;
- i=y/tab_int_step;
- if (i < size-1)
- return tab_int_scale[i]+((tab_int_scale[i+1]-tab_int_scale[i])*(y-i*tab_int_step))/tab_int_step;
- return tab_int_scale[size-1];
+static int tab_int_scale[]= {10000,10002,10008,10019,10033,10052,10076,10103,10135,10171,10212,10257,10306,10359,10417,10479,10546,10617,10693,10773,10858,10947,11041,11140,11243,11352,11465,11582,11705,11833,11965,12103,12246,12394,12547,12706,12870,13039,13214,13395,13581,13773,13971,14174,14384,14600,14822,15050,15285,15526,15774,16028,16289,16557,16832,17114,17404,17700,18005,18316,18636,18964,19299,19643,19995,20355,20724,21102,21489,21885,22290,22705,23129,23563,24007,24461,24926,25401,25886,26383,26891};
+
+int transform_int_scale(int y) {
+ int i,size = sizeof(tab_int_scale)/sizeof(int);
+ if (y < 0)
+ y=-y;
+ i=y/tab_int_step;
+ if (i < size-1)
+ return tab_int_scale[i]+((tab_int_scale[i+1]-tab_int_scale[i])*(y-i*tab_int_step))/tab_int_step;
+ return tab_int_scale[size-1];
}
#endif
-double
-transform_distance(enum projection pro, struct coord *c1, struct coord *c2)
-{
- if (pro == projection_mg) {
-#ifndef AVOID_FLOAT
- double dx,dy,scale=transform_scale((c1->y+c2->y)/2);
- dx=c1->x-c2->x;
- dy=c1->y-c2->y;
- return sqrt(dx*dx+dy*dy)/scale;
+/**
+ * @brief Calculates the distance between two points.
+ *
+ * @param pro The projection used for `c1` and `c2`.
+ * @param c1 The first point.
+ * @param c2 The second point.
+ *
+ * @return The distance in meters.
+ */
+double transform_distance(enum projection pro, struct coord *c1, struct coord *c2) {
+ if (pro == projection_mg) {
+#ifndef AVOID_FLOAT
+ double dx,dy,scale=transform_scale((c1->y+c2->y)/2);
+ dx=c1->x-c2->x;
+ dy=c1->y-c2->y;
+ return sqrt(dx*dx+dy*dy)/scale;
#else
- int dx,dy,f,scale=transform_int_scale((c1->y+c2->y)/2);
- dx=c1->x-c2->x;
- dy=c1->y-c2->y;
- if (dx < 0)
- dx=-dx;
- if (dy < 0)
- dy=-dy;
- while (dx > 20000 || dy > 20000) {
- dx/=10;
- dy/=10;
- scale/=10;
- }
- if (! dy)
- return dx*10000/scale;
- if (! dx)
- return dy*10000/scale;
- if (dx > dy) {
- f=dx*8/dy-8;
- if (f >= 32)
- return dx*10000/scale;
- return dx*tab_sqrt[f]/scale;
- } else {
- f=dy*8/dx-8;
- if (f >= 32)
- return dy*10000/scale;
- return dy*tab_sqrt[f]/scale;
- }
+ int dx,dy,f,scale=transform_int_scale((c1->y+c2->y)/2);
+ dx=c1->x-c2->x;
+ dy=c1->y-c2->y;
+ if (dx < 0)
+ dx=-dx;
+ if (dy < 0)
+ dy=-dy;
+ while (dx > 20000 || dy > 20000) {
+ dx/=10;
+ dy/=10;
+ scale/=10;
+ }
+ if (! dy)
+ return dx*10000/scale;
+ if (! dx)
+ return dy*10000/scale;
+ if (dx > dy) {
+ f=dx*8/dy-8;
+ if (f >= 32)
+ return dx*10000/scale;
+ return dx*tab_sqrt[f]/scale;
+ } else {
+ f=dy*8/dx-8;
+ if (f >= 32)
+ return dy*10000/scale;
+ return dy*tab_sqrt[f]/scale;
+ }
#endif
- } else if (pro == projection_garmin) {
- return transform_distance_garmin(c1, c2);
- } else {
- dbg(lvl_error,"Unknown projection: %d\n", pro);
- return 0;
- }
-}
-
-void
-transform_project(enum projection pro, struct coord *c, int distance, int angle, struct coord *res)
-{
- double scale;
- switch (pro) {
- case projection_mg:
- scale=transform_scale(c->y);
- res->x=c->x+distance*sin(angle*M_PI/180)*scale;
- res->y=c->y+distance*cos(angle*M_PI/180)*scale;
- break;
- default:
- dbg(lvl_error,"Unsupported projection: %d\n", pro);
- return;
- }
-
-}
-
-
-double
-transform_polyline_length(enum projection pro, struct coord *c, int count)
-{
- double ret=0;
- int i;
-
- for (i = 0 ; i < count-1 ; i++)
- ret+=transform_distance(pro, &c[i], &c[i+1]);
- return ret;
+ } else if (pro == projection_garmin) {
+ return transform_distance_garmin(c1, c2);
+ } else {
+ dbg(lvl_error,"Unknown projection: %d", pro);
+ return 0;
+ }
}
-static int
-transform_overflow_possible_if_squared(int count, ...) {
- va_list ap;
- int i, value, result = 0;
-
- va_start (ap, count);
- for (i = 0; i < count; i++) {
- value = va_arg (ap, int);
- if (abs(value)>32767) {
- result = 1;
- }
- }
- va_end (ap);
- return result;
-}
-
-int
-transform_distance_sq(struct coord *c1, struct coord *c2)
-{
- int dx=c1->x-c2->x;
- int dy=c1->y-c2->y;
-
- if (transform_overflow_possible_if_squared(2, dx, dy))
- return INT_MAX;
- else
- return dx*dx+dy*dy;
-}
-
-navit_float
-transform_distance_sq_float(struct coord *c1, struct coord *c2)
-{
- int dx=c1->x-c2->x;
- int dy=c1->y-c2->y;
- return (navit_float)dx*dx+dy*dy;
-}
-
-int
-transform_distance_sq_pc(struct pcoord *c1, struct pcoord *c2)
-{
- struct coord p1,p2;
- p1.x = c1->x; p1.y = c1->y;
- p2.x = c2->x; p2.y = c2->y;
- return transform_distance_sq(&p1, &p2);
-}
-
-int
-transform_distance_line_sq(struct coord *l0, struct coord *l1, struct coord *ref, struct coord *lpnt)
-{
- int vx,vy,wx,wy;
- int c1,c2;
- int climit=1000000;
- struct coord l;
-
- vx=l1->x-l0->x;
- vy=l1->y-l0->y;
- wx=ref->x-l0->x;
- wy=ref->y-l0->y;
-
- if (transform_overflow_possible_if_squared(4, vx, vy, wx, wy)) {
- return INT_MAX;
- }
-
- c1=vx*wx+vy*wy;
- if ( c1 <= 0 ) {
- if (lpnt)
- *lpnt=*l0;
- return transform_distance_sq(l0, ref);
- }
- c2=vx*vx+vy*vy;
- if ( c2 <= c1 ) {
- if (lpnt)
- *lpnt=*l1;
- return transform_distance_sq(l1, ref);
- }
- while (c1 > climit || c2 > climit) {
- c1/=256;
- c2/=256;
- }
- l.x=l0->x+vx*c1/c2;
- l.y=l0->y+vy*c1/c2;
- if (lpnt)
- *lpnt=l;
- return transform_distance_sq(&l, ref);
-}
-
-navit_float
-transform_distance_line_sq_float(struct coord *l0, struct coord *l1, struct coord *ref, struct coord *lpnt)
-{
- navit_float vx,vy,wx,wy;
- navit_float c1,c2;
- struct coord l;
-
- vx=l1->x-l0->x;
- vy=l1->y-l0->y;
- wx=ref->x-l0->x;
- wy=ref->y-l0->y;
-
- c1=vx*wx+vy*wy;
- if ( c1 <= 0 ) {
- if (lpnt)
- *lpnt=*l0;
- return transform_distance_sq_float(l0, ref);
- }
- c2=vx*vx+vy*vy;
- if ( c2 <= c1 ) {
- if (lpnt)
- *lpnt=*l1;
- return transform_distance_sq_float(l1, ref);
- }
- l.x=l0->x+vx*c1/c2;
- l.y=l0->y+vy*c1/c2;
- if (lpnt)
- *lpnt=l;
- return transform_distance_sq_float(&l, ref);
-}
-
-int
-transform_distance_polyline_sq(struct coord *c, int count, struct coord *ref, struct coord *lpnt, int *pos)
-{
- int i,dist,distn;
- struct coord lp;
- if (count < 2)
- return INT_MAX;
- if (pos)
- *pos=0;
- dist=transform_distance_line_sq(&c[0], &c[1], ref, lpnt);
- for (i=2 ; i < count ; i++) {
- distn=transform_distance_line_sq(&c[i-1], &c[i], ref, &lp);
- if (distn < dist) {
- dist=distn;
- if (lpnt)
- *lpnt=lp;
- if (pos)
- *pos=i-1;
- }
- }
- return dist;
-}
-
-int
-transform_douglas_peucker(struct coord *in, int count, int dist_sq, struct coord *out)
-{
- int ret=0;
- int i,d,dmax=0, idx=0;
- for (i = 1; i < count-2 ; i++) {
- d=transform_distance_line_sq(&in[0], &in[count-1], &in[i], NULL);
- if (d > dmax) {
- idx=i;
- dmax=d;
- }
- }
- if (dmax > dist_sq) {
- ret=transform_douglas_peucker(in, idx, dist_sq, out)-1;
- ret+=transform_douglas_peucker(in+idx, count-idx, dist_sq, out+ret);
- } else {
- if (count > 0)
- out[ret++]=in[0];
- if (count > 1)
- out[ret++]=in[count-1];
- }
- return ret;
-}
-
-int
-transform_douglas_peucker_float(struct coord *in, int count, navit_float dist_sq, struct coord *out)
-{
- int ret=0;
- int i,idx=0;
- navit_float d,dmax=0;
- for (i = 1; i < count-2 ; i++) {
- d=transform_distance_line_sq_float(&in[0], &in[count-1], &in[i], NULL);
- if (d > dmax) {
- idx=i;
- dmax=d;
- }
- }
- if (dmax > dist_sq) {
- ret=transform_douglas_peucker_float(in, idx, dist_sq, out)-1;
- ret+=transform_douglas_peucker_float(in+idx, count-idx, dist_sq, out+ret);
- } else {
- if (count > 0)
- out[ret++]=in[0];
- if (count > 1)
- out[ret++]=in[count-1];
- }
- return ret;
-}
-
-
-void
-transform_print_deg(double deg)
-{
- printf("%2.0f:%2.0f:%2.4f", floor(deg), fmod(deg*60,60), fmod(deg*3600,60));
+void transform_project(enum projection pro, struct coord *c, int distance, int angle, struct coord *res) {
+ double scale;
+ switch (pro) {
+ case projection_mg:
+ scale=transform_scale(c->y);
+ res->x=c->x+distance*sin(angle*M_PI/180)*scale;
+ res->y=c->y+distance*cos(angle*M_PI/180)*scale;
+ break;
+ default:
+ dbg(lvl_error,"Unsupported projection: %d", pro);
+ return;
+ }
+
}
-#ifdef AVOID_FLOAT
-static int tab_atan[]={0,262,524,787,1051,1317,1584,1853,2126,2401,2679,2962,3249,3541,3839,4142,4452,4770,5095,5430,5774,6128,6494,6873,7265,7673,8098,8541,9004,9490,10000,10538};
-static int
-atan2_int_lookup(int val)
-{
- int len=sizeof(tab_atan)/sizeof(int);
- int i=len/2;
- int p=i-1;
- for (;;) {
- i>>=1;
- if (val < tab_atan[p])
- p-=i;
- else
- if (val < tab_atan[p+1])
- return p+(p>>1);
- else
- p+=i;
- }
+double transform_polyline_length(enum projection pro, struct coord *c, int count) {
+ double ret=0;
+ int i;
+
+ for (i = 0 ; i < count-1 ; i++)
+ ret+=transform_distance(pro, &c[i], &c[i+1]);
+ return ret;
}
-static int
-atan2_int(int dx, int dy)
-{
- int mul=1,add=0,ret;
- if (! dx) {
- return dy < 0 ? 180 : 0;
- }
- if (! dy) {
- return dx < 0 ? -90 : 90;
- }
- if (dx < 0) {
- dx=-dx;
- mul=-1;
- }
- if (dy < 0) {
- dy=-dy;
- add=180*mul;
- mul*=-1;
- }
- while (dx > 20000 || dy > 20000) {
- dx/=10;
- dy/=10;
- }
- if (dx > dy) {
- ret=90-atan2_int_lookup(dy*10000/dx);
- } else {
- ret=atan2_int_lookup(dx*10000/dy);
- }
- return ret*mul+add;
+static int transform_overflow_possible_if_squared(int count, ...) {
+ va_list ap;
+ int i, value, result = 0;
+
+ va_start (ap, count);
+ for (i = 0; i < count; i++) {
+ value = va_arg (ap, int);
+ if (abs(value)>32767) {
+ result = 1;
+ }
+ }
+ va_end (ap);
+ return result;
+}
+
+/**
+ * @brief Determines the squared Mercator distance between two points.
+ *
+ * @param c0 The first coordinate
+ * @param c1 The second coordinate
+ *
+ * @return The squared distance between `c1` and `c2`, or `INT_MAX` if an overflow occurs.
+ */
+int transform_distance_sq(struct coord *c1, struct coord *c2) {
+ int dx=c1->x-c2->x;
+ int dy=c1->y-c2->y;
+
+ if (transform_overflow_possible_if_squared(2, dx, dy))
+ return INT_MAX;
+ else
+ return dx*dx+dy*dy;
+}
+
+navit_float transform_distance_sq_float(struct coord *c1, struct coord *c2) {
+ int dx=c1->x-c2->x;
+ int dy=c1->y-c2->y;
+ return (navit_float)dx*dx+dy*dy;
+}
+
+int transform_distance_sq_pc(struct pcoord *c1, struct pcoord *c2) {
+ struct coord p1,p2;
+ p1.x = c1->x;
+ p1.y = c1->y;
+ p2.x = c2->x;
+ p2.y = c2->y;
+ return transform_distance_sq(&p1, &p2);
+}
+
+/**
+ * @brief Determines the point on a line segment that is closest to a reference point, and its distance
+ * from the reference point.
+ *
+ * @param l0 The first coordinate of the line segment
+ * @param l1 The second coordinate of the line segment
+ * @param ref The reference point
+ * @param lpnt Receives the coordinates of the point on the line segment that is closest to `ref`, can be `NULL`
+ *
+ * @return The square of the Mercator distance between `ref` and `lpnt`, or `INT_MAX` if an overflow occurred
+ */
+int transform_distance_line_sq(struct coord *l0, struct coord *l1, struct coord *ref, struct coord *lpnt) {
+ int vx,vy,wx,wy;
+ int c1,c2;
+ int climit=1000000;
+ struct coord l;
+
+ vx=l1->x-l0->x;
+ vy=l1->y-l0->y;
+ wx=ref->x-l0->x;
+ wy=ref->y-l0->y;
+
+ if (transform_overflow_possible_if_squared(4, vx, vy, wx, wy)) {
+ return INT_MAX;
+ }
+
+ c1=vx*wx+vy*wy;
+ if ( c1 <= 0 ) {
+ if (lpnt)
+ *lpnt=*l0;
+ return transform_distance_sq(l0, ref);
+ }
+ c2=vx*vx+vy*vy;
+ if ( c2 <= c1 ) {
+ if (lpnt)
+ *lpnt=*l1;
+ return transform_distance_sq(l1, ref);
+ }
+ while (c1 > climit || c2 > climit) {
+ c1/=256;
+ c2/=256;
+ }
+ l.x=l0->x+vx*c1/c2;
+ l.y=l0->y+vy*c1/c2;
+ if (lpnt)
+ *lpnt=l;
+ return transform_distance_sq(&l, ref);
+}
+
+navit_float transform_distance_line_sq_float(struct coord *l0, struct coord *l1, struct coord *ref,
+ struct coord *lpnt) {
+ navit_float vx,vy,wx,wy;
+ navit_float c1,c2;
+ struct coord l;
+
+ vx=l1->x-l0->x;
+ vy=l1->y-l0->y;
+ wx=ref->x-l0->x;
+ wy=ref->y-l0->y;
+
+ c1=vx*wx+vy*wy;
+ if ( c1 <= 0 ) {
+ if (lpnt)
+ *lpnt=*l0;
+ return transform_distance_sq_float(l0, ref);
+ }
+ c2=vx*vx+vy*vy;
+ if ( c2 <= c1 ) {
+ if (lpnt)
+ *lpnt=*l1;
+ return transform_distance_sq_float(l1, ref);
+ }
+ l.x=l0->x+vx*c1/c2;
+ l.y=l0->y+vy*c1/c2;
+ if (lpnt)
+ *lpnt=l;
+ return transform_distance_sq_float(&l, ref);
+}
+
+/**
+ * @brief Determines the point on a polyline that is closest to a reference point, and its distance
+ * from the reference point.
+ *
+ * @param c An array containing the coordinates of the polyline
+ * @param count Number of elements in `c`
+ * @param ref The reference point
+ * @param lpnt Receives the coordinates of the point on the polyline that is closest to `ref`, can be `NULL`
+ * @param pos Receives the index of the line segment containing `lpnt`, can be NULL
+ *
+ * @return The square of the Mercator distance between `ref` and `lpnt`, or `INT_MAX` if an overflow occurred
+ */
+int transform_distance_polyline_sq(struct coord *c, int count, struct coord *ref, struct coord *lpnt, int *pos) {
+ int i,dist,distn;
+ struct coord lp;
+ if (count < 2)
+ return INT_MAX;
+ if (pos)
+ *pos=0;
+ dist=transform_distance_line_sq(&c[0], &c[1], ref, lpnt);
+ for (i=2 ; i < count ; i++) {
+ distn=transform_distance_line_sq(&c[i-1], &c[i], ref, &lp);
+ if (distn < dist) {
+ dist=distn;
+ if (lpnt)
+ *lpnt=lp;
+ if (pos)
+ *pos=i-1;
+ }
+ }
+ return dist;
+}
+
+int transform_douglas_peucker(struct coord *in, int count, int dist_sq, struct coord *out) {
+ int ret=0;
+ int i,d,dmax=0, idx=0;
+ for (i = 1; i < count-2 ; i++) {
+ d=transform_distance_line_sq(&in[0], &in[count-1], &in[i], NULL);
+ if (d > dmax) {
+ idx=i;
+ dmax=d;
+ }
+ }
+ if (dmax > dist_sq) {
+ ret=transform_douglas_peucker(in, idx, dist_sq, out)-1;
+ ret+=transform_douglas_peucker(in+idx, count-idx, dist_sq, out+ret);
+ } else {
+ if (count > 0)
+ out[ret++]=in[0];
+ if (count > 1)
+ out[ret++]=in[count-1];
+ }
+ return ret;
+}
+
+int transform_douglas_peucker_float(struct coord *in, int count, navit_float dist_sq, struct coord *out) {
+ int ret=0;
+ int i,idx=0;
+ navit_float d,dmax=0;
+ for (i = 1; i < count-2 ; i++) {
+ d=transform_distance_line_sq_float(&in[0], &in[count-1], &in[i], NULL);
+ if (d > dmax) {
+ idx=i;
+ dmax=d;
+ }
+ }
+ if (dmax > dist_sq) {
+ ret=transform_douglas_peucker_float(in, idx, dist_sq, out)-1;
+ ret+=transform_douglas_peucker_float(in+idx, count-idx, dist_sq, out+ret);
+ } else {
+ if (count > 0)
+ out[ret++]=in[0];
+ if (count > 1)
+ out[ret++]=in[count-1];
+ }
+ return ret;
+}
+
+
+void transform_print_deg(double deg) {
+ printf("%2.0f:%2.0f:%2.4f", floor(deg), fmod(deg*60,60), fmod(deg*3600,60));
+}
+
+#ifdef AVOID_FLOAT
+static int tab_atan[]= {0,262,524,787,1051,1317,1584,1853,2126,2401,2679,2962,3249,3541,3839,4142,4452,4770,5095,5430,5774,6128,6494,6873,7265,7673,8098,8541,9004,9490,10000,10538};
+
+static int atan2_int_lookup(int val) {
+ int len=sizeof(tab_atan)/sizeof(int);
+ int i=len/2;
+ int p=i-1;
+ for (;;) {
+ i>>=1;
+ if (val < tab_atan[p])
+ p-=i;
+ else if (val < tab_atan[p+1])
+ return p+(p>>1);
+ else
+ p+=i;
+ }
+}
+
+static int atan2_int(int dx, int dy) {
+ int mul=1,add=0,ret;
+ if (! dx) {
+ return dy < 0 ? 180 : 0;
+ }
+ if (! dy) {
+ return dx < 0 ? -90 : 90;
+ }
+ if (dx < 0) {
+ dx=-dx;
+ mul=-1;
+ }
+ if (dy < 0) {
+ dy=-dy;
+ add=180*mul;
+ mul*=-1;
+ }
+ while (dx > 20000 || dy > 20000) {
+ dx/=10;
+ dy/=10;
+ }
+ if (dx > dy) {
+ ret=90-atan2_int_lookup(dy*10000/dx);
+ } else {
+ ret=atan2_int_lookup(dx*10000/dy);
+ }
+ return ret*mul+add;
}
#endif
@@ -1428,157 +1338,139 @@ atan2_int(int dx, int dy)
*
* @return The bearing in degrees, {@code 0 <= result < 360}.
*/
-int
-transform_get_angle_delta(struct coord *c1, struct coord *c2, int dir)
-{
- int dx=c2->x-c1->x;
- int dy=c2->y-c1->y;
-#ifndef AVOID_FLOAT
- double angle;
- angle=atan2(dx,dy);
- angle*=180/M_PI;
+int transform_get_angle_delta(struct coord *c1, struct coord *c2, int dir) {
+ int dx=c2->x-c1->x;
+ int dy=c2->y-c1->y;
+#ifndef AVOID_FLOAT
+ double angle;
+ angle=atan2(dx,dy);
+ angle*=180/M_PI;
#else
- int angle;
- angle=atan2_int(dx,dy);
+ int angle;
+ angle=atan2_int(dx,dy);
#endif
- if (dir == -1)
- angle=angle-180;
- if (angle < 0)
- angle+=360;
- return angle;
-}
-
-int
-transform_within_border(struct transformation *this_, struct point *p, int border)
-{
- struct map_selection *ms=this_->screen_sel;
- while (ms) {
- struct point_rect *r=&ms->u.p_rect;
- if (p->x >= r->lu.x+border && p->x <= r->rl.x-border &&
- p->y >= r->lu.y+border && p->y <= r->rl.y-border)
- return 1;
- ms=ms->next;
- }
- return 0;
-}
-
-int
-transform_within_dist_point(struct coord *ref, struct coord *c, int dist)
-{
- if (c->x-dist > ref->x)
- return 0;
- if (c->x+dist < ref->x)
- return 0;
- if (c->y-dist > ref->y)
- return 0;
- if (c->y+dist < ref->y)
- return 0;
- if ((c->x-ref->x)*(c->x-ref->x) + (c->y-ref->y)*(c->y-ref->y) <= dist*dist)
- return 1;
+ if (dir == -1)
+ angle=angle-180;
+ if (angle < 0)
+ angle+=360;
+ return angle;
+}
+
+int transform_within_border(struct transformation *this_, struct point *p, int border) {
+ struct map_selection *ms=this_->screen_sel;
+ while (ms) {
+ struct point_rect *r=&ms->u.p_rect;
+ if (p->x >= r->lu.x+border && p->x <= r->rl.x-border &&
+ p->y >= r->lu.y+border && p->y <= r->rl.y-border)
+ return 1;
+ ms=ms->next;
+ }
+ return 0;
+}
+
+int transform_within_dist_point(struct coord *ref, struct coord *c, int dist) {
+ if (c->x-dist > ref->x)
+ return 0;
+ if (c->x+dist < ref->x)
+ return 0;
+ if (c->y-dist > ref->y)
return 0;
+ if (c->y+dist < ref->y)
+ return 0;
+ if ((c->x-ref->x)*(c->x-ref->x) + (c->y-ref->y)*(c->y-ref->y) <= dist*dist)
+ return 1;
+ return 0;
+}
+
+int transform_within_dist_line(struct coord *ref, struct coord *c0, struct coord *c1, int dist) {
+ int vx,vy,wx,wy;
+ int n1,n2;
+ struct coord lc;
+
+ if (c0->x < c1->x) {
+ if (c0->x-dist > ref->x)
+ return 0;
+ if (c1->x+dist < ref->x)
+ return 0;
+ } else {
+ if (c1->x-dist > ref->x)
+ return 0;
+ if (c0->x+dist < ref->x)
+ return 0;
+ }
+ if (c0->y < c1->y) {
+ if (c0->y-dist > ref->y)
+ return 0;
+ if (c1->y+dist < ref->y)
+ return 0;
+ } else {
+ if (c1->y-dist > ref->y)
+ return 0;
+ if (c0->y+dist < ref->y)
+ return 0;
+ }
+ vx=c1->x-c0->x;
+ vy=c1->y-c0->y;
+ wx=ref->x-c0->x;
+ wy=ref->y-c0->y;
+
+ n1=vx*wx+vy*wy;
+ if ( n1 <= 0 )
+ return transform_within_dist_point(ref, c0, dist);
+ n2=vx*vx+vy*vy;
+ if ( n2 <= n1 )
+ return transform_within_dist_point(ref, c1, dist);
+
+ lc.x=c0->x+vx*n1/n2;
+ lc.y=c0->y+vy*n1/n2;
+ return transform_within_dist_point(ref, &lc, dist);
+}
+
+int transform_within_dist_polyline(struct coord *ref, struct coord *c, int count, int close, int dist) {
+ int i;
+ for (i = 0 ; i < count-1 ; i++) {
+ if (transform_within_dist_line(ref,c+i,c+i+1,dist)) {
+ return 1;
+ }
+ }
+ if (close)
+ return (transform_within_dist_line(ref,c,c+count-1,dist));
+ return 0;
}
-int
-transform_within_dist_line(struct coord *ref, struct coord *c0, struct coord *c1, int dist)
-{
- int vx,vy,wx,wy;
- int n1,n2;
- struct coord lc;
-
- if (c0->x < c1->x) {
- if (c0->x-dist > ref->x)
- return 0;
- if (c1->x+dist < ref->x)
- return 0;
- } else {
- if (c1->x-dist > ref->x)
- return 0;
- if (c0->x+dist < ref->x)
- return 0;
- }
- if (c0->y < c1->y) {
- if (c0->y-dist > ref->y)
- return 0;
- if (c1->y+dist < ref->y)
- return 0;
- } else {
- if (c1->y-dist > ref->y)
- return 0;
- if (c0->y+dist < ref->y)
- return 0;
- }
- vx=c1->x-c0->x;
- vy=c1->y-c0->y;
- wx=ref->x-c0->x;
- wy=ref->y-c0->y;
-
- n1=vx*wx+vy*wy;
- if ( n1 <= 0 )
- return transform_within_dist_point(ref, c0, dist);
- n2=vx*vx+vy*vy;
- if ( n2 <= n1 )
- return transform_within_dist_point(ref, c1, dist);
-
- lc.x=c0->x+vx*n1/n2;
- lc.y=c0->y+vy*n1/n2;
- return transform_within_dist_point(ref, &lc, dist);
-}
-
-int
-transform_within_dist_polyline(struct coord *ref, struct coord *c, int count, int close, int dist)
-{
- int i;
- for (i = 0 ; i < count-1 ; i++) {
- if (transform_within_dist_line(ref,c+i,c+i+1,dist)) {
- return 1;
- }
- }
- if (close)
- return (transform_within_dist_line(ref,c,c+count-1,dist));
- return 0;
-}
-
-int
-transform_within_dist_polygon(struct coord *ref, struct coord *c, int count, int dist)
-{
- int i, j, ci = 0;
- for (i = 0, j = count-1; i < count; j = i++) {
- if ((((c[i].y <= ref->y) && ( ref->y < c[j].y )) ||
- ((c[j].y <= ref->y) && ( ref->y < c[i].y))) &&
- (ref->x < (c[j].x - c[i].x) * (ref->y - c[i].y) / (c[j].y - c[i].y) + c[i].x))
- ci = !ci;
- }
- if (! ci) {
- if (dist)
- return transform_within_dist_polyline(ref, c, count, dist, 1);
- else
- return 0;
- }
- return 1;
-}
-
-int
-transform_within_dist_item(struct coord *ref, enum item_type type, struct coord *c, int count, int dist)
-{
- if (type < type_line)
- return transform_within_dist_point(ref, c, dist);
- if (type < type_area)
- return transform_within_dist_polyline(ref, c, count, 0, dist);
- return transform_within_dist_polygon(ref, c, count, dist);
-}
-
-void
-transform_copy(struct transformation *src, struct transformation *dst)
-{
- memcpy(dst, src, sizeof(*src));
-}
-
-void
-transform_destroy(struct transformation *t)
-{
- map_selection_destroy(t->map_sel);
- map_selection_destroy(t->screen_sel);
- g_free(t);
+int transform_within_dist_polygon(struct coord *ref, struct coord *c, int count, int dist) {
+ int i, j, ci = 0;
+ for (i = 0, j = count-1; i < count; j = i++) {
+ if ((((c[i].y <= ref->y) && ( ref->y < c[j].y )) ||
+ ((c[j].y <= ref->y) && ( ref->y < c[i].y))) &&
+ (ref->x < (c[j].x - c[i].x) * (ref->y - c[i].y) / (c[j].y - c[i].y) + c[i].x))
+ ci = !ci;
+ }
+ if (! ci) {
+ if (dist)
+ return transform_within_dist_polyline(ref, c, count, dist, 1);
+ else
+ return 0;
+ }
+ return 1;
+}
+
+int transform_within_dist_item(struct coord *ref, enum item_type type, struct coord *c, int count, int dist) {
+ if (type < type_line)
+ return transform_within_dist_point(ref, c, dist);
+ if (type < type_area)
+ return transform_within_dist_polyline(ref, c, count, 0, dist);
+ return transform_within_dist_polygon(ref, c, count, dist);
+}
+
+void transform_copy(struct transformation *src, struct transformation *dst) {
+ memcpy(dst, src, sizeof(*src));
+}
+
+void transform_destroy(struct transformation *t) {
+ map_selection_destroy(t->map_sel);
+ map_selection_destroy(t->screen_sel);
+ g_free(t);
}
@@ -1595,7 +1487,7 @@ For the sphere
E = r Lo
N = r ln [ tan (pi/4 + L/2) ]
-where
+where
r = radius of the sphere (meters)
ln() is the natural logarithm
@@ -1610,7 +1502,7 @@ N = a * ln ( tan (pi/4 + L/2) * ( (1 - e * sin (L)) / (1 + e * sin (L))) ** (e/2
-
pi L 1 - e sin(L) 2
= a ln( tan( ---- + ---) (--------------) )
- 4 2 1 + e sin(L)
+ 4 2 1 + e sin(L)
where
diff --git a/navit/util.c b/navit/util.c
index 2cceae460..944dc2a21 100644
--- a/navit/util.c
+++ b/navit/util.c
@@ -38,91 +38,343 @@ typedef int ssize_t ;
#include "debug.h"
#include "config.h"
-void
-strtoupper(char *dest, const char *src)
-{
- while (*src)
- *dest++=toupper(*src++);
- *dest='\0';
+void strtoupper(char *dest, const char *src) {
+ while (*src)
+ *dest++=toupper(*src++);
+ *dest='\0';
}
-void
-strtolower(char *dest, const char *src)
-{
- while (*src)
- *dest++=tolower(*src++);
- *dest='\0';
+void strtolower(char *dest, const char *src) {
+ while (*src)
+ *dest++=tolower(*src++);
+ *dest='\0';
}
-int
-navit_utf8_strcasecmp(const char *s1, const char *s2)
-{
- char *s1_folded,*s2_folded;
- int cmpres;
- s1_folded=g_utf8_casefold(s1,-1);
- s2_folded=g_utf8_casefold(s2,-1);
- cmpres=strcmp(s1_folded,s2_folded);
- dbg(lvl_debug,"Compared %s with %s, got %d\n",s1_folded,s2_folded,cmpres);
- g_free(s1_folded);
- g_free(s2_folded);
- return cmpres;
+/**
+ * @brief Fast compute of square root for unsigned ints
+ *
+ * @param n The input number
+ * @return sqrt(n)
+ */
+unsigned int uint_sqrt(unsigned int n) {
+ unsigned int h, p= 0, q= 1, r= n;
+
+ /* avoid q rollover */
+ if(n >= (1<<(sizeof(n)*8-2))) {
+ q = 1<<(sizeof(n)*8-2);
+ } else {
+ while ( q <= n ) {
+ q <<= 2;
+ }
+ q >>= 2;
+ }
+
+ while ( q != 0 ) {
+ h = p + q;
+ p >>= 1;
+ if ( r >= h ) {
+ p += q;
+ r -= h;
+ }
+ q >>= 2;
+ }
+ return p;
+}
+
+int navit_utf8_strcasecmp(const char *s1, const char *s2) {
+ char *s1_folded,*s2_folded;
+ int cmpres;
+ s1_folded=g_utf8_casefold(s1,-1);
+ s2_folded=g_utf8_casefold(s2,-1);
+ cmpres=strcmp(s1_folded,s2_folded);
+ dbg(lvl_debug,"Compared %s with %s, got %d",s1_folded,s2_folded,cmpres);
+ g_free(s1_folded);
+ g_free(s2_folded);
+ return cmpres;
+}
+
+/**
+ * @brief Trims all leading and trailing whitespace characters from a string.
+ *
+ * Whitespace characters are all up to and including 0x20.
+ *
+ * This function operates in-place, i.e. `s` will be modified.
+ *
+ * @param s The string to trim
+ */
+static void strtrim(char *s) {
+ char *tmp = g_strdup(s);
+ char *in = tmp;
+ while (strlen(in) && (in[0] <= 0x20))
+ in++;
+ while (strlen(in) && (in[strlen(in) - 1] <= 0x20))
+ in[strlen(in) - 1] = 0;
+ strcpy(s, in);
+ g_free(tmp);
+}
+
+/**
+ * @brief Parser states for `parse_for_systematic_comparison()`.
+ */
+enum parse_state {
+ parse_state_whitespace,
+ parse_state_numeric,
+ parse_state_alpha,
+};
+
+/**
+ * @brief Parses a string for systematic comparison.
+ *
+ * This is a helper function for `compare_name_systematic()`.
+ *
+ * The string is broken down into numeric and non-numeric parts. Whitespace characters are discarded
+ * unless they are surrounded by string characters, in which case the whole unit is treated as one
+ * string part. All strings are converted to lowercase and leading zeroes stripped from numbers.
+ *
+ * @param s The string to parse
+ *
+ * @return A buffer containing the parsed string, parts delimited by a null character, the last part
+ * followed by a double null character.
+ */
+static char * parse_for_systematic_comparison(const char *s) {
+ char *ret = g_malloc0(strlen(s) * 2 + 1);
+ const char *in = s;
+ char *out = ret;
+ char *part;
+ enum parse_state state = parse_state_whitespace;
+ int i = 0;
+ char c;
+
+ dbg(lvl_debug, "enter\n");
+
+ while (i < strlen(in)) {
+ c = in[i];
+ if ((c <= 0x20) || (c == ',') || (c == '-') || (c == '.') || (c == '/')) {
+ /* whitespace */
+ if (state == parse_state_numeric) {
+ part = g_malloc0(i + 1);
+ strncpy(part, in, i);
+ sprintf(part, "%d", atoi(part));
+ strcpy(out, part);
+ out += strlen(part) + 1;
+ dbg(lvl_debug, "part='%s'\n", part);
+ g_free(part);
+ in += i;
+ i = 1;
+ state = parse_state_whitespace;
+ } else
+ i++;
+ } else if ((c >= '0') && (c <= '9')) {
+ /* numeric */
+ if (state == parse_state_alpha) {
+ part = g_malloc0(i + 1);
+ strncpy(part, in, i);
+ strtrim(part);
+ strcpy(out, part);
+ out += strlen(part) + 1;
+ dbg(lvl_debug, "part='%s'\n", part);
+ g_free(part);
+ in += i;
+ i = 1;
+ } else
+ i++;
+ state = parse_state_numeric;
+ } else {
+ /* alpha */
+ if (state == parse_state_numeric) {
+ part = g_malloc0(i + 1);
+ strncpy(part, in, i);
+ sprintf(part, "%d", atoi(part));
+ strcpy(out, part);
+ out += strlen(part) + 1;
+ dbg(lvl_debug, "part='%s'\n", part);
+ g_free(part);
+ in += i;
+ i = 1;
+ } else
+ i++;
+ state = parse_state_alpha;
+ }
+ }
+
+ if (strlen(in) > 0) {
+ if (state == parse_state_numeric) {
+ part = g_malloc0(strlen(in) + 1);
+ strcpy(part, in);
+ sprintf(part, "%d", atoi(part));
+ strcpy(out, part);
+ dbg(lvl_debug, "part='%s'\n", part);
+ g_free(part);
+ } else if (state == parse_state_alpha) {
+ part = g_malloc0(strlen(in) + 1);
+ strcpy(part, in);
+ strtrim(part);
+ strcpy(out, part);
+ dbg(lvl_debug, "part='%s'\n", part);
+ g_free(part);
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Compares two name_systematic strings.
+ *
+ * A name_systematic string is typically used for road reference numbers (A 4, I-51, SP526). This
+ * function performs a fuzzy comparison: Each string is broken down into numeric and non-numeric parts.
+ * Then both strings are compared part by part. The following rules apply:
+ *
+ * \li Semicolons denote sequences of strings, and the best match between any pair of strings from `s1` and `s2` is
+ * returned.
+ * \li Whitespace bordering on a number is discarded.
+ * \li Whitespace surrounded by string characters is treated as one string with the surrounding characters.
+ * \li If one string has more parts than the other, the shorter string is padded with null parts.
+ * \li null equals null.
+ * \li null does not equal non-null.
+ * \li Numeric parts are compared as integers, hence `'042'` equals `'42'`.
+ * \li Comparison of string parts is case-insensitive.
+ *
+ * Partial matches are currently determined by determining each part of one string with each part of the other. Each
+ * part of one string that is matched by at least one part of the other increases the score. Order is currently not
+ * taken into account, i.e. `'42A'` and `'A-42A'` are both considered full (not partial) matches for `'A42'`. Future
+ * versions may change this.
+ *
+ * @param s1 The first string
+ * @param s2 The second string
+ *
+ * @return 0 if both strings match, nonzero if they do not. `MAX_MISMATCH` indicates a complete mismatch; values in
+ * between indicate partial matches (lower values correspond to better matches).
+ */
+int compare_name_systematic(const char *s1, const char *s2) {
+ int ret = MAX_MISMATCH;
+ int tmp;
+ int elements = 0, matches = 0;
+ char *l = NULL, *r = NULL, *l0, *r0;
+
+ if (!s1 || !s1[0]) {
+ if (!s2 || !s2[0])
+ return 0;
+ else
+ return MAX_MISMATCH;
+ } else if (!s2 || !s2[0])
+ return MAX_MISMATCH;
+
+ /* break up strings at semicolons and parse each separately, return 0 if any two match */
+ if (strchr(s1, ';')) {
+ l = g_strdup(s1);
+ for (l0 = strtok(l, ";"); l0; l0 = strtok(NULL, ";")) {
+ tmp = compare_name_systematic(l0, s2);
+ if (tmp < ret)
+ ret = tmp;
+ if (!ret)
+ break;
+ }
+ g_free(l);
+ return ret;
+ } else if (strchr(s2, ';')) {
+ r = g_strdup(s2);
+ for (r0 = strtok(r, ";"); r0; r0 = strtok(NULL, ";")) {
+ tmp = compare_name_systematic(s1, r0);
+ if (tmp < ret)
+ ret = tmp;
+ if (!ret)
+ break;
+ }
+ g_free(r);
+ return ret;
+ }
+
+ /* s1 and s2 are single strings (no semicolons) */
+ l0 = parse_for_systematic_comparison(s1);
+ r0 = parse_for_systematic_comparison(s2);
+
+ /* count left-hand elements and all left-hand elements matched by a right-hand element */
+ for (l = l0; l[0]; l += strlen(l) + 1) {
+ elements++;
+ for (r = r0; r[0]; r += strlen(r) + 1) {
+ if (atoi(l) || (l[0] == '0')) {
+ if ((atoi(r) || (r[0] == '0')) && (atoi(l) == atoi(r))) {
+ matches++;
+ break;
+ }
+ } else if (!strcasecmp(l, r)) {
+ matches++;
+ break;
+ }
+ }
+ }
+
+ /* same in the opposite direction */
+ for (r = r0; r[0]; r += strlen(r) + 1) {
+ elements++;
+ for (l = l0; l[0]; l += strlen(l) + 1) {
+ if (atoi(l) || (l[0] == '0')) {
+ if ((atoi(r) || (r[0] == '0')) && (atoi(l) == atoi(r))) {
+ matches++;
+ break;
+ }
+ } else if (!strcasecmp(l, r)) {
+ matches++;
+ break;
+ }
+ }
+ }
+
+ g_free(l0);
+ g_free(r0);
+
+ ret = ((elements - matches) * MAX_MISMATCH) / elements;
+
+ dbg(lvl_debug, "'%s' %s '%s', ret=%d",
+ s1, ret ? (ret == MAX_MISMATCH ? "does NOT match" : "PARTIALLY matches") : "matches", s2, ret);
+
+ return ret;
}
-static void
-hash_callback(gpointer key, gpointer value, gpointer user_data)
-{
- GList **l=user_data;
- *l=g_list_prepend(*l, value);
+static void hash_callback(gpointer key, gpointer value, gpointer user_data) {
+ GList **l=user_data;
+ *l=g_list_prepend(*l, value);
}
-GList *
-g_hash_to_list(GHashTable *h)
-{
- GList *ret=NULL;
- g_hash_table_foreach(h, hash_callback, &ret);
+GList *g_hash_to_list(GHashTable *h) {
+ GList *ret=NULL;
+ g_hash_table_foreach(h, hash_callback, &ret);
- return ret;
+ return ret;
}
-static void
-hash_callback_key(gpointer key, gpointer value, gpointer user_data)
-{
- GList **l=user_data;
- *l=g_list_prepend(*l, key);
+static void hash_callback_key(gpointer key, gpointer value, gpointer user_data) {
+ GList **l=user_data;
+ *l=g_list_prepend(*l, key);
}
-GList *
-g_hash_to_list_keys(GHashTable *h)
-{
- GList *ret=NULL;
- g_hash_table_foreach(h, hash_callback_key, &ret);
+GList *g_hash_to_list_keys(GHashTable *h) {
+ GList *ret=NULL;
+ g_hash_table_foreach(h, hash_callback_key, &ret);
- return ret;
+ return ret;
}
-gchar *
-g_strconcat_printf(gchar *buffer, gchar *fmt, ...)
-{
- gchar *str,*ret;
- va_list ap;
+gchar *g_strconcat_printf(gchar *buffer, gchar *fmt, ...) {
+ gchar *str,*ret;
+ va_list ap;
- va_start(ap, fmt);
- str=g_strdup_vprintf(fmt, ap);
- va_end(ap);
- if (! buffer)
- return str;
- ret=g_strconcat(buffer, str, NULL);
- g_free(buffer);
- g_free(str);
- return ret;
+ va_start(ap, fmt);
+ str=g_strdup_vprintf(fmt, ap);
+ va_end(ap);
+ if (! buffer)
+ return str;
+ ret=g_strconcat(buffer, str, NULL);
+ g_free(buffer);
+ g_free(str);
+ return ret;
}
#ifndef HAVE_GLIB
int g_utf8_strlen_force_link(gchar *buffer, int max);
-int
-g_utf8_strlen_force_link(gchar *buffer, int max)
-{
- return g_utf8_strlen(buffer, max);
+int g_utf8_strlen_force_link(gchar *buffer, int max) {
+ return g_utf8_strlen(buffer, max);
}
#endif
@@ -132,33 +384,30 @@ g_utf8_strlen_force_link(gchar *buffer, int max)
#endif
#if defined(_WIN32) || defined(__CEGCC__) || defined (__APPLE__) || defined(HAVE_API_ANDROID)
-char *stristr(const char *String, const char *Pattern)
-{
- char *pptr, *sptr, *start;
-
- for (start = (char *)String; *start != (int)NULL; start++)
- {
- /* find start of pattern in string */
- for ( ; ((*start!=(int)NULL) && (toupper(*start) != toupper(*Pattern))); start++)
- ;
- if ((int)NULL == *start)
- return NULL;
-
- pptr = (char *)Pattern;
- sptr = (char *)start;
-
- while (toupper(*sptr) == toupper(*pptr))
- {
- sptr++;
- pptr++;
-
- /* if end of pattern then pattern was found */
-
- if ((int)NULL == *pptr)
- return (start);
- }
- }
- return NULL;
+char *stristr(const char *String, const char *Pattern) {
+ char *pptr, *sptr, *start;
+
+ for (start = (char *)String; *start != (int)NULL; start++) {
+ /* find start of pattern in string */
+ for ( ; ((*start!=(int)NULL) && (toupper(*start) != toupper(*Pattern))); start++)
+ ;
+ if ((int)NULL == *start)
+ return NULL;
+
+ pptr = (char *)Pattern;
+ sptr = (char *)start;
+
+ while (toupper(*sptr) == toupper(*pptr)) {
+ sptr++;
+ pptr++;
+
+ /* if end of pattern then pattern was found */
+
+ if ((int)NULL == *pptr)
+ return (start);
+ }
+ }
+ return NULL;
}
#ifndef SIZE_MAX
@@ -185,128 +434,177 @@ char *stristr(const char *String, const char *Pattern)
#ifndef HAVE_GETDELIM
/**
* @brief Reads the part of a file up to a delimiter to a string.
- * <p>
+ * <p>
* Read up to (and including) a DELIMITER from FP into *LINEPTR (and NUL-terminate it).
*
* @param lineptr Pointer to a pointer returned from malloc (or NULL), pointing to a buffer. It is
* realloc'ed as necessary and will receive the data read.
- * @param n Size of the buffer.
+ * @param n Size of the buffer.
*
* @return Number of characters read (not including the null terminator), or -1 on error or EOF.
*/
-ssize_t
-getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
-{
- int result;
- size_t cur_len = 0;
+ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) {
+ int result;
+ size_t cur_len = 0;
- if (lineptr == NULL || n == NULL || fp == NULL)
- {
- return -1;
+ if (lineptr == NULL || n == NULL || fp == NULL) {
+ return -1;
}
- flockfile (fp);
+ flockfile (fp);
- if (*lineptr == NULL || *n == 0)
- {
- *n = 120;
- *lineptr = (char *) realloc (*lineptr, *n);
- if (*lineptr == NULL)
- {
- result = -1;
- goto unlock_return;
- }
+ if (*lineptr == NULL || *n == 0) {
+ *n = 120;
+ *lineptr = (char *) realloc (*lineptr, *n);
+ if (*lineptr == NULL) {
+ result = -1;
+ goto unlock_return;
+ }
}
- for (;;)
- {
- int i;
-
- i = getc (fp);
- if (i == EOF)
- {
- result = -1;
- break;
- }
-
- /* Make enough space for len+1 (for final NUL) bytes. */
- if (cur_len + 1 >= *n)
- {
- size_t needed_max=SIZE_MAX;
- size_t needed = 2 * *n + 1; /* Be generous. */
- char *new_lineptr;
- if (needed_max < needed)
- needed = needed_max;
- if (cur_len + 1 >= needed)
- {
- result = -1;
- goto unlock_return;
- }
-
- new_lineptr = (char *) realloc (*lineptr, needed);
- if (new_lineptr == NULL)
- {
- result = -1;
- goto unlock_return;
- }
-
- *lineptr = new_lineptr;
- *n = needed;
- }
-
- (*lineptr)[cur_len] = i;
- cur_len++;
-
- if (i == delimiter)
- break;
- }
- (*lineptr)[cur_len] = '\0';
- result = cur_len ? cur_len : result;
-
- unlock_return:
- funlockfile (fp); /* doesn't set errno */
-
- return result;
+ for (;;) {
+ int i;
+
+ i = getc (fp);
+ if (i == EOF) {
+ result = -1;
+ break;
+ }
+
+ /* Make enough space for len+1 (for final NUL) bytes. */
+ if (cur_len + 1 >= *n) {
+ size_t needed_max=SIZE_MAX;
+ size_t needed = 2 * *n + 1; /* Be generous. */
+ char *new_lineptr;
+ if (needed_max < needed)
+ needed = needed_max;
+ if (cur_len + 1 >= needed) {
+ result = -1;
+ goto unlock_return;
+ }
+
+ new_lineptr = (char *) realloc (*lineptr, needed);
+ if (new_lineptr == NULL) {
+ result = -1;
+ goto unlock_return;
+ }
+
+ *lineptr = new_lineptr;
+ *n = needed;
+ }
+
+ (*lineptr)[cur_len] = i;
+ cur_len++;
+
+ if (i == delimiter)
+ break;
+ }
+ (*lineptr)[cur_len] = '\0';
+ result = cur_len ? cur_len : result;
+
+unlock_return:
+ funlockfile (fp); /* doesn't set errno */
+
+ return result;
}
#endif
#ifndef HAVE_GETLINE
-ssize_t
-getline (char **lineptr, size_t *n, FILE *stream)
-{
- return getdelim (lineptr, n, '\n', stream);
+ssize_t getline (char **lineptr, size_t *n, FILE *stream) {
+ return getdelim (lineptr, n, '\n', stream);
}
#endif
#if defined(_UNICODE)
-wchar_t* newSysString(const char *toconvert)
-{
- int newstrlen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toconvert, -1, 0, 0);
- wchar_t *newstring = g_new(wchar_t,newstrlen);
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toconvert, -1, newstring, newstrlen) ;
- return newstring;
+wchar_t* newSysString(const char *toconvert) {
+ int newstrlen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toconvert, -1, 0, 0);
+ wchar_t *newstring = g_new(wchar_t,newstrlen);
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, toconvert, -1, newstring, newstrlen) ;
+ return newstring;
}
#else
-char * newSysString(const char *toconvert)
-{
- return g_strdup(toconvert);
+char * newSysString(const char *toconvert) {
+ return g_strdup(toconvert);
}
#endif
#endif
+/**
+ * @brief Optimizes the format of a string, adding carriage returns so that when displayed, the result text zone is roughly as wide as high
+ *
+ * @param[in,out] s The string to proces (will be modified by this function, but length will be unchanged)
+ */
+void square_shape_str(char *s) {
+ char *c;
+ char *last_break;
+ unsigned int max_cols = 0;
+ unsigned int cur_cols = 0;
+ unsigned int max_rows = 0;
+ unsigned int surface;
+ unsigned int target_cols;
+
+ if (!s)
+ return;
+ for (c=s; *c!='\0'; c++) {
+ if (*c==' ') {
+ if (max_cols < cur_cols)
+ max_cols = cur_cols;
+ cur_cols = 0;
+ max_rows++;
+ } else
+ cur_cols++;
+ }
+ if (max_cols < cur_cols)
+ max_cols = cur_cols;
+ if (cur_cols) /* If last line does not end with CR, add it to line numbers anyway */
+ max_rows++;
+ /* Give twice more room for rows (hence the factor 2 below)
+ * This will render as a rectangular shape, taking more horizontal space than vertical */
+ surface = max_rows * 2 * max_cols;
+ target_cols = uint_sqrt(surface);
+
+ if (target_cols < max_cols)
+ target_cols = max_cols;
+
+ target_cols = target_cols + target_cols/10; /* Allow 10% extra on columns */
+ dbg(lvl_debug, "square_shape_str(): analyzing input text=\"%s\". max_rows=%u, max_cols=%u, surface=%u, target_cols=%u",
+ s, max_rows, max_cols, max_rows * 2 * max_cols, target_cols);
+
+ cur_cols = 0;
+ last_break = NULL;
+ for (c=s; *c!='\0'; c++) {
+ if (*c==' ') {
+ if (cur_cols>=target_cols) { /* This line is too long, break at the previous non alnum character */
+ if (last_break) {
+ *last_break =
+ '\n'; /* Replace the previous non alnum character with a line break, this creates a new line and prevents the previous line from being too long */
+ cur_cols = c-last_break;
+ }
+ }
+ last_break = c; /* Record this position as a candidate to insert a line break */
+ }
+ cur_cols++;
+ }
+ if (cur_cols>=target_cols && last_break) {
+ *last_break =
+ '\n'; /* Replace the previous non alnum character with a line break, this creates a new line and prevents the previous line from being too long */
+ }
+
+ dbg(lvl_debug, "square_shape_str(): output text=\"%s\"", s);
+}
+
#if defined(_MSC_VER) || (!defined(HAVE_GETTIMEOFDAY) && defined(HAVE_API_WIN32_BASE))
/**
* Impements a simple incomplete version of gettimeofday. Only usefull for messuring
* time spans, not the real time of day.
*/
-int gettimeofday(struct timeval *time, void *local)
-{
- int milliseconds = GetTickCount();
+int gettimeofday(struct timeval *time, void *local) {
+ int milliseconds = GetTickCount();
- time->tv_sec = milliseconds/1000;
- time->tv_usec = (milliseconds - (time->tv_sec * 1000)) * 1000;
+ time->tv_sec = milliseconds/1000;
+ time->tv_usec = (milliseconds - (time->tv_sec * 1000)) * 1000;
- return 0;
+ return 0;
}
#endif
/**
@@ -316,32 +614,160 @@ int gettimeofday(struct timeval *time, void *local)
*
* @return The number of seconds elapsed since January 1, 1970, 00:00:00 UTC.
*/
-unsigned int
-iso8601_to_secs(char *iso8601)
-{
- int a,b,d,val[6],i=0;
- char *start=iso8601,*pos=iso8601;
- while (*pos && i < 6) {
- if (*pos < '0' || *pos > '9') {
- val[i++]=atoi(start);
- pos++;
- start=pos;
- }
- if(*pos)
- pos++;
- }
-
- a=val[0]/100;
- b=2-a+a/4;
-
- if (val[1] < 2) {
- val[0]--;
- val[1]+=12;
- }
-
- d=1461*(val[0]+4716)/4+306001*(val[1]+1)/10000+val[2]+b-2442112;
-
- return ((d*24+val[3])*60+val[4])*60+val[5];
+unsigned int iso8601_to_secs(char *iso8601) {
+ int a,b,d,val[6],i=0;
+ char *start=iso8601,*pos=iso8601;
+ while (*pos && i < 6) {
+ if (*pos < '0' || *pos > '9') {
+ val[i++]=atoi(start);
+ pos++;
+ start=pos;
+ }
+ if(*pos)
+ pos++;
+ }
+
+ a=val[0]/100;
+ b=2-a+a/4;
+
+ if (val[1] < 2) {
+ val[0]--;
+ val[1]+=12;
+ }
+
+ d=1461*(val[0]+4716)/4+306001*(val[1]+1)/10000+val[2]+b-2442112;
+
+ return ((d*24+val[3])*60+val[4])*60+val[5];
+}
+
+/**
+ * @brief Converts a `tm` structure to `time_t`
+ *
+ * Returns the value of type `time_t` that represents the UTC time described by the `tm` structure
+ * pointed to by `pt` (which may be modified).
+ *
+ * This function performs the reverse translation that `gmtime()` does. As this functionality is absent
+ * in the standard library, it is emulated by calling `mktime()`, converting its output into both GMT
+ * and local time, comparing the results and calling `mktime()` again with an input adjusted for the
+ * offset in the opposite direction. This ensures maximum portability.
+ *
+ * The values of the `tm_wday` and `tm_yday` members of `pt` are ignored, and the values of the other
+ * members are interpreted even if out of their valid ranges (see `struct tm`). For example, `tm_mday`
+ * may contain values above 31, which are interpreted accordingly as the days that follow the last day
+ * of the selected month.
+ *
+ * A call to this function automatically adjusts the values of the members of `pt` if they are off-range
+ * or—in the case of `tm_wday` and `tm_yday`—if their values are inconsistent with the other members.
+ *
+ */
+time_t mkgmtime(struct tm * pt) {
+ time_t ret;
+
+ /* Input, GMT and local time */
+ struct tm * pti, * pgt, * plt;
+
+ pti = g_memdup(pt, sizeof(struct tm));
+
+ ret = mktime(pti);
+
+ pgt = g_memdup(gmtime(&ret), sizeof(struct tm));
+ plt = g_memdup(localtime(&ret), sizeof(struct tm));
+
+ pti->tm_year = pt->tm_year - pgt->tm_year + plt->tm_year;
+ pti->tm_mon = pt->tm_mon - pgt->tm_mon + plt->tm_mon;
+ pti->tm_mday = pt->tm_mday - pgt->tm_mday + plt->tm_mday;
+ pti->tm_hour = pt->tm_hour - pgt->tm_hour + plt->tm_hour;
+ pti->tm_min = pt->tm_min - pgt->tm_min + plt->tm_min;
+ pti->tm_sec = pt->tm_sec - pgt->tm_sec + plt->tm_sec;
+
+ ret = mktime(pti);
+
+ dbg(lvl_debug, "time %ld (%02d-%02d-%02d %02d:%02d:%02d)\n", ret, pti->tm_year, pti->tm_mon, pti->tm_mday,
+ pti->tm_hour, pti->tm_min, pti->tm_sec);
+
+ g_free(pti);
+ g_free(pgt);
+ g_free(plt);
+
+ return ret;
+}
+
+/**
+ * @brief Converts an ISO 8601-style time string into `time_t`.
+ */
+time_t iso8601_to_time(char * iso8601) {
+ /* Date/time fields (YYYY-MM-DD-hh-mm-ss) */
+ int val[8];
+
+ int i = 0;
+
+ /* Start of next integer portion and current position */
+ char *start = iso8601, *pos = iso8601;
+
+ /* Time struct */
+ struct tm tm;
+
+ memset(&tm, 0, sizeof(struct tm));
+
+ while (*pos && i < 6) {
+ if (*pos < '0' || *pos > '9') {
+ val[i++] = atoi(start);
+ if (i == 6)
+ break;
+ pos++;
+ start = pos;
+ }
+ if (*pos)
+ pos++;
+ }
+ val[6] = 0;
+ val[7] = 0;
+ if (*pos && i == 6) {
+ if (pos[1] && pos[2] && (!pos[3] || pos[3] == ':')) {
+ val[6] = atoi(pos);
+ if (pos[3] == ':') {
+ pos += 3;
+ val[7] = (val[6] < 0) ? -atoi(pos) : atoi(pos);
+ }
+ } else if (pos[1] && pos[2] && pos[3] && pos[4]) {
+ val[6] = atoi(pos) / 100;
+ val[7] = atoi(pos) % 100;
+ }
+ }
+
+ tm.tm_year = val[0] - 1900;
+ tm.tm_mon = val[1] - 1;
+ tm.tm_mday = val[2];
+ tm.tm_hour = val[3] - val[6];
+ tm.tm_min = val[4] - val[7];
+ tm.tm_sec = val[5];
+
+ dbg(lvl_debug, "time %s (%02d-%02d-%02d %02d:%02d:%02d)\n", iso8601, tm.tm_year, tm.tm_mon, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+
+ return mkgmtime(&tm);
+}
+
+/**
+ * @brief Converts time to ISO8601 format.
+ *
+ * The caller is responsible for freeing the return value of this function when it is no longer needed.
+ *
+ * @param time The time, as returned by `time()` and related functions
+ *
+ * @return Time in ISO8601 format
+ */
+char * time_to_iso8601(time_t time) {
+ char *timep=NULL;
+ char buffer[32];
+ struct tm *tm;
+
+ tm = gmtime(&time);
+ if (tm) {
+ strftime(buffer, sizeof(buffer), "%Y-%m-%dT%TZ", tm);
+ timep=g_strdup(buffer);
+ }
+ return timep;
}
/**
@@ -349,35 +775,27 @@ iso8601_to_secs(char *iso8601)
*
* @return Time in ISO 8601 format
*/
-char *
-current_to_iso8601(void)
-{
- char *timep=NULL;
+char *current_to_iso8601(void) {
#ifdef HAVE_API_WIN32_BASE
- SYSTEMTIME ST;
- GetSystemTime(&ST);
- timep=g_strdup_printf("%d-%02d-%02dT%02d:%02d:%02dZ",ST.wYear,ST.wMonth,ST.wDay,ST.wHour,ST.wMinute,ST.wSecond);
+ char *timep=NULL;
+ SYSTEMTIME ST;
+ GetSystemTime(&ST);
+ timep=g_strdup_printf("%d-%02d-%02dT%02d:%02d:%02dZ",ST.wYear,ST.wMonth,ST.wDay,ST.wHour,ST.wMinute,ST.wSecond);
+ return timep;
#else
- char buffer[32];
- time_t tnow;
- struct tm *tm;
- tnow = time(0);
- tm = gmtime(&tnow);
- if (tm) {
- strftime(buffer, sizeof(buffer), "%Y-%m-%dT%TZ", tm);
- timep=g_strdup(buffer);
- }
+ time_t tnow;
+ tnow = time(0);
+ return time_to_iso8601(tnow);
#endif
- return timep;
}
struct spawn_process_info {
#ifdef HAVE_API_WIN32_BASE
- PROCESS_INFORMATION pr;
+ PROCESS_INFORMATION pr;
#else
- pid_t pid; // = -1 if non-blocking spawn isn't supported
- int status; // exit status if non-blocking spawn isn't supported
+ pid_t pid; // = -1 if non-blocking spawn isn't supported
+ int status; // exit status if non-blocking spawn isn't supported
#endif
};
@@ -388,95 +806,91 @@ struct spawn_process_info {
* @param in arg string to escape
* @returns escaped string
*/
-char *
-shell_escape(char *arg)
-{
- char *r;
- int arglen=strlen(arg);
- int i,j,rlen;
+char *shell_escape(char *arg) {
+ char *r;
+ int arglen=strlen(arg);
+ int i,j,rlen;
#ifdef HAVE_API_WIN32_BASE
- {
- int bscount=0;
- rlen=arglen+3;
- r=g_new(char,rlen);
- r[0]='"';
- for(i=0,j=1;i<arglen;i++) {
- if(arg[i]=='\\') {
- bscount++;
- if(i==(arglen-1)) {
- // Most special case - last char is
- // backslash. We can't escape it inside
- // quoted string due to Win unescaping
- // rules so quote should be closed
- // before backslashes and these
- // backslashes shouldn't be doubled
- rlen+=bscount;
- r=g_realloc(r,rlen);
- r[j++]='"';
- memset(r+j,'\\',bscount);
- j+=bscount;
- }
- } else {
- //Any preceeding backslashes will be doubled.
- bscount*=2;
- // Double quote needs to be preceeded by
- // at least one backslash
- if(arg[i]=='"')
- bscount++;
- if(bscount>0) {
- rlen+=bscount;
- r=g_realloc(r,rlen);
- memset(r+j,'\\',bscount);
- j+=bscount;
- bscount=0;
- }
- r[j++]=arg[i];
- if(i==(arglen-1)) {
- r[j++]='"';
- }
- }
- }
- r[j++]=0;
- }
+ {
+ int bscount=0;
+ rlen=arglen+3;
+ r=g_new(char,rlen);
+ r[0]='"';
+ for(i=0,j=1; i<arglen; i++) {
+ if(arg[i]=='\\') {
+ bscount++;
+ if(i==(arglen-1)) {
+ // Most special case - last char is
+ // backslash. We can't escape it inside
+ // quoted string due to Win unescaping
+ // rules so quote should be closed
+ // before backslashes and these
+ // backslashes shouldn't be doubled
+ rlen+=bscount;
+ r=g_realloc(r,rlen);
+ r[j++]='"';
+ memset(r+j,'\\',bscount);
+ j+=bscount;
+ }
+ } else {
+ //Any preceeding backslashes will be doubled.
+ bscount*=2;
+ // Double quote needs to be preceeded by
+ // at least one backslash
+ if(arg[i]=='"')
+ bscount++;
+ if(bscount>0) {
+ rlen+=bscount;
+ r=g_realloc(r,rlen);
+ memset(r+j,'\\',bscount);
+ j+=bscount;
+ bscount=0;
+ }
+ r[j++]=arg[i];
+ if(i==(arglen-1)) {
+ r[j++]='"';
+ }
+ }
+ }
+ r[j++]=0;
+ }
#else
- {
- // Will use hard quoting for the whole string
- // and replace each singular quote found with a '\'' sequence.
- rlen=arglen+3;
- r=g_new(char,rlen);
- r[0]='\'';
- for(i=0,j=1;i<arglen;i++) {
- if(arg[i]=='\'') {
- rlen+=3;
- r=g_realloc(r,rlen);
- g_strlcpy(r+j,"'\\''",rlen-j);
- } else {
- r[j++]=arg[i];
- }
- }
- r[j++]='\'';
- r[j++]=0;
- }
+ {
+ // Will use hard quoting for the whole string
+ // and replace each singular quote found with a '\'' sequence.
+ rlen=arglen+3;
+ r=g_new(char,rlen);
+ r[0]='\'';
+ for(i=0,j=1; i<arglen; i++) {
+ if(arg[i]=='\'') {
+ rlen+=3;
+ r=g_realloc(r,rlen);
+ g_strlcpy(r+j,"'\\''",rlen-j);
+ } else {
+ r[j++]=arg[i];
+ }
+ }
+ r[j++]='\'';
+ r[j++]=0;
+ }
#endif
- return r;
+ return r;
}
#ifndef _POSIX_C_SOURCE
-static char*
-spawn_process_compose_cmdline(char **argv)
-{
- int i,j;
- char *cmdline=shell_escape(argv[0]);
- for(i=1,j=strlen(cmdline);argv[i];i++) {
- char *arg=shell_escape(argv[i]);
- int arglen=strlen(arg);
- cmdline[j]=' ';
- cmdline=g_realloc(cmdline,j+1+arglen+1);
- memcpy(cmdline+j+1,arg,arglen+1);
- g_free(arg);
- j=j+1+arglen;
- }
- return cmdline;
+static char* spawn_process_compose_cmdline(char **argv) {
+ int i,j;
+ char *cmdline=shell_escape(argv[0]);
+ for(i=1,j=strlen(cmdline); argv[i]; i++) {
+ char *arg=shell_escape(argv[i]);
+ int arglen=strlen(arg);
+ cmdline[j]=' ';
+ cmdline=g_realloc(cmdline,j+1+arglen+1);
+ memcpy(cmdline+j+1,arg,arglen+1);
+ g_free(arg);
+ j=j+1+arglen;
+ }
+ return cmdline;
}
#endif
@@ -501,82 +915,81 @@ GList *spawn_process_children=NULL;
* @returns 0 - success, >0 - return code, -1 - error
*/
struct spawn_process_info*
-spawn_process(char **argv)
-{
- struct spawn_process_info*r=g_new(struct spawn_process_info,1);
+spawn_process(char **argv) {
+ struct spawn_process_info*r=g_new(struct spawn_process_info,1);
#ifdef _POSIX_C_SOURCE
- {
- pid_t pid;
-
- sigset_t set, old;
- dbg(lvl_debug,"spawning process for '%s'\n", argv[0]);
- sigemptyset(&set);
- sigaddset(&set,SIGCHLD);
- spawn_process_sigmask(SIG_BLOCK,&set,&old);
- pid=fork();
- if(pid==0) {
- execvp(argv[0], argv);
- /*Shouldn't reach here*/
- exit(1);
- } else if(pid>0) {
- r->status=-1;
- r->pid=pid;
- spawn_process_children=g_list_prepend(spawn_process_children,r);
- } else {
- dbg(lvl_error,"fork() returned error.");
- g_free(r);
- r=NULL;
- }
- spawn_process_sigmask(SIG_SETMASK,&old,NULL);
- return r;
- }
+ {
+ pid_t pid;
+
+ sigset_t set, old;
+ dbg(lvl_debug,"spawning process for '%s'", argv[0]);
+ sigemptyset(&set);
+ sigaddset(&set,SIGCHLD);
+ spawn_process_sigmask(SIG_BLOCK,&set,&old);
+ pid=fork();
+ if(pid==0) {
+ execvp(argv[0], argv);
+ /*Shouldn't reach here*/
+ exit(1);
+ } else if(pid>0) {
+ r->status=-1;
+ r->pid=pid;
+ spawn_process_children=g_list_prepend(spawn_process_children,r);
+ } else {
+ dbg(lvl_error,"fork() returned error.");
+ g_free(r);
+ r=NULL;
+ }
+ spawn_process_sigmask(SIG_SETMASK,&old,NULL);
+ return r;
+ }
#else
#ifdef HAVE_API_WIN32_BASE
- {
- char *cmdline;
- DWORD dwRet;
-
- // For [desktop] Windows it's adviceable not to use
- // first CreateProcess parameter because PATH is not used
- // if it is defined.
- //
- // On WinCE 6.0 I was unable to launch anything
- // without first CreateProcess parameter, also it seems that
- // no WinCE program has support for quoted strings in arguments.
- // So...
+ {
+ char *cmdline;
+ DWORD dwRet;
+
+ // For [desktop] Windows it's adviceable not to use
+ // first CreateProcess parameter because PATH is not used
+ // if it is defined.
+ //
+ // On WinCE 6.0 I was unable to launch anything
+ // without first CreateProcess parameter, also it seems that
+ // no WinCE program has support for quoted strings in arguments.
+ // So...
#ifdef HAVE_API_WIN32_CE
- LPWSTR cmd,args;
- cmdline=g_strjoinv(" ",argv+1);
- args=newSysString(cmdline);
- cmd = newSysString(argv[0]);
- dwRet=CreateProcess(cmd, args, NULL, NULL, 0, 0, NULL, NULL, NULL, &(r->pr));
- dbg(lvl_debug, "CreateProcess(%s,%s), PID=%i\n",argv[0],cmdline,r->pr.dwProcessId);
- g_free(cmd);
+ LPWSTR cmd,args;
+ cmdline=g_strjoinv(" ",argv+1);
+ args=newSysString(cmdline);
+ cmd = newSysString(argv[0]);
+ dwRet=CreateProcess(cmd, args, NULL, NULL, 0, 0, NULL, NULL, NULL, &(r->pr));
+ dbg(lvl_debug, "CreateProcess(%s,%s), PID=%i",argv[0],cmdline,r->pr.dwProcessId);
+ g_free(cmd);
#else
- TCHAR* args;
- STARTUPINFO startupInfo;
- memset(&startupInfo, 0, sizeof(startupInfo));
- startupInfo.cb = sizeof(startupInfo);
- cmdline=spawn_process_compose_cmdline(argv);
- args=newSysString(cmdline);
- dwRet=CreateProcess(NULL, args, NULL, NULL, 0, 0, NULL, NULL, &startupInfo, &(r->pr));
- dbg(lvl_debug, "CreateProcess(%s), PID=%i\n",cmdline,r->pr.dwProcessId);
+ TCHAR* args;
+ STARTUPINFO startupInfo;
+ memset(&startupInfo, 0, sizeof(startupInfo));
+ startupInfo.cb = sizeof(startupInfo);
+ cmdline=spawn_process_compose_cmdline(argv);
+ args=newSysString(cmdline);
+ dwRet=CreateProcess(NULL, args, NULL, NULL, 0, 0, NULL, NULL, &startupInfo, &(r->pr));
+ dbg(lvl_debug, "CreateProcess(%s), PID=%i",cmdline,r->pr.dwProcessId);
#endif
- g_free(cmdline);
- g_free(args);
- return r;
- }
+ g_free(cmdline);
+ g_free(args);
+ return r;
+ }
#else
- {
- char *cmdline=spawn_process_compose_cmdline(argv);
- int status;
- dbg(lvl_error,"Unblocked spawn_process isn't availiable on this platform.\n");
- status=system(cmdline);
- g_free(cmdline);
- r->status=status;
- r->pid=0;
- return r;
- }
+ {
+ char *cmdline=spawn_process_compose_cmdline(argv);
+ int status;
+ dbg(lvl_error,"Unblocked spawn_process isn't availiable on this platform.");
+ status=system(cmdline);
+ g_free(cmdline);
+ r->status=status;
+ r->pid=0;
+ return r;
+ }
#endif
#endif
}
@@ -586,154 +999,164 @@ spawn_process(char **argv)
*
* @param in *pi pointer to spawn_process_info structure
* @param in block =0 do not block =1 block until child terminated
- * @returns -1 - still running, >=0 program exited,
+ * @returns -1 - still running, >=0 program exited,
* =255 trminated abnormally or wasn't run at all.
- *
+ *
*/
-int spawn_process_check_status(struct spawn_process_info *pi, int block)
-{
- if(pi==NULL) {
- dbg(lvl_error,"Trying to get process status of NULL, assuming process is terminated.\n");
- return 255;
- }
+int spawn_process_check_status(struct spawn_process_info *pi, int block) {
+ if(pi==NULL) {
+ dbg(lvl_error,"Trying to get process status of NULL, assuming process is terminated.");
+ return 255;
+ }
#ifdef HAVE_API_WIN32_BASE
- {int failcount=0;
- while(1){
- DWORD dw;
- if(GetExitCodeProcess(pi->pr.hProcess,&dw)) {
- if(dw!=STILL_ACTIVE) {
- return dw;
- break;
- }
- } else {
- dbg(lvl_error,"GetExitCodeProcess failed. Assuming the process is terminated.");
- return 255;
- }
- if(!block)
- return -1;
-
- dw=WaitForSingleObject(pi->pr.hProcess,INFINITE);
- if(dw==WAIT_FAILED && failcount++==1) {
- dbg(lvl_error,"WaitForSingleObject failed twice. Assuming the process is terminated.");
- return 0;
- break;
- }
- }
- }
+ {
+ int failcount=0;
+ while(1) {
+ DWORD dw;
+ if(GetExitCodeProcess(pi->pr.hProcess,&dw)) {
+ if(dw!=STILL_ACTIVE) {
+ return dw;
+ break;
+ }
+ } else {
+ dbg(lvl_error,"GetExitCodeProcess failed. Assuming the process is terminated.");
+ return 255;
+ }
+ if(!block)
+ return -1;
+
+ dw=WaitForSingleObject(pi->pr.hProcess,INFINITE);
+ if(dw==WAIT_FAILED && failcount++==1) {
+ dbg(lvl_error,"WaitForSingleObject failed twice. Assuming the process is terminated.");
+ return 0;
+ break;
+ }
+ }
+ }
#else
#ifdef _POSIX_C_SOURCE
- if(pi->status!=-1) {
- return pi->status;
- }
- while(1) {
- int status;
- pid_t w=waitpid(pi->pid,&status,block?0:WNOHANG);
- if(w>0) {
- if(WIFEXITED(status))
- pi->status=WEXITSTATUS(status);
- return pi->status;
- if(WIFSTOPPED(status)) {
- dbg(lvl_debug,"child is stopped by %i signal\n",WSTOPSIG(status));
- } else if (WIFSIGNALED(status)) {
- dbg(lvl_debug,"child terminated by signal %i\n",WEXITSTATUS(status));
- pi->status=255;
- return 255;
- }
- if(!block)
- return -1;
- } else if(w==0) {
- if(!block)
- return -1;
- } else {
- if(pi->status!=-1) // Signal handler has changed pi->status while in this function
- return pi->status;
- dbg(lvl_error,"waitpid() indicated error, reporting process termination.\n");
- return 255;
- }
- }
+ if(pi->status!=-1) {
+ return pi->status;
+ }
+ while(1) {
+ int status;
+ pid_t w=waitpid(pi->pid,&status,block?0:WNOHANG);
+ if(w>0) {
+ if(WIFEXITED(status))
+ pi->status=WEXITSTATUS(status);
+ return pi->status;
+ if(WIFSTOPPED(status)) {
+ dbg(lvl_debug,"child is stopped by %i signal",WSTOPSIG(status));
+ } else if (WIFSIGNALED(status)) {
+ dbg(lvl_debug,"child terminated by signal %i",WEXITSTATUS(status));
+ pi->status=255;
+ return 255;
+ }
+ if(!block)
+ return -1;
+ } else if(w==0) {
+ if(!block)
+ return -1;
+ } else {
+ if(pi->status!=-1) // Signal handler has changed pi->status while in this function
+ return pi->status;
+ dbg(lvl_error,"waitpid() indicated error, reporting process termination.");
+ return 255;
+ }
+ }
#else
- dbg(lvl_error, "Non-blocking spawn_process isn't availiable for this platform, repoting process exit status.\n");
- return pi->status;
+ dbg(lvl_error, "Non-blocking spawn_process isn't availiable for this platform, repoting process exit status.");
+ return pi->status;
#endif
#endif
}
-void spawn_process_info_free(struct spawn_process_info *pi)
-{
- if(pi==NULL)
- return;
+void spawn_process_info_free(struct spawn_process_info *pi) {
+ if(pi==NULL)
+ return;
#ifdef HAVE_API_WIN32_BASE
- CloseHandle(pi->pr.hProcess);
- CloseHandle(pi->pr.hThread);
+ CloseHandle(pi->pr.hProcess);
+ CloseHandle(pi->pr.hThread);
#endif
#ifdef _POSIX_C_SOURCE
- {
- sigset_t set, old;
- sigemptyset(&set);
- sigaddset(&set,SIGCHLD);
- spawn_process_sigmask(SIG_BLOCK,&set,&old);
- spawn_process_children=g_list_remove(spawn_process_children,pi);
- spawn_process_sigmask(SIG_SETMASK,&old,NULL);
- }
+ {
+ sigset_t set, old;
+ sigemptyset(&set);
+ sigaddset(&set,SIGCHLD);
+ spawn_process_sigmask(SIG_BLOCK,&set,&old);
+ spawn_process_children=g_list_remove(spawn_process_children,pi);
+ spawn_process_sigmask(SIG_SETMASK,&old,NULL);
+ }
#endif
- g_free(pi);
+ g_free(pi);
}
#ifdef _POSIX_C_SOURCE
-static void spawn_process_sigchld(int sig)
-{
- int status;
- pid_t pid;
- while ((pid=waitpid(-1, &status, WNOHANG)) > 0) {
- GList *el=g_list_first(spawn_process_children);
- while(el) {
- struct spawn_process_info *p=el->data;
- if(p->pid==pid) {
- p->status=status;
- }
- el=g_list_next(el);
- }
- }
+static void spawn_process_sigchld(int sig) {
+ int status;
+ pid_t pid;
+ while ((pid=waitpid(-1, &status, WNOHANG)) > 0) {
+ GList *el=g_list_first(spawn_process_children);
+ while(el) {
+ struct spawn_process_info *p=el->data;
+ if(p->pid==pid) {
+ p->status=status;
+ }
+ el=g_list_next(el);
+ }
+ }
}
#endif
-void spawn_process_init()
-{
+void spawn_process_init() {
#ifdef _POSIX_C_SOURCE
- struct sigaction act;
- act.sa_handler=spawn_process_sigchld;
- act.sa_flags=0;
- sigemptyset(&act.sa_mask);
- sigaction(SIGCHLD, &act, NULL);
+ struct sigaction act;
+ act.sa_handler=spawn_process_sigchld;
+ act.sa_flags=0;
+ sigemptyset(&act.sa_mask);
+ sigaction(SIGCHLD, &act, NULL);
#endif
- return;
-}
-
-/** Get printable compass direction from an angle. */
-void
-get_compass_direction(char *buffer, int angle, int mode)
-{
- angle=angle%360;
- switch (mode) {
- case 0:
- sprintf(buffer,"%d",angle);
- break;
- case 1:
- if (angle < 69 || angle > 291)
- *buffer++='N';
- if (angle > 111 && angle < 249)
- *buffer++='S';
- if (angle > 22 && angle < 158)
- *buffer++='E';
- if (angle > 202 && angle < 338)
- *buffer++='W';
- *buffer++='\0';
- break;
- case 2:
- angle=(angle+15)/30;
- if (! angle)
- angle=12;
- sprintf(buffer,"%d H", angle);
- break;
- }
+ return;
+}
+
+/**
+ * @brief Get printable compass direction from an angle.
+ *
+ * This function supports three different modes:
+ *
+ * In mode 0, the angle in degrees is output as a string.
+ *
+ * In mode 1, the angle is output as a cardinal direction (N, SE etc.).
+ *
+ * In mode 2, the angle is output in analog clock notation (6 o'clock).
+ *
+ * @param buffer Buffer to hold the result string (up to 5 characters, including the terminating null
+ * character, may be required)
+ * @param angle The angle to convert
+ * @param mode The conversion mode, see description
+ */
+void get_compass_direction(char *buffer, int angle, int mode) {
+ angle=angle%360;
+ switch (mode) {
+ case 0:
+ sprintf(buffer,"%d",angle);
+ break;
+ case 1:
+ if (angle < 69 || angle > 291)
+ *buffer++='N';
+ if (angle > 111 && angle < 249)
+ *buffer++='S';
+ if (angle > 22 && angle < 158)
+ *buffer++='E';
+ if (angle > 202 && angle < 338)
+ *buffer++='W';
+ *buffer++='\0';
+ break;
+ case 2:
+ angle=(angle+15)/30;
+ if (! angle)
+ angle=12;
+ sprintf(buffer,"%d H", angle);
+ break;
+ }
}
diff --git a/navit/util.h b/navit/util.h
index b7b60b533..685adc080 100644
--- a/navit/util.h
+++ b/navit/util.h
@@ -21,11 +21,16 @@
#define NAVIT_types_H
#include <ctype.h>
+#include <time.h>
#include "config.h"
+#define MAX_MISMATCH 100
+
void strtoupper(char *dest, const char *src);
void strtolower(char *dest, const char *src);
+unsigned int uint_sqrt(unsigned int n);
int navit_utf8_strcasecmp(const char *s1, const char *s2);
+int compare_name_systematic(const char *s1, const char *s2);
GList * g_hash_to_list(GHashTable *h);
GList * g_hash_to_list_keys(GHashTable *h);
gchar * g_strconcat_printf(gchar *buffer, gchar *fmt, ...);
@@ -36,7 +41,13 @@ wchar_t* newSysString(const char *toconvert);
char * newSysString(const char *toconvert);
#endif
#endif
+
+void square_shape_str(char *s);
+
unsigned int iso8601_to_secs(char *iso8601);
+time_t mkgmtime(struct tm * pt);
+time_t iso8601_to_time(char * iso8601);
+char * time_to_iso8601(time_t time);
char * current_to_iso8601(void);
#if defined(_MSC_VER) || (!defined(HAVE_GETTIMEOFDAY) && defined(HAVE_API_WIN32_BASE))
diff --git a/navit/vehicle.c b/navit/vehicle.c
index 33cecb0e9..5bf16c280 100644
--- a/navit/vehicle.c
+++ b/navit/vehicle.c
@@ -16,10 +16,12 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-
+
/** @file vehicle.c
+ * @defgroup vehicle-plugins vehicle plugins
+ * @ingroup plugins
* @brief Generic components of the vehicle object.
- *
+ *
* This file implements the generic vehicle interface, i.e. everything which is
* not specific to a single data source.
*
@@ -52,27 +54,28 @@
#include "vehicle.h"
#include "navit_nls.h"
+
struct vehicle {
- NAVIT_OBJECT
- struct vehicle_methods meth;
- struct vehicle_priv *priv;
- struct callback_list *cbl;
- struct log *nmea_log, *gpx_log;
- char *gpx_desc;
-
- // cursor
- struct cursor *cursor;
- int cursor_fixed;
- struct callback *animate_callback;
- struct event_timeout *animate_timer;
- struct point cursor_pnt;
- struct graphics *gra;
- struct graphics_gc *bg;
- struct transformation *trans;
- int angle;
- int speed;
- int sequence;
- GHashTable *log_to_cb;
+ NAVIT_OBJECT
+ struct vehicle_methods meth;
+ struct vehicle_priv *priv;
+ struct callback_list *cbl;
+ struct log *nmea_log, *gpx_log;
+ char *gpx_desc;
+
+ // cursor
+ struct cursor *cursor;
+ int cursor_fixed;
+ struct callback *animate_callback;
+ struct event_timeout *animate_timer;
+ struct point cursor_pnt;
+ struct graphics *gra;
+ struct graphics_gc *bg;
+ struct transformation *trans;
+ int angle;
+ int speed;
+ int sequence;
+ GHashTable *log_to_cb;
};
struct object_func vehicle_func;
@@ -97,93 +100,89 @@ static int vehicle_add_log(struct vehicle *this_, struct log *log);
* @return The newly created vehicle object
*/
struct vehicle *
-vehicle_new(struct attr *parent, struct attr **attrs)
-{
- struct vehicle *this_;
- struct attr *source;
- struct vehicle_priv *(*vehicletype_new) (struct vehicle_methods *
- meth,
- struct callback_list *
- cbl,
- struct attr ** attrs);
- char *type, *colon;
- struct pcoord center;
-
- dbg(lvl_debug, "enter\n");
- source = attr_search(attrs, NULL, attr_source);
- if (!source) {
- dbg(lvl_error, "incomplete vehicle definition: missing attribute 'source'\n");
- return NULL;
- }
-
- type = g_strdup(source->u.str);
- colon = strchr(type, ':');
- if (colon)
- *colon = '\0';
- dbg(lvl_debug, "source='%s' type='%s'\n", source->u.str, type);
-
- vehicletype_new = plugin_get_category_vehicle(type);
- if (!vehicletype_new) {
- dbg(lvl_error, "invalid source '%s': unknown type '%s'\n", source->u.str, type);
- g_free(type);
- return NULL;
- }
- g_free(type);
- this_ = g_new0(struct vehicle, 1);
- this_->func=&vehicle_func;
- navit_object_ref((struct navit_object *)this_);
- this_->cbl = callback_list_new();
- this_->priv = vehicletype_new(&this_->meth, this_->cbl, attrs);
- if (!this_->priv) {
- dbg(lvl_error, "vehicletype_new failed\n");
- callback_list_destroy(this_->cbl);
- g_free(this_);
- return NULL;
- }
- this_->attrs=attr_list_dup(attrs);
-
- center.pro=projection_screen;
- center.x=0;
- center.y=0;
- this_->trans=transform_new(&center, 16, 0);
- vehicle_set_default_name(this_);
-
- dbg(lvl_debug, "leave\n");
- this_->log_to_cb=g_hash_table_new(NULL,NULL);
- return this_;
+vehicle_new(struct attr *parent, struct attr **attrs) {
+ struct vehicle *this_;
+ struct attr *source;
+ struct vehicle_priv *(*vehicletype_new) (struct vehicle_methods *
+ meth,
+ struct callback_list *
+ cbl,
+ struct attr ** attrs);
+ char *type, *colon;
+ struct pcoord center;
+
+ dbg(lvl_debug, "enter");
+ source = attr_search(attrs, NULL, attr_source);
+ if (!source) {
+ dbg(lvl_error, "incomplete vehicle definition: missing attribute 'source'");
+ return NULL;
+ }
+
+ type = g_strdup(source->u.str);
+ colon = strchr(type, ':');
+ if (colon)
+ *colon = '\0';
+ dbg(lvl_debug, "source='%s' type='%s'", source->u.str, type);
+
+ vehicletype_new = plugin_get_category_vehicle(type);
+ if (!vehicletype_new) {
+ dbg(lvl_error, "invalid source '%s': unknown type '%s'", source->u.str, type);
+ g_free(type);
+ return NULL;
+ }
+ g_free(type);
+ this_ = g_new0(struct vehicle, 1);
+ this_->func=&vehicle_func;
+ navit_object_ref((struct navit_object *)this_);
+ this_->cbl = callback_list_new();
+ this_->priv = vehicletype_new(&this_->meth, this_->cbl, attrs);
+ if (!this_->priv) {
+ dbg(lvl_error, "vehicletype_new failed");
+ callback_list_destroy(this_->cbl);
+ g_free(this_);
+ return NULL;
+ }
+ this_->attrs=attr_list_dup(attrs);
+
+ center.pro=projection_screen;
+ center.x=0;
+ center.y=0;
+ this_->trans=transform_new(&center, 16, 0);
+ vehicle_set_default_name(this_);
+
+ dbg(lvl_debug, "leave");
+ this_->log_to_cb=g_hash_table_new(NULL,NULL);
+ return this_;
}
/**
* @brief Destroys a vehicle
- *
+ *
* @param this_ The vehicle to destroy
*/
-void
-vehicle_destroy(struct vehicle *this_)
-{
- dbg(lvl_debug,"enter\n");
- if (this_->animate_callback) {
- callback_destroy(this_->animate_callback);
- event_remove_timeout(this_->animate_timer);
- }
- transform_destroy(this_->trans);
- this_->meth.destroy(this_->priv);
- callback_list_destroy(this_->cbl);
- attr_list_free(this_->attrs);
- if (this_->bg)
- graphics_gc_destroy(this_->bg);
- if (this_->gra)
- graphics_free(this_->gra);
- g_free(this_);
+void vehicle_destroy(struct vehicle *this_) {
+ dbg(lvl_debug,"enter");
+ if (this_->animate_callback) {
+ callback_destroy(this_->animate_callback);
+ event_remove_timeout(this_->animate_timer);
+ }
+ transform_destroy(this_->trans);
+ this_->meth.destroy(this_->priv);
+ callback_list_destroy(this_->cbl);
+ attr_list_free(this_->attrs);
+ if (this_->bg)
+ graphics_gc_destroy(this_->bg);
+ if (this_->gra)
+ graphics_free(this_->gra);
+ g_free(this_);
}
/**
* Creates an attribute iterator to be used with vehicles
*/
struct attr_iter *
-vehicle_attr_iter_new(void)
-{
- return (struct attr_iter *)g_new0(void *,1);
+vehicle_attr_iter_new(void) {
+ return (struct attr_iter *)g_new0(void *,1);
}
/**
@@ -191,10 +190,8 @@ vehicle_attr_iter_new(void)
*
* @param iter a vehicle attr_iter
*/
-void
-vehicle_attr_iter_destroy(struct attr_iter *iter)
-{
- g_free(iter);
+void vehicle_attr_iter_destroy(struct attr_iter *iter) {
+ g_free(iter);
}
@@ -208,20 +205,18 @@ vehicle_attr_iter_destroy(struct attr_iter *iter)
* @param iter A vehicle attr_iter. This is only used for generic attributes; for attributes specific to the vehicle object it is ignored.
* @return True for success, false for failure
*/
-int
-vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- int ret;
- if (type == attr_log_gpx_desc) {
- attr->u.str = this_->gpx_desc;
- return 1;
- }
- if (this_->meth.position_attr_get) {
- ret=this_->meth.position_attr_get(this_->priv, type, attr);
- if (ret)
- return ret;
- }
- return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+int vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ int ret;
+ if (type == attr_log_gpx_desc) {
+ attr->u.str = this_->gpx_desc;
+ return 1;
+ }
+ if (this_->meth.position_attr_get) {
+ ret=this_->meth.position_attr_get(this_->priv, type, attr);
+ if (ret)
+ return ret;
+ }
+ return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
}
/**
@@ -231,22 +226,20 @@ vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr,
* @param attr The attribute to set
* @return False on success, true on failure
*/
-int
-vehicle_set_attr(struct vehicle *this_, struct attr *attr)
-{
- int ret=1;
- if (attr->type == attr_log_gpx_desc) {
- g_free(this_->gpx_desc);
- this_->gpx_desc = g_strdup(attr->u.str);
- } else if (this_->meth.set_attr)
- ret=this_->meth.set_attr(this_->priv, attr);
- /* attr_profilename probably is never used by vehicle itself but it's used to control the
- routing engine. So any vehicle should allow to set and read it. */
- if(attr->type == attr_profilename)
- ret=1;
- if (ret == 1 && attr->type != attr_navit && attr->type != attr_pdl_gps_update)
- this_->attrs=attr_generic_set_attr(this_->attrs, attr);
- return ret != 0;
+int vehicle_set_attr(struct vehicle *this_, struct attr *attr) {
+ int ret=1;
+ if (attr->type == attr_log_gpx_desc) {
+ g_free(this_->gpx_desc);
+ this_->gpx_desc = g_strdup(attr->u.str);
+ } else if (this_->meth.set_attr)
+ ret=this_->meth.set_attr(this_->priv, attr);
+ /* attr_profilename probably is never used by vehicle itself but it's used to control the
+ routing engine. So any vehicle should allow to set and read it. */
+ if(attr->type == attr_profilename)
+ ret=1;
+ if (ret == 1 && attr->type != attr_navit && attr->type != attr_pdl_gps_update)
+ this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+ return ret != 0;
}
/**
@@ -257,28 +250,26 @@ vehicle_set_attr(struct vehicle *this_, struct attr *attr)
*
* @return true if the attribute was added, false if not.
*/
-int
-vehicle_add_attr(struct vehicle *this_, struct attr *attr)
-{
- int ret=1;
- switch (attr->type) {
- case attr_callback:
- callback_list_add(this_->cbl, attr->u.callback);
- break;
- case attr_log:
- ret=vehicle_add_log(this_, attr->u.log);
- break;
- // currently supporting oldstyle cursor config.
- case attr_cursor:
- this_->cursor_fixed=1;
- vehicle_set_cursor(this_, attr->u.cursor, 1);
- break;
- default:
- break;
- }
- if (ret)
- this_->attrs=attr_generic_add_attr(this_->attrs, attr);
- return ret;
+int vehicle_add_attr(struct vehicle *this_, struct attr *attr) {
+ int ret=1;
+ switch (attr->type) {
+ case attr_callback:
+ callback_list_add(this_->cbl, attr->u.callback);
+ break;
+ case attr_log:
+ ret=vehicle_add_log(this_, attr->u.log);
+ break;
+ // currently supporting oldstyle cursor config.
+ case attr_cursor:
+ this_->cursor_fixed=1;
+ vehicle_set_cursor(this_, attr->u.cursor, 1);
+ break;
+ default:
+ break;
+ }
+ if (ret)
+ this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+ return ret;
}
/**
@@ -288,26 +279,24 @@ vehicle_add_attr(struct vehicle *this_, struct attr *attr)
* @param this_ A vehicle
* @param attr
*/
-int
-vehicle_remove_attr(struct vehicle *this_, struct attr *attr)
-{
- struct callback *cb;
- switch (attr->type) {
- case attr_callback:
- callback_list_remove(this_->cbl, attr->u.callback);
- break;
- case attr_log:
- cb=g_hash_table_lookup(this_->log_to_cb, attr->u.log);
- if (!cb)
- return 0;
- g_hash_table_remove(this_->log_to_cb, attr->u.log);
- callback_list_remove(this_->cbl, cb);
- break;
- default:
- this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
- return 0;
- }
- return 1;
+int vehicle_remove_attr(struct vehicle *this_, struct attr *attr) {
+ struct callback *cb;
+ switch (attr->type) {
+ case attr_callback:
+ callback_list_remove(this_->cbl, attr->u.callback);
+ break;
+ case attr_log:
+ cb=g_hash_table_lookup(this_->log_to_cb, attr->u.log);
+ if (!cb)
+ return 0;
+ g_hash_table_remove(this_->log_to_cb, attr->u.log);
+ callback_list_remove(this_->cbl, cb);
+ break;
+ default:
+ this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
+ return 0;
+ }
+ return 1;
}
@@ -318,43 +307,41 @@ vehicle_remove_attr(struct vehicle *this_, struct attr *attr)
* @param this_ A vehicle
* @param cursor A cursor
* @author Ralph Sennhauser (10/2009)
- */
-void
-vehicle_set_cursor(struct vehicle *this_, struct cursor *cursor, int overwrite)
-{
- struct point sc;
- if (this_->cursor_fixed && !overwrite)
- return;
- if (this_->animate_callback) {
- event_remove_timeout(this_->animate_timer);
- this_->animate_timer=NULL; // dangling pointer! prevent double freeing.
- callback_destroy(this_->animate_callback);
- this_->animate_callback=NULL; // dangling pointer! prevent double freeing.
- }
- if (cursor && cursor->interval) {
- this_->animate_callback=callback_new_2(callback_cast(vehicle_draw_do), this_, 0);
- this_->animate_timer=event_add_timeout(cursor->interval, 1, this_->animate_callback);
- }
-
- if (cursor && this_->gra && this_->cursor) {
- this_->cursor_pnt.x+=(this_->cursor->w - cursor->w)/2;
- this_->cursor_pnt.y+=(this_->cursor->h - cursor->h)/2;
- graphics_overlay_resize(this_->gra, &this_->cursor_pnt, cursor->w, cursor->h, 0);
- }
-
- if (cursor) {
- sc.x=cursor->w/2;
- sc.y=cursor->h/2;
- if (!this_->cursor && this_->gra)
- graphics_overlay_disable(this_->gra, 0);
- } else {
- sc.x=sc.y=0;
- if (this_->cursor && this_->gra)
- graphics_overlay_disable(this_->gra, 1);
- }
- transform_set_screen_center(this_->trans, &sc);
-
- this_->cursor=cursor;
+ */
+void vehicle_set_cursor(struct vehicle *this_, struct cursor *cursor, int overwrite) {
+ struct point sc;
+ if (this_->cursor_fixed && !overwrite)
+ return;
+ if (this_->animate_callback) {
+ event_remove_timeout(this_->animate_timer);
+ this_->animate_timer=NULL; // dangling pointer! prevent double freeing.
+ callback_destroy(this_->animate_callback);
+ this_->animate_callback=NULL; // dangling pointer! prevent double freeing.
+ }
+ if (cursor && cursor->interval) {
+ this_->animate_callback=callback_new_2(callback_cast(vehicle_draw_do), this_, 0);
+ this_->animate_timer=event_add_timeout(cursor->interval, 1, this_->animate_callback);
+ }
+
+ if (cursor && this_->gra && this_->cursor) {
+ this_->cursor_pnt.x+=(this_->cursor->w - cursor->w)/2;
+ this_->cursor_pnt.y+=(this_->cursor->h - cursor->h)/2;
+ graphics_overlay_resize(this_->gra, &this_->cursor_pnt, cursor->w, cursor->h, 0);
+ }
+
+ if (cursor) {
+ sc.x=cursor->w/2;
+ sc.y=cursor->h/2;
+ if (!this_->cursor && this_->gra)
+ graphics_overlay_disable(this_->gra, 0);
+ } else {
+ sc.x=sc.y=0;
+ if (this_->cursor && this_->gra)
+ graphics_overlay_disable(this_->gra, 1);
+ }
+ transform_set_screen_center(this_->trans, &sc);
+
+ this_->cursor=cursor;
}
/**
@@ -366,106 +353,102 @@ vehicle_set_cursor(struct vehicle *this_, struct cursor *cursor, int overwrite)
* @param angle The angle relative to the map.
* @param speed The speed of the vehicle.
*/
-void
-vehicle_draw(struct vehicle *this_, struct graphics *gra, struct point *pnt, int angle, int speed)
-{
- if (angle < 0)
- angle+=360;
- dbg(lvl_debug,"enter this=%p gra=%p pnt=%p dir=%d speed=%d\n", this_, gra, pnt, angle, speed);
- dbg(lvl_debug,"point %d,%d\n", pnt->x, pnt->y);
- this_->cursor_pnt=*pnt;
- this_->angle=angle;
- this_->speed=speed;
- if (!this_->cursor)
- return;
- this_->cursor_pnt.x-=this_->cursor->w/2;
- this_->cursor_pnt.y-=this_->cursor->h/2;
- if (!this_->gra) {
- struct color c;
- this_->gra=graphics_overlay_new(gra, &this_->cursor_pnt, this_->cursor->w, this_->cursor->h, 0);
- if (this_->gra) {
- graphics_init(this_->gra);
- this_->bg=graphics_gc_new(this_->gra);
- c.r=0; c.g=0; c.b=0; c.a=0;
- graphics_gc_set_foreground(this_->bg, &c);
- graphics_background_gc(this_->gra, this_->bg);
- }
- }
- vehicle_draw_do(this_);
+void vehicle_draw(struct vehicle *this_, struct graphics *gra, struct point *pnt, int angle, int speed) {
+ if (angle < 0)
+ angle+=360;
+ dbg(lvl_debug,"enter this=%p gra=%p pnt=%p dir=%d speed=%d", this_, gra, pnt, angle, speed);
+ dbg(lvl_debug,"point %d,%d", pnt->x, pnt->y);
+ this_->cursor_pnt=*pnt;
+ this_->angle=angle;
+ this_->speed=speed;
+ if (!this_->cursor)
+ return;
+ this_->cursor_pnt.x-=this_->cursor->w/2;
+ this_->cursor_pnt.y-=this_->cursor->h/2;
+ if (!this_->gra) {
+ struct color c;
+ this_->gra=graphics_overlay_new(gra, &this_->cursor_pnt, this_->cursor->w, this_->cursor->h, 0);
+ if (this_->gra) {
+ graphics_init(this_->gra);
+ this_->bg=graphics_gc_new(this_->gra);
+ c.r=0;
+ c.g=0;
+ c.b=0;
+ c.a=0;
+ graphics_gc_set_foreground(this_->bg, &c);
+ graphics_background_gc(this_->gra, this_->bg);
+ }
+ }
+ vehicle_draw_do(this_);
}
-int
-vehicle_get_cursor_data(struct vehicle *this, struct point *pnt, int *angle, int *speed)
-{
- *pnt=this->cursor_pnt;
- *angle=this->angle;
- *speed=this->speed;
- return 1;
+int vehicle_get_cursor_data(struct vehicle *this, struct point *pnt, int *angle, int *speed) {
+ *pnt=this->cursor_pnt;
+ *angle=this->angle;
+ *speed=this->speed;
+ return 1;
}
-static void vehicle_set_default_name(struct vehicle *this_)
-{
- struct attr default_name;
- if (!attr_search(this_->attrs, NULL, attr_name)) {
- default_name.type=attr_name;
- // Safe cast: attr_generic_set_attr does not modify its parameter.
- default_name.u.str=(char*)_("Unnamed vehicle");
- this_->attrs=attr_generic_set_attr(this_->attrs, &default_name);
- dbg(lvl_error, "Incomplete vehicle definition: missing attribute 'name'. Default name set.\n");
- }
+static void vehicle_set_default_name(struct vehicle *this_) {
+ struct attr default_name;
+ if (!attr_search(this_->attrs, NULL, attr_name)) {
+ default_name.type=attr_name;
+ // Safe cast: attr_generic_set_attr does not modify its parameter.
+ default_name.u.str=(char*)_("Unnamed vehicle");
+ this_->attrs=attr_generic_set_attr(this_->attrs, &default_name);
+ dbg(lvl_error, "Incomplete vehicle definition: missing attribute 'name'. Default name set.");
+ }
}
-static void
-vehicle_draw_do(struct vehicle *this_)
-{
- struct point p;
- struct cursor *cursor=this_->cursor;
- int speed=this_->speed;
- int angle=this_->angle;
- int sequence=this_->sequence;
- struct attr **attr;
- char *label=NULL;
- int match=0;
-
- if (!this_->cursor || !this_->cursor->attrs || !this_->gra)
- return;
-
- attr=this_->attrs;
- while (attr && *attr) {
- if ((*attr)->type == attr_name)
- label=(*attr)->u.str;
- attr++;
- }
- transform_set_yaw(this_->trans, -this_->angle);
- graphics_draw_mode(this_->gra, draw_mode_begin);
- p.x=0;
- p.y=0;
- graphics_draw_rectangle(this_->gra, this_->bg, &p, cursor->w, cursor->h);
- attr=cursor->attrs;
- while (*attr) {
- if ((*attr)->type == attr_itemgra) {
- struct itemgra *itm=(*attr)->u.itemgra;
- dbg(lvl_debug,"speed %d-%d %d\n", itm->speed_range.min, itm->speed_range.max, speed);
- if (speed >= itm->speed_range.min && speed <= itm->speed_range.max &&
- angle >= itm->angle_range.min && angle <= itm->angle_range.max &&
- sequence >= itm->sequence_range.min && sequence <= itm->sequence_range.max) {
- graphics_draw_itemgra(this_->gra, itm, this_->trans, label);
- }
- if (sequence < itm->sequence_range.max)
- match=1;
- }
- ++attr;
- }
- graphics_draw_drag(this_->gra, &this_->cursor_pnt);
- graphics_draw_mode(this_->gra, draw_mode_end);
- if (this_->animate_callback) {
- ++this_->sequence;
- if (cursor->sequence_range && cursor->sequence_range->max < this_->sequence)
- this_->sequence=cursor->sequence_range->min;
- if (! match && ! cursor->sequence_range)
- this_->sequence=0;
- }
+static void vehicle_draw_do(struct vehicle *this_) {
+ struct point p;
+ struct cursor *cursor=this_->cursor;
+ int speed=this_->speed;
+ int angle=this_->angle;
+ int sequence=this_->sequence;
+ struct attr **attr;
+ char *label=NULL;
+ int match=0;
+
+ if (!this_->cursor || !this_->cursor->attrs || !this_->gra)
+ return;
+
+ attr=this_->attrs;
+ while (attr && *attr) {
+ if ((*attr)->type == attr_name)
+ label=(*attr)->u.str;
+ attr++;
+ }
+ transform_set_yaw(this_->trans, -this_->angle);
+ graphics_draw_mode(this_->gra, draw_mode_begin);
+ p.x=0;
+ p.y=0;
+ graphics_draw_rectangle(this_->gra, this_->bg, &p, cursor->w, cursor->h);
+ attr=cursor->attrs;
+ while (*attr) {
+ if ((*attr)->type == attr_itemgra) {
+ struct itemgra *itm=(*attr)->u.itemgra;
+ dbg(lvl_debug,"speed %d-%d %d", itm->speed_range.min, itm->speed_range.max, speed);
+ if (speed >= itm->speed_range.min && speed <= itm->speed_range.max &&
+ angle >= itm->angle_range.min && angle <= itm->angle_range.max &&
+ sequence >= itm->sequence_range.min && sequence <= itm->sequence_range.max) {
+ graphics_draw_itemgra(this_->gra, itm, this_->trans, label);
+ }
+ if (sequence < itm->sequence_range.max)
+ match=1;
+ }
+ ++attr;
+ }
+ graphics_draw_drag(this_->gra, &this_->cursor_pnt);
+ graphics_draw_mode(this_->gra, draw_mode_end);
+ if (this_->animate_callback) {
+ ++this_->sequence;
+ if (cursor->sequence_range && cursor->sequence_range->max < this_->sequence)
+ this_->sequence=cursor->sequence_range->min;
+ if (! match && ! cursor->sequence_range)
+ this_->sequence=0;
+ }
}
/**
@@ -474,15 +457,13 @@ vehicle_draw_do(struct vehicle *this_)
* @param this_ The vehicle supplying data
* @param log The log to write to
*/
-static void
-vehicle_log_nmea(struct vehicle *this_, struct log *log)
-{
- struct attr pos_attr;
- if (!this_->meth.position_attr_get)
- return;
- if (!this_->meth.position_attr_get(this_->priv, attr_position_nmea, &pos_attr))
- return;
- log_write(log, pos_attr.u.str, strlen(pos_attr.u.str), 0);
+static void vehicle_log_nmea(struct vehicle *this_, struct log *log) {
+ struct attr pos_attr;
+ if (!this_->meth.position_attr_get)
+ return;
+ if (!this_->meth.position_attr_get(this_->priv, attr_position_nmea, &pos_attr))
+ return;
+ log_write(log, pos_attr.u.str, strlen(pos_attr.u.str), 0);
}
/**
@@ -494,37 +475,35 @@ vehicle_log_nmea(struct vehicle *this_, struct log *log)
* to be inserted. If {@code *logstr} is NULL, a new string will be created for the extensions section.
* Upon returning, {@code *logstr} will point to the new string with the additional tag inserted.
*/
-void
-vehicle_log_gpx_add_tag(char *tag, char **logstr)
-{
- char *ext_start="\t<extensions>\n";
- char *ext_end="\t</extensions>\n";
- char *trkpt_end="</trkpt>";
- char *start=NULL,*end=NULL;
- if (!*logstr) {
- start=g_strdup(ext_start);
- end=g_strdup(ext_end);
- } else {
- char *str=strstr(*logstr, ext_start);
- int len;
- if (str) {
- len=str-*logstr+strlen(ext_start);
- start=g_strdup(*logstr);
- start[len]='\0';
- end=g_strdup(str+strlen(ext_start));
- } else {
- str=strstr(*logstr, trkpt_end);
- len=str-*logstr;
- end=g_strdup_printf("%s%s",ext_end,str);
- str=g_strdup(*logstr);
- str[len]='\0';
- start=g_strdup_printf("%s%s",str,ext_start);
- g_free(str);
- }
- }
- *logstr=g_strdup_printf("%s%s%s",start,tag,end);
- g_free(start);
- g_free(end);
+void vehicle_log_gpx_add_tag(char *tag, char **logstr) {
+ char *ext_start="\t<extensions>\n";
+ char *ext_end="\t</extensions>\n";
+ char *trkpt_end="</trkpt>";
+ char *start=NULL,*end=NULL;
+ if (!*logstr) {
+ start=g_strdup(ext_start);
+ end=g_strdup(ext_end);
+ } else {
+ char *str=strstr(*logstr, ext_start);
+ int len;
+ if (str) {
+ len=str-*logstr+strlen(ext_start);
+ start=g_strdup(*logstr);
+ start[len]='\0';
+ end=g_strdup(str+strlen(ext_start));
+ } else {
+ str=strstr(*logstr, trkpt_end);
+ len=str-*logstr;
+ end=g_strdup_printf("%s%s",ext_end,str);
+ str=g_strdup(*logstr);
+ str[len]='\0';
+ start=g_strdup_printf("%s%s",str,ext_start);
+ g_free(str);
+ }
+ }
+ *logstr=g_strdup_printf("%s%s%s",start,tag,end);
+ g_free(start);
+ g_free(end);
}
/**
@@ -533,76 +512,81 @@ vehicle_log_gpx_add_tag(char *tag, char **logstr)
* @param this_ The vehicle supplying data
* @param log The log to write to
*/
-static void
-vehicle_log_gpx(struct vehicle *this_, struct log *log)
-{
- struct attr attr,*attrp, fix_attr;
- enum attr_type *attr_types;
- char *logstr;
- char *extensions="\t<extensions>\n";
-
- if (!this_->meth.position_attr_get)
- return;
- if (log_get_attr(log, attr_attr_types, &attr, NULL))
- attr_types=attr.u.attr_types;
- else
- attr_types=NULL;
- if (this_->meth.position_attr_get(this_->priv, attr_position_fix_type, &fix_attr)) {
- if ( fix_attr.u.num == 0 )
- return;
- }
- if (!this_->meth.position_attr_get(this_->priv, attr_position_coord_geo, &attr))
- return;
- logstr=g_strdup_printf("<trkpt lat=\"%f\" lon=\"%f\">\n",attr.u.coord_geo->lat,attr.u.coord_geo->lng);
- if (attr_types && attr_types_contains_default(attr_types, attr_position_time_iso8601, 0)) {
- if (this_->meth.position_attr_get(this_->priv, attr_position_time_iso8601, &attr)) {
- logstr=g_strconcat_printf(logstr,"\t<time>%s</time>\n",attr.u.str);
- } else {
- char *timep = current_to_iso8601();
- logstr=g_strconcat_printf(logstr,"\t<time>%s</time>\n",timep);
- g_free(timep);
- }
- }
- if (this_->gpx_desc) {
- logstr=g_strconcat_printf(logstr,"\t<desc>%s</desc>\n",this_->gpx_desc);
- g_free(this_->gpx_desc);
- this_->gpx_desc = NULL;
- }
- if (attr_types_contains_default(attr_types, attr_position_height,0) && this_->meth.position_attr_get(this_->priv, attr_position_height, &attr))
- logstr=g_strconcat_printf(logstr,"\t<ele>%.6f</ele>\n",*attr.u.numd);
- // <magvar> magnetic variation in degrees; we might use position_magnetic_direction and position_direction to figure it out
- // <geoidheight> Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message (field 11, which vehicle_wince.c ignores)
- // <name> GPS name (arbitrary)
- // <cmt> comment
- // <src> Source of data
- // <link> Link to additional information (URL)
- // <sym> Text of GPS symbol name
- // <type> Type (classification)
- // <fix> Type of GPS fix {'none'|'2d'|'3d'|'dgps'|'pps'}, leave out if unknown. Similar to position_fix_type but more detailed.
- if (attr_types_contains_default(attr_types, attr_position_sats_used,0) && this_->meth.position_attr_get(this_->priv, attr_position_sats_used, &attr))
- logstr=g_strconcat_printf(logstr,"\t<sat>%d</sat>\n",attr.u.num);
- if (attr_types_contains_default(attr_types, attr_position_hdop,0) && this_->meth.position_attr_get(this_->priv, attr_position_hdop, &attr))
- logstr=g_strconcat_printf(logstr,"\t<hdop>%.6f</hdop>\n",*attr.u.numd);
- // <vdop>, <pdop> Vertical and position dilution of precision, no corresponding attribute
- if (attr_types_contains_default(attr_types, attr_position_direction,0) && this_->meth.position_attr_get(this_->priv, attr_position_direction, &attr))
- logstr=g_strconcat_printf(logstr,"\t<course>%.1f</course>\n",*attr.u.numd);
- if (attr_types_contains_default(attr_types, attr_position_speed, 0) && this_->meth.position_attr_get(this_->priv, attr_position_speed, &attr))
- logstr=g_strconcat_printf(logstr,"\t<speed>%.2f</speed>\n",(*attr.u.numd / 3.6));
- if (attr_types_contains_default(attr_types, attr_profilename, 0) && (attrp=attr_search(this_->attrs, NULL, attr_profilename))) {
- logstr=g_strconcat_printf(logstr,"%s\t\t<navit:profilename>%s</navit:profilename>\n",extensions,attrp->u.str);
- extensions="";
- }
- if (attr_types_contains_default(attr_types, attr_position_radius, 0) && this_->meth.position_attr_get(this_->priv, attr_position_radius, &attr)) {
- logstr=g_strconcat_printf(logstr,"%s\t\t<navit:radius>%.2f</navit:radius>\n",extensions,*attr.u.numd);
- extensions="";
- }
- if (!strcmp(extensions,"")) {
- logstr=g_strconcat_printf(logstr,"\t</extensions>\n");
- }
- logstr=g_strconcat_printf(logstr,"</trkpt>\n");
- callback_list_call_attr_1(this_->cbl, attr_log_gpx, &logstr);
- log_write(log, logstr, strlen(logstr), 0);
- g_free(logstr);
+static void vehicle_log_gpx(struct vehicle *this_, struct log *log) {
+ struct attr attr,*attrp, fix_attr;
+ enum attr_type *attr_types;
+ char *logstr;
+ char *extensions="\t<extensions>\n";
+
+ if (!this_->meth.position_attr_get)
+ return;
+ if (log_get_attr(log, attr_attr_types, &attr, NULL))
+ attr_types=attr.u.attr_types;
+ else
+ attr_types=NULL;
+ if (this_->meth.position_attr_get(this_->priv, attr_position_fix_type, &fix_attr)) {
+ if ( fix_attr.u.num == 0 )
+ return;
+ }
+ if (!this_->meth.position_attr_get(this_->priv, attr_position_coord_geo, &attr))
+ return;
+ logstr=g_strdup_printf("<trkpt lat=\"%f\" lon=\"%f\">\n",attr.u.coord_geo->lat,attr.u.coord_geo->lng);
+ if (attr_types && attr_types_contains_default(attr_types, attr_position_time_iso8601, 0)) {
+ if (this_->meth.position_attr_get(this_->priv, attr_position_time_iso8601, &attr)) {
+ logstr=g_strconcat_printf(logstr,"\t<time>%s</time>\n",attr.u.str);
+ } else {
+ char *timep = current_to_iso8601();
+ logstr=g_strconcat_printf(logstr,"\t<time>%s</time>\n",timep);
+ g_free(timep);
+ }
+ }
+ if (this_->gpx_desc) {
+ logstr=g_strconcat_printf(logstr,"\t<desc>%s</desc>\n",this_->gpx_desc);
+ g_free(this_->gpx_desc);
+ this_->gpx_desc = NULL;
+ }
+ if (attr_types_contains_default(attr_types, attr_position_height,0)
+ && this_->meth.position_attr_get(this_->priv, attr_position_height, &attr))
+ logstr=g_strconcat_printf(logstr,"\t<ele>%.6f</ele>\n",*attr.u.numd);
+ // <magvar> magnetic variation in degrees; we might use position_magnetic_direction and position_direction to figure it out
+ // <geoidheight> Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message (field 11, which vehicle_wince.c ignores)
+ // <name> GPS name (arbitrary)
+ // <cmt> comment
+ // <src> Source of data
+ // <link> Link to additional information (URL)
+ // <sym> Text of GPS symbol name
+ // <type> Type (classification)
+ // <fix> Type of GPS fix {'none'|'2d'|'3d'|'dgps'|'pps'}, leave out if unknown. Similar to position_fix_type but more detailed.
+ if (attr_types_contains_default(attr_types, attr_position_sats_used,0)
+ && this_->meth.position_attr_get(this_->priv, attr_position_sats_used, &attr))
+ logstr=g_strconcat_printf(logstr,"\t<sat>%d</sat>\n",attr.u.num);
+ if (attr_types_contains_default(attr_types, attr_position_hdop,0)
+ && this_->meth.position_attr_get(this_->priv, attr_position_hdop, &attr))
+ logstr=g_strconcat_printf(logstr,"\t<hdop>%.6f</hdop>\n",*attr.u.numd);
+ // <vdop>, <pdop> Vertical and position dilution of precision, no corresponding attribute
+ if (attr_types_contains_default(attr_types, attr_position_direction,0)
+ && this_->meth.position_attr_get(this_->priv, attr_position_direction, &attr))
+ logstr=g_strconcat_printf(logstr,"\t<course>%.1f</course>\n",*attr.u.numd);
+ if (attr_types_contains_default(attr_types, attr_position_speed, 0)
+ && this_->meth.position_attr_get(this_->priv, attr_position_speed, &attr))
+ logstr=g_strconcat_printf(logstr,"\t<speed>%.2f</speed>\n",(*attr.u.numd / 3.6));
+ if (attr_types_contains_default(attr_types, attr_profilename, 0)
+ && (attrp=attr_search(this_->attrs, NULL, attr_profilename))) {
+ logstr=g_strconcat_printf(logstr,"%s\t\t<navit:profilename>%s</navit:profilename>\n",extensions,attrp->u.str);
+ extensions="";
+ }
+ if (attr_types_contains_default(attr_types, attr_position_radius, 0)
+ && this_->meth.position_attr_get(this_->priv, attr_position_radius, &attr)) {
+ logstr=g_strconcat_printf(logstr,"%s\t\t<navit:radius>%.2f</navit:radius>\n",extensions,*attr.u.numd);
+ extensions="";
+ }
+ if (!strcmp(extensions,"")) {
+ logstr=g_strconcat_printf(logstr,"\t</extensions>\n");
+ }
+ logstr=g_strconcat_printf(logstr,"</trkpt>\n");
+ callback_list_call_attr_1(this_->cbl, attr_log_gpx, &logstr);
+ log_write(log, logstr, strlen(logstr), 0);
+ g_free(logstr);
}
/**
@@ -611,22 +595,20 @@ vehicle_log_gpx(struct vehicle *this_, struct log *log)
* @param this_ The vehicle supplying data
* @param log The log to write to
*/
-static void
-vehicle_log_textfile(struct vehicle *this_, struct log *log)
-{
- struct attr pos_attr,fix_attr;
- char *logstr;
- if (!this_->meth.position_attr_get)
- return;
- if (this_->meth.position_attr_get(this_->priv, attr_position_fix_type, &fix_attr)) {
- if (fix_attr.u.num == 0)
- return;
- }
- if (!this_->meth.position_attr_get(this_->priv, attr_position_coord_geo, &pos_attr))
- return;
- logstr=g_strdup_printf("%f %f type=trackpoint\n", pos_attr.u.coord_geo->lng, pos_attr.u.coord_geo->lat);
- callback_list_call_attr_1(this_->cbl, attr_log_textfile, &logstr);
- log_write(log, logstr, strlen(logstr), 0);
+static void vehicle_log_textfile(struct vehicle *this_, struct log *log) {
+ struct attr pos_attr,fix_attr;
+ char *logstr;
+ if (!this_->meth.position_attr_get)
+ return;
+ if (this_->meth.position_attr_get(this_->priv, attr_position_fix_type, &fix_attr)) {
+ if (fix_attr.u.num == 0)
+ return;
+ }
+ if (!this_->meth.position_attr_get(this_->priv, attr_position_coord_geo, &pos_attr))
+ return;
+ logstr=g_strdup_printf("%f %f type=trackpoint\n", pos_attr.u.coord_geo->lng, pos_attr.u.coord_geo->lat);
+ callback_list_call_attr_1(this_->cbl, attr_log_textfile, &logstr);
+ log_write(log, logstr, strlen(logstr), 0);
}
/**
@@ -635,58 +617,56 @@ vehicle_log_textfile(struct vehicle *this_, struct log *log)
* @param this_ The vehicle supplying data
* @param log The log to write to
*/
-static void
-vehicle_log_binfile(struct vehicle *this_, struct log *log)
-{
- struct attr pos_attr, fix_attr;
- int *buffer;
- int *buffer_new;
- int len,limit=1024,done=0,radius=25;
- struct coord c;
- enum log_flags flags;
-
- if (!this_->meth.position_attr_get)
- return;
- if (this_->meth.position_attr_get(this_->priv, attr_position_fix_type, &fix_attr)) {
- if (fix_attr.u.num == 0)
- return;
- }
- if (!this_->meth.position_attr_get(this_->priv, attr_position_coord_geo, &pos_attr))
- return;
- transform_from_geo(projection_mg, pos_attr.u.coord_geo, &c);
- if (!c.x || !c.y)
- return;
- while (!done) {
- buffer=log_get_buffer(log, &len);
- if (! buffer || !len) {
- buffer_new=g_malloc(5*sizeof(int));
- buffer_new[0]=2;
- buffer_new[1]=type_track;
- buffer_new[2]=0;
- } else {
- buffer_new=g_malloc((buffer[0]+3)*sizeof(int));
- memcpy(buffer_new, buffer, (buffer[0]+1)*sizeof(int));
- }
- dbg(lvl_debug,"c=0x%x,0x%x\n",c.x,c.y);
- buffer_new[buffer_new[0]+1]=c.x;
- buffer_new[buffer_new[0]+2]=c.y;
- buffer_new[0]+=2;
- buffer_new[2]+=2;
- if (buffer_new[2] > limit) {
- int count=buffer_new[2]/2;
- struct coord *out=g_alloca(sizeof(struct coord)*(count));
- struct coord *in=(struct coord *)(buffer_new+3);
- int count_out=transform_douglas_peucker(in, count, radius, out);
- memcpy(in, out, count_out*2*sizeof(int));
- buffer_new[0]+=(count_out-count)*2;
- buffer_new[2]+=(count_out-count)*2;
- flags=log_flag_replace_buffer|log_flag_force_flush|log_flag_truncate;
- } else {
- flags=log_flag_replace_buffer|log_flag_keep_pointer|log_flag_keep_buffer|log_flag_force_flush;
- done=1;
- }
- log_write(log, (char *)buffer_new, (buffer_new[0]+1)*sizeof(int), flags);
- }
+static void vehicle_log_binfile(struct vehicle *this_, struct log *log) {
+ struct attr pos_attr, fix_attr;
+ int *buffer;
+ int *buffer_new;
+ int len,limit=1024,done=0,radius=25;
+ struct coord c;
+ enum log_flags flags;
+
+ if (!this_->meth.position_attr_get)
+ return;
+ if (this_->meth.position_attr_get(this_->priv, attr_position_fix_type, &fix_attr)) {
+ if (fix_attr.u.num == 0)
+ return;
+ }
+ if (!this_->meth.position_attr_get(this_->priv, attr_position_coord_geo, &pos_attr))
+ return;
+ transform_from_geo(projection_mg, pos_attr.u.coord_geo, &c);
+ if (!c.x || !c.y)
+ return;
+ while (!done) {
+ buffer=log_get_buffer(log, &len);
+ if (! buffer || !len) {
+ buffer_new=g_malloc(5*sizeof(int));
+ buffer_new[0]=2;
+ buffer_new[1]=type_track;
+ buffer_new[2]=0;
+ } else {
+ buffer_new=g_malloc((buffer[0]+3)*sizeof(int));
+ memcpy(buffer_new, buffer, (buffer[0]+1)*sizeof(int));
+ }
+ dbg(lvl_debug,"c=0x%x,0x%x",c.x,c.y);
+ buffer_new[buffer_new[0]+1]=c.x;
+ buffer_new[buffer_new[0]+2]=c.y;
+ buffer_new[0]+=2;
+ buffer_new[2]+=2;
+ if (buffer_new[2] > limit) {
+ int count=buffer_new[2]/2;
+ struct coord *out=g_alloca(sizeof(struct coord)*(count));
+ struct coord *in=(struct coord *)(buffer_new+3);
+ int count_out=transform_douglas_peucker(in, count, radius, out);
+ memcpy(in, out, count_out*2*sizeof(int));
+ buffer_new[0]+=(count_out-count)*2;
+ buffer_new[2]+=(count_out-count)*2;
+ flags=log_flag_replace_buffer|log_flag_force_flush|log_flag_truncate;
+ } else {
+ flags=log_flag_replace_buffer|log_flag_keep_pointer|log_flag_keep_buffer|log_flag_force_flush;
+ done=1;
+ }
+ log_write(log, (char *)buffer_new, (buffer_new[0]+1)*sizeof(int), flags);
+ }
}
/**
@@ -697,54 +677,52 @@ vehicle_log_binfile(struct vehicle *this_, struct log *log)
*
* @return False if the log is of an unknown type, true otherwise (including when {@code attr_type} is missing).
*/
-static int
-vehicle_add_log(struct vehicle *this_, struct log *log)
-{
- struct callback *cb;
- struct attr type_attr;
- if (!log_get_attr(log, attr_type, &type_attr, NULL))
- return 1;
-
- if (!strcmp(type_attr.u.str, "nmea")) {
- cb=callback_new_attr_2(callback_cast(vehicle_log_nmea), attr_position_coord_geo, this_, log);
- } else if (!strcmp(type_attr.u.str, "gpx")) {
- char *header = "<?xml version='1.0' encoding='UTF-8'?>\n"
- "<gpx version='1.1' creator='Navit http://navit.sourceforge.net'\n"
- " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"
- " xmlns:navit='http://www.navit-project.org/schema/navit'\n"
- " xmlns='http://www.topografix.com/GPX/1/1'\n"
- " xsi:schemaLocation='http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'>\n"
- "<trk>\n"
- "<trkseg>\n";
- char *trailer = "</trkseg>\n</trk>\n</gpx>\n";
- log_set_header(log, header, strlen(header));
- log_set_trailer(log, trailer, strlen(trailer));
- cb=callback_new_attr_2(callback_cast(vehicle_log_gpx), attr_position_coord_geo, this_, log);
- } else if (!strcmp(type_attr.u.str, "textfile")) {
- char *header = "type=track\n";
- log_set_header(log, header, strlen(header));
- cb=callback_new_attr_2(callback_cast(vehicle_log_textfile), attr_position_coord_geo, this_, log);
- } else if (!strcmp(type_attr.u.str, "binfile")) {
- cb=callback_new_attr_2(callback_cast(vehicle_log_binfile), attr_position_coord_geo, this_, log);
- } else
- return 0;
- g_hash_table_insert(this_->log_to_cb, log, cb);
- callback_list_add(this_->cbl, cb);
- return 1;
+static int vehicle_add_log(struct vehicle *this_, struct log *log) {
+ struct callback *cb;
+ struct attr type_attr;
+ if (!log_get_attr(log, attr_type, &type_attr, NULL))
+ return 1;
+
+ if (!strcmp(type_attr.u.str, "nmea")) {
+ cb=callback_new_attr_2(callback_cast(vehicle_log_nmea), attr_position_coord_geo, this_, log);
+ } else if (!strcmp(type_attr.u.str, "gpx")) {
+ char *header = "<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<gpx version='1.1' creator='Navit http://navit.sourceforge.net'\n"
+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"
+ " xmlns:navit='http://www.navit-project.org/schema/navit'\n"
+ " xmlns='http://www.topografix.com/GPX/1/1'\n"
+ " xsi:schemaLocation='http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'>\n"
+ "<trk>\n"
+ "<trkseg>\n";
+ char *trailer = "</trkseg>\n</trk>\n</gpx>\n";
+ log_set_header(log, header, strlen(header));
+ log_set_trailer(log, trailer, strlen(trailer));
+ cb=callback_new_attr_2(callback_cast(vehicle_log_gpx), attr_position_coord_geo, this_, log);
+ } else if (!strcmp(type_attr.u.str, "textfile")) {
+ char *header = "type=track\n";
+ log_set_header(log, header, strlen(header));
+ cb=callback_new_attr_2(callback_cast(vehicle_log_textfile), attr_position_coord_geo, this_, log);
+ } else if (!strcmp(type_attr.u.str, "binfile")) {
+ cb=callback_new_attr_2(callback_cast(vehicle_log_binfile), attr_position_coord_geo, this_, log);
+ } else
+ return 0;
+ g_hash_table_insert(this_->log_to_cb, log, cb);
+ callback_list_add(this_->cbl, cb);
+ return 1;
}
struct object_func vehicle_func = {
- attr_vehicle,
- (object_func_new)vehicle_new,
- (object_func_get_attr)vehicle_get_attr,
- (object_func_iter_new)vehicle_attr_iter_new,
- (object_func_iter_destroy)vehicle_attr_iter_destroy,
- (object_func_set_attr)vehicle_set_attr,
- (object_func_add_attr)vehicle_add_attr,
- (object_func_remove_attr)vehicle_remove_attr,
- (object_func_init)NULL,
- (object_func_destroy)vehicle_destroy,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_vehicle,
+ (object_func_new)vehicle_new,
+ (object_func_get_attr)vehicle_get_attr,
+ (object_func_iter_new)vehicle_attr_iter_new,
+ (object_func_iter_destroy)vehicle_attr_iter_destroy,
+ (object_func_set_attr)vehicle_set_attr,
+ (object_func_add_attr)vehicle_add_attr,
+ (object_func_remove_attr)vehicle_remove_attr,
+ (object_func_init)NULL,
+ (object_func_destroy)vehicle_destroy,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/vehicle/android/vehicle_android.c b/navit/vehicle/android/vehicle_android.c
index 89882d048..f6173e1b3 100644
--- a/navit/vehicle/android/vehicle_android.c
+++ b/navit/vehicle/android/vehicle_android.c
@@ -1,6 +1,4 @@
-/** @file vehicle_android.c
- * @brief android uses dbus signals
- *
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -18,8 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
- * @Author Tim Niemeyer <reddog@mastersword.de>
- * @date 2008-2009
*/
#include <config.h>
@@ -35,40 +31,48 @@
#include "android.h"
#include "vehicle.h"
+/**
+ * @defgroup vehicle-android Vehicle Android
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from android.
+ * @author Tim Niemeyer <reddog@mastersword.de>
+ * @date 2008-2009
+ *
+ */
+
struct vehicle_priv {
- struct callback_list *cbl;
- struct coord_geo geo; /**< The last known position of the vehicle **/
- double speed; /**< Speed in km/h **/
- double direction; /**< Bearing in degrees **/
- double height; /**< Elevation in meters **/
- double radius; /**< Position accuracy in meters **/
- int fix_type; /**< Type of last fix (1 = valid, 0 = invalid) **/
- time_t fix_time; /**< Timestamp of last fix (not used) **/
- char fixiso8601[128]; /**< Timestamp of last fix in ISO 8601 format **/
- int sats; /**< Number of satellites in view **/
- int sats_used; /**< Number of satellites used in fix **/
- int valid; /**< Whether the vehicle coordinates in {@code geo} are valid **/
- struct attr ** attrs;
- struct callback *pcb; /**< The callback function for position updates **/
- struct callback *scb; /**< The callback function for status updates **/
- struct callback *fcb; /**< The callback function for fix status updates **/
- jclass NavitVehicleClass; /**< The {@code NavitVehicle} class **/
- jobject NavitVehicle; /**< An instance of {@code NavitVehicle} **/
- jclass LocationClass; /**< Android's {@code Location} class **/
- jmethodID Location_getLatitude, Location_getLongitude, Location_getSpeed, Location_getBearing, Location_getAltitude, Location_getTime, Location_getAccuracy;
+ struct callback_list *cbl;
+ struct coord_geo geo; /**< The last known position of the vehicle **/
+ double speed; /**< Speed in km/h **/
+ double direction; /**< Bearing in degrees **/
+ double height; /**< Elevation in meters **/
+ double radius; /**< Position accuracy in meters **/
+ int fix_type; /**< Type of last fix (1 = valid, 0 = invalid) **/
+ time_t fix_time; /**< Timestamp of last fix (not used) **/
+ char fixiso8601[128]; /**< Timestamp of last fix in ISO 8601 format **/
+ int sats; /**< Number of satellites in view **/
+ int sats_used; /**< Number of satellites used in fix **/
+ int valid; /**< Whether the vehicle coordinates in {@code geo} are valid **/
+ struct attr ** attrs;
+ struct callback *pcb; /**< The callback function for position updates **/
+ struct callback *scb; /**< The callback function for status updates **/
+ struct callback *fcb; /**< The callback function for fix status updates **/
+ jclass NavitVehicleClass; /**< The {@code NavitVehicle} class **/
+ jobject NavitVehicle; /**< An instance of {@code NavitVehicle} **/
+ jclass LocationClass; /**< Android's {@code Location} class **/
+ jmethodID Location_getLatitude, Location_getLongitude, Location_getSpeed, Location_getBearing, Location_getAltitude,
+ Location_getTime, Location_getAccuracy;
};
/**
* @brief Free the android_vehicle
- *
+ *
* @param priv vehicle_priv structure for the vehicle
* @returns nothing
*/
-static void
-vehicle_android_destroy(struct vehicle_priv *priv)
-{
- dbg(lvl_debug,"enter\n");
- g_free(priv);
+static void vehicle_android_destroy(struct vehicle_priv *priv) {
+ dbg(lvl_debug,"enter");
+ g_free(priv);
}
/**
@@ -79,55 +83,53 @@ vehicle_android_destroy(struct vehicle_priv *priv)
* @param attr Points to an attr structure that will receive the attribute data
* @returns True for success, false for failure
*/
-static int
-vehicle_android_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- dbg(lvl_debug,"enter %s\n",attr_to_name(type));
- switch (type) {
- case attr_position_fix_type:
- attr->u.num = priv->fix_type;
- break;
- case attr_position_height:
- attr->u.numd = &priv->height;
- break;
- case attr_position_speed:
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- attr->u.numd = &priv->direction;
- break;
- case attr_position_radius:
- attr->u.numd = &priv->radius;
- break;
- case attr_position_qual:
- attr->u.num = priv->sats;
- break;
- case attr_position_sats_used:
- attr->u.num = priv->sats_used;
- break;
- case attr_position_coord_geo:
- attr->u.coord_geo = &priv->geo;
- if (priv->valid == attr_position_valid_invalid)
- return 0;
- break;
- case attr_position_time_iso8601:
- attr->u.str=priv->fixiso8601;
- break;
- case attr_position_valid:
- attr->u.num = priv->valid;
- break;
- default:
- return 0;
- }
- dbg(lvl_debug,"ok\n");
- attr->type = type;
- return 1;
+static int vehicle_android_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ dbg(lvl_debug,"enter %s",attr_to_name(type));
+ switch (type) {
+ case attr_position_fix_type:
+ attr->u.num = priv->fix_type;
+ break;
+ case attr_position_height:
+ attr->u.numd = &priv->height;
+ break;
+ case attr_position_speed:
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ attr->u.numd = &priv->direction;
+ break;
+ case attr_position_radius:
+ attr->u.numd = &priv->radius;
+ break;
+ case attr_position_qual:
+ attr->u.num = priv->sats;
+ break;
+ case attr_position_sats_used:
+ attr->u.num = priv->sats_used;
+ break;
+ case attr_position_coord_geo:
+ attr->u.coord_geo = &priv->geo;
+ if (priv->valid == attr_position_valid_invalid)
+ return 0;
+ break;
+ case attr_position_time_iso8601:
+ attr->u.str=priv->fixiso8601;
+ break;
+ case attr_position_valid:
+ attr->u.num = priv->valid;
+ break;
+ default:
+ return 0;
+ }
+ dbg(lvl_debug,"ok");
+ attr->type = type;
+ return 1;
}
struct vehicle_methods vehicle_android_methods = {
- vehicle_android_destroy,
- vehicle_android_position_attr_get,
+ vehicle_android_destroy,
+ vehicle_android_position_attr_get,
};
/**
@@ -138,27 +140,26 @@ struct vehicle_methods vehicle_android_methods = {
* @param v The {@code struct_vehicle_priv} for the vehicle
* @param location A {@code Location} object describing the new position
*/
-static void
-vehicle_android_position_callback(struct vehicle_priv *v, jobject location) {
- time_t tnow;
- struct tm *tm;
- dbg(lvl_debug,"enter\n");
+static void vehicle_android_position_callback(struct vehicle_priv *v, jobject location) {
+ time_t tnow;
+ struct tm *tm;
+ dbg(lvl_debug,"enter");
- v->geo.lat = (*jnienv)->CallDoubleMethod(jnienv, location, v->Location_getLatitude);
- v->geo.lng = (*jnienv)->CallDoubleMethod(jnienv, location, v->Location_getLongitude);
- v->speed = (*jnienv)->CallFloatMethod(jnienv, location, v->Location_getSpeed)*3.6;
- v->direction = (*jnienv)->CallFloatMethod(jnienv, location, v->Location_getBearing);
- v->height = (*jnienv)->CallDoubleMethod(jnienv, location, v->Location_getAltitude);
- v->radius = (*jnienv)->CallFloatMethod(jnienv, location, v->Location_getAccuracy);
- tnow=(*jnienv)->CallLongMethod(jnienv, location, v->Location_getTime)/1000;
- tm = gmtime(&tnow);
- strftime(v->fixiso8601, sizeof(v->fixiso8601), "%Y-%m-%dT%TZ", tm);
- dbg(lvl_debug,"lat %f lon %f time %s\n",v->geo.lat,v->geo.lng,v->fixiso8601);
- if (v->valid != attr_position_valid_valid) {
- v->valid = attr_position_valid_valid;
- callback_list_call_attr_0(v->cbl, attr_position_valid);
- }
- callback_list_call_attr_0(v->cbl, attr_position_coord_geo);
+ v->geo.lat = (*jnienv)->CallDoubleMethod(jnienv, location, v->Location_getLatitude);
+ v->geo.lng = (*jnienv)->CallDoubleMethod(jnienv, location, v->Location_getLongitude);
+ v->speed = (*jnienv)->CallFloatMethod(jnienv, location, v->Location_getSpeed)*3.6;
+ v->direction = (*jnienv)->CallFloatMethod(jnienv, location, v->Location_getBearing);
+ v->height = (*jnienv)->CallDoubleMethod(jnienv, location, v->Location_getAltitude);
+ v->radius = (*jnienv)->CallFloatMethod(jnienv, location, v->Location_getAccuracy);
+ tnow=(*jnienv)->CallLongMethod(jnienv, location, v->Location_getTime)/1000;
+ tm = gmtime(&tnow);
+ strftime(v->fixiso8601, sizeof(v->fixiso8601), "%Y-%m-%dT%TZ", tm);
+ dbg(lvl_debug,"lat %f lon %f time %s",v->geo.lat,v->geo.lng,v->fixiso8601);
+ if (v->valid != attr_position_valid_valid) {
+ v->valid = attr_position_valid_valid;
+ callback_list_call_attr_0(v->cbl, attr_position_valid);
+ }
+ callback_list_call_attr_0(v->cbl, attr_position_coord_geo);
}
/**
@@ -175,16 +176,15 @@ vehicle_android_position_callback(struct vehicle_priv *v, jobject location) {
* @param sats_in_view The number of satellites in view
* @param sats_used The number of satellites currently used to determine the position
*/
-static void
-vehicle_android_status_callback(struct vehicle_priv *v, int sats_in_view, int sats_used) {
- if (v->sats != sats_in_view) {
- v->sats = sats_in_view;
- callback_list_call_attr_0(v->cbl, attr_position_qual);
- }
- if (v->sats_used != sats_used) {
- v->sats_used = sats_used;
- callback_list_call_attr_0(v->cbl, attr_position_sats_used);
- }
+static void vehicle_android_status_callback(struct vehicle_priv *v, int sats_in_view, int sats_used) {
+ if (v->sats != sats_in_view) {
+ v->sats = sats_in_view;
+ callback_list_call_attr_0(v->cbl, attr_position_qual);
+ }
+ if (v->sats_used != sats_used) {
+ v->sats_used = sats_used;
+ callback_list_call_attr_0(v->cbl, attr_position_sats_used);
+ }
}
/**
@@ -195,16 +195,15 @@ vehicle_android_status_callback(struct vehicle_priv *v, int sats_in_view, int sa
* @param v The {@code struct_vehicle_priv} for the vehicle
* @param fix_type The fix type (1 = valid, 0 = invalid)
*/
-static void
-vehicle_android_fix_callback(struct vehicle_priv *v, int fix_type) {
- if (v->fix_type != fix_type) {
- v->fix_type = fix_type;
- callback_list_call_attr_0(v->cbl, attr_position_fix_type);
- if (!fix_type && (v->valid == attr_position_valid_valid)) {
- v->valid = attr_position_valid_extrapolated_time;
- callback_list_call_attr_0(v->cbl, attr_position_valid);
- }
- }
+static void vehicle_android_fix_callback(struct vehicle_priv *v, int fix_type) {
+ if (v->fix_type != fix_type) {
+ v->fix_type = fix_type;
+ callback_list_call_attr_0(v->cbl, attr_position_fix_type);
+ if (!fix_type && (v->valid == attr_position_valid_valid)) {
+ v->valid = attr_position_valid_extrapolated_time;
+ callback_list_call_attr_0(v->cbl, attr_position_valid);
+ }
+ }
}
/**
@@ -212,85 +211,81 @@ vehicle_android_fix_callback(struct vehicle_priv *v, int fix_type) {
*
* @return True on success, false on failure
*/
-static int
-vehicle_android_init(struct vehicle_priv *ret)
-{
- jmethodID cid;
+static int vehicle_android_init(struct vehicle_priv *ret) {
+ jmethodID cid;
- if (!android_find_class_global("android/location/Location", &ret->LocationClass))
- return 0;
- if (!android_find_method(ret->LocationClass, "getLatitude", "()D", &ret->Location_getLatitude))
- return 0;
- if (!android_find_method(ret->LocationClass, "getLongitude", "()D", &ret->Location_getLongitude))
- return 0;
- if (!android_find_method(ret->LocationClass, "getSpeed", "()F", &ret->Location_getSpeed))
- return 0;
- if (!android_find_method(ret->LocationClass, "getBearing", "()F", &ret->Location_getBearing))
- return 0;
- if (!android_find_method(ret->LocationClass, "getAltitude", "()D", &ret->Location_getAltitude))
- return 0;
- if (!android_find_method(ret->LocationClass, "getTime", "()J", &ret->Location_getTime))
- return 0;
- if (!android_find_method(ret->LocationClass, "getAccuracy", "()F", &ret->Location_getAccuracy))
- return 0;
- if (!android_find_class_global("org/navitproject/navit/NavitVehicle", &ret->NavitVehicleClass))
- return 0;
- dbg(lvl_debug,"at 3\n");
- cid = (*jnienv)->GetMethodID(jnienv, ret->NavitVehicleClass, "<init>", "(Landroid/content/Context;III)V");
- if (cid == NULL) {
- dbg(lvl_error,"no method found\n");
- return 0; /* exception thrown */
- }
- dbg(lvl_debug, "at 4 android_activity=%p\n", android_activity);
- ret->NavitVehicle=(*jnienv)->NewObject(jnienv, ret->NavitVehicleClass, cid, android_activity,
- (int) ret->pcb, (int) ret->scb, (int) ret->fcb);
- dbg(lvl_debug,"result=%p\n",ret->NavitVehicle);
- if (!ret->NavitVehicle)
- return 0;
- if (ret->NavitVehicle)
- ret->NavitVehicle = (*jnienv)->NewGlobalRef(jnienv, ret->NavitVehicle);
+ if (!android_find_class_global("android/location/Location", &ret->LocationClass))
+ return 0;
+ if (!android_find_method(ret->LocationClass, "getLatitude", "()D", &ret->Location_getLatitude))
+ return 0;
+ if (!android_find_method(ret->LocationClass, "getLongitude", "()D", &ret->Location_getLongitude))
+ return 0;
+ if (!android_find_method(ret->LocationClass, "getSpeed", "()F", &ret->Location_getSpeed))
+ return 0;
+ if (!android_find_method(ret->LocationClass, "getBearing", "()F", &ret->Location_getBearing))
+ return 0;
+ if (!android_find_method(ret->LocationClass, "getAltitude", "()D", &ret->Location_getAltitude))
+ return 0;
+ if (!android_find_method(ret->LocationClass, "getTime", "()J", &ret->Location_getTime))
+ return 0;
+ if (!android_find_method(ret->LocationClass, "getAccuracy", "()F", &ret->Location_getAccuracy))
+ return 0;
+ if (!android_find_class_global("org/navitproject/navit/NavitVehicle", &ret->NavitVehicleClass))
+ return 0;
+ dbg(lvl_debug,"at 3");
+ cid = (*jnienv)->GetMethodID(jnienv, ret->NavitVehicleClass, "<init>", "(Landroid/content/Context;III)V");
+ if (cid == NULL) {
+ dbg(lvl_error,"no method found");
+ return 0; /* exception thrown */
+ }
+ dbg(lvl_debug, "at 4 android_application=%p", android_application);
+ ret->NavitVehicle=(*jnienv)->NewObject(jnienv, ret->NavitVehicleClass, cid, android_application,
+ (int) ret->pcb, (int) ret->scb, (int) ret->fcb);
+ dbg(lvl_debug,"result=%p",ret->NavitVehicle);
+ if (!ret->NavitVehicle)
+ return 0;
+ if (ret->NavitVehicle)
+ ret->NavitVehicle = (*jnienv)->NewGlobalRef(jnienv, ret->NavitVehicle);
- return 1;
+ return 1;
}
/**
* @brief Create android_vehicle
- *
+ *
* @param meth
* @param cbl
* @param attrs
* @returns vehicle_priv
*/
-static struct vehicle_priv *
-vehicle_android_new_android(struct vehicle_methods *meth,
- struct callback_list *cbl,
- struct attr **attrs)
-{
- struct vehicle_priv *ret;
+static struct vehicle_priv *vehicle_android_new_android(struct vehicle_methods *meth,
+ struct callback_list *cbl,
+ struct attr **attrs) {
+ struct vehicle_priv *ret;
- dbg(lvl_debug, "enter\n");
- ret = g_new0(struct vehicle_priv, 1);
- ret->cbl = cbl;
- ret->pcb = callback_new_1(callback_cast(vehicle_android_position_callback), ret);
- ret->scb = callback_new_1(callback_cast(vehicle_android_status_callback), ret);
- ret->fcb = callback_new_1(callback_cast(vehicle_android_fix_callback), ret);
- ret->valid = attr_position_valid_invalid;
- ret->sats = 0;
- ret->sats_used = 0;
- *meth = vehicle_android_methods;
- vehicle_android_init(ret);
- dbg(lvl_debug, "return\n");
- return ret;
+ dbg(lvl_debug, "enter");
+ ret = g_new0(struct vehicle_priv, 1);
+ ret->cbl = cbl;
+ ret->pcb = callback_new_1(callback_cast(vehicle_android_position_callback), ret);
+ ret->scb = callback_new_1(callback_cast(vehicle_android_status_callback), ret);
+ ret->fcb = callback_new_1(callback_cast(vehicle_android_fix_callback), ret);
+ ret->valid = attr_position_valid_invalid;
+ ret->sats = 0;
+ ret->sats_used = 0;
+ *meth = vehicle_android_methods;
+ vehicle_android_init(ret);
+ dbg(lvl_debug, "return");
+ return ret;
}
/**
* @brief register vehicle_android
- *
+ *
* @returns nothing
*/
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("android", vehicle_android_new_android);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("android", vehicle_android_new_android);
}
+
+/** @} */
diff --git a/navit/vehicle/demo/vehicle_demo.c b/navit/vehicle/demo/vehicle_demo.c
index 4a47c1476..06ab2117a 100644
--- a/navit/vehicle/demo/vehicle_demo.c
+++ b/navit/vehicle/demo/vehicle_demo.c
@@ -1,4 +1,4 @@
-/**
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -34,271 +34,268 @@
#include "event.h"
#include "util.h"
+/**
+ * @defgroup vehicle-demo Vehicle Demo
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle for a demo. It followes the route automatically
+ *
+ */
+
struct vehicle_priv {
- int interval;
- int position_set;
- struct callback_list *cbl;
- struct navit *navit;
- struct route *route;
- struct coord_geo geo;
- struct coord last;
- double config_speed;
- double speed;
- double direction;
- struct callback *timer_callback;
- struct event_timeout *timer;
- char *timep;
- char *nmea;
- enum attr_position_valid valid; /**< Whether the vehicle has valid position data **/
+ int interval;
+ int position_set;
+ struct callback_list *cbl;
+ struct navit *navit;
+ struct route *route;
+ struct coord_geo geo;
+ struct coord last;
+ double config_speed;
+ double speed;
+ double direction;
+ struct callback *timer_callback;
+ struct event_timeout *timer;
+ char *timep;
+ char *nmea;
+ enum attr_position_valid valid; /**< Whether the vehicle has valid position data **/
};
-static void
-vehicle_demo_destroy(struct vehicle_priv *priv)
-{
- if (priv->timer)
- event_remove_timeout(priv->timer);
- callback_destroy(priv->timer_callback);
- g_free(priv->timep);
- g_free(priv);
+static void vehicle_demo_destroy(struct vehicle_priv *priv) {
+ if (priv->timer)
+ event_remove_timeout(priv->timer);
+ callback_destroy(priv->timer_callback);
+ g_free(priv->timep);
+ g_free(priv);
}
-static void
-nmea_chksum(char *nmea)
-{
- int i;
- if (nmea && strlen(nmea) > 3) {
- unsigned char csum=0;
- for (i = 1 ; i < strlen(nmea)-4 ; i++)
- csum^=(unsigned char)(nmea[i]);
- sprintf(nmea+strlen(nmea)-3,"%02X\n",csum);
- }
+static void nmea_chksum(char *nmea) {
+ int i;
+ if (nmea && strlen(nmea) > 3) {
+ unsigned char csum=0;
+ for (i = 1 ; i < strlen(nmea)-4 ; i++)
+ csum^=(unsigned char)(nmea[i]);
+ sprintf(nmea+strlen(nmea)-3,"%02X\n",csum);
+ }
}
-static int
-vehicle_demo_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- char ns='N',ew='E',*timep,*rmc,*gga;
- int hr,min,sec,year,mon,day;
- double lat,lng;
- switch (type) {
- case attr_position_speed:
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- attr->u.numd = &priv->direction;
- break;
- case attr_position_coord_geo:
- attr->u.coord_geo = &priv->geo;
- break;
- case attr_position_time_iso8601:
- g_free(priv->timep);
- priv->timep=current_to_iso8601();
- attr->u.str=priv->timep;
- break;
- case attr_position_fix_type:
- attr->u.num = 2;
- break;
- case attr_position_sats_used:
- attr->u.num = 9;
- break;
- case attr_position_nmea:
- lat=priv->geo.lat;
- if (lat < 0) {
- lat=-lat;
- ns='S';
- }
- lng=priv->geo.lng;
- if (lng < 0) {
- lng=-lng;
- ew='W';
- }
- timep=current_to_iso8601();
- sscanf(timep,"%d-%d-%dT%d:%d:%d",&year,&mon,&day,&hr,&min,&sec);
- g_free(timep);
- gga=g_strdup_printf("$GPGGA,%02d%02d%02d,%02.0f%07.4f,%c,%03.0f%07.4f,%c,1,08,2.5,0,M,,,,0000* \n",hr,min,sec,floor(lat),(lat-floor(lat))*60.0,ns,floor(lng),(lng-floor(lng))*60,ew);
- nmea_chksum(gga);
- rmc=g_strdup_printf("$GPRMC,%02d%02d%02d,A,%02.0f%07.4f,%c,%03.0f%07.4f,%c,%3.1f,%3.1f,%02d%02d%02d,,* \n",hr,min,sec,floor(lat),(lat-floor(lat))*60.0,ns,floor(lng),(lng-floor(lng))*60,ew,priv->speed/1.852,(double)priv->direction,day,mon,year%100);
- nmea_chksum(rmc);
- g_free(priv->nmea);
- priv->nmea=g_strdup_printf("%s%s",gga,rmc);
- g_free(gga);
- g_free(rmc);
- attr->u.str=priv->nmea;
- break;
- case attr_position_valid:
- attr->u.num=priv->valid;
- break;
- default:
- return 0;
- }
- attr->type = type;
- return 1;
+static int vehicle_demo_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ char ns='N',ew='E',*timep,*rmc,*gga;
+ int hr,min,sec,year,mon,day;
+ double lat,lng;
+ switch (type) {
+ case attr_position_speed:
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ attr->u.numd = &priv->direction;
+ break;
+ case attr_position_coord_geo:
+ attr->u.coord_geo = &priv->geo;
+ break;
+ case attr_position_time_iso8601:
+ g_free(priv->timep);
+ priv->timep=current_to_iso8601();
+ attr->u.str=priv->timep;
+ break;
+ case attr_position_fix_type:
+ attr->u.num = 2;
+ break;
+ case attr_position_sats_used:
+ attr->u.num = 9;
+ break;
+ case attr_position_nmea:
+ lat=priv->geo.lat;
+ if (lat < 0) {
+ lat=-lat;
+ ns='S';
+ }
+ lng=priv->geo.lng;
+ if (lng < 0) {
+ lng=-lng;
+ ew='W';
+ }
+ timep=current_to_iso8601();
+ sscanf(timep,"%d-%d-%dT%d:%d:%d",&year,&mon,&day,&hr,&min,&sec);
+ g_free(timep);
+ gga=g_strdup_printf("$GPGGA,%02d%02d%02d,%02.0f%07.4f,%c,%03.0f%07.4f,%c,1,08,2.5,0,M,,,,0000* \n",hr,min,sec,
+ floor(lat),(lat-floor(lat))*60.0,ns,floor(lng),(lng-floor(lng))*60,ew);
+ nmea_chksum(gga);
+ rmc=g_strdup_printf("$GPRMC,%02d%02d%02d,A,%02.0f%07.4f,%c,%03.0f%07.4f,%c,%3.1f,%3.1f,%02d%02d%02d,,* \n",hr,min,sec,
+ floor(lat),(lat-floor(lat))*60.0,ns,floor(lng),(lng-floor(lng))*60,ew,priv->speed/1.852,(double)priv->direction,day,mon,
+ year%100);
+ nmea_chksum(rmc);
+ g_free(priv->nmea);
+ priv->nmea=g_strdup_printf("%s%s",gga,rmc);
+ g_free(gga);
+ g_free(rmc);
+ attr->u.str=priv->nmea;
+ break;
+ case attr_position_valid:
+ attr->u.num=priv->valid;
+ break;
+ default:
+ return 0;
+ }
+ attr->type = type;
+ return 1;
}
-static int
-vehicle_demo_set_attr_do(struct vehicle_priv *priv, struct attr *attr)
-{
- switch(attr->type) {
- case attr_navit:
- priv->navit = attr->u.navit;
- break;
- case attr_route:
- priv->route = attr->u.route;
- break;
- case attr_speed:
- priv->config_speed=attr->u.num;
- break;
- case attr_interval:
- priv->interval=attr->u.num;
- if (priv->timer)
- event_remove_timeout(priv->timer);
- priv->timer=event_add_timeout(priv->interval, 1, priv->timer_callback);
- break;
- case attr_position_coord_geo:
- priv->geo=*(attr->u.coord_geo);
- if (priv->valid != attr_position_valid_valid) {
- priv->valid = attr_position_valid_valid;
- callback_list_call_attr_0(priv->cbl, attr_position_valid);
- }
- priv->position_set=1;
- dbg(lvl_debug,"position_set %f %f\n", priv->geo.lat, priv->geo.lng);
- break;
- case attr_profilename:
- case attr_source:
- case attr_name:
- case attr_follow:
- case attr_active:
- // Ignore; used by Navit's infrastructure, but not relevant for this vehicle.
- break;
- default:
- dbg(lvl_error,"unsupported attribute %s\n",attr_to_name(attr->type));
- return 0;
- }
- return 1;
+static int vehicle_demo_set_attr_do(struct vehicle_priv *priv, struct attr *attr) {
+ switch(attr->type) {
+ case attr_navit:
+ priv->navit = attr->u.navit;
+ break;
+ case attr_route:
+ priv->route = attr->u.route;
+ break;
+ case attr_speed:
+ priv->config_speed=attr->u.num;
+ break;
+ case attr_interval:
+ priv->interval=attr->u.num;
+ if (priv->timer)
+ event_remove_timeout(priv->timer);
+ priv->timer=event_add_timeout(priv->interval, 1, priv->timer_callback);
+ break;
+ case attr_position_coord_geo:
+ priv->geo=*(attr->u.coord_geo);
+ if (priv->valid != attr_position_valid_valid) {
+ priv->valid = attr_position_valid_valid;
+ callback_list_call_attr_0(priv->cbl, attr_position_valid);
+ }
+ priv->position_set=1;
+ dbg(lvl_debug,"position_set %f %f", priv->geo.lat, priv->geo.lng);
+ break;
+ case attr_profilename:
+ case attr_source:
+ case attr_name:
+ case attr_follow:
+ case attr_active:
+ // Ignore; used by Navit's infrastructure, but not relevant for this vehicle.
+ break;
+ default:
+ dbg(lvl_error,"unsupported attribute %s",attr_to_name(attr->type));
+ return 0;
+ }
+ return 1;
}
-static int
-vehicle_demo_set_attr(struct vehicle_priv *priv, struct attr *attr)
-{
- return vehicle_demo_set_attr_do(priv, attr);
+static int vehicle_demo_set_attr(struct vehicle_priv *priv, struct attr *attr) {
+ return vehicle_demo_set_attr_do(priv, attr);
}
struct vehicle_methods vehicle_demo_methods = {
- vehicle_demo_destroy,
- vehicle_demo_position_attr_get,
- vehicle_demo_set_attr,
+ vehicle_demo_destroy,
+ vehicle_demo_position_attr_get,
+ vehicle_demo_set_attr,
};
-static void
-vehicle_demo_timer(struct vehicle_priv *priv)
-{
- struct coord c, c2, pos, ci;
- int slen, len, dx, dy;
- struct route *route=NULL;
- struct map *route_map=NULL;
- struct map_rect *mr=NULL;
- struct item *item=NULL;
+static void vehicle_demo_timer(struct vehicle_priv *priv) {
+ struct coord c, c2, pos, ci;
+ int slen, len, dx, dy;
+ struct route *route=NULL;
+ struct map *route_map=NULL;
+ struct map_rect *mr=NULL;
+ struct item *item=NULL;
- len = (priv->config_speed * priv->interval / 1000)/ 3.6;
- dbg(lvl_debug, "###### Entering simulation loop\n");
- if (!priv->config_speed)
- return;
- if (priv->route)
- route=priv->route;
- else if (priv->navit)
- route=navit_get_route(priv->navit);
- if (route)
- route_map=route_get_map(route);
- if (route_map)
- mr=map_rect_new(route_map, NULL);
- if (mr)
- item=map_rect_get_item(mr);
- if (item && item->type == type_route_start)
- item=map_rect_get_item(mr);
- while(item && item->type!=type_street_route)
- item=map_rect_get_item(mr);
- if (item && item_coord_get(item, &pos, 1)) {
- priv->position_set=0;
- dbg(lvl_debug, "current pos=0x%x,0x%x\n", pos.x, pos.y);
- dbg(lvl_debug, "last pos=0x%x,0x%x\n", priv->last.x, priv->last.y);
- if (priv->last.x == pos.x && priv->last.y == pos.y) {
- dbg(lvl_warning, "endless loop\n");
- }
- priv->last = pos;
- while (item && priv->config_speed) {
- if (!item_coord_get(item, &c, 1)) {
- item=map_rect_get_item(mr);
- continue;
- }
- dbg(lvl_debug, "next pos=0x%x,0x%x\n", c.x, c.y);
- slen = transform_distance(projection_mg, &pos, &c);
- dbg(lvl_debug, "len=%d slen=%d\n", len, slen);
- if (slen < len) {
- len -= slen;
- pos = c;
- } else {
- if (item_coord_get(item, &c2, 1) || map_rect_get_item(mr)) {
- dx = c.x - pos.x;
- dy = c.y - pos.y;
- ci.x = pos.x + dx * len / slen;
- ci.y = pos.y + dy * len / slen;
- priv->direction =
- transform_get_angle_delta(&pos, &c, 0);
- priv->speed=priv->config_speed;
- } else {
- ci.x = pos.x;
- ci.y = pos.y;
- priv->speed=0;
- dbg(lvl_debug,"destination reached\n");
- }
- dbg(lvl_debug, "ci=0x%x,0x%x\n", ci.x, ci.y);
- transform_to_geo(projection_mg, &ci,
- &priv->geo);
- if (priv->valid != attr_position_valid_valid) {
- priv->valid = attr_position_valid_valid;
- callback_list_call_attr_0(priv->cbl, attr_position_valid);
- }
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
- break;
- }
- }
- } else {
- if (priv->position_set)
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
- }
- if (mr)
- map_rect_destroy(mr);
+ len = (priv->config_speed * priv->interval / 1000)/ 3.6;
+ dbg(lvl_debug, "###### Entering simulation loop");
+ if (!priv->config_speed)
+ return;
+ if (priv->route)
+ route=priv->route;
+ else if (priv->navit)
+ route=navit_get_route(priv->navit);
+ if (route)
+ route_map=route_get_map(route);
+ if (route_map)
+ mr=map_rect_new(route_map, NULL);
+ if (mr)
+ item=map_rect_get_item(mr);
+ if (item && item->type == type_route_start)
+ item=map_rect_get_item(mr);
+ while(item && item->type!=type_street_route)
+ item=map_rect_get_item(mr);
+ if (item && item_coord_get(item, &pos, 1)) {
+ priv->position_set=0;
+ dbg(lvl_debug, "current pos=0x%x,0x%x", pos.x, pos.y);
+ dbg(lvl_debug, "last pos=0x%x,0x%x", priv->last.x, priv->last.y);
+ if (priv->last.x == pos.x && priv->last.y == pos.y) {
+ dbg(lvl_warning, "endless loop");
+ }
+ priv->last = pos;
+ while (item && priv->config_speed) {
+ if (!item_coord_get(item, &c, 1)) {
+ item=map_rect_get_item(mr);
+ continue;
+ }
+ dbg(lvl_debug, "next pos=0x%x,0x%x", c.x, c.y);
+ slen = transform_distance(projection_mg, &pos, &c);
+ dbg(lvl_debug, "len=%d slen=%d", len, slen);
+ if (slen < len) {
+ len -= slen;
+ pos = c;
+ } else {
+ if (item_coord_get(item, &c2, 1) || map_rect_get_item(mr)) {
+ dx = c.x - pos.x;
+ dy = c.y - pos.y;
+ ci.x = pos.x + dx * len / slen;
+ ci.y = pos.y + dy * len / slen;
+ priv->direction =
+ transform_get_angle_delta(&pos, &c, 0);
+ priv->speed=priv->config_speed;
+ } else {
+ ci.x = pos.x;
+ ci.y = pos.y;
+ priv->speed=0;
+ dbg(lvl_debug,"destination reached");
+ }
+ dbg(lvl_debug, "ci=0x%x,0x%x", ci.x, ci.y);
+ transform_to_geo(projection_mg, &ci,
+ &priv->geo);
+ if (priv->valid != attr_position_valid_valid) {
+ priv->valid = attr_position_valid_valid;
+ callback_list_call_attr_0(priv->cbl, attr_position_valid);
+ }
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+ break;
+ }
+ }
+ } else {
+ if (priv->position_set)
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+ }
+ if (mr)
+ map_rect_destroy(mr);
}
-static struct vehicle_priv *
-vehicle_demo_new(struct vehicle_methods
- *meth, struct callback_list
- *cbl, struct attr **attrs)
-{
- struct vehicle_priv *ret;
+static struct vehicle_priv *vehicle_demo_new(struct vehicle_methods
+ *meth, struct callback_list
+ *cbl, struct attr **attrs) {
+ struct vehicle_priv *ret;
- dbg(lvl_debug, "enter\n");
- ret = g_new0(struct vehicle_priv, 1);
- ret->cbl = cbl;
- ret->interval=1000;
- ret->config_speed=40;
- ret->timer_callback=callback_new_1(callback_cast(vehicle_demo_timer), ret);
- ret->valid = attr_position_valid_invalid;
- *meth = vehicle_demo_methods;
- while (attrs && *attrs)
- vehicle_demo_set_attr_do(ret, *attrs++);
- if (!ret->timer)
- ret->timer=event_add_timeout(ret->interval, 1, ret->timer_callback);
- return ret;
+ dbg(lvl_debug, "enter");
+ ret = g_new0(struct vehicle_priv, 1);
+ ret->cbl = cbl;
+ ret->interval=1000;
+ ret->config_speed=40;
+ ret->timer_callback=callback_new_1(callback_cast(vehicle_demo_timer), ret);
+ ret->valid = attr_position_valid_invalid;
+ *meth = vehicle_demo_methods;
+ while (attrs && *attrs)
+ vehicle_demo_set_attr_do(ret, *attrs++);
+ if (!ret->timer)
+ ret->timer=event_add_timeout(ret->interval, 1, ret->timer_callback);
+ return ret;
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("demo", vehicle_demo_new);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("demo", vehicle_demo_new);
}
+
+
+/** @} */
diff --git a/navit/vehicle/file/vehicle_file.c b/navit/vehicle/file/vehicle_file.c
index 10bce942b..807d4998d 100644
--- a/navit/vehicle/file/vehicle_file.c
+++ b/navit/vehicle/file/vehicle_file.c
@@ -1,4 +1,4 @@
-/**
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -28,7 +28,7 @@
#include <glib.h>
#include <sys/stat.h>
#ifdef _WIN32
- #include <serial_io.h>
+#include <serial_io.h>
#else
#include <termios.h>
#endif
@@ -51,14 +51,21 @@
#include <winsock2.h>
int inet_aton(const char *cp, struct in_addr *inp);
-int inet_aton(const char *cp, struct in_addr *inp)
-{
- unsigned long addr = inet_addr(cp);
- inp->S_un.S_addr = addr;
- return addr!=-1;
+int inet_aton(const char *cp, struct in_addr *inp) {
+ unsigned long addr = inet_addr(cp);
+ inp->S_un.S_addr = addr;
+ return addr!=-1;
}
#endif
+/**
+ * @defgroup vehicle-file Vehicle File
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from a file, pipe, serial interface or a socket
+ *
+ * @{
+ */
+
static void vehicle_file_disable_watch(struct vehicle_priv *priv);
static void vehicle_file_enable_watch(struct vehicle_priv *priv);
static int vehicle_file_parse(struct vehicle_priv *priv, char *buffer);
@@ -67,91 +74,87 @@ static void vehicle_file_close(struct vehicle_priv *priv);
enum file_type {
- file_type_pipe = 1, file_type_device, file_type_file, file_type_socket, file_type_serial
+ file_type_pipe = 1, file_type_device, file_type_file, file_type_socket, file_type_serial
};
static int buffer_size = 1024;
struct gps_sat {
- int prn;
- int elevation;
- int azimuth;
- int snr;
+ int prn;
+ int elevation;
+ int azimuth;
+ int snr;
};
struct vehicle_priv {
- char *source;
- struct callback_list *cbl;
- int fd;
- struct callback *cb,*cbt;
- char *buffer;
- int buffer_pos;
- char *nmea_data;
- char *nmea_data_buf;
-
- struct coord_geo geo;
- double speed;
- double direction;
- double height;
- double hdop;
- double vdop;
- char fixtime[20];
- int fixyear;
- int fixmonth;
- int fixday;
- int status;
- int sats_used;
- int sats_visible;
- int sats_signal;
- int time;
- int on_eof;
+ char *source;
+ struct callback_list *cbl;
+ int fd;
+ struct callback *cb,*cbt,*cb_fix_timeout;
+ char *buffer;
+ int buffer_pos;
+ char *nmea_data;
+ char *nmea_data_buf;
+
+ struct coord_geo geo;
+ double speed;
+ double direction;
+ double height;
+ double hdop;
+ double vdop;
+ char fixtime[20];
+ int fixyear;
+ int fixmonth;
+ int fixday;
+ int status;
+ int sats_used;
+ int sats_visible;
+ int sats_signal;
+ int time;
+ int on_eof;
#ifdef _WIN32
- int no_data_count;
- struct event_timeout * timeout;
- struct callback *timeout_callback;
+ int no_data_count;
+ struct event_timeout * timeout;
+ struct callback *timeout_callback;
#endif
- enum file_type file_type;
- FILE *file;
- struct event_watch *watch;
- speed_t baudrate;
- struct attr ** attrs;
- char fixiso8601[128];
- int checksum_ignore;
- int magnetic_direction;
- int current_count;
- struct gps_sat current[24];
- int next_count;
- struct gps_sat next[24];
- struct item sat_item;
- int valid;
- char *statefile;
- int process_statefile;
+ enum file_type file_type;
+ FILE *file;
+ struct event_watch *watch;
+ struct event_timeout *ev_fix_timeout;
+ speed_t baudrate;
+ struct attr ** attrs;
+ char fixiso8601[128];
+ int checksum_ignore;
+ int magnetic_direction;
+ int current_count;
+ struct gps_sat current[24];
+ int next_count;
+ struct gps_sat next[24];
+ struct item sat_item;
+ int valid;
+ char *statefile;
+ int process_statefile;
};
-//***************************************************************************
-/** @fn static int vehicle_win32_serial_track(struct vehicle_priv *priv)
-*****************************************************************************
-* @b Description: Callback of the plugin
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-*****************************************************************************
-* @return always 1
-*****************************************************************************
-**/
+/**
+* @brief Callback of the plugin
+*
+* @param priv Pointer on the private data of the plugin
+*
+* @return Always 1
+*/
#ifdef _WIN32
-static int vehicle_win32_serial_track(struct vehicle_priv *priv)
-{
+static int vehicle_win32_serial_track(struct vehicle_priv *priv) {
static char buffer[2048] = {0,};
static int current_index = 0;
const int chunk_size = 1024;
int rc = 0;
int dwBytes;
- dbg(lvl_debug, "enter, *priv='%x', priv->source='%s'\n", priv, priv->source);
+ dbg(lvl_debug, "enter, *priv='%x', priv->source='%s'", priv, priv->source);
- if ( priv->no_data_count > 5 )
- {
+ if ( priv->no_data_count > 5 ) {
vehicle_file_close( priv );
priv->no_data_count = 0;
vehicle_file_open( priv );
@@ -163,21 +166,18 @@ static int vehicle_win32_serial_track(struct vehicle_priv *priv)
// vehicle_file_open( priv );
//}
- if ( current_index >= ( sizeof( buffer ) - chunk_size ) )
- {
+ if ( current_index >= ( sizeof( buffer ) - chunk_size ) ) {
// discard
current_index = 0;
- memset( buffer, 0 , sizeof( buffer ) );
+ memset( buffer, 0, sizeof( buffer ) );
}
dwBytes = serial_io_read( priv->fd, &buffer[ current_index ], chunk_size );
- if ( dwBytes > 0 )
- {
+ if ( dwBytes > 0 ) {
char* return_pos = NULL;
current_index += dwBytes;
- while ( ( return_pos = strchr( buffer, '\n' ) ) != NULL )
- {
+ while ( ( return_pos = strchr( buffer, '\n' ) ) != NULL ) {
char return_buffer[1024];
int bytes_to_copy = return_pos - buffer + 1;
memcpy( return_buffer, buffer, bytes_to_copy );
@@ -188,867 +188,862 @@ static int vehicle_win32_serial_track(struct vehicle_priv *priv)
rc += vehicle_file_parse( priv, return_buffer );
current_index -= bytes_to_copy;
- memmove( buffer, &buffer[ bytes_to_copy ] , sizeof( buffer ) - bytes_to_copy );
+ memmove( buffer, &buffer[ bytes_to_copy ], sizeof( buffer ) - bytes_to_copy );
}
if (rc) {
priv->no_data_count = 0;
callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
if (rc > 1)
- dbg(lvl_error, "Can not keep with gps data delay is %d seconds\n", rc - 1);
+ dbg(lvl_error, "Can not keep with gps data delay is %d seconds", rc - 1);
}
- }
- else
- {
+ } else {
priv->no_data_count++;
}
- dbg(lvl_info, "leave, return '1', priv->no_data_count='%d'\n", priv->no_data_count);
+ dbg(lvl_info, "leave, return '1', priv->no_data_count='%d'", priv->no_data_count);
return 1;
}
#endif
-//***************************************************************************
-/** @fn static int vehicle_file_open(struct vehicle_priv *priv)
-*****************************************************************************
-* @b Description: open dialogue with the GPS
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-*****************************************************************************
-* @return 1 if ok
-* 0 if error
-*****************************************************************************
-**/
-static int
-vehicle_file_open(struct vehicle_priv *priv)
-{
- char *name;
+/**
+* @brief Open dialogue with the GPS
+*
+* @param priv Pointer on the private data of the plugin
+*
+* @return 1 if ok, 0 if error
+*/
+static int vehicle_file_open(struct vehicle_priv *priv) {
+ char *name;
#ifndef _WIN32
- struct termios tio;
+ struct termios tio;
#else
- #define O_NDELAY 0
+#define O_NDELAY 0
#endif
- name = priv->source + 5;
- if (!strncmp(priv->source, "file:", 5)) {
- priv->fd = open(name, O_RDONLY | O_NDELAY);
- if (priv->fd < 0)
- return 0;
- if (file_is_reg(name)) {
- priv->file_type = file_type_file;
- }
+ name = priv->source + 5;
+ if (!strncmp(priv->source, "file:", 5)) {
+ priv->fd = open(name, O_RDONLY | O_NDELAY);
+ if (priv->fd < 0)
+ return 0;
+ if (file_is_reg(name)) {
+ priv->file_type = file_type_file;
+ }
#ifndef _WIN32
- else {
- tcgetattr(priv->fd, &tio);
- cfmakeraw(&tio);
- cfsetispeed(&tio, priv->baudrate);
- cfsetospeed(&tio, priv->baudrate);
- tio.c_cc[VMIN] = 0;
- tio.c_cc[VTIME] = 200;
- tcsetattr(priv->fd, TCSANOW, &tio);
- priv->file_type = file_type_device;
- }
- } else if (!strncmp(priv->source,"pipe:", 5)) {
- priv->file = popen(name, "r");
- if (!priv->file)
- return 0;
- priv->fd = fileno(priv->file);
- priv->file_type = file_type_pipe;
+ else {
+ tcgetattr(priv->fd, &tio);
+ cfmakeraw(&tio);
+ cfsetispeed(&tio, priv->baudrate);
+ cfsetospeed(&tio, priv->baudrate);
+ tio.c_cc[VMIN] = 0;
+ tio.c_cc[VTIME] = 200;
+ tcsetattr(priv->fd, TCSANOW, &tio);
+ priv->file_type = file_type_device;
+ }
+ } else if (!strncmp(priv->source,"pipe:", 5)) {
+ priv->file = popen(name, "r");
+ if (!priv->file)
+ return 0;
+ priv->fd = fileno(priv->file);
+ priv->file_type = file_type_pipe;
#endif //!_WIN32
-#if defined(HAVE_SOCKET) || defined(HAVE_WINSOCK)
- } else if (!strncmp(priv->source,"socket:", 7)) {
- #ifdef _WIN32
- WSADATA wsi;
- WSAStartup(0x00020002,&wsi);
- #endif
- char *p,*s=g_strdup(priv->source+7);
- struct sockaddr_in sin;
- p=strchr(s,':');
- if (!p) {
- dbg(lvl_error,"port number missing in %s\n",s);
- g_free(s);
- return 0;
- }
- *p++='\0';
- sin.sin_family=AF_INET;
- sin.sin_port=ntohs(atoi(p));
- if (!inet_aton(s, &sin.sin_addr)) {
- dbg(lvl_error,"failed to parse %s\n",s);
- g_free(s);
- return 0;
- }
- priv->fd = socket(PF_INET, SOCK_STREAM, 0);
- if (priv->fd != -1) {
- if (connect(priv->fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
- dbg(lvl_error,"failed to connect to %s:%s\n",s,p);
- g_free(s);
- return 0;
- }
- }
- p=strchr(p,':');
- if (p) {
- p++;
- write(priv->fd, p, strlen(p));
- }
- priv->file_type = file_type_socket;
+#if defined(HAVE_SOCKET) || defined(HAVE_WINSOCK)
+ } else if (!strncmp(priv->source,"socket:", 7)) {
+#ifdef _WIN32
+ WSADATA wsi;
+ WSAStartup(0x00020002,&wsi);
+#endif
+ char *p,*s=g_strdup(priv->source+7);
+ struct sockaddr_in sin;
+ p=strchr(s,':');
+ if (!p) {
+ dbg(lvl_error,"port number missing in %s",s);
+ g_free(s);
+ return 0;
+ }
+ *p++='\0';
+ sin.sin_family=AF_INET;
+ sin.sin_port=ntohs(atoi(p));
+ if (!inet_aton(s, &sin.sin_addr)) {
+ dbg(lvl_error,"failed to parse %s",s);
+ g_free(s);
+ return 0;
+ }
+ priv->fd = socket(PF_INET, SOCK_STREAM, 0);
+ if (priv->fd != -1) {
+ if (connect(priv->fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
+ dbg(lvl_error,"failed to connect to %s:%s",s,p);
+ g_free(s);
+ return 0;
+ }
+ }
+ p=strchr(p,':');
+ if (p) {
+ p++;
+ int write_result;
+ write_result = write(priv->fd, p, strlen(p));
+ if (write_result == -1) {
+ dbg(lvl_warning, "write failed.");
+ }
+ }
+ priv->file_type = file_type_socket;
#endif //HAVE_SOCKET
- } else if (!strncmp(priv->source,"serial:",7)) {
+ } else if (!strncmp(priv->source,"serial:",7)) {
#ifdef _WIN32
- char* raw_setting_str = g_strdup( priv->source );
-
- char* strport = strchr(raw_setting_str, ':' );
- char* strsettings = strchr(raw_setting_str, ' ' );
-
- if ( strport && strsettings )
- {
- strport++;
- *strsettings = '\0';
- strsettings++;
-
- priv->fd=serial_io_init( strport, strsettings );
- }
- g_free( raw_setting_str );
- priv->file_type = file_type_serial;
- // Add the callback
- dbg(lvl_info, "Add the callback ...\n", priv->source);
- priv->timeout_callback=callback_new_1(callback_cast(vehicle_win32_serial_track), priv);
+ char* raw_setting_str = g_strdup( priv->source );
+
+ char* strport = strchr(raw_setting_str, ':' );
+ char* strsettings = strchr(raw_setting_str, ' ' );
+
+ if ( strport && strsettings ) {
+ strport++;
+ *strsettings = '\0';
+ strsettings++;
+
+ priv->fd=serial_io_init( strport, strsettings );
+ }
+ g_free( raw_setting_str );
+ priv->file_type = file_type_serial;
+ // Add the callback
+ dbg(lvl_info, "Add the callback ...", priv->source);
+ priv->timeout_callback=callback_new_1(callback_cast(vehicle_win32_serial_track), priv);
#else
- //TODO - add linux serial
+ //TODO - add linux serial
#endif //!_WIN32
}
return(priv->fd != -1);
}
-//***************************************************************************
-/** @fn static void vehicle_file_close(struct vehicle_priv *priv)
-*****************************************************************************
-* @b Description: close dialogue with the GPS
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-*****************************************************************************
-**/
-static void
-vehicle_file_close(struct vehicle_priv *priv)
-{
- dbg(lvl_debug, "enter, priv->fd='%d'\n", priv->fd);
- vehicle_file_disable_watch(priv);
+/**
+* @brief Close dialogue with the GPS
+*
+* @param priv Pointer on the private data of the plugin
+*/
+static void vehicle_file_close(struct vehicle_priv *priv) {
+ dbg(lvl_debug, "enter, priv->fd='%d'", priv->fd);
+ vehicle_file_disable_watch(priv);
#ifdef _WIN32
- if(priv->file_type == file_type_serial)
- {
+ if(priv->file_type == file_type_serial) {
if (priv->timeout_callback) {
- callback_destroy(priv->timeout_callback);
- priv->timeout_callback=NULL; // dangling pointer! prevent double freeing.
+ callback_destroy(priv->timeout_callback);
+ priv->timeout_callback=NULL; // dangling pointer! prevent double freeing.
}
- serial_io_shutdown( priv->fd );
- }
- else
+ serial_io_shutdown( priv->fd );
+ } else
#endif
{
- if (priv->file) {
+ if (priv->file) {
#ifndef _MSC_VER
- pclose(priv->file);
+ pclose(priv->file);
#endif /* _MSC_VER */
+ } else if (priv->fd >= 0) {
+ close(priv->fd);
+ }
+ priv->file = NULL;
+ priv->fd = -1;
}
- else if (priv->fd >= 0) {
- close(priv->fd);
- }
- priv->file = NULL;
- priv->fd = -1;
- }
}
-//***************************************************************************
-/** @fn static int vehicle_file_enable_watch_timer(struct vehicle_priv *priv)
-*****************************************************************************
-* @b Description: Enable watch timer to get GPS data
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-*****************************************************************************
-* @return always 0
-*****************************************************************************
-**/
-static int
-vehicle_file_enable_watch_timer(struct vehicle_priv *priv)
-{
- dbg(lvl_debug, "enter\n");
- vehicle_file_enable_watch(priv);
-
- return FALSE;
+/**
+* @brief Enable watch timer to get GPS data
+*
+* @param priv Pointer on the private data of the plugin
+*
+* @return Always 0
+*/
+static int vehicle_file_enable_watch_timer(struct vehicle_priv *priv) {
+ dbg(lvl_debug, "enter");
+ vehicle_file_enable_watch(priv);
+
+ return FALSE;
+}
+
+
+/**
+* @brief This is a callback function, called when the fix timeout
+* is done. Set the position to invalid.
+*
+* @param priv Pointer on the private data of the plugin
+*/
+static void vehicle_file_fix_timeout_cb(struct vehicle_priv *priv) {
+ priv->valid = attr_position_valid_invalid;
+ priv->ev_fix_timeout = NULL;
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
}
-//***************************************************************************
-/** @fn static int vehicle_file_parse( struct vehicle_priv *priv,
-* char *buffer)
-*****************************************************************************
-* @b Description: Parse the buffer
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-* @param buffer : data buffer (null terminated)
-*****************************************************************************
-* @return 1 if The GPRMC Sentence is found
-* 0 if not found
-*****************************************************************************
-**/
-static int
-vehicle_file_parse(struct vehicle_priv *priv, char *buffer)
-{
- char *nmea_data_buf, *p, *item[32];
- double lat, lng;
- int i, j, bcsum;
- int len = strlen(buffer);
- unsigned char csum = 0;
- int valid=0;
- int ret = 0;
-
- dbg(lvl_info, "enter: buffer='%s'\n", buffer);
- for (;;) {
- if (len < 4) {
- dbg(lvl_error, "'%s' too short\n", buffer);
- return ret;
- }
- if (buffer[len - 1] == '\r' || buffer[len - 1] == '\n') {
- buffer[--len] = '\0';
+/**
+* @brief Cancel previous fix timeout event and add a new one
+*
+* @param priv Pointer on the private data of the plugin
+*/
+static void vehicle_file_restart_fix_timeout(struct vehicle_priv *priv) {
+ if (priv->ev_fix_timeout != NULL)
+ event_remove_timeout(priv->ev_fix_timeout);
+ priv->ev_fix_timeout = event_add_timeout(10000, 0, priv->cb_fix_timeout);
+}
+
+
+/**
+* @brief Parse the buffer
+*
+* @param priv Pointer on the private data of the plugin
+* @param buffer Data buffer (null terminated)
+*
+* @return 1 if new coords were received (fixtime changed) or changed to invalid,
+* 0 if not found
+*/
+static int vehicle_file_parse(struct vehicle_priv *priv, char *buffer) {
+ char *nmea_data_buf, *p, *item[32];
+ double lat, lng;
+ int i, j, bcsum;
+ int len = strlen(buffer);
+ unsigned char csum = 0;
+ int valid=0;
+ int ret = 0;
+
+ dbg(lvl_info, "enter: buffer='%s'", buffer);
+ for (;;) {
+ if (len < 4) {
+ dbg(lvl_error, "'%s' too short", buffer);
+ return ret;
+ }
+ if (buffer[len - 1] == '\r' || buffer[len - 1] == '\n') {
+ buffer[--len] = '\0';
if (buffer[len - 1] == '\r')
buffer[--len] = '\0';
} else
- break;
- }
- if (buffer[0] != '$') {
- dbg(lvl_error, "no leading $ in '%s'\n", buffer);
- return ret;
- }
- if (buffer[len - 3] != '*') {
- dbg(lvl_error, "no *XX in '%s'\n", buffer);
- return ret;
- }
- for (i = 1; i < len - 3; i++) {
- csum ^= (unsigned char) (buffer[i]);
- }
- if (!sscanf(buffer + len - 2, "%x", &bcsum) && priv->checksum_ignore != 2) {
- dbg(lvl_error, "no checksum in '%s'\n", buffer);
- return ret;
- }
- if (bcsum != csum && priv->checksum_ignore == 0) {
- dbg(lvl_error, "wrong checksum in '%s was %x should be %x'\n", buffer,bcsum,csum);
- return ret;
- }
-
- if (!priv->nmea_data_buf || strlen(priv->nmea_data_buf) < 65536) {
- nmea_data_buf=g_strconcat(priv->nmea_data_buf ? priv->nmea_data_buf : "", buffer, "\n", NULL);
- g_free(priv->nmea_data_buf);
- priv->nmea_data_buf=nmea_data_buf;
- } else {
- dbg(lvl_error, "nmea buffer overflow (len %zu), discarding '%s'\n", priv->nmea_data_buf?strlen(priv->nmea_data_buf):-1,buffer);
- }
- i = 0;
- p = buffer;
- while (i < 31) {
- item[i++] = p;
- while (*p && *p != ',')
- p++;
- if (!*p)
- break;
- *p++ = '\0';
- }
-
- if (!strncmp(&buffer[3], "GGA", 3)) {
- /* 1 1111
- 0 1 2 3 4 5 6 7 8 9 0 1234
- $GPGGA,184424.505,4924.2811,N,01107.8846,E,1,05,2.5,408.6,M,,,,0000*0C
- UTC of Fix[1],Latitude[2],N/S[3],Longitude[4],E/W[5],Quality(0=inv,1=gps,2=dgps)[6],Satelites used[7],
- HDOP[8],Altitude[9],"M"[10],height of geoid[11], "M"[12], time since dgps update[13], dgps ref station [14]
- */
- if (*item[2] && *item[3] && *item[4] && *item[5]) {
- lat = g_ascii_strtod(item[2], NULL);
- priv->geo.lat = floor(lat / 100);
- lat -= priv->geo.lat * 100;
- priv->geo.lat += lat / 60;
-
- if (!g_ascii_strcasecmp(item[3],"S"))
- priv->geo.lat=-priv->geo.lat;
-
- lng = g_ascii_strtod(item[4], NULL);
- priv->geo.lng = floor(lng / 100);
- lng -= priv->geo.lng * 100;
- priv->geo.lng += lng / 60;
-
- if (!g_ascii_strcasecmp(item[5],"W"))
- priv->geo.lng=-priv->geo.lng;
- priv->valid=attr_position_valid_valid;
-
- dbg(lvl_info, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng);
-
- } else
- priv->valid=attr_position_valid_invalid;
- if (*item[6])
- sscanf(item[6], "%d", &priv->status);
- if (*item[7])
- sscanf(item[7], "%d", &priv->sats_used);
- if (*item[8])
- sscanf(item[8], "%lf", &priv->hdop);
- if (*item[1])
- strncpy(priv->fixtime, item[1], sizeof(priv->fixtime));
- if (*item[9])
- sscanf(item[9], "%lf", &priv->height);
-
- g_free(priv->nmea_data);
- priv->nmea_data=priv->nmea_data_buf;
- priv->nmea_data_buf=NULL;
- if (priv->file_type == file_type_file) {
- if (priv->watch) {
- vehicle_file_disable_watch(priv);
- event_add_timeout(priv->time, 0, priv->cbt);
- }
- }
- }
- if (!strncmp(&buffer[3], "VTG", 3)) {
- /* 0 1 2 34 5 6 7 8
- $GPVTG,143.58,T,,M,0.26,N,0.5,K*6A
- Course Over Ground Degrees True[1],"T"[2],Course Over Ground Degrees Magnetic[3],"M"[4],
- Speed in Knots[5],"N"[6],"Speed in KM/H"[7],"K"[8]
- */
- if (item[1] && item[7])
- valid = 1;
- if (i >= 10 && (*item[9] == 'A' || *item[9] == 'D'))
- valid = 1;
- if (valid) {
- priv->direction = g_ascii_strtod( item[1], NULL );
- priv->speed = g_ascii_strtod( item[7], NULL );
- dbg(lvl_info,"direction %lf, speed %2.1lf\n", priv->direction, priv->speed);
- }
- }
- if (!strncmp(&buffer[3], "RMC", 3)) {
- /* 1 1
- 0 1 2 3 4 5 6 7 8 9 0 1
- $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
- Time[1],Active/Void[2],lat[3],N/S[4],long[5],W/E[6],speed in knots[7],track angle[8],date[9],
- magnetic variation[10],magnetic variation direction[11]
- */
- if (*item[2] == 'A')
- valid = 1;
- if (i >= 13 && (*item[12] == 'A' || *item[12] == 'D'))
- valid = 1;
- if (valid) {
- priv->direction = g_ascii_strtod( item[8], NULL );
- priv->speed = g_ascii_strtod( item[7], NULL );
- priv->speed *= 1.852;
- sscanf(item[9], "%02d%02d%02d",
- &priv->fixday,
- &priv->fixmonth,
- &priv->fixyear);
- priv->fixyear += 2000;
- }
- ret = 1;
- }
- if (!strncmp(buffer, "$GPGSV", 6) && i >= 4) {
- /*
- 0 GSV Satellites in view
- 1 2 Number of sentences for full data
- 2 1 sentence 1 of 2
- 3 08 Number of satellites in view
-
- 4 01 Satellite PRN number
- 5 40 Elevation, degrees
- 6 083 Azimuth, degrees
- 7 46 SNR - higher is better
- for up to 4 satellites per sentence
- *75 the checksum data, always begins with *
- */
- if (item[3]) {
- sscanf(item[3], "%d", &priv->sats_visible);
- }
- j=4;
- while (j+4 <= i && priv->current_count < 24) {
- struct gps_sat *sat=&priv->next[priv->next_count++];
- sat->prn=atoi(item[j]);
- sat->elevation=atoi(item[j+1]);
- sat->azimuth=atoi(item[j+2]);
- sat->snr=atoi(item[j+3]);
- j+=4;
- }
- if (!strcmp(item[1], item[2])) {
- priv->sats_signal=0;
- for (i = 0 ; i < priv->next_count ; i++) {
- priv->current[i]=priv->next[i];
- if (priv->current[i].snr)
- priv->sats_signal++;
- }
- priv->current_count=priv->next_count;
- priv->next_count=0;
- }
- }
- if (!strncmp(&buffer[3], "ZDA", 3)) {
- /*
- 0 1 2 3 4 5 6
- $GPZDA,hhmmss.ss,dd,mm,yyyy,xx,yy*CC
- hhmmss HrMinSec(UTC)
- dd,mm,yyy Day,Month,Year
- xx local zone hours -13..13
- yy local zone minutes 0..59
- */
- if (item[1] && item[2] && item[3] && item[4]) {
- strncpy(priv->fixtime, item[1], strlen(priv->fixtime));
- priv->fixday = atoi(item[2]);
- priv->fixmonth = atoi(item[3]);
- priv->fixyear = atoi(item[4]);
- }
- }
- if (!strncmp(buffer, "$IISMD", 6)) {
- /*
- 0 1 2 3 4
- $IISMD,dir,press,height,temp*CC"
- dir Direction (0-359)
- press Pressure (hpa, i.e. 1032)
- height Barometric height above ground (meter)
- temp Temperature (Degree Celsius)
- */
- if (item[1]) {
- priv->magnetic_direction = g_ascii_strtod( item[1], NULL );
- dbg(lvl_debug,"magnetic %d\n", priv->magnetic_direction);
- }
- }
- return ret;
+ break;
+ }
+ if (buffer[0] != '$') {
+ dbg(lvl_error, "no leading $ in '%s'", buffer);
+ return ret;
+ }
+ if (buffer[len - 3] != '*') {
+ dbg(lvl_error, "no *XX in '%s'", buffer);
+ return ret;
+ }
+ for (i = 1; i < len - 3; i++) {
+ csum ^= (unsigned char) (buffer[i]);
+ }
+ if (!sscanf(buffer + len - 2, "%x", &bcsum) && priv->checksum_ignore != 2) {
+ dbg(lvl_error, "no checksum in '%s'", buffer);
+ return ret;
+ }
+ if (bcsum != csum && priv->checksum_ignore == 0) {
+ dbg(lvl_error, "wrong checksum in '%s was %x should be %x'", buffer,bcsum,csum);
+ return ret;
+ }
+
+ if (!priv->nmea_data_buf || strlen(priv->nmea_data_buf) < 65536) {
+ nmea_data_buf=g_strconcat(priv->nmea_data_buf ? priv->nmea_data_buf : "", buffer, "\n", NULL);
+ g_free(priv->nmea_data_buf);
+ priv->nmea_data_buf=nmea_data_buf;
+ } else {
+ dbg(lvl_error, "nmea buffer overflow (len %zu), discarding '%s'", priv->nmea_data_buf?strlen(priv->nmea_data_buf):-1,
+ buffer);
+ }
+ i = 0;
+ p = buffer;
+ while (i < 31) {
+ item[i++] = p;
+ while (*p && *p != ',')
+ p++;
+ if (!*p)
+ break;
+ *p++ = '\0';
+ }
+
+ if (!strncmp(&buffer[3], "GGA", 3)) {
+ /* 1 1111
+ 0 1 2 3 4 5 6 7 8 9 0 1234
+ $GPGGA,184424.505,4924.2811,N,01107.8846,E,1,05,2.5,408.6,M,,,,0000*0C
+ UTC of Fix[1],Latitude[2],N/S[3],Longitude[4],E/W[5],Quality(0=inv,1=gps,2=dgps)[6],Satelites used[7],
+ HDOP[8],Altitude[9],"M"[10],height of geoid[11], "M"[12], time since dgps update[13], dgps ref station [14]
+ */
+ if (*item[2] && *item[3] && *item[4] && *item[5] && *item[6] > 0) {
+ lat = g_ascii_strtod(item[2], NULL);
+ priv->geo.lat = floor(lat / 100);
+ lat -= priv->geo.lat * 100;
+ priv->geo.lat += lat / 60;
+
+ if (!g_ascii_strcasecmp(item[3],"S"))
+ priv->geo.lat=-priv->geo.lat;
+
+ lng = g_ascii_strtod(item[4], NULL);
+ priv->geo.lng = floor(lng / 100);
+ lng -= priv->geo.lng * 100;
+ priv->geo.lng += lng / 60;
+
+ if (!g_ascii_strcasecmp(item[5],"W"))
+ priv->geo.lng=-priv->geo.lng;
+
+ if (priv->valid == attr_position_valid_invalid)
+ ret = 1;
+ priv->valid = attr_position_valid_valid;
+ vehicle_file_restart_fix_timeout(priv);
+
+ if (*item[1] && strncmp(priv->fixtime, item[1], sizeof(priv->fixtime))) {
+ ret = 1;
+ strncpy(priv->fixtime, item[1], sizeof(priv->fixtime));
+ }
+
+ dbg(lvl_info, "latitude '%2.4f' longitude %2.4f", priv->geo.lat, priv->geo.lng);
+
+ } else {
+ if (priv->valid == attr_position_valid_valid)
+ ret = 1;
+ priv->valid=attr_position_valid_invalid;
+ }
+
+ if (*item[6])
+ sscanf(item[6], "%d", &priv->status);
+ if (*item[7])
+ sscanf(item[7], "%d", &priv->sats_used);
+ if (*item[8])
+ sscanf(item[8], "%lf", &priv->hdop);
+ if (*item[9])
+ sscanf(item[9], "%lf", &priv->height);
+
+ g_free(priv->nmea_data);
+ priv->nmea_data=priv->nmea_data_buf;
+ priv->nmea_data_buf=NULL;
+ if (priv->file_type == file_type_file) {
+ if (priv->watch) {
+ vehicle_file_disable_watch(priv);
+ event_add_timeout(priv->time, 0, priv->cbt);
+ }
+ }
+ }
+ if (!strncmp(&buffer[3], "VTG", 3)) {
+ /* 0 1 2 34 5 6 7 8
+ $GPVTG,143.58,T,,M,0.26,N,0.5,K*6A
+ Course Over Ground Degrees True[1],"T"[2],Course Over Ground Degrees Magnetic[3],"M"[4],
+ Speed in Knots[5],"N"[6],"Speed in KM/H"[7],"K"[8]
+ */
+ if (item[1] && item[7])
+ valid = 1;
+ if (i >= 10 && (*item[9] == 'A' || *item[9] == 'D'))
+ valid = 1;
+ if (valid) {
+ priv->direction = g_ascii_strtod( item[1], NULL );
+ priv->speed = g_ascii_strtod( item[7], NULL );
+ dbg(lvl_info,"direction %lf, speed %2.1lf", priv->direction, priv->speed);
+ }
+ }
+ if (!strncmp(&buffer[3], "RMC", 3)) {
+ /* 1 1
+ 0 1 2 3 4 5 6 7 8 9 0 1
+ $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
+ Time[1],Active/Void[2],lat[3],N/S[4],long[5],W/E[6],speed in knots[7],track angle[8],date[9],
+ magnetic variation[10],magnetic variation direction[11]
+ */
+ if (*item[2] == 'A')
+ valid = 1;
+ if (i >= 13 && (*item[12] == 'A' || *item[12] == 'D'))
+ valid = 1;
+ if (valid) {
+ priv->direction = g_ascii_strtod( item[8], NULL );
+ priv->speed = g_ascii_strtod( item[7], NULL );
+ priv->speed *= 1.852;
+ sscanf(item[9], "%02d%02d%02d",
+ &priv->fixday,
+ &priv->fixmonth,
+ &priv->fixyear);
+ priv->fixyear += 2000;
+
+ lat = g_ascii_strtod(item[3], NULL);
+ priv->geo.lat = floor(lat / 100);
+ lat -= priv->geo.lat * 100;
+ priv->geo.lat += lat / 60;
+
+ if (!g_ascii_strcasecmp(item[4],"S"))
+ priv->geo.lat=-priv->geo.lat;
+
+ lng = g_ascii_strtod(item[5], NULL);
+ priv->geo.lng = floor(lng / 100);
+ lng -= priv->geo.lng * 100;
+ priv->geo.lng += lng / 60;
+
+ if (!g_ascii_strcasecmp(item[6],"W"))
+ priv->geo.lng=-priv->geo.lng;
+
+ if (priv->valid == attr_position_valid_invalid)
+ ret = 1;
+ priv->valid=attr_position_valid_valid;
+ vehicle_file_restart_fix_timeout(priv);
+
+ if (*item[1] && strncmp(priv->fixtime, item[1], sizeof(priv->fixtime))) {
+ ret = 1;
+ strncpy(priv->fixtime, item[1], sizeof(priv->fixtime));
+ }
+
+ dbg(lvl_info, "latitude '%2.4f' longitude %2.4f", priv->geo.lat, priv->geo.lng);
+
+ } else {
+ if (priv->valid == attr_position_valid_valid)
+ ret = 1;
+ priv->valid=attr_position_valid_invalid;
+ }
+ }
+ if (!strncmp(buffer, "$GPGSV", 6) && i >= 4) {
+ /*
+ 0 GSV Satellites in view
+ 1 2 Number of sentences for full data
+ 2 1 sentence 1 of 2
+ 3 08 Number of satellites in view
+
+ 4 01 Satellite PRN number
+ 5 40 Elevation, degrees
+ 6 083 Azimuth, degrees
+ 7 46 SNR - higher is better
+ for up to 4 satellites per sentence
+ *75 the checksum data, always begins with *
+ */
+ if (item[3]) {
+ sscanf(item[3], "%d", &priv->sats_visible);
+ }
+ j=4;
+ while (j+4 <= i && priv->current_count < 24) {
+ struct gps_sat *sat=&priv->next[priv->next_count++];
+ sat->prn=atoi(item[j]);
+ sat->elevation=atoi(item[j+1]);
+ sat->azimuth=atoi(item[j+2]);
+ sat->snr=atoi(item[j+3]);
+ j+=4;
+ }
+ if (!strcmp(item[1], item[2])) {
+ priv->sats_signal=0;
+ for (i = 0 ; i < priv->next_count ; i++) {
+ priv->current[i]=priv->next[i];
+ if (priv->current[i].snr)
+ priv->sats_signal++;
+ }
+ priv->current_count=priv->next_count;
+ priv->next_count=0;
+ }
+ }
+ if (!strncmp(&buffer[3], "ZDA", 3)) {
+ /*
+ 0 1 2 3 4 5 6
+ $GPZDA,hhmmss.ss,dd,mm,yyyy,xx,yy*CC
+ hhmmss HrMinSec(UTC)
+ dd,mm,yyy Day,Month,Year
+ xx local zone hours -13..13
+ yy local zone minutes 0..59
+ */
+ if (item[1] && item[2] && item[3] && item[4]) {
+ strncpy(priv->fixtime, item[1], strlen(priv->fixtime));
+ priv->fixday = atoi(item[2]);
+ priv->fixmonth = atoi(item[3]);
+ priv->fixyear = atoi(item[4]);
+ }
+ }
+ if (!strncmp(buffer, "$IISMD", 6)) {
+ /*
+ 0 1 2 3 4
+ $IISMD,dir,press,height,temp*CC"
+ dir Direction (0-359)
+ press Pressure (hpa, i.e. 1032)
+ height Barometric height above ground (meter)
+ temp Temperature (Degree Celsius)
+ */
+ if (item[1]) {
+ priv->magnetic_direction = g_ascii_strtod( item[1], NULL );
+ dbg(lvl_debug,"magnetic %d", priv->magnetic_direction);
+ }
+ }
+ return ret;
}
-//***************************************************************************
-/** @fn static void vehicle_file_io(struct vehicle_priv *priv)
-*****************************************************************************
-* @b Description: function to get data from GPS
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-*****************************************************************************
-* @remarks
-*****************************************************************************
-**/
-static void
-vehicle_file_io(struct vehicle_priv *priv)
-{
- int size, rc = 0;
- char *str, *tok;
- dbg(lvl_debug, "vehicle_file_io : enter\n");
-
- if (priv->process_statefile) {
- unsigned char *data;
- priv->process_statefile=0;
- if (file_get_contents(priv->statefile, &data, &size)) {
- if (size > buffer_size)
- size=buffer_size;
- memcpy(priv->buffer, data, size);
- priv->buffer_pos=0;
- g_free(data);
- } else
- return;
- } else {
- size = read(priv->fd, priv->buffer + priv->buffer_pos, buffer_size - priv->buffer_pos - 1);
- }
- if (size <= 0) {
- switch (priv->on_eof) {
- case 0:
- vehicle_file_close(priv);
- vehicle_file_open(priv);
- break;
- case 1:
- vehicle_file_disable_watch(priv);
- break;
- case 2:
- exit(0);
- break;
- }
- return;
- }
- priv->buffer_pos += size;
- priv->buffer[priv->buffer_pos] = '\0';
- dbg(lvl_debug, "size=%d pos=%d buffer='%s'\n", size,
- priv->buffer_pos, priv->buffer);
- str = priv->buffer;
- while ((tok = strchr(str, '\n'))) {
- *tok++ = '\0';
- dbg(lvl_debug, "line='%s'\n", str);
- rc +=vehicle_file_parse(priv, str);
- str = tok;
- if (priv->file_type == file_type_file && rc)
- break;
- }
-
- if (str != priv->buffer) {
- size = priv->buffer + priv->buffer_pos - str;
- memmove(priv->buffer, str, size + 1);
- priv->buffer_pos = size;
- dbg(lvl_debug, "now pos=%d buffer='%s'\n",
- priv->buffer_pos, priv->buffer);
- } else if (priv->buffer_pos == buffer_size - 1) {
- dbg(lvl_debug,
- "Overflow. Most likely wrong baud rate or no nmea protocol\n");
- priv->buffer_pos = 0;
- }
- if (rc)
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+/**
+* @brief Function to get data from GPS
+*
+* @param priv Pointer on the private data of the plugin
+*/
+static void vehicle_file_io(struct vehicle_priv *priv) {
+ int size, rc = 0;
+ char *str, *tok;
+ dbg(lvl_debug, "vehicle_file_io : enter");
+
+ if (priv->process_statefile) {
+ unsigned char *data;
+ priv->process_statefile=0;
+ if (file_get_contents(priv->statefile, &data, &size)) {
+ if (size > buffer_size)
+ size=buffer_size;
+ memcpy(priv->buffer, data, size);
+ priv->buffer_pos=0;
+ g_free(data);
+ } else
+ return;
+ } else {
+ size = read(priv->fd, priv->buffer + priv->buffer_pos, buffer_size - priv->buffer_pos - 1);
+ }
+ if (size <= 0) {
+ switch (priv->on_eof) {
+ case 0:
+ vehicle_file_close(priv);
+ vehicle_file_open(priv);
+ break;
+ case 1:
+ vehicle_file_disable_watch(priv);
+ break;
+ case 2:
+ exit(0);
+ break;
+ }
+ return;
+ }
+ priv->buffer_pos += size;
+ priv->buffer[priv->buffer_pos] = '\0';
+ dbg(lvl_debug, "size=%d pos=%d buffer='%s'", size,
+ priv->buffer_pos, priv->buffer);
+ str = priv->buffer;
+ while ((tok = strchr(str, '\n'))) {
+ *tok++ = '\0';
+ dbg(lvl_debug, "line='%s'", str);
+ rc +=vehicle_file_parse(priv, str);
+ str = tok;
+ if (priv->file_type == file_type_file && rc)
+ break;
+ }
+
+ if (str != priv->buffer) {
+ size = priv->buffer + priv->buffer_pos - str;
+ memmove(priv->buffer, str, size + 1);
+ priv->buffer_pos = size;
+ dbg(lvl_debug, "now pos=%d buffer='%s'",
+ priv->buffer_pos, priv->buffer);
+ } else if (priv->buffer_pos == buffer_size - 1) {
+ dbg(lvl_debug,
+ "Overflow. Most likely wrong baud rate or no nmea protocol");
+ priv->buffer_pos = 0;
+ }
+ if (rc)
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
}
-//***************************************************************************
-/** @fn static void vehicle_file_enable_watch(struct vehicle_priv *priv)
-*****************************************************************************
-* @b Description: Enable watch
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-*****************************************************************************
-**/
-static void
-vehicle_file_enable_watch(struct vehicle_priv *priv)
-{
- dbg(lvl_debug, "enter\n");
+/**
+* @brief Enable watch
+*
+* @param priv Pointer on the private data of the plugin
+*/
+static void vehicle_file_enable_watch(struct vehicle_priv *priv) {
+ dbg(lvl_debug, "enter");
#ifdef _WIN32
- // add an event : don't use glib timers and g_timeout_add
- if (priv->file_type == file_type_serial)
- {
- if (priv->timeout_callback != NULL)
+ // add an event : don't use glib timers and g_timeout_add
+ if (priv->file_type == file_type_serial) {
+ if (priv->timeout_callback != NULL)
priv->timeout = event_add_timeout(500, 1, priv->timeout_callback);
else
- dbg(lvl_warning, "error : watch not enabled : priv->timeout_callback is null\n"); }
- else
+ dbg(lvl_warning, "error : watch not enabled : priv->timeout_callback is null");
+ } else
#endif
{
- if (! priv->watch)
- priv->watch = event_add_watch(priv->fd, event_watch_cond_read, priv->cb);
+ if (! priv->watch)
+ priv->watch = event_add_watch(priv->fd, event_watch_cond_read, priv->cb);
}
}
-//***************************************************************************
-/** @fn static void vehicle_file_disable_watch(struct vehicle_priv *priv)
-*****************************************************************************
-* @b Description: Disable watch
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-*****************************************************************************
-**/
-static void
-vehicle_file_disable_watch(struct vehicle_priv *priv)
-{
- dbg(lvl_debug, "vehicle_file_disable_watch : enter\n");
+/**
+* @brief Disable watch
+*
+* @param priv Pointer on the private data of the plugin
+*/
+static void vehicle_file_disable_watch(struct vehicle_priv *priv) {
+ dbg(lvl_debug, "vehicle_file_disable_watch : enter");
#ifdef _WIN32
- if(priv->file_type == file_type_serial)
- {
- if (priv->timeout) {
- event_remove_timeout(priv->timeout);
- priv->timeout=NULL; // dangling pointer! prevent double freeing.
+ if(priv->file_type == file_type_serial) {
+ if (priv->timeout) {
+ event_remove_timeout(priv->timeout);
+ priv->timeout=NULL; // dangling pointer! prevent double freeing.
}
- }
- else
+ } else
#endif //!_WIN32
{
- if (priv->watch)
- event_remove_watch(priv->watch);
- priv->watch = NULL;
+ if (priv->watch)
+ event_remove_watch(priv->watch);
+ priv->watch = NULL;
}
}
-//***************************************************************************
-/** @fn static void vehicle_priv vehicle_file_destroy(struct vehicle_priv *priv)
-*****************************************************************************
-* @b Description: Function called to uninitialize the plugin
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-*****************************************************************************
+/**
+* @brief Function called to uninitialize the plugin
+*
+* @param priv Pointer on the private data of the plugin
+*
* @remarks private data is freed by this function (g_free)
-*****************************************************************************
-**/
-static void
-vehicle_file_destroy(struct vehicle_priv *priv)
-{
- if (priv->statefile && priv->nmea_data) {
- struct attr readwrite={attr_readwrite};
- struct attr create={attr_create};
- struct attr *attrs[]={&readwrite,&create,NULL};
- struct file *f;
- readwrite.u.num=1;
- create.u.num=1;
- f=file_create(priv->statefile, attrs);
- if (f) {
- file_data_write(f, 0, strlen(priv->nmea_data), priv->nmea_data);
- file_fsync(f);
- file_destroy(f);
- }
- }
- vehicle_file_close(priv);
- callback_destroy(priv->cb);
- callback_destroy(priv->cbt);
- if (priv->statefile)
- g_free(priv->statefile);
- if (priv->source)
- g_free(priv->source);
- if (priv->buffer)
- g_free(priv->buffer);
- g_free(priv);
+*/
+static void vehicle_file_destroy(struct vehicle_priv *priv) {
+ if (priv->statefile && priv->nmea_data) {
+ struct attr readwrite= {attr_readwrite};
+ struct attr create= {attr_create};
+ struct attr *attrs[]= {&readwrite,&create,NULL};
+ struct file *f;
+ readwrite.u.num=1;
+ create.u.num=1;
+ f=file_create(priv->statefile, attrs);
+ if (f) {
+ file_data_write(f, 0, strlen(priv->nmea_data), priv->nmea_data);
+ file_fsync(f);
+ file_destroy(f);
+ }
+ }
+ vehicle_file_close(priv);
+ callback_destroy(priv->cb);
+ callback_destroy(priv->cbt);
+ if (priv->statefile)
+ g_free(priv->statefile);
+ if (priv->source)
+ g_free(priv->source);
+ if (priv->buffer)
+ g_free(priv->buffer);
+ g_free(priv);
}
-//***************************************************************************
-/** @fn static int vehicle_file_position_attr_get(struct vehicle_priv *priv,
-* enum attr_type type,
-* struct attr *attr)
-*****************************************************************************
-* @b Description: Function called to get attribute
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-* @param type : attribute type called
-* @param attr : structure to return the attribute value
-*****************************************************************************
-* @return 1 if ok
-* 0 for unkown or invalid attribute
-*****************************************************************************
-**/
-static int
-vehicle_file_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_position_fix_type:
- attr->u.num = priv->status;
- break;
- case attr_position_height:
- attr->u.numd = &priv->height;
- break;
- case attr_position_speed:
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- attr->u.numd = &priv->direction;
- break;
- case attr_position_magnetic_direction:
- attr->u.num = priv->magnetic_direction;
- break;
- case attr_position_hdop:
- attr->u.numd = &priv->hdop;
- break;
- case attr_position_qual:
- attr->u.num = priv->sats_visible;
- break;
- case attr_position_sats_signal:
- attr->u.num = priv->sats_signal;
- break;
- case attr_position_sats_used:
- attr->u.num = priv->sats_used;
- break;
- case attr_position_coord_geo:
- attr->u.coord_geo = &priv->geo;
- break;
- case attr_position_nmea:
- attr->u.str=priv->nmea_data;
- if (! attr->u.str)
- return 0;
- break;
- case attr_position_time_iso8601:
- if (!priv->fixyear || !priv->fixtime[0])
- return 0;
- sprintf(priv->fixiso8601, "%04d-%02d-%02dT%.2s:%.2s:%sZ",
- priv->fixyear, priv->fixmonth, priv->fixday,
- priv->fixtime, (priv->fixtime+2), (priv->fixtime+4));
- attr->u.str=priv->fixiso8601;
- break;
- case attr_position_sat_item:
- dbg(lvl_debug,"at here\n");
- priv->sat_item.id_lo++;
- if (priv->sat_item.id_lo > priv->current_count) {
- priv->sat_item.id_lo=0;
- return 0;
- }
- attr->u.item=&priv->sat_item;
- break;
- case attr_position_valid:
- attr->u.num=priv->valid;
- break;
- default:
- return 0;
- }
- if (type != attr_position_sat_item)
- priv->sat_item.id_lo=0;
- attr->type = type;
- return 1;
+/**
+* @brief Function called to get attribute
+*
+* @param priv Pointer on the private data of the plugin
+* @param type Attribute type called
+* @param attr Structure to return the attribute value
+*
+* @return 1 if ok, 0 for unknown or invalid attribute
+*/
+static int vehicle_file_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ switch (type) {
+ case attr_position_fix_type:
+ attr->u.num = priv->status;
+ break;
+ case attr_position_height:
+ attr->u.numd = &priv->height;
+ break;
+ case attr_position_speed:
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ attr->u.numd = &priv->direction;
+ break;
+ case attr_position_magnetic_direction:
+ attr->u.num = priv->magnetic_direction;
+ break;
+ case attr_position_hdop:
+ attr->u.numd = &priv->hdop;
+ break;
+ case attr_position_qual:
+ attr->u.num = priv->sats_visible;
+ break;
+ case attr_position_sats_signal:
+ attr->u.num = priv->sats_signal;
+ break;
+ case attr_position_sats_used:
+ attr->u.num = priv->sats_used;
+ break;
+ case attr_position_coord_geo:
+ attr->u.coord_geo = &priv->geo;
+ break;
+ case attr_position_nmea:
+ attr->u.str=priv->nmea_data;
+ if (! attr->u.str)
+ return 0;
+ break;
+ case attr_position_time_iso8601:
+ if (!priv->fixyear || !priv->fixtime[0])
+ return 0;
+ sprintf(priv->fixiso8601, "%04d-%02d-%02dT%.2s:%.2s:%sZ",
+ priv->fixyear, priv->fixmonth, priv->fixday,
+ priv->fixtime, (priv->fixtime+2), (priv->fixtime+4));
+ attr->u.str=priv->fixiso8601;
+ break;
+ case attr_position_sat_item:
+ dbg(lvl_debug,"at here");
+ priv->sat_item.id_lo++;
+ if (priv->sat_item.id_lo > priv->current_count) {
+ priv->sat_item.id_lo=0;
+ return 0;
+ }
+ attr->u.item=&priv->sat_item;
+ break;
+ case attr_position_valid:
+ attr->u.num=priv->valid;
+ break;
+ default:
+ return 0;
+ }
+ if (type != attr_position_sat_item)
+ priv->sat_item.id_lo=0;
+ attr->type = type;
+ return 1;
}
-//***************************************************************************
-/** @fn static int vehicle_file_sat_attr_get(struct vehicle_priv *priv,
-* enum attr_type type,
-* struct attr *attr)
-*****************************************************************************
-* @b Description: Function called to get satellite attribute
-*****************************************************************************
-* @param priv : pointer on the private data of the plugin
-* @param type : attribute type called
-* @param attr : structure to return the attribute value
-*****************************************************************************
-* @return 1 if ok
-* 0 for unkown attribute
-*****************************************************************************
-**/
-static int
-vehicle_file_sat_attr_get(void *priv_data, enum attr_type type, struct attr *attr)
-{
+/**
+* @brief Function called to get satellite attribute
+*
+* @param priv Pointer on the private data of the plugin
+* @param type Attribute type called
+* @param attr Structure to return the attribute value
+*
+* @return 1 if ok, 0 for unknown attribute
+*/
+static int vehicle_file_sat_attr_get(void *priv_data, enum attr_type type, struct attr *attr) {
struct gps_sat *sat;
- struct vehicle_priv *priv=priv_data;
- if (priv->sat_item.id_lo < 1)
- return 0;
- if (priv->sat_item.id_lo > priv->current_count)
- return 0;
- sat=&priv->current[priv->sat_item.id_lo-1];
- switch (type) {
- case attr_sat_prn:
- attr->u.num=sat->prn;
- break;
- case attr_sat_elevation:
- attr->u.num=sat->elevation;
- break;
- case attr_sat_azimuth:
- attr->u.num=sat->azimuth;
- break;
- case attr_sat_snr:
- attr->u.num=sat->snr;
- break;
- default:
- return 0;
- }
- attr->type = type;
- return 1;
+ struct vehicle_priv *priv=priv_data;
+ if (priv->sat_item.id_lo < 1)
+ return 0;
+ if (priv->sat_item.id_lo > priv->current_count)
+ return 0;
+ sat=&priv->current[priv->sat_item.id_lo-1];
+ switch (type) {
+ case attr_sat_prn:
+ attr->u.num=sat->prn;
+ break;
+ case attr_sat_elevation:
+ attr->u.num=sat->elevation;
+ break;
+ case attr_sat_azimuth:
+ attr->u.num=sat->azimuth;
+ break;
+ case attr_sat_snr:
+ attr->u.num=sat->snr;
+ break;
+ default:
+ return 0;
+ }
+ attr->type = type;
+ return 1;
}
static struct item_methods vehicle_file_sat_methods = {
- NULL,
- NULL,
- NULL,
- vehicle_file_sat_attr_get,
+ NULL,
+ NULL,
+ NULL,
+ vehicle_file_sat_attr_get,
};
static struct vehicle_methods vehicle_file_methods = {
- vehicle_file_destroy,
- vehicle_file_position_attr_get,
+ vehicle_file_destroy,
+ vehicle_file_position_attr_get,
};
-//***************************************************************************
-/** @fn static struct vehicle_priv * vehicle_file_new_file(
-* struct vehicle_methods *meth,
-* struct callback_list *cbl,
-* struct attr **attrs)
-*****************************************************************************
-* @b Description: Function called to initialize the plugin
-*****************************************************************************
-* @param meth : ?
-* @param cbl : ?
-* @param attrs : ?
-*****************************************************************************
-* @return pointer on the private data of the plugin
-*****************************************************************************
-* @remarks private data is allocated by this function (g_new0)
-*****************************************************************************
-**/
-static struct vehicle_priv *
-vehicle_file_new_file(struct vehicle_methods
- *meth, struct callback_list
- *cbl, struct attr **attrs)
-{
- struct vehicle_priv *ret;
- struct attr *source;
- struct attr *time;
- struct attr *on_eof;
- struct attr *baudrate;
- struct attr *checksum_ignore;
- struct attr *state_file;
-
- dbg(lvl_debug, "enter\n");
-
- source = attr_search(attrs, NULL, attr_source);
- if(source == NULL){
- dbg(lvl_error,"Missing source attribute");
- return NULL;
+/**
+* @brief Function called to initialize the plugin
+*
+* @param meth ?
+* @param cbl ?
+* @param attrs ?
+*
+* @return Pointer on the private data of the plugin
+*
+* @remarks Private data is allocated by this function (g_new0)
+*/
+static struct vehicle_priv *vehicle_file_new_file(struct vehicle_methods
+ *meth, struct callback_list
+ *cbl, struct attr **attrs) {
+ struct vehicle_priv *ret;
+ struct attr *source;
+ struct attr *time;
+ struct attr *on_eof;
+ struct attr *baudrate;
+ struct attr *checksum_ignore;
+ struct attr *state_file;
+
+ dbg(lvl_debug, "enter");
+
+ source = attr_search(attrs, NULL, attr_source);
+ if(source == NULL) {
+ dbg(lvl_error,"Missing source attribute");
+ return NULL;
}
- ret = g_new0(struct vehicle_priv, 1); // allocate and initialize to 0
- ret->fd = -1;
- ret->cbl = cbl;
- ret->source = g_strdup(source->u.str);
- ret->buffer = g_malloc(buffer_size);
- ret->time=1000;
- ret->baudrate=B4800;
- state_file=attr_search(attrs, NULL, attr_state_file);
- if (state_file)
- ret->statefile=g_strdup(state_file->u.str);
- time = attr_search(attrs, NULL, attr_time);
- if (time)
- ret->time=time->u.num;
- baudrate = attr_search(attrs, NULL, attr_baudrate);
- if (baudrate) {
- switch (baudrate->u.num) {
- case 4800:
- ret->baudrate=B4800;
- break;
- case 9600:
- ret->baudrate=B9600;
- break;
- case 19200:
- ret->baudrate=B19200;
- break;
+ ret = g_new0(struct vehicle_priv, 1); // allocate and initialize to 0
+ ret->fd = -1;
+ ret->cbl = cbl;
+ ret->source = g_strdup(source->u.str);
+ ret->buffer = g_malloc(buffer_size);
+ ret->time=1000;
+ ret->baudrate=B4800;
+ ret->fixtime[0] = '\0';
+ ret->ev_fix_timeout = NULL;
+ state_file=attr_search(attrs, NULL, attr_state_file);
+ if (state_file)
+ ret->statefile=g_strdup(state_file->u.str);
+ time = attr_search(attrs, NULL, attr_time);
+ if (time)
+ ret->time=time->u.num;
+ baudrate = attr_search(attrs, NULL, attr_baudrate);
+ if (baudrate) {
+ switch (baudrate->u.num) {
+ case 4800:
+ ret->baudrate=B4800;
+ break;
+ case 9600:
+ ret->baudrate=B9600;
+ break;
+ case 19200:
+ ret->baudrate=B19200;
+ break;
#ifdef B38400
- case 38400:
- ret->baudrate=B38400;
- break;
+ case 38400:
+ ret->baudrate=B38400;
+ break;
#endif
#ifdef B57600
- case 57600:
- ret->baudrate=B57600;
- break;
+ case 57600:
+ ret->baudrate=B57600;
+ break;
#endif
#ifdef B115200
- case 115200:
- ret->baudrate=B115200;
- break;
+ case 115200:
+ ret->baudrate=B115200;
+ break;
#endif
- }
- }
- checksum_ignore = attr_search(attrs, NULL, attr_checksum_ignore);
- if (checksum_ignore)
- ret->checksum_ignore=checksum_ignore->u.num;
- ret->attrs = attrs;
- on_eof = attr_search(attrs, NULL, attr_on_eof);
- if (on_eof && !g_ascii_strcasecmp(on_eof->u.str, "stop"))
- ret->on_eof=1;
- if (on_eof && !g_ascii_strcasecmp(on_eof->u.str, "exit"))
- ret->on_eof=2;
- dbg(lvl_debug,"on_eof=%d\n", ret->on_eof);
- *meth = vehicle_file_methods;
- ret->cb=callback_new_1(callback_cast(vehicle_file_io), ret);
- ret->cbt=callback_new_1(callback_cast(vehicle_file_enable_watch_timer), ret);
- if (ret->statefile && file_exists(ret->statefile)) {
- ret->process_statefile=1;
- event_add_timeout(1000, 0, ret->cb);
- }
- ret->sat_item.type=type_position_sat;
- ret->sat_item.id_hi=ret->sat_item.id_lo=0;
- ret->sat_item.priv_data=ret;
- ret->sat_item.meth=&vehicle_file_sat_methods;
+ }
+ }
+ checksum_ignore = attr_search(attrs, NULL, attr_checksum_ignore);
+ if (checksum_ignore)
+ ret->checksum_ignore=checksum_ignore->u.num;
+ ret->attrs = attrs;
+ on_eof = attr_search(attrs, NULL, attr_on_eof);
+ if (on_eof && !g_ascii_strcasecmp(on_eof->u.str, "stop"))
+ ret->on_eof=1;
+ if (on_eof && !g_ascii_strcasecmp(on_eof->u.str, "exit"))
+ ret->on_eof=2;
+ dbg(lvl_debug,"on_eof=%d", ret->on_eof);
+ *meth = vehicle_file_methods;
+ ret->cb=callback_new_1(callback_cast(vehicle_file_io), ret);
+ ret->cbt=callback_new_1(callback_cast(vehicle_file_enable_watch_timer), ret);
+ ret->cb_fix_timeout=callback_new_1(callback_cast(vehicle_file_fix_timeout_cb), ret);
+ if (ret->statefile && file_exists(ret->statefile)) {
+ ret->process_statefile=1;
+ event_add_timeout(1000, 0, ret->cb);
+ }
+ ret->sat_item.type=type_position_sat;
+ ret->sat_item.id_hi=ret->sat_item.id_lo=0;
+ ret->sat_item.priv_data=ret;
+ ret->sat_item.meth=&vehicle_file_sat_methods;
#ifdef _WIN32
- ret->no_data_count = 0;
+ ret->no_data_count = 0;
#endif
- dbg(lvl_debug, "vehicle_file_new_file:open\n");
- if (!vehicle_file_open(ret)) {
- dbg(lvl_error, "Failed to open '%s'\n", ret->source);
- }
+ dbg(lvl_debug, "vehicle_file_new_file:open");
+ if (!vehicle_file_open(ret)) {
+ dbg(lvl_error, "Failed to open '%s'", ret->source);
+ }
- vehicle_file_enable_watch(ret);
- // vehicle_file_destroy(ret);
- // return NULL;
- dbg(lvl_debug, "leave\n");
- return ret;
+ vehicle_file_enable_watch(ret);
+ // vehicle_file_destroy(ret);
+ // return NULL;
+ dbg(lvl_debug, "leave");
+ return ret;
}
-//***************************************************************************
-/** @fn void plugin_init(void)
-*****************************************************************************
-* @b Description: Initialisation of vehicle_file plugin
-*****************************************************************************
-**/
-void plugin_init(void)
-{
- dbg(lvl_debug, "vehicle_file:plugin_init:enter\n");
- plugin_register_category_vehicle("file", vehicle_file_new_file);
- plugin_register_category_vehicle("pipe", vehicle_file_new_file);
- plugin_register_category_vehicle("socket", vehicle_file_new_file);
- plugin_register_category_vehicle("serial", vehicle_file_new_file);
+/**
+* @brief Initialisation of vehicle_file plugin
+*/
+void plugin_init(void) {
+ dbg(lvl_debug, "vehicle_file:plugin_init:enter");
+ plugin_register_category_vehicle("file", vehicle_file_new_file);
+ plugin_register_category_vehicle("pipe", vehicle_file_new_file);
+ plugin_register_category_vehicle("socket", vehicle_file_new_file);
+ plugin_register_category_vehicle("serial", vehicle_file_new_file);
}
diff --git a/navit/vehicle/file/vehicle_pipe.c b/navit/vehicle/file/vehicle_pipe.c
index 420390d4e..2f9f6c227 100644
--- a/navit/vehicle/file/vehicle_pipe.c
+++ b/navit/vehicle/file/vehicle_pipe.c
@@ -20,8 +20,6 @@
#include "config.h"
#include "plugin.h"
-void
-plugin_init(void)
-{
- plugin_get_category_vehicle("file");
+void plugin_init(void) {
+ plugin_get_category_vehicle("file");
}
diff --git a/navit/vehicle/file/vehicle_serial.c b/navit/vehicle/file/vehicle_serial.c
index 420390d4e..2f9f6c227 100644
--- a/navit/vehicle/file/vehicle_serial.c
+++ b/navit/vehicle/file/vehicle_serial.c
@@ -20,8 +20,6 @@
#include "config.h"
#include "plugin.h"
-void
-plugin_init(void)
-{
- plugin_get_category_vehicle("file");
+void plugin_init(void) {
+ plugin_get_category_vehicle("file");
}
diff --git a/navit/vehicle/file/vehicle_socket.c b/navit/vehicle/file/vehicle_socket.c
index 420390d4e..2f9f6c227 100644
--- a/navit/vehicle/file/vehicle_socket.c
+++ b/navit/vehicle/file/vehicle_socket.c
@@ -20,8 +20,6 @@
#include "config.h"
#include "plugin.h"
-void
-plugin_init(void)
-{
- plugin_get_category_vehicle("file");
+void plugin_init(void) {
+ plugin_get_category_vehicle("file");
}
diff --git a/navit/vehicle/gpsd/CMakeLists.txt b/navit/vehicle/gpsd/CMakeLists.txt
index 091df2f71..75c3866c4 100644
--- a/navit/vehicle/gpsd/CMakeLists.txt
+++ b/navit/vehicle/gpsd/CMakeLists.txt
@@ -1,8 +1,8 @@
module_add_library(vehicle_gpsd vehicle_gpsd.c)
if (LIBGPS19_FOUND)
- set_property(
- TARGET vehicle_gpsd
- APPEND PROPERTY COMPILE_DEFINITIONS HAVE_LIBGPS19=1
- )
+ set_property(
+ TARGET vehicle_gpsd
+ APPEND PROPERTY COMPILE_DEFINITIONS HAVE_LIBGPS19=1
+ )
endif (LIBGPS19_FOUND)
diff --git a/navit/vehicle/gpsd/vehicle_gpsd.c b/navit/vehicle/gpsd/vehicle_gpsd.c
index a8c29cd97..99a4b4ffc 100644
--- a/navit/vehicle/gpsd/vehicle_gpsd.c
+++ b/navit/vehicle/gpsd/vehicle_gpsd.c
@@ -1,4 +1,4 @@
-/**
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -35,32 +35,40 @@
#include "event.h"
#include "types.h"
+/**
+ * @defgroup vehicle-gpsd Vehicle Gpsd
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from the gpsd service
+ *
+ * @{
+ */
+
static struct vehicle_priv {
- char *source;
- char *gpsd_query;
- struct callback_list *cbl;
- struct callback *cb, *cbt;
- struct event_watch *evwatch;
- guint retry_interval;
- struct gps_data_t *gps;
- struct coord_geo geo;
- double speed;
- double direction;
- double height;
- double hdop;
- int status;
- int fix_type;
- time_t fix_time;
- int sats;
- int sats_signal;
- int sats_used;
- char *nmea_data;
- char *nmea_data_buf;
- struct event_timeout *retry_timer2;
- struct attr ** attrs;
- char fixiso8601[128];
+ char *source;
+ char *gpsd_query;
+ struct callback_list *cbl;
+ struct callback *cb, *cbt;
+ struct event_watch *evwatch;
+ guint retry_interval;
+ struct gps_data_t *gps;
+ struct coord_geo geo;
+ double speed;
+ double direction;
+ double height;
+ double hdop;
+ int status;
+ int fix_type;
+ time_t fix_time;
+ int sats;
+ int sats_signal;
+ int sats_used;
+ char *nmea_data;
+ char *nmea_data_buf;
+ struct event_timeout *retry_timer2;
+ struct attr ** attrs;
+ char fixiso8601[128];
#ifdef HAVE_GPSBT
- gpsbt_t context;
+ gpsbt_t context;
#endif
} *vehicle_last;
@@ -74,124 +82,127 @@ static void
vehicle_gpsd_callback(struct gps_data_t *data, const char *buf, size_t len)
#else
vehicle_gpsd_callback(struct gps_data_t *data, const char *buf, size_t len,
- int level)
+ int level)
#endif
{
- char *pos,*nmea_data_buf;
- int i=0,sats_signal=0;
-
- struct vehicle_priv *priv = vehicle_last;
- if( len > 0 && buf[0] == '$' ) {
- char buffer[len+2];
- buffer[len+1]='\0';
- memcpy(buffer, buf, len);
- pos=strchr(buffer,'\n');
- if(!pos) {
- pos=strchr(buffer,'\r');
- }
- if (pos) {
- *pos ='\n';
- *++pos='\0';
- if (!priv->nmea_data_buf || strlen(priv->nmea_data_buf) < 65536) {
- nmea_data_buf=g_strconcat(priv->nmea_data_buf ? priv->nmea_data_buf : "", buffer, NULL);
- g_free(priv->nmea_data_buf);
- priv->nmea_data_buf=nmea_data_buf;
- } else {
- dbg(lvl_error, "nmea buffer overflow, discarding '%s'\n", buffer);
- }
- }
- }
- dbg(lvl_debug,"data->set="LONGLONG_HEX_FMT"\n", (unsigned long long)data->set);
- if (data->set & SPEED_SET) {
- priv->speed = data->fix.speed * 3.6;
- if(!isnan(data->fix.speed))
- callback_list_call_attr_0(priv->cbl, attr_position_speed);
- data->set &= ~SPEED_SET;
- }
- if (data->set & TRACK_SET) {
- priv->direction = data->fix.track;
- data->set &= ~TRACK_SET;
- }
- if (data->set & ALTITUDE_SET) {
- priv->height = data->fix.altitude;
- data->set &= ~ALTITUDE_SET;
- }
- if (data->set & SATELLITE_SET) {
+ char *pos,*nmea_data_buf;
+ int i=0,sats_signal=0;
+
+ struct vehicle_priv *priv = vehicle_last;
+ if( len > 0 && buf[0] == '$' ) {
+ char buffer[len+2];
+ buffer[len+1]='\0';
+ memcpy(buffer, buf, len);
+ pos=strchr(buffer,'\n');
+ if(!pos) {
+ pos=strchr(buffer,'\r');
+ }
+ if (pos) {
+ *pos ='\n';
+ *++pos='\0';
+ if (!priv->nmea_data_buf || strlen(priv->nmea_data_buf) < 65536) {
+ nmea_data_buf=g_strconcat(priv->nmea_data_buf ? priv->nmea_data_buf : "", buffer, NULL);
+ g_free(priv->nmea_data_buf);
+ priv->nmea_data_buf=nmea_data_buf;
+ } else {
+ dbg(lvl_error, "nmea buffer overflow, discarding '%s'", buffer);
+ }
+ }
+ }
+
+ dbg(lvl_debug,"data->set="LONGLONG_HEX_FMT"", (unsigned long long)data->set);
+ if (data->set & SPEED_SET) {
+ priv->speed = data->fix.speed * MPS_TO_KPH;
+ if(!isnan(data->fix.speed))
+ callback_list_call_attr_0(priv->cbl, attr_position_speed);
+ data->set &= ~SPEED_SET;
+ }
+
+ if (data->set & TRACK_SET) {
+ priv->direction = data->fix.track;
+ data->set &= ~TRACK_SET;
+ }
+ if (data->set & ALTITUDE_SET) {
+ priv->height = data->fix.altitude;
+ data->set &= ~ALTITUDE_SET;
+ }
+ if (data->set & SATELLITE_SET) {
// We cannot rely on GPSD_API_MAJOR_VERSION here because it was not
// incremented for this change :-(.
#ifdef HAVE_LIBGPS19
- if(data->satellites_visible > 0) {
+ if(data->satellites_visible > 0) {
#else
- if(data->satellites > 0) {
+ if(data->satellites > 0) {
#endif
- sats_signal=0;
+ sats_signal=0;
#ifdef HAVE_LIBGPS19
- for( i=0;i<data->satellites_visible;i++) {
+ for( i=0; i<data->satellites_visible; i++) {
#else
- for( i=0;i<data->satellites;i++) {
+ for( i=0; i<data->satellites; i++) {
#endif
#if GPSD_API_MAJOR_VERSION >= 6
- if (data->skyview[i].ss > 0)
+ if (data->skyview[i].ss > 0)
#else
- if (data->ss[i] > 0)
+ if (data->ss[i] > 0)
#endif
- sats_signal++;
- }
- }
+ sats_signal++;
+ }
+ }
#ifdef HAVE_LIBGPS19
- if (priv->sats_used != data->satellites_used || priv->sats != data->satellites_visible || priv->sats_signal != sats_signal ) {
+ if (priv->sats_used != data->satellites_used || priv->sats != data->satellites_visible
+ || priv->sats_signal != sats_signal ) {
#else
- if (priv->sats_used != data->satellites_used || priv->sats != data->satellites || priv->sats_signal != sats_signal ) {
+ if (priv->sats_used != data->satellites_used || priv->sats != data->satellites || priv->sats_signal != sats_signal ) {
#endif
- priv->sats_used = data->satellites_used;
+ priv->sats_used = data->satellites_used;
#ifdef HAVE_LIBGPS19
- priv->sats = data->satellites_visible;
+ priv->sats = data->satellites_visible;
#else
- priv->sats = data->satellites;
+ priv->sats = data->satellites;
#endif
- priv->sats_signal = sats_signal;
- callback_list_call_attr_0(priv->cbl, attr_position_sats);
- }
- data->set &= ~SATELLITE_SET;
- }
- if (data->set & STATUS_SET) {
- priv->status = data->status;
- data->set &= ~STATUS_SET;
- }
- if (data->set & MODE_SET) {
- priv->fix_type = data->fix.mode - 1;
- data->set &= ~MODE_SET;
- }
- if (data->set & TIME_SET) {
- priv->fix_time = data->fix.time;
- data->set &= ~TIME_SET;
- }
+ priv->sats_signal = sats_signal;
+ callback_list_call_attr_0(priv->cbl, attr_position_sats);
+ }
+ data->set &= ~SATELLITE_SET;
+ }
+ if (data->set & STATUS_SET) {
+ priv->status = data->status;
+ data->set &= ~STATUS_SET;
+ }
+ if (data->set & MODE_SET) {
+ priv->fix_type = data->fix.mode - 1;
+ data->set &= ~MODE_SET;
+ }
+ if (data->set & TIME_SET) {
+ priv->fix_time = data->fix.time;
+ data->set &= ~TIME_SET;
+ }
#ifdef HAVE_LIBGPS19
- if (data->set & DOP_SET) {
- dbg(lvl_debug, "pdop : %g\n", data->dop.pdop);
- priv->hdop = data->dop.pdop;
- data->set &= ~DOP_SET;
+ if (data->set & DOP_SET) {
+ dbg(lvl_debug, "pdop : %g", data->dop.pdop);
+ priv->hdop = data->dop.pdop;
+ data->set &= ~DOP_SET;
#else
- if (data->set & PDOP_SET) {
- dbg(lvl_debug, "pdop : %g\n", data->pdop);
- priv->hdop = data->hdop;
- data->set &= ~PDOP_SET;
+ if (data->set & PDOP_SET) {
+ dbg(lvl_debug, "pdop : %g", data->pdop);
+ priv->hdop = data->hdop;
+ data->set &= ~PDOP_SET;
#endif
- }
- if (data->set & LATLON_SET) {
- priv->geo.lat = data->fix.latitude;
- priv->geo.lng = data->fix.longitude;
- dbg(lvl_debug,"lat=%f lng=%f\n", priv->geo.lat, priv->geo.lng);
- g_free(priv->nmea_data);
- priv->nmea_data=priv->nmea_data_buf;
- priv->nmea_data_buf=NULL;
- data->set &= ~LATLON_SET;
- }
- // If data->fix.speed is NAN, then the drawing gets jumpy.
- if (! isnan(data->fix.speed) && priv->fix_type > 0) {
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
- }
- dbg(lvl_info,"speed ok\n");
+ }
+ if (data->set & LATLON_SET) {
+ priv->geo.lat = data->fix.latitude;
+ priv->geo.lng = data->fix.longitude;
+ dbg(lvl_debug,"lat=%f lng=%f", priv->geo.lat, priv->geo.lng);
+ g_free(priv->nmea_data);
+ priv->nmea_data=priv->nmea_data_buf;
+ priv->nmea_data_buf=NULL;
+ data->set &= ~LATLON_SET;
+ }
+ // If data->fix.speed is NAN, then the drawing gets jumpy.
+ if (! isnan(data->fix.speed) && priv->fix_type > 0) {
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+ }
+ dbg(lvl_info,"speed ok");
}
/**
@@ -199,277 +210,264 @@ vehicle_gpsd_callback(struct gps_data_t *data, const char *buf, size_t len,
* Return FALSE if retry not required
* Return TRUE to try again
*/
-static int
-vehicle_gpsd_try_open(struct vehicle_priv *priv)
-{
- char *source = g_strdup(priv->source);
- char *colon = index(source + 7, ':');
- char *port=NULL;
- if (colon) {
- *colon = '\0';
- port=colon+1;
- }
- dbg(lvl_debug,"Trying to connect to %s:%s\n",source+7,port?port:"default");
+static int vehicle_gpsd_try_open(struct vehicle_priv *priv) {
+ char *source = g_strdup(priv->source);
+ char *colon = index(source + 7, ':');
+ char *port=NULL;
+ if (colon) {
+ *colon = '\0';
+ port=colon+1;
+ }
+ dbg(lvl_debug,"Trying to connect to %s:%s",source+7,port?port:"default");
#if GPSD_API_MAJOR_VERSION >= 5
- /* gps_open returns 0 on success */
- if (gps_open(source + 7, port, priv->gps)) {
+ /* gps_open returns 0 on success */
+ if (gps_open(source + 7, port, priv->gps)) {
#else
- priv->gps = gps_open(source + 7, port);
- if(!priv->gps) {
+ priv->gps = gps_open(source + 7, port);
+ if(!priv->gps) {
#endif
- dbg(lvl_error,"gps_open failed for '%s'. Retrying in %d seconds. Have you started gpsd?\n", priv->source, priv->retry_interval);
- g_free(source);
- return TRUE;
- }
- g_free(source);
+ dbg(lvl_error,"gps_open failed for '%s'. Retrying in %d seconds. Have you started gpsd?", priv->source,
+ priv->retry_interval);
+ g_free(source);
+ return TRUE;
+ }
+ g_free(source);
#ifdef HAVE_LIBGPS19
- if (strchr(priv->gpsd_query,'r'))
- gps_stream(priv->gps, WATCH_ENABLE|WATCH_NMEA|WATCH_JSON, NULL);
- else
- gps_stream(priv->gps, WATCH_ENABLE|WATCH_JSON, NULL);
+ if (strchr(priv->gpsd_query,'r'))
+ gps_stream(priv->gps, WATCH_ENABLE|WATCH_NMEA|WATCH_JSON, NULL);
+ else
+ gps_stream(priv->gps, WATCH_ENABLE|WATCH_JSON, NULL);
#else
- gps_query(priv->gps, priv->gpsd_query);
+ gps_query(priv->gps, priv->gpsd_query);
#endif
#if GPSD_API_MAJOR_VERSION < 5
- gps_set_raw_hook(priv->gps, vehicle_gpsd_callback);
+ gps_set_raw_hook(priv->gps, vehicle_gpsd_callback);
#endif
- priv->cb = callback_new_1(callback_cast(vehicle_gpsd_io), priv);
- priv->cbt = callback_new_1(callback_cast(vehicle_gpsd_try_open), priv);
- priv->evwatch = event_add_watch(priv->gps->gps_fd, event_watch_cond_read, priv->cb);
- if (!priv->gps->gps_fd) {
- dbg(lvl_error,"Warning: gps_fd is 0, most likely you have used a gps.h incompatible to libgps");
- }
- dbg(lvl_debug,"Connected to gpsd fd=%d evwatch=%p\n", priv->gps->gps_fd, priv->evwatch);
- event_remove_timeout(priv->retry_timer2);
- priv->retry_timer2=NULL;
- return FALSE;
+ priv->cb = callback_new_1(callback_cast(vehicle_gpsd_io), priv);
+ priv->cbt = callback_new_1(callback_cast(vehicle_gpsd_try_open), priv);
+ priv->evwatch = event_add_watch(priv->gps->gps_fd, event_watch_cond_read, priv->cb);
+ if (!priv->gps->gps_fd) {
+ dbg(lvl_error,"Warning: gps_fd is 0, most likely you have used a gps.h incompatible to libgps");
+ }
+ dbg(lvl_debug,"Connected to gpsd fd=%d evwatch=%p", priv->gps->gps_fd, priv->evwatch);
+ event_remove_timeout(priv->retry_timer2);
+ priv->retry_timer2=NULL;
+ return FALSE;
}
/**
* Open a connection to gpsd. Will re-try the connection if it fails
*/
-static void
-vehicle_gpsd_open(struct vehicle_priv *priv)
-{
+static void vehicle_gpsd_open(struct vehicle_priv *priv) {
#ifdef HAVE_GPSBT
- char errstr[256] = "";
- /* We need to start gpsd (via gpsbt) first. */
- errno = 0;
- memset(&priv->context, 0, sizeof(gpsbt_t));
- if(gpsbt_start(NULL, 0, 0, 0, errstr, sizeof(errstr),
- 0, &priv->context) < 0) {
- dbg(lvl_error,"Error connecting to GPS with gpsbt: (%d) %s (%s)\n",
- errno, strerror(errno), errstr);
- }
- sleep(1); /* give gpsd time to start */
- dbg(lvl_debug,"gpsbt_start: completed\n");
+ char errstr[256] = "";
+ /* We need to start gpsd (via gpsbt) first. */
+ errno = 0;
+ memset(&priv->context, 0, sizeof(gpsbt_t));
+ if(gpsbt_start(NULL, 0, 0, 0, errstr, sizeof(errstr),
+ 0, &priv->context) < 0) {
+ dbg(lvl_error,"Error connecting to GPS with gpsbt: (%d) %s (%s)",
+ errno, strerror(errno), errstr);
+ }
+ sleep(1); /* give gpsd time to start */
+ dbg(lvl_debug,"gpsbt_start: completed");
#endif
- priv->retry_timer2=NULL;
- if (vehicle_gpsd_try_open(priv))
- priv->retry_timer2=event_add_timeout(priv->retry_interval*1000, 1, priv->cbt);
+ priv->retry_timer2=NULL;
+ if (vehicle_gpsd_try_open(priv))
+ priv->retry_timer2=event_add_timeout(priv->retry_interval*1000, 1, priv->cbt);
}
-static void
-vehicle_gpsd_close(struct vehicle_priv *priv)
-{
+static void vehicle_gpsd_close(struct vehicle_priv *priv) {
#ifdef HAVE_GPSBT
- int err;
+ int err;
#endif
- if (priv->retry_timer2) {
- event_remove_timeout(priv->retry_timer2);
- priv->retry_timer2=NULL;
- }
- if (priv->evwatch) {
- event_remove_watch(priv->evwatch);
- priv->evwatch = NULL;
- }
- if (priv->cb) {
- callback_destroy(priv->cb);
- priv->cb = NULL;
- }
- if (priv->cbt) {
- callback_destroy(priv->cbt);
- priv->cbt = NULL;
- }
- if (priv->gps) {
- gps_close(priv->gps);
+ if (priv->retry_timer2) {
+ event_remove_timeout(priv->retry_timer2);
+ priv->retry_timer2=NULL;
+ }
+ if (priv->evwatch) {
+ event_remove_watch(priv->evwatch);
+ priv->evwatch = NULL;
+ }
+ if (priv->cb) {
+ callback_destroy(priv->cb);
+ priv->cb = NULL;
+ }
+ if (priv->cbt) {
+ callback_destroy(priv->cbt);
+ priv->cbt = NULL;
+ }
+ if (priv->gps) {
+ gps_close(priv->gps);
#if GPSD_API_MAJOR_VERSION >= 5
- g_free(priv->gps);
+ g_free(priv->gps);
#endif
- priv->gps = NULL;
- }
+ priv->gps = NULL;
+ }
#ifdef HAVE_GPSBT
- err = gpsbt_stop(&priv->context);
- if (err < 0) {
- dbg(lvl_error,"Error %d while gpsbt_stop", err);
- }
- dbg(lvl_debug,"gpsbt_stop: completed, (%d)",err);
+ err = gpsbt_stop(&priv->context);
+ if (err < 0) {
+ dbg(lvl_error,"Error %d while gpsbt_stop", err);
+ }
+ dbg(lvl_debug,"gpsbt_stop: completed, (%d)",err);
#endif
}
-static void
-vehicle_gpsd_io(struct vehicle_priv *priv)
-{
- dbg(lvl_debug, "enter\n");
- if (priv->gps) {
- vehicle_last = priv;
+static void vehicle_gpsd_io(struct vehicle_priv *priv) {
+ dbg(lvl_debug, "enter");
+ if (priv->gps) {
+ vehicle_last = priv;
#if GPSD_API_MAJOR_VERSION >= 5
- int read_result;
- /* Read until EOF, in case we are lagging behind.
- * No point in processing old GPS reports. */
- while((read_result=gps_read(priv->gps))>0);
- if(read_result==-1) {
- dbg(lvl_error,"gps_poll failed\n");
- vehicle_gpsd_close(priv);
- vehicle_gpsd_open(priv);
- }
- else {
- const char *buf;
- buf = gps_data(priv->gps);
- vehicle_gpsd_callback(priv->gps,buf,strlen(buf));
- }
+ int read_result;
+ /* Read until EOF, in case we are lagging behind.
+ * No point in processing old GPS reports. */
+#if GPSD_API_MAJOR_VERSION >= 7
+ while((read_result=gps_read(priv->gps, NULL, 0))>0);
+#else
+ while((read_result=gps_read(priv->gps))>0);
+#endif
+ if(read_result==-1) {
+ dbg(lvl_error,"gps_poll failed");
+ vehicle_gpsd_close(priv);
+ vehicle_gpsd_open(priv);
+ } else {
+ const char *buf;
+ buf = gps_data(priv->gps);
+ vehicle_gpsd_callback(priv->gps,buf,strlen(buf));
+ }
#else
- if (gps_poll(priv->gps)) {
- dbg(lvl_error,"gps_poll failed\n");
- vehicle_gpsd_close(priv);
- vehicle_gpsd_open(priv);
- }
+ if (gps_poll(priv->gps)) {
+ dbg(lvl_error,"gps_poll failed");
+ vehicle_gpsd_close(priv);
+ vehicle_gpsd_open(priv);
+ }
#endif
- }
+ }
}
-static void
-vehicle_gpsd_destroy(struct vehicle_priv *priv)
-{
- vehicle_gpsd_close(priv);
- if (priv->source)
- g_free(priv->source);
- if (priv->gpsd_query)
- g_free(priv->gpsd_query);
+static void vehicle_gpsd_destroy(struct vehicle_priv *priv) {
+ vehicle_gpsd_close(priv);
+ if (priv->source)
+ g_free(priv->source);
+ if (priv->gpsd_query)
+ g_free(priv->gpsd_query);
#if GPSD_API_MAJOR_VERSION >= 5
- g_free(priv->gps);
+ g_free(priv->gps);
#endif
- g_free(priv);
+ g_free(priv);
}
-static int
-vehicle_gpsd_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- struct attr * active=NULL;
- switch (type) {
- case attr_position_fix_type:
- attr->u.num = priv->fix_type;
- break;
- case attr_position_height:
- attr->u.numd = &priv->height;
- break;
- case attr_position_speed:
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- attr->u.numd = &priv->direction;
- break;
- case attr_position_hdop:
- attr->u.numd = &priv->hdop;
- break;
- case attr_position_qual:
- attr->u.num = priv->sats;
- break;
- case attr_position_sats_signal:
- attr->u.num = priv->sats_signal;
- break;
- case attr_position_sats_used:
- attr->u.num = priv->sats_used;
- break;
- case attr_position_coord_geo:
- attr->u.coord_geo = &priv->geo;
- break;
- case attr_position_nmea:
- attr->u.str=priv->nmea_data;
- if (! attr->u.str)
- return 0;
- break;
- case attr_position_time_iso8601:
- {
- struct tm tm;
- if (!priv->fix_time)
- return 0;
- if (gmtime_r(&priv->fix_time, &tm)) {
- strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
- "%Y-%m-%dT%TZ", &tm);
- attr->u.str=priv->fixiso8601;
- } else
- return 0;
- }
- break;
- case attr_active:
- active = attr_search(priv->attrs,NULL,attr_active);
- if(active != NULL) {
- attr->u.num=active->u.num;
- return 1;
- } else
- return 0;
- break;
- default:
- return 0;
- }
- attr->type = type;
- return 1;
+static int vehicle_gpsd_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ struct attr * active=NULL;
+ switch (type) {
+ case attr_position_fix_type:
+ attr->u.num = priv->fix_type;
+ break;
+ case attr_position_height:
+ attr->u.numd = &priv->height;
+ break;
+ case attr_position_speed:
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ attr->u.numd = &priv->direction;
+ break;
+ case attr_position_hdop:
+ attr->u.numd = &priv->hdop;
+ break;
+ case attr_position_qual:
+ attr->u.num = priv->sats;
+ break;
+ case attr_position_sats_signal:
+ attr->u.num = priv->sats_signal;
+ break;
+ case attr_position_sats_used:
+ attr->u.num = priv->sats_used;
+ break;
+ case attr_position_coord_geo:
+ attr->u.coord_geo = &priv->geo;
+ break;
+ case attr_position_nmea:
+ attr->u.str=priv->nmea_data;
+ if (! attr->u.str)
+ return 0;
+ break;
+ case attr_position_time_iso8601: {
+ struct tm tm;
+ if (!priv->fix_time)
+ return 0;
+ if (gmtime_r(&priv->fix_time, &tm)) {
+ strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
+ "%Y-%m-%dT%TZ", &tm);
+ attr->u.str=priv->fixiso8601;
+ } else
+ return 0;
+ }
+ break;
+ case attr_active:
+ active = attr_search(priv->attrs,NULL,attr_active);
+ if(active != NULL) {
+ attr->u.num=active->u.num;
+ return 1;
+ } else
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ attr->type = type;
+ return 1;
}
static struct vehicle_methods vehicle_gpsd_methods = {
- vehicle_gpsd_destroy,
- vehicle_gpsd_position_attr_get,
+ vehicle_gpsd_destroy,
+ vehicle_gpsd_position_attr_get,
};
-static struct vehicle_priv *
-vehicle_gpsd_new_gpsd(struct vehicle_methods
- *meth, struct callback_list
- *cbl, struct attr **attrs)
-{
- struct vehicle_priv *ret;
- struct attr *source, *query, *retry_int;
+static struct vehicle_priv *vehicle_gpsd_new_gpsd(struct vehicle_methods
+ *meth, struct callback_list
+ *cbl, struct attr **attrs) {
+ struct vehicle_priv *ret;
+ struct attr *source, *query, *retry_int;
- dbg(lvl_debug, "enter\n");
- source = attr_search(attrs, NULL, attr_source);
- ret = g_new0(struct vehicle_priv, 1);
+ dbg(lvl_debug, "enter");
+ source = attr_search(attrs, NULL, attr_source);
+ ret = g_new0(struct vehicle_priv, 1);
#if GPSD_API_MAJOR_VERSION >= 5
- ret->gps = g_new0(struct gps_data_t, 1);
+ ret->gps = g_new0(struct gps_data_t, 1);
#endif
- ret->source = g_strdup(source->u.str);
- query = attr_search(attrs, NULL, attr_gpsd_query);
- if (query) {
- ret->gpsd_query = g_strconcat(query->u.str, "\n", NULL);
- } else {
- ret->gpsd_query = g_strdup("w+x\n");
- }
- dbg(lvl_debug,"Format string for gpsd_query: %s\n",ret->gpsd_query);
- retry_int = attr_search(attrs, NULL, attr_retry_interval);
- if (retry_int) {
- ret->retry_interval = retry_int->u.num;
- if (ret->retry_interval < MIN_RETRY_INTERVAL) {
- dbg(lvl_error, "Retry interval %d too small, setting to %d\n", ret->retry_interval, MIN_RETRY_INTERVAL);
- ret->retry_interval = MIN_RETRY_INTERVAL;
- }
- } else {
- dbg(lvl_debug, "Retry interval not defined, setting to %d\n", DEFAULT_RETRY_INTERVAL);
- ret->retry_interval = DEFAULT_RETRY_INTERVAL;
- }
- ret->cbl = cbl;
- *meth = vehicle_gpsd_methods;
- ret->attrs = attrs;
- vehicle_gpsd_open(ret);
- return ret;
+ ret->source = g_strdup(source->u.str);
+ query = attr_search(attrs, NULL, attr_gpsd_query);
+ if (query) {
+ ret->gpsd_query = g_strconcat(query->u.str, "\n", NULL);
+ } else {
+ ret->gpsd_query = g_strdup("w+x\n");
+ }
+ dbg(lvl_debug,"Format string for gpsd_query: %s",ret->gpsd_query);
+ retry_int = attr_search(attrs, NULL, attr_retry_interval);
+ if (retry_int) {
+ ret->retry_interval = retry_int->u.num;
+ if (ret->retry_interval < MIN_RETRY_INTERVAL) {
+ dbg(lvl_error, "Retry interval %d too small, setting to %d", ret->retry_interval, MIN_RETRY_INTERVAL);
+ ret->retry_interval = MIN_RETRY_INTERVAL;
+ }
+ } else {
+ dbg(lvl_debug, "Retry interval not defined, setting to %d", DEFAULT_RETRY_INTERVAL);
+ ret->retry_interval = DEFAULT_RETRY_INTERVAL;
+ }
+ ret->cbl = cbl;
+ *meth = vehicle_gpsd_methods;
+ ret->attrs = attrs;
+ vehicle_gpsd_open(ret);
+ return ret;
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("gpsd", vehicle_gpsd_new_gpsd);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("gpsd", vehicle_gpsd_new_gpsd);
}
diff --git a/navit/vehicle/gpsd_dbus/CMakeLists.txt b/navit/vehicle/gpsd_dbus/CMakeLists.txt
index 435a987a0..a38e65539 100644
--- a/navit/vehicle/gpsd_dbus/CMakeLists.txt
+++ b/navit/vehicle/gpsd_dbus/CMakeLists.txt
@@ -1,2 +1,2 @@
-module_add_library(vehicle_gpsd_dbus vehicle_gpsd_dbus.c)
+module_add_library(vehicle_gpsd_dbus vehicle_gpsd_dbus.c)
diff --git a/navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c b/navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c
index fa5eb8780..0ce18a1d3 100644
--- a/navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c
+++ b/navit/vehicle/gpsd_dbus/vehicle_gpsd_dbus.c
@@ -1,4 +1,4 @@
-/**
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -34,215 +34,204 @@
#include "vehicle.h"
#include "event.h"
+/**
+ * @defgroup vehicle-gpsd-dbus Vehicle Gpsd DBus
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from Gpsd over DBus
+ *
+ * @{
+ */
+
static char *vehicle_gpsd_dbus_prefix="gpsd_dbus:";
struct vehicle_priv {
- char *source;
- char *address;
- int flags;
- struct callback_list *cbl;
- DBusConnection *connection;
- double time, track, speed, altitude;
- time_t fix_time;
- struct coord_geo geo;
- struct attr ** attrs;
- char fixiso8601[128];
+ char *source;
+ char *address;
+ int flags;
+ struct callback_list *cbl;
+ DBusConnection *connection;
+ double time, track, speed, altitude;
+ time_t fix_time;
+ struct coord_geo geo;
+ struct attr ** attrs;
+ char fixiso8601[128];
};
-static void
-vehicle_gpsd_dbus_close(struct vehicle_priv *priv)
-{
- if (priv->connection)
- dbus_connection_unref(priv->connection);
- priv->connection=NULL;
+static void vehicle_gpsd_dbus_close(struct vehicle_priv *priv) {
+ if (priv->connection)
+ dbus_connection_unref(priv->connection);
+ priv->connection=NULL;
}
-static DBusHandlerResult
-vehicle_gpsd_dbus_filter(DBusConnection *connection, DBusMessage *message, void *user_data)
-{
- struct vehicle_priv *priv=user_data;
- double time,ept,latitude,longitude,eph,altitude,epv,track,epd,speed,eps,climb,epc;
- int mode;
- char *devname;
-
- if (dbus_message_is_signal(message, "org.gpsd","fix")) {
- dbus_message_get_args (message, NULL,
- DBUS_TYPE_DOUBLE, &time,
- DBUS_TYPE_INT32, &mode,
- DBUS_TYPE_DOUBLE, &ept,
- DBUS_TYPE_DOUBLE, &latitude,
- DBUS_TYPE_DOUBLE, &longitude,
- DBUS_TYPE_DOUBLE, &eph,
- DBUS_TYPE_DOUBLE, &altitude,
- DBUS_TYPE_DOUBLE, &epv,
- DBUS_TYPE_DOUBLE, &track,
- DBUS_TYPE_DOUBLE, &epd,
- DBUS_TYPE_DOUBLE, &speed,
- DBUS_TYPE_DOUBLE, &eps,
- DBUS_TYPE_DOUBLE, &climb,
- DBUS_TYPE_DOUBLE, &epc,
- DBUS_TYPE_STRING, &devname,
- DBUS_TYPE_INVALID);
- if (!isnan(latitude) && !isnan(longitude)) {
- priv->geo.lat=latitude;
- priv->geo.lng=longitude;
- }
- if (!isnan(track))
- priv->track=track;
- if (!isnan(speed))
- priv->speed=speed;
- if (!isnan(altitude))
- priv->altitude=altitude;
- if (time != priv->time || (priv->flags & 1)) {
- priv->time=time;
- priv->fix_time=time;
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
- }
- }
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+static DBusHandlerResult vehicle_gpsd_dbus_filter(DBusConnection *connection, DBusMessage *message, void *user_data) {
+ struct vehicle_priv *priv=user_data;
+ double time,ept,latitude,longitude,eph,altitude,epv,track,epd,speed,eps,climb,epc;
+ int mode;
+ char *devname;
+
+ if (dbus_message_is_signal(message, "org.gpsd","fix")) {
+ dbus_message_get_args (message, NULL,
+ DBUS_TYPE_DOUBLE, &time,
+ DBUS_TYPE_INT32, &mode,
+ DBUS_TYPE_DOUBLE, &ept,
+ DBUS_TYPE_DOUBLE, &latitude,
+ DBUS_TYPE_DOUBLE, &longitude,
+ DBUS_TYPE_DOUBLE, &eph,
+ DBUS_TYPE_DOUBLE, &altitude,
+ DBUS_TYPE_DOUBLE, &epv,
+ DBUS_TYPE_DOUBLE, &track,
+ DBUS_TYPE_DOUBLE, &epd,
+ DBUS_TYPE_DOUBLE, &speed,
+ DBUS_TYPE_DOUBLE, &eps,
+ DBUS_TYPE_DOUBLE, &climb,
+ DBUS_TYPE_DOUBLE, &epc,
+ DBUS_TYPE_STRING, &devname,
+ DBUS_TYPE_INVALID);
+ if (!isnan(latitude) && !isnan(longitude)) {
+ priv->geo.lat=latitude;
+ priv->geo.lng=longitude;
+ }
+ if (!isnan(track))
+ priv->track=track;
+ if (!isnan(speed))
+ priv->speed=speed;
+ if (!isnan(altitude))
+ priv->altitude=altitude;
+ if (time != priv->time || (priv->flags & 1)) {
+ priv->time=time;
+ priv->fix_time=time;
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+ }
+ }
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-static int
-vehicle_gpsd_dbus_open(struct vehicle_priv *priv)
-{
- DBusError error;
-
- dbus_error_init(&error);
- if (priv->address) {
- priv->connection = dbus_connection_open(priv->address, &error);
- } else {
- priv->connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
- }
- if (!priv->connection) {
- dbg(lvl_error,"Failed to open connection to %s message bus: %s\n", priv->address?priv->address:"session",error.message);
- dbus_error_free(&error);
- return 0;
- }
- dbus_connection_setup_with_g_main(priv->connection, NULL);
- dbus_bus_add_match(priv->connection,"type='signal',interface='org.gpsd'",&error);
- dbus_connection_flush(priv->connection);
- if (dbus_error_is_set(&error)) {
- dbg(lvl_error,"Failed to add match to connection: %s\n", error.message);
- vehicle_gpsd_dbus_close(priv);
- return 0;
- }
- if (!dbus_connection_add_filter(priv->connection, vehicle_gpsd_dbus_filter, priv, NULL)) {
- dbg(lvl_error,"Failed to add filter to connection\n");
- vehicle_gpsd_dbus_close(priv);
- return 0;
- }
- return 1;
+static int vehicle_gpsd_dbus_open(struct vehicle_priv *priv) {
+ DBusError error;
+
+ dbus_error_init(&error);
+ if (priv->address) {
+ priv->connection = dbus_connection_open(priv->address, &error);
+ } else {
+ priv->connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ }
+ if (!priv->connection) {
+ dbg(lvl_error,"Failed to open connection to %s message bus: %s", priv->address?priv->address:"session",error.message);
+ dbus_error_free(&error);
+ return 0;
+ }
+ dbus_connection_setup_with_g_main(priv->connection, NULL);
+ dbus_bus_add_match(priv->connection,"type='signal',interface='org.gpsd'",&error);
+ dbus_connection_flush(priv->connection);
+ if (dbus_error_is_set(&error)) {
+ dbg(lvl_error,"Failed to add match to connection: %s", error.message);
+ vehicle_gpsd_dbus_close(priv);
+ return 0;
+ }
+ if (!dbus_connection_add_filter(priv->connection, vehicle_gpsd_dbus_filter, priv, NULL)) {
+ dbg(lvl_error,"Failed to add filter to connection");
+ vehicle_gpsd_dbus_close(priv);
+ return 0;
+ }
+ return 1;
}
-static void
-vehicle_gpsd_dbus_destroy(struct vehicle_priv *priv)
-{
- vehicle_gpsd_dbus_close(priv);
- if (priv->source)
- g_free(priv->source);
- g_free(priv);
+static void vehicle_gpsd_dbus_destroy(struct vehicle_priv *priv) {
+ vehicle_gpsd_dbus_close(priv);
+ if (priv->source)
+ g_free(priv->source);
+ g_free(priv);
}
-static int
-vehicle_gpsd_dbus_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_position_height:
- attr->u.numd = &priv->altitude;
- break;
- case attr_position_speed:
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- attr->u.numd = &priv->track;
- break;
- case attr_position_coord_geo:
- attr->u.coord_geo = &priv->geo;
- break;
- case attr_position_time_iso8601:
- {
- struct tm tm;
- if (!priv->fix_time)
- return 0;
- if (gmtime_r(&priv->fix_time, &tm)) {
- strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
- "%Y-%m-%dT%TZ", &tm);
- attr->u.str=priv->fixiso8601;
- } else
- return 0;
- }
- break;
- default:
- return 0;
- }
- attr->type = type;
- return 1;
+static int vehicle_gpsd_dbus_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ switch (type) {
+ case attr_position_height:
+ attr->u.numd = &priv->altitude;
+ break;
+ case attr_position_speed:
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ attr->u.numd = &priv->track;
+ break;
+ case attr_position_coord_geo:
+ attr->u.coord_geo = &priv->geo;
+ break;
+ case attr_position_time_iso8601: {
+ struct tm tm;
+ if (!priv->fix_time)
+ return 0;
+ if (gmtime_r(&priv->fix_time, &tm)) {
+ strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
+ "%Y-%m-%dT%TZ", &tm);
+ attr->u.str=priv->fixiso8601;
+ } else
+ return 0;
+ }
+ break;
+ default:
+ return 0;
+ }
+ attr->type = type;
+ return 1;
}
-static int
-vehicle_gpsd_dbus_set_attr_do(struct vehicle_priv *priv, struct attr *attr, int init)
-{
- switch (attr->type) {
- case attr_source:
- if (strncmp(vehicle_gpsd_dbus_prefix,attr->u.str,strlen(vehicle_gpsd_dbus_prefix))) {
- dbg(lvl_error,"source must start with '%s'\n", vehicle_gpsd_dbus_prefix);
- return 0;
- }
- g_free(priv->source);
- priv->source=g_strdup(attr->u.str);
- priv->address=priv->source+strlen(vehicle_gpsd_dbus_prefix);
- if (!priv->address[0])
- priv->address=NULL;
- if (!init) {
- vehicle_gpsd_dbus_close(priv);
- vehicle_gpsd_dbus_open(priv);
- }
- return 1;
- case attr_flags:
- priv->flags=attr->u.num;
- return 1;
- default:
- return 0;
- }
+static int vehicle_gpsd_dbus_set_attr_do(struct vehicle_priv *priv, struct attr *attr, int init) {
+ switch (attr->type) {
+ case attr_source:
+ if (strncmp(vehicle_gpsd_dbus_prefix,attr->u.str,strlen(vehicle_gpsd_dbus_prefix))) {
+ dbg(lvl_error,"source must start with '%s'", vehicle_gpsd_dbus_prefix);
+ return 0;
+ }
+ g_free(priv->source);
+ priv->source=g_strdup(attr->u.str);
+ priv->address=priv->source+strlen(vehicle_gpsd_dbus_prefix);
+ if (!priv->address[0])
+ priv->address=NULL;
+ if (!init) {
+ vehicle_gpsd_dbus_close(priv);
+ vehicle_gpsd_dbus_open(priv);
+ }
+ return 1;
+ case attr_flags:
+ priv->flags=attr->u.num;
+ return 1;
+ default:
+ return 0;
+ }
}
-static int
-vehicle_gpsd_dbus_set_attr(struct vehicle_priv *priv, struct attr *attr)
-{
- return vehicle_gpsd_dbus_set_attr_do(priv, attr, 0);
+static int vehicle_gpsd_dbus_set_attr(struct vehicle_priv *priv, struct attr *attr) {
+ return vehicle_gpsd_dbus_set_attr_do(priv, attr, 0);
}
static struct vehicle_methods vehicle_gpsd_methods = {
- vehicle_gpsd_dbus_destroy,
- vehicle_gpsd_dbus_position_attr_get,
- vehicle_gpsd_dbus_set_attr,
+ vehicle_gpsd_dbus_destroy,
+ vehicle_gpsd_dbus_position_attr_get,
+ vehicle_gpsd_dbus_set_attr,
};
-static struct vehicle_priv *
-vehicle_gpsd_dbus_new(struct vehicle_methods
- *meth, struct callback_list
- *cbl, struct attr **attrs)
-{
- struct vehicle_priv *ret;
-
-
- ret = g_new0(struct vehicle_priv, 1);
- ret->attrs = attrs;
- ret->cbl = cbl;
- *meth = vehicle_gpsd_methods;
- while (*attrs) {
- vehicle_gpsd_dbus_set_attr_do(ret, *attrs, 1);
- attrs++;
- }
- vehicle_gpsd_dbus_open(ret);
- return ret;
+static struct vehicle_priv *vehicle_gpsd_dbus_new(struct vehicle_methods
+ *meth, struct callback_list
+ *cbl, struct attr **attrs) {
+ struct vehicle_priv *ret;
+
+
+ ret = g_new0(struct vehicle_priv, 1);
+ ret->attrs = attrs;
+ ret->cbl = cbl;
+ *meth = vehicle_gpsd_methods;
+ while (*attrs) {
+ vehicle_gpsd_dbus_set_attr_do(ret, *attrs, 1);
+ attrs++;
+ }
+ vehicle_gpsd_dbus_open(ret);
+ return ret;
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("gpsd_dbus", vehicle_gpsd_dbus_new);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("gpsd_dbus", vehicle_gpsd_dbus_new);
}
diff --git a/navit/vehicle/gypsy/vehicle_gypsy.c b/navit/vehicle/gypsy/vehicle_gypsy.c
index 589e53a3f..077f219a1 100644
--- a/navit/vehicle/gypsy/vehicle_gypsy.c
+++ b/navit/vehicle/gypsy/vehicle_gypsy.c
@@ -1,6 +1,4 @@
-/** @file vehicle_gypsy.c
- * @brief gypsy uses dbus signals
- *
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -18,8 +16,6 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
- * @Author Tim Niemeyer <reddog@mastersword.de>
- * @date 2008-2009
*/
#include <config.h>
@@ -47,28 +43,38 @@
#include "item.h"
#include "vehicle.h"
+/**
+ * @defgroup vehicle-gypsy Vehicle gypsy
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from gypsy. gypsy uses dbus signals
+ * @Author Tim Niemeyer <reddog@mastersword.de>
+ * @date 2008-2009
+ *
+ * @{
+ */
+
static struct vehicle_priv {
- char *source;
- GypsyControl *control;
- GypsyPosition *position;
- GypsyDevice *device;
- GypsyCourse *course;
- GypsySatellite *satellite;
- char *path;
- struct callback_list *cbl;
- guint retry_interval;
- struct coord_geo geo;
- double speed;
- double direction;
- double height;
- int fix_type;
- time_t fix_time;
- char fixiso8601[128];
- int sats;
- int sats_used;
- guint retry_timer;
- struct attr ** attrs;
- int have_cords;
+ char *source;
+ GypsyControl *control;
+ GypsyPosition *position;
+ GypsyDevice *device;
+ GypsyCourse *course;
+ GypsySatellite *satellite;
+ char *path;
+ struct callback_list *cbl;
+ guint retry_interval;
+ struct coord_geo geo;
+ double speed;
+ double direction;
+ double height;
+ int fix_type;
+ time_t fix_time;
+ char fixiso8601[128];
+ int sats;
+ int sats_used;
+ guint retry_timer;
+ struct attr ** attrs;
+ int have_cords;
} *vehicle_last;
#define DEFAULT_RETRY_INTERVAL 10 // seconds
@@ -85,27 +91,25 @@ static struct vehicle_priv {
*
* Anytime this functions get called, we have to call the global
* callback.
- *
+ *
* @param device The GypsyDevice
* @param fixstatus The fisstatus 0, 1, 2 or 3
* @param userdata
* @returns nothing
*/
-static void
-vehicle_gypsy_fixstatus_changed(GypsyDevice *device,
- gint fixstatus,
- gpointer userdata)
-{
- struct vehicle_priv *priv = vehicle_last;
-
- if (fixstatus==GYPSY_DEVICE_FIX_STATUS_3D)
- priv->fix_type = 3;
- else if (fixstatus==GYPSY_DEVICE_FIX_STATUS_2D)
- priv->fix_type = 1;
- else
- priv->fix_type = 0;
-
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+static void vehicle_gypsy_fixstatus_changed(GypsyDevice *device,
+ gint fixstatus,
+ gpointer userdata) {
+ struct vehicle_priv *priv = vehicle_last;
+
+ if (fixstatus==GYPSY_DEVICE_FIX_STATUS_3D)
+ priv->fix_type = 3;
+ else if (fixstatus==GYPSY_DEVICE_FIX_STATUS_2D)
+ priv->fix_type = 1;
+ else
+ priv->fix_type = 0;
+
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
}
/**
@@ -119,49 +123,43 @@ vehicle_gypsy_fixstatus_changed(GypsyDevice *device,
*
* If we get any new information, we have to call the global
* callback.
- *
+ *
* @param position The GypsyPosition
- * @param fields_set Bitmask indicating what field was set
+ * @param fields_set Bitmask indicating what field was set
* @param timestamp the time since Unix Epoch
- * @param latitude
- * @param longitude
+ * @param latitude
+ * @param longitude
* @param altitude
* @param userdata
* @returns nothing
*/
-static void
-vehicle_gypsy_position_changed(GypsyPosition *position,
- GypsyPositionFields fields_set, int timestamp,
- double latitude, double longitude, double altitude,
- gpointer userdata)
-{
- struct vehicle_priv *priv = vehicle_last;
- int cb = FALSE;
-
- if (timestamp > 0)
- priv->fix_time = timestamp;
-
- if (fields_set & GYPSY_POSITION_FIELDS_LATITUDE)
- {
- cb = TRUE;
- priv->geo.lat = latitude;
- }
- if (fields_set & GYPSY_POSITION_FIELDS_LONGITUDE)
- {
- cb = TRUE;
- priv->geo.lng = longitude;
- }
- if (fields_set & GYPSY_POSITION_FIELDS_ALTITUDE)
- {
- cb = TRUE;
- priv->height = altitude;
- }
-
- if (cb)
- {
- priv->have_cords = 1;
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
- }
+static void vehicle_gypsy_position_changed(GypsyPosition *position,
+ GypsyPositionFields fields_set, int timestamp,
+ double latitude, double longitude, double altitude,
+ gpointer userdata) {
+ struct vehicle_priv *priv = vehicle_last;
+ int cb = FALSE;
+
+ if (timestamp > 0)
+ priv->fix_time = timestamp;
+
+ if (fields_set & GYPSY_POSITION_FIELDS_LATITUDE) {
+ cb = TRUE;
+ priv->geo.lat = latitude;
+ }
+ if (fields_set & GYPSY_POSITION_FIELDS_LONGITUDE) {
+ cb = TRUE;
+ priv->geo.lng = longitude;
+ }
+ if (fields_set & GYPSY_POSITION_FIELDS_ALTITUDE) {
+ cb = TRUE;
+ priv->height = altitude;
+ }
+
+ if (cb) {
+ priv->have_cords = 1;
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+ }
}
/**
@@ -172,31 +170,29 @@ vehicle_gypsy_position_changed(GypsyPosition *position,
* Anytime this functions get called, we have to call the global
* callback.
*
- * @param satellite The GypsySatellite
+ * @param satellite The GypsySatellite
* @param satellites An GPtrArray wich hold information of all sats
* @param userdata
* @returns nothing
*/
-static void
-vehicle_gypsy_satellite_changed(GypsySatellite *satellite,
- GPtrArray *satellites,
- gpointer userdata)
-{
- struct vehicle_priv *priv = vehicle_last;
-
- int i, sats, used=0;
-
- sats = satellites->len;
- for (i = 0; i < sats; i++) {
- GypsySatelliteDetails *details = satellites->pdata[i];
- if (details->in_use)
- used++;
- }
-
- priv->sats_used = used;
- priv->sats = sats;
-
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+static void vehicle_gypsy_satellite_changed(GypsySatellite *satellite,
+ GPtrArray *satellites,
+ gpointer userdata) {
+ struct vehicle_priv *priv = vehicle_last;
+
+ int i, sats, used=0;
+
+ sats = satellites->len;
+ for (i = 0; i < sats; i++) {
+ GypsySatelliteDetails *details = satellites->pdata[i];
+ if (details->in_use)
+ used++;
+ }
+
+ priv->sats_used = used;
+ priv->sats = sats;
+
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
}
/**
@@ -206,9 +202,9 @@ vehicle_gypsy_satellite_changed(GypsySatellite *satellite,
*
* If we get any new information, we have to call the global
* callback.
- *
+ *
* @param course The GypsyCourse
- * @param fields Bitmask indicating what field was set
+ * @param fields Bitmask indicating what field was set
* @param timestamp the time since Unix Epoch
* @param speed
* @param direction
@@ -216,282 +212,263 @@ vehicle_gypsy_satellite_changed(GypsySatellite *satellite,
* @param userdata
* @returns nothing
*/
-static void
-vehicle_gypsy_course_changed (GypsyCourse *course,
- GypsyCourseFields fields,
- int timestamp,
- double speed,
- double direction,
- double climb,
- gpointer userdata)
-{
- struct vehicle_priv *priv = vehicle_last;
- int cb = FALSE;
-
- if (fields & GYPSY_COURSE_FIELDS_SPEED)
- {
- priv->speed = speed*3.6;
- cb = TRUE;
- }
- if (fields & GYPSY_COURSE_FIELDS_DIRECTION)
- {
- priv->direction = direction;
- cb = TRUE;
- }
-
- if (cb)
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+static void vehicle_gypsy_course_changed (GypsyCourse *course,
+ GypsyCourseFields fields,
+ int timestamp,
+ double speed,
+ double direction,
+ double climb,
+ gpointer userdata) {
+ struct vehicle_priv *priv = vehicle_last;
+ int cb = FALSE;
+
+ if (fields & GYPSY_COURSE_FIELDS_SPEED) {
+ priv->speed = speed*3.6;
+ cb = TRUE;
+ }
+ if (fields & GYPSY_COURSE_FIELDS_DIRECTION) {
+ priv->direction = direction;
+ cb = TRUE;
+ }
+
+ if (cb)
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
}
/**
* @brief Attempt to open the gypsy device.
- *
+ *
* Tells gypsy wich functions to call when anything occours.
*
* @param data
* @returns TRUE to try again; FALSE if retry not required
*/
-static gboolean
-vehicle_gypsy_try_open(gpointer *data)
-{
- struct vehicle_priv *priv = (struct vehicle_priv *)data;
- char *source = g_strdup(priv->source);
-
- GError *error = NULL;
-
- g_type_init();
- priv->control = gypsy_control_get_default();
- priv->path = gypsy_control_create(priv->control, source+8, &error);
- if (priv->path == NULL) {
- g_warning ("Error creating gypsy conrtol path for %s: %s", source+8, error->message);
- return TRUE;
- }
-
- priv->position = gypsy_position_new(priv->path);
- g_signal_connect(priv->position, "position-changed", G_CALLBACK (vehicle_gypsy_position_changed), NULL);
-
- priv->satellite = gypsy_satellite_new(priv->path);
- g_signal_connect(priv->satellite, "satellites-changed", G_CALLBACK (vehicle_gypsy_satellite_changed), NULL);
-
- priv->course = gypsy_course_new(priv->path);
- g_signal_connect(priv->course, "course-changed", G_CALLBACK (vehicle_gypsy_course_changed), NULL);
-
- priv->device = gypsy_device_new(priv->path);
- g_signal_connect(priv->device, "fix-status-changed", G_CALLBACK (vehicle_gypsy_fixstatus_changed), NULL);
-
- gypsy_device_start(priv->device, &error);
- if (error != NULL) {
- g_warning ("Error starting gypsy for %s: %s", source+8, error->message);
- return TRUE;
- }
-
- vehicle_last = priv;
- dbg(lvl_debug,"gypsy connected to %d\n", source+8);
- g_free(source);
- return FALSE;
+static gboolean vehicle_gypsy_try_open(gpointer *data) {
+ struct vehicle_priv *priv = (struct vehicle_priv *)data;
+ char *source = g_strdup(priv->source);
+
+ GError *error = NULL;
+
+ g_type_init();
+ priv->control = gypsy_control_get_default();
+ priv->path = gypsy_control_create(priv->control, source+8, &error);
+ if (priv->path == NULL) {
+ g_warning ("Error creating gypsy conrtol path for %s: %s", source+8, error->message);
+ return TRUE;
+ }
+
+ priv->position = gypsy_position_new(priv->path);
+ g_signal_connect(priv->position, "position-changed", G_CALLBACK (vehicle_gypsy_position_changed), NULL);
+
+ priv->satellite = gypsy_satellite_new(priv->path);
+ g_signal_connect(priv->satellite, "satellites-changed", G_CALLBACK (vehicle_gypsy_satellite_changed), NULL);
+
+ priv->course = gypsy_course_new(priv->path);
+ g_signal_connect(priv->course, "course-changed", G_CALLBACK (vehicle_gypsy_course_changed), NULL);
+
+ priv->device = gypsy_device_new(priv->path);
+ g_signal_connect(priv->device, "fix-status-changed", G_CALLBACK (vehicle_gypsy_fixstatus_changed), NULL);
+
+ gypsy_device_start(priv->device, &error);
+ if (error != NULL) {
+ g_warning ("Error starting gypsy for %s: %s", source+8, error->message);
+ return TRUE;
+ }
+
+ vehicle_last = priv;
+ dbg(lvl_debug,"gypsy connected to %d", source+8);
+ g_free(source);
+ return FALSE;
}
/**
* @brief Open a connection to gypsy. Will re-try the connection if it fails
- *
+ *
* @param priv
* @returns nothing
*/
-static void
-vehicle_gypsy_open(struct vehicle_priv *priv)
-{
- priv->retry_timer=0;
- if (vehicle_gypsy_try_open((gpointer *)priv)) {
- priv->retry_timer = g_timeout_add(priv->retry_interval*1000, (GSourceFunc)vehicle_gypsy_try_open, (gpointer *)priv);
- }
+static void vehicle_gypsy_open(struct vehicle_priv *priv) {
+ priv->retry_timer=0;
+ if (vehicle_gypsy_try_open((gpointer *)priv)) {
+ priv->retry_timer = g_timeout_add(priv->retry_interval*1000, (GSourceFunc)vehicle_gypsy_try_open, (gpointer *)priv);
+ }
}
/**
* @brief Stop retry timer; Free alloced memory
- *
+ *
* @param priv
* @returns nothing
*/
-static void
-vehicle_gypsy_close(struct vehicle_priv *priv)
-{
- if (priv->retry_timer) {
- g_source_remove(priv->retry_timer);
- priv->retry_timer=0;
- }
- if (priv->path)
- g_free(priv->path);
-
- if (priv->position)
- g_free(priv->position);
-
- if (priv->satellite)
- g_free(priv->satellite);
-
- if (priv->course)
- g_free(priv->course);
-
- if (priv->device)
- g_free(priv->device);
-
- if (priv->control)
- g_object_unref(G_OBJECT (priv->control));
+static void vehicle_gypsy_close(struct vehicle_priv *priv) {
+ if (priv->retry_timer) {
+ g_source_remove(priv->retry_timer);
+ priv->retry_timer=0;
+ }
+ if (priv->path)
+ g_free(priv->path);
+
+ if (priv->position)
+ g_free(priv->position);
+
+ if (priv->satellite)
+ g_free(priv->satellite);
+
+ if (priv->course)
+ g_free(priv->course);
+
+ if (priv->device)
+ g_free(priv->device);
+
+ if (priv->control)
+ g_object_unref(G_OBJECT (priv->control));
}
/**
* @brief Free the gypsy_vehicle
- *
+ *
* @param priv
* @returns nothing
*/
-static void
-vehicle_gypsy_destroy(struct vehicle_priv *priv)
-{
- vehicle_gypsy_close(priv);
- if (priv->source)
- g_free(priv->source);
- g_free(priv);
+static void vehicle_gypsy_destroy(struct vehicle_priv *priv) {
+ vehicle_gypsy_close(priv);
+ if (priv->source)
+ g_free(priv->source);
+ g_free(priv);
}
/**
* @brief Provide the outside with information
- *
+ *
* @param priv
* @param type TODO: What can this be?
* @param attr
* @returns true/false
*/
-static int
-vehicle_gypsy_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- struct attr * active=NULL;
- switch (type) {
- case attr_position_fix_type:
- attr->u.num = priv->fix_type;
- break;
- case attr_position_height:
- attr->u.numd = &priv->height;
- break;
- case attr_position_speed:
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- attr->u.numd = &priv->direction;
- break;
- case attr_position_qual:
- attr->u.num = priv->sats;
- break;
- case attr_position_sats_used:
- attr->u.num = priv->sats_used;
- break;
- case attr_position_coord_geo:
- attr->u.coord_geo = &priv->geo;
- if (!priv->have_cords)
- return 0;
- break;
- case attr_position_time_iso8601:
- {
- struct tm tm;
- if (!priv->fix_time)
- return 0;
- if (gmtime_r(&priv->fix_time, &tm)) {
- strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
- "%Y-%m-%dT%TZ", &tm);
- attr->u.str=priv->fixiso8601;
- } else
- return 0;
- }
- case attr_active:
- active = attr_search(priv->attrs,NULL,attr_active);
- if(active != NULL && active->u.num == 1)
- return 1;
- else
- return 0;
- break;
-
- default:
- return 0;
- }
- attr->type = type;
- return 1;
+static int vehicle_gypsy_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ struct attr * active=NULL;
+ switch (type) {
+ case attr_position_fix_type:
+ attr->u.num = priv->fix_type;
+ break;
+ case attr_position_height:
+ attr->u.numd = &priv->height;
+ break;
+ case attr_position_speed:
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ attr->u.numd = &priv->direction;
+ break;
+ case attr_position_qual:
+ attr->u.num = priv->sats;
+ break;
+ case attr_position_sats_used:
+ attr->u.num = priv->sats_used;
+ break;
+ case attr_position_coord_geo:
+ attr->u.coord_geo = &priv->geo;
+ if (!priv->have_cords)
+ return 0;
+ break;
+ case attr_position_time_iso8601: {
+ struct tm tm;
+ if (!priv->fix_time)
+ return 0;
+ if (gmtime_r(&priv->fix_time, &tm)) {
+ strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
+ "%Y-%m-%dT%TZ", &tm);
+ attr->u.str=priv->fixiso8601;
+ } else
+ return 0;
+ }
+ case attr_active:
+ active = attr_search(priv->attrs,NULL,attr_active);
+ if(active != NULL && active->u.num == 1)
+ return 1;
+ else
+ return 0;
+ break;
+
+ default:
+ return 0;
+ }
+ attr->type = type;
+ return 1;
}
struct vehicle_methods vehicle_gypsy_methods = {
- vehicle_gypsy_destroy,
- vehicle_gypsy_position_attr_get,
+ vehicle_gypsy_destroy,
+ vehicle_gypsy_position_attr_get,
};
/**
* @brief Create gypsy_vehicle
- *
+ *
* @param meth
* @param cbl
* @param attrs
* @returns vehicle_priv
*/
-static struct vehicle_priv *
-vehicle_gypsy_new_gypsy(struct vehicle_methods *meth,
- struct callback_list *cbl,
- struct attr **attrs)
-{
- struct vehicle_priv *ret;
- struct attr *source, *retry_int;
+static struct vehicle_priv *vehicle_gypsy_new_gypsy(struct vehicle_methods *meth,
+ struct callback_list *cbl,
+ struct attr **attrs) {
+ struct vehicle_priv *ret;
+ struct attr *source, *retry_int;
#if defined(USE_BINDING_DBUS) && defined(HAVE_UNISTD_H)
- DBusConnection *conn;
- DBusMessage *message;
- dbus_uint32_t serial,pid=getpid();
- struct attr *destination,*path,*interface,*method;
-
- destination=attr_search(attrs, NULL, attr_dbus_destination);
- path=attr_search(attrs, NULL, attr_dbus_path);
- interface=attr_search(attrs, NULL, attr_dbus_interface);
- method=attr_search(attrs, NULL, attr_dbus_method);
- if (destination && path && interface && method) {
- conn=dbus_bus_get(DBUS_BUS_SESSION, NULL);
- if (conn) {
- message=dbus_message_new_method_call(destination->u.str,path->u.str,interface->u.str,method->u.str);
- dbus_message_append_args(message, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
- dbus_connection_send(conn, message, &serial);
- dbus_message_unref(message);
- dbus_connection_unref(conn);
- } else {
- dbg(lvl_error,"failed to connect to session bus\n");
- }
- }
+ DBusConnection *conn;
+ DBusMessage *message;
+ dbus_uint32_t serial,pid=getpid();
+ struct attr *destination,*path,*interface,*method;
+
+ destination=attr_search(attrs, NULL, attr_dbus_destination);
+ path=attr_search(attrs, NULL, attr_dbus_path);
+ interface=attr_search(attrs, NULL, attr_dbus_interface);
+ method=attr_search(attrs, NULL, attr_dbus_method);
+ if (destination && path && interface && method) {
+ conn=dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ if (conn) {
+ message=dbus_message_new_method_call(destination->u.str,path->u.str,interface->u.str,method->u.str);
+ dbus_message_append_args(message, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
+ dbus_connection_send(conn, message, &serial);
+ dbus_message_unref(message);
+ dbus_connection_unref(conn);
+ } else {
+ dbg(lvl_error,"failed to connect to session bus");
+ }
+ }
#endif
- dbg(lvl_debug, "enter\n");
- source = attr_search(attrs, NULL, attr_source);
- ret = g_new0(struct vehicle_priv, 1);
- ret->have_cords = 0;
- ret->source = g_strdup(source->u.str);
- ret->attrs = attrs;
- retry_int = attr_search(attrs, NULL, attr_retry_interval);
- if (retry_int) {
- ret->retry_interval = retry_int->u.num;
- if (ret->retry_interval < MIN_RETRY_INTERVAL) {
- dbg(lvl_error, "Retry interval %d too small, setting to %d\n", ret->retry_interval, MIN_RETRY_INTERVAL);
- ret->retry_interval = MIN_RETRY_INTERVAL;
- }
- } else {
- dbg(lvl_error, "Retry interval not defined, setting to %d\n", DEFAULT_RETRY_INTERVAL);
- ret->retry_interval = DEFAULT_RETRY_INTERVAL;
- }
- ret->cbl = cbl;
- *meth = vehicle_gypsy_methods;
- vehicle_gypsy_open(ret);
- return ret;
+ dbg(lvl_debug, "enter");
+ source = attr_search(attrs, NULL, attr_source);
+ ret = g_new0(struct vehicle_priv, 1);
+ ret->have_cords = 0;
+ ret->source = g_strdup(source->u.str);
+ ret->attrs = attrs;
+ retry_int = attr_search(attrs, NULL, attr_retry_interval);
+ if (retry_int) {
+ ret->retry_interval = retry_int->u.num;
+ if (ret->retry_interval < MIN_RETRY_INTERVAL) {
+ dbg(lvl_error, "Retry interval %d too small, setting to %d", ret->retry_interval, MIN_RETRY_INTERVAL);
+ ret->retry_interval = MIN_RETRY_INTERVAL;
+ }
+ } else {
+ dbg(lvl_error, "Retry interval not defined, setting to %d", DEFAULT_RETRY_INTERVAL);
+ ret->retry_interval = DEFAULT_RETRY_INTERVAL;
+ }
+ ret->cbl = cbl;
+ *meth = vehicle_gypsy_methods;
+ vehicle_gypsy_open(ret);
+ return ret;
}
/**
* @brief register vehicle_gypsy
- *
+ *
* @returns nothing
*/
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("gypsy", vehicle_gypsy_new_gypsy);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("gypsy", vehicle_gypsy_new_gypsy);
}
diff --git a/navit/vehicle/iphone/corelocation.h b/navit/vehicle/iphone/corelocation.h
index 8a3ee8c51..0ff715964 100644
--- a/navit/vehicle/iphone/corelocation.h
+++ b/navit/vehicle/iphone/corelocation.h
@@ -20,7 +20,7 @@
#define VEHICLE_IPHONE_CORELOCATION_H
typedef void(*FT_LOCATION_CB)(void *, double , double , double , double, char *, double);
-void corelocation_update(double lat,
+void corelocation_update(double lat,
double lng,
double dir,
double spd,
diff --git a/navit/vehicle/iphone/corelocation.m b/navit/vehicle/iphone/corelocation.m
index 5b13c283f..5f02500f3 100644
--- a/navit/vehicle/iphone/corelocation.m
+++ b/navit/vehicle/iphone/corelocation.m
@@ -39,7 +39,7 @@ void corelocation_init(void * pv_arg, FT_LOCATION_CB pf_cb) {
/** Save callbacks */
locationcontroller->pv_arg = pv_arg;
- locationcontroller->pf_cb = pf_cb;
+ locationcontroller->pf_cb = pf_cb;
/** Start location process */
[locationcontroller.locationManager startUpdatingLocation];
@@ -64,7 +64,7 @@ void corelocation_exit(void) {
self = [super init];
if (self != nil) {
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
- self.locationManager.distanceFilter = kCLDistanceFilterNone;
+ self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.delegate = self; // send loc updates to myself
self.pf_cb = NULL;
self.pv_arg = NULL;
@@ -82,7 +82,7 @@ fromLocation:(CLLocation *)oldLocation
{
NSLog(@"New Location: %@", [newLocation description]);
NSString *newDateString = [self.dateFormatter stringFromDate:newLocation.timestamp];
- const char* cString = [newDateString cStringUsingEncoding:NSASCIIStringEncoding];
+ const char* cString = [newDateString cStringUsingEncoding:NSASCIIStringEncoding];
if(self.pf_cb) {
self.pf_cb(
diff --git a/navit/vehicle/iphone/vehicle_iphone.c b/navit/vehicle/iphone/vehicle_iphone.c
index 94fec114a..790166238 100644
--- a/navit/vehicle/iphone/vehicle_iphone.c
+++ b/navit/vehicle/iphone/vehicle_iphone.c
@@ -1,4 +1,4 @@
-/**
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -33,133 +33,130 @@
#include "event.h"
#include "corelocation.h"
+/**
+ * @defgroup vehicle-iphone Vehicle iPhone
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from iPhone.
+ *
+ * @{
+ */
+
struct vehicle_priv {
- int interval;
- int position_set;
- struct callback_list *cbl;
- struct navit *navit;
- struct coord_geo geo;
- struct coord last;
- double config_speed;
- double speed;
- double direction;
- double radius;
- struct callback *timer_callback;
- struct event_timeout *timer;
- char str_time[200];
+ int interval;
+ int position_set;
+ struct callback_list *cbl;
+ struct navit *navit;
+ struct coord_geo geo;
+ struct coord last;
+ double config_speed;
+ double speed;
+ double direction;
+ double radius;
+ struct callback *timer_callback;
+ struct event_timeout *timer;
+ char str_time[200];
};
-static void
-vehicle_iphone_destroy(struct vehicle_priv *priv)
-{
- corelocation_exit();
- g_free(priv);
+static void vehicle_iphone_destroy(struct vehicle_priv *priv) {
+ corelocation_exit();
+ g_free(priv);
}
-static int
-vehicle_iphone_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_position_speed:
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- attr->u.numd = &priv->direction;
- break;
- case attr_position_coord_geo:
- attr->u.coord_geo = &priv->geo;
- break;
- case attr_position_time_iso8601:
- attr->u.str = priv->str_time;
- break;
- case attr_position_radius:
- attr->u.numd = &priv->radius;
- break;
- case attr_position_nmea:
- return 0;
- default:
- return 0;
- }
- attr->type = type;
- return 1;
+static int vehicle_iphone_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ switch (type) {
+ case attr_position_speed:
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ attr->u.numd = &priv->direction;
+ break;
+ case attr_position_coord_geo:
+ attr->u.coord_geo = &priv->geo;
+ break;
+ case attr_position_time_iso8601:
+ attr->u.str = priv->str_time;
+ break;
+ case attr_position_radius:
+ attr->u.numd = &priv->radius;
+ break;
+ case attr_position_nmea:
+ return 0;
+ default:
+ return 0;
+ }
+ attr->type = type;
+ return 1;
}
-static int
-vehicle_iphone_set_attr(struct vehicle_priv *priv, struct attr *attr)
-{
- if (attr->type == attr_navit) {
- priv->navit = attr->u.navit;
- return 1;
- }
- return 0;
+static int vehicle_iphone_set_attr(struct vehicle_priv *priv, struct attr *attr) {
+ if (attr->type == attr_navit) {
+ priv->navit = attr->u.navit;
+ return 1;
+ }
+ return 0;
}
struct vehicle_methods vehicle_iphone_methods = {
- vehicle_iphone_destroy,
- vehicle_iphone_position_attr_get,
- vehicle_iphone_set_attr,
+ vehicle_iphone_destroy,
+ vehicle_iphone_position_attr_get,
+ vehicle_iphone_set_attr,
};
-void
-vehicle_iphone_update(void *arg,
- double lat,
- double lng,
- double dir,
- double spd,
- char * str_time,
- double radius
- )
-{
- struct vehicle_priv * priv = arg;
- priv->geo.lat = lat;
- priv->geo.lng = lng;
- if(dir > 0) priv->direction = dir;
- if(spd > 0) priv->speed = spd*3.6;
- strcpy(priv->str_time, str_time);
- priv->radius = radius;
-
- dbg(lvl_debug,"position_get lat:%f lng:%f (spd:%f dir:%f time:%s)\n", priv->geo.lat, priv->geo.lng, priv->speed, priv->direction, priv->str_time);
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+void vehicle_iphone_update(void *arg,
+ double lat,
+ double lng,
+ double dir,
+ double spd,
+ char * str_time,
+ double radius
+ ) {
+ struct vehicle_priv * priv = arg;
+ priv->geo.lat = lat;
+ priv->geo.lng = lng;
+ if(dir > 0) priv->direction = dir;
+ if(spd > 0) priv->speed = spd*3.6;
+ strcpy(priv->str_time, str_time);
+ priv->radius = radius;
+
+ dbg(lvl_debug,"position_get lat:%f lng:%f (spd:%f dir:%f time:%s)", priv->geo.lat, priv->geo.lng, priv->speed,
+ priv->direction, priv->str_time);
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
}
-static struct vehicle_priv *
-vehicle_iphone_new(struct vehicle_methods
- *meth, struct callback_list
- *cbl, struct attr **attrs)
-{
- struct vehicle_priv *ret;
- struct attr *interval,*speed,*position_coord_geo;
-
- dbg(lvl_debug, "enter\n");
- ret = g_new0(struct vehicle_priv, 1);
- ret->cbl = cbl;
- ret->interval=1000;
- ret->config_speed=40;
- if ((speed=attr_search(attrs, NULL, attr_speed))) {
- ret->config_speed=speed->u.num;
- }
- if ((interval=attr_search(attrs, NULL, attr_interval)))
- ret->interval=interval->u.num;
- if ((position_coord_geo=attr_search(attrs, NULL, attr_position_coord_geo))) {
- ret->geo=*(position_coord_geo->u.coord_geo);
- ret->position_set=1;
- dbg(lvl_debug,"position_set %f %f\n", ret->geo.lat, ret->geo.lng);
- }
- *meth = vehicle_iphone_methods;
- ret->str_time[0] = '\0';
-
- /** Initialize corelocation */
- corelocation_init(ret, vehicle_iphone_update);
-
- return ret;
+static struct vehicle_priv *vehicle_iphone_new(struct vehicle_methods
+ *meth, struct callback_list
+ *cbl, struct attr **attrs) {
+ struct vehicle_priv *ret;
+ struct attr *interval,*speed,*position_coord_geo;
+
+ dbg(lvl_debug, "enter");
+ ret = g_new0(struct vehicle_priv, 1);
+ ret->cbl = cbl;
+ ret->interval=1000;
+ ret->config_speed=40;
+ if ((speed=attr_search(attrs, NULL, attr_speed))) {
+ ret->config_speed=speed->u.num;
+ }
+ if ((interval=attr_search(attrs, NULL, attr_interval)))
+ ret->interval=interval->u.num;
+ if ((position_coord_geo=attr_search(attrs, NULL, attr_position_coord_geo))) {
+ ret->geo=*(position_coord_geo->u.coord_geo);
+ ret->position_set=1;
+ dbg(lvl_debug,"position_set %f %f", ret->geo.lat, ret->geo.lng);
+ }
+ *meth = vehicle_iphone_methods;
+ ret->str_time[0] = '\0';
+
+ /** Initialize corelocation */
+ corelocation_init(ret, vehicle_iphone_update);
+
+ return ret;
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("iphone", vehicle_iphone_new);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("iphone", vehicle_iphone_new);
}
diff --git a/navit/vehicle/maemo/CMakeLists.txt b/navit/vehicle/maemo/CMakeLists.txt
index 2e74763dd..011e5dce9 100644
--- a/navit/vehicle/maemo/CMakeLists.txt
+++ b/navit/vehicle/maemo/CMakeLists.txt
@@ -1,2 +1,2 @@
-module_add_library(vehicle_maemo vehicle_maemo.c)
+module_add_library(vehicle_maemo vehicle_maemo.c)
diff --git a/navit/vehicle/maemo/vehicle_maemo.c b/navit/vehicle/maemo/vehicle_maemo.c
index d686a6a03..4717deb04 100644
--- a/navit/vehicle/maemo/vehicle_maemo.c
+++ b/navit/vehicle/maemo/vehicle_maemo.c
@@ -1,4 +1,4 @@
-/**
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -18,14 +18,6 @@
*/
-/*
- Plugin for new Maemo's liblocation API.
-
- <vehicle source="maemo://any" retry_interval="1"/>
- source cound be on of "any","cwp","acwp","gnss","agnss"
- retry_interval could be one of "1","2","5","10","20","30","60","120" measured in seconds
-*/
-
#include <config.h>
#include <string.h>
#include <glib.h>
@@ -40,290 +32,292 @@
#include "vehicle.h"
#include "event.h"
+/**
+ * @defgroup vehicle-iphone Vehicle Maemo
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from Maemo.
+ *
+ * Plugin for new Maemo's liblocation API.
+ * <vehicle source="maemo://any" retry_interval="1"/>
+ * source cound be on of "any","cwp","acwp","gnss","agnss"
+ * retry_interval could be one of "1","2","5","10","20","30","60","120" measured in seconds
+ *
+ * @{
+ */
+
static struct vehicle_priv {
- LocationGPSDControl *control;
- LocationGPSDevice *device;
- char *source;
- guint retry_interval;
- struct callback_list *cbl;
- struct attr ** attrs;
- int sats; // satellites_in_view
- int sats_used; //satellites_in_user
- int fix_type; //mode
- struct coord_geo geo; //lattigute&longittude
- double speed; //speed:)
- double direction; //track
- double height; //altitude
- double hdop; //eph
- time_t fix_time; //time
- char fixiso8601[128];
+ LocationGPSDControl *control;
+ LocationGPSDevice *device;
+ char *source;
+ guint retry_interval;
+ struct callback_list *cbl;
+ struct attr ** attrs;
+ int sats; // satellites_in_view
+ int sats_used; //satellites_in_user
+ int fix_type; //mode
+ struct coord_geo geo; //lattigute&longittude
+ double speed; //speed:)
+ double direction; //track
+ double height; //altitude
+ double hdop; //eph
+ time_t fix_time; //time
+ char fixiso8601[128];
};
-
+
static void vehicle_maemo_callback(LocationGPSDevice *device, gpointer user_data) {
- struct vehicle_priv *priv=(struct vehicle_priv*)user_data;
-
- priv->sats=device->satellites_in_view;
- priv->sats_used=device->satellites_in_use;
- callback_list_call_attr_0(priv->cbl, attr_position_sats);
-
- dbg(lvl_debug,"Got update with %u/%u satellites\n",priv->sats_used,priv->sats);
-
- if (device->fix) {
- switch(device->fix->mode) {
- case LOCATION_GPS_DEVICE_MODE_NOT_SEEN:
- case LOCATION_GPS_DEVICE_MODE_NO_FIX:
- priv->fix_type=0;
- break;
- case LOCATION_GPS_DEVICE_MODE_2D:
- case LOCATION_GPS_DEVICE_MODE_3D:
- priv->fix_type=1;
- break;
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET) {
- priv->geo.lat=device->fix->latitude;
- priv->geo.lng=device->fix->longitude;
- priv->hdop=device->fix->eph/100;
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
- dbg(lvl_debug,"Position: %f %f with error %f meters\n",priv->geo.lat,priv->geo.lng,priv->hdop);
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) {
- priv->speed=device->fix->speed;
- callback_list_call_attr_0(priv->cbl, attr_position_speed);
- dbg(lvl_debug,"Speed: %f\n ",priv->speed);
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_TRACK_SET) {
- priv->direction=device->fix->track;
- dbg(lvl_debug,"Direction: %f\n",priv->direction);
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) {
- priv->fix_time=device->fix->time;
- dbg(lvl_debug,"Time: %f\n",priv->fix_time);
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET) {
- priv->height=device->fix->altitude;
- dbg(lvl_debug,"Elevation: %f\n",priv->height);
- }
-
- }
-
- return;
+ struct vehicle_priv *priv=(struct vehicle_priv*)user_data;
+
+ priv->sats=device->satellites_in_view;
+ priv->sats_used=device->satellites_in_use;
+ callback_list_call_attr_0(priv->cbl, attr_position_sats);
+
+ dbg(lvl_debug,"Got update with %u/%u satellites",priv->sats_used,priv->sats);
+
+ if (device->fix) {
+ switch(device->fix->mode) {
+ case LOCATION_GPS_DEVICE_MODE_NOT_SEEN:
+ case LOCATION_GPS_DEVICE_MODE_NO_FIX:
+ priv->fix_type=0;
+ break;
+ case LOCATION_GPS_DEVICE_MODE_2D:
+ case LOCATION_GPS_DEVICE_MODE_3D:
+ priv->fix_type=1;
+ break;
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET) {
+ priv->geo.lat=device->fix->latitude;
+ priv->geo.lng=device->fix->longitude;
+ priv->hdop=device->fix->eph/100;
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+ dbg(lvl_debug,"Position: %f %f with error %f meters",priv->geo.lat,priv->geo.lng,priv->hdop);
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) {
+ priv->speed=device->fix->speed;
+ callback_list_call_attr_0(priv->cbl, attr_position_speed);
+ dbg(lvl_debug,"Speed: %f ",priv->speed);
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_TRACK_SET) {
+ priv->direction=device->fix->track;
+ dbg(lvl_debug,"Direction: %f",priv->direction);
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) {
+ priv->fix_time=device->fix->time;
+ dbg(lvl_debug,"Time: %f",priv->fix_time);
+ }
+
+ if (device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET) {
+ priv->height=device->fix->altitude;
+ dbg(lvl_debug,"Elevation: %f",priv->height);
+ }
+
+ }
+
+ return;
}
-
-static void vehicle_maemo_error(LocationGPSDControl *control, LocationGPSDControlError error, gpointer user_data)
-{
- switch (error) {
- case LOCATION_ERROR_USER_REJECTED_DIALOG:
- dbg(lvl_error,"User didn't enable requested methods\n");
- break;
- case LOCATION_ERROR_USER_REJECTED_SETTINGS:
- dbg(lvl_error,"User changed settings, which disabled location\n");
- break;
- case LOCATION_ERROR_BT_GPS_NOT_AVAILABLE:
- dbg(lvl_error,"Problems with BT GPS\n");
- break;
- case LOCATION_ERROR_METHOD_NOT_ALLOWED_IN_OFFLINE_MODE:
- dbg(lvl_error,"Requested method is not allowed in offline mode\n");
- break;
- case LOCATION_ERROR_SYSTEM:
- dbg(lvl_error,"System error\n");
- break;
- }
+
+static void vehicle_maemo_error(LocationGPSDControl *control, LocationGPSDControlError error, gpointer user_data) {
+ switch (error) {
+ case LOCATION_ERROR_USER_REJECTED_DIALOG:
+ dbg(lvl_error,"User didn't enable requested methods");
+ break;
+ case LOCATION_ERROR_USER_REJECTED_SETTINGS:
+ dbg(lvl_error,"User changed settings, which disabled location");
+ break;
+ case LOCATION_ERROR_BT_GPS_NOT_AVAILABLE:
+ dbg(lvl_error,"Problems with BT GPS");
+ break;
+ case LOCATION_ERROR_METHOD_NOT_ALLOWED_IN_OFFLINE_MODE:
+ dbg(lvl_error,"Requested method is not allowed in offline mode");
+ break;
+ case LOCATION_ERROR_SYSTEM:
+ dbg(lvl_error,"System error");
+ break;
+ }
}
/**
* Instantiate liblocation objects
*/
-static void
-vehicle_maemo_open(struct vehicle_priv *priv)
-{
-
- priv->control = location_gpsd_control_get_default();
- priv->device = g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
-
- if (!strcasecmp(priv->source+8,"cwp")) {
- g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_CWP, NULL);
- dbg(lvl_debug,"Method set: CWP\n");
- } else if (!strcasecmp(priv->source+8,"acwp")) {
- g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
- dbg(lvl_debug,"Method set: ACWP\n");
- } else if (!strcasecmp(priv->source+8,"gnss")) {
- g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_GNSS, NULL);
- dbg(lvl_debug,"Method set: GNSS\n");
- } else if (!strcasecmp(priv->source+8,"agnss")) {
- g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_AGNSS, NULL);
- dbg(lvl_debug,"Method set: AGNSS\n");
- } else {
- g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_USER_SELECTED, NULL);
- dbg(lvl_debug,"Method set: ANY\n");
- }
-
- switch (priv->retry_interval) {
- case 2:
- g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_2S, NULL);
- dbg(lvl_debug,"Interval set: 2s\n");
- break;
- case 5:
- g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_5S, NULL);
- dbg(lvl_debug,"Interval set: 5s\n");
- break;
- case 10:
- g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_10S, NULL);
- dbg(lvl_debug,"Interval set: 10s\n");
- break;
- case 20:
- g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_20S, NULL);
- dbg(lvl_debug,"Interval set: 20s\n");
- break;
- case 30:
- g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_30S, NULL);
- dbg(lvl_debug,"Interval set: 30s\n");
- break;
- case 60:
- g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_60S, NULL);
- dbg(lvl_debug,"Interval set: 60s\n");
- break;
- case 120:
- g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_120S, NULL);
- dbg(lvl_debug,"Interval set: 120s\n");
- break;
- case 1:
- default:
- g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_1S, NULL);
- dbg(lvl_debug,"Interval set: 1s\n");
- break;
- }
-
- g_signal_connect(priv->device, "changed", G_CALLBACK(vehicle_maemo_callback), priv);
- g_signal_connect(priv->control, "error-verbose", G_CALLBACK(vehicle_maemo_error), priv);
-
- location_gpsd_control_start(priv->control);
-
- return;
+static void vehicle_maemo_open(struct vehicle_priv *priv) {
+
+ priv->control = location_gpsd_control_get_default();
+ priv->device = g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
+
+ if (!strcasecmp(priv->source+8,"cwp")) {
+ g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_CWP, NULL);
+ dbg(lvl_debug,"Method set: CWP");
+ } else if (!strcasecmp(priv->source+8,"acwp")) {
+ g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
+ dbg(lvl_debug,"Method set: ACWP");
+ } else if (!strcasecmp(priv->source+8,"gnss")) {
+ g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_GNSS, NULL);
+ dbg(lvl_debug,"Method set: GNSS");
+ } else if (!strcasecmp(priv->source+8,"agnss")) {
+ g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_AGNSS, NULL);
+ dbg(lvl_debug,"Method set: AGNSS");
+ } else {
+ g_object_set(G_OBJECT(priv->control), "preferred-method", LOCATION_METHOD_USER_SELECTED, NULL);
+ dbg(lvl_debug,"Method set: ANY");
+ }
+
+ switch (priv->retry_interval) {
+ case 2:
+ g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_2S, NULL);
+ dbg(lvl_debug,"Interval set: 2s");
+ break;
+ case 5:
+ g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_5S, NULL);
+ dbg(lvl_debug,"Interval set: 5s");
+ break;
+ case 10:
+ g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_10S, NULL);
+ dbg(lvl_debug,"Interval set: 10s");
+ break;
+ case 20:
+ g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_20S, NULL);
+ dbg(lvl_debug,"Interval set: 20s");
+ break;
+ case 30:
+ g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_30S, NULL);
+ dbg(lvl_debug,"Interval set: 30s");
+ break;
+ case 60:
+ g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_60S, NULL);
+ dbg(lvl_debug,"Interval set: 60s");
+ break;
+ case 120:
+ g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_120S, NULL);
+ dbg(lvl_debug,"Interval set: 120s");
+ break;
+ case 1:
+ default:
+ g_object_set(G_OBJECT(priv->control), "preferred-interval", LOCATION_INTERVAL_1S, NULL);
+ dbg(lvl_debug,"Interval set: 1s");
+ break;
+ }
+
+ g_signal_connect(priv->device, "changed", G_CALLBACK(vehicle_maemo_callback), priv);
+ g_signal_connect(priv->control, "error-verbose", G_CALLBACK(vehicle_maemo_error), priv);
+
+ location_gpsd_control_start(priv->control);
+
+ return;
}
-static void
-vehicle_maemo_destroy(struct vehicle_priv *priv)
-{
- location_gpsd_control_stop(priv->control);
+static void vehicle_maemo_destroy(struct vehicle_priv *priv) {
+ location_gpsd_control_stop(priv->control);
- g_object_unref(priv->device);
- g_object_unref(priv->control);
+ g_object_unref(priv->device);
+ g_object_unref(priv->control);
- return;
+ return;
}
-static int
-vehicle_maemo_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- struct attr * active=NULL;
- switch (type) {
- case attr_position_fix_type:
- dbg(lvl_debug,"Attr requested: position_fix_type\n");
- attr->u.num = priv->fix_type;
- break;
- case attr_position_height:
- dbg(lvl_debug,"Attr requested: position_height\n");
- attr->u.numd = &priv->height;
- break;
- case attr_position_speed:
- dbg(lvl_debug,"Attr requested: position_speed\n");
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- dbg(lvl_debug,"Attr requested: position_direction\n");
- attr->u.numd = &priv->direction;
- break;
- case attr_position_hdop:
- dbg(lvl_debug,"Attr requested: position_hdop\n");
- attr->u.numd = &priv->hdop;
- break;
- case attr_position_sats:
- dbg(lvl_debug,"Attr requested: position_sats\n");
- attr->u.num = priv->sats;
- break;
- case attr_position_sats_used:
- dbg(lvl_debug,"Attr requested: position_sats_used\n");
- attr->u.num = priv->sats_used;
- break;
- case attr_position_coord_geo:
- dbg(lvl_debug,"Attr requested: position_coord_geo\n");
- attr->u.coord_geo = &priv->geo;
- break;
- case attr_position_time_iso8601:
- {
- struct tm tm;
- dbg(lvl_debug,"Attr requested: position_time_iso8601\n");
- if (!priv->fix_time)
- return 0;
- if (gmtime_r(&priv->fix_time, &tm)) {
- strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
- "%Y-%m-%dT%TZ", &tm);
- attr->u.str=priv->fixiso8601;
- } else
- return 0;
- }
- break;
- case attr_active:
- dbg(lvl_debug,"Attr requested: position_active\n");
- active = attr_search(priv->attrs,NULL,attr_active);
- if(active != NULL) {
- attr->u.num=active->u.num;
- return 1;
- } else
- return 0;
- break;
- default:
- return 0;
- }
- attr->type = type;
- return 1;
+static int vehicle_maemo_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ struct attr * active=NULL;
+ switch (type) {
+ case attr_position_fix_type:
+ dbg(lvl_debug,"Attr requested: position_fix_type");
+ attr->u.num = priv->fix_type;
+ break;
+ case attr_position_height:
+ dbg(lvl_debug,"Attr requested: position_height");
+ attr->u.numd = &priv->height;
+ break;
+ case attr_position_speed:
+ dbg(lvl_debug,"Attr requested: position_speed");
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ dbg(lvl_debug,"Attr requested: position_direction");
+ attr->u.numd = &priv->direction;
+ break;
+ case attr_position_hdop:
+ dbg(lvl_debug,"Attr requested: position_hdop");
+ attr->u.numd = &priv->hdop;
+ break;
+ case attr_position_sats:
+ dbg(lvl_debug,"Attr requested: position_sats");
+ attr->u.num = priv->sats;
+ break;
+ case attr_position_sats_used:
+ dbg(lvl_debug,"Attr requested: position_sats_used");
+ attr->u.num = priv->sats_used;
+ break;
+ case attr_position_coord_geo:
+ dbg(lvl_debug,"Attr requested: position_coord_geo");
+ attr->u.coord_geo = &priv->geo;
+ break;
+ case attr_position_time_iso8601: {
+ struct tm tm;
+ dbg(lvl_debug,"Attr requested: position_time_iso8601");
+ if (!priv->fix_time)
+ return 0;
+ if (gmtime_r(&priv->fix_time, &tm)) {
+ strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
+ "%Y-%m-%dT%TZ", &tm);
+ attr->u.str=priv->fixiso8601;
+ } else
+ return 0;
+ }
+ break;
+ case attr_active:
+ dbg(lvl_debug,"Attr requested: position_active");
+ active = attr_search(priv->attrs,NULL,attr_active);
+ if(active != NULL) {
+ attr->u.num=active->u.num;
+ return 1;
+ } else
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ attr->type = type;
+ return 1;
}
struct vehicle_methods vehicle_maemo_methods = {
- vehicle_maemo_destroy,
- vehicle_maemo_position_attr_get,
+ vehicle_maemo_destroy,
+ vehicle_maemo_position_attr_get,
};
-static struct vehicle_priv *
-vehicle_maemo_new_maemo(struct vehicle_methods
- *meth, struct callback_list
- *cbl, struct attr **attrs)
-{
- struct vehicle_priv *ret;
- struct attr *source, *retry_int;
-
- dbg(lvl_debug, "enter\n");
- source = attr_search(attrs, NULL, attr_source);
- ret = g_new0(struct vehicle_priv, 1);
- ret->source = g_strdup(source->u.str);
- retry_int = attr_search(attrs, NULL, attr_retry_interval);
- if (retry_int) {
- ret->retry_interval = retry_int->u.num;
- if (ret->retry_interval !=1 && ret->retry_interval !=2 && ret->retry_interval !=5 && ret->retry_interval !=10 && ret->retry_interval !=20 && ret->retry_interval !=30 && ret->retry_interval !=60 && ret->retry_interval !=120 ) {
- dbg(lvl_error, "Retry interval %d invalid, setting to 1\n", ret->retry_interval,1);
- ret->retry_interval = 1;
- }
- } else {
- ret->retry_interval = 1;
- }
- dbg(lvl_debug,"source: %s, interval: %u\n",ret->source,ret->retry_interval);
- ret->cbl = cbl;
- *meth = vehicle_maemo_methods;
- ret->attrs = attrs;
- vehicle_maemo_open(ret);
- return ret;
+static struct vehicle_priv *vehicle_maemo_new_maemo(struct vehicle_methods
+ *meth, struct callback_list
+ *cbl, struct attr **attrs) {
+ struct vehicle_priv *ret;
+ struct attr *source, *retry_int;
+
+ dbg(lvl_debug, "enter");
+ source = attr_search(attrs, NULL, attr_source);
+ ret = g_new0(struct vehicle_priv, 1);
+ ret->source = g_strdup(source->u.str);
+ retry_int = attr_search(attrs, NULL, attr_retry_interval);
+ if (retry_int) {
+ ret->retry_interval = retry_int->u.num;
+ if (ret->retry_interval !=1 && ret->retry_interval !=2 && ret->retry_interval !=5 && ret->retry_interval !=10
+ && ret->retry_interval !=20 && ret->retry_interval !=30 && ret->retry_interval !=60 && ret->retry_interval !=120 ) {
+ dbg(lvl_error, "Retry interval %d invalid, setting to 1", ret->retry_interval,1);
+ ret->retry_interval = 1;
+ }
+ } else {
+ ret->retry_interval = 1;
+ }
+ dbg(lvl_debug,"source: %s, interval: %u",ret->source,ret->retry_interval);
+ ret->cbl = cbl;
+ *meth = vehicle_maemo_methods;
+ ret->attrs = attrs;
+ vehicle_maemo_open(ret);
+ return ret;
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("maemo", vehicle_maemo_new_maemo);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("maemo", vehicle_maemo_new_maemo);
}
diff --git a/navit/vehicle/null/vehicle_null.c b/navit/vehicle/null/vehicle_null.c
index 643945c71..61dd7123a 100644
--- a/navit/vehicle/null/vehicle_null.c
+++ b/navit/vehicle/null/vehicle_null.c
@@ -1,4 +1,4 @@
-/** @file vehicle_null.c
+/*
* @brief null uses dbus signals
*
* Navit, a modular navigation system.
@@ -34,150 +34,134 @@
#include "item.h"
#include "vehicle.h"
+/**
+ * @defgroup vehicle-null Vehicle Null
+ * @ingroup vehicle-plugins
+ * @brief A dummy Vehicle to have a null movement.
+ *
+ * @{
+ */
+
struct vehicle_priv {
- struct callback_list *cbl;
- struct coord_geo geo;
- double speed;
- double direction;
- double height;
- double radius;
- int fix_type;
- time_t fix_time;
- char fixiso8601[128];
- int sats;
- int sats_used;
- int have_coords;
- struct attr ** attrs;
+ struct callback_list *cbl;
+ struct coord_geo geo;
+ double speed;
+ double direction;
+ double height;
+ double radius;
+ int fix_type;
+ time_t fix_time;
+ char fixiso8601[128];
+ int sats;
+ int sats_used;
+ int have_coords;
+ struct attr ** attrs;
};
/**
* @brief Free the null_vehicle
- *
+ *
* @param priv
* @returns nothing
*/
-static void
-vehicle_null_destroy(struct vehicle_priv *priv)
-{
- dbg(lvl_debug,"enter\n");
- g_free(priv);
+static void vehicle_null_destroy(struct vehicle_priv *priv) {
+ dbg(lvl_debug,"enter");
+ g_free(priv);
}
/**
* @brief Provide the outside with information
- *
+ *
* @param priv
* @param type TODO: What can this be?
* @param attr
* @returns true/false
*/
-static int
-vehicle_null_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- dbg(lvl_debug,"enter %s\n",attr_to_name(type));
- switch (type) {
-#if 0
- case attr_position_fix_type:
- attr->u.num = priv->fix_type;
- break;
-#endif
- case attr_position_height:
- attr->u.numd = &priv->height;
- break;
- case attr_position_speed:
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- attr->u.numd = &priv->direction;
- break;
- case attr_position_radius:
- attr->u.numd = &priv->radius;
- break;
-
-#if 0
- case attr_position_qual:
- attr->u.num = priv->sats;
- break;
- case attr_position_sats_used:
- attr->u.num = priv->sats_used;
- break;
-#endif
- case attr_position_coord_geo:
- attr->u.coord_geo = &priv->geo;
- if (!priv->have_coords)
- return 0;
- break;
- case attr_position_time_iso8601:
- attr->u.str=priv->fixiso8601;
- break;
- default:
- return 0;
- }
- dbg(lvl_debug,"ok\n");
- attr->type = type;
- return 1;
+static int vehicle_null_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ dbg(lvl_debug,"enter %s",attr_to_name(type));
+ switch (type) {
+ case attr_position_height:
+ attr->u.numd = &priv->height;
+ break;
+ case attr_position_speed:
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ attr->u.numd = &priv->direction;
+ break;
+ case attr_position_radius:
+ attr->u.numd = &priv->radius;
+ break;
+ case attr_position_coord_geo:
+ attr->u.coord_geo = &priv->geo;
+ if (!priv->have_coords)
+ return 0;
+ break;
+ case attr_position_time_iso8601:
+ attr->u.str=priv->fixiso8601;
+ break;
+ default:
+ return 0;
+ }
+ dbg(lvl_debug,"ok");
+ attr->type = type;
+ return 1;
}
-static int
-vehicle_null_set_attr(struct vehicle_priv *priv, struct attr *attr)
-{
- switch (attr->type) {
- case attr_position_speed:
- priv->speed=*attr->u.numd;
- break;
- case attr_position_direction:
- priv->direction=*attr->u.numd;
- break;
- case attr_position_coord_geo:
- priv->geo=*attr->u.coord_geo;
- priv->have_coords=1;
- break;
- default:
- break;
- }
- callback_list_call_attr_0(priv->cbl, attr->type);
- return 1;
+static int vehicle_null_set_attr(struct vehicle_priv *priv, struct attr *attr) {
+ switch (attr->type) {
+ case attr_position_speed:
+ priv->speed=*attr->u.numd;
+ break;
+ case attr_position_direction:
+ priv->direction=*attr->u.numd;
+ break;
+ case attr_position_coord_geo:
+ priv->geo=*attr->u.coord_geo;
+ priv->have_coords=1;
+ break;
+ default:
+ break;
+ }
+ callback_list_call_attr_0(priv->cbl, attr->type);
+ return 1;
}
struct vehicle_methods vehicle_null_methods = {
- vehicle_null_destroy,
- vehicle_null_position_attr_get,
- vehicle_null_set_attr,
+ vehicle_null_destroy,
+ vehicle_null_position_attr_get,
+ vehicle_null_set_attr,
};
/**
* @brief Create null_vehicle
- *
+ *
* @param meth
* @param cbl
* @param attrs
* @returns vehicle_priv
*/
-static struct vehicle_priv *
-vehicle_null_new_null(struct vehicle_methods *meth,
- struct callback_list *cbl,
- struct attr **attrs)
-{
- struct vehicle_priv *ret;
+static struct vehicle_priv *vehicle_null_new_null(struct vehicle_methods *meth,
+ struct callback_list *cbl,
+ struct attr **attrs) {
+ struct vehicle_priv *ret;
- dbg(lvl_debug, "enter\n");
- ret = g_new0(struct vehicle_priv, 1);
- ret->cbl = cbl;
- *meth = vehicle_null_methods;
- dbg(lvl_debug, "return\n");
- return ret;
+ dbg(lvl_debug, "enter");
+ ret = g_new0(struct vehicle_priv, 1);
+ ret->cbl = cbl;
+ *meth = vehicle_null_methods;
+ dbg(lvl_debug, "return");
+ return ret;
}
/**
* @brief register vehicle_null
- *
+ *
* @returns nothing
*/
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("null", vehicle_null_new_null);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("null", vehicle_null_new_null);
}
diff --git a/navit/vehicle/qt5/vehicle_qt5.cpp b/navit/vehicle/qt5/vehicle_qt5.cpp
index 2a2b6f5cf..b855d12b9 100644
--- a/navit/vehicle/qt5/vehicle_qt5.cpp
+++ b/navit/vehicle/qt5/vehicle_qt5.cpp
@@ -1,5 +1,4 @@
-/** @file vehicle_null.c
- * @brief null uses dbus signals
+/*
*
* Navit, a modular navigation system.
* Copyright (C) 2005-2017 Navit Team
@@ -41,55 +40,62 @@ extern "C" {
#include "vehicle_qt5.h"
#include "vehicle_qt5.moc"
#include <QDateTime>
+
+/**
+ * @defgroup vehicle-qt5 Vehicle QT5
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from qt5
+ *
+ * @{
+ */
+
QNavitGeoReceiver::QNavitGeoReceiver(QObject* parent, struct vehicle_priv* c)
- : QObject(parent)
-{
+ : QObject(parent) {
priv = c;
if (priv->source != NULL) {
connect(priv->source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
}
if (priv->satellites != NULL) {
- connect(priv->satellites, SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&)), this, SLOT(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&)));
- connect(priv->satellites, SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&)), this, SLOT(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&)));
+ connect(priv->satellites, SIGNAL(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&)), this,
+ SLOT(satellitesInUseUpdated(const QList<QGeoSatelliteInfo>&)));
+ connect(priv->satellites, SIGNAL(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&)), this,
+ SLOT(satellitesInViewUpdated(const QList<QGeoSatelliteInfo>&)));
}
}
-void QNavitGeoReceiver::satellitesInUseUpdated(const QList<QGeoSatelliteInfo>& sats)
-{
- dbg(lvl_debug, "Sats in use: %d\n", sats.count());
+void QNavitGeoReceiver::satellitesInUseUpdated(const QList<QGeoSatelliteInfo>& sats) {
+ dbg(lvl_debug, "Sats in use: %d", sats.count());
priv->sats_used = sats.count();
callback_list_call_attr_0(priv->cbl, attr_position_sats_used);
}
-void QNavitGeoReceiver::satellitesInViewUpdated(const QList<QGeoSatelliteInfo>& sats)
-{
- dbg(lvl_debug, "Sats in view: %d\n", sats.count());
+void QNavitGeoReceiver::satellitesInViewUpdated(const QList<QGeoSatelliteInfo>& sats) {
+ dbg(lvl_debug, "Sats in view: %d", sats.count());
priv->sats = sats.count();
callback_list_call_attr_0(priv->cbl, attr_position_qual);
}
-void QNavitGeoReceiver::positionUpdated(const QGeoPositionInfo& info)
-{
+void QNavitGeoReceiver::positionUpdated(const QGeoPositionInfo& info) {
/* ignore stale view */
if (info.coordinate().isValid()) {
if (info.timestamp().toUTC().secsTo(QDateTime::currentDateTimeUtc()) > 20) {
- dbg(lvl_debug, "Ignoring old FIX\n");
+ dbg(lvl_debug, "Ignoring old FIX");
return;
}
}
if (info.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) {
- dbg(lvl_debug, "Horizontal acc (%f)\n", info.attribute(QGeoPositionInfo::HorizontalAccuracy));
+ dbg(lvl_debug, "Horizontal acc (%f)", info.attribute(QGeoPositionInfo::HorizontalAccuracy));
priv->radius = info.attribute(QGeoPositionInfo::HorizontalAccuracy);
callback_list_call_attr_0(priv->cbl, attr_position_radius);
}
if (info.hasAttribute(QGeoPositionInfo::GroundSpeed)) {
- dbg(lvl_debug, "Got ground speed (%f)\n", info.attribute(QGeoPositionInfo::GroundSpeed));
+ dbg(lvl_debug, "Got ground speed (%f)", info.attribute(QGeoPositionInfo::GroundSpeed));
priv->speed = info.attribute(QGeoPositionInfo::GroundSpeed) * 3.6;
callback_list_call_attr_0(priv->cbl, attr_position_speed);
}
if (info.hasAttribute(QGeoPositionInfo::Direction)) {
- dbg(lvl_debug, "Direction (%f)\n", info.attribute(QGeoPositionInfo::Direction));
+ dbg(lvl_debug, "Direction (%f)", info.attribute(QGeoPositionInfo::Direction));
priv->direction = info.attribute(QGeoPositionInfo::Direction);
callback_list_call_attr_0(priv->cbl, attr_position_direction);
}
@@ -107,34 +113,38 @@ void QNavitGeoReceiver::positionUpdated(const QGeoPositionInfo& info)
}
if (info.coordinate().isValid()) {
- dbg(lvl_debug, "Got valid coordinate (lat %f, lon %f)\n", info.coordinate().latitude(), info.coordinate().longitude());
+ dbg(lvl_debug, "Got valid coordinate (lat %f, lon %f)", info.coordinate().latitude(), info.coordinate().longitude());
priv->geo.lat = info.coordinate().latitude();
priv->geo.lng = info.coordinate().longitude();
- priv->have_coords = 1;
if (info.coordinate().type() == QGeoCoordinate::Coordinate3D) {
- dbg(lvl_debug, "Got valid altitude (alt %f)\n", info.coordinate().altitude());
+ dbg(lvl_debug, "Got valid altitude (alt %f)", info.coordinate().altitude());
priv->height = info.coordinate().altitude();
}
- //dbg(lvl_debug, "Time %s\n", info.timestamp().toUTC().toString().toLatin1().data());
+ //dbg(lvl_debug, "Time %s", info.timestamp().toUTC().toString().toLatin1().data());
priv->fix_time = info.timestamp().toUTC().toTime_t();
callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+ if(priv->have_coords != attr_position_valid_valid) {
+ priv->have_coords = attr_position_valid_valid;
+ callback_list_call_attr_0(priv->cbl, attr_position_valid);
+ }
} else {
- dbg(lvl_debug, "Got invalid coordinate\n");
- priv->have_coords = 0;
+ dbg(lvl_debug, "Got invalid coordinate");
callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+ if(priv->have_coords != attr_position_valid_invalid) {
+ priv->have_coords = attr_position_valid_invalid;
+ callback_list_call_attr_0(priv->cbl, attr_position_valid);
+ }
}
}
/**
* @brief Free the null_vehicle
- *
+ *
* @param priv
* @returns nothing
*/
-static void
-vehicle_qt5_destroy(struct vehicle_priv* priv)
-{
- dbg(lvl_debug, "enter\n");
+static void vehicle_qt5_destroy(struct vehicle_priv* priv) {
+ dbg(lvl_debug, "enter");
if (priv->receiver != NULL)
delete priv->receiver;
if (priv->source != NULL)
@@ -144,18 +154,16 @@ vehicle_qt5_destroy(struct vehicle_priv* priv)
/**
* @brief Provide the outside with information
- *
+ *
* @param priv
* @param type TODO: What can this be?
* @param attr
* @returns true/false
*/
-static int
-vehicle_qt5_position_attr_get(struct vehicle_priv* priv,
- enum attr_type type, struct attr* attr)
-{
+static int vehicle_qt5_position_attr_get(struct vehicle_priv* priv,
+ enum attr_type type, struct attr* attr) {
struct attr* active = NULL;
- dbg(lvl_debug, "enter %s\n", attr_to_name(type));
+ dbg(lvl_debug, "enter %s", attr_to_name(type));
switch (type) {
case attr_position_valid:
attr->u.num = priv->have_coords;
@@ -183,7 +191,7 @@ vehicle_qt5_position_attr_get(struct vehicle_priv* priv,
break;
case attr_position_coord_geo:
attr->u.coord_geo = &priv->geo;
- if (!priv->have_coords)
+ if (priv->have_coords != attr_position_valid_valid)
return 0;
break;
case attr_position_time_iso8601:
@@ -191,15 +199,15 @@ vehicle_qt5_position_attr_get(struct vehicle_priv* priv,
struct tm tm;
if (gmtime_r(&priv->fix_time, &tm)) {
strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
- "%Y-%m-%dT%TZ", &tm);
+ "%Y-%m-%dT%TZ", &tm);
attr->u.str = priv->fixiso8601;
} else {
priv->fix_time = 0;
return 0;
}
- //dbg(lvl_debug,"Fix Time: %s\n", priv->fixiso8601);
+ //dbg(lvl_debug,"Fix Time: %s", priv->fixiso8601);
} else {
- //dbg(lvl_debug,"Fix Time: 0\n");
+ //dbg(lvl_debug,"Fix Time: 0");
return 0;
}
break;
@@ -216,14 +224,12 @@ vehicle_qt5_position_attr_get(struct vehicle_priv* priv,
default:
return 0;
}
- dbg(lvl_debug, "ok\n");
+ dbg(lvl_debug, "ok");
attr->type = type;
return 1;
}
-static int
-vehicle_qt5_set_attr(struct vehicle_priv* priv, struct attr* attr)
-{
+static int vehicle_qt5_set_attr(struct vehicle_priv* priv, struct attr* attr) {
switch (attr->type) {
case attr_position_speed:
priv->speed = *attr->u.numd;
@@ -233,7 +239,10 @@ vehicle_qt5_set_attr(struct vehicle_priv* priv, struct attr* attr)
break;
case attr_position_coord_geo:
priv->geo = *attr->u.coord_geo;
- priv->have_coords = 1;
+ if(priv->have_coords != attr_position_valid_valid) {
+ priv->have_coords = attr_position_valid_valid;
+ callback_list_call_attr_0(priv->cbl, attr_position_valid);
+ }
break;
default:
break;
@@ -250,20 +259,18 @@ struct vehicle_methods vehicle_null_methods = {
/**
* @brief Create null_vehicle
- *
+ *
* @param meth
* @param cbl
* @param attrs
* @returns vehicle_priv
*/
-static struct vehicle_priv*
-vehicle_qt5_new_qt5(struct vehicle_methods* meth,
- struct callback_list* cbl,
- struct attr** attrs)
-{
+static struct vehicle_priv* vehicle_qt5_new_qt5(struct vehicle_methods* meth,
+ struct callback_list* cbl,
+ struct attr** attrs) {
struct vehicle_priv* ret;
- dbg(lvl_debug, "enter\n");
+ dbg(lvl_debug, "enter");
ret = g_new0(struct vehicle_priv, 1);
ret->cbl = cbl;
*meth = vehicle_null_methods;
@@ -271,26 +278,27 @@ vehicle_qt5_new_qt5(struct vehicle_methods* meth,
ret->source = QGeoPositionInfoSource::createDefaultSource(NULL);
ret->satellites = QGeoSatelliteInfoSource::createDefaultSource(NULL);
if (ret->source == NULL) {
- dbg(lvl_error, "Got NO QGeoPositionInfoSource\n");
+ dbg(lvl_error, "Got NO QGeoPositionInfoSource");
} else {
- dbg(lvl_debug, "Using %s\n", ret->source->sourceName().toLatin1().data());
+ dbg(lvl_debug, "Using %s", ret->source->sourceName().toLatin1().data());
ret->receiver = new QNavitGeoReceiver(NULL, ret);
- ret->satellites->setUpdateInterval(1000);
- ret->satellites->startUpdates();
+ if(ret->satellites != NULL) {
+ ret->satellites->setUpdateInterval(1000);
+ ret->satellites->startUpdates();
+ }
ret->source->setUpdateInterval(500);
ret->source->startUpdates();
}
- dbg(lvl_debug, "return\n");
+ dbg(lvl_debug, "return");
return ret;
}
/**
* @brief register vehicle_null
- *
+ *
* @returns nothing
*/
-void plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
plugin_register_category_vehicle("qt5", vehicle_qt5_new_qt5);
}
diff --git a/navit/vehicle/webos/bluetooth.c b/navit/vehicle/webos/bluetooth.c
index 343d2ec5c..d51ec450b 100644
--- a/navit/vehicle/webos/bluetooth.c
+++ b/navit/vehicle/webos/bluetooth.c
@@ -1,4 +1,4 @@
-/* vim: sw=3 ts=3
+/* vim: sw=3 ts=3
* */
#include <config.h>
@@ -8,7 +8,7 @@
#include <errno.h>
#include <sys/time.h>
#include <PDL.h>
-#include <SDL.h>
+#include "SDL.h"
#include "debug.h"
#include "callback.h"
#include "event.h"
@@ -21,670 +21,565 @@ static void vehicle_webos_spp_init_read(struct vehicle_priv *priv, unsigned int
/********************************************************************/
-static void
-mlPDL_ServiceCall_callback(struct callback_list *cbl, char *service, char *parameters/*, struct callback *fail_cb*/)
-{
- PDL_Err err;
- dbg(lvl_debug,"PDL_ServiceCall(%s) parameters(%s)\n",service,parameters);
- err = PDL_ServiceCall(service, parameters);
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"PDL_ServiceCall to (%s) with (%s) failed with (%d): (%s)\n", service, parameters, err, PDL_GetError());
- }
-
- callback_list_destroy(cbl);
- g_free(service);
- g_free(parameters);
+static void mlPDL_ServiceCall_callback(struct callback_list *cbl, char *service,
+ char *parameters/*, struct callback *fail_cb*/) {
+ PDL_Err err;
+ dbg(lvl_debug,"PDL_ServiceCall(%s) parameters(%s)",service,parameters);
+ err = PDL_ServiceCall(service, parameters);
+ if (err != PDL_NOERROR) {
+ dbg(lvl_error,"PDL_ServiceCall to (%s) with (%s) failed with (%d): (%s)", service, parameters, err, PDL_GetError());
+ }
+
+ callback_list_destroy(cbl);
+ g_free(service);
+ g_free(parameters);
}
-static void
-mlPDL_ServiceCall(const char *service, const char *parameters/*, struct callback *fail_cb = NULL*/)
-{
- struct callback *cb = NULL;
- struct callback_list *cbl = NULL;
+static void mlPDL_ServiceCall(const char *service, const char *parameters/*, struct callback *fail_cb = NULL*/) {
+ struct callback *cb = NULL;
+ struct callback_list *cbl = NULL;
- char *service2 = g_strdup(service);
- char *parameters2 = g_strdup(parameters);
+ char *service2 = g_strdup(service);
+ char *parameters2 = g_strdup(parameters);
- cbl = callback_list_new();
- cb = callback_new_3(callback_cast(mlPDL_ServiceCall_callback),cbl,service2,parameters2);
+ cbl = callback_list_new();
+ cb = callback_new_3(callback_cast(mlPDL_ServiceCall_callback),cbl,service2,parameters2);
- callback_list_add(cbl, cb);
+ callback_list_add(cbl, cb);
-dbg(lvl_debug,"event_call_callback(%p)\n",cbl);
- event_call_callback(cbl);
+ dbg(lvl_debug,"event_call_callback(%p)",cbl);
+ event_call_callback(cbl);
}
/********************************************************************/
-static void
-mlPDL_ServiceCallWithCallback_callback(struct callback_list *cbl,
- char *service,
- char *parameters,
- PDL_ServiceCallbackFunc callback,
- void *user,
- PDL_bool removeAfterResponse)
-{
- PDL_Err err;
- dbg(lvl_debug,"PDL_ServiceCallWithCallback(%s) parameters(%s)\n",service,parameters);
- err = PDL_ServiceCallWithCallback(service, parameters, callback, user, removeAfterResponse);
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"PDL_ServiceCallWithCallback to (%s) with (%s) failed with (%d): (%s)\n", service, parameters, err, PDL_GetError());
- }
-
- callback_list_destroy(cbl);
- g_free(service);
- g_free(parameters);
+static void mlPDL_ServiceCallWithCallback_callback(struct callback_list *cbl,
+ char *service,
+ char *parameters,
+ PDL_ServiceCallbackFunc callback,
+ void *user,
+ PDL_bool removeAfterResponse) {
+ PDL_Err err;
+ dbg(lvl_debug,"PDL_ServiceCallWithCallback(%s) parameters(%s)",service,parameters);
+ err = PDL_ServiceCallWithCallback(service, parameters, callback, user, removeAfterResponse);
+ if (err != PDL_NOERROR) {
+ dbg(lvl_error,"PDL_ServiceCallWithCallback to (%s) with (%s) failed with (%d): (%s)", service, parameters, err,
+ PDL_GetError());
+ }
+
+ callback_list_destroy(cbl);
+ g_free(service);
+ g_free(parameters);
}
-static void
-mlPDL_ServiceCallWithCallback(const char *service,
- const char *parameters,
- PDL_ServiceCallbackFunc callback,
- void *user,
- PDL_bool removeAfterResponse)
-{
- struct callback *cb = NULL;
- struct callback_list *cbl = NULL;
+static void mlPDL_ServiceCallWithCallback(const char *service,
+ const char *parameters,
+ PDL_ServiceCallbackFunc callback,
+ void *user,
+ PDL_bool removeAfterResponse) {
+ struct callback *cb = NULL;
+ struct callback_list *cbl = NULL;
- char *service2 = g_strdup(service);
- char *parameters2 = g_strdup(parameters);
+ char *service2 = g_strdup(service);
+ char *parameters2 = g_strdup(parameters);
- cbl = callback_list_new();
- cb = callback_new_args(callback_cast(mlPDL_ServiceCallWithCallback_callback),6,cbl,service2,parameters2,callback,user,removeAfterResponse);
+ cbl = callback_list_new();
+ cb = callback_new_args(callback_cast(mlPDL_ServiceCallWithCallback_callback),6,cbl,service2,parameters2,callback,user,
+ removeAfterResponse);
- callback_list_add(cbl, cb);
+ callback_list_add(cbl, cb);
- dbg(lvl_debug,"event_call_callback(%p)\n",cbl);
- event_call_callback(cbl);
+ dbg(lvl_debug,"event_call_callback(%p)",cbl);
+ event_call_callback(cbl);
}
/********************************************************************/
-static void
-vehicle_webos_init_pdl_locationtracking_callback(struct vehicle_priv *priv, struct callback_list *cbl, int param)
-{
- PDL_Err err;
+static void vehicle_webos_init_pdl_locationtracking_callback(struct vehicle_priv *priv, struct callback_list *cbl,
+ int param) {
+ PDL_Err err;
- priv->gps_type = param ? GPS_TYPE_INT: GPS_TYPE_NONE;
+ priv->gps_type = param ? GPS_TYPE_INT: GPS_TYPE_NONE;
- dbg(lvl_debug,"Calling PDL_EnableLocationTracking(%i)\n",param);
- err = PDL_EnableLocationTracking(param);
+ dbg(lvl_debug,"Calling PDL_EnableLocationTracking(%i)",param);
+ err = PDL_EnableLocationTracking(param);
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"PDL_EnableLocationTracking failed with (%d): (%s)\n", err, PDL_GetError());
+ if (err != PDL_NOERROR) {
+ dbg(lvl_error,"PDL_EnableLocationTracking failed with (%d): (%s)", err, PDL_GetError());
// vehicle_webos_close(priv);
// return 0;
- }
+ }
- callback_list_destroy(cbl);
+ callback_list_destroy(cbl);
}
-static void
-vehicle_webos_init_pdl_locationtracking(struct vehicle_priv *priv, int param)
-{
- struct callback *cb = NULL;
- struct callback_list *cbl = NULL;
+static void vehicle_webos_init_pdl_locationtracking(struct vehicle_priv *priv, int param) {
+ struct callback *cb = NULL;
+ struct callback_list *cbl = NULL;
- cbl = callback_list_new();
- cb = callback_new_3(callback_cast(vehicle_webos_init_pdl_locationtracking_callback),priv,cbl,param);
+ cbl = callback_list_new();
+ cb = callback_new_3(callback_cast(vehicle_webos_init_pdl_locationtracking_callback),priv,cbl,param);
- callback_list_add(cbl, cb);
+ callback_list_add(cbl, cb);
- event_call_callback(cbl);
+ event_call_callback(cbl);
}
/********************************************************************/
-static int
-vehicle_webos_parse_nmea(struct vehicle_priv *priv, char *buffer)
-{
- char *nmea_data_buf, *p, *item[32];
- double lat, lng;
- int i, bcsum;
- int len = strlen(buffer);
- unsigned char csum = 0;
- int valid=0;
- int ret = 0;
-
- dbg(lvl_info, "enter: buffer='%s'\n", buffer);
- for (;;) {
- if (len < 4) {
- dbg(lvl_error, "'%s' too short\n", buffer);
- return ret;
- }
- if (buffer[len - 1] == '\r' || buffer[len - 1] == '\n') {
- buffer[--len] = '\0';
+static int vehicle_webos_parse_nmea(struct vehicle_priv *priv, char *buffer) {
+ char *nmea_data_buf, *p, *item[32];
+ double lat, lng;
+ int i, bcsum;
+ int len = strlen(buffer);
+ unsigned char csum = 0;
+ int valid=0;
+ int ret = 0;
+
+ dbg(lvl_info, "enter: buffer='%s'", buffer);
+ for (;;) {
+ if (len < 4) {
+ dbg(lvl_error, "'%s' too short", buffer);
+ return ret;
+ }
+ if (buffer[len - 1] == '\r' || buffer[len - 1] == '\n') {
+ buffer[--len] = '\0';
if (buffer[len - 1] == '\r')
buffer[--len] = '\0';
} else
- break;
- }
- if (buffer[0] != '$') {
- dbg(lvl_error, "no leading $ in '%s'\n", buffer);
- return ret;
- }
- if (buffer[len - 3] != '*') {
- dbg(lvl_error, "no *XX in '%s'\n", buffer);
- return ret;
- }
- for (i = 1; i < len - 3; i++) {
- csum ^= (unsigned char) (buffer[i]);
- }
- if (!sscanf(buffer + len - 2, "%x", &bcsum) /*&& priv->checksum_ignore != 2*/) {
- dbg(lvl_error, "no checksum in '%s'\n", buffer);
- return ret;
- }
- if (bcsum != csum /*&& priv->checksum_ignore == 0*/) {
- dbg(lvl_error, "wrong checksum in '%s was %x should be %x'\n", buffer,bcsum,csum);
- return ret;
- }
-
- if (!priv->nmea_data_buf || strlen(priv->nmea_data_buf) < 65536) {
- nmea_data_buf=g_strconcat(priv->nmea_data_buf ? priv->nmea_data_buf : "", buffer, "\n", NULL);
- g_free(priv->nmea_data_buf);
- priv->nmea_data_buf=nmea_data_buf;
- } else {
- dbg(lvl_error, "nmea buffer overflow, discarding '%s'\n", buffer);
- }
- i = 0;
- p = buffer;
- while (i < 31) {
- item[i++] = p;
- while (*p && *p != ',')
- p++;
- if (!*p)
- break;
- *p++ = '\0';
- }
+ break;
+ }
+ if (buffer[0] != '$') {
+ dbg(lvl_error, "no leading $ in '%s'", buffer);
+ return ret;
+ }
+ if (buffer[len - 3] != '*') {
+ dbg(lvl_error, "no *XX in '%s'", buffer);
+ return ret;
+ }
+ for (i = 1; i < len - 3; i++) {
+ csum ^= (unsigned char) (buffer[i]);
+ }
+ if (!sscanf(buffer + len - 2, "%x", &bcsum) /*&& priv->checksum_ignore != 2*/) {
+ dbg(lvl_error, "no checksum in '%s'", buffer);
+ return ret;
+ }
+ if (bcsum != csum /*&& priv->checksum_ignore == 0*/) {
+ dbg(lvl_error, "wrong checksum in '%s was %x should be %x'", buffer,bcsum,csum);
+ return ret;
+ }
+
+ if (!priv->nmea_data_buf || strlen(priv->nmea_data_buf) < 65536) {
+ nmea_data_buf=g_strconcat(priv->nmea_data_buf ? priv->nmea_data_buf : "", buffer, "\n", NULL);
+ g_free(priv->nmea_data_buf);
+ priv->nmea_data_buf=nmea_data_buf;
+ } else {
+ dbg(lvl_error, "nmea buffer overflow, discarding '%s'", buffer);
+ }
+ i = 0;
+ p = buffer;
+ while (i < 31) {
+ item[i++] = p;
+ while (*p && *p != ',')
+ p++;
+ if (!*p)
+ break;
+ *p++ = '\0';
+ }
// if (buffer[0] == '$') {
// struct timeval tv;
// gettimeofday(&tv,NULL);
- priv->delta = 0; // (unsigned int)difftime(tv.tv_sec, priv->fix_time);
+ priv->delta = 0; // (unsigned int)difftime(tv.tv_sec, priv->fix_time);
// priv->fix_time = tv.tv_sec;
-// dbg(lvl_info,"delta(%i)\n",priv->delta);
+// dbg(lvl_info,"delta(%i)",priv->delta);
// }
- if (!strncmp(&buffer[3], "GGA", 3)) {
- /* 1 1111
- 0 1 2 3 4 5 6 7 8 9 0 1234
- $GPGGA,184424.505,4924.2811,N,01107.8846,E,1,05,2.5,408.6,M,,,,0000*0C
- UTC of Fix[1],Latitude[2],N/S[3],Longitude[4],E/W[5],Quality(0=inv,1=gps,2=dgps)[6],Satelites used[7],
- HDOP[8],Altitude[9],"M"[10],height of geoid[11], "M"[12], time since dgps update[13], dgps ref station [14]
- */
- if (*item[2] && *item[3] && *item[4] && *item[5]) {
- lat = g_ascii_strtod(item[2], NULL);
- priv->geo.lat = floor(lat / 100);
- lat -= priv->geo.lat * 100;
- priv->geo.lat += lat / 60;
-
- if (!g_strcasecmp(item[3],"S"))
- priv->geo.lat=-priv->geo.lat;
-
- lng = g_ascii_strtod(item[4], NULL);
- priv->geo.lng = floor(lng / 100);
- lng -= priv->geo.lng * 100;
- priv->geo.lng += lng / 60;
-
- if (!g_strcasecmp(item[5],"W"))
- priv->geo.lng=-priv->geo.lng;
- priv->valid=attr_position_valid_valid;
- dbg(lvl_info, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng);
-
- } else
- priv->valid=attr_position_valid_invalid;
- if (*item[6])
- sscanf(item[6], "%d", &priv->status);
- if (*item[7])
- sscanf(item[7], "%d", &priv->sats_used);
- if (*item[8])
- sscanf(item[8], "%lf", &priv->hdop);
- if (*item[1]) {
- struct tm tm;
- strptime(item[1],"%H%M%S",&tm);
- priv->fix_time = mktime(&tm);
- }
-
- if (*item[9])
- sscanf(item[9], "%lf", &priv->altitude);
-
- g_free(priv->nmea_data);
- priv->nmea_data=priv->nmea_data_buf;
- priv->nmea_data_buf=NULL;
-#if 0
- if (priv->file_type == file_type_file) {
- if (priv->watch) {
- vehicle_file_disable_watch(priv);
- event_add_timeout(priv->time, 0, priv->cbt);
- }
- }
-#endif
- ret = 1;
- }
- if (!strncmp(&buffer[3], "VTG", 3)) {
- /* 0 1 2 34 5 6 7 8
- $GPVTG,143.58,T,,M,0.26,N,0.5,K*6A
- Course Over Ground Degrees True[1],"T"[2],Course Over Ground Degrees Magnetic[3],"M"[4],
- Speed in Knots[5],"N"[6],"Speed in KM/H"[7],"K"[8]
- */
- if (item[1] && item[7])
- valid = 1;
- if (i >= 10 && (*item[9] == 'A' || *item[9] == 'D'))
- valid = 1;
- if (valid) {
- priv->track = g_ascii_strtod( item[1], NULL );
- priv->speed = g_ascii_strtod( item[7], NULL );
- dbg(lvl_info,"direction %lf, speed %2.1lf\n", priv->track, priv->speed);
- }
- }
- if (!strncmp(&buffer[3], "RMC", 3)) {
- /* 1 1
- 0 1 2 3 4 5 6 7 8 9 0 1
- $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
- Time[1],Active/Void[2],lat[3],N/S[4],long[5],W/E[6],speed in knots[7],track angle[8],date[9],
- magnetic variation[10],magnetic variation direction[11]
- */
- if (*item[2] == 'A')
- valid = 1;
- if (i >= 13 && (*item[12] == 'A' || *item[12] == 'D'))
- valid = 1;
- if (valid) {
- priv->track = g_ascii_strtod( item[8], NULL );
- priv->speed = g_ascii_strtod( item[7], NULL );
- priv->speed *= 1.852;
-
- struct tm tm;
- char time[13];
-
- sprintf(time,"%s%s",item[1],item[9]);
-
- strptime(time,"%H%M%S%d%m%y",&tm);
-
- priv->fix_time = mktime(&tm);
-#if 0
- sscanf(item[9], "%02d%02d%02d",
- &priv->fixday,
- &priv->fixmonth,
- &priv->fixyear);
- priv->fixyear += 2000;
-#endif
- }
- ret = 1;
- }
- if (!strncmp(buffer, "$GPGSV", 6) && i >= 4) {
- /*
- 0 GSV Satellites in view
- 1 2 Number of sentences for full data
- 2 1 sentence 1 of 2
- 3 08 Number of satellites in view
-
- 4 01 Satellite PRN number
- 5 40 Elevation, degrees
- 6 083 Azimuth, degrees
- 7 46 SNR - higher is better
- for up to 4 satellites per sentence
- *75 the checksum data, always begins with *
- */
- if (item[3]) {
- sscanf(item[3], "%d", &priv->sats_visible);
- }
-#if 0
- j=4;
- while (j+4 <= i && priv->current_count < 24) {
- struct gps_sat *sat=&priv->next[priv->next_count++];
- sat->prn=atoi(item[j]);
- sat->elevation=atoi(item[j+1]);
- sat->azimuth=atoi(item[j+2]);
- sat->snr=atoi(item[j+3]);
- j+=4;
- }
- if (!strcmp(item[1], item[2])) {
- priv->sats_signal=0;
- for (i = 0 ; i < priv->next_count ; i++) {
- priv->current[i]=priv->next[i];
- if (priv->current[i].snr)
- priv->sats_signal++;
- }
- priv->current_count=priv->next_count;
- priv->next_count=0;
- }
-#endif
- }
-#if 0
- if (!strncmp(&buffer[3], "ZDA", 3)) {
- /*
- 0 1 2 3 4 5 6
- $GPZDA,hhmmss.ss,dd,mm,yyyy,xx,yy*CC
- hhmmss HrMinSec(UTC)
- dd,mm,yyy Day,Month,Year
- xx local zone hours -13..13
- yy local zone minutes 0..59
- */
- if (item[1] && item[2] && item[3] && item[4]) {
- strncpy(priv->fixtime, item[1], strlen(priv->fixtime));
- priv->fixday = atoi(item[2]);
- priv->fixmonth = atoi(item[3]);
- priv->fixyear = atoi(item[4]);
- }
- }
-#endif
- if (!strncmp(buffer, "$IISMD", 6)) {
- /*
- 0 1 2 3 4
- $IISMD,dir,press,height,temp*CC"
- dir Direction (0-359)
- press Pressure (hpa, i.e. 1032)
- height Barometric height above ground (meter)
- temp Temperature (Degree Celsius)
- */
- if (item[1]) {
- priv->magnetic_direction = g_ascii_strtod( item[1], NULL );
- dbg(lvl_debug,"magnetic %d\n", priv->magnetic_direction);
- }
- }
- return ret;
+ if (!strncmp(&buffer[3], "GGA", 3)) {
+ /* 1 1111
+ 0 1 2 3 4 5 6 7 8 9 0 1234
+ $GPGGA,184424.505,4924.2811,N,01107.8846,E,1,05,2.5,408.6,M,,,,0000*0C
+ UTC of Fix[1],Latitude[2],N/S[3],Longitude[4],E/W[5],Quality(0=inv,1=gps,2=dgps)[6],Satelites used[7],
+ HDOP[8],Altitude[9],"M"[10],height of geoid[11], "M"[12], time since dgps update[13], dgps ref station [14]
+ */
+ if (*item[2] && *item[3] && *item[4] && *item[5]) {
+ lat = g_ascii_strtod(item[2], NULL);
+ priv->geo.lat = floor(lat / 100);
+ lat -= priv->geo.lat * 100;
+ priv->geo.lat += lat / 60;
+
+ if (!g_strcasecmp(item[3],"S"))
+ priv->geo.lat=-priv->geo.lat;
+
+ lng = g_ascii_strtod(item[4], NULL);
+ priv->geo.lng = floor(lng / 100);
+ lng -= priv->geo.lng * 100;
+ priv->geo.lng += lng / 60;
+
+ if (!g_strcasecmp(item[5],"W"))
+ priv->geo.lng=-priv->geo.lng;
+ priv->valid=attr_position_valid_valid;
+ dbg(lvl_info, "latitude '%2.4f' longitude %2.4f", priv->geo.lat, priv->geo.lng);
+
+ } else
+ priv->valid=attr_position_valid_invalid;
+ if (*item[6])
+ sscanf(item[6], "%d", &priv->status);
+ if (*item[7])
+ sscanf(item[7], "%d", &priv->sats_used);
+ if (*item[8])
+ sscanf(item[8], "%lf", &priv->hdop);
+ if (*item[1]) {
+ struct tm tm;
+ strptime(item[1],"%H%M%S",&tm);
+ priv->fix_time = mktime(&tm);
+ }
+
+ if (*item[9])
+ sscanf(item[9], "%lf", &priv->altitude);
+
+ g_free(priv->nmea_data);
+ priv->nmea_data=priv->nmea_data_buf;
+ priv->nmea_data_buf=NULL;
+ ret = 1;
+ }
+ if (!strncmp(&buffer[3], "VTG", 3)) {
+ /* 0 1 2 34 5 6 7 8
+ $GPVTG,143.58,T,,M,0.26,N,0.5,K*6A
+ Course Over Ground Degrees True[1],"T"[2],Course Over Ground Degrees Magnetic[3],"M"[4],
+ Speed in Knots[5],"N"[6],"Speed in KM/H"[7],"K"[8]
+ */
+ if (item[1] && item[7])
+ valid = 1;
+ if (i >= 10 && (*item[9] == 'A' || *item[9] == 'D'))
+ valid = 1;
+ if (valid) {
+ priv->track = g_ascii_strtod( item[1], NULL );
+ priv->speed = g_ascii_strtod( item[7], NULL );
+ dbg(lvl_info,"direction %lf, speed %2.1lf", priv->track, priv->speed);
+ }
+ }
+ if (!strncmp(&buffer[3], "RMC", 3)) {
+ /* 1 1
+ 0 1 2 3 4 5 6 7 8 9 0 1
+ $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
+ Time[1],Active/Void[2],lat[3],N/S[4],long[5],W/E[6],speed in knots[7],track angle[8],date[9],
+ magnetic variation[10],magnetic variation direction[11]
+ */
+ if (*item[2] == 'A')
+ valid = 1;
+ if (i >= 13 && (*item[12] == 'A' || *item[12] == 'D'))
+ valid = 1;
+ if (valid) {
+ priv->track = g_ascii_strtod( item[8], NULL );
+ priv->speed = g_ascii_strtod( item[7], NULL );
+ priv->speed *= 1.852;
+
+ struct tm tm;
+ char time[13];
+
+ sprintf(time,"%s%s",item[1],item[9]);
+
+ strptime(time,"%H%M%S%d%m%y",&tm);
+
+ priv->fix_time = mktime(&tm);
+ }
+ ret = 1;
+ }
+ if (!strncmp(buffer, "$GPGSV", 6) && i >= 4) {
+ /*
+ 0 GSV Satellites in view
+ 1 2 Number of sentences for full data
+ 2 1 sentence 1 of 2
+ 3 08 Number of satellites in view
+
+ 4 01 Satellite PRN number
+ 5 40 Elevation, degrees
+ 6 083 Azimuth, degrees
+ 7 46 SNR - higher is better
+ for up to 4 satellites per sentence
+ *75 the checksum data, always begins with *
+ */
+ if (item[3]) {
+ sscanf(item[3], "%d", &priv->sats_visible);
+ }
+ }
+ if (!strncmp(buffer, "$IISMD", 6)) {
+ /*
+ 0 1 2 3 4
+ $IISMD,dir,press,height,temp*CC"
+ dir Direction (0-359)
+ press Pressure (hpa, i.e. 1032)
+ height Barometric height above ground (meter)
+ temp Temperature (Degree Celsius)
+ */
+ if (item[1]) {
+ priv->magnetic_direction = g_ascii_strtod( item[1], NULL );
+ dbg(lvl_debug,"magnetic %d", priv->magnetic_direction);
+ }
+ }
+ return ret;
}
-static void
-vehicle_webos_spp_handle_read(PDL_ServiceParameters *params, void *user)
-{
- struct vehicle_priv *priv = user;
- int size, rc = 0;
- char *str, *tok;
+static void vehicle_webos_spp_handle_read(PDL_ServiceParameters *params, void *user) {
+ struct vehicle_priv *priv = user;
+ int size, rc = 0;
+ char *str, *tok;
- //PDL_Err err;
- size = PDL_GetParamInt(params, "dataLength");
- if (size > buffer_size) {
- dbg(lvl_error, "read returned too much data\n");
- return;
- }
+ //PDL_Err err;
+ size = PDL_GetParamInt(params, "dataLength");
+ if (size > buffer_size) {
+ dbg(lvl_error, "read returned too much data");
+ return;
+ }
- char buffer[buffer_size];
+ char buffer[buffer_size];
- PDL_GetParamString(params,"data",buffer,buffer_size);
- dbg(lvl_debug,"data(%s) dataLength(%i)\n",buffer,size);
+ PDL_GetParamString(params,"data",buffer,buffer_size);
+ dbg(lvl_debug,"data(%s) dataLength(%i)",buffer,size);
- memmove(priv->buffer + priv->buffer_pos, buffer, size);
+ memmove(priv->buffer + priv->buffer_pos, buffer, size);
- priv->buffer_pos += size;
- priv->buffer[priv->buffer_pos] = '\0';
- dbg(lvl_debug, "size=%d pos=%d buffer='%s'\n", size,
- priv->buffer_pos, priv->buffer);
- str = priv->buffer;
- while ((tok = strchr(str, '\n'))) {
- *tok++ = '\0';
- dbg(lvl_debug, "line='%s'\n", str);
- rc += vehicle_webos_parse_nmea(priv, str);
- str = tok;
+ priv->buffer_pos += size;
+ priv->buffer[priv->buffer_pos] = '\0';
+ dbg(lvl_debug, "size=%d pos=%d buffer='%s'", size,
+ priv->buffer_pos, priv->buffer);
+ str = priv->buffer;
+ while ((tok = strchr(str, '\n'))) {
+ *tok++ = '\0';
+ dbg(lvl_debug, "line='%s'", str);
+ rc += vehicle_webos_parse_nmea(priv, str);
+ str = tok;
// if (priv->file_type == file_type_file && rc)
// break;
- }
-
- if (str != priv->buffer) {
- size = priv->buffer + priv->buffer_pos - str;
- memmove(priv->buffer, str, size + 1);
- priv->buffer_pos = size;
- dbg(lvl_debug,"now pos=%d buffer='%s'\n",
- priv->buffer_pos, priv->buffer);
- } else if (priv->buffer_pos == buffer_size - 1) {
- dbg(lvl_error,"Overflow. Most likely wrong baud rate or no nmea protocol\n");
- priv->buffer_pos = 0;
- }
- if (rc) {
- SDL_Event event;
- SDL_UserEvent userevent;
-
- userevent.type = SDL_USEREVENT;
- userevent.code = PDL_GPS_UPDATE;
- userevent.data1 = NULL;
- userevent.data2 = NULL;
-
- event.type = SDL_USEREVENT;
- event.user = userevent;
-
- SDL_PushEvent(&event);
- }
-
- vehicle_webos_spp_init_read(priv, buffer_size - priv->buffer_pos - 1);
+ }
+
+ if (str != priv->buffer) {
+ size = priv->buffer + priv->buffer_pos - str;
+ memmove(priv->buffer, str, size + 1);
+ priv->buffer_pos = size;
+ dbg(lvl_debug,"now pos=%d buffer='%s'",
+ priv->buffer_pos, priv->buffer);
+ } else if (priv->buffer_pos == buffer_size - 1) {
+ dbg(lvl_error,"Overflow. Most likely wrong baud rate or no nmea protocol");
+ priv->buffer_pos = 0;
+ }
+ if (rc) {
+ SDL_Event event;
+ SDL_UserEvent userevent;
+
+ userevent.type = SDL_USEREVENT;
+ userevent.code = PDL_GPS_UPDATE;
+ userevent.data1 = NULL;
+ userevent.data2 = NULL;
+
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
+
+ SDL_PushEvent(&event);
+ }
+
+ vehicle_webos_spp_init_read(priv, buffer_size - priv->buffer_pos - 1);
}
-static void
-vehicle_webos_spp_init_read(struct vehicle_priv *priv, unsigned int length)
-{
- //PDL_Err err;
- char parameters[128];
-
- snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i, \"dataLength\":%i}", priv->spp_instance_id, length);
- mlPDL_ServiceCallWithCallback("palm://com.palm.service.bluetooth.spp/read",
- parameters,
- (PDL_ServiceCallbackFunc)vehicle_webos_spp_handle_read,
- priv,
- PDL_FALSE
- );
-#if 0
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"PDL_ServiceCall failed with (%d): (%s)\n", err, PDL_GetError());
- vehicle_webos_close(priv);
- return;
- }
-#endif
+static void vehicle_webos_spp_init_read(struct vehicle_priv *priv, unsigned int length) {
+ //PDL_Err err;
+ char parameters[128];
+
+ snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i, \"dataLength\":%i}", priv->spp_instance_id, length);
+ mlPDL_ServiceCallWithCallback("palm://com.palm.service.bluetooth.spp/read",
+ parameters,
+ (PDL_ServiceCallbackFunc)vehicle_webos_spp_handle_read,
+ priv,
+ PDL_FALSE
+ );
}
-static void
-vehicle_webos_spp_handle_open(PDL_ServiceParameters *params, void *user)
-{
- struct vehicle_priv *priv = (struct vehicle_priv *)user;
+static void vehicle_webos_spp_handle_open(PDL_ServiceParameters *params, void *user) {
+ struct vehicle_priv *priv = (struct vehicle_priv *)user;
- if (!priv->buffer)
- priv->buffer = g_malloc(buffer_size);
-
- dbg(lvl_debug,"instanceId(%i)\n",priv->spp_instance_id);
+ if (!priv->buffer)
+ priv->buffer = g_malloc(buffer_size);
- priv->gps_type = GPS_TYPE_BT;
+ dbg(lvl_debug,"instanceId(%i)",priv->spp_instance_id);
- vehicle_webos_spp_init_read(priv, buffer_size-1);
+ priv->gps_type = GPS_TYPE_BT;
+
+ vehicle_webos_spp_init_read(priv, buffer_size-1);
}
-static void
-vehicle_webos_spp_notify(PDL_ServiceParameters *params, void *user)
-{
- struct vehicle_priv *priv = user;
-
- char notification[128];
- char parameters[128];
-
- const char *params_json = PDL_GetParamJson(params);
- dbg(lvl_info,"params_json(%s)\n", params_json);
-
- if (PDL_ParamExists(params, "errorText")) {
- PDL_GetParamString(params, "errorText", notification, sizeof(notification));
- dbg(lvl_error,"errorText(%s)\n",notification);
- return;
- }
-
- PDL_GetParamString(params, "notification", notification, sizeof(notification));
- notification[sizeof(notification)-1] = '\0';
-
- dbg(lvl_warning,"notification(%s) %i\n",notification,PDL_ParamExists(params, "notification"));
-
- if(strcmp(notification,"notifnservicenames") == 0) {
- int instance_id = PDL_GetParamInt(params, "instanceId");
-
- dbg(lvl_debug,"instanceId(%i)\n", instance_id);
-
- cJSON *root = cJSON_Parse(params_json);
- if (!root) {
- dbg(lvl_error,"parsing json failed\n");
- return;
- }
-
- cJSON *services = cJSON_GetObjectItem(root, "services");
-
- char *service_name = cJSON_GetArrayItem(services, 0)->valuestring;
-
- snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i, \"servicename\":\"%s\"}",instance_id, service_name);
- mlPDL_ServiceCall("palm://com.palm.bluetooth/spp/selectservice", parameters);
-
- cJSON_Delete(root);
- }
- else if(strcmp(notification,"notifnconnected") == 0) {
- if (PDL_GetParamInt(params,"error") == 0) {
- vehicle_webos_init_pdl_locationtracking(priv, 0);
-
- int instance_id = PDL_GetParamInt(params, "instanceId");
- priv->spp_instance_id = instance_id;
- snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i}", instance_id);
- mlPDL_ServiceCallWithCallback("palm://com.palm.service.bluetooth.spp/open",
- parameters,
- (PDL_ServiceCallbackFunc)vehicle_webos_spp_handle_open,
- priv,
- PDL_TRUE);
- }
- else {
- dbg(lvl_error,"notifnconnected error(%i)\n",PDL_GetParamInt(params,"error"));
- }
- }
- else if(strcmp(notification,"notifndisconnected") == 0) {
- priv->gps_type = GPS_TYPE_NONE;
- snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i}",priv->spp_instance_id);
- mlPDL_ServiceCall("palm://com.palm.service.bluetooth.spp/close", parameters);
- priv->spp_instance_id = 0;
- vehicle_webos_init_pdl_locationtracking(priv, 1);
- }
+static void vehicle_webos_spp_notify(PDL_ServiceParameters *params, void *user) {
+ struct vehicle_priv *priv = user;
+ char notification[128];
+ char parameters[128];
+
+ const char *params_json = PDL_GetParamJson(params);
+ dbg(lvl_info,"params_json(%s)", params_json);
+
+ if (PDL_ParamExists(params, "errorText")) {
+ PDL_GetParamString(params, "errorText", notification, sizeof(notification));
+ dbg(lvl_error,"errorText(%s)",notification);
+ return;
+ }
+
+ PDL_GetParamString(params, "notification", notification, sizeof(notification));
+ notification[sizeof(notification)-1] = '\0';
+
+ dbg(lvl_warning,"notification(%s) %i",notification,PDL_ParamExists(params, "notification"));
+
+ if(strcmp(notification,"notifnservicenames") == 0) {
+ int instance_id = PDL_GetParamInt(params, "instanceId");
+
+ dbg(lvl_debug,"instanceId(%i)", instance_id);
+
+ cJSON *root = cJSON_Parse(params_json);
+ if (!root) {
+ dbg(lvl_error,"parsing json failed");
+ return;
+ }
+
+ cJSON *services = cJSON_GetObjectItem(root, "services");
+
+ char *service_name = cJSON_GetArrayItem(services, 0)->valuestring;
+
+ snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i, \"servicename\":\"%s\"}",instance_id, service_name);
+ mlPDL_ServiceCall("palm://com.palm.bluetooth/spp/selectservice", parameters);
+
+ cJSON_Delete(root);
+ } else if(strcmp(notification,"notifnconnected") == 0) {
+ if (PDL_GetParamInt(params,"error") == 0) {
+ vehicle_webos_init_pdl_locationtracking(priv, 0);
+
+ int instance_id = PDL_GetParamInt(params, "instanceId");
+ priv->spp_instance_id = instance_id;
+ snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i}", instance_id);
+ mlPDL_ServiceCallWithCallback("palm://com.palm.service.bluetooth.spp/open",
+ parameters,
+ (PDL_ServiceCallbackFunc)vehicle_webos_spp_handle_open,
+ priv,
+ PDL_TRUE);
+ } else {
+ dbg(lvl_error,"notifnconnected error(%i)",PDL_GetParamInt(params,"error"));
+ }
+ } else if(strcmp(notification,"notifndisconnected") == 0) {
+ priv->gps_type = GPS_TYPE_NONE;
+ snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i}",priv->spp_instance_id);
+ mlPDL_ServiceCall("palm://com.palm.service.bluetooth.spp/close", parameters);
+ priv->spp_instance_id = 0;
+ vehicle_webos_init_pdl_locationtracking(priv, 1);
+ }
-}
-static void
-vehicle_webos_init_bt_gps(struct vehicle_priv *priv, char *addr)
-{
- char parameters[128];
-
- dbg(lvl_debug,"subscribeNotifications\n");
- mlPDL_ServiceCallWithCallback("palm://com.palm.bluetooth/spp/subscribenotifications",
- "{\"subscribe\":true}",
- (PDL_ServiceCallbackFunc)vehicle_webos_spp_notify,
- priv,
- PDL_FALSE);
-#if 0
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"PDL_ServiceCallWithCallback failed with (%d): (%s)\n", err, PDL_GetError());
- vehicle_webos_close(priv);
- return;
- }
-#endif
-
- snprintf(parameters, sizeof(parameters), "{\"address\":\"%s\"}", addr);
- mlPDL_ServiceCall("palm://com.palm.bluetooth/spp/connect", parameters);
-#if 0
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"PDL_ServiceCall failed with (%d): (%s)\n", err, PDL_GetError());
- vehicle_webos_close(priv);
- return;
- }
-#endif
-
- priv->spp_address = addr;
}
-static void
-vehicle_webos_bt_gap_callback(PDL_ServiceParameters *params, void *param)
-{
- const char *params_json;
- struct vehicle_priv *priv = (struct vehicle_priv *)param;
- char *device_addr = NULL;
- cJSON *root;
-
- dbg(lvl_debug,"enter\n");
-
- PDL_Err err;
- err = PDL_GetParamInt(params, "errorCode");
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"BT GAP Callback errorCode %d\n", err);
- return /*PDL_EOTHER*/;
- }
-
- params_json = PDL_GetParamJson(params);
- dbg(lvl_info,"params_json(%s)\n",params_json);
-
- root = cJSON_Parse(params_json);
- if (!root) {
- dbg(lvl_error,"parsing json failed\n");
- return;
- }
-
- cJSON *trusted_devices = cJSON_GetObjectItem(root, "trusteddevices");
-
- unsigned int i,c = cJSON_GetArraySize(trusted_devices);
- dbg(lvl_debug, "trusted_devices(%i)\n",c);
- for(i=0; i < c && !device_addr; i++) {
- cJSON *device = cJSON_GetArrayItem(trusted_devices,i);
- char *name = cJSON_GetObjectItem(device, "name")->valuestring;
- char *address = cJSON_GetObjectItem(device, "address")->valuestring;
- char *status = cJSON_GetObjectItem(device, "status")->valuestring;
-
- dbg(lvl_debug,"i(%i) name(%s) address(%s) status(%s)\n",i,name,address,status);
-
- if (/*strncmp(status, "connected",9) == 0 && */strstr(name, "GPS") != NULL) {
- dbg(lvl_debug,"choose name(%s) address(%s)\n",name,address);
- device_addr = g_strdup(address);
- break;
- }
- }
-
- cJSON_Delete(root);
-
- if (device_addr) {
- vehicle_webos_init_bt_gps(priv, device_addr);
- }
-
- g_free(device_addr);
+static void vehicle_webos_init_bt_gps(struct vehicle_priv *priv, char *addr) {
+ char parameters[128];
+
+ dbg(lvl_debug,"subscribeNotifications");
+ mlPDL_ServiceCallWithCallback("palm://com.palm.bluetooth/spp/subscribenotifications",
+ "{\"subscribe\":true}",
+ (PDL_ServiceCallbackFunc)vehicle_webos_spp_notify,
+ priv,
+ PDL_FALSE);
+
+ snprintf(parameters, sizeof(parameters), "{\"address\":\"%s\"}", addr);
+ mlPDL_ServiceCall("palm://com.palm.bluetooth/spp/connect", parameters);
+
+ priv->spp_address = addr;
}
-int
-vehicle_webos_bt_open(struct vehicle_priv *priv)
-{
- // Try to connect to BT GPS, or use PDL method
-
- dbg(lvl_debug,"enter\n");
-
- PDL_Err err;
- err = PDL_ServiceCallWithCallback("palm://com.palm.bluetooth/gap/gettrusteddevices",
- "{}",
- (PDL_ServiceCallbackFunc)vehicle_webos_bt_gap_callback,
- priv,
- PDL_TRUE);
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"PDL_ServiceCallWithCallback failed with (%d): (%s)\n", err, PDL_GetError());
- vehicle_webos_close(priv);
- return 0;
- }
- return 1;
+static void vehicle_webos_bt_gap_callback(PDL_ServiceParameters *params, void *param) {
+ const char *params_json;
+ struct vehicle_priv *priv = (struct vehicle_priv *)param;
+ char *device_addr = NULL;
+ cJSON *root;
+
+ dbg(lvl_debug,"enter");
+
+ PDL_Err err;
+ err = PDL_GetParamInt(params, "errorCode");
+ if (err != PDL_NOERROR) {
+ dbg(lvl_error,"BT GAP Callback errorCode %d", err);
+ return /*PDL_EOTHER*/;
+ }
+
+ params_json = PDL_GetParamJson(params);
+ dbg(lvl_info,"params_json(%s)",params_json);
+
+ root = cJSON_Parse(params_json);
+ if (!root) {
+ dbg(lvl_error,"parsing json failed");
+ return;
+ }
+
+ cJSON *trusted_devices = cJSON_GetObjectItem(root, "trusteddevices");
+
+ unsigned int i,c = cJSON_GetArraySize(trusted_devices);
+ dbg(lvl_debug, "trusted_devices(%i)",c);
+ for(i=0; i < c && !device_addr; i++) {
+ cJSON *device = cJSON_GetArrayItem(trusted_devices,i);
+ char *name = cJSON_GetObjectItem(device, "name")->valuestring;
+ char *address = cJSON_GetObjectItem(device, "address")->valuestring;
+ char *status = cJSON_GetObjectItem(device, "status")->valuestring;
+
+ dbg(lvl_debug,"i(%i) name(%s) address(%s) status(%s)",i,name,address,status);
+
+ if (/*strncmp(status, "connected",9) == 0 && */strstr(name, "GPS") != NULL) {
+ dbg(lvl_debug,"choose name(%s) address(%s)",name,address);
+ device_addr = g_strdup(address);
+ break;
+ }
+ }
+
+ cJSON_Delete(root);
+
+ if (device_addr) {
+ vehicle_webos_init_bt_gps(priv, device_addr);
+ }
+
+ g_free(device_addr);
}
-void
-vehicle_webos_bt_close(struct vehicle_priv *priv)
-{
- dbg(lvl_debug,"XXX\n");
- char parameters[128];
- if (priv->spp_instance_id) {
- snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i}", priv->spp_instance_id);
- PDL_ServiceCall("palm://com.palm.service.bluetooth.spp/close", parameters);
- }
- if (priv->spp_address) {
- snprintf(parameters, sizeof(parameters), "{\"address\":\"%s\"}", priv->spp_address);
- PDL_ServiceCall("palm://com.palm.bluetooth.spp/disconnect", parameters);
- g_free(priv->spp_address);
- priv->spp_address = NULL;
- }
- //g_free(priv->buffer);
- //priv->buffer = NULL;
- // g_free(priv->nmea_data);
- // priv->nmea_data = NULL;
- // g_free(priv->nmea_data_buf);
- // priv->nmea_data_buf = NULL;
+int vehicle_webos_bt_open(struct vehicle_priv *priv) {
+ // Try to connect to BT GPS, or use PDL method
+
+ dbg(lvl_debug,"enter");
+
+ PDL_Err err;
+ err = PDL_ServiceCallWithCallback("palm://com.palm.bluetooth/gap/gettrusteddevices",
+ "{}",
+ (PDL_ServiceCallbackFunc)vehicle_webos_bt_gap_callback,
+ priv,
+ PDL_TRUE);
+ if (err != PDL_NOERROR) {
+ dbg(lvl_error,"PDL_ServiceCallWithCallback failed with (%d): (%s)", err, PDL_GetError());
+ vehicle_webos_close(priv);
+ return 0;
+ }
+ return 1;
}
+void vehicle_webos_bt_close(struct vehicle_priv *priv) {
+ dbg(lvl_debug,"XXX");
+ char parameters[128];
+ if (priv->spp_instance_id) {
+ snprintf(parameters, sizeof(parameters), "{\"instanceId\":%i}", priv->spp_instance_id);
+ PDL_ServiceCall("palm://com.palm.service.bluetooth.spp/close", parameters);
+ }
+ if (priv->spp_address) {
+ snprintf(parameters, sizeof(parameters), "{\"address\":\"%s\"}", priv->spp_address);
+ PDL_ServiceCall("palm://com.palm.bluetooth.spp/disconnect", parameters);
+ g_free(priv->spp_address);
+ priv->spp_address = NULL;
+ }
+ //g_free(priv->buffer);
+ //priv->buffer = NULL;
+ // g_free(priv->nmea_data);
+ // priv->nmea_data = NULL;
+ // g_free(priv->nmea_data_buf);
+ // priv->nmea_data_buf = NULL;
+}
diff --git a/navit/vehicle/webos/cJSON.c b/navit/vehicle/webos/cJSON.c
index 19d3151e2..9026a224f 100644
--- a/navit/vehicle/webos/cJSON.c
+++ b/navit/vehicle/webos/cJSON.c
@@ -34,208 +34,260 @@
static const char *ep;
-const char *cJSON_GetErrorPtr() {return ep;}
+const char *cJSON_GetErrorPtr() {
+ return ep;
+}
-static int cJSON_strcasecmp(const char *s1,const char *s2)
-{
- if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
- for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
- return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
+static int cJSON_strcasecmp(const char *s1,const char *s2) {
+ if (!s1) return (s1==s2)?0:1;
+ if (!s2) return 1;
+ for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
+ return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
}
static void *(*cJSON_malloc)(size_t sz) = malloc;
static void (*cJSON_free)(void *ptr) = free;
-static char* cJSON_strdup(const char* str)
-{
- size_t len;
- char* copy;
+static char* cJSON_strdup(const char* str) {
+ size_t len;
+ char* copy;
- len = strlen(str) + 1;
- if (!(copy = (char*)cJSON_malloc(len))) return 0;
- memcpy(copy,str,len);
- return copy;
+ len = strlen(str) + 1;
+ if (!(copy = (char*)cJSON_malloc(len))) return 0;
+ memcpy(copy,str,len);
+ return copy;
}
-void cJSON_InitHooks(cJSON_Hooks* hooks)
-{
+void cJSON_InitHooks(cJSON_Hooks* hooks) {
if (!hooks) { /* Reset hooks */
cJSON_malloc = malloc;
cJSON_free = free;
return;
}
- cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
- cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
+ cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
+ cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
}
/* Internal constructor. */
-static cJSON *cJSON_New_Item(void)
-{
- cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
- if (node) memset(node,0,sizeof(cJSON));
- return node;
+static cJSON *cJSON_New_Item(void) {
+ cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
+ if (node) memset(node,0,sizeof(cJSON));
+ return node;
}
/* Delete a cJSON structure. */
-void cJSON_Delete(cJSON *c)
-{
- cJSON *next;
- while (c)
- {
- next=c->next;
- if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
- if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
- if (c->string) cJSON_free(c->string);
- cJSON_free(c);
- c=next;
- }
+void cJSON_Delete(cJSON *c) {
+ cJSON *next;
+ while (c) {
+ next=c->next;
+ if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
+ if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
+ if (c->string) cJSON_free(c->string);
+ cJSON_free(c);
+ c=next;
+ }
}
/* Parse the input text to generate a number, and populate the result into item. */
-static const char *parse_number(cJSON *item,const char *num)
-{
- double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;
-
- /* Could use sscanf for this? */
- if (*num=='-') sign=-1,num++; /* Has sign? */
- if (*num=='0') num++; /* is zero */
- if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0'); while (*num>='0' && *num<='9'); /* Number? */
- if (*num=='.' && num[1]>='0' && num[1]<='9') {num++; do n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');} /* Fractional part? */
- if (*num=='e' || *num=='E') /* Exponent? */
- { num++;if (*num=='+') num++; else if (*num=='-') signsubscale=-1,num++; /* With sign? */
- while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */
- }
-
- n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
-
- item->valuedouble=n;
- item->valueint=(int)n;
- item->type=cJSON_Number;
- return num;
+static const char *parse_number(cJSON *item,const char *num) {
+ double n=0,sign=1,scale=0;
+ int subscale=0,signsubscale=1;
+
+ /* Could use sscanf for this? */
+ if (*num=='-') sign=-1,num++; /* Has sign? */
+ if (*num=='0') num++; /* is zero */
+ if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0');
+ while (*num>='0' && *num<='9'); /* Number? */
+ if (*num=='.' && num[1]>='0' && num[1]<='9') {
+ num++; /* Fractional part? */
+ do n=(n*10.0)+(*num++ -'0'),scale--;
+ while (*num>='0' && *num<='9');
+ }
+ if (*num=='e' || *num=='E') { /* Exponent? */
+ num++;
+ if (*num=='+') num++;
+ else if (*num=='-') signsubscale=-1,num++; /* With sign? */
+ while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */
+ }
+
+ n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
+
+ item->valuedouble=n;
+ item->valueint=(int)n;
+ item->type=cJSON_Number;
+ return num;
}
/* Render the number nicely from the given item into a string. */
-static char *print_number(cJSON *item)
-{
- char *str;
- double d=item->valuedouble;
- if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
- {
- str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */
- if (str) sprintf(str,"%d",item->valueint);
- }
- else
- {
- str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */
- if (str)
- {
- if (fabs(floor(d)-d)<=DBL_EPSILON) sprintf(str,"%.0f",d);
- else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
- else sprintf(str,"%f",d);
- }
- }
- return str;
+static char *print_number(cJSON *item) {
+ char *str;
+ double d=item->valuedouble;
+ if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN) {
+ str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */
+ if (str) sprintf(str,"%d",item->valueint);
+ } else {
+ str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */
+ if (str) {
+ if (fabs(floor(d)-d)<=DBL_EPSILON) sprintf(str,"%.0f",d);
+ else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
+ else sprintf(str,"%f",d);
+ }
+ }
+ return str;
}
/* Parse the input text into an unescaped cstring, and populate item. */
static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-static const char *parse_string(cJSON *item,const char *str)
-{
- const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
- if (*str!='\"') {ep=str;return 0;} /* not a string! */
-
- while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
-
- out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
- if (!out) return 0;
-
- ptr=str+1;ptr2=out;
- while (*ptr!='\"' && *ptr)
- {
- if (*ptr!='\\') *ptr2++=*ptr++;
- else
- {
- ptr++;
- switch (*ptr)
- {
- case 'b': *ptr2++='\b'; break;
- case 'f': *ptr2++='\f'; break;
- case 'n': *ptr2++='\n'; break;
- case 'r': *ptr2++='\r'; break;
- case 't': *ptr2++='\t'; break;
- case 'u': /* transcode utf16 to utf8. */
- sscanf(ptr+1,"%4x",&uc);ptr+=4; /* get the unicode char. */
-
- if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; // check for invalid.
-
- if (uc>=0xD800 && uc<=0xDBFF) // UTF16 surrogate pairs.
- {
- if (ptr[1]!='\\' || ptr[2]!='u') break; // missing second-half of surrogate.
- sscanf(ptr+3,"%4x",&uc2);ptr+=6;
- if (uc2<0xDC00 || uc2>0xDFFF) break; // invalid second-half of surrogate.
- uc=0x10000 | ((uc&0x3FF)<<10) | (uc2&0x3FF);
- }
-
- len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
-
- switch (len) {
- case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
- case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
- case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
- case 1: *--ptr2 =(uc | firstByteMark[len]);
- }
- ptr2+=len;
- break;
- default: *ptr2++=*ptr; break;
- }
- ptr++;
- }
- }
- *ptr2=0;
- if (*ptr=='\"') ptr++;
- item->valuestring=out;
- item->type=cJSON_String;
- return ptr;
+static const char *parse_string(cJSON *item,const char *str) {
+ const char *ptr=str+1;
+ char *ptr2;
+ char *out;
+ int len=0;
+ unsigned uc,uc2;
+ if (*str!='\"') {
+ ep=str; /* not a string! */
+ return 0;
+ }
+
+ while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
+
+ out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
+ if (!out) return 0;
+
+ ptr=str+1;
+ ptr2=out;
+ while (*ptr!='\"' && *ptr) {
+ if (*ptr!='\\') *ptr2++=*ptr++;
+ else {
+ ptr++;
+ switch (*ptr) {
+ case 'b':
+ *ptr2++='\b';
+ break;
+ case 'f':
+ *ptr2++='\f';
+ break;
+ case 'n':
+ *ptr2++='\n';
+ break;
+ case 'r':
+ *ptr2++='\r';
+ break;
+ case 't':
+ *ptr2++='\t';
+ break;
+ case 'u': /* transcode utf16 to utf8. */
+ sscanf(ptr+1,"%4x",&uc);
+ ptr+=4; /* get the unicode char. */
+
+ if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; // check for invalid.
+
+ if (uc>=0xD800 && uc<=0xDBFF) { // UTF16 surrogate pairs.
+ if (ptr[1]!='\\' || ptr[2]!='u') break; // missing second-half of surrogate.
+ sscanf(ptr+3,"%4x",&uc2);
+ ptr+=6;
+ if (uc2<0xDC00 || uc2>0xDFFF) break; // invalid second-half of surrogate.
+ uc=0x10000 | ((uc&0x3FF)<<10) | (uc2&0x3FF);
+ }
+
+ len=4;
+ if (uc<0x80) len=1;
+ else if (uc<0x800) len=2;
+ else if (uc<0x10000) len=3;
+ ptr2+=len;
+
+ switch (len) {
+ case 4:
+ *--ptr2 =((uc | 0x80) & 0xBF);
+ uc >>= 6;
+ case 3:
+ *--ptr2 =((uc | 0x80) & 0xBF);
+ uc >>= 6;
+ case 2:
+ *--ptr2 =((uc | 0x80) & 0xBF);
+ uc >>= 6;
+ case 1:
+ *--ptr2 =(uc | firstByteMark[len]);
+ }
+ ptr2+=len;
+ break;
+ default:
+ *ptr2++=*ptr;
+ break;
+ }
+ ptr++;
+ }
+ }
+ *ptr2=0;
+ if (*ptr=='\"') ptr++;
+ item->valuestring=out;
+ item->type=cJSON_String;
+ return ptr;
}
/* Render the cstring provided to an escaped version that can be printed. */
-static char *print_string_ptr(const char *str)
-{
- const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
-
- if (!str) return cJSON_strdup("");
- ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
-
- out=(char*)cJSON_malloc(len+3);
- if (!out) return 0;
-
- ptr2=out;ptr=str;
- *ptr2++='\"';
- while (*ptr)
- {
- if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++;
- else
- {
- *ptr2++='\\';
- switch (token=*ptr++)
- {
- case '\\': *ptr2++='\\'; break;
- case '\"': *ptr2++='\"'; break;
- case '\b': *ptr2++='b'; break;
- case '\f': *ptr2++='f'; break;
- case '\n': *ptr2++='n'; break;
- case '\r': *ptr2++='r'; break;
- case '\t': *ptr2++='t'; break;
- default: sprintf(ptr2,"u%04x",token);ptr2+=5; break; /* escape and print */
- }
- }
- }
- *ptr2++='\"';*ptr2++=0;
- return out;
+static char *print_string_ptr(const char *str) {
+ const char *ptr;
+ char *ptr2,*out;
+ int len=0;
+ unsigned char token;
+
+ if (!str) return cJSON_strdup("");
+ ptr=str;
+ while ((token=*ptr) && ++len) {
+ if (strchr("\"\\\b\f\n\r\t",token)) len++;
+ else if (token<32) len+=5;
+ ptr++;
+ }
+
+ out=(char*)cJSON_malloc(len+3);
+ if (!out) return 0;
+
+ ptr2=out;
+ ptr=str;
+ *ptr2++='\"';
+ while (*ptr) {
+ if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++;
+ else {
+ *ptr2++='\\';
+ switch (token=*ptr++) {
+ case '\\':
+ *ptr2++='\\';
+ break;
+ case '\"':
+ *ptr2++='\"';
+ break;
+ case '\b':
+ *ptr2++='b';
+ break;
+ case '\f':
+ *ptr2++='f';
+ break;
+ case '\n':
+ *ptr2++='n';
+ break;
+ case '\r':
+ *ptr2++='r';
+ break;
+ case '\t':
+ *ptr2++='t';
+ break;
+ default:
+ sprintf(ptr2,"u%04x",token);
+ ptr2+=5;
+ break; /* escape and print */
+ }
+ }
+ }
+ *ptr2++='\"';
+ *ptr2++=0;
+ return out;
}
/* Invote print_string_ptr (which is useful) on an item. */
-static char *print_string(cJSON *item) {return print_string_ptr(item->valuestring);}
+static char *print_string(cJSON *item) {
+ return print_string_ptr(item->valuestring);
+}
/* Predeclare these prototypes. */
static const char *parse_value(cJSON *item,const char *value);
@@ -246,269 +298,502 @@ static const char *parse_object(cJSON *item,const char *value);
static char *print_object(cJSON *item,int depth,int fmt);
/* Utility to jump whitespace and cr/lf */
-static const char *skip(const char *in) {while (in && *in && (unsigned char)*in<=32) in++; return in;}
+static const char *skip(const char *in) {
+ while (in && *in && (unsigned char)*in<=32) in++;
+ return in;
+}
/* Parse an object - create a new root, and populate. */
-cJSON *cJSON_Parse(const char *value)
-{
- cJSON *c=cJSON_New_Item();
- ep=0;
- if (!c) return 0; /* memory fail */
-
- if (!parse_value(c,skip(value))) {cJSON_Delete(c);return 0;}
- return c;
+cJSON *cJSON_Parse(const char *value) {
+ cJSON *c=cJSON_New_Item();
+ ep=0;
+ if (!c) return 0; /* memory fail */
+
+ if (!parse_value(c,skip(value))) {
+ cJSON_Delete(c);
+ return 0;
+ }
+ return c;
}
/* Render a cJSON item/entity/structure to text. */
-char *cJSON_Print(cJSON *item) {return print_value(item,0,1);}
-char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0);}
+char *cJSON_Print(cJSON *item) {
+ return print_value(item,0,1);
+}
+char *cJSON_PrintUnformatted(cJSON *item) {
+ return print_value(item,0,0);
+}
/* Parser core - when encountering text, process appropriately. */
-static const char *parse_value(cJSON *item,const char *value)
-{
- if (!value) return 0; /* Fail on null. */
- if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; }
- if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; }
- if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; }
- if (*value=='\"') { return parse_string(item,value); }
- if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); }
- if (*value=='[') { return parse_array(item,value); }
- if (*value=='{') { return parse_object(item,value); }
+static const char *parse_value(cJSON *item,const char *value) {
+ if (!value) return 0; /* Fail on null. */
+ if (!strncmp(value,"null",4)) {
+ item->type=cJSON_NULL;
+ return value+4;
+ }
+ if (!strncmp(value,"false",5)) {
+ item->type=cJSON_False;
+ return value+5;
+ }
+ if (!strncmp(value,"true",4)) {
+ item->type=cJSON_True;
+ item->valueint=1;
+ return value+4;
+ }
+ if (*value=='\"') {
+ return parse_string(item,value);
+ }
+ if (*value=='-' || (*value>='0' && *value<='9')) {
+ return parse_number(item,value);
+ }
+ if (*value=='[') {
+ return parse_array(item,value);
+ }
+ if (*value=='{') {
+ return parse_object(item,value);
+ }
- ep=value;return 0; /* failure. */
+ ep=value;
+ return 0; /* failure. */
}
/* Render a value to text. */
-static char *print_value(cJSON *item,int depth,int fmt)
-{
- char *out=0;
- if (!item) return 0;
- switch ((item->type)&255)
- {
- case cJSON_NULL: out=cJSON_strdup("null"); break;
- case cJSON_False: out=cJSON_strdup("false");break;
- case cJSON_True: out=cJSON_strdup("true"); break;
- case cJSON_Number: out=print_number(item);break;
- case cJSON_String: out=print_string(item);break;
- case cJSON_Array: out=print_array(item,depth,fmt);break;
- case cJSON_Object: out=print_object(item,depth,fmt);break;
- }
- return out;
+static char *print_value(cJSON *item,int depth,int fmt) {
+ char *out=0;
+ if (!item) return 0;
+ switch ((item->type)&255) {
+ case cJSON_NULL:
+ out=cJSON_strdup("null");
+ break;
+ case cJSON_False:
+ out=cJSON_strdup("false");
+ break;
+ case cJSON_True:
+ out=cJSON_strdup("true");
+ break;
+ case cJSON_Number:
+ out=print_number(item);
+ break;
+ case cJSON_String:
+ out=print_string(item);
+ break;
+ case cJSON_Array:
+ out=print_array(item,depth,fmt);
+ break;
+ case cJSON_Object:
+ out=print_object(item,depth,fmt);
+ break;
+ }
+ return out;
}
/* Build an array from input text. */
-static const char *parse_array(cJSON *item,const char *value)
-{
- cJSON *child;
- if (*value!='[') {ep=value;return 0;} /* not an array! */
-
- item->type=cJSON_Array;
- value=skip(value+1);
- if (*value==']') return value+1; /* empty array. */
-
- item->child=child=cJSON_New_Item();
- if (!item->child) return 0; /* memory fail */
- value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
- if (!value) return 0;
+static const char *parse_array(cJSON *item,const char *value) {
+ cJSON *child;
+ if (*value!='[') {
+ ep=value; /* not an array! */
+ return 0;
+ }
- while (*value==',')
- {
- cJSON *new_item;
- if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
- child->next=new_item;new_item->prev=child;child=new_item;
- value=skip(parse_value(child,skip(value+1)));
- if (!value) return 0; /* memory fail */
- }
+ item->type=cJSON_Array;
+ value=skip(value+1);
+ if (*value==']') return value+1; /* empty array. */
+
+ item->child=child=cJSON_New_Item();
+ if (!item->child) return 0; /* memory fail */
+ value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
+ if (!value) return 0;
+
+ while (*value==',') {
+ cJSON *new_item;
+ if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
+ child->next=new_item;
+ new_item->prev=child;
+ child=new_item;
+ value=skip(parse_value(child,skip(value+1)));
+ if (!value) return 0; /* memory fail */
+ }
- if (*value==']') return value+1; /* end of array */
- ep=value;return 0; /* malformed. */
+ if (*value==']') return value+1; /* end of array */
+ ep=value;
+ return 0; /* malformed. */
}
/* Render an array to text */
-static char *print_array(cJSON *item,int depth,int fmt)
-{
- char **entries;
- char *out=0,*ptr,*ret;int len=5;
- cJSON *child=item->child;
- int numentries=0,i=0,fail=0;
-
- /* How many entries in the array? */
- while (child) numentries++,child=child->next;
- /* Allocate an array to hold the values for each */
- entries=(char**)cJSON_malloc(numentries*sizeof(char*));
- if (!entries) return 0;
- memset(entries,0,numentries*sizeof(char*));
- /* Retrieve all the results: */
- child=item->child;
- while (child && !fail)
- {
- ret=print_value(child,depth+1,fmt);
- entries[i++]=ret;
- if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1;
- child=child->next;
- }
-
- /* If we didn't fail, try to malloc the output string */
- if (!fail) out=(char*)cJSON_malloc(len);
- /* If that fails, we fail. */
- if (!out) fail=1;
-
- /* Handle failure. */
- if (fail)
- {
- for (i=0;i<numentries;i++) if (entries[i]) cJSON_free(entries[i]);
- cJSON_free(entries);
- return 0;
- }
-
- /* Compose the output array. */
- *out='[';
- ptr=out+1;*ptr=0;
- for (i=0;i<numentries;i++)
- {
- strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
- if (i!=numentries-1) {*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;}
- cJSON_free(entries[i]);
- }
- cJSON_free(entries);
- *ptr++=']';*ptr++=0;
- return out;
+static char *print_array(cJSON *item,int depth,int fmt) {
+ char **entries;
+ char *out=0,*ptr,*ret;
+ int len=5;
+ cJSON *child=item->child;
+ int numentries=0,i=0,fail=0;
+
+ /* How many entries in the array? */
+ while (child) numentries++,child=child->next;
+ /* Allocate an array to hold the values for each */
+ entries=(char**)cJSON_malloc(numentries*sizeof(char*));
+ if (!entries) return 0;
+ memset(entries,0,numentries*sizeof(char*));
+ /* Retrieve all the results: */
+ child=item->child;
+ while (child && !fail) {
+ ret=print_value(child,depth+1,fmt);
+ entries[i++]=ret;
+ if (ret) len+=strlen(ret)+2+(fmt?1:0);
+ else fail=1;
+ child=child->next;
+ }
+
+ /* If we didn't fail, try to malloc the output string */
+ if (!fail) out=(char*)cJSON_malloc(len);
+ /* If that fails, we fail. */
+ if (!out) fail=1;
+
+ /* Handle failure. */
+ if (fail) {
+ for (i=0; i<numentries; i++) if (entries[i]) cJSON_free(entries[i]);
+ cJSON_free(entries);
+ return 0;
+ }
+
+ /* Compose the output array. */
+ *out='[';
+ ptr=out+1;
+ *ptr=0;
+ for (i=0; i<numentries; i++) {
+ strcpy(ptr,entries[i]);
+ ptr+=strlen(entries[i]);
+ if (i!=numentries-1) {
+ *ptr++=',';
+ if(fmt)*ptr++=' ';
+ *ptr=0;
+ }
+ cJSON_free(entries[i]);
+ }
+ cJSON_free(entries);
+ *ptr++=']';
+ *ptr++=0;
+ return out;
}
/* Build an object from the text. */
-static const char *parse_object(cJSON *item,const char *value)
-{
- cJSON *child;
- if (*value!='{') {ep=value;return 0;} /* not an object! */
-
- item->type=cJSON_Object;
- value=skip(value+1);
- if (*value=='}') return value+1; /* empty array. */
-
- item->child=child=cJSON_New_Item();
- if (!item->child) return 0;
- value=skip(parse_string(child,skip(value)));
- if (!value) return 0;
- child->string=child->valuestring;child->valuestring=0;
- if (*value!=':') {ep=value;return 0;} /* fail! */
- value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
- if (!value) return 0;
-
- while (*value==',')
- {
- cJSON *new_item;
- if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
- child->next=new_item;new_item->prev=child;child=new_item;
- value=skip(parse_string(child,skip(value+1)));
- if (!value) return 0;
- child->string=child->valuestring;child->valuestring=0;
- if (*value!=':') {ep=value;return 0;} /* fail! */
- value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
- if (!value) return 0;
- }
-
- if (*value=='}') return value+1; /* end of array */
- ep=value;return 0; /* malformed. */
+static const char *parse_object(cJSON *item,const char *value) {
+ cJSON *child;
+ if (*value!='{') {
+ ep=value; /* not an object! */
+ return 0;
+ }
+
+ item->type=cJSON_Object;
+ value=skip(value+1);
+ if (*value=='}') return value+1; /* empty array. */
+
+ item->child=child=cJSON_New_Item();
+ if (!item->child) return 0;
+ value=skip(parse_string(child,skip(value)));
+ if (!value) return 0;
+ child->string=child->valuestring;
+ child->valuestring=0;
+ if (*value!=':') {
+ ep=value; /* fail! */
+ return 0;
+ }
+ value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
+ if (!value) return 0;
+
+ while (*value==',') {
+ cJSON *new_item;
+ if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
+ child->next=new_item;
+ new_item->prev=child;
+ child=new_item;
+ value=skip(parse_string(child,skip(value+1)));
+ if (!value) return 0;
+ child->string=child->valuestring;
+ child->valuestring=0;
+ if (*value!=':') {
+ ep=value; /* fail! */
+ return 0;
+ }
+ value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
+ if (!value) return 0;
+ }
+
+ if (*value=='}') return value+1; /* end of array */
+ ep=value;
+ return 0; /* malformed. */
}
/* Render an object to text. */
-static char *print_object(cJSON *item,int depth,int fmt)
-{
- char **entries=0,**names=0;
- char *out=0,*ptr,*ret,*str;int len=7,i=0,j;
- cJSON *child=item->child;
- int numentries=0,fail=0;
- /* Count the number of entries. */
- while (child) numentries++,child=child->next;
- /* Allocate space for the names and the objects */
- entries=(char**)cJSON_malloc(numentries*sizeof(char*));
- if (!entries) return 0;
- names=(char**)cJSON_malloc(numentries*sizeof(char*));
- if (!names) {cJSON_free(entries);return 0;}
- memset(entries,0,sizeof(char*)*numentries);
- memset(names,0,sizeof(char*)*numentries);
-
- /* Collect all the results into our arrays: */
- child=item->child;depth++;if (fmt) len+=depth;
- while (child)
- {
- names[i]=str=print_string_ptr(child->string);
- entries[i++]=ret=print_value(child,depth,fmt);
- if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
- child=child->next;
- }
-
- /* Try to allocate the output string */
- if (!fail) out=(char*)cJSON_malloc(len);
- if (!out) fail=1;
-
- /* Handle failure */
- if (fail)
- {
- for (i=0;i<numentries;i++) {if (names[i]) cJSON_free(names[i]);if (entries[i]) cJSON_free(entries[i]);}
- cJSON_free(names);cJSON_free(entries);
- return 0;
- }
-
- /* Compose the output: */
- *out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0;
- for (i=0;i<numentries;i++)
- {
- if (fmt) for (j=0;j<depth;j++) *ptr++='\t';
- strcpy(ptr,names[i]);ptr+=strlen(names[i]);
- *ptr++=':';if (fmt) *ptr++='\t';
- strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
- if (i!=numentries-1) *ptr++=',';
- if (fmt) *ptr++='\n';*ptr=0;
- cJSON_free(names[i]);cJSON_free(entries[i]);
- }
-
- cJSON_free(names);cJSON_free(entries);
- if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
- *ptr++='}';*ptr++=0;
- return out;
+static char *print_object(cJSON *item,int depth,int fmt) {
+ char **entries=0,**names=0;
+ char *out=0,*ptr,*ret,*str;
+ int len=7,i=0,j;
+ cJSON *child=item->child;
+ int numentries=0,fail=0;
+ /* Count the number of entries. */
+ while (child) numentries++,child=child->next;
+ /* Allocate space for the names and the objects */
+ entries=(char**)cJSON_malloc(numentries*sizeof(char*));
+ if (!entries) return 0;
+ names=(char**)cJSON_malloc(numentries*sizeof(char*));
+ if (!names) {
+ cJSON_free(entries);
+ return 0;
+ }
+ memset(entries,0,sizeof(char*)*numentries);
+ memset(names,0,sizeof(char*)*numentries);
+
+ /* Collect all the results into our arrays: */
+ child=item->child;
+ depth++;
+ if (fmt) len+=depth;
+ while (child) {
+ names[i]=str=print_string_ptr(child->string);
+ entries[i++]=ret=print_value(child,depth,fmt);
+ if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0);
+ else fail=1;
+ child=child->next;
+ }
+
+ /* Try to allocate the output string */
+ if (!fail) out=(char*)cJSON_malloc(len);
+ if (!out) fail=1;
+
+ /* Handle failure */
+ if (fail) {
+ for (i=0; i<numentries; i++) {
+ if (names[i]) cJSON_free(names[i]);
+ if (entries[i]) cJSON_free(entries[i]);
+ }
+ cJSON_free(names);
+ cJSON_free(entries);
+ return 0;
+ }
+
+ /* Compose the output: */
+ *out='{';
+ ptr=out+1;
+ if (fmt)*ptr++='\n';
+ *ptr=0;
+ for (i=0; i<numentries; i++) {
+ if (fmt) for (j=0; j<depth; j++) *ptr++='\t';
+ strcpy(ptr,names[i]);
+ ptr+=strlen(names[i]);
+ *ptr++=':';
+ if (fmt) *ptr++='\t';
+ strcpy(ptr,entries[i]);
+ ptr+=strlen(entries[i]);
+ if (i!=numentries-1) *ptr++=',';
+ if (fmt) *ptr++='\n';
+ *ptr=0;
+ cJSON_free(names[i]);
+ cJSON_free(entries[i]);
+ }
+
+ cJSON_free(names);
+ cJSON_free(entries);
+ if (fmt) for (i=0; i<depth-1; i++) *ptr++='\t';
+ *ptr++='}';
+ *ptr++=0;
+ return out;
}
/* Get Array size/item / object item. */
-int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
-cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
-cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
+int cJSON_GetArraySize(cJSON *array) {
+ cJSON *c=array->child;
+ int i=0;
+ while(c)i++,c=c->next;
+ return i;
+}
+cJSON *cJSON_GetArrayItem(cJSON *array,int item) {
+ cJSON *c=array->child;
+ while (c && item>0) item--,c=c->next;
+ return c;
+}
+cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {
+ cJSON *c=object->child;
+ while (c && cJSON_strcasecmp(c->string,string)) c=c->next;
+ return c;
+}
/* Utility for array list handling. */
-static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
+static void suffix_object(cJSON *prev,cJSON *item) {
+ prev->next=item;
+ item->prev=prev;
+}
/* Utility for handling references. */
-static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
+static cJSON *create_reference(cJSON *item) {
+ cJSON *ref=cJSON_New_Item();
+ if (!ref) return 0;
+ memcpy(ref,item,sizeof(cJSON));
+ ref->string=0;
+ ref->type|=cJSON_IsReference;
+ ref->next=ref->prev=0;
+ return ref;
+}
/* Add item to array/object. */
-void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
-void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
-void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
-void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
+void cJSON_AddItemToArray(cJSON *array, cJSON *item) {
+ cJSON *c=array->child;
+ if (!item) return;
+ if (!c) {
+ array->child=item;
+ } else {
+ while (c && c->next) c=c->next;
+ suffix_object(c,item);
+ }
+}
+void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {
+ if (!item) return;
+ if (item->string) cJSON_free(item->string);
+ item->string=cJSON_strdup(string);
+ cJSON_AddItemToArray(object,item);
+}
+void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {
+ cJSON_AddItemToArray(array,create_reference(item));
+}
+void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {
+ cJSON_AddItemToObject(object,string,create_reference(item));
+}
-cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
- if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
-void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
-cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
-void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
+cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {
+ cJSON *c=array->child;
+ while (c && which>0) c=c->next,which--;
+ if (!c) return 0;
+ if (c->prev) c->prev->next=c->next;
+ if (c->next) c->next->prev=c->prev;
+ if (c==array->child) array->child=c->next;
+ c->prev=c->next=0;
+ return c;
+}
+void cJSON_DeleteItemFromArray(cJSON *array,int which) {
+ cJSON_Delete(cJSON_DetachItemFromArray(array,which));
+}
+cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {
+ int i=0;
+ cJSON *c=object->child;
+ while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;
+ if (c) return cJSON_DetachItemFromArray(object,i);
+ return 0;
+}
+void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {
+ cJSON_Delete(cJSON_DetachItemFromObject(object,string));
+}
/* Replace array/object items with new ones. */
-void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
- newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
- if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
-void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
+void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {
+ cJSON *c=array->child;
+ while (c && which>0) c=c->next,which--;
+ if (!c) return;
+ newitem->next=c->next;
+ newitem->prev=c->prev;
+ if (newitem->next) newitem->next->prev=newitem;
+ if (c==array->child) array->child=newitem;
+ else newitem->prev->next=newitem;
+ c->next=c->prev=0;
+ cJSON_Delete(c);
+}
+void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem) {
+ int i=0;
+ cJSON *c=object->child;
+ while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;
+ if(c) {
+ newitem->string=cJSON_strdup(string);
+ cJSON_ReplaceItemInArray(object,i,newitem);
+ }
+}
/* Create basic types: */
-cJSON *cJSON_CreateNull() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
-cJSON *cJSON_CreateTrue() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
-cJSON *cJSON_CreateFalse() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
-cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
-cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;}
-cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;}
-cJSON *cJSON_CreateArray() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;}
-cJSON *cJSON_CreateObject() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}
+cJSON *cJSON_CreateNull() {
+ cJSON *item=cJSON_New_Item();
+ if(item)item->type=cJSON_NULL;
+ return item;
+}
+cJSON *cJSON_CreateTrue() {
+ cJSON *item=cJSON_New_Item();
+ if(item)item->type=cJSON_True;
+ return item;
+}
+cJSON *cJSON_CreateFalse() {
+ cJSON *item=cJSON_New_Item();
+ if(item)item->type=cJSON_False;
+ return item;
+}
+cJSON *cJSON_CreateBool(int b) {
+ cJSON *item=cJSON_New_Item();
+ if(item)item->type=b?cJSON_True:cJSON_False;
+ return item;
+}
+cJSON *cJSON_CreateNumber(double num) {
+ cJSON *item=cJSON_New_Item();
+ if(item) {
+ item->type=cJSON_Number;
+ item->valuedouble=num;
+ item->valueint=(int)num;
+ }
+ return item;
+}
+cJSON *cJSON_CreateString(const char *string) {
+ cJSON *item=cJSON_New_Item();
+ if(item) {
+ item->type=cJSON_String;
+ item->valuestring=cJSON_strdup(string);
+ }
+ return item;
+}
+cJSON *cJSON_CreateArray() {
+ cJSON *item=cJSON_New_Item();
+ if(item)item->type=cJSON_Array;
+ return item;
+}
+cJSON *cJSON_CreateObject() {
+ cJSON *item=cJSON_New_Item();
+ if(item)item->type=cJSON_Object;
+ return item;
+}
/* Create Arrays: */
-cJSON *cJSON_CreateIntArray(int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
-cJSON *cJSON_CreateFloatArray(float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
-cJSON *cJSON_CreateDoubleArray(double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
-cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
+cJSON *cJSON_CreateIntArray(int *numbers,int count) {
+ int i;
+ cJSON *n=0,*p=0,*a=cJSON_CreateArray();
+ for(i=0; a && i<count; i++) {
+ n=cJSON_CreateNumber(numbers[i]);
+ if(!i)a->child=n;
+ else suffix_object(p,n);
+ p=n;
+ }
+ return a;
+}
+cJSON *cJSON_CreateFloatArray(float *numbers,int count) {
+ int i;
+ cJSON *n=0,*p=0,*a=cJSON_CreateArray();
+ for(i=0; a && i<count; i++) {
+ n=cJSON_CreateNumber(numbers[i]);
+ if(!i)a->child=n;
+ else suffix_object(p,n);
+ p=n;
+ }
+ return a;
+}
+cJSON *cJSON_CreateDoubleArray(double *numbers,int count) {
+ int i;
+ cJSON *n=0,*p=0,*a=cJSON_CreateArray();
+ for(i=0; a && i<count; i++) {
+ n=cJSON_CreateNumber(numbers[i]);
+ if(!i)a->child=n;
+ else suffix_object(p,n);
+ p=n;
+ }
+ return a;
+}
+cJSON *cJSON_CreateStringArray(const char **strings,int count) {
+ int i;
+ cJSON *n=0,*p=0,*a=cJSON_CreateArray();
+ for(i=0; a && i<count; i++) {
+ n=cJSON_CreateString(strings[i]);
+ if(!i)a->child=n;
+ else suffix_object(p,n);
+ p=n;
+ }
+ return a;
+}
diff --git a/navit/vehicle/webos/cJSON.h b/navit/vehicle/webos/cJSON.h
index 97d529aea..61500858f 100644
--- a/navit/vehicle/webos/cJSON.h
+++ b/navit/vehicle/webos/cJSON.h
@@ -1,16 +1,16 @@
/*
Copyright (c) 2009 Dave Gamble
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -36,7 +36,7 @@ extern "C"
#define cJSON_String 4
#define cJSON_Array 5
#define cJSON_Object 6
-
+
#define cJSON_IsReference 256
/* The cJSON structure: */
@@ -80,7 +80,7 @@ extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
extern const char *cJSON_GetErrorPtr(void);
-
+
/* These calls create a cJSON item of the appropriate type. */
extern cJSON *cJSON_CreateNull(void);
extern cJSON *cJSON_CreateTrue(void);
@@ -109,7 +109,7 @@ extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
-
+
/* Update array items. */
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
diff --git a/navit/vehicle/webos/vehicle_webos.c b/navit/vehicle/webos/vehicle_webos.c
index a5bba4bce..c81b6342b 100644
--- a/navit/vehicle/webos/vehicle_webos.c
+++ b/navit/vehicle/webos/vehicle_webos.c
@@ -1,4 +1,4 @@
-/**
+/*
* vim: sw=3 ts=3
*
* Navit, a modular navigation system.
@@ -26,7 +26,7 @@
#include <errno.h>
#include <sys/time.h>
#include <PDL.h>
-#include <SDL.h>
+#include "SDL.h"
#include "debug.h"
#include "callback.h"
#include "plugin.h"
@@ -37,350 +37,332 @@
#include "vehicle_webos.h"
#include "bluetooth.h"
+/**
+ * @defgroup vehicle-webos Vehicle WebOS
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from WebOS
+ *
+ * @{
+ */
+
static char *vehicle_webos_prefix="webos:";
/*******************************************************************/
-static void
-vehicle_webos_callback(PDL_ServiceParameters *params, void *priv)
-{
- PDL_Location *location;
- SDL_Event event;
- SDL_UserEvent userevent;
- int err;
+static void vehicle_webos_callback(PDL_ServiceParameters *params, void *priv) {
+ PDL_Location *location;
+ SDL_Event event;
+ SDL_UserEvent userevent;
+ int err;
- err = PDL_GetParamInt(params, "errorCode");
- if (err != 0) {
- dbg(lvl_error,"Location Callback errorCode %d\n", err);
- return /*PDL_EOTHER*/;
- }
+ err = PDL_GetParamInt(params, "errorCode");
+ if (err != 0) {
+ dbg(lvl_error,"Location Callback errorCode %d", err);
+ return /*PDL_EOTHER*/;
+ }
- location = g_new0 (PDL_Location, 1);
+ location = g_new0 (PDL_Location, 1);
- location->altitude = PDL_GetParamDouble(params, "altitude");
- location->velocity = PDL_GetParamDouble(params, "velocity");
- location->heading = PDL_GetParamDouble(params, "heading");
- location->horizontalAccuracy = PDL_GetParamDouble(params, "horizAccuracy");
- location->latitude = PDL_GetParamDouble(params, "latitude");
- location->longitude = PDL_GetParamDouble(params, "longitude");
+ location->altitude = PDL_GetParamDouble(params, "altitude");
+ location->velocity = PDL_GetParamDouble(params, "velocity");
+ location->heading = PDL_GetParamDouble(params, "heading");
+ location->horizontalAccuracy = PDL_GetParamDouble(params, "horizAccuracy");
+ location->latitude = PDL_GetParamDouble(params, "latitude");
+ location->longitude = PDL_GetParamDouble(params, "longitude");
- userevent.type = SDL_USEREVENT;
- userevent.code = PDL_GPS_UPDATE;
- userevent.data1 = location;
- userevent.data2 = NULL;
+ userevent.type = SDL_USEREVENT;
+ userevent.code = PDL_GPS_UPDATE;
+ userevent.data1 = location;
+ userevent.data2 = NULL;
- event.type = SDL_USEREVENT;
- event.user = userevent;
+ event.type = SDL_USEREVENT;
+ event.user = userevent;
- SDL_PushEvent(&event);
+ SDL_PushEvent(&event);
- return /*PDL_NOERROR*/;
+ return /*PDL_NOERROR*/;
}
-static void
-vehicle_webos_gps_update(struct vehicle_priv *priv, PDL_Location *location)
-{
- if(location) { // location may be NULL if called by bluetooth-code. priv is already prefilled there
- struct timeval tv;
- gettimeofday(&tv,NULL);
-
- priv->delta = (int)difftime(tv.tv_sec, priv->fix_time);
- dbg(lvl_info,"delta(%i)\n",priv->delta);
- priv->fix_time = tv.tv_sec;
- priv->geo.lat = location->latitude;
- /* workaround for webOS GPS bug following */
- priv->geo.lng = (priv->pdk_version >= 200 && location->longitude >= -1 && location->longitude <= 1) ?
- -location->longitude : location->longitude;
-
- dbg(lvl_info,"Location: %f %f %f %.12g %.12g +-%fm\n",
- location->altitude,
- location->velocity,
- location->heading,
- priv->geo.lat,
- priv->geo.lng,
- location->horizontalAccuracy);
-
- if (location->altitude != -1)
- priv->altitude = location->altitude;
- if (location->velocity != -1)
- priv->speed = location->velocity * 3.6;
- if (location->heading != -1)
- priv->track = location->heading;
- if (location->horizontalAccuracy != -1)
- priv->radius = location->horizontalAccuracy;
-
- if (priv->pdk_version <= 100)
- g_free(location);
- }
-
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+static void vehicle_webos_gps_update(struct vehicle_priv *priv, PDL_Location *location) {
+ if(location) { // location may be NULL if called by bluetooth-code. priv is already prefilled there
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+
+ priv->delta = (int)difftime(tv.tv_sec, priv->fix_time);
+ dbg(lvl_info,"delta(%i)",priv->delta);
+ priv->fix_time = tv.tv_sec;
+ priv->geo.lat = location->latitude;
+ /* workaround for webOS GPS bug following */
+ priv->geo.lng = (priv->pdk_version >= 200 && location->longitude >= -1 && location->longitude <= 1) ?
+ -location->longitude : location->longitude;
+
+ dbg(lvl_info,"Location: %f %f %f %.12g %.12g +-%fm",
+ location->altitude,
+ location->velocity,
+ location->heading,
+ priv->geo.lat,
+ priv->geo.lng,
+ location->horizontalAccuracy);
+
+ if (location->altitude != -1)
+ priv->altitude = location->altitude;
+ if (location->velocity != -1)
+ priv->speed = location->velocity * 3.6;
+ if (location->heading != -1)
+ priv->track = location->heading;
+ if (location->horizontalAccuracy != -1)
+ priv->radius = location->horizontalAccuracy;
+
+ if (priv->pdk_version <= 100)
+ g_free(location);
+ }
+
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
}
-static void
-vehicle_webos_timeout_callback(struct vehicle_priv *priv)
-{
- struct timeval tv;
- gettimeofday(&tv,NULL);
+static void vehicle_webos_timeout_callback(struct vehicle_priv *priv) {
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
- if (priv->fix_time && priv->delta) {
- int delta = (int)difftime(tv.tv_sec, priv->fix_time);
+ if (priv->fix_time && priv->delta) {
+ int delta = (int)difftime(tv.tv_sec, priv->fix_time);
- if (delta >= priv->delta*2) {
- dbg(lvl_warning, "GPS timeout triggered cb(%p) delta(%d)\n", priv->timeout_cb, delta);
+ if (delta >= priv->delta*2) {
+ dbg(lvl_warning, "GPS timeout triggered cb(%p) delta(%d)", priv->timeout_cb, delta);
- priv->delta = -1;
+ priv->delta = -1;
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
- }
- }
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+ }
+ }
}
-void
-vehicle_webos_close(struct vehicle_priv *priv)
-{
- event_remove_timeout(priv->ev_timeout);
- priv->ev_timeout = NULL;
+void vehicle_webos_close(struct vehicle_priv *priv) {
+ event_remove_timeout(priv->ev_timeout);
+ priv->ev_timeout = NULL;
- callback_destroy(priv->timeout_cb);
+ callback_destroy(priv->timeout_cb);
- if (priv->pdk_version <= 100)
- PDL_UnregisterServiceCallback((PDL_ServiceCallbackFunc)vehicle_webos_callback);
- else {
- PDL_EnableLocationTracking(PDL_FALSE);
- vehicle_webos_bt_close(priv);
- }
+ if (priv->pdk_version <= 100)
+ PDL_UnregisterServiceCallback((PDL_ServiceCallbackFunc)vehicle_webos_callback);
+ else {
+ PDL_EnableLocationTracking(PDL_FALSE);
+ vehicle_webos_bt_close(priv);
+ }
}
-static int
-vehicle_webos_open(struct vehicle_priv *priv)
-{
- PDL_Err err;
-
- priv->pdk_version = PDL_GetPDKVersion();
- dbg(lvl_debug,"pdk_version(%d)\n", priv->pdk_version);
-
- if (priv->pdk_version <= 100) {
- // Use Location Service via callback interface
- err = PDL_ServiceCallWithCallback("palm://com.palm.location/startTracking",
- "{subscribe:true}",
- (PDL_ServiceCallbackFunc)vehicle_webos_callback,
- priv,
- PDL_FALSE);
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"PDL_ServiceCallWithCallback failed with (%d): (%s)\n", err, PDL_GetError());
- vehicle_webos_close(priv);
- return 0;
- }
- }
- else {
- PDL_Err err;
- err = PDL_EnableLocationTracking(PDL_TRUE);
- if (err != PDL_NOERROR) {
- dbg(lvl_error,"PDL_EnableLocationTracking failed with (%d): (%s)\n", err, PDL_GetError());
+static int vehicle_webos_open(struct vehicle_priv *priv) {
+ PDL_Err err;
+
+ priv->pdk_version = PDL_GetPDKVersion();
+ dbg(lvl_debug,"pdk_version(%d)", priv->pdk_version);
+
+ if (priv->pdk_version <= 100) {
+ // Use Location Service via callback interface
+ err = PDL_ServiceCallWithCallback("palm://com.palm.location/startTracking",
+ "{subscribe:true}",
+ (PDL_ServiceCallbackFunc)vehicle_webos_callback,
+ priv,
+ PDL_FALSE);
+ if (err != PDL_NOERROR) {
+ dbg(lvl_error,"PDL_ServiceCallWithCallback failed with (%d): (%s)", err, PDL_GetError());
+ vehicle_webos_close(priv);
+ return 0;
+ }
+ } else {
+ PDL_Err err;
+ err = PDL_EnableLocationTracking(PDL_TRUE);
+ if (err != PDL_NOERROR) {
+ dbg(lvl_error,"PDL_EnableLocationTracking failed with (%d): (%s)", err, PDL_GetError());
// vehicle_webos_close(priv);
// return 0;
- }
-
- priv->gps_type = GPS_TYPE_INT;
+ }
+
+ priv->gps_type = GPS_TYPE_INT;
- if(!vehicle_webos_bt_open(priv))
- return 0;
- }
+ if(!vehicle_webos_bt_open(priv))
+ return 0;
+ }
- priv->ev_timeout = event_add_timeout(1000, 1, priv->timeout_cb);
- return 1;
+ priv->ev_timeout = event_add_timeout(1000, 1, priv->timeout_cb);
+ return 1;
}
-static void
-vehicle_webos_destroy(struct vehicle_priv *priv)
-{
- vehicle_webos_close(priv);
- if (priv->source)
- g_free(priv->source);
- g_free(priv);
+static void vehicle_webos_destroy(struct vehicle_priv *priv) {
+ vehicle_webos_close(priv);
+ if (priv->source)
+ g_free(priv->source);
+ g_free(priv);
}
-static int
-vehicle_webos_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_position_height:
- dbg(lvl_info,"Altitude: %f\n", priv->altitude);
- attr->u.numd = &priv->altitude;
- break;
- case attr_position_speed:
- dbg(lvl_info,"Speed: %f\n", priv->speed);
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- dbg(lvl_info,"Direction: %f\n", priv->track);
- attr->u.numd = &priv->track;
- break;
- case attr_position_magnetic_direction:
- switch (priv->gps_type) {
- case GPS_TYPE_BT:
- attr->u.num = priv->magnetic_direction;
- break;
- default:
- return 0;
- break;
- }
- break;
- case attr_position_hdop:
- switch (priv->gps_type) {
- case GPS_TYPE_BT:
- attr->u.numd = &priv->hdop;
- break;
- default:
- return 0;
- break;
- }
- break;
- case attr_position_coord_geo:
- dbg(lvl_info,"Coord: %.12g %.12g\n", priv->geo.lat, priv->geo.lng);
- attr->u.coord_geo = &priv->geo;
- break;
- case attr_position_radius:
- dbg(lvl_info,"Radius: %f\n", priv->radius);
- attr->u.numd = &priv->radius;
- break;
- case attr_position_time_iso8601:
- if (priv->fix_time) {
- struct tm tm;
- if (gmtime_r(&priv->fix_time, &tm)) {
- strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
- "%Y-%m-%dT%TZ", &tm);
- attr->u.str=priv->fixiso8601;
- }
- else {
- priv->fix_time = 0;
- return 0;
- }
- dbg(lvl_info,"Fix Time: %d %s\n", priv->fix_time, priv->fixiso8601);
- }
- else {
- dbg(lvl_info,"Fix Time: %d\n", priv->fix_time);
- return 0;
- }
-
- break;
- case attr_position_fix_type:
- switch (priv->gps_type) {
- case GPS_TYPE_INT:
- if (priv->delta <= 0 || priv->radius == 0.0)
- attr->u.num = 0; // strength = 1
- else if (priv->radius > 20.0)
- attr->u.num = 1; // strength >= 2
- else
- attr->u.num = 2; // strength >= 2
- break;
- case GPS_TYPE_BT:
- attr->u.num = priv->status;
- break;
- default:
- return 0;
- break;
- }
- break;
- case attr_position_sats_used:
- switch (priv->gps_type) {
- case GPS_TYPE_INT:
- if (priv->delta <= 0)
- attr->u.num = 0;
- else if (priv->radius <= 6.0 )
- attr->u.num = 6; // strength = 5
- else if (priv->radius <= 10.0 )
- attr->u.num = 5; // strength = 4
- else if (priv->radius <= 15.0 )
- attr->u.num = 4; // strength = 3
- else
- return 0;
- break;
- case GPS_TYPE_BT:
- attr->u.num = priv->sats_used;
- break;
- default:
- return 0;
- break;
- }
- break;
- default:
- return 0;
- }
- attr->type = type;
- return 1;
+static int vehicle_webos_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ switch (type) {
+ case attr_position_height:
+ dbg(lvl_info,"Altitude: %f", priv->altitude);
+ attr->u.numd = &priv->altitude;
+ break;
+ case attr_position_speed:
+ dbg(lvl_info,"Speed: %f", priv->speed);
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ dbg(lvl_info,"Direction: %f", priv->track);
+ attr->u.numd = &priv->track;
+ break;
+ case attr_position_magnetic_direction:
+ switch (priv->gps_type) {
+ case GPS_TYPE_BT:
+ attr->u.num = priv->magnetic_direction;
+ break;
+ default:
+ return 0;
+ break;
+ }
+ break;
+ case attr_position_hdop:
+ switch (priv->gps_type) {
+ case GPS_TYPE_BT:
+ attr->u.numd = &priv->hdop;
+ break;
+ default:
+ return 0;
+ break;
+ }
+ break;
+ case attr_position_coord_geo:
+ dbg(lvl_info,"Coord: %.12g %.12g", priv->geo.lat, priv->geo.lng);
+ attr->u.coord_geo = &priv->geo;
+ break;
+ case attr_position_radius:
+ dbg(lvl_info,"Radius: %f", priv->radius);
+ attr->u.numd = &priv->radius;
+ break;
+ case attr_position_time_iso8601:
+ if (priv->fix_time) {
+ struct tm tm;
+ if (gmtime_r(&priv->fix_time, &tm)) {
+ strftime(priv->fixiso8601, sizeof(priv->fixiso8601),
+ "%Y-%m-%dT%TZ", &tm);
+ attr->u.str=priv->fixiso8601;
+ } else {
+ priv->fix_time = 0;
+ return 0;
+ }
+ dbg(lvl_info,"Fix Time: %d %s", priv->fix_time, priv->fixiso8601);
+ } else {
+ dbg(lvl_info,"Fix Time: %d", priv->fix_time);
+ return 0;
+ }
+
+ break;
+ case attr_position_fix_type:
+ switch (priv->gps_type) {
+ case GPS_TYPE_INT:
+ if (priv->delta <= 0 || priv->radius == 0.0)
+ attr->u.num = 0; // strength = 1
+ else if (priv->radius > 20.0)
+ attr->u.num = 1; // strength >= 2
+ else
+ attr->u.num = 2; // strength >= 2
+ break;
+ case GPS_TYPE_BT:
+ attr->u.num = priv->status;
+ break;
+ default:
+ return 0;
+ break;
+ }
+ break;
+ case attr_position_sats_used:
+ switch (priv->gps_type) {
+ case GPS_TYPE_INT:
+ if (priv->delta <= 0)
+ attr->u.num = 0;
+ else if (priv->radius <= 6.0 )
+ attr->u.num = 6; // strength = 5
+ else if (priv->radius <= 10.0 )
+ attr->u.num = 5; // strength = 4
+ else if (priv->radius <= 15.0 )
+ attr->u.num = 4; // strength = 3
+ else
+ return 0;
+ break;
+ case GPS_TYPE_BT:
+ attr->u.num = priv->sats_used;
+ break;
+ default:
+ return 0;
+ break;
+ }
+ break;
+ default:
+ return 0;
+ }
+ attr->type = type;
+ return 1;
}
-static int
-vehicle_webos_set_attr_do(struct vehicle_priv *priv, struct attr *attr, int init)
-{
- switch (attr->type) {
- case attr_source:
- if (strncmp(vehicle_webos_prefix,attr->u.str,strlen(vehicle_webos_prefix))) {
- dbg(lvl_warning,"source must start with '%s'\n", vehicle_webos_prefix);
- return 0;
- }
- g_free(priv->source);
- priv->source=g_strdup(attr->u.str);
- priv->address=priv->source+strlen(vehicle_webos_prefix);
- if (!priv->address[0])
- priv->address=NULL;
- if (!init) {
- vehicle_webos_close(priv);
- vehicle_webos_open(priv);
- }
- return 1;
- case attr_profilename:
- return 1;
- case attr_pdl_gps_update:
- vehicle_webos_gps_update(priv, (PDL_Location *)attr->u.data);
- return 1;
- default:
- return 0;
- }
+static int vehicle_webos_set_attr_do(struct vehicle_priv *priv, struct attr *attr, int init) {
+ switch (attr->type) {
+ case attr_source:
+ if (strncmp(vehicle_webos_prefix,attr->u.str,strlen(vehicle_webos_prefix))) {
+ dbg(lvl_warning,"source must start with '%s'", vehicle_webos_prefix);
+ return 0;
+ }
+ g_free(priv->source);
+ priv->source=g_strdup(attr->u.str);
+ priv->address=priv->source+strlen(vehicle_webos_prefix);
+ if (!priv->address[0])
+ priv->address=NULL;
+ if (!init) {
+ vehicle_webos_close(priv);
+ vehicle_webos_open(priv);
+ }
+ return 1;
+ case attr_profilename:
+ return 1;
+ case attr_pdl_gps_update:
+ vehicle_webos_gps_update(priv, (PDL_Location *)attr->u.data);
+ return 1;
+ default:
+ return 0;
+ }
}
-static int
-vehicle_webos_set_attr(struct vehicle_priv *priv, struct attr *attr)
-{
- return vehicle_webos_set_attr_do(priv, attr, 0);
+static int vehicle_webos_set_attr(struct vehicle_priv *priv, struct attr *attr) {
+ return vehicle_webos_set_attr_do(priv, attr, 0);
}
struct vehicle_methods vehicle_webos_methods = {
- vehicle_webos_destroy,
- vehicle_webos_position_attr_get,
- vehicle_webos_set_attr,
+ vehicle_webos_destroy,
+ vehicle_webos_position_attr_get,
+ vehicle_webos_set_attr,
};
-static struct vehicle_priv *
-vehicle_webos_new(struct vehicle_methods
- *meth, struct callback_list
- *cbl, struct attr **attrs)
-{
- struct vehicle_priv *priv;
+static struct vehicle_priv *vehicle_webos_new(struct vehicle_methods
+ *meth, struct callback_list
+ *cbl, struct attr **attrs) {
+ struct vehicle_priv *priv;
- priv = g_new0(struct vehicle_priv, 1);
- priv->attrs = attrs;
- priv->cbl = cbl;
+ priv = g_new0(struct vehicle_priv, 1);
+ priv->attrs = attrs;
+ priv->cbl = cbl;
- priv->timeout_cb = callback_new_1(callback_cast(vehicle_webos_timeout_callback), priv);
+ priv->timeout_cb = callback_new_1(callback_cast(vehicle_webos_timeout_callback), priv);
- *meth = vehicle_webos_methods;
- while (*attrs) {
- vehicle_webos_set_attr_do(priv, *attrs, 1);
- attrs++;
- }
+ *meth = vehicle_webos_methods;
+ while (*attrs) {
+ vehicle_webos_set_attr_do(priv, *attrs, 1);
+ attrs++;
+ }
- vehicle_webos_open(priv);
+ vehicle_webos_open(priv);
- return priv;
+ return priv;
}
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("webos", vehicle_webos_new);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("webos", vehicle_webos_new);
}
-
diff --git a/navit/vehicle/wince/vehicle_wince.c b/navit/vehicle/wince/vehicle_wince.c
index d43c516f7..4d2afa0e9 100644
--- a/navit/vehicle/wince/vehicle_wince.c
+++ b/navit/vehicle/wince/vehicle_wince.c
@@ -1,4 +1,4 @@
-/**
+/*
* Navit, a modular navigation system.
* Copyright (C) 2005-2008 Navit Team
*
@@ -42,7 +42,14 @@
#include <winioctl.h>
#include <winbase.h>
#include <wchar.h>
-#include "support/win32/ConvertUTF.h"
+
+/**
+ * @defgroup vehicle-wince Vehicle WinCE
+ * @ingroup vehicle-plugins
+ * @brief The Vehicle to gain position data from WinCE
+ *
+ * @{
+ */
#define SwitchToThread() Sleep(0)
@@ -66,673 +73,700 @@ static int vehicle_wince_open(struct vehicle_priv *priv);
static void vehicle_wince_close(struct vehicle_priv *priv);
enum file_type {
- file_type_pipe = 1, file_type_device, file_type_file, file_type_socket
+ file_type_pipe = 1, file_type_device, file_type_file, file_type_socket
};
static int buffer_size = 1024;
struct gps_sat {
- int prn;
- int elevation;
- int azimuth;
- int snr;
+ int prn;
+ int elevation;
+ int azimuth;
+ int snr;
};
struct vehicle_priv {
- char *source;
- struct callback_list *cbl;
- struct callback_list *priv_cbl;
- int is_running;
- int thread_up;
- int fd;
- HANDLE m_hGPSDevice; // Handle to the device
- HANDLE m_hGPSThread; // Handle to the thread
- DWORD m_dwGPSThread; // Thread id
-
- char *buffer;
- int buffer_pos;
- char *read_buffer;
- int read_buffer_pos;
- char *nmea_data;
- char *nmea_data_buf;
-
- struct coord_geo geo;
- double speed;
- double direction;
- double height;
- double hdop;
- double vdop;
- char fixtime[20];
- int fixyear;
- int fixmonth;
- int fixday;
- int status;
- int sats_used;
- int sats_visible;
- int sats_signal;
- int time;
- int on_eof;
- int baudrate;
- enum file_type file_type;
- struct attr ** attrs;
- char fixiso8601[128];
- int checksum_ignore;
- HMODULE hBthDll;
- PFN_BthSetMode BthSetMode;
- int magnetic_direction;
- int current_count;
- struct gps_sat current[24];
- int next_count;
- struct gps_sat next[24];
- struct item sat_item;
- int valid;
- int has_data;
- GMutex lock;
+ char *source;
+ struct callback_list *cbl;
+ struct callback_list *priv_cbl;
+ struct callback *cb_fix_timeout;
+ struct event_timeout *ev_fix_timeout;
+ int is_running;
+ int thread_up;
+ int fd;
+ HANDLE m_hGPSDevice; // Handle to the device
+ HANDLE m_hGPSThread; // Handle to the thread
+ DWORD m_dwGPSThread; // Thread id
+
+ char *buffer;
+ int buffer_pos;
+ char *read_buffer;
+ int read_buffer_pos;
+ char *nmea_data;
+ char *nmea_data_buf;
+
+ struct coord_geo geo;
+ double speed;
+ double direction;
+ double height;
+ double hdop;
+ double vdop;
+ char fixtime[20];
+ int fixyear;
+ int fixmonth;
+ int fixday;
+ int status;
+ int sats_used;
+ int sats_visible;
+ int sats_signal;
+ int time;
+ int on_eof;
+ int baudrate;
+ enum file_type file_type;
+ struct attr ** attrs;
+ char fixiso8601[128];
+ int checksum_ignore;
+ HMODULE hBthDll;
+ PFN_BthSetMode BthSetMode;
+ int magnetic_direction;
+ int current_count;
+ struct gps_sat current[24];
+ int next_count;
+ struct gps_sat next[24];
+ struct item sat_item;
+ int valid;
+ int has_data;
+ GMutex lock;
};
-static void initBth(struct vehicle_priv *priv)
-{
-
- BOOL succeeded = FALSE;
- priv->hBthDll = LoadLibrary(TEXT("bthutil.dll"));
- if ( priv->hBthDll )
- {
- DWORD bthMode;
- PFN_BthGetMode BthGetMode = (PFN_BthGetMode)GetProcAddress(priv->hBthDll, TEXT("BthGetMode") );
-
- if ( BthGetMode && BthGetMode(&bthMode) == ERROR_SUCCESS && bthMode == 0 )
- {
- priv->BthSetMode = (PFN_BthSetMode)GetProcAddress(priv->hBthDll, TEXT("BthSetMode") );
- if( priv->BthSetMode && priv->BthSetMode(1) == ERROR_SUCCESS )
- {
- dbg(lvl_debug, "bluetooth activated\n");
- succeeded = TRUE;
- }
- }
-
- }
- else
- {
- dbg(lvl_error, "Bluetooth library notfound\n");
- }
-
- if ( !succeeded )
- {
-
- dbg(lvl_warning, "Bluetooth already enabled or failed to enable it.\n");
- priv->BthSetMode = NULL;
- if ( priv->hBthDll )
- {
- FreeLibrary(priv->hBthDll);
- }
- }
+static void initBth(struct vehicle_priv *priv) {
+
+ BOOL succeeded = FALSE;
+ priv->hBthDll = LoadLibrary(TEXT("bthutil.dll"));
+ if ( priv->hBthDll ) {
+ DWORD bthMode;
+ PFN_BthGetMode BthGetMode = (PFN_BthGetMode)GetProcAddress(priv->hBthDll, TEXT("BthGetMode") );
+
+ if ( BthGetMode && BthGetMode(&bthMode) == ERROR_SUCCESS && bthMode == 0 ) {
+ priv->BthSetMode = (PFN_BthSetMode)GetProcAddress(priv->hBthDll, TEXT("BthSetMode") );
+ if( priv->BthSetMode && priv->BthSetMode(1) == ERROR_SUCCESS ) {
+ dbg(lvl_debug, "bluetooth activated");
+ succeeded = TRUE;
+ }
+ }
+
+ } else {
+ dbg(lvl_error, "Bluetooth library notfound");
+ }
+
+ if ( !succeeded ) {
+
+ dbg(lvl_warning, "Bluetooth already enabled or failed to enable it.");
+ priv->BthSetMode = NULL;
+ if ( priv->hBthDll ) {
+ FreeLibrary(priv->hBthDll);
+ }
+ }
}
-static int initDevice(struct vehicle_priv *priv)
-{
- COMMTIMEOUTS commTiming;
- HANDLE hGPS;
- if ( priv->m_hGPSDevice )
- CloseHandle(priv->m_hGPSDevice);
-
- if ( priv->file_type == file_type_device )
- {
- dbg(lvl_debug, "Init Device\n");
- /* GPD0 is the control port for the GPS driver */
- hGPS = CreateFile(L"GPD0:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
- if (hGPS != INVALID_HANDLE_VALUE) {
+static int initDevice(struct vehicle_priv *priv) {
+ COMMTIMEOUTS commTiming;
+ HANDLE hGPS;
+ if ( priv->m_hGPSDevice )
+ CloseHandle(priv->m_hGPSDevice);
+
+ if ( priv->file_type == file_type_device ) {
+ dbg(lvl_debug, "Init Device");
+ /* GPD0 is the control port for the GPS driver */
+ hGPS = CreateFile(L"GPD0:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
+ 0);
+ if (hGPS != INVALID_HANDLE_VALUE) {
#ifndef IOCTL_SERVICE_REFRESH
#define IOCTL_SERVICE_REFRESH 0x4100000C
#endif
- DeviceIoControl(hGPS,IOCTL_SERVICE_REFRESH,0,0,0,0,0,0);
+ DeviceIoControl(hGPS,IOCTL_SERVICE_REFRESH,0,0,0,0,0,0);
#ifndef IOCTL_SERVICE_START
#define IOCTL_SERVICE_START 0x41000004
#endif
- DeviceIoControl(hGPS,IOCTL_SERVICE_START,0,0,0,0,0,0);
- CloseHandle(hGPS);
- }
-
- while (priv->is_running &&
- (priv->m_hGPSDevice = CreateFile(A2W(priv->source),
- GENERIC_READ, 0,
- NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
- {
- Sleep(1000);
- dbg(lvl_debug, "Waiting to connect to %s\n", priv->source);
- }
- GetCommTimeouts (priv->m_hGPSDevice, &commTiming);
- commTiming.ReadIntervalTimeout = 20;
- commTiming.ReadTotalTimeoutMultiplier = 0;
- commTiming.ReadTotalTimeoutConstant = 200;
-
- commTiming.WriteTotalTimeoutMultiplier=5;
- commTiming.WriteTotalTimeoutConstant=5;
- SetCommTimeouts (priv->m_hGPSDevice, &commTiming);
-
- if (priv->baudrate) {
- DCB portState;
- if (!GetCommState(priv->m_hGPSDevice, &portState)) {
- MessageBox (NULL, TEXT ("GetCommState Error"), TEXT (""),
- MB_APPLMODAL|MB_OK);
- priv->thread_up = 0;
- return 0;
- }
- portState.BaudRate = priv->baudrate;
- if (!SetCommState(priv->m_hGPSDevice, &portState)) {
- MessageBox (NULL, TEXT ("SetCommState Error"), TEXT (""),
- MB_APPLMODAL|MB_OK);
- priv->thread_up = 0;
- return 0;
- }
- }
-
- }
- else
- {
- dbg(lvl_debug, "Open File\n");
- priv->m_hGPSDevice = CreateFileW( A2W(priv->source),
- GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
- if ( priv->m_hGPSDevice == INVALID_HANDLE_VALUE) {
- dbg(lvl_error, "Could not open %s\n", priv->source);
- return 0;
- }
- }
- return 1;
+ DeviceIoControl(hGPS,IOCTL_SERVICE_START,0,0,0,0,0,0);
+ CloseHandle(hGPS);
+ }
+
+ while (priv->is_running &&
+ (priv->m_hGPSDevice = CreateFile(A2W(priv->source),
+ GENERIC_READ, 0,
+ NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
+ Sleep(1000);
+ dbg(lvl_debug, "Waiting to connect to %s", priv->source);
+ }
+ GetCommTimeouts (priv->m_hGPSDevice, &commTiming);
+ commTiming.ReadIntervalTimeout = 20;
+ commTiming.ReadTotalTimeoutMultiplier = 0;
+ commTiming.ReadTotalTimeoutConstant = 200;
+
+ commTiming.WriteTotalTimeoutMultiplier=5;
+ commTiming.WriteTotalTimeoutConstant=5;
+ SetCommTimeouts (priv->m_hGPSDevice, &commTiming);
+
+ if (priv->baudrate) {
+ DCB portState;
+ if (!GetCommState(priv->m_hGPSDevice, &portState)) {
+ MessageBox (NULL, TEXT ("GetCommState Error"), TEXT (""),
+ MB_APPLMODAL|MB_OK);
+ priv->thread_up = 0;
+ return 0;
+ }
+ portState.BaudRate = priv->baudrate;
+ if (!SetCommState(priv->m_hGPSDevice, &portState)) {
+ MessageBox (NULL, TEXT ("SetCommState Error"), TEXT (""),
+ MB_APPLMODAL|MB_OK);
+ priv->thread_up = 0;
+ return 0;
+ }
+ }
+
+ } else {
+ dbg(lvl_debug, "Open File");
+ priv->m_hGPSDevice = CreateFileW( A2W(priv->source),
+ GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
+ if ( priv->m_hGPSDevice == INVALID_HANDLE_VALUE) {
+ dbg(lvl_error, "Could not open %s", priv->source);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static int read_win32(struct vehicle_priv *priv, char *buffer, size_t size) {
+ int ret_size;
+
+ g_mutex_lock(&priv->lock);
+ ret_size = MIN(size,priv->read_buffer_pos);
+ priv->has_data = 0;
+ memcpy(buffer, priv->read_buffer, ret_size);
+
+ memmove(priv->read_buffer, priv->read_buffer + ret_size, buffer_size - ret_size);
+ priv->read_buffer_pos -= ret_size;
+ g_mutex_unlock(&priv->lock);
+ return ret_size;
+}
+
+static DWORD WINAPI wince_reader_thread (LPVOID lParam) {
+ struct vehicle_priv *priv = lParam;
+ char chunk_buffer[3*82];
+ BOOL status;
+ DWORD bytes_read;
+ int waitcounter;
+
+ dbg(lvl_debug, "GPS Port:[%s]", priv->source);
+ priv->thread_up = 1;
+
+ if ( !initDevice(priv) ) {
+ return -1;
+ }
+ while (priv->is_running) {
+ dbg(lvl_debug,"readfile");
+ waitcounter = 0;
+ status = ReadFile(priv->m_hGPSDevice,
+ chunk_buffer, sizeof(chunk_buffer),
+ &bytes_read, NULL);
+
+ if ( !status ) {
+ dbg(lvl_error,"Error reading file/device. Try again.");
+ initDevice(priv);
+ continue;
+ }
+
+ while ( priv->read_buffer_pos + bytes_read > buffer_size ) {
+ /* TODO (rikky#1#): should use blocking */
+ if ( priv->file_type != file_type_file ) {
+ dbg(lvl_debug, "GPS data comes too fast. Have to wait here");
+ }
+
+ Sleep(50);
+ waitcounter++;
+ if ( waitcounter % 8 == 0 ) {
+ dbg(lvl_debug, "Remind them of the data");
+ event_call_callback(priv->priv_cbl);
+ }
+ if(waitcounter % 200 == 0) {
+ dbg(lvl_error,"Will main thread ever be ready for the GPS data? Already %d intervals gone.",waitcounter);
+ }
+
+ }
+
+ if(waitcounter>2)
+ dbg(lvl_debug,"Sent GPS data to the main thread after %d intervals delay.",waitcounter);
+
+ g_mutex_lock(&priv->lock);
+ memcpy(priv->read_buffer + priv->read_buffer_pos, chunk_buffer, bytes_read );
+
+ priv->read_buffer_pos += bytes_read;
+
+ if ( !priv->has_data ) {
+ event_call_callback(priv->priv_cbl);
+ priv->has_data = 1;
+ }
+
+ g_mutex_unlock(&priv->lock);
+ }
+ return TRUE;
}
-static int read_win32(struct vehicle_priv *priv, char *buffer, size_t size)
-{
- int ret_size;
-
- g_mutex_lock(&priv->lock);
- ret_size = MIN(size,priv->read_buffer_pos);
- priv->has_data = 0;
- memcpy(buffer, priv->read_buffer, ret_size);
-
- memmove(priv->read_buffer, priv->read_buffer + ret_size, buffer_size - ret_size);
- priv->read_buffer_pos -= ret_size;
- g_mutex_unlock(&priv->lock);
- return ret_size;
+static int vehicle_wince_available_ports(void) {
+ HKEY hkResult;
+ HKEY hkSubResult;
+ wchar_t keyname[20];
+ wchar_t devicename[100];
+ wchar_t devicetype[100];
+ int index = 0;
+ DWORD regkey_length = sizeof(keyname);
+ DWORD regdevtype_length = sizeof(devicetype);
+
+ RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT("Drivers\\Active"), 0, 0, &hkResult);
+ while (RegEnumKeyEx( hkResult, index++, keyname, &regkey_length, NULL, NULL, NULL, NULL) == ERROR_SUCCESS ) {
+ if (RegOpenKeyEx( hkResult, keyname, 0, 0, &hkSubResult) == ERROR_SUCCESS ) {
+ regkey_length = sizeof(keyname);
+ if ( RegQueryValueEx( hkSubResult, L"Name", NULL, NULL, (LPBYTE)devicename, &regkey_length) == ERROR_SUCCESS ) {
+ regdevtype_length = sizeof(devicetype);
+ if ( RegQueryValueEx( hkSubResult, L"Key", NULL, NULL, (LPBYTE)devicetype, &regdevtype_length) == ERROR_SUCCESS ) {
+ dbg(lvl_debug, "Found device '%s' (%s)", W2A(devicename), W2A(devicetype));
+ } else {
+ dbg(lvl_debug, "Found device '%s'", W2A(devicename));
+ }
+ }
+ RegCloseKey(hkSubResult);
+ }
+ regkey_length = sizeof(keyname);
+ }
+
+ RegCloseKey(hkResult);
+ return 0;
}
-static DWORD WINAPI wince_reader_thread (LPVOID lParam)
-{
- struct vehicle_priv *priv = lParam;
- char chunk_buffer[3*82];
- BOOL status;
- DWORD bytes_read;
- int waitcounter;
-
- dbg(lvl_debug, "GPS Port:[%s]\n", priv->source);
- priv->thread_up = 1;
-
- if ( !initDevice(priv) ) {
- return -1;
- }
- while (priv->is_running)
- {
- dbg(lvl_debug,"readfile\n");
- waitcounter = 0;
- status = ReadFile(priv->m_hGPSDevice,
- chunk_buffer, sizeof(chunk_buffer),
- &bytes_read, NULL);
-
- if ( !status )
- {
- dbg(lvl_error,"Error reading file/device. Try again.\n");
- initDevice(priv);
- continue;
- }
-
- while ( priv->read_buffer_pos + bytes_read > buffer_size )
- {
- /* TODO (rikky#1#): should use blocking */
- if ( priv->file_type != file_type_file )
- {
- dbg(lvl_debug, "GPS data comes too fast. Have to wait here\n");
- }
-
- Sleep(50);
- waitcounter++;
- if ( waitcounter % 8 == 0 )
- {
- dbg(lvl_debug, "Remind them of the data\n");
- event_call_callback(priv->priv_cbl);
- }
- if(waitcounter % 200 == 0) {
- dbg(lvl_error,"Will main thread ever be ready for the GPS data? Already %d intervals gone.\n",waitcounter);
- }
-
- }
-
- if(waitcounter>2)
- dbg(lvl_debug,"Sent GPS data to the main thread after %d intervals delay.\n",waitcounter);
-
- g_mutex_lock(&priv->lock);
- memcpy(priv->read_buffer + priv->read_buffer_pos , chunk_buffer, bytes_read );
-
- priv->read_buffer_pos += bytes_read;
-
- if ( !priv->has_data )
- {
- event_call_callback(priv->priv_cbl);
- priv->has_data = 1;
- }
-
- g_mutex_unlock(&priv->lock);
- }
- return TRUE;
+
+/**
+* @brief This is a callback function, called when the fix timeout
+* is done. Set the position to invalid.
+*
+* @param priv Pointer on the private data of the plugin
+*/
+static void vehicle_wince_fix_timeout_cb(struct vehicle_priv *priv) {
+ priv->valid = attr_position_valid_invalid;
+ priv->ev_fix_timeout = NULL;
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
}
-static int
-vehicle_wince_available_ports(void)
-{
- HKEY hkResult;
- HKEY hkSubResult;
- wchar_t keyname[20];
- wchar_t devicename[100];
- wchar_t devicetype[100];
- int index = 0;
- DWORD regkey_length = sizeof(keyname);
- DWORD regdevtype_length = sizeof(devicetype);
-
- RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT("Drivers\\Active"), 0, 0, &hkResult);
- while (RegEnumKeyEx( hkResult, index++, keyname, &regkey_length, NULL, NULL, NULL, NULL) == ERROR_SUCCESS )
- {
- if (RegOpenKeyEx( hkResult, keyname, 0, 0, &hkSubResult) == ERROR_SUCCESS )
- {
- regkey_length = sizeof(keyname);
- if ( RegQueryValueEx( hkSubResult, L"Name", NULL, NULL, (LPBYTE)devicename, &regkey_length) == ERROR_SUCCESS )
- {
- regdevtype_length = sizeof(devicetype);
- if ( RegQueryValueEx( hkSubResult, L"Key", NULL, NULL, (LPBYTE)devicetype, &regdevtype_length) == ERROR_SUCCESS )
- {
- dbg(lvl_debug, "Found device '%s' (%s)\n", W2A(devicename), W2A(devicetype));
- }
- else
- {
- dbg(lvl_debug, "Found device '%s'\n", W2A(devicename));
- }
- }
- RegCloseKey(hkSubResult);
- }
- regkey_length = sizeof(keyname);
- }
-
- RegCloseKey(hkResult);
- return 0;
+
+/**
+* @brief Cancel previous fix timeout event and add a new one
+*
+* @param priv Pointer on the private data of the plugin
+*/
+static void vehicle_wince_restart_fix_timeout(struct vehicle_priv *priv) {
+ if (priv->ev_fix_timeout != NULL)
+ event_remove_timeout(priv->ev_fix_timeout);
+ priv->ev_fix_timeout = event_add_timeout(10000, 0, priv->cb_fix_timeout);
}
-static int
-vehicle_wince_open(struct vehicle_priv *priv)
-{
- char* raw_setting_str;
- char* strport;
- char* strsettings;
- dbg(lvl_debug, "enter vehicle_wince_open, priv->source='%s'\n", priv->source);
+static int vehicle_wince_open(struct vehicle_priv *priv) {
+ char* raw_setting_str;
+ char* strport;
+ char* strsettings;
+
+ dbg(lvl_debug, "enter vehicle_wince_open, priv->source='%s'", priv->source);
- if (priv->source ) {
+ if (priv->source ) {
- if ( strcmp(priv->source, "list") == 0 )
- {
- vehicle_wince_available_ports();
- return 0;
- }
+ if ( strcmp(priv->source, "list") == 0 ) {
+ vehicle_wince_available_ports();
+ return 0;
+ }
- raw_setting_str = g_strdup( priv->source );
- strport = strchr(raw_setting_str, ':' );
- strsettings = strchr(raw_setting_str, ' ' );
+ raw_setting_str = g_strdup( priv->source );
+ strport = strchr(raw_setting_str, ':' );
+ strsettings = strchr(raw_setting_str, ' ' );
- if (raw_setting_str && strport&&strsettings ) {
- strport++;
- *strsettings = '\0';
- strsettings++;
+ if (raw_setting_str && strport&&strsettings ) {
+ strport++;
+ *strsettings = '\0';
+ strsettings++;
- dbg(lvl_debug, "serial('%s', '%s')\n", strport, strsettings );
- }
- if (raw_setting_str)
- g_free( raw_setting_str );
- }
- return 1;
+ dbg(lvl_debug, "serial('%s', '%s')", strport, strsettings );
+ }
+ if (raw_setting_str)
+ g_free( raw_setting_str );
+ }
+ return 1;
}
-static void
-vehicle_wince_close(struct vehicle_priv *priv)
-{
- dbg(lvl_debug,"enter");
+static void vehicle_wince_close(struct vehicle_priv *priv) {
+ dbg(lvl_debug,"enter");
}
-static int
-vehicle_wince_parse(struct vehicle_priv *priv, char *buffer)
-{
- char *nmea_data_buf, *p, *item[32];
- double lat, lng;
- int i, j, bcsum;
- int len = strlen(buffer);
- unsigned char csum = 0;
- int valid=0;
- int ret = 0;
-
- dbg(lvl_info, "enter: buffer='%s'\n", buffer);
- for (;;) {
- if (len < 4) {
- dbg(lvl_error, "'%s' too short\n", buffer);
- return ret;
- }
- if (buffer[len - 1] == '\r' || buffer[len - 1] == '\n') {
- buffer[--len] = '\0';
- if (buffer[len - 1] == '\r')
- buffer[--len] = '\0';
- } else
- break;
- }
- if (buffer[0] != '$') {
- dbg(lvl_error, "no leading $ in '%s'\n", buffer);
- return ret;
- }
- if (buffer[len - 3] != '*') {
- dbg(lvl_error, "no *XX in '%s'\n", buffer);
- return ret;
- }
- for (i = 1; i < len - 3; i++) {
- csum ^= (unsigned char) (buffer[i]);
- }
- if (!sscanf(buffer + len - 2, "%x", &bcsum) && priv->checksum_ignore != 2) {
- dbg(lvl_error, "no checksum in '%s'\n", buffer);
- return ret;
- }
- if (bcsum != csum && priv->checksum_ignore == 0) {
- dbg(lvl_error, "wrong checksum in '%s'\n", buffer);
- return ret;
- }
-
- if (!priv->nmea_data_buf || strlen(priv->nmea_data_buf) < 65536) {
- nmea_data_buf=g_strconcat(priv->nmea_data_buf ? priv->nmea_data_buf : "", buffer, "\n", NULL);
- g_free(priv->nmea_data_buf);
- priv->nmea_data_buf=nmea_data_buf;
- } else {
- dbg(lvl_error, "nmea buffer overflow, discarding '%s'\n", buffer);
- }
- i = 0;
- p = buffer;
- while (i < 31) {
- item[i++] = p;
- while (*p && *p != ',')
- p++;
- if (!*p)
- break;
- *p++ = '\0';
- }
-
- if (!strncmp(&buffer[3], "GGA", 3)) {
- /* 1 1111
- 0 1 2 3 4 5 6 7 8 9 0 1234
- $GPGGA,184424.505,4924.2811,N,01107.8846,E,1,05,2.5,408.6,M,,,,0000*0C
- UTC of Fix[1],Latitude[2],N/S[3],Longitude[4],E/W[5],Quality(0=inv,1=gps,2=dgps)[6],Satelites used[7],
- HDOP[8],Altitude[9],"M"[10],height of geoid[11], "M"[12], time since dgps update[13], dgps ref station [14]
- */
- if (*item[2] && *item[3] && *item[4] && *item[5]) {
- lat = g_ascii_strtod(item[2], NULL);
- priv->geo.lat = floor(lat / 100);
- lat -= priv->geo.lat * 100;
- priv->geo.lat += lat / 60;
-
- if (!g_strcasecmp(item[3],"S"))
- priv->geo.lat=-priv->geo.lat;
-
- lng = g_ascii_strtod(item[4], NULL);
- priv->geo.lng = floor(lng / 100);
- lng -= priv->geo.lng * 100;
- priv->geo.lng += lng / 60;
-
- if (!g_strcasecmp(item[5],"W"))
- priv->geo.lng=-priv->geo.lng;
- priv->valid=attr_position_valid_valid;
-
- dbg(lvl_info, "latitude '%2.4f' longitude %2.4f\n", priv->geo.lat, priv->geo.lng);
-
- } else
- priv->valid=attr_position_valid_invalid;
- if (*item[6])
- sscanf(item[6], "%d", &priv->status);
- if (*item[7])
- sscanf(item[7], "%d", &priv->sats_used);
- if (*item[8])
- sscanf(item[8], "%lf", &priv->hdop);
- if (*item[1])
- strncpy(priv->fixtime, item[1], sizeof(priv->fixtime));
- if (*item[9])
- sscanf(item[9], "%lf", &priv->height);
-
- g_free(priv->nmea_data);
- priv->nmea_data=priv->nmea_data_buf;
- priv->nmea_data_buf=NULL;
- }
- if (!strncmp(&buffer[3], "VTG", 3)) {
- /* 0 1 2 34 5 6 7 8
- $GPVTG,143.58,T,,M,0.26,N,0.5,K*6A
- Course Over Ground Degrees True[1],"T"[2],Course Over Ground Degrees Magnetic[3],"M"[4],
- Speed in Knots[5],"N"[6],"Speed in KM/H"[7],"K"[8]
- */
- if (item[1] && item[7])
- valid = 1;
- if (i >= 10 && (*item[9] == 'A' || *item[9] == 'D'))
- valid = 1;
- if (valid) {
- priv->direction = g_ascii_strtod( item[1], NULL );
- priv->speed = g_ascii_strtod( item[7], NULL );
- dbg(lvl_info,"direction %lf, speed %2.1lf\n", priv->direction, priv->speed);
- }
- }
- if (!strncmp(&buffer[3], "RMC", 3)) {
- /* 1 1
- 0 1 2 3 4 5 6 7 8 9 0 1
- $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
- Time[1],Active/Void[2],lat[3],N/S[4],long[5],W/E[6],speed in knots[7],track angle[8],date[9],
- magnetic variation[10],magnetic variation direction[11]
- */
- if (*item[2] == 'A')
- valid = 1;
- if (i >= 13 && (*item[12] == 'A' || *item[12] == 'D'))
- valid = 1;
- if (valid) {
- priv->direction = g_ascii_strtod( item[8], NULL );
- priv->speed = g_ascii_strtod( item[7], NULL );
- priv->speed *= 1.852;
- sscanf(item[9], "%02d%02d%02d",
- &priv->fixday,
- &priv->fixmonth,
- &priv->fixyear);
- priv->fixyear += 2000;
- }
- ret = 1;
- }
- if (!strncmp(buffer, "$GPGSV", 6) && i >= 4) {
- /*
- 0 GSV Satellites in view
- 1 2 Number of sentences for full data
- 2 1 sentence 1 of 2
- 3 08 Number of satellites in view
-
- 4 01 Satellite PRN number
- 5 40 Elevation, degrees
- 6 083 Azimuth, degrees
- 7 46 SNR - higher is better
- for up to 4 satellites per sentence
- *75 the checksum data, always begins with *
- */
- if (item[3]) {
- sscanf(item[3], "%d", &priv->sats_visible);
- }
- j=4;
- while (j+4 <= i && priv->current_count < 24) {
- struct gps_sat *sat=&priv->next[priv->next_count++];
- sat->prn=atoi(item[j]);
- sat->elevation=atoi(item[j+1]);
- sat->azimuth=atoi(item[j+2]);
- sat->snr=atoi(item[j+3]);
- j+=4;
- }
- if (!strcmp(item[1], item[2])) {
- priv->sats_signal=0;
- for (i = 0 ; i < priv->next_count ; i++) {
- priv->current[i]=priv->next[i];
- if (priv->current[i].snr)
- priv->sats_signal++;
- }
- priv->current_count=priv->next_count;
- priv->next_count=0;
- }
- }
- if (!strncmp(&buffer[3], "ZDA", 3)) {
- /*
- 0 1 2 3 4 5 6
- $GPZDA,hhmmss.ss,dd,mm,yyyy,xx,yy*CC
- hhmmss HrMinSec(UTC)
- dd,mm,yyy Day,Month,Year
- xx local zone hours -13..13
- yy local zone minutes 0..59
- */
- if (item[1] && item[2] && item[3] && item[4]) {
- strncpy(priv->fixtime, item[1], strlen(priv->fixtime));
- priv->fixday = atoi(item[2]);
- priv->fixmonth = atoi(item[3]);
- priv->fixyear = atoi(item[4]);
- }
- }
- if (!strncmp(buffer, "$IISMD", 6)) {
- /*
- 0 1 2 3 4
- $IISMD,dir,press,height,temp*CC"
- dir Direction (0-359)
- press Pressure (hpa, i.e. 1032)
- height Barometric height above ground (meter)
- temp Temperature (Degree Celsius)
- */
- if (item[1]) {
- priv->magnetic_direction = g_ascii_strtod( item[1], NULL );
- dbg(lvl_debug,"magnetic %d\n", priv->magnetic_direction);
- }
- }
- return ret;
+static int vehicle_wince_parse(struct vehicle_priv *priv, char *buffer) {
+ char *nmea_data_buf, *p, *item[32];
+ double lat, lng;
+ int i, j, bcsum;
+ int len = strlen(buffer);
+ unsigned char csum = 0;
+ int valid=0;
+ int ret = 0;
+
+ dbg(lvl_info, "enter: buffer='%s'", buffer);
+ for (;;) {
+ if (len < 4) {
+ dbg(lvl_error, "'%s' too short", buffer);
+ return ret;
+ }
+ if (buffer[len - 1] == '\r' || buffer[len - 1] == '\n') {
+ buffer[--len] = '\0';
+ if (buffer[len - 1] == '\r')
+ buffer[--len] = '\0';
+ } else
+ break;
+ }
+ if (buffer[0] != '$') {
+ dbg(lvl_error, "no leading $ in '%s'", buffer);
+ return ret;
+ }
+ if (buffer[len - 3] != '*') {
+ dbg(lvl_error, "no *XX in '%s'", buffer);
+ return ret;
+ }
+ for (i = 1; i < len - 3; i++) {
+ csum ^= (unsigned char) (buffer[i]);
+ }
+ if (!sscanf(buffer + len - 2, "%x", &bcsum) && priv->checksum_ignore != 2) {
+ dbg(lvl_error, "no checksum in '%s'", buffer);
+ return ret;
+ }
+ if (bcsum != csum && priv->checksum_ignore == 0) {
+ dbg(lvl_error, "wrong checksum in '%s'", buffer);
+ return ret;
+ }
+
+ if (!priv->nmea_data_buf || strlen(priv->nmea_data_buf) < 65536) {
+ nmea_data_buf=g_strconcat(priv->nmea_data_buf ? priv->nmea_data_buf : "", buffer, "\n", NULL);
+ g_free(priv->nmea_data_buf);
+ priv->nmea_data_buf=nmea_data_buf;
+ } else {
+ dbg(lvl_error, "nmea buffer overflow, discarding '%s'", buffer);
+ }
+ i = 0;
+ p = buffer;
+ while (i < 31) {
+ item[i++] = p;
+ while (*p && *p != ',')
+ p++;
+ if (!*p)
+ break;
+ *p++ = '\0';
+ }
+
+ if (!strncmp(&buffer[3], "GGA", 3)) {
+ /* 1 1111
+ 0 1 2 3 4 5 6 7 8 9 0 1234
+ $GPGGA,184424.505,4924.2811,N,01107.8846,E,1,05,2.5,408.6,M,,,,0000*0C
+ UTC of Fix[1],Latitude[2],N/S[3],Longitude[4],E/W[5],Quality(0=inv,1=gps,2=dgps)[6],Satelites used[7],
+ HDOP[8],Altitude[9],"M"[10],height of geoid[11], "M"[12], time since dgps update[13], dgps ref station [14]
+ */
+ if (*item[2] && *item[3] && *item[4] && *item[5] && *item[6] > 0) {
+ lat = g_ascii_strtod(item[2], NULL);
+ priv->geo.lat = floor(lat / 100);
+ lat -= priv->geo.lat * 100;
+ priv->geo.lat += lat / 60;
+
+ if (!g_strcasecmp(item[3],"S"))
+ priv->geo.lat=-priv->geo.lat;
+
+ lng = g_ascii_strtod(item[4], NULL);
+ priv->geo.lng = floor(lng / 100);
+ lng -= priv->geo.lng * 100;
+ priv->geo.lng += lng / 60;
+
+ if (!g_strcasecmp(item[5],"W"))
+ priv->geo.lng=-priv->geo.lng;
+
+ if (priv->valid == attr_position_valid_invalid)
+ ret = 1;
+ priv->valid = attr_position_valid_valid;
+ vehicle_wince_restart_fix_timeout(priv);
+
+ if (*item[1] && strncmp(priv->fixtime, item[1], sizeof(priv->fixtime))) {
+ ret = 1;
+ strncpy(priv->fixtime, item[1], sizeof(priv->fixtime));
+ }
+
+ dbg(lvl_info, "latitude '%2.4f' longitude %2.4f", priv->geo.lat, priv->geo.lng);
+
+ } else {
+ if (priv->valid == attr_position_valid_valid)
+ ret = 1;
+ priv->valid=attr_position_valid_invalid;
+ }
+
+ if (*item[6])
+ sscanf(item[6], "%d", &priv->status);
+ if (*item[7])
+ sscanf(item[7], "%d", &priv->sats_used);
+ if (*item[8])
+ sscanf(item[8], "%lf", &priv->hdop);
+ if (*item[9])
+ sscanf(item[9], "%lf", &priv->height);
+
+ g_free(priv->nmea_data);
+ priv->nmea_data=priv->nmea_data_buf;
+ priv->nmea_data_buf=NULL;
+ }
+ if (!strncmp(&buffer[3], "VTG", 3)) {
+ /* 0 1 2 34 5 6 7 8
+ $GPVTG,143.58,T,,M,0.26,N,0.5,K*6A
+ Course Over Ground Degrees True[1],"T"[2],Course Over Ground Degrees Magnetic[3],"M"[4],
+ Speed in Knots[5],"N"[6],"Speed in KM/H"[7],"K"[8]
+ */
+ if (item[1] && item[7])
+ valid = 1;
+ if (i >= 10 && (*item[9] == 'A' || *item[9] == 'D'))
+ valid = 1;
+ if (valid) {
+ priv->direction = g_ascii_strtod( item[1], NULL );
+ priv->speed = g_ascii_strtod( item[7], NULL );
+ dbg(lvl_info,"direction %lf, speed %2.1lf", priv->direction, priv->speed);
+ }
+ }
+ if (!strncmp(&buffer[3], "RMC", 3)) {
+ /* 1 1
+ 0 1 2 3 4 5 6 7 8 9 0 1
+ $GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A
+ Time[1],Active/Void[2],lat[3],N/S[4],long[5],W/E[6],speed in knots[7],track angle[8],date[9],
+ magnetic variation[10],magnetic variation direction[11]
+ */
+ if (*item[2] == 'A')
+ valid = 1;
+ if (i >= 13 && (*item[12] == 'A' || *item[12] == 'D'))
+ valid = 1;
+ if (valid) {
+ priv->direction = g_ascii_strtod( item[8], NULL );
+ priv->speed = g_ascii_strtod( item[7], NULL );
+ priv->speed *= 1.852;
+ sscanf(item[9], "%02d%02d%02d",
+ &priv->fixday,
+ &priv->fixmonth,
+ &priv->fixyear);
+ priv->fixyear += 2000;
+
+ lat = g_ascii_strtod(item[3], NULL);
+ priv->geo.lat = floor(lat / 100);
+ lat -= priv->geo.lat * 100;
+ priv->geo.lat += lat / 60;
+
+ if (!g_ascii_strcasecmp(item[4],"S"))
+ priv->geo.lat=-priv->geo.lat;
+
+ lng = g_ascii_strtod(item[5], NULL);
+ priv->geo.lng = floor(lng / 100);
+ lng -= priv->geo.lng * 100;
+ priv->geo.lng += lng / 60;
+
+ if (!g_ascii_strcasecmp(item[6],"W"))
+ priv->geo.lng=-priv->geo.lng;
+
+ if (priv->valid == attr_position_valid_invalid)
+ ret = 1;
+ priv->valid=attr_position_valid_valid;
+ vehicle_wince_restart_fix_timeout(priv);
+
+ if (*item[1] && strncmp(priv->fixtime, item[1], sizeof(priv->fixtime))) {
+ ret = 1;
+ strncpy(priv->fixtime, item[1], sizeof(priv->fixtime));
+ }
+
+ dbg(lvl_info, "latitude '%2.4f' longitude %2.4f", priv->geo.lat, priv->geo.lng);
+
+ } else {
+ if (priv->valid == attr_position_valid_valid)
+ ret = 1;
+ priv->valid=attr_position_valid_invalid;
+ }
+ }
+ if (!strncmp(buffer, "$GPGSV", 6) && i >= 4) {
+ /*
+ 0 GSV Satellites in view
+ 1 2 Number of sentences for full data
+ 2 1 sentence 1 of 2
+ 3 08 Number of satellites in view
+
+ 4 01 Satellite PRN number
+ 5 40 Elevation, degrees
+ 6 083 Azimuth, degrees
+ 7 46 SNR - higher is better
+ for up to 4 satellites per sentence
+ *75 the checksum data, always begins with *
+ */
+ if (item[3]) {
+ sscanf(item[3], "%d", &priv->sats_visible);
+ }
+ j=4;
+ while (j+4 <= i && priv->current_count < 24) {
+ struct gps_sat *sat=&priv->next[priv->next_count++];
+ sat->prn=atoi(item[j]);
+ sat->elevation=atoi(item[j+1]);
+ sat->azimuth=atoi(item[j+2]);
+ sat->snr=atoi(item[j+3]);
+ j+=4;
+ }
+ if (!strcmp(item[1], item[2])) {
+ priv->sats_signal=0;
+ for (i = 0 ; i < priv->next_count ; i++) {
+ priv->current[i]=priv->next[i];
+ if (priv->current[i].snr)
+ priv->sats_signal++;
+ }
+ priv->current_count=priv->next_count;
+ priv->next_count=0;
+ }
+ }
+ if (!strncmp(&buffer[3], "ZDA", 3)) {
+ /*
+ 0 1 2 3 4 5 6
+ $GPZDA,hhmmss.ss,dd,mm,yyyy,xx,yy*CC
+ hhmmss HrMinSec(UTC)
+ dd,mm,yyy Day,Month,Year
+ xx local zone hours -13..13
+ yy local zone minutes 0..59
+ */
+ if (item[1] && item[2] && item[3] && item[4]) {
+ strncpy(priv->fixtime, item[1], strlen(priv->fixtime));
+ priv->fixday = atoi(item[2]);
+ priv->fixmonth = atoi(item[3]);
+ priv->fixyear = atoi(item[4]);
+ }
+ }
+ if (!strncmp(buffer, "$IISMD", 6)) {
+ /*
+ 0 1 2 3 4
+ $IISMD,dir,press,height,temp*CC"
+ dir Direction (0-359)
+ press Pressure (hpa, i.e. 1032)
+ height Barometric height above ground (meter)
+ temp Temperature (Degree Celsius)
+ */
+ if (item[1]) {
+ priv->magnetic_direction = g_ascii_strtod( item[1], NULL );
+ dbg(lvl_debug,"magnetic %d", priv->magnetic_direction);
+ }
+ }
+ return ret;
}
-static void
-vehicle_wince_io(struct vehicle_priv *priv)
-{
- int size, rc = 0;
- char *str, *tok;
-
- dbg(lvl_debug, "vehicle_file_io : enter\n");
-
- size = read_win32(priv, priv->buffer + priv->buffer_pos, buffer_size - priv->buffer_pos - 1);
-
- if (size <= 0) {
- switch (priv->on_eof) {
- case 0:
- vehicle_wince_close(priv);
- vehicle_wince_open(priv);
- break;
- case 1:
- vehicle_wince_disable_watch(priv);
- break;
- case 2:
- exit(0);
- break;
- }
- return;
- }
- priv->buffer_pos += size;
- priv->buffer[priv->buffer_pos] = '\0';
- dbg(lvl_debug, "size=%d pos=%d buffer='%s'\n", size,
- priv->buffer_pos, priv->buffer);
- str = priv->buffer;
- while ((tok = strchr(str, '\n'))) {
- *tok++ = '\0';
- dbg(lvl_debug, "line='%s'\n", str);
- rc +=vehicle_wince_parse(priv, str);
- str = tok;
- if (priv->file_type == file_type_file && rc)
- break;
- }
-
- if (str != priv->buffer) {
- size = priv->buffer + priv->buffer_pos - str;
- memmove(priv->buffer, str, size + 1);
- priv->buffer_pos = size;
- dbg(lvl_info, "now pos=%d buffer='%s'\n",
- priv->buffer_pos, priv->buffer);
- } else if (priv->buffer_pos == buffer_size - 1) {
- dbg(lvl_error,
- "Overflow. Most likely wrong baud rate or no nmea protocol\n");
- priv->buffer_pos = 0;
- }
- if (rc)
- callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
+static void vehicle_wince_io(struct vehicle_priv *priv) {
+ int size, rc = 0;
+ char *str, *tok;
+
+ dbg(lvl_debug, "vehicle_file_io : enter");
+
+ size = read_win32(priv, priv->buffer + priv->buffer_pos, buffer_size - priv->buffer_pos - 1);
+
+ if (size <= 0) {
+ switch (priv->on_eof) {
+ case 0:
+ vehicle_wince_close(priv);
+ vehicle_wince_open(priv);
+ break;
+ case 1:
+ vehicle_wince_disable_watch(priv);
+ break;
+ case 2:
+ exit(0);
+ break;
+ }
+ return;
+ }
+ priv->buffer_pos += size;
+ priv->buffer[priv->buffer_pos] = '\0';
+ dbg(lvl_debug, "size=%d pos=%d buffer='%s'", size,
+ priv->buffer_pos, priv->buffer);
+ str = priv->buffer;
+ while ((tok = strchr(str, '\n'))) {
+ *tok++ = '\0';
+ dbg(lvl_debug, "line='%s'", str);
+ rc +=vehicle_wince_parse(priv, str);
+ str = tok;
+ if (priv->file_type == file_type_file && rc)
+ break;
+ }
+
+ if (str != priv->buffer) {
+ size = priv->buffer + priv->buffer_pos - str;
+ memmove(priv->buffer, str, size + 1);
+ priv->buffer_pos = size;
+ dbg(lvl_info, "now pos=%d buffer='%s'",
+ priv->buffer_pos, priv->buffer);
+ } else if (priv->buffer_pos == buffer_size - 1) {
+ dbg(lvl_error,
+ "Overflow. Most likely wrong baud rate or no nmea protocol\n");
+ priv->buffer_pos = 0;
+ }
+ if (rc)
+ callback_list_call_attr_0(priv->cbl, attr_position_coord_geo);
}
-static void
-vehicle_wince_enable_watch(struct vehicle_priv *priv)
-{
- dbg(lvl_debug, "enter");
- vehicle_wince_disable_watch(priv);
- priv->is_running = 1;
-
- InitializeCriticalSection(&priv->lock);
- priv->m_hGPSThread = CreateThread(NULL, 0, wince_reader_thread,
- priv, 0, &priv->m_dwGPSThread);
-
- if (!priv->m_hGPSThread) {
- priv->is_running = 0;
- // error creating thread
- MessageBox (NULL, TEXT ("Can not create GPS reader thread"), TEXT (""),
- MB_APPLMODAL|MB_OK);
- }
+static void vehicle_wince_enable_watch(struct vehicle_priv *priv) {
+ dbg(lvl_debug, "enter");
+ vehicle_wince_disable_watch(priv);
+ priv->is_running = 1;
+
+ InitializeCriticalSection(&priv->lock);
+ priv->m_hGPSThread = CreateThread(NULL, 0, wince_reader_thread,
+ priv, 0, &priv->m_dwGPSThread);
+
+ if (!priv->m_hGPSThread) {
+ priv->is_running = 0;
+ // error creating thread
+ MessageBox (NULL, TEXT ("Can not create GPS reader thread"), TEXT (""),
+ MB_APPLMODAL|MB_OK);
+ }
}
-static void
-vehicle_wince_disable_watch(struct vehicle_priv *priv)
-{
- int wait = 5000;
-
- dbg(lvl_debug, "enter");
-
- priv->is_running = 0;
- while (wait-- > 0 && priv->thread_up) {
- SwitchToThread();
- }
- if (priv->m_hGPSThread) {
- // Terminate reader, sorry
- TerminateThread(priv->m_hGPSThread, -1);
- }
+static void vehicle_wince_disable_watch(struct vehicle_priv *priv) {
+ int wait = 5000;
+
+ dbg(lvl_debug, "enter");
+
+ priv->is_running = 0;
+ while (wait-- > 0 && priv->thread_up) {
+ SwitchToThread();
+ }
+ if (priv->m_hGPSThread) {
+ // Terminate reader, sorry
+ TerminateThread(priv->m_hGPSThread, -1);
+ }
}
/**
* @brief Frees the wince_vehicle
- *
+ *
* @param priv vehicle_priv structure for the vehicle
*/
-static void
-vehicle_wince_destroy(struct vehicle_priv *priv)
-{
- vehicle_wince_disable_watch(priv);
- vehicle_wince_close(priv);
- if (priv->BthSetMode)
- {
- (void)priv->BthSetMode(0);
- FreeLibrary(priv->hBthDll);
- }
- if (priv->source)
- g_free(priv->source);
- if (priv->buffer)
- g_free(priv->buffer);
- if (priv->read_buffer)
- g_free(priv->read_buffer);
- g_free(priv);
+static void vehicle_wince_destroy(struct vehicle_priv *priv) {
+ vehicle_wince_disable_watch(priv);
+ vehicle_wince_close(priv);
+ if (priv->BthSetMode) {
+ (void)priv->BthSetMode(0);
+ FreeLibrary(priv->hBthDll);
+ }
+ if (priv->source)
+ g_free(priv->source);
+ if (priv->buffer)
+ g_free(priv->buffer);
+ if (priv->read_buffer)
+ g_free(priv->read_buffer);
+ g_free(priv);
}
/**
@@ -741,215 +775,210 @@ vehicle_wince_destroy(struct vehicle_priv *priv)
* @param priv vehicle_priv structure for the vehicle
* @param type The attribute type to retrieve
* @param attr Points to an attr structure that will receive the attribute data
- * @returns True for success, false for failure
+ *
+ * @return True for success, false for failure
*/
-static int
-vehicle_wince_position_attr_get(struct vehicle_priv *priv,
- enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_position_fix_type:
- attr->u.num = priv->status;
- break;
- case attr_position_height:
- attr->u.numd = &priv->height;
- break;
- case attr_position_speed:
- attr->u.numd = &priv->speed;
- break;
- case attr_position_direction:
- attr->u.numd = &priv->direction;
- break;
- case attr_position_magnetic_direction:
- attr->u.num = priv->magnetic_direction;
- break;
- case attr_position_hdop:
- attr->u.numd = &priv->hdop;
- break;
- case attr_position_qual:
- attr->u.num = priv->sats_visible;
- break;
- case attr_position_sats_signal:
- attr->u.num = priv->sats_signal;
- break;
- case attr_position_sats_used:
- attr->u.num = priv->sats_used;
- break;
- case attr_position_coord_geo:
- attr->u.coord_geo = &priv->geo;
- break;
- case attr_position_nmea:
- attr->u.str=priv->nmea_data;
- if (! attr->u.str)
- return 0;
- break;
- case attr_position_time_iso8601:
- if (!priv->fixyear || !priv->fixtime[0])
- return 0;
- sprintf(priv->fixiso8601, "%04d-%02d-%02dT%.2s:%.2s:%sZ",
- priv->fixyear, priv->fixmonth, priv->fixday,
- priv->fixtime, (priv->fixtime+2), (priv->fixtime+4));
- attr->u.str=priv->fixiso8601;
- break;
- case attr_position_sat_item:
- dbg(lvl_debug,"at here\n");
- priv->sat_item.id_lo++;
- if (priv->sat_item.id_lo > priv->current_count) {
- priv->sat_item.id_lo=0;
- return 0;
- }
- attr->u.item=&priv->sat_item;
- break;
- case attr_position_valid:
- attr->u.num=priv->valid;
- break;
- default:
- return 0;
- }
- if (type != attr_position_sat_item)
- priv->sat_item.id_lo=0;
- attr->type = type;
- return 1;
+static int vehicle_wince_position_attr_get(struct vehicle_priv *priv,
+ enum attr_type type, struct attr *attr) {
+ switch (type) {
+ case attr_position_fix_type:
+ attr->u.num = priv->status;
+ break;
+ case attr_position_height:
+ attr->u.numd = &priv->height;
+ break;
+ case attr_position_speed:
+ attr->u.numd = &priv->speed;
+ break;
+ case attr_position_direction:
+ attr->u.numd = &priv->direction;
+ break;
+ case attr_position_magnetic_direction:
+ attr->u.num = priv->magnetic_direction;
+ break;
+ case attr_position_hdop:
+ attr->u.numd = &priv->hdop;
+ break;
+ case attr_position_qual:
+ attr->u.num = priv->sats_visible;
+ break;
+ case attr_position_sats_signal:
+ attr->u.num = priv->sats_signal;
+ break;
+ case attr_position_sats_used:
+ attr->u.num = priv->sats_used;
+ break;
+ case attr_position_coord_geo:
+ attr->u.coord_geo = &priv->geo;
+ break;
+ case attr_position_nmea:
+ attr->u.str=priv->nmea_data;
+ if (! attr->u.str)
+ return 0;
+ break;
+ case attr_position_time_iso8601:
+ if (!priv->fixyear || !priv->fixtime[0])
+ return 0;
+ sprintf(priv->fixiso8601, "%04d-%02d-%02dT%.2s:%.2s:%sZ",
+ priv->fixyear, priv->fixmonth, priv->fixday,
+ priv->fixtime, (priv->fixtime+2), (priv->fixtime+4));
+ attr->u.str=priv->fixiso8601;
+ break;
+ case attr_position_sat_item:
+ dbg(lvl_debug,"at here");
+ priv->sat_item.id_lo++;
+ if (priv->sat_item.id_lo > priv->current_count) {
+ priv->sat_item.id_lo=0;
+ return 0;
+ }
+ attr->u.item=&priv->sat_item;
+ break;
+ case attr_position_valid:
+ attr->u.num=priv->valid;
+ break;
+ default:
+ return 0;
+ }
+ if (type != attr_position_sat_item)
+ priv->sat_item.id_lo=0;
+ attr->type = type;
+ return 1;
}
-static int
-vehicle_wince_sat_attr_get(void *priv_data, enum attr_type type, struct attr *attr)
-{
- struct vehicle_priv *priv=priv_data;
- struct gps_sat *sat;
-
- if (priv->sat_item.id_lo < 1)
- return 0;
- if (priv->sat_item.id_lo > priv->current_count)
- return 0;
- sat=&priv->current[priv->sat_item.id_lo-1];
- switch (type) {
- case attr_sat_prn:
- attr->u.num=sat->prn;
- break;
- case attr_sat_elevation:
- attr->u.num=sat->elevation;
- break;
- case attr_sat_azimuth:
- attr->u.num=sat->azimuth;
- break;
- case attr_sat_snr:
- attr->u.num=sat->snr;
- break;
- default:
- return 0;
- }
- attr->type = type;
- return 1;
+static int vehicle_wince_sat_attr_get(void *priv_data, enum attr_type type, struct attr *attr) {
+ struct vehicle_priv *priv=priv_data;
+ struct gps_sat *sat;
+
+ if (priv->sat_item.id_lo < 1)
+ return 0;
+ if (priv->sat_item.id_lo > priv->current_count)
+ return 0;
+ sat=&priv->current[priv->sat_item.id_lo-1];
+ switch (type) {
+ case attr_sat_prn:
+ attr->u.num=sat->prn;
+ break;
+ case attr_sat_elevation:
+ attr->u.num=sat->elevation;
+ break;
+ case attr_sat_azimuth:
+ attr->u.num=sat->azimuth;
+ break;
+ case attr_sat_snr:
+ attr->u.num=sat->snr;
+ break;
+ default:
+ return 0;
+ }
+ attr->type = type;
+ return 1;
}
static struct item_methods vehicle_wince_sat_methods = {
- NULL,
- NULL,
- NULL,
- vehicle_wince_sat_attr_get,
- NULL,
- NULL,
- NULL,
- NULL,
+ NULL,
+ NULL,
+ NULL,
+ vehicle_wince_sat_attr_get,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
};
struct vehicle_methods vehicle_wince_methods = {
- vehicle_wince_destroy,
- vehicle_wince_position_attr_get,
- NULL,
+ vehicle_wince_destroy,
+ vehicle_wince_position_attr_get,
+ NULL,
};
/**
* @brief Creates a new wince_vehicle
- *
- * @param meth
- * @param cbl
- * @param attrs
- * @returns vehicle_priv
+ *
+ * @param meth ?
+ * @param cbl ?
+ * @param attrs ?
+ *
+ * @return vehicle_priv
*/
-static struct vehicle_priv *
-vehicle_wince_new(struct vehicle_methods
- *meth, struct callback_list
- *cbl, struct attr **attrs)
-{
- struct vehicle_priv *ret;
- struct attr *source;
- struct attr *time;
- struct attr *on_eof;
- struct attr *baudrate;
- struct attr *checksum_ignore;
- struct attr *handle_bluetooth;
- char *cp;
-
- dbg(lvl_debug, "enter\n");
- source = attr_search(attrs, NULL, attr_source);
- ret = g_new0(struct vehicle_priv, 1);
- ret->fd = -1;
- ret->cbl = cbl;
-
- ret->file_type = file_type_device;
- cp = strchr(source->u.str,':');
- if (cp)
- {
- if ( strncmp(source->u.str, "file", 4) == 0 )
- ret->file_type = file_type_file;
- cp++;
- }
- else
- cp = source->u.str;
- ret->source = g_strdup(cp);
- ret->buffer = g_malloc(buffer_size);
- ret->time=1000;
- ret->baudrate=0; // do not change the rate if not configured
-
- time = attr_search(attrs, NULL, attr_time);
- if (time)
- ret->time=time->u.num;
- baudrate = attr_search(attrs, NULL, attr_baudrate);
- if (baudrate) {
- ret->baudrate = baudrate->u.num;
- }
- checksum_ignore = attr_search(attrs, NULL, attr_checksum_ignore);
- if (checksum_ignore)
- ret->checksum_ignore=checksum_ignore->u.num;
- ret->attrs = attrs;
- on_eof = attr_search(attrs, NULL, attr_on_eof);
- if (on_eof && !g_strcasecmp(on_eof->u.str, "stop"))
- ret->on_eof=1;
- if (on_eof && !g_strcasecmp(on_eof->u.str, "exit"))
- ret->on_eof=2;
- dbg(lvl_debug,"on_eof=%d\n", ret->on_eof);
- *meth = vehicle_wince_methods;
- ret->priv_cbl = callback_list_new();
- callback_list_add(ret->priv_cbl, callback_new_1(callback_cast(vehicle_wince_io), ret));
- ret->sat_item.type=type_position_sat;
- ret->sat_item.id_hi=ret->sat_item.id_lo=0;
- ret->sat_item.priv_data=ret;
- ret->sat_item.meth=&vehicle_wince_sat_methods;
-
- ret->read_buffer = g_malloc(buffer_size);
-
- handle_bluetooth = attr_search(attrs, NULL, attr_bluetooth);
- if ( handle_bluetooth && handle_bluetooth->u.num == 1 )
- initBth(ret);
-
- if (vehicle_wince_open(ret)) {
- vehicle_wince_enable_watch(ret);
- return ret;
- }
- dbg(lvl_error, "Failed to open '%s'\n", ret->source);
- vehicle_wince_destroy(ret);
- return NULL;
+static struct vehicle_priv *vehicle_wince_new(struct vehicle_methods
+ *meth, struct callback_list
+ *cbl, struct attr **attrs) {
+ struct vehicle_priv *ret;
+ struct attr *source;
+ struct attr *time;
+ struct attr *on_eof;
+ struct attr *baudrate;
+ struct attr *checksum_ignore;
+ struct attr *handle_bluetooth;
+ char *cp;
+
+ dbg(lvl_debug, "enter");
+ source = attr_search(attrs, NULL, attr_source);
+ ret = g_new0(struct vehicle_priv, 1);
+ ret->fd = -1;
+ ret->cbl = cbl;
+
+ ret->file_type = file_type_device;
+ cp = strchr(source->u.str,':');
+ if (cp) {
+ if ( strncmp(source->u.str, "file", 4) == 0 )
+ ret->file_type = file_type_file;
+ cp++;
+ } else
+ cp = source->u.str;
+ ret->source = g_strdup(cp);
+ ret->buffer = g_malloc(buffer_size);
+ ret->time=1000;
+ ret->baudrate=0; // do not change the rate if not configured
+ ret->fixtime[0] = '\0';
+ ret->ev_fix_timeout = NULL;
+
+ time = attr_search(attrs, NULL, attr_time);
+ if (time)
+ ret->time=time->u.num;
+ baudrate = attr_search(attrs, NULL, attr_baudrate);
+ if (baudrate) {
+ ret->baudrate = baudrate->u.num;
+ }
+ checksum_ignore = attr_search(attrs, NULL, attr_checksum_ignore);
+ if (checksum_ignore)
+ ret->checksum_ignore=checksum_ignore->u.num;
+ ret->attrs = attrs;
+ on_eof = attr_search(attrs, NULL, attr_on_eof);
+ if (on_eof && !g_strcasecmp(on_eof->u.str, "stop"))
+ ret->on_eof=1;
+ if (on_eof && !g_strcasecmp(on_eof->u.str, "exit"))
+ ret->on_eof=2;
+ dbg(lvl_debug,"on_eof=%d", ret->on_eof);
+ *meth = vehicle_wince_methods;
+ ret->priv_cbl = callback_list_new();
+ callback_list_add(ret->priv_cbl, callback_new_1(callback_cast(vehicle_wince_io), ret));
+ ret->cb_fix_timeout=callback_new_1(callback_cast(vehicle_wince_fix_timeout_cb), ret);
+ ret->sat_item.type=type_position_sat;
+ ret->sat_item.id_hi=ret->sat_item.id_lo=0;
+ ret->sat_item.priv_data=ret;
+ ret->sat_item.meth=&vehicle_wince_sat_methods;
+
+ ret->read_buffer = g_malloc(buffer_size);
+
+ handle_bluetooth = attr_search(attrs, NULL, attr_bluetooth);
+ if ( handle_bluetooth && handle_bluetooth->u.num == 1 )
+ initBth(ret);
+
+ if (vehicle_wince_open(ret)) {
+ vehicle_wince_enable_watch(ret);
+ return ret;
+ }
+ dbg(lvl_error, "Failed to open '%s'", ret->source);
+ vehicle_wince_destroy(ret);
+ return NULL;
}
/**
* @brief Registers the vehicle_wince plugin
*/
-void
-plugin_init(void)
-{
- dbg(lvl_debug, "enter\n");
- plugin_register_category_vehicle("wince", vehicle_wince_new);
- plugin_register_category_vehicle("file", vehicle_wince_new);
+void plugin_init(void) {
+ dbg(lvl_debug, "enter");
+ plugin_register_category_vehicle("wince", vehicle_wince_new);
+ plugin_register_category_vehicle("file", vehicle_wince_new);
}
diff --git a/navit/vehicleprofile.c b/navit/vehicleprofile.c
index 9da721d26..d20603d73 100644
--- a/navit/vehicleprofile.c
+++ b/navit/vehicleprofile.c
@@ -27,298 +27,271 @@
#include "vehicleprofile.h"
#include "callback.h"
-static void
-vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr)
-{
- dbg(lvl_debug,"%s:%ld\n", attr_to_name(attr->type), attr->u.num);
- switch (attr->type) {
- case attr_flags:
- this_->flags=attr->u.num;
- break;
- case attr_flags_forward_mask:
- this_->flags_forward_mask=attr->u.num;
- break;
- case attr_flags_reverse_mask:
- this_->flags_reverse_mask=attr->u.num;
- break;
- case attr_maxspeed_handling:
- this_->maxspeed_handling=attr->u.num;
- break;
- case attr_route_mode:
- this_->mode=attr->u.num;
- break;
- case attr_name:
- if(this_->name)
- g_free(this_->name);
- /* previously used strdupn not available on win32 */
- this_->name = g_strdup(attr->u.str);
- break;
- case attr_route_depth:
- if(this_->route_depth)
- g_free(this_->route_depth);
- this_->route_depth = g_strdup(attr->u.str);
- break;
- case attr_vehicle_axle_weight:
- this_->axle_weight=attr->u.num;
- break;
- case attr_vehicle_dangerous_goods:
- this_->dangerous_goods=attr->u.num;
- break;
- case attr_vehicle_height:
- this_->height=attr->u.num;
- break;
- case attr_vehicle_length:
- this_->length=attr->u.num;
- break;
- case attr_vehicle_weight:
- this_->weight=attr->u.num;
- break;
- case attr_vehicle_width:
- this_->width=attr->u.num;
- break;
- case attr_static_speed:
- this_->static_speed=attr->u.num;
- break;
- case attr_static_distance:
- this_->static_distance=attr->u.num;
- break;
- case attr_through_traffic_penalty:
- this_->through_traffic_penalty=attr->u.num;
- break;
- case attr_turn_around_penalty:
- this_->turn_around_penalty=attr->u.num;
- break;
- case attr_turn_around_penalty2:
- this_->turn_around_penalty2=attr->u.num;
- break;
- default:
- break;
- }
+static void vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr) {
+ dbg(lvl_debug,"%s:%ld", attr_to_name(attr->type), attr->u.num);
+ switch (attr->type) {
+ case attr_flags:
+ this_->flags=attr->u.num;
+ break;
+ case attr_flags_forward_mask:
+ this_->flags_forward_mask=attr->u.num;
+ break;
+ case attr_flags_reverse_mask:
+ this_->flags_reverse_mask=attr->u.num;
+ break;
+ case attr_maxspeed_handling:
+ this_->maxspeed_handling=attr->u.num;
+ break;
+ case attr_route_mode:
+ this_->mode=attr->u.num;
+ break;
+ case attr_name:
+ if(this_->name)
+ g_free(this_->name);
+ /* previously used strdupn not available on win32 */
+ this_->name = g_strdup(attr->u.str);
+ break;
+ case attr_route_depth:
+ if(this_->route_depth)
+ g_free(this_->route_depth);
+ this_->route_depth = g_strdup(attr->u.str);
+ break;
+ case attr_vehicle_axle_weight:
+ this_->axle_weight=attr->u.num;
+ break;
+ case attr_vehicle_dangerous_goods:
+ this_->dangerous_goods=attr->u.num;
+ break;
+ case attr_vehicle_height:
+ this_->height=attr->u.num;
+ break;
+ case attr_vehicle_length:
+ this_->length=attr->u.num;
+ break;
+ case attr_vehicle_weight:
+ this_->weight=attr->u.num;
+ break;
+ case attr_vehicle_width:
+ this_->width=attr->u.num;
+ break;
+ case attr_static_speed:
+ this_->static_speed=attr->u.num;
+ break;
+ case attr_static_distance:
+ this_->static_distance=attr->u.num;
+ break;
+ case attr_through_traffic_penalty:
+ this_->through_traffic_penalty=attr->u.num;
+ break;
+ case attr_turn_around_penalty:
+ this_->turn_around_penalty=attr->u.num;
+ break;
+ case attr_turn_around_penalty2:
+ this_->turn_around_penalty2=attr->u.num;
+ break;
+ default:
+ break;
+ }
}
-static void
-vehicleprofile_free_hash_item(gpointer key, gpointer value, gpointer user_data)
-{
- struct navit_object *obj=value;
- obj->func->unref(obj);
+static void vehicleprofile_free_hash_item(gpointer key, gpointer value, gpointer user_data) {
+ struct navit_object *obj=value;
+ obj->func->unref(obj);
}
-static void
-vehicleprofile_free_hash(struct vehicleprofile *this_)
-{
- if (this_->roadprofile_hash) {
- g_hash_table_foreach(this_->roadprofile_hash, vehicleprofile_free_hash_item, NULL);
- g_hash_table_destroy(this_->roadprofile_hash);
- }
+static void vehicleprofile_free_hash(struct vehicleprofile *this_) {
+ if (this_->roadprofile_hash) {
+ g_hash_table_foreach(this_->roadprofile_hash, vehicleprofile_free_hash_item, NULL);
+ g_hash_table_destroy(this_->roadprofile_hash);
+ }
}
-static void
-vehicleprofile_clear(struct vehicleprofile *this_)
-{
- this_->mode=0;
- this_->flags_forward_mask=0;
- this_->flags_reverse_mask=0;
- this_->flags=0;
- this_->maxspeed_handling = maxspeed_enforce;
- this_->static_speed=0;
- this_->static_distance=0;
- g_free(this_->name);
- this_->name=NULL;
- g_free(this_->route_depth);
- this_->route_depth=NULL;
- this_->dangerous_goods=0;
- this_->length=-1;
- this_->width=-1;
- this_->height=-1;
- this_->weight=-1;
- this_->axle_weight=-1;
- this_->through_traffic_penalty=9000;
- vehicleprofile_free_hash(this_);
- this_->roadprofile_hash=g_hash_table_new(NULL, NULL);
+static void vehicleprofile_clear(struct vehicleprofile *this_) {
+ this_->mode=0;
+ this_->flags_forward_mask=0;
+ this_->flags_reverse_mask=0;
+ this_->flags=0;
+ this_->maxspeed_handling = maxspeed_enforce;
+ this_->static_speed=0;
+ this_->static_distance=0;
+ g_free(this_->name);
+ this_->name=NULL;
+ g_free(this_->route_depth);
+ this_->route_depth=NULL;
+ this_->dangerous_goods=0;
+ this_->length=-1;
+ this_->width=-1;
+ this_->height=-1;
+ this_->weight=-1;
+ this_->axle_weight=-1;
+ this_->through_traffic_penalty=9000;
+ vehicleprofile_free_hash(this_);
+ this_->roadprofile_hash=g_hash_table_new(NULL, NULL);
}
-static void
-vehicleprofile_apply_roadprofile(struct vehicleprofile *this_, struct navit_object *rp, int is_option)
-{
- struct attr item_types_attr;
- if (rp->func->get_attr(rp, attr_item_types, &item_types_attr, NULL)) {
- enum item_type *types=item_types_attr.u.item_types;
- while (*types != type_none) {
- struct navit_object *oldrp;
- /* Maptool won't place any access flags for roads which don't have default access flags set. Warn user. */
- if(!item_get_default_flags(*types))
- dbg(lvl_error,"On '%s' roads used in '%s' vehicleprofile access restrictions are ignored. You might even be directed to drive in wrong direction on a one-way road. "
- "Please define default access flags for above road type to item.c and rebuild the map.\n", item_to_name(*types), this_->name);
- oldrp=g_hash_table_lookup(this_->roadprofile_hash, (void *)(long)(*types));
- if (is_option && oldrp) {
- struct navit_object *newrp;
- struct attr_iter *iter=rp->func->iter_new(NULL);
- struct attr attr;
- dbg(lvl_debug,"patching roadprofile\n");
- newrp=oldrp->func->dup(oldrp);
- while (rp->func->get_attr(rp, attr_any, &attr, iter))
- newrp->func->set_attr(newrp, &attr);
- oldrp->func->iter_destroy(iter);
- oldrp->func->unref(oldrp);
- g_hash_table_insert(this_->roadprofile_hash, (void *)(long)(*types), newrp);
- } else {
- if (oldrp)
- oldrp->func->unref(oldrp);
- g_hash_table_insert(this_->roadprofile_hash, (void *)(long)(*types), rp->func->ref(rp));
- }
- types++;
- }
- }
+static void vehicleprofile_apply_roadprofile(struct vehicleprofile *this_, struct navit_object *rp, int is_option) {
+ struct attr item_types_attr;
+ if (rp->func->get_attr(rp, attr_item_types, &item_types_attr, NULL)) {
+ enum item_type *types=item_types_attr.u.item_types;
+ while (*types != type_none) {
+ struct navit_object *oldrp;
+ /* Maptool won't place any access flags for roads which don't have default access flags set. Warn user. */
+ if(!item_get_default_flags(*types))
+ dbg(lvl_error,
+ "On '%s' roads used in '%s' vehicleprofile access restrictions are ignored. You might even be directed to drive in wrong direction on a one-way road. "
+ "Please define default access flags for above road type to item.c and rebuild the map.\n", item_to_name(*types),
+ this_->name);
+ oldrp=g_hash_table_lookup(this_->roadprofile_hash, (void *)(long)(*types));
+ if (is_option && oldrp) {
+ struct navit_object *newrp;
+ struct attr_iter *iter=rp->func->iter_new(NULL);
+ struct attr attr;
+ dbg(lvl_debug,"patching roadprofile");
+ newrp=oldrp->func->dup(oldrp);
+ while (rp->func->get_attr(rp, attr_any, &attr, iter))
+ newrp->func->set_attr(newrp, &attr);
+ oldrp->func->iter_destroy(iter);
+ oldrp->func->unref(oldrp);
+ g_hash_table_insert(this_->roadprofile_hash, (void *)(long)(*types), newrp);
+ } else {
+ if (oldrp)
+ oldrp->func->unref(oldrp);
+ g_hash_table_insert(this_->roadprofile_hash, (void *)(long)(*types), rp->func->ref(rp));
+ }
+ types++;
+ }
+ }
}
-static void
-vehicleprofile_apply_attrs(struct vehicleprofile *this_, struct navit_object *obj, int is_option)
-{
- struct attr attr;
- struct attr_iter *iter=obj->func->iter_new(NULL);
- while (obj->func->get_attr(obj, attr_any, &attr, iter)) {
- dbg(lvl_debug,"%s\n",attr_to_name(attr.type));
- if (attr.type == attr_roadprofile)
- vehicleprofile_apply_roadprofile(this_, attr.u.navit_object, is_option);
- else if (attr.type != attr_profile_option)
- vehicleprofile_set_attr_do(this_, &attr);
- }
- obj->func->iter_destroy(iter);
+static void vehicleprofile_apply_attrs(struct vehicleprofile *this_, struct navit_object *obj, int is_option) {
+ struct attr attr;
+ struct attr_iter *iter=obj->func->iter_new(NULL);
+ while (obj->func->get_attr(obj, attr_any, &attr, iter)) {
+ dbg(lvl_debug,"%s",attr_to_name(attr.type));
+ if (attr.type == attr_roadprofile)
+ vehicleprofile_apply_roadprofile(this_, attr.u.navit_object, is_option);
+ else if (attr.type != attr_profile_option)
+ vehicleprofile_set_attr_do(this_, &attr);
+ }
+ obj->func->iter_destroy(iter);
}
-static void
-vehicleprofile_debug_roadprofile(gpointer key, gpointer value, gpointer user_data)
-{
- struct roadprofile *rp=value;
- dbg(lvl_debug,"type %s avg %d weight %d max %d\n",item_to_name((int)(long)key),rp->speed,rp->route_weight,rp->maxspeed);
+static void vehicleprofile_debug_roadprofile(gpointer key, gpointer value, gpointer user_data) {
+ struct roadprofile *rp=value;
+ dbg(lvl_debug,"type %s avg %d weight %d max %d",item_to_name((int)(long)key),rp->speed,rp->route_weight,rp->maxspeed);
}
-static void
-vehicleprofile_update(struct vehicleprofile *this_)
-{
- struct attr_iter *iter=vehicleprofile_attr_iter_new();
- struct attr profile_option;
- dbg(lvl_debug,"enter\n");
- vehicleprofile_clear(this_);
- vehicleprofile_apply_attrs(this_, (struct navit_object *)this_, 0);
- while (vehicleprofile_get_attr(this_, attr_profile_option, &profile_option, iter)) {
- struct attr active, name;
- if (!profile_option.u.navit_object->func->get_attr(profile_option.u.navit_object, attr_active, &active, NULL))
- active.u.num=0;
- if (profile_option.u.navit_object->func->get_attr(profile_option.u.navit_object, attr_name, &name, NULL))
- dbg(lvl_debug,"%p %s %ld\n",profile_option.u.navit_object,name.u.str,active.u.num);
- if (active.u.num)
- vehicleprofile_apply_attrs(this_, profile_option.u.navit_object, 1);
- }
- vehicleprofile_attr_iter_destroy(iter);
- dbg(lvl_debug,"result l %d w %d h %d wg %d awg %d pen %d\n",this_->length,this_->width,this_->height,this_->weight,this_->axle_weight,this_->through_traffic_penalty);
- dbg(lvl_debug,"m %d fwd 0x%x rev 0x%x flags 0x%x max %d stsp %d stdst %d dg %d\n",this_->mode,this_->flags_forward_mask,this_->flags_reverse_mask, this_->flags, this_->maxspeed_handling, this_->static_speed, this_->static_distance, this_->dangerous_goods);
- g_hash_table_foreach(this_->roadprofile_hash, vehicleprofile_debug_roadprofile, NULL);
+static void vehicleprofile_update(struct vehicleprofile *this_) {
+ struct attr_iter *iter=vehicleprofile_attr_iter_new();
+ struct attr profile_option;
+ dbg(lvl_debug,"enter");
+ vehicleprofile_clear(this_);
+ vehicleprofile_apply_attrs(this_, (struct navit_object *)this_, 0);
+ while (vehicleprofile_get_attr(this_, attr_profile_option, &profile_option, iter)) {
+ struct attr active, name;
+ if (!profile_option.u.navit_object->func->get_attr(profile_option.u.navit_object, attr_active, &active, NULL))
+ active.u.num=0;
+ if (profile_option.u.navit_object->func->get_attr(profile_option.u.navit_object, attr_name, &name, NULL))
+ dbg(lvl_debug,"%p %s %ld",profile_option.u.navit_object,name.u.str,active.u.num);
+ if (active.u.num)
+ vehicleprofile_apply_attrs(this_, profile_option.u.navit_object, 1);
+ }
+ vehicleprofile_attr_iter_destroy(iter);
+ dbg(lvl_debug,"result l %d w %d h %d wg %d awg %d pen %d",this_->length,this_->width,this_->height,this_->weight,
+ this_->axle_weight,this_->through_traffic_penalty);
+ dbg(lvl_debug,"m %d fwd 0x%x rev 0x%x flags 0x%x max %d stsp %d stdst %d dg %d",this_->mode,this_->flags_forward_mask,
+ this_->flags_reverse_mask, this_->flags, this_->maxspeed_handling, this_->static_speed, this_->static_distance,
+ this_->dangerous_goods);
+ g_hash_table_foreach(this_->roadprofile_hash, vehicleprofile_debug_roadprofile, NULL);
}
struct vehicleprofile *
-vehicleprofile_new(struct attr *parent, struct attr **attrs)
-{
- struct vehicleprofile *this_;
- struct attr **attr, *type_attr;
- if (! (type_attr=attr_search(attrs, NULL, attr_name))) {
- return NULL;
- }
- this_=g_new0(struct vehicleprofile, 1);
- this_->func=&vehicleprofile_func;
- navit_object_ref((struct navit_object *)this_);
- this_->attrs=attr_list_dup(attrs);
- this_->active_callback.type=attr_callback;
- this_->active_callback.u.callback=callback_new_attr_1(callback_cast(vehicleprofile_update), attr_active, this_);
- vehicleprofile_clear(this_);
- for (attr=attrs;*attr; attr++)
- vehicleprofile_set_attr_do(this_, *attr);
- return this_;
+vehicleprofile_new(struct attr *parent, struct attr **attrs) {
+ struct vehicleprofile *this_;
+ struct attr **attr, *type_attr;
+ if (! (type_attr=attr_search(attrs, NULL, attr_name))) {
+ return NULL;
+ }
+ this_=g_new0(struct vehicleprofile, 1);
+ this_->func=&vehicleprofile_func;
+ navit_object_ref((struct navit_object *)this_);
+ this_->attrs=attr_list_dup(attrs);
+ this_->active_callback.type=attr_callback;
+ this_->active_callback.u.callback=callback_new_attr_1(callback_cast(vehicleprofile_update), attr_active, this_);
+ vehicleprofile_clear(this_);
+ for (attr=attrs; *attr; attr++)
+ vehicleprofile_set_attr_do(this_, *attr);
+ return this_;
}
struct attr_iter *
-vehicleprofile_attr_iter_new(void)
-{
- return (struct attr_iter *)g_new0(void *,1);
+vehicleprofile_attr_iter_new(void) {
+ return (struct attr_iter *)g_new0(void *,1);
}
-void
-vehicleprofile_attr_iter_destroy(struct attr_iter *iter)
-{
- g_free(iter);
+void vehicleprofile_attr_iter_destroy(struct attr_iter *iter) {
+ g_free(iter);
}
-int
-vehicleprofile_get_attr(struct vehicleprofile *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+int vehicleprofile_get_attr(struct vehicleprofile *this_, enum attr_type type, struct attr *attr,
+ struct attr_iter *iter) {
+ return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
}
-int
-vehicleprofile_set_attr(struct vehicleprofile *this_, struct attr *attr)
-{
- vehicleprofile_set_attr_do(this_, attr);
- this_->attrs=attr_generic_set_attr(this_->attrs, attr);
- return 1;
+int vehicleprofile_set_attr(struct vehicleprofile *this_, struct attr *attr) {
+ vehicleprofile_set_attr_do(this_, attr);
+ this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+ return 1;
}
-int
-vehicleprofile_add_attr(struct vehicleprofile *this_, struct attr *attr)
-{
- this_->attrs=attr_generic_add_attr(this_->attrs, attr);
- switch (attr->type) {
- case attr_roadprofile:
- vehicleprofile_apply_roadprofile(this_, attr->u.navit_object, 0);
- break;
- case attr_profile_option:
- attr->u.navit_object->func->add_attr(attr->u.navit_object, &this_->active_callback);
- break;
- default:
- break;
- }
- return 1;
+int vehicleprofile_add_attr(struct vehicleprofile *this_, struct attr *attr) {
+ this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+ switch (attr->type) {
+ case attr_roadprofile:
+ vehicleprofile_apply_roadprofile(this_, attr->u.navit_object, 0);
+ break;
+ case attr_profile_option:
+ attr->u.navit_object->func->add_attr(attr->u.navit_object, &this_->active_callback);
+ break;
+ default:
+ break;
+ }
+ return 1;
}
-int
-vehicleprofile_remove_attr(struct vehicleprofile *this_, struct attr *attr)
-{
- this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
- return 1;
+int vehicleprofile_remove_attr(struct vehicleprofile *this_, struct attr *attr) {
+ this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
+ return 1;
}
struct roadprofile *
-vehicleprofile_get_roadprofile(struct vehicleprofile *this_, enum item_type type)
-{
- return g_hash_table_lookup(this_->roadprofile_hash, (void *)(long)type);
+vehicleprofile_get_roadprofile(struct vehicleprofile *this_, enum item_type type) {
+ return g_hash_table_lookup(this_->roadprofile_hash, (void *)(long)type);
}
-char *
-vehicleprofile_get_name(struct vehicleprofile *this_)
-{
- return this_->name;
+char *vehicleprofile_get_name(struct vehicleprofile *this_) {
+ return this_->name;
}
-static void
-vehicleprofile_init(struct vehicleprofile *this_)
-{
- vehicleprofile_update(this_);
+static void vehicleprofile_init(struct vehicleprofile *this_) {
+ vehicleprofile_update(this_);
}
struct object_func vehicleprofile_func = {
- attr_vehicleprofile,
- (object_func_new)vehicleprofile_new,
- (object_func_get_attr)vehicleprofile_get_attr,
- (object_func_iter_new)vehicleprofile_attr_iter_new,
- (object_func_iter_destroy)vehicleprofile_attr_iter_destroy,
- (object_func_set_attr)vehicleprofile_set_attr,
- (object_func_add_attr)vehicleprofile_add_attr,
- (object_func_remove_attr)vehicleprofile_remove_attr,
- (object_func_init)vehicleprofile_init,
- (object_func_destroy)NULL,
- (object_func_dup)NULL,
- (object_func_ref)navit_object_ref,
- (object_func_unref)navit_object_unref,
+ attr_vehicleprofile,
+ (object_func_new)vehicleprofile_new,
+ (object_func_get_attr)vehicleprofile_get_attr,
+ (object_func_iter_new)vehicleprofile_attr_iter_new,
+ (object_func_iter_destroy)vehicleprofile_attr_iter_destroy,
+ (object_func_set_attr)vehicleprofile_set_attr,
+ (object_func_add_attr)vehicleprofile_add_attr,
+ (object_func_remove_attr)vehicleprofile_remove_attr,
+ (object_func_init)vehicleprofile_init,
+ (object_func_destroy)NULL,
+ (object_func_dup)NULL,
+ (object_func_ref)navit_object_ref,
+ (object_func_unref)navit_object_unref,
};
diff --git a/navit/version.h.in b/navit/version.h.in
deleted file mode 100644
index 3c39d0e1f..000000000
--- a/navit/version.h.in
+++ /dev/null
@@ -1,2 +0,0 @@
-#cmakedefine GIT_VERSION "@GIT_VERSION@"
-#cmakedefine NAVIT_VARIANT "@NAVIT_VARIANT@"
diff --git a/navit/xmlconfig.c b/navit/xmlconfig.c
index f57224481..0a44a43cc 100644
--- a/navit/xmlconfig.c
+++ b/navit/xmlconfig.c
@@ -58,112 +58,109 @@
#endif
struct xistate {
- struct xistate *parent;
- struct xistate *child;
- const gchar *element;
- const gchar **attribute_names;
- const gchar **attribute_values;
+ struct xistate *parent;
+ struct xistate *child;
+ const gchar *element;
+ const gchar **attribute_names;
+ const gchar **attribute_values;
};
struct xmldocument {
- const gchar *href;
- const gchar *xpointer;
- gpointer user_data;
- struct xistate *first;
- struct xistate *last;
- int active;
- int level;
+ const gchar *href;
+ const gchar *xpointer;
+ gpointer user_data;
+ struct xistate *first;
+ struct xistate *last;
+ int active;
+ int level;
};
struct xmlstate {
- const gchar **attribute_names;
- const gchar **attribute_values;
- struct xmlstate *parent;
- struct attr element_attr;
- const gchar *element;
- xmlerror **error;
- struct element_func *func;
- struct object_func *object_func;
- struct xmldocument *document;
+ const gchar **attribute_names;
+ const gchar **attribute_values;
+ struct xmlstate *parent;
+ struct attr element_attr;
+ const gchar *element;
+ xmlerror **error;
+ struct element_func *func;
+ struct object_func *object_func;
+ struct xmldocument *document;
};
struct attr_fixme {
- char *element;
- char **attr_fixme;
+ char *element;
+ char **attr_fixme;
};
-static struct attr ** convert_to_attrs(struct xmlstate *state, struct attr_fixme *fixme)
-{
- const gchar **attribute_name=state->attribute_names;
- const gchar **attribute_value=state->attribute_values;
- const gchar *name;
- int count=0;
- struct attr **ret;
- static int fixme_count;
-
- while (*attribute_name) {
- count++;
- attribute_name++;
- }
- ret=g_new(struct attr *, count+1);
- attribute_name=state->attribute_names;
- count=0;
- while (*attribute_name) {
- name=*attribute_name;
- if (fixme) {
- char **attr_fixme=fixme->attr_fixme;
- while (attr_fixme[0]) {
- if (! strcmp(name, attr_fixme[0])) {
- name=attr_fixme[1];
- if (fixme_count++ < 10)
- dbg(lvl_error,"Please change attribute '%s' to '%s' in <%s />\n", attr_fixme[0], attr_fixme[1], fixme->element);
- break;
- }
- attr_fixme+=2;
- }
- }
- ret[count]=attr_new_from_text(name,*attribute_value);
- if (ret[count])
- count++;
- else if (strcmp(*attribute_name,"enabled") && strcmp(*attribute_name,"xmlns:xi"))
- dbg(lvl_error,"failed to create attribute '%s' with value '%s'\n", *attribute_name,*attribute_value);
- attribute_name++;
- attribute_value++;
- }
- ret[count]=NULL;
- dbg(lvl_debug,"ret=%p\n", ret);
- return ret;
+static struct attr ** convert_to_attrs(struct xmlstate *state, struct attr_fixme *fixme) {
+ const gchar **attribute_name=state->attribute_names;
+ const gchar **attribute_value=state->attribute_values;
+ const gchar *name;
+ int count=0;
+ struct attr **ret;
+ static int fixme_count;
+
+ while (*attribute_name) {
+ count++;
+ attribute_name++;
+ }
+ ret=g_new(struct attr *, count+1);
+ attribute_name=state->attribute_names;
+ count=0;
+ while (*attribute_name) {
+ name=*attribute_name;
+ if (fixme) {
+ char **attr_fixme=fixme->attr_fixme;
+ while (attr_fixme[0]) {
+ if (! strcmp(name, attr_fixme[0])) {
+ name=attr_fixme[1];
+ if (fixme_count++ < 10)
+ dbg(lvl_error,"Please change attribute '%s' to '%s' in <%s />", attr_fixme[0], attr_fixme[1], fixme->element);
+ break;
+ }
+ attr_fixme+=2;
+ }
+ }
+ ret[count]=attr_new_from_text(name,*attribute_value);
+ if (ret[count])
+ count++;
+ else if (strcmp(*attribute_name,"enabled") && strcmp(*attribute_name,"xmlns:xi"))
+ dbg(lvl_error,"failed to create attribute '%s' with value '%s'", *attribute_name,*attribute_value);
+ attribute_name++;
+ attribute_value++;
+ }
+ ret[count]=NULL;
+ dbg(lvl_debug,"ret=%p", ret);
+ return ret;
}
-static const char * find_attribute(struct xmlstate *state, const char *attribute, int required)
-{
- const gchar **attribute_name=state->attribute_names;
- const gchar **attribute_value=state->attribute_values;
- while(*attribute_name) {
- if(! g_ascii_strcasecmp(attribute,*attribute_name))
- return *attribute_value;
- attribute_name++;
- attribute_value++;
- }
- if (required)
- g_set_error(state->error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "element '%s' is missing attribute '%s'", state->element, attribute);
- return NULL;
+static const char * find_attribute(struct xmlstate *state, const char *attribute, int required) {
+ const gchar **attribute_name=state->attribute_names;
+ const gchar **attribute_value=state->attribute_values;
+ while(*attribute_name) {
+ if(! g_ascii_strcasecmp(attribute,*attribute_name))
+ return *attribute_value;
+ attribute_name++;
+ attribute_value++;
+ }
+ if (required)
+ g_set_error(state->error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "element '%s' is missing attribute '%s'",
+ state->element, attribute);
+ return NULL;
}
-static int
-find_boolean(struct xmlstate *state, const char *attribute, int deflt, int required)
-{
- const char *value;
-
- value=find_attribute(state, attribute, required);
- if (! value)
- return deflt;
- if (g_ascii_strcasecmp(value,"no") && g_ascii_strcasecmp(value,"0") && g_ascii_strcasecmp(value,"false"))
- return 1;
- return 0;
+static int find_boolean(struct xmlstate *state, const char *attribute, int deflt, int required) {
+ const char *value;
+
+ value=find_attribute(state, attribute, required);
+ if (! value)
+ return deflt;
+ if (g_ascii_strcasecmp(value,"no") && g_ascii_strcasecmp(value,"0") && g_ascii_strcasecmp(value,"false"))
+ return 1;
+ return 0;
}
/**
@@ -172,49 +169,45 @@ find_boolean(struct xmlstate *state, const char *attribute, int deflt, int requi
* * @param val the string value to convert
* * @returns int value of converted string
* */
-static int
-convert_number(const char *val)
-{
- if (val)
- return g_ascii_strtoull(val,NULL,0);
- else
- return 0;
+static int convert_number(const char *val) {
+ if (val)
+ return g_ascii_strtoull(val,NULL,0);
+ else
+ return 0;
}
-static int
-xmlconfig_announce(struct xmlstate *state)
-{
- const char *type,*value;
- char key[32];
- int level[3];
- int i;
- enum item_type itype;
- char *tok, *type_str, *str;
-
- type=find_attribute(state, "type", 1);
- if (! type)
- return 0;
- for (i = 0 ; i < 3 ; i++) {
- sprintf(key,"level%d", i);
- value=find_attribute(state, key, 0);
- if (value)
- level[i]=convert_number(value);
- else
- level[i]=-1;
- }
- type_str=g_strdup(type);
- str=type_str;
- while ((tok=strtok(str, ","))) {
- itype=item_from_name(tok);
- if (itype!=type_none) {
- navigation_set_announce(state->parent->element_attr.u.data, itype, level);
- } else {
- dbg(lvl_error, "Invalid type for announcement: %s\n",tok);
- }
- str=NULL;
- }
- g_free(type_str);
- return 1;
+static int xmlconfig_announce(struct xmlstate *state) {
+ const char *type,*value;
+ char key[32];
+ int level[3];
+ int i;
+ enum item_type itype;
+ char *tok, *type_str, *str;
+
+ type=find_attribute(state, "type", 1);
+ if (! type)
+ return 0;
+ for (i = 0 ; i < 3 ; i++) {
+ sprintf(key,"level%d", i);
+ value=find_attribute(state, key, 0);
+ if (value)
+ level[i]=convert_number(value);
+ else
+ level[i]=-1;
+ }
+ type_str=g_strdup(type);
+ str=type_str;
+ while ((tok=strtok(str, ","))) {
+ itype=item_from_name(tok);
+ if (itype!=type_none) {
+ navigation_set_announce(state->parent->element_attr.u.data, itype, level);
+ } else {
+ dbg(lvl_error, "Invalid type for announcement: %s",tok);
+ }
+ str=NULL;
+ }
+ g_free(type_str);
+ return 1;
}
/**
* * Define the elements in our config
@@ -232,336 +225,342 @@ xmlconfig_announce(struct xmlstate *state)
#define DESTROY(x) (void (*)(void *))(x)
static struct object_func object_funcs[] = {
- { attr_announcement,NEW(announcement_new), GET(announcement_get_attr), NULL, NULL, SET(announcement_set_attr), ADD(announcement_add_attr) },
- { attr_arrows, NEW(arrows_new)},
- { attr_circle, NEW(circle_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
- { attr_coord, NEW(coord_new_from_attrs)},
- { attr_cursor, NEW(cursor_new), NULL, NULL, NULL, NULL, ADD(cursor_add_attr)},
- { attr_debug, NEW(debug_new)},
- { attr_graphics, NEW(graphics_new), GET(graphics_get_attr)},
- { attr_gui, NEW(gui_new), GET(gui_get_attr), NULL, NULL, SET(gui_set_attr), ADD(gui_add_attr)},
- { attr_icon, NEW(icon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
- { attr_image, NEW(image_new)},
- { attr_itemgra, NEW(itemgra_new), NULL, NULL, NULL, NULL, ADD(itemgra_add_attr)},
- { attr_plugins, NEW(plugins_new), NULL, NULL, NULL, NULL, NULL, NULL, INIT(plugins_init)},
- { attr_plugin, NEW(plugin_new)},
- { attr_polygon, NEW(polygon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
- { attr_polyline, NEW(polyline_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
- { attr_text, NEW(text_new)},
+ { attr_announcement,NEW(announcement_new), GET(announcement_get_attr), NULL, NULL, SET(announcement_set_attr), ADD(announcement_add_attr) },
+ { attr_arrows, NEW(arrows_new)},
+ { attr_circle, NEW(circle_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
+ { attr_coord, NEW(coord_new_from_attrs)},
+ { attr_cursor, NEW(cursor_new), NULL, NULL, NULL, NULL, ADD(cursor_add_attr)},
+ { attr_debug, NEW(debug_new)},
+ { attr_graphics, NEW(graphics_new), GET(graphics_get_attr)},
+ { attr_gui, NEW(gui_new), GET(gui_get_attr), NULL, NULL, SET(gui_set_attr), ADD(gui_add_attr)},
+ { attr_icon, NEW(icon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
+ { attr_image, NEW(image_new)},
+ { attr_itemgra, NEW(itemgra_new), NULL, NULL, NULL, NULL, ADD(itemgra_add_attr)},
+ { attr_plugins, NEW(plugins_new), NULL, NULL, NULL, NULL, NULL, NULL, INIT(plugins_init)},
+ { attr_plugin, NEW(plugin_new)},
+ { attr_polygon, NEW(polygon_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
+ { attr_polyline, NEW(polyline_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
+ { attr_text, NEW(text_new)},
};
struct object_func *
-object_func_lookup(enum attr_type type)
-{
- int i;
- switch (type) {
- case attr_config:
- return &config_func;
- case attr_layer:
- return &layer_func;
- case attr_layout:
- return &layout_func;
- case attr_log:
- return &log_func;
- case attr_map:
- return &map_func;
- case attr_maps:
- return &maps_func;
- case attr_mapset:
- return &mapset_func;
- case attr_navigation:
- return &navigation_func;
- case attr_navit:
- return &navit_func;
- case attr_profile_option:
- return &profile_option_func;
- case attr_roadprofile:
- return &roadprofile_func;
- case attr_route:
- return &route_func;
- case attr_script:
- return &script_func;
- case attr_osd:
- return &osd_func;
- case attr_trackingo:
- return &tracking_func;
- case attr_speech:
- return &speech_func;
- case attr_audio:
- return &audio_func;
- case attr_vehicle:
- return &vehicle_func;
- case attr_vehicleprofile:
- return &vehicleprofile_func;
- default:
- for (i = 0 ; i < sizeof(object_funcs)/sizeof(struct object_func); i++) {
- if (object_funcs[i].type == type)
- return &object_funcs[i];
- }
- return NULL;
- }
+object_func_lookup(enum attr_type type) {
+ int i;
+ switch (type) {
+ case attr_config:
+ return &config_func;
+ case attr_layer:
+ return &layer_func;
+ case attr_layout:
+ return &layout_func;
+ case attr_log:
+ return &log_func;
+ case attr_map:
+ return &map_func;
+ case attr_maps:
+ return &maps_func;
+ case attr_mapset:
+ return &mapset_func;
+ case attr_navigation:
+ return &navigation_func;
+ case attr_navit:
+ return &navit_func;
+ case attr_profile_option:
+ return &profile_option_func;
+ case attr_roadprofile:
+ return &roadprofile_func;
+ case attr_route:
+ return &route_func;
+ case attr_script:
+ return &script_func;
+ case attr_osd:
+ return &osd_func;
+ case attr_trackingo:
+ return &tracking_func;
+ case attr_speech:
+ return &speech_func;
+ case attr_traffic:
+ return &traffic_func;
+ case attr_vehicle:
+ return &vehicle_func;
+ case attr_vehicleprofile:
+ return &vehicleprofile_func;
+ case attr_audio:
+ return &audio_func;
+ default:
+ for (i = 0 ; i < sizeof(object_funcs)/sizeof(struct object_func); i++) {
+ if (object_funcs[i].type == type)
+ return &object_funcs[i];
+ }
+ return NULL;
+ }
}
struct element_func {
- char *name;
- char *parent;
- int (*func)(struct xmlstate *state);
- enum attr_type type;
+ char *name;
+ char *parent;
+ int (*func)(struct xmlstate *state);
+ enum attr_type type;
};
struct element_func *elements;
-static char *attr_fixme_itemgra[]={
- "type","item_types",
- NULL,NULL,
+static char *attr_fixme_itemgra[]= {
+ "type","item_types",
+ NULL,NULL,
};
-static char *attr_fixme_text[]={
- "label_size","text_size",
- NULL,NULL,
+static char *attr_fixme_text[]= {
+ "label_size","text_size",
+ NULL,NULL,
};
-static char *attr_fixme_circle[]={
- "label_size","text_size",
- NULL,NULL,
+static char *attr_fixme_circle[]= {
+ "label_size","text_size",
+ NULL,NULL,
};
-static struct attr_fixme attr_fixmes[]={
- {"item",attr_fixme_itemgra},
- {"itemgra",attr_fixme_itemgra},
- {"text",attr_fixme_text},
- {"label",attr_fixme_text},
- {"circle",attr_fixme_circle},
- {NULL,NULL},
+static struct attr_fixme attr_fixmes[]= {
+ {"item",attr_fixme_itemgra},
+ {"itemgra",attr_fixme_itemgra},
+ {"text",attr_fixme_text},
+ {"label",attr_fixme_text},
+ {"circle",attr_fixme_circle},
+ {NULL,NULL},
};
-static char *element_fixmes[]={
- "item","itemgra",
- "label","text",
- NULL,NULL,
+static char *element_fixmes[]= {
+ "item","itemgra",
+ "label","text",
+ NULL,NULL,
};
static void initStatic(void) {
- elements=g_new0(struct element_func,44); //43 is a number of elements + ending NULL element
-
- elements[0].name="config";
- elements[0].parent=NULL;
- elements[0].func=NULL;
- elements[0].type=attr_config;
-
- elements[1].name="announce";
- elements[1].parent="navigation";
- elements[1].func=xmlconfig_announce;
-
- elements[2].name="speech";
- elements[2].parent="navit";
- elements[2].func=NULL;
- elements[2].type=attr_speech;
-
- elements[3].name="tracking";
- elements[3].parent="navit";
- elements[3].func=NULL;
- elements[3].type=attr_trackingo;
-
- elements[4].name="route";
- elements[4].parent="navit";
- elements[4].func=NULL;
- elements[4].type=attr_route;
-
- elements[5].name="mapset";
- elements[5].parent="navit";
- elements[5].func=NULL;
- elements[5].type=attr_mapset;
-
- elements[6].name="map";
- elements[6].parent="mapset";
- elements[6].func=NULL;
- elements[6].type=attr_map;
-
- elements[7].name="debug";
- elements[7].parent="config";
- elements[7].func=NULL;
- elements[7].type=attr_debug;
-
- elements[8].name="osd";
- elements[8].parent="navit";
- elements[8].func=NULL;
- elements[8].type=attr_osd;
-
- elements[9].name="navigation";
- elements[9].parent="navit";
- elements[9].func=NULL;
- elements[9].type=attr_navigation;
-
- elements[10].name="navit";
- elements[10].parent="config";
- elements[10].func=NULL;
- elements[10].type=attr_navit;
-
- elements[11].name="graphics";
- elements[11].parent="navit";
- elements[11].func=NULL;
- elements[11].type=attr_graphics;
-
- elements[12].name="gui";
- elements[12].parent="navit";
- elements[12].func=NULL;
- elements[12].type=attr_gui;
-
- elements[13].name="layout";
- elements[13].parent="navit";
- elements[13].func=NULL;
- elements[13].type=attr_layout;
-
- elements[14].name="cursor";
- elements[14].parent="layout";
- elements[14].func=NULL;
- elements[14].type=attr_cursor;
-
- elements[15].name="layer";
- elements[15].parent="layout";
- elements[15].func=NULL;
- elements[15].type=attr_layer;
-
- elements[16].name="itemgra";
- elements[16].parent="layer";
- elements[16].func=NULL;
- elements[16].type=attr_itemgra;
-
- elements[17].name="circle";
- elements[17].parent="itemgra";
- elements[17].func=NULL;
- elements[17].type=attr_circle;
-
- elements[18].name="coord";
- elements[18].parent="circle";
- elements[18].func=NULL;
- elements[18].type=attr_coord;
-
- elements[19].name="icon";
- elements[19].parent="itemgra";
- elements[19].func=NULL;
- elements[19].type=attr_icon;
-
- elements[20].name="coord";
- elements[20].parent="icon";
- elements[20].func=NULL;
- elements[20].type=attr_coord;
-
- elements[21].name="image";
- elements[21].parent="itemgra";
- elements[21].func=NULL;
- elements[21].type=attr_image;
-
- elements[22].name="text";
- elements[22].parent="itemgra";
- elements[22].func=NULL;
- elements[22].type=attr_text;
-
- elements[23].name="polygon";
- elements[23].parent="itemgra";
- elements[23].func=NULL;
- elements[23].type=attr_polygon;
-
- elements[24].name="coord";
- elements[24].parent="polygon";
- elements[24].func=NULL;
- elements[24].type=attr_coord;
-
- elements[25].name="polyline";
- elements[25].parent="itemgra";
- elements[25].func=NULL;
- elements[25].type=attr_polyline;
-
- elements[26].name="coord";
- elements[26].parent="polyline";
- elements[26].func=NULL;
- elements[26].type=attr_coord;
-
- elements[27].name="arrows";
- elements[27].parent="itemgra";
- elements[27].func=NULL;
- elements[27].type=attr_arrows;
-
- elements[28].name="vehicle";
- elements[28].parent="navit";
- elements[28].func=NULL;
- elements[28].type=attr_vehicle;
-
- elements[29].name="vehicleprofile";
- elements[29].parent="navit";
- elements[29].func=NULL;
- elements[29].type=attr_vehicleprofile;
-
- elements[30].name="roadprofile";
- elements[30].parent="vehicleprofile";
- elements[30].func=NULL;
- elements[30].type=attr_roadprofile;
-
- elements[31].name="announcement";
- elements[31].parent="roadprofile";
- elements[31].func=NULL;
- elements[31].type=attr_announcement;
-
- elements[32].name="cursor";
- elements[32].parent="vehicle";
- elements[32].func=NULL;
- elements[32].type=attr_cursor;
-
- elements[33].name="itemgra";
- elements[33].parent="cursor";
- elements[33].func=NULL;
- elements[33].type=attr_itemgra;
-
- elements[34].name="log";
- elements[34].parent="vehicle";
- elements[34].func=NULL;
- elements[34].type=attr_log;
-
- elements[35].name="log";
- elements[35].parent="navit";
- elements[35].func=NULL;
- elements[35].type=attr_log;
-
- elements[36].name="plugins";
- elements[36].parent="config";
- elements[36].func=NULL;
- elements[36].type=attr_plugins;
-
- elements[37].name="plugin";
- elements[37].parent="plugins";
- elements[37].func=NULL;
- elements[37].type=attr_plugin;
-
- elements[38].name="maps";
- elements[38].parent="mapset";
- elements[38].func=NULL;
- elements[38].type=attr_maps;
-
- elements[39].name="layer";
- elements[39].parent="navit";
- elements[39].func=NULL;
- elements[39].type=attr_layer;
-
- elements[40].name="profile_option";
- elements[40].parent="vehicleprofile";
- elements[40].func=NULL;
- elements[40].type=attr_profile_option;
-
- elements[41].name="roadprofile";
- elements[41].parent="profile_option";
- elements[41].func=NULL;
- elements[41].type=attr_roadprofile;
-
- elements[42].name="script";
- elements[42].parent="navit";
- elements[42].func=NULL;
- elements[42].type=attr_script;
-
- elements[43].name="audio";
- elements[43].parent="navit";
- elements[43].func=NULL;
- elements[43].type=attr_audio;
+ elements=g_new0(struct element_func, 46); //45 is a number of elements + ending NULL element
+
+ elements[0].name="config";
+ elements[0].parent=NULL;
+ elements[0].func=NULL;
+ elements[0].type=attr_config;
+
+ elements[1].name="announce";
+ elements[1].parent="navigation";
+ elements[1].func=xmlconfig_announce;
+
+ elements[2].name="speech";
+ elements[2].parent="navit";
+ elements[2].func=NULL;
+ elements[2].type=attr_speech;
+
+ elements[3].name="tracking";
+ elements[3].parent="navit";
+ elements[3].func=NULL;
+ elements[3].type=attr_trackingo;
+
+ elements[4].name="route";
+ elements[4].parent="navit";
+ elements[4].func=NULL;
+ elements[4].type=attr_route;
+
+ elements[5].name="mapset";
+ elements[5].parent="navit";
+ elements[5].func=NULL;
+ elements[5].type=attr_mapset;
+
+ elements[6].name="map";
+ elements[6].parent="mapset";
+ elements[6].func=NULL;
+ elements[6].type=attr_map;
+
+ elements[7].name="debug";
+ elements[7].parent="config";
+ elements[7].func=NULL;
+ elements[7].type=attr_debug;
+
+ elements[8].name="osd";
+ elements[8].parent="navit";
+ elements[8].func=NULL;
+ elements[8].type=attr_osd;
+
+ elements[9].name="navigation";
+ elements[9].parent="navit";
+ elements[9].func=NULL;
+ elements[9].type=attr_navigation;
+
+ elements[10].name="navit";
+ elements[10].parent="config";
+ elements[10].func=NULL;
+ elements[10].type=attr_navit;
+
+ elements[11].name="graphics";
+ elements[11].parent="navit";
+ elements[11].func=NULL;
+ elements[11].type=attr_graphics;
+
+ elements[12].name="gui";
+ elements[12].parent="navit";
+ elements[12].func=NULL;
+ elements[12].type=attr_gui;
+
+ elements[13].name="layout";
+ elements[13].parent="navit";
+ elements[13].func=NULL;
+ elements[13].type=attr_layout;
+
+ elements[14].name="cursor";
+ elements[14].parent="layout";
+ elements[14].func=NULL;
+ elements[14].type=attr_cursor;
+
+ elements[15].name="layer";
+ elements[15].parent="layout";
+ elements[15].func=NULL;
+ elements[15].type=attr_layer;
+
+ elements[16].name="itemgra";
+ elements[16].parent="layer";
+ elements[16].func=NULL;
+ elements[16].type=attr_itemgra;
+
+ elements[17].name="circle";
+ elements[17].parent="itemgra";
+ elements[17].func=NULL;
+ elements[17].type=attr_circle;
+
+ elements[18].name="coord";
+ elements[18].parent="circle";
+ elements[18].func=NULL;
+ elements[18].type=attr_coord;
+
+ elements[19].name="icon";
+ elements[19].parent="itemgra";
+ elements[19].func=NULL;
+ elements[19].type=attr_icon;
+
+ elements[20].name="coord";
+ elements[20].parent="icon";
+ elements[20].func=NULL;
+ elements[20].type=attr_coord;
+
+ elements[21].name="image";
+ elements[21].parent="itemgra";
+ elements[21].func=NULL;
+ elements[21].type=attr_image;
+
+ elements[22].name="text";
+ elements[22].parent="itemgra";
+ elements[22].func=NULL;
+ elements[22].type=attr_text;
+
+ elements[23].name="polygon";
+ elements[23].parent="itemgra";
+ elements[23].func=NULL;
+ elements[23].type=attr_polygon;
+
+ elements[24].name="coord";
+ elements[24].parent="polygon";
+ elements[24].func=NULL;
+ elements[24].type=attr_coord;
+
+ elements[25].name="polyline";
+ elements[25].parent="itemgra";
+ elements[25].func=NULL;
+ elements[25].type=attr_polyline;
+
+ elements[26].name="coord";
+ elements[26].parent="polyline";
+ elements[26].func=NULL;
+ elements[26].type=attr_coord;
+
+ elements[27].name="arrows";
+ elements[27].parent="itemgra";
+ elements[27].func=NULL;
+ elements[27].type=attr_arrows;
+
+ elements[28].name="vehicle";
+ elements[28].parent="navit";
+ elements[28].func=NULL;
+ elements[28].type=attr_vehicle;
+
+ elements[29].name="vehicleprofile";
+ elements[29].parent="navit";
+ elements[29].func=NULL;
+ elements[29].type=attr_vehicleprofile;
+
+ elements[30].name="roadprofile";
+ elements[30].parent="vehicleprofile";
+ elements[30].func=NULL;
+ elements[30].type=attr_roadprofile;
+
+ elements[31].name="announcement";
+ elements[31].parent="roadprofile";
+ elements[31].func=NULL;
+ elements[31].type=attr_announcement;
+
+ elements[32].name="cursor";
+ elements[32].parent="vehicle";
+ elements[32].func=NULL;
+ elements[32].type=attr_cursor;
+
+ elements[33].name="itemgra";
+ elements[33].parent="cursor";
+ elements[33].func=NULL;
+ elements[33].type=attr_itemgra;
+
+ elements[34].name="log";
+ elements[34].parent="vehicle";
+ elements[34].func=NULL;
+ elements[34].type=attr_log;
+
+ elements[35].name="log";
+ elements[35].parent="navit";
+ elements[35].func=NULL;
+ elements[35].type=attr_log;
+
+ elements[36].name="plugins";
+ elements[36].parent="config";
+ elements[36].func=NULL;
+ elements[36].type=attr_plugins;
+
+ elements[37].name="plugin";
+ elements[37].parent="plugins";
+ elements[37].func=NULL;
+ elements[37].type=attr_plugin;
+
+ elements[38].name="maps";
+ elements[38].parent="mapset";
+ elements[38].func=NULL;
+ elements[38].type=attr_maps;
+
+ elements[39].name="layer";
+ elements[39].parent="navit";
+ elements[39].func=NULL;
+ elements[39].type=attr_layer;
+
+ elements[40].name="profile_option";
+ elements[40].parent="vehicleprofile";
+ elements[40].func=NULL;
+ elements[40].type=attr_profile_option;
+
+ elements[41].name="roadprofile";
+ elements[41].parent="profile_option";
+ elements[41].func=NULL;
+ elements[41].type=attr_roadprofile;
+
+ elements[42].name="script";
+ elements[42].parent="navit";
+ elements[42].func=NULL;
+ elements[42].type=attr_script;
+
+ elements[43].name="traffic";
+ elements[43].parent="navit";
+ elements[43].func=NULL;
+ elements[43].type=attr_traffic;
+
+ elements[44].name="audio";
+ elements[44].parent="navit";
+ elements[44].func=NULL;
+ elements[44].type=attr_audio;
}
/**
@@ -576,396 +575,390 @@ static void initStatic(void) {
* * @returns nothing
* */
-static void
-start_element(xml_context *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- xmlerror **error)
-{
- struct xmlstate *new=NULL, **parent = user_data;
- struct element_func *e=elements,*func=NULL;
- struct attr_fixme *attr_fixme=attr_fixmes;
- char **element_fixme=element_fixmes;
- int found=0;
- static int fixme_count;
- const char *parent_name=NULL;
- char *s,*sep="",*possible_parents;
- struct attr *parent_attr;
- dbg(lvl_info,"name='%s' parent='%s'\n", element_name, *parent ? (*parent)->element:NULL);
-
- if (!strcmp(element_name,"xml"))
- return;
- /* determine if we have to fix any attributes */
- while (attr_fixme[0].element) {
- if (!strcmp(element_name,attr_fixme[0].element))
- break;
- attr_fixme++;
- }
- if (!attr_fixme[0].element)
- attr_fixme=NULL;
-
- /* tell user to fix deprecated element names */
- while (element_fixme[0]) {
- if (!strcmp(element_name,element_fixme[0])) {
- element_name=element_fixme[1];
- if (fixme_count++ < 10)
- dbg(lvl_error,"Please change <%s /> to <%s /> in config file\n", element_fixme[0], element_fixme[1]);
- }
- element_fixme+=2;
- }
- /* validate that this element is valid
- * and that the element has a valid parent */
- possible_parents=g_strdup("");
- if (*parent)
- parent_name=(*parent)->element;
- while (e->name) {
- if (!g_ascii_strcasecmp(element_name, e->name)) {
- found=1;
- s=g_strconcat(possible_parents,sep,e->parent,NULL);
- g_free(possible_parents);
- possible_parents=s;
- sep=",";
- if ((parent_name && e->parent && !g_ascii_strcasecmp(parent_name, e->parent)) ||
- (!parent_name && !e->parent))
- func=e;
- }
- e++;
- }
- if (! found) {
- g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_UNKNOWN_ELEMENT,
- "Unknown element '%s'", element_name);
- g_free(possible_parents);
- return;
- }
- if (! func) {
- g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT,
- "Element '%s' within unexpected context '%s'. Expected '%s'%s",
- element_name, parent_name, possible_parents, ! strcmp(possible_parents, "config") ? "\nPlease add <config> </config> tags at the beginning/end of your navit.xml": "");
- g_free(possible_parents);
- return;
- }
- g_free(possible_parents);
-
- new=g_new(struct xmlstate, 1);
- new->attribute_names=attribute_names;
- new->attribute_values=attribute_values;
- new->parent=*parent;
- new->element_attr.u.data=NULL;
- new->element=element_name;
- new->error=error;
- new->func=func;
- new->object_func=NULL;
- *parent=new;
- if (!find_boolean(new, "enabled", 1, 0))
- return;
- if (new->parent && !new->parent->element_attr.u.data)
- return;
- if (func->func) {
- if (!func->func(new)) {
- return;
- }
- } else {
- struct attr **attrs;
-
- new->object_func=object_func_lookup(func->type);
- if (! new->object_func)
- return;
- attrs=convert_to_attrs(new,attr_fixme);
- new->element_attr.type=attr_none;
- if (!new->parent || new->parent->element_attr.type == attr_none)
- parent_attr=NULL;
- else
- parent_attr=&new->parent->element_attr;
- new->element_attr.u.data = new->object_func->create(parent_attr, attrs);
- if (! new->element_attr.u.data)
- return;
- new->element_attr.type=attr_from_name(element_name);
- if (new->element_attr.type == attr_none)
- dbg(lvl_error,"failed to create object of type '%s'\n", element_name);
- if (new->element_attr.type == attr_tracking)
- new->element_attr.type=attr_trackingo;
- if (new->parent && new->parent->object_func && new->parent->object_func->add_attr)
- new->parent->object_func->add_attr(new->parent->element_attr.u.data, &new->element_attr);
- }
- return;
+static void start_element(xml_context *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ xmlerror **error) {
+ struct xmlstate *new=NULL, **parent = user_data;
+ struct element_func *e=elements,*func=NULL;
+ struct attr_fixme *attr_fixme=attr_fixmes;
+ char **element_fixme=element_fixmes;
+ int found=0;
+ static int fixme_count;
+ const char *parent_name=NULL;
+ char *s,*sep="",*possible_parents;
+ struct attr *parent_attr;
+ dbg(lvl_info,"name='%s' parent='%s'", element_name, *parent ? (*parent)->element:NULL);
+
+ if (!strcmp(element_name,"xml"))
+ return;
+ /* determine if we have to fix any attributes */
+ while (attr_fixme[0].element) {
+ if (!strcmp(element_name,attr_fixme[0].element))
+ break;
+ attr_fixme++;
+ }
+ if (!attr_fixme[0].element)
+ attr_fixme=NULL;
+
+ /* tell user to fix deprecated element names */
+ while (element_fixme[0]) {
+ if (!strcmp(element_name,element_fixme[0])) {
+ element_name=element_fixme[1];
+ if (fixme_count++ < 10)
+ dbg(lvl_error,"Please change <%s /> to <%s /> in config file", element_fixme[0], element_fixme[1]);
+ }
+ element_fixme+=2;
+ }
+ /* validate that this element is valid
+ * and that the element has a valid parent */
+ possible_parents=g_strdup("");
+ if (*parent)
+ parent_name=(*parent)->element;
+ while (e->name) {
+ if (!g_ascii_strcasecmp(element_name, e->name)) {
+ found=1;
+ s=g_strconcat(possible_parents,sep,e->parent,NULL);
+ g_free(possible_parents);
+ possible_parents=s;
+ sep=",";
+ if ((parent_name && e->parent && !g_ascii_strcasecmp(parent_name, e->parent)) ||
+ (!parent_name && !e->parent))
+ func=e;
+ }
+ e++;
+ }
+ if (! found) {
+ g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_UNKNOWN_ELEMENT,
+ "Unknown element '%s'", element_name);
+ g_free(possible_parents);
+ return;
+ }
+ if (! func) {
+ g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT,
+ "Element '%s' within unexpected context '%s'. Expected '%s'%s",
+ element_name, parent_name, possible_parents, ! strcmp(possible_parents,
+ "config") ? "\nPlease add <config> </config> tags at the beginning/end of your navit.xml": "");
+ g_free(possible_parents);
+ return;
+ }
+ g_free(possible_parents);
+
+ new=g_new(struct xmlstate, 1);
+ new->attribute_names=attribute_names;
+ new->attribute_values=attribute_values;
+ new->parent=*parent;
+ new->element_attr.u.data=NULL;
+ new->element=element_name;
+ new->error=error;
+ new->func=func;
+ new->object_func=NULL;
+ *parent=new;
+ if (!find_boolean(new, "enabled", 1, 0))
+ return;
+ if (new->parent && !new->parent->element_attr.u.data)
+ return;
+ if (func->func) {
+ if (!func->func(new)) {
+ return;
+ }
+ } else {
+ struct attr **attrs;
+
+ new->object_func=object_func_lookup(func->type);
+ if (! new->object_func)
+ return;
+ attrs=convert_to_attrs(new,attr_fixme);
+ new->element_attr.type=attr_none;
+ if (!new->parent || new->parent->element_attr.type == attr_none)
+ parent_attr=NULL;
+ else
+ parent_attr=&new->parent->element_attr;
+ new->element_attr.u.data = new->object_func->create(parent_attr, attrs);
+ if (! new->element_attr.u.data)
+ return;
+ new->element_attr.type=attr_from_name(element_name);
+ if (new->element_attr.type == attr_none)
+ dbg(lvl_error,"failed to create object of type '%s'", element_name);
+ if (new->element_attr.type == attr_tracking)
+ new->element_attr.type=attr_trackingo;
+ if (new->parent && new->parent->object_func && new->parent->object_func->add_attr)
+ new->parent->object_func->add_attr(new->parent->element_attr.u.data, &new->element_attr);
+ }
+ return;
}
/* Called for close tags </foo> */
-static void
-end_element (xml_context *context,
- const gchar *element_name,
- gpointer user_data,
- xmlerror **error)
-{
- struct xmlstate *curr, **state = user_data;
-
- if (!strcmp(element_name,"xml"))
- return;
- dbg(lvl_info,"name='%s'\n", element_name);
- curr=*state;
- if (curr->object_func && curr->object_func->init)
- curr->object_func->init(curr->element_attr.u.data);
- if (curr->object_func && curr->object_func->unref)
- curr->object_func->unref(curr->element_attr.u.data);
- *state=curr->parent;
- g_free(curr);
+static void end_element (xml_context *context,
+ const gchar *element_name,
+ gpointer user_data,
+ xmlerror **error) {
+ struct xmlstate *curr, **state = user_data;
+
+ if (!strcmp(element_name,"xml"))
+ return;
+ dbg(lvl_info,"name='%s'", element_name);
+ curr=*state;
+ if (curr->object_func && curr->object_func->init)
+ curr->object_func->init(curr->element_attr.u.data);
+ if (curr->object_func && curr->object_func->unref)
+ curr->object_func->unref(curr->element_attr.u.data);
+ *state=curr->parent;
+ g_free(curr);
}
static gboolean parse_file(struct xmldocument *document, xmlerror **error);
-static void
-xinclude(xml_context *context, const gchar **attribute_names, const gchar **attribute_values, struct xmldocument *doc_old, xmlerror **error)
-{
- struct xmldocument doc_new;
- struct file_wordexp *we;
- int i,count;
- const char *href=NULL;
- char **we_files;
-
- if (doc_old->level >= 16) {
- g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include recursion too deep");
- return;
- }
- memset(&doc_new, 0, sizeof(doc_new));
- i=0;
- while (attribute_names[i]) {
- if(!g_ascii_strcasecmp("href", attribute_names[i])) {
- if (!href)
- href=attribute_values[i];
- else {
- g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include has more than one href");
- return;
- }
- } else if(!g_ascii_strcasecmp("xpointer", attribute_names[i])) {
- if (!doc_new.xpointer)
- doc_new.xpointer=attribute_values[i];
- else {
- g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include has more than one xpointer");
- return;
- }
- } else {
- g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include has invalid attributes");
- return;
- }
- i++;
- }
- if (!doc_new.xpointer && !href) {
- g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include has neither href nor xpointer");
- return;
- }
- doc_new.level=doc_old->level+1;
- doc_new.user_data=doc_old->user_data;
- if (! href) {
- dbg(lvl_debug,"no href, using '%s'\n", doc_old->href);
- doc_new.href=doc_old->href;
- if (file_exists(doc_new.href)) {
- parse_file(&doc_new, error);
- } else {
- dbg(lvl_error,"Unable to include %s\n",doc_new.href);
- }
- } else {
- dbg(lvl_debug,"expanding '%s'\n", href);
- we=file_wordexp_new(href);
- we_files=file_wordexp_get_array(we);
- count=file_wordexp_get_count(we);
- dbg(lvl_debug,"%d results\n", count);
- if (file_exists(we_files[0])) {
- for (i = 0 ; i < count ; i++) {
- dbg(lvl_debug,"result[%d]='%s'\n", i, we_files[i]);
- doc_new.href=we_files[i];
- parse_file(&doc_new, error);
- }
- } else {
- dbg(lvl_error,"Unable to include %s\n",we_files[0]);
- }
- file_wordexp_destroy(we);
-
- }
-
+/**
+ * @brief Handle xi:include XML tags
+ *
+ * @param context The XML context in which we are parsing
+ * @param[in] attribute_names An array of strings containing all XML attributes of the xi:include tag
+ * @param[in] attribute_values An array of strings containing all XML values (one per entry in @p attribute_names)
+ * @param doc_old The current document being parsed (before moving to the one referenced in this xi:include
+ * @param[out] error A description of the error encountered if any
+ */
+static void xinclude(xml_context *context, const gchar **attribute_names, const gchar **attribute_values,
+ struct xmldocument *doc_old, xmlerror **error) {
+ struct xmldocument doc_new;
+ struct file_wordexp *we;
+ int i,count;
+ const char *href=NULL;
+ char **we_files;
+ char *included_filename=NULL;
+ char *doc_base=NULL;
+ char *tmp=NULL;
+
+ if (doc_old->level >= 16) {
+ g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include recursion too deep");
+ return;
+ }
+ dbg(lvl_debug, "At level %d, processing xi:include in document href=\"%s\"", doc_old->level, doc_old->href);
+ memset(&doc_new, 0, sizeof(doc_new));
+ i=0;
+ while (attribute_names[i]) {
+ if(!g_ascii_strcasecmp("href", attribute_names[i])) {
+ if (!href)
+ href=attribute_values[i];
+ else {
+ g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include has more than one href");
+ return;
+ }
+ } else if(!g_ascii_strcasecmp("xpointer", attribute_names[i])) {
+ if (!doc_new.xpointer)
+ doc_new.xpointer=attribute_values[i];
+ else {
+ g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include has more than one xpointer");
+ return;
+ }
+ } else {
+ g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include has invalid attributes");
+ return;
+ }
+ i++;
+ }
+ if (!doc_new.xpointer && !href) {
+ g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "xi:include has neither href nor xpointer");
+ return;
+ }
+ doc_new.level=doc_old->level+1;
+ doc_new.user_data=doc_old->user_data;
+ if (!href) {
+ dbg(lvl_debug,"no href%s, using own ref '%s'", doc_new.xpointer?" (but xpointer provided)":"", doc_old->href);
+ doc_new.href=doc_old->href;
+ if (file_exists(doc_new.href)) {
+ parse_file(&doc_new, error);
+ } else {
+ dbg(lvl_error,"Unable to include %s",doc_new.href);
+ }
+ } else {
+ dbg(lvl_debug,"expanding '%s'", href);
+ we=file_wordexp_new(href);
+ we_files=file_wordexp_get_array(we); /* Expand wildcards (if any) into a list of files */
+ count=file_wordexp_get_count(we);
+ dbg(lvl_debug,"%d results", count);
+ for (i = 0 ; i < count ; i++) {
+ included_filename = g_strdup(we_files[i]);
+ if (*included_filename != '\0') { /* Non empty href */
+ if (!g_path_is_absolute(included_filename)) { /* The filename's path is relative */
+ doc_base = g_path_get_dirname(doc_old->href); /* Get our own absolute path */
+ if (*doc_base && file_is_dir(doc_base)) {
+ tmp = included_filename;
+ included_filename = g_strconcat(doc_base, G_DIR_SEPARATOR_S, tmp, NULL);
+ g_free(tmp); /* Free initial included_filename buffer (saved in tmp) */
+ }
+ g_free(doc_base);
+ dbg(lvl_debug,"converted relative filename='%s' to absolute filename='%s'", we_files[i], included_filename);
+ }
+ dbg(lvl_debug,"result[%d]='%s'", i, included_filename);
+ if (file_exists(included_filename)) {
+ doc_new.href=included_filename;
+ parse_file(&doc_new, error); /* Now run the parser on the included XML file */
+ } else {
+ dbg(lvl_error,"Unable to include '%s'",included_filename);
+ }
+ }
+ g_free(included_filename);
+ }
+ file_wordexp_destroy(we);
+ }
}
-static int
-strncmp_len(const char *s1, int s1len, const char *s2)
-{
- int ret;
-#if 0
- char c[s1len+1];
- strncpy(c, s1, s1len);
- c[s1len]='\0';
- dbg(lvl_debug,"'%s' vs '%s'\n", c, s2);
-#endif
- ret=strncmp(s1, s2, s1len);
- if (ret)
- return ret;
- return strlen(s2)-s1len;
+static int strncmp_len(const char *s1, int s1len, const char *s2) {
+ int ret;
+ ret=strncmp(s1, s2, s1len);
+ if (ret)
+ return ret;
+ return strlen(s2)-s1len;
}
-static int
-xpointer_value(const char *test, int len, struct xistate *elem, const char **out, int out_len)
-{
- int i,ret=0;
- if (len <= 0 || out_len <= 0) {
- return 0;
- }
- if (!(strncmp_len(test,len,"name(.)"))) {
- out[0]=elem->element;
- return 1;
- }
- if (test[0] == '@') {
- i=0;
- while (elem->attribute_names[i] && out_len > 0) {
- if (!strncmp_len(test+1,len-1,elem->attribute_names[i])) {
- out[ret++]=elem->attribute_values[i];
- out_len--;
- }
- i++;
- }
- return ret;
- }
- return 0;
+static int xpointer_value(const char *test, int len, struct xistate *elem, const char **out, int out_len) {
+ int i,ret=0;
+ if (len <= 0 || out_len <= 0) {
+ return 0;
+ }
+ if (!(strncmp_len(test,len,"name(.)"))) {
+ out[0]=elem->element;
+ return 1;
+ }
+ if (test[0] == '@') {
+ i=0;
+ while (elem->attribute_names[i] && out_len > 0) {
+ if (!strncmp_len(test+1,len-1,elem->attribute_names[i])) {
+ out[ret++]=elem->attribute_values[i];
+ out_len--;
+ }
+ i++;
+ }
+ return ret;
+ }
+ return 0;
}
-static int
-xpointer_test(const char *test, int len, struct xistate *elem)
-{
- int eq,i,count,vlen,cond_req=1,cond=0;
- char c;
- const char *tmp[16];
-#if 0
- char test2[len+1];
-
- strncpy(test2, test, len);
- test2[len]='\0';
- dbg(lvl_debug,"%s\n", test2);
-#endif
- if (!len)
- return 0;
- c=test[len-1];
- if (c != '\'' && c != '"')
- return 0;
- eq=strcspn(test, "=");
- if (eq >= len || test[eq+1] != c)
- return 0;
- vlen=eq;
- if (eq > 0 && test[eq-1] == '!') {
- cond_req=0;
- vlen--;
- }
- count=xpointer_value(test,vlen,elem,tmp,16);
- for (i = 0 ; i < count ; i++) {
- if (!strncmp_len(test+eq+2,len-eq-3, tmp[i]))
- cond=1;
- }
- if (cond == cond_req)
- return 1;
- return 0;
+static int xpointer_test(const char *test, int len, struct xistate *elem) {
+ int eq,i,count,vlen,cond_req=1,cond=0;
+ char c;
+ const char *tmp[16];
+ if (!len)
+ return 0;
+ c=test[len-1];
+ if (c != '\'' && c != '"')
+ return 0;
+ eq=strcspn(test, "=");
+ if (eq >= len || test[eq+1] != c)
+ return 0;
+ vlen=eq;
+ if (eq > 0 && test[eq-1] == '!') {
+ cond_req=0;
+ vlen--;
+ }
+ count=xpointer_value(test,vlen,elem,tmp,16);
+ for (i = 0 ; i < count ; i++) {
+ if (!strncmp_len(test+eq+2,len-eq-3, tmp[i]))
+ cond=1;
+ }
+ if (cond == cond_req)
+ return 1;
+ return 0;
}
-static int
-xpointer_element_match(const char *xpointer, int len, struct xistate *elem)
-{
- int start,tlen;
- start=strcspn(xpointer, "[");
- if (start > len)
- start=len;
- if (strncmp_len(xpointer, start, elem->element) && (start != 1 || xpointer[0] != '*'))
- return 0;
- if (start == len)
- return 1;
- if (xpointer[len-1] != ']')
- return 0;
- for (;;) {
- start++;
- tlen=strcspn(xpointer+start,"]");
- if (start + tlen > len)
- return 1;
- if (!xpointer_test(xpointer+start, tlen, elem))
- return 0;
- start+=tlen+1;
- }
+static int xpointer_element_match(const char *xpointer, int len, struct xistate *elem) {
+ int start,tlen;
+ start=strcspn(xpointer, "[");
+ if (start > len)
+ start=len;
+ if (strncmp_len(xpointer, start, elem->element) && (start != 1 || xpointer[0] != '*'))
+ return 0;
+ if (start == len)
+ return 1;
+ if (xpointer[len-1] != ']')
+ return 0;
+ for (;;) {
+ start++;
+ tlen=strcspn(xpointer+start,"]");
+ if (start + tlen > len)
+ return 1;
+ if (!xpointer_test(xpointer+start, tlen, elem))
+ return 0;
+ start+=tlen+1;
+ }
}
-static int
-xpointer_xpointer_match(const char *xpointer, int len, struct xistate *first)
-{
- const char *c;
- int s;
- dbg(lvl_info,"%s\n", xpointer);
- if (xpointer[0] != '/')
- return 0;
- c=xpointer+1;
- len--;
- do {
- s=strcspn(c, "/");
- if (s > len)
- s=len;
- if (! xpointer_element_match(c, s, first))
- return 0;
- first=first->child;
- c+=s+1;
- len-=s+1;
- } while (len > 0 && first);
- if (len > 0)
- return 0;
- return 1;
+static int xpointer_xpointer_match(const char *xpointer, int len, struct xistate *first) {
+ const char *c;
+ int s;
+ dbg(lvl_info,"%s", xpointer);
+ if (xpointer[0] != '/')
+ return 0;
+ c=xpointer+1;
+ len--;
+ do {
+ s=strcspn(c, "/");
+ if (s > len)
+ s=len;
+ if (! xpointer_element_match(c, s, first))
+ return 0;
+ first=first->child;
+ c+=s+1;
+ len-=s+1;
+ } while (len > 0 && first);
+ if (len > 0)
+ return 0;
+ return 1;
}
-static int
-xpointer_match(const char *xpointer, struct xistate *first)
-{
- char *prefix="xpointer(";
- int len;
- if (! xpointer)
- return 1;
- len=strlen(xpointer);
- if (strncmp(xpointer,prefix,strlen(prefix)))
- return 0;
- if (xpointer[len-1] != ')')
- return 0;
- return xpointer_xpointer_match(xpointer+strlen(prefix), len-strlen(prefix)-1, first);
+static int xpointer_match(const char *xpointer, struct xistate *first) {
+ char *prefix="xpointer(";
+ int len;
+ if (! xpointer)
+ return 1;
+ len=strlen(xpointer);
+ if (strncmp(xpointer,prefix,strlen(prefix)))
+ return 0;
+ if (xpointer[len-1] != ')')
+ return 0;
+ return xpointer_xpointer_match(xpointer+strlen(prefix), len-strlen(prefix)-1, first);
}
-static void
-xi_start_element(xml_context *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- xmlerror **error)
-{
- struct xmldocument *doc=user_data;
- struct xistate *xistate;
- int i,count=0;
- while (attribute_names[count++*XML_ATTR_DISTANCE]);
- xistate=g_new0(struct xistate, 1);
- xistate->element=element_name;
- xistate->attribute_names=g_new0(const char *, count);
- xistate->attribute_values=g_new0(const char *, count);
- for (i = 0 ; i < count ; i++) {
- if (attribute_names[i*XML_ATTR_DISTANCE] && attribute_values[i*XML_ATTR_DISTANCE]) {
- xistate->attribute_names[i]=g_strdup(attribute_names[i*XML_ATTR_DISTANCE]);
- xistate->attribute_values[i]=g_strdup(attribute_values[i*XML_ATTR_DISTANCE]);
- }
- }
- xistate->parent=doc->last;
-
- if (doc->last) {
- doc->last->child=xistate;
- } else
- doc->first=xistate;
- doc->last=xistate;
- if (doc->active > 0 || xpointer_match(doc->xpointer, doc->first)) {
- if(!g_ascii_strcasecmp("xi:include", element_name)) {
- xinclude(context, xistate->attribute_names, xistate->attribute_values, doc, error);
- return;
- }
- start_element(context, element_name, xistate->attribute_names, xistate->attribute_values, doc->user_data, error);
- doc->active++;
- }
+static void xi_start_element(xml_context *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ xmlerror **error) {
+ struct xmldocument *doc=user_data;
+ struct xistate *xistate;
+ int i,count=0;
+ while (attribute_names[count++*XML_ATTR_DISTANCE]);
+ xistate=g_new0(struct xistate, 1);
+ xistate->element=element_name;
+ xistate->attribute_names=g_new0(const char *, count);
+ xistate->attribute_values=g_new0(const char *, count);
+ for (i = 0 ; i < count ; i++) {
+ if (attribute_names[i*XML_ATTR_DISTANCE] && attribute_values[i*XML_ATTR_DISTANCE]) {
+ xistate->attribute_names[i]=g_strdup(attribute_names[i*XML_ATTR_DISTANCE]);
+ xistate->attribute_values[i]=g_strdup(attribute_values[i*XML_ATTR_DISTANCE]);
+ }
+ }
+ xistate->parent=doc->last;
+
+ if (doc->last) {
+ doc->last->child=xistate;
+ } else
+ doc->first=xistate;
+ doc->last=xistate;
+ if (doc->active > 0 || xpointer_match(doc->xpointer, doc->first)) {
+ if(!g_ascii_strcasecmp("xi:include", element_name)) {
+ xinclude(context, xistate->attribute_names, xistate->attribute_values, doc, error);
+ return;
+ }
+ start_element(context, element_name, xistate->attribute_names, xistate->attribute_values, doc->user_data, error);
+ doc->active++;
+ }
}
/**
@@ -978,131 +971,185 @@ xi_start_element(xml_context *context,
* * @returns nothing
* */
-static void
-xi_end_element (xml_context *context,
- const gchar *element_name,
- gpointer user_data,
- xmlerror **error)
-{
- struct xmldocument *doc=user_data;
- struct xistate *xistate=doc->last;
- int i=0;
- doc->last=doc->last->parent;
- if (! doc->last)
- doc->first=NULL;
- else
- doc->last->child=NULL;
- if (doc->active > 0) {
- if(!g_ascii_strcasecmp("xi:include", element_name)) {
- return;
- }
- end_element(context, element_name, doc->user_data, error);
- doc->active--;
- }
- while (xistate->attribute_names[i]) {
- g_free((char *)(xistate->attribute_names[i]));
- g_free((char *)(xistate->attribute_values[i]));
- i++;
- }
- g_free(xistate->attribute_names);
- g_free(xistate->attribute_values);
- g_free(xistate);
+static void xi_end_element (xml_context *context,
+ const gchar *element_name,
+ gpointer user_data,
+ xmlerror **error) {
+ struct xmldocument *doc=user_data;
+ struct xistate *xistate=doc->last;
+ int i=0;
+ doc->last=doc->last->parent;
+ if (! doc->last)
+ doc->first=NULL;
+ else
+ doc->last->child=NULL;
+ if (doc->active > 0) {
+ if(!g_ascii_strcasecmp("xi:include", element_name)) {
+ return;
+ }
+ end_element(context, element_name, doc->user_data, error);
+ doc->active--;
+ }
+ while (xistate->attribute_names[i]) {
+ g_free((char *)(xistate->attribute_names[i]));
+ g_free((char *)(xistate->attribute_values[i]));
+ i++;
+ }
+ g_free(xistate->attribute_names);
+ g_free(xistate->attribute_values);
+ g_free(xistate);
}
/* Called for character data */
/* text is not nul-terminated */
-static void
-xi_text (xml_context *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- xmlerror **error)
-{
- struct xmldocument *doc=user_data;
- int i;
- if (doc->active) {
- for (i = 0 ; i < text_len ; i++) {
- if (!isspace(text[i])) {
- struct xmldocument *doc=user_data;
- struct xmlstate *curr, **state = doc->user_data;
- struct attr attr;
- char *text_dup = malloc(text_len+1);
-
- curr=*state;
- strncpy(text_dup, text, text_len);
- text_dup[text_len]='\0';
- attr.type=attr_xml_text;
- attr.u.str=text_dup;
- if (curr->object_func && curr->object_func->add_attr && curr->element_attr.u.data)
- curr->object_func->add_attr(curr->element_attr.u.data, &attr);
- free(text_dup);
- return;
- }
- }
- }
+static void xi_text (xml_context *context,
+ const gchar *text,
+ gsize text_len,
+ gpointer user_data,
+ xmlerror **error) {
+ struct xmldocument *doc=user_data;
+ int i;
+ if (doc->active) {
+ for (i = 0 ; i < text_len ; i++) {
+ if (!isspace(text[i])) {
+ struct xmldocument *doc=user_data;
+ struct xmlstate *curr, **state = doc->user_data;
+ struct attr attr;
+
+ curr=*state;
+ char *text_dup = g_strndup(text, text_len);
+ attr.type=attr_xml_text;
+ attr.u.str=text_dup;
+ if (curr->object_func && curr->object_func->add_attr && curr->element_attr.u.data)
+ curr->object_func->add_attr(curr->element_attr.u.data, &attr);
+ g_free(text_dup);
+ return;
+ }
+ }
+ }
}
#if USE_EZXML
-static void
-parse_node_text(ezxml_t node, void *data, void (*start)(void *, const char *, const char **, const char **, void *, void *),
- void (*end)(void *, const char *, void *, void *),
- void (*text)(void *, const char *, int, void *, void *))
-{
- while (node) {
- if (start)
- start(NULL, node->name, (const char **)node->attr, (const char **)(node->attr+1), data, NULL);
- if (text && node->txt)
- text(NULL, node->txt, strlen(node->txt), data, NULL);
- if (node->child)
- parse_node_text(node->child, data, start, end, text);
- if (end)
- end(NULL, node->name, data, NULL);
- node=node->ordered;
- }
+static void parse_node_text(ezxml_t node, void *data, void (*start)(void *, const char *, const char **, const char **,
+ void *,
+ void *),
+ void (*end)(void *, const char *, void *, void *),
+ void (*text)(void *, const char *, int, void *, void *)) {
+ while (node) {
+ if (start)
+ start(NULL, node->name, (const char **)node->attr, (const char **)(node->attr+1), data, NULL);
+ if (text && node->txt)
+ text(NULL, node->txt, strlen(node->txt), data, NULL);
+ if (node->child)
+ parse_node_text(node->child, data, start, end, text);
+ if (end)
+ end(NULL, node->name, data, NULL);
+ node=node->ordered;
+ }
}
#endif
-void
-xml_parse_text(const char *document, void *data,
- void (*start)(xml_context *, const char *, const char **, const char **, void *, GError **),
- void (*end)(xml_context *, const char *, void *, GError **),
- void (*text)(xml_context *, const char *, gsize, void *, GError **)) {
+/**
+ * @brief Parses an XML file.
+ *
+ * @param filename The XML file to parse
+ * @param data Points to a user-defined data structure which will be passed to each of the callbacks
+ * passed in the following arguments
+ * @param start Callback which will be called when an open tag is encountered
+ * @param end Callback which will be called when a close tag is encountered
+ * @param text Callback which will be called when character data is encountered
+ *
+ * @return True on success, false on failure.
+ */
+int xml_parse_file(char *filename, void *data,
+ void (*start)(xml_context *, const char *, const char **, const char **, void *, GError **),
+ void (*end)(xml_context *, const char *, void *, GError **),
+ void (*text)(xml_context *, const char *, gsize, void *, GError **)) {
+ int ret = 0;
+#if !USE_EZXML
+ gchar *contents;
+ gsize len;
+
+ if (g_file_get_contents(filename, &contents, &len, NULL)) {
+ dbg(lvl_debug, "XML data:\n%s\n", contents);
+ ret = xml_parse_text(contents, data, start, end, text);
+ g_free(contents);
+ } else {
+ dbg(lvl_error,"could not open XML file");
+ }
+#else
+ FILE *f;
+ ezxml_t root;
+
+ f = fopen(filename,"rb");
+ if (f) {
+ root = ezxml_parse_fp(f);
+ fclose(f);
+ if (root) {
+ parse_node_text(root, data, start, end, text);
+ ezxml_free(root);
+ ret = 1;
+ }
+ } else {
+ dbg(lvl_error,"could not open XML file");
+ }
+#endif
+ return ret;
+}
+
+/**
+ * @brief Parses XML text.
+ *
+ * @param document The XML data to parse
+ * @param data Points to a user-defined data structure which will be passed to each of the callbacks
+ * passed in the following arguments
+ * @param start Callback which will be called when an open tag is encountered
+ * @param end Callback which will be called when a close tag is encountered
+ * @param text Callback which will be called when character data is encountered
+ *
+ * @return True on success, false on failure.
+ */
+int xml_parse_text(const char *document, void *data,
+ void (*start)(xml_context *, const char *, const char **, const char **, void *, GError **),
+ void (*end)(xml_context *, const char *, void *, GError **),
+ void (*text)(xml_context *, const char *, gsize, void *, GError **)) {
#if !USE_EZXML
- GMarkupParser parser = { start, end, text, NULL, NULL};
- xml_context *context;
- gboolean result;
-
- context = g_markup_parse_context_new (&parser, 0, data, NULL);
- if (!document){
- dbg(lvl_error, "FATAL: No XML data supplied (looks like incorrect configuration for internal GUI).\n");
- exit(1);
- }
- result = g_markup_parse_context_parse (context, document, strlen(document), NULL);
- if (!result){
- dbg(lvl_error, "FATAL: Cannot parse data as XML: '%s'\n", document);
- exit(1);
- }
- g_markup_parse_context_free (context);
+ GMarkupParser parser = { start, end, text, NULL, NULL};
+ xml_context *context;
+ gboolean result;
+
+ if (!document) {
+ dbg(lvl_error, "FATAL: No XML data supplied.");
+ return 0;
+ }
+ context = g_markup_parse_context_new (&parser, 0, data, NULL);
+ result = g_markup_parse_context_parse (context, document, strlen(document), NULL);
+ g_markup_parse_context_free (context);
+ if (!result) {
+ dbg(lvl_error, "FATAL: Cannot parse data as XML: '%s'", document);
+ return 0;
+ }
#else
- char *str=g_strdup(document);
- ezxml_t root = ezxml_parse_str(str, strlen(str));
- if (!root)
- return;
- parse_node_text(root, data, start, end, text);
- ezxml_free(root);
- g_free(str);
+ char *str=g_strdup(document);
+ ezxml_t root = ezxml_parse_str(str, strlen(str));
+ if (!root)
+ return 0;
+ parse_node_text(root, data, start, end, text);
+ ezxml_free(root);
+ g_free(str);
#endif
+ return 1;
}
#if !USE_EZXML
static const GMarkupParser parser = {
- xi_start_element,
- xi_end_element,
- xi_text,
- NULL,
- NULL
+ xi_start_element,
+ xi_end_element,
+ xi_text,
+ NULL,
+ NULL
};
/**
* * Parse the contents of the configuration file
@@ -1112,99 +1159,93 @@ static const GMarkupParser parser = {
* * @returns boolean TRUE or FALSE
* */
-static gboolean
-parse_file(struct xmldocument *document, xmlerror **error)
-{
- xml_context *context;
- gchar *contents, *message;
- gsize len;
- gint line, chr;
- gboolean result;
- char *xmldir,*newxmldir,*xmlfile,*newxmlfile,*sep;
-
- dbg(lvl_debug,"enter filename='%s'\n", document->href);
+static gboolean parse_file(struct xmldocument *document, xmlerror **error) {
+ xml_context *context;
+ gchar *contents, *message;
+ gsize len;
+ gint line, chr;
+ gboolean result;
+ char *xmldir,*newxmldir,*xmlfile,*newxmlfile,*sep;
+
+ dbg(lvl_debug,"enter filename='%s'", document->href);
#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 12
#define G_MARKUP_TREAT_CDATA_AS_TEXT 0
#endif
- context = g_markup_parse_context_new (&parser, G_MARKUP_TREAT_CDATA_AS_TEXT, document, NULL);
-
- if (!g_file_get_contents (document->href, &contents, &len, error)) {
- g_markup_parse_context_free (context);
- return FALSE;
- }
- xmldir=getenv("XMLDIR");
- xmlfile=getenv("XMLFILE");
- newxmlfile=g_strdup(document->href);
- newxmldir=g_strdup(document->href);
- if ((sep=strrchr(newxmldir,'/')))
- *sep='\0';
- else {
- g_free(newxmldir);
- newxmldir=g_strdup(".");
- }
- setenv("XMLDIR",newxmldir,1);
- setenv("XMLFILE",newxmlfile,1);
- document->active=document->xpointer ? 0:1;
- document->first=NULL;
- document->last=NULL;
- result = g_markup_parse_context_parse (context, contents, len, error);
- if (!result && error && *error) {
- g_markup_parse_context_get_position(context, &line, &chr);
- message=g_strdup_printf("%s at line %d, char %d\n", (*error)->message, line, chr);
- g_free((*error)->message);
- (*error)->message=message;
- }
- g_markup_parse_context_free (context);
- g_free (contents);
- if (xmldir)
- setenv("XMLDIR",xmldir,1);
- else
- unsetenv("XMLDIR");
- if (xmlfile)
- setenv("XMLFILE",xmlfile,1);
- else
- unsetenv("XMLFILE");
- g_free(newxmldir);
- g_free(newxmlfile);
- dbg(lvl_debug,"return %d\n", result);
-
- return result;
+ context = g_markup_parse_context_new (&parser, G_MARKUP_TREAT_CDATA_AS_TEXT, document, NULL);
+
+ if (!g_file_get_contents (document->href, &contents, &len, error)) {
+ g_markup_parse_context_free (context);
+ return FALSE;
+ }
+ xmldir=getenv("XMLDIR");
+ xmlfile=getenv("XMLFILE");
+ newxmlfile=g_strdup(document->href);
+ newxmldir=g_strdup(document->href);
+ if ((sep=strrchr(newxmldir,'/')))
+ *sep='\0';
+ else {
+ g_free(newxmldir);
+ newxmldir=g_strdup(".");
+ }
+ setenv("XMLDIR",newxmldir,1);
+ setenv("XMLFILE",newxmlfile,1);
+ document->active=document->xpointer ? 0:1;
+ document->first=NULL;
+ document->last=NULL;
+ result = g_markup_parse_context_parse (context, contents, len, error);
+ if (!result && error && *error) {
+ g_markup_parse_context_get_position(context, &line, &chr);
+ message=g_strdup_printf("%s at line %d, char %d\n", (*error)->message, line, chr);
+ g_free((*error)->message);
+ (*error)->message=message;
+ }
+ g_markup_parse_context_free (context);
+ g_free (contents);
+ if (xmldir)
+ setenv("XMLDIR",xmldir,1);
+ else
+ unsetenv("XMLDIR");
+ if (xmlfile)
+ setenv("XMLFILE",xmlfile,1);
+ else
+ unsetenv("XMLFILE");
+ g_free(newxmldir);
+ g_free(newxmlfile);
+ dbg(lvl_debug,"return %d", result);
+
+ return result;
}
#else
-static void
-parse_node(struct xmldocument *document, ezxml_t node)
-{
- while (node) {
- xi_start_element(NULL,node->name, node->attr, node->attr+1, document, NULL);
- if (node->txt)
- xi_text(NULL,node->txt,strlen(node->txt),document,NULL);
- if (node->child)
- parse_node(document, node->child);
- xi_end_element (NULL,node->name,document,NULL);
- node=node->ordered;
- }
+static void parse_node(struct xmldocument *document, ezxml_t node) {
+ while (node) {
+ xi_start_element(NULL,node->name, node->attr, node->attr+1, document, NULL);
+ if (node->txt)
+ xi_text(NULL,node->txt,strlen(node->txt),document,NULL);
+ if (node->child)
+ parse_node(document, node->child);
+ xi_end_element (NULL,node->name,document,NULL);
+ node=node->ordered;
+ }
}
-static gboolean
-parse_file(struct xmldocument *document, xmlerror **error)
-{
- FILE *f;
- ezxml_t root;
-
- f=fopen(document->href,"rb");
- if (!f)
- return FALSE;
- root = ezxml_parse_fp(f);
- fclose(f);
- if (!root)
- return FALSE;
- document->active=document->xpointer ? 0:1;
- document->first=NULL;
- document->last=NULL;
-
- parse_node(document, root);
-
- return TRUE;
+static gboolean parse_file(struct xmldocument *document, xmlerror **error) {
+ FILE *f;
+ ezxml_t root;
+
+ f=fopen(document->href,"rb");
+ if (!f)
+ return FALSE;
+ root = ezxml_parse_fp(f);
+ fclose(f);
+ if (!root)
+ return FALSE;
+ document->active=document->xpointer ? 0:1;
+ document->first=NULL;
+ document->last=NULL;
+
+ parse_node(document, root);
+
+ return TRUE;
}
#endif
@@ -1216,90 +1257,80 @@ parse_file(struct xmldocument *document, xmlerror **error)
* * @returns boolean TRUE or FALSE (if error detected)
* */
-gboolean config_load(const char *filename, xmlerror **error)
-{
- struct xmldocument document;
- struct xmlstate *curr=NULL;
- gboolean result;
-
- attr_create_hash();
- item_create_hash();
- initStatic();
-
- dbg(lvl_debug,"enter filename='%s'\n", filename);
- memset(&document, 0, sizeof(document));
- document.href=filename;
- document.user_data=&curr;
- result=parse_file(&document, error);
- if (result && curr) {
- g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_PARSE, "element '%s' not closed", curr->element);
- result=FALSE;
- }
- attr_destroy_hash();
- item_destroy_hash();
- dbg(lvl_debug,"return %d\n", result);
- return result;
+gboolean config_load(const char *filename, xmlerror **error) {
+ struct xmldocument document;
+ struct xmlstate *curr=NULL;
+ gboolean result;
+
+ attr_create_hash();
+ item_create_hash();
+ initStatic();
+
+ dbg(lvl_debug,"enter filename='%s'", filename);
+ memset(&document, 0, sizeof(document));
+ document.href=filename;
+ document.user_data=&curr;
+ result=parse_file(&document, error);
+ if (result && curr) {
+ g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_PARSE, "element '%s' not closed", curr->element);
+ result=FALSE;
+ }
+ attr_destroy_hash();
+ item_destroy_hash();
+ dbg(lvl_debug,"return %d", result);
+ return result;
}
-int
-navit_object_set_methods(void *in, int in_size, void *out, int out_size)
-{
- int ret,size=out_size;
- if (out_size > in_size) {
- ret=-1;
- size=in_size;
- memset((char *)out+in_size, 0, out_size-in_size);
- } else if (in_size == out_size)
- ret=0;
- else
- ret=1;
- memcpy(out, in, size);
- return ret;
+int navit_object_set_methods(void *in, int in_size, void *out, int out_size) {
+ int ret,size=out_size;
+ if (out_size > in_size) {
+ ret=-1;
+ size=in_size;
+ memset((char *)out+in_size, 0, out_size-in_size);
+ } else if (in_size == out_size)
+ ret=0;
+ else
+ ret=1;
+ memcpy(out, in, size);
+ return ret;
}
struct navit_object *
-navit_object_new(struct attr **attrs, struct object_func *func, int size)
-{
- struct navit_object *ret=g_malloc0(size);
- ret->func=func;
- ret->attrs=attr_list_dup(attrs);
- navit_object_ref(ret);
- return ret;
+navit_object_new(struct attr **attrs, struct object_func *func, int size) {
+ struct navit_object *ret=g_malloc0(size);
+ ret->func=func;
+ ret->attrs=attr_list_dup(attrs);
+ navit_object_ref(ret);
+ return ret;
}
struct navit_object *
-navit_object_ref(struct navit_object *obj)
-{
- obj->refcount++;
- dbg(lvl_debug,"refcount %s %p %d\n",attr_to_name(obj->func->type),obj,obj->refcount);
- return obj;
+navit_object_ref(struct navit_object *obj) {
+ obj->refcount++;
+ dbg(lvl_debug,"refcount %s %p %d",attr_to_name(obj->func->type),obj,obj->refcount);
+ return obj;
}
-void
-navit_object_unref(struct navit_object *obj)
-{
- if (obj) {
- obj->refcount--;
- dbg(lvl_debug,"refcount %s %p %d\n",attr_to_name(obj->func->type),obj,obj->refcount);
- if (obj->refcount <= 0 && obj->func && obj->func->destroy)
- obj->func->destroy(obj);
- }
+void navit_object_unref(struct navit_object *obj) {
+ if (obj) {
+ obj->refcount--;
+ dbg(lvl_debug,"refcount %s %p %d",attr_to_name(obj->func->type),obj,obj->refcount);
+ if (obj->refcount <= 0 && obj->func && obj->func->destroy)
+ obj->func->destroy(obj);
+ }
}
struct attr_iter {
- void *last;
+ void *last;
};
struct attr_iter *
-navit_object_attr_iter_new(void)
-{
- return g_new0(struct attr_iter, 1);
+navit_object_attr_iter_new(void) {
+ return g_new0(struct attr_iter, 1);
}
-void
-navit_object_attr_iter_destroy(struct attr_iter *iter)
-{
- g_free(iter);
+void navit_object_attr_iter_destroy(struct attr_iter *iter) {
+ g_free(iter);
}
/**
@@ -1327,71 +1358,59 @@ navit_object_attr_iter_destroy(struct attr_iter *iter)
*
* @return True if a matching attribute was found, false if not.
*/
-int
-navit_object_get_attr(struct navit_object *obj, enum attr_type type, struct attr *attr, struct attr_iter *iter)
-{
- return attr_generic_get_attr(obj->attrs, NULL, type, attr, iter);
+int navit_object_get_attr(struct navit_object *obj, enum attr_type type, struct attr *attr, struct attr_iter *iter) {
+ return attr_generic_get_attr(obj->attrs, NULL, type, attr, iter);
}
-void
-navit_object_callbacks(struct navit_object *obj, struct attr *attr)
-{
- if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list)
- callback_list_call_attr_2(obj->attrs[0]->u.callback_list, attr->type, attr->u.data, 0);
+void navit_object_callbacks(struct navit_object *obj, struct attr *attr) {
+ if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list)
+ callback_list_call_attr_2(obj->attrs[0]->u.callback_list, attr->type, attr->u.data, 0);
}
-int
-navit_object_set_attr(struct navit_object *obj, struct attr *attr)
-{
- dbg(lvl_debug, "enter, obj=%p, attr=%p (%s)\n", obj, attr, attr_to_name(attr->type));
- obj->attrs=attr_generic_set_attr(obj->attrs, attr);
- navit_object_callbacks(obj, attr);
- return 1;
+int navit_object_set_attr(struct navit_object *obj, struct attr *attr) {
+ dbg(lvl_debug, "enter, obj=%p, attr=%p (%s)", obj, attr, attr_to_name(attr->type));
+ obj->attrs=attr_generic_set_attr(obj->attrs, attr);
+ navit_object_callbacks(obj, attr);
+ return 1;
}
-int
-navit_object_add_attr(struct navit_object *obj, struct attr *attr)
-{
- dbg(lvl_debug, "enter, obj=%p, attr=%p (%s)\n", obj, attr, attr_to_name(attr->type));
- if (attr->type == attr_callback) {
- struct callback_list *cbl;
- if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list)
- cbl=obj->attrs[0]->u.callback_list;
- else {
- struct attr attr;
- cbl=callback_list_new();
- attr.type=attr_callback_list;
- attr.u.callback_list=cbl;
- obj->attrs=attr_generic_prepend_attr(obj->attrs, &attr);
- }
- callback_list_add(cbl, attr->u.callback);
- return 1;
- }
- obj->attrs=attr_generic_add_attr(obj->attrs, attr);
- if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list)
- callback_list_call_attr_2(obj->attrs[0]->u.callback_list, attr->type, attr->u.data, 1);
- return 1;
+int navit_object_add_attr(struct navit_object *obj, struct attr *attr) {
+ dbg(lvl_debug, "enter, obj=%p, attr=%p (%s)", obj, attr, attr_to_name(attr->type));
+ if (attr->type == attr_callback) {
+ struct callback_list *cbl;
+ if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list)
+ cbl=obj->attrs[0]->u.callback_list;
+ else {
+ struct attr attr;
+ cbl=callback_list_new();
+ attr.type=attr_callback_list;
+ attr.u.callback_list=cbl;
+ obj->attrs=attr_generic_prepend_attr(obj->attrs, &attr);
+ }
+ callback_list_add(cbl, attr->u.callback);
+ return 1;
+ }
+ obj->attrs=attr_generic_add_attr(obj->attrs, attr);
+ if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list)
+ callback_list_call_attr_2(obj->attrs[0]->u.callback_list, attr->type, attr->u.data, 1);
+ return 1;
}
-int
-navit_object_remove_attr(struct navit_object *obj, struct attr *attr)
-{
- if (attr->type == attr_callback) {
- if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list) {
- callback_list_remove(obj->attrs[0]->u.callback_list, attr->u.callback);
- return 1;
- } else
- return 0;
- }
- obj->attrs=attr_generic_remove_attr(obj->attrs, attr);
- if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list)
- callback_list_call_attr_2(obj->attrs[0]->u.callback_list, attr->type, attr->u.data, -1);
- return 1;
+int navit_object_remove_attr(struct navit_object *obj, struct attr *attr) {
+ if (attr->type == attr_callback) {
+ if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list) {
+ callback_list_remove(obj->attrs[0]->u.callback_list, attr->u.callback);
+ return 1;
+ } else
+ return 0;
+ }
+ obj->attrs=attr_generic_remove_attr(obj->attrs, attr);
+ if (obj->attrs && obj->attrs[0] && obj->attrs[0]->type == attr_callback_list)
+ callback_list_call_attr_2(obj->attrs[0]->u.callback_list, attr->type, attr->u.data, -1);
+ return 1;
}
-void
-navit_object_destroy(struct navit_object *obj)
-{
- attr_list_free(obj->attrs);
- g_free(obj);
+void navit_object_destroy(struct navit_object *obj) {
+ attr_list_free(obj->attrs);
+ g_free(obj);
}
diff --git a/navit/xmlconfig.h b/navit/xmlconfig.h
index dd24253bc..d1c544a3f 100644
--- a/navit/xmlconfig.h
+++ b/navit/xmlconfig.h
@@ -65,23 +65,54 @@ typedef void *(*object_func_ref)(void *);
typedef void *(*object_func_unref)(void *);
+/**
+ * @brief Basic functions for Navit objects
+ *
+ * This is the minimal list of functions which is supported by every Navit object.
+ *
+ * Some members can be NULL for certain object types: while Navit does not mandate this function to be
+ * implemented for every object class, the function may need to be defined for some object classes.
+ *
+ * Default implementations are available for every function in the list except `create`, `init` and
+ * `dup`. These can be set directly, or type-specific implementations can call through to them as they
+ * see fit.
+ */
struct object_func {
- enum attr_type type;
- void *(*create)(struct attr *parent, struct attr **attrs);
- int (*get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter);
- struct attr_iter *(*iter_new)(void *);
- void (*iter_destroy)(struct attr_iter *);
- int (*set_attr)(void *, struct attr *attr);
- int (*add_attr)(void *, struct attr *attr);
- int (*remove_attr)(void *, struct attr *attr);
- int (*init)(void *);
- void (*destroy)(void *);
- void *(*dup)(void *);
- void *(*ref)(void *);
- void *(*unref)(void *);
+ enum attr_type type; /**< The object type */
+ void *(*create)(struct attr *parent, struct attr **attrs); /**< Function to create a new object instance */
+ int (*get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter); /**< Function
+ * to get an attribute of the object,
+ * set to `navit_object_get_attr` for default behavior */
+ struct attr_iter *(*iter_new)(void *); /**< Function to obtain a new attribute iterator,
+ * set to `navit_object_attr_iter_new` for default
+ * behavior, can be NULL for some object types */
+ void (*iter_destroy)(struct attr_iter *); /**< Function to destroy an attribute iterator,
+ * set to `navit_object_attr_iter_destroy` for default
+ * behavior, can be NULL for some object types */
+ int (*set_attr)(void *, struct attr *attr); /**< Function to set an attribute,
+ * set to `navit_object_set_attr` for default behavior,
+ * can be NULL for some object types */
+ int (*add_attr)(void *, struct attr *attr); /**< Function to add an attribute,
+ * set to `navit_object_add_attr` for default behavior,
+ * can be NULL for some object types */
+ int (*remove_attr)(void *, struct attr *attr); /**< Function to remove an attribute,
+ * set to `navit_object_remove_attr` for default behavior,
+ * can be NULL for some object types */
+ int (*init)(void *); /**< TODO,
+ * can be NULL for some object types */
+ void (*destroy)(void *); /**< Function to destroy an object instance,
+ * set to `navit_object_destroy` for default behavior,
+ * can be NULL */
+ void *(*dup)(void *); /**< Function to create a copy of an object instance */
+ void *(*ref)(void *); /**< Function to increase the reference count for an
+ * object instance, set to `navit_object_ref` for
+ * default behavior, can be NULL for some object types */
+ void *(*unref)(void *); /**< Function to decrease the reference count for an
+ * object instance, set to `navit_object_unref` for
+ * default behavior, can be NULL for some object types */
};
-extern struct object_func map_func, mapset_func, navit_func, osd_func, tracking_func, vehicle_func, maps_func, layout_func, roadprofile_func, vehicleprofile_func, layer_func, config_func, profile_option_func, script_func, log_func, speech_func, navigation_func, route_func, audio_func;
+extern struct object_func map_func, mapset_func, navit_func, osd_func, tracking_func, vehicle_func, maps_func, layout_func, roadprofile_func, vehicleprofile_func, layer_func, config_func, profile_option_func, script_func, log_func, speech_func, navigation_func, route_func, traffic_func, audio_func;
#define HAS_OBJECT_FUNC(x) ((x) == attr_map || (x) == attr_mapset || (x) == attr_navit || (x) == attr_osd || (x) == attr_trackingo || (x) == attr_vehicle || (x) == attr_maps || (x) == attr_layout || (x) == attr_roadprofile || (x) == attr_vehicleprofile || (x) == attr_layer || (x) == attr_config || (x) == attr_profile_option || (x) == attr_script || (x) == attr_log || (x) == attr_speech || (x) == attr_navigation || (x) == attr_route)
@@ -108,7 +139,11 @@ typedef GError xmlerror;
/* prototypes */
enum attr_type;
struct object_func *object_func_lookup(enum attr_type type);
-void xml_parse_text(const char *document, void *data, void (*start)(xml_context *, const char *, const char **, const char **, void *, GError **), void (*end)(xml_context *, const char *, void *, GError **), void (*text)(xml_context*, const char *, gsize, void *, GError **));
+int xml_parse_file(char *filename, void *data,
+ void (*start)(xml_context *, const char *, const char **, const char **, void *, GError **),
+ void (*end)(xml_context *, const char *, void *, GError **),
+ void (*text)(xml_context *, const char *, gsize, void *, GError **));
+int xml_parse_text(const char *document, void *data, void (*start)(xml_context *, const char *, const char **, const char **, void *, GError **), void (*end)(xml_context *, const char *, void *, GError **), void (*text)(xml_context*, const char *, gsize, void *, GError **));
gboolean config_load(const char *filename, xmlerror **error);
//static void xinclude(GMarkupParseContext *context, const gchar **attribute_names, const gchar **attribute_values, struct xmldocument *doc_old, xmlerror **error);
diff --git a/navit/xslt/android.xslt b/navit/xslt/android.xslt
index 68e731be0..3a1fdaf02 100644
--- a/navit/xslt/android.xslt
+++ b/navit/xslt/android.xslt
@@ -44,6 +44,9 @@
&lt;img src=''gui_rules'' onclick=''navit.graphics.set_map_location();''>&lt;text>Set map location&lt;/text>&lt;/img>
&lt;img src=''gui_rules'' onclick=''navit.graphics.backup_restore_dialog();''>&lt;text>Backup / Restore&lt;/text>&lt;/img>')"/>
</xsl:template>
+ <xsl:template match="/config/navit/traffic">
+ <traffic type="traff_android"/>
+ </xsl:template>
<xsl:template match="/config/navit[1]">
<xsl:copy>
@@ -68,7 +71,7 @@
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
- <xsl:template match="/config/navit/layout/layer/itemgra/child::*">
+ <xsl:template match="/config/navit/layout/layer/itemgra/child::*|/config/navit/layer/itemgra/child::*|layout/layer/itemgra/child::*">
<xsl:copy>
<xsl:copy-of select="@*[not(name()='text_size') and not(name()='width') and not(name()='radius') and not(name()='w') and not(name()='h') and not(name()='x') and not(name()='y') and not(name()='dash')]"/>
<xsl:if test="@text_size">
@@ -110,7 +113,7 @@
</xsl:if>
</xsl:copy>
</xsl:template>
- <xsl:template match="/config/navit/layout">
+ <xsl:template match="/config/navit/layout|/layout">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:if test="@name='Car'">
diff --git a/navit/xslt/iphone.xslt b/navit/xslt/iphone.xslt
index 1e9540503..d5a403bb9 100644
--- a/navit/xslt/iphone.xslt
+++ b/navit/xslt/iphone.xslt
@@ -5,7 +5,7 @@
<xsl:param name="ICON_MEDIUM" select="32"/>
<xsl:param name="ICON_BIG" select="64"/>
<xsl:param name="OSD_USE_OVERLAY">yes</xsl:param>
-
+
<xsl:output method="xml" doctype-system="navit.dtd" cdata-section-elements="gui"/>
<xsl:include href="osd_minimum.xslt"/>
<xsl:template match="/config/navit/graphics">
diff --git a/navit/xslt/openmoko.xslt b/navit/xslt/openmoko.xslt
index 2de3c0aab..dae507c90 100644
--- a/navit/xslt/openmoko.xslt
+++ b/navit/xslt/openmoko.xslt
@@ -1,7 +1,13 @@
<?xml version="1.0"?>
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xsl:param name="OSD_SIZE" select="2"/>
+ <xsl:param name="ICON_SMALL" select="48"/>
+ <xsl:param name="ICON_MEDIUM" select="48"/>
+ <xsl:param name="ICON_BIG" select="96"/>
+ <xsl:param name="OSD_USE_OVERLAY">yes</xsl:param>
+
<xsl:output method="xml" doctype-system="navit.dtd" cdata-section-elements="gui"/>
<xsl:include href="navit_drag_bitmap.xslt"/>
- <xsl:include href="osd_enable_zoom.xslt"/>
+ <xsl:include href="osd_minimum.xslt"/>
<xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:template>
</xsl:transform>
diff --git a/navit/xslt/osd_android.xslt b/navit/xslt/osd_android.xslt
index a15d4f34d..96dce2449 100644
--- a/navit/xslt/osd_android.xslt
+++ b/navit/xslt/osd_android.xslt
@@ -3,6 +3,6 @@
<xsl:template match="/config/navit/osd[last()]">
<xsl:copy><xsl:copy-of select="@*|node()"/></xsl:copy>
<xsl:text>&#x0A; </xsl:text>
- <osd type="button" src="gui_android_menu_{number($ICON_BIG)}_{number($ICON_BIG)}.png" command="graphics.menu()" x="{round(-60*number($OSD_SIZE))}" y="{round(48*number($OSD_SIZE))}" enable_expression="!has_menu_button" use_overlay="yes"/>
+ <osd type="button" src="gui_android_menu" command="graphics.menu()" x="{round(-(number($ICON_BIG)+8*number($OSD_SIZE)))}" y="{round(62*number($OSD_SIZE))}" w="{round(number($ICON_MEDIUM))}" h="{round(number($ICON_MEDIUM))}" enable_expression="!has_menu_button" use_overlay="yes"/>
</xsl:template>
</xsl:transform>
diff --git a/navit/xslt/osd_minimum.xslt b/navit/xslt/osd_minimum.xslt
index 5c9c8a0b3..b0e310aae 100644
--- a/navit/xslt/osd_minimum.xslt
+++ b/navit/xslt/osd_minimum.xslt
@@ -4,28 +4,36 @@
<xsl:param name="NEXT_TURN_SIZE"><xsl:value-of select="round(12*number($OSD_SIZE)+number($ICON_BIG))"/></xsl:param>
<xsl:param name="NEXT_TURN_TEXT_HIGHT"><xsl:value-of select="round(20*number($OSD_SIZE))"/></xsl:param>
<xsl:param name="OSD_USE_OVERLAY"><xsl:value-of select="$OSD_USE_OVERLAY='yes' or $OSD_USE_OVERLAY='true' or $OSD_USE_OVERLAY='1'"/></xsl:param>
-
- <osd type="compass" enabled="yes" x="{round(-60*number($OSD_SIZE))}" y="{round(-80*number($OSD_SIZE))}" w="{round(60*number($OSD_SIZE))}" h="{round(80*number($OSD_SIZE))}" font_size="{round(200*number($OSD_SIZE))}" enable_expression="vehicle.position_valid"/>
+
+ <osd type="text" label="${{navigation.item[1].name}}" x="0" y="0" w="100%" h="{round(14*number($OSD_SIZE))}" font_size="{round(200*number($OSD_SIZE))}" enable_expression="navigation.nav_status&gt;=3"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="text" label="${{navigation.item.destination_length[named]}}\n${{navigation.item.destination_time[arrival]}}" x="{round(-60*number($OSD_SIZE))}" y="0" w="{round(60*number($OSD_SIZE))}" h="{round(40*number($OSD_SIZE))}" font_size="{round(200*number($OSD_SIZE))}" enable_expression="navigation.nav_status>=3"/>
+ <osd type="compass" enabled="yes" x="{round(-60*number($OSD_SIZE))}" y="{round(-94*number($OSD_SIZE))}" w="{round(60*number($OSD_SIZE))}" h="{round(80*number($OSD_SIZE))}" font_size="{round(200*number($OSD_SIZE))}" enable_expression="vehicle.position_valid"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="navigation_status" x="0" y="{-($NEXT_TURN_SIZE+$NEXT_TURN_TEXT_HIGHT)}" w="{$NEXT_TURN_SIZE+$NEXT_TURN_TEXT_HIGHT}" h="{$NEXT_TURN_SIZE+$NEXT_TURN_TEXT_HIGHT}" icon_src="%s_wh_{$ICON_BIG}_{$ICON_BIG}.png" enable_expression="navigation.nav_status==-1 || navigation.nav_status==1 || navigation.nav_status==2"/>
+ <osd type="text" label="${{navigation.item.destination_length[named]}}\n${{navigation.item.destination_time[arrival]}}" x="{round(-60*number($OSD_SIZE))}" y="{round(14*number($OSD_SIZE))}" w="{round(60*number($OSD_SIZE))}" h="{round(40*number($OSD_SIZE))}" font_size="{round(200*number($OSD_SIZE))}" enable_expression="navigation.nav_status>=3"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="navigation_next_turn" x="0" y="{-($NEXT_TURN_SIZE+$NEXT_TURN_TEXT_HIGHT)}" w="{$NEXT_TURN_SIZE+$NEXT_TURN_TEXT_HIGHT}" h="{$NEXT_TURN_SIZE}" icon_src="%s_wh_{$ICON_BIG}_{$ICON_BIG}.png" enable_expression="navigation.nav_status>=3"/>
+ <osd type="navigation_status" x="0" y="0" w="{$NEXT_TURN_SIZE}" h="{$NEXT_TURN_SIZE}" icon_w="{round(number($ICON_BIG))}" icon_h="{round(number($ICON_BIG))}" icon_src="%s_wh" enable_expression="navigation.nav_status==-1 || navigation.nav_status==1 || navigation.nav_status==2"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="text" label="${{navigation.item[1].length[named]}}" x="0" y="{-$NEXT_TURN_TEXT_HIGHT}" w="{$NEXT_TURN_SIZE+$NEXT_TURN_TEXT_HIGHT}" h="{$NEXT_TURN_TEXT_HIGHT}" font_size="{round(200*number($OSD_SIZE))}" enable_expression="navigation.nav_status>=3"/>
+ <osd type="navigation_next_turn" x="0" y="{round(14*number($OSD_SIZE))}" w="{$NEXT_TURN_SIZE}" h="{$NEXT_TURN_SIZE}" icon_w="{round(number($ICON_BIG))}" icon_h="{round(number($ICON_BIG))}" icon_src="%s_wh" enable_expression="navigation.nav_status>=3"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="button" src="gui_zoom_manual_{number($ICON_BIG)}_{number($ICON_BIG)}.png" command="autozoom_active=0" x="0" y="0" osd_configuration="1" use_overlay="{$OSD_USE_OVERLAY}" enable_expression="autozoom_active!=0"/>
+ <osd type="text" label="${{navigation.item[1].length[value]}}" x="0" y="{round(14*number($OSD_SIZE))+$NEXT_TURN_SIZE}" w="{$NEXT_TURN_SIZE}" h="{$NEXT_TURN_TEXT_HIGHT}" font_size="{round(260*number($OSD_SIZE))}" enable_expression="navigation.nav_status>=3"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="button" src="gui_zoom_auto_{number($ICON_BIG)}_{number($ICON_BIG)}.png" command="autozoom_active=1" x="0" y="0" osd_configuration="1" use_overlay="{$OSD_USE_OVERLAY}" enable_expression="autozoom_active==0"/>
+ <osd type="text" label="${{navigation.item[1].length[unit]}}" x="0" y="{round(14*number($OSD_SIZE))+$NEXT_TURN_SIZE+$NEXT_TURN_TEXT_HIGHT}" w="{$NEXT_TURN_SIZE}" h="{$NEXT_TURN_TEXT_HIGHT}" font_size="{round(200*number($OSD_SIZE))}" enable_expression="navigation.nav_status>=3"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="button" src="gui_zoom_in_{number($ICON_BIG)}_{number($ICON_BIG)}.png" command="zoom_in()" x="0" y="{round(number($ICON_BIG)+8*number($OSD_SIZE))}" osd_configuration="1" use_overlay="{$OSD_USE_OVERLAY}"/>
+ <osd type="text" label="${{tracking.item.street_name}} ${{tracking.item.street_name_systematic}}" x="0" y="{round(-14*number($OSD_SIZE))}" w="100%" h="{round(14*number($OSD_SIZE))}" font_size="{round(200*number($OSD_SIZE))}" enable_expression="vehicle.position_valid"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="button" src="gui_zoom_out_{number($ICON_BIG)}_{number($ICON_BIG)}.png" command="zoom_out()" x="0" y="{round(2*(number($ICON_BIG)+8*number($OSD_SIZE)))}" osd_configuration="1" use_overlay="{$OSD_USE_OVERLAY}"/>
+ <osd type="toggle_announcer" icon_src="%s" x="{round(-(number($ICON_MEDIUM)+8*number($OSD_SIZE)))}" y="{round(-(number($ICON_MEDIUM)+8*number($OSD_SIZE))-94*number($OSD_SIZE))}" w="{round(number($ICON_MEDIUM))}" h="{round(number($ICON_MEDIUM))}"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="cmd_interface" update_period="1" command="pitch=autozoom_active==0?pitch:(follow>1?0:20);orientation=autozoom_active==0?orientation:(follow>1?0:-1)" x="-1" y="-1" w="1" h="1"/>
+ <osd type="button" src="zoom_manual" command="autozoom_active=0" x="{round(8*number($OSD_SIZE))}" y="{-round(number($ICON_MEDIUM)+22*number($OSD_SIZE))}" w="{round(number($ICON_MEDIUM))}" h="{round(number($ICON_MEDIUM))}" osd_configuration="1" use_overlay="{$OSD_USE_OVERLAY}" enable_expression="autozoom_active!=0"/>
+ <xsl:text>&#x0A; </xsl:text>
+ <osd type="button" src="zoom_auto" command="autozoom_active=1" x="{round(8*number($OSD_SIZE))}" y="{-round(number($ICON_MEDIUM)+22*number($OSD_SIZE))}" w="{round(number($ICON_MEDIUM))}" h="{round(number($ICON_MEDIUM))}" osd_configuration="1" use_overlay="{$OSD_USE_OVERLAY}" enable_expression="autozoom_active==0"/>
+ <xsl:text>&#x0A; </xsl:text>
+ <osd type="button" src="zoom_in" command="zoom_in()" x="{round((number($ICON_MEDIUM)+8*number($OSD_SIZE))+8*number($OSD_SIZE))}" y="{-round(number($ICON_MEDIUM)+22*number($OSD_SIZE))}" w="{round(number($ICON_MEDIUM))}" h="{round(number($ICON_MEDIUM))}" osd_configuration="1" use_overlay="{$OSD_USE_OVERLAY}"/>
<xsl:text>&#x0A; </xsl:text>
- <osd type="button" src="cursor_{number($ICON_BIG)}_{number($ICON_BIG)}.png" command="follow=0;set_center_cursor()" x="{round(number($ICON_BIG)+8*number($OSD_SIZE))}" y="0" enable_expression="follow>1" use_overlay="{$OSD_USE_OVERLAY}"/>
+ <osd type="button" src="zoom_out" command="zoom_out()" x="{round(2*(number($ICON_MEDIUM)+8*number($OSD_SIZE))+8*number($OSD_SIZE))}" y="{-round(number($ICON_MEDIUM)+22*number($OSD_SIZE))}" w="{round(number($ICON_MEDIUM))}" h="{round(number($ICON_MEDIUM))}" osd_configuration="1" use_overlay="{$OSD_USE_OVERLAY}"/>
+ <xsl:text>&#x0A; </xsl:text>
+ <osd type="button" src="follow" command="follow=0;set_center_cursor()" x="{round(8*number($OSD_SIZE))}" y="{round(-2*(number($ICON_MEDIUM)+8*number($OSD_SIZE))-14*number($OSD_SIZE))}" w="{round(number($ICON_MEDIUM))}" h="{round(number($ICON_MEDIUM))}" enable_expression="follow>1" use_overlay="{$OSD_USE_OVERLAY}"/>
+ <xsl:text>&#x0A; </xsl:text>
+ <osd type="cmd_interface" update_period="1" command="pitch=autozoom_active==0?pitch:(follow>1?0:20);orientation=autozoom_active==0?orientation:(follow>1?0:-1)" x="-1" y="-1" w="1" h="1"/>
<xsl:text>&#x0A; </xsl:text>
<xsl:copy><xsl:copy-of select="@*|node()"/></xsl:copy>
</xsl:template>
diff --git a/navit/xslt/sailfish_osd.xslt b/navit/xslt/sailfish_osd.xslt
index ca9925a49..fc2244d97 100644
--- a/navit/xslt/sailfish_osd.xslt
+++ b/navit/xslt/sailfish_osd.xslt
@@ -2,8 +2,14 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xsl:param name="OSD_SIZE" select="2"/>
+ <xsl:param name="ICON_SMALL" select="32"/>
+ <xsl:param name="ICON_MEDIUM" select="64"/>
+ <xsl:param name="ICON_BIG" select="96"/>
+ <xsl:param name="OSD_USE_OVERLAY">yes</xsl:param>
<xsl:output method="xml" indent="yes" cdata-section-elements="gui" doctype-system="navit.dtd"/>
+ <xsl:include href="osd_minimum.xslt"/>
<!-- Default rule: copy all -->
<xsl:template match="node()|@*">
@@ -12,27 +18,4 @@
</xsl:copy>
</xsl:template>
- <xsl:template match="/config/navit/osd[1]">
- <osd enabled="yes" type="gps_status" x="0" y="0" w="50" h="50"/>
- <xsl:text>&#x0A; </xsl:text>
- <osd enabled="no" type="text" label="${{vehicle.position_sats_used}}/${{vehicle.position_qual}}" x="0" y="0" w="50" h="50" background_color="#00000058" font_size="400"/>
- <xsl:text>&#x0A; </xsl:text>
- <osd enabled="yes" type="text" label="${{vehicle.position_speed}}" x="50" y="0" w="150" h="50" background_color="#00000058" font_size="400"/>
- <xsl:text>&#x0A; </xsl:text>
- <osd enabled="yes" type="text" label="${{navigation.item.destination_length[named]}}" x="200" y="0" w="240" h="50" background_color="#00000058" font_size="400"/>
- <xsl:text>&#x0A; </xsl:text>
- <osd enabled="yes" type="navigation_next_turn" x="-100" y="0" w="100" h="100" icon_w="90" icon_h="80" background_color="#00000058"/>
- <xsl:text>&#x0A; </xsl:text>
- <osd enabled="yes" type="button" x="-96" y="-96" w="96" h="96" command="zoom_in()" src="zoom_in" use_overlay="true"/>
- <xsl:text>&#x0A; </xsl:text>
- <osd enabled="yes" type="text" label="${{navigation.item[1].length[named]}}" x="-100" y="100" w="100" h="50" background_color="#00000058" font_size="400"/>
- <xsl:text>&#x0A; </xsl:text>
- <osd enabled="yes" type="button" x="0" y="-96" w="96" h="96" command="zoom_out()" src="zoom_out" use_overlay="true"/>
- <xsl:text>&#x0A; </xsl:text>
- <xsl:copy>
- <xsl:apply-templates select="@*"/>
- <xsl:apply-templates select="node()"/>
- </xsl:copy>
- </xsl:template>
-
</xsl:stylesheet>
diff --git a/navit/xslt/speech_win32.xslt b/navit/xslt/speech_win32.xslt
new file mode 100644
index 000000000..12459fbf7
--- /dev/null
+++ b/navit/xslt/speech_win32.xslt
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xsl:template match="/config/navit/speech">
+ <speech type="cmdline" data="PowerShell -Command &quot;Add-Type –AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak(%s);&quot;"/>
+ </xsl:template>
+</xsl:transform>
diff --git a/navit/xslt/tomtom.xslt b/navit/xslt/tomtom.xslt
index 3e34d9224..dac69f3d3 100644
--- a/navit/xslt/tomtom.xslt
+++ b/navit/xslt/tomtom.xslt
@@ -1,7 +1,13 @@
<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude" version="1.0">
+ <xsl:param name="OSD_SIZE" select="1"/>
+ <xsl:param name="ICON_SMALL" select="24"/>
+ <xsl:param name="ICON_MEDIUM" select="24"/>
+ <xsl:param name="ICON_BIG" select="48"/>
+ <xsl:param name="OSD_USE_OVERLAY">yes</xsl:param>
<xsl:output method="xml" indent="yes" cdata-section-elements="gui" doctype-system="navit.dtd"/>
+ <xsl:include href="osd_minimum.xslt"/>
<xsl:template match="/">
<xsl:apply-templates select="config"/>
@@ -11,7 +17,7 @@
<xsl:copy>
<xsl:apply-templates select="navit"/>
</xsl:copy>
- </xsl:template>
+ </xsl:template>
<xsl:template match="navit">
<xsl:copy>
@@ -22,30 +28,19 @@
<xsl:attribute name="recent_dest">25</xsl:attribute>
<graphics type="sdl" w="480" h="272" bpp="16" frame="0" flags="1"/>
<xsl:copy-of select="gui[@type='internal']"/>
- <osd enabled="yes" type="text" x="80" y="0" w="320" h="40" font_size="360" align="0" label="${{tracking.item.street_name}} ${{tracking.item.street_name_systematic}}" background_color="#00008080"/>
- <osd enabled="yes" type="text" x="80" y="232" w="80" h="40" font_size="360" align="0" label="${{navigation.item[1].length[named]}}" background_color="#00008080"/>
- <osd enabled="yes" type="text" x="160" y="232" w="240" h="40" font_size="360" align="0" label="${{vehicle.position_speed}} / ${{tracking.item.route_speed}}" background_color="#00008080"/>
- <osd enabled="yes" type="text" x="400" y="232" w="80" h="40" font_size="360" align="0" label="${{navigation.item.destination_length[named]}}" background_color="#00008080"/>
- <osd enabled="yes" type="text" x="400" y="192" w="80" h="40" font_size="360" align="0" label="${{navigation.item.destination_time[arrival]}}" background_color="#00008080"/>
- <osd enabled="yes" type="compass" x="400" y="80" w="80" h="112" background_color="#00008080" font_size="300"/>
- <osd enabled="yes" type="gps_status" x="0" y="80" w="80" h="40" background_color="#00008080"/>
- <osd enabled="yes" type="speed_warner" x="0" y="120" w="80" h="72" background_color="#00008080" font_size="300"/>
- <osd enabled="yes" type="navigation_next_turn" x="0" y="192" w="80" h="80" icon_w="48" icon_h="48" icon_src="%s_wh_48_48.png" background_color="#00008080"/>
- <osd enabled="yes" type="button" x="400" y="0" command="zoom_in()" src="tomtom_plus_80_80.png"/>
- <osd enabled="yes" type="button" x="0" y="0" command="zoom_out()" src="tomtom_minus_80_80.png"/>
<vehicle name="Local GPS" profilename="car" enabled="yes" active="yes" follow="1" source="file:/var/run/gpspipe">
<!-- Navit can write a tracklog in several formats (gpx, nmea or textfile): -->
<log enabled="no" type="gpx" attr_types="position_time_iso8601,position_direction,position_speed,position_radius" data="/mnt/sdcard/navit/track_%Y%m%d-%%i.gpx" flush_size="1000" flush_time="30"/>
</vehicle>
<vehicle name="Demo" profilename="car" enabled="yes" active="no" follow="1" source="demo://" speed="100"/>
<xsl:copy-of select="tracking"/>
-
+
<xsl:copy-of select="vehicleprofile[@name='car']"/>
<xsl:copy-of select="vehicleprofile[@name='car_shortest']"/>
<xsl:copy-of select="vehicleprofile[@name='car_avoid_tolls']"/>
<xsl:copy-of select="vehicleprofile[@name='bike']"/>
<xsl:copy-of select="vehicleprofile[@name='pedestrian']"/>
-
+
<xsl:copy-of select="route"/>
<xsl:copy-of select="navigation"/>
diff --git a/navit/xslt/wince.xslt b/navit/xslt/wince.xslt
new file mode 100644
index 000000000..c5f75bf0d
--- /dev/null
+++ b/navit/xslt/wince.xslt
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xsl:param name="OSD_SIZE" select="1"/>
+ <xsl:param name="ICON_SMALL" select="24"/>
+ <xsl:param name="ICON_MEDIUM" select="24"/>
+ <xsl:param name="ICON_BIG" select="48"/>
+ <xsl:param name="OSD_USE_OVERLAY">yes</xsl:param>
+
+ <xsl:output method="xml" doctype-system="navit.dtd" cdata-section-elements="gui"/>
+ <xsl:include href="osd_minimum.xslt"/>
+ <xsl:template match="/config/navit/vehicle[@enabled='yes']">
+ <xsl:copy>
+ <xsl:copy-of select="@*[name() != 'gpsd_query']"/>
+ <xsl:attribute name="source">wince:COM2:</xsl:attribute>
+ <xsl:attribute name="baudrate">4800</xsl:attribute>
+ <xsl:apply-templates/>
+ </xsl:copy>
+ </xsl:template>
+ <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:template>
+</xsl:transform>
diff --git a/navit/xslt/windows.xslt b/navit/xslt/windows.xslt
index 989566c83..862d82ba5 100644
--- a/navit/xslt/windows.xslt
+++ b/navit/xslt/windows.xslt
@@ -3,7 +3,7 @@
<xsl:output method="xml" doctype-system="navit.dtd" cdata-section-elements="gui"/>
<xsl:include href="samplemap.xslt"/>
<xsl:include href="osd_enable_zoom.xslt"/>
- <xsl:include href="speech_espeak.xslt"/>
+ <xsl:include href="speech_win32.xslt"/>
<xsl:template match="/config/navit/graphics">
<graphics type="win32" />
</xsl:template>
diff --git a/navit/zipfile.h b/navit/zipfile.h
index bb3ed1c56..9edccf2ef 100644
--- a/navit/zipfile.h
+++ b/navit/zipfile.h
@@ -119,7 +119,7 @@ struct zip_enc {
short version;
char vendor_id1,vendor_id2;
char encryption_strength;
- short compress_method;
+ short compress_method;
} ATTRIBUTE_PACKED;
#define zip_eoc_sig 0x6054b50
@@ -167,10 +167,6 @@ struct zip64_eocl {
int zip74lnum;
} ATTRIBUTE_PACKED;
-struct zip_alignment_check {
- int x[sizeof(struct zip_cd) == 46 ? 1:-1];
-};
-
#ifdef HAVE_PRAGMA_PACK
#pragma pack(pop)
#endif
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index 1967005b4..da02d43e8 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -1,90 +1,84 @@
FIND_PROGRAM(XGETTEXT xgettext)
set(POTFILES
- ${PROJECT_SOURCE_DIR}/navit/main.c
- ${PROJECT_SOURCE_DIR}/navit/navigation.c
- ${PROJECT_SOURCE_DIR}/navit/navit.c
- ${PROJECT_SOURCE_DIR}/navit/popup.c
- ${PROJECT_SOURCE_DIR}/navit/country.c
- ${PROJECT_SOURCE_DIR}/navit/start_real.c
- ${PROJECT_SOURCE_DIR}/navit/route.c
- ${PROJECT_SOURCE_DIR}/navit/vehicle.c
- ${PROJECT_SOURCE_DIR}/navit/bookmarks.c
- ${PROJECT_SOURCE_DIR}/navit/gui/gtk/destination.c
- ${PROJECT_SOURCE_DIR}/navit/gui/gtk/gui_gtk_action.c
- ${PROJECT_SOURCE_DIR}/navit/gui/gtk/gui_gtk_poi.c
- ${PROJECT_SOURCE_DIR}/navit/gui/gtk/gui_gtk_statusbar.c
- ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal.c
- ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_bookmark.c
- ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_command.c
- ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_html.c
- ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_menu.c
- ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_poi.c
- ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_search.c
- ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_widget.c
- ${PROJECT_SOURCE_DIR}/navit/osd/core/osd_core.c
- ${PROJECT_SOURCE_DIR}/navit/android/src/org/navitproject/navit/NavitAddressSearchActivity.java
- ${PROJECT_SOURCE_DIR}/navit/android/src/org/navitproject/navit/NavitDialogs.java
- ${PROJECT_SOURCE_DIR}/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java
- ${PROJECT_SOURCE_DIR}/navit/android/src/org/navitproject/navit/NavitGraphics.java
- ${PROJECT_SOURCE_DIR}/navit/android/src/org/navitproject/navit/Navit.java
- ${PROJECT_SOURCE_DIR}/navit/android/src/org/navitproject/navit/NavitMapDownloader.java
- ${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.c
- ${CMAKE_CURRENT_BINARY_DIR}/strings_xml.c
-)
+ ${PROJECT_SOURCE_DIR}/navit/main.c
+ ${PROJECT_SOURCE_DIR}/navit/navigation.c
+ ${PROJECT_SOURCE_DIR}/navit/navit.c
+ ${PROJECT_SOURCE_DIR}/navit/popup.c
+ ${PROJECT_SOURCE_DIR}/navit/country.c
+ ${PROJECT_SOURCE_DIR}/navit/start_real.c
+ ${PROJECT_SOURCE_DIR}/navit/route.c
+ ${PROJECT_SOURCE_DIR}/navit/vehicle.c
+ ${PROJECT_SOURCE_DIR}/navit/bookmarks.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/gtk/destination.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/gtk/gui_gtk_action.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/gtk/gui_gtk_poi.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/gtk/gui_gtk_statusbar.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_bookmark.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_command.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_html.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_menu.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_poi.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_search.c
+ ${PROJECT_SOURCE_DIR}/navit/gui/internal/gui_internal_widget.c
+ ${PROJECT_SOURCE_DIR}/navit/osd/core/osd_core.c
+ ${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.c
+ ${CMAKE_CURRENT_BINARY_DIR}/strings_xml.c
+ )
# Trick gettext to get translateable strings out of navit_shipped.xml
ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.c
- DEPENDS ${PROJECT_SOURCE_DIR}/navit/navit_shipped.xml
- COMMAND ${CMAKE_COMMAND} -D SRC=${PROJECT_SOURCE_DIR}/navit/navit_shipped.xml -D DST=${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.c
- -P ${PROJECT_SOURCE_DIR}/cmake/navit_xml_parser.cmake
-)
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.c
+ DEPENDS ${PROJECT_SOURCE_DIR}/navit/navit_shipped.xml
+ COMMAND ${CMAKE_COMMAND} -D SRC=${PROJECT_SOURCE_DIR}/navit/navit_shipped.xml -D DST=${CMAKE_CURRENT_BINARY_DIR}/navit_shipped.c
+ -P ${PROJECT_SOURCE_DIR}/cmake/navit_xml_parser.cmake
+ )
# Trick gettext to get translateable strings out of android strings.xml
ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/strings_xml.c
- DEPENDS ${PROJECT_SOURCE_DIR}/navit/android/res/values/strings.xml
- COMMAND ${CMAKE_COMMAND} -D SRC=${PROJECT_SOURCE_DIR}/navit/android/res/values/strings.xml -D DST=${CMAKE_CURRENT_BINARY_DIR}/strings_xml.c
- -P ${PROJECT_SOURCE_DIR}/cmake/strings_xml_parser.cmake
-)
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/strings_xml.c
+ DEPENDS ${PROJECT_SOURCE_DIR}/navit/android/res/values/strings.xml
+ COMMAND ${CMAKE_COMMAND} -D SRC=${PROJECT_SOURCE_DIR}/navit/android/res/values/strings.xml -D DST=${CMAKE_CURRENT_BINARY_DIR}/strings_xml.c
+ -P ${PROJECT_SOURCE_DIR}/cmake/strings_xml_parser.cmake
+ )
ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/navit.pot
- DEPENDS ${POTFILES}
- COMMAND ${XGETTEXT} --no-location --default-domain=navit_tmp --add-comments --keyword=_ --keyword=_n --keyword=navit_nls_gettext --keyword=navit_nls_ngettext:1,2 ${POTFILES}
- COMMAND ${CMAKE_COMMAND} -DMATCHES="CHARSET" -DREPLACE="utf-8"
- -DSRC=${CMAKE_CURRENT_BINARY_DIR}/navit_tmp.po -DDST=${CMAKE_CURRENT_BINARY_DIR}/navit.pot
- -P ${PROJECT_SOURCE_DIR}/cmake/replace.cmake
-)
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/navit.pot
+ DEPENDS ${POTFILES}
+ COMMAND ${XGETTEXT} --no-location --default-domain=navit_tmp --add-comments --keyword=_ --keyword=_n --keyword=navit_nls_gettext --keyword=navit_nls_ngettext:1,2 ${POTFILES}
+ COMMAND ${CMAKE_COMMAND} -DMATCHES="CHARSET" -DREPLACE="utf-8"
+ -DSRC=${CMAKE_CURRENT_BINARY_DIR}/navit_tmp.po -DDST=${CMAKE_CURRENT_BINARY_DIR}/navit.pot
+ -P ${PROJECT_SOURCE_DIR}/cmake/replace.cmake
+ )
FILE(GLOB POIN_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.po.in")
string(REPLACE ".po.in" "" LANGUAGES "${POIN_FILES}")
foreach (LANG ${LANGUAGES})
- ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/navit.pot ${CMAKE_CURRENT_SOURCE_DIR}/${LANG}.po.in
- COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/${LANG}.po.in -D DST=${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po.tmp -DPACKAGE_STRING=${PACKAGE_STRING} -P ${PROJECT_SOURCE_DIR}/cmake/navit_po_version.cmake
- COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --no-fuzzy-matching --verbose --quiet -o "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po" "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po.tmp" ${CMAKE_CURRENT_BINARY_DIR}/navit.pot
- COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po.tmp"
- )
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/navit.pot ${CMAKE_CURRENT_SOURCE_DIR}/${LANG}.po.in
+ COMMAND ${CMAKE_COMMAND} -D SRC=${CMAKE_CURRENT_SOURCE_DIR}/${LANG}.po.in -D DST=${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po.tmp -DPACKAGE_STRING=${PACKAGE_STRING} -P ${PROJECT_SOURCE_DIR}/cmake/navit_po_version.cmake
+ COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --no-fuzzy-matching --verbose --quiet -o "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po" "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po.tmp" ${CMAKE_CURRENT_BINARY_DIR}/navit.pot
+ COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po.tmp"
+ )
endforeach(LANG ${LANGUAGES})
foreach (LANG ${LANGUAGES})
- ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po
- COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check --verbose --statistics --output-file="${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo" "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po"
- COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/locale/${LANG}/LC_MESSAGES"
- COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo" "${PROJECT_BINARY_DIR}/locale/${LANG}/LC_MESSAGES/navit.mo"
- )
- SET(MOFILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo ${MOFILES})
- INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo DESTINATION ${LOCALE_DIR}/${LANG}/LC_MESSAGES RENAME ${PACKAGE}.mo)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po
+ COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check --verbose --statistics --output-file="${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo" "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.po"
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/locale/${LANG}/LC_MESSAGES"
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo" "${PROJECT_BINARY_DIR}/locale/${LANG}/LC_MESSAGES/navit.mo"
+ )
+ SET(MOFILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo ${MOFILES})
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.mo DESTINATION ${LOCALE_DIR}/${LANG}/LC_MESSAGES RENAME ${PACKAGE}.mo)
endforeach(LANG ${LANGUAGES})
add_custom_target(locales ALL DEPENDS ${MOFILES})
diff --git a/po/af.po.in b/po/af.po.in
index 04af45fca..fbfdf7413 100644
--- a/po/af.po.in
+++ b/po/af.po.in
@@ -1,5 +1,5 @@
# Afrikaans translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Andre Hugo https://launchpad.net/~cortexhugo
@@ -12,7 +12,7 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2015-07-19 03:57+0000\n"
"Last-Translator: Michael von Glasow <Unknown>\n"
@@ -156,7 +156,6 @@ msgstr ""
msgid "%1$sonto %2$s|neuter form"
msgstr ""
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr ""
@@ -357,7 +356,7 @@ msgstr "Draai om %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -369,7 +368,6 @@ msgstr "dan het jy jou bestemming bereik."
msgid "You have reached your destination %s"
msgstr "Jy het jou bestemming bereik %s"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr ""
@@ -386,9 +384,15 @@ msgstr "Bevel"
msgid "Length"
msgstr "Lengte"
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr "kilometer"
+msgid "feet"
+msgstr ""
+
msgid "m"
msgstr "meter"
@@ -449,6 +453,7 @@ msgid "Anguilla"
msgstr "Anguilla"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Albanië"
@@ -461,6 +466,7 @@ msgid "Netherlands Antilles"
msgstr "Nederland Antille"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Angola"
@@ -469,6 +475,7 @@ msgid "Antarctica"
msgstr "Antarktika"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Argentinië"
@@ -477,10 +484,12 @@ msgid "American Samoa"
msgstr "Amerikaanse Samoa"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Oostenryk"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Australië"
@@ -493,10 +502,12 @@ msgid "Aland Islands"
msgstr "Aland Eiland"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Azerbaidjan"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Bosnië en Herzegowina"
@@ -509,6 +520,7 @@ msgid "Bangladesh"
msgstr "Bangladesj"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "België"
@@ -517,6 +529,7 @@ msgid "Burkina Faso"
msgstr "Boerkina Fasso"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Bulgarye"
@@ -525,6 +538,7 @@ msgid "Bahrain"
msgstr "Bahrein"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Boeroendi"
@@ -545,6 +559,7 @@ msgid "Brunei Darussalam"
msgstr "Broenei"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Bolivië"
@@ -553,6 +568,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr ""
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Brasilië"
@@ -569,10 +585,12 @@ msgid "Bouvet Island"
msgstr "Bouveteiland"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Botswana"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Wit-Rusland"
@@ -581,6 +599,7 @@ msgid "Belize"
msgstr "Belize"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Kanada"
@@ -589,6 +608,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Cocos- (Keeling) eilande"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Kongo, Demokratiese Republiek van die"
@@ -601,10 +621,12 @@ msgid "Congo"
msgstr "Kongo"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Switserland"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Ivoorkus"
@@ -613,6 +635,7 @@ msgid "Cook Islands"
msgstr "Cookeilande"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Chili"
@@ -621,10 +644,12 @@ msgid "Cameroon"
msgstr "Kameroen"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "Sjina"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Kolombië"
@@ -633,6 +658,7 @@ msgid "Costa Rica"
msgstr "Costa Rica"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Kuba"
@@ -649,14 +675,17 @@ msgid "Christmas Island"
msgstr "Kerseiland"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Siprus"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "Tjeggiese Republiek"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Duitsland"
@@ -665,6 +694,7 @@ msgid "Djibouti"
msgstr "Djiboeti"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Denemarke"
@@ -673,6 +703,7 @@ msgid "Dominica"
msgstr "Dominika"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "Dominikaanse Republiek"
@@ -681,10 +712,12 @@ msgid "Algeria"
msgstr "Algerië"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Ecuador"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Esland"
@@ -701,14 +734,17 @@ msgid "Eritrea"
msgstr "Eritrea"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Spanje"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Etiopië"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Finland"
@@ -725,10 +761,12 @@ msgid "Micronesia, Federated States of"
msgstr "Mikronesia, Federale state van"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Faroëreilande"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "Frankryk"
@@ -737,6 +775,7 @@ msgid "Gabon"
msgstr "Gaboen"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Verenigde Koninkryk"
@@ -773,6 +812,7 @@ msgid "Gambia"
msgstr "Gambië"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Guinië"
@@ -785,6 +825,7 @@ msgid "Equatorial Guinea"
msgstr "Ekwatoriaal-Guinee"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Griekeland"
@@ -805,6 +846,7 @@ msgid "Guinea-Bissau"
msgstr "Guinee-Bissau"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Guyana"
@@ -821,26 +863,32 @@ msgid "Honduras"
msgstr "Honduras"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Kroasië"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Haïti"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Hongarye"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Indonesië"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Ierland"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Israel"
@@ -849,6 +897,7 @@ msgid "Isle of Man"
msgstr "Man eiland"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "Indië"
@@ -857,18 +906,22 @@ msgid "British Indian Ocean Territory"
msgstr "Brits Indiese oseaan gebiede"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Irak"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Iran"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Ysland"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Italië"
@@ -877,6 +930,7 @@ msgid "Jersey"
msgstr "Jersey"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Jamaika"
@@ -885,14 +939,17 @@ msgid "Jordan"
msgstr "Jordanië"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Japan"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Kenia"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Kyrgyzstan"
@@ -929,6 +986,7 @@ msgid "Cayman Islands"
msgstr "Kaaimanseilande"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Kazakstan"
@@ -953,26 +1011,32 @@ msgid "Sri Lanka"
msgstr "Sri Lanka"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Liberië"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Lesotho"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Litoue"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Luxenburg"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Letland"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr ""
@@ -997,6 +1061,7 @@ msgid "Saint Martin (French part)"
msgstr "St. Martin"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Madagaskar"
@@ -1017,6 +1082,7 @@ msgid "Myanmar"
msgstr "Mianmar"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Mongolië"
@@ -1057,10 +1123,12 @@ msgid "Malawi"
msgstr "Malawi"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "Meksiko"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Maleisië"
@@ -1069,10 +1137,12 @@ msgid "Mozambique"
msgstr "Mosambiek"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Namibië"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Nieu-Kaledonië"
@@ -1093,6 +1163,7 @@ msgid "Nicaragua"
msgstr "Nikaragua"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Nederland"
@@ -1101,6 +1172,7 @@ msgid "Norway"
msgstr "Noorweë"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Nepal"
@@ -1113,6 +1185,7 @@ msgid "Niue"
msgstr "Niue"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Nieu-Seeland"
@@ -1125,6 +1198,7 @@ msgid "Panama"
msgstr "Panama"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Peru"
@@ -1137,14 +1211,17 @@ msgid "Papua New Guinea"
msgstr "Papoea Nieu-Guinee"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Filippyne"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Pakistan"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Pole"
@@ -1165,6 +1242,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Palestynse Gebied, Besette"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Portugal"
@@ -1173,6 +1251,7 @@ msgid "Palau"
msgstr "Palau"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Paraguaai"
@@ -1181,10 +1260,12 @@ msgid "Qatar"
msgstr "Katar"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Réunion"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Roemenië"
@@ -1193,14 +1274,17 @@ msgid "Serbia"
msgstr "Serwië"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Rusland"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Rwanda"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Saoedi-Arabië"
@@ -1221,6 +1305,7 @@ msgid "Sweden"
msgstr "Swede"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Singapoer"
@@ -1237,6 +1322,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Svalbard en Jan Mayen"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Slowakye"
@@ -1257,6 +1343,7 @@ msgid "Somalia"
msgstr "Somalië"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Suriname"
@@ -1301,6 +1388,7 @@ msgid "Togo"
msgstr "Togo"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Thailand"
@@ -1317,6 +1405,7 @@ msgid "Timor-Leste"
msgstr "Oos-Timor"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Turkmenistan"
@@ -1329,6 +1418,7 @@ msgid "Tonga"
msgstr "Tonga"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Turkye"
@@ -1345,14 +1435,17 @@ msgid "Taiwan, Province of China"
msgstr "Taiwan"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Tanzanië"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Oekraïne"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Oeganda"
@@ -1365,6 +1458,7 @@ msgid "United States"
msgstr "Vereenigde State"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Uruguay"
@@ -1381,6 +1475,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "St. Vincent en die Grenadine"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Venezuela"
@@ -1417,6 +1512,7 @@ msgid "Mayotte"
msgstr "Mayotte"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "Suid-Afrika"
@@ -1444,23 +1540,23 @@ msgid ""
msgstr ""
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
+msgid "No config file navit.xml, navit.xml.local found"
msgstr ""
#, c-format
-msgid "Error parsing config file '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
+msgid "Using config file '%s'"
msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
msgstr ""
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
msgid "unknown street"
@@ -1601,6 +1697,9 @@ msgstr ""
msgid "_Lock on Road"
msgstr "Koppel aan Pad"
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr ""
@@ -1670,7 +1769,12 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
msgstr ""
#, c-format
@@ -1678,15 +1782,15 @@ msgid "POI %s. %s"
msgstr ""
#, c-format
-msgid "Set destination to %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
+msgid "Set map to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
msgstr ""
msgid "POI search"
@@ -1695,9 +1799,6 @@ msgstr ""
msgid "Select a category"
msgstr ""
-msgid "Select a distance to look for (km)"
-msgstr ""
-
msgid "Select a POI"
msgstr ""
@@ -1710,7 +1811,7 @@ msgstr ""
msgid "Direction"
msgstr ""
-msgid "Distance(m)"
+msgid "Distance"
msgstr ""
msgid "Name"
@@ -1757,8 +1858,8 @@ msgid "OT"
msgstr "OT"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Roete %4.0fkm %02d:%02d aankomstyd"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "Roete 0000km 0+00:00 aankomstyd"
@@ -1929,10 +2030,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1980,6 +2081,9 @@ msgstr "Roete Beskrywing"
msgid "Show Locale"
msgstr "Toon Lokalisering"
+msgid "Network info"
+msgstr ""
+
msgid "Former Destinations"
msgstr "Voorige bestemmings"
@@ -2018,737 +2122,873 @@ msgstr ""
msgid "Please decrease your speed"
msgstr ""
-msgid "partial match"
-msgstr ""
+msgid "Vehicle Position"
+msgstr "Voertuig posisie"
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr ""
+msgid "Main menu"
+msgstr "Hoofkieslys"
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
+msgid ""
+"Show\n"
+"Map"
msgstr ""
+"Wys\n"
+"Kaart"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr ""
+msgid "Settings"
+msgstr "Instellings"
+
+msgid "Tools"
+msgstr "Gereedskap"
+
+msgid "Route"
+msgstr "Roete"
+
+msgid "About"
+msgstr "Rakende"
+
+msgid "Quit"
+msgstr "Verlaat"
+
+msgid "Actions"
+msgstr "Aksies"
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Former\n"
+"Destinations"
msgstr ""
-msgid "Downloaded maps"
+msgid "Coordinates"
msgstr ""
msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+"Stop\n"
+"Navigation"
msgstr ""
+"Stop\n"
+"Navigasie"
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr ""
+msgid "Display"
+msgstr "Skerm"
-msgid "Cancel"
-msgstr ""
+msgid "Fullscreen"
+msgstr "Volskerm"
-msgid "filenamePath"
-msgstr ""
+msgid "Window Mode"
+msgstr "Venster Modus"
-msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+msgid "Auto zoom"
msgstr ""
-msgid "Whole Planet"
+msgid "Manual zoom"
msgstr ""
-msgid "Africa"
+msgid "Layers"
msgstr ""
-msgid "Canary Islands"
+msgid "Zoom to route"
msgstr ""
-msgid "Asia"
-msgstr ""
+msgid "Description"
+msgstr "Beskrywing"
-msgid "Korea"
+msgid ""
+"Drop last\n"
+"Waypoint"
msgstr ""
-msgid "Taiwan"
+msgid ""
+"Drop next\n"
+"Waypoint"
msgstr ""
-msgid "UAE+Other"
+msgid "Satellite Status"
msgstr ""
-msgid "Oceania"
+msgid "NMEA Data"
msgstr ""
-msgid "Tasmania"
+msgid "car_shortest"
msgstr ""
-msgid "Victoria"
+msgid "car_avoid_tolls"
msgstr ""
-msgid "New South Wales"
+msgid "car_pedantic"
msgstr ""
-msgid "Europe"
-msgstr ""
+msgid "horse"
+msgstr "perd"
-msgid "Western Europe"
+msgid "Truck"
msgstr ""
-msgid "Azores"
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
msgstr ""
-msgid "BeNeLux"
+#. Android resource: @strings/cancel
+msgid "Cancel"
msgstr ""
-msgid "Alsace"
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
msgstr ""
-msgid "Aquitaine"
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
msgstr ""
-msgid "Auvergne"
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
msgstr ""
-msgid "Basse-Normandie"
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
msgstr ""
-msgid "Bourgogne"
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
msgstr ""
-msgid "Bretagne"
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
msgstr ""
-msgid "Centre"
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
msgstr ""
-msgid "Champagne-Ardenne"
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
msgstr ""
-msgid "Corse"
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
msgstr ""
-msgid "Franche-Comte"
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
msgstr ""
-msgid "Haute-Normandie"
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
msgstr ""
-msgid "Ile-de-France"
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
msgstr ""
-msgid "Languedoc-Roussillon"
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
msgstr ""
-msgid "Limousin"
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
msgstr ""
-msgid "Lorraine"
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
msgstr ""
-msgid "Midi-Pyrenees"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
msgstr ""
-msgid "Nord-pas-de-Calais"
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
msgstr ""
-msgid "Pays-de-la-Loire"
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
msgstr ""
-msgid "Picardie"
+#. Android resource: @strings/map_download_ready
+msgid "ready"
msgstr ""
-msgid "Poitou-Charentes"
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
msgstr ""
-msgid "Provence-Alpes-Cote-d-Azur"
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
msgstr ""
-msgid "Rhone-Alpes"
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
msgstr ""
-msgid "Baden-Wuerttemberg"
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
msgstr ""
-msgid "Bayern"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
msgstr ""
-msgid "Mittelfranken"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
msgstr ""
-msgid "Niederbayern"
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
msgstr ""
-msgid "Oberbayern"
+#. Android resource: @strings/map_downloading
+msgid "downloading"
msgstr ""
-msgid "Oberfranken"
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
msgstr ""
-msgid "Oberpfalz"
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
msgstr ""
-msgid "Schwaben"
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
msgstr ""
-msgid "Unterfranken"
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
msgstr ""
-msgid "Berlin"
+#. Android resource: @strings/address_search_title
+msgid "Address search"
msgstr ""
-msgid "Brandenburg"
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
msgstr ""
-msgid "Bremen"
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
msgstr ""
-msgid "Hamburg"
+#. Android resource: @strings/address_search_button
+msgid "Search"
msgstr ""
-msgid "Hessen"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
msgstr ""
-msgid "Mecklenburg-Vorpommern"
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
msgstr ""
-msgid "Niedersachsen"
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
msgstr ""
-msgid "Nordrhein-westfalen"
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
msgstr ""
-msgid "Rheinland-Pfalz"
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
msgstr ""
-msgid "Saarland"
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
msgstr ""
-msgid "Sachsen-Anhalt"
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
msgstr ""
-msgid "Sachsen"
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
msgstr ""
-msgid "Schleswig-Holstein"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
msgstr ""
-msgid "Thueringen"
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
msgstr ""
-msgid "Mallorca"
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
msgstr ""
-msgid "Galicia"
+#. Android resource: @strings/restoring
+msgid "Restoring..."
msgstr ""
-msgid "Scandinavia"
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
msgstr ""
-msgid "England"
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
msgstr ""
-msgid "Buckinghamshire"
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
msgstr ""
-msgid "Cambridgeshire"
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
msgstr ""
-msgid "Cumbria"
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
msgstr ""
-msgid "East yorkshire with hull"
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
-msgid "Essex"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
msgstr ""
-msgid "Herefordshire"
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
msgstr ""
-msgid "Kent"
+#. Android resource: @strings/select_backup
+msgid "Select backup"
msgstr ""
-msgid "Lancashire"
+#. Android resource: @strings/backup
+msgid "Backup"
msgstr ""
-msgid "Leicestershire"
+#. Android resource: @strings/restore
+msgid "Restore"
msgstr ""
-msgid "Norfolk"
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
msgstr ""
-msgid "Nottinghamshire"
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
-msgid "Oxfordshire"
+#. Android resource: @strings/permissions_not_granted
+msgid ""
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
-msgid "Shropshire"
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
msgstr ""
-msgid "Somerset"
+#. Android resource: @strings/whole_planet
+msgid "Whole Planet"
msgstr ""
-msgid "South yorkshire"
+#. Android resource: @strings/africa
+msgid "Africa"
msgstr ""
-msgid "Suffolk"
+#. Android resource: @strings/canary_islands
+msgid "Canary Islands"
msgstr ""
-msgid "Surrey"
+#. Android resource: @strings/asia
+msgid "Asia"
msgstr ""
-msgid "Wiltshire"
+#. Android resource: @strings/taiwan
+msgid "Taiwan"
msgstr ""
-msgid "Scotland"
+#. Android resource: @strings/korea
+msgid "Korea"
msgstr ""
-msgid "Wales"
+#. Android resource: @strings/uae_other
+msgid "UAE+Other"
msgstr ""
-msgid "Crete"
+#. Android resource: @strings/oceania
+msgid "Oceania"
msgstr ""
-msgid "North America"
+#. Android resource: @strings/tasmania
+msgid "Tasmania"
msgstr ""
-msgid "Alaska"
+#. Android resource: @strings/victoria
+msgid "Victoria"
msgstr ""
-msgid "Hawaii"
+#. Android resource: @strings/new_south_wales
+msgid "New South Wales"
msgstr ""
-msgid "USA"
+#. Android resource: @strings/europe
+msgid "Europe"
msgstr ""
-msgid " (except Alaska and Hawaii)"
+#. Android resource: @strings/western_europe
+msgid "Western Europe"
msgstr ""
-msgid "Midwest"
+#. Android resource: @strings/azores
+msgid "Azores"
msgstr ""
-msgid "Michigan"
+#. Android resource: @strings/benelux
+msgid "BeNeLux"
msgstr ""
-msgid "Ohio"
+#. Android resource: @strings/alsace
+msgid "Alsace"
msgstr ""
-msgid "Northeast"
+#. Android resource: @strings/aquitaine
+msgid "Aquitaine"
msgstr ""
-msgid "Massachusetts"
+#. Android resource: @strings/auvergne
+msgid "Auvergne"
msgstr ""
-msgid "Vermont"
+#. Android resource: @strings/centre
+msgid "Centre"
msgstr ""
-msgid "Pacific"
+#. Android resource: @strings/bretagne
+msgid "Bretagne"
msgstr ""
-msgid "South"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
msgstr ""
-msgid "Arkansas"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
msgstr ""
-msgid "District of Columbia"
+#. Android resource: @strings/champagne_ardenne
+msgid "Champagne-Ardenne"
msgstr ""
-msgid "Florida"
+#. Android resource: @strings/corse
+msgid "Corse"
msgstr ""
-msgid "Louisiana"
+#. Android resource: @strings/franche_comte
+msgid "Franche-Comte"
msgstr ""
-msgid "Maryland"
+#. Android resource: @strings/haute_normandie
+msgid "Haute-Normandie"
msgstr ""
-msgid "Mississippi"
+#. Android resource: @strings/ile_de_france
+msgid "Ile-de-France"
msgstr ""
-msgid "Oklahoma"
+#. Android resource: @strings/languedoc_roussillon
+msgid "Languedoc-Roussillon"
msgstr ""
-msgid "Texas"
+#. Android resource: @strings/limousin
+msgid "Limousin"
msgstr ""
-msgid "Virginia"
+#. Android resource: @strings/lorraine
+msgid "Lorraine"
msgstr ""
-msgid "West Virginia"
+#. Android resource: @strings/midi_pyrenees
+msgid "Midi-Pyrenees"
msgstr ""
-msgid "West"
+#. Android resource: @strings/nord_pas_de_calais
+msgid "Nord-pas-de-Calais"
msgstr ""
-msgid "Arizona"
+#. Android resource: @strings/pays_de_la_loire
+msgid "Pays-de-la-Loire"
msgstr ""
-msgid "California"
+#. Android resource: @strings/picardie
+msgid "Picardie"
msgstr ""
-msgid "Colorado"
+#. Android resource: @strings/poitou_charentes
+msgid "Poitou-Charentes"
msgstr ""
-msgid "Idaho"
+#. Android resource: @strings/provence_alpes_cote_d_azur
+msgid "Provence-Alpes-Cote-d-Azur"
msgstr ""
-msgid "Montana"
+#. Android resource: @strings/rhone_alpes
+msgid "Rhone-Alpes"
msgstr ""
-msgid "New Mexico"
+#. Android resource: @strings/baden_wuerttemberg
+msgid "Baden-Wuerttemberg"
msgstr ""
-msgid "Nevada"
+#. Android resource: @strings/bayern
+msgid "Bayern"
msgstr ""
-msgid "Oregon"
+#. Android resource: @strings/mittelfranken
+msgid "Mittelfranken"
msgstr ""
-msgid "Utah"
+#. Android resource: @strings/niederbayern
+msgid "Niederbayern"
msgstr ""
-msgid "Washington State"
+#. Android resource: @strings/oberbayern
+msgid "Oberbayern"
msgstr ""
-msgid "South+Middle America"
+#. Android resource: @strings/oberfranken
+msgid "Oberfranken"
msgstr ""
-msgid "Guyane Francaise"
+#. Android resource: @strings/oberpfalz
+msgid "Oberpfalz"
msgstr ""
-msgid "downloading"
+#. Android resource: @strings/schwaben
+msgid "Schwaben"
msgstr ""
-#. Android resource: @strings/map_download_ready
-msgid "ready"
+#. Android resource: @strings/unterfranken
+msgid "Unterfranken"
msgstr ""
-msgid "Media selected for map storage is not available"
+#. Android resource: @strings/berlin
+msgid "Berlin"
msgstr ""
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
+#. Android resource: @strings/brandenburg
+msgid "Brandenburg"
msgstr ""
-msgid "Error downloading map!"
+#. Android resource: @strings/bremen
+msgid "Bremen"
msgstr ""
-msgid "Error writing map!"
+#. Android resource: @strings/hamburg
+msgid "Hamburg"
msgstr ""
-msgid "Map download aborted!"
+#. Android resource: @strings/hessen
+msgid "Hessen"
msgstr ""
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
+#. Android resource: @strings/mecklenburg_vorpommern
+msgid "Mecklenburg-Vorpommern"
msgstr ""
-#. Android resource: @strings/map_download_title
-msgid "Map download"
+#. Android resource: @strings/niedersachsen
+msgid "Niedersachsen"
msgstr ""
-msgid "Vehicle Position"
-msgstr "Voertuig posisie"
-
-msgid "Main menu"
-msgstr "Hoofkieslys"
-
-msgid ""
-"Show\n"
-"Map"
+#. Android resource: @strings/nordrhein_westfalen
+msgid "Nordrhein-westfalen"
msgstr ""
-"Wys\n"
-"Kaart"
-
-msgid "Settings"
-msgstr "Instellings"
-
-msgid "Tools"
-msgstr "Gereedskap"
-
-msgid "Route"
-msgstr "Roete"
-msgid "About"
-msgstr "Rakende"
+#. Android resource: @strings/rheinland_pfalz
+msgid "Rheinland-Pfalz"
+msgstr ""
-msgid "Quit"
-msgstr "Verlaat"
+#. Android resource: @strings/saarland
+msgid "Saarland"
+msgstr ""
-msgid "Actions"
-msgstr "Aksies"
+#. Android resource: @strings/sachsen_anhalt
+msgid "Sachsen-Anhalt"
+msgstr ""
-msgid ""
-"Former\n"
-"Destinations"
+#. Android resource: @strings/sachsen
+msgid "Sachsen"
msgstr ""
-msgid "Coordinates"
+#. Android resource: @strings/schleswig_holstein
+msgid "Schleswig-Holstein"
msgstr ""
-msgid ""
-"Stop\n"
-"Navigation"
+#. Android resource: @strings/thueringen
+msgid "Thueringen"
msgstr ""
-"Stop\n"
-"Navigasie"
-msgid "Display"
-msgstr "Skerm"
+#. Android resource: @strings/mallorca
+msgid "Mallorca"
+msgstr ""
-msgid "Fullscreen"
-msgstr "Volskerm"
+#. Android resource: @strings/galicia
+msgid "Galicia"
+msgstr ""
-msgid "Window Mode"
-msgstr "Venster Modus"
+#. Android resource: @strings/scandinavia
+msgid "Scandinavia"
+msgstr ""
-msgid "Layers"
+#. Android resource: @strings/england
+msgid "England"
msgstr ""
-msgid "Description"
-msgstr "Beskrywing"
+#. Android resource: @strings/buckinghamshire
+msgid "Buckinghamshire"
+msgstr ""
-msgid ""
-"Drop last \n"
-"Waypoint"
+#. Android resource: @strings/cambridgeshire
+msgid "Cambridgeshire"
msgstr ""
-msgid ""
-"Drop next \n"
-"Waypoint"
+#. Android resource: @strings/cumbria
+msgid "Cumbria"
msgstr ""
-msgid "Satellite Status"
+#. Android resource: @strings/east_yorkshire_with_hull
+msgid "East yorkshire with hull"
msgstr ""
-msgid "NMEA Data"
+#. Android resource: @strings/essex
+msgid "Essex"
msgstr ""
-msgid "car_shortest"
+#. Android resource: @strings/herefordshire
+msgid "Herefordshire"
msgstr ""
-msgid "car_avoid_tolls"
+#. Android resource: @strings/kent
+msgid "Kent"
msgstr ""
-msgid "car_pedantic"
+#. Android resource: @strings/lancashire
+msgid "Lancashire"
msgstr ""
-msgid "horse"
-msgstr "perd"
+#. Android resource: @strings/leicestershire
+msgid "Leicestershire"
+msgstr ""
-msgid "Truck"
+#. Android resource: @strings/norfolk
+msgid "Norfolk"
msgstr ""
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
+#. Android resource: @strings/nottinghamshire
+msgid "Nottinghamshire"
msgstr ""
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
+#. Android resource: @strings/oxfordshire
+msgid "Oxfordshire"
msgstr ""
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
+#. Android resource: @strings/shropshire
+msgid "Shropshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
+#. Android resource: @strings/somerset
+msgid "Somerset"
msgstr ""
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
+#. Android resource: @strings/south_yorkshire
+msgid "South yorkshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
+#. Android resource: @strings/suffolk
+msgid "Suffolk"
msgstr ""
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
+#. Android resource: @strings/surrey
+msgid "Surrey"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
+#. Android resource: @strings/wiltshire
+msgid "Wiltshire"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
+#. Android resource: @strings/scotland
+msgid "Scotland"
msgstr ""
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
+#. Android resource: @strings/wales
+msgid "Wales"
msgstr ""
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
+#. Android resource: @strings/crete
+msgid "Crete"
msgstr ""
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
+#. Android resource: @strings/north_america
+msgid "North America"
msgstr ""
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
+#. Android resource: @strings/alaska
+msgid "Alaska"
msgstr ""
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
+#. Android resource: @strings/hawaii
+msgid "Hawaii"
msgstr ""
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
+#. Android resource: @strings/usa
+msgid "USA"
msgstr ""
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
msgstr ""
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
+#. Android resource: @strings/midwest
+msgid "Midwest"
msgstr ""
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
+#. Android resource: @strings/michigan
+msgid "Michigan"
msgstr ""
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
+#. Android resource: @strings/ohio
+msgid "Ohio"
msgstr ""
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
+#. Android resource: @strings/northeast
+msgid "Northeast"
msgstr ""
-#. Android resource: @strings/address_search_title
-msgid "Address search"
+#. Android resource: @strings/massachusetts
+msgid "Massachusetts"
msgstr ""
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
+#. Android resource: @strings/vermont
+msgid "Vermont"
msgstr ""
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
+#. Android resource: @strings/pacific
+msgid "Pacific"
msgstr ""
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
+#. Android resource: @strings/south
+msgid "South"
msgstr ""
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
+#. Android resource: @strings/arkansas
+msgid "Arkansas"
msgstr ""
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
+#. Android resource: @strings/district_of_columbia
+msgid "District of Columbia"
msgstr ""
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
+#. Android resource: @strings/florida
+msgid "Florida"
msgstr ""
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
+#. Android resource: @strings/louisiana
+msgid "Louisiana"
msgstr ""
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
+#. Android resource: @strings/maryland
+msgid "Maryland"
msgstr ""
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
+#. Android resource: @strings/mississippi
+msgid "Mississippi"
msgstr ""
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
+#. Android resource: @strings/oklahoma
+msgid "Oklahoma"
msgstr ""
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
+#. Android resource: @strings/texas
+msgid "Texas"
msgstr ""
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
+#. Android resource: @strings/virginia
+msgid "Virginia"
msgstr ""
-#. Android resource: @strings/restoring
-msgid "Restoring..."
+#. Android resource: @strings/west_virginia
+msgid "West Virginia"
msgstr ""
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
+#. Android resource: @strings/west
+msgid "West"
msgstr ""
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
+#. Android resource: @strings/arizona
+msgid "Arizona"
msgstr ""
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
+#. Android resource: @strings/california
+msgid "California"
msgstr ""
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
+#. Android resource: @strings/colorado
+msgid "Colorado"
msgstr ""
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
+#. Android resource: @strings/idaho
+msgid "Idaho"
msgstr ""
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
+#. Android resource: @strings/montana
+msgid "Montana"
msgstr ""
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
+#. Android resource: @strings/new_mexico
+msgid "New Mexico"
msgstr ""
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
+#. Android resource: @strings/nevada
+msgid "Nevada"
msgstr ""
-#. Android resource: @strings/select_backup
-msgid "Select backup"
+#. Android resource: @strings/oregon
+msgid "Oregon"
msgstr ""
-#. Android resource: @strings/backup
-msgid "Backup"
+#. Android resource: @strings/utah
+msgid "Utah"
msgstr ""
-#. Android resource: @strings/restore
-msgid "Restore"
+#. Android resource: @strings/washington_state
+msgid "Washington State"
msgstr ""
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
+#. Android resource: @strings/south_middle_america
+msgid "South+Middle America"
msgstr ""
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
+#. Android resource: @strings/guyane_francaise
+msgid "Guyane Francaise"
msgstr ""
#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Roete %4.0fkm %02d:%02d aankomstyd"
+
+#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
#~ msgstr "verlaat dan die sirkel by die %1$s %2$s"
diff --git a/po/ar.po.in b/po/ar.po.in
index 51655456e..0fc2f2957 100644
--- a/po/ar.po.in
+++ b/po/ar.po.in
@@ -1,19 +1,20 @@
# Arabic translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# KaZeR https://launchpad.net/~kazer
# Magd Addin M. Almuntaser https://launchpad.net/~ttmtt-team
+# abed alkareem alnatsheh https://launchpad.net/~abedalkareem
# dargirov https://launchpad.net/~dargirov
# drsaudi https://launchpad.net/~mon7b6
# metehyi https://launchpad.net/~metehyi
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2015-07-19 03:57+0000\n"
-"Last-Translator: dargirov <dargirov@mail.ru>\n"
+"PO-Revision-Date: 2018-02-05 13:00+0000\n"
+"Last-Translator: abed alkareem alnatsheh <Unknown>\n"
"Language-Team: Arabic <ar@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -93,7 +94,7 @@ msgstr "بعد %d.%d أميال"
#, c-format
msgid "one mile"
msgid_plural "%d miles"
-msgstr[0] "مايل واحد"
+msgstr[0] "ميل واحد"
msgstr[1] "%d أميال"
msgstr[2] "%d أميال"
msgstr[3] "%d أميال"
@@ -103,7 +104,7 @@ msgstr[5] "%d أميال"
#, c-format
msgid "in one mile"
msgid_plural "in %d miles"
-msgstr[0] "بعد مايل واحد"
+msgstr[0] "بعد ميل واحد"
msgstr[1] "بعد %d أميال"
msgstr[2] "بعد %d أميال"
msgstr[3] "بعد %d أميال"
@@ -129,12 +130,12 @@ msgstr "بعد %d%d كلم"
#, c-format
msgid "one kilometer"
msgid_plural "%d kilometers"
-msgstr[0] "كلم واحد"
-msgstr[1] "%d كلم"
-msgstr[2] "%d كلم"
-msgstr[3] "%d كلم"
-msgstr[4] "%d كلم"
-msgstr[5] "%d كلم"
+msgstr[0] "كيلومتر واحد"
+msgstr[1] "%d كيلومتر"
+msgstr[2] "%d كيلومتر"
+msgstr[3] "%d كيلومتر"
+msgstr[4] "%d كيلومتر"
+msgstr[5] "%d كيلومتر"
#, c-format
msgid "in one kilometer"
@@ -171,9 +172,8 @@ msgstr ""
msgid "%1$sonto %2$s|neuter form"
msgstr ""
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
-msgstr ""
+msgstr "على الطريق السريع المنحدر"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name
#, c-format
@@ -201,12 +201,12 @@ msgid "%sinto the %s"
msgstr "%s إلى داخل %s"
msgid "When possible, please turn around"
-msgstr "حيث ممكن الرجاء اللف"
+msgstr "عند الإمكانية , انعطف رجاء"
#. TRANSLATORS: the argument is the destination to follow
#, c-format
msgid "towards %s"
-msgstr "تجاه %s"
+msgstr "إتجاه %s"
#, c-format
msgid "Follow the road for the next %s"
@@ -218,10 +218,10 @@ msgstr "قريباً الدخول إلى المستديرة"
#. TRANSLATORS: %s is the distance to the roundabout
#, c-format
msgid "Enter the roundabout %s"
-msgstr ""
+msgstr "ادخل الدائرة بعد %s"
msgid "then enter the roundabout"
-msgstr ""
+msgstr "بعدها ادخل الدائرة"
#. TRANSLATORS: first arg. is the manieth exit, second arg. is the destination to follow
#, c-format
@@ -235,12 +235,12 @@ msgid "now"
msgstr "الآن"
msgid "then"
-msgstr ""
+msgstr "ثم"
#. TRANSLATORS: the arg. is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included.
#, c-format
msgid "then merge%1$s|right"
-msgstr ""
+msgstr "ثم اندمج %1$s|يمينا"
#. TRANSLATORS: the first arg. is distance, the second is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included.
#, c-format
@@ -258,10 +258,10 @@ msgid "Merge %1$s%2$s|left"
msgstr ""
msgid "on your left"
-msgstr ""
+msgstr "على يسارك"
msgid "on your right"
-msgstr ""
+msgstr "على يمينك"
#. TRANSLATORS: the first arg. is exit ref and/or name, the second is the direction of exit and the third is distance
#, c-format
@@ -275,10 +275,10 @@ msgstr ""
#. TRANSLATORS: as in "Keep right at interchange 42 Greenmond-West"
msgid "at interchange"
-msgstr ""
+msgstr "عند التبادل"
msgid "at exit"
-msgstr ""
+msgstr "عند المخرج"
#. TRANSLATORS: the arg. is where to do the maneuver
#, c-format
@@ -345,7 +345,7 @@ msgstr "حوّل %1$s%2$s %3$s%4$s"
#. TRANSLATORS: Left U-turn, the stuff after | doesn't have to be included.
msgid "then make a U-turn|left"
-msgstr ""
+msgstr "ثم انعطف يوترن يسارا"
#. TRANSLATORS: the arg. is distance. Left U-turn, the stuff after | doesn't have to be included.
#, c-format
@@ -354,7 +354,7 @@ msgstr ""
#. TRANSLATORS: Right U-turn, the stuff after | doesn't have to be included.
msgid "then make a U-turn|right"
-msgstr ""
+msgstr "ثم انعطف يوترن يمينا"
#. TRANSLATORS: the arg. is distance. Right U-turn, the stuff after | doesn't have to be included.
#, c-format
@@ -372,9 +372,9 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
-msgstr ""
+msgstr "اتبع"
msgid "then you have reached your destination."
msgstr "و بعدها تكون قد وصلت إلى هدفك"
@@ -384,7 +384,6 @@ msgstr "و بعدها تكون قد وصلت إلى هدفك"
msgid "You have reached your destination %s"
msgstr "لقد وصلت إلى هدفك %s"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr ""
@@ -401,9 +400,15 @@ msgstr "الأمر"
msgid "Length"
msgstr "الطول"
+msgid "mi"
+msgstr "ميل"
+
msgid "km"
msgstr "كلم"
+msgid "feet"
+msgstr "قدم"
+
msgid "m"
msgstr "م."
@@ -464,6 +469,7 @@ msgid "Anguilla"
msgstr "أنغويلا"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "ألبانيا"
@@ -476,6 +482,7 @@ msgid "Netherlands Antilles"
msgstr "الأنتيل الهولندية"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "أنغولا"
@@ -484,6 +491,7 @@ msgid "Antarctica"
msgstr "أنتاركتيكا"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "الأرجنتين"
@@ -492,10 +500,12 @@ msgid "American Samoa"
msgstr "ساموا الأميركية"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "النمسا"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "أستراليا"
@@ -508,10 +518,12 @@ msgid "Aland Islands"
msgstr "جزر أولان"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "أذربيجان"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "البوسنة والهرسك"
@@ -524,6 +536,7 @@ msgid "Bangladesh"
msgstr "بنغلادش"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "بلجيكا"
@@ -532,6 +545,7 @@ msgid "Burkina Faso"
msgstr "بوركينا فاسو"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "بلغاريا"
@@ -540,6 +554,7 @@ msgid "Bahrain"
msgstr "البحرين"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "بوروندي"
@@ -560,6 +575,7 @@ msgid "Brunei Darussalam"
msgstr "بروناي دار السّلام"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "بوليفيا"
@@ -568,6 +584,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr ""
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "البرازيل"
@@ -584,10 +601,12 @@ msgid "Bouvet Island"
msgstr "جزيرة بوفيت"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "بوتسوانا"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "روسيا البيضاء \\ بيلاروس"
@@ -596,6 +615,7 @@ msgid "Belize"
msgstr "بيليز"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "كندا"
@@ -604,6 +624,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "جزر الكوكوس (كيلنك)"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "جمهورية الكونغو الديمقراطيه"
@@ -616,10 +637,12 @@ msgid "Congo"
msgstr "الكونغو"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "سويسرا"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "ساحل العاج"
@@ -628,6 +651,7 @@ msgid "Cook Islands"
msgstr "جزر كوك"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "تشيلي"
@@ -636,10 +660,12 @@ msgid "Cameroon"
msgstr "الكامرون"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "الصين"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "كولومبيا"
@@ -648,6 +674,7 @@ msgid "Costa Rica"
msgstr "كوستاريكا"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "كوبا"
@@ -664,14 +691,17 @@ msgid "Christmas Island"
msgstr "جزر الكريسماس"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "قبرص"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "جمهورية التشيك"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "ألمانيا"
@@ -680,6 +710,7 @@ msgid "Djibouti"
msgstr "جيبوتي"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "الدنمارك"
@@ -688,6 +719,7 @@ msgid "Dominica"
msgstr "الدّومينيكا"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "جمهورية الدومينيكان"
@@ -696,10 +728,12 @@ msgid "Algeria"
msgstr "الجزائر"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "الإكوادور"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "أستونيا"
@@ -716,14 +750,17 @@ msgid "Eritrea"
msgstr "أريتريا"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "إسبانيا"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "الحبشة"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "فنلندا"
@@ -740,10 +777,12 @@ msgid "Micronesia, Federated States of"
msgstr "ميكرونيزيا، ولايات ميكرونيزيا الفدرالية"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "جزر الفارو"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "فرنسا"
@@ -752,6 +791,7 @@ msgid "Gabon"
msgstr "الغابون"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "المملكة المتّحدة"
@@ -788,6 +828,7 @@ msgid "Gambia"
msgstr "غامبيا"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "غينيا"
@@ -800,6 +841,7 @@ msgid "Equatorial Guinea"
msgstr "غينيا الاستوائيه"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "اليونان"
@@ -820,6 +862,7 @@ msgid "Guinea-Bissau"
msgstr "غينيا بيساو"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "غيانا"
@@ -836,26 +879,32 @@ msgid "Honduras"
msgstr "الهوندوراس"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "كرواتيا"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "هايتي"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "المجر (هنغاريا)"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "إندونيسيا"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "إيرلندا"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "فلسطين المحتلة"
@@ -864,6 +913,7 @@ msgid "Isle of Man"
msgstr "جزيرة مان"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "الهند"
@@ -872,18 +922,22 @@ msgid "British Indian Ocean Territory"
msgstr "مقاطعة المحيط الهندي البريطانيّة"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "العراق"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "إيران، الجمهوريّة الإسلاميّة الإيرانيّة"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "آيسلندا"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "إيطاليا"
@@ -892,6 +946,7 @@ msgid "Jersey"
msgstr "جيرسي"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "جامايكا"
@@ -900,14 +955,17 @@ msgid "Jordan"
msgstr "الأردن"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "اليابان"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "كينيا"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "قرغيزستان"
@@ -944,6 +1002,7 @@ msgid "Cayman Islands"
msgstr "جزر الكايمان"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "كازاخستان"
@@ -968,26 +1027,32 @@ msgid "Sri Lanka"
msgstr "سريلانكا"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "ليبريا"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "ليسوتو"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "ليثوانيا"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "اللكسمبورغ"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "لاتفيا"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr "ليبيا"
@@ -1012,6 +1077,7 @@ msgid "Saint Martin (French part)"
msgstr "سانت مارتين (القطاع الفرنسي)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "مدغشقر"
@@ -1032,6 +1098,7 @@ msgid "Myanmar"
msgstr "مينامار"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "منغوليا"
@@ -1072,10 +1139,12 @@ msgid "Malawi"
msgstr "مالاوي"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "المكسيك"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "ماليزيا"
@@ -1084,10 +1153,12 @@ msgid "Mozambique"
msgstr "الموزمبيق"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "ناميبيا"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "قلدونيا الجديدة"
@@ -1108,6 +1179,7 @@ msgid "Nicaragua"
msgstr "نيكاراغوا"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "هولندا"
@@ -1116,6 +1188,7 @@ msgid "Norway"
msgstr "النروج"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "نيبال"
@@ -1128,6 +1201,7 @@ msgid "Niue"
msgstr "نيوي"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "نيوزيلاندا"
@@ -1140,6 +1214,7 @@ msgid "Panama"
msgstr "باناما"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "البيرو"
@@ -1152,14 +1227,17 @@ msgid "Papua New Guinea"
msgstr "بابوا غينيا الجديدة"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "الفلبّين"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "باكستان"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "بولونيا"
@@ -1180,6 +1258,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "فلسطين المحتلّة، الأراضي الفلسطينيّة المحتلّة"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "البرتغال"
@@ -1188,6 +1267,7 @@ msgid "Palau"
msgstr "بالاو"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "الباراغواي"
@@ -1196,10 +1276,12 @@ msgid "Qatar"
msgstr "قطر"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "ريونيون"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "رومانيا"
@@ -1208,14 +1290,17 @@ msgid "Serbia"
msgstr "صربيا"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "الإتّحاد الروسي"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "رواندا"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "المملكة العربيّة السّعوديّة"
@@ -1236,6 +1321,7 @@ msgid "Sweden"
msgstr "السّويد"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "سنغفورة"
@@ -1252,6 +1338,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "سفالبارد وجان مايان"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "سلوفاكيا"
@@ -1272,6 +1359,7 @@ msgid "Somalia"
msgstr "الصّومال"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "سورينام"
@@ -1316,6 +1404,7 @@ msgid "Togo"
msgstr "توغو"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "تايلندا"
@@ -1332,6 +1421,7 @@ msgid "Timor-Leste"
msgstr "تيمور الشرقية"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "تركمانستان"
@@ -1344,6 +1434,7 @@ msgid "Tonga"
msgstr "تونجا"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "تركيا"
@@ -1360,14 +1451,17 @@ msgid "Taiwan, Province of China"
msgstr "تايوان، محافظة صينية"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "تنزانيا، جمهوريّة تنزانيا المتّحدة"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "أوكرانيا"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "اوغندا"
@@ -1380,6 +1474,7 @@ msgid "United States"
msgstr "الولايات المتّحدة الأمريكية"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "الأوروغواي"
@@ -1396,6 +1491,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "سانت فنسنت والجرينادينز"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "فنزويلا"
@@ -1432,6 +1528,7 @@ msgid "Mayotte"
msgstr "مايوت"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "جنوب إفريقيا"
@@ -1459,23 +1556,23 @@ msgid ""
msgstr ""
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
+msgid "No config file navit.xml, navit.xml.local found"
msgstr ""
#, c-format
-msgid "Error parsing config file '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
+msgid "Using config file '%s'"
msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
msgstr ""
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
msgid "unknown street"
@@ -1616,6 +1713,9 @@ msgstr ""
msgid "_Lock on Road"
msgstr "إقفال على الطريق"
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr "_حافظ على الإتجاه شمالا"
@@ -1685,7 +1785,12 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
msgstr ""
#, c-format
@@ -1693,15 +1798,15 @@ msgid "POI %s. %s"
msgstr ""
#, c-format
-msgid "Set destination to %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
+msgid "Set map to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
msgstr ""
msgid "POI search"
@@ -1710,9 +1815,6 @@ msgstr ""
msgid "Select a category"
msgstr ""
-msgid "Select a distance to look for (km)"
-msgstr ""
-
msgid "Select a POI"
msgstr ""
@@ -1725,7 +1827,7 @@ msgstr ""
msgid "Direction"
msgstr ""
-msgid "Distance(m)"
+msgid "Distance"
msgstr ""
msgid "Name"
@@ -1772,8 +1874,8 @@ msgid "OT"
msgstr "OT"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Route %4.0fكلم %02d:%02d ETA"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "الطريك 0000كلم 0+00:00 ETA"
@@ -1944,10 +2046,10 @@ msgstr "نقاط المراحل"
msgid "Enter Coordinates"
msgstr "أدخل الإحداثيات"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1995,6 +2097,9 @@ msgstr "وصف الطريق"
msgid "Show Locale"
msgstr "أعرض المحليات"
+msgid "Network info"
+msgstr ""
+
msgid "Former Destinations"
msgstr "الأهداف السابقة"
@@ -2033,736 +2138,887 @@ msgstr "إنتبه ! آلة تصوير"
msgid "Please decrease your speed"
msgstr "ألرجاء خفض سرعتك"
-msgid "partial match"
-msgstr "تطابق جزئي"
+msgid "Vehicle Position"
+msgstr "موقع وسيلة التنقل"
+
+msgid "Main menu"
+msgstr "اللائحة الرئيسية"
+
+msgid ""
+"Show\n"
+"Map"
+msgstr ""
+"أعرض\n"
+"الخريطة"
+
+msgid "Settings"
+msgstr "الإعدادات"
+
+msgid "Tools"
+msgstr "العدة"
+
+msgid "Route"
+msgstr "الطريق"
+
+msgid "About"
+msgstr "حوْل"
+
+msgid "Quit"
+msgstr "أخرج"
+
+msgid "Actions"
+msgstr "أفعال"
+
+msgid ""
+"Former\n"
+"Destinations"
+msgstr ""
+"الأهداف\n"
+"السابقة"
+
+msgid "Coordinates"
+msgstr "الإحداثيات"
+
+msgid ""
+"Stop\n"
+"Navigation"
+msgstr "قفّ"
+
+msgid "Display"
+msgstr "المظهار"
+
+msgid "Fullscreen"
+msgstr "ملء الشاشة"
+
+msgid "Window Mode"
+msgstr "نمط النافذة"
+
+msgid "Auto zoom"
+msgstr ""
+
+msgid "Manual zoom"
+msgstr ""
+
+msgid "Layers"
+msgstr ""
+
+msgid "Zoom to route"
+msgstr ""
+
+msgid "Description"
+msgstr "الوصف"
+
+msgid ""
+"Drop last\n"
+"Waypoint"
+msgstr ""
+
+msgid ""
+"Drop next\n"
+"Waypoint"
+msgstr ""
+
+msgid "Satellite Status"
+msgstr "حالة القمر الأصطناعي"
+
+msgid "NMEA Data"
+msgstr ""
+
+msgid "car_shortest"
+msgstr ""
+
+msgid "car_avoid_tolls"
+msgstr ""
+
+msgid "car_pedantic"
+msgstr ""
+
+msgid "horse"
+msgstr "خيل/فرس"
+
+msgid "Truck"
+msgstr ""
+
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
+msgstr "نعم"
+
+#. Android resource: @strings/cancel
+msgid "Cancel"
+msgstr "إلغاء"
+
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
+msgstr "نافيت بدء التشغيل"
+
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
+msgstr ""
+
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
+msgstr "مرحبا بك على نافيت"
+
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
+msgstr ""
+
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
+msgstr "موافق"
+
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
+msgstr "المعلومات الإضافية"
+
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
+msgstr "تقريب"
+
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
+msgstr "تبعيد"
+
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
+msgstr "نزل الخرائط"
+
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
+msgstr ""
+
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
+msgstr "أخرج من نافيت"
+
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
+msgstr "النسخ الاحتياطي والاستعادة"
+
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
+msgstr ""
+
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
+msgstr "الطريق إلى هنا"
+
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
+msgstr "حذف هذه الخريطة ؟"
+
+#. Android resource: @strings/map_download_title
+msgid "Map download"
+msgstr "تنزيل الخريطة"
+
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
+msgstr "جاري التنزيل:"
+
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
+msgstr "زمن الوصول المتوقع"
+
+#. Android resource: @strings/map_download_ready
+msgid "ready"
+msgstr "جاهز"
+
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
+msgstr "خطأ عند تنزيل الخريطة."
+
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
+msgstr "تم إجهاض عملية تنزيل الخريطة"
+
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
+msgstr "لا يوجد مجال فارغ كافي"
+
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
+msgstr ""
+
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
+msgstr ""
+
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
+msgstr "الخرائط المحتوية على الموقع الحالي"
+
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
+msgstr ""
+
+#. Android resource: @strings/map_downloading
+msgid "downloading"
+msgstr "يُنزّل"
+
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
+msgstr ""
+
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
+msgstr "خطأ عند كتابة الخريطة!"
+
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
+msgstr ""
+
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
+msgstr ""
+
+#. Android resource: @strings/address_search_title
+msgid "Address search"
+msgstr "البحث عن عنوان"
+
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
+msgstr "أدخل الهدف"
+
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
+msgstr ""
#. Android resource: @strings/address_search_button
msgid "Search"
msgstr "إبحث"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
+msgstr "جاري البحث..."
+
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
+msgstr "لم يعثر على العنوان"
+
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
+msgstr "جاري الحصول على نتائج البحث"
+
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
+msgstr "جاري تحميل نتائج البحث"
+
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
+msgstr "لم يتم العثور على نتائج"
+
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
+msgstr "لم يتم إدخال أي نص"
+
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
+msgstr "جاري تعيين الإتجاه إلى:"
+
#. Android resource: @strings/address_search_towns
msgid "Towns"
msgstr "البلدات"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
+msgstr "اختر فعلاَ"
+
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
+msgstr "الرجاء إدخال رقيقة أس دي"
+
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
+msgstr "جاري النسخ الإحتياطي"
+
+#. Android resource: @strings/restoring
+msgid "Restoring..."
+msgstr "جاري الإستعادة"
+
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
msgstr ""
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
+msgstr "فشل النسخ الإحتياطي"
+
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
+msgstr "لم يعثر على نسخ إحتياطي"
+
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
+msgstr "فشلت في الإستعادة"
+
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
+msgstr "اكتمل النسخ الإحتياطي بنجاح"
+
+#. Android resource: @strings/restore_successful_please_restart_navit
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
-msgid "Downloaded maps"
-msgstr "الخرائط المنزلة"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
+msgstr "لم يعثر على النسخة الإحطياتية"
-msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
msgstr ""
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr "الطريق إلى هنا"
+#. Android resource: @strings/select_backup
+msgid "Select backup"
+msgstr "إختر النسخ الإحتياطي"
-msgid "Cancel"
-msgstr "إلغاء"
+#. Android resource: @strings/backup
+msgid "Backup"
+msgstr "حفظ احتياطي"
+
+#. Android resource: @strings/restore
+msgid "Restore"
+msgstr "استعادة"
-msgid "filenamePath"
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
+msgstr ""
+
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
+#. Android resource: @strings/permissions_not_granted
msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
+msgstr ""
+
+#. Android resource: @strings/whole_planet
msgid "Whole Planet"
msgstr "كامل القرة الأرضية"
+#. Android resource: @strings/africa
msgid "Africa"
msgstr "إفريقيا"
+#. Android resource: @strings/canary_islands
msgid "Canary Islands"
msgstr "جزر الكناري"
+#. Android resource: @strings/asia
msgid "Asia"
msgstr "آسيا"
-msgid "Korea"
-msgstr "كوريا"
-
+#. Android resource: @strings/taiwan
msgid "Taiwan"
msgstr "تايوان"
+#. Android resource: @strings/korea
+msgid "Korea"
+msgstr "كوريا"
+
+#. Android resource: @strings/uae_other
msgid "UAE+Other"
msgstr "الإمارت العرية المتحدة و أخرى"
+#. Android resource: @strings/oceania
msgid "Oceania"
msgstr "أوقيانيا"
+#. Android resource: @strings/tasmania
msgid "Tasmania"
msgstr "تسمانيا"
+#. Android resource: @strings/victoria
msgid "Victoria"
msgstr "فيكتوريا"
+#. Android resource: @strings/new_south_wales
msgid "New South Wales"
msgstr "نيو ساوث ويلز"
+#. Android resource: @strings/europe
msgid "Europe"
msgstr "أوروبا"
+#. Android resource: @strings/western_europe
msgid "Western Europe"
msgstr "أوروبا الغربية"
+#. Android resource: @strings/azores
msgid "Azores"
msgstr "جزر الأزور"
+#. Android resource: @strings/benelux
msgid "BeNeLux"
msgstr "بلجيكا هولاندة اللكسمبرغ"
+#. Android resource: @strings/alsace
msgid "Alsace"
msgstr "الألزاس"
+#. Android resource: @strings/aquitaine
msgid "Aquitaine"
msgstr ""
+#. Android resource: @strings/auvergne
msgid "Auvergne"
msgstr ""
-msgid "Basse-Normandie"
+#. Android resource: @strings/centre
+msgid "Centre"
+msgstr "الوسط"
+
+#. Android resource: @strings/bretagne
+msgid "Bretagne"
msgstr ""
+#. Android resource: @strings/bourgogne
msgid "Bourgogne"
msgstr ""
-msgid "Bretagne"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
msgstr ""
-msgid "Centre"
-msgstr "الوسط"
-
+#. Android resource: @strings/champagne_ardenne
msgid "Champagne-Ardenne"
msgstr ""
+#. Android resource: @strings/corse
msgid "Corse"
msgstr "كورسيكا"
+#. Android resource: @strings/franche_comte
msgid "Franche-Comte"
msgstr ""
+#. Android resource: @strings/haute_normandie
msgid "Haute-Normandie"
msgstr ""
+#. Android resource: @strings/ile_de_france
msgid "Ile-de-France"
msgstr "عاصمة فرنسا و ضواحيها"
+#. Android resource: @strings/languedoc_roussillon
msgid "Languedoc-Roussillon"
msgstr ""
+#. Android resource: @strings/limousin
msgid "Limousin"
msgstr ""
+#. Android resource: @strings/lorraine
msgid "Lorraine"
msgstr ""
+#. Android resource: @strings/midi_pyrenees
msgid "Midi-Pyrenees"
msgstr ""
+#. Android resource: @strings/nord_pas_de_calais
msgid "Nord-pas-de-Calais"
msgstr ""
+#. Android resource: @strings/pays_de_la_loire
msgid "Pays-de-la-Loire"
msgstr ""
+#. Android resource: @strings/picardie
msgid "Picardie"
msgstr "بيكاردي"
+#. Android resource: @strings/poitou_charentes
msgid "Poitou-Charentes"
msgstr "بواتو شارانت"
+#. Android resource: @strings/provence_alpes_cote_d_azur
msgid "Provence-Alpes-Cote-d-Azur"
msgstr ""
+#. Android resource: @strings/rhone_alpes
msgid "Rhone-Alpes"
msgstr "رون-جبال الألب"
+#. Android resource: @strings/baden_wuerttemberg
msgid "Baden-Wuerttemberg"
msgstr "بادن فورتمبيرغ"
+#. Android resource: @strings/bayern
msgid "Bayern"
msgstr "بافاريا"
+#. Android resource: @strings/mittelfranken
msgid "Mittelfranken"
msgstr "فرانكن الوسطى"
+#. Android resource: @strings/niederbayern
msgid "Niederbayern"
msgstr "بافاريا السفلى"
+#. Android resource: @strings/oberbayern
msgid "Oberbayern"
msgstr "بافاريا العليا"
+#. Android resource: @strings/oberfranken
msgid "Oberfranken"
msgstr "فرانكن العليا"
+#. Android resource: @strings/oberpfalz
msgid "Oberpfalz"
msgstr "بفالز العليا"
+#. Android resource: @strings/schwaben
msgid "Schwaben"
msgstr "شفابن"
+#. Android resource: @strings/unterfranken
msgid "Unterfranken"
msgstr "فرانكن السفلى"
+#. Android resource: @strings/berlin
msgid "Berlin"
msgstr "برلين"
+#. Android resource: @strings/brandenburg
msgid "Brandenburg"
msgstr "براندنبورغ"
+#. Android resource: @strings/bremen
msgid "Bremen"
msgstr "بريمن"
+#. Android resource: @strings/hamburg
msgid "Hamburg"
msgstr "هامبرغ"
+#. Android resource: @strings/hessen
msgid "Hessen"
msgstr "هسن"
+#. Android resource: @strings/mecklenburg_vorpommern
msgid "Mecklenburg-Vorpommern"
msgstr "مكليمبورغ-فوربومرن"
+#. Android resource: @strings/niedersachsen
msgid "Niedersachsen"
msgstr "نيدرزاكسن"
+#. Android resource: @strings/nordrhein_westfalen
msgid "Nordrhein-westfalen"
msgstr "نوردراين-فيستفالن"
+#. Android resource: @strings/rheinland_pfalz
msgid "Rheinland-Pfalz"
msgstr "راينلاند-بفالز"
+#. Android resource: @strings/saarland
msgid "Saarland"
msgstr "زارلاند"
+#. Android resource: @strings/sachsen_anhalt
msgid "Sachsen-Anhalt"
msgstr "زاكسن-أنهلت"
+#. Android resource: @strings/sachsen
msgid "Sachsen"
msgstr "ساكسونيا"
+#. Android resource: @strings/schleswig_holstein
msgid "Schleswig-Holstein"
msgstr "شليسفيغ - هولشتاين"
+#. Android resource: @strings/thueringen
msgid "Thueringen"
msgstr "تورينغن"
+#. Android resource: @strings/mallorca
msgid "Mallorca"
msgstr "مايوركا"
+#. Android resource: @strings/galicia
msgid "Galicia"
msgstr "غاليسيا"
+#. Android resource: @strings/scandinavia
msgid "Scandinavia"
msgstr "سكندينافيا"
+#. Android resource: @strings/england
msgid "England"
msgstr "بريطانيا"
+#. Android resource: @strings/buckinghamshire
msgid "Buckinghamshire"
msgstr "باكينجهامشير"
+#. Android resource: @strings/cambridgeshire
msgid "Cambridgeshire"
msgstr "كامبريدجشاير"
+#. Android resource: @strings/cumbria
msgid "Cumbria"
msgstr "كمبريا"
+#. Android resource: @strings/east_yorkshire_with_hull
msgid "East yorkshire with hull"
msgstr ""
+#. Android resource: @strings/essex
msgid "Essex"
msgstr ""
+#. Android resource: @strings/herefordshire
msgid "Herefordshire"
msgstr "هيريفوردشاير"
+#. Android resource: @strings/kent
msgid "Kent"
msgstr "كنت"
+#. Android resource: @strings/lancashire
msgid "Lancashire"
msgstr "لانكشاير"
+#. Android resource: @strings/leicestershire
msgid "Leicestershire"
msgstr "لايسسترشاير"
+#. Android resource: @strings/norfolk
msgid "Norfolk"
msgstr "نورفولك"
+#. Android resource: @strings/nottinghamshire
msgid "Nottinghamshire"
msgstr "نوتينغمشاير"
+#. Android resource: @strings/oxfordshire
msgid "Oxfordshire"
msgstr "أوكسفوردشاير"
+#. Android resource: @strings/shropshire
msgid "Shropshire"
msgstr "شروبشاير"
+#. Android resource: @strings/somerset
msgid "Somerset"
msgstr "سومرست"
+#. Android resource: @strings/south_yorkshire
msgid "South yorkshire"
msgstr "يوركشاير الجنوبية"
+#. Android resource: @strings/suffolk
msgid "Suffolk"
msgstr "سوفولك"
+#. Android resource: @strings/surrey
msgid "Surrey"
msgstr "سورّي"
+#. Android resource: @strings/wiltshire
msgid "Wiltshire"
msgstr "ويلتشايرر"
+#. Android resource: @strings/scotland
msgid "Scotland"
msgstr "أسكتلندا"
+#. Android resource: @strings/wales
msgid "Wales"
msgstr "ويلز"
+#. Android resource: @strings/crete
msgid "Crete"
msgstr "كريتا"
+#. Android resource: @strings/north_america
msgid "North America"
msgstr "أمريكا الشمالية"
+#. Android resource: @strings/alaska
msgid "Alaska"
msgstr "ألاسكا"
+#. Android resource: @strings/hawaii
msgid "Hawaii"
msgstr "هاواي"
+#. Android resource: @strings/usa
msgid "USA"
msgstr "الوﻻيات المتحدة الامريكية"
-msgid " (except Alaska and Hawaii)"
-msgstr " (بدون ألاسكا و هاواي)"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
+msgstr ""
+#. Android resource: @strings/midwest
msgid "Midwest"
msgstr "وسط الغرب"
+#. Android resource: @strings/michigan
msgid "Michigan"
msgstr "ميشيغان"
+#. Android resource: @strings/ohio
msgid "Ohio"
msgstr "أوهايو"
+#. Android resource: @strings/northeast
msgid "Northeast"
msgstr "الشمال الشرقي"
+#. Android resource: @strings/massachusetts
msgid "Massachusetts"
msgstr "ماساتشوستس"
+#. Android resource: @strings/vermont
msgid "Vermont"
msgstr "فيرمونت"
+#. Android resource: @strings/pacific
msgid "Pacific"
msgstr "المحيط الهادئ"
+#. Android resource: @strings/south
msgid "South"
msgstr "الجنوب"
+#. Android resource: @strings/arkansas
msgid "Arkansas"
msgstr "أركنساس"
+#. Android resource: @strings/district_of_columbia
msgid "District of Columbia"
msgstr "مقاطعة كولومبيا"
+#. Android resource: @strings/florida
msgid "Florida"
msgstr "فلوريدا"
+#. Android resource: @strings/louisiana
msgid "Louisiana"
msgstr "لويزيانا"
+#. Android resource: @strings/maryland
msgid "Maryland"
msgstr "ميريلاند"
+#. Android resource: @strings/mississippi
msgid "Mississippi"
msgstr "ميسيسيبي"
+#. Android resource: @strings/oklahoma
msgid "Oklahoma"
msgstr "أوكلاهوما"
+#. Android resource: @strings/texas
msgid "Texas"
msgstr "تكساس"
+#. Android resource: @strings/virginia
msgid "Virginia"
msgstr "فرجينيا"
+#. Android resource: @strings/west_virginia
msgid "West Virginia"
msgstr "غرب فيرجينيا"
+#. Android resource: @strings/west
msgid "West"
msgstr "الغرب"
+#. Android resource: @strings/arizona
msgid "Arizona"
msgstr "أريزونا"
+#. Android resource: @strings/california
msgid "California"
msgstr "كاليفورنيا"
+#. Android resource: @strings/colorado
msgid "Colorado"
msgstr "كولورادو"
+#. Android resource: @strings/idaho
msgid "Idaho"
msgstr "إداهو"
+#. Android resource: @strings/montana
msgid "Montana"
msgstr "مونتانا"
+#. Android resource: @strings/new_mexico
msgid "New Mexico"
msgstr "نيو مكسيكو"
+#. Android resource: @strings/nevada
msgid "Nevada"
msgstr "نيفادا"
+#. Android resource: @strings/oregon
msgid "Oregon"
msgstr "أوريغون"
+#. Android resource: @strings/utah
msgid "Utah"
msgstr "يوتاه"
+#. Android resource: @strings/washington_state
msgid "Washington State"
msgstr "ولاية واشنطن"
+#. Android resource: @strings/south_middle_america
msgid "South+Middle America"
msgstr "جنوب و وسط امريكا"
+#. Android resource: @strings/guyane_francaise
msgid "Guyane Francaise"
msgstr "غويانا الفرنسية"
-msgid "downloading"
-msgstr "يُنزّل"
-
-#. Android resource: @strings/map_download_ready
-msgid "ready"
-msgstr "جاهز"
-
-msgid "Media selected for map storage is not available"
-msgstr ""
-
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
-msgstr "لا يوجد مجال فارغ كافي"
-
-msgid "Error downloading map!"
-msgstr "خطأ أثناء تنزيل الخريطة!"
-
-msgid "Error writing map!"
-msgstr "خطأ عند كتابة الخريطة!"
-
-msgid "Map download aborted!"
-msgstr "تم إجهاض عملية التنزيل للخريطة !"
-
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
-msgstr "زمن الوصول المتوقع"
-
-#. Android resource: @strings/map_download_title
-msgid "Map download"
-msgstr "تنزيل الخريطة"
-
-msgid "Vehicle Position"
-msgstr "موقع وسيلة التنقل"
-
-msgid "Main menu"
-msgstr "اللائحة الرئيسية"
-
-msgid ""
-"Show\n"
-"Map"
-msgstr ""
-"أعرض\n"
-"الخريطة"
-
-msgid "Settings"
-msgstr "الإعدادات"
-
-msgid "Tools"
-msgstr "العدة"
-
-msgid "Route"
-msgstr "الطريق"
-
-msgid "About"
-msgstr "حوْل"
-
-msgid "Quit"
-msgstr "أخرج"
-
-msgid "Actions"
-msgstr "أفعال"
-
-msgid ""
-"Former\n"
-"Destinations"
-msgstr ""
-"الأهداف\n"
-"السابقة"
-
-msgid "Coordinates"
-msgstr "الإحداثيات"
-
-msgid ""
-"Stop\n"
-"Navigation"
-msgstr "قفّ"
-
-msgid "Display"
-msgstr "المظهار"
-
-msgid "Fullscreen"
-msgstr "ملء الشاشة"
-
-msgid "Window Mode"
-msgstr "نمط النافذة"
-
-msgid "Layers"
-msgstr ""
-
-msgid "Description"
-msgstr "الوصف"
-
-msgid ""
-"Drop last \n"
-"Waypoint"
-msgstr ""
-
-msgid ""
-"Drop next \n"
-"Waypoint"
-msgstr ""
-
-msgid "Satellite Status"
-msgstr "حالة القمر الأصطناعي"
-
-msgid "NMEA Data"
-msgstr ""
-
-msgid "car_shortest"
-msgstr ""
-
-msgid "car_avoid_tolls"
-msgstr ""
-
-msgid "car_pedantic"
-msgstr ""
-
-msgid "horse"
-msgstr "خيل/فرس"
-
-msgid "Truck"
-msgstr ""
-
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
-msgstr "نعم"
-
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
-msgstr "نافيت بدء التشغيل"
-
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
-msgstr ""
-
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
-msgstr "مرحبا بك على نافيت"
-
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
-msgstr ""
-
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
-msgstr "موافق"
-
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
-msgstr "المعلومات الإضافية"
-
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
-msgstr "تقريب"
-
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
-msgstr "تبعيد"
-
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
-msgstr "نزل الخرائط"
-
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
-msgstr ""
-
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
-msgstr "أخرج من نافيت"
-
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
-msgstr "النسخ الاحتياطي والاستعادة"
-
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
-msgstr ""
-
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
-msgstr "حذف هذه الخريطة ؟"
-
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
-msgstr "جاري التنزيل:"
-
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
-msgstr "خطأ عند تنزيل الخريطة."
-
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
-msgstr "تم إجهاض عملية تنزيل الخريطة"
-
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
-msgstr ""
-
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
-msgstr "الخرائط المحتوية على الموقع الحالي"
-
-#. Android resource: @strings/address_search_title
-msgid "Address search"
-msgstr "البحث عن عنوان"
-
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
-msgstr "أدخل الهدف"
-
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
-msgstr ""
-
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
-msgstr "جاري البحث..."
-
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
-msgstr "لم يعثر على العنوان"
-
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
-msgstr "جاري الحصول على نتائج البحث"
-
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
-msgstr "جاري تحميل نتائج البحث"
-
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
-msgstr "لم يتم العثور على نتائج"
-
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
-msgstr "لم يتم إدخال أي نص"
-
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
-msgstr "جاري تعيين الإتجاه إلى:"
-
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
-msgstr "اختر فعلاَ"
-
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
-msgstr "الرجاء إدخال رقيقة أس دي"
-
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
-msgstr "جاري النسخ الإحتياطي"
-
-#. Android resource: @strings/restoring
-msgid "Restoring..."
-msgstr "جاري الإستعادة"
-
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
-msgstr ""
-
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
-msgstr "فشل النسخ الإحتياطي"
-
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
-msgstr "لم يعثر على نسخ إحتياطي"
-
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
-msgstr "فشلت في الإستعادة"
-
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
-msgstr "اكتمل النسخ الإحتياطي بنجاح"
-
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
-msgstr ""
-
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
-msgstr "لم يعثر على النسخة الإحطياتية"
-
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
-msgstr ""
+#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Route %4.0fكلم %02d:%02d ETA"
-#. Android resource: @strings/select_backup
-msgid "Select backup"
-msgstr "إختر النسخ الإحتياطي"
+#~ msgid "Downloaded maps"
+#~ msgstr "الخرائط المنزلة"
-#. Android resource: @strings/backup
-msgid "Backup"
-msgstr "حفظ احتياطي"
+#~ msgid "partial match"
+#~ msgstr "تطابق جزئي"
-#. Android resource: @strings/restore
-msgid "Restore"
-msgstr "استعادة"
+#~ msgid " (except Alaska and Hawaii)"
+#~ msgstr " (بدون ألاسكا و هاواي)"
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
-msgstr ""
+#~ msgid "Error downloading map!"
+#~ msgstr "خطأ أثناء تنزيل الخريطة!"
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
-msgstr ""
+#~ msgid "Map download aborted!"
+#~ msgstr "تم إجهاض عملية التنزيل للخريطة !"
#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
diff --git a/po/ast.po.in b/po/ast.po.in
index 02fe9cb07..30c8fbcc1 100644
--- a/po/ast.po.in
+++ b/po/ast.po.in
@@ -1,12 +1,12 @@
# Asturian translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Xuacu Saturio https://launchpad.net/~xuacusk8
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2015-07-19 03:57+0000\n"
"Last-Translator: Xuacu Saturio <xuacusk8@gmail.com>\n"
@@ -150,7 +150,6 @@ msgstr ""
msgid "%1$sonto %2$s|neuter form"
msgstr ""
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr "pal enllaz"
@@ -351,7 +350,7 @@ msgstr "De la vuelta %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "siga"
@@ -363,7 +362,6 @@ msgstr "entós llegará al destín."
msgid "You have reached your destination %s"
msgstr "Llegó al destín %s"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr ""
@@ -380,9 +378,15 @@ msgstr "Comandu"
msgid "Length"
msgstr "Llonxitú"
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr ""
+
msgid "m"
msgstr "m"
@@ -443,6 +447,7 @@ msgid "Anguilla"
msgstr "Anguila"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Albania"
@@ -455,6 +460,7 @@ msgid "Netherlands Antilles"
msgstr "Antilles Holandeses"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Angola"
@@ -463,6 +469,7 @@ msgid "Antarctica"
msgstr "Antártida"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Argentina"
@@ -471,10 +478,12 @@ msgid "American Samoa"
msgstr "Samoa Americana"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Austria"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Australia"
@@ -487,10 +496,12 @@ msgid "Aland Islands"
msgstr "Islles Aland"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Azerbaiyán"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Bosnia Herzegovina"
@@ -503,6 +514,7 @@ msgid "Bangladesh"
msgstr "Bangladesh"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "Bélgica"
@@ -511,6 +523,7 @@ msgid "Burkina Faso"
msgstr "Burkina Faso"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Bulgaria"
@@ -519,6 +532,7 @@ msgid "Bahrain"
msgstr "Bahrein"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Burundi"
@@ -539,6 +553,7 @@ msgid "Brunei Darussalam"
msgstr "Brunei Darussalam"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Bolivia"
@@ -547,6 +562,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr ""
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Brasil"
@@ -563,10 +579,12 @@ msgid "Bouvet Island"
msgstr "Islla Bouvet"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Botswana"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Bielorrusia"
@@ -575,6 +593,7 @@ msgid "Belize"
msgstr "Belice"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Canadá"
@@ -583,6 +602,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Islles Cocos (Keeling)"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Congo, República Democrática del"
@@ -595,10 +615,12 @@ msgid "Congo"
msgstr "Congo"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Suiza"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Costa de Marfil"
@@ -607,6 +629,7 @@ msgid "Cook Islands"
msgstr "Islles Cook"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Chile"
@@ -615,10 +638,12 @@ msgid "Cameroon"
msgstr "Camerún"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "China"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Colombia"
@@ -627,6 +652,7 @@ msgid "Costa Rica"
msgstr "Costa Rica"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Cuba"
@@ -643,14 +669,17 @@ msgid "Christmas Island"
msgstr "Islla Christmas"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Chipre"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "República Checa"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Alemania"
@@ -659,6 +688,7 @@ msgid "Djibouti"
msgstr "Djibouti"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Dinamarca"
@@ -667,6 +697,7 @@ msgid "Dominica"
msgstr "Dominica"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "República Dominicana"
@@ -675,10 +706,12 @@ msgid "Algeria"
msgstr "Argelia"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Ecuador"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Estonia"
@@ -695,14 +728,17 @@ msgid "Eritrea"
msgstr "Eritrea"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "España"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Etiopía"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Finlandia"
@@ -719,10 +755,12 @@ msgid "Micronesia, Federated States of"
msgstr "Micronesia, Estaos Federaos de"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Islles Feroe"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "Francia"
@@ -731,6 +769,7 @@ msgid "Gabon"
msgstr "Gabón"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Reinu Xuníu"
@@ -767,6 +806,7 @@ msgid "Gambia"
msgstr "Gambia"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Guinea"
@@ -779,6 +819,7 @@ msgid "Equatorial Guinea"
msgstr "Guinea Ecuatorial"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Grecia"
@@ -799,6 +840,7 @@ msgid "Guinea-Bissau"
msgstr "Guinea-Bissau"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Guyana"
@@ -815,26 +857,32 @@ msgid "Honduras"
msgstr "Honduras"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Croacia"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Haití"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Hungría"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Indonesia"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Irlanda"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Israel"
@@ -843,6 +891,7 @@ msgid "Isle of Man"
msgstr "Islla de Man"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "India"
@@ -851,18 +900,22 @@ msgid "British Indian Ocean Territory"
msgstr "Territoriu Oceánicu de la India Británica"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Iraq"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Irán, República Islámica de"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Islandia"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Italia"
@@ -871,6 +924,7 @@ msgid "Jersey"
msgstr "Jersey"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Jamaica"
@@ -879,14 +933,17 @@ msgid "Jordan"
msgstr "Xordania"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Xapón"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Kenia"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Kirguistán"
@@ -923,6 +980,7 @@ msgid "Cayman Islands"
msgstr "Islles Caimán"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Kazakhstán"
@@ -947,26 +1005,32 @@ msgid "Sri Lanka"
msgstr "Sri Lanka"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Liberia"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Lesotho"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Lituania"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Luxemburgo"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Letonia"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr ""
@@ -991,6 +1055,7 @@ msgid "Saint Martin (French part)"
msgstr "Saint Martin (Parte Francesa)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Madagascar"
@@ -1011,6 +1076,7 @@ msgid "Myanmar"
msgstr "Myanmar"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Mongolia"
@@ -1051,10 +1117,12 @@ msgid "Malawi"
msgstr "Malawi"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "México"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Malasia"
@@ -1063,10 +1131,12 @@ msgid "Mozambique"
msgstr "Mozambique"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Namibia"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Nueva Caledonia"
@@ -1087,6 +1157,7 @@ msgid "Nicaragua"
msgstr "Nicaragua"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Holanda"
@@ -1095,6 +1166,7 @@ msgid "Norway"
msgstr "Noruega"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Nepal"
@@ -1107,6 +1179,7 @@ msgid "Niue"
msgstr "Niue"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Nueva Zelanda"
@@ -1119,6 +1192,7 @@ msgid "Panama"
msgstr "Panamá"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Perú"
@@ -1131,14 +1205,17 @@ msgid "Papua New Guinea"
msgstr "Papúa Nueva Guinea"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Filipines"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Paquistán"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Polonia"
@@ -1159,6 +1236,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Palestina, Territoriu Ocupáu"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Portugal"
@@ -1167,6 +1245,7 @@ msgid "Palau"
msgstr "Palau"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Paraguay"
@@ -1175,10 +1254,12 @@ msgid "Qatar"
msgstr "Qatar"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Reunión"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Rumanía"
@@ -1187,14 +1268,17 @@ msgid "Serbia"
msgstr "Serbia"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Federación Rusa"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Ruanda"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Arabia Saudí"
@@ -1215,6 +1299,7 @@ msgid "Sweden"
msgstr "Suecia"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Singapur"
@@ -1231,6 +1316,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Svalbard y Jan Mayen"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Eslovaquia"
@@ -1251,6 +1337,7 @@ msgid "Somalia"
msgstr "Somalia"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Surinam"
@@ -1295,6 +1382,7 @@ msgid "Togo"
msgstr "Togo"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Tailandia"
@@ -1311,6 +1399,7 @@ msgid "Timor-Leste"
msgstr "Timor Oriental"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Turkmenistán"
@@ -1323,6 +1412,7 @@ msgid "Tonga"
msgstr "Tonga"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Turquía"
@@ -1339,14 +1429,17 @@ msgid "Taiwan, Province of China"
msgstr "Taiwan, Provincia de China"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Tanzania, República Xunía de"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Ucrania"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Uganda"
@@ -1359,6 +1452,7 @@ msgid "United States"
msgstr "Estaos Xuníos"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Uruguay"
@@ -1375,6 +1469,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "San Vicente y les Granadines"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Venezuela"
@@ -1411,6 +1506,7 @@ msgid "Mayotte"
msgstr "Mayotte"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "Sudáfrica"
@@ -1438,23 +1534,23 @@ msgid ""
msgstr ""
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
+msgid "No config file navit.xml, navit.xml.local found"
msgstr ""
#, c-format
-msgid "Error parsing config file '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
+msgid "Using config file '%s'"
msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
msgstr ""
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
msgid "unknown street"
@@ -1595,6 +1691,9 @@ msgstr ""
msgid "_Lock on Road"
msgstr "Arcoxar carretera"
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr ""
@@ -1664,7 +1763,12 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
msgstr ""
#, c-format
@@ -1672,15 +1776,15 @@ msgid "POI %s. %s"
msgstr ""
#, c-format
-msgid "Set destination to %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
+msgid "Set map to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
msgstr ""
msgid "POI search"
@@ -1689,9 +1793,6 @@ msgstr ""
msgid "Select a category"
msgstr ""
-msgid "Select a distance to look for (km)"
-msgstr ""
-
msgid "Select a POI"
msgstr ""
@@ -1704,7 +1805,7 @@ msgstr ""
msgid "Direction"
msgstr ""
-msgid "Distance(m)"
+msgid "Distance"
msgstr ""
msgid "Name"
@@ -1751,8 +1852,8 @@ msgid "OT"
msgstr "OT"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Ruta %4.0fkm %02d:%02d TED"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "Ruta 0000km 0+00:00 TED"
@@ -1923,10 +2024,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1974,6 +2075,9 @@ msgstr "Descripción de ruta"
msgid "Show Locale"
msgstr "Amosar local"
+msgid "Network info"
+msgstr ""
+
msgid "Former Destinations"
msgstr "Destinos anteriores"
@@ -2012,737 +2116,873 @@ msgstr ""
msgid "Please decrease your speed"
msgstr ""
-msgid "partial match"
-msgstr ""
+msgid "Vehicle Position"
+msgstr "Posición del vehículu"
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr ""
+msgid "Main menu"
+msgstr "Menú principal"
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
+msgid ""
+"Show\n"
+"Map"
msgstr ""
+"Ver\n"
+"Mapa"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr ""
+msgid "Settings"
+msgstr "Axustes"
+
+msgid "Tools"
+msgstr "Ferramientes"
+
+msgid "Route"
+msgstr "Ruta"
+
+msgid "About"
+msgstr "Tocante a"
+
+msgid "Quit"
+msgstr "Colar"
+
+msgid "Actions"
+msgstr "Aiciones"
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Former\n"
+"Destinations"
msgstr ""
-msgid "Downloaded maps"
+msgid "Coordinates"
msgstr ""
msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+"Stop\n"
+"Navigation"
msgstr ""
+"Parar\n"
+"Navegación"
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr ""
+msgid "Display"
+msgstr "Amosar"
-msgid "Cancel"
-msgstr ""
+msgid "Fullscreen"
+msgstr "Pantalla completa"
-msgid "filenamePath"
-msgstr ""
+msgid "Window Mode"
+msgstr "Mou ventana"
-msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+msgid "Auto zoom"
msgstr ""
-msgid "Whole Planet"
+msgid "Manual zoom"
msgstr ""
-msgid "Africa"
+msgid "Layers"
msgstr ""
-msgid "Canary Islands"
+msgid "Zoom to route"
msgstr ""
-msgid "Asia"
-msgstr ""
+msgid "Description"
+msgstr "Descripción"
-msgid "Korea"
+msgid ""
+"Drop last\n"
+"Waypoint"
msgstr ""
-msgid "Taiwan"
+msgid ""
+"Drop next\n"
+"Waypoint"
msgstr ""
-msgid "UAE+Other"
+msgid "Satellite Status"
msgstr ""
-msgid "Oceania"
+msgid "NMEA Data"
msgstr ""
-msgid "Tasmania"
+msgid "car_shortest"
msgstr ""
-msgid "Victoria"
+msgid "car_avoid_tolls"
msgstr ""
-msgid "New South Wales"
+msgid "car_pedantic"
msgstr ""
-msgid "Europe"
-msgstr ""
+msgid "horse"
+msgstr "caballu"
-msgid "Western Europe"
+msgid "Truck"
msgstr ""
-msgid "Azores"
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
msgstr ""
-msgid "BeNeLux"
+#. Android resource: @strings/cancel
+msgid "Cancel"
msgstr ""
-msgid "Alsace"
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
msgstr ""
-msgid "Aquitaine"
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
msgstr ""
-msgid "Auvergne"
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
msgstr ""
-msgid "Basse-Normandie"
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
msgstr ""
-msgid "Bourgogne"
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
msgstr ""
-msgid "Bretagne"
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
msgstr ""
-msgid "Centre"
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
msgstr ""
-msgid "Champagne-Ardenne"
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
msgstr ""
-msgid "Corse"
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
msgstr ""
-msgid "Franche-Comte"
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
msgstr ""
-msgid "Haute-Normandie"
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
msgstr ""
-msgid "Ile-de-France"
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
msgstr ""
-msgid "Languedoc-Roussillon"
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
msgstr ""
-msgid "Limousin"
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
msgstr ""
-msgid "Lorraine"
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
msgstr ""
-msgid "Midi-Pyrenees"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
msgstr ""
-msgid "Nord-pas-de-Calais"
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
msgstr ""
-msgid "Pays-de-la-Loire"
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
msgstr ""
-msgid "Picardie"
+#. Android resource: @strings/map_download_ready
+msgid "ready"
msgstr ""
-msgid "Poitou-Charentes"
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
msgstr ""
-msgid "Provence-Alpes-Cote-d-Azur"
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
msgstr ""
-msgid "Rhone-Alpes"
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
msgstr ""
-msgid "Baden-Wuerttemberg"
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
msgstr ""
-msgid "Bayern"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
msgstr ""
-msgid "Mittelfranken"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
msgstr ""
-msgid "Niederbayern"
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
msgstr ""
-msgid "Oberbayern"
+#. Android resource: @strings/map_downloading
+msgid "downloading"
msgstr ""
-msgid "Oberfranken"
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
msgstr ""
-msgid "Oberpfalz"
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
msgstr ""
-msgid "Schwaben"
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
msgstr ""
-msgid "Unterfranken"
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
msgstr ""
-msgid "Berlin"
+#. Android resource: @strings/address_search_title
+msgid "Address search"
msgstr ""
-msgid "Brandenburg"
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
msgstr ""
-msgid "Bremen"
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
msgstr ""
-msgid "Hamburg"
+#. Android resource: @strings/address_search_button
+msgid "Search"
msgstr ""
-msgid "Hessen"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
msgstr ""
-msgid "Mecklenburg-Vorpommern"
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
msgstr ""
-msgid "Niedersachsen"
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
msgstr ""
-msgid "Nordrhein-westfalen"
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
msgstr ""
-msgid "Rheinland-Pfalz"
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
msgstr ""
-msgid "Saarland"
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
msgstr ""
-msgid "Sachsen-Anhalt"
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
msgstr ""
-msgid "Sachsen"
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
msgstr ""
-msgid "Schleswig-Holstein"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
msgstr ""
-msgid "Thueringen"
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
msgstr ""
-msgid "Mallorca"
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
msgstr ""
-msgid "Galicia"
+#. Android resource: @strings/restoring
+msgid "Restoring..."
msgstr ""
-msgid "Scandinavia"
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
msgstr ""
-msgid "England"
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
msgstr ""
-msgid "Buckinghamshire"
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
msgstr ""
-msgid "Cambridgeshire"
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
msgstr ""
-msgid "Cumbria"
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
msgstr ""
-msgid "East yorkshire with hull"
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
-msgid "Essex"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
msgstr ""
-msgid "Herefordshire"
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
msgstr ""
-msgid "Kent"
+#. Android resource: @strings/select_backup
+msgid "Select backup"
msgstr ""
-msgid "Lancashire"
+#. Android resource: @strings/backup
+msgid "Backup"
msgstr ""
-msgid "Leicestershire"
+#. Android resource: @strings/restore
+msgid "Restore"
msgstr ""
-msgid "Norfolk"
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
msgstr ""
-msgid "Nottinghamshire"
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
-msgid "Oxfordshire"
+#. Android resource: @strings/permissions_not_granted
+msgid ""
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
-msgid "Shropshire"
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
msgstr ""
-msgid "Somerset"
+#. Android resource: @strings/whole_planet
+msgid "Whole Planet"
msgstr ""
-msgid "South yorkshire"
+#. Android resource: @strings/africa
+msgid "Africa"
msgstr ""
-msgid "Suffolk"
+#. Android resource: @strings/canary_islands
+msgid "Canary Islands"
msgstr ""
-msgid "Surrey"
+#. Android resource: @strings/asia
+msgid "Asia"
msgstr ""
-msgid "Wiltshire"
+#. Android resource: @strings/taiwan
+msgid "Taiwan"
msgstr ""
-msgid "Scotland"
+#. Android resource: @strings/korea
+msgid "Korea"
msgstr ""
-msgid "Wales"
+#. Android resource: @strings/uae_other
+msgid "UAE+Other"
msgstr ""
-msgid "Crete"
+#. Android resource: @strings/oceania
+msgid "Oceania"
msgstr ""
-msgid "North America"
+#. Android resource: @strings/tasmania
+msgid "Tasmania"
msgstr ""
-msgid "Alaska"
+#. Android resource: @strings/victoria
+msgid "Victoria"
msgstr ""
-msgid "Hawaii"
+#. Android resource: @strings/new_south_wales
+msgid "New South Wales"
msgstr ""
-msgid "USA"
+#. Android resource: @strings/europe
+msgid "Europe"
msgstr ""
-msgid " (except Alaska and Hawaii)"
+#. Android resource: @strings/western_europe
+msgid "Western Europe"
msgstr ""
-msgid "Midwest"
+#. Android resource: @strings/azores
+msgid "Azores"
msgstr ""
-msgid "Michigan"
+#. Android resource: @strings/benelux
+msgid "BeNeLux"
msgstr ""
-msgid "Ohio"
+#. Android resource: @strings/alsace
+msgid "Alsace"
msgstr ""
-msgid "Northeast"
+#. Android resource: @strings/aquitaine
+msgid "Aquitaine"
msgstr ""
-msgid "Massachusetts"
+#. Android resource: @strings/auvergne
+msgid "Auvergne"
msgstr ""
-msgid "Vermont"
+#. Android resource: @strings/centre
+msgid "Centre"
msgstr ""
-msgid "Pacific"
+#. Android resource: @strings/bretagne
+msgid "Bretagne"
msgstr ""
-msgid "South"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
msgstr ""
-msgid "Arkansas"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
msgstr ""
-msgid "District of Columbia"
+#. Android resource: @strings/champagne_ardenne
+msgid "Champagne-Ardenne"
msgstr ""
-msgid "Florida"
+#. Android resource: @strings/corse
+msgid "Corse"
msgstr ""
-msgid "Louisiana"
+#. Android resource: @strings/franche_comte
+msgid "Franche-Comte"
msgstr ""
-msgid "Maryland"
+#. Android resource: @strings/haute_normandie
+msgid "Haute-Normandie"
msgstr ""
-msgid "Mississippi"
+#. Android resource: @strings/ile_de_france
+msgid "Ile-de-France"
msgstr ""
-msgid "Oklahoma"
+#. Android resource: @strings/languedoc_roussillon
+msgid "Languedoc-Roussillon"
msgstr ""
-msgid "Texas"
+#. Android resource: @strings/limousin
+msgid "Limousin"
msgstr ""
-msgid "Virginia"
+#. Android resource: @strings/lorraine
+msgid "Lorraine"
msgstr ""
-msgid "West Virginia"
+#. Android resource: @strings/midi_pyrenees
+msgid "Midi-Pyrenees"
msgstr ""
-msgid "West"
+#. Android resource: @strings/nord_pas_de_calais
+msgid "Nord-pas-de-Calais"
msgstr ""
-msgid "Arizona"
+#. Android resource: @strings/pays_de_la_loire
+msgid "Pays-de-la-Loire"
msgstr ""
-msgid "California"
+#. Android resource: @strings/picardie
+msgid "Picardie"
msgstr ""
-msgid "Colorado"
+#. Android resource: @strings/poitou_charentes
+msgid "Poitou-Charentes"
msgstr ""
-msgid "Idaho"
+#. Android resource: @strings/provence_alpes_cote_d_azur
+msgid "Provence-Alpes-Cote-d-Azur"
msgstr ""
-msgid "Montana"
+#. Android resource: @strings/rhone_alpes
+msgid "Rhone-Alpes"
msgstr ""
-msgid "New Mexico"
+#. Android resource: @strings/baden_wuerttemberg
+msgid "Baden-Wuerttemberg"
msgstr ""
-msgid "Nevada"
+#. Android resource: @strings/bayern
+msgid "Bayern"
msgstr ""
-msgid "Oregon"
+#. Android resource: @strings/mittelfranken
+msgid "Mittelfranken"
msgstr ""
-msgid "Utah"
+#. Android resource: @strings/niederbayern
+msgid "Niederbayern"
msgstr ""
-msgid "Washington State"
+#. Android resource: @strings/oberbayern
+msgid "Oberbayern"
msgstr ""
-msgid "South+Middle America"
+#. Android resource: @strings/oberfranken
+msgid "Oberfranken"
msgstr ""
-msgid "Guyane Francaise"
+#. Android resource: @strings/oberpfalz
+msgid "Oberpfalz"
msgstr ""
-msgid "downloading"
+#. Android resource: @strings/schwaben
+msgid "Schwaben"
msgstr ""
-#. Android resource: @strings/map_download_ready
-msgid "ready"
+#. Android resource: @strings/unterfranken
+msgid "Unterfranken"
msgstr ""
-msgid "Media selected for map storage is not available"
+#. Android resource: @strings/berlin
+msgid "Berlin"
msgstr ""
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
+#. Android resource: @strings/brandenburg
+msgid "Brandenburg"
msgstr ""
-msgid "Error downloading map!"
+#. Android resource: @strings/bremen
+msgid "Bremen"
msgstr ""
-msgid "Error writing map!"
+#. Android resource: @strings/hamburg
+msgid "Hamburg"
msgstr ""
-msgid "Map download aborted!"
+#. Android resource: @strings/hessen
+msgid "Hessen"
msgstr ""
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
+#. Android resource: @strings/mecklenburg_vorpommern
+msgid "Mecklenburg-Vorpommern"
msgstr ""
-#. Android resource: @strings/map_download_title
-msgid "Map download"
+#. Android resource: @strings/niedersachsen
+msgid "Niedersachsen"
msgstr ""
-msgid "Vehicle Position"
-msgstr "Posición del vehículu"
-
-msgid "Main menu"
-msgstr "Menú principal"
-
-msgid ""
-"Show\n"
-"Map"
+#. Android resource: @strings/nordrhein_westfalen
+msgid "Nordrhein-westfalen"
msgstr ""
-"Ver\n"
-"Mapa"
-
-msgid "Settings"
-msgstr "Axustes"
-
-msgid "Tools"
-msgstr "Ferramientes"
-
-msgid "Route"
-msgstr "Ruta"
-msgid "About"
-msgstr "Tocante a"
+#. Android resource: @strings/rheinland_pfalz
+msgid "Rheinland-Pfalz"
+msgstr ""
-msgid "Quit"
-msgstr "Colar"
+#. Android resource: @strings/saarland
+msgid "Saarland"
+msgstr ""
-msgid "Actions"
-msgstr "Aiciones"
+#. Android resource: @strings/sachsen_anhalt
+msgid "Sachsen-Anhalt"
+msgstr ""
-msgid ""
-"Former\n"
-"Destinations"
+#. Android resource: @strings/sachsen
+msgid "Sachsen"
msgstr ""
-msgid "Coordinates"
+#. Android resource: @strings/schleswig_holstein
+msgid "Schleswig-Holstein"
msgstr ""
-msgid ""
-"Stop\n"
-"Navigation"
+#. Android resource: @strings/thueringen
+msgid "Thueringen"
msgstr ""
-"Parar\n"
-"Navegación"
-msgid "Display"
-msgstr "Amosar"
+#. Android resource: @strings/mallorca
+msgid "Mallorca"
+msgstr ""
-msgid "Fullscreen"
-msgstr "Pantalla completa"
+#. Android resource: @strings/galicia
+msgid "Galicia"
+msgstr ""
-msgid "Window Mode"
-msgstr "Mou ventana"
+#. Android resource: @strings/scandinavia
+msgid "Scandinavia"
+msgstr ""
-msgid "Layers"
+#. Android resource: @strings/england
+msgid "England"
msgstr ""
-msgid "Description"
-msgstr "Descripción"
+#. Android resource: @strings/buckinghamshire
+msgid "Buckinghamshire"
+msgstr ""
-msgid ""
-"Drop last \n"
-"Waypoint"
+#. Android resource: @strings/cambridgeshire
+msgid "Cambridgeshire"
msgstr ""
-msgid ""
-"Drop next \n"
-"Waypoint"
+#. Android resource: @strings/cumbria
+msgid "Cumbria"
msgstr ""
-msgid "Satellite Status"
+#. Android resource: @strings/east_yorkshire_with_hull
+msgid "East yorkshire with hull"
msgstr ""
-msgid "NMEA Data"
+#. Android resource: @strings/essex
+msgid "Essex"
msgstr ""
-msgid "car_shortest"
+#. Android resource: @strings/herefordshire
+msgid "Herefordshire"
msgstr ""
-msgid "car_avoid_tolls"
+#. Android resource: @strings/kent
+msgid "Kent"
msgstr ""
-msgid "car_pedantic"
+#. Android resource: @strings/lancashire
+msgid "Lancashire"
msgstr ""
-msgid "horse"
-msgstr "caballu"
+#. Android resource: @strings/leicestershire
+msgid "Leicestershire"
+msgstr ""
-msgid "Truck"
+#. Android resource: @strings/norfolk
+msgid "Norfolk"
msgstr ""
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
+#. Android resource: @strings/nottinghamshire
+msgid "Nottinghamshire"
msgstr ""
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
+#. Android resource: @strings/oxfordshire
+msgid "Oxfordshire"
msgstr ""
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
+#. Android resource: @strings/shropshire
+msgid "Shropshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
+#. Android resource: @strings/somerset
+msgid "Somerset"
msgstr ""
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
+#. Android resource: @strings/south_yorkshire
+msgid "South yorkshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
+#. Android resource: @strings/suffolk
+msgid "Suffolk"
msgstr ""
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
+#. Android resource: @strings/surrey
+msgid "Surrey"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
+#. Android resource: @strings/wiltshire
+msgid "Wiltshire"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
+#. Android resource: @strings/scotland
+msgid "Scotland"
msgstr ""
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
+#. Android resource: @strings/wales
+msgid "Wales"
msgstr ""
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
+#. Android resource: @strings/crete
+msgid "Crete"
msgstr ""
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
+#. Android resource: @strings/north_america
+msgid "North America"
msgstr ""
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
+#. Android resource: @strings/alaska
+msgid "Alaska"
msgstr ""
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
+#. Android resource: @strings/hawaii
+msgid "Hawaii"
msgstr ""
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
+#. Android resource: @strings/usa
+msgid "USA"
msgstr ""
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
msgstr ""
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
+#. Android resource: @strings/midwest
+msgid "Midwest"
msgstr ""
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
+#. Android resource: @strings/michigan
+msgid "Michigan"
msgstr ""
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
+#. Android resource: @strings/ohio
+msgid "Ohio"
msgstr ""
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
+#. Android resource: @strings/northeast
+msgid "Northeast"
msgstr ""
-#. Android resource: @strings/address_search_title
-msgid "Address search"
+#. Android resource: @strings/massachusetts
+msgid "Massachusetts"
msgstr ""
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
+#. Android resource: @strings/vermont
+msgid "Vermont"
msgstr ""
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
+#. Android resource: @strings/pacific
+msgid "Pacific"
msgstr ""
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
+#. Android resource: @strings/south
+msgid "South"
msgstr ""
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
+#. Android resource: @strings/arkansas
+msgid "Arkansas"
msgstr ""
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
+#. Android resource: @strings/district_of_columbia
+msgid "District of Columbia"
msgstr ""
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
+#. Android resource: @strings/florida
+msgid "Florida"
msgstr ""
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
+#. Android resource: @strings/louisiana
+msgid "Louisiana"
msgstr ""
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
+#. Android resource: @strings/maryland
+msgid "Maryland"
msgstr ""
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
+#. Android resource: @strings/mississippi
+msgid "Mississippi"
msgstr ""
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
+#. Android resource: @strings/oklahoma
+msgid "Oklahoma"
msgstr ""
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
+#. Android resource: @strings/texas
+msgid "Texas"
msgstr ""
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
+#. Android resource: @strings/virginia
+msgid "Virginia"
msgstr ""
-#. Android resource: @strings/restoring
-msgid "Restoring..."
+#. Android resource: @strings/west_virginia
+msgid "West Virginia"
msgstr ""
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
+#. Android resource: @strings/west
+msgid "West"
msgstr ""
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
+#. Android resource: @strings/arizona
+msgid "Arizona"
msgstr ""
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
+#. Android resource: @strings/california
+msgid "California"
msgstr ""
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
+#. Android resource: @strings/colorado
+msgid "Colorado"
msgstr ""
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
+#. Android resource: @strings/idaho
+msgid "Idaho"
msgstr ""
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
+#. Android resource: @strings/montana
+msgid "Montana"
msgstr ""
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
+#. Android resource: @strings/new_mexico
+msgid "New Mexico"
msgstr ""
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
+#. Android resource: @strings/nevada
+msgid "Nevada"
msgstr ""
-#. Android resource: @strings/select_backup
-msgid "Select backup"
+#. Android resource: @strings/oregon
+msgid "Oregon"
msgstr ""
-#. Android resource: @strings/backup
-msgid "Backup"
+#. Android resource: @strings/utah
+msgid "Utah"
msgstr ""
-#. Android resource: @strings/restore
-msgid "Restore"
+#. Android resource: @strings/washington_state
+msgid "Washington State"
msgstr ""
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
+#. Android resource: @strings/south_middle_america
+msgid "South+Middle America"
msgstr ""
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
+#. Android resource: @strings/guyane_francaise
+msgid "Guyane Francaise"
msgstr ""
#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Ruta %4.0fkm %02d:%02d TED"
+
+#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
#~ msgstr "llueu dexe la rotonda pola %1$s %2$s"
diff --git a/po/be.po.in b/po/be.po.in
index 561f630f7..43365f0a2 100644
--- a/po/be.po.in
+++ b/po/be.po.in
@@ -1,5 +1,5 @@
# Belarusian translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Anatoli Putseyeu https://launchpad.net/~st-shadow-by
@@ -8,7 +8,7 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2015-07-19 03:57+0000\n"
"Last-Translator: Michael von Glasow <Unknown>\n"
@@ -153,7 +153,6 @@ msgstr ""
msgid "%1$sonto %2$s|neuter form"
msgstr ""
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr ""
@@ -354,7 +353,7 @@ msgstr "Развярніцеся %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -366,7 +365,6 @@ msgstr ""
msgid "You have reached your destination %s"
msgstr ""
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr ""
@@ -383,9 +381,15 @@ msgstr ""
msgid "Length"
msgstr "Працягласць"
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr "км"
+msgid "feet"
+msgstr ""
+
msgid "m"
msgstr "м"
@@ -446,6 +450,7 @@ msgid "Anguilla"
msgstr "Ангілья"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Албанія"
@@ -458,6 +463,7 @@ msgid "Netherlands Antilles"
msgstr "Нідэрландскія Антыльскія астравы"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Ангола"
@@ -466,6 +472,7 @@ msgid "Antarctica"
msgstr "Антарктыда"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Аргенціна"
@@ -474,10 +481,12 @@ msgid "American Samoa"
msgstr "Усходняе Самоа"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Аўстрыя"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Аўстралія"
@@ -490,10 +499,12 @@ msgid "Aland Islands"
msgstr "Аландскія астравы"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Азербайджан"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Боснія і Герцагавіна"
@@ -506,6 +517,7 @@ msgid "Bangladesh"
msgstr "Бангладэш"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "Бельгія"
@@ -514,6 +526,7 @@ msgid "Burkina Faso"
msgstr "Буркіна Фасо"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Балгарыя"
@@ -522,6 +535,7 @@ msgid "Bahrain"
msgstr "Бахрэйн"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Бурундзі"
@@ -542,6 +556,7 @@ msgid "Brunei Darussalam"
msgstr "Брунэй Даруссалам"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Балівія"
@@ -550,6 +565,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr ""
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Бразілія"
@@ -566,10 +582,12 @@ msgid "Bouvet Island"
msgstr "Востраў Буве"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Батсвана"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Беларусь"
@@ -578,6 +596,7 @@ msgid "Belize"
msgstr "Бэліз"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Канада"
@@ -586,6 +605,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Какосавыя (Кілінг) астравы"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Дэмакратычная Рэспубліка Конга"
@@ -598,10 +618,12 @@ msgid "Congo"
msgstr "Конга"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Швейцарыя"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Кот д'Івуар"
@@ -610,6 +632,7 @@ msgid "Cook Islands"
msgstr "Астравы Кука"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Чылі"
@@ -618,10 +641,12 @@ msgid "Cameroon"
msgstr "Камерун"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "Кітай"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Калумбія"
@@ -630,6 +655,7 @@ msgid "Costa Rica"
msgstr "Коста Рыка"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Куба"
@@ -646,14 +672,17 @@ msgid "Christmas Island"
msgstr "Востраў Раства"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Кіпр"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "Чэшская рэспубліка"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Германія"
@@ -662,6 +691,7 @@ msgid "Djibouti"
msgstr "Джыбуці"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Данія"
@@ -670,6 +700,7 @@ msgid "Dominica"
msgstr "Дамініка"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "Дамініканская Рэспубліка"
@@ -678,10 +709,12 @@ msgid "Algeria"
msgstr "Алжыр"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Эквадор"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Эстонія"
@@ -698,14 +731,17 @@ msgid "Eritrea"
msgstr "Эрытрэя"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Іспанія"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Эфіопія"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Фінляндыя"
@@ -722,10 +758,12 @@ msgid "Micronesia, Federated States of"
msgstr "Фэдэратыўныя Штаты Мікранэзіі"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Фарэрскія астравы"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "Францыя"
@@ -734,6 +772,7 @@ msgid "Gabon"
msgstr "Габон"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Вялікабрытанія"
@@ -770,6 +809,7 @@ msgid "Gambia"
msgstr "Гамбія"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Гвінея"
@@ -782,6 +822,7 @@ msgid "Equatorial Guinea"
msgstr "Экватарыяльная Гвінея"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Грэцыя"
@@ -802,6 +843,7 @@ msgid "Guinea-Bissau"
msgstr "Гвінея-Бісаў"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Гаяна"
@@ -818,26 +860,32 @@ msgid "Honduras"
msgstr "Гандурас"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Харватыя"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Гаіці"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Венгрыя"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Інданэзія"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Ірландыя"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Ізраіль"
@@ -846,6 +894,7 @@ msgid "Isle of Man"
msgstr "Востраў Мэн"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "Індыя"
@@ -854,18 +903,22 @@ msgid "British Indian Ocean Territory"
msgstr "Брытанская тэрыторыя ў Індыйскім акіяне"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Ірак"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Ісламская Рэспубліка Іран"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Ісландыя"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Італія"
@@ -874,6 +927,7 @@ msgid "Jersey"
msgstr "Джэрсі"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Ямайка"
@@ -882,14 +936,17 @@ msgid "Jordan"
msgstr "Іарданія"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Японія"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Кенія"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Кыргыстан"
@@ -926,6 +983,7 @@ msgid "Cayman Islands"
msgstr "Кайманавы астравы"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Казахстан"
@@ -950,26 +1008,32 @@ msgid "Sri Lanka"
msgstr "Шры-Ланка"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Ліберыя"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Лесота"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Літва"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Люксембург"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Латвія"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr ""
@@ -994,6 +1058,7 @@ msgid "Saint Martin (French part)"
msgstr "Сэнт-Марцін (французская частка)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Мадагаскар"
@@ -1014,6 +1079,7 @@ msgid "Myanmar"
msgstr "М'янма"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Манголія"
@@ -1054,10 +1120,12 @@ msgid "Malawi"
msgstr "Малаві"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "Мексіка"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Малайзія"
@@ -1066,10 +1134,12 @@ msgid "Mozambique"
msgstr "Мазамбік"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Намібія"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Новая Каледонія"
@@ -1090,6 +1160,7 @@ msgid "Nicaragua"
msgstr "Нікарагуа"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Нідэрланды"
@@ -1098,6 +1169,7 @@ msgid "Norway"
msgstr "Нарвегія"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Нэпал"
@@ -1110,6 +1182,7 @@ msgid "Niue"
msgstr "Ніуе"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Новая Зеландыя"
@@ -1122,6 +1195,7 @@ msgid "Panama"
msgstr "Панама"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Перу"
@@ -1134,14 +1208,17 @@ msgid "Papua New Guinea"
msgstr "Папуа–Новая Гвінэя"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Філіпіны"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Пакістан"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Польшча"
@@ -1162,6 +1239,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Палестынская тэрыторыя, акупаваная"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Партугалія"
@@ -1170,6 +1248,7 @@ msgid "Palau"
msgstr "Палау"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Парагвай"
@@ -1178,10 +1257,12 @@ msgid "Qatar"
msgstr "Катар"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Рэюньён"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Румынія"
@@ -1190,14 +1271,17 @@ msgid "Serbia"
msgstr "Сербія"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Расійская Федэрацыя"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Руанда"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Саудаўская Аравія"
@@ -1218,6 +1302,7 @@ msgid "Sweden"
msgstr "Швецыя"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Сінгапур"
@@ -1234,6 +1319,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Шпіцбэрген і Ян-Майен"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Славакія"
@@ -1254,6 +1340,7 @@ msgid "Somalia"
msgstr "Самалі"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Сурынам"
@@ -1298,6 +1385,7 @@ msgid "Togo"
msgstr "Тога"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Тайланд"
@@ -1314,6 +1402,7 @@ msgid "Timor-Leste"
msgstr "Тымор-Лестэ"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Туркменістан"
@@ -1326,6 +1415,7 @@ msgid "Tonga"
msgstr "Тонга"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Турцыя"
@@ -1342,14 +1432,17 @@ msgid "Taiwan, Province of China"
msgstr "Кітайская правінцыя Тайвань"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Злучаная Рэспубліка Танзанія"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Украіна"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Уганда"
@@ -1362,6 +1455,7 @@ msgid "United States"
msgstr "Злучаныя Штаты Амерыкі"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Уругвай"
@@ -1378,6 +1472,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "Сэнт-Вінсэнт і Грэнадзіны"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Венесуэла"
@@ -1414,6 +1509,7 @@ msgid "Mayotte"
msgstr "Маёта"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "Паўднёва-Афрыканская Рэспубліка"
@@ -1441,23 +1537,23 @@ msgid ""
msgstr ""
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
+msgid "No config file navit.xml, navit.xml.local found"
msgstr ""
#, c-format
-msgid "Error parsing config file '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
+msgid "Using config file '%s'"
msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
msgstr ""
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
msgid "unknown street"
@@ -1598,6 +1694,9 @@ msgstr ""
msgid "_Lock on Road"
msgstr ""
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr ""
@@ -1667,7 +1766,12 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
msgstr ""
#, c-format
@@ -1675,15 +1779,15 @@ msgid "POI %s. %s"
msgstr ""
#, c-format
-msgid "Set destination to %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
+msgid "Set map to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
msgstr ""
msgid "POI search"
@@ -1692,9 +1796,6 @@ msgstr ""
msgid "Select a category"
msgstr ""
-msgid "Select a distance to look for (km)"
-msgstr ""
-
msgid "Select a POI"
msgstr ""
@@ -1707,7 +1808,7 @@ msgstr ""
msgid "Direction"
msgstr ""
-msgid "Distance(m)"
+msgid "Distance"
msgstr ""
msgid "Name"
@@ -1754,7 +1855,7 @@ msgid "OT"
msgstr ""
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
+msgid "Route %4.1f%s %02d:%02d ETA"
msgstr ""
msgid "Route 0000km 0+00:00 ETA"
@@ -1926,10 +2027,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1977,6 +2078,9 @@ msgstr ""
msgid "Show Locale"
msgstr ""
+msgid "Network info"
+msgstr ""
+
msgid "Former Destinations"
msgstr ""
@@ -2015,729 +2119,861 @@ msgstr ""
msgid "Please decrease your speed"
msgstr ""
-msgid "partial match"
+msgid "Vehicle Position"
msgstr ""
-#. Android resource: @strings/address_search_button
-msgid "Search"
+msgid "Main menu"
msgstr ""
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
+msgid ""
+"Show\n"
+"Map"
msgstr ""
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr ""
+msgid "Settings"
+msgstr "Налады"
+
+msgid "Tools"
+msgstr "Інструменты"
+
+msgid "Route"
+msgstr "Шлях"
+
+msgid "About"
+msgstr "Аб праграме"
+
+msgid "Quit"
+msgstr "Выйсці"
+
+msgid "Actions"
+msgstr "Дзеянні"
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Former\n"
+"Destinations"
msgstr ""
-msgid "Downloaded maps"
+msgid "Coordinates"
msgstr ""
msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+"Stop\n"
+"Navigation"
msgstr ""
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
+msgid "Display"
msgstr ""
-msgid "Cancel"
-msgstr ""
+msgid "Fullscreen"
+msgstr "Поўнаэкранны рэжым"
-msgid "filenamePath"
+msgid "Window Mode"
msgstr ""
-msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+msgid "Auto zoom"
msgstr ""
-msgid "Whole Planet"
+msgid "Manual zoom"
msgstr ""
-msgid "Africa"
+msgid "Layers"
msgstr ""
-msgid "Canary Islands"
+msgid "Zoom to route"
msgstr ""
-msgid "Asia"
-msgstr ""
+msgid "Description"
+msgstr "Апісанне"
-msgid "Korea"
+msgid ""
+"Drop last\n"
+"Waypoint"
msgstr ""
-msgid "Taiwan"
+msgid ""
+"Drop next\n"
+"Waypoint"
msgstr ""
-msgid "UAE+Other"
+msgid "Satellite Status"
msgstr ""
-msgid "Oceania"
+msgid "NMEA Data"
msgstr ""
-msgid "Tasmania"
+msgid "car_shortest"
msgstr ""
-msgid "Victoria"
+msgid "car_avoid_tolls"
msgstr ""
-msgid "New South Wales"
+msgid "car_pedantic"
msgstr ""
-msgid "Europe"
+msgid "horse"
msgstr ""
-msgid "Western Europe"
+msgid "Truck"
msgstr ""
-msgid "Azores"
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
msgstr ""
-msgid "BeNeLux"
+#. Android resource: @strings/cancel
+msgid "Cancel"
msgstr ""
-msgid "Alsace"
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
msgstr ""
-msgid "Aquitaine"
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
msgstr ""
-msgid "Auvergne"
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
msgstr ""
-msgid "Basse-Normandie"
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
msgstr ""
-msgid "Bourgogne"
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
msgstr ""
-msgid "Bretagne"
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
msgstr ""
-msgid "Centre"
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
msgstr ""
-msgid "Champagne-Ardenne"
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
msgstr ""
-msgid "Corse"
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
msgstr ""
-msgid "Franche-Comte"
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
msgstr ""
-msgid "Haute-Normandie"
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
msgstr ""
-msgid "Ile-de-France"
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
msgstr ""
-msgid "Languedoc-Roussillon"
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
msgstr ""
-msgid "Limousin"
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
msgstr ""
-msgid "Lorraine"
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
msgstr ""
-msgid "Midi-Pyrenees"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
msgstr ""
-msgid "Nord-pas-de-Calais"
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
msgstr ""
-msgid "Pays-de-la-Loire"
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
msgstr ""
-msgid "Picardie"
+#. Android resource: @strings/map_download_ready
+msgid "ready"
msgstr ""
-msgid "Poitou-Charentes"
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
msgstr ""
-msgid "Provence-Alpes-Cote-d-Azur"
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
msgstr ""
-msgid "Rhone-Alpes"
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
msgstr ""
-msgid "Baden-Wuerttemberg"
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
msgstr ""
-msgid "Bayern"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
msgstr ""
-msgid "Mittelfranken"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
msgstr ""
-msgid "Niederbayern"
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
msgstr ""
-msgid "Oberbayern"
+#. Android resource: @strings/map_downloading
+msgid "downloading"
msgstr ""
-msgid "Oberfranken"
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
msgstr ""
-msgid "Oberpfalz"
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
msgstr ""
-msgid "Schwaben"
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
msgstr ""
-msgid "Unterfranken"
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
msgstr ""
-msgid "Berlin"
+#. Android resource: @strings/address_search_title
+msgid "Address search"
msgstr ""
-msgid "Brandenburg"
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
msgstr ""
-msgid "Bremen"
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
msgstr ""
-msgid "Hamburg"
+#. Android resource: @strings/address_search_button
+msgid "Search"
msgstr ""
-msgid "Hessen"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
msgstr ""
-msgid "Mecklenburg-Vorpommern"
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
msgstr ""
-msgid "Niedersachsen"
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
msgstr ""
-msgid "Nordrhein-westfalen"
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
msgstr ""
-msgid "Rheinland-Pfalz"
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
msgstr ""
-msgid "Saarland"
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
msgstr ""
-msgid "Sachsen-Anhalt"
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
msgstr ""
-msgid "Sachsen"
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
msgstr ""
-msgid "Schleswig-Holstein"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
msgstr ""
-msgid "Thueringen"
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
msgstr ""
-msgid "Mallorca"
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
msgstr ""
-msgid "Galicia"
+#. Android resource: @strings/restoring
+msgid "Restoring..."
msgstr ""
-msgid "Scandinavia"
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
msgstr ""
-msgid "England"
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
msgstr ""
-msgid "Buckinghamshire"
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
msgstr ""
-msgid "Cambridgeshire"
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
msgstr ""
-msgid "Cumbria"
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
msgstr ""
-msgid "East yorkshire with hull"
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
-msgid "Essex"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
msgstr ""
-msgid "Herefordshire"
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
msgstr ""
-msgid "Kent"
+#. Android resource: @strings/select_backup
+msgid "Select backup"
msgstr ""
-msgid "Lancashire"
+#. Android resource: @strings/backup
+msgid "Backup"
msgstr ""
-msgid "Leicestershire"
+#. Android resource: @strings/restore
+msgid "Restore"
msgstr ""
-msgid "Norfolk"
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
msgstr ""
-msgid "Nottinghamshire"
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
-msgid "Oxfordshire"
+#. Android resource: @strings/permissions_not_granted
+msgid ""
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
-msgid "Shropshire"
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
msgstr ""
-msgid "Somerset"
+#. Android resource: @strings/whole_planet
+msgid "Whole Planet"
msgstr ""
-msgid "South yorkshire"
+#. Android resource: @strings/africa
+msgid "Africa"
msgstr ""
-msgid "Suffolk"
+#. Android resource: @strings/canary_islands
+msgid "Canary Islands"
msgstr ""
-msgid "Surrey"
+#. Android resource: @strings/asia
+msgid "Asia"
msgstr ""
-msgid "Wiltshire"
+#. Android resource: @strings/taiwan
+msgid "Taiwan"
msgstr ""
-msgid "Scotland"
+#. Android resource: @strings/korea
+msgid "Korea"
msgstr ""
-msgid "Wales"
+#. Android resource: @strings/uae_other
+msgid "UAE+Other"
msgstr ""
-msgid "Crete"
+#. Android resource: @strings/oceania
+msgid "Oceania"
msgstr ""
-msgid "North America"
+#. Android resource: @strings/tasmania
+msgid "Tasmania"
msgstr ""
-msgid "Alaska"
+#. Android resource: @strings/victoria
+msgid "Victoria"
msgstr ""
-msgid "Hawaii"
+#. Android resource: @strings/new_south_wales
+msgid "New South Wales"
msgstr ""
-msgid "USA"
+#. Android resource: @strings/europe
+msgid "Europe"
msgstr ""
-msgid " (except Alaska and Hawaii)"
+#. Android resource: @strings/western_europe
+msgid "Western Europe"
msgstr ""
-msgid "Midwest"
+#. Android resource: @strings/azores
+msgid "Azores"
msgstr ""
-msgid "Michigan"
+#. Android resource: @strings/benelux
+msgid "BeNeLux"
msgstr ""
-msgid "Ohio"
+#. Android resource: @strings/alsace
+msgid "Alsace"
msgstr ""
-msgid "Northeast"
+#. Android resource: @strings/aquitaine
+msgid "Aquitaine"
msgstr ""
-msgid "Massachusetts"
+#. Android resource: @strings/auvergne
+msgid "Auvergne"
msgstr ""
-msgid "Vermont"
+#. Android resource: @strings/centre
+msgid "Centre"
msgstr ""
-msgid "Pacific"
+#. Android resource: @strings/bretagne
+msgid "Bretagne"
msgstr ""
-msgid "South"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
msgstr ""
-msgid "Arkansas"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
msgstr ""
-msgid "District of Columbia"
+#. Android resource: @strings/champagne_ardenne
+msgid "Champagne-Ardenne"
msgstr ""
-msgid "Florida"
+#. Android resource: @strings/corse
+msgid "Corse"
msgstr ""
-msgid "Louisiana"
+#. Android resource: @strings/franche_comte
+msgid "Franche-Comte"
msgstr ""
-msgid "Maryland"
+#. Android resource: @strings/haute_normandie
+msgid "Haute-Normandie"
msgstr ""
-msgid "Mississippi"
+#. Android resource: @strings/ile_de_france
+msgid "Ile-de-France"
msgstr ""
-msgid "Oklahoma"
+#. Android resource: @strings/languedoc_roussillon
+msgid "Languedoc-Roussillon"
msgstr ""
-msgid "Texas"
+#. Android resource: @strings/limousin
+msgid "Limousin"
msgstr ""
-msgid "Virginia"
+#. Android resource: @strings/lorraine
+msgid "Lorraine"
msgstr ""
-msgid "West Virginia"
+#. Android resource: @strings/midi_pyrenees
+msgid "Midi-Pyrenees"
msgstr ""
-msgid "West"
+#. Android resource: @strings/nord_pas_de_calais
+msgid "Nord-pas-de-Calais"
msgstr ""
-msgid "Arizona"
+#. Android resource: @strings/pays_de_la_loire
+msgid "Pays-de-la-Loire"
msgstr ""
-msgid "California"
+#. Android resource: @strings/picardie
+msgid "Picardie"
msgstr ""
-msgid "Colorado"
+#. Android resource: @strings/poitou_charentes
+msgid "Poitou-Charentes"
msgstr ""
-msgid "Idaho"
+#. Android resource: @strings/provence_alpes_cote_d_azur
+msgid "Provence-Alpes-Cote-d-Azur"
msgstr ""
-msgid "Montana"
+#. Android resource: @strings/rhone_alpes
+msgid "Rhone-Alpes"
msgstr ""
-msgid "New Mexico"
+#. Android resource: @strings/baden_wuerttemberg
+msgid "Baden-Wuerttemberg"
msgstr ""
-msgid "Nevada"
+#. Android resource: @strings/bayern
+msgid "Bayern"
msgstr ""
-msgid "Oregon"
+#. Android resource: @strings/mittelfranken
+msgid "Mittelfranken"
msgstr ""
-msgid "Utah"
+#. Android resource: @strings/niederbayern
+msgid "Niederbayern"
msgstr ""
-msgid "Washington State"
+#. Android resource: @strings/oberbayern
+msgid "Oberbayern"
msgstr ""
-msgid "South+Middle America"
+#. Android resource: @strings/oberfranken
+msgid "Oberfranken"
msgstr ""
-msgid "Guyane Francaise"
+#. Android resource: @strings/oberpfalz
+msgid "Oberpfalz"
msgstr ""
-msgid "downloading"
+#. Android resource: @strings/schwaben
+msgid "Schwaben"
msgstr ""
-#. Android resource: @strings/map_download_ready
-msgid "ready"
+#. Android resource: @strings/unterfranken
+msgid "Unterfranken"
msgstr ""
-msgid "Media selected for map storage is not available"
+#. Android resource: @strings/berlin
+msgid "Berlin"
msgstr ""
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
+#. Android resource: @strings/brandenburg
+msgid "Brandenburg"
msgstr ""
-msgid "Error downloading map!"
+#. Android resource: @strings/bremen
+msgid "Bremen"
msgstr ""
-msgid "Error writing map!"
+#. Android resource: @strings/hamburg
+msgid "Hamburg"
msgstr ""
-msgid "Map download aborted!"
+#. Android resource: @strings/hessen
+msgid "Hessen"
msgstr ""
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
+#. Android resource: @strings/mecklenburg_vorpommern
+msgid "Mecklenburg-Vorpommern"
msgstr ""
-#. Android resource: @strings/map_download_title
-msgid "Map download"
+#. Android resource: @strings/niedersachsen
+msgid "Niedersachsen"
msgstr ""
-msgid "Vehicle Position"
+#. Android resource: @strings/nordrhein_westfalen
+msgid "Nordrhein-westfalen"
msgstr ""
-msgid "Main menu"
+#. Android resource: @strings/rheinland_pfalz
+msgid "Rheinland-Pfalz"
msgstr ""
-msgid ""
-"Show\n"
-"Map"
+#. Android resource: @strings/saarland
+msgid "Saarland"
msgstr ""
-msgid "Settings"
-msgstr "Налады"
-
-msgid "Tools"
-msgstr "Інструменты"
-
-msgid "Route"
-msgstr "Шлях"
-
-msgid "About"
-msgstr "Аб праграме"
-
-msgid "Quit"
-msgstr "Выйсці"
-
-msgid "Actions"
-msgstr "Дзеянні"
+#. Android resource: @strings/sachsen_anhalt
+msgid "Sachsen-Anhalt"
+msgstr ""
-msgid ""
-"Former\n"
-"Destinations"
+#. Android resource: @strings/sachsen
+msgid "Sachsen"
msgstr ""
-msgid "Coordinates"
+#. Android resource: @strings/schleswig_holstein
+msgid "Schleswig-Holstein"
msgstr ""
-msgid ""
-"Stop\n"
-"Navigation"
+#. Android resource: @strings/thueringen
+msgid "Thueringen"
msgstr ""
-msgid "Display"
+#. Android resource: @strings/mallorca
+msgid "Mallorca"
msgstr ""
-msgid "Fullscreen"
-msgstr "Поўнаэкранны рэжым"
+#. Android resource: @strings/galicia
+msgid "Galicia"
+msgstr ""
-msgid "Window Mode"
+#. Android resource: @strings/scandinavia
+msgid "Scandinavia"
msgstr ""
-msgid "Layers"
+#. Android resource: @strings/england
+msgid "England"
msgstr ""
-msgid "Description"
-msgstr "Апісанне"
+#. Android resource: @strings/buckinghamshire
+msgid "Buckinghamshire"
+msgstr ""
-msgid ""
-"Drop last \n"
-"Waypoint"
+#. Android resource: @strings/cambridgeshire
+msgid "Cambridgeshire"
msgstr ""
-msgid ""
-"Drop next \n"
-"Waypoint"
+#. Android resource: @strings/cumbria
+msgid "Cumbria"
msgstr ""
-msgid "Satellite Status"
+#. Android resource: @strings/east_yorkshire_with_hull
+msgid "East yorkshire with hull"
msgstr ""
-msgid "NMEA Data"
+#. Android resource: @strings/essex
+msgid "Essex"
msgstr ""
-msgid "car_shortest"
+#. Android resource: @strings/herefordshire
+msgid "Herefordshire"
msgstr ""
-msgid "car_avoid_tolls"
+#. Android resource: @strings/kent
+msgid "Kent"
msgstr ""
-msgid "car_pedantic"
+#. Android resource: @strings/lancashire
+msgid "Lancashire"
msgstr ""
-msgid "horse"
+#. Android resource: @strings/leicestershire
+msgid "Leicestershire"
msgstr ""
-msgid "Truck"
+#. Android resource: @strings/norfolk
+msgid "Norfolk"
msgstr ""
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
+#. Android resource: @strings/nottinghamshire
+msgid "Nottinghamshire"
msgstr ""
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
+#. Android resource: @strings/oxfordshire
+msgid "Oxfordshire"
msgstr ""
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
+#. Android resource: @strings/shropshire
+msgid "Shropshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
+#. Android resource: @strings/somerset
+msgid "Somerset"
msgstr ""
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
+#. Android resource: @strings/south_yorkshire
+msgid "South yorkshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
+#. Android resource: @strings/suffolk
+msgid "Suffolk"
msgstr ""
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
+#. Android resource: @strings/surrey
+msgid "Surrey"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
+#. Android resource: @strings/wiltshire
+msgid "Wiltshire"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
+#. Android resource: @strings/scotland
+msgid "Scotland"
msgstr ""
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
+#. Android resource: @strings/wales
+msgid "Wales"
msgstr ""
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
+#. Android resource: @strings/crete
+msgid "Crete"
msgstr ""
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
+#. Android resource: @strings/north_america
+msgid "North America"
msgstr ""
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
+#. Android resource: @strings/alaska
+msgid "Alaska"
msgstr ""
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
+#. Android resource: @strings/hawaii
+msgid "Hawaii"
msgstr ""
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
+#. Android resource: @strings/usa
+msgid "USA"
msgstr ""
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
msgstr ""
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
+#. Android resource: @strings/midwest
+msgid "Midwest"
msgstr ""
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
+#. Android resource: @strings/michigan
+msgid "Michigan"
msgstr ""
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
+#. Android resource: @strings/ohio
+msgid "Ohio"
msgstr ""
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
+#. Android resource: @strings/northeast
+msgid "Northeast"
msgstr ""
-#. Android resource: @strings/address_search_title
-msgid "Address search"
+#. Android resource: @strings/massachusetts
+msgid "Massachusetts"
msgstr ""
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
+#. Android resource: @strings/vermont
+msgid "Vermont"
msgstr ""
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
+#. Android resource: @strings/pacific
+msgid "Pacific"
msgstr ""
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
+#. Android resource: @strings/south
+msgid "South"
msgstr ""
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
+#. Android resource: @strings/arkansas
+msgid "Arkansas"
msgstr ""
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
+#. Android resource: @strings/district_of_columbia
+msgid "District of Columbia"
msgstr ""
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
+#. Android resource: @strings/florida
+msgid "Florida"
msgstr ""
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
+#. Android resource: @strings/louisiana
+msgid "Louisiana"
msgstr ""
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
+#. Android resource: @strings/maryland
+msgid "Maryland"
msgstr ""
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
+#. Android resource: @strings/mississippi
+msgid "Mississippi"
msgstr ""
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
+#. Android resource: @strings/oklahoma
+msgid "Oklahoma"
msgstr ""
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
+#. Android resource: @strings/texas
+msgid "Texas"
msgstr ""
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
+#. Android resource: @strings/virginia
+msgid "Virginia"
msgstr ""
-#. Android resource: @strings/restoring
-msgid "Restoring..."
+#. Android resource: @strings/west_virginia
+msgid "West Virginia"
msgstr ""
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
+#. Android resource: @strings/west
+msgid "West"
msgstr ""
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
+#. Android resource: @strings/arizona
+msgid "Arizona"
msgstr ""
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
+#. Android resource: @strings/california
+msgid "California"
msgstr ""
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
+#. Android resource: @strings/colorado
+msgid "Colorado"
msgstr ""
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
+#. Android resource: @strings/idaho
+msgid "Idaho"
msgstr ""
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
+#. Android resource: @strings/montana
+msgid "Montana"
msgstr ""
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
+#. Android resource: @strings/new_mexico
+msgid "New Mexico"
msgstr ""
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
+#. Android resource: @strings/nevada
+msgid "Nevada"
msgstr ""
-#. Android resource: @strings/select_backup
-msgid "Select backup"
+#. Android resource: @strings/oregon
+msgid "Oregon"
msgstr ""
-#. Android resource: @strings/backup
-msgid "Backup"
+#. Android resource: @strings/utah
+msgid "Utah"
msgstr ""
-#. Android resource: @strings/restore
-msgid "Restore"
+#. Android resource: @strings/washington_state
+msgid "Washington State"
msgstr ""
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
+#. Android resource: @strings/south_middle_america
+msgid "South+Middle America"
msgstr ""
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
+#. Android resource: @strings/guyane_francaise
+msgid "Guyane Francaise"
msgstr ""
diff --git a/po/bg.po.in b/po/bg.po.in
index 9da4a8820..6dbfe0ea8 100644
--- a/po/bg.po.in
+++ b/po/bg.po.in
@@ -1,5 +1,5 @@
# Bulgarian translations for navit
-# Copyright (C) 2006-2015 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Alex Stanev https://launchpad.net/~realender
@@ -7,13 +7,14 @@
# Anton Todorov https://launchpad.net/~antod
# Lyudmil Bonev https://launchpad.net/~bonev-j
# MalamiR https://launchpad.net/~mamut-killer
+# Martin Voinov https://launchpad.net/~mvoinov
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2015-07-19 03:57+0000\n"
-"Last-Translator: Alex Stanev <alex@stanev.org>\n"
+"PO-Revision-Date: 2018-05-01 20:30+0000\n"
+"Last-Translator: Anton Todorov <Unknown>\n"
"Language-Team: Bulgarian <bg@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -23,7 +24,7 @@ msgstr ""
"X-Report-Errors: https://translations.launchpad.net/navit/trunk/+pots/navit\n"
msgid "Running from source directory\n"
-msgstr ""
+msgstr "стартиране от главната директория\n"
#, c-format
msgid "setting '%s' to '%s'\n"
@@ -75,31 +76,31 @@ msgstr "шестия изход"
#, c-format
msgid "%d feet"
-msgstr ""
+msgstr "%d фута"
#, c-format
msgid "in %d feet"
-msgstr ""
+msgstr "след %d фута"
#, c-format
msgid "%d.%d miles"
-msgstr ""
+msgstr "%d.%d мили"
#, c-format
msgid "in %d.%d miles"
-msgstr ""
+msgstr "след %d.%d мили"
#, c-format
msgid "one mile"
msgid_plural "%d miles"
-msgstr[0] ""
-msgstr[1] ""
+msgstr[0] "%d мили"
+msgstr[1] "%d miles"
#, c-format
msgid "in one mile"
msgid_plural "in %d miles"
-msgstr[0] ""
-msgstr[1] ""
+msgstr[0] "след %d миля"
+msgstr[1] "in %d miles"
#, c-format
msgid "%d meters"
@@ -154,7 +155,6 @@ msgstr ""
msgid "%1$sonto %2$s|neuter form"
msgstr ""
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr "на рампата"
@@ -189,7 +189,7 @@ msgstr "Когато е възможно обърнете"
#. TRANSLATORS: the argument is the destination to follow
#, c-format
msgid "towards %s"
-msgstr ""
+msgstr "към %s"
#, c-format
msgid "Follow the road for the next %s"
@@ -204,7 +204,7 @@ msgid "Enter the roundabout %s"
msgstr "Навлизате в кръгово %s"
msgid "then enter the roundabout"
-msgstr ""
+msgstr "след това навлезте в кръговото движение"
#. TRANSLATORS: first arg. is the manieth exit, second arg. is the destination to follow
#, c-format
@@ -241,57 +241,57 @@ msgid "Merge %1$s%2$s|left"
msgstr ""
msgid "on your left"
-msgstr ""
+msgstr "ваше ляво"
msgid "on your right"
-msgstr ""
+msgstr "ваше дясно"
#. TRANSLATORS: the first arg. is exit ref and/or name, the second is the direction of exit and the third is distance
#, c-format
msgid "Take exit %1$s %2$s %3$s"
-msgstr ""
+msgstr "вземете изход %1$s %2$s %3$s"
#. TRANSLATORS: the first arg. is the direction of exit, the second is distance, the third is destination
#, c-format
msgid "Take the exit %1$s %2$s%3$s"
-msgstr ""
+msgstr "вземете изхода %1$s %2$s %3$s"
#. TRANSLATORS: as in "Keep right at interchange 42 Greenmond-West"
msgid "at interchange"
-msgstr ""
+msgstr "при обмен"
msgid "at exit"
-msgstr ""
+msgstr "на изхода"
#. TRANSLATORS: the arg. is where to do the maneuver
#, c-format
msgid "then continue straight%1$s"
-msgstr ""
+msgstr "след това продължете%1$s"
#. TRANSLATORS: the first arg. is distance, the second is where to do the maneuver, the third is destination
#, c-format
msgid "Continue straight %1$s%2$s%3$s"
-msgstr ""
+msgstr "продължете направо %1$s%2$s%3$s"
#. TRANSLATORS: the arg. is where to do the maneuver
#, c-format
msgid "then keep right%1$s"
-msgstr ""
+msgstr "след това дръжте в дясно %1$s"
#. TRANSLATORS: the first arg. is distance, the second is where to do the maneuver, the third is destination
#, c-format
msgid "Keep right %1$s%2$s%3$s"
-msgstr ""
+msgstr "дръжте в дясно %1$s%2$s%3$s"
#. TRANSLATORS: the arg. is where to do the maneuver
#, c-format
msgid "then keep left%1$s"
-msgstr ""
+msgstr "след това дръжте в ляво%1$s"
#. TRANSLATORS: the first arg. is distance, the second is where to do the maneuver, the third is destination
#, c-format
msgid "Keep left %1$s%2$s%3$s"
-msgstr ""
+msgstr "дръжте в ляво%1$s%2$s%3$s"
#. TRANSLATORS: "right" as in "turn right"
msgid "right"
@@ -355,9 +355,9 @@ msgstr "Обърнете %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
-msgstr ""
+msgstr "следвайте"
msgid "then you have reached your destination."
msgstr "след това пристигате на местоназначението"
@@ -367,9 +367,8 @@ msgstr "след това пристигате на местоназначени
msgid "You have reached your destination %s"
msgstr "Достигнахте до целта %s"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
-msgstr ""
+msgstr "обмен"
msgid "Exit"
msgstr "Изход"
@@ -384,9 +383,15 @@ msgstr "Команда"
msgid "Length"
msgstr "Дължина"
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr "км"
+msgid "feet"
+msgstr ""
+
msgid "m"
msgstr "м"
@@ -447,6 +452,7 @@ msgid "Anguilla"
msgstr "Ангуила"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Албания"
@@ -459,6 +465,7 @@ msgid "Netherlands Antilles"
msgstr "Холандски Антили"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Ангола"
@@ -467,6 +474,7 @@ msgid "Antarctica"
msgstr "Антарктика"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Аржентина"
@@ -475,10 +483,12 @@ msgid "American Samoa"
msgstr "Американска Самоа"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Австрия"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Австралия"
@@ -491,10 +501,12 @@ msgid "Aland Islands"
msgstr "Айландски Острови"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Азърбайджан"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Босна и Херцеговина"
@@ -507,6 +519,7 @@ msgid "Bangladesh"
msgstr "Бангладеш"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "Белгия"
@@ -515,6 +528,7 @@ msgid "Burkina Faso"
msgstr "Буркина Фасо"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "България"
@@ -523,6 +537,7 @@ msgid "Bahrain"
msgstr "Бахрейн"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Бурунди"
@@ -543,6 +558,7 @@ msgid "Brunei Darussalam"
msgstr "Бруней"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Боливия"
@@ -551,6 +567,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr ""
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Бразилия"
@@ -567,10 +584,12 @@ msgid "Bouvet Island"
msgstr "Остров Буве"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Ботсвана"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Беларус"
@@ -579,6 +598,7 @@ msgid "Belize"
msgstr "Белийз"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Канада"
@@ -587,6 +607,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Кокосови Острови"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Демократична Република Конго"
@@ -599,10 +620,12 @@ msgid "Congo"
msgstr "Конго"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Швейцария"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Кот Д'Ивоар"
@@ -611,6 +634,7 @@ msgid "Cook Islands"
msgstr "Острови Кук"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Чили"
@@ -619,10 +643,12 @@ msgid "Cameroon"
msgstr "Камерун"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "Китай"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Колумбия"
@@ -631,6 +657,7 @@ msgid "Costa Rica"
msgstr "Коста Рика"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Куба"
@@ -647,14 +674,17 @@ msgid "Christmas Island"
msgstr "Коледни острови"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Кипър"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "Чешка република"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Германия"
@@ -663,6 +693,7 @@ msgid "Djibouti"
msgstr "Джибути"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Дания"
@@ -671,6 +702,7 @@ msgid "Dominica"
msgstr "Доминика"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "Доминиканска Република"
@@ -679,10 +711,12 @@ msgid "Algeria"
msgstr "Алжир"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Еквадор"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Естония"
@@ -699,14 +733,17 @@ msgid "Eritrea"
msgstr "Еритрея"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Испания"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Етиопия"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Финландия"
@@ -723,10 +760,12 @@ msgid "Micronesia, Federated States of"
msgstr "Микронезия, Обединени щати"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Острови Фаро"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "Франция"
@@ -735,6 +774,7 @@ msgid "Gabon"
msgstr "Габон"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Обединеното Кралство"
@@ -771,6 +811,7 @@ msgid "Gambia"
msgstr "Гамбия"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Гвинея"
@@ -783,6 +824,7 @@ msgid "Equatorial Guinea"
msgstr "Екваториална Гвинея"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Гърция"
@@ -803,6 +845,7 @@ msgid "Guinea-Bissau"
msgstr "Гвинея-Бисау"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Гаяна"
@@ -819,26 +862,32 @@ msgid "Honduras"
msgstr "Хондурас"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Хърватска"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Хаити"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Унгария"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Индонезия"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Ирландия"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Израел"
@@ -847,6 +896,7 @@ msgid "Isle of Man"
msgstr "Остров Ман"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "Индия"
@@ -855,18 +905,22 @@ msgid "British Indian Ocean Territory"
msgstr "Британска територия в Индийския океан"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Ирак"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Иран, Ислямска република"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Исландия"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Италия"
@@ -875,6 +929,7 @@ msgid "Jersey"
msgstr "Джърси (остров)"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Ямайка"
@@ -883,14 +938,17 @@ msgid "Jordan"
msgstr "Йордания"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Япония"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Кения"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Киргизстан"
@@ -927,6 +985,7 @@ msgid "Cayman Islands"
msgstr "Кайманови острови"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Казахстан"
@@ -951,26 +1010,32 @@ msgid "Sri Lanka"
msgstr "Шри Ланка"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Либерия"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Лесото"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Литва"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Люксембург"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Латвия"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr ""
@@ -995,6 +1060,7 @@ msgid "Saint Martin (French part)"
msgstr "Свети Мартин (френска част)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Мадагаскар"
@@ -1015,6 +1081,7 @@ msgid "Myanmar"
msgstr "Мианмарският съюз"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Монголия"
@@ -1055,10 +1122,12 @@ msgid "Malawi"
msgstr "Малави"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "Мексико"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Малайзия"
@@ -1067,10 +1136,12 @@ msgid "Mozambique"
msgstr "Мозамбик"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Намибия"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Нова Каледония"
@@ -1091,6 +1162,7 @@ msgid "Nicaragua"
msgstr "Никарагуа"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Кралство Холандия"
@@ -1099,6 +1171,7 @@ msgid "Norway"
msgstr "Кралство Норвегия"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Непал"
@@ -1111,6 +1184,7 @@ msgid "Niue"
msgstr "Ниуе"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Нова Зеландия"
@@ -1123,6 +1197,7 @@ msgid "Panama"
msgstr "Панама"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Перу"
@@ -1135,14 +1210,17 @@ msgid "Papua New Guinea"
msgstr "Папуа Нова Гвинея"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Филипини"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Пакистан"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Полша"
@@ -1163,6 +1241,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Палестинска територия, Окупирана"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Португалия"
@@ -1171,6 +1250,7 @@ msgid "Palau"
msgstr "Палау"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Парагвай"
@@ -1179,10 +1259,12 @@ msgid "Qatar"
msgstr "Катар"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Реюнион"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Румъния"
@@ -1191,14 +1273,17 @@ msgid "Serbia"
msgstr "Сърбия"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Руска Федерация"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Руанда"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Саудитска Арабия"
@@ -1219,6 +1304,7 @@ msgid "Sweden"
msgstr "Швеция"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Сингапур"
@@ -1235,6 +1321,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Шпицберген и Ян Майен"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Словакия"
@@ -1255,6 +1342,7 @@ msgid "Somalia"
msgstr "Сомалия"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Суринам"
@@ -1299,6 +1387,7 @@ msgid "Togo"
msgstr "Того"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Тайланд"
@@ -1315,6 +1404,7 @@ msgid "Timor-Leste"
msgstr "Източен Тимор"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Туркменистан"
@@ -1327,6 +1417,7 @@ msgid "Tonga"
msgstr "Тонга"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Турция"
@@ -1343,14 +1434,17 @@ msgid "Taiwan, Province of China"
msgstr "Тайван, Китайска провинция"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Танзания, Обединена република"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Украйна"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Уганда"
@@ -1363,6 +1457,7 @@ msgid "United States"
msgstr "Съединени Амеркански Щати"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Уругвай"
@@ -1379,6 +1474,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "Сейнт Винсънт и Гренадини"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Венецуела"
@@ -1415,6 +1511,7 @@ msgid "Mayotte"
msgstr "Майот"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "Република Южна Африка"
@@ -1442,23 +1539,23 @@ msgid ""
msgstr ""
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
+msgid "No config file navit.xml, navit.xml.local found"
msgstr ""
#, c-format
-msgid "Error parsing config file '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
+msgid "Using config file '%s'"
msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
msgstr ""
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
msgid "unknown street"
@@ -1599,6 +1696,9 @@ msgstr ""
msgid "_Lock on Road"
msgstr "Придържай към пътя"
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr ""
@@ -1668,7 +1768,12 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
msgstr ""
#, c-format
@@ -1676,15 +1781,15 @@ msgid "POI %s. %s"
msgstr ""
#, c-format
-msgid "Set destination to %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
+msgid "Set map to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
msgstr ""
msgid "POI search"
@@ -1693,9 +1798,6 @@ msgstr ""
msgid "Select a category"
msgstr ""
-msgid "Select a distance to look for (km)"
-msgstr ""
-
msgid "Select a POI"
msgstr ""
@@ -1708,7 +1810,7 @@ msgstr ""
msgid "Direction"
msgstr ""
-msgid "Distance(m)"
+msgid "Distance"
msgstr ""
msgid "Name"
@@ -1755,8 +1857,8 @@ msgid "OT"
msgstr ""
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Маршрут %4.0fкм %02d:%02d ОВП"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "Маршрут 0000fкм 0+00:00 ОВП"
@@ -1927,10 +2029,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1966,12 +2068,21 @@ msgstr "Изглед"
msgid "Height Profile"
msgstr "Височинен профил"
+msgid "please install a map *.heightlines.bin to provide elevationdata"
+msgstr ""
+
+msgid "The route must cross at least 2 heightlines"
+msgstr ""
+
msgid "Route Description"
msgstr "Описание на маршрута"
msgid "Show Locale"
msgstr ""
+msgid "Network info"
+msgstr ""
+
msgid "Former Destinations"
msgstr "Предишни Местоназначения"
@@ -2010,734 +2121,873 @@ msgstr ""
msgid "Please decrease your speed"
msgstr ""
-msgid "partial match"
-msgstr ""
+msgid "Vehicle Position"
+msgstr "Позиция на автомобил"
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr ""
+msgid "Main menu"
+msgstr "Главно меню"
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
+msgid ""
+"Show\n"
+"Map"
msgstr ""
+"Покажи\n"
+"Картата"
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr ""
+msgid "Settings"
+msgstr "Настройки"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr ""
+msgid "Tools"
+msgstr "Инструменти"
+
+msgid "Route"
+msgstr "Маршрут"
+
+msgid "About"
+msgstr "Относно"
+
+msgid "Quit"
+msgstr "Излез"
+
+msgid "Actions"
+msgstr "Действия"
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Former\n"
+"Destinations"
msgstr ""
-msgid "Downloaded maps"
+msgid "Coordinates"
msgstr ""
msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+"Stop\n"
+"Navigation"
msgstr ""
+"Спри\n"
+"Навигацията"
-msgid "Cancel"
-msgstr ""
+msgid "Display"
+msgstr "Показване"
-msgid "filenamePath"
-msgstr ""
+msgid "Fullscreen"
+msgstr "Цял екран"
-msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
-msgstr ""
+msgid "Window Mode"
+msgstr "Режим Прозорец"
-msgid "Whole Planet"
+msgid "Auto zoom"
msgstr ""
-msgid "Africa"
+msgid "Manual zoom"
msgstr ""
-msgid "Canary Islands"
+msgid "Layers"
msgstr ""
-msgid "Asia"
+msgid "Zoom to route"
msgstr ""
-msgid "Korea"
-msgstr ""
+msgid "Description"
+msgstr "Описание"
-msgid "Taiwan"
+msgid ""
+"Drop last\n"
+"Waypoint"
msgstr ""
-msgid "UAE+Other"
+msgid ""
+"Drop next\n"
+"Waypoint"
msgstr ""
-msgid "Oceania"
+msgid "Satellite Status"
msgstr ""
-msgid "Tasmania"
+msgid "NMEA Data"
msgstr ""
-msgid "Victoria"
+msgid "car_shortest"
msgstr ""
-msgid "New South Wales"
+msgid "car_avoid_tolls"
msgstr ""
-msgid "Europe"
+msgid "car_pedantic"
msgstr ""
-msgid "Western Europe"
-msgstr ""
+msgid "horse"
+msgstr "кон"
-msgid "Azores"
+msgid "Truck"
msgstr ""
-msgid "BeNeLux"
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
msgstr ""
-msgid "Alsace"
+#. Android resource: @strings/cancel
+msgid "Cancel"
msgstr ""
-msgid "Aquitaine"
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
msgstr ""
-msgid "Auvergne"
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
msgstr ""
-msgid "Basse-Normandie"
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
msgstr ""
-msgid "Bourgogne"
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
msgstr ""
-msgid "Bretagne"
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
msgstr ""
-msgid "Centre"
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
msgstr ""
-msgid "Champagne-Ardenne"
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
msgstr ""
-msgid "Corse"
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
msgstr ""
-msgid "Franche-Comte"
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
msgstr ""
-msgid "Haute-Normandie"
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
msgstr ""
-msgid "Ile-de-France"
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
msgstr ""
-msgid "Languedoc-Roussillon"
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
msgstr ""
-msgid "Limousin"
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
msgstr ""
-msgid "Lorraine"
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
msgstr ""
-msgid "Midi-Pyrenees"
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
msgstr ""
-msgid "Nord-pas-de-Calais"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
msgstr ""
-msgid "Pays-de-la-Loire"
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
msgstr ""
-msgid "Picardie"
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
msgstr ""
-msgid "Poitou-Charentes"
+#. Android resource: @strings/map_download_ready
+msgid "ready"
msgstr ""
-msgid "Provence-Alpes-Cote-d-Azur"
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
msgstr ""
-msgid "Rhone-Alpes"
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
msgstr ""
-msgid "Baden-Wuerttemberg"
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
msgstr ""
-msgid "Bayern"
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
msgstr ""
-msgid "Mittelfranken"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
msgstr ""
-msgid "Niederbayern"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
msgstr ""
-msgid "Oberbayern"
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
msgstr ""
-msgid "Oberfranken"
+#. Android resource: @strings/map_downloading
+msgid "downloading"
msgstr ""
-msgid "Oberpfalz"
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
msgstr ""
-msgid "Schwaben"
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
msgstr ""
-msgid "Unterfranken"
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
msgstr ""
-msgid "Berlin"
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
msgstr ""
-msgid "Brandenburg"
+#. Android resource: @strings/address_search_title
+msgid "Address search"
msgstr ""
-msgid "Bremen"
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
msgstr ""
-msgid "Hamburg"
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
msgstr ""
-msgid "Hessen"
+#. Android resource: @strings/address_search_button
+msgid "Search"
msgstr ""
-msgid "Mecklenburg-Vorpommern"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
msgstr ""
-msgid "Niedersachsen"
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
msgstr ""
-msgid "Nordrhein-westfalen"
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
msgstr ""
-msgid "Rheinland-Pfalz"
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
msgstr ""
-msgid "Saarland"
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
msgstr ""
-msgid "Sachsen-Anhalt"
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
msgstr ""
-msgid "Sachsen"
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
msgstr ""
-msgid "Schleswig-Holstein"
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
msgstr ""
-msgid "Thueringen"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
msgstr ""
-msgid "Mallorca"
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
msgstr ""
-msgid "Galicia"
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
msgstr ""
-msgid "Scandinavia"
+#. Android resource: @strings/restoring
+msgid "Restoring..."
msgstr ""
-msgid "England"
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
msgstr ""
-msgid "Buckinghamshire"
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
msgstr ""
-msgid "Cambridgeshire"
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
msgstr ""
-msgid "Cumbria"
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
msgstr ""
-msgid "East yorkshire with hull"
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
msgstr ""
-msgid "Essex"
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
-msgid "Herefordshire"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
msgstr ""
-msgid "Kent"
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
msgstr ""
-msgid "Lancashire"
+#. Android resource: @strings/select_backup
+msgid "Select backup"
msgstr ""
-msgid "Leicestershire"
+#. Android resource: @strings/backup
+msgid "Backup"
msgstr ""
-msgid "Norfolk"
+#. Android resource: @strings/restore
+msgid "Restore"
msgstr ""
-msgid "Nottinghamshire"
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
msgstr ""
-msgid "Oxfordshire"
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
-msgid "Shropshire"
+#. Android resource: @strings/permissions_not_granted
+msgid ""
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
-msgid "Somerset"
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
msgstr ""
-msgid "South yorkshire"
+#. Android resource: @strings/whole_planet
+msgid "Whole Planet"
msgstr ""
-msgid "Suffolk"
+#. Android resource: @strings/africa
+msgid "Africa"
msgstr ""
-msgid "Surrey"
+#. Android resource: @strings/canary_islands
+msgid "Canary Islands"
msgstr ""
-msgid "Wiltshire"
+#. Android resource: @strings/asia
+msgid "Asia"
msgstr ""
-msgid "Scotland"
+#. Android resource: @strings/taiwan
+msgid "Taiwan"
msgstr ""
-msgid "Wales"
+#. Android resource: @strings/korea
+msgid "Korea"
msgstr ""
-msgid "Crete"
+#. Android resource: @strings/uae_other
+msgid "UAE+Other"
msgstr ""
-msgid "North America"
+#. Android resource: @strings/oceania
+msgid "Oceania"
msgstr ""
-msgid "Alaska"
+#. Android resource: @strings/tasmania
+msgid "Tasmania"
msgstr ""
-msgid "Hawaii"
+#. Android resource: @strings/victoria
+msgid "Victoria"
msgstr ""
-msgid "USA"
+#. Android resource: @strings/new_south_wales
+msgid "New South Wales"
msgstr ""
-msgid " (except Alaska and Hawaii)"
+#. Android resource: @strings/europe
+msgid "Europe"
msgstr ""
-msgid "Midwest"
+#. Android resource: @strings/western_europe
+msgid "Western Europe"
msgstr ""
-msgid "Michigan"
+#. Android resource: @strings/azores
+msgid "Azores"
msgstr ""
-msgid "Ohio"
+#. Android resource: @strings/benelux
+msgid "BeNeLux"
msgstr ""
-msgid "Northeast"
+#. Android resource: @strings/alsace
+msgid "Alsace"
msgstr ""
-msgid "Massachusetts"
+#. Android resource: @strings/aquitaine
+msgid "Aquitaine"
msgstr ""
-msgid "Vermont"
+#. Android resource: @strings/auvergne
+msgid "Auvergne"
msgstr ""
-msgid "Pacific"
+#. Android resource: @strings/centre
+msgid "Centre"
msgstr ""
-msgid "South"
+#. Android resource: @strings/bretagne
+msgid "Bretagne"
msgstr ""
-msgid "Arkansas"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
msgstr ""
-msgid "District of Columbia"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
msgstr ""
-msgid "Florida"
+#. Android resource: @strings/champagne_ardenne
+msgid "Champagne-Ardenne"
msgstr ""
-msgid "Louisiana"
+#. Android resource: @strings/corse
+msgid "Corse"
msgstr ""
-msgid "Maryland"
+#. Android resource: @strings/franche_comte
+msgid "Franche-Comte"
msgstr ""
-msgid "Mississippi"
+#. Android resource: @strings/haute_normandie
+msgid "Haute-Normandie"
msgstr ""
-msgid "Oklahoma"
+#. Android resource: @strings/ile_de_france
+msgid "Ile-de-France"
msgstr ""
-msgid "Texas"
+#. Android resource: @strings/languedoc_roussillon
+msgid "Languedoc-Roussillon"
msgstr ""
-msgid "Virginia"
+#. Android resource: @strings/limousin
+msgid "Limousin"
msgstr ""
-msgid "West Virginia"
+#. Android resource: @strings/lorraine
+msgid "Lorraine"
msgstr ""
-msgid "West"
+#. Android resource: @strings/midi_pyrenees
+msgid "Midi-Pyrenees"
msgstr ""
-msgid "Arizona"
+#. Android resource: @strings/nord_pas_de_calais
+msgid "Nord-pas-de-Calais"
msgstr ""
-msgid "California"
+#. Android resource: @strings/pays_de_la_loire
+msgid "Pays-de-la-Loire"
msgstr ""
-msgid "Colorado"
+#. Android resource: @strings/picardie
+msgid "Picardie"
msgstr ""
-msgid "Idaho"
+#. Android resource: @strings/poitou_charentes
+msgid "Poitou-Charentes"
msgstr ""
-msgid "Montana"
+#. Android resource: @strings/provence_alpes_cote_d_azur
+msgid "Provence-Alpes-Cote-d-Azur"
msgstr ""
-msgid "New Mexico"
+#. Android resource: @strings/rhone_alpes
+msgid "Rhone-Alpes"
msgstr ""
-msgid "Nevada"
+#. Android resource: @strings/baden_wuerttemberg
+msgid "Baden-Wuerttemberg"
msgstr ""
-msgid "Oregon"
+#. Android resource: @strings/bayern
+msgid "Bayern"
msgstr ""
-msgid "Utah"
+#. Android resource: @strings/mittelfranken
+msgid "Mittelfranken"
msgstr ""
-msgid "Washington State"
+#. Android resource: @strings/niederbayern
+msgid "Niederbayern"
msgstr ""
-msgid "South+Middle America"
+#. Android resource: @strings/oberbayern
+msgid "Oberbayern"
msgstr ""
-msgid "Guyane Francaise"
+#. Android resource: @strings/oberfranken
+msgid "Oberfranken"
msgstr ""
-msgid "downloading"
+#. Android resource: @strings/oberpfalz
+msgid "Oberpfalz"
msgstr ""
-#. Android resource: @strings/map_download_ready
-msgid "ready"
+#. Android resource: @strings/schwaben
+msgid "Schwaben"
msgstr ""
-msgid "Media selected for map storage is not available"
+#. Android resource: @strings/unterfranken
+msgid "Unterfranken"
msgstr ""
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
+#. Android resource: @strings/berlin
+msgid "Berlin"
msgstr ""
-msgid "Error downloading map!"
+#. Android resource: @strings/brandenburg
+msgid "Brandenburg"
msgstr ""
-msgid "Error writing map!"
+#. Android resource: @strings/bremen
+msgid "Bremen"
msgstr ""
-msgid "Map download aborted!"
+#. Android resource: @strings/hamburg
+msgid "Hamburg"
msgstr ""
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
+#. Android resource: @strings/hessen
+msgid "Hessen"
msgstr ""
-#. Android resource: @strings/map_download_title
-msgid "Map download"
+#. Android resource: @strings/mecklenburg_vorpommern
+msgid "Mecklenburg-Vorpommern"
msgstr ""
-msgid "Vehicle Position"
-msgstr "Позиция на автомобил"
-
-msgid "Main menu"
-msgstr "Главно меню"
-
-msgid ""
-"Show\n"
-"Map"
+#. Android resource: @strings/niedersachsen
+msgid "Niedersachsen"
msgstr ""
-"Покажи\n"
-"Картата"
-
-msgid "Settings"
-msgstr "Настройки"
-msgid "Tools"
-msgstr "Инструменти"
+#. Android resource: @strings/nordrhein_westfalen
+msgid "Nordrhein-westfalen"
+msgstr ""
-msgid "Route"
-msgstr "Маршрут"
+#. Android resource: @strings/rheinland_pfalz
+msgid "Rheinland-Pfalz"
+msgstr ""
-msgid "About"
-msgstr "Относно"
+#. Android resource: @strings/saarland
+msgid "Saarland"
+msgstr ""
-msgid "Quit"
-msgstr "Излез"
+#. Android resource: @strings/sachsen_anhalt
+msgid "Sachsen-Anhalt"
+msgstr ""
-msgid "Actions"
-msgstr "Действия"
+#. Android resource: @strings/sachsen
+msgid "Sachsen"
+msgstr ""
-msgid ""
-"Former\n"
-"Destinations"
+#. Android resource: @strings/schleswig_holstein
+msgid "Schleswig-Holstein"
msgstr ""
-msgid "Coordinates"
+#. Android resource: @strings/thueringen
+msgid "Thueringen"
msgstr ""
-msgid ""
-"Stop\n"
-"Navigation"
+#. Android resource: @strings/mallorca
+msgid "Mallorca"
msgstr ""
-"Спри\n"
-"Навигацията"
-msgid "Display"
-msgstr "Показване"
+#. Android resource: @strings/galicia
+msgid "Galicia"
+msgstr ""
-msgid "Fullscreen"
-msgstr "Цял екран"
+#. Android resource: @strings/scandinavia
+msgid "Scandinavia"
+msgstr ""
-msgid "Window Mode"
-msgstr "Режим Прозорец"
+#. Android resource: @strings/england
+msgid "England"
+msgstr ""
-msgid "Description"
-msgstr "Описание"
+#. Android resource: @strings/buckinghamshire
+msgid "Buckinghamshire"
+msgstr ""
-msgid ""
-"Drop last \n"
-"Waypoint"
+#. Android resource: @strings/cambridgeshire
+msgid "Cambridgeshire"
msgstr ""
-msgid ""
-"Drop next \n"
-"Waypoint"
+#. Android resource: @strings/cumbria
+msgid "Cumbria"
msgstr ""
-msgid "Satellite Status"
+#. Android resource: @strings/east_yorkshire_with_hull
+msgid "East yorkshire with hull"
msgstr ""
-msgid "NMEA Data"
+#. Android resource: @strings/essex
+msgid "Essex"
msgstr ""
-msgid "car_shortest"
+#. Android resource: @strings/herefordshire
+msgid "Herefordshire"
msgstr ""
-msgid "car_avoid_tolls"
+#. Android resource: @strings/kent
+msgid "Kent"
msgstr ""
-msgid "car_pedantic"
+#. Android resource: @strings/lancashire
+msgid "Lancashire"
msgstr ""
-msgid "horse"
-msgstr "кон"
+#. Android resource: @strings/leicestershire
+msgid "Leicestershire"
+msgstr ""
-msgid "Truck"
+#. Android resource: @strings/norfolk
+msgid "Norfolk"
msgstr ""
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
+#. Android resource: @strings/nottinghamshire
+msgid "Nottinghamshire"
msgstr ""
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
+#. Android resource: @strings/oxfordshire
+msgid "Oxfordshire"
msgstr ""
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
+#. Android resource: @strings/shropshire
+msgid "Shropshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
+#. Android resource: @strings/somerset
+msgid "Somerset"
msgstr ""
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
+#. Android resource: @strings/south_yorkshire
+msgid "South yorkshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
+#. Android resource: @strings/suffolk
+msgid "Suffolk"
msgstr ""
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
+#. Android resource: @strings/surrey
+msgid "Surrey"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
+#. Android resource: @strings/wiltshire
+msgid "Wiltshire"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
+#. Android resource: @strings/scotland
+msgid "Scotland"
msgstr ""
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
+#. Android resource: @strings/wales
+msgid "Wales"
msgstr ""
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
+#. Android resource: @strings/crete
+msgid "Crete"
msgstr ""
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
+#. Android resource: @strings/north_america
+msgid "North America"
msgstr ""
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
+#. Android resource: @strings/alaska
+msgid "Alaska"
msgstr ""
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
+#. Android resource: @strings/hawaii
+msgid "Hawaii"
msgstr ""
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
+#. Android resource: @strings/usa
+msgid "USA"
msgstr ""
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
msgstr ""
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
+#. Android resource: @strings/midwest
+msgid "Midwest"
msgstr ""
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
+#. Android resource: @strings/michigan
+msgid "Michigan"
msgstr ""
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
+#. Android resource: @strings/ohio
+msgid "Ohio"
msgstr ""
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
+#. Android resource: @strings/northeast
+msgid "Northeast"
msgstr ""
-#. Android resource: @strings/address_search_title
-msgid "Address search"
+#. Android resource: @strings/massachusetts
+msgid "Massachusetts"
msgstr ""
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
+#. Android resource: @strings/vermont
+msgid "Vermont"
msgstr ""
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
+#. Android resource: @strings/pacific
+msgid "Pacific"
msgstr ""
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
+#. Android resource: @strings/south
+msgid "South"
msgstr ""
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
+#. Android resource: @strings/arkansas
+msgid "Arkansas"
msgstr ""
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
+#. Android resource: @strings/district_of_columbia
+msgid "District of Columbia"
msgstr ""
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
+#. Android resource: @strings/florida
+msgid "Florida"
msgstr ""
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
+#. Android resource: @strings/louisiana
+msgid "Louisiana"
msgstr ""
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
+#. Android resource: @strings/maryland
+msgid "Maryland"
msgstr ""
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
+#. Android resource: @strings/mississippi
+msgid "Mississippi"
msgstr ""
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
+#. Android resource: @strings/oklahoma
+msgid "Oklahoma"
msgstr ""
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
+#. Android resource: @strings/texas
+msgid "Texas"
msgstr ""
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
+#. Android resource: @strings/virginia
+msgid "Virginia"
msgstr ""
-#. Android resource: @strings/restoring
-msgid "Restoring..."
+#. Android resource: @strings/west_virginia
+msgid "West Virginia"
msgstr ""
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
+#. Android resource: @strings/west
+msgid "West"
msgstr ""
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
+#. Android resource: @strings/arizona
+msgid "Arizona"
msgstr ""
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
+#. Android resource: @strings/california
+msgid "California"
msgstr ""
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
+#. Android resource: @strings/colorado
+msgid "Colorado"
msgstr ""
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
+#. Android resource: @strings/idaho
+msgid "Idaho"
msgstr ""
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
+#. Android resource: @strings/montana
+msgid "Montana"
msgstr ""
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
+#. Android resource: @strings/new_mexico
+msgid "New Mexico"
msgstr ""
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
+#. Android resource: @strings/nevada
+msgid "Nevada"
msgstr ""
-#. Android resource: @strings/select_backup
-msgid "Select backup"
+#. Android resource: @strings/oregon
+msgid "Oregon"
msgstr ""
-#. Android resource: @strings/backup
-msgid "Backup"
+#. Android resource: @strings/utah
+msgid "Utah"
msgstr ""
-#. Android resource: @strings/restore
-msgid "Restore"
+#. Android resource: @strings/washington_state
+msgid "Washington State"
msgstr ""
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
+#. Android resource: @strings/south_middle_america
+msgid "South+Middle America"
msgstr ""
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
+#. Android resource: @strings/guyane_francaise
+msgid "Guyane Francaise"
msgstr ""
#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Маршрут %4.0fкм %02d:%02d ОВП"
+
+#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
#~ msgstr "след това излезте от кръговото на %1$s %2$s"
diff --git a/po/bs.po.in b/po/bs.po.in
index c6c8e8506..d28cdea28 100644
--- a/po/bs.po.in
+++ b/po/bs.po.in
@@ -1,5 +1,5 @@
# Bosnian translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# KaZeR https://launchpad.net/~kazer
@@ -8,7 +8,7 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2015-07-19 03:57+0000\n"
"Last-Translator: Michael von Glasow <Unknown>\n"
@@ -154,7 +154,6 @@ msgstr ""
msgid "%1$sonto %2$s|neuter form"
msgstr ""
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr "u rampu"
@@ -355,7 +354,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -367,7 +366,6 @@ msgstr ""
msgid "You have reached your destination %s"
msgstr ""
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr ""
@@ -384,9 +382,15 @@ msgstr ""
msgid "Length"
msgstr ""
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr ""
+msgid "feet"
+msgstr ""
+
msgid "m"
msgstr ""
@@ -447,6 +451,7 @@ msgid "Anguilla"
msgstr ""
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr ""
@@ -459,6 +464,7 @@ msgid "Netherlands Antilles"
msgstr ""
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr ""
@@ -467,6 +473,7 @@ msgid "Antarctica"
msgstr ""
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr ""
@@ -475,10 +482,12 @@ msgid "American Samoa"
msgstr ""
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr ""
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr ""
@@ -491,10 +500,12 @@ msgid "Aland Islands"
msgstr ""
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr ""
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr ""
@@ -507,6 +518,7 @@ msgid "Bangladesh"
msgstr ""
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr ""
@@ -515,6 +527,7 @@ msgid "Burkina Faso"
msgstr ""
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr ""
@@ -523,6 +536,7 @@ msgid "Bahrain"
msgstr ""
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr ""
@@ -543,6 +557,7 @@ msgid "Brunei Darussalam"
msgstr ""
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr ""
@@ -551,6 +566,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr ""
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr ""
@@ -567,10 +583,12 @@ msgid "Bouvet Island"
msgstr ""
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr ""
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr ""
@@ -579,6 +597,7 @@ msgid "Belize"
msgstr ""
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr ""
@@ -587,6 +606,7 @@ msgid "Cocos (Keeling) Islands"
msgstr ""
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr ""
@@ -599,10 +619,12 @@ msgid "Congo"
msgstr ""
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr ""
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr ""
@@ -611,6 +633,7 @@ msgid "Cook Islands"
msgstr ""
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr ""
@@ -619,10 +642,12 @@ msgid "Cameroon"
msgstr ""
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr ""
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr ""
@@ -631,6 +656,7 @@ msgid "Costa Rica"
msgstr ""
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr ""
@@ -647,14 +673,17 @@ msgid "Christmas Island"
msgstr ""
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr ""
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr ""
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr ""
@@ -663,6 +692,7 @@ msgid "Djibouti"
msgstr ""
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr ""
@@ -671,6 +701,7 @@ msgid "Dominica"
msgstr ""
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr ""
@@ -679,10 +710,12 @@ msgid "Algeria"
msgstr ""
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr ""
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr ""
@@ -699,14 +732,17 @@ msgid "Eritrea"
msgstr ""
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr ""
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr ""
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr ""
@@ -723,10 +759,12 @@ msgid "Micronesia, Federated States of"
msgstr ""
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr ""
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr ""
@@ -735,6 +773,7 @@ msgid "Gabon"
msgstr ""
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr ""
@@ -771,6 +810,7 @@ msgid "Gambia"
msgstr ""
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr ""
@@ -783,6 +823,7 @@ msgid "Equatorial Guinea"
msgstr ""
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr ""
@@ -803,6 +844,7 @@ msgid "Guinea-Bissau"
msgstr ""
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr ""
@@ -819,26 +861,32 @@ msgid "Honduras"
msgstr ""
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr ""
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr ""
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr ""
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr ""
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr ""
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr ""
@@ -847,6 +895,7 @@ msgid "Isle of Man"
msgstr ""
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr ""
@@ -855,18 +904,22 @@ msgid "British Indian Ocean Territory"
msgstr ""
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr ""
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr ""
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr ""
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr ""
@@ -875,6 +928,7 @@ msgid "Jersey"
msgstr ""
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr ""
@@ -883,14 +937,17 @@ msgid "Jordan"
msgstr ""
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr ""
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr ""
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr ""
@@ -927,6 +984,7 @@ msgid "Cayman Islands"
msgstr ""
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr ""
@@ -951,26 +1009,32 @@ msgid "Sri Lanka"
msgstr ""
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr ""
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr ""
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr ""
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr ""
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr ""
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr ""
@@ -995,6 +1059,7 @@ msgid "Saint Martin (French part)"
msgstr ""
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr ""
@@ -1015,6 +1080,7 @@ msgid "Myanmar"
msgstr ""
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr ""
@@ -1055,10 +1121,12 @@ msgid "Malawi"
msgstr ""
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr ""
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr ""
@@ -1067,10 +1135,12 @@ msgid "Mozambique"
msgstr ""
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr ""
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr ""
@@ -1091,6 +1161,7 @@ msgid "Nicaragua"
msgstr ""
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr ""
@@ -1099,6 +1170,7 @@ msgid "Norway"
msgstr ""
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr ""
@@ -1111,6 +1183,7 @@ msgid "Niue"
msgstr ""
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr ""
@@ -1123,6 +1196,7 @@ msgid "Panama"
msgstr ""
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr ""
@@ -1135,14 +1209,17 @@ msgid "Papua New Guinea"
msgstr ""
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr ""
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr ""
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr ""
@@ -1163,6 +1240,7 @@ msgid "Palestinian Territory, Occupied"
msgstr ""
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr ""
@@ -1171,6 +1249,7 @@ msgid "Palau"
msgstr ""
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr ""
@@ -1179,10 +1258,12 @@ msgid "Qatar"
msgstr ""
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr ""
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr ""
@@ -1191,14 +1272,17 @@ msgid "Serbia"
msgstr ""
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr ""
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr ""
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr ""
@@ -1219,6 +1303,7 @@ msgid "Sweden"
msgstr ""
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr ""
@@ -1235,6 +1320,7 @@ msgid "Svalbard and Jan Mayen"
msgstr ""
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr ""
@@ -1255,6 +1341,7 @@ msgid "Somalia"
msgstr ""
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr ""
@@ -1299,6 +1386,7 @@ msgid "Togo"
msgstr ""
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr ""
@@ -1315,6 +1403,7 @@ msgid "Timor-Leste"
msgstr ""
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr ""
@@ -1327,6 +1416,7 @@ msgid "Tonga"
msgstr ""
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr ""
@@ -1343,14 +1433,17 @@ msgid "Taiwan, Province of China"
msgstr ""
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr ""
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr ""
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr ""
@@ -1363,6 +1456,7 @@ msgid "United States"
msgstr ""
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr ""
@@ -1379,6 +1473,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr ""
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr ""
@@ -1415,6 +1510,7 @@ msgid "Mayotte"
msgstr ""
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr ""
@@ -1442,23 +1538,23 @@ msgid ""
msgstr ""
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
+msgid "No config file navit.xml, navit.xml.local found"
msgstr ""
#, c-format
-msgid "Error parsing config file '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
+msgid "Using config file '%s'"
msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
msgstr ""
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
msgid "unknown street"
@@ -1599,6 +1695,9 @@ msgstr ""
msgid "_Lock on Road"
msgstr ""
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr ""
@@ -1668,7 +1767,12 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
msgstr ""
#, c-format
@@ -1676,15 +1780,15 @@ msgid "POI %s. %s"
msgstr ""
#, c-format
-msgid "Set destination to %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
+msgid "Set map to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
msgstr ""
msgid "POI search"
@@ -1693,9 +1797,6 @@ msgstr ""
msgid "Select a category"
msgstr ""
-msgid "Select a distance to look for (km)"
-msgstr ""
-
msgid "Select a POI"
msgstr ""
@@ -1708,7 +1809,7 @@ msgstr ""
msgid "Direction"
msgstr ""
-msgid "Distance(m)"
+msgid "Distance"
msgstr ""
msgid "Name"
@@ -1755,7 +1856,7 @@ msgid "OT"
msgstr ""
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
+msgid "Route %4.1f%s %02d:%02d ETA"
msgstr ""
msgid "Route 0000km 0+00:00 ETA"
@@ -1927,10 +2028,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1978,6 +2079,9 @@ msgstr ""
msgid "Show Locale"
msgstr ""
+msgid "Network info"
+msgstr ""
+
msgid "Former Destinations"
msgstr ""
@@ -2016,729 +2120,861 @@ msgstr ""
msgid "Please decrease your speed"
msgstr ""
-msgid "partial match"
+msgid "Vehicle Position"
msgstr ""
-#. Android resource: @strings/address_search_button
-msgid "Search"
+msgid "Main menu"
msgstr ""
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
+msgid ""
+"Show\n"
+"Map"
msgstr ""
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
+msgid "Settings"
msgstr ""
-msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+msgid "Tools"
msgstr ""
-msgid "Downloaded maps"
+msgid "Route"
msgstr ""
-msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+msgid "About"
msgstr ""
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
+msgid "Quit"
msgstr ""
-msgid "Cancel"
+msgid "Actions"
msgstr ""
-msgid "filenamePath"
+msgid ""
+"Former\n"
+"Destinations"
msgstr ""
-msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+msgid "Coordinates"
msgstr ""
-msgid "Whole Planet"
+msgid ""
+"Stop\n"
+"Navigation"
msgstr ""
-msgid "Africa"
+msgid "Display"
msgstr ""
-msgid "Canary Islands"
+msgid "Fullscreen"
msgstr ""
-msgid "Asia"
+msgid "Window Mode"
msgstr ""
-msgid "Korea"
+msgid "Auto zoom"
msgstr ""
-msgid "Taiwan"
+msgid "Manual zoom"
msgstr ""
-msgid "UAE+Other"
+msgid "Layers"
msgstr ""
-msgid "Oceania"
+msgid "Zoom to route"
msgstr ""
-msgid "Tasmania"
+msgid "Description"
msgstr ""
-msgid "Victoria"
+msgid ""
+"Drop last\n"
+"Waypoint"
msgstr ""
-msgid "New South Wales"
+msgid ""
+"Drop next\n"
+"Waypoint"
msgstr ""
-msgid "Europe"
+msgid "Satellite Status"
msgstr ""
-msgid "Western Europe"
+msgid "NMEA Data"
msgstr ""
-msgid "Azores"
+msgid "car_shortest"
msgstr ""
-msgid "BeNeLux"
+msgid "car_avoid_tolls"
msgstr ""
-msgid "Alsace"
+msgid "car_pedantic"
msgstr ""
-msgid "Aquitaine"
+msgid "horse"
msgstr ""
-msgid "Auvergne"
+msgid "Truck"
msgstr ""
-msgid "Basse-Normandie"
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
msgstr ""
-msgid "Bourgogne"
+#. Android resource: @strings/cancel
+msgid "Cancel"
msgstr ""
-msgid "Bretagne"
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
msgstr ""
-msgid "Centre"
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
msgstr ""
-msgid "Champagne-Ardenne"
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
msgstr ""
-msgid "Corse"
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
msgstr ""
-msgid "Franche-Comte"
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
msgstr ""
-msgid "Haute-Normandie"
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
msgstr ""
-msgid "Ile-de-France"
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
msgstr ""
-msgid "Languedoc-Roussillon"
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
msgstr ""
-msgid "Limousin"
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
msgstr ""
-msgid "Lorraine"
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
msgstr ""
-msgid "Midi-Pyrenees"
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
msgstr ""
-msgid "Nord-pas-de-Calais"
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
msgstr ""
-msgid "Pays-de-la-Loire"
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
msgstr ""
-msgid "Picardie"
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
msgstr ""
-msgid "Poitou-Charentes"
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
msgstr ""
-msgid "Provence-Alpes-Cote-d-Azur"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
msgstr ""
-msgid "Rhone-Alpes"
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
msgstr ""
-msgid "Baden-Wuerttemberg"
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
msgstr ""
-msgid "Bayern"
+#. Android resource: @strings/map_download_ready
+msgid "ready"
msgstr ""
-msgid "Mittelfranken"
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
msgstr ""
-msgid "Niederbayern"
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
msgstr ""
-msgid "Oberbayern"
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
msgstr ""
-msgid "Oberfranken"
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
msgstr ""
-msgid "Oberpfalz"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
msgstr ""
-msgid "Schwaben"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
msgstr ""
-msgid "Unterfranken"
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
msgstr ""
-msgid "Berlin"
+#. Android resource: @strings/map_downloading
+msgid "downloading"
msgstr ""
-msgid "Brandenburg"
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
msgstr ""
-msgid "Bremen"
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
msgstr ""
-msgid "Hamburg"
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
msgstr ""
-msgid "Hessen"
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
msgstr ""
-msgid "Mecklenburg-Vorpommern"
+#. Android resource: @strings/address_search_title
+msgid "Address search"
msgstr ""
-msgid "Niedersachsen"
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
msgstr ""
-msgid "Nordrhein-westfalen"
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
msgstr ""
-msgid "Rheinland-Pfalz"
+#. Android resource: @strings/address_search_button
+msgid "Search"
msgstr ""
-msgid "Saarland"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
msgstr ""
-msgid "Sachsen-Anhalt"
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
msgstr ""
-msgid "Sachsen"
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
msgstr ""
-msgid "Schleswig-Holstein"
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
msgstr ""
-msgid "Thueringen"
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
msgstr ""
-msgid "Mallorca"
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
msgstr ""
-msgid "Galicia"
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
msgstr ""
-msgid "Scandinavia"
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
msgstr ""
-msgid "England"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
msgstr ""
-msgid "Buckinghamshire"
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
msgstr ""
-msgid "Cambridgeshire"
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
msgstr ""
-msgid "Cumbria"
+#. Android resource: @strings/restoring
+msgid "Restoring..."
msgstr ""
-msgid "East yorkshire with hull"
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
msgstr ""
-msgid "Essex"
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
msgstr ""
-msgid "Herefordshire"
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
msgstr ""
-msgid "Kent"
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
msgstr ""
-msgid "Lancashire"
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
msgstr ""
-msgid "Leicestershire"
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
-msgid "Norfolk"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
msgstr ""
-msgid "Nottinghamshire"
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
msgstr ""
-msgid "Oxfordshire"
+#. Android resource: @strings/select_backup
+msgid "Select backup"
msgstr ""
-msgid "Shropshire"
+#. Android resource: @strings/backup
+msgid "Backup"
msgstr ""
-msgid "Somerset"
+#. Android resource: @strings/restore
+msgid "Restore"
msgstr ""
-msgid "South yorkshire"
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
msgstr ""
-msgid "Suffolk"
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
-msgid "Surrey"
+#. Android resource: @strings/permissions_not_granted
+msgid ""
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
-msgid "Wiltshire"
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
msgstr ""
-msgid "Scotland"
+#. Android resource: @strings/whole_planet
+msgid "Whole Planet"
msgstr ""
-msgid "Wales"
+#. Android resource: @strings/africa
+msgid "Africa"
msgstr ""
-msgid "Crete"
+#. Android resource: @strings/canary_islands
+msgid "Canary Islands"
msgstr ""
-msgid "North America"
+#. Android resource: @strings/asia
+msgid "Asia"
msgstr ""
-msgid "Alaska"
+#. Android resource: @strings/taiwan
+msgid "Taiwan"
msgstr ""
-msgid "Hawaii"
+#. Android resource: @strings/korea
+msgid "Korea"
msgstr ""
-msgid "USA"
+#. Android resource: @strings/uae_other
+msgid "UAE+Other"
msgstr ""
-msgid " (except Alaska and Hawaii)"
+#. Android resource: @strings/oceania
+msgid "Oceania"
msgstr ""
-msgid "Midwest"
+#. Android resource: @strings/tasmania
+msgid "Tasmania"
msgstr ""
-msgid "Michigan"
+#. Android resource: @strings/victoria
+msgid "Victoria"
msgstr ""
-msgid "Ohio"
+#. Android resource: @strings/new_south_wales
+msgid "New South Wales"
msgstr ""
-msgid "Northeast"
+#. Android resource: @strings/europe
+msgid "Europe"
msgstr ""
-msgid "Massachusetts"
+#. Android resource: @strings/western_europe
+msgid "Western Europe"
msgstr ""
-msgid "Vermont"
+#. Android resource: @strings/azores
+msgid "Azores"
msgstr ""
-msgid "Pacific"
+#. Android resource: @strings/benelux
+msgid "BeNeLux"
msgstr ""
-msgid "South"
+#. Android resource: @strings/alsace
+msgid "Alsace"
msgstr ""
-msgid "Arkansas"
+#. Android resource: @strings/aquitaine
+msgid "Aquitaine"
msgstr ""
-msgid "District of Columbia"
+#. Android resource: @strings/auvergne
+msgid "Auvergne"
msgstr ""
-msgid "Florida"
+#. Android resource: @strings/centre
+msgid "Centre"
msgstr ""
-msgid "Louisiana"
+#. Android resource: @strings/bretagne
+msgid "Bretagne"
msgstr ""
-msgid "Maryland"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
msgstr ""
-msgid "Mississippi"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
msgstr ""
-msgid "Oklahoma"
+#. Android resource: @strings/champagne_ardenne
+msgid "Champagne-Ardenne"
msgstr ""
-msgid "Texas"
+#. Android resource: @strings/corse
+msgid "Corse"
msgstr ""
-msgid "Virginia"
+#. Android resource: @strings/franche_comte
+msgid "Franche-Comte"
msgstr ""
-msgid "West Virginia"
+#. Android resource: @strings/haute_normandie
+msgid "Haute-Normandie"
msgstr ""
-msgid "West"
+#. Android resource: @strings/ile_de_france
+msgid "Ile-de-France"
msgstr ""
-msgid "Arizona"
+#. Android resource: @strings/languedoc_roussillon
+msgid "Languedoc-Roussillon"
msgstr ""
-msgid "California"
+#. Android resource: @strings/limousin
+msgid "Limousin"
msgstr ""
-msgid "Colorado"
+#. Android resource: @strings/lorraine
+msgid "Lorraine"
msgstr ""
-msgid "Idaho"
+#. Android resource: @strings/midi_pyrenees
+msgid "Midi-Pyrenees"
msgstr ""
-msgid "Montana"
+#. Android resource: @strings/nord_pas_de_calais
+msgid "Nord-pas-de-Calais"
msgstr ""
-msgid "New Mexico"
+#. Android resource: @strings/pays_de_la_loire
+msgid "Pays-de-la-Loire"
msgstr ""
-msgid "Nevada"
+#. Android resource: @strings/picardie
+msgid "Picardie"
msgstr ""
-msgid "Oregon"
+#. Android resource: @strings/poitou_charentes
+msgid "Poitou-Charentes"
msgstr ""
-msgid "Utah"
+#. Android resource: @strings/provence_alpes_cote_d_azur
+msgid "Provence-Alpes-Cote-d-Azur"
msgstr ""
-msgid "Washington State"
+#. Android resource: @strings/rhone_alpes
+msgid "Rhone-Alpes"
msgstr ""
-msgid "South+Middle America"
+#. Android resource: @strings/baden_wuerttemberg
+msgid "Baden-Wuerttemberg"
msgstr ""
-msgid "Guyane Francaise"
+#. Android resource: @strings/bayern
+msgid "Bayern"
msgstr ""
-msgid "downloading"
+#. Android resource: @strings/mittelfranken
+msgid "Mittelfranken"
msgstr ""
-#. Android resource: @strings/map_download_ready
-msgid "ready"
+#. Android resource: @strings/niederbayern
+msgid "Niederbayern"
msgstr ""
-msgid "Media selected for map storage is not available"
+#. Android resource: @strings/oberbayern
+msgid "Oberbayern"
msgstr ""
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
+#. Android resource: @strings/oberfranken
+msgid "Oberfranken"
msgstr ""
-msgid "Error downloading map!"
+#. Android resource: @strings/oberpfalz
+msgid "Oberpfalz"
msgstr ""
-msgid "Error writing map!"
+#. Android resource: @strings/schwaben
+msgid "Schwaben"
msgstr ""
-msgid "Map download aborted!"
+#. Android resource: @strings/unterfranken
+msgid "Unterfranken"
msgstr ""
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
+#. Android resource: @strings/berlin
+msgid "Berlin"
msgstr ""
-#. Android resource: @strings/map_download_title
-msgid "Map download"
+#. Android resource: @strings/brandenburg
+msgid "Brandenburg"
msgstr ""
-msgid "Vehicle Position"
+#. Android resource: @strings/bremen
+msgid "Bremen"
msgstr ""
-msgid "Main menu"
+#. Android resource: @strings/hamburg
+msgid "Hamburg"
msgstr ""
-msgid ""
-"Show\n"
-"Map"
+#. Android resource: @strings/hessen
+msgid "Hessen"
msgstr ""
-msgid "Settings"
+#. Android resource: @strings/mecklenburg_vorpommern
+msgid "Mecklenburg-Vorpommern"
msgstr ""
-msgid "Tools"
+#. Android resource: @strings/niedersachsen
+msgid "Niedersachsen"
msgstr ""
-msgid "Route"
+#. Android resource: @strings/nordrhein_westfalen
+msgid "Nordrhein-westfalen"
msgstr ""
-msgid "About"
+#. Android resource: @strings/rheinland_pfalz
+msgid "Rheinland-Pfalz"
msgstr ""
-msgid "Quit"
+#. Android resource: @strings/saarland
+msgid "Saarland"
msgstr ""
-msgid "Actions"
+#. Android resource: @strings/sachsen_anhalt
+msgid "Sachsen-Anhalt"
msgstr ""
-msgid ""
-"Former\n"
-"Destinations"
+#. Android resource: @strings/sachsen
+msgid "Sachsen"
msgstr ""
-msgid "Coordinates"
+#. Android resource: @strings/schleswig_holstein
+msgid "Schleswig-Holstein"
msgstr ""
-msgid ""
-"Stop\n"
-"Navigation"
+#. Android resource: @strings/thueringen
+msgid "Thueringen"
msgstr ""
-msgid "Display"
+#. Android resource: @strings/mallorca
+msgid "Mallorca"
msgstr ""
-msgid "Fullscreen"
+#. Android resource: @strings/galicia
+msgid "Galicia"
msgstr ""
-msgid "Window Mode"
+#. Android resource: @strings/scandinavia
+msgid "Scandinavia"
msgstr ""
-msgid "Layers"
+#. Android resource: @strings/england
+msgid "England"
msgstr ""
-msgid "Description"
+#. Android resource: @strings/buckinghamshire
+msgid "Buckinghamshire"
msgstr ""
-msgid ""
-"Drop last \n"
-"Waypoint"
+#. Android resource: @strings/cambridgeshire
+msgid "Cambridgeshire"
msgstr ""
-msgid ""
-"Drop next \n"
-"Waypoint"
+#. Android resource: @strings/cumbria
+msgid "Cumbria"
msgstr ""
-msgid "Satellite Status"
+#. Android resource: @strings/east_yorkshire_with_hull
+msgid "East yorkshire with hull"
msgstr ""
-msgid "NMEA Data"
+#. Android resource: @strings/essex
+msgid "Essex"
msgstr ""
-msgid "car_shortest"
+#. Android resource: @strings/herefordshire
+msgid "Herefordshire"
msgstr ""
-msgid "car_avoid_tolls"
+#. Android resource: @strings/kent
+msgid "Kent"
msgstr ""
-msgid "car_pedantic"
+#. Android resource: @strings/lancashire
+msgid "Lancashire"
msgstr ""
-msgid "horse"
+#. Android resource: @strings/leicestershire
+msgid "Leicestershire"
msgstr ""
-msgid "Truck"
+#. Android resource: @strings/norfolk
+msgid "Norfolk"
msgstr ""
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
+#. Android resource: @strings/nottinghamshire
+msgid "Nottinghamshire"
msgstr ""
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
+#. Android resource: @strings/oxfordshire
+msgid "Oxfordshire"
msgstr ""
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
+#. Android resource: @strings/shropshire
+msgid "Shropshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
+#. Android resource: @strings/somerset
+msgid "Somerset"
msgstr ""
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
+#. Android resource: @strings/south_yorkshire
+msgid "South yorkshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
+#. Android resource: @strings/suffolk
+msgid "Suffolk"
msgstr ""
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
+#. Android resource: @strings/surrey
+msgid "Surrey"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
+#. Android resource: @strings/wiltshire
+msgid "Wiltshire"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
+#. Android resource: @strings/scotland
+msgid "Scotland"
msgstr ""
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
+#. Android resource: @strings/wales
+msgid "Wales"
msgstr ""
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
+#. Android resource: @strings/crete
+msgid "Crete"
msgstr ""
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
+#. Android resource: @strings/north_america
+msgid "North America"
msgstr ""
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
+#. Android resource: @strings/alaska
+msgid "Alaska"
msgstr ""
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
+#. Android resource: @strings/hawaii
+msgid "Hawaii"
msgstr ""
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
+#. Android resource: @strings/usa
+msgid "USA"
msgstr ""
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
msgstr ""
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
+#. Android resource: @strings/midwest
+msgid "Midwest"
msgstr ""
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
+#. Android resource: @strings/michigan
+msgid "Michigan"
msgstr ""
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
+#. Android resource: @strings/ohio
+msgid "Ohio"
msgstr ""
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
+#. Android resource: @strings/northeast
+msgid "Northeast"
msgstr ""
-#. Android resource: @strings/address_search_title
-msgid "Address search"
+#. Android resource: @strings/massachusetts
+msgid "Massachusetts"
msgstr ""
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
+#. Android resource: @strings/vermont
+msgid "Vermont"
msgstr ""
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
+#. Android resource: @strings/pacific
+msgid "Pacific"
msgstr ""
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
+#. Android resource: @strings/south
+msgid "South"
msgstr ""
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
+#. Android resource: @strings/arkansas
+msgid "Arkansas"
msgstr ""
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
+#. Android resource: @strings/district_of_columbia
+msgid "District of Columbia"
msgstr ""
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
+#. Android resource: @strings/florida
+msgid "Florida"
msgstr ""
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
+#. Android resource: @strings/louisiana
+msgid "Louisiana"
msgstr ""
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
+#. Android resource: @strings/maryland
+msgid "Maryland"
msgstr ""
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
+#. Android resource: @strings/mississippi
+msgid "Mississippi"
msgstr ""
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
+#. Android resource: @strings/oklahoma
+msgid "Oklahoma"
msgstr ""
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
+#. Android resource: @strings/texas
+msgid "Texas"
msgstr ""
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
+#. Android resource: @strings/virginia
+msgid "Virginia"
msgstr ""
-#. Android resource: @strings/restoring
-msgid "Restoring..."
+#. Android resource: @strings/west_virginia
+msgid "West Virginia"
msgstr ""
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
+#. Android resource: @strings/west
+msgid "West"
msgstr ""
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
+#. Android resource: @strings/arizona
+msgid "Arizona"
msgstr ""
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
+#. Android resource: @strings/california
+msgid "California"
msgstr ""
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
+#. Android resource: @strings/colorado
+msgid "Colorado"
msgstr ""
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
+#. Android resource: @strings/idaho
+msgid "Idaho"
msgstr ""
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
+#. Android resource: @strings/montana
+msgid "Montana"
msgstr ""
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
+#. Android resource: @strings/new_mexico
+msgid "New Mexico"
msgstr ""
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
+#. Android resource: @strings/nevada
+msgid "Nevada"
msgstr ""
-#. Android resource: @strings/select_backup
-msgid "Select backup"
+#. Android resource: @strings/oregon
+msgid "Oregon"
msgstr ""
-#. Android resource: @strings/backup
-msgid "Backup"
+#. Android resource: @strings/utah
+msgid "Utah"
msgstr ""
-#. Android resource: @strings/restore
-msgid "Restore"
+#. Android resource: @strings/washington_state
+msgid "Washington State"
msgstr ""
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
+#. Android resource: @strings/south_middle_america
+msgid "South+Middle America"
msgstr ""
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
+#. Android resource: @strings/guyane_francaise
+msgid "Guyane Francaise"
msgstr ""
diff --git a/po/ca.po.in b/po/ca.po.in
index 4c41bcd79..da9421f44 100644
--- a/po/ca.po.in
+++ b/po/ca.po.in
@@ -1,5 +1,5 @@
# Catalan translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Ferran Roig https://launchpad.net/~ferro9
@@ -17,7 +17,7 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2016-01-01 20:32+0000\n"
"Last-Translator: pataquets <Unknown>\n"
@@ -161,7 +161,6 @@ msgstr ""
msgid "%1$sonto %2$s|neuter form"
msgstr ""
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr ""
@@ -362,7 +361,7 @@ msgstr "Doneu mitja volta %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "seguiu"
@@ -374,7 +373,6 @@ msgstr "aleshores heu arribat a destí"
msgid "You have reached your destination %s"
msgstr "Heu arribat a la destinació %s"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr "Intersecció"
@@ -391,9 +389,15 @@ msgstr "Ordre"
msgid "Length"
msgstr "Durada"
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr ""
+
msgid "m"
msgstr "m"
@@ -454,6 +458,7 @@ msgid "Anguilla"
msgstr "Anguilla"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Albània"
@@ -466,6 +471,7 @@ msgid "Netherlands Antilles"
msgstr "Antilles Holandeses"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Angola"
@@ -474,6 +480,7 @@ msgid "Antarctica"
msgstr "Antàrtida"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Argentina"
@@ -482,10 +489,12 @@ msgid "American Samoa"
msgstr "Samoa Americana"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Àustria"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Austràlia"
@@ -498,10 +507,12 @@ msgid "Aland Islands"
msgstr "Illes Aland"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Azerbaitjan"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Bòsnia i Hercegovina"
@@ -514,6 +525,7 @@ msgid "Bangladesh"
msgstr "Bangladesh"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "Bèlgica"
@@ -522,6 +534,7 @@ msgid "Burkina Faso"
msgstr "Burkina Faso"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Bulgària"
@@ -530,6 +543,7 @@ msgid "Bahrain"
msgstr "Bahrain"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Burundi"
@@ -550,6 +564,7 @@ msgid "Brunei Darussalam"
msgstr "Brunei"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Bolívia"
@@ -558,6 +573,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr ""
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Brasil"
@@ -574,10 +590,12 @@ msgid "Bouvet Island"
msgstr "Illa Bouvet"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Botswana"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Bielorússia"
@@ -586,6 +604,7 @@ msgid "Belize"
msgstr "Belize"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Canadà"
@@ -594,6 +613,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Illes Cocos (Keeling)"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Congo, República Democràtica del"
@@ -606,10 +626,12 @@ msgid "Congo"
msgstr "Congo"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Suïssa"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Costa d'Ivori"
@@ -618,6 +640,7 @@ msgid "Cook Islands"
msgstr "Illes Cook"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Xile"
@@ -626,10 +649,12 @@ msgid "Cameroon"
msgstr "Camerun"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "Xina"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Colòmbia"
@@ -638,6 +663,7 @@ msgid "Costa Rica"
msgstr "Costa Rica"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Cuba"
@@ -654,14 +680,17 @@ msgid "Christmas Island"
msgstr "Illa Christmas"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Xipre"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "República Txeca"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Alemanya"
@@ -670,6 +699,7 @@ msgid "Djibouti"
msgstr "Djibouti"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Dinamarca"
@@ -678,6 +708,7 @@ msgid "Dominica"
msgstr "Dominica"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "República Dominicana"
@@ -686,10 +717,12 @@ msgid "Algeria"
msgstr "Algèria"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Equador"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Estònia"
@@ -706,14 +739,17 @@ msgid "Eritrea"
msgstr "Eritrea"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Espanya"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Etiòpia"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Finlàndia"
@@ -730,10 +766,12 @@ msgid "Micronesia, Federated States of"
msgstr "Micronèsia, Estats Federats de"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Illes Fèroe"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "França"
@@ -742,6 +780,7 @@ msgid "Gabon"
msgstr "Gabon"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Regne Unit"
@@ -778,6 +817,7 @@ msgid "Gambia"
msgstr "Gàmbia"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Guinea"
@@ -790,6 +830,7 @@ msgid "Equatorial Guinea"
msgstr "Guinea Equatorial"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Grècia"
@@ -810,6 +851,7 @@ msgid "Guinea-Bissau"
msgstr "Guinea Bissau"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Guyana"
@@ -826,26 +868,32 @@ msgid "Honduras"
msgstr "Hondures"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Croàcia"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Haití"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Hongria"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Indonèsia"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Irlanda"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Israel"
@@ -854,6 +902,7 @@ msgid "Isle of Man"
msgstr "Illa de Man"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "Índia"
@@ -862,18 +911,22 @@ msgid "British Indian Ocean Territory"
msgstr "Territori britànic de l'oceà Índic"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Iraq"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Iran"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Islàndia"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Itàlia"
@@ -882,6 +935,7 @@ msgid "Jersey"
msgstr "Jersey"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Jamàica"
@@ -890,14 +944,17 @@ msgid "Jordan"
msgstr "Jordània"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Japó"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Kenya"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Kirguizistan"
@@ -934,6 +991,7 @@ msgid "Cayman Islands"
msgstr "Illes Caiman"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Kazakhstan"
@@ -958,26 +1016,32 @@ msgid "Sri Lanka"
msgstr "Sri Lanka"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Libèria"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Lesotho"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Lituània"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Luxemburg"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Letònia"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr "Líbia"
@@ -1002,6 +1066,7 @@ msgid "Saint Martin (French part)"
msgstr "Saint-Martin (zona francesa)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Madagascar"
@@ -1022,6 +1087,7 @@ msgid "Myanmar"
msgstr "Myanmar"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Mongòlia"
@@ -1062,10 +1128,12 @@ msgid "Malawi"
msgstr "Malawi"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "Mèxic"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Malàisia"
@@ -1074,10 +1142,12 @@ msgid "Mozambique"
msgstr "Moçambic"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Namíbia"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Nova Caledònia"
@@ -1098,6 +1168,7 @@ msgid "Nicaragua"
msgstr "Nicaragua"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Països Baixos"
@@ -1106,6 +1177,7 @@ msgid "Norway"
msgstr "Noruega"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Nepal"
@@ -1118,6 +1190,7 @@ msgid "Niue"
msgstr "Niue"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Nova Zelanda"
@@ -1130,6 +1203,7 @@ msgid "Panama"
msgstr "Panamà"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Perú"
@@ -1142,14 +1216,17 @@ msgid "Papua New Guinea"
msgstr "Papua Nova Guinea"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Filipines"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Pakistan"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Polònia"
@@ -1170,6 +1247,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Palestina (territori ocupat)"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Portugal"
@@ -1178,6 +1256,7 @@ msgid "Palau"
msgstr "Palau"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Paraguai"
@@ -1186,10 +1265,12 @@ msgid "Qatar"
msgstr "Qatar"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Illa de la Reunió"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Romania"
@@ -1198,14 +1279,17 @@ msgid "Serbia"
msgstr "Sèrbia"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Rússia"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Rwanda"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Aràbia Saudita"
@@ -1226,6 +1310,7 @@ msgid "Sweden"
msgstr "Suècia"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Singapur"
@@ -1242,6 +1327,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Svalbard i Jan Mayen"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Eslovàquia"
@@ -1262,6 +1348,7 @@ msgid "Somalia"
msgstr "Somàlia"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Surinam"
@@ -1306,6 +1393,7 @@ msgid "Togo"
msgstr "Togo"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Tailàndia"
@@ -1322,6 +1410,7 @@ msgid "Timor-Leste"
msgstr "Timor Oriental"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Turkmenistan"
@@ -1334,6 +1423,7 @@ msgid "Tonga"
msgstr "Tonga"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Turquia"
@@ -1350,14 +1440,17 @@ msgid "Taiwan, Province of China"
msgstr "Taiwan"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Tanzània"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Ucraïna"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Uganda"
@@ -1370,6 +1463,7 @@ msgid "United States"
msgstr "Estats Units d'Amèrica"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Uruguai"
@@ -1386,6 +1480,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "Saint Vincent i les Grenadines"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Veneçuela"
@@ -1422,6 +1517,7 @@ msgid "Mayotte"
msgstr "Mayotte"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "Sud-àfrica"
@@ -1449,23 +1545,23 @@ msgid ""
msgstr ""
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
-msgstr "No s'ha trobat l'arxiu de configuració navit.xml, navit.xml.local\n"
+msgid "No config file navit.xml, navit.xml.local found"
+msgstr ""
#, c-format
-msgid "Error parsing config file '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
-msgstr "Usant l'arxiu de configuració '%s'\n"
+msgid "Using config file '%s'"
+msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
msgstr ""
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
msgid "unknown street"
@@ -1606,6 +1702,9 @@ msgstr ""
msgid "_Lock on Road"
msgstr ""
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr ""
@@ -1675,7 +1774,12 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
msgstr ""
#, c-format
@@ -1683,15 +1787,15 @@ msgid "POI %s. %s"
msgstr ""
#, c-format
-msgid "Set destination to %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
+msgid "Set map to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
msgstr ""
msgid "POI search"
@@ -1700,9 +1804,6 @@ msgstr ""
msgid "Select a category"
msgstr "Seleccioneu una categoria"
-msgid "Select a distance to look for (km)"
-msgstr ""
-
msgid "Select a POI"
msgstr ""
@@ -1715,7 +1816,7 @@ msgstr ""
msgid "Direction"
msgstr ""
-msgid "Distance(m)"
+msgid "Distance"
msgstr ""
msgid "Name"
@@ -1762,8 +1863,8 @@ msgid "OT"
msgstr ""
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Ruta %4.0fkm %02d:%02d TEA"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "Ruta 0000km 0+00:00 TEA"
@@ -1934,10 +2035,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1985,6 +2086,9 @@ msgstr "Descripció de la ruta"
msgid "Show Locale"
msgstr "Mostra la localitat"
+msgid "Network info"
+msgstr ""
+
msgid "Former Destinations"
msgstr "Destinacions anteriors"
@@ -2023,737 +2127,880 @@ msgstr ""
msgid "Please decrease your speed"
msgstr ""
-msgid "partial match"
-msgstr ""
+msgid "Vehicle Position"
+msgstr "Posició del vehicle"
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr ""
+msgid "Main menu"
+msgstr "Menú principal"
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
+msgid ""
+"Show\n"
+"Map"
msgstr ""
+"Mostra\n"
+"Mapa"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr ""
+msgid "Settings"
+msgstr "Configuració"
+
+msgid "Tools"
+msgstr "Eines"
+
+msgid "Route"
+msgstr "Ruta"
+
+msgid "About"
+msgstr "Quant a..."
+
+msgid "Quit"
+msgstr "Surt"
+
+msgid "Actions"
+msgstr "Accions"
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Former\n"
+"Destinations"
msgstr ""
-msgid "Downloaded maps"
+msgid "Coordinates"
msgstr ""
msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+"Stop\n"
+"Navigation"
msgstr ""
+"Atura la\n"
+"Navegació"
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr ""
+msgid "Display"
+msgstr "Pantalla"
-msgid "Cancel"
-msgstr ""
+msgid "Fullscreen"
+msgstr "Pantalla completa"
-msgid "filenamePath"
-msgstr ""
+msgid "Window Mode"
+msgstr "Mode de la finestra"
-msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+msgid "Auto zoom"
msgstr ""
-msgid "Whole Planet"
+msgid "Manual zoom"
msgstr ""
-msgid "Africa"
+msgid "Layers"
msgstr ""
-msgid "Canary Islands"
+msgid "Zoom to route"
msgstr ""
-msgid "Asia"
-msgstr ""
+msgid "Description"
+msgstr "Descripció"
-msgid "Korea"
+msgid ""
+"Drop last\n"
+"Waypoint"
msgstr ""
-msgid "Taiwan"
+msgid ""
+"Drop next\n"
+"Waypoint"
msgstr ""
-msgid "UAE+Other"
+msgid "Satellite Status"
msgstr ""
-msgid "Oceania"
+msgid "NMEA Data"
msgstr ""
-msgid "Tasmania"
+msgid "car_shortest"
msgstr ""
-msgid "Victoria"
+msgid "car_avoid_tolls"
msgstr ""
-msgid "New South Wales"
+msgid "car_pedantic"
msgstr ""
-msgid "Europe"
-msgstr ""
+msgid "horse"
+msgstr "cavall"
-msgid "Western Europe"
+msgid "Truck"
msgstr ""
-msgid "Azores"
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
msgstr ""
-msgid "BeNeLux"
+#. Android resource: @strings/cancel
+msgid "Cancel"
msgstr ""
-msgid "Alsace"
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
msgstr ""
-msgid "Aquitaine"
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
msgstr ""
-msgid "Auvergne"
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
msgstr ""
-msgid "Basse-Normandie"
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
msgstr ""
-msgid "Bourgogne"
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
msgstr ""
-msgid "Bretagne"
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
msgstr ""
-msgid "Centre"
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
msgstr ""
-msgid "Champagne-Ardenne"
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
msgstr ""
-msgid "Corse"
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
msgstr ""
-msgid "Franche-Comte"
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
msgstr ""
-msgid "Haute-Normandie"
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
msgstr ""
-msgid "Ile-de-France"
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
msgstr ""
-msgid "Languedoc-Roussillon"
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
msgstr ""
-msgid "Limousin"
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
msgstr ""
-msgid "Lorraine"
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
msgstr ""
-msgid "Midi-Pyrenees"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
msgstr ""
-msgid "Nord-pas-de-Calais"
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
msgstr ""
-msgid "Pays-de-la-Loire"
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
msgstr ""
-msgid "Picardie"
+#. Android resource: @strings/map_download_ready
+msgid "ready"
msgstr ""
-msgid "Poitou-Charentes"
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
msgstr ""
-msgid "Provence-Alpes-Cote-d-Azur"
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
msgstr ""
-msgid "Rhone-Alpes"
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
msgstr ""
-msgid "Baden-Wuerttemberg"
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
msgstr ""
-msgid "Bayern"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
msgstr ""
-msgid "Mittelfranken"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
msgstr ""
-msgid "Niederbayern"
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
msgstr ""
-msgid "Oberbayern"
+#. Android resource: @strings/map_downloading
+msgid "downloading"
msgstr ""
-msgid "Oberfranken"
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
msgstr ""
-msgid "Oberpfalz"
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
msgstr ""
-msgid "Schwaben"
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
msgstr ""
-msgid "Unterfranken"
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
msgstr ""
-msgid "Berlin"
+#. Android resource: @strings/address_search_title
+msgid "Address search"
msgstr ""
-msgid "Brandenburg"
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
msgstr ""
-msgid "Bremen"
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
msgstr ""
-msgid "Hamburg"
+#. Android resource: @strings/address_search_button
+msgid "Search"
msgstr ""
-msgid "Hessen"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
msgstr ""
-msgid "Mecklenburg-Vorpommern"
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
msgstr ""
-msgid "Niedersachsen"
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
msgstr ""
-msgid "Nordrhein-westfalen"
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
msgstr ""
-msgid "Rheinland-Pfalz"
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
msgstr ""
-msgid "Saarland"
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
msgstr ""
-msgid "Sachsen-Anhalt"
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
msgstr ""
-msgid "Sachsen"
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
msgstr ""
-msgid "Schleswig-Holstein"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
msgstr ""
-msgid "Thueringen"
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
msgstr ""
-msgid "Mallorca"
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
msgstr ""
-msgid "Galicia"
+#. Android resource: @strings/restoring
+msgid "Restoring..."
msgstr ""
-msgid "Scandinavia"
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
msgstr ""
-msgid "England"
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
msgstr ""
-msgid "Buckinghamshire"
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
msgstr ""
-msgid "Cambridgeshire"
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
msgstr ""
-msgid "Cumbria"
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
msgstr ""
-msgid "East yorkshire with hull"
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
-msgid "Essex"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
msgstr ""
-msgid "Herefordshire"
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
msgstr ""
-msgid "Kent"
+#. Android resource: @strings/select_backup
+msgid "Select backup"
msgstr ""
-msgid "Lancashire"
+#. Android resource: @strings/backup
+msgid "Backup"
msgstr ""
-msgid "Leicestershire"
+#. Android resource: @strings/restore
+msgid "Restore"
msgstr ""
-msgid "Norfolk"
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
msgstr ""
-msgid "Nottinghamshire"
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
-msgid "Oxfordshire"
+#. Android resource: @strings/permissions_not_granted
+msgid ""
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
-msgid "Shropshire"
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
msgstr ""
-msgid "Somerset"
+#. Android resource: @strings/whole_planet
+msgid "Whole Planet"
msgstr ""
-msgid "South yorkshire"
+#. Android resource: @strings/africa
+msgid "Africa"
msgstr ""
-msgid "Suffolk"
+#. Android resource: @strings/canary_islands
+msgid "Canary Islands"
msgstr ""
-msgid "Surrey"
+#. Android resource: @strings/asia
+msgid "Asia"
msgstr ""
-msgid "Wiltshire"
+#. Android resource: @strings/taiwan
+msgid "Taiwan"
msgstr ""
-msgid "Scotland"
+#. Android resource: @strings/korea
+msgid "Korea"
msgstr ""
-msgid "Wales"
+#. Android resource: @strings/uae_other
+msgid "UAE+Other"
msgstr ""
-msgid "Crete"
+#. Android resource: @strings/oceania
+msgid "Oceania"
msgstr ""
-msgid "North America"
+#. Android resource: @strings/tasmania
+msgid "Tasmania"
msgstr ""
-msgid "Alaska"
+#. Android resource: @strings/victoria
+msgid "Victoria"
msgstr ""
-msgid "Hawaii"
+#. Android resource: @strings/new_south_wales
+msgid "New South Wales"
msgstr ""
-msgid "USA"
+#. Android resource: @strings/europe
+msgid "Europe"
msgstr ""
-msgid " (except Alaska and Hawaii)"
+#. Android resource: @strings/western_europe
+msgid "Western Europe"
msgstr ""
-msgid "Midwest"
+#. Android resource: @strings/azores
+msgid "Azores"
msgstr ""
-msgid "Michigan"
+#. Android resource: @strings/benelux
+msgid "BeNeLux"
msgstr ""
-msgid "Ohio"
+#. Android resource: @strings/alsace
+msgid "Alsace"
msgstr ""
-msgid "Northeast"
+#. Android resource: @strings/aquitaine
+msgid "Aquitaine"
msgstr ""
-msgid "Massachusetts"
+#. Android resource: @strings/auvergne
+msgid "Auvergne"
msgstr ""
-msgid "Vermont"
+#. Android resource: @strings/centre
+msgid "Centre"
msgstr ""
-msgid "Pacific"
+#. Android resource: @strings/bretagne
+msgid "Bretagne"
msgstr ""
-msgid "South"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
msgstr ""
-msgid "Arkansas"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
msgstr ""
-msgid "District of Columbia"
+#. Android resource: @strings/champagne_ardenne
+msgid "Champagne-Ardenne"
msgstr ""
-msgid "Florida"
+#. Android resource: @strings/corse
+msgid "Corse"
msgstr ""
-msgid "Louisiana"
+#. Android resource: @strings/franche_comte
+msgid "Franche-Comte"
msgstr ""
-msgid "Maryland"
+#. Android resource: @strings/haute_normandie
+msgid "Haute-Normandie"
msgstr ""
-msgid "Mississippi"
+#. Android resource: @strings/ile_de_france
+msgid "Ile-de-France"
msgstr ""
-msgid "Oklahoma"
+#. Android resource: @strings/languedoc_roussillon
+msgid "Languedoc-Roussillon"
msgstr ""
-msgid "Texas"
+#. Android resource: @strings/limousin
+msgid "Limousin"
msgstr ""
-msgid "Virginia"
+#. Android resource: @strings/lorraine
+msgid "Lorraine"
msgstr ""
-msgid "West Virginia"
+#. Android resource: @strings/midi_pyrenees
+msgid "Midi-Pyrenees"
msgstr ""
-msgid "West"
+#. Android resource: @strings/nord_pas_de_calais
+msgid "Nord-pas-de-Calais"
msgstr ""
-msgid "Arizona"
+#. Android resource: @strings/pays_de_la_loire
+msgid "Pays-de-la-Loire"
msgstr ""
-msgid "California"
+#. Android resource: @strings/picardie
+msgid "Picardie"
msgstr ""
-msgid "Colorado"
+#. Android resource: @strings/poitou_charentes
+msgid "Poitou-Charentes"
msgstr ""
-msgid "Idaho"
+#. Android resource: @strings/provence_alpes_cote_d_azur
+msgid "Provence-Alpes-Cote-d-Azur"
msgstr ""
-msgid "Montana"
+#. Android resource: @strings/rhone_alpes
+msgid "Rhone-Alpes"
msgstr ""
-msgid "New Mexico"
+#. Android resource: @strings/baden_wuerttemberg
+msgid "Baden-Wuerttemberg"
msgstr ""
-msgid "Nevada"
+#. Android resource: @strings/bayern
+msgid "Bayern"
msgstr ""
-msgid "Oregon"
+#. Android resource: @strings/mittelfranken
+msgid "Mittelfranken"
msgstr ""
-msgid "Utah"
+#. Android resource: @strings/niederbayern
+msgid "Niederbayern"
msgstr ""
-msgid "Washington State"
+#. Android resource: @strings/oberbayern
+msgid "Oberbayern"
msgstr ""
-msgid "South+Middle America"
+#. Android resource: @strings/oberfranken
+msgid "Oberfranken"
msgstr ""
-msgid "Guyane Francaise"
+#. Android resource: @strings/oberpfalz
+msgid "Oberpfalz"
msgstr ""
-msgid "downloading"
+#. Android resource: @strings/schwaben
+msgid "Schwaben"
msgstr ""
-#. Android resource: @strings/map_download_ready
-msgid "ready"
+#. Android resource: @strings/unterfranken
+msgid "Unterfranken"
msgstr ""
-msgid "Media selected for map storage is not available"
+#. Android resource: @strings/berlin
+msgid "Berlin"
msgstr ""
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
+#. Android resource: @strings/brandenburg
+msgid "Brandenburg"
msgstr ""
-msgid "Error downloading map!"
+#. Android resource: @strings/bremen
+msgid "Bremen"
msgstr ""
-msgid "Error writing map!"
+#. Android resource: @strings/hamburg
+msgid "Hamburg"
msgstr ""
-msgid "Map download aborted!"
+#. Android resource: @strings/hessen
+msgid "Hessen"
msgstr ""
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
+#. Android resource: @strings/mecklenburg_vorpommern
+msgid "Mecklenburg-Vorpommern"
msgstr ""
-#. Android resource: @strings/map_download_title
-msgid "Map download"
+#. Android resource: @strings/niedersachsen
+msgid "Niedersachsen"
msgstr ""
-msgid "Vehicle Position"
-msgstr "Posició del vehicle"
-
-msgid "Main menu"
-msgstr "Menú principal"
-
-msgid ""
-"Show\n"
-"Map"
+#. Android resource: @strings/nordrhein_westfalen
+msgid "Nordrhein-westfalen"
msgstr ""
-"Mostra\n"
-"Mapa"
-msgid "Settings"
-msgstr "Configuració"
-
-msgid "Tools"
-msgstr "Eines"
-
-msgid "Route"
-msgstr "Ruta"
-
-msgid "About"
-msgstr "Quant a..."
+#. Android resource: @strings/rheinland_pfalz
+msgid "Rheinland-Pfalz"
+msgstr ""
-msgid "Quit"
-msgstr "Surt"
+#. Android resource: @strings/saarland
+msgid "Saarland"
+msgstr ""
-msgid "Actions"
-msgstr "Accions"
+#. Android resource: @strings/sachsen_anhalt
+msgid "Sachsen-Anhalt"
+msgstr ""
-msgid ""
-"Former\n"
-"Destinations"
+#. Android resource: @strings/sachsen
+msgid "Sachsen"
msgstr ""
-msgid "Coordinates"
+#. Android resource: @strings/schleswig_holstein
+msgid "Schleswig-Holstein"
msgstr ""
-msgid ""
-"Stop\n"
-"Navigation"
+#. Android resource: @strings/thueringen
+msgid "Thueringen"
msgstr ""
-"Atura la\n"
-"Navegació"
-msgid "Display"
-msgstr "Pantalla"
+#. Android resource: @strings/mallorca
+msgid "Mallorca"
+msgstr ""
-msgid "Fullscreen"
-msgstr "Pantalla completa"
+#. Android resource: @strings/galicia
+msgid "Galicia"
+msgstr ""
-msgid "Window Mode"
-msgstr "Mode de la finestra"
+#. Android resource: @strings/scandinavia
+msgid "Scandinavia"
+msgstr ""
-msgid "Layers"
+#. Android resource: @strings/england
+msgid "England"
msgstr ""
-msgid "Description"
-msgstr "Descripció"
+#. Android resource: @strings/buckinghamshire
+msgid "Buckinghamshire"
+msgstr ""
-msgid ""
-"Drop last \n"
-"Waypoint"
+#. Android resource: @strings/cambridgeshire
+msgid "Cambridgeshire"
msgstr ""
-msgid ""
-"Drop next \n"
-"Waypoint"
+#. Android resource: @strings/cumbria
+msgid "Cumbria"
msgstr ""
-msgid "Satellite Status"
+#. Android resource: @strings/east_yorkshire_with_hull
+msgid "East yorkshire with hull"
msgstr ""
-msgid "NMEA Data"
+#. Android resource: @strings/essex
+msgid "Essex"
msgstr ""
-msgid "car_shortest"
+#. Android resource: @strings/herefordshire
+msgid "Herefordshire"
msgstr ""
-msgid "car_avoid_tolls"
+#. Android resource: @strings/kent
+msgid "Kent"
msgstr ""
-msgid "car_pedantic"
+#. Android resource: @strings/lancashire
+msgid "Lancashire"
msgstr ""
-msgid "horse"
-msgstr "cavall"
+#. Android resource: @strings/leicestershire
+msgid "Leicestershire"
+msgstr ""
-msgid "Truck"
+#. Android resource: @strings/norfolk
+msgid "Norfolk"
msgstr ""
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
+#. Android resource: @strings/nottinghamshire
+msgid "Nottinghamshire"
msgstr ""
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
+#. Android resource: @strings/oxfordshire
+msgid "Oxfordshire"
msgstr ""
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
+#. Android resource: @strings/shropshire
+msgid "Shropshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
+#. Android resource: @strings/somerset
+msgid "Somerset"
msgstr ""
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
+#. Android resource: @strings/south_yorkshire
+msgid "South yorkshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
+#. Android resource: @strings/suffolk
+msgid "Suffolk"
msgstr ""
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
+#. Android resource: @strings/surrey
+msgid "Surrey"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
+#. Android resource: @strings/wiltshire
+msgid "Wiltshire"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
+#. Android resource: @strings/scotland
+msgid "Scotland"
msgstr ""
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
+#. Android resource: @strings/wales
+msgid "Wales"
msgstr ""
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
+#. Android resource: @strings/crete
+msgid "Crete"
msgstr ""
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
+#. Android resource: @strings/north_america
+msgid "North America"
msgstr ""
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
+#. Android resource: @strings/alaska
+msgid "Alaska"
msgstr ""
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
+#. Android resource: @strings/hawaii
+msgid "Hawaii"
msgstr ""
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
+#. Android resource: @strings/usa
+msgid "USA"
msgstr ""
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
msgstr ""
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
+#. Android resource: @strings/midwest
+msgid "Midwest"
msgstr ""
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
+#. Android resource: @strings/michigan
+msgid "Michigan"
msgstr ""
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
+#. Android resource: @strings/ohio
+msgid "Ohio"
msgstr ""
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
+#. Android resource: @strings/northeast
+msgid "Northeast"
msgstr ""
-#. Android resource: @strings/address_search_title
-msgid "Address search"
+#. Android resource: @strings/massachusetts
+msgid "Massachusetts"
msgstr ""
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
+#. Android resource: @strings/vermont
+msgid "Vermont"
msgstr ""
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
+#. Android resource: @strings/pacific
+msgid "Pacific"
msgstr ""
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
+#. Android resource: @strings/south
+msgid "South"
msgstr ""
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
+#. Android resource: @strings/arkansas
+msgid "Arkansas"
msgstr ""
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
+#. Android resource: @strings/district_of_columbia
+msgid "District of Columbia"
msgstr ""
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
+#. Android resource: @strings/florida
+msgid "Florida"
msgstr ""
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
+#. Android resource: @strings/louisiana
+msgid "Louisiana"
msgstr ""
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
+#. Android resource: @strings/maryland
+msgid "Maryland"
msgstr ""
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
+#. Android resource: @strings/mississippi
+msgid "Mississippi"
msgstr ""
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
+#. Android resource: @strings/oklahoma
+msgid "Oklahoma"
msgstr ""
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
+#. Android resource: @strings/texas
+msgid "Texas"
msgstr ""
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
+#. Android resource: @strings/virginia
+msgid "Virginia"
msgstr ""
-#. Android resource: @strings/restoring
-msgid "Restoring..."
+#. Android resource: @strings/west_virginia
+msgid "West Virginia"
msgstr ""
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
+#. Android resource: @strings/west
+msgid "West"
msgstr ""
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
+#. Android resource: @strings/arizona
+msgid "Arizona"
msgstr ""
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
+#. Android resource: @strings/california
+msgid "California"
msgstr ""
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
+#. Android resource: @strings/colorado
+msgid "Colorado"
msgstr ""
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
+#. Android resource: @strings/idaho
+msgid "Idaho"
msgstr ""
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
+#. Android resource: @strings/montana
+msgid "Montana"
msgstr ""
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
+#. Android resource: @strings/new_mexico
+msgid "New Mexico"
msgstr ""
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
+#. Android resource: @strings/nevada
+msgid "Nevada"
msgstr ""
-#. Android resource: @strings/select_backup
-msgid "Select backup"
+#. Android resource: @strings/oregon
+msgid "Oregon"
msgstr ""
-#. Android resource: @strings/backup
-msgid "Backup"
+#. Android resource: @strings/utah
+msgid "Utah"
msgstr ""
-#. Android resource: @strings/restore
-msgid "Restore"
+#. Android resource: @strings/washington_state
+msgid "Washington State"
msgstr ""
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
+#. Android resource: @strings/south_middle_america
+msgid "South+Middle America"
msgstr ""
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
+#. Android resource: @strings/guyane_francaise
+msgid "Guyane Francaise"
msgstr ""
#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Ruta %4.0fkm %02d:%02d TEA"
+
+#, c-format
+#~ msgid "Using config file '%s'\n"
+#~ msgstr "Usant l'arxiu de configuració '%s'\n"
+
+#~ msgid "No config file navit.xml, navit.xml.local found\n"
+#~ msgstr "No s'ha trobat l'arxiu de configuració navit.xml, navit.xml.local\n"
+
+#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
#~ msgstr "aleshores deixeu la rotonda a la %1$s %2$s"
diff --git a/po/ckb.po.in b/po/ckb.po.in
index ab8a5a1eb..549d8f26e 100644
--- a/po/ckb.po.in
+++ b/po/ckb.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/cs.po.in b/po/cs.po.in
index 28a3ec959..4bfa00bc1 100644
--- a/po/cs.po.in
+++ b/po/cs.po.in
@@ -1,9 +1,10 @@
# Čeština translations for navit
-# Copyright (C) 2006-2017 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# 72ka https://launchpad.net/~2hp
# Aleš Janda https://launchpad.net/~kyblicek
+# Clon https://launchpad.net/~fillip1
# Ivan Kološ https://launchpad.net/~ivan-kolos
# Jakuje https://launchpad.net/~jakuje
# Jiří Holubčík https://launchpad.net/~jery
@@ -21,10 +22,10 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2017-09-24 10:28+0000\n"
-"Last-Translator: Pavel Borecki <Unknown>\n"
+"PO-Revision-Date: 2018-05-25 09:58+0000\n"
+"Last-Translator: Clon <Unknown>\n"
"Language-Team: Čeština\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -169,7 +170,6 @@ msgstr "%1$sna %2$s"
msgid "%1$sonto %2$s|neuter form"
msgstr "%1$sna %2$s"
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr "na přivadeč"
@@ -370,7 +370,7 @@ msgstr "Otočte se %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "následujte"
@@ -382,7 +382,6 @@ msgstr "pak budete v cíli."
msgid "You have reached your destination %s"
msgstr "%s dorazíte do cíle"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr "Sjezd"
@@ -399,9 +398,15 @@ msgstr "Příkaz"
msgid "Length"
msgstr "Délka"
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr "stop"
+
msgid "m"
msgstr "m"
@@ -462,6 +467,7 @@ msgid "Anguilla"
msgstr "Anguilla"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Albánie"
@@ -474,6 +480,7 @@ msgid "Netherlands Antilles"
msgstr "Nizozemské Antily"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Angola"
@@ -482,6 +489,7 @@ msgid "Antarctica"
msgstr "Antarktida"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Argentina"
@@ -490,10 +498,12 @@ msgid "American Samoa"
msgstr "Americká Samoa"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Rakousko"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Austrálie"
@@ -506,10 +516,12 @@ msgid "Aland Islands"
msgstr "Ålandy"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Ázerbájdžán"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Bosna a Hercegovina"
@@ -522,6 +534,7 @@ msgid "Bangladesh"
msgstr "Bangladéš"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "Belgie"
@@ -530,6 +543,7 @@ msgid "Burkina Faso"
msgstr "Burkina Faso"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Bulharsko"
@@ -538,6 +552,7 @@ msgid "Bahrain"
msgstr "Bahrajn"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Burundi"
@@ -558,6 +573,7 @@ msgid "Brunei Darussalam"
msgstr "Brunej"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Bolívie"
@@ -566,6 +582,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr "Bonaire, Svatý Eustach a Saba"
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Brazílie"
@@ -582,10 +599,12 @@ msgid "Bouvet Island"
msgstr "Bouvetův ostrov"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Botswana"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Bělorusko"
@@ -594,6 +613,7 @@ msgid "Belize"
msgstr "Belize"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Kanada"
@@ -602,6 +622,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Kokosové (Keelingovy) ostrovy"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Kongo, demokratická republika"
@@ -614,10 +635,12 @@ msgid "Congo"
msgstr "Kongo"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Švýcarsko"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Pobřeží slonoviny"
@@ -626,6 +649,7 @@ msgid "Cook Islands"
msgstr "Cookovy ostrovy"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Chile"
@@ -634,10 +658,12 @@ msgid "Cameroon"
msgstr "Kamerun"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "Čína"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Kolumbie"
@@ -646,6 +672,7 @@ msgid "Costa Rica"
msgstr "Kostarika"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Kuba"
@@ -662,14 +689,17 @@ msgid "Christmas Island"
msgstr "Vánoční ostrov"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Kypr"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "Česká republika"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Německo"
@@ -678,6 +708,7 @@ msgid "Djibouti"
msgstr "Džibutsko"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Dánsko"
@@ -686,6 +717,7 @@ msgid "Dominica"
msgstr "Dominika"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "Dominikánská republika"
@@ -694,10 +726,12 @@ msgid "Algeria"
msgstr "Alžírsko"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Ekvádor"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Estonsko"
@@ -714,14 +748,17 @@ msgid "Eritrea"
msgstr "Eritrea"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Španělsko"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Etiopie"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Finsko"
@@ -738,10 +775,12 @@ msgid "Micronesia, Federated States of"
msgstr "Mikronésie, federativní státy"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Faerské ostrovy"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "Francie"
@@ -750,6 +789,7 @@ msgid "Gabon"
msgstr "Gabon"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Spojené království"
@@ -786,6 +826,7 @@ msgid "Gambia"
msgstr "Gambie"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Guinea"
@@ -798,6 +839,7 @@ msgid "Equatorial Guinea"
msgstr "Rovníková Guinea"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Řecko"
@@ -818,6 +860,7 @@ msgid "Guinea-Bissau"
msgstr "Guinea-Bissau"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Guyana"
@@ -834,26 +877,32 @@ msgid "Honduras"
msgstr "Honduras"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Chorvatsko"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Haiti"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Maďarsko"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Indonésie"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Irsko"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Izrael"
@@ -862,6 +911,7 @@ msgid "Isle of Man"
msgstr "Ostrov Man"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "Indie"
@@ -870,18 +920,22 @@ msgid "British Indian Ocean Territory"
msgstr "Britské indickooceánské území"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Irák"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Írán, islámská republika"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Island"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Itálie"
@@ -890,6 +944,7 @@ msgid "Jersey"
msgstr "Jersey"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Jamajka"
@@ -898,14 +953,17 @@ msgid "Jordan"
msgstr "Jordánsko"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Japonsko"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Keňa"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Kyrgyzstán"
@@ -942,6 +1000,7 @@ msgid "Cayman Islands"
msgstr "Kajmanské ostrovy"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Kazachstán"
@@ -966,26 +1025,32 @@ msgid "Sri Lanka"
msgstr "Srí Lanka"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Libérie"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Lesotho"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Litva"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Lucembursko"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Lotyšsko"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr "Libye"
@@ -1010,6 +1075,7 @@ msgid "Saint Martin (French part)"
msgstr "Svatý Martin (francouzská část)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Madagaskar"
@@ -1030,6 +1096,7 @@ msgid "Myanmar"
msgstr "Myanmar"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Mongolsko"
@@ -1070,10 +1137,12 @@ msgid "Malawi"
msgstr "Malawi"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "Mexiko"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Malajsie"
@@ -1082,10 +1151,12 @@ msgid "Mozambique"
msgstr "Mosambik"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Namibie"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Nová Kaledonie"
@@ -1106,6 +1177,7 @@ msgid "Nicaragua"
msgstr "Nikaragua"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Nizozemsko"
@@ -1114,6 +1186,7 @@ msgid "Norway"
msgstr "Norsko"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Nepál"
@@ -1126,6 +1199,7 @@ msgid "Niue"
msgstr "Niue"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Nový Zéland"
@@ -1138,6 +1212,7 @@ msgid "Panama"
msgstr "Panama"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Peru"
@@ -1150,14 +1225,17 @@ msgid "Papua New Guinea"
msgstr "Papua Nová Guinea"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Filipíny"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Pákistán"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Polsko"
@@ -1178,6 +1256,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Palestinské území, okupované"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Portugalsko"
@@ -1186,6 +1265,7 @@ msgid "Palau"
msgstr "Palau"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Paraguay"
@@ -1194,10 +1274,12 @@ msgid "Qatar"
msgstr "Katar"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Réunion"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Rumunsko"
@@ -1206,14 +1288,17 @@ msgid "Serbia"
msgstr "Srbsko"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Ruská federace"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Rwanda"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Saúdská Arábie"
@@ -1234,6 +1319,7 @@ msgid "Sweden"
msgstr "Švédsko"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Singapur"
@@ -1250,6 +1336,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Špicberky a Jan Mayen"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Slovensko"
@@ -1270,6 +1357,7 @@ msgid "Somalia"
msgstr "Somálsko"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Surinam"
@@ -1314,6 +1402,7 @@ msgid "Togo"
msgstr "Togo"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Thajsko"
@@ -1330,6 +1419,7 @@ msgid "Timor-Leste"
msgstr "Východní Timor"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Turkmenistán"
@@ -1342,6 +1432,7 @@ msgid "Tonga"
msgstr "Tonga"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Turecko"
@@ -1358,14 +1449,17 @@ msgid "Taiwan, Province of China"
msgstr "Tchaj-wan, provincie Číny"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Tanzanie, sjednocená republika"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Ukrajina"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Uganda"
@@ -1378,6 +1472,7 @@ msgid "United States"
msgstr "Spojené státy"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Uruguay"
@@ -1394,6 +1489,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "Svatý Vincenc a Grenadiny"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Venezuela"
@@ -1430,6 +1526,7 @@ msgid "Mayotte"
msgstr "Mayotte"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "Jihoafrická republika"
@@ -1455,28 +1552,36 @@ msgid ""
"\t-h: print this usage info and exit.\n"
"\t-v: print the version and exit.\n"
msgstr ""
+"použití navit:\n"
+"navit [možnosti] [configfile]\n"
+"\t-c <soubor>: použíjte <soubor> jako konfiguračnísoubor, místo použítí "
+"výchozího souboru.\n"
+"\t-d <n>: nastaví globální hodnotu ladění na <n> (0=chyba, 1=varování, "
+"2=informace, 3=ladění).\n"
+"\tNastavení z konfiguračního souboru budou použita tam kde nastavují vyšší "
+"hodnotu.\n"
+"\t-h: vytisknout tyto informace o použití a zavřít.\n"
+"\t-v: vytisknout verzi a zavřít.\n"
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
-msgstr "Nenalezen konfigurační soubor navit.xml a navit.xml.local\n"
+msgid "No config file navit.xml, navit.xml.local found"
+msgstr "Nebyl nalezen konfigurační soubor navit.xml, navit.xml.local"
#, c-format
-msgid "Error parsing config file '%s': %s\n"
-msgstr "Chyba při zpracování konfiguračního souboru '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
+msgstr "Chyba při načítání konfiguračního souboru '%s': %s"
#, c-format
-msgid "Using config file '%s'\n"
-msgstr "Používáte konfigurační soubor '% s'\n"
+msgid "Using config file '%s'"
+msgstr "Použit konfigurační soubor '%s'"
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
-msgstr "Chyba: Nenalezena žádná konfigurace v konfiguračním souboru '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
+msgstr "Chyba: Nebylo nalezeno nastavení v konfiguračním souboru '%s'"
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
-"Interní selhání inicializace, končím. Zkontrolujte předchozí chybové "
-"zprávy.\n"
msgid "unknown street"
msgstr "neznámá ulice"
@@ -1616,6 +1721,9 @@ msgstr "Zobrazit pozici _kurzoru"
msgid "_Lock on Road"
msgstr "Jet jen po silnici"
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr "_Orientovat na sever"
@@ -1685,24 +1793,29 @@ msgstr "Taxi"
msgid "Shopping"
msgstr "Nakupování"
-msgid "Distance from screen center (km)"
-msgstr "Vzdálenost od středu mapy (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
+msgstr ""
#, c-format
msgid "POI %s. %s"
msgstr "POI %s. %s"
#, c-format
-msgid "Set destination to %ld, %ld \n"
-msgstr "Nastav cíl na %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
+msgstr "Nastavit cíl na %ld, %ld "
#, c-format
-msgid "Set map to %ld, %ld \n"
-msgstr "Posuň mapu na %ld, %ld \n"
+msgid "Set map to %ld, %ld "
+msgstr "Nastavit mapu na %ld, %ld "
#, c-format
-msgid "Set next visit to %ld, %ld \n"
-msgstr "Nastav další zastavení na %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
+msgstr "Nastavit příští návštěvu na %ld, %ld "
msgid "POI search"
msgstr "Vyhledávání POI"
@@ -1710,9 +1823,6 @@ msgstr "Vyhledávání POI"
msgid "Select a category"
msgstr "Vyberte kategorii"
-msgid "Select a distance to look for (km)"
-msgstr "Vyberte vzdálenost ve které hledat (km)"
-
msgid "Select a POI"
msgstr "Vyberte POI"
@@ -1725,8 +1835,8 @@ msgstr "Kategorie"
msgid "Direction"
msgstr "Směr"
-msgid "Distance(m)"
-msgstr "Vzdálenost (m)"
+msgid "Distance"
+msgstr ""
msgid "Name"
msgstr "Název"
@@ -1772,8 +1882,8 @@ msgid "OT"
msgstr "OT"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Trasa %4.0fkm %02d:%02d ETA"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "Trasa 0000km 0+00:00 ETA"
@@ -1944,10 +2054,10 @@ msgstr "Body trasy"
msgid "Enter Coordinates"
msgstr "Zadejte souřadnice"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1987,7 +2097,7 @@ msgid "please install a map *.heightlines.bin to provide elevationdata"
msgstr "pro výškové údaje nainstalujte mapu *.heightlines.bin"
msgid "The route must cross at least 2 heightlines"
-msgstr ""
+msgstr "Trasa musí překročit alspoň dvě vrstevnice."
msgid "Route Description"
msgstr "Popis trasy"
@@ -2036,29 +2146,224 @@ msgstr "Pozor! Kamera!"
msgid "Please decrease your speed"
msgstr "Zpomalte"
-msgid "partial match"
-msgstr "Částečná shoda"
+msgid "Vehicle Position"
+msgstr "Poloha vozidla"
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr "Vyhledat"
+msgid "Main menu"
+msgstr "Hlavní nabídka"
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
-msgstr "Města"
+msgid ""
+"Show\n"
+"Map"
+msgstr ""
+"Zobrazit\n"
+"mapu"
+
+msgid "Settings"
+msgstr "Nastavení"
+
+msgid "Tools"
+msgstr "Nástroje"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr "Mapová data (c) přispěvatelé OpenStreetMap, ODBL"
+msgid "Route"
+msgstr "Trasa"
+
+msgid "About"
+msgstr "O aplikaci"
+
+msgid "Quit"
+msgstr "Ukončit"
+
+msgid "Actions"
+msgstr "Akce"
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Former\n"
+"Destinations"
msgstr ""
+"Minulé\n"
+"cíle"
+
+msgid "Coordinates"
+msgstr "Souřadnice"
+
+msgid ""
+"Stop\n"
+"Navigation"
+msgstr ""
+"Ukončit\n"
+"navigaci"
+
+msgid "Display"
+msgstr "Zobrazit"
+
+msgid "Fullscreen"
+msgstr "Celá obrazovka"
+
+msgid "Window Mode"
+msgstr "V okně"
+
+msgid "Auto zoom"
+msgstr "Automatické přiblížení"
+
+msgid "Manual zoom"
+msgstr "Ruční přiblížení"
+
+msgid "Layers"
+msgstr "Vrstvy"
+
+msgid "Zoom to route"
+msgstr "Přiblížit trasu"
+
+msgid "Description"
+msgstr "Popis"
+
+msgid ""
+"Drop last\n"
+"Waypoint"
+msgstr ""
+
+msgid ""
+"Drop next\n"
+"Waypoint"
+msgstr ""
+
+msgid "Satellite Status"
+msgstr "Stav satelitu"
+
+msgid "NMEA Data"
+msgstr "NMEA údaje"
+
+msgid "car_shortest"
+msgstr "auto nejkratší"
+
+msgid "car_avoid_tolls"
+msgstr "auto bez mýtného"
+
+msgid "car_pedantic"
+msgstr "auto puntičkářské"
+
+msgid "horse"
+msgstr "kůň"
+
+msgid "Truck"
+msgstr "Nákladní vůz"
+
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
+msgstr "Ano"
+
+#. Android resource: @strings/cancel
+msgid "Cancel"
+msgstr "Storno"
+
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
+msgstr "Startuje Navit"
+
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
+msgstr "Navit je spuštěný"
+
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
+msgstr "Vítejte v Navit"
+
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
+msgstr ""
+"Děkujeme za instalaci Navit!\n"
+"\n"
+"Pro začátek, vyberte \"Stáhnout mapy\" z menu pro stažení map. Poznámka: "
+"Velikost souboru map mohou být velké (>50MB) - wifi připojení je "
+"doporučeno.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap a přispěvovatelé\n"
+"\n"
+"Užijte si Navit!"
+
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
+msgstr "OK"
+
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
+msgstr "Další informace"
+
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
+msgstr "Přiblížit"
+
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
+msgstr "Oddálit"
+
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
+msgstr "Stáhnout mapy"
+
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
+msgstr "Přepnout Body zájmu (POIs = Points of Interest)"
+
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
+msgstr "Ukončit Navit"
+
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
+msgstr "Zálohovat / Obnovit"
-msgid "Downloaded maps"
-msgstr "Stažené mapy"
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
+msgstr "Nastavit umístění mapy"
+
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
+msgstr "Cestovat sem"
+
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
+msgstr "Smazat tuto mapu?"
+
+#. Android resource: @strings/map_download_title
+msgid "Map download"
+msgstr "Mapa ke stažení"
+
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
+msgstr "Stahování:"
+
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
+msgstr "Zbývající čas"
+#. Android resource: @strings/map_download_ready
+msgid "ready"
+msgstr "mapa připravena"
+
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
+msgstr "Chyba při stahování map."
+
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
+msgstr "Stahování map přerušeno"
+
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
+msgstr "Není dostatek volného místa"
+
+#. Android resource: @strings/map_download_oversize
msgid ""
"Sorry, we currently do not support maps above 3.8G on Android, please select "
"a smaller one."
@@ -2066,744 +2371,736 @@ msgstr ""
"Omlouváme se, ale na systému Android tato aplikace v současnosti nepodporuje "
"mapy větší, než 3,8 GiB – vyberte takovou, která nepřekračuje tuto hranici."
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr "Cestovat sem"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
+msgstr "Žádné umístění. Zkuste znovu po opravě umístění."
-msgid "Cancel"
-msgstr "Storno"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
+msgstr "Mapy obsahující nynější umístění"
+
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
+msgstr ""
+
+#. Android resource: @strings/map_downloading
+msgid "downloading"
+msgstr "stahování…"
+
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
+msgstr "Médium zvolené pro uchovávání map není k dispozici"
+
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
+msgstr "Chyba při zápisu mapy!"
+
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
+msgstr ""
+
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
+msgstr ""
+
+#. Android resource: @strings/address_search_title
+msgid "Address search"
+msgstr "Hledat dle adresy"
+
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
+msgstr "Zadejte cíl"
-msgid "filenamePath"
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
+msgstr "Shoda částí adresy"
+
+#. Android resource: @strings/address_search_button
+msgid "Search"
+msgstr "Vyhledat"
+
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
+msgstr "Vyhledávání…"
+
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
+msgstr "Adresa nebyla nalezena"
+
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
+msgstr "Výsledky hledání"
+
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
+msgstr "Načítání výsledku vyhledávání"
+
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
+msgstr "Výsledky nenalezeny."
+
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
+msgstr "Nebyl zadán žádný text"
+
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
+msgstr "Nastavování cíle na:"
+
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
+msgstr "Města"
+
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
+msgstr "Vyberte akci"
+
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
+msgstr "Vložte SD kartu"
+
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
+msgstr "Zálohování…"
+
+#. Android resource: @strings/restoring
+msgid "Restoring..."
+msgstr "Obnovování…"
+
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
+msgstr "Nezdařilo se vytvořit adresář pro zálohu"
+
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
+msgstr "Záloha se nezdařila"
+
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
+msgstr "Záloha nenalezena"
+
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
+msgstr "Obnova se nezdařila"
+
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
+msgstr "Záloha byla úspěšná"
+
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
+msgstr ""
+"Obnova byla úspěšná.\n"
+"Restartujte prosím Navit."
+
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
+msgstr "Záloha nenalezena"
+
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
+msgstr "Obnova selhala"
+
+#. Android resource: @strings/select_backup
+msgid "Select backup"
+msgstr "Vyberte zálohu"
+
+#. Android resource: @strings/backup
+msgid "Backup"
+msgstr "Zálohování"
+
+#. Android resource: @strings/restore
+msgid "Restore"
+msgstr "Obnova"
+
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
+msgstr "Chybí data systémového převodníku textu na řeč"
+
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
+#. Android resource: @strings/permissions_not_granted
msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
+msgstr "Chybí přinejmenším jedno oprávnění"
+
+#. Android resource: @strings/whole_planet
msgid "Whole Planet"
msgstr "Celá planeta"
+#. Android resource: @strings/africa
msgid "Africa"
msgstr "Afrika"
+#. Android resource: @strings/canary_islands
msgid "Canary Islands"
msgstr "Kanárské ostrovy"
+#. Android resource: @strings/asia
msgid "Asia"
msgstr "Asie"
-msgid "Korea"
-msgstr "Korea"
-
+#. Android resource: @strings/taiwan
msgid "Taiwan"
msgstr "Taiwan"
+#. Android resource: @strings/korea
+msgid "Korea"
+msgstr "Korea"
+
+#. Android resource: @strings/uae_other
msgid "UAE+Other"
msgstr "Spojené arabské emiráty+ostatní"
+#. Android resource: @strings/oceania
msgid "Oceania"
msgstr "Oceánie"
+#. Android resource: @strings/tasmania
msgid "Tasmania"
msgstr "Tasmánie"
+#. Android resource: @strings/victoria
msgid "Victoria"
msgstr "Viktorie"
+#. Android resource: @strings/new_south_wales
msgid "New South Wales"
msgstr "Nový Jižní Wales"
+#. Android resource: @strings/europe
msgid "Europe"
msgstr "Evropa"
+#. Android resource: @strings/western_europe
msgid "Western Europe"
msgstr "Západní Evropa"
+#. Android resource: @strings/azores
msgid "Azores"
msgstr "Azory"
+#. Android resource: @strings/benelux
msgid "BeNeLux"
msgstr "Benelux"
+#. Android resource: @strings/alsace
msgid "Alsace"
msgstr "Alsasko"
+#. Android resource: @strings/aquitaine
msgid "Aquitaine"
msgstr "Akvitánie"
+#. Android resource: @strings/auvergne
msgid "Auvergne"
msgstr "Auvergne"
-msgid "Basse-Normandie"
-msgstr "Dolní Normandie"
-
-msgid "Bourgogne"
-msgstr "Burgundsko"
+#. Android resource: @strings/centre
+msgid "Centre"
+msgstr "Střed"
+#. Android resource: @strings/bretagne
msgid "Bretagne"
msgstr "Bretaň"
-msgid "Centre"
-msgstr "Střed"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
+msgstr "Burgundsko"
+
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
+msgstr "Dolní Normandie"
+#. Android resource: @strings/champagne_ardenne
msgid "Champagne-Ardenne"
msgstr "Champagne-Ardennes"
+#. Android resource: @strings/corse
msgid "Corse"
msgstr "Korsika"
+#. Android resource: @strings/franche_comte
msgid "Franche-Comte"
msgstr "Franche-Comté"
+#. Android resource: @strings/haute_normandie
msgid "Haute-Normandie"
msgstr "Horní Normandie"
+#. Android resource: @strings/ile_de_france
msgid "Ile-de-France"
msgstr "Ile-de-France"
+#. Android resource: @strings/languedoc_roussillon
msgid "Languedoc-Roussillon"
msgstr "Languedoc-Roussillon"
+#. Android resource: @strings/limousin
msgid "Limousin"
msgstr "Limousin"
+#. Android resource: @strings/lorraine
msgid "Lorraine"
msgstr "Lotrinsko"
+#. Android resource: @strings/midi_pyrenees
msgid "Midi-Pyrenees"
msgstr "Jižní Pyreneje"
+#. Android resource: @strings/nord_pas_de_calais
msgid "Nord-pas-de-Calais"
msgstr "Nord-pas-de-Calais"
+#. Android resource: @strings/pays_de_la_loire
msgid "Pays-de-la-Loire"
msgstr "Pays-de-la-Loire"
+#. Android resource: @strings/picardie
msgid "Picardie"
msgstr "Pikardie"
+#. Android resource: @strings/poitou_charentes
msgid "Poitou-Charentes"
msgstr "Poitou-Charentes"
+#. Android resource: @strings/provence_alpes_cote_d_azur
msgid "Provence-Alpes-Cote-d-Azur"
msgstr "Provensálsko-Alpy-Azurové pobřeží"
+#. Android resource: @strings/rhone_alpes
msgid "Rhone-Alpes"
msgstr "Rhone-Alpy"
+#. Android resource: @strings/baden_wuerttemberg
msgid "Baden-Wuerttemberg"
msgstr "Baden-Württembersko"
+#. Android resource: @strings/bayern
msgid "Bayern"
msgstr "Bavorsko"
+#. Android resource: @strings/mittelfranken
msgid "Mittelfranken"
msgstr "Střední Franky"
+#. Android resource: @strings/niederbayern
msgid "Niederbayern"
msgstr "Dolní Bavorsko"
+#. Android resource: @strings/oberbayern
msgid "Oberbayern"
msgstr "Horní Bavorsko"
+#. Android resource: @strings/oberfranken
msgid "Oberfranken"
msgstr "Horní Franky"
+#. Android resource: @strings/oberpfalz
msgid "Oberpfalz"
msgstr "Horní Falcko"
+#. Android resource: @strings/schwaben
msgid "Schwaben"
msgstr "Švábsko"
+#. Android resource: @strings/unterfranken
msgid "Unterfranken"
msgstr "Dolní Franky"
+#. Android resource: @strings/berlin
msgid "Berlin"
msgstr "Berlín"
+#. Android resource: @strings/brandenburg
msgid "Brandenburg"
msgstr "Braniborsko"
+#. Android resource: @strings/bremen
msgid "Bremen"
msgstr "Brémy"
+#. Android resource: @strings/hamburg
msgid "Hamburg"
msgstr "Hamburg"
+#. Android resource: @strings/hessen
msgid "Hessen"
msgstr "Hessensko"
+#. Android resource: @strings/mecklenburg_vorpommern
msgid "Mecklenburg-Vorpommern"
msgstr "Meklenbursko-Pomořansko"
+#. Android resource: @strings/niedersachsen
msgid "Niedersachsen"
msgstr "Dolní Sasko"
+#. Android resource: @strings/nordrhein_westfalen
msgid "Nordrhein-westfalen"
msgstr "Severní Porýní-Vestfálsko"
+#. Android resource: @strings/rheinland_pfalz
msgid "Rheinland-Pfalz"
msgstr "Porýnsko-Falcko"
+#. Android resource: @strings/saarland
msgid "Saarland"
msgstr "Sársko"
+#. Android resource: @strings/sachsen_anhalt
msgid "Sachsen-Anhalt"
msgstr "Sasko-Anhaltsko"
+#. Android resource: @strings/sachsen
msgid "Sachsen"
msgstr "Sasko"
+#. Android resource: @strings/schleswig_holstein
msgid "Schleswig-Holstein"
msgstr "Šlesvicko-Holštýnsko"
+#. Android resource: @strings/thueringen
msgid "Thueringen"
msgstr "Thueringen"
+#. Android resource: @strings/mallorca
msgid "Mallorca"
msgstr "Mallorca"
+#. Android resource: @strings/galicia
msgid "Galicia"
msgstr "Galície"
+#. Android resource: @strings/scandinavia
msgid "Scandinavia"
msgstr "Skandinávie"
+#. Android resource: @strings/england
msgid "England"
msgstr "Anglie"
+#. Android resource: @strings/buckinghamshire
msgid "Buckinghamshire"
msgstr "Buckinghamshire"
+#. Android resource: @strings/cambridgeshire
msgid "Cambridgeshire"
msgstr "Cambridgeshire"
+#. Android resource: @strings/cumbria
msgid "Cumbria"
msgstr "Cumbria"
+#. Android resource: @strings/east_yorkshire_with_hull
msgid "East yorkshire with hull"
msgstr "Východní Yorkshire a Hull"
+#. Android resource: @strings/essex
msgid "Essex"
msgstr "Essex"
+#. Android resource: @strings/herefordshire
msgid "Herefordshire"
msgstr "Herefordshire"
+#. Android resource: @strings/kent
msgid "Kent"
msgstr "Kent"
+#. Android resource: @strings/lancashire
msgid "Lancashire"
msgstr "Lancashire"
+#. Android resource: @strings/leicestershire
msgid "Leicestershire"
msgstr "Leicestershire"
+#. Android resource: @strings/norfolk
msgid "Norfolk"
msgstr "Norfolk"
+#. Android resource: @strings/nottinghamshire
msgid "Nottinghamshire"
msgstr "Nottinghamshire"
+#. Android resource: @strings/oxfordshire
msgid "Oxfordshire"
msgstr "Oxfordshire"
+#. Android resource: @strings/shropshire
msgid "Shropshire"
msgstr "Shropshire"
+#. Android resource: @strings/somerset
msgid "Somerset"
msgstr "Somerset"
+#. Android resource: @strings/south_yorkshire
msgid "South yorkshire"
msgstr "Jižní Yorkshire"
+#. Android resource: @strings/suffolk
msgid "Suffolk"
msgstr "Suffolk"
+#. Android resource: @strings/surrey
msgid "Surrey"
msgstr "Surrey"
+#. Android resource: @strings/wiltshire
msgid "Wiltshire"
msgstr "Wiltshire"
+#. Android resource: @strings/scotland
msgid "Scotland"
msgstr "Skotsko"
+#. Android resource: @strings/wales
msgid "Wales"
msgstr "Wales"
+#. Android resource: @strings/crete
msgid "Crete"
msgstr "Kréta"
+#. Android resource: @strings/north_america
msgid "North America"
msgstr "Severní Amerika"
+#. Android resource: @strings/alaska
msgid "Alaska"
msgstr "Aljaška"
+#. Android resource: @strings/hawaii
msgid "Hawaii"
msgstr "Havaj"
+#. Android resource: @strings/usa
msgid "USA"
msgstr "USA"
-msgid " (except Alaska and Hawaii)"
-msgstr " (mimo Aljašky a Havaje)"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
+msgstr ""
+#. Android resource: @strings/midwest
msgid "Midwest"
msgstr "Středozápad"
+#. Android resource: @strings/michigan
msgid "Michigan"
msgstr "Michigan"
+#. Android resource: @strings/ohio
msgid "Ohio"
msgstr "Ohio"
+#. Android resource: @strings/northeast
msgid "Northeast"
msgstr "Severovýchod"
+#. Android resource: @strings/massachusetts
msgid "Massachusetts"
msgstr "Massachusetts"
+#. Android resource: @strings/vermont
msgid "Vermont"
msgstr "Vermont"
+#. Android resource: @strings/pacific
msgid "Pacific"
msgstr "Tichý oceán"
+#. Android resource: @strings/south
msgid "South"
msgstr "Jih"
+#. Android resource: @strings/arkansas
msgid "Arkansas"
msgstr "Arkansas"
+#. Android resource: @strings/district_of_columbia
msgid "District of Columbia"
msgstr "Washington D.C."
+#. Android resource: @strings/florida
msgid "Florida"
msgstr "Florida"
+#. Android resource: @strings/louisiana
msgid "Louisiana"
msgstr "Louisiana"
+#. Android resource: @strings/maryland
msgid "Maryland"
msgstr "Maryland"
+#. Android resource: @strings/mississippi
msgid "Mississippi"
msgstr "Mississippi"
+#. Android resource: @strings/oklahoma
msgid "Oklahoma"
msgstr "Oklahoma"
+#. Android resource: @strings/texas
msgid "Texas"
msgstr "Texas"
+#. Android resource: @strings/virginia
msgid "Virginia"
msgstr "Virginie"
+#. Android resource: @strings/west_virginia
msgid "West Virginia"
msgstr "Západní Virginie"
+#. Android resource: @strings/west
msgid "West"
msgstr "Západ"
+#. Android resource: @strings/arizona
msgid "Arizona"
msgstr "Arizona"
+#. Android resource: @strings/california
msgid "California"
msgstr "Kalifornie"
+#. Android resource: @strings/colorado
msgid "Colorado"
msgstr "Colorado"
+#. Android resource: @strings/idaho
msgid "Idaho"
msgstr "Idaho"
+#. Android resource: @strings/montana
msgid "Montana"
msgstr "Montana"
+#. Android resource: @strings/new_mexico
msgid "New Mexico"
msgstr "Nové Mexico"
+#. Android resource: @strings/nevada
msgid "Nevada"
msgstr "Nevada"
+#. Android resource: @strings/oregon
msgid "Oregon"
msgstr "Oregon"
+#. Android resource: @strings/utah
msgid "Utah"
msgstr "Utah"
+#. Android resource: @strings/washington_state
msgid "Washington State"
msgstr "Stát Washington"
+#. Android resource: @strings/south_middle_america
msgid "South+Middle America"
msgstr "Jižní a Střední Amerika"
+#. Android resource: @strings/guyane_francaise
msgid "Guyane Francaise"
msgstr "Francouzská Guyana"
-msgid "downloading"
-msgstr "stahování…"
-
-#. Android resource: @strings/map_download_ready
-msgid "ready"
-msgstr "mapa připravena"
-
-msgid "Media selected for map storage is not available"
-msgstr "Médium zvolené pro uchovávání map není k dispozici"
-
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
-msgstr "Není dostatek volného místa"
-
-msgid "Error downloading map!"
-msgstr "Chyba při stahování mapy!"
-
-msgid "Error writing map!"
-msgstr "Chyba při zápisu mapy!"
-
-msgid "Map download aborted!"
-msgstr "Stahování mapy přerušeno!"
-
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
-msgstr "Zbývající čas"
-
-#. Android resource: @strings/map_download_title
-msgid "Map download"
-msgstr "Mapa ke stažení"
-
-msgid "Vehicle Position"
-msgstr "Poloha vozidla"
-
-msgid "Main menu"
-msgstr "Hlavní nabídka"
-
-msgid ""
-"Show\n"
-"Map"
-msgstr ""
-"Zobrazit\n"
-"mapu"
-
-msgid "Settings"
-msgstr "Nastavení"
-
-msgid "Tools"
-msgstr "Nástroje"
-
-msgid "Route"
-msgstr "Trasa"
-
-msgid "About"
-msgstr "O aplikaci"
-
-msgid "Quit"
-msgstr "Ukončit"
-
-msgid "Actions"
-msgstr "Akce"
-
-msgid ""
-"Former\n"
-"Destinations"
-msgstr ""
-"Minulé\n"
-"cíle"
-
-msgid "Coordinates"
-msgstr "Souřadnice"
-
-msgid ""
-"Stop\n"
-"Navigation"
-msgstr ""
-"Ukončit\n"
-"navigaci"
-
-msgid "Display"
-msgstr "Zobrazit"
-
-msgid "Fullscreen"
-msgstr "Celá obrazovka"
-
-msgid "Window Mode"
-msgstr "V okně"
-
-msgid "Auto zoom"
-msgstr "Automatické přiblížení"
-
-msgid "Manual zoom"
-msgstr "Ruční přiblížení"
-
-msgid "Layers"
-msgstr "Vrstvy"
-
-msgid "Zoom to route"
-msgstr "Přiblížit trasu"
-
-msgid "Description"
-msgstr "Popis"
-
-msgid ""
-"Drop last \n"
-"Waypoint"
-msgstr ""
-"Zrušit minulý \n"
-"bod trasy"
-
-msgid ""
-"Drop next \n"
-"Waypoint"
-msgstr ""
-"Zrušit příští \n"
-" bod trasy"
-
-msgid "Satellite Status"
-msgstr "Stav satelitu"
-
-msgid "NMEA Data"
-msgstr "NMEA údaje"
-
-msgid "car_shortest"
-msgstr "auto nejkratší"
-
-msgid "car_avoid_tolls"
-msgstr "auto bez mýtného"
-
-msgid "car_pedantic"
-msgstr "auto puntičkářské"
-
-msgid "horse"
-msgstr "kůň"
-
-msgid "Truck"
-msgstr "Nákladní vůz"
-
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
-msgstr "Ano"
-
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
-msgstr "Startuje Navit"
-
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
-msgstr "Navit je spuštěný"
-
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
-msgstr "Vítejte v Navit"
-
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
-msgstr ""
-"Děkujeme za instalaci Navit!\n"
-"\n"
-"Pro začátek, vyberte \"Stáhnout mapy\" z menu pro stažení map. Poznámka: "
-"Velikost souboru map mohou být velké (>50MB) - wifi připojení je "
-"doporučeno.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap a přispěvovatelé\n"
-"\n"
-"Užijte si Navit!"
-
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
-msgstr "OK"
-
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
-msgstr "Další informace"
-
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
-msgstr "Přiblížit"
-
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
-msgstr "Oddálit"
-
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
-msgstr "Stáhnout mapy"
-
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
-msgstr "Přepnout Body zájmu (POIs = Points of Interest)"
-
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
-msgstr "Ukončit Navit"
-
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
-msgstr "Zálohovat / Obnovit"
-
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
-msgstr "Nastavit umístění mapy"
-
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
-msgstr "Smazat tuto mapu?"
-
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
-msgstr "Stahování:"
-
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
-msgstr "Chyba při stahování map."
-
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
-msgstr "Stahování map přerušeno"
-
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
-msgstr "Žádné umístění. Zkuste znovu po opravě umístění."
-
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
-msgstr "Mapy obsahující nynější umístění"
-
-#. Android resource: @strings/address_search_title
-msgid "Address search"
-msgstr "Hledat dle adresy"
-
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
-msgstr "Zadejte cíl"
-
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
-msgstr "Shoda částí adresy"
-
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
-msgstr "Vyhledávání…"
-
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
-msgstr "Adresa nebyla nalezena"
-
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
-msgstr "Výsledky hledání"
-
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
-msgstr "Načítání výsledku vyhledávání"
-
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
-msgstr "Výsledky nenalezeny."
-
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
-msgstr "Nebyl zadán žádný text"
-
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
-msgstr "Nastavování cíle na:"
+#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Trasa %4.0fkm %02d:%02d ETA"
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
-msgstr "Vyberte akci"
+#~ msgid "No config file navit.xml, navit.xml.local found\n"
+#~ msgstr "Nenalezen konfigurační soubor navit.xml a navit.xml.local\n"
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
-msgstr "Vložte SD kartu"
+#, c-format
+#~ msgid "Error parsing config file '%s': %s\n"
+#~ msgstr "Chyba při zpracování konfiguračního souboru '%s': %s\n"
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
-msgstr "Zálohování…"
+#, c-format
+#~ msgid "Using config file '%s'\n"
+#~ msgstr "Používáte konfigurační soubor '% s'\n"
-#. Android resource: @strings/restoring
-msgid "Restoring..."
-msgstr "Obnovování…"
+#~ msgid ""
+#~ "Internal initialization failed, exiting. Check previous error messages.\n"
+#~ msgstr ""
+#~ "Interní selhání inicializace, končím. Zkontrolujte předchozí chybové "
+#~ "zprávy.\n"
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
-msgstr "Nezdařilo se vytvořit adresář pro zálohu"
+#~ msgid "partial match"
+#~ msgstr "Částečná shoda"
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
-msgstr "Záloha se nezdařila"
+#~ msgid "Map data (c) OpenStreetMap contributors, ODBL"
+#~ msgstr "Mapová data (c) přispěvatelé OpenStreetMap, ODBL"
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
-msgstr "Záloha nenalezena"
+#~ msgid "Downloaded maps"
+#~ msgstr "Stažené mapy"
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
-msgstr "Obnova se nezdařila"
+#~ msgid " (except Alaska and Hawaii)"
+#~ msgstr " (mimo Aljašky a Havaje)"
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
-msgstr "Záloha byla úspěšná"
+#~ msgid "Error downloading map!"
+#~ msgstr "Chyba při stahování mapy!"
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
-msgstr ""
-"Obnova byla úspěšná.\n"
-"Restartujte prosím Navit."
+#~ msgid "Map download aborted!"
+#~ msgstr "Stahování mapy přerušeno!"
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
-msgstr "Záloha nenalezena"
+#~ msgid ""
+#~ "Drop last \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Zrušit minulý \n"
+#~ "bod trasy"
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
-msgstr "Obnova selhala"
+#~ msgid ""
+#~ "Drop next \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Zrušit příští \n"
+#~ " bod trasy"
-#. Android resource: @strings/select_backup
-msgid "Select backup"
-msgstr "Vyberte zálohu"
+#, c-format
+#~ msgid "Error: No configuration found in config file '%s'\n"
+#~ msgstr "Chyba: Nenalezena žádná konfigurace v konfiguračním souboru '%s'\n"
-#. Android resource: @strings/backup
-msgid "Backup"
-msgstr "Zálohování"
+#~ msgid "Distance from screen center (km)"
+#~ msgstr "Vzdálenost od středu mapy (km)"
-#. Android resource: @strings/restore
-msgid "Restore"
-msgstr "Obnova"
+#, c-format
+#~ msgid "Set destination to %ld, %ld \n"
+#~ msgstr "Nastav cíl na %ld, %ld \n"
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
-msgstr "Chybí data systémového převodníku textu na řeč"
+#, c-format
+#~ msgid "Set map to %ld, %ld \n"
+#~ msgstr "Posuň mapu na %ld, %ld \n"
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
-msgstr ""
+#, c-format
+#~ msgid "Set next visit to %ld, %ld \n"
+#~ msgstr "Nastav další zastavení na %ld, %ld \n"
-#. Android resource: @strings/permissions_not_granted
-msgid ""
-"Navit needs permission to access GPS and read the map.\n"
-"If you change your mind please restart Navit and grant the permissions"
-msgstr ""
+#~ msgid "Select a distance to look for (km)"
+#~ msgstr "Vyberte vzdálenost ve které hledat (km)"
-#. Android resource: @strings/permissions_info_box_title
-msgid "One or more ungranted permissions"
-msgstr "Chybí přinejmenším jedno oprávnění"
+#~ msgid "Distance(m)"
+#~ msgstr "Vzdálenost (m)"
#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
diff --git a/po/cy.po.in b/po/cy.po.in
index 9171574a7..db524f7f2 100644
--- a/po/cy.po.in
+++ b/po/cy.po.in
@@ -355,7 +355,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1668,7 +1668,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1927,10 +1927,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/da.po.in b/po/da.po.in
index 2bd2cee87..e3c1d3c5b 100644
--- a/po/da.po.in
+++ b/po/da.po.in
@@ -361,7 +361,7 @@ msgstr "Vend om %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "følg"
@@ -1674,7 +1674,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1933,10 +1933,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/de.po.in b/po/de.po.in
index 7ff0ba0e6..16fa0717b 100644
--- a/po/de.po.in
+++ b/po/de.po.in
@@ -1,18 +1,15 @@
# German translations for navit
-# Copyright (C) 2006-2017 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Achim Behrens https://launchpad.net/~k1l
# Artem Anufrij https://launchpad.net/~artem-anufrij
# Bernhard Reiter https://launchpad.net/~ockham-razor
# Christian Moll https://launchpad.net/~christian-chrmoll
-# Clemens Kiener https://launchpad.net/~clemens-kiener
# Dennis Gohert https://launchpad.net/~info-degoist
-# Ettore Atalan https://launchpad.net/~atalanttore
# Fred https://launchpad.net/~jelk
# Fume https://launchpad.net/~fume
# KaZeR https://launchpad.net/~kazer
-# Kamikaaze https://launchpad.net/~kamikaazewiesel
# Keruskerfuerst https://launchpad.net/~arminmohring
# Konsti K. https://launchpad.net/~konstantin-koehring
# Lars Hennig https://launchpad.net/~elhennig
@@ -35,13 +32,13 @@
# metehyi https://launchpad.net/~metehyi
# singesang https://launchpad.net/~singesang
# spaetz https://launchpad.net/~spaetz
-# vsandre https://launchpad.net/~riedel-andre
+# vsandre https://launchpad.net/~vsandre
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2017-01-12 18:37+0000\n"
+"PO-Revision-Date: 2018-05-01 17:39+0000\n"
"Last-Translator: Steffen <zintor@lycos.com>\n"
"Language-Team: Martin Schaller <martin-s@sourceforge.net>\n"
"MIME-Version: 1.0\n"
@@ -385,7 +382,7 @@ msgstr "Wenden Sie %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "folgen"
@@ -414,9 +411,15 @@ msgstr "Anweisung"
msgid "Length"
msgstr "Länge"
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr "Fuß"
+
msgid "m"
msgstr "m"
@@ -1484,26 +1487,24 @@ msgstr ""
"\t-v: zeige die Version und beende.\n"
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
-msgstr "Keine Konfigurations-Datei navit.xml oder navit.xml.local gefunden\n"
+msgid "No config file navit.xml, navit.xml.local found"
+msgstr ""
#, c-format
-msgid "Error parsing config file '%s': %s\n"
-msgstr "Fehler beim Parsen der Konfigurations-Datei '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
+msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
-msgstr "Benutze Konfigurations-Datei '%s'\n"
+msgid "Using config file '%s'"
+msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
-msgstr "Fehler: Keine Konfiguration in der Datei '%s' gefunden\n"
+msgid "Error: No configuration found in config file '%s'"
+msgstr ""
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
-"Interne Initialisierung fehlgeschlagen, Programm wird beendet. Frühere "
-"Fehler beachten.\n"
msgid "unknown street"
msgstr "unbekannte Straße"
@@ -1644,6 +1645,9 @@ msgstr "Positions_marke zeigen"
msgid "_Lock on Road"
msgstr "Auf Straße _zeigen"
+msgid "_Follow Vehicle"
+msgstr "_Folge Fahrzeug"
+
msgid "_Keep orientation to the North"
msgstr "_Nordorientierung"
@@ -1714,24 +1718,24 @@ msgstr "Taxi"
msgid "Shopping"
msgstr "Einkaufen"
-msgid "Distance from screen center (km)"
-msgstr "Entfernung vom Bildschirmmittelpunkt (km)"
+msgid "Select a search radius from screen center"
+msgstr "Entfernung vom Bildschirmmittelpunkt"
#, c-format
msgid "POI %s. %s"
msgstr "POI %s. %s"
#, c-format
-msgid "Set destination to %ld, %ld \n"
-msgstr "Setze Ziel auf %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
+msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
-msgstr "Setze Karte auf %ld, %ld \n"
+msgid "Set map to %ld, %ld "
+msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
-msgstr "Setze nächsten Besuch auf %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
+msgstr ""
msgid "POI search"
msgstr "POI Suche"
@@ -1801,8 +1805,8 @@ msgid "OT"
msgstr "OT"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Route %4.0fkm %02d:%02d ETA"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "Route 0000km 0+00:00 ETA"
@@ -1973,10 +1977,10 @@ msgstr "Wegpunkte"
msgid "Enter Coordinates"
msgstr "Koordinaten eingeben"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -2025,6 +2029,9 @@ msgstr "Wegbeschreibung"
msgid "Show Locale"
msgstr "Lokalisierung anzeigen"
+msgid "Network info"
+msgstr "Netzwerkinfo"
+
msgid "Former Destinations"
msgstr "Vorherige Ziele"
@@ -2063,451 +2070,9 @@ msgstr "Achtung Blitzer!"
msgid "Please decrease your speed"
msgstr "Bitte Geschwindigkeit verringern"
-msgid "partial match"
-msgstr "ungefähr"
-
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr "Suche"
-
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
-msgstr "Städte"
-
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr "Kartendaten (c) von OpenStreetMap unter ODbL"
-
-msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
-msgstr ""
-"Der Speicherpfad für die Karte ist nicht verfügbar.\n"
-"Setzen Sie eine SD Karte ein und starten Sie Navit erneut\n"
-"oder wählen Sie einen anderen Pfad aus."
-
-msgid "Downloaded maps"
-msgstr "Heruntergeladene Karten"
-
-msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
-msgstr ""
-"Entschuldigung. Derzeit untestützen wir auf Android keine Karten die größer "
-"als 3,8Gigabyte sind. Bitte wählen Sie eine kleinere Karte aus."
-
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr "Ziel setzen"
-
-msgid "Cancel"
-msgstr "Abbrechen"
-
msgid "filenamePath"
msgstr "Dateipfad"
-msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
-msgstr ""
-"Karten-Speicherort ist %s\n"
-"Starten Sie Navit erneut."
-
-msgid "Whole Planet"
-msgstr "Ganze Welt"
-
-msgid "Africa"
-msgstr "Afrika"
-
-msgid "Canary Islands"
-msgstr "Kanarische Inseln"
-
-msgid "Asia"
-msgstr "Asien"
-
-msgid "Korea"
-msgstr "Korea"
-
-msgid "Taiwan"
-msgstr "Taiwan"
-
-msgid "UAE+Other"
-msgstr "Vereinigte Arabische Emirate+weitere"
-
-msgid "Oceania"
-msgstr "Ozeanien"
-
-msgid "Tasmania"
-msgstr "Tasmanien"
-
-msgid "Victoria"
-msgstr "Victoria"
-
-msgid "New South Wales"
-msgstr "New South Wales"
-
-msgid "Europe"
-msgstr "Europa"
-
-msgid "Western Europe"
-msgstr "West-Europa"
-
-msgid "Azores"
-msgstr "Azoren"
-
-msgid "BeNeLux"
-msgstr "Beneluxländer"
-
-msgid "Alsace"
-msgstr "Elsass"
-
-msgid "Aquitaine"
-msgstr "Aquitanien"
-
-msgid "Auvergne"
-msgstr "Auvergne"
-
-msgid "Basse-Normandie"
-msgstr "Basse-Normandie"
-
-msgid "Bourgogne"
-msgstr "Burgund"
-
-msgid "Bretagne"
-msgstr "Bretagne"
-
-msgid "Centre"
-msgstr "Centre"
-
-msgid "Champagne-Ardenne"
-msgstr "Champagne-Ardenne"
-
-msgid "Corse"
-msgstr "Korsika"
-
-msgid "Franche-Comte"
-msgstr "Freie Grafschaft"
-
-msgid "Haute-Normandie"
-msgstr "Haute Normandie"
-
-msgid "Ile-de-France"
-msgstr "Ile-de-France"
-
-msgid "Languedoc-Roussillon"
-msgstr "Languedoc-Roussillon"
-
-msgid "Limousin"
-msgstr "Limousin"
-
-msgid "Lorraine"
-msgstr "Lothringen"
-
-msgid "Midi-Pyrenees"
-msgstr "Midi-Pyrenäen"
-
-msgid "Nord-pas-de-Calais"
-msgstr "Nord-pas-de-Calais"
-
-msgid "Pays-de-la-Loire"
-msgstr "Pays-de-la-Loire"
-
-msgid "Picardie"
-msgstr "Picardie"
-
-msgid "Poitou-Charentes"
-msgstr "Poitou-Charentes"
-
-msgid "Provence-Alpes-Cote-d-Azur"
-msgstr "Provence-Alpes-Cote-d-Azur"
-
-msgid "Rhone-Alpes"
-msgstr "Rhone-Alpen"
-
-msgid "Baden-Wuerttemberg"
-msgstr "Baden-Württemberg"
-
-msgid "Bayern"
-msgstr "Bayern"
-
-msgid "Mittelfranken"
-msgstr "Mittelfranken"
-
-msgid "Niederbayern"
-msgstr "Niederbayern"
-
-msgid "Oberbayern"
-msgstr "Oberbayern"
-
-msgid "Oberfranken"
-msgstr "Oberfranken"
-
-msgid "Oberpfalz"
-msgstr "Oberpfalz"
-
-msgid "Schwaben"
-msgstr "Schwaben"
-
-msgid "Unterfranken"
-msgstr "Unterfranken"
-
-msgid "Berlin"
-msgstr "Berlin"
-
-msgid "Brandenburg"
-msgstr "Brandenburg"
-
-msgid "Bremen"
-msgstr "Bremen"
-
-msgid "Hamburg"
-msgstr "Hamburg"
-
-msgid "Hessen"
-msgstr "Hessen"
-
-msgid "Mecklenburg-Vorpommern"
-msgstr "Mecklenburg-Vorpommern"
-
-msgid "Niedersachsen"
-msgstr "Niedersachsen"
-
-msgid "Nordrhein-westfalen"
-msgstr "Nordrhein-Westfalen"
-
-msgid "Rheinland-Pfalz"
-msgstr "Rheinland-Pfalz"
-
-msgid "Saarland"
-msgstr "Saarland"
-
-msgid "Sachsen-Anhalt"
-msgstr "Sachsen-Anhalt"
-
-msgid "Sachsen"
-msgstr "Sachsen"
-
-msgid "Schleswig-Holstein"
-msgstr "Schleswig-Holstein"
-
-msgid "Thueringen"
-msgstr "Thüringen"
-
-msgid "Mallorca"
-msgstr "Mallorca"
-
-msgid "Galicia"
-msgstr "Galicien"
-
-msgid "Scandinavia"
-msgstr "Skandinavien"
-
-msgid "England"
-msgstr "England"
-
-msgid "Buckinghamshire"
-msgstr "Buckinghamshire"
-
-msgid "Cambridgeshire"
-msgstr "Cambridgeshire"
-
-msgid "Cumbria"
-msgstr "Cumbria"
-
-msgid "East yorkshire with hull"
-msgstr "East Yorkshire und Hull"
-
-msgid "Essex"
-msgstr "Essex"
-
-msgid "Herefordshire"
-msgstr "Herefordshire"
-
-msgid "Kent"
-msgstr "Kent"
-
-msgid "Lancashire"
-msgstr "Lancashire"
-
-msgid "Leicestershire"
-msgstr "Leicestershire"
-
-msgid "Norfolk"
-msgstr "Norfolk"
-
-msgid "Nottinghamshire"
-msgstr "Nottinghamshire"
-
-msgid "Oxfordshire"
-msgstr "Oxfordshire"
-
-msgid "Shropshire"
-msgstr "Shropshire"
-
-msgid "Somerset"
-msgstr "Somerset"
-
-msgid "South yorkshire"
-msgstr "South yorkshire"
-
-msgid "Suffolk"
-msgstr "Suffolk"
-
-msgid "Surrey"
-msgstr "Surrey"
-
-msgid "Wiltshire"
-msgstr "Wiltshire"
-
-msgid "Scotland"
-msgstr "Schottland"
-
-msgid "Wales"
-msgstr "Wales"
-
-msgid "Crete"
-msgstr "Kreta"
-
-msgid "North America"
-msgstr "Nordamerika"
-
-msgid "Alaska"
-msgstr "Alaska"
-
-msgid "Hawaii"
-msgstr "Hawaii"
-
-msgid "USA"
-msgstr "USA"
-
-msgid " (except Alaska and Hawaii)"
-msgstr " (außer Alaska und Hawaii)"
-
-msgid "Midwest"
-msgstr "Mittlerer Westen"
-
-msgid "Michigan"
-msgstr "Michigan"
-
-msgid "Ohio"
-msgstr "Ohio"
-
-msgid "Northeast"
-msgstr "Nordosten"
-
-msgid "Massachusetts"
-msgstr "Massachusetts"
-
-msgid "Vermont"
-msgstr "Vermont"
-
-msgid "Pacific"
-msgstr "Pazifik"
-
-msgid "South"
-msgstr "Süd"
-
-msgid "Arkansas"
-msgstr "Arkansas"
-
-msgid "District of Columbia"
-msgstr "District of Columbia"
-
-msgid "Florida"
-msgstr "Florida"
-
-msgid "Louisiana"
-msgstr "Louisiana"
-
-msgid "Maryland"
-msgstr "Maryland"
-
-msgid "Mississippi"
-msgstr "Mississippi"
-
-msgid "Oklahoma"
-msgstr "Oklahoma"
-
-msgid "Texas"
-msgstr "Texas"
-
-msgid "Virginia"
-msgstr "Virginia"
-
-msgid "West Virginia"
-msgstr "West Virginia"
-
-msgid "West"
-msgstr "West"
-
-msgid "Arizona"
-msgstr "Arizona"
-
-msgid "California"
-msgstr "Kalifornien"
-
-msgid "Colorado"
-msgstr "Colorado"
-
-msgid "Idaho"
-msgstr "Idaho"
-
-msgid "Montana"
-msgstr "Montana"
-
-msgid "New Mexico"
-msgstr "New Mexico"
-
-msgid "Nevada"
-msgstr "Nevada"
-
-msgid "Oregon"
-msgstr "Oregon"
-
-msgid "Utah"
-msgstr "Utah"
-
-msgid "Washington State"
-msgstr "Washington State"
-
-msgid "South+Middle America"
-msgstr "Süd+Mittel-Amerika"
-
-msgid "Guyane Francaise"
-msgstr "Französisch-Guayana"
-
-msgid "downloading"
-msgstr "wird heruntergeladen"
-
-#. Android resource: @strings/map_download_ready
-msgid "ready"
-msgstr "Fertig in"
-
-msgid "Media selected for map storage is not available"
-msgstr ""
-"Der eingestellte Speicherort für das Kartenmaterial ist nicht verfügbar."
-
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
-msgstr "Nicht genug freier Speicher"
-
-msgid "Error downloading map!"
-msgstr "Fehler beim Kartendownload"
-
-msgid "Error writing map!"
-msgstr "Fehler beim speichern der Karte!"
-
-msgid "Map download aborted!"
-msgstr "Kartendownload abgebrochen!"
-
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
-msgstr "Fertig in"
-
-#. Android resource: @strings/map_download_title
-msgid "Map download"
-msgstr "Kartendownload"
-
msgid "Vehicle Position"
msgstr "Fahrzeugposition"
@@ -2565,9 +2130,18 @@ msgstr "Vollbildmodus"
msgid "Window Mode"
msgstr "Fenstermodus"
+msgid "Auto zoom"
+msgstr "Automatischer Zoom"
+
+msgid "Manual zoom"
+msgstr "Manuelle Vergrößerung"
+
msgid "Layers"
msgstr "Ebenen"
+msgid "Zoom to route"
+msgstr ""
+
msgid "Description"
msgstr "Beschreibung"
@@ -2680,14 +2254,30 @@ msgstr "Sichern / Wiederherstellen"
msgid "Set map location"
msgstr "Kartenort festlegen"
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
+msgstr "Ziel setzen"
+
#. Android resource: @strings/map_delete
msgid "Delete this map?"
msgstr "Diese Karte löschen?"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
+msgstr "Kartendownload"
+
#. Android resource: @strings/map_download_downloading
msgid "Downloading:"
msgstr "Laden:"
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
+msgstr "Fertig in"
+
+#. Android resource: @strings/map_download_ready
+msgid "ready"
+msgstr "Fertig in"
+
#. Android resource: @strings/map_download_download_error
msgid "Error downloading map."
msgstr "Fehler beim Kartendownload"
@@ -2696,6 +2286,10 @@ msgstr "Fehler beim Kartendownload"
msgid "Map download aborted"
msgstr "Download der Karte abgebrochen"
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
+msgstr "Nicht genug freier Speicher"
+
#. Android resource: @strings/map_no_fix
msgid "No location. Reopen after location fix."
msgstr "Position noch nicht bekannt."
@@ -2716,6 +2310,10 @@ msgstr "Ziel eingeben"
msgid "Match partial address"
msgstr "Ungefähr"
+#. Android resource: @strings/address_search_button
+msgid "Search"
+msgstr "Suche"
+
#. Android resource: @strings/address_search_searching
msgid "Searching..."
msgstr "Suche läuft..."
@@ -2744,6 +2342,10 @@ msgstr "Keine Eingabe"
msgid "Setting destination to:"
msgstr "Neues Fahrziel:"
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
+msgstr "Städte"
+
#. Android resource: @strings/choose_an_action
msgid "Choose an action"
msgstr "Bitte auswählen"
@@ -2827,15 +2429,468 @@ msgid ""
"Navit needs permission to access GPS and read the map.\n"
"If you change your mind please restart Navit and grant the permissions"
msgstr ""
+"Navit benötigt die Berechtigung, um GPS zu nutzen und die Karte zu zeigen.\n"
+"Wenn Du dies erlauben möchtest, starte Navit bitte neu und erlaube die "
+"Berechtigung"
#. Android resource: @strings/permissions_info_box_title
msgid "One or more ungranted permissions"
-msgstr ""
+msgstr "Eine oder mehrere nicht gewährte Berechtigungen"
+
+#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Route %4.0fkm %02d:%02d ETA"
+
+#~ msgid "No config file navit.xml, navit.xml.local found\n"
+#~ msgstr "Keine Konfigurations-Datei navit.xml oder navit.xml.local gefunden\n"
+
+#, c-format
+#~ msgid "Error parsing config file '%s': %s\n"
+#~ msgstr "Fehler beim Parsen der Konfigurations-Datei '%s': %s\n"
+
+#, c-format
+#~ msgid "Using config file '%s'\n"
+#~ msgstr "Benutze Konfigurations-Datei '%s'\n"
+
+#~ msgid ""
+#~ "Internal initialization failed, exiting. Check previous error messages.\n"
+#~ msgstr ""
+#~ "Interne Initialisierung fehlgeschlagen, Programm wird beendet. Frühere "
+#~ "Fehler beachten.\n"
+
+#~ msgid "partial match"
+#~ msgstr "ungefähr"
+
+#~ msgid "Downloaded maps"
+#~ msgstr "Heruntergeladene Karten"
+
+#~ msgid "Error downloading map!"
+#~ msgstr "Fehler beim Kartendownload"
+
+#~ msgid "Taiwan"
+#~ msgstr "Taiwan"
+
+#~ msgid "Asia"
+#~ msgstr "Asien"
+
+#~ msgid "Canary Islands"
+#~ msgstr "Kanarische Inseln"
+
+#~ msgid "Whole Planet"
+#~ msgstr "Ganze Welt"
+
+#~ msgid "Map data (c) OpenStreetMap contributors, ODBL"
+#~ msgstr "Kartendaten (c) von OpenStreetMap unter ODbL"
+
+#~ msgid "Korea"
+#~ msgstr "Korea"
+
+#~ msgid "Tasmania"
+#~ msgstr "Tasmanien"
+
+#~ msgid "Oceania"
+#~ msgstr "Ozeanien"
+
+#~ msgid "Alsace"
+#~ msgstr "Elsass"
+
+#~ msgid "BeNeLux"
+#~ msgstr "Beneluxländer"
+
+#~ msgid "Victoria"
+#~ msgstr "Victoria"
+
+#~ msgid "Western Europe"
+#~ msgstr "West-Europa"
+
+#~ msgid "New South Wales"
+#~ msgstr "New South Wales"
+
+#~ msgid "Europe"
+#~ msgstr "Europa"
+
+#~ msgid "Aquitaine"
+#~ msgstr "Aquitanien"
+
+#~ msgid "Auvergne"
+#~ msgstr "Auvergne"
+
+#~ msgid "Basse-Normandie"
+#~ msgstr "Basse-Normandie"
+
+#~ msgid "Languedoc-Roussillon"
+#~ msgstr "Languedoc-Roussillon"
+
+#~ msgid "Limousin"
+#~ msgstr "Limousin"
+
+#~ msgid "Haute-Normandie"
+#~ msgstr "Haute Normandie"
+
+#~ msgid "Bretagne"
+#~ msgstr "Bretagne"
+
+#~ msgid "Corse"
+#~ msgstr "Korsika"
+
+#~ msgid "Champagne-Ardenne"
+#~ msgstr "Champagne-Ardenne"
+
+#~ msgid "Baden-Wuerttemberg"
+#~ msgstr "Baden-Württemberg"
+
+#~ msgid "Bayern"
+#~ msgstr "Bayern"
+
+#~ msgid "Lorraine"
+#~ msgstr "Lothringen"
+
+#~ msgid "Poitou-Charentes"
+#~ msgstr "Poitou-Charentes"
+
+#~ msgid "Picardie"
+#~ msgstr "Picardie"
+
+#~ msgid "Mittelfranken"
+#~ msgstr "Mittelfranken"
+
+#~ msgid "Oberpfalz"
+#~ msgstr "Oberpfalz"
+
+#~ msgid "Oberfranken"
+#~ msgstr "Oberfranken"
+
+#~ msgid "Oberbayern"
+#~ msgstr "Oberbayern"
+
+#~ msgid "Unterfranken"
+#~ msgstr "Unterfranken"
+
+#~ msgid "Schwaben"
+#~ msgstr "Schwaben"
+
+#~ msgid "Niederbayern"
+#~ msgstr "Niederbayern"
+
+#~ msgid "Bremen"
+#~ msgstr "Bremen"
+
+#~ msgid "Berlin"
+#~ msgstr "Berlin"
+
+#~ msgid "Brandenburg"
+#~ msgstr "Brandenburg"
+
+#~ msgid "Rheinland-Pfalz"
+#~ msgstr "Rheinland-Pfalz"
+
+#~ msgid "Saarland"
+#~ msgstr "Saarland"
+
+#~ msgid "Niedersachsen"
+#~ msgstr "Niedersachsen"
+
+#~ msgid "Hessen"
+#~ msgstr "Hessen"
+
+#~ msgid "Mecklenburg-Vorpommern"
+#~ msgstr "Mecklenburg-Vorpommern"
+
+#~ msgid "Hamburg"
+#~ msgstr "Hamburg"
+
+#~ msgid "Sachsen"
+#~ msgstr "Sachsen"
+
+#~ msgid "Sachsen-Anhalt"
+#~ msgstr "Sachsen-Anhalt"
+
+#~ msgid "Schleswig-Holstein"
+#~ msgstr "Schleswig-Holstein"
+
+#~ msgid "Galicia"
+#~ msgstr "Galicien"
+
+#~ msgid "Essex"
+#~ msgstr "Essex"
+
+#~ msgid "Cumbria"
+#~ msgstr "Cumbria"
+
+#~ msgid "Thueringen"
+#~ msgstr "Thüringen"
+
+#~ msgid "Mallorca"
+#~ msgstr "Mallorca"
+
+#~ msgid "England"
+#~ msgstr "England"
+
+#~ msgid "Scandinavia"
+#~ msgstr "Skandinavien"
+
+#~ msgid "Cambridgeshire"
+#~ msgstr "Cambridgeshire"
+
+#~ msgid "Buckinghamshire"
+#~ msgstr "Buckinghamshire"
+
+#~ msgid "Oxfordshire"
+#~ msgstr "Oxfordshire"
+
+#~ msgid "Nottinghamshire"
+#~ msgstr "Nottinghamshire"
+
+#~ msgid "Lancashire"
+#~ msgstr "Lancashire"
+
+#~ msgid "Kent"
+#~ msgstr "Kent"
+
+#~ msgid "Norfolk"
+#~ msgstr "Norfolk"
+
+#~ msgid "Leicestershire"
+#~ msgstr "Leicestershire"
+
+#~ msgid "Herefordshire"
+#~ msgstr "Herefordshire"
+
+#~ msgid "South yorkshire"
+#~ msgstr "South yorkshire"
+
+#~ msgid "Shropshire"
+#~ msgstr "Shropshire"
+
+#~ msgid "Somerset"
+#~ msgstr "Somerset"
+
+#~ msgid "Alaska"
+#~ msgstr "Alaska"
+
+#~ msgid "North America"
+#~ msgstr "Nordamerika"
+
+#~ msgid "USA"
+#~ msgstr "USA"
+
+#~ msgid "Hawaii"
+#~ msgstr "Hawaii"
+
+#~ msgid "Crete"
+#~ msgstr "Kreta"
+
+#~ msgid "Suffolk"
+#~ msgstr "Suffolk"
+
+#~ msgid "Scotland"
+#~ msgstr "Schottland"
+
+#~ msgid "Wales"
+#~ msgstr "Wales"
+
+#~ msgid "Surrey"
+#~ msgstr "Surrey"
+
+#~ msgid "Wiltshire"
+#~ msgstr "Wiltshire"
+
+#~ msgid "Pacific"
+#~ msgstr "Pazifik"
+
+#~ msgid "South"
+#~ msgstr "Süd"
+
+#~ msgid "Arkansas"
+#~ msgstr "Arkansas"
+
+#~ msgid " (except Alaska and Hawaii)"
+#~ msgstr " (außer Alaska und Hawaii)"
+
+#~ msgid "Northeast"
+#~ msgstr "Nordosten"
+
+#~ msgid "Ohio"
+#~ msgstr "Ohio"
+
+#~ msgid "Michigan"
+#~ msgstr "Michigan"
+
+#~ msgid "Midwest"
+#~ msgstr "Mittlerer Westen"
+
+#~ msgid "Vermont"
+#~ msgstr "Vermont"
+
+#~ msgid "Massachusetts"
+#~ msgstr "Massachusetts"
+
+#~ msgid "District of Columbia"
+#~ msgstr "District of Columbia"
+
+#~ msgid "Florida"
+#~ msgstr "Florida"
+
+#~ msgid "Louisiana"
+#~ msgstr "Louisiana"
+
+#~ msgid "Maryland"
+#~ msgstr "Maryland"
+
+#~ msgid "Oklahoma"
+#~ msgstr "Oklahoma"
+
+#~ msgid "Texas"
+#~ msgstr "Texas"
+
+#~ msgid "Mississippi"
+#~ msgstr "Mississippi"
+
+#~ msgid "West Virginia"
+#~ msgstr "West Virginia"
+
+#~ msgid "Virginia"
+#~ msgstr "Virginia"
+
+#~ msgid "West"
+#~ msgstr "West"
+
+#~ msgid "Washington State"
+#~ msgstr "Washington State"
+
+#~ msgid "Oregon"
+#~ msgstr "Oregon"
+
+#~ msgid "New Mexico"
+#~ msgstr "New Mexico"
+
+#~ msgid "Nevada"
+#~ msgstr "Nevada"
+
+#~ msgid "Arizona"
+#~ msgstr "Arizona"
+
+#~ msgid "Colorado"
+#~ msgstr "Colorado"
+
+#~ msgid "California"
+#~ msgstr "Kalifornien"
+
+#~ msgid "Montana"
+#~ msgstr "Montana"
+
+#~ msgid "Idaho"
+#~ msgstr "Idaho"
+
+#~ msgid "Utah"
+#~ msgstr "Utah"
+
+#~ msgid "Africa"
+#~ msgstr "Afrika"
+
+#~ msgid "UAE+Other"
+#~ msgstr "Vereinigte Arabische Emirate+weitere"
+
+#~ msgid "Azores"
+#~ msgstr "Azoren"
+
+#~ msgid "Bourgogne"
+#~ msgstr "Burgund"
+
+#~ msgid "South+Middle America"
+#~ msgstr "Süd+Mittel-Amerika"
+
+#~ msgid "Error writing map!"
+#~ msgstr "Fehler beim speichern der Karte!"
+
+#~ msgid "downloading"
+#~ msgstr "wird heruntergeladen"
+
+#~ msgid "Nordrhein-westfalen"
+#~ msgstr "Nordrhein-Westfalen"
+
+#~ msgid "Map download aborted!"
+#~ msgstr "Kartendownload abgebrochen!"
+
+#~ msgid "Centre"
+#~ msgstr "Centre"
+
+#~ msgid "Ile-de-France"
+#~ msgstr "Ile-de-France"
+
+#~ msgid "Nord-pas-de-Calais"
+#~ msgstr "Nord-pas-de-Calais"
+
+#~ msgid "Pays-de-la-Loire"
+#~ msgstr "Pays-de-la-Loire"
+
+#~ msgid "Midi-Pyrenees"
+#~ msgstr "Midi-Pyrenäen"
+
+#~ msgid "Guyane Francaise"
+#~ msgstr "Französisch-Guayana"
+
+#~ msgid "Franche-Comte"
+#~ msgstr "Freie Grafschaft"
+
+#~ msgid "Cancel"
+#~ msgstr "Abbrechen"
+
+#~ msgid "Rhone-Alpes"
+#~ msgstr "Rhone-Alpen"
+
+#, c-format
+#~ msgid "Error: No configuration found in config file '%s'\n"
+#~ msgstr "Fehler: Keine Konfiguration in der Datei '%s' gefunden\n"
+
+#~ msgid "Provence-Alpes-Cote-d-Azur"
+#~ msgstr "Provence-Alpes-Cote-d-Azur"
+
+#~ msgid "Media selected for map storage is not available"
+#~ msgstr ""
+#~ "Der eingestellte Speicherort für das Kartenmaterial ist nicht verfügbar."
+
+#~ msgid ""
+#~ "Sorry, we currently do not support maps above 3.8G on Android, please select "
+#~ "a smaller one."
+#~ msgstr ""
+#~ "Entschuldigung. Derzeit untestützen wir auf Android keine Karten die größer "
+#~ "als 3,8Gigabyte sind. Bitte wählen Sie eine kleinere Karte aus."
+
+#, c-format
+#~ msgid "Set destination to %ld, %ld \n"
+#~ msgstr "Setze Ziel auf %ld, %ld \n"
+
+#~ msgid "Distance from screen center (km)"
+#~ msgstr "Entfernung vom Bildschirmmittelpunkt (km)"
+
+#, c-format
+#~ msgid "Set map to %ld, %ld \n"
+#~ msgstr "Setze Karte auf %ld, %ld \n"
+
+#~ msgid ""
+#~ "New location set to %s\n"
+#~ "Restart Navit to apply the changes."
+#~ msgstr ""
+#~ "Karten-Speicherort ist %s\n"
+#~ "Starten Sie Navit erneut."
+
+#~ msgid ""
+#~ "Current map location %s is not available\n"
+#~ "Please restart Navit after you attach an SD card or select a different map "
+#~ "location."
+#~ msgstr ""
+#~ "Der Speicherpfad für die Karte ist nicht verfügbar.\n"
+#~ "Setzen Sie eine SD Karte ein und starten Sie Navit erneut\n"
+#~ "oder wählen Sie einen anderen Pfad aus."
#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
#~ msgstr "anschließend verlassen Sie den Kreisverkehr an der %1$s %2$s"
+#~ msgid "East yorkshire with hull"
+#~ msgstr "East Yorkshire und Hull"
+
#, c-format
#~ msgid "in %d m"
#~ msgstr "in %d m"
@@ -2843,3 +2898,7 @@ msgstr ""
#, c-format
#~ msgid "%d m"
#~ msgstr "%d m"
+
+#, c-format
+#~ msgid "Set next visit to %ld, %ld \n"
+#~ msgstr "Setze nächsten Besuch auf %ld, %ld \n"
diff --git a/po/de_CH.po.in b/po/de_CH.po.in
index d30c18584..a31b5840b 100644
--- a/po/de_CH.po.in
+++ b/po/de_CH.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/el.po.in b/po/el.po.in
index 9da1b8087..41b5e38f8 100644
--- a/po/el.po.in
+++ b/po/el.po.in
@@ -357,7 +357,7 @@ msgstr "Κάνε αναστροφή %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1670,7 +1670,7 @@ msgstr "Ταξί"
msgid "Shopping"
msgstr "Αγορές"
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1929,10 +1929,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/en.po.in b/po/en.po.in
index ca337896c..a3937cb80 100644
--- a/po/en.po.in
+++ b/po/en.po.in
@@ -1669,7 +1669,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1695,7 +1695,7 @@ msgid "Select a category"
msgstr ""
msgid "Select a distance to look for (km)"
-msgstr ""
+msgstr "Select a search radius from screen center"
msgid "Select a POI"
msgstr ""
@@ -1709,8 +1709,9 @@ msgstr ""
msgid "Direction"
msgstr ""
+# TRANSLATORS: This is the distance to a Point of Interest (POI) in the POI window. It will be feet (imperial) or, meters (metric), depending on the user's preference.
msgid "Distance(m)"
-msgstr ""
+msgstr "Distance"
msgid "Name"
msgstr ""
diff --git a/po/en_AU.po.in b/po/en_AU.po.in
index 50842f620..b65529d3a 100644
--- a/po/en_AU.po.in
+++ b/po/en_AU.po.in
@@ -353,7 +353,7 @@ msgstr "Make a U-turn %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1666,7 +1666,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1692,7 +1692,7 @@ msgid "Select a category"
msgstr ""
msgid "Select a distance to look for (km)"
-msgstr ""
+msgstr "Select a search radius from screen center"
msgid "Select a POI"
msgstr ""
@@ -1706,8 +1706,9 @@ msgstr ""
msgid "Direction"
msgstr ""
+# TRANSLATORS: This is the distance to a Point of Interest (POI) in the POI window. It will be feet (imperial) or, meters (metric), depending on the user's preference.
msgid "Distance(m)"
-msgstr ""
+msgstr "Distance"
msgid "Name"
msgstr ""
@@ -1925,10 +1926,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/en_CA.po.in b/po/en_CA.po.in
index fa624bc71..93672159c 100644
--- a/po/en_CA.po.in
+++ b/po/en_CA.po.in
@@ -350,7 +350,7 @@ msgstr "Make a U-turn %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1689,7 +1689,7 @@ msgid "Select a category"
msgstr ""
msgid "Select a distance to look for (km)"
-msgstr ""
+msgstr "Select a search radius from screen center"
msgid "Select a POI"
msgstr ""
@@ -1703,8 +1703,9 @@ msgstr ""
msgid "Direction"
msgstr ""
+# TRANSLATORS: This is the distance to a Point of Interest (POI) in the POI window. It will be feet (imperial) or, meters (metric), depending on the user's preference.
msgid "Distance(m)"
-msgstr ""
+msgstr "Distance"
msgid "Name"
msgstr ""
@@ -1922,10 +1923,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/en_GB.po.in b/po/en_GB.po.in
index fec19d509..e8cc6e9bf 100644
--- a/po/en_GB.po.in
+++ b/po/en_GB.po.in
@@ -1,5 +1,5 @@
# English (United Kingdom) translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Andi Chandler https://launchpad.net/~bing
@@ -14,9 +14,9 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2016-02-17 14:43+0000\n"
+"PO-Revision-Date: 2018-06-19 22:44+0000\n"
"Last-Translator: Andi Chandler <Unknown>\n"
"Language-Team: English (United Kingdom) <en_GB@li.org>\n"
"MIME-Version: 1.0\n"
@@ -158,7 +158,6 @@ msgstr "%1$sonto %2$s"
msgid "%1$sonto %2$s|neuter form"
msgstr "%1$sonto %2$s"
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr "onto the slip road"
@@ -359,7 +358,7 @@ msgstr "Make a U-turn %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "follow"
@@ -371,7 +370,6 @@ msgstr "then you have reached your destination"
msgid "You have reached your destination %s"
msgstr "You have reached your destination %s"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr "Interchange"
@@ -388,9 +386,15 @@ msgstr "Command"
msgid "Length"
msgstr "Length"
+msgid "mi"
+msgstr "mi"
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr "feet"
+
msgid "m"
msgstr "m"
@@ -451,6 +455,7 @@ msgid "Anguilla"
msgstr "Anguilla"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Albania"
@@ -463,6 +468,7 @@ msgid "Netherlands Antilles"
msgstr "Netherlands Antilles"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Angola"
@@ -471,6 +477,7 @@ msgid "Antarctica"
msgstr "Antarctica"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Argentina"
@@ -479,10 +486,12 @@ msgid "American Samoa"
msgstr "American Samoa"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Austria"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Australia"
@@ -495,10 +504,12 @@ msgid "Aland Islands"
msgstr "Aland Islands"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Azerbaijan"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Bosnia and Herzegovina"
@@ -511,6 +522,7 @@ msgid "Bangladesh"
msgstr "Bangladesh"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "Belgium"
@@ -519,6 +531,7 @@ msgid "Burkina Faso"
msgstr "Burkina Faso"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Bulgaria"
@@ -527,6 +540,7 @@ msgid "Bahrain"
msgstr "Bahrain"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Burundi"
@@ -547,6 +561,7 @@ msgid "Brunei Darussalam"
msgstr "Brunei Darussalam"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Bolivia"
@@ -555,6 +570,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr "Bonaire, Sint Eustatius and Saba"
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Brazil"
@@ -571,10 +587,12 @@ msgid "Bouvet Island"
msgstr "Bouvet Island"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Botswana"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Belarus"
@@ -583,6 +601,7 @@ msgid "Belize"
msgstr "Belize"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Canada"
@@ -591,6 +610,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Cocos (Keeling) Islands"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Congo, Democratic Republic of the"
@@ -603,10 +623,12 @@ msgid "Congo"
msgstr "Congo"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Switzerland"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Cote d'Ivoire"
@@ -615,6 +637,7 @@ msgid "Cook Islands"
msgstr "Cook Islands"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Chile"
@@ -623,10 +646,12 @@ msgid "Cameroon"
msgstr "Cameroon"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "China"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Colombia"
@@ -635,6 +660,7 @@ msgid "Costa Rica"
msgstr "Costa Rica"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Cuba"
@@ -651,14 +677,17 @@ msgid "Christmas Island"
msgstr "Christmas Island"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Cyprus"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "Czech Republic"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Germany"
@@ -667,6 +696,7 @@ msgid "Djibouti"
msgstr "Djibouti"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Denmark"
@@ -675,6 +705,7 @@ msgid "Dominica"
msgstr "Dominica"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "Dominican Republic"
@@ -683,10 +714,12 @@ msgid "Algeria"
msgstr "Algeria"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Ecuador"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Estonia"
@@ -703,14 +736,17 @@ msgid "Eritrea"
msgstr "Eritrea"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Spain"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Ethiopia"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Finland"
@@ -727,10 +763,12 @@ msgid "Micronesia, Federated States of"
msgstr "Micronesia, Federated States of"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Faroe Islands"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "France"
@@ -739,6 +777,7 @@ msgid "Gabon"
msgstr "Gabon"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "United Kingdom"
@@ -775,6 +814,7 @@ msgid "Gambia"
msgstr "Gambia"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Guinea"
@@ -787,6 +827,7 @@ msgid "Equatorial Guinea"
msgstr "Equatorial Guinea"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Greece"
@@ -807,6 +848,7 @@ msgid "Guinea-Bissau"
msgstr "Guinea-Bissau"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Guyana"
@@ -823,26 +865,32 @@ msgid "Honduras"
msgstr "Honduras"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Croatia"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Haiti"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Hungary"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Indonesia"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Ireland"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Israel"
@@ -851,6 +899,7 @@ msgid "Isle of Man"
msgstr "Isle of Man"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "India"
@@ -859,18 +908,22 @@ msgid "British Indian Ocean Territory"
msgstr "British Indian Ocean Territory"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Iraq"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Iran, Islamic Republic of"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Iceland"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Italy"
@@ -879,6 +932,7 @@ msgid "Jersey"
msgstr "Jersey"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Jamaica"
@@ -887,14 +941,17 @@ msgid "Jordan"
msgstr "Jordan"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Japan"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Kenya"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Kyrgyzstan"
@@ -931,6 +988,7 @@ msgid "Cayman Islands"
msgstr "Cayman Islands"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Kazakhstan"
@@ -955,26 +1013,32 @@ msgid "Sri Lanka"
msgstr "Sri Lanka"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Liberia"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Lesotho"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Lithuania"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Luxembourg"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Latvia"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr "Libya"
@@ -999,6 +1063,7 @@ msgid "Saint Martin (French part)"
msgstr "Saint Martin (French part)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Madagascar"
@@ -1019,6 +1084,7 @@ msgid "Myanmar"
msgstr "Myanmar"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Mongolia"
@@ -1059,10 +1125,12 @@ msgid "Malawi"
msgstr "Malawi"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "Mexico"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Malaysia"
@@ -1071,10 +1139,12 @@ msgid "Mozambique"
msgstr "Mozambique"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Namibia"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "New Caledonia"
@@ -1095,6 +1165,7 @@ msgid "Nicaragua"
msgstr "Nicaragua"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Netherlands"
@@ -1103,6 +1174,7 @@ msgid "Norway"
msgstr "Norway"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Nepal"
@@ -1115,6 +1187,7 @@ msgid "Niue"
msgstr "Niue"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "New Zealand"
@@ -1127,6 +1200,7 @@ msgid "Panama"
msgstr "Panama"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Peru"
@@ -1139,14 +1213,17 @@ msgid "Papua New Guinea"
msgstr "Papua New Guinea"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Philippines"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Pakistan"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Poland"
@@ -1167,6 +1244,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Palestinian Territory, Occupied"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Portugal"
@@ -1175,6 +1253,7 @@ msgid "Palau"
msgstr "Palau"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Paraguay"
@@ -1183,10 +1262,12 @@ msgid "Qatar"
msgstr "Qatar"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Reunion"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Romania"
@@ -1195,14 +1276,17 @@ msgid "Serbia"
msgstr "Serbia"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Russian Federation"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Rwanda"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Saudi Arabia"
@@ -1223,6 +1307,7 @@ msgid "Sweden"
msgstr "Sweden"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Singapore"
@@ -1239,6 +1324,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Svalbard and Jan Mayen"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Slovakia"
@@ -1259,6 +1345,7 @@ msgid "Somalia"
msgstr "Somalia"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Suriname"
@@ -1303,6 +1390,7 @@ msgid "Togo"
msgstr "Togo"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Thailand"
@@ -1319,6 +1407,7 @@ msgid "Timor-Leste"
msgstr "Timor-Leste"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Turkmenistan"
@@ -1331,6 +1420,7 @@ msgid "Tonga"
msgstr "Tonga"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Turkey"
@@ -1347,14 +1437,17 @@ msgid "Taiwan, Province of China"
msgstr "Taiwan, Province of China"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Tanzania, United Republic of"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Ukraine"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Uganda"
@@ -1367,6 +1460,7 @@ msgid "United States"
msgstr "United States"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Uruguay"
@@ -1383,6 +1477,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "Saint Vincent and the Grenadines"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Venezuela"
@@ -1419,6 +1514,7 @@ msgid "Mayotte"
msgstr "Mayotte"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "South Africa"
@@ -1455,25 +1551,25 @@ msgstr ""
"\t-v: print the version and exit.\n"
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
-msgstr "No config file navit.xml, navit.xml.local found\n"
+msgid "No config file navit.xml, navit.xml.local found"
+msgstr "No config file navit.xml, navit.xml.local found"
#, c-format
-msgid "Error parsing config file '%s': %s\n"
-msgstr "Error parsing config file '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
+msgstr "Error parsing config file '%s': %s"
#, c-format
-msgid "Using config file '%s'\n"
-msgstr "Using config file '%s'\n"
+msgid "Using config file '%s'"
+msgstr "Using config file '%s'"
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
-msgstr "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
+msgstr "Error: No configuration found in config file '%s'"
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
-"Internal initialisation failed, exiting. Check previous error messages.\n"
+"Internal initialisation failed, exiting. Check previous error messages."
msgid "unknown street"
msgstr "unknown street"
@@ -1613,6 +1709,9 @@ msgstr "Show position _cursor"
msgid "_Lock on Road"
msgstr "Lock on road"
+msgid "_Follow Vehicle"
+msgstr "_Follow Vehicle"
+
msgid "_Keep orientation to the North"
msgstr "_Keep orientation to the North"
@@ -1682,24 +1781,29 @@ msgstr "Taxi"
msgid "Shopping"
msgstr "Shopping"
-msgid "Distance from screen center (km)"
-msgstr "Distance from screen centre (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
+msgstr ""
#, c-format
msgid "POI %s. %s"
msgstr "POI %s. %s"
#, c-format
-msgid "Set destination to %ld, %ld \n"
-msgstr "Set destination to %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
+msgstr "Set destination to %ld, %ld "
#, c-format
-msgid "Set map to %ld, %ld \n"
-msgstr "Set map to %ld, %ld \n"
+msgid "Set map to %ld, %ld "
+msgstr "Set map to %ld, %ld "
#, c-format
-msgid "Set next visit to %ld, %ld \n"
-msgstr "Set next visit to %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
+msgstr "Set next visit to %ld, %ld "
msgid "POI search"
msgstr "POI search"
@@ -1707,9 +1811,6 @@ msgstr "POI search"
msgid "Select a category"
msgstr "Select a category"
-msgid "Select a distance to look for (km)"
-msgstr "Select a distance to look for (km)"
-
msgid "Select a POI"
msgstr "Select a POI"
@@ -1722,8 +1823,8 @@ msgstr "Category"
msgid "Direction"
msgstr "Direction"
-msgid "Distance(m)"
-msgstr "Distance(m)"
+msgid "Distance"
+msgstr ""
msgid "Name"
msgstr "Name"
@@ -1769,8 +1870,8 @@ msgid "OT"
msgstr "QT"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Route %4.0fkm %02d:%02d ETA"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr "Route %4.1f%s %02d:%02d ETA"
msgid "Route 0000km 0+00:00 ETA"
msgstr "Route 0000km 0+00:00 ETA"
@@ -1941,10 +2042,10 @@ msgstr "Waypoints"
msgid "Enter Coordinates"
msgstr "Enter Coordinates"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1981,10 +2082,10 @@ msgid "Height Profile"
msgstr "Height Profile"
msgid "please install a map *.heightlines.bin to provide elevationdata"
-msgstr ""
+msgstr "please install a map *.heightlines.bin to provide elevationdata"
msgid "The route must cross at least 2 heightlines"
-msgstr ""
+msgstr "The route must cross at least 2 heightlines"
msgid "Route Description"
msgstr "Route Description"
@@ -1992,6 +2093,9 @@ msgstr "Route Description"
msgid "Show Locale"
msgstr "Show Locale"
+msgid "Network info"
+msgstr "Network info"
+
msgid "Former Destinations"
msgstr "Former Destinations"
@@ -2030,759 +2134,995 @@ msgstr "Look out! Camera!"
msgid "Please decrease your speed"
msgstr "Please decrease your speed"
-msgid "partial match"
-msgstr "partial match"
+msgid "Vehicle Position"
+msgstr "Vehicle Position"
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr "Search"
+msgid "Main menu"
+msgstr "Main Menu"
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
-msgstr "Towns"
+msgid ""
+"Show\n"
+"Map"
+msgstr "Show Map"
+
+msgid "Settings"
+msgstr "Settings"
+
+msgid "Tools"
+msgstr "Tools"
+
+msgid "Route"
+msgstr "Route"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr "Map data (c) OpenStreetMap contributors, ODBL"
+msgid "About"
+msgstr "About"
+
+msgid "Quit"
+msgstr "Quit"
+
+msgid "Actions"
+msgstr "Actions"
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Former\n"
+"Destinations"
msgstr ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Former\n"
+"Destinations"
+
+msgid "Coordinates"
+msgstr "Coordinates"
+
+msgid ""
+"Stop\n"
+"Navigation"
+msgstr "Stop"
+
+msgid "Display"
+msgstr "Display"
+
+msgid "Fullscreen"
+msgstr "Fullscreen"
+
+msgid "Window Mode"
+msgstr "Window Mode"
+
+msgid "Auto zoom"
+msgstr "Auto zoom"
+
+msgid "Manual zoom"
+msgstr "Manual zoom"
+
+msgid "Layers"
+msgstr "Layers"
-msgid "Downloaded maps"
-msgstr "Downloaded maps"
+msgid "Zoom to route"
+msgstr "Zoom to route"
+
+msgid "Description"
+msgstr "Description"
msgid ""
+"Drop last\n"
+"Waypoint"
+msgstr ""
+"Drop last\n"
+"Waypoint"
+
+msgid ""
+"Drop next\n"
+"Waypoint"
+msgstr ""
+"Drop next\n"
+"Waypoint"
+
+msgid "Satellite Status"
+msgstr "Satellite Status"
+
+msgid "NMEA Data"
+msgstr "NMEA Data"
+
+msgid "car_shortest"
+msgstr "car_shortest"
+
+msgid "car_avoid_tolls"
+msgstr "car_avoid_tolls"
+
+msgid "car_pedantic"
+msgstr "car_pedantic"
+
+msgid "horse"
+msgstr "horse"
+
+msgid "Truck"
+msgstr "Truck"
+
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
+msgstr "Yes"
+
+#. Android resource: @strings/cancel
+msgid "Cancel"
+msgstr "Cancel"
+
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
+msgstr "Navit started"
+
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
+msgstr "Navit running"
+
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
+msgstr "Welcome to Navit"
+
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
+msgstr ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map file size may be large (>50MB) - a WiFi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
+
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
+msgstr "OK"
+
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
+msgstr "More info"
+
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
+msgstr "Zoom in"
+
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
+msgstr "Zoom out"
+
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
+msgstr "Download maps"
+
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
+msgstr "Toggle POIs"
+
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
+msgstr "Exit Navit"
+
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
+msgstr "Backup / Restore"
+
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
+msgstr "Set map location"
+
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
+msgstr "Route to here"
+
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
+msgstr "Delete this map?"
+
+#. Android resource: @strings/map_download_title
+msgid "Map download"
+msgstr "Map download"
+
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
+msgstr "Downloading:"
+
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
+msgstr "ETA"
+
+#. Android resource: @strings/map_download_ready
+msgid "ready"
+msgstr "ready"
+
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
+msgstr "Error downloading map."
+
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
+msgstr "Map download aborted"
+
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
+msgstr "Not enough free space"
+
+#. Android resource: @strings/map_download_oversize
+msgid ""
"Sorry, we currently do not support maps above 3.8G on Android, please select "
"a smaller one."
msgstr ""
"Sorry, we currently do not support maps above 3.8G on Android, please select "
"a smaller one."
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr "Route to here"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
+msgstr "No location. Reopen after location fix."
-msgid "Cancel"
-msgstr "Cancel"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
+msgstr "Maps containing current location"
+
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
+msgstr "Installed maps"
+
+#. Android resource: @strings/map_downloading
+msgid "downloading"
+msgstr "downloading"
+
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
+msgstr "Media selected for map storage is not available"
+
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
+msgstr "Error writing map!"
+
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
+msgstr "New location set to %s Restart Navit to apply the changes."
+
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
+msgstr ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
+
+#. Android resource: @strings/address_search_title
+msgid "Address search"
+msgstr "Address search"
+
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
+msgstr "Enter destination"
+
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
+msgstr "Match partial address"
+
+#. Android resource: @strings/address_search_button
+msgid "Search"
+msgstr "Search"
+
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
+msgstr "Searching..."
+
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
+msgstr "Address not found"
+
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
+msgstr "Getting search results"
+
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
+msgstr "Loading search results"
+
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
+msgstr "No results found"
+
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
+msgstr "No text entered"
+
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
+msgstr "Setting destination to:"
+
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
+msgstr "Towns"
+
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
+msgstr "Choose an action"
+
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
+msgstr "Please insert an SD Card"
+
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
+msgstr "Backing up..."
+
+#. Android resource: @strings/restoring
+msgid "Restoring..."
+msgstr "Restoring..."
+
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
+msgstr "Failed to create backup directory"
+
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
+msgstr "Backup failed"
+
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
+msgstr "No backup found"
+
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
+msgstr "Failed to restore"
+
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
+msgstr "Backup successful"
+
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
+msgstr ""
+"Restore Successful\n"
+"Please restart Navit"
+
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
+msgstr "Backup not found"
+
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
+msgstr "Restore failed"
+
+#. Android resource: @strings/select_backup
+msgid "Select backup"
+msgstr "Select backup"
+
+#. Android resource: @strings/backup
+msgid "Backup"
+msgstr "Backup"
+
+#. Android resource: @strings/restore
+msgid "Restore"
+msgstr "Restore"
+
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
+msgstr "System text to speech engine data is missing"
-msgid "filenamePath"
-msgstr "filenamePath"
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
+msgstr ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
+#. Android resource: @strings/permissions_not_granted
msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
+msgstr "One or more ungranted permissions"
+
+#. Android resource: @strings/whole_planet
msgid "Whole Planet"
msgstr "Whole Planet"
+#. Android resource: @strings/africa
msgid "Africa"
msgstr "Africa"
+#. Android resource: @strings/canary_islands
msgid "Canary Islands"
msgstr "Canary Islands"
+#. Android resource: @strings/asia
msgid "Asia"
msgstr "Asia"
-msgid "Korea"
-msgstr "Korea"
-
+#. Android resource: @strings/taiwan
msgid "Taiwan"
msgstr "Taiwan"
+#. Android resource: @strings/korea
+msgid "Korea"
+msgstr "Korea"
+
+#. Android resource: @strings/uae_other
msgid "UAE+Other"
msgstr "UAE+Other"
+#. Android resource: @strings/oceania
msgid "Oceania"
msgstr "Oceania"
+#. Android resource: @strings/tasmania
msgid "Tasmania"
msgstr "Tasmania"
+#. Android resource: @strings/victoria
msgid "Victoria"
msgstr "Victoria"
+#. Android resource: @strings/new_south_wales
msgid "New South Wales"
msgstr "New South Wales"
+#. Android resource: @strings/europe
msgid "Europe"
msgstr "Europe"
+#. Android resource: @strings/western_europe
msgid "Western Europe"
msgstr "Western Europe"
+#. Android resource: @strings/azores
msgid "Azores"
msgstr "Azores"
+#. Android resource: @strings/benelux
msgid "BeNeLux"
msgstr "BeNeLux"
+#. Android resource: @strings/alsace
msgid "Alsace"
msgstr "Alsace"
+#. Android resource: @strings/aquitaine
msgid "Aquitaine"
msgstr "Aquitaine"
+#. Android resource: @strings/auvergne
msgid "Auvergne"
msgstr "Auvergne"
-msgid "Basse-Normandie"
-msgstr "Basse-Normandie"
-
-msgid "Bourgogne"
-msgstr "Bourgogne"
+#. Android resource: @strings/centre
+msgid "Centre"
+msgstr "Centre"
+#. Android resource: @strings/bretagne
msgid "Bretagne"
msgstr "Bretagne"
-msgid "Centre"
-msgstr "Centre"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
+msgstr "Bourgogne"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
+msgstr "Basse-Normandie"
+
+#. Android resource: @strings/champagne_ardenne
msgid "Champagne-Ardenne"
msgstr "Champagne-Ardenne"
+#. Android resource: @strings/corse
msgid "Corse"
msgstr "Corse"
+#. Android resource: @strings/franche_comte
msgid "Franche-Comte"
msgstr "Franche-Comte"
+#. Android resource: @strings/haute_normandie
msgid "Haute-Normandie"
msgstr "Haute-Normandie"
+#. Android resource: @strings/ile_de_france
msgid "Ile-de-France"
msgstr "Ile-de-France"
+#. Android resource: @strings/languedoc_roussillon
msgid "Languedoc-Roussillon"
msgstr "Languedoc-Roussillon"
+#. Android resource: @strings/limousin
msgid "Limousin"
msgstr "Limousin"
+#. Android resource: @strings/lorraine
msgid "Lorraine"
msgstr "Lorraine"
+#. Android resource: @strings/midi_pyrenees
msgid "Midi-Pyrenees"
msgstr "Midi-Pyrenees"
+#. Android resource: @strings/nord_pas_de_calais
msgid "Nord-pas-de-Calais"
msgstr "Nord-pas-de-Calais"
+#. Android resource: @strings/pays_de_la_loire
msgid "Pays-de-la-Loire"
msgstr "Pays-de-la-Loire"
+#. Android resource: @strings/picardie
msgid "Picardie"
msgstr "Picardie"
+#. Android resource: @strings/poitou_charentes
msgid "Poitou-Charentes"
msgstr "Poitou-Charentes"
+#. Android resource: @strings/provence_alpes_cote_d_azur
msgid "Provence-Alpes-Cote-d-Azur"
msgstr "Provence-Alpes-Cote-d-Azur"
+#. Android resource: @strings/rhone_alpes
msgid "Rhone-Alpes"
msgstr "Rhone-Alpes"
+#. Android resource: @strings/baden_wuerttemberg
msgid "Baden-Wuerttemberg"
msgstr "Baden-Wuerttemberg"
+#. Android resource: @strings/bayern
msgid "Bayern"
msgstr "Bayern"
+#. Android resource: @strings/mittelfranken
msgid "Mittelfranken"
msgstr "Mittelfranken"
+#. Android resource: @strings/niederbayern
msgid "Niederbayern"
msgstr "Niederbayern"
+#. Android resource: @strings/oberbayern
msgid "Oberbayern"
msgstr "Oberbayern"
+#. Android resource: @strings/oberfranken
msgid "Oberfranken"
msgstr "Oberfranken"
+#. Android resource: @strings/oberpfalz
msgid "Oberpfalz"
msgstr "Oberpfalz"
+#. Android resource: @strings/schwaben
msgid "Schwaben"
msgstr "Schwaben"
+#. Android resource: @strings/unterfranken
msgid "Unterfranken"
msgstr "Unterfranken"
+#. Android resource: @strings/berlin
msgid "Berlin"
msgstr "Berlin"
+#. Android resource: @strings/brandenburg
msgid "Brandenburg"
msgstr "Brandenburg"
+#. Android resource: @strings/bremen
msgid "Bremen"
msgstr "Bremen"
+#. Android resource: @strings/hamburg
msgid "Hamburg"
msgstr "Hamburg"
+#. Android resource: @strings/hessen
msgid "Hessen"
msgstr "Hessen"
+#. Android resource: @strings/mecklenburg_vorpommern
msgid "Mecklenburg-Vorpommern"
msgstr "Mecklenburg-Vorpommern"
+#. Android resource: @strings/niedersachsen
msgid "Niedersachsen"
msgstr "Niedersachsen"
+#. Android resource: @strings/nordrhein_westfalen
msgid "Nordrhein-westfalen"
msgstr "Nordrhein-westfalen"
+#. Android resource: @strings/rheinland_pfalz
msgid "Rheinland-Pfalz"
msgstr "Rheinland-Pfalz"
+#. Android resource: @strings/saarland
msgid "Saarland"
msgstr "Saarland"
+#. Android resource: @strings/sachsen_anhalt
msgid "Sachsen-Anhalt"
msgstr "Sachsen-Anhalt"
+#. Android resource: @strings/sachsen
msgid "Sachsen"
msgstr "Sachsen"
+#. Android resource: @strings/schleswig_holstein
msgid "Schleswig-Holstein"
msgstr "Schleswig-Holstein"
+#. Android resource: @strings/thueringen
msgid "Thueringen"
msgstr "Thueringen"
+#. Android resource: @strings/mallorca
msgid "Mallorca"
msgstr "Mallorca"
+#. Android resource: @strings/galicia
msgid "Galicia"
msgstr "Galicia"
+#. Android resource: @strings/scandinavia
msgid "Scandinavia"
msgstr "Scandinavia"
+#. Android resource: @strings/england
msgid "England"
msgstr "England"
+#. Android resource: @strings/buckinghamshire
msgid "Buckinghamshire"
msgstr "Buckinghamshire"
+#. Android resource: @strings/cambridgeshire
msgid "Cambridgeshire"
msgstr "Cambridgeshire"
+#. Android resource: @strings/cumbria
msgid "Cumbria"
msgstr "Cumbria"
+#. Android resource: @strings/east_yorkshire_with_hull
msgid "East yorkshire with hull"
msgstr "East Yorkshire with Hull"
+#. Android resource: @strings/essex
msgid "Essex"
msgstr "Essex"
+#. Android resource: @strings/herefordshire
msgid "Herefordshire"
msgstr "Herefordshire"
+#. Android resource: @strings/kent
msgid "Kent"
msgstr "Kent"
+#. Android resource: @strings/lancashire
msgid "Lancashire"
msgstr "Lancashire"
+#. Android resource: @strings/leicestershire
msgid "Leicestershire"
msgstr "Leicestershire"
+#. Android resource: @strings/norfolk
msgid "Norfolk"
msgstr "Norfolk"
+#. Android resource: @strings/nottinghamshire
msgid "Nottinghamshire"
msgstr "Nottinghamshire"
+#. Android resource: @strings/oxfordshire
msgid "Oxfordshire"
msgstr "Oxfordshire"
+#. Android resource: @strings/shropshire
msgid "Shropshire"
msgstr "Shropshire"
+#. Android resource: @strings/somerset
msgid "Somerset"
msgstr "Somerset"
+#. Android resource: @strings/south_yorkshire
msgid "South yorkshire"
msgstr "South Yorkshire"
+#. Android resource: @strings/suffolk
msgid "Suffolk"
msgstr "Suffolk"
+#. Android resource: @strings/surrey
msgid "Surrey"
msgstr "Surrey"
+#. Android resource: @strings/wiltshire
msgid "Wiltshire"
msgstr "Wiltshire"
+#. Android resource: @strings/scotland
msgid "Scotland"
msgstr "Scotland"
+#. Android resource: @strings/wales
msgid "Wales"
msgstr "Wales"
+#. Android resource: @strings/crete
msgid "Crete"
msgstr "Crete"
+#. Android resource: @strings/north_america
msgid "North America"
msgstr "North America"
+#. Android resource: @strings/alaska
msgid "Alaska"
msgstr "Alaska"
+#. Android resource: @strings/hawaii
msgid "Hawaii"
msgstr "Hawaii"
+#. Android resource: @strings/usa
msgid "USA"
msgstr "USA"
-msgid " (except Alaska and Hawaii)"
-msgstr " (except Alaska and Hawaii)"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
+msgstr "(except Alaska and Hawaii)"
+#. Android resource: @strings/midwest
msgid "Midwest"
msgstr "Midwest"
+#. Android resource: @strings/michigan
msgid "Michigan"
msgstr "Michigan"
+#. Android resource: @strings/ohio
msgid "Ohio"
msgstr "Ohio"
+#. Android resource: @strings/northeast
msgid "Northeast"
msgstr "Northeast"
+#. Android resource: @strings/massachusetts
msgid "Massachusetts"
msgstr "Massachusetts"
+#. Android resource: @strings/vermont
msgid "Vermont"
msgstr "Vermont"
+#. Android resource: @strings/pacific
msgid "Pacific"
msgstr "Pacific"
+#. Android resource: @strings/south
msgid "South"
msgstr "South"
+#. Android resource: @strings/arkansas
msgid "Arkansas"
msgstr "Arkansas"
+#. Android resource: @strings/district_of_columbia
msgid "District of Columbia"
msgstr "District of Columbia"
+#. Android resource: @strings/florida
msgid "Florida"
msgstr "Florida"
+#. Android resource: @strings/louisiana
msgid "Louisiana"
msgstr "Louisiana"
+#. Android resource: @strings/maryland
msgid "Maryland"
msgstr "Maryland"
+#. Android resource: @strings/mississippi
msgid "Mississippi"
msgstr "Mississippi"
+#. Android resource: @strings/oklahoma
msgid "Oklahoma"
msgstr "Oklahoma"
+#. Android resource: @strings/texas
msgid "Texas"
msgstr "Texas"
+#. Android resource: @strings/virginia
msgid "Virginia"
msgstr "Virginia"
+#. Android resource: @strings/west_virginia
msgid "West Virginia"
msgstr "West Virginia"
+#. Android resource: @strings/west
msgid "West"
msgstr "West"
+#. Android resource: @strings/arizona
msgid "Arizona"
msgstr "Arizona"
+#. Android resource: @strings/california
msgid "California"
msgstr "California"
+#. Android resource: @strings/colorado
msgid "Colorado"
msgstr "Colorado"
+#. Android resource: @strings/idaho
msgid "Idaho"
msgstr "Idaho"
+#. Android resource: @strings/montana
msgid "Montana"
msgstr "Montana"
+#. Android resource: @strings/new_mexico
msgid "New Mexico"
msgstr "New Mexico"
+#. Android resource: @strings/nevada
msgid "Nevada"
msgstr "Nevada"
+#. Android resource: @strings/oregon
msgid "Oregon"
msgstr "Oregon"
+#. Android resource: @strings/utah
msgid "Utah"
msgstr "Utah"
+#. Android resource: @strings/washington_state
msgid "Washington State"
msgstr "Washington State"
+#. Android resource: @strings/south_middle_america
msgid "South+Middle America"
msgstr "South+Middle America"
+#. Android resource: @strings/guyane_francaise
msgid "Guyane Francaise"
msgstr "Guyane Francaise"
-msgid "downloading"
-msgstr "downloading"
-
-#. Android resource: @strings/map_download_ready
-msgid "ready"
-msgstr "ready"
-
-msgid "Media selected for map storage is not available"
-msgstr "Media selected for map storage is not available"
-
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
-msgstr "Not enough free space"
-
-msgid "Error downloading map!"
-msgstr "Error downloading map!"
-
-msgid "Error writing map!"
-msgstr "Error writing map!"
-
-msgid "Map download aborted!"
-msgstr "Map download aborted!"
-
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
-msgstr "ETA"
-
-#. Android resource: @strings/map_download_title
-msgid "Map download"
-msgstr "Map download"
-
-msgid "Vehicle Position"
-msgstr "Vehicle Position"
-
-msgid "Main menu"
-msgstr "Main Menu"
-
-msgid ""
-"Show\n"
-"Map"
-msgstr "Show Map"
-
-msgid "Settings"
-msgstr "Settings"
-
-msgid "Tools"
-msgstr "Tools"
-
-msgid "Route"
-msgstr "Route"
-
-msgid "About"
-msgstr "About"
-
-msgid "Quit"
-msgstr "Quit"
-
-msgid "Actions"
-msgstr "Actions"
-
-msgid ""
-"Former\n"
-"Destinations"
-msgstr ""
-"Former\n"
-"Destinations"
-
-msgid "Coordinates"
-msgstr "Coordinates"
-
-msgid ""
-"Stop\n"
-"Navigation"
-msgstr "Stop"
-
-msgid "Display"
-msgstr "Display"
-
-msgid "Fullscreen"
-msgstr "Fullscreen"
-
-msgid "Window Mode"
-msgstr "Window Mode"
-
-msgid "Layers"
-msgstr ""
-
-msgid "Description"
-msgstr "Description"
-
-msgid ""
-"Drop last \n"
-"Waypoint"
-msgstr ""
-"Drop last \n"
-"Waypoint"
-
-msgid ""
-"Drop next \n"
-"Waypoint"
-msgstr ""
-"Drop next \n"
-"Waypoint"
-
-msgid "Satellite Status"
-msgstr "Satellite Status"
-
-msgid "NMEA Data"
-msgstr "NMEA Data"
-
-msgid "car_shortest"
-msgstr "car_shortest"
-
-msgid "car_avoid_tolls"
-msgstr "car_avoid_tolls"
-
-msgid "car_pedantic"
-msgstr "car_pedantic"
-
-msgid "horse"
-msgstr "horse"
-
-msgid "Truck"
-msgstr "Truck"
-
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
-msgstr "Yes"
-
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
-msgstr "Navit started"
-
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
-msgstr "Navit running"
-
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
-msgstr "Welcome to Navit"
-
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
-msgstr ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map file size may be large (>50MB) - a WiFi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
-
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
-msgstr "OK"
-
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
-msgstr "More info"
-
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
-msgstr "Zoom in"
-
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
-msgstr "Zoom out"
-
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
-msgstr "Download maps"
-
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
-msgstr "Toggle POIs"
-
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
-msgstr "Exit Navit"
-
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
-msgstr "Backup / Restore"
-
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
-msgstr "Set map location"
-
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
-msgstr "Delete this map?"
-
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
-msgstr "Downloading:"
-
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
-msgstr "Error downloading map."
-
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
-msgstr "Map download aborted"
-
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
-msgstr "No location. Reopen after location fix."
-
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
-msgstr "Maps containing current location"
-
-#. Android resource: @strings/address_search_title
-msgid "Address search"
-msgstr "Address search"
-
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
-msgstr "Enter destination"
-
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
-msgstr "Match partial address"
+#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Route %4.0fkm %02d:%02d ETA"
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
-msgstr "Searching..."
+#, c-format
+#~ msgid "Error: No configuration found in config file '%s'\n"
+#~ msgstr "Error: No configuration found in config file '%s'\n"
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
-msgstr "Address not found"
+#, c-format
+#~ msgid "Using config file '%s'\n"
+#~ msgstr "Using config file '%s'\n"
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
-msgstr "Getting search results"
+#~ msgid ""
+#~ "Internal initialization failed, exiting. Check previous error messages.\n"
+#~ msgstr ""
+#~ "Internal initialisation failed, exiting. Check previous error messages.\n"
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
-msgstr "Loading search results"
+#~ msgid "No config file navit.xml, navit.xml.local found\n"
+#~ msgstr "No config file navit.xml, navit.xml.local found\n"
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
-msgstr "No results found"
+#, c-format
+#~ msgid "Error parsing config file '%s': %s\n"
+#~ msgstr "Error parsing config file '%s': %s\n"
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
-msgstr "No text entered"
+#~ msgid "Map data (c) OpenStreetMap contributors, ODBL"
+#~ msgstr "Map data (c) OpenStreetMap contributors, ODBL"
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
-msgstr "Setting destination to:"
+#~ msgid "partial match"
+#~ msgstr "partial match"
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
-msgstr "Choose an action"
+#~ msgid "Downloaded maps"
+#~ msgstr "Downloaded maps"
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
-msgstr "Please insert an SD Card"
+#~ msgid " (except Alaska and Hawaii)"
+#~ msgstr " (except Alaska and Hawaii)"
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
-msgstr "Backing up..."
+#~ msgid "Error downloading map!"
+#~ msgstr "Error downloading map!"
-#. Android resource: @strings/restoring
-msgid "Restoring..."
-msgstr "Restoring..."
+#~ msgid ""
+#~ "Drop last \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Drop last \n"
+#~ "Waypoint"
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
-msgstr "Failed to create backup directory"
+#~ msgid ""
+#~ "Drop next \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Drop next \n"
+#~ "Waypoint"
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
-msgstr "Backup failed"
+#~ msgid "Map download aborted!"
+#~ msgstr "Map download aborted!"
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
-msgstr "No backup found"
+#, c-format
+#~ msgid "Set destination to %ld, %ld \n"
+#~ msgstr "Set destination to %ld, %ld \n"
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
-msgstr "Failed to restore"
+#~ msgid "Distance from screen center (km)"
+#~ msgstr "Distance from screen centre (km)"
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
-msgstr "Backup successful"
+#, c-format
+#~ msgid "Set map to %ld, %ld \n"
+#~ msgstr "Set map to %ld, %ld \n"
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
-msgstr ""
-"Restore Successful\n"
-"Please restart Navit"
+#, c-format
+#~ msgid "Set next visit to %ld, %ld \n"
+#~ msgstr "Set next visit to %ld, %ld \n"
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
-msgstr "Backup not found"
+#, c-format
+#~ msgid "then leave the roundabout at the %1$s %2$s"
+#~ msgstr "then leave the roundabout at the %1$s %2$s"
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
-msgstr "Restore failed"
+#~ msgid "filenamePath"
+#~ msgstr "filenamePath"
-#. Android resource: @strings/select_backup
-msgid "Select backup"
-msgstr "Select backup"
+#~ msgid ""
+#~ "New location set to %s\n"
+#~ "Restart Navit to apply the changes."
+#~ msgstr ""
+#~ "New location set to %s\n"
+#~ "Restart Navit to apply the changes."
-#. Android resource: @strings/backup
-msgid "Backup"
-msgstr "Backup"
+#~ msgid ""
+#~ "Current map location %s is not available\n"
+#~ "Please restart Navit after you attach an SD card or select a different map "
+#~ "location."
+#~ msgstr ""
+#~ "Current map location %s is not available\n"
+#~ "Please restart Navit after you attach an SD card or select a different map "
+#~ "location."
-#. Android resource: @strings/restore
-msgid "Restore"
-msgstr "Restore"
+#~ msgid "Select a distance to look for (km)"
+#~ msgstr "Select a search radius from screen center"
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
-msgstr "System text to speech engine data is missing"
+# TRANSLATORS: This is the distance to a Point of Interest (POI) in the POI window. It will be feet (imperial) or, meters (metric), depending on the user's preference.
+#~ msgid "Distance(m)"
+#~ msgstr "Distance"
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
-msgstr ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
+#, c-format
+#~ msgid "in %d m"
+#~ msgstr "in %d m"
#, c-format
-#~ msgid "then leave the roundabout at the %1$s %2$s"
-#~ msgstr "then leave the roundabout at the %1$s %2$s"
+#~ msgid "%d m"
+#~ msgstr "%d m"
diff --git a/po/eo.po.in b/po/eo.po.in
index 62a0a7128..cc9826086 100644
--- a/po/eo.po.in
+++ b/po/eo.po.in
@@ -355,7 +355,7 @@ msgstr "Ĉirkaŭturnu %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "sekvu"
@@ -1668,7 +1668,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1927,10 +1927,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/es.po.in b/po/es.po.in
index bbd11a961..18bb0af56 100644
--- a/po/es.po.in
+++ b/po/es.po.in
@@ -1,5 +1,5 @@
# Spanish translations for navit
-# Copyright (C) 2006-2017 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Benjamín Valero Espinosa https://launchpad.net/~benjavalero
@@ -25,10 +25,10 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2017-09-26 07:01+0000\n"
-"Last-Translator: Iñigo Huguet <inigohuguet@hotmail.com>\n"
+"PO-Revision-Date: 2018-05-01 17:39+0000\n"
+"Last-Translator: iceman75 <Unknown>\n"
"Language-Team: Chris Eubank <cteubank@gmail.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -369,7 +369,7 @@ msgstr "Dé la vuelta %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "continúe"
@@ -398,9 +398,15 @@ msgstr "Orden"
msgid "Length"
msgstr "Longitud"
+msgid "mi"
+msgstr "mi"
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr "pies"
+
msgid "m"
msgstr "m"
@@ -1466,28 +1472,24 @@ msgstr ""
"\t-v: muestra la versión y termina.\n"
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
+msgid "No config file navit.xml, navit.xml.local found"
msgstr ""
-"No hay fichero de configuración navit.xml, encontrado navit.xml.local\n"
#, c-format
-msgid "Error parsing config file '%s': %s\n"
-msgstr "Error cargando el fichero de configuración '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
+msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
-msgstr "Usando el fichero de configuración '%s'\n"
+msgid "Using config file '%s'"
+msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
msgstr ""
-"Error: No se encontró la configuración en el archivo de configuración '%s'\n"
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
-"Inicialización interna fallida, saliendo. Compruebe mensajes previos de "
-"error\n"
msgid "unknown street"
msgstr "calle desconocida"
@@ -1627,6 +1629,9 @@ msgstr "_Mostrar posición del cursor"
msgid "_Lock on Road"
msgstr "_Bloqueo en la ruta"
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr "Mantener _orientación al Norte"
@@ -1696,24 +1701,24 @@ msgstr "Taxi"
msgid "Shopping"
msgstr "Shopping"
-msgid "Distance from screen center (km)"
-msgstr "Distancia del centro de la pantalla (km)"
+msgid "Select a search radius from screen center"
+msgstr "Distancia del centro de la pantalla"
#, c-format
msgid "POI %s. %s"
msgstr "POI %s. %s"
#, c-format
-msgid "Set destination to %ld, %ld \n"
-msgstr "Cambiar destino a %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
+msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
-msgstr "Cambiar mapa a % ld, %ld \n"
+msgid "Set map to %ld, %ld "
+msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
-msgstr "Conjunto siguiente visita a %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
+msgstr ""
msgid "POI search"
msgstr "Búsqueda de puntos de interés"
@@ -1783,8 +1788,8 @@ msgid "OT"
msgstr "OT"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Ruta %4.0fkm %02d:%02d TEL"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "Ruta 0000km 0+00:00 TEL"
@@ -1955,10 +1960,10 @@ msgstr "Puntos de paso"
msgid "Enter Coordinates"
msgstr "Introduzca coordenadas"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -2049,452 +2054,9 @@ msgstr "¡Atención! Radar"
msgid "Please decrease your speed"
msgstr "Por favor, disminuya su velocidad"
-msgid "partial match"
-msgstr "Coincidencia parcial"
-
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr "Búsqueda"
-
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
-msgstr "Ciudades"
-
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr "Datos de Mapa (c) contribuyentes de OpenStreetMap, ODBL"
-
-msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
-msgstr ""
-"Ubicación actual del mapa %s no se encuentra disponible\n"
-"Por favor reiniciar Navit después de conectar una tarjeta SD o seleccione "
-"una ubicación del mapa diferente."
-
-msgid "Downloaded maps"
-msgstr "Mapas descargados"
-
-msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
-msgstr ""
-"Lo sentimos, actualmente no permitimos mapas por encima de 3,8 G en Android, "
-"por favor, seleccione una versión más pequeña."
-
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr "Ruta hasta aquí"
-
-msgid "Cancel"
-msgstr "Cancelar"
-
msgid "filenamePath"
msgstr ""
-msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
-msgstr ""
-"Nueva ubicación cambiada a %s\n"
-"Reinicie Navit para aplicar los cambios."
-
-msgid "Whole Planet"
-msgstr "Todo el Planeta"
-
-msgid "Africa"
-msgstr "África"
-
-msgid "Canary Islands"
-msgstr "Islas Canarias"
-
-msgid "Asia"
-msgstr "Asia"
-
-msgid "Korea"
-msgstr "Corea"
-
-msgid "Taiwan"
-msgstr "Taiwán"
-
-msgid "UAE+Other"
-msgstr "Emiratos Árabes Unidos + Otros"
-
-msgid "Oceania"
-msgstr "Oceanía"
-
-msgid "Tasmania"
-msgstr "Tasmania"
-
-msgid "Victoria"
-msgstr "Victoria"
-
-msgid "New South Wales"
-msgstr "Nueva Gales del Sur"
-
-msgid "Europe"
-msgstr "Europa"
-
-msgid "Western Europe"
-msgstr "Europa Occidental"
-
-msgid "Azores"
-msgstr "Azores"
-
-msgid "BeNeLux"
-msgstr "Benelux"
-
-msgid "Alsace"
-msgstr "Alsacia"
-
-msgid "Aquitaine"
-msgstr "Aquitania"
-
-msgid "Auvergne"
-msgstr "Auvernia"
-
-msgid "Basse-Normandie"
-msgstr "Baja Normandía"
-
-msgid "Bourgogne"
-msgstr "Borgoña"
-
-msgid "Bretagne"
-msgstr "Bretaña"
-
-msgid "Centre"
-msgstr "Centro"
-
-msgid "Champagne-Ardenne"
-msgstr "Champaña - Ardenas"
-
-msgid "Corse"
-msgstr "Córcega"
-
-msgid "Franche-Comte"
-msgstr "Franco Condado"
-
-msgid "Haute-Normandie"
-msgstr "Alta Normandía"
-
-msgid "Ile-de-France"
-msgstr "Isla de Francia"
-
-msgid "Languedoc-Roussillon"
-msgstr "Languedoc - Rosellón"
-
-msgid "Limousin"
-msgstr "Limusina"
-
-msgid "Lorraine"
-msgstr "Lorena"
-
-msgid "Midi-Pyrenees"
-msgstr "Midi - Pirineos"
-
-msgid "Nord-pas-de-Calais"
-msgstr "Paso Norte de Calais"
-
-msgid "Pays-de-la-Loire"
-msgstr "Países del Loira"
-
-msgid "Picardie"
-msgstr "Paradía"
-
-msgid "Poitou-Charentes"
-msgstr "Poitou-Charentes"
-
-msgid "Provence-Alpes-Cote-d-Azur"
-msgstr "Alpes - Costa Azul"
-
-msgid "Rhone-Alpes"
-msgstr "Rhone - Alpes"
-
-msgid "Baden-Wuerttemberg"
-msgstr "Baden-Wuerttemberg"
-
-msgid "Bayern"
-msgstr "Baviera"
-
-msgid "Mittelfranken"
-msgstr "Franconia Media"
-
-msgid "Niederbayern"
-msgstr "Baja Baviera"
-
-msgid "Oberbayern"
-msgstr "Alta Baviera"
-
-msgid "Oberfranken"
-msgstr "Alta Franconia"
-
-msgid "Oberpfalz"
-msgstr "Alto Palatinado"
-
-msgid "Schwaben"
-msgstr "Schawben"
-
-msgid "Unterfranken"
-msgstr "Baja Franconia"
-
-msgid "Berlin"
-msgstr "Berlín"
-
-msgid "Brandenburg"
-msgstr "Brandenburgo"
-
-msgid "Bremen"
-msgstr "Bremen"
-
-msgid "Hamburg"
-msgstr "Hamburgo"
-
-msgid "Hessen"
-msgstr "Hessen"
-
-msgid "Mecklenburg-Vorpommern"
-msgstr "Mecklemburgo-Pomerania"
-
-msgid "Niedersachsen"
-msgstr "Niedersachsen"
-
-msgid "Nordrhein-westfalen"
-msgstr "Renania del Norte-Westfalia"
-
-msgid "Rheinland-Pfalz"
-msgstr "Renania del Norte-Westfalia"
-
-msgid "Saarland"
-msgstr "Sarre"
-
-msgid "Sachsen-Anhalt"
-msgstr "Sajonia-Anhalt"
-
-msgid "Sachsen"
-msgstr "Sachsen"
-
-msgid "Schleswig-Holstein"
-msgstr "Schleswig-Holstein"
-
-msgid "Thueringen"
-msgstr "Turingia"
-
-msgid "Mallorca"
-msgstr "Mallorca"
-
-msgid "Galicia"
-msgstr "Galicia"
-
-msgid "Scandinavia"
-msgstr "Escandinavia"
-
-msgid "England"
-msgstr "Inglaterra"
-
-msgid "Buckinghamshire"
-msgstr "Buckinghamshire"
-
-msgid "Cambridgeshire"
-msgstr "Cambridgeshire"
-
-msgid "Cumbria"
-msgstr "Cumbria"
-
-msgid "East yorkshire with hull"
-msgstr "Yorkshire Este con Hull"
-
-msgid "Essex"
-msgstr "Essex"
-
-msgid "Herefordshire"
-msgstr "Herefordshire"
-
-msgid "Kent"
-msgstr "Kent"
-
-msgid "Lancashire"
-msgstr "Lancashire"
-
-msgid "Leicestershire"
-msgstr "Leicestershire"
-
-msgid "Norfolk"
-msgstr "Norfolk"
-
-msgid "Nottinghamshire"
-msgstr "Nottinghamshire"
-
-msgid "Oxfordshire"
-msgstr "Oxfordshire"
-
-msgid "Shropshire"
-msgstr "Shropshire"
-
-msgid "Somerset"
-msgstr "Somerset"
-
-msgid "South yorkshire"
-msgstr "Yorkshire Sur"
-
-msgid "Suffolk"
-msgstr "Suffolk"
-
-msgid "Surrey"
-msgstr "Surrey"
-
-msgid "Wiltshire"
-msgstr "Wiltshire"
-
-msgid "Scotland"
-msgstr "Escocia"
-
-msgid "Wales"
-msgstr "Gales"
-
-msgid "Crete"
-msgstr "Creta"
-
-msgid "North America"
-msgstr "Norteamérica"
-
-msgid "Alaska"
-msgstr "Alaska"
-
-msgid "Hawaii"
-msgstr "Hawái"
-
-msgid "USA"
-msgstr "Estados Unidos de Norteamérica"
-
-msgid " (except Alaska and Hawaii)"
-msgstr " (excepto Alaska y Hawái)"
-
-msgid "Midwest"
-msgstr "Medio-Oeste"
-
-msgid "Michigan"
-msgstr "Michigan"
-
-msgid "Ohio"
-msgstr "Ohio"
-
-msgid "Northeast"
-msgstr "Noreste"
-
-msgid "Massachusetts"
-msgstr "Massachusetts"
-
-msgid "Vermont"
-msgstr "Vermont"
-
-msgid "Pacific"
-msgstr "Pacífico"
-
-msgid "South"
-msgstr "Sur"
-
-msgid "Arkansas"
-msgstr "Arkansas"
-
-msgid "District of Columbia"
-msgstr "Distrito de Columbia"
-
-msgid "Florida"
-msgstr "Florida"
-
-msgid "Louisiana"
-msgstr "Luisiana"
-
-msgid "Maryland"
-msgstr "Maryland"
-
-msgid "Mississippi"
-msgstr "Mississippi"
-
-msgid "Oklahoma"
-msgstr "Oklahoma"
-
-msgid "Texas"
-msgstr "Tejas"
-
-msgid "Virginia"
-msgstr "Virginia"
-
-msgid "West Virginia"
-msgstr "Virginia Occidental"
-
-msgid "West"
-msgstr "Oeste"
-
-msgid "Arizona"
-msgstr "Arizona"
-
-msgid "California"
-msgstr "California"
-
-msgid "Colorado"
-msgstr "Colorado"
-
-msgid "Idaho"
-msgstr "Idaho"
-
-msgid "Montana"
-msgstr "Montana"
-
-msgid "New Mexico"
-msgstr "Nuevo Méjico"
-
-msgid "Nevada"
-msgstr "Nevada"
-
-msgid "Oregon"
-msgstr "Oregón"
-
-msgid "Utah"
-msgstr "Utah"
-
-msgid "Washington State"
-msgstr "Estado de Washington"
-
-msgid "South+Middle America"
-msgstr "Suramérica + Centroamérica"
-
-msgid "Guyane Francaise"
-msgstr "Guayana Francesa"
-
-msgid "downloading"
-msgstr "descargando"
-
-#. Android resource: @strings/map_download_ready
-msgid "ready"
-msgstr "listo"
-
-msgid "Media selected for map storage is not available"
-msgstr ""
-"Los medios de comunicación seleccionados para el almacenamiento del mapa no "
-"está disponible"
-
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
-msgstr "No hay suficiente espacio libre"
-
-msgid "Error downloading map!"
-msgstr "Error al descargar el mapa"
-
-msgid "Error writing map!"
-msgstr "Error al guardar el mapa"
-
-msgid "Map download aborted!"
-msgstr "Descarga del mapa interrumpida"
-
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
-msgstr "Tiempo estimado"
-
-#. Android resource: @strings/map_download_title
-msgid "Map download"
-msgstr "Mapa descargado"
-
msgid "Vehicle Position"
msgstr "Posición del vehículo"
@@ -2559,7 +2121,7 @@ msgid "Manual zoom"
msgstr "Zoom manual"
msgid "Layers"
-msgstr ""
+msgstr "Capas"
msgid "Zoom to route"
msgstr "Zoom a ruta"
@@ -2676,14 +2238,30 @@ msgstr "Respaldar / Restaurar"
msgid "Set map location"
msgstr "Establecer ubicación en mapa"
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
+msgstr "Ruta hasta aquí"
+
#. Android resource: @strings/map_delete
msgid "Delete this map?"
msgstr "¿Borrar este mapa?"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
+msgstr "Mapa descargado"
+
#. Android resource: @strings/map_download_downloading
msgid "Downloading:"
msgstr "Descargando:"
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
+msgstr "Tiempo estimado"
+
+#. Android resource: @strings/map_download_ready
+msgid "ready"
+msgstr "listo"
+
#. Android resource: @strings/map_download_download_error
msgid "Error downloading map."
msgstr "Error descargando mapa"
@@ -2692,6 +2270,10 @@ msgstr "Error descargando mapa"
msgid "Map download aborted"
msgstr "Descarga de mapa interrumpida"
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
+msgstr "No hay suficiente espacio libre"
+
#. Android resource: @strings/map_no_fix
msgid "No location. Reopen after location fix."
msgstr "Sin localización. Reabra tras fijar localización."
@@ -2712,6 +2294,10 @@ msgstr "Introduzca destino"
msgid "Match partial address"
msgstr "Coincidencia parcial en la dirección"
+#. Android resource: @strings/address_search_button
+msgid "Search"
+msgstr "Búsqueda"
+
#. Android resource: @strings/address_search_searching
msgid "Searching..."
msgstr "Buscando…"
@@ -2740,6 +2326,10 @@ msgstr "No se introdujo texto"
msgid "Setting destination to:"
msgstr "Configurando destino a:"
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
+msgstr "Ciudades"
+
#. Android resource: @strings/choose_an_action
msgid "Choose an action"
msgstr "Elija una acción"
@@ -2806,7 +2396,7 @@ msgstr "Restaurar"
#. Android resource: @strings/TTS_title_data_missing
msgid "System text to speech engine data is missing"
-msgstr ""
+msgstr "No hay datos de síntesis de voz del sistema"
#. Android resource: @strings/TTS_qery_install_data
msgid ""
@@ -2814,6 +2404,9 @@ msgid ""
"currently selected engine reports it is unable to speak in your language. "
"Should we ask the system to show voice download dialog?"
msgstr ""
+"Navit puede usar cualquier sintetizador de voz instalado en el dispositivo. "
+"El sintetizador seleccionado actualmente informa de que no puede hablar en "
+"su idioma. ¿Desea ver el diálogo de descarga de voces del sistema?"
#. Android resource: @strings/permissions_not_granted
msgid ""
@@ -2828,5 +2421,462 @@ msgid "One or more ungranted permissions"
msgstr "Uno o más permisos rechazados"
#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Ruta %4.0fkm %02d:%02d TEL"
+
+#~ msgid "No config file navit.xml, navit.xml.local found\n"
+#~ msgstr ""
+#~ "No hay fichero de configuración navit.xml, encontrado navit.xml.local\n"
+
+#, c-format
+#~ msgid "Error parsing config file '%s': %s\n"
+#~ msgstr "Error cargando el fichero de configuración '%s': %s\n"
+
+#, c-format
+#~ msgid "Using config file '%s'\n"
+#~ msgstr "Usando el fichero de configuración '%s'\n"
+
+#~ msgid ""
+#~ "Internal initialization failed, exiting. Check previous error messages.\n"
+#~ msgstr ""
+#~ "Inicialización interna fallida, saliendo. Compruebe mensajes previos de "
+#~ "error\n"
+
+#~ msgid "Cancel"
+#~ msgstr "Cancelar"
+
+#~ msgid "Downloaded maps"
+#~ msgstr "Mapas descargados"
+
+#~ msgid "partial match"
+#~ msgstr "Coincidencia parcial"
+
+#~ msgid "Taiwan"
+#~ msgstr "Taiwán"
+
+#~ msgid "Asia"
+#~ msgstr "Asia"
+
+#~ msgid "Canary Islands"
+#~ msgstr "Islas Canarias"
+
+#~ msgid "Whole Planet"
+#~ msgstr "Todo el Planeta"
+
+#~ msgid "Korea"
+#~ msgstr "Corea"
+
+#~ msgid "Tasmania"
+#~ msgstr "Tasmania"
+
+#~ msgid "Victoria"
+#~ msgstr "Victoria"
+
+#~ msgid "Oceania"
+#~ msgstr "Oceanía"
+
+#~ msgid "UAE+Other"
+#~ msgstr "Emiratos Árabes Unidos + Otros"
+
+#~ msgid "BeNeLux"
+#~ msgstr "Benelux"
+
+#~ msgid "Alsace"
+#~ msgstr "Alsacia"
+
+#~ msgid "Western Europe"
+#~ msgstr "Europa Occidental"
+
+#~ msgid "Azores"
+#~ msgstr "Azores"
+
+#~ msgid "New South Wales"
+#~ msgstr "Nueva Gales del Sur"
+
+#~ msgid "Europe"
+#~ msgstr "Europa"
+
+#~ msgid "Bourgogne"
+#~ msgstr "Borgoña"
+
+#~ msgid "Auvergne"
+#~ msgstr "Auvernia"
+
+#~ msgid "Aquitaine"
+#~ msgstr "Aquitania"
+
+#~ msgid "Basse-Normandie"
+#~ msgstr "Baja Normandía"
+
+#~ msgid "Lorraine"
+#~ msgstr "Lorena"
+
+#~ msgid "Languedoc-Roussillon"
+#~ msgstr "Languedoc - Rosellón"
+
+#~ msgid "Bretagne"
+#~ msgstr "Bretaña"
+
+#~ msgid "Haute-Normandie"
+#~ msgstr "Alta Normandía"
+
+#~ msgid "Centre"
+#~ msgstr "Centro"
+
+#~ msgid "Corse"
+#~ msgstr "Córcega"
+
+#~ msgid "Champagne-Ardenne"
+#~ msgstr "Champaña - Ardenas"
+
+#~ msgid "Baden-Wuerttemberg"
+#~ msgstr "Baden-Wuerttemberg"
+
+#~ msgid "Rhone-Alpes"
+#~ msgstr "Rhone - Alpes"
+
+#~ msgid "Provence-Alpes-Cote-d-Azur"
+#~ msgstr "Alpes - Costa Azul"
+
+#~ msgid "Midi-Pyrenees"
+#~ msgstr "Midi - Pirineos"
+
+#~ msgid "Nord-pas-de-Calais"
+#~ msgstr "Paso Norte de Calais"
+
+#~ msgid "Picardie"
+#~ msgstr "Paradía"
+
+#~ msgid "Schwaben"
+#~ msgstr "Schawben"
+
+#~ msgid "Hamburg"
+#~ msgstr "Hamburgo"
+
+#~ msgid "Bremen"
+#~ msgstr "Bremen"
+
+#~ msgid "Berlin"
+#~ msgstr "Berlín"
+
+#~ msgid "Brandenburg"
+#~ msgstr "Brandenburgo"
+
+#~ msgid "Saarland"
+#~ msgstr "Sarre"
+
+#~ msgid "Niedersachsen"
+#~ msgstr "Niedersachsen"
+
+#~ msgid "Hessen"
+#~ msgstr "Hessen"
+
+#~ msgid "Sachsen"
+#~ msgstr "Sachsen"
+
+#~ msgid "Thueringen"
+#~ msgstr "Turingia"
+
+#~ msgid "Schleswig-Holstein"
+#~ msgstr "Schleswig-Holstein"
+
+#~ msgid "Cumbria"
+#~ msgstr "Cumbria"
+
+#~ msgid "Herefordshire"
+#~ msgstr "Herefordshire"
+
+#~ msgid "Essex"
+#~ msgstr "Essex"
+
+#~ msgid "Buckinghamshire"
+#~ msgstr "Buckinghamshire"
+
+#~ msgid "Galicia"
+#~ msgstr "Galicia"
+
+#~ msgid "Mallorca"
+#~ msgstr "Mallorca"
+
+#~ msgid "England"
+#~ msgstr "Inglaterra"
+
+#~ msgid "Scandinavia"
+#~ msgstr "Escandinavia"
+
+#~ msgid "Cambridgeshire"
+#~ msgstr "Cambridgeshire"
+
+#~ msgid "Oxfordshire"
+#~ msgstr "Oxfordshire"
+
+#~ msgid "Nottinghamshire"
+#~ msgstr "Nottinghamshire"
+
+#~ msgid "Lancashire"
+#~ msgstr "Lancashire"
+
+#~ msgid "Kent"
+#~ msgstr "Kent"
+
+#~ msgid "Norfolk"
+#~ msgstr "Norfolk"
+
+#~ msgid "Leicestershire"
+#~ msgstr "Leicestershire"
+
+#~ msgid "Suffolk"
+#~ msgstr "Suffolk"
+
+#~ msgid "Somerset"
+#~ msgstr "Somerset"
+
+#~ msgid " (except Alaska and Hawaii)"
+#~ msgstr " (excepto Alaska y Hawái)"
+
+#~ msgid "USA"
+#~ msgstr "Estados Unidos de Norteamérica"
+
+#~ msgid "Hawaii"
+#~ msgstr "Hawái"
+
+#~ msgid "Alaska"
+#~ msgstr "Alaska"
+
+#~ msgid "Crete"
+#~ msgstr "Creta"
+
+#~ msgid "North America"
+#~ msgstr "Norteamérica"
+
+#~ msgid "Scotland"
+#~ msgstr "Escocia"
+
+#~ msgid "Wales"
+#~ msgstr "Gales"
+
+#~ msgid "Surrey"
+#~ msgstr "Surrey"
+
+#~ msgid "Wiltshire"
+#~ msgstr "Wiltshire"
+
+#~ msgid "Pacific"
+#~ msgstr "Pacífico"
+
+#~ msgid "South"
+#~ msgstr "Sur"
+
+#~ msgid "Arkansas"
+#~ msgstr "Arkansas"
+
+#~ msgid "District of Columbia"
+#~ msgstr "Distrito de Columbia"
+
+#~ msgid "Ohio"
+#~ msgstr "Ohio"
+
+#~ msgid "Michigan"
+#~ msgstr "Michigan"
+
+#~ msgid "Vermont"
+#~ msgstr "Vermont"
+
+#~ msgid "Massachusetts"
+#~ msgstr "Massachusetts"
+
+#~ msgid "Florida"
+#~ msgstr "Florida"
+
+#~ msgid "Louisiana"
+#~ msgstr "Luisiana"
+
+#~ msgid "Maryland"
+#~ msgstr "Maryland"
+
+#~ msgid "Oklahoma"
+#~ msgstr "Oklahoma"
+
+#~ msgid "Mississippi"
+#~ msgstr "Mississippi"
+
+#~ msgid "Texas"
+#~ msgstr "Tejas"
+
+#~ msgid "West Virginia"
+#~ msgstr "Virginia Occidental"
+
+#~ msgid "Virginia"
+#~ msgstr "Virginia"
+
+#~ msgid "Arizona"
+#~ msgstr "Arizona"
+
+#~ msgid "West"
+#~ msgstr "Oeste"
+
+#~ msgid "Washington State"
+#~ msgstr "Estado de Washington"
+
+#~ msgid "South+Middle America"
+#~ msgstr "Suramérica + Centroamérica"
+
+#~ msgid "Oregon"
+#~ msgstr "Oregón"
+
+#~ msgid "Utah"
+#~ msgstr "Utah"
+
+#~ msgid "Nevada"
+#~ msgstr "Nevada"
+
+#~ msgid "New Mexico"
+#~ msgstr "Nuevo Méjico"
+
+#~ msgid "Colorado"
+#~ msgstr "Colorado"
+
+#~ msgid "California"
+#~ msgstr "California"
+
+#~ msgid "Montana"
+#~ msgstr "Montana"
+
+#~ msgid "Idaho"
+#~ msgstr "Idaho"
+
+#~ msgid "Error downloading map!"
+#~ msgstr "Error al descargar el mapa"
+
+#~ msgid "Guyane Francaise"
+#~ msgstr "Guayana Francesa"
+
+#~ msgid "downloading"
+#~ msgstr "descargando"
+
+#~ msgid "Map download aborted!"
+#~ msgstr "Descarga del mapa interrumpida"
+
+#~ msgid "Error writing map!"
+#~ msgstr "Error al guardar el mapa"
+
+#~ msgid "Mittelfranken"
+#~ msgstr "Franconia Media"
+
+#~ msgid "Africa"
+#~ msgstr "África"
+
+#~ msgid "Map data (c) OpenStreetMap contributors, ODBL"
+#~ msgstr "Datos de Mapa (c) contribuyentes de OpenStreetMap, ODBL"
+
+#~ msgid "Ile-de-France"
+#~ msgstr "Isla de Francia"
+
+#~ msgid "Limousin"
+#~ msgstr "Limusina"
+
+#~ msgid "Pays-de-la-Loire"
+#~ msgstr "Países del Loira"
+
+#~ msgid "Poitou-Charentes"
+#~ msgstr "Poitou-Charentes"
+
+#~ msgid "Franche-Comte"
+#~ msgstr "Franco Condado"
+
+#~ msgid "Northeast"
+#~ msgstr "Noreste"
+
+#~ msgid "Midwest"
+#~ msgstr "Medio-Oeste"
+
+#~ msgid "Oberpfalz"
+#~ msgstr "Alto Palatinado"
+
+#~ msgid "Oberfranken"
+#~ msgstr "Alta Franconia"
+
+#~ msgid "Unterfranken"
+#~ msgstr "Baja Franconia"
+
+#~ msgid "Rheinland-Pfalz"
+#~ msgstr "Renania del Norte-Westfalia"
+
+#~ msgid "Mecklenburg-Vorpommern"
+#~ msgstr "Mecklemburgo-Pomerania"
+
+#~ msgid "Sachsen-Anhalt"
+#~ msgstr "Sajonia-Anhalt"
+
+#~ msgid "Nordrhein-westfalen"
+#~ msgstr "Renania del Norte-Westfalia"
+
+#~ msgid "South yorkshire"
+#~ msgstr "Yorkshire Sur"
+
+#~ msgid "Shropshire"
+#~ msgstr "Shropshire"
+
+#~ msgid "East yorkshire with hull"
+#~ msgstr "Yorkshire Este con Hull"
+
+#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
#~ msgstr "después salga de la rotonda por la %1$s %2$s"
+
+#~ msgid "Bayern"
+#~ msgstr "Baviera"
+
+#~ msgid "Niederbayern"
+#~ msgstr "Baja Baviera"
+
+#~ msgid "Oberbayern"
+#~ msgstr "Alta Baviera"
+
+#~ msgid "Distance from screen center (km)"
+#~ msgstr "Distancia del centro de la pantalla (km)"
+
+#, c-format
+#~ msgid "Set destination to %ld, %ld \n"
+#~ msgstr "Cambiar destino a %ld, %ld \n"
+
+#, c-format
+#~ msgid "Set map to %ld, %ld \n"
+#~ msgstr "Cambiar mapa a % ld, %ld \n"
+
+#, c-format
+#~ msgid "Set next visit to %ld, %ld \n"
+#~ msgstr "Conjunto siguiente visita a %ld, %ld \n"
+
+#~ msgid ""
+#~ "Current map location %s is not available\n"
+#~ "Please restart Navit after you attach an SD card or select a different map "
+#~ "location."
+#~ msgstr ""
+#~ "Ubicación actual del mapa %s no se encuentra disponible\n"
+#~ "Por favor reiniciar Navit después de conectar una tarjeta SD o seleccione "
+#~ "una ubicación del mapa diferente."
+
+#~ msgid ""
+#~ "Sorry, we currently do not support maps above 3.8G on Android, please select "
+#~ "a smaller one."
+#~ msgstr ""
+#~ "Lo sentimos, actualmente no permitimos mapas por encima de 3,8 G en Android, "
+#~ "por favor, seleccione una versión más pequeña."
+
+#~ msgid ""
+#~ "New location set to %s\n"
+#~ "Restart Navit to apply the changes."
+#~ msgstr ""
+#~ "Nueva ubicación cambiada a %s\n"
+#~ "Reinicie Navit para aplicar los cambios."
+
+#~ msgid "Media selected for map storage is not available"
+#~ msgstr ""
+#~ "Los medios de comunicación seleccionados para el almacenamiento del mapa no "
+#~ "está disponible"
+
+#, c-format
+#~ msgid "Error: No configuration found in config file '%s'\n"
+#~ msgstr ""
+#~ "Error: No se encontró la configuración en el archivo de configuración '%s'\n"
diff --git a/po/et.po.in b/po/et.po.in
index 23781e008..6b81f10c3 100644
--- a/po/et.po.in
+++ b/po/et.po.in
@@ -355,7 +355,7 @@ msgstr "Pööra ümber %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1670,7 +1670,7 @@ msgstr "Takso"
msgid "Shopping"
msgstr "kauplus"
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1929,10 +1929,10 @@ msgstr "Teekonnapunktid"
msgid "Enter Coordinates"
msgstr "Sisesta koordinaadid"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/eu.po.in b/po/eu.po.in
index d0de74d5d..7ecec298e 100644
--- a/po/eu.po.in
+++ b/po/eu.po.in
@@ -352,7 +352,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1665,7 +1665,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1924,10 +1924,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/fa.po.in b/po/fa.po.in
index 96767686f..753087ba1 100644
--- a/po/fa.po.in
+++ b/po/fa.po.in
@@ -352,7 +352,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1665,7 +1665,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1924,10 +1924,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/fi.po.in b/po/fi.po.in
index 5662696a4..cdcc582f3 100644
--- a/po/fi.po.in
+++ b/po/fi.po.in
@@ -357,7 +357,7 @@ msgstr "Tee u-käännös %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1675,7 +1675,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1934,10 +1934,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/fil.po.in b/po/fil.po.in
index a882e9f6d..5e301ac35 100644
--- a/po/fil.po.in
+++ b/po/fil.po.in
@@ -1,15 +1,16 @@
# Filipino translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
+# Marlon Janssen Arao https://launchpad.net/~marlonjanssenarao
# chito https://launchpad.net/~cnuarin
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2015-07-19 03:58+0000\n"
-"Last-Translator: chito <cnuarin@gmail.com>\n"
+"PO-Revision-Date: 2018-06-04 20:43+0000\n"
+"Last-Translator: Marlon Janssen Arao <Unknown>\n"
"Language-Team: Filipino <fil@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -22,20 +23,20 @@ msgstr ""
#, c-format
msgid "setting '%s' to '%s'\n"
-msgstr ""
+msgstr "itinatakda ang '%s' sa '%s'\n"
#. TRANSLATORS: the following counts refer to streets
msgid "zeroth"
msgstr ""
msgid "first"
-msgstr ""
+msgstr "una"
msgid "second"
-msgstr ""
+msgstr "pangalawa"
msgid "third"
-msgstr ""
+msgstr "pangatlo"
msgid "fourth"
msgstr "pang-apat"
@@ -70,39 +71,39 @@ msgstr "pang-anim na labasan"
#, c-format
msgid "%d feet"
-msgstr ""
+msgstr "%d talampakan"
#, c-format
msgid "in %d feet"
-msgstr ""
+msgstr "sa %d talampakan"
#, c-format
msgid "%d.%d miles"
-msgstr ""
+msgstr "%d.%d milya"
#, c-format
msgid "in %d.%d miles"
-msgstr ""
+msgstr "sa %d.%d na milya"
#, c-format
msgid "one mile"
msgid_plural "%d miles"
-msgstr[0] ""
-msgstr[1] ""
+msgstr[0] "isang milya"
+msgstr[1] "%d na milya"
#, c-format
msgid "in one mile"
msgid_plural "in %d miles"
-msgstr[0] ""
-msgstr[1] ""
+msgstr[0] "sa isang milya"
+msgstr[1] "sa %d na milya"
#, c-format
msgid "%d meters"
-msgstr ""
+msgstr "%d metro"
#, c-format
msgid "in %d meters"
-msgstr ""
+msgstr "sa %d metro"
#, c-format
msgid "%d.%d kilometers"
@@ -110,29 +111,29 @@ msgstr "%d.%d kilometro"
#, c-format
msgid "in %d.%d kilometers"
-msgstr "%d.%d kilometro"
+msgstr "sa %d.%d na kilometro"
#, c-format
msgid "one kilometer"
msgid_plural "%d kilometers"
-msgstr[0] ""
+msgstr[0] "isang kilometro"
msgstr[1] "%d kilometro"
#, c-format
msgid "in one kilometer"
msgid_plural "in %d kilometers"
-msgstr[0] "sa loob ng isang kilometro"
-msgstr[1] "sa loob ng %d kilometro"
+msgstr[0] "sa isang kilometro"
+msgstr[1] "sa %d na kilometro"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Systematic Street Name 3: Separator (Space if required), 4: Street Name
#, c-format
msgid "%1$sonto the %2$s%3$s%4$s"
-msgstr ""
+msgstr "%1$s papunta sa %2$s%3$s%4$s"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name
#, c-format
msgid "%1$sonto %2$s"
-msgstr ""
+msgstr "%1$s papuntang %2$s"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Masculine form. The stuff after | doesn't have to be included
#, c-format
@@ -149,71 +150,70 @@ msgstr ""
msgid "%1$sonto %2$s|neuter form"
msgstr ""
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr ""
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name
#, c-format
msgid "%sinto %s%s%s"
-msgstr "%s sa kalyeng %s%s%s"
+msgstr "%s sa %s%s%s"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Masculine form. The stuff after | doesn't have to be included
#, c-format
msgid "%sinto %s%s%s|masculine form"
-msgstr "%s sa kalyeng %s%s%s"
+msgstr "%s sa %s%s%s|masculine form"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Feminine form. The stuff after | doesn't have to be included
#, c-format
msgid "%sinto %s%s%s|feminine form"
-msgstr "%s sa kalyeng %s%s%s"
+msgstr "%s sa %s%s%s|feminine form"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name 3: Separator (Space if required), 4: Systematic Street Name. Neuter form. The stuff after | doesn't have to be included
#, c-format
msgid "%sinto %s%s%s|neuter form"
-msgstr "%s sa kalyeng %s%s%s"
+msgstr "%s sa %s%s%s|neuter form"
#. TRANSLATORS: gives the name of the next road to turn into (into the E17)
#, c-format
msgid "%sinto the %s"
-msgstr ""
+msgstr "%s sa %s"
msgid "When possible, please turn around"
-msgstr "Kung maari ay bumalik"
+msgstr "Kung maari, mangyaring umikot pabalik"
#. TRANSLATORS: the argument is the destination to follow
#, c-format
msgid "towards %s"
-msgstr ""
+msgstr "patungo sa %s"
#, c-format
msgid "Follow the road for the next %s"
-msgstr "Sundan ang kalye sa susunod na %s"
+msgstr "Sundan ang daan para sa susunod na %s"
msgid "Enter the roundabout soon"
-msgstr ""
+msgstr "Pumasok sa rotonda sa lalong madaling panahon"
#. TRANSLATORS: %s is the distance to the roundabout
#, c-format
msgid "Enter the roundabout %s"
-msgstr ""
+msgstr "Pumasok sa rotonda sa %s"
msgid "then enter the roundabout"
-msgstr ""
+msgstr "pagkatapos ay pumasok sa rotonda"
#. TRANSLATORS: first arg. is the manieth exit, second arg. is the destination to follow
#, c-format
msgid "Leave the roundabout at the %1$s %2$s"
-msgstr "Lisanin ang rotonda sa may %1$s %2$s"
+msgstr "Lumabas sa rotonda sa %1$s %2$s"
msgid "soon"
-msgstr ""
+msgstr "sa lalong madaling panahon"
msgid "now"
msgstr "ngayon na"
msgid "then"
-msgstr ""
+msgstr "pagkatapos"
#. TRANSLATORS: the arg. is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included.
#, c-format
@@ -236,10 +236,10 @@ msgid "Merge %1$s%2$s|left"
msgstr ""
msgid "on your left"
-msgstr ""
+msgstr "sa iyong gawing kaliwa"
msgid "on your right"
-msgstr ""
+msgstr "sa iyong gawing kaliwa"
#. TRANSLATORS: the first arg. is exit ref and/or name, the second is the direction of exit and the third is distance
#, c-format
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -362,7 +362,6 @@ msgstr ""
msgid "You have reached your destination %s"
msgstr ""
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr ""
@@ -379,9 +378,15 @@ msgstr ""
msgid "Length"
msgstr ""
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr ""
+msgid "feet"
+msgstr ""
+
msgid "m"
msgstr ""
@@ -442,6 +447,7 @@ msgid "Anguilla"
msgstr ""
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr ""
@@ -454,6 +460,7 @@ msgid "Netherlands Antilles"
msgstr ""
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr ""
@@ -462,6 +469,7 @@ msgid "Antarctica"
msgstr ""
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr ""
@@ -470,10 +478,12 @@ msgid "American Samoa"
msgstr ""
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr ""
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr ""
@@ -486,10 +496,12 @@ msgid "Aland Islands"
msgstr ""
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr ""
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr ""
@@ -502,6 +514,7 @@ msgid "Bangladesh"
msgstr ""
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr ""
@@ -510,6 +523,7 @@ msgid "Burkina Faso"
msgstr ""
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr ""
@@ -518,6 +532,7 @@ msgid "Bahrain"
msgstr ""
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr ""
@@ -538,6 +553,7 @@ msgid "Brunei Darussalam"
msgstr ""
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr ""
@@ -546,6 +562,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr ""
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr ""
@@ -562,10 +579,12 @@ msgid "Bouvet Island"
msgstr ""
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr ""
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr ""
@@ -574,6 +593,7 @@ msgid "Belize"
msgstr ""
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr ""
@@ -582,6 +602,7 @@ msgid "Cocos (Keeling) Islands"
msgstr ""
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr ""
@@ -594,10 +615,12 @@ msgid "Congo"
msgstr ""
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr ""
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr ""
@@ -606,6 +629,7 @@ msgid "Cook Islands"
msgstr ""
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr ""
@@ -614,10 +638,12 @@ msgid "Cameroon"
msgstr ""
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr ""
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr ""
@@ -626,6 +652,7 @@ msgid "Costa Rica"
msgstr ""
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr ""
@@ -642,14 +669,17 @@ msgid "Christmas Island"
msgstr ""
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr ""
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr ""
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr ""
@@ -658,6 +688,7 @@ msgid "Djibouti"
msgstr ""
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr ""
@@ -666,6 +697,7 @@ msgid "Dominica"
msgstr ""
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr ""
@@ -674,10 +706,12 @@ msgid "Algeria"
msgstr ""
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr ""
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr ""
@@ -694,14 +728,17 @@ msgid "Eritrea"
msgstr ""
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr ""
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr ""
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr ""
@@ -718,10 +755,12 @@ msgid "Micronesia, Federated States of"
msgstr ""
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr ""
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr ""
@@ -730,6 +769,7 @@ msgid "Gabon"
msgstr ""
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr ""
@@ -766,6 +806,7 @@ msgid "Gambia"
msgstr ""
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr ""
@@ -778,6 +819,7 @@ msgid "Equatorial Guinea"
msgstr ""
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr ""
@@ -798,6 +840,7 @@ msgid "Guinea-Bissau"
msgstr ""
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr ""
@@ -814,26 +857,32 @@ msgid "Honduras"
msgstr ""
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr ""
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr ""
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr ""
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr ""
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr ""
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr ""
@@ -842,6 +891,7 @@ msgid "Isle of Man"
msgstr ""
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr ""
@@ -850,18 +900,22 @@ msgid "British Indian Ocean Territory"
msgstr ""
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr ""
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr ""
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr ""
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr ""
@@ -870,6 +924,7 @@ msgid "Jersey"
msgstr ""
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr ""
@@ -878,14 +933,17 @@ msgid "Jordan"
msgstr ""
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr ""
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr ""
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr ""
@@ -922,6 +980,7 @@ msgid "Cayman Islands"
msgstr ""
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr ""
@@ -946,26 +1005,32 @@ msgid "Sri Lanka"
msgstr ""
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr ""
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr ""
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr ""
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr ""
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr ""
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr ""
@@ -990,6 +1055,7 @@ msgid "Saint Martin (French part)"
msgstr ""
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr ""
@@ -1010,6 +1076,7 @@ msgid "Myanmar"
msgstr ""
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr ""
@@ -1050,10 +1117,12 @@ msgid "Malawi"
msgstr ""
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr ""
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr ""
@@ -1062,10 +1131,12 @@ msgid "Mozambique"
msgstr ""
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr ""
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr ""
@@ -1086,6 +1157,7 @@ msgid "Nicaragua"
msgstr ""
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr ""
@@ -1094,6 +1166,7 @@ msgid "Norway"
msgstr ""
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr ""
@@ -1106,6 +1179,7 @@ msgid "Niue"
msgstr ""
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr ""
@@ -1118,6 +1192,7 @@ msgid "Panama"
msgstr ""
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr ""
@@ -1130,14 +1205,17 @@ msgid "Papua New Guinea"
msgstr ""
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr ""
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr ""
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr ""
@@ -1158,6 +1236,7 @@ msgid "Palestinian Territory, Occupied"
msgstr ""
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr ""
@@ -1166,6 +1245,7 @@ msgid "Palau"
msgstr ""
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr ""
@@ -1174,10 +1254,12 @@ msgid "Qatar"
msgstr ""
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr ""
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr ""
@@ -1186,14 +1268,17 @@ msgid "Serbia"
msgstr ""
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr ""
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr ""
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr ""
@@ -1214,6 +1299,7 @@ msgid "Sweden"
msgstr ""
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr ""
@@ -1230,6 +1316,7 @@ msgid "Svalbard and Jan Mayen"
msgstr ""
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr ""
@@ -1250,6 +1337,7 @@ msgid "Somalia"
msgstr ""
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr ""
@@ -1294,6 +1382,7 @@ msgid "Togo"
msgstr ""
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr ""
@@ -1310,6 +1399,7 @@ msgid "Timor-Leste"
msgstr ""
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr ""
@@ -1322,6 +1412,7 @@ msgid "Tonga"
msgstr ""
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr ""
@@ -1338,14 +1429,17 @@ msgid "Taiwan, Province of China"
msgstr ""
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr ""
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr ""
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr ""
@@ -1358,6 +1452,7 @@ msgid "United States"
msgstr ""
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr ""
@@ -1374,6 +1469,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr ""
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr ""
@@ -1410,6 +1506,7 @@ msgid "Mayotte"
msgstr ""
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr ""
@@ -1437,23 +1534,23 @@ msgid ""
msgstr ""
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
+msgid "No config file navit.xml, navit.xml.local found"
msgstr ""
#, c-format
-msgid "Error parsing config file '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
msgstr ""
#, c-format
-msgid "Using config file '%s'\n"
+msgid "Using config file '%s'"
msgstr ""
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
msgstr ""
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
msgid "unknown street"
@@ -1594,6 +1691,9 @@ msgstr ""
msgid "_Lock on Road"
msgstr ""
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr ""
@@ -1663,7 +1763,12 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
msgstr ""
#, c-format
@@ -1671,15 +1776,15 @@ msgid "POI %s. %s"
msgstr ""
#, c-format
-msgid "Set destination to %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set map to %ld, %ld \n"
+msgid "Set map to %ld, %ld "
msgstr ""
#, c-format
-msgid "Set next visit to %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
msgstr ""
msgid "POI search"
@@ -1688,9 +1793,6 @@ msgstr ""
msgid "Select a category"
msgstr ""
-msgid "Select a distance to look for (km)"
-msgstr ""
-
msgid "Select a POI"
msgstr ""
@@ -1703,7 +1805,7 @@ msgstr ""
msgid "Direction"
msgstr ""
-msgid "Distance(m)"
+msgid "Distance"
msgstr ""
msgid "Name"
@@ -1750,7 +1852,7 @@ msgid "OT"
msgstr ""
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
+msgid "Route %4.1f%s %02d:%02d ETA"
msgstr ""
msgid "Route 0000km 0+00:00 ETA"
@@ -1922,10 +2024,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1973,6 +2075,9 @@ msgstr ""
msgid "Show Locale"
msgstr ""
+msgid "Network info"
+msgstr ""
+
msgid "Former Destinations"
msgstr ""
@@ -2011,731 +2116,863 @@ msgstr ""
msgid "Please decrease your speed"
msgstr ""
-msgid "partial match"
+msgid "Vehicle Position"
msgstr ""
-#. Android resource: @strings/address_search_button
-msgid "Search"
+msgid "Main menu"
msgstr ""
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
+msgid ""
+"Show\n"
+"Map"
msgstr ""
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
+msgid "Settings"
msgstr ""
-msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+msgid "Tools"
msgstr ""
-msgid "Downloaded maps"
+msgid "Route"
msgstr ""
-msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+msgid "About"
msgstr ""
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
+msgid "Quit"
msgstr ""
-msgid "Cancel"
+msgid "Actions"
msgstr ""
-msgid "filenamePath"
+msgid ""
+"Former\n"
+"Destinations"
msgstr ""
-msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+msgid "Coordinates"
msgstr ""
-msgid "Whole Planet"
+msgid ""
+"Stop\n"
+"Navigation"
msgstr ""
-msgid "Africa"
+msgid "Display"
msgstr ""
-msgid "Canary Islands"
+msgid "Fullscreen"
msgstr ""
-msgid "Asia"
+msgid "Window Mode"
msgstr ""
-msgid "Korea"
+msgid "Auto zoom"
msgstr ""
-msgid "Taiwan"
+msgid "Manual zoom"
msgstr ""
-msgid "UAE+Other"
+msgid "Layers"
msgstr ""
-msgid "Oceania"
+msgid "Zoom to route"
msgstr ""
-msgid "Tasmania"
+msgid "Description"
msgstr ""
-msgid "Victoria"
+msgid ""
+"Drop last\n"
+"Waypoint"
msgstr ""
-msgid "New South Wales"
+msgid ""
+"Drop next\n"
+"Waypoint"
msgstr ""
-msgid "Europe"
+msgid "Satellite Status"
msgstr ""
-msgid "Western Europe"
+msgid "NMEA Data"
msgstr ""
-msgid "Azores"
+msgid "car_shortest"
msgstr ""
-msgid "BeNeLux"
+msgid "car_avoid_tolls"
msgstr ""
-msgid "Alsace"
+msgid "car_pedantic"
msgstr ""
-msgid "Aquitaine"
+msgid "horse"
msgstr ""
-msgid "Auvergne"
+msgid "Truck"
msgstr ""
-msgid "Basse-Normandie"
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
msgstr ""
-msgid "Bourgogne"
+#. Android resource: @strings/cancel
+msgid "Cancel"
msgstr ""
-msgid "Bretagne"
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
msgstr ""
-msgid "Centre"
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
msgstr ""
-msgid "Champagne-Ardenne"
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
msgstr ""
-msgid "Corse"
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
msgstr ""
-msgid "Franche-Comte"
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
msgstr ""
-msgid "Haute-Normandie"
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
msgstr ""
-msgid "Ile-de-France"
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
msgstr ""
-msgid "Languedoc-Roussillon"
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
msgstr ""
-msgid "Limousin"
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
msgstr ""
-msgid "Lorraine"
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
msgstr ""
-msgid "Midi-Pyrenees"
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
msgstr ""
-msgid "Nord-pas-de-Calais"
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
msgstr ""
-msgid "Pays-de-la-Loire"
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
msgstr ""
-msgid "Picardie"
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
msgstr ""
-msgid "Poitou-Charentes"
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
msgstr ""
-msgid "Provence-Alpes-Cote-d-Azur"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
msgstr ""
-msgid "Rhone-Alpes"
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
msgstr ""
-msgid "Baden-Wuerttemberg"
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
msgstr ""
-msgid "Bayern"
+#. Android resource: @strings/map_download_ready
+msgid "ready"
msgstr ""
-msgid "Mittelfranken"
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
msgstr ""
-msgid "Niederbayern"
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
msgstr ""
-msgid "Oberbayern"
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
msgstr ""
-msgid "Oberfranken"
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
msgstr ""
-msgid "Oberpfalz"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
msgstr ""
-msgid "Schwaben"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
msgstr ""
-msgid "Unterfranken"
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
msgstr ""
-msgid "Berlin"
+#. Android resource: @strings/map_downloading
+msgid "downloading"
msgstr ""
-msgid "Brandenburg"
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
msgstr ""
-msgid "Bremen"
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
msgstr ""
-msgid "Hamburg"
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
msgstr ""
-msgid "Hessen"
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
msgstr ""
-msgid "Mecklenburg-Vorpommern"
+#. Android resource: @strings/address_search_title
+msgid "Address search"
msgstr ""
-msgid "Niedersachsen"
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
msgstr ""
-msgid "Nordrhein-westfalen"
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
msgstr ""
-msgid "Rheinland-Pfalz"
+#. Android resource: @strings/address_search_button
+msgid "Search"
msgstr ""
-msgid "Saarland"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
msgstr ""
-msgid "Sachsen-Anhalt"
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
msgstr ""
-msgid "Sachsen"
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
msgstr ""
-msgid "Schleswig-Holstein"
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
msgstr ""
-msgid "Thueringen"
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
msgstr ""
-msgid "Mallorca"
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
msgstr ""
-msgid "Galicia"
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
msgstr ""
-msgid "Scandinavia"
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
msgstr ""
-msgid "England"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
msgstr ""
-msgid "Buckinghamshire"
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
msgstr ""
-msgid "Cambridgeshire"
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
msgstr ""
-msgid "Cumbria"
+#. Android resource: @strings/restoring
+msgid "Restoring..."
msgstr ""
-msgid "East yorkshire with hull"
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
msgstr ""
-msgid "Essex"
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
msgstr ""
-msgid "Herefordshire"
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
msgstr ""
-msgid "Kent"
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
msgstr ""
-msgid "Lancashire"
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
msgstr ""
-msgid "Leicestershire"
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
-msgid "Norfolk"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
msgstr ""
-msgid "Nottinghamshire"
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
msgstr ""
-msgid "Oxfordshire"
+#. Android resource: @strings/select_backup
+msgid "Select backup"
msgstr ""
-msgid "Shropshire"
+#. Android resource: @strings/backup
+msgid "Backup"
msgstr ""
-msgid "Somerset"
+#. Android resource: @strings/restore
+msgid "Restore"
msgstr ""
-msgid "South yorkshire"
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
msgstr ""
-msgid "Suffolk"
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
-msgid "Surrey"
+#. Android resource: @strings/permissions_not_granted
+msgid ""
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
-msgid "Wiltshire"
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
msgstr ""
-msgid "Scotland"
+#. Android resource: @strings/whole_planet
+msgid "Whole Planet"
msgstr ""
-msgid "Wales"
+#. Android resource: @strings/africa
+msgid "Africa"
msgstr ""
-msgid "Crete"
+#. Android resource: @strings/canary_islands
+msgid "Canary Islands"
msgstr ""
-msgid "North America"
+#. Android resource: @strings/asia
+msgid "Asia"
msgstr ""
-msgid "Alaska"
+#. Android resource: @strings/taiwan
+msgid "Taiwan"
msgstr ""
-msgid "Hawaii"
+#. Android resource: @strings/korea
+msgid "Korea"
msgstr ""
-msgid "USA"
+#. Android resource: @strings/uae_other
+msgid "UAE+Other"
msgstr ""
-msgid " (except Alaska and Hawaii)"
+#. Android resource: @strings/oceania
+msgid "Oceania"
msgstr ""
-msgid "Midwest"
+#. Android resource: @strings/tasmania
+msgid "Tasmania"
msgstr ""
-msgid "Michigan"
+#. Android resource: @strings/victoria
+msgid "Victoria"
msgstr ""
-msgid "Ohio"
+#. Android resource: @strings/new_south_wales
+msgid "New South Wales"
msgstr ""
-msgid "Northeast"
+#. Android resource: @strings/europe
+msgid "Europe"
msgstr ""
-msgid "Massachusetts"
+#. Android resource: @strings/western_europe
+msgid "Western Europe"
msgstr ""
-msgid "Vermont"
+#. Android resource: @strings/azores
+msgid "Azores"
msgstr ""
-msgid "Pacific"
+#. Android resource: @strings/benelux
+msgid "BeNeLux"
msgstr ""
-msgid "South"
+#. Android resource: @strings/alsace
+msgid "Alsace"
msgstr ""
-msgid "Arkansas"
+#. Android resource: @strings/aquitaine
+msgid "Aquitaine"
msgstr ""
-msgid "District of Columbia"
+#. Android resource: @strings/auvergne
+msgid "Auvergne"
msgstr ""
-msgid "Florida"
+#. Android resource: @strings/centre
+msgid "Centre"
msgstr ""
-msgid "Louisiana"
+#. Android resource: @strings/bretagne
+msgid "Bretagne"
msgstr ""
-msgid "Maryland"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
msgstr ""
-msgid "Mississippi"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
msgstr ""
-msgid "Oklahoma"
+#. Android resource: @strings/champagne_ardenne
+msgid "Champagne-Ardenne"
msgstr ""
-msgid "Texas"
+#. Android resource: @strings/corse
+msgid "Corse"
msgstr ""
-msgid "Virginia"
+#. Android resource: @strings/franche_comte
+msgid "Franche-Comte"
msgstr ""
-msgid "West Virginia"
+#. Android resource: @strings/haute_normandie
+msgid "Haute-Normandie"
msgstr ""
-msgid "West"
+#. Android resource: @strings/ile_de_france
+msgid "Ile-de-France"
msgstr ""
-msgid "Arizona"
+#. Android resource: @strings/languedoc_roussillon
+msgid "Languedoc-Roussillon"
msgstr ""
-msgid "California"
+#. Android resource: @strings/limousin
+msgid "Limousin"
msgstr ""
-msgid "Colorado"
+#. Android resource: @strings/lorraine
+msgid "Lorraine"
msgstr ""
-msgid "Idaho"
+#. Android resource: @strings/midi_pyrenees
+msgid "Midi-Pyrenees"
msgstr ""
-msgid "Montana"
+#. Android resource: @strings/nord_pas_de_calais
+msgid "Nord-pas-de-Calais"
msgstr ""
-msgid "New Mexico"
+#. Android resource: @strings/pays_de_la_loire
+msgid "Pays-de-la-Loire"
msgstr ""
-msgid "Nevada"
+#. Android resource: @strings/picardie
+msgid "Picardie"
msgstr ""
-msgid "Oregon"
+#. Android resource: @strings/poitou_charentes
+msgid "Poitou-Charentes"
msgstr ""
-msgid "Utah"
+#. Android resource: @strings/provence_alpes_cote_d_azur
+msgid "Provence-Alpes-Cote-d-Azur"
msgstr ""
-msgid "Washington State"
+#. Android resource: @strings/rhone_alpes
+msgid "Rhone-Alpes"
msgstr ""
-msgid "South+Middle America"
+#. Android resource: @strings/baden_wuerttemberg
+msgid "Baden-Wuerttemberg"
msgstr ""
-msgid "Guyane Francaise"
+#. Android resource: @strings/bayern
+msgid "Bayern"
msgstr ""
-msgid "downloading"
+#. Android resource: @strings/mittelfranken
+msgid "Mittelfranken"
msgstr ""
-#. Android resource: @strings/map_download_ready
-msgid "ready"
+#. Android resource: @strings/niederbayern
+msgid "Niederbayern"
msgstr ""
-msgid "Media selected for map storage is not available"
+#. Android resource: @strings/oberbayern
+msgid "Oberbayern"
msgstr ""
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
+#. Android resource: @strings/oberfranken
+msgid "Oberfranken"
msgstr ""
-msgid "Error downloading map!"
+#. Android resource: @strings/oberpfalz
+msgid "Oberpfalz"
msgstr ""
-msgid "Error writing map!"
+#. Android resource: @strings/schwaben
+msgid "Schwaben"
msgstr ""
-msgid "Map download aborted!"
+#. Android resource: @strings/unterfranken
+msgid "Unterfranken"
msgstr ""
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
+#. Android resource: @strings/berlin
+msgid "Berlin"
msgstr ""
-#. Android resource: @strings/map_download_title
-msgid "Map download"
+#. Android resource: @strings/brandenburg
+msgid "Brandenburg"
msgstr ""
-msgid "Vehicle Position"
+#. Android resource: @strings/bremen
+msgid "Bremen"
msgstr ""
-msgid "Main menu"
+#. Android resource: @strings/hamburg
+msgid "Hamburg"
msgstr ""
-msgid ""
-"Show\n"
-"Map"
+#. Android resource: @strings/hessen
+msgid "Hessen"
msgstr ""
-msgid "Settings"
+#. Android resource: @strings/mecklenburg_vorpommern
+msgid "Mecklenburg-Vorpommern"
msgstr ""
-msgid "Tools"
+#. Android resource: @strings/niedersachsen
+msgid "Niedersachsen"
msgstr ""
-msgid "Route"
+#. Android resource: @strings/nordrhein_westfalen
+msgid "Nordrhein-westfalen"
msgstr ""
-msgid "About"
+#. Android resource: @strings/rheinland_pfalz
+msgid "Rheinland-Pfalz"
msgstr ""
-msgid "Quit"
+#. Android resource: @strings/saarland
+msgid "Saarland"
msgstr ""
-msgid "Actions"
+#. Android resource: @strings/sachsen_anhalt
+msgid "Sachsen-Anhalt"
msgstr ""
-msgid ""
-"Former\n"
-"Destinations"
+#. Android resource: @strings/sachsen
+msgid "Sachsen"
msgstr ""
-msgid "Coordinates"
+#. Android resource: @strings/schleswig_holstein
+msgid "Schleswig-Holstein"
msgstr ""
-msgid ""
-"Stop\n"
-"Navigation"
+#. Android resource: @strings/thueringen
+msgid "Thueringen"
msgstr ""
-msgid "Display"
+#. Android resource: @strings/mallorca
+msgid "Mallorca"
msgstr ""
-msgid "Fullscreen"
+#. Android resource: @strings/galicia
+msgid "Galicia"
msgstr ""
-msgid "Window Mode"
+#. Android resource: @strings/scandinavia
+msgid "Scandinavia"
msgstr ""
-msgid "Layers"
+#. Android resource: @strings/england
+msgid "England"
msgstr ""
-msgid "Description"
+#. Android resource: @strings/buckinghamshire
+msgid "Buckinghamshire"
msgstr ""
-msgid ""
-"Drop last \n"
-"Waypoint"
+#. Android resource: @strings/cambridgeshire
+msgid "Cambridgeshire"
msgstr ""
-msgid ""
-"Drop next \n"
-"Waypoint"
+#. Android resource: @strings/cumbria
+msgid "Cumbria"
msgstr ""
-msgid "Satellite Status"
+#. Android resource: @strings/east_yorkshire_with_hull
+msgid "East yorkshire with hull"
msgstr ""
-msgid "NMEA Data"
+#. Android resource: @strings/essex
+msgid "Essex"
msgstr ""
-msgid "car_shortest"
+#. Android resource: @strings/herefordshire
+msgid "Herefordshire"
msgstr ""
-msgid "car_avoid_tolls"
+#. Android resource: @strings/kent
+msgid "Kent"
msgstr ""
-msgid "car_pedantic"
+#. Android resource: @strings/lancashire
+msgid "Lancashire"
msgstr ""
-msgid "horse"
+#. Android resource: @strings/leicestershire
+msgid "Leicestershire"
msgstr ""
-msgid "Truck"
+#. Android resource: @strings/norfolk
+msgid "Norfolk"
msgstr ""
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
+#. Android resource: @strings/nottinghamshire
+msgid "Nottinghamshire"
msgstr ""
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
+#. Android resource: @strings/oxfordshire
+msgid "Oxfordshire"
msgstr ""
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
+#. Android resource: @strings/shropshire
+msgid "Shropshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
+#. Android resource: @strings/somerset
+msgid "Somerset"
msgstr ""
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
+#. Android resource: @strings/south_yorkshire
+msgid "South yorkshire"
msgstr ""
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
+#. Android resource: @strings/suffolk
+msgid "Suffolk"
msgstr ""
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
+#. Android resource: @strings/surrey
+msgid "Surrey"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
+#. Android resource: @strings/wiltshire
+msgid "Wiltshire"
msgstr ""
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
+#. Android resource: @strings/scotland
+msgid "Scotland"
msgstr ""
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
+#. Android resource: @strings/wales
+msgid "Wales"
msgstr ""
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
+#. Android resource: @strings/crete
+msgid "Crete"
msgstr ""
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
+#. Android resource: @strings/north_america
+msgid "North America"
msgstr ""
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
+#. Android resource: @strings/alaska
+msgid "Alaska"
msgstr ""
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
+#. Android resource: @strings/hawaii
+msgid "Hawaii"
msgstr ""
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
+#. Android resource: @strings/usa
+msgid "USA"
msgstr ""
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
msgstr ""
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
+#. Android resource: @strings/midwest
+msgid "Midwest"
msgstr ""
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
+#. Android resource: @strings/michigan
+msgid "Michigan"
msgstr ""
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
+#. Android resource: @strings/ohio
+msgid "Ohio"
msgstr ""
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
+#. Android resource: @strings/northeast
+msgid "Northeast"
msgstr ""
-#. Android resource: @strings/address_search_title
-msgid "Address search"
+#. Android resource: @strings/massachusetts
+msgid "Massachusetts"
msgstr ""
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
+#. Android resource: @strings/vermont
+msgid "Vermont"
msgstr ""
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
+#. Android resource: @strings/pacific
+msgid "Pacific"
msgstr ""
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
+#. Android resource: @strings/south
+msgid "South"
msgstr ""
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
+#. Android resource: @strings/arkansas
+msgid "Arkansas"
msgstr ""
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
+#. Android resource: @strings/district_of_columbia
+msgid "District of Columbia"
msgstr ""
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
+#. Android resource: @strings/florida
+msgid "Florida"
msgstr ""
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
+#. Android resource: @strings/louisiana
+msgid "Louisiana"
msgstr ""
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
+#. Android resource: @strings/maryland
+msgid "Maryland"
msgstr ""
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
+#. Android resource: @strings/mississippi
+msgid "Mississippi"
msgstr ""
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
+#. Android resource: @strings/oklahoma
+msgid "Oklahoma"
msgstr ""
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
+#. Android resource: @strings/texas
+msgid "Texas"
msgstr ""
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
+#. Android resource: @strings/virginia
+msgid "Virginia"
msgstr ""
-#. Android resource: @strings/restoring
-msgid "Restoring..."
+#. Android resource: @strings/west_virginia
+msgid "West Virginia"
msgstr ""
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
+#. Android resource: @strings/west
+msgid "West"
msgstr ""
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
+#. Android resource: @strings/arizona
+msgid "Arizona"
msgstr ""
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
+#. Android resource: @strings/california
+msgid "California"
msgstr ""
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
+#. Android resource: @strings/colorado
+msgid "Colorado"
msgstr ""
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
+#. Android resource: @strings/idaho
+msgid "Idaho"
msgstr ""
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
+#. Android resource: @strings/montana
+msgid "Montana"
msgstr ""
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
+#. Android resource: @strings/new_mexico
+msgid "New Mexico"
msgstr ""
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
+#. Android resource: @strings/nevada
+msgid "Nevada"
msgstr ""
-#. Android resource: @strings/select_backup
-msgid "Select backup"
+#. Android resource: @strings/oregon
+msgid "Oregon"
msgstr ""
-#. Android resource: @strings/backup
-msgid "Backup"
+#. Android resource: @strings/utah
+msgid "Utah"
msgstr ""
-#. Android resource: @strings/restore
-msgid "Restore"
+#. Android resource: @strings/washington_state
+msgid "Washington State"
msgstr ""
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
+#. Android resource: @strings/south_middle_america
+msgid "South+Middle America"
msgstr ""
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
+#. Android resource: @strings/guyane_francaise
+msgid "Guyane Francaise"
msgstr ""
#, c-format
diff --git a/po/fo.po.in b/po/fo.po.in
index f713a82aa..24c638b61 100644
--- a/po/fo.po.in
+++ b/po/fo.po.in
@@ -352,7 +352,7 @@ msgstr "Vend um %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1665,7 +1665,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1924,10 +1924,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/fr.po.in b/po/fr.po.in
index 17c40e85c..380470f6c 100644
--- a/po/fr.po.in
+++ b/po/fr.po.in
@@ -1,5 +1,5 @@
# French (fr) translations for navit
-# Copyright (C) 2006-2017 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Arnaud https://launchpad.net/~arnaud-lemeur
@@ -21,6 +21,7 @@
# alfred002 https://launchpad.net/~alfred002
# boism https://launchpad.net/~boism
# cyp https://launchpad.net/~cyprien-d
+# lains https://launchpad.net/~lains-lp
# mercier133 https://launchpad.net/~mercierdamien
# metehyi https://launchpad.net/~metehyi
# pierre https://launchpad.net/~pmghost4
@@ -30,10 +31,10 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2017-10-08 23:54+0000\n"
-"Last-Translator: KaZeR <Unknown>\n"
+"PO-Revision-Date: 2018-10-13 16:09+0000\n"
+"Last-Translator: lains <Unknown>\n"
"Language-Team: KaZeR <kazer@altern.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -174,7 +175,6 @@ msgstr "%1$svers la %2$s"
msgid "%1$sonto %2$s|neuter form"
msgstr "%1$svers l'%2$s"
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr "et prendre la bretelle"
@@ -243,22 +243,22 @@ msgstr "puis"
#. TRANSLATORS: the arg. is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included.
#, c-format
msgid "then merge%1$s|right"
-msgstr "Puis prendre à droite %1$s"
+msgstr "puis s'insérer à droite %1$s"
#. TRANSLATORS: the first arg. is distance, the second is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included.
#, c-format
msgid "Merge %1$s%2$s|right"
-msgstr "%1$s prendre à droite %2$s"
+msgstr "%1$s s'insérer à droite %2$s"
#. TRANSLATORS: the arg. is the phrase 'onto ...'. Left merge, the stuff after | doesn't have to be included.
#, c-format
msgid "then merge%1$s|left"
-msgstr "Puis prendre à gauche %1$s"
+msgstr "Puis s'insérer à gauche %1$s"
#. TRANSLATORS: the first arg. is distance, the second is the phrase 'onto ...'. Left merge, the stuff after | doesn't have to be included.
#, c-format
msgid "Merge %1$s%2$s|left"
-msgstr "%1$s prendre à gauche %2$s"
+msgstr "%1$s s'insérer à gauche %2$s"
msgid "on your left"
msgstr "sur votre gauche"
@@ -378,7 +378,7 @@ msgstr "Faites demi-tour %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "suivre"
@@ -390,7 +390,6 @@ msgstr "puis vous arriverez à destination"
msgid "You have reached your destination %s"
msgstr "Vous êtes arrivé à destination %s"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr "Echangeur"
@@ -407,9 +406,15 @@ msgstr "Commande"
msgid "Length"
msgstr "Distance"
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr "pieds"
+
msgid "m"
msgstr "m"
@@ -470,6 +475,7 @@ msgid "Anguilla"
msgstr "Anguille"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Albanie"
@@ -482,6 +488,7 @@ msgid "Netherlands Antilles"
msgstr "Antilles néerlandaises"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Angola"
@@ -490,6 +497,7 @@ msgid "Antarctica"
msgstr "Antarctique"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Argentine"
@@ -498,10 +506,12 @@ msgid "American Samoa"
msgstr "Samoa américaines"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Autriche"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Australie"
@@ -514,10 +524,12 @@ msgid "Aland Islands"
msgstr "Åland, îles"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Azerbaïdjan"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Bosnie Herzégovine"
@@ -530,6 +542,7 @@ msgid "Bangladesh"
msgstr "Bengladesh"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "Belgique"
@@ -538,6 +551,7 @@ msgid "Burkina Faso"
msgstr "Burkina Faso"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Bulgarie"
@@ -546,6 +560,7 @@ msgid "Bahrain"
msgstr "Bahreïn"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Burundi"
@@ -566,6 +581,7 @@ msgid "Brunei Darussalam"
msgstr "Brunei Darussalam"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Bolivie"
@@ -574,6 +590,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr "Bonaire, Saint-Eustache et Saba"
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Brésil"
@@ -590,10 +607,12 @@ msgid "Bouvet Island"
msgstr "Îles Bouvet"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Botswana"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Biélorussie"
@@ -602,6 +621,7 @@ msgid "Belize"
msgstr "Belize"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Canada"
@@ -610,6 +630,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Îles Cocos"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Répulique démocratique du Congo"
@@ -622,10 +643,12 @@ msgid "Congo"
msgstr "Congo"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Suisse"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Côte d'Ivoire"
@@ -634,6 +657,7 @@ msgid "Cook Islands"
msgstr "Îles Cook"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Chili"
@@ -642,10 +666,12 @@ msgid "Cameroon"
msgstr "Cameroun"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "Chine"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Colombie"
@@ -654,6 +680,7 @@ msgid "Costa Rica"
msgstr "Costa Rica"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Cuba"
@@ -670,14 +697,17 @@ msgid "Christmas Island"
msgstr "Île Christmas"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Chypre"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "République Tchèque"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Allemagne"
@@ -686,6 +716,7 @@ msgid "Djibouti"
msgstr "Djibouti"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Danemark"
@@ -694,6 +725,7 @@ msgid "Dominica"
msgstr "Dominique"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "République Dominicaine"
@@ -702,10 +734,12 @@ msgid "Algeria"
msgstr "Algérie"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Équateur"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Estonie"
@@ -722,14 +756,17 @@ msgid "Eritrea"
msgstr "Erythrée"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Espagne"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Ethiopie"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Finlande"
@@ -746,10 +783,12 @@ msgid "Micronesia, Federated States of"
msgstr "Micronésie, États fédérés de"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Îles Féroé"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "France"
@@ -758,6 +797,7 @@ msgid "Gabon"
msgstr "Gabon"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Royaume-Uni"
@@ -794,6 +834,7 @@ msgid "Gambia"
msgstr "Gambie"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Guinée"
@@ -806,6 +847,7 @@ msgid "Equatorial Guinea"
msgstr "Guinée équatoriale"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Grèce"
@@ -826,6 +868,7 @@ msgid "Guinea-Bissau"
msgstr "Guinée-Bissau"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Guyane"
@@ -842,26 +885,32 @@ msgid "Honduras"
msgstr "Honduras"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Croatie"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Haïti"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Hongrie"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Indonésie"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Irlande"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Israël"
@@ -870,6 +919,7 @@ msgid "Isle of Man"
msgstr "Ile de Man"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "Inde"
@@ -878,18 +928,22 @@ msgid "British Indian Ocean Territory"
msgstr "Territoire britannique de l'océan Indien"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Irak"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Iran, République islamique d'"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Islande"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Italie"
@@ -898,6 +952,7 @@ msgid "Jersey"
msgstr "Jersey"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Jamaïque"
@@ -906,14 +961,17 @@ msgid "Jordan"
msgstr "Jordanie"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Japon"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Kenya"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Kirghizstan"
@@ -950,6 +1008,7 @@ msgid "Cayman Islands"
msgstr "Îles Cayman"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Kazakhstan"
@@ -974,26 +1033,32 @@ msgid "Sri Lanka"
msgstr "Sri Lanka"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Libéria"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Lesotho"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Lithuanie"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Luxembourg"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Lettonie"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr "Libye"
@@ -1018,6 +1083,7 @@ msgid "Saint Martin (French part)"
msgstr "Saint Martin"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Madagascar"
@@ -1038,6 +1104,7 @@ msgid "Myanmar"
msgstr "Myanmar"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Mongolie"
@@ -1078,10 +1145,12 @@ msgid "Malawi"
msgstr "Malawi"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "Mexique"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Malaisie"
@@ -1090,10 +1159,12 @@ msgid "Mozambique"
msgstr "Mozambique"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Namibie"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Nouvelle Calédonie"
@@ -1114,6 +1185,7 @@ msgid "Nicaragua"
msgstr "Nicaragua"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Pays-Bas"
@@ -1122,6 +1194,7 @@ msgid "Norway"
msgstr "Norvège"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Népal"
@@ -1134,6 +1207,7 @@ msgid "Niue"
msgstr "Niue"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Nouvelle-Zélande"
@@ -1146,6 +1220,7 @@ msgid "Panama"
msgstr "Panama"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Pérou"
@@ -1158,14 +1233,17 @@ msgid "Papua New Guinea"
msgstr "Papouasie-Nouvelle-Guinée"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Philippines"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Pakistan"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Pologne"
@@ -1186,6 +1264,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Territoire palestinien, occupé"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Portugal"
@@ -1194,6 +1273,7 @@ msgid "Palau"
msgstr "Palau"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Paraguay"
@@ -1202,10 +1282,12 @@ msgid "Qatar"
msgstr "Qatar"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Réunion"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Roumanie"
@@ -1214,14 +1296,17 @@ msgid "Serbia"
msgstr "Serbie"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Russie"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Rwanda"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Arabie Saoudite"
@@ -1242,6 +1327,7 @@ msgid "Sweden"
msgstr "Suède"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Singapour"
@@ -1258,6 +1344,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Svalbard et Jan Mayen"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Slovaquie"
@@ -1278,6 +1365,7 @@ msgid "Somalia"
msgstr "Somalie"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Surinam"
@@ -1322,6 +1410,7 @@ msgid "Togo"
msgstr "Togo"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Thailande"
@@ -1338,6 +1427,7 @@ msgid "Timor-Leste"
msgstr "Timor-Leste"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Turkmenistan"
@@ -1350,6 +1440,7 @@ msgid "Tonga"
msgstr "Tonga"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Turquie"
@@ -1366,14 +1457,17 @@ msgid "Taiwan, Province of China"
msgstr "Taïwan, province de Chine"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Tanzanie, République unie de"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Ukraine"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Uganda"
@@ -1386,6 +1480,7 @@ msgid "United States"
msgstr "États-Unis"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Uruguay"
@@ -1402,6 +1497,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "Saint-Vincent-et-les Grenadines"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Venezuela"
@@ -1438,6 +1534,7 @@ msgid "Mayotte"
msgstr "Mayotte"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "Afrique du Sud"
@@ -1475,26 +1572,26 @@ msgstr ""
"\t-v: affiche la version et quitte.\n"
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
-msgstr "Pas de fichier de configuration navit.xml, navit.xml.local trouvé\n"
+msgid "No config file navit.xml, navit.xml.local found"
+msgstr "Aucun fichier de configuration (navit.xml, navit.xml.local) trouvé"
#, c-format
-msgid "Error parsing config file '%s': %s\n"
-msgstr "erreur d'analyse du fichier de configuration '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
+msgstr "Erreur d'analyse du fichier de configuration '%s': %s"
#, c-format
-msgid "Using config file '%s'\n"
-msgstr "utilisation du fichier '%s'\n"
+msgid "Using config file '%s'"
+msgstr "Utilisation du fichier de configuration '%s'"
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
-msgstr "Erreur: Configuration non trouvée dans le fichier '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
+msgstr "Erreur: Aucune configuration trouvée dans le fichier '%s'"
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
-"initialisation interne échouée, arrêt de l'exécution. Vérifiez les messages "
-"d'erreurs précédents.\n"
+"\"Echec de l'initialisation interne , arrêt de l'exécution. Consulter les "
+"messages d'erreur précédents."
msgid "unknown street"
msgstr "rue inconnue"
@@ -1634,6 +1731,9 @@ msgstr "Montrer la position _curseur"
msgid "_Lock on Road"
msgstr "Coller à la route"
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr "Garder l'orientation au Nord"
@@ -1703,24 +1803,29 @@ msgstr "Taxi"
msgid "Shopping"
msgstr "Achats"
-msgid "Distance from screen center (km)"
-msgstr "Distance du centre de l'écran (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr "Choisir un rayon de recherche autour du centre de l'écran (en km)"
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
+msgstr "Choisir un rayon de recherche autour du centre de l'écran (en miles)"
#, c-format
msgid "POI %s. %s"
msgstr "Point d'intérêt %s. %s"
#, c-format
-msgid "Set destination to %ld, %ld \n"
-msgstr "Définir la destination vers %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
+msgstr "Définir la destination vers %ld,%ld "
#, c-format
-msgid "Set map to %ld, %ld \n"
-msgstr "sélectionner la carte de %ld, %ld \n"
+msgid "Set map to %ld, %ld "
+msgstr "Centrer la carte sur %ld, %ld \\n "
#, c-format
-msgid "Set next visit to %ld, %ld \n"
-msgstr "Définir la prochaine visite à %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
+msgstr "Définir la prochaine étape à %ld, %ld\\n "
msgid "POI search"
msgstr "recherche de point d'intérêt"
@@ -1728,9 +1833,6 @@ msgstr "recherche de point d'intérêt"
msgid "Select a category"
msgstr "Sélectionnez une catégorie"
-msgid "Select a distance to look for (km)"
-msgstr "Sélectionnez une distance à chercher (km)"
-
msgid "Select a POI"
msgstr "Sélectionnez un point d'intérêt"
@@ -1743,8 +1845,8 @@ msgstr "Catégorie"
msgid "Direction"
msgstr "Direction"
-msgid "Distance(m)"
-msgstr "Distance (m)"
+msgid "Distance"
+msgstr "Distance"
msgid "Name"
msgstr "Nom"
@@ -1790,8 +1892,8 @@ msgid "OT"
msgstr "Autre"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Trajet restant %4.0f km heure d'arrivée estimée %02d:%02d"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "Trajet 0000 km temps estimé 0+00:00"
@@ -1880,14 +1982,14 @@ msgstr "Insérer le signet"
#, c-format
msgid "Bookmark %s"
-msgstr "Ajouter %s aux favoris"
+msgstr "Favoris %s"
#, c-format
msgid "Download %s"
msgstr "Télécharger %s"
msgid "Map Download"
-msgstr "Télécharger la carte"
+msgstr "Téléchargement de carte"
msgid "Active"
msgstr "Actif"
@@ -1896,7 +1998,7 @@ msgid "Download Enabled"
msgstr "Téléchargement activé"
msgid "Download completely"
-msgstr "Télécharger completement"
+msgstr "Télécharger complètement"
msgid "Show Satellite Status"
msgstr "Afficher les infos satellite"
@@ -1962,10 +2064,10 @@ msgstr "Étapes"
msgid "Enter Coordinates"
msgstr "Saisissez les coordonnées"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -2015,7 +2117,7 @@ msgid "Show Locale"
msgstr "Afficher la locale"
msgid "Network info"
-msgstr ""
+msgstr "Informations réseau"
msgid "Former Destinations"
msgstr "Destinations précédentes"
@@ -2055,32 +2157,224 @@ msgstr "Attention ! Contrôle radar !"
msgid "Please decrease your speed"
msgstr "Veuillez ralentir"
-msgid "partial match"
-msgstr "correspondance partielle"
+msgid "Vehicle Position"
+msgstr "Position du véhicule"
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr "Chercher"
+msgid "Main menu"
+msgstr "Menu principal"
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
-msgstr "Villes"
+msgid ""
+"Show\n"
+"Map"
+msgstr ""
+"Afficher\n"
+"la carte"
+
+msgid "Settings"
+msgstr "Configuration"
+
+msgid "Tools"
+msgstr "Outils"
+
+msgid "Route"
+msgstr "Itinéraire"
+
+msgid "About"
+msgstr "À propos"
+
+msgid "Quit"
+msgstr "Quitter"
+
+msgid "Actions"
+msgstr "Actions"
+
+msgid ""
+"Former\n"
+"Destinations"
+msgstr ""
+"Destinations\n"
+"précédentes"
+
+msgid "Coordinates"
+msgstr "Coordonnées"
+
+msgid ""
+"Stop\n"
+"Navigation"
+msgstr ""
+"Arrêter\n"
+"la navigation"
+
+msgid "Display"
+msgstr "Affichage"
+
+msgid "Fullscreen"
+msgstr "Plein écran"
+
+msgid "Window Mode"
+msgstr "Mode fenêtré"
+
+msgid "Auto zoom"
+msgstr "Zoom auto"
+
+msgid "Manual zoom"
+msgstr "Zoom manuel"
+
+msgid "Layers"
+msgstr "Couches"
+
+msgid "Zoom to route"
+msgstr "Zoomer sur le parcours"
+
+msgid "Description"
+msgstr "Description"
+
+msgid ""
+"Drop last\n"
+"Waypoint"
+msgstr "Abandonner la\\ndernière étape"
+
+msgid ""
+"Drop next\n"
+"Waypoint"
+msgstr "Abandonner la\\nprochaine étape"
+
+msgid "Satellite Status"
+msgstr "Etat des satellites"
+
+msgid "NMEA Data"
+msgstr "Données NMEA"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr "Données cartographiques (c) OpenStreetMap contributors, ODBL"
+msgid "car_shortest"
+msgstr "voiture _le plus court"
+
+msgid "car_avoid_tolls"
+msgstr "voiture _sans péage"
+
+msgid "car_pedantic"
+msgstr "voiture_detaillée"
+
+msgid "horse"
+msgstr "cheval"
+
+msgid "Truck"
+msgstr "Camion"
+
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
+msgstr "Oui"
+
+#. Android resource: @strings/cancel
+msgid "Cancel"
+msgstr "Annuler"
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
+msgstr "Navit commencé"
+
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
+msgstr "Navit exécute"
+
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
+msgstr "Bienvenue chez Navit"
+
+#. Android resource: @strings/initial_info_box_message
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
msgstr ""
-"L'emplacement de carte %s n'est pas disponible\n"
-"Veuillez redémarrer Navit après avoir branché une carte SD ou selectionné en "
-"emplacement de carte différent."
+"Nous vous remercions d'avoir installé Navit!\n"
+"\n"
+"Pour commencer, sélectionnez \"Télécharger des cartes\" du menu et "
+"télechargez une carte de votre région. Les cartes sont volumineuses, donc il "
+"est préférable d'avoir une connection internet illimitée!\n"
+"\n"
+"Cartes: (c) OpenStreetMap contributors\n"
+"\n"
+"Amusez-vous avec Navit!"
+
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
+msgstr "OK"
+
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
+msgstr "Plus d'infos"
+
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
+msgstr "Zoom-avant"
+
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
+msgstr "Zoom-arrière"
+
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
+msgstr "Télécharger des cartes"
+
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
+msgstr "Afficher/masquer POIs"
+
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
+msgstr "Quitter Navit"
+
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
+msgstr "Sauvegarde / Restauration"
+
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
+msgstr "Emplacement des cartes"
+
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
+msgstr "Conduire ici"
+
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
+msgstr "Supprimer cette carte?"
-msgid "Downloaded maps"
-msgstr "Cartes téléchargées"
+#. Android resource: @strings/map_download_title
+msgid "Map download"
+msgstr "Téléchargement de carte"
+
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
+msgstr "Télécharger:"
+
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
+msgstr "Temps restant"
+
+#. Android resource: @strings/map_download_ready
+msgid "ready"
+msgstr "prêt"
+
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
+msgstr "Erreur de téléchargement carte"
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
+msgstr "Téléchargement de la carte abandonné"
+
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
+msgstr "Pas assez d'espace libre"
+
+#. Android resource: @strings/map_download_oversize
msgid ""
"Sorry, we currently do not support maps above 3.8G on Android, please select "
"a smaller one."
@@ -2088,758 +2382,769 @@ msgstr ""
"Désolé, nous ne supportons pas les cartes de plus de 3.8GB sur Android, "
"merci de sélectionner une carte plus petite."
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr "Conduire ici"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
+msgstr "Pas de géolocalisation. Relancez après obtention d'un signal GPS"
-msgid "Cancel"
-msgstr "Annuler"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
+msgstr "Cartes couvrant la position actuelle"
+
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
+msgstr ""
+
+#. Android resource: @strings/map_downloading
+msgid "downloading"
+msgstr "transfert en cours"
+
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
+msgstr ""
+"Le support sélectionné pour le stockage de la carte n'est pas disponible"
+
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
+msgstr "Erreur d'écriture de carte !"
+
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
+msgstr ""
+
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
+msgstr ""
+
+#. Android resource: @strings/address_search_title
+msgid "Address search"
+msgstr "Cherchez adresse"
+
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
+msgstr "Entrez votre destination"
+
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
+msgstr "Correspondance partielle"
+
+#. Android resource: @strings/address_search_button
+msgid "Search"
+msgstr "Chercher"
+
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
+msgstr "Recherche..."
+
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
+msgstr "Adresse introuvable"
+
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
+msgstr "Obtenir des résultats de recherche"
+
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
+msgstr "Chargement des résultats de recherche"
+
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
+msgstr "Aucun résultat trouvé"
+
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
+msgstr "Aucun texte entré"
+
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
+msgstr "Destination fixée à:"
+
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
+msgstr "Villes"
+
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
+msgstr "Choisir une action"
+
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
+msgstr "Veuillez insérer une carte SD"
+
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
+msgstr "Sauvegarde..."
+
+#. Android resource: @strings/restoring
+msgid "Restoring..."
+msgstr "Restauration..."
+
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
+msgstr "Impossible de créer le dossier de sauvegarde"
+
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
+msgstr "Échec de la sauvegarde"
+
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
+msgstr "Pas de sauvegarde trouvée"
+
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
+msgstr "Échec de la restauration"
+
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
+msgstr "Sauvegarde terminée avec succès"
+
+#. Android resource: @strings/restore_successful_please_restart_navit
+msgid ""
+"Restore Successful\n"
+"Please restart Navit"
+msgstr ""
+"Restauration réussie\n"
+"Veuillez redémarrer Navit"
+
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
+msgstr "Sauvegarde introuvable"
+
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
+msgstr "Échec de la restauration"
+
+#. Android resource: @strings/select_backup
+msgid "Select backup"
+msgstr "Sélectionner la sauvegarde"
-msgid "filenamePath"
-msgstr "emplacementFichier"
+#. Android resource: @strings/backup
+msgid "Backup"
+msgstr "Sauvegarder"
+#. Android resource: @strings/restore
+msgid "Restore"
+msgstr "Restaurer"
+
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
+msgstr "Les données du moteur de parole système sont manquantes"
+
+#. Android resource: @strings/TTS_qery_install_data
msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
-msgstr "redémarrer Navit pour appliquer les modifications"
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
+msgstr ""
+"Navit peut utiliser n'importe quel système de parole disponible sur votre "
+"appareil. Le système actuellement sélectionné indique qu'il ne peut pas "
+"parler dans votre langue. Devons nous demander au système d'afficher le menu "
+"de téléchargement des voix?"
+#. Android resource: @strings/permissions_not_granted
+msgid ""
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
+msgstr ""
+"Navit doit être autorisé à accéder au GPS et à lire la carte.\n"
+"Si vous changez d'avis, redémarrez Navit et accordez les autorisations"
+
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
+msgstr "Une ou plusieurs autorisations manquantes"
+
+#. Android resource: @strings/whole_planet
msgid "Whole Planet"
msgstr "Terre entière"
+#. Android resource: @strings/africa
msgid "Africa"
msgstr "Afrique"
+#. Android resource: @strings/canary_islands
msgid "Canary Islands"
msgstr "Îles Canaries"
+#. Android resource: @strings/asia
msgid "Asia"
msgstr "Asie"
-msgid "Korea"
-msgstr "Corée"
-
+#. Android resource: @strings/taiwan
msgid "Taiwan"
msgstr "Taïwan"
+#. Android resource: @strings/korea
+msgid "Korea"
+msgstr "Corée"
+
+#. Android resource: @strings/uae_other
msgid "UAE+Other"
msgstr "EAU+Autres"
+#. Android resource: @strings/oceania
msgid "Oceania"
msgstr "Océanie"
+#. Android resource: @strings/tasmania
msgid "Tasmania"
msgstr "Tasmanie"
+#. Android resource: @strings/victoria
msgid "Victoria"
msgstr "Victoria"
+#. Android resource: @strings/new_south_wales
msgid "New South Wales"
msgstr "Nouvelle-Galles du Sud"
+#. Android resource: @strings/europe
msgid "Europe"
msgstr "Europe"
+#. Android resource: @strings/western_europe
msgid "Western Europe"
msgstr "Europe de l'Ouest"
+#. Android resource: @strings/azores
msgid "Azores"
msgstr "Açores"
+#. Android resource: @strings/benelux
msgid "BeNeLux"
msgstr "BeNeLux"
+#. Android resource: @strings/alsace
msgid "Alsace"
msgstr "Alsace"
+#. Android resource: @strings/aquitaine
msgid "Aquitaine"
msgstr "Aquitaine"
+#. Android resource: @strings/auvergne
msgid "Auvergne"
msgstr "Auvergne"
-msgid "Basse-Normandie"
-msgstr "Basse-Normandie"
-
-msgid "Bourgogne"
-msgstr "Bourgogne"
+#. Android resource: @strings/centre
+msgid "Centre"
+msgstr "Centre"
+#. Android resource: @strings/bretagne
msgid "Bretagne"
msgstr "Bretagne"
-msgid "Centre"
-msgstr "Centre"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
+msgstr "Bourgogne"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
+msgstr "Basse-Normandie"
+
+#. Android resource: @strings/champagne_ardenne
msgid "Champagne-Ardenne"
msgstr "Champagne-Ardenne"
+#. Android resource: @strings/corse
msgid "Corse"
msgstr "Corse"
+#. Android resource: @strings/franche_comte
msgid "Franche-Comte"
msgstr "Franche-Comté"
+#. Android resource: @strings/haute_normandie
msgid "Haute-Normandie"
msgstr "Haute-Normandie"
+#. Android resource: @strings/ile_de_france
msgid "Ile-de-France"
msgstr "Île-de-France"
+#. Android resource: @strings/languedoc_roussillon
msgid "Languedoc-Roussillon"
msgstr "Languedoc-Roussillon"
+#. Android resource: @strings/limousin
msgid "Limousin"
msgstr "Limousin"
+#. Android resource: @strings/lorraine
msgid "Lorraine"
msgstr "Lorraine"
+#. Android resource: @strings/midi_pyrenees
msgid "Midi-Pyrenees"
msgstr "Midi-Pyrénées"
+#. Android resource: @strings/nord_pas_de_calais
msgid "Nord-pas-de-Calais"
msgstr "Nord-Pas-de-Calais"
+#. Android resource: @strings/pays_de_la_loire
msgid "Pays-de-la-Loire"
msgstr "Pays-de-la-Loire"
+#. Android resource: @strings/picardie
msgid "Picardie"
msgstr "Picardie"
+#. Android resource: @strings/poitou_charentes
msgid "Poitou-Charentes"
msgstr "Poitou-Charentes"
+#. Android resource: @strings/provence_alpes_cote_d_azur
msgid "Provence-Alpes-Cote-d-Azur"
msgstr "Provence-Alpes-Côte d'Azur"
+#. Android resource: @strings/rhone_alpes
msgid "Rhone-Alpes"
msgstr "Rhône-Alpes"
+#. Android resource: @strings/baden_wuerttemberg
msgid "Baden-Wuerttemberg"
msgstr "Bade-Wurtemberg"
+#. Android resource: @strings/bayern
msgid "Bayern"
msgstr "Bavière"
+#. Android resource: @strings/mittelfranken
msgid "Mittelfranken"
msgstr "Moyenne-Franconie"
+#. Android resource: @strings/niederbayern
msgid "Niederbayern"
msgstr "Basse-Bavière"
+#. Android resource: @strings/oberbayern
msgid "Oberbayern"
msgstr "Basse-Bavière"
+#. Android resource: @strings/oberfranken
msgid "Oberfranken"
msgstr "Haute-Franconie"
+#. Android resource: @strings/oberpfalz
msgid "Oberpfalz"
msgstr "Haut-Palatinat"
+#. Android resource: @strings/schwaben
msgid "Schwaben"
msgstr "Souabe"
+#. Android resource: @strings/unterfranken
msgid "Unterfranken"
msgstr "Basse-Franconie"
+#. Android resource: @strings/berlin
msgid "Berlin"
msgstr "Berlin"
+#. Android resource: @strings/brandenburg
msgid "Brandenburg"
msgstr "Brandebourg"
+#. Android resource: @strings/bremen
msgid "Bremen"
msgstr "Brême"
+#. Android resource: @strings/hamburg
msgid "Hamburg"
msgstr "Hambourg"
+#. Android resource: @strings/hessen
msgid "Hessen"
msgstr "Hesse"
+#. Android resource: @strings/mecklenburg_vorpommern
msgid "Mecklenburg-Vorpommern"
msgstr "Mecklembourg-Poméranie occidentale"
+#. Android resource: @strings/niedersachsen
msgid "Niedersachsen"
msgstr "Basse-Saxe"
+#. Android resource: @strings/nordrhein_westfalen
msgid "Nordrhein-westfalen"
msgstr "Rhénanie-du-Nord - Westphalie"
+#. Android resource: @strings/rheinland_pfalz
msgid "Rheinland-Pfalz"
msgstr "Rhénanie-Palatinat"
+#. Android resource: @strings/saarland
msgid "Saarland"
msgstr "Sarre"
+#. Android resource: @strings/sachsen_anhalt
msgid "Sachsen-Anhalt"
msgstr "Saxe-Anhalt"
+#. Android resource: @strings/sachsen
msgid "Sachsen"
msgstr "Saxe"
+#. Android resource: @strings/schleswig_holstein
msgid "Schleswig-Holstein"
msgstr "Schleswig-Holstein"
+#. Android resource: @strings/thueringen
msgid "Thueringen"
msgstr "Thuringe"
+#. Android resource: @strings/mallorca
msgid "Mallorca"
msgstr "Majorque"
+#. Android resource: @strings/galicia
msgid "Galicia"
msgstr "Galice"
+#. Android resource: @strings/scandinavia
msgid "Scandinavia"
msgstr "Scandinavie"
+#. Android resource: @strings/england
msgid "England"
msgstr "Angleterre"
+#. Android resource: @strings/buckinghamshire
msgid "Buckinghamshire"
msgstr "Buckinghamshire"
+#. Android resource: @strings/cambridgeshire
msgid "Cambridgeshire"
msgstr "Cambridgeshire"
+#. Android resource: @strings/cumbria
msgid "Cumbria"
msgstr "Cumbrie"
+#. Android resource: @strings/east_yorkshire_with_hull
msgid "East yorkshire with hull"
msgstr "Hull & Yorkshire de l'Est"
+#. Android resource: @strings/essex
msgid "Essex"
msgstr "Essex"
+#. Android resource: @strings/herefordshire
msgid "Herefordshire"
msgstr "Herefordshire"
+#. Android resource: @strings/kent
msgid "Kent"
msgstr "Kent"
+#. Android resource: @strings/lancashire
msgid "Lancashire"
msgstr "Lancashire"
+#. Android resource: @strings/leicestershire
msgid "Leicestershire"
msgstr "Leicestershire"
+#. Android resource: @strings/norfolk
msgid "Norfolk"
msgstr "Norfolk"
+#. Android resource: @strings/nottinghamshire
msgid "Nottinghamshire"
msgstr "Nottinghamshire"
+#. Android resource: @strings/oxfordshire
msgid "Oxfordshire"
msgstr "Oxfordshire"
+#. Android resource: @strings/shropshire
msgid "Shropshire"
msgstr "Shropshire"
+#. Android resource: @strings/somerset
msgid "Somerset"
msgstr "Somerset"
+#. Android resource: @strings/south_yorkshire
msgid "South yorkshire"
msgstr "Yorkshire de l'Ouest"
+#. Android resource: @strings/suffolk
msgid "Suffolk"
msgstr "Suffolk"
+#. Android resource: @strings/surrey
msgid "Surrey"
msgstr "Surrey"
+#. Android resource: @strings/wiltshire
msgid "Wiltshire"
msgstr "Wiltshire"
+#. Android resource: @strings/scotland
msgid "Scotland"
msgstr "Écosse"
+#. Android resource: @strings/wales
msgid "Wales"
msgstr "Pays de Galles"
+#. Android resource: @strings/crete
msgid "Crete"
msgstr "Crète"
+#. Android resource: @strings/north_america
msgid "North America"
msgstr "Amérique du Nord"
+#. Android resource: @strings/alaska
msgid "Alaska"
msgstr "Alaska"
+#. Android resource: @strings/hawaii
msgid "Hawaii"
msgstr "Hawaï"
+#. Android resource: @strings/usa
msgid "USA"
msgstr "États-Unis"
-msgid " (except Alaska and Hawaii)"
-msgstr " (sans Alaska et Hawaï)"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
+msgstr ""
+#. Android resource: @strings/midwest
msgid "Midwest"
msgstr "Midwest"
+#. Android resource: @strings/michigan
msgid "Michigan"
msgstr "Michigan"
+#. Android resource: @strings/ohio
msgid "Ohio"
msgstr "Ohio"
+#. Android resource: @strings/northeast
msgid "Northeast"
msgstr "Nord-Est"
+#. Android resource: @strings/massachusetts
msgid "Massachusetts"
msgstr "Massachusetts"
+#. Android resource: @strings/vermont
msgid "Vermont"
msgstr "Vermont"
+#. Android resource: @strings/pacific
msgid "Pacific"
msgstr "Pacifique"
+#. Android resource: @strings/south
msgid "South"
msgstr "Sud"
+#. Android resource: @strings/arkansas
msgid "Arkansas"
msgstr "Arkansas"
+#. Android resource: @strings/district_of_columbia
msgid "District of Columbia"
msgstr "District de Columbia"
+#. Android resource: @strings/florida
msgid "Florida"
msgstr "Floride"
+#. Android resource: @strings/louisiana
msgid "Louisiana"
msgstr "Louisiane"
+#. Android resource: @strings/maryland
msgid "Maryland"
msgstr "Maryland"
+#. Android resource: @strings/mississippi
msgid "Mississippi"
msgstr "Mississippi"
+#. Android resource: @strings/oklahoma
msgid "Oklahoma"
msgstr "Oklahoma"
+#. Android resource: @strings/texas
msgid "Texas"
msgstr "Texas"
+#. Android resource: @strings/virginia
msgid "Virginia"
msgstr "Virginie"
+#. Android resource: @strings/west_virginia
msgid "West Virginia"
msgstr "Virginie-Occidentale"
+#. Android resource: @strings/west
msgid "West"
msgstr "Ouest"
+#. Android resource: @strings/arizona
msgid "Arizona"
msgstr "Arizona"
+#. Android resource: @strings/california
msgid "California"
msgstr "Californie"
+#. Android resource: @strings/colorado
msgid "Colorado"
msgstr "Colorado"
+#. Android resource: @strings/idaho
msgid "Idaho"
msgstr "Idaho"
+#. Android resource: @strings/montana
msgid "Montana"
msgstr "Montana"
+#. Android resource: @strings/new_mexico
msgid "New Mexico"
msgstr "Nouveau-Mexique"
+#. Android resource: @strings/nevada
msgid "Nevada"
msgstr "Nevada"
+#. Android resource: @strings/oregon
msgid "Oregon"
msgstr "Oregon"
+#. Android resource: @strings/utah
msgid "Utah"
msgstr "Utah"
+#. Android resource: @strings/washington_state
msgid "Washington State"
msgstr "État de Washington"
+#. Android resource: @strings/south_middle_america
msgid "South+Middle America"
msgstr "Amérique (Centrale et Sud)"
+#. Android resource: @strings/guyane_francaise
msgid "Guyane Francaise"
msgstr "Guyane Française"
-msgid "downloading"
-msgstr "transfert en cours"
-
-#. Android resource: @strings/map_download_ready
-msgid "ready"
-msgstr "prêt"
-
-msgid "Media selected for map storage is not available"
-msgstr ""
-"Le support sélectionné pour le stockage de la carte n'est pas disponible"
-
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
-msgstr "Pas assez d'espace libre"
-
-msgid "Error downloading map!"
-msgstr "Erreur de téléchargement de carte !"
-
-msgid "Error writing map!"
-msgstr "Erreur d'écriture de carte !"
-
-msgid "Map download aborted!"
-msgstr "Téléchargement de la carte abandonné!"
-
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
-msgstr "Temps restant"
-
-#. Android resource: @strings/map_download_title
-msgid "Map download"
-msgstr "Télécharger la carte"
-
-msgid "Vehicle Position"
-msgstr "Position du véhicule"
-
-msgid "Main menu"
-msgstr "Menu principal"
-
-msgid ""
-"Show\n"
-"Map"
-msgstr ""
-"Afficher\n"
-"la carte"
-
-msgid "Settings"
-msgstr "Configuration"
-
-msgid "Tools"
-msgstr "Outils"
-
-msgid "Route"
-msgstr "Itinéraire"
-
-msgid "About"
-msgstr "À propos"
-
-msgid "Quit"
-msgstr "Quitter"
-
-msgid "Actions"
-msgstr "Actions"
-
-msgid ""
-"Former\n"
-"Destinations"
-msgstr ""
-"Destinations\n"
-"précédentes"
-
-msgid "Coordinates"
-msgstr "Coordonnées"
-
-msgid ""
-"Stop\n"
-"Navigation"
-msgstr ""
-"Arrêter\n"
-"la navigation"
-
-msgid "Display"
-msgstr "Affichage"
-
-msgid "Fullscreen"
-msgstr "Plein écran"
-
-msgid "Window Mode"
-msgstr "Mode fenêtré"
-
-msgid "Auto zoom"
-msgstr ""
-
-msgid "Manual zoom"
-msgstr ""
-
-msgid "Layers"
-msgstr "Couches"
-
-msgid "Zoom to route"
-msgstr ""
-
-msgid "Description"
-msgstr "Description"
-
-msgid ""
-"Drop last \n"
-"Waypoint"
-msgstr ""
-"Sauter le dernier \n"
-"Point de passage"
-
-msgid ""
-"Drop next \n"
-"Waypoint"
-msgstr ""
-"Sauter le prochain \n"
-"point de passage"
-
-msgid "Satellite Status"
-msgstr "Etat des satellites"
-
-msgid "NMEA Data"
-msgstr "Données NMEA"
-
-msgid "car_shortest"
-msgstr "voiture _le plus court"
-
-msgid "car_avoid_tolls"
-msgstr "voiture _sans péage"
-
-msgid "car_pedantic"
-msgstr "voiture_detaillée"
-
-msgid "horse"
-msgstr "cheval"
-
-msgid "Truck"
-msgstr "Camion"
-
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
-msgstr "Oui"
-
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
-msgstr "Navit commencé"
-
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
-msgstr "Navit exécute"
-
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
-msgstr "Bienvenue chez Navit"
-
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
-msgstr ""
-"Nous vous remercions d'avoir installé Navit!\n"
-"\n"
-"Pour commencer, sélectionnez \"Télécharger des cartes\" du menu et "
-"télechargez une carte de votre région. Les cartes sont volumineuses, donc il "
-"est préférable d'avoir une connection internet illimitée!\n"
-"\n"
-"Cartes: (c) OpenStreetMap contributors\n"
-"\n"
-"Amusez-vous avec Navit!"
-
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
-msgstr "OK"
-
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
-msgstr "Plus d'infos"
-
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
-msgstr "Zoom-avant"
-
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
-msgstr "Zoom-arrière"
-
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
-msgstr "Télécharger des cartes"
-
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
-msgstr "Basculer POIs"
-
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
-msgstr "Quitter Navit"
-
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
-msgstr "Sauvegarde / Restauration"
-
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
-msgstr "sélectionner le chemin de la carte"
-
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
-msgstr "Supprimer cette carte?"
-
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
-msgstr "Télécharger:"
-
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
-msgstr "Erreur de téléchargement carte"
-
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
-msgstr "Téléchargement de la carte abandonné"
-
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
-msgstr "Pas de géolocalisation. Relancez après obtention d'un signal GPS"
-
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
-msgstr "Cartes couvrant la position actuelle"
-
-#. Android resource: @strings/address_search_title
-msgid "Address search"
-msgstr "Cherchez adresse"
-
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
-msgstr "Entrez votre destination"
-
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
-msgstr "Correspondance partielle"
-
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
-msgstr "Recherche..."
-
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
-msgstr "Adresse introuvable"
-
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
-msgstr "Obtenir des résultats de recherche"
-
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
-msgstr "Chargement des résultats de recherche"
-
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
-msgstr "Aucun résultat trouvé"
-
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
-msgstr "Aucun texte entré"
-
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
-msgstr "Destination fixée à:"
+#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Trajet restant %4.0f km heure d'arrivée estimée %02d:%02d"
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
-msgstr "Choisir une action"
+#, c-format
+#~ msgid "Using config file '%s'\n"
+#~ msgstr "utilisation du fichier '%s'\n"
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
-msgstr "Veuillez insérer une carte SD"
+#~ msgid ""
+#~ "Internal initialization failed, exiting. Check previous error messages.\n"
+#~ msgstr ""
+#~ "initialisation interne échouée, arrêt de l'exécution. Vérifiez les messages "
+#~ "d'erreurs précédents.\n"
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
-msgstr "Sauvegarde..."
+#~ msgid "No config file navit.xml, navit.xml.local found\n"
+#~ msgstr "Pas de fichier de configuration navit.xml, navit.xml.local trouvé\n"
-#. Android resource: @strings/restoring
-msgid "Restoring..."
-msgstr "Restauration..."
+#, c-format
+#~ msgid "Error parsing config file '%s': %s\n"
+#~ msgstr "erreur d'analyse du fichier de configuration '%s': %s\n"
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
-msgstr "Impossible de créer le dossier de sauvegarde"
+#~ msgid "Downloaded maps"
+#~ msgstr "Cartes téléchargées"
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
-msgstr "Échec de la sauvegarde"
+#~ msgid ""
+#~ "Drop last \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Sauter le dernier \n"
+#~ "Point de passage"
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
-msgstr "Pas de sauvegarde trouvée"
+#~ msgid ""
+#~ "Drop next \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Sauter le prochain \n"
+#~ "point de passage"
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
-msgstr "Échec de la restauration"
+#~ msgid "partial match"
+#~ msgstr "correspondance partielle"
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
-msgstr "Sauvegarde terminée avec succès"
+#~ msgid "Map data (c) OpenStreetMap contributors, ODBL"
+#~ msgstr "Données cartographiques (c) OpenStreetMap contributors, ODBL"
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
-msgstr ""
-"Restauration réussie\n"
-"Veuillez redémarrer Navit"
+#~ msgid "Error downloading map!"
+#~ msgstr "Erreur de téléchargement de carte !"
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
-msgstr "Sauvegarde introuvable"
-
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
-msgstr "Échec de la restauration"
+#~ msgid " (except Alaska and Hawaii)"
+#~ msgstr " (sans Alaska et Hawaï)"
-#. Android resource: @strings/select_backup
-msgid "Select backup"
-msgstr "Sélectionner la sauvegarde"
-
-#. Android resource: @strings/backup
-msgid "Backup"
-msgstr "Sauvegarder"
-
-#. Android resource: @strings/restore
-msgid "Restore"
-msgstr "Restaurer"
-
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
-msgstr "Les données du moteur de parole système sont manquantes"
-
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
-msgstr ""
-"Navit peut utiliser n'importe quel système de parole disponible sur votre "
-"appareil. Le système actuellement sélectionné indique qu'il ne peut pas "
-"parler dans votre langue. Devons nous demander au système d'afficher le menu "
-"de téléchargement des voix?"
+#, c-format
+#~ msgid "Error: No configuration found in config file '%s'\n"
+#~ msgstr "Erreur: Configuration non trouvée dans le fichier '%s'\n"
-#. Android resource: @strings/permissions_not_granted
-msgid ""
-"Navit needs permission to access GPS and read the map.\n"
-"If you change your mind please restart Navit and grant the permissions"
-msgstr ""
+#, c-format
+#~ msgid "Set destination to %ld, %ld \n"
+#~ msgstr "Définir la destination vers %ld, %ld \n"
-#. Android resource: @strings/permissions_info_box_title
-msgid "One or more ungranted permissions"
-msgstr ""
+#~ msgid "Distance(m)"
+#~ msgstr "Distance (m)"
#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
#~ msgstr "puis sortez du rond-point à la %1$s %2$s"
#, c-format
+#~ msgid "Set map to %ld, %ld \n"
+#~ msgstr "sélectionner la carte de %ld, %ld \n"
+
+#~ msgid ""
+#~ "New location set to %s\n"
+#~ "Restart Navit to apply the changes."
+#~ msgstr "redémarrer Navit pour appliquer les modifications"
+
+#, c-format
#~ msgid "in %d m"
#~ msgstr "dans %d m"
#, c-format
#~ msgid "%d m"
#~ msgstr "%d m"
+
+#~ msgid "Select a distance to look for (km)"
+#~ msgstr "Sélectionnez une distance à chercher (km)"
+
+#, c-format
+#~ msgid "Set next visit to %ld, %ld \n"
+#~ msgstr "Définir la prochaine visite à %ld, %ld \n"
+
+#~ msgid "Distance from screen center (km)"
+#~ msgstr "Distance du centre de l'écran (km)"
+
+#~ msgid "filenamePath"
+#~ msgstr "emplacementFichier"
+
+#~ msgid ""
+#~ "Current map location %s is not available\n"
+#~ "Please restart Navit after you attach an SD card or select a different map "
+#~ "location."
+#~ msgstr ""
+#~ "L'emplacement de carte %s n'est pas disponible\n"
+#~ "Veuillez redémarrer Navit après avoir branché une carte SD ou selectionné en "
+#~ "emplacement de carte différent."
+
+#~ msgid "Map download aborted!"
+#~ msgstr "Téléchargement de la carte abandonné!"
diff --git a/po/fr_CH.po.in b/po/fr_CH.po.in
index 68d798ee5..e6db9a30c 100644
--- a/po/fr_CH.po.in
+++ b/po/fr_CH.po.in
@@ -355,7 +355,7 @@ msgstr "Faites demi-tour %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "suivez"
@@ -1668,7 +1668,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1927,10 +1927,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/fy.po.in b/po/fy.po.in
index 5b3e798cb..1667983ec 100644
--- a/po/fy.po.in
+++ b/po/fy.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/gl.po.in b/po/gl.po.in
index e4cb41cd6..3d04375ea 100644
--- a/po/gl.po.in
+++ b/po/gl.po.in
@@ -354,7 +354,7 @@ msgstr "Dea a volta %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1667,7 +1667,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1926,10 +1926,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/he.po.in b/po/he.po.in
index 2fb3df1eb..ba1954926 100644
--- a/po/he.po.in
+++ b/po/he.po.in
@@ -355,7 +355,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1668,7 +1668,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1927,10 +1927,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr "נא להזין נקודות ציון"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/hi.po.in b/po/hi.po.in
index ba0d20e10..7a7f7981e 100644
--- a/po/hi.po.in
+++ b/po/hi.po.in
@@ -352,7 +352,7 @@ msgstr "चारों ओर मोड़ %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1665,7 +1665,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1924,10 +1924,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/hr.po.in b/po/hr.po.in
index c39cad97e..3cc37c313 100644
--- a/po/hr.po.in
+++ b/po/hr.po.in
@@ -357,7 +357,7 @@ msgstr "Okrenite se %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1670,7 +1670,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1929,10 +1929,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/hu.po.in b/po/hu.po.in
index c4ec926a7..1b891c290 100644
--- a/po/hu.po.in
+++ b/po/hu.po.in
@@ -357,7 +357,7 @@ msgstr "Fordujon meg %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1682,7 +1682,7 @@ msgstr "Taxi"
msgid "Shopping"
msgstr "Bevásárlás"
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1941,10 +1941,10 @@ msgstr "Útvonalpontok"
msgid "Enter Coordinates"
msgstr "Koordináták megadása"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/id.po.in b/po/id.po.in
index 302b11212..cb8395731 100644
--- a/po/id.po.in
+++ b/po/id.po.in
@@ -354,7 +354,7 @@ msgstr "Balik arah %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1667,7 +1667,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1926,10 +1926,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/it.po.in b/po/it.po.in
index c2c557d7e..562981647 100644
--- a/po/it.po.in
+++ b/po/it.po.in
@@ -367,7 +367,7 @@ msgstr "Invertire il senso di marcia %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "seguire"
@@ -1684,8 +1684,8 @@ msgstr "Taxi"
msgid "Shopping"
msgstr "Negozi"
-msgid "Distance from screen center (km)"
-msgstr "Distanza dal centro dello schermo (km)"
+msgid "Select a search radius from screen center"
+msgstr "Distanza dal centro dello schermo"
#, c-format
msgid "POI %s. %s"
@@ -1943,10 +1943,10 @@ msgstr "Waypoints"
msgid "Enter Coordinates"
msgstr "Inserire Coordinate"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/ja.po.in b/po/ja.po.in
index 66ce52328..65d7ecb32 100644
--- a/po/ja.po.in
+++ b/po/ja.po.in
@@ -352,7 +352,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1665,7 +1665,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1924,10 +1924,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/jv.po.in b/po/jv.po.in
index 500c5c750..4b98e6cdf 100644
--- a/po/jv.po.in
+++ b/po/jv.po.in
@@ -352,7 +352,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1665,7 +1665,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1924,10 +1924,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/kk.po.in b/po/kk.po.in
index 7f48773a4..ab5701b42 100644
--- a/po/kk.po.in
+++ b/po/kk.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/kn.po.in b/po/kn.po.in
index 7a1b13a20..d063f7648 100644
--- a/po/kn.po.in
+++ b/po/kn.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/ko.po.in b/po/ko.po.in
index 4c908aa68..03703ef16 100644
--- a/po/ko.po.in
+++ b/po/ko.po.in
@@ -347,7 +347,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1660,7 +1660,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1919,10 +1919,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/ku.po.in b/po/ku.po.in
index 22f79bbea..473aa44b0 100644
--- a/po/ku.po.in
+++ b/po/ku.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/lb.po.in b/po/lb.po.in
index a8e5450db..78a6c5437 100644
--- a/po/lb.po.in
+++ b/po/lb.po.in
@@ -350,7 +350,7 @@ msgstr "Dreinen %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/lt.po.in b/po/lt.po.in
index b1c4a4e68..207694d35 100644
--- a/po/lt.po.in
+++ b/po/lt.po.in
@@ -361,7 +361,7 @@ msgstr "Apsisukite %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "laikykitės kelio"
@@ -1676,8 +1676,8 @@ msgstr "Taksi"
msgid "Shopping"
msgstr "Parduotuvė"
-msgid "Distance from screen center (km)"
-msgstr "Atstumas nuo ekrano vidaus (km)"
+msgid "Select a search radius from screen center"
+msgstr "Atstumas nuo ekrano vidaus"
#, c-format
msgid "POI %s. %s"
@@ -1935,10 +1935,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr "Įvėskite koordinates"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/lv.po.in b/po/lv.po.in
index 8f729a8ca..3cbcc23b6 100644
--- a/po/lv.po.in
+++ b/po/lv.po.in
@@ -359,7 +359,7 @@ msgstr "Apgriezieties %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "turpiniet"
@@ -1674,8 +1674,8 @@ msgstr "Taksometrs"
msgid "Shopping"
msgstr "Iepirkšanās"
-msgid "Distance from screen center (km)"
-msgstr "Attālums no ekrāna centra (km)"
+msgid "Select a search radius from screen center"
+msgstr "Attālums no ekrāna centra"
#, c-format
msgid "POI %s. %s"
@@ -1933,10 +1933,10 @@ msgstr "Pieturpunkti"
msgid "Enter Coordinates"
msgstr "Ievadiet Koordinātes"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/mk.po.in b/po/mk.po.in
index d51a99fb3..d5e9ed1a4 100644
--- a/po/mk.po.in
+++ b/po/mk.po.in
@@ -355,7 +355,7 @@ msgstr "Свртете %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1671,7 +1671,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1930,10 +1930,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/ml.po.in b/po/ml.po.in
index 3658437a3..1e70bc149 100644
--- a/po/ml.po.in
+++ b/po/ml.po.in
@@ -352,7 +352,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1666,7 +1666,7 @@ msgstr "ടാക്സി സ്റ്റാന്റ്"
msgid "Shopping"
msgstr "കച്ചവടസ്ഥാപനം"
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr "സ്ക്രീനിന്റെ നടുവില്‍ നിന്നുള്ള ദൂരം (കി. മി. )"
#, c-format
@@ -1925,10 +1925,10 @@ msgstr "വഴിത്തിരിവുകള്‍"
msgid "Enter Coordinates"
msgstr "കോഓര്‍ഡിനേറ്റുകള്‍ ചേര്‍ക്കുക"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/mn.po.in b/po/mn.po.in
index d9c7c7fff..e95f1d2fd 100644
--- a/po/mn.po.in
+++ b/po/mn.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/mr.po.in b/po/mr.po.in
index 69acbd449..a2dcc1df2 100644
--- a/po/mr.po.in
+++ b/po/mr.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/nb.po.in b/po/nb.po.in
index 04b4436e0..f3d660bbd 100644
--- a/po/nb.po.in
+++ b/po/nb.po.in
@@ -359,7 +359,7 @@ msgstr "Snu %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "følg"
@@ -1672,7 +1672,7 @@ msgstr "Drosje"
msgid "Shopping"
msgstr "Handleområde"
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1931,10 +1931,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/nds.po.in b/po/nds.po.in
index 76b176302..c45dc2152 100644
--- a/po/nds.po.in
+++ b/po/nds.po.in
@@ -359,7 +359,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1672,7 +1672,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1931,10 +1931,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/nl.po.in b/po/nl.po.in
index 92f587b6d..6b1936122 100644
--- a/po/nl.po.in
+++ b/po/nl.po.in
@@ -1,5 +1,5 @@
# Dutch translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Bert de Bruijn https://launchpad.net/~lpdebruijn
@@ -23,10 +23,10 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2016-05-04 15:48+0000\n"
-"Last-Translator: wb9688 <Unknown>\n"
+"PO-Revision-Date: 2018-05-10 19:30+0000\n"
+"Last-Translator: jan <jandegr1@hotmail.com>\n"
"Language-Team: afaber\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -170,7 +170,6 @@ msgstr "%1$s de %2$s op"
msgid "%1$sonto %2$s|neuter form"
msgstr "%1$s de %2$s op"
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr "naar de oprit"
@@ -368,7 +367,7 @@ msgstr "%1$s rechtsomkeren"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "volg"
@@ -380,7 +379,6 @@ msgstr "daarna heeft u uw bestemming bereikt."
msgid "You have reached your destination %s"
msgstr "Bestemming %s bereikt"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr "Knooppunt"
@@ -397,9 +395,15 @@ msgstr "Opdracht"
msgid "Length"
msgstr "Afstand"
+msgid "mi"
+msgstr "mijl"
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr "voet"
+
msgid "m"
msgstr "m"
@@ -460,6 +464,7 @@ msgid "Anguilla"
msgstr "Anguilla"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Albanië"
@@ -472,6 +477,7 @@ msgid "Netherlands Antilles"
msgstr "Nederlandse Antillen"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Angola"
@@ -480,6 +486,7 @@ msgid "Antarctica"
msgstr "Antarctica"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Argentinië"
@@ -488,10 +495,12 @@ msgid "American Samoa"
msgstr "Samoa"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Oostenrijk"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Australië"
@@ -504,10 +513,12 @@ msgid "Aland Islands"
msgstr "Aland Eilanden"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Azerbeidzjan"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Bosnië en Herzegovina"
@@ -520,6 +531,7 @@ msgid "Bangladesh"
msgstr "Bangladesh"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "België"
@@ -528,6 +540,7 @@ msgid "Burkina Faso"
msgstr "Burkina Faso"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Bulgarije"
@@ -536,6 +549,7 @@ msgid "Bahrain"
msgstr "Bahrein"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Burundi"
@@ -556,6 +570,7 @@ msgid "Brunei Darussalam"
msgstr "Brunei"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Bolivia"
@@ -564,6 +579,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr "Bonaire, Sint Eustatius en Saba"
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Brazilië"
@@ -580,10 +596,12 @@ msgid "Bouvet Island"
msgstr "Bouvet eiland"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Botswana"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Wit-Rusland"
@@ -592,6 +610,7 @@ msgid "Belize"
msgstr "Belize"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Canada"
@@ -600,6 +619,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Cocoseilanden"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Congo-Kinshasa"
@@ -612,10 +632,12 @@ msgid "Congo"
msgstr "Congo-Brazzaville"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Zwitserland"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Ivoorkust"
@@ -624,6 +646,7 @@ msgid "Cook Islands"
msgstr "Cookeilanden"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Chili"
@@ -632,10 +655,12 @@ msgid "Cameroon"
msgstr "Kameroen"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "China"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Colombia"
@@ -644,6 +669,7 @@ msgid "Costa Rica"
msgstr "Costa Rica"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Cuba"
@@ -660,14 +686,17 @@ msgid "Christmas Island"
msgstr "Kersteiland"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Cyprus"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "Tsjechië"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Duitsland"
@@ -676,6 +705,7 @@ msgid "Djibouti"
msgstr "Djibouti"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Denemarken"
@@ -684,6 +714,7 @@ msgid "Dominica"
msgstr "Dominica"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "Dominicaanse Republiek"
@@ -692,10 +723,12 @@ msgid "Algeria"
msgstr "Algerije"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Ecuador"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Estland"
@@ -712,14 +745,17 @@ msgid "Eritrea"
msgstr "Eritrea"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Spanje"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Ethiopië"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Finland"
@@ -736,10 +772,12 @@ msgid "Micronesia, Federated States of"
msgstr "Micronesië"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Färöer"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "Frankrijk"
@@ -748,6 +786,7 @@ msgid "Gabon"
msgstr "Gabon"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Verenigd Koninkrijk"
@@ -784,6 +823,7 @@ msgid "Gambia"
msgstr "Gambia"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Guinee"
@@ -796,6 +836,7 @@ msgid "Equatorial Guinea"
msgstr "Equitoriaal Guinea"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Griekenland"
@@ -816,6 +857,7 @@ msgid "Guinea-Bissau"
msgstr "Guinee-Bissau"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Guyana"
@@ -832,26 +874,32 @@ msgid "Honduras"
msgstr "Honduras"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Kroatië"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Haïti"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Hongarije"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Indonesië"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Ierland"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Israël"
@@ -860,6 +908,7 @@ msgid "Isle of Man"
msgstr "Eiland Man"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "India"
@@ -868,18 +917,22 @@ msgid "British Indian Ocean Territory"
msgstr "Brits Territorium in de Indische Oceaan"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Irak"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Iran"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "IJsland"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Italië"
@@ -888,6 +941,7 @@ msgid "Jersey"
msgstr "Jersey"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Jamaica"
@@ -896,14 +950,17 @@ msgid "Jordan"
msgstr "Jordanie"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Japan"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Kenia"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Kirgizië"
@@ -940,6 +997,7 @@ msgid "Cayman Islands"
msgstr "Caymaneilanden"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Kazachstan"
@@ -964,26 +1022,32 @@ msgid "Sri Lanka"
msgstr "Sri Lanka"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Liberia"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Lesotho"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Litouwen"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Luxemburg"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Letland"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr "Libië"
@@ -1008,6 +1072,7 @@ msgid "Saint Martin (French part)"
msgstr "Sint-Maarten (Franse Antillen)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Madagascar"
@@ -1028,6 +1093,7 @@ msgid "Myanmar"
msgstr "Myanmar"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Mongolië"
@@ -1068,10 +1134,12 @@ msgid "Malawi"
msgstr "Malawi"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "Mexico"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Maleisië"
@@ -1080,10 +1148,12 @@ msgid "Mozambique"
msgstr "Mozambique"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Namibië"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Nieuw Caledonië"
@@ -1104,6 +1174,7 @@ msgid "Nicaragua"
msgstr "NIcaragua"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Nederland"
@@ -1112,6 +1183,7 @@ msgid "Norway"
msgstr "Noorwegen"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Nepal"
@@ -1124,6 +1196,7 @@ msgid "Niue"
msgstr "Niue"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Nieuw Zeeland"
@@ -1136,6 +1209,7 @@ msgid "Panama"
msgstr "Panama"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Peru"
@@ -1148,14 +1222,17 @@ msgid "Papua New Guinea"
msgstr "Papoea-Nieuw-Guinea"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Filipijnen"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Pakistan"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Polen"
@@ -1176,6 +1253,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Palestijns Gebied, Bezet"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Portugal"
@@ -1184,6 +1262,7 @@ msgid "Palau"
msgstr "Palau"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Paraguay"
@@ -1192,10 +1271,12 @@ msgid "Qatar"
msgstr "Qatar"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Réunion"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Roemenië"
@@ -1204,15 +1285,18 @@ msgid "Serbia"
msgstr "Servië"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Rusland"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Rwanda"
#
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Saudi-Arabië"
@@ -1233,6 +1317,7 @@ msgid "Sweden"
msgstr "Zweden"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Singapore"
@@ -1249,6 +1334,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Spitsbergen en Jan Mayen"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Slowakije"
@@ -1269,6 +1355,7 @@ msgid "Somalia"
msgstr "Somalië"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Suriname"
@@ -1313,6 +1400,7 @@ msgid "Togo"
msgstr "Togo"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Thailand"
@@ -1329,6 +1417,7 @@ msgid "Timor-Leste"
msgstr "Oost-Timor"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Turkmenistan"
@@ -1341,6 +1430,7 @@ msgid "Tonga"
msgstr "Tonga"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Turkije"
@@ -1357,14 +1447,17 @@ msgid "Taiwan, Province of China"
msgstr "Taiwan"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Tanzania"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Oekraïne"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Oeganda"
@@ -1377,6 +1470,7 @@ msgid "United States"
msgstr "Verenigde Staten"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Uruguay"
@@ -1393,6 +1487,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "Saint Vincent en de Grenadines"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Venezuela"
@@ -1429,6 +1524,7 @@ msgid "Mayotte"
msgstr "Mayotte"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "Zuid-Afrika"
@@ -1454,28 +1550,37 @@ msgid ""
"\t-h: print this usage info and exit.\n"
"\t-v: print the version and exit.\n"
msgstr ""
+"navit gebruik:\n"
+"navit [opties] [configuratiebestand]\n"
+"\t-c <bestand>: gebruik <bestand> als configuratiebestand, in plaats van het "
+"standaard bestand gebruiken.\n"
+"\t-d <n>: zet de globale debug output level naar <n> (0=fout, "
+"1=waarschuwing, 2=info, 3=debug).\n"
+"\tInstellingen van het configuratiebestand zijn nog steeds van kracht als ze "
+"ingesteld zijn op een hoger level.\n"
+"\t-h: print deze gebruiksinfo en sluit af.\n"
+"\t-v: print de versie en sluit af.\n"
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
-msgstr "Geen configuratiebestand navit.xml of navit.xml.local gevonden\n"
+msgid "No config file navit.xml, navit.xml.local found"
+msgstr "Geen bestand navit.xml, navit.xml.local gevonden"
#, c-format
-msgid "Error parsing config file '%s': %s\n"
-msgstr "Foutieve waarde in het configuratie bestand '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
+msgstr "Fout in configuratiebestand '%s': %s"
#, c-format
-msgid "Using config file '%s'\n"
-msgstr "Gebruikte configuratie bestand: '%s'\n"
+msgid "Using config file '%s'"
+msgstr "Gebruik configuratiebestand '%s'"
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
-msgstr "Fout: Geen configuratie gevonden in configuratiebestand '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
+msgstr "Fout: Geen configuratie gevondein in configuratiebestand '%s'"
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
-"Interne initialisatie is mislukt, programma wordt afgesloten. Controleer de "
-"vorafgaande foutmeldingen.\n"
+"Afsluiten wegens interne initialisatiefout. Zie eerdere foutboodschappen na."
msgid "unknown street"
msgstr "onbekende weg"
@@ -1594,7 +1699,7 @@ msgid "Opens address search dialog"
msgstr "Opent het venster om adressen te zoeken"
msgid "_POI search"
-msgstr ""
+msgstr "_POI zoeken"
msgid "Opens POI search dialog"
msgstr "POI zoekscherm openen"
@@ -1617,6 +1722,9 @@ msgstr "laat positie zien"
msgid "_Lock on Road"
msgstr "Huidige locatie altijd op de weg"
+msgid "_Follow Vehicle"
+msgstr "_Voertuig Volgen"
+
msgid "_Keep orientation to the North"
msgstr "houd het kaart noorden boven"
@@ -1686,24 +1794,29 @@ msgstr "Taxi"
msgid "Shopping"
msgstr "Winkelen"
-msgid "Distance from screen center (km)"
-msgstr "Afstand vanaf schem midden (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
+msgstr ""
#, c-format
msgid "POI %s. %s"
msgstr "POI %s. %s"
#, c-format
-msgid "Set destination to %ld, %ld \n"
-msgstr ""
+msgid "Set destination to %ld, %ld "
+msgstr "Bestemming ingesteld naar %ld, %ld "
#, c-format
-msgid "Set map to %ld, %ld \n"
-msgstr ""
+msgid "Set map to %ld, %ld "
+msgstr "Kaart %ld, %ld ingesteld "
#, c-format
-msgid "Set next visit to %ld, %ld \n"
-msgstr ""
+msgid "Set next visit to %ld, %ld "
+msgstr "Volgende bezoek %ld, %ld "
msgid "POI search"
msgstr "POI zoeken"
@@ -1711,9 +1824,6 @@ msgstr "POI zoeken"
msgid "Select a category"
msgstr "Kies een categorie"
-msgid "Select a distance to look for (km)"
-msgstr "Zoekafstand kiezen (km)"
-
msgid "Select a POI"
msgstr "POI selecteren"
@@ -1726,14 +1836,14 @@ msgstr "Categorie"
msgid "Direction"
msgstr "Richting"
-msgid "Distance(m)"
-msgstr "Afstand(m)"
+msgid "Distance"
+msgstr ""
msgid "Name"
msgstr "Naam"
msgid "Visit Before"
-msgstr ""
+msgstr "Bezoek eerder"
msgid "N"
msgstr "N"
@@ -1773,8 +1883,8 @@ msgid "OT"
msgstr "OT"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Route %4.0fkm %02d:%02d Aankomsttijd"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr "Route %4.1f%s %02d:%02d ETA"
msgid "Route 0000km 0+00:00 ETA"
msgstr "Route 0000km 0+00:00 Aankomsttijd"
@@ -1945,10 +2055,10 @@ msgstr "route punten"
msgid "Enter Coordinates"
msgstr "voer coordinaten in"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1985,10 +2095,10 @@ msgid "Height Profile"
msgstr "Hoogteprofiel"
msgid "please install a map *.heightlines.bin to provide elevationdata"
-msgstr ""
+msgstr "installeer een kaart *.heightlines.bin om hoogtedata te leveren"
msgid "The route must cross at least 2 heightlines"
-msgstr ""
+msgstr "De route moet minstens twee hoogtelijnen kruisen"
msgid "Route Description"
msgstr "Routebeschrijving"
@@ -1996,6 +2106,9 @@ msgstr "Routebeschrijving"
msgid "Show Locale"
msgstr "Toon taal"
+msgid "Network info"
+msgstr "Netwerk info"
+
msgid "Former Destinations"
msgstr "Vorige bestemmingen"
@@ -2034,764 +2147,974 @@ msgstr "Pas op! Camera!"
msgid "Please decrease your speed"
msgstr "Verminder snelheid"
-msgid "partial match"
-msgstr "gedeeltelijke overeenkomst"
+msgid "Vehicle Position"
+msgstr "Voertuigpositie"
-#. Android resource: @strings/address_search_button
-msgid "Search"
-msgstr "Zoek"
+msgid "Main menu"
+msgstr "Hoofdmenu"
-#. Android resource: @strings/address_search_towns
-msgid "Towns"
-msgstr "Steden"
+msgid ""
+"Show\n"
+"Map"
+msgstr ""
+"Kaart\n"
+"Weergeven"
+
+msgid "Settings"
+msgstr "Instellingen"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr "kaart gegevens (c) OpenStreetMap contributeurs, ODBL"
+msgid "Tools"
+msgstr "Gereedschappen"
+
+msgid "Route"
+msgstr "Route"
+
+msgid "About"
+msgstr "Info"
+
+msgid "Quit"
+msgstr "Afsluiten"
+
+msgid "Actions"
+msgstr "Navigatieopties"
msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
+"Former\n"
+"Destinations"
msgstr ""
-"Huidige locatie %s voor opslag van de kaart is niet beschikbaar.\n"
-"Herstart Navit na dat U een SD kaart heeft geplaatst of een andere\n"
-"locatie voor opslag heeft gekozen."
+"Vorige\n"
+"bestemmingen"
-msgid "Downloaded maps"
-msgstr "Gedownloade kaarten"
+msgid "Coordinates"
+msgstr "Coördinaten"
msgid ""
+"Stop\n"
+"Navigation"
+msgstr ""
+"Stop\n"
+"navigatie"
+
+msgid "Display"
+msgstr "Display"
+
+msgid "Fullscreen"
+msgstr "Beeldvullend"
+
+msgid "Window Mode"
+msgstr "Venstermodus"
+
+msgid "Auto zoom"
+msgstr "Automatisch schalen"
+
+msgid "Manual zoom"
+msgstr "Manueel schalen"
+
+msgid "Layers"
+msgstr "Kaartlagen"
+
+msgid "Zoom to route"
+msgstr "Toon volledige route"
+
+msgid "Description"
+msgstr "Beschrijving"
+
+msgid ""
+"Drop last\n"
+"Waypoint"
+msgstr ""
+
+msgid ""
+"Drop next\n"
+"Waypoint"
+msgstr ""
+
+msgid "Satellite Status"
+msgstr "GPS-status"
+
+msgid "NMEA Data"
+msgstr "NMEA-gegevens"
+
+msgid "car_shortest"
+msgstr "auto_kortste_weg"
+
+msgid "car_avoid_tolls"
+msgstr "auto_vermijd_tolwegen"
+
+msgid "car_pedantic"
+msgstr "auto (incl. kleine wegen)"
+
+msgid "horse"
+msgstr "paard"
+
+msgid "Truck"
+msgstr "Vrachtwagen"
+
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
+msgstr "Ja"
+
+#. Android resource: @strings/cancel
+msgid "Cancel"
+msgstr "Annuleer"
+
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
+msgstr "Navit gestart"
+
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
+msgstr "Navit actief"
+
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
+msgstr "Welkom bij Navit"
+
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
+msgstr ""
+"Dank u voor het installeren van Navit!\n"
+"\n"
+"Om te beginnen, selecteer \"Download kaarten\" uit het menu en download een "
+"kaart van je regio. De kaarten zijn groot, dus is het aangeraden om een "
+"ongelimiteerde internetverbinding te hebben!\n"
+"\n"
+"Kaartendata: (c) OpenStreetMap contributors\n"
+"\n"
+"Nog veel plezier met Navit!"
+
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
+msgstr "OK"
+
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
+msgstr "Meer info"
+
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
+msgstr "Zoom in"
+
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
+msgstr "Zoom uit"
+
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
+msgstr "Download kaarten"
+
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
+msgstr "Schakel POIs"
+
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
+msgstr "Verlaat Navit"
+
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
+msgstr "Back-up maken / terugzetten"
+
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
+msgstr "Kaart locatie kiezen"
+
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
+msgstr "route hiernaartoe"
+
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
+msgstr "Verwijder deze kaart?"
+
+#. Android resource: @strings/map_download_title
+msgid "Map download"
+msgstr "Kaart downloaden"
+
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
+msgstr "Downloading:"
+
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
+msgstr "Resterende tijd"
+
+#. Android resource: @strings/map_download_ready
+msgid "ready"
+msgstr "klaar"
+
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
+msgstr "Fout met kaart downloaden"
+
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
+msgstr "Kaart downloaden afgebroken"
+
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
+msgstr "Niet genoeg vrije ruimte"
+
+#. Android resource: @strings/map_download_oversize
+msgid ""
"Sorry, we currently do not support maps above 3.8G on Android, please select "
"a smaller one."
msgstr ""
"Kaarten gorter dan 3,8GB zijn momenteel niet ondersteund op Android.\r\n"
"Kies a.u.b. een kleinere kaart."
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr "route hiernaartoe"
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
+msgstr "Geen locatie. Heropen nadat er een locatie-fix is."
-msgid "Cancel"
-msgstr "Annuleer"
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
+msgstr "Kaarten die de huidige locatie bevatten"
-msgid "filenamePath"
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
+msgstr "geinstalleerde kaarten"
+
+#. Android resource: @strings/map_downloading
+msgid "downloading"
+msgstr "aan het downloaden"
+
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
+msgstr "De gekozen locatie voor opslag van de kaarten is niet beschikbaar."
+
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
+msgstr "Wegschrijven van kaart mislukt!"
+
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
msgstr ""
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
+msgstr ""
+
+#. Android resource: @strings/address_search_title
+msgid "Address search"
+msgstr "Zoek een adres"
+
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
+msgstr "Uwe bestemming"
+
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
+msgstr "gedeelte van adres"
+
+#. Android resource: @strings/address_search_button
+msgid "Search"
+msgstr "Zoek"
+
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
+msgstr "Zoeken..."
+
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
+msgstr "Adres niet gevonden"
+
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
+msgstr "Zoekresultaten krijgen"
+
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
+msgstr "Zoekresultaten laden"
+
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
+msgstr "Geen resultaten gevonden"
+
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
+msgstr "Geen tekst ingevoerd"
+
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
+msgstr "Bestemming ingesteld:"
+
+#. Android resource: @strings/address_search_towns
+msgid "Towns"
+msgstr "Steden"
+
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
+msgstr "Kies een actie"
+
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
+msgstr "Voer een SD-kaart in"
+
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
+msgstr "Back-up maken..."
+
+#. Android resource: @strings/restoring
+msgid "Restoring..."
+msgstr "Terugzetten..."
+
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
+msgstr "Aanmaken back-up-map mislukt"
+
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
+msgstr "Back-up mislukt"
+
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
+msgstr "Geen back-up gevonden"
+
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
+msgstr "Terugzetten mislukt"
+
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
+msgstr "Back-up succesvol"
+
+#. Android resource: @strings/restore_successful_please_restart_navit
msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
-"%s is als nieuwe locatie ingesteld.\n"
-"Herstart a.u.b. Navit om de wijzigingen door te voeren."
+"De back-up is succesvol teruggezet.\n"
+"Herstart nu Navit."
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
+msgstr "Back-up niet gevonden"
+
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
+msgstr "Terugzetten mislukt"
+
+#. Android resource: @strings/select_backup
+msgid "Select backup"
+msgstr "Selecteer een back-up"
+
+#. Android resource: @strings/backup
+msgid "Backup"
+msgstr "Back-up"
+
+#. Android resource: @strings/restore
+msgid "Restore"
+msgstr "Terugzetten"
+
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
+msgstr "geen tekst naar spraak aanwezig"
+
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
+msgstr ""
+"Navit kan elke tekst naar spraak-engine geïnstalleerd op uw apparaat "
+"gebruiken. De momenteel geselecteerde engine meldt dat het niet in uw taal "
+"kan spreken. Wil U de spraak download dialoog van Uw toestel starten?"
+
+#. Android resource: @strings/permissions_not_granted
+msgid ""
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
+msgstr ""
+"Navit heeft toestemming voor locatie nodig en om de kaarten te lezen.\n"
+"Navit herstarten nadat U de toestemmingen heeft gegeven."
+
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
+msgstr "Ontbrekende toestemming(en)"
+
+#. Android resource: @strings/whole_planet
msgid "Whole Planet"
msgstr "de hele aarde"
+#. Android resource: @strings/africa
msgid "Africa"
msgstr "Afrika"
+#. Android resource: @strings/canary_islands
msgid "Canary Islands"
msgstr "Canarische Eilanden"
+#. Android resource: @strings/asia
msgid "Asia"
msgstr "Azië"
-msgid "Korea"
-msgstr "Korea"
-
+#. Android resource: @strings/taiwan
msgid "Taiwan"
msgstr "Taiwan"
+#. Android resource: @strings/korea
+msgid "Korea"
+msgstr "Korea"
+
+#. Android resource: @strings/uae_other
msgid "UAE+Other"
msgstr "Verenigde Arabische Emiraten + andere"
+#. Android resource: @strings/oceania
msgid "Oceania"
msgstr "Oceanië"
+#. Android resource: @strings/tasmania
msgid "Tasmania"
msgstr "Tasmanië"
+#. Android resource: @strings/victoria
msgid "Victoria"
msgstr "Victoria"
+#. Android resource: @strings/new_south_wales
msgid "New South Wales"
msgstr "Nieuw-Zuid-Wales"
+#. Android resource: @strings/europe
msgid "Europe"
msgstr "Europa"
+#. Android resource: @strings/western_europe
msgid "Western Europe"
msgstr "West-Europa"
+#. Android resource: @strings/azores
msgid "Azores"
msgstr "Azoren"
+#. Android resource: @strings/benelux
msgid "BeNeLux"
msgstr "Benelux"
+#. Android resource: @strings/alsace
msgid "Alsace"
msgstr "Elzas"
+#. Android resource: @strings/aquitaine
msgid "Aquitaine"
msgstr "Aquitanië"
+#. Android resource: @strings/auvergne
msgid "Auvergne"
msgstr "Auvergne"
-msgid "Basse-Normandie"
-msgstr "Basse-Normandie"
-
-msgid "Bourgogne"
-msgstr "Bourgondië"
+#. Android resource: @strings/centre
+msgid "Centre"
+msgstr "Midden-Frankrijk"
+#. Android resource: @strings/bretagne
msgid "Bretagne"
msgstr "Bretagne"
-msgid "Centre"
-msgstr "Midden-Frankrijk"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
+msgstr "Bourgondië"
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
+msgstr "Basse-Normandie"
+
+#. Android resource: @strings/champagne_ardenne
msgid "Champagne-Ardenne"
msgstr "Champagne-Ardenne"
+#. Android resource: @strings/corse
msgid "Corse"
msgstr "Corsica"
+#. Android resource: @strings/franche_comte
msgid "Franche-Comte"
msgstr "Franche-Comté"
+#. Android resource: @strings/haute_normandie
msgid "Haute-Normandie"
msgstr "Haute-Normandie"
+#. Android resource: @strings/ile_de_france
msgid "Ile-de-France"
msgstr "Île-de-France"
+#. Android resource: @strings/languedoc_roussillon
msgid "Languedoc-Roussillon"
msgstr "Languedoc-Roussillon"
+#. Android resource: @strings/limousin
msgid "Limousin"
msgstr "Limousin"
+#. Android resource: @strings/lorraine
msgid "Lorraine"
msgstr "Lotharingen"
+#. Android resource: @strings/midi_pyrenees
msgid "Midi-Pyrenees"
msgstr "Midi-Pyrénées"
+#. Android resource: @strings/nord_pas_de_calais
msgid "Nord-pas-de-Calais"
msgstr "Nord-Pas-de-Calais"
+#. Android resource: @strings/pays_de_la_loire
msgid "Pays-de-la-Loire"
msgstr "Pays de la Loire"
+#. Android resource: @strings/picardie
msgid "Picardie"
msgstr "Picardië"
+#. Android resource: @strings/poitou_charentes
msgid "Poitou-Charentes"
msgstr "Poitou-Charentes"
+#. Android resource: @strings/provence_alpes_cote_d_azur
msgid "Provence-Alpes-Cote-d-Azur"
msgstr "Provence-Alpes-Côte d'Azur"
+#. Android resource: @strings/rhone_alpes
msgid "Rhone-Alpes"
msgstr "Rhône-Alpes"
+#. Android resource: @strings/baden_wuerttemberg
msgid "Baden-Wuerttemberg"
msgstr "Baden-Württemberg"
+#. Android resource: @strings/bayern
msgid "Bayern"
msgstr "Beieren"
+#. Android resource: @strings/mittelfranken
msgid "Mittelfranken"
msgstr "Mittelfranken"
+#. Android resource: @strings/niederbayern
msgid "Niederbayern"
msgstr "Niederbayern"
+#. Android resource: @strings/oberbayern
msgid "Oberbayern"
msgstr "Oberbayern"
+#. Android resource: @strings/oberfranken
msgid "Oberfranken"
msgstr "Oberfranken"
+#. Android resource: @strings/oberpfalz
msgid "Oberpfalz"
msgstr "Oberpfalz"
+#. Android resource: @strings/schwaben
msgid "Schwaben"
msgstr "Schwaben"
+#. Android resource: @strings/unterfranken
msgid "Unterfranken"
msgstr "Unterfranken"
+#. Android resource: @strings/berlin
msgid "Berlin"
msgstr "Berlijn"
+#. Android resource: @strings/brandenburg
msgid "Brandenburg"
msgstr "Brandenburg"
+#. Android resource: @strings/bremen
msgid "Bremen"
msgstr "Bremen"
+#. Android resource: @strings/hamburg
msgid "Hamburg"
msgstr "Hamburg"
+#. Android resource: @strings/hessen
msgid "Hessen"
msgstr "Hessen"
+#. Android resource: @strings/mecklenburg_vorpommern
msgid "Mecklenburg-Vorpommern"
msgstr "Mecklenburg-Voor-Pommeren"
+#. Android resource: @strings/niedersachsen
msgid "Niedersachsen"
msgstr "Nedersaksen"
+#. Android resource: @strings/nordrhein_westfalen
msgid "Nordrhein-westfalen"
msgstr "Noordrijn-Westfalen"
+#. Android resource: @strings/rheinland_pfalz
msgid "Rheinland-Pfalz"
msgstr "Rijnland-Palts"
+#. Android resource: @strings/saarland
msgid "Saarland"
msgstr "Saarland"
+#. Android resource: @strings/sachsen_anhalt
msgid "Sachsen-Anhalt"
msgstr "Saksen-Anhalt"
+#. Android resource: @strings/sachsen
msgid "Sachsen"
msgstr "Saksen"
+#. Android resource: @strings/schleswig_holstein
msgid "Schleswig-Holstein"
msgstr "Sleeswijk-Holstein"
+#. Android resource: @strings/thueringen
msgid "Thueringen"
msgstr "Thüringen"
+#. Android resource: @strings/mallorca
msgid "Mallorca"
msgstr "Mallorca"
+#. Android resource: @strings/galicia
msgid "Galicia"
msgstr "Galicië"
+#. Android resource: @strings/scandinavia
msgid "Scandinavia"
msgstr "Scandinavië"
+#. Android resource: @strings/england
msgid "England"
msgstr "Engeland"
+#. Android resource: @strings/buckinghamshire
msgid "Buckinghamshire"
msgstr "Buckinghamshire"
+#. Android resource: @strings/cambridgeshire
msgid "Cambridgeshire"
msgstr "Cambridgeshire"
+#. Android resource: @strings/cumbria
msgid "Cumbria"
msgstr "Cumbria"
+#. Android resource: @strings/east_yorkshire_with_hull
msgid "East yorkshire with hull"
msgstr "East Yorkshire en Hull"
+#. Android resource: @strings/essex
msgid "Essex"
msgstr "Essex"
+#. Android resource: @strings/herefordshire
msgid "Herefordshire"
msgstr "Herefordshire"
+#. Android resource: @strings/kent
msgid "Kent"
msgstr "Kent"
+#. Android resource: @strings/lancashire
msgid "Lancashire"
msgstr "Lancashire"
+#. Android resource: @strings/leicestershire
msgid "Leicestershire"
msgstr "Leicestershire"
+#. Android resource: @strings/norfolk
msgid "Norfolk"
msgstr "Norfolk"
+#. Android resource: @strings/nottinghamshire
msgid "Nottinghamshire"
msgstr "Nottinghamshire"
+#. Android resource: @strings/oxfordshire
msgid "Oxfordshire"
msgstr "Oxfordshire"
+#. Android resource: @strings/shropshire
msgid "Shropshire"
msgstr "Shropshire"
+#. Android resource: @strings/somerset
msgid "Somerset"
msgstr "Somerset"
+#. Android resource: @strings/south_yorkshire
msgid "South yorkshire"
msgstr "South Yorkshire"
+#. Android resource: @strings/suffolk
msgid "Suffolk"
msgstr "Suffolk"
+#. Android resource: @strings/surrey
msgid "Surrey"
msgstr "Surrey"
+#. Android resource: @strings/wiltshire
msgid "Wiltshire"
msgstr "Wiltshire"
+#. Android resource: @strings/scotland
msgid "Scotland"
msgstr "Schotland"
+#. Android resource: @strings/wales
msgid "Wales"
msgstr "Wales"
+#. Android resource: @strings/crete
msgid "Crete"
msgstr "Kreta"
+#. Android resource: @strings/north_america
msgid "North America"
msgstr "Noord-Amerika"
+#. Android resource: @strings/alaska
msgid "Alaska"
msgstr "Alaska"
+#. Android resource: @strings/hawaii
msgid "Hawaii"
msgstr "Hawaï"
+#. Android resource: @strings/usa
msgid "USA"
msgstr "VS"
-msgid " (except Alaska and Hawaii)"
-msgstr " (behalve Alaska en Hawaï)"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
+msgstr ""
+#. Android resource: @strings/midwest
msgid "Midwest"
msgstr "Midwest"
+#. Android resource: @strings/michigan
msgid "Michigan"
msgstr "Michigan"
+#. Android resource: @strings/ohio
msgid "Ohio"
msgstr "Ohio"
+#. Android resource: @strings/northeast
msgid "Northeast"
msgstr "Northeast"
+#. Android resource: @strings/massachusetts
msgid "Massachusetts"
msgstr "Massachusetts"
+#. Android resource: @strings/vermont
msgid "Vermont"
msgstr "Vermont"
+#. Android resource: @strings/pacific
msgid "Pacific"
msgstr "Pacific"
+#. Android resource: @strings/south
msgid "South"
msgstr "South"
+#. Android resource: @strings/arkansas
msgid "Arkansas"
msgstr "Arkansas"
+#. Android resource: @strings/district_of_columbia
msgid "District of Columbia"
msgstr "District Columbia"
+#. Android resource: @strings/florida
msgid "Florida"
msgstr "Florida"
+#. Android resource: @strings/louisiana
msgid "Louisiana"
msgstr "Louisiana"
+#. Android resource: @strings/maryland
msgid "Maryland"
msgstr "Maryland"
+#. Android resource: @strings/mississippi
msgid "Mississippi"
msgstr "Mississippi"
+#. Android resource: @strings/oklahoma
msgid "Oklahoma"
msgstr "Oklahoma"
+#. Android resource: @strings/texas
msgid "Texas"
msgstr "Texas"
+#. Android resource: @strings/virginia
msgid "Virginia"
msgstr "Virginia"
+#. Android resource: @strings/west_virginia
msgid "West Virginia"
msgstr "West Virginia"
+#. Android resource: @strings/west
msgid "West"
msgstr "West"
+#. Android resource: @strings/arizona
msgid "Arizona"
msgstr "Arizona"
+#. Android resource: @strings/california
msgid "California"
msgstr "Californië"
+#. Android resource: @strings/colorado
msgid "Colorado"
msgstr "Colorado"
+#. Android resource: @strings/idaho
msgid "Idaho"
msgstr "Idaho"
+#. Android resource: @strings/montana
msgid "Montana"
msgstr "Montana"
+#. Android resource: @strings/new_mexico
msgid "New Mexico"
msgstr "Nieuw-Mexico"
+#. Android resource: @strings/nevada
msgid "Nevada"
msgstr "Nevada"
+#. Android resource: @strings/oregon
msgid "Oregon"
msgstr "Oregon"
+#. Android resource: @strings/utah
msgid "Utah"
msgstr "Utah"
+#. Android resource: @strings/washington_state
msgid "Washington State"
msgstr "Washington State"
+#. Android resource: @strings/south_middle_america
msgid "South+Middle America"
msgstr "Zuid- en Midden-Amerika"
+#. Android resource: @strings/guyane_francaise
msgid "Guyane Francaise"
msgstr "Frans Guyana"
-msgid "downloading"
-msgstr "aan het downloaden"
-
-#. Android resource: @strings/map_download_ready
-msgid "ready"
-msgstr "klaar"
-
-msgid "Media selected for map storage is not available"
-msgstr "De gekozen locatie voor opslag van de kaarten is niet beschikbaar."
-
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
-msgstr "Niet genoeg vrije ruimte"
-
-msgid "Error downloading map!"
-msgstr "Kaart downloaden mislukt!"
-
-msgid "Error writing map!"
-msgstr "Wegschrijven van kaart mislukt!"
-
-msgid "Map download aborted!"
-msgstr "Kaart-download afgebroken!"
-
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
-msgstr "Resterende tijd"
-
-#. Android resource: @strings/map_download_title
-msgid "Map download"
-msgstr "Kaart downloaden"
-
-msgid "Vehicle Position"
-msgstr "Voertuigpositie"
-
-msgid "Main menu"
-msgstr "Hoofdmenu"
-
-msgid ""
-"Show\n"
-"Map"
-msgstr ""
-"Kaart\n"
-"Weergeven"
-
-msgid "Settings"
-msgstr "Instellingen"
-
-msgid "Tools"
-msgstr "Gereedschappen"
-
-msgid "Route"
-msgstr "Route"
-
-msgid "About"
-msgstr "Info"
-
-msgid "Quit"
-msgstr "Afsluiten"
-
-msgid "Actions"
-msgstr "Navigatieopties"
-
-msgid ""
-"Former\n"
-"Destinations"
-msgstr ""
-"Vorige\n"
-"bestemmingen"
-
-msgid "Coordinates"
-msgstr "Coördinaten"
-
-msgid ""
-"Stop\n"
-"Navigation"
-msgstr ""
-"Stop\n"
-"navigatie"
-
-msgid "Display"
-msgstr "Display"
-
-msgid "Fullscreen"
-msgstr "Beeldvullend"
-
-msgid "Window Mode"
-msgstr "Venstermodus"
-
-msgid "Layers"
-msgstr ""
-
-msgid "Description"
-msgstr "Beschrijving"
-
-msgid ""
-"Drop last \n"
-"Waypoint"
-msgstr ""
-"Laatste routepunt \n"
-"verwijderen"
-
-msgid ""
-"Drop next \n"
-"Waypoint"
-msgstr ""
-"Volgende routepunt \n"
-"verwijderen"
-
-msgid "Satellite Status"
-msgstr "GPS-status"
-
-msgid "NMEA Data"
-msgstr "NMEA-gegevens"
-
-msgid "car_shortest"
-msgstr "auto_kortste_weg"
-
-msgid "car_avoid_tolls"
-msgstr "auto_vermijd_tolwegen"
-
-msgid "car_pedantic"
-msgstr "auto (incl. kleine wegen)"
-
-msgid "horse"
-msgstr "paard"
-
-msgid "Truck"
-msgstr "Vrachtwagen"
-
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
-msgstr "Ja"
-
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
-msgstr "Navit gestart"
-
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
-msgstr "Navit actief"
-
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
-msgstr "Welkom bij Navit"
-
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
-msgstr ""
-"Dank u voor het installeren van Navit!\n"
-"\n"
-"Om te beginnen, selecteer \"Download kaarten\" uit het menu en download een "
-"kaart van je regio. De kaarten zijn groot, dus is het aangeraden om een "
-"ongelimiteerde internetverbinding te hebben!\n"
-"\n"
-"Kaartendata: (c) OpenStreetMap contributors\n"
-"\n"
-"Nog veel plezier met Navit!"
-
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
-msgstr "OK"
-
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
-msgstr "Meer info"
-
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
-msgstr "Zoom in"
-
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
-msgstr "Zoom uit"
-
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
-msgstr "Download kaarten"
-
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
-msgstr "Schakel POIs"
-
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
-msgstr "Verlaat Navit"
-
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
-msgstr "Back-up maken / terugzetten"
-
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
-msgstr "Kaart locatie kiezen"
-
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
-msgstr "Verwijder deze kaart?"
-
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
-msgstr "Downloading:"
-
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
-msgstr "Fout met kaart downloaden"
-
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
-msgstr "Kaart downloaden afgebroken"
-
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
-msgstr "Geen locatie. Heropen nadat er een locatie-fix is."
-
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
-msgstr "Kaarten die de huidige locatie bevatten"
-
-#. Android resource: @strings/address_search_title
-msgid "Address search"
-msgstr "Zoek een adres"
-
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
-msgstr "Uwe bestemming"
-
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
-msgstr "gedeelte van adres"
-
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
-msgstr "Zoeken..."
-
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
-msgstr "Adres niet gevonden"
-
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
-msgstr "Zoekresultaten krijgen"
-
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
-msgstr "Zoekresultaten laden"
-
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
-msgstr "Geen resultaten gevonden"
-
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
-msgstr "Geen tekst ingevoerd"
-
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
-msgstr "Bestemming ingesteld:"
-
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
-msgstr "Kies een actie"
-
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
-msgstr "Voer een SD-kaart in"
-
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
-msgstr "Back-up maken..."
-
-#. Android resource: @strings/restoring
-msgid "Restoring..."
-msgstr "Terugzetten..."
+#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Route %4.0fkm %02d:%02d Aankomsttijd"
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
-msgstr "Aanmaken back-up-map mislukt"
+#~ msgid "Downloaded maps"
+#~ msgstr "Gedownloade kaarten"
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
-msgstr "Back-up mislukt"
+#, c-format
+#~ msgid "Using config file '%s'\n"
+#~ msgstr "Gebruikte configuratie bestand: '%s'\n"
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
-msgstr "Geen back-up gevonden"
+#~ msgid ""
+#~ "Internal initialization failed, exiting. Check previous error messages.\n"
+#~ msgstr ""
+#~ "Interne initialisatie is mislukt, programma wordt afgesloten. Controleer de "
+#~ "vorafgaande foutmeldingen.\n"
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
-msgstr "Terugzetten mislukt"
+#, c-format
+#~ msgid "Error parsing config file '%s': %s\n"
+#~ msgstr "Foutieve waarde in het configuratie bestand '%s': %s\n"
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
-msgstr "Back-up succesvol"
+#~ msgid "Map data (c) OpenStreetMap contributors, ODBL"
+#~ msgstr "kaart gegevens (c) OpenStreetMap contributeurs, ODBL"
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
-msgstr ""
-"De back-up is succesvol teruggezet.\n"
-"Herstart nu Navit."
+#~ msgid "partial match"
+#~ msgstr "gedeeltelijke overeenkomst"
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
-msgstr "Back-up niet gevonden"
+#~ msgid "No config file navit.xml, navit.xml.local found\n"
+#~ msgstr "Geen configuratiebestand navit.xml of navit.xml.local gevonden\n"
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
-msgstr "Terugzetten mislukt"
+#~ msgid " (except Alaska and Hawaii)"
+#~ msgstr " (behalve Alaska en Hawaï)"
-#. Android resource: @strings/select_backup
-msgid "Select backup"
-msgstr "Selecteer een back-up"
+#~ msgid "Error downloading map!"
+#~ msgstr "Kaart downloaden mislukt!"
-#. Android resource: @strings/backup
-msgid "Backup"
-msgstr "Back-up"
+#~ msgid "Map download aborted!"
+#~ msgstr "Kaart-download afgebroken!"
-#. Android resource: @strings/restore
-msgid "Restore"
-msgstr "Terugzetten"
+#~ msgid ""
+#~ "Drop last \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Laatste routepunt \n"
+#~ "verwijderen"
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
-msgstr "geen tekst naar spraak aanwezig"
+#~ msgid ""
+#~ "Drop next \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Volgende routepunt \n"
+#~ "verwijderen"
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
-msgstr ""
-"Navit kan elke tekst naar spraak-engine geïnstalleerd op uw apparaat "
-"gebruiken. De momenteel geselecteerde engine meldt dat het niet in uw taal "
-"kan spreken. Wil U de spraak download dialoog van Uw toestel starten?"
+#, c-format
+#~ msgid "Error: No configuration found in config file '%s'\n"
+#~ msgstr "Fout: Geen configuratie gevonden in configuratiebestand '%s'\n"
+
+#~ msgid "Distance(m)"
+#~ msgstr "Afstand(m)"
+
+#~ msgid ""
+#~ "Current map location %s is not available\n"
+#~ "Please restart Navit after you attach an SD card or select a different map "
+#~ "location."
+#~ msgstr ""
+#~ "Huidige locatie %s voor opslag van de kaart is niet beschikbaar.\n"
+#~ "Herstart Navit na dat U een SD kaart heeft geplaatst of een andere\n"
+#~ "locatie voor opslag heeft gekozen."
+
+#~ msgid ""
+#~ "New location set to %s\n"
+#~ "Restart Navit to apply the changes."
+#~ msgstr ""
+#~ "%s is als nieuwe locatie ingesteld.\n"
+#~ "Herstart a.u.b. Navit om de wijzigingen door te voeren."
+
+#~ msgid "Select a distance to look for (km)"
+#~ msgstr "Zoekafstand kiezen (km)"
+
+#~ msgid "Distance from screen center (km)"
+#~ msgstr "Afstand vanaf schem midden (km)"
#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
#~ msgstr "daarna de rotonde verlaten bij de %1$s %2$s"
+
+#~ msgid "filenamePath"
+#~ msgstr "bestandslocatie"
diff --git a/po/nn.po.in b/po/nn.po.in
index b4d4c66e5..a069fb307 100644
--- a/po/nn.po.in
+++ b/po/nn.po.in
@@ -353,7 +353,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1666,7 +1666,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1925,10 +1925,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/pl.po.in b/po/pl.po.in
index cd4bf9dd5..b88aa8842 100644
--- a/po/pl.po.in
+++ b/po/pl.po.in
@@ -369,7 +369,7 @@ msgstr "Zawróc %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1684,7 +1684,7 @@ msgstr "Postój taksówek"
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1943,10 +1943,10 @@ msgstr "Punkty trasy"
msgid "Enter Coordinates"
msgstr "Wprowadź współrzędne"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/pms.po.in b/po/pms.po.in
index e52ac59fb..967002ea9 100644
--- a/po/pms.po.in
+++ b/po/pms.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/pt.po.in b/po/pt.po.in
index 418c05136..99ea00ef8 100644
--- a/po/pt.po.in
+++ b/po/pt.po.in
@@ -364,7 +364,7 @@ msgstr "Dê meia-volta à direita %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "siga"
@@ -1689,8 +1689,8 @@ msgstr "Táxi"
msgid "Shopping"
msgstr "Compras"
-msgid "Distance from screen center (km)"
-msgstr "Distância ao centro do ecrã (km)"
+msgid "Select a search radius from screen center"
+msgstr "Distância ao centro do ecrã"
#, c-format
msgid "POI %s. %s"
@@ -1948,10 +1948,10 @@ msgstr "Pontos"
msgid "Enter Coordinates"
msgstr "Introduzir coordenadas"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/pt_BR.po.in b/po/pt_BR.po.in
index 3c4d5c6d7..e20c8a1ca 100644
--- a/po/pt_BR.po.in
+++ b/po/pt_BR.po.in
@@ -1,5 +1,5 @@
# Brazilian Portuguese translations for navit
-# Copyright (C) 2006-2015 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Carla Pita https://launchpad.net/~carla-pita
@@ -22,10 +22,10 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2015-07-27 11:44+0000\n"
-"Last-Translator: Julio Alexander Sieg <julio.sieg@gmail.com>\n"
+"PO-Revision-Date: 2018-07-20 01:19+0000\n"
+"Last-Translator: Jairo Roberto Duarte <Unknown>\n"
"Language-Team: Brazilian Portuguese <pt_BR@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -144,7 +144,7 @@ msgstr[1] "em %d quilômetros"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Systematic Street Name 3: Separator (Space if required), 4: Street Name
#, c-format
msgid "%1$sonto the %2$s%3$s%4$s"
-msgstr ""
+msgstr "%1$sno %2$s%3$s%4$s"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name
#, c-format
@@ -154,19 +154,18 @@ msgstr "%1$sno %2$s"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Masculine form. The stuff after | doesn't have to be included
#, c-format
msgid "%1$sonto %2$s|masculine form"
-msgstr ""
+msgstr "%1$sno %2$s|formato masculino"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Feminine form. The stuff after | doesn't have to be included
#, c-format
msgid "%1$sonto %2$s|feminine form"
-msgstr ""
+msgstr "%1$sno %2$s|formato feminino"
#. TRANSLATORS: Arguments: 1: Prefix (Space if required) 2: Street Name. Neuter form. The stuff after | doesn't have to be included
#, c-format
msgid "%1$sonto %2$s|neuter form"
-msgstr ""
+msgstr "%1$sno %2$s|formato neutro"
-#. TRANSLATORS: motorway ramp refers to the slip road for entering a motorway.
msgid "onto the motorway ramp"
msgstr "na rampa"
@@ -216,7 +215,7 @@ msgid "Enter the roundabout %s"
msgstr "Entre na rotatória %s"
msgid "then enter the roundabout"
-msgstr ""
+msgstr "em seguida entre na rotatória"
#. TRANSLATORS: first arg. is the manieth exit, second arg. is the destination to follow
#, c-format
@@ -235,12 +234,12 @@ msgstr "em seguida"
#. TRANSLATORS: the arg. is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included.
#, c-format
msgid "then merge%1$s|right"
-msgstr ""
+msgstr "em seguida vire a %1$s|direita"
#. TRANSLATORS: the first arg. is distance, the second is the phrase 'onto ...'. Right merge, the stuff after | doesn't have to be included.
#, c-format
msgid "Merge %1$s%2$s|right"
-msgstr ""
+msgstr "Vire a %1$s%2$s|direita"
#. TRANSLATORS: the arg. is the phrase 'onto ...'. Left merge, the stuff after | doesn't have to be included.
#, c-format
@@ -323,7 +322,7 @@ msgstr "fortemente "
#, c-format
msgid "then take the %1$s road to the %2$s"
-msgstr ""
+msgstr "então pegue a %1$s via para a %2$s"
#, c-format
msgid "Take the %1$s road to the %2$s"
@@ -367,7 +366,7 @@ msgstr "Faça o retorno a direita %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "siga por"
@@ -379,7 +378,6 @@ msgstr "então você chegará ao destino."
msgid "You have reached your destination %s"
msgstr "Você chegará ao destino %s"
-#. TRANSLATORS: Exit as a noun, as in "Exit 43 Greenmound-East"
msgid "Interchange"
msgstr "Trevo"
@@ -396,9 +394,15 @@ msgstr "Comando"
msgid "Length"
msgstr "Distância"
+msgid "mi"
+msgstr "milha"
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr "pé"
+
msgid "m"
msgstr "m"
@@ -459,6 +463,7 @@ msgid "Anguilla"
msgstr "Anguilla"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Albânia"
@@ -471,6 +476,7 @@ msgid "Netherlands Antilles"
msgstr "Antilhas Holandesas"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Angola"
@@ -479,6 +485,7 @@ msgid "Antarctica"
msgstr "Antártida"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Argentina"
@@ -487,10 +494,12 @@ msgid "American Samoa"
msgstr "Samoa Americana"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Áustria"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Austrália"
@@ -503,10 +512,12 @@ msgid "Aland Islands"
msgstr "Ilhas Aland"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Azerbaijão"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Bósnia e Herzegovina"
@@ -519,6 +530,7 @@ msgid "Bangladesh"
msgstr "Bangladesh"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "Bélgica"
@@ -527,6 +539,7 @@ msgid "Burkina Faso"
msgstr "Burkina Faso"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Bulgária"
@@ -535,6 +548,7 @@ msgid "Bahrain"
msgstr "Bahrein"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Burundi"
@@ -555,6 +569,7 @@ msgid "Brunei Darussalam"
msgstr "Brunei"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Bolívia"
@@ -563,6 +578,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr "Bonaire, São Eustácio e Saba"
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Brasil"
@@ -579,10 +595,12 @@ msgid "Bouvet Island"
msgstr "Ilha Bouvet"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Botswana"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Bielorrússia"
@@ -591,6 +609,7 @@ msgid "Belize"
msgstr "Belize"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Canadá"
@@ -599,6 +618,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Ilhas Cocos (Keeling)"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "República Democrática do Congo"
@@ -611,10 +631,12 @@ msgid "Congo"
msgstr "Congo"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Suíça"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Costa do Marfim"
@@ -623,6 +645,7 @@ msgid "Cook Islands"
msgstr "Ilhas Cook"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Chile"
@@ -631,10 +654,12 @@ msgid "Cameroon"
msgstr "Camarões"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "China"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Colômbia"
@@ -643,6 +668,7 @@ msgid "Costa Rica"
msgstr "Costa Rica"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Cuba"
@@ -659,14 +685,17 @@ msgid "Christmas Island"
msgstr "Ilha Christmas"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Chipre"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "República Tcheca"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Alemanha"
@@ -675,6 +704,7 @@ msgid "Djibouti"
msgstr "Djibuti"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Dinamarca"
@@ -683,6 +713,7 @@ msgid "Dominica"
msgstr "Dominica"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "República Dominicana"
@@ -691,10 +722,12 @@ msgid "Algeria"
msgstr "Argélia"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Equador"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Estônia"
@@ -711,14 +744,17 @@ msgid "Eritrea"
msgstr "Eritréia"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Espanha"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Etiópia"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Finlândia"
@@ -735,10 +771,12 @@ msgid "Micronesia, Federated States of"
msgstr "Micronésia"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Ilhas Faroé"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "França"
@@ -747,6 +785,7 @@ msgid "Gabon"
msgstr "Gabão"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Reino Unido"
@@ -783,6 +822,7 @@ msgid "Gambia"
msgstr "Gâmbia"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Guiné"
@@ -795,6 +835,7 @@ msgid "Equatorial Guinea"
msgstr "Guiné Equatorial"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Grécia"
@@ -815,6 +856,7 @@ msgid "Guinea-Bissau"
msgstr "Guiné-Bissau"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Guiana"
@@ -831,26 +873,32 @@ msgid "Honduras"
msgstr "Honduras"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Croácia"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Haiti"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Hungria"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Indonésia"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Irlanda"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Israel"
@@ -859,6 +907,7 @@ msgid "Isle of Man"
msgstr "Ilha de Man"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "Índia"
@@ -867,18 +916,22 @@ msgid "British Indian Ocean Territory"
msgstr "Território Britânico do Oceano Índico"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Iraque"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Irã"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Islândia"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Itália"
@@ -887,6 +940,7 @@ msgid "Jersey"
msgstr "Jersey"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Jamaica"
@@ -895,14 +949,17 @@ msgid "Jordan"
msgstr "Jordânia"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Japão"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Quênia"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Quirguistão"
@@ -939,6 +996,7 @@ msgid "Cayman Islands"
msgstr "Ilhas Caiman"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Cazaquistão"
@@ -963,26 +1021,32 @@ msgid "Sri Lanka"
msgstr "Siri Lanka"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Libéria"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Lesoto"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Lituânia"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Luxemburgo"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Letônia"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr "Líbia"
@@ -1007,6 +1071,7 @@ msgid "Saint Martin (French part)"
msgstr "São Martin (parte francesa)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Madagascar"
@@ -1027,6 +1092,7 @@ msgid "Myanmar"
msgstr "Mianmar"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Mongólia"
@@ -1067,10 +1133,12 @@ msgid "Malawi"
msgstr "Malawi"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "México"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Malásia"
@@ -1079,10 +1147,12 @@ msgid "Mozambique"
msgstr "Moçambique"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Namíbia"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Nova Caledônia"
@@ -1103,6 +1173,7 @@ msgid "Nicaragua"
msgstr "Nicarágua"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Holanda"
@@ -1111,6 +1182,7 @@ msgid "Norway"
msgstr "Noruega"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Nepal"
@@ -1123,6 +1195,7 @@ msgid "Niue"
msgstr "Niue"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Nova Zelândia"
@@ -1135,6 +1208,7 @@ msgid "Panama"
msgstr "Panamá"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Perú"
@@ -1147,14 +1221,17 @@ msgid "Papua New Guinea"
msgstr "Papua Nova Guiné"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Filipinas"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Paquistão"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Polônia"
@@ -1175,6 +1252,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Palestina"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Portugal"
@@ -1183,6 +1261,7 @@ msgid "Palau"
msgstr "Palau"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Paraguai"
@@ -1191,10 +1270,12 @@ msgid "Qatar"
msgstr "Catar"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Ilhas Reunião"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Romênia"
@@ -1203,14 +1284,17 @@ msgid "Serbia"
msgstr "Sérvia"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Rússia"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Ruanda"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Arábia Saudita"
@@ -1231,6 +1315,7 @@ msgid "Sweden"
msgstr "Suécia"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Singapura"
@@ -1247,6 +1332,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Svalbard e Jan Mayen"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Eslováquia"
@@ -1267,6 +1353,7 @@ msgid "Somalia"
msgstr "Somália"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Suriname"
@@ -1311,6 +1398,7 @@ msgid "Togo"
msgstr "Togo"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Tailândia"
@@ -1327,6 +1415,7 @@ msgid "Timor-Leste"
msgstr "Timor-Leste"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Turcomenistão"
@@ -1339,6 +1428,7 @@ msgid "Tonga"
msgstr "Tonga"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Turquia"
@@ -1355,14 +1445,17 @@ msgid "Taiwan, Province of China"
msgstr "Taiwan"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Tanzânia"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Ucrânia"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Uganda"
@@ -1375,6 +1468,7 @@ msgid "United States"
msgstr "Estados Unidos"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Uruguai"
@@ -1391,6 +1485,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "São Vicente e Granadinas"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Venezuela"
@@ -1427,6 +1522,7 @@ msgid "Mayotte"
msgstr "Mayotte"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "África do Sul"
@@ -1464,27 +1560,26 @@ msgstr ""
"\t-v: imprimir a versão e sair.\n"
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
-msgstr ""
-"Nenhum arquivo de configuração navit.xml, navit.xml.local foi encontrado\n"
+msgid "No config file navit.xml, navit.xml.local found"
+msgstr "Nenhum arquivo de configuração navit.xml, navit.xml.local encontrado"
#, c-format
-msgid "Error parsing config file '%s': %s\n"
-msgstr "Erro ao analizar o arquivo de configuração '%s': %s\n"
+msgid "Error parsing config file '%s': %s"
+msgstr "Erro ao analisar o arquivo de configuração '%s': %s"
#, c-format
-msgid "Using config file '%s'\n"
-msgstr "Utilizando arquivo de configuração '%s'\n"
+msgid "Using config file '%s'"
+msgstr "Usando o arquivo de configuração '%s'"
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
-msgstr "Erro: Nenhuma configuração encontrada no arquivo '%s'\n"
+msgid "Error: No configuration found in config file '%s'"
+msgstr ""
+"Erro: Nenhuma configuração encontrada no arquivo de configuração '%s'"
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
-"Inicialização interna falhou, finalizando. Verifique mensagens de erro "
-"anteriores.\n"
+"Inicialização interna falhou, saindo. Verificar mensagens de erro anteriores."
msgid "unknown street"
msgstr "rua desconhecida"
@@ -1624,6 +1719,9 @@ msgstr "Mostrar a posição _cursor"
msgid "_Lock on Road"
msgstr "_Bloqueio na estrada"
+msgid "_Follow Vehicle"
+msgstr "_Siga o Veículo"
+
msgid "_Keep orientation to the North"
msgstr "_Manter orientação para o Norte"
@@ -1693,24 +1791,29 @@ msgstr "Táxi"
msgid "Shopping"
msgstr "Comprando"
-msgid "Distance from screen center (km)"
-msgstr "Distância do centro da tela (km)"
+#. Input is in kilometers
+msgid "Select a search radius from screen center in km"
+msgstr ""
+
+#. Input is in miles.
+msgid "Select a search radius from screen center in miles"
+msgstr ""
#, c-format
msgid "POI %s. %s"
msgstr "POI %s. %s"
#, c-format
-msgid "Set destination to %ld, %ld \n"
-msgstr "Definir destino para %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
+msgstr "Definir destino para %ld, %ld "
#, c-format
-msgid "Set map to %ld, %ld \n"
-msgstr "Definir mapa para o %ld, %ld \n"
+msgid "Set map to %ld, %ld "
+msgstr "Definir mapa para %ld, %ld "
#, c-format
-msgid "Set next visit to %ld, %ld \n"
-msgstr "Definir próxima parada parao %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
+msgstr "Configurar próxima visita para %ld, %ld "
msgid "POI search"
msgstr "Pesquisar POI"
@@ -1718,9 +1821,6 @@ msgstr "Pesquisar POI"
msgid "Select a category"
msgstr "Selecione uma categoria"
-msgid "Select a distance to look for (km)"
-msgstr "Selecione a distância para pesquisar (km)"
-
msgid "Select a POI"
msgstr "Selecione um POI"
@@ -1733,8 +1833,8 @@ msgstr "Categori­a"
msgid "Direction"
msgstr "Direção"
-msgid "Distance(m)"
-msgstr "Distância (m)"
+msgid "Distance"
+msgstr ""
msgid "Name"
msgstr "Nome"
@@ -1780,8 +1880,8 @@ msgid "OT"
msgstr "OT"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Rota %4.0fkm TEC %02d:%02d"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr "Rota %4.1f%s %02d:%02d ETA"
msgid "Route 0000km 0+00:00 ETA"
msgstr "Rota 0000km TEC 0+00:00"
@@ -1952,10 +2052,10 @@ msgstr "Pontos da via"
msgid "Enter Coordinates"
msgstr "Digite as coordenadas"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1991,12 +2091,21 @@ msgstr "Layout"
msgid "Height Profile"
msgstr "Perfil de Altitude"
+msgid "please install a map *.heightlines.bin to provide elevationdata"
+msgstr "Instale um mapa *.heightlines.bin para fornecer dados de elevação"
+
+msgid "The route must cross at least 2 heightlines"
+msgstr "A rota deve atravessar pelo menos 2 linhas de altitude"
+
msgid "Route Description"
msgstr "Descrição da Rota"
msgid "Show Locale"
msgstr "Inf. Regionais"
+msgid "Network info"
+msgstr "Informações de rede"
+
msgid "Former Destinations"
msgstr "Destinos Anteriores"
@@ -2035,751 +2144,996 @@ msgstr "Cuidado! Radar!"
msgid "Please decrease your speed"
msgstr "Por favor, reduza a velocidade"
-msgid "partial match"
-msgstr "resultado parcial"
+msgid "Vehicle Position"
+msgstr "Posição do Veículo"
+
+msgid "Main menu"
+msgstr "Menu principal"
+
+msgid ""
+"Show\n"
+"Map"
+msgstr ""
+"Mostrar\n"
+"Mapa"
+
+msgid "Settings"
+msgstr "Configurações"
+
+msgid "Tools"
+msgstr "Ferramentas"
+
+msgid "Route"
+msgstr "Rota"
+
+msgid "About"
+msgstr "Sobre"
+
+msgid "Quit"
+msgstr "Sair"
+
+msgid "Actions"
+msgstr "Ações"
+
+msgid ""
+"Former\n"
+"Destinations"
+msgstr ""
+"Destinos\n"
+"Anteriores"
+
+msgid "Coordinates"
+msgstr "Coordenadas"
+
+msgid ""
+"Stop\n"
+"Navigation"
+msgstr ""
+"Parar\n"
+"Navegação"
+
+msgid "Display"
+msgstr "Exibição"
+
+msgid "Fullscreen"
+msgstr "Tela cheia"
+
+msgid "Window Mode"
+msgstr "Modo de Janela"
+
+msgid "Auto zoom"
+msgstr "Zoom automático"
+
+msgid "Manual zoom"
+msgstr "Zoom manual"
+
+msgid "Layers"
+msgstr "Camadas"
+
+msgid "Zoom to route"
+msgstr "Zoom para rota"
+
+msgid "Description"
+msgstr "Descrição"
+
+msgid ""
+"Drop last\n"
+"Waypoint"
+msgstr ""
+"Baixe o último\n"
+"Nó"
+
+msgid ""
+"Drop next\n"
+"Waypoint"
+msgstr ""
+"Baixe o próximo\n"
+"Nó"
+
+msgid "Satellite Status"
+msgstr "Estado do Satélite"
+
+msgid "NMEA Data"
+msgstr "Dados NMEA"
+
+msgid "car_shortest"
+msgstr "carro_pequeno"
+
+msgid "car_avoid_tolls"
+msgstr "Evitar pedágios"
+
+msgid "car_pedantic"
+msgstr "detalhe do carro"
+
+msgid "horse"
+msgstr "cavalo"
+
+msgid "Truck"
+msgstr "Caminhão"
+
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
+msgstr "Sim"
+
+#. Android resource: @strings/cancel
+msgid "Cancel"
+msgstr "Cancelar"
+
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
+msgstr "Navit iniciou"
+
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
+msgstr "Navit rodando"
+
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
+msgstr "Bem-vindo ao Navit"
+
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
+msgstr ""
+"Obrigado por instalar Navit!\n"
+"\n"
+"Para começar, selecione \"Importar mapas\" no menu para fazer o download de "
+"um mapa. Nota: O tamanho do arquivo do mapa pode ser grande (> 50MB) - uma "
+"conexão Wi-Fi é recomendada.\n"
+"\n"
+"Mapdata: (c) contribuidores OpenStreetMap\n"
+"\n"
+"Desfrute do Navit!"
+
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
+msgstr "OK"
+
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
+msgstr "Mais informações"
+
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
+msgstr "Aumentar zoom"
+
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
+msgstr "Diminuir zoom"
+
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
+msgstr "Baixar mapas"
+
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
+msgstr "Alternar POIs"
+
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
+msgstr "Sair do Navit"
+
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
+msgstr "Backup / Restauração"
+
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
+msgstr "Definir localização no mapa"
+
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
+msgstr "Rota até aqui"
+
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
+msgstr "Excluir este mapa?"
+
+#. Android resource: @strings/map_download_title
+msgid "Map download"
+msgstr "Baixa do mapa"
+
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
+msgstr "Baixando:"
+
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
+msgstr "ETA"
+
+#. Android resource: @strings/map_download_ready
+msgid "ready"
+msgstr "pronto"
+
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
+msgstr "Erro ao baixar mapa."
+
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
+msgstr "Baixa do mapa abortada"
+
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
+msgstr "Não há espaço livre suficiente"
+
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
+msgstr ""
+"Desculpe, atualmente não suportamos mapas acima do 3.8G no Android, "
+"selecione um menor."
+
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
+msgstr "Nenhum local. Reabrir após corrigir localização"
+
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
+msgstr "Mapas contendo localização atual"
+
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
+msgstr "Installed maps"
+
+#. Android resource: @strings/map_downloading
+msgid "downloading"
+msgstr "baixando"
+
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
+msgstr "Mídia selecionada para armazenamento de mapas não está disponível"
+
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
+msgstr "Erro escrevendo mapa!"
+
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
+msgstr ""
+"Novo local configurado para %s Reinicie o Navit para aplicar as alterações."
+
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
+msgstr ""
+"Localização atual no mapa %s não está disponível. Por favor, reinicie o "
+"Navit depois de conectar um cartão SD ou selecione um local diferente no "
+"mapa."
+
+#. Android resource: @strings/address_search_title
+msgid "Address search"
+msgstr "Pesquisar endereço"
+
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
+msgstr "Digite o destino"
+
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
+msgstr "Combine endereço parcial"
#. Android resource: @strings/address_search_button
msgid "Search"
msgstr "Pesquisar"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
+msgstr "Procurando..."
+
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
+msgstr "Endereço não encontrado"
+
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
+msgstr "Obtendo resultados de busca"
+
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
+msgstr "Carregando resultados da busca"
+
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
+msgstr "Nenhum resultado encontrado"
+
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
+msgstr "Nenhum texto digitado"
+
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
+msgstr "Definir destino para:"
+
#. Android resource: @strings/address_search_towns
msgid "Towns"
msgstr "Cidades"
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr "Rota até aqui"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
+msgstr "Escolha uma ação"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr "Dados do mapa (c) colaboradores OpenStreetMap, ODBL"
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
+msgstr "Por favor insira um cartão SD"
-msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
-msgstr ""
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
+msgstr "Cópia de Segurança em andamento..."
+
+#. Android resource: @strings/restoring
+msgid "Restoring..."
+msgstr "Restaurando ..."
+
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
+msgstr "Falha ao criar o diretório da cópia de segurança"
+
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
+msgstr "Cópia de segurança falhou"
-msgid "Downloaded maps"
-msgstr "Mapas baixados"
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
+msgstr "Não encontrou a cópia de segurança"
+
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
+msgstr "Falha ao restaurar"
+
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
+msgstr "Cópia de segurança bem-sucedida"
+#. Android resource: @strings/restore_successful_please_restart_navit
msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
+"Restauração bem-sucedida\n"
+"Por favor, reinicie Navit"
-msgid "Cancel"
-msgstr "Cancelar"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
+msgstr "Cópia de segurança não encontrada"
+
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
+msgstr "Falha na restauração"
-msgid "filenamePath"
+#. Android resource: @strings/select_backup
+msgid "Select backup"
+msgstr "Selecione a cópia de segurança"
+
+#. Android resource: @strings/backup
+msgid "Backup"
+msgstr "Cópia de segurança"
+
+#. Android resource: @strings/restore
+msgid "Restore"
+msgstr "Restaurar"
+
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
+msgstr "Faltam dados de texto para o sistema de fala"
+
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
+"Navit pode usar qualquer motor de conversão de texto para voz instalado em "
+"seu dispositivo. O motor atualmente selecionado informa que é incapaz de "
+"falar em seu idioma. Devemos pedir ao sistema que mostre a caixa de diálogo "
+"de download de voz?"
+#. Android resource: @strings/permissions_not_granted
msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
msgstr ""
+"Navit precisa de permissão para acessar GPS e ler o mapa. \n"
+"Se você mudar de idéia, por favor, reinicie o Navit e conceda as permissões"
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
+msgstr "Uma ou mais permissões não concedidas"
+
+#. Android resource: @strings/whole_planet
msgid "Whole Planet"
msgstr "Todo o Planeta"
+#. Android resource: @strings/africa
msgid "Africa"
msgstr "África"
+#. Android resource: @strings/canary_islands
msgid "Canary Islands"
msgstr "Ilhas Canárias"
+#. Android resource: @strings/asia
msgid "Asia"
msgstr "Ásia"
-msgid "Korea"
-msgstr "Coréia"
-
+#. Android resource: @strings/taiwan
msgid "Taiwan"
msgstr "Taiwan"
+#. Android resource: @strings/korea
+msgid "Korea"
+msgstr "Coréia"
+
+#. Android resource: @strings/uae_other
msgid "UAE+Other"
-msgstr "UAE + Outros"
+msgstr "Emirados Árabes Unidos+Outros"
+#. Android resource: @strings/oceania
msgid "Oceania"
msgstr "Oceania"
+#. Android resource: @strings/tasmania
msgid "Tasmania"
msgstr "Tasmânia"
+#. Android resource: @strings/victoria
msgid "Victoria"
msgstr "Vitória"
+#. Android resource: @strings/new_south_wales
msgid "New South Wales"
msgstr "Nova Gales do Sul"
+#. Android resource: @strings/europe
msgid "Europe"
msgstr "Europa"
+#. Android resource: @strings/western_europe
msgid "Western Europe"
msgstr "Europa Ocidental"
+#. Android resource: @strings/azores
msgid "Azores"
msgstr "Açores"
+#. Android resource: @strings/benelux
msgid "BeNeLux"
msgstr "Países Baixos"
+#. Android resource: @strings/alsace
msgid "Alsace"
msgstr "Alsácia"
+#. Android resource: @strings/aquitaine
msgid "Aquitaine"
msgstr "Aquitânia"
+#. Android resource: @strings/auvergne
msgid "Auvergne"
msgstr "Auvergne"
-msgid "Basse-Normandie"
-msgstr "Baixa-Normandia"
-
-msgid "Bourgogne"
-msgstr "Borgonha"
+#. Android resource: @strings/centre
+msgid "Centre"
+msgstr "Centro"
+#. Android resource: @strings/bretagne
msgid "Bretagne"
msgstr "Bretanha"
-msgid "Centre"
-msgstr "Centro"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
+msgstr "Borgonha"
+
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
+msgstr "Baixa-Normandia"
+#. Android resource: @strings/champagne_ardenne
msgid "Champagne-Ardenne"
msgstr "Champagne-Ardenne"
+#. Android resource: @strings/corse
msgid "Corse"
msgstr "Córsega"
+#. Android resource: @strings/franche_comte
msgid "Franche-Comte"
msgstr "Franche-Comte"
+#. Android resource: @strings/haute_normandie
msgid "Haute-Normandie"
msgstr "Alta-Normandia"
+#. Android resource: @strings/ile_de_france
msgid "Ile-de-France"
msgstr "Ile-deFrance"
+#. Android resource: @strings/languedoc_roussillon
msgid "Languedoc-Roussillon"
msgstr "Languedoc-Roussillon"
+#. Android resource: @strings/limousin
msgid "Limousin"
msgstr "Limousin"
+#. Android resource: @strings/lorraine
msgid "Lorraine"
msgstr "Lorena"
+#. Android resource: @strings/midi_pyrenees
msgid "Midi-Pyrenees"
msgstr "Médio Pirineus"
+#. Android resource: @strings/nord_pas_de_calais
msgid "Nord-pas-de-Calais"
msgstr "Nord-pas-de-Calais"
+#. Android resource: @strings/pays_de_la_loire
msgid "Pays-de-la-Loire"
msgstr "País do Loire"
+#. Android resource: @strings/picardie
msgid "Picardie"
msgstr "Picardia"
+#. Android resource: @strings/poitou_charentes
msgid "Poitou-Charentes"
msgstr "Poitou-Charentes"
+#. Android resource: @strings/provence_alpes_cote_d_azur
msgid "Provence-Alpes-Cote-d-Azur"
msgstr "Provença-Alpes-Costa Azul"
+#. Android resource: @strings/rhone_alpes
msgid "Rhone-Alpes"
msgstr "Rhone-Alpes"
+#. Android resource: @strings/baden_wuerttemberg
msgid "Baden-Wuerttemberg"
msgstr "Baden-Wuerttemberg"
+#. Android resource: @strings/bayern
msgid "Bayern"
msgstr "Bayern"
+#. Android resource: @strings/mittelfranken
msgid "Mittelfranken"
msgstr "Mittelfranken"
+#. Android resource: @strings/niederbayern
msgid "Niederbayern"
msgstr "Baixa Bavária"
+#. Android resource: @strings/oberbayern
msgid "Oberbayern"
msgstr "Alta Bavária"
+#. Android resource: @strings/oberfranken
msgid "Oberfranken"
msgstr "Alta Franconia"
+#. Android resource: @strings/oberpfalz
msgid "Oberpfalz"
msgstr "Alto Palatinado"
+#. Android resource: @strings/schwaben
msgid "Schwaben"
msgstr "Suábia"
+#. Android resource: @strings/unterfranken
msgid "Unterfranken"
msgstr "Baixa Francônia"
+#. Android resource: @strings/berlin
msgid "Berlin"
msgstr "Berlim"
+#. Android resource: @strings/brandenburg
msgid "Brandenburg"
msgstr "Brandenburg"
+#. Android resource: @strings/bremen
msgid "Bremen"
msgstr "Bremen"
+#. Android resource: @strings/hamburg
msgid "Hamburg"
msgstr "Hamburgo"
+#. Android resource: @strings/hessen
msgid "Hessen"
msgstr "Hesse"
+#. Android resource: @strings/mecklenburg_vorpommern
msgid "Mecklenburg-Vorpommern"
msgstr "Mecklenburgo-Pomerânia Ocidental"
+#. Android resource: @strings/niedersachsen
msgid "Niedersachsen"
msgstr "Baixa Saxônia"
+#. Android resource: @strings/nordrhein_westfalen
msgid "Nordrhein-westfalen"
msgstr "Renânia do Norte-Vestfália"
+#. Android resource: @strings/rheinland_pfalz
msgid "Rheinland-Pfalz"
msgstr "Renânia-Palatinado"
+#. Android resource: @strings/saarland
msgid "Saarland"
msgstr "Sarre"
+#. Android resource: @strings/sachsen_anhalt
msgid "Sachsen-Anhalt"
msgstr "Saxônia-Anhalt"
+#. Android resource: @strings/sachsen
msgid "Sachsen"
msgstr "Saxônia"
+#. Android resource: @strings/schleswig_holstein
msgid "Schleswig-Holstein"
msgstr "Schleswig-Holstein"
+#. Android resource: @strings/thueringen
msgid "Thueringen"
msgstr "Turíngia"
+#. Android resource: @strings/mallorca
msgid "Mallorca"
msgstr "Maiorca"
+#. Android resource: @strings/galicia
msgid "Galicia"
msgstr "Galicia"
+#. Android resource: @strings/scandinavia
msgid "Scandinavia"
msgstr "Escandinávia"
+#. Android resource: @strings/england
msgid "England"
msgstr "Inglaterra"
+#. Android resource: @strings/buckinghamshire
msgid "Buckinghamshire"
msgstr "Condado de Buckingham"
+#. Android resource: @strings/cambridgeshire
msgid "Cambridgeshire"
msgstr "Condado de Cambridge"
+#. Android resource: @strings/cumbria
msgid "Cumbria"
msgstr "Cumbria"
+#. Android resource: @strings/east_yorkshire_with_hull
msgid "East yorkshire with hull"
msgstr "Condado de York a leste do Hull"
+#. Android resource: @strings/essex
msgid "Essex"
msgstr "Essex"
+#. Android resource: @strings/herefordshire
msgid "Herefordshire"
msgstr "Condado de Hereford"
+#. Android resource: @strings/kent
msgid "Kent"
msgstr "Kent"
+#. Android resource: @strings/lancashire
msgid "Lancashire"
msgstr "condado de Lanca"
+#. Android resource: @strings/leicestershire
msgid "Leicestershire"
msgstr "Condado de Leichester"
+#. Android resource: @strings/norfolk
msgid "Norfolk"
msgstr "Norfolk"
+#. Android resource: @strings/nottinghamshire
msgid "Nottinghamshire"
msgstr "Condado de Nottinham"
+#. Android resource: @strings/oxfordshire
msgid "Oxfordshire"
msgstr "Condado de Oxford"
+#. Android resource: @strings/shropshire
msgid "Shropshire"
msgstr "Condado de Shrop"
+#. Android resource: @strings/somerset
msgid "Somerset"
msgstr "Somerset"
+#. Android resource: @strings/south_yorkshire
msgid "South yorkshire"
msgstr "Condado York do Sul"
+#. Android resource: @strings/suffolk
msgid "Suffolk"
msgstr "Suffolk"
+#. Android resource: @strings/surrey
msgid "Surrey"
msgstr "Surrey"
+#. Android resource: @strings/wiltshire
msgid "Wiltshire"
msgstr "condado de Wilt"
+#. Android resource: @strings/scotland
msgid "Scotland"
msgstr "Escócia"
+#. Android resource: @strings/wales
msgid "Wales"
msgstr "País de Gales"
+#. Android resource: @strings/crete
msgid "Crete"
msgstr "Creta"
+#. Android resource: @strings/north_america
msgid "North America"
msgstr "América do Norte"
+#. Android resource: @strings/alaska
msgid "Alaska"
msgstr "Alasca"
+#. Android resource: @strings/hawaii
msgid "Hawaii"
msgstr "Havaí"
+#. Android resource: @strings/usa
msgid "USA"
msgstr "EUA"
-msgid " (except Alaska and Hawaii)"
-msgstr " (exceto Alasca e Havaí)"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
+msgstr "(exceto Alasca e Havaí)"
+#. Android resource: @strings/midwest
msgid "Midwest"
msgstr "Meio Oeste"
+#. Android resource: @strings/michigan
msgid "Michigan"
msgstr "Michigan"
+#. Android resource: @strings/ohio
msgid "Ohio"
msgstr "Ohio"
+#. Android resource: @strings/northeast
msgid "Northeast"
msgstr "Nordeste"
+#. Android resource: @strings/massachusetts
msgid "Massachusetts"
msgstr "Massachusetts"
+#. Android resource: @strings/vermont
msgid "Vermont"
msgstr "Vermont"
+#. Android resource: @strings/pacific
msgid "Pacific"
msgstr "Pacífico"
+#. Android resource: @strings/south
msgid "South"
msgstr "Sul"
+#. Android resource: @strings/arkansas
msgid "Arkansas"
msgstr "Arkansas"
+#. Android resource: @strings/district_of_columbia
msgid "District of Columbia"
msgstr "Distrito de Columbia"
+#. Android resource: @strings/florida
msgid "Florida"
msgstr "Flórida"
+#. Android resource: @strings/louisiana
msgid "Louisiana"
msgstr "Luisiana"
+#. Android resource: @strings/maryland
msgid "Maryland"
msgstr "Maryland"
+#. Android resource: @strings/mississippi
msgid "Mississippi"
msgstr "Mississippi"
+#. Android resource: @strings/oklahoma
msgid "Oklahoma"
msgstr "Oklahoma"
+#. Android resource: @strings/texas
msgid "Texas"
msgstr "Texas"
+#. Android resource: @strings/virginia
msgid "Virginia"
msgstr "Virginia"
+#. Android resource: @strings/west_virginia
msgid "West Virginia"
msgstr "Virgínia Ocidental"
+#. Android resource: @strings/west
msgid "West"
msgstr "Oeste"
+#. Android resource: @strings/arizona
msgid "Arizona"
msgstr "Arizona"
+#. Android resource: @strings/california
msgid "California"
msgstr "Califórnia"
+#. Android resource: @strings/colorado
msgid "Colorado"
msgstr "Colorado"
+#. Android resource: @strings/idaho
msgid "Idaho"
msgstr "Idaho"
+#. Android resource: @strings/montana
msgid "Montana"
msgstr "Montana"
+#. Android resource: @strings/new_mexico
msgid "New Mexico"
msgstr "Novo México"
+#. Android resource: @strings/nevada
msgid "Nevada"
msgstr "Nevada"
+#. Android resource: @strings/oregon
msgid "Oregon"
msgstr "Oregon"
+#. Android resource: @strings/utah
msgid "Utah"
msgstr "Utah"
+#. Android resource: @strings/washington_state
msgid "Washington State"
msgstr "Washington"
+#. Android resource: @strings/south_middle_america
msgid "South+Middle America"
msgstr "Sul + América Central"
+#. Android resource: @strings/guyane_francaise
msgid "Guyane Francaise"
msgstr "Guiana Francesa"
-msgid "downloading"
-msgstr "baixando"
-
-#. Android resource: @strings/map_download_ready
-msgid "ready"
-msgstr "pronto"
-
-msgid "Media selected for map storage is not available"
-msgstr ""
-
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
-msgstr "Não há espaço livre suficiente"
-
-msgid "Error downloading map!"
-msgstr "Erro ao baixar o mapa!"
-
-msgid "Error writing map!"
-msgstr "Erro escrevendo mapa!"
-
-msgid "Map download aborted!"
-msgstr "Baixa do mapa abortada!"
-
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
-msgstr "ETA"
-
-#. Android resource: @strings/map_download_title
-msgid "Map download"
-msgstr "Baixa do mapa"
-
-msgid "Vehicle Position"
-msgstr "Posição do Veículo"
-
-msgid "Main menu"
-msgstr "Menu principal"
-
-msgid ""
-"Show\n"
-"Map"
-msgstr ""
-"Mostrar\n"
-"Mapa"
-
-msgid "Settings"
-msgstr "Configurações"
-
-msgid "Tools"
-msgstr "Ferramentas"
-
-msgid "Route"
-msgstr "Rota"
-
-msgid "About"
-msgstr "Sobre"
-
-msgid "Quit"
-msgstr "Sair"
-
-msgid "Actions"
-msgstr "Ações"
-
-msgid ""
-"Former\n"
-"Destinations"
-msgstr ""
-"Destinos\n"
-"Anteriores"
-
-msgid "Coordinates"
-msgstr "Coordenadas"
-
-msgid ""
-"Stop\n"
-"Navigation"
-msgstr ""
-"Parar\n"
-"Navegação"
-
-msgid "Display"
-msgstr "Exibição"
-
-msgid "Fullscreen"
-msgstr "Tela cheia"
-
-msgid "Window Mode"
-msgstr "Modo de Janela"
-
-msgid "Description"
-msgstr "Descrição"
-
-msgid ""
-"Drop last \n"
-"Waypoint"
-msgstr ""
-"Remover último\n"
-"Ponto"
-
-msgid ""
-"Drop next \n"
-"Waypoint"
-msgstr ""
-"Remover próximo\n"
-"Ponto"
-
-msgid "Satellite Status"
-msgstr "Estado do Satélite"
-
-msgid "NMEA Data"
-msgstr "Dados NMEA"
-
-msgid "car_shortest"
-msgstr "carro_pequeno"
-
-msgid "car_avoid_tolls"
-msgstr "Evitar pedágios"
-
-msgid "car_pedantic"
-msgstr "detalhe do carro"
-
-msgid "horse"
-msgstr "cavalo"
-
-msgid "Truck"
-msgstr "Caminhão"
-
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
-msgstr "Sim"
-
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
-msgstr "Navit iniciou"
-
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
-msgstr "Navit rodando"
-
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
-msgstr "Bem-vindo ao Navit"
-
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
-msgstr ""
-"Obrigado por instalar Navit!\n"
-"\n"
-"Para começar, selecione \"Importar mapas\" no menu para fazer o download de "
-"um mapa. Nota: O tamanho do arquivo do mapa pode ser grande (> 50MB) - uma "
-"conexão Wi-Fi é recomendada.\n"
-"\n"
-"Mapdata: (c) contribuidores OpenStreetMap\n"
-"\n"
-"Desfrute do Navit!"
-
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
-msgstr "OK"
-
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
-msgstr "Mais informações"
-
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
-msgstr "Aumentar zoom"
-
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
-msgstr "Diminuir zoom"
-
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
-msgstr "Baixar mapas"
-
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
-msgstr "Alternar POIs"
-
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
-msgstr "Sair do Navit"
-
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
-msgstr "Backup / Restauração"
-
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
-msgstr ""
-
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
-msgstr "Excluir este mapa?"
-
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
-msgstr "Baixando:"
-
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
-msgstr "Erro ao baixar mapa."
-
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
-msgstr "Baixa do mapa abortada"
-
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
-msgstr "Nenhum local. Reabrir após corrigir localização"
-
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
-msgstr "Mapas contendo localização atual"
-
-#. Android resource: @strings/address_search_title
-msgid "Address search"
-msgstr "Pesquisar endereço"
-
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
-msgstr "Digite o destino"
-
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
-msgstr "Combine endereço parcial"
-
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
-msgstr "Procurando..."
-
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
-msgstr "Endereço não encontrado"
-
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
-msgstr "Obtendo resultados de busca"
-
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
-msgstr "Carregando resultados da busca"
-
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
-msgstr "Nenhum resultado encontrado"
+#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Rota %4.0fkm TEC %02d:%02d"
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
-msgstr "Nenhum texto digitado"
+#~ msgid "No config file navit.xml, navit.xml.local found\n"
+#~ msgstr ""
+#~ "Nenhum arquivo de configuração navit.xml, navit.xml.local foi encontrado\n"
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
-msgstr "Definir destino para:"
+#, c-format
+#~ msgid "Error parsing config file '%s': %s\n"
+#~ msgstr "Erro ao analizar o arquivo de configuração '%s': %s\n"
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
-msgstr "Escolha uma ação"
+#, c-format
+#~ msgid "Using config file '%s'\n"
+#~ msgstr "Utilizando arquivo de configuração '%s'\n"
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
-msgstr "Por favor insira um cartão SD"
+#~ msgid ""
+#~ "Internal initialization failed, exiting. Check previous error messages.\n"
+#~ msgstr ""
+#~ "Inicialização interna falhou, finalizando. Verifique mensagens de erro "
+#~ "anteriores.\n"
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
-msgstr "Cópia de Segurança em andamento..."
+#~ msgid "Downloaded maps"
+#~ msgstr "Mapas baixados"
-#. Android resource: @strings/restoring
-msgid "Restoring..."
-msgstr "Restaurando ..."
+#~ msgid "Map data (c) OpenStreetMap contributors, ODBL"
+#~ msgstr "Dados do mapa (c) colaboradores OpenStreetMap, ODBL"
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
-msgstr "Falha ao criar o diretório da cópia de segurança"
+#~ msgid "partial match"
+#~ msgstr "resultado parcial"
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
-msgstr "Cópia de segurança falhou"
+#~ msgid " (except Alaska and Hawaii)"
+#~ msgstr " (exceto Alasca e Havaí)"
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
-msgstr "Não encontrou a cópia de segurança"
+#~ msgid "Error downloading map!"
+#~ msgstr "Erro ao baixar o mapa!"
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
-msgstr "Falha ao restaurar"
+#~ msgid "Map download aborted!"
+#~ msgstr "Baixa do mapa abortada!"
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
-msgstr "Cópia de segurança bem-sucedida"
+#, c-format
+#~ msgid "Error: No configuration found in config file '%s'\n"
+#~ msgstr "Erro: Nenhuma configuração encontrada no arquivo '%s'\n"
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
-msgstr ""
-"Restauração bem-sucedida\n"
-"Por favor, reinicie Navit"
+#~ msgid "Distance from screen center (km)"
+#~ msgstr "Distância do centro da tela (km)"
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
-msgstr "Cópia de segurança não encontrada"
+#, c-format
+#~ msgid "Set destination to %ld, %ld \n"
+#~ msgstr "Definir destino para %ld, %ld \n"
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
-msgstr "Falha na restauração"
+#, c-format
+#~ msgid "Set next visit to %ld, %ld \n"
+#~ msgstr "Definir próxima parada parao %ld, %ld \n"
-#. Android resource: @strings/select_backup
-msgid "Select backup"
-msgstr "Selecione a cópia de segurança"
+#, c-format
+#~ msgid "Set map to %ld, %ld \n"
+#~ msgstr "Definir mapa para o %ld, %ld \n"
-#. Android resource: @strings/backup
-msgid "Backup"
-msgstr "Cópia de segurança"
+#~ msgid "Select a distance to look for (km)"
+#~ msgstr "Selecione a distância para pesquisar (km)"
-#. Android resource: @strings/restore
-msgid "Restore"
-msgstr "Restaurar"
+#~ msgid "Distance(m)"
+#~ msgstr "Distância (m)"
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
-msgstr ""
+#~ msgid ""
+#~ "Drop last \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Remover último\n"
+#~ "Ponto"
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
-msgstr ""
+#~ msgid ""
+#~ "Drop next \n"
+#~ "Waypoint"
+#~ msgstr ""
+#~ "Remover próximo\n"
+#~ "Ponto"
#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
#~ msgstr "então deixe a rotatória na %1$s %2$s"
+
+#~ msgid "filenamePath"
+#~ msgstr "nome do aquivoPath"
+
+#~ msgid ""
+#~ "New location set to %s\n"
+#~ "Restart Navit to apply the changes."
+#~ msgstr ""
+#~ "Nova localização definida como %s\n"
+#~ "Reinicie o Navit para aplicar as alterações."
+
+#~ msgid ""
+#~ "Current map location %s is not available\n"
+#~ "Please restart Navit after you attach an SD card or select a different map "
+#~ "location."
+#~ msgstr ""
+#~ "O atual localização %s não está disponível no mapa \n"
+#~ "Reinicie o Navit depois de plugar um cartão SD ou selecione outra "
+#~ "localização no mapa."
diff --git a/po/ro.po.in b/po/ro.po.in
index 28ac5f311..ad18c4e34 100644
--- a/po/ro.po.in
+++ b/po/ro.po.in
@@ -363,7 +363,7 @@ msgstr "Întoarceţi %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1676,7 +1676,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1935,10 +1935,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/ru.po.in b/po/ru.po.in
index 0f1944e1d..224da3412 100644
--- a/po/ru.po.in
+++ b/po/ru.po.in
@@ -377,7 +377,7 @@ msgstr "%1$s разворот направо"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "следуйте"
@@ -1692,7 +1692,7 @@ msgstr "Такси"
msgid "Shopping"
msgstr "Магазин"
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr "Расстояние от центра экрана (км)"
#, c-format
@@ -1951,10 +1951,10 @@ msgstr "Маршрутные точки"
msgid "Enter Coordinates"
msgstr "Введите координаты"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/sc.po.in b/po/sc.po.in
index 4c3fffbe6..c3362c962 100644
--- a/po/sc.po.in
+++ b/po/sc.po.in
@@ -351,7 +351,7 @@ msgstr "Torra in daesecusu %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "sichi"
@@ -1664,7 +1664,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1923,10 +1923,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/si.po.in b/po/si.po.in
index 890eb0644..d7bf212ac 100644
--- a/po/si.po.in
+++ b/po/si.po.in
@@ -350,7 +350,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1663,7 +1663,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1922,10 +1922,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/sk.po.in b/po/sk.po.in
index b11a80e2e..4d0eb0ce1 100644
--- a/po/sk.po.in
+++ b/po/sk.po.in
@@ -362,7 +362,7 @@ msgstr "Otočte sa %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1678,7 +1678,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1937,10 +1937,10 @@ msgstr "Body trasy"
msgid "Enter Coordinates"
msgstr "Vložte súradnice"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/sl.po.in b/po/sl.po.in
index 703178d83..bf1d34e09 100644
--- a/po/sl.po.in
+++ b/po/sl.po.in
@@ -359,7 +359,7 @@ msgstr "Obrnite čim %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1672,7 +1672,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1931,10 +1931,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/sq.po.in b/po/sq.po.in
index 58850e77b..a2ef1b237 100644
--- a/po/sq.po.in
+++ b/po/sq.po.in
@@ -349,7 +349,7 @@ msgstr "Bëni një U-kthim %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "ndiqni"
@@ -1662,7 +1662,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1921,10 +1921,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/sr.po.in b/po/sr.po.in
index 00ec61b1d..fe3ef64dc 100644
--- a/po/sr.po.in
+++ b/po/sr.po.in
@@ -1,5 +1,5 @@
# Serbian translations for navit
-# Copyright (C) 2006-2016 The Navit Team
+# Copyright (C) 2006-2018 The Navit Team
# This file is distributed under the same license as the navit package.
# Many thanks to the contributors of this translation:
# Ivan Janjić https://launchpad.net/~milandd
@@ -11,9 +11,9 @@
msgid ""
msgstr ""
-"Project-Id-Version: navit 0.5.0\n"
+"Project-Id-Version: navit 0.5.1\n"
"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: 2015-07-19 04:00+0000\n"
+"PO-Revision-Date: 2018-05-10 17:33+0000\n"
"Last-Translator: Саша Петровић <salepetronije@gmail.com>\n"
"Language-Team: српски <xfce4@xfce4.org>\n"
"MIME-Version: 1.0\n"
@@ -361,7 +361,7 @@ msgstr "Променити смер %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -390,9 +390,15 @@ msgstr "Наредба"
msgid "Length"
msgstr "Дужина"
+msgid "mi"
+msgstr ""
+
msgid "km"
msgstr "km"
+msgid "feet"
+msgstr ""
+
msgid "m"
msgstr "m"
@@ -453,6 +459,7 @@ msgid "Anguilla"
msgstr "Ангвила"
#. 008
+#. Android resource: @strings/albania
msgid "Albania"
msgstr "Албанија"
@@ -465,6 +472,7 @@ msgid "Netherlands Antilles"
msgstr "Холандски Антили"
#. 024
+#. Android resource: @strings/angola
msgid "Angola"
msgstr "Ангола"
@@ -473,6 +481,7 @@ msgid "Antarctica"
msgstr "Антарктик"
#. 032
+#. Android resource: @strings/argentina
msgid "Argentina"
msgstr "Аргентина"
@@ -481,10 +490,12 @@ msgid "American Samoa"
msgstr "Америчка Самоа"
#. 040
+#. Android resource: @strings/austria
msgid "Austria"
msgstr "Аустрија"
#. 036
+#. Android resource: @strings/australia
msgid "Australia"
msgstr "Аустралија"
@@ -497,10 +508,12 @@ msgid "Aland Islands"
msgstr "Оландска острва"
#. 031
+#. Android resource: @strings/azerbaijan
msgid "Azerbaijan"
msgstr "Азербејџан"
#. 070
+#. Android resource: @strings/bosnia_and_herzegovina
msgid "Bosnia and Herzegovina"
msgstr "Босна и Херцеговина"
@@ -513,6 +526,7 @@ msgid "Bangladesh"
msgstr "Бангладеш"
#. 056
+#. Android resource: @strings/belgium
msgid "Belgium"
msgstr "Белгија"
@@ -521,6 +535,7 @@ msgid "Burkina Faso"
msgstr "Буркина Фасо"
#. 100
+#. Android resource: @strings/bulgaria
msgid "Bulgaria"
msgstr "Бугарска"
@@ -529,6 +544,7 @@ msgid "Bahrain"
msgstr "Бахреин"
#. 108
+#. Android resource: @strings/burundi
msgid "Burundi"
msgstr "Бурунди"
@@ -549,6 +565,7 @@ msgid "Brunei Darussalam"
msgstr "Брунеј"
#. 068
+#. Android resource: @strings/bolivia
msgid "Bolivia"
msgstr "Боливија"
@@ -557,6 +574,7 @@ msgid "Bonaire, Sint Eustatius and Saba"
msgstr ""
#. 076
+#. Android resource: @strings/brazil
msgid "Brazil"
msgstr "Бразил"
@@ -573,10 +591,12 @@ msgid "Bouvet Island"
msgstr "Бувеова острва"
#. 072
+#. Android resource: @strings/botswana
msgid "Botswana"
msgstr "Боцвана"
#. 112
+#. Android resource: @strings/belarus
msgid "Belarus"
msgstr "Белорусија"
@@ -585,6 +605,7 @@ msgid "Belize"
msgstr "Белизе"
#. 124
+#. Android resource: @strings/canada
msgid "Canada"
msgstr "Канада"
@@ -593,6 +614,7 @@ msgid "Cocos (Keeling) Islands"
msgstr "Kokosova ostrva"
#. 180
+#. Android resource: @strings/congo
msgid "Congo, Democratic Republic of the"
msgstr "Демократска република Конго"
@@ -605,10 +627,12 @@ msgid "Congo"
msgstr "Конго"
#. 756
+#. Android resource: @strings/switzerland
msgid "Switzerland"
msgstr "Швајцарска"
#. 384
+#. Android resource: @strings/cotedivoire
msgid "Cote d'Ivoire"
msgstr "Обала Слоноваче"
@@ -617,6 +641,7 @@ msgid "Cook Islands"
msgstr "Кукова острва"
#. 152
+#. Android resource: @strings/chile
msgid "Chile"
msgstr "Чиле"
@@ -625,10 +650,12 @@ msgid "Cameroon"
msgstr "Камерун"
#. 156
+#. Android resource: @strings/china
msgid "China"
msgstr "Кина"
#. 170
+#. Android resource: @strings/colombia
msgid "Colombia"
msgstr "Колумбија"
@@ -637,6 +664,7 @@ msgid "Costa Rica"
msgstr "Костарика"
#. 192
+#. Android resource: @strings/cuba
msgid "Cuba"
msgstr "Куба"
@@ -653,14 +681,17 @@ msgid "Christmas Island"
msgstr "Божићна острва"
#. 196
+#. Android resource: @strings/cyprus
msgid "Cyprus"
msgstr "Кипар"
#. 203
+#. Android resource: @strings/czech_republic
msgid "Czech Republic"
msgstr "Чешка"
#. 276
+#. Android resource: @strings/germany
msgid "Germany"
msgstr "Немачка"
@@ -669,6 +700,7 @@ msgid "Djibouti"
msgstr "Џибути"
#. 208
+#. Android resource: @strings/denmark
msgid "Denmark"
msgstr "Данска"
@@ -677,6 +709,7 @@ msgid "Dominica"
msgstr "Доминика"
#. 214
+#. Android resource: @strings/dominican_republic
msgid "Dominican Republic"
msgstr "Доминиканска Република"
@@ -685,10 +718,12 @@ msgid "Algeria"
msgstr "Алжир"
#. 218
+#. Android resource: @strings/ecuador
msgid "Ecuador"
msgstr "Еквадор"
#. 233
+#. Android resource: @strings/estonia
msgid "Estonia"
msgstr "Естонија"
@@ -705,14 +740,17 @@ msgid "Eritrea"
msgstr "Еритреја"
#. 724
+#. Android resource: @strings/spain
msgid "Spain"
msgstr "Шпанија"
#. 231
+#. Android resource: @strings/ethiopia
msgid "Ethiopia"
msgstr "Етиопија"
#. 246
+#. Android resource: @strings/finland
msgid "Finland"
msgstr "Финска"
@@ -729,10 +767,12 @@ msgid "Micronesia, Federated States of"
msgstr "Микронезија, Федеративне државе"
#. 234
+#. Android resource: @strings/faroe_islands
msgid "Faroe Islands"
msgstr "Фарска острва"
#. 250
+#. Android resource: @strings/france
msgid "France"
msgstr "Француска"
@@ -741,6 +781,7 @@ msgid "Gabon"
msgstr "Габон"
#. 826
+#. Android resource: @strings/united_kingdom
msgid "United Kingdom"
msgstr "Уједињено краљевство"
@@ -777,6 +818,7 @@ msgid "Gambia"
msgstr "Гамбија"
#. 324
+#. Android resource: @strings/guinea
msgid "Guinea"
msgstr "Гвинеја"
@@ -789,6 +831,7 @@ msgid "Equatorial Guinea"
msgstr "Екваторијална Гвинеја"
#. 300
+#. Android resource: @strings/greece
msgid "Greece"
msgstr "Грчка"
@@ -809,6 +852,7 @@ msgid "Guinea-Bissau"
msgstr "Гвинеја Бисао"
#. 328
+#. Android resource: @strings/guyana
msgid "Guyana"
msgstr "Гвајана"
@@ -825,26 +869,32 @@ msgid "Honduras"
msgstr "Хондурас"
#. 191
+#. Android resource: @strings/croatia
msgid "Croatia"
msgstr "Хрватска"
#. 332
+#. Android resource: @strings/haiti
msgid "Haiti"
msgstr "Хаити"
#. 348
+#. Android resource: @strings/hungary
msgid "Hungary"
msgstr "Мађарска"
#. 360
+#. Android resource: @strings/indonesia
msgid "Indonesia"
msgstr "Индонезија"
#. 372
+#. Android resource: @strings/ireland
msgid "Ireland"
msgstr "Ирска"
#. 376
+#. Android resource: @strings/israel
msgid "Israel"
msgstr "Израел"
@@ -853,6 +903,7 @@ msgid "Isle of Man"
msgstr "Острво Ман"
#. 356
+#. Android resource: @strings/india
msgid "India"
msgstr "Индија"
@@ -861,18 +912,22 @@ msgid "British Indian Ocean Territory"
msgstr "Британска Индијска Океанска Територија"
#. 368
+#. Android resource: @strings/iraq
msgid "Iraq"
msgstr "Ирак"
#. 364
+#. Android resource: @strings/iran
msgid "Iran, Islamic Republic of"
msgstr "Иран, Исламска Република"
#. 352
+#. Android resource: @strings/iceland
msgid "Iceland"
msgstr "Исланд"
#. 380
+#. Android resource: @strings/italy
msgid "Italy"
msgstr "Италија"
@@ -881,6 +936,7 @@ msgid "Jersey"
msgstr "Џерси"
#. 388
+#. Android resource: @strings/jamaica
msgid "Jamaica"
msgstr "Јамајка"
@@ -889,14 +945,17 @@ msgid "Jordan"
msgstr "Јордан"
#. 392
+#. Android resource: @strings/japan
msgid "Japan"
msgstr "Јапан"
#. 404
+#. Android resource: @strings/kenya
msgid "Kenya"
msgstr "Кенија"
#. 417
+#. Android resource: @strings/kyrgyzsyan
msgid "Kyrgyzstan"
msgstr "Киргистан"
@@ -933,6 +992,7 @@ msgid "Cayman Islands"
msgstr "Кајманска острва"
#. 398
+#. Android resource: @strings/kazakhstan
msgid "Kazakhstan"
msgstr "Казахстан"
@@ -957,26 +1017,32 @@ msgid "Sri Lanka"
msgstr "Шри Ланка"
#. 430
+#. Android resource: @strings/liberia
msgid "Liberia"
msgstr "Либерија"
#. 426
+#. Android resource: @strings/lesotho
msgid "Lesotho"
msgstr "Лесото"
#. 440
+#. Android resource: @strings/lithuania
msgid "Lithuania"
msgstr "Литванија"
#. 442
+#. Android resource: @strings/luxembourg
msgid "Luxembourg"
msgstr "Луксембург"
#. 428
+#. Android resource: @strings/latvia
msgid "Latvia"
msgstr "Летонија"
#. 434
+#. Android resource: @strings/libya
msgid "Libya"
msgstr "Либија"
@@ -1001,6 +1067,7 @@ msgid "Saint Martin (French part)"
msgstr "Свети Мартин (француски део)"
#. 450
+#. Android resource: @strings/madagascar
msgid "Madagascar"
msgstr "Мадагаскар"
@@ -1021,6 +1088,7 @@ msgid "Myanmar"
msgstr "Мијанмар"
#. 496
+#. Android resource: @strings/mongolia
msgid "Mongolia"
msgstr "Монголија"
@@ -1061,10 +1129,12 @@ msgid "Malawi"
msgstr "Малави"
#. 484
+#. Android resource: @strings/mexico
msgid "Mexico"
msgstr "Мексико"
#. 458
+#. Android resource: @strings/malaysia
msgid "Malaysia"
msgstr "Малезија"
@@ -1073,10 +1143,12 @@ msgid "Mozambique"
msgstr "Мозамбик"
#. 516
+#. Android resource: @strings/namibia
msgid "Namibia"
msgstr "Намибија"
#. 540
+#. Android resource: @strings/new_caledonia
msgid "New Caledonia"
msgstr "Нова Каледонија"
@@ -1097,6 +1169,7 @@ msgid "Nicaragua"
msgstr "Никарагва"
#. 528
+#. Android resource: @strings/netherlands
msgid "Netherlands"
msgstr "Холандија"
@@ -1105,6 +1178,7 @@ msgid "Norway"
msgstr "Норвешка"
#. 524
+#. Android resource: @strings/nepal
msgid "Nepal"
msgstr "Непал"
@@ -1117,6 +1191,7 @@ msgid "Niue"
msgstr "Нијуе"
#. 554
+#. Android resource: @strings/newzealand
msgid "New Zealand"
msgstr "Нови Зеланд"
@@ -1129,6 +1204,7 @@ msgid "Panama"
msgstr "Панама"
#. 604
+#. Android resource: @strings/peru
msgid "Peru"
msgstr "Перу"
@@ -1141,14 +1217,17 @@ msgid "Papua New Guinea"
msgstr "Папуа Нова Гвинеја"
#. 608
+#. Android resource: @strings/philippines
msgid "Philippines"
msgstr "Филипини"
#. 586
+#. Android resource: @strings/pakistan
msgid "Pakistan"
msgstr "Пакистан"
#. 616
+#. Android resource: @strings/poland
msgid "Poland"
msgstr "Пољска"
@@ -1169,6 +1248,7 @@ msgid "Palestinian Territory, Occupied"
msgstr "Палестинска Територија, Окупирана"
#. 620
+#. Android resource: @strings/portugal
msgid "Portugal"
msgstr "Португал"
@@ -1177,6 +1257,7 @@ msgid "Palau"
msgstr "Палау"
#. 600
+#. Android resource: @strings/paraguay
msgid "Paraguay"
msgstr "Парагвај"
@@ -1185,10 +1266,12 @@ msgid "Qatar"
msgstr "Катар"
#. 638
+#. Android resource: @strings/reunion
msgid "Reunion"
msgstr "Реинион"
#. 642
+#. Android resource: @strings/romania
msgid "Romania"
msgstr "Румунија"
@@ -1197,14 +1280,17 @@ msgid "Serbia"
msgstr "Србија"
#. 643
+#. Android resource: @strings/russian_federation
msgid "Russian Federation"
msgstr "Руска федерација"
#. 646
+#. Android resource: @strings/rwanda
msgid "Rwanda"
msgstr "Руанда"
#. 682
+#. Android resource: @strings/saudi_arabia
msgid "Saudi Arabia"
msgstr "Саудијска Арабија"
@@ -1225,6 +1311,7 @@ msgid "Sweden"
msgstr "Шведска"
#. 702
+#. Android resource: @strings/singapore
msgid "Singapore"
msgstr "Сингапур"
@@ -1241,6 +1328,7 @@ msgid "Svalbard and Jan Mayen"
msgstr "Свалбард и Јан Мајен"
#. 703
+#. Android resource: @strings/slovakia
msgid "Slovakia"
msgstr "Словачка"
@@ -1261,6 +1349,7 @@ msgid "Somalia"
msgstr "Сомалија"
#. 740
+#. Android resource: @strings/suriname
msgid "Suriname"
msgstr "Суринам"
@@ -1305,6 +1394,7 @@ msgid "Togo"
msgstr "Того"
#. 764
+#. Android resource: @strings/thailand
msgid "Thailand"
msgstr "Тајланд"
@@ -1321,6 +1411,7 @@ msgid "Timor-Leste"
msgstr "Источни Тимор"
#. 795
+#. Android resource: @strings/turkmenistan
msgid "Turkmenistan"
msgstr "Туркменистан"
@@ -1333,6 +1424,7 @@ msgid "Tonga"
msgstr "Тонга"
#. 792
+#. Android resource: @strings/turkey
msgid "Turkey"
msgstr "Турска"
@@ -1349,14 +1441,17 @@ msgid "Taiwan, Province of China"
msgstr "Тајван, Кинеска Провинција"
#. 834
+#. Android resource: @strings/tanzania
msgid "Tanzania, United Republic of"
msgstr "Танзанија, Уједињена република"
#. 804
+#. Android resource: @strings/ukraine
msgid "Ukraine"
msgstr "Украјна"
#. 800
+#. Android resource: @strings/uganda
msgid "Uganda"
msgstr "Уганда"
@@ -1369,6 +1464,7 @@ msgid "United States"
msgstr "Sjedinjene Američke Države"
#. 858
+#. Android resource: @strings/uruguay
msgid "Uruguay"
msgstr "Уругвај"
@@ -1385,6 +1481,7 @@ msgid "Saint Vincent and the Grenadines"
msgstr "Свети Винсент и Гренадини"
#. 862
+#. Android resource: @strings/venezuela
msgid "Venezuela"
msgstr "Венецуела"
@@ -1421,6 +1518,7 @@ msgid "Mayotte"
msgstr "Мајот"
#. 710
+#. Android resource: @strings/south_africa
msgid "South Africa"
msgstr "Јужноафричка република"
@@ -1448,28 +1546,25 @@ msgid ""
msgstr ""
#. We have not found an existing config file from all possibilities
-msgid "No config file navit.xml, navit.xml.local found\n"
-msgstr ""
-"Нема датотеке подешавања navit.xml, navit.xml.сопствени је пронађен\n"
+msgid "No config file navit.xml, navit.xml.local found"
+msgstr "Нема датотеке подешавања navit.xml, navit.xml.сопствени је пронађен"
#, c-format
-msgid "Error parsing config file '%s': %s\n"
-msgstr ""
-"Десила се грешка приликом рашчлањивања датотеке подешавања „%s“: %s\n"
+msgid "Error parsing config file '%s': %s"
+msgstr "Десила се грешка приликом рашчлањивања датотеке подешавања „%s“: %s"
#, c-format
-msgid "Using config file '%s'\n"
-msgstr "Користим датотеку подешавања „%s“\n"
+msgid "Using config file '%s'"
+msgstr "Користим датотеку подешавања „%s“"
#, c-format
-msgid "Error: No configuration found in config file '%s'\n"
-msgstr "ГРЕШКА: Нису пронађене поставке у датотеци подешавања „%s“\n"
+msgid "Error: No configuration found in config file '%s'"
+msgstr "ГРЕШКА: Нису пронађене поставке у датотеци подешавања „%s"
msgid ""
-"Internal initialization failed, exiting. Check previous error messages.\n"
+"Internal initialization failed, exiting. Check previous error messages."
msgstr ""
-"Није успело унутрашње покретање, излазим. Проверите претходне поруке "
-"грешака.\n"
+"Није успело унутрашње покретање, излазим. Проверите претходне поруке грешака."
msgid "unknown street"
msgstr "непозната улица"
@@ -1609,6 +1704,9 @@ msgstr "Прикажи _показивач положаја"
msgid "_Lock on Road"
msgstr "Прати пут"
+msgid "_Follow Vehicle"
+msgstr ""
+
msgid "_Keep orientation to the North"
msgstr "_Држи усмерење према северу"
@@ -1678,24 +1776,24 @@ msgstr "Такси"
msgid "Shopping"
msgstr "Куповина"
-msgid "Distance from screen center (km)"
-msgstr "Растојање од средишта екрана (km)"
+msgid "Select a search radius from screen center"
+msgstr "Растојање од средишта екрана"
#, c-format
msgid "POI %s. %s"
msgstr "Занимљива тачка %s. %s"
#, c-format
-msgid "Set destination to %ld, %ld \n"
-msgstr "Постави одредиште на %ld, %ld \n"
+msgid "Set destination to %ld, %ld "
+msgstr "Постави одредиште на %ld, %ld "
#, c-format
-msgid "Set map to %ld, %ld \n"
-msgstr "Постави карту на %ld, %ld \n"
+msgid "Set map to %ld, %ld "
+msgstr "Постави карту на %ld, %ld "
#, c-format
-msgid "Set next visit to %ld, %ld \n"
-msgstr "Постави следећу посету на %ld, %ld \n"
+msgid "Set next visit to %ld, %ld "
+msgstr "Постави следећу посету на %ld, %ld "
msgid "POI search"
msgstr "Претрага занимљивих тачака"
@@ -1765,8 +1863,8 @@ msgid "OT"
msgstr "ОТ"
#, c-format
-msgid "Route %4.0fkm %02d:%02d ETA"
-msgstr "Рута %4.0fкм %02d:%02d ПВД"
+msgid "Route %4.1f%s %02d:%02d ETA"
+msgstr ""
msgid "Route 0000km 0+00:00 ETA"
msgstr "Рута 0000км 0+00:00 ПВД"
@@ -1937,10 +2035,10 @@ msgstr "Пролазне тачке"
msgid "Enter Coordinates"
msgstr "Унесите координате"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
@@ -1988,6 +2086,9 @@ msgstr "Опис путање"
msgid "Show Locale"
msgstr "Прикажи име превода"
+msgid "Network info"
+msgstr ""
+
msgid "Former Destinations"
msgstr "Претходна одредишта"
@@ -2026,752 +2127,941 @@ msgstr "Пажња! Камера!"
msgid "Please decrease your speed"
msgstr "Молим, смањите брзину"
-msgid "partial match"
-msgstr "делимично поклапање"
+msgid "Vehicle Position"
+msgstr "Позиција возила"
+
+msgid "Main menu"
+msgstr "Главни мени"
+
+msgid ""
+"Show\n"
+"Map"
+msgstr ""
+"Прикажи\n"
+"карту"
+
+msgid "Settings"
+msgstr "Подешавања"
+
+msgid "Tools"
+msgstr "Алати"
+
+msgid "Route"
+msgstr "рута"
+
+msgid "About"
+msgstr "O"
+
+msgid "Quit"
+msgstr "Заврши"
+
+msgid "Actions"
+msgstr "Поступци"
+
+msgid ""
+"Former\n"
+"Destinations"
+msgstr ""
+"Претходна\n"
+"одредишта"
+
+msgid "Coordinates"
+msgstr "Координате"
+
+msgid ""
+"Stop\n"
+"Navigation"
+msgstr ""
+"Заустави\n"
+"навигацију"
+
+msgid "Display"
+msgstr "Приказ"
+
+msgid "Fullscreen"
+msgstr "Цео екран"
+
+msgid "Window Mode"
+msgstr "Режим прозора"
+
+msgid "Auto zoom"
+msgstr ""
+
+msgid "Manual zoom"
+msgstr ""
+
+msgid "Layers"
+msgstr ""
+
+msgid "Zoom to route"
+msgstr ""
+
+msgid "Description"
+msgstr "Опис"
+
+msgid ""
+"Drop last \n"
+"Waypoint"
+msgstr ""
+"Одбаци последњу\n"
+"пролазну тачку"
+
+msgid ""
+"Drop next \n"
+"Waypoint"
+msgstr ""
+"Одбаци следећу\n"
+"пролазну тачку"
+
+msgid "Satellite Status"
+msgstr "Стање сателита"
+
+msgid "NMEA Data"
+msgstr ""
+
+msgid "car_shortest"
+msgstr "најкраћим_колима"
+
+msgid "car_avoid_tolls"
+msgstr "алати_избегавања_колима"
+
+msgid "car_pedantic"
+msgstr ""
+
+msgid "horse"
+msgstr "коњ"
+
+msgid "Truck"
+msgstr "Камион"
+
+#. Strings from android/res/values/strings.xml
+#. Android resource: @strings/yes
+msgid "Yes"
+msgstr "Да"
+
+#. Android resource: @strings/cancel
+msgid "Cancel"
+msgstr "Откажи"
+
+#. Android resource: @strings/notification_ticker
+msgid "Navit started"
+msgstr "Навит је покренут"
+
+#. Android resource: @strings/notification_event_default
+msgid "Navit running"
+msgstr "Навит је покренут"
+
+#. Android resource: @strings/initial_info_box_title
+msgid "Welcome to Navit"
+msgstr "Добродошли у Навит"
+
+#. Android resource: @strings/initial_info_box_message
+msgid ""
+"Thank you for installing Navit!\n"
+"\n"
+"To start, select \"Download maps\" from the menu to download a map. Note: "
+"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
+"\n"
+"Mapdata: (c) OpenStreetMap contributors\n"
+"\n"
+"Enjoy Navit!"
+msgstr ""
+"Хвала што уградисте Навит!\n"
+"\n"
+"За почетак, изаберите „Преузмите карте“ из изборника ради преузимања карте. "
+"Примедба: Карта може бити велика (>50MB) - бежична веза је препоручена.\n"
+"\n"
+"Подаци о картама: доприносиоци (c) OpenStreetMap-а\n"
+"\n"
+"Уживајте у Навиту!"
+
+#. Android resource: @strings/initial_info_box_OK
+msgid "OK"
+msgstr "У реду"
+
+#. Android resource: @strings/initial_info_box_more_info
+msgid "More info"
+msgstr "Још података"
+
+#. Android resource: @strings/optionsmenu_zoom_in
+msgid "Zoom in"
+msgstr "Приближи"
+
+#. Android resource: @strings/optionsmenu_zoom_out
+msgid "Zoom out"
+msgstr "Удаљи"
+
+#. Android resource: @strings/optionsmenu_download_maps
+msgid "Download maps"
+msgstr "Преузми карте"
+
+#. Android resource: @strings/optionsmenu_toggle_poi
+msgid "Toggle POIs"
+msgstr "Прекидач употребе занимљивих тачака"
+
+#. Android resource: @strings/optionsmenu_exit_navit
+msgid "Exit Navit"
+msgstr "Изађи из Навита"
+
+#. Android resource: @strings/optionsmenu_backup_restore
+msgid "Backup / Restore"
+msgstr "Остава / повратак са ње"
+
+#. Android resource: @strings/optionsmenu_set_map_location
+msgid "Set map location"
+msgstr ""
+
+#. Android resource: @strings/position_popup_drive_here
+msgid "Route to here"
+msgstr "Путања довде"
+
+#. Android resource: @strings/map_delete
+msgid "Delete this map?"
+msgstr "Да ли избрисати ову карту?"
+
+#. Android resource: @strings/map_download_title
+msgid "Map download"
+msgstr "Преузимање карте"
+
+#. Android resource: @strings/map_download_downloading
+msgid "Downloading:"
+msgstr "Преузимам:"
+
+#. Android resource: @strings/map_download_eta
+msgid "ETA"
+msgstr ""
+
+#. Android resource: @strings/map_download_ready
+msgid "ready"
+msgstr "спремно"
+
+#. Android resource: @strings/map_download_download_error
+msgid "Error downloading map."
+msgstr "Десила се грешка при преузимању карте."
+
+#. Android resource: @strings/map_download_download_aborted
+msgid "Map download aborted"
+msgstr "Преузимање карте је отказано"
+
+#. Android resource: @strings/map_download_not_enough_free_space
+msgid "Not enough free space"
+msgstr "Нема довољно расположивог простора"
+
+#. Android resource: @strings/map_download_oversize
+msgid ""
+"Sorry, we currently do not support maps above 3.8G on Android, please select "
+"a smaller one."
+msgstr ""
+
+#. Android resource: @strings/map_no_fix
+msgid "No location. Reopen after location fix."
+msgstr "Нема положаја. Отварам поново по исправци положаја."
+
+#. Android resource: @strings/maps_for_current_location
+msgid "Maps containing current location"
+msgstr "Карте које садрже тренутни положај"
+
+#. Android resource: @strings/maps_installed
+msgid "Installed maps"
+msgstr ""
+
+#. Android resource: @strings/map_downloading
+msgid "downloading"
+msgstr "преузимање"
+
+#. Android resource: @strings/map_download_medium_unavailable
+msgid "Media selected for map storage is not available"
+msgstr ""
+
+#. Android resource: @strings/map_download_error_writing_map
+msgid "Error writing map!"
+msgstr "Десила се грешка при упису карте!"
+
+#. Android resource: @strings/map_location_changed
+#, c-format
+msgid "New location set to %s Restart Navit to apply the changes."
+msgstr ""
+
+#. Android resource: @strings/map_location_unavailable
+#, c-format
+msgid ""
+"Current map location %s is not available Please restart Navit after you "
+"attach an SD card or select a different map location."
+msgstr ""
+
+#. Android resource: @strings/address_search_title
+msgid "Address search"
+msgstr "Претрага адреса"
+
+#. Android resource: @strings/address_enter_destination
+msgid "Enter destination"
+msgstr "Унесите одредиште"
+
+#. Android resource: @strings/address_partial_match
+msgid "Match partial address"
+msgstr "Упореди непотпуну адресу"
#. Android resource: @strings/address_search_button
msgid "Search"
msgstr "Претражи"
+#. Android resource: @strings/address_search_searching
+msgid "Searching..."
+msgstr "Претрага..."
+
+#. Android resource: @strings/address_search_not_found
+msgid "Address not found"
+msgstr "Није пронађена адреса"
+
+#. Android resource: @strings/address_search_getting_results
+msgid "Getting search results"
+msgstr "Добављам излазе претраге"
+
+#. Android resource: @strings/address_search_loading_results
+msgid "Loading search results"
+msgstr "Учитавам излазе претраге"
+
+#. Android resource: @strings/address_search_no_results
+msgid "No results found"
+msgstr "Нема излаза претраге"
+
+#. Android resource: @strings/address_search_no_text_entered
+msgid "No text entered"
+msgstr "Нема унетог текста"
+
+#. Android resource: @strings/address_search_set_destination
+msgid "Setting destination to:"
+msgstr "Постављам одредиште на:"
+
#. Android resource: @strings/address_search_towns
msgid "Towns"
msgstr "Градове"
-msgid "Map data (c) OpenStreetMap contributors, ODBL"
-msgstr "Подаци карте (c) доприносиоци Отворене карте улица, ОДБЛ"
+#. Android resource: @strings/choose_an_action
+msgid "Choose an action"
+msgstr "Изаберите радњу"
-msgid ""
-"Current map location %s is not available\n"
-"Please restart Navit after you attach an SD card or select a different map "
-"location."
-msgstr ""
+#. Android resource: @strings/please_insert_an_sd_card
+msgid "Please insert an SD Card"
+msgstr "Молим, утакните СД картицу"
+
+#. Android resource: @strings/backing_up
+msgid "Backing up..."
+msgstr "Чувам у оставу..."
+
+#. Android resource: @strings/restoring
+msgid "Restoring..."
+msgstr "Враћам из оставе..."
+
+#. Android resource: @strings/failed_to_create_backup_directory
+msgid "Failed to create backup directory"
+msgstr "Нисам успео да образујем фасциклу оставе"
+
+#. Android resource: @strings/backup_failed
+msgid "Backup failed"
+msgstr "Чување у оставу није успело"
+
+#. Android resource: @strings/no_backup_found
+msgid "No backup found"
+msgstr "Нисам пронашао оставу"
-msgid "Downloaded maps"
-msgstr "Преузете карте"
+#. Android resource: @strings/failed_to_restore
+msgid "Failed to restore"
+msgstr "Нисам успео да вратим податке из оставе"
+#. Android resource: @strings/backup_successful
+msgid "Backup successful"
+msgstr "Чување у оставу је успешно"
+
+#. Android resource: @strings/restore_successful_please_restart_navit
msgid ""
-"Sorry, we currently do not support maps above 3.8G on Android, please select "
-"a smaller one."
+"Restore Successful\n"
+"Please restart Navit"
msgstr ""
+"Враћање из оставе је успешно\n"
+"Молим, поново покрените Навит"
-#. Android resource: @strings/position_popup_drive_here
-msgid "Route to here"
-msgstr "Путања довде"
+#. Android resource: @strings/backup_not_found
+msgid "Backup not found"
+msgstr "Није пронађена остава"
-msgid "Cancel"
-msgstr "Откажи"
+#. Android resource: @strings/restore_failed
+msgid "Restore failed"
+msgstr "Није успео повраћај из оставе"
+
+#. Android resource: @strings/select_backup
+msgid "Select backup"
+msgstr "Изаберите податке за повраћај"
+
+#. Android resource: @strings/backup
+msgid "Backup"
+msgstr "Остава"
+
+#. Android resource: @strings/restore
+msgid "Restore"
+msgstr "Поврати"
+
+#. Android resource: @strings/TTS_title_data_missing
+msgid "System text to speech engine data is missing"
+msgstr ""
-msgid "filenamePath"
+#. Android resource: @strings/TTS_qery_install_data
+msgid ""
+"Navit can use any text to speech engine installed on your device. The "
+"currently selected engine reports it is unable to speak in your language. "
+"Should we ask the system to show voice download dialog?"
msgstr ""
+#. Android resource: @strings/permissions_not_granted
msgid ""
-"New location set to %s\n"
-"Restart Navit to apply the changes."
+"Navit needs permission to access GPS and read the map.\n"
+"If you change your mind please restart Navit and grant the permissions"
+msgstr ""
+
+#. Android resource: @strings/permissions_info_box_title
+msgid "One or more ungranted permissions"
msgstr ""
+#. Android resource: @strings/whole_planet
msgid "Whole Planet"
msgstr "Читава планета"
+#. Android resource: @strings/africa
msgid "Africa"
msgstr "Африка"
+#. Android resource: @strings/canary_islands
msgid "Canary Islands"
msgstr "Канарска Острва"
+#. Android resource: @strings/asia
msgid "Asia"
msgstr "Азија"
-msgid "Korea"
-msgstr "Кореја"
-
+#. Android resource: @strings/taiwan
msgid "Taiwan"
msgstr "Тајван"
+#. Android resource: @strings/korea
+msgid "Korea"
+msgstr "Кореја"
+
+#. Android resource: @strings/uae_other
msgid "UAE+Other"
msgstr ""
+#. Android resource: @strings/oceania
msgid "Oceania"
msgstr "Океанија"
+#. Android resource: @strings/tasmania
msgid "Tasmania"
msgstr "Тасманија"
+#. Android resource: @strings/victoria
msgid "Victoria"
msgstr "Викторија"
+#. Android resource: @strings/new_south_wales
msgid "New South Wales"
msgstr "Нови Јужни Велс"
+#. Android resource: @strings/europe
msgid "Europe"
msgstr "Европа"
+#. Android resource: @strings/western_europe
msgid "Western Europe"
msgstr "Западна Европа"
+#. Android resource: @strings/azores
msgid "Azores"
msgstr "Азори"
+#. Android resource: @strings/benelux
msgid "BeNeLux"
msgstr "Бенелукс"
+#. Android resource: @strings/alsace
msgid "Alsace"
msgstr "Алзас"
+#. Android resource: @strings/aquitaine
msgid "Aquitaine"
msgstr ""
+#. Android resource: @strings/auvergne
msgid "Auvergne"
msgstr ""
-msgid "Basse-Normandie"
-msgstr ""
-
-msgid "Bourgogne"
-msgstr ""
+#. Android resource: @strings/centre
+msgid "Centre"
+msgstr "Средиште"
+#. Android resource: @strings/bretagne
msgid "Bretagne"
msgstr "Бретања"
-msgid "Centre"
-msgstr "Средиште"
+#. Android resource: @strings/bourgogne
+msgid "Bourgogne"
+msgstr ""
+#. Android resource: @strings/basse_normandie
+msgid "Basse-Normandie"
+msgstr ""
+
+#. Android resource: @strings/champagne_ardenne
msgid "Champagne-Ardenne"
msgstr "Шампањ-Арден"
+#. Android resource: @strings/corse
msgid "Corse"
msgstr ""
+#. Android resource: @strings/franche_comte
msgid "Franche-Comte"
msgstr ""
+#. Android resource: @strings/haute_normandie
msgid "Haute-Normandie"
msgstr ""
+#. Android resource: @strings/ile_de_france
msgid "Ile-de-France"
msgstr ""
+#. Android resource: @strings/languedoc_roussillon
msgid "Languedoc-Roussillon"
msgstr ""
+#. Android resource: @strings/limousin
msgid "Limousin"
msgstr ""
+#. Android resource: @strings/lorraine
msgid "Lorraine"
msgstr "Лорена"
+#. Android resource: @strings/midi_pyrenees
msgid "Midi-Pyrenees"
msgstr "Средњи Пиринеји"
+#. Android resource: @strings/nord_pas_de_calais
msgid "Nord-pas-de-Calais"
msgstr ""
+#. Android resource: @strings/pays_de_la_loire
msgid "Pays-de-la-Loire"
msgstr ""
+#. Android resource: @strings/picardie
msgid "Picardie"
msgstr ""
+#. Android resource: @strings/poitou_charentes
msgid "Poitou-Charentes"
msgstr ""
+#. Android resource: @strings/provence_alpes_cote_d_azur
msgid "Provence-Alpes-Cote-d-Azur"
msgstr ""
+#. Android resource: @strings/rhone_alpes
msgid "Rhone-Alpes"
msgstr ""
+#. Android resource: @strings/baden_wuerttemberg
msgid "Baden-Wuerttemberg"
msgstr ""
+#. Android resource: @strings/bayern
msgid "Bayern"
msgstr ""
+#. Android resource: @strings/mittelfranken
msgid "Mittelfranken"
msgstr ""
+#. Android resource: @strings/niederbayern
msgid "Niederbayern"
msgstr ""
+#. Android resource: @strings/oberbayern
msgid "Oberbayern"
msgstr ""
+#. Android resource: @strings/oberfranken
msgid "Oberfranken"
msgstr ""
+#. Android resource: @strings/oberpfalz
msgid "Oberpfalz"
msgstr ""
+#. Android resource: @strings/schwaben
msgid "Schwaben"
msgstr ""
+#. Android resource: @strings/unterfranken
msgid "Unterfranken"
msgstr ""
+#. Android resource: @strings/berlin
msgid "Berlin"
msgstr "Берлин"
+#. Android resource: @strings/brandenburg
msgid "Brandenburg"
msgstr "Бранденбург"
+#. Android resource: @strings/bremen
msgid "Bremen"
msgstr "Бремен"
+#. Android resource: @strings/hamburg
msgid "Hamburg"
msgstr "Хамбург"
+#. Android resource: @strings/hessen
msgid "Hessen"
msgstr ""
+#. Android resource: @strings/mecklenburg_vorpommern
msgid "Mecklenburg-Vorpommern"
msgstr ""
+#. Android resource: @strings/niedersachsen
msgid "Niedersachsen"
msgstr ""
+#. Android resource: @strings/nordrhein_westfalen
msgid "Nordrhein-westfalen"
msgstr ""
+#. Android resource: @strings/rheinland_pfalz
msgid "Rheinland-Pfalz"
msgstr ""
+#. Android resource: @strings/saarland
msgid "Saarland"
msgstr "Сарланд"
+#. Android resource: @strings/sachsen_anhalt
msgid "Sachsen-Anhalt"
msgstr "Саксонија-Анхалт"
+#. Android resource: @strings/sachsen
msgid "Sachsen"
msgstr ""
+#. Android resource: @strings/schleswig_holstein
msgid "Schleswig-Holstein"
msgstr ""
+#. Android resource: @strings/thueringen
msgid "Thueringen"
msgstr ""
+#. Android resource: @strings/mallorca
msgid "Mallorca"
msgstr ""
+#. Android resource: @strings/galicia
msgid "Galicia"
msgstr "Галиција"
+#. Android resource: @strings/scandinavia
msgid "Scandinavia"
msgstr "Скандинавија"
+#. Android resource: @strings/england
msgid "England"
msgstr "Енглеска"
+#. Android resource: @strings/buckinghamshire
msgid "Buckinghamshire"
msgstr ""
+#. Android resource: @strings/cambridgeshire
msgid "Cambridgeshire"
msgstr ""
+#. Android resource: @strings/cumbria
msgid "Cumbria"
msgstr ""
+#. Android resource: @strings/east_yorkshire_with_hull
msgid "East yorkshire with hull"
msgstr ""
+#. Android resource: @strings/essex
msgid "Essex"
msgstr "Есекс"
+#. Android resource: @strings/herefordshire
msgid "Herefordshire"
msgstr ""
+#. Android resource: @strings/kent
msgid "Kent"
msgstr "Кент"
+#. Android resource: @strings/lancashire
msgid "Lancashire"
msgstr ""
+#. Android resource: @strings/leicestershire
msgid "Leicestershire"
msgstr ""
+#. Android resource: @strings/norfolk
msgid "Norfolk"
msgstr "Норфолк"
+#. Android resource: @strings/nottinghamshire
msgid "Nottinghamshire"
msgstr ""
+#. Android resource: @strings/oxfordshire
msgid "Oxfordshire"
msgstr ""
+#. Android resource: @strings/shropshire
msgid "Shropshire"
msgstr ""
+#. Android resource: @strings/somerset
msgid "Somerset"
msgstr "Сомерсет"
+#. Android resource: @strings/south_yorkshire
msgid "South yorkshire"
msgstr ""
+#. Android resource: @strings/suffolk
msgid "Suffolk"
msgstr ""
+#. Android resource: @strings/surrey
msgid "Surrey"
msgstr ""
+#. Android resource: @strings/wiltshire
msgid "Wiltshire"
msgstr ""
+#. Android resource: @strings/scotland
msgid "Scotland"
msgstr "Шкотска"
+#. Android resource: @strings/wales
msgid "Wales"
msgstr "Велс"
+#. Android resource: @strings/crete
msgid "Crete"
msgstr ""
+#. Android resource: @strings/north_america
msgid "North America"
msgstr "Северна Америка"
+#. Android resource: @strings/alaska
msgid "Alaska"
msgstr "Аљаска"
+#. Android resource: @strings/hawaii
msgid "Hawaii"
msgstr "Хаваји"
+#. Android resource: @strings/usa
msgid "USA"
msgstr "САД"
-msgid " (except Alaska and Hawaii)"
+#. Android resource: @strings/except_alaska_and_hawaii
+msgid "(except Alaska and Hawaii)"
msgstr ""
+#. Android resource: @strings/midwest
msgid "Midwest"
msgstr ""
+#. Android resource: @strings/michigan
msgid "Michigan"
msgstr "Мичиген"
+#. Android resource: @strings/ohio
msgid "Ohio"
msgstr "Охајо"
+#. Android resource: @strings/northeast
msgid "Northeast"
msgstr "Североисток"
+#. Android resource: @strings/massachusetts
msgid "Massachusetts"
msgstr "Масачусец"
+#. Android resource: @strings/vermont
msgid "Vermont"
msgstr "Вермонт"
+#. Android resource: @strings/pacific
msgid "Pacific"
msgstr "Пацифик"
+#. Android resource: @strings/south
msgid "South"
msgstr ""
+#. Android resource: @strings/arkansas
msgid "Arkansas"
msgstr "Арканзас"
+#. Android resource: @strings/district_of_columbia
msgid "District of Columbia"
msgstr "Колумбијски округ"
+#. Android resource: @strings/florida
msgid "Florida"
msgstr "Флорида"
+#. Android resource: @strings/louisiana
msgid "Louisiana"
msgstr "Луизијана"
+#. Android resource: @strings/maryland
msgid "Maryland"
msgstr "Мериленд"
+#. Android resource: @strings/mississippi
msgid "Mississippi"
msgstr "Мисисипи"
+#. Android resource: @strings/oklahoma
msgid "Oklahoma"
msgstr "Оклахома"
+#. Android resource: @strings/texas
msgid "Texas"
msgstr "Тексас"
+#. Android resource: @strings/virginia
msgid "Virginia"
msgstr "Вирџинија"
+#. Android resource: @strings/west_virginia
msgid "West Virginia"
msgstr "Западна Вирџинија"
+#. Android resource: @strings/west
msgid "West"
msgstr "Запад"
+#. Android resource: @strings/arizona
msgid "Arizona"
msgstr "Аризона"
+#. Android resource: @strings/california
msgid "California"
msgstr "Калифорнија"
+#. Android resource: @strings/colorado
msgid "Colorado"
msgstr "Колорадо"
+#. Android resource: @strings/idaho
msgid "Idaho"
msgstr "Ајдахо"
+#. Android resource: @strings/montana
msgid "Montana"
msgstr "Монтана"
+#. Android resource: @strings/new_mexico
msgid "New Mexico"
msgstr "Нови Мексико"
+#. Android resource: @strings/nevada
msgid "Nevada"
msgstr "Невада"
+#. Android resource: @strings/oregon
msgid "Oregon"
msgstr "Орегон"
+#. Android resource: @strings/utah
msgid "Utah"
msgstr "Јута"
+#. Android resource: @strings/washington_state
msgid "Washington State"
msgstr ""
+#. Android resource: @strings/south_middle_america
msgid "South+Middle America"
msgstr ""
+#. Android resource: @strings/guyane_francaise
msgid "Guyane Francaise"
msgstr ""
-msgid "downloading"
-msgstr "преузимање"
-
-#. Android resource: @strings/map_download_ready
-msgid "ready"
-msgstr "спремно"
-
-msgid "Media selected for map storage is not available"
-msgstr ""
-
-#. Android resource: @strings/map_download_not_enough_free_space
-msgid "Not enough free space"
-msgstr "Нема довољно расположивог простора"
-
-msgid "Error downloading map!"
-msgstr "Десила се грешка приликом преузимања карте!"
-
-msgid "Error writing map!"
-msgstr "Десила се грешка при упису карте!"
-
-msgid "Map download aborted!"
-msgstr "Преузимање карте је прекинуто!"
-
-#. Android resource: @strings/map_download_eta
-msgid "ETA"
-msgstr ""
-
-#. Android resource: @strings/map_download_title
-msgid "Map download"
-msgstr "Преузимање карте"
-
-msgid "Vehicle Position"
-msgstr "Позиција возила"
-
-msgid "Main menu"
-msgstr "Главни мени"
-
-msgid ""
-"Show\n"
-"Map"
-msgstr ""
-"Прикажи\n"
-"карту"
-
-msgid "Settings"
-msgstr "Подешавања"
-
-msgid "Tools"
-msgstr "Алати"
-
-msgid "Route"
-msgstr "рута"
-
-msgid "About"
-msgstr "O"
-
-msgid "Quit"
-msgstr "Заврши"
-
-msgid "Actions"
-msgstr "Поступци"
-
-msgid ""
-"Former\n"
-"Destinations"
-msgstr ""
-"Претходна\n"
-"одредишта"
-
-msgid "Coordinates"
-msgstr "Координате"
-
-msgid ""
-"Stop\n"
-"Navigation"
-msgstr ""
-"Заустави\n"
-"навигацију"
-
-msgid "Display"
-msgstr "Приказ"
-
-msgid "Fullscreen"
-msgstr "Цео екран"
-
-msgid "Window Mode"
-msgstr "Режим прозора"
-
-msgid "Layers"
-msgstr ""
-
-msgid "Description"
-msgstr "Опис"
-
-msgid ""
-"Drop last \n"
-"Waypoint"
-msgstr ""
-"Одбаци последњу\n"
-"пролазну тачку"
-
-msgid ""
-"Drop next \n"
-"Waypoint"
-msgstr ""
-"Одбаци следећу\n"
-"пролазну тачку"
-
-msgid "Satellite Status"
-msgstr "Стање сателита"
-
-msgid "NMEA Data"
-msgstr ""
-
-msgid "car_shortest"
-msgstr "најкраћим_колима"
-
-msgid "car_avoid_tolls"
-msgstr "алати_избегавања_колима"
-
-msgid "car_pedantic"
-msgstr ""
-
-msgid "horse"
-msgstr "коњ"
-
-msgid "Truck"
-msgstr "Камион"
-
-#. Strings from android/res/values/strings.xml
-#. Android resource: @strings/yes
-msgid "Yes"
-msgstr "Да"
-
-#. Android resource: @strings/notification_ticker
-msgid "Navit started"
-msgstr "Навит је покренут"
-
-#. Android resource: @strings/notification_event_default
-msgid "Navit running"
-msgstr "Навит је покренут"
-
-#. Android resource: @strings/initial_info_box_title
-msgid "Welcome to Navit"
-msgstr "Добродошли у Навит"
-
-#. Android resource: @strings/initial_info_box_message
-msgid ""
-"Thank you for installing Navit!\n"
-"\n"
-"To start, select \"Download maps\" from the menu to download a map. Note: "
-"The map filesize may be large (>50MB) - a wifi connection is recommended.\n"
-"\n"
-"Mapdata: (c) OpenStreetMap contributors\n"
-"\n"
-"Enjoy Navit!"
-msgstr ""
-"Хвала што уградисте Навит!\n"
-"\n"
-"За почетак, изаберите „Преузмите карте“ из изборника ради преузимања карте. "
-"Примедба: Карта може бити велика (>50MB) - бежична веза је препоручена.\n"
-"\n"
-"Подаци о картама: доприносиоци (c) OpenStreetMap-а\n"
-"\n"
-"Уживајте у Навиту!"
-
-#. Android resource: @strings/initial_info_box_OK
-msgid "OK"
-msgstr "У реду"
-
-#. Android resource: @strings/initial_info_box_more_info
-msgid "More info"
-msgstr "Још података"
-
-#. Android resource: @strings/optionsmenu_zoom_in
-msgid "Zoom in"
-msgstr "Приближи"
-
-#. Android resource: @strings/optionsmenu_zoom_out
-msgid "Zoom out"
-msgstr "Удаљи"
-
-#. Android resource: @strings/optionsmenu_download_maps
-msgid "Download maps"
-msgstr "Преузми карте"
-
-#. Android resource: @strings/optionsmenu_toggle_poi
-msgid "Toggle POIs"
-msgstr "Прекидач употребе занимљивих тачака"
-
-#. Android resource: @strings/optionsmenu_exit_navit
-msgid "Exit Navit"
-msgstr "Изађи из Навита"
-
-#. Android resource: @strings/optionsmenu_backup_restore
-msgid "Backup / Restore"
-msgstr "Остава / повратак са ње"
-
-#. Android resource: @strings/optionsmenu_set_map_location
-msgid "Set map location"
-msgstr ""
-
-#. Android resource: @strings/map_delete
-msgid "Delete this map?"
-msgstr "Да ли избрисати ову карту?"
-
-#. Android resource: @strings/map_download_downloading
-msgid "Downloading:"
-msgstr "Преузимам:"
-
-#. Android resource: @strings/map_download_download_error
-msgid "Error downloading map."
-msgstr "Десила се грешка при преузимању карте."
-
-#. Android resource: @strings/map_download_download_aborted
-msgid "Map download aborted"
-msgstr "Преузимање карте је отказано"
-
-#. Android resource: @strings/map_no_fix
-msgid "No location. Reopen after location fix."
-msgstr "Нема положаја. Отварам поново по исправци положаја."
-
-#. Android resource: @strings/maps_for_current_location
-msgid "Maps containing current location"
-msgstr "Карте које садрже тренутни положај"
-
-#. Android resource: @strings/address_search_title
-msgid "Address search"
-msgstr "Претрага адреса"
-
-#. Android resource: @strings/address_enter_destination
-msgid "Enter destination"
-msgstr "Унесите одредиште"
-
-#. Android resource: @strings/address_partial_match
-msgid "Match partial address"
-msgstr "Упореди непотпуну адресу"
-
-#. Android resource: @strings/address_search_searching
-msgid "Searching..."
-msgstr "Претрага..."
-
-#. Android resource: @strings/address_search_not_found
-msgid "Address not found"
-msgstr "Није пронађена адреса"
-
-#. Android resource: @strings/address_search_getting_results
-msgid "Getting search results"
-msgstr "Добављам излазе претраге"
-
-#. Android resource: @strings/address_search_loading_results
-msgid "Loading search results"
-msgstr "Учитавам излазе претраге"
-
-#. Android resource: @strings/address_search_no_results
-msgid "No results found"
-msgstr "Нема излаза претраге"
-
-#. Android resource: @strings/address_search_no_text_entered
-msgid "No text entered"
-msgstr "Нема унетог текста"
-
-#. Android resource: @strings/address_search_set_destination
-msgid "Setting destination to:"
-msgstr "Постављам одредиште на:"
-
-#. Android resource: @strings/choose_an_action
-msgid "Choose an action"
-msgstr "Изаберите радњу"
-
-#. Android resource: @strings/please_insert_an_sd_card
-msgid "Please insert an SD Card"
-msgstr "Молим, утакните СД картицу"
-
-#. Android resource: @strings/backing_up
-msgid "Backing up..."
-msgstr "Чувам у оставу..."
+#, c-format
+#~ msgid "Route %4.0fkm %02d:%02d ETA"
+#~ msgstr "Рута %4.0fкм %02d:%02d ПВД"
-#. Android resource: @strings/restoring
-msgid "Restoring..."
-msgstr "Враћам из оставе..."
+#~ msgid "No config file navit.xml, navit.xml.local found\n"
+#~ msgstr ""
+#~ "Нема датотеке подешавања navit.xml, navit.xml.сопствени је пронађен\n"
-#. Android resource: @strings/failed_to_create_backup_directory
-msgid "Failed to create backup directory"
-msgstr "Нисам успео да образујем фасциклу оставе"
+#, c-format
+#~ msgid "Error parsing config file '%s': %s\n"
+#~ msgstr ""
+#~ "Десила се грешка приликом рашчлањивања датотеке подешавања „%s“: %s\n"
-#. Android resource: @strings/backup_failed
-msgid "Backup failed"
-msgstr "Чување у оставу није успело"
+#, c-format
+#~ msgid "Using config file '%s'\n"
+#~ msgstr "Користим датотеку подешавања „%s“\n"
-#. Android resource: @strings/no_backup_found
-msgid "No backup found"
-msgstr "Нисам пронашао оставу"
+#, c-format
+#~ msgid "Error: No configuration found in config file '%s'\n"
+#~ msgstr "ГРЕШКА: Нису пронађене поставке у датотеци подешавања „%s“\n"
-#. Android resource: @strings/failed_to_restore
-msgid "Failed to restore"
-msgstr "Нисам успео да вратим податке из оставе"
+#~ msgid ""
+#~ "Internal initialization failed, exiting. Check previous error messages.\n"
+#~ msgstr ""
+#~ "Није успело унутрашње покретање, излазим. Проверите претходне поруке "
+#~ "грешака.\n"
-#. Android resource: @strings/backup_successful
-msgid "Backup successful"
-msgstr "Чување у оставу је успешно"
+#~ msgid "Distance from screen center (km)"
+#~ msgstr "Растојање од средишта екрана (km)"
-#. Android resource: @strings/restore_successful_please_restart_navit
-msgid ""
-"Restore Successful\n"
-"Please restart Navit"
-msgstr ""
-"Враћање из оставе је успешно\n"
-"Молим, поново покрените Навит"
+#, c-format
+#~ msgid "Set destination to %ld, %ld \n"
+#~ msgstr "Постави одредиште на %ld, %ld \n"
-#. Android resource: @strings/backup_not_found
-msgid "Backup not found"
-msgstr "Није пронађена остава"
+#, c-format
+#~ msgid "Set map to %ld, %ld \n"
+#~ msgstr "Постави карту на %ld, %ld \n"
-#. Android resource: @strings/restore_failed
-msgid "Restore failed"
-msgstr "Није успео повраћај из оставе"
+#, c-format
+#~ msgid "Set next visit to %ld, %ld \n"
+#~ msgstr "Постави следећу посету на %ld, %ld \n"
-#. Android resource: @strings/select_backup
-msgid "Select backup"
-msgstr "Изаберите податке за повраћај"
+#~ msgid "partial match"
+#~ msgstr "делимично поклапање"
-#. Android resource: @strings/backup
-msgid "Backup"
-msgstr "Остава"
+#~ msgid "Map data (c) OpenStreetMap contributors, ODBL"
+#~ msgstr "Подаци карте (c) доприносиоци Отворене карте улица, ОДБЛ"
-#. Android resource: @strings/restore
-msgid "Restore"
-msgstr "Поврати"
+#~ msgid "Downloaded maps"
+#~ msgstr "Преузете карте"
-#. Android resource: @strings/TTS_title_data_missing
-msgid "System text to speech engine data is missing"
-msgstr ""
+#~ msgid "Error downloading map!"
+#~ msgstr "Десила се грешка приликом преузимања карте!"
-#. Android resource: @strings/TTS_qery_install_data
-msgid ""
-"Navit can use any text to speech engine installed on your device. The "
-"currently selected engine reports it is unable to speak in your language. "
-"Should we ask the system to show voice download dialog?"
-msgstr ""
+#~ msgid "Map download aborted!"
+#~ msgstr "Преузимање карте је прекинуто!"
#, c-format
#~ msgid "then leave the roundabout at the %1$s %2$s"
diff --git a/po/sv.po.in b/po/sv.po.in
index 8a4a292c4..0a294fb63 100644
--- a/po/sv.po.in
+++ b/po/sv.po.in
@@ -358,7 +358,7 @@ msgstr "Vänd %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "följ"
@@ -1671,7 +1671,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1930,10 +1930,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/sw.po.in b/po/sw.po.in
index d1fe07e31..b8e85634a 100644
--- a/po/sw.po.in
+++ b/po/sw.po.in
@@ -352,7 +352,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1665,7 +1665,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1924,10 +1924,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/ta.po.in b/po/ta.po.in
index 74ba7a104..5e5f2112c 100644
--- a/po/ta.po.in
+++ b/po/ta.po.in
@@ -352,7 +352,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1665,7 +1665,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1924,10 +1924,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/te.po.in b/po/te.po.in
index eb412a536..62a274a0e 100644
--- a/po/te.po.in
+++ b/po/te.po.in
@@ -352,7 +352,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1665,7 +1665,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1924,10 +1924,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/th.po.in b/po/th.po.in
index 58ac0335d..407a360e4 100644
--- a/po/th.po.in
+++ b/po/th.po.in
@@ -349,7 +349,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1662,7 +1662,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1921,10 +1921,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/tr.po.in b/po/tr.po.in
index 1802c15a9..c59d0cf25 100644
--- a/po/tr.po.in
+++ b/po/tr.po.in
@@ -362,7 +362,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "takip edin"
@@ -1685,7 +1685,7 @@ msgstr "Taksi"
msgid "Shopping"
msgstr "Alışveriş"
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1944,10 +1944,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr "Koordinat Gir"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/uk.po.in b/po/uk.po.in
index 787e71327..83fe79e50 100644
--- a/po/uk.po.in
+++ b/po/uk.po.in
@@ -359,7 +359,7 @@ msgstr "То розверніться %1$s"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1672,7 +1672,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1931,10 +1931,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/ur.po.in b/po/ur.po.in
index e1ffb4b51..78532dd3b 100644
--- a/po/ur.po.in
+++ b/po/ur.po.in
@@ -373,7 +373,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1677,7 +1677,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1926,10 +1926,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/vi.po.in b/po/vi.po.in
index 54ec62618..085f8de54 100644
--- a/po/vi.po.in
+++ b/po/vi.po.in
@@ -351,7 +351,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1664,7 +1664,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1923,10 +1923,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/zh_CN.po.in b/po/zh_CN.po.in
index 44f5e1cc3..3445bb425 100644
--- a/po/zh_CN.po.in
+++ b/po/zh_CN.po.in
@@ -355,7 +355,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1668,7 +1668,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1927,10 +1927,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/zh_HK.po.in b/po/zh_HK.po.in
index 49fb73c01..3c17dc8f6 100644
--- a/po/zh_HK.po.in
+++ b/po/zh_HK.po.in
@@ -353,7 +353,7 @@ msgstr ""
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr ""
@@ -1666,7 +1666,7 @@ msgstr ""
msgid "Shopping"
msgstr ""
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr ""
#, c-format
@@ -1925,10 +1925,10 @@ msgstr ""
msgid "Enter Coordinates"
msgstr ""
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/po/zh_TW.po.in b/po/zh_TW.po.in
index bd136f1e8..426155840 100644
--- a/po/zh_TW.po.in
+++ b/po/zh_TW.po.in
@@ -345,7 +345,7 @@ msgstr "%1$s 右迴轉"
#. *
#. * UNTESTED !
#. *
-#.
+#.
msgid "follow"
msgstr "沿著"
@@ -1665,7 +1665,7 @@ msgstr "計程車"
msgid "Shopping"
msgstr "購物處"
-msgid "Distance from screen center (km)"
+msgid "Select a search radius from screen center"
msgstr "距螢幕中心的距離 (公里)"
#, c-format
@@ -1924,10 +1924,10 @@ msgstr "航點"
msgid "Enter Coordinates"
msgstr "輸入座標"
-#.
+#.
#. w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill)
#. gui_internal_widget_append(wb, w)
-#.
+#.
#. we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill)
#. gui_internal_widget_append(w, we)
msgid "Latitude Longitude"
diff --git a/ci/basic_upload_apks.py b/scripts/basic_upload_apks.py
index b4b439536..b4b439536 100644
--- a/ci/basic_upload_apks.py
+++ b/scripts/basic_upload_apks.py
diff --git a/ci/build.sh b/scripts/build.sh
index 536ab7781..536ab7781 100644
--- a/ci/build.sh
+++ b/scripts/build.sh
diff --git a/scripts/build_android.sh b/scripts/build_android.sh
new file mode 100755
index 000000000..4b915f35e
--- /dev/null
+++ b/scripts/build_android.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+# Build Navit for Android.
+#
+# This script is to be run from the root of the Navit source tree. It is used by CircleCI as well as for local builds,
+# in order to keep build environments as uniform as possible and CI test results meaningful.
+#
+# It will build Navit for all processor architectures specified in navit/android/build.gradle.
+#
+# When running this script locally, ensure all build dependencies are in place:
+# - Packages required: cmake gettext libsaxonb-java librsvg2-bin pkg-config libprotobuf-c-dev protobuf-c-compiler
+# - Android SDK installed
+# - Environment variable $ANDROID_HOME points to Android SDK install location
+# - Android NDK and CMake components installed via
+# sdkmanager ndk-bundle "cmake;3.6.4111459"
+# (later CMake versions from the SDK repository may also work)
+#
+# If any of the build steps fails, this script aborts with an error immediately.
+
+echo Set up environment
+set - e
+export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin
+export JVM_OPTS="-Xmx3200m"
+export GRADLE_OPTS='-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
+
+echo Run CMake
+cmake ./ -Dvehicle/gpsd_dbus:BOOL=FALSE -Dsvg2png_scaling:STRING=-1,24,32,48,64,96,128,192,256 -Dsvg2png_scaling_nav:STRING=-1,24,32,48,64,96,128,192,256 -Dsvg2png_scaling_flag:STRING=-1,24,32,64,96 -DUSE_PLUGINS=n -DBUILD_MAPTOOL=n -DXSL_PROCESSING=y -DXSLTS=android -DANDROID=y -DSAMPLE_MAP=n || exit 1
+
+echo Process icons
+pushd navit/icons
+make || exit 32
+mkdir ../android/res/drawable-nodpi
+cp ./*.png ../android/res/drawable-nodpi
+pushd ../android/res/drawable-nodpi
+rename 'y/A-Z/a-z/' ./*.png
+popd
+popd
+
+echo Process translations
+pushd po
+make || exit 64
+mkdir ../navit/android/res/raw
+cp ./*.mo ../navit/android/res/raw
+pushd ../navit/android/res/raw
+rename 'y/A-Z/a-z/' ./*.mo
+popd
+popd
+
+echo Process xml config files
+make navit_config_xml || exit 96
+pushd navit
+mkdir -p ./android/assets
+cp -R config ./android/assets/
+popd
+
+echo Chmod permissions
+chmod a+x ./gradlew
+
+echo Download dependencies
+./gradlew -v
+
+echo Build
+./gradlew assembleDebug || exit 128
+
+echo Build finished.
+echo APK should be in "navit/android/build/outputs/apk" and can be installed with
+echo ./gradlew installDebug
+
diff --git a/scripts/build_linux.sh b/scripts/build_linux.sh
new file mode 100644
index 000000000..5d807ec45
--- /dev/null
+++ b/scripts/build_linux.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+set -e
+
+COVERITY_VERSION="2017.07"
+BUILD_PATH="linux"
+
+cmake_opts="-Dgraphics/qt_qpainter:BOOL=FALSE -Dgui/qml:BOOL=FALSE -DSVG2PNG:BOOL=FALSE -DSAMPLE_MAP=n -Dgraphics/gtk_drawing_area:BOOL=TRUE"
+
+[ -d $BUILD_PATH ] || mkdir -p $BUILD_PATH
+pushd $BUILD_PATH
+
+# Build everything
+ echo "Building..."
+cmake ${cmake_opts} ../
+make -j $(nproc --all)
+make package
+
+if [[ "${CIRCLE_PROJECT_USERNAME}" == "navit-gps" && "${CIRCLE_BRANCH}" == "trunk" ]]; then
+ # If we are building the official trunk code, push an update to coverity
+ # Temporarily disabled because Coverity is down.
+ # TODO on the long run, CI should not fail just because the Coverity test did not run,
+ # especially if the test results are not taken into account.
+ #echo "Pushing an update to coverity as we are building the official trunk code."
+ #echo "Downloading coverity..."
+ #curl \
+ # -X POST --data "token=${COVERITY_TOKEN}&project=${CIRCLE_PROJECT_USERNAME}" \
+ # -o /tmp/cov-analysis-linux64-${COVERITY_VERSION}.tar.gz -s \
+ # https://scan.coverity.com/download/linux64
+
+ #echo "Unpacking coverity..."
+ #tar xfz /tmp/cov-analysis-linux64-${COVERITY_VERSION}.tar.gz --no-same-owner -C /usr/local/share/
+ #export PATH=/usr/local/share/cov-analysis-linux64-${COVERITY_VERSION}/bin:$PATH
+
+ #echo "Re-running build with coverity..."
+ #cov-build --dir cov-int make -j $(nproc --all)
+ #tar czvf navit.tgz cov-int
+
+# curl --form token=$COVERITY_TOKEN \
+# --form email=$COVERITY_EMAIL \
+# --form file=@navit.tgz \
+# --form version="${CIRCLE_BRANCH}-$CIRCLE_SHA1" \
+# --form description="${CIRCLE_BRANCH}-$CIRCLE_SHA1" \
+# https://scan.coverity.com/builds?project=$CIRCLE_PROJECT_USERNAME
+
+ # Then update the translation template on launchpad
+ echo "Updating the translation template on launchpad..."
+ sed -i '/INTEGER/d' po/navit.pot
+ cp po/navit.pot $CIRCLE_ARTIFACTS/
+ curl "https://translations.launchpad.net/navit/${CIRCLE_BRANCH}/+translations-upload" -H "$lp_cookie" -H "Referer: https://translations.launchpad.net/navit/${CIRCLE_BRANCH}/+translations-upload" -F file=@po/navit.pot | grep title
+fi
+
+if [[ "$CIRCLE_ARTIFACTS" != "" ]]; then
+ echo "Copying icons to artifacts..."
+ cp -r navit/icons $CIRCLE_ARTIFACTS
+fi
diff --git a/ci/build_tomtom_minimal.sh b/scripts/build_tomtom_minimal.sh
index a178b9733..ba6975e0f 100644
--- a/ci/build_tomtom_minimal.sh
+++ b/scripts/build_tomtom_minimal.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
# this builds navit for tomtom
# in case you want to build a plugin for tomtom use build_tomtom_plugin.sh instead
# in case you want to build a standalone system
diff --git a/ci/build_tomtom_plugin.sh b/scripts/build_tomtom_plugin.sh
index 51a15f815..47fedb59a 100644
--- a/ci/build_tomtom_plugin.sh
+++ b/scripts/build_tomtom_plugin.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
# this builds a plugin for tomtom
# in case you want to build a standalone system
# https://github.com/george-hopkins/opentom
@@ -11,7 +11,7 @@ cp Toolchain/$ARCH.cmake /tmp
# toolchain
export TOMTOM_SDK_DIR=/opt/tomtom-sdk
-mkdir -p $TOMTOM_SDK_DIR >/dev/null 2>&1 || export TOMTOM_SDK_DIR=$HOME/tomtom-sdk
+mkdir -p $TOMTOM_SDK_DIR >/dev/null 2>&1 || export TOMTOM_SDK_DIR=$HOME/tomtom-sdk
export PREFIX=$TOMTOM_SDK_DIR/gcc-3.3.4_glibc-2.3.2/$ARCH/sys-root
export PATH=$TOMTOM_SDK_DIR/gcc-3.3.4_glibc-2.3.2/bin:$PREFIX/bin/:$PATH
export CFLAGS="-O2 -I$PREFIX/include -I$PREFIX/usr/include"
@@ -27,7 +27,7 @@ export STRIP=$ARCH-strip
export OBJCOPY=$ARCH-objcopy
export LN_S="ln -s"
export PKG_CONFIG_LIBDIR=$PREFIX/lib/pkgconfig
-JOBS=$(nproc --all)
+JOBS=$(nproc --all)
echo "Jobs"
echo $JOBS
@@ -99,7 +99,7 @@ cp $PREFIX/usr/bin/testvidinfo $OUT_PATH/navit/sdl
# navit executable and wrapper
cp $PREFIX/bin/navit $OUT_PATH/navit/bin
-cp ../contrib/tomtom/navit-wrapper $OUT_PATH/navit/bin/navit-wrapper
+cp ../contrib/tomtom/navit-wrapper $OUT_PATH/navit/bin/navit-wrapper
# fonts
cp -r ../navit/fonts/*.ttf $OUT_PATH/navit/share/fonts
diff --git a/scripts/build_win32.sh b/scripts/build_win32.sh
new file mode 100644
index 000000000..ce0ec0c07
--- /dev/null
+++ b/scripts/build_win32.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+set -e
+apt-get update && apt-get install -y mingw-w64 mingw-w64-tools \
+ default-jdk nsis libsaxonb-java curl
+
+mkdir win32
+pushd win32
+
+cmake -DTARGET_ARCH=i686-w64-mingw32 -DCMAKE_SYSTEM_NAME=Windows \
+ -Dbinding/python:BOOL=FALSE -DSAMPLE_MAP=n -DBUILD_MAPTOOL=n \
+ -DXSLTS=windows -DCMAKE_TOOLCHAIN_FILE=../Toolchain/mingw.cmake ..
+
+make -j $(nproc --all)
+make -j $(nproc --all) package
+
+popd
+
+cp win32/*.exe $CIRCLE_ARTIFACTS/ \ No newline at end of file
diff --git a/scripts/build_wince.sh b/scripts/build_wince.sh
new file mode 100644
index 000000000..bd8f6feb1
--- /dev/null
+++ b/scripts/build_wince.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+set -e
+
+mkdir -p wince
+pushd wince
+#
+cmake \
+ -DTARGET_ARCH=arm-mingw32ce -DCMAKE_SYSTEM_NAME=WindowsCETest \
+ -DCMAKE_TOOLCHAIN_FILE=../Toolchain/mingw.cmake \
+ -DXSLTS=windows,wince -DCACHE_SIZE=10485760 -Dsvg2png_scaling:STRING=16,32 \
+ -Dsvg2png_scaling_nav:STRING=32 -Dsvg2png_scaling_flag=16 -DSAMPLE_MAP=n ..
+make VERBOSE=1
+
+test -d output && rm -rf output
+mkdir output
+cp navit/navit.exe output/
+cp navit/navit.xml output/
+cp navit/navit_layout*.xml output/
+cp -r locale/ output/
+cp -r navit/icons/ output/
+cp -r ../navit/support/espeak/espeak-data/ output/
+mkdir output/maps
+rm -rf output/icons/CMakeFiles/ icons/cmake_install.cmake
+
+cd output/
+zip -r navit.zip .
+
+cd ../..
+bash ./navit/script/cabify.sh wince/output/navit.cab wince/
diff --git a/scripts/ci_sanity_checks.sh b/scripts/ci_sanity_checks.sh
new file mode 100755
index 000000000..cceec6397
--- /dev/null
+++ b/scripts/ci_sanity_checks.sh
@@ -0,0 +1,66 @@
+#!/usr/bin/env bash
+set -u
+
+# #####################################################################################################################
+# This script runs on circle CI to verify that the code of the PR has been
+# sanitized before push.
+#
+# WARNING: make sure you commit ALL your changes before running it locally if you ever do it because it will run a git
+# checkout -- which will reset your changes on all files...
+# #####################################################################################################################
+
+return_code=0
+
+# Check if any file has been modified. If yes, that means the best practices
+# have not been followed, so we will fail the job later but print a message here.
+check_diff(){
+ git diff --exit-code
+ code=$?
+ if [[ $code -ne 0 ]]; then
+ echo "[ERROR] You may need to do some cleanup in the files you commited, see the git diff output above."
+ fi
+ git checkout -- .
+ return_code=$(($return_code + $code))
+}
+
+# List the files that are different from the trunk
+from=$(git rev-parse refs/remotes/origin/trunk)
+to=$(git rev-parse HEAD)
+interval=${from}..${to}
+[[ "${from}" == "${to}" ]] && interval=${to}
+
+for f in $(git diff --name-only ${interval} | sort -u); do
+ if [[ "${f}" =~ navit/support/ ]] || [[ "${f}" =~ navit/fib-1\.1/ ]]; then
+ echo "[DEBUG] Skipping file ${f} ..."
+ continue
+ fi
+ if [[ -e "${f}" ]]; then
+
+ # Checks for trailing spaces
+ if [[ "${f: -4}" != ".bat" ]]; then
+ echo "[INFO] Checking for trailing spaces on ${f}..."
+ if [[ "$(file -bi """${f}""")" =~ ^text ]]; then
+ sed 's/\s*$//' -i "${f}"
+ check_diff
+ fi
+ fi
+
+ # Formats any *.c and *.cpp files
+ if [[ "${f: -2}" == ".c" ]] || [[ "${f: -4}" == ".cpp" ]]; then
+ echo "[INFO] Checking for indentation and style compliance on ${f}..."
+ astyle --indent=spaces=4 --style=attach -n --max-code-length=120 -xf -xh "${f}"
+ check_diff
+ fi
+
+ if [[ "${f}" == "navit/navit_shipped.xml" ]]; then
+ echo "[INFO] Checking for compliance with the DTD using xmllint on ${f}..."
+ xmllint --noout --dtdvalid navit/navit.dtd "$f"
+ rc=$?
+ if [[ $rc -ne 0 ]]; then
+ echo "[ERROR] Your ${f} file doesn't validate against the navit/navit.dtd using xmllint"
+ fi
+ fi
+ fi
+done
+
+exit $return_code
diff --git a/ci/dbus_tests.py b/scripts/dbus_tests.py
index fe343da32..fe343da32 100644
--- a/ci/dbus_tests.py
+++ b/scripts/dbus_tests.py
diff --git a/scripts/generate_contributors.sh b/scripts/generate_contributors.sh
new file mode 100644
index 000000000..43ef47c73
--- /dev/null
+++ b/scripts/generate_contributors.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+set -e
+
+# ###########################################################################################################
+# This script generates a AUTHORS file in the current directory based on the
+# output of the git log command. It splits the contributors in 2 groups:
+# * The "active contributors" are the contributors that authored commits over the last 2 years
+# * The "retired contributors" are the contributors that have authored commits but not over the last 2 years
+# Note: it uses git's mailmap functionnality to get a clean list of users
+# ###########################################################################################################
+
+declare -A CONTRIBUTORS=()
+declare -a authors=()
+TWO_YEARS_AGO=$(date +%s --date="2 years ago")
+retiredTitleWritten=false
+
+git log --encoding=utf-8 --full-history --date=short --use-mailmap "--format=format:%ad;%aN" |
+{
+ echo "# Active contributors:" > AUTHORS
+ while read -r line; do
+ IFS=';'; arrLine=($line); unset IFS;
+ author=${arrLine[1]}
+ commitDate=$(date +%s --date="${arrLine[0]}")
+
+ # Exclude circleci
+ if [[ $author =~ [Cc]ircle[[:space:]]*[Cc][Ii] ]]; then
+ continue
+ fi
+
+ # indicates that the commits are now older than 2 years so we print the
+ # sorted list of active contributors and reset the authors array
+ if [ "$retiredTitleWritten" = false ]; then
+ if [ $TWO_YEARS_AGO -ge $commitDate ]; then
+ IFS=$'\n' sorted=($(sort <<<"${authors[*]}"))
+ printf "%s\n" "${sorted[@]}" >> AUTHORS
+ authors=()
+ echo -e "\n# Retired contributors:" >> AUTHORS
+ retiredTitleWritten=true
+ fi
+ fi
+
+ # using the map as an easy way to check if the author has already been listed
+ if [ -z "${CONTRIBUTORS[${author}]}" ]; then
+ CONTRIBUTORS[${author}]=${arrLine[0]}
+ authors+=("${author}")
+ fi
+ done
+ # We are still in the subprocess scope so we can print the sorted list of
+ # retired contributors
+ IFS=$'\n' sorted=($(sort <<<"${authors[*]}"))
+ printf "%s\n" "${sorted[@]}" >> AUTHORS
+}
diff --git a/ci/import_translations.sh b/scripts/import_translation.sh
index 33d94e9c4..fc4117847 100644
--- a/ci/import_translations.sh
+++ b/scripts/import_translation.sh
@@ -1,18 +1,36 @@
-# Let's check if there is files in the import queue
-[ -d po/import_queue/ ] || exit 0
+#!/bin/bash
+
+# This script imports one translation from launchpad
+# The url to the .po file should be provided as an argument
+
+if [[ $1 == "" ]]; then
+ echo "I need the po URL from Launchpad"
+ exit
+fi
+
+id=$(echo $1|cut -d'/' -f4)
+po=$(echo $1|cut -d'/' -f5|cut -c 13-)
+
+rm -rf navit
+git clone git@github.com:navit-gps/navit.git
+cd navit/
+[ -d po/import_queue ] && exit -1
+mkdir po/import_queue
+i="po/import_queue/$po"
+wget $1 -O po/import_queue/$po
# Let's fix the headers of the .po files in the import queue
for i in po/import_queue/*.po; do
- b=`basename $i`;
- po=${b#*-};
+ b=$(basename $i)
+ po=${b#*-}
code=${po%.*}
- git checkout -b i18n/$code
- lname=`head -n1 ${i} | sed 's/# \(.*\) translation.\{0,1\} for navit/\1/'`
+ git checkout -b i18n/$code || exit -1
+ lname=$(head -n1 ${i} | sed 's/# \(.*\) translation.\{0,1\} for navit/\1/')
if [[ $lname == "" ]]; then
echo "Cannot find the language name in the header of $i"
exit 1
fi
- d=`date +"%Y"`
+ d=$(date +"%Y")
echo "# ${lname} translations for navit" > po/${po}.header
echo "# Copyright (C) 2006-${d} The Navit Team" >> po/${po}.header
echo "# This file is distributed under the same license as the navit package." >> po/${po}.header
@@ -20,10 +38,10 @@ for i in po/import_queue/*.po; do
# Build a clean list of the contributors
IFS=$'\n'
echo "Downloading https://translations.launchpad.net/navit/trunk/+pots/navit/${code}/+details"
- contributors=`wget -q https://translations.launchpad.net/navit/trunk/+pots/navit/${code}/+details -O - | egrep '^ <a href=".+?" class="sprite person">'`
+ contributors=$(wget -q https://translations.launchpad.net/navit/trunk/+pots/navit/${code}/+details -O - | grep -E '^ <a href=".+?" class="sprite person">')
for user in $contributors; do
- url=`echo $user|cut -d'"' -f2`
- name=`echo $user|cut -d'>' -f2|cut -d'<' -f1`
+ url=$(echo $user|cut -d'"' -f2)
+ name=$(echo $user|cut -d'>' -f2|cut -d'<' -f1)
echo "# $name $url" >> po/${po}.header
done
echo '' >> po/${po}.header
@@ -38,7 +56,14 @@ for i in po/import_queue/*.po; do
mv po/${po}.header po/${po}.in
sed '1,/msgid ""/ d' ${i} >> po/${po}.in
+ # We remove extra whitespaces to make the sanity checks happy
+ sed -i -e 's/ *$//' po/${po}.in
+
+ git status
git add po/${po}.in && rm $i
- git commit -m "Updated ${lname} translation from launchpad" po/${po}.in
+ git commit -m "Update:i18n:Updated ${lname} translation from launchpad" po/${po}.in
+ git diff trunk
+ echo "Going to push $id/$code in branch i18n/$code, press a key"
+ read -r
git push --set-upstream origin i18n/${code}
done
diff --git a/ci/merge_i18n_update.sh b/scripts/merge_i18n_update.sh
index 1943b27e4..bb0715d5b 100644
--- a/ci/merge_i18n_update.sh
+++ b/scripts/merge_i18n_update.sh
@@ -1,4 +1,7 @@
-message=`git log -1 --pretty=%B`
+#!/bin/sh
+set -e
+
+message=$(git log -1 --pretty=%B)
git config --global user.name "CircleCI"
git config --global user.email circleci@navit-project.org
git rebase trunk
diff --git a/ci/pointer-64.png b/scripts/pointer-64.png
index 904f6878d..904f6878d 100644
--- a/ci/pointer-64.png
+++ b/scripts/pointer-64.png
Binary files differ
diff --git a/scripts/pre-commit b/scripts/pre-commit
new file mode 100755
index 000000000..4a07a26a8
--- /dev/null
+++ b/scripts/pre-commit
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+set -eu
+
+# #############################################################################
+# This is a pre-commit hook that allows you to respect the code formatting
+# chosen by the Navit team.
+#
+# To install it, create a folder named "hooks" in the .git directory of this
+# project and just symlink this script inside it. Or run the following script
+# from the root directory of the project:
+# mkdir .git/hooks
+# ln -s ${PWD}/scripts/pre-commit ${PWD}/.git/hooks/
+#
+# This will not work on Windows platform unless you are using cygwin.
+# #############################################################################
+
+files=$(git diff --cached --name-only --diff-filter=ACM)
+git_dir=$(git rev-parse --show-toplevel)
+
+# check for common misspells if misspell is installed
+[[ -n "$(which misspell)" ]] && misspell
+if [[ -z "$(which astyle)" ]]; then
+ echo "Unable to find the astyle executable. Please install it to have automatic formatting of your files."
+fi
+
+# Only work on the files that are part of the commit
+for f in $files; do
+ if [[ -e "${git_dir}/${f}" ]]; then
+ if [[ "${f: -4}" != ".bat" ]]; then
+ # Makes sure to not commit ^M
+ [[ -n "$(which dos2unix)" ]] && dos2unix -s -S -q "${git_dir}/${f}"
+ # Removes trailing spaces
+ [[ "$(file -bi """${git_dir}/${f}""")" =~ ^text ]] && sed 's/\s*$//' -i "${git_dir}/${f}"
+ git add "${git_dir}/${f}"
+ fi
+ # Formats any *.c and *.cpp files
+ if [[ "${f: -2}" == ".c" ]] || [[ "${f: -4}" == ".cpp" ]]; then
+ if [[ -n "$(which astyle)" ]]; then
+ astyle --indent=spaces=4 --style=attach -n --max-code-length=120 -xf -xh "${git_dir}/${f}"
+ git add "${git_dir}/${f}"
+ fi
+ fi
+ fi
+done
diff --git a/scripts/publish.sh b/scripts/publish.sh
new file mode 100644
index 000000000..8b564eaa8
--- /dev/null
+++ b/scripts/publish.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+if [ -z $CI ];then
+ echo "This Script needs to be run by CI"
+fi
+if [ -z $CIRCLECI ];then
+ echo "This Script needs to be run on CircleCI"
+fi
+if [[ "${CIRCLE_PROJECT_USERNAME}" != "navit-gps" || "${CIRCLE_BRANCH}" != "trunk" ]]; then
+ echo "Only trunk on navit-gps may upload to the Play Store"
+ exit 0
+fi
+
+set -e
+
+ARCH="arm"
+BINPATH="android-arm/navit/android/bin"
+
+export PATH="/opt/android-sdk-linux/build-tools/25.0.1/":$PATH
+
+cd ~/
+git clone git@github.com:navit-gps/infrastructure-blackbox.git
+cd infrastructure-blackbox/keyrings/
+openssl aes-256-cbc -d -in keystore.gpg -k $KEY > ~/.keystore
+openssl aes-256-cbc -d -in client_secrets.gpg -k $KEY > /root/project/scripts/client_secrets.json
+openssl aes-256-cbc -d -in androidpublisher.gpg -k $KEY > /root/project/androidpublisher.dat
+cd ~/project
+
+pip install google-api-python-client
+
+jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -storepass $SP $BINPATH/navit-$CIRCLE_SHA1-${ARCH}-release-unsigned.apk $key_name
+
+zipalign 4 $BINPATH/navit-$CIRCLE_SHA1-${ARCH}-release-unsigned.apk $BINPATH/navit-$CIRCLE_SHA1-${ARCH}-release-signed.apk
+apksigner verify -v $BINPATH/navit-$CIRCLE_SHA1-${ARCH}-release-signed.apk
+python ~/project/scripts/basic_upload_apks.py org.navitproject.navit $BINPATH/navit-$CIRCLE_SHA1-${ARCH}-release-signed.apk --noauth_local_webserver
diff --git a/ci/run_linux_tests.sh b/scripts/run_linux_tests.sh
index 4c937dc7d..ff91bed6b 100644
--- a/ci/run_linux_tests.sh
+++ b/scripts/run_linux_tests.sh
@@ -15,9 +15,9 @@ linux_test () {
import -window root $CIRCLE_ARTIFACTS/logs_${1}/default.png
# run tests on X11
- bash ~/navit/ci/xdotools.sh ${1}
+ bash ~/navit/scripts/xdotools.sh ${1}
- # python ~/navit/ci/dbus_tests.py $CIRCLE_TEST_REPORTS/
+ # python ~/navit/scripts/dbus_tests.py $CIRCLE_TEST_REPORTS/
# dbus-send --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.navit.quit
# kill navit instance
diff --git a/scripts/setup_14.04_requirements.list b/scripts/setup_14.04_requirements.list
new file mode 100644
index 000000000..efa122c7e
--- /dev/null
+++ b/scripts/setup_14.04_requirements.list
@@ -0,0 +1,2 @@
+wget unzip cmake build-essential gettext librsvg2-bin util-linux git ssh
+sed astyle libprotobuf-c0-dev protobuf-c-compiler bash
diff --git a/ci/setup_android.sh b/scripts/setup_android.sh
index f3ae96900..fee29613b 100644
--- a/ci/setup_android.sh
+++ b/scripts/setup_android.sh
@@ -1,13 +1,16 @@
+#!/bin/bash
+set -e
+
apt-get update && apt-get install -y software-properties-common
add-apt-repository -y ppa:openjdk-r/ppa
-apt-get update && apt-get install -y openjdk-8-jdk wget expect git curl libsaxonb-java ant
+apt-get update && apt-get install -y openjdk-8-jdk wget expect curl libsaxonb-java ant ca-certificates python-pip
apt-get remove -y openjdk-7-jre-headless
export ANDROID_SDK_HOME=/opt/android-sdk-linux
export ANDROID_HOME=/opt/android-sdk-linux
cd /opt && wget -q https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz -O android-sdk.tgz
-cd /opt && tar -xvzf android-sdk.tgz
+cd /opt && tar -xvzf android-sdk.tgz --no-same-owner
cd /opt && rm -f android-sdk.tgz
export PATH=${PATH}:${ANDROID_SDK_HOME}/tools:${ANDROID_SDK_HOME}/platform-tools:/opt/tools
diff --git a/scripts/setup_common_requirements.sh b/scripts/setup_common_requirements.sh
new file mode 100644
index 000000000..0506fff7c
--- /dev/null
+++ b/scripts/setup_common_requirements.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+
+apt-get update && apt-get install -y wget unzip cmake build-essential \
+ gettext librsvg2-bin util-linux git ssh sed astyle \
+ libprotobuf-c-dev protobuf-c-compiler
diff --git a/ci/setup_tomtom_requirements.sh b/scripts/setup_tomtom_requirements.sh
index 00bd33c44..4e8415daf 100644
--- a/ci/setup_tomtom_requirements.sh
+++ b/scripts/setup_tomtom_requirements.sh
@@ -4,7 +4,7 @@
set -e
# install additional packages to build TT evitonment and navit
-apt-get install -y libglib2.0-dev git autogen autoconf libtool imagemagick zip
+apt-get install -y libglib2.0-dev git autogen autoconf libtool zip
dpkg --add-architecture i386
apt-get update
apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386
@@ -17,7 +17,7 @@ cp Toolchain/$ARCH.cmake /tmp
# toolchain
export TOMTOM_SDK_DIR=/opt/tomtom-sdk
-mkdir -p $TOMTOM_SDK_DIR >/dev/null 2>&1 || export TOMTOM_SDK_DIR=$HOME/tomtom-sdk
+mkdir -p $TOMTOM_SDK_DIR >/dev/null 2>&1 || export TOMTOM_SDK_DIR=$HOME/tomtom-sdk
export PREFIX=$TOMTOM_SDK_DIR/gcc-3.3.4_glibc-2.3.2/$ARCH/sys-root
export PATH=$TOMTOM_SDK_DIR/gcc-3.3.4_glibc-2.3.2/bin:$PREFIX/bin/:$PATH
export CFLAGS="-O2 -I$PREFIX/include -I$PREFIX/usr/include"
@@ -33,7 +33,7 @@ export STRIP=$ARCH-strip
export OBJCOPY=$ARCH-objcopy
export LN_S="ln -s"
export PKG_CONFIG_LIBDIR=$PREFIX/lib/pkgconfig
-JOBS=$(nproc --all)
+JOBS=$(nproc --all)
echo "Jobs"
echo $JOBS
@@ -41,12 +41,12 @@ echo $JOBS
mkdir -p ~/tomtom_assets
if ! [ -e "~/tomtom_assets/toolchain_redhat_gcc-3.3.4_glibc-2.3.2-20060131a.tar.gz" ]
- then
+ then
wget -nv -c https://github.com/navit-gps/dependencies/raw/master/tomtom/toolchain_redhat_gcc-3.3.4_glibc-2.3.2-20060131a.tar.gz -P ~/tomtom_assets
fi
if ! test -f "~/tomtom_assets/libpng-1.6.29.tar.gz"
-then
+then
wget -nv -c https://github.com/navit-gps/dependencies/raw/master/tomtom/libpng-1.6.29.tar.gz -P ~/tomtom_assets
fi
@@ -77,7 +77,7 @@ make install
# libpng
cd /tmp/
tar xzf ~/tomtom_assets/libpng-1.6.29.tar.gz
-cd libpng-1.6.29/
+cd libpng-1.6.29/
./configure --prefix=$PREFIX --host=$ARCH
make -j$JOBS
make install
diff --git a/scripts/setup_wince.sh b/scripts/setup_wince.sh
new file mode 100644
index 000000000..66f85abaa
--- /dev/null
+++ b/scripts/setup_wince.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+set -e
+
+mkdir -p /var/lib/apt/lists/partial
+apt-get update
+apt-get install -y git-core
+apt-get install -y xsltproc
diff --git a/scripts/update_download_center.sh b/scripts/update_download_center.sh
new file mode 100644
index 000000000..8e4359717
--- /dev/null
+++ b/scripts/update_download_center.sh
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+
+#############################################
+############# Functions #############
+#############################################
+
+cleanup(){
+ if [ -d $TMP_DIR ]; then
+ rm -rf $TMP_DIR
+ fi
+}
+
+#############################################
+############# Functions END #############
+#############################################
+
+echo "Check the requirements"
+
+if [ -z $CI ];then
+ echo "This Script needs to be run by CI"
+fi
+if [ -z $CIRCLECI ];then
+ echo "This Script needs to be run on CircleCI"
+fi
+if [[ "${CIRCLE_PROJECT_USERNAME}" != "navit-gps" || "${CIRCLE_BRANCH}" != "trunk" ]]; then
+ echo "Only trunk on navit-gps may upload to the Download Center"
+ exit 0
+fi
+
+#############################################
+
+echo "Setting up all Variables"
+
+UUID=${RANDOM}-${RANDOM}-${RANDOM}-${RANDOM}
+TMP_DIR=$(mktemp -d)
+CIRCLECI_API_BASE="https://circleci.com/api/v1.1/"
+NAVIT_DOWNLOAD_CENTER_REPO="git@github.com:navit-gps/download-center"
+
+# To keep it generic
+CVS_TYPE="github"
+REPONAME=$CIRCLE_PROJECT_REPONAME
+USERNAME=$CIRCLE_PROJECT_USERNAME
+BUILD_NUM=$CIRCLE_BUILD_NUM
+JOB_NAME=$CIRCLE_JOB
+
+# Build all api urls
+URL_BUILD_ARTIFACTS="${CIRCLECI_API_BASE}project/${CVS_TYPE}/${USERNAME}/${REPONAME}/${BUILD_NUM}/artifacts"
+echo "Artifact URL: $URL_BUILD_ARTIFACTS"
+
+#############################################
+
+echo "Setup trap for cleanup"
+trap cleanup EXIT
+
+#############################################
+
+echo "Init Git Repo"
+export GIT_TERMINAL_PROMPT=0
+cd $TMP_DIR
+mkdir -p ~/.ssh/
+ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
+git clone $NAVIT_DOWNLOAD_CENTER_REPO $UUID
+if [ ! -d $UUID/_data/$JOB_NAME ]; then
+ mkdir -p $UUID/_data/$JOB_NAME
+fi
+cd $UUID/_data/$JOB_NAME
+
+#############################################
+
+echo "Download metadata of this build"
+wget --no-check-certificate $URL_BUILD_ARTIFACTS -O $(printf "%010d" ${BUILD_NUM}).json
+RC=$?
+if [ $RC -ne 0 ]; then
+ echo "wget artifacts download failed"
+ exit 1
+fi
+
+#############################################
+
+echo "Push update to ${NAVIT_DOWNLOAD_CENTER_REPO}"
+git config --global push.default simple
+git config user.name "Circle CI"
+git config user.email "circleci@navit-project.org"
+git add $(printf "%010d" ${BUILD_NUM}).json
+git commit -m "add:artifacts:Add artifacts for build #${BUILD_NUM} with SHA1:${CIRCLE_SHA1}"
+git push
+RC=$?
+if [ $RC -ne 0 ]; then
+ exit 0
+else
+ echo "Push to ${NAVIT_DOWNLOAD_CENTER_REPO} was not successful update repo and try again..."
+ for NUM in {1..10}; do
+ echo "Retry #${NUM} to push to github"
+ git pull
+ git push
+ RC=$?
+ if [ $RC -eq 0 ]; then
+ exit 0
+ fi
+ sleep $(($RANDOM%5)) # sleep between 1 and 5 seconds
+ done
+fi
+
+echo "Failed to push to github"
+exit 100
diff --git a/scripts/update_doxygen.sh b/scripts/update_doxygen.sh
new file mode 100644
index 000000000..7a76f1fd1
--- /dev/null
+++ b/scripts/update_doxygen.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+set -e
+mkdir -p ~/.ssh/
+ssh-keyscan github.com >> ~/.ssh/known_hosts
+git clone -b gh-pages git@github.com:navit-gps/navit.git /root/navit-doc
+cd /root/navit-doc
+git config --global push.default simple
+git config user.name "Circle CI"
+git config user.email "circleci@navit-project.org"
+rsync -vrtza --exclude '.git' --delete /root/project/doc/html/ /root/navit-doc/
+echo "" > .nojekyll
+echo "doxygen.navit-project.org" > CNAME
+git add .
+git commit -am "update:doc:Doxygen update for commit ${CIRCLE_SHA1} [ci skip]" || true
+git push
diff --git a/ci/xdotools.sh b/scripts/xdotools.sh
index b745d9f39..a9fa65e8d 100644
--- a/ci/xdotools.sh
+++ b/scripts/xdotools.sh
@@ -1,3 +1,5 @@
+#!/usr/bin/env bash
+set -e
sudo apt-get install xdotool
# Use xinput test 4 when running x11vnc on the circleci server to find mouse coordinates
@@ -9,11 +11,11 @@ LOGS_DIR=$CIRCLE_ARTIFACTS/logs_${1}
event=0
send_event (){
- file=`printf "%05d\n" $event`
+ file=$(printf "%05d\n" $event)
import -window root $FRAME_DIR/tmp.png
if [[ "$1" == "mousemove" ]]; then
- composite -gravity NorthWest -geometry +$2+$3 ~/navit/ci/pointer-64.png $FRAME_DIR/tmp.png $FRAME_DIR/${file}.png
+ composite -gravity NorthWest -geometry +$2+$3 ~/navit/scripts/pointer-64.png $FRAME_DIR/tmp.png $FRAME_DIR/${file}.png
else
mv $FRAME_DIR/tmp.png $FRAME_DIR/${file}.png
fi
@@ -80,7 +82,7 @@ send_event key KP_Enter # Validate
# Send 'Berk'
# capture 5 seconds of usage
-for i in `seq 99994 99999`; do
+for i in $(seq 99994 99999); do
import -window root $FRAME_DIR/${i}.png
sleep 1
done
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 000000000..5cac9edd2
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include 'navit:android'